@blinkk/root 2.5.16 → 3.0.1-alpha.1
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-3OVMCKPA.js +416 -0
- package/dist/chunk-3OVMCKPA.js.map +1 -0
- package/dist/chunk-CY5IQ4AQ.js +73 -0
- package/dist/chunk-CY5IQ4AQ.js.map +1 -0
- package/dist/chunk-PVBPP5LN.js +854 -0
- package/dist/chunk-PVBPP5LN.js.map +1 -0
- package/dist/{chunk-ZOU2UDXE.js → chunk-RRJ3JKJD.js} +56 -33
- package/dist/chunk-RRJ3JKJD.js.map +1 -0
- package/dist/{chunk-6FDF3DXT.js → chunk-XSNCF7WU.js} +1 -1
- package/dist/chunk-XSNCF7WU.js.map +1 -0
- package/dist/cli.d.ts +3 -1
- package/dist/cli.js +4 -4
- package/dist/core.d.ts +4 -2
- package/dist/core.js +10 -4
- package/dist/core.js.map +1 -1
- package/dist/functions.js +4 -4
- package/dist/jsx/jsx-dev-runtime.d.ts +1 -0
- package/dist/jsx/jsx-dev-runtime.js +11 -0
- package/dist/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx/jsx-runtime.d.ts +1 -0
- package/dist/jsx/jsx-runtime.js +19 -0
- package/dist/jsx/jsx-runtime.js.map +1 -0
- package/dist/jsx-C8BaDh-4.d.ts +14 -0
- package/dist/jsx-dev-runtime-DUJrvx5P.d.ts +677 -0
- package/dist/jsx.d.ts +2 -0
- package/dist/jsx.js +23 -0
- package/dist/jsx.js.map +1 -0
- package/dist/middleware.d.ts +4 -2
- package/dist/node.d.ts +36 -2
- package/dist/node.js +6 -2
- package/dist/render.d.ts +3 -1
- package/dist/render.js +86 -16
- package/dist/render.js.map +1 -1
- package/dist/{types-BXpvdaTX.d.ts → types-Cksf99CK.d.ts} +100 -1
- package/package.json +21 -8
- package/dist/chunk-6FDF3DXT.js.map +0 -1
- package/dist/chunk-ISNB54FM.js +0 -406
- package/dist/chunk-ISNB54FM.js.map +0 -1
- package/dist/chunk-ZOU2UDXE.js.map +0 -1
package/dist/middleware.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { R as RootConfig, a as Request, b as Response, N as NextFunction } from './types-Cksf99CK.js';
|
|
2
|
+
export { S as SESSION_COOKIE, d as SaveSessionOptions, e as Session, c as SessionMiddlewareOptions, s as sessionMiddleware } from './types-Cksf99CK.js';
|
|
3
3
|
import { RequestHandler } from 'express';
|
|
4
4
|
import 'preact';
|
|
5
5
|
import 'vite';
|
|
6
|
+
import './jsx-C8BaDh-4.js';
|
|
7
|
+
import './jsx-dev-runtime-DUJrvx5P.js';
|
|
6
8
|
import 'html-minifier-terser';
|
|
7
9
|
import 'js-beautify';
|
|
8
10
|
|
package/dist/node.d.ts
CHANGED
|
@@ -1,11 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P as PodConfig, R as RootConfig } from './types-Cksf99CK.js';
|
|
2
2
|
import { PackageInfo } from 'workspace-tools';
|
|
3
3
|
import { ViteDevServer } from 'vite';
|
|
4
4
|
import 'express';
|
|
5
5
|
import 'preact';
|
|
6
|
+
import './jsx-C8BaDh-4.js';
|
|
7
|
+
import './jsx-dev-runtime-DUJrvx5P.js';
|
|
6
8
|
import 'html-minifier-terser';
|
|
7
9
|
import 'js-beautify';
|
|
8
10
|
|
|
11
|
+
interface ResolvedPodRoute {
|
|
12
|
+
filePath: string;
|
|
13
|
+
relPath: string;
|
|
14
|
+
routePath: string;
|
|
15
|
+
}
|
|
16
|
+
interface ResolvedPodCollection {
|
|
17
|
+
filePath: string;
|
|
18
|
+
relPath: string;
|
|
19
|
+
id: string;
|
|
20
|
+
}
|
|
21
|
+
interface ResolvedPod {
|
|
22
|
+
name: string;
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
mount: string;
|
|
25
|
+
priority: number;
|
|
26
|
+
routesDir?: string;
|
|
27
|
+
elementsDirs: string[];
|
|
28
|
+
bundlesDir?: string;
|
|
29
|
+
collectionsDir?: string;
|
|
30
|
+
translationsDir?: string;
|
|
31
|
+
routeFiles: ResolvedPodRoute[];
|
|
32
|
+
bundleFiles: string[];
|
|
33
|
+
collectionFiles: ResolvedPodCollection[];
|
|
34
|
+
translationFiles: Array<{
|
|
35
|
+
locale: string;
|
|
36
|
+
filePath: string;
|
|
37
|
+
}>;
|
|
38
|
+
config: PodConfig;
|
|
39
|
+
}
|
|
40
|
+
declare function invalidatePodCache(): void;
|
|
41
|
+
declare function collectPods(rootConfig: RootConfig): Promise<ResolvedPod[]>;
|
|
42
|
+
|
|
9
43
|
interface ConfigOptions {
|
|
10
44
|
command: string;
|
|
11
45
|
}
|
|
@@ -54,4 +88,4 @@ declare function createViteServer(rootConfig: RootConfig, options?: CreateViteSe
|
|
|
54
88
|
*/
|
|
55
89
|
declare function viteSsrLoadModule<T = Record<string, any>>(rootConfig: RootConfig, file: string): Promise<T>;
|
|
56
90
|
|
|
57
|
-
export { type ConfigOptions, type CreateViteServerOptions, bundleRootConfig, createViteServer, flattenPackageDepsFromMonorepo, getMonorepoPackageDeps, loadBundledConfig, loadPackageJson, loadRootConfig, loadRootConfigWithDeps, viteSsrLoadModule };
|
|
91
|
+
export { type ConfigOptions, type CreateViteServerOptions, type ResolvedPod, type ResolvedPodCollection, type ResolvedPodRoute, bundleRootConfig, collectPods, createViteServer, flattenPackageDepsFromMonorepo, getMonorepoPackageDeps, invalidatePodCache, loadBundledConfig, loadPackageJson, loadRootConfig, loadRootConfigWithDeps, viteSsrLoadModule };
|
package/dist/node.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bundleRootConfig,
|
|
3
|
+
collectPods,
|
|
3
4
|
createViteServer,
|
|
4
5
|
flattenPackageDepsFromMonorepo,
|
|
5
6
|
getMonorepoPackageDeps,
|
|
7
|
+
invalidatePodCache,
|
|
6
8
|
loadBundledConfig,
|
|
7
9
|
loadPackageJson,
|
|
8
10
|
loadRootConfig,
|
|
9
11
|
loadRootConfigWithDeps,
|
|
10
12
|
viteSsrLoadModule
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-PVBPP5LN.js";
|
|
14
|
+
import "./chunk-XSNCF7WU.js";
|
|
13
15
|
export {
|
|
14
16
|
bundleRootConfig,
|
|
17
|
+
collectPods,
|
|
15
18
|
createViteServer,
|
|
16
19
|
flattenPackageDepsFromMonorepo,
|
|
17
20
|
getMonorepoPackageDeps,
|
|
21
|
+
invalidatePodCache,
|
|
18
22
|
loadBundledConfig,
|
|
19
23
|
loadPackageJson,
|
|
20
24
|
loadRootConfig,
|
package/dist/render.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { U as Renderer } from './types-Cksf99CK.js';
|
|
2
2
|
import 'express';
|
|
3
3
|
import 'preact';
|
|
4
4
|
import 'vite';
|
|
5
|
+
import './jsx-C8BaDh-4.js';
|
|
6
|
+
import './jsx-dev-runtime-DUJrvx5P.js';
|
|
5
7
|
import 'html-minifier-terser';
|
|
6
8
|
import 'js-beautify';
|
package/dist/render.js
CHANGED
|
@@ -12,6 +12,10 @@ import {
|
|
|
12
12
|
htmlPretty,
|
|
13
13
|
parseTagNames
|
|
14
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";
|
|
@@ -12874,10 +12877,9 @@ function test419Country(countryCode) {
|
|
|
12874
12877
|
|
|
12875
12878
|
// src/render/router.ts
|
|
12876
12879
|
import path from "path";
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
);
|
|
12880
|
+
import { ROUTE_MODULES, POD_ROUTE_MODULES } from "virtual:root/routes";
|
|
12881
|
+
var ROUTES_FILES = ROUTE_MODULES;
|
|
12882
|
+
var POD_ROUTES = POD_ROUTE_MODULES || {};
|
|
12881
12883
|
var Router = class {
|
|
12882
12884
|
rootConfig;
|
|
12883
12885
|
routeTrie;
|
|
@@ -12898,6 +12900,9 @@ var Router = class {
|
|
|
12898
12900
|
const locales = this.rootConfig.i18n?.locales || [];
|
|
12899
12901
|
const basePath = this.rootConfig.base || "/";
|
|
12900
12902
|
const defaultLocale = this.rootConfig.i18n?.defaultLocale || "en";
|
|
12903
|
+
const i18nUrlFormat = toSquareBrackets(
|
|
12904
|
+
this.rootConfig.i18n?.urlFormat || "/[locale]/[base]/[path]"
|
|
12905
|
+
);
|
|
12901
12906
|
const trie = new RouteTrie();
|
|
12902
12907
|
Object.keys(ROUTES_FILES).forEach((modulePath) => {
|
|
12903
12908
|
const src = modulePath.slice(1);
|
|
@@ -12912,9 +12917,6 @@ var Router = class {
|
|
|
12912
12917
|
relativeRoutePath = path.join(parts.dir, parts.name);
|
|
12913
12918
|
}
|
|
12914
12919
|
const urlFormat = "/[base]/[path]";
|
|
12915
|
-
const i18nUrlFormat = toSquareBrackets(
|
|
12916
|
-
this.rootConfig.i18n?.urlFormat || "/[locale]/[base]/[path]"
|
|
12917
|
-
);
|
|
12918
12920
|
const placeholders = {
|
|
12919
12921
|
base: removeSlashes(basePath),
|
|
12920
12922
|
path: removeSlashes(relativeRoutePath)
|
|
@@ -12951,6 +12953,42 @@ var Router = class {
|
|
|
12951
12953
|
});
|
|
12952
12954
|
}
|
|
12953
12955
|
});
|
|
12956
|
+
Object.keys(POD_ROUTES).forEach((key) => {
|
|
12957
|
+
const entry = POD_ROUTES[key];
|
|
12958
|
+
const routePath = entry.routePath;
|
|
12959
|
+
const localeRoutePath = i18nUrlFormat.includes("[locale]") ? i18nUrlFormat.replaceAll("[base]", removeSlashes(basePath)).replaceAll("[path]", removeSlashes(routePath)) : routePath;
|
|
12960
|
+
const normalizedLocaleRoutePath = normalizeUrlPath(localeRoutePath, {
|
|
12961
|
+
trailingSlash: this.rootConfig.server?.trailingSlash
|
|
12962
|
+
});
|
|
12963
|
+
trie.add(routePath, {
|
|
12964
|
+
src: entry.src,
|
|
12965
|
+
module: entry.module,
|
|
12966
|
+
locale: defaultLocale,
|
|
12967
|
+
isDefaultLocale: true,
|
|
12968
|
+
routePath,
|
|
12969
|
+
localeRoutePath: normalizedLocaleRoutePath,
|
|
12970
|
+
podName: entry.podName
|
|
12971
|
+
});
|
|
12972
|
+
if (i18nUrlFormat.includes("[locale]")) {
|
|
12973
|
+
locales.forEach((locale) => {
|
|
12974
|
+
const localePath = normalizedLocaleRoutePath.replace(
|
|
12975
|
+
"[locale]",
|
|
12976
|
+
locale
|
|
12977
|
+
);
|
|
12978
|
+
if (localePath !== routePath) {
|
|
12979
|
+
trie.add(localePath, {
|
|
12980
|
+
src: entry.src,
|
|
12981
|
+
module: entry.module,
|
|
12982
|
+
locale,
|
|
12983
|
+
isDefaultLocale: false,
|
|
12984
|
+
routePath,
|
|
12985
|
+
localeRoutePath: normalizedLocaleRoutePath,
|
|
12986
|
+
podName: entry.podName
|
|
12987
|
+
});
|
|
12988
|
+
}
|
|
12989
|
+
});
|
|
12990
|
+
}
|
|
12991
|
+
});
|
|
12954
12992
|
return trie;
|
|
12955
12993
|
}
|
|
12956
12994
|
async getAllPathsForRoute(urlPathFormat, route) {
|
|
@@ -13150,7 +13188,7 @@ var Renderer = class {
|
|
|
13150
13188
|
preactHook(vnode);
|
|
13151
13189
|
}
|
|
13152
13190
|
};
|
|
13153
|
-
mainHtml =
|
|
13191
|
+
mainHtml = await this.renderJsx(vdom);
|
|
13154
13192
|
preactOptions.vnode = preactHook;
|
|
13155
13193
|
} catch (err) {
|
|
13156
13194
|
preactOptions.vnode = preactHook;
|
|
@@ -13457,6 +13495,26 @@ var Renderer = class {
|
|
|
13457
13495
|
});
|
|
13458
13496
|
return orderedSitemap;
|
|
13459
13497
|
}
|
|
13498
|
+
getJsxRenderOptions() {
|
|
13499
|
+
return this.rootConfig.jsxRenderer || {};
|
|
13500
|
+
}
|
|
13501
|
+
/**
|
|
13502
|
+
* Renders JSX via either the `@blinkk/root/jsx` package or
|
|
13503
|
+
* `preact-render-to-string` depending if the `jsxRenderer` config is set up
|
|
13504
|
+
* in `root.config.ts`.
|
|
13505
|
+
*/
|
|
13506
|
+
async renderJsx(vnode) {
|
|
13507
|
+
if (this.rootConfig.jsxRenderer?.mode) {
|
|
13508
|
+
return renderJsxToString(vnode, this.getJsxRenderOptions());
|
|
13509
|
+
}
|
|
13510
|
+
const { renderToString } = await import("preact-render-to-string");
|
|
13511
|
+
if (!renderToString) {
|
|
13512
|
+
throw new Error(
|
|
13513
|
+
'failed to render jsx. either install preact-render-to-string or add the "jsxRenderer" config to root.config.ts'
|
|
13514
|
+
);
|
|
13515
|
+
}
|
|
13516
|
+
return renderToString(vnode);
|
|
13517
|
+
}
|
|
13460
13518
|
getConfiguredStyleEntries() {
|
|
13461
13519
|
const styleEntries = this.rootConfig.styles?.entries || [];
|
|
13462
13520
|
const basePath = this.rootConfig.base || "/";
|
|
@@ -13471,11 +13529,23 @@ var Renderer = class {
|
|
|
13471
13529
|
/* @__PURE__ */ jsx4("meta", { charSet: "utf-8" }),
|
|
13472
13530
|
options?.headComponents
|
|
13473
13531
|
] }),
|
|
13474
|
-
/* @__PURE__ */ jsx4(
|
|
13532
|
+
/* @__PURE__ */ jsx4(
|
|
13533
|
+
"body",
|
|
13534
|
+
{
|
|
13535
|
+
...bodyAttrs,
|
|
13536
|
+
dangerouslySetInnerHTML: { __html: this.ensureNewline(html) }
|
|
13537
|
+
}
|
|
13538
|
+
)
|
|
13475
13539
|
] });
|
|
13540
|
+
const content = await this.renderJsx(page);
|
|
13476
13541
|
return `<!doctype html>
|
|
13477
|
-
${
|
|
13478
|
-
|
|
13542
|
+
${content}`;
|
|
13543
|
+
}
|
|
13544
|
+
ensureNewline(str) {
|
|
13545
|
+
if (!str.endsWith("\n")) {
|
|
13546
|
+
return str + "\n";
|
|
13547
|
+
}
|
|
13548
|
+
return str;
|
|
13479
13549
|
}
|
|
13480
13550
|
async render404(options) {
|
|
13481
13551
|
const basePath = this.rootConfig.base || "/";
|
|
@@ -13490,7 +13560,7 @@ ${renderToString(page)}
|
|
|
13490
13560
|
{ currentPath, route, routeParams, locale: "en" }
|
|
13491
13561
|
);
|
|
13492
13562
|
}
|
|
13493
|
-
const mainHtml =
|
|
13563
|
+
const mainHtml = await this.renderJsx(
|
|
13494
13564
|
/* @__PURE__ */ jsx4(
|
|
13495
13565
|
ErrorPage,
|
|
13496
13566
|
{
|
|
@@ -13526,7 +13596,7 @@ ${renderToString(page)}
|
|
|
13526
13596
|
{ currentPath, route, routeParams, locale: "en" }
|
|
13527
13597
|
);
|
|
13528
13598
|
}
|
|
13529
|
-
const mainHtml =
|
|
13599
|
+
const mainHtml = await this.renderJsx(
|
|
13530
13600
|
/* @__PURE__ */ jsx4(
|
|
13531
13601
|
ErrorPage,
|
|
13532
13602
|
{
|
|
@@ -13553,7 +13623,7 @@ ${renderToString(page)}
|
|
|
13553
13623
|
}
|
|
13554
13624
|
async renderDevServer404(req) {
|
|
13555
13625
|
const sitemap = await this.getSitemap();
|
|
13556
|
-
const mainHtml =
|
|
13626
|
+
const mainHtml = await this.renderJsx(
|
|
13557
13627
|
/* @__PURE__ */ jsx4(DevNotFoundPage, { req, sitemap })
|
|
13558
13628
|
);
|
|
13559
13629
|
const html = await this.renderHtml(mainHtml, {
|
|
@@ -13563,7 +13633,7 @@ ${renderToString(page)}
|
|
|
13563
13633
|
}
|
|
13564
13634
|
async renderDevServer500(req, error) {
|
|
13565
13635
|
const [route, routeParams] = this.router.get(req.path);
|
|
13566
|
-
const mainHtml =
|
|
13636
|
+
const mainHtml = await this.renderJsx(
|
|
13567
13637
|
/* @__PURE__ */ jsx4(
|
|
13568
13638
|
DevErrorPage,
|
|
13569
13639
|
{
|