@blinkk/root 2.5.13 → 3.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/chunk-3OVMCKPA.js +416 -0
  2. package/dist/chunk-3OVMCKPA.js.map +1 -0
  3. package/dist/{chunk-3KGEENDW.js → chunk-6P3B7ZXL.js} +16 -17
  4. package/dist/chunk-6P3B7ZXL.js.map +1 -0
  5. package/dist/chunk-CY5IQ4AQ.js +73 -0
  6. package/dist/chunk-CY5IQ4AQ.js.map +1 -0
  7. package/dist/{chunk-ISNB54FM.js → chunk-EBE4O463.js} +30 -19
  8. package/dist/chunk-EBE4O463.js.map +1 -0
  9. package/dist/{chunk-EWCJOOZN.js → chunk-G7OKXRD3.js} +34 -32
  10. package/dist/chunk-G7OKXRD3.js.map +1 -0
  11. package/dist/cli.d.ts +3 -1
  12. package/dist/cli.js +3 -3
  13. package/dist/core.d.ts +4 -2
  14. package/dist/core.js +4 -4
  15. package/dist/core.js.map +1 -1
  16. package/dist/functions.js +3 -3
  17. package/dist/jsx/jsx-dev-runtime.d.ts +1 -0
  18. package/dist/jsx/jsx-dev-runtime.js +11 -0
  19. package/dist/jsx/jsx-dev-runtime.js.map +1 -0
  20. package/dist/jsx/jsx-runtime.d.ts +1 -0
  21. package/dist/jsx/jsx-runtime.js +19 -0
  22. package/dist/jsx/jsx-runtime.js.map +1 -0
  23. package/dist/jsx-C8BaDh-4.d.ts +14 -0
  24. package/dist/jsx-dev-runtime-DUJrvx5P.d.ts +677 -0
  25. package/dist/jsx.d.ts +2 -0
  26. package/dist/jsx.js +23 -0
  27. package/dist/jsx.js.map +1 -0
  28. package/dist/middleware.d.ts +4 -2
  29. package/dist/node.d.ts +3 -1
  30. package/dist/node.js +1 -1
  31. package/dist/render.d.ts +3 -1
  32. package/dist/render.js +45 -10
  33. package/dist/render.js.map +1 -1
  34. package/dist/{types-BXpvdaTX.d.ts → types-BstdV3Rj.d.ts} +31 -1
  35. package/package.json +21 -8
  36. package/dist/chunk-3KGEENDW.js.map +0 -1
  37. package/dist/chunk-EWCJOOZN.js.map +0 -1
  38. package/dist/chunk-ISNB54FM.js.map +0 -1
package/dist/jsx.js ADDED
@@ -0,0 +1,23 @@
1
+ import {
2
+ renderJsxToString
3
+ } from "./chunk-3OVMCKPA.js";
4
+ import {
5
+ Fragment,
6
+ createContext,
7
+ createElement,
8
+ jsx,
9
+ options,
10
+ useContext
11
+ } from "./chunk-CY5IQ4AQ.js";
12
+ export {
13
+ Fragment,
14
+ createContext,
15
+ createElement,
16
+ createElement as h,
17
+ jsx,
18
+ jsx as jsxs,
19
+ options,
20
+ renderJsxToString,
21
+ useContext
22
+ };
23
+ //# sourceMappingURL=jsx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,10 +1,12 @@
1
- import { b as RootConfig, s as Request, t as Response, N as NextFunction } from './types-BXpvdaTX.js';
2
- export { D as SESSION_COOKIE, F as SaveSessionOptions, J as Session, E as SessionMiddlewareOptions, I as sessionMiddleware } from './types-BXpvdaTX.js';
1
+ import { R as RootConfig, a as Request, b as Response, N as NextFunction } from './types-BstdV3Rj.js';
2
+ export { S as SESSION_COOKIE, d as SaveSessionOptions, e as Session, c as SessionMiddlewareOptions, s as sessionMiddleware } from './types-BstdV3Rj.js';
3
3
  import { RequestHandler } from 'express';
4
4
  import 'preact';
5
5
  import 'vite';
6
6
  import 'html-minifier-terser';
7
7
  import 'js-beautify';
8
+ import './jsx-C8BaDh-4.js';
9
+ import './jsx-dev-runtime-DUJrvx5P.js';
8
10
 
