@publish.os/nextjs 0.0.1-alpha.4 → 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 (229) 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/design-system-preview.js +18 -17
  6. package/dist/kernel/components/blocks/link-playground.js +3 -3
  7. package/dist/kernel/components/blocks/logo-block.js +1 -1
  8. package/dist/kernel/components/blocks/nav-breadcrumb.js +2 -12
  9. package/dist/kernel/components/blocks/navbar.js +1 -1
  10. package/dist/kernel/components/blocks/navigation-progress-playground.js +2 -2
  11. package/dist/kernel/components/mdx/components/image.js +1 -1
  12. package/dist/kernel/components/ui/breadcrumb-trail.d.ts +3 -1
  13. package/dist/kernel/components/ui/breadcrumb-trail.js +1 -0
  14. package/dist/kernel/components/ui/breadcrumb.d.ts +1 -5
  15. package/dist/kernel/components/ui/breadcrumb.js +1 -16
  16. package/dist/kernel/components/ui/button-group.d.ts +2 -2
  17. package/dist/kernel/components/ui/button-group.js +2 -3
  18. package/dist/kernel/components/ui/button.d.ts +3 -4
  19. package/dist/kernel/components/ui/button.js +4 -12
  20. package/dist/kernel/components/ui/card.d.ts +1 -1
  21. package/dist/kernel/components/ui/menu.js +5 -5
  22. package/dist/kernel/components/ui/navigation-menu.js +2 -2
  23. package/dist/kernel/components/ui/popover.js +5 -11
  24. package/dist/kernel/components/ui/select.js +5 -5
  25. package/dist/kernel/components/ui/tag.d.ts +14 -0
  26. package/dist/kernel/components/ui/tag.js +76 -0
  27. package/dist/kernel/components/ui/text.d.ts +1 -1
  28. package/dist/kernel/components/ui/text.js +109 -106
  29. package/dist/kernel/components/ui/theme-toggle.js +1 -1
  30. package/dist/kernel/components/ui/tooltip.js +2 -2
  31. package/dist/kernel/defaults.registry.d.ts +63 -72
  32. package/dist/kernel/defaults.registry.js +62 -70
  33. package/dist/kernel/routes/agent/markdown.js +2 -2
  34. package/dist/kernel/routes/metadata/feed.js +2 -2
  35. package/dist/kernel/routes/metadata/llms.js +4 -2
  36. package/dist/kernel/routes/metadata/og-image.d.ts +1 -1
  37. package/dist/kernel/routes/metadata/robots.js +2 -2
  38. package/dist/kernel/routes/metadata/sitemap.js +2 -2
  39. package/dist/utils/cn.d.ts +1 -1
  40. package/package.json +4 -9
  41. package/release/package.json +4 -3
  42. package/release/release.json +5 -5
  43. package/release/{pnpm-lock.yaml → runtime-pnpm-lock.yaml} +348 -224
  44. package/dist/cache/tags.cjs +0 -79
  45. package/dist/cache/tags.d.cts +0 -13
  46. package/dist/config/createNextConfig.cjs +0 -52
  47. package/dist/config/createNextConfig.d.cts +0 -8
  48. package/dist/config.cjs +0 -78
  49. package/dist/config.d.cts +0 -101
  50. package/dist/config.d.ts +0 -101
  51. package/dist/config.js +0 -48
  52. package/dist/index.cjs +0 -1266
  53. package/dist/index.d.cts +0 -18
  54. package/dist/kernel/components/blocks/AgentActions.cjs +0 -425
  55. package/dist/kernel/components/blocks/AgentActions.d.cts +0 -52
  56. package/dist/kernel/components/blocks/animated-icon-swap.cjs +0 -101
  57. package/dist/kernel/components/blocks/animated-icon-swap.d.cts +0 -16
  58. package/dist/kernel/components/blocks/color-palette.cjs +0 -413
  59. package/dist/kernel/components/blocks/color-palette.d.cts +0 -7
  60. package/dist/kernel/components/blocks/design-system-preview.cjs +0 -592
  61. package/dist/kernel/components/blocks/design-system-preview.d.cts +0 -29
  62. package/dist/kernel/components/blocks/link-playground.cjs +0 -816
  63. package/dist/kernel/components/blocks/link-playground.d.cts +0 -5
  64. package/dist/kernel/components/blocks/logo-block.cjs +0 -156
  65. package/dist/kernel/components/blocks/logo-block.d.cts +0 -21
  66. package/dist/kernel/components/blocks/nav-breadcrumb.cjs +0 -122
  67. package/dist/kernel/components/blocks/nav-breadcrumb.d.cts +0 -11
  68. package/dist/kernel/components/blocks/navbar.cjs +0 -154
  69. package/dist/kernel/components/blocks/navbar.d.cts +0 -16
  70. package/dist/kernel/components/blocks/navigation-progress-playground.cjs +0 -735
  71. package/dist/kernel/components/blocks/navigation-progress-playground.d.cts +0 -5
  72. package/dist/kernel/components/blocks/navigation-progress.cjs +0 -270
  73. package/dist/kernel/components/blocks/navigation-progress.d.cts +0 -16
  74. package/dist/kernel/components/blocks/next-prev.cjs +0 -142
  75. package/dist/kernel/components/blocks/next-prev.d.cts +0 -11
  76. package/dist/kernel/components/blocks/page-list.cjs +0 -59
  77. package/dist/kernel/components/blocks/page-list.d.cts +0 -11
  78. package/dist/kernel/components/blocks/search.cjs +0 -717
  79. package/dist/kernel/components/blocks/search.d.cts +0 -77
  80. package/dist/kernel/components/blocks/sidebar-node.cjs +0 -309
  81. package/dist/kernel/components/blocks/sidebar-node.d.cts +0 -8
  82. package/dist/kernel/components/blocks/sidebar.cjs +0 -317
  83. package/dist/kernel/components/blocks/sidebar.d.cts +0 -33
  84. package/dist/kernel/components/blocks/theme-toggle.cjs +0 -31
  85. package/dist/kernel/components/blocks/theme-toggle.d.cts +0 -6
  86. package/dist/kernel/components/blocks/toc.cjs +0 -356
  87. package/dist/kernel/components/blocks/toc.d.cts +0 -10
  88. package/dist/kernel/components/mdx/components/blockquote.cjs +0 -66
  89. package/dist/kernel/components/mdx/components/blockquote.d.cts +0 -6
  90. package/dist/kernel/components/mdx/components/callout.cjs +0 -137
  91. package/dist/kernel/components/mdx/components/callout.d.cts +0 -18
  92. package/dist/kernel/components/mdx/components/code-block.cjs +0 -39
  93. package/dist/kernel/components/mdx/components/code-block.d.cts +0 -9
  94. package/dist/kernel/components/mdx/components/figure-caption.cjs +0 -63
  95. package/dist/kernel/components/mdx/components/figure-caption.d.cts +0 -6
  96. package/dist/kernel/components/mdx/components/figure.cjs +0 -78
  97. package/dist/kernel/components/mdx/components/figure.d.cts +0 -10
  98. package/dist/kernel/components/mdx/components/footnotes.cjs +0 -66
  99. package/dist/kernel/components/mdx/components/footnotes.d.cts +0 -6
  100. package/dist/kernel/components/mdx/components/heading-copy-link.cjs +0 -108
  101. package/dist/kernel/components/mdx/components/heading-copy-link.d.cts +0 -23
  102. package/dist/kernel/components/mdx/components/heading.cjs +0 -166
  103. package/dist/kernel/components/mdx/components/heading.d.cts +0 -8
  104. package/dist/kernel/components/mdx/components/hr.cjs +0 -34
  105. package/dist/kernel/components/mdx/components/hr.d.cts +0 -9
  106. package/dist/kernel/components/mdx/components/image-zoom.cjs +0 -49
  107. package/dist/kernel/components/mdx/components/image-zoom.d.cts +0 -10
  108. package/dist/kernel/components/mdx/components/image.cjs +0 -192
  109. package/dist/kernel/components/mdx/components/image.d.cts +0 -21
  110. package/dist/kernel/components/mdx/components/inline-code.cjs +0 -66
  111. package/dist/kernel/components/mdx/components/inline-code.d.cts +0 -6
  112. package/dist/kernel/components/mdx/components/kbd.cjs +0 -34
  113. package/dist/kernel/components/mdx/components/kbd.d.cts +0 -10
  114. package/dist/kernel/components/mdx/components/link.cjs +0 -49
  115. package/dist/kernel/components/mdx/components/link.d.cts +0 -11
  116. package/dist/kernel/components/mdx/components/paragraph.cjs +0 -87
  117. package/dist/kernel/components/mdx/components/paragraph.d.cts +0 -5
  118. package/dist/kernel/components/mdx/components/pre.cjs +0 -66
  119. package/dist/kernel/components/mdx/components/pre.d.cts +0 -6
  120. package/dist/kernel/components/mdx/components/strikethrough.cjs +0 -63
  121. package/dist/kernel/components/mdx/components/strikethrough.d.cts +0 -6
  122. package/dist/kernel/components/mdx/components/table.cjs +0 -59
  123. package/dist/kernel/components/mdx/components/table.d.cts +0 -10
  124. package/dist/kernel/components/mdx/components/task-list.cjs +0 -88
  125. package/dist/kernel/components/mdx/components/task-list.d.cts +0 -8
  126. package/dist/kernel/components/mdx/components/video-player.cjs +0 -173
  127. package/dist/kernel/components/mdx/components/video-player.d.cts +0 -18
  128. package/dist/kernel/components/mdx/components/video.cjs +0 -185
  129. package/dist/kernel/components/mdx/components/video.d.cts +0 -15
  130. package/dist/kernel/components/mdx/error-boundary.cjs +0 -62
  131. package/dist/kernel/components/mdx/error-boundary.d.cts +0 -8
  132. package/dist/kernel/components/mdx/error-fallback.cjs +0 -58
  133. package/dist/kernel/components/mdx/error-fallback.d.cts +0 -9
  134. package/dist/kernel/components/mdx/mdx.cjs +0 -141
  135. package/dist/kernel/components/mdx/mdx.d.cts +0 -22
  136. package/dist/kernel/components/mdx/rehype-heading-ids.cjs +0 -113
  137. package/dist/kernel/components/mdx/rehype-heading-ids.d.cts +0 -10
  138. package/dist/kernel/components/mdx/types.cjs +0 -18
  139. package/dist/kernel/components/mdx/types.d.cts +0 -18
  140. package/dist/kernel/components/ui/accordion.cjs +0 -104
  141. package/dist/kernel/components/ui/accordion.d.cts +0 -16
  142. package/dist/kernel/components/ui/badge.cjs +0 -75
  143. package/dist/kernel/components/ui/badge.d.cts +0 -12
  144. package/dist/kernel/components/ui/badge.d.ts +0 -12
  145. package/dist/kernel/components/ui/badge.js +0 -47
  146. package/dist/kernel/components/ui/breadcrumb-trail.cjs +0 -238
  147. package/dist/kernel/components/ui/breadcrumb-trail.d.cts +0 -13
  148. package/dist/kernel/components/ui/breadcrumb.cjs +0 -399
  149. package/dist/kernel/components/ui/breadcrumb.d.cts +0 -52
  150. package/dist/kernel/components/ui/button-group.cjs +0 -144
  151. package/dist/kernel/components/ui/button-group.d.cts +0 -19
  152. package/dist/kernel/components/ui/button.cjs +0 -147
  153. package/dist/kernel/components/ui/button.d.cts +0 -23
  154. package/dist/kernel/components/ui/card.cjs +0 -133
  155. package/dist/kernel/components/ui/card.d.cts +0 -17
  156. package/dist/kernel/components/ui/dialog.cjs +0 -149
  157. package/dist/kernel/components/ui/dialog.d.cts +0 -22
  158. package/dist/kernel/components/ui/drawer.cjs +0 -163
  159. package/dist/kernel/components/ui/drawer.d.cts +0 -24
  160. package/dist/kernel/components/ui/input.cjs +0 -96
  161. package/dist/kernel/components/ui/input.d.cts +0 -18
  162. package/dist/kernel/components/ui/kbd.cjs +0 -105
  163. package/dist/kernel/components/ui/kbd.d.cts +0 -13
  164. package/dist/kernel/components/ui/link.cjs +0 -253
  165. package/dist/kernel/components/ui/link.d.cts +0 -31
  166. package/dist/kernel/components/ui/menu.cjs +0 -301
  167. package/dist/kernel/components/ui/menu.d.cts +0 -70
  168. package/dist/kernel/components/ui/meta-key.cjs +0 -34
  169. package/dist/kernel/components/ui/meta-key.d.cts +0 -12
  170. package/dist/kernel/components/ui/navigation-menu.cjs +0 -253
  171. package/dist/kernel/components/ui/navigation-menu.d.cts +0 -47
  172. package/dist/kernel/components/ui/popover.cjs +0 -168
  173. package/dist/kernel/components/ui/popover.d.cts +0 -24
  174. package/dist/kernel/components/ui/progress.cjs +0 -112
  175. package/dist/kernel/components/ui/progress.d.cts +0 -16
  176. package/dist/kernel/components/ui/scroll-area.cjs +0 -413
  177. package/dist/kernel/components/ui/scroll-area.d.cts +0 -58
  178. package/dist/kernel/components/ui/select.cjs +0 -244
  179. package/dist/kernel/components/ui/select.d.cts +0 -40
  180. package/dist/kernel/components/ui/separator.cjs +0 -73
  181. package/dist/kernel/components/ui/separator.d.cts +0 -8
  182. package/dist/kernel/components/ui/table.cjs +0 -131
  183. package/dist/kernel/components/ui/table.d.cts +0 -11
  184. package/dist/kernel/components/ui/tabs.cjs +0 -450
  185. package/dist/kernel/components/ui/tabs.d.cts +0 -82
  186. package/dist/kernel/components/ui/text.cjs +0 -184
  187. package/dist/kernel/components/ui/text.d.cts +0 -17
  188. package/dist/kernel/components/ui/theme-toggle.cjs +0 -108
  189. package/dist/kernel/components/ui/theme-toggle.d.cts +0 -10
  190. package/dist/kernel/components/ui/toast.cjs +0 -154
  191. package/dist/kernel/components/ui/toast.d.cts +0 -26
  192. package/dist/kernel/components/ui/tooltip.cjs +0 -127
  193. package/dist/kernel/components/ui/tooltip.d.cts +0 -20
  194. package/dist/kernel/defaults.registry.cjs +0 -541
  195. package/dist/kernel/defaults.registry.d.cts +0 -469
  196. package/dist/kernel/routes/agent/markdown.cjs +0 -202
  197. package/dist/kernel/routes/agent/markdown.d.cts +0 -58
  198. package/dist/kernel/routes/layouts/group.cjs +0 -181
  199. package/dist/kernel/routes/layouts/group.d.cts +0 -20
  200. package/dist/kernel/routes/metadata/feed.cjs +0 -293
  201. package/dist/kernel/routes/metadata/feed.d.cts +0 -20
  202. package/dist/kernel/routes/metadata/llms.cjs +0 -239
  203. package/dist/kernel/routes/metadata/llms.d.cts +0 -26
  204. package/dist/kernel/routes/metadata/og-image.cjs +0 -630
  205. package/dist/kernel/routes/metadata/og-image.d.cts +0 -62
  206. package/dist/kernel/routes/metadata/robots.cjs +0 -148
  207. package/dist/kernel/routes/metadata/robots.d.cts +0 -6
  208. package/dist/kernel/routes/metadata/sitemap.cjs +0 -192
  209. package/dist/kernel/routes/metadata/sitemap.d.cts +0 -8
  210. package/dist/kernel/routes/pages/group.cjs +0 -263
  211. package/dist/kernel/routes/pages/group.d.cts +0 -17
  212. package/dist/kernel/routes/pages/leaf.cjs +0 -421
  213. package/dist/kernel/routes/pages/leaf.d.cts +0 -36
  214. package/dist/kernel/routes/pages/root.cjs +0 -229
  215. package/dist/kernel/routes/pages/root.d.cts +0 -16
  216. package/dist/keyboard-shortcuts.cjs +0 -345
  217. package/dist/keyboard-shortcuts.d.cts +0 -34
  218. package/dist/resolvers/manifest-resolver.cjs +0 -111
  219. package/dist/resolvers/manifest-resolver.d.cts +0 -13
  220. package/dist/search.cjs +0 -411
  221. package/dist/search.d.cts +0 -20
  222. package/dist/types.cjs +0 -30
  223. package/dist/types.d.cts +0 -269
  224. package/dist/utils/cn.cjs +0 -49
  225. package/dist/utils/cn.d.cts +0 -15
  226. package/dist/utils/heading-ids.cjs +0 -119
  227. package/dist/utils/heading-ids.d.cts +0 -15
  228. package/dist/utils/pretty-date.cjs +0 -55
  229. package/dist/utils/pretty-date.d.cts +0 -6
