@ginjou/nuxt 0.1.0-beta.2 → 0.1.0-beta.3

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 (34) hide show
  1. package/LICENSE +1 -1
  2. package/dist/module.cjs +148 -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 +51 -136
  7. package/dist/runtime/composables/form.d.ts +4 -0
  8. package/dist/runtime/composables/form.js +8 -0
  9. package/dist/runtime/composables/get-infinite-list.d.ts +4 -0
  10. package/dist/runtime/composables/get-infinite-list.js +8 -0
  11. package/dist/runtime/composables/get-list.d.ts +4 -0
  12. package/dist/runtime/composables/get-list.js +8 -0
  13. package/dist/runtime/composables/get-many.d.ts +4 -0
  14. package/dist/runtime/composables/get-many.js +8 -0
  15. package/dist/runtime/composables/get-one.d.ts +4 -0
  16. package/dist/runtime/composables/get-one.js +8 -0
  17. package/dist/runtime/composables/list.d.ts +4 -0
  18. package/dist/runtime/composables/list.js +8 -0
  19. package/dist/runtime/composables/select.d.ts +4 -0
  20. package/dist/runtime/composables/select.js +8 -0
  21. package/dist/runtime/composables/show.d.ts +4 -0
  22. package/dist/runtime/composables/show.js +8 -0
  23. package/dist/runtime/query-hydrate-plugin.d.ts +2 -0
  24. package/dist/runtime/query-hydrate-plugin.js +22 -0
  25. package/dist/runtime/router-plugin.d.ts +2 -0
  26. package/dist/runtime/router-plugin.js +11 -0
  27. package/dist/runtime/utils/async.d.ts +2 -0
  28. package/dist/runtime/utils/async.js +18 -0
  29. package/dist/types.d.mts +4 -2
  30. package/package.json +20 -13
  31. package/dist/module.d.ts +0 -16
  32. package/dist/runtime/plugin.d.ts +0 -2
  33. package/dist/runtime/plugin.js +0 -41
  34. 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,149 @@
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/form",
35
+ name: "useAsyncForm"
36
+ },
37
+ {
38
+ from: "./runtime/composables/select",
39
+ name: "useAsyncSelect"
40
+ }
41
+ ];
42
+ function ImportListForAsync(resolve) {
43
+ return composables$2.map(
44
+ (item) => ({
45
+ from: resolve(item.from),
46
+ name: item.name
47
+ })
48
+ );
3
49
  }
