@dooc-dev/dooc 0.0.21 → 0.0.23

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 (66) hide show
  1. package/dist/client.global.js +1 -1
  2. package/dist/edit.global.js +269 -263
  3. package/dist/engine/compiler/check.js +17 -0
  4. package/dist/engine/compiler/export.js +18 -1
  5. package/dist/engine/compiler/files.js +13 -2
  6. package/dist/engine/compiler/manifest.js +4 -0
  7. package/dist/engine/compiler/skills.d.ts +10 -0
  8. package/dist/engine/compiler/skills.js +95 -0
  9. package/dist/engine/core/content-metadata.d.ts +7 -1
  10. package/dist/engine/core/content-metadata.js +52 -18
  11. package/dist/engine/core/files.d.ts +1 -0
  12. package/dist/engine/core/files.js +3 -0
  13. package/dist/frontend/document-application.d.ts +11 -2
  14. package/dist/frontend/document-application.js +364 -133
  15. package/dist/frontend/document-links.js +31 -21
  16. package/dist/frontend/language-picker.js +1 -0
  17. package/dist/frontend/locales/eng.json +19 -2
  18. package/dist/frontend/locales/jpn.json +19 -2
  19. package/dist/frontend/locales/zho.json +19 -2
  20. package/dist/frontend/mcp-operations.js +57 -1
  21. package/dist/frontend/nav-focus.d.ts +1 -1
  22. package/dist/frontend/nav-focus.js +25 -2
  23. package/dist/frontend/nav-update.js +12 -0
  24. package/dist/frontend/page-jump.d.ts +3 -0
  25. package/dist/frontend/page-jump.js +130 -0
  26. package/dist/frontend/resource-download.d.ts +1 -1
  27. package/dist/frontend/resource-download.js +118 -28
  28. package/dist/frontend/resource-library.js +16 -7
  29. package/dist/frontend/search.js +18 -5
  30. package/dist/frontend/theme-picker.js +11 -0
  31. package/dist/manifest.global.js +349 -0
  32. package/dist/mcp-relay.mjs +71 -1
  33. package/dist/plugins.global.js +4 -4
  34. package/dist/server/assets.d.ts +1 -0
  35. package/dist/server/assets.js +4 -1
  36. package/dist/server/build-media.d.ts +6 -0
  37. package/dist/server/build-media.js +136 -0
  38. package/dist/server/build-output.d.ts +2 -1
  39. package/dist/server/build-output.js +32 -2
  40. package/dist/server/build-split.d.ts +15 -0
  41. package/dist/server/build-split.js +160 -0
  42. package/dist/server/build.d.ts +6 -1
  43. package/dist/server/build.js +37 -10
  44. package/dist/server/cli.js +20 -2
  45. package/dist/server/mcp.js +14 -1
  46. package/dist/server/serve.d.ts +21 -2
  47. package/dist/server/serve.js +26 -20
  48. package/dist/server/static-client.js +2 -1
  49. package/dist/server/workspace-server.d.ts +1 -1
  50. package/dist/server/workspace-server.js +24 -4
  51. package/dist/subformats.global.js +25 -25
  52. package/dist/ui.global.js +68 -68
  53. package/dist/workspace/client.d.ts +1 -1
  54. package/dist/workspace/client.js +22 -3
  55. package/dist/workspace/mcp-tools.js +32 -0
  56. package/dist/workspace/mcp.js +50 -1
  57. package/dist/workspace/protocol.d.ts +3 -0
  58. package/dist/workspace/server.d.ts +1 -1
  59. package/dist/workspace/server.js +14 -3
  60. package/dist/workspace/site-icon.js +17 -12
  61. package/dist/workspace/textfile.js +16 -4
  62. package/dist/workspace-mcp-worker.global.js +242 -122
  63. package/dist/workspace-reader-mcp-worker.global.js +242 -122
  64. package/dist/workspace-reader-worker.global.js +242 -122
  65. package/dist/workspace-worker.global.js +242 -122
  66. package/package.json +2 -2
