@anweb/nuxt-ancore 1.3.2 → 1.3.5

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