ysdede commited on
Commit
8a16cdb
·
1 Parent(s): 9e48a60

fix(hf-space): harden runtime loading and cache behavior

Browse files

Exclude parakeet and wink NLP modules from Vite dep optimization to avoid transient missing optimized chunks in dev/HF environments.

Clear all browser caches when running on .hf.space and tighten control-widget drag target checks to avoid click handling edge cases.

Files changed (3) hide show
  1. index.html +2 -6
  2. src/App.tsx +2 -1
  3. vite.config.js +8 -1
index.html CHANGED
@@ -41,13 +41,9 @@
41
  .then(() => {
42
  if (!('caches' in window)) return;
43
  return caches.keys()
44
- .then((keys) => Promise.all(
45
- keys
46
- .filter((k) => k.startsWith('keet-'))
47
- .map((k) => caches.delete(k))
48
- ));
49
  })
50
- .then(() => console.log('[App] SW disabled on HF Space (avoids stale chunk cache).'))
51
  .catch((err) => console.warn('[App] SW cleanup on HF failed:', err));
52
  return;
53
  }
 
41
  .then(() => {
42
  if (!('caches' in window)) return;
43
  return caches.keys()
44
+ .then((keys) => Promise.all(keys.map((k) => caches.delete(k))));
 
 
 
 
45
  })
46
+ .then(() => console.log('[App] SW disabled on HF Space (all caches cleared to avoid stale chunks).'))
47
  .catch((err) => console.warn('[App] SW cleanup on HF failed:', err));
48
  return;
49
  }
src/App.tsx CHANGED
@@ -160,7 +160,8 @@ const App: Component = () => {
160
  };
161
 
162
  const handleWidgetDragStart = (e: MouseEvent) => {
163
- if ((e.target as HTMLElement).closest('button, select, input')) return;
 
164
  e.preventDefault();
165
  const pos = widgetPos();
166
  if (!pos) return;
 
160
  };
161
 
162
  const handleWidgetDragStart = (e: MouseEvent) => {
163
+ const target = e.target;
164
+ if (target instanceof Element && target.closest('button, select, input')) return;
165
  e.preventDefault();
166
  const pos = widgetPos();
167
  if (!pos) return;
vite.config.js CHANGED
@@ -76,7 +76,14 @@ export default defineConfig({
76
  },
77
  },
78
  optimizeDeps: {
79
- exclude: ['audio-processor.js'],
 
 
 
 
 
 
 
80
  },
81
  worker: {
82
  format: 'es',
 
76
  },
77
  },
78
  optimizeDeps: {
79
+ // Keep these ESM libs out of Vite's dev pre-bundler to avoid
80
+ // intermittent missing-chunk warnings in node_modules/.vite/deps.
81
+ exclude: [
82
+ 'audio-processor.js',
83
+ 'parakeet.js',
84
+ 'wink-nlp',
85
+ 'wink-eng-lite-web-model',
86
+ ],
87
  },
88
  worker: {
89
  format: 'es',