@takazudo/zudo-doc 5.5.3 → 5.7.0

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 (83) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +39 -0
  3. package/dist/chrome/derive.d.ts +46 -0
  4. package/dist/chrome/derive.js +6 -2
  5. package/dist/config-assertions/index.d.ts +31 -0
  6. package/dist/config-assertions/index.js +24 -0
  7. package/dist/config.d.ts +23 -2
  8. package/dist/config.js +3 -0
  9. package/dist/current-path/index.d.ts +27 -0
  10. package/dist/current-path/index.js +11 -0
  11. package/dist/design-token-panel-bootstrap.d.ts +89 -23
  12. package/dist/design-token-panel-bootstrap.js +19 -6
  13. package/dist/doc-page-props/index.d.ts +5 -67
  14. package/dist/doc-route-entries/index.d.ts +10 -95
  15. package/dist/doc-route-entries/index.js +1 -78
  16. package/dist/doc-route-paths/index.d.ts +1 -1
  17. package/dist/head-with-defaults/index.d.ts +3 -1
  18. package/dist/head-with-defaults/index.js +76 -4
  19. package/dist/header/nav-active.d.ts +31 -0
  20. package/dist/header/nav-active.js +2 -1
  21. package/dist/header/nav-overflow-generated-script.d.ts +11 -0
  22. package/dist/header/nav-overflow-generated-script.js +302 -0
  23. package/dist/header/nav-overflow-script.d.ts +1 -1
  24. package/dist/header/nav-overflow-script.js +1 -286
  25. package/dist/header-with-defaults/index.js +11 -2
  26. package/dist/i18n-version/language-switcher.d.ts +6 -0
  27. package/dist/i18n-version/language-switcher.js +3 -1
  28. package/dist/i18n-version/version-switcher.d.ts +6 -0
  29. package/dist/i18n-version/version-switcher.js +3 -1
  30. package/dist/md-utils/index.js +33 -1
  31. package/dist/nav-source-docs/index.d.ts +7 -11
  32. package/dist/plugins/route-pages-candidates.d.ts +19 -0
  33. package/dist/plugins/route-pages-candidates.js +17 -0
  34. package/dist/plugins/routes.d.ts +46 -0
  35. package/dist/plugins/routes.js +72 -18
  36. package/dist/preset.d.ts +12 -1
  37. package/dist/preset.js +2 -0
  38. package/dist/route-context/index.js +2 -2
  39. package/dist/routes/_chrome.d.ts +1 -1
  40. package/dist/routes/_chrome.js +4 -0
  41. package/dist/routes/_context.d.ts +3 -3
  42. package/dist/routes/_design-token-panel-bootstrap.d.ts +18 -0
  43. package/dist/routes/_design-token-panel-bootstrap.js +11 -0
  44. package/dist/routes/_docs-helpers.d.ts +1 -36
  45. package/dist/routes/_docs-helpers.js +0 -138
  46. package/dist/safelist.css +1 -1
  47. package/dist/search-widget-script/generated-script.d.ts +8 -0
  48. package/dist/search-widget-script/generated-script.js +465 -0
  49. package/dist/search-widget-script/index.d.ts +1 -18
  50. package/dist/search-widget-script/index.js +1 -443
  51. package/dist/settings.d.ts +82 -1
  52. package/dist/sidebar-toggle-island/index.js +2 -1
  53. package/dist/sidebar-tree/category-meta.d.ts +9 -0
  54. package/dist/sidebar-tree/category-meta.js +21 -12
  55. package/dist/sidebar-tree-island/index.d.ts +8 -1
  56. package/dist/sidebar-tree-island/index.js +16 -14
  57. package/dist/site-schema/doc-route-entries.d.ts +89 -0
  58. package/dist/site-schema/doc-route-entries.js +83 -0
  59. package/dist/site-schema/index.d.ts +17 -0
  60. package/dist/site-schema/index.js +46 -0
  61. package/dist/site-schema/nav-tree.d.ts +28 -0
  62. package/dist/site-schema/nav-tree.js +138 -0
  63. package/dist/site-schema/types.d.ts +97 -0
  64. package/dist/site-schema/types.js +0 -0
  65. package/dist/theme/theme-pack-provider.d.ts +34 -3
  66. package/dist/theme/theme-pack-provider.js +30 -2
  67. package/dist/transitions/index.d.ts +1 -0
  68. package/dist/transitions/index.js +2 -0
  69. package/dist/transitions/nested-island-props-refresh.d.ts +19 -0
  70. package/dist/transitions/nested-island-props-refresh.js +104 -0
  71. package/eject/header/header.tsx +13 -5
  72. package/eject/header/nav-active.ts +16 -1
  73. package/eject/header/nav-class-tokens.ts +9 -5
  74. package/eject/header/nav-overflow-generated-script.ts +29 -0
  75. package/eject/header/nav-overflow-script.ts +26 -304
  76. package/eject/sidebar-toggle-island/index.tsx +13 -1
  77. package/eject/sidebar-tree-island/index.tsx +44 -20
  78. package/package.json +25 -12
  79. package/routes-src/_chrome.tsx +21 -9
  80. package/routes-src/_design-token-panel-bootstrap.tsx +63 -0
  81. package/routes-src/_docs-helpers.ts +18 -225
  82. package/routes-src/_virtual.d.ts +5 -2
  83. package/virtual-modules.d.ts +5 -2
