@interactive-inc/emdash-plugins 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +203 -2
- package/dist/builder/admin/get-editor-page-id.d.ts +3 -0
- package/dist/builder/admin/get-editor-page-id.d.ts.map +1 -0
- package/dist/builder/admin/get-editor-page-id.js +8 -0
- package/dist/builder/admin/get-editor-page-id.js.map +1 -0
- package/dist/builder/admin/get-page-preview.d.ts +7 -0
- package/dist/builder/admin/get-page-preview.d.ts.map +1 -0
- package/dist/builder/admin/get-page-preview.js +27 -0
- package/dist/builder/admin/get-page-preview.js.map +1 -0
- package/dist/builder/astro.d.ts +5 -0
- package/dist/builder/astro.d.ts.map +1 -0
- package/dist/builder/astro.js +56 -0
- package/dist/builder/astro.js.map +1 -0
- package/dist/builder/catalog.d.ts +1232 -0
- package/dist/builder/catalog.d.ts.map +1 -0
- package/dist/builder/catalog.js +111 -0
- package/dist/builder/catalog.js.map +1 -0
- package/dist/builder/constants.d.ts +5 -0
- package/dist/builder/constants.d.ts.map +1 -0
- package/dist/builder/constants.js +5 -0
- package/dist/builder/constants.js.map +1 -0
- package/dist/builder/document.d.ts +74 -0
- package/dist/builder/document.d.ts.map +1 -0
- package/dist/builder/document.js +172 -0
- package/dist/builder/document.js.map +1 -0
- package/dist/builder/extensions.d.ts +32 -0
- package/dist/builder/extensions.d.ts.map +1 -0
- package/dist/builder/extensions.js +30 -0
- package/dist/builder/extensions.js.map +1 -0
- package/dist/builder/list-limits.d.ts +7 -0
- package/dist/builder/list-limits.d.ts.map +1 -0
- package/dist/builder/list-limits.js +8 -0
- package/dist/builder/list-limits.js.map +1 -0
- package/dist/builder/middleware.d.ts +3 -0
- package/dist/builder/middleware.d.ts.map +1 -0
- package/dist/builder/middleware.js +25 -0
- package/dist/builder/middleware.js.map +1 -0
- package/dist/builder/motion-directive.d.ts +14 -0
- package/dist/builder/motion-directive.d.ts.map +1 -0
- package/dist/builder/motion-directive.js +14 -0
- package/dist/builder/motion-directive.js.map +1 -0
- package/dist/builder/motion-tokens.d.ts +114 -0
- package/dist/builder/motion-tokens.d.ts.map +1 -0
- package/dist/builder/motion-tokens.js +25 -0
- package/dist/builder/motion-tokens.js.map +1 -0
- package/dist/builder/options.d.ts +14 -0
- package/dist/builder/options.d.ts.map +1 -0
- package/dist/builder/options.js +20 -0
- package/dist/builder/options.js.map +1 -0
- package/dist/builder/plugin.d.ts +6 -0
- package/dist/builder/plugin.d.ts.map +1 -0
- package/dist/builder/plugin.js +15 -0
- package/dist/builder/plugin.js.map +1 -0
- package/dist/builder/portable-text.d.ts +9 -0
- package/dist/builder/portable-text.d.ts.map +1 -0
- package/dist/builder/portable-text.js +58 -0
- package/dist/builder/portable-text.js.map +1 -0
- package/dist/builder/resolve-page.d.ts +28 -0
- package/dist/builder/resolve-page.d.ts.map +1 -0
- package/dist/builder/resolve-page.js +99 -0
- package/dist/builder/resolve-page.js.map +1 -0
- package/dist/builder/runtime.d.ts +4 -0
- package/dist/builder/runtime.d.ts.map +1 -0
- package/dist/builder/runtime.js +99 -0
- package/dist/builder/runtime.js.map +1 -0
- package/dist/builder/safe-url.d.ts +3 -0
- package/dist/builder/safe-url.d.ts.map +1 -0
- package/dist/builder/safe-url.js +21 -0
- package/dist/builder/safe-url.js.map +1 -0
- package/dist/builder/server/load-page.d.ts +18 -0
- package/dist/builder/server/load-page.d.ts.map +1 -0
- package/dist/builder/server/load-page.js +37 -0
- package/dist/builder/server/load-page.js.map +1 -0
- package/dist/builder/server/page-response.d.ts +10 -0
- package/dist/builder/server/page-response.d.ts.map +1 -0
- package/dist/builder/server/page-response.js +12 -0
- package/dist/builder/server/page-response.js.map +1 -0
- package/package.json +95 -3
- package/src/builder/PageDocument.astro +27 -0
- package/src/builder/PageShell.astro +15 -0
- package/src/builder/StaticPageShell.astro +11 -0
- package/src/builder/admin/get-editor-page-id.ts +8 -0
- package/src/builder/admin/get-page-preview.ts +28 -0
- package/src/builder/admin/managed-page-field.tsx +4 -0
- package/src/builder/admin/page-preview-field.tsx +53 -0
- package/src/builder/admin/page-preview-frame.tsx +67 -0
- package/src/builder/admin.tsx +5 -0
- package/src/builder/astro.ts +53 -0
- package/src/builder/catalog.ts +117 -0
- package/src/builder/constants.ts +4 -0
- package/src/builder/document.ts +137 -0
- package/src/builder/extensions.ts +46 -0
- package/src/builder/island.tsx +8 -0
- package/src/builder/list-limits.ts +10 -0
- package/src/builder/middleware.ts +22 -0
- package/src/builder/motion-directive.ts +19 -0
- package/src/builder/motion-site.tsx +15 -0
- package/src/builder/motion-tokens.ts +40 -0
- package/src/builder/options.ts +20 -0
- package/src/builder/pages/[...slug].astro +11 -0
- package/src/builder/pages/preview/[id].astro +14 -0
- package/src/builder/plugin.ts +17 -0
- package/src/builder/portable-content.tsx +17 -0
- package/src/builder/portable-text.ts +63 -0
- package/src/builder/renderer.tsx +16 -0
- package/src/builder/resolve-page.ts +90 -0
- package/src/builder/reveal.tsx +321 -0
- package/src/builder/runtime.ts +92 -0
- package/src/builder/safe-url.ts +13 -0
- package/src/builder/server/load-page.ts +45 -0
- package/src/builder/server/page-response.ts +15 -0
- package/src/builder/site-view.tsx +60 -0
- package/src/builder/styles/site.css +1 -0
- package/src/builder/virtual.d.ts +13 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { Component, createContext, createElement, useContext, useLayoutEffect, useMemo, useRef, useState, type FocusEvent, type ReactNode } from 'react';
|
|
2
|
+
import { m, type Variants } from 'motion/react';
|
|
3
|
+
import { motionTokens, type MotionTag, type ResolvedMotion, type RootProps } from './motion-tokens.ts';
|
|
4
|
+
|
|
5
|
+
type Outcomes = { entered: () => void; passed: () => void };
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Any visible pixel counts, a bare edge does not: content folded into a collapsed accordion touches its edge with
|
|
9
|
+
* no area, which IntersectionObserver may report as intersecting. The tiny threshold reports the first real pixel.
|
|
10
|
+
* An element without area has no pixel to wait for: it counts wherever it touches, so content overflowing it shows.
|
|
11
|
+
*/
|
|
12
|
+
const visible = { threshold: Number.EPSILON };
|
|
13
|
+
/** Everything above the viewport: 10^7px taller than any page, yet within every engine's layout range. */
|
|
14
|
+
const aboveViewport = '10000000px 0px -100% 0px';
|
|
15
|
+
/** Everything above the viewport, the viewport, and one more viewport below it. */
|
|
16
|
+
const nearViewport = '10000000px 0px 100% 0px';
|
|
17
|
+
/** Milliseconds between checks whether something may carry a waiting element. */
|
|
18
|
+
const carryingCheck = 250;
|
|
19
|
+
|
|
20
|
+
/** While the page loads, WebKit holds an observer's first report until a rendering update, for up to 2s: request one. */
|
|
21
|
+
function firstReport() {
|
|
22
|
+
requestAnimationFrame(() => {});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The element's ancestors as the browser renders them: through the slot it is assigned to, and out of shadow roots.
|
|
27
|
+
* A closed shadow root keeps its slots to itself, so content assigned to one continues at the host.
|
|
28
|
+
*/
|
|
29
|
+
function* ancestors(element: Element): Generator<Element> {
|
|
30
|
+
let node: Element | null = element;
|
|
31
|
+
// Only a shadow root has a host: the document above <html> exposes any element named "host" under that name.
|
|
32
|
+
while ((node = node.assignedSlot ?? node.parentElement ?? (node.parentNode instanceof ShadowRoot ? node.parentNode.host : null))) yield node;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function overflow(node: Element): string {
|
|
36
|
+
const { overflowX, overflowY } = getComputedStyle(node);
|
|
37
|
+
return `${overflowX} ${overflowY}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Whether moving the node's content could change what it scrolls or where it snaps: it scrolls (overflow auto or
|
|
41
|
+
* scroll, whether or not it overflows yet), or it clips and snaps (a carousel moved by buttons).
|
|
42
|
+
*/
|
|
43
|
+
function scrollContainer(node: Element): boolean {
|
|
44
|
+
const clips = overflow(node);
|
|
45
|
+
return /auto|scroll/.test(clips) || (/hidden/.test(clips) && getComputedStyle(node).scrollSnapType !== 'none');
|
|
46
|
+
}
|
|
47
|
+
/** Whether the visitor can scroll the node: its content overflows it on an axis whose overflow is auto or scroll. */
|
|
48
|
+
function scrollable(node: Element): boolean {
|
|
49
|
+
const { overflowX, overflowY } = getComputedStyle(node);
|
|
50
|
+
return (/auto|scroll/.test(overflowX) && node.scrollWidth > node.clientWidth)
|
|
51
|
+
|| (/auto|scroll/.test(overflowY) && node.scrollHeight > node.clientHeight);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Whether scrolling the page moves the element. Content in a fixed box (a drawer, say) stays where it is. */
|
|
55
|
+
function scrollsWithPage(element: Element): boolean {
|
|
56
|
+
return [element, ...ancestors(element)].every(node => getComputedStyle(node).position !== 'fixed');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Whether a container inside .site scrolls the element, so that moving it would change what that container scrolls. */
|
|
60
|
+
function insideScroller(element: Element): boolean {
|
|
61
|
+
for (const node of ancestors(element)) {
|
|
62
|
+
if (node.classList.contains('site')) return false;
|
|
63
|
+
if (scrollContainer(node)) return true;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The outermost container the visitor can scroll around the element, if any. The viewport scrolls in place of <html>,
|
|
70
|
+
* and of <body> unless <html> has overflow of its own (body{overflow-x:hidden} still scrolls the viewport).
|
|
71
|
+
*/
|
|
72
|
+
function outermostScroller(element: Element): Element | undefined {
|
|
73
|
+
const { documentElement: html, body } = element.ownerDocument;
|
|
74
|
+
let outermost: Element | undefined;
|
|
75
|
+
for (const node of ancestors(element)) {
|
|
76
|
+
if (node === html || (node === body && !/hidden|clip|auto|scroll/.test(overflow(html)))) break;
|
|
77
|
+
if (scrollable(node)) outermost = node;
|
|
78
|
+
}
|
|
79
|
+
return outermost;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Coordinates the moving elements of one island. Only used in the browser after hydration. */
|
|
83
|
+
export class MotionStage {
|
|
84
|
+
#groups = new Map<string, { count: number; open: boolean }>();
|
|
85
|
+
#waiting = new Map<Element, Outcomes>();
|
|
86
|
+
#view: IntersectionObserver | undefined;
|
|
87
|
+
#above: IntersectionObserver | undefined;
|
|
88
|
+
#near: IntersectionObserver | undefined;
|
|
89
|
+
#locating = new Map<Element, Set<(near: boolean) => void>>();
|
|
90
|
+
#places = new WeakMap<Element, string>();
|
|
91
|
+
#carrying = 0;
|
|
92
|
+
/** Position among the children of one stagger group that enter the viewport in the same frame. */
|
|
93
|
+
order(group: string): number {
|
|
94
|
+
let entry = this.#groups.get(group);
|
|
95
|
+
if (!entry) this.#groups.set(group, entry = { count: 0, open: false });
|
|
96
|
+
if (!entry.open) {
|
|
97
|
+
const current = entry;
|
|
98
|
+
current.open = true;
|
|
99
|
+
requestAnimationFrame(() => { current.open = false; current.count = 0; });
|
|
100
|
+
}
|
|
101
|
+
return entry.count++;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Reports once that the element enters the viewport (`entered`), or that the page was scrolled past it
|
|
105
|
+
* before it ever did, for example by scroll restoration (`passed`: wholly above the viewport). The element
|
|
106
|
+
* waits invisible in the place it ends up, so the browser judges what shows: a container that clips it
|
|
107
|
+
* (.site, a card, a scrolled row, a collapsed accordion, a closed <details>) keeps it waiting either way.
|
|
108
|
+
* An image is watched once its pixels are decoded, so that its entrance never plays on an empty box.
|
|
109
|
+
* The returned function stops watching; call it on unmount.
|
|
110
|
+
*/
|
|
111
|
+
watch(element: Element, outcomes: Outcomes): () => void {
|
|
112
|
+
this.#waiting.set(element, outcomes);
|
|
113
|
+
this.#view ??= new IntersectionObserver(entries => this.#report(entries, 'entered'), visible);
|
|
114
|
+
this.#above ??= new IntersectionObserver(entries => this.#report(entries, 'passed'), { ...visible, rootMargin: aboveViewport });
|
|
115
|
+
const observe = () => {
|
|
116
|
+
if (!this.#waiting.has(element)) return;
|
|
117
|
+
this.#view!.observe(element);
|
|
118
|
+
this.#above!.observe(element);
|
|
119
|
+
firstReport();
|
|
120
|
+
};
|
|
121
|
+
// Still loading, an image has no pixels and often no height: it would enter wherever it merely touches.
|
|
122
|
+
if (element instanceof HTMLImageElement && !element.complete) element.decode().then(observe, observe);
|
|
123
|
+
else observe();
|
|
124
|
+
this.#checkCarrying();
|
|
125
|
+
return () => this.#forget(element);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Reports once whether the element could be on screen a frame or two from now: whether it, or the outermost
|
|
129
|
+
* container the visitor can scroll around it, lies on, above, or within one viewport below the viewport where the
|
|
130
|
+
* browser next lays it out. During hydration the main thread may not know how far a fling has scrolled the page or a container,
|
|
131
|
+
* and what it decides shows a frame or two later. Hence the observer and its margin, and the container as a
|
|
132
|
+
* whole, since an observer clips at every container without a margin. The returned function stops locating;
|
|
133
|
+
* call it on unmount.
|
|
134
|
+
*/
|
|
135
|
+
locate(element: Element, report: (near: boolean) => void): () => void {
|
|
136
|
+
const target = outermostScroller(element) ?? element;
|
|
137
|
+
const reports = this.#locating.get(target) ?? new Set<(near: boolean) => void>();
|
|
138
|
+
this.#locating.set(target, reports.add(report));
|
|
139
|
+
this.#near ??= new IntersectionObserver(entries => {
|
|
140
|
+
for (const { target, isIntersecting } of entries) {
|
|
141
|
+
const located = this.#locating.get(target);
|
|
142
|
+
if (!located) continue;
|
|
143
|
+
this.#locating.delete(target);
|
|
144
|
+
this.#near!.unobserve(target);
|
|
145
|
+
// Settled, a locate stops nothing: the target may be located again.
|
|
146
|
+
const settled = [...located];
|
|
147
|
+
located.clear();
|
|
148
|
+
for (const report of settled) report(isIntersecting);
|
|
149
|
+
}
|
|
150
|
+
}, { rootMargin: nearViewport });
|
|
151
|
+
this.#near.observe(target);
|
|
152
|
+
firstReport();
|
|
153
|
+
return () => {
|
|
154
|
+
if (!reports.delete(report) || reports.size) return;
|
|
155
|
+
this.#locating.delete(target);
|
|
156
|
+
this.#near!.unobserve(target);
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
#report(entries: IntersectionObserverEntry[], outcome: keyof Outcomes) {
|
|
160
|
+
for (const { target, intersectionRatio, boundingClientRect } of entries) {
|
|
161
|
+
if (!intersectionRatio) continue;
|
|
162
|
+
if (outcome === 'entered' || (boundingClientRect.bottom <= 0 && scrollsWithPage(target))) this.#settle(target, outcome);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* WebKit updates IntersectionObserver only in a rendering update, and an animation running on the compositor
|
|
167
|
+
* requests none, so a marquee could carry a waiting element into view unseen. While elements wait, check every
|
|
168
|
+
* `carryingCheck` ms and request a frame while an ancestor animates or a waiting element moved. Checking, not
|
|
169
|
+
* events: resuming a paused animation or starting one through the Web Animations API fires none. An ancestor's
|
|
170
|
+
* animation also covers a clipping window sliding over content that stays put; a moving box also reveals what a
|
|
171
|
+
* closed shadow root hides. Only animations that advance with time count: a scroll-driven one moves only while
|
|
172
|
+
* the page scrolls, which updates rendering anyway. A page where nothing moves requests no frames.
|
|
173
|
+
*/
|
|
174
|
+
#checkCarrying() {
|
|
175
|
+
if (this.#carrying) return;
|
|
176
|
+
this.#carrying = window.setTimeout(() => {
|
|
177
|
+
this.#carrying = 0;
|
|
178
|
+
if (this.#carried()) requestAnimationFrame(() => {});
|
|
179
|
+
this.#checkCarrying();
|
|
180
|
+
}, carryingCheck);
|
|
181
|
+
}
|
|
182
|
+
#carried(): boolean {
|
|
183
|
+
let moved = false;
|
|
184
|
+
for (const element of this.#waiting.keys()) {
|
|
185
|
+
const { x, y, width, height } = element.getBoundingClientRect();
|
|
186
|
+
const place = `${x} ${y} ${width} ${height}`;
|
|
187
|
+
if (this.#places.get(element) !== place) moved = true;
|
|
188
|
+
this.#places.set(element, place);
|
|
189
|
+
}
|
|
190
|
+
if (moved) return true;
|
|
191
|
+
const carriers = new Set<Element>();
|
|
192
|
+
for (const element of this.#waiting.keys()) {
|
|
193
|
+
for (const node of ancestors(element)) {
|
|
194
|
+
if (carriers.has(node)) break;
|
|
195
|
+
carriers.add(node);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// An element's own animations, never those of its pseudo-elements, which carry none of its children.
|
|
199
|
+
return [...carriers].some(node => node.getAnimations?.().some(({ playState, timeline }) =>
|
|
200
|
+
playState === 'running' && timeline instanceof DocumentTimeline));
|
|
201
|
+
}
|
|
202
|
+
#settle(element: Element, outcome: keyof Outcomes) {
|
|
203
|
+
const outcomes = this.#waiting.get(element);
|
|
204
|
+
if (!outcomes) return;
|
|
205
|
+
this.#forget(element);
|
|
206
|
+
outcomes[outcome]();
|
|
207
|
+
}
|
|
208
|
+
#forget(element: Element) {
|
|
209
|
+
if (!this.#waiting.delete(element)) return;
|
|
210
|
+
this.#view?.unobserve(element);
|
|
211
|
+
this.#above?.unobserve(element);
|
|
212
|
+
if (this.#waiting.size) return;
|
|
213
|
+
window.clearTimeout(this.#carrying);
|
|
214
|
+
this.#carrying = 0;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Present only inside the page island; elements render as plain tags everywhere else. */
|
|
219
|
+
export const StageContext = createContext<MotionStage | null>(null);
|
|
220
|
+
/** Motion of the host component currently rendering; consumed once by its Root. */
|
|
221
|
+
export const HostMotionContext = createContext<ResolvedMotion | null>(null);
|
|
222
|
+
|
|
223
|
+
const waiting = 'builder-waiting';
|
|
224
|
+
const shown = 'builder-shown';
|
|
225
|
+
|
|
226
|
+
/** The CSS fallback animation if it has already started revealing this element. Its delay comes from site.css. */
|
|
227
|
+
function revealedByCss(element: Element): Animation | undefined {
|
|
228
|
+
const fallback = element.getAnimations?.().find(animation => 'animationName' in animation && animation.animationName === 'builder-motion-fallback');
|
|
229
|
+
return fallback && Number(fallback.currentTime ?? 0) >= (fallback.effect?.getTiming().delay ?? 0) ? fallback : undefined;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
type MovingProps = { as: MotionTag; motion: ResolvedMotion; stage: MotionStage; children?: ReactNode } & Record<string, unknown>;
|
|
233
|
+
function Moving({ as, motion, stage, children, ...attributes }: MovingProps) {
|
|
234
|
+
const element = useRef<HTMLDivElement>(null); // any tag; typed as the m.div it renders through
|
|
235
|
+
// Decided when the entrance starts: Motion resolves the variant again on every render.
|
|
236
|
+
const slot = useRef<number | null>(null);
|
|
237
|
+
const moves = useRef<boolean | null>(null);
|
|
238
|
+
// `armed`: Motion owns visibility and CSS stops its fallback. `show`: play the entrance, or show it at once.
|
|
239
|
+
const [state, setState] = useState<{ armed: boolean; show?: 'play' | 'instant' }>({ armed: false });
|
|
240
|
+
// Once focus lands inside, CSS keeps the final state for good, so blur never reveals a half-played frame.
|
|
241
|
+
const [focused, setFocused] = useState(false);
|
|
242
|
+
const variants = useMemo<Variants>(() => {
|
|
243
|
+
const { from, to }: { from: Partial<Record<string, number>>; to: Record<string, number> } = motionTokens.effect[motion.effect];
|
|
244
|
+
return {
|
|
245
|
+
[waiting]: { opacity: 0 },
|
|
246
|
+
// Resolved when the element enters the viewport, so stagger order follows what the visitor sees.
|
|
247
|
+
[shown]: (instant: boolean) => {
|
|
248
|
+
if (instant) return { ...to, transition: { duration: 0 } };
|
|
249
|
+
slot.current ??= motion.group ? stage.order(motion.group) : 0;
|
|
250
|
+
const stagger = motion.stagger ? Math.min(slot.current * motionTokens.stagger[motion.stagger], motionTokens.maxStaggerOffset) : 0;
|
|
251
|
+
// Only the entrance starts from the effect's start state. Inside a scroll container it only fades, since
|
|
252
|
+
// moving or scaling would change what that container scrolls or where it snaps (.site clips its edges instead).
|
|
253
|
+
moves.current ??= !insideScroller(element.current!);
|
|
254
|
+
const entrance = Object.fromEntries(Object.entries(to).filter(([key]) => moves.current || key === 'opacity').map(([key, value]) => [key, [from[key] ?? value, value]]));
|
|
255
|
+
return { ...entrance, transition: { duration: motionTokens.duration[motion.duration], ease: motionTokens.ease, delay: motionTokens.delay[motion.delay] + stagger } };
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
}, [motion.effect, motion.delay, motion.duration, motion.stagger, motion.group, stage]);
|
|
259
|
+
useLayoutEffect(() => {
|
|
260
|
+
const node = element.current;
|
|
261
|
+
if (!node) return;
|
|
262
|
+
if (node.matches(':focus-within')) setFocused(true);
|
|
263
|
+
const watch = () => {
|
|
264
|
+
setState({ armed: true });
|
|
265
|
+
return stage.watch(node, {
|
|
266
|
+
entered: () => setState({ armed: true, show: 'play' }),
|
|
267
|
+
passed: () => setState({ armed: true, show: 'instant' }),
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
const fallback = revealedByCss(node);
|
|
271
|
+
if (!fallback) return watch();
|
|
272
|
+
// Hydration after the CSS fallback began: never hide what may be on screen. Content far below the
|
|
273
|
+
// viewport is invisible, so Motion can take it back and reveal it on scroll.
|
|
274
|
+
let live = true;
|
|
275
|
+
let forget = stage.locate(node, near => {
|
|
276
|
+
if (!near) {
|
|
277
|
+
forget = watch();
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
// The keyframes fade from the inline opacity, so Motion writing the final state mid-fade would jump
|
|
281
|
+
// to its end, and playing the entrance would override the fade. Unarmed, Motion leaves it alone until it ends.
|
|
282
|
+
const settle = () => { if (live) setState({ armed: false, show: 'instant' }); };
|
|
283
|
+
fallback.finished.then(settle, settle);
|
|
284
|
+
});
|
|
285
|
+
return () => {
|
|
286
|
+
live = false;
|
|
287
|
+
forget();
|
|
288
|
+
};
|
|
289
|
+
}, [stage]);
|
|
290
|
+
const onFocusCapture = (event: FocusEvent<HTMLDivElement>) => {
|
|
291
|
+
setFocused(true);
|
|
292
|
+
(attributes.onFocusCapture as ((event: FocusEvent<HTMLDivElement>) => void) | undefined)?.(event);
|
|
293
|
+
};
|
|
294
|
+
const Tag = m[as as keyof typeof m] as typeof m.div;
|
|
295
|
+
return <Tag ref={element} {...attributes} onFocusCapture={onFocusCapture} data-motion="" data-motion-armed={state.armed ? '' : undefined} data-motion-shown={focused ? '' : undefined}
|
|
296
|
+
variants={variants} custom={state.show === 'instant'} initial={waiting} animate={state.show ? shown : undefined}>{children}</Tag>;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** Sits inside json-render's own per-element boundary, so a failing animation keeps its content. */
|
|
300
|
+
class StaticOnError extends Component<{ fallback: ReactNode; children: ReactNode }, { failed: boolean }> {
|
|
301
|
+
state = { failed: false };
|
|
302
|
+
static getDerivedStateFromError() { return { failed: true }; }
|
|
303
|
+
render() { return this.state.failed ? this.props.fallback : this.props.children; }
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
type RevealProps = { as: MotionTag; motion?: ResolvedMotion; children?: ReactNode } & Record<string, unknown>;
|
|
307
|
+
/** Renders exactly one element: the plain tag outside the island, the same tag through Motion inside it. */
|
|
308
|
+
export function Reveal({ as, motion, children, ...attributes }: RevealProps) {
|
|
309
|
+
const stage = useContext(StageContext);
|
|
310
|
+
const plain = createElement(as, attributes, children);
|
|
311
|
+
if (!stage || !motion) return plain;
|
|
312
|
+
return <StaticOnError fallback={plain}><Moving as={as} motion={motion} stage={stage} {...attributes}>{children}</Moving></StaticOnError>;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Passed to host components so their outermost element moves; hosts never import Motion. */
|
|
316
|
+
export function Root({ as = 'div', children, ...attributes }: RootProps) {
|
|
317
|
+
const motion = useContext(HostMotionContext);
|
|
318
|
+
// Void tags such as img must not receive a provider as a child.
|
|
319
|
+
const content = children == null ? undefined : <HostMotionContext value={null}>{children}</HostMotionContext>;
|
|
320
|
+
return <Reveal as={as} motion={motion ?? undefined} {...attributes}>{content}</Reveal>;
|
|
321
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ContentSaveRejectedError, definePlugin, getPreviewUrl } from 'emdash';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { componentSchemas, createPageGuide, staggerComponentNames } from './catalog.ts';
|
|
4
|
+
import { validateDocument } from './document.ts';
|
|
5
|
+
import { pluginId, pluginVersion } from './constants.ts';
|
|
6
|
+
import { resolveOptions, type BuilderOptions } from './options.ts';
|
|
7
|
+
import { componentContract, type ComponentExtensions } from './extensions.ts';
|
|
8
|
+
import { maxMotionElements, motionTokens } from './motion-tokens.ts';
|
|
9
|
+
|
|
10
|
+
// EmDash's Contributor role is the lowest role that may read drafts.
|
|
11
|
+
const contributorRole = 20;
|
|
12
|
+
const documentInput = z.object({ document: z.unknown() });
|
|
13
|
+
const pageInput = z.object({ id: z.string().min(1).max(200) });
|
|
14
|
+
|
|
15
|
+
export function createPlugin(input: BuilderOptions = {}, components: ComponentExtensions = {}) {
|
|
16
|
+
const options = resolveOptions(input);
|
|
17
|
+
const contract = componentContract(components);
|
|
18
|
+
const validate = (document: unknown) => validateDocument(document, components);
|
|
19
|
+
const guide = createPageGuide(options);
|
|
20
|
+
const schemas = Object.fromEntries(Object.entries(contract.props).map(([name, props]) => [name, { props: z.toJSONSchema(props), ...(components[name] ? { description: components[name].description, container: !!components[name].container, motion: !!components[name].motion } : {}) }]));
|
|
21
|
+
const motion = {
|
|
22
|
+
enabled: options.motion,
|
|
23
|
+
effect: Object.keys(motionTokens.effect), delay: Object.keys(motionTokens.delay), duration: Object.keys(motionTokens.duration), stagger: Object.keys(motionTokens.stagger),
|
|
24
|
+
components: [...contract.motion], staggerComponents: [...staggerComponentNames], limit: maxMotionElements,
|
|
25
|
+
};
|
|
26
|
+
return definePlugin({
|
|
27
|
+
id: pluginId, version: pluginVersion,
|
|
28
|
+
capabilities: ['content:read', 'content:write', 'hooks.content-policy:register'],
|
|
29
|
+
admin: {
|
|
30
|
+
entry: '@interactive-inc/emdash-plugins/builder/admin',
|
|
31
|
+
fieldWidgets: [
|
|
32
|
+
{ name: 'page-preview', label: 'ページプレビュー', fieldTypes: ['json'] },
|
|
33
|
+
{ name: 'managed', label: 'チャットで管理', fieldTypes: ['string', 'text'] },
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
hooks: {
|
|
37
|
+
'content:beforeSave': {
|
|
38
|
+
errorPolicy: 'abort',
|
|
39
|
+
handler: async event => {
|
|
40
|
+
if (event.collection !== options.collection) return;
|
|
41
|
+
if (!event.isNew && !Object.hasOwn(event.content, 'document')) return;
|
|
42
|
+
const result = validate(event.content.document);
|
|
43
|
+
if (!result.success) throw new ContentSaveRejectedError(`Page JSON is invalid: ${result.errors.join('; ')}`);
|
|
44
|
+
return { ...event.content, document: result.document };
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
'content:beforePublish': {
|
|
48
|
+
errorPolicy: 'abort',
|
|
49
|
+
handler: async event => {
|
|
50
|
+
if (event.collection !== options.collection) return;
|
|
51
|
+
const data = event.content.data;
|
|
52
|
+
const document = data && typeof data === 'object' && 'document' in data ? data.document : event.content.document;
|
|
53
|
+
const result = validate(document);
|
|
54
|
+
if (!result.success) return { cancel: true, reason: `Invalid page JSON: ${result.errors.join('; ')}` };
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
routes: {
|
|
59
|
+
configuration: { permission: 'content:read', handler: async () => ({ collection: options.collection, previewPath: options.previewPath }) },
|
|
60
|
+
catalog: {
|
|
61
|
+
permission: 'content:read',
|
|
62
|
+
handler: async () => ({ version: 1, components: { ...componentSchemas, ...Object.fromEntries(Object.entries(components).map(([name]) => [name, schemas[name].props])) }, descriptions: schemas, motion, guide, configuration: { collection: options.collection, basePath: options.basePath, previewPath: options.previewPath, homeSlug: options.homeSlug } }),
|
|
63
|
+
},
|
|
64
|
+
validate: {
|
|
65
|
+
permission: 'content:read',
|
|
66
|
+
input: documentInput,
|
|
67
|
+
handler: async ctx => validate(documentInput.parse(ctx.input).document),
|
|
68
|
+
},
|
|
69
|
+
preview: {
|
|
70
|
+
permission: 'content:read_drafts',
|
|
71
|
+
input: pageInput,
|
|
72
|
+
handler: async ctx => {
|
|
73
|
+
// Defense in depth: plugin capabilities must not widen a caller's draft access.
|
|
74
|
+
if (!ctx.user || ctx.user.role < contributorRole) throw new Error('Draft access is required');
|
|
75
|
+
const page = await ctx.content?.get(options.collection, pageInput.parse(ctx.input).id);
|
|
76
|
+
if (!page) throw new Error('Page not found');
|
|
77
|
+
const previewSecret = process.env.EMDASH_PREVIEW_SECRET;
|
|
78
|
+
if (!previewSecret) throw new Error('Configure EMDASH_PREVIEW_SECRET before creating preview links');
|
|
79
|
+
return {
|
|
80
|
+
url: await getPreviewUrl({ collection: options.collection, id: page.id, secret: previewSecret, expiresIn: '15m', pathPattern: `${options.previewPath}/{id}` }),
|
|
81
|
+
expiresIn: 900,
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
mcp: { tools: {
|
|
87
|
+
catalog: { description: 'Read the supported site components, JSON property schemas, data bindings, theme tokens, and the page creation workflow.', route: 'catalog', input: z.object({}) },
|
|
88
|
+
validate: { description: 'Validate a complete page document before saving it with EmDash content_create or content_update. Does not save or publish.', route: 'validate', input: documentInput },
|
|
89
|
+
preview: { description: 'Create a 15-minute signed preview URL for one saved page. Use after saving a draft, before content_publish.', route: 'preview', input: pageInput },
|
|
90
|
+
} },
|
|
91
|
+
});
|
|
92
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The URL rule. resolvePage applies it to every built-in URL after binding, before rendering; host components use it for their own. */
|
|
2
|
+
export function safeUrl(value: unknown, image = false): string | undefined {
|
|
3
|
+
if (typeof value !== 'string' || value !== value.trim() || /[\u0000-\u0020\u007f\\]/.test(value)) return undefined;
|
|
4
|
+
if (value.startsWith('/') && !value.startsWith('//')) return value;
|
|
5
|
+
if (!image && /^#[a-zA-Z][\w-]*$/.test(value)) return value;
|
|
6
|
+
try {
|
|
7
|
+
const url = new URL(value);
|
|
8
|
+
if (url.username || url.password) return undefined;
|
|
9
|
+
if (url.protocol === 'https:') return value;
|
|
10
|
+
if (!image && ['mailto:', 'tel:'].includes(url.protocol)) return value;
|
|
11
|
+
} catch { /* Invalid URLs are displayed without navigation. */ }
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { resolveOptions, type BuilderOptions } from '../options.ts';
|
|
2
|
+
import type { ComponentExtensions } from '../extensions.ts';
|
|
3
|
+
import { getEmDashCollection, getEmDashEntry } from 'emdash';
|
|
4
|
+
import { validateDocument, type PageDocument, type PageState } from '../document.ts';
|
|
5
|
+
import { defaultListItems } from '../list-limits.ts';
|
|
6
|
+
import { resolvePage, type ResolvedView } from '../resolve-page.ts';
|
|
7
|
+
|
|
8
|
+
export type LoadedPage = {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
description: string;
|
|
12
|
+
slug: string;
|
|
13
|
+
document: PageDocument;
|
|
14
|
+
state: PageState;
|
|
15
|
+
/** What the page renders; the only page data that reaches the browser. */
|
|
16
|
+
view: ResolvedView;
|
|
17
|
+
isPreview: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** All reads go through EmDash's published-entry and scoped preview checks. */
|
|
21
|
+
export async function loadPage(identifier: string, input: BuilderOptions = {}, components: ComponentExtensions = {}): Promise<LoadedPage | null> {
|
|
22
|
+
const options = resolveOptions(input);
|
|
23
|
+
const { entry, error, isPreview } = await getEmDashEntry(options.collection, identifier);
|
|
24
|
+
if (error) throw new Error('Could not load page');
|
|
25
|
+
if (!entry) return null;
|
|
26
|
+
const validated = validateDocument(entry.data.document, components);
|
|
27
|
+
if (!validated.success) throw new Error('Stored page JSON is invalid');
|
|
28
|
+
const document = validated.document;
|
|
29
|
+
const title = typeof entry.data.title === 'string' ? entry.data.title : '';
|
|
30
|
+
const description = typeof entry.data.description === 'string' ? entry.data.description : '';
|
|
31
|
+
const slug = typeof entry.data.slug === 'string' ? entry.data.slug : identifier;
|
|
32
|
+
const data = Object.fromEntries(await Promise.all(Object.entries(document.data ?? {}).map(async ([name, query]) => {
|
|
33
|
+
if (query.id) {
|
|
34
|
+
const result = await getEmDashEntry(query.collection, query.id);
|
|
35
|
+
if (result.error) throw new Error(`Could not load data source ${name}`);
|
|
36
|
+
return [name, result.entry ? { ...result.entry.data, id: result.entry.id } : null];
|
|
37
|
+
}
|
|
38
|
+
const result = await getEmDashCollection(query.collection, { limit: query.limit ?? defaultListItems });
|
|
39
|
+
if (result.error) throw new Error(`Could not load data source ${name}`);
|
|
40
|
+
return [name, result.entries.map(item => ({ ...item.data, id: item.id }))];
|
|
41
|
+
})));
|
|
42
|
+
const state: PageState = { page: { title, description, slug }, data };
|
|
43
|
+
const view = resolvePage(document, state, components, { motion: options.motion });
|
|
44
|
+
return { id: entry.id, title, description, slug, document, state, view, isPreview };
|
|
45
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { loadPage, type LoadedPage } from './load-page.ts';
|
|
2
|
+
|
|
3
|
+
import type { BuilderOptions } from '../options.ts';
|
|
4
|
+
import type { ComponentExtensions } from '../extensions.ts';
|
|
5
|
+
|
|
6
|
+
type Result = { page: LoadedPage | null; status: number };
|
|
7
|
+
export async function pageResponse(identifier: string, options: BuilderOptions = {}, components: ComponentExtensions = {}): Promise<Result> {
|
|
8
|
+
try {
|
|
9
|
+
const page = await loadPage(identifier, options, components);
|
|
10
|
+
return { page, status: page ? 200 : 404 };
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.error('[emdash-plugins/builder] Page resolution failed', error);
|
|
13
|
+
return { page: null, status: 503 };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { JSONUIProvider, Renderer, type ComponentRegistry } from '@json-render/react';
|
|
2
|
+
import type { Spec } from '@json-render/core';
|
|
3
|
+
import { useMemo, type ReactNode } from 'react';
|
|
4
|
+
import { PortableContent } from './portable-content.tsx';
|
|
5
|
+
import type { z } from 'zod';
|
|
6
|
+
import { HostMotionContext, Reveal, Root } from './reveal.tsx';
|
|
7
|
+
import type { componentProps } from './catalog.ts';
|
|
8
|
+
import type { ComponentExtensions } from './extensions.ts';
|
|
9
|
+
import type { ResolvedMotion } from './motion-tokens.ts';
|
|
10
|
+
import type { ResolvedView } from './resolve-page.ts';
|
|
11
|
+
|
|
12
|
+
// Client module: zod, catalog, document and extension code is imported for types only.
|
|
13
|
+
type Props = Record<string, any> & { motion?: ResolvedMotion };
|
|
14
|
+
type Builtin = (input: { props: Props; children?: ReactNode }) => ReactNode;
|
|
15
|
+
type Builtins = { [K in keyof typeof componentProps]: (input: { props: Omit<z.infer<(typeof componentProps)[K]>, 'motion'> & { motion?: ResolvedMotion }; children?: ReactNode }) => ReactNode };
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Each component's own root element moves, so motion never adds wrappers that change layout.
|
|
19
|
+
* resolvePage has already emptied unsafe URLs, so an empty href or src is all that is checked here.
|
|
20
|
+
*/
|
|
21
|
+
const builtins: Builtins = {
|
|
22
|
+
Section: ({ props, children }) => <section id={props.id} className={`section tone-${props.tone ?? 'default'} space-${props.spacing ?? 'lg'}`}>{children}</section>,
|
|
23
|
+
Container: ({ props, children }) => <Reveal as="div" motion={props.motion} className={`container width-${props.width ?? 'normal'}`}>{children}</Reveal>,
|
|
24
|
+
Stack: ({ props, children }) => <Reveal as="div" motion={props.motion} className={`stack direction-${props.direction ?? 'vertical'} gap-${props.gap ?? 'md'} align-${props.align ?? 'start'}`}>{children}</Reveal>,
|
|
25
|
+
Grid: ({ props, children }) => <Reveal as="div" motion={props.motion} className={`grid columns-${props.columns ?? 3} gap-${props.gap ?? 'md'}`}>{children}</Reveal>,
|
|
26
|
+
Heading: ({ props }) => <Reveal as={props.level ?? 'h2'} motion={props.motion} className={`heading size-${props.size ?? 'md'} text-${props.align ?? 'start'}`}>{props.text}</Reveal>,
|
|
27
|
+
Text: ({ props }) => <Reveal as="p" motion={props.motion} className={`text text-${props.tone ?? 'default'} size-${props.size ?? 'md'} text-${props.align ?? 'start'}`}>{props.text}</Reveal>,
|
|
28
|
+
Link: ({ props }) => props.href
|
|
29
|
+
? <Reveal as="a" motion={props.motion} href={props.href} className={`link link-${props.variant ?? 'text'}`}>{props.label}</Reveal>
|
|
30
|
+
: <Reveal as="span" motion={props.motion}>{props.label}</Reveal>,
|
|
31
|
+
Image: ({ props }) => props.src ? <Reveal as="img" motion={props.motion} src={props.src} alt={props.alt} className={`image ratio-${props.ratio ?? 'auto'}`} loading="lazy" decoding="async" /> : null,
|
|
32
|
+
Card: ({ props, children }) => <Reveal as="div" motion={props.motion} className={`card card-${props.tone ?? 'default'}`}>{children}</Reveal>,
|
|
33
|
+
Badge: ({ props }) => <Reveal as="span" motion={props.motion} className="badge">{props.text}</Reveal>,
|
|
34
|
+
Divider: ({ props }) => <Reveal as="hr" motion={props.motion} className="divider" />,
|
|
35
|
+
PortableText: ({ props }) => <Reveal as="div" motion={props.motion} className="prose"><PortableContent value={props.value} /></Reveal>,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function createRegistry(components: ComponentExtensions): ComponentRegistry {
|
|
39
|
+
const registry: ComponentRegistry = {};
|
|
40
|
+
for (const [name, Builtin] of Object.entries(builtins as unknown as Record<string, Builtin>)) registry[name] = ({ element, children }) => <Builtin props={element.props as Props} children={children} />;
|
|
41
|
+
for (const [name, definition] of Object.entries(components)) {
|
|
42
|
+
const Component = definition.component;
|
|
43
|
+
registry[name] = ({ element, children }) => {
|
|
44
|
+
const { motion, ...props } = element.props as Props;
|
|
45
|
+
return <HostMotionContext value={motion ?? null}><Component props={props} Root={Root} children={children} /></HostMotionContext>;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return registry;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type SiteProps = { view: ResolvedView; components?: ComponentExtensions };
|
|
52
|
+
/** Renders a resolved page. The server and the page island render the same tree. */
|
|
53
|
+
export function ResolvedSite({ view, components = {} }: SiteProps) {
|
|
54
|
+
const registry = useMemo(() => createRegistry(components), [components]);
|
|
55
|
+
return <div className="site" style={view.theme}>
|
|
56
|
+
<JSONUIProvider registry={registry} initialState={{}}>
|
|
57
|
+
<Renderer spec={view.spec as Spec} registry={registry} />
|
|
58
|
+
</JSONUIProvider>
|
|
59
|
+
</div>;
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;font-family:Inter,"Noto Sans JP",system-ui,sans-serif;color:#18221a;background:#f7f8f2}a{color:inherit}button,input,textarea,select{font:inherit}img{display:block;max-width:100%}.site{background:var(--background);color:var(--foreground);min-height:100vh;overflow:clip}main>astro-island{display:contents}.section{width:100%;padding-inline:1.5rem}.tone-default{background:var(--background)}.tone-muted{background:color-mix(in srgb,var(--foreground) 5%,var(--background))}.tone-accent{background:var(--accent);color:#18221a}.tone-dark{background:var(--foreground);color:var(--background)}.space-none{padding-block:0}.space-sm{padding-block:1.5rem}.space-md{padding-block:3rem}.space-lg{padding-block:5rem}.space-xl{padding-block:8rem}.container{width:100%;margin-inline:auto}.width-narrow{max-width:720px}.width-normal{max-width:1100px}.width-wide{max-width:1400px}.stack{display:flex}.direction-vertical{flex-direction:column}.direction-horizontal{flex-direction:row;flex-wrap:wrap}.align-start{align-items:flex-start}.align-center{align-items:center}.align-end{align-items:flex-end}.gap-none{gap:0}.gap-sm{gap:.75rem}.gap-md{gap:1.5rem}.gap-lg{gap:2.5rem}.gap-xl{gap:4rem}.grid{display:grid;align-items:stretch;width:100%}.columns-1{grid-template-columns:1fr}.columns-2{grid-template-columns:repeat(2,minmax(0,1fr))}.columns-3{grid-template-columns:repeat(3,minmax(0,1fr))}.columns-4{grid-template-columns:repeat(4,minmax(0,1fr))}.heading{white-space:pre-line;font-weight:650;line-height:1.12;letter-spacing:-.045em;text-wrap:balance;margin:0;max-width:100%}.heading.size-sm{font-size:1.4rem}.heading.size-md{font-size:clamp(1.8rem,4vw,3rem)}.heading.size-lg{font-size:clamp(2.5rem,6vw,4.8rem)}.heading.size-xl{font-size:clamp(3rem,8vw,6.8rem)}.text{line-height:1.85;margin:0;max-width:65ch;white-space:pre-line;overflow-wrap:anywhere}.text.size-sm{font-size:.875rem}.text.size-md{font-size:1rem}.text.size-lg{font-size:1.2rem}.text-muted{color:color-mix(in srgb,currentColor 70%,transparent)}.text-start{text-align:start}.text-center{text-align:center}.text-end{text-align:end}.link{display:inline-flex;align-items:center;justify-content:center;gap:.5rem;font-size:.95rem;font-weight:600;text-underline-offset:4px}.link-primary,.link-secondary{padding:1rem 1.6rem;border-radius:999px;text-decoration:none;border:1px solid currentColor}.link-primary{background:var(--foreground);color:var(--background);border-color:var(--foreground)}.link-secondary{background:transparent}.link:hover{filter:opacity(.75)}.card{height:100%;border:1px solid color-mix(in srgb,var(--foreground) 15%,transparent);border-radius:var(--radius);padding:2rem}.card-muted{background:color-mix(in srgb,var(--foreground) 5%,var(--background))}.badge{display:inline-block;padding:.5rem .9rem;border:1px solid currentColor;border-radius:999px;font-size:.7rem;font-weight:650;letter-spacing:.08em;text-transform:uppercase}.image{width:100%;object-fit:cover;border-radius:var(--radius)}.ratio-square{aspect-ratio:1}.ratio-landscape{aspect-ratio:16/9}.ratio-portrait{aspect-ratio:3/4}.divider{border:0;border-top:1px solid color-mix(in srgb,var(--foreground) 20%,transparent);margin:0;width:100%}.prose{line-height:1.85;overflow-wrap:anywhere}.prose a{text-decoration:underline}.prose pre{overflow:auto}.prose :not(figure)>img{display:inline-block;vertical-align:middle}.is-preview .site{min-height:0}.preview-banner{position:sticky;top:0;z-index:10;background:#18221a;color:white;text-align:center;padding:.7rem 1rem;font-size:.8rem}.error-page{max-width:720px;margin:15vh auto;padding:2rem}.error-code{font-size:4rem;opacity:.4;margin:0}a:focus-visible,button:focus-visible,select:focus-visible{outline:3px solid #55761d;outline-offset:5px}@media(max-width:700px){.section{width:100%;padding-inline:1.25rem}.space-xl{padding-block:5rem}.space-lg{padding-block:3rem}.columns-2,.columns-3,.columns-4{grid-template-columns:1fr}.card{padding:1.5rem}}@keyframes builder-motion-fallback{to{opacity:1}}[data-motion]:not([data-motion-armed]){animation:builder-motion-fallback .4s ease-out 1.5s forwards}[data-motion]:focus-within,[data-motion][data-motion-shown]{opacity:1!important;transform:none!important}[data-motion-static] [data-motion]{opacity:1!important;transform:none!important;animation:none!important}@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}}@media(scripting:none),print,(prefers-reduced-motion:reduce){[data-motion]{opacity:1!important;transform:none!important;animation:none!important}}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare module 'virtual:emdash-plugins/builder/config' {
|
|
2
|
+
const options: import('./options.ts').ResolvedOptions;
|
|
3
|
+
export default options;
|
|
4
|
+
}
|
|
5
|
+
declare module 'virtual:emdash-plugins/builder/extensions' {
|
|
6
|
+
const components: import('./extensions.ts').ComponentExtensions;
|
|
7
|
+
export default components;
|
|
8
|
+
}
|
|
9
|
+
declare module 'virtual:emdash-plugins/builder/page-shell' {
|
|
10
|
+
/** PageShell.astro, or the island-free StaticPageShell.astro with motion: false. */
|
|
11
|
+
const PageShell: typeof import('./PageShell.astro').default;
|
|
12
|
+
export default PageShell;
|
|
13
|
+
}
|