nuxt-files-sdk 0.1.1 → 0.2.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.
Files changed (94) hide show
  1. package/dist/config/evaluate.js +149 -0
  2. package/dist/config/load.js +22 -40
  3. package/dist/config/merge.d.ts +1 -2
  4. package/dist/config/merge.js +0 -2
  5. package/dist/config/prepare.js +58 -0
  6. package/dist/config/prune.js +8 -9
  7. package/dist/config.d.ts +11 -6
  8. package/dist/config.js +0 -2
  9. package/dist/devtools/auth.js +0 -2
  10. package/dist/devtools/client/app.js +2 -2
  11. package/dist/devtools/client/index.html +4 -0
  12. package/dist/devtools/devframe.js +1 -3
  13. package/dist/devtools/diagnostics.d.ts +1 -2
  14. package/dist/devtools/diagnostics.js +0 -2
  15. package/dist/devtools/enabled.d.ts +1 -2
  16. package/dist/devtools/enabled.js +0 -2
  17. package/dist/devtools/files-read.d.ts +2 -3
  18. package/dist/devtools/files-read.js +0 -2
  19. package/dist/devtools/files-write.d.ts +2 -3
  20. package/dist/devtools/files-write.js +0 -2
  21. package/dist/devtools/files.js +7 -10
  22. package/dist/devtools/index.js +24 -26
  23. package/dist/devtools/nuxt-v3-handler.d.ts +1 -2
  24. package/dist/devtools/nuxt-v3-handler.js +0 -2
  25. package/dist/devtools/nuxt-v3.js +1 -3
  26. package/dist/devtools/nuxt-v4.js +4 -7
  27. package/dist/devtools/paths.js +8 -0
  28. package/dist/devtools/snapshot.d.ts +5 -14
  29. package/dist/devtools/snapshot.js +2 -9
  30. package/dist/devtools/token.d.ts +1 -2
  31. package/dist/devtools/token.js +0 -2
  32. package/dist/integration/capabilities.js +17 -0
  33. package/dist/integration/dependencies.d.ts +12 -0
  34. package/dist/integration/dependencies.js +67 -0
  35. package/dist/integration/diagnostics.d.ts +9 -0
  36. package/dist/integration/diagnostics.js +80 -0
  37. package/dist/integration/imports.js +83 -0
  38. package/dist/integration/nitro-dev-close.js +13 -0
  39. package/dist/integration/nitro-event.d.ts +7 -0
  40. package/dist/integration/nitro-event.js +24 -0
  41. package/dist/integration/nitro.d.ts +9 -2
  42. package/dist/integration/nitro.js +170 -91
  43. package/dist/integration/nuxt-diagnostics.js +23 -0
  44. package/dist/integration/nuxt.js +235 -0
  45. package/dist/integration/resolve.d.ts +1 -0
  46. package/dist/integration/resolve.js +113 -0
  47. package/dist/integration/terminal.js +20 -0
  48. package/dist/integration/update.js +59 -0
  49. package/dist/meta.js +8 -0
  50. package/dist/module.d.ts +1 -8
  51. package/dist/module.js +74 -59
  52. package/dist/module.json +8 -0
  53. package/dist/nitro.d.ts +1 -2
  54. package/dist/nitro.js +7 -7
  55. package/dist/package.js +1 -3
  56. package/dist/runtime/development.d.ts +5 -0
  57. package/dist/runtime/development.js +14 -0
  58. package/dist/runtime/gateway-secret.d.ts +4 -0
  59. package/dist/runtime/gateway-secret.js +10 -0
  60. package/dist/runtime/internal.d.ts +1 -2
  61. package/dist/runtime/internal.js +1 -2
  62. package/dist/runtime/normalize.d.ts +1 -0
  63. package/dist/runtime/normalize.js +0 -2
  64. package/dist/runtime/provider-types.d.ts +1 -2
  65. package/dist/runtime/registry.d.ts +9 -22
  66. package/dist/runtime/registry.js +23 -28
  67. package/dist/runtime.d.ts +1 -2
  68. package/dist/runtime.js +0 -2
  69. package/package.json +247 -13
  70. package/dist/config/load.js.map +0 -1
  71. package/dist/config/merge.js.map +0 -1
  72. package/dist/config/prune.js.map +0 -1
  73. package/dist/config.js.map +0 -1
  74. package/dist/devtools/auth.js.map +0 -1
  75. package/dist/devtools/devframe.js.map +0 -1
  76. package/dist/devtools/diagnostics.js.map +0 -1
  77. package/dist/devtools/enabled.js.map +0 -1
  78. package/dist/devtools/files-read.js.map +0 -1
  79. package/dist/devtools/files-write.js.map +0 -1
  80. package/dist/devtools/files.js.map +0 -1
  81. package/dist/devtools/index.js.map +0 -1
  82. package/dist/devtools/nuxt-v3-handler.js.map +0 -1
  83. package/dist/devtools/nuxt-v3.js.map +0 -1
  84. package/dist/devtools/nuxt-v4.js.map +0 -1
  85. package/dist/devtools/snapshot.js.map +0 -1
  86. package/dist/devtools/token.js.map +0 -1
  87. package/dist/integration/nitro.js.map +0 -1
  88. package/dist/module.js.map +0 -1
  89. package/dist/nitro.js.map +0 -1
  90. package/dist/package.js.map +0 -1
  91. package/dist/runtime/internal.js.map +0 -1
  92. package/dist/runtime/normalize.js.map +0 -1
  93. package/dist/runtime/registry.js.map +0 -1
  94. package/dist/runtime.js.map +0 -1
