@ultimat3/seo 30.8.0 → 31.0.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/CLAUDE.md CHANGED
@@ -152,6 +152,11 @@ Tier 1. May import `@ultimat3/core`, `@ultimat3/schema`, `@ultimat3/i18n`. Nothi
152
152
  `meta-social.test.ts`.
153
153
  - Only `site/` routes are SEO-checked — `app/` is behind auth and crawlers never authenticate.
154
154
 
155
+ - **`./adapter` (`adapter.ts`) is the `images` port** (`ImageTransformDriver`, `TransformRequest`,
156
+ `TransformedImage`, `BuiltinImageDriverOptions`) plus `notImplementedDriver`, the stub a driver
157
+ throws, which is on `./adapter` ONLY (v31); no installer — `@ultimat3/cli` reads `runtime.ts`'s
158
+ `images` where it mounts `/media/*`. The types stay on `.` too.
159
+
155
160
  ## Files
156
161
 
157
162
  | Path | Responsibility |
@@ -169,6 +174,6 @@ Tier 1. May import `@ultimat3/core`, `@ultimat3/schema`, `@ultimat3/i18n`. Nothi
169
174
  ## Commands
170
175
 
171
176
  ```
172
- bun test packages/seo
177
+ bun test ./packages/seo/
173
178
  bun run --filter @ultimat3/seo typecheck
174
179
  ```
package/README.md CHANGED
@@ -61,7 +61,7 @@ a job boundary the class is gone and the `code` is what survives — match on th
61
61
  | `ld.ts` | typed JSON-LD builders; required fields are required in the **input type** |
62
62
  | `sitemap.ts` | `buildSitemap()` from the route table + each route's `prerender()`, per-locale alternates. One urlset at `/sitemap.xml`; past a cap (`SITEMAP_MAX_URLS` 50,000, `SITEMAP_MAX_BYTES` 50 MB) the index stays `/sitemap.xml` and the parts are `/sitemaps/<n>.xml` (`SITEMAP_PARTS_DIR`). With `sections` it is always an index of `/sitemaps/<name>-<n>.xml` — see below |
63
63
  | `sitemap-sections.ts` | `sectionOf(path, sections)`: which named section a page files under (`/blog/**`, `/blog/*`, exact), first match wins, else `pages` |
64
- | `sitemap-datetime.ts` | `sitemapDatetime(value, now)`: a page's `lastmod` as W3C Datetime in UTC, or `undefined` — a zoneless time is not a date here |
64
+ | `sitemap-datetime.ts` | `sitemapDatetime(value, now)`: a page's `lastmod` as W3C Datetime in UTC, or `undefined` — a zoneless time, or a day its month does not have (`2026-02-30`), is not a date here: `@ultimat3/schema`'s `isIsoDateTime`, the feed's rule |
65
65
  | `sitemap-xml.ts` | the `<urlset>` and `<sitemapindex>` XML, and `paginate()` — files that each fit both caps |
66
66
  | `robots.ts` | `buildRobots()`, environment-aware and fail-closed; `disallow` reaches **every** group, and a `User-agent: *` group is emitted for it when none is declared |. `disallowMatcher(rules)` reads those rules as a crawler does — what `buildSitemap({ disallow })` leaves out
67
67
  | `rss.ts` | `buildFeed()` → RSS 2.0 + Atom + JSON Feed from one item list. Channel `author`/`copyright`/`icon` → Atom `<author>`/`<rights>`/`<icon>`; an item `author` → Atom `<author>`, RSS `<author>` when it has an email, `<dc:creator>` when it does not; an item `image` → Atom `<link rel="enclosure">`, RSS `<media:content medium="image">`. Extra RSS namespaces are declared only when used |
@@ -132,6 +132,10 @@ No sitemap line either — advertising one invites the crawl that was just refus
132
132
 
133
133
  ## Image transforms
134
134
 
135
+ A CDN or `sharp`-backed transform implements `ImageTransformDriver` from `@ultimat3/seo/adapter`
136
+ (types only, with `TransformRequest` / `TransformedImage`) and is handed to the boot as
137
+ `images: myDriver()` in `apps/web/runtime.ts`.
138
+
135
139
  `builtinImageDriver({ read })` is the one built-in `ImageTransformDriver`, and it runs
