@publish.os/nextjs 0.0.1-alpha.91 → 0.0.1-alpha.92

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 (153) hide show
  1. package/compiler-assets/nextjs/defaults/group/index.tsx +16 -11
  2. package/compiler-assets/nextjs/defaults/group/layout.tsx +6 -2
  3. package/compiler-assets/nextjs/defaults/group/page.tsx +7 -6
  4. package/compiler-assets/nextjs/defaults/project/next.config.mjs +2 -1
  5. package/compiler-assets/nextjs/defaults/root/index.tsx +16 -11
  6. package/compiler-assets/nextjs/defaults/root/layout.tsx +7 -3
  7. package/compiler-assets/nextjs/shims/agent-user-agents.ts +65 -0
  8. package/compiler-assets/nextjs/shims/document.tsx +9 -1
  9. package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +3 -0
  10. package/compiler-assets/nextjs/shims/proxy.ts +156 -54
  11. package/dist/{build-operation-5QMLXF7N.js → build-operation-CJDUL4OW.js} +5 -5
  12. package/dist/{chunk-GBPLER5H.js → chunk-3T4HVDSC.js} +2 -2
  13. package/dist/{chunk-UYGCOWRF.js → chunk-DX7PXFCM.js} +860 -50
  14. package/dist/{chunk-F3AGNDF4.js → chunk-DZ3VWEV5.js} +860 -575
  15. package/dist/{chunk-OXOFRXEI.js → chunk-NHSLTARU.js} +1284 -1164
  16. package/dist/{chunk-ORIUWJBQ.js → chunk-SBMDONTV.js} +3 -2
  17. package/dist/compiler.js +42 -23
  18. package/dist/components/blocks/agent-actions.d.ts +7 -7
  19. package/dist/components/blocks/agent-actions.js +1 -32
  20. package/dist/components/blocks/toc.d.ts +7 -7
  21. package/dist/components/ui/button.d.ts +1 -2
  22. package/dist/{compose-CVBJRAF6.js → compose-44GJSMXD.js} +2 -2
  23. package/dist/config/createNextConfig.js +2 -0
  24. package/dist/{dev-operation-OSHHWRWK.js → dev-operation-WNECBHZ5.js} +17 -7
  25. package/dist/{ide-support-CU6Z5PVR.js → ide-support-TG74L4FF.js} +3 -3
  26. package/dist/index.d.ts +143 -126
  27. package/dist/index.js +25 -0
  28. package/dist/kernel/components/blocks/AgentActions.d.ts +7 -7
  29. package/dist/kernel/components/blocks/AgentActions.js +1 -32
  30. package/dist/kernel/components/blocks/agent-actions.d.ts +1 -2
  31. package/dist/kernel/components/blocks/agent-actions.js +1 -32
  32. package/dist/kernel/components/blocks/animated-icon-swap.d.ts +2 -2
  33. package/dist/kernel/components/blocks/color-palette.d.ts +2 -2
  34. package/dist/kernel/components/blocks/logo-block.d.ts +2 -2
  35. package/dist/kernel/components/blocks/nav-breadcrumb.d.ts +6 -5
  36. package/dist/kernel/components/blocks/nav-breadcrumb.js +19 -13
  37. package/dist/kernel/components/blocks/navbar.d.ts +5 -4
  38. package/dist/kernel/components/blocks/navbar.js +62 -42
  39. package/dist/kernel/components/blocks/navigation-progress.d.ts +2 -2
  40. package/dist/kernel/components/blocks/next-prev.d.ts +4 -4
  41. package/dist/kernel/components/blocks/next-prev.js +29 -6
  42. package/dist/kernel/components/blocks/page-list.d.ts +4 -4
  43. package/dist/kernel/components/blocks/page-list.js +30 -7
  44. package/dist/kernel/components/blocks/search.d.ts +9 -15
  45. package/dist/kernel/components/blocks/sidebar-node.d.ts +3 -5
  46. package/dist/kernel/components/blocks/sidebar-node.js +12 -2
  47. package/dist/kernel/components/blocks/sidebar.d.ts +6 -7
  48. package/dist/kernel/components/blocks/sidebar.js +132 -26
  49. package/dist/kernel/components/blocks/theme-toggle.d.ts +3 -4
  50. package/dist/kernel/components/blocks/toc-client.d.ts +7 -7
  51. package/dist/kernel/components/blocks/toc.d.ts +3 -3
  52. package/dist/kernel/components/mdx/components/blockquote.d.ts +2 -2
  53. package/dist/kernel/components/mdx/components/callout.d.ts +3 -3
  54. package/dist/kernel/components/mdx/components/code-block.d.ts +2 -2
  55. package/dist/kernel/components/mdx/components/copy-code-button.d.ts +2 -2
  56. package/dist/kernel/components/mdx/components/figure-caption.d.ts +2 -2
  57. package/dist/kernel/components/mdx/components/figure.d.ts +3 -3
  58. package/dist/kernel/components/mdx/components/footnotes.d.ts +2 -2
  59. package/dist/kernel/components/mdx/components/heading-copy-link.d.ts +2 -2
  60. package/dist/kernel/components/mdx/components/heading.d.ts +2 -2
  61. package/dist/kernel/components/mdx/components/hr.d.ts +4 -4
  62. package/dist/kernel/components/mdx/components/image-zoom.d.ts +3 -3
  63. package/dist/kernel/components/mdx/components/image-zoom.js +3 -2
  64. package/dist/kernel/components/mdx/components/image.d.ts +2 -2
  65. package/dist/kernel/components/mdx/components/image.js +1 -1
  66. package/dist/kernel/components/mdx/components/inline-code.d.ts +2 -2
  67. package/dist/kernel/components/mdx/components/kbd.d.ts +3 -3
  68. package/dist/kernel/components/mdx/components/link.d.ts +3 -3
  69. package/dist/kernel/components/mdx/components/paragraph.d.ts +2 -2
  70. package/dist/kernel/components/mdx/components/strikethrough.d.ts +2 -2
  71. package/dist/kernel/components/mdx/components/table.d.ts +7 -7
  72. package/dist/kernel/components/mdx/components/task-list.d.ts +3 -3
  73. package/dist/kernel/components/mdx/components/video-player.d.ts +2 -2
  74. package/dist/kernel/components/mdx/components/video.d.ts +2 -3
  75. package/dist/kernel/components/mdx/error-boundary.d.ts +2 -3
  76. package/dist/kernel/components/mdx/error-fallback.d.ts +2 -2
  77. package/dist/kernel/components/mdx/mdx.d.ts +42 -11
  78. package/dist/kernel/components/mdx/mdx.js +1 -1
  79. package/dist/kernel/components/next-image.d.ts +3 -3
  80. package/dist/kernel/components/ui/accordion.d.ts +7 -7
  81. package/dist/kernel/components/ui/breadcrumb-trail.d.ts +2 -3
  82. package/dist/kernel/components/ui/breadcrumb.d.ts +13 -13
  83. package/dist/kernel/components/ui/button-group.d.ts +5 -5
  84. package/dist/kernel/components/ui/button.d.ts +3 -3
  85. package/dist/kernel/components/ui/card.d.ts +7 -7
  86. package/dist/kernel/components/ui/dialog.d.ts +10 -10
  87. package/dist/kernel/components/ui/drawer.d.ts +12 -12
  88. package/dist/kernel/components/ui/kbd.d.ts +3 -3
  89. package/dist/kernel/components/ui/link.d.ts +3 -3
  90. package/dist/kernel/components/ui/menu.d.ts +22 -22
  91. package/dist/kernel/components/ui/mod-key.d.ts +2 -3
  92. package/dist/kernel/components/ui/navigation-menu.d.ts +15 -15
  93. package/dist/kernel/components/ui/popover.d.ts +11 -11
  94. package/dist/kernel/components/ui/progress.d.ts +7 -7
  95. package/dist/kernel/components/ui/scroll-area.d.ts +1 -2
  96. package/dist/kernel/components/ui/select.d.ts +16 -16
  97. package/dist/kernel/components/ui/separator.d.ts +3 -3
  98. package/dist/kernel/components/ui/table.d.ts +7 -7
  99. package/dist/kernel/components/ui/tabs.d.ts +12 -12
  100. package/dist/kernel/components/ui/tag.d.ts +3 -3
  101. package/dist/kernel/components/ui/text.d.ts +4 -4
  102. package/dist/kernel/components/ui/toast.d.ts +11 -11
  103. package/dist/kernel/components/ui/tooltip.d.ts +9 -9
  104. package/dist/kernel/defaults.registry.d.ts +2 -2
  105. package/dist/kernel/defaults.registry.js +2 -2
  106. package/dist/kernel/routes/agent/markdown.d.ts +4 -0
  107. package/dist/kernel/routes/agent/markdown.js +11 -7
  108. package/dist/kernel/routes/layouts/group.d.ts +1 -1
  109. package/dist/kernel/routes/metadata/feed.d.ts +1 -2
  110. package/dist/kernel/routes/metadata/feed.js +34 -29
  111. package/dist/kernel/routes/metadata/llms.d.ts +3 -31
  112. package/dist/kernel/routes/metadata/llms.js +2 -200
  113. package/dist/kernel/routes/metadata/robots.d.ts +5 -3
  114. package/dist/kernel/routes/metadata/robots.js +4 -25
  115. package/dist/kernel/routes/metadata/sitemap.d.ts +15 -1
  116. package/dist/kernel/routes/metadata/sitemap.js +200 -112
  117. package/dist/kernel/routes/not-found.js +1 -1
  118. package/dist/kernel/routes/pages/group.d.ts +3 -3
  119. package/dist/kernel/routes/pages/group.js +10 -4
  120. package/dist/kernel/routes/pages/leaf.d.ts +9 -4
  121. package/dist/kernel/routes/pages/leaf.js +16 -8
  122. package/dist/kernel/routes/pages/root.d.ts +3 -3
  123. package/dist/kernel/routes/pages/root.js +20 -5
  124. package/dist/keyboard-shortcuts.d.ts +2 -2
  125. package/dist/manifest-types-CcVPH_jh.d.ts +83 -0
  126. package/dist/resolvers/manifest-resolver.d.ts +2 -2
  127. package/dist/resolvers/manifest-resolver.js +65 -35
  128. package/dist/search.d.ts +2 -9
  129. package/dist/search.js +2 -7
  130. package/dist/sidebar-types-CMrMM0Nj.d.ts +105 -0
  131. package/dist/theme-scope.d.ts +2 -2
  132. package/dist/types-BbqmOzLC.d.ts +168 -0
  133. package/dist/types-TjH1ek0X.d.ts +22 -0
  134. package/dist/types.d.ts +116 -91
  135. package/dist/{validate-local-source-SV44DBQT.js → validate-local-source-EN2GW4FR.js} +3 -3
  136. package/dist/{validate-publish-os-source-NZJF3TB2.js → validate-publish-os-source-OEWQDB7B.js} +2 -2
  137. package/init/seed/minimal/publish.os/blog/index.tsx +25 -22
  138. package/init/seed/minimal/publish.os/blog/page.tsx +31 -16
  139. package/init/seed/minimal/publish.os/components/blog/copy-link.tsx +1 -1
  140. package/init/seed/minimal/publish.os/components/blog/frontmatter.ts +41 -0
  141. package/init/seed/minimal/publish.os/publish.os.config.json +13 -2
  142. package/init/seed/minimal/seed.json +1 -0
  143. package/init/seed/scratch/publish.os/publish.os.config.json +1 -1
  144. package/package.json +4 -4
  145. package/release/app/phosphor/package.json +1 -1
  146. package/release/app/phosphor/pnpm-lock.yaml.template +53 -127
  147. package/release/compiler/pnpm-lock.yaml.template +49 -123
  148. package/release/release.json +4 -4
  149. package/dist/sidebar-types-DKpR27II.d.ts +0 -25
  150. package/dist/types-CJWRG05y.d.ts +0 -76
  151. package/dist/types-CUtrppxt.d.ts +0 -69
  152. package/dist/types-J2w_puPF.d.ts +0 -128
  153. package/dist/{button-BdCScEKi.d.ts → button-D6Xp2HBm.d.ts} +1 -1
