nuxt-files-sdk 0.0.0 → 0.0.2

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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -1
  3. package/dist/config.d.ts +34 -0
  4. package/dist/config.js +7 -0
  5. package/dist/config.js.map +1 -0
  6. package/dist/devtools/client/index.html +113 -0
  7. package/dist/devtools/devframe.js +24 -0
  8. package/dist/devtools/devframe.js.map +1 -0
  9. package/dist/devtools/enabled.js +6 -0
  10. package/dist/devtools/enabled.js.map +1 -0
  11. package/dist/devtools/index.js +25 -0
  12. package/dist/devtools/index.js.map +1 -0
  13. package/dist/devtools/nuxt-v3-handler.d.ts +12 -0
  14. package/dist/devtools/nuxt-v3-handler.js +12 -0
  15. package/dist/devtools/nuxt-v3-handler.js.map +1 -0
  16. package/dist/devtools/nuxt-v3.js +19 -0
  17. package/dist/devtools/nuxt-v3.js.map +1 -0
  18. package/dist/devtools/nuxt-v4.js +21 -0
  19. package/dist/devtools/nuxt-v4.js.map +1 -0
  20. package/dist/devtools/snapshot.d.ts +21 -0
  21. package/dist/devtools/snapshot.js +9 -0
  22. package/dist/devtools/snapshot.js.map +1 -0
  23. package/dist/integration/nitro.d.ts +32 -0
  24. package/dist/integration/nitro.js +57 -0
  25. package/dist/integration/nitro.js.map +1 -0
  26. package/dist/module.d.ts +22 -0
  27. package/dist/module.js +52 -0
  28. package/dist/module.js.map +1 -0
  29. package/dist/nitro.d.ts +15 -0
  30. package/dist/nitro.js +20 -0
  31. package/dist/nitro.js.map +1 -0
  32. package/dist/package.js +6 -0
  33. package/dist/package.js.map +1 -0
  34. package/dist/plugins.d.ts +31 -0
  35. package/dist/plugins.js +16 -0
  36. package/dist/runtime/registry.d.ts +43 -0
  37. package/dist/runtime/registry.js +122 -0
  38. package/dist/runtime/registry.js.map +1 -0
  39. package/dist/runtime.d.ts +22 -0
  40. package/dist/runtime.js +26 -0
  41. package/dist/runtime.js.map +1 -0
  42. package/package.json +71 -13
  43. package/index.js +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Liry24
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
1
  # nuxt-files-sdk
2
2
 
