@simpleview/cms-foundation 0.0.18 → 0.0.20

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.
Files changed (90) hide show
  1. package/dist/chunk-4BZHC5AC.js +37 -0
  2. package/dist/chunk-4BZHC5AC.js.map +7 -0
  3. package/dist/chunk-4LSFAAZW.js +1 -0
  4. package/dist/chunk-4LSFAAZW.js.map +7 -0
  5. package/dist/chunk-5WRI5ZAA.js +31 -0
  6. package/dist/chunk-5WRI5ZAA.js.map +7 -0
  7. package/dist/chunk-CMALSZV3.js +1 -0
  8. package/dist/chunk-CMALSZV3.js.map +7 -0
  9. package/dist/chunk-DG37VYL5.js +1 -0
  10. package/dist/chunk-DG37VYL5.js.map +7 -0
  11. package/dist/chunk-EE5DCIH7.js +2451 -0
  12. package/dist/chunk-EE5DCIH7.js.map +7 -0
  13. package/dist/chunk-EEKFLXZI.js +11 -0
  14. package/dist/chunk-EEKFLXZI.js.map +7 -0
  15. package/dist/chunk-EG5F4AP4.js +1 -0
  16. package/dist/chunk-EG5F4AP4.js.map +7 -0
  17. package/dist/chunk-EWRVCIV6.js +1 -0
  18. package/dist/chunk-EWRVCIV6.js.map +7 -0
  19. package/dist/chunk-F5L7DWHD.js +1 -0
  20. package/dist/chunk-F5L7DWHD.js.map +7 -0
  21. package/dist/chunk-FJML4RHB.js +59 -0
  22. package/dist/chunk-FJML4RHB.js.map +7 -0
  23. package/dist/chunk-GPTPACV2.js +33 -0
  24. package/dist/chunk-GPTPACV2.js.map +7 -0
  25. package/dist/chunk-MNT3ZFUU.js +14 -0
  26. package/dist/chunk-MNT3ZFUU.js.map +7 -0
  27. package/dist/chunk-NX7QUAFC.js +82 -0
  28. package/dist/chunk-NX7QUAFC.js.map +7 -0
  29. package/dist/chunk-OEYLOZQK.js +31 -0
  30. package/dist/chunk-OEYLOZQK.js.map +7 -0
  31. package/dist/chunk-P3WX4DFS.js +93 -0
  32. package/dist/chunk-P3WX4DFS.js.map +7 -0
  33. package/dist/chunk-VV3NKXSX.js +17 -0
  34. package/dist/chunk-VV3NKXSX.js.map +7 -0
  35. package/dist/chunk-XG5CMDEI.js +1 -0
  36. package/dist/chunk-XG5CMDEI.js.map +7 -0
  37. package/dist/chunk-ZQUGFKHP.js +1 -0
  38. package/dist/chunk-ZQUGFKHP.js.map +7 -0
  39. package/dist/components/App/App.js +5 -5
  40. package/dist/components/App/App.js.map +3 -3
  41. package/dist/components/App/index.js +9 -1
  42. package/dist/components/App/index.js.map +3 -3
  43. package/dist/components/Error/Error.js +4 -11
  44. package/dist/components/Error/Error.js.map +3 -3
  45. package/dist/components/Error/Error.types.js +1 -0
  46. package/dist/components/Error/index.js +9 -2
  47. package/dist/components/Error/index.js.map +3 -3
  48. package/dist/components/Layout/Layout.js +5 -25
  49. package/dist/components/Layout/Layout.js.map +3 -3
  50. package/dist/components/Layout/index.js +9 -1
  51. package/dist/components/Layout/index.js.map +3 -3
  52. package/dist/components/Preview/PreviewCivWrapper.js +4 -25
  53. package/dist/components/Preview/PreviewCivWrapper.js.map +3 -3
  54. package/dist/components/Preview/PreviewContent.js +19 -10
  55. package/dist/components/Preview/PreviewContent.js.map +3 -3
  56. package/dist/components/Preview/PreviewPageWrapper.js +4 -85
  57. package/dist/components/Preview/PreviewPageWrapper.js.map +3 -3
  58. package/dist/components/Preview/index.js +30 -3
  59. package/dist/components/Preview/index.js.map +3 -3
  60. package/dist/components/Section/Section.js +19 -8
  61. package/dist/components/Section/Section.js.map +3 -3
  62. package/dist/components/Section/Section.types.js +1 -0
  63. package/dist/components/Section/SectionItem.js +19 -11
  64. package/dist/components/Section/SectionItem.js.map +3 -3
  65. package/dist/components/Section/SectionItemCiv.js +19 -20
  66. package/dist/components/Section/SectionItemCiv.js.map +3 -3
  67. package/dist/components/Section/index.js +26 -4
  68. package/dist/components/Section/index.js.map +3 -3
  69. package/dist/components/Unknown/Unknown.js +6 -28
  70. package/dist/components/Unknown/Unknown.js.map +3 -3
  71. package/dist/components/Unknown/index.js +10 -1
  72. package/dist/components/Unknown/index.js.map +3 -3
  73. package/dist/components/index.js +48 -6
  74. package/dist/components/index.js.map +3 -3
  75. package/dist/contexts/ComponentMapContext.js +20 -9
  76. package/dist/contexts/ComponentMapContext.js.map +3 -3
  77. package/dist/contexts/index.js +24 -1
  78. package/dist/contexts/index.js.map +3 -3
  79. package/dist/routes/index.js +7134 -3
  80. package/dist/routes/index.js.map +4 -4
  81. package/dist/types/cms.js +1 -0
  82. package/dist/types/index.js +2 -1
  83. package/dist/types/index.js.map +3 -3
  84. package/dist/utils/getCmsUrl.js +4 -5
  85. package/dist/utils/getCmsUrl.js.map +3 -3
  86. package/dist/utils/getPageContent.js +5 -50
  87. package/dist/utils/getPageContent.js.map +3 -3
  88. package/dist/utils/index.js +11 -2
  89. package/dist/utils/index.js.map +3 -3
  90. package/package.json +1 -1
