@talex-touch/utils 1.0.30 → 1.0.32
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/animation/window-node.ts +205 -0
- package/animation/window.ts +19 -15
- package/auth/clerk-types.ts +1 -1
- package/auth/index.ts +1 -1
- package/auth/useAuthState.ts +6 -5
- package/auth/useClerkConfig.ts +6 -6
- package/auth/useClerkProvider.ts +3 -2
- package/channel/index.ts +28 -21
- package/common/file-scan-constants.ts +137 -121
- package/common/file-scan-utils.ts +49 -25
- package/common/index.ts +3 -3
- package/common/search/gather.ts +1 -1
- package/common/search/index.ts +5 -6
- package/common/storage/constants.ts +3 -2
- package/common/storage/entity/app-settings.ts +19 -3
- package/common/storage/entity/shortcut-settings.ts +10 -10
- package/common/storage/shortcut-storage.ts +6 -4
- package/common/utils/file.ts +15 -4
- package/common/utils/index.ts +62 -52
- package/common/utils/polling.ts +114 -63
- package/common/utils/task-queue.ts +11 -10
- package/common/utils/time.ts +50 -47
- package/common/utils/timing.ts +41 -37
- package/core-box/builder/index.ts +1 -1
- package/core-box/builder/tuff-builder.ts +255 -230
- package/core-box/index.ts +3 -6
- package/core-box/preview/index.ts +1 -0
- package/core-box/preview/types.ts +43 -0
- package/core-box/tuff/index.ts +1 -1
- package/core-box/tuff/tuff-dsl.ts +419 -253
- package/electron/clipboard-helper.ts +20 -12
- package/electron/download-manager.ts +43 -42
- package/electron/env-tool.ts +19 -18
- package/electron/file-parsers/index.ts +2 -2
- package/electron/file-parsers/parsers/text-parser.ts +15 -14
- package/electron/file-parsers/registry.ts +9 -7
- package/electron/file-parsers/types.ts +4 -4
- package/electron/index.ts +1 -1
- package/eventbus/index.ts +11 -11
- package/index.ts +6 -5
- package/intelligence/client.ts +87 -0
- package/intelligence/index.ts +1 -0
- package/package.json +14 -14
- package/permission/index.ts +8 -8
- package/plugin/channel.ts +77 -68
- package/plugin/index.ts +113 -84
- package/plugin/install.ts +8 -8
- package/plugin/log/types.ts +5 -5
- package/plugin/node/index.ts +1 -1
- package/plugin/node/logger-manager.ts +14 -11
- package/plugin/node/logger.ts +8 -8
- package/plugin/plugin-source.ts +11 -11
- package/plugin/preload.ts +6 -3
- package/plugin/providers/registry.ts +8 -7
- package/plugin/providers/types.ts +6 -6
- package/plugin/sdk/channel.ts +20 -20
- package/plugin/sdk/clipboard.ts +8 -6
- package/plugin/sdk/common.ts +10 -6
- package/plugin/sdk/core-box.ts +2 -3
- package/plugin/sdk/division-box.ts +266 -0
- package/plugin/sdk/enum/bridge-event.ts +1 -1
- package/plugin/sdk/examples/storage-onDidChange-example.js +1 -1
- package/plugin/sdk/features.ts +34 -26
- package/plugin/sdk/hooks/bridge.ts +3 -6
- package/plugin/sdk/hooks/index.ts +1 -1
- package/plugin/sdk/hooks/life-cycle.ts +4 -10
- package/plugin/sdk/index.ts +9 -13
- package/plugin/sdk/service/index.ts +3 -3
- package/plugin/sdk/storage.ts +4 -4
- package/plugin/sdk/system.ts +1 -1
- package/plugin/sdk/types.ts +169 -143
- package/plugin/sdk/window/index.ts +8 -5
- package/preload/loading.ts +6 -6
- package/preload/renderer.ts +4 -2
- package/renderer/hooks/arg-mapper.ts +1 -2
- package/renderer/hooks/index.ts +2 -0
- package/renderer/hooks/initialize.ts +10 -8
- package/renderer/hooks/performance.ts +4 -4
- package/renderer/hooks/use-channel.ts +150 -0
- package/renderer/hooks/use-intelligence.ts +236 -0
- package/renderer/index.ts +6 -1
- package/renderer/ref.ts +32 -36
- package/renderer/slots.ts +29 -26
- package/renderer/storage/app-settings.ts +16 -6
- package/renderer/storage/base-storage.ts +236 -88
- package/renderer/storage/index.ts +3 -0
- package/renderer/storage/intelligence-storage.ts +215 -0
- package/renderer/storage/openers.ts +13 -3
- package/renderer/touch-sdk/env.ts +41 -41
- package/renderer/touch-sdk/index.ts +1 -1
- package/renderer/touch-sdk/terminal.ts +5 -5
- package/renderer/touch-sdk/utils.ts +4 -3
- package/search/levenshtein-utils.ts +11 -11
- package/search/types.ts +102 -103
- package/service/index.ts +11 -11
- package/service/protocol/index.ts +217 -14
- package/types/division-box.ts +248 -0
- package/types/download.ts +72 -34
- package/types/icon.ts +2 -1
- package/types/index.ts +3 -1
- package/types/intelligence.ts +413 -0
- package/types/modules/base.ts +16 -16
- package/types/modules/index.ts +1 -1
- package/types/modules/module-lifecycle.ts +21 -21
- package/types/modules/module-manager.ts +11 -11
- package/types/modules/module.ts +16 -16
- package/types/storage.ts +0 -1
- package/types/touch-app-core.ts +32 -32
- package/types/update.ts +79 -21
- package/core-box/README.md +0 -218
- package/core-box/builder/tuff-builder.example.ts.bak +0 -258
- package/core-box/run-tests.sh +0 -7
- package/core-box/search.ts +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MaybePromise, ModuleDirectory, ModuleFileConfig, ModuleKey, ResolvedModuleFileConfig } from
|
|
2
|
-
import { IBaseModule, ModuleCtor, ModuleRegistrant } from
|
|
3
|
-
import { ModuleStopContext } from
|
|
1
|
+
import type { MaybePromise, ModuleDirectory, ModuleFileConfig, ModuleKey, ResolvedModuleFileConfig } from './base'
|
|
2
|
+
import type { IBaseModule, ModuleCtor, ModuleRegistrant } from './module'
|
|
3
|
+
import type { ModuleStopContext } from './module-lifecycle'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Interface of the Module Manager.
|
|
@@ -32,7 +32,7 @@ export interface IBaseModuleManager<E = any> {
|
|
|
32
32
|
* - If an instance is provided, step (2) is skipped; the same lifecycle calls apply.
|
|
33
33
|
* - The manager must preserve **singleton semantics** per {@link ModuleKey}.
|
|
34
34
|
*/
|
|
35
|
-
loadModule<T extends IBaseModule<E>>(module: ModuleRegistrant<T, E>)
|
|
35
|
+
loadModule: <T extends IBaseModule<E>>(module: ModuleRegistrant<T, E>) => boolean | Promise<boolean>
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Unloads a module by key.
|
|
@@ -45,7 +45,7 @@ export interface IBaseModuleManager<E = any> {
|
|
|
45
45
|
* The manager should invoke `stop?()` (with a `ModuleStopContext`) followed by `destroy()`
|
|
46
46
|
* (with a `ModuleDestroyContext`), then remove the singleton instance.
|
|
47
47
|
*/
|
|
48
|
-
unloadModule(moduleKey: ModuleKey, reason?: ModuleStopContext<E>[
|
|
48
|
+
unloadModule: (moduleKey: ModuleKey, reason?: ModuleStopContext<E>['reason']) => boolean | Promise<boolean>
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Retrieves a module instance by key.
|
|
@@ -54,7 +54,7 @@ export interface IBaseModuleManager<E = any> {
|
|
|
54
54
|
* @param moduleKey - The unique key of the module.
|
|
55
55
|
* @returns The module instance if loaded; otherwise `undefined`.
|
|
56
56
|
*/
|
|
57
|
-
getModule<T extends IBaseModule<E> = IBaseModule<E>>(moduleKey: ModuleKey)
|
|
57
|
+
getModule: <T extends IBaseModule<E> = IBaseModule<E>>(moduleKey: ModuleKey) => T | undefined
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Optional class-based getter for stronger typing.
|
|
@@ -63,17 +63,17 @@ export interface IBaseModuleManager<E = any> {
|
|
|
63
63
|
* @param ctor - The module class used at registration time (or a class with the same static `key`).
|
|
64
64
|
* @returns The module instance if loaded; otherwise `undefined`.
|
|
65
65
|
*/
|
|
66
|
-
get<T extends IBaseModule<E>>(ctor: ModuleCtor<T, E>)
|
|
66
|
+
get: <T extends IBaseModule<E>>(ctor: ModuleCtor<T, E>) => T | undefined
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Returns whether a module is currently loaded.
|
|
70
70
|
*/
|
|
71
|
-
hasModule(moduleKey: ModuleKey)
|
|
71
|
+
hasModule: (moduleKey: ModuleKey) => boolean
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Lists keys of all currently loaded modules.
|
|
75
75
|
*/
|
|
76
|
-
listModules()
|
|
76
|
+
listModules: () => readonly ModuleKey[]
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/**
|
|
@@ -89,11 +89,11 @@ export interface IModuleDirectoryService {
|
|
|
89
89
|
/**
|
|
90
90
|
* Resolves a {@link ModuleFileConfig} to {@link ResolvedModuleFileConfig} without creating anything.
|
|
91
91
|
*/
|
|
92
|
-
resolve(moduleKey: ModuleKey, input?: ModuleFileConfig)
|
|
92
|
+
resolve: (moduleKey: ModuleKey, input?: ModuleFileConfig) => ResolvedModuleFileConfig
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* Creates (or returns) the single {@link ModuleDirectory} for a module if configured to `create: true`.
|
|
96
96
|
* If `create !== true`, implementations should return `undefined`.
|
|
97
97
|
*/
|
|
98
|
-
ensure(moduleKey: ModuleKey, input?: ModuleFileConfig)
|
|
98
|
+
ensure: (moduleKey: ModuleKey, input?: ModuleFileConfig) => MaybePromise<ModuleDirectory | undefined>
|
|
99
99
|
}
|
package/types/modules/module.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MaybePromise, ModuleFileConfig, ModuleKey } from
|
|
2
|
-
import { ModuleCreateContext, ModuleDestroyContext, ModuleInitContext, ModuleStartContext, ModuleStopContext } from
|
|
1
|
+
import type { MaybePromise, ModuleFileConfig, ModuleKey } from './base'
|
|
2
|
+
import type { ModuleCreateContext, ModuleDestroyContext, ModuleInitContext, ModuleStartContext, ModuleStopContext } from './module-lifecycle'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Contract that every module must implement.
|
|
@@ -19,7 +19,7 @@ export interface IBaseModule<E = any> {
|
|
|
19
19
|
/**
|
|
20
20
|
* Unique module key. Prefer `Symbol.for("your-module")` for global uniqueness.
|
|
21
21
|
*/
|
|
22
|
-
name: ModuleKey
|
|
22
|
+
name: ModuleKey
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Optional custom module entry file path.
|
|
@@ -28,7 +28,7 @@ export interface IBaseModule<E = any> {
|
|
|
28
28
|
* If omitted, the manager can resolve a default location (e.g., inside the module's directory
|
|
29
29
|
* when one exists, or from an app-level modules root).
|
|
30
30
|
*/
|
|
31
|
-
filePath?: string
|
|
31
|
+
filePath?: string
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Declarative directory configuration for this module.
|
|
@@ -38,33 +38,33 @@ export interface IBaseModule<E = any> {
|
|
|
38
38
|
* expose a `ModuleDirectory` on all lifecycle contexts.
|
|
39
39
|
* - If `file.create !== true`, no directory will be created and `context.directory` will be `undefined`.
|
|
40
40
|
*/
|
|
41
|
-
file?: ModuleFileConfig
|
|
41
|
+
file?: ModuleFileConfig
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Optional hook invoked after construction/registration and before `init`.
|
|
45
45
|
* Use this for last-moment wiring that depends on resolved paths or file config.
|
|
46
46
|
*/
|
|
47
|
-
created
|
|
47
|
+
created?: (ctx: ModuleCreateContext<E>) => MaybePromise<void>
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Called to perform resource preparation and subscription wiring.
|
|
51
51
|
*/
|
|
52
|
-
init(ctx: ModuleInitContext<E>)
|
|
52
|
+
init: (ctx: ModuleInitContext<E>) => MaybePromise<void>
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Called when the module should start its active work.
|
|
56
56
|
*/
|
|
57
|
-
start
|
|
57
|
+
start?: (ctx: ModuleStartContext<E>) => MaybePromise<void>
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Called when the module should leave the active state but may still keep allocated resources.
|
|
61
61
|
*/
|
|
62
|
-
stop
|
|
62
|
+
stop?: (ctx: ModuleStopContext<E>) => MaybePromise<void>
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Called to perform final teardown and resource release.
|
|
66
66
|
*/
|
|
67
|
-
destroy(ctx: ModuleDestroyContext<E>)
|
|
67
|
+
destroy: (ctx: ModuleDestroyContext<E>) => MaybePromise<void>
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -81,19 +81,19 @@ export interface IBaseModule<E = any> {
|
|
|
81
81
|
* @public
|
|
82
82
|
*/
|
|
83
83
|
export interface ModuleCtor<T extends IBaseModule<E>, E = any> {
|
|
84
|
-
new (ctx: ModuleCreateContext<E>): T
|
|
84
|
+
new (ctx: ModuleCreateContext<E>): T
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* Optional class-level unique key.
|
|
88
88
|
* If omitted, the instance {@link IModule.name | name} must be used as the key.
|
|
89
89
|
*/
|
|
90
|
-
readonly key?: ModuleKey
|
|
90
|
+
readonly key?: ModuleKey
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* Optional declarative dependencies expressed as other module keys.
|
|
94
94
|
* Useful if the manager performs topological ordering.
|
|
95
95
|
*/
|
|
96
|
-
readonly requires?: readonly ModuleKey[]
|
|
96
|
+
readonly requires?: readonly ModuleKey[]
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
@@ -107,6 +107,6 @@ export interface ModuleCtor<T extends IBaseModule<E>, E = any> {
|
|
|
107
107
|
*
|
|
108
108
|
* @public
|
|
109
109
|
*/
|
|
110
|
-
export type ModuleRegistrant<T extends IBaseModule<E>, E = any>
|
|
111
|
-
| T
|
|
112
|
-
|
|
110
|
+
export type ModuleRegistrant<T extends IBaseModule<E>, E = any>
|
|
111
|
+
= | T
|
|
112
|
+
| ModuleCtor<T, E>
|
package/types/storage.ts
CHANGED
package/types/touch-app-core.ts
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { BrowserWindowConstructorOptions, OpenDevToolsOptions } from
|
|
2
|
-
import {
|
|
1
|
+
import type { BrowserWindowConstructorOptions, OpenDevToolsOptions } from 'electron'
|
|
2
|
+
import type { IBaseModule, IBaseModuleManager } from './modules'
|
|
3
3
|
|
|
4
4
|
export namespace TalexTouch {
|
|
5
5
|
export interface TouchApp {
|
|
6
|
-
app: Electron.App
|
|
7
|
-
window: ITouchWindow
|
|
8
|
-
version: AppVersion
|
|
9
|
-
moduleManager: IBaseModuleManager
|
|
10
|
-
config: IConfiguration
|
|
11
|
-
rootPath: string
|
|
6
|
+
app: Electron.App
|
|
7
|
+
window: ITouchWindow
|
|
8
|
+
version: AppVersion
|
|
9
|
+
moduleManager: IBaseModuleManager
|
|
10
|
+
config: IConfiguration
|
|
11
|
+
rootPath: string
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export enum AppVersion {
|
|
15
15
|
// ALPHA = "alpha",
|
|
16
16
|
// BETA = "beta",
|
|
17
|
-
DEV =
|
|
18
|
-
RELEASE =
|
|
17
|
+
DEV = 'dev',
|
|
18
|
+
RELEASE = 'release',
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface ITouchWindow {
|
|
22
|
-
window: Electron.BrowserWindow
|
|
22
|
+
window: Electron.BrowserWindow
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Try to close the window. This has the same effect as a user manually clicking
|
|
26
26
|
* the close button of the window. The web page may cancel the close though. See
|
|
27
27
|
* the close event.
|
|
28
28
|
*/
|
|
29
|
-
close(): void
|
|
29
|
+
close(): void
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Minimizes the window. On some platforms the minimized window will be shown in
|
|
33
33
|
* the Dock.
|
|
34
34
|
*/
|
|
35
|
-
minimize(): void
|
|
35
|
+
minimize(): void
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Opens the devtools.
|
|
@@ -43,29 +43,29 @@ export namespace TalexTouch {
|
|
|
43
43
|
* On Windows, if Windows Control Overlay is enabled, Devtools will be opened with
|
|
44
44
|
* `mode: 'detach'`.
|
|
45
45
|
*/
|
|
46
|
-
openDevTools(options?: OpenDevToolsOptions): void
|
|
46
|
+
openDevTools(options?: OpenDevToolsOptions): void
|
|
47
47
|
|
|
48
48
|
loadURL(
|
|
49
49
|
url: string,
|
|
50
50
|
options?: LoadURLOptions | undefined,
|
|
51
|
-
): Promise<Electron.WebContents
|
|
51
|
+
): Promise<Electron.WebContents>
|
|
52
52
|
loadFile(
|
|
53
53
|
filePath: string,
|
|
54
54
|
options?: LoadFileOptions | undefined,
|
|
55
|
-
): Promise<Electron.WebContents
|
|
55
|
+
): Promise<Electron.WebContents>
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
export type TouchWindowConstructorOptions
|
|
59
|
-
BrowserWindowConstructorOptions & {
|
|
60
|
-
autoShow?: boolean
|
|
61
|
-
}
|
|
58
|
+
export type TouchWindowConstructorOptions
|
|
59
|
+
= BrowserWindowConstructorOptions & {
|
|
60
|
+
autoShow?: boolean
|
|
61
|
+
}
|
|
62
62
|
|
|
63
63
|
export type LoadFileOptions = Electron.LoadFileOptions & {
|
|
64
|
-
devtools?: boolean |
|
|
65
|
-
}
|
|
64
|
+
devtools?: boolean | 'detach' | 'left' | 'right' | 'bottom' | 'undocked'
|
|
65
|
+
}
|
|
66
66
|
export type LoadURLOptions = Electron.LoadURLOptions & {
|
|
67
|
-
devtools?: boolean |
|
|
68
|
-
}
|
|
67
|
+
devtools?: boolean | 'detach' | 'left' | 'right' | 'bottom' | 'undocked'
|
|
68
|
+
}
|
|
69
69
|
|
|
70
70
|
export interface IModuleManager<E> extends IBaseModuleManager<E> {
|
|
71
71
|
|
|
@@ -74,17 +74,17 @@ export namespace TalexTouch {
|
|
|
74
74
|
export interface IModule<E> extends IBaseModule<E> {}
|
|
75
75
|
|
|
76
76
|
export interface IConfiguration {
|
|
77
|
-
configPath: string
|
|
78
|
-
data: TouchAppConfig
|
|
79
|
-
triggerSave: Function
|
|
77
|
+
configPath: string
|
|
78
|
+
data: TouchAppConfig
|
|
79
|
+
triggerSave: Function
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
export interface TouchAppConfig {
|
|
83
83
|
frame: {
|
|
84
|
-
width: number
|
|
85
|
-
height: number
|
|
86
|
-
left?: number
|
|
87
|
-
top?: number
|
|
88
|
-
}
|
|
84
|
+
width: number
|
|
85
|
+
height: number
|
|
86
|
+
left?: number
|
|
87
|
+
top?: number
|
|
88
|
+
}
|
|
89
89
|
}
|
|
90
90
|
}
|
package/types/update.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Known update provider types.
|
|
3
|
+
*/
|
|
2
4
|
export enum UpdateProviderType {
|
|
3
5
|
GITHUB = 'github',
|
|
4
6
|
OFFICIAL = 'official',
|
|
5
|
-
CUSTOM = 'custom'
|
|
7
|
+
CUSTOM = 'custom',
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Describes the remote endpoint that serves release metadata.
|
|
12
|
+
*/
|
|
9
13
|
export interface UpdateSourceConfig {
|
|
10
14
|
type: UpdateProviderType
|
|
11
15
|
name: string
|
|
@@ -14,7 +18,9 @@ export interface UpdateSourceConfig {
|
|
|
14
18
|
priority: number
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Represents a downloadable build artifact.
|
|
23
|
+
*/
|
|
18
24
|
export interface DownloadAsset {
|
|
19
25
|
name: string
|
|
20
26
|
url: string
|
|
@@ -24,7 +30,9 @@ export interface DownloadAsset {
|
|
|
24
30
|
checksum?: string
|
|
25
31
|
}
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Minimal subset of the GitHub release payload that the updater consumes.
|
|
35
|
+
*/
|
|
28
36
|
export interface GitHubRelease {
|
|
29
37
|
tag_name: string
|
|
30
38
|
name: string
|
|
@@ -33,7 +41,9 @@ export interface GitHubRelease {
|
|
|
33
41
|
assets: DownloadAsset[]
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Standardized shape of an update check response.
|
|
46
|
+
*/
|
|
37
47
|
export interface UpdateCheckResult {
|
|
38
48
|
hasUpdate: boolean
|
|
39
49
|
release?: GitHubRelease
|
|
@@ -41,7 +51,9 @@ export interface UpdateCheckResult {
|
|
|
41
51
|
source: string
|
|
42
52
|
}
|
|
43
53
|
|
|
44
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Custom provider definition used to extend the updater beyond the built-ins.
|
|
56
|
+
*/
|
|
45
57
|
export interface CustomUpdateConfig {
|
|
46
58
|
name: string
|
|
47
59
|
url: string
|
|
@@ -49,49 +61,95 @@ export interface CustomUpdateConfig {
|
|
|
49
61
|
headers?: Record<string, string>
|
|
50
62
|
}
|
|
51
63
|
|
|
52
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Build channels supported by the desktop client.
|
|
66
|
+
*/
|
|
53
67
|
export enum AppPreviewChannel {
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
RELEASE = 'RELEASE',
|
|
69
|
+
BETA = 'BETA',
|
|
70
|
+
SNAPSHOT = 'SNAPSHOT',
|
|
56
71
|
}
|
|
57
72
|
|
|
58
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Scheduler presets used by the polling worker.
|
|
75
|
+
*/
|
|
76
|
+
export type UpdateFrequency = 'everyday' | '1day' | '3day' | '7day' | '1month' | 'never'
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* User and system configurable update preferences.
|
|
80
|
+
*/
|
|
59
81
|
export interface UpdateSettings {
|
|
60
82
|
enabled: boolean
|
|
61
|
-
frequency:
|
|
83
|
+
frequency: UpdateFrequency
|
|
62
84
|
source: UpdateSourceConfig
|
|
63
|
-
|
|
85
|
+
updateChannel: AppPreviewChannel
|
|
64
86
|
ignoredVersions: string[]
|
|
65
87
|
customSources: CustomUpdateConfig[]
|
|
88
|
+
/**
|
|
89
|
+
* Timestamp (ms) of the last successful update check.
|
|
90
|
+
*/
|
|
91
|
+
lastCheckedAt?: number | null
|
|
92
|
+
/**
|
|
93
|
+
* Enable/disable local caching of remote responses.
|
|
94
|
+
*/
|
|
95
|
+
cacheEnabled?: boolean
|
|
96
|
+
/**
|
|
97
|
+
* Cache TTL in minutes.
|
|
98
|
+
*/
|
|
99
|
+
cacheTTL?: number
|
|
100
|
+
/**
|
|
101
|
+
* Enable retry logic for transient failures.
|
|
102
|
+
*/
|
|
103
|
+
rateLimitEnabled?: boolean
|
|
104
|
+
/**
|
|
105
|
+
* Maximum retry attempts when the provider throttles requests.
|
|
106
|
+
*/
|
|
107
|
+
maxRetries?: number
|
|
108
|
+
/**
|
|
109
|
+
* Base retry delay in milliseconds.
|
|
110
|
+
*/
|
|
111
|
+
retryDelay?: number
|
|
66
112
|
}
|
|
67
113
|
|
|
68
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Safe defaults used when no user configuration exists yet.
|
|
116
|
+
*/
|
|
69
117
|
export const defaultUpdateSettings: UpdateSettings = {
|
|
70
118
|
enabled: true,
|
|
71
|
-
frequency: '
|
|
119
|
+
frequency: 'everyday',
|
|
72
120
|
source: {
|
|
73
121
|
type: UpdateProviderType.GITHUB,
|
|
74
122
|
name: 'GitHub Releases',
|
|
75
123
|
url: 'https://api.github.com/repos/talex-touch/tuff/releases',
|
|
76
124
|
enabled: true,
|
|
77
|
-
priority: 1
|
|
125
|
+
priority: 1,
|
|
78
126
|
},
|
|
79
|
-
|
|
127
|
+
updateChannel: AppPreviewChannel.RELEASE,
|
|
80
128
|
ignoredVersions: [],
|
|
81
|
-
customSources: []
|
|
129
|
+
customSources: [],
|
|
130
|
+
lastCheckedAt: null,
|
|
131
|
+
cacheEnabled: true,
|
|
132
|
+
cacheTTL: 30,
|
|
133
|
+
rateLimitEnabled: true,
|
|
134
|
+
maxRetries: 3,
|
|
135
|
+
retryDelay: 2000,
|
|
82
136
|
}
|
|
83
137
|
|
|
84
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Categorized error types emitted by the updater pipeline.
|
|
140
|
+
*/
|
|
85
141
|
export enum UpdateErrorType {
|
|
86
142
|
NETWORK_ERROR = 'network_error',
|
|
87
143
|
TIMEOUT_ERROR = 'timeout_error',
|
|
88
144
|
API_ERROR = 'api_error',
|
|
89
145
|
PARSE_ERROR = 'parse_error',
|
|
90
146
|
VERSION_ERROR = 'version_error',
|
|
91
|
-
UNKNOWN_ERROR = 'unknown_error'
|
|
147
|
+
UNKNOWN_ERROR = 'unknown_error',
|
|
92
148
|
}
|
|
93
149
|
|
|
94
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Error type used across providers.
|
|
152
|
+
*/
|
|
95
153
|
export interface UpdateError extends Error {
|
|
96
154
|
type: UpdateErrorType
|
|
97
155
|
code?: string
|
package/core-box/README.md
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
# Core Box Package
|
|
2
|
-
|
|
3
|
-
The Core Box package provides unified type definitions and utility functions for the TUFF search box system. This package contains the foundational types and tools used across the entire project for search result management and plugin integration.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
### 🎯 Unified Type System
|
|
8
|
-
- **ISearchItem**: Universal search result item interface
|
|
9
|
-
- **IRenderConfig**: Flexible rendering configuration with multiple modes
|
|
10
|
-
- **IDataItem**: Extended interface for data processing results
|
|
11
|
-
- **IAppItem**: Specialized interface for application results
|
|
12
|
-
- **IFileItem**: Specialized interface for file results
|
|
13
|
-
- **IFeatureItem**: Specialized interface for plugin feature results
|
|
14
|
-
|
|
15
|
-
### 🎨 Render Modes
|
|
16
|
-
The package supports multiple rendering modes for search results:
|
|
17
|
-
|
|
18
|
-
- **STANDARD**: Default text-based rendering
|
|
19
|
-
- **URL**: URL rendering - loads and displays remote URL content
|
|
20
|
-
- **HTML**: Rich HTML content rendering
|
|
21
|
-
- **JAVASCRIPT**: JavaScript code with syntax highlighting
|
|
22
|
-
- **JSX**: React JSX component rendering
|
|
23
|
-
- **VUE_SFC**: Vue Single File Component rendering
|
|
24
|
-
|
|
25
|
-
### 🛠️ Utility Functions
|
|
26
|
-
Comprehensive set of utility functions for creating and managing search results:
|
|
27
|
-
|
|
28
|
-
- `SearchUtils.createSearchItem()`: Create basic search items
|
|
29
|
-
- `SearchUtils.createDataItem()`: Create data processing results
|
|
30
|
-
- `SearchUtils.createAppItem()`: Create application results
|
|
31
|
-
- `SearchUtils.createFileItem()`: Create file results
|
|
32
|
-
- `SearchUtils.createFeatureItem()`: Create plugin feature results
|
|
33
|
-
- `SearchUtils.createErrorItem()`: Create error state items
|
|
34
|
-
- `SearchUtils.sortByPriority()`: Sort results by relevance
|
|
35
|
-
- `SearchUtils.removeDuplicates()`: Remove duplicate results
|
|
36
|
-
- `SearchUtils.filterByConfidence()`: Filter by confidence score
|
|
37
|
-
- `SearchUtils.groupByPluginType()`: Group results by type
|
|
38
|
-
|
|
39
|
-
## Usage Examples
|
|
40
|
-
|
|
41
|
-
### Basic Search Item
|
|
42
|
-
```typescript
|
|
43
|
-
import { SearchUtils, RenderMode } from '@talex-touch/utils';
|
|
44
|
-
|
|
45
|
-
const basicItem = SearchUtils.createSearchItem({
|
|
46
|
-
name: "My Feature",
|
|
47
|
-
desc: "A useful plugin feature",
|
|
48
|
-
pluginName: "my-plugin",
|
|
49
|
-
keyWords: ["feature", "utility"],
|
|
50
|
-
render: {
|
|
51
|
-
mode: RenderMode.STANDARD
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Data Processing Result
|
|
57
|
-
```typescript
|
|
58
|
-
const dataItem = SearchUtils.createDataItem({
|
|
59
|
-
name: "Translation Result",
|
|
60
|
-
desc: "English to Chinese translation",
|
|
61
|
-
pluginName: "translator",
|
|
62
|
-
source: "google-translate",
|
|
63
|
-
dataType: "translation",
|
|
64
|
-
originalData: "Hello World",
|
|
65
|
-
processedData: "你好世界",
|
|
66
|
-
confidence: 95,
|
|
67
|
-
duration: 120,
|
|
68
|
-
render: {
|
|
69
|
-
mode: RenderMode.STANDARD
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### HTML Rendering
|
|
75
|
-
```typescript
|
|
76
|
-
const htmlItem = SearchUtils.createSearchItem({
|
|
77
|
-
name: "Rich Content",
|
|
78
|
-
desc: "HTML formatted result",
|
|
79
|
-
pluginName: "content-plugin",
|
|
80
|
-
render: {
|
|
81
|
-
mode: RenderMode.HTML,
|
|
82
|
-
content: "<div><h3>Title</h3><p>Content</p></div>",
|
|
83
|
-
options: {
|
|
84
|
-
trusted: true,
|
|
85
|
-
className: "custom-content"
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Code Rendering
|
|
92
|
-
```typescript
|
|
93
|
-
const codeItem = SearchUtils.createDataItem({
|
|
94
|
-
name: "JavaScript Function",
|
|
95
|
-
desc: "Generated code snippet",
|
|
96
|
-
pluginName: "code-generator",
|
|
97
|
-
dataType: "javascript",
|
|
98
|
-
processedData: "function hello() { return 'world'; }",
|
|
99
|
-
render: {
|
|
100
|
-
mode: RenderMode.JAVASCRIPT,
|
|
101
|
-
content: "function hello() { return 'world'; }",
|
|
102
|
-
options: {
|
|
103
|
-
syntaxHighlight: true,
|
|
104
|
-
showLineNumbers: true,
|
|
105
|
-
theme: "dark"
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### URL Rendering with Preview
|
|
112
|
-
```typescript
|
|
113
|
-
const urlItem = SearchUtils.createSearchItem({
|
|
114
|
-
name: "GitHub Repository",
|
|
115
|
-
desc: "TUFF project",
|
|
116
|
-
pluginName: "web-search",
|
|
117
|
-
render: {
|
|
118
|
-
mode: RenderMode.URL,
|
|
119
|
-
content: "https://github.com/talex-touch/talex-touch", // The actual URL to load
|
|
120
|
-
preview: {
|
|
121
|
-
enabled: true,
|
|
122
|
-
title: "Tuff", // Preview metadata
|
|
123
|
-
description: "Modern desktop application framework", // Preview description
|
|
124
|
-
image: "https://github.com/talex-touch.png" // Preview image
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
**Note**:
|
|
131
|
-
- `content`: The remote URL that will be loaded and displayed
|
|
132
|
-
- `preview`: Metadata shown before/alongside the loaded URL content
|
|
133
|
-
|
|
134
|
-
## Type Definitions
|
|
135
|
-
|
|
136
|
-
### ISearchItem
|
|
137
|
-
The core interface for all search results:
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
interface ISearchItem {
|
|
141
|
-
name: string; // Display name
|
|
142
|
-
desc: string; // Description
|
|
143
|
-
icon: ITuffIcon; // Icon configuration
|
|
144
|
-
push: boolean; // Push mode support
|
|
145
|
-
names: string[]; // Searchable names
|
|
146
|
-
keyWords: string[]; // Search keywords
|
|
147
|
-
pluginType: string; // Plugin type
|
|
148
|
-
type: string; // General type
|
|
149
|
-
value: string; // Associated value
|
|
150
|
-
render?: IRenderConfig; // Render configuration
|
|
151
|
-
// ... additional properties
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### IRenderConfig
|
|
156
|
-
Configuration for custom rendering:
|
|
157
|
-
|
|
158
|
-
```typescript
|
|
159
|
-
interface IRenderConfig {
|
|
160
|
-
mode: RenderMode; // Rendering mode
|
|
161
|
-
content?: string; // Content to render
|
|
162
|
-
options?: { // Render options
|
|
163
|
-
syntaxHighlight?: boolean;
|
|
164
|
-
theme?: string;
|
|
165
|
-
showLineNumbers?: boolean;
|
|
166
|
-
className?: string;
|
|
167
|
-
style?: Record<string, string>;
|
|
168
|
-
trusted?: boolean;
|
|
169
|
-
};
|
|
170
|
-
preview?: { // URL preview config
|
|
171
|
-
enabled?: boolean;
|
|
172
|
-
image?: string;
|
|
173
|
-
title?: string;
|
|
174
|
-
description?: string;
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## Integration
|
|
180
|
-
|
|
181
|
-
This package is automatically exported from `@talex-touch/utils`:
|
|
182
|
-
|
|
183
|
-
```typescript
|
|
184
|
-
import {
|
|
185
|
-
ISearchItem,
|
|
186
|
-
IDataItem,
|
|
187
|
-
SearchUtils,
|
|
188
|
-
RenderMode
|
|
189
|
-
} from '@talex-touch/utils';
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
## Best Practices
|
|
193
|
-
|
|
194
|
-
1. **Always specify render mode**: Even for standard rendering, explicitly set the render mode
|
|
195
|
-
2. **Use appropriate specialized interfaces**: Use IDataItem for data processing, IAppItem for applications, etc.
|
|
196
|
-
3. **Include confidence scores**: For data processing results, always include confidence levels
|
|
197
|
-
4. **Sanitize HTML content**: When using HTML render mode, ensure content is safe
|
|
198
|
-
5. **Provide meaningful keywords**: Include relevant search terms in the keyWords array
|
|
199
|
-
6. **Use consistent naming**: Follow established naming conventions for plugin types
|
|
200
|
-
|
|
201
|
-
## Migration Guide
|
|
202
|
-
|
|
203
|
-
If you're migrating from the old type system:
|
|
204
|
-
|
|
205
|
-
1. Replace `ITranslationItem` with `IDataItem`
|
|
206
|
-
2. Update render configurations to use the new `IRenderConfig` interface
|
|
207
|
-
3. Use `SearchUtils` functions instead of manual object creation
|
|
208
|
-
4. Update import paths to use `@talex-touch/utils`
|
|
209
|
-
|
|
210
|
-
## Contributing
|
|
211
|
-
|
|
212
|
-
When adding new types or utilities:
|
|
213
|
-
|
|
214
|
-
1. Add comprehensive TSDoc comments in English
|
|
215
|
-
2. Include usage examples in documentation
|
|
216
|
-
3. Follow the established naming conventions
|
|
217
|
-
4. Add appropriate unit tests
|
|
218
|
-
5. Update this README with new features
|