@ginjou/nuxt 0.1.0-beta.1 → 0.1.0-beta.11

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.
Files changed (44) hide show
  1. package/LICENSE +1 -1
  2. package/dist/module.cjs +173 -4
  3. package/dist/module.d.cts +13 -0
  4. package/dist/module.d.mts +8 -11
  5. package/dist/module.json +3 -3
  6. package/dist/module.mjs +87 -147
  7. package/dist/runtime/composables/authenticated.d.ts +4 -0
  8. package/dist/runtime/composables/authenticated.js +8 -0
  9. package/dist/runtime/composables/can.d.ts +3 -0
  10. package/dist/runtime/composables/can.js +8 -0
  11. package/dist/runtime/composables/edit.d.ts +4 -0
  12. package/dist/runtime/composables/edit.js +8 -0
  13. package/dist/runtime/composables/get-infinite-list.d.ts +4 -0
  14. package/dist/runtime/composables/get-infinite-list.js +8 -0
  15. package/dist/runtime/composables/get-list.d.ts +4 -0
  16. package/dist/runtime/composables/get-list.js +8 -0
  17. package/dist/runtime/composables/get-many.d.ts +4 -0
  18. package/dist/runtime/composables/get-many.js +8 -0
  19. package/dist/runtime/composables/get-one.d.ts +4 -0
  20. package/dist/runtime/composables/get-one.js +8 -0
  21. package/dist/runtime/composables/identity.d.ts +4 -0
  22. package/dist/runtime/composables/identity.js +8 -0
  23. package/dist/runtime/composables/infinite-list.d.ts +4 -0
  24. package/dist/runtime/composables/infinite-list.js +8 -0
  25. package/dist/runtime/composables/list.d.ts +4 -0
  26. package/dist/runtime/composables/list.js +8 -0
  27. package/dist/runtime/composables/permissions.d.ts +3 -0
  28. package/dist/runtime/composables/permissions.js +8 -0
  29. package/dist/runtime/composables/select.d.ts +4 -0
  30. package/dist/runtime/composables/select.js +8 -0
  31. package/dist/runtime/composables/show.d.ts +4 -0
  32. package/dist/runtime/composables/show.js +8 -0
  33. package/dist/runtime/query-hydrate-plugin.d.ts +2 -0
  34. package/dist/runtime/query-hydrate-plugin.js +22 -0
  35. package/dist/runtime/router-plugin.d.ts +2 -0
  36. package/dist/runtime/router-plugin.js +11 -0
  37. package/dist/runtime/utils/async.d.ts +2 -0
  38. package/dist/runtime/utils/async.js +18 -0
  39. package/dist/types.d.mts +4 -2
  40. package/package.json +22 -14
  41. package/dist/module.d.ts +0 -16
  42. package/dist/runtime/plugin.d.ts +0 -2
  43. package/dist/runtime/plugin.js +0 -41
  44. 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> and bouzu contributors
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,174 @@
1
- module.exports = function(...args) {
2
- return import('./module.mjs').then(m => m.default.call(this, ...args))
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/edit",
35
+ name: "useAsyncEdit"
36
+ },
37
+ {
38
+ from: "./runtime/composables/select",
39
+ name: "useAsyncSelect"
40
+ },
41
+ {
42
+ from: "./runtime/composables/infinite-list",
43
+ name: "useAsyncInfiniteList"
44
+ },
45
+ // Auth
46
+ {
47
+ from: "./runtime/composables/authenticated",
48
+ name: "useAsyncAuthenticated"
49
+ },
50
+ {
51
+ from: "./runtime/composables/identity",
52
+ name: "useAsyncGetIdentity"
53
+ },
54
+ // Authz
55
+ {
56
+ from: "./runtime/composables/permissions",
57
+ name: "useAsyncPermissions"
58
+ },
59
+ {
60
+ from: "./runtime/composables/can",
61
+ name: "useAsyncCanAccess"
62
+ }
63
+ ];
64
+ function ImportListForAsync(resolve) {
65
+ return composables$2.map(
66
+ (item) => ({
67
+ from: resolve(item.from),
68
+ name: item.name
69
+ })
70
+ );
3
71
  }