@@ -0,0 +1,465 @@
1
+ function buildSearchWidgetScript() {
2
+ return `(function () {
3
+ if (customElements.get("site-search")) return; // guard double-registration
4
+
5
+ var PAGE_SIZE = 10;
6
+
7
+ // Allowlist-based href sanitizer: only relative paths and http(s) URLs are
8
+ // permitted. Anything else (e.g. javascript:, data:) falls back to "#" so a
9
+ // malicious entry in search-index.json cannot turn a result link into a
10
+ // script-injection vector.
11
+ function safeHref(url) {
12
+ if (!url) return "#";
13
+ var s = String(url);
14
+ if (s.startsWith("/") || s.startsWith("http://") || s.startsWith("https://")) {
15
+ return s;
16
+ }
17
+ return "#";
18
+ }
19
+
20
+ function escapeHtml(text) {
21
+ return String(text)
22
+ .replace(/&/g, "&")
23
+ .replace(/</g, "&lt;")
24
+ .replace(/>/g, "&gt;")
25
+ .replace(/"/g, "&quot;")
26
+ .replace(/'/g, "&#39;");
27
+ }
28
+
29
+ function escapeRegExp(text) {
30
+ return text.replace(/[.*+?^\${}()|[\\]\\\\]/g, "\\\\$&");
31
+ }
32
+
33
+ function parseTerms(query) {
34
+ return query.trim().split(/\\s+/).filter(Boolean);
35
+ }
36
+
37
+ // scoreEntry / prepareLc: embedded verbatim (via Function.prototype.toString(),
38
+ // captured once at package build time by scripts/gen-search-widget-script.mjs)
39
+ // from the real, unit-tested implementation in ./scoring.ts \u2014 see the module
40
+ // header comment there and search-widget-script/__tests__/scoring.test.ts.
41
+ // This keeps the shipped inline script and the tested source identical by
42
+ // construction instead of relying on a hand-copied mirror staying in sync.
43
+ function prepareLc(entries) {
44
+ for (var i = 0; i < entries.length; i++) {
45
+ var e = entries[i];
46
+ e._titleLc = (e.title || "").toLowerCase();
47
+ e._descLc = (e.description || "").toLowerCase();
48
+ e._bodyLc = (e.body || "").toLowerCase();
49
+ }
50
+ }
51
+
52
+ function scoreEntry(entry, terms) {
53
+ var score = 0;
54
+ var titleLc = entry._titleLc;
55
+ var descLc = entry._descLc;
56
+ var bodyLc = entry._bodyLc;
57
+ for (var i = 0; i < terms.length; i++) {
58
+ var t = terms[i];
59
+ if (titleLc.indexOf(t) !== -1) score += 3;
60
+ if (descLc.indexOf(t) !== -1) score += 2;
61
+ if (bodyLc.indexOf(t) !== -1) score += 1;
62
+ }
63
+ return score;
64
+ }
65
+
66
+ function highlightTerms(text, terms) {
67
+ if (!terms.length) return escapeHtml(text);
68
+ var escaped = terms.map(function(t) { return escapeRegExp(t); });
69
+ var pattern = new RegExp("(" + escaped.join("|") + ")", "gi");
70
+ return text.split(pattern).map(function(seg, i) {
71
+ return i % 2 === 1
72
+ ? "<mark>" + escapeHtml(seg) + "</mark>"
73
+ : escapeHtml(seg);
74
+ }).join("");
75
+ }
76
+
77
+ function truncate(text, query, max) {
78
+ max = max || 200;
79
+ if (text.length <= max) return text;
80
+ var terms = parseTerms(query);
81
+ var lower = text.toLowerCase();
82
+ var best = -1;
83
+ for (var i = 0; i < terms.length; i++) {
84
+ var idx = lower.indexOf(terms[i].toLowerCase());
85
+ if (idx !== -1 && (best === -1 || idx < best)) best = idx;
86
+ }
87
+ if (best === -1) return text.slice(0, max) + "\\u2026";
88
+ var half = Math.floor(max / 2);
89
+ var start = Math.max(0, best - half);
90
+ var end = start + max;
91
+ if (end > text.length) { end = text.length; start = Math.max(0, end - max); }
92
+ var result = text.slice(start, end);
93
+ if (start > 0) result = "\\u2026" + result;
94
+ if (end < text.length) result += "\\u2026";
95
+ return result;
96
+ }
97
+
98
+ customElements.define("site-search", class SiteSearch extends HTMLElement {
99
+ constructor() {
100
+ super();
101
+ this._dialog = null;
102
+ this._openBtn = null;
103
+ this._closeBtn = null;
104
+ this._input = null;
105
+ this._results = null;
106
+ this._countWide = null;
107
+ this._countNarrow = null;
108
+ this._entries = null;
109
+ this._loading = false;
110
+ this._indexUnavailable = false;
111
+ this._debounce = null;
112
+ this._currentQuery = "";
113
+ this._allResults = [];
114
+ this._shownCount = 0;
115
+ this._shortcut = "";
116
+ this._resultCountTemplate = "";
117
+ // Locale-aware status strings (threaded from the SSR component via
118
+ // data-* attributes, same mechanism as _resultCountTemplate). English
119
+ // literals below in connectedCallback are fallbacks only.
120
+ this._searchUnavailable = "";
121
+ this._loadingIndex = "";
122
+ this._noResults = "";
123
+ this._keydownHandler = null;
124
+ // Delegated click handler on the results container: closing the dialog
125
+ // when a result link is activated (epic #2148). Held so disconnectedCallback
126
+ // can detach it on body swap.
127
+ this._resultsClickHandler = null;
128
+ this._observer = null;
129
+ this._sentinel = null;
130
+ this._isLoadingBatch = false;
131
+ // Snapshot of the initial results-area HTML (includes SSR placeholder).
132
+ // Captured in connectedCallback so we can restore it on input-clear
133
+ // without re-querying the DOM (the placeholder node is replaced once
134
+ // search results are rendered).
135
+ this._placeholderHtml = "";
136
+ // Held so we can remove the document-level after-navigate listener
137
+ // in disconnectedCallback. zudolab/zudo-doc#1523 \u2014 under Strategy B
138
+ // SPA navigation a non-persisted <site-search> element would leak
139
+ // one document listener per nav without this hook.
140
+ this._afterNavHandler = null;
141
+ }
142
+
143
+ connectedCallback() {
144
+ this._dialog = this.querySelector("[data-search-dialog]");
145
+ this._openBtn = this.querySelector("[data-open-search]");
146
+ this._closeBtn = this.querySelector("[data-close-search]");
147
+ this._input = this.querySelector("[data-search-input]");
148
+ this._results = this.querySelector("[data-search-results]");
149
+ this._countWide = this.querySelector("[data-search-count]");
150
+ this._countNarrow = this.querySelector("[data-search-count-narrow]");
151
+ this._resultCountTemplate = this.dataset.resultCountTemplate || "{count} results";
152
+ this._searchUnavailable = this.dataset.searchUnavailable || "Search unavailable";
153
+ this._loadingIndex = this.dataset.loadingIndex || "Loading search index\\u2026";
154
+ this._noResults = this.dataset.noResults || "No results found.";
155
+ // Snapshot the placeholder HTML before any search renders overwrite it.
156
+ this._placeholderHtml = this._results ? this._results.innerHTML : "";
157
+
158
+ // Platform keyboard-shortcut label \u2014 injected into [data-kbd-shortcut]
159
+ var nav = navigator;
160
+ var isMac = /Mac|iPhone|iPad|iPod/.test(
161
+ (nav.userAgentData && nav.userAgentData.platform) || nav.userAgent
162
+ );
163
+ this._shortcut = isMac ? "\\u2318K" : "Ctrl+K";
164
+ var kbdEl = this.querySelector("[data-kbd-shortcut]");
165
+ if (kbdEl) kbdEl.textContent = this._shortcut;
166
+
167
+ // Wire open/close handlers
168
+ var self = this;
169
+ if (this._openBtn) {
170
+ this._openBtn.addEventListener("click", function() { self.openDialog(); });
171
+ }
172
+ if (this._closeBtn) {
173
+ this._closeBtn.addEventListener("click", function() { self.closeDialog(); });
174
+ }
175
+ if (this._dialog) {
176
+ this._dialog.addEventListener("close", function() {
177
+ document.documentElement.style.overflow = "";
178
+ });
179
+ this._dialog.addEventListener("click", function(e) {
180
+ if (e.target === self._dialog) self.closeDialog();
181
+ });
182
+ }
183
+ if (this._input) {
184
+ this._input.addEventListener("input", function() { self.handleInput(); });
185
+ }
186
+
187
+ // Close-on-result-click (epic #2148): result links are created dynamically
188
+ // in renderResult(), so use one delegated listener on the results container
189
+ // instead of per-link handlers. We do NOT preventDefault \u2014 the link's own
190
+ // navigation (zfb Strategy-B SPA swap or a plain load) must still proceed;
191
+ // we only close the <dialog> so it does not linger over the swapped page.
192
+ // closeDialog() runs synchronously before navigation; the dialog's close
193
+ // restores documentElement overflow via the existing "close" listener.
194
+ if (this._results) {
195
+ this._resultsClickHandler = function(e) {
196
+ var t = e.target;
197
+ while (t && t !== self._results) {
198
+ if (t.tagName === "A") { self.closeDialog(); return; }
199
+ t = t.parentNode;
200
+ }
201
+ };
202
+ this._results.addEventListener("click", this._resultsClickHandler);
203
+ }
204
+
205
+ // Global keyboard shortcut (\u2318K / Ctrl+K to open)
206
+ this._keydownHandler = function(e) {
207
+ if ((e.metaKey || e.ctrlKey) && e.key === "k") {
208
+ e.preventDefault();
209
+ self.openDialog();
210
+ }
211
+ };
212
+ document.addEventListener("keydown", this._keydownHandler);
213
+
214
+ // View-Transitions compat: re-run on the v2 after-navigate event.
215
+ // Stored on the instance so disconnectedCallback can detach it on
216
+ // body swap when this element is NOT persisted via
217
+ // data-zfb-transition-persist (zudolab/zudo-doc#1523).
218
+ this._afterNavHandler = function() {
219
+ // Backstop for the original bug (epic #2148): if the dialog is somehow
220
+ // still open after an SPA body swap (e.g. a nav path that bypassed the
221
+ // result-click handler), close it so it does not linger / flash over the
222
+ // newly-swapped page. Safe no-op when already closed.
223
+ if (self._dialog && self._dialog.open) self.closeDialog();
224
+ var kbdEl2 = self.querySelector("[data-kbd-shortcut]");
225
+ if (kbdEl2) kbdEl2.textContent = self._shortcut;
226
+ };
227
+ document.addEventListener("zfb:after-swap", this._afterNavHandler);
228
+ }
229
+
230
+ disconnectedCallback() {
231
+ if (this._keydownHandler) {
232
+ document.removeEventListener("keydown", this._keydownHandler);
233
+ this._keydownHandler = null;
234
+ }
235
+ if (this._afterNavHandler) {
236
+ document.removeEventListener("zfb:after-swap", this._afterNavHandler);
237
+ this._afterNavHandler = null;
238
+ }
239
+ if (this._resultsClickHandler && this._results) {
240
+ this._results.removeEventListener("click", this._resultsClickHandler);
241
+ this._resultsClickHandler = null;
242
+ }
243
+ this.teardownSentinel();
244
+ }
245
+
246
+ openDialog() {
247
+ if (!this._dialog) return;
248
+ document.documentElement.style.overflow = "hidden";
249
+ this._dialog.showModal();
250
+ if (this._input) {
251
+ this._input.focus();
252
+ this._input.select();
253
+ }
254
+ if (!this._entries && !this._loading) {
255
+ this.loadIndex();
256
+ }
257
+ }
258
+
259
+ closeDialog() {
260
+ if (!this._dialog) return;
261
+ this._dialog.close();
262
+ document.documentElement.style.overflow = "";
263
+ }
264
+
265
+ handleInput() {
266
+ var self = this;
267
+ if (this._debounce) clearTimeout(this._debounce);
268
+ this._debounce = setTimeout(function() { self.search(); }, 150);
269
+ }
270
+
271
+ loadIndex() {
272
+ if (this._loading) return;
273
+ this._loading = true;
274
+ var self = this;
275
+ var base = this.dataset.base || "/";
276
+ fetch(base + "search-index.json")
277
+ .then(function(r) {
278
+ if (!r.ok) throw new Error("HTTP " + r.status);
279
+ return r.json();
280
+ })
281
+ .then(function(data) {
282
+ self._entries = Array.isArray(data) ? data : (data.entries || []);
283
+ prepareLc(self._entries);
284
+ self._loading = false;
285
+ // Clear the unavailable flag BEFORE re-running search so a successful
286
+ // retry (e.g. via the openDialog() reload path) fully recovers (#2062).
287
+ self._indexUnavailable = false;
288
+ // If user already typed, search now
289
+ if (self._input && self._input.value.trim()) {
290
+ self.search();
291
+ }
292
+ })
293
+ .catch(function() {
294
+ self._loading = false;
295
+ self._indexUnavailable = true;
296
+ if (self._results) {
297
+ self._results.innerHTML = "<p class=\\"text-small text-muted\\">" + escapeHtml(self._searchUnavailable) + "</p>";
298
+ }
299
+ });
300
+ }
301
+
302
+ search() {
303
+ var query = this._input ? this._input.value.trim() : "";
304
+ this._currentQuery = query;
305
+
306
+ if (!query) {
307
+ this.teardownSentinel();
308
+ this._allResults = [];
309
+ this._shownCount = 0;
310
+ if (this._results) this._results.innerHTML = this.placeholderHtml();
311
+ this.updateCount();
312
+ return;
313
+ }
314
+
315
+ if (!this._entries) {
316
+ // Index failed to load: show the terminal "Search unavailable" state and
317
+ // stop \u2014 do NOT show "Loading search index\u2026" or refetch on every
318
+ // keystroke (#2062). The openDialog() reload path is the intended retry
319
+ // trigger. Clear any stale result state/count/sentinel first.
320
+ if (this._indexUnavailable) {
321
+ this.teardownSentinel();
322
+ this._allResults = [];
323
+ this._shownCount = 0;
324
+ if (this._results) {
325
+ this._results.innerHTML = "<p class=\\"text-small text-muted\\">" + escapeHtml(this._searchUnavailable) + "</p>";
326
+ }
327
+ this.updateCount();
328
+ return;
329
+ }
330
+ if (this._results) {
331
+ this._results.innerHTML = "<p class=\\"text-small text-muted\\">" + escapeHtml(this._loadingIndex) + "</p>";
332
+ }
333
+ if (!this._loading) this.loadIndex();
334
+ return;
335
+ }
336
+
337
+ // Lowercase the query terms once here so scoreEntry() can do plain
338
+ // indexOf() against pre-lowercased entry fields without repeating
339
+ // toLowerCase() across the entire index on every keystroke.
340
+ var terms = parseTerms(query).map(function(t) { return t.toLowerCase(); });
341
+ var scored = [];
342
+ for (var i = 0; i < this._entries.length; i++) {
343
+ var s = scoreEntry(this._entries[i], terms);
344
+ if (s > 0) scored.push({ entry: this._entries[i], score: s });
345
+ }
346
+ scored.sort(function(a, b) { return b.score - a.score; });
347
+ this._allResults = scored;
348
+ this._shownCount = 0;
349
+ this.teardownSentinel();
350
+ this.updateCount();
351
+
352
+ if (!scored.length) {
353
+ if (this._results) {
354
+ this._results.innerHTML = "<p class=\\"text-small text-muted\\">" + escapeHtml(this._noResults) + "</p>";
355
+ }
356
+ return;
357
+ }
358
+
359
+ if (this._results) this._results.innerHTML = "";
360
+ this.loadMore();
361
+ if (this._shownCount < this._allResults.length) {
362
+ this.setupSentinel();
363
+ }
364
+ }
365
+
366
+ loadMore() {
367
+ if (this._isLoadingBatch) return;
368
+ if (this._shownCount >= this._allResults.length) return;
369
+ this._isLoadingBatch = true;
370
+ try {
371
+ var batch = this._allResults.slice(this._shownCount, this._shownCount + PAGE_SIZE);
372
+ var self = this;
373
+ for (var i = 0; i < batch.length; i++) {
374
+ var article = self.renderResult(batch[i].entry);
375
+ if (self._sentinel && self._sentinel.parentNode === self._results) {
376
+ self._results.insertBefore(article, self._sentinel);
377
+ } else if (self._results) {
378
+ self._results.appendChild(article);
379
+ }
380
+ }
381
+ this._shownCount += batch.length;
382
+ if (this._shownCount >= this._allResults.length) {
383
+ this.teardownSentinel();
384
+ }
385
+ } finally {
386
+ this._isLoadingBatch = false;
387
+ }
388
+ }
389
+
390
+ setupSentinel() {
391
+ this.teardownSentinel();
392
+ if (!this._results) return;
393
+ var sentinel = document.createElement("div");
394
+ sentinel.setAttribute("data-search-sentinel", "");
395
+ sentinel.setAttribute("aria-hidden", "true");
396
+ sentinel.style.height = "1px";
397
+ sentinel.style.width = "100%";
398
+ this._results.appendChild(sentinel);
399
+ this._sentinel = sentinel;
400
+ var self = this;
401
+ this._observer = new IntersectionObserver(function(entries) {
402
+ for (var i = 0; i < entries.length; i++) {
403
+ if (entries[i].isIntersecting) self.loadMore();
404
+ }
405
+ }, { root: this._results, rootMargin: "200px 0px" });
406
+ this._observer.observe(sentinel);
407
+ }
408
+
409
+ teardownSentinel() {
410
+ if (this._observer) { this._observer.disconnect(); this._observer = null; }
411
+ if (this._sentinel) { this._sentinel.remove(); this._sentinel = null; }
412
+ }
413
+
414
+ updateCount() {
415
+ var count = this._allResults.length;
416
+ var template = this._resultCountTemplate;
417
+ var text = count > 0 ? template.replace("{count}", String(count)) : "";
418
+ var show = !!text;
419
+ if (this._countWide) {
420
+ this._countWide.textContent = text;
421
+ this._countWide.classList.toggle("hidden", !show);
422
+ }
423
+ if (this._countNarrow) {
424
+ this._countNarrow.textContent = text;
425
+ this._countNarrow.classList.toggle("hidden", !show);
426
+ }
427
+ }
428
+
429
+ placeholderHtml() {
430
+ return this._placeholderHtml;
431
+ }
432
+
433
+ renderResult(entry) {
434
+ var article = document.createElement("article");
435
+ article.className = "-mx-hsp-lg border-b border-muted";
436
+ var link = document.createElement("a");
437
+ link.href = safeHref(entry.url);
438
+ link.className =
439
+ "group block px-hsp-lg py-vsp-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent";
440
+ var title = document.createElement("span");
441
+ title.className =
442
+ "font-semibold text-fg group-hover:text-accent group-hover:underline group-focus-visible:underline";
443
+ var terms = parseTerms(this._currentQuery);
444
+ title.innerHTML = highlightTerms(entry.title || "", terms);
445
+ link.appendChild(title);
446
+ var text = entry.description || entry.body;
447
+ if (text) {
448
+ var excerpt = document.createElement("p");
449
+ excerpt.className =
450
+ "mt-vsp-2xs text-caption text-muted leading-relaxed group-hover:underline group-focus-visible:underline decoration-muted";
451
+ var truncated = truncate(text, this._currentQuery, 200);
452
+ excerpt.innerHTML = highlightTerms(truncated, terms);
453
+ link.appendChild(excerpt);
454
+ }
455
+ article.appendChild(link);
456
+ return article;
457
+ }
458
+ });
459
+ })();`;
460
+ }
461
+ const SEARCH_WIDGET_SCRIPT = buildSearchWidgetScript();
462
+ export {
463
+ SEARCH_WIDGET_SCRIPT,
464
+ buildSearchWidgetScript
465
+ };
@@ -1,18 +1 @@
1
- /**
2
- * Client-side script string for the SiteSearch custom element.
3
- *
4
- * Emitted via `dangerouslySetInnerHTML` in `<SearchWidget>`. Plain JS IIFE
5
- * (no ES-module `import` statements) so it can be inlined in SSR output.
6
- *
7
- * Features:
8
- * - Dialog open/close (button, backdrop click, Escape key)
9
- * - ⌘K / Ctrl+K global keyboard shortcut
10
- * - Lazy-fetch of `search-index.json`
11
- * - Built-in word-match scoring (pre-lowercased `_titleLc/_descLc/_bodyLc`)
12
- * - Result highlighting with `<mark>` and text truncation
13
- * - Infinite scroll via `IntersectionObserver` (PAGE_SIZE=10)
14
- * - Close-on-result-click (epic #2148)
15
- * - SPA after-navigate rebind (`zfb:after-swap`)
16
- * - Double-registration guard (`customElements.get(...)`)
17
- */
18
- export declare const SEARCH_WIDGET_SCRIPT: string;
1
+ export { SEARCH_WIDGET_SCRIPT } from "./generated-script.js";