@talex-touch/utils 1.0.18 → 1.0.21
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/channel/index.ts +49 -1
- package/common/index.ts +2 -0
- package/common/search/gather.ts +45 -0
- package/common/search/index.ts +67 -0
- package/common/storage/constants.ts +16 -2
- package/common/storage/entity/index.ts +2 -1
- package/common/storage/entity/openers.ts +32 -0
- package/common/storage/entity/shortcut-settings.ts +22 -0
- package/common/storage/shortcut-storage.ts +58 -0
- package/common/utils/file.ts +62 -0
- package/common/{utils.ts → utils/index.ts} +14 -2
- package/common/utils/polling.ts +184 -0
- package/common/utils/task-queue.ts +108 -0
- package/common/utils/time.ts +374 -0
- package/core-box/README.md +8 -8
- package/core-box/builder/index.ts +6 -0
- package/core-box/builder/tuff-builder.example.ts.bak +258 -0
- package/core-box/builder/tuff-builder.ts +1162 -0
- package/core-box/index.ts +5 -2
- package/core-box/run-tests.sh +7 -0
- package/core-box/search.ts +1 -536
- package/core-box/tuff/index.ts +6 -0
- package/core-box/tuff/tuff-dsl.ts +1412 -0
- package/electron/clipboard-helper.ts +199 -0
- package/electron/env-tool.ts +36 -2
- package/electron/file-parsers/index.ts +8 -0
- package/electron/file-parsers/parsers/text-parser.ts +109 -0
- package/electron/file-parsers/registry.ts +92 -0
- package/electron/file-parsers/types.ts +58 -0
- package/electron/index.ts +3 -0
- package/eventbus/index.ts +0 -7
- package/index.ts +3 -1
- package/package.json +4 -29
- package/plugin/channel.ts +48 -16
- package/plugin/index.ts +194 -30
- package/plugin/log/types.ts +11 -0
- package/plugin/node/index.ts +4 -0
- package/plugin/node/logger-manager.ts +113 -0
- package/plugin/{log → node}/logger.ts +41 -7
- package/plugin/plugin-source.ts +74 -0
- package/plugin/preload.ts +5 -15
- package/plugin/providers/index.ts +2 -0
- package/plugin/providers/registry.ts +47 -0
- package/plugin/providers/types.ts +54 -0
- package/plugin/risk/index.ts +1 -0
- package/plugin/risk/types.ts +20 -0
- package/plugin/sdk/enum/bridge-event.ts +4 -0
- package/plugin/sdk/enum/index.ts +1 -0
- package/plugin/sdk/hooks/bridge.ts +68 -0
- package/plugin/sdk/hooks/index.ts +2 -1
- package/plugin/sdk/hooks/life-cycle.ts +2 -4
- package/plugin/sdk/index.ts +2 -0
- package/plugin/sdk/storage.ts +84 -0
- package/plugin/sdk/types.ts +2 -2
- package/plugin/sdk/window/index.ts +5 -3
- package/preload/index.ts +2 -0
- package/preload/loading.ts +15 -0
- package/preload/renderer.ts +41 -0
- package/renderer/hooks/arg-mapper.ts +79 -0
- package/renderer/hooks/index.ts +2 -0
- package/renderer/hooks/initialize.ts +198 -0
- package/renderer/index.ts +3 -0
- package/renderer/storage/app-settings.ts +2 -0
- package/renderer/storage/base-storage.ts +1 -0
- package/renderer/storage/openers.ts +11 -0
- package/renderer/touch-sdk/env.ts +106 -0
- package/renderer/touch-sdk/index.ts +108 -0
- package/renderer/touch-sdk/terminal.ts +85 -0
- package/renderer/touch-sdk/utils.ts +61 -0
- package/search/levenshtein-utils.ts +39 -0
- package/search/types.ts +16 -16
- package/types/index.ts +2 -1
- package/types/modules/base.ts +146 -0
- package/types/modules/index.ts +4 -0
- package/types/modules/module-lifecycle.ts +148 -0
- package/types/modules/module-manager.ts +99 -0
- package/types/modules/module.ts +112 -0
- package/types/touch-app-core.ts +16 -93
- package/core-box/types.ts +0 -384
- package/plugin/log/logger-manager.ts +0 -60
package/types/touch-app-core.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { OpenDevToolsOptions } from "electron";
|
|
1
|
+
import { BrowserWindowConstructorOptions, OpenDevToolsOptions } from "electron";
|
|
2
|
+
import { IBaseModuleManager, IBaseModule } from './modules'
|
|
2
3
|
|
|
3
4
|
export namespace TalexTouch {
|
|
4
5
|
export interface TouchApp {
|
|
5
6
|
app: Electron.App;
|
|
6
7
|
window: ITouchWindow;
|
|
7
8
|
version: AppVersion;
|
|
8
|
-
moduleManager:
|
|
9
|
+
moduleManager: IBaseModuleManager;
|
|
9
10
|
config: IConfiguration;
|
|
10
11
|
rootPath: string;
|
|
11
12
|
}
|
|
@@ -46,14 +47,19 @@ export namespace TalexTouch {
|
|
|
46
47
|
|
|
47
48
|
loadURL(
|
|
48
49
|
url: string,
|
|
49
|
-
options?: LoadURLOptions | undefined
|
|
50
|
+
options?: LoadURLOptions | undefined,
|
|
50
51
|
): Promise<Electron.WebContents>;
|
|
51
52
|
loadFile(
|
|
52
53
|
filePath: string,
|
|
53
|
-
options?: LoadFileOptions | undefined
|
|
54
|
+
options?: LoadFileOptions | undefined,
|
|
54
55
|
): Promise<Electron.WebContents>;
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
export type TouchWindowConstructorOptions =
|
|
59
|
+
BrowserWindowConstructorOptions & {
|
|
60
|
+
autoShow?: boolean;
|
|
61
|
+
};
|
|
62
|
+
|
|
57
63
|
export type LoadFileOptions = Electron.LoadFileOptions & {
|
|
58
64
|
devtools?: boolean | "detach" | "left" | "right" | "bottom" | "undocked";
|
|
59
65
|
};
|
|
@@ -61,99 +67,16 @@ export namespace TalexTouch {
|
|
|
61
67
|
devtools?: boolean | "detach" | "left" | "right" | "bottom" | "undocked";
|
|
62
68
|
};
|
|
63
69
|
|
|
64
|
-
export interface IModuleManager {
|
|
65
|
-
/**
|
|
66
|
-
* Module Loader
|
|
67
|
-
* @param {TalexTouch.IModule} module
|
|
68
|
-
* @description This function will load the module with the given name.
|
|
69
|
-
* @returns {boolean} Returns true if the module is loaded successfully, otherwise returns false.
|
|
70
|
-
*/
|
|
71
|
-
loadModule(module: IModule): boolean | Promise<boolean>;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Module Unloader
|
|
75
|
-
* @param {string}
|
|
76
|
-
* @description This function will unload the module with the given name.
|
|
77
|
-
* @description This function will also call the module's destroy function.
|
|
78
|
-
* @returns {boolean} Returns true if the module is unloaded successfully, otherwise returns false.
|
|
79
|
-
*/
|
|
80
|
-
unloadModule(moduleName: Symbol): boolean | Promise<boolean>;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Module Getter
|
|
84
|
-
* @param {string}
|
|
85
|
-
* @description This function will return the module with the given name.
|
|
86
|
-
* @description If the module is not loaded, this function will return undefined.
|
|
87
|
-
*/
|
|
88
|
-
getModule(moduleName: Symbol): IModule | undefined;
|
|
89
|
-
|
|
90
|
-
// TODO Next version preview
|
|
91
|
-
// /**
|
|
92
|
-
// * Module register event listener
|
|
93
|
-
// */
|
|
94
|
-
// registerEvent(moduleName: Symbol, eventName: string, callback: Function): void
|
|
95
|
-
|
|
96
|
-
// /**
|
|
97
|
-
// * Module unregister event listener
|
|
98
|
-
// */
|
|
99
|
-
// unregisterEvent(moduleName: Symbol, eventName: string, callback: Function): void
|
|
70
|
+
export interface IModuleManager<E> extends IBaseModuleManager<E> {
|
|
100
71
|
|
|
101
|
-
// /**
|
|
102
|
-
// * Module emit event
|
|
103
|
-
// */
|
|
104
|
-
// emitEvent(eventName: string, ...args: any[]): void
|
|
105
72
|
}
|
|
106
73
|
|
|
107
|
-
export interface IModule {
|
|
108
|
-
/**
|
|
109
|
-
* Module name
|
|
110
|
-
* @type {string}
|
|
111
|
-
* @description It's a unique name for each module, and it will be used to identify the module.
|
|
112
|
-
* @description It's also the name of the module's folder, which will be automatically created by the manager.
|
|
113
|
-
* @example "example-module"
|
|
114
|
-
*/
|
|
115
|
-
name: Symbol;
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Custom module file-path
|
|
119
|
-
* @type {string}
|
|
120
|
-
* @description If you want to load the module from a custom file-path, you can set this property.
|
|
121
|
-
* @description If this property is not set, the manager will load the module from the default file-path. (.../modules/{module-name})
|
|
122
|
-
*/
|
|
123
|
-
filePath?: string | boolean;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Module Initialization
|
|
127
|
-
* @param {TalexTouch.TouchApp} app
|
|
128
|
-
* @param {TalexTouch.IModuleManager} manager
|
|
129
|
-
* @description This function will be called when the module is loaded.
|
|
130
|
-
* @description You can use this function to initialize your module.
|
|
131
|
-
* @description You can also use this function to register your module's event listeners.
|
|
132
|
-
*/
|
|
133
|
-
init(
|
|
134
|
-
app: TalexTouch.TouchApp,
|
|
135
|
-
manager: TalexTouch.IModuleManager
|
|
136
|
-
): void;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Module Destruction
|
|
140
|
-
* @param {TalexTouch.TouchApp} app
|
|
141
|
-
* @param {TalexTouch.IModuleManager} manager
|
|
142
|
-
* @description This function will be called when the module is unloaded.
|
|
143
|
-
* @description You can use this function to destroy your module.
|
|
144
|
-
* @description You can also use this function to unregister your module's event listeners.
|
|
145
|
-
* @description This function will be called when the app is closed.
|
|
146
|
-
*/
|
|
147
|
-
destroy(
|
|
148
|
-
app: TalexTouch.TouchApp,
|
|
149
|
-
manager: TalexTouch.IModuleManager
|
|
150
|
-
): void;
|
|
151
|
-
}
|
|
74
|
+
export interface IModule<E> extends IBaseModule<E> {}
|
|
152
75
|
|
|
153
76
|
export interface IConfiguration {
|
|
154
77
|
configPath: string;
|
|
155
|
-
data: TouchAppConfig
|
|
156
|
-
triggerSave: Function
|
|
78
|
+
data: TouchAppConfig;
|
|
79
|
+
triggerSave: Function;
|
|
157
80
|
}
|
|
158
81
|
|
|
159
82
|
export interface TouchAppConfig {
|
|
@@ -162,6 +85,6 @@ export namespace TalexTouch {
|
|
|
162
85
|
height: number;
|
|
163
86
|
left?: number;
|
|
164
87
|
top?: number;
|
|
165
|
-
}
|
|
88
|
+
};
|
|
166
89
|
}
|
|
167
|
-
}
|
|
90
|
+
}
|
package/core-box/types.ts
DELETED
|
@@ -1,384 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core Box Type Definitions
|
|
3
|
-
* Universal types extracted from various parts of the project for reuse across the entire codebase
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { IPluginIcon, IFeatureCommand } from '@talex-touch/utils/plugin';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Render mode enumeration for search result items
|
|
10
|
-
* Defines different ways to render search result content
|
|
11
|
-
*/
|
|
12
|
-
export enum RenderMode {
|
|
13
|
-
/** Standard text-based rendering */
|
|
14
|
-
STANDARD = 'standard',
|
|
15
|
-
/** URL-based rendering - loads and displays remote URL content */
|
|
16
|
-
URL = 'url',
|
|
17
|
-
/** HTML content rendering */
|
|
18
|
-
HTML = 'html',
|
|
19
|
-
/** JavaScript code rendering with syntax highlighting */
|
|
20
|
-
JAVASCRIPT = 'javascript',
|
|
21
|
-
/** JSX component rendering */
|
|
22
|
-
JSX = 'jsx',
|
|
23
|
-
/** Vue Single File Component rendering */
|
|
24
|
-
VUE_SFC = 'vue-sfc'
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Render configuration for search result items
|
|
29
|
-
* Specifies how the search result should be displayed in the UI
|
|
30
|
-
*/
|
|
31
|
-
export interface IRenderConfig {
|
|
32
|
-
/** The rendering mode to use */
|
|
33
|
-
mode: RenderMode;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Content to render
|
|
37
|
-
* - For URL mode: The remote URL to load and display
|
|
38
|
-
* - For HTML mode: HTML content string
|
|
39
|
-
* - For code modes: Source code string
|
|
40
|
-
*/
|
|
41
|
-
content?: string;
|
|
42
|
-
|
|
43
|
-
/** Additional render options */
|
|
44
|
-
options?: {
|
|
45
|
-
/** Whether to enable syntax highlighting for code */
|
|
46
|
-
syntaxHighlight?: boolean;
|
|
47
|
-
/** Theme for code highlighting */
|
|
48
|
-
theme?: string;
|
|
49
|
-
/** Whether to show line numbers */
|
|
50
|
-
showLineNumbers?: boolean;
|
|
51
|
-
/** Custom CSS classes */
|
|
52
|
-
className?: string;
|
|
53
|
-
/** Inline styles */
|
|
54
|
-
style?: Record<string, string>;
|
|
55
|
-
/** Whether content is trusted (for HTML rendering) */
|
|
56
|
-
trusted?: boolean;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Preview configuration - provides metadata for URL previews
|
|
61
|
-
* Used to show rich preview information before loading the actual URL content
|
|
62
|
-
*/
|
|
63
|
-
preview?: {
|
|
64
|
-
/** Whether to show URL preview */
|
|
65
|
-
enabled?: boolean;
|
|
66
|
-
/** Preview image URL */
|
|
67
|
-
image?: string;
|
|
68
|
-
/** Preview title */
|
|
69
|
-
title?: string;
|
|
70
|
-
/** Preview description */
|
|
71
|
-
description?: string;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Search result item interface - unified data structure
|
|
77
|
-
* Compatible with SearchItem in app/core/src/views/box/search-box.ts
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* ```typescript
|
|
81
|
-
* const searchItem: ISearchItem = {
|
|
82
|
-
* name: "Example Result",
|
|
83
|
-
* desc: "This is an example search result",
|
|
84
|
-
* icon: { type: 'remix', value: 'search', init: async () => {} },
|
|
85
|
-
* push: false,
|
|
86
|
-
* names: ["Example Result"],
|
|
87
|
-
* keyWords: ["example", "result"],
|
|
88
|
-
* pluginType: "feature",
|
|
89
|
-
* type: "plugin",
|
|
90
|
-
* value: "example-plugin",
|
|
91
|
-
* render: {
|
|
92
|
-
* mode: RenderMode.STANDARD
|
|
93
|
-
* }
|
|
94
|
-
* };
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
export interface ISearchItem {
|
|
98
|
-
/** Display name of the search result */
|
|
99
|
-
name: string;
|
|
100
|
-
|
|
101
|
-
/** Description or subtitle of the search result */
|
|
102
|
-
desc: string;
|
|
103
|
-
|
|
104
|
-
/** Icon configuration for visual representation */
|
|
105
|
-
icon: IPluginIcon;
|
|
106
|
-
|
|
107
|
-
/** Whether this item supports push mode functionality */
|
|
108
|
-
push: boolean;
|
|
109
|
-
|
|
110
|
-
/** List of feature commands associated with this item */
|
|
111
|
-
commands?: IFeatureCommand[];
|
|
112
|
-
|
|
113
|
-
/** Array of searchable names for this item */
|
|
114
|
-
names: string[];
|
|
115
|
-
|
|
116
|
-
/** Array of keywords for search matching */
|
|
117
|
-
keyWords: string[];
|
|
118
|
-
|
|
119
|
-
/** Type of plugin this item belongs to */
|
|
120
|
-
pluginType: string;
|
|
121
|
-
|
|
122
|
-
/** General type classification of the item */
|
|
123
|
-
type: string;
|
|
124
|
-
|
|
125
|
-
/** Associated value, typically the plugin name */
|
|
126
|
-
value: string;
|
|
127
|
-
|
|
128
|
-
/** Usage frequency counter for ranking */
|
|
129
|
-
amo?: number;
|
|
130
|
-
|
|
131
|
-
/** Matching information from search algorithms */
|
|
132
|
-
matched?: any;
|
|
133
|
-
|
|
134
|
-
/** Whether this item was matched by name */
|
|
135
|
-
matchedByName?: boolean;
|
|
136
|
-
|
|
137
|
-
/** Whether this item was matched by description */
|
|
138
|
-
descMatched?: boolean;
|
|
139
|
-
|
|
140
|
-
/** Whether this item was matched by abbreviation */
|
|
141
|
-
abridgeMatched?: boolean;
|
|
142
|
-
|
|
143
|
-
/** Unique identifier for this search item */
|
|
144
|
-
id?: string;
|
|
145
|
-
|
|
146
|
-
/** Action to execute when this item is selected */
|
|
147
|
-
action?: string;
|
|
148
|
-
|
|
149
|
-
/** Reference to original feature object for command matching */
|
|
150
|
-
originFeature?: ISearchItem;
|
|
151
|
-
|
|
152
|
-
/** Render configuration for custom display */
|
|
153
|
-
render?: IRenderConfig;
|
|
154
|
-
|
|
155
|
-
/** Additional properties for extensibility */
|
|
156
|
-
[key: string]: any;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Search mode enumeration
|
|
161
|
-
* Defines different modes of operation for the search box
|
|
162
|
-
*/
|
|
163
|
-
export enum BoxMode {
|
|
164
|
-
/** Standard input mode for text search */
|
|
165
|
-
INPUT = 0,
|
|
166
|
-
/** Command mode for executing specific commands */
|
|
167
|
-
COMMAND = 1,
|
|
168
|
-
/** Image mode for image-based search */
|
|
169
|
-
IMAGE = 2,
|
|
170
|
-
/** File mode for file-based operations */
|
|
171
|
-
FILE = 3,
|
|
172
|
-
/** Feature mode for plugin feature activation */
|
|
173
|
-
FEATURE = 4
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Search options configuration
|
|
178
|
-
* Configures how search operations should be performed
|
|
179
|
-
*/
|
|
180
|
-
export interface ISearchOptions {
|
|
181
|
-
/** The search mode to use */
|
|
182
|
-
mode: BoxMode;
|
|
183
|
-
|
|
184
|
-
/** Maximum number of results to return */
|
|
185
|
-
maxResults?: number;
|
|
186
|
-
|
|
187
|
-
/** Whether to enable fuzzy matching algorithms */
|
|
188
|
-
fuzzyMatch?: boolean;
|
|
189
|
-
|
|
190
|
-
/** Search timeout in milliseconds */
|
|
191
|
-
timeout?: number;
|
|
192
|
-
|
|
193
|
-
/** Whether to include cached results */
|
|
194
|
-
includeCached?: boolean;
|
|
195
|
-
|
|
196
|
-
/** Minimum confidence score for results */
|
|
197
|
-
minConfidence?: number;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Plugin search result push interface
|
|
202
|
-
* Used when plugins push search results to the core box
|
|
203
|
-
*/
|
|
204
|
-
export interface IPluginSearchResult {
|
|
205
|
-
/** Name of the plugin pushing the results */
|
|
206
|
-
pluginName: string;
|
|
207
|
-
|
|
208
|
-
/** Array of search result items */
|
|
209
|
-
items: ISearchItem[];
|
|
210
|
-
|
|
211
|
-
/** Timestamp when results were generated */
|
|
212
|
-
timestamp: number;
|
|
213
|
-
|
|
214
|
-
/** Original query that generated these results */
|
|
215
|
-
query: string;
|
|
216
|
-
|
|
217
|
-
/** Total number of results available */
|
|
218
|
-
total: number;
|
|
219
|
-
|
|
220
|
-
/** Whether more results are available */
|
|
221
|
-
hasMore?: boolean;
|
|
222
|
-
|
|
223
|
-
/** Metadata about the search operation */
|
|
224
|
-
metadata?: {
|
|
225
|
-
/** Time taken to generate results in milliseconds */
|
|
226
|
-
processingTime?: number;
|
|
227
|
-
/** Source of the results */
|
|
228
|
-
source?: string;
|
|
229
|
-
/** Confidence score of the overall result set */
|
|
230
|
-
confidence?: number;
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Search result manager interface
|
|
236
|
-
* Manages search results within the core box
|
|
237
|
-
*/
|
|
238
|
-
export interface ISearchResultManager {
|
|
239
|
-
/** Push new search results to the manager */
|
|
240
|
-
pushItems(items: ISearchItem[]): void;
|
|
241
|
-
|
|
242
|
-
/** Clear all current search results */
|
|
243
|
-
clearItems(): void;
|
|
244
|
-
|
|
245
|
-
/** Get all current search results */
|
|
246
|
-
getItems(): ISearchItem[];
|
|
247
|
-
|
|
248
|
-
/** Update a specific search result item */
|
|
249
|
-
updateItem(id: string, item: Partial<ISearchItem>): boolean;
|
|
250
|
-
|
|
251
|
-
/** Remove a specific search result item */
|
|
252
|
-
removeItem(id: string): boolean;
|
|
253
|
-
|
|
254
|
-
/** Get the total count of search results */
|
|
255
|
-
getCount(): number;
|
|
256
|
-
|
|
257
|
-
/** Filter results based on criteria */
|
|
258
|
-
filterItems(predicate: (item: ISearchItem) => boolean): ISearchItem[];
|
|
259
|
-
|
|
260
|
-
/** Sort results using a comparison function */
|
|
261
|
-
sortItems(compareFn: (a: ISearchItem, b: ISearchItem) => number): void;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Generic data item interface
|
|
266
|
-
* Extended search item for various types of data processing results
|
|
267
|
-
*
|
|
268
|
-
* @example
|
|
269
|
-
* ```typescript
|
|
270
|
-
* const dataItem: IDataItem = {
|
|
271
|
-
* name: "Translation Result",
|
|
272
|
-
* desc: "English to Chinese translation",
|
|
273
|
-
* // ... other ISearchItem properties
|
|
274
|
-
* source: "google-translate",
|
|
275
|
-
* dataType: "translation",
|
|
276
|
-
* originalData: "Hello World",
|
|
277
|
-
* processedData: "你好世界",
|
|
278
|
-
* confidence: 95
|
|
279
|
-
* };
|
|
280
|
-
* ```
|
|
281
|
-
*/
|
|
282
|
-
export interface IDataItem extends ISearchItem {
|
|
283
|
-
/** Source service or system that generated this data */
|
|
284
|
-
source?: string;
|
|
285
|
-
|
|
286
|
-
/** Type of data processing performed */
|
|
287
|
-
dataType?: string;
|
|
288
|
-
|
|
289
|
-
/** Original input data before processing */
|
|
290
|
-
originalData?: any;
|
|
291
|
-
|
|
292
|
-
/** Processed output data */
|
|
293
|
-
processedData?: any;
|
|
294
|
-
|
|
295
|
-
/** Quality score of the processing result (0-100) */
|
|
296
|
-
quality?: number;
|
|
297
|
-
|
|
298
|
-
/** Whether this result was retrieved from cache */
|
|
299
|
-
cached?: boolean;
|
|
300
|
-
|
|
301
|
-
/** Processing time in milliseconds */
|
|
302
|
-
duration?: number;
|
|
303
|
-
|
|
304
|
-
/** Confidence level of the result (0-100) */
|
|
305
|
-
confidence?: number;
|
|
306
|
-
|
|
307
|
-
/** Additional metadata about the processing */
|
|
308
|
-
metadata?: Record<string, any>;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Application item interface
|
|
313
|
-
* Represents an application in search results
|
|
314
|
-
*/
|
|
315
|
-
export interface IAppItem extends ISearchItem {
|
|
316
|
-
/** File system path to the application */
|
|
317
|
-
path?: string;
|
|
318
|
-
|
|
319
|
-
/** Version string of the application */
|
|
320
|
-
version?: string;
|
|
321
|
-
|
|
322
|
-
/** File size in bytes */
|
|
323
|
-
size?: number;
|
|
324
|
-
|
|
325
|
-
/** Timestamp of last usage */
|
|
326
|
-
lastUsed?: number;
|
|
327
|
-
|
|
328
|
-
/** Application category */
|
|
329
|
-
category?: string;
|
|
330
|
-
|
|
331
|
-
/** Whether the application is currently running */
|
|
332
|
-
isRunning?: boolean;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* File item interface
|
|
337
|
-
* Represents a file in search results
|
|
338
|
-
*/
|
|
339
|
-
export interface IFileItem extends ISearchItem {
|
|
340
|
-
/** Full file system path */
|
|
341
|
-
filePath: string;
|
|
342
|
-
|
|
343
|
-
/** File size in bytes */
|
|
344
|
-
fileSize?: number;
|
|
345
|
-
|
|
346
|
-
/** MIME type of the file */
|
|
347
|
-
fileType?: string;
|
|
348
|
-
|
|
349
|
-
/** File extension */
|
|
350
|
-
extension?: string;
|
|
351
|
-
|
|
352
|
-
/** Last modified timestamp */
|
|
353
|
-
modifiedTime?: number;
|
|
354
|
-
|
|
355
|
-
/** Creation timestamp */
|
|
356
|
-
createdTime?: number;
|
|
357
|
-
|
|
358
|
-
/** Whether the file is currently accessible */
|
|
359
|
-
accessible?: boolean;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* Feature item interface
|
|
364
|
-
* Represents a plugin feature in search results
|
|
365
|
-
*/
|
|
366
|
-
export interface IFeatureItem extends ISearchItem {
|
|
367
|
-
/** Unique identifier for the feature */
|
|
368
|
-
featureId: string;
|
|
369
|
-
|
|
370
|
-
/** Name of the plugin that owns this feature */
|
|
371
|
-
pluginName: string;
|
|
372
|
-
|
|
373
|
-
/** Detailed description of the feature */
|
|
374
|
-
featureDesc?: string;
|
|
375
|
-
|
|
376
|
-
/** Parameters required by the feature */
|
|
377
|
-
parameters?: Record<string, any>;
|
|
378
|
-
|
|
379
|
-
/** Whether the feature is currently enabled */
|
|
380
|
-
enabled?: boolean;
|
|
381
|
-
|
|
382
|
-
/** Feature category or group */
|
|
383
|
-
category?: string;
|
|
384
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import { LogItem } from './types'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* LoggerManager is responsible for managing and writing logs for all plugins.
|
|
7
|
-
*/
|
|
8
|
-
export class LoggerManager {
|
|
9
|
-
private readonly logDir: string
|
|
10
|
-
private readonly sessionLogPath: string
|
|
11
|
-
private buffer: LogItem[] = []
|
|
12
|
-
private flushInterval: NodeJS.Timeout
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Initializes a new LoggerManager instance.
|
|
16
|
-
* @param baseDir - Base directory to store logs.
|
|
17
|
-
*/
|
|
18
|
-
constructor(baseDir: string) {
|
|
19
|
-
this.logDir = path.resolve(baseDir, 'logs')
|
|
20
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-')
|
|
21
|
-
this.sessionLogPath = path.resolve(this.logDir, `${timestamp}.log`)
|
|
22
|
-
this.ensureDirectory()
|
|
23
|
-
this.flushInterval = setInterval(() => this.flush(), 5000)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Appends a new log item to the buffer.
|
|
28
|
-
* @param log - The log entry to append.
|
|
29
|
-
*/
|
|
30
|
-
append(log: LogItem): void {
|
|
31
|
-
this.buffer.push(log)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Flushes all buffered log items to the current session log file.
|
|
36
|
-
*/
|
|
37
|
-
flush(): void {
|
|
38
|
-
if (this.buffer.length === 0) return
|
|
39
|
-
const lines = this.buffer.map((item) => JSON.stringify(item)).join('\n') + '\n'
|
|
40
|
-
fs.appendFileSync(this.sessionLogPath, lines)
|
|
41
|
-
this.buffer = []
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Stops the flush interval and ensures remaining logs are written.
|
|
46
|
-
*/
|
|
47
|
-
destroy(): void {
|
|
48
|
-
clearInterval(this.flushInterval)
|
|
49
|
-
this.flush()
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Ensures the log directory exists.
|
|
54
|
-
*/
|
|
55
|
-
private ensureDirectory(): void {
|
|
56
|
-
if (!fs.existsSync(this.logDir)) {
|
|
57
|
-
fs.mkdirSync(this.logDir, { recursive: true })
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|