@rathnasgala2/template 2.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.
Files changed (43) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +515 -0
  3. package/contracts/render-policy.jcs +1 -0
  4. package/contracts/theme-styling-contract.jcs +1 -0
  5. package/package.json +96 -0
  6. package/src/core/errors.js +136 -0
  7. package/src/core/index.js +758 -0
  8. package/src/core/internal/appearance/bootstrap-script.js +159 -0
  9. package/src/core/internal/appearance/contract.js +193 -0
  10. package/src/core/internal/appearance/controller-markup.js +80 -0
  11. package/src/core/internal/appearance/styling-contract.js +509 -0
  12. package/src/core/internal/canonical-jcs.js +0 -0
  13. package/src/core/internal/content-security.js +0 -0
  14. package/src/core/internal/eleventy-render.js +220 -0
  15. package/src/core/internal/feeds.js +161 -0
  16. package/src/core/internal/fs-walk.js +38 -0
  17. package/src/core/internal/media/avif-probe.js +169 -0
  18. package/src/core/internal/media/font-policy.js +56 -0
  19. package/src/core/internal/media/jpeg-codec.js +0 -0
  20. package/src/core/internal/media/limits.js +129 -0
  21. package/src/core/internal/media/pipeline.js +353 -0
  22. package/src/core/internal/media/png-codec.js +406 -0
  23. package/src/core/internal/media/resize.js +147 -0
  24. package/src/core/internal/media/sniff.js +109 -0
  25. package/src/core/internal/media/webp-probe.js +139 -0
  26. package/src/core/internal/messages.js +78 -0
  27. package/src/core/internal/page-kinds.js +709 -0
  28. package/src/core/internal/provenance.js +49 -0
  29. package/src/core/internal/render-policy-content.js +295 -0
  30. package/src/core/internal/route-labels.js +68 -0
  31. package/src/core/internal/route.js +167 -0
  32. package/src/core/internal/search-index.js +119 -0
  33. package/src/core/internal/seo.js +114 -0
  34. package/src/core/internal/sitemap.js +77 -0
  35. package/src/core/internal/skeleton.js +413 -0
  36. package/src/core/internal/source-inventory.js +145 -0
  37. package/src/core/internal/text-direction.js +59 -0
  38. package/src/core/internal/theme-assets.js +387 -0
  39. package/src/core/internal/uuid.js +51 -0
  40. package/src/core/manifest.js +0 -0
  41. package/types/eleventy-plugin-syntaxhighlight.d.ts +26 -0
  42. package/types/eleventy.d.ts +38 -0
  43. package/types/index.d.ts +347 -0
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Typed failure modes for the renderer adapter. Every rejection the adapter
3
+ * raises before or during rendering is one of these two classes, never a
4
+ * bare `Error`, so a caller (eventually `publish-kernel`) can distinguish
5
+ * "the supplied build input is not schema-valid" from "the caller's own
6
+ * adapter options are incomplete or unsafe" without string-matching a
7
+ * message (brief S2 section 3: "fails closed on invalid input").
8
+ */
9
+
10
+ /**
11
+ * The supplied `build-input:2.0.0` candidate failed schema validation and
12
+ * was never rendered. `diagnostics` is the exact
13
+ * `validateGalaDocument` result from `@rathnasgala2/schemas`.
14
+ */
15
+ export class BuildInputValidationError extends Error {
16
+ /**
17
+ * @param {readonly Record<string, unknown>[]} diagnostics
18
+ * the schema validator's diagnostics for the rejected instance
19
+ */
20
+ constructor(diagnostics) {
21
+ super(
22
+ `build-input:2.0.0 failed schema validation (${diagnostics.length} diagnostic(s))`,
23
+ );
24
+ this.name = 'BuildInputValidationError';
25
+ /** @type {readonly Record<string, unknown>[]} */
26
+ this.diagnostics = diagnostics;
27
+ }
28
+ }
29
+
30
+ /**
31
+ * The caller's adapter options (directories, provenance pass-through facts)
32
+ * were missing, malformed, or violated the adapter's filesystem-confinement
33
+ * contract. Rendering never started.
34
+ */
35
+ export class RenderOptionsError extends Error {
36
+ /**
37
+ * @param {string} message what was wrong with the supplied options
38
+ */
39
+ constructor(message) {
40
+ super(message);
41
+ this.name = 'RenderOptionsError';
42
+ }
43
+ }
44
+
45
+ /**
46
+ * The media pipeline (S2-T05) rejected an image or font reference: an
47
+ * unrecognized or malformed format, a decompression or resource ceiling
48
+ * crossing, an unconditionally-rejected SVG image input, a font that is not
49
+ * bounded WOFF2, or a source file whose bytes do not match its declared
50
+ * `build-input` digest. Every one of these fails closed — before any
51
+ * derivative is written and before rendering completes — never as a warning
52
+ * or silent fallback (brief S2 section 3: "Reject decompression or resource
53
+ * excess"; "SVG is never processed as author media").
54
+ */
55
+ export class MediaPipelineError extends Error {
56
+ /**
57
+ * @param {string} reasonCode a stable, machine-checkable reason code (for
58
+ * example `MEDIA_SVG_REJECTED`, `MEDIA_RESOURCE_EXCEEDED`,
59
+ * `MEDIA_FORMAT_INVALID`, `MEDIA_SOURCE_DIGEST_MISMATCH`,
60
+ * `MEDIA_FONT_FORMAT_INVALID`)
61
+ * @param {string} message a human-readable description
62
+ * @param {string} referencePath the repository-relative source path this
63
+ * rejection concerns
64
+ */
65
+ constructor(reasonCode, message, referencePath) {
66
+ super(`${reasonCode}: ${message} (${referencePath})`);
67
+ this.name = 'MediaPipelineError';
68
+ /** @type {string} */
69
+ this.reasonCode = reasonCode;
70
+ /** @type {string} */
71
+ this.referencePath = referencePath;
72
+ }
73
+ }
74
+
75
+ /**
76
+ * The output-security pipeline rejected something before it could reach
77
+ * rendered output: a `renderableBody.renderPolicy` reference that does not
78
+ * byte-equal the published render-policy identity, a non-empty module or
79
+ * placement value, or sanitized output that still matched a forbidden
80
+ * pattern (an adapter defect, never expected of admitted content). Rendering
81
+ * never completes for the affected build (brief S2 section 3: "fail-closed
82
+ * behaviour on any content the policy rejects").
83
+ */
84
+ export class RenderPolicyViolationError extends Error {
85
+ /**
86
+ * @param {string} message what the render policy rejected
87
+ */
88
+ constructor(message) {
89
+ super(message);
90
+ this.name = 'RenderPolicyViolationError';
91
+ }
92
+ }
93
+
94
+ /**
95
+ * The selected theme package's `theme.json` (or its declared file set) did
96
+ * not conform to the closed shape `internal/theme-assets.js` needs to copy
97
+ * its stylesheets/passive assets and render its `<link>` elements: an
98
+ * invalid `stylesheets` list shape, a `cssLayers` projection that does not
99
+ * byte-equal the corresponding ordered layer names, or a missing declared
100
+ * file (task packet S2-T12).
101
+ */
102
+ export class ThemeAssetError extends Error {
103
+ /**
104
+ * @param {string} reasonCode a stable, machine-checkable reason code (for
105
+ * example `THEME_STYLESHEETS_INVALID`, `THEME_CSS_LAYERS_INVALID`)
106
+ * @param {string} message a human-readable description
107
+ */
108
+ constructor(reasonCode, message) {
109
+ super(`${reasonCode}: ${message}`);
110
+ this.name = 'ThemeAssetError';
111
+ /** @type {string} */
112
+ this.reasonCode = reasonCode;
113
+ }
114
+ }
115
+
116
+ /**
117
+ * The assembled `artifact-manifest:2.0.0` candidate failed schema
118
+ * validation. This indicates an adapter defect (every field it emits should
119
+ * be schema-valid by construction), so it is reported distinctly from the
120
+ * two caller-facing errors above.
121
+ */
122
+ export class ArtifactManifestValidationError extends Error {
123
+ /**
124
+ * @param {readonly Record<string, unknown>[]} diagnostics
125
+ * the schema validator's diagnostics for the rejected instance
126
+ */
127
+ constructor(diagnostics) {
128
+ super(
129
+ `artifact-manifest:2.0.0 produced by the renderer failed schema validation ` +
130
+ `(${diagnostics.length} diagnostic(s)); this is an adapter defect`,
131
+ );
132
+ this.name = 'ArtifactManifestValidationError';
133
+ /** @type {readonly Record<string, unknown>[]} */
134
+ this.diagnostics = diagnostics;
135
+ }
136
+ }