@apleasantview/eleventy-plugin-baseline 0.1.0-next.39 → 0.1.0-next.40
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/core/logging.js +31 -0
- package/core/schema.js +33 -0
- package/core/types.js +1 -1
- package/core/wikilinks.js +3 -3
- package/modules/assets/processors/esbuild-process.js +33 -0
- package/modules/assets/processors/postcss-process.js +34 -0
- package/modules/head/drivers/capo-adapter.js +26 -4
- package/modules/head/drivers/posthtml-head-elements.js +1 -1
- package/package.json +1 -1
package/core/logging.js
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
import chalk from 'kleur';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Logger (runtime substrate)
|
|
5
|
+
*
|
|
6
|
+
* Namespaced console logger used across the plugin. One factory, three
|
|
7
|
+
* levels: `info` (verbose-gated), `warn`, `error`. The composition root
|
|
8
|
+
* holds an unscoped logger; modules receive a scoped one through the
|
|
9
|
+
* module context.
|
|
10
|
+
*
|
|
11
|
+
* Architecture layer:
|
|
12
|
+
* runtime substrate
|
|
13
|
+
*
|
|
14
|
+
* System role:
|
|
15
|
+
* Single output surface for plugin diagnostics. Every module writes
|
|
16
|
+
* through it so prefixes, colours, and verbosity behave identically.
|
|
17
|
+
*
|
|
18
|
+
* Lifecycle:
|
|
19
|
+
* build-time → loggers created at plugin init and per-module activation
|
|
20
|
+
*
|
|
21
|
+
* Why this exists:
|
|
22
|
+
* Eleventy gives no opinionated logging primitive. A shared factory
|
|
23
|
+
* keeps every prefix consistent and lets one `verbose` switch silence
|
|
24
|
+
* info-level chatter without affecting warnings or errors.
|
|
25
|
+
*
|
|
26
|
+
* Scope:
|
|
27
|
+
* Owns the prefix format, colour treatment, and verbosity gate. Does
|
|
28
|
+
* not own message content or what each module chooses to log.
|
|
29
|
+
*
|
|
30
|
+
* Data flow:
|
|
31
|
+
* namespace + verbose → logger triple → console
|
|
32
|
+
*/
|
|
33
|
+
|
|
3
34
|
/**
|
|
4
35
|
* @typedef {Object} BaselineLogger
|
|
5
36
|
* @property {(...args: unknown[]) => void} info Verbose-only.
|
package/core/schema.js
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Schemas (runtime substrate)
|
|
5
|
+
*
|
|
6
|
+
* Zod schemas for the two user-facing inputs Baseline validates: the
|
|
7
|
+
* directory `config` export and the `settings` argument. Structural only.
|
|
8
|
+
* Value-level preferences stay permissive.
|
|
9
|
+
*
|
|
10
|
+
* Architecture layer:
|
|
11
|
+
* runtime substrate
|
|
12
|
+
*
|
|
13
|
+
* System role:
|
|
14
|
+
* Validation seam at the public boundary. The composition root parses
|
|
15
|
+
* `settings` non-fatally at init; the directory `config` is checked in
|
|
16
|
+
* the test suite, not at runtime.
|
|
17
|
+
*
|
|
18
|
+
* Lifecycle:
|
|
19
|
+
* build-time → composition root calls `settingsSchema.safeParse(settings)`
|
|
20
|
+
* and logs structural mismatches under `info`
|
|
21
|
+
*
|
|
22
|
+
* Why this exists:
|
|
23
|
+
* Eleventy accepts almost anything users pass through `addPlugin`. A
|
|
24
|
+
* structural gate catches typos and shape drift early without forcing
|
|
25
|
+
* a hard failure on imperfect input.
|
|
26
|
+
*
|
|
27
|
+
* Scope:
|
|
28
|
+
* Owns the structural shape of `settings` and `config`. Does not own
|
|
29
|
+
* defaults, value semantics, or required-field policy; those live in
|
|
30
|
+
* the composition root and individual modules.
|
|
31
|
+
*
|
|
32
|
+
* Data flow:
|
|
33
|
+
* user input → safeParse → issues logged or accepted
|
|
34
|
+
*/
|
|
35
|
+
|
|
3
36
|
export const configSchema = z.object({
|
|
4
37
|
dir: z.object({
|
|
5
38
|
input: z.string().min(1),
|
package/core/types.js
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
* Head module options.
|
|
44
44
|
*
|
|
45
45
|
* @property {{ esbuild?: { minify?: boolean, target?: string } }} [assets]
|
|
46
|
-
* Assets module options. The esbuild slice is permissive
|
|
46
|
+
* Assets module options. The esbuild slice is permissive: any esbuild
|
|
47
47
|
* option is accepted; only `minify` and `target` are typed.
|
|
48
48
|
*/
|
|
49
49
|
|
package/core/wikilinks.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { slugify } from './utils/helpers.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Wikilinks (runtime substrate)
|
|
5
5
|
*
|
|
6
6
|
* MediaWiki-style inline link syntax for body markdown. Recognises
|
|
7
7
|
* [[slug]], [[slug#anchor]], [[slug:lang]], [[slug|alias]], and any
|
|
@@ -24,8 +24,8 @@ import { slugify } from './utils/helpers.js';
|
|
|
24
24
|
* Why this exists:
|
|
25
25
|
* Markdown-it has no wiki-link syntax. Eleventy resolves all
|
|
26
26
|
* eleventyComputed values before any body renders, so the slug index
|
|
27
|
-
* and translation map are complete by the time this rule fires
|
|
28
|
-
*
|
|
27
|
+
* and translation map are complete by the time this rule fires.
|
|
28
|
+
* Resolution is deterministic without a two-pass build.
|
|
29
29
|
*
|
|
30
30
|
* Scope:
|
|
31
31
|
* Owns syntax parsing, slug-to-href resolution, the lang hop, and link
|
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild';
|
|
2
2
|
import { createLogger } from '../../../core/logging.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* esbuild processor (processor)
|
|
6
|
+
*
|
|
7
|
+
* Bundles a single JS entrypoint with esbuild and returns the text. Used
|
|
8
|
+
* both by the `js` template format compile guard and by the
|
|
9
|
+
* `inlineESbuild` filter in the assets module.
|
|
10
|
+
*
|
|
11
|
+
* Architecture layer:
|
|
12
|
+
* module
|
|
13
|
+
*
|
|
14
|
+
* System role:
|
|
15
|
+
* Stateless bundler called by `modules/assets/index.js`. The compile
|
|
16
|
+
* guard decides which files reach this processor; this file owns the
|
|
17
|
+
* esbuild call itself.
|
|
18
|
+
*
|
|
19
|
+
* Lifecycle:
|
|
20
|
+
* build-time → invoked per matching entrypoint during template compile,
|
|
21
|
+
* or per-call from the inline filter
|
|
22
|
+
*
|
|
23
|
+
* Why this exists:
|
|
24
|
+
* Eleventy treats every `.js` file as a template. A dedicated processor
|
|
25
|
+
* keeps esbuild configuration out of the template format wiring and lets
|
|
26
|
+
* the inline filter reuse the same defaults.
|
|
27
|
+
*
|
|
28
|
+
* Scope:
|
|
29
|
+
* Owns esbuild option defaults and the bundle call. Does not own the
|
|
30
|
+
* compile guard, the watch target, or markup wrapping; the assets
|
|
31
|
+
* module owns those.
|
|
32
|
+
*
|
|
33
|
+
* Data flow:
|
|
34
|
+
* entrypoint path + options → esbuild.build → bundled JS text
|
|
35
|
+
*/
|
|
36
|
+
|
|
4
37
|
const log = createLogger('assets-esbuild');
|
|
5
38
|
const defaultOptions = { minify: true, target: 'es2020' };
|
|
6
39
|
|
|
@@ -4,6 +4,40 @@ import loadPostCSSConfig from 'postcss-load-config';
|
|
|
4
4
|
import fallbackPostCSSConfig from '../configs/postcss.config.js';
|
|
5
5
|
import { createLogger } from '../../../core/logging.js';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* PostCSS processor (processor)
|
|
9
|
+
*
|
|
10
|
+
* Processes a single CSS entrypoint through PostCSS and returns the text.
|
|
11
|
+
* Used both by the `css` template format compile guard and by the
|
|
12
|
+
* `inlinePostCSS` filter in the assets module.
|
|
13
|
+
*
|
|
14
|
+
* Architecture layer:
|
|
15
|
+
* module
|
|
16
|
+
*
|
|
17
|
+
* System role:
|
|
18
|
+
* Stateless processor called by `modules/assets/index.js`. Resolves the
|
|
19
|
+
* user's PostCSS config from the project root, falling back to the
|
|
20
|
+
* bundled Baseline config when none is found. Cached for the lifetime
|
|
21
|
+
* of the process.
|
|
22
|
+
*
|
|
23
|
+
* Lifecycle:
|
|
24
|
+
* build-time → invoked per matching entrypoint during template compile,
|
|
25
|
+
* or per-call from the inline filter
|
|
26
|
+
*
|
|
27
|
+
* Why this exists:
|
|
28
|
+
* Eleventy has no PostCSS hook of its own. A dedicated processor lets
|
|
29
|
+
* user configs win when present and keeps the bundled fallback out of
|
|
30
|
+
* the consumer's `node_modules` resolution path.
|
|
31
|
+
*
|
|
32
|
+
* Scope:
|
|
33
|
+
* Owns config resolution, caching, and the PostCSS call. Does not own
|
|
34
|
+
* the compile guard, the watch target, or markup wrapping; the assets
|
|
35
|
+
* module owns those.
|
|
36
|
+
*
|
|
37
|
+
* Data flow:
|
|
38
|
+
* entrypoint path → PostCSS pipeline → processed CSS text
|
|
39
|
+
*/
|
|
40
|
+
|
|
7
41
|
const log = createLogger('assets-postcss');
|
|
8
42
|
|
|
9
43
|
// Resolve user PostCSS config from the project root (cwd), not the Eleventy input dir.
|
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Capo PostHTML adapter (driver)
|
|
3
3
|
*
|
|
4
|
-
* Implements the HTMLAdapter interface capo.js v2
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Implements the `HTMLAdapter` interface capo.js v2 expects, against
|
|
5
|
+
* PostHTML's `{ tag, attrs, content }` node shape. Only `getWeight` is
|
|
6
|
+
* exercised downstream; the rest are shimmed to satisfy the contract.
|
|
7
|
+
*
|
|
8
|
+
* Architecture layer:
|
|
9
|
+
* module
|
|
10
|
+
*
|
|
11
|
+
* System role:
|
|
12
|
+
* Translation shim between the head driver's PostHTML tree and the
|
|
13
|
+
* capo.js sort. Used by `posthtml-head-elements.js` when ordering the
|
|
14
|
+
* composed `<head>` element list.
|
|
15
|
+
*
|
|
16
|
+
* Lifecycle:
|
|
17
|
+
* transform-time → invoked per node while capo.js scores element weights
|
|
18
|
+
*
|
|
19
|
+
* Why this exists:
|
|
20
|
+
* capo.js is DOM-shaped; PostHTML is not. Without an adapter the driver
|
|
21
|
+
* would have to walk the tree twice or hand-roll element weighting.
|
|
22
|
+
*
|
|
23
|
+
* Scope:
|
|
24
|
+
* Owns attribute lookup, tag name resolution, and text extraction over
|
|
25
|
+
* PostHTML nodes. Does not own weighting logic; capo.js owns that.
|
|
26
|
+
*
|
|
27
|
+
* Data flow:
|
|
28
|
+
* PostHTML node → adapter accessor → capo.js getWeight
|
|
7
29
|
*
|
|
8
30
|
* A PostHTML element node looks like `{ tag, attrs, content }` where attrs
|
|
9
31
|
* is either undefined or a plain object. Boolean attributes appear with an
|
|
@@ -10,7 +10,7 @@ import { dedupeMeta, dedupeLink } from '../utils/dedupe.js';
|
|
|
10
10
|
* <baseline-head> placeholder with the result.
|
|
11
11
|
*
|
|
12
12
|
* Architecture layer:
|
|
13
|
-
* module
|
|
13
|
+
* module
|
|
14
14
|
*
|
|
15
15
|
* System role:
|
|
16
16
|
* The seam between head's pipeline and the renderer choice. Alternate
|