@talex-touch/utils 1.0.42 → 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.
Files changed (233) 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 +2670 -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 +9 -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 +73 -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 +620 -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 +139 -0
  194. package/transport/main.ts +2 -0
  195. package/transport/sdk/constants.ts +29 -0
  196. package/transport/sdk/domains/agents-market.ts +47 -0
  197. package/transport/sdk/domains/agents.ts +62 -0
  198. package/transport/sdk/domains/app.ts +48 -0
  199. package/transport/sdk/domains/disposable.ts +35 -0
  200. package/transport/sdk/domains/download.ts +139 -0
  201. package/transport/sdk/domains/index.ts +13 -0
  202. package/transport/sdk/domains/intelligence.ts +616 -0
  203. package/transport/sdk/domains/market.ts +35 -0
  204. package/transport/sdk/domains/notification.ts +62 -0
  205. package/transport/sdk/domains/permission.ts +85 -0
  206. package/transport/sdk/domains/platform.ts +19 -0
  207. package/transport/sdk/domains/plugin.ts +144 -0
  208. package/transport/sdk/domains/settings.ts +92 -0
  209. package/transport/sdk/domains/update.ts +64 -0
  210. package/transport/sdk/index.ts +60 -0
  211. package/transport/sdk/main-transport.ts +710 -0
  212. package/transport/sdk/main.ts +9 -0
  213. package/transport/sdk/plugin-transport.ts +654 -0
  214. package/transport/sdk/port-policy.ts +38 -0
  215. package/transport/sdk/renderer-transport.ts +1165 -0
  216. package/transport/types.ts +605 -0
  217. package/types/agent.ts +399 -0
  218. package/types/cloud-sync.ts +157 -0
  219. package/types/division-box.ts +31 -31
  220. package/types/download.ts +1 -0
  221. package/types/flow.ts +63 -12
  222. package/types/icon.ts +2 -1
  223. package/types/index.ts +5 -0
  224. package/types/intelligence.ts +166 -173
  225. package/types/modules/base.ts +2 -0
  226. package/types/path-browserify.d.ts +5 -0
  227. package/types/platform.ts +12 -0
  228. package/types/startup-info.ts +32 -0
  229. package/types/touch-app-core.ts +8 -8
  230. package/types/update.ts +94 -1
  231. package/vitest.config.ts +25 -0
  232. package/auth/useClerkConfig.ts +0 -40
  233. 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
+ }
@@ -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
- intervalId: NodeJS.Timeout | null
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
- intervalId: null,
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.intervalId) {
93
- clearInterval(animationState.intervalId)
94
- animationState.intervalId = null
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
- animationState.intervalId = setInterval(() => {
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.intervalId) {
114
- clearInterval(animationState.intervalId)
115
- animationState.intervalId = null
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.intervalId) {
131
- clearInterval(animationState.intervalId)
132
- animationState.intervalId = null
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.intervalId) {
148
- clearInterval(animationState.intervalId)
149
- animationState.intervalId = null
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.intervalId) {
191
- clearInterval(animationState.intervalId)
192
- animationState.intervalId = null
197
+ if (animationState.taskId) {
198
+ pollingService.unregister(animationState.taskId)
199
+ animationState.taskId = null
193
200
  }
194
201
 
195
202
  // Set new window
@@ -1,21 +1,20 @@
1
- export interface ClerkUser {
1
+ export interface AuthUser {
2
2
  id: string
3
- emailAddresses: Array<{
4
- emailAddress: string
5
- id: string
6
- }>
7
- firstName?: string
8
- lastName?: string
9
- username?: string
10
- imageUrl?: string
11
- createdAt: string
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 ClerkAuthState {
14
+ export interface AuthState {
16
15
  isLoaded: boolean
17
16
  isSignedIn: boolean
18
- user: ClerkUser | null
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
@@ -1,4 +1,2 @@
1
1
  export * from './clerk-types'
2
2
  export * from './useAuthState'
3
- export * from './useClerkConfig'
4
- export * from './useClerkProvider'
@@ -1,9 +1,9 @@
1
- import type { ClerkAuthState, CurrentUser } from './clerk-types'
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<ClerkAuthState>({
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 { firstName, lastName, username, imageUrl } = authState.user
25
- let name = ''
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: imageUrl,
40
- provider: 'clerk',
31
+ avatar: authState.user.avatar || undefined,
32
+ provider: 'nexus',
41
33
  }
42
34
  })
43
35
 
package/base/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from './log-level'
2
+
1
3
  export type Arch = 'x64' | 'x86' | 'arm' | 'arm64'
2
4
 
3
5
  export type OS = 'Win' | 'Darwin' | 'Linux' | 'Android' | 'iOS' | 'ipadOS' | 'web' | 'watchOS' | 'tvOS' | 'wearOS' | 'visionOS'
@@ -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
+ }