@parhelia/next 0.0.0-stage → 1.0.12903
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +8 -0
- package/README.md +69 -2
- package/package.json +110 -4
- package/src/config.cjs +128 -0
- package/src/config.d.cts +50 -0
- package/src/contentful.d.ts +1 -0
- package/src/contentful.js +2 -0
- package/src/identity.d.ts +1 -0
- package/src/identity.js +2 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +10 -0
- package/src/magnolia.d.ts +1 -0
- package/src/magnolia.js +2 -0
- package/src/refresh.d.ts +1 -0
- package/src/refresh.js +2 -0
- package/src/rich-text.d.ts +1 -0
- package/src/rich-text.js +2 -0
- package/src/server.d.ts +1 -0
- package/src/server.js +2 -0
- package/src/typo3.d.ts +1 -0
- package/src/typo3.js +2 -0
- package/src/umbraco.d.ts +1 -0
- package/src/umbraco.js +2 -0
package/LICENSE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,70 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @parhelia/next
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Serve a Next.js rendering head in the Parhelia editor. Plain JavaScript, no build step: it can be copied into a head
|
|
4
|
+
that is built elsewhere.
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
// next.config.js
|
|
8
|
+
const { withParhelia } = require('@parhelia/next/config');
|
|
9
|
+
module.exports = withParhelia({ /* the head's config, or a config function such as next-compose-plugins' */ });
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
// pages/_app.tsx (or a client component of the App Router layout)
|
|
14
|
+
import { ContentfulLivePreviewProvider } from '@contentful/live-preview/react';
|
|
15
|
+
import { ParheliaBridge, withBasePath } from '@parhelia/next';
|
|
16
|
+
import { contentfulLivePreviewOrigins } from '@parhelia/next/contentful'; // a CMS's own helpers: its entry
|
|
17
|
+
|
|
18
|
+
<ContentfulLivePreviewProvider locale={locale} targetOrigin={contentfulLivePreviewOrigins()}>
|
|
19
|
+
<ParheliaBridge />
|
|
20
|
+
{children}
|
|
21
|
+
</ContentfulLivePreviewProvider>;
|
|
22
|
+
|
|
23
|
+
// a root-relative URL below the rendering proxy: a browser fetch, or markup (the server render writes the same URL)
|
|
24
|
+
fetch(withBasePath('/api/content'), { method: 'POST', body });
|
|
25
|
+
<img src={withBasePath('/logo.svg')} alt="" />;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
| Setting | Read | Effect |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| `PARHELIA_RENDERING_PROXY_PATH` (`/parhelia/proxy/<head name>`) | at build | the basePath; `NEXT_PUBLIC_BASE_PATH` is read when it is unset, `/` means none |
|
|
31
|
+
| `PARHELIA_ORIGIN` (e.g. `https://cms.example.com`) | at build | the editor may frame the head directly (CSP `frame-ancestors`; `X-Frame-Options` gives way to the same list), and the browser loads the editing bridge from it |
|
|
32
|
+
|
|
33
|
+
Both come from the head's **Head settings** block in Parhelia (Settings › Rendering Hosts).
|
|
34
|
+
|
|
35
|
+
- **Proxy mode** (the editor frames `/parhelia/proxy/<head name>/…` from its own origin) needs only the base path:
|
|
36
|
+
`contentfulLivePreviewOrigins()` adds the page's own origin in the browser, and Parhelia injects the bridge itself.
|
|
37
|
+
Moving the editor to another origin needs no rebuild.
|
|
38
|
+
- **Direct mode** (the editor frames the head's own URL) needs `PARHELIA_ORIGIN`: the framing rule, the Live Preview
|
|
39
|
+
target and the bridge (`ParheliaBridge` loads it after hydration on `?parhelia=1`, only in a cross-origin frame;
|
|
40
|
+
`ParheliaBridgeScript` renders it into the server's HTML instead, with a CSP nonce: see `@parhelia/react`).
|
|
41
|
+
|
|
42
|
+
Without `withParhelia` the helpers fall back to nothing: no basePath, no Parhelia origin.
|
|
43
|
+
|
|
44
|
+
### Server render and browser read the same values
|
|
45
|
+
|
|
46
|
+
`withParhelia` inlines both values into the head's bundles and adds `@parhelia/next` to `transpilePackages` (after the
|
|
47
|
+
head's own entries). That entry matters: Next.js inlines only into code it bundles, and the Pages Router's server loads a
|
|
48
|
+
package from `node_modules` at run time instead (webpack and Turbopack alike). Without it, `withBasePath('/logo.svg')`
|
|
49
|
+
rendered `/logo.svg` on the server and `/parhelia/proxy/<head name>/logo.svg` in the browser: a broken URL in the server's
|
|
50
|
+
HTML and a hydration mismatch. A head that lists the package in `serverExternalPackages` keeps it external (Next.js
|
|
51
|
+
refuses a package in both lists) and renders on the server with what the server's own environment sets.
|
|
52
|
+
|
|
53
|
+
`probe/run-probe.mjs` proves it on a real build: it copies the package into a head's `node_modules` (as
|
|
54
|
+
`scripts/e2e/contentful-site/install-parhelia-next.mjs` does), builds and starts it below a rendering-proxy path with
|
|
55
|
+
webpack and Turbopack, and compares the server's HTML with what the browser computes after hydration
|
|
56
|
+
(`node probe/run-probe.mjs` from this folder after the frontend install; ports 11091-11092, `--port` moves them).
|
|
57
|
+
|
|
58
|
+
A CMS's own helpers live in its entry (`@parhelia/next/contentful`). The root still re-exports `contentfulLivePreviewOrigins`
|
|
59
|
+
and `CONTENTFUL_APP_ORIGINS` for heads built before the entry existed (deprecated; removed in 2.0).
|
|
60
|
+
|
|
61
|
+
## Everything else: `@parhelia/head` and `@parhelia/react`
|
|
62
|
+
|
|
63
|
+
This package is the Next.js adapter over [`@parhelia/head`](../head/README.md), which holds everything a head renders with
|
|
64
|
+
whatever its framework (the frame-mode marker and empty-component hints, the rendered identity `/identity`, the editor signal
|
|
65
|
+
`/server`, rich-text sanitising `/rich-text`, the in-place refresh `/refresh`, the CMS entries `/contentful`, `/umbraco`,
|
|
66
|
+
`/magnolia`, `/typo3`), and [`@parhelia/react`](../react/README.md), its React components (`ParheliaBridge`,
|
|
67
|
+
`ParheliaBridgeScript`, `ParheliaSlot`, `useParheliaRefresh`). Every entry of this package but `/config` is the same-named
|
|
68
|
+
entry of `@parhelia/head`, and the root also re-exports `@parhelia/react`: the very same bindings, so existing imports keep
|
|
69
|
+
working; read their documentation there. `withParhelia` transpiles all three packages, so the server render reads the
|
|
70
|
+
build's values as the browser does.
|
package/package.json
CHANGED
|
@@ -1,6 +1,112 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parhelia/next",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.12903",
|
|
4
|
+
"description": "Serve a Next.js rendering head in the Parhelia editor: withParhelia() for next.config.js (/config), plus the React bindings of @parhelia/react and everything of @parhelia/head under the same entries (the editing bridge, slot markers, the in-place refresh, the rendered-content identity, the editor signal a head's server checks, rich-text sanitising, per-CMS marker helpers).",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "./src/index.js",
|
|
11
|
+
"types": "./src/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./src/index.d.ts",
|
|
15
|
+
"default": "./src/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./identity": {
|
|
18
|
+
"types": "./src/identity.d.ts",
|
|
19
|
+
"default": "./src/identity.js"
|
|
20
|
+
},
|
|
21
|
+
"./server": {
|
|
22
|
+
"types": "./src/server.d.ts",
|
|
23
|
+
"default": "./src/server.js"
|
|
24
|
+
},
|
|
25
|
+
"./contentful": {
|
|
26
|
+
"types": "./src/contentful.d.ts",
|
|
27
|
+
"default": "./src/contentful.js"
|
|
28
|
+
},
|
|
29
|
+
"./umbraco": {
|
|
30
|
+
"types": "./src/umbraco.d.ts",
|
|
31
|
+
"default": "./src/umbraco.js"
|
|
32
|
+
},
|
|
33
|
+
"./magnolia": {
|
|
34
|
+
"types": "./src/magnolia.d.ts",
|
|
35
|
+
"default": "./src/magnolia.js"
|
|
36
|
+
},
|
|
37
|
+
"./typo3": {
|
|
38
|
+
"types": "./src/typo3.d.ts",
|
|
39
|
+
"default": "./src/typo3.js"
|
|
40
|
+
},
|
|
41
|
+
"./refresh": {
|
|
42
|
+
"types": "./src/refresh.d.ts",
|
|
43
|
+
"default": "./src/refresh.js"
|
|
44
|
+
},
|
|
45
|
+
"./rich-text": {
|
|
46
|
+
"types": "./src/rich-text.d.ts",
|
|
47
|
+
"default": "./src/rich-text.js"
|
|
48
|
+
},
|
|
49
|
+
"./config": {
|
|
50
|
+
"types": "./src/config.d.cts",
|
|
51
|
+
"default": "./src/config.cjs"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"typesVersions": {
|
|
55
|
+
"*": {
|
|
56
|
+
"identity": [
|
|
57
|
+
"./src/identity.d.ts"
|
|
58
|
+
],
|
|
59
|
+
"server": [
|
|
60
|
+
"./src/server.d.ts"
|
|
61
|
+
],
|
|
62
|
+
"contentful": [
|
|
63
|
+
"./src/contentful.d.ts"
|
|
64
|
+
],
|
|
65
|
+
"umbraco": [
|
|
66
|
+
"./src/umbraco.d.ts"
|
|
67
|
+
],
|
|
68
|
+
"magnolia": [
|
|
69
|
+
"./src/magnolia.d.ts"
|
|
70
|
+
],
|
|
71
|
+
"typo3": [
|
|
72
|
+
"./src/typo3.d.ts"
|
|
73
|
+
],
|
|
74
|
+
"refresh": [
|
|
75
|
+
"./src/refresh.d.ts"
|
|
76
|
+
],
|
|
77
|
+
"rich-text": [
|
|
78
|
+
"./src/rich-text.d.ts"
|
|
79
|
+
],
|
|
80
|
+
"config": [
|
|
81
|
+
"./src/config.d.cts"
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"files": [
|
|
86
|
+
"src/*.js",
|
|
87
|
+
"src/*.cjs",
|
|
88
|
+
"src/*.d.ts",
|
|
89
|
+
"src/*.d.cts",
|
|
90
|
+
"README.md",
|
|
91
|
+
"LICENSE"
|
|
92
|
+
],
|
|
93
|
+
"sideEffects": false,
|
|
94
|
+
"scripts": {
|
|
95
|
+
"check-types": "tsc --noEmit -p tsconfig.json",
|
|
96
|
+
"test": "vitest run"
|
|
97
|
+
},
|
|
98
|
+
"dependencies": {
|
|
99
|
+
"@parhelia/head": "1.0.12903",
|
|
100
|
+
"@parhelia/react": "1.0.12903"
|
|
101
|
+
},
|
|
102
|
+
"peerDependencies": {
|
|
103
|
+
"react": ">=18"
|
|
104
|
+
},
|
|
105
|
+
"devDependencies": {
|
|
106
|
+
"@types/node": "*",
|
|
107
|
+
"@types/react": "19.2.18",
|
|
108
|
+
"jsdom": "^30.0.1",
|
|
109
|
+
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
110
|
+
"vitest": "^4.1.11"
|
|
111
|
+
}
|
|
112
|
+
}
|
package/src/config.cjs
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `@parhelia/next/config` — `withParhelia(nextConfig)` for a Next.js rendering head (setup plan E).
|
|
4
|
+
*
|
|
5
|
+
* CommonJS on purpose: most heads have a `next.config.js` that `require`s its plugins. Plain JavaScript on purpose: the
|
|
6
|
+
* package is copied into heads that are built elsewhere (the Marketing starter on its own VM), so it needs no build.
|
|
7
|
+
* Everything a head renders with lives in `@parhelia/head` and `@parhelia/react` (this package re-exports both); this file
|
|
8
|
+
* is the Next.js build adapter, the counterpart of `@parhelia/head/vite`. The settings it reads are `@parhelia/head/settings`'.
|
|
9
|
+
*
|
|
10
|
+
* It reads two settings while Next.js loads the config (Next.js bakes basePath and headers into the build):
|
|
11
|
+
*
|
|
12
|
+
* PARHELIA_RENDERING_PROXY_PATH `/parhelia/proxy/<head name>`: served below Parhelia's same-origin rendering proxy
|
|
13
|
+
* (the basePath). `NEXT_PUBLIC_BASE_PATH` is read when it is unset; `/` means none.
|
|
14
|
+
* PARHELIA_ORIGIN the Parhelia editor's origin. It may frame the head directly (its CSP frame-ancestors;
|
|
15
|
+
* X-Frame-Options cannot name another origin and gives way to the same list) and is
|
|
16
|
+
* handed to the browser for the editing bridge and Contentful Live Preview.
|
|
17
|
+
*
|
|
18
|
+
* A proxied head needs neither origin nor framing rule: the editor frames it from its own origin.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const { originFromEnv: parheliaOrigin, basePathFromEnv: proxyBasePath } = require("@parhelia/head/settings");
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Wraps a Next.js config: the basePath below the rendering proxy, the editor allowed to frame the head, and both
|
|
25
|
+
* values inlined into the head's bundles as `process.env.PARHELIA_BASE_PATH` / `process.env.PARHELIA_ORIGIN` (read by
|
|
26
|
+
* `withBasePath`, `contentfulLivePreviewOrigins` and `ParheliaBridge`), this package bundled on the server as well. A
|
|
27
|
+
* config function (next-compose-plugins, `(phase, context) => config`) is wrapped as a function. A basePath the config
|
|
28
|
+
* sets itself is kept.
|
|
29
|
+
*/
|
|
30
|
+
function withParhelia(nextConfig, options) {
|
|
31
|
+
const env = (options && options.env) || process.env;
|
|
32
|
+
if (typeof nextConfig === "function")
|
|
33
|
+
return async (phase, context) => applyParhelia(await nextConfig(phase, context), env);
|
|
34
|
+
return applyParhelia(nextConfig || {}, env);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function applyParhelia(config, env) {
|
|
38
|
+
const origin = parheliaOrigin(env);
|
|
39
|
+
const basePath = Object.prototype.hasOwnProperty.call(config, "basePath") ? config.basePath || "" : proxyBasePath(env);
|
|
40
|
+
const result = {
|
|
41
|
+
...config,
|
|
42
|
+
// Next.js inlines `env` into the code it bundles; values must be strings.
|
|
43
|
+
env: { ...config.env, PARHELIA_BASE_PATH: basePath, PARHELIA_ORIGIN: origin },
|
|
44
|
+
};
|
|
45
|
+
// The Pages Router's server does not bundle a package from node_modules (webpack and Turbopack alike): it loads it at
|
|
46
|
+
// run time, where nothing is inlined, and `withBasePath` would answer without the basePath in the server render (a
|
|
47
|
+
// hydration mismatch). Transpiled, the packages are bundled and read the build's values on the server as in the browser:
|
|
48
|
+
// this one, `@parhelia/react` and `@parhelia/head`, where the reads are.
|
|
49
|
+
const missing = packagesToTranspile(config);
|
|
50
|
+
if (missing.length > 0) result.transpilePackages = [...(config.transpilePackages || []), ...missing];
|
|
51
|
+
if (basePath) result.basePath = basePath;
|
|
52
|
+
if (origin) {
|
|
53
|
+
const headers = config.headers;
|
|
54
|
+
result.headers = async () => allowParheliaFrame(typeof headers === "function" ? await headers() : [], origin);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const PACKAGE_NAMES = ["@parhelia/next", "@parhelia/react", "@parhelia/head"];
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The packages the config does not yet say how Next.js loads: neither transpiled nor kept external by the head
|
|
63
|
+
* (`serverExternalPackages`; Next.js refuses a package in both lists). A head that keeps `@parhelia/next` external renders
|
|
64
|
+
* on the server with what the server's own environment sets, and gets neither added.
|
|
65
|
+
*/
|
|
66
|
+
function packagesToTranspile(config) {
|
|
67
|
+
const listed = (name, lists) => lists.some((list) => Array.isArray(list) && list.includes(name));
|
|
68
|
+
const external = [config.serverExternalPackages, config.experimental && config.experimental.serverComponentsExternalPackages];
|
|
69
|
+
if (listed(PACKAGE_NAMES[0], external)) return [];
|
|
70
|
+
return PACKAGE_NAMES.filter((name) => !listed(name, [config.transpilePackages, ...external]));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// A CSP directive names its sources separated by ASCII whitespace (tab, line feed, form feed, carriage return, space), any
|
|
74
|
+
// of them, any number; other white space is part of a source. The Umbraco package's FrameAncestors reads them by the same set.
|
|
75
|
+
const CSP_WHITESPACE = /[\t\n\f\r ]+/;
|
|
76
|
+
const FRAME_ANCESTORS = /^[\t\n\f\r ]*frame-ancestors([\t\n\f\r ]|$)/i;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Lets `origin` frame every route a header rule covers: an existing CSP `frame-ancestors` list gains it ('none', in any
|
|
80
|
+
* case, gives way; its sources are read as a browser reads them), and an X-Frame-Options header is replaced by the same rule
|
|
81
|
+
* as a `frame-ancestors` list (`SAMEORIGIN` → 'self' plus the origin, `DENY` → the origin only). A rule with neither leaves
|
|
82
|
+
* framing unrestricted, as it was.
|
|
83
|
+
*/
|
|
84
|
+
function allowParheliaFrame(rules, origin) {
|
|
85
|
+
return (rules || []).map((rule) => {
|
|
86
|
+
if (!rule || !Array.isArray(rule.headers)) return rule;
|
|
87
|
+
let frameOptions = null;
|
|
88
|
+
let listed = false;
|
|
89
|
+
const headers = [];
|
|
90
|
+
for (const header of rule.headers) {
|
|
91
|
+
const key = String(header.key).toLowerCase();
|
|
92
|
+
if (key === "x-frame-options") {
|
|
93
|
+
frameOptions = String(header.value).trim().toUpperCase();
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (key === "content-security-policy") {
|
|
97
|
+
const directives = String(header.value).split(";");
|
|
98
|
+
const index = directives.findIndex((directive) => FRAME_ANCESTORS.test(directive));
|
|
99
|
+
if (index >= 0) {
|
|
100
|
+
listed = true;
|
|
101
|
+
// CSP keywords are case-insensitive: 'NONE' refuses every frame as 'none' does.
|
|
102
|
+
const sources = directives[index]
|
|
103
|
+
.split(CSP_WHITESPACE)
|
|
104
|
+
.filter(Boolean)
|
|
105
|
+
.slice(1)
|
|
106
|
+
.filter((source) => source.toLowerCase() !== "'none'");
|
|
107
|
+
if (!sources.includes(origin)) sources.push(origin);
|
|
108
|
+
directives[index] = `${index === 0 ? "" : " "}frame-ancestors ${sources.join(" ")}`;
|
|
109
|
+
headers.push({ ...header, value: directives.join(";") });
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
headers.push(header);
|
|
114
|
+
}
|
|
115
|
+
if (frameOptions !== null && !listed) {
|
|
116
|
+
const sources = frameOptions === "DENY" ? [origin] : ["'self'", origin];
|
|
117
|
+
const directive = `frame-ancestors ${sources.join(" ")}`;
|
|
118
|
+
const policy = headers.findIndex((header) => String(header.key).toLowerCase() === "content-security-policy");
|
|
119
|
+
if (policy >= 0) {
|
|
120
|
+
const value = String(headers[policy].value).trim().replace(/;\s*$/, "");
|
|
121
|
+
headers[policy] = { ...headers[policy], value: value ? `${value}; ${directive}` : directive };
|
|
122
|
+
} else headers.push({ key: "Content-Security-Policy", value: directive });
|
|
123
|
+
}
|
|
124
|
+
return { ...rule, headers };
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
module.exports = { withParhelia, allowParheliaFrame, parheliaOrigin, proxyBasePath };
|
package/src/config.d.cts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** A Next.js config object or config function; typed loosely so the package needs no `next` types. */
|
|
2
|
+
export type NextConfigLike = Record<string, any>;
|
|
3
|
+
export type NextConfigFunction = (phase: string, context: any) => NextConfigLike | Promise<NextConfigLike>;
|
|
4
|
+
|
|
5
|
+
export interface HeaderRule {
|
|
6
|
+
source: string;
|
|
7
|
+
headers: { key: string; value: string }[];
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface WithParheliaOptions {
|
|
12
|
+
/** The environment to read (default `process.env`). */
|
|
13
|
+
env?: Record<string, string | undefined>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** What `withParhelia` adds to a config. */
|
|
17
|
+
export interface ParheliaConfig {
|
|
18
|
+
basePath?: string;
|
|
19
|
+
/** Inlined into the head's bundles: `PARHELIA_BASE_PATH` and `PARHELIA_ORIGIN` ("" when unset). */
|
|
20
|
+
env: Record<string, string | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* The config's own list plus `@parhelia/next`, `@parhelia/react` and `@parhelia/head` where it does not name them yet, so the server render
|
|
23
|
+
* reads the inlined values as the browser does; unchanged when it keeps `@parhelia/next` in `serverExternalPackages`.
|
|
24
|
+
*/
|
|
25
|
+
transpilePackages?: string[];
|
|
26
|
+
/** Present when `PARHELIA_ORIGIN` is set: the config's own rules with the editor allowed to frame. */
|
|
27
|
+
headers?: () => Promise<HeaderRule[]>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Serves the head below Parhelia's rendering proxy (`PARHELIA_RENDERING_PROXY_PATH`, else `NEXT_PUBLIC_BASE_PATH`, as
|
|
32
|
+
* basePath) and lets the Parhelia editor (`PARHELIA_ORIGIN`) frame it; exposes both to the browser bundle.
|
|
33
|
+
*/
|
|
34
|
+
export declare function withParhelia(
|
|
35
|
+
nextConfig: NextConfigFunction,
|
|
36
|
+
options?: WithParheliaOptions,
|
|
37
|
+
): (phase: string, context: any) => Promise<NextConfigLike & ParheliaConfig>;
|
|
38
|
+
export declare function withParhelia<T extends NextConfigLike>(
|
|
39
|
+
nextConfig?: T,
|
|
40
|
+
options?: WithParheliaOptions,
|
|
41
|
+
): Omit<T, keyof ParheliaConfig> & ParheliaConfig;
|
|
42
|
+
|
|
43
|
+
/** Lets `origin` frame every route the rules cover (CSP frame-ancestors; X-Frame-Options gives way). */
|
|
44
|
+
export declare function allowParheliaFrame<T extends HeaderRule>(rules: T[], origin: string): T[];
|
|
45
|
+
|
|
46
|
+
/** `PARHELIA_ORIGIN` trimmed, without a trailing slash; "" when unset. Throws for a value that is not an origin. */
|
|
47
|
+
export declare function parheliaOrigin(env?: Record<string, string | undefined>): string;
|
|
48
|
+
|
|
49
|
+
/** `PARHELIA_RENDERING_PROXY_PATH` (else `NEXT_PUBLIC_BASE_PATH`) without a trailing slash; "" when unset or `/`. */
|
|
50
|
+
export declare function proxyBasePath(env?: Record<string, string | undefined>): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@parhelia/head/contentful";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@parhelia/head/identity";
|
package/src/identity.js
ADDED
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@parhelia/next` — Parhelia for a Next.js rendering head: `withParhelia` (`@parhelia/next/config`, the build adapter),
|
|
3
|
+
* the React bindings of `@parhelia/react` and everything of `@parhelia/head`, which this package re-exports at the same
|
|
4
|
+
* paths (`@parhelia/next/server` is `@parhelia/head/server`, and so on). Heads on another framework use those directly.
|
|
5
|
+
*/
|
|
6
|
+
export * from "@parhelia/head";
|
|
7
|
+
export * from "@parhelia/react";
|
|
8
|
+
// Umbraco program thirdcms-frontend: kept on the root only for heads built before the vendor entry existed (the patched
|
|
9
|
+
// Marketing starter imports them from here); new heads import `@parhelia/next/contentful`. Removed with @parhelia/next 2.0.
|
|
10
|
+
export * from "@parhelia/head/contentful";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@parhelia/head/magnolia";
|
package/src/magnolia.js
ADDED
package/src/refresh.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@parhelia/head/refresh";
|
package/src/refresh.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@parhelia/head/rich-text";
|
package/src/rich-text.js
ADDED
package/src/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@parhelia/head/server";
|
package/src/server.js
ADDED
package/src/typo3.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@parhelia/head/typo3";
|
package/src/typo3.js
ADDED
package/src/umbraco.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@parhelia/head/umbraco";
|
package/src/umbraco.js
ADDED