modern-canvas 0.18.2 → 0.18.3

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.
@@ -90,7 +90,7 @@ export declare class Element2D extends Node2D implements Rectangulable {
90
90
  protected _updateStyleProperty(key: string, value: any, oldValue: any): void;
91
91
  requestLayout(): void;
92
92
  protected _process(delta: number): void;
93
- protected _updateConnectionTransform(): void;
93
+ protected _updateConnection(): void;
94
94
  protected _updateStyleFilter(value?: string): void;
95
95
  protected _updateStyleMaskImage(value?: string): void;
96
96
  protected _getPointArray(): Vector2Like[];
@@ -1,4 +1,6 @@
1
- import type { NormalizedConnection } from 'modern-idoc';
1
+ import type { ConnectionMode, NormalizedConnection } from 'modern-idoc';
2
+ import type { Path2D } from 'modern-path2d';
3
+ import type { ConnectionEndpoint } from './connectionRouter';
2
4
  import type { Element2D } from './Element2D';
3
5
  import { Vector2 } from 'modern-path2d';
4
6
  import { CoreObject } from '../../../core';
@@ -6,6 +8,8 @@ export declare class Element2DConnection extends CoreObject implements Normalize
6
8
  protected _parent: Element2D;
7
9
  start: NormalizedConnection['start'];
8
10
  end: NormalizedConnection['end'];
11
+ /** Routing mode: `straight` | `orthogonal` | `curved` (normalized by modern-idoc). */
12
+ mode: ConnectionMode;
9
13
  constructor(_parent: Element2D);
10
14
  setProperties(properties?: Record<string, any>): this;
11
15
  isValid(): boolean;
@@ -16,4 +20,12 @@ export declare class Element2DConnection extends CoreObject implements Normalize
16
20
  * otherwise falls back to the target's globalAabb center.
17
21
  */
18
22
  resolveAnchor(anchor: NormalizedConnection['start']): Vector2 | undefined;
23
+ /**
24
+ * Resolve an anchor to a world-space point and outward direction.
25
+ * Direction comes from the connection point's `ang` if present, otherwise it is
26
+ * inferred from which edge the point sits on; a centre fallback has no direction.
27
+ */
28
+ resolveEndpoint(anchor: NormalizedConnection['start']): ConnectionEndpoint | undefined;
29
+ /** Resolve both ends and return the routed world-space path. */
30
+ route(): Path2D | undefined;
19
31
  }
@@ -1,6 +1,6 @@
1
1
  import type { NormalizedShape } from 'modern-idoc';
2
2
  import type { Element2D } from './Element2D';
3
- import { Path2DSet } from 'modern-path2d';
3
+ import { Path2D, Path2DSet } from 'modern-path2d';
4
4
  import { CoreObject } from '../../../core';
5
5
  export declare class Element2DShape extends CoreObject implements NormalizedShape {
6
6
  protected _parent: Element2D;
@@ -11,7 +11,16 @@ export declare class Element2DShape extends CoreObject implements NormalizedShap
11
11
  paths: NormalizedShape['paths'];
12
12
  connectionPoints: NormalizedShape['connectionPoints'];
13
13
  protected _path2DSet: Path2DSet;
14
+ /**
15
+ * A derived path in the element's local pixel space (NOT normalized to the unit
16
+ * box). Used by connections so the routed polyline is drawn 1:1 — going through
17
+ * the normalize→size scaling would distort the stroke width non-uniformly.
18
+ */
19
+ protected _localPath?: Path2D;
14
20
  constructor(_parent: Element2D);
21
+ /** Set/clear the local-space derived path (e.g. a connection route). */
22
+ setLocalPath(path: Path2D | undefined): void;
23
+ get localPath(): Path2D | undefined;
15
24
  setProperties(properties?: Record<string, any>): this;
16
25
  protected _updateProperty(key: string, value: any, oldValue: any): void;
17
26
  isValid(): boolean;
@@ -0,0 +1,21 @@
1
+ import type { ConnectionMode } from 'modern-idoc';
2
+ import type { Vector2Like } from 'modern-path2d';
3
+ import { Path2D } from 'modern-path2d';
4
+ export type { ConnectionMode };
5
+ export interface ConnectionEndpoint {
6
+ /** world-space anchor point */
7
+ point: Vector2Like;
8
+ /** outward unit direction the line leaves the anchor by; undefined = auto-infer */
9
+ dir?: Vector2Like;
10
+ }
11
+ export interface ConnectionRouteOptions {
12
+ /** perpendicular stub length the line leaves each anchor by (px) */
13
+ stub?: number;
14
+ }
15
+ /** Nearest axis-aligned unit vector for an arbitrary delta. */
16
+ export declare function axisDir(dx: number, dy: number): Vector2Like;
17
+ /**
18
+ * Build the world-space path that routes a connection from `start` to `end`
19
+ * under the given mode.
20
+ */
21
+ export declare function routeConnection(mode: ConnectionMode, start: ConnectionEndpoint, end: ConnectionEndpoint, options?: ConnectionRouteOptions): Path2D;
@@ -1,3 +1,4 @@
1
+ export * from './connectionRouter';
1
2
  export * from './Element2D';
2
3
  export * from './Element2DBackground';
3
4
  export * from './Element2DConnection';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.18.2",
4
+ "version": "0.18.3",
5
5
  "packageManager": "pnpm@10.19.0",
6
6
  "description": "A JavaScript WebGL rendering engine. only the ESM.",
7
7
  "author": "wxm",
@@ -63,9 +63,9 @@
63
63
  "colord": "^2.9.3",
64
64
  "earcut": "^3.0.2",
65
65
  "modern-font": "^0.5.0",
66
- "modern-idoc": "^0.11.4",
66
+ "modern-idoc": "^0.11.5",
67
67
  "modern-path2d": "^1.6.0",
68
- "modern-text": "^1.11.1"
68
+ "modern-text": "^1.12.0"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "lottie-web": "^5",
@@ -86,7 +86,7 @@
86
86
  "devDependencies": {
87
87
  "@antfu/eslint-config": "^9.0.0",
88
88
  "@types/earcut": "^3.0.0",
89
- "@types/node": "^25.9.0",
89
+ "@types/node": "^25.9.1",
90
90
  "bumpp": "^11.1.0",
91
91
  "conventional-changelog-cli": "^5.0.0",
92
92
  "eslint": "^10.4.0",
@@ -95,7 +95,7 @@
95
95
  "typescript": "^6.0.3",
96
96
  "unbuild": "^3.6.1",
97
97
  "vite": "^8.0.13",
98
- "vitest": "^4.1.6",
98
+ "vitest": "^4.1.7",
99
99
  "yoga-layout": "^3.2.1"
100
100
  }
101
101
  }