pagegraph 0.10.1 → 0.12.0
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.
- package/README.md +163 -124
- package/dist/audit.d.ts +1 -1
- package/dist/audit.js +1 -1
- package/dist/build-only/audit.d.ts +1 -0
- package/dist/build-only/audit.js +6 -0
- package/dist/build-only/audit.js.map +1 -0
- package/dist/build-only/config.d.ts +1 -0
- package/dist/build-only/config.js +6 -0
- package/dist/build-only/config.js.map +1 -0
- package/dist/build-only/tanstack-start.d.ts +1 -0
- package/dist/build-only/tanstack-start.js +6 -0
- package/dist/build-only/tanstack-start.js.map +1 -0
- package/dist/build-only/vite.d.ts +1 -0
- package/dist/build-only/vite.js +6 -0
- package/dist/build-only/vite.js.map +1 -0
- package/dist/checks-uZk5Em9A.js +352 -0
- package/dist/checks-uZk5Em9A.js.map +1 -0
- package/dist/cli.js +3814 -3017
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +10 -45
- package/dist/config.js +10 -98
- package/dist/config.js.map +1 -1
- package/dist/{content-DVL2iyGU.d.ts → content-B1cPtL8b.d.ts} +4 -128
- package/dist/{content-BE9KCTgb.js → content-kcEnQdfi.js} +4 -489
- package/dist/content-kcEnQdfi.js.map +1 -0
- package/dist/declare-D5o7hwmv.js +9 -0
- package/dist/declare-D5o7hwmv.js.map +1 -0
- package/dist/declare-DVgdEdOL.d.ts +12127 -0
- package/dist/graph-Bcsourlv.js +162 -0
- package/dist/graph-Bcsourlv.js.map +1 -0
- package/dist/graph-BxCY90vq.d.ts +104 -0
- package/dist/graph-CBIY71w6.d.ts +57 -0
- package/dist/index.d.ts +37 -73
- package/dist/index.js +23 -133
- package/dist/index.js.map +1 -1
- package/dist/message-DT_CjUdt.js +12 -0
- package/dist/message-DT_CjUdt.js.map +1 -0
- package/dist/page-heads-6y-CARRQ.js +25 -0
- package/dist/page-heads-6y-CARRQ.js.map +1 -0
- package/dist/page-heads-DNkjMUEN.d.ts +21 -0
- package/dist/projections-D0oOFKiY.js +142 -0
- package/dist/projections-D0oOFKiY.js.map +1 -0
- package/dist/projections-DeEFe7XT.d.ts +78 -0
- package/dist/react.d.ts +26 -12051
- package/dist/react.js +12 -3
- package/dist/react.js.map +1 -1
- package/dist/route-config-35ZEzkNC.js +308 -0
- package/dist/route-config-35ZEzkNC.js.map +1 -0
- package/dist/route-config-wneg6ktn.d.ts +29 -0
- package/dist/tanstack-start/index.d.ts +40 -0
- package/dist/tanstack-start/index.js +368 -0
- package/dist/tanstack-start/index.js.map +1 -0
- package/dist/tanstack-start/server.d.ts +14 -0
- package/dist/tanstack-start/server.js +53 -0
- package/dist/tanstack-start/server.js.map +1 -0
- package/dist/vite-graph-loader-01p1WxEq.js +104 -0
- package/dist/vite-graph-loader-01p1WxEq.js.map +1 -0
- package/dist/vite-graph-loader-Btgjz5RH.d.ts +56 -0
- package/dist/vite.d.ts +2 -28
- package/dist/vite.js +1 -307
- package/dist/wire-B4RQMc4e.js +26 -0
- package/dist/wire-B4RQMc4e.js.map +1 -0
- package/package.json +35 -13
- package/dist/content-BE9KCTgb.js.map +0 -1
- package/dist/vite.js.map +0 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { a as SeoGraph } from "./graph-BxCY90vq.js";
|
|
2
|
+
import { r as RobotsConfig } from "./projections-DeEFe7XT.js";
|
|
3
|
+
import { PluginOption } from "vite";
|
|
4
|
+
//#region src/config/vite-graph-loader.d.ts
|
|
5
|
+
/** A graph, plus the release of whatever producing it acquired. */
|
|
6
|
+
interface LoadedSeoGraph {
|
|
7
|
+
readonly graph: SeoGraph;
|
|
8
|
+
/**
|
|
9
|
+
* The robots policy the app serves, when the loader knows it (the TanStack
|
|
10
|
+
* Start loader reads it from the `pagegraph()` plugin). `pagegraph robots`
|
|
11
|
+
* uses it instead of `seo.config.ts` fields.
|
|
12
|
+
*/
|
|
13
|
+
readonly robots?: Pick<RobotsConfig, "disallow" | "contentSignal" | "directives"> | undefined;
|
|
14
|
+
/** Called once the command is done with the graph, on success or failure. */
|
|
15
|
+
readonly dispose: () => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Produces the SEO graph for the `pagegraph` CLI. A plain promise on purpose: a
|
|
19
|
+
* config file must be writable without Effect, which the CLI keeps behind its
|
|
20
|
+
* `bin` (an optional peer dependency).
|
|
21
|
+
*/
|
|
22
|
+
/** JSON input that can be supplied by config files to an app graph export. */
|
|
23
|
+
type GraphLoaderInput = null | boolean | number | string | ReadonlyArray<GraphLoaderInput> | {
|
|
24
|
+
readonly [key: string]: GraphLoaderInput;
|
|
25
|
+
};
|
|
26
|
+
type SeoGraphLoader<Input extends GraphLoaderInput | void = void> = (input: Input) => Promise<LoadedSeoGraph>;
|
|
27
|
+
interface ViteGraphLoaderOptions {
|
|
28
|
+
/** The app's Vite root — the directory its aliases and plugins resolve against. */
|
|
29
|
+
readonly root: string;
|
|
30
|
+
/** Module exporting the graph loader, root-relative (e.g. `/lib/seo/graph.ts`). */
|
|
31
|
+
readonly entry: string;
|
|
32
|
+
/** Named export on `entry` returning `Promise<SeoGraph>`. Defaults to `loadSeoGraph`. */
|
|
33
|
+
readonly exportName?: string | undefined;
|
|
34
|
+
/** Vite plugins the app's module graph needs — a content/MDX plugin, say. */
|
|
35
|
+
readonly plugins?: ReadonlyArray<PluginOption> | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Bare or virtual module ids to replace with inert source, so a module that
|
|
38
|
+
* only resolves inside the app's server runtime does not break the load.
|
|
39
|
+
*/
|
|
40
|
+
readonly stubs?: Readonly<Record<string, string>> | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Variables to seed on `process.env` before the app's modules parse it. Vite
|
|
43
|
+
* exposes prefixed values through `import.meta.env`, so this is how a module
|
|
44
|
+
* that demands an env var at import time is satisfied. Existing values win —
|
|
45
|
+
* a real `.env` is never clobbered.
|
|
46
|
+
*/
|
|
47
|
+
readonly env?: Readonly<Record<string, string>> | undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Build a {@link SeoGraphLoader} that evaluates `entry` in a headless Vite
|
|
51
|
+
* server rooted at `root`, and returns what its `exportName` export resolves to.
|
|
52
|
+
*/
|
|
53
|
+
declare const viteGraphLoader: <Input extends GraphLoaderInput | void = void>(options: ViteGraphLoaderOptions) => SeoGraphLoader<Input>;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { viteGraphLoader as a, ViteGraphLoaderOptions as i, LoadedSeoGraph as n, SeoGraphLoader as r, GraphLoaderInput as t };
|
|
56
|
+
//# sourceMappingURL=vite-graph-loader-Btgjz5RH.d.ts.map
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
interface SeoRouteConfigOptions {
|
|
4
|
-
/** Absolute path the generated route-config module is written to. */
|
|
5
|
-
outputPath: string;
|
|
6
|
-
/** Route groups whose page leaves form the public surface. Include the parens. */
|
|
7
|
-
publicGroups: ReadonlyArray<string>;
|
|
8
|
-
/** Route groups where every page leaf must declare `staticData` or `head`. */
|
|
9
|
-
enforceCoverageIn: ReadonlyArray<string>;
|
|
10
|
-
/** Route groups whose page paths are disallowed in robots.txt (e.g. auth). */
|
|
11
|
-
disallowGroups?: ReadonlyArray<string> | undefined;
|
|
12
|
-
/** Public routes that live outside any group folder, so nothing discovers them. */
|
|
13
|
-
extraPublicRoutes?: ReadonlyArray<string> | undefined;
|
|
14
|
-
/** Reserved top-level segments that are not route-tree paths (e.g. an api mount). */
|
|
15
|
-
reservedExtras?: ReadonlyArray<string> | undefined;
|
|
16
|
-
/** Prefixes always disallowed in robots.txt, route tree or not. */
|
|
17
|
-
alwaysDisallow?: ReadonlyArray<string> | undefined;
|
|
18
|
-
/** Routes directory, relative to the Vite root. Defaults to `src/routes`. */
|
|
19
|
-
routesDirectory?: string | undefined;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Vite plugin that runs its own `@tanstack/router-generator` instance over the
|
|
23
|
-
* routes directory and derives the route-config module from the result.
|
|
24
|
-
*/
|
|
25
|
-
declare function seoRouteConfig(options: SeoRouteConfigOptions): Plugin;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { SeoRouteConfigOptions, seoRouteConfig };
|
|
28
|
-
//# sourceMappingURL=vite.d.ts.map
|
|
1
|
+
import { n as seoRouteConfig, t as SeoRouteConfigOptions } from "./route-config-wneg6ktn.js";
|
|
2
|
+
export { type SeoRouteConfigOptions, seoRouteConfig };
|
package/dist/vite.js
CHANGED
|
@@ -1,308 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { open, stat } from "node:fs/promises";
|
|
3
|
-
import { basename, normalize, resolve } from "node:path";
|
|
4
|
-
import { Generator, getConfig } from "@tanstack/router-generator";
|
|
5
|
-
//#region src/vite/index.ts
|
|
6
|
-
/**
|
|
7
|
-
* Derives a route-config module from the parsed TanStack route tree.
|
|
8
|
-
*
|
|
9
|
-
* The route tree is the single source of truth for which paths exist; this
|
|
10
|
-
* plugin projects it into the small config the host consumes at runtime:
|
|
11
|
-
* - `robotsExclusions` — path prefixes disallowed in robots.txt (feed them to
|
|
12
|
-
* `renderRobots`).
|
|
13
|
-
* - `reservedSegments` — top-level path segments the app must not hand out (an
|
|
14
|
-
* org slug, a tenant name). Derived from the full public route surface — the
|
|
15
|
-
* `publicGroups` route groups plus the group-less `extraPublicRoutes` — which
|
|
16
|
-
* is parsed here but not emitted: "which pages are public" already has a
|
|
17
|
-
* canonical runtime answer in the SEO graph.
|
|
18
|
-
*
|
|
19
|
-
* It also enforces that every page in `enforceCoverageIn` declares its SEO: a
|
|
20
|
-
* page leaf missing both `staticData` and `head` fails dev startup and build.
|
|
21
|
-
*
|
|
22
|
-
* **Why we run our own Generator.** The parse must come from
|
|
23
|
-
* `@tanstack/router-generator` itself — a second, hand-rolled scanner would
|
|
24
|
-
* drift from TanStack's group/param/layout conventions. But routing our plugin
|
|
25
|
-
* through TanStack Start does not work: `start-plugin-core` builds its own
|
|
26
|
-
* generator-plugin array and drops `router.plugins` on the floor
|
|
27
|
-
* (tanstack/router#7768 — `plugins` is not public API there), and even when
|
|
28
|
-
* forced through, the router unplugin wraps `generator.run()` in
|
|
29
|
-
* `catch (e) { console.error(e) }`, so a plugin can never fail a build.
|
|
30
|
-
*
|
|
31
|
-
* So we instantiate `Generator` ourselves — `config.plugins` is natively
|
|
32
|
-
* honored on our own instance, and because we own the `.run()` call site a
|
|
33
|
-
* coverage violation throws straight out of `buildStart`. Cost: route files are
|
|
34
|
-
* parsed twice at startup (~40 files, milliseconds) — the host's router plugin
|
|
35
|
-
* still owns the real `routeTree.gen.ts`; ours is a shadow parse whose route
|
|
36
|
-
* tree is thrown away (see {@link inMemoryWriteFs}).
|
|
37
|
-
*
|
|
38
|
-
* `onRouteTreeChanged` fires on every generator run, but the config is written
|
|
39
|
-
* only when its content changes, and the output path lives outside the routes
|
|
40
|
-
* directory, so regeneration never feeds back into the watcher.
|
|
41
|
-
*/
|
|
42
|
-
const PLUGIN_NAME = "seo-route-config";
|
|
43
|
-
/** Match a route's group folder (`filePath` is relative to the routes directory). */
|
|
44
|
-
function groupOf(filePath, groups) {
|
|
45
|
-
return groups.find((group) => filePath.startsWith(`${group}/`));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* A page leaf is a `.tsx` route file that is not a `route.tsx` layout. This
|
|
49
|
-
* excludes layout wrappers, `.ts` server routes (robots.txt / sitemap.xml /
|
|
50
|
-
* markdown mirrors), and any other non-page file — matching the leaves that
|
|
51
|
-
* contribute a crawlable URL.
|
|
52
|
-
*/
|
|
53
|
-
function isPageLeaf(node) {
|
|
54
|
-
return node.filePath.endsWith(".tsx") && basename(node.filePath) !== "route.tsx";
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Convert a group-prefixed routePath (e.g. "/(marketing)/blog/$slug") into the
|
|
58
|
-
* public URL form used by route-config ("/blog/*"): drop the group segment,
|
|
59
|
-
* collapse the first dynamic/splat segment and everything after it to "*", and
|
|
60
|
-
* trim the index trailing slash.
|
|
61
|
-
*/
|
|
62
|
-
function routePathToPublicUrl(routePath) {
|
|
63
|
-
const stripped = routePath.replace(/^\/\([^)]+\)/, "");
|
|
64
|
-
if (stripped === "" || stripped === "/") return "/";
|
|
65
|
-
const segments = stripped.split("/");
|
|
66
|
-
const dynamicIndex = segments.findIndex((segment) => segment.startsWith("$"));
|
|
67
|
-
if (dynamicIndex !== -1) return `${segments.slice(0, dynamicIndex).join("/")}/*`;
|
|
68
|
-
return stripped.endsWith("/") ? stripped.slice(0, -1) : stripped;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* First path segment of each route, reserved so it can't be claimed as an org
|
|
72
|
-
* slug. Strip the leading slash and a trailing "/*", then take the first
|
|
73
|
-
* segment ("/features/email" -> "features").
|
|
74
|
-
*/
|
|
75
|
-
function extractReservedSegments(routes) {
|
|
76
|
-
const segments = /* @__PURE__ */ new Set();
|
|
77
|
-
for (const route of routes) {
|
|
78
|
-
const first = route.replace(/^\//, "").replace(/\/\*$/, "").split("/")[0];
|
|
79
|
-
if (first) segments.add(first);
|
|
80
|
-
}
|
|
81
|
-
return Array.from(segments).sort();
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* robots.txt disallow prefixes are directory prefixes, so a splat route
|
|
85
|
-
* ("/reset-password/*") disallows the whole subtree ("/reset-password").
|
|
86
|
-
*/
|
|
87
|
-
function normalizeRoutePrefix(route) {
|
|
88
|
-
const cleaned = route.replace(/\/\*$/, "");
|
|
89
|
-
return cleaned === "" ? "/" : cleaned;
|
|
90
|
-
}
|
|
91
|
-
function deriveRouteConfig(routeNodes, options) {
|
|
92
|
-
const publicUrls = new Set(options.extraPublicRoutes);
|
|
93
|
-
const disallowedUrls = /* @__PURE__ */ new Set();
|
|
94
|
-
for (const node of routeNodes) {
|
|
95
|
-
const group = groupOf(node.filePath, options.publicGroups);
|
|
96
|
-
if (group === void 0 || !isPageLeaf(node) || node.routePath === void 0) continue;
|
|
97
|
-
const url = routePathToPublicUrl(node.routePath);
|
|
98
|
-
publicUrls.add(url);
|
|
99
|
-
if (options.disallowGroups.includes(group)) disallowedUrls.add(url);
|
|
100
|
-
}
|
|
101
|
-
const reservedSegments = [...extractReservedSegments([...publicUrls].sort()), ...options.reservedExtras].sort();
|
|
102
|
-
return {
|
|
103
|
-
robotsExclusions: [.../* @__PURE__ */ new Set([...options.alwaysDisallow, ...[...disallowedUrls].map(normalizeRoutePrefix)])].sort(),
|
|
104
|
-
reservedSegments
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Every page in an enforced group must declare its search presence. A leaf that
|
|
109
|
-
* passes neither `staticData` (from which the SEO graph reads `staticData.seo`)
|
|
110
|
-
* nor `head` has no path to correct metadata.
|
|
111
|
-
*/
|
|
112
|
-
function findCoverageViolations(routeNodes, options) {
|
|
113
|
-
const violations = [];
|
|
114
|
-
for (const node of routeNodes) {
|
|
115
|
-
const group = groupOf(node.filePath, options.enforceCoverageIn);
|
|
116
|
-
if (group === void 0 || !isPageLeaf(node)) continue;
|
|
117
|
-
const props = node.createFileRouteProps;
|
|
118
|
-
if (props?.has("staticData") || props?.has("head")) continue;
|
|
119
|
-
violations.push(`${node.filePath} (${group} page)`);
|
|
120
|
-
}
|
|
121
|
-
return violations;
|
|
122
|
-
}
|
|
123
|
-
function coverageMessage(violations) {
|
|
124
|
-
return `[${PLUGIN_NAME}] ${violations.length} page(s) declare neither staticData nor head. Every page in an SEO-enforced route group must declare its SEO — add staticData: { seo: ... } or a head() to each route:\n - ${violations.join("\n - ")}`;
|
|
125
|
-
}
|
|
126
|
-
const HEADER = `// Auto-generated by the ${PLUGIN_NAME} Vite plugin.\n// DO NOT EDIT MANUALLY — regenerated from the route tree on every dev/build.
|
|
127
|
-
`;
|
|
128
|
-
function renderRouteConfig(config) {
|
|
129
|
-
return `${HEADER}
|
|
130
|
-
export const routeConfig = ${JSON.stringify(config, null, 2)} as const;
|
|
131
|
-
|
|
132
|
-
export type RouteConfig = typeof routeConfig;
|
|
133
|
-
`;
|
|
134
|
-
}
|
|
135
|
-
function routeConfigGeneratorPlugin(options) {
|
|
136
|
-
const { outputPath } = options;
|
|
137
|
-
return {
|
|
138
|
-
name: PLUGIN_NAME,
|
|
139
|
-
init() {
|
|
140
|
-
if (!existsSync(resolve(outputPath, ".."))) throw new Error(`[${PLUGIN_NAME}] output directory does not exist: ${resolve(outputPath, "..")}`);
|
|
141
|
-
},
|
|
142
|
-
onRouteTreeChanged({ routeNodes }) {
|
|
143
|
-
const violations = findCoverageViolations(routeNodes, options);
|
|
144
|
-
if (violations.length > 0) throw new Error(coverageMessage(violations));
|
|
145
|
-
const content = renderRouteConfig(deriveRouteConfig(routeNodes, options));
|
|
146
|
-
if ((existsSync(outputPath) ? readFileSync(outputPath, "utf8") : void 0) !== content) writeFileSync(outputPath, content);
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* A `Generator` filesystem that reads real files but keeps every write in
|
|
152
|
-
* memory, so our shadow parse cannot touch the repo.
|
|
153
|
-
*
|
|
154
|
-
* The Generator writes through `safeFileWrite`: `writeFile(<tmp>)`, then
|
|
155
|
-
* `rename(<tmp>, <dest>)`. Two destinations exist, and neither may land:
|
|
156
|
-
* - the route tree — we point it at a throwaway path and hold it in memory, so
|
|
157
|
-
* the only route tree on disk stays the one the host's router plugin writes;
|
|
158
|
-
* - route source files — the Generator normalizes them (`createFileRoute` ids,
|
|
159
|
-
* code-split transforms). The host's generator already did that with its own
|
|
160
|
-
* config; ours is not the host's, so such a write is dropped rather than
|
|
161
|
-
* allowed to fight it.
|
|
162
|
-
*
|
|
163
|
-
* Reads and stats of real files go to disk, which keeps the Generator's mtime
|
|
164
|
-
* cache honest: a route edited mid-watch is always seen.
|
|
165
|
-
*/
|
|
166
|
-
function inMemoryWriteFs(routeTreePath) {
|
|
167
|
-
const written = /* @__PURE__ */ new Map();
|
|
168
|
-
let clock = 0n;
|
|
169
|
-
const tick = () => clock += 1n;
|
|
170
|
-
return {
|
|
171
|
-
/**
|
|
172
|
-
* The in-memory route tree is invisible to the watcher, so nothing else can
|
|
173
|
-
* mark it stale. Bumping its mtime before each run is what makes the
|
|
174
|
-
* Generator rebuild the tree — and therefore re-fire `onRouteTreeChanged`
|
|
175
|
-
* — on every run, not only when the set of routes changes. Coverage and the
|
|
176
|
-
* derived config depend on route *contents* (`staticData` / `head`), which
|
|
177
|
-
* leave the route tree itself untouched.
|
|
178
|
-
*/
|
|
179
|
-
touchRouteTree() {
|
|
180
|
-
const file = written.get(routeTreePath);
|
|
181
|
-
if (file) written.set(routeTreePath, {
|
|
182
|
-
content: file.content,
|
|
183
|
-
mtimeMs: tick()
|
|
184
|
-
});
|
|
185
|
-
},
|
|
186
|
-
fs: {
|
|
187
|
-
async stat(filePath) {
|
|
188
|
-
const file = written.get(filePath);
|
|
189
|
-
if (file) return {
|
|
190
|
-
mtimeMs: file.mtimeMs,
|
|
191
|
-
mode: 33188,
|
|
192
|
-
uid: 0,
|
|
193
|
-
gid: 0
|
|
194
|
-
};
|
|
195
|
-
const real = await stat(filePath, { bigint: true });
|
|
196
|
-
return {
|
|
197
|
-
mtimeMs: real.mtimeMs,
|
|
198
|
-
mode: Number(real.mode),
|
|
199
|
-
uid: Number(real.uid),
|
|
200
|
-
gid: Number(real.gid)
|
|
201
|
-
};
|
|
202
|
-
},
|
|
203
|
-
async readFile(filePath) {
|
|
204
|
-
const file = written.get(filePath);
|
|
205
|
-
if (file) return {
|
|
206
|
-
stat: { mtimeMs: file.mtimeMs },
|
|
207
|
-
fileContent: file.content
|
|
208
|
-
};
|
|
209
|
-
if (!existsSync(filePath)) return "file-not-existing";
|
|
210
|
-
const handle = await open(filePath, "r");
|
|
211
|
-
const fileStat = await handle.stat({ bigint: true });
|
|
212
|
-
const fileContent = (await handle.readFile()).toString();
|
|
213
|
-
await handle.close();
|
|
214
|
-
return {
|
|
215
|
-
stat: { mtimeMs: fileStat.mtimeMs },
|
|
216
|
-
fileContent
|
|
217
|
-
};
|
|
218
|
-
},
|
|
219
|
-
async writeFile(filePath, content) {
|
|
220
|
-
written.set(filePath, {
|
|
221
|
-
content,
|
|
222
|
-
mtimeMs: tick()
|
|
223
|
-
});
|
|
224
|
-
},
|
|
225
|
-
async rename(oldPath, newPath) {
|
|
226
|
-
const file = written.get(oldPath);
|
|
227
|
-
written.delete(oldPath);
|
|
228
|
-
if (file && newPath === routeTreePath) written.set(newPath, {
|
|
229
|
-
content: file.content,
|
|
230
|
-
mtimeMs: tick()
|
|
231
|
-
});
|
|
232
|
-
},
|
|
233
|
-
async chmod() {},
|
|
234
|
-
async chown() {}
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
function resolveOptions(options) {
|
|
239
|
-
return {
|
|
240
|
-
outputPath: options.outputPath,
|
|
241
|
-
publicGroups: options.publicGroups,
|
|
242
|
-
enforceCoverageIn: options.enforceCoverageIn,
|
|
243
|
-
disallowGroups: options.disallowGroups ?? [],
|
|
244
|
-
extraPublicRoutes: options.extraPublicRoutes ?? [],
|
|
245
|
-
reservedExtras: options.reservedExtras ?? [],
|
|
246
|
-
alwaysDisallow: options.alwaysDisallow ?? [],
|
|
247
|
-
routesDirectory: options.routesDirectory ?? "src/routes"
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Vite plugin that runs its own `@tanstack/router-generator` instance over the
|
|
252
|
-
* routes directory and derives the route-config module from the result.
|
|
253
|
-
*/
|
|
254
|
-
function seoRouteConfig(options) {
|
|
255
|
-
const resolved = resolveOptions(options);
|
|
256
|
-
let generator;
|
|
257
|
-
let touchRouteTree;
|
|
258
|
-
let routesDirectory;
|
|
259
|
-
/**
|
|
260
|
-
* A throw here propagates: it fails `vite build` and dev startup, which is
|
|
261
|
-
* the reason we own this call site instead of registering through Start.
|
|
262
|
-
*/
|
|
263
|
-
const run = async (event) => {
|
|
264
|
-
if (generator === void 0 || touchRouteTree === void 0) throw new Error(`[${PLUGIN_NAME}] generator was not initialized by configResolved`);
|
|
265
|
-
touchRouteTree();
|
|
266
|
-
await generator.run(event);
|
|
267
|
-
};
|
|
268
|
-
return {
|
|
269
|
-
name: PLUGIN_NAME,
|
|
270
|
-
enforce: "pre",
|
|
271
|
-
configResolved(config) {
|
|
272
|
-
const root = config.root;
|
|
273
|
-
const cacheDirectory = resolve(root, `node_modules/.cache/${PLUGIN_NAME}`);
|
|
274
|
-
routesDirectory = resolve(root, resolved.routesDirectory);
|
|
275
|
-
const generatorConfig = getConfig({
|
|
276
|
-
routesDirectory,
|
|
277
|
-
generatedRouteTree: resolve(cacheDirectory, "route-tree.gen.ts"),
|
|
278
|
-
tmpDir: resolve(cacheDirectory, "tmp"),
|
|
279
|
-
plugins: [routeConfigGeneratorPlugin(resolved)],
|
|
280
|
-
disableTypes: true,
|
|
281
|
-
enableRouteTreeFormatting: false,
|
|
282
|
-
disableLogging: true
|
|
283
|
-
}, root);
|
|
284
|
-
const memory = inMemoryWriteFs(generatorConfig.generatedRouteTree);
|
|
285
|
-
touchRouteTree = memory.touchRouteTree;
|
|
286
|
-
generator = new Generator({
|
|
287
|
-
config: generatorConfig,
|
|
288
|
-
root,
|
|
289
|
-
fs: memory.fs
|
|
290
|
-
});
|
|
291
|
-
},
|
|
292
|
-
async buildStart() {
|
|
293
|
-
await run();
|
|
294
|
-
},
|
|
295
|
-
async watchChange(id, { event }) {
|
|
296
|
-
const file = normalize(id);
|
|
297
|
-
if (routesDirectory === void 0 || !file.startsWith(routesDirectory)) return;
|
|
298
|
-
await run({
|
|
299
|
-
path: file,
|
|
300
|
-
type: event
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
//#endregion
|
|
1
|
+
import { i as seoRouteConfig } from "./route-config-35ZEzkNC.js";
|
|
306
2
|
export { seoRouteConfig };
|
|
307
|
-
|
|
308
|
-
//# sourceMappingURL=vite.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/core/wire.ts
|
|
2
|
+
function graphToJson(graph) {
|
|
3
|
+
return {
|
|
4
|
+
nodes: [...graph.nodes.values()].map((node) => ({
|
|
5
|
+
...node,
|
|
6
|
+
policy: {
|
|
7
|
+
...node.policy,
|
|
8
|
+
crumb: typeof node.policy.crumb === "function" ? void 0 : node.policy.crumb,
|
|
9
|
+
head: void 0
|
|
10
|
+
}
|
|
11
|
+
})),
|
|
12
|
+
edges: graph.edges,
|
|
13
|
+
collisions: graph.collisions
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function graphFromJson(json) {
|
|
17
|
+
return {
|
|
18
|
+
nodes: new Map(json.nodes.map((node) => [node.path, node])),
|
|
19
|
+
edges: [...json.edges],
|
|
20
|
+
collisions: json.collisions
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { graphToJson as n, graphFromJson as t };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=wire-B4RQMc4e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire-B4RQMc4e.js","names":[],"sources":["../src/core/wire.ts"],"sourcesContent":["/**\n * The graph as JSON, for shipping a build-time graph to a runtime that cannot\n * rebuild it (a Worker serving sitemap.xml). Node order is preserved — the\n * sitemap lists collection instances in collection order — and a function\n * `crumb` (render-time only) is dropped.\n */\n\nimport type { SeoEdge, SeoGraph, SeoNode, SeoSource } from \"./graph\";\n\nexport interface SeoGraphJson {\n readonly nodes: ReadonlyArray<SeoNode>;\n readonly edges: ReadonlyArray<SeoEdge>;\n readonly collisions?: ReadonlyArray<{ readonly path: string; readonly sources: ReadonlyArray<SeoSource> }> | undefined;\n}\n\nexport function graphToJson(graph: SeoGraph): SeoGraphJson {\n return {\n nodes: [...graph.nodes.values()].map((node) => ({\n ...node,\n // `node.head` carries the head as data; the declaration's render-only\n // fields (JSON-LD, Open Graph overrides) stay in the route module.\n policy: {\n ...node.policy,\n crumb: typeof node.policy.crumb === \"function\" ? undefined : node.policy.crumb,\n head: undefined,\n },\n })),\n edges: graph.edges,\n collisions: graph.collisions,\n };\n}\n\nexport function graphFromJson(json: SeoGraphJson): SeoGraph {\n return {\n nodes: new Map(json.nodes.map((node) => [node.path, node])),\n edges: [...json.edges],\n collisions: json.collisions,\n };\n}\n"],"mappings":";AAeA,SAAgB,YAAY,OAA+B;CACzD,OAAO;EACL,OAAO,CAAC,GAAG,MAAM,MAAM,OAAO,CAAC,CAAC,CAAC,KAAK,UAAU;GAC9C,GAAG;GAGH,QAAQ;IACN,GAAG,KAAK;IACR,OAAO,OAAO,KAAK,OAAO,UAAU,aAAa,KAAA,IAAY,KAAK,OAAO;IACzE,MAAM,KAAA;GACR;EACF,EAAE;EACF,OAAO,MAAM;EACb,YAAY,MAAM;CACpB;AACF;AAEA,SAAgB,cAAc,MAA8B;CAC1D,OAAO;EACL,OAAO,IAAI,IAAI,KAAK,MAAM,KAAK,SAAS,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;EAC1D,OAAO,CAAC,GAAG,KAAK,KAAK;EACrB,YAAY,KAAK;CACnB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pagegraph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Route-declared SEO graph, audit, and agentic workflow toolkit for TanStack Start.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"seo",
|
|
@@ -46,17 +46,37 @@
|
|
|
46
46
|
"types": "./dist/react.d.ts",
|
|
47
47
|
"import": "./dist/react.js"
|
|
48
48
|
},
|
|
49
|
+
"./tanstack-start/server": {
|
|
50
|
+
"types": "./dist/tanstack-start/server.d.ts",
|
|
51
|
+
"import": "./dist/tanstack-start/server.js"
|
|
52
|
+
},
|
|
49
53
|
"./vite": {
|
|
50
54
|
"types": "./dist/vite.d.ts",
|
|
55
|
+
"workerd": "./dist/build-only/vite.js",
|
|
56
|
+
"worker": "./dist/build-only/vite.js",
|
|
57
|
+
"browser": "./dist/build-only/vite.js",
|
|
51
58
|
"import": "./dist/vite.js"
|
|
52
59
|
},
|
|
53
60
|
"./config": {
|
|
54
61
|
"types": "./dist/config.d.ts",
|
|
62
|
+
"workerd": "./dist/build-only/config.js",
|
|
63
|
+
"worker": "./dist/build-only/config.js",
|
|
64
|
+
"browser": "./dist/build-only/config.js",
|
|
55
65
|
"import": "./dist/config.js"
|
|
56
66
|
},
|
|
57
67
|
"./audit": {
|
|
58
68
|
"types": "./dist/audit.d.ts",
|
|
69
|
+
"workerd": "./dist/build-only/audit.js",
|
|
70
|
+
"worker": "./dist/build-only/audit.js",
|
|
71
|
+
"browser": "./dist/build-only/audit.js",
|
|
59
72
|
"import": "./dist/audit.js"
|
|
73
|
+
},
|
|
74
|
+
"./tanstack-start": {
|
|
75
|
+
"types": "./dist/tanstack-start/index.d.ts",
|
|
76
|
+
"workerd": "./dist/build-only/tanstack-start.js",
|
|
77
|
+
"worker": "./dist/build-only/tanstack-start.js",
|
|
78
|
+
"browser": "./dist/build-only/tanstack-start.js",
|
|
79
|
+
"import": "./dist/tanstack-start/index.js"
|
|
60
80
|
}
|
|
61
81
|
},
|
|
62
82
|
"publishConfig": {
|
|
@@ -75,19 +95,17 @@
|
|
|
75
95
|
"release:validate": "bun run scripts/validate-release.ts",
|
|
76
96
|
"release": "bun run release:check && bun run tegami publish"
|
|
77
97
|
},
|
|
78
|
-
"dependencies": {
|
|
79
|
-
"@opencode/sdk": "^2.0.11",
|
|
80
|
-
"@tanstack/router-generator": "^1.167.21"
|
|
81
|
-
},
|
|
82
98
|
"devDependencies": {
|
|
83
|
-
"@effect/ai-typesafe": "4.0.0
|
|
84
|
-
"@effect/platform-bun": "4.0.0
|
|
85
|
-
"@effect/platform-node-shared": "4.0.0
|
|
86
|
-
"@effect/vitest": "4.0.0
|
|
99
|
+
"@effect/ai-typesafe": "4.0.0",
|
|
100
|
+
"@effect/platform-bun": "4.0.0",
|
|
101
|
+
"@effect/platform-node-shared": "4.0.0",
|
|
102
|
+
"@effect/vitest": "4.0.0",
|
|
103
|
+
"@opencode/sdk": "2.0.22",
|
|
87
104
|
"@tanstack/react-router": "^1.170.18",
|
|
105
|
+
"@tanstack/router-generator": "^1.167.21",
|
|
88
106
|
"@types/node": "^24.0.0",
|
|
89
107
|
"@types/react": "19.2.18",
|
|
90
|
-
"effect": "4.0.0
|
|
108
|
+
"effect": "4.0.0",
|
|
91
109
|
"lighthouse": "13.4.1",
|
|
92
110
|
"react": "19.2.8",
|
|
93
111
|
"schema-dts": "^2.0.0",
|
|
@@ -98,10 +116,11 @@
|
|
|
98
116
|
"vitest": "^5.0.0"
|
|
99
117
|
},
|
|
100
118
|
"peerDependencies": {
|
|
101
|
-
"@effect/ai-typesafe": "^4.0.0
|
|
102
|
-
"@effect/platform-bun": "^4.0.0
|
|
119
|
+
"@effect/ai-typesafe": "^4.0.0",
|
|
120
|
+
"@effect/platform-bun": "^4.0.0",
|
|
103
121
|
"@tanstack/react-router": "^1.170.0",
|
|
104
|
-
"
|
|
122
|
+
"@tanstack/router-generator": "^1.167.21",
|
|
123
|
+
"effect": "^4.0.0",
|
|
105
124
|
"lighthouse": ">=13.0.0",
|
|
106
125
|
"react": "^19.0.0",
|
|
107
126
|
"vite": "^8.0.0"
|
|
@@ -113,6 +132,9 @@
|
|
|
113
132
|
"@effect/platform-bun": {
|
|
114
133
|
"optional": true
|
|
115
134
|
},
|
|
135
|
+
"@tanstack/router-generator": {
|
|
136
|
+
"optional": true
|
|
137
|
+
},
|
|
116
138
|
"effect": {
|
|
117
139
|
"optional": true
|
|
118
140
|
},
|