@macrulez/visual-linker-nuxt 0.3.0 → 0.4.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/README.md +40 -38
- package/dist/module.d.ts +2 -41
- package/dist/module.js +1 -30
- package/dist/module.js.map +1 -1
- package/dist/runtime/plugin.js +4 -2
- package/dist/runtime/plugin.js.map +1 -1
- package/package.json +2 -2
- package/dist/runtime/plugin.client.d.ts +0 -5
- package/dist/runtime/plugin.client.js +0 -11
- package/dist/runtime/plugin.client.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
Nuxt module wrapping
|
|
6
6
|
[`@macrulez/visual-linker-vue`](https://www.npmjs.com/package/@macrulez/visual-linker-vue):
|
|
7
|
-
auto-imported `<VisualLinker>`/`useVisualLinker`, and a
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
own.
|
|
7
|
+
auto-imported `<VisualLinker>`/`useVisualLinker`, and a shared configuration
|
|
8
|
+
of every diagram taken from your `nuxt.config.ts` — no manual `<ClientOnly>`
|
|
9
|
+
wrapping needed, both are already SSR-safe on their own.
|
|
11
10
|
|
|
12
11
|
Part of the [visual-linker](https://github.com/macrulezru/visual-linker)
|
|
13
12
|
monorepo.
|
|
@@ -18,9 +17,9 @@ monorepo.
|
|
|
18
17
|
|
|
19
18
|
- **Auto-imports `<VisualLinker>` and `useVisualLinker`** — registered/imported from `@macrulez/visual-linker-vue`, no explicit `import` anywhere in your app
|
|
20
19
|
- **Registers `v-vl-block` / `v-vl-port` globally** — on the server too, so the `data-vl-*` discovery attributes are already in the server-rendered HTML
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
- **Nothing needs `<ClientOnly>`** — the component/composable are SSR-safe on their own
|
|
20
|
+
- **The whole configuration, set once** — `visualLinker` in `nuxt.config.ts` takes the same structure as the engine (`theme`, `lines`, `markers`, `ports`, `labels`, `blocks`, `interaction`), applied to every diagram
|
|
21
|
+
- **The configuration is shared through Vue's `provide`** — one reactive object per app, which `useVisualLinkerConfig()` exposes for runtime changes (a theme switch re-styles every diagram)
|
|
22
|
+
- **Nothing needs `<ClientOnly>`** — the component/composable are SSR-safe on their own
|
|
24
23
|
|
|
25
24
|
---
|
|
26
25
|
|
|
@@ -28,10 +27,10 @@ monorepo.
|
|
|
28
27
|
|
|
29
28
|
You're already on Nuxt and want `<VisualLinker>`/`useVisualLinker` wired
|
|
30
29
|
up with zero manual setup — auto-imports, and one place to configure
|
|
31
|
-
|
|
32
|
-
site.
|
|
30
|
+
style, theme and behavior in one structured config instead of passing the
|
|
31
|
+
same `config` at every call site.
|
|
33
32
|
|
|
34
|
-
- **Passing the same `
|
|
33
|
+
- **Passing the same `config` to every `<VisualLinker>` on the page gets old** — Set `lines`/`ports`/`theme`/etc. once in `nuxt.config.ts` and every instance that doesn't override them picks up your project's defaults automatically.
|
|
35
34
|
- **You'd rather not remember to import the component in every page** — Auto-imports mean `<VisualLinker>`/`useVisualLinker()` are just available, the same way Nuxt's own built-ins are.
|
|
36
35
|
- **A team member reaches for `<ClientOnly>` out of habit** — There's nothing to wrap. Both already render an SSR-safe no-op and pick up the real diagram after hydration on their own.
|
|
37
36
|
|
|
@@ -48,8 +47,8 @@ npm install @macrulez/visual-linker-nuxt
|
|
|
48
47
|
export default defineNuxtConfig({
|
|
49
48
|
modules: ['@macrulez/visual-linker-nuxt'],
|
|
50
49
|
visualLinker: {
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
lines: { curve: 'smoothstep' },
|
|
51
|
+
ports: { show: true },
|
|
53
52
|
},
|
|
54
53
|
})
|
|
55
54
|
```
|
|
@@ -78,8 +77,7 @@ for the full component/composable API.
|
|
|
78
77
|
|
|
79
78
|
1. **Auto-imports** `<VisualLinker>` as a global component and `useVisualLinker` as an auto-import, both sourced from `@macrulez/visual-linker-vue` — no explicit `import` needed in your components.
|
|
80
79
|
2. **Forwards module options** into `runtimeConfig.public.visualLinker`.
|
|
81
|
-
3. **Registers the `v-vl-block` / `v-vl-port` directives
|
|
82
|
-
4. **Registers a client-only plugin** (`runtime/plugin.client.ts`) that reads that runtime config and calls `setVisualLinkerDefaults(...)` — so every `<VisualLinker>`/`useVisualLinker()` use that doesn't pass its own `options` picks up your configured defaults.
|
|
80
|
+
3. **Registers one universal plugin** (`runtime/plugin.ts`): the `v-vl-block` / `v-vl-port` directives — on the server too, so the `data-vl-*` attributes are already in the SSR markup — and the app-wide shared config, taken from that runtime config. Every `<VisualLinker>`/`useVisualLinker()` merges it under its own `config`, and `useVisualLinkerConfig()` (from `@macrulez/visual-linker-vue`) hands you the same reactive object to change at runtime, e.g. to switch the theme.
|
|
83
81
|
|
|
84
82
|
No `defaults` are hardcoded in the module itself — a field left unset in
|
|
85
83
|
`nuxt.config.ts` falls all the way through to
|
|
@@ -88,40 +86,44 @@ to core's default is never silently shadowed by this module.
|
|
|
88
86
|
|
|
89
87
|
#### Module options
|
|
90
88
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
89
|
+
The `visualLinker` key is a `VisualLinkerConfig` — exactly the object
|
|
90
|
+
`createVisualLinker()` and `<VisualLinker :config>` take, so there is no
|
|
91
|
+
separate list of module-only names to learn:
|
|
92
|
+
|
|
93
|
+
| Group | What it configures |
|
|
94
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
95
|
+
| `theme` | color tokens, written as CSS variables — `lightTheme`/`darkTheme` or your own |
|
|
96
|
+
| `lines` | curve, color/width/dashed, `hover`/`selected`/`focus`, `bezier`, `smoothstep`, `routing`, `jumps`, `animated` |
|
|
97
|
+
| `markers` | `start`/`end` markers (with their own states) and per-shape `sizes` |
|
|
98
|
+
| `ports` | the built-in dot (`show`, `radius`, `fill`, `stroke`, states), default `side`/`offset`, `spread` |
|
|
99
|
+
| `labels` | the look of library-drawn connection labels, with states |
|
|
100
|
+
| `blocks` | `draggable`, `drag: { grid, bounds }` (values must be plain data — `'container'` or an inset object) |
|
|
101
|
+
| `interaction` | `selectable`, `clipToScrollParents` |
|
|
102
|
+
|
|
103
|
+
Everything is optional and nothing is hardcoded in the module: a field left
|
|
104
|
+
out falls through to `@macrulez/visual-linker-core`'s own built-in default.
|
|
105
|
+
The options travel through `runtimeConfig.public.visualLinker`, so they must
|
|
106
|
+
be JSON-serializable (no `HTMLElement` for `drag.bounds`).
|
|
107
|
+
|
|
108
|
+
#### An app-wide look
|
|
110
109
|
|
|
111
110
|
```ts
|
|
112
111
|
// nuxt.config.ts
|
|
113
112
|
export default defineNuxtConfig({
|
|
114
113
|
modules: ['@macrulez/visual-linker-nuxt'],
|
|
115
114
|
visualLinker: {
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
theme: { line: '#6366f1', lineHover: '#312e81' },
|
|
116
|
+
lines: { curve: 'smoothstep', smoothstep: { cornerRadius: 10 }, jumps: true },
|
|
117
|
+
markers: { end: { shape: 'arrow', hover: { size: 10 } } },
|
|
118
|
+
blocks: { draggable: true, drag: { grid: 20 } },
|
|
118
119
|
},
|
|
119
120
|
})
|
|
120
121
|
```
|
|
121
122
|
|
|
122
|
-
Every `<VisualLinker>`/`useVisualLinker()` call in the app
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
Every `<VisualLinker>`/`useVisualLinker()` call in the app starts from this,
|
|
124
|
+
and a call site's own `config` overrides it field by field. The values are
|
|
125
|
+
also reactive at runtime: `useVisualLinkerConfig().theme = darkTheme`
|
|
126
|
+
(from `@macrulez/visual-linker-vue`) re-themes every diagram on the page.
|
|
125
127
|
|
|
126
128
|
---
|
|
127
129
|
|
package/dist/module.d.ts
CHANGED
|
@@ -1,46 +1,7 @@
|
|
|
1
1
|
import { NuxtModule } from '@nuxt/schema';
|
|
2
|
-
import {
|
|
2
|
+
import { VisualLinkerConfig } from '@macrulez/visual-linker-vue';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
/** Falls through to @macrulez/visual-linker-core's own default (VLConnectionCurveEnum.BEZIER) when unset. */
|
|
6
|
-
defaultCurve?: ConnectionCurve;
|
|
7
|
-
/** Falls through to @macrulez/visual-linker-core's own default (true) when unset. */
|
|
8
|
-
showPorts?: boolean;
|
|
9
|
-
curvature?: number;
|
|
10
|
-
curveMinReach?: number;
|
|
11
|
-
curveMaxReach?: number;
|
|
12
|
-
curveAngleBlend?: number;
|
|
13
|
-
curveAngleMaxOffset?: number;
|
|
14
|
-
/** Snaps every draggable block to this px grid while dragging. Falls through to no snapping when unset. */
|
|
15
|
-
dragGridSize?: number;
|
|
16
|
-
/** Instance-wide look for the built-in port dot — falls through to @macrulez/visual-linker-core's own defaults (params.ts) when unset. */
|
|
17
|
-
portRadius?: number;
|
|
18
|
-
portColor?: string;
|
|
19
|
-
portStrokeColor?: string;
|
|
20
|
-
portStrokeWidth?: number;
|
|
21
|
-
/** Instance-wide default marker size per built-in shape — falls through to @macrulez/visual-linker-core's own defaults (params.ts) when unset. */
|
|
22
|
-
circleMarkerSize?: number;
|
|
23
|
-
squareMarkerSize?: number;
|
|
24
|
-
diamondMarkerSize?: number;
|
|
25
|
-
arrowMarkerSize?: number;
|
|
26
|
-
/** Spreads connections sharing a port side into separate virtual ports — `true`, `{ gap, padding }`, or unset (off). */
|
|
27
|
-
portSpread?: boolean | {
|
|
28
|
-
gap?: number;
|
|
29
|
-
padding?: number;
|
|
30
|
-
};
|
|
31
|
-
/** What to do with a connection end scrolled out of a clipping ancestor: `'pin'` (`true`, default) to the visible edge, `'hide'` the connection, `false` ignore. */
|
|
32
|
-
clipToScrollParents?: boolean | 'pin' | 'hide';
|
|
33
|
-
/** Animated flow along every connection by default — `true` or a `ConnectionFlow` object; a connection can opt out with `animated: false`. */
|
|
34
|
-
animated?: boolean | ConnectionFlow;
|
|
35
|
-
/** Route `smoothstep` connections around the other blocks instead of through them. */
|
|
36
|
-
avoidObstacles?: boolean;
|
|
37
|
-
/** Clearance kept between a routed line and every other block, px. */
|
|
38
|
-
obstaclePadding?: number;
|
|
39
|
-
/** Hop over crossing lines (`smoothstep`): `true` or `{ radius }`. */
|
|
40
|
-
jumps?: boolean | {
|
|
41
|
-
radius?: number;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
4
|
+
type ModuleOptions = VisualLinkerConfig;
|
|
44
5
|
declare const visualLinkerModule: NuxtModule<ModuleOptions>;
|
|
45
6
|
|
|
46
7
|
export { type ModuleOptions, visualLinkerModule as default };
|
package/dist/module.js
CHANGED
|
@@ -5,41 +5,12 @@ var visualLinkerModule = defineNuxtModule({
|
|
|
5
5
|
name: "@macrulez/visual-linker-nuxt",
|
|
6
6
|
configKey: "visualLinker"
|
|
7
7
|
},
|
|
8
|
-
// No `defaults` here on purpose: an option the user didn't set in
|
|
9
|
-
// nuxt.config.ts must stay `undefined` all the way through to
|
|
10
|
-
// @macrulez/visual-linker-core's own defaults (params.ts) — hardcoding one
|
|
11
|
-
// here would silently shadow it, making a change to core's default look
|
|
12
|
-
// like it does nothing for a Nuxt consumer.
|
|
13
8
|
setup(options, nuxt) {
|
|
14
9
|
const resolver = createResolver(import.meta.url);
|
|
15
10
|
addComponent({ name: "VisualLinker", export: "VisualLinker", filePath: "@macrulez/visual-linker-vue" });
|
|
16
11
|
addImports({ name: "useVisualLinker", from: "@macrulez/visual-linker-vue" });
|
|
17
|
-
nuxt.options.runtimeConfig.public.visualLinker = {
|
|
18
|
-
defaultCurve: options.defaultCurve,
|
|
19
|
-
showPorts: options.showPorts,
|
|
20
|
-
defaultCurvature: options.curvature,
|
|
21
|
-
defaultCurveMinReach: options.curveMinReach,
|
|
22
|
-
defaultCurveMaxReach: options.curveMaxReach,
|
|
23
|
-
defaultCurveAngleBlend: options.curveAngleBlend,
|
|
24
|
-
defaultCurveAngleMaxOffset: options.curveAngleMaxOffset,
|
|
25
|
-
dragGridSize: options.dragGridSize,
|
|
26
|
-
defaultPortRadius: options.portRadius,
|
|
27
|
-
defaultPortColor: options.portColor,
|
|
28
|
-
defaultPortStrokeColor: options.portStrokeColor,
|
|
29
|
-
defaultPortStrokeWidth: options.portStrokeWidth,
|
|
30
|
-
defaultCircleMarkerSize: options.circleMarkerSize,
|
|
31
|
-
defaultSquareMarkerSize: options.squareMarkerSize,
|
|
32
|
-
defaultDiamondMarkerSize: options.diamondMarkerSize,
|
|
33
|
-
defaultArrowMarkerSize: options.arrowMarkerSize,
|
|
34
|
-
defaultPortSpread: options.portSpread,
|
|
35
|
-
clipToScrollParents: options.clipToScrollParents,
|
|
36
|
-
defaultAnimated: options.animated,
|
|
37
|
-
avoidObstacles: options.avoidObstacles,
|
|
38
|
-
obstaclePadding: options.obstaclePadding,
|
|
39
|
-
jumps: options.jumps
|
|
40
|
-
};
|
|
12
|
+
nuxt.options.runtimeConfig.public.visualLinker = JSON.parse(JSON.stringify(options ?? {}));
|
|
41
13
|
addPlugin(resolver.resolve("./runtime/plugin"));
|
|
42
|
-
addPlugin(resolver.resolve("./runtime/plugin.client"));
|
|
43
14
|
}
|
|
44
15
|
});
|
|
45
16
|
var module_default = visualLinkerModule;
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/module.ts"],"sourcesContent":["import { addComponent, addImports, addPlugin, createResolver, defineNuxtModule } from '@nuxt/kit'\nimport type { NuxtModule } from '@nuxt/schema'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/module.ts"],"sourcesContent":["import { addComponent, addImports, addPlugin, createResolver, defineNuxtModule } from '@nuxt/kit'\nimport type { NuxtModule } from '@nuxt/schema'\nimport type { VisualLinkerConfig } from '@macrulez/visual-linker-vue'\n\nexport type ModuleOptions = VisualLinkerConfig\n\nconst visualLinkerModule: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@macrulez/visual-linker-nuxt',\n configKey: 'visualLinker',\n },\n setup(options, nuxt) {\n const resolver = createResolver(import.meta.url)\n\n addComponent({ name: 'VisualLinker', export: 'VisualLinker', filePath: '@macrulez/visual-linker-vue' })\n addImports({ name: 'useVisualLinker', from: '@macrulez/visual-linker-vue' })\n\n nuxt.options.runtimeConfig.public.visualLinker = JSON.parse(JSON.stringify(options ?? {}))\n\n addPlugin(resolver.resolve('./runtime/plugin'))\n },\n})\n\nexport default visualLinkerModule\n"],"mappings":";AAAA,SAAS,cAAc,YAAY,WAAW,gBAAgB,wBAAwB;AAMtF,IAAM,qBAAgD,iBAAgC;AAAA,EACpF,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,WAAW;AAAA,EACb;AAAA,EACA,MAAM,SAAS,MAAM;AACnB,UAAM,WAAW,eAAe,YAAY,GAAG;AAE/C,iBAAa,EAAE,MAAM,gBAAgB,QAAQ,gBAAgB,UAAU,8BAA8B,CAAC;AACtG,eAAW,EAAE,MAAM,mBAAmB,MAAM,8BAA8B,CAAC;AAE3E,SAAK,QAAQ,cAAc,OAAO,eAAe,KAAK,MAAM,KAAK,UAAU,WAAW,CAAC,CAAC,CAAC;AAEzF,cAAU,SAAS,QAAQ,kBAAkB,CAAC;AAAA,EAChD;AACF,CAAC;AAED,IAAO,iBAAQ;","names":[]}
|
package/dist/runtime/plugin.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// src/runtime/plugin.ts
|
|
2
|
-
import { vVlBlock, vVlPort } from "@macrulez/visual-linker-vue";
|
|
3
|
-
import { defineNuxtPlugin } from "nuxt/app";
|
|
2
|
+
import { installVisualLinkerConfig, vVlBlock, vVlPort } from "@macrulez/visual-linker-vue";
|
|
3
|
+
import { defineNuxtPlugin, useRuntimeConfig } from "nuxt/app";
|
|
4
4
|
var plugin_default = defineNuxtPlugin((nuxtApp) => {
|
|
5
5
|
nuxtApp.vueApp.directive("vl-block", vVlBlock);
|
|
6
6
|
nuxtApp.vueApp.directive("vl-port", vVlPort);
|
|
7
|
+
const config = useRuntimeConfig().public.visualLinker;
|
|
8
|
+
installVisualLinkerConfig(nuxtApp.vueApp, config);
|
|
7
9
|
});
|
|
8
10
|
export {
|
|
9
11
|
plugin_default as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/plugin.ts"],"sourcesContent":["import { vVlBlock, vVlPort } from '@macrulez/visual-linker-vue'\nimport { defineNuxtPlugin } from 'nuxt/app'\n\
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/plugin.ts"],"sourcesContent":["import { installVisualLinkerConfig, vVlBlock, vVlPort, type VisualLinkerConfig } from '@macrulez/visual-linker-vue'\nimport { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app'\n\nexport default defineNuxtPlugin((nuxtApp) => {\n nuxtApp.vueApp.directive('vl-block', vVlBlock)\n nuxtApp.vueApp.directive('vl-port', vVlPort)\n const config = useRuntimeConfig().public.visualLinker as VisualLinkerConfig | undefined\n installVisualLinkerConfig(nuxtApp.vueApp, config)\n})\n"],"mappings":";AAAA,SAAS,2BAA2B,UAAU,eAAwC;AACtF,SAAS,kBAAkB,wBAAwB;AAEnD,IAAO,iBAAQ,iBAAiB,CAAC,YAAY;AAC3C,UAAQ,OAAO,UAAU,YAAY,QAAQ;AAC7C,UAAQ,OAAO,UAAU,WAAW,OAAO;AAC3C,QAAM,SAAS,iBAAiB,EAAE,OAAO;AACzC,4BAA0B,QAAQ,QAAQ,MAAM;AAClD,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@macrulez/visual-linker-nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Nuxt module wrapping @macrulez/visual-linker-vue: auto-imported <VisualLinker> and useVisualLinker, module options for default curve/port rendering",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@nuxt/kit": "^4.5.2",
|
|
28
|
-
"@macrulez/visual-linker-vue": "0.
|
|
28
|
+
"@macrulez/visual-linker-vue": "0.4.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@nuxt/schema": "^4.5.2",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// src/runtime/plugin.client.ts
|
|
2
|
-
import { setVisualLinkerDefaults } from "@macrulez/visual-linker-vue";
|
|
3
|
-
import { defineNuxtPlugin, useRuntimeConfig } from "nuxt/app";
|
|
4
|
-
var plugin_client_default = defineNuxtPlugin(() => {
|
|
5
|
-
const config = useRuntimeConfig().public.visualLinker;
|
|
6
|
-
if (config) setVisualLinkerDefaults(config);
|
|
7
|
-
});
|
|
8
|
-
export {
|
|
9
|
-
plugin_client_default as default
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=plugin.client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/plugin.client.ts"],"sourcesContent":["import { setVisualLinkerDefaults, type VisualLinkerDefaults } from '@macrulez/visual-linker-vue'\nimport { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app'\n\nexport default defineNuxtPlugin(() => {\n const config = useRuntimeConfig().public.visualLinker as VisualLinkerDefaults | undefined\n if (config) setVisualLinkerDefaults(config)\n})\n"],"mappings":";AAAA,SAAS,+BAA0D;AACnE,SAAS,kBAAkB,wBAAwB;AAEnD,IAAO,wBAAQ,iBAAiB,MAAM;AACpC,QAAM,SAAS,iBAAiB,EAAE,OAAO;AACzC,MAAI,OAAQ,yBAAwB,MAAM;AAC5C,CAAC;","names":[]}
|