@talex-touch/utils 1.0.40 → 1.0.44
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 +97 -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 +21 -3
- package/market/index.ts +1 -1
- package/market/types.ts +20 -5
- 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 +82 -8
- 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 -0
- package/plugin/providers/market-client.ts +218 -0
- package/plugin/providers/npm-provider.ts +228 -0
- package/plugin/providers/tpex-provider.ts +297 -0
- package/plugin/providers/tpex-types.ts +34 -0
- 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 +113 -49
- 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/performance.ts +1 -16
- 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 +34 -6
- 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 +202 -104
- 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 +37 -46
- 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 +2670 -0
- package/transport/events/meta-overlay.ts +79 -0
- package/transport/events/types/agents.ts +177 -0
- package/transport/events/types/app-index.ts +9 -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 +73 -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 +620 -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 +139 -0
- package/transport/main.ts +2 -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 +92 -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 +47 -27
- 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 +1492 -81
- 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
package/types/modules/base.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type PlatformCapabilityScope = 'system' | 'plugin' | 'ai'
|
|
2
|
+
|
|
3
|
+
export type PlatformCapabilityStatus = 'alpha' | 'beta' | 'stable'
|
|
4
|
+
|
|
5
|
+
export interface PlatformCapability {
|
|
6
|
+
id: string
|
|
7
|
+
name: string
|
|
8
|
+
description: string
|
|
9
|
+
scope: PlatformCapabilityScope
|
|
10
|
+
status: PlatformCapabilityStatus
|
|
11
|
+
sensitive?: boolean
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface StartupPaths {
|
|
2
|
+
appDataPath: string
|
|
3
|
+
appPath: string
|
|
4
|
+
configPath: string
|
|
5
|
+
exePath: string
|
|
6
|
+
homePath: string
|
|
7
|
+
modulePath: string
|
|
8
|
+
pluginPath: string
|
|
9
|
+
rootPath: string
|
|
10
|
+
tempPath: string
|
|
11
|
+
userDataPath: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface StartupInfo {
|
|
15
|
+
id: number
|
|
16
|
+
version: string
|
|
17
|
+
path: StartupPaths
|
|
18
|
+
isPackaged: boolean
|
|
19
|
+
isDev: boolean
|
|
20
|
+
isRelease: boolean
|
|
21
|
+
platform: string
|
|
22
|
+
arch: string
|
|
23
|
+
platformWarning?: string
|
|
24
|
+
t: {
|
|
25
|
+
_s: number
|
|
26
|
+
s: number
|
|
27
|
+
e: number
|
|
28
|
+
p: number
|
|
29
|
+
h: number[]
|
|
30
|
+
}
|
|
31
|
+
appUpdate?: boolean
|
|
32
|
+
}
|
package/types/touch-app-core.ts
CHANGED
|
@@ -26,13 +26,13 @@ export namespace TalexTouch {
|
|
|
26
26
|
* the close button of the window. The web page may cancel the close though. See
|
|
27
27
|
* the close event.
|
|
28
28
|
*/
|
|
29
|
-
close()
|
|
29
|
+
close: () => void
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Minimizes the window. On some platforms the minimized window will be shown in
|
|
33
33
|
* the Dock.
|
|
34
34
|
*/
|
|
35
|
-
minimize()
|
|
35
|
+
minimize: () => void
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Opens the devtools.
|
|
@@ -43,16 +43,16 @@ export namespace TalexTouch {
|
|
|
43
43
|
* On Windows, if Windows Control Overlay is enabled, Devtools will be opened with
|
|
44
44
|
* `mode: 'detach'`.
|
|
45
45
|
*/
|
|
46
|
-
openDevTools(options?: OpenDevToolsOptions)
|
|
46
|
+
openDevTools: (options?: OpenDevToolsOptions) => void
|
|
47
47
|
|
|
48
|
-
loadURL(
|
|
48
|
+
loadURL: (
|
|
49
49
|
url: string,
|
|
50
50
|
options?: LoadURLOptions | undefined,
|
|
51
|
-
)
|
|
52
|
-
loadFile(
|
|
51
|
+
) => Promise<Electron.WebContents>
|
|
52
|
+
loadFile: (
|
|
53
53
|
filePath: string,
|
|
54
54
|
options?: LoadFileOptions | undefined,
|
|
55
|
-
)
|
|
55
|
+
) => Promise<Electron.WebContents>
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export type TouchWindowConstructorOptions
|
|
@@ -76,7 +76,7 @@ export namespace TalexTouch {
|
|
|
76
76
|
export interface IConfiguration {
|
|
77
77
|
configPath: string
|
|
78
78
|
data: TouchAppConfig
|
|
79
|
-
triggerSave:
|
|
79
|
+
triggerSave: () => void
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
export interface TouchAppConfig {
|
package/types/update.ts
CHANGED
|
@@ -97,6 +97,14 @@ export interface UpdateSettings {
|
|
|
97
97
|
updateChannel: AppPreviewChannel
|
|
98
98
|
ignoredVersions: string[]
|
|
99
99
|
customSources: CustomUpdateConfig[]
|
|
100
|
+
/**
|
|
101
|
+
* Automatically download update packages when available.
|
|
102
|
+
*/
|
|
103
|
+
autoDownload?: boolean
|
|
104
|
+
/**
|
|
105
|
+
* Enable experimental renderer override updates.
|
|
106
|
+
*/
|
|
107
|
+
rendererOverrideEnabled?: boolean
|
|
100
108
|
/**
|
|
101
109
|
* Timestamp (ms) of the last successful update check.
|
|
102
110
|
*/
|
|
@@ -123,6 +131,11 @@ export interface UpdateSettings {
|
|
|
123
131
|
retryDelay?: number
|
|
124
132
|
}
|
|
125
133
|
|
|
134
|
+
export const UPDATE_GITHUB_REPO = 'talex-touch/tuff'
|
|
135
|
+
export const UPDATE_GITHUB_RELEASES_API = `https://api.github.com/repos/${UPDATE_GITHUB_REPO}/releases`
|
|
136
|
+
export const UPDATE_TAG_PREFIX = 'v'
|
|
137
|
+
export const UPDATE_RELEASE_MANIFEST_NAME = 'tuff-release-manifest.json'
|
|
138
|
+
|
|
126
139
|
/**
|
|
127
140
|
* Safe defaults used when no user configuration exists yet.
|
|
128
141
|
*/
|
|
@@ -132,13 +145,15 @@ export const defaultUpdateSettings: UpdateSettings = {
|
|
|
132
145
|
source: {
|
|
133
146
|
type: UpdateProviderType.GITHUB,
|
|
134
147
|
name: 'GitHub Releases',
|
|
135
|
-
url:
|
|
148
|
+
url: UPDATE_GITHUB_RELEASES_API,
|
|
136
149
|
enabled: true,
|
|
137
150
|
priority: 1,
|
|
138
151
|
},
|
|
139
152
|
updateChannel: AppPreviewChannel.RELEASE,
|
|
140
153
|
ignoredVersions: [],
|
|
141
154
|
customSources: [],
|
|
155
|
+
autoDownload: false,
|
|
156
|
+
rendererOverrideEnabled: false,
|
|
142
157
|
lastCheckedAt: null,
|
|
143
158
|
cacheEnabled: true,
|
|
144
159
|
cacheTTL: 30,
|
|
@@ -147,6 +162,84 @@ export const defaultUpdateSettings: UpdateSettings = {
|
|
|
147
162
|
retryDelay: 2000,
|
|
148
163
|
}
|
|
149
164
|
|
|
165
|
+
const UPDATE_CHANNEL_LABELS = {
|
|
166
|
+
beta: ['BETA', 'SNAPSHOT', 'ALPHA'],
|
|
167
|
+
release: ['RELEASE', 'MASTER'],
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Resolve a release channel from the tag suffix label.
|
|
172
|
+
*/
|
|
173
|
+
export function resolveUpdateChannelLabel(label?: string): AppPreviewChannel {
|
|
174
|
+
const normalized = (label || '').trim().toUpperCase()
|
|
175
|
+
|
|
176
|
+
if (UPDATE_CHANNEL_LABELS.beta.some((value) => normalized.startsWith(value))) {
|
|
177
|
+
return AppPreviewChannel.BETA
|
|
178
|
+
}
|
|
179
|
+
if (UPDATE_CHANNEL_LABELS.release.some((value) => normalized.startsWith(value))) {
|
|
180
|
+
return AppPreviewChannel.RELEASE
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return AppPreviewChannel.RELEASE
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Split an update tag into the numeric version part and optional channel label.
|
|
188
|
+
* Expected format: v<major>.<minor>.<patch>[-<channel>]
|
|
189
|
+
*/
|
|
190
|
+
export function splitUpdateTag(tag: string): { version: string; channelLabel?: string } {
|
|
191
|
+
const trimmed = tag.trim()
|
|
192
|
+
const cleaned = trimmed.toLowerCase().startsWith(UPDATE_TAG_PREFIX)
|
|
193
|
+
? trimmed.slice(UPDATE_TAG_PREFIX.length)
|
|
194
|
+
: trimmed
|
|
195
|
+
const [version = '', channelLabel] = cleaned.split('-', 2)
|
|
196
|
+
return { version, channelLabel }
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function parseUpdateTag(tag: string): { version: string; channel: AppPreviewChannel } {
|
|
200
|
+
const { version, channelLabel } = splitUpdateTag(tag)
|
|
201
|
+
return { version, channel: resolveUpdateChannelLabel(channelLabel) }
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export type UpdateArtifactComponent = 'core' | 'renderer' | 'extensions'
|
|
205
|
+
|
|
206
|
+
export type SystemUpdateType = 'announcement' | 'config' | 'data'
|
|
207
|
+
|
|
208
|
+
export interface FxRatePayload {
|
|
209
|
+
kind: 'fx-rate'
|
|
210
|
+
base: string
|
|
211
|
+
asOf?: string
|
|
212
|
+
providerUpdatedAt?: string | null
|
|
213
|
+
fetchedAt: string
|
|
214
|
+
providerNextUpdateAt?: string | null
|
|
215
|
+
ttlMs?: number
|
|
216
|
+
source?: string
|
|
217
|
+
rates: Record<string, number>
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export type SystemUpdatePayload = FxRatePayload | { kind: string; [key: string]: unknown }
|
|
221
|
+
|
|
222
|
+
export interface UpdateReleaseArtifact {
|
|
223
|
+
name: string
|
|
224
|
+
component: UpdateArtifactComponent
|
|
225
|
+
platform?: 'win32' | 'darwin' | 'linux'
|
|
226
|
+
arch?: 'x64' | 'arm64'
|
|
227
|
+
sha256: string
|
|
228
|
+
signature?: string
|
|
229
|
+
signatureKey?: string
|
|
230
|
+
coreRange?: string
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface UpdateReleaseManifest {
|
|
234
|
+
schemaVersion: 1
|
|
235
|
+
release: {
|
|
236
|
+
version: string
|
|
237
|
+
channel: AppPreviewChannel
|
|
238
|
+
tag: string
|
|
239
|
+
}
|
|
240
|
+
artifacts: UpdateReleaseArtifact[]
|
|
241
|
+
}
|
|
242
|
+
|
|
150
243
|
/**
|
|
151
244
|
* Categorized error types emitted by the updater pipeline.
|
|
152
245
|
*/
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config'
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
globals: true,
|
|
6
|
+
environment: 'node',
|
|
7
|
+
include: ['__tests__/**/*.test.ts'],
|
|
8
|
+
exclude: ['**/node_modules/**', '**/dist/**'],
|
|
9
|
+
testTimeout: 10000,
|
|
10
|
+
coverage: {
|
|
11
|
+
provider: 'v8',
|
|
12
|
+
reporter: ['text', 'json', 'html'],
|
|
13
|
+
include: [
|
|
14
|
+
'core-box/**/*.ts',
|
|
15
|
+
'search/**/*.ts',
|
|
16
|
+
'transport/**/*.ts',
|
|
17
|
+
],
|
|
18
|
+
exclude: [
|
|
19
|
+
'**/*.d.ts',
|
|
20
|
+
'**/index.ts',
|
|
21
|
+
'**/types.ts',
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
})
|
package/auth/useClerkConfig.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { ClerkConfig } from './clerk-types'
|
|
2
|
-
|
|
3
|
-
const clerkPublishableKey = (import.meta.env as any).VITE_CLERK_PUBLISHABLE_KEY
|
|
4
|
-
const clerkDomain = (import.meta.env as any).VITE_CLERK_DOMAIN
|
|
5
|
-
|
|
6
|
-
if (!clerkPublishableKey?.length) {
|
|
7
|
-
throw new Error('VITE_CLERK_PUBLISHABLE_KEY is not set')
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const CLERK_PUBLISHABLE_KEY_KEY = 'clerk-publishable-key'
|
|
11
|
-
|
|
12
|
-
export const defaultClerkConfig: ClerkConfig = {
|
|
13
|
-
publishableKey: clerkPublishableKey,
|
|
14
|
-
domain: clerkDomain,
|
|
15
|
-
signInUrl: '/sign-in',
|
|
16
|
-
signUpUrl: '/sign-up',
|
|
17
|
-
afterSignInUrl: '/home',
|
|
18
|
-
afterSignUpUrl: '/home',
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function useClerkConfig() {
|
|
22
|
-
const getClerkConfig = (): ClerkConfig => {
|
|
23
|
-
return {
|
|
24
|
-
...defaultClerkConfig,
|
|
25
|
-
publishableKey:
|
|
26
|
-
localStorage.getItem(CLERK_PUBLISHABLE_KEY_KEY) || defaultClerkConfig.publishableKey,
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const setClerkConfig = (config: Partial<ClerkConfig>): void => {
|
|
31
|
-
if (config.publishableKey) {
|
|
32
|
-
localStorage.setItem(CLERK_PUBLISHABLE_KEY_KEY, config.publishableKey)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
getClerkConfig,
|
|
38
|
-
setClerkConfig,
|
|
39
|
-
}
|
|
40
|
-
}
|
package/auth/useClerkProvider.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Clerk } from '@clerk/clerk-js'
|
|
2
|
-
import { useClerkConfig } from './useClerkConfig'
|
|
3
|
-
|
|
4
|
-
let clerkInstance: Clerk | null = null
|
|
5
|
-
|
|
6
|
-
export function useClerkProvider() {
|
|
7
|
-
const initializeClerk = async (): Promise<Clerk> => {
|
|
8
|
-
if (clerkInstance) {
|
|
9
|
-
return clerkInstance
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const { getClerkConfig } = useClerkConfig()
|
|
13
|
-
const config = getClerkConfig()
|
|
14
|
-
|
|
15
|
-
if (!config.publishableKey) {
|
|
16
|
-
throw new Error('Clerk publishable key is required')
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
clerkInstance = new Clerk(config.publishableKey)
|
|
21
|
-
await clerkInstance.load()
|
|
22
|
-
|
|
23
|
-
console.log('Clerk initialized successfully')
|
|
24
|
-
return clerkInstance
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
console.error('Failed to initialize Clerk:', error)
|
|
28
|
-
throw error
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const getClerk = (): Clerk | null => {
|
|
33
|
-
return clerkInstance
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const isClerkInitialized = (): boolean => {
|
|
37
|
-
return clerkInstance !== null
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const cleanupClerk = (): void => {
|
|
41
|
-
if (clerkInstance) {
|
|
42
|
-
clerkInstance = null
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
initializeClerk,
|
|
48
|
-
getClerk,
|
|
49
|
-
isClerkInitialized,
|
|
50
|
-
cleanupClerk,
|
|
51
|
-
}
|
|
52
|
-
}
|