@getvitops/astro 4.1.0 → 5.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/CHANGELOG.md +225 -0
- package/README.md +22 -0
- package/dist/exports/tracking.d.mts +3 -0
- package/dist/exports/tracking.mjs +5 -0
- package/dist/index.d.mts +1 -51
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +77 -36
- package/dist/index.mjs.map +1 -1
- package/dist/routes/conversion.d.mts +6 -3
- package/dist/routes/conversion.d.mts.map +1 -1
- package/dist/routes/conversion.mjs +21 -3
- package/dist/routes/conversion.mjs.map +1 -1
- package/dist/tracking-CmSfxWC3.mjs +47 -0
- package/dist/tracking-CmSfxWC3.mjs.map +1 -0
- package/dist/tracking-DdEKExlE.d.mts +65 -0
- package/dist/tracking-DdEKExlE.d.mts.map +1 -0
- package/package.json +11 -6
- package/src/components/Cards.astro +38 -24
- package/src/components/Subgrid.astro +39 -21
- package/src/components/Tree.astro +2 -2
- package/src/components/TreeNode.astro +1 -1
- package/src/exports/tracking.ts +26 -0
- package/src/scripts/tracking.ts +11 -1
- package/src/tracking.ts +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,230 @@
|
|
|
1
1
|
# @getvitops/astro
|
|
2
2
|
|
|
3
|
+
## 5.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- **Dangling token references are now a build failure.** `validate()` resolves every `var(--…)` a
|
|
8
|
+
config authors — in `patterns.defaults` / `radii` / `groups` / `items.*.{base,overrides,states}`,
|
|
9
|
+
`typography.roles` and `shadows` — against the tokens that config actually emits. A reference to a
|
|
10
|
+
token that does not exist used to validate, generate, minify and ship, then resolve to nothing in
|
|
11
|
+
the browser: one downstream config shipped a `.cta` whose `color` fell back to `inherit` on a brand
|
|
12
|
+
fill (unreadable text on every filled button), and two of its four dead references had been dead for
|
|
13
|
+
several releases with nothing ever reporting them.
|
|
14
|
+
|
|
15
|
+
The check is deliberately anchored to the namespaces the generator owns — `--color-*`, `--shadow-*`,
|
|
16
|
+
`--z-tier-*`, `--surface-glass`, `--overlay` — the same discipline `vitops lint` follows. A pattern
|
|
17
|
+
may legitimately reference a framework token from `@getvitops/core` or a hook of your own, and
|
|
18
|
+
enumerating "every valid token" would make those false positives. A reference carrying a fallback
|
|
19
|
+
(`var(--x, 0.25rem)`) is never flagged: that is you saying what happens when the token is absent.
|
|
20
|
+
Errors name the config path and suggest the nearest token that does exist.
|
|
21
|
+
|
|
22
|
+
Two related diagnostics ship with it:
|
|
23
|
+
- **Pre-1.0 colour-grammar references are reported as one rename table**, not as a dozen separate
|
|
24
|
+
"no such token" errors — the shape the 3.0 flat-config detector uses, applied to the 1.0 colour
|
|
25
|
+
change. It is built from your own role names, and it says to apply the renames _simultaneously_,
|
|
26
|
+
because several of them rotate (`--surface-bg` → `--color-bg-surface-muted`,
|
|
27
|
+
`--surface-bg-bold` → `--color-bg-surface`) and sequential replacement compounds them.
|
|
28
|
+
- **A surface-shaped role declared chromatic now warns.** A bare hue string is shorthand for
|
|
29
|
+
`kind: "chromatic"`, which emits no bare `--color-bg-<role>` and no `.bg-<role>` — so writing
|
|
30
|
+
`"surface": "ink"` silently removed `--color-bg-surface` and the 36 references the framework's own
|
|
31
|
+
CSS makes to it. Relatedly, `--surface-glass`, `--overlay` and `.glass` are no longer emitted when
|
|
32
|
+
`surface` is chromatic: they read `--color-bg-surface`, so emitting them pointed at nothing.
|
|
33
|
+
|
|
34
|
+
**`vitops lint --fix` is now the migration tool.** It reads `var(--…)` out of CSS and `<style>`
|
|
35
|
+
blocks (not just `class` attributes) and rewrites pre-1.0 token references in a **single pass**, so
|
|
36
|
+
the rotating renames cannot compound. Nothing else is rewritten — every other finding it reports is
|
|
37
|
+
a judgement call. Run it after a major bump.
|
|
38
|
+
|
|
39
|
+
**`--help` works on every subcommand.** `vitops lint --help` used to exit non-zero with
|
|
40
|
+
`Unknown option '--help'`; every leaf subcommand parsed its own argv strictly and none declared the
|
|
41
|
+
option. It is now answered before dispatch, so no command can forget it, and a drift guard fails the
|
|
42
|
+
build if a command has no documented options. (`validate`'s options were genuinely undocumented and
|
|
43
|
+
now are.)
|
|
44
|
+
|
|
45
|
+
**The Astro integration reads `site.tracking` and `site.legal.cookieConsent`.** These drive the
|
|
46
|
+
generated cookie notice, while `vitops({ consent, tracking })` drove the runtime — two hand-synced
|
|
47
|
+
declarations of the same fact with nothing comparing them, so a site could ship a notice naming
|
|
48
|
+
categories its banner never offered, or disclosing an `_ac` cookie no capture script ever wrote, and
|
|
49
|
+
the build was clean. The config blocks are now defaults (as `css` / `fonts` / `favicon` / `ads`
|
|
50
|
+
already were) and a genuine contradiction — `true` against `false` on the same fact — **fails the
|
|
51
|
+
build**, naming both sides. An absent option is not a contradiction; it just takes the config's
|
|
52
|
+
value.
|
|
53
|
+
|
|
54
|
+
Also fixed, each from a downstream report:
|
|
55
|
+
- **`@getvitops/astro/tracking`** re-exports `@getvitops/utils/tracking` (plus `TRACKING_ENDPOINT`),
|
|
56
|
+
so the documented conversion flow works with one install. Under strict pnpm app code cannot
|
|
57
|
+
resolve a transitive dependency, and the obvious workaround — importing the same symbols from the
|
|
58
|
+
package index — is the one that drags the integration's Node builtins toward a Worker bundle. This
|
|
59
|
+
entry and `./routes` are both clean.
|
|
60
|
+
- **`createConversionRoute`'s example was broken on every supported Astro.** It read the binding off
|
|
61
|
+
`locals.runtime.env`, removed in Astro v6, while the package peers on `>= 7` — and because the
|
|
62
|
+
throw precedes the response, Astro re-reads the request and reports a misleading "Body has already
|
|
63
|
+
been used". It also called a `toNotifyContext()` helper that does not exist. The example now uses
|
|
64
|
+
`import { env } from 'cloudflare:workers'` and a plain `NotifyContext`.
|
|
65
|
+
- **`/api/track` is exported as `TRACKING_ENDPOINT`**, and the integration warns at build when
|
|
66
|
+
tracking is on and no route answers it. It was a bare literal inside the inlined capture script:
|
|
67
|
+
name the route file anything else and every `tel:` beacon 404s, conversions vanish, and nothing
|
|
68
|
+
errors anywhere.
|
|
69
|
+
- **`describeEvent` no longer reports "from Unknown"** for forms that don't have a field literally
|
|
70
|
+
named `name`. It now falls back through `first_name`/`last_name`, `full_name`, and finally the
|
|
71
|
+
email address.
|
|
72
|
+
- **`sendEmail` takes `timeoutMs` (default 10s).** `binding.send()` had no deadline, so one hung
|
|
73
|
+
attempt hung the request that produced it — indefinitely, in the one module otherwise built on
|
|
74
|
+
always saying why. A timeout is retried, like any other transient failure.
|
|
75
|
+
- **`vitops search notify` warns when the sitemap's URLs aren't on the configured origin.** A 404
|
|
76
|
+
fails loudly; a well-formed sitemap belonging to someone else did not — a route collision served a
|
|
77
|
+
valid document listing another site's pages and the run reported a healthy submission. Surfaces at
|
|
78
|
+
`--dry`.
|
|
79
|
+
- **`require()` warns when the page has no `<wc-consent>`.** The demand can never be granted, so
|
|
80
|
+
whatever waited on it never runs — silently. Hit by rendering `<Tracking />` on pages where
|
|
81
|
+
`<CookieConsent />` wasn't.
|
|
82
|
+
- **`vitops agents` no longer writes a path it guessed.** It used to warn and then write "tokens
|
|
83
|
+
live in `design-system.json`" into a project whose tokens are in `company.json`, with the four
|
|
84
|
+
emitted `vitops generate` commands hard-coded to match — copy-paste-broken in exactly the projects
|
|
85
|
+
that most need the block to be right. It now finds the config by shape, interpolates the resolved
|
|
86
|
+
path into every emitted command, and fails rather than guessing when there is nothing to name.
|
|
87
|
+
- **`vitops search setup --dry` and `vitops ads setup --dry` run without credentials.** A dry run
|
|
88
|
+
that mutates nothing should not demand the token to mutate; with none set it plans from scratch
|
|
89
|
+
and says so. (`--check` still needs them — drift is a comparison against live state.) Both now
|
|
90
|
+
also mention that the Cloudflare token needs `Zone:Read` alongside `Zone:DNS:Edit` — the
|
|
91
|
+
zone-by-name lookup uses it, and its absence read as "the zone isn't in this account".
|
|
92
|
+
- **`vitops legal` names the files it wrote and flags new ones.** Enabling `cookieConsent` silently
|
|
93
|
+
produced a `cookie-notice` document that then needs a page, a route, a link and a `policyUrl`; the
|
|
94
|
+
command said only "3 files". The review reminder is also printed on the stdout path, where it was
|
|
95
|
+
missing entirely.
|
|
96
|
+
- **`vitops init` writes a versioned `$schema`** — `./node_modules/@getvitops/generator/schema.json`,
|
|
97
|
+
following wrangler — instead of an unpinned unpkg URL that resolved to whatever was newest, so an
|
|
98
|
+
editor validated a pinned project against a schema it wasn't built with.
|
|
99
|
+
- **`favicon.backgroundColor` and `favicon.name` are described accurately.** `backgroundColor` is
|
|
100
|
+
not manifest-only: it fills the opaque `apple-touch-icon.png` and `icon-mask.png`, which are
|
|
101
|
+
written whether or not a manifest is. `name` documents that it and `themeColor` **together** are
|
|
102
|
+
what make a site installable. The missing-background warning now also fires for a dark opaque mark,
|
|
103
|
+
not only a transparent source — `apple-touch-icon` insets the logo and fills the surround either
|
|
104
|
+
way.
|
|
105
|
+
|
|
106
|
+
- **The framework now says out loud which patterns are foundational, and reports it when you
|
|
107
|
+
reach past them.** From repeated downstream reports: sites were inventing a `.wrap` class and
|
|
108
|
+
using it everywhere instead of `.centered`, and `.subgrid` — the class for any set of cards —
|
|
109
|
+
was going essentially unused. Neither failure is visible in a build: every class involved is
|
|
110
|
+
real, nothing errors, and the page renders.
|
|
111
|
+
|
|
112
|
+
**`.subgrid` was missing from the generated class reference entirely.** So was `.cluster`, and
|
|
113
|
+
so was `.region`. `vitops docs classes` is the doc an agent is told to fetch for "which class
|
|
114
|
+
do I apply", and the framework's answer for a set of cards was not in it — which is most of why
|
|
115
|
+
it never got used. All three are now documented, along with `grid-auto`, and the reference opens
|
|
116
|
+
with a **Foundations** section that states the six substitutions as
|
|
117
|
+
_temptation → what to write instead_ rather than as a vocabulary list. The same table is now in
|
|
118
|
+
the shipped agent skill and in the `@getvitops/create` template's `AGENTS.md`, because a pointer
|
|
119
|
+
to a doc only helps someone who already suspects there is something to look up. (`css`/`bricks`
|
|
120
|
+
and `tailwind` alike — this is documentation and the `TIERS` manifest, not emitted CSS.)
|
|
121
|
+
|
|
122
|
+
**`vitops lint` gained three reuse rules and a markup pass.** The existing `.centered` rule only
|
|
123
|
+
fired when the hand-written CSS already referenced `--width-measure`, which is precisely the
|
|
124
|
+
author who was never going to hand-roll a container. It now also catches a page-scale
|
|
125
|
+
`max-width` (≥ 48rem, or a `ch` reading measure) with auto margins, and a
|
|
126
|
+
container-shaped class name — `wrap`, `wrapper`, `container`, `inner`, `shell`, … — carrying any
|
|
127
|
+
width cap at all. Reading the cap out of `min()` / `clamp()` too. New rules report a
|
|
128
|
+
hand-written `repeat()` grid as `.subgrid` (or `.grid-auto`), and a new **markup** pass reports a
|
|
129
|
+
repeated card set laid out without either — a loop that renders a card, or three or more cards
|
|
130
|
+
written out. That last one is the only check that can see this drift at all, since a card list
|
|
131
|
+
built from utility classes contains no bad class and no hand-written CSS.
|
|
132
|
+
|
|
133
|
+
All of these are `suggestion` severity, so they do not fail your build unless you pass
|
|
134
|
+
`--strict`. They found five real instances in this repo's own docs site.
|
|
135
|
+
|
|
136
|
+
**`vitops lint [files...]`** now takes explicit paths instead of scanning `--src`, so it can be
|
|
137
|
+
wired into a pre-commit hook — `vp`'s `staged` key appends the staged files to whatever it runs,
|
|
138
|
+
and a command that refused positionals could not be put in the one place the feedback lands at
|
|
139
|
+
the moment the code is written. Unreadable and non-source paths are skipped rather than fatal. The
|
|
140
|
+
`@getvitops/create` emdash template wires it up with `--strict` and adds a `lint:design` script.
|
|
141
|
+
|
|
142
|
+
**Two answers for "the whole card is a link", because one cannot exist.** Reported downstream:
|
|
143
|
+
agents dislike the `<li>` wrapper when a card is a link and write `<li><a class="card">` instead.
|
|
144
|
+
That shape is **wrong in a way that renders fine**, which is why it survives review — the `<li>`
|
|
145
|
+
is the grid item, so the anchor is an ordinary block inside it and the tranches within the anchor
|
|
146
|
+
never reach the parent's shared row lines. The alignment `.subgrid` exists for silently does not
|
|
147
|
+
happen, and the anchor does not fill the cell either. Putting the anchor in the grid's place
|
|
148
|
+
(`<ul><a></ul>`) is invalid HTML, so there was genuinely no correct shape to reach for.
|
|
149
|
+
|
|
150
|
+
There are now two, and they trade against each other because **no CSS-only technique can make a
|
|
151
|
+
whole card clickable and leave its text selectable** — a transparent overlay necessarily receives
|
|
152
|
+
the pointer-drag:
|
|
153
|
+
|
|
154
|
+
| Want | Use |
|
|
155
|
+
| ---------------------------------------- | ------------------------------------------- |
|
|
156
|
+
| zero JS, whole card clickable | `.stretched-link` — **text not selectable** |
|
|
157
|
+
| selectable text **and** a clickable card | `<Cards>` / `<wc-cards>` — needs JS |
|
|
158
|
+
|
|
159
|
+
`.stretched-link` goes on a link inside the card; its `::after` covers the card.
|
|
160
|
+
**`<wc-cards>` is a new tier-2 element** that adds no overlay and instead tells a click apart from
|
|
161
|
+
the end of a drag, so text selection survives. Its fallback is the card's own link, fully usable
|
|
162
|
+
with no JS, and the pointer cursor is applied by the element — so the affordance never appears
|
|
163
|
+
without the behaviour. `<Cards>` emits it for you. They are alternatives, never layered: with an
|
|
164
|
+
overlay present the JS has nothing to do, and `vitops lint` reports the combination. (All formats
|
|
165
|
+
— pattern partials, deliberately not `utilities.css`, which the tailwind format skips on the
|
|
166
|
+
invariant that everything left in it is a name Tailwind ships itself.)
|
|
167
|
+
|
|
168
|
+
### Breaking
|
|
169
|
+
- **`<Subgrid />` renders its slot verbatim — author the `<li>` items yourself.**
|
|
170
|
+
|
|
171
|
+
```diff
|
|
172
|
+
<Subgrid>
|
|
173
|
+
- <article class="card">…</article>
|
|
174
|
+
+ <li class="card subgrid-card">…</li>
|
|
175
|
+
</Subgrid>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
It used to parse the slotted HTML and rebuild each child as an `<li>`, carrying over only
|
|
179
|
+
`class` and `style`. That existed solely because a `<ul>` may contain nothing else, and it cost
|
|
180
|
+
more than it bought: the child's tag was discarded, `id`/`data-*`/`aria-*` were silently
|
|
181
|
+
dropped, and `href` could not survive at all. Nothing is copied now, so nothing is lost. `as`
|
|
182
|
+
picks the container (`ul` by default, `ol`, `div`), and all other props are forwarded — they
|
|
183
|
+
were previously discarded, including `role`.
|
|
184
|
+
|
|
185
|
+
- **`<Subgrid />` and `<Tree />` now emit `role="list"`,** as does the Bricks `sitenav` element.
|
|
186
|
+
`list-style: none` stops Safari + VoiceOver announcing a `<ul>` as a list, so every marker-less
|
|
187
|
+
framework list was silently losing the semantics its `<ul>` was chosen for. If you hand-write
|
|
188
|
+
`.subgrid`, `.list`, `.facet-list`, `.nav-items`, `.collapse-menu` or `.tree` markup, add
|
|
189
|
+
`role="list"` yourself — the framework cannot add it to markup it does not render, and each
|
|
190
|
+
partial now says so at the `list-style` reset.
|
|
191
|
+
- **`<Cards />` no longer adds `class="card"` to slotted children,** because it no longer parses
|
|
192
|
+
them. Write the class on the item. It now emits `<wc-cards>` around a `<Subgrid>`, which is what
|
|
193
|
+
makes the whole card clickable — and like `<Tree />`, **it emits its own element, so do not wrap
|
|
194
|
+
it in `<wc-cards>` yourself.** It also previously passed a `role="list"` that `<Subgrid>` silently
|
|
195
|
+
discarded, so that never took effect.
|
|
196
|
+
- **`.subgrid-card` now sets `position: relative`**, so `stretched-link` inside it needs no extra
|
|
197
|
+
class. If you were absolutely positioning a descendant of a `.subgrid-card` against an ancestor
|
|
198
|
+
_outside_ that card, it will now resolve against the card. Move the positioning context
|
|
199
|
+
explicitly. (`css`/`bricks`/`tailwind` — the pattern partial is inlined into all three.) Not
|
|
200
|
+
reachable by `vitops lint --fix`: the fix depends on which ancestor you meant, which the
|
|
201
|
+
linter cannot know.
|
|
202
|
+
|
|
203
|
+
### Fixed
|
|
204
|
+
- **`packages/generator/src/docs.ts` contained a literal NUL byte** (`CODE_SLOT`, written as the
|
|
205
|
+
raw character rather than an escape). libmagic classified the file as `data` rather than text, so
|
|
206
|
+
grep and ripgrep treated the largest doc emitter in the repo as **binary and silently skipped
|
|
207
|
+
it** — every search for a string in it returned nothing, with no error. It is now written as the `\u0000` escape.
|
|
208
|
+
Behaviour is identical; the file is searchable.
|
|
209
|
+
- **`.grid-auto` is documented.** It was a real framework class for auto-fit card grids with no
|
|
210
|
+
entry in the class reference, so the honest alternative to `subgrid` was as invisible as
|
|
211
|
+
`subgrid` itself.
|
|
212
|
+
- **`.raised` replaces the advice to use `.relative` above a `stretched-link` overlay**, which
|
|
213
|
+
could not work: a positioned element at `z-index: auto` does not rise above an explicit
|
|
214
|
+
`z-index` regardless of DOM order, so a second link or button in the card stayed underneath and
|
|
215
|
+
unclickable. `.raised` sets both, against the same `--z-tier-raised` token the overlay now uses
|
|
216
|
+
instead of a hard-coded `1`.
|
|
217
|
+
|
|
218
|
+
### Patch Changes
|
|
219
|
+
|
|
220
|
+
- Updated dependencies
|
|
221
|
+
- Updated dependencies
|
|
222
|
+
- Updated dependencies
|
|
223
|
+
- @getvitops/generator@5.0.0
|
|
224
|
+
- @getvitops/utils@5.0.0
|
|
225
|
+
- @getvitops/core@5.0.0
|
|
226
|
+
- @getvitops/vite@5.0.0
|
|
227
|
+
|
|
3
228
|
## 4.1.0
|
|
4
229
|
|
|
5
230
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -45,6 +45,28 @@ import Head from '@getvitops/astro/Head.astro';
|
|
|
45
45
|
priority. It does **not** emit a stylesheet `<link>` — the integration imports the generated CSS into
|
|
46
46
|
Astro's module graph and Astro emits that link itself.
|
|
47
47
|
|
|
48
|
+
## Rendering mode
|
|
49
|
+
|
|
50
|
+
**Prefer `output: 'static'`** (Astro's default). Nothing this integration produces needs a server:
|
|
51
|
+
the CSS, favicons and web-component bundles are all build-time artifacts, and the components
|
|
52
|
+
progressively enhance markup that is already complete in the HTML. A static build also gives the
|
|
53
|
+
sitemap every route, since `@astrojs/sitemap` lists prerendered routes only.
|
|
54
|
+
|
|
55
|
+
Opt individual routes out with `export const prerender = false` where a page genuinely needs
|
|
56
|
+
per-request work — a form `POST` handler, an auth-gated page, per-visitor content. That needs an
|
|
57
|
+
adapter, but leaves the rest of the site static.
|
|
58
|
+
|
|
59
|
+
```astro
|
|
60
|
+
---
|
|
61
|
+
// src/pages/account.astro — server-rendered; every other page stays static
|
|
62
|
+
export const prerender = false;
|
|
63
|
+
---
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**EmDash sites invert this**, because the CMS admin and API need a server: they run
|
|
67
|
+
`output: 'server'` and opt _into_ prerendering per route. See
|
|
68
|
+
[`@getvitops/emdash`](../emdash/README.md#rendering-mode).
|
|
69
|
+
|
|
48
70
|
## Options
|
|
49
71
|
|
|
50
72
|
| option | default | does |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { i as TRACKING_COOKIE, n as ResolveTrackingContext, o as TrackingCategory, r as ResolvedTracking, s as resolveTracking, t as GetvitopsTrackingOptions } from "./tracking-DdEKExlE.mjs";
|
|
1
2
|
import { LegalOutput, SiteFont, StylesheetFormat } from "@getvitops/generator";
|
|
2
3
|
import { generateIconInclude } from "@getvitops/utils";
|
|
3
4
|
import { AdProvider } from "@getvitops/utils/ads";
|
|
@@ -342,57 +343,6 @@ interface SeoContext {
|
|
|
342
343
|
*/
|
|
343
344
|
declare function resolveSeo(defaults: GetvitopsSeoOptions, props: SeoProps, ctx: SeoContext): ResolvedSeo;
|
|
344
345
|
//#endregion
|
|
345
|
-
//#region src/tracking.d.ts
|
|
346
|
-
/**
|
|
347
|
-
* The `<Tracking />` resolution layer — tracking config in, what to emit out.
|
|
348
|
-
*
|
|
349
|
-
* Separate from `Tracking.astro` for the same reason `analytics.ts` is separate
|
|
350
|
-
* from `Analytics.astro`: everything decidable is a pure function asserted in
|
|
351
|
-
* `tracking.test.ts`, and the component only renders what this returns.
|
|
352
|
-
*
|
|
353
|
-
* The one decision here is **which consent category the `_ac` cookie waits on**,
|
|
354
|
-
* and it is stated rather than inferred. `_ac` is a 90-day identifier tying a
|
|
355
|
-
* visitor to the ad that brought them, so `marketing` is the default — but a site
|
|
356
|
-
* using click IDs purely for its own campaign reporting may reasonably file it
|
|
357
|
-
* under `analytics`, and that is the consumer's call to make, not ours to guess.
|
|
358
|
-
*/
|
|
359
|
-
/** Which consent category the attribution cookie waits on. */
|
|
360
|
-
type TrackingCategory = 'marketing' | 'analytics';
|
|
361
|
-
interface GetvitopsTrackingOptions {
|
|
362
|
-
/** Capture ad click IDs and UTMs into `_ac`. */
|
|
363
|
-
enabled?: boolean;
|
|
364
|
-
/** Default `marketing`. */
|
|
365
|
-
category?: TrackingCategory;
|
|
366
|
-
/** Informational; capture recognises every known click-ID parameter regardless. */
|
|
367
|
-
platforms?: string[];
|
|
368
|
-
}
|
|
369
|
-
/** The cookie the capture script writes. Mirrors `TRACKING_COOKIE` in utils. */
|
|
370
|
-
declare const TRACKING_COOKIE = "_ac";
|
|
371
|
-
interface ResolvedTracking {
|
|
372
|
-
enabled: boolean;
|
|
373
|
-
category: TrackingCategory;
|
|
374
|
-
/** Cookie names to clear on revoke — rides on `data-consent-cookies`. */
|
|
375
|
-
cookies: string[];
|
|
376
|
-
/** Configuration problems, as prose. The integration logs these. */
|
|
377
|
-
warnings: string[];
|
|
378
|
-
}
|
|
379
|
-
interface ResolveTrackingContext {
|
|
380
|
-
/** Is the consent gate enabled on this site (`vitops({ consent })`)? */
|
|
381
|
-
consent?: boolean;
|
|
382
|
-
/** Categories the banner offers, so we can catch a demand with no row. */
|
|
383
|
-
consentCategories?: readonly string[];
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Resolve the tracking config into what the component emits.
|
|
387
|
-
*
|
|
388
|
-
* Two warnings, both about the same failure — a persistent identifier written
|
|
389
|
-
* with no way for the visitor to decline, or a permission asked for with no way
|
|
390
|
-
* to answer. Returned as data rather than logged here so the check is a test
|
|
391
|
-
* rather than a line someone might scroll past, exactly as `resolveAnalytics`
|
|
392
|
-
* does.
|
|
393
|
-
*/
|
|
394
|
-
declare function resolveTracking(opts: GetvitopsTrackingOptions | undefined, ctx?: ResolveTrackingContext): ResolvedTracking;
|
|
395
|
-
//#endregion
|
|
396
346
|
//#region src/integration.d.ts
|
|
397
347
|
interface GetvitopsFaviconOptions {
|
|
398
348
|
/** Source SVG or PNG. */
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/analytics.ts","../src/seo.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/analytics.ts","../src/seo.ts","../src/integration.ts","../src/ads.ts","../src/lastmod.ts"],"mappings":";;;;;;;;;;;;;;;;;;;AA2BA;;;;AAA6B;AAQ7B;;;;AAA2B;AAE3B;;;;AAA6D;AAE7D;KAZY,iBAAA;;;;;;;KAQA,eAAA;AAAA,KAEA,uBAAA,GAA0B,OAAO,CAAC,eAAA;AAAA,UAE7B,sBAAA;EAYA;EAVf,EAAA;;;;;EAKA,QAAA,GAAW,uBAAA;EAQuB;EANlC,MAAA,GAAS,MAAM;AAAA;AAAA,UAGA,cAAA;;EAEf,EAAA;EACA,QAAA,GAAW,uBAAuB;AAAA;AAAA,UAGnB,aAAA;EAaR;EAXP,GAAA;EAce;EAZf,MAAA;;;AAgBG;AAGL;;;;;EAVE,OAAA;AAAA;AAAA,UAGe,gBAAA;EAaa;EAX5B,MAAA;EAMA;EAJA,GAAG;AAAA;AAAA,UAGY,yBAAA;EACf,eAAA,YAA2B,sBAAA;EAC3B,OAAA,YAAmB,cAAA;EACnB,MAAA,GAAS,aAAA;EACT,SAAA,YAAqB,gBAAA;EAErB;EAAA,QAAA,GAAW,iBAAA;AAAA;AAAiB;AAW9B;;;;;;;AAX8B,UAWb,uBAAA;EAON;AAkBX;;;EApBE,UAAA,GAAa,uBAAuB;EA2B1B;EAzBV,SAAA;AAAA;;;;;;;;;;;;;;;AAmCa;UAjBE,QAAA;EAqBY;EAnB3B,QAAA;EACA,QAAA,EAAU,eAAA;EACV,WAAA;EAqBe;EAnBf,OAAA;EACA,QAAA,EAAU,iBAAA;EAmBO;;;;;EAbjB,KAAA;EAiBQ;EAfR,MAAA;EACA,GAAA;EACA,KAAA,EAAO,MAAA;AAAA;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EHe2B;EGb3B,OAAA;EHeS;EGbT,QAAA,GAAW,iBAAiB;AAAA;;iBAYd,UAAA,CACd,GAAA,EAAK,mBAAA,cACL,GAAA,GAAK,iBAAA,GACJ,WAAA;;;UC9Cc,iBAAA;;EAEf,IAAA;;EAEA,GAAA;;EAEA,MAAA,IAAU,OAAA;AAAA;;AJlBZ;;;;AAA6B;AAQ7B;iBIoBgB,aAAA,CAAc,IAAY;;iBAa1B,eAAA,CAAgB,IAAY;AJjCjB;AAE3B;;;;AAA6D;AAE7D;;AAJ2B,iBIqFL,UAAA,CACpB,OAAA,GAAS,iBAAA,GACR,OAAA,EAAS,IAAA,EAAM,qBAAA,KAA0B,qBAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as TRACKING_ENDPOINT, r as resolveTracking, t as TRACKING_COOKIE } from "./tracking-CmSfxWC3.mjs";
|
|
1
2
|
import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { dirname, join, relative, resolve } from "node:path";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -325,39 +326,6 @@ function resolveFonts(decls) {
|
|
|
325
326
|
};
|
|
326
327
|
}
|
|
327
328
|
|
|
328
|
-
//#endregion
|
|
329
|
-
//#region src/tracking.ts
|
|
330
|
-
/** The cookie the capture script writes. Mirrors `TRACKING_COOKIE` in utils. */
|
|
331
|
-
const TRACKING_COOKIE = "_ac";
|
|
332
|
-
/**
|
|
333
|
-
* Resolve the tracking config into what the component emits.
|
|
334
|
-
*
|
|
335
|
-
* Two warnings, both about the same failure — a persistent identifier written
|
|
336
|
-
* with no way for the visitor to decline, or a permission asked for with no way
|
|
337
|
-
* to answer. Returned as data rather than logged here so the check is a test
|
|
338
|
-
* rather than a line someone might scroll past, exactly as `resolveAnalytics`
|
|
339
|
-
* does.
|
|
340
|
-
*/
|
|
341
|
-
function resolveTracking(opts, ctx = {}) {
|
|
342
|
-
const warnings = [];
|
|
343
|
-
const category = opts?.category ?? "marketing";
|
|
344
|
-
const enabled = opts?.enabled === true;
|
|
345
|
-
if (!enabled) return {
|
|
346
|
-
enabled: false,
|
|
347
|
-
category,
|
|
348
|
-
cookies: [],
|
|
349
|
-
warnings
|
|
350
|
-
};
|
|
351
|
-
if (!ctx.consent) warnings.push(`tracking is on, so this site writes the \`${"_ac"}\` cookie — a 90-day identifier tying a visitor to the ad that brought them — and \`consent\` is off, so it is written for every visitor with no way to decline. Set \`consent: true\`.`);
|
|
352
|
-
else if (ctx.consentCategories && !ctx.consentCategories.includes(category)) warnings.push(`tracking demands the \`${category}\` consent category, but the banner offers ${ctx.consentCategories.join(", ") || "nothing"}. Add \`${category}\` to \`consent.categories\`, or the visitor is asked about something the banner never names.`);
|
|
353
|
-
return {
|
|
354
|
-
enabled,
|
|
355
|
-
category,
|
|
356
|
-
cookies: ["_ac"],
|
|
357
|
-
warnings
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
|
|
361
329
|
//#endregion
|
|
362
330
|
//#region src/integration.ts
|
|
363
331
|
/**
|
|
@@ -426,6 +394,73 @@ function readSiteAds(configPath, siteEnv) {
|
|
|
426
394
|
return null;
|
|
427
395
|
}
|
|
428
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* The consent + tracking facts a site config already states.
|
|
399
|
+
*
|
|
400
|
+
* These were the one pair the integration did not read. `site.tracking` and
|
|
401
|
+
* `site.legal.cookieConsent` drive the **generated cookie notice**, while
|
|
402
|
+
* `vitops({ consent, tracking })` drove the **runtime** — two hand-synced
|
|
403
|
+
* declarations of the same fact with nothing checking them against each other.
|
|
404
|
+
* The failure that produces is precisely the one the rest of the toolchain is
|
|
405
|
+
* fastidious about avoiding: a site can ship a cookie notice naming categories
|
|
406
|
+
* its banner never offers, or promising attribution that no capture script
|
|
407
|
+
* implements, and the build is clean. That is a compliance defect, not a
|
|
408
|
+
* documentation gap.
|
|
409
|
+
*
|
|
410
|
+
* Read as DEFAULTS, the same as `css` / `fonts` / `favicon` / `ads` — the
|
|
411
|
+
* config is where a site's facts live, and an integration option is how you
|
|
412
|
+
* override one. A genuine contradiction is an error rather than a warning; see
|
|
413
|
+
* `consentTrackingConflicts`.
|
|
414
|
+
*/
|
|
415
|
+
function readSiteConsentTracking(configPath, siteEnv) {
|
|
416
|
+
try {
|
|
417
|
+
const cfg = resolveConfig(JSON.parse(readFileSync(configPath, "utf8")), siteEnv);
|
|
418
|
+
const t = cfg.site.tracking;
|
|
419
|
+
const cc = cfg.site.legal?.cookieConsent;
|
|
420
|
+
if (!t && !cc) return null;
|
|
421
|
+
return {
|
|
422
|
+
...t ? { tracking: t } : {},
|
|
423
|
+
...cc ? { consentEnabled: cc.enabled } : {},
|
|
424
|
+
...cc?.categories ? { categories: cc.categories } : {}
|
|
425
|
+
};
|
|
426
|
+
} catch {
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Contradictions between the config and an explicit integration option.
|
|
432
|
+
*
|
|
433
|
+
* Absent-vs-present is a default and resolves silently. `true` vs `false` on the
|
|
434
|
+
* same fact is not resolvable — one of the two documents is wrong, and picking
|
|
435
|
+
* either quietly is how a notice and a banner get out of step. The message names
|
|
436
|
+
* both sides so the fix does not require guessing which one won.
|
|
437
|
+
*/
|
|
438
|
+
function consentTrackingConflicts(site, opts, configPath) {
|
|
439
|
+
const out = [];
|
|
440
|
+
const optConsent = opts.consent === void 0 ? void 0 : !!opts.consent;
|
|
441
|
+
if (site.consentEnabled !== void 0 && optConsent !== void 0 && site.consentEnabled !== optConsent) out.push(`consent: ${configPath} sets site.legal.cookieConsent.enabled: ${site.consentEnabled}, but vitops({ consent: ${optConsent} }) says the opposite. The generated cookie notice follows the config and the banner follows the option, so one of them would describe a site that does not exist. Set them the same, or drop the option and let the config decide.`);
|
|
442
|
+
const optTracking = opts.tracking === void 0 ? void 0 : opts.tracking === true ? true : opts.tracking === false ? false : opts.tracking.enabled ?? true;
|
|
443
|
+
if (site.tracking?.enabled !== void 0 && optTracking !== void 0 && site.tracking.enabled !== optTracking) out.push(`tracking: ${configPath} sets site.tracking.enabled: ${site.tracking.enabled}, but vitops({ tracking: ${optTracking} }) says the opposite. The cookie notice discloses \`_ac\` from the config while the capture script ships from the option — so the site would either disclose a cookie it never sets, or set one it never discloses.`);
|
|
444
|
+
return out;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Does a route answer `TRACKING_ENDPOINT`?
|
|
448
|
+
*
|
|
449
|
+
* Checked by filename rather than through Astro's route manifest, because this
|
|
450
|
+
* runs in `astro:config:setup` — before routes are collected. The extension set
|
|
451
|
+
* covers the ways a consumer can author the same endpoint; a false negative
|
|
452
|
+
* costs a warning, a false positive costs the whole point of the check, so this
|
|
453
|
+
* errs toward looking in more places.
|
|
454
|
+
*/
|
|
455
|
+
function hasConversionRoute(root) {
|
|
456
|
+
const base = resolve(root, "src/pages", TRACKING_ENDPOINT.replace(/^\//, ""));
|
|
457
|
+
return [
|
|
458
|
+
".ts",
|
|
459
|
+
".js",
|
|
460
|
+
".mjs",
|
|
461
|
+
".astro"
|
|
462
|
+
].some((ext) => existsSync(`${base}${ext}`) || existsSync(join(base, `index${ext}`)));
|
|
463
|
+
}
|
|
429
464
|
const VIRTUAL_ID = "virtual:getvitops/head";
|
|
430
465
|
const RESOLVED_ID = `\0${VIRTUAL_ID}`;
|
|
431
466
|
function virtualHeadPlugin(data) {
|
|
@@ -516,10 +551,15 @@ function vitops(opts = {}) {
|
|
|
516
551
|
if (!config.site) logger.warn("seo: needs the `site` astro.config option (your deployed URL) — without it <Seo /> omits canonical, og:url and any relative og:image rather than guessing an origin.");
|
|
517
552
|
if (config.integrations.some((i) => i.name === "emdash")) logger.warn("seo: emdash() is registered, and its <EmDashHead> emits the same title/description/canonical/og tags from the CMS. Use one or the other — rendering both duplicates every tag.");
|
|
518
553
|
}
|
|
519
|
-
const
|
|
520
|
-
|
|
554
|
+
const siteConsent = siteInput ? readSiteConsentTracking(resolve(root, siteInput), opts.site?.siteEnv ?? "production") : null;
|
|
555
|
+
if (siteConsent) {
|
|
556
|
+
const conflicts = consentTrackingConflicts(siteConsent, opts, siteInput);
|
|
557
|
+
if (conflicts.length) throw new Error(`vitops: the site config and the integration options disagree about consent.\n\n` + conflicts.map((c) => ` • ${c}`).join("\n\n"));
|
|
558
|
+
}
|
|
559
|
+
const consentEnabled = opts.consent !== void 0 ? !!opts.consent : !!siteConsent?.consentEnabled;
|
|
560
|
+
const consentOpts = typeof opts.consent === "object" ? opts.consent : siteConsent?.categories ? { categories: siteConsent.categories } : {};
|
|
521
561
|
const analytics = resolveAnalytics(opts.analytics, { consent: consentEnabled });
|
|
522
|
-
const trackingOpts = opts.tracking === true ? { enabled: true } : opts.tracking || void 0;
|
|
562
|
+
const trackingOpts = opts.tracking === true ? { enabled: true } : opts.tracking || (siteConsent?.tracking?.enabled ? siteConsent.tracking : void 0);
|
|
523
563
|
const adsConfig = siteInput ? readSiteAds(resolve(root, siteInput), opts.site?.siteEnv ?? "production") : null;
|
|
524
564
|
const detectedCategories = consentCategories([...analytics.tags, ...resolveAds(adsConfig?.properties, {
|
|
525
565
|
consent: consentEnabled,
|
|
@@ -535,6 +575,7 @@ function vitops(opts = {}) {
|
|
|
535
575
|
consentCategories: offeredCategories
|
|
536
576
|
});
|
|
537
577
|
for (const warning of tracking.warnings) logger.warn(warning);
|
|
578
|
+
if (tracking.enabled && !hasConversionRoute(root)) logger.warn(`tracking is on, so the capture script beacons \`tel:\` conversions to ${TRACKING_ENDPOINT}, but no route answers that path. Add \`src/pages/api/track.ts\` exporting \`createConversionRoute(...)\` from \`@getvitops/astro/routes\` — otherwise every call conversion is silently lost.`);
|
|
538
579
|
const ads = resolveAds(adsConfig?.properties, {
|
|
539
580
|
consent: consentEnabled,
|
|
540
581
|
consentCategories: offeredCategories,
|