@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,203 @@
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/leaf.tsx
21
+ var leaf_exports = {};
22
+ __export(leaf_exports, {
23
+ createLeafMetadata: () => createLeafMetadata,
24
+ createLeafPage: () => createLeafPage,
25
+ createLeafStaticParams: () => createLeafStaticParams
26
+ });
27
+ module.exports = __toCommonJS(leaf_exports);
28
+ var import_cache = require("next/cache");
29
+ var import_navigation = require("next/navigation");
30
+
31
+ // src/cache/tags.ts
32
+ var import_node_crypto = require("crypto");
33
+ var MAX_TAG_LEN = 256;
34
+ var MAX_SEGMENT_LEN = 80;
35
+ var TAG_PATTERN = /^[a-z0-9:_./-]+$/;
36
+ function sha256(value) {
37
+ return (0, import_node_crypto.createHash)("sha256").update(value).digest("hex").slice(0, 16);
38
+ }
39
+ function safeSegment(value) {
40
+ const raw = value.trim().toLowerCase() || "root";
41
+ const normalized = raw.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/^\//, "").replace(/\/$/, "").replace(/[^a-z0-9:_./-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
42
+ const segment = normalized || "root";
43
+ if (segment.length <= MAX_SEGMENT_LEN) return segment;
44
+ return `${segment.slice(0, 48)}.${sha256(segment)}`;
45
+ }
46
+ function assertTag(tag) {
47
+ if (tag.length > MAX_TAG_LEN || !TAG_PATTERN.test(tag)) {
48
+ return `tag:${sha256(tag)}`;
49
+ }
50
+ return tag;
51
+ }
52
+ var tags = {
53
+ site() {
54
+ return "site";
55
+ },
56
+ pages() {
57
+ return "pages";
58
+ },
59
+ group(group) {
60
+ return assertTag(`group:${safeSegment(group)}`);
61
+ },
62
+ page(group, slug) {
63
+ const path = Array.isArray(slug) ? slug.join("/") : slug;
64
+ return assertTag(`page:${safeSegment(group)}:${safeSegment(path)}`);
65
+ },
66
+ manifest(contentHash) {
67
+ return assertTag(`manifest:${safeSegment(contentHash)}`);
68
+ },
69
+ sitemap() {
70
+ return "sitemap";
71
+ },
72
+ robots() {
73
+ return "robots";
74
+ },
75
+ llms(scope = "root") {
76
+ return assertTag(`llms:${safeSegment(scope)}`);
77
+ }
78
+ };
79
+
80
+ // src/internal/utils/logger.ts
81
+ var isDev = process.env.NODE_ENV !== "production";
82
+ var log = {
83
+ debug(...args) {
84
+ if (isDev) console.debug("[publish.os:debug]", ...args);
85
+ },
86
+ info(...args) {
87
+ console.log("[publish.os]", ...args);
88
+ },
89
+ warn(...args) {
90
+ console.warn("[publish.os:warn]", ...args);
91
+ },
92
+ error(...args) {
93
+ console.error("[publish.os:error]", ...args);
94
+ }
95
+ };
96
+
97
+ // src/resolvers/manifest-resolver.ts
98
+ function findNodeInTree(nodes, id) {
99
+ for (const node of nodes) {
100
+ if (node.id === id) return node;
101
+ if (node.type === "section" || node.type === "folder") {
102
+ const found = findNodeInTree(node.children, id);
103
+ if (found) return found;
104
+ }
105
+ }
106
+ return null;
107
+ }
108
+ function pageNode(page) {
109
+ return {
110
+ type: "page",
111
+ id: page.id,
112
+ title: page.title,
113
+ path: page.path,
114
+ group: page.group,
115
+ description: page.description,
116
+ status: page.status,
117
+ publishedAt: page.publishedAt,
118
+ updatedAt: page.updatedAt,
119
+ authors: page.authors,
120
+ tags: page.tags,
121
+ meta: page.meta
122
+ };
123
+ }
124
+ function resolveLeaf(manifest, group, slug) {
125
+ const slugPath = Array.isArray(slug) ? slug.join("/") : slug;
126
+ const page = manifest.pages.find((p) => p.group === group && p.slug === slugPath) ?? null;
127
+ if (!page) return null;
128
+ const groupData = manifest.groups[group];
129
+ if (!groupData) return null;
130
+ return {
131
+ site: manifest.site,
132
+ tree: groupData.tree,
133
+ node: findNodeInTree(groupData.tree, page.id) ?? pageNode(page),
134
+ page,
135
+ currentPath: page.path,
136
+ group
137
+ };
138
+ }
139
+ function listStaticParams(manifest, group) {
140
+ const groupData = manifest.groups[group];
141
+ if (!groupData) return [];
142
+ return groupData.pages.map((page) => ({ slug: page.slug.split("/") }));
143
+ }
144
+
145
+ // src/pages/leaf.tsx
146
+ var import_jsx_runtime = require("react/jsx-runtime");
147
+ var manifests = /* @__PURE__ */ new Map();
148
+ var leaves = /* @__PURE__ */ new Map();
149
+ async function CachedLeafPage({
150
+ group,
151
+ slug
152
+ }) {
153
+ "use cache";
154
+ (0, import_cache.cacheLife)("page");
155
+ (0, import_cache.cacheTag)(
156
+ tags.site(),
157
+ tags.pages(),
158
+ tags.group(group),
159
+ tags.page(group, slug)
160
+ );
161
+ const manifest = manifests.get(group);
162
+ const Leaf = leaves.get(group);
163
+ if (!manifest || !Leaf) (0, import_navigation.notFound)();
164
+ (0, import_cache.cacheTag)(tags.manifest(manifest.contentHash));
165
+ log.debug("[cache]", `${group}/${slug.join("/")}`);
166
+ const resolved = resolveLeaf(manifest, group, slug);
167
+ if (!resolved) (0, import_navigation.notFound)();
168
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Leaf, { ...resolved });
169
+ }
170
+ function createLeafPage({ group, manifest, Leaf }) {
171
+ manifests.set(group, manifest);
172
+ leaves.set(group, Leaf);
173
+ return async function Page({ params }) {
174
+ const { slug = [] } = await params;
175
+ log.debug("[render]", `${group}/${slug.join("/")}`);
176
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CachedLeafPage, { group, slug });
177
+ };
178
+ }
179
+ function createLeafMetadata({ group, manifest }) {
180
+ return async function generateMetadata({
181
+ params
182
+ }) {
183
+ const { slug = [] } = await params;
184
+ log.debug("[metadata]", `${group}/${slug.join("/")}`);
185
+ const resolved = resolveLeaf(manifest, group, slug);
186
+ if (!resolved) return {};
187
+ return {
188
+ title: resolved.page.title,
189
+ description: resolved.page.description
190
+ };
191
+ };
192
+ }
193
+ function createLeafStaticParams({ group, manifest }) {
194
+ return function generateStaticParams() {
195
+ return listStaticParams(manifest, group);
196
+ };
197
+ }
198
+ // Annotate the CommonJS export names for ESM import in node:
199
+ 0 && (module.exports = {
200
+ createLeafMetadata,
201
+ createLeafPage,
202
+ createLeafStaticParams
203
+ });
@@ -0,0 +1,23 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Metadata } from 'next';
3
+ import { ReactElement } from 'react';
4
+ import { PageProps, ManifestLike } from '../types.cjs';
5
+
6
+ type LeafComponent = (props: PageProps) => ReactElement | Promise<ReactElement>;
7
+ type LeafRouteConfig = {
8
+ group: string;
9
+ manifest: ManifestLike;
10
+ Leaf: LeafComponent;
11
+ };
12
+ type PageRouteProps = {
13
+ params: Promise<{
14
+ slug?: string[];
15
+ }>;
16
+ };
17
+ declare function createLeafPage({ group, manifest, Leaf }: LeafRouteConfig): ({ params }: PageRouteProps) => Promise<react_jsx_runtime.JSX.Element>;
18
+ declare function createLeafMetadata({ group, manifest }: LeafRouteConfig): ({ params, }: PageRouteProps) => Promise<Metadata>;
19
+ declare function createLeafStaticParams({ group, manifest }: LeafRouteConfig): () => {
20
+ slug: string[];
21
+ }[];
22
+
23
+ export { type LeafComponent, type LeafRouteConfig, createLeafMetadata, createLeafPage, createLeafStaticParams };
@@ -0,0 +1,23 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Metadata } from 'next';
3
+ import { ReactElement } from 'react';
4
+ import { PageProps, ManifestLike } from '../types.js';
5
+
6
+ type LeafComponent = (props: PageProps) => ReactElement | Promise<ReactElement>;
7
+ type LeafRouteConfig = {
8
+ group: string;
9
+ manifest: ManifestLike;
10
+ Leaf: LeafComponent;
11
+ };
12
+ type PageRouteProps = {
13
+ params: Promise<{
14
+ slug?: string[];
15
+ }>;
16
+ };
17
+ declare function createLeafPage({ group, manifest, Leaf }: LeafRouteConfig): ({ params }: PageRouteProps) => Promise<react_jsx_runtime.JSX.Element>;
18
+ declare function createLeafMetadata({ group, manifest }: LeafRouteConfig): ({ params, }: PageRouteProps) => Promise<Metadata>;
19
+ declare function createLeafStaticParams({ group, manifest }: LeafRouteConfig): () => {
20
+ slug: string[];
21
+ }[];
22
+
23
+ export { type LeafComponent, type LeafRouteConfig, createLeafMetadata, createLeafPage, createLeafStaticParams };
@@ -0,0 +1,176 @@
1
+ // src/pages/leaf.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 findNodeInTree(nodes, id) {
73
+ for (const node of nodes) {
74
+ if (node.id === id) return node;
75
+ if (node.type === "section" || node.type === "folder") {
76
+ const found = findNodeInTree(node.children, id);
77
+ if (found) return found;
78
+ }
79
+ }
80
+ return null;
81
+ }
82
+ function pageNode(page) {
83
+ return {
84
+ type: "page",
85
+ id: page.id,
86
+ title: page.title,
87
+ path: page.path,
88
+ group: page.group,
89
+ description: page.description,
90
+ status: page.status,
91
+ publishedAt: page.publishedAt,
92
+ updatedAt: page.updatedAt,
93
+ authors: page.authors,
94
+ tags: page.tags,
95
+ meta: page.meta
96
+ };
97
+ }
98
+ function resolveLeaf(manifest, group, slug) {
99
+ const slugPath = Array.isArray(slug) ? slug.join("/") : slug;
100
+ const page = manifest.pages.find((p) => p.group === group && p.slug === slugPath) ?? null;
101
+ if (!page) return null;
102
+ const groupData = manifest.groups[group];
103
+ if (!groupData) return null;
104
+ return {
105
+ site: manifest.site,
106
+ tree: groupData.tree,
107
+ node: findNodeInTree(groupData.tree, page.id) ?? pageNode(page),
108
+ page,
109
+ currentPath: page.path,
110
+ group
111
+ };
112
+ }
113
+ function listStaticParams(manifest, group) {
114
+ const groupData = manifest.groups[group];
115
+ if (!groupData) return [];
116
+ return groupData.pages.map((page) => ({ slug: page.slug.split("/") }));
117
+ }
118
+
119
+ // src/pages/leaf.tsx
120
+ import { jsx } from "react/jsx-runtime";
121
+ var manifests = /* @__PURE__ */ new Map();
122
+ var leaves = /* @__PURE__ */ new Map();
123
+ async function CachedLeafPage({
124
+ group,
125
+ slug
126
+ }) {
127
+ "use cache";
128
+ cacheLife("page");
129
+ cacheTag(
130
+ tags.site(),
131
+ tags.pages(),
132
+ tags.group(group),
133
+ tags.page(group, slug)
134
+ );
135
+ const manifest = manifests.get(group);
136
+ const Leaf = leaves.get(group);
137
+ if (!manifest || !Leaf) notFound();
138
+ cacheTag(tags.manifest(manifest.contentHash));
139
+ log.debug("[cache]", `${group}/${slug.join("/")}`);
140
+ const resolved = resolveLeaf(manifest, group, slug);
141
+ if (!resolved) notFound();
142
+ return /* @__PURE__ */ jsx(Leaf, { ...resolved });
143
+ }
144
+ function createLeafPage({ group, manifest, Leaf }) {
145
+ manifests.set(group, manifest);
146
+ leaves.set(group, Leaf);
147
+ return async function Page({ params }) {
148
+ const { slug = [] } = await params;
149
+ log.debug("[render]", `${group}/${slug.join("/")}`);
150
+ return /* @__PURE__ */ jsx(CachedLeafPage, { group, slug });
151
+ };
152
+ }
153
+ function createLeafMetadata({ group, manifest }) {
154
+ return async function generateMetadata({
155
+ params
156
+ }) {
157
+ const { slug = [] } = await params;
158
+ log.debug("[metadata]", `${group}/${slug.join("/")}`);
159
+ const resolved = resolveLeaf(manifest, group, slug);
160
+ if (!resolved) return {};
161
+ return {
162
+ title: resolved.page.title,
163
+ description: resolved.page.description
164
+ };
165
+ };
166
+ }
167
+ function createLeafStaticParams({ group, manifest }) {
168
+ return function generateStaticParams() {
169
+ return listStaticParams(manifest, group);
170
+ };
171
+ }
172
+ export {
173
+ createLeafMetadata,
174
+ createLeafPage,
175
+ createLeafStaticParams
176
+ };
@@ -0,0 +1,127 @@
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/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
+ };
77
+
78
+ // src/internal/utils/logger.ts
79
+ var isDev = process.env.NODE_ENV !== "production";
80
+ var log = {
81
+ debug(...args) {
82
+ if (isDev) console.debug("[publish.os:debug]", ...args);
83
+ },
84
+ info(...args) {
85
+ console.log("[publish.os]", ...args);
86
+ },
87
+ warn(...args) {
88
+ console.warn("[publish.os:warn]", ...args);
89
+ },
90
+ error(...args) {
91
+ console.error("[publish.os:error]", ...args);
92
+ }
93
+ };
94
+
95
+ // src/pages/root.tsx
96
+ var import_jsx_runtime = require("react/jsx-runtime");
97
+ var rootManifest;
98
+ var rootPage;
99
+ async function CachedRootPage() {
100
+ "use cache";
101
+ (0, import_cache.cacheLife)("page");
102
+ (0, import_cache.cacheTag)(tags.site());
103
+ if (!rootManifest || !rootPage) return null;
104
+ (0, import_cache.cacheTag)(tags.manifest(rootManifest.contentHash));
105
+ log.debug("[cache]", "root");
106
+ const RootPage = rootPage;
107
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RootPage, { site: rootManifest.site, tree: rootManifest.tree });
108
+ }
109
+ function createRootPage({ manifest, RootPage }) {
110
+ rootManifest = manifest;
111
+ rootPage = RootPage;
112
+ return async function Page() {
113
+ log.debug("[render]", "root");
114
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CachedRootPage, {});
115
+ };
116
+ }
117
+ function createRootMetadata({ manifest }) {
118
+ return {
119
+ title: manifest.site.title,
120
+ description: manifest.site.description
121
+ };
122
+ }
123
+ // Annotate the CommonJS export names for ESM import in node:
124
+ 0 && (module.exports = {
125
+ createRootMetadata,
126
+ createRootPage
127
+ });
@@ -0,0 +1,14 @@
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
+
6
+ type RootPageComponent = (props: RootPageProps) => ReactElement | Promise<ReactElement>;
7
+ type RootRouteConfig = {
8
+ manifest: ManifestLike;
9
+ RootPage: RootPageComponent;
10
+ };
11
+ declare function createRootPage({ manifest, RootPage }: RootRouteConfig): () => Promise<react_jsx_runtime.JSX.Element>;
12
+ declare function createRootMetadata({ manifest }: RootRouteConfig): Metadata;
13
+
14
+ export { type RootPageComponent, type RootRouteConfig, createRootMetadata, createRootPage };
@@ -0,0 +1,14 @@
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.js';
5
+
6
+ type RootPageComponent = (props: RootPageProps) => ReactElement | Promise<ReactElement>;
7
+ type RootRouteConfig = {
8
+ manifest: ManifestLike;
9
+ RootPage: RootPageComponent;
10
+ };
11
+ declare function createRootPage({ manifest, RootPage }: RootRouteConfig): () => Promise<react_jsx_runtime.JSX.Element>;
12
+ declare function createRootMetadata({ manifest }: RootRouteConfig): Metadata;
13
+
14
+ export { type RootPageComponent, type RootRouteConfig, createRootMetadata, createRootPage };
@@ -0,0 +1,101 @@
1
+ // src/pages/root.tsx
2
+ import { cacheLife, cacheTag } from "next/cache";
3
+
4
+ // src/cache/tags.ts
5
+ import { createHash } from "crypto";
6
+ var MAX_TAG_LEN = 256;
7
+ var MAX_SEGMENT_LEN = 80;
8
+ var TAG_PATTERN = /^[a-z0-9:_./-]+$/;
9
+ function sha256(value) {
10
+ return createHash("sha256").update(value).digest("hex").slice(0, 16);
11
+ }
12
+ function safeSegment(value) {
13
+ const raw = value.trim().toLowerCase() || "root";
14
+ const normalized = raw.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/^\//, "").replace(/\/$/, "").replace(/[^a-z0-9:_./-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
15
+ const segment = normalized || "root";
16
+ if (segment.length <= MAX_SEGMENT_LEN) return segment;
17
+ return `${segment.slice(0, 48)}.${sha256(segment)}`;
18
+ }
19
+ function assertTag(tag) {
20
+ if (tag.length > MAX_TAG_LEN || !TAG_PATTERN.test(tag)) {
21
+ return `tag:${sha256(tag)}`;
22
+ }
23
+ return tag;
24
+ }
25
+ var tags = {
26
+ site() {
27
+ return "site";
28
+ },
29
+ pages() {
30
+ return "pages";
31
+ },
32
+ group(group) {
33
+ return assertTag(`group:${safeSegment(group)}`);
34
+ },
35
+ page(group, slug) {
36
+ const path = Array.isArray(slug) ? slug.join("/") : slug;
37
+ return assertTag(`page:${safeSegment(group)}:${safeSegment(path)}`);
38
+ },
39
+ manifest(contentHash) {
40
+ return assertTag(`manifest:${safeSegment(contentHash)}`);
41
+ },
42
+ sitemap() {
43
+ return "sitemap";
44
+ },
45
+ robots() {
46
+ return "robots";
47
+ },
48
+ llms(scope = "root") {
49
+ return assertTag(`llms:${safeSegment(scope)}`);
50
+ }
51
+ };
52
+
53
+ // src/internal/utils/logger.ts
54
+ var isDev = process.env.NODE_ENV !== "production";
55
+ var log = {
56
+ debug(...args) {
57
+ if (isDev) console.debug("[publish.os:debug]", ...args);
58
+ },
59
+ info(...args) {
60
+ console.log("[publish.os]", ...args);
61
+ },
62
+ warn(...args) {
63
+ console.warn("[publish.os:warn]", ...args);
64
+ },
65
+ error(...args) {
66
+ console.error("[publish.os:error]", ...args);
67
+ }
68
+ };
69
+
70
+ // src/pages/root.tsx
71
+ import { jsx } from "react/jsx-runtime";
72
+ var rootManifest;
73
+ var rootPage;
74
+ async function CachedRootPage() {
75
+ "use cache";
76
+ cacheLife("page");
77
+ cacheTag(tags.site());
78
+ if (!rootManifest || !rootPage) return null;
79
+ cacheTag(tags.manifest(rootManifest.contentHash));
80
+ log.debug("[cache]", "root");
81
+ const RootPage = rootPage;
82
+ return /* @__PURE__ */ jsx(RootPage, { site: rootManifest.site, tree: rootManifest.tree });
83
+ }
84
+ function createRootPage({ manifest, RootPage }) {
85
+ rootManifest = manifest;
86
+ rootPage = RootPage;
87
+ return async function Page() {
88
+ log.debug("[render]", "root");
89
+ return /* @__PURE__ */ jsx(CachedRootPage, {});
90
+ };
91
+ }
92
+ function createRootMetadata({ manifest }) {
93
+ return {
94
+ title: manifest.site.title,
95
+ description: manifest.site.description
96
+ };
97
+ }
98
+ export {
99
+ createRootMetadata,
100
+ createRootPage
101
+ };