glassbrain 0.2.0-alpha.3 → 0.2.0-alpha.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/dist/core.js CHANGED
@@ -1,10 +1,9 @@
1
1
  import {
2
- MAX_DERIVED_LAYERS,
3
2
  childrenMap,
4
3
  deriveLayers,
5
4
  layerIndexOf,
6
5
  orderedChildren
7
- } from "./chunks/chunk-QJ4B3U76.js";
6
+ } from "./chunks/chunk-G7XWVKHN.js";
8
7
  import {
9
8
  CONTENT_SCALE,
10
9
  DARK_THEME,
@@ -35,6 +34,7 @@ import {
35
34
  buildModel,
36
35
  changedSubset,
37
36
  checkEdit,
37
+ checkNativeEdit,
38
38
  chromeStyle,
39
39
  cls,
40
40
  countByKind,
@@ -43,7 +43,9 @@ import {
43
43
  defineProfile,
44
44
  diffModels,
45
45
  diffStyle,
46
+ edgeKindClass,
46
47
  edgesOf,
48
+ encodeParent,
47
49
  graphStyle,
48
50
  hasChanges,
49
51
  indexModel,
@@ -76,10 +78,10 @@ import {
76
78
  untheme,
77
79
  validateModel,
78
80
  validateStructure
79
- } from "./chunks/chunk-WW23WBYG.js";
81
+ } from "./chunks/chunk-F4HDKER4.js";
80
82
  import {
81
83
  EN
82
- } from "./chunks/chunk-H2WV3DTN.js";
84
+ } from "./chunks/chunk-ISWKAU5G.js";
83
85
  import "./chunks/chunk-ZA47FP7C.js";
84
86
  export {
85
87
  CONTENT_SCALE,
@@ -97,7 +99,6 @@ export {
97
99
  KEPT_FLAG,
98
100
  LABEL_MAX_EM,
99
101
  LIGHT_THEME,
100
- MAX_DERIVED_LAYERS,
101
102
  NODE_BASE,
102
103
  PAST_KINDS,
103
104
  PLANE_HUES,
@@ -113,6 +114,7 @@ export {
113
114
  buildModel,
114
115
  changedSubset,
115
116
  checkEdit,
117
+ checkNativeEdit,
116
118
  childrenMap,
117
119
  chromeStyle,
118
120
  cls,
@@ -123,7 +125,9 @@ export {
123
125
  deriveLayers,
124
126
  diffModels,
125
127
  diffStyle,
128
+ edgeKindClass,
126
129
  edgesOf,
130
+ encodeParent,
127
131
  graphStyle,
128
132
  hasChanges,
129
133
  indexModel,
package/dist/edit.d.ts CHANGED
@@ -5,6 +5,7 @@ export interface NodeFields {
5
5
  label?: string;
6
6
  kind?: string;
7
7
  parent?: string | null;
8
+ order?: number | null;
8
9
  data?: Record<string, unknown>;
9
10
  }
10
11
  export interface EdgeRef {
@@ -37,7 +38,7 @@ export type EditOp =
37
38
  op: 'removeEdge';
38
39
  edge: EdgeRef;
39
40
  };
40
- export type EditError = 'id-empty' | 'id-taken' | 'no-node' | 'no-parent' | 'cycle' | 'has-children' | 'no-endpoint' | 'self-loop' | 'edge-exists' | 'no-edge';
41
+ export type EditError = 'id-format' | 'multiple-roots' | 'order-mixed' | 'order-invalid' | 'id-empty' | 'id-taken' | 'no-node' | 'no-parent' | 'cycle' | 'has-children' | 'no-endpoint' | 'self-loop' | 'edge-exists' | 'no-edge';
41
42
  /** Whether this op can be applied. null = yes; otherwise the reason (the UI looks it up in `strings.error`). */
42
43
  export declare function checkEdit(model: GraphModel, op: EditOp): EditError | null;
43
44
  /** How many edges hang on a node (the ones that go with it when it is deleted). */
@@ -56,3 +57,5 @@ export declare function applyEdits(model: GraphModel, ops: EditOp[], profile?: G
56
57
  error: EditError;
57
58
  }[];
58
59
  };
60
+ /** Native CLI edits must remain exportable under the parent/order contract. */
61
+ export declare function checkNativeEdit(model: GraphModel, op: EditOp): EditError | null;
@@ -12,6 +12,8 @@ export declare const RESERVED_CLASSES: readonly ["container", "crosslayer", "con
12
12
  * must build selectors with the same rule, or input like "a kind with a space" would compute two different
13
13
  * names in two places, and neither would select the other. */
14
14
  export declare const cls: (s: string) => string;
15
+ /** Legacy semantic contains must never acquire the structural skeleton class. */
16
+ export declare const edgeKindClass: (kind: string) => string;
15
17
  /**
16
18
  * A node's **skin**: what it looks like is decided entirely by this class string (kind / flags / container or not /
17
19
  * the profile's own part).
package/dist/index.js CHANGED
@@ -1,12 +1,11 @@
1
1
  'use client';
2
2
  import "./chunks/chunk-SA6RSWZP.js";
3
3
  import {
4
- MAX_DERIVED_LAYERS,
5
4
  childrenMap,
6
5
  deriveLayers,
7
6
  layerIndexOf,
8
7
  orderedChildren
9
- } from "./chunks/chunk-QJ4B3U76.js";
8
+ } from "./chunks/chunk-G7XWVKHN.js";
10
9
  import {
11
10
  ALL_CONTROLS,
12
11
  DEFAULT_PLANES,
@@ -15,7 +14,7 @@ import {
15
14
  clearLayoutCache,
16
15
  computeLayout,
17
16
  projectPlanes
18
- } from "./chunks/chunk-7C3QZVGJ.js";
17
+ } from "./chunks/chunk-WUBELTBU.js";
19
18
  import {
20
19
  CONTENT_SCALE,
21
20
  DARK_THEME,
@@ -46,6 +45,7 @@ import {
46
45
  buildModel,
47
46
  changedSubset,
48
47
  checkEdit,
48
+ checkNativeEdit,
49
49
  chromeStyle,
50
50
  cls,
51
51
  countByKind,
@@ -54,7 +54,9 @@ import {
54
54
  defineProfile,
55
55
  diffModels,
56
56
  diffStyle,
57
+ edgeKindClass,
57
58
  edgesOf,
59
+ encodeParent,
58
60
  graphStyle,
59
61
  hasChanges,
60
62
  indexModel,
@@ -87,16 +89,16 @@ import {
87
89
  untheme,
88
90
  validateModel,
89
91
  validateStructure
90
- } from "./chunks/chunk-WW23WBYG.js";
92
+ } from "./chunks/chunk-F4HDKER4.js";
91
93
  import {
92
94
  DetailPanel,
93
95
  renderInline,
94
96
  renderMarkdown
95
- } from "./chunks/chunk-PBF4KMQB.js";
97
+ } from "./chunks/chunk-3JGZ27DC.js";
96
98
  import {
97
99
  EN
98
- } from "./chunks/chunk-H2WV3DTN.js";
99
- import "./chunks/chunk-YGRPNAXE.js";
100
+ } from "./chunks/chunk-ISWKAU5G.js";
101
+ import "./chunks/chunk-OE5IRKWZ.js";
100
102
  import "./chunks/chunk-ZA47FP7C.js";
101
103
  export {
102
104
  ALL_CONTROLS,
@@ -118,7 +120,6 @@ export {
118
120
  KEPT_FLAG,
119
121
  LABEL_MAX_EM,
120
122
  LIGHT_THEME,
121
- MAX_DERIVED_LAYERS,
122
123
  NODE_BASE,
123
124
  PAST_KINDS,
124
125
  PLANE_HUES,
@@ -135,6 +136,7 @@ export {
135
136
  buildModel,
136
137
  changedSubset,
137
138
  checkEdit,
139
+ checkNativeEdit,
138
140
  childrenMap,
139
141
  chromeStyle,
140
142
  clearLayoutCache,
@@ -147,7 +149,9 @@ export {
147
149
  deriveLayers,
148
150
  diffModels,
149
151
  diffStyle,
152
+ edgeKindClass,
150
153
  edgesOf,
154
+ encodeParent,
151
155
  graphStyle,
152
156
  hasChanges,
153
157
  indexModel,
@@ -4,6 +4,6 @@ export { default as DiffOverlay, type DiffOverlayProps, type DiffGeometry, type
4
4
  export { diffPositions, solveDiffLayout, type DiffSides, type DiffSolve, } from './layout/diff-layout.js';
5
5
  export { relaxOverlaps, relaxNodes, type RelaxNode } from './layout/relax.js';
6
6
  export { planLabels, labelBox, idPhase, type LabelInput, type LabelPlan, type LabelSide, type ReadabilityOptions, } from './layout/readability.js';
7
- export { shapeOf, arrowOf, type Shape as PaintShape, type Arrow as PaintArrow, dotOf, gapOf, skeletonLineOf, semanticAlphaOf, clippedLength, hazeOf, detailed, reachOf, hittable, focusAlphaOf, MIN_DOT, MIN_LINE, SKEL_FLOOR, SEM_W, SEM_INK, SEM_BOOST, DETAIL_LEAF, GAP, HOVER_DIM, HOLD_LEAF, NODE_SLACK, EDGE_REACH, FOCUS_INK, } from './paint.js';
7
+ export { edgeKindHidden, shapeOf, arrowOf, type Shape as PaintShape, type Arrow as PaintArrow, dotOf, gapOf, skeletonLineOf, semanticAlphaOf, clippedLength, hazeOf, detailed, reachOf, hittable, focusAlphaOf, MIN_DOT, MIN_LINE, SKEL_FLOOR, SEM_W, SEM_INK, SEM_BOOST, DETAIL_LEAF, GAP, HOVER_DIM, HOLD_LEAF, NODE_SLACK, EDGE_REACH, FOCUS_INK, } from './paint.js';
8
8
  export { touchGestures } from './react/touch.js';
9
9
  export { placePanel } from './react/placement.js';
package/dist/internal.js CHANGED
@@ -1,12 +1,11 @@
1
1
  'use client';
2
2
  import "./chunks/chunk-SA6RSWZP.js";
3
3
  import {
4
- MAX_DERIVED_LAYERS,
5
4
  childrenMap,
6
5
  deriveLayers,
7
6
  layerIndexOf,
8
7
  orderedChildren
9
- } from "./chunks/chunk-QJ4B3U76.js";
8
+ } from "./chunks/chunk-G7XWVKHN.js";
10
9
  import {
11
10
  ALL_CONTROLS,
12
11
  DEFAULT_PLANES,
@@ -32,6 +31,7 @@ import {
32
31
  computeLayout,
33
32
  detailed,
34
33
  dotOf,
34
+ edgeKindHidden,
35
35
  focusAlphaOf,
36
36
  gapOf,
37
37
  hazeOf,
@@ -48,7 +48,7 @@ import {
48
48
  shapeOf,
49
49
  skeletonLineOf,
50
50
  touchGestures
51
- } from "./chunks/chunk-7C3QZVGJ.js";
51
+ } from "./chunks/chunk-WUBELTBU.js";
52
52
  import {
53
53
  CONTENT_SCALE,
54
54
  DARK_THEME,
@@ -85,6 +85,7 @@ import {
85
85
  buildModel,
86
86
  changedSubset,
87
87
  checkEdit,
88
+ checkNativeEdit,
88
89
  chromeStyle,
89
90
  cls,
90
91
  countByKind,
@@ -100,8 +101,10 @@ import {
100
101
  easeOutBack,
101
102
  easeOutCubic,
102
103
  edgeFade,
104
+ edgeKindClass,
103
105
  edgeTraffic,
104
106
  edgesOf,
107
+ encodeParent,
105
108
  fadeAt,
106
109
  graphStyle,
107
110
  hasChanges,
@@ -145,16 +148,16 @@ import {
145
148
  untheme,
146
149
  validateModel,
147
150
  validateStructure
148
- } from "./chunks/chunk-WW23WBYG.js";
151
+ } from "./chunks/chunk-F4HDKER4.js";
149
152
  import {
150
153
  DetailPanel,
151
154
  renderInline,
152
155
  renderMarkdown
153
- } from "./chunks/chunk-PBF4KMQB.js";
156
+ } from "./chunks/chunk-3JGZ27DC.js";
154
157
  import {
155
158
  EN
156
- } from "./chunks/chunk-H2WV3DTN.js";
157
- import "./chunks/chunk-YGRPNAXE.js";
159
+ } from "./chunks/chunk-ISWKAU5G.js";
160
+ import "./chunks/chunk-OE5IRKWZ.js";
158
161
  import "./chunks/chunk-ZA47FP7C.js";
159
162
  export {
160
163
  ALL_CONTROLS,
@@ -186,7 +189,6 @@ export {
186
189
  KEPT_FLAG,
187
190
  LABEL_MAX_EM,
188
191
  LIGHT_THEME,
189
- MAX_DERIVED_LAYERS,
190
192
  MIN_DOT,
191
193
  MIN_LINE,
192
194
  NODE_BASE,
@@ -214,6 +216,7 @@ export {
214
216
  buildModel,
215
217
  changedSubset,
216
218
  checkEdit,
219
+ checkNativeEdit,
217
220
  childrenMap,
218
221
  chromeStyle,
219
222
  clearLayoutCache,
@@ -236,8 +239,11 @@ export {
236
239
  easeOutBack,
237
240
  easeOutCubic,
238
241
  edgeFade,
242
+ edgeKindClass,
243
+ edgeKindHidden,
239
244
  edgeTraffic,
240
245
  edgesOf,
246
+ encodeParent,
241
247
  fadeAt,
242
248
  focusAlphaOf,
243
249
  gapOf,
package/dist/layers.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import type { GraphModel, GraphNode } from './model.js';
2
2
  import type { LayerSpec } from './profile.js';
3
- /** Beyond this many ordered children the planes stop being an outline and become a stack of cards. */
4
- export declare const MAX_DERIVED_LAYERS = 8;
5
3
  export interface DerivedLayers {
6
4
  /** Empty when the graph has no ordered siblings at the top of a single root. */
7
5
  layers: LayerSpec[];
@@ -32,7 +32,8 @@ export interface LayoutRequest {
32
32
  *
33
33
  * The cost is that layout becomes **path dependent**: going step1 → step2 and step4 → step2, the same data
34
34
  * gets two different layouts. That is a real cost, but within one session layout is stable (see lastByNs),
35
- * and results go into the cache, so the same structure hits it the second time and never drifts; for a different one press "Relayout", which deliberately takes no seed.
35
+ * and results go into the cache, so the same structure hits it the second time and never drifts. "Relayout" discards
36
+ * this continuation seed and rebuilds the forest's sector seed (ordered siblings keep their order).
36
37
  *
37
38
  * **All three places need it; miss one and the seed is wasted:**
38
39
  * ① inside components: member coordinates as the force start
@@ -42,6 +43,7 @@ export interface LayoutRequest {
42
43
  */
43
44
  seed?: Positions;
44
45
  onProgress?: (done: number, total: number) => void;
46
+ /** Bypass cached coordinates and rebuild the sector seed, ignoring continuation coordinates. */
45
47
  force?: boolean;
46
48
  /** Cache partition: the same structure stores each solving mode separately (`layoutMode` fresh / continue).
47
49
  * Without it, after one pass with continue, switching back to fresh would still show the continue result: "a free solve by content,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  inlinePool
3
- } from "../chunks/chunk-YGRPNAXE.js";
3
+ } from "../chunks/chunk-OE5IRKWZ.js";
4
4
  import "../chunks/chunk-ZA47FP7C.js";
5
5
  export {
6
6
  inlinePool
@@ -7,12 +7,15 @@ export interface OrderInfo {
7
7
  orderedKids: Map<string, string[]>;
8
8
  /** Every node id, for subtree walks. */
9
9
  nodeIds: Set<string>;
10
- /** At least one run is numbered (otherwise there is nothing to do). */
10
+ /** At least one run is numbered; unnumbered runs still receive sectors. */
11
11
  any: boolean;
12
12
  }
13
- /** Read `order` off the elements. Returns null when nothing is numbered: the layout then stays exactly as it was. */
13
+ /** Read the forest for sector seeding, including graphs with no numbered siblings. */
14
14
  export declare function readOrder(elements: CyElement[]): OrderInfo | null;
15
- /** Pre-solve positions: ordered runs on arcs (clockwise, first at 12 o'clock), the rest by hash. */
16
- export declare function orderSeed(elements: CyElement[], info: OrderInfo): Positions;
17
- /** Post-pass: rotate every ordered run into place, sub-tree by sub-tree. */
18
- export declare function enforceOrder(elements: CyElement[], info: OrderInfo, positions: Positions): Positions;
15
+ type Dimensions = Record<string, {
16
+ w: number;
17
+ h: number;
18
+ }>;
19
+ /** Sector assignment constrains only the seed; the force solver owns the final positions. */
20
+ export declare function orderSeed(elements: CyElement[], info: OrderInfo, dims?: Dimensions, random?: () => number): Positions;
21
+ export {};
@@ -37,7 +37,13 @@ function runLayoutJob(job) {
37
37
  return new Promise((resolve, reject) => {
38
38
  let cy;
39
39
  try {
40
- cy = cytoscape({ headless: true, styleEnabled: true, elements: job.elements, style: GEOMETRY_STYLE });
40
+ cy = cytoscape({
41
+ headless: true,
42
+ styleEnabled: true,
43
+ elements: job.elements,
44
+ style: GEOMETRY_STYLE,
45
+ layout: { name: "preset", fit: false }
46
+ });
41
47
  } catch (err) {
42
48
  reject(err);
43
49
  return;
package/dist/model.d.ts CHANGED
@@ -6,8 +6,9 @@ export interface GraphNode {
6
6
  kind?: string;
7
7
  /** Compound parent node id: expresses "nested inside", the only source of structural hierarchy. */
8
8
  parent?: string;
9
- /** Position among its siblings: every child of a parent carries one, or none does. The layout reads it
10
- * clockwise, and a run of ordered siblings is what opens the layer view. */
9
+ /** Position among its siblings: every child of a parent carries one, or none does. **The file format writes it as the
10
+ * `@<order>` tail of `parent`** (`"<id>@<order>"`; `@-1` means explicitly unordered and parses to undefined). The layout
11
+ * reads it clockwise, and a run of ordered siblings is what opens the layer view. */
11
12
  order?: number;
12
13
  /** **Where it hung in the previous version** (filled by `diffModels`, only `moved` nodes in a union have it).
13
14
  *
@@ -94,3 +95,5 @@ export interface GraphIndex {
94
95
  export declare function indexModel(model: GraphModel): GraphIndex;
95
96
  /** The sources that appear in the model (data for the subgraph / view dropdown). */
96
97
  export declare function originsOf(model: GraphModel): string[];
98
+ /** Canonical decimal encoding: Number.toString uses exponents for tiny/large orders. */
99
+ export declare function encodeParent(parent: string | null | undefined, order?: number): string | null;
package/dist/paint.d.ts CHANGED
@@ -51,6 +51,8 @@ export declare const reachOf: (vis: number, lineW: number, touch?: boolean, base
51
51
  export declare const hittable: (reach: number) => boolean;
52
52
  /** Up close or not (dashes, semantic edge arrows). */
53
53
  export declare const detailed: (leafPx: number) => boolean;
54
+ /** Relationship filters never hide the parent skeleton, even in legacy graphs with a contains kind. */
55
+ export declare const edgeKindHidden: (skeleton: boolean, kind: string, hidden: ReadonlySet<string>) => boolean;
54
56
  /** Shapes and arrow heads the painter can draw. Hosts drawing marks "like on the graph" (a legend, say) follow these two mappings. */
55
57
  export type Shape = 'circle' | 'hexagon' | 'diamond' | 'rect';
56
58
  export type Arrow = 'none' | 'triangle' | 'tee';
@@ -6,6 +6,8 @@ export interface SelectedNode {
6
6
  label: string;
7
7
  kind: string;
8
8
  layer?: string;
9
+ parent?: string;
10
+ order?: number;
9
11
  origin?: string | null;
10
12
  /** Has children. */
11
13
  container?: boolean;
@@ -2,8 +2,8 @@
2
2
  "use client";
3
3
  import {
4
4
  DetailPanel
5
- } from "../chunks/chunk-PBF4KMQB.js";
6
- import "../chunks/chunk-H2WV3DTN.js";
5
+ } from "../chunks/chunk-3JGZ27DC.js";
6
+ import "../chunks/chunk-ISWKAU5G.js";
7
7
  import "../chunks/chunk-ZA47FP7C.js";
8
8
  export {
9
9
  DetailPanel as default
@@ -28,7 +28,7 @@ import { type ControlId } from './Toolbar.js';
28
28
  import { type SelectedNode } from './DetailPanel.js';
29
29
  import { type RenderEditor } from './EditPanel.js';
30
30
  import { type GraphLook } from './Legend.js';
31
- import { type EditOp } from '../edit.js';
31
+ import { type EditError, type EditOp } from '../edit.js';
32
32
  import { type GraphStrings } from '../strings.js';
33
33
  /** Where a layout came from (as `onLayout` reports it):
34
34
  * `preset` the host's `layout` covered everything · `cache` nothing was computed, an existing result was reused (local cache, or the one already on screen) ·
@@ -120,10 +120,11 @@ export interface GraphCanvasProps {
120
120
  layout?: Positions | null;
121
121
  /**
122
122
  * How ③ solves:
123
- * `'fresh'` (default) **full recompute**, structure only.
123
+ * `'fresh'` (default) **full recompute** from sampled sectors: ordered siblings follow their numbers; others shuffle sectors.
124
124
  * `'continue'` **continue**: also a full recompute, but starting from existing coordinates (this frame on screen, gaps filled from the preset)
125
- * instead of a random start, so the result hugs the previous version and surviving nodes move only a little between steps.
125
+ * instead of rebuilding sectors. Missing coordinates are filled from the sector seed.
126
126
  * Only decides the first time: the result goes into the cache (each mode separately), so the same structure hits the cache next time and never drifts.
127
+ * Re-layout always bypasses saved coordinates and rebuilds sectors, regardless of this mode.
127
128
  */
128
129
  layoutMode?: 'fresh' | 'continue';
129
130
  /** Called once per layout produced (including "Relayout" in the canvas menu): flat coordinates, and where they came from.
@@ -187,11 +188,16 @@ export interface GraphCanvasProps {
187
188
  * with `applyEdit` to its own model and passes it back, and the transition shows the change. Not editable in compare mode. See edit.ts.
188
189
  */
189
190
  onEdit?: (op: EditOp) => void;
191
+ /** Full editable graph when the drawn model omits a layer anchor. */
192
+ editModel?: GraphModel;
193
+ validateEdit?: (op: EditOp) => EditError | null;
190
194
  /** Replace the free-form part of the edit panel (label / kind / data, JSON) with the host's own editor. */
191
195
  renderEditor?: RenderEditor;
192
- /** "Restructure" in ⋯: the host re-hangs and renumbers the graph (see cli/restructure.ts) and hands back a new model.
196
+ /** "Re-structure" in ⋯: the host re-hangs and renumbers the graph (see cli/restructure.ts) and hands back a new model.
193
197
  * Without it the item is absent. Pure callback: the library never edits. */
194
198
  onRestructure?: () => void;
199
+ /** Optional inline content under Re-structure in the existing toolbar popup. */
200
+ restructureContent?: ReactNode;
195
201
  /** Why the layer button is grey. The button is always shown; this text goes in its popover. */
196
202
  layerIssue?: string;
197
203
  /** "Open the floors anyway" in that popover: the host rebuilds its profile with layers forced on. */
@@ -2,11 +2,11 @@
2
2
  "use client";
3
3
  import {
4
4
  GraphCanvas
5
- } from "../chunks/chunk-7C3QZVGJ.js";
6
- import "../chunks/chunk-WW23WBYG.js";
7
- import "../chunks/chunk-PBF4KMQB.js";
8
- import "../chunks/chunk-H2WV3DTN.js";
9
- import "../chunks/chunk-YGRPNAXE.js";
5
+ } from "../chunks/chunk-WUBELTBU.js";
6
+ import "../chunks/chunk-F4HDKER4.js";
7
+ import "../chunks/chunk-3JGZ27DC.js";
8
+ import "../chunks/chunk-ISWKAU5G.js";
9
+ import "../chunks/chunk-OE5IRKWZ.js";
10
10
  import "../chunks/chunk-ZA47FP7C.js";
11
11
  export {
12
12
  GraphCanvas as default
@@ -1,4 +1,4 @@
1
- import { type RefObject } from 'react';
1
+ import { type ReactNode, type RefObject } from 'react';
2
2
  import type { GraphIssue, LayerSpec } from '../profile.js';
3
3
  import { type GraphView } from '../view.js';
4
4
  export type ControlId = 'search' | 'origins' | 'layers' | 'relayout' | 'zoom';
@@ -37,8 +37,9 @@ export interface ToolbarProps {
37
37
  onAdd?: (what: 'node' | 'edge') => void;
38
38
  /** "Relayout" in ⋯: another arrangement of the same data. Without it the item is absent. */
39
39
  onRelayout?: () => void;
40
- /** "Restructure" in ⋯: re-hang and renumber to raise the shape score. Without it the item is absent. */
40
+ /** "Re-structure" in ⋯: repair containment and ordering while preserving content. Without it the item is absent. */
41
41
  onRestructure?: () => void;
42
+ restructureContent?: ReactNode;
42
43
  /** Why the layer button is grey (it is always shown). `onForceLayers` adds "open the floors anyway". */
43
44
  layerIssue?: string;
44
45
  onForceLayers?: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glassbrain",
3
- "version": "0.2.0-alpha.3",
3
+ "version": "0.2.0-alpha.5",
4
4
  "description": "Know what your agent knows: open, diff and review the knowledge graphs agents write. Plain JSON in, one html file out.",
5
5
  "keywords": [
6
6
  "knowledge-graph",
@@ -88,7 +88,8 @@
88
88
  "demo:public": "node demo/build.mjs --public",
89
89
  "bench": "node demo/build.mjs && node scripts/bench.mjs",
90
90
  "pretest": "npm run build",
91
- "test": "node --test \"test/*.test.ts\""
91
+ "test": "node --test \"test/*.test.ts\"",
92
+ "release:alpha": "node scripts/release-alpha.mjs"
92
93
  },
93
94
  "peerDependencies": {
94
95
  "cytoscape": "^3.30.0",
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://unpkg.com/glassbrain/schema/graph.schema.json",
4
4
  "title": "glassbrain graph",
5
- "description": "One file of a glassbrain knowledge graph. A graph is nodes plus edges; structure comes from `parent` (containment), not from edges. Every node carries `parent`: a node id, or null for the root. Several files in one folder are merged into one graph (same id = same node). Unknown fields are kept and shown in the detail panel.",
5
+ "description": "One file of a glassbrain knowledge graph. A graph is nodes plus edges; structure comes from `parent` (containment), not from edges. Every node carries `parent`: null for the root, otherwise `\"<id>@<order>\"` where `order` is a positive number or -1 for explicitly unordered. Several files in one folder are merged into one graph (same id = same node). Unknown fields are kept and shown in the detail panel.",
6
6
  "type": "object",
7
7
  "anyOf": [{ "required": ["nodes"] }, { "required": ["edges"] }],
8
8
  "properties": {
@@ -22,12 +22,11 @@
22
22
  "type": "object",
23
23
  "required": ["id", "parent"],
24
24
  "properties": {
25
- "id": { "type": ["string", "number"], "description": "Stable identity. Keep it the same across versions: that is how a diff knows it is the same thing." },
25
+ "id": { "type": ["string", "number"], "pattern": "^[^\\s@]{1,80}$", "description": "Stable identity. Keep it the same across versions: that is how a diff knows it is the same thing. No `@` and no whitespace, at most 80 characters; prefer a short code (`a-z0-9_`, under 20)." },
26
26
  "label": { "type": "string", "description": "Display name. Falls back to `name`, then `id`." },
27
27
  "name": { "type": "string", "description": "Alias of `label`." },
28
28
  "kind": { "type": "string", "description": "What sort of thing this is. Colors come from the profile's `nodePalette[kind]`; kinds not in the palette are drawn as skeleton." },
29
- "parent": { "type": ["string", "null"], "description": "Id of the node this one sits inside; null for the root. Required: the only source of structure, and the layout, the layers and the outline are all built from it." },
30
- "order": { "type": "number", "exclusiveMinimum": 0, "description": "Position among its siblings (1, 2, 3…; 3.5 inserts between 3 and 4). Either every child of a parent has one or none does, and no two siblings share one." },
29
+ "parent": { "type": ["string", "null"], "pattern": "^[^\\s@]{1,80}@(-1|[1-9]\\d*(\\.\\d+)?|0\\.\\d*[1-9]\\d*)$", "description": "`\"<id>@<order>\"`: the id of the node this one sits inside, then its position among the siblings (1, 2, 3…; 3.5 inserts between 3 and 4), or -1 for explicitly unordered. null for the root. Required: the only source of structure, and the layout, the layers and the outline are all built from it." },
31
30
  "flags": { "type": "array", "items": { "type": "string" }, "description": "Boolean markers; each becomes a CSS-like class. A flag listed in the profile's `placeholderFlags` draws the node as a placeholder." },
32
31
  "description": { "type": "string", "description": "Markdown shown in the detail panel. `[text](node:<id>)` links jump to another node." }
33
32
  },