@publish.os/nextjs 0.0.1-alpha.5 → 0.0.1-alpha.6

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 (214) hide show
  1. package/README.md +1 -1
  2. package/dist/config/createNextConfig.js +3 -3
  3. package/dist/index.js +7 -5
  4. package/dist/kernel/components/blocks/color-palette.js +35 -4
  5. package/dist/kernel/components/blocks/logo-block.js +1 -1
  6. package/dist/kernel/components/blocks/nav-breadcrumb.js +2 -12
  7. package/dist/kernel/components/mdx/components/image.js +1 -1
  8. package/dist/kernel/components/ui/breadcrumb-trail.d.ts +3 -1
  9. package/dist/kernel/components/ui/breadcrumb-trail.js +1 -0
  10. package/dist/kernel/components/ui/breadcrumb.d.ts +1 -5
  11. package/dist/kernel/components/ui/breadcrumb.js +1 -16
  12. package/dist/kernel/components/ui/menu.js +5 -5
  13. package/dist/kernel/components/ui/navigation-menu.js +2 -2
  14. package/dist/kernel/components/ui/popover.js +5 -11
  15. package/dist/kernel/components/ui/select.js +5 -5
  16. package/dist/kernel/components/ui/text.js +109 -106
  17. package/dist/kernel/components/ui/tooltip.js +2 -2
  18. package/dist/kernel/defaults.registry.d.ts +60 -69
  19. package/dist/kernel/defaults.registry.js +59 -67
  20. package/dist/kernel/routes/agent/markdown.js +2 -2
  21. package/dist/kernel/routes/metadata/feed.js +2 -2
  22. package/dist/kernel/routes/metadata/llms.js +4 -2
  23. package/dist/kernel/routes/metadata/og-image.d.ts +1 -1
  24. package/dist/kernel/routes/metadata/robots.js +2 -2
  25. package/dist/kernel/routes/metadata/sitemap.js +2 -2
  26. package/dist/utils/cn.d.ts +1 -1
  27. package/package.json +2 -6
  28. package/release/package.json +3 -2
  29. package/release/release.json +5 -5
  30. package/release/{pnpm-lock.yaml → runtime-pnpm-lock.yaml} +135 -34
  31. package/dist/cache/tags.cjs +0 -79
  32. package/dist/cache/tags.d.cts +0 -13
  33. package/dist/config/createNextConfig.cjs +0 -52
  34. package/dist/config/createNextConfig.d.cts +0 -8
  35. package/dist/config.cjs +0 -78
  36. package/dist/config.d.cts +0 -101
  37. package/dist/config.d.ts +0 -101
  38. package/dist/config.js +0 -48
  39. package/dist/index.cjs +0 -1266
  40. package/dist/index.d.cts +0 -18
  41. package/dist/kernel/components/blocks/AgentActions.cjs +0 -425
  42. package/dist/kernel/components/blocks/AgentActions.d.cts +0 -52
  43. package/dist/kernel/components/blocks/animated-icon-swap.cjs +0 -101
  44. package/dist/kernel/components/blocks/animated-icon-swap.d.cts +0 -16
  45. package/dist/kernel/components/blocks/color-palette.cjs +0 -413
  46. package/dist/kernel/components/blocks/color-palette.d.cts +0 -7
  47. package/dist/kernel/components/blocks/design-system-preview.cjs +0 -593
  48. package/dist/kernel/components/blocks/design-system-preview.d.cts +0 -29
  49. package/dist/kernel/components/blocks/link-playground.cjs +0 -816
  50. package/dist/kernel/components/blocks/link-playground.d.cts +0 -5
  51. package/dist/kernel/components/blocks/logo-block.cjs +0 -156
  52. package/dist/kernel/components/blocks/logo-block.d.cts +0 -21
  53. package/dist/kernel/components/blocks/nav-breadcrumb.cjs +0 -122
  54. package/dist/kernel/components/blocks/nav-breadcrumb.d.cts +0 -11
  55. package/dist/kernel/components/blocks/navbar.cjs +0 -154
  56. package/dist/kernel/components/blocks/navbar.d.cts +0 -16
  57. package/dist/kernel/components/blocks/navigation-progress-playground.cjs +0 -735
  58. package/dist/kernel/components/blocks/navigation-progress-playground.d.cts +0 -5
  59. package/dist/kernel/components/blocks/navigation-progress.cjs +0 -270
  60. package/dist/kernel/components/blocks/navigation-progress.d.cts +0 -16
  61. package/dist/kernel/components/blocks/next-prev.cjs +0 -142
  62. package/dist/kernel/components/blocks/next-prev.d.cts +0 -11
  63. package/dist/kernel/components/blocks/page-list.cjs +0 -59
  64. package/dist/kernel/components/blocks/page-list.d.cts +0 -11
  65. package/dist/kernel/components/blocks/search.cjs +0 -717
  66. package/dist/kernel/components/blocks/search.d.cts +0 -77
  67. package/dist/kernel/components/blocks/sidebar-node.cjs +0 -309
  68. package/dist/kernel/components/blocks/sidebar-node.d.cts +0 -8
  69. package/dist/kernel/components/blocks/sidebar.cjs +0 -317
  70. package/dist/kernel/components/blocks/sidebar.d.cts +0 -33
  71. package/dist/kernel/components/blocks/theme-toggle.cjs +0 -31
  72. package/dist/kernel/components/blocks/theme-toggle.d.cts +0 -6
  73. package/dist/kernel/components/blocks/toc.cjs +0 -356
  74. package/dist/kernel/components/blocks/toc.d.cts +0 -10
  75. package/dist/kernel/components/mdx/components/blockquote.cjs +0 -66
  76. package/dist/kernel/components/mdx/components/blockquote.d.cts +0 -6
  77. package/dist/kernel/components/mdx/components/callout.cjs +0 -137
  78. package/dist/kernel/components/mdx/components/callout.d.cts +0 -18
  79. package/dist/kernel/components/mdx/components/code-block.cjs +0 -39
  80. package/dist/kernel/components/mdx/components/code-block.d.cts +0 -9
  81. package/dist/kernel/components/mdx/components/figure-caption.cjs +0 -63
  82. package/dist/kernel/components/mdx/components/figure-caption.d.cts +0 -6
  83. package/dist/kernel/components/mdx/components/figure.cjs +0 -78
  84. package/dist/kernel/components/mdx/components/figure.d.cts +0 -10
  85. package/dist/kernel/components/mdx/components/footnotes.cjs +0 -66
  86. package/dist/kernel/components/mdx/components/footnotes.d.cts +0 -6
  87. package/dist/kernel/components/mdx/components/heading-copy-link.cjs +0 -108
  88. package/dist/kernel/components/mdx/components/heading-copy-link.d.cts +0 -23
  89. package/dist/kernel/components/mdx/components/heading.cjs +0 -166
  90. package/dist/kernel/components/mdx/components/heading.d.cts +0 -8
  91. package/dist/kernel/components/mdx/components/hr.cjs +0 -34
  92. package/dist/kernel/components/mdx/components/hr.d.cts +0 -9
  93. package/dist/kernel/components/mdx/components/image-zoom.cjs +0 -49
  94. package/dist/kernel/components/mdx/components/image-zoom.d.cts +0 -10
  95. package/dist/kernel/components/mdx/components/image.cjs +0 -192
  96. package/dist/kernel/components/mdx/components/image.d.cts +0 -21
  97. package/dist/kernel/components/mdx/components/inline-code.cjs +0 -66
  98. package/dist/kernel/components/mdx/components/inline-code.d.cts +0 -6
  99. package/dist/kernel/components/mdx/components/kbd.cjs +0 -34
  100. package/dist/kernel/components/mdx/components/kbd.d.cts +0 -10
  101. package/dist/kernel/components/mdx/components/link.cjs +0 -49
  102. package/dist/kernel/components/mdx/components/link.d.cts +0 -11
  103. package/dist/kernel/components/mdx/components/paragraph.cjs +0 -87
  104. package/dist/kernel/components/mdx/components/paragraph.d.cts +0 -5
  105. package/dist/kernel/components/mdx/components/pre.cjs +0 -66
  106. package/dist/kernel/components/mdx/components/pre.d.cts +0 -6
  107. package/dist/kernel/components/mdx/components/strikethrough.cjs +0 -63
  108. package/dist/kernel/components/mdx/components/strikethrough.d.cts +0 -6
  109. package/dist/kernel/components/mdx/components/table.cjs +0 -59
  110. package/dist/kernel/components/mdx/components/table.d.cts +0 -10
  111. package/dist/kernel/components/mdx/components/task-list.cjs +0 -88
  112. package/dist/kernel/components/mdx/components/task-list.d.cts +0 -8
  113. package/dist/kernel/components/mdx/components/video-player.cjs +0 -173
  114. package/dist/kernel/components/mdx/components/video-player.d.cts +0 -18
  115. package/dist/kernel/components/mdx/components/video.cjs +0 -185
  116. package/dist/kernel/components/mdx/components/video.d.cts +0 -15
  117. package/dist/kernel/components/mdx/error-boundary.cjs +0 -62
  118. package/dist/kernel/components/mdx/error-boundary.d.cts +0 -8
  119. package/dist/kernel/components/mdx/error-fallback.cjs +0 -58
  120. package/dist/kernel/components/mdx/error-fallback.d.cts +0 -9
  121. package/dist/kernel/components/mdx/mdx.cjs +0 -141
  122. package/dist/kernel/components/mdx/mdx.d.cts +0 -22
  123. package/dist/kernel/components/mdx/rehype-heading-ids.cjs +0 -113
  124. package/dist/kernel/components/mdx/rehype-heading-ids.d.cts +0 -10
  125. package/dist/kernel/components/mdx/types.cjs +0 -18
  126. package/dist/kernel/components/mdx/types.d.cts +0 -18
  127. package/dist/kernel/components/ui/accordion.cjs +0 -104
  128. package/dist/kernel/components/ui/accordion.d.cts +0 -16
  129. package/dist/kernel/components/ui/breadcrumb-trail.cjs +0 -238
  130. package/dist/kernel/components/ui/breadcrumb-trail.d.cts +0 -13
  131. package/dist/kernel/components/ui/breadcrumb.cjs +0 -399
  132. package/dist/kernel/components/ui/breadcrumb.d.cts +0 -52
  133. package/dist/kernel/components/ui/button-group.cjs +0 -143
  134. package/dist/kernel/components/ui/button-group.d.cts +0 -19
  135. package/dist/kernel/components/ui/button.cjs +0 -139
  136. package/dist/kernel/components/ui/button.d.cts +0 -22
  137. package/dist/kernel/components/ui/card.cjs +0 -133
  138. package/dist/kernel/components/ui/card.d.cts +0 -17
  139. package/dist/kernel/components/ui/dialog.cjs +0 -149
  140. package/dist/kernel/components/ui/dialog.d.cts +0 -22
  141. package/dist/kernel/components/ui/drawer.cjs +0 -163
  142. package/dist/kernel/components/ui/drawer.d.cts +0 -24
  143. package/dist/kernel/components/ui/input.cjs +0 -96
  144. package/dist/kernel/components/ui/input.d.cts +0 -18
  145. package/dist/kernel/components/ui/kbd.cjs +0 -105
  146. package/dist/kernel/components/ui/kbd.d.cts +0 -13
  147. package/dist/kernel/components/ui/link.cjs +0 -253
  148. package/dist/kernel/components/ui/link.d.cts +0 -31
  149. package/dist/kernel/components/ui/menu.cjs +0 -301
  150. package/dist/kernel/components/ui/menu.d.cts +0 -70
  151. package/dist/kernel/components/ui/meta-key.cjs +0 -34
  152. package/dist/kernel/components/ui/meta-key.d.cts +0 -12
  153. package/dist/kernel/components/ui/navigation-menu.cjs +0 -253
  154. package/dist/kernel/components/ui/navigation-menu.d.cts +0 -47
  155. package/dist/kernel/components/ui/popover.cjs +0 -168
  156. package/dist/kernel/components/ui/popover.d.cts +0 -24
  157. package/dist/kernel/components/ui/progress.cjs +0 -112
  158. package/dist/kernel/components/ui/progress.d.cts +0 -16
  159. package/dist/kernel/components/ui/scroll-area.cjs +0 -413
  160. package/dist/kernel/components/ui/scroll-area.d.cts +0 -58
  161. package/dist/kernel/components/ui/select.cjs +0 -244
  162. package/dist/kernel/components/ui/select.d.cts +0 -40
  163. package/dist/kernel/components/ui/separator.cjs +0 -73
  164. package/dist/kernel/components/ui/separator.d.cts +0 -8
  165. package/dist/kernel/components/ui/table.cjs +0 -131
  166. package/dist/kernel/components/ui/table.d.cts +0 -11
  167. package/dist/kernel/components/ui/tabs.cjs +0 -450
  168. package/dist/kernel/components/ui/tabs.d.cts +0 -82
  169. package/dist/kernel/components/ui/tag.cjs +0 -104
  170. package/dist/kernel/components/ui/tag.d.cts +0 -14
  171. package/dist/kernel/components/ui/text.cjs +0 -184
  172. package/dist/kernel/components/ui/text.d.cts +0 -17
  173. package/dist/kernel/components/ui/theme-toggle.cjs +0 -108
  174. package/dist/kernel/components/ui/theme-toggle.d.cts +0 -10
  175. package/dist/kernel/components/ui/toast.cjs +0 -154
  176. package/dist/kernel/components/ui/toast.d.cts +0 -26
  177. package/dist/kernel/components/ui/tooltip.cjs +0 -127
  178. package/dist/kernel/components/ui/tooltip.d.cts +0 -20
  179. package/dist/kernel/defaults.registry.cjs +0 -541
  180. package/dist/kernel/defaults.registry.d.cts +0 -469
  181. package/dist/kernel/routes/agent/markdown.cjs +0 -202
  182. package/dist/kernel/routes/agent/markdown.d.cts +0 -58
  183. package/dist/kernel/routes/layouts/group.cjs +0 -181
  184. package/dist/kernel/routes/layouts/group.d.cts +0 -20
  185. package/dist/kernel/routes/metadata/feed.cjs +0 -293
  186. package/dist/kernel/routes/metadata/feed.d.cts +0 -20
  187. package/dist/kernel/routes/metadata/llms.cjs +0 -239
  188. package/dist/kernel/routes/metadata/llms.d.cts +0 -26
  189. package/dist/kernel/routes/metadata/og-image.cjs +0 -630
  190. package/dist/kernel/routes/metadata/og-image.d.cts +0 -62
  191. package/dist/kernel/routes/metadata/robots.cjs +0 -148
  192. package/dist/kernel/routes/metadata/robots.d.cts +0 -6
  193. package/dist/kernel/routes/metadata/sitemap.cjs +0 -192
  194. package/dist/kernel/routes/metadata/sitemap.d.cts +0 -8
  195. package/dist/kernel/routes/pages/group.cjs +0 -263
  196. package/dist/kernel/routes/pages/group.d.cts +0 -17
  197. package/dist/kernel/routes/pages/leaf.cjs +0 -421
  198. package/dist/kernel/routes/pages/leaf.d.cts +0 -36
  199. package/dist/kernel/routes/pages/root.cjs +0 -229
  200. package/dist/kernel/routes/pages/root.d.cts +0 -16
  201. package/dist/keyboard-shortcuts.cjs +0 -345
  202. package/dist/keyboard-shortcuts.d.cts +0 -34
  203. package/dist/resolvers/manifest-resolver.cjs +0 -111
  204. package/dist/resolvers/manifest-resolver.d.cts +0 -13
  205. package/dist/search.cjs +0 -411
  206. package/dist/search.d.cts +0 -20
  207. package/dist/types.cjs +0 -30
  208. package/dist/types.d.cts +0 -269
  209. package/dist/utils/cn.cjs +0 -49
  210. package/dist/utils/cn.d.cts +0 -15
  211. package/dist/utils/heading-ids.cjs +0 -119
  212. package/dist/utils/heading-ids.d.cts +0 -15
  213. package/dist/utils/pretty-date.cjs +0 -55
  214. package/dist/utils/pretty-date.d.cts +0 -6
