@jotx-labs/core 2.4.82 → 2.4.130

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 (59) hide show
  1. package/README.md +2 -2
  2. package/dist/__tests__/events.test 2.d.ts +2 -0
  3. package/dist/__tests__/events.test 2.d.ts.map +1 -0
  4. package/dist/__tests__/events.test 2.js +63 -0
  5. package/dist/__tests__/events.test 2.js.map +1 -0
  6. package/dist/parser/serializer.d.ts.map +1 -1
  7. package/dist/parser/serializer.js +8 -0
  8. package/dist/parser/serializer.js.map +1 -1
  9. package/dist/parser/tokenizer.new 2.d.ts +32 -0
  10. package/dist/parser/tokenizer.new 2.d.ts.map +1 -0
  11. package/dist/parser/tokenizer.new 2.js +195 -0
  12. package/dist/parser/tokenizer.new 2.js.map +1 -0
  13. package/dist/parser/tokenizer.new.d.ts.map +1 -1
  14. package/dist/parser/tokenizer.new.js +5 -4
  15. package/dist/parser/tokenizer.new.js.map +1 -1
  16. package/dist/platform/NullPlatformAdapter 2.d.ts +18 -0
  17. package/dist/platform/NullPlatformAdapter 2.d.ts.map +1 -0
  18. package/dist/platform/NullPlatformAdapter 2.js +41 -0
  19. package/dist/platform/NullPlatformAdapter 2.js.map +1 -0
  20. package/dist/platform/PlatformAdapter 2.d.ts +22 -0
  21. package/dist/platform/PlatformAdapter 2.d.ts.map +1 -0
  22. package/dist/platform/PlatformAdapter 2.js +7 -0
  23. package/dist/platform/PlatformAdapter 2.js.map +1 -0
  24. package/dist/platform/index 2.d.ts +3 -0
  25. package/dist/platform/index 2.d.ts.map +1 -0
  26. package/dist/{links/index.js → platform/index 2.js } +3 -12
  27. package/dist/platform/index 2.js.map +1 -0
  28. package/dist/plugin/PluginSystem 2.d.ts +46 -0
  29. package/dist/plugin/PluginSystem 2.d.ts.map +1 -0
  30. package/dist/plugin/PluginSystem 2.js +58 -0
  31. package/dist/plugin/PluginSystem 2.js.map +1 -0
  32. package/dist/plugin/index 2.d.ts +2 -0
  33. package/dist/plugin/index 2.d.ts.map +1 -0
  34. package/dist/plugin/index 2.js +18 -0
  35. package/dist/plugin/index 2.js.map +1 -0
  36. package/dist/types/nodeManager 2.d.ts +86 -0
  37. package/dist/types/nodeManager 2.d.ts.map +1 -0
  38. package/dist/types/nodeManager 2.js +7 -0
  39. package/dist/types/nodeManager 2.js.map +1 -0
  40. package/dist/utils/idGenerator 2.d.ts +34 -0
  41. package/dist/utils/idGenerator 2.d.ts.map +1 -0
  42. package/dist/utils/idGenerator 2.js +105 -0
  43. package/dist/utils/idGenerator 2.js.map +1 -0
  44. package/package.json +3 -3
  45. package/dist/links/LinkIndexer.d.ts +0 -85
  46. package/dist/links/LinkIndexer.d.ts.map +0 -1
  47. package/dist/links/LinkIndexer.js +0 -238
  48. package/dist/links/LinkIndexer.js.map +0 -1
  49. package/dist/links/LinkParser.d.ts +0 -41
  50. package/dist/links/LinkParser.d.ts.map +0 -1
  51. package/dist/links/LinkParser.js +0 -162
  52. package/dist/links/LinkParser.js.map +0 -1
  53. package/dist/links/index.d.ts +0 -12
  54. package/dist/links/index.d.ts.map +0 -1
  55. package/dist/links/index.js.map +0 -1
  56. package/dist/links/types.d.ts +0 -66
  57. package/dist/links/types.d.ts.map +0 -1
  58. package/dist/links/types.js +0 -7
  59. package/dist/links/types.js.map +0 -1
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Plugin system - Core plugin interfaces and manager
3
+ */
4
+ export interface Plugin {
5
+ name: string;
6
+ version: string;
7
+ description?: string;
8
+ author?: string;
9
+ onLoad?(core: any): void | Promise<void>;
10
+ onUnload?(): void | Promise<void>;
11
+ blocks?: BlockDefinition[];
12
+ validators?: ValidatorDefinition[];
13
+ serializers?: SerializerDefinition[];
14
+ events?: EventListener[];
15
+ }
16
+ export interface BlockDefinition {
17
+ type: string;
18
+ blockClass: any;
19
+ schema?: any;
20
+ renderer?: any;
21
+ }
22
+ export interface ValidatorDefinition {
23
+ name: string;
24
+ validate: (ast: any) => any;
25
+ }
26
+ export interface SerializerDefinition {
27
+ name: string;
28
+ serialize: (ast: any) => string;
29
+ }
30
+ export interface EventListener {
31
+ event: string;
32
+ handler: (data: any) => void;
33
+ }
34
+ export declare class PluginManager {
35
+ private plugins;
36
+ private loadedPlugins;
37
+ register(plugin: Plugin): void;
38
+ unregister(name: string): void;
39
+ load(name: string, core: any): Promise<void>;
40
+ unload(name: string): Promise<void>;
41
+ get(name: string): Plugin | undefined;
42
+ getAll(): Plugin[];
43
+ getLoaded(): Plugin[];
44
+ isLoaded(name: string): boolean;
45
+ }
46
+ //# sourceMappingURL=PluginSystem%202.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginSystem 2.d.ts","sourceRoot":"","sources":["../../src/plugin/PluginSystem 2.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IAGf,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxC,QAAQ,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAGjC,MAAM,CAAC,EAAE,eAAe,EAAE,CAAA;IAC1B,UAAU,CAAC,EAAE,mBAAmB,EAAE,CAAA;IAClC,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAA;IACpC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAA;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,GAAG,CAAA;IACf,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,QAAQ,CAAC,EAAE,GAAG,CAAA;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,CAAA;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAA;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAA;CAC7B;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,aAAa,CAAoB;IAEzC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ9B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKxB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAe5C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIrC,MAAM,IAAI,MAAM,EAAE;IAIlB,SAAS,IAAI,MAAM,EAAE;IAMrB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGhC"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ /**
3
+ * Plugin system - Core plugin interfaces and manager
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PluginManager = void 0;
7
+ class PluginManager {
8
+ constructor() {
9
+ this.plugins = new Map();
10
+ this.loadedPlugins = new Set();
11
+ }
12
+ register(plugin) {
13
+ if (this.plugins.has(plugin.name)) {
14
+ console.warn(`Plugin ${plugin.name} already registered`);
15
+ return;
16
+ }
17
+ this.plugins.set(plugin.name, plugin);
18
+ }
19
+ unregister(name) {
20
+ this.plugins.delete(name);
21
+ this.loadedPlugins.delete(name);
22
+ }
23
+ async load(name, core) {
24
+ const plugin = this.plugins.get(name);
25
+ if (!plugin) {
26
+ throw new Error(`Plugin ${name} not found`);
27
+ }
28
+ if (this.loadedPlugins.has(name)) {
29
+ console.warn(`Plugin ${name} already loaded`);
30
+ return;
31
+ }
32
+ await plugin.onLoad?.(core);
33
+ this.loadedPlugins.add(name);
34
+ }
35
+ async unload(name) {
36
+ const plugin = this.plugins.get(name);
37
+ if (!plugin)
38
+ return;
39
+ await plugin.onUnload?.();
40
+ this.loadedPlugins.delete(name);
41
+ }
42
+ get(name) {
43
+ return this.plugins.get(name);
44
+ }
45
+ getAll() {
46
+ return Array.from(this.plugins.values());
47
+ }
48
+ getLoaded() {
49
+ return Array.from(this.loadedPlugins)
50
+ .map(name => this.plugins.get(name))
51
+ .filter((p) => p !== undefined);
52
+ }
53
+ isLoaded(name) {
54
+ return this.loadedPlugins.has(name);
55
+ }
56
+ }
57
+ exports.PluginManager = PluginManager;
58
+ //# sourceMappingURL=PluginSystem%202.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginSystem 2.js","sourceRoot":"","sources":["../../src/plugin/PluginSystem 2.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAyCH,MAAa,aAAa;IAA1B;QACU,YAAO,GAAG,IAAI,GAAG,EAAkB,CAAA;QACnC,kBAAa,GAAG,IAAI,GAAG,EAAU,CAAA;IAuD3C,CAAC;IArDC,QAAQ,CAAC,MAAc;QACrB,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,OAAO,CAAC,IAAI,CAAC,UAAU,MAAM,CAAC,IAAI,qBAAqB,CAAC,CAAA;YACxD,OAAM;QACR,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACvC,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACzB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C,CAAC;aACnC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAA;IAChD,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;CACF;AAzDD,sCAyDC"}
@@ -0,0 +1,2 @@
1
+ export * from './PluginSystem';
2
+ //# sourceMappingURL=index%202.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index 2.d.ts","sourceRoot":"","sources":["../../src/plugin/index 2.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./PluginSystem"), exports);
18
+ //# sourceMappingURL=index%202.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index 2.js","sourceRoot":"","sources":["../../src/plugin/index 2.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * NodeManager - Core types and interfaces
3
+ * Platform-agnostic definitions for node management
4
+ */
5
+ /**
6
+ * Represents a single node (block) in the knowledge graph
7
+ */
8
+ export interface NodeEntry {
9
+ /** Unique identifier (shortUUID) - MUST be unique across entire workspace */
10
+ id: string;
11
+ /** Block type (def, mermaid, heading, paragraph, etc.) */
12
+ type: string;
13
+ /** Absolute path to the .jot file containing this node */
14
+ filePath: string;
15
+ /** Display label (def name, heading text, etc.) */
16
+ label: string;
17
+ /** Block properties from AST */
18
+ properties: Record<string, any>;
19
+ /** Content for preview (text/src/json) */
20
+ content?: string;
21
+ /** Parent node ID (for def hierarchy) */
22
+ parentId?: string;
23
+ /** Child node IDs (for def hierarchy) */
24
+ children: string[];
25
+ }
26
+ /**
27
+ * Represents a def block in the hierarchy tree
28
+ */
29
+ export interface DefTreeNode {
30
+ /** ID of the NodeEntry */
31
+ nodeId: string;
32
+ /** Child def nodes */
33
+ children: DefTreeNode[];
34
+ }
35
+ /**
36
+ * Platform-agnostic NodeManager interface
37
+ * Implemented by VSCodeNodeManager, BrowserNodeManager, etc.
38
+ */
39
+ export interface INodeManager {
40
+ /**
41
+ * Get node by ID - O(1)
42
+ */
43
+ getNode(id: string): NodeEntry | undefined;
44
+ /**
45
+ * Get all nodes in a file - O(1)
46
+ */
47
+ getNodesByFile(filePath: string): NodeEntry[];
48
+ /**
49
+ * Get all nodes of a type - O(1)
50
+ */
51
+ getNodesByType(type: string): NodeEntry[];
52
+ /**
53
+ * Get def tree for a document
54
+ */
55
+ getDefTree(filePath: string): DefTreeNode | undefined;
56
+ /**
57
+ * Get nodes this node links to
58
+ */
59
+ getLinkedNodes(nodeId: string): NodeEntry[];
60
+ /**
61
+ * Get nodes that link to this node (backlinks)
62
+ */
63
+ getBacklinks(nodeId: string): NodeEntry[];
64
+ /**
65
+ * Validate unique IDs across workspace
66
+ * @returns Map of duplicate IDs to file paths
67
+ */
68
+ validateUniqueIds(): Map<string, string[]>;
69
+ /**
70
+ * Re-index a specific file
71
+ */
72
+ reindexFile(filePath: string): Promise<void>;
73
+ /**
74
+ * Full workspace reindex
75
+ */
76
+ fullReindex(): Promise<void>;
77
+ }
78
+ /**
79
+ * Event emitted when graph changes
80
+ */
81
+ export interface NodeManagerChangeEvent {
82
+ type: 'add' | 'update' | 'delete';
83
+ nodeIds: string[];
84
+ filePath: string;
85
+ }
86
+ //# sourceMappingURL=nodeManager%202.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeManager 2.d.ts","sourceRoot":"","sources":["../../src/types/nodeManager 2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,6EAA6E;IAC7E,EAAE,EAAE,MAAM,CAAA;IAEV,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IAEZ,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAA;IAEhB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAA;IAEb,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAE/B,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,EAAE,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAA;IAEd,sBAAsB;IACtB,QAAQ,EAAE,WAAW,EAAE,CAAA;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;IAE1C;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,CAAA;IAE7C;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,CAAA;IAEzC;;OAEG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAA;IAErD;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CAAA;IAE3C;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CAAA;IAEzC;;;OAGG;IACH,iBAAiB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAE1C;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5C;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAA;IACjC,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACnB"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * NodeManager - Core types and interfaces
4
+ * Platform-agnostic definitions for node management
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=nodeManager%202.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeManager 2.js","sourceRoot":"","sources":["../../src/types/nodeManager 2.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Block ID Generator - Short UUIDs for global uniqueness
3
+ *
4
+ * Generates 8-character lowercase alphanumeric IDs for blocks.
5
+ * Format: [0-9a-z]{8}
6
+ * Examples: "xk4h2p9d", "m3n8q7wz", "p2b5k9tx"
7
+ *
8
+ * Collision probability: ~1 in 2.8 trillion
9
+ * Safe for millions of blocks across thousands of documents
10
+ */
11
+ /**
12
+ * Generate a short, globally unique ID for blocks
13
+ * Uses crypto.getRandomValues for secure random generation
14
+ */
15
+ export declare function generateBlockId(): string;
16
+ /**
17
+ * Validate if a string is a valid block ID
18
+ * Accepts both new format (8-char alphanumeric) and legacy formats
19
+ */
20
+ export declare function isValidBlockId(id: string): boolean;
21
+ /**
22
+ * Generate multiple unique IDs at once
23
+ * Ensures no duplicates in the returned array
24
+ */
25
+ export declare function generateBlockIds(count: number): string[];
26
+ /**
27
+ * Check if an ID is in the new short UUID format
28
+ */
29
+ export declare function isShortUUID(id: string): boolean;
30
+ /**
31
+ * Check if an ID is in legacy sequential format (block_N, item_N, etc.)
32
+ */
33
+ export declare function isLegacySequentialId(id: string): boolean;
34
+ //# sourceMappingURL=idGenerator%202.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idGenerator 2.d.ts","sourceRoot":"","sources":["../../src/utils/idGenerator 2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CA2BxC;AAcD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAalD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAMxD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAExD"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /**
3
+ * Block ID Generator - Short UUIDs for global uniqueness
4
+ *
5
+ * Generates 8-character lowercase alphanumeric IDs for blocks.
6
+ * Format: [0-9a-z]{8}
7
+ * Examples: "xk4h2p9d", "m3n8q7wz", "p2b5k9tx"
8
+ *
9
+ * Collision probability: ~1 in 2.8 trillion
10
+ * Safe for millions of blocks across thousands of documents
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.generateBlockId = generateBlockId;
14
+ exports.isValidBlockId = isValidBlockId;
15
+ exports.generateBlockIds = generateBlockIds;
16
+ exports.isShortUUID = isShortUUID;
17
+ exports.isLegacySequentialId = isLegacySequentialId;
18
+ const ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';
19
+ const ID_LENGTH = 8;
20
+ /**
21
+ * Generate a short, globally unique ID for blocks
22
+ * Uses crypto.getRandomValues for secure random generation
23
+ */
24
+ function generateBlockId() {
25
+ let id = '';
26
+ // Use crypto API for better randomness (works in Node.js 15+ and all modern browsers)
27
+ if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
28
+ const bytes = crypto.getRandomValues(new Uint8Array(ID_LENGTH));
29
+ for (let i = 0; i < ID_LENGTH; i++) {
30
+ id += ALPHABET[bytes[i] % ALPHABET.length];
31
+ }
32
+ }
33
+ else if (typeof require !== 'undefined') {
34
+ // Fallback for older Node.js environments
35
+ try {
36
+ const cryptoNode = require('crypto');
37
+ const bytes = cryptoNode.randomBytes(ID_LENGTH);
38
+ for (let i = 0; i < ID_LENGTH; i++) {
39
+ id += ALPHABET[bytes[i] % ALPHABET.length];
40
+ }
41
+ }
42
+ catch {
43
+ // Final fallback to Math.random (less secure but works everywhere)
44
+ id = fallbackGenerateId();
45
+ }
46
+ }
47
+ else {
48
+ // Fallback for environments without crypto
49
+ id = fallbackGenerateId();
50
+ }
51
+ return id;
52
+ }
53
+ /**
54
+ * Fallback ID generator using Math.random
55
+ * Less cryptographically secure but works in all environments
56
+ */
57
+ function fallbackGenerateId() {
58
+ let id = '';
59
+ for (let i = 0; i < ID_LENGTH; i++) {
60
+ id += ALPHABET[Math.floor(Math.random() * ALPHABET.length)];
61
+ }
62
+ return id;
63
+ }
64
+ /**
65
+ * Validate if a string is a valid block ID
66
+ * Accepts both new format (8-char alphanumeric) and legacy formats
67
+ */
68
+ function isValidBlockId(id) {
69
+ if (!id || typeof id !== 'string')
70
+ return false;
71
+ // New format: 8 lowercase alphanumeric characters
72
+ if (/^[0-9a-z]{8}$/.test(id))
73
+ return true;
74
+ // Legacy formats (for backward compatibility):
75
+ // - Sequential: block_1, block_123
76
+ // - Descriptive: h1, h2, p1, intro, etc.
77
+ // - Any alphanumeric with underscores
78
+ if (/^[a-zA-Z0-9_]+$/.test(id))
79
+ return true;
80
+ return false;
81
+ }
82
+ /**
83
+ * Generate multiple unique IDs at once
84
+ * Ensures no duplicates in the returned array
85
+ */
86
+ function generateBlockIds(count) {
87
+ const ids = new Set();
88
+ while (ids.size < count) {
89
+ ids.add(generateBlockId());
90
+ }
91
+ return Array.from(ids);
92
+ }
93
+ /**
94
+ * Check if an ID is in the new short UUID format
95
+ */
96
+ function isShortUUID(id) {
97
+ return /^[0-9a-z]{8}$/.test(id);
98
+ }
99
+ /**
100
+ * Check if an ID is in legacy sequential format (block_N, item_N, etc.)
101
+ */
102
+ function isLegacySequentialId(id) {
103
+ return /^[a-z]+_\d+$/i.test(id);
104
+ }
105
+ //# sourceMappingURL=idGenerator%202.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idGenerator 2.js","sourceRoot":"","sources":["../../src/utils/idGenerator 2.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AASH,0CA2BC;AAkBD,wCAaC;AAMD,4CAMC;AAKD,kCAEC;AAKD,oDAEC;AA3FD,MAAM,QAAQ,GAAG,sCAAsC,CAAC;AACxD,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB;;;GAGG;AACH,SAAgB,eAAe;IAC3B,IAAI,EAAE,GAAG,EAAE,CAAC;IAEZ,sFAAsF;IACtF,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;QAChE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;YACjC,EAAE,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC;SAAM,IAAI,OAAO,OAAO,KA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,CAAC;QAAE,OAAO,IAAI,CAAC;IAE5C,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,KAAa;IAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,OAAO,GAAG,CAAC,IAAI,GAAG,KAAK,EAAE,CAAC;QACtB,GAAG,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,EAAU;IAClC,OAAO,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,EAAU;IAC3C,OAAO,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jotx-labs/core",
3
- "version": "2.4.82",
3
+ "version": "2.4.130",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -36,6 +36,6 @@
36
36
  "dependencies": {
37
37
  "@types/marked": "^6.0.0",
38
38
  "marked": "^17.0.1",
39
- "@jotx-labs/registry": "file:../registry"
39
+ "@jotx-labs/registry": "^2.4.130"
40
40
  }