4
- const _meta = module.exports.meta = require('./module.json')
5
- module.exports.getMeta = () => Promise.resolve(_meta)
72
+
73
+ const composables$1 = [
74
+ "useAuthContext",
75
+ "useAuthzContext",
76
+ "useAuthenticated",
77
+ "useBack",
78
+ "useCanAccess",
79
+ "useCheckError",
80
+ "useCreateOne",
81
+ "useCreateMany",
82
+ "useCustom",
83
+ "useCustomMutation",
84
+ "useDeleteOne",
85
+ "useDeleteMany",
86
+ "useFetchersContext",
87
+ "useCreate",
88
+ "useEdit",
89
+ "useGetIdentity",
90
+ "useGetInfiniteList",
91
+ "useGetList",
92
+ "useGetMany",
93
+ "useGetOne",
94
+ "useGo",
95
+ "useI18nContext",
96
+ "useInfiniteList",
97
+ "useList",
98
+ "useLocale",
99
+ "useLocation",
100
+ "useLogin",
101
+ "useLogout",
102
+ "useNavigateTo",
103
+ "useNotificationContext",
104
+ "useNotify",
105
+ "usePermissions",
106
+ "usePublish",
107
+ "useQueryClientContext",
108
+ "useRealtimeContext",
109
+ "useRealtimeOptions",
110
+ "useResolvePath",
111
+ "useResource",
112
+ "useResourceContext",
113
+ "useResourcePath",
114
+ "useRouterContext",
115
+ "useSelect",
116
+ "useShow",
117
+ "useSubscribe",
118
+ "useTranslate",
119
+ "useUpdateOne",
120
+ "useUpdateMany"
121
+ ];
122
+ const ImportListForGinjou = composables$1.map(
123
+ (name) => ({
124
+ name,
125
+ from: "@ginjou/vue"
126
+ })
127
+ );
128
+
129
+ const composables = [
130
+ "useQuery",
131
+ "useQueries",
132
+ "useInfiniteQuery",
133
+ "useMutation",
134
+ "useIsFetching",
135
+ "useIsMutating",
136
+ "useQueryClient"
137
+ ];
138
+ const ImportListForTanstackQuery = composables.map(
139
+ (name) => ({
140
+ name,
141
+ from: "@tanstack/vue-query"
142
+ })
143
+ );
144
+
145
+ const module$1 = kit.defineNuxtModule({
146
+ meta: {
147
+ name: "ginjou",
148
+ configKey: "ginjou"
149
+ },
150
+ defaults: {
151
+ router: true
152
+ },
153
+ setup: async (options, nuxt) => {
154
+ 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)));
155
+ nuxt.hook("vite:extend", ({ config }) => {
156
+ config.optimizeDeps ??= {};
157
+ config.optimizeDeps.include ??= [];
158
+ config.optimizeDeps.include.push(
159
+ "@ginjou/core",
160
+ "@ginjou/vue",
161
+ "@ginjou/with-vue-router",
162
+ "@ginjou/with-vue-i18n"
163
+ );
164
+ });
165
+ kit.addImports(ImportListForTanstackQuery);
166
+ kit.addImports(ImportListForGinjou);
167
+ kit.addImports(ImportListForAsync(resolve));
168
+ kit.addPlugin(resolve("./runtime/query-hydrate-plugin"));
169
+ if (options.router)
170
+ kit.addPlugin(resolve("./runtime/router-plugin"));
171
+ }
172
+ });
173
+
174
+ 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
- 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;
4
+ router?: boolean;
13
5
  }
14
- declare const _default: _nuxt_schema.NuxtModule<Options, Options, false>;
6
+ declare const _default: _nuxt_schema.NuxtModule<{
7
+ router: boolean;
8
+ }, {
9
+ router: boolean;
10
+ }, false>;
15
11
 
16
- export { type Options, _default as default };
12
+ export { _default as default };
13
+ export type { Options };
package/dist/module.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "ginjou",
3
3
  "configKey": "ginjou",
4
- "version": "0.1.0-beta.1",
4
+ "version": "0.1.0-beta.11",
5
5
  "builder": {
6
- "@nuxt/module-builder": "0.8.4",
7
- "unbuild": "2.0.0"
6
+ "@nuxt/module-builder": "1.0.2",
7
+ "unbuild": "3.6.1"
8
8
  }
9
9
  }
