@principal-ai/principal-view-react 0.16.49 → 0.16.51
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/graphify/anchor.d.ts +28 -0
- package/dist/graphify/anchor.d.ts.map +1 -0
- package/dist/graphify/anchor.js +132 -0
- package/dist/graphify/anchor.js.map +1 -0
- package/dist/graphify/ids.d.ts +19 -0
- package/dist/graphify/ids.d.ts.map +1 -0
- package/dist/graphify/ids.js +46 -0
- package/dist/graphify/ids.js.map +1 -0
- package/dist/graphify/index.d.ts +7 -0
- package/dist/graphify/index.d.ts.map +1 -1
- package/dist/graphify/index.js +4 -0
- package/dist/graphify/index.js.map +1 -1
- package/dist/graphify/kind.d.ts +23 -0
- package/dist/graphify/kind.d.ts.map +1 -0
- package/dist/graphify/kind.js +71 -0
- package/dist/graphify/kind.js.map +1 -0
- package/dist/graphify/signature.d.ts +87 -0
- package/dist/graphify/signature.d.ts.map +1 -0
- package/dist/graphify/signature.js +276 -0
- package/dist/graphify/signature.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/subsystem/ComponentDeclaration.d.ts +68 -5
- package/dist/subsystem/ComponentDeclaration.d.ts.map +1 -1
- package/dist/subsystem/ComponentDeclaration.js +183 -38
- package/dist/subsystem/ComponentDeclaration.js.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts +7 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +25 -15
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/declarationRef.d.ts +39 -0
- package/dist/subsystem/declarationRef.d.ts.map +1 -0
- package/dist/subsystem/declarationRef.js +32 -0
- package/dist/subsystem/declarationRef.js.map +1 -0
- package/dist/subsystem/model.d.ts +6 -0
- package/dist/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js.map +1 -1
- package/package.json +1 -1
- package/src/graphify/anchor.test.ts +124 -0
- package/src/graphify/anchor.ts +160 -0
- package/src/graphify/ids.ts +48 -0
- package/src/graphify/index.ts +26 -0
- package/src/graphify/kind.test.ts +108 -0
- package/src/graphify/kind.ts +114 -0
- package/src/graphify/signature.test.ts +278 -0
- package/src/graphify/signature.ts +354 -0
- package/src/index.ts +37 -0
- package/src/subsystem/ComponentDeclaration.tsx +318 -44
- package/src/subsystem/SubsystemComponentGraph.tsx +53 -19
- package/src/subsystem/declarationRef.test.ts +33 -0
- package/src/subsystem/declarationRef.ts +63 -0
- package/src/subsystem/model.ts +6 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declaration anchoring — start-line + single-line content hash.
|
|
3
|
+
*
|
|
4
|
+
* Graphify emits `source_location: "L42"` (declaration start line). We capture
|
|
5
|
+
* that line's normalized text as a fingerprint to detect drift without end-line
|
|
6
|
+
* spans or graphify changes.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Persisted anchor for a subsystem component's source declaration. */
|
|
10
|
+
export interface SubsystemDeclarationRef {
|
|
11
|
+
/** Repo-root-relative path (matches `component.file`). */
|
|
12
|
+
file: string;
|
|
13
|
+
/** 1-based declaration start line (from graphify `source_location`). */
|
|
14
|
+
startLine: number;
|
|
15
|
+
/** SHA-256 of {@link normalizeDeclarationLine} output, truncated to 32 hex chars. */
|
|
16
|
+
lineHash: string;
|
|
17
|
+
/** Graphify node id when captured from an exact anchor. */
|
|
18
|
+
graphifyNodeId?: string;
|
|
19
|
+
/** ISO timestamp when this ref was recorded. */
|
|
20
|
+
capturedAt: string;
|
|
21
|
+
/** Repo revision at capture time (optional). */
|
|
22
|
+
revision?: {
|
|
23
|
+
headSha: string;
|
|
24
|
+
dirtyHash?: string | null;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type DeclarationFreshness =
|
|
29
|
+
| 'valid'
|
|
30
|
+
| 'stale'
|
|
31
|
+
| 'missing'
|
|
32
|
+
| 'unanchored'
|
|
33
|
+
| 'unchecked';
|
|
34
|
+
|
|
35
|
+
export const DECLARATION_HASH_ALGO = 'v1' as const;
|
|
36
|
+
|
|
37
|
+
/** Parse graphify `source_location` (`"L42"`) → 1-based line number. */
|
|
38
|
+
export function parseSourceLocation(loc: string | undefined | null): number | null {
|
|
39
|
+
if (!loc?.trim()) return null;
|
|
40
|
+
const m = /^L(\d+)$/.exec(loc.trim());
|
|
41
|
+
if (!m) return null;
|
|
42
|
+
const n = Number.parseInt(m[1]!, 10);
|
|
43
|
+
return Number.isFinite(n) && n >= 1 ? n : null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Normalize a source line before hashing (algo v1). */
|
|
47
|
+
export function normalizeDeclarationLine(line: string): string {
|
|
48
|
+
return line.replace(/\r$/, '').trimEnd();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Extract one 1-based line from file content; null when out of range. */
|
|
52
|
+
export function extractDeclarationLine(content: string, lineNumber: number): string | null {
|
|
53
|
+
if (lineNumber < 1) return null;
|
|
54
|
+
const lines = content.split(/\r?\n/);
|
|
55
|
+
if (lineNumber > lines.length) return null;
|
|
56
|
+
return lines[lineNumber - 1] ?? null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Options when opening a file in the subsystem graph drawer. */
|
|
60
|
+
export interface SubsystemOpenFileOptions {
|
|
61
|
+
/** Scroll/highlight this 1-based line (declaration start). */
|
|
62
|
+
startLine?: number;
|
|
63
|
+
}
|
package/src/subsystem/model.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
} from '@xyflow/react';
|
|
20
20
|
import { computeElkLayout } from '../utils/elkLayout';
|
|
21
21
|
import type { GraphifyComponentDetail } from '../graphify';
|
|
22
|
+
import type { SubsystemDeclarationRef } from './declarationRef';
|
|
22
23
|
|
|
23
24
|
export type SubsystemComponentKind =
|
|
24
25
|
| 'class'
|
|
@@ -112,6 +113,11 @@ export interface SubsystemComponent {
|
|
|
112
113
|
* a different language just needs a different tokenizer and text joiner.
|
|
113
114
|
*/
|
|
114
115
|
tokens?: SubsystemDeclToken[];
|
|
116
|
+
/**
|
|
117
|
+
* Anchored declaration location: graphify start line + hash of that line's
|
|
118
|
+
* content at capture time. Populated by verify when an exact anchor resolves.
|
|
119
|
+
*/
|
|
120
|
+
declarationRef?: SubsystemDeclarationRef;
|
|
115
121
|
}
|
|
116
122
|
|
|
117
123
|
/** A cross-component edge in the subsystem graph. */
|