@publish.os/nextjs 0.0.1-alpha.1

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 (94) hide show
  1. package/README.md +7 -0
  2. package/dist/cache/tags.cjs +76 -0
  3. package/dist/cache/tags.d.cts +12 -0
  4. package/dist/cache/tags.d.ts +12 -0
  5. package/dist/cache/tags.js +51 -0
  6. package/dist/components/color-palette.cjs +408 -0
  7. package/dist/components/color-palette.d.cts +5 -0
  8. package/dist/components/color-palette.d.ts +5 -0
  9. package/dist/components/color-palette.js +388 -0
  10. package/dist/components/nav-breadcrumb.cjs +141 -0
  11. package/dist/components/nav-breadcrumb.d.cts +9 -0
  12. package/dist/components/nav-breadcrumb.d.ts +9 -0
  13. package/dist/components/nav-breadcrumb.js +107 -0
  14. package/dist/components/page-list.cjs +68 -0
  15. package/dist/components/page-list.d.cts +11 -0
  16. package/dist/components/page-list.d.ts +11 -0
  17. package/dist/components/page-list.js +33 -0
  18. package/dist/components/providers.cjs +44 -0
  19. package/dist/components/providers.d.cts +8 -0
  20. package/dist/components/providers.d.ts +8 -0
  21. package/dist/components/providers.js +20 -0
  22. package/dist/components/site-header.cjs +302 -0
  23. package/dist/components/site-header.d.cts +12 -0
  24. package/dist/components/site-header.d.ts +12 -0
  25. package/dist/components/site-header.js +268 -0
  26. package/dist/components/theme-toggle.cjs +147 -0
  27. package/dist/components/theme-toggle.d.cts +5 -0
  28. package/dist/components/theme-toggle.d.ts +5 -0
  29. package/dist/components/theme-toggle.js +123 -0
  30. package/dist/config/createNextConfig.cjs +52 -0
  31. package/dist/config/createNextConfig.d.cts +8 -0
  32. package/dist/config/createNextConfig.d.ts +8 -0
  33. package/dist/config/createNextConfig.js +27 -0
  34. package/dist/index.cjs +347 -0
  35. package/dist/index.d.cts +14 -0
  36. package/dist/index.d.ts +14 -0
  37. package/dist/index.js +299 -0
  38. package/dist/layouts/group.cjs +157 -0
  39. package/dist/layouts/group.d.cts +15 -0
  40. package/dist/layouts/group.d.ts +15 -0
  41. package/dist/layouts/group.js +132 -0
  42. package/dist/mdx/error-boundary.cjs +94 -0
  43. package/dist/mdx/error-boundary.d.cts +13 -0
  44. package/dist/mdx/error-boundary.d.ts +13 -0
  45. package/dist/mdx/error-boundary.js +70 -0
  46. package/dist/mdx/error-fallback.cjs +58 -0
  47. package/dist/mdx/error-fallback.d.cts +9 -0
  48. package/dist/mdx/error-fallback.d.ts +9 -0
  49. package/dist/mdx/error-fallback.js +33 -0
  50. package/dist/mdx/mdx.cjs +182 -0
  51. package/dist/mdx/mdx.d.cts +10 -0
  52. package/dist/mdx/mdx.d.ts +10 -0
  53. package/dist/mdx/mdx.js +147 -0
  54. package/dist/pages/group.cjs +162 -0
  55. package/dist/pages/group.d.cts +15 -0
  56. package/dist/pages/group.d.ts +15 -0
  57. package/dist/pages/group.js +136 -0
  58. package/dist/pages/leaf.cjs +203 -0
  59. package/dist/pages/leaf.d.cts +23 -0
  60. package/dist/pages/leaf.d.ts +23 -0
  61. package/dist/pages/leaf.js +176 -0
  62. package/dist/pages/root.cjs +127 -0
  63. package/dist/pages/root.d.cts +14 -0
  64. package/dist/pages/root.d.ts +14 -0
  65. package/dist/pages/root.js +101 -0
  66. package/dist/resolvers/manifest-resolver.cjs +107 -0
  67. package/dist/resolvers/manifest-resolver.d.cts +13 -0
  68. package/dist/resolvers/manifest-resolver.d.ts +13 -0
  69. package/dist/resolvers/manifest-resolver.js +79 -0
  70. package/dist/routes/llms.cjs +101 -0
  71. package/dist/routes/llms.d.cts +7 -0
  72. package/dist/routes/llms.d.ts +7 -0
  73. package/dist/routes/llms.js +76 -0
  74. package/dist/routes/robots.cjs +94 -0
  75. package/dist/routes/robots.d.cts +5 -0
  76. package/dist/routes/robots.d.ts +5 -0
  77. package/dist/routes/robots.js +69 -0
  78. package/dist/routes/sitemap.cjs +108 -0
  79. package/dist/routes/sitemap.d.cts +5 -0
  80. package/dist/routes/sitemap.d.ts +5 -0
  81. package/dist/routes/sitemap.js +83 -0
  82. package/dist/types.cjs +18 -0
  83. package/dist/types.d.cts +144 -0
  84. package/dist/types.d.ts +144 -0
  85. package/dist/types.js +0 -0
  86. package/dist/utils/cn.cjs +49 -0
  87. package/dist/utils/cn.d.cts +15 -0
  88. package/dist/utils/cn.d.ts +15 -0
  89. package/dist/utils/cn.js +24 -0
  90. package/dist/utils/pretty-date.cjs +55 -0
  91. package/dist/utils/pretty-date.d.cts +6 -0
  92. package/dist/utils/pretty-date.d.ts +6 -0
  93. package/dist/utils/pretty-date.js +30 -0
  94. package/package.json +100 -0
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/mdx/mdx.tsx
31
+ var mdx_exports = {};
32
+ __export(mdx_exports, {
33
+ MDX: () => MDX
34
+ });
35
+ module.exports = __toCommonJS(mdx_exports);
36
+ var import_rsc = require("next-mdx-remote/rsc");
37
+ var import_remark_gfm = __toESM(require("remark-gfm"), 1);
38
+
39
+ // src/utils/cn.ts
40
+ var import_clsx = require("clsx");
41
+ var import_tailwind_merge = require("tailwind-merge");
42
+ var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
43
+ extend: {
44
+ classGroups: {
45
+ z: [
46
+ "z-content",
47
+ "z-nav",
48
+ "z-overlay",
49
+ "z-modal",
50
+ "z-search",
51
+ "z-toast",
52
+ "z-progress"
53
+ ]
54
+ }
55
+ }
56
+ });
57
+ function cn(...inputs) {
58
+ return twMerge((0, import_clsx.clsx)(inputs));
59
+ }
60
+
61
+ // src/mdx/utils/heading-ids.ts
62
+ var import_react = require("react");
63
+ var SELF_CLOSING_TAG_RE = new RegExp("<[^>]+/>", "g");
64
+ var PAIRED_TAG_RE = /<\/?\w[^>]*>/g;
65
+ var MDX_BOLD_RE = /\*\*(.*?)\*\*/g;
66
+ var MDX_ITALIC_RE = /\*(.*?)\*/g;
67
+ var MDX_UNDERLINE_BOLD_RE = /__(.*?)__/g;
68
+ var MDX_UNDERLINE_ITALIC_RE = /_(.*?)_/g;
69
+ var MDX_STRIKETHROUGH_RE = /~~(.*?)~~/g;
70
+ var MDX_INLINE_CODE_RE = /`(.*?)`/g;
71
+ var MDX_LINK_RE = /\[(.*?)\]\(.*?\)/g;
72
+ var NON_ALPHANUMERIC_RE = /[^a-z0-9]+/g;
73
+ var LEADING_TRAILING_HYPHEN_RE = /^-+|-+$/g;
74
+ var LEADING_DIGIT_RE = /^(\d)/;
75
+ function extractText(node) {
76
+ if (typeof node === "string") return node;
77
+ if (typeof node === "number") return String(node);
78
+ if (node == null || typeof node === "boolean") return "";
79
+ if (Array.isArray(node)) {
80
+ return node.map(extractText).join("");
81
+ }
82
+ if ((0, import_react.isValidElement)(node)) {
83
+ const element = node;
84
+ if (element.props.href && element.props.children) {
85
+ return extractText(element.props.children);
86
+ }
87
+ if (element.props.children !== void 0) {
88
+ return extractText(element.props.children);
89
+ }
90
+ return "";
91
+ }
92
+ return "";
93
+ }
94
+ function sanitizeHeadingText(text) {
95
+ const htmlCleaned = text.replace(SELF_CLOSING_TAG_RE, "").replace(PAIRED_TAG_RE, "");
96
+ const markdownCleaned = htmlCleaned.replace(MDX_BOLD_RE, "$1").replace(MDX_ITALIC_RE, "$1").replace(MDX_UNDERLINE_BOLD_RE, "$1").replace(MDX_UNDERLINE_ITALIC_RE, "$1").replace(MDX_STRIKETHROUGH_RE, "$1").replace(MDX_INLINE_CODE_RE, "$1").replace(MDX_LINK_RE, "$1").trim();
97
+ return markdownCleaned;
98
+ }
99
+ function slugify(text) {
100
+ return text.toLowerCase().replace(NON_ALPHANUMERIC_RE, "-").replace(LEADING_TRAILING_HYPHEN_RE, "").replace(LEADING_DIGIT_RE, "id-$1");
101
+ }
102
+ function headingToHTMLId(input) {
103
+ try {
104
+ const text = typeof input === "string" ? input : extractText(input);
105
+ if (!text) {
106
+ return "empty-heading";
107
+ }
108
+ const clean = sanitizeHeadingText(text);
109
+ const id = slugify(clean);
110
+ return id || "empty-heading";
111
+ } catch {
112
+ return "empty-heading";
113
+ }
114
+ }
115
+
116
+ // src/mdx/components/Heading.tsx
117
+ var import_jsx_runtime = (
118
+ // @ts-expect-error — polymorphic `as` prop with spread is safe at runtime
119
+ require("react/jsx-runtime")
120
+ );
121
+ function Heading({
122
+ as: Tag,
123
+ children,
124
+ className,
125
+ ...props
126
+ }) {
127
+ const id = headingToHTMLId(children) || void 0;
128
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tag, { id, className: cn("scroll-mt-20", className), ...props, children });
129
+ }
130
+
131
+ // src/mdx/components/Paragraph.tsx
132
+ var import_jsx_runtime2 = require("react/jsx-runtime");
133
+ function Paragraph(props) {
134
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { ...props });
135
+ }
136
+
137
+ // src/mdx/mdx.tsx
138
+ var import_error_boundary = require("./error-boundary.js");
139
+ var import_jsx_runtime3 = require("react/jsx-runtime");
140
+ var defaultMdxComponents = {
141
+ h1: (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading, { as: "h1", ...props }),
142
+ h2: (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading, { as: "h2", ...props }),
143
+ h3: (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading, { as: "h3", ...props }),
144
+ h4: (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading, { as: "h4", ...props }),
145
+ h5: (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading, { as: "h5", ...props }),
146
+ h6: (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading, { as: "h6", ...props }),
147
+ p: (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Paragraph, { ...props })
148
+ };
149
+ function getErrorMessage(error) {
150
+ return error instanceof Error ? error.message : "An error occurred while rendering the content";
151
+ }
152
+ async function MDX({ content, pageId, slug }) {
153
+ const mdx = await (0, import_rsc.compileMDX)({
154
+ source: content,
155
+ components: defaultMdxComponents,
156
+ options: {
157
+ parseFrontmatter: false,
158
+ mdxOptions: {
159
+ remarkPlugins: [import_remark_gfm.default]
160
+ }
161
+ }
162
+ }).then(({ content: compiledContent }) => ({
163
+ compiledContent,
164
+ errorMessage: void 0
165
+ })).catch((error) => ({
166
+ compiledContent: null,
167
+ errorMessage: getErrorMessage(error)
168
+ }));
169
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
170
+ import_error_boundary.MDXErrorBoundary,
171
+ {
172
+ errorMessage: mdx.errorMessage,
173
+ pageId,
174
+ slug,
175
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "markdown-prose", children: mdx.compiledContent })
176
+ }
177
+ );
178
+ }
179
+ // Annotate the CommonJS export names for ESM import in node:
180
+ 0 && (module.exports = {
181
+ MDX
182
+ });
@@ -0,0 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type MDXProps = {
4
+ content: string;
5
+ pageId?: string;
6
+ slug?: string;
7
+ };
8
+ declare function MDX({ content, pageId, slug }: MDXProps): Promise<react_jsx_runtime.JSX.Element>;
9
+
10
+ export { MDX, type MDXProps };
@@ -0,0 +1,10 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ type MDXProps = {
4
+ content: string;
5
+ pageId?: string;
6
+ slug?: string;
7
+ };
8
+ declare function MDX({ content, pageId, slug }: MDXProps): Promise<react_jsx_runtime.JSX.Element>;
9
+
10
+ export { MDX, type MDXProps };
@@ -0,0 +1,147 @@
1
+ // src/mdx/mdx.tsx
2
+ import { compileMDX } from "next-mdx-remote/rsc";
3
+ import remarkGfm from "remark-gfm";
4
+
5
+ // src/utils/cn.ts
6
+ import { clsx } from "clsx";
7
+ import { extendTailwindMerge } from "tailwind-merge";
8
+ var twMerge = extendTailwindMerge({
9
+ extend: {
10
+ classGroups: {
11
+ z: [
12
+ "z-content",
13
+ "z-nav",
14
+ "z-overlay",
15
+ "z-modal",
16
+ "z-search",
17
+ "z-toast",
18
+ "z-progress"
19
+ ]
20
+ }
21
+ }
22
+ });
23
+ function cn(...inputs) {
24
+ return twMerge(clsx(inputs));
25
+ }
26
+
27
+ // src/mdx/utils/heading-ids.ts
28
+ import { isValidElement } from "react";
29
+ var SELF_CLOSING_TAG_RE = new RegExp("<[^>]+/>", "g");
30
+ var PAIRED_TAG_RE = /<\/?\w[^>]*>/g;
31
+ var MDX_BOLD_RE = /\*\*(.*?)\*\*/g;
32
+ var MDX_ITALIC_RE = /\*(.*?)\*/g;
33
+ var MDX_UNDERLINE_BOLD_RE = /__(.*?)__/g;
34
+ var MDX_UNDERLINE_ITALIC_RE = /_(.*?)_/g;
35
+ var MDX_STRIKETHROUGH_RE = /~~(.*?)~~/g;
36
+ var MDX_INLINE_CODE_RE = /`(.*?)`/g;
37
+ var MDX_LINK_RE = /\[(.*?)\]\(.*?\)/g;
38
+ var NON_ALPHANUMERIC_RE = /[^a-z0-9]+/g;
39
+ var LEADING_TRAILING_HYPHEN_RE = /^-+|-+$/g;
40
+ var LEADING_DIGIT_RE = /^(\d)/;
41
+ function extractText(node) {
42
+ if (typeof node === "string") return node;
43
+ if (typeof node === "number") return String(node);
44
+ if (node == null || typeof node === "boolean") return "";
45
+ if (Array.isArray(node)) {
46
+ return node.map(extractText).join("");
47
+ }
48
+ if (isValidElement(node)) {
49
+ const element = node;
50
+ if (element.props.href && element.props.children) {
51
+ return extractText(element.props.children);
52
+ }
53
+ if (element.props.children !== void 0) {
54
+ return extractText(element.props.children);
55
+ }
56
+ return "";
57
+ }
58
+ return "";
59
+ }
60
+ function sanitizeHeadingText(text) {
61
+ const htmlCleaned = text.replace(SELF_CLOSING_TAG_RE, "").replace(PAIRED_TAG_RE, "");
62
+ const markdownCleaned = htmlCleaned.replace(MDX_BOLD_RE, "$1").replace(MDX_ITALIC_RE, "$1").replace(MDX_UNDERLINE_BOLD_RE, "$1").replace(MDX_UNDERLINE_ITALIC_RE, "$1").replace(MDX_STRIKETHROUGH_RE, "$1").replace(MDX_INLINE_CODE_RE, "$1").replace(MDX_LINK_RE, "$1").trim();
63
+ return markdownCleaned;
64
+ }
65
+ function slugify(text) {
66
+ return text.toLowerCase().replace(NON_ALPHANUMERIC_RE, "-").replace(LEADING_TRAILING_HYPHEN_RE, "").replace(LEADING_DIGIT_RE, "id-$1");
67
+ }
68
+ function headingToHTMLId(input) {
69
+ try {
70
+ const text = typeof input === "string" ? input : extractText(input);
71
+ if (!text) {
72
+ return "empty-heading";
73
+ }
74
+ const clean = sanitizeHeadingText(text);
75
+ const id = slugify(clean);
76
+ return id || "empty-heading";
77
+ } catch {
78
+ return "empty-heading";
79
+ }
80
+ }
81
+
82
+ // src/mdx/components/Heading.tsx
83
+ import { jsx } from "react/jsx-runtime";
84
+ function Heading({
85
+ as: Tag,
86
+ children,
87
+ className,
88
+ ...props
89
+ }) {
90
+ const id = headingToHTMLId(children) || void 0;
91
+ return (
92
+ // @ts-expect-error — polymorphic `as` prop with spread is safe at runtime
93
+ /* @__PURE__ */ jsx(Tag, { id, className: cn("scroll-mt-20", className), ...props, children })
94
+ );
95
+ }
96
+
97
+ // src/mdx/components/Paragraph.tsx
98
+ import { jsx as jsx2 } from "react/jsx-runtime";
99
+ function Paragraph(props) {
100
+ return /* @__PURE__ */ jsx2("p", { ...props });
101
+ }
102
+
103
+ // src/mdx/mdx.tsx
104
+ import { MDXErrorBoundary } from "./error-boundary.js";
105
+ import { jsx as jsx3 } from "react/jsx-runtime";
106
+ var defaultMdxComponents = {
107
+ h1: (props) => /* @__PURE__ */ jsx3(Heading, { as: "h1", ...props }),
108
+ h2: (props) => /* @__PURE__ */ jsx3(Heading, { as: "h2", ...props }),
109
+ h3: (props) => /* @__PURE__ */ jsx3(Heading, { as: "h3", ...props }),
110
+ h4: (props) => /* @__PURE__ */ jsx3(Heading, { as: "h4", ...props }),
111
+ h5: (props) => /* @__PURE__ */ jsx3(Heading, { as: "h5", ...props }),
112
+ h6: (props) => /* @__PURE__ */ jsx3(Heading, { as: "h6", ...props }),
113
+ p: (props) => /* @__PURE__ */ jsx3(Paragraph, { ...props })
114
+ };
115
+ function getErrorMessage(error) {
116
+ return error instanceof Error ? error.message : "An error occurred while rendering the content";
117
+ }
118
+ async function MDX({ content, pageId, slug }) {
119
+ const mdx = await compileMDX({
120
+ source: content,
121
+ components: defaultMdxComponents,
122
+ options: {
123
+ parseFrontmatter: false,
124
+ mdxOptions: {
125
+ remarkPlugins: [remarkGfm]
126
+ }
127
+ }
128
+ }).then(({ content: compiledContent }) => ({
129
+ compiledContent,
130
+ errorMessage: void 0
131
+ })).catch((error) => ({
132
+ compiledContent: null,
133
+ errorMessage: getErrorMessage(error)
134
+ }));
135
+ return /* @__PURE__ */ jsx3(
136
+ MDXErrorBoundary,
137
+ {
138
+ errorMessage: mdx.errorMessage,
139
+ pageId,
140
+ slug,
141
+ children: /* @__PURE__ */ jsx3("div", { className: "markdown-prose", children: mdx.compiledContent })
142
+ }
143
+ );
144
+ }
145
+ export {
146
+ MDX
147
+ };
@@ -0,0 +1,162 @@
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/pages/group.tsx
21
+ var group_exports = {};
22
+ __export(group_exports, {
23
+ createGroupMetadata: () => createGroupMetadata,
24
+ createGroupPage: () => createGroupPage
25
+ });
26
+ module.exports = __toCommonJS(group_exports);
27
+ var import_cache = require("next/cache");
28
+ var import_navigation = require("next/navigation");
29
+
30
+ // src/cache/tags.ts
31
+ var import_node_crypto = require("crypto");
32
+ var MAX_TAG_LEN = 256;
33
+ var MAX_SEGMENT_LEN = 80;
34
+ var TAG_PATTERN = /^[a-z0-9:_./-]+$/;
35
+ function sha256(value) {
36
+ return (0, import_node_crypto.createHash)("sha256").update(value).digest("hex").slice(0, 16);
37
+ }
38
+ function safeSegment(value) {
39
+ const raw = value.trim().toLowerCase() || "root";
40
+ const normalized = raw.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/^\//, "").replace(/\/$/, "").replace(/[^a-z0-9:_./-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
41
+ const segment = normalized || "root";
42
+ if (segment.length <= MAX_SEGMENT_LEN) return segment;
43
+ return `${segment.slice(0, 48)}.${sha256(segment)}`;
44
+ }
45
+ function assertTag(tag) {
46
+ if (tag.length > MAX_TAG_LEN || !TAG_PATTERN.test(tag)) {
47
+ return `tag:${sha256(tag)}`;
48
+ }
49
+ return tag;
50
+ }
51
+ var tags = {
52
+ site() {
53
+ return "site";
54
+ },
55
+ pages() {
56
+ return "pages";
57
+ },
58
+ group(group) {
59
+ return assertTag(`group:${safeSegment(group)}`);
60
+ },
61
+ page(group, slug) {
62
+ const path = Array.isArray(slug) ? slug.join("/") : slug;
63
+ return assertTag(`page:${safeSegment(group)}:${safeSegment(path)}`);
64
+ },
65
+ manifest(contentHash) {
66
+ return assertTag(`manifest:${safeSegment(contentHash)}`);
67
+ },
68
+ sitemap() {
69
+ return "sitemap";
70
+ },
71
+ robots() {
72
+ return "robots";
73
+ },
74
+ llms(scope = "root") {
75
+ return assertTag(`llms:${safeSegment(scope)}`);
76
+ }
77
+ };
78
+
79
+ // src/internal/utils/logger.ts
80
+ var isDev = process.env.NODE_ENV !== "production";
81
+ var log = {
82
+ debug(...args) {
83
+ if (isDev) console.debug("[publish.os:debug]", ...args);
84
+ },
85
+ info(...args) {
86
+ console.log("[publish.os]", ...args);
87
+ },
88
+ warn(...args) {
89
+ console.warn("[publish.os:warn]", ...args);
90
+ },
91
+ error(...args) {
92
+ console.error("[publish.os:error]", ...args);
93
+ }
94
+ };
95
+
96
+ // src/resolvers/manifest-resolver.ts
97
+ function groupNode(group) {
98
+ return {
99
+ type: "section",
100
+ id: group.key,
101
+ title: group.title,
102
+ path: group.path,
103
+ group: group.key,
104
+ children: group.tree
105
+ };
106
+ }
107
+ function resolveGroup(manifest, group) {
108
+ const groupData = manifest.groups[group];
109
+ if (!groupData) return null;
110
+ return {
111
+ site: manifest.site,
112
+ tree: groupData.tree,
113
+ node: groupNode(groupData),
114
+ currentPath: groupData.path,
115
+ group
116
+ };
117
+ }
118
+
119
+ // src/pages/group.tsx
120
+ var import_jsx_runtime = require("react/jsx-runtime");
121
+ var manifests = /* @__PURE__ */ new Map();
122
+ var indexPages = /* @__PURE__ */ new Map();
123
+ async function CachedGroupPage({ group }) {
124
+ "use cache";
125
+ (0, import_cache.cacheLife)("page");
126
+ (0, import_cache.cacheTag)(tags.site(), tags.group(group));
127
+ const manifest = manifests.get(group);
128
+ const IndexPage = indexPages.get(group);
129
+ if (!manifest || !IndexPage) (0, import_navigation.notFound)();
130
+ (0, import_cache.cacheTag)(tags.manifest(manifest.contentHash));
131
+ log.debug("[cache]", group);
132
+ const resolved = resolveGroup(manifest, group);
133
+ if (!resolved) (0, import_navigation.notFound)();
134
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IndexPage, { ...resolved });
135
+ }
136
+ function createGroupPage({
137
+ group,
138
+ manifest,
139
+ IndexPage
140
+ }) {
141
+ manifests.set(group, manifest);
142
+ indexPages.set(group, IndexPage);
143
+ return async function Page() {
144
+ log.debug("[render]", group);
145
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CachedGroupPage, { group });
146
+ };
147
+ }
148
+ function createGroupMetadata({
149
+ group,
150
+ manifest
151
+ }) {
152
+ const groupData = manifest.groups[group];
153
+ return {
154
+ title: groupData?.title ?? group,
155
+ description: manifest.site.description
156
+ };
157
+ }
158
+ // Annotate the CommonJS export names for ESM import in node:
159
+ 0 && (module.exports = {
160
+ createGroupMetadata,
161
+ createGroupPage
162
+ });
@@ -0,0 +1,15 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Metadata } from 'next';
3
+ import { ReactElement } from 'react';
4
+ import { ManifestLike, IndexPageProps } from '../types.cjs';
5
+
6
+ type IndexPageComponent = (props: IndexPageProps) => ReactElement | Promise<ReactElement>;
7
+ type GroupRouteConfig = {
8
+ group: string;
9
+ manifest: ManifestLike;
10
+ IndexPage: IndexPageComponent;
11
+ };
12
+ declare function createGroupPage({ group, manifest, IndexPage, }: GroupRouteConfig): () => Promise<react_jsx_runtime.JSX.Element>;
13
+ declare function createGroupMetadata({ group, manifest, }: GroupRouteConfig): Metadata;
14
+
15
+ export { type GroupRouteConfig, type IndexPageComponent, createGroupMetadata, createGroupPage };
@@ -0,0 +1,15 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Metadata } from 'next';
3
+ import { ReactElement } from 'react';
4
+ import { ManifestLike, IndexPageProps } from '../types.js';
5
+
6
+ type IndexPageComponent = (props: IndexPageProps) => ReactElement | Promise<ReactElement>;
7
+ type GroupRouteConfig = {
8
+ group: string;
9
+ manifest: ManifestLike;
10
+ IndexPage: IndexPageComponent;
11
+ };
12
+ declare function createGroupPage({ group, manifest, IndexPage, }: GroupRouteConfig): () => Promise<react_jsx_runtime.JSX.Element>;
13
+ declare function createGroupMetadata({ group, manifest, }: GroupRouteConfig): Metadata;
14
+
15
+ export { type GroupRouteConfig, type IndexPageComponent, createGroupMetadata, createGroupPage };
@@ -0,0 +1,136 @@
1
+ // src/pages/group.tsx
2
+ import { cacheLife, cacheTag } from "next/cache";
3
+ import { notFound } from "next/navigation";
4
+
5
+ // src/cache/tags.ts
6
+ import { createHash } from "crypto";
7
+ var MAX_TAG_LEN = 256;
8
+ var MAX_SEGMENT_LEN = 80;
9
+ var TAG_PATTERN = /^[a-z0-9:_./-]+$/;
10
+ function sha256(value) {
11
+ return createHash("sha256").update(value).digest("hex").slice(0, 16);
12
+ }
13
+ function safeSegment(value) {
14
+ const raw = value.trim().toLowerCase() || "root";
15
+ const normalized = raw.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/^\//, "").replace(/\/$/, "").replace(/[^a-z0-9:_./-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
16
+ const segment = normalized || "root";
17
+ if (segment.length <= MAX_SEGMENT_LEN) return segment;
18
+ return `${segment.slice(0, 48)}.${sha256(segment)}`;
19
+ }
20
+ function assertTag(tag) {
21
+ if (tag.length > MAX_TAG_LEN || !TAG_PATTERN.test(tag)) {
22
+ return `tag:${sha256(tag)}`;
23
+ }
24
+ return tag;
25
+ }
26
+ var tags = {
27
+ site() {
28
+ return "site";
29
+ },
30
+ pages() {
31
+ return "pages";
32
+ },
33
+ group(group) {
34
+ return assertTag(`group:${safeSegment(group)}`);
35
+ },
36
+ page(group, slug) {
37
+ const path = Array.isArray(slug) ? slug.join("/") : slug;
38
+ return assertTag(`page:${safeSegment(group)}:${safeSegment(path)}`);
39
+ },
40
+ manifest(contentHash) {
41
+ return assertTag(`manifest:${safeSegment(contentHash)}`);
42
+ },
43
+ sitemap() {
44
+ return "sitemap";
45
+ },
46
+ robots() {
47
+ return "robots";
48
+ },
49
+ llms(scope = "root") {
50
+ return assertTag(`llms:${safeSegment(scope)}`);
51
+ }
52
+ };
53
+
54
+ // src/internal/utils/logger.ts
55
+ var isDev = process.env.NODE_ENV !== "production";
56
+ var log = {
57
+ debug(...args) {
58
+ if (isDev) console.debug("[publish.os:debug]", ...args);
59
+ },
60
+ info(...args) {
61
+ console.log("[publish.os]", ...args);
62
+ },
63
+ warn(...args) {
64
+ console.warn("[publish.os:warn]", ...args);
65
+ },
66
+ error(...args) {
67
+ console.error("[publish.os:error]", ...args);
68
+ }
69
+ };
70
+
71
+ // src/resolvers/manifest-resolver.ts
72
+ function groupNode(group) {
73
+ return {
74
+ type: "section",
75
+ id: group.key,
76
+ title: group.title,
77
+ path: group.path,
78
+ group: group.key,
79
+ children: group.tree
80
+ };
81
+ }
82
+ function resolveGroup(manifest, group) {
83
+ const groupData = manifest.groups[group];
84
+ if (!groupData) return null;
85
+ return {
86
+ site: manifest.site,
87
+ tree: groupData.tree,
88
+ node: groupNode(groupData),
89
+ currentPath: groupData.path,
90
+ group
91
+ };
92
+ }
93
+
94
+ // src/pages/group.tsx
95
+ import { jsx } from "react/jsx-runtime";
96
+ var manifests = /* @__PURE__ */ new Map();
97
+ var indexPages = /* @__PURE__ */ new Map();
98
+ async function CachedGroupPage({ group }) {
99
+ "use cache";
100
+ cacheLife("page");
101
+ cacheTag(tags.site(), tags.group(group));
102
+ const manifest = manifests.get(group);
103
+ const IndexPage = indexPages.get(group);
104
+ if (!manifest || !IndexPage) notFound();
105
+ cacheTag(tags.manifest(manifest.contentHash));
106
+ log.debug("[cache]", group);
107
+ const resolved = resolveGroup(manifest, group);
108
+ if (!resolved) notFound();
109
+ return /* @__PURE__ */ jsx(IndexPage, { ...resolved });
110
+ }
111
+ function createGroupPage({
112
+ group,
113
+ manifest,
114
+ IndexPage
115
+ }) {
116
+ manifests.set(group, manifest);
117
+ indexPages.set(group, IndexPage);
118
+ return async function Page() {
119
+ log.debug("[render]", group);
120
+ return /* @__PURE__ */ jsx(CachedGroupPage, { group });
121
+ };
122
+ }
123
+ function createGroupMetadata({
124
+ group,
125
+ manifest
126
+ }) {
127
+ const groupData = manifest.groups[group];
128
+ return {
129
+ title: groupData?.title ?? group,
130
+ description: manifest.site.description
131
+ };
132
+ }
133
+ export {
134
+ createGroupMetadata,
135
+ createGroupPage
136
+ };