@devframes/nuxt 0.9.0-beta.2 → 0.9.0-beta.7
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/dist/hub-client.d.mts +28 -0
- package/dist/hub-client.mjs +43 -0
- package/dist/hub.d.mts +40 -0
- package/dist/hub.mjs +60 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +4 -0
- package/dist/module.json +3 -3
- package/dist/{module.d.mts → single.d.mts} +6 -6
- package/dist/{module.mjs → single.mjs} +11 -13
- package/package.json +33 -6
- package/dist/types.d.mts +0 -3
|
@@ -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,43 @@
|
|
|
1
|
+
import { createDevframeClientHost } from "@devframes/hub/client";
|
|
2
|
+
import { DEVFRAMES_HUB_BASE } from "@devframes/hub/constants";
|
|
3
|
+
import { onScopeDispose, shallowRef } from "vue";
|
|
4
|
+
//#region src/hub-client.ts
|
|
5
|
+
/**
|
|
6
|
+
* Boot the devframes-hub **client runtime** inside a Nuxt (Vue) client
|
|
7
|
+
* component — the browser half of `@devframes/nuxt/hub`. Connects RPC to the
|
|
8
|
+
* hub (defaulting `base` to `/__devframes/`), assembles the shared
|
|
9
|
+
* `DevframeClientContext`, imports each dock's client script into the page,
|
|
10
|
+
* and disposes when the current effect scope is torn down. Returns a ref that
|
|
11
|
+
* resolves to the {@link DevframeClientHost} (`null` while connecting).
|
|
12
|
+
*
|
|
13
|
+
* Client-only: call it inside `<script setup>` on a client-rendered component
|
|
14
|
+
* (e.g. under `<ClientOnly>`), never during SSR. Only needed when you render
|
|
15
|
+
* your own dock UI (or override the hub's `ui`); with the default
|
|
16
|
+
* `@devframes/hub-ui` the injected `embedded.js` boots the client for you.
|
|
17
|
+
*/
|
|
18
|
+
function useDevframeHubClient(options = {}) {
|
|
19
|
+
const { base = DEVFRAMES_HUB_BASE, connect, ...rest } = options;
|
|
20
|
+
const host = shallowRef(null);
|
|
21
|
+
let disposed = false;
|
|
22
|
+
createDevframeClientHost({
|
|
23
|
+
...rest,
|
|
24
|
+
...rest.rpc ? {} : { connect: {
|
|
25
|
+
baseURL: base,
|
|
26
|
+
...connect
|
|
27
|
+
} }
|
|
28
|
+
}).then((created) => {
|
|
29
|
+
if (disposed) {
|
|
30
|
+
created.dispose();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
host.value = created;
|
|
34
|
+
});
|
|
35
|
+
onScopeDispose(() => {
|
|
36
|
+
disposed = true;
|
|
37
|
+
host.value?.dispose();
|
|
38
|
+
host.value = null;
|
|
39
|
+
});
|
|
40
|
+
return host;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
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/single` 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,60 @@
|
|
|
1
|
+
import { addVitePlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
|
|
2
|
+
import { DEVFRAMES_HUB_BASE, normalizeHubBase } from "@devframes/hub/constants";
|
|
3
|
+
import { viteDevframeHub } from "@devframes/vite/hub";
|
|
4
|
+
//#region src/hub.ts
|
|
5
|
+
let recommendedNuxtDevtools = false;
|
|
6
|
+
function recommendNuxtDevtools() {
|
|
7
|
+
if (recommendedNuxtDevtools) return;
|
|
8
|
+
recommendedNuxtDevtools = true;
|
|
9
|
+
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.");
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Nuxt module that mounts a whole **devframes-hub** alongside `nuxt dev` —
|
|
13
|
+
* many integrations under one namespace, one merged RPC registry — by wiring
|
|
14
|
+
* `@devframes/vite`'s hub plugin into Nuxt's underlying Vite dev server and
|
|
15
|
+
* injecting `@devframes/hub-ui`'s floating dock into the app. The UI defaults
|
|
16
|
+
* to `@devframes/hub-ui`; pass `ui` to swap it or `ui: false` for a headless
|
|
17
|
+
* hub you drive with `@devframes/nuxt/hub/client`.
|
|
18
|
+
*
|
|
19
|
+
* This mounts one integration-agnostic hub. Nuxt DevTools (`@nuxt/devtools`)
|
|
20
|
+
* integrates the same hub protocol natively and is the recommended path for a
|
|
21
|
+
* Nuxt app, so this module emits a one-time notice to that effect (silence it
|
|
22
|
+
* with `{ quiet: true }`). To wire a Nuxt app up as a single devframe client,
|
|
23
|
+
* reach for `@devframes/nuxt/single` instead.
|
|
24
|
+
*
|
|
25
|
+
* ```ts [nuxt.config.ts]
|
|
26
|
+
* export default defineNuxtConfig({
|
|
27
|
+
* modules: [['@devframes/nuxt/hub', { devframes: [] }]],
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
var hub_default = defineNuxtModule({
|
|
32
|
+
meta: {
|
|
33
|
+
name: "@devframes/nuxt/hub",
|
|
34
|
+
configKey: "devframeHub"
|
|
35
|
+
},
|
|
36
|
+
defaults: {},
|
|
37
|
+
setup(options, nuxt) {
|
|
38
|
+
if (!options.quiet) recommendNuxtDevtools();
|
|
39
|
+
if (!nuxt.options.dev) return;
|
|
40
|
+
createResolver(import.meta.url);
|
|
41
|
+
const base = normalizeHubBase(options.base ?? DEVFRAMES_HUB_BASE);
|
|
42
|
+
const { injectEmbedded, quiet: _quiet, ...hubOptions } = options;
|
|
43
|
+
addVitePlugin(viteDevframeHub({
|
|
44
|
+
...hubOptions,
|
|
45
|
+
base,
|
|
46
|
+
quiet: true
|
|
47
|
+
}));
|
|
48
|
+
if (injectEmbedded ?? options.ui !== false) {
|
|
49
|
+
nuxt.options.app ??= {};
|
|
50
|
+
nuxt.options.app.head ??= {};
|
|
51
|
+
nuxt.options.app.head.script ??= [];
|
|
52
|
+
nuxt.options.app.head.script.push({
|
|
53
|
+
type: "module",
|
|
54
|
+
src: `${base}embedded.js`
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
//#endregion
|
|
60
|
+
export { hub_default as default };
|
package/dist/index.d.mts
ADDED
|
@@ -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/single\"] — 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,5 +1,5 @@
|
|
|
1
1
|
import { DevframeDefinition } from "devframe";
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/single.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
|
|
28
|
-
*
|
|
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(
|
|
61
|
-
*
|
|
62
|
-
*
|
|
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/single";
|
|
1
2
|
import { addPlugin, addVitePlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
|
|
2
|
-
|
|
3
|
-
//#region src/module.ts
|
|
3
|
+
//#region src/single.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(
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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
|
|
35
|
+
var single_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(
|
|
69
|
+
addVitePlugin(devframeViteBridge(options.devframe, {
|
|
70
70
|
base: options.baseURL ?? "./",
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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 {
|
|
79
|
+
export { single_default as default };
|
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.
|
|
4
|
+
"version": "0.9.0-beta.7",
|
|
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/
|
|
24
|
-
"default": "./dist/
|
|
23
|
+
"types": "./dist/index.d.mts",
|
|
24
|
+
"default": "./dist/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./single": {
|
|
27
|
+
"types": "./dist/single.d.mts",
|
|
28
|
+
"default": "./dist/single.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/
|
|
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
|
-
"
|
|
46
|
+
"vue": "^3.0.0",
|
|
47
|
+
"@devframes/hub": "0.9.0-beta.7",
|
|
48
|
+
"devframe": "0.9.0-beta.7"
|
|
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.7"
|
|
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
|
-
"
|
|
66
|
+
"vue": "^3.5.41",
|
|
67
|
+
"devframe": "0.9.0-beta.7",
|
|
68
|
+
"@devframes/hub": "0.9.0-beta.7"
|
|
42
69
|
},
|
|
43
70
|
"scripts": {
|
|
44
71
|
"build": "tsdown",
|
package/dist/types.d.mts
DELETED