@cda/adapter-xma 0.4.3 → 0.6.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 +54 -20
- package/dist/cjs/diagnostics/diagnostics.d.ts.map +1 -0
- package/dist/cjs/diagnostics/diagnostics.js +23 -0
- package/dist/cjs/diagnostics/diagnostics.js.map +1 -0
- package/dist/cjs/diagnostics/errors.d.ts.map +1 -0
- package/dist/cjs/diagnostics/errors.js +24 -0
- package/dist/cjs/diagnostics/errors.js.map +1 -0
- package/dist/cjs/geometry/bendpoints.d.ts.map +1 -0
- package/dist/cjs/geometry/bendpoints.js +51 -0
- package/dist/cjs/geometry/bendpoints.js.map +1 -0
- package/dist/cjs/geometry/geometry.d.ts +75 -0
- package/dist/cjs/geometry/geometry.d.ts.map +1 -0
- package/dist/cjs/geometry/geometry.js +77 -0
- package/dist/cjs/geometry/geometry.js.map +1 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/infrastructure/assert.d.ts +10 -0
- package/dist/cjs/infrastructure/assert.d.ts.map +1 -0
- package/dist/cjs/infrastructure/assert.js +18 -0
- package/dist/cjs/infrastructure/assert.js.map +1 -0
- package/dist/cjs/infrastructure/id-allocator.d.ts.map +1 -0
- package/dist/cjs/infrastructure/id-allocator.js +59 -0
- package/dist/cjs/infrastructure/id-allocator.js.map +1 -0
- package/dist/cjs/infrastructure/xml-writer.d.ts.map +1 -0
- package/dist/cjs/infrastructure/xml-writer.js +94 -0
- package/dist/cjs/infrastructure/xml-writer.js.map +1 -0
- package/dist/cjs/mapping/element-mapping.d.ts.map +1 -0
- package/dist/cjs/mapping/element-mapping.js +117 -0
- package/dist/cjs/mapping/element-mapping.js.map +1 -0
- package/dist/cjs/mapping/generic-relationship-mapping.d.ts.map +1 -0
- package/dist/cjs/mapping/generic-relationship-mapping.js +71 -0
- package/dist/cjs/mapping/generic-relationship-mapping.js.map +1 -0
- package/dist/cjs/mapping/relationship-mapping.d.ts.map +1 -0
- package/dist/cjs/mapping/relationship-mapping.js +697 -0
- package/dist/cjs/mapping/relationship-mapping.js.map +1 -0
- package/dist/cjs/mapping/scheme-mapping.d.ts.map +1 -0
- package/dist/cjs/mapping/scheme-mapping.js +42 -0
- package/dist/cjs/mapping/scheme-mapping.js.map +1 -0
- package/dist/{mapping → cjs/mapping}/visual-mapping.d.ts +8 -0
- package/dist/cjs/mapping/visual-mapping.d.ts.map +1 -0
- package/dist/cjs/mapping/visual-mapping.js +51 -0
- package/dist/cjs/mapping/visual-mapping.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/serializer/document-writer.d.ts.map +1 -0
- package/dist/cjs/serializer/document-writer.js +143 -0
- package/dist/cjs/serializer/document-writer.js.map +1 -0
- package/dist/{serializer → cjs/serializer}/graphical-writer.d.ts +8 -6
- package/dist/cjs/serializer/graphical-writer.d.ts.map +1 -0
- package/dist/cjs/serializer/graphical-writer.js +521 -0
- package/dist/cjs/serializer/graphical-writer.js.map +1 -0
- package/dist/cjs/serializer/profile-values.d.ts.map +1 -0
- package/dist/cjs/serializer/profile-values.js +28 -0
- package/dist/cjs/serializer/profile-values.js.map +1 -0
- package/dist/cjs/serializer/relationship-writer.d.ts.map +1 -0
- package/dist/cjs/serializer/relationship-writer.js +109 -0
- package/dist/cjs/serializer/relationship-writer.js.map +1 -0
- package/dist/cjs/serializer/rtf.d.ts.map +1 -0
- package/dist/cjs/serializer/rtf.js +67 -0
- package/dist/cjs/serializer/rtf.js.map +1 -0
- package/dist/cjs/serializer/semantic-writer.d.ts.map +1 -0
- package/dist/cjs/serializer/semantic-writer.js +170 -0
- package/dist/cjs/serializer/semantic-writer.js.map +1 -0
- package/dist/cjs/serializer/serialize-xma.d.ts.map +1 -0
- package/dist/cjs/serializer/serialize-xma.js +113 -0
- package/dist/cjs/serializer/serialize-xma.js.map +1 -0
- package/dist/{serializer → cjs/serializer}/view-writer.d.ts +6 -0
- package/dist/cjs/serializer/view-writer.d.ts.map +1 -0
- package/dist/cjs/serializer/view-writer.js +239 -0
- package/dist/cjs/serializer/view-writer.js.map +1 -0
- package/dist/esm/diagnostics/diagnostics.d.ts +20 -0
- package/dist/esm/diagnostics/diagnostics.d.ts.map +1 -0
- package/dist/esm/diagnostics/diagnostics.js.map +1 -0
- package/dist/esm/diagnostics/errors.d.ts +13 -0
- package/dist/esm/diagnostics/errors.d.ts.map +1 -0
- package/dist/esm/diagnostics/errors.js.map +1 -0
- package/dist/esm/geometry/bendpoints.d.ts +33 -0
- package/dist/esm/geometry/bendpoints.d.ts.map +1 -0
- package/dist/{geometry → esm/geometry}/bendpoints.js +6 -2
- package/dist/esm/geometry/bendpoints.js.map +1 -0
- package/dist/esm/geometry/geometry.d.ts +75 -0
- package/dist/esm/geometry/geometry.d.ts.map +1 -0
- package/dist/{geometry → esm/geometry}/geometry.js +25 -6
- package/dist/esm/geometry/geometry.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/infrastructure/assert.d.ts +10 -0
- package/dist/esm/infrastructure/assert.d.ts.map +1 -0
- package/dist/esm/infrastructure/assert.js +15 -0
- package/dist/esm/infrastructure/assert.js.map +1 -0
- package/dist/esm/infrastructure/id-allocator.d.ts +34 -0
- package/dist/esm/infrastructure/id-allocator.d.ts.map +1 -0
- package/dist/esm/infrastructure/id-allocator.js.map +1 -0
- package/dist/esm/infrastructure/xml-writer.d.ts +20 -0
- package/dist/esm/infrastructure/xml-writer.d.ts.map +1 -0
- package/dist/{infrastructure → esm/infrastructure}/xml-writer.js +37 -2
- package/dist/esm/infrastructure/xml-writer.js.map +1 -0
- package/dist/esm/mapping/element-mapping.d.ts +31 -0
- package/dist/esm/mapping/element-mapping.d.ts.map +1 -0
- package/dist/esm/mapping/element-mapping.js.map +1 -0
- package/dist/esm/mapping/generic-relationship-mapping.d.ts +18 -0
- package/dist/esm/mapping/generic-relationship-mapping.d.ts.map +1 -0
- package/dist/esm/mapping/generic-relationship-mapping.js.map +1 -0
- package/dist/esm/mapping/relationship-mapping.d.ts +47 -0
- package/dist/esm/mapping/relationship-mapping.d.ts.map +1 -0
- package/dist/esm/mapping/relationship-mapping.js.map +1 -0
- package/dist/esm/mapping/scheme-mapping.d.ts +38 -0
- package/dist/esm/mapping/scheme-mapping.d.ts.map +1 -0
- package/dist/esm/mapping/scheme-mapping.js.map +1 -0
- package/dist/esm/mapping/visual-mapping.d.ts +32 -0
- package/dist/esm/mapping/visual-mapping.d.ts.map +1 -0
- package/dist/{mapping → esm/mapping}/visual-mapping.js +8 -0
- package/dist/esm/mapping/visual-mapping.js.map +1 -0
- package/dist/esm/serializer/document-writer.d.ts +40 -0
- package/dist/esm/serializer/document-writer.d.ts.map +1 -0
- package/dist/{serializer → esm/serializer}/document-writer.js +5 -0
- package/dist/esm/serializer/document-writer.js.map +1 -0
- package/dist/esm/serializer/graphical-writer.d.ts +29 -0
- package/dist/esm/serializer/graphical-writer.d.ts.map +1 -0
- package/dist/{serializer → esm/serializer}/graphical-writer.js +213 -54
- package/dist/esm/serializer/graphical-writer.js.map +1 -0
- package/dist/esm/serializer/profile-values.d.ts +8 -0
- package/dist/esm/serializer/profile-values.d.ts.map +1 -0
- package/dist/esm/serializer/profile-values.js.map +1 -0
- package/dist/esm/serializer/relationship-writer.d.ts +41 -0
- package/dist/esm/serializer/relationship-writer.d.ts.map +1 -0
- package/dist/{serializer → esm/serializer}/relationship-writer.js +4 -1
- package/dist/esm/serializer/relationship-writer.js.map +1 -0
- package/dist/esm/serializer/rtf.d.ts +9 -0
- package/dist/esm/serializer/rtf.d.ts.map +1 -0
- package/dist/{serializer → esm/serializer}/rtf.js +14 -0
- package/dist/esm/serializer/rtf.js.map +1 -0
- package/dist/esm/serializer/semantic-writer.d.ts +51 -0
- package/dist/esm/serializer/semantic-writer.d.ts.map +1 -0
- package/dist/{serializer → esm/serializer}/semantic-writer.js +24 -0
- package/dist/esm/serializer/semantic-writer.js.map +1 -0
- package/dist/esm/serializer/serialize-xma.d.ts +29 -0
- package/dist/esm/serializer/serialize-xma.d.ts.map +1 -0
- package/dist/{serializer → esm/serializer}/serialize-xma.js +40 -1
- package/dist/esm/serializer/serialize-xma.js.map +1 -0
- package/dist/esm/serializer/view-writer.d.ts +33 -0
- package/dist/esm/serializer/view-writer.d.ts.map +1 -0
- package/dist/esm/serializer/view-writer.js +236 -0
- package/dist/esm/serializer/view-writer.js.map +1 -0
- package/package.json +20 -9
- package/dist/diagnostics/diagnostics.d.ts.map +0 -1
- package/dist/diagnostics/diagnostics.js.map +0 -1
- package/dist/diagnostics/errors.d.ts.map +0 -1
- package/dist/diagnostics/errors.js.map +0 -1
- package/dist/geometry/bendpoints.d.ts.map +0 -1
- package/dist/geometry/bendpoints.js.map +0 -1
- package/dist/geometry/geometry.d.ts +0 -48
- package/dist/geometry/geometry.d.ts.map +0 -1
- package/dist/geometry/geometry.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/infrastructure/id-allocator.d.ts.map +0 -1
- package/dist/infrastructure/id-allocator.js.map +0 -1
- package/dist/infrastructure/xml-writer.d.ts.map +0 -1
- package/dist/infrastructure/xml-writer.js.map +0 -1
- package/dist/mapping/element-mapping.d.ts.map +0 -1
- package/dist/mapping/element-mapping.js.map +0 -1
- package/dist/mapping/generic-relationship-mapping.d.ts.map +0 -1
- package/dist/mapping/generic-relationship-mapping.js.map +0 -1
- package/dist/mapping/relationship-mapping.d.ts.map +0 -1
- package/dist/mapping/relationship-mapping.js.map +0 -1
- package/dist/mapping/scheme-mapping.d.ts.map +0 -1
- package/dist/mapping/scheme-mapping.js.map +0 -1
- package/dist/mapping/visual-mapping.d.ts.map +0 -1
- package/dist/mapping/visual-mapping.js.map +0 -1
- package/dist/serializer/document-writer.d.ts.map +0 -1
- package/dist/serializer/document-writer.js.map +0 -1
- package/dist/serializer/graphical-writer.d.ts.map +0 -1
- package/dist/serializer/graphical-writer.js.map +0 -1
- package/dist/serializer/profile-values.d.ts.map +0 -1
- package/dist/serializer/profile-values.js.map +0 -1
- package/dist/serializer/relationship-writer.d.ts.map +0 -1
- package/dist/serializer/relationship-writer.js.map +0 -1
- package/dist/serializer/rtf.d.ts.map +0 -1
- package/dist/serializer/rtf.js.map +0 -1
- package/dist/serializer/semantic-writer.d.ts.map +0 -1
- package/dist/serializer/semantic-writer.js.map +0 -1
- package/dist/serializer/serialize-xma.d.ts.map +0 -1
- package/dist/serializer/serialize-xma.js.map +0 -1
- package/dist/serializer/view-writer.d.ts.map +0 -1
- package/dist/serializer/view-writer.js +0 -145
- package/dist/serializer/view-writer.js.map +0 -1
- /package/dist/{diagnostics → cjs/diagnostics}/diagnostics.d.ts +0 -0
- /package/dist/{diagnostics → cjs/diagnostics}/errors.d.ts +0 -0
- /package/dist/{geometry → cjs/geometry}/bendpoints.d.ts +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{infrastructure → cjs/infrastructure}/id-allocator.d.ts +0 -0
- /package/dist/{infrastructure → cjs/infrastructure}/xml-writer.d.ts +0 -0
- /package/dist/{mapping → cjs/mapping}/element-mapping.d.ts +0 -0
- /package/dist/{mapping → cjs/mapping}/generic-relationship-mapping.d.ts +0 -0
- /package/dist/{mapping → cjs/mapping}/relationship-mapping.d.ts +0 -0
- /package/dist/{mapping → cjs/mapping}/scheme-mapping.d.ts +0 -0
- /package/dist/{serializer → cjs/serializer}/document-writer.d.ts +0 -0
- /package/dist/{serializer → cjs/serializer}/profile-values.d.ts +0 -0
- /package/dist/{serializer → cjs/serializer}/relationship-writer.d.ts +0 -0
- /package/dist/{serializer → cjs/serializer}/rtf.d.ts +0 -0
- /package/dist/{serializer → cjs/serializer}/semantic-writer.d.ts +0 -0
- /package/dist/{serializer → cjs/serializer}/serialize-xma.d.ts +0 -0
- /package/dist/{diagnostics → esm/diagnostics}/diagnostics.js +0 -0
- /package/dist/{diagnostics → esm/diagnostics}/errors.js +0 -0
- /package/dist/{index.js → esm/index.js} +0 -0
- /package/dist/{infrastructure → esm/infrastructure}/id-allocator.js +0 -0
- /package/dist/{mapping → esm/mapping}/element-mapping.js +0 -0
- /package/dist/{mapping → esm/mapping}/generic-relationship-mapping.js +0 -0
- /package/dist/{mapping → esm/mapping}/relationship-mapping.js +0 -0
- /package/dist/{mapping → esm/mapping}/scheme-mapping.js +0 -0
- /package/dist/{serializer → esm/serializer}/profile-values.js +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Continuous-Driven Architecture
|
|
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
CHANGED
|
@@ -59,9 +59,9 @@ unconfirmed relationship, more than one view, a diagram object missing
|
|
|
59
59
|
width/height, ...) it throws `XmaSerializationError` carrying a structured
|
|
60
60
|
diagnostic for every problem found, rather than silently dropping content or
|
|
61
61
|
fabricating an approximate result. Lower-severity findings (`warning`) don't
|
|
62
|
-
block serialization — e.g. an explicit
|
|
63
|
-
`DiagramModelReference`
|
|
64
|
-
|
|
62
|
+
block serialization — e.g. an explicit fill-opacity (`alpha`) override, or a
|
|
63
|
+
`DiagramModelReference` pointing outside this model's own ArchiMate views
|
|
64
|
+
(e.g. a Sketch/Canvas), which has no XMA representation.
|
|
65
65
|
|
|
66
66
|
To preview what is and isn't supported without throwing:
|
|
67
67
|
|
|
@@ -145,16 +145,46 @@ extrapolated beyond that evidence.
|
|
|
145
145
|
when its value is `0`, per the ArchiMate Exchange Format convention. Not
|
|
146
146
|
treated as incomplete geometry; JS's null-coerces-to-0 arithmetic applies
|
|
147
147
|
the default when scaling/centering. See `src/geometry/geometry.ts`.
|
|
148
|
-
- `DiagramModelReference` ("insert view as reference") nodes
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
`
|
|
148
|
+
- `DiagramModelReference` ("insert view as reference") nodes, when they
|
|
149
|
+
point at another ArchiMate view within the same model — drawn as an
|
|
150
|
+
`mm_concept="AllView"`/`mm_graphicType="3"` node whose semantic object
|
|
151
|
+
resolves, via an `ArchiMate:AllViewRef`, to the *referenced view's own*
|
|
152
|
+
`ArchiMate:AllView` (no new semantic concept is minted for the reference
|
|
153
|
+
itself). Confirmed byte-for-byte against both instances in the
|
|
154
|
+
agile-manifesto fixture, including their fixed fill/line color. A
|
|
155
|
+
reference to something outside this model's own views (e.g. a
|
|
156
|
+
Sketch/Canvas) has no XMA representation and is reported as a `warning`,
|
|
157
|
+
not a blocking error. See `src/serializer/view-writer.ts` and
|
|
158
|
+
`graphical-writer.ts`'s `buildViewReferenceNode`.
|
|
159
|
+
- **A purely-visual connection between two drawable objects (no underlying
|
|
160
|
+
ArchiMate relationship)** — represented as an `ArchiMate:ViewEdge`
|
|
161
|
+
(semantic layer) and an `mm_concept="ViewEdge"` `MM_DirectedRel`
|
|
162
|
+
(graphical layer). Confirmed against two independent real instances in
|
|
163
|
+
two different fixtures — agile-manifesto (between two
|
|
164
|
+
`DiagramModelReference`s) and sabsa (between a Note/Group and a
|
|
165
|
+
`BusinessRole` element) — that the `ViewEdge`'s `from`/`to` are exactly
|
|
166
|
+
each endpoint's own semantic id, the same value already used as that
|
|
167
|
+
endpoint's own node's `mm_semanticObject`. Requires
|
|
168
|
+
`@cda/archi-semantic-core >=0.4.3`, which stopped silently dropping a
|
|
169
|
+
`sourceConnection` with no `xsi:type` (some of these connections have
|
|
170
|
+
none); with an older parser version the connection simply never reaches
|
|
171
|
+
this library's input, so nothing breaks, the improvement just doesn't
|
|
172
|
+
apply. See `view-writer.ts`'s `resolveObjectSemanticId`.
|
|
153
173
|
- A configurable output language, applied consistently — never inferred
|
|
154
174
|
from element names.
|
|
155
175
|
- Direct, lossless mapping of explicit Archi `fillColor`/`lineColor`
|
|
156
176
|
(hex → RGB) and `fontName` overrides, where the source field maps onto
|
|
157
|
-
the exact same structural XMA slot
|
|
177
|
+
the exact same structural XMA slot — including a connection's own
|
|
178
|
+
`lineColor` override, applied to its `MM_DirectedRel` the same way.
|
|
179
|
+
- An explicit font-size override, via the confirmed `floor(pt) * 20`
|
|
180
|
+
formula (two independent data points in the agile-manifesto fixture:
|
|
181
|
+
11.25pt → `mm_fontSize="220"`, 14.25pt → `"280"`).
|
|
182
|
+
- **Multiple views sharing an element or relationship** each get their own
|
|
183
|
+
independent `RefObjects` entry — confirmed against the 38-view sabsa
|
|
184
|
+
fixture (840 `Ref` elements for 735 distinct semantic targets: a ref id
|
|
185
|
+
is never reused across two views). An earlier version deduplicated these
|
|
186
|
+
globally, which silently dropped `RefObjects` entries for every view
|
|
187
|
+
after the first that referenced an already-seen element.
|
|
158
188
|
|
|
159
189
|
### Not yet guaranteed
|
|
160
190
|
|
|
@@ -173,19 +203,18 @@ extrapolated beyond that evidence.
|
|
|
173
203
|
- A nested `ArchiNote` (as opposed to a nested `ArchiDiagramObject`, now
|
|
174
204
|
supported) — only one instance exists across all four fixtures, not
|
|
175
205
|
enough to confirm its representation.
|
|
176
|
-
- Purely visual (non-semantic) connections not touching a
|
|
177
|
-
`DiagramModelReference` — no fixture evidence either way (the one
|
|
178
|
-
purely-visual connection found, between two `DiagramModelReference`
|
|
179
|
-
nodes, isn't even parsed as a diagram connection by
|
|
180
|
-
`@cda/archi-semantic-core`, since it lacks an `xsi:type`).
|
|
181
206
|
- Profiles/specializations and arbitrary model properties.
|
|
182
|
-
- Explicit
|
|
183
|
-
|
|
184
|
-
|
|
207
|
+
- Explicit bold/italic, line width, font color, or fill opacity (`alpha`)
|
|
208
|
+
overrides (reported as diagnostics; the confirmed defaults are used
|
|
209
|
+
instead). `alpha` in particular has zero occurrences across all four
|
|
210
|
+
reference fixtures — no evidence to confirm a mapping, so it's diagnosed
|
|
211
|
+
like every other unconfirmed override rather than applied on a guess.
|
|
185
212
|
- Manual connector anchor metadata (`mm_fromx`/`mm_fromy`/`mm_tox`/`mm_toy`)
|
|
186
|
-
—
|
|
187
|
-
|
|
188
|
-
|
|
213
|
+
— present on a minority of connections in three of the four fixtures
|
|
214
|
+
(5/93 in agile-manifesto, 1/3 in relaciones, 15/346 in sabsa; catalogo has
|
|
215
|
+
no connections at all), never on all of them. Not enough evidence to tell
|
|
216
|
+
what distinguishes an anchored connection from the rest or to derive a
|
|
217
|
+
general formula, so they're deliberately omitted rather than guessed; see
|
|
189
218
|
`src/serializer/graphical-writer.ts`.
|
|
190
219
|
|
|
191
220
|
## Architecture
|
|
@@ -238,10 +267,15 @@ values are ever embedded).
|
|
|
238
267
|
```
|
|
239
268
|
npm install
|
|
240
269
|
npm run typecheck
|
|
270
|
+
npm run lint
|
|
241
271
|
npm run build
|
|
242
272
|
npm test
|
|
243
273
|
```
|
|
244
274
|
|
|
275
|
+
See [`CONTRIBUTING.md`](CONTRIBUTING.md) for this project's core rule
|
|
276
|
+
(every mapping is evidence-backed, never guessed) and how to trace a
|
|
277
|
+
change to fixture bytes.
|
|
278
|
+
|
|
245
279
|
## License
|
|
246
280
|
|
|
247
281
|
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/diagnostics.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,SAAS,CAAC;AAExD,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,qBAAqB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,uGAAuG;IACvG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,kEAAkE;AAClE,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;IAE7C,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,GAAG,IAAI;IAIxD,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,GAAG,IAAI;IAI1D,IAAI,GAAG,IAAI,aAAa,EAAE,CAEzB;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiagnosticCollector = void 0;
|
|
4
|
+
/** Accumulates diagnostics during a single serialization pass. */
|
|
5
|
+
class DiagnosticCollector {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.items = [];
|
|
8
|
+
}
|
|
9
|
+
error(diagnostic) {
|
|
10
|
+
this.items.push({ ...diagnostic, severity: 'error' });
|
|
11
|
+
}
|
|
12
|
+
warning(diagnostic) {
|
|
13
|
+
this.items.push({ ...diagnostic, severity: 'warning' });
|
|
14
|
+
}
|
|
15
|
+
get all() {
|
|
16
|
+
return [...this.items];
|
|
17
|
+
}
|
|
18
|
+
get hasErrors() {
|
|
19
|
+
return this.items.some((d) => d.severity === 'error');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.DiagnosticCollector = DiagnosticCollector;
|
|
23
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../../src/diagnostics/diagnostics.ts"],"names":[],"mappings":";;;AAaA,kEAAkE;AAClE,MAAa,mBAAmB;IAAhC;QACmB,UAAK,GAAoB,EAAE,CAAC;IAiB/C,CAAC;IAfC,KAAK,CAAC,UAA2C;QAC/C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,CAAC,UAA2C;QACjD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,GAAG;QACL,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;IACxD,CAAC;CACF;AAlBD,kDAkBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;;;GAMG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,WAAW,EAAE,aAAa,EAAE,CAAC;gBAE1B,WAAW,EAAE,aAAa,EAAE;CAYzC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XmaSerializationError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Thrown by `serializeXma` whenever serializing would silently lose
|
|
6
|
+
* semantics or presentation intent. Carries the full structured diagnostic
|
|
7
|
+
* list (not just the first failure) so callers can report everything wrong
|
|
8
|
+
* in one pass — see `inspectXmaSupport` to obtain the same list without
|
|
9
|
+
* throwing.
|
|
10
|
+
*/
|
|
11
|
+
class XmaSerializationError extends Error {
|
|
12
|
+
constructor(diagnostics) {
|
|
13
|
+
const errorCount = diagnostics.filter((d) => d.severity === 'error').length;
|
|
14
|
+
super(`XMA serialization failed: ${errorCount} unsupported construct(s) would cause semantic or presentation loss. ` +
|
|
15
|
+
diagnostics
|
|
16
|
+
.filter((d) => d.severity === 'error')
|
|
17
|
+
.map((d) => `[${d.code}] ${d.message}`)
|
|
18
|
+
.join('; '));
|
|
19
|
+
this.name = 'XmaSerializationError';
|
|
20
|
+
this.diagnostics = diagnostics;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.XmaSerializationError = XmaSerializationError;
|
|
24
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/diagnostics/errors.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,MAAa,qBAAsB,SAAQ,KAAK;IAG9C,YAAY,WAA4B;QACtC,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAA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 -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveBendpoint = resolveBendpoint;
|
|
4
|
+
const geometry_js_1 = require("./geometry.js");
|
|
5
|
+
const AGREEMENT_EPSILON = 0.01;
|
|
6
|
+
/**
|
|
7
|
+
* Resolves a single Archi bendpoint (stored as offsets from the source and
|
|
8
|
+
* target diagram-object centers) to an absolute point in Archi coordinate
|
|
9
|
+
* space.
|
|
10
|
+
*
|
|
11
|
+
* Confirmed fixture: source bounds x=48,y=180,w=120,h=55 (center 108,207),
|
|
12
|
+
* target bounds x=204,y=276,w=120,h=55 (center 264,303), bendpoint
|
|
13
|
+
* startX=-12,startY=93,endX=-168,endY=-3 resolves to absolute (96, 300) via
|
|
14
|
+
* either offset.
|
|
15
|
+
*
|
|
16
|
+
* When both offsets are present, they are cross-checked against each other;
|
|
17
|
+
* a material disagreement is reported via `mismatch` rather than silently
|
|
18
|
+
* resolved, so the caller can surface a diagnostic instead of guessing.
|
|
19
|
+
*/
|
|
20
|
+
function resolveBendpoint(bendpoint, sourceBounds, targetBounds) {
|
|
21
|
+
// A NaN/Infinity offset (e.g. from an upstream parser's failed arithmetic)
|
|
22
|
+
// is treated as absent rather than propagated into a nonsensical resolved
|
|
23
|
+
// point — this falls through to the existing "neither offset usable"
|
|
24
|
+
// diagnostic below instead of silently producing invalid geometry.
|
|
25
|
+
const hasSourceOffset = Number.isFinite(bendpoint.startX) && Number.isFinite(bendpoint.startY);
|
|
26
|
+
const hasTargetOffset = Number.isFinite(bendpoint.endX) && Number.isFinite(bendpoint.endY);
|
|
27
|
+
if (!hasSourceOffset && !hasTargetOffset) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const sourceCenter = (0, geometry_js_1.centerOf)(sourceBounds);
|
|
31
|
+
const targetCenter = (0, geometry_js_1.centerOf)(targetBounds);
|
|
32
|
+
const fromSource = hasSourceOffset
|
|
33
|
+
? { x: sourceCenter.x + bendpoint.startX, y: sourceCenter.y + bendpoint.startY }
|
|
34
|
+
: null;
|
|
35
|
+
const fromTarget = hasTargetOffset
|
|
36
|
+
? { x: targetCenter.x + bendpoint.endX, y: targetCenter.y + bendpoint.endY }
|
|
37
|
+
: null;
|
|
38
|
+
if (fromSource && fromTarget) {
|
|
39
|
+
const deltaX = Math.abs(fromSource.x - fromTarget.x);
|
|
40
|
+
const deltaY = Math.abs(fromSource.y - fromTarget.y);
|
|
41
|
+
if (deltaX > AGREEMENT_EPSILON || deltaY > AGREEMENT_EPSILON) {
|
|
42
|
+
return { point: fromSource, agreement: 'both', mismatch: { fromSource, fromTarget } };
|
|
43
|
+
}
|
|
44
|
+
return { point: fromSource, agreement: 'both' };
|
|
45
|
+
}
|
|
46
|
+
if (fromSource) {
|
|
47
|
+
return { point: fromSource, agreement: 'source-only' };
|
|
48
|
+
}
|
|
49
|
+
return { point: fromTarget, agreement: 'target-only' };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=bendpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bendpoints.js","sourceRoot":"","sources":["../../../src/geometry/bendpoints.ts"],"names":[],"mappings":";;AAgCA,4CAwCC;AAvED,+CAAyC;AAEzC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAe/B;;;;;;;;;;;;;GAaG;AACH,SAAgB,gBAAgB,CAC9B,SAAqG,EACrG,YAAkB,EAClB,YAAkB;IAElB,2EAA2E;IAC3E,0EAA0E;IAC1E,qEAAqE;IACrE,mEAAmE;IACnE,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC/F,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAA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,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;IACzD,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,UAAmB,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confirmed across all catalogue shapes and the relationship fixture: XMA
|
|
3
|
+
* geometry is Archi geometry uniformly scaled by 3 (x, y, width, height,
|
|
4
|
+
* and bendpoint coordinates alike).
|
|
5
|
+
*/
|
|
6
|
+
export declare const XMA_SCALE = 3;
|
|
7
|
+
export interface Rect {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function scaleValue(archiValue: number): number;
|
|
14
|
+
export declare function scaleRect(bounds: Rect): Rect;
|
|
15
|
+
export interface Point {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
}
|
|
19
|
+
export declare function scalePoint(point: Point): Point;
|
|
20
|
+
/**
|
|
21
|
+
* Rect center, floored to a whole pixel — confirmed against the proven
|
|
22
|
+
* bendpoint fixture: a 55px-tall shape's center is Archi's own `180 + 55/2`
|
|
23
|
+
* truncated to `207`, not `207.5`. Using the exact fraction here would
|
|
24
|
+
* throw off every bendpoint resolved against an odd-height/width shape.
|
|
25
|
+
*/
|
|
26
|
+
export declare function centerOf(bounds: Rect): Point;
|
|
27
|
+
interface NullableBounds {
|
|
28
|
+
x: number | null;
|
|
29
|
+
y: number | null;
|
|
30
|
+
width: number | null;
|
|
31
|
+
height: number | null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A bounds with confirmed `width`/`height`, but `x`/`y` still possibly
|
|
35
|
+
* `null` (Archi's own convention for "this coordinate is 0" — see
|
|
36
|
+
* `hasCompleteBounds`). Deliberately distinct from `Rect`: unlike the old
|
|
37
|
+
* `bounds is Rect` guard, this doesn't claim `x`/`y` are numbers when they
|
|
38
|
+
* might not be, so a caller can't reach for `bounds.x` arithmetic without
|
|
39
|
+
* going through `toRect` first and getting the null-to-0 substitution
|
|
40
|
+
* explicitly, instead of relying on it happening implicitly via JS
|
|
41
|
+
* coercion behind an unchecked cast.
|
|
42
|
+
*/
|
|
43
|
+
export interface CompleteBounds {
|
|
44
|
+
x: number | null;
|
|
45
|
+
y: number | null;
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Type guard: true when a bounds has usable width/height (`x`/`y` may
|
|
51
|
+
* still be `null` — see `CompleteBounds`).
|
|
52
|
+
*
|
|
53
|
+
* `width`/`height` must be set — there is no fixture evidence of Archi ever
|
|
54
|
+
* omitting either. `x`/`y` are allowed to be `null`: confirmed across all
|
|
55
|
+
* four fixtures (three omitted-`x` cases in sabsa, one omitted-`y` case in
|
|
56
|
+
* agile-manifesto — always alone, never alongside a missing `width`/
|
|
57
|
+
* `height`) that Archi omits a bounds coordinate specifically when its value
|
|
58
|
+
* is `0`, per the ArchiMate Exchange Format convention. Use `toRect` to
|
|
59
|
+
* apply that default explicitly before doing numeric work with `x`/`y`.
|
|
60
|
+
*
|
|
61
|
+
* Every non-null field must also be a finite number: a `NaN`/`Infinity`
|
|
62
|
+
* value (e.g. from an upstream parser's failed arithmetic on garbled
|
|
63
|
+
* geometry text) would otherwise pass this check and flow silently into the
|
|
64
|
+
* rendered XML as a literal `"NaN"`/`"Infinity"` attribute — invalid output
|
|
65
|
+
* produced with no diagnostic. Treating it as incomplete instead routes it
|
|
66
|
+
* through the same `missing-bounds` diagnostic as an actually-missing value.
|
|
67
|
+
*/
|
|
68
|
+
export declare function hasCompleteBounds(bounds: NullableBounds | null): bounds is CompleteBounds;
|
|
69
|
+
/**
|
|
70
|
+
* Applies Archi's "omitted coordinate means 0" convention explicitly (see
|
|
71
|
+
* `hasCompleteBounds`), turning a `CompleteBounds` into a real `Rect`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function toRect(bounds: CompleteBounds): Rect;
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../../src/geometry/geometry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,SAAS,IAAI,CAAC;AAE3B,MAAM,WAAW,IAAI;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,CAO5C;AAED,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAE9C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,IAAI,GAAG,KAAK,CAK5C;AAED,UAAU,cAAc;IACtB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,GAAG,MAAM,IAAI,cAAc,CAMzF;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAEnD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XMA_SCALE = void 0;
|
|
4
|
+
exports.scaleValue = scaleValue;
|
|
5
|
+
exports.scaleRect = scaleRect;
|
|
6
|
+
exports.scalePoint = scalePoint;
|
|
7
|
+
exports.centerOf = centerOf;
|
|
8
|
+
exports.hasCompleteBounds = hasCompleteBounds;
|
|
9
|
+
exports.toRect = toRect;
|
|
10
|
+
/**
|
|
11
|
+
* Confirmed across all catalogue shapes and the relationship fixture: XMA
|
|
12
|
+
* geometry is Archi geometry uniformly scaled by 3 (x, y, width, height,
|
|
13
|
+
* and bendpoint coordinates alike).
|
|
14
|
+
*/
|
|
15
|
+
exports.XMA_SCALE = 3;
|
|
16
|
+
function scaleValue(archiValue) {
|
|
17
|
+
return archiValue * exports.XMA_SCALE;
|
|
18
|
+
}
|
|
19
|
+
function scaleRect(bounds) {
|
|
20
|
+
return {
|
|
21
|
+
x: scaleValue(bounds.x),
|
|
22
|
+
y: scaleValue(bounds.y),
|
|
23
|
+
width: scaleValue(bounds.width),
|
|
24
|
+
height: scaleValue(bounds.height),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function scalePoint(point) {
|
|
28
|
+
return { x: scaleValue(point.x), y: scaleValue(point.y) };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Rect center, floored to a whole pixel — confirmed against the proven
|
|
32
|
+
* bendpoint fixture: a 55px-tall shape's center is Archi's own `180 + 55/2`
|
|
33
|
+
* truncated to `207`, not `207.5`. Using the exact fraction here would
|
|
34
|
+
* throw off every bendpoint resolved against an odd-height/width shape.
|
|
35
|
+
*/
|
|
36
|
+
function centerOf(bounds) {
|
|
37
|
+
return {
|
|
38
|
+
x: Math.floor(bounds.x + bounds.width / 2),
|
|
39
|
+
y: Math.floor(bounds.y + bounds.height / 2),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Type guard: true when a bounds has usable width/height (`x`/`y` may
|
|
44
|
+
* still be `null` — see `CompleteBounds`).
|
|
45
|
+
*
|
|
46
|
+
* `width`/`height` must be set — there is no fixture evidence of Archi ever
|
|
47
|
+
* omitting either. `x`/`y` are allowed to be `null`: confirmed across all
|
|
48
|
+
* four fixtures (three omitted-`x` cases in sabsa, one omitted-`y` case in
|
|
49
|
+
* agile-manifesto — always alone, never alongside a missing `width`/
|
|
50
|
+
* `height`) that Archi omits a bounds coordinate specifically when its value
|
|
51
|
+
* is `0`, per the ArchiMate Exchange Format convention. Use `toRect` to
|
|
52
|
+
* apply that default explicitly before doing numeric work with `x`/`y`.
|
|
53
|
+
*
|
|
54
|
+
* Every non-null field must also be a finite number: a `NaN`/`Infinity`
|
|
55
|
+
* value (e.g. from an upstream parser's failed arithmetic on garbled
|
|
56
|
+
* geometry text) would otherwise pass this check and flow silently into the
|
|
57
|
+
* rendered XML as a literal `"NaN"`/`"Infinity"` attribute — invalid output
|
|
58
|
+
* produced with no diagnostic. Treating it as incomplete instead routes it
|
|
59
|
+
* through the same `missing-bounds` diagnostic as an actually-missing value.
|
|
60
|
+
*/
|
|
61
|
+
function hasCompleteBounds(bounds) {
|
|
62
|
+
if (bounds === null)
|
|
63
|
+
return false;
|
|
64
|
+
for (const value of [bounds.x, bounds.y, bounds.width, bounds.height]) {
|
|
65
|
+
if (value !== null && !Number.isFinite(value))
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return bounds.width !== null && bounds.height !== null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Applies Archi's "omitted coordinate means 0" convention explicitly (see
|
|
72
|
+
* `hasCompleteBounds`), turning a `CompleteBounds` into a real `Rect`.
|
|
73
|
+
*/
|
|
74
|
+
function toRect(bounds) {
|
|
75
|
+
return { x: bounds.x ?? 0, y: bounds.y ?? 0, width: bounds.width, height: bounds.height };
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../../src/geometry/geometry.ts"],"names":[],"mappings":";;;AAcA,gCAEC;AAED,8BAOC;AAOD,gCAEC;AAQD,4BAKC;AA6CD,8CAMC;AAMD,wBAEC;AA1GD;;;;GAIG;AACU,QAAA,SAAS,GAAG,CAAC,CAAC;AAS3B,SAAgB,UAAU,CAAC,UAAkB;IAC3C,OAAO,UAAU,GAAG,iBAAS,CAAC;AAChC,CAAC;AAED,SAAgB,SAAS,CAAC,MAAY;IACpC,OAAO;QACL,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QACvB,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QACvB,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/B,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC;KAClC,CAAC;AACJ,CAAC;AAOD,SAAgB,UAAU,CAAC,KAAY;IACrC,OAAO,EAAE,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5D,CAAC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,MAAY;IACnC,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QAC1C,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;KAC5C,CAAC;AACJ,CAAC;AA0BD;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,iBAAiB,CAAC,MAA6B;IAC7D,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAClC,KAAK,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACtE,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;IAC9D,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,SAAgB,MAAM,CAAC,MAAsB;IAC3C,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAChF,YAAY,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XmaSerializationError = exports.inspectXmaSupport = exports.serializeXma = void 0;
|
|
4
|
+
var serialize_xma_js_1 = require("./serializer/serialize-xma.js");
|
|
5
|
+
Object.defineProperty(exports, "serializeXma", { enumerable: true, get: function () { return serialize_xma_js_1.serializeXma; } });
|
|
6
|
+
Object.defineProperty(exports, "inspectXmaSupport", { enumerable: true, get: function () { return serialize_xma_js_1.inspectXmaSupport; } });
|
|
7
|
+
var errors_js_1 = require("./diagnostics/errors.js");
|
|
8
|
+
Object.defineProperty(exports, "XmaSerializationError", { enumerable: true, get: function () { return errors_js_1.XmaSerializationError; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,kEAAgF;AAAvE,gHAAA,YAAY,OAAA;AAAE,qHAAA,iBAAiB,OAAA;AAExC,qDAAgE;AAAvD,kHAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asserts an internal cross-module invariant (e.g. "view-writer always
|
|
3
|
+
* registers this id before graphical-writer reads it back") instead of
|
|
4
|
+
* silently trusting it via a `!` non-null assertion. If the invariant is
|
|
5
|
+
* ever violated by a future refactor, this throws a clear, specific error
|
|
6
|
+
* instead of letting `undefined` flow into the rendered XML as the literal
|
|
7
|
+
* string `"undefined"`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function assertDefined<T>(value: T | undefined, message: string): T;
|
|
10
|
+
//# sourceMappingURL=assert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/assert.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAKzE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertDefined = assertDefined;
|
|
4
|
+
/**
|
|
5
|
+
* Asserts an internal cross-module invariant (e.g. "view-writer always
|
|
6
|
+
* registers this id before graphical-writer reads it back") instead of
|
|
7
|
+
* silently trusting it via a `!` non-null assertion. If the invariant is
|
|
8
|
+
* ever violated by a future refactor, this throws a clear, specific error
|
|
9
|
+
* instead of letting `undefined` flow into the rendered XML as the literal
|
|
10
|
+
* string `"undefined"`.
|
|
11
|
+
*/
|
|
12
|
+
function assertDefined(value, message) {
|
|
13
|
+
if (value === undefined) {
|
|
14
|
+
throw new Error(`Internal invariant violation: ${message}`);
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=assert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../../src/infrastructure/assert.ts"],"names":[],"mappings":";;AAQA,sCAKC;AAbD;;;;;;;GAOG;AACH,SAAgB,aAAa,CAAI,KAAoB,EAAE,OAAe;IACpE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,iCAAiC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-allocator.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/id-allocator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAK;IAEpB,IAAI,IAAI,MAAM;CAIf;AAED;;;;GAIG;AACH,qBAAa,aAAa;IAGZ,OAAO,CAAC,QAAQ,CAAC,SAAS;IAFtC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA6B;gBAEpB,SAAS,EAAE,cAAc;IAEtD,oEAAoE;IACpE,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAU1B,8FAA8F;IAC9F,KAAK,IAAI,MAAM;IAIf,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGrC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XmaIdRegistry = exports.XmaIdAllocator = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Deterministic numeric XMA id allocator.
|
|
6
|
+
*
|
|
7
|
+
* XMA reference documents use small sequential integer ids. We do not (and
|
|
8
|
+
* cannot) reproduce Archi's string ids — instead we hand out ids in strictly
|
|
9
|
+
* increasing order, starting from 1, driven entirely by serializer traversal
|
|
10
|
+
* order. As long as the traversal order over a given `ArchiModel` is stable
|
|
11
|
+
* (it is: every `ArchiModel` collection preserves source document order),
|
|
12
|
+
* the same input always yields the same ids.
|
|
13
|
+
*
|
|
14
|
+
* Never uses Math.random(), Date.now(), or any other non-deterministic or
|
|
15
|
+
* environment-specific source.
|
|
16
|
+
*/
|
|
17
|
+
class XmaIdAllocator {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.counter = 0;
|
|
20
|
+
}
|
|
21
|
+
next() {
|
|
22
|
+
this.counter += 1;
|
|
23
|
+
return this.counter;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.XmaIdAllocator = XmaIdAllocator;
|
|
27
|
+
/**
|
|
28
|
+
* A registry mapping arbitrary string keys (Archi ids, or synthetic
|
|
29
|
+
* composite keys) to allocated XMA numeric ids, with reference-consistent
|
|
30
|
+
* reuse: asking for the same key twice returns the same id.
|
|
31
|
+
*/
|
|
32
|
+
class XmaIdRegistry {
|
|
33
|
+
constructor(allocator) {
|
|
34
|
+
this.allocator = allocator;
|
|
35
|
+
this.ids = new Map();
|
|
36
|
+
}
|
|
37
|
+
/** Allocates (or returns the previously allocated) id for `key`. */
|
|
38
|
+
idFor(key) {
|
|
39
|
+
const existing = this.ids.get(key);
|
|
40
|
+
if (existing !== undefined) {
|
|
41
|
+
return existing;
|
|
42
|
+
}
|
|
43
|
+
const id = this.allocator.next();
|
|
44
|
+
this.ids.set(key, id);
|
|
45
|
+
return id;
|
|
46
|
+
}
|
|
47
|
+
/** Allocates a fresh id not tied to any lookup key (e.g. structural scaffolding elements). */
|
|
48
|
+
fresh() {
|
|
49
|
+
return this.allocator.next();
|
|
50
|
+
}
|
|
51
|
+
has(key) {
|
|
52
|
+
return this.ids.has(key);
|
|
53
|
+
}
|
|
54
|
+
get(key) {
|
|
55
|
+
return this.ids.get(key);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.XmaIdRegistry = XmaIdRegistry;
|
|
59
|
+
//# sourceMappingURL=id-allocator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id-allocator.js","sourceRoot":"","sources":["../../../src/infrastructure/id-allocator.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACH,MAAa,cAAc;IAA3B;QACU,YAAO,GAAG,CAAC,CAAC;IAMtB,CAAC;IAJC,IAAI;QACF,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAPD,wCAOC;AAED;;;;GAIG;AACH,MAAa,aAAa;IAGxB,YAA6B,SAAyB;QAAzB,cAAS,GAAT,SAAS,CAAgB;QAFrC,QAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEQ,CAAC;IAE1D,oEAAoE;IACpE,KAAK,CAAC,GAAW;QACf,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACjC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