@blackwell-systems/gcf 2.1.2 → 2.2.1

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.
Files changed (61) hide show
  1. package/README.md +6 -6
  2. package/dist/cjs/index.cjs +259 -40
  3. package/dist/cli.js +0 -0
  4. package/dist/decode_generic.js +92 -8
  5. package/dist/decode_generic.js.map +1 -1
  6. package/dist/generic.d.ts +9 -1
  7. package/dist/generic.d.ts.map +1 -1
  8. package/dist/generic.js +231 -35
  9. package/dist/generic.js.map +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/package.json +2 -2
  14. package/src/decode_generic.ts +97 -7
  15. package/src/generic.ts +232 -35
  16. package/src/index.ts +1 -1
  17. package/dist/cjs/browser.d.ts +0 -9
  18. package/dist/cjs/browser.js +0 -25
  19. package/dist/cjs/browser.js.map +0 -1
  20. package/dist/cjs/cli.d.ts +0 -5
  21. package/dist/cjs/cli.js +0 -136
  22. package/dist/cjs/cli.js.map +0 -1
  23. package/dist/cjs/constants.d.ts +0 -8
  24. package/dist/cjs/constants.js +0 -46
  25. package/dist/cjs/constants.js.map +0 -1
  26. package/dist/cjs/decode.d.ts +0 -5
  27. package/dist/cjs/decode.js +0 -197
  28. package/dist/cjs/decode.js.map +0 -1
  29. package/dist/cjs/decode_generic.d.ts +0 -4
  30. package/dist/cjs/decode_generic.js +0 -678
  31. package/dist/cjs/decode_generic.js.map +0 -1
  32. package/dist/cjs/delta.d.ts +0 -15
  33. package/dist/cjs/delta.js +0 -73
  34. package/dist/cjs/delta.js.map +0 -1
  35. package/dist/cjs/encode.d.ts +0 -5
  36. package/dist/cjs/encode.js +0 -89
  37. package/dist/cjs/encode.js.map +0 -1
  38. package/dist/cjs/generic.d.ts +0 -1
  39. package/dist/cjs/generic.js +0 -332
  40. package/dist/cjs/generic.js.map +0 -1
  41. package/dist/cjs/index.d.ts +0 -11
  42. package/dist/cjs/index.js +0 -32
  43. package/dist/cjs/index.js.map +0 -1
  44. package/dist/cjs/packroot.d.ts +0 -13
  45. package/dist/cjs/packroot.js +0 -50
  46. package/dist/cjs/packroot.js.map +0 -1
  47. package/dist/cjs/scalar.d.ts +0 -26
  48. package/dist/cjs/scalar.js +0 -339
  49. package/dist/cjs/scalar.js.map +0 -1
  50. package/dist/cjs/session.d.ts +0 -30
  51. package/dist/cjs/session.js +0 -140
  52. package/dist/cjs/session.js.map +0 -1
  53. package/dist/cjs/stream.d.ts +0 -66
  54. package/dist/cjs/stream.js +0 -127
  55. package/dist/cjs/stream.js.map +0 -1
  56. package/dist/cjs/stream_generic.d.ts +0 -37
  57. package/dist/cjs/stream_generic.js +0 -87
  58. package/dist/cjs/stream_generic.js.map +0 -1
  59. package/dist/cjs/types.d.ts +0 -75
  60. package/dist/cjs/types.js +0 -3
  61. package/dist/cjs/types.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/session.ts"],"names":[],"mappings":";;;AA0EA,8CA6EC;AAtJD,iDAA6C;AAC7C,2CAAqC;AAErC;;;;GAIG;AACH,MAAa,OAAO;IACV,OAAO,GAAwB,IAAI,GAAG,EAAE,CAAC;IACzC,MAAM,GAAW,CAAC,CAAC;IAE3B,uEAAuE;IACvE,WAAW,CAAC,KAAa;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,6FAA6F;IAC7F,KAAK,CAAC,KAAa;QACjB,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnC,OAAO,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,OAAiB;QACtB,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B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AE,CAAC;YACxB,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YACxC,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YACxC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS;gBAAE,SAAS;YAE3D,IAAI,IAAI,GAAG,IAAI,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;YACjD,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBACzC,IAAI,IAAI,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;YACzB,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IAED,yCAAyC;IACzC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAExB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AACjC,CAAC"}