@@ -0,0 +1,8 @@
1
+ //#region src/devtools/paths.ts
2
+ const FILES_DEVTOOLS_PATH = "/__nuxt-files-sdk/";
3
+ const FILES_SNAPSHOT_PATH = "/__nuxt-files-api/snapshot";
4
+ const FILES_GATEWAY_PATH = "/__nuxt-files-api/files";
5
+ const FILES_TOKEN_PATH = "/__nuxt-files-api/token";
6
+ const FILES_DEVTOOLS_MAX_UPLOAD_SIZE = 10485760;
7
+ //#endregion
8
+ export { FILES_DEVTOOLS_MAX_UPLOAD_SIZE, FILES_DEVTOOLS_PATH, FILES_GATEWAY_PATH, FILES_SNAPSHOT_PATH, FILES_TOKEN_PATH };
@@ -1,4 +1,6 @@
1
+ import { DependencyDiagnostic } from "../integration/diagnostics.js";
1
2
  import { FilesDevtoolsDiagnostic } from "./diagnostics.js";
3
+ import { RequestEvent } from "@nuxt/schema";
2
4
  //#region src/devtools/snapshot.d.ts
3
5
  export interface FilesDevtoolsSnapshot {
4
6
  storages: Array<{
@@ -8,19 +10,8 @@ export interface FilesDevtoolsSnapshot {
8
10
  initialized: boolean;
9
11
  }>;
10
12
  diagnostics: FilesDevtoolsDiagnostic[];
13
+ dependencies: DependencyDiagnostic[];
11
14
  }
12
- export declare const FILES_DEVTOOLS_PATH = "/__nuxt-files-sdk/";
13
- export declare const FILES_SNAPSHOT_PATH = "/__nuxt-files-sdk/snapshot";
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>;
15
+ declare function _default(event: RequestEvent, secret: string): Promise<Response>;
24
16
  //#endregion
25
- export { _default as default };
26
- //# sourceMappingURL=snapshot.d.ts.map
17
+ export { _default as default };
@@ -2,13 +2,8 @@ import { inspectFiles } from "../runtime/internal.js";
2
2
  import { authorizeFilesDevtoolsRequest } from "./auth.js";
3
3
  import { createFilesDevtoolsDiagnostic } from "./diagnostics.js";
4
4
  //#region src/devtools/snapshot.ts
5
- const FILES_DEVTOOLS_PATH = "/__nuxt-files-sdk/";
6
- const FILES_SNAPSHOT_PATH = `${FILES_DEVTOOLS_PATH}snapshot`;
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
5
  var snapshot_default = async (event, secret) => {
11
- if (!await authorizeFilesDevtoolsRequest(event.node.req, secret)) return new Response(null, { status: 401 });
6
+ if (!await authorizeFilesDevtoolsRequest(event.req, secret)) return new Response(null, { status: 401 });
12
7
  const snapshot = inspectFiles();
13
8
  return Response.json({
14
9
  ...snapshot,
@@ -16,6 +11,4 @@ var snapshot_default = async (event, secret) => {
16
11
  });
17
12
  };
18
13
  //#endregion
19
- export { FILES_DEVTOOLS_MAX_UPLOAD_SIZE, FILES_DEVTOOLS_PATH, FILES_GATEWAY_PATH, FILES_SNAPSHOT_PATH, FILES_TOKEN_PATH, snapshot_default as default };
20
-
21
- //# sourceMappingURL=snapshot.js.map
14
+ export { snapshot_default as default };
@@ -10,5 +10,4 @@ declare function _default(event: {
10
10
  };
11
11
  }, secret: string, authorize: (token: string) => Promise<void>): Promise<Response>;
12
12
  //#endregion
13
- export { _default as default };
14
- //# sourceMappingURL=token.d.ts.map
13
+ export { _default as default };
@@ -13,5 +13,3 @@ var token_default = async (event, secret, authorize) => {
13
13
  };
14
14
  //#endregion
15
15
  export { token_default as default };
16
-
17
- //# sourceMappingURL=token.js.map
@@ -0,0 +1,17 @@
1
+ //#region src/integration/capabilities.ts
2
+ /** Public API selection is evidence of an adapter, not a promise of arbitrary builder features. */
3
+ const filesBuilderCapabilities = (api) => {
4
+ const nitro = api === "nitro2" || api === "nitro3";
5
+ return {
6
+ runtime: true,
7
+ gateway: nitro,
8
+ devtools: nitro,
9
+ nitroHooks: nitro,
10
+ experimental: !nitro
11
+ };
12
+ };
13
+ const requireFilesGateway = (enabled, available) => {
14
+ if (enabled && !available) throw new Error("[nuxt-files-sdk:gateway-unavailable] The selected server builder cannot mount Files Gateway routes.");
15
+ };
16
+ //#endregion
17
+ export { filesBuilderCapabilities, requireFilesGateway };
@@ -0,0 +1,12 @@
1
+ import "../runtime/normalize.js";
2
+ //#region src/integration/dependencies.d.ts
3
+ export interface DependencyRequirement {
4
+ storage?: string;
5
+ subpath: string;
6
+ dependency: string;
7
+ necessity: 'required' | 'conditional' | 'unknown';
8
+ stage: 'import' | 'construction' | 'operation';
9
+ reason: string;
10
+ conditions?: string[];
11
+ }
12
+ //#endregion
@@ -0,0 +1,67 @@
1
+ //#region src/integration/dependencies.ts
2
+ const aws = [
3
+ "@aws-sdk/client-s3",
4
+ "@aws-sdk/s3-presigned-post",
5
+ "@aws-sdk/s3-request-presigner"
6
+ ];
7
+ const unknownValue = Symbol("runtime value");
8
+ const field = (object, key) => {
9
+ if (typeof object === "function") return unknownValue;
10
+ if (!object || typeof object !== "object") return void 0;
11
+ for (let current = object; current; current = Object.getPrototypeOf(current)) {
12
+ const descriptor = Object.getOwnPropertyDescriptor(current, key);
13
+ if (descriptor) return "value" in descriptor ? descriptor.value : unknownValue;
14
+ }
15
+ };
16
+ /** Pure structural analysis: never calls config resolvers, clients, factories or credentials. */
17
+ const storageDependencies = (entry, target, imports) => {
18
+ const adapter = entry.storage.adapter;
19
+ if (typeof adapter !== "string") return [];
20
+ const subpath = `files-sdk/${adapter}`;
21
+ const requirement = (dependency, necessity, stage, reason) => ({
22
+ ...entry.name === void 0 ? {} : { storage: entry.name },
23
+ subpath,
24
+ dependency,
25
+ necessity,
26
+ stage,
27
+ reason
28
+ });
29
+ const result = imports.map((entryImport) => ({
30
+ ...entryImport,
31
+ ...entry.name === void 0 ? {} : { storage: entry.name }
32
+ }));
33
+ let usesAws = imports.some(({ dependency }) => dependency === "@aws-sdk/client-s3");
34
+ if (adapter === "r2" || adapter === "minio" || adapter === "rustfs") {
35
+ const binding = adapter === "r2" ? field(entry.storage.config, "binding") : void 0;
36
+ const client = field(entry.storage.config, "client");
37
+ usesAws = binding === unknownValue || client === unknownValue ? void 0 : binding || client === "fetch" ? false : client === "aws-sdk" ? true : target === "node" || target === "bun" ? true : void 0;
38
+ if (usesAws !== false) result.push(...aws.map((dependency) => requirement(dependency, usesAws ? "required" : "unknown", "operation", "AWS engine selected at runtime unless client is explicit")));
39
+ }
40
+ if (usesAws !== false) result.push(requirement("@aws-sdk/lib-storage", usesAws ? "conditional" : "unknown", "operation", "Multipart, progress or unknown-length uploads only"));
41
+ if (adapter === "firebase-storage") {
42
+ const app = field(entry.storage.config, "app");
43
+ const file = field(app, "file");
44
+ const getFiles = field(app, "getFiles");
45
+ const injectedBucket = typeof file === "function" && typeof getFiles === "function";
46
+ const unknown = app === unknownValue || file === unknownValue || getFiles === unknownValue;
47
+ if (!injectedBucket) {
48
+ if (!app || unknown) result.push({
49
+ ...requirement("firebase-admin/app", unknown ? "unknown" : "required", "construction", "Create the Firebase app"),
50
+ conditions: ["node", "require"]
51
+ });
52
+ result.push({
53
+ ...requirement("firebase-admin/storage", unknown ? "unknown" : "required", "construction", "Resolve a bucket from the Firebase app"),
54
+ conditions: ["node", "require"]
55
+ });
56
+ }
57
+ }
58
+ return result;
59
+ };
60
+ const deploymentTarget = (preset) => {
61
+ if (preset?.startsWith("cloudflare")) return "workerd";
62
+ if (preset === "bun") return "bun";
63
+ if (preset === "node" || preset?.startsWith("node-")) return "node";
64
+ return "unknown";
65
+ };
66
+ //#endregion
67
+ export { deploymentTarget, storageDependencies };
@@ -0,0 +1,9 @@
1
+ import { DependencyRequirement } from "./dependencies.js";
2
+ import "./resolve.js";
3
+ //#region src/integration/diagnostics.d.ts
4
+ export interface DependencyDiagnostic extends DependencyRequirement {
5
+ status: 'satisfied' | 'missing' | 'incompatible' | 'unresolved' | 'unknown';
6
+ range?: string;
7
+ version?: string;
8
+ }
9
+ //#endregion
@@ -0,0 +1,80 @@
1
+ import { resolvePackage, sdkEntry } from "./resolve.js";
2
+ import { pathToFileURL } from "node:url";
3
+ import { satisfies } from "verkit";
4
+ //#region src/integration/diagnostics.ts
5
+ /** Resolution and version inspection are silent, even for uncertain aliases and optional operations. */
6
+ const diagnoseDependencies = (sdk, requirements, aliases = {}, shims = []) => requirements.map((requirement) => {
7
+ const name = requirement.dependency.split("/").slice(0, requirement.dependency.startsWith("@") ? 2 : 1).join("/");
8
+ const range = sdk.manifest.peerDependencies?.[name];
9
+ const base = {
10
+ ...requirement,
11
+ ...range ? { range } : {}
12
+ };
13
+ if (requirement.necessity !== "required") return {
14
+ ...base,
15
+ status: "unknown"
16
+ };
17
+ if (Object.keys(aliases).some((alias) => !shims.includes(alias) && (requirement.dependency === alias || requirement.dependency.startsWith(`${alias}/`)))) return {
18
+ ...base,
19
+ status: "unknown"
20
+ };
21
+ const resolved = resolvePackage(requirement.dependency, pathToFileURL(sdkEntry(sdk, requirement.subpath)), requirement.conditions);
22
+ if (resolved.status !== "resolved") return {
23
+ ...base,
24
+ status: resolved.status
25
+ };
26
+ const version = resolved.package.manifest.version;
27
+ if (!version || !range) return {
28
+ ...base,
29
+ status: "unknown"
30
+ };
31
+ try {
32
+ return {
33
+ ...base,
34
+ version,
35
+ status: satisfies(version, range) ? "satisfied" : "incompatible"
36
+ };
37
+ } catch {
38
+ return {
39
+ ...base,
40
+ status: "unknown"
41
+ };
42
+ }
43
+ });
44
+ /** The caller retains state across setup, generation and internal worker restarts. */
45
+ const reportDependencyIssues = (diagnostics, previous, warn) => {
46
+ const issues = diagnostics.filter((entry) => entry.necessity === "required" && (entry.status === "missing" || entry.status === "incompatible" || entry.status === "unresolved"));
47
+ const current = new Set(issues.map((entry) => JSON.stringify([
48
+ entry.storage,
49
+ entry.subpath,
50
+ entry.dependency,
51
+ entry.status,
52
+ entry.range,
53
+ entry.version
54
+ ])));
55
+ const fresh = issues.filter((entry) => !previous.has(JSON.stringify([
56
+ entry.storage,
57
+ entry.subpath,
58
+ entry.dependency,
59
+ entry.status,
60
+ entry.range,
61
+ entry.version
62
+ ])));
63
+ previous.clear();
64
+ for (const key of current) previous.add(key);
65
+ if (!fresh.length) return;
66
+ warn(`[nuxt-files-sdk:dependencies] ${[...new Set(fresh.map((entry) => {
67
+ return `${entry.storage === void 0 ? entry.subpath : `${entry.storage} (${entry.subpath})`}: ${entry.dependency} ${entry.status}${entry.version ? ` (${entry.version})` : ""}; ${entry.status === "unresolved" ? "check its public exports and aliases" : `install a version matching ${entry.range}`}`;
68
+ }))].join("\n")}`);
69
+ };
70
+ const sessions = /* @__PURE__ */ new Map();
71
+ const dependencySession = (root) => {
72
+ let state = sessions.get(root);
73
+ if (!state) {
74
+ state = /* @__PURE__ */ new Set();
75
+ sessions.set(root, state);
76
+ }
77
+ return state;
78
+ };
79
+ //#endregion
80
+ export { dependencySession, diagnoseDependencies, reportDependencyIssues };
@@ -0,0 +1,83 @@
1
+ import { sdkEntry } from "./resolve.js";
2
+ import { dirname, isAbsolute, resolve } from "node:path";
3
+ import { readFileSync } from "node:fs";
4
+ import { pathToFileURL } from "node:url";
5
+ import { resolveModulePath } from "exsolve";
6
+ import { parseSync } from "oxc-parser";
7
+ //#region src/integration/imports.ts
8
+ /** Follow local and Layer imports from their actual importer, without discovering/merging configs. */
9
+ const configSources = (filename, aliases = {}) => {
10
+ const files = /* @__PURE__ */ new Set();
11
+ const sdkImports = /* @__PURE__ */ new Set();
12
+ const visit = (path) => {
13
+ path = resolve(path);
14
+ if (files.has(path)) return;
15
+ files.add(path);
16
+ let source;
17
+ try {
18
+ source = readFileSync(path, "utf8");
19
+ } catch {
20
+ return;
21
+ }
22
+ for (const specifier of sourceImports(path, source)) {
23
+ if (specifier === "#files-sdk" || specifier.startsWith("#files-sdk/")) {
24
+ sdkImports.add(specifier.slice(1));
25
+ continue;
26
+ }
27
+ const alias = Object.keys(aliases).toSorted((a, b) => b.length - a.length).find((key) => specifier === key || specifier.startsWith(`${key}/`));
28
+ const target = alias ? aliases[alias] + specifier.slice(alias.length) : specifier;
29
+ if (!target.startsWith(".") && !isAbsolute(target)) continue;
30
+ const entry = resolveModulePath(target, {
31
+ from: pathToFileURL(path),
32
+ cache: false,
33
+ try: true,
34
+ extensions: [
35
+ ".ts",
36
+ ".mts",
37
+ ".js",
38
+ ".mjs",
39
+ ".cts",
40
+ ".cjs",
41
+ ".json"
42
+ ],
43
+ suffixes: ["", "/index"]
44
+ });
45
+ if (entry) visit(entry);
46
+ else files.add(resolve(dirname(path), target));
47
+ }
48
+ };
49
+ visit(filename);
50
+ return {
51
+ files: [...files],
52
+ sdkImports: [...sdkImports]
53
+ };
54
+ };
55
+ /** Runtime imports only; type-only references never require optional SDK installation. */
56
+ const sourceImports = (filename, source) => {
57
+ const { module } = parseSync(filename, source);
58
+ return [.../* @__PURE__ */ new Set([...module.staticImports.filter((entry) => !entry.entries.length || entry.entries.some((binding) => !binding.isType)).map((entry) => entry.moduleRequest.value), ...module.staticExports.flatMap((entry) => entry.entries.filter((binding) => !binding.isType && binding.moduleRequest).map((binding) => binding.moduleRequest.value))])];
59
+ };
60
+ /** Read the selected public entry's static graph; never import or execute it. */
61
+ const subpathDependencies = (sdk, subpath) => {
62
+ const seen = /* @__PURE__ */ new Set();
63
+ const found = /* @__PURE__ */ new Set();
64
+ const visit = (filename) => {
65
+ if (seen.has(filename)) return;
66
+ seen.add(filename);
67
+ for (const specifier of sourceImports(filename, readFileSync(filename, "utf8"))) if (specifier.startsWith(".")) visit(resolve(dirname(filename), specifier));
68
+ else {
69
+ const name = specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/");
70
+ if (sdk.manifest.peerDependencies?.[name]) found.add(specifier);
71
+ }
72
+ };
73
+ visit(sdkEntry(sdk, subpath));
74
+ return [...found].map((dependency) => ({
75
+ subpath,
76
+ dependency,
77
+ necessity: "required",
78
+ stage: "import",
79
+ reason: "Static public SDK import"
80
+ }));
81
+ };
82
+ //#endregion
83
+ export { configSources, sourceImports, subpathDependencies };
@@ -0,0 +1,13 @@
1
+ //#region src/integration/nitro-dev-close.ts
2
+ /** Stop late Nitro 2 build events from recreating a development worker during Nuxt shutdown. */
3
+ const stopNitroDevReloadOnClose = (instance) => {
4
+ const hooks = instance?.hooks;
5
+ if (typeof hooks?.hook !== "function" || typeof hooks.callHookWith !== "function" || typeof hooks.removeHook !== "function") return;
6
+ const callHookWith = hooks.callHookWith.bind(hooks);
7
+ const removeHook = hooks.removeHook.bind(hooks);
8
+ hooks.hook("close", () => callHookWith((callbacks) => {
9
+ for (const callback of callbacks) removeHook("dev:reload", callback);
10
+ }, "dev:reload"));
11
+ };
12
+ //#endregion
13
+ export { stopNitroDevReloadOnClose };
@@ -0,0 +1,7 @@
1
+ import { RequestEvent } from "@nuxt/schema";
2
+ //#region src/integration/nitro-event.d.ts
3
+ /** Adapt standalone Nitro only. Nuxt handlers already receive its public RequestEvent. */
4
+ export declare const nitroRequestEvent: (req: Request, context: RequestEvent['context']) => RequestEvent;
5
+ /** Preserve response changes made by portable authorization callbacks. */
6
+ export declare const nitroResponse: (response: Response, event: RequestEvent) => Response;
7
+ //#endregion
@@ -0,0 +1,24 @@
1
+ //#region src/integration/nitro-event.ts
2
+ /** Adapt standalone Nitro only. Nuxt handlers already receive its public RequestEvent. */
3
+ const nitroRequestEvent = (req, context) => ({
4
+ req,
5
+ url: new URL(req.url),
6
+ context,
7
+ res: { headers: new Headers() }
8
+ });
9
+ /** Preserve response changes made by portable authorization callbacks. */
10
+ const nitroResponse = (response, event) => {
11
+ const headers = new Headers(response.headers);
12
+ for (const [name, value] of event.res.headers) if (name !== "set-cookie") headers.set(name, value);
13
+ if (event.res.headers.has("set-cookie")) {
14
+ headers.delete("set-cookie");
15
+ for (const cookie of event.res.headers.getSetCookie()) headers.append("set-cookie", cookie);
16
+ }
17
+ return new Response(response.body, {
18
+ status: event.res.status ?? response.status,
19
+ statusText: event.res.statusText ?? response.statusText,
20
+ headers
21
+ });
22
+ };
23
+ //#endregion
24
+ export { nitroRequestEvent, nitroResponse };
@@ -1,11 +1,16 @@
1
+ import "./resolve.js";
1
2
  import { ProviderSlug } from "files-sdk";
2
3
  //#region src/integration/nitro.d.ts
3
4
  export interface NitroIntegration {
5
+ logger?: {
6
+ warn(message: string): void;
7
+ };
4
8
  meta?: {
5
9
  majorVersion?: number;
6
10
  };
7
11
  options: {
8
12
  rootDir: string;
13
+ workspaceDir?: string;
9
14
  buildDir: string;
10
15
  dev?: boolean;
11
16
  static?: boolean;
@@ -16,6 +21,7 @@ export interface NitroIntegration {
16
21
  handler: string;
17
22
  }[];
18
23
  alias?: Record<string, string>;
24
+ virtual?: Record<string, string>;
19
25
  externals?: {
20
26
  inline?: unknown[];
21
27
  };
@@ -32,6 +38,8 @@ export interface NitroIntegration {
32
38
  };
33
39
  };
34
40
  hooks: {
41
+ callHook?(name: 'restart'): Promise<void>;
42
+ hook(name: 'close', callback: () => void): void;
35
43
  hook(name: 'types:extend', callback: (types: {
36
44
  tsConfig?: {
37
45
  include?: string[];
@@ -42,5 +50,4 @@ export interface NitroIntegration {
42
50
  }) => void | Promise<void>): void;
43
51
  };
44
52
  }
45
- //#endregion
46
- //# sourceMappingURL=nitro.d.ts.map
53
+ //#endregion