@blinkk/root 2.5.11 → 2.5.12-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.
- package/dist/chunk-P6EPJRRM.js +448 -0
- package/dist/chunk-P6EPJRRM.js.map +1 -0
- package/dist/cli.d.ts +2 -1
- package/dist/core.d.ts +3 -2
- package/dist/core.js.map +1 -1
- package/dist/jsx-render-BCCySLjz.d.ts +127 -0
- package/dist/jsx.d.ts +565 -0
- package/dist/jsx.js +21 -0
- package/dist/jsx.js.map +1 -0
- package/dist/middleware.d.ts +3 -2
- package/dist/node.d.ts +2 -1
- package/dist/render.d.ts +2 -1
- package/dist/render.js +43 -9
- package/dist/render.js.map +1 -1
- package/dist/{types-BXpvdaTX.d.ts → types-yeULDLJI.d.ts} +30 -0
- package/package.json +11 -4
package/dist/jsx.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Fragment,
|
|
3
|
+
createContext,
|
|
4
|
+
createElement,
|
|
5
|
+
jsx,
|
|
6
|
+
options,
|
|
7
|
+
renderJsxToString,
|
|
8
|
+
useContext
|
|
9
|
+
} from "./chunk-P6EPJRRM.js";
|
|
10
|
+
export {
|
|
11
|
+
Fragment,
|
|
12
|
+
createContext,
|
|
13
|
+
createElement,
|
|
14
|
+
createElement as h,
|
|
15
|
+
jsx,
|
|
16
|
+
jsx as jsxs,
|
|
17
|
+
options,
|
|
18
|
+
renderJsxToString,
|
|
19
|
+
useContext
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=jsx.js.map
|
package/dist/jsx.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/middleware.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { b as RootConfig, s as Request, t as Response, N as NextFunction } from './types-
|
|
2
|
-
export { D as SESSION_COOKIE, F as SaveSessionOptions, J as Session, E as SessionMiddlewareOptions, I as sessionMiddleware } from './types-
|
|
1
|
+
import { b as RootConfig, s as Request, t as Response, N as NextFunction } from './types-yeULDLJI.js';
|
|
2
|
+
export { D as SESSION_COOKIE, F as SaveSessionOptions, J as Session, E as SessionMiddlewareOptions, I as sessionMiddleware } from './types-yeULDLJI.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-render-BCCySLjz.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Middleware that injects the root.js project config into the request context.
|
package/dist/node.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { b as RootConfig } from './types-
|
|
1
|
+
import { b as RootConfig } from './types-yeULDLJI.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-render-BCCySLjz.js';
|
|
8
9
|
|
|
9
10
|
interface ConfigOptions {
|
|
10
11
|
command: string;
|
package/dist/render.d.ts
CHANGED
package/dist/render.js
CHANGED
|
@@ -12,6 +12,9 @@ import {
|
|
|
12
12
|
htmlPretty,
|
|
13
13
|
parseTagNames
|
|
14
14
|
} from "./chunk-3KGEENDW.js";
|
|
15
|
+
import {
|
|
16
|
+
renderJsxToString
|
|
17
|
+
} from "./chunk-P6EPJRRM.js";
|
|
15
18
|
|
|
16
19
|
// src/render/render.tsx
|
|
17
20
|
import crypto from "crypto";
|
|
@@ -19,7 +22,6 @@ import path2 from "path";
|
|
|
19
22
|
import {
|
|
20
23
|
options as preactOptions
|
|
21
24
|
} from "preact";
|
|
22
|
-
import { renderToString } from "preact-render-to-string";
|
|
23
25
|
|
|
24
26
|
// src/core/pages/ErrorPage.tsx
|
|
25
27
|
import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
|
|
@@ -13150,7 +13152,7 @@ var Renderer = class {
|
|
|
13150
13152
|
preactHook(vnode);
|
|
13151
13153
|
}
|
|
13152
13154
|
};
|
|
13153
|
-
mainHtml =
|
|
13155
|
+
mainHtml = await this.renderJsx(vdom);
|
|
13154
13156
|
preactOptions.vnode = preactHook;
|
|
13155
13157
|
} catch (err) {
|
|
13156
13158
|
preactOptions.vnode = preactHook;
|
|
@@ -13457,6 +13459,26 @@ var Renderer = class {
|
|
|
13457
13459
|
});
|
|
13458
13460
|
return orderedSitemap;
|
|
13459
13461
|
}
|
|
13462
|
+
getJsxRenderOptions() {
|
|
13463
|
+
return this.rootConfig.jsxRenderer || {};
|
|
13464
|
+
}
|
|
13465
|
+
/**
|
|
13466
|
+
* Renders JSX via either the `@blinkk/root/jsx` package or
|
|
13467
|
+
* `preact-render-to-string` depending if the `jsxRenderer` config is set up
|
|
13468
|
+
* in `root.config.ts`.
|
|
13469
|
+
*/
|
|
13470
|
+
async renderJsx(vnode) {
|
|
13471
|
+
if (this.rootConfig.jsxRenderer?.mode) {
|
|
13472
|
+
return renderJsxToString(vnode, this.getJsxRenderOptions());
|
|
13473
|
+
}
|
|
13474
|
+
const { renderToString } = await import("preact-render-to-string");
|
|
13475
|
+
if (!renderToString) {
|
|
13476
|
+
throw new Error(
|
|
13477
|
+
'failed to render jsx. either install preact-render-to-string or add the "jsxRenderer" config to root.config.ts'
|
|
13478
|
+
);
|
|
13479
|
+
}
|
|
13480
|
+
return renderToString(vnode);
|
|
13481
|
+
}
|
|
13460
13482
|
getConfiguredStyleEntries() {
|
|
13461
13483
|
const styleEntries = this.rootConfig.styles?.entries || [];
|
|
13462
13484
|
const basePath = this.rootConfig.base || "/";
|
|
@@ -13471,11 +13493,23 @@ var Renderer = class {
|
|
|
13471
13493
|
/* @__PURE__ */ jsx4("meta", { charSet: "utf-8" }),
|
|
13472
13494
|
options?.headComponents
|
|
13473
13495
|
] }),
|
|
13474
|
-
/* @__PURE__ */ jsx4(
|
|
13496
|
+
/* @__PURE__ */ jsx4(
|
|
13497
|
+
"body",
|
|
13498
|
+
{
|
|
13499
|
+
...bodyAttrs,
|
|
13500
|
+
dangerouslySetInnerHTML: { __html: this.ensureNewline(html) }
|
|
13501
|
+
}
|
|
13502
|
+
)
|
|
13475
13503
|
] });
|
|
13504
|
+
const content = await this.renderJsx(page);
|
|
13476
13505
|
return `<!doctype html>
|
|
13477
|
-
${
|
|
13478
|
-
|
|
13506
|
+
${content}`;
|
|
13507
|
+
}
|
|
13508
|
+
ensureNewline(str) {
|
|
13509
|
+
if (!str.endsWith("\n")) {
|
|
13510
|
+
return str + "\n";
|
|
13511
|
+
}
|
|
13512
|
+
return str;
|
|
13479
13513
|
}
|
|
13480
13514
|
async render404(options) {
|
|
13481
13515
|
const basePath = this.rootConfig.base || "/";
|
|
@@ -13490,7 +13524,7 @@ ${renderToString(page)}
|
|
|
13490
13524
|
{ currentPath, route, routeParams, locale: "en" }
|
|
13491
13525
|
);
|
|
13492
13526
|
}
|
|
13493
|
-
const mainHtml =
|
|
13527
|
+
const mainHtml = await this.renderJsx(
|
|
13494
13528
|
/* @__PURE__ */ jsx4(
|
|
13495
13529
|
ErrorPage,
|
|
13496
13530
|
{
|
|
@@ -13526,7 +13560,7 @@ ${renderToString(page)}
|
|
|
13526
13560
|
{ currentPath, route, routeParams, locale: "en" }
|
|
13527
13561
|
);
|
|
13528
13562
|
}
|
|
13529
|
-
const mainHtml =
|
|
13563
|
+
const mainHtml = await this.renderJsx(
|
|
13530
13564
|
/* @__PURE__ */ jsx4(
|
|
13531
13565
|
ErrorPage,
|
|
13532
13566
|
{
|
|
@@ -13553,7 +13587,7 @@ ${renderToString(page)}
|
|
|
13553
13587
|
}
|
|
13554
13588
|
async renderDevServer404(req) {
|
|
13555
13589
|
const sitemap = await this.getSitemap();
|
|
13556
|
-
const mainHtml =
|
|
13590
|
+
const mainHtml = await this.renderJsx(
|
|
13557
13591
|
/* @__PURE__ */ jsx4(DevNotFoundPage, { req, sitemap })
|
|
13558
13592
|
);
|
|
13559
13593
|
const html = await this.renderHtml(mainHtml, {
|
|
@@ -13563,7 +13597,7 @@ ${renderToString(page)}
|
|
|
13563
13597
|
}
|
|
13564
13598
|
async renderDevServer500(req, error) {
|
|
13565
13599
|
const [route, routeParams] = this.router.get(req.path);
|
|
13566
|
-
const mainHtml =
|
|
13600
|
+
const mainHtml = await this.renderJsx(
|
|
13567
13601
|
/* @__PURE__ */ jsx4(
|
|
13568
13602
|
DevErrorPage,
|
|
13569
13603
|
{
|