@linked.archi/kernel 0.0.0-stage → 0.1.5
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 +202 -0
- package/NOTICE +11 -0
- package/README.md +96 -2
- package/assets/arch-decision/arch-decision-metamodel.ttl +44 -0
- package/assets/arch-decision/arch-decision-onto.ttl +1566 -0
- package/assets/arch-decision/arch-decision-shapes.ttl +582 -0
- package/assets/arch-decision/arch-decision-tax.ttl +129 -0
- package/assets/arch-processes/arch-processes-metamodel.ttl +42 -0
- package/assets/arch-processes/arch-processes-tax.ttl +136 -0
- package/assets/arch-processes/archProcesses-shapes.ttl +189 -0
- package/assets/arch-processes/archProcesses.ttl +953 -0
- package/assets/archimate3/archimate3.2-element-shapes.ttl +379 -0
- package/assets/archimate3/archimate3.2-metamodel.ttl +205 -0
- package/assets/archimate3/archimate3.2-notation.ttl +1503 -0
- package/assets/archimate3/archimate3.2-onto.ttl +1579 -0
- package/assets/archimate3/archimate3.2-presentation-contexts.ttl +90 -0
- package/assets/archimate3/archimate3.2-principle-shapes.ttl +923 -0
- package/assets/archimate3/archimate3.2-questions.ttl +1125 -0
- package/assets/archimate3/archimate3.2-reference-data.ttl +74 -0
- package/assets/archimate3/archimate3.2-relationship-shapes.ttl +30956 -0
- package/assets/archimate3/archimate3.2-relationship-tables.ttl +5992 -0
- package/assets/archimate3/archimate3.2-tax.ttl +724 -0
- package/assets/archimate3/archimate3.2-viewpoint-shapes.ttl +59 -0
- package/assets/archimate3/archimate3.2-viewpoints.ttl +793 -0
- package/assets/archimate3/icons/and-junction.svg +3 -0
- package/assets/archimate3/icons/application-collaboration.svg +22 -0
- package/assets/archimate3/icons/application-component.svg +18 -0
- package/assets/archimate3/icons/application-event.svg +15 -0
- package/assets/archimate3/icons/application-function.svg +14 -0
- package/assets/archimate3/icons/application-interaction.svg +17 -0
- package/assets/archimate3/icons/application-interface.svg +16 -0
- package/assets/archimate3/icons/application-process.svg +14 -0
- package/assets/archimate3/icons/application-service.svg +14 -0
- package/assets/archimate3/icons/artifact.svg +16 -0
- package/assets/archimate3/icons/assessment.svg +17 -0
- package/assets/archimate3/icons/business-actor.svg +22 -0
- package/assets/archimate3/icons/business-collaboration.svg +21 -0
- package/assets/archimate3/icons/business-event.svg +15 -0
- package/assets/archimate3/icons/business-function.svg +14 -0
- package/assets/archimate3/icons/business-interaction.svg +18 -0
- package/assets/archimate3/icons/business-interface.svg +16 -0
- package/assets/archimate3/icons/business-object.svg +14 -0
- package/assets/archimate3/icons/business-process.svg +15 -0
- package/assets/archimate3/icons/business-role.svg +16 -0
- package/assets/archimate3/icons/business-service.svg +14 -0
- package/assets/archimate3/icons/capability.svg +40 -0
- package/assets/archimate3/icons/communication-network.svg +18 -0
- package/assets/archimate3/icons/constraint.svg +18 -0
- package/assets/archimate3/icons/contract.svg +13 -0
- package/assets/archimate3/icons/course-of-action.svg +20 -0
- package/assets/archimate3/icons/data-object.svg +14 -0
- package/assets/archimate3/icons/deliverable.svg +11 -0
- package/assets/archimate3/icons/device.svg +18 -0
- package/assets/archimate3/icons/distribution-network.svg +19 -0
- package/assets/archimate3/icons/driver.svg +24 -0
- package/assets/archimate3/icons/equipment.svg +31 -0
- package/assets/archimate3/icons/facility.svg +16 -0
- package/assets/archimate3/icons/gap.svg +22 -0
- package/assets/archimate3/icons/glyphs/activity.svg +3 -0
- package/assets/archimate3/icons/glyphs/actor.svg +14 -0
- package/assets/archimate3/icons/glyphs/application-component.svg +12 -0
- package/assets/archimate3/icons/glyphs/artifact.svg +9 -0
- package/assets/archimate3/icons/glyphs/assessment.svg +9 -0
- package/assets/archimate3/icons/glyphs/capability.svg +32 -0
- package/assets/archimate3/icons/glyphs/cloud-gear.svg +3 -0
- package/assets/archimate3/icons/glyphs/collaboration.svg +15 -0
- package/assets/archimate3/icons/glyphs/communication-network.svg +12 -0
- package/assets/archimate3/icons/glyphs/constraint.svg +10 -0
- package/assets/archimate3/icons/glyphs/contract.svg +5 -0
- package/assets/archimate3/icons/glyphs/course-of-action.svg +12 -0
- package/assets/archimate3/icons/glyphs/data-object.svg +4 -0
- package/assets/archimate3/icons/glyphs/deliverable.svg +3 -0
- package/assets/archimate3/icons/glyphs/device.svg +10 -0
- package/assets/archimate3/icons/glyphs/distribution-network.svg +11 -0
- package/assets/archimate3/icons/glyphs/driver.svg +16 -0
- package/assets/archimate3/icons/glyphs/equipment.svg +22 -0
- package/assets/archimate3/icons/glyphs/event.svg +6 -0
- package/assets/archimate3/icons/glyphs/facility.svg +7 -0
- package/assets/archimate3/icons/glyphs/function.svg +6 -0
- package/assets/archimate3/icons/glyphs/gap.svg +14 -0
- package/assets/archimate3/icons/glyphs/goal.svg +10 -0
- package/assets/archimate3/icons/glyphs/grouping.svg +4 -0
- package/assets/archimate3/icons/glyphs/interaction.svg +10 -0
- package/assets/archimate3/icons/glyphs/interface.svg +8 -0
- package/assets/archimate3/icons/glyphs/location.svg +6 -0
- package/assets/archimate3/icons/glyphs/material.svg +12 -0
- package/assets/archimate3/icons/glyphs/meaning.svg +3 -0
- package/assets/archimate3/icons/glyphs/node.svg +8 -0
- package/assets/archimate3/icons/glyphs/object.svg +4 -0
- package/assets/archimate3/icons/glyphs/outcome.svg +16 -0
- package/assets/archimate3/icons/glyphs/path.svg +10 -0
- package/assets/archimate3/icons/glyphs/person-silhouette.svg +3 -0
- package/assets/archimate3/icons/glyphs/plateau.svg +8 -0
- package/assets/archimate3/icons/glyphs/principle.svg +12 -0
- package/assets/archimate3/icons/glyphs/process.svg +6 -0
- package/assets/archimate3/icons/glyphs/product.svg +4 -0
- package/assets/archimate3/icons/glyphs/representation.svg +4 -0
- package/assets/archimate3/icons/glyphs/requirement.svg +6 -0
- package/assets/archimate3/icons/glyphs/resource.svg +14 -0
- package/assets/archimate3/icons/glyphs/role.svg +6 -0
- package/assets/archimate3/icons/glyphs/service.svg +6 -0
- package/assets/archimate3/icons/glyphs/stakeholder.svg +6 -0
- package/assets/archimate3/icons/glyphs/system-software.svg +14 -0
- package/assets/archimate3/icons/glyphs/value-stream.svg +3 -0
- package/assets/archimate3/icons/glyphs/value.svg +3 -0
- package/assets/archimate3/icons/glyphs/work-package.svg +4 -0
- package/assets/archimate3/icons/goal.svg +18 -0
- package/assets/archimate3/icons/grouping.svg +12 -0
- package/assets/archimate3/icons/implementation-event.svg +15 -0
- package/assets/archimate3/icons/location.svg +14 -0
- package/assets/archimate3/icons/material.svg +21 -0
- package/assets/archimate3/icons/meaning.svg +11 -0
- package/assets/archimate3/icons/node.svg +14 -0
- package/assets/archimate3/icons/or-junction.svg +3 -0
- package/assets/archimate3/icons/outcome.svg +25 -0
- package/assets/archimate3/icons/path.svg +18 -0
- package/assets/archimate3/icons/plateau.svg +16 -0
- package/assets/archimate3/icons/principle.svg +21 -0
- package/assets/archimate3/icons/product.svg +12 -0
- package/assets/archimate3/icons/representation.svg +12 -0
- package/assets/archimate3/icons/requirement.svg +14 -0
- package/assets/archimate3/icons/resource.svg +23 -0
- package/assets/archimate3/icons/stakeholder.svg +15 -0
- package/assets/archimate3/icons/system-software.svg +22 -0
- package/assets/archimate3/icons/technology-collaboration.svg +22 -0
- package/assets/archimate3/icons/technology-event.svg +15 -0
- package/assets/archimate3/icons/technology-function.svg +14 -0
- package/assets/archimate3/icons/technology-interaction.svg +18 -0
- package/assets/archimate3/icons/technology-interface.svg +16 -0
- package/assets/archimate3/icons/technology-process.svg +14 -0
- package/assets/archimate3/icons/technology-service.svg +14 -0
- package/assets/archimate3/icons/value-stream.svg +11 -0
- package/assets/archimate3/icons/value.svg +11 -0
- package/assets/archimate3/icons/work-package.svg +12 -0
- package/assets/archimate4/archimate4-element-shapes.ttl +404 -0
- package/assets/archimate4/archimate4-metamodel.ttl +179 -0
- package/assets/archimate4/archimate4-notation.ttl +1147 -0
- package/assets/archimate4/archimate4-onto.ttl +1559 -0
- package/assets/archimate4/archimate4-presentation-contexts.ttl +60 -0
- package/assets/archimate4/archimate4-principle-shapes.ttl +893 -0
- package/assets/archimate4/archimate4-questions.ttl +1224 -0
- package/assets/archimate4/archimate4-reference-data.ttl +56 -0
- package/assets/archimate4/archimate4-relationship-shapes.ttl +16920 -0
- package/assets/archimate4/archimate4-relationship-tables.ttl +3200 -0
- package/assets/archimate4/archimate4-tax.ttl +749 -0
- package/assets/archimate4/archimate4-viewpoint-shapes.ttl +55 -0
- package/assets/archimate4/archimate4-viewpoints.ttl +777 -0
- package/assets/archimate4/icons/and-junction.svg +3 -0
- package/assets/archimate4/icons/application-component.svg +18 -0
- package/assets/archimate4/icons/application-interface.svg +16 -0
- package/assets/archimate4/icons/artifact.svg +16 -0
- package/assets/archimate4/icons/assessment.svg +17 -0
- package/assets/archimate4/icons/business-actor.svg +22 -0
- package/assets/archimate4/icons/business-interface.svg +16 -0
- package/assets/archimate4/icons/business-object.svg +14 -0
- package/assets/archimate4/icons/capability.svg +40 -0
- package/assets/archimate4/icons/collaboration.svg +21 -0
- package/assets/archimate4/icons/communication-network.svg +18 -0
- package/assets/archimate4/icons/course-of-action.svg +20 -0
- package/assets/archimate4/icons/data-object.svg +14 -0
- package/assets/archimate4/icons/deliverable.svg +11 -0
- package/assets/archimate4/icons/device.svg +18 -0
- package/assets/archimate4/icons/distribution-network.svg +19 -0
- package/assets/archimate4/icons/driver.svg +24 -0
- package/assets/archimate4/icons/equipment.svg +31 -0
- package/assets/archimate4/icons/event.svg +15 -0
- package/assets/archimate4/icons/facility.svg +16 -0
- package/assets/archimate4/icons/function.svg +13 -0
- package/assets/archimate4/icons/glyphs/activity.svg +3 -0
- package/assets/archimate4/icons/glyphs/actor.svg +14 -0
- package/assets/archimate4/icons/glyphs/application-component.svg +12 -0
- package/assets/archimate4/icons/glyphs/artifact.svg +9 -0
- package/assets/archimate4/icons/glyphs/assessment.svg +9 -0
- package/assets/archimate4/icons/glyphs/capability.svg +32 -0
- package/assets/archimate4/icons/glyphs/cloud-gear.svg +3 -0
- package/assets/archimate4/icons/glyphs/collaboration.svg +15 -0
- package/assets/archimate4/icons/glyphs/communication-network.svg +12 -0
- package/assets/archimate4/icons/glyphs/constraint.svg +10 -0
- package/assets/archimate4/icons/glyphs/contract.svg +5 -0
- package/assets/archimate4/icons/glyphs/course-of-action.svg +12 -0
- package/assets/archimate4/icons/glyphs/data-object.svg +4 -0
- package/assets/archimate4/icons/glyphs/deliverable.svg +3 -0
- package/assets/archimate4/icons/glyphs/device.svg +10 -0
- package/assets/archimate4/icons/glyphs/distribution-network.svg +11 -0
- package/assets/archimate4/icons/glyphs/driver.svg +16 -0
- package/assets/archimate4/icons/glyphs/equipment.svg +22 -0
- package/assets/archimate4/icons/glyphs/event.svg +6 -0
- package/assets/archimate4/icons/glyphs/facility.svg +7 -0
- package/assets/archimate4/icons/glyphs/function.svg +6 -0
- package/assets/archimate4/icons/glyphs/gap.svg +14 -0
- package/assets/archimate4/icons/glyphs/goal.svg +10 -0
- package/assets/archimate4/icons/glyphs/grouping.svg +4 -0
- package/assets/archimate4/icons/glyphs/interaction.svg +10 -0
- package/assets/archimate4/icons/glyphs/interface.svg +8 -0
- package/assets/archimate4/icons/glyphs/location.svg +6 -0
- package/assets/archimate4/icons/glyphs/material.svg +12 -0
- package/assets/archimate4/icons/glyphs/meaning.svg +3 -0
- package/assets/archimate4/icons/glyphs/node.svg +8 -0
- package/assets/archimate4/icons/glyphs/object.svg +4 -0
- package/assets/archimate4/icons/glyphs/outcome.svg +16 -0
- package/assets/archimate4/icons/glyphs/path.svg +10 -0
- package/assets/archimate4/icons/glyphs/person-silhouette.svg +3 -0
- package/assets/archimate4/icons/glyphs/plateau.svg +8 -0
- package/assets/archimate4/icons/glyphs/principle.svg +12 -0
- package/assets/archimate4/icons/glyphs/process.svg +6 -0
- package/assets/archimate4/icons/glyphs/product.svg +4 -0
- package/assets/archimate4/icons/glyphs/representation.svg +4 -0
- package/assets/archimate4/icons/glyphs/requirement.svg +6 -0
- package/assets/archimate4/icons/glyphs/resource.svg +14 -0
- package/assets/archimate4/icons/glyphs/role.svg +6 -0
- package/assets/archimate4/icons/glyphs/service.svg +6 -0
- package/assets/archimate4/icons/glyphs/stakeholder.svg +6 -0
- package/assets/archimate4/icons/glyphs/system-software.svg +14 -0
- package/assets/archimate4/icons/glyphs/value-stream.svg +3 -0
- package/assets/archimate4/icons/glyphs/value.svg +3 -0
- package/assets/archimate4/icons/glyphs/work-package.svg +4 -0
- package/assets/archimate4/icons/goal.svg +18 -0
- package/assets/archimate4/icons/grouping.svg +12 -0
- package/assets/archimate4/icons/location.svg +14 -0
- package/assets/archimate4/icons/material.svg +21 -0
- package/assets/archimate4/icons/meaning.svg +11 -0
- package/assets/archimate4/icons/node.svg +14 -0
- package/assets/archimate4/icons/or-junction.svg +3 -0
- package/assets/archimate4/icons/outcome.svg +25 -0
- package/assets/archimate4/icons/path.svg +18 -0
- package/assets/archimate4/icons/plateau.svg +16 -0
- package/assets/archimate4/icons/principle.svg +21 -0
- package/assets/archimate4/icons/process.svg +15 -0
- package/assets/archimate4/icons/product.svg +12 -0
- package/assets/archimate4/icons/requirement.svg +14 -0
- package/assets/archimate4/icons/resource.svg +23 -0
- package/assets/archimate4/icons/role.svg +16 -0
- package/assets/archimate4/icons/service.svg +13 -0
- package/assets/archimate4/icons/stakeholder.svg +15 -0
- package/assets/archimate4/icons/system-software.svg +22 -0
- package/assets/archimate4/icons/technology-interface.svg +16 -0
- package/assets/archimate4/icons/value-stream.svg +11 -0
- package/assets/archimate4/icons/value.svg +11 -0
- package/assets/archimate4/icons/work-package.svg +12 -0
- package/assets/basic/basic-metamodel.ttl +100 -0
- package/assets/basic/basic-notation-bubble.ttl +175 -0
- package/assets/basic/basic-notation.ttl +172 -0
- package/assets/basic/basic-onto.ttl +171 -0
- package/assets/basic/basic-presentation-contexts.ttl +70 -0
- package/assets/basic/basic-tax.ttl +130 -0
- package/assets/basic/icons/aggregation.svg +7 -0
- package/assets/basic/icons/association.svg +6 -0
- package/assets/basic/icons/element.svg +5 -0
- package/assets/basic/icons/glyphs/aggregation.svg +6 -0
- package/assets/basic/icons/glyphs/association.svg +5 -0
- package/assets/basic/icons/glyphs/element.svg +5 -0
- package/assets/basic/icons/glyphs/relationship.svg +5 -0
- package/assets/basic/icons/relationship.svg +7 -0
- package/assets/basic/notation-bubble/icons/aggregation.svg +7 -0
- package/assets/basic/notation-bubble/icons/association.svg +6 -0
- package/assets/basic/notation-bubble/icons/element.svg +5 -0
- package/assets/basic/notation-bubble/icons/glyphs/aggregation.svg +6 -0
- package/assets/basic/notation-bubble/icons/glyphs/association.svg +5 -0
- package/assets/basic/notation-bubble/icons/glyphs/element.svg +5 -0
- package/assets/basic/notation-bubble/icons/glyphs/relationship.svg +5 -0
- package/assets/basic/notation-bubble/icons/relationship.svg +7 -0
- package/assets/catalog.ttl +7302 -0
- package/assets/core/core-notation.ttl +131 -0
- package/assets/core/core-onto.ttl +2811 -0
- package/assets/core/core-questions.ttl +957 -0
- package/assets/core/core-shapes.ttl +915 -0
- package/assets/core/core-vis-onto.ttl +1408 -0
- package/assets/core/core-vis-shapes.ttl +840 -0
- package/assets/core-vis/markers/circle-dot.svg +3 -0
- package/assets/core-vis/markers/closed-arrowhead.svg +3 -0
- package/assets/core-vis/markers/filled-diamond.svg +3 -0
- package/assets/core-vis/markers/half-arrowhead.svg +3 -0
- package/assets/core-vis/markers/hollow-arrowhead.svg +3 -0
- package/assets/core-vis/markers/hollow-diamond.svg +3 -0
- package/assets/core-vis/markers/open-arrowhead.svg +3 -0
- package/fixtures/interoperability/archimate4-demo.trig +259 -0
- package/fixtures/interoperability/expected-findings.json +26 -0
- package/fixtures/interoperability/shop-seed.ttl +225 -0
- package/package.json +136 -4
- package/scripts/sync-assets.mjs +252 -0
- package/src/conformance.ts +66 -0
- package/src/import-export/model-io.ts +426 -0
- package/src/index.ts +11 -0
- package/src/metamodel-manager/asset-sources.ts +754 -0
- package/src/metamodel-manager/bundled-assets.ts +599 -0
- package/src/metamodel-manager/catalogue.ts +114 -0
- package/src/metamodel-manager/class-hierarchy.ts +155 -0
- package/src/metamodel-manager/index.ts +65 -0
- package/src/metamodel-manager/interfaces.ts +422 -0
- package/src/metamodel-manager/metamodel-completeness.ts +162 -0
- package/src/metamodel-manager/metamodel-loader.ts +864 -0
- package/src/metamodel-manager/notation-resolver.ts +284 -0
- package/src/metamodel-manager/notation.ts +659 -0
- package/src/metamodel-manager/palette-generator.ts +882 -0
- package/src/metamodel-manager/property-shapes.ts +290 -0
- package/src/metamodel-manager/taxonomy.ts +904 -0
- package/src/metamodel-manager/type-guide.ts +241 -0
- package/src/metamodel-manager/viewpoint-manager.ts +147 -0
- package/src/model-manager/appearance.ts +389 -0
- package/src/model-manager/cascade.ts +246 -0
- package/src/model-manager/clipboard.ts +566 -0
- package/src/model-manager/context-names.ts +108 -0
- package/src/model-manager/custom-properties.ts +549 -0
- package/src/model-manager/derivations.ts +166 -0
- package/src/model-manager/direct-permissions.ts +182 -0
- package/src/model-manager/drawing-order.ts +119 -0
- package/src/model-manager/element-manager.ts +69 -0
- package/src/model-manager/element-pictures.ts +118 -0
- package/src/model-manager/field-names.ts +42 -0
- package/src/model-manager/folders.ts +354 -0
- package/src/model-manager/grid.ts +6 -0
- package/src/model-manager/index.ts +43 -0
- package/src/model-manager/interfaces.ts +417 -0
- package/src/model-manager/iri-conformance.ts +183 -0
- package/src/model-manager/label-expression.ts +233 -0
- package/src/model-manager/legacy-migration.ts +200 -0
- package/src/model-manager/missing-references.ts +86 -0
- package/src/model-manager/model-diff-text.ts +150 -0
- package/src/model-manager/model-diff.ts +534 -0
- package/src/model-manager/model-merge.ts +1160 -0
- package/src/model-manager/model-namespace.ts +199 -0
- package/src/model-manager/model-operations.ts +132 -0
- package/src/model-manager/model-queries.ts +616 -0
- package/src/model-manager/model-session.ts +759 -0
- package/src/model-manager/multiplicity.ts +74 -0
- package/src/model-manager/nested-resources.ts +145 -0
- package/src/model-manager/own-metamodel.ts +157 -0
- package/src/model-manager/placement-copy.ts +116 -0
- package/src/model-manager/property-catalog.ts +787 -0
- package/src/model-manager/proposal-order.ts +203 -0
- package/src/model-manager/provenance.ts +396 -0
- package/src/model-manager/questions.ts +470 -0
- package/src/model-manager/rdf-scope.ts +97 -0
- package/src/model-manager/relationship-graph.ts +462 -0
- package/src/model-manager/relationship-manager.ts +962 -0
- package/src/model-manager/relationship-table.ts +189 -0
- package/src/model-manager/relationship-validity.ts +261 -0
- package/src/model-manager/resource-edits.ts +28 -0
- package/src/model-manager/short-hash.ts +104 -0
- package/src/model-manager/snapshot-lines.ts +88 -0
- package/src/model-manager/version-history.ts +205 -0
- package/src/model-manager/view-from-results.ts +81 -0
- package/src/model-manager/view-manager.ts +1410 -0
- package/src/model-manager/vocabulary.ts +279 -0
- package/src/rdf-engine/finding-shape.ts +23 -0
- package/src/rdf-engine/graph-scope.ts +163 -0
- package/src/rdf-engine/index.ts +7 -0
- package/src/rdf-engine/interfaces.ts +144 -0
- package/src/rdf-engine/iri.ts +203 -0
- package/src/rdf-engine/localized-text.ts +13 -0
- package/src/rdf-engine/namespaces.ts +41 -0
- package/src/rdf-engine/observable-store.ts +631 -0
- package/src/rdf-engine/rdf-store.ts +508 -0
- package/src/rdf-engine/shacl-validator.ts +602 -0
- package/src/rdf-engine/shape-reach.ts +140 -0
- package/src/rdf-engine/shape-switches.ts +165 -0
- package/src/rdf-engine/single-valued.ts +219 -0
- package/src/rdf-engine/sparql-constraints.ts +334 -0
- package/src/rdf-engine/term-codec.ts +51 -0
- package/src/rdf-engine/ttl-parser.ts +51 -0
- package/src/rdf-engine/ttl-serializer.ts +79 -0
- package/src/rdf-engine/turtle-writer.ts +284 -0
- package/src/rdf-engine/validation-engine.ts +682 -0
- package/src/rdf-engine/validation-service.ts +184 -0
- package/src/rdf-engine/validation.worker.ts +47 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How one thing drawn in a view looks — an element's placement, a figure, a
|
|
3
|
+
* relationship's line, a line from a note — set on its own core-vis style
|
|
4
|
+
* (`arch-vis:style`): the look of that one diagram object.
|
|
5
|
+
* Each value absent leaves the notation's choice, or la-gram's.
|
|
6
|
+
*
|
|
7
|
+
* | key | core-vis | value |
|
|
8
|
+
* | --- | --- | --- |
|
|
9
|
+
* | `fillColor`, `lineColor`, `fontColor` | `arch-vis:fillColor` … | a CSS colour; its alpha its opacity |
|
|
10
|
+
* | `gradient` | `arch-vis:gradient` (0.7) | `arch-vis:GradientTop`, `GradientLeft`, `GradientRight`, `GradientBottom` |
|
|
11
|
+
* | `iconColor` | `arch-vis:iconColor` (0.7) | a CSS colour: the glyph's |
|
|
12
|
+
* | `lineStyle` | `arch-vis:lineStyle` | a line from a note's: `arch-vis:SolidLine`, `DashedLine`, `DottedLine` |
|
|
13
|
+
* | `sourceDecor`, `targetDecor` | `arch-vis:sourceDecor`, `targetDecor` | a line from a note's ends: `arch-vis:NoDecoration`, `OpenArrowhead`, … |
|
|
14
|
+
* | `shapeType` | `arch-vis:shapeType` | the shape an element's placement is drawn as: one of its notation's alternatives (`arch-vis:alternativeStyle`) |
|
|
15
|
+
* | `renderingMode` | `arch-vis:renderingMode` | `arch-vis:ShapeWithBadge`, `IconCentric`, `ShapeOnly`: the figure an element's placement is drawn as (the Figure tab) |
|
|
16
|
+
* | `lineWidth` | `arch-vis:lineWidth` (0.7) | a positive integer |
|
|
17
|
+
* | `borderStyle` | `arch-vis:borderStyle` | `arch-vis:SolidLine`, `DashedLine`, `DottedLine` |
|
|
18
|
+
* | `fontName` | `arch-vis:fontName` | a font family |
|
|
19
|
+
* | `fontSize` | `arch-vis:fontSize` | a positive integer, in the diagram's units |
|
|
20
|
+
* | `fontStyle` | `arch-vis:fontStyle` (0.7) | `bold`, `italic`, `underline`, separated by spaces |
|
|
21
|
+
* | `textAlignment` | `arch-vis:textAlignment` (0.7) | `arch-vis:AlignLeft`, `AlignCenter`, `AlignRight` |
|
|
22
|
+
* | `textPosition` | `arch-vis:textPosition` (0.7) | `arch-vis:PositionTop`, `PositionMiddle`, `PositionBottom` |
|
|
23
|
+
* | `labelAnchor` | `arch-vis:labelAnchor` (0.7) | where along a line its text sits: `arch-vis:AnchorSource`, `AnchorMiddle`, `AnchorTarget` |
|
|
24
|
+
* | `image` | `arch-vis:image` (0.7) | a picture drawn in a node: an http(s) URL or a `data:image/…` URI, an `xsd:anyURI` |
|
|
25
|
+
* | `imagePosition` | `arch-vis:imagePosition` (0.7) | where: an `arch-vis:IconPlacement` — `TopLeft` … `BottomRight`, or `Fill` |
|
|
26
|
+
* | `iconSymbol` | `arch-vis:iconSymbol` | a placement's own picture in place of its notation's glyph — with `IconCentric`, drawn as the figure; an `xsd:anyURI` as `image` |
|
|
27
|
+
* | `useElementPicture` | `arch-vis:useElementPicture` (0.8) | `true`: its icon is its element's picture for the presentation shown — its badge in box-with-badge, its figure in icon mode; an `xsd:boolean` |
|
|
28
|
+
*
|
|
29
|
+
* ## A colour's alpha
|
|
30
|
+
*
|
|
31
|
+
* core-vis says a colour is a CSS colour string, its alpha CSS's (0–1), but
|
|
32
|
+
* the ArchiMate converter wrote the exchange format's alpha as it is before
|
|
33
|
+
* core-vis 0.7 said so — a percentage, `rgba(255,247,179,100)` — or out of
|
|
34
|
+
* 255. CSS reads any alpha above 1 as opaque, so {@link cssColour} reads one
|
|
35
|
+
* above 1 as meant: a percentage up to 100, else out of 255. la-gram writes
|
|
36
|
+
* `#rrggbb`, or `#rrggbbaa` when a colour is not opaque, which no reader can
|
|
37
|
+
* take two ways.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
import { NAMESPACES } from '../rdf-engine/namespaces.js';
|
|
41
|
+
|
|
42
|
+
const VIS = NAMESPACES['arch-vis'];
|
|
43
|
+
|
|
44
|
+
export type TextAlignment = 'left' | 'center' | 'right';
|
|
45
|
+
export type TextPosition = 'top' | 'middle' | 'bottom';
|
|
46
|
+
export type BorderStyle = 'SolidLine' | 'DashedLine' | 'DottedLine';
|
|
47
|
+
/** What an end of a line is drawn with (core-vis's `arch-vis:Decoration`s). */
|
|
48
|
+
export type LineDecoration =
|
|
49
|
+
| 'NoDecoration'
|
|
50
|
+
| 'OpenArrowhead'
|
|
51
|
+
| 'ClosedArrowhead'
|
|
52
|
+
| 'HollowArrowhead'
|
|
53
|
+
| 'HollowDiamond'
|
|
54
|
+
| 'FilledDiamond'
|
|
55
|
+
| 'HalfArrowhead'
|
|
56
|
+
| 'CircleDot';
|
|
57
|
+
const DECORATION_NAMES: readonly LineDecoration[] = [
|
|
58
|
+
'NoDecoration',
|
|
59
|
+
'OpenArrowhead',
|
|
60
|
+
'ClosedArrowhead',
|
|
61
|
+
'HollowArrowhead',
|
|
62
|
+
'HollowDiamond',
|
|
63
|
+
'FilledDiamond',
|
|
64
|
+
'HalfArrowhead',
|
|
65
|
+
'CircleDot',
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
/** How an element is drawn: a shape with its glyph as a badge, the glyph as the figure, or the shape alone. */
|
|
69
|
+
export type FigureMode = 'ShapeWithBadge' | 'IconCentric' | 'ShapeOnly';
|
|
70
|
+
/** The side a fill shades from — its colour there, white at the opposite side. */
|
|
71
|
+
export type Gradient = 'top' | 'left' | 'right' | 'bottom';
|
|
72
|
+
/** Where along a line its text sits: near its source end, at its middle, near its target end. */
|
|
73
|
+
export type LabelAnchor = 'source' | 'middle' | 'target';
|
|
74
|
+
/** Where a node's picture is drawn: a corner, the middle of a side, its centre — or filling it. */
|
|
75
|
+
export type ImagePosition =
|
|
76
|
+
| 'TopLeft'
|
|
77
|
+
| 'TopCenter'
|
|
78
|
+
| 'TopRight'
|
|
79
|
+
| 'MiddleLeft'
|
|
80
|
+
| 'Center'
|
|
81
|
+
| 'MiddleRight'
|
|
82
|
+
| 'BottomLeft'
|
|
83
|
+
| 'BottomCenter'
|
|
84
|
+
| 'BottomRight'
|
|
85
|
+
| 'Fill';
|
|
86
|
+
export const IMAGE_POSITIONS: readonly ImagePosition[] = [
|
|
87
|
+
'TopLeft',
|
|
88
|
+
'TopCenter',
|
|
89
|
+
'TopRight',
|
|
90
|
+
'MiddleLeft',
|
|
91
|
+
'Center',
|
|
92
|
+
'MiddleRight',
|
|
93
|
+
'BottomLeft',
|
|
94
|
+
'BottomCenter',
|
|
95
|
+
'BottomRight',
|
|
96
|
+
'Fill',
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
export interface Appearance {
|
|
100
|
+
fillColor?: string;
|
|
101
|
+
/** None when absent: the fill all one colour. */
|
|
102
|
+
gradient?: Gradient;
|
|
103
|
+
lineColor?: string;
|
|
104
|
+
fontColor?: string;
|
|
105
|
+
lineWidth?: number;
|
|
106
|
+
borderStyle?: BorderStyle;
|
|
107
|
+
/** The colour of an element's glyph — its badge, or its icon — drawn as published when absent. */
|
|
108
|
+
iconColor?: string;
|
|
109
|
+
fontName?: string;
|
|
110
|
+
fontSize?: number;
|
|
111
|
+
/** `bold`, `italic`, `underline`, separated by spaces, in that order. */
|
|
112
|
+
fontStyle?: string;
|
|
113
|
+
textAlignment?: TextAlignment;
|
|
114
|
+
textPosition?: TextPosition;
|
|
115
|
+
/** The figure an element's placement is drawn as, in place of its notation's (the Figure tab). */
|
|
116
|
+
renderingMode?: FigureMode;
|
|
117
|
+
/** The shape it is drawn as, by IRI — a figure's, or one of its notation's alternatives (the Figure tab). */
|
|
118
|
+
shapeType?: string;
|
|
119
|
+
/** A line from a note's style — a relationship's is its notation's, which says what it is. */
|
|
120
|
+
lineStyle?: BorderStyle;
|
|
121
|
+
/** What a line from a note is drawn with at its start, and at its end. */
|
|
122
|
+
sourceDecor?: LineDecoration;
|
|
123
|
+
targetDecor?: LineDecoration;
|
|
124
|
+
/** Where along a line its text sits — at its middle when absent; a text moved by hand stays where it was put. */
|
|
125
|
+
labelAnchor?: LabelAnchor;
|
|
126
|
+
/** A picture drawn in a node: an http(s) URL or a `data:image/…` URI. */
|
|
127
|
+
image?: string;
|
|
128
|
+
/** Where the picture is drawn; its top left when absent. */
|
|
129
|
+
imagePosition?: ImagePosition;
|
|
130
|
+
/** A placement's own picture in place of its notation's glyph: with `renderingMode` `IconCentric`, the figure itself. */
|
|
131
|
+
iconSymbol?: string;
|
|
132
|
+
/** Its icon is its element's picture for the presentation shown — its badge, or its figure — followed, not copied (core-vis 0.8). */
|
|
133
|
+
useElementPicture?: boolean;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export type AppearanceKey = keyof Appearance;
|
|
137
|
+
|
|
138
|
+
/** Changes to an appearance: a value sets it, `null` takes it back to the default, absent leaves it. */
|
|
139
|
+
export type AppearanceChanges = { [K in AppearanceKey]?: Appearance[K] | null };
|
|
140
|
+
|
|
141
|
+
/** The keys, in the order the Appearance tab lists them. */
|
|
142
|
+
export const APPEARANCE_KEYS: readonly AppearanceKey[] = [
|
|
143
|
+
'fillColor',
|
|
144
|
+
'gradient',
|
|
145
|
+
'lineColor',
|
|
146
|
+
'lineWidth',
|
|
147
|
+
'borderStyle',
|
|
148
|
+
'iconColor',
|
|
149
|
+
'textAlignment',
|
|
150
|
+
'textPosition',
|
|
151
|
+
'fontName',
|
|
152
|
+
'fontSize',
|
|
153
|
+
'fontStyle',
|
|
154
|
+
'fontColor',
|
|
155
|
+
'renderingMode',
|
|
156
|
+
'shapeType',
|
|
157
|
+
'lineStyle',
|
|
158
|
+
'sourceDecor',
|
|
159
|
+
'targetDecor',
|
|
160
|
+
'labelAnchor',
|
|
161
|
+
'image',
|
|
162
|
+
'imagePosition',
|
|
163
|
+
'iconSymbol',
|
|
164
|
+
'useElementPicture',
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
const ENUMERATIONS = {
|
|
168
|
+
borderStyle: { SolidLine: VIS + 'SolidLine', DashedLine: VIS + 'DashedLine', DottedLine: VIS + 'DottedLine' },
|
|
169
|
+
textAlignment: { left: VIS + 'AlignLeft', center: VIS + 'AlignCenter', right: VIS + 'AlignRight' },
|
|
170
|
+
textPosition: { top: VIS + 'PositionTop', middle: VIS + 'PositionMiddle', bottom: VIS + 'PositionBottom' },
|
|
171
|
+
gradient: { top: VIS + 'GradientTop', left: VIS + 'GradientLeft', right: VIS + 'GradientRight', bottom: VIS + 'GradientBottom' },
|
|
172
|
+
renderingMode: { ShapeWithBadge: VIS + 'ShapeWithBadge', IconCentric: VIS + 'IconCentric', ShapeOnly: VIS + 'ShapeOnly' },
|
|
173
|
+
lineStyle: { SolidLine: VIS + 'SolidLine', DashedLine: VIS + 'DashedLine', DottedLine: VIS + 'DottedLine' },
|
|
174
|
+
sourceDecor: Object.fromEntries(DECORATION_NAMES.map((name) => [name, VIS + name])) as Record<LineDecoration, string>,
|
|
175
|
+
targetDecor: Object.fromEntries(DECORATION_NAMES.map((name) => [name, VIS + name])) as Record<LineDecoration, string>,
|
|
176
|
+
labelAnchor: { source: VIS + 'AnchorSource', middle: VIS + 'AnchorMiddle', target: VIS + 'AnchorTarget' },
|
|
177
|
+
imagePosition: Object.fromEntries(IMAGE_POSITIONS.map((name) => [name, VIS + name])) as Record<ImagePosition, string>,
|
|
178
|
+
} as const satisfies Partial<Record<AppearanceKey, Record<string, string>>>;
|
|
179
|
+
|
|
180
|
+
/** Each key's predicate. */
|
|
181
|
+
export const APPEARANCE_PREDICATES: Record<AppearanceKey, string> = {
|
|
182
|
+
fillColor: VIS + 'fillColor',
|
|
183
|
+
gradient: VIS + 'gradient',
|
|
184
|
+
lineColor: VIS + 'lineColor',
|
|
185
|
+
fontColor: VIS + 'fontColor',
|
|
186
|
+
iconColor: VIS + 'iconColor',
|
|
187
|
+
lineWidth: VIS + 'lineWidth',
|
|
188
|
+
borderStyle: VIS + 'borderStyle',
|
|
189
|
+
fontName: VIS + 'fontName',
|
|
190
|
+
fontSize: VIS + 'fontSize',
|
|
191
|
+
fontStyle: VIS + 'fontStyle',
|
|
192
|
+
textAlignment: VIS + 'textAlignment',
|
|
193
|
+
textPosition: VIS + 'textPosition',
|
|
194
|
+
renderingMode: VIS + 'renderingMode',
|
|
195
|
+
shapeType: VIS + 'shapeType',
|
|
196
|
+
lineStyle: VIS + 'lineStyle',
|
|
197
|
+
sourceDecor: VIS + 'sourceDecor',
|
|
198
|
+
targetDecor: VIS + 'targetDecor',
|
|
199
|
+
labelAnchor: VIS + 'labelAnchor',
|
|
200
|
+
image: VIS + 'image',
|
|
201
|
+
imagePosition: VIS + 'imagePosition',
|
|
202
|
+
iconSymbol: VIS + 'iconSymbol',
|
|
203
|
+
useElementPicture: VIS + 'useElementPicture',
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/** How a value is written: an enumeration's member (an IRI), an integer, a boolean, or a string. */
|
|
207
|
+
export function appearanceObject(
|
|
208
|
+
key: AppearanceKey,
|
|
209
|
+
value: NonNullable<Appearance[AppearanceKey]>,
|
|
210
|
+
): { iri: string } | { integer: number } | { string: string } | { uri: string } | { boolean: boolean } | undefined {
|
|
211
|
+
if (key === 'useElementPicture') return typeof value === 'boolean' ? { boolean: value } : undefined;
|
|
212
|
+
if (isEnumeration(key)) {
|
|
213
|
+
const iri = (ENUMERATIONS[key] as Record<string, string>)[String(value)];
|
|
214
|
+
return iri ? { iri } : undefined;
|
|
215
|
+
}
|
|
216
|
+
if (key === 'shapeType') {
|
|
217
|
+
const iri = String(value).trim();
|
|
218
|
+
return /^[a-z][\w+.-]*:/i.test(iri) ? { iri } : undefined;
|
|
219
|
+
}
|
|
220
|
+
if (key === 'lineWidth' || key === 'fontSize') {
|
|
221
|
+
const n = Math.round(Number(value));
|
|
222
|
+
return Number.isFinite(n) && n >= 1 ? { integer: n } : undefined;
|
|
223
|
+
}
|
|
224
|
+
if (key === 'fontStyle') {
|
|
225
|
+
const style = fontStyleOf(String(value));
|
|
226
|
+
return style ? { string: style } : undefined;
|
|
227
|
+
}
|
|
228
|
+
if (key === 'image' || key === 'iconSymbol') {
|
|
229
|
+
const uri = imageUri(String(value));
|
|
230
|
+
return uri ? { uri } : undefined;
|
|
231
|
+
}
|
|
232
|
+
const text = String(value).trim();
|
|
233
|
+
return text ? { string: text } : undefined;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** A value as read from a style: `undefined` for what is not one of the key's. */
|
|
237
|
+
export function appearanceValue<K extends AppearanceKey>(key: K, term: { termType: string; value: string }): Appearance[K] | undefined {
|
|
238
|
+
const value = term.value.trim();
|
|
239
|
+
if (isEnumeration(key)) {
|
|
240
|
+
const members = ENUMERATIONS[key] as Record<string, string>;
|
|
241
|
+
return Object.keys(members).find((member) => members[member] === value) as Appearance[K] | undefined;
|
|
242
|
+
}
|
|
243
|
+
if (key === 'shapeType') return (term.termType === 'NamedNode' ? value : undefined) as Appearance[K] | undefined;
|
|
244
|
+
if (key === 'lineWidth' || key === 'fontSize') {
|
|
245
|
+
const n = Number(value);
|
|
246
|
+
return (Number.isFinite(n) && n > 0 ? n : undefined) as Appearance[K] | undefined;
|
|
247
|
+
}
|
|
248
|
+
if (key === 'fontStyle') return fontStyleOf(value) as Appearance[K] | undefined;
|
|
249
|
+
if (key === 'image' || key === 'iconSymbol') return (term.termType === 'Literal' ? imageUri(value) : undefined) as Appearance[K] | undefined;
|
|
250
|
+
if (key === 'useElementPicture') {
|
|
251
|
+
const flag = value === 'true' || value === '1' ? true : value === 'false' || value === '0' ? false : undefined;
|
|
252
|
+
return (term.termType === 'Literal' ? flag : undefined) as Appearance[K] | undefined;
|
|
253
|
+
}
|
|
254
|
+
if (key === 'fillColor' || key === 'lineColor' || key === 'fontColor' || key === 'iconColor') {
|
|
255
|
+
return (value ? cssColour(value) : undefined) as Appearance[K] | undefined;
|
|
256
|
+
}
|
|
257
|
+
return (value || undefined) as Appearance[K] | undefined;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function isEnumeration(key: AppearanceKey): key is keyof typeof ENUMERATIONS {
|
|
261
|
+
return key in ENUMERATIONS;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* A picture's address as drawn: an http(s) URL, or a `data:` URI of an image —
|
|
266
|
+
* `undefined` for anything else (a `javascript:` or a `file:` URI, a relative
|
|
267
|
+
* path), which is neither written nor drawn.
|
|
268
|
+
*/
|
|
269
|
+
export function imageUri(value: string | undefined): string | undefined {
|
|
270
|
+
const uri = value?.trim();
|
|
271
|
+
if (!uri) return undefined;
|
|
272
|
+
if (/^data:image\/[a-z0-9.+-]+[;,]/i.test(uri)) return uri;
|
|
273
|
+
try {
|
|
274
|
+
const url = new URL(uri);
|
|
275
|
+
return url.protocol === 'https:' || url.protocol === 'http:' ? uri : undefined;
|
|
276
|
+
} catch {
|
|
277
|
+
return undefined;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const FONT_STYLES = ['bold', 'italic', 'underline'] as const;
|
|
282
|
+
|
|
283
|
+
/** A font style's keywords, known ones only, in order; `undefined` for plain. */
|
|
284
|
+
export function fontStyleOf(style: string | undefined): string | undefined {
|
|
285
|
+
const words = new Set((style ?? '').toLowerCase().split(/\s+/));
|
|
286
|
+
const kept = FONT_STYLES.filter((word) => words.has(word));
|
|
287
|
+
return kept.length > 0 ? kept.join(' ') : undefined;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** Whether a font style has a keyword. */
|
|
291
|
+
export function hasFontStyle(style: string | undefined, word: (typeof FONT_STYLES)[number]): boolean {
|
|
292
|
+
return (style ?? '').split(/\s+/).includes(word);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// ── Colours ─────────────────────────────────────────────────────────────
|
|
296
|
+
|
|
297
|
+
/** A colour's red, green and blue (0–255) and alpha (0–1); `undefined` for what la-gram cannot read. */
|
|
298
|
+
export function parseColour(colour: string | undefined): { r: number; g: number; b: number; a: number } | undefined {
|
|
299
|
+
const value = colour?.trim().toLowerCase();
|
|
300
|
+
if (!value) return undefined;
|
|
301
|
+
const hex = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(value)?.[1];
|
|
302
|
+
if (hex) {
|
|
303
|
+
const full = hex.length <= 4 ? [...hex].map((c) => c + c).join('') : hex;
|
|
304
|
+
const byte = (i: number) => parseInt(full.slice(i * 2, i * 2 + 2), 16);
|
|
305
|
+
return { r: byte(0), g: byte(1), b: byte(2), a: full.length === 8 ? round3(byte(3) / 255) : 1 };
|
|
306
|
+
}
|
|
307
|
+
const rgb = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*([\d.]+)\s*(%?)\s*)?\)$/.exec(value);
|
|
308
|
+
if (!rgb) return undefined;
|
|
309
|
+
const channel = (i: number) => Math.min(255, Number(rgb[i]));
|
|
310
|
+
return { r: channel(1), g: channel(2), b: channel(3), a: alphaOf(rgb[4], rgb[5] === '%') };
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* An `rgba()` alpha as meant: CSS's 0–1, a percentage — the exchange format's,
|
|
315
|
+
* written as it is, up to 100 — or out of 255 beyond it.
|
|
316
|
+
*/
|
|
317
|
+
function alphaOf(text: string | undefined, percent: boolean): number {
|
|
318
|
+
if (text === undefined) return 1;
|
|
319
|
+
const n = Number(text);
|
|
320
|
+
if (!Number.isFinite(n)) return 1;
|
|
321
|
+
if (percent) return clamp01(n / 100);
|
|
322
|
+
if (n <= 1) return clamp01(n);
|
|
323
|
+
return clamp01(n <= 100 ? n / 100 : n / 255);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* A colour as CSS should draw it: `#rrggbb`, or `#rrggbbaa` when it is not
|
|
328
|
+
* opaque — its alpha read as meant (see the module's notes). A colour la-gram
|
|
329
|
+
* cannot read (a name: `red`) is kept as it is.
|
|
330
|
+
*/
|
|
331
|
+
export function cssColour(colour: string): string {
|
|
332
|
+
const parts = parseColour(colour);
|
|
333
|
+
if (!parts) return colour.trim();
|
|
334
|
+
return withAlpha(hexOf(parts), parts.a);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** A colour as `#rrggbb`, what a colour picker shows; `undefined` for what la-gram cannot read. */
|
|
338
|
+
export function hexColour(colour: string | undefined): string | undefined {
|
|
339
|
+
const parts = parseColour(colour);
|
|
340
|
+
return parts ? hexOf(parts) : undefined;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** A colour's opacity, 0–1: 1 for an opaque one, or one la-gram cannot read. */
|
|
344
|
+
export function colourAlpha(colour: string | undefined): number {
|
|
345
|
+
return parseColour(colour)?.a ?? 1;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** `#rrggbb` at `alpha` (0–1): itself when opaque, else `#rrggbbaa`. */
|
|
349
|
+
export function withAlpha(hex: string, alpha: number): string {
|
|
350
|
+
const base = hexColour(hex) ?? hex;
|
|
351
|
+
const a = clamp01(alpha);
|
|
352
|
+
return a >= 1 ? base : `${base}${Math.round(a * 255).toString(16).padStart(2, '0')}`;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function hexOf(parts: { r: number; g: number; b: number }): string {
|
|
356
|
+
return `#${[parts.r, parts.g, parts.b].map((c) => c.toString(16).padStart(2, '0')).join('')}`;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function clamp01(n: number): number {
|
|
360
|
+
return Math.min(1, Math.max(0, n));
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function round3(n: number): number {
|
|
364
|
+
return Math.round(n * 1000) / 1000;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** Whether two appearances say the same. */
|
|
368
|
+
export function sameAppearance(a: Appearance | undefined, b: Appearance | undefined): boolean {
|
|
369
|
+
return APPEARANCE_KEYS.every((key) => (a?.[key] ?? undefined) === (b?.[key] ?? undefined));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** The look a style — a notation's, a thing's own — says, from whatever of the keys it has. */
|
|
373
|
+
export function lookOf(style: object | undefined): Appearance {
|
|
374
|
+
const look: Record<string, unknown> = {};
|
|
375
|
+
if (!style) return look as Appearance;
|
|
376
|
+
for (const key of APPEARANCE_KEYS) {
|
|
377
|
+
// A notation's shape type is the shape's local name, not a placement's IRI; its icon is its glyph,
|
|
378
|
+
// not a placement's own picture: neither a look to take over — nor whether a placement shows its element's picture.
|
|
379
|
+
if (key === 'shapeType' || key === 'iconSymbol' || key === 'useElementPicture') continue;
|
|
380
|
+
const value = (style as Record<string, unknown>)[key];
|
|
381
|
+
if (value !== undefined && value !== null) look[key] = value;
|
|
382
|
+
}
|
|
383
|
+
return look as Appearance;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** An appearance with nothing set is none. */
|
|
387
|
+
export function appearanceOrNone(appearance: Appearance): Appearance | undefined {
|
|
388
|
+
return APPEARANCE_KEYS.some((key) => appearance[key] !== undefined) ? appearance : undefined;
|
|
389
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What "delete from the model" removes.
|
|
3
|
+
*
|
|
4
|
+
* Both deletions are computed as a set of quads first and removed second. The
|
|
5
|
+
* set doubles as the undo snapshot — putting exactly those quads back restores
|
|
6
|
+
* the model, every view that showed the concept, and every route — which is
|
|
7
|
+
* why the managers expose `collect…` twins of their deletes.
|
|
8
|
+
*
|
|
9
|
+
* ## A relationship
|
|
10
|
+
*
|
|
11
|
+
* - the qualified resource (every triple with it as subject);
|
|
12
|
+
* - the qualified predicate leading to it from its source (`am4:qualifiedServing`,
|
|
13
|
+
* or core's `arch:hasQualifiedRelationship`), which would otherwise point at
|
|
14
|
+
* nothing;
|
|
15
|
+
* - its unqualified triple `source predicate target` — unless another qualified
|
|
16
|
+
* resource of the same kind still connects the same pair, in which case the
|
|
17
|
+
* triple is still true and stays;
|
|
18
|
+
* - every `arch-vis:Link` drawing it, in any view, with its route and its label node;
|
|
19
|
+
* - its `arch:inView` statements (they are its own triples, covered above).
|
|
20
|
+
*
|
|
21
|
+
* ## An element
|
|
22
|
+
*
|
|
23
|
+
* - every relationship with it at either end, as above;
|
|
24
|
+
* - every `arch-vis:ArchNode` placing it, in any view, and every link ending at
|
|
25
|
+
* those nodes;
|
|
26
|
+
* - every triple with it as subject, and every triple pointing at it.
|
|
27
|
+
*
|
|
28
|
+
* Retired endpoint vocabulary (`arch:relSource` / `arch:relTarget`) is matched
|
|
29
|
+
* as well, so relationships in a model that predates the migration still
|
|
30
|
+
* cascade.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import type { NamedNode, Quad, Term } from '@rdfjs/types';
|
|
34
|
+
import type { RdfStore } from '../rdf-engine/interfaces.js';
|
|
35
|
+
import { NAMESPACES } from '../rdf-engine/namespaces.js';
|
|
36
|
+
import { CUSTOM_PROPERTY } from './custom-properties.js';
|
|
37
|
+
import { IRI, T, dedupe, nn, relationshipClassAmong } from './vocabulary.js';
|
|
38
|
+
|
|
39
|
+
const RDFS_RANGE = nn(NAMESPACES.rdfs + 'range');
|
|
40
|
+
|
|
41
|
+
/** Endpoint predicates on a qualified relationship, current first. */
|
|
42
|
+
const ENDPOINTS = [IRI.source, IRI.target, IRI.legacyRelSource, IRI.legacyRelTarget].map(nn);
|
|
43
|
+
|
|
44
|
+
function objects(store: RdfStore, subject: Term, predicate: NamedNode): string[] {
|
|
45
|
+
return store.getQuads(subject as NamedNode, predicate).map((q) => q.object.value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The unqualified predicate a relationship class maps to, from any graph. */
|
|
49
|
+
export function unqualifiedFormOf(store: RdfStore, classIri: string): string | undefined {
|
|
50
|
+
return store.getQuads(nn(classIri), T.unqualifiedForm)[0]?.object.value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A relationship class's qualified predicate — the property from a source to
|
|
55
|
+
* its relationship resource, which a metamodel declares with the class as its
|
|
56
|
+
* `rdfs:range` and an `arch:unqualifiedForm` (`am4:qualifiedRealization` for
|
|
57
|
+
* `am4:Realization`) — or its nearest superclass's — else core's fallback, `arch:hasQualifiedRelationship`.
|
|
58
|
+
*/
|
|
59
|
+
export function qualifiedFormOf(store: RdfStore, classIri: string): string {
|
|
60
|
+
// The class's own, else the nearest superclass's: a kind of relationship with no qualified property of its own
|
|
61
|
+
// (the decision extension's Supporting Influence, a kind of Force Influence) is reached by its parent's.
|
|
62
|
+
const RDFS_SUBCLASS = nn(NAMESPACES.rdfs + 'subClassOf');
|
|
63
|
+
const seen = new Set<string>();
|
|
64
|
+
for (let level = [classIri]; level.length > 0; ) {
|
|
65
|
+
for (const cls of level) {
|
|
66
|
+
seen.add(cls);
|
|
67
|
+
const declared = store
|
|
68
|
+
.getQuads(null, RDFS_RANGE, nn(cls))
|
|
69
|
+
.map((q) => q.subject)
|
|
70
|
+
.find((p) => p.termType === 'NamedNode' && store.getQuads(p as NamedNode, T.unqualifiedForm).length > 0);
|
|
71
|
+
if (declared) return declared.value;
|
|
72
|
+
}
|
|
73
|
+
level = level
|
|
74
|
+
.flatMap((cls) => store.getQuads(nn(cls), RDFS_SUBCLASS).map((q) => q.object))
|
|
75
|
+
.filter((o) => o.termType === 'NamedNode' && !seen.has(o.value))
|
|
76
|
+
.map((o) => o.value);
|
|
77
|
+
}
|
|
78
|
+
return IRI.hasQualifiedRelationship;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Whether a predicate leads from a relationship's source to its resource:
|
|
83
|
+
* core's fallback, or a property a metamodel declares an `arch:unqualifiedForm`
|
|
84
|
+
* for (only qualified predicates and relationship classes have one, and a
|
|
85
|
+
* class is never a predicate).
|
|
86
|
+
*/
|
|
87
|
+
export function isQualifiedPredicate(store: RdfStore, predicateIri: string): boolean {
|
|
88
|
+
return predicateIri === IRI.hasQualifiedRelationship || store.getQuads(nn(predicateIri), T.unqualifiedForm).length > 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The quads leading from a relationship's source to it by a qualified predicate — whichever one the data uses. */
|
|
92
|
+
export function qualifiedPointerQuads(store: RdfStore, relationshipIri: string, sourceIri: string): Quad[] {
|
|
93
|
+
return store
|
|
94
|
+
.getQuads(nn(sourceIri), null, nn(relationshipIri))
|
|
95
|
+
.filter((q) => isQualifiedPredicate(store, q.predicate.value));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The relationship class of a qualified resource: its type other than the core's generic ones. */
|
|
99
|
+
export function relationshipClassOf(store: RdfStore, relationshipIri: string): string | undefined {
|
|
100
|
+
return relationshipClassAmong(objects(store, nn(relationshipIri), T.rdfType));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The quads of a link: its own, its point list cells and points — and those of
|
|
105
|
+
* every link ending on it (core-vis 0.6), which cannot outlive it.
|
|
106
|
+
*/
|
|
107
|
+
/**
|
|
108
|
+
* What goes with a diagram element or a concept that nothing else uses: a
|
|
109
|
+
* node's or a link's own styles (`arch-vis:style`, each context's too) and the label expressions they
|
|
110
|
+
* gives (core-vis 0.7), and a concept's SKOS-XL names and pictures (core 0.5.0)
|
|
111
|
+
* — each only when no other subject points at it.
|
|
112
|
+
*/
|
|
113
|
+
function ownedQuads(store: RdfStore, subject: Term): Quad[] {
|
|
114
|
+
const quads: Quad[] = [];
|
|
115
|
+
const alone = (predicate: NamedNode, object: Term) => store.getQuads(null, predicate, object as NamedNode).length <= 1;
|
|
116
|
+
for (const style of store.getQuads(subject as NamedNode, T.visStyle)) {
|
|
117
|
+
if (style.object.termType === 'Literal' || !alone(T.visStyle, style.object)) continue;
|
|
118
|
+
quads.push(...store.getQuads(style.object as NamedNode, null, null));
|
|
119
|
+
for (const label of store.getQuads(style.object as NamedNode, T.labelExpression)) {
|
|
120
|
+
if (label.object.termType !== 'Literal' && alone(T.labelExpression, label.object)) quads.push(...store.getQuads(label.object as NamedNode, null, null));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
for (const name of store.getQuads(subject as NamedNode, T.skosxlAltLabel)) {
|
|
124
|
+
if (name.object.termType !== 'Literal' && alone(T.skosxlAltLabel, name.object)) quads.push(...store.getQuads(name.object as NamedNode, null, null));
|
|
125
|
+
}
|
|
126
|
+
// Its custom properties (KD-12): a pair nothing else points at.
|
|
127
|
+
for (const pair of store.getQuads(subject as NamedNode, nn(CUSTOM_PROPERTY))) {
|
|
128
|
+
if (pair.object.termType !== 'NamedNode' || store.getQuads(null, null, pair.object as NamedNode).length > 1) continue;
|
|
129
|
+
quads.push(...store.getQuads(pair.object as NamedNode, null, null));
|
|
130
|
+
}
|
|
131
|
+
// Its pictures (core 0.5.0): an ImageObject nothing else points at — not a published image's own IRI.
|
|
132
|
+
for (const predicate of [T.prefVisNotation, T.altVisNotation]) {
|
|
133
|
+
for (const picture of store.getQuads(subject as NamedNode, predicate)) {
|
|
134
|
+
if (picture.object.termType === 'Literal' || store.getQuads(null, null, picture.object as NamedNode).length > 1) continue;
|
|
135
|
+
quads.push(...store.getQuads(picture.object as NamedNode, null, null));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return quads;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function linkQuads(store: RdfStore, link: Term, seen: Set<string> = new Set()): Quad[] {
|
|
142
|
+
if (seen.has(link.value)) return [];
|
|
143
|
+
seen.add(link.value);
|
|
144
|
+
// Its own style goes with it.
|
|
145
|
+
const quads = [...store.getQuads(link as NamedNode, null, null), ...ownedQuads(store, link)];
|
|
146
|
+
// Its label node — where its name was moved to — goes with it.
|
|
147
|
+
for (const label of store.getQuads(link as NamedNode, T.visLabel)) quads.push(...store.getQuads(label.object as NamedNode, null, null));
|
|
148
|
+
for (const end of [T.visSource, T.visTarget]) {
|
|
149
|
+
for (const attached of store.getQuads(null, end, link as NamedNode)) quads.push(...linkQuads(store, attached.subject, seen));
|
|
150
|
+
}
|
|
151
|
+
let cell = objects(store, link, T.points)[0];
|
|
152
|
+
const guard = new Set<string>();
|
|
153
|
+
while (cell && cell !== IRI.rdfNil && !guard.has(cell)) {
|
|
154
|
+
guard.add(cell);
|
|
155
|
+
for (const point of objects(store, nn(cell), T.rdfFirst)) {
|
|
156
|
+
quads.push(...store.getQuads(nn(point), null, null));
|
|
157
|
+
}
|
|
158
|
+
quads.push(...store.getQuads(nn(cell), null, null));
|
|
159
|
+
cell = objects(store, nn(cell), T.rdfRest)[0];
|
|
160
|
+
}
|
|
161
|
+
return quads;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Everything that goes when a qualified relationship is deleted from the model —
|
|
166
|
+
* with every relationship whose source or target it is, as an element takes the
|
|
167
|
+
* relationships at its ends.
|
|
168
|
+
*/
|
|
169
|
+
export function collectRelationshipQuads(store: RdfStore, relationshipIri: string, seen: Set<string> = new Set()): Quad[] {
|
|
170
|
+
if (seen.has(relationshipIri)) return [];
|
|
171
|
+
seen.add(relationshipIri);
|
|
172
|
+
const rel = nn(relationshipIri);
|
|
173
|
+
// Its names for each audience go with it.
|
|
174
|
+
const quads: Quad[] = [...store.getQuads(rel, null, null), ...ownedQuads(store, rel)];
|
|
175
|
+
|
|
176
|
+
// The unqualified triple, unless a sibling occurrence keeps it true.
|
|
177
|
+
const sourceIri = objects(store, rel, T.source)[0] ?? objects(store, rel, nn(IRI.legacyRelSource))[0];
|
|
178
|
+
const targetIri = objects(store, rel, T.target)[0] ?? objects(store, rel, nn(IRI.legacyRelTarget))[0];
|
|
179
|
+
if (sourceIri) quads.push(...qualifiedPointerQuads(store, relationshipIri, sourceIri));
|
|
180
|
+
const classIri = relationshipClassOf(store, relationshipIri);
|
|
181
|
+
const predicateIri =
|
|
182
|
+
(classIri && unqualifiedFormOf(store, classIri)) ??
|
|
183
|
+
objects(store, rel, nn(IRI.legacyRelPredicate))[0];
|
|
184
|
+
if (sourceIri && targetIri && predicateIri) {
|
|
185
|
+
const siblings = store
|
|
186
|
+
.getQuads(null, T.source, nn(sourceIri))
|
|
187
|
+
.map((q) => q.subject.value)
|
|
188
|
+
.filter(
|
|
189
|
+
(other) =>
|
|
190
|
+
other !== relationshipIri &&
|
|
191
|
+
objects(store, nn(other), T.target).includes(targetIri) &&
|
|
192
|
+
relationshipClassOf(store, other) === classIri,
|
|
193
|
+
);
|
|
194
|
+
if (siblings.length === 0) {
|
|
195
|
+
quads.push(...store.getQuads(nn(sourceIri), nn(predicateIri), nn(targetIri)));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Every link drawing it, in every view.
|
|
200
|
+
for (const q of store.getQuads(null, T.archRelationship, rel)) {
|
|
201
|
+
quads.push(...linkQuads(store, q.subject));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// A relationship ending on this one cannot outlive it.
|
|
205
|
+
for (const other of relationshipsTouching(store, relationshipIri)) {
|
|
206
|
+
quads.push(...collectRelationshipQuads(store, other, seen));
|
|
207
|
+
}
|
|
208
|
+
return dedupe(quads);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Qualified relationships with the element at either end. */
|
|
212
|
+
export function relationshipsTouching(store: RdfStore, elementIri: string): string[] {
|
|
213
|
+
const element = nn(elementIri);
|
|
214
|
+
const rels = new Set<string>();
|
|
215
|
+
for (const predicate of ENDPOINTS) {
|
|
216
|
+
for (const q of store.getQuads(null, predicate, element)) rels.add(q.subject.value);
|
|
217
|
+
}
|
|
218
|
+
return [...rels];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** Everything that goes when an element is deleted from the model. */
|
|
222
|
+
export function collectElementQuads(store: RdfStore, elementIri: string): Quad[] {
|
|
223
|
+
const element = nn(elementIri);
|
|
224
|
+
const quads: Quad[] = [];
|
|
225
|
+
|
|
226
|
+
for (const rel of relationshipsTouching(store, elementIri)) {
|
|
227
|
+
quads.push(...collectRelationshipQuads(store, rel));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
for (const q of store.getQuads(null, T.archElement, element)) {
|
|
231
|
+
const node = q.subject;
|
|
232
|
+
// A placement's own style — its look, what its label says — goes with it.
|
|
233
|
+
quads.push(...store.getQuads(node as NamedNode, null, null), ...ownedQuads(store, node));
|
|
234
|
+
for (const end of [T.visSource, T.visTarget]) {
|
|
235
|
+
for (const link of store.getQuads(null, end, node as NamedNode)) {
|
|
236
|
+
quads.push(...linkQuads(store, link.subject));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
quads.push(...store.getQuads(element, null, null));
|
|
242
|
+
// Its names for each audience.
|
|
243
|
+
quads.push(...ownedQuads(store, element));
|
|
244
|
+
quads.push(...store.getQuads(null, null, element).filter((q) => q.graph.termType === 'DefaultGraph'));
|
|
245
|
+
return dedupe(quads);
|
|
246
|
+
}
|