@movk/nuxt 1.1.1 → 1.1.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.
- package/dist/module.d.mts +0 -30
- package/dist/module.json +1 -1
- package/dist/module.mjs +44 -72
- package/dist/runtime/composables/index.d.ts +8 -0
- package/dist/runtime/composables/index.js +8 -0
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/module.d.ts +39 -0
- package/dist/runtime/types/module.js +0 -0
- package/dist/types.d.mts +6 -2
- package/package.json +33 -3
package/dist/module.d.mts
CHANGED
|
@@ -1,35 +1,5 @@
|
|
|
1
|
-
import { z } from 'zod/v4';
|
|
2
|
-
import { ApiClient, MovkApiPublicConfig, MovkApiPrivateConfig } from '../dist/runtime/types/index.js';
|
|
3
1
|
export * from '../dist/runtime/types/index.js';
|
|
4
2
|
|
|
5
|
-
declare const moduleOptionsSchema: any;
|
|
6
|
-
type ModuleOptions = z.input<typeof moduleOptionsSchema>;
|
|
7
3
|
declare const _default: any;
|
|
8
4
|
|
|
9
|
-
declare module 'nuxt/app' {
|
|
10
|
-
interface NuxtApp {
|
|
11
|
-
$api: ApiClient;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
declare module 'nuxt/schema' {
|
|
15
|
-
interface NuxtOptions {
|
|
16
|
-
['movk']: ModuleOptions;
|
|
17
|
-
}
|
|
18
|
-
interface PublicRuntimeConfig {
|
|
19
|
-
movkApi: MovkApiPublicConfig;
|
|
20
|
-
}
|
|
21
|
-
interface RuntimeConfig {
|
|
22
|
-
movkApi: MovkApiPrivateConfig;
|
|
23
|
-
}
|
|
24
|
-
interface AppConfig {
|
|
25
|
-
theme: {
|
|
26
|
-
radius: number;
|
|
27
|
-
blackAsPrimary: boolean;
|
|
28
|
-
font: string;
|
|
29
|
-
icons: string;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
5
|
export { _default as default };
|
|
35
|
-
export type { ModuleOptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { addPlugin, defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addServerHandler
|
|
2
|
-
import {
|
|
3
|
-
import { movkApiFullConfigSchema, apiToastConfigSchema, apiAuthConfigSchema, apiResponseConfigSchema } from '../dist/runtime/schemas/api.js';
|
|
1
|
+
import { addPlugin, defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addServerHandler } from '@nuxt/kit';
|
|
2
|
+
import { apiToastConfigSchema, apiAuthConfigSchema, apiResponseConfigSchema } from '../dist/runtime/schemas/api.js';
|
|
4
3
|
import defu from 'defu';
|
|
5
4
|
export * from '../dist/runtime/types/index.js';
|
|
6
5
|
|
|
7
6
|
const name = "@movk/nuxt";
|
|
8
|
-
const version = "1.1.
|
|
7
|
+
const version = "1.1.2";
|
|
9
8
|
|
|
10
9
|
function setupTheme(nuxt, resolve) {
|
|
11
10
|
nuxt.options.appConfig.theme = defu(nuxt.options.appConfig.theme || {}, {
|
|
@@ -25,101 +24,74 @@ function setupTheme(nuxt, resolve) {
|
|
|
25
24
|
});
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
27
|
+
const DEFAULT_ENDPOINT = { default: { baseURL: "/api" } };
|
|
28
|
+
function splitEndpointConfigs(endpoints) {
|
|
29
|
+
const publicEndpoints = {};
|
|
30
|
+
const privateEndpoints = {};
|
|
31
|
+
if (!endpoints) return { publicEndpoints, privateEndpoints };
|
|
32
|
+
for (const [name2, { headers, ...publicConfig }] of Object.entries(endpoints)) {
|
|
33
|
+
publicEndpoints[name2] = publicConfig;
|
|
34
|
+
if (headers) {
|
|
35
|
+
privateEndpoints[name2] = { headers };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { publicEndpoints, privateEndpoints };
|
|
39
|
+
}
|
|
40
|
+
function buildApiRuntimeConfig(apiConfig) {
|
|
41
|
+
const { publicEndpoints, privateEndpoints } = splitEndpointConfigs(apiConfig.endpoints);
|
|
42
|
+
const hasEndpoints = Object.keys(publicEndpoints).length > 0;
|
|
43
|
+
const publicConfig = {
|
|
44
|
+
defaultEndpoint: apiConfig.defaultEndpoint ?? "default",
|
|
45
|
+
debug: apiConfig.debug ?? false,
|
|
46
|
+
endpoints: hasEndpoints ? publicEndpoints : DEFAULT_ENDPOINT,
|
|
47
|
+
response: apiResponseConfigSchema.parse(apiConfig.response ?? {}),
|
|
48
|
+
auth: apiAuthConfigSchema.parse(apiConfig.auth ?? {}),
|
|
49
|
+
toast: apiToastConfigSchema.parse(apiConfig.toast ?? {})
|
|
50
|
+
};
|
|
51
|
+
const privateConfig = {
|
|
52
|
+
endpoints: Object.keys(privateEndpoints).length > 0 ? privateEndpoints : void 0
|
|
53
|
+
};
|
|
54
|
+
return { publicConfig, privateConfig };
|
|
55
|
+
}
|
|
39
56
|
const module$1 = defineNuxtModule({
|
|
40
57
|
meta: {
|
|
41
58
|
name,
|
|
42
59
|
version,
|
|
43
60
|
configKey: "movk",
|
|
44
|
-
compatibility: {
|
|
45
|
-
nuxt: ">=4.2.0"
|
|
46
|
-
}
|
|
61
|
+
compatibility: { nuxt: ">=4.2.0" }
|
|
47
62
|
},
|
|
48
|
-
defaults:
|
|
63
|
+
defaults: { prefix: "M" },
|
|
49
64
|
moduleDependencies: {
|
|
50
|
-
"@nuxt/image": {
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
"@vueuse/nuxt": {
|
|
57
|
-
version: ">=14.1.0"
|
|
58
|
-
},
|
|
59
|
-
"nuxt-og-image": {
|
|
60
|
-
version: ">=5.1.13"
|
|
61
|
-
},
|
|
62
|
-
"nuxt-auth-utils": {
|
|
63
|
-
version: ">=0.5.26"
|
|
64
|
-
}
|
|
65
|
+
"@nuxt/image": { version: ">=2.0.0" },
|
|
66
|
+
"@nuxt/ui": { version: ">=4.3.0" },
|
|
67
|
+
"@vueuse/nuxt": { version: ">=14.1.0" },
|
|
68
|
+
"nuxt-og-image": { version: ">=5.1.13" },
|
|
69
|
+
"nuxt-auth-utils": { version: ">=0.5.26" }
|
|
65
70
|
},
|
|
66
|
-
|
|
71
|
+
setup(options, nuxt) {
|
|
67
72
|
const { resolve } = createResolver(import.meta.url);
|
|
68
73
|
setupTheme(nuxt, resolve);
|
|
69
74
|
nuxt.options.alias["#movk"] = resolve("./runtime");
|
|
70
|
-
|
|
75
|
+
nuxt.options.css.push(resolve("runtime/style.css"));
|
|
71
76
|
addComponentsDir({
|
|
72
77
|
path: resolve("runtime/components"),
|
|
73
78
|
prefix: options.prefix,
|
|
74
79
|
pathPrefix: false,
|
|
75
80
|
ignore: ["auto-form-renderer/**", "theme-picker/ThemePickerButton.vue"]
|
|
76
81
|
});
|
|
77
|
-
nuxt.options.css.push(resolve("runtime/style.css"));
|
|
78
82
|
addImportsDir(resolve("runtime/composables"));
|
|
79
|
-
|
|
83
|
+
const apiConfig = options.api ?? {};
|
|
80
84
|
if (apiConfig.enabled !== false) {
|
|
81
|
-
const
|
|
82
|
-
const privateEndpoints = {};
|
|
83
|
-
if (apiConfig.endpoints) {
|
|
84
|
-
for (const [endpointName, endpoint] of Object.entries(apiConfig.endpoints)) {
|
|
85
|
-
const { headers, ...publicConfig2 } = endpoint;
|
|
86
|
-
publicEndpoints[endpointName] = publicConfig2;
|
|
87
|
-
if (headers) {
|
|
88
|
-
privateEndpoints[endpointName] = { headers };
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const publicConfig = {
|
|
93
|
-
defaultEndpoint: apiConfig.defaultEndpoint ?? "default",
|
|
94
|
-
debug: apiConfig.debug ?? false,
|
|
95
|
-
endpoints: Object.keys(publicEndpoints).length > 0 ? publicEndpoints : { default: { baseURL: "/api" } },
|
|
96
|
-
response: apiResponseConfigSchema.parse(apiConfig.response ?? {}),
|
|
97
|
-
auth: apiAuthConfigSchema.parse(apiConfig.auth ?? {}),
|
|
98
|
-
toast: apiToastConfigSchema.parse(apiConfig.toast ?? {})
|
|
99
|
-
};
|
|
100
|
-
const privateConfig = {
|
|
101
|
-
endpoints: Object.keys(privateEndpoints).length > 0 ? privateEndpoints : void 0
|
|
102
|
-
};
|
|
85
|
+
const { publicConfig, privateConfig } = buildApiRuntimeConfig(apiConfig);
|
|
103
86
|
nuxt.options.runtimeConfig.movkApi = privateConfig;
|
|
104
87
|
nuxt.options.runtimeConfig.public.movkApi = publicConfig;
|
|
105
|
-
addPlugin({
|
|
106
|
-
src: resolve("runtime/plugins/api.factory"),
|
|
107
|
-
mode: "all"
|
|
108
|
-
});
|
|
88
|
+
addPlugin({ src: resolve("runtime/plugins/api.factory"), mode: "all" });
|
|
109
89
|
addServerHandler({
|
|
110
90
|
route: "/api/_movk/session",
|
|
111
91
|
method: "post",
|
|
112
92
|
handler: resolve("runtime/server/api/_movk/session.post")
|
|
113
93
|
});
|
|
114
94
|
}
|
|
115
|
-
addTypeTemplate({
|
|
116
|
-
filename: "runtime/types/auto-form-zod.d.ts",
|
|
117
|
-
src: resolve("runtime/types/zod.d.ts")
|
|
118
|
-
});
|
|
119
|
-
addTypeTemplate({
|
|
120
|
-
filename: "runtime/types/auth.d.ts",
|
|
121
|
-
src: resolve("runtime/types/auth.d.ts")
|
|
122
|
-
});
|
|
123
95
|
}
|
|
124
96
|
});
|
|
125
97
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './useApiFetch.js';
|
|
2
|
+
export * from './useClientApiFetch.js';
|
|
3
|
+
export * from './useApiAuth.js';
|
|
4
|
+
export * from './useDownloadWithProgress.js';
|
|
5
|
+
export * from './useUploadWithProgress.js';
|
|
6
|
+
export * from './useAutoForm.js';
|
|
7
|
+
export * from './useTheme.js';
|
|
8
|
+
export * from './useDateFormatter.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./useApiFetch.js";
|
|
2
|
+
export * from "./useClientApiFetch.js";
|
|
3
|
+
export * from "./useApiAuth.js";
|
|
4
|
+
export * from "./useDownloadWithProgress.js";
|
|
5
|
+
export * from "./useUploadWithProgress.js";
|
|
6
|
+
export * from "./useAutoForm.js";
|
|
7
|
+
export * from "./useTheme.js";
|
|
8
|
+
export * from "./useDateFormatter.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ApiClient, MovkApiPublicConfig, MovkApiPrivateConfig, MovkApiFullConfig } from './api.js';
|
|
2
|
+
export interface ModuleOptions {
|
|
3
|
+
/**
|
|
4
|
+
* 组件前缀
|
|
5
|
+
* @default 'M'
|
|
6
|
+
*/
|
|
7
|
+
prefix?: string;
|
|
8
|
+
/**
|
|
9
|
+
* API 模块配置
|
|
10
|
+
*/
|
|
11
|
+
api?: MovkApiFullConfig;
|
|
12
|
+
}
|
|
13
|
+
declare module '#app' {
|
|
14
|
+
interface NuxtApp {
|
|
15
|
+
$api: ApiClient;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
declare module 'nuxt/schema' {
|
|
19
|
+
interface NuxtConfig {
|
|
20
|
+
movk?: ModuleOptions;
|
|
21
|
+
}
|
|
22
|
+
interface NuxtOptions {
|
|
23
|
+
movk: ModuleOptions;
|
|
24
|
+
}
|
|
25
|
+
interface PublicRuntimeConfig {
|
|
26
|
+
movkApi: MovkApiPublicConfig;
|
|
27
|
+
}
|
|
28
|
+
interface RuntimeConfig {
|
|
29
|
+
movkApi: MovkApiPrivateConfig;
|
|
30
|
+
}
|
|
31
|
+
interface AppConfig {
|
|
32
|
+
theme: {
|
|
33
|
+
radius: number;
|
|
34
|
+
blackAsPrimary: boolean;
|
|
35
|
+
font: string;
|
|
36
|
+
icons: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
File without changes
|
package/dist/types.d.mts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
|
+
|
|
3
|
+
import type { default as Module } from './module.mjs'
|
|
2
4
|
|
|
3
|
-
export
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
+
|
|
7
|
+
export { default } from './module.mjs'
|
|
4
8
|
|
|
5
9
|
export * from '../dist/runtime/types/index.js'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movk/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"packageManager": "pnpm@10.28.0",
|
|
6
6
|
"description": "Modular engineering suite for Nuxt 4 with schema-driven forms, API integration, UI components and composables",
|
|
7
7
|
"author": "YiXuan <mhaibaraai@gmail.com>",
|
|
@@ -36,12 +36,42 @@
|
|
|
36
36
|
],
|
|
37
37
|
"exports": {
|
|
38
38
|
".": {
|
|
39
|
-
"types": "./dist/
|
|
39
|
+
"types": "./dist/module.d.mts",
|
|
40
|
+
"style": "./dist/runtime/style.css",
|
|
40
41
|
"import": "./dist/module.mjs"
|
|
42
|
+
},
|
|
43
|
+
"./runtime/*": "./dist/runtime/*",
|
|
44
|
+
"./components/*": "./dist/runtime/components/*",
|
|
45
|
+
"./composables": {
|
|
46
|
+
"types": "./dist/runtime/composables/index.d.ts",
|
|
47
|
+
"import": "./dist/runtime/composables/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./composables/*": {
|
|
50
|
+
"types": "./dist/runtime/composables/*.d.ts",
|
|
51
|
+
"import": "./dist/runtime/composables/*.js"
|
|
41
52
|
}
|
|
42
53
|
},
|
|
54
|
+
"typesVersions": {
|
|
55
|
+
"*": {
|
|
56
|
+
".": [
|
|
57
|
+
"./dist/module.d.mts"
|
|
58
|
+
],
|
|
59
|
+
"runtime/*": [
|
|
60
|
+
"./dist/runtime/*"
|
|
61
|
+
],
|
|
62
|
+
"components/*": [
|
|
63
|
+
"./dist/runtime/components/*"
|
|
64
|
+
],
|
|
65
|
+
"composables": [
|
|
66
|
+
"./dist/runtime/composables/index.d.ts"
|
|
67
|
+
],
|
|
68
|
+
"composables/*": [
|
|
69
|
+
"./dist/runtime/composables/*.d.ts"
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"style": "./dist/runtime/index.css",
|
|
43
74
|
"main": "./dist/module.mjs",
|
|
44
|
-
"types": "./dist/types.d.mts",
|
|
45
75
|
"files": [
|
|
46
76
|
"dist"
|
|
47
77
|
],
|