@@ -1,630 +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/metadata/og-image.tsx
21
- var og_image_exports = {};
22
- __export(og_image_exports, {
23
- createOgImageRoute: () => createOgImageRoute,
24
- createOgImageStaticParams: () => createOgImageStaticParams
25
- });
26
- module.exports = __toCommonJS(og_image_exports);
27
- var import_promises = require("fs/promises");
28
- var import_node_module = require("module");
29
- var import_og = require("next/og");
30
- var import_jsx_runtime = require("react/jsx-runtime");
31
- var ERROR_HEADERS = {
32
- "cache-control": "public, max-age=60, must-revalidate",
33
- "cdn-cache-control": "public, max-age=300",
34
- "vercel-cdn-cache-control": "public, max-age=300",
35
- "x-content-type-options": "nosniff"
36
- };
37
- var SUCCESS_HEADERS = {
38
- "cache-control": "public, max-age=31536000, immutable",
39
- "cdn-cache-control": "public, max-age=31536000, immutable",
40
- "vercel-cdn-cache-control": "public, max-age=31536000, immutable",
41
- "x-content-type-options": "nosniff"
42
- };
43
- var DEVELOPMENT_SUCCESS_HEADERS = {
44
- "cache-control": "no-store",
45
- "cdn-cache-control": "no-store",
46
- "vercel-cdn-cache-control": "no-store",
47
- "x-content-type-options": "nosniff"
48
- };
49
- var KEY_PATTERN = /^[a-f0-9]{16}$/;
50
- var DESCRIPTION_MAX_LENGTH = 260;
51
- var LABEL_MAX_LENGTH = 72;
52
- var SITE_NAME_MAX_LENGTH = 42;
53
- var TITLE_MAX_LENGTH = 220;
54
- var GRID_INSET = 86;
55
- var GRID_BOTTOM = 544;
56
- var CONTENT_X = 122;
57
- var CONTENT_WIDTH = 956;
58
- var TITLE_MAX_FONT_SIZE = 60;
59
- var TITLE_MIN_FONT_SIZE = 40;
60
- var LOGO_MAX_WIDTH = 300;
61
- var LOGO_MAX_HEIGHT = 46;
62
- var MAX_RESPONSE_CACHE_ENTRIES = 128;
63
- var BADGE_RADIUS = 999;
64
- var CONTENT_TYPE_HEADER = { "content-type": "image/png" };
65
- var PLATFORM_FONT_FAMILY = "PublishOS Geist";
66
- var PLATFORM_FONT_WEIGHTS = [
67
- 400,
68
- 500,
69
- 600,
70
- 700,
71
- 800
72
- ];
73
- var fontArrayBufferCache = /* @__PURE__ */ new Map();
74
- var imageResponseFontCache = /* @__PURE__ */ new Map();
75
- var imageResponseCache = /* @__PURE__ */ new Map();
76
- var require2 = (0, import_node_module.createRequire)(`${process.cwd()}/package.json`);
77
- var platformFontPath = require2.resolve(
78
- "next/dist/compiled/@vercel/og/Geist-Regular.ttf"
79
- );
80
- var platformFontData;
81
- function isDevelopment() {
82
- return process.env.NODE_ENV === "development";
83
- }
84
- function successHeaders() {
85
- return isDevelopment() ? DEVELOPMENT_SUCCESS_HEADERS : SUCCESS_HEADERS;
86
- }
87
- function clampText(value, maxLength) {
88
- if (!value) return void 0;
89
- if (value.length <= maxLength) return value;
90
- return `${value.slice(0, maxLength - 3).trimEnd()}...`;
91
- }
92
- async function routeKey(context) {
93
- const params = await context.params;
94
- return params.key.replace(/\.png$/, "");
95
- }
96
- function ellipsize(value, maxLength) {
97
- if (value.length <= maxLength) return value;
98
- return `${value.slice(0, maxLength - 3).trimEnd()}...`;
99
- }
100
- function wrapText(options) {
101
- const source = clampText(options.text, options.maxLength);
102
- if (!source) return [];
103
- const maxCharsPerLine = Math.max(
104
- 12,
105
- Math.floor(options.width / (options.fontSize * 0.54))
106
- );
107
- const words = source.split(/\s+/).filter(Boolean);
108
- const lines = [];
109
- let line = "";
110
- for (const word of words) {
111
- const nextLine = line ? `${line} ${word}` : word;
112
- if (nextLine.length <= maxCharsPerLine) {
113
- line = nextLine;
114
- continue;
115
- }
116
- if (line) lines.push(line);
117
- line = word.length > maxCharsPerLine ? ellipsize(word, maxCharsPerLine) : word;
118
- if (lines.length === options.maxLines) break;
119
- }
120
- if (line && lines.length < options.maxLines) lines.push(line);
121
- const consumed = lines.join(" ").replace(/\.\.\.$/, "");
122
- const didOverflow = words.join(" ").length > consumed.length || (lines.at(-1)?.endsWith("...") ?? false);
123
- if (didOverflow && lines.length > 0) {
124
- const lastIndex = lines.length - 1;
125
- lines[lastIndex] = ellipsize(lines[lastIndex] ?? "", maxCharsPerLine);
126
- }
127
- return lines;
128
- }
129
- function singleLineText(options) {
130
- const source = clampText(options.text, options.maxLength);
131
- if (!source) return void 0;
132
- const charWidth = options.fontSize * (options.mono ? 0.62 : 0.54);
133
- const maxChars = Math.max(4, Math.floor(options.width / charWidth));
134
- return ellipsize(source.replace(/\s+/g, " "), maxChars);
135
- }
136
- function titleFontSize(title) {
137
- const length = title?.length ?? 0;
138
- if (length > 130) return TITLE_MIN_FONT_SIZE;
139
- if (length > 100) return 44;
140
- if (length > 80) return 48;
141
- if (length > 60) return 52;
142
- if (length > 40) return 56;
143
- return TITLE_MAX_FONT_SIZE;
144
- }
145
- function siteUrl(value) {
146
- if (!value) return void 0;
147
- const candidate = value.includes("://") ? value : `https://${value}`;
148
- try {
149
- return new URL(candidate);
150
- } catch {
151
- return void 0;
152
- }
153
- }
154
- function displayUrlParts(entry) {
155
- const url = siteUrl(entry.siteUrl);
156
- const host = url?.hostname ?? entry.siteUrl?.replace(/\/.*$/, "") ?? "";
157
- const basePath = url?.pathname.replace(/\/+$/, "") ?? "";
158
- const routePath = entry.routePath === "/" ? "" : `/${entry.routePath.replace(/^\/+/, "")}`;
159
- const path = `${basePath === "/" ? "" : basePath}${routePath}`;
160
- if (host) return { host, path };
161
- return { host: "", path: path || routePath };
162
- }
163
- function dataUrlToArrayBuffer(value) {
164
- const cached = fontArrayBufferCache.get(value);
165
- if (cached) return cached;
166
- const binary = atob(value);
167
- const bytes = new Uint8Array(binary.length);
168
- for (let index = 0; index < binary.length; index += 1) {
169
- bytes[index] = binary.charCodeAt(index);
170
- }
171
- fontArrayBufferCache.set(value, bytes.buffer);
172
- return bytes.buffer;
173
- }
174
- function platformFonts() {
175
- platformFontData ??= (0, import_promises.readFile)(platformFontPath).then(
176
- (data) => data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)
177
- );
178
- return platformFontData.then(
179
- (data) => PLATFORM_FONT_WEIGHTS.map((weight) => ({
180
- data: data.slice(0),
181
- name: PLATFORM_FONT_FAMILY,
182
- style: "normal",
183
- weight
184
- }))
185
- );
186
- }
187
- async function imageResponseFonts(entry) {
188
- const cached = imageResponseFontCache.get(entry.key);
189
- if (cached) return cached;
190
- const manifestFonts = ["main", "mono"].flatMap((role) => {
191
- const font = entry.fonts?.[role];
192
- return font?.files?.map((file) => ({
193
- data: dataUrlToArrayBuffer(file.data),
194
- name: font.family,
195
- style: file.style,
196
- weight: file.weight
197
- })) ?? [];
198
- });
199
- const fonts = manifestFonts.length > 0 ? [...manifestFonts, ...await platformFonts()] : await platformFonts();
200
- imageResponseFontCache.set(entry.key, fonts);
201
- return fonts;
202
- }
203
- function fontFamily(font, fallback) {
204
- const fallbackStack = fallback === "mono" ? `"${PLATFORM_FONT_FAMILY}", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace` : `"${PLATFORM_FONT_FAMILY}", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`;
205
- return font?.family ? `${JSON.stringify(font.family)}, ${fallbackStack}` : fallbackStack;
206
- }
207
- function fittedLogoDimensions(logo) {
208
- if (!logo?.width || !logo.height) return void 0;
209
- const scale = Math.min(
210
- LOGO_MAX_WIDTH / logo.width,
211
- LOGO_MAX_HEIGHT / logo.height,
212
- 1
213
- );
214
- return {
215
- height: Math.max(1, Math.round(logo.height * scale)),
216
- width: Math.max(1, Math.round(logo.width * scale))
217
- };
218
- }
219
- function cacheImageResponse(key, render) {
220
- if (isDevelopment()) return render();
221
- const cached = imageResponseCache.get(key);
222
- if (cached) return cached;
223
- const promise = render().catch((error) => {
224
- imageResponseCache.delete(key);
225
- throw error;
226
- });
227
- imageResponseCache.set(key, promise);
228
- if (imageResponseCache.size > MAX_RESPONSE_CACHE_ENTRIES) {
229
- const oldest = imageResponseCache.keys().next().value;
230
- if (oldest) imageResponseCache.delete(oldest);
231
- }
232
- return promise;
233
- }
234
- function responseFromCachedImage(cached) {
235
- return new Response(cached.body.slice(0), {
236
- headers: cached.headers,
237
- status: cached.status
238
- });
239
- }
240
- async function cachedImageResponse(response) {
241
- const headersToApply = successHeaders();
242
- const headers = new Headers(response.headers);
243
- headers.set("cache-control", headersToApply["cache-control"]);
244
- headers.set("cdn-cache-control", headersToApply["cdn-cache-control"]);
245
- headers.set(
246
- "vercel-cdn-cache-control",
247
- headersToApply["vercel-cdn-cache-control"]
248
- );
249
- headers.set(
250
- "x-content-type-options",
251
- headersToApply["x-content-type-options"]
252
- );
253
- if (!headers.has("content-type")) {
254
- headers.set("content-type", CONTENT_TYPE_HEADER["content-type"]);
255
- }
256
- return {
257
- body: await response.arrayBuffer(),
258
- headers,
259
- status: response.status
260
- };
261
- }
262
- function createOgImageRoute({ manifest }) {
263
- return async function GET(_request, context) {
264
- const key = await routeKey(context);
265
- if (!KEY_PATTERN.test(key)) {
266
- return new Response("Bad request", {
267
- headers: ERROR_HEADERS,
268
- status: 400
269
- });
270
- }
271
- const entry = manifest.generated[key];
272
- if (!entry || entry.source !== "generated") {
273
- return new Response("Not found", {
274
- headers: ERROR_HEADERS,
275
- status: 404
276
- });
277
- }
278
- const titleSize = titleFontSize(entry.title);
279
- const titleLines = wrapText({
280
- fontSize: titleSize,
281
- maxLength: TITLE_MAX_LENGTH,
282
- maxLines: 2,
283
- text: entry.title,
284
- width: 900
285
- });
286
- const descriptionLines = wrapText({
287
- fontSize: 30,
288
- maxLength: DESCRIPTION_MAX_LENGTH,
289
- maxLines: 2,
290
- text: entry.description,
291
- width: 870
292
- });
293
- const label = singleLineText({
294
- fontSize: 22,
295
- maxLength: LABEL_MAX_LENGTH,
296
- mono: true,
297
- text: entry.label,
298
- width: 520
299
- });
300
- const displayUrl = displayUrlParts(entry);
301
- const siteName = clampText(
302
- entry.siteName ?? entry.alt,
303
- SITE_NAME_MAX_LENGTH
304
- );
305
- const background = entry.background ?? "#ffffff";
306
- const textPrimary = entry.textPrimary ?? "#111111";
307
- const textSecondary = entry.textSecondary ?? "#525252";
308
- const accent = entry.accent ?? "#2563eb";
309
- const stroke = entry.stroke ?? "#e5e7eb";
310
- const logoSrc = entry.logo?.dataUri;
311
- const logoDimensions = fittedLogoDimensions(entry.logo);
312
- return responseFromCachedImage(
313
- await cacheImageResponse(
314
- entry.key,
315
- async () => cachedImageResponse(
316
- new import_og.ImageResponse(
317
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
318
- "div",
319
- {
320
- style: {
321
- background,
322
- color: textPrimary,
323
- display: "flex",
324
- fontFamily: fontFamily(entry.fonts?.main, "sans"),
325
- height: "100%",
326
- position: "relative",
327
- width: "100%"
328
- },
329
- children: [
330
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
331
- "div",
332
- {
333
- style: {
334
- background: stroke,
335
- display: "flex",
336
- height: "100%",
337
- left: GRID_INSET,
338
- position: "absolute",
339
- top: 0,
340
- width: 2
341
- }
342
- }
343
- ),
344
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
345
- "div",
346
- {
347
- style: {
348
- background: stroke,
349
- display: "flex",
350
- height: "100%",
351
- position: "absolute",
352
- right: GRID_INSET,
353
- top: 0,
354
- width: 2
355
- }
356
- }
357
- ),
358
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
359
- "div",
360
- {
361
- style: {
362
- background: stroke,
363
- display: "flex",
364
- height: 2,
365
- left: 0,
366
- position: "absolute",
367
- top: GRID_INSET,
368
- width: "100%"
369
- }
370
- }
371
- ),
372
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
373
- "div",
374
- {
375
- style: {
376
- background: stroke,
377
- bottom: GRID_INSET,
378
- display: "flex",
379
- height: 2,
380
- left: 0,
381
- position: "absolute",
382
- width: "100%"
383
- }
384
- }
385
- ),
386
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
387
- "div",
388
- {
389
- style: {
390
- alignItems: "center",
391
- color: accent,
392
- display: "flex",
393
- fontFamily: fontFamily(entry.fonts?.main, "sans"),
394
- fontSize: 22,
395
- fontWeight: 700,
396
- height: GRID_INSET,
397
- justifyContent: "flex-start",
398
- left: CONTENT_X,
399
- lineHeight: 1,
400
- overflow: "hidden",
401
- position: "absolute",
402
- top: 0,
403
- width: 430
404
- },
405
- children: logoSrc ? (
406
- // biome-ignore lint/performance/noImgElement: ImageResponse renders static manifest-provided logo data; next/image is not available in Satori output.
407
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
408
- "img",
409
- {
410
- alt: "",
411
- src: logoSrc,
412
- style: {
413
- height: logoDimensions?.height ?? LOGO_MAX_HEIGHT,
414
- maxHeight: LOGO_MAX_HEIGHT,
415
- maxWidth: LOGO_MAX_WIDTH,
416
- objectFit: "contain",
417
- objectPosition: "left center",
418
- width: logoDimensions?.width ?? "auto"
419
- }
420
- }
421
- )
422
- ) : siteName
423
- }
424
- ),
425
- label ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
426
- "div",
427
- {
428
- style: {
429
- alignItems: "center",
430
- display: "flex",
431
- fontFamily: fontFamily(entry.fonts?.mono, "mono"),
432
- height: GRID_INSET,
433
- justifyContent: "flex-end",
434
- overflow: "hidden",
435
- position: "absolute",
436
- right: CONTENT_X,
437
- top: 0,
438
- width: 520
439
- },
440
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
441
- "div",
442
- {
443
- style: {
444
- alignItems: "center",
445
- borderRadius: BADGE_RADIUS,
446
- color: accent,
447
- display: "flex",
448
- fontSize: 20,
449
- fontWeight: 600,
450
- lineHeight: 1,
451
- maxWidth: 520,
452
- overflow: "hidden",
453
- paddingBottom: 6,
454
- paddingLeft: 12,
455
- paddingRight: 12,
456
- paddingTop: 6,
457
- position: "relative"
458
- },
459
- children: [
460
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
461
- "div",
462
- {
463
- style: {
464
- background: accent,
465
- borderRadius: BADGE_RADIUS,
466
- bottom: 0,
467
- display: "flex",
468
- left: 0,
469
- opacity: 0.14,
470
- position: "absolute",
471
- right: 0,
472
- top: 0
473
- }
474
- }
475
- ),
476
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
477
- "div",
478
- {
479
- style: {
480
- borderColor: accent,
481
- borderRadius: BADGE_RADIUS,
482
- borderStyle: "solid",
483
- borderWidth: 1,
484
- bottom: 0,
485
- display: "flex",
486
- left: 0,
487
- opacity: 0.32,
488
- position: "absolute",
489
- right: 0,
490
- top: 0
491
- }
492
- }
493
- ),
494
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "flex", position: "relative" }, children: label })
495
- ]
496
- }
497
- )
498
- }
499
- ) : null,
500
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
501
- "div",
502
- {
503
- style: {
504
- display: "flex",
505
- flexDirection: "column",
506
- gap: 24,
507
- left: CONTENT_X,
508
- position: "absolute",
509
- top: 164,
510
- width: CONTENT_WIDTH
511
- },
512
- children: [
513
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
514
- "div",
515
- {
516
- style: {
517
- display: "flex",
518
- flexDirection: "column",
519
- fontSize: titleSize,
520
- fontWeight: 800,
521
- letterSpacing: 0,
522
- lineHeight: 1.08,
523
- width: 900
524
- },
525
- children: titleLines.map((line) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "flex" }, children: line }, line))
526
- }
527
- ),
528
- descriptionLines.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
529
- "div",
530
- {
531
- style: {
532
- color: textSecondary,
533
- display: "flex",
534
- flexDirection: "column",
535
- fontSize: 30,
536
- lineHeight: 1.25,
537
- width: 870
538
- },
539
- children: descriptionLines.map((line) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "flex" }, children: line }, line))
540
- }
541
- ) : null
542
- ]
543
- }
544
- ),
545
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
546
- "div",
547
- {
548
- style: {
549
- alignItems: "center",
550
- display: "flex",
551
- fontFamily: fontFamily(entry.fonts?.mono, "mono"),
552
- fontSize: 22,
553
- height: GRID_INSET,
554
- justifyContent: "flex-start",
555
- left: CONTENT_X,
556
- lineHeight: 1.2,
557
- overflow: "hidden",
558
- position: "absolute",
559
- top: GRID_BOTTOM,
560
- width: CONTENT_WIDTH
561
- },
562
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
563
- "div",
564
- {
565
- style: {
566
- display: "flex",
567
- flexDirection: "row",
568
- overflow: "hidden",
569
- textOverflow: "ellipsis",
570
- whiteSpace: "nowrap",
571
- width: CONTENT_WIDTH
572
- },
573
- children: [
574
- displayUrl.host ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
575
- "div",
576
- {
577
- style: {
578
- color: textSecondary,
579
- display: "flex",
580
- flexShrink: 0,
581
- whiteSpace: "nowrap"
582
- },
583
- children: displayUrl.host
584
- }
585
- ) : null,
586
- displayUrl.path ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
587
- "div",
588
- {
589
- style: {
590
- color: textPrimary,
591
- display: "flex",
592
- minWidth: 0,
593
- overflow: "hidden",
594
- textOverflow: "ellipsis",
595
- whiteSpace: "nowrap"
596
- },
597
- children: displayUrl.path
598
- }
599
- ) : null
600
- ]
601
- }
602
- )
603
- }
604
- )
605
- ]
606
- }
607
- ),
608
- {
609
- fonts: await imageResponseFonts(entry),
610
- headers: {
611
- ...CONTENT_TYPE_HEADER,
612
- ...successHeaders()
613
- },
614
- height: manifest.height,
615
- width: manifest.width
616
- }
617
- )
618
- )
619
- )
620
- );
621
- };
622
- }
623
- function createOgImageStaticParams({ manifest }) {
624
- return Object.keys(manifest.generated).map((key) => ({ key: `${key}.png` }));
625
- }
626
- // Annotate the CommonJS export names for ESM import in node:
627
- 0 && (module.exports = {
628
- createOgImageRoute,
629
- createOgImageStaticParams
630
- });
@@ -1,62 +0,0 @@
1
- type OgImageEntryLike = {
2
- key: string;
3
- routePath: string;
4
- title: string;
5
- description?: string;
6
- source: "asset" | "generated" | "remote";
7
- url: string;
8
- width: number;
9
- height: number;
10
- alt: string;
11
- group?: string;
12
- logo?: {
13
- dataUri?: string;
14
- height?: number;
15
- kind: "logo" | "mark" | "wordmark";
16
- url: string;
17
- width?: number;
18
- };
19
- siteName?: string;
20
- siteUrl?: string;
21
- label?: string;
22
- background?: string;
23
- textPrimary?: string;
24
- textSecondary?: string;
25
- accent?: string;
26
- stroke?: string;
27
- theme?: "light" | "dark";
28
- fonts?: {
29
- main: OgFontRoleLike;
30
- mono: OgFontRoleLike;
31
- };
32
- };
33
- type OgManifestLike = {
34
- width: number;
35
- height: number;
36
- generated: Record<string, OgImageEntryLike>;
37
- };
38
- type OgImageRouteConfig = {
39
- manifest: OgManifestLike;
40
- };
41
- type RouteContext = {
42
- params: Promise<{
43
- key: string;
44
- }> | {
45
- key: string;
46
- };
47
- };
48
- type OgFontRoleLike = {
49
- family: string;
50
- files?: ReadonlyArray<{
51
- data: string;
52
- style: "normal" | "italic";
53
- weight: number;
54
- }>;
55
- sourceType: "google" | "local" | "url";
56
- };
57
- declare function createOgImageRoute({ manifest }: OgImageRouteConfig): (_request: Request, context: RouteContext) => Promise<Response>;
58
- declare function createOgImageStaticParams({ manifest }: OgImageRouteConfig): {
59
- key: string;
60
- }[];
61
-
62
- export { type OgImageEntryLike, type OgImageRouteConfig, type OgManifestLike, createOgImageRoute, createOgImageStaticParams };