@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,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Constants for TuffTransport SDK
|
|
3
|
+
* @module @talex-touch/utils/transport/sdk/constants
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Default timeout for transport requests (ms)
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_TIMEOUT = 10_000
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Stream message types
|
|
13
|
+
*/
|
|
14
|
+
export const STREAM_MESSAGE_TYPES = {
|
|
15
|
+
DATA: 'data',
|
|
16
|
+
ERROR: 'error',
|
|
17
|
+
END: 'end',
|
|
18
|
+
} as const
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Stream event name suffixes
|
|
22
|
+
*/
|
|
23
|
+
export const STREAM_SUFFIXES = {
|
|
24
|
+
START: ':stream:start',
|
|
25
|
+
DATA: ':stream:data',
|
|
26
|
+
END: ':stream:end',
|
|
27
|
+
ERROR: ':stream:error',
|
|
28
|
+
CANCEL: ':stream:cancel',
|
|
29
|
+
} as const
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AgentsMarketCategoriesResponse,
|
|
3
|
+
AgentsMarketInfo,
|
|
4
|
+
AgentsMarketInstallResponse,
|
|
5
|
+
AgentsMarketSearchRequest,
|
|
6
|
+
AgentsMarketSearchResponse,
|
|
7
|
+
} from '../../events/types'
|
|
8
|
+
import type { ITuffTransport } from '../../types'
|
|
9
|
+
import { AgentsEvents } from '../../events'
|
|
10
|
+
|
|
11
|
+
export type MarketAgentInfo = AgentsMarketInfo
|
|
12
|
+
export type AgentSearchOptions = AgentsMarketSearchRequest
|
|
13
|
+
export type AgentSearchResult = AgentsMarketSearchResponse
|
|
14
|
+
export type AgentInstallResult = AgentsMarketInstallResponse
|
|
15
|
+
export type AgentCategory = AgentsMarketCategoriesResponse[number]
|
|
16
|
+
|
|
17
|
+
export interface AgentMarketSdk {
|
|
18
|
+
searchAgents: (options?: AgentSearchOptions) => Promise<AgentSearchResult>
|
|
19
|
+
getAgentDetails: (agentId: string) => Promise<MarketAgentInfo | null>
|
|
20
|
+
getFeaturedAgents: () => Promise<MarketAgentInfo[]>
|
|
21
|
+
getInstalledAgents: () => Promise<MarketAgentInfo[]>
|
|
22
|
+
getCategories: () => Promise<AgentCategory[]>
|
|
23
|
+
installAgent: (agentId: string, version?: string) => Promise<AgentInstallResult>
|
|
24
|
+
uninstallAgent: (agentId: string) => Promise<AgentInstallResult>
|
|
25
|
+
checkUpdates: () => Promise<MarketAgentInfo[]>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function createAgentMarketSdk(transport: ITuffTransport): AgentMarketSdk {
|
|
29
|
+
return {
|
|
30
|
+
searchAgents: options => transport.send(AgentsEvents.market.search, options),
|
|
31
|
+
|
|
32
|
+
getAgentDetails: agentId => transport.send(AgentsEvents.market.get, { agentId }),
|
|
33
|
+
|
|
34
|
+
getFeaturedAgents: () => transport.send(AgentsEvents.market.featured),
|
|
35
|
+
|
|
36
|
+
getInstalledAgents: () => transport.send(AgentsEvents.market.installed),
|
|
37
|
+
|
|
38
|
+
getCategories: () => transport.send(AgentsEvents.market.categories),
|
|
39
|
+
|
|
40
|
+
installAgent: (agentId, version) =>
|
|
41
|
+
transport.send(AgentsEvents.market.install, { agentId, version }),
|
|
42
|
+
|
|
43
|
+
uninstallAgent: agentId => transport.send(AgentsEvents.market.uninstall, { agentId }),
|
|
44
|
+
|
|
45
|
+
checkUpdates: () => transport.send(AgentsEvents.market.checkUpdates),
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AgentsCancelResponse,
|
|
3
|
+
AgentsExecuteImmediateRequest,
|
|
4
|
+
AgentsExecuteImmediateResponse,
|
|
5
|
+
AgentsExecuteRequest,
|
|
6
|
+
AgentsExecuteResponse,
|
|
7
|
+
AgentsGetResponse,
|
|
8
|
+
AgentsListResponse,
|
|
9
|
+
AgentsStatsResponse,
|
|
10
|
+
AgentsTaskCancelledPayload,
|
|
11
|
+
AgentsTaskCompletedPayload,
|
|
12
|
+
AgentsTaskFailedPayload,
|
|
13
|
+
AgentsTaskProgressPayload,
|
|
14
|
+
AgentsTaskStartedPayload,
|
|
15
|
+
AgentsTaskStatusResponse,
|
|
16
|
+
AgentsToolsGetResponse,
|
|
17
|
+
AgentsToolsListResponse,
|
|
18
|
+
AgentsUpdatePriorityResponse,
|
|
19
|
+
} from '../../events/types'
|
|
20
|
+
import type { ITuffTransport } from '../../types'
|
|
21
|
+
import { AgentsEvents } from '../../events'
|
|
22
|
+
|
|
23
|
+
export interface AgentsSdk {
|
|
24
|
+
list: () => Promise<AgentsListResponse>
|
|
25
|
+
listAll: () => Promise<AgentsListResponse>
|
|
26
|
+
get: (id: string) => Promise<AgentsGetResponse>
|
|
27
|
+
execute: (task: AgentsExecuteRequest) => Promise<AgentsExecuteResponse>
|
|
28
|
+
executeImmediate: (task: AgentsExecuteImmediateRequest) => Promise<AgentsExecuteImmediateResponse>
|
|
29
|
+
cancel: (taskId: string) => Promise<AgentsCancelResponse>
|
|
30
|
+
getTaskStatus: (taskId: string) => Promise<AgentsTaskStatusResponse>
|
|
31
|
+
updatePriority: (taskId: string, priority: number) => Promise<AgentsUpdatePriorityResponse>
|
|
32
|
+
getStats: () => Promise<AgentsStatsResponse>
|
|
33
|
+
listTools: () => Promise<AgentsToolsListResponse>
|
|
34
|
+
getTool: (toolId: string) => Promise<AgentsToolsGetResponse>
|
|
35
|
+
onTaskStarted: (handler: (payload: AgentsTaskStartedPayload) => void) => () => void
|
|
36
|
+
onTaskProgress: (handler: (payload: AgentsTaskProgressPayload) => void) => () => void
|
|
37
|
+
onTaskCompleted: (handler: (payload: AgentsTaskCompletedPayload) => void) => () => void
|
|
38
|
+
onTaskFailed: (handler: (payload: AgentsTaskFailedPayload) => void) => () => void
|
|
39
|
+
onTaskCancelled: (handler: (payload: AgentsTaskCancelledPayload) => void) => () => void
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function createAgentsSdk(transport: ITuffTransport): AgentsSdk {
|
|
43
|
+
return {
|
|
44
|
+
list: () => transport.send(AgentsEvents.api.list),
|
|
45
|
+
listAll: () => transport.send(AgentsEvents.api.listAll),
|
|
46
|
+
get: id => transport.send(AgentsEvents.api.get, { id }),
|
|
47
|
+
execute: task => transport.send(AgentsEvents.api.execute, task),
|
|
48
|
+
executeImmediate: task => transport.send(AgentsEvents.api.executeImmediate, task),
|
|
49
|
+
cancel: taskId => transport.send(AgentsEvents.api.cancel, { taskId }),
|
|
50
|
+
getTaskStatus: taskId => transport.send(AgentsEvents.api.taskStatus, { taskId }),
|
|
51
|
+
updatePriority: (taskId, priority) =>
|
|
52
|
+
transport.send(AgentsEvents.api.updatePriority, { taskId, priority }),
|
|
53
|
+
getStats: () => transport.send(AgentsEvents.api.stats),
|
|
54
|
+
listTools: () => transport.send(AgentsEvents.api.tools.list),
|
|
55
|
+
getTool: toolId => transport.send(AgentsEvents.api.tools.get, { toolId }),
|
|
56
|
+
onTaskStarted: handler => transport.on(AgentsEvents.push.taskStarted, handler),
|
|
57
|
+
onTaskProgress: handler => transport.on(AgentsEvents.push.taskProgress, handler),
|
|
58
|
+
onTaskCompleted: handler => transport.on(AgentsEvents.push.taskCompleted, handler),
|
|
59
|
+
onTaskFailed: handler => transport.on(AgentsEvents.push.taskFailed, handler),
|
|
60
|
+
onTaskCancelled: handler => transport.on(AgentsEvents.push.taskCancelled, handler),
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ITuffTransport } from '../../types'
|
|
2
|
+
import { AppEvents } from '../../events'
|
|
3
|
+
|
|
4
|
+
export interface AppSdk {
|
|
5
|
+
close: () => Promise<void>
|
|
6
|
+
hide: () => Promise<void>
|
|
7
|
+
minimize: () => Promise<void>
|
|
8
|
+
focus: () => Promise<void>
|
|
9
|
+
openDevTools: (options?: Parameters<ITuffTransport['send']>[1]) => Promise<void>
|
|
10
|
+
|
|
11
|
+
getCwd: () => Promise<string>
|
|
12
|
+
getOS: () => Promise<unknown>
|
|
13
|
+
getPackage: () => Promise<unknown>
|
|
14
|
+
getPath: (name: string) => Promise<string | null>
|
|
15
|
+
getSecureValue: (key: string) => Promise<string | null>
|
|
16
|
+
setSecureValue: (key: string, value: string | null) => Promise<void>
|
|
17
|
+
|
|
18
|
+
openExternal: (url: string) => Promise<void>
|
|
19
|
+
showInFolder: (path: string) => Promise<void>
|
|
20
|
+
openApp: (options: { appName?: string, path?: string }) => Promise<void>
|
|
21
|
+
openPromptsFolder: () => Promise<void>
|
|
22
|
+
executeCommand: (options: { command: string }) => Promise<unknown>
|
|
23
|
+
readFile: (path: string) => Promise<string>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function createAppSdk(transport: ITuffTransport): AppSdk {
|
|
27
|
+
return {
|
|
28
|
+
close: () => transport.send(AppEvents.window.close),
|
|
29
|
+
hide: () => transport.send(AppEvents.window.hide),
|
|
30
|
+
minimize: () => transport.send(AppEvents.window.minimize),
|
|
31
|
+
focus: () => transport.send(AppEvents.window.focus),
|
|
32
|
+
openDevTools: options => transport.send(AppEvents.debug.openDevTools, options as any),
|
|
33
|
+
|
|
34
|
+
getCwd: () => transport.send(AppEvents.system.getCwd),
|
|
35
|
+
getOS: () => transport.send(AppEvents.system.getOS),
|
|
36
|
+
getPackage: () => transport.send(AppEvents.system.getPackage),
|
|
37
|
+
getPath: name => transport.send(AppEvents.system.getPath, { name }),
|
|
38
|
+
getSecureValue: key => transport.send(AppEvents.system.getSecureValue, { key }),
|
|
39
|
+
setSecureValue: (key, value) => transport.send(AppEvents.system.setSecureValue, { key, value }),
|
|
40
|
+
|
|
41
|
+
openExternal: url => transport.send(AppEvents.system.openExternal, { url }),
|
|
42
|
+
showInFolder: path => transport.send(AppEvents.system.showInFolder, { path }),
|
|
43
|
+
openApp: options => transport.send(AppEvents.system.openApp, options),
|
|
44
|
+
openPromptsFolder: () => transport.send(AppEvents.system.openPromptsFolder),
|
|
45
|
+
executeCommand: options => transport.send(AppEvents.system.executeCommand, options as any),
|
|
46
|
+
readFile: path => transport.send(AppEvents.system.readFile, { source: path }),
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type Disposer = () => void
|
|
2
|
+
|
|
3
|
+
export interface DisposableBag {
|
|
4
|
+
add: (...disposers: Array<Disposer | null | undefined | false>) => void
|
|
5
|
+
dispose: () => void
|
|
6
|
+
readonly size: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function createDisposableBag(): DisposableBag {
|
|
10
|
+
const disposers = new Set<Disposer>()
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
add: (...items) => {
|
|
14
|
+
for (const item of items) {
|
|
15
|
+
if (typeof item === 'function') {
|
|
16
|
+
disposers.add(item)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
dispose: () => {
|
|
21
|
+
for (const disposer of disposers) {
|
|
22
|
+
try {
|
|
23
|
+
disposer()
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// ignore disposer errors
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
disposers.clear()
|
|
30
|
+
},
|
|
31
|
+
get size() {
|
|
32
|
+
return disposers.size
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DownloadAddTaskRequest,
|
|
3
|
+
DownloadAddTaskResponse,
|
|
4
|
+
DownloadClearHistoryItemRequest,
|
|
5
|
+
DownloadGetConfigResponse,
|
|
6
|
+
DownloadGetErrorStatsResponse,
|
|
7
|
+
DownloadGetHistoryRequest,
|
|
8
|
+
DownloadGetHistoryResponse,
|
|
9
|
+
DownloadGetLogsResponse,
|
|
10
|
+
DownloadGetNotificationConfigResponse,
|
|
11
|
+
DownloadGetStatsResponse,
|
|
12
|
+
DownloadGetTasksByStatusRequest,
|
|
13
|
+
DownloadGetTasksResponse,
|
|
14
|
+
DownloadGetTaskStatusResponse,
|
|
15
|
+
DownloadGetTempStatsResponse,
|
|
16
|
+
DownloadMigrationNeededResponse,
|
|
17
|
+
DownloadMigrationRetryResponse,
|
|
18
|
+
DownloadMigrationStartResponse,
|
|
19
|
+
DownloadMigrationStatusResponse,
|
|
20
|
+
DownloadNotificationClickedPayload,
|
|
21
|
+
DownloadOpResponse,
|
|
22
|
+
DownloadTaskIdRequest,
|
|
23
|
+
DownloadTaskPayload,
|
|
24
|
+
DownloadTaskRetryingPayload,
|
|
25
|
+
DownloadUpdateConfigRequest,
|
|
26
|
+
DownloadUpdateNotificationConfigRequest,
|
|
27
|
+
DownloadUpdatePriorityRequest,
|
|
28
|
+
} from '../../events/types'
|
|
29
|
+
import type { ITuffTransport } from '../../types'
|
|
30
|
+
import { DownloadEvents } from '../../events'
|
|
31
|
+
|
|
32
|
+
export interface DownloadSdk {
|
|
33
|
+
addTask: (request: DownloadAddTaskRequest) => Promise<DownloadAddTaskResponse>
|
|
34
|
+
pauseTask: (payload: DownloadTaskIdRequest) => Promise<DownloadOpResponse>
|
|
35
|
+
resumeTask: (payload: DownloadTaskIdRequest) => Promise<DownloadOpResponse>
|
|
36
|
+
cancelTask: (payload: DownloadTaskIdRequest) => Promise<DownloadOpResponse>
|
|
37
|
+
retryTask: (payload: DownloadTaskIdRequest) => Promise<DownloadOpResponse>
|
|
38
|
+
removeTask: (payload: DownloadTaskIdRequest) => Promise<DownloadOpResponse>
|
|
39
|
+
updatePriority: (payload: DownloadUpdatePriorityRequest) => Promise<DownloadOpResponse>
|
|
40
|
+
pauseAll: () => Promise<DownloadOpResponse>
|
|
41
|
+
resumeAll: () => Promise<DownloadOpResponse>
|
|
42
|
+
cancelAll: () => Promise<DownloadOpResponse>
|
|
43
|
+
|
|
44
|
+
getAllTasks: () => Promise<DownloadGetTasksResponse>
|
|
45
|
+
getTasksByStatus: (payload: DownloadGetTasksByStatusRequest) => Promise<DownloadGetTasksResponse>
|
|
46
|
+
getTaskStatus: (payload: DownloadTaskIdRequest) => Promise<DownloadGetTaskStatusResponse>
|
|
47
|
+
|
|
48
|
+
getConfig: () => Promise<DownloadGetConfigResponse>
|
|
49
|
+
updateConfig: (payload: DownloadUpdateConfigRequest) => Promise<DownloadOpResponse>
|
|
50
|
+
getNotificationConfig: () => Promise<DownloadGetNotificationConfigResponse>
|
|
51
|
+
updateNotificationConfig: (
|
|
52
|
+
payload: DownloadUpdateNotificationConfigRequest,
|
|
53
|
+
) => Promise<DownloadOpResponse>
|
|
54
|
+
|
|
55
|
+
getHistory: (payload?: DownloadGetHistoryRequest) => Promise<DownloadGetHistoryResponse>
|
|
56
|
+
clearHistory: () => Promise<DownloadOpResponse>
|
|
57
|
+
clearHistoryItem: (payload: DownloadClearHistoryItemRequest) => Promise<DownloadOpResponse>
|
|
58
|
+
|
|
59
|
+
openFile: (payload: DownloadTaskIdRequest) => Promise<DownloadOpResponse>
|
|
60
|
+
showInFolder: (payload: DownloadTaskIdRequest) => Promise<DownloadOpResponse>
|
|
61
|
+
deleteFile: (payload: DownloadTaskIdRequest) => Promise<DownloadOpResponse>
|
|
62
|
+
|
|
63
|
+
cleanupTemp: () => Promise<DownloadOpResponse>
|
|
64
|
+
getTempStats: () => Promise<DownloadGetTempStatsResponse>
|
|
65
|
+
|
|
66
|
+
getLogs: (payload?: { limit?: number }) => Promise<DownloadGetLogsResponse>
|
|
67
|
+
getErrorStats: () => Promise<DownloadGetErrorStatsResponse>
|
|
68
|
+
clearLogs: () => Promise<DownloadOpResponse>
|
|
69
|
+
|
|
70
|
+
getStats: () => Promise<DownloadGetStatsResponse>
|
|
71
|
+
|
|
72
|
+
checkMigrationNeeded: () => Promise<DownloadMigrationNeededResponse>
|
|
73
|
+
startMigration: () => Promise<DownloadMigrationStartResponse>
|
|
74
|
+
retryMigration: () => Promise<DownloadMigrationRetryResponse>
|
|
75
|
+
getMigrationStatus: () => Promise<DownloadMigrationStatusResponse>
|
|
76
|
+
|
|
77
|
+
onTaskAdded: (handler: (task: DownloadTaskPayload) => void) => () => void
|
|
78
|
+
onTaskProgress: (handler: (task: DownloadTaskPayload) => void) => () => void
|
|
79
|
+
onTaskCompleted: (handler: (task: DownloadTaskPayload) => void) => () => void
|
|
80
|
+
onTaskFailed: (handler: (task: DownloadTaskPayload) => void) => () => void
|
|
81
|
+
onTaskUpdated: (handler: (task: DownloadTaskPayload) => void) => () => void
|
|
82
|
+
onTaskRetrying: (handler: (payload: DownloadTaskRetryingPayload) => void) => () => void
|
|
83
|
+
onNotificationClicked: (handler: (payload: DownloadNotificationClickedPayload) => void) => () => void
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function createDownloadSdk(transport: ITuffTransport): DownloadSdk {
|
|
87
|
+
return {
|
|
88
|
+
addTask: request => transport.send(DownloadEvents.task.add, request),
|
|
89
|
+
pauseTask: payload => transport.send(DownloadEvents.task.pause, payload),
|
|
90
|
+
resumeTask: payload => transport.send(DownloadEvents.task.resume, payload),
|
|
91
|
+
cancelTask: payload => transport.send(DownloadEvents.task.cancel, payload),
|
|
92
|
+
retryTask: payload => transport.send(DownloadEvents.task.retry, payload),
|
|
93
|
+
removeTask: payload => transport.send(DownloadEvents.task.remove, payload),
|
|
94
|
+
updatePriority: payload => transport.send(DownloadEvents.task.updatePriority, payload),
|
|
95
|
+
pauseAll: () => transport.send(DownloadEvents.task.pauseAll),
|
|
96
|
+
resumeAll: () => transport.send(DownloadEvents.task.resumeAll),
|
|
97
|
+
cancelAll: () => transport.send(DownloadEvents.task.cancelAll),
|
|
98
|
+
|
|
99
|
+
getAllTasks: () => transport.send(DownloadEvents.list.getAll),
|
|
100
|
+
getTasksByStatus: payload => transport.send(DownloadEvents.list.getByStatus, payload),
|
|
101
|
+
getTaskStatus: payload => transport.send(DownloadEvents.task.getStatus, payload),
|
|
102
|
+
|
|
103
|
+
getConfig: () => transport.send(DownloadEvents.config.get),
|
|
104
|
+
updateConfig: payload => transport.send(DownloadEvents.config.update, payload),
|
|
105
|
+
getNotificationConfig: () => transport.send(DownloadEvents.config.getNotification),
|
|
106
|
+
updateNotificationConfig: payload =>
|
|
107
|
+
transport.send(DownloadEvents.config.updateNotification, payload),
|
|
108
|
+
|
|
109
|
+
getHistory: payload => transport.send(DownloadEvents.history.get, payload ?? {}),
|
|
110
|
+
clearHistory: () => transport.send(DownloadEvents.history.clear),
|
|
111
|
+
clearHistoryItem: payload => transport.send(DownloadEvents.history.clearItem, payload),
|
|
112
|
+
|
|
113
|
+
openFile: payload => transport.send(DownloadEvents.file.open, payload),
|
|
114
|
+
showInFolder: payload => transport.send(DownloadEvents.file.showInFolder, payload),
|
|
115
|
+
deleteFile: payload => transport.send(DownloadEvents.file.delete, payload),
|
|
116
|
+
|
|
117
|
+
cleanupTemp: () => transport.send(DownloadEvents.maintenance.cleanupTemp),
|
|
118
|
+
getTempStats: () => transport.send(DownloadEvents.temp.getStats),
|
|
119
|
+
|
|
120
|
+
getLogs: payload => transport.send(DownloadEvents.logs.get, payload ?? {}),
|
|
121
|
+
getErrorStats: () => transport.send(DownloadEvents.logs.getErrorStats),
|
|
122
|
+
clearLogs: () => transport.send(DownloadEvents.logs.clear),
|
|
123
|
+
|
|
124
|
+
getStats: () => transport.send(DownloadEvents.stats.get),
|
|
125
|
+
|
|
126
|
+
checkMigrationNeeded: () => transport.send(DownloadEvents.migration.checkNeeded),
|
|
127
|
+
startMigration: () => transport.send(DownloadEvents.migration.start),
|
|
128
|
+
retryMigration: () => transport.send(DownloadEvents.migration.retry),
|
|
129
|
+
getMigrationStatus: () => transport.send(DownloadEvents.migration.status),
|
|
130
|
+
|
|
131
|
+
onTaskAdded: handler => transport.on(DownloadEvents.push.taskAdded, handler),
|
|
132
|
+
onTaskProgress: handler => transport.on(DownloadEvents.push.taskProgress, handler),
|
|
133
|
+
onTaskCompleted: handler => transport.on(DownloadEvents.push.taskCompleted, handler),
|
|
134
|
+
onTaskFailed: handler => transport.on(DownloadEvents.push.taskFailed, handler),
|
|
135
|
+
onTaskUpdated: handler => transport.on(DownloadEvents.push.taskUpdated, handler),
|
|
136
|
+
onTaskRetrying: handler => transport.on(DownloadEvents.push.taskRetrying, handler),
|
|
137
|
+
onNotificationClicked: handler => transport.on(DownloadEvents.push.notificationClicked, handler),
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './agents'
|
|
2
|
+
export * from './agents-market'
|
|
3
|
+
export * from './app'
|
|
4
|
+
export * from './disposable'
|
|
5
|
+
export * from './download'
|
|
6
|
+
export * from './intelligence'
|
|
7
|
+
export * from './market'
|
|
8
|
+
export * from './notification'
|
|
9
|
+
export * from './permission'
|
|
10
|
+
export * from './platform'
|
|
11
|
+
export * from './plugin'
|
|
12
|
+
export * from './settings'
|
|
13
|
+
export * from './update'
|