4
- const _meta = module.exports.meta = require('./module.json')
5
- module.exports.getMeta = () => Promise.resolve(_meta)
50
+
51
+ const composables$1 = [
52
+ "useAccessContext",
53
+ "useAuthContext",
54
+ "useAuthenticated",
55
+ "useBack",
56
+ "useCheckError",
57
+ "useCreate",
58
+ "useCreateMany",
59
+ "useCustom",
60
+ "useCustomMutation",
61
+ "useDelete",
62
+ "useDeleteMany",
63
+ "useFetchersContext",
64
+ "useForm",
65
+ "useGetIdentity",
66
+ "useGetInfiniteList",
67
+ "useGetList",
68
+ "useGetMany",
69
+ "useGetOne",
70
+ "useGo",
71
+ "useI18nContext",
72
+ "useList",
73
+ "useLocale",
74
+ "useLocation",
75
+ "useLogin",
76
+ "useLogout",
77
+ "useNavigateTo",
78
+ "useNotificationContext",
79
+ "useNotify",
80
+ "usePermissions",
81
+ "usePublish",
82
+ "useQueryClientContext",
83
+ "useRealtimeContext",
84
+ "useRealtimeOptions",
85
+ "useResolvePath",
86
+ "useResource",
87
+ "useResourceContext",
88
+ "useResourcePath",
89
+ "useRouterContext",
90
+ "useSelect",
91
+ "useShow",
92
+ "useSubscribe",
93
+ "useTranslate",
94
+ "useUpdate",
95
+ "useUpdateMany"
96
+ ];
97
+ const ImportListForGinjou = composables$1.map(
98
+ (name) => ({
99
+ name,
100
+ from: "@ginjou/vue"
101
+ })
102
+ );
103
+
104
+ const composables = [
105
+ "useQuery",
106
+ "useQueries",
107
+ "useInfiniteQuery",
108
+ "useMutation",
109
+ "useIsFetching",
110
+ "useIsMutating",
111
+ "useQueryClient"
112
+ ];
113
+ const ImportListForTanstackQuery = composables.map(
114
+ (name) => ({
115
+ name,
116
+ from: "@tanstack/vue-query"
117
+ })
118
+ );
119
+
120
+ const module$1 = kit.defineNuxtModule({
121
+ meta: {
122
+ name: "ginjou",
123
+ configKey: "ginjou"
124
+ },
125
+ defaults: {
126
+ router: true
127
+ },
128
+ setup: async (options, nuxt) => {
129
+ 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)));
130
+ nuxt.hook("vite:extend", ({ config }) => {
131
+ config.optimizeDeps ??= {};
132
+ config.optimizeDeps.exclude ??= [];
133
+ config.optimizeDeps.exclude.push(...[
134
+ "@ginjou/core",
135
+ "@ginjou/vue",
136
+ "@ginjou/with-vue-router",
137
+ "@ginjou/with-vue-i18n"
138
+ ]);
139
+ });
140
+ kit.addImports(ImportListForTanstackQuery);
141
+ kit.addImports(ImportListForGinjou);
142
+ kit.addImports(ImportListForAsync(resolve));
143
+ kit.addPlugin(resolve("./runtime/query-hydrate-plugin"));
144
+ if (options.router)
145
+ kit.addPlugin(resolve("./runtime/router-plugin"));
146
+ }
147
+ });
148
+
149
+ 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.2",
4
+ "version": "0.1.0-beta.3",
5
5
  "builder": {
6
- "@nuxt/module-builder": "0.8.4",
7
- "unbuild": "2.0.0"
6
+ "@nuxt/module-builder": "1.0.1",
7
+ "unbuild": "3.5.0"
8
8
  }
9
9
  }
package/dist/module.mjs CHANGED
@@ -1,6 +1,49 @@
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/form",
32
+ name: "useAsyncForm"
33
+ },
34
+ {
35
+ from: "./runtime/composables/select",
36
+ name: "useAsyncSelect"
37
+ }
38
+ ];
39
+ function ImportListForAsync(resolve) {
40
+ return composables$2.map(
41
+ (item) => ({
42
+ from: resolve(item.from),
43
+ name: item.name
44
+ })
45
+ );
46
+ }
4
47
 
5
48
  const composables$1 = [
6
49
  "useAccessContext",
@@ -71,147 +114,16 @@ const ImportListForTanstackQuery = composables.map(
71
114
  })
72
115
  );
73
116
 
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
117
  const module = defineNuxtModule({
119
118
  meta: {
120
119
  name: "ginjou",
121
120
  configKey: "ginjou"
122
121
  },
123
122
  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"
123
+ router: true
133
124
  },
134
125
  setup: async (options, nuxt) => {
135
126
  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
127
  nuxt.hook("vite:extend", ({ config }) => {
216
128
  config.optimizeDeps ??= {};
217
129
  config.optimizeDeps.exclude ??= [];
@@ -224,7 +136,10 @@ const module = defineNuxtModule({
224
136
  });
225
137
  addImports(ImportListForTanstackQuery);
226
138
  addImports(ImportListForGinjou);
227
- addPlugin(resolve("./runtime/plugin"));
139
+ addImports(ImportListForAsync(resolve));
140
+ addPlugin(resolve("./runtime/query-hydrate-plugin"));
141
+ if (options.router)
142
+ addPlugin(resolve("./runtime/router-plugin"));
228
143
  }
229
144
  });
230
145
 
@@ -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,8 @@
1
+ import { useForm } from "@ginjou/vue";
2
+ import { withAsync } from "../utils/async.js";
3
+ export function useAsyncForm(props, context) {
4
+ const result = useForm(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 } 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,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 { 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,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.2",
4
+ "version": "0.1.0-beta.3",
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,15 @@
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.17.1",
41
+ "@ginjou/vue": "^0.1.0-beta.7",
42
+ "@ginjou/with-vue-router": "^0.1.0-beta.2"
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.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 };
@@ -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'