@ginjou/nuxt 0.1.0-beta.2 → 0.1.0-beta.4
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 +1 -1
- package/dist/module.cjs +153 -4
- package/dist/module.d.cts +13 -0
- package/dist/module.d.mts +8 -11
- package/dist/module.json +3 -3
- package/dist/module.mjs +56 -136
- package/dist/runtime/composables/form.d.ts +4 -0
- package/dist/runtime/composables/form.js +8 -0
- package/dist/runtime/composables/get-infinite-list.d.ts +4 -0
- package/dist/runtime/composables/get-infinite-list.js +8 -0
- package/dist/runtime/composables/get-list.d.ts +4 -0
- package/dist/runtime/composables/get-list.js +8 -0
- package/dist/runtime/composables/get-many.d.ts +4 -0
- package/dist/runtime/composables/get-many.js +8 -0
- package/dist/runtime/composables/get-one.d.ts +4 -0
- package/dist/runtime/composables/get-one.js +8 -0
- package/dist/runtime/composables/infinite-list.d.ts +4 -0
- package/dist/runtime/composables/infinite-list.js +8 -0
- package/dist/runtime/composables/list.d.ts +4 -0
- package/dist/runtime/composables/list.js +8 -0
- package/dist/runtime/composables/select.d.ts +4 -0
- package/dist/runtime/composables/select.js +8 -0
- package/dist/runtime/composables/show.d.ts +4 -0
- package/dist/runtime/composables/show.js +8 -0
- package/dist/runtime/query-hydrate-plugin.d.ts +2 -0
- package/dist/runtime/query-hydrate-plugin.js +22 -0
- package/dist/runtime/router-plugin.d.ts +2 -0
- package/dist/runtime/router-plugin.js +11 -0
- package/dist/runtime/utils/async.d.ts +2 -0
- package/dist/runtime/utils/async.js +18 -0
- package/dist/types.d.mts +4 -2
- package/package.json +20 -13
- package/dist/module.d.ts +0 -16
- package/dist/runtime/plugin.d.ts +0 -2
- package/dist/runtime/plugin.js +0 -41
- package/dist/types.d.ts +0 -7
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) zhong666 <hi@zhong666.me>
|
|
3
|
+
Copyright (c) zhong666 <hi@zhong666.me>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/module.cjs
CHANGED
|
@@ -1,5 +1,154 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const kit = require('@nuxt/kit');
|
|
4
|
+
|
|
5
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
6
|
+
const composables$2 = [
|
|
7
|
+
// Query
|
|
8
|
+
{
|
|
9
|
+
from: "./runtime/composables/get-one",
|
|
10
|
+
name: "useAsyncGetOne"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
from: "./runtime/composables/get-many",
|
|
14
|
+
name: "useAsyncGetMany"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
from: "./runtime/composables/get-list",
|
|
18
|
+
name: "useAsyncGetList"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
from: "./runtime/composables/get-infinite-list",
|
|
22
|
+
name: "useAsyncGetInfiniteList"
|
|
23
|
+
},
|
|
24
|
+
// Controllers
|
|
25
|
+
{
|
|
26
|
+
from: "./runtime/composables/show",
|
|
27
|
+
name: "useAsyncShow"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
from: "./runtime/composables/list",
|
|
31
|
+
name: "useAsyncList"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
from: "./runtime/composables/form",
|
|
35
|
+
name: "useAsyncForm"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
from: "./runtime/composables/select",
|
|
39
|
+
name: "useAsyncSelect"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
from: "./runtime/composables/infinite-list",
|
|
43
|
+
name: "useAsyncInfiniteList"
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
function ImportListForAsync(resolve) {
|
|
47
|
+
return composables$2.map(
|
|
48
|
+
(item) => ({
|
|
49
|
+
from: resolve(item.from),
|
|
50
|
+
name: item.name
|
|
51
|
+
})
|
|
52
|
+
);
|
|
3
53
|
}
|
|
4
|
-
|
|
5
|
-
|
|
54
|
+
|
|
55
|
+
const composables$1 = [
|
|
56
|
+
"useAccessContext",
|
|
57
|
+
"useAuthContext",
|
|
58
|
+
"useAuthenticated",
|
|
59
|
+
"useBack",
|
|
60
|
+
"useCheckError",
|
|
61
|
+
"useCreate",
|
|
62
|
+
"useCreateMany",
|
|
63
|
+
"useCustom",
|
|
64
|
+
"useCustomMutation",
|
|
65
|
+
"useDelete",
|
|
66
|
+
"useDeleteMany",
|
|
67
|
+
"useFetchersContext",
|
|
68
|
+
"useForm",
|
|
69
|
+
"useGetIdentity",
|
|
70
|
+
"useGetInfiniteList",
|
|
71
|
+
"useGetList",
|
|
72
|
+
"useGetMany",
|
|
73
|
+
"useGetOne",
|
|
74
|
+
"useGo",
|
|
75
|
+
"useI18nContext",
|
|
76
|
+
"useInfiniteList",
|
|
77
|
+
"useList",
|
|
78
|
+
"useLocale",
|
|
79
|
+
"useLocation",
|
|
80
|
+
"useLogin",
|
|
81
|
+
"useLogout",
|
|
82
|
+
"useNavigateTo",
|
|
83
|
+
"useNotificationContext",
|
|
84
|
+
"useNotify",
|
|
85
|
+
"usePermissions",
|
|
86
|
+
"usePublish",
|
|
87
|
+
"useQueryClientContext",
|
|
88
|
+
"useRealtimeContext",
|
|
89
|
+
"useRealtimeOptions",
|
|
90
|
+
"useResolvePath",
|
|
91
|
+
"useResource",
|
|
92
|
+
"useResourceContext",
|
|
93
|
+
"useResourcePath",
|
|
94
|
+
"useRouterContext",
|
|
95
|
+
"useSelect",
|
|
96
|
+
"useShow",
|
|
97
|
+
"useSubscribe",
|
|
98
|
+
"useTranslate",
|
|
99
|
+
"useUpdate",
|
|
100
|
+
"useUpdateMany"
|
|
101
|
+
];
|
|
102
|
+
const ImportListForGinjou = composables$1.map(
|
|
103
|
+
(name) => ({
|
|
104
|
+
name,
|
|
105
|
+
from: "@ginjou/vue"
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const composables = [
|
|
110
|
+
"useQuery",
|
|
111
|
+
"useQueries",
|
|
112
|
+
"useInfiniteQuery",
|
|
113
|
+
"useMutation",
|
|
114
|
+
"useIsFetching",
|
|
115
|
+
"useIsMutating",
|
|
116
|
+
"useQueryClient"
|
|
117
|
+
];
|
|
118
|
+
const ImportListForTanstackQuery = composables.map(
|
|
119
|
+
(name) => ({
|
|
120
|
+
name,
|
|
121
|
+
from: "@tanstack/vue-query"
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const module$1 = kit.defineNuxtModule({
|
|
126
|
+
meta: {
|
|
127
|
+
name: "ginjou",
|
|
128
|
+
configKey: "ginjou"
|
|
129
|
+
},
|
|
130
|
+
defaults: {
|
|
131
|
+
router: true
|
|
132
|
+
},
|
|
133
|
+
setup: async (options, nuxt) => {
|
|
134
|
+
const { resolve } = kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('module.cjs', document.baseURI).href)));
|
|
135
|
+
nuxt.hook("vite:extend", ({ config }) => {
|
|
136
|
+
config.optimizeDeps ??= {};
|
|
137
|
+
config.optimizeDeps.exclude ??= [];
|
|
138
|
+
config.optimizeDeps.exclude.push(...[
|
|
139
|
+
"@ginjou/core",
|
|
140
|
+
"@ginjou/vue",
|
|
141
|
+
"@ginjou/with-vue-router",
|
|
142
|
+
"@ginjou/with-vue-i18n"
|
|
143
|
+
]);
|
|
144
|
+
});
|
|
145
|
+
kit.addImports(ImportListForTanstackQuery);
|
|
146
|
+
kit.addImports(ImportListForGinjou);
|
|
147
|
+
kit.addImports(ImportListForAsync(resolve));
|
|
148
|
+
kit.addPlugin(resolve("./runtime/query-hydrate-plugin"));
|
|
149
|
+
if (options.router)
|
|
150
|
+
kit.addPlugin(resolve("./runtime/router-plugin"));
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
module.exports = module$1;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface Options {
|
|
4
|
+
router?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const _default: _nuxt_schema.NuxtModule<{
|
|
7
|
+
router: boolean;
|
|
8
|
+
}, {
|
|
9
|
+
router: boolean;
|
|
10
|
+
}, false>;
|
|
11
|
+
|
|
12
|
+
export = _default;
|
|
13
|
+
export type { Options };
|
package/dist/module.d.mts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
|
|
3
3
|
interface Options {
|
|
4
|
-
|
|
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;
|
|
4
|
+
router?: boolean;
|
|
13
5
|
}
|
|
14
|
-
declare const _default: _nuxt_schema.NuxtModule<
|
|
6
|
+
declare const _default: _nuxt_schema.NuxtModule<{
|
|
7
|
+
router: boolean;
|
|
8
|
+
}, {
|
|
9
|
+
router: boolean;
|
|
10
|
+
}, false>;
|
|
15
11
|
|
|
16
|
-
export {
|
|
12
|
+
export { _default as default };
|
|
13
|
+
export type { Options };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver,
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { defineNuxtModule, createResolver, addImports, addPlugin } from '@nuxt/kit';
|
|
2
|
+
|
|
3
|
+
const composables$2 = [
|
|
4
|
+
// Query
|
|
5
|
+
{
|
|
6
|
+
from: "./runtime/composables/get-one",
|
|
7
|
+
name: "useAsyncGetOne"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
from: "./runtime/composables/get-many",
|
|
11
|
+
name: "useAsyncGetMany"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
from: "./runtime/composables/get-list",
|
|
15
|
+
name: "useAsyncGetList"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
from: "./runtime/composables/get-infinite-list",
|
|
19
|
+
name: "useAsyncGetInfiniteList"
|
|
20
|
+
},
|
|
21
|
+
// Controllers
|
|
22
|
+
{
|
|
23
|
+
from: "./runtime/composables/show",
|
|
24
|
+
name: "useAsyncShow"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
from: "./runtime/composables/list",
|
|
28
|
+
name: "useAsyncList"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
from: "./runtime/composables/form",
|
|
32
|
+
name: "useAsyncForm"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
from: "./runtime/composables/select",
|
|
36
|
+
name: "useAsyncSelect"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
from: "./runtime/composables/infinite-list",
|
|
40
|
+
name: "useAsyncInfiniteList"
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
function ImportListForAsync(resolve) {
|
|
44
|
+
return composables$2.map(
|
|
45
|
+
(item) => ({
|
|
46
|
+
from: resolve(item.from),
|
|
47
|
+
name: item.name
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
}
|
|
4
51
|
|
|
5
52
|
const composables$1 = [
|
|
6
53
|
"useAccessContext",
|
|
@@ -23,6 +70,7 @@ const composables$1 = [
|
|
|
23
70
|
"useGetOne",
|
|
24
71
|
"useGo",
|
|
25
72
|
"useI18nContext",
|
|
73
|
+
"useInfiniteList",
|
|
26
74
|
"useList",
|
|
27
75
|
"useLocale",
|
|
28
76
|
"useLocation",
|
|
@@ -71,147 +119,16 @@ const ImportListForTanstackQuery = composables.map(
|
|
|
71
119
|
})
|
|
72
120
|
);
|
|
73
121
|
|
|
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
122
|
const module = defineNuxtModule({
|
|
119
123
|
meta: {
|
|
120
124
|
name: "ginjou",
|
|
121
125
|
configKey: "ginjou"
|
|
122
126
|
},
|
|
123
127
|
defaults: {
|
|
124
|
-
|
|
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"
|
|
128
|
+
router: true
|
|
133
129
|
},
|
|
134
130
|
setup: async (options, nuxt) => {
|
|
135
131
|
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
132
|
nuxt.hook("vite:extend", ({ config }) => {
|
|
216
133
|
config.optimizeDeps ??= {};
|
|
217
134
|
config.optimizeDeps.exclude ??= [];
|
|
@@ -224,7 +141,10 @@ const module = defineNuxtModule({
|
|
|
224
141
|
});
|
|
225
142
|
addImports(ImportListForTanstackQuery);
|
|
226
143
|
addImports(ImportListForGinjou);
|
|
227
|
-
|
|
144
|
+
addImports(ImportListForAsync(resolve));
|
|
145
|
+
addPlugin(resolve("./runtime/query-hydrate-plugin"));
|
|
146
|
+
if (options.router)
|
|
147
|
+
addPlugin(resolve("./runtime/router-plugin"));
|
|
228
148
|
}
|
|
229
149
|
});
|
|
230
150
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BaseRecord } from '@ginjou/core';
|
|
2
|
+
import type { UseFormContext, UseFormProps, UseFormResult } from '@ginjou/vue';
|
|
3
|
+
import type { AsyncResult } from '../utils/async.js';
|
|
4
|
+
export declare function useAsyncForm<TQueryData extends BaseRecord = BaseRecord, TMutationParams = unknown, TQueryError = unknown, TQueryResultData extends BaseRecord = TQueryData, TMutationData extends BaseRecord = TQueryResultData, TMutationError = unknown>(props?: UseFormProps<TQueryData, TMutationParams, TQueryError, TQueryResultData, TMutationData, TMutationError>, context?: UseFormContext): AsyncResult<UseFormResult<TMutationParams, TQueryError, TQueryResultData, TMutationData, TMutationError>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BaseRecord } from '@ginjou/core';
|
|
2
|
+
import type { UseGetInfiniteListContext, UseGetInfiniteListProps, UseGetInfiniteListResult } from '@ginjou/vue';
|
|
3
|
+
import type { AsyncResult } from '../utils/async.js';
|
|
4
|
+
export declare function useAsyncGetInfiniteList<TData extends BaseRecord = BaseRecord, TError = unknown, TResultData extends BaseRecord = TData, TPageParam = number>(props: UseGetInfiniteListProps<TData, TError, TResultData, TPageParam>, context?: UseGetInfiniteListContext): AsyncResult<UseGetInfiniteListResult<TError, TResultData, TPageParam>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useGetInfiniteList } from "@ginjou/vue";
|
|
2
|
+
import { withAsync } from "../utils/async.js";
|
|
3
|
+
export function useAsyncGetInfiniteList(props, context) {
|
|
4
|
+
const query = useGetInfiniteList(props, context);
|
|
5
|
+
return withAsync(query, async () => {
|
|
6
|
+
await query.suspense();
|
|
7
|
+
});
|
|
8
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BaseRecord } from '@ginjou/core';
|
|
2
|
+
import type { UseGetListContext, UseGetListProps, UseGetListResult } from '@ginjou/vue';
|
|
3
|
+
import type { AsyncResult } from '../utils/async.js';
|
|
4
|
+
export declare function useAsyncGetList<TData extends BaseRecord = BaseRecord, TError = unknown, TResultData extends BaseRecord = TData, TPageParam = number>(props: UseGetListProps<TData, TError, TResultData, TPageParam>, context?: UseGetListContext): AsyncResult<UseGetListResult<TError, TResultData, TPageParam>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BaseRecord } from '@ginjou/core';
|
|
2
|
+
import type { UseGetManyContext, UseGetManyProps, UseGetManyResult } from '@ginjou/vue';
|
|
3
|
+
import type { AsyncResult } from '../utils/async.js';
|
|
4
|
+
export declare function useAsyncGetMany<TData extends BaseRecord = BaseRecord, TError = unknown, TResultData extends BaseRecord = TData>(props: UseGetManyProps<TData, TError, TResultData>, context?: UseGetManyContext): AsyncResult<UseGetManyResult<TData, TError, TResultData>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BaseRecord } from '@ginjou/core';
|
|
2
|
+
import type { UseGetOneContext, UseGetOneProps, UseGetOneResult } from '@ginjou/vue';
|
|
3
|
+
import type { AsyncResult } from '../utils/async.js';
|
|
4
|
+
export declare function useAsyncGetOne<TData extends BaseRecord = BaseRecord, TError = unknown, TResultData extends BaseRecord = TData>(props: UseGetOneProps<TData, TError, TResultData>, context?: UseGetOneContext): AsyncResult<UseGetOneResult<TError, TResultData>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BaseRecord } from '@ginjou/core';
|
|
2
|
+
import type { UseInfiniteListContext, UseInfiniteListProps, UseInfiniteListResult } from '@ginjou/vue';
|
|
3
|
+
import type { AsyncResult } from '../utils/async.js';
|
|
4
|
+
export declare function useAsyncInfiniteList<TData extends BaseRecord = BaseRecord, TError = unknown, TResultData extends BaseRecord = TData, TPageParam = number>(props?: UseInfiniteListProps<TData, TError, TResultData, TPageParam>, context?: UseInfiniteListContext): AsyncResult<UseInfiniteListResult<TError, TResultData, TPageParam>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useInfiniteList } from "@ginjou/vue";
|
|
2
|
+
import { withAsync } from "../utils/async.js";
|
|
3
|
+
export function useAsyncInfiniteList(props, context) {
|
|
4
|
+
const query = useInfiniteList(props, context);
|
|
5
|
+
return withAsync(query, async () => {
|
|
6
|
+
await query.suspense();
|
|
7
|
+
});
|
|
8
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BaseRecord } from '@ginjou/core';
|
|
2
|
+
import type { UseListContext, UseListProps, UseListResult } from '@ginjou/vue';
|
|
3
|
+
import type { AsyncResult } from '../utils/async.js';
|
|
4
|
+
export declare function useAsyncList<TData extends BaseRecord = BaseRecord, TError = unknown, TResultData extends BaseRecord = TData>(props?: UseListProps<TData, TError, TResultData>, context?: UseListContext): AsyncResult<UseListResult<TError, TResultData>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BaseRecord } from '@ginjou/core';
|
|
2
|
+
import type { UseSelectContext, UseSelectProps, UseSelectResult } from '@ginjou/vue';
|
|
3
|
+
import type { AsyncResult } from '../utils/async.js';
|
|
4
|
+
export declare function useAsyncSelect<TData extends BaseRecord = BaseRecord, TError = unknown, TResultData extends BaseRecord = TData, TPageParam = number>(props?: UseSelectProps<TData, TError, TResultData, TPageParam>, context?: UseSelectContext): AsyncResult<UseSelectResult<TError, TResultData, TPageParam>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BaseRecord } from '@ginjou/core';
|
|
2
|
+
import type { UseShowContext, UseShowProps, UseShowResult } from '@ginjou/vue';
|
|
3
|
+
import type { AsyncResult } from '../utils/async.js';
|
|
4
|
+
export declare function useAsyncShow<TData extends BaseRecord = BaseRecord, TError = unknown, TResultData extends BaseRecord = TData>(props?: UseShowProps<TData, TError, TResultData>, context?: UseShowContext): AsyncResult<UseShowResult<TError, TResultData>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useState } from "#imports";
|
|
2
|
+
import { getQueryClients, setQueryClientDehydrateState } from "@ginjou/vue";
|
|
3
|
+
import { dehydrate } from "@tanstack/vue-query";
|
|
4
|
+
export default defineNuxtPlugin({
|
|
5
|
+
name: "ginjou/query-hydrate-plugin",
|
|
6
|
+
setup: (nuxt) => {
|
|
7
|
+
const dehydratedStateMap = useState("ginjou-query/dehydrated-state-map");
|
|
8
|
+
if (import.meta.server) {
|
|
9
|
+
nuxt.hooks.hook("app:rendered", () => {
|
|
10
|
+
const clients = getQueryClients();
|
|
11
|
+
dehydratedStateMap.value = Object.fromEntries(
|
|
12
|
+
[...clients].map(([key, client]) => [key, dehydrate(client)])
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (import.meta.client && dehydratedStateMap.value != null) {
|
|
17
|
+
for (const [key, value] of Object.entries(dehydratedStateMap.value)) {
|
|
18
|
+
setQueryClientDehydrateState(key, value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from "#imports";
|
|
2
|
+
import { defineRouterContext } from "@ginjou/vue";
|
|
3
|
+
import { createRouterBinding } from "@ginjou/with-vue-router";
|
|
4
|
+
export default defineNuxtPlugin({
|
|
5
|
+
name: "ginjou/router-plugin",
|
|
6
|
+
setup: (nuxt) => {
|
|
7
|
+
nuxt.hook("vue:setup", () => {
|
|
8
|
+
defineRouterContext(createRouterBinding());
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useNuxtApp } from "#imports";
|
|
2
|
+
import { getCurrentInstance, onServerPrefetch } from "vue";
|
|
3
|
+
export function withAsync(value, wait) {
|
|
4
|
+
const nuxtApp = useNuxtApp();
|
|
5
|
+
if (import.meta.server) {
|
|
6
|
+
const instance = getCurrentInstance();
|
|
7
|
+
const handler = async () => {
|
|
8
|
+
await wait();
|
|
9
|
+
};
|
|
10
|
+
if (instance)
|
|
11
|
+
onServerPrefetch(handler);
|
|
12
|
+
else
|
|
13
|
+
nuxtApp.hook("app:created", handler);
|
|
14
|
+
}
|
|
15
|
+
const promise = Promise.resolve(wait()).then(() => value);
|
|
16
|
+
Object.assign(promise, value);
|
|
17
|
+
return promise;
|
|
18
|
+
}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { NuxtModule } from '@nuxt/schema'
|
|
2
2
|
|
|
3
|
-
import type { default as Module } from './module.
|
|
3
|
+
import type { default as Module } from './module.mjs'
|
|
4
4
|
|
|
5
5
|
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { default } from './module.mjs'
|
|
8
|
+
|
|
9
|
+
export { type Options } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ginjou/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.0-beta.
|
|
4
|
+
"version": "0.1.0-beta.4",
|
|
5
5
|
"author": "zhong666 <hi@zhong666.me>",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/aa900031/ginjou#readme",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/aa900031/ginjou"
|
|
10
|
+
"url": "git+https://github.com/aa900031/ginjou.git",
|
|
11
|
+
"directory": "packages/nuxt"
|
|
10
12
|
},
|
|
11
13
|
"bugs": {
|
|
12
14
|
"url": "https://github.com/aa900031/ginjou/issues"
|
|
@@ -14,13 +16,20 @@
|
|
|
14
16
|
"sideEffects": false,
|
|
15
17
|
"exports": {
|
|
16
18
|
".": {
|
|
17
|
-
"types": "./dist/
|
|
19
|
+
"types": "./dist/types.d.mts",
|
|
18
20
|
"import": "./dist/module.mjs",
|
|
19
21
|
"require": "./dist/module.cjs"
|
|
20
22
|
}
|
|
21
23
|
},
|
|
22
24
|
"main": "./dist/module.mjs",
|
|
23
|
-
"types": "./dist/
|
|
25
|
+
"types": "./dist/types.d.mts",
|
|
26
|
+
"typesVersions": {
|
|
27
|
+
"*": {
|
|
28
|
+
".": [
|
|
29
|
+
"./dist/types.d.mts"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
24
33
|
"files": [
|
|
25
34
|
"dist"
|
|
26
35
|
],
|
|
@@ -28,17 +37,15 @@
|
|
|
28
37
|
"access": "public"
|
|
29
38
|
},
|
|
30
39
|
"dependencies": {
|
|
31
|
-
"@nuxt/kit": "^3.
|
|
32
|
-
"@ginjou/vue": "^0.1.0-beta.
|
|
33
|
-
"@ginjou/with-vue-router": "^0.1.0-beta.
|
|
40
|
+
"@nuxt/kit": "^3.17.1",
|
|
41
|
+
"@ginjou/vue": "^0.1.0-beta.8",
|
|
42
|
+
"@ginjou/with-vue-router": "^0.1.0-beta.2"
|
|
34
43
|
},
|
|
35
44
|
"devDependencies": {
|
|
36
|
-
"@nuxt/module-builder": "^0.
|
|
37
|
-
"@nuxt/schema": "^3.
|
|
38
|
-
"@nuxt/test-utils": "^3.
|
|
39
|
-
"
|
|
40
|
-
"nuxt": "^3.14.1592",
|
|
41
|
-
"@ginjou/vue": "^0.1.0-beta.6"
|
|
45
|
+
"@nuxt/module-builder": "^1.0.1",
|
|
46
|
+
"@nuxt/schema": "^3.17.1",
|
|
47
|
+
"@nuxt/test-utils": "^3.17.2",
|
|
48
|
+
"nuxt": "^3.17.1"
|
|
42
49
|
},
|
|
43
50
|
"scripts": {
|
|
44
51
|
"build": "run-s build:prepare build:bundle",
|
package/dist/module.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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/runtime/plugin.d.ts
DELETED
package/dist/runtime/plugin.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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.ts
DELETED