@@ -1,66 +0,0 @@
1
- import type { Symbol, Edge } from './types.js';
2
- /**
3
- * Options for the streaming encoder.
4
- */
5
- export interface StreamOptions {
6
- tokenBudget?: number;
7
- tokensUsed?: number;
8
- packRoot?: string;
9
- session?: boolean;
10
- }
11
- /**
12
- * A writable sink for streaming output. Accepts string chunks.
13
- * Compatible with Node.js streams, web WritableStreams, or simple callbacks.
14
- */
15
- export interface StreamWriter {
16
- write(chunk: string): void;
17
- }
18
- /**
19
- * StreamEncoder writes GCF output incrementally as symbols and edges arrive.
20
- * Zero buffering: each symbol/edge is written immediately. A trailer summary
21
- * is emitted on close() with the final counts.
22
- *
23
- * @example
24
- * ```ts
25
- * const chunks: string[] = [];
26
- * const enc = new StreamEncoder({ write: (s) => chunks.push(s) }, 'context_for_task', { tokenBudget: 5000 });
27
- * enc.writeSymbol({ qualifiedName: 'pkg.Auth', kind: 'function', score: 0.95, provenance: 'lsp', distance: 0 });
28
- * enc.writeEdge({ source: 'pkg.Server', target: 'pkg.Auth', edgeType: 'calls' });
29
- * enc.close();
30
- * ```
31
- */
32
- export declare class StreamEncoder {
33
- private w;
34
- private symIndex;
35
- private nextID;
36
- private currentGroup;
37
- private groupCounts;
38
- private edgeCount;
39
- private edgesStarted;
40
- constructor(w: StreamWriter, tool: string, opts?: StreamOptions);
41
- private writeHeader;
42
- /**
43
- * Emit a symbol line immediately. Group headers are emitted automatically
44
- * when the distance changes.
45
- */
46
- writeSymbol(s: Symbol): void;
47
- /**
48
- * Emit an edge line immediately. The edges section header is emitted
49
- * automatically on the first edge (with [?] deferred count).
50
- * Source and target must reference previously-written symbols.
51
- */
52
- writeEdge(e: Edge): void;
53
- /**
54
- * Emit a bare reference for a previously-transmitted symbol (session mode).
55
- */
56
- writeBareRef(qname: string, distance: number): void;
57
- /**
58
- * Emit the ##! summary trailer with final counts. Must be called after all
59
- * symbols and edges have been written.
60
- */
61
- close(): void;
62
- /** Number of symbols written so far. */
63
- get symbolCount(): number;
64
- /** Number of edges written so far. */
65
- get edgeCount_(): number;
66
- }
@@ -1,127 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StreamEncoder = void 0;
4
- const constants_js_1 = require("./constants.js");
5
- /**
6
- * StreamEncoder writes GCF output incrementally as symbols and edges arrive.
7
- * Zero buffering: each symbol/edge is written immediately. A trailer summary
8
- * is emitted on close() with the final counts.
9
- *
10
- * @example
11
- * ```ts
12
- * const chunks: string[] = [];
13
- * const enc = new StreamEncoder({ write: (s) => chunks.push(s) }, 'context_for_task', { tokenBudget: 5000 });
14
- * enc.writeSymbol({ qualifiedName: 'pkg.Auth', kind: 'function', score: 0.95, provenance: 'lsp', distance: 0 });
15
- * enc.writeEdge({ source: 'pkg.Server', target: 'pkg.Auth', edgeType: 'calls' });
16
- * enc.close();
17
- * ```
18
- */
19
- class StreamEncoder {
20
- w;
21
- symIndex = new Map();
22
- nextID = 0;
23
- currentGroup = '';
24
- groupCounts = new Map();
25
- edgeCount = 0;
26
- edgesStarted = false;
27
- constructor(w, tool, opts = {}) {
28
- this.w = w;
29
- this.writeHeader(tool, opts);
30
- }
31
- writeHeader(tool, opts) {
32
- const parts = [`GCF profile=graph tool=${tool}`];
33
- if (opts.tokenBudget)
34
- parts.push(`budget=${opts.tokenBudget}`);
35
- if (opts.tokensUsed)
36
- parts.push(`tokens=${opts.tokensUsed}`);
37
- if (opts.packRoot)
38
- parts.push(`pack_root=${opts.packRoot}`);
39
- if (opts.session)
40
- parts.push('session=true');
41
- this.w.write(parts.join(' ') + '\n');
42
- }
43
- /**
44
- * Emit a symbol line immediately. Group headers are emitted automatically
45
- * when the distance changes.
46
- */
47
- writeSymbol(s) {
48
- const groupNames = ['targets', 'related', 'extended'];
49
- const groupName = s.distance < groupNames.length
50
- ? groupNames[s.distance]
51
- : `distance_${s.distance}`;
52
- if (groupName !== this.currentGroup) {
53
- this.w.write(`## ${groupName}\n`);
54
- this.currentGroup = groupName;
55
- }
56
- const id = this.nextID++;
57
- this.symIndex.set(s.qualifiedName, id);
58
- const kind = constants_js_1.KIND_ABBREV[s.kind] || s.kind;
59
- this.w.write(`@${id} ${kind} ${s.qualifiedName} ${s.score.toFixed(2)} ${s.provenance}\n`);
60
- this.groupCounts.set(groupName, (this.groupCounts.get(groupName) || 0) + 1);
61
- }
62
- /**
63
- * Emit an edge line immediately. The edges section header is emitted
64
- * automatically on the first edge (with [?] deferred count).
65
- * Source and target must reference previously-written symbols.
66
- */
67
- writeEdge(e) {
68
- const srcIdx = this.symIndex.get(e.source);
69
- const tgtIdx = this.symIndex.get(e.target);
70
- if (srcIdx === undefined || tgtIdx === undefined)
71
- return;
72
- if (!this.edgesStarted) {
73
- this.w.write('## edges [?]\n');
74
- this.edgesStarted = true;
75
- }
76
- let line = `@${tgtIdx}<@${srcIdx} ${e.edgeType}`;
77
- if (e.status && e.status !== 'unchanged') {
78
- line += ` ${e.status}`;
79
- }
80
- this.w.write(line + '\n');
81
- this.edgeCount++;
82
- }
83
- /**
84
- * Emit a bare reference for a previously-transmitted symbol (session mode).
85
- */
86
- writeBareRef(qname, distance) {
87
- const groupNames = ['targets', 'related', 'extended'];
88
- const groupName = distance < groupNames.length
89
- ? groupNames[distance]
90
- : `distance_${distance}`;
91
- if (groupName !== this.currentGroup) {
92
- this.w.write(`## ${groupName}\n`);
93
- this.currentGroup = groupName;
94
- }
95
- const id = this.nextID++;
96
- this.symIndex.set(qname, id);
97
- this.w.write(`@${id} # previously transmitted\n`);
98
- this.groupCounts.set(groupName, (this.groupCounts.get(groupName) || 0) + 1);
99
- }
100
- /**
101
- * Emit the ##! summary trailer with final counts. Must be called after all
102
- * symbols and edges have been written.
103
- */
104
- close() {
105
- const deferredCounts = [];
106
- const groupOrder = ['targets', 'related', 'extended'];
107
- for (const g of groupOrder) {
108
- const c = this.groupCounts.get(g);
109
- if (c && c > 0)
110
- deferredCounts.push(c);
111
- }
112
- for (const [g, c] of this.groupCounts) {
113
- if (!groupOrder.includes(g) && c > 0)
114
- deferredCounts.push(c);
115
- }
116
- if (this.edgeCount > 0) {
117
- deferredCounts.push(this.edgeCount);
118
- }
119
- this.w.write(`##! summary symbols=${this.nextID} edges=${this.edgeCount} counts=${deferredCounts.join(',')}\n`);
120
- }
121
- /** Number of symbols written so far. */
122
- get symbolCount() { return this.nextID; }
123
- /** Number of edges written so far. */
124
- get edgeCount_() { return this.edgeCount; }
125
- }
126
- exports.StreamEncoder = StreamEncoder;
127
- //# sourceMappingURL=stream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAqB7C;;;;;;;;;;;;;GAaG;AACH,MAAa,aAAa;IAChB,CAAC,CAAe;IAChB,QAAQ,GAAwB,IAAI,GAAG,EAAE,CAAC;IAC1C,MAAM,GAAG,CAAC,CAAC;IACX,YAAY,GAAG,EAAE,C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AAM,CAAC,IAAI,UAAU,EAAE,CAAC;YAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;gBAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACtC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;gBAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/D,CAAC;QACD,IAAI,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;YACvB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,uBAAuB,IAAI,CAAC,MAAM,UAAU,IAAI,CAAC,SAAS,WAAW,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClH,CAAC;IAED,wCAAwC;IACxC,IAAI,WAAW,KAAa,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAEjD,sCAAsC;IACtC,IAAI,UAAU,KAAa,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;CACpD;AAtHD,sCAsHC"}
@@ -1,37 +0,0 @@
1
- import type { StreamWriter } from './stream.js';
2
- /**
3
- * GenericStreamEncoder writes GCF tabular output incrementally as rows arrive.
4
- * Zero buffering: each row is written immediately. A trailer summary is
5
- * emitted on close() with the final counts.
6
- *
7
- * @example
8
- * ```ts
9
- * const enc = new GenericStreamEncoder({ write: (s) => process.stdout.write(s) });
10
- * enc.beginArray('employees', ['id', 'name', 'department', 'salary']);
11
- * enc.writeRow([1, 'Alice', 'Engineering', 95000]);
12
- * enc.writeRow([2, 'Bob', 'Sales', 72000]);
13
- * enc.endArray();
14
- * enc.close();
15
- * ```
16
- */
17
- export declare class GenericStreamEncoder {
18
- private readonly writer;
19
- private sections;
20
- private current;
21
- constructor(writer: StreamWriter);
22
- /** Start a tabular array section with deferred count [?]. */
23
- beginArray(name: string, fields: string[]): void;
24
- /** Emit a single pipe-separated row immediately. */
25
- writeRow(values: unknown[]): void;
26
- /** Close the current array section and record its count. */
27
- endArray(): void;
28
- /** Emit a key=value line immediately. */
29
- writeKV(key: string, value: unknown): void;
30
- /** Start a nested object section (## key). */
31
- writeSection(name: string): void;
32
- /** Emit a primitive array inline: name[N]: val1,val2,val3 */
33
- writeInlineArray(name: string, values: unknown[]): void;
34
- /** Emit the ##! summary trailer with final counts. Must be called after all data. */
35
- close(): void;
36
- private endArrayInternal;
37
- }
@@ -1,87 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GenericStreamEncoder = void 0;
4
- const scalar_js_1 = require("./scalar.js");
5
- /**
6
- * GenericStreamEncoder writes GCF tabular output incrementally as rows arrive.
7
- * Zero buffering: each row is written immediately. A trailer summary is
8
- * emitted on close() with the final counts.
9
- *
10
- * @example
11
- * ```ts
12
- * const enc = new GenericStreamEncoder({ write: (s) => process.stdout.write(s) });
13
- * enc.beginArray('employees', ['id', 'name', 'department', 'salary']);
14
- * enc.writeRow([1, 'Alice', 'Engineering', 95000]);
15
- * enc.writeRow([2, 'Bob', 'Sales', 72000]);
16
- * enc.endArray();
17
- * enc.close();
18
- * ```
19
- */
20
- class GenericStreamEncoder {
21
- writer;
22
- sections = [];
23
- current = null;
24
- constructor(writer) {
25
- this.writer = writer;
26
- }
27
- /** Start a tabular array section with deferred count [?]. */
28
- beginArray(name, fields) {
29
- if (this.current !== null) {
30
- this.endArrayInternal();
31
- }
32
- this.writer.write(`## ${name} [?]{${fields.join(',')}}\n`);
33
- this.current = { name, fields, count: 0 };
34
- }
35
- /** Emit a single pipe-separated row immediately. */
36
- writeRow(values) {
37
- if (this.current === null) {
38
- return;
39
- }
40
- const parts = values.map(formatValue);
41
- this.writer.write(`${parts.join('|')}\n`);
42
- this.current.count++;
43
- }
44
- /** Close the current array section and record its count. */
45
- endArray() {
46
- this.endArrayInternal();
47
- }
48
- /** Emit a key=value line immediately. */
49
- writeKV(key, value) {
50
- this.writer.write(`${key}=${formatValue(value)}\n`);
51
- }
52
- /** Start a nested object section (## key). */
53
- writeSection(name) {
54
- if (this.current !== null) {
55
- this.endArrayInternal();
56
- }
57
- this.writer.write(`## ${name}\n`);
58
- }
59
- /** Emit a primitive array inline: name[N]: val1,val2,val3 */
60
- writeInlineArray(name, values) {
61
- const parts = values.map(formatValue);
62
- this.writer.write(`${name}[${values.length}]: ${parts.join(',')}\n`);
63
- }
64
- /** Emit the ##! summary trailer with final counts. Must be called after all data. */
65
- close() {
66
- if (this.current !== null) {
67
- this.endArrayInternal();
68
- }
69
- if (this.sections.length === 0) {
70
- return;
71
- }
72
- const counts = this.sections.map(s => String(s.count));
73
- this.writer.write(`##! summary counts=${counts.join(',')}\n`);
74
- }
75
- endArrayInternal() {
76
- if (this.current === null) {
77
- return;
78
- }
79
- this.sections.push({ name: this.current.name, count: this.current.count });
80
- this.current = null;
81
- }
82
- }
83
- exports.GenericStreamEncoder = GenericStreamEncoder;
84
- function formatValue(v) {
85
- return (0, scalar_js_1.formatScalar)(v, 0x7c); // '|' context
86
- }
87
- //# sourceMappingURL=stream_generic.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream_generic.js","sourceRoot":"","sources":["../../src/stream_generic.ts"],"names":[],"mappings":";;;AACA,2CAA2C;AAa3C;;;;;;;;;;;;;;GAcG;AACH,MAAa,oBAAoB;IACd,MAAM,CAAe;IAC9B,QAAQ,GAAmB,EAAE,CAAC;IAC9B,OAAO,GAAuB,IAAI,CAAC;IAE3C,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,6DAA6D;I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g/auth.Middleware") */
6
- qualifiedName: string;
7
- /** Node type: "function", "type", "method", etc. */
8
- kind: string;
9
- /** Relevance score (0.0 to 1.0) */
10
- score: number;
11
- /** Discovery method: "lsp_resolved", "ast_inferred", etc. */
12
- provenance: string;
13
- /** Hops from query center (0=target, 1=related, 2+=extended) */
14
- distance: number;
15
- /** Optional: function/method signature */
16
- signature?: string;
17
- /** Optional: score breakdown */
18
- components?: Components;
19
- }
20
- /**
21
- * Components holds the score breakdown for a symbol.
22
- */
23
- export interface Components {
24
- blastRadius: number;
25
- confidence: number;
26
- recency: number;
27
- distance: number;
28
- }
29
- /**
30
- * Edge represents a directed relationship in a GCF payload.
31
- */
32
- export interface Edge {
33
- /** Qualified name of source symbol */
34
- source: string;
35
- /** Qualified name of target symbol */
36
- target: string;
37
- /** Relationship type (e.g., "calls", "imports", "implements") */
38
- edgeType: string;
39
- /** Optional: "added", "removed", "unchanged" (for diff responses) */
40
- status?: string;
41
- }
42
- /**
43
- * Payload is the input/output structure for GCF encoding/decoding.
44
- */
45
- export interface Payload {
46
- /** Producing tool name (e.g., "context_for_task") */
47
- tool: string;
48
- /** Token budget requested by the consumer */
49
- tokenBudget: number;
50
- /** Actual tokens consumed by this payload */
51
- tokensUsed: number;
52
- /** Content-addressed identity (hex SHA-256), enables delta encoding */
53
- packRoot?: string;
54
- /** Ordered by score descending within each distance group */
55
- symbols: Symbol[];
56
- /** Directed relationships between symbols */
57
- edges: Edge[];
58
- }
59
- /**
60
- * DeltaPayload represents the diff between a prior context pack and the
61
- * current result. Used for incremental context delivery.
62
- */
63
- export interface DeltaPayload {
64
- tool: string;
65
- /** pack_root the consumer has */
66
- baseRoot: string;
67
- /** pack_root of the current result */
68
- newRoot: string;
69
- removed: Symbol[];
70
- added: Symbol[];
71
- removedEdges: Edge[];
72
- addedEdges: Edge[];
73
- deltaTokens: number;
74
- fullTokens: number;
75
- }
package/dist/cjs/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}