41
- }
41
+ }
@@ -1,85 +0,0 @@
1
- /**
2
- * Link Indexer - Build and maintain link index for documents
3
- *
4
- * Tracks:
5
- * - Outgoing links from each document
6
- * - Incoming links (backlinks) to each document
7
- * - Tags used across documents
8
- * - Orphaned documents (no links)
9
- *
10
- * Updates incrementally when documents change
11
- */
12
- import { AST } from '../types/ast';
13
- import { LinkIndex, LinkIndexEntry, DocumentLink, ParsedLink } from './types';
14
- /**
15
- * Link Indexer class
16
- */
17
- export declare class LinkIndexer {
18
- private index;
19
- constructor();
20
- /**
21
- * Index a document and extract all links
22
- */
23
- indexDocument(documentPath: string, ast: AST): void;
24
- /**
25
- * Remove a document from the index
26
- */
27
- removeDocument(documentPath: string): void;
28
- /**
29
- * Get all links from a document
30
- */
31
- getDocumentLinks(documentPath: string): LinkIndexEntry | undefined;
32
- /**
33
- * Get backlinks for a document (who links to this doc)
34
- */
35
- getBacklinks(documentPath: string): DocumentLink[];
36
- /**
37
- * Get outgoing links from a document (where this doc links to)
38
- */
39
- getOutgoingLinks(documentPath: string): ParsedLink[];
40
- /**
41
- * Get all documents using a specific tag
42
- */
43
- getDocumentsByTag(tag: string): string[];
44
- /**
45
- * Get all orphaned documents (no incoming or outgoing links)
46
- */
47
- getOrphans(): string[];
48
- /**
49
- * Get the complete index
50
- */
51
- getIndex(): LinkIndex;
52
- /**
53
- * Clear the entire index
54
- */
55
- clear(): void;
56
- /**
57
- * Extract links from AST blocks recursively
58
- */
59
- private extractLinksFromAST;
60
- /**
61
- * Extract links from a single block and its children
62
- */
63
- private extractLinksFromBlock;
64
- /**
65
- * Update backlinks for all documents
66
- */
67
- private updateBacklinks;
68
- /**
69
- * Find target document by name (handles .jot extension)
70
- */
71
- private findTargetDocument;
72
- /**
73
- * Extract context around a link for backlinks display
74
- */
75
- private extractContext;
76
- /**
77
- * Update orphans list (documents with no links in/out)
78
- */
79
- private updateOrphans;
80
- }
81
- /**
82
- * Create a global link indexer instance
83
- */
84
- export declare function createLinkIndexer(): LinkIndexer;
85
- //# sourceMappingURL=LinkIndexer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LinkIndexer.d.ts","sourceRoot":"","sources":["../../src/links/LinkIndexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,GAAG,EAAa,MAAM,cAAc,CAAA;AAE7C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAE7E;;GAEG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,KAAK,CAAW;;IAUxB;;OAEG;IACH,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI;IA+BnD;;OAEG;IACH,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAyB1C;;OAEG;IACH,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIlE;;OAEG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY,EAAE;IAKlD;;OAEG;IACH,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,EAAE;IAKpD;;OAEG;IACH,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE;IAIxC;;OAEG;IACH,UAAU,IAAI,MAAM,EAAE;IAItB;;OAEG;IACH,QAAQ,IAAI,SAAS;IAIrB;;OAEG;IACH,KAAK,IAAI,IAAI;IAQb;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAW3B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAqB7B;;OAEG;IACH,OAAO,CAAC,eAAe;IA0BvB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAoB1B;;OAEG;IACH,OAAO,CAAC,cAAc;IAMtB;;OAEG;IACH,OAAO,CAAC,aAAa;CAYxB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAE/C"}