nuxt-files-sdk 0.1.0 → 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 +14 -13
  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 +171 -92
  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 +248 -14
  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,113 @@
1
+ import { dirname, join } from "node:path";
2
+ import { existsSync, readFileSync, realpathSync } from "node:fs";
3
+ import { pathToFileURL } from "node:url";
4
+ import { createRequire } from "node:module";
5
+ import { resolveModulePath } from "exsolve";
6
+ import { getPackageInfoSync, resolveModule } from "local-pkg";
7
+ import { exports } from "resolve.exports";
8
+ //#region src/integration/resolve.ts
9
+ const packageName = (specifier) => specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/");
10
+ /** Resolve first to keep local-pkg silent when an optional dependency is absent. */
11
+ const packageInfo = (specifier, from) => {
12
+ const name = packageName(specifier);
13
+ const entry = resolveModule(specifier, { paths: [from.href] });
14
+ if (entry) {
15
+ const info = getPackageInfoSync(entry);
16
+ if (info?.packageJson.name === name) {
17
+ const manifestPath = realpathSync(info.packageJsonPath);
18
+ return {
19
+ manifest: {
20
+ ...info.packageJson,
21
+ name,
22
+ version: info.version ?? ""
23
+ },
24
+ manifestPath,
25
+ root: dirname(manifestPath)
26
+ };
27
+ }
28
+ }
29
+ for (const directory of createRequire(from).resolve.paths(name) ?? []) {
30
+ const path = join(directory, name, "package.json");
31
+ if (!existsSync(path)) continue;
32
+ const manifest = JSON.parse(readFileSync(path, "utf8"));
33
+ if (manifest.name !== name) continue;
34
+ const manifestPath = realpathSync(path);
35
+ return {
36
+ manifest,
37
+ manifestPath,
38
+ root: dirname(manifestPath)
39
+ };
40
+ }
41
+ };
42
+ const resolvePackage = (specifier, from, conditions = ["node", "import"]) => {
43
+ const info = packageInfo(specifier, from);
44
+ if (!info) return { status: "missing" };
45
+ const entry = publicEntry(info, specifier, conditions);
46
+ return entry ? {
47
+ status: "resolved",
48
+ entry: entry.replaceAll("\\", "/"),
49
+ package: info
50
+ } : {
51
+ status: "unresolved",
52
+ package: info
53
+ };
54
+ };
55
+ const resolveOwnedSdk = (from = import.meta.url) => {
56
+ const result = resolvePackage("files-sdk", new URL(from));
57
+ if (result.status !== "resolved") throw new Error("[nuxt-files-sdk:sdk-resolution] The owned Files SDK dependency could not be resolved.");
58
+ return result.package;
59
+ };
60
+ const publicEntry = (info, specifier, conditions) => {
61
+ try {
62
+ const suffix = specifier.slice(info.manifest.name.length);
63
+ const target = info.manifest.exports ? exports(info.manifest, `.${suffix}`, {
64
+ conditions,
65
+ unsafe: true
66
+ })?.[0] : suffix ? `.${suffix}` : info.manifest.main || "./index.js";
67
+ if (!target) return void 0;
68
+ return resolveModulePath(new URL(target, pathToFileURL(info.manifestPath)).href, {
69
+ conditions,
70
+ cache: false,
71
+ try: true,
72
+ extensions: [
73
+ ".js",
74
+ ".json",
75
+ ".node"
76
+ ],
77
+ suffixes: ["", "/index"]
78
+ });
79
+ } catch {
80
+ return;
81
+ }
82
+ };
83
+ const sdkEntry = (sdk, subpath, conditions = ["node", "import"]) => {
84
+ const entry = publicEntry(sdk, subpath, conditions);
85
+ if (!entry) throw new Error(`[nuxt-files-sdk:sdk-exports] Cannot resolve public entry ${subpath}.`);
86
+ return entry.replaceAll("\\", "/");
87
+ };
88
+ /** Enumerate public subpaths without evaluating providers. Root comes last for prefix alias engines. */
89
+ const sdkAliases = (sdk, conditions = ["node", "import"]) => Object.fromEntries(Object.keys(sdk.manifest.exports ?? {}).toSorted((a, b) => b.length - a.length).map((key) => {
90
+ if (key !== "." && (!key.startsWith("./") || key.includes("*"))) throw new Error(`[nuxt-files-sdk:sdk-exports] Unsupported public export pattern: ${key}`);
91
+ const suffix = key === "." ? "" : key.slice(1);
92
+ return [`#files-sdk${suffix}`, sdkEntry(sdk, `files-sdk${suffix}`, conditions)];
93
+ }));
94
+ const registerSdkAliases = (aliases, sdk, conditions = ["node", "import"]) => {
95
+ const selected = sdkAliases(sdk, conditions);
96
+ let node;
97
+ let browser;
98
+ for (const [name, path] of Object.entries(aliases)) {
99
+ if (name !== "#files-sdk" && !name.startsWith("#files-sdk/")) continue;
100
+ const normalized = path.replaceAll("\\", "/");
101
+ if (selected[name] === normalized) continue;
102
+ node ??= sdkAliases(sdk);
103
+ browser ??= sdkAliases(sdk, ["browser", "import"]);
104
+ if (![node[name], browser[name]].includes(normalized)) throw new Error(`[nuxt-files-sdk:reserved-alias] ${name} must refer to the owned Files SDK.`);
105
+ }
106
+ return {
107
+ ...selected,
108
+ ...Object.fromEntries(Object.entries(aliases).filter(([name]) => !(name in selected)))
109
+ };
110
+ };
111
+ const sdkTypePaths = (sdk) => Object.fromEntries(Object.entries(sdkAliases(sdk, ["types", "import"])).map(([name, entry]) => [name, [entry]]));
112
+ //#endregion
113
+ export { packageInfo, registerSdkAliases, resolveOwnedSdk, resolvePackage, sdkAliases, sdkEntry, sdkTypePaths };
@@ -0,0 +1,20 @@
1
+ //#region src/integration/terminal.ts
2
+ /** Short work is quiet. A visible task always terminates with its actual outcome. */
3
+ const withFilesTask = async (terminal, label, work, delay = 500) => {
4
+ let task;
5
+ let outcome = "failure";
6
+ const timer = setTimeout(() => {
7
+ task = terminal.startTask(label);
8
+ }, delay);
9
+ timer.unref();
10
+ try {
11
+ const result = await work();
12
+ outcome = "success";
13
+ return result;
14
+ } finally {
15
+ clearTimeout(timer);
16
+ task?.stop(void 0, outcome);
17
+ }
18
+ };
19
+ //#endregion
20
+ export { withFilesTask };
@@ -0,0 +1,59 @@
1
+ import { fileHash } from "../runtime/development.js";
2
+ import { unwatchFile, watchFile } from "node:fs";
3
+ import { readFile, writeFile } from "node:fs/promises";
4
+ //#region src/integration/update.ts
5
+ const writeChanged = async (path, content) => {
6
+ if (await readFile(path, "utf8").catch(() => void 0) !== content) await writeFile(path, content);
7
+ };
8
+ /** Poll specific inputs, including missing lockfiles, without watching generated output. */
9
+ const watchFiles = (paths, changed, failed) => {
10
+ const listeners = /* @__PURE__ */ new Map();
11
+ let timer;
12
+ let pending = false;
13
+ let running = false;
14
+ let closed = false;
15
+ const run = async () => {
16
+ if (closed || running || !pending) return;
17
+ pending = false;
18
+ running = true;
19
+ try {
20
+ await changed();
21
+ } catch (error) {
22
+ failed(error);
23
+ } finally {
24
+ running = false;
25
+ if (pending && !closed) run();
26
+ }
27
+ };
28
+ const add = (files) => {
29
+ for (const path of files) {
30
+ if (listeners.has(path)) continue;
31
+ let hash = fileHash(path);
32
+ const listener = () => {
33
+ const next = fileHash(path);
34
+ if (hash === next) return;
35
+ hash = next;
36
+ pending = true;
37
+ clearTimeout(timer);
38
+ timer = setTimeout(() => void run(), 100);
39
+ timer.unref();
40
+ };
41
+ listeners.set(path, listener);
42
+ watchFile(path, {
43
+ interval: 250,
44
+ persistent: false
45
+ }, listener);
46
+ }
47
+ };
48
+ add(paths);
49
+ return {
50
+ add,
51
+ close() {
52
+ closed = true;
53
+ clearTimeout(timer);
54
+ for (const [path, listener] of listeners) unwatchFile(path, listener);
55
+ }
56
+ };
57
+ };
58
+ //#endregion
59
+ export { watchFiles, writeChanged };
package/dist/meta.js ADDED
@@ -0,0 +1,8 @@
1
+ //#region src/meta.ts
2
+ const moduleMeta = {
3
+ name: "nuxt-files-sdk",
4
+ configKey: "files",
5
+ compatibility: { nuxt: "^4.6.0 || ^5.0.0-0" }
6
+ };
7
+ //#endregion
8
+ export { moduleMeta };
package/dist/module.d.ts CHANGED
@@ -1,11 +1,5 @@
1
1
  import { FilesDevtoolsOptions } from "./devtools/enabled.js";