package/dist/module.mjs CHANGED
@@ -1,21 +1,88 @@
1
- import { defineNuxtModule, createResolver, addTemplate, updateTemplates, addImports, addPlugin } from '@nuxt/kit';
2
- import { existsSync } from 'node:fs';
3
- import { readFile } from 'node:fs/promises';
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/edit",
32
+ name: "useAsyncEdit"
33
+ },
34
+ {
35
+ from: "./runtime/composables/select",
36
+ name: "useAsyncSelect"
37
+ },
38
+ {
39
+ from: "./runtime/composables/infinite-list",
40
+ name: "useAsyncInfiniteList"
41
+ },
42
+ // Auth
43
+ {
44
+ from: "./runtime/composables/authenticated",
45
+ name: "useAsyncAuthenticated"
46
+ },
47
+ {
48
+ from: "./runtime/composables/identity",
49
+ name: "useAsyncGetIdentity"
50
+ },
51
+ // Authz
52
+ {
53
+ from: "./runtime/composables/permissions",
54
+ name: "useAsyncPermissions"
55
+ },
56
+ {
57
+ from: "./runtime/composables/can",
58
+ name: "useAsyncCanAccess"
59
+ }
60
+ ];
61
+ function ImportListForAsync(resolve) {
62
+ return composables$2.map(
63
+ (item) => ({
64
+ from: resolve(item.from),
65
+ name: item.name
66
+ })
67
+ );
68
+ }
4
69
 
