@alignable/bifrost 0.0.33 → 0.0.34
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/index.d.ts +3 -3
- package/dist/{internal-1d9cac7c.d.ts → internal-23a16e8b.d.ts} +1 -1
- package/dist/proxy/pages/passthru/+config.d.ts +8 -0
- package/dist/proxy/pages/passthru/+config.js +12 -0
- package/dist/proxy/pages/passthru/+config.js.map +1 -0
- package/dist/proxy/pages/passthru/onRenderClient.d.ts +3 -0
- package/dist/proxy/pages/passthru/onRenderClient.js +8 -0
- package/dist/proxy/pages/passthru/onRenderClient.js.map +1 -0
- package/dist/proxy/pages/passthru/onRenderHtml.d.ts +12 -0
- package/dist/proxy/pages/passthru/onRenderHtml.js +10 -0
- package/dist/proxy/pages/passthru/onRenderHtml.js.map +1 -0
- package/dist/proxy/pages/{+config.d.ts → wrapped/+config.d.ts} +3 -3
- package/dist/proxy/pages/{+config.js → wrapped/+config.js} +4 -4
- package/dist/proxy/pages/wrapped/+config.js.map +1 -0
- package/dist/proxy/pages/{onBeforeRender.d.ts → wrapped/onBeforeRender.d.ts} +3 -3
- package/dist/proxy/pages/{onBeforeRender.js → wrapped/onBeforeRender.js} +1 -1
- package/dist/proxy/pages/wrapped/onBeforeRender.js.map +1 -0
- package/dist/proxy/pages/{onRenderClient.d.ts → wrapped/onRenderClient.d.ts} +3 -3
- package/dist/proxy/pages/{onRenderClient.js → wrapped/onRenderClient.js} +7 -7
- package/dist/proxy/pages/wrapped/onRenderClient.js.map +1 -0
- package/dist/proxy/pages/{onRenderHtml.d.ts → wrapped/onRenderHtml.d.ts} +3 -3
- package/dist/proxy/pages/{onRenderHtml.js → wrapped/onRenderHtml.js} +5 -5
- package/dist/proxy/pages/wrapped/onRenderHtml.js.map +1 -0
- package/dist/proxy/pages/wrapped/restorationVisit/+config.d.ts +19 -0
- package/dist/proxy/pages/wrapped/restorationVisit/+config.js +18 -0
- package/dist/proxy/pages/wrapped/restorationVisit/+config.js.map +1 -0
- package/dist/proxy/pages/{restorationVisit → wrapped/restorationVisit}/onRenderClient.d.ts +3 -3
- package/dist/proxy/pages/{restorationVisit → wrapped/restorationVisit}/onRenderClient.js +6 -6
- package/dist/proxy/pages/wrapped/restorationVisit/onRenderClient.js.map +1 -0
- package/dist/proxy/pages/wrapped/restorationVisit/route.js +8 -0
- package/dist/proxy/pages/wrapped/restorationVisit/route.js.map +1 -0
- package/dist/renderer/getConfigOrPageContext.d.ts +2 -2
- package/dist/renderer/onBeforeRoute.js +1 -1
- package/dist/renderer/onBeforeRoute.js.map +1 -1
- package/dist/renderer/onRenderClient.d.ts +2 -2
- package/dist/renderer/onRenderClient.js +3 -3
- package/dist/renderer/onRenderHtml.d.ts +2 -2
- package/dist/renderer/onRenderHtml.js +3 -3
- package/dist/renderer/usePageContext.d.ts +2 -2
- package/dist/renderer/utils/buildHead.d.ts +2 -2
- package/package.json +37 -25
- package/dist/proxy/pages/+config.js.map +0 -1
- package/dist/proxy/pages/onBeforeRender.js.map +0 -1
- package/dist/proxy/pages/onRenderClient.js.map +0 -1
- package/dist/proxy/pages/onRenderHtml.js.map +0 -1
- package/dist/proxy/pages/restorationVisit/+config.d.ts +0 -11
- package/dist/proxy/pages/restorationVisit/+config.js +0 -14
- package/dist/proxy/pages/restorationVisit/+config.js.map +0 -1
- package/dist/proxy/pages/restorationVisit/onRenderClient.js.map +0 -1
- package/dist/proxy/pages/restorationVisit/route.js +0 -8
- package/dist/proxy/pages/restorationVisit/route.js.map +0 -1
- /package/dist/proxy/pages/{restorationVisit → wrapped/restorationVisit}/route.d.ts +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { Config, GuardAsync, GuardSync, Meta, OnBeforePrerenderStartAsync, OnBeforePrerenderStartSync, OnBeforeRenderAsync, OnBeforeRenderSync, OnBeforeRouteAsync, OnBeforeRouteSync, OnHydrationEndAsync, OnHydrationEndSync, OnPageTransitionEndAsync, OnPageTransitionEndSync, OnPageTransitionStartAsync, OnPageTransitionStartSync, OnPrerenderStartAsync, OnPrerenderStartSync, OnRenderClientAsync, OnRenderClientSync, OnRenderHtmlAsync, OnRenderHtmlSync, RouteAsync, RouteSync } from 'vike/types';
|
|
2
2
|
import { navigate as navigate$1 } from 'vike/client/router';
|
|
3
|
-
import { A as ApplicationFacingPageContext, a as AugmentMe } from './internal-
|
|
4
|
-
export { N as BifrostConfig, P as BifrostProxyConfig, D as DocumentProps, b as LayoutComponent, L as LayoutMap, c as PageContext } from './internal-
|
|
3
|
+
import { A as ApplicationFacingPageContext, a as AugmentMe } from './internal-23a16e8b.js';
|
|
4
|
+
export { N as BifrostConfig, P as BifrostProxyConfig, D as DocumentProps, b as LayoutComponent, L as LayoutMap, c as PageContext } from './internal-23a16e8b.js';
|
|
5
5
|
export { PageContextProvider, usePageContext } from './renderer/usePageContext.js';
|
|
6
6
|
import 'react';
|
|
7
|
-
import './proxy/pages/_config.js';
|
|
7
|
+
import './proxy/pages/wrapped/_config.js';
|
|
8
8
|
import './renderer/_config.js';
|
|
9
9
|
import './controller-16e58bbd.js';
|
|
10
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { Config, PageContextBuiltInServer, PageContextBuiltInClientWithClientRouting } from 'vike/types';
|
|
3
|
-
import _default from './proxy/pages/_config.js';
|
|
3
|
+
import _default from './proxy/pages/wrapped/_config.js';
|
|
4
4
|
import _default$1 from './renderer/_config.js';
|
|
5
5
|
import { S as Snapshot } from './controller-16e58bbd.js';
|
|
6
6
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// proxy/pages/passthru/+config.ts
|
|
2
|
+
var config_default = {
|
|
3
|
+
route: "/*",
|
|
4
|
+
// Fake page:
|
|
5
|
+
Page: "import:@alignable/bifrost/proxy/pages/Page",
|
|
6
|
+
onRenderHtml: "import:@alignable/bifrost/proxy/pages/passthru/onRenderHtml",
|
|
7
|
+
onRenderClient: "import:@alignable/bifrost/proxy/pages/passthru/onRenderClient"
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
config_default as default
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=+config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../proxy/pages/passthru/+config.ts"],"sourcesContent":["import { Config } from \"vike/types\";\n\nexport default {\n route: \"/*\",\n // Fake page:\n Page: \"import:@alignable/bifrost/proxy/pages/Page\",\n onRenderHtml: \"import:@alignable/bifrost/proxy/pages/passthru/onRenderHtml\",\n onRenderClient:\n \"import:@alignable/bifrost/proxy/pages/passthru/onRenderClient\",\n} satisfies Config;\n"],"mappings":";AAEA,IAAO,iBAAQ;AAAA,EACb,OAAO;AAAA;AAAA,EAEP,MAAM;AAAA,EACN,cAAc;AAAA,EACd,gBACE;AACJ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../proxy/pages/passthru/onRenderClient.tsx"],"sourcesContent":["export default async function onRenderClient() {\n // Passthru pages are unhandled by bifrost, reload to grab legacy content from server\n window.location.reload();\n}\n"],"mappings":";AAAA,eAAO,iBAAwC;AAE7C,SAAO,SAAS,OAAO;AACzB;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { f as PageContextNoProxyServer } from '../../../internal-23a16e8b.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'vike/types';
|
|
4
|
+
import '../wrapped/_config.js';
|
|
5
|
+
import '../../../renderer/_config.js';
|
|
6
|
+
import '../../../controller-16e58bbd.js';
|
|
7
|
+
|
|
8
|
+
declare function onRenderHtml(pageContext: PageContextNoProxyServer): Promise<{
|
|
9
|
+
pageContext: {};
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
export { onRenderHtml as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../proxy/pages/passthru/onRenderHtml.tsx"],"sourcesContent":["import { PageContextNoProxyServer } from \"../../../types/internal.js\";\n\nexport default async function onRenderHtml(\n pageContext: PageContextNoProxyServer\n) {\n return {\n pageContext: {},\n };\n}\n"],"mappings":";AAEA,eAAO,aACL,aACA;AACA,SAAO;AAAA,IACL,aAAa,CAAC;AAAA,EAChB;AACF;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
route: string;
|
|
3
|
-
onBeforeRender: "import:@alignable/bifrost/proxy/pages/onBeforeRender";
|
|
4
|
-
onRenderClient: "import:@alignable/bifrost/proxy/pages/onRenderClient";
|
|
5
|
-
onRenderHtml: "import:@alignable/bifrost/proxy/pages/onRenderHtml";
|
|
3
|
+
onBeforeRender: "import:@alignable/bifrost/proxy/pages/wrapped/onBeforeRender";
|
|
4
|
+
onRenderClient: "import:@alignable/bifrost/proxy/pages/wrapped/onRenderClient";
|
|
5
|
+
onRenderHtml: "import:@alignable/bifrost/proxy/pages/wrapped/onRenderHtml";
|
|
6
6
|
Page: string;
|
|
7
7
|
passToClient: string[];
|
|
8
8
|
clientRouting: true;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// proxy/pages/+config.ts
|
|
1
|
+
// proxy/pages/wrapped/+config.ts
|
|
2
2
|
var config_default = {
|
|
3
3
|
route: "/*",
|
|
4
|
-
onBeforeRender: "import:@alignable/bifrost/proxy/pages/onBeforeRender",
|
|
5
|
-
onRenderClient: "import:@alignable/bifrost/proxy/pages/onRenderClient",
|
|
6
|
-
onRenderHtml: "import:@alignable/bifrost/proxy/pages/onRenderHtml",
|
|
4
|
+
onBeforeRender: "import:@alignable/bifrost/proxy/pages/wrapped/onBeforeRender",
|
|
5
|
+
onRenderClient: "import:@alignable/bifrost/proxy/pages/wrapped/onRenderClient",
|
|
6
|
+
onRenderHtml: "import:@alignable/bifrost/proxy/pages/wrapped/onRenderHtml",
|
|
7
7
|
Page: "import:@alignable/bifrost/proxy/pages/Page",
|
|
8
8
|
passToClient: ["proxySendClient", "layout", "layoutProps", "redirectTo"],
|
|
9
9
|
clientRouting: true,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../proxy/pages/wrapped/+config.ts"],"sourcesContent":["import { type Config } from \"vike/types\";\n\nexport default {\n route: \"/*\",\n onBeforeRender:\n \"import:@alignable/bifrost/proxy/pages/wrapped/onBeforeRender\",\n onRenderClient:\n \"import:@alignable/bifrost/proxy/pages/wrapped/onRenderClient\",\n onRenderHtml: \"import:@alignable/bifrost/proxy/pages/wrapped/onRenderHtml\",\n Page: \"import:@alignable/bifrost/proxy/pages/Page\",\n passToClient: [\"proxySendClient\", \"layout\", \"layoutProps\", \"redirectTo\"],\n clientRouting: true,\n hydrationCanBeAborted: true,\n meta: {\n layoutMap: { env: \"server-and-client\" },\n onClientInit: { env: \"client-only\" },\n },\n} satisfies Config;\n"],"mappings":";AAEA,IAAO,iBAAQ;AAAA,EACb,OAAO;AAAA,EACP,gBACE;AAAA,EACF,gBACE;AAAA,EACF,cAAc;AAAA,EACd,MAAM;AAAA,EACN,cAAc,CAAC,mBAAmB,UAAU,eAAe,YAAY;AAAA,EACvE,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,MAAM;AAAA,IACJ,WAAW,EAAE,KAAK,oBAAoB;AAAA,IACtC,cAAc,EAAE,KAAK,cAAc;AAAA,EACrC;AACF;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { g as PageContextProxyInit, a as AugmentMe } from '
|
|
1
|
+
import { g as PageContextProxyInit, a as AugmentMe } from '../../../internal-23a16e8b.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'vike/types';
|
|
4
4
|
import './_config.js';
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
5
|
+
import '../../../renderer/_config.js';
|
|
6
|
+
import '../../../controller-16e58bbd.js';
|
|
7
7
|
|
|
8
8
|
declare function onBeforeRender(pageContext: PageContextProxyInit): Promise<{
|
|
9
9
|
pageContext: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../proxy/pages/wrapped/onBeforeRender.tsx"],"sourcesContent":["import { PageContextProxyInit } from \"../../../types/internal\";\n\nexport default async function onBeforeRender(\n pageContext: PageContextProxyInit\n) {\n if (pageContext.fromProxy) {\n const { fromProxy } = pageContext;\n if (pageContext.isClientSideNavigation) {\n return {\n pageContext: {\n layout: fromProxy.layout,\n layoutProps: fromProxy.layoutProps,\n // proxySendClient is serialized and sent to client on subsequent navigation.\n // Important that we dont send it on ssr\n proxySendClient: fromProxy.html,\n },\n };\n } else {\n return {\n pageContext: {\n layout: fromProxy.layout,\n layoutProps: fromProxy.layoutProps,\n // proxy is ONLY included server-side to avoid doubling page size\n proxy: fromProxy.html,\n },\n };\n }\n }\n}\n"],"mappings":";AAEA,eAAO,eACL,aACA;AACA,MAAI,YAAY,WAAW;AACzB,UAAM,EAAE,UAAU,IAAI;AACtB,QAAI,YAAY,wBAAwB;AACtC,aAAO;AAAA,QACL,aAAa;AAAA,UACX,QAAQ,UAAU;AAAA,UAClB,aAAa,UAAU;AAAA;AAAA;AAAA,UAGvB,iBAAiB,UAAU;AAAA,QAC7B;AAAA,MACF;AAAA,IACF,OAAO;AACL,aAAO;AAAA,QACL,aAAa;AAAA,UACX,QAAQ,UAAU;AAAA,UAClB,aAAa,UAAU;AAAA;AAAA,UAEvB,OAAO,UAAU;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { h as PageContextProxyClient } from '
|
|
1
|
+
import { h as PageContextProxyClient } from '../../../internal-23a16e8b.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'vike/types';
|
|
4
4
|
import './_config.js';
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
5
|
+
import '../../../renderer/_config.js';
|
|
6
|
+
import '../../../controller-16e58bbd.js';
|
|
7
7
|
|
|
8
8
|
declare function onRenderClient(pageContext: PageContextProxyClient): Promise<void>;
|
|
9
9
|
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getElementAttributes
|
|
3
|
-
} from "
|
|
3
|
+
} from "../../../chunk-RQ34EW7E.js";
|
|
4
4
|
import {
|
|
5
5
|
runClientInit
|
|
6
|
-
} from "
|
|
6
|
+
} from "../../../chunk-HZZHKVWB.js";
|
|
7
7
|
import {
|
|
8
8
|
Turbolinks,
|
|
9
9
|
copyElementAttributes,
|
|
10
10
|
renderReact
|
|
11
|
-
} from "
|
|
11
|
+
} from "../../../chunk-LCW7IDQV.js";
|
|
12
12
|
import {
|
|
13
13
|
PageShell
|
|
14
|
-
} from "
|
|
15
|
-
import "
|
|
16
|
-
import "
|
|
14
|
+
} from "../../../chunk-6QZLCT3X.js";
|
|
15
|
+
import "../../../chunk-IYGONC4I.js";
|
|
16
|
+
import "../../../chunk-EYYCKU6F.js";
|
|
17
17
|
|
|
18
|
-
// proxy/pages/onRenderClient.tsx
|
|
18
|
+
// proxy/pages/wrapped/onRenderClient.tsx
|
|
19
19
|
import React from "react";
|
|
20
20
|
Turbolinks.start();
|
|
21
21
|
var PassthruLayout = ({ children }) => /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../proxy/pages/wrapped/onRenderClient.tsx"],"sourcesContent":["import React from \"react\";\nimport { renderReact } from \"../../../lib/renderReact.js\";\nimport { PageShell } from \"../../../lib/PageShell.js\";\nimport { PageContextProxyClient } from \"../../../types/internal.js\";\nimport { Turbolinks } from \"../../../lib/turbolinks/index.js\";\nimport { copyElementAttributes } from \"../../../lib/turbolinks/util.js\";\nimport { getElementAttributes } from \"../../../lib/getElementAttributes.js\";\nimport { LayoutComponent } from \"../../../types/internal.js\";\nimport { runClientInit } from \"../../../lib/runClientInit.js\";\n\nTurbolinks.start();\n\nconst PassthruLayout: LayoutComponent = ({ children }) => <>{children}</>;\n\nexport default async function onRenderClient(\n pageContext: PageContextProxyClient\n) {\n if (pageContext.redirectTo) {\n Turbolinks.visit(pageContext.redirectTo);\n return;\n }\n const { layoutProps, layout } = pageContext;\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] || PassthruLayout;\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 let bodyEl: Element;\n\n function cachePageContext() {\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\n if (pageContext.isHydration) {\n // During hydration of initial ssr, body is in dom, not page props (to avoid double-send)\n await runClientInit(pageContext.configEntries);\n bodyEl = document.getElementById(\"proxied-body\")!;\n render(bodyEl.innerHTML);\n cachePageContext();\n } else {\n const { proxySendClient: proxy } = pageContext;\n\n if (!proxy) {\n console.error(\"proxy/+onRenderClient did not receive proxySendClient\");\n return;\n }\n\n const parsed = document.createElement(\"html\");\n parsed.innerHTML = proxy;\n bodyEl = parsed.querySelector(\"body\")!;\n const headEl = parsed.querySelector(\"head\")!;\n\n Turbolinks._vpsOnRenderClient(headEl, true, 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(bodyEl.innerHTML);\n cachePageContext();\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAUlB,WAAW,MAAM;AAEjB,IAAM,iBAAkC,CAAC,EAAE,SAAS,MAAM,0DAAG,QAAS;AAEtE,eAAO,eACL,aACA;AACA,MAAI,YAAY,YAAY;AAC1B,eAAW,MAAM,YAAY,UAAU;AACvC;AAAA,EACF;AACA,QAAM,EAAE,aAAa,OAAO,IAAI;AAEhC,QAAM,EAAE,UAAU,IAAI,YAAY;AAClC,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC3D;AACA,QAAM,SAAS,UAAU,MAAM,KAAK;AAEpC,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,MAAI;AAEJ,WAAS,mBAAmB;AAE1B,eAAW,qBAAqB;AAAA,MAC9B;AAAA,MACA;AAAA,MACA,WAAW,qBAAqB,MAAM;AAAA,IACxC,CAAC;AAAA,EACH;AAEA,MAAI,YAAY,aAAa;AAE3B,UAAM,cAAc,YAAY,aAAa;AAC7C,aAAS,SAAS,eAAe,cAAc;AAC/C,WAAO,OAAO,SAAS;AACvB,qBAAiB;AAAA,EACnB,OAAO;AACL,UAAM,EAAE,iBAAiB,MAAM,IAAI;AAEnC,QAAI,CAAC,OAAO;AACV,cAAQ,MAAM,uDAAuD;AACrE;AAAA,IACF;AAEA,UAAM,SAAS,SAAS,cAAc,MAAM;AAC5C,WAAO,YAAY;AACnB,aAAS,OAAO,cAAc,MAAM;AACpC,UAAM,SAAS,OAAO,cAAc,MAAM;AAE1C,eAAW,mBAAmB,QAAQ,MAAM,MAAM,MAAM;AAEtD,eAAS,KACN,kBAAkB,EAClB,QAAQ,CAAC,MAAM,SAAS,KAAK,gBAAgB,CAAC,CAAC;AAClD,4BAAsB,SAAS,MAAM,MAAM;AAE3C,aAAO,OAAO,SAAS;AACvB,uBAAiB;AAAA,IACnB,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as vike_dist_esm_node_runtime_html_renderHtml_js from 'vike/dist/esm/node/runtime/html/renderHtml.js';
|
|
2
|
-
import { i as PageContextProxyServer } from '
|
|
2
|
+
import { i as PageContextProxyServer } from '../../../internal-23a16e8b.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'vike/types';
|
|
5
5
|
import './_config.js';
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
6
|
+
import '../../../renderer/_config.js';
|
|
7
|
+
import '../../../controller-16e58bbd.js';
|
|
8
8
|
|
|
9
9
|
declare function onRenderHtml(pageContext: PageContextProxyServer): Promise<{
|
|
10
10
|
documentHtml: string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getElementAttributes
|
|
3
|
-
} from "
|
|
3
|
+
} from "../../../chunk-RQ34EW7E.js";
|
|
4
4
|
import {
|
|
5
5
|
PageShell
|
|
6
|
-
} from "
|
|
7
|
-
import "
|
|
8
|
-
import "
|
|
6
|
+
} from "../../../chunk-6QZLCT3X.js";
|
|
7
|
+
import "../../../chunk-IYGONC4I.js";
|
|
8
|
+
import "../../../chunk-EYYCKU6F.js";
|
|
9
9
|
|
|
10
|
-
// proxy/pages/onRenderHtml.tsx
|
|
10
|
+
// proxy/pages/wrapped/onRenderHtml.tsx
|
|
11
11
|
import React from "react";
|
|
12
12
|
import ReactDOMServer from "react-dom/server";
|
|
13
13
|
import { dangerouslySkipEscape, escapeInject } from "vike/server";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../proxy/pages/wrapped/onRenderHtml.tsx"],"sourcesContent":["import React from \"react\";\nimport ReactDOMServer from \"react-dom/server\";\nimport { dangerouslySkipEscape, escapeInject } from \"vike/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 { 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) {\n // passthru\n return { documentHtml: proxy, pageContext: {} };\n }\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 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,EAAE,UAAU,IAAI,YAAY;AAClC,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,MAAM,yCAAyC;AAAA,IAC3D;AACA,UAAM,SAAS,UAAU,MAAM;AAC/B,QAAI,CAAC,QAAQ;AAEX,aAAO,EAAE,cAAc,OAAO,aAAa,CAAC,EAAE;AAAA,IAChD;AAEA,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,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":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
route: string;
|
|
3
|
+
Page: string;
|
|
4
|
+
onBeforeRender: null;
|
|
5
|
+
onRenderClient: "import:@alignable/bifrost/proxy/pages/wrapped/restorationVisit/onRenderClient";
|
|
6
|
+
passToClient: never[];
|
|
7
|
+
clientRouting: true;
|
|
8
|
+
hydrationCanBeAborted: true;
|
|
9
|
+
meta: {
|
|
10
|
+
layoutMap: {
|
|
11
|
+
env: "server-and-client";
|
|
12
|
+
};
|
|
13
|
+
onClientInit: {
|
|
14
|
+
env: "client-only";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { _default as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// proxy/pages/wrapped/restorationVisit/+config.ts
|
|
2
|
+
var config_default = {
|
|
3
|
+
route: "import:@alignable/bifrost/proxy/pages/wrapped/restorationVisit/route",
|
|
4
|
+
Page: "import:@alignable/bifrost/proxy/pages/Page",
|
|
5
|
+
onBeforeRender: null,
|
|
6
|
+
onRenderClient: "import:@alignable/bifrost/proxy/pages/wrapped/restorationVisit/onRenderClient",
|
|
7
|
+
passToClient: [],
|
|
8
|
+
clientRouting: true,
|
|
9
|
+
hydrationCanBeAborted: true,
|
|
10
|
+
meta: {
|
|
11
|
+
layoutMap: { env: "server-and-client" },
|
|
12
|
+
onClientInit: { env: "client-only" }
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
config_default as default
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=+config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../proxy/pages/wrapped/restorationVisit/+config.ts"],"sourcesContent":["import { Config } from \"vike/types\";\n\nexport default {\n route: \"import:@alignable/bifrost/proxy/pages/wrapped/restorationVisit/route\",\n Page: \"import:@alignable/bifrost/proxy/pages/Page\",\n onBeforeRender: null,\n onRenderClient:\n \"import:@alignable/bifrost/proxy/pages/wrapped/restorationVisit/onRenderClient\",\n passToClient: [],\n clientRouting: true,\n hydrationCanBeAborted: true,\n meta: {\n layoutMap: { env: \"server-and-client\" },\n onClientInit: { env: \"client-only\" },\n },\n} satisfies Config;\n"],"mappings":";AAEA,IAAO,iBAAQ;AAAA,EACb,OAAO;AAAA,EACP,MAAM;AAAA,EACN,gBAAgB;AAAA,EAChB,gBACE;AAAA,EACF,cAAc,CAAC;AAAA,EACf,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,MAAM;AAAA,IACJ,WAAW,EAAE,KAAK,oBAAoB;AAAA,IACtC,cAAc,EAAE,KAAK,cAAc;AAAA,EACrC;AACF;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { j as PageContextProxyRestorationVisit } from '
|
|
1
|
+
import { j as PageContextProxyRestorationVisit } from '../../../../internal-23a16e8b.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'vike/types';
|
|
4
4
|
import '../_config.js';
|
|
5
|
-
import '
|
|
6
|
-
import '
|
|
5
|
+
import '../../../../renderer/_config.js';
|
|
6
|
+
import '../../../../controller-16e58bbd.js';
|
|
7
7
|
|
|
8
8
|
declare function onRenderClient(pageContext: PageContextProxyRestorationVisit): Promise<void>;
|
|
9
9
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getElementAttributes
|
|
3
|
-
} from "
|
|
3
|
+
} from "../../../../chunk-RQ34EW7E.js";
|
|
4
4
|
import {
|
|
5
5
|
Turbolinks,
|
|
6
6
|
copyElementAttributes,
|
|
7
7
|
renderReact
|
|
8
|
-
} from "
|
|
8
|
+
} from "../../../../chunk-LCW7IDQV.js";
|
|
9
9
|
import {
|
|
10
10
|
PageShell
|
|
11
|
-
} from "
|
|
12
|
-
import "
|
|
13
|
-
import "
|
|
11
|
+
} from "../../../../chunk-6QZLCT3X.js";
|
|
12
|
+
import "../../../../chunk-IYGONC4I.js";
|
|
13
|
+
import "../../../../chunk-EYYCKU6F.js";
|
|
14
14
|
|
|
15
|
-
// proxy/pages/restorationVisit/onRenderClient.tsx
|
|
15
|
+
// proxy/pages/wrapped/restorationVisit/onRenderClient.tsx
|
|
16
16
|
import React from "react";
|
|
17
17
|
var PassthruLayout = ({ children }) => /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
18
18
|
async function onRenderClient(pageContext) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../proxy/pages/wrapped/restorationVisit/onRenderClient.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n LayoutComponent,\n PageContextProxyRestorationVisit,\n} 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\nconst PassthruLayout: LayoutComponent = ({ children }) => <>{children}</>;\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 } = pageContext.snapshot.pageContext;\n const { bodyEl, headEl } = pageContext.snapshot;\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] || PassthruLayout;\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, 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 // 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}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAWlB,IAAM,iBAAkC,CAAC,EAAE,SAAS,MAAM,0DAAG,QAAS;AAEtE,eAAO,eACL,aACA;AACA,MAAI,YAAY,aAAa;AAC3B,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AAEA,QAAM,EAAE,aAAa,OAAO,IAAI,YAAY,SAAS;AACrD,QAAM,EAAE,QAAQ,OAAO,IAAI,YAAY;AACvC,QAAM,EAAE,UAAU,IAAI,YAAY;AAClC,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC3D;AACA,QAAM,SAAS,UAAU,MAAM,KAAK;AAEpC,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,MAAM;AAEtD,aAAS,KACN,kBAAkB,EAClB,QAAQ,CAAC,MAAM,SAAS,KAAK,gBAAgB,CAAC,CAAC;AAClD,0BAAsB,SAAS,MAAM,MAAM;AAE3C,WAAO,YAAY,SAAS;AAE5B,eAAW,qBAAqB;AAAA,MAC9B;AAAA,MACA;AAAA,MACA,WAAW,qBAAqB,MAAM;AAAA,IACxC,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../proxy/pages/wrapped/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":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { d as PageContextNoProxy } from '../internal-
|
|
1
|
+
import { d as PageContextNoProxy } from '../internal-23a16e8b.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'vike/types';
|
|
4
|
-
import '../proxy/pages/_config.js';
|
|
4
|
+
import '../proxy/pages/wrapped/_config.js';
|
|
5
5
|
import './_config.js';
|
|
6
6
|
import '../controller-16e58bbd.js';
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../renderer/onBeforeRoute.ts"],"sourcesContent":["// do NOT import turbolinks in this file. It is used on server side.\n\nconst onBeforeRoute = () => {\n if (typeof window !== \"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,\n // isBackwardNavigation: true,\n _pageId: \"/proxy/pages/restorationVisit\",\n },\n };\n } else {\n return {\n pageContext: { isBackwardNavigation: true },\n };\n }\n }\n }\n return { pageContext: {} };\n};\n\nexport default onBeforeRoute;\n"],"mappings":";AAEA,IAAM,gBAAgB,MAAM;AAC1B,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,aAAa,OAAO;AAE1B,UAAM,eAAe,WAAW,WAAW;AAC3C,QAAI,CAAC,gBAAgB,aAAa,UAAU,aAAa;AAEvD,YAAM,WAAW,WAAW,WAAW;AAAA,QACrC,OAAO,SAAS;AAAA,MAClB;AACA,iBAAW,WAAW;AAAA,QACpB,OAAO,SAAS;AAAA,QAChB;AAAA,MACF;AAEA,UAAI,CAAC,CAAC,UAAU;AACd,eAAO;AAAA,UACL,aAAa;AAAA,YACX;AAAA;AAAA,YAEA,SAAS;AAAA,UACX;AAAA,QACF;AAAA,MACF,OAAO;AACL,eAAO;AAAA,UACL,aAAa,EAAE,sBAAsB,KAAK;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO,EAAE,aAAa,CAAC,EAAE;AAC3B;AAEA,IAAO,wBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../renderer/onBeforeRoute.ts"],"sourcesContent":["// do NOT import turbolinks in this file. It is used on server side.\n\nconst onBeforeRoute = () => {\n if (typeof window !== \"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,\n // isBackwardNavigation: true,\n _pageId: \"/proxy/pages/wrapped/restorationVisit\",\n },\n };\n } else {\n return {\n pageContext: { isBackwardNavigation: true },\n };\n }\n }\n }\n return { pageContext: {} };\n};\n\nexport default onBeforeRoute;\n"],"mappings":";AAEA,IAAM,gBAAgB,MAAM;AAC1B,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,aAAa,OAAO;AAE1B,UAAM,eAAe,WAAW,WAAW;AAC3C,QAAI,CAAC,gBAAgB,aAAa,UAAU,aAAa;AAEvD,YAAM,WAAW,WAAW,WAAW;AAAA,QACrC,OAAO,SAAS;AAAA,MAClB;AACA,iBAAW,WAAW;AAAA,QACpB,OAAO,SAAS;AAAA,QAChB;AAAA,MACF;AAEA,UAAI,CAAC,CAAC,UAAU;AACd,eAAO;AAAA,UACL,aAAa;AAAA,YACX;AAAA;AAAA,YAEA,SAAS;AAAA,UACX;AAAA,QACF;AAAA,MACF,OAAO;AACL,eAAO;AAAA,UACL,aAAa,EAAE,sBAAsB,KAAK;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO,EAAE,aAAa,CAAC,EAAE;AAC3B;AAEA,IAAO,wBAAQ;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { e as PageContextNoProxyClient } from '../internal-
|
|
1
|
+
import { e as PageContextNoProxyClient } from '../internal-23a16e8b.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'vike/types';
|
|
4
|
-
import '../proxy/pages/_config.js';
|
|
4
|
+
import '../proxy/pages/wrapped/_config.js';
|
|
5
5
|
import './_config.js';
|
|
6
6
|
import '../controller-16e58bbd.js';
|
|
7
7
|
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
Turbolinks,
|
|
6
6
|
renderReact
|
|
7
7
|
} from "../chunk-LCW7IDQV.js";
|
|
8
|
-
import {
|
|
9
|
-
documentPropsToReact
|
|
10
|
-
} from "../chunk-VYXAWOXV.js";
|
|
11
8
|
import {
|
|
12
9
|
PageShell
|
|
13
10
|
} from "../chunk-6QZLCT3X.js";
|
|
11
|
+
import {
|
|
12
|
+
documentPropsToReact
|
|
13
|
+
} from "../chunk-VYXAWOXV.js";
|
|
14
14
|
import {
|
|
15
15
|
getPageContextOrConfig
|
|
16
16
|
} from "../chunk-CXNEKD7R.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as vike_dist_esm_node_runtime_html_renderHtml_js from 'vike/dist/esm/node/runtime/html/renderHtml.js';
|
|
2
|
-
import { f as PageContextNoProxyServer } from '../internal-
|
|
2
|
+
import { f as PageContextNoProxyServer } from '../internal-23a16e8b.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'vike/types';
|
|
5
|
-
import '../proxy/pages/_config.js';
|
|
5
|
+
import '../proxy/pages/wrapped/_config.js';
|
|
6
6
|
import './_config.js';
|
|
7
7
|
import '../controller-16e58bbd.js';
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { c as PageContext } from '../internal-
|
|
2
|
+
import { c as PageContext } from '../internal-23a16e8b.js';
|
|
3
3
|
import 'vike/types';
|
|
4
|
-
import '../proxy/pages/_config.js';
|
|
4
|
+
import '../proxy/pages/wrapped/_config.js';
|
|
5
5
|
import './_config.js';
|
|
6
6
|
import '../controller-16e58bbd.js';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { D as DocumentProps } from '../../internal-
|
|
2
|
+
import { D as DocumentProps } from '../../internal-23a16e8b.js';
|
|
3
3
|
import 'vike/types';
|
|
4
|
-
import '../../proxy/pages/_config.js';
|
|
4
|
+
import '../../proxy/pages/wrapped/_config.js';
|
|
5
5
|
import '../_config.js';
|
|
6
6
|
import '../../controller-16e58bbd.js';
|
|
7
7
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alignable/bifrost",
|
|
3
3
|
"repository": "https://github.com/Alignable/bifrost.git",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.34",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -21,37 +21,49 @@
|
|
|
21
21
|
"types": "./dist/renderer/onBeforeRoute.d.ts",
|
|
22
22
|
"default": "./dist/renderer/onBeforeRoute.js"
|
|
23
23
|
},
|
|
24
|
-
"./proxy/pages/+config": {
|
|
25
|
-
"types": "./dist/proxy/pages/+config.d.ts",
|
|
26
|
-
"default": "./dist/proxy/pages/+config.js"
|
|
27
|
-
},
|
|
28
|
-
"./proxy/pages/onRenderClient": {
|
|
29
|
-
"types": "./dist/proxy/pages/onRenderClient.d.ts",
|
|
30
|
-
"default": "./dist/proxy/pages/onRenderClient.js"
|
|
31
|
-
},
|
|
32
|
-
"./proxy/pages/onRenderHtml": {
|
|
33
|
-
"types": "./dist/proxy/pages/onRenderHtml.d.ts",
|
|
34
|
-
"default": "./dist/proxy/pages/onRenderHtml.js"
|
|
35
|
-
},
|
|
36
24
|
"./proxy/pages/Page": {
|
|
37
25
|
"types": "./dist/proxy/pages/Page.d.ts",
|
|
38
26
|
"default": "./dist/proxy/pages/Page.js"
|
|
39
27
|
},
|
|
40
|
-
"./proxy/pages/
|
|
41
|
-
"types": "./dist/proxy/pages/
|
|
42
|
-
"default": "./dist/proxy/pages/
|
|
28
|
+
"./proxy/pages/wrapped/+config": {
|
|
29
|
+
"types": "./dist/proxy/pages/wrapped/+config.d.ts",
|
|
30
|
+
"default": "./dist/proxy/pages/wrapped/+config.js"
|
|
31
|
+
},
|
|
32
|
+
"./proxy/pages/wrapped/onRenderClient": {
|
|
33
|
+
"types": "./dist/proxy/pages/wrapped/onRenderClient.d.ts",
|
|
34
|
+
"default": "./dist/proxy/pages/wrapped/onRenderClient.js"
|
|
35
|
+
},
|
|
36
|
+
"./proxy/pages/wrapped/onRenderHtml": {
|
|
37
|
+
"types": "./dist/proxy/pages/wrapped/onRenderHtml.d.ts",
|
|
38
|
+
"default": "./dist/proxy/pages/wrapped/onRenderHtml.js"
|
|
39
|
+
},
|
|
40
|
+
"./proxy/pages/wrapped/onBeforeRender": {
|
|
41
|
+
"types": "./dist/proxy/pages/wrapped/onBeforeRender.d.ts",
|
|
42
|
+
"default": "./dist/proxy/pages/wrapped/onBeforeRender.js"
|
|
43
|
+
},
|
|
44
|
+
"./proxy/pages/wrapped/restorationVisit/+config": {
|
|
45
|
+
"types": "./dist/proxy/pages/wrapped/restorationVisit/+config.d.ts",
|
|
46
|
+
"default": "./dist/proxy/pages/wrapped/restorationVisit/+config.js"
|
|
47
|
+
},
|
|
48
|
+
"./proxy/pages/wrapped/restorationVisit/route": {
|
|
49
|
+
"types": "./dist/proxy/pages/wrapped/restorationVisit/route.d.ts",
|
|
50
|
+
"default": "./dist/proxy/pages/wrapped/restorationVisit/route.js"
|
|
51
|
+
},
|
|
52
|
+
"./proxy/pages/wrapped/restorationVisit/onRenderClient": {
|
|
53
|
+
"types": "./dist/proxy/pages/wrapped/restorationVisit/onRenderClient.d.ts",
|
|
54
|
+
"default": "./dist/proxy/pages/wrapped/restorationVisit/onRenderClient.js"
|
|
43
55
|
},
|
|
44
|
-
"./proxy/pages/
|
|
45
|
-
"types": "./dist/proxy/pages/
|
|
46
|
-
"default": "./dist/proxy/pages/
|
|
56
|
+
"./proxy/pages/passthru/+config": {
|
|
57
|
+
"types": "./dist/proxy/pages/passthru/+config.d.ts",
|
|
58
|
+
"default": "./dist/proxy/pages/passthru/+config.js"
|
|
47
59
|
},
|
|
48
|
-
"./proxy/pages/
|
|
49
|
-
"types": "./dist/proxy/pages/
|
|
50
|
-
"default": "./dist/proxy/pages/
|
|
60
|
+
"./proxy/pages/passthru/onRenderHtml": {
|
|
61
|
+
"types": "./dist/proxy/pages/passthru/onRenderHtml.d.ts",
|
|
62
|
+
"default": "./dist/proxy/pages/passthru/onRenderHtml.js"
|
|
51
63
|
},
|
|
52
|
-
"./proxy/pages/
|
|
53
|
-
"types": "./dist/proxy/pages/
|
|
54
|
-
"default": "./dist/proxy/pages/
|
|
64
|
+
"./proxy/pages/passthru/onRenderClient": {
|
|
65
|
+
"types": "./dist/proxy/pages/passthru/onRenderClient.d.ts",
|
|
66
|
+
"default": "./dist/proxy/pages/passthru/onRenderClient.js"
|
|
55
67
|
},
|
|
56
68
|
".": {
|
|
57
69
|
"types": "./dist/index.d.ts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../proxy/pages/+config.ts"],"sourcesContent":["import { type Config } from \"vike/types\";\n\nexport default {\n route: \"/*\",\n onBeforeRender: \"import:@alignable/bifrost/proxy/pages/onBeforeRender\",\n onRenderClient: \"import:@alignable/bifrost/proxy/pages/onRenderClient\",\n onRenderHtml: \"import:@alignable/bifrost/proxy/pages/onRenderHtml\",\n Page: \"import:@alignable/bifrost/proxy/pages/Page\",\n passToClient: [\"proxySendClient\", \"layout\", \"layoutProps\", \"redirectTo\"],\n clientRouting: true,\n hydrationCanBeAborted: true,\n meta: {\n layoutMap: { env: \"server-and-client\" },\n onClientInit: { env: \"client-only\" },\n },\n} satisfies Config;\n"],"mappings":";AAEA,IAAO,iBAAQ;AAAA,EACb,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,MAAM;AAAA,EACN,cAAc,CAAC,mBAAmB,UAAU,eAAe,YAAY;AAAA,EACvE,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,MAAM;AAAA,IACJ,WAAW,EAAE,KAAK,oBAAoB;AAAA,IACtC,cAAc,EAAE,KAAK,cAAc;AAAA,EACrC;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../proxy/pages/onBeforeRender.tsx"],"sourcesContent":["import { PageContextProxyInit } from \"../../types/internal\";\n\nexport default async function onBeforeRender(\n pageContext: PageContextProxyInit\n) {\n if (pageContext.fromProxy) {\n const { fromProxy } = pageContext;\n if (pageContext.isClientSideNavigation) {\n return {\n pageContext: {\n layout: fromProxy.layout,\n layoutProps: fromProxy.layoutProps,\n // proxySendClient is serialized and sent to client on subsequent navigation.\n // Important that we dont send it on ssr\n proxySendClient: fromProxy.html,\n },\n };\n } else {\n return {\n pageContext: {\n layout: fromProxy.layout,\n layoutProps: fromProxy.layoutProps,\n // proxy is ONLY included server-side to avoid doubling page size\n proxy: fromProxy.html,\n },\n };\n }\n }\n}\n"],"mappings":";AAEA,eAAO,eACL,aACA;AACA,MAAI,YAAY,WAAW;AACzB,UAAM,EAAE,UAAU,IAAI;AACtB,QAAI,YAAY,wBAAwB;AACtC,aAAO;AAAA,QACL,aAAa;AAAA,UACX,QAAQ,UAAU;AAAA,UAClB,aAAa,UAAU;AAAA;AAAA;AAAA,UAGvB,iBAAiB,UAAU;AAAA,QAC7B;AAAA,MACF;AAAA,IACF,OAAO;AACL,aAAO;AAAA,QACL,aAAa;AAAA,UACX,QAAQ,UAAU;AAAA,UAClB,aAAa,UAAU;AAAA;AAAA,UAEvB,OAAO,UAAU;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../proxy/pages/onRenderClient.tsx"],"sourcesContent":["import React from \"react\";\nimport { renderReact } from \"../../lib/renderReact.js\";\nimport { PageShell } from \"../../lib/PageShell.js\";\nimport { PageContextProxyClient } from \"../../types/internal.js\";\nimport { Turbolinks } from \"../../lib/turbolinks/index.js\";\nimport { copyElementAttributes } from \"../../lib/turbolinks/util.js\";\nimport { getElementAttributes } from \"../../lib/getElementAttributes.js\";\nimport { LayoutComponent } from \"../../types/internal.js\";\nimport { runClientInit } from \"../../lib/runClientInit.js\";\n\nTurbolinks.start();\n\nconst PassthruLayout: LayoutComponent = ({ children }) => <>{children}</>;\n\nexport default async function onRenderClient(\n pageContext: PageContextProxyClient\n) {\n if (pageContext.redirectTo) {\n Turbolinks.visit(pageContext.redirectTo);\n return;\n }\n const { layoutProps, layout } = pageContext;\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] || PassthruLayout;\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 let bodyEl: Element;\n\n function cachePageContext() {\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\n if (pageContext.isHydration) {\n // During hydration of initial ssr, body is in dom, not page props (to avoid double-send)\n await runClientInit(pageContext.configEntries);\n bodyEl = document.getElementById(\"proxied-body\")!;\n render(bodyEl.innerHTML);\n cachePageContext();\n } else {\n const { proxySendClient: proxy } = pageContext;\n\n if (!proxy) {\n console.error(\"proxy/+onRenderClient did not receive proxySendClient\");\n return;\n }\n\n const parsed = document.createElement(\"html\");\n parsed.innerHTML = proxy;\n bodyEl = parsed.querySelector(\"body\")!;\n const headEl = parsed.querySelector(\"head\")!;\n\n Turbolinks._vpsOnRenderClient(headEl, true, 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(bodyEl.innerHTML);\n cachePageContext();\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAUlB,WAAW,MAAM;AAEjB,IAAM,iBAAkC,CAAC,EAAE,SAAS,MAAM,0DAAG,QAAS;AAEtE,eAAO,eACL,aACA;AACA,MAAI,YAAY,YAAY;AAC1B,eAAW,MAAM,YAAY,UAAU;AACvC;AAAA,EACF;AACA,QAAM,EAAE,aAAa,OAAO,IAAI;AAEhC,QAAM,EAAE,UAAU,IAAI,YAAY;AAClC,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC3D;AACA,QAAM,SAAS,UAAU,MAAM,KAAK;AAEpC,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,MAAI;AAEJ,WAAS,mBAAmB;AAE1B,eAAW,qBAAqB;AAAA,MAC9B;AAAA,MACA;AAAA,MACA,WAAW,qBAAqB,MAAM;AAAA,IACxC,CAAC;AAAA,EACH;AAEA,MAAI,YAAY,aAAa;AAE3B,UAAM,cAAc,YAAY,aAAa;AAC7C,aAAS,SAAS,eAAe,cAAc;AAC/C,WAAO,OAAO,SAAS;AACvB,qBAAiB;AAAA,EACnB,OAAO;AACL,UAAM,EAAE,iBAAiB,MAAM,IAAI;AAEnC,QAAI,CAAC,OAAO;AACV,cAAQ,MAAM,uDAAuD;AACrE;AAAA,IACF;AAEA,UAAM,SAAS,SAAS,cAAc,MAAM;AAC5C,WAAO,YAAY;AACnB,aAAS,OAAO,cAAc,MAAM;AACpC,UAAM,SAAS,OAAO,cAAc,MAAM;AAE1C,eAAW,mBAAmB,QAAQ,MAAM,MAAM,MAAM;AAEtD,eAAS,KACN,kBAAkB,EAClB,QAAQ,CAAC,MAAM,SAAS,KAAK,gBAAgB,CAAC,CAAC;AAClD,4BAAsB,SAAS,MAAM,MAAM;AAE3C,aAAO,OAAO,SAAS;AACvB,uBAAiB;AAAA,IACnB,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../proxy/pages/onRenderHtml.tsx"],"sourcesContent":["import React from \"react\";\nimport ReactDOMServer from \"react-dom/server\";\nimport { dangerouslySkipEscape, escapeInject } from \"vike/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 { 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) {\n // passthru\n return { documentHtml: proxy, pageContext: {} };\n }\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 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,EAAE,UAAU,IAAI,YAAY;AAClC,QAAI,CAAC,WAAW;AACd,YAAM,IAAI,MAAM,yCAAyC;AAAA,IAC3D;AACA,UAAM,SAAS,UAAU,MAAM;AAC/B,QAAI,CAAC,QAAQ;AAEX,aAAO,EAAE,cAAc,OAAO,aAAa,CAAC,EAAE;AAAA,IAChD;AAEA,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,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,11 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
route: string;
|
|
3
|
-
Page: string;
|
|
4
|
-
onBeforeRender: null;
|
|
5
|
-
onRenderClient: "import:@alignable/bifrost/proxy/pages/restorationVisit/onRenderClient";
|
|
6
|
-
passToClient: never[];
|
|
7
|
-
clientRouting: true;
|
|
8
|
-
hydrationCanBeAborted: true;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export { _default as default };
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
onBeforeRender: null,
|
|
6
|
-
onRenderClient: "import:@alignable/bifrost/proxy/pages/restorationVisit/onRenderClient",
|
|
7
|
-
passToClient: [],
|
|
8
|
-
clientRouting: true,
|
|
9
|
-
hydrationCanBeAborted: true
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
config_default as default
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=+config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../proxy/pages/restorationVisit/+config.ts"],"sourcesContent":["import { Config } from \"vike/types\";\n\nexport default {\n route: \"import:@alignable/bifrost/proxy/pages/restorationVisit/route\",\n Page: \"import:@alignable/bifrost/proxy/pages/Page\",\n onBeforeRender: null,\n onRenderClient:\n \"import:@alignable/bifrost/proxy/pages/restorationVisit/onRenderClient\",\n passToClient: [],\n clientRouting: true,\n hydrationCanBeAborted: true,\n} satisfies Config;\n"],"mappings":";AAEA,IAAO,iBAAQ;AAAA,EACb,OAAO;AAAA,EACP,MAAM;AAAA,EACN,gBAAgB;AAAA,EAChB,gBACE;AAAA,EACF,cAAc,CAAC;AAAA,EACf,eAAe;AAAA,EACf,uBAAuB;AACzB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../proxy/pages/restorationVisit/onRenderClient.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n LayoutComponent,\n PageContextProxyRestorationVisit,\n} 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\nconst PassthruLayout: LayoutComponent = ({ children }) => <>{children}</>;\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 } = pageContext.snapshot.pageContext;\n const { bodyEl, headEl } = pageContext.snapshot;\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] || PassthruLayout;\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, 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 // 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}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAWlB,IAAM,iBAAkC,CAAC,EAAE,SAAS,MAAM,0DAAG,QAAS;AAEtE,eAAO,eACL,aACA;AACA,MAAI,YAAY,aAAa;AAC3B,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AAEA,QAAM,EAAE,aAAa,OAAO,IAAI,YAAY,SAAS;AACrD,QAAM,EAAE,QAAQ,OAAO,IAAI,YAAY;AACvC,QAAM,EAAE,UAAU,IAAI,YAAY;AAClC,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC3D;AACA,QAAM,SAAS,UAAU,MAAM,KAAK;AAEpC,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,MAAM;AAEtD,aAAS,KACN,kBAAkB,EAClB,QAAQ,CAAC,MAAM,SAAS,KAAK,gBAAgB,CAAC,CAAC;AAClD,0BAAsB,SAAS,MAAM,MAAM;AAE3C,WAAO,YAAY,SAAS;AAE5B,eAAW,qBAAqB;AAAA,MAC9B;AAAA,MACA;AAAA,MACA,WAAW,qBAAqB,MAAM;AAAA,IACxC,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|
|
File without changes
|