@styleflow.app/flowpress-astro-core 1.0.0-beta.33 → 1.0.0-beta.35
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 +18 -0
- package/README.md +5 -5
- package/dist/astro/native/registry.d.ts.map +1 -1
- package/dist/astro/native/registry.js +0 -3
- package/dist/astro/native/registry.js.map +1 -1
- package/dist/astro/native/registry.ts +0 -3
- package/dist/build-cache.d.ts +8 -0
- package/dist/build-cache.d.ts.map +1 -0
- package/dist/build-cache.js +81 -0
- package/dist/build-cache.js.map +1 -0
- package/dist/client.d.ts +10 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +35 -50
- package/dist/client.js.map +1 -1
- package/dist/default-blocks.d.ts.map +1 -1
- package/dist/default-blocks.js +0 -3
- package/dist/default-blocks.js.map +1 -1
- package/dist/media.d.ts +2 -10
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +10 -116
- package/dist/media.js.map +1 -1
- package/dist/template-hierarchy.d.ts +0 -7
- package/dist/template-hierarchy.d.ts.map +1 -1
- package/dist/template-hierarchy.js +0 -21
- package/dist/template-hierarchy.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -6
- package/dist/astro/DefaultTemplate.astro +0 -47
- package/dist/templates.d.ts +0 -19
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -20
- package/dist/templates.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.35 — 2026-10-26
|
|
4
|
+
|
|
5
|
+
- Add a fresh CMS content revision API and an optional request store; HTTP remains the default.
|
|
6
|
+
- Export a separate Node build store for private, revision-bound data shared across processes. Authenticated queries, mutations and failed responses bypass storage.
|
|
7
|
+
- [Canonical report](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-10-26-prestazioni-oauth-dmo.md).
|
|
8
|
+
|
|
9
|
+
## 1.0.0-beta.34 — 2026-10-20
|
|
10
|
+
|
|
11
|
+
- Make page loading composition-only and retire content-loader and conventional Astro template APIs.
|
|
12
|
+
- Remove pilot block aliases and media proxies; redirect historical file URLs to their real origins while preserving editorial /media pages.
|
|
13
|
+
- [Canonical report](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-10-20-sync-site-editor-ritiro-legacy.md).
|
|
14
|
+
|
|
3
15
|
## 1.0.0-beta.33 — 2026-10-15
|
|
4
16
|
|
|
5
17
|
- Preserve inherited surfaces and layout on native blocks rendered in nested semantic passes, including dynamic query titles.
|
|
18
|
+
- Point README installation and release instructions to the current pins and canonical release evidence.
|
|
6
19
|
- [Canonical verification](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-10-14-consolidamento-tessari.md).
|
|
7
20
|
|
|
8
21
|
## 1.0.0-beta.32 — 2026-10-15
|
|
@@ -93,6 +106,11 @@
|
|
|
93
106
|
- Canonical behavior, migration and verification: [pilot integration](https://github.com/StyleFlow-App/styleflow-docs/blob/main/wiki/piloti-flowpress.md), [report](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-10-07-integrazione-piloti-flowpress.md).
|
|
94
107
|
|
|
95
108
|
## Unreleased
|
|
109
|
+
- Agent rules only, no runtime or API change: `AGENTS.md` names the canonical
|
|
110
|
+
docs vault path (2026-10-18) and requires every published change to be
|
|
111
|
+
merged into `main`, with its branches, worktrees and stashes removed in the
|
|
112
|
+
same task.
|
|
113
|
+
[Canonical report](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-10-19-branch-residui-e-regole-di-chiusura.md).
|
|
96
114
|
|
|
97
115
|
## 1.0.0-beta.16
|
|
98
116
|
|
package/README.md
CHANGED
|
@@ -9,8 +9,8 @@ The package must not import from an application or project plugin.
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
pnpm add @styleflow.app/flowpress-astro-core@1.0.0-beta.
|
|
13
|
-
@styleflow.app/astro@1.0.0-beta.
|
|
12
|
+
pnpm add @styleflow.app/flowpress-astro-core@1.0.0-beta.33 \
|
|
13
|
+
@styleflow.app/astro@1.0.0-beta.9
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Prereleases are pinned exactly. The package expects Astro 7 or newer and the
|
|
@@ -262,9 +262,9 @@ The TypeScript template-hierarchy suite is self-contained. Its additional PHP
|
|
|
262
262
|
parity test runs when the sibling `flowpress-wordpress-core` checkout is
|
|
263
263
|
available locally and is skipped in a standalone package checkout.
|
|
264
264
|
|
|
265
|
-
Publish
|
|
266
|
-
|
|
267
|
-
|
|
265
|
+
Publish prereleases on `next` through CI/OIDC from an immutable version tag on main.
|
|
266
|
+
Inspect the workflow, registry, `gitHead`, integrity and downloaded tarball.
|
|
267
|
+
Canonical release and adoption evidence is in the [consolidation report](https://github.com/StyleFlow-App/styleflow-docs/blob/main/dev/rapporti/2026-10-14-consolidamento-tessari.md).
|
|
268
268
|
|
|
269
269
|
Release activity reports are indexed in
|
|
270
270
|
[`docs/activities/README.md`](docs/activities/README.md).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/astro/native/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAwCxE,eAAO,MAAM,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/astro/native/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAwCxE,eAAO,MAAM,oBAAoB,EAAE,uBAyClC,CAAC"}
|
|
@@ -71,11 +71,8 @@ export const nativeBlockRenderers = {
|
|
|
71
71
|
"core/navigation-link": Renderer25,
|
|
72
72
|
"core/post-title": Renderer26,
|
|
73
73
|
"sf/post-field": Renderer27,
|
|
74
|
-
"project/post-field": Renderer27,
|
|
75
74
|
"sf/block-binding": Renderer28,
|
|
76
|
-
"project/block-binding": Renderer28,
|
|
77
75
|
"sf/term-field": Renderer29,
|
|
78
|
-
"project/term-field": Renderer29,
|
|
79
76
|
"sf/blob": BlobBlock,
|
|
80
77
|
"sf/map": Renderer30,
|
|
81
78
|
"sf/timeline": Renderer31,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/astro/native/registry.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,SAAS,MAAM,yBAAyB,CAAC;AAChD,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,SAAS,MAAM,2BAA2B,CAAC;AAClD,OAAO,SAAS,MAAM,+BAA+B,CAAC;AACtD,OAAO,SAAS,MAAM,4BAA4B,CAAC;AACnD,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAC1D,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAChD,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAO,UAAU,MAAM,4BAA4B,CAAC;AACpD,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,UAAU,MAAM,iCAAiC,CAAC;AACzD,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,UA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kB,EAAE,UAAU;IAC9B,cAAc,EAAE,UAAU;IAC1B,YAAY,EAAE,UAAU;IACxB,iBAAiB,EAAE,aAAa;IAChC,+BAA+B,EAAE,aAAa;IAC9C,uBAAuB,EAAE,UAAU;IACnC,oBAAoB,EAAE,UAAU;IAChC,iBAAiB,EAAE,UAAU;IAC7B,yBAAyB,EAAE,UAAU;IACrC,YAAY,EAAE,UAAU;IACxB,gBAAgB,EAAE,UAAU;IAC5B,qBAAqB,EAAE,UAAU;IACjC,sBAAsB,EAAE,UAAU;IAClC,iBAAiB,EAAE,UAAU;IAC7B,eAAe,EAAE,UAAU;IAC3B,kBAAkB,EAAE,UAAU;IAC9B,eAAe,EAAE,UAAU;IAC3B,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,UAAU;IACzB,kBAAkB,EAAE,iBAAiB;CACtC,CAAC","sourcesContent":["import type { FlowpressBlockRenderers } from \"../../block-renderers.js\";\nimport Renderer0 from \"./core-term-name.astro\";\nimport Renderer2 from \"./core-post-terms.astro\";\nimport Renderer3 from \"./core-button.astro\";\nimport Renderer4 from \"./core-post-date.astro\";\nimport Renderer5 from \"./core-icon.astro\";\nimport Renderer6 from \"./core-post-excerpt.astro\";\nimport Renderer7 from \"./core-term-description.astro\";\nimport Renderer8 from \"./core-post-template.astro\";\nimport Renderer9 from \"./core-group.astro\";\nimport Renderer10 from \"./core-html.astro\";\nimport Renderer11 from \"./core-block.astro\";\nimport Renderer12 from \"./core-site-title.astro\";\nimport Renderer13 from \"./core-post-featured-image.astro\";\nimport Renderer14 from \"./core-page-list.astro\";\nimport Renderer15 from \"./core-terms-query.astro\";\nimport Renderer16 from \"./core-buttons.astro\";\nimport Renderer17 from \"./core-image.astro\";\nimport Renderer18 from \"./core-query-no-results.astro\";\nimport Renderer19 from \"./core-term-template.astro\";\nimport Renderer20 from \"./core-navigation.astro\";\nimport Renderer21 from \"./core-navigation-submenu.astro\";\nimport Renderer22 from \"./core-query.astro\";\nimport Renderer23 from \"./core-home-link.astro\";\nimport Renderer24 from \"./core-page-list-item.astro\";\nimport Renderer25 from \"./core-navigation-link.astro\";\nimport Renderer26 from \"./core-post-title.astro\";\nimport Renderer27 from \"./sf-post-field.astro\";\nimport Renderer28 from \"./sf-block-binding.astro\";\nimport Renderer29 from \"./sf-term-field.astro\";\nimport Renderer30 from \"./MapBlock.astro\";\nimport Renderer31 from \"./ProjectTimelineBlock.astro\";\nimport TimelineCardBlock from \"./TimelineCardBlock.astro\";\nimport BlobBlock from \"./BlobBlock.astro\";\nimport TransparentBlock from \"./core-transparent.astro\";\nimport SeparatorBlock from \"./core-separator.astro\";\nimport SiteLogoBlock from \"../blocks/SiteLogoBlock.astro\";\nimport ThemeToggleBlock from \"../blocks/ThemeToggleBlock.astro\";\nimport ReservedLogin from \"./ReservedLogin.astro\";\n\nexport const nativeBlockRenderers: FlowpressBlockRenderers = {\n \"core/separator\": SeparatorBlock,\n \"core/post-content\": TransparentBlock,\n \"core/template-part\": TransparentBlock,\n \"core/site-logo\": SiteLogoBlock,\n \"sf/theme-toggle\": ThemeToggleBlock,\n \"core/term-name\": Renderer0,\n \"core/post-terms\": Renderer2,\n \"core/button\": Renderer3,\n \"core/post-date\": Renderer4,\n \"core/icon\": Renderer5,\n \"core/post-excerpt\": Renderer6,\n \"core/term-description\": Renderer7,\n \"core/post-template\": Renderer8,\n \"core/group\": Renderer9,\n \"core/html\": Renderer10,\n \"core/block\": Renderer11,\n \"core/site-title\": Renderer12,\n \"core/post-featured-image\": Renderer13,\n \"core/page-list\": Renderer14,\n \"core/terms-query\": Renderer15,\n \"core/buttons\": Renderer16,\n \"core/image\": Renderer17,\n \"flowpress/login\": ReservedLogin,\n \"flowpress/reserved-pagination\": ReservedLogin,\n \"core/query-no-results\": Renderer18,\n \"core/term-template\": Renderer19,\n \"core/navigation\": Renderer20,\n \"core/navigation-submenu\": Renderer21,\n \"core/query\": Renderer22,\n \"core/home-link\": Renderer23,\n \"core/page-list-item\": Renderer24,\n \"core/navigation-link\": Renderer25,\n \"core/post-title\": Renderer26,\n \"sf/post-field\": Renderer27,\n \"sf/block-binding\": Renderer28,\n \"sf/term-field\": Renderer29,\n \"sf/blob\": BlobBlock,\n \"sf/map\": Renderer30,\n \"sf/timeline\": Renderer31,\n \"sf/timeline-card\": TimelineCardBlock,\n};\n"]}
|
|
@@ -73,11 +73,8 @@ export const nativeBlockRenderers: FlowpressBlockRenderers = {
|
|
|
73
73
|
"core/navigation-link": Renderer25,
|
|
74
74
|
"core/post-title": Renderer26,
|
|
75
75
|
"sf/post-field": Renderer27,
|
|
76
|
-
"project/post-field": Renderer27,
|
|
77
76
|
"sf/block-binding": Renderer28,
|
|
78
|
-
"project/block-binding": Renderer28,
|
|
79
77
|
"sf/term-field": Renderer29,
|
|
80
|
-
"project/term-field": Renderer29,
|
|
81
78
|
"sf/blob": BlobBlock,
|
|
82
79
|
"sf/map": Renderer30,
|
|
83
80
|
"sf/timeline": Renderer31,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FlowpressRequestStore } from "./client.js";
|
|
2
|
+
export interface FlowpressBuildStoreOptions {
|
|
3
|
+
directory: string;
|
|
4
|
+
endpoint: string;
|
|
5
|
+
revision: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function createBuildRequestStore(options: FlowpressBuildStoreOptions): Promise<FlowpressRequestStore>;
|
|
8
|
+
//# sourceMappingURL=build-cache.d.ts.map
|
|
@@ -0,0 +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;AAIzD,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"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** Node-only, private store shared by the safelist and Astro build processes. */
|
|
2
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
+
import { lstat, readFile, rename, writeFile, unlink, mkdir, rmdir } from "node:fs/promises";
|
|
4
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
5
|
+
import { isAbsolute, join } from "node:path";
|
|
6
|
+
const inFlight = new Map();
|
|
7
|
+
export async function createBuildRequestStore(options) {
|
|
8
|
+
const { directory, endpoint, revision } = options;
|
|
9
|
+
if (!isAbsolute(directory) || !/^[a-f0-9]{32}$/.test(revision)) {
|
|
10
|
+
throw new Error("A build request store requires a private absolute directory and content revision.");
|
|
11
|
+
}
|
|
12
|
+
const stat = await lstat(directory);
|
|
13
|
+
if (!stat.isDirectory() || stat.isSymbolicLink() || (stat.mode & 0o077)) {
|
|
14
|
+
throw new Error("The build request directory must be private and cannot be a symlink.");
|
|
15
|
+
}
|
|
16
|
+
const metadata = JSON.parse(await readFile(join(directory, "session.json"), "utf8"));
|
|
17
|
+
if (metadata.schemaVersion !== 1 || metadata.endpoint !== endpoint || metadata.revision !== revision) {
|
|
18
|
+
throw new Error("The build request store belongs to another backend or revision.");
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
async getOrCreate(key, load) {
|
|
22
|
+
const identity = JSON.parse(key);
|
|
23
|
+
if (identity.endpoint !== endpoint)
|
|
24
|
+
throw new Error("Cross-backend build cache access refused.");
|
|
25
|
+
const digest = createHash("sha256").update(key).digest("hex");
|
|
26
|
+
const file = join(directory, digest + ".json");
|
|
27
|
+
const pending = inFlight.get(file);
|
|
28
|
+
if (pending)
|
|
29
|
+
return pending;
|
|
30
|
+
const result = (async () => {
|
|
31
|
+
const lock = file + ".lock";
|
|
32
|
+
const deadline = Date.now() + 120000;
|
|
33
|
+
while (true) {
|
|
34
|
+
try {
|
|
35
|
+
await mkdir(lock, { mode: 0o700 });
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (error.code !== "EEXIST")
|
|
40
|
+
throw error;
|
|
41
|
+
if (Date.now() > deadline)
|
|
42
|
+
throw new Error("Timed out waiting for another build process. Discard this attempt.");
|
|
43
|
+
await delay(20);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
try {
|
|
48
|
+
const cached = JSON.parse(await readFile(file, "utf8"));
|
|
49
|
+
if (cached.key === key && Object.hasOwn(cached, "value"))
|
|
50
|
+
return cached.value;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (!(error instanceof SyntaxError) && error.code !== "ENOENT")
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
const value = await load();
|
|
57
|
+
const temporary = file + "." + randomUUID() + ".tmp";
|
|
58
|
+
try {
|
|
59
|
+
await writeFile(temporary, JSON.stringify({ key, value }), { mode: 0o600, flag: "wx" });
|
|
60
|
+
await rename(temporary, file);
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
await unlink(temporary).catch(() => { });
|
|
64
|
+
}
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
await rmdir(lock);
|
|
69
|
+
}
|
|
70
|
+
})();
|
|
71
|
+
inFlight.set(file, result);
|
|
72
|
+
try {
|
|
73
|
+
return await result;
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
inFlight.delete(file);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=build-cache.js.map
|
|
@@ -0,0 +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,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GAAG,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;4BAAE,OAAO,MAAM,CAAC,KAAU,CAAC;oBACrF,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,IAAI,CAAC,CAAC,KAAK,YAAY,WAAW,CAAC,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;4BAAE,MAAM,KAAK,CAAC;oBACzG,CAAC;oBACD,MAAM,KAAK,GAAG,MAAM,IAAI,EAAE,CAAC;oBAC3B,MAAM,SAAS,GAAG,IAAI,GAAG,GAAG,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\";\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() + 120000;\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
|
@@ -7,11 +7,16 @@ export interface FlowpressGraphqlIssue {
|
|
|
7
7
|
[key: string]: unknown;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
+
/** Store only successful anonymous query data; implementations may deduplicate in flight. */
|
|
11
|
+
export interface FlowpressRequestStore {
|
|
12
|
+
getOrCreate<T>(key: string, load: () => Promise<T>): Promise<T>;
|
|
13
|
+
}
|
|
10
14
|
export interface FlowpressClientOptions {
|
|
11
15
|
endpoint: string;
|
|
12
16
|
timeoutMs?: number;
|
|
13
17
|
headers?: Record<string, string>;
|
|
14
18
|
debug?: boolean;
|
|
19
|
+
requestStore?: FlowpressRequestStore;
|
|
15
20
|
}
|
|
16
21
|
export declare class FlowpressGraphqlError extends Error {
|
|
17
22
|
readonly status?: number | undefined;
|
|
@@ -25,27 +30,27 @@ export declare class FlowpressClient {
|
|
|
25
30
|
readonly timeoutMs: number;
|
|
26
31
|
readonly headers: Record<string, string>;
|
|
27
32
|
readonly debug: boolean;
|
|
33
|
+
readonly requestStore: FlowpressRequestStore | undefined;
|
|
28
34
|
constructor(options: FlowpressClientOptions);
|
|
29
35
|
request<T>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
36
|
+
getContentRevision(): Promise<string>;
|
|
37
|
+
private requestUncached;
|
|
30
38
|
getCapabilities(): Promise<FlowpressCapabilities>;
|
|
31
39
|
getRoute(uri: string, locale?: string): Promise<FlowpressRoute | null>;
|
|
32
40
|
getRoutes(locale?: string): Promise<FlowpressRoute[]>;
|
|
33
|
-
getContent(loader: string, variables: Record<string, unknown>): Promise<FlowpressContent | null>;
|
|
34
41
|
getComposition(uri: string, locale?: string, options?: {
|
|
35
42
|
includeContent?: boolean;
|
|
36
43
|
}): Promise<FlowpressCompositionV1 | null>;
|
|
37
44
|
/** Site Editor already returns route and content in its composition. No
|
|
38
45
|
* route preflight, retries or cross-request cache are needed for previews.
|
|
39
46
|
*/
|
|
40
|
-
getPage(uri: string, options
|
|
41
|
-
mode: "site-editor" | "astro";
|
|
47
|
+
getPage(uri: string, options?: {
|
|
42
48
|
locale?: string;
|
|
43
|
-
route?: FlowpressRoute;
|
|
44
49
|
includeContent?: boolean;
|
|
45
50
|
}): Promise<{
|
|
46
51
|
route: FlowpressRoute;
|
|
47
52
|
content: FlowpressContent | null;
|
|
48
|
-
composition: FlowpressCompositionV1
|
|
53
|
+
composition: FlowpressCompositionV1;
|
|
49
54
|
} | null>;
|
|
50
55
|
}
|
|
51
56
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EAEf,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE;QACX,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAOD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;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K1M"}
|
package/dist/client.js
CHANGED
|
@@ -17,6 +17,7 @@ export class FlowpressClient {
|
|
|
17
17
|
timeoutMs;
|
|
18
18
|
headers;
|
|
19
19
|
debug;
|
|
20
|
+
requestStore;
|
|
20
21
|
constructor(options) {
|
|
21
22
|
const endpoint = options.endpoint.trim();
|
|
22
23
|
if (!endpoint) {
|
|
@@ -27,8 +28,30 @@ export class FlowpressClient {
|
|
|
27
28
|
this.timeoutMs = options.timeoutMs ?? 15_000;
|
|
28
29
|
this.headers = { ...options.headers };
|
|
29
30
|
this.debug = options.debug ?? false;
|
|
31
|
+
this.requestStore = options.requestStore;
|
|
30
32
|
}
|
|
31
33
|
async request(query, variables = {}) {
|
|
34
|
+
const url = new URL(this.endpoint);
|
|
35
|
+
const anonymousQuery = Object.keys(this.headers).length === 0
|
|
36
|
+
&& !url.username && !url.password
|
|
37
|
+
&& /^(?:query\b|\{)/.test(query.trim())
|
|
38
|
+
&& !/\b(?:mutation|subscription|sfContentRevision)\b/.test(query);
|
|
39
|
+
if (this.requestStore && anonymousQuery) {
|
|
40
|
+
return this.requestStore.getOrCreate(JSON.stringify({
|
|
41
|
+
endpoint: this.endpoint, query, variables: canonicalVariables(variables)
|
|
42
|
+
}), () => this.requestUncached(query, variables));
|
|
43
|
+
}
|
|
44
|
+
return this.requestUncached(query, variables);
|
|
45
|
+
}
|
|
46
|
+
async getContentRevision() {
|
|
47
|
+
// This read must never come from the build store it is validating.
|
|
48
|
+
const data = await this.requestUncached("query FlowpressContentRevision { sfContentRevision }", {});
|
|
49
|
+
if (!/^[a-f0-9]{32}$/.test(data.sfContentRevision || "")) {
|
|
50
|
+
throw new Error("WordPress returned no valid FlowPress content revision.");
|
|
51
|
+
}
|
|
52
|
+
return data.sfContentRevision;
|
|
53
|
+
}
|
|
54
|
+
async requestUncached(query, variables) {
|
|
32
55
|
const controller = new AbortController();
|
|
33
56
|
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
34
57
|
const operationName = getOperationName(query);
|
|
@@ -174,41 +197,6 @@ export class FlowpressClient {
|
|
|
174
197
|
seo: normalizeGraphqlSeo(route.seo)
|
|
175
198
|
}));
|
|
176
199
|
}
|
|
177
|
-
async getContent(loader, variables) {
|
|
178
|
-
const data = await this.request(`query FlowpressContent(
|
|
179
|
-
$loader: String!,
|
|
180
|
-
$databaseId: Int,
|
|
181
|
-
$termId: Int,
|
|
182
|
-
$uri: String,
|
|
183
|
-
$locale: String
|
|
184
|
-
) {
|
|
185
|
-
sfContentByLoader(
|
|
186
|
-
loader: $loader,
|
|
187
|
-
databaseId: $databaseId,
|
|
188
|
-
termId: $termId,
|
|
189
|
-
uri: $uri,
|
|
190
|
-
locale: $locale
|
|
191
|
-
) {
|
|
192
|
-
title excerpt content contentBlocksJson projectFieldsJson
|
|
193
|
-
}
|
|
194
|
-
}`, {
|
|
195
|
-
loader,
|
|
196
|
-
databaseId: variables.databaseId ?? null,
|
|
197
|
-
termId: variables.termId ?? null,
|
|
198
|
-
uri: variables.uri ?? null,
|
|
199
|
-
locale: variables.locale ?? null
|
|
200
|
-
});
|
|
201
|
-
const content = data.sfContentByLoader;
|
|
202
|
-
if (!content) {
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
const { contentBlocksJson, projectFieldsJson, ...rest } = content;
|
|
206
|
-
return {
|
|
207
|
-
...rest,
|
|
208
|
-
contentBlocks: parseJson(contentBlocksJson, []),
|
|
209
|
-
projectFields: parseJson(projectFieldsJson, {})
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
200
|
async getComposition(uri, locale, options = {}) {
|
|
213
201
|
const data = await this.request(`query FlowpressComposition($uri: String!, $locale: String${options.includeContent === false ? ", $includeContent: Boolean" : ""}) {
|
|
214
202
|
sfCompositionByUri(uri: $uri, locale: $locale${options.includeContent === false ? ", includeContent: $includeContent" : ""}) {
|
|
@@ -236,21 +224,9 @@ export class FlowpressClient {
|
|
|
236
224
|
/** Site Editor already returns route and content in its composition. No
|
|
237
225
|
* route preflight, retries or cross-request cache are needed for previews.
|
|
238
226
|
*/
|
|
239
|
-
async getPage(uri, options) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
return composition ? { route: composition.route, content: composition.content ?? null, composition } : null;
|
|
243
|
-
}
|
|
244
|
-
const route = options.route ?? await this.getRoute(uri, options.locale);
|
|
245
|
-
if (!route)
|
|
246
|
-
return null;
|
|
247
|
-
const content = route.content?.loader ? await this.getContent(route.content.loader, {
|
|
248
|
-
databaseId: route.content.databaseId ?? route.databaseId,
|
|
249
|
-
termId: route.content.termId ?? route.termId,
|
|
250
|
-
uri: route.uri,
|
|
251
|
-
locale: route.locale ?? options.locale
|
|
252
|
-
}) : null;
|
|
253
|
-
return { route, content, composition: null };
|
|
227
|
+
async getPage(uri, options = {}) {
|
|
228
|
+
const composition = await this.getComposition(uri, options.locale, options);
|
|
229
|
+
return composition ? { route: composition.route, content: composition.content ?? null, composition } : null;
|
|
254
230
|
}
|
|
255
231
|
}
|
|
256
232
|
function getOperationName(query) {
|
|
@@ -309,4 +285,13 @@ function parseRequiredJson(value, field) {
|
|
|
309
285
|
throw new FlowpressGraphqlError(`FlowPress composition field ${field} is not valid JSON.`, undefined, undefined, "FlowpressComposition", undefined, error);
|
|
310
286
|
}
|
|
311
287
|
}
|
|
288
|
+
function canonicalVariables(value) {
|
|
289
|
+
const normalized = JSON.parse(JSON.stringify(value));
|
|
290
|
+
const sort = (item) => Array.isArray(item)
|
|
291
|
+
? item.map(sort)
|
|
292
|
+
: item && typeof item === "object"
|
|
293
|
+
? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b)).map(([key, child]) => [key, sort(child)]))
|
|
294
|
+
: item;
|
|
295
|
+
return sort(normalized);
|
|
296
|
+
}
|
|
312
297
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AA6BA,MAAM,O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,SAAS,EACT,sBAAsB,EACtB,SAAS,EACT,KAAK,CACN,CAAC;IACJ,CAAC;AACH,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\nexport interface FlowpressClientOptions {\n endpoint: string;\n timeoutMs?: number;\n headers?: Record<string, string>;\n debug?: boolean;\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\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 }\n\n async request<T>(\n query: string,\n variables: Record<string, unknown> = {}\n ): 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 getContent(\n loader: string,\n variables: Record<string, unknown>\n ): Promise<FlowpressContent | null> {\n const data = await this.request<{\n sfContentByLoader: (Omit<FlowpressContent, \"contentBlocks\"> & {\n contentBlocksJson?: string | null;\n projectFieldsJson?: string | null;\n }) | null;\n }>(\n `query FlowpressContent(\n $loader: String!,\n $databaseId: Int,\n $termId: Int,\n $uri: String,\n $locale: String\n ) {\n sfContentByLoader(\n loader: $loader,\n databaseId: $databaseId,\n termId: $termId,\n uri: $uri,\n locale: $locale\n ) {\n title excerpt content contentBlocksJson projectFieldsJson\n }\n }`,\n {\n loader,\n databaseId: variables.databaseId ?? null,\n termId: variables.termId ?? null,\n uri: variables.uri ?? null,\n locale: variables.locale ?? null\n }\n );\n const content = data.sfContentByLoader;\n if (!content) {\n return null;\n }\n const { contentBlocksJson, projectFieldsJson, ...rest } = content;\n return {\n ...rest,\n contentBlocks: parseJson(contentBlocksJson, []),\n projectFields: parseJson(projectFieldsJson, {})\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: {\n mode: \"site-editor\" | \"astro\";\n locale?: string;\n route?: FlowpressRoute;\n includeContent?: boolean;\n }): Promise<{ route: FlowpressRoute; content: FlowpressContent | null; composition: FlowpressCompositionV1 | null } | null> {\n if (options.mode === \"site-editor\") {\n const composition = await this.getComposition(uri, options.locale, options);\n return composition ? { route: composition.route, content: composition.content ?? null, composition } : null;\n }\n const route = options.route ?? await this.getRoute(uri, options.locale);\n if (!route) return null;\n const content = route.content?.loader ? await this.getContent(route.content.loader, {\n databaseId: route.content.databaseId ?? route.databaseId,\n termId: route.content.termId ?? route.termId,\n uri: route.uri,\n locale: route.locale ?? options.locale\n }) : null;\n return { route, content, 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"]}
|
|
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,KAA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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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-blocks.d.ts","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uCAAuC,EAAG,GAAY,CAAC;AAEpE,MAAM,WAAW,iCAAiC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,2BAA2B,CAAC;CACvC;
|
|
1
|
+
{"version":3,"file":"default-blocks.d.ts","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uCAAuC,EAAG,GAAY,CAAC;AAEpE,MAAM,WAAW,iCAAiC;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,2BAA2B,CAAC;CACvC;AAkFD,eAAO,MAAM,4BAA4B,EAAE,SAAS,iCAAiC,EACc,CAAC;AAIpG,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE1E;AAED,wBAAgB,wCAAwC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CA+BlF"}
|
package/dist/default-blocks.js
CHANGED
|
@@ -39,11 +39,8 @@ const blockNames = [
|
|
|
39
39
|
"core/navigation-link",
|
|
40
40
|
"core/post-title",
|
|
41
41
|
"sf/post-field",
|
|
42
|
-
"project/post-field",
|
|
43
42
|
"sf/block-binding",
|
|
44
|
-
"project/block-binding",
|
|
45
43
|
"sf/term-field",
|
|
46
|
-
"project/term-field",
|
|
47
44
|
"sf/timeline",
|
|
48
45
|
"core/cover",
|
|
49
46
|
"core/group",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-blocks.js","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uCAAuC,GAAG,GAAY,CAAC;AAOpE,MAAM,UAAU,GAAG;IACjB,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB,oBAAoB;IACpB,cAAc;IACd,eAAe;IACf,SAAS;IACT,UAAU;IACV,YAAY;IACZ,eAAe;IACf,iBAAiB;IAEjB,gBAAgB;IAChB,iBAAiB;IACjB,aAAa;IACb,iBAAiB;IACjB,+BAA+B;IAC/B,gBAAgB;IAChB,WAAW;IACX,mBAAmB;IACnB,uBAAuB;IACvB,oBAAoB;IACpB,WAAW;IACX,YAAY;IACZ,iBAAiB;IACjB,0BAA0B;IAC1B,gBAAgB;IAChB,kBAAkB;IAClB,cAAc;IACd,YAAY;IACZ,uBAAuB;IACvB,oBAAoB;IACpB,iBAAiB;IACjB,yBAAyB;IACzB,YAAY;IACZ,gBAAgB;IAChB,qBAAqB;IACrB,sBAAsB;IACtB,iBAAiB;IACjB,eAAe;IACf,
|
|
1
|
+
{"version":3,"file":"default-blocks.js","sourceRoot":"","sources":["../src/default-blocks.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uCAAuC,GAAG,GAAY,CAAC;AAOpE,MAAM,UAAU,GAAG;IACjB,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB,oBAAoB;IACpB,cAAc;IACd,eAAe;IACf,SAAS;IACT,UAAU;IACV,YAAY;IACZ,eAAe;IACf,iBAAiB;IAEjB,gBAAgB;IAChB,iBAAiB;IACjB,aAAa;IACb,iBAAiB;IACjB,+BAA+B;IAC/B,gBAAgB;IAChB,WAAW;IACX,mBAAmB;IACnB,uBAAuB;IACvB,oBAAoB;IACpB,WAAW;IACX,YAAY;IACZ,iBAAiB;IACjB,0BAA0B;IAC1B,gBAAgB;IAChB,kBAAkB;IAClB,cAAc;IACd,YAAY;IACZ,uBAAuB;IACvB,oBAAoB;IACpB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ourcesContent":["export const FLOWPRESS_DEFAULT_BLOCK_CATALOG_VERSION = \"6\" as const;\n\nexport interface FlowpressDefaultBlockCatalogEntry {\n blockName: string;\n template: \"DefaultBlockAdapter.astro\";\n}\n\nconst blockNames = [\n \"core/separator\",\n \"core/post-content\",\n \"core/site-logo\",\n \"core/template-part\",\n \"sf/accordion\",\n \"sf/collection\",\n \"sf/flex\",\n \"sf/group\",\n \"sf/marquee\",\n \"sf/media-text\",\n \"sf/theme-toggle\",\n\n \"core/term-name\",\n \"core/post-terms\",\n \"core/button\",\n \"flowpress/login\",\n \"flowpress/reserved-pagination\",\n \"core/post-date\",\n \"core/icon\",\n \"core/post-excerpt\",\n \"core/term-description\",\n \"core/post-template\",\n \"core/html\",\n \"core/block\",\n \"core/site-title\",\n \"core/post-featured-image\",\n \"core/page-list\",\n \"core/terms-query\",\n \"core/buttons\",\n \"core/image\",\n \"core/query-no-results\",\n \"core/term-template\",\n \"core/navigation\",\n \"core/navigation-submenu\",\n \"core/query\",\n \"core/home-link\",\n \"core/page-list-item\",\n \"core/navigation-link\",\n \"core/post-title\",\n \"sf/post-field\",\n \"sf/block-binding\",\n \"sf/term-field\",\n \"sf/timeline\",\n \"core/cover\",\n \"core/group\",\n \"core/heading\",\n \"core/list\",\n \"core/list-item\",\n \"core/paragraph\",\n \"core/quote\",\n \"sf/accordion-item\",\n \"sf/button\",\n \"sf/card\",\n \"sf/carousel\",\n \"sf/carousel-item\",\n \"sf/chip\",\n \"sf/code\",\n \"sf/column\",\n \"sf/content-list\",\n \"sf/form\",\n \"sf/gallery\",\n \"sf/grid\",\n \"sf/heading\",\n \"sf/hero\",\n \"sf/icon\",\n \"sf/image\",\n \"sf/blob\",\n \"sf/timeline-card\",\n \"sf/map\",\n \"sf/number-spinner\",\n \"sf/quote\",\n \"sf/rich-text\",\n \"sf/section\",\n \"sf/template\",\n \"sf/term-list\",\n \"sf/video\",\n \"sf/video-youtube\"\n] as const;\n\nexport const flowpressDefaultBlockCatalog: readonly FlowpressDefaultBlockCatalogEntry[] =\n [...blockNames].sort().map((blockName) => ({ blockName, template: \"DefaultBlockAdapter.astro\" }));\n\nconst supported = new Set<string>(blockNames);\n\nexport function hasFlowpressDefaultBlockAdapter(blockName: string): boolean {\n return supported.has(blockName);\n}\n\nexport function createFlowpressDefaultBlockAdapterSource(blockName: string): string {\n if (!hasFlowpressDefaultBlockAdapter(blockName)) {\n throw new Error(`FlowPress has no official default adapter for ${blockName}.`);\n }\n if (blockName === \"core/cover\") {\n return `---\nimport CoverBlock from \"@styleflow.app/flowpress-astro-core/blocks/CoverBlock.astro\";\nimport type { FlowpressBlockRendererProps } from \"@styleflow.app/flowpress-astro-core\";\n\nconst { block, contract, htmlProps, styleflowProps } = Astro.props as FlowpressBlockRendererProps;\n---\n\n<CoverBlock\n block={block}\n contract={contract}\n htmlProps={htmlProps}\n styleflowProps={styleflowProps}\n>\n <slot />\n</CoverBlock>\n`;\n }\n return `---\nimport DefaultBlockAdapter from \"@styleflow.app/flowpress-astro-core/DefaultBlockAdapter.astro\";\nimport type { FlowpressBlockRendererProps } from \"@styleflow.app/flowpress-astro-core\";\n\nconst props = Astro.props as FlowpressBlockRendererProps;\n---\n\n<DefaultBlockAdapter {...props} />\n`;\n}\n"]}
|
package/dist/media.d.ts
CHANGED
|
@@ -15,14 +15,6 @@ export declare function rewriteFlowpressMediaUrls<T>(value: T, options: Flowpres
|
|
|
15
15
|
export declare function isFlowpressUploadPath(pathname: string): boolean;
|
|
16
16
|
export declare function isFlowpressMediaPath(pathname: string): boolean;
|
|
17
17
|
export declare function rewriteFlowpressBackendUrl(value: string, backendUrl: string, frontendOrigin?: string): string;
|
|
18
|
-
/**
|
|
19
|
-
export declare function
|
|
20
|
-
/**
|
|
21
|
-
* Proxy /media/<path> to the current FLOWPRESS_MEDIA origin (an offload CDN,
|
|
22
|
-
* or the WordPress backend as a fallback). /media/ is a frontend-only routing
|
|
23
|
-
* marker with no equivalent on either upstream, so it is stripped before the
|
|
24
|
-
* request is forwarded: /media/2026/09/x.jpg becomes <origin>/2026/09/x.jpg.
|
|
25
|
-
*/
|
|
26
|
-
/** @deprecated Deliver media directly from storage. Kept for existing consumers. */
|
|
27
|
-
export declare function proxyFlowpressMedia(request: Request, mediaUrl: string, fetchImpl?: typeof fetch): Promise<Response>;
|
|
18
|
+
/** Historical file URLs redirect to their real origin; editorial /media pages remain routes. */
|
|
19
|
+
export declare function redirectFlowpressMedia(request: Request, options: FlowpressFrontendMediaOptions): Response | null;
|
|
28
20
|
//# sourceMappingURL=media.d.ts.map
|
package/dist/media.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAEhD,MAAM,WAAW,6BAA6B;IAC5C,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,yEAAyE;IACzE,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CAC9C;AAiCD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,6BAA6B,GAAG,MAAM,CAEtG;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,6BAA6B,GAAG,CAAC,CAyBhG;
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAEhD,MAAM,WAAW,6BAA6B;IAC5C,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,yEAAyE;IACzE,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;CAC9C;AAiCD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,6BAA6B,GAAG,MAAM,CAEtG;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,6BAA6B,GAAG,CAAC,CAyBhG;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG/D;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG9D;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,cAAc,SAAK,GAClB,MAAM,CASR;AAED,gGAAgG;AAChG,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,6BAA6B,GAAG,QAAQ,GAAG,IAAI,CAOhH"}
|
package/dist/media.js
CHANGED
|
@@ -72,26 +72,6 @@ export function rewriteFlowpressMediaUrls(value, options) {
|
|
|
72
72
|
}
|
|
73
73
|
return rewrite(value);
|
|
74
74
|
}
|
|
75
|
-
const requestHeaders = [
|
|
76
|
-
"accept",
|
|
77
|
-
"if-match",
|
|
78
|
-
"if-modified-since",
|
|
79
|
-
"if-none-match",
|
|
80
|
-
"if-unmodified-since",
|
|
81
|
-
"range"
|
|
82
|
-
];
|
|
83
|
-
const responseHeaders = [
|
|
84
|
-
"accept-ranges",
|
|
85
|
-
"cache-control",
|
|
86
|
-
"content-disposition",
|
|
87
|
-
"content-encoding",
|
|
88
|
-
"content-length",
|
|
89
|
-
"content-range",
|
|
90
|
-
"content-type",
|
|
91
|
-
"etag",
|
|
92
|
-
"last-modified",
|
|
93
|
-
"vary"
|
|
94
|
-
];
|
|
95
75
|
export function isFlowpressUploadPath(pathname) {
|
|
96
76
|
return pathname === FLOWPRESS_UPLOADS_PREFIX.slice(0, -1)
|
|
97
77
|
|| pathname.startsWith(FLOWPRESS_UPLOADS_PREFIX);
|
|
@@ -112,101 +92,15 @@ export function rewriteFlowpressBackendUrl(value, backendUrl, frontendOrigin = "
|
|
|
112
92
|
return value;
|
|
113
93
|
}
|
|
114
94
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
return new Response("Bad Gateway", { status: 502 });
|
|
128
|
-
}
|
|
129
|
-
const headers = new Headers();
|
|
130
|
-
for (const name of requestHeaders) {
|
|
131
|
-
const value = request.headers.get(name);
|
|
132
|
-
if (value)
|
|
133
|
-
headers.set(name, value);
|
|
134
|
-
}
|
|
135
|
-
try {
|
|
136
|
-
// Follow storage redirects on the server: Location must never reveal the
|
|
137
|
-
// backend/CDN origin to the browser or move it off the public media URL.
|
|
138
|
-
let upstream;
|
|
139
|
-
for (let redirects = 0;; redirects++) {
|
|
140
|
-
upstream = await fetchImpl(target, { method: request.method, headers, redirect: "manual" });
|
|
141
|
-
const location = upstream.headers.get("location");
|
|
142
|
-
if (![301, 302, 303, 307, 308].includes(upstream.status) || !location)
|
|
143
|
-
break;
|
|
144
|
-
await upstream.body?.cancel();
|
|
145
|
-
if (redirects >= 5)
|
|
146
|
-
throw new Error("Too many media redirects.");
|
|
147
|
-
target = new URL(location, target);
|
|
148
|
-
if (!/^https?:$/.test(target.protocol) || target.username || target.password) {
|
|
149
|
-
throw new Error("Invalid media redirect.");
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const safeHeaders = new Headers();
|
|
153
|
-
for (const name of responseHeaders) {
|
|
154
|
-
const value = upstream.headers.get(name);
|
|
155
|
-
if (value)
|
|
156
|
-
safeHeaders.set(name, value);
|
|
157
|
-
}
|
|
158
|
-
return new Response(request.method === "HEAD" ? null : upstream.body, {
|
|
159
|
-
status: upstream.status,
|
|
160
|
-
statusText: upstream.statusText,
|
|
161
|
-
headers: safeHeaders
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
catch {
|
|
165
|
-
return new Response("Bad Gateway", { status: 502 });
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/** @deprecated Deliver media directly from WordPress or storage. Kept for existing consumers. */
|
|
169
|
-
export function proxyFlowpressUpload(request, backendUrl, fetchImpl = fetch) {
|
|
170
|
-
return proxyFlowpressAsset(request, backendUrl, fetchImpl, {
|
|
171
|
-
prefix: FLOWPRESS_UPLOADS_PREFIX,
|
|
172
|
-
preserveUpstreamPath: false,
|
|
173
|
-
stripPrefix: false
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Proxy /media/<path> to the current FLOWPRESS_MEDIA origin (an offload CDN,
|
|
178
|
-
* or the WordPress backend as a fallback). /media/ is a frontend-only routing
|
|
179
|
-
* marker with no equivalent on either upstream, so it is stripped before the
|
|
180
|
-
* request is forwarded: /media/2026/09/x.jpg becomes <origin>/2026/09/x.jpg.
|
|
181
|
-
*/
|
|
182
|
-
/** @deprecated Deliver media directly from storage. Kept for existing consumers. */
|
|
183
|
-
export function proxyFlowpressMedia(request, mediaUrl, fetchImpl = fetch) {
|
|
184
|
-
return proxyFlowpressAsset(request, mediaUrl, fetchImpl, {
|
|
185
|
-
prefix: FLOWPRESS_MEDIA_PREFIX,
|
|
186
|
-
preserveUpstreamPath: true,
|
|
187
|
-
stripPrefix: true
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
function assetTarget(requestUrl, upstreamUrl, prefix, preserveUpstreamPath, stripPrefix) {
|
|
191
|
-
const request = new URL(requestUrl);
|
|
192
|
-
if (request.pathname !== prefix.slice(0, -1) && !request.pathname.startsWith(prefix)) {
|
|
193
|
-
throw new Error("Unsupported FlowPress asset path.");
|
|
194
|
-
}
|
|
195
|
-
const upstream = new URL(upstreamUrl);
|
|
196
|
-
if (!/^https?:$/.test(upstream.protocol)
|
|
197
|
-
|| upstream.username
|
|
198
|
-
|| upstream.password
|
|
199
|
-
|| upstream.search
|
|
200
|
-
|| upstream.hash) {
|
|
201
|
-
throw new Error("Invalid FlowPress asset upstream.");
|
|
202
|
-
}
|
|
203
|
-
const requestPath = stripPrefix
|
|
204
|
-
? request.pathname.slice(prefix.length - 1) || "/"
|
|
205
|
-
: request.pathname;
|
|
206
|
-
const target = new URL(upstream.origin);
|
|
207
|
-
const upstreamPath = preserveUpstreamPath ? upstream.pathname.replace(/\/+$/, "") : "";
|
|
208
|
-
target.pathname = `${upstreamPath}${requestPath}`;
|
|
209
|
-
target.search = request.search;
|
|
210
|
-
return target;
|
|
95
|
+
/** Historical file URLs redirect to their real origin; editorial /media pages remain routes. */
|
|
96
|
+
export function redirectFlowpressMedia(request, options) {
|
|
97
|
+
const url = new URL(request.url);
|
|
98
|
+
const file = /\.[a-z0-9]{1,8}$/i.test(url.pathname);
|
|
99
|
+
if (!(isFlowpressUploadPath(url.pathname) || (isFlowpressMediaPath(url.pathname) && file)))
|
|
100
|
+
return null;
|
|
101
|
+
if (!["GET", "HEAD"].includes(request.method))
|
|
102
|
+
return new Response("Method Not Allowed", { status: 405, headers: { allow: "GET, HEAD" } });
|
|
103
|
+
const target = rewriteFlowpressMediaUrl(url.href, options);
|
|
104
|
+
return target === url.href ? null : Response.redirect(target, 308);
|
|
211
105
|
}
|
|
212
106
|
//# sourceMappingURL=media.js.map
|
package/dist/media.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.js","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AACxD,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAUhD;;;G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QAAQ,CAAC,QAAQ;WACjB,QAAQ,CAAC,QAAQ;WACjB,QAAQ,CAAC,MAAM;WACf,QAAQ,CAAC,IAAI,EAChB,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,WAAW,GAAG,WAAW;QAC7B,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG;QAClD,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACrB,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,YAAY,GAAG,oBAAoB,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvF,MAAM,CAAC,QAAQ,GAAG,GAAG,YAAY,GAAG,WAAW,EAAE,CAAC;IAClD,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC/B,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["export const FLOWPRESS_UPLOADS_PREFIX = \"/app/uploads/\";\nexport const FLOWPRESS_MEDIA_PREFIX = \"/media/\";\n\nexport interface FlowpressFrontendMediaOptions {\n frontendOrigin: string;\n backendUrl?: string | undefined;\n mediaUrl?: string | undefined;\n /** Canonical frontend URLs and aliases owned by the selected backend. */\n frontendUrls?: readonly string[] | undefined;\n}\n\n/** Resolve legacy frontend media aliases to their real origin. Absolute URLs\n * supplied by WordPress/offload plugins remain authoritative, even in a mixed\n * library. FLOWPRESS_MEDIA is only used to undo the old /media/ alias.\n */\nfunction mediaResolver(options: FlowpressFrontendMediaOptions): (value: string) => string {\n try {\n const frontend = new URL(options.frontendOrigin);\n const backend = options.backendUrl ? new URL(options.backendUrl) : undefined;\n const media = options.mediaUrl ? new URL(options.mediaUrl) : backend;\n const frontends = new Set([frontend.origin, ...(options.frontendUrls ?? []).map((url) => new URL(url).origin)]);\n return (value) => {\n // Most JSON strings are labels, HTML or CSS: avoid parsing these as URLs.\n if (!value || /\\s/.test(value) || !/^(?:https?:\\/\\/|\\/)/i.test(value)) return value;\n try {\n const source = new URL(value, frontend);\n if (!/^https?:$/.test(source.protocol) || source.username || source.password) return value;\n const relative = value.startsWith(\"/\") && !value.startsWith(\"//\");\n if (!relative && !frontends.has(source.origin)) return value;\n const uploads = /\\/(?:wp-content\\/)?uploads\\//i.test(source.pathname);\n if (uploads && backend) return `${backend.origin}${source.pathname}${source.search}${source.hash}`;\n // Do not mistake a page such as /media/gallery/ for an asset alias.\n if (source.pathname.startsWith(FLOWPRESS_MEDIA_PREFIX) && /\\.[a-z0-9]+$/i.test(source.pathname) && media) {\n const base = media.pathname.replace(/\\/+$/, \"\");\n return `${media.origin}${base}/${source.pathname.slice(FLOWPRESS_MEDIA_PREFIX.length)}${source.search}${source.hash}`;\n }\n return value;\n } catch { return value; }\n };\n } catch { return (value) => value; }\n}\n\nexport function rewriteFlowpressMediaUrl(value: string, options: FlowpressFrontendMediaOptions): string {\n return mediaResolver(options)(value);\n}\n\n/** Normalize media data once, sharing unchanged branches and parsing origins\n * once per payload. HTML, CSS and scripts remain intact.\n */\nexport function rewriteFlowpressMediaUrls<T>(value: T, options: FlowpressFrontendMediaOptions): T {\n const resolve = mediaResolver(options);\n function rewrite(item: unknown, key = \"\"): unknown {\n if (typeof item === \"string\") {\n return /^srcset$/i.test(key) ? item.replace(/\\S+/g, (token) => {\n const url = token.replace(/,+$/, \"\");\n return `${resolve(url)}${token.slice(url.length)}`;\n }) : resolve(item);\n }\n if (Array.isArray(item)) {\n const next = item.map((entry) => rewrite(entry));\n return next.some((entry, i) => entry !== item[i]) ? next : item;\n }\n if (item && typeof item === \"object\") {\n let changed = false;\n const next = Object.fromEntries(Object.entries(item).map(([name, entry]) => {\n const result = rewrite(entry, name);\n changed ||= result !== entry;\n return [name, result];\n }));\n return changed ? next : item;\n }\n return item;\n }\n return rewrite(value) as T;\n}\n\nconst requestHeaders = [\n \"accept\",\n \"if-match\",\n \"if-modified-since\",\n \"if-none-match\",\n \"if-unmodified-since\",\n \"range\"\n] as const;\n\nconst responseHeaders = [\n \"accept-ranges\",\n \"cache-control\",\n \"content-disposition\",\n \"content-encoding\",\n \"content-length\",\n \"content-range\",\n \"content-type\",\n \"etag\",\n \"last-modified\",\n \"vary\"\n] as const;\n\nexport function isFlowpressUploadPath(pathname: string): boolean {\n return pathname === FLOWPRESS_UPLOADS_PREFIX.slice(0, -1)\n || pathname.startsWith(FLOWPRESS_UPLOADS_PREFIX);\n}\n\nexport function isFlowpressMediaPath(pathname: string): boolean {\n return pathname === FLOWPRESS_MEDIA_PREFIX.slice(0, -1)\n || pathname.startsWith(FLOWPRESS_MEDIA_PREFIX);\n}\n\nexport function rewriteFlowpressBackendUrl(\n value: string,\n backendUrl: string,\n frontendOrigin = \"\"\n): string {\n try {\n const source = new URL(value);\n const backend = new URL(backendUrl);\n if (source.origin !== backend.origin || /\\/(?:wp-content\\/)?uploads\\//i.test(source.pathname)) return value;\n return `${frontendOrigin.replace(/\\/$/, \"\")}${source.pathname}${source.search}${source.hash}`;\n } catch {\n return value;\n }\n}\n\ninterface AssetProxyOptions {\n prefix: string;\n preserveUpstreamPath: boolean;\n stripPrefix: boolean;\n}\n\nasync function proxyFlowpressAsset(\n request: Request,\n upstreamUrl: string,\n fetchImpl: typeof fetch,\n options: AssetProxyOptions\n): Promise<Response> {\n if (request.method !== \"GET\" && request.method !== \"HEAD\") {\n return new Response(\"Method Not Allowed\", {\n status: 405,\n headers: { allow: \"GET, HEAD\" }\n });\n }\n let target: URL;\n try {\n target = assetTarget(\n request.url,\n upstreamUrl,\n options.prefix,\n options.preserveUpstreamPath,\n options.stripPrefix\n );\n } catch {\n return new Response(\"Bad Gateway\", { status: 502 });\n }\n\n const headers = new Headers();\n for (const name of requestHeaders) {\n const value = request.headers.get(name);\n if (value) headers.set(name, value);\n }\n try {\n // Follow storage redirects on the server: Location must never reveal the\n // backend/CDN origin to the browser or move it off the public media URL.\n let upstream: Response;\n for (let redirects = 0; ; redirects++) {\n upstream = await fetchImpl(target, { method: request.method, headers, redirect: \"manual\" });\n const location = upstream.headers.get(\"location\");\n if (![301, 302, 303, 307, 308].includes(upstream.status) || !location) break;\n await upstream.body?.cancel();\n if (redirects >= 5) throw new Error(\"Too many media redirects.\");\n target = new URL(location, target);\n if (!/^https?:$/.test(target.protocol) || target.username || target.password) {\n throw new Error(\"Invalid media redirect.\");\n }\n }\n const safeHeaders = new Headers();\n for (const name of responseHeaders) {\n const value = upstream.headers.get(name);\n if (value) safeHeaders.set(name, value);\n }\n return new Response(request.method === \"HEAD\" ? null : upstream.body, {\n status: upstream.status,\n statusText: upstream.statusText,\n headers: safeHeaders\n });\n } catch {\n return new Response(\"Bad Gateway\", { status: 502 });\n }\n}\n\n/** @deprecated Deliver media directly from WordPress or storage. Kept for existing consumers. */\nexport function proxyFlowpressUpload(\n request: Request,\n backendUrl: string,\n fetchImpl: typeof fetch = fetch\n): Promise<Response> {\n return proxyFlowpressAsset(request, backendUrl, fetchImpl, {\n prefix: FLOWPRESS_UPLOADS_PREFIX,\n preserveUpstreamPath: false,\n stripPrefix: false\n });\n}\n\n/**\n * Proxy /media/<path> to the current FLOWPRESS_MEDIA origin (an offload CDN,\n * or the WordPress backend as a fallback). /media/ is a frontend-only routing\n * marker with no equivalent on either upstream, so it is stripped before the\n * request is forwarded: /media/2026/09/x.jpg becomes <origin>/2026/09/x.jpg.\n */\n/** @deprecated Deliver media directly from storage. Kept for existing consumers. */\nexport function proxyFlowpressMedia(\n request: Request,\n mediaUrl: string,\n fetchImpl: typeof fetch = fetch\n): Promise<Response> {\n return proxyFlowpressAsset(request, mediaUrl, fetchImpl, {\n prefix: FLOWPRESS_MEDIA_PREFIX,\n preserveUpstreamPath: true,\n stripPrefix: true\n });\n}\n\nfunction assetTarget(\n requestUrl: string,\n upstreamUrl: string,\n prefix: string,\n preserveUpstreamPath: boolean,\n stripPrefix: boolean\n): URL {\n const request = new URL(requestUrl);\n if (request.pathname !== prefix.slice(0, -1) && !request.pathname.startsWith(prefix)) {\n throw new Error(\"Unsupported FlowPress asset path.\");\n }\n const upstream = new URL(upstreamUrl);\n if (\n !/^https?:$/.test(upstream.protocol)\n || upstream.username\n || upstream.password\n || upstream.search\n || upstream.hash\n ) {\n throw new Error(\"Invalid FlowPress asset upstream.\");\n }\n const requestPath = stripPrefix\n ? request.pathname.slice(prefix.length - 1) || \"/\"\n : request.pathname;\n const target = new URL(upstream.origin);\n const upstreamPath = preserveUpstreamPath ? upstream.pathname.replace(/\\/+$/, \"\") : \"\";\n target.pathname = `${upstreamPath}${requestPath}`;\n target.search = request.search;\n return target;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AACxD,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAUhD;;;GAGG;AACH,SAAS,aAAa,CAAC,OAAsC;IAC3D,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7E,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACrE,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAA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,GAAG,wBAAwB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,OAAO,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACrE,CAAC","sourcesContent":["export const FLOWPRESS_UPLOADS_PREFIX = \"/app/uploads/\";\nexport const FLOWPRESS_MEDIA_PREFIX = \"/media/\";\n\nexport interface FlowpressFrontendMediaOptions {\n frontendOrigin: string;\n backendUrl?: string | undefined;\n mediaUrl?: string | undefined;\n /** Canonical frontend URLs and aliases owned by the selected backend. */\n frontendUrls?: readonly string[] | undefined;\n}\n\n/** Resolve legacy frontend media aliases to their real origin. Absolute URLs\n * supplied by WordPress/offload plugins remain authoritative, even in a mixed\n * library. FLOWPRESS_MEDIA is only used to undo the old /media/ alias.\n */\nfunction mediaResolver(options: FlowpressFrontendMediaOptions): (value: string) => string {\n try {\n const frontend = new URL(options.frontendOrigin);\n const backend = options.backendUrl ? new URL(options.backendUrl) : undefined;\n const media = options.mediaUrl ? new URL(options.mediaUrl) : backend;\n const frontends = new Set([frontend.origin, ...(options.frontendUrls ?? []).map((url) => new URL(url).origin)]);\n return (value) => {\n // Most JSON strings are labels, HTML or CSS: avoid parsing these as URLs.\n if (!value || /\\s/.test(value) || !/^(?:https?:\\/\\/|\\/)/i.test(value)) return value;\n try {\n const source = new URL(value, frontend);\n if (!/^https?:$/.test(source.protocol) || source.username || source.password) return value;\n const relative = value.startsWith(\"/\") && !value.startsWith(\"//\");\n if (!relative && !frontends.has(source.origin)) return value;\n const uploads = /\\/(?:wp-content\\/)?uploads\\//i.test(source.pathname);\n if (uploads && backend) return `${backend.origin}${source.pathname}${source.search}${source.hash}`;\n // Do not mistake a page such as /media/gallery/ for an asset alias.\n if (source.pathname.startsWith(FLOWPRESS_MEDIA_PREFIX) && /\\.[a-z0-9]+$/i.test(source.pathname) && media) {\n const base = media.pathname.replace(/\\/+$/, \"\");\n return `${media.origin}${base}/${source.pathname.slice(FLOWPRESS_MEDIA_PREFIX.length)}${source.search}${source.hash}`;\n }\n return value;\n } catch { return value; }\n };\n } catch { return (value) => value; }\n}\n\nexport function rewriteFlowpressMediaUrl(value: string, options: FlowpressFrontendMediaOptions): string {\n return mediaResolver(options)(value);\n}\n\n/** Normalize media data once, sharing unchanged branches and parsing origins\n * once per payload. HTML, CSS and scripts remain intact.\n */\nexport function rewriteFlowpressMediaUrls<T>(value: T, options: FlowpressFrontendMediaOptions): T {\n const resolve = mediaResolver(options);\n function rewrite(item: unknown, key = \"\"): unknown {\n if (typeof item === \"string\") {\n return /^srcset$/i.test(key) ? item.replace(/\\S+/g, (token) => {\n const url = token.replace(/,+$/, \"\");\n return `${resolve(url)}${token.slice(url.length)}`;\n }) : resolve(item);\n }\n if (Array.isArray(item)) {\n const next = item.map((entry) => rewrite(entry));\n return next.some((entry, i) => entry !== item[i]) ? next : item;\n }\n if (item && typeof item === \"object\") {\n let changed = false;\n const next = Object.fromEntries(Object.entries(item).map(([name, entry]) => {\n const result = rewrite(entry, name);\n changed ||= result !== entry;\n return [name, result];\n }));\n return changed ? next : item;\n }\n return item;\n }\n return rewrite(value) as T;\n}\n\nexport function isFlowpressUploadPath(pathname: string): boolean {\n return pathname === FLOWPRESS_UPLOADS_PREFIX.slice(0, -1)\n || pathname.startsWith(FLOWPRESS_UPLOADS_PREFIX);\n}\n\nexport function isFlowpressMediaPath(pathname: string): boolean {\n return pathname === FLOWPRESS_MEDIA_PREFIX.slice(0, -1)\n || pathname.startsWith(FLOWPRESS_MEDIA_PREFIX);\n}\n\nexport function rewriteFlowpressBackendUrl(\n value: string,\n backendUrl: string,\n frontendOrigin = \"\"\n): string {\n try {\n const source = new URL(value);\n const backend = new URL(backendUrl);\n if (source.origin !== backend.origin || /\\/(?:wp-content\\/)?uploads\\//i.test(source.pathname)) return value;\n return `${frontendOrigin.replace(/\\/$/, \"\")}${source.pathname}${source.search}${source.hash}`;\n } catch {\n return value;\n }\n}\n\n/** Historical file URLs redirect to their real origin; editorial /media pages remain routes. */\nexport function redirectFlowpressMedia(request: Request, options: FlowpressFrontendMediaOptions): Response | null {\n const url = new URL(request.url);\n const file = /\\.[a-z0-9]{1,8}$/i.test(url.pathname);\n if (!(isFlowpressUploadPath(url.pathname) || (isFlowpressMediaPath(url.pathname) && file))) return null;\n if (![\"GET\", \"HEAD\"].includes(request.method)) return new Response(\"Method Not Allowed\", { status: 405, headers: { allow: \"GET, HEAD\" } });\n const target = rewriteFlowpressMediaUrl(url.href, options);\n return target === url.href ? null : Response.redirect(target, 308);\n}\n"]}
|
|
@@ -6,11 +6,4 @@ import type { TemplateContext } from "./types.js";
|
|
|
6
6
|
* scaffolding.
|
|
7
7
|
*/
|
|
8
8
|
export declare function getTemplateCandidates(context: TemplateContext): string[];
|
|
9
|
-
export interface TemplateResolution<T> {
|
|
10
|
-
name: string;
|
|
11
|
-
component: T;
|
|
12
|
-
candidates: string[];
|
|
13
|
-
source: "project" | "core";
|
|
14
|
-
}
|
|
15
|
-
export declare function resolveTemplate<T>(candidates: string[], projectTemplates: Readonly<Record<string, T>>, coreTemplates: Readonly<Record<string, T>>): TemplateResolution<T>;
|
|
16
9
|
//# sourceMappingURL=template-hierarchy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-hierarchy.d.ts","sourceRoot":"","sources":["../src/template-hierarchy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAsDlD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,EAAE,CA8FxE
|
|
1
|
+
{"version":3,"file":"template-hierarchy.d.ts","sourceRoot":"","sources":["../src/template-hierarchy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAsDlD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,EAAE,CA8FxE"}
|
|
@@ -145,25 +145,4 @@ export function getTemplateCandidates(context) {
|
|
|
145
145
|
return ["404", "index"];
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
export function resolveTemplate(candidates, projectTemplates, coreTemplates) {
|
|
149
|
-
for (const candidate of candidates) {
|
|
150
|
-
const project = projectTemplates[candidate];
|
|
151
|
-
if (project) {
|
|
152
|
-
return { name: candidate, component: project, candidates, source: "project" };
|
|
153
|
-
}
|
|
154
|
-
const core = coreTemplates[candidate];
|
|
155
|
-
if (core) {
|
|
156
|
-
return { name: candidate, component: core, candidates, source: "core" };
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
const projectIndex = projectTemplates.index;
|
|
160
|
-
if (projectIndex) {
|
|
161
|
-
return { name: "index", component: projectIndex, candidates, source: "project" };
|
|
162
|
-
}
|
|
163
|
-
const coreIndex = coreTemplates.index;
|
|
164
|
-
if (!coreIndex) {
|
|
165
|
-
throw new Error("FlowPress requires a core index template.");
|
|
166
|
-
}
|
|
167
|
-
return { name: "index", component: coreIndex, candidates, source: "core" };
|
|
168
|
-
}
|
|
169
148
|
//# sourceMappingURL=template-hierarchy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-hierarchy.js","sourceRoot":"","sources":["../src/template-hierarchy.ts"],"names":[],"mappings":"AAEA,SAAS,QAAQ,CAAC,KAAyC;IACzD,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;SACvB,IAAI,EAAE;SACN,WAAW,EAAE;SACb,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;SACtB,OAAO,CAAC,+BAA+B,EAAE,GAAG,CAAC;SAC7C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE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AAU,eAAe,CAC7B,UAAoB,EACpB,gBAA6C,EAC7C,aAA0C;IAE1C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAC5C,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAChF,CAAC;QAED,MAAM,IAAI,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;QACtC,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAC1E,CAAC;IACH,CAAC;IAED,MAAM,YAAY,GAAG,gBAAgB,CAAC,KAAK,CAAC;IAC5C,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACnF,CAAC;IAED,MAAM,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC;IACtC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC7E,CAAC","sourcesContent":["import type { TemplateContext } from \"./types.js\";\n\nfunction slugPart(value: string | number | null | undefined): string {\n return String(value ?? \"\")\n .trim()\n .toLowerCase()\n .replace(/\\.php$/i, \"\")\n .replace(/[^a-z0-9_%\\-\\u0080-\\uFFFF]+/gu, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n\nfunction assignedTemplatePart(value: string | null | undefined): string {\n return String(value ?? \"\")\n .trim()\n .replace(/\\.php$/i, \"\")\n .split(\"/\")\n .map((part) => slugPart(part))\n .filter(Boolean)\n .join(\"/\");\n}\n\nfunction unique(values: Array<string | null | undefined>): string[] {\n return [...new Set(values.filter((value): value is string => Boolean(value)))];\n}\n\nfunction pageCandidates(context: TemplateContext): string[] {\n return unique([\n context.pageTemplate && context.pageTemplate !== \"default\"\n ? assignedTemplatePart(context.pageTemplate)\n : null,\n context.slug ? `page-${slugPart(context.slug)}` : null,\n context.databaseId ? `page-${context.databaseId}` : null,\n \"page\",\n \"singular\",\n \"index\"\n ]);\n}\n\nfunction attachmentMimeCandidates(mimeType?: string | null): string[] {\n const [type = \"\", subtype = \"\"] = String(mimeType ?? \"\")\n .toLowerCase()\n .split(\"/\", 2);\n const normalizedType = slugPart(type);\n const normalizedSubtype = slugPart(subtype);\n\n return unique([\n normalizedType && normalizedSubtype\n ? `${normalizedType}-${normalizedSubtype}`\n : null,\n normalizedSubtype || null,\n normalizedType || null\n ]);\n}\n\n/**\n * Mirrors the WordPress classic template hierarchy, without file extensions.\n * WordPress is still the source of truth at runtime and may filter candidates\n * before returning them to Astro; this pure function powers tests and offline\n * scaffolding.\n */\nexport function getTemplateCandidates(context: TemplateContext): string[] {\n switch (context.queryType) {\n case \"front-page\":\n return unique([\n \"front-page\",\n ...(context.frontPageMode === \"posts\"\n ? [\"home\", \"index\"]\n : pageCandidates(context))\n ]);\n case \"home\":\n return [\"home\", \"index\"];\n case \"privacy-policy\":\n return unique([\"privacy-policy\", ...pageCandidates(context)]);\n case \"page\":\n return pageCandidates(context);\n case \"single\":\n return unique([\n context.postType && context.slug\n ? `single-${slugPart(context.postType)}-${slugPart(context.slug)}`\n : null,\n context.postType ? `single-${slugPart(context.postType)}` : null,\n \"single\",\n \"singular\",\n \"index\"\n ]);\n case \"attachment\":\n return unique([\n ...attachmentMimeCandidates(context.mimeType),\n \"attachment\",\n context.slug ? `single-attachment-${slugPart(context.slug)}` : null,\n \"single-attachment\",\n \"single\",\n \"singular\",\n \"index\"\n ]);\n case \"post-type-archive\":\n return unique([\n context.postType ? `archive-${slugPart(context.postType)}` : null,\n \"archive\",\n \"index\"\n ]);\n case \"category\":\n return unique([\n context.slug ? `category-${slugPart(context.slug)}` : null,\n context.termId ? `category-${context.termId}` : null,\n \"category\",\n \"archive\",\n \"index\"\n ]);\n case \"tag\":\n return unique([\n context.slug ? `tag-${slugPart(context.slug)}` : null,\n context.termId ? `tag-${context.termId}` : null,\n \"tag\",\n \"archive\",\n \"index\"\n ]);\n case \"taxonomy\":\n return unique([\n context.taxonomy && context.term\n ? `taxonomy-${slugPart(context.taxonomy)}-${slugPart(context.term)}`\n : null,\n context.taxonomy ? `taxonomy-${slugPart(context.taxonomy)}` : null,\n \"taxonomy\",\n \"archive\",\n \"index\"\n ]);\n case \"author\":\n return unique([\n context.authorNicename\n ? `author-${slugPart(context.authorNicename)}`\n : null,\n context.authorId ? `author-${context.authorId}` : null,\n \"author\",\n \"archive\",\n \"index\"\n ]);\n case \"date\":\n return [\"date\", \"archive\", \"index\"];\n case \"search\":\n return [\"search\", \"index\"];\n case \"embed\":\n return unique([\n context.postType && context.postFormat\n ? `embed-${slugPart(context.postType)}-${slugPart(context.postFormat)}`\n : null,\n context.postType ? `embed-${slugPart(context.postType)}` : null,\n \"embed\"\n ]);\n case \"archive\":\n return [\"archive\", \"index\"];\n case \"404\":\n return [\"404\", \"index\"];\n }\n}\n\nexport interface TemplateResolution<T> {\n name: string;\n component: T;\n candidates: string[];\n source: \"project\" | \"core\";\n}\n\nexport function resolveTemplate<T>(\n candidates: string[],\n projectTemplates: Readonly<Record<string, T>>,\n coreTemplates: Readonly<Record<string, T>>\n): TemplateResolution<T> {\n for (const candidate of candidates) {\n const project = projectTemplates[candidate];\n if (project) {\n return { name: candidate, component: project, candidates, source: \"project\" };\n }\n\n const core = coreTemplates[candidate];\n if (core) {\n return { name: candidate, component: core, candidates, source: \"core\" };\n }\n }\n\n const projectIndex = projectTemplates.index;\n if (projectIndex) {\n return { name: \"index\", component: projectIndex, candidates, source: \"project\" };\n }\n\n const coreIndex = coreTemplates.index;\n if (!coreIndex) {\n throw new Error(\"FlowPress requires a core index template.\");\n }\n\n return { name: \"index\", component: coreIndex, candidates, source: \"core\" };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"template-hierarchy.js","sourceRoot":"","sources":["../src/template-hierarchy.ts"],"names":[],"mappings":"AAEA,SAAS,QAAQ,CAAC,KAAyC;IACzD,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;SACvB,IAAI,EAAE;SACN,WAAW,EAAE;SACb,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;SACtB,OAAO,CAAC,+BAA+B,EAAE,GAAG,CAAC;SAC7C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;SACvB,IAAI,EAAE;SACN,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;SACtB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SAC7B,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,SAAS,MAAM,CAAC,MAAwC;IACtD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,cAAc,CAAC,OAAwB;IAC9C,OAAO,MAAM,CAAC;QACZ,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS;YACxD,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,YAAY,CAAC;YAC5C,CAAC,CAAC,I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AQ;YACX,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC7B,KAAK,OAAO;YACV,OAAO,MAAM,CAAC;gBACZ,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,UAAU;oBACpC,CAAC,CAAC,SAAS,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;oBACvE,CAAC,CAAC,IAAI;gBACR,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;gBAC/D,OAAO;aACR,CAAC,CAAC;QACL,KAAK,SAAS;YACZ,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC9B,KAAK,KAAK;YACR,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC","sourcesContent":["import type { TemplateContext } from \"./types.js\";\n\nfunction slugPart(value: string | number | null | undefined): string {\n return String(value ?? \"\")\n .trim()\n .toLowerCase()\n .replace(/\\.php$/i, \"\")\n .replace(/[^a-z0-9_%\\-\\u0080-\\uFFFF]+/gu, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n\nfunction assignedTemplatePart(value: string | null | undefined): string {\n return String(value ?? \"\")\n .trim()\n .replace(/\\.php$/i, \"\")\n .split(\"/\")\n .map((part) => slugPart(part))\n .filter(Boolean)\n .join(\"/\");\n}\n\nfunction unique(values: Array<string | null | undefined>): string[] {\n return [...new Set(values.filter((value): value is string => Boolean(value)))];\n}\n\nfunction pageCandidates(context: TemplateContext): string[] {\n return unique([\n context.pageTemplate && context.pageTemplate !== \"default\"\n ? assignedTemplatePart(context.pageTemplate)\n : null,\n context.slug ? `page-${slugPart(context.slug)}` : null,\n context.databaseId ? `page-${context.databaseId}` : null,\n \"page\",\n \"singular\",\n \"index\"\n ]);\n}\n\nfunction attachmentMimeCandidates(mimeType?: string | null): string[] {\n const [type = \"\", subtype = \"\"] = String(mimeType ?? \"\")\n .toLowerCase()\n .split(\"/\", 2);\n const normalizedType = slugPart(type);\n const normalizedSubtype = slugPart(subtype);\n\n return unique([\n normalizedType && normalizedSubtype\n ? `${normalizedType}-${normalizedSubtype}`\n : null,\n normalizedSubtype || null,\n normalizedType || null\n ]);\n}\n\n/**\n * Mirrors the WordPress classic template hierarchy, without file extensions.\n * WordPress is still the source of truth at runtime and may filter candidates\n * before returning them to Astro; this pure function powers tests and offline\n * scaffolding.\n */\nexport function getTemplateCandidates(context: TemplateContext): string[] {\n switch (context.queryType) {\n case \"front-page\":\n return unique([\n \"front-page\",\n ...(context.frontPageMode === \"posts\"\n ? [\"home\", \"index\"]\n : pageCandidates(context))\n ]);\n case \"home\":\n return [\"home\", \"index\"];\n case \"privacy-policy\":\n return unique([\"privacy-policy\", ...pageCandidates(context)]);\n case \"page\":\n return pageCandidates(context);\n case \"single\":\n return unique([\n context.postType && context.slug\n ? `single-${slugPart(context.postType)}-${slugPart(context.slug)}`\n : null,\n context.postType ? `single-${slugPart(context.postType)}` : null,\n \"single\",\n \"singular\",\n \"index\"\n ]);\n case \"attachment\":\n return unique([\n ...attachmentMimeCandidates(context.mimeType),\n \"attachment\",\n context.slug ? `single-attachment-${slugPart(context.slug)}` : null,\n \"single-attachment\",\n \"single\",\n \"singular\",\n \"index\"\n ]);\n case \"post-type-archive\":\n return unique([\n context.postType ? `archive-${slugPart(context.postType)}` : null,\n \"archive\",\n \"index\"\n ]);\n case \"category\":\n return unique([\n context.slug ? `category-${slugPart(context.slug)}` : null,\n context.termId ? `category-${context.termId}` : null,\n \"category\",\n \"archive\",\n \"index\"\n ]);\n case \"tag\":\n return unique([\n context.slug ? `tag-${slugPart(context.slug)}` : null,\n context.termId ? `tag-${context.termId}` : null,\n \"tag\",\n \"archive\",\n \"index\"\n ]);\n case \"taxonomy\":\n return unique([\n context.taxonomy && context.term\n ? `taxonomy-${slugPart(context.taxonomy)}-${slugPart(context.term)}`\n : null,\n context.taxonomy ? `taxonomy-${slugPart(context.taxonomy)}` : null,\n \"taxonomy\",\n \"archive\",\n \"index\"\n ]);\n case \"author\":\n return unique([\n context.authorNicename\n ? `author-${slugPart(context.authorNicename)}`\n : null,\n context.authorId ? `author-${context.authorId}` : null,\n \"author\",\n \"archive\",\n \"index\"\n ]);\n case \"date\":\n return [\"date\", \"archive\", \"index\"];\n case \"search\":\n return [\"search\", \"index\"];\n case \"embed\":\n return unique([\n context.postType && context.postFormat\n ? `embed-${slugPart(context.postType)}-${slugPart(context.postFormat)}`\n : null,\n context.postType ? `embed-${slugPart(context.postType)}` : null,\n \"embed\"\n ]);\n case \"archive\":\n return [\"archive\", \"index\"];\n case \"404\":\n return [\"404\", \"index\"];\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/accessibility-panel.ts","../src/astro.d.ts","../src/block-renderers.ts","../src/carousel.ts","../src/client.ts","../src/composition.ts","../src/default-blocks.ts","../src/env.ts","../src/index.ts","../src/links.ts","../src/media.ts","../src/motion-preference.ts","../src/number-spinner.ts","../src/preferences-runtime.ts","../src/preferences-styleflow.ts","../src/preferences.ts","../src/reserved-area.ts","../src/style-classes.ts","../src/styleflow.ts","../src/svg-media-types.ts","../src/svg-media.ts","../src/template-hierarchy.ts","../src/
|
|
1
|
+
{"root":["../src/accessibility-panel.ts","../src/astro.d.ts","../src/block-renderers.ts","../src/build-cache.ts","../src/carousel.ts","../src/client.ts","../src/composition.ts","../src/default-blocks.ts","../src/env.ts","../src/index.ts","../src/links.ts","../src/media.ts","../src/motion-preference.ts","../src/number-spinner.ts","../src/preferences-runtime.ts","../src/preferences-styleflow.ts","../src/preferences.ts","../src/reserved-area.ts","../src/style-classes.ts","../src/styleflow.ts","../src/svg-media-types.ts","../src/svg-media.ts","../src/template-hierarchy.ts","../src/text.ts","../src/theme-runtime.ts","../src/types.ts","../src/vivid-colors-preference.ts","../src/astro/blocks/cover.ts","../src/astro/blocks/helpers.ts","../src/astro/motion/accordion.ts","../src/astro/motion/motion-controller.ts","../src/astro/motion/motion.ts","../src/astro/native/button-template.ts","../src/astro/native/button.ts","../src/astro/native/flowpress-navigation-controller.ts","../src/astro/native/grid.ts","../src/astro/native/group.ts","../src/astro/native/html.ts","../src/astro/native/icon.ts","../src/astro/native/map.ts","../src/astro/native/motion-preference.ts","../src/astro/native/motion.ts","../src/astro/native/query-carousel.ts","../src/astro/native/query-loop.ts","../src/astro/native/registry.ts","../src/astro/native/timeline.ts","../src/astro/native/blob/blob-shapes.generated.ts","../src/astro/native/blob/config.ts","../src/astro/native/blob/controller.ts","../src/astro/native/blob/geometry.ts","../src/astro/native/blob/ids.ts","../src/svg-media-runtime.js","../src/astro/native/grid-bleed.js"],"version":"5.9.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@styleflow.app/flowpress-astro-core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.35",
|
|
4
4
|
"description": "Project-agnostic WordPress routing, templates, SEO and GraphQL runtime for FlowPress Astro apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -24,9 +24,7 @@
|
|
|
24
24
|
"import": "./dist/index.js",
|
|
25
25
|
"default": "./dist/index.js"
|
|
26
26
|
},
|
|
27
|
-
"./templates": "./dist/templates.js",
|
|
28
27
|
"./BaseLayout.astro": "./dist/astro/BaseLayout.astro",
|
|
29
|
-
"./DefaultTemplate.astro": "./dist/astro/DefaultTemplate.astro",
|
|
30
28
|
"./GutenbergRenderer.astro": "./dist/astro/GutenbergRenderer.astro",
|
|
31
29
|
"./CompositionRenderer.astro": "./dist/astro/CompositionRenderer.astro",
|
|
32
30
|
"./DefaultBlockAdapter.astro": "./dist/astro/DefaultBlockAdapter.astro",
|
|
@@ -73,7 +71,11 @@
|
|
|
73
71
|
"import": "./dist/astro/motion/motion-controller.js",
|
|
74
72
|
"default": "./dist/astro/motion/motion-controller.js"
|
|
75
73
|
},
|
|
76
|
-
"./motion.css": "./dist/astro/motion/motion.css"
|
|
74
|
+
"./motion.css": "./dist/astro/motion/motion.css",
|
|
75
|
+
"./build-cache": {
|
|
76
|
+
"types": "./dist/build-cache.d.ts",
|
|
77
|
+
"import": "./dist/build-cache.js"
|
|
78
|
+
}
|
|
77
79
|
},
|
|
78
80
|
"files": [
|
|
79
81
|
"dist",
|
|
@@ -81,7 +83,7 @@
|
|
|
81
83
|
"CHANGELOG.md"
|
|
82
84
|
],
|
|
83
85
|
"scripts": {
|
|
84
|
-
"build": "tsc -b && node ./scripts/copy-astro.mjs",
|
|
86
|
+
"build": "node -e \"require('node:fs').rmSync('dist', {recursive:true,force:true})\" && tsc -b --force && node ./scripts/copy-astro.mjs",
|
|
85
87
|
"typecheck": "tsc -b --pretty false && node ./scripts/copy-astro.mjs && astro check",
|
|
86
88
|
"test": "vitest run && npm run test:renderer",
|
|
87
89
|
"test:renderer": "node ./scripts/test-custom-renderer.mjs",
|
|
@@ -93,7 +95,7 @@
|
|
|
93
95
|
"dependencies": {
|
|
94
96
|
"@splidejs/splide": "4.1.4",
|
|
95
97
|
"@styleflow.app/astro": "1.0.0-beta.9",
|
|
96
|
-
"@styleflow.app/flowpress-components": "1.0.0-beta.
|
|
98
|
+
"@styleflow.app/flowpress-components": "1.0.0-beta.15",
|
|
97
99
|
"entities": "8.1.0"
|
|
98
100
|
},
|
|
99
101
|
"peerDependencies": {
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import StyleflowElement from "./StyleflowElement.astro";
|
|
3
|
-
import BaseLayout from "./BaseLayout.astro";
|
|
4
|
-
import GutenbergRenderer from "./GutenbergRenderer.astro";
|
|
5
|
-
import type { FlowpressTemplateProps } from "../types.js";
|
|
6
|
-
|
|
7
|
-
const { route, content, styleflowContract } = Astro.props as FlowpressTemplateProps;
|
|
8
|
-
const title = content?.title || route.seo?.title || "Contenuto";
|
|
9
|
-
const isNotFound = route.queryType === "404" || route.status === 404;
|
|
10
|
-
const hasGutembergBlocks = Array.isArray(content?.contentBlocks) && content.contentBlocks.length > 0 ? true : false;
|
|
11
|
-
//TODO SET GLOBAL LOCAL ON ENV
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
<BaseLayout
|
|
15
|
-
lang={route.locale || "it"}
|
|
16
|
-
seo={route.seo}
|
|
17
|
-
theme={styleflowContract?.defaultTheme}
|
|
18
|
-
themes={styleflowContract?.semantic.themes}
|
|
19
|
-
>
|
|
20
|
-
|
|
21
|
-
{hasGutembergBlocks ? (
|
|
22
|
-
<GutenbergRenderer
|
|
23
|
-
blocks={content?.contentBlocks as import("../types.js").FlowpressBlock[]}
|
|
24
|
-
contract={styleflowContract}
|
|
25
|
-
/>
|
|
26
|
-
) : (
|
|
27
|
-
<StyleflowElement as="section" surface="default" layoutRole="section" density="regular">
|
|
28
|
-
<StyleflowElement as="h1">{isNotFound ? "Pagina non trovata" : title}</StyleflowElement>
|
|
29
|
-
{content?.excerpt && <StyleflowElement as="p">{content.excerpt}</StyleflowElement>}
|
|
30
|
-
{Array.isArray(content?.contentBlocks) && content.contentBlocks.length > 0 ? (
|
|
31
|
-
<GutenbergRenderer
|
|
32
|
-
blocks={content.contentBlocks as import("../types.js").FlowpressBlock[]}
|
|
33
|
-
contract={styleflowContract}
|
|
34
|
-
/>
|
|
35
|
-
) : content?.content && (
|
|
36
|
-
<StyleflowElement as="div"
|
|
37
|
-
surface="default"
|
|
38
|
-
layoutRole="stack"
|
|
39
|
-
density="regular"
|
|
40
|
-
set:html={String(content.content)}
|
|
41
|
-
/>
|
|
42
|
-
)}
|
|
43
|
-
</StyleflowElement>
|
|
44
|
-
)}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
</BaseLayout>
|
package/dist/templates.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const coreTemplates: {
|
|
2
|
-
readonly index: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
3
|
-
readonly singular: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
4
|
-
readonly single: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
5
|
-
readonly page: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
6
|
-
readonly archive: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
7
|
-
readonly taxonomy: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
8
|
-
readonly category: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
9
|
-
readonly tag: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
10
|
-
readonly author: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
11
|
-
readonly date: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
12
|
-
readonly search: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
13
|
-
readonly home: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
14
|
-
readonly attachment: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
15
|
-
readonly embed: import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
16
|
-
readonly "privacy-policy": import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
17
|
-
readonly "404": import("astro/runtime/server/index.js").AstroComponentFactory;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=templates.d.ts.map
|
package/dist/templates.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;CAiBhB,CAAC"}
|
package/dist/templates.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import DefaultTemplate from "./astro/DefaultTemplate.astro";
|
|
2
|
-
export const coreTemplates = {
|
|
3
|
-
index: DefaultTemplate,
|
|
4
|
-
singular: DefaultTemplate,
|
|
5
|
-
single: DefaultTemplate,
|
|
6
|
-
page: DefaultTemplate,
|
|
7
|
-
archive: DefaultTemplate,
|
|
8
|
-
taxonomy: DefaultTemplate,
|
|
9
|
-
category: DefaultTemplate,
|
|
10
|
-
tag: DefaultTemplate,
|
|
11
|
-
author: DefaultTemplate,
|
|
12
|
-
date: DefaultTemplate,
|
|
13
|
-
search: DefaultTemplate,
|
|
14
|
-
home: DefaultTemplate,
|
|
15
|
-
attachment: DefaultTemplate,
|
|
16
|
-
embed: DefaultTemplate,
|
|
17
|
-
"privacy-policy": DefaultTemplate,
|
|
18
|
-
"404": DefaultTemplate
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=templates.js.map
|
package/dist/templates.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAE5D,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK,EAAE,eAAe;IACtB,QAAQ,EAAE,eAAe;IACzB,MAAM,EAAE,eAAe;IACvB,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,eAAe;IACxB,QAAQ,EAAE,eAAe;IACzB,QAAQ,EAAE,eAAe;IACzB,GAAG,EAAE,eAAe;IACpB,MAAM,EAAE,eAAe;IACvB,IAAI,EAAE,eAAe;IACrB,MAAM,EAAE,eAAe;IACvB,IAAI,EAAE,eAAe;IACrB,UAAU,EAAE,eAAe;IAC3B,KAAK,EAAE,eAAe;IACtB,gBAAgB,EAAE,eAAe;IACjC,KAAK,EAAE,eAAe;CACd,CAAC","sourcesContent":["import DefaultTemplate from \"./astro/DefaultTemplate.astro\";\n\nexport const coreTemplates = {\n index: DefaultTemplate,\n singular: DefaultTemplate,\n single: DefaultTemplate,\n page: DefaultTemplate,\n archive: DefaultTemplate,\n taxonomy: DefaultTemplate,\n category: DefaultTemplate,\n tag: DefaultTemplate,\n author: DefaultTemplate,\n date: DefaultTemplate,\n search: DefaultTemplate,\n home: DefaultTemplate,\n attachment: DefaultTemplate,\n embed: DefaultTemplate,\n \"privacy-policy\": DefaultTemplate,\n \"404\": DefaultTemplate\n} as const;\n"]}
|