136
140
  `@ultimat3/core`'s pipeline — zero dependencies, no `sharp`, no native binary.
137
141
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/seo",
3
- "version": "30.8.0",
3
+ "version": "31.0.0",
4
4
  "description": "Enforced SEO: typed meta, JSON-LD, sitemap, robots, feeds, responsive images, perf budgets",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -24,7 +24,8 @@
24
24
  "provenance": true
25
25
  },
26
26
  "exports": {
27
- ".": "./src/index.ts"
27
+ ".": "./src/index.ts",
28
+ "./adapter": "./src/adapter.ts"
28
29
  },
29
30
  "files": [
30
31
  "src",
@@ -42,7 +43,7 @@
42
43
  "test": "bun test"
43
44
  },
44
45
  "dependencies": {
45
- "@ultimat3/core": "30.8.0",
46
- "@ultimat3/schema": "30.8.0"
46
+ "@ultimat3/core": "31.0.0",
47
+ "@ultimat3/schema": "31.0.0"
47
48
  }
48
49
  }
package/src/adapter.ts ADDED
@@ -0,0 +1,12 @@
1
+ // `@ultimat3/seo/adapter`: the `images` port (`ADAPTER_PORTS`) as an adapter author needs it —
2
+ // the driver, its request/answer, the built-in's options and the stub error. No installer: the boot
3
+ // READS `runtime.ts`'s `images` at `/media/*` (`@ultimat3/cli`'s `serve-web.ts`);
4
+ // `builtinImageDriver` stays on `.`.
5
+
6
+ export { notImplementedDriver } from './errors';
7
+ export type {
8
+ BuiltinImageDriverOptions,
9
+ ImageTransformDriver,
10
+ TransformedImage,
11
+ TransformRequest,
12
+ } from './image-driver';
package/src/index.ts CHANGED
@@ -2,20 +2,7 @@
2
2
 
3
3
  export type { RenderMode } from '@ultimat3/core';
4
4
  export type { SeoErrorCode, SeoErrorInit } from './errors';
