forked from AACTools/AACProcessors-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.node.ts
More file actions
140 lines (127 loc) · 4.4 KB
/
Copy pathindex.node.ts
File metadata and controls
140 lines (127 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/**
* AACProcessors Library
*
* A comprehensive TypeScript library for processing AAC file formats.
*
* @module aac-processors
*/
// ===================================================================
// CORE TYPES (always needed)
// ===================================================================
export * from './core/treeStructure';
export * from './core/baseProcessor';
export * from './core/stringCasing';
// ===================================================================
// PROCESSORS (main functionality)
// ===================================================================
export * from './processors';
// ===================================================================
// NAMESPACES
// ===================================================================
// Analytics namespace (usage/history)
export * as Analytics from './analytics';
// Validation namespace
export * as Validation from './validation';
// Metrics namespace (pageset analytics)
export * as Metrics from './metrics';
// Processor namespaces (platform-specific utilities)
export * as Gridset from './gridset';
export * as Snap from './snap';
export * as OBF from './obf';
export * as Obfset from './obfset';
export * as TouchChat from './touchchat';
export * as Dot from './dot';
export * as Excel from './excel';
export * as Opml from './opml';
export * as ApplePanels from './applePanels';
export * as AstericsGrid from './astericsGrid';
export * as Translation from './translation';
// ===================================================================
// UTILITY FUNCTIONS
// ===================================================================
import { BaseProcessor, ProcessorOptions } from './core/baseProcessor';
import { DotProcessor } from './processors/dotProcessor';
import { ExcelProcessor } from './processors/excelProcessor';
import { OpmlProcessor } from './processors/opmlProcessor';
import { ObfProcessor } from './processors/obfProcessor';
import { GridsetProcessor } from './processors/gridsetProcessor';
import { SnapProcessor } from './processors/snapProcessor';
import { TouchChatProcessor } from './processors/touchchatProcessor';
import { ApplePanelsProcessor } from './processors/applePanelsProcessor';
import { AstericsGridProcessor } from './processors/astericsGridProcessor';
import { ObfsetProcessor } from './processors/obfsetProcessor';
/**
* Factory function to get the appropriate processor for a file extension
* @param filePathOrExtension - File path or extension (e.g., '.dot', '/path/to/file.obf')
* @returns The appropriate processor instance
* @throws Error if the file extension is not supported
*
* @example
* const processor = getProcessor('/path/to/file.gridset');
* const tree = processor.loadIntoTree('/path/to/file.gridset');
*/
export function getProcessor(
filePathOrExtension: string,
options?: ProcessorOptions
): BaseProcessor {
// Extract extension from file path
const extension = filePathOrExtension.includes('.')
? filePathOrExtension.substring(filePathOrExtension.lastIndexOf('.'))
: filePathOrExtension;
switch (extension.toLowerCase()) {
case '.dot':
return new DotProcessor(options);
case '.xlsx':
return new ExcelProcessor(options);
case '.opml':
return new OpmlProcessor(options);
case '.obf':
case '.obz':
return new ObfProcessor(options);
case '.obfset':
return new ObfsetProcessor(options);
case '.gridset':
case '.gridsetx':
return new GridsetProcessor(options);
case '.spb':
case '.sps':
return new SnapProcessor(options);
case '.ce':
return new TouchChatProcessor(options);
case '.plist':
return new ApplePanelsProcessor(options);
case '.grd':
return new AstericsGridProcessor(options);
default:
throw new Error(`Unsupported file extension: ${extension}`);
}
}
/**
* Get all supported file extensions
* @returns Array of supported file extensions
*/
export function getSupportedExtensions(): string[] {
return [
'.dot',
'.xlsx',
'.opml',
'.obf',
'.obz',
'.obfset',
'.gridset',
'.gridsetx',
'.spb',
'.sps',
'.ce',
'.plist',
'.grd',
];
}
/**
* Check if a file extension is supported
* @param extension - File extension to check
* @returns True if the extension is supported
*/
export function isExtensionSupported(extension: string): boolean {
return getSupportedExtensions().includes(extension.toLowerCase());
}