@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,322 @@
|
|
|
1
|
+
import type { Ref } from 'vue'
|
|
2
|
+
import { nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resize dimensions in pixels.
|
|
6
|
+
*/
|
|
7
|
+
export interface AutoResizeSize {
|
|
8
|
+
width: number
|
|
9
|
+
height: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Resize event payload passed to callbacks.
|
|
14
|
+
*/
|
|
15
|
+
export interface AutoResizeEvent {
|
|
16
|
+
/** Previous measured size (null on first run) */
|
|
17
|
+
prev: AutoResizeSize | null
|
|
18
|
+
/** Current measured size */
|
|
19
|
+
next: AutoResizeSize
|
|
20
|
+
/** Whether the change was triggered by manual refresh() */
|
|
21
|
+
isManual: boolean
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* How to round measured values.
|
|
26
|
+
*/
|
|
27
|
+
export type AutoResizeRounding = 'none' | 'round' | 'floor' | 'ceil'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Options for {@link useAutoResize}.
|
|
31
|
+
*/
|
|
32
|
+
export interface UseAutoResizeOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Sync width from inner -> outer.
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
width?: boolean
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Sync height from inner -> outer.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
height?: boolean
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Apply measured values as `px` inline styles on the outer element.
|
|
47
|
+
* If false, no inline width/height will be written (callbacks still fire).
|
|
48
|
+
* @default true
|
|
49
|
+
*/
|
|
50
|
+
applyStyle?: boolean
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Which element receives the styles.
|
|
54
|
+
* - "outer": write width/height to outer (common for wrapper animation)
|
|
55
|
+
* - "inner": write width/height to inner (rare but sometimes useful)
|
|
56
|
+
* @default "outer"
|
|
57
|
+
*/
|
|
58
|
+
styleTarget?: 'outer' | 'inner'
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Rounding strategy for measured sizes.
|
|
62
|
+
* Useful to avoid sub-pixel jitter when animating.
|
|
63
|
+
* @default "ceil"
|
|
64
|
+
*/
|
|
65
|
+
rounding?: AutoResizeRounding
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Run an initial measurement on mount.
|
|
69
|
+
* @default true
|
|
70
|
+
*/
|
|
71
|
+
immediate?: boolean
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* If true, batches multiple observer triggers into a single DOM write via rAF.
|
|
75
|
+
* Helps avoid layout thrash when content changes rapidly.
|
|
76
|
+
* @default true
|
|
77
|
+
*/
|
|
78
|
+
rafBatch?: boolean
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Called whenever a resize is detected (after measurement, before applying styles).
|
|
82
|
+
*/
|
|
83
|
+
onResize?: (e: AutoResizeEvent) => void
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Called right before applying inline styles (if applyStyle = true).
|
|
87
|
+
* You can mutate/override the target style here if you want.
|
|
88
|
+
*/
|
|
89
|
+
onBeforeApply?: (e: AutoResizeEvent) => void
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Called after applying inline styles (if applyStyle = true).
|
|
93
|
+
*/
|
|
94
|
+
onAfterApply?: (e: AutoResizeEvent) => void
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Result returned by {@link useAutoResize}.
|
|
99
|
+
*/
|
|
100
|
+
export interface UseAutoResizeReturn {
|
|
101
|
+
/**
|
|
102
|
+
* Manually re-measure and (optionally) apply size.
|
|
103
|
+
* Useful after state toggles (e.g. loading -> show spinner),
|
|
104
|
+
* or when content changes but you suspect observer didn't fire (rare).
|
|
105
|
+
*/
|
|
106
|
+
refresh: () => Promise<void>
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Start observing (automatically called onMounted if enabled = true).
|
|
110
|
+
*/
|
|
111
|
+
start: () => void
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Stop observing and cancel pending rAF.
|
|
115
|
+
*/
|
|
116
|
+
stop: () => void
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Enable/disable without unmounting.
|
|
120
|
+
* When disabled, observer is disconnected and no styles are applied.
|
|
121
|
+
*/
|
|
122
|
+
setEnabled: (enabled: boolean) => void
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Latest measured size (null until first measure).
|
|
126
|
+
*/
|
|
127
|
+
size: Ref<AutoResizeSize | null>
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Observe the size of `innerRef` using `ResizeObserver` and synchronize it to `outerRef`.
|
|
132
|
+
*
|
|
133
|
+
* Typical usage:
|
|
134
|
+
* - Buttons: animate width changes when toggling loading spinners.
|
|
135
|
+
* - Tabs/Accordions: animate height changes when switching content.
|
|
136
|
+
*
|
|
137
|
+
* @example Button width animation
|
|
138
|
+
* ```vue
|
|
139
|
+
* <template>
|
|
140
|
+
* <button ref="outer" class="transition-[width] duration-200 overflow-hidden">
|
|
141
|
+
* <span ref="inner" class="inline-flex items-center gap-2 whitespace-nowrap">
|
|
142
|
+
* <Spinner v-if="loading" />
|
|
143
|
+
* <span>{{ label }}</span>
|
|
144
|
+
* </span>
|
|
145
|
+
* </button>
|
|
146
|
+
* </template>
|
|
147
|
+
* <script setup lang="ts">
|
|
148
|
+
* import { ref, watch } from 'vue'
|
|
149
|
+
* import { useAutoResize } from './useAutoResize'
|
|
150
|
+
*
|
|
151
|
+
* const outer = ref<HTMLElement|null>(null)
|
|
152
|
+
* const inner = ref<HTMLElement|null>(null)
|
|
153
|
+
* const loading = ref(false)
|
|
154
|
+
*
|
|
155
|
+
* const { refresh } = useAutoResize(outer, inner, { width: true, height: false })
|
|
156
|
+
* watch(loading, () => void refresh())
|
|
157
|
+
* </script>
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @example Tabs height animation
|
|
161
|
+
* ```vue
|
|
162
|
+
* <template>
|
|
163
|
+
* <div ref="outer" class="transition-[height] duration-250 overflow-hidden">
|
|
164
|
+
* <div ref="inner">
|
|
165
|
+
* <component :is="activeComp" />
|
|
166
|
+
* </div>
|
|
167
|
+
* </div>
|
|
168
|
+
* </template>
|
|
169
|
+
* <script setup lang="ts">
|
|
170
|
+
* import { ref, watch } from 'vue'
|
|
171
|
+
* import { useAutoResize } from './useAutoResize'
|
|
172
|
+
*
|
|
173
|
+
* const outer = ref<HTMLElement|null>(null)
|
|
174
|
+
* const inner = ref<HTMLElement|null>(null)
|
|
175
|
+
* const activeKey = ref('a')
|
|
176
|
+
*
|
|
177
|
+
* const { refresh } = useAutoResize(outer, inner, { width: false, height: true })
|
|
178
|
+
* watch(activeKey, () => void refresh())
|
|
179
|
+
* </script>
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
export function useAutoResize(
|
|
183
|
+
outerRef: Ref<HTMLElement | null>,
|
|
184
|
+
innerRef: Ref<HTMLElement | null>,
|
|
185
|
+
options: UseAutoResizeOptions = {},
|
|
186
|
+
): UseAutoResizeReturn {
|
|
187
|
+
const opt: Required<UseAutoResizeOptions> = {
|
|
188
|
+
width: options.width ?? true,
|
|
189
|
+
height: options.height ?? false,
|
|
190
|
+
applyStyle: options.applyStyle ?? true,
|
|
191
|
+
styleTarget: options.styleTarget ?? 'outer',
|
|
192
|
+
rounding: options.rounding ?? 'ceil',
|
|
193
|
+
immediate: options.immediate ?? true,
|
|
194
|
+
rafBatch: options.rafBatch ?? true,
|
|
195
|
+
onResize: options.onResize ?? (() => {}),
|
|
196
|
+
onBeforeApply: options.onBeforeApply ?? (() => {}),
|
|
197
|
+
onAfterApply: options.onAfterApply ?? (() => {}),
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const size = ref<AutoResizeSize | null>(null)
|
|
201
|
+
const enabled = ref(true)
|
|
202
|
+
const ro = ref<ResizeObserver | null>(null)
|
|
203
|
+
let rafId: number | null = null
|
|
204
|
+
let pendingManual = false
|
|
205
|
+
|
|
206
|
+
const round = (v: number) => {
|
|
207
|
+
switch (opt.rounding) {
|
|
208
|
+
case 'none':
|
|
209
|
+
return v
|
|
210
|
+
case 'round':
|
|
211
|
+
return Math.round(v)
|
|
212
|
+
case 'floor':
|
|
213
|
+
return Math.floor(v)
|
|
214
|
+
case 'ceil':
|
|
215
|
+
default:
|
|
216
|
+
return Math.ceil(v)
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const getTargets = () => {
|
|
221
|
+
const outer = outerRef.value
|
|
222
|
+
const inner = innerRef.value
|
|
223
|
+
const styleEl = opt.styleTarget === 'outer' ? outer : inner
|
|
224
|
+
return { outer, inner, styleEl }
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const apply = (e: AutoResizeEvent, styleEl: HTMLElement) => {
|
|
228
|
+
if (!opt.applyStyle)
|
|
229
|
+
return
|
|
230
|
+
if (opt.width)
|
|
231
|
+
styleEl.style.width = `${e.next.width}px`
|
|
232
|
+
if (opt.height)
|
|
233
|
+
styleEl.style.height = `${e.next.height}px`
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const measureAndSync = async (isManual: boolean) => {
|
|
237
|
+
await nextTick()
|
|
238
|
+
const { inner, styleEl } = getTargets()
|
|
239
|
+
if (!inner || !styleEl)
|
|
240
|
+
return
|
|
241
|
+
if (!enabled.value)
|
|
242
|
+
return
|
|
243
|
+
|
|
244
|
+
const rect = inner.getBoundingClientRect()
|
|
245
|
+
const next: AutoResizeSize = {
|
|
246
|
+
width: round(rect.width),
|
|
247
|
+
height: round(rect.height),
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const prev = size.value
|
|
251
|
+
const event: AutoResizeEvent = { prev, next, isManual }
|
|
252
|
+
|
|
253
|
+
// always update size ref (even if applyStyle = false)
|
|
254
|
+
size.value = next
|
|
255
|
+
|
|
256
|
+
opt.onResize(event)
|
|
257
|
+
opt.onBeforeApply(event)
|
|
258
|
+
apply(event, styleEl)
|
|
259
|
+
opt.onAfterApply(event)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const schedule = (isManual: boolean) => {
|
|
263
|
+
if (!opt.rafBatch) {
|
|
264
|
+
void measureAndSync(isManual)
|
|
265
|
+
return
|
|
266
|
+
}
|
|
267
|
+
if (rafId != null)
|
|
268
|
+
return
|
|
269
|
+
rafId = requestAnimationFrame(() => {
|
|
270
|
+
rafId = null
|
|
271
|
+
const manual = pendingManual
|
|
272
|
+
pendingManual = false
|
|
273
|
+
void measureAndSync(manual)
|
|
274
|
+
})
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const start = () => {
|
|
278
|
+
if (ro.value)
|
|
279
|
+
return
|
|
280
|
+
const { inner } = getTargets()
|
|
281
|
+
if (!inner)
|
|
282
|
+
return
|
|
283
|
+
ro.value = new ResizeObserver(() => schedule(false))
|
|
284
|
+
ro.value.observe(inner)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const stop = () => {
|
|
288
|
+
ro.value?.disconnect()
|
|
289
|
+
ro.value = null
|
|
290
|
+
if (rafId != null)
|
|
291
|
+
cancelAnimationFrame(rafId)
|
|
292
|
+
rafId = null
|
|
293
|
+
pendingManual = false
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const setEnabled = (v: boolean) => {
|
|
297
|
+
enabled.value = v
|
|
298
|
+
if (!v)
|
|
299
|
+
stop()
|
|
300
|
+
else start()
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const refresh = async () => {
|
|
304
|
+
pendingManual = true
|
|
305
|
+
schedule(true)
|
|
306
|
+
await new Promise<void>((resolve) => {
|
|
307
|
+
requestAnimationFrame(() => resolve())
|
|
308
|
+
})
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
onMounted(async () => {
|
|
312
|
+
if (!enabled.value)
|
|
313
|
+
return
|
|
314
|
+
start()
|
|
315
|
+
if (opt.immediate)
|
|
316
|
+
await measureAndSync(false)
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
onBeforeUnmount(() => stop())
|
|
320
|
+
|
|
321
|
+
return { refresh, start, stop, setEnabled, size }
|
|
322
|
+
}
|
package/animation/window-node.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TalexTouch } from '../types'
|
|
2
|
+
import { PollingService } from '../common/utils/polling'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Window animation controller return type
|
|
@@ -36,7 +37,7 @@ export interface WindowAnimationController {
|
|
|
36
37
|
* Tracks the state of an animation
|
|
37
38
|
*/
|
|
38
39
|
interface AnimationState {
|
|
39
|
-
|
|
40
|
+
taskId: string | null
|
|
40
41
|
completed: boolean
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -55,9 +56,11 @@ function easeInOutCubic(t: number): number {
|
|
|
55
56
|
export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnimationController {
|
|
56
57
|
// Store current window reference inside the function scope
|
|
57
58
|
let currentWindow: TalexTouch.ITouchWindow | null = window || null
|
|
59
|
+
const pollingService = PollingService.getInstance()
|
|
60
|
+
let animationTaskCounter = 0
|
|
58
61
|
|
|
59
62
|
const animationState: AnimationState = {
|
|
60
|
-
|
|
63
|
+
taskId: null,
|
|
61
64
|
completed: false,
|
|
62
65
|
}
|
|
63
66
|
|
|
@@ -89,9 +92,9 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
|
|
|
89
92
|
const window = getCurrentWindow()
|
|
90
93
|
|
|
91
94
|
// Cancel any existing animation
|
|
92
|
-
if (animationState.
|
|
93
|
-
|
|
94
|
-
animationState.
|
|
95
|
+
if (animationState.taskId) {
|
|
96
|
+
pollingService.unregister(animationState.taskId)
|
|
97
|
+
animationState.taskId = null
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
// Reset state for new animation
|
|
@@ -107,12 +110,15 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
|
|
|
107
110
|
const durationMs = duration * 1000
|
|
108
111
|
|
|
109
112
|
return new Promise<boolean>((resolve) => {
|
|
110
|
-
|
|
113
|
+
const taskId = `window-animation.${animationTaskCounter++}`
|
|
114
|
+
animationState.taskId = taskId
|
|
115
|
+
|
|
116
|
+
pollingService.register(taskId, () => {
|
|
111
117
|
// Check if window is still valid
|
|
112
118
|
if (!isWindowValid()) {
|
|
113
|
-
if (animationState.
|
|
114
|
-
|
|
115
|
-
animationState.
|
|
119
|
+
if (animationState.taskId) {
|
|
120
|
+
pollingService.unregister(animationState.taskId)
|
|
121
|
+
animationState.taskId = null
|
|
116
122
|
}
|
|
117
123
|
resolve(false)
|
|
118
124
|
return
|
|
@@ -127,14 +133,15 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
|
|
|
127
133
|
browserWindow.setPosition(x, y)
|
|
128
134
|
|
|
129
135
|
if (progress >= 1) {
|
|
130
|
-
if (animationState.
|
|
131
|
-
|
|
132
|
-
animationState.
|
|
136
|
+
if (animationState.taskId) {
|
|
137
|
+
pollingService.unregister(animationState.taskId)
|
|
138
|
+
animationState.taskId = null
|
|
133
139
|
}
|
|
134
140
|
animationState.completed = true
|
|
135
141
|
resolve(true)
|
|
136
142
|
}
|
|
137
|
-
}, 16) // ~60fps
|
|
143
|
+
}, { interval: 16, unit: 'milliseconds' }) // ~60fps
|
|
144
|
+
pollingService.start()
|
|
138
145
|
})
|
|
139
146
|
}
|
|
140
147
|
catch (error) {
|
|
@@ -144,9 +151,9 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
|
|
|
144
151
|
}
|
|
145
152
|
|
|
146
153
|
const cancel = async (): Promise<boolean> => {
|
|
147
|
-
if (animationState.
|
|
148
|
-
|
|
149
|
-
animationState.
|
|
154
|
+
if (animationState.taskId) {
|
|
155
|
+
pollingService.unregister(animationState.taskId)
|
|
156
|
+
animationState.taskId = null
|
|
150
157
|
return Promise.resolve(true)
|
|
151
158
|
}
|
|
152
159
|
return Promise.resolve(false)
|
|
@@ -187,9 +194,9 @@ export function useWindowAnimation(window?: TalexTouch.ITouchWindow): WindowAnim
|
|
|
187
194
|
|
|
188
195
|
const changeWindow = (newWindow: TalexTouch.ITouchWindow): void => {
|
|
189
196
|
// Cancel any ongoing animation
|
|
190
|
-
if (animationState.
|
|
191
|
-
|
|
192
|
-
animationState.
|
|
197
|
+
if (animationState.taskId) {
|
|
198
|
+
pollingService.unregister(animationState.taskId)
|
|
199
|
+
animationState.taskId = null
|
|
193
200
|
}
|
|
194
201
|
|
|
195
202
|
// Set new window
|
package/auth/clerk-types.ts
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface AuthUser {
|
|
2
2
|
id: string
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
updatedAt: string
|
|
3
|
+
email: string
|
|
4
|
+
name?: string | null
|
|
5
|
+
avatar?: string | null
|
|
6
|
+
role?: string | null
|
|
7
|
+
locale?: string | null
|
|
8
|
+
emailVerified?: boolean
|
|
9
|
+
bio?: string | null
|
|
10
|
+
createdAt?: string | null
|
|
11
|
+
updatedAt?: string | null
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
export interface
|
|
14
|
+
export interface AuthState {
|
|
16
15
|
isLoaded: boolean
|
|
17
16
|
isSignedIn: boolean
|
|
18
|
-
user:
|
|
17
|
+
user: AuthUser | null
|
|
19
18
|
sessionId: string | null
|
|
20
19
|
}
|
|
21
20
|
|
|
@@ -37,20 +36,3 @@ export interface CurrentUser {
|
|
|
37
36
|
avatar?: string
|
|
38
37
|
provider: string
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Clerk Auth Config
|
|
43
|
-
*/
|
|
44
|
-
export interface ClerkConfig {
|
|
45
|
-
publishableKey: string
|
|
46
|
-
domain?: string
|
|
47
|
-
signInUrl?: string
|
|
48
|
-
signUpUrl?: string
|
|
49
|
-
afterSignInUrl?: string
|
|
50
|
-
afterSignUpUrl?: string
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface ClerkResourceSnapshot {
|
|
54
|
-
user?: any | null
|
|
55
|
-
session?: { id?: string | null } | null
|
|
56
|
-
}
|
package/auth/index.ts
CHANGED
package/auth/useAuthState.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AuthState, CurrentUser } from './clerk-types'
|
|
2
2
|
import { createGlobalState } from '@vueuse/core'
|
|
3
3
|
import { computed, shallowReactive } from 'vue'
|
|
4
4
|
|
|
5
5
|
export const useAuthState = createGlobalState(() => {
|
|
6
|
-
const authState = shallowReactive<
|
|
6
|
+
const authState = shallowReactive<AuthState>({
|
|
7
7
|
isLoaded: false,
|
|
8
8
|
isSignedIn: false,
|
|
9
9
|
user: null,
|
|
@@ -21,23 +21,15 @@ export function useCurrentUser() {
|
|
|
21
21
|
return null
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
if (firstName || lastName) {
|
|
27
|
-
name = [firstName, lastName].filter(Boolean).join(' ')
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
name = username || ''
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const email = authState.user.emailAddresses?.[0]?.emailAddress || ''
|
|
24
|
+
const name = authState.user.name || authState.user.email || ''
|
|
25
|
+
const email = authState.user.email
|
|
34
26
|
|
|
35
27
|
return {
|
|
36
28
|
id: authState.user.id,
|
|
37
29
|
name,
|
|
38
30
|
email,
|
|
39
|
-
avatar:
|
|
40
|
-
provider: '
|
|
31
|
+
avatar: authState.user.avatar || undefined,
|
|
32
|
+
provider: 'nexus',
|
|
41
33
|
}
|
|
42
34
|
})
|
|
43
35
|
|
package/base/index.ts
CHANGED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Log Level Definition
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for log levels across the entire application.
|
|
5
|
+
* Used by both module logger and plugin logger systems.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Log level enumeration with numeric values for comparison
|
|
10
|
+
*/
|
|
11
|
+
export enum LogLevel {
|
|
12
|
+
DEBUG = 0,
|
|
13
|
+
INFO = 1,
|
|
14
|
+
WARN = 2,
|
|
15
|
+
ERROR = 3,
|
|
16
|
+
NONE = 4,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Log level string type (uppercase)
|
|
21
|
+
*/
|
|
22
|
+
export type LogLevelString = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'NONE'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Log level string type (lowercase)
|
|
26
|
+
*/
|
|
27
|
+
export type LogLevelStringLower = 'debug' | 'info' | 'warn' | 'error' | 'none'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Convert LogLevel enum to uppercase string
|
|
31
|
+
*/
|
|
32
|
+
export function logLevelToString(level: LogLevel): LogLevelString {
|
|
33
|
+
switch (level) {
|
|
34
|
+
case LogLevel.DEBUG:
|
|
35
|
+
return 'DEBUG'
|
|
36
|
+
case LogLevel.INFO:
|
|
37
|
+
return 'INFO'
|
|
38
|
+
case LogLevel.WARN:
|
|
39
|
+
return 'WARN'
|
|
40
|
+
case LogLevel.ERROR:
|
|
41
|
+
return 'ERROR'
|
|
42
|
+
case LogLevel.NONE:
|
|
43
|
+
return 'NONE'
|
|
44
|
+
default:
|
|
45
|
+
return 'INFO'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Convert LogLevel enum to lowercase string
|
|
51
|
+
*/
|
|
52
|
+
export function logLevelToLowerString(level: LogLevel): LogLevelStringLower {
|
|
53
|
+
return logLevelToString(level).toLowerCase() as LogLevelStringLower
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Convert string to LogLevel enum
|
|
58
|
+
*/
|
|
59
|
+
export function stringToLogLevel(str: string): LogLevel {
|
|
60
|
+
const upper = str.toUpperCase()
|
|
61
|
+
switch (upper) {
|
|
62
|
+
case 'DEBUG':
|
|
63
|
+
return LogLevel.DEBUG
|
|
64
|
+
case 'INFO':
|
|
65
|
+
return LogLevel.INFO
|
|
66
|
+
case 'WARN':
|
|
67
|
+
case 'WARNING':
|
|
68
|
+
return LogLevel.WARN
|
|
69
|
+
case 'ERROR':
|
|
70
|
+
return LogLevel.ERROR
|
|
71
|
+
case 'NONE':
|
|
72
|
+
case 'OFF':
|
|
73
|
+
return LogLevel.NONE
|
|
74
|
+
default:
|
|
75
|
+
return LogLevel.INFO
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Check if a level should be logged given a minimum level
|
|
81
|
+
*/
|
|
82
|
+
export function shouldLog(level: LogLevel, minLevel: LogLevel): boolean {
|
|
83
|
+
return level >= minLevel
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get all log levels as array (excluding NONE)
|
|
88
|
+
*/
|
|
89
|
+
export function getLogLevels(): LogLevel[] {
|
|
90
|
+
return [LogLevel.DEBUG, LogLevel.INFO, LogLevel.WARN, LogLevel.ERROR]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get log level display name
|
|
95
|
+
*/
|
|
96
|
+
export function getLogLevelName(level: LogLevel): string {
|
|
97
|
+
const names: Record<LogLevel, string> = {
|
|
98
|
+
[LogLevel.DEBUG]: 'Debug',
|
|
99
|
+
[LogLevel.INFO]: 'Info',
|
|
100
|
+
[LogLevel.WARN]: 'Warning',
|
|
101
|
+
[LogLevel.ERROR]: 'Error',
|
|
102
|
+
[LogLevel.NONE]: 'None',
|
|
103
|
+
}
|
|
104
|
+
return names[level] ?? 'Unknown'
|
|
105
|
+
}
|