package/dist/types/cms.js CHANGED
@@ -1 +1,2 @@
1
+ import "../chunk-ZQUGFKHP.js";
1
2
  //# sourceMappingURL=cms.js.map
@@ -1,2 +1,3 @@
1
- export * from "./cms.js";
1
+ import "../chunk-4LSFAAZW.js";
2
+ import "../chunk-ZQUGFKHP.js";
2
3
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/types/index.ts"],
4
- "sourcesContent": ["export * from \"./cms.js\";\r\n"],
5
- "mappings": "AAAA,cAAc;",
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
6
  "names": []
7
7
  }
@@ -1,8 +1,7 @@
1
- const { CMS_DOMAIN } = process.env;
2
- function getCmsUrl(host) {
3
- const siteClient = host.split(".")[0];
4
- return new URL(`https://${siteClient}.${CMS_DOMAIN}`);
5
- }
1
+ import {
2
+ getCmsUrl
3
+ } from "../chunk-EEKFLXZI.js";
4
+ import "../chunk-5WRI5ZAA.js";
6
5
  export {
7
6
  getCmsUrl
8
7
  };
@@ -1,7 +1,7 @@
1
1
  {
2
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,MAAM,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;",
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
6
  "names": []
7
7
  }
@@ -1,53 +1,8 @@
1
- import { getCmsUrl } from "./getCmsUrl.js";
2
- const previewPath = "/includes/plugins/nav/preview_civs/";
3
- async function getPageContent(req) {
4
- const incomingUrl = new URL(req.url, "http://placeholder.com");
5
- const cmsUrl = getCmsUrl(incomingUrl.host);
6
- if (!incomingUrl.pathname.endsWith("/") || /\.[^/]+$/.test(incomingUrl.pathname)) {
7
- cmsUrl.pathname = incomingUrl.pathname + "/content.json";
8
- } else {
9
- cmsUrl.pathname = incomingUrl.pathname + "content.json";
10
- }
11
- const headers = {
12
- "Accept-Encoding": "gzip",
13
- "X-Forwarded-For": req.headers.get("x-real-ip") || req.headers.get("x-forwarded-host") || "",
14
- "User-Agent": req.headers.get("user-agent") || ""
15
- };
16
- try {
17
- let body = void 0;
18
- if (req.method === "POST" && incomingUrl.pathname === previewPath) {
19
- incomingUrl.searchParams.forEach((val, key) => {
20
- cmsUrl.searchParams.set(key, val);
21
- });
22
- const formData = await req.formData();
23
- const civs = formData.get("headless_civs");
24
- if (typeof civs !== "string") {
25
- throw new Error(
26
- "Posted CIVs were not a base64 encoded string."
27
- );
28
- }
29
- const data = JSON.parse(atob(civs));
30
- return data;
31
- }
32
- const url = cmsUrl.toString();
33
- const { method } = req;
34
- const fetchParams = {
35
- method,
36
- headers,
37
- body
38
- };
39
- console.log("Making page content request:", {
40
- url,
41
- ...fetchParams
42
- });
43
- const result = await fetch(url, fetchParams).then((res) => res.json());
44
- return result;
45
- } catch (err) {
46
- const status = err?.response?.status || 500;
47
- const message = err?.response?.statusText || "Server Error";
48
- throw new Error(`Status ${status}: ${message}`);
49
- }
50
- }
1
+ import {
2
+ getPageContent
3
+ } from "../chunk-FJML4RHB.js";
4
+ import "../chunk-EEKFLXZI.js";
5
+ import "../chunk-5WRI5ZAA.js";
51
6
  export {
52
7
  getPageContent
53
8
  };
@@ -1,7 +1,7 @@
1
1
  {
2
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": "AACA,SAAS,iBAAiB;AAI1B,MAAM,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,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appings": "",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,12 @@
1
- export * from "./getCmsUrl.js";
2
- export * from "./getPageContent.js";
1
+ import {
2
+ getPageContent
3
+ } from "../chunk-FJML4RHB.js";
4
+ import {
5
+ getCmsUrl
6
+ } from "../chunk-EEKFLXZI.js";
7
+ import "../chunk-5WRI5ZAA.js";
8
+ export {
9
+ getCmsUrl,
10
+ getPageContent
11
+ };
3
12
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/index.ts"],
4
- "sourcesContent": ["export * from \"./getCmsUrl.js\";\r\nexport * from \"./getPageContent.js\";\r\n"],
5
- "mappings": "AAAA,cAAc;AACd,cAAc;",
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simpleview/cms-foundation",
3
3
  "type": "module",
4
- "version": "0.0.18",
4
+ "version": "0.0.20",
5
5
  "description": "Provides helper types and components to assist when working with Granicus CMS Reactor.",
6
6
  "packageManager": "yarn@4.6.0+sha224.acd0786f07ffc6c933940eb65fc1d627131ddf5455bddcc295dc90fd",
7
7
  "scripts": {