2
- import { NitroIntegration } from "./integration/nitro.js";
3
2
  //#region src/module.d.ts
4
- declare module '@nuxt/schema' {
5
- interface NuxtHooks {
6
- 'nitro:init': (nitro: NitroIntegration) => void | Promise<void>;
7
- }
8
- }
9
3
  /** Options for the Nuxt Files SDK module. */
10
4
  export interface ModuleOptions {
11
5
  /** Path to the Files configuration module, relative to the Nuxt root directory. */
@@ -16,5 +10,4 @@ export interface ModuleOptions {
16
10
  /** Install Files SDK storage configuration, server utilities, Vue composables, and development diagnostics in Nuxt. */
17
11
  declare const _default: import("@nuxt/schema").NuxtModule<ModuleOptions, ModuleOptions, false>;
18
12
  //#endregion
19
- export { type FilesDevtoolsOptions, _default as default };
20
- //# sourceMappingURL=module.d.ts.map
13
+ export { type FilesDevtoolsOptions, _default as default };
package/dist/module.js CHANGED
@@ -1,75 +1,90 @@
1
1
  import { filesDevtoolsWriteEnabled, shouldEnableFilesDevtools } from "./devtools/enabled.js";
2
- import { setupNitroFilesIntegration } from "./integration/nitro.js";
3
- import { randomUUID } from "node:crypto";
2
+ import { filesBuilderCapabilities } from "./integration/capabilities.js";
3
+ import { moduleMeta } from "./meta.js";
4
+ import { createHash, randomUUID } from "node:crypto";
4
5
  import { resolve } from "node:path";
5
- import { addImports, addServerImports, defineNuxtModule, getNuxtModuleVersion } from "@nuxt/kit";
6
+ import { addImports, addServerImports, defineNuxtModule, getNuxtModuleVersion, resolveModule, resolveServerVariant, useLogger } from "@nuxt/kit";
6
7
  //#region src/module.ts
7
8
  /** Install Files SDK storage configuration, server utilities, Vue composables, and development diagnostics in Nuxt. */
8
9
  var module_default = defineNuxtModule({
9
- meta: {
10
- name: "nuxt-files-sdk",
11
- configKey: "files",
12
- compatibility: { nuxt: "^4.0.0 || ^5.0.0" }
13
- },
10
+ meta: moduleMeta,
14
11
  defaults: {
15
12
  config: "files.config.ts",
16
13
  devtools: true
17
14
  },
18
- async setup(options, nuxt) {
19
- const configPath = resolve(nuxt.options.rootDir, options.config);
20
- (nuxt.options.typescript.tsConfig.include ??= []).push(configPath);
21
- const paths = (nuxt.options.typescript.tsConfig.compilerOptions ??= {}).paths ??= {};
22
- paths["files-sdk"] ??= [resolve(nuxt.options.rootDir, "node_modules/files-sdk").replaceAll("\\", "/")];
23
- let active = false;
24
- nuxt.hook("nitro:init", async (nitro) => {
25
- active = await setupNitroFilesIntegration(nitro, {
26
- configPath,
27
- environments: nitro.options.static ? ["production", "prerender"] : [nuxt.options.envName || (nuxt.options.dev ? "development" : "production")]
28
- });
29
- });
30
- nuxt.hook("prepare:types", ({ references }) => {
31
- if (active) references.push({ path: resolve(nuxt.options.buildDir, "nuxt-files-sdk/storage-registry.d.ts") });
32
- });
33
- addServerImports([
34
- {
15
+ setup(options, nuxt) {
16
+ nuxt.hook("modules:done", () => nuxt.runWithContext(async () => {
17
+ const { setupNuxtFilesIntegration } = await import("./integration/nuxt.js");
18
+ if (!await setupNuxtFilesIntegration(nuxt, { configPath: resolve(nuxt.options.rootDir, options.config) })) return;
19
+ const capabilities = filesBuilderCapabilities(resolveServerVariant({
20
+ nuxt: "nuxt",
21
+ nitro2: "nitro2",
22
+ nitro3: "nitro3"
23
+ }));
24
+ addServerImports([
25
+ {
26
+ name: "defineFilesConfig",
27
+ from: "nuxt-files-sdk/config",
28
+ typeFrom: resolveModule("nuxt-files-sdk/config", { url: new URL(import.meta.url) }).replaceAll("\\", "/")
29
+ },
30
+ {
31
+ name: "useServerFiles",
32
+ from: "nuxt-files-sdk/runtime",
33
+ dtsDisabled: true
34
+ },
35
+ {
36
+ name: "syncFiles",
37
+ from: "nuxt-files-sdk/runtime",
38
+ dtsDisabled: true
39
+ },
40
+ {
41
+ name: "transferFiles",
42
+ from: "nuxt-files-sdk/runtime",
43
+ dtsDisabled: true
44
+ }
45
+ ]);
46
+ addImports({
35
47
  name: "defineFilesConfig",
36
48
  from: "nuxt-files-sdk/config"
37
- },
38
- {
39
- name: "useServerFiles",
40
- from: "nuxt-files-sdk/runtime"
41
- },
42
- {
43
- name: "syncFiles",
44
- from: "nuxt-files-sdk/runtime"
45
- },
46
- {
47
- name: "transferFiles",
48
- from: "nuxt-files-sdk/runtime"
49
+ });
50
+ for (const name of [
51
+ "useFiles",
52
+ "useFile",
53
+ "useList",
54
+ "useSearch"
55
+ ]) addImports({
56
+ name,
57
+ from: "#files-sdk/vue"
58
+ });
59
+ if (shouldEnableFilesDevtools(nuxt.options.dev, options.devtools, nuxt.options.devtools)) {
60
+ if (!capabilities.devtools) {
61
+ useLogger("nuxt-files-sdk").warn("[nuxt-files-sdk:devtools-unavailable] Files DevTools is unavailable with this server builder. Basic Files runtime remains enabled.");
62
+ return;
63
+ }
64
+ const version = await getNuxtModuleVersion("@nuxt/devtools", nuxt);
65
+ const { setupFilesDevtools } = await import("./devtools/index.js");
66
+ const environmentKey = `NUXT_FILES_DEVTOOLS_${createHash("sha256").update(nuxt.options.rootDir).digest("hex").slice(0, 24).toUpperCase()}`;
67
+ const previous = process.env[environmentKey];
68
+ const secrets = {
69
+ token: randomUUID(),
70
+ environmentKey
71
+ };
72
+ process.env[environmentKey] = secrets.token;
73
+ const restore = () => {
74
+ if (process.env[environmentKey] !== secrets.token) return;
75
+ if (previous === void 0) delete process.env[environmentKey];
76
+ else process.env[environmentKey] = previous;
77
+ };
78
+ nuxt.hook("close", restore);
79
+ try {
80
+ await setupFilesDevtools(nuxt, version || "3", filesDevtoolsWriteEnabled(options.devtools), secrets);
81
+ } catch (error) {
82
+ restore();
83
+ throw error;
84
+ }
49
85
  }
50
- ]);
51
- addImports({
52
- name: "defineFilesConfig",
53
- from: "nuxt-files-sdk/config"
54
- });
55
- for (const name of [
56
- "useFiles",
57
- "useFile",
58
- "useList",
59
- "useSearch"
60
- ]) addImports({
61
- name,
62
- from: "files-sdk/vue"
63
- });
64
- if (shouldEnableFilesDevtools(nuxt.options.dev, options.devtools, nuxt.options.devtools)) {
65
- const version = await getNuxtModuleVersion("@nuxt/devtools", nuxt);
66
- const { setupFilesDevtools } = await import("./devtools/index.js");
67
- const secrets = { token: randomUUID() };
68
- setupFilesDevtools(nuxt, version || "3", filesDevtoolsWriteEnabled(options.devtools), secrets);
69
- }
86
+ }));
70
87
  }
71
88
  });
72
89
  //#endregion
73
90
  export { module_default as default };
74
-
75
- //# sourceMappingURL=module.js.map
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "nuxt-files-sdk",
3
+ "configKey": "files",
4
+ "compatibility": {
5
+ "nuxt": "^4.6.0 || ^5.0.0-0"
6
+ },
7
+ "version": "0.2.0"
8
+ }
package/dist/nitro.d.ts CHANGED
@@ -9,5 +9,4 @@ declare const _default: {
9
9
  setup: (nitro: NitroIntegration) => Promise<boolean>;
10
10
  };
11
11
  //#endregion
12
- export { _default as default };
13
- //# sourceMappingURL=nitro.d.ts.map
12
+ export { _default as default };
package/dist/nitro.js CHANGED
@@ -1,4 +1,3 @@
1
- import { setupNitroFilesIntegration } from "./integration/nitro.js";
2
1
  import { resolve } from "node:path";
3
2
  //#region src/nitro.ts
4
3
  /**
@@ -7,12 +6,13 @@ import { resolve } from "node:path";
7
6
  */
8
7
  var nitro_default = {
9
8
  name: "nuxt-files-sdk",
10
- setup: (nitro) => setupNitroFilesIntegration(nitro, {
11
- configPath: resolve(nitro.options.rootDir, "files.config.ts"),
12
- environments: nitro.options.static ? ["production", "prerender"] : [nitro.options.dev ? "development" : "production"]
13
- })
9
+ setup: async (nitro) => {
10
+ const { setupNitroFilesIntegration } = await import("./integration/nitro.js");
11
+ return setupNitroFilesIntegration(nitro, {
12
+ configPath: resolve(nitro.options.rootDir, "files.config.ts"),
13
+ environments: nitro.options.static ? ["production", "prerender"] : [nitro.options.dev ? "development" : "production"]
14
+ });
15
+ }
14
16
  };
15
17
  //#endregion
16
18
  export { nitro_default as default };
17
-
18
- //# sourceMappingURL=nitro.js.map
package/dist/package.js CHANGED
@@ -1,6 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.1.0";
2
+ var version = "0.2.0";
3
3
  //#endregion
4
4
  export { version };
5
-
6
- //# sourceMappingURL=package.js.map
@@ -0,0 +1,5 @@
1
+ //#region src/runtime/development.d.ts
2
+ export declare const fileHash: (path: string) => string;
3
+ /** Development only: a failed rebuild must never leave old authorization accepting requests. */
4
+ export declare const developmentConfigCurrent: (files: Record<string, string>) => boolean;
5
+ //#endregion
@@ -0,0 +1,14 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFileSync } from "node:fs";
3
+ //#region src/runtime/development.ts
4
+ const fileHash = (path) => {
5
+ try {
6
+ return createHash("sha256").update(readFileSync(path)).digest("hex");
7
+ } catch {
8
+ return "unavailable";
9
+ }
10
+ };
11
+ /** Development only: a failed rebuild must never leave old authorization accepting requests. */
12
+ const developmentConfigCurrent = (files) => Object.entries(files).every(([path, hash]) => hash !== "unavailable" && fileHash(path) === hash);
13
+ //#endregion
14
+ export { developmentConfigCurrent, fileHash };
@@ -0,0 +1,4 @@
1
+ //#region src/runtime/gateway-secret.d.ts
2
+ /** Resolve on the server only. Never serialize the resolved value during generation. */
3
+ export declare const resolveGatewaySecret: (routeSecret: string | undefined, environmentSecret: string | undefined, derive?: () => Promise<string>) => Promise<string>;
4
+ //#endregion
@@ -0,0 +1,10 @@
1
+ //#region src/runtime/gateway-secret.ts
2
+ /** Resolve on the server only. Never serialize the resolved value during generation. */
3
+ const resolveGatewaySecret = async (routeSecret, environmentSecret, derive) => {
4
+ if (routeSecret) return routeSecret;
5
+ if (environmentSecret) return environmentSecret;
6
+ if (derive) return derive();
7
+ throw new Error("[nuxt-files-sdk:gateway-secret] Standalone Nitro requires route.secret or FILES_API_SECRET.");
8
+ };
9
+ //#endregion
10
+ export { resolveGatewaySecret };
@@ -7,5 +7,4 @@ export declare const configureFiles: <const C extends FilesConfig>(config: C, op
7
7
  /** Return secret-free diagnostics for the configured process-local Files registry. */
8
8
  export declare const inspectFiles: () => ReturnType<FilesRegistry['inspect']>;
9
9
  export declare const getFiles: (name?: string) => Files;
10
- //#endregion
11
- //# sourceMappingURL=internal.d.ts.map
10
+ //#endregion
@@ -18,6 +18,7 @@ const configureFiles = (config, options) => {
18
18
  /** Return secret-free diagnostics for the configured process-local Files registry. */
19
19
  const inspectFiles = () => registry?.inspect() ?? {
20
20
  storages: [],
21
+ dependencies: [],
21
22
  diagnostics: [registryDiagnostic ?? { code: "NUXT_FILES_NOT_CONFIGURED" }]
22
23
  };
23
24
  const getFiles = (name) => {
@@ -26,5 +27,3 @@ const getFiles = (name) => {
26
27
  };
27
28
  //#endregion
28
29
  export { configureFiles, getFiles, inspectFiles };
29
-
30
- //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ import "../config.js";
@@ -25,5 +25,3 @@ const normalizeFilesConfig = (config) => {
25
25
  };
26
26
  //#endregion
27
27
  export { normalizeFilesConfig };
28
-
29
- //# sourceMappingURL=normalize.js.map
@@ -49,5 +49,4 @@ export interface ProviderFactories {
49
49
  webdav: typeof import('files-sdk/webdav').webdav;
50
50
  yandex: typeof import('files-sdk/yandex').yandex;
51
51
  }
52
- //#endregion
53
- //# sourceMappingURL=provider-types.d.ts.map
52
+ //#endregion
@@ -1,5 +1,6 @@
1
1
  import { ProviderFactories } from "./provider-types.js";
2
- import { FilesConfig, FilesConfigInput } from "../config.js";
2
+ import { FilesConfig, FilesConfigInput, StorageBranches, StorageNames } from "../config.js";
3
+ import { DependencyDiagnostic } from "../integration/diagnostics.js";
3
4
  import { FilesDevtoolsDiagnosticCode } from "../devtools/diagnostics.js";
4
5
  import { Adapter, ExtensionsOf, Files, FilesActionEvent, FilesErrorEvent, FilesRetryEvent, ProviderSlug } from "files-sdk";
5
6
  //#region src/runtime/registry.d.ts
@@ -8,30 +9,15 @@ type AdapterFor<A> = A extends ProviderSlug ? ReturnType<ProviderFactories[A]> :
8
9
  type PluginsFor<T> = T extends {
9
10
  plugins: infer V;
10
11
  } ? V extends ((...args: never[]) => infer P) ? P extends readonly import('files-sdk').FilesPlugin[] ? P : never : V extends readonly import('files-sdk').FilesPlugin[] ? V : never : never;
11
- export type FilesForStorage<T extends {
12
+ export type FilesForStorage<T> = T extends {
12
13
  adapter: ProviderSlug | ((...args: never[]) => Adapter);
13
- }> = Files<AdapterFor<T['adapter']>> & ExtensionsOf<PluginsFor<T>>;
14
- type StorageOf<C> = C extends {
15
- storage: infer S;
16
- } ? S : never;
17
- type StorageBranch<C> = StorageOf<C> | StorageOf<C extends {
18
- $development: infer E;
19
- } ? E : never> | StorageOf<C extends {
20
- $production: infer E;
21
- } ? E : never> | StorageOf<C extends {
22
- $test: infer E;
23
- } ? E : never> | StorageOf<C extends {
24
- $prerender: infer E;
25
- } ? E : never> | StorageOf<C extends {
26
- $env: infer E;
27
- } ? E[keyof E] : never>;
28
- type SingleEntry<C> = Extract<StorageBranch<C>, {
14
+ } ? Files<AdapterFor<T['adapter']>> & ExtensionsOf<PluginsFor<T>> : never;
15
+ type SingleEntry<C> = Extract<StorageBranches<C>, {
29
16
  adapter: ProviderSlug | ((...args: never[]) => Adapter);
30
17
  }>;
31
- type NamedSet<C> = Exclude<StorageBranch<C>, {
18
+ type NamedSet<C> = Exclude<StorageBranches<C>, {
32
19
  adapter: unknown;
33
20
  }>;
34
- type StorageNames<C> = NamedSet<C> extends (infer S) ? (S extends object ? keyof S : never) : never;
35
21
  type NamedEntry<C, Name extends PropertyKey> = NamedSet<C> extends (infer S) ? (S extends object ? (Name extends keyof S ? S[Name] : never) : never) : never;
36
22
  /** Map each configured storage name to its native Files client and plugin extensions. */
37
23
  export type StorageRegistry<C extends FilesConfigInput> = { [Name in StorageNames<C>]: FilesForStorage<Extract<NamedEntry<C, Name>, {
@@ -66,6 +52,7 @@ export declare class FilesRegistry<const C extends FilesConfig = FilesConfig> {
66
52
  environment?: ProviderEnvironment;
67
53
  factories: FilesProviderFactories;
68
54
  hooks?: FilesRuntimeHooks;
55
+ dependencies?: readonly DependencyDiagnostic[];
69
56
  });
70
57
  /** Return the client from an unnamed single-storage configuration. */
71
58
  get(...args: SingleEntry<C> extends never ? [name: never] : []): SingleStorage<C>;
@@ -80,9 +67,9 @@ export declare class FilesRegistry<const C extends FilesConfig = FilesConfig> {
80
67
  initialized: boolean;
81
68
  }[];
82
69
  diagnostics: RegistryDiagnostic[];
70
+ dependencies: readonly DependencyDiagnostic[];
83
71
  };
84
72
  /** Resolve one selected adapter without constructing its Files client. */
85
73
  resolveAdapter(name?: string): Adapter;
86
74
  }
87
- //#endregion
88
- //# sourceMappingURL=registry.d.ts.map
75
+ //#endregion