@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,285 @@
1
+ import { UserConfig as ViteUserConfig } from 'vite';
2
+ import { JsxRenderOptions } from '../jsx/jsx-render.js';
3
+ import { HtmlMinifyOptions } from '../render/html-minify.js';
4
+ import { HtmlPrettyOptions } from '../render/html-pretty.js';
5
+ import { Plugin } from './plugin.js';
6
+ import { PodConfig } from './pod.js';
7
+ import { RequestMiddleware } from './types.js';
8
+ export interface RootUserConfig {
9
+ /**
10
+ * Canonical domain the website will serve on. Useful for things like the
11
+ * sitemap, SEO tags, etc.
12
+ */
13
+ domain?: string;
14
+ /**
15
+ * The base URL path that the site will serve on. Defaults to `/`;
16
+ */
17
+ base?: string;
18
+ /**
19
+ * Config for auto-injecting custom element dependencies.
20
+ */
21
+ elements?: {
22
+ /**
23
+ * A list of directories to use to look for custom elements. The dir path
24
+ * should be relative to the project dir, e.g. "path/to/elements".
25
+ */
26
+ include?: string[];
27
+ /**
28
+ * A list of RegEx patterns to exclude. The string passed to the RegEx is
29
+ * the file URL relative to the project root, e.g. "/elements/foo/foo.ts".
30
+ */
31
+ exclude?: RegExp[];
32
+ };
33
+ /**
34
+ * Config for manually injecting stylesheet entries as
35
+ * `<link rel="stylesheet">` tags.
36
+ */
37
+ styles?: {
38
+ /**
39
+ * Project-root-relative stylesheet files to include on every rendered
40
+ * page, e.g. `styles/index.css`.
41
+ *
42
+ * Entries are normalized as URL paths, so both `styles/index.css` and
43
+ * `/styles/index.css` resolve to `/styles/index.css`.
44
+ *
45
+ * Manual entries are injected first, then auto-collected CSS
46
+ * dependencies are merged after. Duplicate URLs are de-duped so each
47
+ * stylesheet is only injected once.
48
+ */
49
+ entries?: string[];
50
+ };
51
+ /**
52
+ * Config options for localization and internationalization.
53
+ */
54
+ i18n?: RootI18nConfig;
55
+ /**
56
+ * Config options for the Root.js express server.
57
+ */
58
+ server?: RootServerConfig;
59
+ /**
60
+ * Build options for the `root build` command.
61
+ */
62
+ build?: RootBuildConfig;
63
+ /**
64
+ * Vite config.
65
+ * @see {@link https://vitejs.dev/config/} for more information.
66
+ */
67
+ vite?: ViteUserConfig;
68
+ /**
69
+ * Config for the built-in JSX-to-HTML renderer.
70
+ *
71
+ * - `mode: 'pretty'` (default) — block-level elements render on their own
72
+ * line with no indentation.
73
+ * - `mode: 'minimal'` — compact output with no extra whitespace.
74
+ *
75
+ * Use `blockElements` to specify additional custom element tag names that
76
+ * should be treated as block-level in pretty mode.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * export default defineConfig({
81
+ * jsxRenderer: {
82
+ * mode: 'pretty',
83
+ * blockElements: ['my-card', 'my-section'],
84
+ * },
85
+ * });
86
+ * ```
87
+ */
88
+ jsxRenderer?: JsxRenderOptions;
89
+ /**
90
+ * Whether to automatically minify HTML output. This is enabled by default,
91
+ * in order to disable, pass `minifyHtml: false` to root.config.ts.
92
+ */
93
+ minifyHtml?: boolean;
94
+ /**
95
+ * Options to pass to html-minifier-terser.
96
+ */
97
+ minifyHtmlOptions?: HtmlMinifyOptions;
98
+ /**
99
+ * Whether to pretty print HTML output.
100
+ */
101
+ prettyHtml?: boolean;
102
+ /**
103
+ * Options to pass to js-beautify.
104
+ */
105
+ prettyHtmlOptions?: HtmlPrettyOptions;
106
+ /**
107
+ * Whether to include a sitemap.xml file to the build output.
108
+ */
109
+ sitemap?: boolean;
110
+ /**
111
+ * Plugins.
112
+ */
113
+ plugins?: Plugin[];
114
+ /**
115
+ * Per-pod user-level overrides. The key is the pod name as declared in
116
+ * Pod.name.
117
+ */
118
+ pods?: Record<string, PodConfig>;
119
+ /**
120
+ * Experimental config options. Note: these are subject to change at any time.
121
+ */
122
+ experiments?: {
123
+ /** Whether to render `<script>` tags with `async`. */
124
+ enableScriptAsync?: boolean;
125
+ };
126
+ }
127
+ export type RootConfig = RootUserConfig & {
128
+ rootDir: string;
129
+ };
130
+ export interface LocaleGroup {
131
+ label?: string;
132
+ locales: string[];
133
+ }
134
+ export interface RootI18nConfig {
135
+ /**
136
+ * Locales enabled for the site.
137
+ */
138
+ locales?: string[];
139
+ /**
140
+ * The default locale to use. Defaults is `en`.
141
+ */
142
+ defaultLocale?: string;
143
+ /**
144
+ * URL format for localized content. Default is `/[locale]/[base]/[path]`.
145
+ */
146
+ urlFormat?: string;
147
+ /**
148
+ * Localization groups, to help UIs (like Root.js CMS) logically group
149
+ * locales.
150
+ */
151
+ groups?: Record<string, LocaleGroup>;
152
+ }
153
+ export interface RootBuildConfig {
154
+ /**
155
+ * Excludes the `/intl/{defaultLocale}/...` path from the SSG build.
156
+ */
157
+ excludeDefaultLocaleFromIntlPaths?: boolean;
158
+ }
159
+ export interface RootRedirectConfig {
160
+ /**
161
+ * The source path to redirect. Accepts placeholders in the format
162
+ * `[key]` or `[...key]`. Use `[key]` for single segments and
163
+ * `[...key]` for multi-segment wildcards.
164
+ * @example "/old-path/[id]" or "/old-path/[...wildcard]"
165
+ */
166
+ source: string;
167
+ /**
168
+ * The destination to redirect to. Placeholders from the source can
169
+ * optionally be inserted into the destination using the same
170
+ * placeholder format.
171
+ * @example "/new-path/[id]" or "/new-path/[...wildcard]"
172
+ */
173
+ destination: string;
174
+ /**
175
+ * The redirect type (`301` = permanent, `302` = temporary). If unspecified,
176
+ * defaults to `302` (temporary).
177
+ */
178
+ type?: 301 | 302;
179
+ }
180
+ export interface RootHeaderConfig {
181
+ /** A glob pattern match (regex not supported yet). */
182
+ source: string;
183
+ headers: Array<{
184
+ key: string;
185
+ value: string;
186
+ }>;
187
+ }
188
+ export interface ContentSecurityPolicyConfig {
189
+ directives?: Record<string, string[]>;
190
+ reportOnly?: boolean;
191
+ }
192
+ export interface XFrameOptionsConfig {
193
+ action: 'DENY' | 'SAMEORIGIN';
194
+ }
195
+ export interface RootSecurityConfig {
196
+ /**
197
+ * Content-Security-Policy config. If enabled, a nonce is auto-generated
198
+ * for every request and appended to script and stylesheet tags. You can
199
+ * validate your CSP headers using a tool like {@link https://csp-evaluator.withgoogle.com/}.
200
+ *
201
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP}
202
+ */
203
+ contentSecurityPolicy?: ContentSecurityPolicyConfig | boolean;
204
+ /**
205
+ * Strict-Transport-Security config. When enabled, the header value is set
206
+ * to `Strict-Transport-Security: max-age=63072000; includeSubDomains; preload`.
207
+ */
208
+ strictTransportSecurity?: boolean;
209
+ /**
210
+ * X-Content-Type-Options config. When enabled, the header value is set to
211
+ * `X-Content-Type-Options: nosniff`.
212
+ */
213
+ xContentTypeOptions?: boolean;
214
+ /**
215
+ * X-Frame-Options config. Setting this value to `true` will default the
216
+ * header value to `X-Frame-Options: SAMEORIGIN`.
217
+ *
218
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options}
219
+ */
220
+ xFrameOptions?: 'DENY' | 'SAMEORIGIN' | boolean;
221
+ /**
222
+ * X-XSS-Protection config. When enabled, the header value is set to
223
+ * `X-XSS-Protection: 1; mode=block`.
224
+ */
225
+ xXssProtection?: boolean;
226
+ }
227
+ export interface RootServerConfig {
228
+ /**
229
+ * An array of middleware to add to the express server. These middleware are
230
+ * added to the beginning of the express app.
231
+ */
232
+ middlewares?: RequestMiddleware[];
233
+ /**
234
+ * The `trailingSlash` config allows you to control how the server handles
235
+ * trailing slashes. This config only affects URLs that do not have a file
236
+ * extension (i.e. HTML paths).
237
+ *
238
+ * - When `true`, the server redirects URLs to add a trailing slash
239
+ * - When `false`, the server redirects URLs to remove a trailing slash
240
+ * - When unspecified, the server allows URLs with and without trailing slash
241
+ */
242
+ trailingSlash?: boolean;
243
+ /**
244
+ * Cookie secret for the session middleware.
245
+ *
246
+ * Generate a secure secret with:
247
+ * ```
248
+ * node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
249
+ * ```
250
+ */
251
+ sessionCookieSecret?: string | string[];
252
+ /**
253
+ * List of redirects. Supports optional wildcards.
254
+ *
255
+ * @example
256
+ * ```ts
257
+ * redirects: [
258
+ * {
259
+ * source: '/old-path/[id]',
260
+ * destination: '/new-path/[id]',
261
+ * type: 301,
262
+ * },
263
+ * {
264
+ * source: '/old-path/[...wildcard]',
265
+ * destination: '/new-path/[...wildcard]',
266
+ * },
267
+ * ]
268
+ * ```
269
+ */
270
+ redirects?: RootRedirectConfig[];
271
+ /**
272
+ * HTTP headers to add to a response.
273
+ */
274
+ headers?: RootHeaderConfig[];
275
+ /**
276
+ * HTTP security settings. By default, all security settings are enabled with
277
+ * commonly used default values.
278
+ */
279
+ security?: RootSecurityConfig;
280
+ /**
281
+ * Home page URL path, which is printed when the dev server starts.
282
+ */
283
+ homePagePath?: string;
284
+ }
285
+ export declare function defineConfig(config: RootUserConfig): RootUserConfig;
@@ -0,0 +1,14 @@
1
+ export * from './config.js';
2
+ export { Body } from './components/Body.js';
3
+ export { Head } from './components/Head.js';
4
+ export { Html, HTML_CONTEXT } from './components/Html.js';
5
+ export { Script } from './components/Script.js';
6
+ export { StringParamsContext, StringParamsProvider, useStringParams, } from './hooks/useStringParams.js';
7
+ export { TranslationMiddlewareProvider, useTranslationMiddleware, } from './hooks/useTranslationsMiddleware.js';
8
+ export { I18nContext, useI18nContext, getTranslations, } from './hooks/useI18nContext.js';
9
+ export { RequestContext, useRequestContext } from './hooks/useRequestContext.js';
10
+ export { useTranslations } from './hooks/useTranslations.js';
11
+ export * from './pod.js';
12
+ export * from './plugin.js';
13
+ export * from './types.js';
14
+ export * from '../utils/url-path-params.js';
@@ -0,0 +1,11 @@
1
+ export declare const I18N_CONTEXT: import("preact").Context<I18nContext | null>;
2
+ export interface I18nContext {
3
+ locale: string;
4
+ translations: Record<string, string>;
5
+ }
6
+ /**
7
+ * A hook that returns information about the current i18n context, including the
8
+ * locale for the given route and a map of translations for that locale.
9
+ */
10
+ export declare function useI18nContext(): I18nContext;
11
+ export declare function getTranslations(locale: string): Record<string, string>;
@@ -0,0 +1,36 @@
1
+ import { Route } from '../types.js';
2
+ export interface RequestContext {
3
+ /**
4
+ * The current request path, e.g. `/foo/bar` (default route path) or
5
+ * `/{locale}/foo/bar` (localized route path).
6
+ */
7
+ currentPath: string;
8
+ /** The route file. */
9
+ route: Route;
10
+ /**
11
+ * Route param values. E.g. for a route like `routes/blog/[slug].tsx`,
12
+ * visiting `/blog/foo` will pass {slug: 'foo'} here.
13
+ */
14
+ routeParams: Record<string, string>;
15
+ /** Props passed to the route's server component. */
16
+ props: any;
17
+ /** The current locale. */
18
+ locale: string;
19
+ /** Translations map for the current locale. */
20
+ translations: Record<string, string>;
21
+ /** CSP nonce value. */
22
+ nonce?: string;
23
+ }
24
+ export declare const REQUEST_CONTEXT: import("preact").Context<RequestContext | null>;
25
+ /**
26
+ * A hook that returns information about the current route.
27
+ *
28
+ * Usage:
29
+ *
30
+ * ```ts
31
+ * const ctx = useRequestContext();
32
+ * ctx.route.src;
33
+ * // => 'routes/index.tsx'
34
+ * ```
35
+ */
36
+ export declare function useRequestContext(): RequestContext;
@@ -0,0 +1,34 @@
1
+ import { ComponentChildren, FunctionalComponent } from 'preact';
2
+ export type StringParamsContext = Record<string, string>;
3
+ export declare const STRING_PARAMS_CONTEXT: import("preact").Context<StringParamsContext | null>;
4
+ export interface StringParamsProviderProps {
5
+ value?: StringParamsContext;
6
+ children?: ComponentChildren;
7
+ }
8
+ export declare const StringParamsProvider: FunctionalComponent<StringParamsProviderProps>;
9
+ /**
10
+ * A hook that returns a map of string params, configured via the
11
+ * `StringParamsProvider` context provider. These params are automatically
12
+ * applied to the `useTranslations()` hook.
13
+ *
14
+ *
15
+ * Usage:
16
+ *
17
+ * ```
18
+ * export default function Page() {
19
+ * return (
20
+ * <StringParamsProvider value={{name: 'Alice'}}>
21
+ * <SayHello />
22
+ * </StringParamsProvider>
23
+ * );
24
+ * }
25
+ *
26
+ * function SayHello() {
27
+ * const t = useTranslations();
28
+ * return <h1>{t('Hello, {name}!')}</h1>;
29
+ * }
30
+ * ```
31
+ *
32
+ * This should render `<h1>Hello, Alice!</h1>`.
33
+ */
34
+ export declare function useStringParams(): StringParamsContext;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A hook that returns a function that can be used to translate a string, and
3
+ * optionally replace any parameterized values that are surrounded in curly
4
+ * braces.
5
+ *
6
+ * Usage:
7
+ *
8
+ * ```ts
9
+ * const t = useTranslations();
10
+ * t('Hello {name}', {name: 'Bob'});
11
+ * // => 'Bounjour Bob'
12
+ * ```
13
+ */
14
+ export declare function useTranslations(): (str: string, params?: Record<string, string | number>) => string;
15
+ /**
16
+ * Cleans a string that's used for translations. Performs the following:
17
+ * - Removes any leading/trailing whitespace
18
+ * - Removes spaces at the end of any line
19
+ */
20
+ export declare function normalizeString(str: string): string;
@@ -0,0 +1,25 @@
1
+ import { ComponentChildren, FunctionalComponent } from 'preact';
2
+ type TransformFn = (str: string) => string;
3
+ export interface TranslationMiddleware {
4
+ /** Transform the string before translation lookup. */
5
+ beforeTranslate?: TransformFn;
6
+ /** Transform the string after translation lookup. */
7
+ afterTranslate?: TransformFn;
8
+ /** Transform the string before `{param}` values are replaced. */
9
+ beforeReplaceParams?: TransformFn;
10
+ /** Transform the string after `{param}` values are replaced. */
11
+ afterReplaceParams?: TransformFn;
12
+ }
13
+ export interface TranslationMiddlewareContext {
14
+ beforeTranslateFns: TransformFn[];
15
+ afterTranslateFns: TransformFn[];
16
+ beforeReplaceParamsFns: TransformFn[];
17
+ afterReplaceParamsFns: TransformFn[];
18
+ }
19
+ export interface TranslationMiddlewareProviderProps {
20
+ value?: TranslationMiddleware;
21
+ children?: ComponentChildren;
22
+ }
23
+ export declare const TranslationMiddlewareProvider: FunctionalComponent<TranslationMiddlewareProviderProps>;
24
+ export declare function useTranslationMiddleware(): TranslationMiddlewareContext;
25
+ export {};
@@ -0,0 +1,9 @@
1
+ import { Request, Route, RouteParams } from '../types.js';
2
+ interface DevErrorPageProps {
3
+ req: Request;
4
+ route?: Route;
5
+ routeParams?: RouteParams;
6
+ error: any;
7
+ }
8
+ export declare function DevErrorPage(props: DevErrorPageProps): import("preact").JSX.Element;
9
+ export {};
@@ -0,0 +1,10 @@
1
+ import { Request, Route } from '../types.js';
2
+ interface DevNotFoundPageProps {
3
+ req: Request;
4
+ sitemap: Record<string, {
5
+ route: Route;
6
+ params: Record<string, string>;
7
+ }>;
8
+ }
9
+ export declare function DevNotFoundPage(props: DevNotFoundPageProps): import("preact").JSX.Element;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ComponentChildren } from 'preact';
2
+ export interface ErrorPageProps {
3
+ code: number;
4
+ title?: string;
5
+ message?: string;
6
+ children?: ComponentChildren;
7
+ align?: 'center';
8
+ }
9
+ export declare function ErrorPage(props: ErrorPageProps): import("preact").JSX.Element;
@@ -0,0 +1,80 @@
1
+ import { PluginOption as VitePlugin } from 'vite';
2
+ import { RootConfig } from './config.js';
3
+ import { Pod, PodFactory } from './pod.js';
4
+ import { NextFunction, Request, Response, Server } from './types.js';
5
+ type MaybePromise<T> = T | Promise<T>;
6
+ type PreBuildHook = (rootConfig: RootConfig) => MaybePromise<void>;
7
+ export interface PostBuildOptions {
8
+ /** Whether the build was SSR-only (no SSG pre-rendering). */
9
+ ssrOnly?: boolean;
10
+ }
11
+ type PostBuildHook = (rootConfig: RootConfig, options?: PostBuildOptions) => MaybePromise<void>;
12
+ export type ConfigureServerHook = (server: Server, options: ConfigureServerOptions) => MaybePromise<void> | MaybePromise<() => void>;
13
+ export interface ConfigureServerOptions {
14
+ type: 'dev' | 'preview' | 'prod';
15
+ rootConfig: RootConfig;
16
+ }
17
+ export interface PluginHooks {
18
+ /**
19
+ * Hook that runs before the build starts.
20
+ */
21
+ preBuild?: PreBuildHook;
22
+ /**
23
+ * Hook that runs after the build completes.
24
+ */
25
+ postBuild?: PostBuildHook;
26
+ /**
27
+ * Post-render hook that's called before the HTML is rendered to the response
28
+ * object. If a string is returned from this hook, it will replace the
29
+ * rendered HTML.
30
+ */
31
+ preRender?: (html: string) => void | MaybePromise<string>;
32
+ }
33
+ export interface Plugin {
34
+ [key: string]: any;
35
+ /** The name of the plugin. */
36
+ name?: string;
37
+ /**
38
+ * Configures the root.js express server. Any middleware defined by the plugin
39
+ * will be added to the server first. If a callback fn is returned, it will
40
+ * be called after the root.js middlewares are added.
41
+ */
42
+ configureServer?: ConfigureServerHook;
43
+ /**
44
+ * Hook for file changes.
45
+ */
46
+ onFileChange?: (eventName: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', path: string) => void;
47
+ /**
48
+ * Returns a list of deps to bundle for ssr. The files will be bundled and
49
+ * output to `dist/server/`. The return value should be a map of
50
+ * `{output filename => input filepath}`.
51
+ *
52
+ * E.g. a value of `{foo: 'path/to/bar.js'}` will output `dist/server/foo.js`.
53
+ *
54
+ * @experimental This config is subject to change to be incorporated into a
55
+ * broader config option called "ssr" or "ssrOptions".
56
+ */
57
+ ssrInput?: () => {
58
+ [entryAlias: string]: string;
59
+ };
60
+ /** Adds vite plugins. */
61
+ vitePlugins?: VitePlugin[];
62
+ /** Plugin lifecycle callback hooks. */
63
+ hooks?: PluginHooks;
64
+ /** Custom 404 handler. */
65
+ handle404?: (req: Request, res: Response, next: NextFunction) => void | Promise<void>;
66
+ /**
67
+ * Registers a pod (a mini root.js site) that gets merged into the parent
68
+ * site at dev/build time. A plugin may return a single pod, an array of
69
+ * pods, or a factory that receives the rootConfig.
70
+ */
71
+ pod?: Pod | Pod[] | PodFactory;
72
+ }
73
+ /**
74
+ * Runs the pre-hook configureServer method of every plugin, calls a callback
75
+ * function, and then runs the configureServer's post-hook if provided. Plugins
76
+ * provide a post-hook by returning a callback function from configureServer.
77
+ */
78
+ export declare function configureServerPlugins(server: Server, callback: () => Promise<void>, plugins: Plugin[], options: ConfigureServerOptions): Promise<void>;
79
+ export declare function getVitePlugins(plugins: Plugin[]): VitePlugin[];
80
+ export {};
@@ -0,0 +1,54 @@
1
+ import { PluginOption as VitePlugin } from 'vite';
2
+ import { RootConfig } from './config.js';
3
+ export interface Pod {
4
+ /** Unique pod name, e.g. '@blinkk/root-docs-pod'. */
5
+ name: string;
6
+ /**
7
+ * URL prefix for pod routes. Routes within the pod are served under this
8
+ * mount path. Defaults to '/'.
9
+ */
10
+ mount?: string;
11
+ /**
12
+ * Priority for route conflict resolution. Higher values win when multiple
13
+ * pods register the same URL path. User-site routes always take precedence
14
+ * regardless of priority. Defaults to 0.
15
+ */
16
+ priority?: number;
17
+ /** Absolute path to the pod's routes/ directory. */
18
+ routesDir?: string;
19
+ /** Absolute path(s) to the pod's elements/ directory(s). */
20
+ elementsDirs?: string[];
21
+ /** Absolute path to the pod's bundles/ directory. */
22
+ bundlesDir?: string;
23
+ /** Absolute path to the pod's collections/ directory (root-cms only). */
24
+ collectionsDir?: string;
25
+ /** Absolute path to the pod's translations/ directory. */
26
+ translationsDir?: string;
27
+ /** Extra Vite plugins contributed by the pod. */
28
+ vitePlugins?: VitePlugin[];
29
+ }
30
+ export type PodFactory = (ctx: {
31
+ rootConfig: RootConfig;
32
+ }) => Pod | Promise<Pod>;
33
+ export interface PodConfig {
34
+ /** Whether the pod is enabled. Defaults to true. */
35
+ enabled?: boolean;
36
+ /** Override the pod's mount path. */
37
+ mount?: string;
38
+ /** Override the pod's priority. */
39
+ priority?: number;
40
+ /** Filter pod routes. */
41
+ routes?: {
42
+ exclude?: (string | RegExp)[];
43
+ };
44
+ /** Configure pod collections. */
45
+ collections?: {
46
+ exclude?: string[];
47
+ /** Rename collection ids, e.g. {Posts: 'DocsPosts'}. */
48
+ rename?: Record<string, string>;
49
+ };
50
+ }
51
+ /**
52
+ * Helper to define a pod with type-checking.
53
+ */
54
+ export declare function definePod(pod: Pod): Pod;