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.
- package/dist/config/evaluate.js +149 -0
- package/dist/config/load.js +22 -40
- package/dist/config/merge.d.ts +1 -2
- package/dist/config/merge.js +0 -2
- package/dist/config/prepare.js +58 -0
- package/dist/config/prune.js +14 -13
- package/dist/config.d.ts +11 -6
- package/dist/config.js +0 -2
- package/dist/devtools/auth.js +0 -2
- package/dist/devtools/client/app.js +2 -2
- package/dist/devtools/client/index.html +4 -0
- package/dist/devtools/devframe.js +1 -3
- package/dist/devtools/diagnostics.d.ts +1 -2
- package/dist/devtools/diagnostics.js +0 -2
- package/dist/devtools/enabled.d.ts +1 -2
- package/dist/devtools/enabled.js +0 -2
- package/dist/devtools/files-read.d.ts +2 -3
- package/dist/devtools/files-read.js +0 -2
- package/dist/devtools/files-write.d.ts +2 -3
- package/dist/devtools/files-write.js +0 -2
- package/dist/devtools/files.js +7 -10
- package/dist/devtools/index.js +24 -26
- package/dist/devtools/nuxt-v3-handler.d.ts +1 -2
- package/dist/devtools/nuxt-v3-handler.js +0 -2
- package/dist/devtools/nuxt-v3.js +1 -3
- package/dist/devtools/nuxt-v4.js +4 -7
- package/dist/devtools/paths.js +8 -0
- package/dist/devtools/snapshot.d.ts +5 -14
- package/dist/devtools/snapshot.js +2 -9
- package/dist/devtools/token.d.ts +1 -2
- package/dist/devtools/token.js +0 -2
- package/dist/integration/capabilities.js +17 -0
- package/dist/integration/dependencies.d.ts +12 -0
- package/dist/integration/dependencies.js +67 -0
- package/dist/integration/diagnostics.d.ts +9 -0
- package/dist/integration/diagnostics.js +80 -0
- package/dist/integration/imports.js +83 -0
- package/dist/integration/nitro-dev-close.js +13 -0
- package/dist/integration/nitro-event.d.ts +7 -0
- package/dist/integration/nitro-event.js +24 -0
- package/dist/integration/nitro.d.ts +9 -2
- package/dist/integration/nitro.js +171 -92
- package/dist/integration/nuxt-diagnostics.js +23 -0
- package/dist/integration/nuxt.js +235 -0
- package/dist/integration/resolve.d.ts +1 -0
- package/dist/integration/resolve.js +113 -0
- package/dist/integration/terminal.js +20 -0
- package/dist/integration/update.js +59 -0
- package/dist/meta.js +8 -0
- package/dist/module.d.ts +1 -8
- package/dist/module.js +74 -59
- package/dist/module.json +8 -0
- package/dist/nitro.d.ts +1 -2
- package/dist/nitro.js +7 -7
- package/dist/package.js +1 -3
- package/dist/runtime/development.d.ts +5 -0
- package/dist/runtime/development.js +14 -0
- package/dist/runtime/gateway-secret.d.ts +4 -0
- package/dist/runtime/gateway-secret.js +10 -0
- package/dist/runtime/internal.d.ts +1 -2
- package/dist/runtime/internal.js +1 -2
- package/dist/runtime/normalize.d.ts +1 -0
- package/dist/runtime/normalize.js +0 -2
- package/dist/runtime/provider-types.d.ts +1 -2
- package/dist/runtime/registry.d.ts +9 -22
- package/dist/runtime/registry.js +23 -28
- package/dist/runtime.d.ts +1 -2
- package/dist/runtime.js +0 -2
- package/package.json +248 -14
- package/dist/config/load.js.map +0 -1
- package/dist/config/merge.js.map +0 -1
- package/dist/config/prune.js.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/devtools/auth.js.map +0 -1
- package/dist/devtools/devframe.js.map +0 -1
- package/dist/devtools/diagnostics.js.map +0 -1
- package/dist/devtools/enabled.js.map +0 -1
- package/dist/devtools/files-read.js.map +0 -1
- package/dist/devtools/files-write.js.map +0 -1
- package/dist/devtools/files.js.map +0 -1
- package/dist/devtools/index.js.map +0 -1
- package/dist/devtools/nuxt-v3-handler.js.map +0 -1
- package/dist/devtools/nuxt-v3.js.map +0 -1
- package/dist/devtools/nuxt-v4.js.map +0 -1
- package/dist/devtools/snapshot.js.map +0 -1
- package/dist/devtools/token.js.map +0 -1
- package/dist/integration/nitro.js.map +0 -1
- package/dist/module.js.map +0 -1
- package/dist/nitro.js.map +0 -1
- package/dist/package.js.map +0 -1
- package/dist/runtime/internal.js.map +0 -1
- package/dist/runtime/normalize.js.map +0 -1
- package/dist/runtime/registry.js.map +0 -1
- package/dist/runtime.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nitro.js","names":[],"sources":["../../src/integration/nitro.ts"],"sourcesContent":["import { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { createRequire } from 'node:module'\nimport { resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport type { ProviderSlug } from 'files-sdk'\nimport { getProvider, listEnvVars } from 'files-sdk/providers'\n\nimport { loadFilesConfig } from '../config/load'\nimport { pruneFilesConfigSource } from '../config/prune'\nimport { normalizeFilesConfig } from '../runtime/normalize'\n\nexport interface NitroIntegration {\n meta?: { majorVersion?: number }\n options: {\n rootDir: string\n buildDir: string\n dev?: boolean\n static?: boolean\n preset?: string\n plugins: string[]\n handlers?: { route: string; handler: string }[]\n alias?: Record<string, string>\n externals?: { inline?: unknown[] }\n }\n unimport?: {\n injectImports(code: string, id?: string): Promise<{ code: string }>\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: {\n tsConfig?: {\n include?: string[]\n compilerOptions?: { paths?: Record<string, string[]> }\n }\n }) => void | Promise<void>,\n ): void\n }\n}\n\nexport interface NitroFilesIntegrationOptions {\n configPath: string\n environments: readonly string[]\n}\n\nconst AWS_CORE_DEPENDENCIES = [\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-presigned-post',\n '@aws-sdk/s3-request-presigner',\n] as const\nconst AWS_MULTIPART_DEPENDENCY = '@aws-sdk/lib-storage'\nconst FETCH_CAPABLE_S3_ADAPTERS = new Set<ProviderSlug>(['minio', 'r2', 'rustfs'])\nconst WORKERD_PRESETS = new Set(['cloudflare-module', 'cloudflare-durable', 'cloudflare-pages'])\n\nexport const optionalAwsSdkDependencies = (\n adapters: ProviderSlug[],\n options: { nitroMajor: number; preset?: string | undefined; resolvable: (dependency: string) => boolean },\n): string[] => {\n if (options.nitroMajor >= 3 || !options.preset || !WORKERD_PRESETS.has(options.preset)) return []\n const s3Adapters = adapters.filter((adapter) => getProvider(adapter)?.peerDeps.includes('@aws-sdk/client-s3'))\n if (s3Adapters.length === 0) return []\n const optional = s3Adapters.every((adapter) => FETCH_CAPABLE_S3_ADAPTERS.has(adapter))\n ? [...AWS_CORE_DEPENDENCIES, AWS_MULTIPART_DEPENDENCY]\n : [AWS_MULTIPART_DEPENDENCY]\n return optional.filter((dependency) => !options.resolvable(dependency))\n}\n\nconst nitroMajorVersion = (nitro: NitroIntegration): number => nitro.meta?.majorVersion ?? ('routing' in nitro ? 3 : 2)\n\nexport const selectedAdapters = (config: unknown): { adapters: ProviderSlug[]; single: boolean } => {\n const entries = normalizeFilesConfig(config)\n const single = entries.has(undefined)\n const adapters = [\n ...new Set(\n [...entries.values()]\n .map(({ storage }) => storage.adapter)\n .filter((adapter): adapter is ProviderSlug => typeof adapter === 'string'),\n ),\n ].toSorted()\n for (const adapter of adapters) {\n if (!getProvider(adapter)) {\n throw new Error(`[nuxt-files-sdk:unknown-adapter] Unknown adapter \"${adapter}\".`)\n }\n }\n return { adapters, single }\n}\n\nexport const gatewayRoutes = (config: unknown): { path: string; storage?: string }[] => {\n const routes = config && typeof config === 'object' && 'routes' in config ? config.routes : undefined\n if (routes === undefined) return []\n if (!Array.isArray(routes)) throw new Error('[nuxt-files-sdk:invalid-route] routes must be an array.')\n const storages = normalizeFilesConfig(config)\n const paths = new Set<string>()\n const selected: { path: string; storage?: string }[] = []\n for (const route of routes as unknown[]) {\n if (\n !route ||\n typeof route !== 'object' ||\n !('path' in route) ||\n typeof route.path !== 'string' ||\n !/^\\/(?:[\\w.~-]+(?:\\/[\\w.~-]+)*)?$/u.test(route.path)\n ) {\n throw new Error('[nuxt-files-sdk:invalid-route] Each route needs a static absolute path.')\n }\n if (paths.has(route.path)) throw new Error(`[nuxt-files-sdk:duplicate-route] Duplicate route \"${route.path}\".`)\n paths.add(route.path)\n const name = 'storage' in route ? route.storage : undefined\n if (storages.has(undefined) ? name !== undefined : typeof name !== 'string' || !storages.has(name)) {\n throw new Error(`[nuxt-files-sdk:unknown-storage] Invalid storage for route \"${route.path}\".`)\n }\n selected.push(typeof name === 'string' ? { path: route.path, storage: name } : { path: route.path })\n }\n return selected\n}\n\nconst factoryName = (adapter: ProviderSlug): string =>\n adapter === 'cloudinary'\n ? 'cloudinaryAdapter'\n : adapter.replaceAll(/-([a-z0-9])/gu, (_, character: string) => character.toUpperCase())\n\nexport const providerCode = (adapters: ProviderSlug[]): { imports: string; factories: string } => ({\n imports: adapters\n .map(\n (adapter, index) =>\n `import { ${factoryName(adapter)} as provider${index} } from ${JSON.stringify(`files-sdk/${adapter}`)}`,\n )\n .join('\\n'),\n factories: adapters.map((adapter, index) => `${JSON.stringify(adapter)}: provider${index}`).join(', '),\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 { SingleStorage, StorageRegistry } from 'nuxt-files-sdk/runtime'\n\ndeclare module 'nuxt-files-sdk/runtime' {\n interface NuxtFilesSingleStorage { value: SingleStorage<typeof config> }\n interface NuxtFilesStorageRegistry extends StorageRegistry<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<boolean> => {\n const configPath = options.configPath.replaceAll('\\\\', '/')\n const config = await loadFilesConfig({\n configPath,\n environments: options.environments,\n alias: nitro.options.alias,\n injectImports: nitro.unimport?.injectImports.bind(nitro.unimport),\n })\n if (!config) return false\n const selected = selectedAdapters(config)\n const directory = resolve(nitro.options.rootDir, nitro.options.buildDir, 'nuxt-files-sdk')\n const typesPath = resolve(directory, 'storage-registry.d.ts')\n let writeRuntime: (() => Promise<void>) | undefined\n const writeTypes = async (): Promise<void> => {\n await mkdir(directory, { recursive: true })\n await writeFile(typesPath, storageTypes(configPath, nitroMajorVersion(nitro)))\n }\n await writeTypes()\n nitro.hooks.hook('types:extend', async (types) => {\n await writeTypes()\n await writeRuntime?.()\n const tsConfig = (types.tsConfig ??= {})\n ;(tsConfig.include ??= []).push(typesPath)\n const paths = ((tsConfig.compilerOptions ??= {}).paths ??= {})\n paths['files-sdk'] ??= [resolve(nitro.options.rootDir, 'node_modules/files-sdk').replaceAll('\\\\', '/')]\n })\n const routes = gatewayRoutes(config)\n const { adapters } = selected\n const providers = providerCode(adapters)\n const internalPath = fileURLToPath(new URL('../runtime/internal.js', import.meta.url)).replaceAll('\\\\', '/')\n const environment = Object.fromEntries(\n adapters.map((adapter) => [\n adapter,\n listEnvVars(adapter)\n .filter((variable) => variable.readBy === 'files-sdk')\n .map((variable) => [variable.key, ...(variable.aliases ?? [])]),\n ]),\n )\n const require = createRequire(resolve(nitro.options.rootDir, 'package.json'))\n const aliases = nitro.options.alias ?? {}\n const awsShims = optionalAwsSdkDependencies(adapters, {\n nitroMajor: nitroMajorVersion(nitro),\n preset: nitro.options.preset,\n resolvable: (dependency) => {\n if (Object.hasOwn(aliases, dependency)) return true\n try {\n require.resolve(dependency)\n return true\n } catch {\n return false\n }\n },\n })\n const shimFiles = awsShims.map((dependency) => ({\n dependency,\n path: resolve(directory, `${dependency.replaceAll(/[^a-z0-9]+/giu, '-')}.mjs`),\n }))\n if (shimFiles.length > 0) {\n nitro.options.alias = aliases\n for (const { dependency, path } of shimFiles) aliases[dependency] = path.replaceAll('\\\\', '/')\n }\n nitro.unimport?.getInternalContext().addons.push({\n name: 'nuxt-files-sdk-jsdoc',\n declaration: (declarations) =>\n declarations.replace(\n /^([ \\t]*)const (useServerFiles|syncFiles|transferFiles): typeof .*\\.\\2$/gmu,\n (_, indent: string, name: string) =>\n `${name === 'useServerFiles' ? `${indent}/** Return the project's Files client, including its configured plugin extensions. */\\n` : ''}${indent}const ${name}: typeof import('nuxt-files-sdk/runtime').${name}`,\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 pluginPath = resolve(directory, nitro.options.dev ? 'plugin.dev.mjs' : 'plugin.mjs')\n const resolvedPath = resolve(directory, nitro.options.dev ? 'resolved.dev.mjs' : 'resolved.mjs')\n const selectedPath = resolve(directory, nitro.options.dev ? 'selected.dev.ts' : 'selected.ts')\n const routePaths = routes.map((_, index) =>\n resolve(directory, `gateway-${index}${nitro.options.dev ? '.dev' : ''}.mjs`).replaceAll('\\\\', '/'),\n )\n for (const [index, route] of routes.entries()) {\n ;(nitro.options.handlers ??= []).push({ route: route.path, handler: routePaths[index]! })\n }\n // Development also externalizes local .mjs files unless explicitly inlined.\n externals.inline.push(\n pluginPath.replaceAll('\\\\', '/'),\n resolvedPath.replaceAll('\\\\', '/'),\n selectedPath.replaceAll('\\\\', '/'),\n ...routePaths,\n )\n nitro.options.plugins.push(pluginPath.replaceAll('\\\\', '/'))\n writeRuntime = async (): Promise<void> => {\n await mkdir(directory, { recursive: true })\n await Promise.all(\n shimFiles.map(({ dependency, path }) =>\n writeFile(\n path,\n `throw new Error(${JSON.stringify(`[nuxt-files-sdk:missing-optional-dependency] ${dependency} is required for this Files SDK operation. Install it or select the provider's fetch client.`)})\\n`,\n ),\n ),\n )\n const originalSource = await readFile(configPath, 'utf8')\n const importedSource = nitro.unimport\n ? (await nitro.unimport.injectImports(originalSource, configPath)).code\n : originalSource\n await writeFile(selectedPath, pruneFilesConfigSource(importedSource, configPath, options.environments))\n const mergePath = fileURLToPath(new URL('../config/merge.js', import.meta.url)).replaceAll('\\\\', '/')\n const selectedBranches = options.environments\n .flatMap((name) => [`raw[${JSON.stringify(`$${name}`)}]`, `raw.$env?.[${JSON.stringify(name)}]`])\n .toReversed()\n await writeFile(\n resolvedPath,\n `import raw from ${JSON.stringify(selectedPath.replaceAll('\\\\', '/'))}\\nimport { mergeFilesConfig } from ${JSON.stringify(mergePath)}\\nconst resolved = mergeFilesConfig(${[...selectedBranches, 'raw'].join(', ')})\\nexport default { storage: resolved.storage, routes: resolved.routes }\\n`,\n )\n await writeFile(\n pluginPath,\n `import config from ${JSON.stringify(resolvedPath.replaceAll('\\\\', '/'))}\n${providers.imports}\nimport { configureFiles } from ${JSON.stringify(internalPath)}\n\nexport default (nitroApp) => configureFiles(config, {\n factories: { ${providers.factories} },\n environment: ${JSON.stringify(environment)},\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 await Promise.all(\n routePaths.map((path, index) => {\n const route = routes[index]!\n const handler =\n nitroMajorVersion(nitro) >= 3 ? 'router.handle(event.req)' : 'createRouteHandler(router)(event)'\n return writeFile(\n path,\n `import config from ${JSON.stringify(resolvedPath.replaceAll('\\\\', '/'))}\nimport { createFilesRouter } from 'files-sdk/api'\n${nitroMajorVersion(nitro) >= 3 ? '' : \"import { createRouteHandler } from 'files-sdk/nitro'\"}\nimport { getFiles } from ${JSON.stringify(internalPath)}\n\nconst route = config.routes[${index}]\nconst environmentSecret = typeof process === 'undefined' ? undefined : process.env?.FILES_API_SECRET\nconst secret = route.authorize\n ? route.secret || environmentSecret || crypto.randomUUID() + crypto.randomUUID()\n : route.secret\nif (route.authorize && !route.secret && !environmentSecret) {\n console.warn('[nuxt-files-sdk:gateway-secret] Set FILES_API_SECRET for upload tokens shared across processes.')\n}\nlet sharedRouter\nconst makeRouter = (event) => createFilesRouter({\n ...route,\n files: () => getFiles(${route.storage === undefined ? '' : JSON.stringify(route.storage)}),\n secret,\n authorize: route.authorize && ((context) => route.authorize({ ...context, event })),\n})\nexport default (event) => {\n const router = route.authorize ? makeRouter(event) : (sharedRouter ??= makeRouter(event))\n return ${handler}\n}\n`,\n )\n }),\n )\n }\n await writeRuntime()\n return true\n}\n"],"mappings":";;;;;;;;;AAoDA,MAAM,wBAAwB;CAC1B;CACA;CACA;AACJ;AACA,MAAM,2BAA2B;AACjC,MAAM,4CAA4B,IAAI,IAAkB;CAAC;CAAS;CAAM;AAAQ,CAAC;AACjF,MAAM,kCAAkB,IAAI,IAAI;CAAC;CAAqB;CAAsB;AAAkB,CAAC;AAE/F,MAAa,8BACT,UACA,YACW;CACX,IAAI,QAAQ,cAAc,KAAK,CAAC,QAAQ,UAAU,CAAC,gBAAgB,IAAI,QAAQ,MAAM,GAAG,OAAO,CAAC;CAChG,MAAM,aAAa,SAAS,QAAQ,YAAY,YAAY,OAAO,CAAC,EAAE,SAAS,SAAS,oBAAoB,CAAC;CAC7G,IAAI,WAAW,WAAW,GAAG,OAAO,CAAC;CAIrC,QAHiB,WAAW,OAAO,YAAY,0BAA0B,IAAI,OAAO,CAAC,IAC/E,CAAC,GAAG,uBAAuB,wBAAwB,IACnD,CAAC,wBAAwB,EAAA,CACf,QAAQ,eAAe,CAAC,QAAQ,WAAW,UAAU,CAAC;AAC1E;AAEA,MAAM,qBAAqB,UAAoC,MAAM,MAAM,iBAAiB,aAAa,QAAQ,IAAI;AAErH,MAAa,oBAAoB,WAAmE;CAChG,MAAM,UAAU,qBAAqB,MAAM;CAC3C,MAAM,SAAS,QAAQ,IAAI,KAAA,CAAS;CACpC,MAAM,WAAW,CACb,GAAG,IAAI,IACH,CAAC,GAAG,QAAQ,OAAO,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EACJ,CAAC,CACL;CACJ;CACA,MAAM,aAAa;CACnB,OAAO;AACX"}
|
package/dist/module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","names":[],"sources":["../src/module.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto'\nimport { resolve } from 'node:path'\n\nimport { addImports, addServerImports, defineNuxtModule, getNuxtModuleVersion } from '@nuxt/kit'\nimport type { Nuxt } from '@nuxt/schema'\n\nimport { filesDevtoolsWriteEnabled, shouldEnableFilesDevtools, type FilesDevtoolsOptions } 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 tools. File writes are enabled unless explicitly disabled. */\n devtools: boolean | FilesDevtoolsOptions\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.options.typescript.tsConfig.include ??= []).push(configPath)\n const paths = ((nuxt.options.typescript.tsConfig.compilerOptions ??= {}).paths ??= {})\n paths['files-sdk'] ??= [resolve(nuxt.options.rootDir, 'node_modules/files-sdk').replaceAll('\\\\', '/')]\n let active = false\n nuxt.hook('nitro:init', async (nitro) => {\n active = await setupNitroFilesIntegration(nitro, {\n configPath,\n environments: nitro.options.static\n ? ['production', 'prerender']\n : [nuxt.options.envName || (nuxt.options.dev ? 'development' : 'production')],\n })\n })\n nuxt.hook('prepare:types', ({ references }) => {\n if (active)\n references.push({ path: resolve(nuxt.options.buildDir, 'nuxt-files-sdk/storage-registry.d.ts') })\n })\n\n addServerImports([\n { name: 'defineFilesConfig', from: 'nuxt-files-sdk/config' },\n { name: 'useServerFiles', from: 'nuxt-files-sdk/runtime' },\n { name: 'syncFiles', from: 'nuxt-files-sdk/runtime' },\n { name: 'transferFiles', from: 'nuxt-files-sdk/runtime' },\n ])\n addImports({ name: 'defineFilesConfig', from: 'nuxt-files-sdk/config' })\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 const secrets = { token: randomUUID() }\n setupFilesDevtools(nuxt, version || '3', filesDevtoolsWriteEnabled(options.devtools), secrets)\n }\n },\n})\n\nexport type { FilesDevtoolsOptions } from './devtools/enabled'\n"],"mappings":";;;;;;;AAwBA,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;EAC9D,CAAC,KAAK,QAAQ,WAAW,SAAS,YAAY,CAAC,EAAA,CAAG,KAAK,UAAU;EAClE,MAAM,QAAS,CAAC,KAAK,QAAQ,WAAW,SAAS,oBAAoB,CAAC,EAAA,CAAG,UAAU,CAAC;EACpF,MAAM,iBAAiB,CAAC,QAAQ,KAAK,QAAQ,SAAS,wBAAwB,CAAC,CAAC,WAAW,MAAM,GAAG,CAAC;EACrG,IAAI,SAAS;EACb,KAAK,KAAK,cAAc,OAAO,UAAU;GACrC,SAAS,MAAM,2BAA2B,OAAO;IAC7C;IACA,cAAc,MAAM,QAAQ,SACtB,CAAC,cAAc,WAAW,IAC1B,CAAC,KAAK,QAAQ,YAAY,KAAK,QAAQ,MAAM,gBAAgB,aAAa;GACpF,CAAC;EACL,CAAC;EACD,KAAK,KAAK,kBAAkB,EAAE,iBAAiB;GAC3C,IAAI,QACA,WAAW,KAAK,EAAE,MAAM,QAAQ,KAAK,QAAQ,UAAU,sCAAsC,EAAE,CAAC;EACxG,CAAC;EAED,iBAAiB;GACb;IAAE,MAAM;IAAqB,MAAM;GAAwB;GAC3D;IAAE,MAAM;IAAkB,MAAM;GAAyB;GACzD;IAAE,MAAM;IAAa,MAAM;GAAyB;GACpD;IAAE,MAAM;IAAiB,MAAM;GAAyB;EAC5D,CAAC;EACD,WAAW;GAAE,MAAM;GAAqB,MAAM;EAAwB,CAAC;EACvE,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,MAAM,UAAU,EAAE,OAAO,WAAW,EAAE;GACtC,mBAAmB,MAAM,WAAW,KAAK,0BAA0B,QAAQ,QAAQ,GAAG,OAAO;EACjG;CACJ;AACJ,CAAC"}
|
package/dist/nitro.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 environments: nitro.options.static\n ? ['production', 'prerender']\n : [nitro.options.dev ? 'development' : 'production'],\n }),\n}\n"],"mappings":";;;;;;;AAQA,IAAA,gBAAe;CACX,MAAM;CACN,QAAQ,UACJ,2BAA2B,OAAO;EAC9B,YAAY,QAAQ,MAAM,QAAQ,SAAS,iBAAiB;EAC5D,cAAc,MAAM,QAAQ,SACtB,CAAC,cAAc,WAAW,IAC1B,CAAC,MAAM,QAAQ,MAAM,gBAAgB,YAAY;CAC3D,CAAC;AACT"}
|
package/dist/package.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","names":[],"sources":["../../src/runtime/internal.ts"],"sourcesContent":["import type { Files } from 'files-sdk'\n\nimport type { FilesConfig } from '../config'\nimport { FilesRegistry, type RegistryDiagnostic } from './registry'\n\nlet registry: FilesRegistry | undefined\nlet registryDiagnostic: RegistryDiagnostic | 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 try {\n const value = new FilesRegistry(config, options)\n registry = value\n registryDiagnostic = undefined\n return value\n } catch (error) {\n registry = undefined\n registryDiagnostic = { code: 'NUXT_FILES_INVALID_CONFIG' }\n throw error\n }\n}\n\n/** Return secret-free diagnostics for the configured process-local Files registry. */\nexport const inspectFiles = (): ReturnType<FilesRegistry['inspect']> =>\n registry?.inspect() ?? {\n storages: [],\n diagnostics: [registryDiagnostic ?? { code: 'NUXT_FILES_NOT_CONFIGURED' }],\n }\n\nexport const getFiles = (name?: string): Files => {\n if (!registry) throw new Error('[nuxt-files-sdk:not-configured] The Files registry has not been configured.')\n return name === undefined ? registry.get() : (registry.get as (storage: string) => Files)(name)\n}\n"],"mappings":";;AAKA,IAAI;AACJ,IAAI;;AAGJ,MAAa,kBACT,QACA,YACmB;CACnB,IAAI;EACA,MAAM,QAAQ,IAAI,cAAc,QAAQ,OAAO;EAC/C,WAAW;EACX,qBAAqB,KAAA;EACrB,OAAO;CACX,SAAS,OAAO;EACZ,WAAW,KAAA;EACX,qBAAqB,EAAE,MAAM,4BAA4B;EACzD,MAAM;CACV;AACJ;;AAGA,MAAa,qBACT,UAAU,QAAQ,KAAK;CACnB,UAAU,CAAC;CACX,aAAa,CAAC,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC7E;AAEJ,MAAa,YAAY,SAAyB;CAC9C,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,6EAA6E;CAC5G,OAAO,SAAS,KAAA,IAAY,SAAS,IAAI,IAAK,SAAS,IAAmC,IAAI;AAClG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.js","names":[],"sources":["../../src/runtime/normalize.ts"],"sourcesContent":["import type { StorageConfig } from '../config'\n\nexport interface StorageEntry {\n name: string | undefined\n storage: StorageConfig\n}\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value)\nconst isStorage = (value: unknown): value is StorageConfig =>\n isObject(value) && (typeof value.adapter === 'string' || typeof value.adapter === 'function')\n\n/** Validate one resolved config without selecting an environment or evaluating provider options. */\nexport const normalizeFilesConfig = (config: unknown): Map<string | undefined, StorageEntry> => {\n if (!isObject(config)) throw new Error('[nuxt-files-sdk:invalid-config] Files configuration must be an object.')\n const { storage } = config\n if (!isObject(storage)) throw new Error('[nuxt-files-sdk:invalid-config] At least one storage is required.')\n const entries = new Map<string | undefined, StorageEntry>()\n if (isStorage(storage)) {\n entries.set(undefined, { name: undefined, storage })\n } else {\n if (!Object.keys(storage).length)\n throw new Error('[nuxt-files-sdk:invalid-config] At least one storage is required.')\n for (const [name, value] of Object.entries(storage)) {\n if (!isStorage(value)) throw new Error(`[nuxt-files-sdk:invalid-config] Invalid storage \"${name}\".`)\n entries.set(name, { name, storage: value })\n }\n }\n return entries\n}\n"],"mappings":";AAOA,MAAM,YAAY,UACd,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AACvE,MAAM,aAAa,UACf,SAAS,KAAK,MAAM,OAAO,MAAM,YAAY,YAAY,OAAO,MAAM,YAAY;;AAGtF,MAAa,wBAAwB,WAA2D;CAC5F,IAAI,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,wEAAwE;CAC/G,MAAM,EAAE,YAAY;CACpB,IAAI,CAAC,SAAS,OAAO,GAAG,MAAM,IAAI,MAAM,mEAAmE;CAC3G,MAAM,0BAAU,IAAI,IAAsC;CAC1D,IAAI,UAAU,OAAO,GACjB,QAAQ,IAAI,KAAA,GAAW;EAAE,MAAM,KAAA;EAAW;CAAQ,CAAC;MAChD;EACH,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,QACtB,MAAM,IAAI,MAAM,mEAAmE;EACvF,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAAG;GACjD,IAAI,CAAC,UAAU,KAAK,GAAG,MAAM,IAAI,MAAM,oDAAoD,KAAK,GAAG;GACnG,QAAQ,IAAI,MAAM;IAAE;IAAM,SAAS;GAAM,CAAC;EAC9C;CACJ;CACA,OAAO;AACX"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","names":[],"sources":["../../src/runtime/registry.ts"],"sourcesContent":["import {\n createFiles,\n type Adapter,\n type ExtensionsOf,\n type Files,\n type FilesActionEvent,\n type FilesErrorEvent,\n type FilesRetryEvent,\n type ProviderSlug,\n} from 'files-sdk'\n\nimport type { FilesConfig, FilesConfigInput, StorageConfig } from '../config'\nimport type { FilesDevtoolsDiagnosticCode } from '../devtools/diagnostics'\nimport { normalizeFilesConfig, type StorageEntry } from './normalize'\nimport type { ProviderFactories } from './provider-types'\n\n/** Native Files client plus the methods contributed by a storage's plugins. */\ntype AdapterFor<A> = A extends ProviderSlug\n ? ReturnType<ProviderFactories[A]>\n : A extends (...args: never[]) => Adapter\n ? ReturnType<A>\n : never\ntype PluginsFor<T> = T extends { plugins: infer V }\n ? V extends (...args: never[]) => infer P\n ? P extends readonly import('files-sdk').FilesPlugin[]\n ? P\n : never\n : V extends readonly import('files-sdk').FilesPlugin[]\n ? V\n : never\n : never\nexport type FilesForStorage<T extends { adapter: ProviderSlug | ((...args: never[]) => Adapter) }> = Files<\n AdapterFor<T['adapter']>\n> &\n ExtensionsOf<PluginsFor<T>>\n\ntype StorageOf<C> = C extends { storage: infer S } ? S : never\ntype StorageBranch<C> =\n | StorageOf<C>\n | StorageOf<C extends { $development: infer E } ? E : never>\n | StorageOf<C extends { $production: infer E } ? E : never>\n | StorageOf<C extends { $test: infer E } ? E : never>\n | StorageOf<C extends { $prerender: infer E } ? E : never>\n | StorageOf<C extends { $env: infer E } ? E[keyof E] : never>\ntype SingleEntry<C> = Extract<StorageBranch<C>, { adapter: ProviderSlug | ((...args: never[]) => Adapter) }>\ntype NamedSet<C> = Exclude<StorageBranch<C>, { adapter: unknown }>\ntype StorageNames<C> = NamedSet<C> extends infer S ? (S extends object ? keyof S : never) : never\ntype NamedEntry<C, Name extends PropertyKey> =\n NamedSet<C> extends infer S ? (S extends object ? (Name extends keyof S ? S[Name] : never) : never) : never\n/** Map each configured storage name to its native Files client and plugin extensions. */\nexport type StorageRegistry<C extends FilesConfigInput> = {\n [Name in StorageNames<C>]: FilesForStorage<\n Extract<NamedEntry<C, Name>, { adapter: ProviderSlug | ((...args: never[]) => Adapter) }>\n >\n}\n\n/** Files client returned by an unnamed single-storage configuration. */\nexport type SingleStorage<C extends FilesConfigInput> = FilesForStorage<SingleEntry<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\n/** One provider factory statically supplied by the generated Nitro plugin. */\nexport type FilesProviderFactory = (config: never) => Adapter\n/** Provider factories available in the current build. */\nexport type FilesProviderFactories = Partial<Record<ProviderSlug, FilesProviderFactory>>\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\nconst nativeFilesOptions = ({\n adapter: _adapter,\n config: _config,\n hooks: _hooks,\n plugins: _plugins,\n ...options\n}: StorageConfig) => options\n\nexport type ProviderEnvironment = Partial<Record<ProviderSlug, readonly (readonly string[])[]>>\nexport interface RegistryDiagnostic {\n code: FilesDevtoolsDiagnosticCode\n name?: string\n adapter?: string\n}\n\n/** Lazily construct and memoize native Files clients for a validated project configuration. */\nexport class FilesRegistry<const C extends FilesConfig = FilesConfig> {\n readonly #entries: Map<string | undefined, StorageEntry>\n readonly #environment: ProviderEnvironment\n readonly #factories: FilesProviderFactories\n readonly #hooks: FilesRuntimeHooks\n readonly #adapters = new Map<string | undefined, Adapter>()\n readonly #adapterInitializing = new Set<string | undefined>()\n readonly #instances = new Map<string | undefined, Files>()\n readonly #filesInitializing = new Set<string | undefined>()\n readonly #pluginNames = new Map<string | undefined, string[]>()\n readonly #diagnostics = new Map<string | undefined, RegistryDiagnostic>()\n\n /** Create a registry without constructing a provider. */\n constructor(\n config: C,\n options: {\n environment?: ProviderEnvironment\n factories: FilesProviderFactories\n hooks?: FilesRuntimeHooks\n },\n ) {\n this.#entries = normalizeFilesConfig(config)\n if (!this.#entries.size) throw new Error('[nuxt-files-sdk:invalid-config] At least one storage is required.')\n this.#environment = options.environment ?? {}\n this.#factories = options.factories\n this.#hooks = options.hooks ?? {}\n }\n\n /** Return the client from an unnamed single-storage configuration. */\n get(...args: SingleEntry<C> extends never ? [name: never] : []): SingleStorage<C>\n /** Return one named storage client. */\n get<Name extends Extract<keyof StorageRegistry<C>, string>>(name: Name): StorageRegistry<C>[Name]\n get(...args: [] | [string]): unknown {\n const name = args[0]\n const entry = this.#entry(name)\n const key = entry.name\n const cached = this.#instances.get(key)\n if (cached) return cached\n if (this.#filesInitializing.has(key)) throw this.#circular(key)\n this.#filesInitializing.add(key)\n try {\n const files = this.#create(entry)\n this.#instances.set(key, files)\n this.#diagnostics.delete(key)\n return files\n } catch (error) {\n this.#diagnostics.set(key, {\n code: 'NUXT_FILES_ADAPTER_INIT_FAILED',\n ...(entry.name === undefined ? {} : { name: entry.name }),\n adapter: typeof entry.storage.adapter === 'string' ? entry.storage.adapter : 'custom',\n })\n throw error\n } finally {\n this.#filesInitializing.delete(key)\n }\n }\n\n /** Return secret-free storage metadata and initialization state for development diagnostics. */\n inspect() {\n return {\n storages: [...this.#entries.values()].map(({ name, storage }) => ({\n ...(name === undefined ? {} : { name }),\n adapter: typeof storage.adapter === 'string' ? storage.adapter : 'custom',\n plugins:\n this.#pluginNames.get(name) ??\n (Array.isArray(storage.plugins) ? storage.plugins.map((plugin) => plugin.name) : []),\n initialized: this.#instances.has(name),\n })),\n diagnostics: [...this.#diagnostics.values()],\n }\n }\n\n #entry(name?: string): StorageEntry {\n if (name === undefined && !this.#entries.has(undefined)) {\n throw new Error('[nuxt-files-sdk:storage-name-required] A storage name is required.')\n }\n const entry = this.#entries.get(name)\n if (!entry) throw new Error(`[nuxt-files-sdk:unknown-storage] Unknown storage \"${name}\".`)\n return entry\n }\n\n /** Resolve one selected adapter without constructing its Files client. */\n resolveAdapter(name?: string): Adapter {\n const entry = this.#entry(name)\n const key = entry.name\n const cached = this.#adapters.get(key)\n if (cached) return cached\n if (this.#adapterInitializing.has(key)) throw this.#circular(key)\n this.#adapterInitializing.add(key)\n try {\n const adapter = this.#createAdapter(entry)\n this.#adapters.set(key, adapter)\n return adapter\n } finally {\n this.#adapterInitializing.delete(key)\n }\n }\n\n #circular(name?: string): Error {\n return new Error(\n `[nuxt-files-sdk:circular-initialization] Circular storage dependency${name ? ` at \"${name}\"` : ''}.`,\n )\n }\n\n #createAdapter({ storage: selected }: StorageEntry): Adapter {\n const factory = typeof selected.adapter === 'string' ? this.#factories[selected.adapter] : selected.adapter\n if (!factory) {\n throw new Error(\n `[nuxt-files-sdk:adapter-not-generated] Adapter \"${typeof selected.adapter === 'string' ? selected.adapter : 'custom'}\" is not available in this build.`,\n )\n }\n const environment = typeof selected.adapter === 'string' ? (this.#environment[selected.adapter] ?? []) : []\n return withNuxtEnvironment(environment, () => {\n const input = typeof selected.config === 'function' ? selected.config() : selected.config\n if (input && typeof input === 'object' && 'then' in input) {\n throw new Error('[nuxt-files-sdk:async-config] Storage config functions must be synchronous.')\n }\n const value =\n selected.adapter === 's3'\n ? withS3NuxtCredentials(input)\n : selected.adapter === 'bun-s3'\n ? withBunS3NuxtOptions(input)\n : input\n // Generated factories and configs share an adapter key; the broad registry type erases that correlation.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return factory(value as never)\n })\n }\n\n #create({ name, storage }: StorageEntry): Files {\n const adapter = this.resolveAdapter(name)\n const plugins =\n typeof storage.plugins === 'function'\n ? storage.plugins({ storage: (storageName) => this.resolveAdapter(storageName) })\n : storage.plugins\n const files = createFiles({\n adapter,\n ...nativeFilesOptions(storage),\n hooks: {\n onAction: (event) =>\n runHooks(\n () => storage.hooks?.onAction?.(event),\n () => this.#hooks.onAction?.(event, name),\n ),\n onError: (event) =>\n runHooks(\n () => storage.hooks?.onError?.(event),\n () => this.#hooks.onError?.(event, name),\n ),\n onRetry: (event) =>\n runHooks(\n () => storage.hooks?.onRetry?.(event),\n () => this.#hooks.onRetry?.(event, name),\n ),\n },\n ...(plugins ? { plugins } : {}),\n })\n if (plugins)\n this.#pluginNames.set(\n name,\n plugins.map((plugin) => plugin.name),\n )\n return files\n }\n}\n\n/** Pass NUXT_ credentials explicitly because the AWS SDK resolves its chain after construction. */\nconst withS3NuxtCredentials = (input: unknown): unknown => {\n if (!input || typeof input !== 'object' || 'credentials' in input) return input\n if (\n [\n 'AWS_ACCESS_KEY_ID',\n 'AWS_SECRET_ACCESS_KEY',\n 'AWS_PROFILE',\n 'AWS_WEB_IDENTITY_TOKEN_FILE',\n 'AWS_CONTAINER_CREDENTIALS_RELATIVE_URI',\n 'AWS_CONTAINER_CREDENTIALS_FULL_URI',\n ].some((key) => process.env[key] !== undefined)\n )\n return input\n const accessKeyId = process.env.NUXT_AWS_ACCESS_KEY_ID\n const secretAccessKey = process.env.NUXT_AWS_SECRET_ACCESS_KEY\n if (!accessKeyId || !secretAccessKey) return input\n return {\n ...input,\n credentials: {\n accessKeyId,\n secretAccessKey,\n ...((process.env.AWS_SESSION_TOKEN ?? process.env.NUXT_AWS_SESSION_TOKEN) && {\n sessionToken: process.env.AWS_SESSION_TOKEN ?? process.env.NUXT_AWS_SESSION_TOKEN,\n }),\n },\n }\n}\n\n/** Bun resolves these environment keys in its own client; pass NUXT_ aliases as explicit options. */\nconst withBunS3NuxtOptions = (input: unknown): unknown => {\n if (input && (typeof input !== 'object' || 'client' in input)) return input\n const options: Record<string, unknown> = { ...(typeof input === 'object' && input ? input : {}) }\n for (const [field, key, alias] of [\n ['accessKeyId', 'AWS_ACCESS_KEY_ID', 'S3_ACCESS_KEY_ID'],\n ['secretAccessKey', 'AWS_SECRET_ACCESS_KEY', 'S3_SECRET_ACCESS_KEY'],\n ['sessionToken', 'AWS_SESSION_TOKEN', 'S3_SESSION_TOKEN'],\n ['region', 'AWS_REGION', 'S3_REGION'],\n ['bucket', 'AWS_BUCKET', 'S3_BUCKET'],\n ] as const) {\n if (Object.hasOwn(options, field) || process.env[key] !== undefined || process.env[alias] !== undefined)\n continue\n const value = process.env[`NUXT_${key}`] ?? process.env[`NUXT_${alias}`]\n if (value !== undefined) options[field] = value\n }\n return options\n}\n\n/** Bridge only NUXT_ aliases declared by the configured native provider during synchronous construction. */\nexport const withNuxtEnvironment = <T>(variables: readonly (readonly string[])[], load: () => T): T => {\n const injected: string[] = []\n for (const keys of variables) {\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 load()\n } finally {\n for (const key of injected) delete process.env[key]\n }\n}\n"],"mappings":";;;AA0EA,MAAM,WAAW,OAAO,GAAG,UAAqE;CAC5F,KAAK,MAAM,QAAQ,OACf,IAAI;EAGA,MAAM,KAAK;CACf,QAAQ,CAAC;AAEjB;AAEA,MAAM,sBAAsB,EACxB,SAAS,UACT,QAAQ,SACR,OAAO,QACP,SAAS,UACT,GAAG,cACc;;AAUrB,IAAa,gBAAb,MAAsE;CAClE;CACA;CACA;CACA;CACA,4BAAqB,IAAI,IAAiC;CAC1D,uCAAgC,IAAI,IAAwB;CAC5D,6BAAsB,IAAI,IAA+B;CACzD,qCAA8B,IAAI,IAAwB;CAC1D,+BAAwB,IAAI,IAAkC;CAC9D,+BAAwB,IAAI,IAA4C;;CAGxE,YACI,QACA,SAKF;EACE,KAAK,WAAW,qBAAqB,MAAM;EAC3C,IAAI,CAAC,KAAK,SAAS,MAAM,MAAM,IAAI,MAAM,mEAAmE;EAC5G,KAAK,eAAe,QAAQ,eAAe,CAAC;EAC5C,KAAK,aAAa,QAAQ;EAC1B,KAAK,SAAS,QAAQ,SAAS,CAAC;CACpC;CAMA,IAAI,GAAG,MAA8B;EACjC,MAAM,OAAO,KAAK;EAClB,MAAM,QAAQ,KAAK,OAAO,IAAI;EAC9B,MAAM,MAAM,MAAM;EAClB,MAAM,SAAS,KAAK,WAAW,IAAI,GAAG;EACtC,IAAI,QAAQ,OAAO;EACnB,IAAI,KAAK,mBAAmB,IAAI,GAAG,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;EACnE;GAAC;GAAgB;GAAqB;EAAkB;EACxD;GAAC;GAAU;GAAc;EAAW;EACpC;GAAC;GAAU;GAAc;EAAW;CACxC,GAAY;EACR,IAAI,OAAO,OAAO,SAAS,KAAK,KAAK,QAAQ,IAAI,SAAS,KAAA,KAAa,QAAQ,IAAI,WAAW,KAAA,GAC1F;EACJ,MAAM,QAAQ,QAAQ,IAAI,QAAQ,UAAU,QAAQ,IAAI,QAAQ;EAChE,IAAI,UAAU,KAAA,GAAW,QAAQ,SAAS;CAC9C;CACA,OAAO;AACX;;AAGA,MAAa,uBAA0B,WAA2C,SAAqB;CACnG,MAAM,WAAqB,CAAC;CAC5B,KAAK,MAAM,QAAQ,WAAW;EAC1B,IAAI,KAAK,MAAM,QAAQ,QAAQ,IAAI,SAAS,KAAA,CAAS,GAAG;EACxD,KAAK,MAAM,OAAO,MAAM;GACpB,MAAM,QAAQ,QAAQ,IAAI,QAAQ;GAClC,IAAI,UAAU,KAAA,KAAa,QAAQ,IAAI,SAAS,KAAA,GAAW;IACvD,QAAQ,IAAI,OAAO;IACnB,SAAS,KAAK,GAAG;GACrB;EACJ;CACJ;CACA,IAAI;EACA,OAAO,KAAK;CAChB,UAAU;EACN,KAAK,MAAM,OAAO,UAAU,OAAO,QAAQ,IAAI;CACnD;AACJ"}
|
package/dist/runtime.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","names":[],"sources":["../src/runtime.ts"],"sourcesContent":["import { sync, transfer, type Files, type SyncOptions, type TransferOptions } from 'files-sdk'\n\nimport { getFiles } from './runtime/internal'\n\nexport type { FilesForStorage, SingleStorage, StorageRegistry } from './runtime/registry'\n\n/** Project storage names and plugin-extended Files clients supplied by generated declarations. */\nexport interface NuxtFilesStorageRegistry {}\n/** Project single Files client supplied by generated declarations. */\nexport interface NuxtFilesSingleStorage {}\n\n/** Return the project's unnamed Files client, including its configured plugin extensions. */\nexport function useServerFiles(\n ...args: keyof NuxtFilesStorageRegistry extends never ? [] : [name: never]\n): NuxtFilesSingleStorage extends { value: infer Single } ? Single : 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): NuxtFilesStorageRegistry[Name]\nexport function useServerFiles(name?: string): Files {\n return getFiles(name)\n}\n\ntype FilesInput<Name extends string = Extract<keyof NuxtFilesStorageRegistry, string>> = Files | Name\n\n/** Delegate a mirror operation to the native Files SDK. */\nexport const syncFiles = (source: FilesInput, destination: FilesInput, options?: SyncOptions) =>\n sync(\n typeof source === 'string' ? getFiles(source) : source,\n typeof destination === 'string' ? getFiles(destination) : destination,\n options,\n )\n\n/** Delegate a transfer operation to the native Files SDK. */\nexport const transferFiles = (source: FilesInput, destination: FilesInput, options?: TransferOptions) =>\n transfer(\n typeof source === 'string' ? getFiles(source) : source,\n typeof destination === 'string' ? getFiles(destination) : destination,\n options,\n )\n"],"mappings":";;;AAmBA,SAAgB,eAAe,MAAsB;CACjD,OAAO,SAAS,IAAI;AACxB;;AAKA,MAAa,aAAa,QAAoB,aAAyB,YACnE,KACI,OAAO,WAAW,WAAW,SAAS,MAAM,IAAI,QAChD,OAAO,gBAAgB,WAAW,SAAS,WAAW,IAAI,aAC1D,OACJ;;AAGJ,MAAa,iBAAiB,QAAoB,aAAyB,YACvE,SACI,OAAO,WAAW,WAAW,SAAS,MAAM,IAAI,QAChD,OAAO,gBAAgB,WAAW,SAAS,WAAW,IAAI,aAC1D,OACJ"}
|