@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.
Files changed (234) hide show
  1. package/.eslintcache +1 -0
  2. package/__tests__/cloud-sync-sdk.test.ts +442 -0
  3. package/__tests__/icons/icons.test.ts +84 -0
  4. package/__tests__/plugin-sdk-lifecycle.test.ts +130 -0
  5. package/__tests__/power-sdk.test.ts +143 -0
  6. package/__tests__/preset-export-types.test.ts +108 -0
  7. package/__tests__/search/fuzzy-match.test.ts +137 -0
  8. package/__tests__/transport/port-policy.test.ts +44 -0
  9. package/__tests__/transport-domain-sdks.test.ts +152 -0
  10. package/__tests__/types/update.test.ts +67 -0
  11. package/account/account-sdk.ts +915 -0
  12. package/account/index.ts +2 -0
  13. package/account/types.ts +321 -0
  14. package/analytics/client.ts +136 -0
  15. package/analytics/index.ts +2 -0
  16. package/analytics/types.ts +156 -0
  17. package/animation/auto-resize.ts +322 -0
  18. package/animation/window-node.ts +26 -19
  19. package/auth/clerk-types.ts +12 -30
  20. package/auth/index.ts +0 -2
  21. package/auth/useAuthState.ts +6 -14
  22. package/base/index.ts +2 -0
  23. package/base/log-level.ts +105 -0
  24. package/channel/index.ts +170 -69
  25. package/cloud-sync/cloud-sync-sdk.ts +450 -0
  26. package/cloud-sync/index.ts +1 -0
  27. package/common/file-scan-utils.ts +17 -9
  28. package/common/index.ts +4 -0
  29. package/common/logger/index.ts +46 -0
  30. package/common/logger/logger-manager.ts +303 -0
  31. package/common/logger/module-logger.ts +270 -0
  32. package/common/logger/transport-logger.ts +234 -0
  33. package/common/logger/types.ts +93 -0
  34. package/common/search/gather.ts +48 -6
  35. package/common/search/index.ts +8 -0
  36. package/common/storage/constants.ts +13 -0
  37. package/common/storage/entity/app-settings.ts +245 -0
  38. package/common/storage/entity/index.ts +3 -0
  39. package/common/storage/entity/layout-atom-types.ts +147 -0
  40. package/common/storage/entity/openers.ts +1 -0
  41. package/common/storage/entity/preset-cloud-api.ts +132 -0
  42. package/common/storage/entity/preset-export-types.ts +256 -0
  43. package/common/storage/entity/shortcut-settings.ts +1 -0
  44. package/common/storage/shortcut-storage.ts +11 -0
  45. package/common/utils/clone-diagnostics.ts +105 -0
  46. package/common/utils/file.ts +16 -8
  47. package/common/utils/index.ts +6 -2
  48. package/common/utils/payload-preview.ts +173 -0
  49. package/common/utils/polling.ts +167 -13
  50. package/common/utils/safe-path.ts +103 -0
  51. package/common/utils/safe-shell.ts +115 -0
  52. package/common/utils/task-queue.ts +4 -1
  53. package/core-box/builder/tuff-builder.ts +0 -1
  54. package/core-box/index.ts +1 -1
  55. package/core-box/recommendation.ts +38 -1
  56. package/core-box/tuff/tuff-dsl.ts +32 -0
  57. package/electron/download-manager.ts +10 -7
  58. package/electron/env-tool.ts +42 -40
  59. package/electron/index.ts +0 -1
  60. package/env/index.ts +156 -0
  61. package/eslint.config.js +55 -0
  62. package/i18n/index.ts +62 -0
  63. package/i18n/locales/en.json +226 -0
  64. package/i18n/locales/zh.json +226 -0
  65. package/i18n/message-keys.ts +236 -0
  66. package/i18n/resolver.ts +181 -0
  67. package/icons/index.ts +257 -0
  68. package/icons/svg.ts +69 -0
  69. package/index.ts +9 -1
  70. package/intelligence/client.ts +72 -42
  71. package/market/constants.ts +9 -5
  72. package/market/index.ts +1 -1
  73. package/market/types.ts +19 -4
  74. package/package.json +15 -5
  75. package/permission/index.ts +143 -46
  76. package/permission/legacy.ts +26 -0
  77. package/permission/registry.ts +304 -0
  78. package/permission/types.ts +164 -0
  79. package/plugin/channel.ts +68 -39
  80. package/plugin/index.ts +80 -7
  81. package/plugin/install.ts +3 -0
  82. package/plugin/log/types.ts +22 -5
  83. package/plugin/node/logger-manager.ts +11 -3
  84. package/plugin/node/logger.ts +24 -17
  85. package/plugin/preload.ts +25 -2
  86. package/plugin/providers/index.ts +4 -4
  87. package/plugin/providers/market-client.ts +6 -3
  88. package/plugin/providers/npm-provider.ts +22 -7
  89. package/plugin/providers/tpex-provider.ts +22 -8
  90. package/plugin/sdk/box-items.ts +14 -0
  91. package/plugin/sdk/box-sdk.ts +64 -0
  92. package/plugin/sdk/channel.ts +119 -4
  93. package/plugin/sdk/clipboard.ts +26 -12
  94. package/plugin/sdk/cloud-sync.ts +113 -0
  95. package/plugin/sdk/common.ts +19 -11
  96. package/plugin/sdk/core-box.ts +6 -15
  97. package/plugin/sdk/division-box.ts +160 -65
  98. package/plugin/sdk/examples/storage-onDidChange-example.js +5 -2
  99. package/plugin/sdk/feature-sdk.ts +111 -76
  100. package/plugin/sdk/flow.ts +146 -45
  101. package/plugin/sdk/hooks/bridge.ts +13 -6
  102. package/plugin/sdk/hooks/life-cycle.ts +35 -16
  103. package/plugin/sdk/index.ts +14 -3
  104. package/plugin/sdk/intelligence.ts +87 -0
  105. package/plugin/sdk/meta/README.md +179 -0
  106. package/plugin/sdk/meta-sdk.ts +244 -0
  107. package/plugin/sdk/notification.ts +9 -0
  108. package/plugin/sdk/plugin-info.ts +64 -0
  109. package/plugin/sdk/power.ts +155 -0
  110. package/plugin/sdk/recommend.ts +21 -0
  111. package/plugin/sdk/service/index.ts +12 -8
  112. package/plugin/sdk/sqlite.ts +141 -0
  113. package/plugin/sdk/storage.ts +2 -6
  114. package/plugin/sdk/system.ts +2 -9
  115. package/plugin/sdk/temp-files.ts +41 -0
  116. package/plugin/sdk/touch-sdk.ts +18 -0
  117. package/plugin/sdk/types.ts +44 -4
  118. package/plugin/sdk/window/index.ts +12 -9
  119. package/plugin/sdk-version.ts +231 -0
  120. package/preload/renderer.ts +3 -2
  121. package/renderer/hooks/arg-mapper.ts +16 -2
  122. package/renderer/hooks/index.ts +13 -0
  123. package/renderer/hooks/initialize.ts +2 -1
  124. package/renderer/hooks/use-agent-market-sdk.ts +7 -0
  125. package/renderer/hooks/use-agent-market.ts +106 -0
  126. package/renderer/hooks/use-agents-sdk.ts +7 -0
  127. package/renderer/hooks/use-app-sdk.ts +7 -0
  128. package/renderer/hooks/use-channel.ts +33 -4
  129. package/renderer/hooks/use-download-sdk.ts +21 -0
  130. package/renderer/hooks/use-intelligence-sdk.ts +7 -0
  131. package/renderer/hooks/use-intelligence-stats.ts +290 -0
  132. package/renderer/hooks/use-intelligence.ts +55 -214
  133. package/renderer/hooks/use-market-sdk.ts +16 -0
  134. package/renderer/hooks/use-notification-sdk.ts +7 -0
  135. package/renderer/hooks/use-permission-sdk.ts +7 -0
  136. package/renderer/hooks/use-permission.ts +325 -0
  137. package/renderer/hooks/use-platform-sdk.ts +7 -0
  138. package/renderer/hooks/use-plugin-sdk.ts +16 -0
  139. package/renderer/hooks/use-settings-sdk.ts +7 -0
  140. package/renderer/hooks/use-update-sdk.ts +21 -0
  141. package/renderer/index.ts +1 -0
  142. package/renderer/ref.ts +19 -10
  143. package/renderer/shared/components/SharedPluginDetailContent.vue +84 -0
  144. package/renderer/shared/components/SharedPluginDetailHeader.vue +116 -0
  145. package/renderer/shared/components/SharedPluginDetailMetaList.vue +39 -0
  146. package/renderer/shared/components/SharedPluginDetailReadme.vue +45 -0
  147. package/renderer/shared/components/SharedPluginDetailVersions.vue +98 -0
  148. package/renderer/shared/components/index.ts +5 -0
  149. package/renderer/shared/components/shims-vue.d.ts +5 -0
  150. package/renderer/shared/index.ts +2 -0
  151. package/renderer/shared/plugin-detail.ts +62 -0
  152. package/renderer/storage/app-settings.ts +3 -1
  153. package/renderer/storage/base-storage.ts +508 -82
  154. package/renderer/storage/intelligence-storage.ts +31 -40
  155. package/renderer/storage/openers.ts +3 -1
  156. package/renderer/storage/storage-subscription.ts +126 -42
  157. package/renderer/touch-sdk/env.ts +10 -10
  158. package/renderer/touch-sdk/index.ts +114 -18
  159. package/renderer/touch-sdk/terminal.ts +24 -13
  160. package/search/feature-matcher.ts +279 -0
  161. package/search/fuzzy-match.ts +64 -34
  162. package/search/index.ts +10 -0
  163. package/search/levenshtein-utils.ts +17 -11
  164. package/transport/errors.ts +310 -0
  165. package/transport/event/builder.ts +378 -0
  166. package/transport/event/index.ts +7 -0
  167. package/transport/event/types.ts +292 -0
  168. package/transport/events/index.ts +2690 -0
  169. package/transport/events/meta-overlay.ts +79 -0
  170. package/transport/events/types/agents.ts +177 -0
  171. package/transport/events/types/app-index.ts +20 -0
  172. package/transport/events/types/app.ts +475 -0
  173. package/transport/events/types/box-item.ts +222 -0
  174. package/transport/events/types/clipboard.ts +80 -0
  175. package/transport/events/types/core-box.ts +534 -0
  176. package/transport/events/types/device-idle.ts +7 -0
  177. package/transport/events/types/division-box.ts +99 -0
  178. package/transport/events/types/download.ts +115 -0
  179. package/transport/events/types/file-index.ts +84 -0
  180. package/transport/events/types/flow.ts +149 -0
  181. package/transport/events/types/index.ts +70 -0
  182. package/transport/events/types/market.ts +39 -0
  183. package/transport/events/types/meta-overlay.ts +184 -0
  184. package/transport/events/types/notification.ts +140 -0
  185. package/transport/events/types/permission.ts +90 -0
  186. package/transport/events/types/platform.ts +8 -0
  187. package/transport/events/types/plugin.ts +631 -0
  188. package/transport/events/types/sentry.ts +20 -0
  189. package/transport/events/types/storage.ts +208 -0
  190. package/transport/events/types/transport.ts +60 -0
  191. package/transport/events/types/tray.ts +16 -0
  192. package/transport/events/types/update.ts +78 -0
  193. package/transport/index.ts +141 -0
  194. package/transport/main.ts +2 -0
  195. package/transport/prelude.ts +208 -0
  196. package/transport/sdk/constants.ts +29 -0
  197. package/transport/sdk/domains/agents-market.ts +47 -0
  198. package/transport/sdk/domains/agents.ts +62 -0
  199. package/transport/sdk/domains/app.ts +48 -0
  200. package/transport/sdk/domains/disposable.ts +35 -0
  201. package/transport/sdk/domains/download.ts +139 -0
  202. package/transport/sdk/domains/index.ts +13 -0
  203. package/transport/sdk/domains/intelligence.ts +616 -0
  204. package/transport/sdk/domains/market.ts +35 -0
  205. package/transport/sdk/domains/notification.ts +62 -0
  206. package/transport/sdk/domains/permission.ts +85 -0
  207. package/transport/sdk/domains/platform.ts +19 -0
  208. package/transport/sdk/domains/plugin.ts +144 -0
  209. package/transport/sdk/domains/settings.ts +102 -0
  210. package/transport/sdk/domains/update.ts +64 -0
  211. package/transport/sdk/index.ts +60 -0
  212. package/transport/sdk/main-transport.ts +710 -0
  213. package/transport/sdk/main.ts +9 -0
  214. package/transport/sdk/plugin-transport.ts +654 -0
  215. package/transport/sdk/port-policy.ts +38 -0
  216. package/transport/sdk/renderer-transport.ts +1165 -0
  217. package/transport/types.ts +605 -0
  218. package/types/agent.ts +399 -0
  219. package/types/cloud-sync.ts +157 -0
  220. package/types/division-box.ts +31 -31
  221. package/types/download.ts +1 -0
  222. package/types/flow.ts +63 -12
  223. package/types/icon.ts +2 -1
  224. package/types/index.ts +5 -0
  225. package/types/intelligence.ts +166 -173
  226. package/types/modules/base.ts +2 -0
  227. package/types/path-browserify.d.ts +5 -0
  228. package/types/platform.ts +12 -0
  229. package/types/startup-info.ts +32 -0
  230. package/types/touch-app-core.ts +8 -8
  231. package/types/update.ts +94 -1
  232. package/vitest.config.ts +25 -0
  233. package/auth/useClerkConfig.ts +0 -40
  234. package/auth/useClerkProvider.ts +0 -52
