@anweb/nuxt-ancore 1.3.3 → 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,6 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  interface ModuleOptions {
4
+ api?: string;
4
5
  }
5
6
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
6
7
 
package/dist/module.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  interface ModuleOptions {
4
+ api?: string;
4
5
  }
5
6
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
6
7
 
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "AnCore",
3
3
  "configKey": "ancore",
4
- "version": "1.3.3",
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,9 +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 = {};
10
+ const { resolve, resolvePath } = createResolver(import.meta.url);
11
+ _nuxt.options.runtimeConfig.public = {};
12
12
  _nuxt.options.alias["#ancore/types"] = resolve("./runtime/types");
13
+ if (_options.api) {
14
+ _nuxt.options.alias["#ancore/customApi"] = await resolvePath(_options.api);
15
+ }
13
16
  addImportsDir(resolve("./runtime/composables"));
14
17
  addImportsDir(resolve("./runtime/utils"));
15
18
  }
@@ -1,6 +1,6 @@
1
1
  import { computed, ref } from "vue";
2
2
  import { useAsyncData } from "#app";
3
- import { userApi } from "#ancore/utils";
3
+ import { userApi } from "../utils/index.js";
4
4
  export const useData = (config) => {
5
5
  const request = ref(config.request);
6
6
  const loading = computed(() => {
@@ -1,7 +1,7 @@
1
1
  import { useEventBus } from "@vueuse/core";
2
2
  import { computed, ref, reactive, watch } from "vue";
3
3
  import { useAsyncData } from "#app";
4
- import { userApi, toQuery } from "#ancore/utils";
4
+ import { userApi, toQuery } from "../utils/index.js";
5
5
  export default (config) => {
6
6
  const busWS = useEventBus("ws");
7
7
  const inited = ref(false);
@@ -0,0 +1,19 @@
1
+ import type { ModuleOptions } from '../../module'
2
+ import type { TApi } from '#ancore/types'
3
+
4
+
5
+ declare module 'nuxt/schema' {
6
+ interface NuxtConfig {
7
+ ancore?: ModuleOptions
8
+ }
9
+
10
+ interface RuntimeConfig {
11
+ }
12
+
13
+ interface PublicRuntimeConfig {
14
+ }
15
+ }
16
+
17
+ declare module '#ancore/customApi' {
18
+ export const api: TApi
19
+ }
@@ -0,0 +1,7 @@
1
+ import type { NitroFetchRequest, NitroFetchOptions } from 'nitropack'
2
+
3
+
4
+ export type TApi = <TData = unknown, TError = unknown>(
5
+ request: NitroFetchRequest,
6
+ opts: NitroFetchOptions<string>
7
+ ) => Promise<TData>
@@ -1,3 +1,4 @@
1
- export * from './nuxt.js';
1
+ export * from './ancore.js';
2
+ export * from './api.js';
2
3
  export * from './ws.js';
3
4
  export * from './responseList.js';
@@ -1,3 +1,4 @@
1
- export * from "./nuxt";
2
- export * from "./ws.js";
3
- export * from "./responseList.js";
1
+ export * from "./ancore";
2
+ export * from "./api";
3
+ export * from "./ws";
4
+ export * from "./responseList";
@@ -1,4 +1,4 @@
1
- export interface TResponseList<TData> {
2
- items: TData[];
3
- count: number;
4
- }
1
+ export interface TResponseList<TData> {
2
+ items: TData[]
3
+ count: number
4
+ }
@@ -1,4 +1,4 @@
1
- export interface TWS {
2
- type: string;
3
- data: unknown;
4
- }
1
+ export interface TWS {
2
+ type: string
3
+ data: unknown
4
+ }
@@ -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 { useNuxtApp } from "#app";
2
- import { coreApi } from "#ancore/utils";
1
+ import { coreApi } from "./index.js";
2
+ import { api as customApi } from "#ancore/customApi";
3
3
  export const userApi = (request, opts) => {
4
- const { $api } = useNuxtApp();
5
- if ($api) {
6
- return $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.3",
3
+ "version": "1.3.6",
4
4
  "description": "AnCore Nuxt module",
5
5
  "repository": "https://github.com/ANLTD/ancore",
6
6
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "release:major": "npm run prepack && changelogen --bump major --release && npm publish --access public && git push --follow-tags"
33
33
  },
34
34
  "dependencies": {
35
- "@nuxt/kit": "^4.0.0",
35
+ "@nuxt/kit": "^4.0.1",
36
36
  "@vueuse/core": "^13.5.0",
37
37
  "@vueuse/integrations": "^13.5.0",
38
38
  "async-validator": "^4.2.5"
@@ -40,10 +40,10 @@
40
40
  "devDependencies": {
41
41
  "@nuxt/devtools": "^2.6.2",
42
42
  "@nuxt/module-builder": "^1.0.1",
43
- "@nuxt/schema": "^3.17.7",
43
+ "@nuxt/schema": "^4.0.1",
44
44
  "@types/node": "latest",
45
45
  "changelogen": "^0.6.2",
46
- "nuxt": "^4.0.0",
46
+ "nuxt": "^4.0.1",
47
47
  "typescript": "~5.8.3"
48
48
  }
49
49
  }
@@ -1,8 +0,0 @@
1
- import type { TApi } from '#ancore/utils'
2
-
3
-
4
- declare module '#app' {
5
- interface NuxtApp {
6
- $api: TApi
7
- }
8
- }
File without changes
File without changes