@@ -1,15 +1,14 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { a as SidebarTreeNode } from '../../../sidebar-types-DKpR27II.js';
4
- export { b as SidebarActiveState, c as SidebarDepth, S as SidebarNodePrimitiveProps } from '../../../sidebar-types-DKpR27II.js';
5
- import '../../../types-CJWRG05y.js';
3
+ import { R as ResolvedNavigation } from '../../../sidebar-types-CMrMM0Nj.js';
4
+ export { a as SidebarActiveState, b as SidebarDepth, c as SidebarNavigationNode, S as SidebarNodePrimitiveProps } from '../../../sidebar-types-CMrMM0Nj.js';
6
5
 
7
6
  type SidebarProps = {
8
7
  className?: string;
9
8
  currentPath?: string;
10
9
  title?: ReactNode;
11
- tree: SidebarTreeNode[];
10
+ navigation: ResolvedNavigation;
12
11
  };
13
- declare function Sidebar({ className, currentPath, title, tree }: SidebarProps): react_jsx_runtime.JSX.Element;
12
+ declare function Sidebar({ className, currentPath, title, navigation, }: SidebarProps): react.JSX.Element;
14
13
 
15
- export { Sidebar, type SidebarProps, SidebarTreeNode };
14
+ export { Sidebar, type SidebarProps };
@@ -15,45 +15,103 @@ import {
15
15
  useRef,
16
16
  useState
17
17
  } from "react";