@@ -1,7 +1,6 @@
1
1
  /** Self-contained so live readers and standalone HTML use the same click behavior. */
2
2
  export const mountDocumentLinks = (dialog, network = true, request) => {
3
3
  const t = (text) => window.__docsTranslate?.(text) ?? text;
4
- const mobile = () => matchMedia("(max-width: 600px), (hover: none) and (pointer: coarse)").matches;
5
4
  const webUrl = (value) => {
6
5
  if (!value)
7
6
  return;
@@ -45,7 +44,7 @@ export const mountDocumentLinks = (dialog, network = true, request) => {
45
44
  event.preventDefault();
46
45
  window.open(url, "_blank", "noopener,noreferrer");
47
46
  }
48
- else if (link.hasAttribute("data-web-open") || mobile() || !network) {
47
+ else if (link.hasAttribute("data-web-open") || !network) {
49
48
  event.preventDefault();
50
49
  void confirm(url);
51
50
  }
@@ -55,16 +54,19 @@ export const mountDocumentLinks = (dialog, network = true, request) => {
55
54
  const mounted = new WeakSet();
56
55
  const mount = () => {
57
56
  for (const host of document.querySelectorAll(".document-web[data-web-url]")) {
58
- if (mounted.has(host))
57
+ if (mounted.has(host) || host.querySelector(".document-web-frame"))
59
58
  continue;
60
59
  mounted.add(host);
61
60
  const url = webUrl(host.dataset.webUrl);
61
+ const notice = host.querySelector(".document-web-notice");
62
62
  const status = host.querySelector("[data-web-status]");
63
- if (!url || !status)
63
+ const external = host.querySelector("[data-web-open]");
64
+ if (!url || !notice || !status || !external)
64
65
  continue;
65
- if (mobile() || !network) {
66
+ if (!network) {
66
67
  status.dataset.i18n = "Open this website externally to view it.";
67
68
  status.textContent = t(status.dataset.i18n);
69
+ external.hidden = false;
68
70
  void confirm(url);
69
71
  continue;
70
72
  }
@@ -73,32 +75,40 @@ export const mountDocumentLinks = (dialog, network = true, request) => {
73
75
  frame.title = host.dataset.title || url;
74
76
  frame.referrerPolicy = "no-referrer";
75
77
  frame.sandbox.add("allow-scripts", "allow-forms", "allow-popups");
76
- let failed = false;
77
- const fail = (message = "This website could not be displayed here. Open it externally?") => {
78
- if (failed)
78
+ let blocked = false;
79
+ const showStatus = (message) => {
80
+ if (blocked || !host.isConnected)
79
81
  return;
80
- failed = true;
81
- clearTimeout(timer);
82
- document.removeEventListener("securitypolicyviolation", violation);
83
- if (!host.isConnected)
84
- return;
85
- status.hidden = false;
82
+ notice.hidden = false;
86
83
  status.dataset.i18n = message;
87
84
  status.textContent = t(message);
85
+ };
86
+ const denied = () => {
87
+ if (blocked || !host.isConnected)
88
+ return;
89
+ const message = "This website could not be displayed here. Open it externally?";
90
+ showStatus(message);
91
+ blocked = true;
92
+ clearTimeout(timer);
93
+ document.removeEventListener("securitypolicyviolation", violation);
94
+ external.hidden = false;
88
95
  void confirm(url, message);
89
96
  };
90
- const timer = setTimeout(() => fail("This website has not loaded. Open it externally?"), 12000);
91
- frame.onerror = () => fail();
97
+ const timer = setTimeout(() => showStatus("This website has not loaded."), 12000);
98
+ frame.onerror = () => {
99
+ clearTimeout(timer);
100
+ showStatus("This website could not be loaded.");
101
+ };
92
102
  frame.onload = () => {
93
103
  clearTimeout(timer);
94
104
  document.removeEventListener("securitypolicyviolation", violation);
95
- if (!failed)
96
- status.hidden = true;
105
+ if (!blocked)
106
+ notice.hidden = true;
97
107
  };
98
- // shortcut: Browsers hide some cross-origin frame denials; retain the explicit external action.
108
+ // shortcut: Browsers hide some cross-origin frame denials; retain new-tab navigation as a fallback.
99
109
  const violation = (event) => {
100
110
  if (event.effectiveDirective === "frame-src" && event.blockedURI === url)
101
- fail();
111
+ denied();
102
112
  };
103
113
  document.addEventListener("securitypolicyviolation", violation);
104
114
  frame.src = url;
@@ -107,7 +117,7 @@ export const mountDocumentLinks = (dialog, network = true, request) => {
107
117
  void request(`/api/frame-policy?url=${encodeURIComponent(host.dataset.webUrl ?? url)}&parent=${encodeURIComponent(location.origin)}`)
108
118
  .then(async (response) => {
109
119
  if (response.ok && (await response.json()).blocked === true)
110
- fail();
120
+ denied();
111
121
  })
112
122
  .catch(() => { });
113
123
  }
@@ -302,6 +302,7 @@ export const mountSelectPickers = (t, selects = document.querySelectorAll("#fm-l
302
302
  }
303
303
  else if (event.key === "Escape" && isOpen()) {
304
304
  event.preventDefault();
305
+ event.stopPropagation();
305
306
  popup.hidePopover();
306
307
  if (!workspace)
307
308
  input.select();
@@ -38,6 +38,7 @@
38
38
  "View settings": "View settings",
39
39
  "Auto save": "Auto save",
40
40
  "Wrap lines": "Wrap lines",
41
+ "Space + arrow page jump": "space+arrow page jump",
41
42
  "Front-matter fields": "Front-matter fields",
42
43
  "title": "title",
43
44
  "desc": "desc",
@@ -448,6 +449,22 @@
448
449
  "Open this website in a new tab?": "Open this website in a new tab?",
449
450
  "Open this website externally to view it.": "Open this website externally to view it.",
450
451
  "This website could not be displayed here. Open it externally?": "This website could not be displayed here. Open it externally?",
451
- "This website has not loaded. Open it externally?": "This website has not loaded. Open it externally?",
452
- "Loading website…": "Loading website…"
452
+ "This website has not loaded.": "This website has not loaded.",
453
+ "This website could not be loaded.": "This website could not be loaded.",
454
+ "Loading website…": "Loading website…",
455
+ "Zoom in": "Zoom in",
456
+ "Zoom out": "Zoom out",
457
+ "Reset zoom": "Reset zoom",
458
+ "Image preview": "Image preview",
459
+ "Manifest editor": "Manifest editor",
460
+ "Settings": "Settings",
461
+ "Title": "Title",
462
+ "Add file": "Add file",
463
+ "Light and dark": "Light and dark",
464
+ "Automatic": "Automatic",
465
+ "Edit this legacy manifest in YAML.": "Edit this legacy manifest in YAML.",
466
+ "Manifest file is unavailable.": "Manifest file is unavailable.",
467
+ "Discard changes and reload the manifest?": "Discard changes and reload the manifest?",
468
+ "Load failed": "Load failed",
469
+ "Remove path": "Remove path"
453
470
  }
@@ -38,6 +38,7 @@
38
38
  "View settings": "表示設定",
39
39
  "Auto save": "自動保存",
40
40
  "Wrap lines": "折り返す",
41
+ "Space + arrow page jump": "space+矢印 page jump",
41
42
  "Front-matter fields": "文書の属性を表示",
42
43
  "title": "タイトル",
43
44
  "desc": "説明",
@@ -448,6 +449,22 @@
448
449
  "Open this website in a new tab?": "このWebサイトを新しいタブで開きますか?",
449
450
  "Open this website externally to view it.": "このWebサイトは外部で開いて表示できます。",
450
451
  "This website could not be displayed here. Open it externally?": "ここではWebサイトを表示できませんでした。外部で開きますか?",
451
- "This website has not loaded. Open it externally?": "Webサイトの読み込みが完了していません。外部で開きますか?",
452
- "Loading website…": "Webサイトを読み込み中…"
452
+ "This website has not loaded.": "Webサイトの読み込みが完了していません。",
453
+ "This website could not be loaded.": "Webサイトを読み込めませんでした。",
454
+ "Loading website…": "Webサイトを読み込み中…",
455
+ "Zoom in": "拡大",
456
+ "Zoom out": "縮小",
457
+ "Reset zoom": "ズームをリセット",
458
+ "Image preview": "画像プレビュー",
459
+ "Manifest editor": "マニフェスト編集",
460
+ "Settings": "設定",
461
+ "Title": "タイトル",
462
+ "Add file": "ファイルを追加",
463
+ "Light and dark": "ライトとダーク",
464
+ "Automatic": "自動",
465
+ "Edit this legacy manifest in YAML.": "この旧形式の設定は YAML で編集してください。",
466
+ "Manifest file is unavailable.": "設定ファイルを読み込めません。",
467
+ "Discard changes and reload the manifest?": "変更を破棄して設定ファイルを再読み込みしますか?",
468
+ "Load failed": "読み込みに失敗しました",
469
+ "Remove path": "参照を外す"
453
470
  }
@@ -38,6 +38,7 @@
38
38
  "View settings": "显示设置",
39
39
  "Auto save": "自动保存",
40
40
  "Wrap lines": "自动换行",
41
+ "Space + arrow page jump": "space+方向键 page jump",
41
42
  "Front-matter fields": "显示文档属性",
42
43
  "title": "标题",
43
44
  "desc": "描述",
@@ -448,6 +449,22 @@
448
449
  "Open this website in a new tab?": "在新标签页中打开此网站?",
449
450
  "Open this website externally to view it.": "请在外部打开此网站。",
450
451
  "This website could not be displayed here. Open it externally?": "无法在此显示该网站。在外部打开?",
451
- "This website has not loaded. Open it externally?": "此网站尚未加载。在外部打开?",
452
- "Loading website…": "正在加载网站…"
452
+ "This website has not loaded.": "此网站尚未加载。",
453
+ "This website could not be loaded.": "无法加载此网站。",
454
+ "Loading website…": "正在加载网站…",
455
+ "Zoom in": "放大",
456
+ "Zoom out": "缩小",
457
+ "Reset zoom": "重置缩放",
458
+ "Image preview": "图像预览",
459
+ "Manifest editor": "清单编辑器",
460
+ "Settings": "设置",
461
+ "Title": "标题",
462
+ "Add file": "添加文件",
463
+ "Light and dark": "浅色和深色",
464
+ "Automatic": "自动",
465
+ "Edit this legacy manifest in YAML.": "请使用 YAML 编辑此旧格式清单。",
466
+ "Manifest file is unavailable.": "无法读取清单文件。",
467
+ "Discard changes and reload the manifest?": "放弃更改并重新加载清单?",
468
+ "Load failed": "加载失败",
469
+ "Remove path": "移除路径"
453
470
  }
@@ -3,9 +3,10 @@ import { createCompiler } from "../engine/compiler/compile.js";
3
3
  import { exportBundle } from "../engine/compiler/export.js";
4
4
  import { filesSnapshot, updateFiles, uploadFile } from "../engine/compiler/files.js";
5
5
  import { listProjectFonts, removeProjectFont } from "../engine/compiler/fonts.js";
6
- import { dirname, join, mkdirSync, randomUUID, readFileSync, realpathSync, relative, renameSync, rmSync, writeFileSync, } from "../engine/compiler/host.js";
6
+ import { createHash, dirname, join, mkdirSync, randomUUID, readFileSync, realpathSync, relative, renameSync, rmSync, writeFileSync, } from "../engine/compiler/host.js";
7
7
  import { manifestFile } from "../engine/compiler/manifest.js";
8
8
  import { createDocOps, isOpError } from "../engine/compiler/ops.js";
9
+ import { readProjectSkills } from "../engine/compiler/skills.js";
9
10
  import { validateSubformatFile } from "../engine/compiler/subformats.js";
10
11
  import { readTextfile, textfilePath, writeTextfile } from "../engine/compiler/textfile.js";
11
12
  import { localFile } from "../engine/core/files.js";
@@ -28,6 +29,61 @@ export const createMcpOperations = (root, options = {}) => {
28
29
  return file ? (compiled.sources.get(file)?.errors ?? []) : [];
29
30
  };
30
31
  return {
32
+ skills: (a) => {
33
+ const skills = readProjectSkills(root);
34
+ const uri = (name, file) => `skill://${name}/${file.split("/").map(encodeURIComponent).join("/")}`;
35
+ const entry = (skill) => ({
36
+ uri: uri(skill.frontmatter.name, "SKILL.md"),
37
+ frontmatter: skill.frontmatter,
38
+ resources: [...skill.files].map(([file, data]) => ({
39
+ uri: uri(skill.frontmatter.name, file),
40
+ digest: `sha256:${createHash("sha256").update(data).digest("hex")}`,
41
+ size: data.length,
42
+ })),
43
+ });
44
+ if (a.action === "list")
45
+ return { resultType: "complete", skills: skills.map(entry) };
46
+ if (typeof a.uri !== "string")
47
+ throw new Error("A skill resource URI is required");
48
+ for (const skill of skills) {
49
+ if (a.action === "get" && a.uri === uri(skill.frontmatter.name, "SKILL.md"))
50
+ return { resultType: "complete", skill: entry(skill) };
51
+ if (a.action !== "read")
52
+ continue;
53
+ for (const [file, data] of skill.files) {
54
+ if (a.uri !== uri(skill.frontmatter.name, file))
55
+ continue;
56
+ let text;
57
+ try {
58
+ text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(data);
59
+ if (text.includes("\0"))
60
+ text = undefined;
61
+ }
62
+ catch {
63
+ text = undefined;
64
+ }
65
+ return {
66
+ contents: [
67
+ {
68
+ uri: a.uri,
69
+ ...(text === undefined
70
+ ? {
71
+ mimeType: "application/octet-stream",
72
+ blob: data.toString("base64"),
73
+ }
74
+ : {
75
+ mimeType: file.endsWith(".md")
76
+ ? "text/markdown"
77
+ : "text/plain",
78
+ text,
79
+ }),
80
+ },
81
+ ],
82
+ };
83
+ }
84
+ }
85
+ return { error: "Unknown project skill or resource", status: 404 };
86
+ },
31
87
  export: () => {
32
88
  const file = "dist/bundle.zip";
33
89
  const data = exportBundle(root);
@@ -1,2 +1,2 @@
1
1
  /** In narrow trees, show the current level beneath its compact ancestor chain. */
2
- export declare const focusNavTree: (root: HTMLElement | null) => void;
2
+ export declare const focusNavTree: (root: HTMLElement | null, href?: string) => void;
@@ -1,7 +1,26 @@
1
1
  /** In narrow trees, show the current level beneath its compact ancestor chain. */
2
- export const focusNavTree = (root) => {
2
+ export const focusNavTree = (root, href) => {
3
3
  if (!root)
4
4
  return;
5
+ if (href !== undefined) {
6
+ const target = new URL(href, location.href);
7
+ for (const link of document.querySelectorAll("#site-title, #nav-groups .nav-row > a[href]")) {
8
+ const url = new URL(link.href, location.href);
9
+ const current = url.origin === target.origin &&
10
+ url.pathname === target.pathname &&
11
+ (!target.hash.startsWith("#/") ||
12
+ url.hash.split("#")[1]?.split("?")[0] ===
13
+ target.hash.split("#")[1]?.split("?")[0]);
14
+ link.classList.toggle("cur", current);
15
+ if (current)
16
+ link.setAttribute("aria-current", "page");
17
+ else
18
+ link.removeAttribute("aria-current");
19
+ if (current)
20
+ for (let item = link.closest(".nav-item")?.parentElement?.closest(".nav-item"); item; item = item.parentElement?.closest(".nav-item"))
21
+ item.classList.add("open");
22
+ }
23
+ }
5
24
  const current = root.querySelector(".nav-row > a.cur")?.closest("[data-doc-id]");
6
25
  const path = [];
7
26
  for (let item = current; item; item = item.parentElement?.closest("[data-doc-id]")) {
@@ -68,6 +87,10 @@ export const focusNavTree = (root) => {
68
87
  item.classList.add("open");
69
88
  current?.querySelector(":scope > .nav-row")?.scrollIntoView({ block: "nearest" });
70
89
  }
71
- for (const item of items)
90
+ for (const item of items) {
91
+ const list = item.querySelector(":scope > .nav-list");
92
+ if (list)
93
+ list.inert = !item.classList.contains("open");
72
94
  item.querySelector(":scope > .nav-row > .nav-tree-toggle")?.setAttribute("aria-expanded", String(item.classList.contains("open")));
95
+ }
73
96
  };
@@ -2,6 +2,18 @@
2
2
  export const updateNav = (root, html) => {
3
3
  const template = root.ownerDocument.createElement("template");
4
4
  template.innerHTML = html;
5
+ // Selection runs before the link observer, so mount new routes synchronously.
6
+ for (const link of template.content.querySelectorAll("a[href]")) {
7
+ const href = link.getAttribute("href") ?? "";
8
+ if (!globalThis.__doocClientBase ||
9
+ !href.startsWith("/") ||
10
+ href.startsWith("//") ||
11
+ href === link.dataset.doocClientHref)
12
+ continue;
13
+ const mounted = `${globalThis.__doocClientBase ?? ""}${href}`;
14
+ link.setAttribute("href", mounted);
15
+ link.dataset.doocClientHref = mounted;
16
+ }
5
17
  const key = (node) => {
6
18
  if (!(node instanceof HTMLElement))
7
19
  return;
@@ -0,0 +1,3 @@
1
+ import type { focusNavTree } from "./nav-focus.js";
2
+ /** Self-contained for live pages and standalone readers. */
3
+ export declare const mountPageJump: (select: typeof focusNavTree) => void;
@@ -0,0 +1,130 @@
1
+ /** Self-contained for live pages and standalone readers. */
2
+ export const mountPageJump = (select) => {
3
+ const key = "docs-edit:page-jump";
4
+ const editor = document.body.classList.contains("edit");
5
+ const toggle = document.getElementById("opt-page-jump");
6
+ let enabled = true;
7
+ try {
8
+ if (editor)
9
+ enabled = localStorage.getItem(key) !== "0";
10
+ }
11
+ catch { }
12
+ let held = null;
13
+ let jumped = false;
14
+ const reset = () => {
15
+ held = null;
16
+ jumped = false;
17
+ };
18
+ const current = () => document.querySelector("#site-title.cur, #nav-groups [data-doc-id] > .nav-row > a.cur");
19
+ const surface = (target) => {
20
+ if (!enabled ||
21
+ !(target instanceof Element) ||
22
+ !current() ||
23
+ document.querySelector('dialog[open], [aria-modal="true"]') ||
24
+ target.closest('input, textarea, select, button, label, a, summary, iframe, audio, video, canvas, svg, .cm-editor, [contenteditable]:not([contenteditable="false"]), [role="button"], [role="textbox"], [role="searchbox"], [role="combobox"], [role="checkbox"], [role="radio"], [role="radiogroup"], [role="spinbutton"], [role="slider"], [role="tablist"], [role="tree"], [role="grid"], [role="listbox"], [role="menu"], [role="application"]'))
25
+ return null;
26
+ if (target === document.body && !editor)
27
+ return document.querySelector("main");
28
+ return target.closest(editor ? ".preview-pane.active" : "main");
29
+ };
30
+ if (toggle) {
31
+ toggle.checked = enabled;
32
+ toggle.addEventListener("change", () => {
33
+ enabled = toggle.checked;
34
+ reset();
35
+ try {
36
+ localStorage.setItem(key, enabled ? "1" : "0");
37
+ }
38
+ catch { }
39
+ });
40
+ }
41
+ document.addEventListener("pointerdown", (event) => {
42
+ const pane = surface(event.target);
43
+ if (pane !== held)
44
+ reset();
45
+ if (pane) {
46
+ if (!pane.hasAttribute("tabindex"))
47
+ pane.tabIndex = -1;
48
+ pane.focus({ preventScroll: true });
49
+ }
50
+ });
51
+ document.addEventListener("focusin", (event) => {
52
+ if (held && surface(event.target) !== held)
53
+ reset();
54
+ });
55
+ window.addEventListener("blur", reset);
56
+ document.addEventListener("visibilitychange", () => {
57
+ if (document.hidden)
58
+ reset();
59
+ });
60
+ document.addEventListener("keydown", (event) => {
61
+ if (event.defaultPrevented ||
62
+ event.isComposing ||
63
+ event.ctrlKey ||
64
+ event.altKey ||
65
+ event.metaKey ||
66
+ event.shiftKey) {
67
+ reset();
68
+ return;
69
+ }
70
+ const pane = surface(event.target);
71
+ if (!pane) {
72
+ reset();
73
+ return;
74
+ }
75
+ if (event.code === "Space" || event.key === " ") {
76
+ if (!held && !event.repeat) {
77
+ held = pane;
78
+ jumped = false;
79
+ }
80
+ if (held)
81
+ event.preventDefault();
82
+ return;
83
+ }
84
+ if (!held ||
85
+ held !== pane ||
86
+ !["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(event.key))
87
+ return;
88
+ event.preventDefault();
89
+ jumped = true;
90
+ const selected = current();
91
+ const item = selected?.closest(".nav-item[data-doc-id]");
92
+ const link = (item) => item?.querySelector(":scope > .nav-row > a[href]");
93
+ let destination;
94
+ if (event.key === "ArrowRight") {
95
+ const list = item?.querySelector(":scope > .nav-list") ??
96
+ (!item ? document.querySelector("#nav-groups > .nav-root") : null);
97
+ destination = link(list?.querySelector(":scope > .nav-item[data-doc-id]"));
98
+ if (destination && item)
99
+ window.__docsNavOpen?.(item.dataset.docId ?? "", true);
100
+ }
101
+ else if (event.key === "ArrowLeft" && item) {
102
+ destination =
103
+ link(item.parentElement?.closest(".nav-item[data-doc-id]")) ??
104
+ document.querySelector("#site-title[href]");
105
+ }
106
+ else if (item && (event.key === "ArrowUp" || event.key === "ArrowDown")) {
107
+ const siblings = [...(item.parentElement?.children ?? [])].filter((node) => node.matches(".nav-item[data-doc-id]"));
108
+ destination = link(siblings[siblings.indexOf(item) + (event.key === "ArrowUp" ? -1 : 1)]);
109
+ }
110
+ if (!destination)
111
+ return;
112
+ if (!pane.hasAttribute("tabindex"))
113
+ pane.tabIndex = -1;
114
+ pane.focus({ preventScroll: true });
115
+ select(document.getElementById("nav-groups"), destination.href);
116
+ destination.click();
117
+ });
118
+ document.addEventListener("keyup", (event) => {
119
+ if (event.code !== "Space" && event.key !== " ")
120
+ return;
121
+ const pane = held;
122
+ const scroll = !jumped && pane && surface(event.target) === pane;
123
+ reset();
124
+ if (!pane)
125
+ return;
126
+ event.preventDefault();
127
+ if (scroll)
128
+ pane.scrollBy({ top: pane.clientHeight * 0.875, behavior: "auto" });
129
+ });
130
+ };
@@ -2,7 +2,7 @@ export declare function mountDownloadBlock(): void;
2
2
  /** Self-contained for standalone HTML; data URLs use the browser's native download behavior. */
3
3
  export declare const mountResourceDownloads: (request?: (url: string, init?: RequestInit, workspace?: string) => Promise<Response>) => void;
4
4
  /**
5
- * Expanded view of a block: wheel zooms around the pointer, middle-button dragging pans while zoomed.
5
+ * Expanded view with pointer, keyboard and touch zoom and pan controls.
6
6
  * Self-contained (stringified with toString and embedded in the page).
7
7
  */
8
8
  export declare const mountResourceExpand: () => void;