@blinkk/root 3.0.2 → 3.0.3
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-FQBA5QSG.js → chunk-3Z5TNZEP.js} +3 -3
- package/dist/chunk-3Z5TNZEP.js.map +7 -0
- package/dist/{chunk-JCRXBB26.js → chunk-6NBKAR5Y.js} +2 -2
- package/dist/chunk-6NBKAR5Y.js.map +7 -0
- package/dist/chunk-6P3B7ZXL.js +1 -1
- package/dist/chunk-6P3B7ZXL.js.map +7 -1
- package/dist/{chunk-PVBPP5LN.js → chunk-7PSEEE6C.js} +10 -10
- package/dist/chunk-7PSEEE6C.js.map +7 -0
- package/dist/{chunk-4PO5HYET.js → chunk-DU7JUEDY.js} +37 -4
- package/dist/chunk-DU7JUEDY.js.map +7 -0
- package/dist/{chunk-GSR74KEI.js → chunk-JTZWI4MH.js} +279 -73
- package/dist/chunk-JTZWI4MH.js.map +7 -0
- package/dist/{chunk-WAZTR3DX.js → chunk-KW7KTYGC.js} +2 -2
- package/dist/chunk-KW7KTYGC.js.map +7 -0
- package/dist/chunk-XSNCF7WU.js +1 -1
- package/dist/chunk-XSNCF7WU.js.map +7 -1
- package/dist/cli/build.d.ts +7 -0
- package/dist/cli/cli.d.ts +12 -0
- package/dist/cli/codegen.d.ts +5 -0
- package/dist/cli/create-package.d.ts +14 -0
- package/dist/cli/dev.d.ts +10 -0
- package/dist/cli/gae-deploy.d.ts +18 -0
- package/dist/cli/preview.d.ts +8 -0
- package/dist/cli/start.d.ts +8 -0
- package/dist/cli/startup/check-version.d.ts +17 -0
- package/dist/cli/startup/startup-tasks.d.ts +39 -0
- package/dist/cli.js +4 -4
- package/dist/cli.js.map +7 -1
- package/dist/core/components/Body.d.ts +23 -0
- package/dist/core/components/Head.d.ts +18 -0
- package/dist/core/components/Html.d.ts +24 -0
- package/dist/core/components/Script.d.ts +16 -0
- package/dist/core/config.d.ts +285 -0
- package/dist/core/core.d.ts +14 -0
- package/dist/core/hooks/useI18nContext.d.ts +11 -0
- package/dist/core/hooks/useRequestContext.d.ts +36 -0
- package/dist/core/hooks/useStringParams.d.ts +34 -0
- package/dist/core/hooks/useTranslations.d.ts +20 -0
- package/dist/core/hooks/useTranslationsMiddleware.d.ts +25 -0
- package/dist/core/pages/DevErrorPage.d.ts +9 -0
- package/dist/core/pages/DevNotFoundPage.d.ts +10 -0
- package/dist/core/pages/ErrorPage.d.ts +9 -0
- package/dist/core/plugin.d.ts +80 -0
- package/dist/core/pod.d.ts +54 -0
- package/dist/core/types.d.ts +228 -0
- package/dist/core.js +3 -3
- package/dist/core.js.map +7 -1
- package/dist/functions/functions.d.ts +1 -0
- package/dist/functions/server.d.ts +10 -0
- package/dist/functions.js +5 -5
- package/dist/functions.js.map +7 -1
- package/dist/jsx/jsx-dev-runtime.d.ts +10 -1
- package/dist/jsx/jsx-dev-runtime.js +2 -2
- package/dist/jsx/jsx-dev-runtime.js.map +7 -1
- package/dist/{jsx-C8cJO55i.d.ts → jsx/jsx-render.d.ts} +3 -6
- package/dist/jsx/jsx-runtime.d.ts +120 -1
- package/dist/jsx/jsx-runtime.js +2 -2
- package/dist/jsx/jsx-runtime.js.map +7 -1
- package/dist/jsx/jsx.d.ts +37 -0
- package/dist/{jsx-dev-runtime-DHf9jiFH.d.ts → jsx/types.d.ts} +8 -124
- package/dist/jsx.js +3 -3
- package/dist/jsx.js.map +7 -1
- package/dist/middleware/common.d.ts +22 -0
- package/dist/middleware/hooks.d.ts +8 -0
- package/dist/middleware/middleware.d.ts +3 -0
- package/dist/middleware/multipart.d.ts +11 -0
- package/dist/middleware/redirects.d.ts +10 -0
- package/dist/middleware/session.d.ts +24 -0
- package/dist/middleware.js +2 -2
- package/dist/middleware.js.map +7 -1
- package/dist/node/element-graph.d.ts +51 -0
- package/dist/node/load-config.d.ts +17 -0
- package/dist/node/monorepo.d.ts +14 -0
- package/dist/node/node.d.ts +4 -0
- package/dist/node/pod-collector.d.ts +33 -0
- package/dist/node/pods-vite-plugin.d.ts +6 -0
- package/dist/node/vite-plugin-preact-alias.d.ts +10 -0
- package/dist/node/vite-plugin-prune-empty-chunks.d.ts +27 -0
- package/dist/node/vite-plugin-root-jsx-virtual.d.ts +16 -0
- package/dist/node/vite.d.ts +18 -0
- package/dist/node.js +2 -2
- package/dist/node.js.map +7 -1
- package/dist/render/accept-language.d.ts +8 -0
- package/dist/render/asset-map/asset-map.d.ts +25 -0
- package/dist/render/asset-map/build-asset-map.d.ts +47 -0
- package/dist/render/asset-map/dev-asset-map.d.ts +26 -0
- package/dist/render/countrie-language.d.ts +13 -0
- package/dist/render/html-minify.d.ts +3 -0
- package/dist/render/html-pretty.d.ts +3 -0
- package/dist/render/i18n-fallbacks.d.ts +11 -0
- package/dist/render/render.d.ts +91 -0
- package/dist/render/route-trie.d.ts +44 -0
- package/dist/render/router.d.ts +18 -0
- package/dist/render.js +9 -9
- package/dist/render.js.map +7 -1
- package/dist/utils/batch.d.ts +1 -0
- package/dist/utils/elements.d.ts +12 -0
- package/dist/utils/fsutils.d.ts +24 -0
- package/dist/utils/i18n.d.ts +8 -0
- package/dist/utils/ports.d.ts +8 -0
- package/dist/utils/rand.d.ts +10 -0
- package/dist/utils/url-path-params.d.ts +2 -0
- package/package.json +14 -15
- package/dist/chunk-4PO5HYET.js.map +0 -1
- package/dist/chunk-FQBA5QSG.js.map +0 -1
- package/dist/chunk-GSR74KEI.js.map +0 -1
- package/dist/chunk-JCRXBB26.js.map +0 -1
- package/dist/chunk-PVBPP5LN.js.map +0 -1
- package/dist/chunk-WAZTR3DX.js.map +0 -1
- package/dist/cli.d.ts +0 -60
- package/dist/core.d.ts +0 -214
- package/dist/functions.d.ts +0 -14
- package/dist/jsx.d.ts +0 -2
- package/dist/middleware.d.ts +0 -43
- package/dist/node.d.ts +0 -91
- package/dist/render.d.ts +0 -8
- package/dist/types-B-pJtsB4.d.ts +0 -827
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Vite plugin that removes 0-byte JS chunks from the build output and prunes
|
|
4
|
+
* the import statements that reference them.
|
|
5
|
+
*
|
|
6
|
+
* Tree-shaking (via rolldown/esbuild) can reduce a module to nothing — e.g. a
|
|
7
|
+
* type-only `.ts` file, or an entry whose contents are entirely eliminated.
|
|
8
|
+
* rolldown still emits a file for every explicit input, so these surface as
|
|
9
|
+
* 0-byte `.js` files in the build output. Worse, a sibling chunk may keep a
|
|
10
|
+
* bare side-effect import (`import "./<hash>.js"`) pointing at the empty file.
|
|
11
|
+
* If that empty file is removed without also removing the import, the import
|
|
12
|
+
* 404s at runtime and breaks the entire module graph.
|
|
13
|
+
*
|
|
14
|
+
* This plugin runs in `generateBundle` (before Vite's manifest plugin) and:
|
|
15
|
+
* 1. Detects chunks whose generated code is empty.
|
|
16
|
+
* 2. Skips any that still anchor CSS or asset references, so co-located
|
|
17
|
+
* styles are preserved (Vite keeps an empty JS chunk to carry the CSS
|
|
18
|
+
* link for a style-only module).
|
|
19
|
+
* 3. Strips bare side-effect imports of the empty chunks from sibling chunks.
|
|
20
|
+
* A 0-byte module exports nothing, so it can only be imported bare.
|
|
21
|
+
* 4. Deletes the empty chunks from the bundle.
|
|
22
|
+
*
|
|
23
|
+
* Because it runs before the manifest is emitted, the resulting
|
|
24
|
+
* `manifest.json` (consumed by Root's asset map) never references the removed
|
|
25
|
+
* files.
|
|
26
|
+
*/
|
|
27
|
+
export declare function pruneEmptyChunksPlugin(): Plugin;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
export interface PreactToRootJsxPluginOptions {
|
|
3
|
+
/** Whether Root's JSX renderer mode is enabled. */
|
|
4
|
+
useRootJsx?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Vite plugin that aliases `preact` imports to `@blinkk/root/jsx` in the SSR
|
|
8
|
+
* environment only.
|
|
9
|
+
*
|
|
10
|
+
* When `jsxRenderer.mode` is configured, the project uses Root's built-in JSX
|
|
11
|
+
* runtime instead of Preact for server-side rendering. This plugin redirects
|
|
12
|
+
* `preact` imports (`preact`, `preact/hooks`, `preact/jsx-runtime`, etc.) to
|
|
13
|
+
* Root's JSX package, but only in the SSR environment. Client-side code (e.g.
|
|
14
|
+
* islands that depend on real Preact for hydration) is left untouched.
|
|
15
|
+
*/
|
|
16
|
+
export declare function preactToRootJsxPlugin(options?: PreactToRootJsxPluginOptions): Plugin;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ViteDevServer } from 'vite';
|
|
2
|
+
import { RootConfig } from '../core/config.js';
|
|
3
|
+
export interface CreateViteServerOptions {
|
|
4
|
+
/** Override HMR settings. */
|
|
5
|
+
hmr?: boolean;
|
|
6
|
+
/** The port the server will run on. */
|
|
7
|
+
port?: number;
|
|
8
|
+
/** List of files to include in the optimizeDeps.include config. */
|
|
9
|
+
optimizeDeps?: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Returns a vite dev server.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createViteServer(rootConfig: RootConfig, options?: CreateViteServerOptions): Promise<ViteDevServer>;
|
|
15
|
+
/**
|
|
16
|
+
* Shortcut `viteServer.ssrLoadModule()` without starting an actual dev server.
|
|
17
|
+
*/
|
|
18
|
+
export declare function viteSsrLoadModule<T = Record<string, any>>(rootConfig: RootConfig, file: string): Promise<T>;
|
package/dist/node.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
loadRootConfig,
|
|
11
11
|
loadRootConfigWithDeps,
|
|
12
12
|
viteSsrLoadModule
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-7PSEEE6C.js";
|
|
14
14
|
import "./chunk-XSNCF7WU.js";
|
|
15
15
|
export {
|
|
16
16
|
bundleRootConfig,
|
|
@@ -25,4 +25,4 @@ export {
|
|
|
25
25
|
loadRootConfigWithDeps,
|
|
26
26
|
viteSsrLoadModule
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=node.js.map
|
|
28
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface Asset {
|
|
2
|
+
/**
|
|
3
|
+
* The path to the asset's src file, relative to the project root.
|
|
4
|
+
*/
|
|
5
|
+
src: string;
|
|
6
|
+
/**
|
|
7
|
+
* The serving URL for the asset.
|
|
8
|
+
*/
|
|
9
|
+
assetUrl: string;
|
|
10
|
+
/**
|
|
11
|
+
* Recursively walks all deps and returns a list of CSS asset URLs.
|
|
12
|
+
*/
|
|
13
|
+
getCssDeps(): Promise<string[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Recursively walks all deps and returns a list of JS asset URLs.
|
|
16
|
+
*/
|
|
17
|
+
getJsDeps(): Promise<string[]>;
|
|
18
|
+
}
|
|
19
|
+
export interface AssetMap {
|
|
20
|
+
/**
|
|
21
|
+
* Returns the asset for a given src file. The `src` value should be a path
|
|
22
|
+
* relative to the project root, e.g. "routes/index.tsx".
|
|
23
|
+
*/
|
|
24
|
+
get: (src: string) => Promise<Asset | null>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Manifest } from 'vite';
|
|
2
|
+
import { RootConfig } from '../../core/config.js';
|
|
3
|
+
import { ElementGraph } from '../../node/element-graph.js';
|
|
4
|
+
import { Asset, AssetMap } from './asset-map.js';
|
|
5
|
+
export type BuildAssetManifest = Record<string, {
|
|
6
|
+
src: string;
|
|
7
|
+
assetUrl: string;
|
|
8
|
+
importedModules: string[];
|
|
9
|
+
importedCss: string[];
|
|
10
|
+
isElement: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
export declare class BuildAssetMap implements AssetMap {
|
|
13
|
+
private rootConfig;
|
|
14
|
+
private srcToAsset;
|
|
15
|
+
constructor(rootConfig: RootConfig);
|
|
16
|
+
get(src: string): Promise<Asset | null>;
|
|
17
|
+
private add;
|
|
18
|
+
toJson(): BuildAssetManifest;
|
|
19
|
+
static fromViteManifest(rootConfig: RootConfig, clientManifest: Manifest, elementsGraph: ElementGraph): BuildAssetMap;
|
|
20
|
+
static fromRootManifest(rootConfig: RootConfig, rootManifest: BuildAssetManifest): BuildAssetMap;
|
|
21
|
+
}
|
|
22
|
+
export declare class BuildAsset {
|
|
23
|
+
src: string;
|
|
24
|
+
assetUrl: string;
|
|
25
|
+
private assetMap;
|
|
26
|
+
private importedModules;
|
|
27
|
+
private importedCss;
|
|
28
|
+
isElement: boolean;
|
|
29
|
+
constructor(assetMap: BuildAssetMap, assetData: {
|
|
30
|
+
src: string;
|
|
31
|
+
assetUrl: string;
|
|
32
|
+
importedModules: string[];
|
|
33
|
+
importedCss: string[];
|
|
34
|
+
isElement: boolean;
|
|
35
|
+
});
|
|
36
|
+
getCssDeps(): Promise<string[]>;
|
|
37
|
+
getJsDeps(): Promise<string[]>;
|
|
38
|
+
private collectJs;
|
|
39
|
+
private collectCss;
|
|
40
|
+
toJson(): {
|
|
41
|
+
src: string;
|
|
42
|
+
assetUrl: string;
|
|
43
|
+
importedModules: string[];
|
|
44
|
+
importedCss: string[];
|
|
45
|
+
isElement: boolean;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ModuleGraph, ModuleNode } from 'vite';
|
|
2
|
+
import { RootConfig } from '../../core/config.js';
|
|
3
|
+
import { Asset, AssetMap } from './asset-map.js';
|
|
4
|
+
export declare class DevServerAssetMap implements AssetMap {
|
|
5
|
+
private rootConfig;
|
|
6
|
+
private moduleGraph;
|
|
7
|
+
constructor(rootConfig: RootConfig, moduleGraph: ModuleGraph);
|
|
8
|
+
get(src: string): Promise<Asset | null>;
|
|
9
|
+
filePathToSrc(file: string): string;
|
|
10
|
+
}
|
|
11
|
+
export declare class DevServerAsset implements Asset {
|
|
12
|
+
src: string;
|
|
13
|
+
moduleId: string;
|
|
14
|
+
assetUrl: string;
|
|
15
|
+
private assetMap;
|
|
16
|
+
private viteModule;
|
|
17
|
+
constructor(src: string, options: {
|
|
18
|
+
assetMap: DevServerAssetMap;
|
|
19
|
+
viteModule: ModuleNode;
|
|
20
|
+
});
|
|
21
|
+
getCssDeps(): Promise<string[]>;
|
|
22
|
+
getJsDeps(): Promise<string[]>;
|
|
23
|
+
getImportedModules(): Set<ModuleNode>;
|
|
24
|
+
private collectJs;
|
|
25
|
+
private collectCss;
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface CountryLanguages {
|
|
2
|
+
code: string;
|
|
3
|
+
name: string;
|
|
4
|
+
languages: Language[];
|
|
5
|
+
langCultureMs?: Array<{
|
|
6
|
+
langCultureName: string;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
interface Language {
|
|
10
|
+
iso639_1: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function getCountryLanguageData(countryCode: string): CountryLanguages | null;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for handling requests that mimic the Firebase Hosting i18n
|
|
3
|
+
* fallback logic.
|
|
4
|
+
* https://firebase.google.com/docs/hosting/i18n-rewrites
|
|
5
|
+
*/
|
|
6
|
+
import { Request } from '../core/types.js';
|
|
7
|
+
export declare const UNKNOWN_COUNTRY = "zz";
|
|
8
|
+
export declare const ES_419_COUNTRIES: string[];
|
|
9
|
+
export declare function getFallbackLocales(req: Request): string[];
|
|
10
|
+
export declare function getCountry(req: Request): string;
|
|
11
|
+
export declare function test419Country(countryCode: string): boolean;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { RootConfig } from '../core/config.js';
|
|
2
|
+
import { Request, Response, NextFunction, Route, Sitemap } from '../core/types.js';
|
|
3
|
+
import type { ElementGraph } from '../node/element-graph.js';
|
|
4
|
+
import { AssetMap } from './asset-map/asset-map.js';
|
|
5
|
+
export declare class Renderer {
|
|
6
|
+
private rootConfig;
|
|
7
|
+
private assetMap;
|
|
8
|
+
private elementGraph;
|
|
9
|
+
private router;
|
|
10
|
+
constructor(rootConfig: RootConfig, options: {
|
|
11
|
+
assetMap: AssetMap;
|
|
12
|
+
elementGraph: ElementGraph;
|
|
13
|
+
});
|
|
14
|
+
/** Returns a route from the router. */
|
|
15
|
+
getRoute(url: string): [Route | undefined, Record<string, string>];
|
|
16
|
+
handle(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
17
|
+
private renderComponent;
|
|
18
|
+
/** SSG renders a route. */
|
|
19
|
+
renderRoute(route: Route, options: {
|
|
20
|
+
routeParams: Record<string, string>;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
html?: string;
|
|
23
|
+
notFound?: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
/** Handles the SSR rendering of a route. */
|
|
26
|
+
handleRoute(req: Request, res: Response, next: NextFunction, route: Route, options?: {
|
|
27
|
+
defaultStatusCode?: number;
|
|
28
|
+
/**
|
|
29
|
+
* URL placeholder params.
|
|
30
|
+
*/
|
|
31
|
+
routeParams?: Record<string, string>;
|
|
32
|
+
/**
|
|
33
|
+
* Handler function that tries the next matching route if multiple routes
|
|
34
|
+
* match for a given url path.
|
|
35
|
+
*/
|
|
36
|
+
nextRouteHandler?: () => void | Promise<void>;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Constructs and returns the project's sitemap.
|
|
40
|
+
*
|
|
41
|
+
* The sitemap is used to:
|
|
42
|
+
* - determine all paths to build in SSG mode
|
|
43
|
+
* - display links on the dev server's 404 page
|
|
44
|
+
* - construct alternates for localized URL paths
|
|
45
|
+
*/
|
|
46
|
+
getSitemap(): Promise<Sitemap>;
|
|
47
|
+
private getJsxRenderOptions;
|
|
48
|
+
/**
|
|
49
|
+
* Renders JSX via either the `@blinkk/root/jsx` package or
|
|
50
|
+
* `preact-render-to-string` depending if the `jsxRenderer` config is set up
|
|
51
|
+
* in `root.config.ts`.
|
|
52
|
+
*/
|
|
53
|
+
private renderJsx;
|
|
54
|
+
private getConfiguredStyleEntries;
|
|
55
|
+
private renderHtml;
|
|
56
|
+
private ensureNewline;
|
|
57
|
+
render404(options?: {
|
|
58
|
+
currentPath?: string;
|
|
59
|
+
}): Promise<{
|
|
60
|
+
html: string;
|
|
61
|
+
}>;
|
|
62
|
+
renderError(err: any, options?: {
|
|
63
|
+
currentPath?: string;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
html: string;
|
|
66
|
+
}>;
|
|
67
|
+
renderDevServer404(req: Request): Promise<{
|
|
68
|
+
html: string;
|
|
69
|
+
}>;
|
|
70
|
+
renderDevServer500(req: Request, error: unknown): Promise<{
|
|
71
|
+
html: string;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Parses rendered HTML for custom element tags used on the page and
|
|
75
|
+
* automatically adds the JS/CSS deps to the page.
|
|
76
|
+
*/
|
|
77
|
+
private collectElementDeps;
|
|
78
|
+
/**
|
|
79
|
+
* Returns the `security` config value with default values inserted wherever
|
|
80
|
+
* a user config value is blank or set to `true`.
|
|
81
|
+
*/
|
|
82
|
+
private getSecurityConfig;
|
|
83
|
+
/**
|
|
84
|
+
* Generates a random string that can be used as the "nonce" value for CSP.
|
|
85
|
+
*/
|
|
86
|
+
private generateNonce;
|
|
87
|
+
/**
|
|
88
|
+
* Sets security-related HTTP headers.
|
|
89
|
+
*/
|
|
90
|
+
private setSecurityHeaders;
|
|
91
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A trie data structure that stores routes. Supports Next-style routing using
|
|
3
|
+
* [param], [...catchall], and [[...optcatchall]] placeholders.
|
|
4
|
+
*/
|
|
5
|
+
export declare class RouteTrie<T> {
|
|
6
|
+
private children;
|
|
7
|
+
private paramNodes?;
|
|
8
|
+
private catchAllNodes?;
|
|
9
|
+
private optCatchAllNodes?;
|
|
10
|
+
private route?;
|
|
11
|
+
/**
|
|
12
|
+
* Adds a route to the trie.
|
|
13
|
+
*/
|
|
14
|
+
add(path: string, route: T): void;
|
|
15
|
+
/**
|
|
16
|
+
* Returns a route mapped to the given path and any parameter values from the
|
|
17
|
+
* URL.
|
|
18
|
+
*/
|
|
19
|
+
get(path: string): [T | undefined, Record<string, string>];
|
|
20
|
+
/**
|
|
21
|
+
* Returns all routes that match the given path and their parameter values.
|
|
22
|
+
*/
|
|
23
|
+
matchAll(path: string): Array<[T, Record<string, string>]>;
|
|
24
|
+
/**
|
|
25
|
+
* Walks the route trie and calls a callback function for each route.
|
|
26
|
+
*/
|
|
27
|
+
walk(cb: (urlPath: string, route: T) => Promise<void> | void): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Removes all routes from the trie.
|
|
30
|
+
*/
|
|
31
|
+
clear(): void;
|
|
32
|
+
private getRoute;
|
|
33
|
+
private collectRoutes;
|
|
34
|
+
/**
|
|
35
|
+
* Normalizes a path for inclusion into the route trie.
|
|
36
|
+
*/
|
|
37
|
+
private normalizePath;
|
|
38
|
+
/**
|
|
39
|
+
* Splits the parent directory from its children, e.g.:
|
|
40
|
+
*
|
|
41
|
+
* splitPath("foo/bar/baz") -> ["foo", "bar/baz"]
|
|
42
|
+
*/
|
|
43
|
+
private splitPath;
|
|
44
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RootConfig } from '../core/config.js';
|
|
2
|
+
import { Route } from '../core/types.js';
|
|
3
|
+
export declare class Router {
|
|
4
|
+
private rootConfig;
|
|
5
|
+
private routeTrie;
|
|
6
|
+
constructor(rootConfig: RootConfig);
|
|
7
|
+
get(url: string): [Route | undefined, Record<string, string>];
|
|
8
|
+
matchAll(url: string): [Route, Record<string, string>][];
|
|
9
|
+
walk(cb: (urlPath: string, route: Route) => void | Promise<void>): Promise<void>;
|
|
10
|
+
private initRouteTrie;
|
|
11
|
+
getAllPathsForRoute(urlPathFormat: string, route: Route): Promise<Array<{
|
|
12
|
+
urlPath: string;
|
|
13
|
+
params: Record<string, string>;
|
|
14
|
+
}>>;
|
|
15
|
+
}
|
|
16
|
+
export declare function normalizeUrlPath(urlPath: string, options?: {
|
|
17
|
+
trailingSlash?: boolean;
|
|
18
|
+
}): string;
|
package/dist/render.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
getTranslations,
|
|
6
6
|
replaceParams,
|
|
7
7
|
testPathHasParams
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KW7KTYGC.js";
|
|
9
9
|
import {
|
|
10
10
|
RouteTrie,
|
|
11
11
|
htmlMinify,
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
} from "./chunk-6P3B7ZXL.js";
|
|
15
15
|
import {
|
|
16
16
|
renderJsxToString
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-DU7JUEDY.js";
|
|
18
|
+
import "./chunk-3Z5TNZEP.js";
|
|
19
19
|
|
|
20
20
|
// src/render/render.tsx
|
|
21
|
-
import crypto from "crypto";
|
|
22
|
-
import path2 from "path";
|
|
21
|
+
import crypto from "node:crypto";
|
|
22
|
+
import path2 from "node:path";
|
|
23
23
|
import {
|
|
24
24
|
options as preactOptions
|
|
25
25
|
} from "preact";
|
|
@@ -12876,7 +12876,7 @@ function test419Country(countryCode) {
|
|
|
12876
12876
|
}
|
|
12877
12877
|
|
|
12878
12878
|
// src/render/router.ts
|
|
12879
|
-
import path from "path";
|
|
12879
|
+
import path from "node:path";
|
|
12880
12880
|
import { ROUTE_MODULES, POD_ROUTE_MODULES } from "virtual:root/routes";
|
|
12881
12881
|
var ROUTES_FILES = ROUTE_MODULES;
|
|
12882
12882
|
var POD_ROUTES = POD_ROUTE_MODULES || {};
|
|
@@ -13125,7 +13125,7 @@ var Renderer = class {
|
|
|
13125
13125
|
if (url.includes("%")) {
|
|
13126
13126
|
try {
|
|
13127
13127
|
url = decodeURI(url);
|
|
13128
|
-
} catch
|
|
13128
|
+
} catch {
|
|
13129
13129
|
}
|
|
13130
13130
|
}
|
|
13131
13131
|
const matches = this.router.matchAll(url);
|
|
@@ -13172,7 +13172,7 @@ var Renderer = class {
|
|
|
13172
13172
|
};
|
|
13173
13173
|
const vdom = /* @__PURE__ */ jsx4(REQUEST_CONTEXT.Provider, { value: ctx, children: /* @__PURE__ */ jsx4(I18N_CONTEXT.Provider, { value: { locale, translations }, children: /* @__PURE__ */ jsx4(HTML_CONTEXT.Provider, { value: htmlContext, children: /* @__PURE__ */ jsx4(Component, { ...props }) }) }) });
|
|
13174
13174
|
const preactHook = preactOptions.vnode;
|
|
13175
|
-
let mainHtml
|
|
13175
|
+
let mainHtml;
|
|
13176
13176
|
try {
|
|
13177
13177
|
preactOptions.vnode = (vnode) => {
|
|
13178
13178
|
if (vnode && vnode.type === "script") {
|
|
@@ -13793,4 +13793,4 @@ function guessContentType(ext) {
|
|
|
13793
13793
|
export {
|
|
13794
13794
|
Renderer
|
|
13795
13795
|
};
|
|
13796
|
-
//# sourceMappingURL=render.js.map
|
|
13796
|
+
//# sourceMappingURL=render.js.map
|