@devframes/nuxt 0.0.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present, VoidZero Inc. and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,46 @@
1
+ import * as _$_nuxt_schema0 from "@nuxt/schema";
2
+
3
+ //#region src/index.d.ts
4
+ interface DevframeNuxtModuleOptions {
5
+ /**
6
+ * Base URL, relative to the deployed page, where the devframe
7
+ * connection meta (`.connection.json`) and dump shards live.
8
+ * Defaults to `'./'` — the SPA root — so a single build works at any
9
+ * deployment base (the browser resolves relative fetches against
10
+ * `document.baseURI`).
11
+ */
12
+ baseURL?: string;
13
+ /**
14
+ * Disable the opinionated Nuxt app defaults (`app.baseURL: './'`,
15
+ * `vite.base: './'`). Set to `true` if you need to own these yourself.
16
+ * Defaults to `false` — devframe sets sensible base-agnostic defaults.
17
+ */
18
+ skipAppDefaults?: boolean;
19
+ }
20
+ /**
21
+ * Nuxt module that wires a Nuxt-built SPA up as a devframe client:
22
+ *
23
+ * - Sets `app.baseURL: './'` + `vite.base: './'` so the production
24
+ * build is base-agnostic (works at any deployment path without
25
+ * build-time rewriting).
26
+ * - Injects a client plugin that calls {@link connectDevtool} once on
27
+ * page load and exposes the RPC client via `useNuxtApp().$rpc`.
28
+ *
29
+ * ```ts [nuxt.config.ts]
30
+ * export default defineNuxtConfig({
31
+ * modules: ['@devframes/nuxt'],
32
+ * })
33
+ * ```
34
+ *
35
+ * At the call site:
36
+ *
37
+ * ```ts [composables/payload.ts]
38
+ * export async function fetchPayload() {
39
+ * const { $rpc } = useNuxtApp()
40
+ * return $rpc.call('my-tool:get-payload')
41
+ * }
42
+ * ```
43
+ */
44
+ declare const _default: _$_nuxt_schema0.NuxtModule<DevframeNuxtModuleOptions, DevframeNuxtModuleOptions, false>;
45
+ //#endregion
46
+ export { DevframeNuxtModuleOptions, _default as default };
package/dist/index.mjs ADDED
@@ -0,0 +1,58 @@
1
+ import { addPlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
2
+ //#region src/index.ts
3
+ /**
4
+ * Nuxt module that wires a Nuxt-built SPA up as a devframe client:
5
+ *
6
+ * - Sets `app.baseURL: './'` + `vite.base: './'` so the production
7
+ * build is base-agnostic (works at any deployment path without
8
+ * build-time rewriting).
9
+ * - Injects a client plugin that calls {@link connectDevtool} once on
10
+ * page load and exposes the RPC client via `useNuxtApp().$rpc`.
11
+ *
12
+ * ```ts [nuxt.config.ts]
13
+ * export default defineNuxtConfig({
14
+ * modules: ['@devframes/nuxt'],
15
+ * })
16
+ * ```
17
+ *
18
+ * At the call site:
19
+ *
20
+ * ```ts [composables/payload.ts]
21
+ * export async function fetchPayload() {
22
+ * const { $rpc } = useNuxtApp()
23
+ * return $rpc.call('my-tool:get-payload')
24
+ * }
25
+ * ```
26
+ */
27
+ var src_default = defineNuxtModule({
28
+ meta: {
29
+ name: "devframe",
30
+ configKey: "devframe"
31
+ },
32
+ defaults: {
33
+ baseURL: "./",
34
+ skipAppDefaults: false
35
+ },
36
+ setup(options, nuxt) {
37
+ const { resolve } = createResolver(import.meta.url);
38
+ if (!options.skipAppDefaults) {
39
+ nuxt.options.app ??= {};
40
+ nuxt.options.app.baseURL ??= "./";
41
+ nuxt.options.vite ??= {};
42
+ nuxt.options.vite.base ??= "./";
43
+ }
44
+ nuxt.options.runtimeConfig ??= {};
45
+ nuxt.options.runtimeConfig.public ??= {};
46
+ const publicConfig = nuxt.options.runtimeConfig.public;
47
+ publicConfig.devframe = {
48
+ ...publicConfig.devframe ?? {},
49
+ baseURL: options.baseURL
50
+ };
51
+ addPlugin({
52
+ src: resolve("./runtime/plugin.client"),
53
+ mode: "client"
54
+ });
55
+ }
56
+ });
57
+ //#endregion
58
+ export { src_default as default };
@@ -0,0 +1,8 @@
1
+ //#region src/runtime/plugin.client.d.ts
2
+ /**
3
+ * Nuxt client plugin that calls `connectDevtool()` once on the client
4
+ * and provides the RPC client as `$rpc` / `useNuxtApp().$rpc`.
5
+ */
6
+ declare const _default: any;
7
+ //#endregion
8
+ export { _default as default };
@@ -0,0 +1,12 @@
1
+ import { defineNuxtPlugin, useRuntimeConfig } from "#app";
2
+ import { connectDevtool } from "devframe/client";
3
+ //#region src/runtime/plugin.client.ts
4
+ /**
5
+ * Nuxt client plugin that calls `connectDevtool()` once on the client
6
+ * and provides the RPC client as `$rpc` / `useNuxtApp().$rpc`.
7
+ */
8
+ var plugin_client_default = defineNuxtPlugin(async () => {
9
+ return { provide: { rpc: await connectDevtool({ baseURL: useRuntimeConfig().public?.devframe?.baseURL ?? "./" }) } };
10
+ });
11
+ //#endregion
12
+ export { plugin_client_default as default };
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@devframes/nuxt",
3
+ "type": "module",
4
+ "version": "0.0.0",
5
+ "description": "Nuxt module for DevFrame — wires a Nuxt-built SPA up as a devframe client",
6
+ "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/vitejs/devtools#readme",
9
+ "repository": {
10
+ "directory": "devframe/packages/nuxt",
11
+ "type": "git",
12
+ "url": "git+https://github.com/vitejs/devtools.git"
13
+ },
14
+ "bugs": "https://github.com/vitejs/devtools/issues",
15
+ "keywords": [
16
+ "devframe",
17
+ "nuxt",
18
+ "devtools"
19
+ ],
20
+ "sideEffects": false,
21
+ "exports": {
22
+ ".": "./dist/index.mjs",
23
+ "./runtime/plugin.client": "./dist/runtime/plugin.client.mjs",
24
+ "./package.json": "./package.json"
25
+ },
26
+ "types": "./dist/index.d.ts",
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "peerDependencies": {
31
+ "@nuxt/kit": "^3.0.0 || ^4.0.0",
32
+ "devframe": "0.1.19"
33
+ },
34
+ "devDependencies": {
35
+ "@nuxt/kit": "^4.4.4",
36
+ "tsdown": "^0.21.10"
37
+ },
38
+ "scripts": {
39
+ "build": "tsdown",
40
+ "watch": "tsdown --watch"
41
+ }
42
+ }