@macrulez/visual-linker-nuxt 0.1.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) 2026 Danil Lisin
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.
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # **Visual Linker Nuxt**
2
+
3
+ ![Visual Linker Nuxt](https://github.com/macrulezru/assets/blob/master/packages-images/visual-linker-nuxt-vuecraft.png?raw=true)
4
+
5
+ Nuxt module wrapping
6
+ [`@macrulez/visual-linker-vue`](https://www.npmjs.com/package/@macrulez/visual-linker-vue):
7
+ auto-imported `<VisualLinker>`/`useVisualLinker`, and a client-only plugin
8
+ that seeds their shared option defaults from your `nuxt.config.ts` — no
9
+ manual `<ClientOnly>` wrapping needed, both are already SSR-safe on their
10
+ own.
11
+
12
+ Part of the [visual-linker](https://github.com/macrulezru/visual-linker)
13
+ monorepo.
14
+
15
+ ---
16
+
17
+ ## Features
18
+
19
+ - **Auto-imports `<VisualLinker>` and `useVisualLinker`** — registered/imported from `@macrulez/visual-linker-vue`, no explicit `import` anywhere in your app
20
+ - **Module options forwarded through `runtimeConfig`** — `defaultCurve`, `showPorts`, curve-geometry and port/marker-size knobs, `dragGridSize` — set once in `nuxt.config.ts`, applied everywhere
21
+ - **A client-only plugin seeds those defaults** — reads the runtime config and calls `setVisualLinkerDefaults(...)` once, on the client
22
+ - **Nothing needs `<ClientOnly>`** — the component/composable are SSR-safe on their own; this module's client-only-ness is only about _when_ the defaults get applied
23
+
24
+ ---
25
+
26
+ ## When you'd reach for this
27
+
28
+ You're already on Nuxt and want `<VisualLinker>`/`useVisualLinker` wired
29
+ up with zero manual setup — auto-imports, and one place to configure
30
+ curve/port defaults instead of passing the same `options` at every call
31
+ site.
32
+
33
+ - **Passing the same `options` to every `<VisualLinker>` on the page gets old** — Set `defaultCurve`/`showPorts`/etc. once in `nuxt.config.ts` and every instance that doesn't override them picks up your project's defaults automatically.
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.
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.
36
+
37
+ ---
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ npm install @macrulez/visual-linker-nuxt
43
+ ```
44
+
45
+ ```ts
46
+ // nuxt.config.ts
47
+ export default defineNuxtConfig({
48
+ modules: ['@macrulez/visual-linker-nuxt'],
49
+ visualLinker: {
50
+ defaultCurve: 'smoothstep',
51
+ showPorts: true,
52
+ },
53
+ })
54
+ ```
55
+
56
+ Requires Nuxt `^3.9.0 || ^4.0.0`.
57
+
58
+ ### Quick start
59
+
60
+ Once the module is registered, just use the component — no imports:
61
+
62
+ ```vue
63
+ <template>
64
+ <VisualLinker :blocks="blocks" :connections="connections">
65
+ <template v-for="b in blocks" #[`block-${b.id}`]="{}" :key="b.id">
66
+ <div class="card">{{ b.id }}</div>
67
+ </template>
68
+ </VisualLinker>
69
+ </template>
70
+ ```
71
+
72
+ See
73
+ [`@macrulez/visual-linker-vue`'s README](https://www.npmjs.com/package/@macrulez/visual-linker-vue)
74
+ for the full component/composable API.
75
+
76
+ ### More examples
77
+
78
+ #### What the module does
79
+
80
+ 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.
81
+ 2. **Forwards module options** into `runtimeConfig.public.visualLinker`.
82
+ 3. **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.
83
+
84
+ No `defaults` are hardcoded in the module itself — a field left unset in
85
+ `nuxt.config.ts` falls all the way through to
86
+ `@macrulez/visual-linker-core`'s own built-in default, so a future change
87
+ to core's default is never silently shadowed by this module.
88
+
89
+ #### Module options
90
+
91
+ | Option | Mirrors | |
92
+ | ------------------------------------------------------------------------------------------- | -------------------------------------- | ---------------------------------------- |
93
+ | `defaultCurve` | `VisualLinkerOptions.defaultCurve` | `'bezier' \| 'straight' \| 'smoothstep'` |
94
+ | `showPorts` | `VisualLinkerOptions.showPorts` | |
95
+ | `curvature` / `curveMinReach` / `curveMaxReach` / `curveAngleBlend` / `curveAngleMaxOffset` | matching `defaultCurveXxx` fields | bezier geometry |
96
+ | `dragGridSize` | `VisualLinkerOptions.dragGridSize` | |
97
+ | `portRadius` / `portColor` / `portStrokeColor` / `portStrokeWidth` | matching `defaultPortXxx` fields | built-in port dot look |
98
+ | `circleMarkerSize` / `squareMarkerSize` / `diamondMarkerSize` / `arrowMarkerSize` | matching `defaultXxxMarkerSize` fields | |
99
+
100
+ **Not covered by module options** (set these directly on
101
+ `<VisualLinker :options="...">`/`useVisualLinker()` instead):
102
+ `defaultCornerRadius`, `defaultMaxTrunkReach`, `draggable`, `dragBounds`.
103
+
104
+ #### Setting an app-wide curve default
105
+
106
+ ```ts
107
+ // nuxt.config.ts
108
+ export default defineNuxtConfig({
109
+ modules: ['@macrulez/visual-linker-nuxt'],
110
+ visualLinker: {
111
+ defaultCurve: 'smoothstep',
112
+ dragGridSize: 20,
113
+ },
114
+ })
115
+ ```
116
+
117
+ Every `<VisualLinker>`/`useVisualLinker()` call in the app now defaults
118
+ to orthogonal routing and a 20px drag grid, unless a call site passes its
119
+ own `options.defaultCurve`/`dragGridSize` to override it.
120
+
121
+ ---
122
+
123
+ ## Documentation & links
124
+
125
+ - 📖 **Full documentation:** [npm.vuecraft.ru/en/packages/visual-linker](https://npm.vuecraft.ru/en/packages/visual-linker/guide/nuxt-module.html)
126
+ - 🌐 **VueCraft:** [vuecraft.ru/en](https://vuecraft.ru/en)
127
+ - 👤 **Author:** [macrulez.ru/en](https://macrulez.ru/en)
128
+ - 💻 **GitHub:** [macrulezru/visual-linker/packages/nuxt](https://github.com/macrulezru/visual-linker/tree/master/packages/nuxt)
129
+ - 📦 **NPM:** [@macrulez/visual-linker-nuxt](https://www.npmjs.com/package/@macrulez/visual-linker-nuxt)
130
+ - 🐛 **Issues:** [github.com/macrulezru/visual-linker/issues](https://github.com/macrulezru/visual-linker/issues)
131
+
132
+ ---
133
+
134
+ ## License
135
+
136
+ MIT
137
+
138
+ ---
139
+
140
+ ## 💖 Support the project
141
+
142
+ Open source takes time and effort. If this library saves you time or brings value, consider supporting further development.
143
+
144
+ <a href="https://donate.cryptocloud.plus/M6O34NIN" target="_blank">
145
+ <img src="https://img.shields.io/badge/Donate-CryptoCloud-8A2BE2?style=for-the-badge&logo=cryptocurrency&logoColor=white" alt="Donate via CryptoCloud">
146
+ </a>
147
+
148
+ Thank you for being part of this journey. ❤️
@@ -0,0 +1,29 @@
1
+ import { NuxtModule } from '@nuxt/schema';
2
+ import { ConnectionCurve } from '@macrulez/visual-linker-vue';
3
+
4
+ interface ModuleOptions {
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
+ }
27
+ declare const visualLinkerModule: NuxtModule<ModuleOptions>;
28
+
29
+ export { type ModuleOptions, visualLinkerModule as default };
package/dist/module.js ADDED
@@ -0,0 +1,42 @@
1
+ // src/module.ts
2
+ import { addComponent, addImports, addPlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
3
+ var visualLinkerModule = defineNuxtModule({
4
+ meta: {
5
+ name: "@macrulez/visual-linker-nuxt",
6
+ configKey: "visualLinker"
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
+ setup(options, nuxt) {
14
+ const resolver = createResolver(import.meta.url);
15
+ addComponent({ name: "VisualLinker", export: "VisualLinker", filePath: "@macrulez/visual-linker-vue" });
16
+ 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
+ };
35
+ addPlugin(resolver.resolve("./runtime/plugin.client"));
36
+ }
37
+ });
38
+ var module_default = visualLinkerModule;
39
+ export {
40
+ module_default as default
41
+ };
42
+ //# sourceMappingURL=module.js.map
@@ -0,0 +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 { ConnectionCurve } from '@macrulez/visual-linker-vue'\n\nexport interface ModuleOptions {\n /** Falls through to @macrulez/visual-linker-core's own default (VLConnectionCurveEnum.BEZIER) when unset. */\n defaultCurve?: ConnectionCurve\n /** Falls through to @macrulez/visual-linker-core's own default (true) when unset. */\n showPorts?: boolean\n curvature?: number\n curveMinReach?: number\n curveMaxReach?: number\n curveAngleBlend?: number\n curveAngleMaxOffset?: number\n /** Snaps every draggable block to this px grid while dragging. Falls through to no snapping when unset. */\n dragGridSize?: number\n /** Instance-wide look for the built-in port dot — falls through to @macrulez/visual-linker-core's own defaults (params.ts) when unset. */\n portRadius?: number\n portColor?: string\n portStrokeColor?: string\n portStrokeWidth?: number\n /** Instance-wide default marker size per built-in shape — falls through to @macrulez/visual-linker-core's own defaults (params.ts) when unset. */\n circleMarkerSize?: number\n squareMarkerSize?: number\n diamondMarkerSize?: number\n arrowMarkerSize?: number\n}\n\nconst visualLinkerModule: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({\n meta: {\n name: '@macrulez/visual-linker-nuxt',\n configKey: 'visualLinker',\n },\n // No `defaults` here on purpose: an option the user didn't set in\n // nuxt.config.ts must stay `undefined` all the way through to\n // @macrulez/visual-linker-core's own defaults (params.ts) — hardcoding one\n // here would silently shadow it, making a change to core's default look\n // like it does nothing for a Nuxt consumer.\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 = {\n defaultCurve: options.defaultCurve,\n showPorts: options.showPorts,\n defaultCurvature: options.curvature,\n defaultCurveMinReach: options.curveMinReach,\n defaultCurveMaxReach: options.curveMaxReach,\n defaultCurveAngleBlend: options.curveAngleBlend,\n defaultCurveAngleMaxOffset: options.curveAngleMaxOffset,\n dragGridSize: options.dragGridSize,\n defaultPortRadius: options.portRadius,\n defaultPortColor: options.portColor,\n defaultPortStrokeColor: options.portStrokeColor,\n defaultPortStrokeWidth: options.portStrokeWidth,\n defaultCircleMarkerSize: options.circleMarkerSize,\n defaultSquareMarkerSize: options.squareMarkerSize,\n defaultDiamondMarkerSize: options.diamondMarkerSize,\n defaultArrowMarkerSize: options.arrowMarkerSize,\n }\n\n // Applies module options on the client only — <VisualLinker>/useVisualLinker\n // are already SSR-safe no-ops, this just seeds their shared client-side defaults.\n addPlugin(resolver.resolve('./runtime/plugin.client'))\n },\n})\n\nexport default visualLinkerModule\n"],"mappings":";AAAA,SAAS,cAAc,YAAY,WAAW,gBAAgB,wBAAwB;AA4BtF,IAAM,qBAAgD,iBAAgC;AAAA,EACpF,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,WAAW;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,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;AAAA,MAC/C,cAAc,QAAQ;AAAA,MACtB,WAAW,QAAQ;AAAA,MACnB,kBAAkB,QAAQ;AAAA,MAC1B,sBAAsB,QAAQ;AAAA,MAC9B,sBAAsB,QAAQ;AAAA,MAC9B,wBAAwB,QAAQ;AAAA,MAChC,4BAA4B,QAAQ;AAAA,MACpC,cAAc,QAAQ;AAAA,MACtB,mBAAmB,QAAQ;AAAA,MAC3B,kBAAkB,QAAQ;AAAA,MAC1B,wBAAwB,QAAQ;AAAA,MAChC,wBAAwB,QAAQ;AAAA,MAChC,yBAAyB,QAAQ;AAAA,MACjC,yBAAyB,QAAQ;AAAA,MACjC,0BAA0B,QAAQ;AAAA,MAClC,wBAAwB,QAAQ;AAAA,IAClC;AAIA,cAAU,SAAS,QAAQ,yBAAyB,CAAC;AAAA,EACvD;AACF,CAAC;AAED,IAAO,iBAAQ;","names":[]}
@@ -0,0 +1,5 @@
1
+ import * as nuxt_app from 'nuxt/app';
2
+
3
+ declare const _default: nuxt_app.Plugin<Record<string, unknown>> & nuxt_app.ObjectPlugin<Record<string, unknown>>;
4
+
5
+ export { _default as default };
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
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":[]}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@macrulez/visual-linker-nuxt",
3
+ "version": "0.1.0",
4
+ "description": "Nuxt module wrapping @macrulez/visual-linker-vue: auto-imported <VisualLinker> and useVisualLinker, module options for default curve/port rendering",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "main": "./dist/module.js",
11
+ "module": "./dist/module.js",
12
+ "types": "./dist/module.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/module.d.ts",
16
+ "import": "./dist/module.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "sideEffects": false,
23
+ "peerDependencies": {
24
+ "nuxt": "^3.9.0 || ^4.0.0"
25
+ },
26
+ "dependencies": {
27
+ "@nuxt/kit": "^4.5.2",
28
+ "@macrulez/visual-linker-vue": "0.1.0"
29
+ },
30
+ "devDependencies": {
31
+ "@nuxt/schema": "^4.5.2",
32
+ "nuxt": "^4.5.2",
33
+ "tsup": "^8.3.5",
34
+ "typescript": "^5.6.3",
35
+ "vitest": "^2.1.8"
36
+ },
37
+ "scripts": {
38
+ "build": "tsup",
39
+ "dev": "tsup --watch",
40
+ "test": "vitest run",
41
+ "test:watch": "vitest",
42
+ "typecheck": "tsc --noEmit"
43
+ }
44
+ }