3
- This is a stub package published by setup-trusted-publishing to enable OIDC trusted publishing configuration.
3
+ Native-first integration of [Files SDK](https://github.com/haydenbleasel/files-sdk) with Nuxt and Nitro.
4
+
5
+ > This repository is under initial development.
@@ -0,0 +1,34 @@
1
+ import { FilesHooks, FilesPlugin, ProviderSlug } from "files-sdk";
2
+ import { LoadFilesOptions } from "files-sdk/loader";
3
+ //#region src/config.d.ts
4
+ /** Configuration for one named Files SDK storage. */
5
+ export type StorageConfig<Plugins extends readonly FilesPlugin[] = readonly FilesPlugin[]> = Omit<LoadFilesOptions, 'provider'> & {
6
+ /** Files SDK provider slug, for example `r2`, `s3`, or `fs`. */
7
+ adapter: ProviderSlug;
8
+ /** Native Files SDK plugins applied in array order. Their extensions are reflected in the storage type. */
9
+ plugins?: Plugins;
10
+ /** Native Files SDK lifecycle hooks. They run before the Nuxt/Nitro integration hooks. */
11
+ hooks?: FilesHooks;
12
+ };
13
+ /** Development-only connection settings for a storage declared in {@link FilesConfig.storage}. */
14
+ export type DevStorageConfig = Omit<StorageConfig, 'plugins' | 'hooks'> & {
15
+ /** Plugins belong to the logical storage and cannot be replaced in development. */
16
+ plugins?: never;
17
+ /** Hooks belong to the logical storage and cannot be replaced in development. */
18
+ hooks?: never;
19
+ };
20
+ /** Files SDK storages and development overrides used by the Nuxt/Nitro integration. */
21
+ export interface FilesConfig<Storage extends Record<string, StorageConfig> = Record<string, StorageConfig>> {
22
+ /** Storage used by `useServerFiles()` and `FilesRegistry.get()` when no name is passed. */
23
+ default?: keyof Storage & string;
24
+ /** Development-only connection overrides keyed by a name in {@link storage}; never used as failure fallbacks. */
25
+ devStorage?: Partial<{ [Name in keyof Storage]: DevStorageConfig; }>;
26
+ /** Named storages, each initialized lazily on first access. */
27
+ storage: Storage;
28
+ }
29
+ /** Define a Files SDK configuration while preserving storage names and plugin tuples for generated types. */
30
+ export declare const defineFilesConfig: <const Storage extends Record<string, StorageConfig>, const Config extends FilesConfig<Storage>>(config: Config & FilesConfig<Storage> & {
31
+ storage: Storage;
32
+ }) => Config;
33
+ //#endregion
34
+ //# sourceMappingURL=config.d.ts.map
package/dist/config.js ADDED
@@ -0,0 +1,7 @@
1
+ //#region src/config.ts
2
+ /** Define a Files SDK configuration while preserving storage names and plugin tuples for generated types. */
3
+ const defineFilesConfig = (config) => config;
4
+ //#endregion
5
+ export { defineFilesConfig };
6
+
7
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["import type { FilesHooks, FilesPlugin, ProviderSlug } from 'files-sdk'\nimport type { LoadFilesOptions } from 'files-sdk/loader'\n\n/** Configuration for one named Files SDK storage. */\nexport type StorageConfig<Plugins extends readonly FilesPlugin[] = readonly FilesPlugin[]> = Omit<\n LoadFilesOptions,\n 'provider'\n> & {\n /** Files SDK provider slug, for example `r2`, `s3`, or `fs`. */\n adapter: ProviderSlug\n /** Native Files SDK plugins applied in array order. Their extensions are reflected in the storage type. */\n plugins?: Plugins\n /** Native Files SDK lifecycle hooks. They run before the Nuxt/Nitro integration hooks. */\n hooks?: FilesHooks\n}\n\n/** Development-only connection settings for a storage declared in {@link FilesConfig.storage}. */\nexport type DevStorageConfig = Omit<StorageConfig, 'plugins' | 'hooks'> & {\n /** Plugins belong to the logical storage and cannot be replaced in development. */\n plugins?: never\n /** Hooks belong to the logical storage and cannot be replaced in development. */\n hooks?: never\n}\n\n/** Files SDK storages and development overrides used by the Nuxt/Nitro integration. */\nexport interface FilesConfig<Storage extends Record<string, StorageConfig> = Record<string, StorageConfig>> {\n /** Storage used by `useServerFiles()` and `FilesRegistry.get()` when no name is passed. */\n default?: keyof Storage & string\n /** Development-only connection overrides keyed by a name in {@link storage}; never used as failure fallbacks. */\n devStorage?: Partial<{ [Name in keyof Storage]: DevStorageConfig }>\n /** Named storages, each initialized lazily on first access. */\n storage: Storage\n}\n\n/** Define a Files SDK configuration while preserving storage names and plugin tuples for generated types. */\nexport const defineFilesConfig = <\n const Storage extends Record<string, StorageConfig>,\n const Config extends FilesConfig<Storage>,\n>(\n config: Config & FilesConfig<Storage> & { storage: Storage },\n): Config => config\n"],"mappings":";;AAmCA,MAAa,qBAIT,WACS"}
@@ -0,0 +1,113 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Files</title>
7
+ <style>
8
+ :root {
9
+ color-scheme: light dark;
10
+ font-family: system-ui, sans-serif;
11
+ }
12
+ body {
13
+ margin: 0;
14
+ padding: 20px;
15
+ background: Canvas;
16
+ color: CanvasText;
17
+ }
18
+ h1 {
19
+ margin: 0 0 4px;
20
+ font-size: 20px;
21
+ }
22
+ #summary {
23
+ margin: 0 0 20px;
24
+ color: GrayText;
25
+ }
26
+ table {
27
+ width: 100%;
28
+ border-collapse: collapse;
29
+ }
30
+ th,
31
+ td {
32
+ padding: 10px;
33
+ border-bottom: 1px solid color-mix(in srgb, CanvasText 18%, transparent);
34
+ text-align: left;
35
+ }
36
+ th {
37
+ font-size: 12px;
38
+ color: GrayText;
39
+ text-transform: uppercase;
40
+ }
41
+ code {
42
+ font-family: ui-monospace, monospace;
43
+ }
44
+ .warning,
45
+ .error {
46
+ padding: 10px;
47
+ border-radius: 6px;
48
+ background: color-mix(in srgb, orange 16%, Canvas);
49
+ }
50
+ .error {
51
+ background: color-mix(in srgb, red 16%, Canvas);
52
+ }
53
+ </style>
54
+ </head>
55
+ <body>
56
+ <main>
57
+ <h1>Files</h1>
58
+ <p id="summary" aria-live="polite">Loading resolved configuration…</p>
59
+ <section aria-labelledby="storages-heading">
60
+ <h2 id="storages-heading">Storages</h2>
61
+ <table>
62
+ <thead>
63
+ <tr>
64
+ <th>Name</th>
65
+ <th>Adapter</th>
66
+ <th>Plugins</th>
67
+ <th>Source</th>
68
+ <th>Status</th>
69
+ </tr>
70
+ </thead>
71
+ <tbody id="storages"></tbody>
72
+ </table>
73
+ </section>
74
+ <section aria-labelledby="diagnostics-heading">
75
+ <h2 id="diagnostics-heading">Diagnostics</h2>
76
+ <div id="diagnostics"></div>
77
+ </section>
78
+ </main>
79
+ <script type="module">
80
+ const snapshot = await fetch('./snapshot').then((response) => response.json())
81
+ document.querySelector('#summary').textContent =
82
+ `${snapshot.storages.length} configured storage${snapshot.storages.length === 1 ? '' : 's'}`
83
+ document.querySelector('#storages').replaceChildren(
84
+ ...snapshot.storages.map((storage) => {
85
+ const row = document.createElement('tr')
86
+ for (const value of [
87
+ storage.name,
88
+ storage.adapter,
89
+ storage.plugins.join(', ') || '—',
90
+ storage.source,
91
+ storage.initialized ? 'Initialized' : 'Not initialized',
92
+ ]) {
93
+ const cell = document.createElement('td')
94
+ cell.textContent = value
95
+ row.append(cell)
96
+ }
97
+ return row
98
+ }),
99
+ )
100
+ const diagnostics = document.querySelector('#diagnostics')
101
+ if (!snapshot.diagnostics.length) diagnostics.textContent = 'No integration diagnostics.'
102
+ else
103
+ diagnostics.replaceChildren(
104
+ ...snapshot.diagnostics.map((item) => {
105
+ const message = document.createElement('p')
106
+ message.className = item.level
107
+ message.textContent = `${item.code}: ${item.message}`
108
+ return message
109
+ }),
110
+ )
111
+ </script>
112
+ </body>
113
+ </html>
@@ -0,0 +1,24 @@
1
+ import { FILES_DEVTOOLS_PATH } from "./snapshot.js";
2
+ import { version } from "../package.js";
3
+ import { fileURLToPath } from "node:url";
4
+ import { defineDevframe } from "devframe";
5
+ //#region src/devtools/devframe.ts
6
+ var devframe_default = defineDevframe({
7
+ id: "nuxt-files-sdk",
8
+ name: "Files",
9
+ version,
10
+ packageName: "nuxt-files-sdk",
11
+ importMetaUrl: import.meta.url,
12
+ homepage: "https://github.com/liria24/nuxt-files-sdk",
13
+ description: "Files SDK storage and integration diagnostics for Nuxt.",
14
+ icon: "ph:files-duotone",
15
+ basePath: FILES_DEVTOOLS_PATH,
16
+ cli: { distDir: fileURLToPath(new URL("./client", import.meta.url)) },
17
+ setup(context) {
18
+ context.views.hostStatic(FILES_DEVTOOLS_PATH, fileURLToPath(new URL("./client", import.meta.url)));
19
+ }
20
+ });
21
+ //#endregion
22
+ export { devframe_default as default };
23
+
24
+ //# sourceMappingURL=devframe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devframe.js","names":[],"sources":["../../src/devtools/devframe.ts"],"sourcesContent":["import { fileURLToPath } from 'node:url'\n\nimport { defineDevframe } from 'devframe'\n\nimport { version } from '../../package.json'\nimport { FILES_DEVTOOLS_PATH } from './snapshot'\n\nexport default defineDevframe({\n id: 'nuxt-files-sdk',\n name: 'Files',\n version,\n packageName: 'nuxt-files-sdk',\n importMetaUrl: import.meta.url,\n homepage: 'https://github.com/liria24/nuxt-files-sdk',\n description: 'Files SDK storage and integration diagnostics for Nuxt.',\n icon: 'ph:files-duotone',\n basePath: FILES_DEVTOOLS_PATH,\n cli: { distDir: fileURLToPath(new URL('./client', import.meta.url)) },\n setup(context) {\n context.views.hostStatic(FILES_DEVTOOLS_PATH, fileURLToPath(new URL('./client', import.meta.url)))\n },\n})\n"],"mappings":";;;;;AAOA,IAAA,mBAAe,eAAe;CAC1B,IAAI;CACJ,MAAM;CACN;CACA,aAAa;CACb,eAAe,YAAY;CAC3B,UAAU;CACV,aAAa;CACb,MAAM;CACN,UAAU;CACV,KAAK,EAAE,SAAS,cAAc,IAAI,IAAI,YAAY,YAAY,GAAG,CAAC,EAAE;CACpE,MAAM,SAAS;EACX,QAAQ,MAAM,WAAW,qBAAqB,cAAc,IAAI,IAAI,YAAY,YAAY,GAAG,CAAC,CAAC;CACrG;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ //#region src/devtools/enabled.ts
2
+ const shouldEnableFilesDevtools = (development, moduleEnabled, nuxtDevtools) => development && moduleEnabled && (typeof nuxtDevtools === "boolean" ? nuxtDevtools : nuxtDevtools.enabled);
3
+ //#endregion
4
+ export { shouldEnableFilesDevtools };
5
+
6
+ //# sourceMappingURL=enabled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enabled.js","names":[],"sources":["../../src/devtools/enabled.ts"],"sourcesContent":["export const shouldEnableFilesDevtools = (\n development: boolean,\n moduleEnabled: boolean,\n nuxtDevtools: boolean | { enabled: boolean },\n): boolean => development && moduleEnabled && (typeof nuxtDevtools === 'boolean' ? nuxtDevtools : nuxtDevtools.enabled)\n"],"mappings":";AAAA,MAAa,6BACT,aACA,eACA,iBACU,eAAe,kBAAkB,OAAO,iBAAiB,YAAY,eAAe,aAAa"}
@@ -0,0 +1,25 @@
1
+ import nuxt_v3_handler_default from "./nuxt-v3-handler.js";
2
+ import { FILES_DEVTOOLS_PATH, FILES_SNAPSHOT_PATH } from "./snapshot.js";
3
+ import { setupNuxtV3Devtools } from "./nuxt-v3.js";
4
+ import { setupNuxtV4Devtools } from "./nuxt-v4.js";
5
+ import { addDevServerHandler, addServerHandler } from "@nuxt/kit";
6
+ import { fileURLToPath } from "node:url";
7
+ //#region src/devtools/index.ts
8
+ const setupFilesDevtools = (nuxt, version) => {
9
+ addServerHandler({
10
+ route: FILES_SNAPSHOT_PATH,
11
+ handler: fileURLToPath(new URL("./snapshot.js", import.meta.url))
12
+ });
13
+ if (Number.parseInt(version) >= 4) setupNuxtV4Devtools(nuxt);
14
+ else {
15
+ addDevServerHandler({
16
+ route: FILES_DEVTOOLS_PATH,
17
+ handler: nuxt_v3_handler_default
18
+ });
19
+ setupNuxtV3Devtools(nuxt);
20
+ }
21
+ };
22
+ //#endregion
23
+ export { setupFilesDevtools };
24
+
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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 { FILES_DEVTOOLS_PATH, FILES_SNAPSHOT_PATH } from './snapshot'\n\nexport const setupFilesDevtools = (nuxt: Nuxt, version: string): void => {\n // Snapshot must run inside Nitro's worker, where the runtime registry lives.\n addServerHandler({\n route: FILES_SNAPSHOT_PATH,\n handler: fileURLToPath(new URL('./snapshot.js', import.meta.url)),\n })\n if (Number.parseInt(version) >= 4) {\n setupNuxtV4Devtools(nuxt)\n } else {\n addDevServerHandler({\n route: FILES_DEVTOOLS_PATH,\n handler: uiHandler,\n })\n setupNuxtV3Devtools(nuxt)\n }\n}\n"],"mappings":";;;;;;;AAUA,MAAa,sBAAsB,MAAY,YAA0B;CAErE,iBAAiB;EACb,OAAO;EACP,SAAS,cAAc,IAAI,IAAI,iBAAiB,YAAY,GAAG,CAAC;CACpE,CAAC;CACD,IAAI,OAAO,SAAS,OAAO,KAAK,GAC5B,oBAAoB,IAAI;MACrB;EACH,oBAAoB;GAChB,OAAO;GACP,SAASA;EACb,CAAC;EACD,oBAAoB,IAAI;CAC5B;AACJ"}
@@ -0,0 +1,12 @@
1
+ //#region src/devtools/nuxt-v3-handler.d.ts
2
+ declare function _default(event: {
3
+ path: string;
4
+ node: {
5
+ res: {
6
+ setHeader(name: string, value: string): void;
7
+ };
8
+ };
9
+ }): Promise<string | undefined>;
10
+ //#endregion
11
+ export { _default as default };
12
+ //# sourceMappingURL=nuxt-v3-handler.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { readFile } from "node:fs/promises";
2
+ //#region src/devtools/nuxt-v3-handler.ts
3
+ const html = readFile(new URL("./client/index.html", import.meta.url), "utf8");
4
+ var nuxt_v3_handler_default = async (event) => {
5
+ if (event.path !== "/" && event.path !== "/index.html") return void 0;
6
+ event.node.res.setHeader("content-type", "text/html; charset=utf-8");
7
+ return html;
8
+ };
9
+ //#endregion
10
+ export { nuxt_v3_handler_default as default };
11
+
12
+ //# sourceMappingURL=nuxt-v3-handler.js.map
@@ -0,0 +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 if (event.path !== '/' && event.path !== '/index.html') return undefined\n event.node.res.setHeader('content-type', 'text/html; charset=utf-8')\n return html\n}\n"],"mappings":";;AAEA,MAAM,OAAO,SAAS,IAAI,IAAI,uBAAuB,YAAY,GAAG,GAAG,MAAM;AAE7E,IAAA,0BAAe,OAAO,UAA6F;CAC/G,IAAI,MAAM,SAAS,OAAO,MAAM,SAAS,eAAe,OAAO,KAAA;CAC/D,MAAM,KAAK,IAAI,UAAU,gBAAgB,0BAA0B;CACnE,OAAO;AACX"}
@@ -0,0 +1,19 @@
1
+ import { FILES_DEVTOOLS_PATH } from "./snapshot.js";
2
+ //#region src/devtools/nuxt-v3.ts
3
+ const setupNuxtV3Devtools = (nuxt) => {
4
+ nuxt.hook("devtools:customTabs", (tabs) => {
5
+ tabs.push({
6
+ name: "nuxt-files-sdk",
7
+ title: "Files",
8
+ icon: "ph:files-duotone",
9
+ view: {
10
+ type: "iframe",
11
+ src: FILES_DEVTOOLS_PATH
12
+ }
13
+ });
14
+ });
15
+ };
16
+ //#endregion
17
+ export { setupNuxtV3Devtools };
18
+
19
+ //# sourceMappingURL=nuxt-v3.js.map
@@ -0,0 +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;GAAoB;EACrD,CAAC;CACL,CAAC;AACL"}
@@ -0,0 +1,21 @@
1
+ import { FILES_DEVTOOLS_PATH } from "./snapshot.js";
2
+ import devframe_default from "./devframe.js";
3
+ import { createEmbedded } from "devframe/adapters/embedded";
4
+ //#region src/devtools/nuxt-v4.ts
5
+ const setupNuxtV4Devtools = (nuxt) => {
6
+ nuxt.hook("devtools:ready", async (context) => {
7
+ await createEmbedded(devframe_default, { ctx: context });
8
+ context.docks.register({
9
+ id: "nuxt-files-sdk",
10
+ title: "Files",
11
+ icon: "ph:files-duotone",
12
+ type: "iframe",
13
+ url: FILES_DEVTOOLS_PATH,
14
+ groupId: "nuxt"
15
+ });
16
+ });
17
+ };
18
+ //#endregion
19
+ export { setupNuxtV4Devtools };
20
+
21
+ //# sourceMappingURL=nuxt-v4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nuxt-v4.js","names":["filesDevframe"],"sources":["../../src/devtools/nuxt-v4.ts"],"sourcesContent":["import type { Nuxt } from '@nuxt/schema'\nimport { createEmbedded } from 'devframe/adapters/embedded'\n\nimport filesDevframe from './devframe'\nimport { FILES_DEVTOOLS_PATH } from './snapshot'\n\ntype DevtoolsContext = Parameters<typeof createEmbedded>[1]['ctx'] & {\n docks: {\n register(entry: {\n id: string\n title: string\n icon: string\n type: 'iframe'\n url: string\n groupId: string\n }): unknown\n }\n}\n\ndeclare module '@nuxt/schema' {\n interface NuxtHooks {\n 'devtools:ready': (context: DevtoolsContext) => void | Promise<void>\n }\n}\n\nexport const setupNuxtV4Devtools = (nuxt: Nuxt): void => {\n nuxt.hook('devtools:ready', async (context) => {\n await createEmbedded(filesDevframe, { ctx: context })\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',\n })\n })\n}\n"],"mappings":";;;;AAyBA,MAAa,uBAAuB,SAAqB;CACrD,KAAK,KAAK,kBAAkB,OAAO,YAAY;EAC3C,MAAM,eAAeA,kBAAe,EAAE,KAAK,QAAQ,CAAC;EACpD,QAAQ,MAAM,SAAS;GACnB,IAAI;GACJ,OAAO;GACP,MAAM;GACN,MAAM;GACN,KAAK;GACL,SAAS;EACb,CAAC;CACL,CAAC;AACL"}
@@ -0,0 +1,21 @@
1
+ //#region src/devtools/snapshot.d.ts
2
+ export interface FilesDevtoolsSnapshot {
3
+ storages: Array<{
4
+ name: string;
5
+ adapter: string;
6
+ plugins: string[];
7
+ source: 'storage' | 'devStorage';
8
+ initialized: boolean;
9
+ }>;
10
+ diagnostics: Array<{
11
+ code: string;
12
+ level: 'info' | 'warning' | 'error';
13
+ message: string;
14
+ }>;
15
+ }
16
+ export declare const FILES_DEVTOOLS_PATH = "/__nuxt-files-sdk/";
17
+ export declare const FILES_SNAPSHOT_PATH = "/__nuxt-files-sdk/snapshot";
18
+ declare function _default(): FilesDevtoolsSnapshot;
19
+ //#endregion
20
+ export { _default as default };
21
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { inspectFiles } from "../runtime.js";
2
+ //#region src/devtools/snapshot.ts
3
+ const FILES_DEVTOOLS_PATH = "/__nuxt-files-sdk/";
4
+ const FILES_SNAPSHOT_PATH = `${FILES_DEVTOOLS_PATH}snapshot`;
5
+ var snapshot_default = () => inspectFiles();
6
+ //#endregion
7
+ export { FILES_DEVTOOLS_PATH, FILES_SNAPSHOT_PATH, snapshot_default as default };
8
+
9
+ //# sourceMappingURL=snapshot.js.map
@@ -0,0 +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 source: 'storage' | 'devStorage'\n initialized: boolean\n }>\n diagnostics: Array<{\n code: string\n level: 'info' | 'warning' | 'error'\n message: string\n }>\n}\n\nexport const FILES_DEVTOOLS_PATH = '/__nuxt-files-sdk/'\nexport const FILES_SNAPSHOT_PATH = `${FILES_DEVTOOLS_PATH}snapshot`\n\nexport default () => inspectFiles()\n"],"mappings":";;AAiBA,MAAa,sBAAsB;AACnC,MAAa,sBAAsB,GAAG,oBAAoB;AAE1D,IAAA,yBAAqB,aAAa"}
@@ -0,0 +1,32 @@
1
+ //#region src/integration/nitro.d.ts
2
+ export interface NitroIntegration {
3
+ meta?: {
4
+ majorVersion?: number;
5
+ };
6
+ options: {
7
+ rootDir: string;
8
+ buildDir: string;
9
+ dev?: boolean;
10
+ plugins: string[];
11
+ externals?: {
12
+ inline?: unknown[];
13
+ };
14
+ };
15
+ unimport?: {
16
+ getInternalContext(): {
17
+ addons: {
18
+ name?: string;
19
+ declaration?: (declarations: string) => string;
20
+ }[];
21
+ };
22
+ };
23
+ hooks: {
24
+ hook(name: 'types:extend', callback: (types: {
25
+ tsConfig?: {
26
+ include?: string[];
27
+ };
28
+ }) => void | Promise<void>): void;
29
+ };
30
+ }
31
+ //#endregion
32
+ //# sourceMappingURL=nitro.d.ts.map
@@ -0,0 +1,57 @@
1
+ import { resolve } from "node:path";
2
+ import { mkdir, writeFile } from "node:fs/promises";
3
+ //#region src/integration/nitro.ts
4
+ const hookTypes = (moduleName) => `
5
+ declare module ${JSON.stringify(moduleName)} {
6
+ interface NitroRuntimeHooks {
7
+ 'files:action': (payload: { event: import('files-sdk').FilesActionEvent; storage: string }) => void | Promise<void>
8
+ 'files:error': (payload: { event: import('files-sdk').FilesErrorEvent; storage: string }) => void | Promise<void>
9
+ 'files:retry': (payload: { event: import('files-sdk').FilesRetryEvent; storage: string }) => void | Promise<void>
10
+ }
11
+ }
12
+ `;
13
+ const storageTypes = (configPath, nitroMajor) => `import type config from ${JSON.stringify(configPath)}
14
+ import type { DefaultStorage, StorageRegistry } from 'nuxt-files-sdk/runtime'
15
+
16
+ declare module 'nuxt-files-sdk/runtime' {
17
+ interface NuxtFilesStorageRegistry extends StorageRegistry<typeof config> {}
18
+ interface NuxtFilesDefaultStorage { value: DefaultStorage<typeof config> }
19
+ }
20
+ ${hookTypes(nitroMajor >= 3 ? "nitro/types" : "nitropack/types")}
21
+ export {}
22
+ `;
23
+ const setupNitroFilesIntegration = async (nitro, options) => {
24
+ const configPath = options.configPath.replaceAll("\\", "/");
25
+ nitro.unimport?.getInternalContext().addons.push({
26
+ name: "nuxt-files-sdk-jsdoc",
27
+ declaration: (declarations) => declarations.replace(/^(\s*)(const useServerFiles: typeof .*\.useServerFiles)$/mu, "$1/** Return the project's default Files client, including its configured plugin extensions. */\n$1$2")
28
+ });
29
+ const externals = nitro.options.externals ??= {};
30
+ (externals.inline ??= []).push("nuxt-files-sdk");
31
+ if (!nitro.options.dev) externals.inline.push("files-sdk");
32
+ const directory = resolve(nitro.options.buildDir, "nuxt-files-sdk");
33
+ const pluginPath = resolve(directory, "plugin.mjs");
34
+ const typesPath = resolve(directory, "storage-registry.d.ts");
35
+ externals.inline.push(pluginPath.replaceAll("\\", "/"), configPath);
36
+ nitro.options.plugins.push(pluginPath.replaceAll("\\", "/"));
37
+ nitro.hooks.hook("types:extend", async (types) => {
38
+ await mkdir(directory, { recursive: true });
39
+ await Promise.all([writeFile(pluginPath, `import config from ${JSON.stringify(configPath)}
40
+ import { configureFiles } from 'nuxt-files-sdk/runtime'
41
+
42
+ export default (nitroApp) => configureFiles(config, {
43
+ development: ${JSON.stringify(options.development)},
44
+ hooks: {
45
+ onAction: (event, storage) => nitroApp.hooks.callHook('files:action', { event, storage }),
46
+ onError: (event, storage) => nitroApp.hooks.callHook('files:error', { event, storage }),
47
+ onRetry: (event, storage) => nitroApp.hooks.callHook('files:retry', { event, storage }),
48
+ },
49
+ })
50
+ `), writeFile(typesPath, storageTypes(configPath, nitro.meta?.majorVersion ?? ("routing" in nitro ? 3 : 2)))]);
51
+ types.tsConfig?.include?.push(typesPath);
52
+ });
53
+ };
54
+ //#endregion
55
+ export { setupNitroFilesIntegration, storageTypes };
56
+
57
+ //# sourceMappingURL=nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nitro.js","names":[],"sources":["../../src/integration/nitro.ts"],"sourcesContent":["import { mkdir, writeFile } from 'node:fs/promises'\nimport { resolve } from 'node:path'\n\nexport interface NitroIntegration {\n meta?: { majorVersion?: number }\n options: { rootDir: string; buildDir: string; dev?: boolean; plugins: string[]; externals?: { inline?: unknown[] } }\n unimport?: {\n getInternalContext(): {\n addons: {\n name?: string\n declaration?: (declarations: string) => string\n }[]\n }\n }\n hooks: {\n hook(\n name: 'types:extend',\n callback: (types: { tsConfig?: { include?: string[] } }) => void | Promise<void>,\n ): void\n }\n}\n\nexport interface NitroFilesIntegrationOptions {\n configPath: string\n development: boolean\n}\n\nconst hookTypes = (moduleName: 'nitropack/types' | 'nitro/types'): string => `\ndeclare module ${JSON.stringify(moduleName)} {\n interface NitroRuntimeHooks {\n 'files:action': (payload: { event: import('files-sdk').FilesActionEvent; storage: string }) => void | Promise<void>\n 'files:error': (payload: { event: import('files-sdk').FilesErrorEvent; storage: string }) => void | Promise<void>\n 'files:retry': (payload: { event: import('files-sdk').FilesRetryEvent; storage: string }) => void | Promise<void>\n }\n}\n`\n\nexport const storageTypes = (\n configPath: string,\n nitroMajor: number,\n): string => `import type config from ${JSON.stringify(configPath)}\nimport type { DefaultStorage, StorageRegistry } from 'nuxt-files-sdk/runtime'\n\ndeclare module 'nuxt-files-sdk/runtime' {\n interface NuxtFilesStorageRegistry extends StorageRegistry<typeof config> {}\n interface NuxtFilesDefaultStorage { value: DefaultStorage<typeof config> }\n}\n${hookTypes(nitroMajor >= 3 ? 'nitro/types' : 'nitropack/types')}\nexport {}\n`\n\nexport const setupNitroFilesIntegration = async (\n nitro: NitroIntegration,\n options: NitroFilesIntegrationOptions,\n): Promise<void> => {\n const configPath = options.configPath.replaceAll('\\\\', '/')\n nitro.unimport?.getInternalContext().addons.push({\n name: 'nuxt-files-sdk-jsdoc',\n declaration: (declarations) =>\n declarations.replace(\n /^(\\s*)(const useServerFiles: typeof .*\\.useServerFiles)$/mu,\n \"$1/** Return the project's default Files client, including its configured plugin extensions. */\\n$1$2\",\n ),\n })\n // Inline both packages so installed consumers also tree-shake the plugin barrel.\n const externals = (nitro.options.externals ??= {})\n ;(externals.inline ??= []).push('nuxt-files-sdk')\n // Nitro's single-file dev build would eagerly import every native provider SDK.\n if (!nitro.options.dev) externals.inline.push('files-sdk')\n const directory = resolve(nitro.options.buildDir, 'nuxt-files-sdk')\n const pluginPath = resolve(directory, 'plugin.mjs')\n const typesPath = resolve(directory, 'storage-registry.d.ts')\n // Development also externalizes local .mjs files unless explicitly inlined.\n externals.inline.push(pluginPath.replaceAll('\\\\', '/'), configPath)\n nitro.options.plugins.push(pluginPath.replaceAll('\\\\', '/'))\n nitro.hooks.hook('types:extend', async (types) => {\n await mkdir(directory, { recursive: true })\n await Promise.all([\n writeFile(\n pluginPath,\n `import config from ${JSON.stringify(configPath)}\nimport { configureFiles } from 'nuxt-files-sdk/runtime'\n\nexport default (nitroApp) => configureFiles(config, {\n development: ${JSON.stringify(options.development)},\n hooks: {\n onAction: (event, storage) => nitroApp.hooks.callHook('files:action', { event, storage }),\n onError: (event, storage) => nitroApp.hooks.callHook('files:error', { event, storage }),\n onRetry: (event, storage) => nitroApp.hooks.callHook('files:retry', { event, storage }),\n },\n})\n`,\n ),\n // Older v2 and current v3 omit meta; only v3 exposes the routing API.\n writeFile(typesPath, storageTypes(configPath, nitro.meta?.majorVersion ?? ('routing' in nitro ? 3 : 2))),\n ])\n types.tsConfig?.include?.push(typesPath)\n })\n}\n"],"mappings":";;;AA2BA,MAAM,aAAa,eAA0D;iBAC5D,KAAK,UAAU,UAAU,EAAE;;;;;;;;AAS5C,MAAa,gBACT,YACA,eACS,2BAA2B,KAAK,UAAU,UAAU,EAAE;;;;;;;EAOjE,UAAU,cAAc,IAAI,gBAAgB,iBAAiB,EAAE;;;AAIjE,MAAa,6BAA6B,OACtC,OACA,YACgB;CAChB,MAAM,aAAa,QAAQ,WAAW,WAAW,MAAM,GAAG;CAC1D,MAAM,UAAU,mBAAmB,CAAC,CAAC,OAAO,KAAK;EAC7C,MAAM;EACN,cAAc,iBACV,aAAa,QACT,8DACA,uGACJ;CACR,CAAC;CAED,MAAM,YAAa,MAAM,QAAQ,cAAc,CAAC;CAC/C,CAAC,UAAU,WAAW,CAAC,EAAA,CAAG,KAAK,gBAAgB;CAEhD,IAAI,CAAC,MAAM,QAAQ,KAAK,UAAU,OAAO,KAAK,WAAW;CACzD,MAAM,YAAY,QAAQ,MAAM,QAAQ,UAAU,gBAAgB;CAClE,MAAM,aAAa,QAAQ,WAAW,YAAY;CAClD,MAAM,YAAY,QAAQ,WAAW,uBAAuB;CAE5D,UAAU,OAAO,KAAK,WAAW,WAAW,MAAM,GAAG,GAAG,UAAU;CAClE,MAAM,QAAQ,QAAQ,KAAK,WAAW,WAAW,MAAM,GAAG,CAAC;CAC3D,MAAM,MAAM,KAAK,gBAAgB,OAAO,UAAU;EAC9C,MAAM,MAAM,WAAW,EAAE,WAAW,KAAK,CAAC;EAC1C,MAAM,QAAQ,IAAI,CACd,UACI,YACA,sBAAsB,KAAK,UAAU,UAAU,EAAE;;;;iBAIhD,KAAK,UAAU,QAAQ,WAAW,EAAE;;;;;;;CAQzC,GAEA,UAAU,WAAW,aAAa,YAAY,MAAM,MAAM,iBAAiB,aAAa,QAAQ,IAAI,EAAE,CAAC,CAC3G,CAAC;EACD,MAAM,UAAU,SAAS,KAAK,SAAS;CAC3C,CAAC;AACL"}
@@ -0,0 +1,22 @@
1
+ import { NitroIntegration } from "./integration/nitro.js";
2
+ import { DefaultStorage, DefaultStorageName, FilesForStorage, FilesRegistry, FilesRuntimeHooks, StorageRegistry } from "./runtime/registry.js";
3
+ import { NuxtFilesDefaultStorage, NuxtFilesStorageRegistry, configureFiles, inspectFiles, useServerFiles } from "./runtime.js";
4
+ export * from "files-sdk";
5
+ //#region src/module.d.ts
6
+ declare module '@nuxt/schema' {
7
+ interface NuxtHooks {
8
+ 'nitro:init': (nitro: NitroIntegration) => void | Promise<void>;
9
+ }
10
+ }
11
+ /** Options for the Nuxt Files SDK module. */
12
+ export interface ModuleOptions {
13
+ /** Path to the Files configuration module, relative to the Nuxt root directory. */
14
+ config: string;
15
+ /** Enable Files SDK development diagnostics when Nuxt DevTools is available. */
16
+ devtools: boolean;
17
+ }
18
+ /** Install Files SDK storage configuration, server utilities, Vue composables, and development diagnostics in Nuxt. */
19
+ declare const _default: import("@nuxt/schema").NuxtModule<ModuleOptions, ModuleOptions, false>;
20
+ //#endregion
21
+ export { type DefaultStorage, type DefaultStorageName, type FilesForStorage, FilesRegistry, type FilesRuntimeHooks, NuxtFilesDefaultStorage, NuxtFilesStorageRegistry, type StorageRegistry, configureFiles, _default as default, inspectFiles, useServerFiles };
22
+ //# sourceMappingURL=module.d.ts.map
package/dist/module.js ADDED
@@ -0,0 +1,52 @@
1
+ import { shouldEnableFilesDevtools } from "./devtools/enabled.js";
2
+ import { setupNitroFilesIntegration } from "./integration/nitro.js";
3
+ import { FilesRegistry } from "./runtime/registry.js";
4
+ import { configureFiles, inspectFiles, useServerFiles } from "./runtime.js";
5
+ import { resolve } from "node:path";
6
+ import { addImports, addServerImports, defineNuxtModule, getNuxtModuleVersion } from "@nuxt/kit";
7
+ export * from "files-sdk";
8
+ //#region src/module.ts
9
+ /** Install Files SDK storage configuration, server utilities, Vue composables, and development diagnostics in Nuxt. */
10
+ var module_default = defineNuxtModule({
11
+ meta: {
12
+ name: "nuxt-files-sdk",
13
+ configKey: "files",
14
+ compatibility: { nuxt: "^4.0.0 || ^5.0.0" }
15
+ },
16
+ defaults: {
17
+ config: "files.config.ts",
18
+ devtools: true
19
+ },
20
+ async setup(options, nuxt) {
21
+ const configPath = resolve(nuxt.options.rootDir, options.config);
22
+ nuxt.hook("nitro:init", (nitro) => setupNitroFilesIntegration(nitro, {
23
+ configPath,
24
+ development: nuxt.options.dev
25
+ }));
26
+ nuxt.hook("prepare:types", ({ references }) => {
27
+ references.push({ path: resolve(nuxt.options.buildDir, "nuxt-files-sdk/storage-registry.d.ts") });
28
+ });
29
+ addServerImports({
30
+ name: "useServerFiles",
31
+ from: "nuxt-files-sdk/runtime"
32
+ });
33
+ for (const name of [
34
+ "useFiles",
35
+ "useFile",
36
+ "useList",
37
+ "useSearch"
38
+ ]) addImports({
39
+ name,
40
+ from: "files-sdk/vue"
41
+ });
42
+ if (shouldEnableFilesDevtools(nuxt.options.dev, options.devtools, nuxt.options.devtools)) {
43
+ const version = await getNuxtModuleVersion("@nuxt/devtools", nuxt);
44
+ const { setupFilesDevtools } = await import("./devtools/index.js");
45
+ setupFilesDevtools(nuxt, version || "3");
46
+ }
47
+ }
48
+ });
49
+ //#endregion
50
+ export { FilesRegistry, configureFiles, module_default as default, inspectFiles, useServerFiles };
51
+
52
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","names":[],"sources":["../src/module.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { addImports, addServerImports, defineNuxtModule, getNuxtModuleVersion } from '@nuxt/kit'\nimport type { Nuxt } from '@nuxt/schema'\n\nimport { shouldEnableFilesDevtools } from './devtools/enabled'\nimport { setupNitroFilesIntegration, type NitroIntegration } from './integration/nitro'\n\ndeclare module '@nuxt/schema' {\n interface NuxtHooks {\n 'nitro:init': (nitro: NitroIntegration) => void | Promise<void>\n }\n}\n\n/** Options for the Nuxt Files SDK module. */\nexport interface ModuleOptions {\n /** Path to the Files configuration module, relative to the Nuxt root directory. */\n config: string\n /** Enable Files SDK development diagnostics when Nuxt DevTools is available. */\n devtools: boolean\n}\n\n/** Install Files SDK storage configuration, server utilities, Vue composables, and development diagnostics in Nuxt. */\nexport default defineNuxtModule<ModuleOptions>({\n meta: {\n name: 'nuxt-files-sdk',\n configKey: 'files',\n compatibility: { nuxt: '^4.0.0 || ^5.0.0' },\n },\n defaults: {\n config: 'files.config.ts',\n devtools: true,\n },\n async setup(options, nuxt: Nuxt) {\n const configPath = resolve(nuxt.options.rootDir, options.config)\n nuxt.hook('nitro:init', (nitro) =>\n setupNitroFilesIntegration(nitro, {\n configPath,\n development: nuxt.options.dev,\n }),\n )\n nuxt.hook('prepare:types', ({ references }) => {\n references.push({ path: resolve(nuxt.options.buildDir, 'nuxt-files-sdk/storage-registry.d.ts') })\n })\n\n addServerImports({ name: 'useServerFiles', from: 'nuxt-files-sdk/runtime' })\n for (const name of ['useFiles', 'useFile', 'useList', 'useSearch']) {\n addImports({ name, from: 'files-sdk/vue' })\n }\n\n if (shouldEnableFilesDevtools(nuxt.options.dev, options.devtools, nuxt.options.devtools)) {\n const version = await getNuxtModuleVersion('@nuxt/devtools', nuxt)\n const { setupFilesDevtools } = await import('./devtools')\n setupFilesDevtools(nuxt, version || '3')\n }\n },\n})\n\nexport * from 'files-sdk'\nexport * from './runtime'\n"],"mappings":";;;;;;;;;AAuBA,IAAA,iBAAe,iBAAgC;CAC3C,MAAM;EACF,MAAM;EACN,WAAW;EACX,eAAe,EAAE,MAAM,mBAAmB;CAC9C;CACA,UAAU;EACN,QAAQ;EACR,UAAU;CACd;CACA,MAAM,MAAM,SAAS,MAAY;EAC7B,MAAM,aAAa,QAAQ,KAAK,QAAQ,SAAS,QAAQ,MAAM;EAC/D,KAAK,KAAK,eAAe,UACrB,2BAA2B,OAAO;GAC9B;GACA,aAAa,KAAK,QAAQ;EAC9B,CAAC,CACL;EACA,KAAK,KAAK,kBAAkB,EAAE,iBAAiB;GAC3C,WAAW,KAAK,EAAE,MAAM,QAAQ,KAAK,QAAQ,UAAU,sCAAsC,EAAE,CAAC;EACpG,CAAC;EAED,iBAAiB;GAAE,MAAM;GAAkB,MAAM;EAAyB,CAAC;EAC3E,KAAK,MAAM,QAAQ;GAAC;GAAY;GAAW;GAAW;EAAW,GAC7D,WAAW;GAAE;GAAM,MAAM;EAAgB,CAAC;EAG9C,IAAI,0BAA0B,KAAK,QAAQ,KAAK,QAAQ,UAAU,KAAK,QAAQ,QAAQ,GAAG;GACtF,MAAM,UAAU,MAAM,qBAAqB,kBAAkB,IAAI;GACjE,MAAM,EAAE,uBAAuB,MAAM,OAAO;GAC5C,mBAAmB,MAAM,WAAW,GAAG;EAC3C;CACJ;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { NitroIntegration } from "./integration/nitro.js";
2
+ import { DefaultStorage, DefaultStorageName, FilesForStorage, FilesRegistry, FilesRuntimeHooks, StorageRegistry } from "./runtime/registry.js";
3
+ import { NuxtFilesDefaultStorage, NuxtFilesStorageRegistry, configureFiles, inspectFiles, useServerFiles } from "./runtime.js";
4
+ //#region src/nitro.d.ts
5
+ /**
6
+ * A structurally compatible Nitro v2/v3 module. Nitro loads this export
7
+ * directly from `modules: ['nuxt-files-sdk/nitro']`.
8
+ */
9
+ declare const _default: {
10
+ name: string;
11
+ setup: (nitro: NitroIntegration) => Promise<void>;
12
+ };
13
+ //#endregion
14
+ export { type DefaultStorage, type DefaultStorageName, type FilesForStorage, FilesRegistry, type FilesRuntimeHooks, NuxtFilesDefaultStorage, NuxtFilesStorageRegistry, type StorageRegistry, configureFiles, _default as default, inspectFiles, useServerFiles };
15
+ //# sourceMappingURL=nitro.d.ts.map
package/dist/nitro.js ADDED
@@ -0,0 +1,20 @@
1
+ import { setupNitroFilesIntegration } from "./integration/nitro.js";
2
+ import { FilesRegistry } from "./runtime/registry.js";
3
+ import { configureFiles, inspectFiles, useServerFiles } from "./runtime.js";
4
+ import { resolve } from "node:path";
5
+ //#region src/nitro.ts
6
+ /**
7
+ * A structurally compatible Nitro v2/v3 module. Nitro loads this export
8
+ * directly from `modules: ['nuxt-files-sdk/nitro']`.
9
+ */
10
+ var nitro_default = {
11
+ name: "nuxt-files-sdk",
12
+ setup: (nitro) => setupNitroFilesIntegration(nitro, {
13
+ configPath: resolve(nitro.options.rootDir, "files.config.ts"),
14
+ development: Boolean(nitro.options.dev)
15
+ })
16
+ };
17
+ //#endregion
18
+ export { FilesRegistry, configureFiles, nitro_default as default, inspectFiles, useServerFiles };
19
+
20
+ //# sourceMappingURL=nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nitro.js","names":[],"sources":["../src/nitro.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { setupNitroFilesIntegration, type NitroIntegration } from './integration/nitro'\n\n/**\n * A structurally compatible Nitro v2/v3 module. Nitro loads this export\n * directly from `modules: ['nuxt-files-sdk/nitro']`.\n */\nexport default {\n name: 'nuxt-files-sdk',\n setup: (nitro: NitroIntegration) =>\n setupNitroFilesIntegration(nitro, {\n configPath: resolve(nitro.options.rootDir, 'files.config.ts'),\n development: Boolean(nitro.options.dev),\n }),\n}\n\nexport * from './runtime'\n"],"mappings":";;;;;;;;;AAQA,IAAA,gBAAe;CACX,MAAM;CACN,QAAQ,UACJ,2BAA2B,OAAO;EAC9B,YAAY,QAAQ,MAAM,QAAQ,SAAS,iBAAiB;EAC5D,aAAa,QAAQ,MAAM,QAAQ,GAAG;CAC1C,CAAC;AACT"}
@@ -0,0 +1,6 @@
1
+ //#region package.json
2
+ var version = "0.0.2";
3
+ //#endregion
4
+ export { version };
5
+
6
+ //# sourceMappingURL=package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -0,0 +1,31 @@
1
+ import { audit } from "files-sdk/audit";
2
+ import { cache } from "files-sdk/cache";
3
+ import { compression } from "files-sdk/compression";
4
+ import { contentType, detectContentType } from "files-sdk/content-type";
5
+ import { dedup } from "files-sdk/dedup";
6
+ import { encryption, generateEncryptionKey } from "files-sdk/encryption";
7
+ import { failover } from "files-sdk/failover";
8
+ import { signedUrlPolicy } from "files-sdk/signed-url-policy";
9
+ import { softDelete } from "files-sdk/soft-delete";
10
+ import { tiering } from "files-sdk/tiering";
11
+ import { tracing } from "files-sdk/tracing";
12
+ import { usage } from "files-sdk/usage";
13
+ import { ValidationError, validation } from "files-sdk/validation";
14
+ import { versioning } from "files-sdk/versioning";
15
+ import { zip } from "files-sdk/zip";
16
+ export type * from "files-sdk/audit";
17
+ export type * from "files-sdk/cache";
18
+ export type * from "files-sdk/compression";
19
+ export type * from "files-sdk/content-type";
20
+ export type * from "files-sdk/dedup";
21
+ export type * from "files-sdk/encryption";
22
+ export type * from "files-sdk/failover";
23
+ export type * from "files-sdk/signed-url-policy";
24
+ export type * from "files-sdk/soft-delete";
25
+ export type * from "files-sdk/tiering";
26
+ export type * from "files-sdk/tracing";
27
+ export type * from "files-sdk/usage";
28
+ export type * from "files-sdk/validation";
29
+ export type * from "files-sdk/versioning";
30
+ export type * from "files-sdk/zip";
31
+ export { ValidationError, audit, cache, compression, contentType, dedup, detectContentType, encryption, failover, generateEncryptionKey, signedUrlPolicy, softDelete, tiering, tracing, usage, validation, versioning, zip };
@@ -0,0 +1,16 @@
1
+ import { audit } from "files-sdk/audit";
2
+ import { cache } from "files-sdk/cache";
3
+ import { compression } from "files-sdk/compression";
4
+ import { contentType, detectContentType } from "files-sdk/content-type";
5
+ import { dedup } from "files-sdk/dedup";
6
+ import { encryption, generateEncryptionKey } from "files-sdk/encryption";
7
+ import { failover } from "files-sdk/failover";
8
+ import { signedUrlPolicy } from "files-sdk/signed-url-policy";
9
+ import { softDelete } from "files-sdk/soft-delete";
10
+ import { tiering } from "files-sdk/tiering";
11
+ import { tracing } from "files-sdk/tracing";
12
+ import { usage } from "files-sdk/usage";
13
+ import { ValidationError, validation } from "files-sdk/validation";
14
+ import { versioning } from "files-sdk/versioning";
15
+ import { zip } from "files-sdk/zip";
16
+ export { ValidationError, audit, cache, compression, contentType, dedup, detectContentType, encryption, failover, generateEncryptionKey, signedUrlPolicy, softDelete, tiering, tracing, usage, validation, versioning, zip };
@@ -0,0 +1,43 @@
1
+ import { FilesConfig, StorageConfig } from "../config.js";
2
+ import { FilesDevtoolsSnapshot } from "../devtools/snapshot.js";
3
+ import { ExtensionsOf, Files, FilesActionEvent, FilesErrorEvent, FilesRetryEvent, ProviderSlug } from "files-sdk";
4
+ //#region src/runtime/registry.d.ts
5
+ /** Native Files client plus the methods contributed by a storage's plugins. */
6
+ export type FilesForStorage<T extends StorageConfig> = Files & ExtensionsOf<NonNullable<T['plugins']>>;
7
+ /** Map each configured storage name to its native Files client and plugin extensions. */
8
+ export type StorageRegistry<C extends FilesConfig> = { [Name in keyof C['storage']]: FilesForStorage<C['storage'][Name]>; };
9
+ type IsUnion<T, C = T> = T extends C ? ([C] extends [T] ? false : true) : never;
10
+ /** Resolve the explicit, conventional, or only storage name used by an unnamed access. */
11
+ export type DefaultStorageName<C extends FilesConfig> = C extends {
12
+ default: infer Name extends Extract<keyof C['storage'], string>;
13
+ } ? Name : 'default' extends keyof C['storage'] ? 'default' : IsUnion<Extract<keyof C['storage'], string>> extends false ? Extract<keyof C['storage'], string> : never;
14
+ /** Files client and plugin extensions returned for a configuration's default storage. */
15
+ export type DefaultStorage<C extends FilesConfig> = StorageRegistry<C>[DefaultStorageName<C>];
16
+ /** Hooks emitted by the Nuxt/Nitro bridge after the storage's native hooks. */
17
+ export interface FilesRuntimeHooks {
18
+ /** Observe a failed native Files operation. */
19
+ onError?: (event: FilesErrorEvent, storage: string) => void | Promise<void>;
20
+ /** Observe a completed native Files operation. */
21
+ onAction?: (event: FilesActionEvent, storage: string) => void | Promise<void>;
22
+ /** Observe a native Files retry. */
23
+ onRetry?: (event: FilesRetryEvent, storage: string) => void | Promise<void>;
24
+ }
25
+ /** Lazily initialize and memoize native Files clients for a validated project configuration. */
26
+ export declare class FilesRegistry<const C extends FilesConfig = FilesConfig> {
27
+ #private;
28
+ /**
29
+ * Create a registry and validate storage references without initializing or connecting to a provider.
30
+ */
31
+ constructor(config: C, options?: {
32
+ development?: boolean;
33
+ hooks?: FilesRuntimeHooks;
34
+ });
35
+ /** Return the default storage, sharing its in-flight initialization Promise. */
36
+ get(name?: undefined): Promise<DefaultStorage<C>>;
37
+ /** Return a named storage with its plugin extensions, sharing its in-flight initialization Promise. */
38
+ get<Name extends keyof C['storage'] & string>(name: Name): Promise<StorageRegistry<C>[Name]>;
39
+ /** Return secret-free storage metadata and initialization state for development diagnostics. */
40
+ inspect(): FilesDevtoolsSnapshot;
41
+ }
42
+ //#endregion
43
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1,122 @@
1
+ import { createFiles } from "files-sdk";
2
+ import { loadFiles } from "files-sdk/loader";
3
+ import { getProvider, listEnvVars } from "files-sdk/providers";
4
+ //#region src/runtime/registry.ts
5
+ const runHooks = async (...hooks) => {
6
+ for (const hook of hooks) try {
7
+ await hook();
8
+ } catch {}
9
+ };
10
+ /** Lazily initialize and memoize native Files clients for a validated project configuration. */
11
+ var FilesRegistry = class {
12
+ #config;
13
+ #development;
14
+ #hooks;
15
+ #instances = /* @__PURE__ */ new Map();
16
+ /**
17
+ * Create a registry and validate storage references without initializing or connecting to a provider.
18
+ */
19
+ constructor(config, options = {}) {
20
+ if (!config.storage || Object.keys(config.storage).length === 0) throw new Error("[nuxt-files-sdk:invalid-config] At least one storage is required.");
21
+ for (const name of [config.default, ...Object.keys(config.devStorage ?? {})]) if (name !== void 0 && !Object.hasOwn(config.storage, name)) throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage "${name}".`);
22
+ this.#config = config;
23
+ this.#development = options.development ?? false;
24
+ this.#hooks = options.hooks ?? {};
25
+ }
26
+ get(name) {
27
+ const resolvedName = name ?? this.#defaultName();
28
+ if (!Object.hasOwn(this.#config.storage, resolvedName)) throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage "${resolvedName}".`);
29
+ let instance = this.#instances.get(resolvedName);
30
+ if (!instance) {
31
+ instance = this.#create(resolvedName);
32
+ this.#instances.set(resolvedName, instance);
33
+ instance.catch(() => this.#instances.delete(resolvedName));
34
+ }
35
+ return instance;
36
+ }
37
+ /** Return secret-free storage metadata and initialization state for development diagnostics. */
38
+ inspect() {
39
+ return {
40
+ storages: Object.entries(this.#config.storage).map(([name, storage]) => {
41
+ const override = this.#development ? this.#config.devStorage?.[name] : void 0;
42
+ return {
43
+ name,
44
+ adapter: override?.adapter ?? storage.adapter,
45
+ plugins: storage.plugins?.map((plugin) => plugin.name) ?? [],
46
+ source: override ? "devStorage" : "storage",
47
+ initialized: this.#instances.has(name)
48
+ };
49
+ }),
50
+ diagnostics: []
51
+ };
52
+ }
53
+ #defaultName() {
54
+ if (this.#config.default !== void 0) return this.#config.default;
55
+ const names = Object.keys(this.#config.storage);
56
+ if (names.length === 1 && names[0]) return names[0];
57
+ if (Object.hasOwn(this.#config.storage, "default")) return "default";
58
+ throw new Error("[nuxt-files-sdk:storage-name-required] A storage name is required.");
59
+ }
60
+ async #create(name) {
61
+ const base = this.#config.storage[name];
62
+ const override = this.#development ? this.#config.devStorage?.[name] : void 0;
63
+ const selected = override ? {
64
+ ...base,
65
+ ...override,
66
+ plugins: base?.plugins,
67
+ hooks: base?.hooks
68
+ } : base;
69
+ if (!selected) throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage "${name}".`);
70
+ const { adapter, plugins, hooks: userHooks, ...options } = selected;
71
+ const loaded = await withNuxtEnvironment(adapter, () => loadFiles({
72
+ ...options,
73
+ provider: adapter
74
+ }));
75
+ if (!plugins && !userHooks && !Object.values(this.#hooks).some(Boolean)) return loaded.files;
76
+ return createFiles({
77
+ adapter: loaded.files.adapter,
78
+ hooks: {
79
+ onAction: (event) => runHooks(() => userHooks?.onAction?.(event), () => this.#hooks.onAction?.(event, name)),
80
+ onError: (event) => runHooks(() => userHooks?.onError?.(event), () => this.#hooks.onError?.(event, name)),
81
+ onRetry: (event) => runHooks(() => userHooks?.onRetry?.(event), () => this.#hooks.onRetry?.(event, name))
82
+ },
83
+ ...plugins ? { plugins } : {},
84
+ ...options.prefix === void 0 ? {} : { prefix: options.prefix },
85
+ ...options.retries === void 0 ? {} : { retries: options.retries },
86
+ ...options.timeout === void 0 ? {} : { timeout: options.timeout }
87
+ });
88
+ }
89
+ };
90
+ let environmentLock = Promise.resolve();
91
+ /** Bridge only NUXT_ aliases declared by the configured native provider. */
92
+ const withNuxtEnvironment = async (provider, load) => {
93
+ if (!getProvider(provider)) return load();
94
+ const variables = listEnvVars(provider);
95
+ if (variables.length === 0) return load();
96
+ const previous = environmentLock;
97
+ let release;
98
+ environmentLock = new Promise((resolveLock) => release = resolveLock);
99
+ await previous;
100
+ const injected = [];
101
+ for (const variable of variables) {
102
+ const keys = [variable.key, ...variable.aliases ?? []];
103
+ if (keys.some((key) => process.env[key] !== void 0)) continue;
104
+ for (const key of keys) {
105
+ const value = process.env[`NUXT_${key}`];
106
+ if (value !== void 0 && process.env[key] === void 0) {
107
+ process.env[key] = value;
108
+ injected.push(key);
109
+ }
110
+ }
111
+ }
112
+ try {
113
+ return await load();
114
+ } finally {
115
+ for (const key of injected) delete process.env[key];
116
+ release();
117
+ }
118
+ };
119
+ //#endregion
120
+ export { FilesRegistry, withNuxtEnvironment };
121
+
122
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","names":[],"sources":["../../src/runtime/registry.ts"],"sourcesContent":["import {\n createFiles,\n type ExtensionsOf,\n type Files,\n type FilesActionEvent,\n type FilesErrorEvent,\n type FilesRetryEvent,\n type ProviderSlug,\n} from 'files-sdk'\nimport { loadFiles } from 'files-sdk/loader'\nimport { getProvider, listEnvVars } from 'files-sdk/providers'\n\nimport type { FilesConfig, StorageConfig } from '../config'\nimport type { FilesDevtoolsSnapshot } from '../devtools/snapshot'\n\n/** Native Files client plus the methods contributed by a storage's plugins. */\nexport type FilesForStorage<T extends StorageConfig> = Files & ExtensionsOf<NonNullable<T['plugins']>>\n\n/** Map each configured storage name to its native Files client and plugin extensions. */\nexport type StorageRegistry<C extends FilesConfig> = {\n [Name in keyof C['storage']]: FilesForStorage<C['storage'][Name]>\n}\n\ntype IsUnion<T, C = T> = T extends C ? ([C] extends [T] ? false : true) : never\n\n/** Resolve the explicit, conventional, or only storage name used by an unnamed access. */\nexport type DefaultStorageName<C extends FilesConfig> = C extends {\n default: infer Name extends Extract<keyof C['storage'], string>\n}\n ? Name\n : 'default' extends keyof C['storage']\n ? 'default'\n : IsUnion<Extract<keyof C['storage'], string>> extends false\n ? Extract<keyof C['storage'], string>\n : never\n\n/** Files client and plugin extensions returned for a configuration's default storage. */\nexport type DefaultStorage<C extends FilesConfig> = StorageRegistry<C>[DefaultStorageName<C>]\n\n/** Hooks emitted by the Nuxt/Nitro bridge after the storage's native hooks. */\nexport interface FilesRuntimeHooks {\n /** Observe a failed native Files operation. */\n onError?: (event: FilesErrorEvent, storage: string) => void | Promise<void>\n /** Observe a completed native Files operation. */\n onAction?: (event: FilesActionEvent, storage: string) => void | Promise<void>\n /** Observe a native Files retry. */\n onRetry?: (event: FilesRetryEvent, storage: string) => void | Promise<void>\n}\n\nconst runHooks = async (...hooks: (() => void | Promise<void> | undefined)[]): Promise<void> => {\n for (const hook of hooks) {\n try {\n // Preserve user-before-bridge ordering without exposing hook failures to native operations.\n // oxlint-disable-next-line no-await-in-loop\n await hook()\n } catch {}\n }\n}\n\n/** Lazily initialize and memoize native Files clients for a validated project configuration. */\nexport class FilesRegistry<const C extends FilesConfig = FilesConfig> {\n readonly #config: C\n readonly #development: boolean\n readonly #hooks: FilesRuntimeHooks\n readonly #instances = new Map<string, Promise<Files>>()\n\n /**\n * Create a registry and validate storage references without initializing or connecting to a provider.\n */\n constructor(config: C, options: { development?: boolean; hooks?: FilesRuntimeHooks } = {}) {\n if (!config.storage || Object.keys(config.storage).length === 0) {\n throw new Error('[nuxt-files-sdk:invalid-config] At least one storage is required.')\n }\n for (const name of [config.default, ...Object.keys(config.devStorage ?? {})]) {\n if (name !== undefined && !Object.hasOwn(config.storage, name)) {\n throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage \"${name}\".`)\n }\n }\n this.#config = config\n this.#development = options.development ?? false\n this.#hooks = options.hooks ?? {}\n }\n\n /** Return the default storage, sharing its in-flight initialization Promise. */\n get(name?: undefined): Promise<DefaultStorage<C>>\n /** Return a named storage with its plugin extensions, sharing its in-flight initialization Promise. */\n get<Name extends keyof C['storage'] & string>(name: Name): Promise<StorageRegistry<C>[Name]>\n get(name?: string): Promise<Files> {\n const resolvedName = name ?? this.#defaultName()\n if (!Object.hasOwn(this.#config.storage, resolvedName)) {\n throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage \"${resolvedName}\".`)\n }\n let instance = this.#instances.get(resolvedName)\n if (!instance) {\n instance = this.#create(resolvedName)\n this.#instances.set(resolvedName, instance)\n void instance.catch(() => this.#instances.delete(resolvedName))\n }\n return instance\n }\n\n /** Return secret-free storage metadata and initialization state for development diagnostics. */\n inspect(): FilesDevtoolsSnapshot {\n return {\n storages: Object.entries(this.#config.storage).map(([name, storage]) => {\n const override = this.#development ? this.#config.devStorage?.[name] : undefined\n return {\n name,\n adapter: override?.adapter ?? storage.adapter,\n plugins: storage.plugins?.map((plugin) => plugin.name) ?? [],\n source: override ? 'devStorage' : 'storage',\n initialized: this.#instances.has(name),\n }\n }),\n diagnostics: [],\n }\n }\n\n #defaultName(): string {\n if (this.#config.default !== undefined) return this.#config.default\n const names = Object.keys(this.#config.storage)\n if (names.length === 1 && names[0]) return names[0]\n if (Object.hasOwn(this.#config.storage, 'default')) return 'default'\n throw new Error('[nuxt-files-sdk:storage-name-required] A storage name is required.')\n }\n\n async #create(name: string): Promise<Files> {\n const base = this.#config.storage[name]\n const override = this.#development ? this.#config.devStorage?.[name] : undefined\n const selected = override ? { ...base, ...override, plugins: base?.plugins, hooks: base?.hooks } : base\n if (!selected) throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage \"${name}\".`)\n const { adapter, plugins, hooks: userHooks, ...options } = selected\n const loaded = await withNuxtEnvironment(adapter, () => loadFiles({ ...options, provider: adapter }))\n // The upstream loader has no hooks/plugins input. Avoid rebuilding the\n // native instance unless those native capabilities are actually used.\n if (!plugins && !userHooks && !Object.values(this.#hooks).some(Boolean)) return loaded.files\n return createFiles({\n adapter: loaded.files.adapter,\n hooks: {\n onAction: (event) =>\n runHooks(\n () => userHooks?.onAction?.(event),\n () => this.#hooks.onAction?.(event, name),\n ),\n onError: (event) =>\n runHooks(\n () => userHooks?.onError?.(event),\n () => this.#hooks.onError?.(event, name),\n ),\n onRetry: (event) =>\n runHooks(\n () => userHooks?.onRetry?.(event),\n () => this.#hooks.onRetry?.(event, name),\n ),\n },\n ...(plugins ? { plugins } : {}),\n ...(options.prefix === undefined ? {} : { prefix: options.prefix }),\n ...(options.retries === undefined ? {} : { retries: options.retries }),\n ...(options.timeout === undefined ? {} : { timeout: options.timeout }),\n })\n }\n}\n\nlet environmentLock = Promise.resolve()\n\n/** Bridge only NUXT_ aliases declared by the configured native provider. */\nexport const withNuxtEnvironment = async <T>(provider: ProviderSlug, load: () => Promise<T>): Promise<T> => {\n const metadata = getProvider(provider)\n if (!metadata) return load()\n const variables = listEnvVars(provider)\n if (variables.length === 0) return load()\n // ponytail: module-local env lock; use native env keys to avoid temporary aliases.\n const previous = environmentLock\n let release!: () => void\n environmentLock = new Promise<void>((resolveLock) => (release = resolveLock))\n await previous\n const injected: string[] = []\n for (const variable of variables) {\n const keys = [variable.key, ...(variable.aliases ?? [])]\n if (keys.some((key) => process.env[key] !== undefined)) continue\n for (const key of keys) {\n const value = process.env[`NUXT_${key}`]\n if (value !== undefined && process.env[key] === undefined) {\n process.env[key] = value\n injected.push(key)\n }\n }\n }\n try {\n return await load()\n } finally {\n for (const key of injected) delete process.env[key]\n release()\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,22 @@
1
+ import { FilesConfig } from "./config.js";
2
+ import { FilesDevtoolsSnapshot } from "./devtools/snapshot.js";
3
+ import { DefaultStorage, DefaultStorageName, FilesForStorage, FilesRegistry, FilesRuntimeHooks, StorageRegistry } from "./runtime/registry.js";
4
+ import { Files } from "files-sdk";
5
+ //#region src/runtime.d.ts
6
+ /** Project storage names and plugin-extended Files clients supplied by generated declarations. */
7
+ export interface NuxtFilesStorageRegistry {}
8
+ /** Project default Files client supplied by generated declarations. */
9
+ export interface NuxtFilesDefaultStorage {}
10
+ /** Configure the process-local Files registry used by {@link useServerFiles}. */
11
+ export declare const configureFiles: <const C extends FilesConfig>(config: C, options?: ConstructorParameters<typeof FilesRegistry<C>>[1]) => FilesRegistry<C>;
12
+ /** Return secret-free diagnostics for the configured process-local Files registry. */
13
+ export declare const inspectFiles: () => FilesDevtoolsSnapshot;
14
+ /** Return the project's default Files client, including its configured plugin extensions. */
15
+ export declare function useServerFiles(): Promise<NuxtFilesDefaultStorage extends {
16
+ value: infer Default;
17
+ } ? Default : Files>;
18
+ /** Return a named project Files client, including that storage's configured plugin extensions. */
19
+ export declare function useServerFiles<Name extends Extract<keyof NuxtFilesStorageRegistry, string>>(name: Name): Promise<NuxtFilesStorageRegistry[Name]>;
20
+ //#endregion
21
+ export { type DefaultStorage, type DefaultStorageName, type FilesForStorage, FilesRegistry, type FilesRuntimeHooks, type StorageRegistry };
22
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1,26 @@
1
+ import { FilesRegistry } from "./runtime/registry.js";
2
+ //#region src/runtime.ts
3
+ let registry;
4
+ /** Configure the process-local Files registry used by {@link useServerFiles}. */
5
+ const configureFiles = (config, options) => {
6
+ const value = new FilesRegistry(config, options);
7
+ registry = value;
8
+ return value;
9
+ };
10
+ /** Return secret-free diagnostics for the configured process-local Files registry. */
11
+ const inspectFiles = () => registry?.inspect() ?? {
12
+ storages: [],
13
+ diagnostics: [{
14
+ code: "NUXT_FILES_NOT_CONFIGURED",
15
+ level: "warning",
16
+ message: "The Files registry has not been configured."
17
+ }]
18
+ };
19
+ function useServerFiles(name) {
20
+ if (!registry) throw new Error("[nuxt-files-sdk:not-configured] The Files registry has not been configured.");
21
+ return name === void 0 ? registry.get() : registry.get(name);
22
+ }
23
+ //#endregion
24
+ export { FilesRegistry, configureFiles, inspectFiles, useServerFiles };
25
+
26
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","names":[],"sources":["../src/runtime.ts"],"sourcesContent":["import type { Files } from 'files-sdk'\n\nimport type { FilesConfig } from './config'\nimport type { FilesDevtoolsSnapshot } from './devtools/snapshot'\nimport { FilesRegistry } from './runtime/registry'\n\nexport { FilesRegistry } from './runtime/registry'\nexport type {\n DefaultStorage,\n DefaultStorageName,\n FilesForStorage,\n FilesRuntimeHooks,\n StorageRegistry,\n} from './runtime/registry'\n\n/** Project storage names and plugin-extended Files clients supplied by generated declarations. */\nexport interface NuxtFilesStorageRegistry {}\n/** Project default Files client supplied by generated declarations. */\nexport interface NuxtFilesDefaultStorage {}\n\nlet registry: FilesRegistry | undefined\n\n/** Configure the process-local Files registry used by {@link useServerFiles}. */\nexport const configureFiles = <const C extends FilesConfig>(\n config: C,\n options?: ConstructorParameters<typeof FilesRegistry<C>>[1],\n): FilesRegistry<C> => {\n const value = new FilesRegistry(config, options)\n registry = value\n return value\n}\n\n/** Return secret-free diagnostics for the configured process-local Files registry. */\nexport const inspectFiles = (): FilesDevtoolsSnapshot =>\n registry?.inspect() ?? {\n storages: [],\n diagnostics: [\n {\n code: 'NUXT_FILES_NOT_CONFIGURED',\n level: 'warning',\n message: 'The Files registry has not been configured.',\n },\n ],\n }\n\n/** Return the project's default Files client, including its configured plugin extensions. */\nexport function useServerFiles(): Promise<NuxtFilesDefaultStorage extends { value: infer Default } ? Default : Files>\n/** Return a named project Files client, including that storage's configured plugin extensions. */\nexport function useServerFiles<Name extends Extract<keyof NuxtFilesStorageRegistry, string>>(\n name: Name,\n): Promise<NuxtFilesStorageRegistry[Name]>\nexport function useServerFiles(name?: string): Promise<Files> {\n if (!registry) {\n throw new Error('[nuxt-files-sdk:not-configured] The Files registry has not been configured.')\n }\n return name === undefined ? registry.get() : registry.get(name)\n}\n"],"mappings":";;AAoBA,IAAI;;AAGJ,MAAa,kBACT,QACA,YACmB;CACnB,MAAM,QAAQ,IAAI,cAAc,QAAQ,OAAO;CAC/C,WAAW;CACX,OAAO;AACX;;AAGA,MAAa,qBACT,UAAU,QAAQ,KAAK;CACnB,UAAU,CAAC;CACX,aAAa,CACT;EACI,MAAM;EACN,OAAO;EACP,SAAS;CACb,CACJ;AACJ;AAQJ,SAAgB,eAAe,MAA+B;CAC1D,IAAI,CAAC,UACD,MAAM,IAAI,MAAM,6EAA6E;CAEjG,OAAO,SAAS,KAAA,IAAY,SAAS,IAAI,IAAI,SAAS,IAAI,IAAI;AAClE"}
package/package.json CHANGED
@@ -1,15 +1,73 @@
1
1
  {
2
- "name": "nuxt-files-sdk",
3
- "version": "0.0.0",
4
- "main": "index.js",
5
- "description": "Native-first Files SDK integration for Nuxt and Nitro",
6
- "publishConfig": {
7
- "access": "public"
8
- },
9
- "license": "MIT",
10
- "homepage": "https://github.com/liria24/nuxt-files-sdk#readme",
11
- "repository": {
12
- "type": "git",
13
- "url": "git+https://github.com/liria24/nuxt-files-sdk.git"
14
- }
2
+ "name": "nuxt-files-sdk",
3
+ "version": "0.0.2",
4
+ "description": "Native-first Files SDK integration for Nuxt and Nitro",
5
+ "homepage": "https://github.com/liria24/nuxt-files-sdk#readme",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/liria24/nuxt-files-sdk.git"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "type": "module",
15
+ "sideEffects": false,
16
+ "main": "./dist/module.js",
17
+ "types": "./dist/module.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/module.d.ts",
21
+ "import": "./dist/module.js"
22
+ },
23
+ "./config": {
24
+ "types": "./dist/config.d.ts",
25
+ "import": "./dist/config.js"
26
+ },
27
+ "./nitro": {
28
+ "types": "./dist/nitro.d.ts",
29
+ "import": "./dist/nitro.js"
30
+ },
31
+ "./plugins": {
32
+ "types": "./dist/plugins.d.ts",
33
+ "import": "./dist/plugins.js"
34
+ },
35
+ "./runtime": {
36
+ "types": "./dist/runtime.d.ts",
37
+ "import": "./dist/runtime.js"
38
+ },
39
+ "./package.json": "./package.json"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "provenance": true
44
+ },
45
+ "scripts": {
46
+ "build": "tsdown",
47
+ "dev": "tsdown --watch",
48
+ "prepack": "bun run build",
49
+ "typecheck": "tsc --noEmit"
50
+ },
51
+ "dependencies": {
52
+ "@nuxt/kit": "^4.5.2",
53
+ "devframe": "^0.9.12",
54
+ "files-sdk": "^2.4.0"
55
+ },
56
+ "devDependencies": {
57
+ "@arethetypeswrong/cli": "^0.18.5",
58
+ "@nuxt/schema": "^4.5.2",
59
+ "@types/node": "^26.5.0",
60
+ "publint": "^0.3.24",
61
+ "tsdown": "^0.23.0",
62
+ "typescript": "^7.0.2",
63
+ "vue": "^3.5.42"
64
+ },
65
+ "peerDependencies": {
66
+ "nuxt": "^4.0.0 || ^5.0.0"
67
+ },
68
+ "peerDependenciesMeta": {
69
+ "nuxt": {
70
+ "optional": true
71
+ }
72
+ }
15
73
  }
package/index.js DELETED
@@ -1 +0,0 @@
1
- module.exports = {};