@alignable/bifrost 0.0.14 → 0.0.17
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-4DL7N7Y5.js +17 -0
- package/dist/chunk-4DL7N7Y5.js.map +1 -0
- package/dist/chunk-ABW2IXO4.js +936 -0
- package/dist/chunk-ABW2IXO4.js.map +1 -0
- package/dist/chunk-AIK6VRNF.js +20 -0
- package/dist/chunk-AIK6VRNF.js.map +1 -0
- package/dist/chunk-CXNEKD7R.js +9 -0
- package/dist/chunk-CXNEKD7R.js.map +1 -0
- package/dist/chunk-EYYCKU6F.js +11 -0
- package/dist/chunk-EYYCKU6F.js.map +1 -0
- package/dist/chunk-LEUA73GT.js +26 -0
- package/dist/chunk-LEUA73GT.js.map +1 -0
- package/dist/chunk-RQ34EW7E.js +13 -0
- package/dist/chunk-RQ34EW7E.js.map +1 -0
- package/dist/index.d.ts +13 -7
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -0
- package/dist/internal-fe09ebc7.d.ts +72 -0
- package/dist/proxy/pages/+config.d.ts +2 -2
- package/dist/proxy/pages/+config.js +17 -12
- package/dist/proxy/pages/+config.js.map +1 -0
- package/dist/proxy/pages/Page.d.ts +3 -2
- package/dist/proxy/pages/Page.js +7 -3
- package/dist/proxy/pages/Page.js.map +1 -0
- package/dist/proxy/pages/onBeforeRender.d.ts +9 -3
- package/dist/proxy/pages/onBeforeRender.js +9 -5
- package/dist/proxy/pages/onBeforeRender.js.map +1 -0
- package/dist/proxy/pages/onRenderClient.d.ts +9 -3
- package/dist/proxy/pages/onRenderClient.js +59 -51
- package/dist/proxy/pages/onRenderClient.js.map +1 -0
- package/dist/proxy/pages/onRenderHtml.d.ts +11 -4
- package/dist/proxy/pages/onRenderHtml.js +54 -39
- package/dist/proxy/pages/onRenderHtml.js.map +1 -0
- package/dist/proxy/pages/restorationVisit/+config.d.ts +2 -2
- package/dist/proxy/pages/restorationVisit/+config.js +19 -14
- package/dist/proxy/pages/restorationVisit/+config.js.map +1 -0
- package/dist/proxy/pages/restorationVisit/onRenderClient.d.ts +9 -3
- package/dist/proxy/pages/restorationVisit/onRenderClient.js +49 -39
- package/dist/proxy/pages/restorationVisit/onRenderClient.js.map +1 -0
- package/dist/proxy/pages/restorationVisit/route.d.ts +3 -2
- package/dist/proxy/pages/restorationVisit/route.js +7 -3
- package/dist/proxy/pages/restorationVisit/route.js.map +1 -0
- package/dist/renderer/+config.d.ts +2 -5
- package/dist/renderer/+config.js +25 -14
- package/dist/renderer/+config.js.map +1 -0
- package/dist/renderer/_error/Page.d.ts +2 -3
- package/dist/renderer/_error/Page.js +11 -12
- package/dist/renderer/_error/Page.js.map +1 -0
- package/dist/renderer/getConfigOrPageContext.d.ts +9 -4
- package/dist/renderer/getConfigOrPageContext.js +7 -6
- package/dist/renderer/getConfigOrPageContext.js.map +1 -0
- package/dist/renderer/onBeforeRoute.d.ts +3 -2
- package/dist/renderer/onBeforeRoute.js +28 -20
- package/dist/renderer/onBeforeRoute.js.map +1 -0
- package/dist/renderer/onRenderClient.d.ts +9 -3
- package/dist/renderer/onRenderClient.js +53 -38
- package/dist/renderer/onRenderClient.js.map +1 -0
- package/dist/renderer/onRenderHtml.d.ts +19 -5
- package/dist/renderer/onRenderHtml.js +50 -23
- package/dist/renderer/onRenderHtml.js.map +1 -0
- package/dist/renderer/usePageContext.d.ts +7 -4
- package/dist/renderer/usePageContext.js +10 -21
- package/dist/renderer/usePageContext.js.map +1 -0
- package/dist/renderer/utils/buildHead.d.ts +9 -4
- package/dist/renderer/utils/buildHead.js +7 -10
- package/dist/renderer/utils/buildHead.js.map +1 -0
- package/dist/renderer/utils/getGlobalObject.d.ts +3 -2
- package/dist/renderer/utils/getGlobalObject.js +7 -8
- package/dist/renderer/utils/getGlobalObject.js.map +1 -0
- package/package.json +5 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/PageShell.d.ts +0 -7
- package/dist/lib/PageShell.d.ts.map +0 -1
- package/dist/lib/PageShell.js +0 -6
- package/dist/lib/getElementAttributes.d.ts +0 -2
- package/dist/lib/getElementAttributes.d.ts.map +0 -1
- package/dist/lib/getElementAttributes.js +0 -7
- package/dist/lib/renderReact.d.ts +0 -3
- package/dist/lib/renderReact.d.ts.map +0 -1
- package/dist/lib/renderReact.js +0 -14
- package/dist/lib/turbolinks/adapter.d.ts +0 -17
- package/dist/lib/turbolinks/adapter.d.ts.map +0 -1
- package/dist/lib/turbolinks/adapter.js +0 -1
- package/dist/lib/turbolinks/browser_adapter.d.ts +0 -28
- package/dist/lib/turbolinks/browser_adapter.d.ts.map +0 -1
- package/dist/lib/turbolinks/browser_adapter.js +0 -68
- package/dist/lib/turbolinks/controller.d.ts +0 -75
- package/dist/lib/turbolinks/controller.d.ts.map +0 -1
- package/dist/lib/turbolinks/controller.js +0 -219
- package/dist/lib/turbolinks/head_details.d.ts +0 -24
- package/dist/lib/turbolinks/head_details.d.ts.map +0 -1
- package/dist/lib/turbolinks/head_details.js +0 -97
- package/dist/lib/turbolinks/index.d.ts +0 -14
- package/dist/lib/turbolinks/index.d.ts.map +0 -1
- package/dist/lib/turbolinks/index.js +0 -55
- package/dist/lib/turbolinks/location.d.ts +0 -23
- package/dist/lib/turbolinks/location.d.ts.map +0 -1
- package/dist/lib/turbolinks/location.js +0 -75
- package/dist/lib/turbolinks/lruCache.d.ts +0 -8
- package/dist/lib/turbolinks/lruCache.d.ts.map +0 -1
- package/dist/lib/turbolinks/lruCache.js +0 -25
- package/dist/lib/turbolinks/mergeHead.d.ts +0 -2
- package/dist/lib/turbolinks/mergeHead.d.ts.map +0 -1
- package/dist/lib/turbolinks/mergeHead.js +0 -120
- package/dist/lib/turbolinks/progress_bar.d.ts +0 -24
- package/dist/lib/turbolinks/progress_bar.d.ts.map +0 -1
- package/dist/lib/turbolinks/progress_bar.js +0 -99
- package/dist/lib/turbolinks/types.d.ts +0 -7
- package/dist/lib/turbolinks/types.d.ts.map +0 -1
- package/dist/lib/turbolinks/types.js +0 -3
- package/dist/lib/turbolinks/util.d.ts +0 -18
- package/dist/lib/turbolinks/util.d.ts.map +0 -1
- package/dist/lib/turbolinks/util.js +0 -125
- package/dist/lib/turbolinks/visit.d.ts +0 -55
- package/dist/lib/turbolinks/visit.d.ts.map +0 -1
- package/dist/lib/turbolinks/visit.js +0 -163
- package/dist/proxy/pages/+config.d.ts.map +0 -1
- package/dist/proxy/pages/Page.d.ts.map +0 -1
- package/dist/proxy/pages/onBeforeRender.d.ts.map +0 -1
- package/dist/proxy/pages/onRenderClient.d.ts.map +0 -1
- package/dist/proxy/pages/onRenderHtml.d.ts.map +0 -1
- package/dist/proxy/pages/restorationVisit/+config.d.ts.map +0 -1
- package/dist/proxy/pages/restorationVisit/onRenderClient.d.ts.map +0 -1
- package/dist/proxy/pages/restorationVisit/route.d.ts.map +0 -1
- package/dist/renderer/+config.d.ts.map +0 -1
- package/dist/renderer/_error/Page.d.ts.map +0 -1
- package/dist/renderer/getConfigOrPageContext.d.ts.map +0 -1
- package/dist/renderer/onBeforeRoute.d.ts.map +0 -1
- package/dist/renderer/onRenderClient.d.ts.map +0 -1
- package/dist/renderer/onRenderHtml.d.ts.map +0 -1
- package/dist/renderer/usePageContext.d.ts.map +0 -1
- package/dist/renderer/utils/buildHead.d.ts.map +0 -1
- package/dist/renderer/utils/getGlobalObject.d.ts.map +0 -1
- package/dist/types/internal.d.ts +0 -64
- package/dist/types/internal.d.ts.map +0 -1
- package/dist/types/internal.js +0 -1
|
@@ -1,39 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getElementAttributes
|
|
3
|
+
} from "../../chunk-RQ34EW7E.js";
|
|
4
|
+
import {
|
|
5
|
+
PageShell
|
|
6
|
+
} from "../../chunk-4DL7N7Y5.js";
|
|
7
|
+
import "../../chunk-LEUA73GT.js";
|
|
8
|
+
import "../../chunk-EYYCKU6F.js";
|
|
9
|
+
|
|
10
|
+
// proxy/pages/onRenderHtml.tsx
|
|
1
11
|
import React from "react";
|
|
2
12
|
import ReactDOMServer from "react-dom/server";
|
|
3
13
|
import { dangerouslySkipEscape, escapeInject } from "vite-plugin-ssr/server";
|
|
4
|
-
import { PageShell } from "../../lib/PageShell.js";
|
|
5
14
|
import jsdom from "jsdom";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
async function onRenderHtml(pageContext) {
|
|
16
|
+
if (pageContext.proxy) {
|
|
17
|
+
const { proxy, layoutProps, layout } = pageContext;
|
|
18
|
+
const dom = new jsdom.JSDOM(proxy);
|
|
19
|
+
const doc = dom.window.document;
|
|
20
|
+
const bodyEl = doc.querySelector("body");
|
|
21
|
+
const head = doc.querySelector("head");
|
|
22
|
+
if (!bodyEl || !head) {
|
|
23
|
+
throw new Error("Proxy failed");
|
|
24
|
+
}
|
|
25
|
+
const { layoutMap } = pageContext.config;
|
|
26
|
+
if (!layoutMap) {
|
|
27
|
+
throw new Error("layoutMap needs to be defined in config");
|
|
28
|
+
}
|
|
29
|
+
const Layout = layoutMap[layout];
|
|
30
|
+
if (!Layout)
|
|
31
|
+
throw new Error(`${layout} layout not found`);
|
|
32
|
+
const pageHtml = ReactDOMServer.renderToString(
|
|
33
|
+
/* @__PURE__ */ React.createElement(PageShell, { pageContext }, /* @__PURE__ */ React.createElement(Layout, { ...layoutProps }, /* @__PURE__ */ React.createElement(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
id: "proxied-body",
|
|
37
|
+
dangerouslySetInnerHTML: { __html: bodyEl.innerHTML }
|
|
20
38
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const pageHtml = ReactDOMServer.renderToString(React.createElement(PageShell, { pageContext: pageContext },
|
|
25
|
-
React.createElement(Layout, { ...layoutProps },
|
|
26
|
-
React.createElement("div", { id: "proxied-body", dangerouslySetInnerHTML: { __html: bodyEl.innerHTML } }))));
|
|
27
|
-
const documentHtml = escapeInject `
|
|
39
|
+
)))
|
|
40
|
+
);
|
|
41
|
+
const documentHtml = escapeInject`
|
|
28
42
|
<!DOCTYPE html>
|
|
29
43
|
<html>
|
|
30
44
|
<head>
|
|
31
45
|
${dangerouslySkipEscape(head.innerHTML)}
|
|
32
|
-
${
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
dangerouslySkipEscape(`<script>
|
|
46
|
+
${// We need to fire turbolinks:load exactly on DCL, so it must be a blocking head script to catch DCL event.
|
|
47
|
+
// Vite loads scripts with type="module" so the rest of our code will show up too late.
|
|
48
|
+
// TODO: figure out how to bundle this better. at least read from a .js file
|
|
49
|
+
dangerouslySkipEscape(`<script>
|
|
37
50
|
window.Turbolinks = {controller:{restorationIdentifier: ''}};
|
|
38
51
|
addEventListener("DOMContentLoaded", () => {
|
|
39
52
|
const event = new Event("turbolinks:load", { bubbles: true, cancelable: true });
|
|
@@ -42,19 +55,21 @@ export default async function onRenderHtml(pageContext) {
|
|
|
42
55
|
})
|
|
43
56
|
</script>`)}
|
|
44
57
|
</head>
|
|
45
|
-
<body ${dangerouslySkipEscape(
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
<body ${dangerouslySkipEscape(
|
|
59
|
+
Object.entries(getElementAttributes(bodyEl)).map(([name, value]) => `${name}="${value}"`).join(" ")
|
|
60
|
+
)}>
|
|
48
61
|
<div id="page-view">${dangerouslySkipEscape(pageHtml)}</div>
|
|
49
62
|
</body>
|
|
50
63
|
</html>`;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return {};
|
|
59
|
-
}
|
|
64
|
+
return {
|
|
65
|
+
documentHtml,
|
|
66
|
+
pageContext: {}
|
|
67
|
+
};
|
|
68
|
+
} else {
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
60
71
|
}
|
|
72
|
+
export {
|
|
73
|
+
onRenderHtml as default
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=onRenderHtml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../proxy/pages/onRenderHtml.tsx"],"sourcesContent":["import React from \"react\";\nimport ReactDOMServer from \"react-dom/server\";\nimport { dangerouslySkipEscape, escapeInject } from \"vite-plugin-ssr/server\";\nimport { PageContextProxyServer } from \"../../types/internal.js\";\nimport { PageShell } from \"../../lib/PageShell.js\";\nimport jsdom from \"jsdom\";\nimport { getElementAttributes } from \"../../lib/getElementAttributes.js\";\n\nexport default async function onRenderHtml(\n pageContext: PageContextProxyServer\n) {\n if (pageContext.proxy) {\n const { proxy, layoutProps, layout } = pageContext;\n\n const dom = new jsdom.JSDOM(proxy);\n const doc = dom.window.document;\n const bodyEl = doc.querySelector(\"body\");\n const head = doc.querySelector(\"head\");\n if (!bodyEl || !head) {\n throw new Error(\"Proxy failed\");\n }\n\n const { layoutMap } = pageContext.config;\n if (!layoutMap) {\n throw new Error(\"layoutMap needs to be defined in config\");\n }\n const Layout = layoutMap[layout];\n if (!Layout) throw new Error(`${layout} layout not found`);\n const pageHtml = ReactDOMServer.renderToString(\n <PageShell pageContext={pageContext}>\n <Layout {...layoutProps}>\n <div\n id=\"proxied-body\"\n dangerouslySetInnerHTML={{ __html: bodyEl.innerHTML }}\n />\n </Layout>\n </PageShell>\n );\n\n const documentHtml = escapeInject`\n <!DOCTYPE html>\n <html>\n <head>\n ${dangerouslySkipEscape(head.innerHTML)}\n ${\n // We need to fire turbolinks:load exactly on DCL, so it must be a blocking head script to catch DCL event.\n // Vite loads scripts with type=\"module\" so the rest of our code will show up too late.\n // TODO: figure out how to bundle this better. at least read from a .js file\n dangerouslySkipEscape(`<script>\n window.Turbolinks = {controller:{restorationIdentifier: ''}};\n addEventListener(\"DOMContentLoaded\", () => {\n const event = new Event(\"turbolinks:load\", { bubbles: true, cancelable: true });\n event.data = {url: window.location.href};\n document.dispatchEvent(event); \n })\n </script>`)\n }\n </head>\n <body ${dangerouslySkipEscape(\n Object.entries(getElementAttributes(bodyEl))\n .map(([name, value]) => `${name}=\"${value}\"`)\n .join(\" \")\n )}>\n <div id=\"page-view\">${dangerouslySkipEscape(pageHtml)}</div>\n </body>\n </html>`;\n\n return {\n documentHtml,\n pageContext: {},\n };\n } else {\n // do nothing: Just exists to signal fastify server that no routes matched and we should proxy\n return {};\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,OAAO,WAAW;AAClB,OAAO,oBAAoB;AAC3B,SAAS,uBAAuB,oBAAoB;AAGpD,OAAO,WAAW;AAGlB,eAAO,aACL,aACA;AACA,MAAI,YAAY,OAAO;AACrB,UAAM,EAAE,OAAO,aAAa,OAAO,IAAI;AAEvC,UAAM,MAAM,IAAI,MAAM,MAAM,KAAK;AACjC,UAAM,MAAM,IAAI,OAAO;AACvB,UAAM,SAAS,IAAI,cAAc,MAAM;AACvC,UAAM,OAAO,IAAI,cAAc,MAAM;AACrC,QAAI,CAAC,UAAU,CAAC,MAAM;AACpB,YAAM,IAAI,MAAM,cAAc;AAAA,IAChC;AAEA,UAAM,EAAE,UAAU,IAAI,YAAY;AAClC,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,MAAM,yCAAyC;AAAA,IAC3D;AACA,UAAM,SAAS,UAAU,MAAM;AAC/B,QAAI,CAAC;AAAQ,YAAM,IAAI,MAAM,GAAG,MAAM,mBAAmB;AACzD,UAAM,WAAW,eAAe;AAAA,MAC9B,oCAAC,aAAU,eACT,oCAAC,UAAQ,GAAG,eACV;AAAA,QAAC;AAAA;AAAA,UACC,IAAG;AAAA,UACH,yBAAyB,EAAE,QAAQ,OAAO,UAAU;AAAA;AAAA,MACtD,CACF,CACF;AAAA,IACF;AAEA,UAAM,eAAe;AAAA;AAAA;AAAA;AAAA,YAIb,sBAAsB,KAAK,SAAS,CAAC;AAAA;AAAA;AAAA;AAAA,IAKrC,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOd,CACV;AAAA;AAAA,gBAEM;AAAA,MACN,OAAO,QAAQ,qBAAqB,MAAM,CAAC,EACxC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,GAAG,IAAI,KAAK,KAAK,GAAG,EAC3C,KAAK,GAAG;AAAA,IACb,CAAC;AAAA,gCACuB,sBAAsB,QAAQ,CAAC;AAAA;AAAA;AAI3D,WAAO;AAAA,MACL;AAAA,MACA,aAAa,CAAC;AAAA,IAChB;AAAA,EACF,OAAO;AAEL,WAAO,CAAC;AAAA,EACV;AACF;","names":[]}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
1
|
+
// proxy/pages/restorationVisit/+config.ts
|
|
2
|
+
var config_default = {
|
|
3
|
+
route: "import:@alignable/bifrost/proxy/pages/restorationVisit/route",
|
|
4
|
+
Page: "import:@alignable/bifrost/proxy/pages/Page",
|
|
5
|
+
onRenderClient: "import:@alignable/bifrost/proxy/pages/restorationVisit/onRenderClient",
|
|
6
|
+
// See onBeforeRoute for how head and body are inserted from Turbolinks snapshot
|
|
7
|
+
passToClient: ["headEl", "bodyEl", "layout", "layoutProps"],
|
|
8
|
+
meta: {
|
|
9
|
+
onBeforeRender: {
|
|
10
|
+
// We tell vite-plugin-ssr to load and execute onBeforeRender()
|
|
11
|
+
// not only on the server-side but also on the client-side.
|
|
12
|
+
// Moving onBeforeRender to client tells VPS it does not need to make network request on navigation
|
|
13
|
+
env: "server-and-client"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
15
16
|
};
|
|
17
|
+
export {
|
|
18
|
+
config_default as default
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=+config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../proxy/pages/restorationVisit/+config.ts"],"sourcesContent":["import { ConfigNonHeaderFile } from \"vite-plugin-ssr/types\";\n\nexport default {\n route: \"import:@alignable/bifrost/proxy/pages/restorationVisit/route\",\n Page: \"import:@alignable/bifrost/proxy/pages/Page\",\n onRenderClient: \"import:@alignable/bifrost/proxy/pages/restorationVisit/onRenderClient\",\n // See onBeforeRoute for how head and body are inserted from Turbolinks snapshot\n passToClient: [\"headEl\", \"bodyEl\", \"layout\", \"layoutProps\"],\n meta: {\n onBeforeRender: {\n // We tell vite-plugin-ssr to load and execute onBeforeRender()\n // not only on the server-side but also on the client-side.\n // Moving onBeforeRender to client tells VPS it does not need to make network request on navigation\n env: \"server-and-client\",\n },\n },\n} satisfies ConfigNonHeaderFile;\n"],"mappings":";AAEA,IAAO,iBAAQ;AAAA,EACb,OAAO;AAAA,EACP,MAAM;AAAA,EACN,gBAAgB;AAAA;AAAA,EAEhB,cAAc,CAAC,UAAU,UAAU,UAAU,aAAa;AAAA,EAC1D,MAAM;AAAA,IACJ,gBAAgB;AAAA;AAAA;AAAA;AAAA,MAId,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import { PageContextProxyRestorationVisit } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { h as PageContextProxyRestorationVisit } from '../../../internal-fe09ebc7.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'vite-plugin-ssr/types';
|
|
4
|
+
import '../_config.js';
|
|
5
|
+
import '../../../renderer/_config.js';
|
|
6
|
+
|
|
7
|
+
declare function onRenderClient(pageContext: PageContextProxyRestorationVisit): Promise<void>;
|
|
8
|
+
|
|
9
|
+
export { onRenderClient as default };
|
|
@@ -1,41 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getElementAttributes
|
|
3
|
+
} from "../../../chunk-RQ34EW7E.js";
|
|
4
|
+
import {
|
|
5
|
+
Turbolinks,
|
|
6
|
+
copyElementAttributes,
|
|
7
|
+
renderReact
|
|
8
|
+
} from "../../../chunk-ABW2IXO4.js";
|
|
9
|
+
import {
|
|
10
|
+
PageShell
|
|
11
|
+
} from "../../../chunk-4DL7N7Y5.js";
|
|
12
|
+
import "../../../chunk-LEUA73GT.js";
|
|
13
|
+
import "../../../chunk-EYYCKU6F.js";
|
|
14
|
+
|
|
15
|
+
// proxy/pages/restorationVisit/onRenderClient.tsx
|
|
1
16
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// render body with react
|
|
33
|
-
render(proxyBodyEl.innerHTML);
|
|
34
|
-
});
|
|
35
|
-
// cache page context will save it and return it to us during restoration visits
|
|
36
|
-
Turbolinks._vpsCachePageContext({
|
|
37
|
-
layoutProps,
|
|
38
|
-
layout,
|
|
39
|
-
bodyAttrs: getElementAttributes(bodyEl),
|
|
40
|
-
});
|
|
17
|
+
async function onRenderClient(pageContext) {
|
|
18
|
+
if (pageContext.isHydration) {
|
|
19
|
+
throw new Error("restoration visit should never happen on initial render");
|
|
20
|
+
}
|
|
21
|
+
const { layoutProps, layout, bodyEl, headEl } = pageContext;
|
|
22
|
+
const { layoutMap } = pageContext.config;
|
|
23
|
+
if (!layoutMap) {
|
|
24
|
+
throw new Error("layoutMap needs to be defined in config");
|
|
25
|
+
}
|
|
26
|
+
const Layout = layoutMap[layout];
|
|
27
|
+
function render(body) {
|
|
28
|
+
renderReact(
|
|
29
|
+
/* @__PURE__ */ React.createElement(PageShell, { key: pageContext.urlOriginal, pageContext }, /* @__PURE__ */ React.createElement(Layout, { ...layoutProps }, /* @__PURE__ */ React.createElement("div", { id: "proxied-body", dangerouslySetInnerHTML: { __html: body } }))),
|
|
30
|
+
pageContext.isHydration
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const proxyBodyEl = bodyEl.querySelector("#proxied-body");
|
|
34
|
+
if (!proxyBodyEl) {
|
|
35
|
+
throw new Error("proxied body not found in cached snapshot");
|
|
36
|
+
}
|
|
37
|
+
Turbolinks._vpsOnRenderClient(headEl, true, () => {
|
|
38
|
+
document.body.getAttributeNames().forEach((n) => document.body.removeAttribute(n));
|
|
39
|
+
copyElementAttributes(document.body, bodyEl);
|
|
40
|
+
render(proxyBodyEl.innerHTML);
|
|
41
|
+
});
|
|
42
|
+
Turbolinks._vpsCachePageContext({
|
|
43
|
+
layoutProps,
|
|
44
|
+
layout,
|
|
45
|
+
bodyAttrs: getElementAttributes(bodyEl)
|
|
46
|
+
});
|
|
41
47
|
}
|
|
48
|
+
export {
|
|
49
|
+
onRenderClient as default
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=onRenderClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../proxy/pages/restorationVisit/onRenderClient.tsx"],"sourcesContent":["import React from \"react\";\nimport { PageContextProxyRestorationVisit } from \"../../../types/internal.js\";\nimport { PageShell } from \"../../../lib/PageShell.js\";\nimport { renderReact } from \"../../../lib/renderReact.js\";\nimport { Turbolinks } from \"../../../lib/turbolinks/index.js\";\nimport { getElementAttributes } from \"../../../lib/getElementAttributes.js\";\nimport { copyElementAttributes } from \"../../../lib/turbolinks/util.js\";\n\nexport default async function onRenderClient(\n pageContext: PageContextProxyRestorationVisit\n) {\n if (pageContext.isHydration) {\n throw new Error(\"restoration visit should never happen on initial render\");\n }\n\n const { layoutProps, layout, bodyEl, headEl } = pageContext;\n const { layoutMap } = pageContext.config;\n if (!layoutMap) {\n throw new Error(\"layoutMap needs to be defined in config\");\n }\n const Layout = layoutMap[layout];\n\n function render(body: string) {\n renderReact(\n <PageShell key={pageContext.urlOriginal} pageContext={pageContext}>\n <Layout {...layoutProps}>\n <div id=\"proxied-body\" dangerouslySetInnerHTML={{ __html: body }} />\n </Layout>\n </PageShell>,\n pageContext.isHydration\n );\n }\n const proxyBodyEl = bodyEl.querySelector(\"#proxied-body\");\n if (!proxyBodyEl) {\n throw new Error(\"proxied body not found in cached snapshot\");\n }\n\n Turbolinks._vpsOnRenderClient(headEl, true, () => {\n // merge body attributes\n document.body\n .getAttributeNames()\n .forEach((n) => document.body.removeAttribute(n));\n copyElementAttributes(document.body, bodyEl);\n // render body with react\n render(proxyBodyEl.innerHTML);\n });\n // cache page context will save it and return it to us during restoration visits\n Turbolinks._vpsCachePageContext({\n layoutProps,\n layout,\n bodyAttrs: getElementAttributes(bodyEl),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAQlB,eAAO,eACL,aACA;AACA,MAAI,YAAY,aAAa;AAC3B,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AAEA,QAAM,EAAE,aAAa,QAAQ,QAAQ,OAAO,IAAI;AAChD,QAAM,EAAE,UAAU,IAAI,YAAY;AAClC,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC3D;AACA,QAAM,SAAS,UAAU,MAAM;AAE/B,WAAS,OAAO,MAAc;AAC5B;AAAA,MACE,oCAAC,aAAU,KAAK,YAAY,aAAa,eACvC,oCAAC,UAAQ,GAAG,eACV,oCAAC,SAAI,IAAG,gBAAe,yBAAyB,EAAE,QAAQ,KAAK,GAAG,CACpE,CACF;AAAA,MACA,YAAY;AAAA,IACd;AAAA,EACF;AACA,QAAM,cAAc,OAAO,cAAc,eAAe;AACxD,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI,MAAM,2CAA2C;AAAA,EAC7D;AAEA,aAAW,mBAAmB,QAAQ,MAAM,MAAM;AAEhD,aAAS,KACN,kBAAkB,EAClB,QAAQ,CAAC,MAAM,SAAS,KAAK,gBAAgB,CAAC,CAAC;AAClD,0BAAsB,SAAS,MAAM,MAAM;AAE3C,WAAO,YAAY,SAAS;AAAA,EAC9B,CAAC;AAED,aAAW,qBAAqB;AAAA,IAC9B;AAAA,IACA;AAAA,IACA,WAAW,qBAAqB,MAAM;AAAA,EACxC,CAAC;AACH;","names":[]}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare function route(): boolean;
|
|
2
|
+
|
|
3
|
+
export { route as default };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// proxy/pages/restorationVisit/route.ts
|
|
2
|
+
function route() {
|
|
3
|
+
return false;
|
|
4
4
|
}
|
|
5
|
+
export {
|
|
6
|
+
route as default
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../proxy/pages/restorationVisit/route.ts"],"sourcesContent":["// never matches - see onBeforeRoute for how this route only triggers on restoration visit.\nexport default function route() {\n return false;\n}\n"],"mappings":";AACe,SAAR,QAAyB;AAC9B,SAAO;AACT;","names":[]}
|
|
@@ -15,13 +15,10 @@ declare const _default: {
|
|
|
15
15
|
documentProps: {
|
|
16
16
|
env: "server-and-client";
|
|
17
17
|
};
|
|
18
|
-
isLoggedIn: {
|
|
19
|
-
env: "server-and-client";
|
|
20
|
-
};
|
|
21
18
|
scripts: {
|
|
22
19
|
env: "server-and-client";
|
|
23
20
|
};
|
|
24
21
|
};
|
|
25
22
|
};
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
|
|
24
|
+
export { _default as default };
|
package/dist/renderer/+config.js
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
// renderer/+config.ts
|
|
2
|
+
var passToClient = [
|
|
3
|
+
"layoutProps",
|
|
4
|
+
"pageProps",
|
|
5
|
+
"redirectTo",
|
|
6
|
+
"documentProps",
|
|
7
|
+
"scripts"
|
|
8
|
+
];
|
|
9
|
+
var config_default = {
|
|
10
|
+
passToClient,
|
|
11
|
+
onRenderClient: "import:@alignable/bifrost/renderer/onRenderClient",
|
|
12
|
+
onRenderHtml: "import:@alignable/bifrost/renderer/onRenderHtml",
|
|
13
|
+
onBeforeRoute: "import:@alignable/bifrost/renderer/onBeforeRoute",
|
|
14
|
+
clientRouting: true,
|
|
15
|
+
hydrationCanBeAborted: true,
|
|
16
|
+
meta: {
|
|
17
|
+
Layout: { env: "server-and-client" },
|
|
18
|
+
layoutProps: { env: "server-and-client" },
|
|
19
|
+
documentProps: { env: "server-and-client" },
|
|
20
|
+
scripts: { env: "server-and-client" }
|
|
21
|
+
}
|
|
15
22
|
};
|
|
23
|
+
export {
|
|
24
|
+
config_default as default
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=+config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../renderer/+config.ts"],"sourcesContent":["import { type ConfigNonHeaderFile } from \"vite-plugin-ssr/types\";\n\nconst passToClient = [\n \"layoutProps\",\n \"pageProps\",\n \"redirectTo\",\n \"documentProps\",\n \"scripts\",\n];\nexport default {\n passToClient,\n onRenderClient: \"import:@alignable/bifrost/renderer/onRenderClient\",\n onRenderHtml: \"import:@alignable/bifrost/renderer/onRenderHtml\",\n onBeforeRoute: \"import:@alignable/bifrost/renderer/onBeforeRoute\",\n clientRouting: true,\n hydrationCanBeAborted: true,\n meta: {\n Layout: { env: \"server-and-client\" },\n layoutProps: { env: \"server-and-client\" },\n documentProps: { env: \"server-and-client\" },\n scripts: { env: \"server-and-client\" },\n },\n} satisfies ConfigNonHeaderFile;\n"],"mappings":";AAEA,IAAM,eAAe;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,IAAO,iBAAQ;AAAA,EACb;AAAA,EACA,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,MAAM;AAAA,IACJ,QAAQ,EAAE,KAAK,oBAAoB;AAAA,IACnC,aAAa,EAAE,KAAK,oBAAoB;AAAA,IACxC,eAAe,EAAE,KAAK,oBAAoB;AAAA,IAC1C,SAAS,EAAE,KAAK,oBAAoB;AAAA,EACtC;AACF;","names":[]}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
// renderer/_error/Page.tsx
|
|
2
2
|
import React from "react";
|
|
3
|
+
var Page_default = Page;
|
|
3
4
|
function Page({ is404, errorInfo }) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
return (React.createElement(React.Fragment, null,
|
|
12
|
-
React.createElement("h1", null, "500 Internal Server Error"),
|
|
13
|
-
React.createElement("p", null, "Something went wrong.")));
|
|
14
|
-
}
|
|
5
|
+
if (is404) {
|
|
6
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h1", null, "404 Page Not Found"), /* @__PURE__ */ React.createElement("p", null, "This page could not be found."), /* @__PURE__ */ React.createElement("p", null, errorInfo));
|
|
7
|
+
} else {
|
|
8
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h1", null, "500 Internal Server Error"), /* @__PURE__ */ React.createElement("p", null, "Something went wrong."));
|
|
9
|
+
}
|
|
15
10
|
}
|
|
11
|
+
export {
|
|
12
|
+
Page_default as default
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=Page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../renderer/_error/Page.tsx"],"sourcesContent":["export default Page;\n\nimport React from \"react\";\n\nfunction Page({ is404, errorInfo }: { is404: boolean; errorInfo?: string }) {\n if (is404) {\n return (\n <>\n <h1>404 Page Not Found</h1>\n <p>This page could not be found.</p>\n <p>{errorInfo}</p>\n </>\n );\n } else {\n return (\n <>\n <h1>500 Internal Server Error</h1>\n <p>Something went wrong.</p>\n </>\n );\n }\n}\n"],"mappings":";AAEA,OAAO,WAAW;AAFlB,IAAO,eAAQ;AAIf,SAAS,KAAK,EAAE,OAAO,UAAU,GAA2C;AAC1E,MAAI,OAAO;AACT,WACE,0DACE,oCAAC,YAAG,oBAAkB,GACtB,oCAAC,WAAE,+BAA6B,GAChC,oCAAC,WAAG,SAAU,CAChB;AAAA,EAEJ,OAAO;AACL,WACE,0DACE,oCAAC,YAAG,2BAAyB,GAC7B,oCAAC,WAAE,uBAAqB,CAC1B;AAAA,EAEJ;AACF;","names":[]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { PageContextNoProxy } from
|
|
1
|
+
import { P as PageContextNoProxy } from '../internal-fe09ebc7.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'vite-plugin-ssr/types';
|
|
4
|
+
import '../proxy/pages/_config.js';
|
|
5
|
+
import './_config.js';
|
|
6
|
+
|
|
2
7
|
type ConfigOrContext = PageContextNoProxy | PageContextNoProxy["config"];
|
|
3
8
|
/**
|
|
4
9
|
* Get page configs that are definable in config and in runtime via onBeforeRoute. documentProps, for example.
|
|
5
10
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
declare function getPageContextOrConfig<T extends keyof ConfigOrContext>(pageContext: PageContextNoProxy, prop: T): ConfigOrContext[T];
|
|
12
|
+
|
|
13
|
+
export { getPageContextOrConfig };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
getPageContextOrConfig
|
|
3
|
+
} from "../chunk-CXNEKD7R.js";
|
|
4
|
+
export {
|
|
5
|
+
getPageContextOrConfig
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=getConfigOrPageContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
// renderer/onBeforeRoute.ts
|
|
2
|
+
function onBeforeRoute(_pageContext) {
|
|
3
|
+
if (typeof window === "undefined")
|
|
4
|
+
return void 0;
|
|
5
|
+
const Turbolinks = window.Turbolinks;
|
|
6
|
+
const currentVisit = Turbolinks.controller.currentVisit;
|
|
7
|
+
if (!currentVisit || currentVisit.state === "completed") {
|
|
8
|
+
const snapshot = Turbolinks.controller.getCachedSnapshotForLocation(
|
|
9
|
+
window.location.href
|
|
10
|
+
);
|
|
11
|
+
Turbolinks.controller.historyPoppedToLocationWithRestorationIdentifier(
|
|
12
|
+
window.location.href,
|
|
13
|
+
""
|
|
14
|
+
);
|
|
15
|
+
if (!!snapshot) {
|
|
16
|
+
return {
|
|
17
|
+
pageContext: {
|
|
18
|
+
...snapshot.pageContext,
|
|
19
|
+
bodyEl: snapshot.bodyEl,
|
|
20
|
+
headEl: snapshot.headEl,
|
|
21
|
+
_pageId: "/proxy/pages/restorationVisit"
|
|
20
22
|
}
|
|
23
|
+
};
|
|
21
24
|
}
|
|
22
|
-
|
|
25
|
+
}
|
|
26
|
+
return void 0;
|
|
23
27
|
}
|
|
28
|
+
export {
|
|
29
|
+
onBeforeRoute as default
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=onBeforeRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../renderer/onBeforeRoute.ts"],"sourcesContent":["// do NOT import turbolinks in this file. It is used on server side.\n\nexport default function onBeforeRoute(_pageContext: any) {\n if (typeof window === \"undefined\") return undefined;\n const Turbolinks = window.Turbolinks;\n\n const currentVisit = Turbolinks.controller.currentVisit;\n if (!currentVisit || currentVisit.state === \"completed\") {\n // old/nonexistent currentVisit means VPS is doing history navigation. Ideally we might turn off VPS' onpopstate listener.\n const snapshot = Turbolinks.controller.getCachedSnapshotForLocation(\n window.location.href\n );\n Turbolinks.controller.historyPoppedToLocationWithRestorationIdentifier(\n window.location.href,\n \"\"\n );\n\n if (!!snapshot) {\n return {\n pageContext: {\n ...snapshot.pageContext,\n bodyEl: snapshot.bodyEl,\n headEl: snapshot.headEl,\n _pageId: \"/proxy/pages/restorationVisit\",\n },\n };\n }\n }\n return undefined;\n}\n"],"mappings":";AAEe,SAAR,cAA+B,cAAmB;AACvD,MAAI,OAAO,WAAW;AAAa,WAAO;AAC1C,QAAM,aAAa,OAAO;AAE1B,QAAM,eAAe,WAAW,WAAW;AAC3C,MAAI,CAAC,gBAAgB,aAAa,UAAU,aAAa;AAEvD,UAAM,WAAW,WAAW,WAAW;AAAA,MACrC,OAAO,SAAS;AAAA,IAClB;AACA,eAAW,WAAW;AAAA,MACpB,OAAO,SAAS;AAAA,MAChB;AAAA,IACF;AAEA,QAAI,CAAC,CAAC,UAAU;AACd,aAAO;AAAA,QACL,aAAa;AAAA,UACX,GAAG,SAAS;AAAA,UACZ,QAAQ,SAAS;AAAA,UACjB,QAAQ,SAAS;AAAA,UACjB,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import { PageContextNoProxyClient } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { d as PageContextNoProxyClient } from '../internal-fe09ebc7.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'vite-plugin-ssr/types';
|
|
4
|
+
import '../proxy/pages/_config.js';
|
|
5
|
+
import './_config.js';
|
|
6
|
+
|
|
7
|
+
declare function onRenderClient(pageContext: PageContextNoProxyClient): Promise<void>;
|
|
8
|
+
|
|
9
|
+
export { onRenderClient as default };
|