snappy-prerender 2.6.0 → 2.8.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/README.md +281 -101
  3. package/assets/snappy-logo.png +0 -0
  4. package/docs/limitations.md +94 -0
  5. package/docs/react-snap-migration.md +45 -0
  6. package/docs/report.md +135 -0
  7. package/package.json +4 -1
  8. package/src/cli-init.js +205 -0
  9. package/src/cli-options.js +258 -0
  10. package/src/cli.js +128 -309
  11. package/src/core/artifacts.js +2 -0
  12. package/src/core/audit/index.js +114 -0
  13. package/src/core/audit/links.js +74 -0
  14. package/src/core/audit/metadata.js +197 -0
  15. package/src/core/audit/sitemap.js +39 -0
  16. package/src/core/clock.js +60 -0
  17. package/src/core/config-validation.js +557 -0
  18. package/src/core/config-warnings.js +150 -0
  19. package/src/core/config.js +189 -136
  20. package/src/core/crawl.js +362 -0
  21. package/src/core/csp.js +138 -0
  22. package/src/core/destination.js +23 -7
  23. package/src/core/frameworks.js +94 -0
  24. package/src/core/hydration-diff.js +93 -0
  25. package/src/core/hydration-policy.js +38 -0
  26. package/src/core/init.js +143 -30
  27. package/src/core/inline-css.js +52 -9
  28. package/src/core/locale-context.js +63 -0
  29. package/src/core/locales.js +385 -0
  30. package/src/core/normalize.js +37 -6
  31. package/src/core/page-content.js +57 -7
  32. package/src/core/page-meta.js +122 -0
  33. package/src/core/preload-links.js +133 -0
  34. package/src/core/preload-manifest.js +6 -2
  35. package/src/core/render.js +126 -35
  36. package/src/core/report.js +116 -0
  37. package/src/core/resources.js +5 -1
  38. package/src/core/route-config.js +17 -0
  39. package/src/core/route-sources.js +220 -0
  40. package/src/core/run.js +156 -131
  41. package/src/core/seo-locale.js +234 -0
  42. package/src/core/settle.js +2 -4
  43. package/src/core/sitemap.js +90 -14
  44. package/src/core/text-separators.js +11 -7
  45. package/src/core/verify.js +164 -71
  46. package/src/core/write.js +314 -52
  47. package/src/head/index.js +104 -6
  48. package/src/head/manager.js +304 -48
  49. package/src/head/tags.js +349 -30
package/CHANGELOG.md CHANGED
@@ -6,6 +6,106 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
6
6
  uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Earlier history predates
7
7
  the release tags; see the Git history for those changes.
8
8
 
