@simpleview/cms-foundation 0.0.28 → 0.0.29
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/chunk-2WII7C3O.js +31 -0
- package/dist/chunk-2WII7C3O.js.map +7 -0
- package/dist/chunk-4LSFAAZW.js +1 -0
- package/dist/chunk-4LSFAAZW.js.map +7 -0
- package/dist/chunk-5WRI5ZAA.js +31 -0
- package/dist/chunk-5WRI5ZAA.js.map +7 -0
- package/dist/chunk-CMALSZV3.js +1 -0
- package/dist/chunk-CMALSZV3.js.map +7 -0
- package/dist/chunk-DG37VYL5.js +1 -0
- package/dist/chunk-DG37VYL5.js.map +7 -0
- package/dist/chunk-EDXU7MNB.js +39 -0
- package/dist/chunk-EDXU7MNB.js.map +7 -0
- package/dist/chunk-EEKFLXZI.js +11 -0
- package/dist/chunk-EEKFLXZI.js.map +7 -0
- package/dist/chunk-EG5F4AP4.js +1 -0
- package/dist/chunk-EG5F4AP4.js.map +7 -0
- package/dist/chunk-EWRVCIV6.js +1 -0
- package/dist/chunk-EWRVCIV6.js.map +7 -0
- package/dist/chunk-F5L7DWHD.js +1 -0
- package/dist/chunk-F5L7DWHD.js.map +7 -0
- package/dist/chunk-FJML4RHB.js +59 -0
- package/dist/chunk-FJML4RHB.js.map +7 -0
- package/dist/chunk-GPTPACV2.js +33 -0
- package/dist/chunk-GPTPACV2.js.map +7 -0
- package/dist/chunk-JT6WIXOP.js +81 -0
- package/dist/chunk-JT6WIXOP.js.map +7 -0
- package/dist/chunk-MPAGXIUB.js +11 -0
- package/dist/chunk-MPAGXIUB.js.map +7 -0
- package/dist/chunk-OEYLOZQK.js +31 -0
- package/dist/chunk-OEYLOZQK.js.map +7 -0
- package/dist/chunk-P3WX4DFS.js +93 -0
- package/dist/chunk-P3WX4DFS.js.map +7 -0
- package/dist/chunk-VV3NKXSX.js +17 -0
- package/dist/chunk-VV3NKXSX.js.map +7 -0
- package/dist/chunk-XG5CMDEI.js +1 -0
- package/dist/chunk-XG5CMDEI.js.map +7 -0
- package/dist/chunk-ZQUGFKHP.js +1 -0
- package/dist/chunk-ZQUGFKHP.js.map +7 -0
- package/dist/components/App/App.js +4 -5
- package/dist/components/App/App.js.map +3 -3
- package/dist/components/App/index.js +8 -1
- package/dist/components/App/index.js.map +3 -3
- package/dist/components/Error/Error.js +4 -11
- package/dist/components/Error/Error.js.map +3 -3
- package/dist/components/Error/Error.types.js +1 -0
- package/dist/components/Error/index.js +9 -2
- package/dist/components/Error/index.js.map +3 -3
- package/dist/components/Layout/Layout.js +4 -25
- package/dist/components/Layout/Layout.js.map +3 -3
- package/dist/components/Layout/index.js +8 -1
- package/dist/components/Layout/index.js.map +3 -3
- package/dist/components/Preview/PreviewCivWrapper.js +4 -25
- package/dist/components/Preview/PreviewCivWrapper.js.map +3 -3
- package/dist/components/Preview/PreviewContent.js +18 -10
- package/dist/components/Preview/PreviewContent.js.map +3 -3
- package/dist/components/Preview/PreviewPageWrapper.js +4 -85
- package/dist/components/Preview/PreviewPageWrapper.js.map +3 -3
- package/dist/components/Preview/index.js +29 -3
- package/dist/components/Preview/index.js.map +3 -3
- package/dist/components/Section/Section.js +18 -8
- package/dist/components/Section/Section.js.map +3 -3
- package/dist/components/Section/Section.types.js +1 -0
- package/dist/components/Section/SectionItem.js +18 -11
- package/dist/components/Section/SectionItem.js.map +3 -3
- package/dist/components/Section/SectionItemCiv.js +18 -19
- package/dist/components/Section/SectionItemCiv.js.map +3 -3
- package/dist/components/Section/index.js +25 -4
- package/dist/components/Section/index.js.map +3 -3
- package/dist/components/Unknown/Unknown.js +6 -28
- package/dist/components/Unknown/Unknown.js.map +3 -3
- package/dist/components/Unknown/index.js +10 -1
- package/dist/components/Unknown/index.js.map +3 -3
- package/dist/components/index.js +47 -6
- package/dist/components/index.js.map +3 -3
- package/dist/contexts/ComponentMapContext.js +19 -9
- package/dist/contexts/ComponentMapContext.js.map +3 -3
- package/dist/contexts/index.js +23 -1
- package/dist/contexts/index.js.map +3 -3
- package/dist/routes/index.js +7131 -2
- package/dist/routes/index.js.map +4 -4
- package/dist/types/cms.js +1 -0
- package/dist/types/index.js +2 -1
- package/dist/types/index.js.map +3 -3
- package/dist/utils/getCmsUrl.js +4 -5
- package/dist/utils/getCmsUrl.js.map +3 -3
- package/dist/utils/getPageContent.js +5 -50
- package/dist/utils/getPageContent.js.map +3 -3
- package/dist/utils/index.js +11 -2
- package/dist/utils/index.js.map +3 -3
- package/dist/vite/config.js +4 -33
- package/dist/vite/config.js.map +3 -3
- package/dist/vite/index.js +7 -1
- package/dist/vite/index.js.map +3 -3
- package/package.json +4 -4
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/components/Layout/Layout.tsx
|
|
2
|
+
import { Links, Meta, Scripts, ScrollRestoration } from "react-router";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var allowIndexing = process.env.NODE_ENV === "production";
|
|
5
|
+
function Layout({ children }) {
|
|
6
|
+
return /* @__PURE__ */ jsxs("html", { lang: "en", children: [
|
|
7
|
+
/* @__PURE__ */ jsxs("head", { children: [
|
|
8
|
+
/* @__PURE__ */ jsx(Meta, {}),
|
|
9
|
+
/* @__PURE__ */ jsx("meta", { charSet: "utf-8" }),
|
|
10
|
+
/* @__PURE__ */ jsx(
|
|
11
|
+
"meta",
|
|
12
|
+
{
|
|
13
|
+
name: "viewport",
|
|
14
|
+
content: "width=device-width,initial-scale=1"
|
|
15
|
+
}
|
|
16
|
+
),
|
|
17
|
+
allowIndexing && /* @__PURE__ */ jsx("meta", { name: "robots", content: "noindex, nofollow" }),
|
|
18
|
+
/* @__PURE__ */ jsx(Links, {})
|
|
19
|
+
] }),
|
|
20
|
+
/* @__PURE__ */ jsxs("body", { children: [
|
|
21
|
+
children,
|
|
22
|
+
/* @__PURE__ */ jsx(ScrollRestoration, {}),
|
|
23
|
+
/* @__PURE__ */ jsx(Scripts, {})
|
|
24
|
+
] })
|
|
25
|
+
] });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
Layout
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=chunk-2WII7C3O.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/Layout/Layout.tsx"],
|
|
4
|
+
"sourcesContent": ["import { Links, Meta, Scripts, ScrollRestoration } from \"react-router\";\n\n// FIXME: This is not ideal as its client-level and we really need site-level\nconst allowIndexing = process.env.NODE_ENV === \"production\";\n\ninterface LayoutProps {\n\tchildren: React.ReactNode;\n}\n\nexport function Layout({ children }: LayoutProps) {\n\treturn (\n\t\t<html lang=\"en\">\n\t\t\t<head>\n\t\t\t\t<Meta />\n\t\t\t\t<meta charSet=\"utf-8\" />\n\t\t\t\t<meta\n\t\t\t\t\tname=\"viewport\"\n\t\t\t\t\tcontent=\"width=device-width,initial-scale=1\"\n\t\t\t\t/>\n\t\t\t\t{allowIndexing && (\n\t\t\t\t\t<meta name=\"robots\" content=\"noindex, nofollow\" />\n\t\t\t\t)}\n\t\t\t\t<Links />\n\t\t\t</head>\n\t\t\t<body>\n\t\t\t\t{children}\n\t\t\t\t<ScrollRestoration />\n\t\t\t\t<Scripts />\n\t\t\t</body>\n\t\t</html>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,OAAO,MAAM,SAAS,yBAAyB;AAYrD,SACC,KADD;AATH,IAAM,gBAAgB,QAAQ,IAAI,aAAa;AAMxC,SAAS,OAAO,EAAE,SAAS,GAAgB;AACjD,SACC,qBAAC,UAAK,MAAK,MACV;AAAA,yBAAC,UACA;AAAA,0BAAC,QAAK;AAAA,MACN,oBAAC,UAAK,SAAQ,SAAQ;AAAA,MACtB;AAAA,QAAC;AAAA;AAAA,UACA,MAAK;AAAA,UACL,SAAQ;AAAA;AAAA,MACT;AAAA,MACC,iBACA,oBAAC,UAAK,MAAK,UAAS,SAAQ,qBAAoB;AAAA,MAEjD,oBAAC,SAAM;AAAA,OACR;AAAA,IACA,qBAAC,UACC;AAAA;AAAA,MACD,oBAAC,qBAAkB;AAAA,MACnB,oBAAC,WAAQ;AAAA,OACV;AAAA,KACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-4LSFAAZW.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
__commonJS,
|
|
29
|
+
__toESM
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=chunk-5WRI5ZAA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-CMALSZV3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-DG37VYL5.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/vite/config.ts
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
|
+
import tsconfigPaths from "vite-tsconfig-paths";
|
|
4
|
+
var config = defineConfig({
|
|
5
|
+
define: {
|
|
6
|
+
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV)
|
|
7
|
+
},
|
|
8
|
+
build: {
|
|
9
|
+
target: "es2022",
|
|
10
|
+
cssMinify: process.env.NODE_ENV === "production",
|
|
11
|
+
rollupOptions: {
|
|
12
|
+
external: [/node:.*/, "fsevents"]
|
|
13
|
+
},
|
|
14
|
+
assetsInlineLimit: (source) => {
|
|
15
|
+
if (source.endsWith("sprite.svg") || source.endsWith("favicon.svg") || source.endsWith("apple-touch-icon.png")) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
sourcemap: process.env.NODE_ENV === "development" ? true : false
|
|
20
|
+
},
|
|
21
|
+
plugins: [tsconfigPaths()],
|
|
22
|
+
server: {
|
|
23
|
+
allowedHosts: [".local.simpleviewcms.app"],
|
|
24
|
+
watch: {
|
|
25
|
+
usePolling: true
|
|
26
|
+
},
|
|
27
|
+
hmr: {
|
|
28
|
+
path: "/__cms_hmr_ws",
|
|
29
|
+
port: 24678,
|
|
30
|
+
clientPort: 443,
|
|
31
|
+
protocol: "wss"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
config
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=chunk-EDXU7MNB.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/vite/config.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineConfig } from \"vite\";\r\nimport tsconfigPaths from \"vite-tsconfig-paths\";\r\n\r\nexport const config = defineConfig({\r\n\tdefine: {\r\n\t\t\"process.env.NODE_ENV\": JSON.stringify(process.env.NODE_ENV),\r\n\t},\r\n\tbuild: {\r\n\t\ttarget: \"es2022\",\r\n\t\tcssMinify: process.env.NODE_ENV === \"production\",\r\n\t\trollupOptions: {\r\n\t\t\texternal: [/node:.*/, \"fsevents\"],\r\n\t\t},\r\n\t\tassetsInlineLimit: (source) => {\r\n\t\t\tif (\r\n\t\t\t\tsource.endsWith(\"sprite.svg\") ||\r\n\t\t\t\tsource.endsWith(\"favicon.svg\") ||\r\n\t\t\t\tsource.endsWith(\"apple-touch-icon.png\")\r\n\t\t\t) {\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t},\r\n\t\tsourcemap: process.env.NODE_ENV === \"development\" ? true : false,\r\n\t},\r\n\tplugins: [tsconfigPaths()],\r\n\tserver: {\r\n\t\tallowedHosts: [\".local.simpleviewcms.app\"],\r\n\t\twatch: {\r\n\t\t\tusePolling: true,\r\n\t\t},\r\n\t\thmr: {\r\n\t\t\tpath: \"/__cms_hmr_ws\",\r\n\t\t\tport: 24678,\r\n\t\t\tclientPort: 443,\r\n\t\t\tprotocol: \"wss\",\r\n\t\t},\r\n\t},\r\n});\r\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,oBAAoB;AAC7B,OAAO,mBAAmB;AAEnB,IAAM,SAAS,aAAa;AAAA,EAClC,QAAQ;AAAA,IACP,wBAAwB,KAAK,UAAU,QAAQ,IAAI,QAAQ;AAAA,EAC5D;AAAA,EACA,OAAO;AAAA,IACN,QAAQ;AAAA,IACR,WAAW,QAAQ,IAAI,aAAa;AAAA,IACpC,eAAe;AAAA,MACd,UAAU,CAAC,WAAW,UAAU;AAAA,IACjC;AAAA,IACA,mBAAmB,CAAC,WAAW;AAC9B,UACC,OAAO,SAAS,YAAY,KAC5B,OAAO,SAAS,aAAa,KAC7B,OAAO,SAAS,sBAAsB,GACrC;AACD,eAAO;AAAA,MACR;AAAA,IACD;AAAA,IACA,WAAW,QAAQ,IAAI,aAAa,gBAAgB,OAAO;AAAA,EAC5D;AAAA,EACA,SAAS,CAAC,cAAc,CAAC;AAAA,EACzB,QAAQ;AAAA,IACP,cAAc,CAAC,0BAA0B;AAAA,IACzC,OAAO;AAAA,MACN,YAAY;AAAA,IACb;AAAA,IACA,KAAK;AAAA,MACJ,MAAM;AAAA,MACN,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,UAAU;AAAA,IACX;AAAA,EACD;AACD,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/utils/getCmsUrl.ts
|
|
2
|
+
var { CMS_DOMAIN } = process.env;
|
|
3
|
+
function getCmsUrl(host) {
|
|
4
|
+
const siteClient = host.split(".")[0];
|
|
5
|
+
return new URL(`https://${siteClient}.${CMS_DOMAIN}`);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
getCmsUrl
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=chunk-EEKFLXZI.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils/getCmsUrl.ts"],
|
|
4
|
+
"sourcesContent": ["const { CMS_DOMAIN } = process.env;\r\n\r\nexport function getCmsUrl(host: string): URL {\r\n\tconst siteClient = host.split(\".\")[0];\r\n\treturn new URL(`https://${siteClient}.${CMS_DOMAIN}`);\r\n}\r\n"],
|
|
5
|
+
"mappings": ";AAAA,IAAM,EAAE,WAAW,IAAI,QAAQ;AAExB,SAAS,UAAU,MAAmB;AAC5C,QAAM,aAAa,KAAK,MAAM,GAAG,EAAE,CAAC;AACpC,SAAO,IAAI,IAAI,WAAW,UAAU,IAAI,UAAU,EAAE;AACrD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-EG5F4AP4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-EWRVCIV6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-F5L7DWHD.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCmsUrl
|
|
3
|
+
} from "./chunk-EEKFLXZI.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/getPageContent.ts
|
|
6
|
+
var previewPath = "/includes/plugins/nav/preview_civs/";
|
|
7
|
+
async function getPageContent(req) {
|
|
8
|
+
const incomingUrl = new URL(req.url, "http://placeholder.com");
|
|
9
|
+
const cmsUrl = getCmsUrl(incomingUrl.host);
|
|
10
|
+
if (!incomingUrl.pathname.endsWith("/") || /\.[^/]+$/.test(incomingUrl.pathname)) {
|
|
11
|
+
cmsUrl.pathname = incomingUrl.pathname + "/content.json";
|
|
12
|
+
} else {
|
|
13
|
+
cmsUrl.pathname = incomingUrl.pathname + "content.json";
|
|
14
|
+
}
|
|
15
|
+
const headers = {
|
|
16
|
+
"Accept-Encoding": "gzip",
|
|
17
|
+
"X-Forwarded-For": req.headers.get("x-real-ip") || req.headers.get("x-forwarded-host") || "",
|
|
18
|
+
"User-Agent": req.headers.get("user-agent") || ""
|
|
19
|
+
};
|
|
20
|
+
try {
|
|
21
|
+
let body = void 0;
|
|
22
|
+
if (req.method === "POST" && incomingUrl.pathname === previewPath) {
|
|
23
|
+
incomingUrl.searchParams.forEach((val, key) => {
|
|
24
|
+
cmsUrl.searchParams.set(key, val);
|
|
25
|
+
});
|
|
26
|
+
const formData = await req.formData();
|
|
27
|
+
const civs = formData.get("headless_civs");
|
|
28
|
+
if (typeof civs !== "string") {
|
|
29
|
+
throw new Error(
|
|
30
|
+
"Posted CIVs were not a base64 encoded string."
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const data = JSON.parse(atob(civs));
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
const url = cmsUrl.toString();
|
|
37
|
+
const { method } = req;
|
|
38
|
+
const fetchParams = {
|
|
39
|
+
method,
|
|
40
|
+
headers,
|
|
41
|
+
body
|
|
42
|
+
};
|
|
43
|
+
console.log("Making page content request:", {
|
|
44
|
+
url,
|
|
45
|
+
...fetchParams
|
|
46
|
+
});
|
|
47
|
+
const result = await fetch(url, fetchParams).then((res) => res.json());
|
|
48
|
+
return result;
|
|
49
|
+
} catch (err) {
|
|
50
|
+
const status = err?.response?.status || 500;
|
|
51
|
+
const message = err?.response?.statusText || "Server Error";
|
|
52
|
+
throw new Error(`Status ${status}: ${message}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
getPageContent
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=chunk-FJML4RHB.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils/getPageContent.ts"],
|
|
4
|
+
"sourcesContent": ["import type { CivProps, PageData } from \"../types/index.js\";\r\nimport { getCmsUrl } from \"./getCmsUrl.js\";\r\n\r\nexport type { PageData };\r\n\r\nconst previewPath = \"/includes/plugins/nav/preview_civs/\";\r\n\r\nexport async function getPageContent(\r\n\treq: Request\r\n): Promise<PageData<CivProps>> {\r\n\tconst incomingUrl = new URL(req.url, \"http://placeholder.com\");\r\n\tconst cmsUrl = getCmsUrl(incomingUrl.host);\r\n\r\n\tif (\r\n\t\t!incomingUrl.pathname.endsWith(\"/\") ||\r\n\t\t/\\.[^/]+$/.test(incomingUrl.pathname)\r\n\t) {\r\n\t\t// If it's a file request, we append /content.json\r\n\t\tcmsUrl.pathname = incomingUrl.pathname + \"/content.json\";\r\n\t} else {\r\n\t\t// If it's not a file request, we just append content.json since it already ends with a \"/\"\r\n\t\tcmsUrl.pathname = incomingUrl.pathname + \"content.json\";\r\n\t}\r\n\r\n\tconst headers: Record<string, string> = {\r\n\t\t\"Accept-Encoding\": \"gzip\",\r\n\t\t\"X-Forwarded-For\":\r\n\t\t\treq.headers.get(\"x-real-ip\") ||\r\n\t\t\treq.headers.get(\"x-forwarded-host\") ||\r\n\t\t\t\"\",\r\n\t\t\"User-Agent\": req.headers.get(\"user-agent\") || \"\",\r\n\t};\r\n\r\n\ttry {\r\n\t\tlet body: URLSearchParams | undefined = undefined;\r\n\r\n\t\t/**\r\n\t\t * If this is the live preview page, we need to append the search params from the incoming URL\r\n\t\t * and send the CIVs along with the request.\r\n\t\t */\r\n\t\tif (req.method === \"POST\" && incomingUrl.pathname === previewPath) {\r\n\t\t\tincomingUrl.searchParams.forEach((val, key) => {\r\n\t\t\t\tcmsUrl.searchParams.set(key, val);\r\n\t\t\t});\r\n\r\n\t\t\tconst formData = await req.formData();\r\n\t\t\tconst civs = formData.get(\"headless_civs\");\r\n\r\n\t\t\tif (typeof civs !== \"string\") {\r\n\t\t\t\tthrow new Error(\r\n\t\t\t\t\t\"Posted CIVs were not a base64 encoded string.\"\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\tconst data = JSON.parse(atob(civs));\r\n\r\n\t\t\treturn data;\r\n\t\t}\r\n\r\n\t\tconst url = cmsUrl.toString();\r\n\t\tconst { method } = req;\r\n\t\tconst fetchParams: RequestInit = {\r\n\t\t\tmethod,\r\n\t\t\theaders,\r\n\t\t\tbody,\r\n\t\t};\r\n\r\n\t\tconsole.log(\"Making page content request:\", {\r\n\t\t\turl,\r\n\t\t\t...fetchParams,\r\n\t\t});\r\n\r\n\t\tconst result = await fetch(url, fetchParams).then((res) => res.json());\r\n\t\treturn result;\r\n\t} catch (err: unknown) {\r\n\t\tconst status =\r\n\t\t\t(err as { response?: { status?: number } })?.response?.status ||\r\n\t\t\t500;\r\n\t\tconst message =\r\n\t\t\t(err as { response?: { statusText?: string } })?.response\r\n\t\t\t\t?.statusText || \"Server Error\";\r\n\t\tthrow new Error(`Status ${status}: ${message}`);\r\n\t}\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;;;;AAKA,IAAM,cAAc;AAEpB,eAAsB,eACrB,KAC8B;AAC9B,QAAM,cAAc,IAAI,IAAI,IAAI,KAAK,wBAAwB;AAC7D,QAAM,SAAS,UAAU,YAAY,IAAI;AAEzC,MACC,CAAC,YAAY,SAAS,SAAS,GAAG,KAClC,WAAW,KAAK,YAAY,QAAQ,GACnC;AAED,WAAO,WAAW,YAAY,WAAW;AAAA,EAC1C,OAAO;AAEN,WAAO,WAAW,YAAY,WAAW;AAAA,EAC1C;AAEA,QAAM,UAAkC;AAAA,IACvC,mBAAmB;AAAA,IACnB,mBACC,IAAI,QAAQ,IAAI,WAAW,KAC3B,IAAI,QAAQ,IAAI,kBAAkB,KAClC;AAAA,IACD,cAAc,IAAI,QAAQ,IAAI,YAAY,KAAK;AAAA,EAChD;AAEA,MAAI;AACH,QAAI,OAAoC;AAMxC,QAAI,IAAI,WAAW,UAAU,YAAY,aAAa,aAAa;AAClE,kBAAY,aAAa,QAAQ,CAAC,KAAK,QAAQ;AAC9C,eAAO,aAAa,IAAI,KAAK,GAAG;AAAA,MACjC,CAAC;AAED,YAAM,WAAW,MAAM,IAAI,SAAS;AACpC,YAAM,OAAO,SAAS,IAAI,eAAe;AAEzC,UAAI,OAAO,SAAS,UAAU;AAC7B,cAAM,IAAI;AAAA,UACT;AAAA,QACD;AAAA,MACD;AAEA,YAAM,OAAO,KAAK,MAAM,KAAK,IAAI,CAAC;AAElC,aAAO;AAAA,IACR;AAEA,UAAM,MAAM,OAAO,SAAS;AAC5B,UAAM,EAAE,OAAO,IAAI;AACnB,UAAM,cAA2B;AAAA,MAChC;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAEA,YAAQ,IAAI,gCAAgC;AAAA,MAC3C;AAAA,MACA,GAAG;AAAA,IACJ,CAAC;AAED,UAAM,SAAS,MAAM,MAAM,KAAK,WAAW,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC;AACrE,WAAO;AAAA,EACR,SAAS,KAAc;AACtB,UAAM,SACJ,KAA4C,UAAU,UACvD;AACD,UAAM,UACJ,KAAgD,UAC9C,cAAc;AAClB,UAAM,IAAI,MAAM,UAAU,MAAM,KAAK,OAAO,EAAE;AAAA,EAC/C;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/components/Unknown/Unknown.tsx
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
var Unknown = ({ civid, name, type, component }) => {
|
|
4
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-red-900 text-white p-6 my-5 flex flex-col rounded-lg", children: [
|
|
5
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
6
|
+
/* @__PURE__ */ jsx("strong", { children: "Unknown Component" }),
|
|
7
|
+
component && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8
|
+
/* @__PURE__ */ jsx("span", { children: " " }),
|
|
9
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
10
|
+
"(",
|
|
11
|
+
component,
|
|
12
|
+
")"
|
|
13
|
+
] })
|
|
14
|
+
] })
|
|
15
|
+
] }),
|
|
16
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
17
|
+
"civid: ",
|
|
18
|
+
civid
|
|
19
|
+
] }),
|
|
20
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
21
|
+
"name: ",
|
|
22
|
+
name,
|
|
23
|
+
" (",
|
|
24
|
+
type,
|
|
25
|
+
")"
|
|
26
|
+
] })
|
|
27
|
+
] });
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
Unknown
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=chunk-GPTPACV2.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/Unknown/Unknown.tsx"],
|
|
4
|
+
"sourcesContent": ["import { type CivProps } from \"../../types/index.js\";\n\nexport const Unknown = ({ civid, name, type, component }: CivProps) => {\n\treturn (\n\t\t<div className=\"bg-red-900 text-white p-6 my-5 flex flex-col rounded-lg\">\n\t\t\t<div>\n\t\t\t\t<strong>Unknown Component</strong>\n\t\t\t\t{component && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span> </span>\n\t\t\t\t\t\t<span>({component})</span>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t<div>civid: {civid}</div>\n\t\t\t<div>\n\t\t\t\tname: {name} ({type})\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n"],
|
|
5
|
+
"mappings": ";AAMI,SAEC,UAFD,KAIE,YAJF;AAJG,IAAM,UAAU,CAAC,EAAE,OAAO,MAAM,MAAM,UAAU,MAAgB;AACtE,SACC,qBAAC,SAAI,WAAU,2DACd;AAAA,yBAAC,SACA;AAAA,0BAAC,YAAO,+BAAiB;AAAA,MACxB,aACA,iCACC;AAAA,4BAAC,UAAK,eAAC;AAAA,QACP,qBAAC,UAAK;AAAA;AAAA,UAAE;AAAA,UAAU;AAAA,WAAC;AAAA,SACpB;AAAA,OAEF;AAAA,IACA,qBAAC,SAAI;AAAA;AAAA,MAAQ;AAAA,OAAM;AAAA,IACnB,qBAAC,SAAI;AAAA;AAAA,MACG;AAAA,MAAK;AAAA,MAAG;AAAA,MAAK;AAAA,OACrB;AAAA,KACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PreviewCivWrapper
|
|
3
|
+
} from "./chunk-OEYLOZQK.js";
|
|
4
|
+
import {
|
|
5
|
+
usePreview
|
|
6
|
+
} from "./chunk-P3WX4DFS.js";
|
|
7
|
+
import {
|
|
8
|
+
Error
|
|
9
|
+
} from "./chunk-VV3NKXSX.js";
|
|
10
|
+
import {
|
|
11
|
+
Unknown
|
|
12
|
+
} from "./chunk-GPTPACV2.js";
|
|
13
|
+
|
|
14
|
+
// src/components/Preview/PreviewContent.tsx
|
|
15
|
+
import { jsx } from "react/jsx-runtime";
|
|
16
|
+
function PreviewContent() {
|
|
17
|
+
const preview = usePreview();
|
|
18
|
+
if (!preview || !preview.pageData) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return /* @__PURE__ */ jsx(Section, { section: [preview.pageData.body] });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/contexts/ComponentMapContext.tsx
|
|
25
|
+
import { createContext, useContext } from "react";
|
|
26
|
+
var ComponentMapContext = createContext({
|
|
27
|
+
civs: {},
|
|
28
|
+
Error,
|
|
29
|
+
Unknown
|
|
30
|
+
});
|
|
31
|
+
var ComponentMapProvider = ComponentMapContext.Provider;
|
|
32
|
+
var useComponentMap = () => useContext(ComponentMapContext);
|
|
33
|
+
|
|
34
|
+
// src/components/Section/SectionItemCiv.tsx
|
|
35
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
36
|
+
function SectionItemCiv(civ) {
|
|
37
|
+
const map = useComponentMap();
|
|
38
|
+
if (civ === void 0) {
|
|
39
|
+
return /* @__PURE__ */ jsx2(
|
|
40
|
+
map.Error,
|
|
41
|
+
{
|
|
42
|
+
status: 500,
|
|
43
|
+
message: "Is the CMS API running? I bet it isn't \u{1F609}"
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
const Component = map.civs[civ.component];
|
|
48
|
+
if (Component === void 0) {
|
|
49
|
+
return /* @__PURE__ */ jsx2(map.Unknown, { ...civ });
|
|
50
|
+
}
|
|
51
|
+
return /* @__PURE__ */ jsx2(Component, { ...civ });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/components/Section/SectionItem.tsx
|
|
55
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
56
|
+
function SectionItem(civ) {
|
|
57
|
+
const preview = usePreview();
|
|
58
|
+
if (!preview) {
|
|
59
|
+
return /* @__PURE__ */ jsx3(SectionItemCiv, { ...civ });
|
|
60
|
+
}
|
|
61
|
+
return /* @__PURE__ */ jsx3(PreviewCivWrapper, { civid: civ.civid, ...preview, children: /* @__PURE__ */ jsx3(SectionItemCiv, { ...civ }) });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/components/Section/Section.tsx
|
|
65
|
+
import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
|
|
66
|
+
function Section({ section }) {
|
|
67
|
+
if (!Array.isArray(section) || !section.length) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return /* @__PURE__ */ jsx4(Fragment, { children: section.map((civ) => /* @__PURE__ */ jsx4(SectionItem, { ...civ }, civ.civid)) });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
ComponentMapProvider,
|
|
75
|
+
useComponentMap,
|
|
76
|
+
SectionItemCiv,
|
|
77
|
+
SectionItem,
|
|
78
|
+
Section,
|
|
79
|
+
PreviewContent
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=chunk-JT6WIXOP.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/Preview/PreviewContent.tsx", "../src/contexts/ComponentMapContext.tsx", "../src/components/Section/SectionItemCiv.tsx", "../src/components/Section/SectionItem.tsx", "../src/components/Section/Section.tsx"],
|
|
4
|
+
"sourcesContent": ["import { Section } from \"../Section/Section.js\";\r\nimport { usePreview } from \"./PreviewPageWrapper.js\";\r\n\r\nexport function PreviewContent() {\r\n\tconst preview = usePreview();\r\n\r\n\tif (!preview || !preview.pageData) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\treturn <Section section={[preview.pageData.body]} />;\r\n}\r\n", "import { Unknown, Error, type ErrorProps } from \"../components/index.js\";\r\nimport type { CivProps, ComponentMap } from \"../types/index.js\";\r\nimport { createContext, useContext, type FC } from \"react\";\r\n\r\nconst ComponentMapContext = createContext<{\r\n\tcivs: ComponentMap;\r\n\tError: FC<ErrorProps>;\r\n\tUnknown: FC<CivProps>;\r\n}>({\r\n\tcivs: {},\r\n\tError,\r\n\tUnknown,\r\n});\r\n\r\nexport const ComponentMapProvider = ComponentMapContext.Provider;\r\n\r\nexport const useComponentMap = () => useContext(ComponentMapContext);\r\n", "import { useComponentMap } from \"../../contexts/index.js\";\r\nimport type { CivProps } from \"../../types/index.js\";\r\n\r\nexport function SectionItemCiv(civ: CivProps) {\r\n\tconst map = useComponentMap();\r\n\r\n\tif (civ === undefined) {\r\n\t\treturn (\r\n\t\t\t<map.Error\r\n\t\t\t\tstatus={500}\r\n\t\t\t\tmessage=\"Is the CMS API running? I bet it isn't \uD83D\uDE09\"\r\n\t\t\t/>\r\n\t\t);\r\n\t}\r\n\r\n\tconst Component = map.civs[civ.component];\r\n\r\n\tif (Component === undefined) {\r\n\t\treturn <map.Unknown {...civ} />;\r\n\t}\r\n\r\n\treturn <Component {...civ} />;\r\n}\r\n", "import type { CivProps } from \"../../types/index.js\";\r\nimport { PreviewCivWrapper } from \"../Preview/index.js\";\r\nimport { usePreview } from \"../Preview/PreviewPageWrapper.js\";\r\nimport { SectionItemCiv } from \"./SectionItemCiv.js\";\r\n\r\nexport function SectionItem(civ: CivProps) {\r\n\tconst preview = usePreview();\r\n\r\n\tif (!preview) {\r\n\t\treturn <SectionItemCiv {...civ} />;\r\n\t}\r\n\r\n\treturn (\r\n\t\t<PreviewCivWrapper civid={civ.civid} {...preview}>\r\n\t\t\t<SectionItemCiv {...civ} />\r\n\t\t</PreviewCivWrapper>\r\n\t);\r\n}\r\n", "import type { SectionProps } from \"./Section.types.js\";\r\nimport { SectionItem } from \"./SectionItem.js\";\r\n\r\nexport function Section({ section }: SectionProps) {\r\n\tif (!Array.isArray(section) || !section.length) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\treturn (\r\n\t\t<>\r\n\t\t\t{section.map((civ) => (\r\n\t\t\t\t<SectionItem key={civ.civid} {...civ} />\r\n\t\t\t))}\r\n\t\t</>\r\n\t);\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAUQ;AAPD,SAAS,iBAAiB;AAChC,QAAM,UAAU,WAAW;AAE3B,MAAI,CAAC,WAAW,CAAC,QAAQ,UAAU;AAClC,WAAO;AAAA,EACR;AAEA,SAAO,oBAAC,WAAQ,SAAS,CAAC,QAAQ,SAAS,IAAI,GAAG;AACnD;;;ACTA,SAAS,eAAe,kBAA2B;AAEnD,IAAM,sBAAsB,cAIzB;AAAA,EACF,MAAM,CAAC;AAAA,EACP;AAAA,EACA;AACD,CAAC;AAEM,IAAM,uBAAuB,oBAAoB;AAEjD,IAAM,kBAAkB,MAAM,WAAW,mBAAmB;;;ACRhE,gBAAAA,YAAA;AALI,SAAS,eAAe,KAAe;AAC7C,QAAM,MAAM,gBAAgB;AAE5B,MAAI,QAAQ,QAAW;AACtB,WACC,gBAAAA;AAAA,MAAC,IAAI;AAAA,MAAJ;AAAA,QACA,QAAQ;AAAA,QACR,SAAQ;AAAA;AAAA,IACT;AAAA,EAEF;AAEA,QAAM,YAAY,IAAI,KAAK,IAAI,SAAS;AAExC,MAAI,cAAc,QAAW;AAC5B,WAAO,gBAAAA,KAAC,IAAI,SAAJ,EAAa,GAAG,KAAK;AAAA,EAC9B;AAEA,SAAO,gBAAAA,KAAC,aAAW,GAAG,KAAK;AAC5B;;;ACbS,gBAAAC,YAAA;AAJF,SAAS,YAAY,KAAe;AAC1C,QAAM,UAAU,WAAW;AAE3B,MAAI,CAAC,SAAS;AACb,WAAO,gBAAAA,KAAC,kBAAgB,GAAG,KAAK;AAAA,EACjC;AAEA,SACC,gBAAAA,KAAC,qBAAkB,OAAO,IAAI,OAAQ,GAAG,SACxC,0BAAAA,KAAC,kBAAgB,GAAG,KAAK,GAC1B;AAEF;;;ACRE,mBAEE,OAAAC,YAFF;AANK,SAAS,QAAQ,EAAE,QAAQ,GAAiB;AAClD,MAAI,CAAC,MAAM,QAAQ,OAAO,KAAK,CAAC,QAAQ,QAAQ;AAC/C,WAAO;AAAA,EACR;AAEA,SACC,gBAAAA,KAAA,YACE,kBAAQ,IAAI,CAAC,QACb,gBAAAA,KAAC,eAA6B,GAAG,OAAf,IAAI,KAAgB,CACtC,GACF;AAEF;",
|
|
6
|
+
"names": ["jsx", "jsx", "jsx"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/App/App.tsx"],
|
|
4
|
+
"sourcesContent": ["import { Outlet } from \"react-router\";\n\nexport function App() {\n\treturn <Outlet />;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,cAAc;AAGf;AADD,SAAS,MAAM;AACrB,SAAO,oBAAC,UAAO;AAChB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/components/Preview/PreviewCivWrapper.tsx
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
function PreviewCivWrapper({
|
|
4
|
+
children,
|
|
5
|
+
civid,
|
|
6
|
+
onCivEnter,
|
|
7
|
+
highlighted,
|
|
8
|
+
register
|
|
9
|
+
}) {
|
|
10
|
+
const onMouseEnter = (e) => {
|
|
11
|
+
e.stopPropagation();
|
|
12
|
+
onCivEnter(civid);
|
|
13
|
+
};
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
"div",
|
|
16
|
+
{
|
|
17
|
+
style: highlighted === civid ? {
|
|
18
|
+
outlineOffset: 5,
|
|
19
|
+
outline: "rgb(217, 83, 30) solid 7px"
|
|
20
|
+
} : void 0,
|
|
21
|
+
onMouseEnter,
|
|
22
|
+
ref: register(civid),
|
|
23
|
+
children
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
PreviewCivWrapper
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=chunk-OEYLOZQK.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/Preview/PreviewCivWrapper.tsx"],
|
|
4
|
+
"sourcesContent": ["import type { PropsWithChildren, MouseEventHandler } from \"react\";\r\nimport type { PreviewContextState } from \"./PreviewPageWrapper.js\";\r\n\r\ntype PreviewCivWrapper = PropsWithChildren<{\r\n\tcivid: string;\r\n}> &\r\n\tPreviewContextState;\r\n\r\nexport function PreviewCivWrapper({\r\n\tchildren,\r\n\tcivid,\r\n\tonCivEnter,\r\n\thighlighted,\r\n\tregister,\r\n}: PreviewCivWrapper) {\r\n\tconst onMouseEnter: MouseEventHandler = (e) => {\r\n\t\te.stopPropagation();\r\n\t\tonCivEnter(civid);\r\n\t};\r\n\r\n\treturn (\r\n\t\t<div\r\n\t\t\tstyle={\r\n\t\t\t\thighlighted === civid\r\n\t\t\t\t\t? {\r\n\t\t\t\t\t\t\toutlineOffset: 5,\r\n\t\t\t\t\t\t\toutline: \"rgb(217, 83, 30) solid 7px\",\r\n\t\t\t\t\t }\r\n\t\t\t\t\t: undefined\r\n\t\t\t}\r\n\t\t\tonMouseEnter={onMouseEnter}\r\n\t\t\tref={register(civid)}\r\n\t\t>\r\n\t\t\t{children}\r\n\t\t</div>\r\n\t);\r\n}\r\n"],
|
|
5
|
+
"mappings": ";AAqBE;AAbK,SAAS,kBAAkB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAsB;AACrB,QAAM,eAAkC,CAAC,MAAM;AAC9C,MAAE,gBAAgB;AAClB,eAAW,KAAK;AAAA,EACjB;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OACC,gBAAgB,QACb;AAAA,QACA,eAAe;AAAA,QACf,SAAS;AAAA,MACT,IACA;AAAA,MAEJ;AAAA,MACA,KAAK,SAAS,KAAK;AAAA,MAElB;AAAA;AAAA,EACF;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/components/Preview/PreviewPageWrapper.tsx
|
|
2
|
+
import {
|
|
3
|
+
createContext,
|
|
4
|
+
useContext,
|
|
5
|
+
useMemo,
|
|
6
|
+
useEffect,
|
|
7
|
+
useState,
|
|
8
|
+
useRef
|
|
9
|
+
} from "react";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
var PreviewContext = createContext(
|
|
12
|
+
void 0
|
|
13
|
+
);
|
|
14
|
+
var usePreview = () => useContext(PreviewContext);
|
|
15
|
+
var post = (message) => {
|
|
16
|
+
const parent = window.opener || window.parent;
|
|
17
|
+
const fullMessage = typeof message === "string" ? message : {
|
|
18
|
+
...message,
|
|
19
|
+
namespace: "sv_preview"
|
|
20
|
+
};
|
|
21
|
+
parent.postMessage(fullMessage, "*");
|
|
22
|
+
};
|
|
23
|
+
function PreviewPageWrapper({
|
|
24
|
+
children,
|
|
25
|
+
pageContent
|
|
26
|
+
}) {
|
|
27
|
+
const refs = useRef({});
|
|
28
|
+
const [highlighted, setHighlighted] = useState(
|
|
29
|
+
void 0
|
|
30
|
+
);
|
|
31
|
+
const [pageData, setPageData] = useState(
|
|
32
|
+
pageContent
|
|
33
|
+
);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
setPageData(pageContent);
|
|
36
|
+
}, [pageContent]);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
post("init");
|
|
39
|
+
const handleMessage = ({ data }) => {
|
|
40
|
+
if (!data || !("namespace" in data) || data.namespace !== "sv_preview" || !("event" in data) || !("args" in data)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const { event, args } = data;
|
|
44
|
+
if (event === "highlight") {
|
|
45
|
+
setHighlighted(args.civid);
|
|
46
|
+
}
|
|
47
|
+
if (event === "scrollTo") {
|
|
48
|
+
if (!refs.current[args.civid]) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
refs.current[args.civid].scrollIntoView({
|
|
52
|
+
behavior: "smooth",
|
|
53
|
+
block: "nearest"
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (event === "update") {
|
|
57
|
+
setPageData((prevPageData) => {
|
|
58
|
+
if (!prevPageData) return null;
|
|
59
|
+
return { ...prevPageData, body: args.body };
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
window.addEventListener("message", handleMessage);
|
|
64
|
+
return () => window.removeEventListener("message", handleMessage);
|
|
65
|
+
}, [setPageData]);
|
|
66
|
+
const previewContextState = useMemo(
|
|
67
|
+
() => ({
|
|
68
|
+
register: (civid) => {
|
|
69
|
+
return (ref) => refs.current[civid] = ref;
|
|
70
|
+
},
|
|
71
|
+
onCivEnter: (civid) => {
|
|
72
|
+
post({
|
|
73
|
+
event: "pbScrollTo",
|
|
74
|
+
args: { civid }
|
|
75
|
+
});
|
|
76
|
+
post({
|
|
77
|
+
event: "pbHighlight",
|
|
78
|
+
args: { civid }
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
highlighted,
|
|
82
|
+
pageData
|
|
83
|
+
}),
|
|
84
|
+
[highlighted, pageData]
|
|
85
|
+
);
|
|
86
|
+
return /* @__PURE__ */ jsx(PreviewContext.Provider, { value: previewContextState, children });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
usePreview,
|
|
91
|
+
PreviewPageWrapper
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=chunk-P3WX4DFS.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/Preview/PreviewPageWrapper.tsx"],
|
|
4
|
+
"sourcesContent": ["import type { PropsWithChildren } from \"react\";\r\nimport {\r\n\tcreateContext,\r\n\tuseContext,\r\n\tuseMemo,\r\n\tuseEffect,\r\n\tuseState,\r\n\tuseRef,\r\n} from \"react\";\r\nimport type { CivProps, PageData } from \"../../types/index.js\";\r\n\r\nexport interface PreviewContextState {\r\n\tonCivEnter: (civid: string) => void;\r\n\thighlighted?: string;\r\n\tregister: (civid: string) => (ref: HTMLDivElement) => void;\r\n\tpageData: PageData<CivProps> | null;\r\n}\r\n\r\nconst PreviewContext = createContext<PreviewContextState | undefined>(\r\n\tundefined\r\n);\r\n\r\nexport const usePreview = (): PreviewContextState | undefined =>\r\n\tuseContext(PreviewContext);\r\n\r\ntype PostMessage =\r\n\t| \"init\"\r\n\t| { event: \"pbScrollTo\"; args: { civid: string } }\r\n\t| { event: \"pbHighlight\"; args: { civid: string } }\r\n\t| { event: \"pbUpdate\"; args: { body: CivProps } };\r\n\r\nconst post = (message: PostMessage) => {\r\n\tconst parent = window.opener || window.parent;\r\n\tconst fullMessage =\r\n\t\ttypeof message === \"string\"\r\n\t\t\t? message\r\n\t\t\t: {\r\n\t\t\t\t\t...message,\r\n\t\t\t\t\tnamespace: \"sv_preview\",\r\n\t\t\t };\r\n\r\n\tparent.postMessage(fullMessage, \"*\");\r\n};\r\n\r\nexport function PreviewPageWrapper({\r\n\tchildren,\r\n\tpageContent,\r\n}: PropsWithChildren<{ pageContent: PageData<CivProps> }>) {\r\n\tconst refs = useRef<Record<string, HTMLDivElement>>({});\r\n\tconst [highlighted, setHighlighted] = useState<string | undefined>(\r\n\t\tundefined\r\n\t);\r\n\tconst [pageData, setPageData] = useState<PageData<CivProps> | null>(\r\n\t\tpageContent\r\n\t);\r\n\r\n\tuseEffect(() => {\r\n\t\tsetPageData(pageContent);\r\n\t}, [pageContent]);\r\n\r\n\tuseEffect(() => {\r\n\t\tpost(\"init\");\r\n\r\n\t\tconst handleMessage = ({ data }: WindowEventMap[\"message\"]) => {\r\n\t\t\tif (\r\n\t\t\t\t!data ||\r\n\t\t\t\t!(\"namespace\" in data) ||\r\n\t\t\t\tdata.namespace !== \"sv_preview\" ||\r\n\t\t\t\t!(\"event\" in data) ||\r\n\t\t\t\t!(\"args\" in data)\r\n\t\t\t) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tconst { event, args } = data;\r\n\r\n\t\t\tif (event === \"highlight\") {\r\n\t\t\t\tsetHighlighted(args.civid);\r\n\t\t\t}\r\n\r\n\t\t\tif (event === \"scrollTo\") {\r\n\t\t\t\tif (!refs.current[args.civid]) {\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\trefs.current[args.civid].scrollIntoView({\r\n\t\t\t\t\tbehavior: \"smooth\",\r\n\t\t\t\t\tblock: \"nearest\",\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tif (event === \"update\") {\r\n\t\t\t\tsetPageData((prevPageData) => {\r\n\t\t\t\t\tif (!prevPageData) return null;\r\n\t\t\t\t\treturn { ...prevPageData, body: args.body };\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\twindow.addEventListener(\"message\", handleMessage);\r\n\t\treturn () => window.removeEventListener(\"message\", handleMessage);\r\n\t}, [setPageData]);\r\n\r\n\tconst previewContextState = useMemo<PreviewContextState>(\r\n\t\t() => ({\r\n\t\t\tregister: (civid) => {\r\n\t\t\t\treturn (ref) => (refs.current[civid] = ref);\r\n\t\t\t},\r\n\t\t\tonCivEnter: (civid) => {\r\n\t\t\t\tpost({\r\n\t\t\t\t\tevent: \"pbScrollTo\",\r\n\t\t\t\t\targs: { civid },\r\n\t\t\t\t});\r\n\t\t\t\tpost({\r\n\t\t\t\t\tevent: \"pbHighlight\",\r\n\t\t\t\t\targs: { civid },\r\n\t\t\t\t});\r\n\t\t\t},\r\n\t\t\thighlighted,\r\n\t\t\tpageData,\r\n\t\t}),\r\n\t\t[highlighted, pageData]\r\n\t);\r\n\r\n\treturn (\r\n\t\t<PreviewContext.Provider value={previewContextState}>\r\n\t\t\t{children}\r\n\t\t</PreviewContext.Provider>\r\n\t);\r\n}\r\n"],
|
|
5
|
+
"mappings": ";AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAqHL;AA3GF,IAAM,iBAAiB;AAAA,EACtB;AACD;AAEO,IAAM,aAAa,MACzB,WAAW,cAAc;AAQ1B,IAAM,OAAO,CAAC,YAAyB;AACtC,QAAM,SAAS,OAAO,UAAU,OAAO;AACvC,QAAM,cACL,OAAO,YAAY,WAChB,UACA;AAAA,IACA,GAAG;AAAA,IACH,WAAW;AAAA,EACX;AAEJ,SAAO,YAAY,aAAa,GAAG;AACpC;AAEO,SAAS,mBAAmB;AAAA,EAClC;AAAA,EACA;AACD,GAA2D;AAC1D,QAAM,OAAO,OAAuC,CAAC,CAAC;AACtD,QAAM,CAAC,aAAa,cAAc,IAAI;AAAA,IACrC;AAAA,EACD;AACA,QAAM,CAAC,UAAU,WAAW,IAAI;AAAA,IAC/B;AAAA,EACD;AAEA,YAAU,MAAM;AACf,gBAAY,WAAW;AAAA,EACxB,GAAG,CAAC,WAAW,CAAC;AAEhB,YAAU,MAAM;AACf,SAAK,MAAM;AAEX,UAAM,gBAAgB,CAAC,EAAE,KAAK,MAAiC;AAC9D,UACC,CAAC,QACD,EAAE,eAAe,SACjB,KAAK,cAAc,gBACnB,EAAE,WAAW,SACb,EAAE,UAAU,OACX;AACD;AAAA,MACD;AAEA,YAAM,EAAE,OAAO,KAAK,IAAI;AAExB,UAAI,UAAU,aAAa;AAC1B,uBAAe,KAAK,KAAK;AAAA,MAC1B;AAEA,UAAI,UAAU,YAAY;AACzB,YAAI,CAAC,KAAK,QAAQ,KAAK,KAAK,GAAG;AAC9B;AAAA,QACD;AAEA,aAAK,QAAQ,KAAK,KAAK,EAAE,eAAe;AAAA,UACvC,UAAU;AAAA,UACV,OAAO;AAAA,QACR,CAAC;AAAA,MACF;AAEA,UAAI,UAAU,UAAU;AACvB,oBAAY,CAAC,iBAAiB;AAC7B,cAAI,CAAC,aAAc,QAAO;AAC1B,iBAAO,EAAE,GAAG,cAAc,MAAM,KAAK,KAAK;AAAA,QAC3C,CAAC;AAAA,MACF;AAAA,IACD;AAEA,WAAO,iBAAiB,WAAW,aAAa;AAChD,WAAO,MAAM,OAAO,oBAAoB,WAAW,aAAa;AAAA,EACjE,GAAG,CAAC,WAAW,CAAC;AAEhB,QAAM,sBAAsB;AAAA,IAC3B,OAAO;AAAA,MACN,UAAU,CAAC,UAAU;AACpB,eAAO,CAAC,QAAS,KAAK,QAAQ,KAAK,IAAI;AAAA,MACxC;AAAA,MACA,YAAY,CAAC,UAAU;AACtB,aAAK;AAAA,UACJ,OAAO;AAAA,UACP,MAAM,EAAE,MAAM;AAAA,QACf,CAAC;AACD,aAAK;AAAA,UACJ,OAAO;AAAA,UACP,MAAM,EAAE,MAAM;AAAA,QACf,CAAC;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA,CAAC,aAAa,QAAQ;AAAA,EACvB;AAEA,SACC,oBAAC,eAAe,UAAf,EAAwB,OAAO,qBAC9B,UACF;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/components/Error/Error.tsx
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
function Error({ status, message }) {
|
|
4
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5
|
+
/* @__PURE__ */ jsx("h1", { children: "Error" }),
|
|
6
|
+
/* @__PURE__ */ jsxs("h3", { children: [
|
|
7
|
+
"Status Code: ",
|
|
8
|
+
status
|
|
9
|
+
] }),
|
|
10
|
+
/* @__PURE__ */ jsx("p", { children: message })
|
|
11
|
+
] });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
Error
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=chunk-VV3NKXSX.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/components/Error/Error.tsx"],
|
|
4
|
+
"sourcesContent": ["import type { ErrorProps } from \"./Error.types.js\";\r\n\r\nexport function Error({ status, message }: ErrorProps) {\r\n\treturn (\r\n\t\t<>\r\n\t\t\t<h1>Error</h1>\r\n\t\t\t<h3>Status Code: {status}</h3>\r\n\t\t\t<p>{message}</p>\r\n\t\t</>\r\n\t);\r\n}\r\n"],
|
|
5
|
+
"mappings": ";AAIE,mBACC,KACA,YAFD;AAFK,SAAS,MAAM,EAAE,QAAQ,QAAQ,GAAe;AACtD,SACC,iCACC;AAAA,wBAAC,QAAG,mBAAK;AAAA,IACT,qBAAC,QAAG;AAAA;AAAA,MAAc;AAAA,OAAO;AAAA,IACzB,oBAAC,OAAG,mBAAQ;AAAA,KACb;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|