@anweb/nuxt-ancore 1.3.5 → 1.3.6

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/module.d.mts CHANGED
@@ -1,8 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { TApi } from '../dist/runtime/types/index.js';
3
2
 
4
3
  interface ModuleOptions {
5
- api?: TApi;
4
+ api?: string;
6
5
  }
7
6
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
8
7
 
package/dist/module.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { TApi } from '../dist/runtime/types/index.js';
3
2
 
4
3
  interface ModuleOptions {
5
- api?: TApi;
4
+ api?: string;
6
5
  }
7
6
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
8
7
 
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "AnCore",
3
3
  "configKey": "ancore",
4
- "version": "1.3.5",
4
+ "version": "1.3.6",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.1",
7
7
  "unbuild": "3.5.0"
package/dist/module.mjs CHANGED
@@ -7,11 +7,12 @@ const module = defineNuxtModule({
7
7
  },
8
8
  defaults: {},
9
9
  async setup(_options, _nuxt) {
10
- const { resolve } = createResolver(import.meta.url);
11
- _nuxt.options.runtimeConfig.public.ancore = {
12
- api: _options.api
13
- };
10
+ const { resolve, resolvePath } = createResolver(import.meta.url);
11
+ _nuxt.options.runtimeConfig.public = {};
14
12
  _nuxt.options.alias["#ancore/types"] = resolve("./runtime/types");
13
+ if (_options.api) {
14
+ _nuxt.options.alias["#ancore/customApi"] = await resolvePath(_options.api);
15
+ }
15
16
  addImportsDir(resolve("./runtime/composables"));
16
17
  addImportsDir(resolve("./runtime/utils"));
17
18
  }
@@ -1,4 +1,5 @@
1
1
  import type { ModuleOptions } from '../../module'
2
+ import type { TApi } from '#ancore/types'
2
3
 
3
4
 
4
5
  declare module 'nuxt/schema' {
@@ -10,8 +11,9 @@ declare module 'nuxt/schema' {
10
11
  }
11
12
 
12
13
  interface PublicRuntimeConfig {
13
- ancore?: Partial<ModuleOptions>
14
14
  }
15
15
  }
16
16
 
17
- export {}
17
+ declare module '#ancore/customApi' {
18
+ export const api: TApi
19
+ }
@@ -1,2 +1,2 @@
1
1
  import type { NitroFetchOptions, NitroFetchRequest } from 'nitropack';
2
- export declare const userApi: <TData = unknown, TError = unknown>(request: NitroFetchRequest, opts: NitroFetchOptions<string>) => Promise<TData>;
2
+ export declare const userApi: <TData = unknown, TError = unknown>(request: NitroFetchRequest, opts: NitroFetchOptions<string>) => any;
@@ -1,9 +1,8 @@
1
- import { useRuntimeConfig } from "#app";
2
1
  import { coreApi } from "./index.js";
2
+ import { api as customApi } from "#ancore/customApi";
3
3
  export const userApi = (request, opts) => {
4
- const runtimeConfig = useRuntimeConfig().public.ancore;
5
- if (runtimeConfig.api) {
6
- return runtimeConfig.api(request, opts);
4
+ if (customApi) {
5
+ return customApi(request, opts);
7
6
  } else {
8
7
  return coreApi(request, opts);
9
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anweb/nuxt-ancore",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "description": "AnCore Nuxt module",
5
5
  "repository": "https://github.com/ANLTD/ancore",
6
6
  "license": "MIT",