9
+ ## [2.8.0] - 2026-10-31
10
+
11
+ ### Added
12
+
13
+ - `freezeTime`, `timezone` and `randomSeed` make `Date`/`Date.now()` and optional
14
+ `Math.random()` deterministic across render and verification. `SOURCE_DATE_EPOCH` is
15
+ honoured, and pages can read `window.__SNAPPY_NOW__` / `window.__SNAPPY_NOW_ISO__`.
16
+ - `hydration.allowRerender` and `hydration.skip`, plus `routeOverrides[].hydration`, let
17
+ explicitly dynamic routes re-render without being reported as failures.
18
+ - `locales` adds path or single locale modes with automatic `<html lang>`, canonical,
19
+ `og:locale`, `og:locale:alternate`, self/alternate/`x-default` hreflang, sitemap
20
+ alternates, translated route maps and hreflang audit rules.
21
+ - `seoLocale` seeds a cookie or `localStorage` locale before render and verification, and
22
+ optionally writes a pre-app bootstrap into the output. It supports localStorage, cookie
23
+ or both, `overwrite`, `navigator`, `forceHtmlLang`, route scoping, CSP hash and strict
24
+ externalization.
25
+ - CLI flags for the clock, hydration policies, simple locale matrices and SEO locale.
26
+ - Report fields for the fixed clock, locale counts, per-route locale, hydration policy,
27
+ allowed re-renders, ignored hydration errors and generated locale scripts.
28
+ - `Head` accepts `tags` for arbitrary `script`, `style`, `noscript` and `base` elements,
29
+ with attribute objects, text, trusted `noscript` HTML and explicit keys.
30
+ - `Head` accepts `htmlAttributes`, `bodyAttributes` and `titleAttributes`, restoring the
31
+ document's original attributes when no Head wants them.
32
+ - `Head` accepts `defaultTitle`, multiple `images` and multiple `alternateLocales`; repeated
33
+ same-name `extra` metas can opt into duplicates. These replace the client-side surface of
34
+ React Helmet and React Helmet Async.
35
+ - `Head` accepts `onChangeClientState` for observing added, removed and changed entries
36
+ after real DOM updates.
37
+ - React 19 native `<meta>` and `<link>` tags are adopted and updated instead of
38
+ duplicated. A correct native `<title>` is left to React so navigation can remove it, while
39
+ older template titles are removed.
40
+ - The head entry documents `HeadProps`, `HeadTag`, `HeadAttributes` and `HeadChange` with
41
+ JSDoc types; the package remains plain JavaScript and adds no TypeScript files.
42
+
43
+ ### Changed
44
+
45
+ - Final HTML processing uses one parsed document for preload injection, CSP hashes,
46
+ page metadata and preload resources instead of reparsing after each step.
47
+ - Render and verification use fewer Playwright round trips.
48
+ - Route writes, audit link checks, destination copies and sitemap-index fetches run with
49
+ bounded concurrency; route reports are merged in deterministic order.
50
+ - Preload hints are sorted, so repeated builds do not reorder modulepreload links.
51
+ - Inline stylesheet text and critical CSS processor state are cached within a run.
52
+ - Relative route-source loading and browser/server startup overlap where safe.
53
+ - The JSON report includes phase timings, and `npm run benchmark` measures large sites.
54
+ - `reuseVerificationContext` optionally reuses one browser context per verification worker.
55
+ - A not-found page's generated noindex replaces an existing robots directive instead of
56
+ adding a second meta tag.
57
+
58
+ ## [2.7.0] - 2026-10-29
59
+
60
+ ### Added
61
+
62
+ - Site audit for route health, links, metadata, sitemap and CSP. Findings are report-only
63
+ unless `failOnAuditError` is set; `auditIgnoreLinks` excludes dynamic links.
64
+ - `reportPath` / `--report` writes a versioned JSON report with per-route records, audit,
65
+ verification, sitemap, preload manifest, truncation and traces.
66
+ - `routesFile` and `routesFromSitemap` seed routes from text, JSON or a sitemap. Sitemap
67
+ indexes are followed one level, and relative paths resolve against the config file.
68
+ - Deterministic BFS crawling when `maxRoutes` or `routePriority` is set.
69
+ `truncated.droppedRoutes` lists the routes that did not fit.
70
+ - `routeOverrides` for per-route timeout, wait, readiness, crawl and storage state.
71
+ - `transformHtml`, sync or async, runs before preload and CSP injection.
72
+ - Framework detection for React, Vue, Svelte and Preact, with framework-specific hydration
73
+ messages and `firstMismatch` details.
74
+ - `preloadLinks` for runtime chunks, fonts and the LCP image.
75
+ - Sitemap hreflang alternates, image entries and `sitemap.locs` in the report.
76
+ - Head JSON-LD, `lang`/`dir` and hreflang alternates.
77
+ - App-declared 404 pages via `<meta name="prerender-status-code" content="404">`.
78
+ - `csp: 'hash'` adds a meta policy with SHA-256 hashes for inline scripts and styles.
79
+ - `retries`, `retryDelay` and `traceOnError` for failed renders.
80
+ - `init` migration for a legacy `reactSnap` block.
81
+ - CLI flags and documentation for the new options.
82
+
83
+ ### Changed
84
+
85
+ - Verification reports the detected framework and uses its hydration message patterns.
86
+ - SVG `<title>` elements are no longer counted as page titles.
87
+ - Page metadata, audit findings and sitemap entries use the final HTML after transform and
88
+ preload injection.
89
+ - Route sources resolve relative paths against the config file. Sitemap base and origin
90
+ handling is stricter.
91
+ - The JSON report includes the verification summary, uses crawl acceptance order for
92
+ `order`, and redacts credentials, query strings and the storage-state path.
93
+
94
+ ### Fixed
95
+
96
+ - A configured `notFoundRoute` may return HTTP 404 and is still written as `404.html`;
97
+ verification accepts that status for the same route.
98
+ - An explicit `framework` selects its hydration message patterns during verification.
99
+ - A non-string `transformHtml` result fails that route with a clear error.
100
+ - `routeOverrides` ignores undefined values instead of clearing base settings.
101
+ - `audit.linksChecked` counts every link pair considered, and route-health findings are
102
+ included in the audit.
103
+ - `preloadLinks` does not preload scripts removed by `removeScriptTags` or `transformHtml`.
104
+ - CSP hash mode warns when the generated policy blocks a browser request.
105
+ - `init` normalises a single-string `reactSnap.include`.
106
+ - The image sitemap collects `srcset` and `<picture><source>` candidates.
107
+ - New no-op option combinations produce configuration warnings.
108
+
9
109
  ## [2.6.0] - 2026-10-27
10
110
 
11
111
  ### Added