5
- export {
6
- canonicalMismatch,
7
- duplicateMeta,
8
- imageQueryInvalid,
9
- ldInvalid,
10
- linkInvalid,
11
- metaMissing,
12
- metaTooLong,
13
- notImplementedDriver,
14
- SEO_ERROR_CODES,
15
- SeoError,
16
- sitemapEntryInvalid,
17
- sitemapTooLarge,
18
- } from './errors';
5
+ export { ldInvalid, metaMissing, SEO_ERROR_CODES, SeoError, sitemapEntryInvalid } from './errors';
19
6
  export type {
20
7
  BuiltinImageDriverOptions,
21
8
  ImageTransformDriver,
@@ -35,10 +22,8 @@ export {
35
22
  DEFAULT_FORMATS,
36
23
  DEFAULT_WIDTHS,
37
24
  FORMAT_ORDER,
38
- IMAGE_QUERY_KEYS,
39
25
  inlineBlur,
40
26
  MAX_IMAGE_WIDTH,
41
- MIME_TYPES,
42
27
  parseImageQuery,
43
28
  renderPicture,
44
29
  responsiveImage,
@@ -102,7 +87,7 @@ export {
102
87
  } from './meta';
103
88
  export type { RobotsConfig, RobotsGroup } from './robots';
104
89
  export { buildRobots, disallowMatcher, isIndexable } from './robots';
105
- export type { ChangeFreq, RouteRecord, SitemapPage, Surface } from './routes';
90
+ export type { ChangeFreq, RouteRecord, SitemapPage } from './routes';
106
91
  export { expandRoute, expandRoutePages, indexableRoutes, isDynamic } from './routes';
107
92
  export type { BuildFeedOptions, Feed, FeedAuthor, FeedChannel, FeedItem } from './rss';
108
93
  export { buildFeed } from './rss';
@@ -116,7 +101,6 @@ export type {
116
101
  export {
117
102
  buildSitemap,
118
103
  chunk,
119
- SITEMAP_INDEX_MAX_FILES,
120
104
  SITEMAP_MAX_BYTES,
121
105
  SITEMAP_MAX_URLS,
122
106
  SITEMAP_PARTS_DIR,
package/src/llms.ts CHANGED
@@ -33,6 +33,12 @@ const listed = (route: RouteRecord): boolean =>
33
33
  /** One line, so a newline in a title cannot open a second Markdown entry. */
34
34
  const oneLine = (text: string): string => text.replace(/\s+/g, ' ').trim();
35
35
  const linkText = (text: string): string => oneLine(text).replace(/[[\]]/g, '\\$&');
36
+ /** A Markdown destination ends at a space or an unbalanced `)`; these three never arrive encoded. */
37
+ const linkTarget = (url: string): string =>
38
+ url.replace(
39
+ /[ ()]/g,
40
+ (char) => `%${char.charCodeAt(0).toString(16).toUpperCase().padStart(2, '0')}`,
41
+ );
36
42
 
37
43
  /**
38
44
  * `# <home title>`, `> <home description>`, then `- [title](url): description` per listed page,
@@ -50,7 +56,7 @@ export function buildLlmsTxt(routes: readonly RouteRecord[], site: LlmsSite): st
50
56
  if (summary !== undefined) lines.push(`> ${oneLine(summary)}`, '');
51
57
  for (const route of pages) {
52
58
  const description = route.meta?.description;
53
- const link = `- [${linkText(route.meta?.title ?? route.path)}](${absoluteUrl(site.baseUrl, route.path)})`;
59
+ const link = `- [${linkText(route.meta?.title ?? route.path)}](${linkTarget(absoluteUrl(site.baseUrl, route.path))})`;
54
60
  lines.push(description === undefined ? link : `${link}: ${oneLine(description)}`);
55
61
  }
56
62
  return `${lines.join('\n')}\n`;
package/src/robots.ts CHANGED
@@ -100,15 +100,35 @@ export function buildRobots(config: RobotsConfig): string {
100
100
  /**
101
101
  * `rule` as a crawler reads it: a PREFIX of the path, `*` standing for any run of characters and a
102
102
  * trailing `$` anchoring the end. An empty rule disallows nothing.
103
+ *
104
+ * Matched literal by literal, never through a `RegExp`: one `.*` per `*` backtracks, and eleven
105
+ * wildcards against a 41-character slug took 14 s — per URL, inside the sitemap build. With `*`
106
+ * the only operator, the leftmost occurrence of each literal is always a safe choice, so one
107
+ * forward pass of `indexOf` decides it: O(path × rule), whatever the path holds.
103
108
  */
104
- function disallowPattern(rule: string): RegExp | undefined {
109
+ function disallowPattern(rule: string): ((path: string) => boolean) | undefined {
105
110
  if (rule === '') return undefined;
106
111
  const anchored = rule.endsWith('$');
107
- const body = (anchored ? rule.slice(0, -1) : rule)
108
- .split('*')
109
- .map((literal) => literal.replace(/[.+?^${}()|[\]\\]/g, '\\$&'))
110
- .join('.*');
111
- return new RegExp(`^${body}${anchored ? '$' : ''}`);
112
+ const literals = (anchored ? rule.slice(0, -1) : rule).split('*');
113
+ const first = literals[0] ?? '';
114
+ const last = literals[literals.length - 1] ?? '';
115
+ if (literals.length === 1) {
116
+ return anchored ? (path) => path === first : (path) => path.startsWith(first);
117
+ }
118
+ const middle = literals.slice(1, -1);
119
+ return (path) => {
120
+ if (!path.startsWith(first)) return false;
121
+ let at = first.length;
122
+ for (const literal of middle) {
123
+ const found = path.indexOf(literal, at);
124
+ if (found === -1) return false;
125
+ at = found + literal.length;
126
+ }
127
+ // Anchored, the last literal is the path's END — and must not overlap what was already used.
128
+ return anchored
129
+ ? path.length - last.length >= at && path.endsWith(last)
130
+ : path.indexOf(last, at) !== -1;
131
+ };
112
132
  }
113
133
 
114
134
  /**
@@ -118,5 +138,5 @@ function disallowPattern(rule: string): RegExp | undefined {
118
138
  */
119
139
  export function disallowMatcher(rules: readonly string[]): (path: string) => boolean {
120
140
  const patterns = rules.flatMap((rule) => disallowPattern(rule) ?? []);
121
- return (path) => patterns.some((pattern) => pattern.test(path));
141
+ return (path) => patterns.some((matches) => matches(path));
122
142
  }
package/src/routes.ts CHANGED
@@ -2,12 +2,9 @@
2
2
  // `x.manifest.json`; every checker here reports against `file`, so an agent can
3
3
  // open the exact source rather than guess which route a URL came from.
4
4
 
5
- import type { RenderMode } from '@ultimat3/core';
5
+ import type { RenderMode, Surface } from '@ultimat3/core';
6
6
  import type { RouteMeta } from './meta';
7
7
 
8
- /** `site/` is the only surface SEO applies to; `app/` is behind auth. */
9
- export type Surface = 'site' | 'app' | 'api';
10
-
11
8
  export type ChangeFreq = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
12
9
 
13
10
  /**
@@ -34,7 +31,8 @@ export interface RouteRecord {
34
31
  path: string;
35
32
  /** Source file relative to the app root — named verbatim in every error. */
36
33
  file: string;
37
- surface: Surface;
34
+ /** `site/` is the only surface SEO applies to; `app/` is behind auth. `shared/` holds no route. */
35
+ surface: Exclude<Surface, 'shared'>;
38
36
  render: RenderMode;
39
37
  meta?: RouteMeta;
40
38
  /** The route's concrete pages, from `defineRoute({ prerender })` — required for a dynamic one. */
@@ -1,13 +1,7 @@
1
1
  // Single responsibility: one page's `lastmod`, as the W3C Datetime a sitemap writes — or the
2
2
  // answer that it is not a date. No ambient zone is ever read: a time without one is refused.
3
3
 
4
- /**
5
- * ISO 8601 as a sitemap accepts it, with the zone REQUIRED on a time. `Date.parse` alone is not the
6
- * test: it reads `2026-10-01T10:00:00` and `October 1, 2026` in the process's own zone, so one row
7
- * would be two instants on a laptop in Bogotá and in a container on UTC.
8
- */
9
- const ISO_ZONED =
10
- /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2}))?$/;
4
+ import { isIsoDateTime } from '@ultimat3/schema';
11
5
 
12
6
  /** What a refusal quotes back, so the fix names the forms that are accepted. */
13
7
  export const SITEMAP_DATETIME_FORMS =
@@ -16,6 +10,11 @@ export const SITEMAP_DATETIME_FORMS =
16
10
  /**
17
11
  * `value` in UTC (`2026-10-01T15:04:05.000Z`), or `undefined` when it names no instant.
18
12
  *
13
+ * A string is screened by `@ultimat3/schema`'s `isIsoDateTime`, the rule `t.date` and the feed
14
+ * dates answer with: the zone is REQUIRED on a time (`Date.parse` reads a zoneless one in the
15
+ * process's zone, so one row would be two instants), and the day must exist (`Date.parse` rolls
16
+ * `2026-02-30` into March 2nd, a date nobody wrote).
17
+ *
19
18
  * A moment after `now` is CLAMPED to `now`, never refused and never written as it stands. Written,
20
19
  * it is a date a crawler learns to distrust for the whole file. Refused, one row stamped by a
21
20
  * database a second ahead of this process fails the enumeration for every page. Clamped, it says
@@ -25,7 +24,7 @@ export function sitemapDatetime(value: unknown, now: Date): string | undefined {
25
24
  const time =
26
25
  value instanceof Date
27
26
  ? value.getTime()
28
- : typeof value === 'string' && ISO_ZONED.test(value)
27
+ : typeof value === 'string' && isIsoDateTime(value)
29
28
  ? Date.parse(value)
30
29
  : Number.NaN;
31
30
  if (!Number.isFinite(time)) return undefined;