@alignable/bifrost 0.0.9 → 0.0.11

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.
@@ -15,6 +15,12 @@ declare const _default: {
15
15
  documentProps: {
16
16
  env: "server-and-client";
17
17
  };
18
+ isLoggedIn: {
19
+ env: "server-and-client";
20
+ };
21
+ scripts: {
22
+ env: "server-and-client";
23
+ };
18
24
  };
19
25
  };
20
26
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"+config.d.ts","sourceRoot":"","sources":["../../renderer/+config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAEA,wBAYgC"}
1
+ {"version":3,"file":"+config.d.ts","sourceRoot":"","sources":["../../renderer/+config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wBAcgC"}
@@ -1,5 +1,5 @@
1
1
  export default {
2
- passToClient: ["layoutProps", "pageProps", "redirectTo", "documentProps"],
2
+ passToClient: ["layoutProps", "pageProps", "redirectTo", "documentProps", "isLoggedIn", "scripts"],
3
3
  onRenderClient: "import:@alignable/bifrost/renderer/onRenderClient",
4
4
  onRenderHtml: "import:@alignable/bifrost/renderer/onRenderHtml",
5
5
  onBeforeRoute: "import:@alignable/bifrost/renderer/onBeforeRoute",
@@ -9,5 +9,7 @@ export default {
9
9
  Layout: { env: "server-and-client" },
10
10
  layoutProps: { env: "server-and-client" },
11
11
  documentProps: { env: "server-and-client" },
12
+ isLoggedIn: { env: "server-and-client" },
13
+ scripts: { env: "server-and-client" },
12
14
  },
13
15
  };
@@ -1,9 +1,9 @@
1
1
  export default function onBeforeRoute(_pageContext: any): {
2
2
  pageContext: {
3
3
  _pageId: string;
4
+ layoutProps: Record<string, unknown>;
4
5
  proxySendClient?: import("../types/internal.js").Proxy | undefined;
5
6
  layout: string;
6
- layoutProps: Record<string, unknown>;
7
7
  };
8
8
  } | undefined;
9
9
  //# sourceMappingURL=onBeforeRoute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"onRenderClient.d.ts","sourceRoot":"","sources":["../../renderer/onRenderClient.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAUhE,wBAA8B,cAAc,CAC1C,WAAW,EAAE,wBAAwB,iBA8BtC"}
1
+ {"version":3,"file":"onRenderClient.d.ts","sourceRoot":"","sources":["../../renderer/onRenderClient.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAWhE,wBAA8B,cAAc,CAC1C,WAAW,EAAE,wBAAwB,iBAmCtC"}
@@ -6,6 +6,7 @@ import { getDocumentProps } from "./getDocumentProps.js";
6
6
  import { cacheProxiedBody } from "../lib/snapshots.js";
7
7
  import { navigateAnywhere } from "../lib/navigateAnywhere.js";
8
8
  import { setupTurbolinks } from "../lib/turbolinks.js";
9
+ import { formatMetaObject } from "./utils/formatMetaObject.js";
9
10
  setupTurbolinks();
10
11
  export default async function onRenderClient(pageContext) {
11
12
  if (navigateAnywhere(pageContext.redirectTo))
@@ -18,11 +19,16 @@ export default async function onRenderClient(pageContext) {
18
19
  throw new Error("Client-side render() hook expects Layout to be exported");
19
20
  document.removeEventListener("click", turbolinksClickListener);
20
21
  cacheProxiedBody();
21
- const { title = "", description = "" } = getDocumentProps(pageContext);
22
+ const { title = "", description = "", viewport } = getDocumentProps(pageContext);
22
23
  document.title = title;
23
24
  document.head
24
25
  .querySelector("meta[name='description']")
25
26
  ?.setAttribute("content", description);
27
+ if (viewport) {
28
+ document.head
29
+ .querySelector("meta[name='viewport']")
30
+ ?.setAttribute("content", formatMetaObject(viewport));
31
+ }
26
32
  const page = (React.createElement(PageShell, { pageContext: pageContext },
27
33
  React.createElement(Layout, { ...layoutProps },
28
34
  React.createElement(Page, { ...pageProps }))));
@@ -1 +1 @@
1
- {"version":3,"file":"onRenderHtml.d.ts","sourceRoot":"","sources":["../../renderer/onRenderHtml.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,wBAA8B,YAAY,CACxC,WAAW,EAAE,wBAAwB;;;GA0CtC"}
1
+ {"version":3,"file":"onRenderHtml.d.ts","sourceRoot":"","sources":["../../renderer/onRenderHtml.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAIhE,wBAA8B,YAAY,CACxC,WAAW,EAAE,wBAAwB;;;GAmDtC"}
@@ -3,6 +3,7 @@ import React from "react";
3
3
  import { PageShell } from "../lib/PageShell.js";
4
4
  import { escapeInject, dangerouslySkipEscape } from "vite-plugin-ssr/server";
5
5
  import { getDocumentProps } from "./getDocumentProps.js";
6
+ import { formatMetaObject } from "./utils/formatMetaObject.js";
6
7
  export default async function onRenderHtml(pageContext) {
7
8
  const { Page, pageProps } = pageContext;
8
9
  const { Layout, layoutProps } = pageContext.config;
@@ -13,17 +14,24 @@ export default async function onRenderHtml(pageContext) {
13
14
  const pageHtml = ReactDOMServer.renderToString(React.createElement(PageShell, { pageContext: pageContext },
14
15
  React.createElement(Layout, { ...layoutProps },
15
16
  React.createElement(Page, { ...pageProps }))));
17
+ const { googleAnalytics, osano } = pageContext.config.scripts;
18
+ const googleAnalyticsTag = dangerouslySkipEscape(googleAnalytics);
19
+ const osanoTag = dangerouslySkipEscape(osano);
16
20
  // // See https://vite-plugin-ssr.com/head
17
- const { title = "", description = "" } = getDocumentProps(pageContext);
21
+ const { title = "", description = "", viewport } = getDocumentProps(pageContext);
18
22
  if (!title) {
19
23
  console.warn(`No title set for ${pageContext.urlOriginal}!`);
20
24
  }
25
+ const viewportTag = !viewport ? "" : escapeInject `<meta content="${formatMetaObject(viewport)}" name="viewport">`;
21
26
  const documentHtml = escapeInject `<!DOCTYPE html>
22
27
  <html lang="en">
23
28
  <head>
29
+ ${googleAnalyticsTag}
30
+ ${osanoTag}
24
31
  <title>${title}</title>
25
32
  <meta name="title" property="og:title" content="${title}"/>
26
33
  <meta name="description" content="${description}"/>
34
+ ${viewportTag}
27
35
  </head>
28
36
  <body>
29
37
  <div id="page-view">${dangerouslySkipEscape(pageHtml)}</div>
@@ -0,0 +1,4 @@
1
+ export declare function formatMetaObject(obj: {
2
+ [key: string]: string;
3
+ }): string;
4
+ //# sourceMappingURL=formatMetaObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatMetaObject.d.ts","sourceRoot":"","sources":["../../../renderer/utils/formatMetaObject.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,GAAG,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,UAE9D"}
@@ -0,0 +1,3 @@
1
+ export function formatMetaObject(obj) {
2
+ return Object.entries(obj).map((e) => e.join("=")).join(", ");
3
+ }
@@ -31,6 +31,13 @@ export type PageContextProxy = PageContextProxyServer | PageContextProxyClient;
31
31
  export interface DocumentProps {
32
32
  title?: string;
33
33
  description?: string;
34
+ viewport?: {
35
+ [key: string]: string;
36
+ };
37
+ }
38
+ export interface ScriptProps {
39
+ googleAnalytics: string;
40
+ osano: string;
34
41
  }
35
42
  type PageProps = Record<string, unknown>;
36
43
  type Page = React.ComponentType<PageProps>;
@@ -42,6 +49,8 @@ interface PageContextNoProxyCommon<LayoutProps = Record<string, unknown>> {
42
49
  Layout: Layout<LayoutProps>;
43
50
  layoutProps?: LayoutProps;
44
51
  documentProps?: DocumentProps;
52
+ isLoggedIn?: boolean;
53
+ scripts: ScriptProps;
45
54
  };
46
55
  }
47
56
  export type PageContextNoProxyServer = PageContextBuiltIn<Page> & PageContextNoProxyCommon;
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../types/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAClB,yCAAyC,IAAI,wBAAwB,EACtE,MAAM,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ACzC,KAAK,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;AAE3C,UAAU,wBAAwB,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACtE,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAC5B,WAAW,CAAC,EAAE,WAAW,CAAC;QAC1B,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,OAAO,EAAE,WAAW,CAAC;KACtB,CAAC;CACH;AAED,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,CAAC,IAAI,CAAC,GAC7D,wBAAwB,CAAC;AAC3B,MAAM,MAAM,wBAAwB,GAAG,wBAAwB,CAAC,IAAI,CAAC,GACnE,wBAAwB,CAAC;AAE3B,MAAM,MAAM,kBAAkB,GAC1B,wBAAwB,GACxB,wBAAwB,CAAC;AAE7B,MAAM,MAAM,WAAW,GAAG,kBAAkB,GAAG,gBAAgB,CAAC"}
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.9",
4
+ "version": "0.0.11",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "exports": {
@@ -1,5 +0,0 @@
1
- export declare function getGlobalObject<T extends Record<string, unknown> = never>(key: `${string}.ts`, defaultValue: T): T;
2
- declare global {
3
- var __vite_plugin_ssr: undefined | Record<string, Record<string, unknown>>;
4
- }
5
- //# sourceMappingURL=getGlobalObject.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getGlobalObject.d.ts","sourceRoot":"","sources":["../../lib/getGlobalObject.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,EAEvE,GAAG,EAAE,GAAG,MAAM,KAAK,EACnB,YAAY,EAAE,CAAC,GACd,CAAC,CAIH;AACD,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,iBAAiB,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAC3E"}
@@ -1,7 +0,0 @@
1
- export function getGlobalObject(
2
- // We use the filename as key; each `getGlobalObject()` call should live in a unique filename.
3
- key, defaultValue) {
4
- const allGlobalObjects = (globalThis.__vite_plugin_ssr = globalThis.__vite_plugin_ssr || {});
5
- const globalObject = (allGlobalObjects[key] = allGlobalObjects[key] || defaultValue);
6
- return globalObject;
7
- }
@@ -1,3 +0,0 @@
1
- import { PageContextBuiltInClientWithClientRouting } from "vite-plugin-ssr/types";
2
- export default function onPageTransitionEnd(pageContext: PageContextBuiltInClientWithClientRouting): void;
3
- //# sourceMappingURL=onPageTransitionEnd.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"onPageTransitionEnd.d.ts","sourceRoot":"","sources":["../../../proxy/pages/onPageTransitionEnd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yCAAyC,EAAE,MAAM,uBAAuB,CAAC;AAGlF,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,WAAW,EAAE,yCAAyC,QAGvD"}
@@ -1,3 +0,0 @@
1
- export default function onPageTransitionEnd(pageContext) {
2
- // TODO: We're just guessing with the request. handle failed and failedwithstatuscode
3
- }
@@ -1,3 +0,0 @@
1
- import { PageContextBuiltInClientWithClientRouting } from "vite-plugin-ssr/types";
2
- export default function onPageTransitionStart(pageContext: PageContextBuiltInClientWithClientRouting): void;
3
- //# sourceMappingURL=onPageTransitionStart.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"onPageTransitionStart.d.ts","sourceRoot":"","sources":["../../../proxy/pages/onPageTransitionStart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yCAAyC,EAAE,MAAM,uBAAuB,CAAC;AAIlF,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,WAAW,EAAE,yCAAyC,QAQvD"}
@@ -1,9 +0,0 @@
1
- import { Visit, getAdapter } from "../../lib/turbolinks";
2
- export default function onPageTransitionStart(pageContext) {
3
- const v = new Visit();
4
- window.Turbolinks.controller.restorationIdentifier = v.restorationIdentifier;
5
- window.Turbolinks.controller.currentVisit = v;
6
- console.log(v.identifier);
7
- getAdapter()?.visitStarted(v);
8
- getAdapter()?.visitRequestStarted(v);
9
- }