@haikal-fikri/archimate 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 +21 -0
- package/README.md +92 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +1368 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Haikal Fikri
|
|
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,92 @@
|
|
|
1
|
+
# @haikal-fikri/archimate
|
|
2
|
+
|
|
3
|
+
ArchiMate Open Exchange XML viewer for React — parser plus SVG renderer with full ArchiMate 3.2 notation. Read-only, stateless, dependency-light.
|
|
4
|
+
|
|
5
|
+
Supports both ArchiMate **3.0** and **2.1** Open Exchange XML.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @haikal-fikri/archimate react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`react` is a peer dependency (`^18 || ^19`).
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { parseArchimate, ArchimateRenderer } from '@haikal-fikri/archimate'
|
|
19
|
+
|
|
20
|
+
const xml = await fetch('/archisurance.xml').then((r) => r.text())
|
|
21
|
+
const view = parseArchimate(xml) // first view in the model
|
|
22
|
+
|
|
23
|
+
return <ArchimateRenderer view={view} style={{ width: '100%', height: 600 }} />
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
To render a specific view by identifier:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
const view = parseArchimate(xml, 'id-4056')
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- **Open Exchange XML 2.1 + 3.0** — namespace-tolerant parser, handles British/American spelling differences, `Infrastructure*` → `Technology*` rename, both `<views><view>` and `<views><diagrams><view>` layouts
|
|
35
|
+
- **Full element notation** — rounded rects, stadiums (Service), junctions, motivation chamfers, plus per-type icon glyphs (Actor, Process, Component, Service, Node, Device, etc.)
|
|
36
|
+
- **All relationship arrowheads** — Composition (filled diamond), Aggregation (hollow diamond), Realization (dashed + hollow triangle), Specialization (solid + hollow triangle), Triggering, Flow, Serving, Used-By, Influence, Access (with Read/Write/ReadWrite), Assignment
|
|
37
|
+
- **Smart edge routing** — orthogonal snap when boxes share an axis, rectangle-edge intersection on diagonals, automatic distribution of multiple edges sharing the same node side
|
|
38
|
+
- **Word-wrapped labels** — automatic multi-line tspan wrapping into the available width
|
|
39
|
+
- **Pan + zoom** — drag to pan, wheel/pinch to zoom; programmatic `fit()` / `reset()` via ref handle
|
|
40
|
+
- **Inline marker glyphs** — markers rendered as transformed siblings, not via `<marker>`, so dashed lines never bleed into arrowhead outlines
|
|
41
|
+
- **Layer-correct colors** — ArchiMate standard yellow / blue / green / lavender / orange palette built in
|
|
42
|
+
|
|
43
|
+
## API
|
|
44
|
+
|
|
45
|
+
### `parseArchimate(xml: string, viewId?: string): ParsedView`
|
|
46
|
+
|
|
47
|
+
Parses Open Exchange XML and returns one view's geometry. Throws `ArchimateParseError` (with `kind`) on:
|
|
48
|
+
|
|
49
|
+
- `'invalid-xml'` — malformed XML
|
|
50
|
+
- `'wrong-format'` — namespace not Open Exchange (e.g. native `.archimate` file)
|
|
51
|
+
- `'no-views'` — model has no views
|
|
52
|
+
- `'view-not-found'` — `viewId` doesn't match any view
|
|
53
|
+
|
|
54
|
+
If `viewId` is omitted, returns the first view.
|
|
55
|
+
|
|
56
|
+
### `<ArchimateRenderer view={view} ... />`
|
|
57
|
+
|
|
58
|
+
Props:
|
|
59
|
+
|
|
60
|
+
- `view: ParsedView` — required
|
|
61
|
+
- `className?: string`
|
|
62
|
+
- `style?: CSSProperties`
|
|
63
|
+
|
|
64
|
+
The component sizes itself via the consumer's CSS — set `width` / `height` on the SVG (or its container) to whatever fits your layout. The diagram's aspect ratio is preserved automatically.
|
|
65
|
+
|
|
66
|
+
`forwardRef` exposes `ArchimateRendererHandle` for programmatic control:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
type ArchimateRendererHandle = {
|
|
70
|
+
zoomIn: () => void
|
|
71
|
+
zoomOut: () => void
|
|
72
|
+
fitView: () => void
|
|
73
|
+
pan: (dirX: number, dirY: number) => void
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Other exports
|
|
78
|
+
|
|
79
|
+
- `LAYER_COLORS`, `colorForType(elementType)` — the color palette
|
|
80
|
+
- `ICONS`, `iconNameForType(elementType)` — icon glyph map
|
|
81
|
+
- Types: `ParsedView`, `NodeBox`, `Edge`, `Point`, `AccessType`, `IconDef`
|
|
82
|
+
|
|
83
|
+
## What's not supported (yet)
|
|
84
|
+
|
|
85
|
+
- Editing — read-only viewer
|
|
86
|
+
- Native `.archimate` files — only the standard Open Exchange XML format
|
|
87
|
+
- Influence relationship `+` / `-` modifier labels
|
|
88
|
+
- Real-time updates / collaborative editing
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
|
|
4
|
+
type RGB = string;
|
|
5
|
+
type NodeBox = {
|
|
6
|
+
id: string;
|
|
7
|
+
elementId?: string;
|
|
8
|
+
elementType?: string;
|
|
9
|
+
nodeType?: string;
|
|
10
|
+
isJunction: boolean;
|
|
11
|
+
label: string;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
w: number;
|
|
15
|
+
h: number;
|
|
16
|
+
fill: RGB;
|
|
17
|
+
stroke: RGB;
|
|
18
|
+
textColor: RGB;
|
|
19
|
+
fontFamily?: string;
|
|
20
|
+
fontSize?: number;
|
|
21
|
+
};
|
|
22
|
+
type Point = {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
};
|
|
26
|
+
type AccessType = 'Access' | 'Read' | 'Write' | 'ReadWrite';
|
|
27
|
+
type Edge = {
|
|
28
|
+
id: string;
|
|
29
|
+
sourceId: string;
|
|
30
|
+
targetId: string;
|
|
31
|
+
relationshipType?: string;
|
|
32
|
+
accessType?: AccessType;
|
|
33
|
+
isDirected?: boolean;
|
|
34
|
+
name?: string;
|
|
35
|
+
bendpoints: Point[];
|
|
36
|
+
stroke?: RGB;
|
|
37
|
+
};
|
|
38
|
+
type ParsedView = {
|
|
39
|
+
viewId: string;
|
|
40
|
+
viewName: string;
|
|
41
|
+
viewBox: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
};
|
|
47
|
+
nodes: NodeBox[];
|
|
48
|
+
connections: Edge[];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type ArchimateParseErrorKind = 'invalid-xml' | 'wrong-format' | 'no-views' | 'view-not-found';
|
|
52
|
+
declare class ArchimateParseError extends Error {
|
|
53
|
+
readonly kind: ArchimateParseErrorKind;
|
|
54
|
+
constructor(message: string, kind: ArchimateParseErrorKind);
|
|
55
|
+
}
|
|
56
|
+
declare function parseArchimate(xml: string, viewId?: string): ParsedView;
|
|
57
|
+
|
|
58
|
+
type ArchimateRendererHandle = {
|
|
59
|
+
zoomIn: () => void;
|
|
60
|
+
zoomOut: () => void;
|
|
61
|
+
fitView: () => void;
|
|
62
|
+
pan: (dirX: number, dirY: number) => void;
|
|
63
|
+
};
|
|
64
|
+
type Props = {
|
|
65
|
+
view: ParsedView;
|
|
66
|
+
className?: string;
|
|
67
|
+
style?: CSSProperties;
|
|
68
|
+
};
|
|
69
|
+
declare const ArchimateRenderer: react.ForwardRefExoticComponent<Props & react.RefAttributes<ArchimateRendererHandle>>;
|
|
70
|
+
|
|
71
|
+
declare const LAYER_COLORS: Record<string, string>;
|
|
72
|
+
declare function colorForType(elementType?: string): string;
|
|
73
|
+
|
|
74
|
+
type IconDef = {
|
|
75
|
+
/** Path data strings in the 0..100 local coord system. Stroked, not filled. */
|
|
76
|
+
outline?: string[];
|
|
77
|
+
/** Path data strings drawn filled with currentColor (no stroke). */
|
|
78
|
+
filled?: string[];
|
|
79
|
+
};
|
|
80
|
+
declare const ICONS: Record<string, IconDef>;
|
|
81
|
+
declare function iconNameForType(elementType?: string): string | null;
|
|
82
|
+
|
|
83
|
+
export { type AccessType, ArchimateParseError, type ArchimateParseErrorKind, ArchimateRenderer, type ArchimateRendererHandle, type Edge, ICONS, type IconDef, LAYER_COLORS, type NodeBox, type ParsedView, type Point, colorForType, iconNameForType, parseArchimate };
|