@devframes/nuxt 0.1.22 → 0.2.1

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.
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025-present, VoidZero Inc. and contributors
3
+ Copyright (c) 2025-PRESENT Anthony Fu <https://github.com/antfu>
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
@@ -0,0 +1,82 @@
1
+ import * as _$_nuxt_schema0 from "@nuxt/schema";
2
+ import { DevframeDefinition } from "devframe/types";
3
+
4
+ //#region src/index.d.ts
5
+ interface DevframeNuxtModuleOptions {
6
+ /**
7
+ * Base URL, relative to the deployed page, where the devframe
8
+ * connection meta (`__connection.json`) and dump shards live.
9
+ * Defaults to `'./'` — the SPA root — so a single build works at any
10
+ * deployment base (the browser resolves relative fetches against
11
+ * `document.baseURI`).
12
+ */
13
+ baseURL?: string;
14
+ /**
15
+ * Disable the opinionated Nuxt app defaults (`app.baseURL: './'`,
16
+ * `vite.base: './'`). Set to `true` if you need to own these yourself.
17
+ * Defaults to `false` — devframe sets sensible base-agnostic defaults.
18
+ */
19
+ skipAppDefaults?: boolean;
20
+ /**
21
+ * Devframe definition that powers the dev-time RPC bridge. When set
22
+ * (and Nuxt is in dev mode), the module starts a separate RPC + WS
23
+ * server alongside `nuxt dev` and registers Vite middleware at
24
+ * `${baseURL}__connection.json` so the client SPA can discover the
25
+ * WS endpoint. Without it the module stays client-only.
26
+ */
27
+ devframe?: DevframeDefinition;
28
+ /**
29
+ * Dev-time middleware mode. Mirrors `viteDevBridge`'s option of
30
+ * the same name.
31
+ *
32
+ * - `true` (default) — when `devframe` is set and Nuxt is in dev
33
+ * mode, start the RPC bridge with all defaults.
34
+ * - `false` — skip the bridge entirely. The module remains
35
+ * client-only.
36
+ * - object — enable with explicit overrides.
37
+ */
38
+ devMiddleware?: boolean | {
39
+ /** Override the bridge port. Default: resolved via `get-port-please`. */port?: number;
40
+ /**
41
+ * Override the bridge bind host. Defaults to
42
+ * `nuxt.options.devServer.host ?? devframe.cli?.host ?? 'localhost'`,
43
+ * so `nuxt dev --host` propagates automatically.
44
+ */
45
+ host?: string; /** Flag bag forwarded to `devframe.setup(ctx, { flags })`. */
46
+ flags?: Record<string, unknown>;
47
+ };
48
+ }
49
+ /**
50
+ * Nuxt module that wires a Nuxt-built SPA up as a devframe client, and
51
+ * (optionally) serves the dev-time RPC bridge alongside `nuxt dev`.
52
+ *
53
+ * - Sets `app.baseURL: './'` + `vite.base: './'` so the production
54
+ * build is base-agnostic (works at any deployment path without
55
+ * build-time rewriting).
56
+ * - Injects a client plugin that calls {@link connectDevframe} once on
57
+ * page load and exposes the RPC client via `useNuxtApp().$rpc`.
58
+ * - When `devframe` is provided and Nuxt is in dev mode, registers a
59
+ * Vite plugin (via `addVitePlugin(viteDevBridge(devframe, {
60
+ * devMiddleware: ... }))`) that starts the RPC + WS bridge and
61
+ * serves `${baseURL}__connection.json`.
62
+ *
63
+ * ```ts [nuxt.config.ts]
64
+ * import devframe from './src/devframe' // defineDevframe(...) export
65
+ *
66
+ * export default defineNuxtConfig({
67
+ * modules: [['@devframes/nuxt', { devframe }]],
68
+ * })
69
+ * ```
70
+ *
71
+ * At the call site:
72
+ *
73
+ * ```ts [composables/payload.ts]
74
+ * export async function fetchPayload() {
75
+ * const { $rpc } = useNuxtApp()
76
+ * return $rpc.call('my-tool:get-payload')
77
+ * }
78
+ * ```
79
+ */
80
+ declare const _default: _$_nuxt_schema0.NuxtModule<DevframeNuxtModuleOptions, DevframeNuxtModuleOptions, false>;
81
+ //#endregion
82
+ export { DevframeNuxtModuleOptions, _default as default };
package/dist/index.mjs ADDED
@@ -0,0 +1,83 @@
1
+ import { addPlugin, addVitePlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
2
+ import { viteDevBridge } from "devframe/helpers/vite";
3
+ //#region src/index.ts
4
+ /**
5
+ * Nuxt module that wires a Nuxt-built SPA up as a devframe client, and
6
+ * (optionally) serves the dev-time RPC bridge alongside `nuxt dev`.
7
+ *
8
+ * - Sets `app.baseURL: './'` + `vite.base: './'` so the production
9
+ * build is base-agnostic (works at any deployment path without
10
+ * build-time rewriting).
11
+ * - Injects a client plugin that calls {@link connectDevframe} once on
12
+ * page load and exposes the RPC client via `useNuxtApp().$rpc`.
13
+ * - When `devframe` is provided and Nuxt is in dev mode, registers a
14
+ * Vite plugin (via `addVitePlugin(viteDevBridge(devframe, {
15
+ * devMiddleware: ... }))`) that starts the RPC + WS bridge and
16
+ * serves `${baseURL}__connection.json`.
17
+ *
18
+ * ```ts [nuxt.config.ts]
19
+ * import devframe from './src/devframe' // defineDevframe(...) export
20
+ *
21
+ * export default defineNuxtConfig({
22
+ * modules: [['@devframes/nuxt', { devframe }]],
23
+ * })
24
+ * ```
25
+ *
26
+ * At the call site:
27
+ *
28
+ * ```ts [composables/payload.ts]
29
+ * export async function fetchPayload() {
30
+ * const { $rpc } = useNuxtApp()
31
+ * return $rpc.call('my-tool:get-payload')
32
+ * }
33
+ * ```
34
+ */
35
+ var src_default = defineNuxtModule({
36
+ meta: {
37
+ name: "devframe",
38
+ configKey: "devframe"
39
+ },
40
+ defaults: {
41
+ baseURL: "./",
42
+ skipAppDefaults: false,
43
+ devMiddleware: true
44
+ },
45
+ setup(options, nuxt) {
46
+ const { resolve } = createResolver(import.meta.url);
47
+ if (!options.skipAppDefaults) {
48
+ nuxt.options.app ??= {};
49
+ nuxt.options.app.baseURL ??= "./";
50
+ nuxt.options.vite ??= {};
51
+ nuxt.options.vite.base ??= "./";
52
+ }
53
+ nuxt.options.runtimeConfig ??= {};
54
+ nuxt.options.runtimeConfig.public ??= {};
55
+ const publicConfig = nuxt.options.runtimeConfig.public;
56
+ publicConfig.devframe = {
57
+ ...publicConfig.devframe ?? {},
58
+ baseURL: options.baseURL
59
+ };
60
+ const runtimeDir = resolve("./runtime");
61
+ nuxt.hook("prepare:types", ({ references }) => {
62
+ references.push({ path: resolve(runtimeDir, "types") });
63
+ });
64
+ addPlugin({
65
+ src: resolve(runtimeDir, "plugin.client"),
66
+ mode: "client"
67
+ });
68
+ if (options.devframe && options.devMiddleware !== false && nuxt.options.dev) {
69
+ const mw = options.devMiddleware === true || options.devMiddleware === void 0 ? {} : options.devMiddleware;
70
+ const host = mw.host ?? nuxt.options.devServer?.host ?? options.devframe.cli?.host;
71
+ addVitePlugin(viteDevBridge(options.devframe, {
72
+ base: options.baseURL ?? "./",
73
+ devMiddleware: {
74
+ port: mw.port,
75
+ host,
76
+ flags: mw.flags
77
+ }
78
+ }));
79
+ }
80
+ }
81
+ });
82
+ //#endregion
83
+ export { src_default as default };
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from '#app';
2
+ import type { DevToolsRpcClient } from 'devframe/client';
3
+ declare const plugin: Plugin<{
4
+ rpc: DevToolsRpcClient;
5
+ }>;
6
+ export default plugin;
@@ -0,0 +1,12 @@
1
+ import { connectDevframe } from "devframe/client";
2
+ import { defineNuxtPlugin, useRuntimeConfig } from "#imports";
3
+ //#region src/runtime/plugin.client.ts
4
+ /**
5
+ * Nuxt client plugin that calls `connectDevframe()` once on the client
6
+ * and provides the RPC client as `$rpc` / `useNuxtApp().$rpc`.
7
+ */
8
+ var plugin_client_default = defineNuxtPlugin({ async setup() {
9
+ return { provide: { rpc: await connectDevframe({ baseURL: useRuntimeConfig().public?.devframe?.baseURL ?? "./" }) } };
10
+ } });
11
+ //#endregion
12
+ export { plugin_client_default as default };
@@ -0,0 +1,20 @@
1
+ import type { DevToolsRpcClient } from 'devframe/client'
2
+
3
+ declare module '#app' {
4
+ interface NuxtApp {
5
+ /**
6
+ * Devframe RPC client, provided by the `@devframes/nuxt` module's
7
+ * client plugin.
8
+ */
9
+ $rpc: DevToolsRpcClient
10
+ }
11
+ }
12
+
13
+ declare module 'vue' {
14
+ interface ComponentCustomProperties {
15
+ /** Devframe RPC client (see `NuxtApp['$rpc']`). */
16
+ $rpc: DevToolsRpcClient
17
+ }
18
+ }
19
+
20
+ export {}
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@devframes/nuxt",
3
3
  "type": "module",
4
- "version": "0.1.22",
4
+ "version": "0.2.1",
5
5
  "description": "Nuxt module for Devframe — wires a Nuxt-built SPA up as a devframe client",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
8
- "homepage": "https://github.com/vitejs/devtools#readme",
8
+ "homepage": "https://github.com/devframes/devframe#readme",
9
9
  "repository": {
10
- "directory": "devframe/packages/nuxt",
10
+ "directory": "packages/nuxt",
11
11
  "type": "git",
12
- "url": "git+https://github.com/vitejs/devtools.git"
12
+ "url": "git+https://github.com/devframes/devframe.git"
13
13
  },
14
- "bugs": "https://github.com/vitejs/devtools/issues",
14
+ "bugs": "https://github.com/devframes/devframe/issues",
15
15
  "keywords": [
16
16
  "devframe",
17
17
  "nuxt",
@@ -20,20 +20,22 @@
20
20
  "sideEffects": false,
21
21
  "exports": {
22
22
  ".": "./dist/index.mjs",
23
- "./runtime/plugin.client": "./dist/runtime/plugin.client.mjs",
24
23
  "./package.json": "./package.json"
25
24
  },
26
- "types": "./dist/index.d.ts",
25
+ "types": "./dist/index.d.mts",
27
26
  "files": [
28
27
  "dist"
29
28
  ],
30
29
  "peerDependencies": {
31
- "@nuxt/kit": "^3.0.0 || ^4.0.0",
32
- "devframe": "0.1.22"
30
+ "@nuxt/kit": "^3.0.0 || ^4.0.0 || ^5.0.0-0",
31
+ "devframe": "0.2.1"
33
32
  },
34
33
  "devDependencies": {
35
34
  "@nuxt/kit": "^4.4.5",
36
- "tsdown": "^0.22.0"
35
+ "@types/node": "^25.7.0",
36
+ "nuxt": "^4.4.4",
37
+ "tsdown": "^0.22.0",
38
+ "devframe": "0.2.1"
37
39
  },
38
40
  "scripts": {
39
41
  "build": "tsdown",