@webmcp-auto-ui/ui 2.5.29 → 2.5.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webmcp-auto-ui/ui",
3
- "version": "2.5.29",
3
+ "version": "2.5.30",
4
4
  "description": "Svelte 5 UI components — primitives, widgets, window manager",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "type": "module",
@@ -207,12 +207,15 @@ function walk(node: Node): void {
207
207
  // via turndown on input (debounced) and at blur.
208
208
  // ---------------------------------------------------------------------------
209
209
 
210
- // @ts-ignore — turndown ships its own types but we stay ts-nocheck here
211
- import TurndownService from 'turndown';
212
-
210
+ // turndown is loaded lazily (browser-only). Top-level import breaks SSR because
211
+ // turndown's CJS internals use require() which throws in ESM scope.
213
212
  let _td: any = null;
214
- function td(): any {
213
+ async function ensureTd(): Promise<any> {
215
214
  if (_td) return _td;
215
+ if (typeof window === 'undefined') return null;
216
+ // @ts-ignore — turndown ships its own types but we stay ts-nocheck here
217
+ const mod = await import('turndown');
218
+ const TurndownService = mod.default || mod;
216
219
  _td = new TurndownService({
217
220
  headingStyle: 'atx',
218
221
  hr: '---',
@@ -230,8 +233,11 @@ function td(): any {
230
233
  return _td;
231
234
  }
232
235
 
233
- function htmlToMd(html: string): string {
234
- try { return td().turndown(html || ''); } catch { return ''; }
236
+ async function htmlToMd(html: string): Promise<string> {
237
+ try {
238
+ const t = await ensureTd();
239
+ return t ? t.turndown(html || '') : '';
240
+ } catch { return ''; }
235
241
  }
236
242
 
237
243
  function ensureToolbarStyles(): void {
@@ -442,9 +448,9 @@ export function mountEditableProse(opts: {
442
448
  flushToMd();
443
449
  }, 400);
444
450
  };
445
- const flushToMd = () => {
451
+ const flushToMd = async () => {
446
452
  const html = host.innerHTML;
447
- const md = htmlToMd(html);
453
+ const md = await htmlToMd(html);
448
454
  opts.setContent(md);
449
455
  opts.onChange?.();
450
456
  updateEmptyState(host);
@@ -491,10 +497,11 @@ export function mountEditableProse(opts: {
491
497
  if (html) {
492
498
  e.preventDefault();
493
499
  // Strip inline styles by routing via turndown → re-render via our MD pipeline
494
- const md = htmlToMd(html);
495
- const cleanHtml = renderProse(md);
496
- document.execCommand('insertHTML', false, cleanHtml);
497
- scheduleSync();
500
+ htmlToMd(html).then((md) => {
501
+ const cleanHtml = renderProse(md);
502
+ document.execCommand('insertHTML', false, cleanHtml);
503
+ scheduleSync();
504
+ });
498
505
  } else if (text) {
499
506
  // Plain text paste — default behaviour fine, but still trigger sync
500
507
  scheduleSync();