@talex-touch/utils 1.0.42 → 1.0.45
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/.eslintcache +1 -0
- package/__tests__/cloud-sync-sdk.test.ts +442 -0
- package/__tests__/icons/icons.test.ts +84 -0
- package/__tests__/plugin-sdk-lifecycle.test.ts +130 -0
- package/__tests__/power-sdk.test.ts +143 -0
- package/__tests__/preset-export-types.test.ts +108 -0
- package/__tests__/search/fuzzy-match.test.ts +137 -0
- package/__tests__/transport/port-policy.test.ts +44 -0
- package/__tests__/transport-domain-sdks.test.ts +152 -0
- package/__tests__/types/update.test.ts +67 -0
- package/account/account-sdk.ts +915 -0
- package/account/index.ts +2 -0
- package/account/types.ts +321 -0
- package/analytics/client.ts +136 -0
- package/analytics/index.ts +2 -0
- package/analytics/types.ts +156 -0
- package/animation/auto-resize.ts +322 -0
- package/animation/window-node.ts +26 -19
- package/auth/clerk-types.ts +12 -30
- package/auth/index.ts +0 -2
- package/auth/useAuthState.ts +6 -14
- package/base/index.ts +2 -0
- package/base/log-level.ts +105 -0
- package/channel/index.ts +170 -69
- package/cloud-sync/cloud-sync-sdk.ts +450 -0
- package/cloud-sync/index.ts +1 -0
- package/common/file-scan-utils.ts +17 -9
- package/common/index.ts +4 -0
- package/common/logger/index.ts +46 -0
- package/common/logger/logger-manager.ts +303 -0
- package/common/logger/module-logger.ts +270 -0
- package/common/logger/transport-logger.ts +234 -0
- package/common/logger/types.ts +93 -0
- package/common/search/gather.ts +48 -6
- package/common/search/index.ts +8 -0
- package/common/storage/constants.ts +13 -0
- package/common/storage/entity/app-settings.ts +245 -0
- package/common/storage/entity/index.ts +3 -0
- package/common/storage/entity/layout-atom-types.ts +147 -0
- package/common/storage/entity/openers.ts +1 -0
- package/common/storage/entity/preset-cloud-api.ts +132 -0
- package/common/storage/entity/preset-export-types.ts +256 -0
- package/common/storage/entity/shortcut-settings.ts +1 -0
- package/common/storage/shortcut-storage.ts +11 -0
- package/common/utils/clone-diagnostics.ts +105 -0
- package/common/utils/file.ts +16 -8
- package/common/utils/index.ts +6 -2
- package/common/utils/payload-preview.ts +173 -0
- package/common/utils/polling.ts +167 -13
- package/common/utils/safe-path.ts +103 -0
- package/common/utils/safe-shell.ts +115 -0
- package/common/utils/task-queue.ts +4 -1
- package/core-box/builder/tuff-builder.ts +0 -1
- package/core-box/index.ts +1 -1
- package/core-box/recommendation.ts +38 -1
- package/core-box/tuff/tuff-dsl.ts +32 -0
- package/electron/download-manager.ts +10 -7
- package/electron/env-tool.ts +42 -40
- package/electron/index.ts +0 -1
- package/env/index.ts +156 -0
- package/eslint.config.js +55 -0
- package/i18n/index.ts +62 -0
- package/i18n/locales/en.json +226 -0
- package/i18n/locales/zh.json +226 -0
- package/i18n/message-keys.ts +236 -0
- package/i18n/resolver.ts +181 -0
- package/icons/index.ts +257 -0
- package/icons/svg.ts +69 -0
- package/index.ts +9 -1
- package/intelligence/client.ts +72 -42
- package/market/constants.ts +9 -5
- package/market/index.ts +1 -1
- package/market/types.ts +19 -4
- package/package.json +15 -5
- package/permission/index.ts +143 -46
- package/permission/legacy.ts +26 -0
- package/permission/registry.ts +304 -0
- package/permission/types.ts +164 -0
- package/plugin/channel.ts +68 -39
- package/plugin/index.ts +80 -7
- package/plugin/install.ts +3 -0
- package/plugin/log/types.ts +22 -5
- package/plugin/node/logger-manager.ts +11 -3
- package/plugin/node/logger.ts +24 -17
- package/plugin/preload.ts +25 -2
- package/plugin/providers/index.ts +4 -4
- package/plugin/providers/market-client.ts +6 -3
- package/plugin/providers/npm-provider.ts +22 -7
- package/plugin/providers/tpex-provider.ts +22 -8
- package/plugin/sdk/box-items.ts +14 -0
- package/plugin/sdk/box-sdk.ts +64 -0
- package/plugin/sdk/channel.ts +119 -4
- package/plugin/sdk/clipboard.ts +26 -12
- package/plugin/sdk/cloud-sync.ts +113 -0
- package/plugin/sdk/common.ts +19 -11
- package/plugin/sdk/core-box.ts +6 -15
- package/plugin/sdk/division-box.ts +160 -65
- package/plugin/sdk/examples/storage-onDidChange-example.js +5 -2
- package/plugin/sdk/feature-sdk.ts +111 -76
- package/plugin/sdk/flow.ts +146 -45
- package/plugin/sdk/hooks/bridge.ts +13 -6
- package/plugin/sdk/hooks/life-cycle.ts +35 -16
- package/plugin/sdk/index.ts +14 -3
- package/plugin/sdk/intelligence.ts +87 -0
- package/plugin/sdk/meta/README.md +179 -0
- package/plugin/sdk/meta-sdk.ts +244 -0
- package/plugin/sdk/notification.ts +9 -0
- package/plugin/sdk/plugin-info.ts +64 -0
- package/plugin/sdk/power.ts +155 -0
- package/plugin/sdk/recommend.ts +21 -0
- package/plugin/sdk/service/index.ts +12 -8
- package/plugin/sdk/sqlite.ts +141 -0
- package/plugin/sdk/storage.ts +2 -6
- package/plugin/sdk/system.ts +2 -9
- package/plugin/sdk/temp-files.ts +41 -0
- package/plugin/sdk/touch-sdk.ts +18 -0
- package/plugin/sdk/types.ts +44 -4
- package/plugin/sdk/window/index.ts +12 -9
- package/plugin/sdk-version.ts +231 -0
- package/preload/renderer.ts +3 -2
- package/renderer/hooks/arg-mapper.ts +16 -2
- package/renderer/hooks/index.ts +13 -0
- package/renderer/hooks/initialize.ts +2 -1
- package/renderer/hooks/use-agent-market-sdk.ts +7 -0
- package/renderer/hooks/use-agent-market.ts +106 -0
- package/renderer/hooks/use-agents-sdk.ts +7 -0
- package/renderer/hooks/use-app-sdk.ts +7 -0
- package/renderer/hooks/use-channel.ts +33 -4
- package/renderer/hooks/use-download-sdk.ts +21 -0
- package/renderer/hooks/use-intelligence-sdk.ts +7 -0
- package/renderer/hooks/use-intelligence-stats.ts +290 -0
- package/renderer/hooks/use-intelligence.ts +55 -214
- package/renderer/hooks/use-market-sdk.ts +16 -0
- package/renderer/hooks/use-notification-sdk.ts +7 -0
- package/renderer/hooks/use-permission-sdk.ts +7 -0
- package/renderer/hooks/use-permission.ts +325 -0
- package/renderer/hooks/use-platform-sdk.ts +7 -0
- package/renderer/hooks/use-plugin-sdk.ts +16 -0
- package/renderer/hooks/use-settings-sdk.ts +7 -0
- package/renderer/hooks/use-update-sdk.ts +21 -0
- package/renderer/index.ts +1 -0
- package/renderer/ref.ts +19 -10
- package/renderer/shared/components/SharedPluginDetailContent.vue +84 -0
- package/renderer/shared/components/SharedPluginDetailHeader.vue +116 -0
- package/renderer/shared/components/SharedPluginDetailMetaList.vue +39 -0
- package/renderer/shared/components/SharedPluginDetailReadme.vue +45 -0
- package/renderer/shared/components/SharedPluginDetailVersions.vue +98 -0
- package/renderer/shared/components/index.ts +5 -0
- package/renderer/shared/components/shims-vue.d.ts +5 -0
- package/renderer/shared/index.ts +2 -0
- package/renderer/shared/plugin-detail.ts +62 -0
- package/renderer/storage/app-settings.ts +3 -1
- package/renderer/storage/base-storage.ts +508 -82
- package/renderer/storage/intelligence-storage.ts +31 -40
- package/renderer/storage/openers.ts +3 -1
- package/renderer/storage/storage-subscription.ts +126 -42
- package/renderer/touch-sdk/env.ts +10 -10
- package/renderer/touch-sdk/index.ts +114 -18
- package/renderer/touch-sdk/terminal.ts +24 -13
- package/search/feature-matcher.ts +279 -0
- package/search/fuzzy-match.ts +64 -34
- package/search/index.ts +10 -0
- package/search/levenshtein-utils.ts +17 -11
- package/transport/errors.ts +310 -0
- package/transport/event/builder.ts +378 -0
- package/transport/event/index.ts +7 -0
- package/transport/event/types.ts +292 -0
- package/transport/events/index.ts +2690 -0
- package/transport/events/meta-overlay.ts +79 -0
- package/transport/events/types/agents.ts +177 -0
- package/transport/events/types/app-index.ts +20 -0
- package/transport/events/types/app.ts +475 -0
- package/transport/events/types/box-item.ts +222 -0
- package/transport/events/types/clipboard.ts +80 -0
- package/transport/events/types/core-box.ts +534 -0
- package/transport/events/types/device-idle.ts +7 -0
- package/transport/events/types/division-box.ts +99 -0
- package/transport/events/types/download.ts +115 -0
- package/transport/events/types/file-index.ts +84 -0
- package/transport/events/types/flow.ts +149 -0
- package/transport/events/types/index.ts +70 -0
- package/transport/events/types/market.ts +39 -0
- package/transport/events/types/meta-overlay.ts +184 -0
- package/transport/events/types/notification.ts +140 -0
- package/transport/events/types/permission.ts +90 -0
- package/transport/events/types/platform.ts +8 -0
- package/transport/events/types/plugin.ts +631 -0
- package/transport/events/types/sentry.ts +20 -0
- package/transport/events/types/storage.ts +208 -0
- package/transport/events/types/transport.ts +60 -0
- package/transport/events/types/tray.ts +16 -0
- package/transport/events/types/update.ts +78 -0
- package/transport/index.ts +141 -0
- package/transport/main.ts +2 -0
- package/transport/prelude.ts +208 -0
- package/transport/sdk/constants.ts +29 -0
- package/transport/sdk/domains/agents-market.ts +47 -0
- package/transport/sdk/domains/agents.ts +62 -0
- package/transport/sdk/domains/app.ts +48 -0
- package/transport/sdk/domains/disposable.ts +35 -0
- package/transport/sdk/domains/download.ts +139 -0
- package/transport/sdk/domains/index.ts +13 -0
- package/transport/sdk/domains/intelligence.ts +616 -0
- package/transport/sdk/domains/market.ts +35 -0
- package/transport/sdk/domains/notification.ts +62 -0
- package/transport/sdk/domains/permission.ts +85 -0
- package/transport/sdk/domains/platform.ts +19 -0
- package/transport/sdk/domains/plugin.ts +144 -0
- package/transport/sdk/domains/settings.ts +102 -0
- package/transport/sdk/domains/update.ts +64 -0
- package/transport/sdk/index.ts +60 -0
- package/transport/sdk/main-transport.ts +710 -0
- package/transport/sdk/main.ts +9 -0
- package/transport/sdk/plugin-transport.ts +654 -0
- package/transport/sdk/port-policy.ts +38 -0
- package/transport/sdk/renderer-transport.ts +1165 -0
- package/transport/types.ts +605 -0
- package/types/agent.ts +399 -0
- package/types/cloud-sync.ts +157 -0
- package/types/division-box.ts +31 -31
- package/types/download.ts +1 -0
- package/types/flow.ts +63 -12
- package/types/icon.ts +2 -1
- package/types/index.ts +5 -0
- package/types/intelligence.ts +166 -173
- package/types/modules/base.ts +2 -0
- package/types/path-browserify.d.ts +5 -0
- package/types/platform.ts +12 -0
- package/types/startup-info.ts +32 -0
- package/types/touch-app-core.ts +8 -8
- package/types/update.ts +94 -1
- package/vitest.config.ts +25 -0
- package/auth/useClerkConfig.ts +0 -40
- package/auth/useClerkProvider.ts +0 -52
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Type definitions for Storage domain events
|
|
3
|
+
* @module @talex-touch/utils/transport/events/types/storage
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// App Storage Types
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Request to get a storage value.
|
|
12
|
+
*/
|
|
13
|
+
export interface StorageGetRequest {
|
|
14
|
+
/**
|
|
15
|
+
* Storage key to retrieve.
|
|
16
|
+
*/
|
|
17
|
+
key: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Versioned storage response payload.
|
|
22
|
+
*/
|
|
23
|
+
export interface StorageGetVersionedResponse {
|
|
24
|
+
/**
|
|
25
|
+
* Stored data.
|
|
26
|
+
*/
|
|
27
|
+
data: unknown
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Current version number.
|
|
31
|
+
*/
|
|
32
|
+
version: number
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Request to set a storage value.
|
|
37
|
+
*/
|
|
38
|
+
export interface StorageSetRequest {
|
|
39
|
+
/**
|
|
40
|
+
* Storage key.
|
|
41
|
+
*/
|
|
42
|
+
key: string
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Value to store.
|
|
46
|
+
*/
|
|
47
|
+
value: unknown
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Request to save a storage value with version tracking.
|
|
52
|
+
*/
|
|
53
|
+
export interface StorageSaveRequest {
|
|
54
|
+
/**
|
|
55
|
+
* Storage key.
|
|
56
|
+
*/
|
|
57
|
+
key: string
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Serialized JSON content.
|
|
61
|
+
*/
|
|
62
|
+
content?: string
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Raw value to serialize (fallback when content not provided).
|
|
66
|
+
*/
|
|
67
|
+
value?: unknown
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Clear stored data for the key.
|
|
71
|
+
*/
|
|
72
|
+
clear?: boolean
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Force save even if content is unchanged.
|
|
76
|
+
*/
|
|
77
|
+
force?: boolean
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Client version for conflict detection.
|
|
81
|
+
*/
|
|
82
|
+
version?: number
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Result for versioned storage save.
|
|
87
|
+
*/
|
|
88
|
+
export interface StorageSaveResult {
|
|
89
|
+
success: boolean
|
|
90
|
+
version: number
|
|
91
|
+
conflict?: boolean
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Request to delete a storage value.
|
|
96
|
+
*/
|
|
97
|
+
export interface StorageDeleteRequest {
|
|
98
|
+
/**
|
|
99
|
+
* Storage key to delete.
|
|
100
|
+
*/
|
|
101
|
+
key: string
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ============================================================================
|
|
105
|
+
// Plugin Storage Types
|
|
106
|
+
// ============================================================================
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Request to get a plugin storage value.
|
|
110
|
+
*/
|
|
111
|
+
export interface PluginStorageGetRequest {
|
|
112
|
+
/**
|
|
113
|
+
* Plugin name.
|
|
114
|
+
*/
|
|
115
|
+
pluginName: string
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Storage key.
|
|
119
|
+
*/
|
|
120
|
+
key: string
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Request to set a plugin storage value.
|
|
125
|
+
*/
|
|
126
|
+
export interface PluginStorageSetRequest {
|
|
127
|
+
/**
|
|
128
|
+
* Plugin name.
|
|
129
|
+
*/
|
|
130
|
+
pluginName: string
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Storage key.
|
|
134
|
+
*/
|
|
135
|
+
key: string
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Value to store.
|
|
139
|
+
*/
|
|
140
|
+
value: unknown
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Request to delete a plugin storage value.
|
|
145
|
+
*/
|
|
146
|
+
export interface PluginStorageDeleteRequest {
|
|
147
|
+
/**
|
|
148
|
+
* Plugin name.
|
|
149
|
+
*/
|
|
150
|
+
pluginName: string
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Storage key to delete.
|
|
154
|
+
*/
|
|
155
|
+
key: string
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Storage subscription notification.
|
|
160
|
+
*/
|
|
161
|
+
export interface StorageUpdateNotification {
|
|
162
|
+
/**
|
|
163
|
+
* Storage key that was updated.
|
|
164
|
+
*/
|
|
165
|
+
key: string
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* New value (undefined if deleted).
|
|
169
|
+
*/
|
|
170
|
+
value?: unknown
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Version number if available.
|
|
174
|
+
*/
|
|
175
|
+
version?: number
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Update timestamp.
|
|
179
|
+
*/
|
|
180
|
+
timestamp: number
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Source of the update.
|
|
184
|
+
*/
|
|
185
|
+
source?: 'local' | 'remote' | 'sync'
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface StorageLegacyUpdatePayload {
|
|
189
|
+
/**
|
|
190
|
+
* Legacy storage key name.
|
|
191
|
+
*/
|
|
192
|
+
name: string
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Version number if available.
|
|
196
|
+
*/
|
|
197
|
+
version?: number
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Plugin storage update notification.
|
|
202
|
+
*/
|
|
203
|
+
export interface PluginStorageUpdateNotification extends StorageUpdateNotification {
|
|
204
|
+
/**
|
|
205
|
+
* Plugin name.
|
|
206
|
+
*/
|
|
207
|
+
pluginName: string
|
|
208
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Type definitions for Transport port upgrade events
|
|
3
|
+
* @module @talex-touch/utils/transport/events/types/transport
|
|
4
|
+
* @since v0.9.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type TransportPortScope = 'app' | 'window' | 'plugin'
|
|
8
|
+
|
|
9
|
+
export interface TransportPortError {
|
|
10
|
+
code: string
|
|
11
|
+
message: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TransportPortUpgradeRequest {
|
|
15
|
+
channel: string
|
|
16
|
+
scope?: TransportPortScope
|
|
17
|
+
windowId?: number
|
|
18
|
+
plugin?: string
|
|
19
|
+
permissions?: string[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface TransportPortUpgradeResponse {
|
|
23
|
+
accepted: boolean
|
|
24
|
+
channel: string
|
|
25
|
+
scope?: TransportPortScope
|
|
26
|
+
permissions?: string[]
|
|
27
|
+
portId?: string
|
|
28
|
+
error?: TransportPortError
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface TransportPortConfirmPayload {
|
|
32
|
+
channel: string
|
|
33
|
+
portId: string
|
|
34
|
+
scope?: TransportPortScope
|
|
35
|
+
permissions?: string[]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface TransportPortClosePayload {
|
|
39
|
+
channel: string
|
|
40
|
+
portId?: string
|
|
41
|
+
scope?: TransportPortScope
|
|
42
|
+
reason?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface TransportPortErrorPayload {
|
|
46
|
+
channel: string
|
|
47
|
+
portId?: string
|
|
48
|
+
scope?: TransportPortScope
|
|
49
|
+
error: TransportPortError
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface TransportPortEnvelope<TPayload = unknown> {
|
|
53
|
+
channel: string
|
|
54
|
+
portId?: string
|
|
55
|
+
streamId?: string
|
|
56
|
+
sequence?: number
|
|
57
|
+
type: 'data' | 'close' | 'error'
|
|
58
|
+
payload?: TPayload
|
|
59
|
+
error?: TransportPortError
|
|
60
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Type definitions for Tray domain events
|
|
3
|
+
* @module @talex-touch/utils/transport/events/types/tray
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type TrayAutostartUpdateRequest = boolean
|
|
7
|
+
export type TrayAutostartUpdateResponse = boolean
|
|
8
|
+
|
|
9
|
+
export type TrayAutostartGetResponse = boolean
|
|
10
|
+
|
|
11
|
+
export type TrayShowGetResponse = boolean
|
|
12
|
+
|
|
13
|
+
export type TrayShowSetRequest = boolean
|
|
14
|
+
export type TrayShowSetResponse = boolean
|
|
15
|
+
|
|
16
|
+
export type TrayHideDockSetResponse = boolean
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AppPreviewChannel,
|
|
3
|
+
CachedUpdateRecord,
|
|
4
|
+
GitHubRelease,
|
|
5
|
+
UpdateCheckResult,
|
|
6
|
+
UpdateSettings,
|
|
7
|
+
UpdateUserAction,
|
|
8
|
+
} from '../../../types/update'
|
|
9
|
+
|
|
10
|
+
export interface UpdateOpResponse<T = void> {
|
|
11
|
+
success: boolean
|
|
12
|
+
data?: T
|
|
13
|
+
error?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface UpdateCheckRequest {
|
|
17
|
+
force?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type UpdateGetStatusResponse = UpdateOpResponse<{
|
|
21
|
+
enabled: boolean
|
|
22
|
+
frequency: UpdateSettings['frequency']
|
|
23
|
+
source: UpdateSettings['source']
|
|
24
|
+
channel: AppPreviewChannel
|
|
25
|
+
polling: boolean
|
|
26
|
+
lastCheck: number | null
|
|
27
|
+
downloadReady?: boolean
|
|
28
|
+
downloadReadyVersion?: string | null
|
|
29
|
+
downloadTaskId?: string | null
|
|
30
|
+
}>
|
|
31
|
+
|
|
32
|
+
export interface UpdateCachedReleaseRequest {
|
|
33
|
+
channel?: AppPreviewChannel
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface UpdateRecordActionRequest {
|
|
37
|
+
tag: string
|
|
38
|
+
action: UpdateUserAction
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type UpdateDownloadRequest = GitHubRelease
|
|
42
|
+
|
|
43
|
+
export type UpdateDownloadResponse = UpdateOpResponse<{
|
|
44
|
+
taskId?: string
|
|
45
|
+
}>
|
|
46
|
+
|
|
47
|
+
export interface UpdateInstallRequest {
|
|
48
|
+
taskId?: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface UpdateIgnoreVersionRequest {
|
|
52
|
+
version: string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface UpdateAutoDownloadRequest {
|
|
56
|
+
enabled: boolean
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface UpdateAutoCheckRequest {
|
|
60
|
+
enabled: boolean
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface UpdateAvailablePayload {
|
|
64
|
+
hasUpdate: boolean
|
|
65
|
+
release: GitHubRelease
|
|
66
|
+
source: string
|
|
67
|
+
channel?: AppPreviewChannel
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type UpdateGetCachedReleaseResponse = UpdateOpResponse<CachedUpdateRecord | null>
|
|
71
|
+
|
|
72
|
+
export type UpdateCheckResponse = UpdateOpResponse<UpdateCheckResult>
|
|
73
|
+
|
|
74
|
+
export type UpdateGetSettingsResponse = UpdateOpResponse<UpdateSettings>
|
|
75
|
+
|
|
76
|
+
export interface UpdateUpdateSettingsRequest {
|
|
77
|
+
settings: Partial<UpdateSettings>
|
|
78
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview TuffTransport - Next-generation IPC communication system for Tuff
|
|
3
|
+
* @module @talex-touch/utils/transport
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* TuffTransport provides a type-safe, high-performance IPC communication layer
|
|
8
|
+
* with support for batching, streaming, and plugin isolation.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { useTuffTransport, CoreBoxEvents } from '@talex-touch/utils/transport'
|
|
13
|
+
*
|
|
14
|
+
* const transport = useTuffTransport()
|
|
15
|
+
* await transport.send(CoreBoxEvents.ui.hide)
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// Event Builder
|
|
21
|
+
// ============================================================================
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Use `useTuffTransport()` instead. Will be removed in v3.0.0.
|
|
26
|
+
*/
|
|
27
|
+
ChannelType,
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use `TuffTransportErrorCode` instead. Will be removed in v3.0.0.
|
|
30
|
+
*/
|
|
31
|
+
DataCode,
|
|
32
|
+
} from '../channel'
|
|
33
|
+
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// Event Types
|
|
36
|
+
// ============================================================================
|
|
37
|
+
|
|
38
|
+
export type {
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Use `ITuffTransport` instead. Will be removed in v3.0.0.
|
|
41
|
+
*/
|
|
42
|
+
ITouchChannel,
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Use `ITuffTransport` instead. Will be removed in v3.0.0.
|
|
45
|
+
*/
|
|
46
|
+
ITouchClientChannel,
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use TuffTransport types instead. Will be removed in v3.0.0.
|
|
49
|
+
*/
|
|
50
|
+
RawStandardChannelData,
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated Use TuffTransport types instead. Will be removed in v3.0.0.
|
|
53
|
+
*/
|
|
54
|
+
StandardChannelData,
|
|
55
|
+
} from '../channel'
|
|
56
|
+
|
|
57
|
+
// ============================================================================
|
|
58
|
+
// Predefined Events (by domain)
|
|
59
|
+
// ============================================================================
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
TuffTransportError,
|
|
63
|
+
TuffTransportErrorCode,
|
|
64
|
+
} from './errors'
|
|
65
|
+
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// SDK Types
|
|
68
|
+
// ============================================================================
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
assertTuffEvent,
|
|
72
|
+
defineEvent,
|
|
73
|
+
isTuffEvent,
|
|
74
|
+
TuffActionBuilder,
|
|
75
|
+
TuffEventBuilder,
|
|
76
|
+
TuffModuleBuilder,
|
|
77
|
+
} from './event/builder'
|
|
78
|
+
|
|
79
|
+
// ============================================================================
|
|
80
|
+
// Error Types
|
|
81
|
+
// ============================================================================
|
|
82
|
+
|
|
83
|
+
export type {
|
|
84
|
+
BatchConfig,
|
|
85
|
+
EventOptions,
|
|
86
|
+
EventRequest,
|
|
87
|
+
EventResponse,
|
|
88
|
+
IsStreamEvent,
|
|
89
|
+
StreamChunk,
|
|
90
|
+
StreamConfig,
|
|
91
|
+
TuffEvent,
|
|
92
|
+
} from './event/types'
|
|
93
|
+
|
|
94
|
+
// ============================================================================
|
|
95
|
+
// SDK Functions
|
|
96
|
+
// ============================================================================
|
|
97
|
+
|
|
98
|
+
export * from './events'
|
|
99
|
+
|
|
100
|
+
// ============================================================================
|
|
101
|
+
// Legacy Compatibility (Deprecated)
|
|
102
|
+
// ============================================================================
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
createPluginTuffTransport,
|
|
106
|
+
createTuffRendererTransport,
|
|
107
|
+
useTuffTransport,
|
|
108
|
+
} from './sdk'
|
|
109
|
+
|
|
110
|
+
export type {
|
|
111
|
+
// Batch types
|
|
112
|
+
BatchPayload,
|
|
113
|
+
BatchResponse,
|
|
114
|
+
BatchResult,
|
|
115
|
+
|
|
116
|
+
// Contexts
|
|
117
|
+
HandlerContext,
|
|
118
|
+
IPluginTuffTransport,
|
|
119
|
+
// Transport interfaces
|
|
120
|
+
ITuffTransport,
|
|
121
|
+
|
|
122
|
+
ITuffTransportMain,
|
|
123
|
+
PluginKeyManager,
|
|
124
|
+
|
|
125
|
+
// Plugin security
|
|
126
|
+
PluginSecurityContext,
|
|
127
|
+
// Options
|
|
128
|
+
SendOptions,
|
|
129
|
+
StreamContext,
|
|
130
|
+
|
|
131
|
+
StreamController,
|
|
132
|
+
// Stream types
|
|
133
|
+
StreamMessage,
|
|
134
|
+
|
|
135
|
+
StreamMessageType,
|
|
136
|
+
StreamOptions,
|
|
137
|
+
TransportPortHandle,
|
|
138
|
+
TransportPortOpenOptions,
|
|
139
|
+
} from './types'
|
|
140
|
+
|
|
141
|
+
export * from './prelude'
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { DataCode } from '../channel'
|
|
2
|
+
|
|
3
|
+
type PluginChannelPreludeOptions = {
|
|
4
|
+
uniqueKey: string
|
|
5
|
+
initialData?: Record<string, unknown>
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function getPluginChannelPreludeCode(options: PluginChannelPreludeOptions): string {
|
|
9
|
+
const initialData = options.initialData ?? {}
|
|
10
|
+
|
|
11
|
+
return `
|
|
12
|
+
(function() {
|
|
13
|
+
const uniqueKey = ${JSON.stringify(options.uniqueKey)};
|
|
14
|
+
window['$tuffInitialData'] = ${JSON.stringify(initialData)};
|
|
15
|
+
const { ipcRenderer } = require('electron');
|
|
16
|
+
const DataCode = ${JSON.stringify(DataCode)};
|
|
17
|
+
const CHANNEL_DEFAULT_TIMEOUT = 60000;
|
|
18
|
+
|
|
19
|
+
class TouchChannel {
|
|
20
|
+
channelMap = new Map();
|
|
21
|
+
pendingMap = new Map();
|
|
22
|
+
earlyMessageQueue = new Map();
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
ipcRenderer.on('@plugin-process-message', this.__handle_main.bind(this));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
__parse_raw_data(e, arg) {
|
|
29
|
+
if (arg) {
|
|
30
|
+
const { name, header, code, plugin, data, sync } = arg;
|
|
31
|
+
if (header) {
|
|
32
|
+
const { uniqueKey: thisUniqueKey } = header;
|
|
33
|
+
if (!thisUniqueKey) {
|
|
34
|
+
console.warn('[Plugin] uniqueKey missing in header:', arg);
|
|
35
|
+
} else if (thisUniqueKey !== uniqueKey) {
|
|
36
|
+
console.error('[Plugin] uniqueKey mismatch:', thisUniqueKey, uniqueKey);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
header: {
|
|
41
|
+
status: header.status || 'request',
|
|
42
|
+
type: 'main',
|
|
43
|
+
_originData: arg,
|
|
44
|
+
event: e || undefined
|
|
45
|
+
},
|
|
46
|
+
sync,
|
|
47
|
+
code,
|
|
48
|
+
data,
|
|
49
|
+
plugin,
|
|
50
|
+
name
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
console.error(e, arg);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
__handle_main(e, arg) {
|
|
59
|
+
const rawData = this.__parse_raw_data(e, arg);
|
|
60
|
+
if (!rawData?.header) return;
|
|
61
|
+
if (rawData.header.status === 'reply' && rawData.sync) {
|
|
62
|
+
const { id } = rawData.sync;
|
|
63
|
+
return this.pendingMap.get(id)?.(rawData);
|
|
64
|
+
}
|
|
65
|
+
const listeners = this.channelMap.get(rawData.name);
|
|
66
|
+
if (listeners && listeners.length > 0) {
|
|
67
|
+
this.__dispatch(e, rawData, listeners);
|
|
68
|
+
} else {
|
|
69
|
+
const queue = this.earlyMessageQueue.get(rawData.name) || [];
|
|
70
|
+
queue.push({ e, rawData });
|
|
71
|
+
this.earlyMessageQueue.set(rawData.name, queue);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
__dispatch(e, rawData, listeners) {
|
|
76
|
+
listeners.forEach((func) => {
|
|
77
|
+
const handInData = {
|
|
78
|
+
reply: (code, data) => {
|
|
79
|
+
e.sender.send(
|
|
80
|
+
'@plugin-process-message',
|
|
81
|
+
this.__parse_sender(code, rawData, data, rawData.sync)
|
|
82
|
+
);
|
|
83
|
+
},
|
|
84
|
+
...rawData
|
|
85
|
+
};
|
|
86
|
+
func(handInData);
|
|
87
|
+
handInData.reply(DataCode.SUCCESS, undefined);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
__parse_sender(code, rawData, data, sync) {
|
|
92
|
+
return {
|
|
93
|
+
code,
|
|
94
|
+
data,
|
|
95
|
+
sync: !sync ? undefined : {
|
|
96
|
+
timeStamp: new Date().getTime(),
|
|
97
|
+
timeout: sync.timeout,
|
|
98
|
+
id: sync.id
|
|
99
|
+
},
|
|
100
|
+
name: rawData.name,
|
|
101
|
+
header: {
|
|
102
|
+
status: 'reply',
|
|
103
|
+
type: rawData.header.type,
|
|
104
|
+
_originData: rawData.header._originData
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
regChannel(eventName, callback) {
|
|
110
|
+
const listeners = this.channelMap.get(eventName) || [];
|
|
111
|
+
if (!listeners.includes(callback)) {
|
|
112
|
+
listeners.push(callback);
|
|
113
|
+
} else {
|
|
114
|
+
return () => {};
|
|
115
|
+
}
|
|
116
|
+
this.channelMap.set(eventName, listeners);
|
|
117
|
+
|
|
118
|
+
const earlyMessages = this.earlyMessageQueue.get(eventName);
|
|
119
|
+
if (earlyMessages && earlyMessages.length > 0) {
|
|
120
|
+
this.earlyMessageQueue.delete(eventName);
|
|
121
|
+
earlyMessages.forEach(({ e, rawData }) => {
|
|
122
|
+
this.__dispatch(e, rawData, [callback]);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return () => {
|
|
127
|
+
const index = listeners.indexOf(callback);
|
|
128
|
+
if (index !== -1) {
|
|
129
|
+
listeners.splice(index, 1);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
send(eventName, arg) {
|
|
135
|
+
const uniqueId = Date.now() + '#' + eventName + '@' + Math.random().toString(12);
|
|
136
|
+
const data = {
|
|
137
|
+
code: DataCode.SUCCESS,
|
|
138
|
+
data: arg,
|
|
139
|
+
sync: {
|
|
140
|
+
timeStamp: new Date().getTime(),
|
|
141
|
+
timeout: CHANNEL_DEFAULT_TIMEOUT,
|
|
142
|
+
id: uniqueId
|
|
143
|
+
},
|
|
144
|
+
name: eventName,
|
|
145
|
+
header: {
|
|
146
|
+
uniqueKey,
|
|
147
|
+
status: 'request',
|
|
148
|
+
type: 'plugin'
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const instance = this;
|
|
152
|
+
return new Promise((resolve, reject) => {
|
|
153
|
+
try {
|
|
154
|
+
ipcRenderer.send('@plugin-process-message', data);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
157
|
+
console.error('[Plugin] Failed to send channel message', eventName, errorMessage);
|
|
158
|
+
const sendError = new Error('Failed to send plugin channel message "' + eventName + '": ' + errorMessage);
|
|
159
|
+
sendError.code = 'plugin_channel_send_failed';
|
|
160
|
+
reject(sendError);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const timeoutMs = data.sync?.timeout ?? CHANNEL_DEFAULT_TIMEOUT;
|
|
165
|
+
const timeoutHandle = setTimeout(() => {
|
|
166
|
+
if (!instance.pendingMap.has(uniqueId)) return;
|
|
167
|
+
instance.pendingMap.delete(uniqueId);
|
|
168
|
+
const timeoutError = new Error('Plugin channel request "' + eventName + '" timed out after ' + timeoutMs + 'ms');
|
|
169
|
+
timeoutError.code = 'plugin_channel_timeout';
|
|
170
|
+
console.warn(timeoutError.message);
|
|
171
|
+
reject(timeoutError);
|
|
172
|
+
}, timeoutMs);
|
|
173
|
+
|
|
174
|
+
instance.pendingMap.set(uniqueId, (res) => {
|
|
175
|
+
clearTimeout(timeoutHandle);
|
|
176
|
+
instance.pendingMap.delete(uniqueId);
|
|
177
|
+
resolve(res.data);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
sendSync(eventName, arg) {
|
|
183
|
+
const data = {
|
|
184
|
+
code: DataCode.SUCCESS,
|
|
185
|
+
data: arg,
|
|
186
|
+
name: eventName,
|
|
187
|
+
header: {
|
|
188
|
+
uniqueKey,
|
|
189
|
+
status: 'request',
|
|
190
|
+
type: 'plugin'
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
try {
|
|
194
|
+
const res = this.__parse_raw_data(null, ipcRenderer.sendSync('@plugin-process-message', data));
|
|
195
|
+
if (res?.header?.status === 'reply') return res.data;
|
|
196
|
+
return res;
|
|
197
|
+
} catch (error) {
|
|
198
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
199
|
+
console.error('[Plugin] Failed to sendSync channel message', eventName, errorMessage);
|
|
200
|
+
throw new Error('Failed to sendSync plugin channel message "' + eventName + '": ' + errorMessage);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
window['$channel'] = new TouchChannel();
|
|
206
|
+
})();
|
|
207
|
+
`
|
|
208
|
+
}
|