@@ -1,421 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/kernel/routes/pages/leaf.tsx
21
- var leaf_exports = {};
22
- __export(leaf_exports, {
23
- appendPoweredByFooter: () => appendPoweredByFooter,
24
- createLeafMetadata: () => createLeafMetadata,
25
- createLeafPage: () => createLeafPage,
26
- createLeafStaticParams: () => createLeafStaticParams
27
- });
28
- module.exports = __toCommonJS(leaf_exports);
29
- var import_mdx = require("@publish.os/nextjs/mdx");
30
- var import_cache = require("next/cache");
31
- var import_navigation = require("next/navigation");
32
- var import_react = require("react");
33
-
34
- // src/cache/tags.ts
35
- var import_node_crypto = require("crypto");
36
- var MAX_TAG_LEN = 256;
37
- var MAX_SEGMENT_LEN = 80;
38
- var TAG_PATTERN = /^[a-z0-9:_./-]+$/;
39
- function sha256(value) {
40
- return (0, import_node_crypto.createHash)("sha256").update(value).digest("hex").slice(0, 16);
41
- }
42
- function safeSegment(value) {
43
- const raw = value.trim().toLowerCase() || "root";
44
- const normalized = raw.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/^\//, "").replace(/\/$/, "").replace(/[^a-z0-9:_./-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
45
- const segment = normalized || "root";
46
- if (segment.length <= MAX_SEGMENT_LEN) return segment;
47
- return `${segment.slice(0, 48)}.${sha256(segment)}`;
48
- }
49
- function assertTag(tag) {
50
- if (tag.length > MAX_TAG_LEN || !TAG_PATTERN.test(tag)) {
51
- return `tag:${sha256(tag)}`;
52
- }
53
- return tag;
54
- }
55
- var tags = {
56
- site() {
57
- return "site";
58
- },
59
- pages() {
60
- return "pages";
61
- },
62
- group(group) {
63
- return assertTag(`group:${safeSegment(group)}`);
64
- },
65
- page(group, slug) {
66
- const path = Array.isArray(slug) ? slug.join("/") : slug;
67
- return assertTag(`page:${safeSegment(group)}:${safeSegment(path)}`);
68
- },
69
- manifest(contentHash) {
70
- return assertTag(`manifest:${safeSegment(contentHash)}`);
71
- },
72
- sitemap() {
73
- return "sitemap";
74
- },
75
- robots() {
76
- return "robots";
77
- },
78
- llms(scope = "root") {
79
- return assertTag(`llms:${safeSegment(scope)}`);
80
- },
81
- feed(format, scope = "site") {
82
- return assertTag(`feed:${safeSegment(format)}:${safeSegment(scope)}`);
83
- }
84
- };
85
-
86
- // src/internal/utils/logger.ts
87
- var isDev = process.env.NODE_ENV !== "production";
88
- var isDebugEnabled = process.env.NEXT_PRIVATE_DEBUG_CACHE === "1";
89
- var log = {
90
- debug(...args) {
91
- if (isDev && isDebugEnabled) console.debug("[publish.os:debug]", ...args);
92
- },
93
- info(...args) {
94
- console.log("[publish.os]", ...args);
95
- },
96
- warn(...args) {
97
- console.warn("[publish.os:warn]", ...args);
98
- },
99
- error(...args) {
100
- console.error("[publish.os:error]", ...args);
101
- }
102
- };
103
-
104
- // src/resolvers/manifest-resolver.ts
105
- function findNodeInTree(nodes, id) {
106
- for (const node of nodes) {
107
- if (node.type === "page") {
108
- if (node.fileID === id) return node;
109
- } else if (node.id === id) {
110
- return node;
111
- }
112
- if (node.type === "section" || node.type === "folder") {
113
- const found = findNodeInTree(node.children, id);
114
- if (found) return found;
115
- }
116
- }
117
- return null;
118
- }
119
- function pageNode(page) {
120
- return {
121
- type: "page",
122
- fileID: page.fileID,
123
- title: page.title,
124
- path: page.path,
125
- group: page.group,
126
- description: page.description,
127
- status: page.status,
128
- publishedAt: page.publishedAt,
129
- updatedAt: page.updatedAt,
130
- authors: page.authors,
131
- tags: page.tags,
132
- meta: page.meta
133
- };
134
- }
135
- function resolveLeaf(manifest, group, slug) {
136
- const slugPath = Array.isArray(slug) ? slug.join("/") : slug;
137
- const page = manifest.pages.find((p) => p.group === group && p.slug === slugPath) ?? null;
138
- if (!page) return null;
139
- const groupData = manifest.groups[group];
140
- if (!groupData) return null;
141
- return {
142
- site: manifest.site,
143
- tree: groupData.tree,
144
- node: findNodeInTree(groupData.tree, page.fileID) ?? pageNode(page),
145
- page,
146
- currentPath: page.path,
147
- group
148
- };
149
- }
150
- function listStaticParams(manifest, group) {
151
- const groupData = manifest.groups[group];
152
- if (!groupData) return [];
153
- return groupData.pages.map((page) => ({ slug: page.slug.split("/") }));
154
- }
155
-
156
- // src/kernel/routes/pages/agent-metadata.ts
157
- function normalizePath(path) {
158
- const prefixed = path.startsWith("/") ? path : `/${path}`;
159
- if (prefixed === "/") return prefixed;
160
- return prefixed.replace(/\/+$/, "");
161
- }
162
- function markdownPathForHtmlPath(path) {
163
- const normalized = normalizePath(path);
164
- if (normalized === "/") return "/index.md";
165
- return `${normalized}.md`;
166
- }
167
- function agentReadableAlternates({
168
- canonicalPath,
169
- manifest,
170
- markdownPath
171
- }) {
172
- return {
173
- ...manifest.site.url ? { canonical: normalizePath(canonicalPath) } : {},
174
- types: {
175
- ...markdownPath ? { "text/markdown": normalizePath(markdownPath) } : {},
176
- "text/plain": "/llms.txt"
177
- }
178
- };
179
- }
180
-
181
- // src/kernel/routes/pages/social-metadata.ts
182
- function isDevelopment() {
183
- return process.env.NODE_ENV === "development";
184
- }
185
- function absoluteUrl(path, siteUrl) {
186
- if (/^https:\/\//.test(path)) return path;
187
- if (isDevelopment()) return path;
188
- if (!siteUrl) return path;
189
- return new URL(path, siteUrl).toString();
190
- }
191
- function createSocialMetadata({
192
- canonicalPath,
193
- description,
194
- manifest,
195
- ogManifest,
196
- title,
197
- type = "website"
198
- }) {
199
- const key = ogManifest?.routes?.[canonicalPath];
200
- const rootKey = ogManifest?.routes?.["/"];
201
- const entry = (key ? ogManifest?.entries?.[key] : void 0) ?? (rootKey ? ogManifest?.entries?.[rootKey] : void 0);
202
- if (!entry) {
203
- return {
204
- openGraph: {
205
- description,
206
- title,
207
- type,
208
- url: canonicalPath
209
- },
210
- twitter: {
211
- card: "summary",
212
- description,
213
- title
214
- }
215
- };
216
- }
217
- const imageUrl = absoluteUrl(entry.url, manifest.site.url);
218
- return {
219
- openGraph: {
220
- description,
221
- images: [
222
- {
223
- alt: entry.alt,
224
- height: entry.height,
225
- url: imageUrl,
226
- width: entry.width
227
- }
228
- ],
229
- siteName: manifest.site.name,
230
- title,
231
- type,
232
- url: canonicalPath
233
- },
234
- twitter: {
235
- card: "summary_large_image",
236
- description,
237
- images: [imageUrl],
238
- title
239
- }
240
- };
241
- }
242
-
243
- // src/kernel/routes/pages/leaf.tsx
244
- var import_jsx_runtime = require("react/jsx-runtime");
245
- var manifests = /* @__PURE__ */ new Map();
246
- var leaves = /* @__PURE__ */ new Map();
247
- var poweredByFooters = /* @__PURE__ */ new Map();
248
- function hasClassName(value, className) {
249
- return typeof value === "string" && value.split(/\s+/).includes(className);
250
- }
251
- function isPlatformMdx(value) {
252
- return value === import_mdx.MDX || typeof value === "function" && value.__publishOsMdx === true;
253
- }
254
- function findMdxPath(node) {
255
- if (!(0, import_react.isValidElement)(node)) {
256
- return null;
257
- }
258
- if (isPlatformMdx(node.type)) {
259
- return [];
260
- }
261
- const children = import_react.Children.toArray(node.props.children);
262
- for (let index = 0; index < children.length; index += 1) {
263
- const childPath = findMdxPath(children[index]);
264
- if (childPath) {
265
- return [
266
- {
267
- childIndex: index,
268
- children,
269
- element: node
270
- },
271
- ...childPath
272
- ];
273
- }
274
- }
275
- return null;
276
- }
277
- function targetDepthForMdxPath(path) {
278
- for (let index = path.length - 1; index >= 0; index -= 1) {
279
- const entry = path[index];
280
- if (entry && entry.childIndex < entry.children.length - 1) {
281
- return index;
282
- }
283
- }
284
- for (let index = path.length - 1; index >= 0; index -= 1) {
285
- const entry = path[index];
286
- if (!hasClassName(entry?.element.props.className, "markdown-prose")) {
287
- return index;
288
- }
289
- }
290
- return 0;
291
- }
292
- function appendFooterAtPath({
293
- currentPath = [],
294
- footer,
295
- node,
296
- targetPath
297
- }) {
298
- if (!(0, import_react.isValidElement)(node)) {
299
- return node;
300
- }
301
- const children = import_react.Children.toArray(node.props.children);
302
- if (currentPath.length === targetPath.length) {
303
- return (0, import_react.cloneElement)(node, void 0, ...children, footer);
304
- }
305
- const childIndex = targetPath[currentPath.length];
306
- const nextChildren = children.map(
307
- (child, index) => index === childIndex ? appendFooterAtPath({
308
- currentPath: [...currentPath, index],
309
- footer,
310
- node: child,
311
- targetPath
312
- }) : child
313
- );
314
- return (0, import_react.cloneElement)(node, void 0, ...nextChildren);
315
- }
316
- function appendPoweredByFooter({
317
- footer,
318
- node
319
- }) {
320
- const path = findMdxPath(node);
321
- if (!path?.length) {
322
- return { node, placed: false };
323
- }
324
- const targetDepth = targetDepthForMdxPath(path);
325
- const targetPath = path.slice(0, targetDepth).map((entry) => entry.childIndex);
326
- return {
327
- node: appendFooterAtPath({ footer, node, targetPath }),
328
- placed: true
329
- };
330
- }
331
- async function CachedLeafPage({
332
- group,
333
- slug
334
- }) {
335
- "use cache";
336
- (0, import_cache.cacheLife)("page");
337
- (0, import_cache.cacheTag)(
338
- tags.site(),
339
- tags.pages(),
340
- tags.group(group),
341
- tags.page(group, slug)
342
- );
343
- const manifest = manifests.get(group);
344
- const Leaf = leaves.get(group);
345
- const PoweredByFooter = poweredByFooters.get(group);
346
- if (!manifest || !Leaf) (0, import_navigation.notFound)();
347
- (0, import_cache.cacheTag)(tags.manifest(manifest.contentHash));
348
- log.debug("[cache]", `${group}/${slug.join("/")}`);
349
- const resolved = resolveLeaf(manifest, group, slug);
350
- if (!resolved) (0, import_navigation.notFound)();
351
- const attribution = manifest.attribution?.[group] ?? { enabled: false };
352
- const leaf = await Leaf(resolved);
353
- const footer = attribution.enabled && PoweredByFooter ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PoweredByFooter, { attribution }) : null;
354
- const placed = footer ? appendPoweredByFooter({ footer, node: leaf }) : { node: leaf, placed: true };
355
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex min-h-full min-w-0 flex-1 flex-col", children: [
356
- placed.node,
357
- footer && !placed.placed ? footer : null
358
- ] });
359
- }
360
- function createLeafPage({
361
- group,
362
- manifest,
363
- Leaf,
364
- PoweredByFooter
365
- }) {
366
- manifests.set(group, manifest);
367
- leaves.set(group, Leaf);
368
- if (PoweredByFooter) {
369
- poweredByFooters.set(group, PoweredByFooter);
370
- } else {
371
- poweredByFooters.delete(group);
372
- }
373
- return async function Page({ params }) {
374
- const { slug = [] } = await params;
375
- log.debug("[render]", `${group}/${slug.join("/")}`);
376
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CachedLeafPage, { group, slug });
377
- };
378
- }
379
- function createLeafMetadata({
380
- group,
381
- manifest,
382
- ogManifest
383
- }) {
384
- return async function generateMetadata({
385
- params
386
- }) {
387
- const { slug = [] } = await params;
388
- log.debug("[metadata]", `${group}/${slug.join("/")}`);
389
- const resolved = resolveLeaf(manifest, group, slug);
390
- if (!resolved) return {};
391
- return {
392
- title: resolved.page.title,
393
- description: resolved.page.description,
394
- alternates: agentReadableAlternates({
395
- canonicalPath: resolved.page.path,
396
- manifest,
397
- markdownPath: markdownPathForHtmlPath(resolved.page.path)
398
- }),
399
- ...createSocialMetadata({
400
- canonicalPath: resolved.page.path,
401
- description: resolved.page.description,
402
- manifest,
403
- ogManifest,
404
- title: resolved.page.title,
405
- type: "article"
406
- })
407
- };
408
- };
409
- }
410
- function createLeafStaticParams({ group, manifest }) {
411
- return function generateStaticParams() {
412
- return listStaticParams(manifest, group);
413
- };
414
- }
415
- // Annotate the CommonJS export names for ESM import in node:
416
- 0 && (module.exports = {
417
- appendPoweredByFooter,
418
- createLeafMetadata,
419
- createLeafPage,
420
- createLeafStaticParams
421
- });
@@ -1,36 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Metadata } from 'next';
3
- import { ReactElement, ReactNode } from 'react';
4
- import { PageProps, ManifestLike, ResolvedAttribution } from '../../../types.cjs';
5
- import { OgManifestLike } from '../metadata/og-image.cjs';
6
-
7
- type LeafComponent = (props: PageProps) => ReactElement | Promise<ReactElement>;
8
- type PoweredByFooterComponent = (props: {
9
- attribution: ResolvedAttribution;
10
- }) => ReactElement | null;
11
- type LeafRouteConfig = {
12
- group: string;
13
- manifest: ManifestLike;
14
- ogManifest?: OgManifestLike;
15
- Leaf: LeafComponent;
16
- PoweredByFooter?: PoweredByFooterComponent;
17
- };
18
- type PageRouteProps = {
19
- params: Promise<{
20
- slug?: string[];
21
- }>;
22
- };
23
- declare function appendPoweredByFooter({ footer, node, }: {
24
- footer: ReactElement;
25
- node: ReactNode;
26
- }): {
27
- node: ReactNode;
28
- placed: boolean;
29
- };
30
- declare function createLeafPage({ group, manifest, Leaf, PoweredByFooter, }: LeafRouteConfig): ({ params }: PageRouteProps) => Promise<react_jsx_runtime.JSX.Element>;
31
- declare function createLeafMetadata({ group, manifest, ogManifest, }: LeafRouteConfig): ({ params, }: PageRouteProps) => Promise<Metadata>;
32
- declare function createLeafStaticParams({ group, manifest }: LeafRouteConfig): () => {
33
- slug: string[];
34
- }[];
35
-
36
- export { type LeafComponent, type LeafRouteConfig, type PoweredByFooterComponent, appendPoweredByFooter, createLeafMetadata, createLeafPage, createLeafStaticParams };
@@ -1,229 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/kernel/routes/pages/root.tsx
21
- var root_exports = {};
22
- __export(root_exports, {
23
- createRootMetadata: () => createRootMetadata,
24
- createRootPage: () => createRootPage
25
- });
26
- module.exports = __toCommonJS(root_exports);
27
- var import_cache = require("next/cache");
28
-
29
- // src/cache/tags.ts
30
- var import_node_crypto = require("crypto");
31
- var MAX_TAG_LEN = 256;
32
- var MAX_SEGMENT_LEN = 80;
33
- var TAG_PATTERN = /^[a-z0-9:_./-]+$/;
34
- function sha256(value) {
35
- return (0, import_node_crypto.createHash)("sha256").update(value).digest("hex").slice(0, 16);
36
- }
37
- function safeSegment(value) {
38
- const raw = value.trim().toLowerCase() || "root";
39
- const normalized = raw.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/^\//, "").replace(/\/$/, "").replace(/[^a-z0-9:_./-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
40
- const segment = normalized || "root";
41
- if (segment.length <= MAX_SEGMENT_LEN) return segment;
42
- return `${segment.slice(0, 48)}.${sha256(segment)}`;
43
- }
44
- function assertTag(tag) {
45
- if (tag.length > MAX_TAG_LEN || !TAG_PATTERN.test(tag)) {
46
- return `tag:${sha256(tag)}`;
47
- }
48
- return tag;
49
- }
50
- var tags = {
51
- site() {
52
- return "site";
53
- },
54
- pages() {
55
- return "pages";
56
- },
57
- group(group) {
58
- return assertTag(`group:${safeSegment(group)}`);
59
- },
60
- page(group, slug) {
61
- const path = Array.isArray(slug) ? slug.join("/") : slug;
62
- return assertTag(`page:${safeSegment(group)}:${safeSegment(path)}`);
63
- },
64
- manifest(contentHash) {
65
- return assertTag(`manifest:${safeSegment(contentHash)}`);
66
- },
67
- sitemap() {
68
- return "sitemap";
69
- },
70
- robots() {
71
- return "robots";
72
- },
73
- llms(scope = "root") {
74
- return assertTag(`llms:${safeSegment(scope)}`);
75
- },
76
- feed(format, scope = "site") {
77
- return assertTag(`feed:${safeSegment(format)}:${safeSegment(scope)}`);
78
- }
79
- };
80
-
81
- // src/internal/utils/logger.ts
82
- var isDev = process.env.NODE_ENV !== "production";
83
- var isDebugEnabled = process.env.NEXT_PRIVATE_DEBUG_CACHE === "1";
84
- var log = {
85
- debug(...args) {
86
- if (isDev && isDebugEnabled) console.debug("[publish.os:debug]", ...args);
87
- },
88
- info(...args) {
89
- console.log("[publish.os]", ...args);
90
- },
91
- warn(...args) {
92
- console.warn("[publish.os:warn]", ...args);
93
- },
94
- error(...args) {
95
- console.error("[publish.os:error]", ...args);
96
- }
97
- };
98
-
99
- // src/kernel/routes/pages/agent-metadata.ts
100
- function normalizePath(path) {
101
- const prefixed = path.startsWith("/") ? path : `/${path}`;
102
- if (prefixed === "/") return prefixed;
103
- return prefixed.replace(/\/+$/, "");
104
- }
105
- function agentReadableAlternates({
106
- canonicalPath,
107
- manifest,
108
- markdownPath
109
- }) {
110
- return {
111
- ...manifest.site.url ? { canonical: normalizePath(canonicalPath) } : {},
112
- types: {
113
- ...markdownPath ? { "text/markdown": normalizePath(markdownPath) } : {},
114
- "text/plain": "/llms.txt"
115
- }
116
- };
117
- }
118
-
119
- // src/kernel/routes/pages/social-metadata.ts
120
- function isDevelopment() {
121
- return process.env.NODE_ENV === "development";
122
- }
123
- function absoluteUrl(path, siteUrl) {
124
- if (/^https:\/\//.test(path)) return path;
125
- if (isDevelopment()) return path;
126
- if (!siteUrl) return path;
127
- return new URL(path, siteUrl).toString();
128
- }
129
- function createSocialMetadata({
130
- canonicalPath,
131
- description,
132
- manifest,
133
- ogManifest,
134
- title,
135
- type = "website"
136
- }) {
137
- const key = ogManifest?.routes?.[canonicalPath];
138
- const rootKey = ogManifest?.routes?.["/"];
139
- const entry = (key ? ogManifest?.entries?.[key] : void 0) ?? (rootKey ? ogManifest?.entries?.[rootKey] : void 0);
140
- if (!entry) {
141
- return {
142
- openGraph: {
143
- description,
144
- title,
145
- type,
146
- url: canonicalPath
147
- },
148
- twitter: {
149
- card: "summary",
150
- description,
151
- title
152
- }
153
- };
154
- }
155
- const imageUrl = absoluteUrl(entry.url, manifest.site.url);
156
- return {
157
- openGraph: {
158
- description,
159
- images: [
160
- {
161
- alt: entry.alt,
162
- height: entry.height,
163
- url: imageUrl,
164
- width: entry.width
165
- }
166
- ],
167
- siteName: manifest.site.name,
168
- title,
169
- type,
170
- url: canonicalPath
171
- },
172
- twitter: {
173
- card: "summary_large_image",
174
- description,
175
- images: [imageUrl],
176
- title
177
- }
178
- };
179
- }
180
-
181
- // src/kernel/routes/pages/root.tsx
182
- var import_jsx_runtime = require("react/jsx-runtime");
183
- var rootManifest;
184
- var rootPage;
185
- async function CachedRootPage() {
186
- "use cache";
187
- (0, import_cache.cacheLife)("page");
188
- (0, import_cache.cacheTag)(tags.site());
189
- if (!rootManifest || !rootPage) return null;
190
- (0, import_cache.cacheTag)(tags.manifest(rootManifest.contentHash));
191
- log.debug("[cache]", "root");
192
- const RootPage = rootPage;
193
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RootPage, { site: rootManifest.site, tree: rootManifest.tree });
194
- }
195
- function createRootPage({ manifest, RootPage }) {
196
- rootManifest = manifest;
197
- rootPage = RootPage;
198
- return async function Page() {
199
- log.debug("[render]", "root");
200
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CachedRootPage, {});
201
- };
202
- }
203
- function createRootMetadata({
204
- manifest,
205
- ogManifest
206
- }) {
207
- const description = manifest.site.description;
208
- return {
209
- title: manifest.site.name,
210
- description,
211
- alternates: agentReadableAlternates({
212
- canonicalPath: "/",
213
- manifest,
214
- markdownPath: "/sitemap.md"
215
- }),
216
- ...createSocialMetadata({
217
- canonicalPath: "/",
218
- description,
219
- manifest,
220
- ogManifest,
221
- title: manifest.site.name
222
- })
223
- };
224
- }
225
- // Annotate the CommonJS export names for ESM import in node:
226
- 0 && (module.exports = {
227
- createRootMetadata,
228
- createRootPage
229
- });
@@ -1,16 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Metadata } from 'next';
3
- import { ReactElement } from 'react';
4
- import { RootPageProps, ManifestLike } from '../../../types.cjs';
5
- import { OgManifestLike } from '../metadata/og-image.cjs';
6
-
7
- type RootPageComponent = (props: RootPageProps) => ReactElement | Promise<ReactElement>;
8
- type RootRouteConfig = {
9
- manifest: ManifestLike;
10
- ogManifest?: OgManifestLike;
11
- RootPage: RootPageComponent;
12
- };
13
- declare function createRootPage({ manifest, RootPage }: RootRouteConfig): () => Promise<react_jsx_runtime.JSX.Element>;
14
- declare function createRootMetadata({ manifest, ogManifest, }: RootRouteConfig): Metadata;
15
-
16
- export { type RootPageComponent, type RootRouteConfig, createRootMetadata, createRootPage };