@simpleview/cms-foundation 0.0.3 → 0.0.4
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/components/App/App.js +9 -0
- package/dist/components/App/App.js.map +7 -0
- package/dist/components/App/index.js +2 -0
- package/dist/components/App/index.js.map +7 -0
- package/dist/components/Layout/Layout.js +29 -0
- package/dist/components/Layout/Layout.js.map +7 -0
- package/dist/components/Layout/index.js +2 -0
- package/dist/components/Layout/index.js.map +7 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +2 -2
- package/dist/types/components/App/App.d.ts +1 -0
- package/dist/types/components/App/index.d.ts +1 -0
- package/dist/types/components/Layout/Layout.d.ts +5 -0
- package/dist/types/components/Layout/index.d.ts +1 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/types/cms.d.ts +2 -1
- package/dist/utils/getPageContent.js +6 -0
- package/dist/utils/getPageContent.js.map +2 -2
- package/package.json +3 -2
|
@@ -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": "AAGQ;AAHR,SAAS,cAAc;AAEhB,SAAS,MAAM;AACrB,SAAO,oBAAC,UAAO;AAChB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Links, Meta, Scripts, ScrollRestoration } from "react-router";
|
|
3
|
+
const allowIndexing = process.env.NODE_ENV === "production";
|
|
4
|
+
function Layout({ children }) {
|
|
5
|
+
return /* @__PURE__ */ jsxs("html", { lang: "en", children: [
|
|
6
|
+
/* @__PURE__ */ jsxs("head", { children: [
|
|
7
|
+
/* @__PURE__ */ jsx(Meta, {}),
|
|
8
|
+
/* @__PURE__ */ jsx("meta", { charSet: "utf-8" }),
|
|
9
|
+
/* @__PURE__ */ jsx(
|
|
10
|
+
"meta",
|
|
11
|
+
{
|
|
12
|
+
name: "viewport",
|
|
13
|
+
content: "width=device-width,initial-scale=1"
|
|
14
|
+
}
|
|
15
|
+
),
|
|
16
|
+
allowIndexing && /* @__PURE__ */ jsx("meta", { name: "robots", content: "noindex, nofollow" }),
|
|
17
|
+
/* @__PURE__ */ jsx(Links, {})
|
|
18
|
+
] }),
|
|
19
|
+
/* @__PURE__ */ jsxs("body", { children: [
|
|
20
|
+
children,
|
|
21
|
+
/* @__PURE__ */ jsx(ScrollRestoration, {}),
|
|
22
|
+
/* @__PURE__ */ jsx(Scripts, {})
|
|
23
|
+
] })
|
|
24
|
+
] });
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
Layout
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=Layout.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\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": "AAWG,SACC,KADD;AAXH,SAAS,OAAO,MAAM,SAAS,yBAAyB;AAExD,MAAM,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
|
+
}
|
package/dist/components/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/components/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./Error\";\r\nexport * from \"./Section\";\r\nexport * from \"./Unknown\";\r\n"],
|
|
5
|
-
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
4
|
+
"sourcesContent": ["export * from \"./App\";\r\nexport * from \"./Error\";\r\nexport * from \"./Layout\";\r\nexport * from \"./Section\";\r\nexport * from \"./Unknown\";\r\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function App(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./App";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Layout";
|
|
@@ -162,12 +162,13 @@ export interface PageData<T> {
|
|
|
162
162
|
};
|
|
163
163
|
token: string;
|
|
164
164
|
}
|
|
165
|
-
export interface CivProps<D = any> {
|
|
165
|
+
export interface CivProps<D = any, TD = any> {
|
|
166
166
|
civid: string;
|
|
167
167
|
name: string;
|
|
168
168
|
type: string;
|
|
169
169
|
component: string;
|
|
170
170
|
content: Record<string, CivProps[]>;
|
|
171
171
|
data: D;
|
|
172
|
+
templateData: TD;
|
|
172
173
|
}
|
|
173
174
|
export type ComponentMap = Record<string, React.FC<CivProps>>;
|
|
@@ -22,6 +22,12 @@ async function getPageContent(req) {
|
|
|
22
22
|
headers["User-Agent"] = req.headers.get("user-agent") || "";
|
|
23
23
|
}
|
|
24
24
|
try {
|
|
25
|
+
console.log("Making page content request:", {
|
|
26
|
+
url: cmsUrl.toString(),
|
|
27
|
+
method: req.method,
|
|
28
|
+
headers,
|
|
29
|
+
body: data
|
|
30
|
+
});
|
|
25
31
|
const response = await fetch(cmsUrl.toString(), {
|
|
26
32
|
method: req.method,
|
|
27
33
|
headers,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/getPageContent.ts"],
|
|
4
|
-
"sourcesContent": ["import { IncomingMessage } from \"http\";\r\nimport type { CivProps, PageData } from \"../types\";\r\nimport { getCmsUrl } from \"./getCmsUrl\";\r\n\r\nexport type { PageData };\r\n\r\nexport async function getPageContent(\r\n\treq: Request\r\n): Promise<PageData<CivProps>> {\r\n\tlet data: undefined | IncomingMessage;\r\n\r\n\t// if (req.method === \"POST\") {\r\n\t// \t// if we have a POST req (most likely for Page Editor preview) then\r\n\t// \t// we'll pass the incoming req stream directly on to our outgoing\r\n\t// \t// req to the CMS. We don't do anything with the data here.\r\n\t// \tdata = req;\r\n\t// }\r\n\r\n\tconst parsed_url = new URL(req.url, \"http://placeholder.com\");\r\n\tconst cmsUrl = getCmsUrl(parsed_url.host);\r\n\r\n\tif (/\\.[^/]+$/.test(parsed_url.pathname)) {\r\n\t\t// If it's a file request, we append /content.json\r\n\t\tcmsUrl.pathname = parsed_url.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 = parsed_url.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};\r\n\r\n\tif (req.headers.get(\"x-real-ip\")) {\r\n\t\theaders[\"X-Forwarded-For\"] = req.headers.get(\"x-real-ip\") || \"\";\r\n\t}\r\n\tif (req.headers.get(\"x-forwarded-host\")) {\r\n\t\theaders[\"X-Forwarded-For\"] = req.headers.get(\"x-forwarded-host\") || \"\";\r\n\t}\r\n\tif (req.headers.get(\"user-agent\")) {\r\n\t\theaders[\"User-Agent\"] = req.headers.get(\"user-agent\") || \"\";\r\n\t}\r\n\r\n\ttry {\r\n\t\tconst response = await fetch(cmsUrl.toString(), {\r\n\t\t\tmethod: req.method,\r\n\t\t\theaders,\r\n\t\t\tbody: JSON.stringify(data),\r\n\t\t});\r\n\t\tconst result: PageData<CivProps> = await response.json();\r\n\r\n\t\tconst resultWithData = {\r\n\t\t\t...result,\r\n\t\t\theaders: result.headers ?? [],\r\n\t\t\tbody: result.body,\r\n\t\t};\r\n\r\n\t\treturn resultWithData;\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": "AAAA,SAAS,uBAAuB;AAEhC,SAAS,iBAAiB;AAI1B,eAAsB,eACrB,KAC8B;AAC9B,MAAI;AASJ,QAAM,aAAa,IAAI,IAAI,IAAI,KAAK,wBAAwB;AAC5D,QAAM,SAAS,UAAU,WAAW,IAAI;AAExC,MAAI,WAAW,KAAK,WAAW,QAAQ,GAAG;AAEzC,WAAO,WAAW,WAAW,WAAW;AAAA,EACzC,OAAO;AAEN,WAAO,WAAW,WAAW,WAAW;AAAA,EACzC;AAEA,QAAM,UAAkC;AAAA,IACvC,mBAAmB;AAAA,EACpB;AAEA,MAAI,IAAI,QAAQ,IAAI,WAAW,GAAG;AACjC,YAAQ,iBAAiB,IAAI,IAAI,QAAQ,IAAI,WAAW,KAAK;AAAA,EAC9D;AACA,MAAI,IAAI,QAAQ,IAAI,kBAAkB,GAAG;AACxC,YAAQ,iBAAiB,IAAI,IAAI,QAAQ,IAAI,kBAAkB,KAAK;AAAA,EACrE;AACA,MAAI,IAAI,QAAQ,IAAI,YAAY,GAAG;AAClC,YAAQ,YAAY,IAAI,IAAI,QAAQ,IAAI,YAAY,KAAK;AAAA,EAC1D;AAEA,MAAI;AACH,UAAM,WAAW,MAAM,MAAM,OAAO,SAAS,GAAG;AAAA,MAC/C,QAAQ,IAAI;AAAA,MACZ;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,IAC1B,CAAC;AACD,UAAM,SAA6B,MAAM,SAAS,KAAK;AAEvD,UAAM,iBAAiB;AAAA,MACtB,GAAG;AAAA,MACH,SAAS,OAAO,WAAW,CAAC;AAAA,MAC5B,MAAM,OAAO;AAAA,IACd;AAEA,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;",
|
|
4
|
+
"sourcesContent": ["import { IncomingMessage } from \"http\";\r\nimport type { CivProps, PageData } from \"../types\";\r\nimport { getCmsUrl } from \"./getCmsUrl\";\r\n\r\nexport type { PageData };\r\n\r\nexport async function getPageContent(\r\n\treq: Request\r\n): Promise<PageData<CivProps>> {\r\n\tlet data: undefined | IncomingMessage;\r\n\r\n\t// if (req.method === \"POST\") {\r\n\t// \t// if we have a POST req (most likely for Page Editor preview) then\r\n\t// \t// we'll pass the incoming req stream directly on to our outgoing\r\n\t// \t// req to the CMS. We don't do anything with the data here.\r\n\t// \tdata = req;\r\n\t// }\r\n\r\n\tconst parsed_url = new URL(req.url, \"http://placeholder.com\");\r\n\tconst cmsUrl = getCmsUrl(parsed_url.host);\r\n\r\n\tif (/\\.[^/]+$/.test(parsed_url.pathname)) {\r\n\t\t// If it's a file request, we append /content.json\r\n\t\tcmsUrl.pathname = parsed_url.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 = parsed_url.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};\r\n\r\n\tif (req.headers.get(\"x-real-ip\")) {\r\n\t\theaders[\"X-Forwarded-For\"] = req.headers.get(\"x-real-ip\") || \"\";\r\n\t}\r\n\tif (req.headers.get(\"x-forwarded-host\")) {\r\n\t\theaders[\"X-Forwarded-For\"] = req.headers.get(\"x-forwarded-host\") || \"\";\r\n\t}\r\n\tif (req.headers.get(\"user-agent\")) {\r\n\t\theaders[\"User-Agent\"] = req.headers.get(\"user-agent\") || \"\";\r\n\t}\r\n\r\n\ttry {\r\n\t\tconsole.log(\"Making page content request:\", {\r\n\t\t\turl: cmsUrl.toString(),\r\n\t\t\tmethod: req.method,\r\n\t\t\theaders,\r\n\t\t\tbody: data,\r\n\t\t});\r\n\r\n\t\tconst response = await fetch(cmsUrl.toString(), {\r\n\t\t\tmethod: req.method,\r\n\t\t\theaders,\r\n\t\t\tbody: JSON.stringify(data),\r\n\t\t});\r\n\t\tconst result: PageData<CivProps> = await response.json();\r\n\r\n\t\tconst resultWithData = {\r\n\t\t\t...result,\r\n\t\t\theaders: result.headers ?? [],\r\n\t\t\tbody: result.body,\r\n\t\t};\r\n\r\n\t\treturn resultWithData;\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": "AAAA,SAAS,uBAAuB;AAEhC,SAAS,iBAAiB;AAI1B,eAAsB,eACrB,KAC8B;AAC9B,MAAI;AASJ,QAAM,aAAa,IAAI,IAAI,IAAI,KAAK,wBAAwB;AAC5D,QAAM,SAAS,UAAU,WAAW,IAAI;AAExC,MAAI,WAAW,KAAK,WAAW,QAAQ,GAAG;AAEzC,WAAO,WAAW,WAAW,WAAW;AAAA,EACzC,OAAO;AAEN,WAAO,WAAW,WAAW,WAAW;AAAA,EACzC;AAEA,QAAM,UAAkC;AAAA,IACvC,mBAAmB;AAAA,EACpB;AAEA,MAAI,IAAI,QAAQ,IAAI,WAAW,GAAG;AACjC,YAAQ,iBAAiB,IAAI,IAAI,QAAQ,IAAI,WAAW,KAAK;AAAA,EAC9D;AACA,MAAI,IAAI,QAAQ,IAAI,kBAAkB,GAAG;AACxC,YAAQ,iBAAiB,IAAI,IAAI,QAAQ,IAAI,kBAAkB,KAAK;AAAA,EACrE;AACA,MAAI,IAAI,QAAQ,IAAI,YAAY,GAAG;AAClC,YAAQ,YAAY,IAAI,IAAI,QAAQ,IAAI,YAAY,KAAK;AAAA,EAC1D;AAEA,MAAI;AACH,YAAQ,IAAI,gCAAgC;AAAA,MAC3C,KAAK,OAAO,SAAS;AAAA,MACrB,QAAQ,IAAI;AAAA,MACZ;AAAA,MACA,MAAM;AAAA,IACP,CAAC;AAED,UAAM,WAAW,MAAM,MAAM,OAAO,SAAS,GAAG;AAAA,MAC/C,QAAQ,IAAI;AAAA,MACZ;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,IAC1B,CAAC;AACD,UAAM,SAA6B,MAAM,SAAS,KAAK;AAEvD,UAAM,iBAAiB;AAAA,MACtB,GAAG;AAAA,MACH,SAAS,OAAO,WAAW,CAAC;AAAA,MAC5B,MAAM,OAAO;AAAA,IACd;AAEA,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
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleview/cms-foundation",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Provides helper types and components to assist when working with Granicus CMS Reactor.",
|
|
5
5
|
"packageManager": "yarn@4.6.0+sha224.acd0786f07ffc6c933940eb65fc1d627131ddf5455bddcc295dc90fd",
|
|
6
6
|
"scripts": {
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"typescript": "^5.8.3"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"react": "^19.1.1"
|
|
41
|
+
"react": "^19.1.1",
|
|
42
|
+
"react-router": "7.7.0"
|
|
42
43
|
},
|
|
43
44
|
"files": [
|
|
44
45
|
"dist/"
|