@macrulez/visual-linker-nuxt 0.1.0 → 0.2.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 CHANGED
@@ -17,6 +17,7 @@ monorepo.
17
17
  ## Features
18
18
 
19
19
  - **Auto-imports `<VisualLinker>` and `useVisualLinker`** — registered/imported from `@macrulez/visual-linker-vue`, no explicit `import` anywhere in your app
20
+ - **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
20
21
  - **Module options forwarded through `runtimeConfig`** — `defaultCurve`, `showPorts`, curve-geometry and port/marker-size knobs, `dragGridSize` — set once in `nuxt.config.ts`, applied everywhere
21
22
  - **A client-only plugin seeds those defaults** — reads the runtime config and calls `setVisualLinkerDefaults(...)` once, on the client
22
23
  - **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
@@ -61,10 +62,8 @@ Once the module is registered, just use the component — no imports:
61
62
 
62
63
  ```vue
63
64
  <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>
65
+ <VisualLinker :connections="connections">
66
+ <div v-for="b in blocks" :key="b.id" v-vl-block="b.id" class="card">{{ b.id }}</div>
68
67
  </VisualLinker>
69
68
  </template>
70
69
  ```
@@ -79,7 +78,8 @@ for the full component/composable API.
79
78
 
80
79
  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
80
  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.
81
+ 3. **Registers the `v-vl-block` / `v-vl-port` directives** in a universal plugin (`runtime/plugin.ts`) — on the server too, so the `data-vl-*` attributes are already in the SSR markup.
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.
83
83
 
84
84
  No `defaults` are hardcoded in the module itself — a field left unset in
85
85
  `nuxt.config.ts` falls all the way through to
package/dist/module.js CHANGED
@@ -32,6 +32,7 @@ var visualLinkerModule = defineNuxtModule({
32
32
  defaultDiamondMarkerSize: options.diamondMarkerSize,
33
33
  defaultArrowMarkerSize: options.arrowMarkerSize
34
34
  };
35
+ addPlugin(resolver.resolve("./runtime/plugin"));
35
36
  addPlugin(resolver.resolve("./runtime/plugin.client"));
36
37
  }
37
38
  });
@@ -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 { 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":[]}
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 // Registers v-vl-block / v-vl-port on both server and client.\n addPlugin(resolver.resolve('./runtime/plugin'))\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;AAGA,cAAU,SAAS,QAAQ,kBAAkB,CAAC;AAG9C,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.ts
2
+ import { vVlBlock, vVlPort } from "@macrulez/visual-linker-vue";
3
+ import { defineNuxtPlugin } from "nuxt/app";
4
+ var plugin_default = defineNuxtPlugin((nuxtApp) => {
5
+ nuxtApp.vueApp.directive("vl-block", vVlBlock);
6
+ nuxtApp.vueApp.directive("vl-port", vVlPort);
7
+ });
8
+ export {
9
+ plugin_default as default
10
+ };
11
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/runtime/plugin.ts"],"sourcesContent":["import { vVlBlock, vVlPort } from '@macrulez/visual-linker-vue'\nimport { defineNuxtPlugin } from 'nuxt/app'\n\n// Universal (not client-only): the directives' getSSRProps put the\n// data-vl-* discovery attributes straight into server-rendered markup.\nexport default defineNuxtPlugin((nuxtApp) => {\n nuxtApp.vueApp.directive('vl-block', vVlBlock)\n nuxtApp.vueApp.directive('vl-port', vVlPort)\n})\n"],"mappings":";AAAA,SAAS,UAAU,eAAe;AAClC,SAAS,wBAAwB;AAIjC,IAAO,iBAAQ,iBAAiB,CAAC,YAAY;AAC3C,UAAQ,OAAO,UAAU,YAAY,QAAQ;AAC7C,UAAQ,OAAO,UAAU,WAAW,OAAO;AAC7C,CAAC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@macrulez/visual-linker-nuxt",
3
- "version": "0.1.0",
3
+ "version": "0.2.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.1.0"
28
+ "@macrulez/visual-linker-vue": "0.2.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@nuxt/schema": "^4.5.2",