@talex-touch/utils 1.0.31 → 1.0.33
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 +15 -12
- 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 +4 -4
- package/auth/useClerkProvider.ts +3 -2
- package/channel/index.ts +23 -22
- package/common/file-scan-constants.ts +137 -121
- package/common/file-scan-utils.ts +48 -27
- 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 +5 -3
- package/common/storage/entity/shortcut-settings.ts +10 -10
- package/common/storage/shortcut-storage.ts +6 -4
- package/common/utils/file.ts +14 -6
- package/common/utils/index.ts +62 -52
- package/common/utils/polling.ts +88 -84
- 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 +254 -229
- package/core-box/index.ts +4 -6
- package/core-box/preview/index.ts +1 -0
- package/core-box/preview/types.ts +43 -0
- package/core-box/recommendation.ts +77 -0
- package/core-box/tuff/index.ts +1 -1
- package/core-box/tuff/tuff-dsl.ts +328 -266
- 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 +2 -2
- package/eventbus/index.ts +11 -11
- package/index.ts +5 -4
- 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 +96 -82
- 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 +1 -1
- package/plugin/providers/registry.ts +8 -7
- package/plugin/providers/types.ts +6 -6
- package/plugin/sdk/README.md +216 -0
- package/plugin/sdk/box-sdk.ts +219 -0
- 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/feature-sdk.ts +235 -0
- 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 +10 -7
- 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 +165 -146
- 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 -2
- 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 +222 -114
- package/renderer/storage/index.ts +3 -0
- package/renderer/storage/intelligence-storage.ts +218 -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 -102
- 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/index.ts +3 -1
- package/types/intelligence.ts +607 -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 +91 -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
- package/electron/clipboard-helper.ts +0 -199
package/types/modules/base.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Unique key for a module.
|
|
3
3
|
* @public
|
|
4
4
|
*/
|
|
5
|
-
export type ModuleKey = symbol
|
|
5
|
+
export type ModuleKey = symbol
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Utility type representing a synchronous or asynchronous value.
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
|
-
export type MaybePromise<T> = T | Promise<T
|
|
11
|
+
export type MaybePromise<T> = T | Promise<T>
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Declarative file/directory configuration for a module (input).
|
|
@@ -31,21 +31,21 @@ export interface ModuleFileConfig {
|
|
|
31
31
|
*
|
|
32
32
|
* @defaultValue false
|
|
33
33
|
*/
|
|
34
|
-
create?: boolean
|
|
34
|
+
create?: boolean
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Optional custom directory name (basename only, no slashes).
|
|
38
38
|
*
|
|
39
39
|
* @example "clipboard"
|
|
40
40
|
*/
|
|
41
|
-
dirName?: string
|
|
41
|
+
dirName?: string
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Optional absolute root path under which the module directory will be created.
|
|
45
45
|
*
|
|
46
46
|
* @example "/var/app/modules"
|
|
47
47
|
*/
|
|
48
|
-
root?: string
|
|
48
|
+
root?: string
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
@@ -66,17 +66,17 @@ export interface ResolvedModuleFileConfig {
|
|
|
66
66
|
/**
|
|
67
67
|
* Final boolean indicating if the module has a dedicated directory.
|
|
68
68
|
*/
|
|
69
|
-
create: boolean
|
|
69
|
+
create: boolean
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* Final directory name (basename), if a directory is created.
|
|
73
73
|
*/
|
|
74
|
-
dirName?: string
|
|
74
|
+
dirName?: string
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Final absolute path to the module directory, if a directory is created.
|
|
78
78
|
*/
|
|
79
|
-
dirPath?: string
|
|
79
|
+
dirPath?: string
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
@@ -93,7 +93,7 @@ export interface ModuleDirectory {
|
|
|
93
93
|
/**
|
|
94
94
|
* Absolute path to the module directory.
|
|
95
95
|
*/
|
|
96
|
-
readonly path: string
|
|
96
|
+
readonly path: string
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* Joins one or more path segments to the module directory path. Does not touch the filesystem.
|
|
@@ -101,24 +101,24 @@ export interface ModuleDirectory {
|
|
|
101
101
|
* @param segments - One or more relative path segments.
|
|
102
102
|
* @returns The combined absolute path string.
|
|
103
103
|
*/
|
|
104
|
-
join(...segments: string[])
|
|
104
|
+
join: (...segments: string[]) => string
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Ensures the directory exists, creating it if necessary.
|
|
108
108
|
*/
|
|
109
|
-
ensure()
|
|
109
|
+
ensure: () => MaybePromise<void>
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* Checks whether the directory exists.
|
|
113
113
|
*/
|
|
114
|
-
exists()
|
|
114
|
+
exists: () => MaybePromise<boolean>
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* Lists entries in the directory (filenames/subdirectory names).
|
|
118
118
|
*
|
|
119
119
|
* @returns An array of entry names (not absolute paths).
|
|
120
120
|
*/
|
|
121
|
-
list()
|
|
121
|
+
list: () => MaybePromise<string[]>
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
124
|
* Reads a file within the module directory.
|
|
@@ -126,7 +126,7 @@ export interface ModuleDirectory {
|
|
|
126
126
|
* @param relativePath - Path relative to the module directory.
|
|
127
127
|
* @returns File contents as a Buffer or string (implementation-dependent).
|
|
128
128
|
*/
|
|
129
|
-
readFile(relativePath: string)
|
|
129
|
+
readFile: (relativePath: string) => MaybePromise<Buffer | string>
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* Writes a file within the module directory, creating parent folders if needed.
|
|
@@ -134,7 +134,7 @@ export interface ModuleDirectory {
|
|
|
134
134
|
* @param relativePath - Path relative to the module directory.
|
|
135
135
|
* @param data - File content.
|
|
136
136
|
*/
|
|
137
|
-
writeFile(relativePath: string, data: string | Uint8Array)
|
|
137
|
+
writeFile: (relativePath: string, data: string | Uint8Array) => MaybePromise<void>
|
|
138
138
|
|
|
139
139
|
/**
|
|
140
140
|
* Removes a file or subdirectory within the module directory.
|
|
@@ -142,5 +142,5 @@ export interface ModuleDirectory {
|
|
|
142
142
|
* @param relativePath - Path relative to the module directory. If omitted, implementations
|
|
143
143
|
* may remove the entire directory (use with caution).
|
|
144
144
|
*/
|
|
145
|
-
remove(relativePath?: string)
|
|
145
|
+
remove: (relativePath?: string) => MaybePromise<void>
|
|
146
146
|
}
|
package/types/modules/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { TalexTouch } from
|
|
4
|
-
import { ModuleDirectory, ResolvedModuleFileConfig } from
|
|
1
|
+
import type { ModuleKey } from '.'
|
|
2
|
+
import type { ITouchEventBus } from '../../eventbus'
|
|
3
|
+
import type { TalexTouch } from '../touch-app-core'
|
|
4
|
+
import type { ModuleDirectory, ResolvedModuleFileConfig } from './base'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Base context available to all lifecycle phases.
|
|
@@ -13,17 +13,17 @@ export interface ModuleBaseContext<E> {
|
|
|
13
13
|
/**
|
|
14
14
|
* The application root object (TalexTouch).
|
|
15
15
|
*/
|
|
16
|
-
app: TalexTouch.TouchApp
|
|
16
|
+
app: TalexTouch.TouchApp
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The module manager controlling creation, lifecycle, and lookup.
|
|
20
20
|
*/
|
|
21
|
-
manager: TalexTouch.IModuleManager<E
|
|
21
|
+
manager: TalexTouch.IModuleManager<E>
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* The unique key for the current module (same as the module's `name`).
|
|
25
25
|
*/
|
|
26
|
-
moduleKey: ModuleKey
|
|
26
|
+
moduleKey: ModuleKey
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Optional configuration accessor bound to the application or module.
|
|
@@ -31,12 +31,12 @@ export interface ModuleBaseContext<E> {
|
|
|
31
31
|
* @param key - Configuration key.
|
|
32
32
|
* @returns The typed configuration value.
|
|
33
33
|
*/
|
|
34
|
-
config
|
|
34
|
+
config?: <T = unknown>(key: string) => T
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Optional event bus bound to the application or module layer.
|
|
38
38
|
*/
|
|
39
|
-
events?: ITouchEventBus<E
|
|
39
|
+
events?: ITouchEventBus<E>
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* The module's directory instance if a directory was created; otherwise `undefined`.
|
|
@@ -44,7 +44,7 @@ export interface ModuleBaseContext<E> {
|
|
|
44
44
|
* @remarks
|
|
45
45
|
* **Single-directory rule**: Each module can expose at most one `ModuleDirectory` instance here.
|
|
46
46
|
*/
|
|
47
|
-
directory?: ModuleDirectory
|
|
47
|
+
directory?: ModuleDirectory
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
@@ -57,18 +57,18 @@ export interface ModuleCreateContext<E> extends ModuleBaseContext<E> {
|
|
|
57
57
|
/**
|
|
58
58
|
* Resolved file/directory configuration for the module.
|
|
59
59
|
*/
|
|
60
|
-
file: ResolvedModuleFileConfig
|
|
60
|
+
file: ResolvedModuleFileConfig
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Fully resolved module entry file path if a custom path was provided,
|
|
64
64
|
* or a default path computed by the manager; otherwise `undefined`.
|
|
65
65
|
*/
|
|
66
|
-
resolvedPath?: string
|
|
66
|
+
resolvedPath?: string
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Indicates whether this load is part of a hot-reload/replace cycle.
|
|
70
70
|
*/
|
|
71
|
-
hot?: boolean
|
|
71
|
+
hot?: boolean
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/**
|
|
@@ -81,12 +81,12 @@ export interface ModuleInitContext<E> extends ModuleBaseContext<E> {
|
|
|
81
81
|
/**
|
|
82
82
|
* Optional hint that dependencies have been verified and are ready.
|
|
83
83
|
*/
|
|
84
|
-
depsReady?: boolean
|
|
84
|
+
depsReady?: boolean
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* Resolved file/directory configuration for the module.
|
|
88
88
|
*/
|
|
89
|
-
file: ResolvedModuleFileConfig
|
|
89
|
+
file: ResolvedModuleFileConfig
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/**
|
|
@@ -99,12 +99,12 @@ export interface ModuleStartContext<E> extends ModuleBaseContext<E> {
|
|
|
99
99
|
/**
|
|
100
100
|
* Optional startup arguments or mode flags.
|
|
101
101
|
*/
|
|
102
|
-
startArgs?: Record<string, unknown
|
|
102
|
+
startArgs?: Record<string, unknown>
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* Resolved file/directory configuration for the module.
|
|
106
106
|
*/
|
|
107
|
-
file: ResolvedModuleFileConfig
|
|
107
|
+
file: ResolvedModuleFileConfig
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
/**
|
|
@@ -121,12 +121,12 @@ export interface ModuleStopContext<E> extends ModuleBaseContext<E> {
|
|
|
121
121
|
* - `"hot-reload"`: Stop as part of a hot reload / replacement cycle.
|
|
122
122
|
* - `string`: Custom reason.
|
|
123
123
|
*/
|
|
124
|
-
reason?:
|
|
124
|
+
reason?: 'normal' | 'error' | 'hot-reload' | string
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
127
|
* Resolved file/directory configuration for the module.
|
|
128
128
|
*/
|
|
129
|
-
file: ResolvedModuleFileConfig
|
|
129
|
+
file: ResolvedModuleFileConfig
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
@@ -139,10 +139,10 @@ export interface ModuleDestroyContext<E> extends ModuleBaseContext<E> {
|
|
|
139
139
|
/**
|
|
140
140
|
* Indicates the module is being destroyed as part of application shutdown.
|
|
141
141
|
*/
|
|
142
|
-
appClosing?: boolean
|
|
142
|
+
appClosing?: boolean
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* Resolved file/directory configuration for the module.
|
|
146
146
|
*/
|
|
147
|
-
file: ResolvedModuleFileConfig
|
|
147
|
+
file: ResolvedModuleFileConfig
|
|
148
148
|
}
|
|
@@ -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
|
}
|