yarramate 1.38.0 → 1.40.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.
@@ -1,2 +1,4 @@
1
1
  export { projectGraphForCanvas, type CanvasGraph, type CanvasNode, type CanvasEdge, } from '../graph-projection.js';
2
2
  export { foldTree, foldGraph, nestingTree, liftedEdgeId, NESTING_KIND_IDS, type FoldInput, type FoldNode, type FoldEdge, type FoldMembership, type FoldTree, type LiftedEdge, type NestingConflict, type SlotWiring, } from '../fold-tree.js';
3
+ export { edgeLabelText, type EdgeLabelData } from '../edge-label.js';
4
+ export { DEFAULT_LAYOUT, LAYOUT_MODES, type LayoutMode } from '../layout-mode.js';
@@ -5,3 +5,9 @@ export { projectGraphForCanvas, } from '../graph-projection.js';
5
5
  // an application is made of. `fold-tree.ts` imports nothing, so this subpath
6
6
  // stays runtime-neutral.
7
7
  export { foldTree, foldGraph, nestingTree, liftedEdgeId, NESTING_KIND_IDS, } from '../fold-tree.js';
8
+ // What an edge says (ADR 0147) and the mode list it depends on (#587). The
9
+ // editor entry has exported these since #576, but that entry is the mounted
10
+ // editor, so a Worker importing one pure function from it took React and
11
+ // cytoscape too. `edge-label.ts` and `layout-mode.ts` reach no package.
12
+ export { edgeLabelText } from '../edge-label.js';
13
+ export { DEFAULT_LAYOUT, LAYOUT_MODES } from '../layout-mode.js';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * What an edge says, kept in a module that imports nothing with a runtime of
3
+ * its own (#587). The canvas draws with it; a host that renders the same
4
+ * picture somewhere else, a server-side SVG Worker, imports it from
5
+ * `yarramate/adapter/visual-graph` without taking elkjs, React or cytoscape.
6
+ * It was first published from the editor entry (#576), which is where a
7
+ * consumer could not use it.
8
+ */
9
+ import { type LayoutMode } from './layout-mode.js';
10
+ /** The data fields an edge's label is decided from. */
11
+ export interface EdgeLabelData {
12
+ readonly name?: string | null;
13
+ readonly kindLabel?: string;
14
+ readonly coreKindLabel?: string;
15
+ /** An extension kind with a reading of its own (ADR 0159), else absent. */
16
+ readonly readingKind?: string;
17
+ /** A reading the endpoints decided (ADR 0160), else absent. */
18
+ readonly reading?: string;
19
+ readonly liftedCount?: number;
20
+ }
21
+ /**
22
+ * The one place that decides what an edge says (ADR 0147).
23
+ *
24
+ * A named relationship says its name. An unnamed one says its reading -
25
+ * "serves", or "served by" where the mode layers the served element above -
26
+ * unless kind labels are off, in which case the line style and arrowhead
27
+ * carry the kind alone. An extension kind has no reading in the table and is
28
+ * spelled out from its own name ("deploys to" for `deploys-to`), in the active
29
+ * voice whichever way it is layered, because nobody can conjugate a verb they
30
+ * have not seen. A lifted edge stands for several relationships and says how
31
+ * many.
32
+ */
33
+ export declare const edgeLabelText: (data: EdgeLabelData, mode: LayoutMode, showKindLabels: boolean) => string;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * What an edge says, kept in a module that imports nothing with a runtime of
3
+ * its own (#587). The canvas draws with it; a host that renders the same
4
+ * picture somewhere else, a server-side SVG Worker, imports it from
5
+ * `yarramate/adapter/visual-graph` without taking elkjs, React or cytoscape.
6
+ * It was first published from the editor entry (#576), which is where a
7
+ * consumer could not use it.
8
+ */
9
+ import { LAYERING_REVERSED_KINDS, reversesForLayering } from './layout-mode.js';
10
+ import { humanizeKind, relationshipReading } from './relationship-reading.js';
11
+ /**
12
+ * The one place that decides what an edge says (ADR 0147).
13
+ *
14
+ * A named relationship says its name. An unnamed one says its reading -
15
+ * "serves", or "served by" where the mode layers the served element above -
16
+ * unless kind labels are off, in which case the line style and arrowhead
17
+ * carry the kind alone. An extension kind has no reading in the table and is
18
+ * spelled out from its own name ("deploys to" for `deploys-to`), in the active
19
+ * voice whichever way it is layered, because nobody can conjugate a verb they
20
+ * have not seen. A lifted edge stands for several relationships and says how
21
+ * many.
22
+ */
23
+ export const edgeLabelText = (data, mode, showKindLabels) => {
24
+ if (typeof data.name === 'string' && data.name !== '')
25
+ return data.name;
26
+ if (!showKindLabels)
27
+ return '';
28
+ const core = data.coreKindLabel ?? '';
29
+ const kind = data.kindLabel ?? core;
30
+ const readingKind = data.readingKind;
31
+ const reading = data.reading !== undefined && data.reading !== ''
32
+ ? data.reading
33
+ : readingKind !== undefined && readingKind !== core
34
+ ? relationshipReading(readingKind)
35
+ : kind !== core && kind !== ''
36
+ ? humanizeKind(kind)
37
+ : relationshipReading(core, reversesForLayering(mode) && LAYERING_REVERSED_KINDS.has(core));
38
+ const count = typeof data.liftedCount === 'number' ? data.liftedCount : 0;
39
+ return count > 1 ? `${reading} ×${count}` : reading;
40
+ };
@@ -9,7 +9,7 @@
9
9
  // file and not a runtime one; the two pure helpers imported below are
10
10
  // all the runtime still takes from ajv.
11
11
  //
12
- // schema/ sha256: 8a400593d350c8577da31613cd6b55f1a75d187699722524d375c3898a318913
12
+ // schema/ sha256: fdfda188cef519c631c9842d886983873df0cc520b56f3c74050edbb1aebb9fb
13
13
  import ajvRuntime0Module from 'ajv/dist/runtime/ucs2length.js';
14
14
  const ajvRuntime0 = ajvRuntime0Module.default ?? ajvRuntime0Module;
15
15
  import ajvRuntime1Module from 'ajv/dist/runtime/equal.js';
@@ -11877,7 +11877,7 @@ else {
11877
11877
  } validate74.errors = vErrors; return errors === 0; }
11878
11878
  validate74.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
11879
11879
  export const validateVisualLayout = validate82;
11880
- const schema187 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://yarramate.org/schema/visual-layout/v1", "title": "YarraMate visual layout", "description": "Adapter-owned drag-position sidecar for one saved projection's canvas (ADR 0023). Never validated by Core, never routed through apply.", "type": "object", "additionalProperties": false, "required": ["format", "projectionId", "positions"], "properties": { "format": { "const": "yarramate/visual-layout/v1" }, "projectionId": { "$ref": "https://yarramate.org/schema/projection/v1#/$defs/id" }, "positions": { "$ref": "#/$defs/positions" }, "folded": { "description": "The instances this view draws folded (#473). Written WITH the positions in the same document and always in full, never as a patch: a reader that half-applies a fold state draws a box whose contents are somewhere else on the canvas. Absent means the view's own `presentation.fold` decides.", "$ref": "#/$defs/subjectIds" }, "unfolded": { "description": "The instances this view draws OPEN even though `presentation.fold` says to fold them (#473). Two lists rather than one, because a reader who opened a box must not have it close again the moment the view's default is read back.", "$ref": "#/$defs/subjectIds" }, "routes": { "description": "The routes the canvas was drawing when the positions were saved (ADR 0147), keyed by relationship id, in absolute canvas coordinates from the source end. A route is applied only while both of its ends still sit where `positions` says; an edge whose end has moved draws straight. Absent means the layout recomputes every route.", "$ref": "#/$defs/routes" } }, "$defs": { "subjectIds": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } }, "positions": { "type": "object", "propertyNames": { "type": "string", "minLength": 1 }, "additionalProperties": { "$ref": "#/$defs/position" } }, "position": { "type": "object", "additionalProperties": false, "required": ["x", "y"], "properties": { "x": { "type": "number" }, "y": { "type": "number" } } }, "routes": { "type": "object", "propertyNames": { "type": "string", "minLength": 1 }, "additionalProperties": { "$ref": "#/$defs/route" } }, "route": { "type": "object", "additionalProperties": false, "required": ["points", "labelAt"], "properties": { "points": { "description": "Source end first, both endpoints included, so a route is never fewer than two points.", "type": "array", "minItems": 2, "items": { "$ref": "#/$defs/position" } }, "labelAt": { "description": "How far along the route, in px from the source end, the label's centre sits; null for a route with no label.", "type": ["number", "null"] } } } } };
11880
+ const schema187 = { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://yarramate.org/schema/visual-layout/v1", "title": "YarraMate visual layout", "description": "Adapter-owned drag-position sidecar for one saved projection's canvas (ADR 0023). Never validated by Core, never routed through apply.", "type": "object", "additionalProperties": false, "required": ["format", "projectionId", "positions"], "properties": { "format": { "const": "yarramate/visual-layout/v1" }, "projectionId": { "$ref": "https://yarramate.org/schema/projection/v1#/$defs/id" }, "positions": { "description": "Where the canvas put each subject the view draws, keyed by subject id, in absolute canvas coordinates. Written for the view's own subjects and the boxes that hold them, including any the quick filter or a fold hides at save time; a subject outside the view has no entry (#578). Entries are of three kinds, and only two are INPUT. A LEAF's entry is input: the canvas pins the subject there. A FOLDED box's entry is input: a folded box is drawn as a leaf, so it is pinned there like one. An UNFOLDED box's entry is TESTIMONY, not input: a box's centre is derived from its members (#507), so the entry records where the canvas drew it at save time, a few pixels stale if saved mid-drag, and is never read back. A reader drawing the same picture must place an unfolded box from its members, not from this entry. Files written before 1.40 may carry entries for subjects outside the view; they are inert (#273).", "$ref": "#/$defs/positions" }, "folded": { "description": "The instances this view draws folded (#473). Written WITH the positions in the same document and always in full, never as a patch: a reader that half-applies a fold state draws a box whose contents are somewhere else on the canvas. Absent means the view's own `presentation.fold` decides.", "$ref": "#/$defs/subjectIds" }, "unfolded": { "description": "The instances this view draws OPEN even though `presentation.fold` says to fold them (#473). Two lists rather than one, because a reader who opened a box must not have it close again the moment the view's default is read back.", "$ref": "#/$defs/subjectIds" }, "routes": { "description": "The routes the canvas was drawing when the positions were saved (ADR 0147), keyed by relationship id, in absolute canvas coordinates from the source end. A route is applied only while both of its ends still sit where `positions` says; an edge whose end has moved draws straight. Absent means the layout recomputes every route.", "$ref": "#/$defs/routes" } }, "$defs": { "subjectIds": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } }, "positions": { "type": "object", "propertyNames": { "type": "string", "minLength": 1 }, "additionalProperties": { "$ref": "#/$defs/position" } }, "position": { "type": "object", "additionalProperties": false, "required": ["x", "y"], "properties": { "x": { "type": "number" }, "y": { "type": "number" } } }, "routes": { "type": "object", "propertyNames": { "type": "string", "minLength": 1 }, "additionalProperties": { "$ref": "#/$defs/route" } }, "route": { "type": "object", "additionalProperties": false, "required": ["points", "labelAt"], "properties": { "points": { "description": "Source end first, both endpoints included, so a route is never fewer than two points.", "type": "array", "minItems": 2, "items": { "$ref": "#/$defs/position" } }, "labelAt": { "description": "How far along the route, in px from the source end, the label's centre sits; null for a route with no label.", "type": ["number", "null"] } } } } };
11881
11881
  const schema191 = { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } };
11882
11882
  const schema189 = { "type": "object", "propertyNames": { "type": "string", "minLength": 1 }, "additionalProperties": { "$ref": "#/$defs/position" } };
11883
11883
  const schema190 = { "type": "object", "additionalProperties": false, "required": ["x", "y"], "properties": { "x": { "type": "number" }, "y": { "type": "number" } } };