@devframes/nuxt 0.9.0-beta.2 → 0.9.0-beta.4

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,5 +1,5 @@
1
1
  import { DevframeDefinition } from "devframe";
2
- //#region src/module.d.ts
2
+ //#region src/dev-spa.d.ts
3
3
  interface DevframeNuxtModuleOptions {
4
4
  /**
5
5
  * Base URL, relative to the deployed page, where the devframe
@@ -24,8 +24,8 @@ interface DevframeNuxtModuleOptions {
24
24
  */
25
25
  devframe?: DevframeDefinition;
26
26
  /**
27
- * Dev-time middleware mode. Mirrors `viteDevBridge`'s option of
28
- * the same name.
27
+ * Dev-time middleware mode — whether to start `@devframes/vite`'s
28
+ * RPC bridge (`devframeViteBridge`) alongside `nuxt dev`.
29
29
  *
30
30
  * - `true` (default) — when `devframe` is set and Nuxt is in dev
31
31
  * mode, start the RPC bridge with all defaults.
@@ -57,9 +57,9 @@ type ModuleOptions = DevframeNuxtModuleOptions;
57
57
  * - Injects a client plugin that calls {@link connectDevframe} once on
58
58
  * page load and exposes the RPC client via `useNuxtApp().$rpc`.
59
59
  * - When `devframe` is provided and Nuxt is in dev mode, registers a
60
- * Vite plugin (via `addVitePlugin(viteDevBridge(devframe, {
61
- * devMiddleware: ... }))`) that starts the RPC + WS bridge and
62
- * serves `${baseURL}__connection.json`.
60
+ * Vite plugin (via `addVitePlugin(devframeViteBridge(devframe, {
61
+ * ... }))`) that starts the RPC + WS bridge and serves
62
+ * `${baseURL}__connection.json`.
63
63
  *
64
64
  * ```ts [nuxt.config.ts]
65
65
  * import devframe from './src/devframe' // defineDevframe(...) export
@@ -1,6 +1,6 @@
1
+ import { devframeViteBridge } from "@devframes/vite/dev-spa";
1
2
  import { addPlugin, addVitePlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
2
- import { viteDevBridge } from "devframe/helpers/vite";
3
- //#region src/module.ts
3
+ //#region src/dev-spa.ts
4
4
  /**
5
5
  * Nuxt module that wires a Nuxt-built SPA up as a devframe client, and
6
6
  * (optionally) serves the dev-time RPC bridge alongside `nuxt dev`.
@@ -11,9 +11,9 @@ import { viteDevBridge } from "devframe/helpers/vite";
11
11
  * - Injects a client plugin that calls {@link connectDevframe} once on
12
12
  * page load and exposes the RPC client via `useNuxtApp().$rpc`.
13
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`.
14
+ * Vite plugin (via `addVitePlugin(devframeViteBridge(devframe, {
15
+ * ... }))`) that starts the RPC + WS bridge and serves
16
+ * `${baseURL}__connection.json`.
17
17
  *
18
18
  * ```ts [nuxt.config.ts]
19
19
  * import devframe from './src/devframe' // defineDevframe(...) export
@@ -32,7 +32,7 @@ import { viteDevBridge } from "devframe/helpers/vite";
32
32
  * }
33
33
  * ```
34
34
  */
35
- var module_default = defineNuxtModule({
35
+ var dev_spa_default = defineNuxtModule({
36
36
  meta: {
37
37
  name: "@devframes/nuxt",
38
38
  configKey: "devframe"
@@ -66,16 +66,14 @@ var module_default = defineNuxtModule({
66
66
  if (options.devframe && options.devMiddleware !== false && nuxt.options.dev) {
67
67
  const mw = options.devMiddleware === true || options.devMiddleware === void 0 ? {} : options.devMiddleware;
68
68
  const host = mw.host ?? nuxt.options.devServer?.host ?? options.devframe.cli?.host;
69
- addVitePlugin(viteDevBridge(options.devframe, {
69
+ addVitePlugin(devframeViteBridge(options.devframe, {
70
70
  base: options.baseURL ?? "./",
71
- devMiddleware: {
72
- port: mw.port,
73
- host,
74
- flags: mw.flags
75
- }
71
+ port: mw.port,
72
+ host,
73
+ flags: mw.flags
76
74
  }));
77
75
  }
78
76
  }
79
77
  });
80
78
  //#endregion
81
- export { module_default as default };
79
+ export { dev_spa_default as default };
@@ -0,0 +1,28 @@
1
+ import { DevframeClientHost, DevframeClientHost as DevframeClientHost$1, DevframeClientHostOptions, DevframeClientHostOptions as DevframeClientHostOptions$1 } from "@devframes/hub/client";
2
+ import { Ref } from "vue";
3
+ //#region src/hub-client.d.ts
4
+ interface UseDevframeHubClientOptions extends DevframeClientHostOptions$1 {
5
+ /**
6
+ * Hub mount base to connect to. Forwarded as `connect.baseURL` when no
7
+ * `rpc` / `connect.baseURL` is supplied.
8
+ *
9
+ * @default '/__devframes/'
10
+ */
11
+ base?: string;
12
+ }
13
+ /**
14
+ * Boot the devframes-hub **client runtime** inside a Nuxt (Vue) client
15
+ * component — the browser half of `@devframes/nuxt/hub`. Connects RPC to the
16
+ * hub (defaulting `base` to `/__devframes/`), assembles the shared
17
+ * `DevframeClientContext`, imports each dock's client script into the page,
18
+ * and disposes when the current effect scope is torn down. Returns a ref that
19
+ * resolves to the {@link DevframeClientHost} (`null` while connecting).
20
+ *
21
+ * Client-only: call it inside `<script setup>` on a client-rendered component
22
+ * (e.g. under `<ClientOnly>`), never during SSR. Only needed when you render
23
+ * your own dock UI (or override the hub's `ui`); with the default
24
+ * `@devframes/hub-ui` the injected `embedded.js` boots the client for you.
25
+ */
26
+ declare function useDevframeHubClient(options?: UseDevframeHubClientOptions): Ref<DevframeClientHost$1 | null>;
27
+ //#endregion
28
+ export { type DevframeClientHost, type DevframeClientHostOptions, UseDevframeHubClientOptions, useDevframeHubClient };
@@ -0,0 +1,44 @@
1
+ import { createDevframeClientHost } from "@devframes/hub/client";
2
+ import { onScopeDispose, shallowRef } from "vue";
3
+ //#region src/hub-client.ts
4
+ /** Default hub mount base — mirrors `@devframes/hub`'s `DEVFRAMES_HUB_BASE`. */
5
+ const DEVFRAMES_HUB_BASE = "/__devframes/";
6
+ /**
7
+ * Boot the devframes-hub **client runtime** inside a Nuxt (Vue) client
8
+ * component — the browser half of `@devframes/nuxt/hub`. Connects RPC to the
9
+ * hub (defaulting `base` to `/__devframes/`), assembles the shared
10
+ * `DevframeClientContext`, imports each dock's client script into the page,
11
+ * and disposes when the current effect scope is torn down. Returns a ref that
12
+ * resolves to the {@link DevframeClientHost} (`null` while connecting).
13
+ *
14
+ * Client-only: call it inside `<script setup>` on a client-rendered component
15
+ * (e.g. under `<ClientOnly>`), never during SSR. Only needed when you render
16
+ * your own dock UI (or override the hub's `ui`); with the default
17
+ * `@devframes/hub-ui` the injected `embedded.js` boots the client for you.
18
+ */
19
+ function useDevframeHubClient(options = {}) {
20
+ const { base = DEVFRAMES_HUB_BASE, connect, ...rest } = options;
21
+ const host = shallowRef(null);
22
+ let disposed = false;
23
+ createDevframeClientHost({
24
+ ...rest,
25
+ ...rest.rpc ? {} : { connect: {
26
+ baseURL: base,
27
+ ...connect
28
+ } }
29
+ }).then((created) => {
30
+ if (disposed) {
31
+ created.dispose();
32
+ return;
33
+ }
34
+ host.value = created;
35
+ });
36
+ onScopeDispose(() => {
37
+ disposed = true;
38
+ host.value?.dispose();
39
+ host.value = null;
40
+ });
41
+ return host;
42
+ }
43
+ //#endregion
44
+ export { useDevframeHubClient };
package/dist/hub.d.mts ADDED
@@ -0,0 +1,40 @@
1
+ import { ViteDevframeHubOptions } from "@devframes/vite/hub";
2
+ //#region src/hub.d.ts
3
+ interface DevframeNuxtHubOptions extends Omit<ViteDevframeHubOptions, 'quiet'> {
4
+ /**
5
+ * Inject `@devframes/hub-ui`'s floating-dock bootstrap (`<base>embedded.js`)
6
+ * into the app head in dev. Disable if you render your own UI or pass
7
+ * `ui: false`. Default: `true` (unless `ui` is `false`).
8
+ */
9
+ injectEmbedded?: boolean;
10
+ /**
11
+ * Silence the notice recommending Nuxt DevTools. See the module docs.
12
+ *
13
+ * @default false
14
+ */
15
+ quiet?: boolean;
16
+ }
17
+ type ModuleOptions = DevframeNuxtHubOptions;
18
+ /**
19
+ * Nuxt module that mounts a whole **devframes-hub** alongside `nuxt dev` —
20
+ * many integrations under one namespace, one merged RPC registry — by wiring
21
+ * `@devframes/vite`'s hub plugin into Nuxt's underlying Vite dev server and
22
+ * injecting `@devframes/hub-ui`'s floating dock into the app. The UI defaults
23
+ * to `@devframes/hub-ui`; pass `ui` to swap it or `ui: false` for a headless
24
+ * hub you drive with `@devframes/nuxt/hub/client`.
25
+ *
26
+ * This mounts one integration-agnostic hub. Nuxt DevTools (`@nuxt/devtools`)
27
+ * integrates the same hub protocol natively and is the recommended path for a
28
+ * Nuxt app, so this module emits a one-time notice to that effect (silence it
29
+ * with `{ quiet: true }`). To wire a Nuxt app up as a single devframe client,
30
+ * reach for `@devframes/nuxt/dev-spa` instead.
31
+ *
32
+ * ```ts [nuxt.config.ts]
33
+ * export default defineNuxtConfig({
34
+ * modules: [['@devframes/nuxt/hub', { devframes: [] }]],
35
+ * })
36
+ * ```
37
+ */
38
+ declare const _default: import("@nuxt/schema").NuxtModule<DevframeNuxtHubOptions, DevframeNuxtHubOptions, false>;
39
+ //#endregion
40
+ export { DevframeNuxtHubOptions, ModuleOptions, _default as default };
package/dist/hub.mjs ADDED
@@ -0,0 +1,66 @@
1
+ import { addVitePlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
2
+ import { viteDevframeHub } from "@devframes/vite/hub";
3
+ //#region src/hub.ts
4
+ /** Default hub mount base — mirrors `@devframes/hub`'s `DEVFRAMES_HUB_BASE`. */
5
+ const DEVFRAMES_HUB_BASE = "/__devframes/";
6
+ let recommendedNuxtDevtools = false;
7
+ function recommendNuxtDevtools() {
8
+ if (recommendedNuxtDevtools) return;
9
+ recommendedNuxtDevtools = true;
10
+ console.warn("[@devframes/nuxt/hub] Serving a devframes-hub directly inside Nuxt works, but Nuxt DevTools (`@nuxt/devtools`) integrates the hub protocol natively — prefer it for a first-class, multi-integration experience. Pass `{ quiet: true }` to silence this notice.");
11
+ }
12
+ /**
13
+ * Nuxt module that mounts a whole **devframes-hub** alongside `nuxt dev` —
14
+ * many integrations under one namespace, one merged RPC registry — by wiring
15
+ * `@devframes/vite`'s hub plugin into Nuxt's underlying Vite dev server and
16
+ * injecting `@devframes/hub-ui`'s floating dock into the app. The UI defaults
17
+ * to `@devframes/hub-ui`; pass `ui` to swap it or `ui: false` for a headless
18
+ * hub you drive with `@devframes/nuxt/hub/client`.
19
+ *
20
+ * This mounts one integration-agnostic hub. Nuxt DevTools (`@nuxt/devtools`)
21
+ * integrates the same hub protocol natively and is the recommended path for a
22
+ * Nuxt app, so this module emits a one-time notice to that effect (silence it
23
+ * with `{ quiet: true }`). To wire a Nuxt app up as a single devframe client,
24
+ * reach for `@devframes/nuxt/dev-spa` instead.
25
+ *
26
+ * ```ts [nuxt.config.ts]
27
+ * export default defineNuxtConfig({
28
+ * modules: [['@devframes/nuxt/hub', { devframes: [] }]],
29
+ * })
30
+ * ```
31
+ */
32
+ var hub_default = defineNuxtModule({
33
+ meta: {
34
+ name: "@devframes/nuxt/hub",
35
+ configKey: "devframeHub"
36
+ },
37
+ defaults: {},
38
+ setup(options, nuxt) {
39
+ if (!options.quiet) recommendNuxtDevtools();
40
+ if (!nuxt.options.dev) return;
41
+ createResolver(import.meta.url);
42
+ const base = normalizeBase(options.base ?? DEVFRAMES_HUB_BASE);
43
+ const { injectEmbedded, quiet: _quiet, ...hubOptions } = options;
44
+ addVitePlugin(viteDevframeHub({
45
+ ...hubOptions,
46
+ base,
47
+ quiet: true
48
+ }));
49
+ if (injectEmbedded ?? options.ui !== false) {
50
+ nuxt.options.app ??= {};
51
+ nuxt.options.app.head ??= {};
52
+ nuxt.options.app.head.script ??= [];
53
+ nuxt.options.app.head.script.push({
54
+ type: "module",
55
+ src: `${base}embedded.js`
56
+ });
57
+ }
58
+ }
59
+ });
60
+ function normalizeBase(base) {
61
+ let out = base.startsWith("/") ? base : `/${base}`;
62
+ if (!out.endsWith("/")) out = `${out}/`;
63
+ return out;
64
+ }
65
+ //#endregion
66
+ export { hub_default as default };
@@ -0,0 +1 @@
1
+ export {}
package/dist/index.mjs ADDED
@@ -0,0 +1,4 @@
1
+ //#region src/index.ts
2
+ throw new Error("[@devframes/nuxt] has no root export. Use a scoped subpath instead:\n • modules: [\"@devframes/nuxt/dev-spa\"] — Nuxt app as one devframe client\n • modules: [\"@devframes/nuxt/hub\"] — mount a devframes-hub with nuxt dev\n");
3
+ //#endregion
4
+ export {};
package/dist/module.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
- "name": "@devframes/nuxt",
2
+ "name": "@devframes/nuxt/dev-spa",
3
3
  "configKey": "devframe",
4
- "version": "0.9.0-beta.2",
4
+ "version": "0.9.0-beta.4",
5
5
  "builder": {
6
6
  "tsdown": "0.22.14"
7
- }
7
+ }
8
8
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@devframes/nuxt",
3
3
  "type": "module",
4
- "version": "0.9.0-beta.2",
4
+ "version": "0.9.0-beta.4",
5
5
  "description": "Nuxt module that exposes a Nuxt app as a devframe client.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -20,25 +20,52 @@
20
20
  "sideEffects": false,
21
21
  "exports": {
22
22
  ".": {
23
- "types": "./dist/types.d.mts",
24
- "default": "./dist/module.mjs"
23
+ "types": "./dist/index.d.mts",
24
+ "default": "./dist/index.mjs"
25
+ },
26
+ "./dev-spa": {
27
+ "types": "./dist/dev-spa.d.mts",
28
+ "default": "./dist/dev-spa.mjs"
29
+ },
30
+ "./hub": {
31
+ "types": "./dist/hub.d.mts",
32
+ "default": "./dist/hub.mjs"
33
+ },
34
+ "./hub/client": {
35
+ "types": "./dist/hub-client.d.mts",
36
+ "default": "./dist/hub-client.mjs"
25
37
  },
26
38
  "./package.json": "./package.json"
27
39
  },
28
- "types": "./dist/types.d.mts",
40
+ "types": "./dist/index.d.mts",
29
41
  "files": [
30
42
  "dist"
31
43
  ],
32
44
  "peerDependencies": {
33
45
  "@nuxt/kit": "^3.0.0 || ^4.0.0 || ^5.0.0-0",
34
- "devframe": "0.9.0-beta.2"
46
+ "vue": "^3.0.0",
47
+ "@devframes/hub": "0.9.0-beta.4",
48
+ "devframe": "0.9.0-beta.4"
49
+ },
50
+ "peerDependenciesMeta": {
51
+ "@devframes/hub": {
52
+ "optional": true
53
+ },
54
+ "vue": {
55
+ "optional": true
56
+ }
57
+ },
58
+ "dependencies": {
59
+ "@devframes/vite": "0.9.0-beta.4"
35
60
  },
36
61
  "devDependencies": {
37
62
  "@nuxt/kit": "^4.5.2",
38
63
  "@types/node": "^26.2.0",
39
64
  "nuxt": "^4.5.2",
40
65
  "tsdown": "^0.22.14",
41
- "devframe": "0.9.0-beta.2"
66
+ "vue": "^3.5.41",
67
+ "devframe": "0.9.0-beta.4",
68
+ "@devframes/hub": "0.9.0-beta.4"
42
69
  },
43
70
  "scripts": {
44
71
  "build": "tsdown",
package/dist/types.d.mts DELETED
@@ -1,3 +0,0 @@
1
- export { default } from './module.mjs';
2
-
3
- export { type ModuleOptions, type DevframeNuxtModuleOptions } from './module.mjs';