@styleflow.app/flowpress-astro-core 1.0.0-beta.41 → 1.0.0-beta.43
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 +13 -0
- package/README.md +19 -3
- package/dist/astro/EditorialMedia.astro +47 -0
- package/dist/astro/GutenbergRenderer.astro +3 -6
- package/dist/astro/blocks/ImageBlock.astro +1 -1
- package/dist/astro/motion/motion-controller.d.ts.map +1 -1
- package/dist/astro/motion/motion-controller.js +22 -3
- package/dist/astro/motion/motion-controller.js.map +1 -1
- package/dist/astro/motion/motion-controller.ts +21 -6
- package/dist/astro/motion/motion.css +55 -3
- package/dist/astro/motion/motion.d.ts.map +1 -1
- package/dist/astro/motion/motion.js +1 -0
- package/dist/astro/motion/motion.js.map +1 -1
- package/dist/astro/motion/motion.ts +1 -0
- package/dist/astro/native/core-image.astro +2 -3
- package/dist/astro/native/core-post-featured-image.astro +2 -2
- package/dist/build-cache.d.ts.map +1 -1
- package/dist/build-cache.js +2 -1
- package/dist/build-cache.js.map +1 -1
- package/dist/client.d.ts +11 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +46 -3
- package/dist/client.js.map +1 -1
- package/dist/env.d.ts +12 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +33 -0
- package/dist/env.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.43 — 2026-10-30
|
|
4
|
+
|
|
5
|
+
- Retry GraphQL query documents after a timeout, a network failure or HTTP 429/502/503/504. Every attempt has a fresh timeout that also covers the response body, backoff starts at `retryDelayMs` and doubles, and each retry logs one warning. Mutations, GraphQL errors and other statuses are never replayed. Defaults: 15000 ms per attempt and 1 retry.
|
|
6
|
+
- Add `readFlowpressGraphqlOptions()` for `FLOWPRESS_GRAPHQL_TIMEOUT_MS` and `FLOWPRESS_GRAPHQL_RETRIES`. It refuses budgets that reach the shared 120 s lock of the build request store. The build store keeps storing only final successes.
|
|
7
|
+
- [Canonical report](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-10-30-graphql-cold-start-retry.md).
|
|
8
|
+
|
|
9
|
+
## 1.0.0-beta.42 — 2026-10-27
|
|
10
|
+
|
|
11
|
+
- Add the one-shot `sf-reveal--zoom-in` preset: the editorial media scales from 1.25 to 1 over 2000 ms inside a stationary clipping frame, without fading or moving the block or caption.
|
|
12
|
+
- Share SSR media frames across native Image, Post Featured Image, Styleflow Image and Gallery items; preserve intrinsic dimensions, responsive geometry, crop/focal settings, inline SVG and link semantics.
|
|
13
|
+
- Wait for inner media transitions, including stagger delays, before settling; keep focus, deep links, print and reduced-motion fallbacks immediate. Preserve priority metadata when an image becomes inline SVG.
|
|
14
|
+
- [Canonical release and adoption report](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-10-27-reveal-zoom-immagini.md).
|
|
15
|
+
|
|
3
16
|
## 1.0.0-beta.41 — 2026-10-27
|
|
4
17
|
|
|
5
18
|
- Fill the assigned layout space by default for structural blocks and editorial images, while allowing Styleflow recipes and responsive CSS widths to override the defaults.
|
package/README.md
CHANGED
|
@@ -6,11 +6,14 @@ CMS values.
|
|
|
6
6
|
|
|
7
7
|
The package must not import from an application or project plugin.
|
|
8
8
|
|
|
9
|
+
Editorial media frames and the `sf-reveal--zoom-in` motion preset are documented
|
|
10
|
+
in the [canonical motion guide](https://github.com/StyleFlow-App/styleflow-docs/blob/main/wiki/motion.md).
|
|
11
|
+
|
|
9
12
|
## Install
|
|
10
13
|
|
|
11
14
|
```bash
|
|
12
|
-
pnpm add @styleflow.app/flowpress-astro-core@1.0.0-beta.
|
|
13
|
-
@styleflow.app/astro@1.0.0-beta.
|
|
15
|
+
pnpm add @styleflow.app/flowpress-astro-core@1.0.0-beta.43 \
|
|
16
|
+
@styleflow.app/astro@1.0.0-beta.11
|
|
14
17
|
```
|
|
15
18
|
|
|
16
19
|
Prereleases are pinned exactly. The package expects Astro 7 or newer and the
|
|
@@ -32,10 +35,23 @@ remain hidden unless `debug: true` is explicitly set for local development.
|
|
|
32
35
|
```ts
|
|
33
36
|
const client = new FlowpressClient({
|
|
34
37
|
endpoint: process.env.BACKEND_GRAPHQL_URL!,
|
|
35
|
-
debug: process.env.APP_ENV === "local"
|
|
38
|
+
debug: process.env.APP_ENV === "local",
|
|
39
|
+
...readFlowpressGraphqlOptions(process.env)
|
|
36
40
|
});
|
|
37
41
|
```
|
|
38
42
|
|
|
43
|
+
Each attempt has its own `timeoutMs` (default 15000 ms, covering the body
|
|
44
|
+
as well as the headers). Query documents are retried `retries` times (default 1)
|
|
45
|
+
after a timeout, a network failure or HTTP 429/502/503/504, with backoff that
|
|
46
|
+
starts at `retryDelayMs` (default 1000 ms) and doubles. Each retry logs one
|
|
47
|
+
`console.warn` with the operation, the attempt and the elapsed time.
|
|
48
|
+
Mutations, GraphQL `errors` and other HTTP statuses are never replayed. A build
|
|
49
|
+
request store receives only the final successful response.
|
|
50
|
+
`readFlowpressGraphqlOptions()` reads optional `FLOWPRESS_GRAPHQL_TIMEOUT_MS`
|
|
51
|
+
(1000–60000) and `FLOWPRESS_GRAPHQL_RETRIES` (0–5) values. It refuses any pair
|
|
52
|
+
whose worst case reaches the 120 s lock that build processes wait on in the
|
|
53
|
+
shared request store.
|
|
54
|
+
|
|
39
55
|
For local Cloudflare development, prefer an HTTP loopback endpoint dedicated
|
|
40
56
|
to server-to-server traffic. Keep the public HTTPS backend URL separate for
|
|
41
57
|
canonical URL rewriting.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Media from "./Media.astro";
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
presentation?: Record<string, string>;
|
|
6
|
+
[attribute: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
const { presentation = {}, ...props } = Astro.props;
|
|
9
|
+
// Size the clipping box in the original containing block, so percentages and
|
|
10
|
+
// authored units are not resolved a second time against a new parent.
|
|
11
|
+
const frameStyle = Object.entries(presentation)
|
|
12
|
+
.filter(([name]) => ["width", "height", "aspect-ratio"].includes(name))
|
|
13
|
+
.map(([name, value]) => `${name}:${value}`).join(";");
|
|
14
|
+
const mediaStyle = Object.entries(presentation)
|
|
15
|
+
.filter(([name]) => !["width", "height"].includes(name))
|
|
16
|
+
.map(([name, value]) => `${name}:${value}`);
|
|
17
|
+
if (presentation["object-position"]) mediaStyle.push(`--sf-reveal-zoom-origin:${presentation["object-position"]}`);
|
|
18
|
+
if (presentation.width !== undefined) mediaStyle.push("width:100%");
|
|
19
|
+
if (presentation.height && presentation.height !== "auto") mediaStyle.push("height:100%");
|
|
20
|
+
const radiusClasses = String(props.class ?? "").split(/\s+/)
|
|
21
|
+
.filter(name => /(?:^|:)!?rounded(?:-|$)/.test(name)).join(" ");
|
|
22
|
+
---
|
|
23
|
+
<span data-flowpress-media-frame data-flowpress-media-priority={props.loading === "eager" || props.fetchpriority === "high" ? true : undefined} class={radiusClasses || undefined} style={frameStyle || undefined}>
|
|
24
|
+
<Media {...props} style={mediaStyle.join(";") || undefined} />
|
|
25
|
+
</span>
|
|
26
|
+
<style is:global>
|
|
27
|
+
@layer base {
|
|
28
|
+
:where([data-flowpress-media-frame]) {
|
|
29
|
+
display: inline-grid;
|
|
30
|
+
grid-template-columns: minmax(0, 1fr);
|
|
31
|
+
grid-template-rows: minmax(0, 1fr);
|
|
32
|
+
width: 100%;
|
|
33
|
+
max-width: 100%;
|
|
34
|
+
min-width: 0;
|
|
35
|
+
vertical-align: bottom;
|
|
36
|
+
border-radius: inherit;
|
|
37
|
+
}
|
|
38
|
+
:where([data-flowpress-media-frame] > img, [data-flowpress-media-frame] > svg) {
|
|
39
|
+
width: 100%;
|
|
40
|
+
max-width: 100%;
|
|
41
|
+
min-width: 0;
|
|
42
|
+
min-height: 0;
|
|
43
|
+
height: auto;
|
|
44
|
+
vertical-align: bottom;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -418,12 +418,9 @@ function nestedRendererProps(nextParentBlockName: string, attrs: Record<string,
|
|
|
418
418
|
return (
|
|
419
419
|
<StyleflowElement as="div" {...semantic} {...htmlAttributes}>
|
|
420
420
|
{images.map((image) => image.url ? (
|
|
421
|
-
<
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
loading="lazy"
|
|
425
|
-
decoding="async"
|
|
426
|
-
/>
|
|
421
|
+
<ImageBlock block={{ name: "sf/image", attributes: {
|
|
422
|
+
image, alt: decodeFlowpressText(image.alt), loading: "lazy", decoding: "async",
|
|
423
|
+
} }} contract={contract} />
|
|
427
424
|
) : null)}
|
|
428
425
|
</StyleflowElement>
|
|
429
426
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion-controller.d.ts","sourceRoot":"","sources":["../../../src/astro/motion/motion-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAeL,KAAK,eAAe,EAErB,MAAM,aAAa,CAAC;AAmHrB;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,eAAoB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"motion-controller.d.ts","sourceRoot":"","sources":["../../../src/astro/motion/motion-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAeL,KAAK,eAAe,EAErB,MAAM,aAAa,CAAC;AAmHrB;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,eAAoB,GAAG,IAAI,CA0PtE"}
|
|
@@ -98,6 +98,16 @@ export function initializeSfMotion(options = {}) {
|
|
|
98
98
|
const resolvedOptions = resolveSfMotionOptions(options);
|
|
99
99
|
inheritAutomaticReveals(resolvedOptions);
|
|
100
100
|
applyRevealStaggers();
|
|
101
|
+
// Custom media classes may round the image instead of its block. Keep that
|
|
102
|
+
// authored edge on the stationary frame while the inner pixels zoom.
|
|
103
|
+
document.querySelectorAll(".sf-reveal--zoom-in [data-flowpress-media-frame]").forEach(frame => {
|
|
104
|
+
const media = frame.querySelector("img, svg");
|
|
105
|
+
if (!media)
|
|
106
|
+
return;
|
|
107
|
+
const radius = window.getComputedStyle(media).borderRadius;
|
|
108
|
+
if (radius && !/^0px(?: 0px)*$/.test(radius))
|
|
109
|
+
frame.style.borderRadius = radius;
|
|
110
|
+
});
|
|
101
111
|
const revealElements = () => Array.from(document.querySelectorAll(".sf-reveal"));
|
|
102
112
|
const revealAll = () => {
|
|
103
113
|
revealElements().forEach((element) => {
|
|
@@ -113,8 +123,15 @@ export function initializeSfMotion(options = {}) {
|
|
|
113
123
|
const existingTimer = settleTimers.get(element);
|
|
114
124
|
if (existingTimer !== undefined)
|
|
115
125
|
window.clearTimeout(existingTimer);
|
|
116
|
-
|
|
117
|
-
|
|
126
|
+
// Zoom animates the media inside an unmoving reveal box. Its transition,
|
|
127
|
+
// including stagger delay, must finish before entering `settled`.
|
|
128
|
+
const transitioning = element.classList.contains("sf-reveal--zoom-in")
|
|
129
|
+
? [element, ...element.querySelectorAll("[data-flowpress-media-frame] > img, [data-flowpress-media-frame] > svg")]
|
|
130
|
+
: [element];
|
|
131
|
+
const transitionTime = Math.max(...transitioning.map(target => {
|
|
132
|
+
const styles = window.getComputedStyle(target);
|
|
133
|
+
return maximumTransitionTimeMs(styles.transitionDuration, styles.transitionDelay);
|
|
134
|
+
}));
|
|
118
135
|
const settle = () => {
|
|
119
136
|
if (revealState(element) === "visible") {
|
|
120
137
|
element.setAttribute(REVEAL_STATE_ATTRIBUTE, "settled");
|
|
@@ -128,7 +145,9 @@ export function initializeSfMotion(options = {}) {
|
|
|
128
145
|
settleTimers.set(element, window.setTimeout(settle, transitionTime + REVEAL_SETTLE_BUFFER_MS));
|
|
129
146
|
};
|
|
130
147
|
const revealOne = (element, event) => {
|
|
131
|
-
const state =
|
|
148
|
+
const state = event === "focus" && element.classList.contains("sf-reveal--zoom-in")
|
|
149
|
+
? "settled"
|
|
150
|
+
: nextRevealState(revealState(element), event);
|
|
132
151
|
element.setAttribute(REVEAL_STATE_ATTRIBUTE, state);
|
|
133
152
|
pending.delete(element);
|
|
134
153
|
if (state === "visible")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion-controller.js","sourceRoot":"","sources":["../../../src/astro/motion/motion-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,oCAAoC,EACpC,kBAAkB,EAClB,0BAA0B,EAC1B,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,GAIvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,GAE1B,MAAM,4BAA4B,CAAC;AAEpC,MAAM,sBAAsB,GAAG,sBAAsB,CAAC;AACtD,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;AAC/E,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,SAAS,UAAU;IACjB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IAEvE,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,cAAc,CAC5B,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAClD,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CACrB,OAAoB,EACpB,MAA0B;IAE1B,OAAO,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,KAAK,MAAM,IAA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QAAQ;YAAE,OAAO;QACtB,MAAM,aAAa,GAAG,UAAU,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,aAAa,EAAE,OAAO,CAAc,kBAAkB,CAAC,CAAC;QACxE,IAAI,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;YAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,eAAe,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACvC,yBAAyB,CAAC,eAAe,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import {\n SF_MOTION_DISABLE_CLASS,\n SF_MOTION_PROTECTED_CONTENT_SELECTOR,\n SF_REVEAL_SELECTOR,\n SF_REVEAL_STAGGER_SELECTOR,\n automaticRevealClasses,\n hasEnoughVisibleArea,\n initialRevealState,\n maximumTransitionTimeMs,\n nextRevealState,\n resolveSfMotionOptions,\n ruleRevealClassChanges,\n staggerRevealDelayMs,\n shouldInitializeMotion,\n type ResolvedSfMotionOptions,\n type SfMotionOptions,\n type SfRevealState,\n} from \"./motion.js\";\nimport {\n getMotionPreference,\n subscribeMotionPreference,\n type MotionPreference,\n} from \"../../motion-preference.js\";\n\nconst REVEAL_STATE_ATTRIBUTE = \"data-sf-reveal-state\";\nconst REVEAL_THRESHOLDS = Array.from({ length: 41 }, (_, index) => index / 40);\nconst REVEAL_SETTLE_BUFFER_MS = 50;\n\nfunction hashTarget(): HTMLElement | null {\n if (!window.location.hash || window.location.hash === \"#\") return null;\n\n try {\n return document.getElementById(\n decodeURIComponent(window.location.hash.slice(1)),\n );\n } catch {\n return null;\n }\n}\n\nfunction containsTarget(\n element: HTMLElement,\n target: HTMLElement | null,\n): boolean {\n return Boolean(target && (element === target || element.contains(target)));\n}\n\nfunction containsProtectedContent(element: HTMLElement): boolean {\n return (\n element.matches(SF_MOTION_PROTECTED_CONTENT_SELECTOR) ||\n Boolean(element.querySelector(SF_MOTION_PROTECTED_CONTENT_SELECTOR))\n );\n}\n\nfunction revealState(element: HTMLElement): SfRevealState {\n const state = element.getAttribute(REVEAL_STATE_ATTRIBUTE);\n if (state === \"visible\" || state === \"settled\") return state;\n return \"pending\";\n}\n\nfunction isMotionDisabled(element: HTMLElement): boolean {\n return Boolean(element.closest(`.${SF_MOTION_DISABLE_CLASS}`));\n}\n\nfunction selectElements(selector: string): NodeListOf<HTMLElement> | null {\n try {\n return document.querySelectorAll<HTMLElement>(selector);\n } catch {\n return null;\n }\n}\n\nfunction inheritAutomaticReveals({\n autoRevealSelectors,\n defaultReveal,\n revealRules,\n}: ResolvedSfMotionOptions): void {\n const ruleMatchedElements = new WeakSet<HTMLElement>();\n revealRules.forEach(({ selector, reveal }) => {\n selectElements(selector)?.forEach((element) => {\n if (isMotionDisabled(element) || ruleMatchedElements.has(element)) return;\n\n const classChanges = ruleRevealClassChanges(element.classList, reveal);\n element.classList.remove(...classChanges.remove);\n element.classList.add(...classChanges.add);\n ruleMatchedElements.add(element);\n });\n });\n\n if (defaultReveal === false) return;\n autoRevealSelectors.forEach((selector) => {\n selectElements(selector)?.forEach((element) => {\n if (isMotionDisabled(element)) return;\n\n element.classList.add(\n ...automaticRevealClasses(element.classList, defaultReveal),\n );\n });\n });\n}\n\n/**\n * Assigns delay by participating reveal, not by direct-child position. A\n * reveal belongs only to its nearest stagger group, so nested groups keep an\n * autonomous sequence even through arbitrary Gutenberg wrappers.\n */\nfunction applyRevealStaggers(): void {\n document\n .querySelectorAll<HTMLElement>(SF_REVEAL_STAGGER_SELECTOR)\n .forEach((group) => {\n const owned = Array.from(\n group.querySelectorAll<HTMLElement>(\".sf-reveal\"),\n ).filter((element) => element.closest(SF_REVEAL_STAGGER_SELECTOR) === group);\n\n owned.forEach((element) => {\n element.style.removeProperty(\"--sf-reveal-delay\");\n });\n owned\n .filter((element) => (\n !element.classList.contains(\"sf-motion-static\") &&\n !isMotionDisabled(element) &&\n !containsProtectedContent(element)\n ))\n .forEach((element, index) => {\n element.style.setProperty(\n \"--sf-reveal-delay\",\n `${staggerRevealDelayMs(index)}ms`,\n );\n });\n });\n}\n\n/**\n * Initializes the project reveal system once per document.\n *\n * Markup is visible by default. Initial-viewport content remains visible unless\n * `revealAboveFold` explicitly opts it into motion; every reveal completes once.\n * Reveals follow the shared motion preference (see `motion-preference.ts`):\n * reduced motion shows everything at once, and allowing it again re-arms the\n * reveals still below the fold without a reload.\n */\nexport function initializeSfMotion(options: SfMotionOptions = {}): void {\n const root = document.documentElement;\n if (!shouldInitializeMotion(root.dataset.sfMotionInitialized)) return;\n root.dataset.sfMotionInitialized = \"true\";\n\n const resolvedOptions = resolveSfMotionOptions(options);\n inheritAutomaticReveals(resolvedOptions);\n applyRevealStaggers();\n\n const revealElements = (): HTMLElement[] =>\n Array.from(document.querySelectorAll<HTMLElement>(\".sf-reveal\"));\n const revealAll = (): void => {\n revealElements().forEach((element) => {\n element.setAttribute(REVEAL_STATE_ATTRIBUTE, \"settled\");\n });\n };\n\n const observed = new WeakSet<HTMLElement>();\n const pending = new Set<HTMLElement>();\n const settleTimers = new WeakMap<HTMLElement, number>();\n let observer: IntersectionObserver | null = null;\n let visibilityFrame = 0;\n\n const settleReveal = (element: HTMLElement): void => {\n const existingTimer = settleTimers.get(element);\n if (existingTimer !== undefined) window.clearTimeout(existingTimer);\n\n const styles = window.getComputedStyle(element);\n const transitionTime = maximumTransitionTimeMs(\n styles.transitionDuration,\n styles.transitionDelay,\n );\n const settle = (): void => {\n if (revealState(element) === \"visible\") {\n element.setAttribute(REVEAL_STATE_ATTRIBUTE, \"settled\");\n }\n settleTimers.delete(element);\n };\n\n if (transitionTime === 0) {\n settle();\n return;\n }\n\n settleTimers.set(\n element,\n window.setTimeout(settle, transitionTime + REVEAL_SETTLE_BUFFER_MS),\n );\n };\n\n const revealOne = (\n element: HTMLElement,\n event: \"focus\" | \"intersect\",\n ): void => {\n const state = nextRevealState(revealState(element), event);\n element.setAttribute(REVEAL_STATE_ATTRIBUTE, state);\n pending.delete(element);\n if (state === \"visible\") settleReveal(element);\n if (observed.has(element)) {\n observer?.unobserve(element);\n observed.delete(element);\n }\n };\n\n /**\n * A reveal's opacity/filter/clip-path apply only to itself, but those\n * properties compose down the DOM: painted inside a still-pending ancestor,\n * an element renders invisible regardless of its own state. Revealing an\n * element therefore also reveals every pending `.sf-reveal` ancestor, so a\n * nested reveal can never end up stuck under a hidden parent.\n */\n const reveal = (\n element: HTMLElement,\n event: \"focus\" | \"intersect\" = \"focus\",\n ): void => {\n revealOne(element, event);\n let ancestor =\n element.parentElement?.closest<HTMLElement>(SF_REVEAL_SELECTOR) ?? null;\n while (ancestor) {\n if (revealState(ancestor) === \"pending\") revealOne(ancestor, event);\n ancestor =\n ancestor.parentElement?.closest<HTMLElement>(SF_REVEAL_SELECTOR) ??\n null;\n }\n };\n\n /**\n * A fully clipped reveal can intersect with a zero-area rectangle. Its first\n * observer entry may arrive before 20% of its height is in view, and no more\n * entries follow while that intersection ratio stays at zero. Check layout\n * bounds on scroll as well so those reveals cannot remain pending in view.\n */\n const checkPendingVisibility = (): void => {\n visibilityFrame = 0;\n const ready: HTMLElement[] = [];\n for (const element of pending) {\n const bounds = element.getBoundingClientRect();\n if (\n bounds.width <= 0 ||\n bounds.height <= 0 ||\n bounds.right <= 0 ||\n bounds.left >= window.innerWidth ||\n !hasEnoughVisibleArea({\n bottom: bounds.bottom,\n height: bounds.height,\n top: bounds.top,\n viewportHeight: window.innerHeight,\n })\n ) {\n continue;\n }\n\n ready.push(element);\n }\n ready.forEach((element) => {\n if (pending.has(element)) reveal(element, \"intersect\");\n });\n };\n\n const scheduleVisibilityCheck = (): void => {\n if (pending.size === 0 || visibilityFrame !== 0) return;\n visibilityFrame = window.requestAnimationFrame(checkPendingVisibility);\n };\n\n window.addEventListener(\"scroll\", scheduleVisibilityCheck, { passive: true });\n document.addEventListener(\"scroll\", scheduleVisibilityCheck, {\n capture: true,\n passive: true,\n });\n window.addEventListener(\"resize\", scheduleVisibilityCheck);\n\n /** Motion reduced: every reveal is simply there, nothing is hidden or animated. */\n const disarm = (): void => {\n observer?.disconnect();\n observer = null;\n pending.clear();\n revealAll();\n root.dataset.sfMotion = \"static\";\n };\n\n /**\n * Motion allowed: hide what is still below the fold and let it enter with the\n * viewport. When motion is allowed again mid-visit (`initial` is false)\n * everything already in view or behind stays put instead of replaying.\n */\n const arm = (initial: boolean): void => {\n if (typeof window.IntersectionObserver !== \"function\") {\n disarm();\n return;\n }\n\n observer?.disconnect();\n pending.clear();\n const entering = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (\n !entry.isIntersecting ||\n !(entry.target instanceof HTMLElement) ||\n !hasEnoughVisibleArea({\n bottom: entry.boundingClientRect.bottom,\n height: entry.boundingClientRect.height,\n top: entry.boundingClientRect.top,\n viewportHeight: window.innerHeight,\n })\n ) {\n return;\n }\n\n reveal(entry.target, \"intersect\");\n });\n },\n {\n rootMargin: \"0px\",\n threshold: REVEAL_THRESHOLDS,\n },\n );\n observer = entering;\n\n const target = hashTarget();\n document\n .querySelectorAll<HTMLElement>(SF_REVEAL_SELECTOR)\n .forEach((element) => {\n if (isMotionDisabled(element)) return;\n\n const bounds = element.getBoundingClientRect();\n const state = !initial && bounds.top < window.innerHeight\n ? \"visible\"\n : initialRevealState({\n bottom: bounds.bottom,\n containsHashTarget: containsTarget(element, target),\n protectedContent: containsProtectedContent(element),\n reducedMotion: false,\n revealAboveFold: resolvedOptions.revealAboveFold,\n top: bounds.top,\n viewportHeight: window.innerHeight,\n });\n element.setAttribute(\n REVEAL_STATE_ATTRIBUTE,\n state === \"visible\" ? \"settled\" : state,\n );\n\n if (state === \"pending\") {\n observed.add(element);\n pending.add(element);\n entering.observe(element);\n }\n });\n\n root.dataset.sfMotion = \"ready\";\n scheduleVisibilityCheck();\n };\n\n let initial = true;\n const applyPreference = (preference: MotionPreference): void => {\n if (preference === \"reduce\") disarm();\n else arm(initial);\n initial = false;\n };\n\n document.addEventListener(\"focusin\", (event) => {\n if (!observer || !(event.target instanceof Element)) return;\n const element = event.target.closest<HTMLElement>(SF_REVEAL_SELECTOR);\n if (element && !isMotionDisabled(element)) reveal(element);\n });\n\n window.addEventListener(\"hashchange\", () => {\n if (!observer) return;\n const targetElement = hashTarget();\n const element = targetElement?.closest<HTMLElement>(SF_REVEAL_SELECTOR);\n if (element && !isMotionDisabled(element)) reveal(element);\n });\n\n applyPreference(getMotionPreference());\n subscribeMotionPreference(applyPreference);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"motion-controller.js","sourceRoot":"","sources":["../../../src/astro/motion/motion-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,oCAAoC,EACpC,kBAAkB,EAClB,0BAA0B,EAC1B,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,GAIvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,GAE1B,MAAM,4BAA4B,CAAC;AAEpC,MAAM,sBAAsB,GAAG,sBAAsB,CAAC;AACtD,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;AAC/E,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,SAAS,UAAU;IACjB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IAEvE,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,cAAc,CAC5B,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAClD,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAA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M,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,eAAe,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACvC,yBAAyB,CAAC,eAAe,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import {\n SF_MOTION_DISABLE_CLASS,\n SF_MOTION_PROTECTED_CONTENT_SELECTOR,\n SF_REVEAL_SELECTOR,\n SF_REVEAL_STAGGER_SELECTOR,\n automaticRevealClasses,\n hasEnoughVisibleArea,\n initialRevealState,\n maximumTransitionTimeMs,\n nextRevealState,\n resolveSfMotionOptions,\n ruleRevealClassChanges,\n staggerRevealDelayMs,\n shouldInitializeMotion,\n type ResolvedSfMotionOptions,\n type SfMotionOptions,\n type SfRevealState,\n} from \"./motion.js\";\nimport {\n getMotionPreference,\n subscribeMotionPreference,\n type MotionPreference,\n} from \"../../motion-preference.js\";\n\nconst REVEAL_STATE_ATTRIBUTE = \"data-sf-reveal-state\";\nconst REVEAL_THRESHOLDS = Array.from({ length: 41 }, (_, index) => index / 40);\nconst REVEAL_SETTLE_BUFFER_MS = 50;\n\nfunction hashTarget(): HTMLElement | null {\n if (!window.location.hash || window.location.hash === \"#\") return null;\n\n try {\n return document.getElementById(\n decodeURIComponent(window.location.hash.slice(1)),\n );\n } catch {\n return null;\n }\n}\n\nfunction containsTarget(\n element: HTMLElement,\n target: HTMLElement | null,\n): boolean {\n return Boolean(target && (element === target || element.contains(target)));\n}\n\nfunction containsProtectedContent(element: HTMLElement): boolean {\n return (\n element.matches(SF_MOTION_PROTECTED_CONTENT_SELECTOR) ||\n Boolean(element.querySelector(SF_MOTION_PROTECTED_CONTENT_SELECTOR))\n );\n}\n\nfunction revealState(element: HTMLElement): SfRevealState {\n const state = element.getAttribute(REVEAL_STATE_ATTRIBUTE);\n if (state === \"visible\" || state === \"settled\") return state;\n return \"pending\";\n}\n\nfunction isMotionDisabled(element: HTMLElement): boolean {\n return Boolean(element.closest(`.${SF_MOTION_DISABLE_CLASS}`));\n}\n\nfunction selectElements(selector: string): NodeListOf<HTMLElement> | null {\n try {\n return document.querySelectorAll<HTMLElement>(selector);\n } catch {\n return null;\n }\n}\n\nfunction inheritAutomaticReveals({\n autoRevealSelectors,\n defaultReveal,\n revealRules,\n}: ResolvedSfMotionOptions): void {\n const ruleMatchedElements = new WeakSet<HTMLElement>();\n revealRules.forEach(({ selector, reveal }) => {\n selectElements(selector)?.forEach((element) => {\n if (isMotionDisabled(element) || ruleMatchedElements.has(element)) return;\n\n const classChanges = ruleRevealClassChanges(element.classList, reveal);\n element.classList.remove(...classChanges.remove);\n element.classList.add(...classChanges.add);\n ruleMatchedElements.add(element);\n });\n });\n\n if (defaultReveal === false) return;\n autoRevealSelectors.forEach((selector) => {\n selectElements(selector)?.forEach((element) => {\n if (isMotionDisabled(element)) return;\n\n element.classList.add(\n ...automaticRevealClasses(element.classList, defaultReveal),\n );\n });\n });\n}\n\n/**\n * Assigns delay by participating reveal, not by direct-child position. A\n * reveal belongs only to its nearest stagger group, so nested groups keep an\n * autonomous sequence even through arbitrary Gutenberg wrappers.\n */\nfunction applyRevealStaggers(): void {\n document\n .querySelectorAll<HTMLElement>(SF_REVEAL_STAGGER_SELECTOR)\n .forEach((group) => {\n const owned = Array.from(\n group.querySelectorAll<HTMLElement>(\".sf-reveal\"),\n ).filter((element) => element.closest(SF_REVEAL_STAGGER_SELECTOR) === group);\n\n owned.forEach((element) => {\n element.style.removeProperty(\"--sf-reveal-delay\");\n });\n owned\n .filter((element) => (\n !element.classList.contains(\"sf-motion-static\") &&\n !isMotionDisabled(element) &&\n !containsProtectedContent(element)\n ))\n .forEach((element, index) => {\n element.style.setProperty(\n \"--sf-reveal-delay\",\n `${staggerRevealDelayMs(index)}ms`,\n );\n });\n });\n}\n\n/**\n * Initializes the project reveal system once per document.\n *\n * Markup is visible by default. Initial-viewport content remains visible unless\n * `revealAboveFold` explicitly opts it into motion; every reveal completes once.\n * Reveals follow the shared motion preference (see `motion-preference.ts`):\n * reduced motion shows everything at once, and allowing it again re-arms the\n * reveals still below the fold without a reload.\n */\nexport function initializeSfMotion(options: SfMotionOptions = {}): void {\n const root = document.documentElement;\n if (!shouldInitializeMotion(root.dataset.sfMotionInitialized)) return;\n root.dataset.sfMotionInitialized = \"true\";\n\n const resolvedOptions = resolveSfMotionOptions(options);\n inheritAutomaticReveals(resolvedOptions);\n applyRevealStaggers();\n\n // Custom media classes may round the image instead of its block. Keep that\n // authored edge on the stationary frame while the inner pixels zoom.\n document.querySelectorAll<HTMLElement>(\".sf-reveal--zoom-in [data-flowpress-media-frame]\").forEach(frame => {\n const media = frame.querySelector(\"img, svg\");\n if (!media) return;\n const radius = window.getComputedStyle(media).borderRadius;\n if (radius && !/^0px(?: 0px)*$/.test(radius)) frame.style.borderRadius = radius;\n });\n\n const revealElements = (): HTMLElement[] =>\n Array.from(document.querySelectorAll<HTMLElement>(\".sf-reveal\"));\n const revealAll = (): void => {\n revealElements().forEach((element) => {\n element.setAttribute(REVEAL_STATE_ATTRIBUTE, \"settled\");\n });\n };\n\n const observed = new WeakSet<HTMLElement>();\n const pending = new Set<HTMLElement>();\n const settleTimers = new WeakMap<HTMLElement, number>();\n let observer: IntersectionObserver | null = null;\n let visibilityFrame = 0;\n\n const settleReveal = (element: HTMLElement): void => {\n const existingTimer = settleTimers.get(element);\n if (existingTimer !== undefined) window.clearTimeout(existingTimer);\n\n // Zoom animates the media inside an unmoving reveal box. Its transition,\n // including stagger delay, must finish before entering `settled`.\n const transitioning = element.classList.contains(\"sf-reveal--zoom-in\")\n ? [element, ...element.querySelectorAll<HTMLElement>(\"[data-flowpress-media-frame] > img, [data-flowpress-media-frame] > svg\")]\n : [element];\n const transitionTime = Math.max(...transitioning.map(target => {\n const styles = window.getComputedStyle(target);\n return maximumTransitionTimeMs(styles.transitionDuration, styles.transitionDelay);\n }));\n const settle = (): void => {\n if (revealState(element) === \"visible\") {\n element.setAttribute(REVEAL_STATE_ATTRIBUTE, \"settled\");\n }\n settleTimers.delete(element);\n };\n\n if (transitionTime === 0) {\n settle();\n return;\n }\n\n settleTimers.set(\n element,\n window.setTimeout(settle, transitionTime + REVEAL_SETTLE_BUFFER_MS),\n );\n };\n\n const revealOne = (\n element: HTMLElement,\n event: \"focus\" | \"intersect\",\n ): void => {\n const state = event === \"focus\" && element.classList.contains(\"sf-reveal--zoom-in\")\n ? \"settled\"\n : nextRevealState(revealState(element), event);\n element.setAttribute(REVEAL_STATE_ATTRIBUTE, state);\n pending.delete(element);\n if (state === \"visible\") settleReveal(element);\n if (observed.has(element)) {\n observer?.unobserve(element);\n observed.delete(element);\n }\n };\n\n /**\n * A reveal's opacity/filter/clip-path apply only to itself, but those\n * properties compose down the DOM: painted inside a still-pending ancestor,\n * an element renders invisible regardless of its own state. Revealing an\n * element therefore also reveals every pending `.sf-reveal` ancestor, so a\n * nested reveal can never end up stuck under a hidden parent.\n */\n const reveal = (\n element: HTMLElement,\n event: \"focus\" | \"intersect\" = \"focus\",\n ): void => {\n revealOne(element, event);\n let ancestor =\n element.parentElement?.closest<HTMLElement>(SF_REVEAL_SELECTOR) ?? null;\n while (ancestor) {\n if (revealState(ancestor) === \"pending\") revealOne(ancestor, event);\n ancestor =\n ancestor.parentElement?.closest<HTMLElement>(SF_REVEAL_SELECTOR) ??\n null;\n }\n };\n\n /**\n * A fully clipped reveal can intersect with a zero-area rectangle. Its first\n * observer entry may arrive before 20% of its height is in view, and no more\n * entries follow while that intersection ratio stays at zero. Check layout\n * bounds on scroll as well so those reveals cannot remain pending in view.\n */\n const checkPendingVisibility = (): void => {\n visibilityFrame = 0;\n const ready: HTMLElement[] = [];\n for (const element of pending) {\n const bounds = element.getBoundingClientRect();\n if (\n bounds.width <= 0 ||\n bounds.height <= 0 ||\n bounds.right <= 0 ||\n bounds.left >= window.innerWidth ||\n !hasEnoughVisibleArea({\n bottom: bounds.bottom,\n height: bounds.height,\n top: bounds.top,\n viewportHeight: window.innerHeight,\n })\n ) {\n continue;\n }\n\n ready.push(element);\n }\n ready.forEach((element) => {\n if (pending.has(element)) reveal(element, \"intersect\");\n });\n };\n\n const scheduleVisibilityCheck = (): void => {\n if (pending.size === 0 || visibilityFrame !== 0) return;\n visibilityFrame = window.requestAnimationFrame(checkPendingVisibility);\n };\n\n window.addEventListener(\"scroll\", scheduleVisibilityCheck, { passive: true });\n document.addEventListener(\"scroll\", scheduleVisibilityCheck, {\n capture: true,\n passive: true,\n });\n window.addEventListener(\"resize\", scheduleVisibilityCheck);\n\n /** Motion reduced: every reveal is simply there, nothing is hidden or animated. */\n const disarm = (): void => {\n observer?.disconnect();\n observer = null;\n pending.clear();\n revealAll();\n root.dataset.sfMotion = \"static\";\n };\n\n /**\n * Motion allowed: hide what is still below the fold and let it enter with the\n * viewport. When motion is allowed again mid-visit (`initial` is false)\n * everything already in view or behind stays put instead of replaying.\n */\n const arm = (initial: boolean): void => {\n if (typeof window.IntersectionObserver !== \"function\") {\n disarm();\n return;\n }\n\n observer?.disconnect();\n pending.clear();\n const entering = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (\n !entry.isIntersecting ||\n !(entry.target instanceof HTMLElement) ||\n !hasEnoughVisibleArea({\n bottom: entry.boundingClientRect.bottom,\n height: entry.boundingClientRect.height,\n top: entry.boundingClientRect.top,\n viewportHeight: window.innerHeight,\n })\n ) {\n return;\n }\n\n reveal(entry.target, \"intersect\");\n });\n },\n {\n rootMargin: \"0px\",\n threshold: REVEAL_THRESHOLDS,\n },\n );\n observer = entering;\n\n const target = hashTarget();\n document\n .querySelectorAll<HTMLElement>(SF_REVEAL_SELECTOR)\n .forEach((element) => {\n if (isMotionDisabled(element)) return;\n\n const bounds = element.getBoundingClientRect();\n const state = !initial && bounds.top < window.innerHeight\n ? \"visible\"\n : initialRevealState({\n bottom: bounds.bottom,\n containsHashTarget: containsTarget(element, target),\n protectedContent: containsProtectedContent(element),\n reducedMotion: false,\n revealAboveFold: resolvedOptions.revealAboveFold,\n top: bounds.top,\n viewportHeight: window.innerHeight,\n });\n element.setAttribute(\n REVEAL_STATE_ATTRIBUTE,\n state === \"visible\" ? \"settled\" : state,\n );\n\n if (state === \"pending\") {\n observed.add(element);\n pending.add(element);\n entering.observe(element);\n }\n });\n\n root.dataset.sfMotion = \"ready\";\n scheduleVisibilityCheck();\n };\n\n let initial = true;\n const applyPreference = (preference: MotionPreference): void => {\n if (preference === \"reduce\") disarm();\n else arm(initial);\n initial = false;\n };\n\n document.addEventListener(\"focusin\", (event) => {\n if (!observer || !(event.target instanceof Element)) return;\n const element = event.target.closest<HTMLElement>(SF_REVEAL_SELECTOR);\n if (element && !isMotionDisabled(element)) reveal(element);\n });\n\n window.addEventListener(\"hashchange\", () => {\n if (!observer) return;\n const targetElement = hashTarget();\n const element = targetElement?.closest<HTMLElement>(SF_REVEAL_SELECTOR);\n if (element && !isMotionDisabled(element)) reveal(element);\n });\n\n applyPreference(getMotionPreference());\n subscribeMotionPreference(applyPreference);\n}\n"]}
|
|
@@ -148,6 +148,15 @@ export function initializeSfMotion(options: SfMotionOptions = {}): void {
|
|
|
148
148
|
inheritAutomaticReveals(resolvedOptions);
|
|
149
149
|
applyRevealStaggers();
|
|
150
150
|
|
|
151
|
+
// Custom media classes may round the image instead of its block. Keep that
|
|
152
|
+
// authored edge on the stationary frame while the inner pixels zoom.
|
|
153
|
+
document.querySelectorAll<HTMLElement>(".sf-reveal--zoom-in [data-flowpress-media-frame]").forEach(frame => {
|
|
154
|
+
const media = frame.querySelector("img, svg");
|
|
155
|
+
if (!media) return;
|
|
156
|
+
const radius = window.getComputedStyle(media).borderRadius;
|
|
157
|
+
if (radius && !/^0px(?: 0px)*$/.test(radius)) frame.style.borderRadius = radius;
|
|
158
|
+
});
|
|
159
|
+
|
|
151
160
|
const revealElements = (): HTMLElement[] =>
|
|
152
161
|
Array.from(document.querySelectorAll<HTMLElement>(".sf-reveal"));
|
|
153
162
|
const revealAll = (): void => {
|
|
@@ -166,11 +175,15 @@ export function initializeSfMotion(options: SfMotionOptions = {}): void {
|
|
|
166
175
|
const existingTimer = settleTimers.get(element);
|
|
167
176
|
if (existingTimer !== undefined) window.clearTimeout(existingTimer);
|
|
168
177
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
178
|
+
// Zoom animates the media inside an unmoving reveal box. Its transition,
|
|
179
|
+
// including stagger delay, must finish before entering `settled`.
|
|
180
|
+
const transitioning = element.classList.contains("sf-reveal--zoom-in")
|
|
181
|
+
? [element, ...element.querySelectorAll<HTMLElement>("[data-flowpress-media-frame] > img, [data-flowpress-media-frame] > svg")]
|
|
182
|
+
: [element];
|
|
183
|
+
const transitionTime = Math.max(...transitioning.map(target => {
|
|
184
|
+
const styles = window.getComputedStyle(target);
|
|
185
|
+
return maximumTransitionTimeMs(styles.transitionDuration, styles.transitionDelay);
|
|
186
|
+
}));
|
|
174
187
|
const settle = (): void => {
|
|
175
188
|
if (revealState(element) === "visible") {
|
|
176
189
|
element.setAttribute(REVEAL_STATE_ATTRIBUTE, "settled");
|
|
@@ -193,7 +206,9 @@ export function initializeSfMotion(options: SfMotionOptions = {}): void {
|
|
|
193
206
|
element: HTMLElement,
|
|
194
207
|
event: "focus" | "intersect",
|
|
195
208
|
): void => {
|
|
196
|
-
const state =
|
|
209
|
+
const state = event === "focus" && element.classList.contains("sf-reveal--zoom-in")
|
|
210
|
+
? "settled"
|
|
211
|
+
: nextRevealState(revealState(element), event);
|
|
197
212
|
element.setAttribute(REVEAL_STATE_ATTRIBUTE, state);
|
|
198
213
|
pending.delete(element);
|
|
199
214
|
if (state === "visible") settleReveal(element);
|
|
@@ -48,6 +48,55 @@ html[data-sf-motion-preference="full"] {
|
|
|
48
48
|
--sf-reveal-from-clip: inset(2%);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
.sf-reveal--zoom-in {
|
|
52
|
+
--sf-reveal-duration: 2000ms;
|
|
53
|
+
--sf-reveal-from-scale: 1.25;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Only the media moves. Captions, links, the observer box and layout stay put. */
|
|
57
|
+
.sf-reveal--zoom-in [data-flowpress-media-frame] {
|
|
58
|
+
overflow: clip;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.sf-reveal--zoom-in [data-flowpress-media-frame] > :is(img, svg) {
|
|
62
|
+
transform-origin: var(--sf-reveal-zoom-origin, center);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
html[data-sf-motion="ready"]
|
|
66
|
+
.sf-reveal.sf-reveal--zoom-in:is([data-sf-reveal-state="pending"], [data-sf-reveal-state="visible"]):not(.sf-motion-static) {
|
|
67
|
+
opacity: 1;
|
|
68
|
+
transform: none;
|
|
69
|
+
clip-path: none;
|
|
70
|
+
filter: none;
|
|
71
|
+
transition: none;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
html[data-sf-motion="ready"]
|
|
75
|
+
.sf-reveal.sf-reveal--zoom-in[data-sf-reveal-state="pending"]:not(.sf-motion-static)
|
|
76
|
+
[data-flowpress-media-frame] > :is(img, svg) {
|
|
77
|
+
transform: scale(var(--sf-reveal-from-scale));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
html[data-sf-motion="ready"]
|
|
81
|
+
.sf-reveal.sf-reveal--zoom-in[data-sf-reveal-state="visible"]:not(.sf-motion-static)
|
|
82
|
+
[data-flowpress-media-frame] > :is(img, svg) {
|
|
83
|
+
transform: scale(1);
|
|
84
|
+
transition: transform var(--sf-reveal-duration) var(--sf-motion-ease-soft) var(--sf-reveal-delay);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* Release animation-only clipping; also cover live preference changes. */
|
|
88
|
+
.sf-reveal--zoom-in[data-sf-reveal-state="settled"] [data-flowpress-media-frame],
|
|
89
|
+
.sf-reveal--zoom-in.sf-motion-static [data-flowpress-media-frame] {
|
|
90
|
+
overflow: visible;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
html[data-sf-motion="static"] .sf-reveal--zoom-in [data-flowpress-media-frame] > :is(img, svg),
|
|
94
|
+
html[data-sf-motion] .sf-motion-disable .sf-reveal--zoom-in [data-flowpress-media-frame] > :is(img, svg),
|
|
95
|
+
html[data-sf-motion] .sf-motion-disable.sf-reveal--zoom-in [data-flowpress-media-frame] > :is(img, svg) {
|
|
96
|
+
transform: none !important;
|
|
97
|
+
transition: none !important;
|
|
98
|
+
}
|
|
99
|
+
|
|
51
100
|
.sf-reveal--blur {
|
|
52
101
|
--sf-reveal-duration: 800ms;
|
|
53
102
|
--sf-reveal-opacity-duration: 620ms;
|
|
@@ -437,7 +486,8 @@ html[data-sf-motion-preference="reduce"] {
|
|
|
437
486
|
scroll-behavior: auto;
|
|
438
487
|
}
|
|
439
488
|
|
|
440
|
-
html[data-sf-motion-preference="reduce"][data-sf-motion] .sf-reveal
|
|
489
|
+
html[data-sf-motion-preference="reduce"][data-sf-motion] .sf-reveal,
|
|
490
|
+
html[data-sf-motion-preference="reduce"][data-sf-motion] .sf-reveal--zoom-in [data-flowpress-media-frame] > :is(img, svg) {
|
|
441
491
|
clip-path: none !important;
|
|
442
492
|
filter: none !important;
|
|
443
493
|
opacity: 1 !important;
|
|
@@ -466,7 +516,8 @@ html[data-sf-motion-preference="reduce"] *::after {
|
|
|
466
516
|
scroll-behavior: auto;
|
|
467
517
|
}
|
|
468
518
|
|
|
469
|
-
html:not([data-sf-motion-preference])[data-sf-motion] .sf-reveal
|
|
519
|
+
html:not([data-sf-motion-preference])[data-sf-motion] .sf-reveal,
|
|
520
|
+
html:not([data-sf-motion-preference])[data-sf-motion] .sf-reveal--zoom-in [data-flowpress-media-frame] > :is(img, svg) {
|
|
470
521
|
clip-path: none !important;
|
|
471
522
|
filter: none !important;
|
|
472
523
|
opacity: 1 !important;
|
|
@@ -486,7 +537,8 @@ html[data-sf-motion-preference="reduce"] *::after {
|
|
|
486
537
|
}
|
|
487
538
|
|
|
488
539
|
@media print {
|
|
489
|
-
html[data-sf-motion] .sf-reveal
|
|
540
|
+
html[data-sf-motion] .sf-reveal,
|
|
541
|
+
html[data-sf-motion] .sf-reveal--zoom-in [data-flowpress-media-frame] > :is(img, svg) {
|
|
490
542
|
clip-path: none !important;
|
|
491
543
|
filter: none !important;
|
|
492
544
|
opacity: 1 !important;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../../src/astro/motion/motion.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,sCAAsC,CAAC;AAEtE,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AAEzD,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAE3D,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,eAAO,MAAM,0BAA0B,uBAAuB,CAAC;AAE/D,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,wEAAwE;AACxE,eAAO,MAAM,oCAAoC,
|
|
1
|
+
{"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../../src/astro/motion/motion.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,sCAAsC,CAAC;AAEtE,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AAEzD,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAE3D,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,eAAO,MAAM,0BAA0B,uBAAuB,CAAC;AAE/D,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,wEAAwE;AACxE,eAAO,MAAM,oCAAoC,QAUtC,CAAC;AAIZ,MAAM,MAAM,gBAAgB,GAAG,cAAc,MAAM,EAAE,CAAC;AAEtD,MAAM,MAAM,eAA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CAAC,QAAQ,EAAE,EAAE;YACvC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,QAAQ,SAAS,uBAAuB,GAAG,QAAQ,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC;QACjG,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;IAChE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["export const SF_REVEAL_SELECTOR = \".sf-reveal:not(.sf-motion-static)\";\n\nexport const SF_REVEAL_CLASS = \"sf-reveal\";\n\nexport const SF_MOTION_STATIC_CLASS = \"sf-motion-static\";\n\nexport const SF_MOTION_DISABLE_CLASS = \"sf-motion-disable\";\n\nexport const SF_MOTION_DRAWER_EXIT_MS = 820;\n\nexport const SF_REVEAL_VISIBLE_RATIO = 0.2;\n\nexport const SF_REVEAL_STAGGER_SELECTOR = \".sf-reveal-stagger\";\n\nexport const SF_REVEAL_STAGGER_STEP_MS = 90;\n\nexport const SF_REVEAL_STAGGER_MAX_MS = 450;\n\n/** Reveals matching or containing this content always start visible. */\nexport const SF_MOTION_PROTECTED_CONTENT_SELECTOR = [\n \".flowpress-hero\",\n 'img[fetchpriority=\"high\"]',\n 'img[loading=\"eager\"]',\n \"video[autoplay]\",\n \"form\",\n \"[aria-live]\",\n '[role=\"alert\"]',\n '[role=\"status\"]',\n].join(\",\");\n\nconst SF_REVEAL_MODIFIER_PATTERN = /^sf-reveal--\\S+$/;\n\nexport type SfRevealModifier = `sf-reveal--${string}`;\n\nexport type SfDefaultReveal = false | SfRevealModifier;\n\nexport interface SfRevealRule {\n /** Any selector accepted by `document.querySelectorAll`. */\n selector: string;\n /** Reveal modifier enforced on every matching element. */\n reveal: SfRevealModifier;\n}\n\nexport interface SfRevealClassChanges {\n add: string[];\n remove: SfRevealModifier[];\n}\n\nexport interface SfMotionOptions {\n /**\n * Allows reveal elements already in the initial viewport to animate.\n * Defaults to `false`, so initial content is immediately available.\n */\n revealAboveFold?: boolean;\n /**\n * Ordered selector-specific reveal rules. The first matching rule wins and\n * enforces its modifier. Any valid CSS selector may be used.\n */\n revealRules?: readonly SfRevealRule[];\n /**\n * Preset applied to automatically selected elements. `false` keeps the\n * reveal system strictly opt-in.\n */\n defaultReveal?: SfDefaultReveal;\n /**\n * Standard CSS selectors. Tags, classes, IDs, attributes and combinations\n * can be mixed in the same array.\n */\n autoRevealSelectors?: readonly string[];\n}\n\nexport interface ResolvedSfMotionOptions {\n autoRevealSelectors: string[];\n defaultReveal: SfDefaultReveal;\n revealAboveFold: boolean;\n revealRules: SfRevealRule[];\n}\n\nexport type SfRevealState = \"pending\" | \"visible\" | \"settled\";\n\nexport interface InitialRevealStateInput {\n bottom: number;\n containsHashTarget: boolean;\n protectedContent: boolean;\n reducedMotion: boolean;\n revealAboveFold: boolean;\n top: number;\n viewportHeight: number;\n}\n\nexport interface RevealVisibilityInput {\n bottom: number;\n height: number;\n top: number;\n viewportHeight: number;\n}\n\nexport function isSfRevealModifier(value: unknown): value is SfRevealModifier {\n return typeof value === \"string\" && SF_REVEAL_MODIFIER_PATTERN.test(value);\n}\n\nfunction normalizeSelectors(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n\n return Array.from(\n new Set(\n value\n .filter((selector): selector is string => typeof selector === \"string\")\n .map((selector) => selector.trim())\n .filter(Boolean),\n ),\n );\n}\n\nfunction normalizeRevealRules(value: unknown): SfRevealRule[] {\n if (!Array.isArray(value)) return [];\n\n const seenSelectors = new Set<string>();\n return value.flatMap((rule: unknown) => {\n if (!rule || typeof rule !== \"object\") return [];\n\n const candidate = rule as Partial<SfRevealRule>;\n const selector =\n typeof candidate.selector === \"string\" ? candidate.selector.trim() : \"\";\n if (\n !selector ||\n seenSelectors.has(selector) ||\n !isSfRevealModifier(candidate.reveal)\n ) {\n return [];\n }\n\n seenSelectors.add(selector);\n return [{ selector, reveal: candidate.reveal }];\n });\n}\n\n/**\n * Normalizes server- or client-provided configuration. Invalid values fail\n * open by disabling automatic reveals; empty and duplicate selectors are\n * removed without changing their order.\n */\nexport function resolveSfMotionOptions(\n options: SfMotionOptions = {},\n): ResolvedSfMotionOptions {\n const defaultReveal = isSfRevealModifier(options.defaultReveal)\n ? options.defaultReveal\n : false;\n return {\n autoRevealSelectors: normalizeSelectors(options.autoRevealSelectors),\n defaultReveal,\n revealAboveFold: options.revealAboveFold === true,\n revealRules: normalizeRevealRules(options.revealRules),\n };\n}\n\n/** Exact class mutation required by an authoritative selector rule. */\nexport function ruleRevealClassChanges(\n existingClasses: Iterable<string>,\n reveal: SfRevealModifier,\n): SfRevealClassChanges {\n const classes = Array.from(existingClasses);\n if (\n classes.includes(SF_MOTION_STATIC_CLASS) ||\n classes.includes(SF_MOTION_DISABLE_CLASS)\n ) {\n return { add: [], remove: [] };\n }\n\n return {\n add: [\n ...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),\n ...(classes.includes(reveal) ? [] : [reveal]),\n ],\n remove: classes\n .filter(isSfRevealModifier)\n .filter((modifier) => modifier !== reveal),\n };\n}\n\n/** Delay for a zero-based participant index in a reveal stagger group. */\nexport function staggerRevealDelayMs(index: number): number {\n if (!Number.isFinite(index) || index <= 0) return 0;\n return Math.min(\n Math.floor(index) * SF_REVEAL_STAGGER_STEP_MS,\n SF_REVEAL_STAGGER_MAX_MS,\n );\n}\n\n/**\n * Returns only the classes that automatic inheritance must add. Explicit\n * modifiers win over the configured default and `sf-motion-static` remains a\n * complete opt-out.\n */\nexport function automaticRevealClasses(\n existingClasses: Iterable<string>,\n defaultReveal: SfDefaultReveal,\n): string[] {\n if (defaultReveal === false) return [];\n\n const classes = Array.from(existingClasses);\n if (\n classes.includes(SF_MOTION_STATIC_CLASS) ||\n classes.includes(SF_MOTION_DISABLE_CLASS)\n ) {\n return [];\n }\n\n return [\n ...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),\n ...(classes.some(isSfRevealModifier) ? [] : [defaultReveal]),\n ];\n}\n\nfunction cssTimeToMs(value: string): number {\n const normalized = value.trim();\n const amount = Number.parseFloat(normalized);\n if (!Number.isFinite(amount)) return 0;\n\n return normalized.endsWith(\"ms\") ? amount : amount * 1000;\n}\n\n/** Returns the longest combined CSS transition duration and delay. */\nexport function maximumTransitionTimeMs(\n transitionDuration: string,\n transitionDelay: string,\n): number {\n const durations = transitionDuration.split(\",\").map(cssTimeToMs);\n const delays = transitionDelay.split(\",\").map(cssTimeToMs);\n const itemCount = Math.max(durations.length, delays.length);\n\n return Array.from({ length: itemCount }, (_, index) => {\n const duration = durations[index % durations.length] ?? 0;\n const delay = delays[index % delays.length] ?? 0;\n return Math.max(0, duration + delay);\n }).reduce((maximum, value) => Math.max(maximum, value), 0);\n}\n\n/**\n * Initial viewport content stays static unless the project explicitly enables\n * above-the-fold reveals. Deep links and protected content remain visible.\n */\nexport function initialRevealState({\n bottom,\n containsHashTarget,\n protectedContent,\n reducedMotion,\n revealAboveFold,\n top,\n viewportHeight,\n}: InitialRevealStateInput): SfRevealState {\n if (\n reducedMotion ||\n containsHashTarget ||\n protectedContent\n ) {\n return \"visible\";\n }\n\n // reveal share of its height) waits for the scroll instead of appearing\n // statically; content already scrolled past the top stays visible.\n if (\n !revealAboveFold &&\n bottom > 0 &&\n top < viewportHeight &&\n (top < 0 ||\n hasEnoughVisibleArea({\n bottom,\n height: Math.max(0, bottom - top),\n top,\n viewportHeight,\n }))\n ) {\n return \"visible\";\n }\n\n return \"pending\";\n}\n\n/**\n * Reveal ordinary content once 20% of its perceivable height is visible.\n * For elements taller than the viewport, the viewport height is the reference.\n */\nexport function hasEnoughVisibleArea({\n bottom,\n height,\n top,\n viewportHeight,\n}: RevealVisibilityInput): boolean {\n if (height <= 0 || viewportHeight <= 0) return true;\n\n const visibleHeight = Math.max(\n 0,\n Math.min(bottom, viewportHeight) - Math.max(top, 0),\n );\n // The 1px tolerance below must not let thin elements such as a 1px <hr>\n // pass while they are still entirely outside the viewport.\n if (visibleHeight <= 0) return false;\n\n const requiredHeight =\n Math.min(height, viewportHeight) * SF_REVEAL_VISIBLE_RATIO;\n\n return visibleHeight + 1 >= requiredHeight;\n}\n\n/**\n * Reveal is deliberately one-way: focus and viewport entry can complete it,\n * while leaving the viewport never conceals content again.\n */\nexport function nextRevealState(\n current: SfRevealState,\n event: \"focus\" | \"intersect\" | \"leave\",\n): SfRevealState {\n if (current === \"settled\") return \"settled\";\n\n if (current === \"visible\" || event === \"focus\" || event === \"intersect\") {\n return \"visible\";\n }\n\n return \"pending\";\n}\n\nexport function shouldInitializeMotion(\n initialized: string | undefined,\n): boolean {\n return initialized !== \"true\";\n}\n\n/** `<html data-sf-motion>` value from the head bootstrap until the controller arms. */\nexport const SF_MOTION_BOOT_STATE = \"boot\";\n\n/** Failsafe: boot-hidden content shows anyway if the controller never arms. */\nexport const SF_MOTION_BOOT_FAILSAFE_MS = 3000;\n\n/**\n * Modifiers whose pending state keeps the element visible and hides only a\n * drawn decoration, mapped to the pseudo-element carrying it.\n */\nexport const SF_REVEAL_DECORATION_PSEUDOS: Readonly<\n Record<SfRevealModifier, \"::before\" | \"::after\">\n> = {\n \"sf-reveal--accordion-line\": \"::after\",\n};\n\n// Everything the controller leaves visible: opt-outs, protected content and the hash target.\n// :has() makes :not() invalid where unsupported, which drops the rule: content stays visible.\nconst SF_MOTION_BOOT_EXCLUDED = [\n `.${SF_MOTION_STATIC_CLASS}`,\n `.${SF_MOTION_DISABLE_CLASS}`,\n `.${SF_MOTION_DISABLE_CLASS} *`,\n SF_MOTION_PROTECTED_CONTENT_SELECTOR,\n `:has(${SF_MOTION_PROTECTED_CONTENT_SELECTOR})`,\n \":target\",\n \":has(:target)\",\n].join(\", \");\n\n/**\n * Inline `<head>` script, placed after the motion preference bootstrap: marks\n * the document as booting when the controller will arm reveals, so the CSS of\n * `motionBootCss` hides them before first paint.\n */\nexport function motionBootScript(preferenceAttribute: string): string {\n const attribute = JSON.stringify(preferenceAttribute);\n const state = JSON.stringify(SF_MOTION_BOOT_STATE);\n return `(()=>{const r=document.documentElement;if(r.getAttribute(${attribute})===\"full\"&&\"IntersectionObserver\"in window&&!r.dataset.sfMotion)r.dataset.sfMotion=${state}})()`;\n}\n\n/**\n * Pre-paint counterpart of the controller for `revealAboveFold`: hides what the\n * controller will arm (authored reveals, rule and automatic selectors) while\n * `<html data-sf-motion=\"boot\">`, so content is never painted, hidden, then\n * revealed. Each selector gets its own rule: an invalid one only drops itself.\n * Like the controller, the first matching rule decides the modifier.\n * Portabile in FlowPress: docs/pilots/primo-paint-stabile.md\n */\nexport function motionBootCss(options: SfMotionOptions = {}): string {\n const { autoRevealSelectors, defaultReveal, revealAboveFold, revealRules } =\n resolveSfMotionOptions(options);\n if (!revealAboveFold) return \"\";\n\n const root = `html[data-sf-motion=\"${SF_MOTION_BOOT_STATE}\"]`;\n const failsafe = `${SF_MOTION_BOOT_FAILSAFE_MS}ms`;\n const decorations = Object.entries(SF_REVEAL_DECORATION_PSEUDOS) as [\n SfRevealModifier,\n string,\n ][];\n const hide = (target: string, reveal: SfRevealModifier | null): string => {\n const pseudo = reveal ? (SF_REVEAL_DECORATION_PSEUDOS[reveal] ?? \"\") : \"\";\n return `${root} ${target}${pseudo}{opacity:0;animation:sf-motion-boot-failsafe 0s linear ${failsafe} forwards}`;\n };\n const rules: string[] = [];\n\n // Authored reveals keep their own modifier; decorations hide their pseudo.\n const decorationClasses = decorations.map(([modifier]) => `.${modifier}`);\n rules.push(hide(\n `.${SF_REVEAL_CLASS}:not(${[SF_MOTION_BOOT_EXCLUDED, ...decorationClasses].join(\", \")})`,\n null,\n ));\n decorations.forEach(([modifier]) => {\n rules.push(hide(`.${SF_REVEAL_CLASS}.${modifier}:not(${SF_MOTION_BOOT_EXCLUDED})`, modifier));\n });\n\n const earlier: string[] = [];\n revealRules.forEach(({ selector, reveal }) => {\n const shadowed = earlier.length ? `, :is(${earlier.join(\", \")})` : \"\";\n rules.push(hide(`:is(${selector}):not(${SF_MOTION_BOOT_EXCLUDED}${shadowed})`, reveal));\n earlier.push(selector);\n });\n\n if (defaultReveal !== false) {\n const shadowed = earlier.length ? `, :is(${earlier.join(\", \")})` : \"\";\n autoRevealSelectors.forEach((selector) => {\n rules.push(hide(`:is(${selector}):not(${SF_MOTION_BOOT_EXCLUDED}${shadowed})`, defaultReveal));\n });\n }\n\n rules.push(\"@keyframes sf-motion-boot-failsafe{to{opacity:1}}\");\n return rules.join(\"\\n\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"motion.js","sourceRoot":"","sources":["../../../src/astro/motion/motion.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,mCAAmC,CAAC;AAEtE,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAE3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAEzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAE3D,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,MAAM,CAAC,MAAM,0BAA0B,GAAG,oBAAoB,CAAC;AAE/D,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAE5C,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C,wEAAwE;AACxE,MAAM,CAAC,MAAM,oCAAoC,GAAG;IAClD,iBAAiB;IACjB,2BAA2B;IAC3B,sBAAsB;IACtB,iCAAiC;IACjC,iBAAiB;IACjB,MAAM;IACN,aAAa;IACb,gBAAgB;IAChB,iBAAiB;CAClB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,MAAM,0BAA0B,GAAG,kBAAkB,CAAC;AAmEtD,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,0BAA0B,CAAC,IAAI,CAAC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S,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,mBAAmB,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YACvC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,QAAQ,SAAS,uBAAuB,GAAG,QAAQ,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC;QACjG,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;IAChE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["export const SF_REVEAL_SELECTOR = \".sf-reveal:not(.sf-motion-static)\";\n\nexport const SF_REVEAL_CLASS = \"sf-reveal\";\n\nexport const SF_MOTION_STATIC_CLASS = \"sf-motion-static\";\n\nexport const SF_MOTION_DISABLE_CLASS = \"sf-motion-disable\";\n\nexport const SF_MOTION_DRAWER_EXIT_MS = 820;\n\nexport const SF_REVEAL_VISIBLE_RATIO = 0.2;\n\nexport const SF_REVEAL_STAGGER_SELECTOR = \".sf-reveal-stagger\";\n\nexport const SF_REVEAL_STAGGER_STEP_MS = 90;\n\nexport const SF_REVEAL_STAGGER_MAX_MS = 450;\n\n/** Reveals matching or containing this content always start visible. */\nexport const SF_MOTION_PROTECTED_CONTENT_SELECTOR = [\n \".flowpress-hero\",\n 'img[fetchpriority=\"high\"]',\n 'img[loading=\"eager\"]',\n \"[data-flowpress-media-priority]\",\n \"video[autoplay]\",\n \"form\",\n \"[aria-live]\",\n '[role=\"alert\"]',\n '[role=\"status\"]',\n].join(\",\");\n\nconst SF_REVEAL_MODIFIER_PATTERN = /^sf-reveal--\\S+$/;\n\nexport type SfRevealModifier = `sf-reveal--${string}`;\n\nexport type SfDefaultReveal = false | SfRevealModifier;\n\nexport interface SfRevealRule {\n /** Any selector accepted by `document.querySelectorAll`. */\n selector: string;\n /** Reveal modifier enforced on every matching element. */\n reveal: SfRevealModifier;\n}\n\nexport interface SfRevealClassChanges {\n add: string[];\n remove: SfRevealModifier[];\n}\n\nexport interface SfMotionOptions {\n /**\n * Allows reveal elements already in the initial viewport to animate.\n * Defaults to `false`, so initial content is immediately available.\n */\n revealAboveFold?: boolean;\n /**\n * Ordered selector-specific reveal rules. The first matching rule wins and\n * enforces its modifier. Any valid CSS selector may be used.\n */\n revealRules?: readonly SfRevealRule[];\n /**\n * Preset applied to automatically selected elements. `false` keeps the\n * reveal system strictly opt-in.\n */\n defaultReveal?: SfDefaultReveal;\n /**\n * Standard CSS selectors. Tags, classes, IDs, attributes and combinations\n * can be mixed in the same array.\n */\n autoRevealSelectors?: readonly string[];\n}\n\nexport interface ResolvedSfMotionOptions {\n autoRevealSelectors: string[];\n defaultReveal: SfDefaultReveal;\n revealAboveFold: boolean;\n revealRules: SfRevealRule[];\n}\n\nexport type SfRevealState = \"pending\" | \"visible\" | \"settled\";\n\nexport interface InitialRevealStateInput {\n bottom: number;\n containsHashTarget: boolean;\n protectedContent: boolean;\n reducedMotion: boolean;\n revealAboveFold: boolean;\n top: number;\n viewportHeight: number;\n}\n\nexport interface RevealVisibilityInput {\n bottom: number;\n height: number;\n top: number;\n viewportHeight: number;\n}\n\nexport function isSfRevealModifier(value: unknown): value is SfRevealModifier {\n return typeof value === \"string\" && SF_REVEAL_MODIFIER_PATTERN.test(value);\n}\n\nfunction normalizeSelectors(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n\n return Array.from(\n new Set(\n value\n .filter((selector): selector is string => typeof selector === \"string\")\n .map((selector) => selector.trim())\n .filter(Boolean),\n ),\n );\n}\n\nfunction normalizeRevealRules(value: unknown): SfRevealRule[] {\n if (!Array.isArray(value)) return [];\n\n const seenSelectors = new Set<string>();\n return value.flatMap((rule: unknown) => {\n if (!rule || typeof rule !== \"object\") return [];\n\n const candidate = rule as Partial<SfRevealRule>;\n const selector =\n typeof candidate.selector === \"string\" ? candidate.selector.trim() : \"\";\n if (\n !selector ||\n seenSelectors.has(selector) ||\n !isSfRevealModifier(candidate.reveal)\n ) {\n return [];\n }\n\n seenSelectors.add(selector);\n return [{ selector, reveal: candidate.reveal }];\n });\n}\n\n/**\n * Normalizes server- or client-provided configuration. Invalid values fail\n * open by disabling automatic reveals; empty and duplicate selectors are\n * removed without changing their order.\n */\nexport function resolveSfMotionOptions(\n options: SfMotionOptions = {},\n): ResolvedSfMotionOptions {\n const defaultReveal = isSfRevealModifier(options.defaultReveal)\n ? options.defaultReveal\n : false;\n return {\n autoRevealSelectors: normalizeSelectors(options.autoRevealSelectors),\n defaultReveal,\n revealAboveFold: options.revealAboveFold === true,\n revealRules: normalizeRevealRules(options.revealRules),\n };\n}\n\n/** Exact class mutation required by an authoritative selector rule. */\nexport function ruleRevealClassChanges(\n existingClasses: Iterable<string>,\n reveal: SfRevealModifier,\n): SfRevealClassChanges {\n const classes = Array.from(existingClasses);\n if (\n classes.includes(SF_MOTION_STATIC_CLASS) ||\n classes.includes(SF_MOTION_DISABLE_CLASS)\n ) {\n return { add: [], remove: [] };\n }\n\n return {\n add: [\n ...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),\n ...(classes.includes(reveal) ? [] : [reveal]),\n ],\n remove: classes\n .filter(isSfRevealModifier)\n .filter((modifier) => modifier !== reveal),\n };\n}\n\n/** Delay for a zero-based participant index in a reveal stagger group. */\nexport function staggerRevealDelayMs(index: number): number {\n if (!Number.isFinite(index) || index <= 0) return 0;\n return Math.min(\n Math.floor(index) * SF_REVEAL_STAGGER_STEP_MS,\n SF_REVEAL_STAGGER_MAX_MS,\n );\n}\n\n/**\n * Returns only the classes that automatic inheritance must add. Explicit\n * modifiers win over the configured default and `sf-motion-static` remains a\n * complete opt-out.\n */\nexport function automaticRevealClasses(\n existingClasses: Iterable<string>,\n defaultReveal: SfDefaultReveal,\n): string[] {\n if (defaultReveal === false) return [];\n\n const classes = Array.from(existingClasses);\n if (\n classes.includes(SF_MOTION_STATIC_CLASS) ||\n classes.includes(SF_MOTION_DISABLE_CLASS)\n ) {\n return [];\n }\n\n return [\n ...(classes.includes(SF_REVEAL_CLASS) ? [] : [SF_REVEAL_CLASS]),\n ...(classes.some(isSfRevealModifier) ? [] : [defaultReveal]),\n ];\n}\n\nfunction cssTimeToMs(value: string): number {\n const normalized = value.trim();\n const amount = Number.parseFloat(normalized);\n if (!Number.isFinite(amount)) return 0;\n\n return normalized.endsWith(\"ms\") ? amount : amount * 1000;\n}\n\n/** Returns the longest combined CSS transition duration and delay. */\nexport function maximumTransitionTimeMs(\n transitionDuration: string,\n transitionDelay: string,\n): number {\n const durations = transitionDuration.split(\",\").map(cssTimeToMs);\n const delays = transitionDelay.split(\",\").map(cssTimeToMs);\n const itemCount = Math.max(durations.length, delays.length);\n\n return Array.from({ length: itemCount }, (_, index) => {\n const duration = durations[index % durations.length] ?? 0;\n const delay = delays[index % delays.length] ?? 0;\n return Math.max(0, duration + delay);\n }).reduce((maximum, value) => Math.max(maximum, value), 0);\n}\n\n/**\n * Initial viewport content stays static unless the project explicitly enables\n * above-the-fold reveals. Deep links and protected content remain visible.\n */\nexport function initialRevealState({\n bottom,\n containsHashTarget,\n protectedContent,\n reducedMotion,\n revealAboveFold,\n top,\n viewportHeight,\n}: InitialRevealStateInput): SfRevealState {\n if (\n reducedMotion ||\n containsHashTarget ||\n protectedContent\n ) {\n return \"visible\";\n }\n\n // reveal share of its height) waits for the scroll instead of appearing\n // statically; content already scrolled past the top stays visible.\n if (\n !revealAboveFold &&\n bottom > 0 &&\n top < viewportHeight &&\n (top < 0 ||\n hasEnoughVisibleArea({\n bottom,\n height: Math.max(0, bottom - top),\n top,\n viewportHeight,\n }))\n ) {\n return \"visible\";\n }\n\n return \"pending\";\n}\n\n/**\n * Reveal ordinary content once 20% of its perceivable height is visible.\n * For elements taller than the viewport, the viewport height is the reference.\n */\nexport function hasEnoughVisibleArea({\n bottom,\n height,\n top,\n viewportHeight,\n}: RevealVisibilityInput): boolean {\n if (height <= 0 || viewportHeight <= 0) return true;\n\n const visibleHeight = Math.max(\n 0,\n Math.min(bottom, viewportHeight) - Math.max(top, 0),\n );\n // The 1px tolerance below must not let thin elements such as a 1px <hr>\n // pass while they are still entirely outside the viewport.\n if (visibleHeight <= 0) return false;\n\n const requiredHeight =\n Math.min(height, viewportHeight) * SF_REVEAL_VISIBLE_RATIO;\n\n return visibleHeight + 1 >= requiredHeight;\n}\n\n/**\n * Reveal is deliberately one-way: focus and viewport entry can complete it,\n * while leaving the viewport never conceals content again.\n */\nexport function nextRevealState(\n current: SfRevealState,\n event: \"focus\" | \"intersect\" | \"leave\",\n): SfRevealState {\n if (current === \"settled\") return \"settled\";\n\n if (current === \"visible\" || event === \"focus\" || event === \"intersect\") {\n return \"visible\";\n }\n\n return \"pending\";\n}\n\nexport function shouldInitializeMotion(\n initialized: string | undefined,\n): boolean {\n return initialized !== \"true\";\n}\n\n/** `<html data-sf-motion>` value from the head bootstrap until the controller arms. */\nexport const SF_MOTION_BOOT_STATE = \"boot\";\n\n/** Failsafe: boot-hidden content shows anyway if the controller never arms. */\nexport const SF_MOTION_BOOT_FAILSAFE_MS = 3000;\n\n/**\n * Modifiers whose pending state keeps the element visible and hides only a\n * drawn decoration, mapped to the pseudo-element carrying it.\n */\nexport const SF_REVEAL_DECORATION_PSEUDOS: Readonly<\n Record<SfRevealModifier, \"::before\" | \"::after\">\n> = {\n \"sf-reveal--accordion-line\": \"::after\",\n};\n\n// Everything the controller leaves visible: opt-outs, protected content and the hash target.\n// :has() makes :not() invalid where unsupported, which drops the rule: content stays visible.\nconst SF_MOTION_BOOT_EXCLUDED = [\n `.${SF_MOTION_STATIC_CLASS}`,\n `.${SF_MOTION_DISABLE_CLASS}`,\n `.${SF_MOTION_DISABLE_CLASS} *`,\n SF_MOTION_PROTECTED_CONTENT_SELECTOR,\n `:has(${SF_MOTION_PROTECTED_CONTENT_SELECTOR})`,\n \":target\",\n \":has(:target)\",\n].join(\", \");\n\n/**\n * Inline `<head>` script, placed after the motion preference bootstrap: marks\n * the document as booting when the controller will arm reveals, so the CSS of\n * `motionBootCss` hides them before first paint.\n */\nexport function motionBootScript(preferenceAttribute: string): string {\n const attribute = JSON.stringify(preferenceAttribute);\n const state = JSON.stringify(SF_MOTION_BOOT_STATE);\n return `(()=>{const r=document.documentElement;if(r.getAttribute(${attribute})===\"full\"&&\"IntersectionObserver\"in window&&!r.dataset.sfMotion)r.dataset.sfMotion=${state}})()`;\n}\n\n/**\n * Pre-paint counterpart of the controller for `revealAboveFold`: hides what the\n * controller will arm (authored reveals, rule and automatic selectors) while\n * `<html data-sf-motion=\"boot\">`, so content is never painted, hidden, then\n * revealed. Each selector gets its own rule: an invalid one only drops itself.\n * Like the controller, the first matching rule decides the modifier.\n * Portabile in FlowPress: docs/pilots/primo-paint-stabile.md\n */\nexport function motionBootCss(options: SfMotionOptions = {}): string {\n const { autoRevealSelectors, defaultReveal, revealAboveFold, revealRules } =\n resolveSfMotionOptions(options);\n if (!revealAboveFold) return \"\";\n\n const root = `html[data-sf-motion=\"${SF_MOTION_BOOT_STATE}\"]`;\n const failsafe = `${SF_MOTION_BOOT_FAILSAFE_MS}ms`;\n const decorations = Object.entries(SF_REVEAL_DECORATION_PSEUDOS) as [\n SfRevealModifier,\n string,\n ][];\n const hide = (target: string, reveal: SfRevealModifier | null): string => {\n const pseudo = reveal ? (SF_REVEAL_DECORATION_PSEUDOS[reveal] ?? \"\") : \"\";\n return `${root} ${target}${pseudo}{opacity:0;animation:sf-motion-boot-failsafe 0s linear ${failsafe} forwards}`;\n };\n const rules: string[] = [];\n\n // Authored reveals keep their own modifier; decorations hide their pseudo.\n const decorationClasses = decorations.map(([modifier]) => `.${modifier}`);\n rules.push(hide(\n `.${SF_REVEAL_CLASS}:not(${[SF_MOTION_BOOT_EXCLUDED, ...decorationClasses].join(\", \")})`,\n null,\n ));\n decorations.forEach(([modifier]) => {\n rules.push(hide(`.${SF_REVEAL_CLASS}.${modifier}:not(${SF_MOTION_BOOT_EXCLUDED})`, modifier));\n });\n\n const earlier: string[] = [];\n revealRules.forEach(({ selector, reveal }) => {\n const shadowed = earlier.length ? `, :is(${earlier.join(\", \")})` : \"\";\n rules.push(hide(`:is(${selector}):not(${SF_MOTION_BOOT_EXCLUDED}${shadowed})`, reveal));\n earlier.push(selector);\n });\n\n if (defaultReveal !== false) {\n const shadowed = earlier.length ? `, :is(${earlier.join(\", \")})` : \"\";\n autoRevealSelectors.forEach((selector) => {\n rules.push(hide(`:is(${selector}):not(${SF_MOTION_BOOT_EXCLUDED}${shadowed})`, defaultReveal));\n });\n }\n\n rules.push(\"@keyframes sf-motion-boot-failsafe{to{opacity:1}}\");\n return rules.join(\"\\n\");\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
import Media from "../
|
|
2
|
+
import Media from "../EditorialMedia.astro";
|
|
3
3
|
import StyleflowElement from "../StyleflowElement.astro";
|
|
4
4
|
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
5
5
|
import { imageMediaStyle } from "./image.js";
|
|
@@ -91,7 +91,6 @@ const imageClass = classNames(
|
|
|
91
91
|
media.imageClass,
|
|
92
92
|
attributes.imageClassName,
|
|
93
93
|
);
|
|
94
|
-
const mediaStyle = Object.entries(imageMediaStyle(attributes)).map(([name, value]) => `${name}:${value}`).join(";");
|
|
95
94
|
const imageProps = {
|
|
96
95
|
src,
|
|
97
96
|
srcset: srcSet,
|
|
@@ -101,7 +100,7 @@ const imageProps = {
|
|
|
101
100
|
alt,
|
|
102
101
|
title,
|
|
103
102
|
class: imageClass,
|
|
104
|
-
|
|
103
|
+
presentation: imageMediaStyle(attributes),
|
|
105
104
|
loading: "lazy" as const,
|
|
106
105
|
decoding: "async" as const,
|
|
107
106
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
import Media from "../
|
|
2
|
+
import Media from "../EditorialMedia.astro";
|
|
3
3
|
import { imageMediaStyle } from "./image.js";
|
|
4
4
|
import StyleflowElement from "../StyleflowElement.astro";
|
|
5
5
|
import type { FlowpressBlockRendererProps } from "../../index.js";
|
|
@@ -27,7 +27,7 @@ const imageProps = {
|
|
|
27
27
|
class: image.id ? `wp-image-${image.id}` : undefined,
|
|
28
28
|
loading: "lazy" as const,
|
|
29
29
|
decoding: "async" as const,
|
|
30
|
-
|
|
30
|
+
presentation: imageMediaStyle(attributes),
|
|
31
31
|
};
|
|
32
32
|
---
|
|
33
33
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-cache.d.ts","sourceRoot":"","sources":["../src/build-cache.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"build-cache.d.ts","sourceRoot":"","sources":["../src/build-cache.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAKzD,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAsDjH"}
|
package/dist/build-cache.js
CHANGED
|
@@ -3,6 +3,7 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
3
3
|
import { lstat, readFile, rename, writeFile, unlink, mkdir, rmdir } from "node:fs/promises";
|
|
4
4
|
import { setTimeout as delay } from "node:timers/promises";
|
|
5
5
|
import { isAbsolute, join } from "node:path";
|
|
6
|
+
import { FLOWPRESS_BUILD_STORE_LOCK_MS } from "./env.js";
|
|
6
7
|
const inFlight = new Map();
|
|
7
8
|
export async function createBuildRequestStore(options) {
|
|
8
9
|
const { directory, endpoint, revision } = options;
|
|
@@ -29,7 +30,7 @@ export async function createBuildRequestStore(options) {
|
|
|
29
30
|
return pending;
|
|
30
31
|
const result = (async () => {
|
|
31
32
|
const lock = file + ".lock";
|
|
32
|
-
const deadline = Date.now() +
|
|
33
|
+
const deadline = Date.now() + FLOWPRESS_BUILD_STORE_LOCK_MS;
|
|
33
34
|
while (true) {
|
|
34
35
|
try {
|
|
35
36
|
await mkdir(lock, { mode: 0o700 });
|
package/dist/build-cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-cache.js","sourceRoot":"","sources":["../src/build-cache.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"build-cache.js","sourceRoot":"","sources":["../src/build-cache.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAEzD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA4B,CAAC;AAQrD,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAAmC;IAC/E,MAAM,EAAE,SAAS,EAAE,QAAQ,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,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;oBACrD,IAAI,CAAC;wBACH,MAAM,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;wBACxF,MAAM,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;oBAChC,CAAC;4BAAS,CAAC;wBACT,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;oBAC1C,CAAC;oBACD,OAAO,KAAK,CAAC;gBACb,CAAC;wBAAS,CAAC;oBAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;gBAAC,CAAC;YAClC,CAAC,CAAC,EAAE,CAAC;YACL,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC3B,IAAI,CAAC;gBAAC,OAAO,MAAM,MAAM,CAAC;YAAC,CAAC;oBAAS,CAAC;gBAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAAC,CAAC;QACjE,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/** Node-only, private store shared by the safelist and Astro build processes. */\nimport { createHash, randomUUID } from \"node:crypto\";\nimport { lstat, readFile, rename, writeFile, unlink, mkdir, rmdir } from \"node:fs/promises\";\nimport { setTimeout as delay } from \"node:timers/promises\";\nimport { isAbsolute, join } from \"node:path\";\nimport type { FlowpressRequestStore } from \"./client.js\";\nimport { FLOWPRESS_BUILD_STORE_LOCK_MS } from \"./env.js\";\n\nconst inFlight = new Map<string, Promise<unknown>>();\n\nexport interface FlowpressBuildStoreOptions {\n directory: string;\n endpoint: string;\n revision: string;\n}\n\nexport async function createBuildRequestStore(options: FlowpressBuildStoreOptions): Promise<FlowpressRequestStore> {\n const { directory, endpoint, revision } = options;\n if (!isAbsolute(directory) || !/^[a-f0-9]{32}$/.test(revision)) {\n throw new Error(\"A build request store requires a private absolute directory and content revision.\");\n }\n const stat = await lstat(directory);\n if (!stat.isDirectory() || stat.isSymbolicLink() || (stat.mode & 0o077)) {\n throw new Error(\"The build request directory must be private and cannot be a symlink.\");\n }\n const metadata = JSON.parse(await readFile(join(directory, \"session.json\"), \"utf8\"));\n if (metadata.schemaVersion !== 1 || metadata.endpoint !== endpoint || metadata.revision !== revision) {\n throw new Error(\"The build request store belongs to another backend or revision.\");\n }\n return {\n async getOrCreate<T>(key: string, load: () => Promise<T>): Promise<T> {\n const identity = JSON.parse(key) as { endpoint?: string };\n if (identity.endpoint !== endpoint) throw new Error(\"Cross-backend build cache access refused.\");\n const digest = createHash(\"sha256\").update(key).digest(\"hex\");\n const file = join(directory, digest + \".json\");\n const pending = inFlight.get(file);\n if (pending) return pending as Promise<T>;\n const result = (async (): Promise<T> => {\n const lock = file + \".lock\";\n const deadline = Date.now() + FLOWPRESS_BUILD_STORE_LOCK_MS;\n while (true) {\n try { await mkdir(lock, { mode: 0o700 }); break; }\n catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n if (Date.now() > deadline) throw new Error(\"Timed out waiting for another build process. Discard this attempt.\");\n await delay(20);\n }\n }\n try {\n try {\n const cached = JSON.parse(await readFile(file, \"utf8\"));\n if (cached.key === key && Object.hasOwn(cached, \"value\")) return cached.value as T;\n } catch (error) {\n if (!(error instanceof SyntaxError) && (error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n }\n const value = await load();\n const temporary = file + \".\" + randomUUID() + \".tmp\";\n try {\n await writeFile(temporary, JSON.stringify({ key, value }), { mode: 0o600, flag: \"wx\" });\n await rename(temporary, file);\n } finally {\n await unlink(temporary).catch(() => {});\n }\n return value;\n } finally { await rmdir(lock); }\n })();\n inFlight.set(file, result);\n try { return await result; } finally { inFlight.delete(file); }\n }\n };\n}\n"]}
|
package/dist/client.d.ts
CHANGED
|
@@ -11,9 +11,17 @@ export interface FlowpressGraphqlIssue {
|
|
|
11
11
|
export interface FlowpressRequestStore {
|
|
12
12
|
getOrCreate<T>(key: string, load: () => Promise<T>): Promise<T>;
|
|
13
13
|
}
|
|
14
|
+
export declare const DEFAULT_GRAPHQL_TIMEOUT_MS = 15000;
|
|
15
|
+
export declare const DEFAULT_GRAPHQL_RETRIES = 1;
|
|
16
|
+
export declare const DEFAULT_GRAPHQL_RETRY_DELAY_MS = 1000;
|
|
14
17
|
export interface FlowpressClientOptions {
|
|
15
18
|
endpoint: string;
|
|
19
|
+
/** Per-attempt limit; every retry gets a fresh timer. */
|
|
16
20
|
timeoutMs?: number;
|
|
21
|
+
/** Extra attempts for queries after a timeout, network error or 429/502/503/504. */
|
|
22
|
+
retries?: number;
|
|
23
|
+
/** First backoff; it doubles on every further retry. */
|
|
24
|
+
retryDelayMs?: number;
|
|
17
25
|
headers?: Record<string, string>;
|
|
18
26
|
debug?: boolean;
|
|
19
27
|
requestStore?: FlowpressRequestStore;
|
|
@@ -28,6 +36,8 @@ export declare class FlowpressGraphqlError extends Error {
|
|
|
28
36
|
export declare class FlowpressClient {
|
|
29
37
|
readonly endpoint: string;
|
|
30
38
|
readonly timeoutMs: number;
|
|
39
|
+
readonly retries: number;
|
|
40
|
+
readonly retryDelayMs: number;
|
|
31
41
|
readonly headers: Record<string, string>;
|
|
32
42
|
readonly debug: boolean;
|
|
33
43
|
readonly requestStore: FlowpressRequestStore | undefined;
|
|
@@ -35,6 +45,7 @@ export declare class FlowpressClient {
|
|
|
35
45
|
request<T>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
36
46
|
getContentRevision(): Promise<string>;
|
|
37
47
|
private requestUncached;
|
|
48
|
+
private requestOnce;
|
|
38
49
|
getCapabilities(): Promise<FlowpressCapabilities>;
|
|
39
50
|
getRoute(uri: string, locale?: string): Promise<FlowpressRoute | null>;
|
|
40
51
|
getRoutes(locale?: string): Promise<FlowpressRoute[]>;
|
package/dist/client.d.ts.map
C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,OAAO,CAAC,qBAAqB,CAAC;IA4CjD,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAgCtE,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IA6BrD,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,cAAc,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;IAwCtI;;OAEG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;QAAC,WAAW,EAAE,sBAAsB,CAAA;KAAE,GAAG,IAAI,CAAC;CAK1M"}
|
package/dist/client.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export const DEFAULT_GRAPHQL_TIMEOUT_MS = 15_000;
|
|
2
|
+
export const DEFAULT_GRAPHQL_RETRIES = 1;
|
|
3
|
+
export const DEFAULT_GRAPHQL_RETRY_DELAY_MS = 1_000;
|
|
4
|
+
const RETRYABLE_STATUSES = new Set([429, 502, 503, 504]);
|
|
1
5
|
export class FlowpressGraphqlError extends Error {
|
|
2
6
|
status;
|
|
3
7
|
errors;
|
|
@@ -15,6 +19,8 @@ export class FlowpressGraphqlError extends Error {
|
|
|
15
19
|
export class FlowpressClient {
|
|
16
20
|
endpoint;
|
|
17
21
|
timeoutMs;
|
|
22
|
+
retries;
|
|
23
|
+
retryDelayMs;
|
|
18
24
|
headers;
|
|
19
25
|
debug;
|
|
20
26
|
requestStore;
|
|
@@ -25,7 +31,9 @@ export class FlowpressClient {
|
|
|
25
31
|
}
|
|
26
32
|
new URL(endpoint);
|
|
27
33
|
this.endpoint = endpoint;
|
|
28
|
-
this.timeoutMs = options.timeoutMs ??
|
|
34
|
+
this.timeoutMs = boundedInteger(options.timeoutMs ?? DEFAULT_GRAPHQL_TIMEOUT_MS, "timeoutMs", 1);
|
|
35
|
+
this.retries = boundedInteger(options.retries ?? DEFAULT_GRAPHQL_RETRIES, "retries", 0, 5);
|
|
36
|
+
this.retryDelayMs = boundedInteger(options.retryDelayMs ?? DEFAULT_GRAPHQL_RETRY_DELAY_MS, "retryDelayMs", 0);
|
|
29
37
|
this.headers = { ...options.headers };
|
|
30
38
|
this.debug = options.debug ?? false;
|
|
31
39
|
this.requestStore = options.requestStore;
|
|
@@ -52,12 +60,31 @@ export class FlowpressClient {
|
|
|
52
60
|
return data.sfContentRevision;
|
|
53
61
|
}
|
|
54
62
|
async requestUncached(query, variables) {
|
|
63
|
+
const operationName = getOperationName(query);
|
|
64
|
+
// Only read documents are replayed; a mutation may already have been applied.
|
|
65
|
+
const attempts = /^(?:query\b|\{)/.test(query.trim()) ? this.retries + 1 : 1;
|
|
66
|
+
const started = Date.now();
|
|
67
|
+
for (let attempt = 1;; attempt++) {
|
|
68
|
+
try {
|
|
69
|
+
return await this.requestOnce(query, variables, operationName);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (attempt >= attempts || !isTransientFailure(error))
|
|
73
|
+
throw error;
|
|
74
|
+
const wait = this.retryDelayMs * 2 ** (attempt - 1);
|
|
75
|
+
console.warn(`FlowPress GraphQL ${operationName} attempt ${attempt}/${attempts} failed after `
|
|
76
|
+
+ `${Date.now() - started}ms: ${error.message} Retrying in ${wait}ms.`);
|
|
77
|
+
await new Promise((resolve) => setTimeout(resolve, wait));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async requestOnce(query, variables, operationName) {
|
|
55
82
|
const controller = new AbortController();
|
|
56
83
|
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
57
|
-
const operationName = getOperationName(query);
|
|
58
84
|
const safeEndpoint = sanitizeEndpoint(this.endpoint);
|
|
59
85
|
try {
|
|
60
86
|
let response;
|
|
87
|
+
let body;
|
|
61
88
|
try {
|
|
62
89
|
response = await fetch(this.endpoint, {
|
|
63
90
|
method: "POST",
|
|
@@ -68,6 +95,8 @@ export class FlowpressClient {
|
|
|
68
95
|
body: JSON.stringify({ query, variables }),
|
|
69
96
|
signal: controller.signal
|
|
70
97
|
});
|
|
98
|
+
// The timeout also covers a body that stalls after the headers.
|
|
99
|
+
body = await response.text();
|
|
71
100
|
}
|
|
72
101
|
catch (error) {
|
|
73
102
|
const timedOut = controller.signal.aborted;
|
|
@@ -78,7 +107,6 @@ export class FlowpressClient {
|
|
|
78
107
|
? `FlowPress GraphQL ${operationName} timed out after ${this.timeoutMs}ms at ${safeEndpoint}.`
|
|
79
108
|
: `FlowPress GraphQL ${operationName} could not reach ${safeEndpoint}.${detail}`, undefined, undefined, operationName, safeEndpoint, error);
|
|
80
109
|
}
|
|
81
|
-
const body = await response.text();
|
|
82
110
|
let payload;
|
|
83
111
|
try {
|
|
84
112
|
payload = JSON.parse(body);
|
|
@@ -229,6 +257,21 @@ export class FlowpressClient {
|
|
|
229
257
|
return composition ? { route: composition.route, content: composition.content ?? null, composition } : null;
|
|
230
258
|
}
|
|
231
259
|
}
|
|
260
|
+
/** Timeouts, unreachable endpoints and gateway/rate-limit statuses; never GraphQL errors. */
|
|
261
|
+
function isTransientFailure(error) {
|
|
262
|
+
if (!(error instanceof FlowpressGraphqlError))
|
|
263
|
+
return false;
|
|
264
|
+
return error.status === undefined
|
|
265
|
+
? error.cause !== undefined
|
|
266
|
+
: RETRYABLE_STATUSES.has(error.status);
|
|
267
|
+
}
|
|
268
|
+
function boundedInteger(value, name, min, max = Number.MAX_SAFE_INTEGER) {
|
|
269
|
+
if (!Number.isInteger(value) || value < min || value > max) {
|
|
270
|
+
const range = max === Number.MAX_SAFE_INTEGER ? `>= ${min}` : `between ${min} and ${max}`;
|
|
271
|
+
throw new Error(`FlowPress GraphQL ${name} must be an integer ${range}.`);
|
|
272
|
+
}
|
|
273
|
+
return value;
|
|
274
|
+
}
|
|
232
275
|
function getOperationName(query) {
|
|
233
276
|
return query.match(/\b(?:query|mutation|subscription)\s+([_A-Za-z][_0-9A-Za-z]*)/)?.[1] || "AnonymousOperation";
|
|
234
277
|
}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAmCA,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAGnC;IACA;IACA;IACA;IALX,YACE,OAAe,EACN,MAAe,EACf,MAAgC,EAChC,aAAsB,EACtB,QAAiB,EAC1B,KAAe;QAEf,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QANnD,WAAM,GAAN,MAAM,CAAS;QACf,WAAM,GAAN,MAAM,CAA0B;QAChC,kBAAa,GAAb,aAAa,CAAS;QACtB,aAAQ,GAAR,QAAQ,CAAS;QAI1B,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED,MAAM,OAAO,eAAe;IACjB,QAAQ,CAAS;IACjB,SAAS,CAAS;IAClB,OAAO,CAAyB;IAChC,KAAK,CAAU;IACf,YAAY,CAAoC;IAEzD,YAAY,OAA+B;QACzC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,Q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Aa,EAAE,KAAa;IACxD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,qBAAqB,CAC7B,+BAA+B,KAAK,qBAAqB,EACzD,SAAS,EACT,SAAS,EACT,sBAAsB,EACtB,SAAS,EACT,KAAK,CACN,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc;IACxC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAY,CAAC;IAChE,MAAM,IAAI,GAAG,CAAC,IAAa,EAAW,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAC1D,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QAChB,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAChC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC3H,CAAC,CAAC,IAAI,CAAC;IACX,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import type {\n FlowpressCapabilities,\n FlowpressCompositionV1,\n FlowpressContent,\n FlowpressRoute,\n SfSeo\n} from \"./types.js\";\n\nexport interface FlowpressGraphqlIssue {\n message?: string;\n extensions?: {\n debugMessage?: string;\n category?: string;\n [key: string]: unknown;\n };\n}\n\ninterface GraphqlResponse<T> {\n data?: T;\n errors?: FlowpressGraphqlIssue[];\n}\n\n/** Store only successful anonymous query data; implementations may deduplicate in flight. */\nexport interface FlowpressRequestStore {\n getOrCreate<T>(key: string, load: () => Promise<T>): Promise<T>;\n}\n\nexport interface FlowpressClientOptions {\n endpoint: string;\n timeoutMs?: number;\n headers?: Record<string, string>;\n debug?: boolean;\n requestStore?: FlowpressRequestStore;\n}\n\nexport class FlowpressGraphqlError extends Error {\n constructor(\n message: string,\n readonly status?: number,\n readonly errors?: FlowpressGraphqlIssue[],\n readonly operationName?: string,\n readonly endpoint?: string,\n cause?: unknown\n ) {\n super(message, cause === undefined ? undefined : { cause });\n this.name = \"FlowpressGraphqlError\";\n }\n}\n\nexport class FlowpressClient {\n readonly endpoint: string;\n readonly timeoutMs: number;\n readonly headers: Record<string, string>;\n readonly debug: boolean;\n readonly requestStore: FlowpressRequestStore | undefined;\n\n constructor(options: FlowpressClientOptions) {\n const endpoint = options.endpoint.trim();\n if (!endpoint) {\n throw new Error(\"FlowPress GraphQL endpoint is required.\");\n }\n\n new URL(endpoint);\n this.endpoint = endpoint;\n this.timeoutMs = options.timeoutMs ?? 15_000;\n this.headers = { ...options.headers };\n this.debug = options.debug ?? false;\n this.requestStore = options.requestStore;\n }\n\n async request<T>(\n query: string,\n variables: Record<string, unknown> = {}\n ): Promise<T> {\n const url = new URL(this.endpoint);\n const anonymousQuery = Object.keys(this.headers).length === 0\n && !url.username && !url.password\n && /^(?:query\\b|\\{)/.test(query.trim())\n && !/\\b(?:mutation|subscription|sfContentRevision)\\b/.test(query);\n if (this.requestStore && anonymousQuery) {\n return this.requestStore.getOrCreate<T>(JSON.stringify({\n endpoint: this.endpoint, query, variables: canonicalVariables(variables)\n }), () => this.requestUncached<T>(query, variables));\n }\n return this.requestUncached<T>(query, variables);\n }\n\n async getContentRevision(): Promise<string> {\n // This read must never come from the build store it is validating.\n const data = await this.requestUncached<{ sfContentRevision: string }>(\n \"query FlowpressContentRevision { sfContentRevision }\", {}\n );\n if (!/^[a-f0-9]{32}$/.test(data.sfContentRevision || \"\")) {\n throw new Error(\"WordPress returned no valid FlowPress content revision.\");\n }\n return data.sfContentRevision;\n }\n\n private async requestUncached<T>(query: string, variables: Record<string, unknown>): Promise<T> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeoutMs);\n const operationName = getOperationName(query);\n const safeEndpoint = sanitizeEndpoint(this.endpoint);\n\n try {\n let response: Response;\n try {\n response = await fetch(this.endpoint, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...this.headers\n },\n body: JSON.stringify({ query, variables }),\n signal: controller.signal\n });\n } catch (error) {\n const timedOut = controller.signal.aborted;\n const detail = error instanceof Error && error.message\n ? ` ${error.message}`\n : \"\";\n throw new FlowpressGraphqlError(\n timedOut\n ? `FlowPress GraphQL ${operationName} timed out after ${this.timeoutMs}ms at ${safeEndpoint}.`\n : `FlowPress GraphQL ${operationName} could not reach ${safeEndpoint}.${detail}`,\n undefined,\n undefined,\n operationName,\n safeEndpoint,\n error\n );\n }\n\n const body = await response.text();\n let payload: GraphqlResponse<T>;\n try {\n payload = JSON.parse(body) as GraphqlResponse<T>;\n } catch (error) {\n const contentType = response.headers.get(\"content-type\") || \"unknown content type\";\n throw new FlowpressGraphqlError(\n `FlowPress GraphQL ${operationName} returned ${response.status} `\n + `with ${contentType}, not JSON, from ${safeEndpoint}.`,\n response.status,\n undefined,\n operationName,\n safeEndpoint,\n error\n );\n }\n\n if (!response.ok || payload.errors?.length || payload.data === undefined) {\n const errors: FlowpressGraphqlIssue[] | undefined = payload.errors?.map(\n (error) => {\n if (this.debug) {\n return error;\n }\n return error.message ? { message: error.message } : {};\n }\n );\n const messages = errors\n ?.flatMap((error) => [\n error.message,\n this.debug ? error.extensions?.debugMessage : undefined\n ])\n .filter((message): message is string => Boolean(message));\n throw new FlowpressGraphqlError(\n messages?.join(\"; \")\n || `FlowPress GraphQL ${operationName} failed with ${response.status} at ${safeEndpoint}.`,\n response.status,\n errors,\n operationName,\n safeEndpoint\n );\n }\n\n return payload.data;\n } finally {\n clearTimeout(timer);\n }\n }\n\n async getCapabilities(): Promise<FlowpressCapabilities> {\n const data = await this.request<{ styleflowCapabilities: FlowpressCapabilities }>(\n `query FlowpressCapabilities {\n styleflowCapabilities {\n schemaVersion\n wpGraphql\n acfPro\n wpGraphqlAcf\n rankMath\n wpml\n woocommerce\n contactForm7\n defaultLocale\n locales { code slug homeUrl }\n features { id version enabled capabilities configJson }\n }\n }`\n );\n return {\n ...data.styleflowCapabilities,\n features: (data.styleflowCapabilities.features ?? []).map((feature) => {\n const wire = feature as typeof feature & { configJson?: string | null };\n let config: Record<string, unknown> = {};\n if (wire.configJson) {\n try {\n const parsed = JSON.parse(wire.configJson);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n config = parsed as Record<string, unknown>;\n }\n } catch {\n config = {};\n }\n }\n return {\n id: feature.id,\n version: feature.version ?? null,\n enabled: feature.enabled,\n capabilities: feature.capabilities ?? [],\n config\n };\n })\n };\n }\n\n async getRoute(uri: string, locale?: string): Promise<FlowpressRoute | null> {\n const data = await this.request<{\n sfRouteByUri: (Omit<FlowpressRoute, \"seo\"> & {\n seo?: GraphqlSeo | null;\n }) | null;\n }>(\n `query FlowpressRoute($uri: String!, $locale: String) {\n sfRouteByUri(uri: $uri, locale: $locale) {\n uri status queryType locale isFrontPage isPostsPage frontPageMode\n postType taxonomy slug term databaseId termId authorNicename authorId\n pageTemplate mimeType postFormat templateCandidates\n content { loader databaseId termId }\n seo {\n title description canonicalUrl robots headHtml\n hreflang { locale url }\n jsonLd { raw }\n openGraph { title description image { url altText } }\n twitterMeta { title description image { url altText } }\n }\n }\n }`,\n { uri, locale: locale ?? null }\n );\n if (!data.sfRouteByUri) {\n return null;\n }\n return {\n ...data.sfRouteByUri,\n seo: normalizeGraphqlSeo(data.sfRouteByUri.seo)\n };\n }\n\n async getRoutes(locale?: string): Promise<FlowpressRoute[]> {\n const data = await this.request<{\n sfRoutes: Array<Omit<FlowpressRoute, \"seo\"> & {\n seo?: GraphqlSeo | null;\n }>;\n }>(\n `query FlowpressRoutes($locale: String) {\n sfRoutes(locale: $locale) {\n uri status queryType locale isFrontPage isPostsPage frontPageMode\n postType taxonomy slug term databaseId termId authorNicename authorId\n pageTemplate mimeType postFormat templateCandidates\n content { loader databaseId termId }\n seo {\n title description canonicalUrl robots headHtml\n hreflang { locale url }\n jsonLd { raw }\n openGraph { title description image { url altText } }\n twitterMeta { title description image { url altText } }\n }\n }\n }`,\n { locale: locale ?? null }\n );\n return data.sfRoutes.map((route) => ({\n ...route,\n seo: normalizeGraphqlSeo(route.seo)\n }));\n }\n\n async getComposition(uri: string, locale?: string, options: { includeContent?: boolean } = {}): Promise<FlowpressCompositionV1 | null> {\n const data = await this.request<{\n sfCompositionByUri: null | {\n version: \"1\";\n sourceDigest: string;\n locale?: string | null;\n templateJson: string;\n blocksJson: string;\n stylesheetsJson: string;\n blockTypesJson: string;\n diagnosticsJson: string;\n routeJson: string;\n contentJson?: string | null;\n };\n }>(\n `query FlowpressComposition($uri: String!, $locale: String${options.includeContent === false ? \", $includeContent: Boolean\" : \"\"}) {\n sfCompositionByUri(uri: $uri, locale: $locale${options.includeContent === false ? \", includeContent: $includeContent\" : \"\"}) {\n version sourceDigest locale templateJson blocksJson stylesheetsJson blockTypesJson\n diagnosticsJson routeJson contentJson\n }\n }`,\n { uri, locale: locale ?? null, ...(options.includeContent === false ? { includeContent: false } : {}) }\n );\n const wire = data.sfCompositionByUri;\n if (!wire) return null;\n const route = parseRequiredJson<Omit<FlowpressRoute, \"seo\"> & { seo?: GraphqlSeo | SfSeo | null }>(wire.routeJson, \"routeJson\");\n return {\n version: wire.version,\n sourceDigest: wire.sourceDigest,\n locale: wire.locale ?? null,\n template: parseRequiredJson(wire.templateJson, \"templateJson\"),\n blocks: parseRequiredJson(wire.blocksJson, \"blocksJson\"),\n stylesheets: parseRequiredJson(wire.stylesheetsJson, \"stylesheetsJson\"),\n blockTypes: parseRequiredJson(wire.blockTypesJson, \"blockTypesJson\"),\n diagnostics: parseRequiredJson(wire.diagnosticsJson, \"diagnosticsJson\"),\n route: { ...route, seo: normalizeGraphqlSeo(route.seo) },\n content: parseJson(wire.contentJson, null)\n };\n }\n\n /** Site Editor already returns route and content in its composition. No\n * route preflight, retries or cross-request cache are needed for previews.\n */\n async getPage(uri: string, options: { locale?: string; includeContent?: boolean } = {}): Promise<{ route: FlowpressRoute; content: FlowpressContent | null; composition: FlowpressCompositionV1 } | null> {\n const composition = await this.getComposition(uri, options.locale, options);\n return composition ? { route: composition.route, content: composition.content ?? null, composition } : null;\n }\n\n}\n\nfunction getOperationName(query: string): string {\n return query.match(\n /\\b(?:query|mutation|subscription)\\s+([_A-Za-z][_0-9A-Za-z]*)/\n )?.[1] || \"AnonymousOperation\";\n}\n\nfunction sanitizeEndpoint(endpoint: string): string {\n const url = new URL(endpoint);\n url.username = \"\";\n url.password = \"\";\n url.search = \"\";\n url.hash = \"\";\n return url.toString();\n}\n\ninterface GraphqlSeo {\n title?: string | null;\n description?: string | null;\n canonicalUrl?: string | null;\n robots?: string[] | null;\n headHtml?: string | null;\n jsonLd?: { raw?: string | null } | null;\n openGraph?: GraphqlSocial | null;\n twitterMeta?: GraphqlSocial | null;\n hreflang?: Array<{ locale: string; url: string }> | null;\n}\n\ninterface GraphqlSocial {\n title?: string | null;\n description?: string | null;\n image?: { url: string; altText?: string | null } | null;\n}\n\nfunction normalizeGraphqlSeo(seo?: GraphqlSeo | SfSeo | null) {\n if (!seo) return null;\n const social = (value?: GraphqlSocial | SfSeo[\"openGraph\"] | null) => {\n if (!value) return null;\n const source = value.image as (NonNullable<NonNullable<SfSeo[\"openGraph\"]>[\"image\"]> & { altText?: string | null }) | null | undefined;\n const { altText, ...image } = source ?? {};\n return {\n title: value.title ?? null,\n description: value.description ?? null,\n image: source ? { ...image, url: source.url, alt: altText ?? source.alt ?? null } : null\n };\n };\n\n return {\n title: seo.title ?? null,\n description: seo.description ?? null,\n canonicalUrl: seo.canonicalUrl ?? null,\n robots: seo.robots ?? null,\n headHtml: seo.headHtml ?? null,\n jsonLd: seo.jsonLd && typeof seo.jsonLd === \"object\" && \"raw\" in seo.jsonLd\n ? parseJson((seo.jsonLd as { raw?: string | null }).raw, null) : seo.jsonLd ?? null,\n hreflang: seo.hreflang ?? null,\n openGraph: social(seo.openGraph),\n twitter: social(\"twitterMeta\" in seo ? seo.twitterMeta : (seo as SfSeo).twitter)\n };\n}\n\nfunction parseJson<T>(value: string | null | undefined, fallback: T): T {\n if (!value) return fallback;\n try {\n return JSON.parse(value) as T;\n } catch {\n return fallback;\n }\n}\n\nfunction parseRequiredJson<T>(value: string, field: string): T {\n try {\n return JSON.parse(value) as T;\n } catch (error) {\n throw new FlowpressGraphqlError(\n `FlowPress composition field ${field} is not valid JSON.`,\n undefined,\n undefined,\n \"FlowpressComposition\",\n undefined,\n error\n );\n }\n}\n\nfunction canonicalVariables(value: unknown): unknown {\n const normalized = JSON.parse(JSON.stringify(value)) as unknown;\n const sort = (item: unknown): unknown => Array.isArray(item)\n ? item.map(sort)\n : item && typeof item === \"object\"\n ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b)).map(([key, child]) => [key, sort(child)]))\n : item;\n return sort(normalized);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;AACjD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AACzC,MAAM,CAAC,MAAM,8BAA8B,GAAG,KAAK,CAAC;AACpD,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAezD,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAGnC;IACA;IACA;IACA;IALX,YACE,OAAe,EACN,MAAe,EACf,MAAgC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C,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC3H,CAAC,CAAC,IAAI,CAAC;IACX,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import type {\n FlowpressCapabilities,\n FlowpressCompositionV1,\n FlowpressContent,\n FlowpressRoute,\n SfSeo\n} from \"./types.js\";\n\nexport interface FlowpressGraphqlIssue {\n message?: string;\n extensions?: {\n debugMessage?: string;\n category?: string;\n [key: string]: unknown;\n };\n}\n\ninterface GraphqlResponse<T> {\n data?: T;\n errors?: FlowpressGraphqlIssue[];\n}\n\n/** Store only successful anonymous query data; implementations may deduplicate in flight. */\nexport interface FlowpressRequestStore {\n getOrCreate<T>(key: string, load: () => Promise<T>): Promise<T>;\n}\n\nexport const DEFAULT_GRAPHQL_TIMEOUT_MS = 15_000;\nexport const DEFAULT_GRAPHQL_RETRIES = 1;\nexport const DEFAULT_GRAPHQL_RETRY_DELAY_MS = 1_000;\nconst RETRYABLE_STATUSES = new Set([429, 502, 503, 504]);\n\nexport interface FlowpressClientOptions {\n endpoint: string;\n /** Per-attempt limit; every retry gets a fresh timer. */\n timeoutMs?: number;\n /** Extra attempts for queries after a timeout, network error or 429/502/503/504. */\n retries?: number;\n /** First backoff; it doubles on every further retry. */\n retryDelayMs?: number;\n headers?: Record<string, string>;\n debug?: boolean;\n requestStore?: FlowpressRequestStore;\n}\n\nexport class FlowpressGraphqlError extends Error {\n constructor(\n message: string,\n readonly status?: number,\n readonly errors?: FlowpressGraphqlIssue[],\n readonly operationName?: string,\n readonly endpoint?: string,\n cause?: unknown\n ) {\n super(message, cause === undefined ? undefined : { cause });\n this.name = \"FlowpressGraphqlError\";\n }\n}\n\nexport class FlowpressClient {\n readonly endpoint: string;\n readonly timeoutMs: number;\n readonly retries: number;\n readonly retryDelayMs: number;\n readonly headers: Record<string, string>;\n readonly debug: boolean;\n readonly requestStore: FlowpressRequestStore | undefined;\n\n constructor(options: FlowpressClientOptions) {\n const endpoint = options.endpoint.trim();\n if (!endpoint) {\n throw new Error(\"FlowPress GraphQL endpoint is required.\");\n }\n\n new URL(endpoint);\n this.endpoint = endpoint;\n this.timeoutMs = boundedInteger(options.timeoutMs ?? DEFAULT_GRAPHQL_TIMEOUT_MS, \"timeoutMs\", 1);\n this.retries = boundedInteger(options.retries ?? DEFAULT_GRAPHQL_RETRIES, \"retries\", 0, 5);\n this.retryDelayMs = boundedInteger(options.retryDelayMs ?? DEFAULT_GRAPHQL_RETRY_DELAY_MS, \"retryDelayMs\", 0);\n this.headers = { ...options.headers };\n this.debug = options.debug ?? false;\n this.requestStore = options.requestStore;\n }\n\n async request<T>(\n query: string,\n variables: Record<string, unknown> = {}\n ): Promise<T> {\n const url = new URL(this.endpoint);\n const anonymousQuery = Object.keys(this.headers).length === 0\n && !url.username && !url.password\n && /^(?:query\\b|\\{)/.test(query.trim())\n && !/\\b(?:mutation|subscription|sfContentRevision)\\b/.test(query);\n if (this.requestStore && anonymousQuery) {\n return this.requestStore.getOrCreate<T>(JSON.stringify({\n endpoint: this.endpoint, query, variables: canonicalVariables(variables)\n }), () => this.requestUncached<T>(query, variables));\n }\n return this.requestUncached<T>(query, variables);\n }\n\n async getContentRevision(): Promise<string> {\n // This read must never come from the build store it is validating.\n const data = await this.requestUncached<{ sfContentRevision: string }>(\n \"query FlowpressContentRevision { sfContentRevision }\", {}\n );\n if (!/^[a-f0-9]{32}$/.test(data.sfContentRevision || \"\")) {\n throw new Error(\"WordPress returned no valid FlowPress content revision.\");\n }\n return data.sfContentRevision;\n }\n\n private async requestUncached<T>(query: string, variables: Record<string, unknown>): Promise<T> {\n const operationName = getOperationName(query);\n // Only read documents are replayed; a mutation may already have been applied.\n const attempts = /^(?:query\\b|\\{)/.test(query.trim()) ? this.retries + 1 : 1;\n const started = Date.now();\n for (let attempt = 1; ; attempt++) {\n try {\n return await this.requestOnce<T>(query, variables, operationName);\n } catch (error) {\n if (attempt >= attempts || !isTransientFailure(error)) throw error;\n const wait = this.retryDelayMs * 2 ** (attempt - 1);\n console.warn(\n `FlowPress GraphQL ${operationName} attempt ${attempt}/${attempts} failed after `\n + `${Date.now() - started}ms: ${(error as Error).message} Retrying in ${wait}ms.`\n );\n await new Promise((resolve) => setTimeout(resolve, wait));\n }\n }\n }\n\n private async requestOnce<T>(\n query: string,\n variables: Record<string, unknown>,\n operationName: string\n ): Promise<T> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeoutMs);\n const safeEndpoint = sanitizeEndpoint(this.endpoint);\n\n try {\n let response: Response;\n let body: string;\n try {\n response = await fetch(this.endpoint, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...this.headers\n },\n body: JSON.stringify({ query, variables }),\n signal: controller.signal\n });\n // The timeout also covers a body that stalls after the headers.\n body = await response.text();\n } catch (error) {\n const timedOut = controller.signal.aborted;\n const detail = error instanceof Error && error.message\n ? ` ${error.message}`\n : \"\";\n throw new FlowpressGraphqlError(\n timedOut\n ? `FlowPress GraphQL ${operationName} timed out after ${this.timeoutMs}ms at ${safeEndpoint}.`\n : `FlowPress GraphQL ${operationName} could not reach ${safeEndpoint}.${detail}`,\n undefined,\n undefined,\n operationName,\n safeEndpoint,\n error\n );\n }\n\n let payload: GraphqlResponse<T>;\n try {\n payload = JSON.parse(body) as GraphqlResponse<T>;\n } catch (error) {\n const contentType = response.headers.get(\"content-type\") || \"unknown content type\";\n throw new FlowpressGraphqlError(\n `FlowPress GraphQL ${operationName} returned ${response.status} `\n + `with ${contentType}, not JSON, from ${safeEndpoint}.`,\n response.status,\n undefined,\n operationName,\n safeEndpoint,\n error\n );\n }\n\n if (!response.ok || payload.errors?.length || payload.data === undefined) {\n const errors: FlowpressGraphqlIssue[] | undefined = payload.errors?.map(\n (error) => {\n if (this.debug) {\n return error;\n }\n return error.message ? { message: error.message } : {};\n }\n );\n const messages = errors\n ?.flatMap((error) => [\n error.message,\n this.debug ? error.extensions?.debugMessage : undefined\n ])\n .filter((message): message is string => Boolean(message));\n throw new FlowpressGraphqlError(\n messages?.join(\"; \")\n || `FlowPress GraphQL ${operationName} failed with ${response.status} at ${safeEndpoint}.`,\n response.status,\n errors,\n operationName,\n safeEndpoint\n );\n }\n\n return payload.data;\n } finally {\n clearTimeout(timer);\n }\n }\n\n async getCapabilities(): Promise<FlowpressCapabilities> {\n const data = await this.request<{ styleflowCapabilities: FlowpressCapabilities }>(\n `query FlowpressCapabilities {\n styleflowCapabilities {\n schemaVersion\n wpGraphql\n acfPro\n wpGraphqlAcf\n rankMath\n wpml\n woocommerce\n contactForm7\n defaultLocale\n locales { code slug homeUrl }\n features { id version enabled capabilities configJson }\n }\n }`\n );\n return {\n ...data.styleflowCapabilities,\n features: (data.styleflowCapabilities.features ?? []).map((feature) => {\n const wire = feature as typeof feature & { configJson?: string | null };\n let config: Record<string, unknown> = {};\n if (wire.configJson) {\n try {\n const parsed = JSON.parse(wire.configJson);\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n config = parsed as Record<string, unknown>;\n }\n } catch {\n config = {};\n }\n }\n return {\n id: feature.id,\n version: feature.version ?? null,\n enabled: feature.enabled,\n capabilities: feature.capabilities ?? [],\n config\n };\n })\n };\n }\n\n async getRoute(uri: string, locale?: string): Promise<FlowpressRoute | null> {\n const data = await this.request<{\n sfRouteByUri: (Omit<FlowpressRoute, \"seo\"> & {\n seo?: GraphqlSeo | null;\n }) | null;\n }>(\n `query FlowpressRoute($uri: String!, $locale: String) {\n sfRouteByUri(uri: $uri, locale: $locale) {\n uri status queryType locale isFrontPage isPostsPage frontPageMode\n postType taxonomy slug term databaseId termId authorNicename authorId\n pageTemplate mimeType postFormat templateCandidates\n content { loader databaseId termId }\n seo {\n title description canonicalUrl robots headHtml\n hreflang { locale url }\n jsonLd { raw }\n openGraph { title description image { url altText } }\n twitterMeta { title description image { url altText } }\n }\n }\n }`,\n { uri, locale: locale ?? null }\n );\n if (!data.sfRouteByUri) {\n return null;\n }\n return {\n ...data.sfRouteByUri,\n seo: normalizeGraphqlSeo(data.sfRouteByUri.seo)\n };\n }\n\n async getRoutes(locale?: string): Promise<FlowpressRoute[]> {\n const data = await this.request<{\n sfRoutes: Array<Omit<FlowpressRoute, \"seo\"> & {\n seo?: GraphqlSeo | null;\n }>;\n }>(\n `query FlowpressRoutes($locale: String) {\n sfRoutes(locale: $locale) {\n uri status queryType locale isFrontPage isPostsPage frontPageMode\n postType taxonomy slug term databaseId termId authorNicename authorId\n pageTemplate mimeType postFormat templateCandidates\n content { loader databaseId termId }\n seo {\n title description canonicalUrl robots headHtml\n hreflang { locale url }\n jsonLd { raw }\n openGraph { title description image { url altText } }\n twitterMeta { title description image { url altText } }\n }\n }\n }`,\n { locale: locale ?? null }\n );\n return data.sfRoutes.map((route) => ({\n ...route,\n seo: normalizeGraphqlSeo(route.seo)\n }));\n }\n\n async getComposition(uri: string, locale?: string, options: { includeContent?: boolean } = {}): Promise<FlowpressCompositionV1 | null> {\n const data = await this.request<{\n sfCompositionByUri: null | {\n version: \"1\";\n sourceDigest: string;\n locale?: string | null;\n templateJson: string;\n blocksJson: string;\n stylesheetsJson: string;\n blockTypesJson: string;\n diagnosticsJson: string;\n routeJson: string;\n contentJson?: string | null;\n };\n }>(\n `query FlowpressComposition($uri: String!, $locale: String${options.includeContent === false ? \", $includeContent: Boolean\" : \"\"}) {\n sfCompositionByUri(uri: $uri, locale: $locale${options.includeContent === false ? \", includeContent: $includeContent\" : \"\"}) {\n version sourceDigest locale templateJson blocksJson stylesheetsJson blockTypesJson\n diagnosticsJson routeJson contentJson\n }\n }`,\n { uri, locale: locale ?? null, ...(options.includeContent === false ? { includeContent: false } : {}) }\n );\n const wire = data.sfCompositionByUri;\n if (!wire) return null;\n const route = parseRequiredJson<Omit<FlowpressRoute, \"seo\"> & { seo?: GraphqlSeo | SfSeo | null }>(wire.routeJson, \"routeJson\");\n return {\n version: wire.version,\n sourceDigest: wire.sourceDigest,\n locale: wire.locale ?? null,\n template: parseRequiredJson(wire.templateJson, \"templateJson\"),\n blocks: parseRequiredJson(wire.blocksJson, \"blocksJson\"),\n stylesheets: parseRequiredJson(wire.stylesheetsJson, \"stylesheetsJson\"),\n blockTypes: parseRequiredJson(wire.blockTypesJson, \"blockTypesJson\"),\n diagnostics: parseRequiredJson(wire.diagnosticsJson, \"diagnosticsJson\"),\n route: { ...route, seo: normalizeGraphqlSeo(route.seo) },\n content: parseJson(wire.contentJson, null)\n };\n }\n\n /** Site Editor already returns route and content in its composition. No\n * route preflight, retries or cross-request cache are needed for previews.\n */\n async getPage(uri: string, options: { locale?: string; includeContent?: boolean } = {}): Promise<{ route: FlowpressRoute; content: FlowpressContent | null; composition: FlowpressCompositionV1 } | null> {\n const composition = await this.getComposition(uri, options.locale, options);\n return composition ? { route: composition.route, content: composition.content ?? null, composition } : null;\n }\n\n}\n\n/** Timeouts, unreachable endpoints and gateway/rate-limit statuses; never GraphQL errors. */\nfunction isTransientFailure(error: unknown): boolean {\n if (!(error instanceof FlowpressGraphqlError)) return false;\n return error.status === undefined\n ? error.cause !== undefined\n : RETRYABLE_STATUSES.has(error.status);\n}\n\nfunction boundedInteger(value: number, name: string, min: number, max = Number.MAX_SAFE_INTEGER): number {\n if (!Number.isInteger(value) || value < min || value > max) {\n const range = max === Number.MAX_SAFE_INTEGER ? `>= ${min}` : `between ${min} and ${max}`;\n throw new Error(`FlowPress GraphQL ${name} must be an integer ${range}.`);\n }\n return value;\n}\n\nfunction getOperationName(query: string): string {\n return query.match(\n /\\b(?:query|mutation|subscription)\\s+([_A-Za-z][_0-9A-Za-z]*)/\n )?.[1] || \"AnonymousOperation\";\n}\n\nfunction sanitizeEndpoint(endpoint: string): string {\n const url = new URL(endpoint);\n url.username = \"\";\n url.password = \"\";\n url.search = \"\";\n url.hash = \"\";\n return url.toString();\n}\n\ninterface GraphqlSeo {\n title?: string | null;\n description?: string | null;\n canonicalUrl?: string | null;\n robots?: string[] | null;\n headHtml?: string | null;\n jsonLd?: { raw?: string | null } | null;\n openGraph?: GraphqlSocial | null;\n twitterMeta?: GraphqlSocial | null;\n hreflang?: Array<{ locale: string; url: string }> | null;\n}\n\ninterface GraphqlSocial {\n title?: string | null;\n description?: string | null;\n image?: { url: string; altText?: string | null } | null;\n}\n\nfunction normalizeGraphqlSeo(seo?: GraphqlSeo | SfSeo | null) {\n if (!seo) return null;\n const social = (value?: GraphqlSocial | SfSeo[\"openGraph\"] | null) => {\n if (!value) return null;\n const source = value.image as (NonNullable<NonNullable<SfSeo[\"openGraph\"]>[\"image\"]> & { altText?: string | null }) | null | undefined;\n const { altText, ...image } = source ?? {};\n return {\n title: value.title ?? null,\n description: value.description ?? null,\n image: source ? { ...image, url: source.url, alt: altText ?? source.alt ?? null } : null\n };\n };\n\n return {\n title: seo.title ?? null,\n description: seo.description ?? null,\n canonicalUrl: seo.canonicalUrl ?? null,\n robots: seo.robots ?? null,\n headHtml: seo.headHtml ?? null,\n jsonLd: seo.jsonLd && typeof seo.jsonLd === \"object\" && \"raw\" in seo.jsonLd\n ? parseJson((seo.jsonLd as { raw?: string | null }).raw, null) : seo.jsonLd ?? null,\n hreflang: seo.hreflang ?? null,\n openGraph: social(seo.openGraph),\n twitter: social(\"twitterMeta\" in seo ? seo.twitterMeta : (seo as SfSeo).twitter)\n };\n}\n\nfunction parseJson<T>(value: string | null | undefined, fallback: T): T {\n if (!value) return fallback;\n try {\n return JSON.parse(value) as T;\n } catch {\n return fallback;\n }\n}\n\nfunction parseRequiredJson<T>(value: string, field: string): T {\n try {\n return JSON.parse(value) as T;\n } catch (error) {\n throw new FlowpressGraphqlError(\n `FlowPress composition field ${field} is not valid JSON.`,\n undefined,\n undefined,\n \"FlowpressComposition\",\n undefined,\n error\n );\n }\n}\n\nfunction canonicalVariables(value: unknown): unknown {\n const normalized = JSON.parse(JSON.stringify(value)) as unknown;\n const sort = (item: unknown): unknown => Array.isArray(item)\n ? item.map(sort)\n : item && typeof item === \"object\"\n ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b)).map(([key, child]) => [key, sort(child)]))\n : item;\n return sort(normalized);\n}\n"]}
|
package/dist/env.d.ts
CHANGED
|
@@ -19,4 +19,16 @@ export interface FlowpressMediaRemotePattern {
|
|
|
19
19
|
export declare function resolveFlowpressMediaUrl(env: NodeJS.ProcessEnv): string;
|
|
20
20
|
export declare function flowpressMediaRemotePattern(env: NodeJS.ProcessEnv): FlowpressMediaRemotePattern;
|
|
21
21
|
export declare function readFlowpressEnvironment(env?: NodeJS.ProcessEnv): FlowpressEnvironment;
|
|
22
|
+
/** Node build stores wait this long on another process before giving up. */
|
|
23
|
+
export declare const FLOWPRESS_BUILD_STORE_LOCK_MS = 120000;
|
|
24
|
+
export interface FlowpressGraphqlOptions {
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
retries?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Optional client tuning from FLOWPRESS_GRAPHQL_TIMEOUT_MS and
|
|
30
|
+
* FLOWPRESS_GRAPHQL_RETRIES. The worst case (every attempt timing out plus
|
|
31
|
+
* backoff) must end before a waiting build process abandons the shared store.
|
|
32
|
+
*/
|
|
33
|
+
export declare function readFlowpressGraphqlOptions(env?: NodeJS.ProcessEnv): FlowpressGraphqlOptions;
|
|
22
34
|
//# sourceMappingURL=env.d.ts.map
|
package/dist/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,eAAe,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAQvE;AAED,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,2BAA2B,CAS7B;AA0BD,wBAAgB,wBAAwB,CACtC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,oBAAoB,CAuBtB;AAED,4EAA4E;AAC5E,eAAO,MAAM,6BAA6B,SAAU,CAAC;AAErD,MAAM,WAAW,uBAAuB;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,uBAAuB,CAgBzB"}
|
package/dist/env.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_GRAPHQL_RETRIES, DEFAULT_GRAPHQL_RETRY_DELAY_MS, DEFAULT_GRAPHQL_TIMEOUT_MS } from "./client.js";
|
|
1
2
|
export function resolveFlowpressMediaUrl(env) {
|
|
2
3
|
const key = env.FLOWPRESS_MEDIA?.trim() ? "FLOWPRESS_MEDIA" : "BACKEND_URL";
|
|
3
4
|
const value = validUrl(required(env, key), key);
|
|
@@ -56,4 +57,36 @@ export function readFlowpressEnvironment(env = process.env) {
|
|
|
56
57
|
localAstroPort: port(required(env, "LOCAL_ASTRO_PORT"), "LOCAL_ASTRO_PORT")
|
|
57
58
|
};
|
|
58
59
|
}
|
|
60
|
+
/** Node build stores wait this long on another process before giving up. */
|
|
61
|
+
export const FLOWPRESS_BUILD_STORE_LOCK_MS = 120_000;
|
|
62
|
+
/**
|
|
63
|
+
* Optional client tuning from FLOWPRESS_GRAPHQL_TIMEOUT_MS and
|
|
64
|
+
* FLOWPRESS_GRAPHQL_RETRIES. The worst case (every attempt timing out plus
|
|
65
|
+
* backoff) must end before a waiting build process abandons the shared store.
|
|
66
|
+
*/
|
|
67
|
+
export function readFlowpressGraphqlOptions(env = process.env) {
|
|
68
|
+
const timeoutMs = optionalInteger(env, "FLOWPRESS_GRAPHQL_TIMEOUT_MS", 1_000, 60_000);
|
|
69
|
+
const retries = optionalInteger(env, "FLOWPRESS_GRAPHQL_RETRIES", 0, 5);
|
|
70
|
+
const attempts = (retries ?? DEFAULT_GRAPHQL_RETRIES) + 1;
|
|
71
|
+
const worstCase = (timeoutMs ?? DEFAULT_GRAPHQL_TIMEOUT_MS) * attempts
|
|
72
|
+
+ DEFAULT_GRAPHQL_RETRY_DELAY_MS * (2 ** (attempts - 1) - 1);
|
|
73
|
+
if (worstCase >= FLOWPRESS_BUILD_STORE_LOCK_MS) {
|
|
74
|
+
throw new Error(`FLOWPRESS_GRAPHQL_TIMEOUT_MS x attempts reaches ${worstCase}ms; `
|
|
75
|
+
+ `keep it below the ${FLOWPRESS_BUILD_STORE_LOCK_MS}ms build store lock.`);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
79
|
+
...(retries === undefined ? {} : { retries })
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function optionalInteger(env, key, min, max) {
|
|
83
|
+
const value = env[key]?.trim();
|
|
84
|
+
if (!value)
|
|
85
|
+
return undefined;
|
|
86
|
+
const parsed = Number(value);
|
|
87
|
+
if (!/^\d+$/.test(value) || parsed < min || parsed > max) {
|
|
88
|
+
throw new Error(`${key} must be an integer between ${min} and ${max}.`);
|
|
89
|
+
}
|
|
90
|
+
return parsed;
|
|
91
|
+
}
|
|
59
92
|
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,8BAA8B,EAC9B,0BAA0B,EAC3B,MAAM,aAAa,CAAC;AAuBrB,MAAM,UAAU,wBAAwB,CAAC,GAAsB;IAC7D,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,aAAa,CAAC;IAC5E,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,oDAAoD,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,GAAsB;IAEtB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC;IACnD,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE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APHQL_TIMEOUT_MS\n} from \"./client.js\";\n\nexport type AstroOutputMode = \"static\" | \"server\";\n\nexport interface FlowpressEnvironment {\n appEnv: string;\n projectName: string;\n projectSlug: string;\n outputMode: AstroOutputMode;\n siteUrl: string;\n backendUrl: string;\n mediaUrl: string;\n graphqlUrl: string;\n localAstroPort: number;\n}\n\nexport interface FlowpressMediaRemotePattern {\n protocol: \"http\" | \"https\";\n hostname: string;\n port?: string;\n pathname: string;\n}\n\nexport function resolveFlowpressMediaUrl(env: NodeJS.ProcessEnv): string {\n const key = env.FLOWPRESS_MEDIA?.trim() ? \"FLOWPRESS_MEDIA\" : \"BACKEND_URL\";\n const value = validUrl(required(env, key), key);\n const url = new URL(value);\n if (url.username || url.password || url.search || url.hash) {\n throw new Error(`${key} must not contain credentials, query, or fragment.`);\n }\n return url.toString().replace(/\\/+$/, \"\");\n}\n\nexport function flowpressMediaRemotePattern(\n env: NodeJS.ProcessEnv\n): FlowpressMediaRemotePattern {\n const url = new URL(resolveFlowpressMediaUrl(env));\n const basePath = url.pathname.replace(/\\/+$/, \"\");\n return {\n protocol: url.protocol.slice(0, -1) as \"http\" | \"https\",\n hostname: url.hostname,\n ...(url.port ? { port: url.port } : {}),\n pathname: basePath ? `${basePath}/**` : \"/**\"\n };\n}\n\nfunction required(env: NodeJS.ProcessEnv, key: string): string {\n const value = env[key]?.trim();\n if (!value) {\n throw new Error(`Missing required environment variable ${key}.`);\n }\n return value;\n}\n\nfunction validUrl(value: string, key: string): string {\n try {\n return new URL(value).toString().replace(/\\/$/, \"\");\n } catch {\n throw new Error(`${key} must be an absolute URL.`);\n }\n}\n\nfunction port(value: string, key: string): number {\n const parsed = Number.parseInt(value, 10);\n if (!Number.isInteger(parsed) || parsed < 1 || parsed > 65_535) {\n throw new Error(`${key} must be a valid TCP port.`);\n }\n return parsed;\n}\n\nexport function readFlowpressEnvironment(\n env: NodeJS.ProcessEnv = process.env\n): FlowpressEnvironment {\n const outputMode = required(env, \"ASTRO_OUTPUT_MODE\");\n if (outputMode !== \"static\" && outputMode !== \"server\") {\n throw new Error(\"ASTRO_OUTPUT_MODE must be static or server.\");\n }\n\n return {\n appEnv: required(env, \"APP_ENV\"),\n projectName: required(env, \"PROJECT_NAME\"),\n projectSlug: required(env, \"PROJECT_SLUG\"),\n outputMode,\n siteUrl: validUrl(required(env, \"SITE_URL\"), \"SITE_URL\"),\n backendUrl: validUrl(required(env, \"BACKEND_URL\"), \"BACKEND_URL\"),\n mediaUrl: resolveFlowpressMediaUrl(env),\n graphqlUrl: validUrl(\n required(env, \"BACKEND_GRAPHQL_URL\"),\n \"BACKEND_GRAPHQL_URL\"\n ),\n localAstroPort: port(\n required(env, \"LOCAL_ASTRO_PORT\"),\n \"LOCAL_ASTRO_PORT\"\n )\n };\n}\n\n/** Node build stores wait this long on another process before giving up. */\nexport const FLOWPRESS_BUILD_STORE_LOCK_MS = 120_000;\n\nexport interface FlowpressGraphqlOptions {\n timeoutMs?: number;\n retries?: number;\n}\n\n/**\n * Optional client tuning from FLOWPRESS_GRAPHQL_TIMEOUT_MS and\n * FLOWPRESS_GRAPHQL_RETRIES. The worst case (every attempt timing out plus\n * backoff) must end before a waiting build process abandons the shared store.\n */\nexport function readFlowpressGraphqlOptions(\n env: NodeJS.ProcessEnv = process.env\n): FlowpressGraphqlOptions {\n const timeoutMs = optionalInteger(env, \"FLOWPRESS_GRAPHQL_TIMEOUT_MS\", 1_000, 60_000);\n const retries = optionalInteger(env, \"FLOWPRESS_GRAPHQL_RETRIES\", 0, 5);\n const attempts = (retries ?? DEFAULT_GRAPHQL_RETRIES) + 1;\n const worstCase = (timeoutMs ?? DEFAULT_GRAPHQL_TIMEOUT_MS) * attempts\n + DEFAULT_GRAPHQL_RETRY_DELAY_MS * (2 ** (attempts - 1) - 1);\n if (worstCase >= FLOWPRESS_BUILD_STORE_LOCK_MS) {\n throw new Error(\n `FLOWPRESS_GRAPHQL_TIMEOUT_MS x attempts reaches ${worstCase}ms; `\n + `keep it below the ${FLOWPRESS_BUILD_STORE_LOCK_MS}ms build store lock.`\n );\n }\n return {\n ...(timeoutMs === undefined ? {} : { timeoutMs }),\n ...(retries === undefined ? {} : { retries })\n };\n}\n\nfunction optionalInteger(\n env: NodeJS.ProcessEnv,\n key: string,\n min: number,\n max: number\n): number | undefined {\n const value = env[key]?.trim();\n if (!value) return undefined;\n const parsed = Number(value);\n if (!/^\\d+$/.test(value) || parsed < min || parsed > max) {\n throw new Error(`${key} must be an integer between ${min} and ${max}.`);\n }\n return parsed;\n}\n"]}
|
package/package.json
CHANGED