@@ -0,0 +1,62 @@
1
+ import type {
2
+ NotificationActionPayload,
3
+ NotificationDismissPayload,
4
+ NotificationDismissRequest,
5
+ NotificationInboxArchiveRequest,
6
+ NotificationInboxClearRequest,
7
+ NotificationInboxClearResponse,
8
+ NotificationInboxDeleteRequest,
9
+ NotificationInboxDeleteResponse,
10
+ NotificationInboxEntry,
11
+ NotificationInboxListRequest,
12
+ NotificationInboxListResponse,
13
+ NotificationInboxMarkReadRequest,
14
+ NotificationInboxUpdatedPayload,
15
+ NotificationPushPayload,
16
+ NotificationRequest,
17
+ NotificationResult,
18
+ NotificationUpdatePayload,
19
+ NotificationUpdateRequest,
20
+ } from '../../events/types'
21
+ import type { ITuffTransport } from '../../types'
22
+ import { NotificationEvents } from '../../events'
23
+
24
+ export interface NotificationSdk {
25
+ notify: (request: NotificationRequest) => Promise<NotificationResult>
26
+ update: (request: NotificationUpdateRequest) => Promise<NotificationResult>
27
+ dismiss: (request: NotificationDismissRequest) => Promise<NotificationResult>
28
+ reportAction: (payload: NotificationActionPayload) => Promise<void>
29
+
30
+ listInbox: (request?: NotificationInboxListRequest) => Promise<NotificationInboxListResponse>
31
+ markRead: (request: NotificationInboxMarkReadRequest) => Promise<NotificationInboxEntry | null>
32
+ archive: (request: NotificationInboxArchiveRequest) => Promise<NotificationInboxEntry | null>
33
+ delete: (request: NotificationInboxDeleteRequest) => Promise<NotificationInboxDeleteResponse>
34
+ clear: (request?: NotificationInboxClearRequest) => Promise<NotificationInboxClearResponse>
35
+
36
+ onNotify: (handler: (payload: NotificationPushPayload) => void) => () => void
37
+ onUpdate: (handler: (payload: NotificationUpdatePayload) => void) => () => void
38
+ onDismiss: (handler: (payload: NotificationDismissPayload) => void) => () => void
39
+ onAction: (handler: (payload: NotificationActionPayload) => void) => () => void
40
+ onInboxUpdated: (handler: (payload: NotificationInboxUpdatedPayload) => void) => () => void
41
+ }
42
+
43
+ export function createNotificationSdk(transport: ITuffTransport): NotificationSdk {
44
+ return {
45
+ notify: request => transport.send(NotificationEvents.api.notify, request),
46
+ update: request => transport.send(NotificationEvents.api.update, request),
47
+ dismiss: request => transport.send(NotificationEvents.api.dismiss, request),
48
+ reportAction: payload => transport.send(NotificationEvents.api.action, payload),
49
+
50
+ listInbox: request => transport.send(NotificationEvents.inbox.list, request ?? {}),
51
+ markRead: request => transport.send(NotificationEvents.inbox.markRead, request),
52
+ archive: request => transport.send(NotificationEvents.inbox.archive, request),
53
+ delete: request => transport.send(NotificationEvents.inbox.delete, request),
54
+ clear: request => transport.send(NotificationEvents.inbox.clear, request ?? {}),
55
+
56
+ onNotify: handler => transport.on(NotificationEvents.push.notify, handler),
57
+ onUpdate: handler => transport.on(NotificationEvents.push.update, handler),
58
+ onDismiss: handler => transport.on(NotificationEvents.push.dismiss, handler),
59
+ onAction: handler => transport.on(NotificationEvents.push.action, handler),
60
+ onInboxUpdated: handler => transport.on(NotificationEvents.push.inboxUpdated, handler),
61
+ }
62
+ }
@@ -0,0 +1,85 @@
1
+ import type {
2
+ PermissionCheckRequest,
3
+ PermissionCheckResponse,
4
+ PermissionGetAllResponse,
5
+ PermissionGetAuditLogsRequest,
6
+ PermissionGetAuditLogsResponse,
7
+ PermissionGetPerformanceResponse,
8
+ PermissionGetPluginRequest,
9
+ PermissionGetPluginResponse,
10
+ PermissionGetRegistryResponse,
11
+ PermissionGetStatusRequest,
12
+ PermissionGetStatusResponse,
13
+ PermissionGrantMultipleRequest,
14
+ PermissionGrantRequest,
15
+ PermissionOperationResult,
16
+ PermissionRevokeAllRequest,
17
+ PermissionRevokeRequest,
18
+ PermissionStartupRequestPayload,
19
+ PermissionUpdatedPayload,
20
+ } from '../../events/types/permission'
21
+ import type { ITuffTransport } from '../../types'
22
+ import { PermissionEvents } from '../../events'
23
+
24
+ export interface PermissionSdk {
25
+ getPlugin: (payload: PermissionGetPluginRequest) => Promise<PermissionGetPluginResponse>
26
+ getStatus: (payload: PermissionGetStatusRequest) => Promise<PermissionGetStatusResponse>
27
+ grant: (payload: PermissionGrantRequest) => Promise<PermissionOperationResult>
28
+ revoke: (payload: PermissionRevokeRequest) => Promise<PermissionOperationResult>
29
+ grantMultiple: (payload: PermissionGrantMultipleRequest) => Promise<PermissionOperationResult>
30
+ grantSession: (payload: PermissionGrantMultipleRequest) => Promise<PermissionOperationResult>
31
+ revokeAll: (payload: PermissionRevokeAllRequest) => Promise<PermissionOperationResult>
32
+ check: (payload: PermissionCheckRequest) => Promise<PermissionCheckResponse>
33
+ getAll: () => Promise<PermissionGetAllResponse>
34
+ getRegistry: () => Promise<PermissionGetRegistryResponse>
35
+ getAuditLogs: (payload?: PermissionGetAuditLogsRequest) => Promise<PermissionGetAuditLogsResponse>
36
+ clearAuditLogs: () => Promise<PermissionOperationResult>
37
+ getPerformance: () => Promise<PermissionGetPerformanceResponse>
38
+ resetPerformance: () => Promise<PermissionOperationResult>
39
+ onUpdated: (handler: (payload: PermissionUpdatedPayload) => void) => () => void
40
+ onStartupRequest: (handler: (payload: PermissionStartupRequestPayload) => void) => () => void
41
+ }
42
+
43
+ export type PermissionSdkTransport = Pick<ITuffTransport, 'send' | 'on'>
44
+
45
+ export function createPermissionSdk(transport: PermissionSdkTransport): PermissionSdk {
46
+ return {
47
+ getPlugin: payload => transport.send(PermissionEvents.api.getPlugin, payload),
48
+ getStatus: payload => transport.send(PermissionEvents.api.getStatus, payload),
49
+ grant: payload => transport.send(PermissionEvents.api.grant, payload),
50
+ revoke: payload => transport.send(PermissionEvents.api.revoke, payload),
51
+ grantMultiple: payload => transport.send(PermissionEvents.api.grantMultiple, payload),
52
+ grantSession: payload => transport.send(PermissionEvents.api.grantSession, payload),
53
+ revokeAll: payload => transport.send(PermissionEvents.api.revokeAll, payload),
54
+ check: payload => transport.send(PermissionEvents.api.check, payload),
55
+ getAll: () => transport.send(PermissionEvents.api.getAll),
56
+ getRegistry: () => transport.send(PermissionEvents.api.getRegistry),
57
+ getAuditLogs: payload => transport.send(PermissionEvents.api.getAuditLogs, payload),
58
+ clearAuditLogs: () => transport.send(PermissionEvents.api.clearAuditLogs),
59
+ getPerformance: () => transport.send(PermissionEvents.api.getPerformance),
60
+ resetPerformance: () => transport.send(PermissionEvents.api.resetPerformance),
61
+ onUpdated: handler => transport.on(PermissionEvents.push.updated, handler),
62
+ onStartupRequest: handler => transport.on(PermissionEvents.push.startupRequest, handler),
63
+ }
64
+ }
65
+
66
+ export type {
67
+ PermissionCheckRequest,
68
+ PermissionCheckResponse,
69
+ PermissionGetAllResponse,
70
+ PermissionGetAuditLogsRequest,
71
+ PermissionGetAuditLogsResponse,
72
+ PermissionGetPerformanceResponse,
73
+ PermissionGetPluginRequest,
74
+ PermissionGetPluginResponse,
75
+ PermissionGetRegistryResponse,
76
+ PermissionGetStatusRequest,
77
+ PermissionGetStatusResponse,
78
+ PermissionGrantMultipleRequest,
79
+ PermissionGrantRequest,
80
+ PermissionOperationResult,
81
+ PermissionRevokeAllRequest,
82
+ PermissionRevokeRequest,
83
+ PermissionStartupRequestPayload,
84
+ PermissionUpdatedPayload,
85
+ }
@@ -0,0 +1,19 @@
1
+ import type {
2
+ PlatformCapabilityListRequest,
3
+ PlatformCapabilityListResponse,
4
+ } from '../../events/types'
5
+ import type { ITuffTransport } from '../../types'
6
+ import { PlatformEvents } from '../../events'
7
+
8
+ export interface PlatformSdk {
9
+ listCapabilities: (
10
+ payload?: PlatformCapabilityListRequest,
11
+ ) => Promise<PlatformCapabilityListResponse>
12
+ }
13
+
14
+ export function createPlatformSdk(transport: ITuffTransport): PlatformSdk {
15
+ return {
16
+ listCapabilities: payload =>
17
+ transport.send(PlatformEvents.capabilities.list, payload ?? undefined),
18
+ }
19
+ }
@@ -0,0 +1,144 @@
1
+ import type {
2
+ PluginApiFeatureInputChangedRequest,
3
+ PluginApiGetManifestRequest,
4
+ PluginApiGetManifestResponse,
5
+ PluginApiGetOfficialListRequest,
6
+ PluginApiGetOfficialListResponse,
7
+ PluginApiGetPathsRequest,
8
+ PluginApiGetPathsResponse,
9
+ PluginApiGetPerformanceRequest,
10
+ PluginApiGetPerformanceResponse,
11
+ PluginApiGetRequest,
12
+ PluginApiGetResponse,
13
+ PluginApiGetRuntimeStatsRequest,
14
+ PluginApiGetRuntimeStatsResponse,
15
+ PluginApiGetStatusRequest,
16
+ PluginApiGetStatusResponse,
17
+ PluginApiInstallRequest,
18
+ PluginApiInstallResponse,
19
+ PluginApiListRequest,
20
+ PluginApiListResponse,
21
+ PluginApiOpenFolderRequest,
22
+ PluginApiOpenPathRequest,
23
+ PluginApiOpenPathResponse,
24
+ PluginApiRevealPathRequest,
25
+ PluginApiRevealPathResponse,
26
+ PluginApiRegisterWidgetRequest,
27
+ PluginApiRegisterWidgetResponse,
28
+ PluginApiOperationRequest,
29
+ PluginApiOperationResponse,
30
+ PluginApiSaveManifestRequest,
31
+ PluginApiSaveManifestResponse,
32
+ PluginApiSaveWidgetFileRequest,
33
+ PluginApiSaveWidgetFileResponse,
34
+ PluginApiTriggerFeatureRequest,
35
+ PluginDevServerStatusRequest,
36
+ PluginDevServerStatusResponse,
37
+ PluginInstallConfirmPayload,
38
+ PluginInstallConfirmResponsePayload,
39
+ PluginInstallProgressPayload,
40
+ PluginInstallSourceRequest,
41
+ PluginInstallSourceResponse,
42
+ PluginPushStateChangedPayload,
43
+ PluginPushStatusUpdatedPayload,
44
+ PluginReconnectDevServerRequest,
45
+ PluginReconnectDevServerResponse,
46
+ } from '../../events/types'
47
+ import type { ITuffTransport } from '../../types'
48
+ import { PluginEvents } from '../../events'
49
+
50
+ export interface PluginSdk {
51
+ list: (request?: PluginApiListRequest) => Promise<PluginApiListResponse>
52
+ get: (request: PluginApiGetRequest) => Promise<PluginApiGetResponse>
53
+ getStatus: (request: PluginApiGetStatusRequest) => Promise<PluginApiGetStatusResponse>
54
+
55
+ enable: (request: PluginApiOperationRequest) => Promise<PluginApiOperationResponse>
56
+ disable: (request: PluginApiOperationRequest) => Promise<PluginApiOperationResponse>
57
+ reload: (request: PluginApiOperationRequest) => Promise<PluginApiOperationResponse>
58
+ install: (request: PluginApiInstallRequest) => Promise<PluginApiInstallResponse>
59
+ uninstall: (request: PluginApiOperationRequest) => Promise<PluginApiOperationResponse>
60
+
61
+ triggerFeature: (request: PluginApiTriggerFeatureRequest) => Promise<unknown>
62
+ registerWidget: (request: PluginApiRegisterWidgetRequest) => Promise<PluginApiRegisterWidgetResponse>
63
+ featureInputChanged: (request: PluginApiFeatureInputChangedRequest) => Promise<void>
64
+
65
+ openFolder: (request: PluginApiOpenFolderRequest) => Promise<void>
66
+
67
+ getOfficialList: (request?: PluginApiGetOfficialListRequest) => Promise<PluginApiGetOfficialListResponse>
68
+ getManifest: (request: PluginApiGetManifestRequest) => Promise<PluginApiGetManifestResponse>
69
+ saveManifest: (request: PluginApiSaveManifestRequest) => Promise<PluginApiSaveManifestResponse>
70
+ saveWidgetFile: (request: PluginApiSaveWidgetFileRequest) => Promise<PluginApiSaveWidgetFileResponse>
71
+ getPaths: (request: PluginApiGetPathsRequest) => Promise<PluginApiGetPathsResponse>
72
+ openPath: (request: PluginApiOpenPathRequest) => Promise<PluginApiOpenPathResponse>
73
+ revealPath: (request: PluginApiRevealPathRequest) => Promise<PluginApiRevealPathResponse>
74
+ getPerformance: (request: PluginApiGetPerformanceRequest) => Promise<PluginApiGetPerformanceResponse>
75
+ getRuntimeStats: (request: PluginApiGetRuntimeStatsRequest) => Promise<PluginApiGetRuntimeStatsResponse>
76
+
77
+ reconnectDevServer: (request: PluginReconnectDevServerRequest) => Promise<PluginReconnectDevServerResponse>
78
+ getDevServerStatus: (request: PluginDevServerStatusRequest) => Promise<PluginDevServerStatusResponse>
79
+
80
+ onStateChanged: (handler: (payload: PluginPushStateChangedPayload) => void) => () => void
81
+ onStatusUpdated: (handler: (payload: PluginPushStatusUpdatedPayload) => void) => () => void
82
+
83
+ onInstallProgress: (handler: (payload: PluginInstallProgressPayload) => void) => () => void
84
+ onInstallConfirm: (handler: (payload: PluginInstallConfirmPayload) => void) => () => void
85
+ sendInstallConfirmResponse: (payload: PluginInstallConfirmResponsePayload) => Promise<void>
86
+
87
+ installFromSource: (payload: PluginInstallSourceRequest) => Promise<PluginInstallSourceResponse>
88
+ }
89
+
90
+ export function createPluginSdk(transport: ITuffTransport): PluginSdk {
91
+ return {
92
+ list: async request => transport.send(PluginEvents.api.list, request ?? {}),
93
+ get: async request => transport.send(PluginEvents.api.get, request),
94
+ getStatus: async request => transport.send(PluginEvents.api.getStatus, request),
95
+
96
+ enable: async request => transport.send(PluginEvents.api.enable, request),
97
+ disable: async request => transport.send(PluginEvents.api.disable, request),
98
+ reload: async request => transport.send(PluginEvents.api.reload, request),
99
+ install: async request => transport.send(PluginEvents.api.install, request),
100
+ uninstall: async request => transport.send(PluginEvents.api.uninstall, request),
101
+
102
+ triggerFeature: async request => transport.send(PluginEvents.api.triggerFeature, request),
103
+ registerWidget: async request => transport.send(PluginEvents.api.registerWidget, request),
104
+ featureInputChanged: async request => transport.send(PluginEvents.api.featureInputChanged, request),
105
+
106
+ openFolder: async request => transport.send(PluginEvents.api.openFolder, request),
107
+
108
+ getOfficialList: async request => transport.send(PluginEvents.api.getOfficialList, request ?? {}),
109
+ getManifest: async request => transport.send(PluginEvents.api.getManifest, request),
110
+ saveManifest: async request => transport.send(PluginEvents.api.saveManifest, request),
111
+ saveWidgetFile: async request => transport.send(PluginEvents.api.saveWidgetFile, request),
112
+ getPaths: async request => transport.send(PluginEvents.api.getPaths, request),
113
+ openPath: async request => transport.send(PluginEvents.api.openPath, request),
114
+ revealPath: async request => transport.send(PluginEvents.api.revealPath, request),
115
+ getPerformance: async request => transport.send(PluginEvents.api.getPerformance, request),
116
+ getRuntimeStats: async request => transport.send(PluginEvents.api.getRuntimeStats, request),
117
+
118
+ reconnectDevServer: async request => transport.send(PluginEvents.devServer.reconnect, request),
119
+ getDevServerStatus: async request => transport.send(PluginEvents.devServer.status, request),
120
+
121
+ onStateChanged: handler =>
122
+ transport.on(PluginEvents.push.stateChanged, (payload) => {
123
+ handler(payload)
124
+ }),
125
+ onStatusUpdated: handler =>
126
+ transport.on(PluginEvents.push.statusUpdated, (payload) => {
127
+ handler(payload)
128
+ }),
129
+
130
+ onInstallProgress: handler =>
131
+ transport.on(PluginEvents.install.progress, (payload) => {
132
+ handler(payload)
133
+ }),
134
+ onInstallConfirm: handler =>
135
+ transport.on(PluginEvents.install.confirm, (payload) => {
136
+ handler(payload)
137
+ }),
138
+ sendInstallConfirmResponse: async (payload) => {
139
+ await transport.send(PluginEvents.install.confirmResponse, payload)
140
+ },
141
+
142
+ installFromSource: async payload => transport.send(PluginEvents.install.source, payload),
143
+ }
144
+ }
@@ -0,0 +1,102 @@
1
+ import type {
2
+ AnalyticsExportPayload,
3
+ AnalyticsExportResult,
4
+ AnalyticsMessage,
5
+ AnalyticsMessageListRequest,
6
+ AnalyticsMessageUpdateRequest,
7
+ AnalyticsRangeRequest,
8
+ AnalyticsSnapshot,
9
+ AnalyticsWindowType,
10
+ } from '../../../analytics'
11
+ import type {
12
+ AppIndexAddPathRequest,
13
+ AppIndexAddPathResult,
14
+ AppIndexSettings,
15
+ } from '../../events/types/app-index'
16
+ import type { AnalyticsToggleRequest, CurrentMetrics, PerformanceHistoryEntry, PerformanceSummary } from '../../events/types/app'
17
+ import type { DeviceIdleSettings } from '../../events/types/device-idle'
18
+ import type {
19
+ FileIndexAddPathRequest,
20
+ FileIndexAddPathResult,
21
+ FileIndexBatteryStatus,
22
+ FileIndexFailedFile,
23
+ FileIndexProgress,
24
+ FileIndexRebuildRequest,
25
+ FileIndexRebuildResult,
26
+ FileIndexStats,
27
+ FileIndexStatus,
28
+ } from '../../events/types/file-index'
29
+ import type { ITuffTransport, StreamController, StreamOptions } from '../../types'
30
+ import { AppEvents } from '../../events'
31
+
32
+ export interface SettingsSdk {
33
+ fileIndex: {
34
+ getStatus: () => Promise<FileIndexStatus>
35
+ getStats: () => Promise<FileIndexStats>
36
+ getBatteryLevel: () => Promise<FileIndexBatteryStatus | null>
37
+ rebuild: (request?: FileIndexRebuildRequest) => Promise<FileIndexRebuildResult>
38
+ streamProgress: (
39
+ options: StreamOptions<FileIndexProgress>,
40
+ ) => Promise<StreamController>
41
+ getFailedFiles: () => Promise<FileIndexFailedFile[]>
42
+ addPath: (payload: FileIndexAddPathRequest) => Promise<FileIndexAddPathResult>
43
+ }
44
+ deviceIdle: {
45
+ getSettings: () => Promise<DeviceIdleSettings>
46
+ updateSettings: (settings: Partial<DeviceIdleSettings>) => Promise<DeviceIdleSettings>
47
+ }
48
+ appIndex: {
49
+ getSettings: () => Promise<AppIndexSettings>
50
+ updateSettings: (settings: Partial<AppIndexSettings>) => Promise<AppIndexSettings>
51
+ addPath: (payload: AppIndexAddPathRequest) => Promise<AppIndexAddPathResult>
52
+ }
53
+ analytics: {
54
+ getSnapshot: (windowType: AnalyticsWindowType) => Promise<AnalyticsSnapshot>
55
+ getRange: (payload: AnalyticsRangeRequest) => Promise<AnalyticsSnapshot[]>
56
+ export: (payload: AnalyticsExportPayload) => Promise<AnalyticsExportResult>
57
+ toggleReporting: (payload: AnalyticsToggleRequest) => Promise<{ enabled: boolean }>
58
+ getCurrent: () => Promise<CurrentMetrics>
59
+ getHistory: () => Promise<PerformanceHistoryEntry[]>
60
+ getSummary: () => Promise<PerformanceSummary>
61
+ messages: {
62
+ list: (payload?: AnalyticsMessageListRequest) => Promise<AnalyticsMessage[]>
63
+ mark: (payload: AnalyticsMessageUpdateRequest) => Promise<AnalyticsMessage | null>
64
+ }
65
+ }
66
+ }
67
+
68
+ export function createSettingsSdk(transport: ITuffTransport): SettingsSdk {
69
+ return {
70
+ fileIndex: {
71
+ getStatus: () => transport.send(AppEvents.fileIndex.status),
72
+ getStats: () => transport.send(AppEvents.fileIndex.stats),
73
+ getBatteryLevel: () => transport.send(AppEvents.fileIndex.batteryLevel),
74
+ rebuild: request => transport.send(AppEvents.fileIndex.rebuild, request),
75
+ streamProgress: options => transport.stream(AppEvents.fileIndex.progress, undefined, options),
76
+ getFailedFiles: () => transport.send(AppEvents.fileIndex.failedFiles),
77
+ addPath: payload => transport.send(AppEvents.fileIndex.addPath, payload),
78
+ },
79
+ deviceIdle: {
80
+ getSettings: () => transport.send(AppEvents.deviceIdle.getSettings),
81
+ updateSettings: settings => transport.send(AppEvents.deviceIdle.updateSettings, settings),
82
+ },
83
+ appIndex: {
84
+ getSettings: () => transport.send(AppEvents.appIndex.getSettings),
85
+ updateSettings: settings => transport.send(AppEvents.appIndex.updateSettings, settings),
86
+ addPath: payload => transport.send(AppEvents.appIndex.addPath, payload),
87
+ },
88
+ analytics: {
89
+ getSnapshot: windowType => transport.send(AppEvents.analytics.getSnapshot, { windowType }),
90
+ getRange: payload => transport.send(AppEvents.analytics.getRange, payload),
91
+ export: payload => transport.send(AppEvents.analytics.export, payload),
92
+ toggleReporting: payload => transport.send(AppEvents.analytics.toggleReporting, payload),
93
+ getCurrent: () => transport.send(AppEvents.analytics.getCurrent),
94
+ getHistory: () => transport.send(AppEvents.analytics.getHistory),
95
+ getSummary: () => transport.send(AppEvents.analytics.getSummary),
96
+ messages: {
97
+ list: payload => transport.send(AppEvents.analytics.messages.list, payload ?? {}),
98
+ mark: payload => transport.send(AppEvents.analytics.messages.mark, payload),
99
+ },
100
+ },
101
+ }
102
+ }
@@ -0,0 +1,64 @@
1
+ import type { AppPreviewChannel, CachedUpdateRecord, GitHubRelease, UpdateCheckResult, UpdateSettings, UpdateUserAction } from '../../../types/update'
2
+ import type {
3
+ UpdateAvailablePayload,
4
+ UpdateCheckResponse,
5
+ UpdateGetCachedReleaseResponse,
6
+ UpdateGetSettingsResponse,
7
+ UpdateGetStatusResponse,
8
+ UpdateIgnoreVersionRequest,
9
+ UpdateInstallRequest,
10
+ UpdateOpResponse,
11
+ } from '../../events/types/update'
12
+ import type { ITuffTransport } from '../../types'
13
+ import { UpdateEvents } from '../../events'
14
+
15
+ export interface UpdateSdk {
16
+ check: (payload?: { force?: boolean }) => Promise<UpdateCheckResponse>
17
+ getSettings: () => Promise<UpdateGetSettingsResponse>
18
+ updateSettings: (settings: Partial<UpdateSettings>) => Promise<UpdateOpResponse>
19
+ getStatus: () => Promise<UpdateGetStatusResponse>
20
+ clearCache: () => Promise<UpdateOpResponse>
21
+ getCachedRelease: (payload?: { channel?: AppPreviewChannel }) => Promise<UpdateGetCachedReleaseResponse>
22
+ recordAction: (payload: { tag: string, action: UpdateUserAction }) => Promise<UpdateOpResponse>
23
+ download: (release: GitHubRelease) => Promise<UpdateOpResponse<{ taskId?: string }>>
24
+ install: (payload: UpdateInstallRequest) => Promise<UpdateOpResponse>
25
+ ignoreVersion: (payload: UpdateIgnoreVersionRequest) => Promise<UpdateOpResponse>
26
+ setAutoDownload: (enabled: boolean) => Promise<UpdateOpResponse>
27
+ setAutoCheck: (enabled: boolean) => Promise<UpdateOpResponse>
28
+ onAvailable: (handler: (payload: UpdateAvailablePayload) => void) => () => void
29
+ }
30
+
31
+ export function createUpdateSdk(transport: ITuffTransport): UpdateSdk {
32
+ return {
33
+ check: payload => transport.send(UpdateEvents.check, payload ?? {}),
34
+ getSettings: () => transport.send(UpdateEvents.getSettings),
35
+ updateSettings: settings => transport.send(UpdateEvents.updateSettings, { settings }),
36
+ getStatus: () => transport.send(UpdateEvents.getStatus),
37
+ clearCache: () => transport.send(UpdateEvents.clearCache),
38
+ getCachedRelease: payload => transport.send(UpdateEvents.getCachedRelease, payload ?? {}),
39
+ recordAction: payload => transport.send(UpdateEvents.recordAction, payload),
40
+ download: release => transport.send(UpdateEvents.download, release),
41
+ install: payload => transport.send(UpdateEvents.install, payload),
42
+ ignoreVersion: payload => transport.send(UpdateEvents.ignoreVersion, payload),
43
+ setAutoDownload: enabled => transport.send(UpdateEvents.setAutoDownload, { enabled }),
44
+ setAutoCheck: enabled => transport.send(UpdateEvents.setAutoCheck, { enabled }),
45
+ onAvailable: handler => transport.on(UpdateEvents.available, handler),
46
+ }
47
+ }
48
+
49
+ export type {
50
+ UpdateAvailablePayload,
51
+ UpdateCheckResponse,
52
+ UpdateGetCachedReleaseResponse,
53
+ UpdateGetSettingsResponse,
54
+ UpdateGetStatusResponse,
55
+ UpdateOpResponse,
56
+ }
57
+
58
+ export type {
59
+ AppPreviewChannel,
60
+ CachedUpdateRecord,
61
+ UpdateCheckResult,
62
+ UpdateSettings,
63
+ UpdateUserAction,
64
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @fileoverview TuffTransport SDK entry point
3
+ * @module @talex-touch/utils/transport/sdk
4
+ */
5
+
6
+ import type { ITuffTransport } from '../types'
7
+ import { createPluginTuffTransport } from './plugin-transport'
8
+ import { TuffRendererTransport } from './renderer-transport'
9
+
10
+ export * from './domains'
11
+
12
+ // Singleton instance for renderer transport
13
+ let rendererTransportInstance: ITuffTransport | null = null
14
+
15
+ /**
16
+ * Gets or creates the singleton TuffTransport instance for renderer processes.
17
+ *
18
+ * @returns The TuffTransport instance
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { useTuffTransport } from '@talex-touch/utils/transport'
23
+ * import { ClipboardEvents } from '@talex-touch/utils/transport/events'
24
+ *
25
+ * const transport = useTuffTransport()
26
+ * const latest = await transport.send(ClipboardEvents.getLatest)
27
+ * ```
28
+ */
29
+ export function useTuffTransport(): ITuffTransport {
30
+ if (!rendererTransportInstance) {
31
+ rendererTransportInstance = new TuffRendererTransport()
32
+ }
33
+ return rendererTransportInstance
34
+ }
35
+
36
+ /**
37
+ * Creates a new TuffTransport instance for renderer processes.
38
+ *
39
+ * @param module - Optional module name for namespacing (currently unused, reserved for future use)
40
+ * @returns A new TuffTransport instance
41
+ *
42
+ * @remarks
43
+ * In most cases, you should use `useTuffTransport()` instead to get the singleton instance.
44
+ * This function is useful when you need multiple isolated transport instances.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * import { createTuffRendererTransport } from '@talex-touch/utils/transport'
49
+ *
50
+ * const transport = createTuffRendererTransport('clipboard')
51
+ * ```
52
+ */
53
+ export function createTuffRendererTransport(module?: string): ITuffTransport {
54
+ // Module parameter is reserved for future namespacing
55
+ void module
56
+ // For now, we create a new instance
57
+ return new TuffRendererTransport()
58
+ }
59
+
60
+ export { createPluginTuffTransport }