@ai-wendao/ant 0.5.1 → 0.5.2

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 (2) hide show
  1. package/client.js +36 -14
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -3099,6 +3099,9 @@ window.__ModuleLoader__.load({
3099
3099
  const originalHeadlines = new Map()
3100
3100
  let headlineObserver = null
3101
3101
  let applied = null
3102
+ let timer = null
3103
+ let retryTimer = null
3104
+ let disposed = false
3102
3105
  const isHeroHeadlineNode = (node) => {
3103
3106
  let container = node?.parentElement
3104
3107
  const compact = (value) => value?.replace(/\s+/gu, '') || ''
@@ -3121,7 +3124,7 @@ window.__ModuleLoader__.load({
3121
3124
  slotDisposers.get(name)?.()
3122
3125
  slotDisposers.delete(name); slotValues.delete(name)
3123
3126
  if (!value) return
3124
- const dispose = ctx.slots.inject(name, () => ctx.slots.register({ name }, component))
3127
+ const dispose = ctx.slots.inject(name, () => ctx.slots.register({ name, priority: -1 }, component))
3125
3128
  slotDisposers.set(name, dispose); slotValues.set(name, value)
3126
3129
  }
3127
3130
  const replaceHeadlineNode = (node) => {
@@ -3147,6 +3150,15 @@ window.__ModuleLoader__.load({
3147
3150
  }
3148
3151
  const updateHeadline = (records = null) => {
3149
3152
  if (typeof document === 'undefined' || !document.body) return
3153
+ if (!applied?.headline) {
3154
+ for (const [node, prior] of originalHeadlines) {
3155
+ if (node.textContent?.trim() === prior.current) {
3156
+ node.textContent = prior.original
3157
+ originalHeadlines.delete(node)
3158
+ }
3159
+ }
3160
+ return
3161
+ }
3150
3162
  if (!records) { replaceHeadlineSubtree(document.body); return }
3151
3163
  for (const record of records) {
3152
3164
  if (record.type === 'characterData') replaceHeadlineNode(record.target)
@@ -3156,7 +3168,6 @@ window.__ModuleLoader__.load({
3156
3168
  }
3157
3169
  const apply = (value) => {
3158
3170
  const branding = normalizeBranding(value)
3159
- const previousHeadline = applied?.headline
3160
3171
  applied = branding ? { ...branding } : null
3161
3172
  const logo = branding?.logo_data_url || null
3162
3173
  const nameValue = branding && (branding.wordmark || branding.badge)
@@ -3177,11 +3188,29 @@ window.__ModuleLoader__.load({
3177
3188
  }
3178
3189
  updateHeadline()
3179
3190
  }
3180
- apply(readBrandingCache())
3191
+
3192
+ const cleanup = () => {
3193
+ if (disposed) return
3194
+ disposed = true
3195
+ if (timer !== null) clearInterval(timer)
3196
+ if (retryTimer !== null) clearTimeout(retryTimer)
3197
+ headlineObserver?.disconnect()
3198
+ for (const [node, prior] of originalHeadlines) {
3199
+ if (node.textContent?.trim() === prior.current) node.textContent = prior.original
3200
+ }
3201
+ for (const dispose of slotDisposers.values()) dispose?.()
3202
+ }
3203
+
3204
+ try {
3205
+ apply(readBrandingCache())
3206
+ } catch (error) {
3207
+ cleanup()
3208
+ console.warn('ANT branding setup failed; continuing with the default DSH branding.', error)
3209
+ return cleanup
3210
+ }
3211
+
3181
3212
  let etag = applied?.revision ? `"${applied.revision}"` : null
3182
3213
  let retryCount = 0
3183
- let retryTimer = null
3184
- let disposed = false
3185
3214
  const refresh = async () => {
3186
3215
  if (disposed) return
3187
3216
  let retryable = true
@@ -3223,15 +3252,8 @@ window.__ModuleLoader__.load({
3223
3252
  }
3224
3253
  }
3225
3254
  void refresh()
3226
- const timer = setInterval(() => void refresh(), 5 * 60 * 1000)
3227
- return () => {
3228
- disposed = true
3229
- clearInterval(timer); clearTimeout(retryTimer); headlineObserver?.disconnect()
3230
- for (const [node, prior] of originalHeadlines) {
3231
- if (node.textContent?.trim() === prior.current) node.textContent = prior.original
3232
- }
3233
- for (const dispose of slotDisposers.values()) dispose?.()
3234
- }
3255
+ timer = setInterval(() => void refresh(), 5 * 60 * 1000)
3256
+ return cleanup
3235
3257
  }
3236
3258
 
3237
3259
  function apply(ctx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-wendao/ant",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "ANT (AI-native Teams) connects a DeepSeek Harness Desktop profile to team identity and approved models.",
5
5
  "type": "module",
6
6
  "scripts": {