@ginjou/nuxt 0.1.0-beta.1
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/LICENSE +21 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +16 -0
- package/dist/module.d.ts +16 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +231 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.js +41 -0
- package/dist/types.d.mts +7 -0
- package/dist/types.d.ts +7 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) zhong666 <hi@zhong666.me> and bouzu contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/module.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface Options {
|
|
4
|
+
query?: string;
|
|
5
|
+
router?: boolean | string;
|
|
6
|
+
i18n?: string;
|
|
7
|
+
resource?: string;
|
|
8
|
+
auth?: string;
|
|
9
|
+
access?: string;
|
|
10
|
+
fetcher?: string;
|
|
11
|
+
realtime?: string;
|
|
12
|
+
notification?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: _nuxt_schema.NuxtModule<Options, Options, false>;
|
|
15
|
+
|
|
16
|
+
export { type Options, _default as default };
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface Options {
|
|
4
|
+
query?: string;
|
|
5
|
+
router?: boolean | string;
|
|
6
|
+
i18n?: string;
|
|
7
|
+
resource?: string;
|
|
8
|
+
auth?: string;
|
|
9
|
+
access?: string;
|
|
10
|
+
fetcher?: string;
|
|
11
|
+
realtime?: string;
|
|
12
|
+
notification?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: _nuxt_schema.NuxtModule<Options, Options, false>;
|
|
15
|
+
|
|
16
|
+
export { type Options, _default as default };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, addTemplate, updateTemplates, addImports, addPlugin } from '@nuxt/kit';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
|
|
5
|
+
const composables$1 = [
|
|
6
|
+
"useAccessContext",
|
|
7
|
+
"useAuthContext",
|
|
8
|
+
"useAuthenticated",
|
|
9
|
+
"useBack",
|
|
10
|
+
"useCheckError",
|
|
11
|
+
"useCreate",
|
|
12
|
+
"useCreateMany",
|
|
13
|
+
"useCustom",
|
|
14
|
+
"useCustomMutation",
|
|
15
|
+
"useDelete",
|
|
16
|
+
"useDeleteMany",
|
|
17
|
+
"useFetchersContext",
|
|
18
|
+
"useForm",
|
|
19
|
+
"useGetIdentity",
|
|
20
|
+
"useGetInfiniteList",
|
|
21
|
+
"useGetList",
|
|
22
|
+
"useGetMany",
|
|
23
|
+
"useGetOne",
|
|
24
|
+
"useGo",
|
|
25
|
+
"useI18nContext",
|
|
26
|
+
"useList",
|
|
27
|
+
"useLocale",
|
|
28
|
+
"useLocation",
|
|
29
|
+
"useLogin",
|
|
30
|
+
"useLogout",
|
|
31
|
+
"useNavigateTo",
|
|
32
|
+
"useNotificationContext",
|
|
33
|
+
"useNotify",
|
|
34
|
+
"usePermissions",
|
|
35
|
+
"usePublish",
|
|
36
|
+
"useQueryClientContext",
|
|
37
|
+
"useRealtimeContext",
|
|
38
|
+
"useRealtimeOptions",
|
|
39
|
+
"useResolvePath",
|
|
40
|
+
"useResource",
|
|
41
|
+
"useResourceContext",
|
|
42
|
+
"useResourcePath",
|
|
43
|
+
"useRouterContext",
|
|
44
|
+
"useSelect",
|
|
45
|
+
"useShow",
|
|
46
|
+
"useSubscribe",
|
|
47
|
+
"useTranslate",
|
|
48
|
+
"useUpdate",
|
|
49
|
+
"useUpdateMany"
|
|
50
|
+
];
|
|
51
|
+
const ImportListForGinjou = composables$1.map(
|
|
52
|
+
(name) => ({
|
|
53
|
+
name,
|
|
54
|
+
from: "@ginjou/vue"
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const composables = [
|
|
59
|
+
"useQuery",
|
|
60
|
+
"useQueries",
|
|
61
|
+
"useInfiniteQuery",
|
|
62
|
+
"useMutation",
|
|
63
|
+
"useIsFetching",
|
|
64
|
+
"useIsMutating",
|
|
65
|
+
"useQueryClient"
|
|
66
|
+
];
|
|
67
|
+
const ImportListForTanstackQuery = composables.map(
|
|
68
|
+
(name) => ({
|
|
69
|
+
name,
|
|
70
|
+
from: "@tanstack/vue-query"
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
function createConfigTemplate(props) {
|
|
75
|
+
const opt = props.options[props.key];
|
|
76
|
+
const paths = typeof opt === "string" ? {
|
|
77
|
+
src: props.resolve(props.nuxt.options.srcDir, opt),
|
|
78
|
+
nitro: toNitroPath(props.nuxt.options.rootDir, props.resolve(props.nuxt.options.buildDir, props.filename))
|
|
79
|
+
} : void 0;
|
|
80
|
+
return {
|
|
81
|
+
paths,
|
|
82
|
+
template: {
|
|
83
|
+
filename: props.filename,
|
|
84
|
+
getContents: async () => {
|
|
85
|
+
if (opt === false)
|
|
86
|
+
return `export default undefined`;
|
|
87
|
+
if (typeof opt === "string" && paths != null) {
|
|
88
|
+
const content = await loadContent(paths.src);
|
|
89
|
+
if (content)
|
|
90
|
+
return content;
|
|
91
|
+
}
|
|
92
|
+
return props.fallback ?? `export default undefined`;
|
|
93
|
+
},
|
|
94
|
+
write: true
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async function loadContent(path) {
|
|
99
|
+
if (existsSync(path))
|
|
100
|
+
return (await readFile(path)).toString();
|
|
101
|
+
}
|
|
102
|
+
function toNitroPath(base, full) {
|
|
103
|
+
return full.replace(base, "root").replaceAll("/", ":");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function createRouterTemplate(props) {
|
|
107
|
+
return createConfigTemplate({
|
|
108
|
+
...props,
|
|
109
|
+
key: "router",
|
|
110
|
+
filename: "ginjou-router.ts",
|
|
111
|
+
fallback: `
|
|
112
|
+
import { createRouterBinding } from '@ginjou/with-vue-router'
|
|
113
|
+
export default createRouterBinding
|
|
114
|
+
`
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const module = defineNuxtModule({
|
|
119
|
+
meta: {
|
|
120
|
+
name: "ginjou",
|
|
121
|
+
configKey: "ginjou"
|
|
122
|
+
},
|
|
123
|
+
defaults: {
|
|
124
|
+
query: "ginjou/query.ts",
|
|
125
|
+
router: "ginjou/router.ts",
|
|
126
|
+
i18n: "ginjou/i18n.ts",
|
|
127
|
+
resource: "ginjou/resource.ts",
|
|
128
|
+
auth: "ginjou/auth.ts",
|
|
129
|
+
access: "ginjou/access.ts",
|
|
130
|
+
fetcher: "ginjou/fetcher.ts",
|
|
131
|
+
realtime: "ginjou/realtime.ts",
|
|
132
|
+
notification: "ginjou/notification.ts"
|
|
133
|
+
},
|
|
134
|
+
setup: async (options, nuxt) => {
|
|
135
|
+
const { resolve } = createResolver(import.meta.url);
|
|
136
|
+
const templates = [
|
|
137
|
+
createRouterTemplate({
|
|
138
|
+
nuxt,
|
|
139
|
+
resolve,
|
|
140
|
+
options
|
|
141
|
+
}),
|
|
142
|
+
createConfigTemplate({
|
|
143
|
+
key: "query",
|
|
144
|
+
filename: "ginjou-query.ts",
|
|
145
|
+
nuxt,
|
|
146
|
+
resolve,
|
|
147
|
+
options
|
|
148
|
+
}),
|
|
149
|
+
createConfigTemplate({
|
|
150
|
+
key: "i18n",
|
|
151
|
+
filename: "ginjou-i18n.ts",
|
|
152
|
+
nuxt,
|
|
153
|
+
resolve,
|
|
154
|
+
options
|
|
155
|
+
}),
|
|
156
|
+
createConfigTemplate({
|
|
157
|
+
key: "resource",
|
|
158
|
+
filename: "ginjou-resource.ts",
|
|
159
|
+
nuxt,
|
|
160
|
+
resolve,
|
|
161
|
+
options
|
|
162
|
+
}),
|
|
163
|
+
createConfigTemplate({
|
|
164
|
+
key: "auth",
|
|
165
|
+
filename: "ginjou-auth.ts",
|
|
166
|
+
nuxt,
|
|
167
|
+
resolve,
|
|
168
|
+
options
|
|
169
|
+
}),
|
|
170
|
+
createConfigTemplate({
|
|
171
|
+
key: "access",
|
|
172
|
+
filename: "ginjou-access.ts",
|
|
173
|
+
nuxt,
|
|
174
|
+
resolve,
|
|
175
|
+
options
|
|
176
|
+
}),
|
|
177
|
+
createConfigTemplate({
|
|
178
|
+
key: "fetcher",
|
|
179
|
+
filename: "ginjou-fetcher.ts",
|
|
180
|
+
nuxt,
|
|
181
|
+
resolve,
|
|
182
|
+
options
|
|
183
|
+
}),
|
|
184
|
+
createConfigTemplate({
|
|
185
|
+
key: "realtime",
|
|
186
|
+
filename: "ginjou-realtime.ts",
|
|
187
|
+
nuxt,
|
|
188
|
+
resolve,
|
|
189
|
+
options
|
|
190
|
+
}),
|
|
191
|
+
createConfigTemplate({
|
|
192
|
+
key: "notification",
|
|
193
|
+
filename: "ginjou-notification.ts",
|
|
194
|
+
nuxt,
|
|
195
|
+
resolve,
|
|
196
|
+
options
|
|
197
|
+
})
|
|
198
|
+
];
|
|
199
|
+
for (const { template } of templates) {
|
|
200
|
+
addTemplate(template);
|
|
201
|
+
}
|
|
202
|
+
nuxt.hook("builder:watch", async (event, relativePath) => {
|
|
203
|
+
if (!["add", "unlink", "change"].includes(event)) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const path = resolve(nuxt.options.srcDir, relativePath);
|
|
207
|
+
const target = templates.find((item) => item.paths?.src === path);
|
|
208
|
+
if (!target)
|
|
209
|
+
return;
|
|
210
|
+
await updateTemplates({
|
|
211
|
+
filter: (template) => template.filename === target.template.filename
|
|
212
|
+
});
|
|
213
|
+
await nuxt.hooks.callHook("restart", { hard: true });
|
|
214
|
+
});
|
|
215
|
+
nuxt.hook("vite:extend", ({ config }) => {
|
|
216
|
+
config.optimizeDeps ??= {};
|
|
217
|
+
config.optimizeDeps.exclude ??= [];
|
|
218
|
+
config.optimizeDeps.exclude.push(...[
|
|
219
|
+
"@ginjou/core",
|
|
220
|
+
"@ginjoy/vue",
|
|
221
|
+
"@ginjou/with-vue-router",
|
|
222
|
+
"@ginjou/with-vue-i18n"
|
|
223
|
+
]);
|
|
224
|
+
});
|
|
225
|
+
addImports(ImportListForTanstackQuery);
|
|
226
|
+
addImports(ImportListForGinjou);
|
|
227
|
+
addPlugin(resolve("./runtime/plugin"));
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
export { module as default };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import GinjouAccess from "#build/ginjou-access";
|
|
2
|
+
import GinjouAuth from "#build/ginjou-auth";
|
|
3
|
+
import GinjouFetcher from "#build/ginjou-fetcher";
|
|
4
|
+
import GinjouI18n from "#build/ginjou-i18n";
|
|
5
|
+
import GinjouNotification from "#build/ginjou-notification";
|
|
6
|
+
import GinjouQuery from "#build/ginjou-query";
|
|
7
|
+
import GinjouRealtime from "#build/ginjou-realtime";
|
|
8
|
+
import GinjouResource from "#build/ginjou-resource";
|
|
9
|
+
import GinjouRouter from "#build/ginjou-router";
|
|
10
|
+
import { defineNuxtPlugin, useState } from "#imports";
|
|
11
|
+
import VuePlugin from "@ginjou/vue/plugin";
|
|
12
|
+
import { dehydrate, hydrate, QueryClient } from "@tanstack/vue-query";
|
|
13
|
+
export default defineNuxtPlugin({
|
|
14
|
+
setup: (nuxt) => {
|
|
15
|
+
const queryState = useState("ginjou-query-key");
|
|
16
|
+
const queryClient = getQueryClient(GinjouQuery);
|
|
17
|
+
nuxt.vueApp.use(VuePlugin, {
|
|
18
|
+
query: GinjouQuery,
|
|
19
|
+
router: GinjouRouter,
|
|
20
|
+
i18n: GinjouI18n,
|
|
21
|
+
resource: GinjouResource,
|
|
22
|
+
auth: GinjouAuth,
|
|
23
|
+
access: GinjouAccess,
|
|
24
|
+
fetcher: GinjouFetcher,
|
|
25
|
+
realtime: GinjouRealtime,
|
|
26
|
+
notification: GinjouNotification
|
|
27
|
+
});
|
|
28
|
+
if (import.meta.server) {
|
|
29
|
+
nuxt.hooks.hook("app:rendered", () => {
|
|
30
|
+
queryState.value = dehydrate(queryClient);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (import.meta.client)
|
|
34
|
+
hydrate(queryClient, queryState.value);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
function getQueryClient(options) {
|
|
38
|
+
const client = "queryClient" in options && options.queryClient != null ? options.queryClient : new QueryClient("queryClientConfig" in options ? options.queryClientConfig : void 0);
|
|
39
|
+
options.queryClient = client;
|
|
40
|
+
return client;
|
|
41
|
+
}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
|
+
|
|
3
|
+
import type { default as Module } from './module.js'
|
|
4
|
+
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
+
|
|
7
|
+
export { type Options, default } from './module.js'
|
package/dist/types.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ginjou/nuxt",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0-beta.1",
|
|
5
|
+
"author": "zhong666 <hi@zhong666.me>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/aa900031/ginjou"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/aa900031/ginjou/issues"
|
|
13
|
+
},
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/module.d.ts",
|
|
18
|
+
"import": "./dist/module.mjs",
|
|
19
|
+
"require": "./dist/module.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"main": "./dist/module.mjs",
|
|
23
|
+
"types": "./dist/module.d.ts",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@nuxt/kit": "^3.9.0",
|
|
32
|
+
"@ginjou/vue": "^0.1.0-beta.6",
|
|
33
|
+
"@ginjou/with-vue-router": "^0.1.0-beta.1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@nuxt/module-builder": "^0.8.4",
|
|
37
|
+
"@nuxt/schema": "^3.9.0",
|
|
38
|
+
"@nuxt/test-utils": "^3.14.4",
|
|
39
|
+
"npm-run-all2": "^6.2.6",
|
|
40
|
+
"nuxt": "^3.14.1592",
|
|
41
|
+
"@ginjou/vue": "^0.1.0-beta.6"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "run-s build:prepare build:bundle",
|
|
45
|
+
"build:bundle": "nuxt-module-build build",
|
|
46
|
+
"build:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare",
|
|
47
|
+
"dev:playground": "nuxi dev playground",
|
|
48
|
+
"dev": "run-s build:prepare dev:playground",
|
|
49
|
+
"release": "release-it --ci"
|
|
50
|
+
}
|
|
51
|
+
}
|