9
11
  /**
10
12
  * Middleware that injects the root.js project config into the request context.
package/dist/node.d.ts CHANGED
@@ -1,10 +1,12 @@
1
- import { b as RootConfig } from './types-BXpvdaTX.js';
1
+ import { R as RootConfig } from './types-BstdV3Rj.js';
2
2
  import { PackageInfo } from 'workspace-tools';
3
3
  import { ViteDevServer } from 'vite';
4
4
  import 'express';
5
5
  import 'preact';
6
6
  import 'html-minifier-terser';
7
7
  import 'js-beautify';
8
+ import './jsx-C8BaDh-4.js';
9
+ import './jsx-dev-runtime-DUJrvx5P.js';
8
10
 
9
11
  interface ConfigOptions {
10
12
  command: string;
package/dist/node.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  loadRootConfig,
9
9
  loadRootConfigWithDeps,
10
10
  viteSsrLoadModule
11
- } from "./chunk-ISNB54FM.js";
11
+ } from "./chunk-EBE4O463.js";
12
12
  import "./chunk-6FDF3DXT.js";
13
13
  export {
14
14
  bundleRootConfig,
package/dist/render.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- export { K as Renderer } from './types-BXpvdaTX.js';
1
+ export { K as Renderer } from './types-BstdV3Rj.js';
2
2
  import 'express';
3
3
  import 'preact';
4
4
  import 'vite';
5
5
  import 'html-minifier-terser';
6
6
  import 'js-beautify';
7
+ import './jsx-C8BaDh-4.js';
8
+ import './jsx-dev-runtime-DUJrvx5P.js';
package/dist/render.js CHANGED
@@ -11,7 +11,11 @@ import {
11
11
  htmlMinify,
12
12
  htmlPretty,
13
13
  parseTagNames
14
- } from "./chunk-3KGEENDW.js";
14
+ } from "./chunk-6P3B7ZXL.js";
15
+ import {
16
+ renderJsxToString
17
+ } from "./chunk-3OVMCKPA.js";
18
+ import "./chunk-CY5IQ4AQ.js";
15
19
 
16
20
  // src/render/render.tsx
17
21
  import crypto from "crypto";
@@ -19,7 +23,6 @@ import path2 from "path";
19
23
  import {
20
24
  options as preactOptions
21
25
  } from "preact";
22
- import { renderToString } from "preact-render-to-string";
23
26
 
24
27
  // src/core/pages/ErrorPage.tsx
25
28
  import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
@@ -13150,7 +13153,7 @@ var Renderer = class {
13150
13153
  preactHook(vnode);
13151
13154
  }
13152
13155
  };
13153
- mainHtml = renderToString(vdom);
13156
+ mainHtml = await this.renderJsx(vdom);
13154
13157
  preactOptions.vnode = preactHook;
13155
13158
  } catch (err) {
13156
13159
  preactOptions.vnode = preactHook;
@@ -13457,6 +13460,26 @@ var Renderer = class {
13457
13460
  });
13458
13461
  return orderedSitemap;
13459
13462
  }
13463
+ getJsxRenderOptions() {
13464
+ return this.rootConfig.jsxRenderer || {};
13465
+ }
13466
+ /**
13467
+ * Renders JSX via either the `@blinkk/root/jsx` package or
13468
+ * `preact-render-to-string` depending if the `jsxRenderer` config is set up
13469
+ * in `root.config.ts`.
13470
+ */
13471
+ async renderJsx(vnode) {
13472
+ if (this.rootConfig.jsxRenderer?.mode) {
13473
+ return renderJsxToString(vnode, this.getJsxRenderOptions());
13474
+ }
13475
+ const { renderToString } = await import("preact-render-to-string");
13476
+ if (!renderToString) {
13477
+ throw new Error(
13478
+ 'failed to render jsx. either install preact-render-to-string or add the "jsxRenderer" config to root.config.ts'
13479
+ );
13480
+ }
13481
+ return renderToString(vnode);
13482
+ }
13460
13483
  getConfiguredStyleEntries() {
13461
13484
  const styleEntries = this.rootConfig.styles?.entries || [];
13462
13485
  const basePath = this.rootConfig.base || "/";
@@ -13471,11 +13494,23 @@ var Renderer = class {
13471
13494
  /* @__PURE__ */ jsx4("meta", { charSet: "utf-8" }),
13472
13495
  options?.headComponents
13473
13496
  ] }),
13474
- /* @__PURE__ */ jsx4("body", { ...bodyAttrs, dangerouslySetInnerHTML: { __html: html } })
13497
+ /* @__PURE__ */ jsx4(
13498
+ "body",
13499
+ {
13500
+ ...bodyAttrs,
13501
+ dangerouslySetInnerHTML: { __html: this.ensureNewline(html) }
13502
+ }
13503
+ )
13475
13504
  ] });
13505
+ const content = await this.renderJsx(page);
13476
13506
  return `<!doctype html>
13477
- ${renderToString(page)}
13478
- `;
13507
+ ${content}`;
13508
+ }
13509
+ ensureNewline(str) {
13510
+ if (!str.endsWith("\n")) {
13511
+ return str + "\n";
13512
+ }
13513
+ return str;
13479
13514
  }
13480
13515
  async render404(options) {
13481
13516
  const basePath = this.rootConfig.base || "/";
@@ -13490,7 +13525,7 @@ ${renderToString(page)}
13490
13525
  { currentPath, route, routeParams, locale: "en" }
13491
13526
  );
13492
13527
  }
13493
- const mainHtml = renderToString(
13528
+ const mainHtml = await this.renderJsx(
13494
13529
  /* @__PURE__ */ jsx4(
13495
13530
  ErrorPage,
13496
13531
  {
@@ -13526,7 +13561,7 @@ ${renderToString(page)}
13526
13561
  { currentPath, route, routeParams, locale: "en" }
13527
13562
  );
13528
13563
  }
13529
- const mainHtml = renderToString(
13564
+ const mainHtml = await this.renderJsx(
13530
13565
  /* @__PURE__ */ jsx4(
13531
13566
  ErrorPage,
13532
13567
  {
@@ -13553,7 +13588,7 @@ ${renderToString(page)}
13553
13588
  }
13554
13589
  async renderDevServer404(req) {
13555
13590
  const sitemap = await this.getSitemap();
13556
- const mainHtml = renderToString(
13591
+ const mainHtml = await this.renderJsx(
13557
13592
  /* @__PURE__ */ jsx4(DevNotFoundPage, { req, sitemap })
13558
13593
  );
13559
13594
  const html = await this.renderHtml(mainHtml, {
@@ -13563,7 +13598,7 @@ ${renderToString(page)}
13563
13598
  }
13564
13599
  async renderDevServer500(req, error) {
13565
13600
  const [route, routeParams] = this.router.get(req.path);
13566
- const mainHtml = renderToString(
13601
+ const mainHtml = await this.renderJsx(
13567
13602
  /* @__PURE__ */ jsx4(
13568
13603
  DevErrorPage,
13569
13604
  {