@nitrogenbuilder/connector-payload 0.1.22 → 0.1.24
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/dist/editor/NitrogenEditorAssetsRoute.d.ts +6 -0
- package/dist/editor/NitrogenEditorAssetsRoute.js +56 -0
- package/dist/editor/NitrogenEditorPage.js +22 -9
- package/dist/editor/index.d.ts +1 -0
- package/dist/editor/index.js +1 -0
- package/dist/editor-assets/fa620pro/css/all.css +26887 -0
- package/dist/editor-assets/fa620pro/css/all.min.css +6 -0
- package/dist/editor-assets/fa620pro/css/brands.css +1516 -0
- package/dist/editor-assets/fa620pro/css/brands.min.css +6 -0
- package/dist/editor-assets/fa620pro/css/duotone.css +12395 -0
- package/dist/editor-assets/fa620pro/css/duotone.min.css +6 -0
- package/dist/editor-assets/fa620pro/css/fontawesome.css +12880 -0
- package/dist/editor-assets/fa620pro/css/fontawesome.min.css +6 -0
- package/dist/editor-assets/fa620pro/css/light.css +19 -0
- package/dist/editor-assets/fa620pro/css/light.min.css +6 -0
- package/dist/editor-assets/fa620pro/css/regular.css +19 -0
- package/dist/editor-assets/fa620pro/css/regular.min.css +6 -0
- package/dist/editor-assets/fa620pro/css/sharp-solid.css +19 -0
- package/dist/editor-assets/fa620pro/css/sharp-solid.min.css +6 -0
- package/dist/editor-assets/fa620pro/css/solid.css +19 -0
- package/dist/editor-assets/fa620pro/css/solid.min.css +6 -0
- package/dist/editor-assets/fa620pro/css/svg-with-js.css +635 -0
- package/dist/editor-assets/fa620pro/css/svg-with-js.min.css +6 -0
- package/dist/editor-assets/fa620pro/css/thin.css +19 -0
- package/dist/editor-assets/fa620pro/css/thin.min.css +6 -0
- package/dist/editor-assets/fa620pro/css/v4-font-face.css +26 -0
- package/dist/editor-assets/fa620pro/css/v4-font-face.min.css +6 -0
- package/dist/editor-assets/fa620pro/css/v4-shims.css +2194 -0
- package/dist/editor-assets/fa620pro/css/v4-shims.min.css +6 -0
- package/dist/editor-assets/fa620pro/css/v5-font-face.css +34 -0
- package/dist/editor-assets/fa620pro/css/v5-font-face.min.css +6 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-brands-400.ttf +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-brands-400.woff2 +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-duotone-900.ttf +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-duotone-900.woff2 +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-light-300.ttf +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-light-300.woff2 +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-regular-400.ttf +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-regular-400.woff2 +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-sharp-solid-900.ttf +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-sharp-solid-900.woff2 +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-solid-900.ttf +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-solid-900.woff2 +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-thin-100.ttf +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-thin-100.woff2 +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-v4compatibility.ttf +0 -0
- package/dist/editor-assets/fa620pro/webfonts/fa-v4compatibility.woff2 +0 -0
- package/dist/editor-assets/logo-white.svg +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { NextResponse } from "next/server";
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
const ASSETS_DIR = path.resolve(__dirname, "..", "editor-assets");
|
|
8
|
+
function getContentType(filePath) {
|
|
9
|
+
switch (path.extname(filePath).toLowerCase()) {
|
|
10
|
+
case ".css":
|
|
11
|
+
return "text/css; charset=utf-8";
|
|
12
|
+
case ".svg":
|
|
13
|
+
return "image/svg+xml";
|
|
14
|
+
case ".woff2":
|
|
15
|
+
return "font/woff2";
|
|
16
|
+
case ".woff":
|
|
17
|
+
return "font/woff";
|
|
18
|
+
case ".ttf":
|
|
19
|
+
return "font/ttf";
|
|
20
|
+
case ".eot":
|
|
21
|
+
return "application/vnd.ms-fontobject";
|
|
22
|
+
case ".otf":
|
|
23
|
+
return "font/otf";
|
|
24
|
+
case ".ico":
|
|
25
|
+
return "image/x-icon";
|
|
26
|
+
default:
|
|
27
|
+
return "application/octet-stream";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function normalizeSlug(slug) {
|
|
31
|
+
return (slug ?? []).filter((segment) => segment && segment !== "." && segment !== "..");
|
|
32
|
+
}
|
|
33
|
+
export async function GET(_request, context) {
|
|
34
|
+
const params = await context.params;
|
|
35
|
+
const slug = normalizeSlug(params.slug);
|
|
36
|
+
if (slug.length === 0) {
|
|
37
|
+
return new NextResponse("Not Found", { status: 404 });
|
|
38
|
+
}
|
|
39
|
+
const filePath = path.join(ASSETS_DIR, ...slug);
|
|
40
|
+
const relativePath = path.relative(ASSETS_DIR, filePath);
|
|
41
|
+
if (relativePath.startsWith("..") || path.isAbsolute(relativePath)) {
|
|
42
|
+
return new NextResponse("Not Found", { status: 404 });
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const data = await fs.readFile(filePath);
|
|
46
|
+
return new NextResponse(new Uint8Array(data), {
|
|
47
|
+
headers: {
|
|
48
|
+
"Content-Type": getContentType(filePath),
|
|
49
|
+
"Cache-Control": "public, max-age=31536000, immutable",
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return new NextResponse("Not Found", { status: 404 });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { getPayload } from "payload";
|
|
3
3
|
import { headers } from "next/headers";
|
|
4
4
|
import { redirect } from "next/navigation";
|
|
5
|
+
const EDITOR_CDN_VERSION = "0.5.29";
|
|
5
6
|
function getNitrogenApiUrl(isDevelopment) {
|
|
6
7
|
if (isDevelopment) {
|
|
7
8
|
return "/api/nitrogen/v1";
|
|
@@ -18,6 +19,15 @@ function getNitrogenApiUrl(isDevelopment) {
|
|
|
18
19
|
}
|
|
19
20
|
return `${normalizedBase}/api/nitrogen/v1`;
|
|
20
21
|
}
|
|
22
|
+
function getSiteUrl(settings, isDevelopment) {
|
|
23
|
+
const preferredUrl = isDevelopment
|
|
24
|
+
? settings.developmentUrl
|
|
25
|
+
: settings.frontendUrl;
|
|
26
|
+
const fallbackUrl = isDevelopment
|
|
27
|
+
? settings.frontendUrl
|
|
28
|
+
: settings.developmentUrl;
|
|
29
|
+
return preferredUrl || fallbackUrl || "";
|
|
30
|
+
}
|
|
21
31
|
/**
|
|
22
32
|
* Creates a standalone editor page that loads the Nitrogen builder.
|
|
23
33
|
*
|
|
@@ -44,9 +54,7 @@ export function createNitrogenEditorPage(config) {
|
|
|
44
54
|
slug: "nitrogen-settings",
|
|
45
55
|
}));
|
|
46
56
|
const isDevelopment = params.development === "true";
|
|
47
|
-
const siteUrl = isDevelopment
|
|
48
|
-
? settings.developmentUrl
|
|
49
|
-
: settings.frontendUrl;
|
|
57
|
+
const siteUrl = getSiteUrl(settings, isDevelopment);
|
|
50
58
|
const nitrogenConfig = settings.nitrogenConfig || {};
|
|
51
59
|
// Determine the postType for the editor's API calls
|
|
52
60
|
let postType;
|
|
@@ -75,8 +83,11 @@ export function createNitrogenEditorPage(config) {
|
|
|
75
83
|
const editId = params.templateId || params.pageId || "";
|
|
76
84
|
const isEditorDev = isDevelopment && !!settings.instanceUrl;
|
|
77
85
|
const editorOrigin = settings.instanceUrl?.replace(/\/$/, "") || "";
|
|
78
|
-
const
|
|
79
|
-
|
|
86
|
+
const editorAssetsBase = isEditorDev
|
|
87
|
+
? editorOrigin
|
|
88
|
+
: "/nitrogen-editor/assets";
|
|
89
|
+
const cdnBase = `https://cdn.jsdelivr.net/npm/@nitrogenbuilder/editor@${EDITOR_CDN_VERSION}`;
|
|
90
|
+
return (_jsxs(_Fragment, { children: [!isEditorDev && (_jsxs(_Fragment, { children: [_jsx("link", { rel: "preconnect", href: "https://cdn.jsdelivr.net" }), _jsx("link", { rel: "preconnect", href: "https://fonts.gstatic.com", crossOrigin: "" })] })), isEditorDev ? (_jsxs(_Fragment, { children: [_jsx("link", { rel: "stylesheet", crossOrigin: "", href: `${editorAssetsBase}/fa620pro/css/all.css` }), _jsx("link", { rel: "stylesheet", crossOrigin: "", href: `${editorAssetsBase}/fa620pro/css/sharp-solid.css` }), _jsx("link", { rel: "stylesheet", crossOrigin: "", href: `${editorOrigin}/src/index.scss` })] })) : (_jsxs(_Fragment, { children: [_jsx("link", { rel: "stylesheet", crossOrigin: "", href: `${editorAssetsBase}/fa620pro/css/all.css` }), _jsx("link", { rel: "stylesheet", crossOrigin: "", href: `${editorAssetsBase}/fa620pro/css/sharp-solid.css` }), _jsx("link", { rel: "stylesheet", crossOrigin: "", href: `${cdnBase}/index.css` })] })), _jsx("script", { dangerouslySetInnerHTML: {
|
|
80
91
|
__html: [
|
|
81
92
|
`window.nitrogenConfig = ${JSON.stringify(builderConfig)};`,
|
|
82
93
|
`window.nitrogenEditId = "${editId}";`,
|
|
@@ -91,13 +102,15 @@ export function createNitrogenEditorPage(config) {
|
|
|
91
102
|
alignItems: "center",
|
|
92
103
|
justifyContent: "center",
|
|
93
104
|
backgroundColor: "#0F1214",
|
|
94
|
-
}, children: _jsx("img", { src:
|
|
95
|
-
|
|
96
|
-
:
|
|
105
|
+
}, children: isEditorDev ? (_jsx("img", { src: `${editorAssetsBase}/logo-white.svg`, alt: "Loading\u2026", style: {
|
|
106
|
+
width: "24rem",
|
|
107
|
+
maxWidth: "100%",
|
|
108
|
+
animation: "nitrogen-loader-pulse 3s ease-in-out infinite",
|
|
109
|
+
} })) : (_jsx("img", { src: `${editorAssetsBase}/logo-white.svg`, alt: "Loading\u2026", style: {
|
|
97
110
|
width: "24rem",
|
|
98
111
|
maxWidth: "100%",
|
|
99
112
|
animation: "nitrogen-loader-pulse 3s ease-in-out infinite",
|
|
100
|
-
} }) }), _jsx("style", { dangerouslySetInnerHTML: {
|
|
113
|
+
} })) }), _jsx("style", { dangerouslySetInnerHTML: {
|
|
101
114
|
__html: `@keyframes nitrogen-loader-pulse{0%{transform:scale(1);opacity:0}50%{opacity:1}100%{transform:scale(1.05);opacity:0}}`,
|
|
102
115
|
} })] }), isEditorDev ? (_jsxs(_Fragment, { children: [_jsx("script", { type: "module", dangerouslySetInnerHTML: {
|
|
103
116
|
__html: `import RefreshRuntime from "${editorOrigin}/@react-refresh";RefreshRuntime.injectIntoGlobalHook(window);window.$RefreshReg$ = () => {};window.$RefreshSig$ = () => (type) => type;window.__vite_plugin_react_preamble_installed__ = true;`,
|
package/dist/editor/index.d.ts
CHANGED
package/dist/editor/index.js
CHANGED