@peterbud/nuxt-query 0.0.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.
- package/README.md +165 -0
- package/dist/client/200.html +1 -0
- package/dist/client/404.html +1 -0
- package/dist/client/_nuxt/BBhWNxb-.js +1 -0
- package/dist/client/_nuxt/BZdBh-vQ.js +1 -0
- package/dist/client/_nuxt/DlTfw1eD.js +1 -0
- package/dist/client/_nuxt/F_UyZesz.js +1 -0
- package/dist/client/_nuxt/W1CaT6nm.js +1 -0
- package/dist/client/_nuxt/builds/latest.json +1 -0
- package/dist/client/_nuxt/builds/meta/2d499f35-75ff-491f-9a71-cfca55d2ee82.json +1 -0
- package/dist/client/_nuxt/entry.Cj2RvDGv.css +1 -0
- package/dist/client/_nuxt/error-404.KsBxadWe.css +1 -0
- package/dist/client/_nuxt/error-500.32Z7AtvF.css +1 -0
- package/dist/client/_nuxt/h3aULeno.js +27 -0
- package/dist/client/_nuxt/vue-query.DSSNLNU-.css +1 -0
- package/dist/client/index.html +1 -0
- package/dist/client/vue-query/index.html +1 -0
- package/dist/module.d.mts +32 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +75 -0
- package/dist/runtime/plugin.d.ts +7 -0
- package/dist/runtime/plugin.js +37 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/types.d.mts +7 -0
- package/package.json +79 -0
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { createResolver, defineNuxtModule, useLogger, addPlugin, addImports } from '@nuxt/kit';
|
|
2
|
+
import { defu } from 'defu';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { addCustomTab } from '@nuxt/devtools-kit';
|
|
5
|
+
|
|
6
|
+
const version = "0.0.2";
|
|
7
|
+
|
|
8
|
+
const DEVTOOLS_UI_ROUTE = "/__nuxt-query-client";
|
|
9
|
+
const DEVTOOLS_UI_LOCAL_PORT = 3300;
|
|
10
|
+
function setupDevToolsUI(nuxt, resolver) {
|
|
11
|
+
const clientPath = resolver.resolve("./client");
|
|
12
|
+
const isProductionBuild = existsSync(clientPath);
|
|
13
|
+
if (isProductionBuild) {
|
|
14
|
+
nuxt.hook("vite:serverCreated", async (server) => {
|
|
15
|
+
const sirv = await import('sirv').then((r) => r.default || r);
|
|
16
|
+
server.middlewares.use(
|
|
17
|
+
DEVTOOLS_UI_ROUTE,
|
|
18
|
+
sirv(clientPath, { dev: true, single: true })
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
nuxt.hook("vite:extendConfig", (config) => {
|
|
23
|
+
config.server = config.server || {};
|
|
24
|
+
config.server.proxy = config.server.proxy || {};
|
|
25
|
+
config.server.proxy[DEVTOOLS_UI_ROUTE] = {
|
|
26
|
+
target: `http://localhost:${DEVTOOLS_UI_LOCAL_PORT}${DEVTOOLS_UI_ROUTE}`,
|
|
27
|
+
changeOrigin: true,
|
|
28
|
+
followRedirects: true,
|
|
29
|
+
rewrite: (path) => path.replace(DEVTOOLS_UI_ROUTE, "")
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
addCustomTab({
|
|
34
|
+
name: "nuxt-query",
|
|
35
|
+
title: "Nuxt Query",
|
|
36
|
+
icon: "carbon:apps",
|
|
37
|
+
// iframe view
|
|
38
|
+
view: {
|
|
39
|
+
type: "iframe",
|
|
40
|
+
src: `${DEVTOOLS_UI_ROUTE}/vue-query`
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const resolver = createResolver(import.meta.url);
|
|
46
|
+
const module = defineNuxtModule({
|
|
47
|
+
meta: {
|
|
48
|
+
name: "nuxt-query",
|
|
49
|
+
configKey: "nuxtQuery",
|
|
50
|
+
version
|
|
51
|
+
},
|
|
52
|
+
// Default configuration options of the Nuxt module
|
|
53
|
+
defaults: {
|
|
54
|
+
autoImports: false,
|
|
55
|
+
devtools: true
|
|
56
|
+
},
|
|
57
|
+
setup(options, nuxt) {
|
|
58
|
+
const logger = useLogger("nuxt-query");
|
|
59
|
+
logger.info(`Adding nuxt-query module`);
|
|
60
|
+
nuxt.options.runtimeConfig.public.nuxtQuery = defu(
|
|
61
|
+
nuxt.options.runtimeConfig.public.nuxtQuery,
|
|
62
|
+
{
|
|
63
|
+
queryClientOptions: { ...options.queryClientOptions }
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
addPlugin(resolver.resolve("./runtime/plugin"));
|
|
67
|
+
if (options.autoImports && options.autoImports.length > 0)
|
|
68
|
+
addImports(options.autoImports.map((name) => ({ name, from: "@tanstack/vue-query" })));
|
|
69
|
+
if (options.devtools)
|
|
70
|
+
setupDevToolsUI(nuxt, resolver);
|
|
71
|
+
logger.success(`Added nuxt-query module successfully.`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export { module as default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { QueryClient, VueQueryPlugin, dehydrate, hydrate } from "@tanstack/vue-query";
|
|
2
|
+
import { defineNuxtPlugin, useRuntimeConfig, useState } from "#app";
|
|
3
|
+
export default defineNuxtPlugin({
|
|
4
|
+
name: "nuxt-query:plugin",
|
|
5
|
+
async setup(nuxtApp) {
|
|
6
|
+
const queryClientOptions = useRuntimeConfig().public.nuxtQuery?.queryClientOptions;
|
|
7
|
+
let queryClient;
|
|
8
|
+
let options;
|
|
9
|
+
const getPluginOptions = (queryClientParam) => {
|
|
10
|
+
queryClient = queryClientParam ?? new QueryClient(queryClientOptions);
|
|
11
|
+
options = {
|
|
12
|
+
queryClient
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
await nuxtApp.callHook("nuxt-query:configure", getPluginOptions);
|
|
16
|
+
if (!queryClient)
|
|
17
|
+
queryClient = new QueryClient(queryClientOptions);
|
|
18
|
+
if (!options)
|
|
19
|
+
options = {
|
|
20
|
+
queryClient,
|
|
21
|
+
enableDevtoolsV6Plugin: true
|
|
22
|
+
};
|
|
23
|
+
nuxtApp.vueApp.use(VueQueryPlugin, options);
|
|
24
|
+
const vueQueryState = useState("vue-query-state");
|
|
25
|
+
if (import.meta.server) {
|
|
26
|
+
nuxtApp.hooks.hook("app:rendered", () => {
|
|
27
|
+
vueQueryState.value = dehydrate(queryClient);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (import.meta.client) hydrate(queryClient, vueQueryState.value);
|
|
31
|
+
return {
|
|
32
|
+
provide: {
|
|
33
|
+
queryClient
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
});
|
package/dist/types.d.mts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@peterbud/nuxt-query",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Nuxt integration for Tanstack Query",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/peterbud/nuxt-query.git"
|
|
11
|
+
},
|
|
12
|
+
"author": "Peter Budai",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/types.d.mts",
|
|
18
|
+
"import": "./dist/module.mjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"vue",
|
|
23
|
+
"nuxt",
|
|
24
|
+
"query",
|
|
25
|
+
"nuxt-module",
|
|
26
|
+
"tanstack",
|
|
27
|
+
"tanstack-query",
|
|
28
|
+
"vue-query"
|
|
29
|
+
],
|
|
30
|
+
"main": "./dist/module.mjs",
|
|
31
|
+
"typesVersions": {
|
|
32
|
+
"*": {
|
|
33
|
+
".": [
|
|
34
|
+
"./dist/types.d.mts"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "nuxt-module-build build && pnpm build:client",
|
|
43
|
+
"build:client": "nuxi generate client",
|
|
44
|
+
"dev": "nuxi dev playground",
|
|
45
|
+
"dev:client": "concurrently \"nuxi dev client --port 3300\" \"nuxi dev playground\"",
|
|
46
|
+
"dev:build": "nuxi build playground",
|
|
47
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
48
|
+
"release": "pnpm lint && pnpm build && changelogen --release && npm publish && git push --follow-tags",
|
|
49
|
+
"lint": "eslint .",
|
|
50
|
+
"test": "vitest run",
|
|
51
|
+
"test:watch": "vitest watch",
|
|
52
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@nuxt/devtools-kit": "^2.0.0",
|
|
56
|
+
"@nuxt/devtools-ui-kit": "^2.0.0",
|
|
57
|
+
"@nuxt/kit": "^3.15.4",
|
|
58
|
+
"@tanstack/vue-query": "^5.66.0",
|
|
59
|
+
"defu": "^6.1.4",
|
|
60
|
+
"sirv": "^3.0.1"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@nuxt/devtools": "^2.0.0",
|
|
64
|
+
"@nuxt/eslint-config": "^1.0.1",
|
|
65
|
+
"@nuxt/module-builder": "1.0.0-alpha.1",
|
|
66
|
+
"@nuxt/schema": "^3.15.4",
|
|
67
|
+
"@nuxt/test-utils": "^3.15.4",
|
|
68
|
+
"@types/node": "latest",
|
|
69
|
+
"@unocss/nuxt": "^65.4.3",
|
|
70
|
+
"changelogen": "^0.5.7",
|
|
71
|
+
"concurrently": "^9.1.2",
|
|
72
|
+
"eslint": "^9.20.1",
|
|
73
|
+
"nuxt": "^3.15.4",
|
|
74
|
+
"typescript": "~5.6.3",
|
|
75
|
+
"vitest": "^3.0.5",
|
|
76
|
+
"vue-tsc": "^2.2.0"
|
|
77
|
+
},
|
|
78
|
+
"packageManager": "pnpm@10.2.0"
|
|
79
|
+
}
|