5
70
  const composables$1 = [
6
- "useAccessContext",
7
71
  "useAuthContext",
72
+ "useAuthzContext",
8
73
  "useAuthenticated",
9
74
  "useBack",
75
+ "useCanAccess",
10
76
  "useCheckError",
11
- "useCreate",
77
+ "useCreateOne",
12
78
  "useCreateMany",
13
79
  "useCustom",
14
80
  "useCustomMutation",
15
- "useDelete",
81
+ "useDeleteOne",
16
82
  "useDeleteMany",
17
83
  "useFetchersContext",
18
- "useForm",
84
+ "useCreate",
85
+ "useEdit",
19
86
  "useGetIdentity",
20
87
  "useGetInfiniteList",
21
88
  "useGetList",
@@ -23,6 +90,7 @@ const composables$1 = [
23
90
  "useGetOne",
24
91
  "useGo",
25
92
  "useI18nContext",
93
+ "useInfiniteList",
26
94
  "useList",
27
95
  "useLocale",
28
96
  "useLocation",
@@ -45,7 +113,7 @@ const composables$1 = [
45
113
  "useShow",
46
114
  "useSubscribe",
47
115
  "useTranslate",
48
- "useUpdate",
116
+ "useUpdateOne",
49
117
  "useUpdateMany"
50
118
  ];
51
119
  const ImportListForGinjou = composables$1.map(
@@ -71,161 +139,33 @@ const ImportListForTanstackQuery = composables.map(
71
139
  })
72
140
  );
73
141
 
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({
142
+ const module$1 = defineNuxtModule({
119
143
  meta: {
120
144
  name: "ginjou",
121
145
  configKey: "ginjou"
122
146
  },
123
147
  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"
148
+ router: true
133
149
  },
134
150
  setup: async (options, nuxt) => {
135
151
  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
152
  nuxt.hook("vite:extend", ({ config }) => {
216
153
  config.optimizeDeps ??= {};
217
- config.optimizeDeps.exclude ??= [];
218
- config.optimizeDeps.exclude.push(...[
154
+ config.optimizeDeps.include ??= [];
155
+ config.optimizeDeps.include.push(
219
156
  "@ginjou/core",
220
- "@ginjoy/vue",
157
+ "@ginjou/vue",
221
158
  "@ginjou/with-vue-router",
222
159
  "@ginjou/with-vue-i18n"
223
- ]);
160
+ );
224
161
  });
225
162
  addImports(ImportListForTanstackQuery);
226
163
  addImports(ImportListForGinjou);
227
- addPlugin(resolve("./runtime/plugin"));
164
+ addImports(ImportListForAsync(resolve));
165
+ addPlugin(resolve("./runtime/query-hydrate-plugin"));
166
+ if (options.router)
167
+ addPlugin(resolve("./runtime/router-plugin"));
228
168
  }
229
169
  });
230
170
 
231
- export { module as default };
171
+ export { module$1 as default };
@@ -0,0 +1,4 @@
1
+ import type { Params } from '@ginjou/core';
2
+ import type { UseAuthenticatedContext, UseAuthenticatedProps, UseAuthenticatedResult } from '@ginjou/vue';
3
+ import type { AsyncResult } from '../utils/async.js';
4
+ export declare function useAsyncAuthenticated<TParams extends Params = Params, TError = unknown>(props?: UseAuthenticatedProps<TParams, TError>, context?: UseAuthenticatedContext): AsyncResult<UseAuthenticatedResult<TError>>;
@@ -0,0 +1,8 @@
1
+ import { useAuthenticated } from "@ginjou/vue";
2
+ import { withAsync } from "../utils/async.js";
3
+ export function useAsyncAuthenticated(props, context) {
4
+ const query = useAuthenticated(props, context);
5
+ return withAsync(query, async () => {
6
+ await query.suspense();
7
+ });
8
+ }
@@ -0,0 +1,3 @@
1
+ import type { UseCanAccessContext, UseCanAccessProps, UseCanAccessResult } from '@ginjou/vue';
2
+ import type { AsyncResult } from '../utils/async.js';
3
+ export declare function useAsyncCanAccess<TError = unknown>(props: UseCanAccessProps<TError>, context?: UseCanAccessContext): AsyncResult<UseCanAccessResult<TError>>;
@@ -0,0 +1,8 @@
1
+ import { useCanAccess } from "@ginjou/vue";
2
+ import { withAsync } from "../utils/async.js";
3
+ export function useAsyncCanAccess(props, context) {
4
+ const query = useCanAccess(props, context);
5
+ return withAsync(query, async () => {
6
+ await query.suspense();
7
+ });
8
+ }
@@ -0,0 +1,4 @@
1
+ import type { BaseRecord, Params } from '@ginjou/core';
2
+ import type { UseEditContext, UseEditProps, UseEditResult } from '@ginjou/vue';
3
+ import type { AsyncResult } from '../utils/async.js';
4
+ export declare function useAsyncEdit<TQueryData extends BaseRecord = BaseRecord, TMutationParams extends Params = Params, TQueryError = unknown, TQueryResultData extends BaseRecord = TQueryData, TMutationData extends BaseRecord = TQueryResultData, TMutationError = unknown>(props?: UseEditProps<TQueryData, TMutationParams, TQueryError, TQueryResultData, TMutationData, TMutationError>, context?: UseEditContext): AsyncResult<UseEditResult<TMutationParams, TQueryError, TQueryResultData, TMutationData, TMutationError>>;
@@ -0,0 +1,8 @@
1
+ import { useEdit } from "@ginjou/vue";
2
+ import { withAsync } from "../utils/async.js";
3
+ export function useAsyncEdit(props, context) {
4
+ const result = useEdit(props, context);
5
+ return withAsync(result, async () => {
6
+ await result.query.suspense();
7
+ });
8
+ }
@@ -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,8 @@
1
+ import { useGetList } from "@ginjou/vue";
2
+ import { withAsync } from "../utils/async.js";
3
+ export function useAsyncGetList(props, context) {
4
+ const query = useGetList(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 { 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,8 @@
1
+ import { useGetMany } from "@ginjou/vue";
2
+ import { withAsync } from "../utils/async.js";
3
+ export function useAsyncGetMany(props, context) {
4
+ const query = useGetMany(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 { 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,8 @@
1
+ import { useGetOne } from "@ginjou/vue";
2
+ import { withAsync } from "../utils/async.js";
3
+ export function useAsyncGetOne(props, context) {
4
+ const query = useGetOne(props, context);
5
+ return withAsync(query, async () => {
6
+ await query.suspense();
7
+ });
8
+ }
@@ -0,0 +1,4 @@
1
+ import type { BaseRecord, Params } from '@ginjou/core';
2
+ import type { UseGetIdentityContext, UseGetIdentityProps, UseGetIdentityResult } from '@ginjou/vue';
3
+ import type { AsyncResult } from '../utils/async.js';
4
+ export declare function useAsyncGetIdentity<TData extends BaseRecord = BaseRecord, TParams extends Params = Params, TError = unknown>(props?: UseGetIdentityProps<TData, TParams, TError>, context?: UseGetIdentityContext): AsyncResult<UseGetIdentityResult<TData, TError>>;
@@ -0,0 +1,8 @@
1
+ import { useGetIdentity } from "@ginjou/vue";
2
+ import { withAsync } from "../utils/async.js";
3
+ export function useAsyncGetIdentity(props, context) {
4
+ const query = useGetIdentity(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 { 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,8 @@
1
+ import { useList } from "@ginjou/vue";
2
+ import { withAsync } from "../utils/async.js";
3
+ export function useAsyncList(props, context) {
4
+ const query = useList(props, context);
5
+ return withAsync(query, async () => {
6
+ await query.suspense();
7
+ });
8
+ }
@@ -0,0 +1,3 @@
1
+ import type { UsePermissionsProps, UsePermissionsResult, UserPermissionsContext } from '@ginjou/vue';
2
+ import type { AsyncResult } from '../utils/async.js';
3
+ export declare function useAsyncPermissions<TData = unknown, TParams = unknown, TError = unknown>(props?: UsePermissionsProps<TData, TParams, TError>, context?: UserPermissionsContext): AsyncResult<UsePermissionsResult<TData, TError>>;
@@ -0,0 +1,8 @@
1
+ import { usePermissions } from "@ginjou/vue";
2
+ import { withAsync } from "../utils/async.js";
3
+ export function useAsyncPermissions(props, context) {
4
+ const query = usePermissions(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 { 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,8 @@
1
+ import { useSelect } from "@ginjou/vue";
2
+ import { withAsync } from "../utils/async.js";
3
+ export function useAsyncSelect(props, context) {
4
+ const result = useSelect(props, context);
5
+ return withAsync(result, async () => {
6
+ await result.suspense();
7
+ });
8
+ }
@@ -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,8 @@
1
+ import { useShow } from "@ginjou/vue";
2
+ import { withAsync } from "../utils/async.js";
3
+ export function useAsyncShow(props, context) {
4
+ const query = useShow(props, context);
5
+ return withAsync(query, async () => {
6
+ await query.suspense();
7
+ });
8
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -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,2 @@
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { defineNuxtPlugin } from "#imports";
2
+ import { defineRouterContext } from "@ginjou/vue";
3
+ import { createRouter } from "@ginjou/with-vue-router";
4
+ export default defineNuxtPlugin({
5
+ name: "ginjou/router-plugin",
6
+ setup: (nuxt) => {
7
+ nuxt.hook("vue:setup", () => {
8
+ defineRouterContext(createRouter());
9
+ });
10
+ }
11
+ });
@@ -0,0 +1,2 @@
1
+ export type AsyncResult<T extends Record<string, unknown>> = T & Promise<T>;
2
+ export declare function withAsync<T extends Record<string, unknown>>(value: T, wait: () => Promise<void>): AsyncResult<T>;
@@ -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.js'
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 { type Options, default } from './module.js'
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.1",
4
+ "version": "0.1.0-beta.11",
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/module.d.ts",
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/module.d.ts",
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,16 @@
28
37
  "access": "public"
29
38
  },
30
39
  "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"
40
+ "@nuxt/kit": "^3.20.1",
41
+ "@ginjou/with-vue-router": "^0.1.0-beta.6",
42
+ "@ginjou/vue": "^0.1.0-beta.14"
34
43
  },
35
44
  "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"
45
+ "@nuxt/module-builder": "^1.0.2",
46
+ "@nuxt/schema": "^3.20.1",
47
+ "@nuxt/test-utils": "^3.21.0",
48
+ "nuxt": "^3.20.1",
49
+ "@ginjou/vite-config": "0.1.0"
42
50
  },
43
51
  "scripts": {
44
52
  "build": "run-s build:prepare build:bundle",
@@ -46,6 +54,6 @@
46
54
  "build:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare",
47
55
  "dev:playground": "nuxi dev playground",
48
56
  "dev": "run-s build:prepare dev:playground",
49
- "release": "release-it --ci"
57
+ "release": "release-it"
50
58
  }
51
59
  }
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 };
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -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
@@ -1,7 +0,0 @@
1
- import type { NuxtModule } from '@nuxt/schema'
2
-
3
- import type { default as Module } from './module'
4
-
5
- export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
-
7
- export { type Options, default } from './module'