18
- import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
18
+
19
+ // src/components/block/sidebar/sidebar-navigation-view.ts
19
20
  function normalizePath(path) {
20
21
  if (!path) return "";
21
22
  let [withoutQuery = ""] = path.split(/[?#]/);
22
23
  return withoutQuery === "/" ? "/" : withoutQuery.replace(/\/+$/g, "");
23
24
  }
25
+ function nodePath(node) {
26
+ if (node.type === "page") return node.page.path;
27
+ if (node.type === "group") return node.route;
28
+ }
29
+ function pathSpecificity(nodes, path) {
30
+ let normalizedPath = normalizePath(path), specificity = -1;
31
+ for (let node of nodes) {
32
+ let candidate = normalizePath(nodePath(node));
33
+ candidate && (normalizedPath === candidate || normalizedPath.startsWith(`${candidate}/`)) && (specificity = Math.max(specificity, candidate.length)), node.type === "view" ? specificity = Math.max(specificity, pathSpecificity(node.items, path)) : "children" in node && (specificity = Math.max(
34
+ specificity,
35
+ pathSpecificity(node.children ?? [], path)
36
+ ));
37
+ }
38
+ return specificity;
39
+ }
40
+ function focusedViewForPath(nodes, path) {
41
+ let selected, selectedDepth = -1, selectedSpecificity = -1;
42
+ function visit(entries, depth) {
43
+ for (let node of entries)
44
+ if (node.type === "view") {
45
+ let specificity = pathSpecificity(node.items, path);
46
+ specificity >= 0 && (depth > selectedDepth || depth === selectedDepth && specificity > selectedSpecificity) && (selected = node, selectedDepth = depth, selectedSpecificity = specificity), visit(node.items, depth + 1);
47
+ } else "children" in node && visit(node.children ?? [], depth);
48
+ }
49
+ return visit(nodes, 0), selected;
50
+ }
51
+ function focusedViewForTarget(nodes, target) {
52
+ if (typeof target != "string")
53
+ return findNamedView(nodes, target.view);
54
+ let group = findGroup(nodes, target);
55
+ return group ? focusedViewForPath(nodes, group.route) : findNamedView(nodes, target);
56
+ }
57
+ function findNavigationView(nodes, viewId) {
58
+ if (viewId)
59
+ for (let node of nodes) {
60
+ if (node.type === "view" && (node.viewId === viewId || node.id === viewId))
61
+ return node;
62
+ let nested = node.type === "view" ? findNavigationView(node.items, viewId) : "children" in node ? findNavigationView(node.children ?? [], viewId) : void 0;
63
+ if (nested) return nested;
64
+ }
65
+ }
66
+ function findNamedView(nodes, viewId) {
67
+ return findNavigationView(nodes, viewId);
68
+ }
69
+ function findGroup(nodes, groupKey) {
70
+ for (let node of nodes) {
71
+ if (node.type === "group" && node.groupKey === groupKey) return node;
72
+ let nested = node.type === "view" ? findGroup(node.items, groupKey) : "children" in node ? findGroup(node.children ?? [], groupKey) : void 0;
73
+ if (nested) return nested;
74
+ }
75
+ }
76
+
77
+ // src/components/block/sidebar/sidebar.tsx
78
+ import { jsx, jsxs } from "@publish.os/nextjs/jsx-runtime";
79
+ function normalizePath2(path) {
80
+ if (!path) return "";
81
+ let [withoutQuery = ""] = path.split(/[?#]/);
82
+ return withoutQuery === "/" ? "/" : withoutQuery.replace(/\/+$/g, "");
83
+ }
24
84
  function isExternalHref(href) {
25
85
  return /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//");
26
86
  }
27
87
  function nodeHref(node) {
28
- if (node.type === "link" || "href" in node && typeof node.href == "string") return node.href;
29
- if ("path" in node && typeof node.path == "string") return node.path;
88
+ if (node.type === "link" || node.type === "page" || node.type === "group" && node.presentation === "page") return node.href;
30
89
  }
31
- function nodePath(node) {
32
- if (node.type !== "link" && "path" in node && typeof node.path == "string")
33
- return node.path;
90
+ function nodePath2(node) {
91
+ if (node.type === "page") return node.page.path;
92
+ if (node.type === "group" && node.presentation === "page") return node.route;
34
93
  }
35
94
  function nodeChildren(node) {
36
- return Array.isArray(node.children) ? node.children : [];
95
+ return node.type === "view" ? node.items : "children" in node ? node.children ?? [] : [];
37
96
  }
38
97
  function nodeKey(node, parentKey) {
39
- let prefix = parentKey ? `${parentKey}/` : "";
40
- return node.type === "page" ? `${prefix}page:${node.fileID}` : node.type === "link" ? `${prefix}link:${node.id}` : `${prefix}${node.type}:${node.id}`;
98
+ return `${parentKey ? `${parentKey}/` : ""}${node.type}:${node.id}`;
41
99
  }
42
100
  function isActivePath(path, currentPath) {
43
101
  if (!path || isExternalHref(path)) return !1;
44
- let normalizedPath = normalizePath(path), normalizedCurrentPath = normalizePath(currentPath);
102
+ let normalizedPath = normalizePath2(path), normalizedCurrentPath = normalizePath2(currentPath);
45
103
  return normalizedPath ? normalizedCurrentPath === normalizedPath || normalizedCurrentPath.startsWith(`${normalizedPath}/`) : !1;
46
104
  }
47
105
  function isExactActivePath(path, currentPath) {
48
- return !path || isExternalHref(path) ? !1 : normalizePath(path) === normalizePath(currentPath);
106
+ return !path || isExternalHref(path) ? !1 : normalizePath2(path) === normalizePath2(currentPath);
49
107
  }
50
108
  function createActiveIndex({
51
109
  currentPath,
52
- tree
110
+ nodes
53
111
  }) {
54
112
  let activeIndex = /* @__PURE__ */ new Map();
55
113
  function visit(node) {
56
- let path = nodePath(node), exactActive = isExactActivePath(path, currentPath), pathActive = node.type === "page" && isActivePath(path, currentPath), childActive = !1;
114
+ let path = nodePath2(node), exactActive = isExactActivePath(path, currentPath), pathActive = (node.type === "page" || node.type === "group") && isActivePath(path, currentPath), childActive = !1;
57
115
  for (let child of nodeChildren(node))
58
116
  childActive = visit(child) || childActive;
59
117
  let activeState = exactActive ? "path-active" : childActive || pathActive ? "child-path-active" : void 0;
@@ -62,7 +120,7 @@ function createActiveIndex({
62
120
  initiallyExpanded: exactActive || pathActive || childActive
63
121
  }), exactActive || pathActive || childActive;
64
122
  }
65
- for (let node of tree)
123
+ for (let node of nodes)
66
124
  visit(node);
67
125
  return activeIndex;
68
126
  }
@@ -73,7 +131,7 @@ function nodeContentId({
73
131
  instanceId,
74
132
  node
75
133
  }) {
76
- let key = "path" in node && node.path ? node.path : node.type === "page" ? node.fileID : node.id;
134
+ let key = node.type === "page" ? node.page.path : node.type === "group" ? node.route : node.id;
77
135
  return `sidebar-${safeIdPart(instanceId)}-${safeIdPart(key)}`;
78
136
  }
79
137
  function clampDepth(depth) {
@@ -88,6 +146,7 @@ function ExpandableChildren({
88
146
  expanded,
89
147
  instanceId,
90
148
  nodes,
149
+ onSwitchView,
91
150
  parentExpanded,
92
151
  renderChildren
93
152
  }) {
@@ -112,6 +171,7 @@ function ExpandableChildren({
112
171
  instanceId,
113
172
  itemKey: nodeKey(child, contentId),
114
173
  node: child,
174
+ onSwitchView,
115
175
  parentExpanded: childFocusable
116
176
  },
117
177
  nodeKey(child, contentId)
@@ -127,18 +187,19 @@ var SidebarTreeItem = memo(function SidebarTreeItem2({
127
187
  instanceId,
128
188
  itemKey,
129
189
  node,
190
+ onSwitchView,
130
191
  parentExpanded
131
192
  }) {
132
- let nodes = nodeChildren(node), href = nodeHref(node), activeInfo = activeIndex.get(node), activeState = activeInfo?.activeState, initiallyExpanded = !!activeInfo?.initiallyExpanded, isExpandable = nodes.length > 0 && (node.type === "folder" || node.type === "page"), [expanded, setExpanded] = useState(initiallyExpanded), [renderChildren, setRenderChildren] = useState(initiallyExpanded), interactedRef = useRef(!1), lastPathRef = useRef(normalizePath(currentPath)), contentId = nodeContentId({ instanceId, node });
193
+ let nodes = nodeChildren(node), href = nodeHref(node), activeInfo = activeIndex.get(node), activeState = activeInfo?.activeState, initiallyExpanded = !!activeInfo?.initiallyExpanded, hasChildren = nodes.length > 0, isExpandable = hasChildren && (node.type === "folder" || node.type === "page" || node.type === "group" && node.presentation === "folder"), [expanded, setExpanded] = useState(initiallyExpanded), [renderChildren, setRenderChildren] = useState(initiallyExpanded), interactedRef = useRef(!1), lastPathRef = useRef(normalizePath2(currentPath)), contentId = nodeContentId({ instanceId, node });
133
194
  useEffect(() => {
134
- let normalizedCurrentPath = normalizePath(currentPath);
195
+ let normalizedCurrentPath = normalizePath2(currentPath);
135
196
  lastPathRef.current !== normalizedCurrentPath && (interactedRef.current = !1, lastPathRef.current = normalizedCurrentPath), initiallyExpanded && !expanded && !interactedRef.current && (setRenderChildren(!0), startTransition(() => setExpanded(!0)));
136
197
  }, [currentPath, expanded, initiallyExpanded]);
137
198
  let toggleExpanded = useCallback(() => {
138
199
  interactedRef.current = !0, setRenderChildren(!0), setExpanded((value) => !value);
139
200
  }, []), expandOnNavigate = useCallback(() => {
140
201
  interactedRef.current = !0, setRenderChildren(!0), setExpanded(!0);
141
- }, []), pageWithChildrenLinkClick = node.type === "page" && nodes.length > 0 ? expandOnNavigate : void 0, children = isExpandable && nodes.length > 0 ? /* @__PURE__ */ jsx(
202
+ }, []), pageWithChildrenLinkClick = (node.type === "page" || node.type === "group" && node.presentation === "page") && hasChildren ? expandOnNavigate : void 0, children = isExpandable && hasChildren ? /* @__PURE__ */ jsx(
142
203
  ExpandableChildren,
143
204
  {
144
205
  activeIndex,
@@ -149,10 +210,25 @@ var SidebarTreeItem = memo(function SidebarTreeItem2({
149
210
  expanded,
150
211
  instanceId,
151
212
  nodes,
213
+ onSwitchView,
152
214
  parentExpanded,
153
215
  renderChildren
154
216
  }
155
- ) : node.type === "section" && nodes.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-px", children: nodes.map((child) => /* @__PURE__ */ jsx(
217
+ ) : node.type === "section" && hasChildren ? /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-px", children: nodes.map((child) => /* @__PURE__ */ jsx(
218
+ SidebarTreeItem2,
219
+ {
220
+ activeIndex,
221
+ activeItemRef,
222
+ currentPath,
223
+ depth,
224
+ instanceId,
225
+ itemKey: nodeKey(child, itemKey),
226
+ node: child,
227
+ onSwitchView,
228
+ parentExpanded
229
+ },
230
+ nodeKey(child, itemKey)
231
+ )) }) : node.type === "view" && hasChildren ? /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-px", children: nodes.map((child) => /* @__PURE__ */ jsx(
156
232
  SidebarTreeItem2,
157
233
  {
158
234
  activeIndex,
@@ -162,11 +238,12 @@ var SidebarTreeItem = memo(function SidebarTreeItem2({
162
238
  instanceId,
163
239
  itemKey: nodeKey(child, itemKey),
164
240
  node: child,
241
+ onSwitchView,
165
242
  parentExpanded
166
243
  },
167
244
  nodeKey(child, itemKey)
168
245
  )) }) : null;
169
- return /* @__PURE__ */ jsx(
246
+ return node.type === "view" ? children : /* @__PURE__ */ jsx(
170
247
  SidebarNode,
171
248
  {
172
249
  activeState,
@@ -178,17 +255,45 @@ var SidebarTreeItem = memo(function SidebarTreeItem2({
178
255
  isExpandable,
179
256
  node,
180
257
  onLinkClick: pageWithChildrenLinkClick,
258
+ onSwitchView: node.type === "switch-view" ? () => onSwitchView(node.target) : void 0,
181
259
  onToggle: isExpandable ? toggleExpanded : void 0,
182
260
  parentExpanded,
183
- title: node.title,
261
+ title: node.label ?? "",
184
262
  children
185
263
  }
186
264
  );
187
265
  });
188
- function Sidebar({ className, currentPath, title, tree }) {
189
- let resolvedCurrentPath = usePathname() ?? currentPath ?? "", instanceId = useId(), activeItemRef = useRef(null), viewportRef = useRef(null), activeIndex = useMemo(
190
- () => createActiveIndex({ currentPath: resolvedCurrentPath, tree }),
191
- [resolvedCurrentPath, tree]
266
+ function Sidebar({
267
+ className,
268
+ currentPath,
269
+ title,
270
+ navigation
271
+ }) {
272
+ let resolvedCurrentPath = usePathname() ?? currentPath ?? "", normalizedCurrentPath = normalizePath2(resolvedCurrentPath), [selection, setSelection] = useState(() => ({
273
+ path: normalizedCurrentPath,
274
+ viewId: focusedViewForPath(navigation.items, resolvedCurrentPath)?.id
275
+ })), defaultViewId = focusedViewForPath(
276
+ navigation.items,
277
+ resolvedCurrentPath
278
+ )?.id, viewId = selection.path === normalizedCurrentPath ? selection.viewId : defaultViewId, selectedView = findNavigationView(navigation.items, viewId), visibleNodes = selectedView?.type === "view" ? selectedView.items : navigation.items, switchView = useCallback(
279
+ (target) => {
280
+ let targetView = focusedViewForTarget(navigation.items, target);
281
+ setSelection({ path: normalizedCurrentPath, viewId: targetView?.id });
282
+ },
283
+ [navigation.items, normalizedCurrentPath]
284
+ );
285
+ useEffect(() => {
286
+ setSelection({
287
+ path: normalizedCurrentPath,
288
+ viewId: defaultViewId
289
+ });
290
+ }, [defaultViewId, normalizedCurrentPath]);
291
+ let instanceId = useId(), activeItemRef = useRef(null), viewportRef = useRef(null), activeIndex = useMemo(
292
+ () => createActiveIndex({
293
+ currentPath: resolvedCurrentPath,
294
+ nodes: visibleNodes
295
+ }),
296
+ [resolvedCurrentPath, visibleNodes]
192
297
  );
193
298
  return useEffect(() => {
194
299
  let viewport = viewportRef.current, win = viewport?.ownerDocument.defaultView;
@@ -219,7 +324,7 @@ function Sidebar({ className, currentPath, title, tree }) {
219
324
  scrollbarClassName: "opacity-0 transition-opacity data-[hovering]:opacity-100 data-[scrolling]:opacity-100",
220
325
  variant: "gradient",
221
326
  viewportRef,
222
- children: /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-px px-2 py-3", children: tree.map((node) => /* @__PURE__ */ jsx(
327
+ children: /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-px px-2 py-3", children: visibleNodes.map((node) => /* @__PURE__ */ jsx(
223
328
  SidebarTreeItem,
224
329
  {
225
330
  activeIndex,
@@ -229,6 +334,7 @@ function Sidebar({ className, currentPath, title, tree }) {
229
334
  instanceId,
230
335
  itemKey: nodeKey(node, ""),
231
336
  node,
337
+ onSwitchView: switchView,
232
338
  parentExpanded: !0
233
339
  },
234
340
  nodeKey(node, "")
@@ -1,10 +1,9 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { B as ButtonProps } from '../../../button-BdCScEKi.js';
1
+ import * as react from 'react';
2
+ import { B as ButtonProps } from '../../../button-D6Xp2HBm.js';
3
3
  import 'class-variance-authority/types';
4
4
  import 'class-variance-authority';
5
- import 'react';
6
5
 
7
6
  type ThemeToggleProps = Omit<ButtonProps, "children" | "iconOnly" | "leftIcon" | "loading" | "rightIcon">;
8
- declare function ThemeToggle({ className, onClick, size, title, type, variant, ...props }: ThemeToggleProps): react_jsx_runtime.JSX.Element;
7
+ declare function ThemeToggle({ className, onClick, size, title, type, variant, ...props }: ThemeToggleProps): react.JSX.Element;
9
8
 
10
9
  export { ThemeToggle, type ThemeToggleProps };
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
 
4
4
  type TocHeading = {
@@ -20,21 +20,21 @@ type TocClientProps = {
20
20
  title: string;
21
21
  children: ReactNode;
22
22
  };
23
- declare function TocClientProvider({ className, desktopClassName, desktopListClassName, headings, levels, listClassName, mobileClassName, mobileQuery, readingOffset, title, children, }: TocClientProps): react_jsx_runtime.JSX.Element;
23
+ declare function TocClientProvider({ className, desktopClassName, desktopListClassName, headings, levels, listClassName, mobileClassName, mobileQuery, readingOffset, title, children, }: TocClientProps): react.JSX.Element;
24
24
  declare function TocDesktop({ children }: {
25
25
  children?: ReactNode;
26
- }): react_jsx_runtime.JSX.Element;
26
+ }): react.JSX.Element;
27
27
  declare function TocMobile({ children }: {
28
28
  children?: ReactNode;
29
- }): react_jsx_runtime.JSX.Element;
29
+ }): react.JSX.Element;
30
30
  declare function TocMobileHeader({ children }: {
31
31
  children?: ReactNode;
32
- }): react_jsx_runtime.JSX.Element;
32
+ }): react.JSX.Element;
33
33
  declare function TocLinksSlot({ className, listClassName, viewport, }: {
34
34
  className?: string;
35
35
  listClassName?: string;
36
36
  viewport?: "desktop" | "mobile";
37
- }): react_jsx_runtime.JSX.Element;
38
- declare function TocTitle({ children, className, ...props }: React.ComponentPropsWithoutRef<"span">): react_jsx_runtime.JSX.Element;
37
+ }): react.JSX.Element;
38
+ declare function TocTitle({ children, className, ...props }: React.ComponentPropsWithoutRef<"span">): react.JSX.Element;
39
39
 
40
40
  export { TocClientProvider, TocDesktop, TocLinksSlot, TocMobile, TocMobileHeader, TocTitle };
@@ -1,6 +1,6 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { TocDesktop, TocLinksSlot, TocMobile, TocMobileHeader, TocTitle } from './toc-client.js';
1
+ import * as react from 'react';
3
2
  import { ReactNode } from 'react';
3
+ import { TocDesktop, TocLinksSlot, TocMobile, TocMobileHeader, TocTitle } from './toc-client.js';
4
4
 
5
5
  type TocProps = {
6
6
  children?: ReactNode;
@@ -15,7 +15,7 @@ type TocProps = {
15
15
  readingOffset?: number;
16
16
  title?: string;
17
17
  };
18
- declare function TocRoot({ className, content, desktopClassName, desktopListClassName, levels, listClassName, mobileClassName, mobileQuery, readingOffset, title, children, }: TocProps): react_jsx_runtime.JSX.Element | null;
18
+ declare function TocRoot({ className, content, desktopClassName, desktopListClassName, levels, listClassName, mobileClassName, mobileQuery, readingOffset, title, children, }: TocProps): react.JSX.Element | null;
19
19
  declare const Toc: typeof TocRoot & {
20
20
  Desktop: typeof TocDesktop;
21
21
  Links: typeof TocLinksSlot;
@@ -1,6 +1,6 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
 
3
3
  type BlockquoteProps = React.ComponentPropsWithoutRef<"blockquote">;
4
- declare function Blockquote({ className, ...props }: BlockquoteProps): react_jsx_runtime.JSX.Element;
4
+ declare function Blockquote({ className, ...props }: BlockquoteProps): react.JSX.Element;
5
5
 
6
6
  export { Blockquote, type BlockquoteProps };
@@ -1,7 +1,7 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
+ import { ComponentPropsWithoutRef, ReactNode } from 'react';
2
3
  import * as class_variance_authority_types from 'class-variance-authority/types';
3
4
  import { VariantProps } from 'class-variance-authority';
4
- import { ComponentPropsWithoutRef, ReactNode } from 'react';
5
5
 
6
6
  declare const calloutVariants: (props?: ({
7
7
  color?: "neutral" | "info" | "warning" | "danger" | "success" | null | undefined;
@@ -11,6 +11,6 @@ type CalloutProps = Omit<ComponentPropsWithoutRef<"aside">, "color" | "title" |
11
11
  icon?: ReactNode;
12
12
  title?: ReactNode;
13
13
  };
14
- declare function Callout({ children, className, color, icon, title, variant, ...props }: CalloutProps): react_jsx_runtime.JSX.Element;
14
+ declare function Callout({ children, className, color, icon, title, variant, ...props }: CalloutProps): react.JSX.Element;
15
15
 
16
16
  export { Callout, type CalloutProps, calloutVariants };
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { BundledTheme } from 'shiki';
3
3
 
4
4
  type CodeBlockProps = Omit<React.ComponentPropsWithoutRef<"div">, "style"> & {
@@ -7,6 +7,6 @@ type CodeBlockProps = Omit<React.ComponentPropsWithoutRef<"div">, "style"> & {
7
7
  lightTheme?: BundledTheme;
8
8
  darkTheme?: BundledTheme;
9
9
  };
10
- declare function CodeBlock({ children, className, code, language, lightTheme, darkTheme, title, ...props }: CodeBlockProps): Promise<react_jsx_runtime.JSX.Element>;
10
+ declare function CodeBlock({ children, className, code, language, lightTheme, darkTheme, title, ...props }: CodeBlockProps): Promise<react.JSX.Element>;
11
11
 
12
12
  export { CodeBlock, type CodeBlockProps };
@@ -1,8 +1,8 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
 
3
3
  declare function CopyCodeButton({ className, code, }: {
4
4
  className?: string;
5
5
  code: string;
6
- }): react_jsx_runtime.JSX.Element;
6
+ }): react.JSX.Element;
7
7
 
8
8
  export { CopyCodeButton };
@@ -1,6 +1,6 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
 
3
3
  type FigureCaptionProps = React.ComponentProps<"figcaption">;
4
- declare function FigureCaption({ className, ...props }: FigureCaptionProps): react_jsx_runtime.JSX.Element;
4
+ declare function FigureCaption({ className, ...props }: FigureCaptionProps): react.JSX.Element;
5
5
 
6
6
  export { FigureCaption, type FigureCaptionProps };
@@ -1,12 +1,12 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { FigureCaption } from './figure-caption.js';
1
+ import * as react from 'react';
3
2
  import { ReactNode } from 'react';
3
+ import { FigureCaption } from './figure-caption.js';
4
4
 
5
5
  type FigureProps = React.ComponentProps<"figure"> & {
6
6
  /** A fallback caption after the children. An authored caption takes precedence. */
7
7
  caption?: ReactNode;
8
8
  };
9
- declare function Figure({ caption, children, className, ...props }: FigureProps): react_jsx_runtime.JSX.Element;
9
+ declare function Figure({ caption, children, className, ...props }: FigureProps): react.JSX.Element;
10
10
  declare namespace Figure {
11
11
  var Caption: typeof FigureCaption;
12
12
  }
@@ -1,6 +1,6 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
 
3
3
  type FootnotesProps = React.ComponentPropsWithoutRef<"section">;
4
- declare function Footnotes({ className, ...props }: FootnotesProps): react_jsx_runtime.JSX.Element;
4
+ declare function Footnotes({ className, ...props }: FootnotesProps): react.JSX.Element;
5
5
 
6
6
  export { Footnotes, type FootnotesProps };
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
 
4
4
  declare function headingCopyUrl({ href, id }: {
@@ -18,6 +18,6 @@ declare function HeadingCopyLink({ className, id, children, iconOnly, }: {
18
18
  id: string;
19
19
  children?: ReactNode;
20
20
  iconOnly?: boolean;
21
- }): react_jsx_runtime.JSX.Element;
21
+ }): react.JSX.Element;
22
22
 
23
23
  export { HeadingCopyLink, headingCopyUrl };
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { ComponentPropsWithoutRef } from 'react';
3
3
 
4
4
  type HeadingElement = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
@@ -8,6 +8,6 @@ type HeadingProps<T extends HeadingElement> = {
8
8
  className?: string;
9
9
  };
10
10
 
11
- declare function Heading<T extends HeadingElement>({ as: Tag, children, className, id, ...props }: HeadingProps<T>): react_jsx_runtime.JSX.Element;
11
+ declare function Heading<T extends HeadingElement>({ as: Tag, children, className, id, ...props }: HeadingProps<T>): react.JSX.Element;
12
12
 
13
13
  export { Heading };
@@ -1,11 +1,11 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Separator as Separator$1 } from '@base-ui/react/separator';
1
+ import * as react from 'react';
3
2
  import { ComponentPropsWithoutRef } from 'react';
3
+ import { Separator as Separator$1 } from '@base-ui/react/separator';
4
4
 
5
5
  type SeparatorProps = ComponentPropsWithoutRef<typeof Separator$1>;
6
- declare function Separator({ className, orientation, ...props }: SeparatorProps): react_jsx_runtime.JSX.Element;
6
+ declare function Separator({ className, orientation, ...props }: SeparatorProps): react.JSX.Element;
7
7
 
8
8
  type HrProps = React.ComponentPropsWithoutRef<typeof Separator>;
9
- declare function Hr({ className, ...props }: HrProps): react_jsx_runtime.JSX.Element;
9
+ declare function Hr({ className, ...props }: HrProps): react.JSX.Element;
10
10
 
11
11
  export { Hr, type HrProps };
@@ -1,10 +1,10 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import * as react from 'react';
3
2
  import { ReactNode } from 'react';
4
3
 
5
- declare function ImageZoom({ children, enabled, }: {
4
+ declare function ImageZoom({ children, enabled, src, }: {
6
5
  children: ReactNode;
7
6
  enabled: boolean;
8
- }): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
7
+ src?: string;
8
+ }): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react.JSX.Element | null | undefined;
9
9
 
10
10
  export { ImageZoom };
@@ -5,9 +5,10 @@ import Zoom from "react-medium-image-zoom";
5
5
  import { jsx } from "@publish.os/nextjs/jsx-runtime";
6
6
  function ImageZoom({
7
7
  children,
8
- enabled
8
+ enabled,
9
+ src
9
10
  }) {
10
- return enabled ? /* @__PURE__ */ jsx(Zoom, { zoomMargin: 40, children }) : children;
11
+ return enabled ? /* @__PURE__ */ jsx(Zoom, { zoomImg: src ? { src } : void 0, zoomMargin: 40, children }) : children;
11
12
  }
12
13
  export {
13
14
  ImageZoom
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
 
3
3
  type ImageProps = Omit<React.ComponentPropsWithoutRef<"img">, "height" | "sizes" | "width"> & {
4
4
  aspect?: number | `${number}/${number}`;
@@ -16,6 +16,6 @@ type ImageProps = Omit<React.ComponentPropsWithoutRef<"img">, "height" | "sizes"
16
16
  width?: number;
17
17
  zoom?: boolean;
18
18
  };
19
- declare function Image({ alt, aspect, caption, className, decorative: authoredDecorative, fill: authoredFill, frame, height, intrinsicHeight, intrinsicWidth, optimized: authoredOptimized, priority: authoredPriority, quality, sizes, src, width, zoom: authoredZoom, ...props }: ImageProps): react_jsx_runtime.JSX.Element | null;
19
+ declare function Image({ alt, aspect, caption, className, decorative: authoredDecorative, fill: authoredFill, frame, height, intrinsicHeight, intrinsicWidth, optimized: authoredOptimized, priority: authoredPriority, quality, sizes, src, width, zoom: authoredZoom, ...props }: ImageProps): react.JSX.Element | null;
20
20
 
21
21
  export { Image, type ImageProps };
@@ -130,7 +130,7 @@ function Image({
130
130
  framed && "rounded-media border border-stroke-2 bg-surface-2"
131
131
  ),
132
132
  style: layout.style,
133
- children: /* @__PURE__ */ jsx(ImageZoom, { enabled: zoom, children: image })
133
+ children: /* @__PURE__ */ jsx(ImageZoom, { enabled: zoom, src: stringSrc, children: image })
134
134
  }
135
135
  );
136
136
  return caption ? /* @__PURE__ */ jsxs("figure", { className: "not-markdown-prose my-8 w-full", children: [
@@ -1,6 +1,6 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
 
3
3
  type InlineCodeProps = React.ComponentPropsWithoutRef<"code">;
4
- declare function InlineCode({ className, ...props }: InlineCodeProps): react_jsx_runtime.JSX.Element;
4
+ declare function InlineCode({ className, ...props }: InlineCodeProps): react.JSX.Element;
5
5
 
6
6
  export { InlineCode, type InlineCodeProps };
@@ -1,7 +1,7 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
+ import { HTMLAttributes } from 'react';
2
3
  import * as class_variance_authority_types from 'class-variance-authority/types';
3
4
  import { VariantProps } from 'class-variance-authority';
4
- import { HTMLAttributes } from 'react';
5
5
 
6
6
  declare const kbdVariants: (props?: ({
7
7
  size?: "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
@@ -10,6 +10,6 @@ declare const kbdVariants: (props?: ({
10
10
  type KbdProps$1 = HTMLAttributes<HTMLElement> & VariantProps<typeof kbdVariants>;
11
11
 
12
12
  type KbdProps = Omit<KbdProps$1, "size">;
13
- declare function Kbd({ className, ...props }: KbdProps): react_jsx_runtime.JSX.Element;
13
+ declare function Kbd({ className, ...props }: KbdProps): react.JSX.Element;
14
14
 
15
15
  export { Kbd, type KbdProps };
@@ -1,8 +1,8 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
+ import { ReactNode, AnchorHTMLAttributes } from 'react';
2
3
  import * as class_variance_authority_types from 'class-variance-authority/types';
3
4
  import { VariantProps } from 'class-variance-authority';
4
5
  import { LinkProps as LinkProps$1 } from 'next/link';
5
- import { ReactNode, AnchorHTMLAttributes } from 'react';
6
6
 
7
7
  declare const buttonVariants: (props?: ({
8
8
  readonly variant?: "solid" | "soft" | "outline" | "ghost" | null | undefined;
@@ -36,6 +36,6 @@ type LinkProps = {
36
36
  } & Omit<LinkVariantProps, "color" | "variant"> & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "color" | "href">;
37
37
 
38
38
  type MdxLinkProps = LinkProps;
39
- declare function Link({ color, href, size, variant, ...props }: MdxLinkProps): react_jsx_runtime.JSX.Element;
39
+ declare function Link({ color, href, size, variant, ...props }: MdxLinkProps): react.JSX.Element;
40
40
 
41
41
  export { Link, type MdxLinkProps };
@@ -1,5 +1,5 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
 
3
- declare function Paragraph({ children, className, ...props }: React.ComponentPropsWithoutRef<"p">): react_jsx_runtime.JSX.Element;
3
+ declare function Paragraph({ children, className, ...props }: React.ComponentPropsWithoutRef<"p">): react.JSX.Element;
4
4
 
5
5
  export { Paragraph };
@@ -1,6 +1,6 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
 
3
3
  type StrikethroughProps = React.ComponentPropsWithoutRef<"del">;
4
- declare function Strikethrough({ className, ...props }: StrikethroughProps): react_jsx_runtime.JSX.Element;
4
+ declare function Strikethrough({ className, ...props }: StrikethroughProps): react.JSX.Element;
5
5
 
6
6
  export { Strikethrough, type StrikethroughProps };