@blinkk/root 3.0.2 → 3.0.4

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 (123) hide show
  1. package/dist/{chunk-FQBA5QSG.js → chunk-3Z5TNZEP.js} +3 -3
  2. package/dist/chunk-3Z5TNZEP.js.map +7 -0
  3. package/dist/{chunk-JCRXBB26.js → chunk-6NBKAR5Y.js} +2 -2
  4. package/dist/chunk-6NBKAR5Y.js.map +7 -0
  5. package/dist/chunk-6P3B7ZXL.js +1 -1
  6. package/dist/chunk-6P3B7ZXL.js.map +7 -1
  7. package/dist/{chunk-PVBPP5LN.js → chunk-7PSEEE6C.js} +10 -10
  8. package/dist/chunk-7PSEEE6C.js.map +7 -0
  9. package/dist/{chunk-WAZTR3DX.js → chunk-KW7KTYGC.js} +2 -2
  10. package/dist/chunk-KW7KTYGC.js.map +7 -0
  11. package/dist/{chunk-GSR74KEI.js → chunk-URG2INLL.js} +1477 -85
  12. package/dist/chunk-URG2INLL.js.map +7 -0
  13. package/dist/{chunk-4PO5HYET.js → chunk-X2C2MEJ2.js} +39 -4
  14. package/dist/chunk-X2C2MEJ2.js.map +7 -0
  15. package/dist/chunk-XSNCF7WU.js +1 -1
  16. package/dist/chunk-XSNCF7WU.js.map +7 -1
  17. package/dist/cli/build.d.ts +7 -0
  18. package/dist/cli/cli.d.ts +12 -0
  19. package/dist/cli/codegen.d.ts +5 -0
  20. package/dist/cli/create-package.d.ts +14 -0
  21. package/dist/cli/dev.d.ts +10 -0
  22. package/dist/cli/gae-deploy.d.ts +18 -0
  23. package/dist/cli/preview.d.ts +8 -0
  24. package/dist/cli/secrets.d.ts +9 -0
  25. package/dist/cli/start.d.ts +8 -0
  26. package/dist/cli/startup/check-version.d.ts +17 -0
  27. package/dist/cli/startup/startup-tasks.d.ts +39 -0
  28. package/dist/cli.js +4 -4
  29. package/dist/cli.js.map +7 -1
  30. package/dist/core/components/Body.d.ts +23 -0
  31. package/dist/core/components/Head.d.ts +18 -0
  32. package/dist/core/components/Html.d.ts +24 -0
  33. package/dist/core/components/Script.d.ts +16 -0
  34. package/dist/core/config.d.ts +285 -0
  35. package/dist/core/core.d.ts +14 -0
  36. package/dist/core/hooks/useI18nContext.d.ts +11 -0
  37. package/dist/core/hooks/useRequestContext.d.ts +36 -0
  38. package/dist/core/hooks/useStringParams.d.ts +34 -0
  39. package/dist/core/hooks/useTranslations.d.ts +20 -0
  40. package/dist/core/hooks/useTranslationsMiddleware.d.ts +25 -0
  41. package/dist/core/pages/DevErrorPage.d.ts +9 -0
  42. package/dist/core/pages/DevNotFoundPage.d.ts +10 -0
  43. package/dist/core/pages/ErrorPage.d.ts +9 -0
  44. package/dist/core/plugin.d.ts +80 -0
  45. package/dist/core/pod.d.ts +54 -0
  46. package/dist/core/types.d.ts +228 -0
  47. package/dist/core.js +3 -3
  48. package/dist/core.js.map +7 -1
  49. package/dist/functions/functions.d.ts +1 -0
  50. package/dist/functions/server.d.ts +10 -0
  51. package/dist/functions.js +5 -5
  52. package/dist/functions.js.map +7 -1
  53. package/dist/jsx/jsx-dev-runtime.d.ts +10 -1
  54. package/dist/jsx/jsx-dev-runtime.js +2 -2
  55. package/dist/jsx/jsx-dev-runtime.js.map +7 -1
  56. package/dist/{jsx-C8cJO55i.d.ts → jsx/jsx-render.d.ts} +3 -6
  57. package/dist/jsx/jsx-runtime.d.ts +120 -1
  58. package/dist/jsx/jsx-runtime.js +2 -2
  59. package/dist/jsx/jsx-runtime.js.map +7 -1
  60. package/dist/jsx/jsx.d.ts +37 -0
  61. package/dist/{jsx-dev-runtime-DHf9jiFH.d.ts → jsx/types.d.ts} +8 -124
  62. package/dist/jsx.js +3 -3
  63. package/dist/jsx.js.map +7 -1
  64. package/dist/middleware/common.d.ts +22 -0
  65. package/dist/middleware/hooks.d.ts +8 -0
  66. package/dist/middleware/middleware.d.ts +3 -0
  67. package/dist/middleware/multipart.d.ts +11 -0
  68. package/dist/middleware/redirects.d.ts +10 -0
  69. package/dist/middleware/session.d.ts +24 -0
  70. package/dist/middleware.js +2 -2
  71. package/dist/middleware.js.map +7 -1
  72. package/dist/node/element-graph.d.ts +51 -0
  73. package/dist/node/load-config.d.ts +17 -0
  74. package/dist/node/monorepo.d.ts +14 -0
  75. package/dist/node/node.d.ts +4 -0
  76. package/dist/node/pod-collector.d.ts +33 -0
  77. package/dist/node/pods-vite-plugin.d.ts +6 -0
  78. package/dist/node/vite-plugin-preact-alias.d.ts +10 -0
  79. package/dist/node/vite-plugin-prune-empty-chunks.d.ts +27 -0
  80. package/dist/node/vite-plugin-root-jsx-virtual.d.ts +16 -0
  81. package/dist/node/vite.d.ts +18 -0
  82. package/dist/node.js +2 -2
  83. package/dist/node.js.map +7 -1
  84. package/dist/render/accept-language.d.ts +8 -0
  85. package/dist/render/asset-map/asset-map.d.ts +25 -0
  86. package/dist/render/asset-map/build-asset-map.d.ts +47 -0
  87. package/dist/render/asset-map/dev-asset-map.d.ts +26 -0
  88. package/dist/render/countrie-language.d.ts +13 -0
  89. package/dist/render/html-minify.d.ts +3 -0
  90. package/dist/render/html-pretty.d.ts +3 -0
  91. package/dist/render/i18n-fallbacks.d.ts +11 -0
  92. package/dist/render/render.d.ts +91 -0
  93. package/dist/render/route-trie.d.ts +44 -0
  94. package/dist/render/router.d.ts +18 -0
  95. package/dist/render.js +9 -9
  96. package/dist/render.js.map +7 -1
  97. package/dist/secrets/env-file.d.ts +44 -0
  98. package/dist/secrets/gcloud.d.ts +28 -0
  99. package/dist/secrets/hash.d.ts +11 -0
  100. package/dist/secrets/manifest.d.ts +60 -0
  101. package/dist/secrets/secrets.d.ts +118 -0
  102. package/dist/utils/batch.d.ts +1 -0
  103. package/dist/utils/elements.d.ts +12 -0
  104. package/dist/utils/fsutils.d.ts +24 -0
  105. package/dist/utils/i18n.d.ts +8 -0
  106. package/dist/utils/ports.d.ts +8 -0
  107. package/dist/utils/rand.d.ts +10 -0
  108. package/dist/utils/url-path-params.d.ts +2 -0
  109. package/package.json +14 -15
  110. package/dist/chunk-4PO5HYET.js.map +0 -1
  111. package/dist/chunk-FQBA5QSG.js.map +0 -1
  112. package/dist/chunk-GSR74KEI.js.map +0 -1
  113. package/dist/chunk-JCRXBB26.js.map +0 -1
  114. package/dist/chunk-PVBPP5LN.js.map +0 -1
  115. package/dist/chunk-WAZTR3DX.js.map +0 -1
  116. package/dist/cli.d.ts +0 -60
  117. package/dist/core.d.ts +0 -214
  118. package/dist/functions.d.ts +0 -14
  119. package/dist/jsx.d.ts +0 -2
  120. package/dist/middleware.d.ts +0 -43
  121. package/dist/node.d.ts +0 -91
  122. package/dist/render.d.ts +0 -8
  123. package/dist/types-B-pJtsB4.d.ts +0 -827
@@ -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,3 @@
1
+ import type { Options } from 'html-minifier-terser';
2
+ export type HtmlMinifyOptions = Options;
3
+ export declare function htmlMinify(html: string, options?: HtmlMinifyOptions): Promise<string>;
@@ -0,0 +1,3 @@
1
+ import type { HTMLBeautifyOptions } from 'js-beautify';
2
+ export type HtmlPrettyOptions = HTMLBeautifyOptions;
3
+ export declare function htmlPretty(html: string, options?: HtmlPrettyOptions): Promise<string>;
@@ -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-WAZTR3DX.js";
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-4PO5HYET.js";
18
- import "./chunk-FQBA5QSG.js";
17
+ } from "./chunk-X2C2MEJ2.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 (e) {
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