@blinkk/root 1.0.0-alpha.3 → 1.0.0-alpha.31
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/bin/root.js +27 -16
- package/dist/chunk-BCRXWKTP.js +156 -0
- package/dist/chunk-BCRXWKTP.js.map +1 -0
- package/dist/chunk-ZB7R6ZOY.js +31 -0
- package/dist/chunk-ZB7R6ZOY.js.map +1 -0
- package/dist/cli.d.ts +10 -4
- package/dist/cli.js +812 -207
- package/dist/cli.js.map +1 -1
- package/dist/config-0a9ae264.d.ts +232 -0
- package/dist/core.d.ts +52 -5
- package/dist/core.js +17 -1
- package/dist/core.js.map +1 -1
- package/dist/render.d.ts +5 -57
- package/dist/render.js +297 -117
- package/dist/render.js.map +1 -1
- package/package.json +20 -21
- package/dist/chunk-CDPH3RKE.js +0 -96
- package/dist/chunk-CDPH3RKE.js.map +0 -1
- package/dist/types-d6c0705e.d.ts +0 -27
package/bin/root.js
CHANGED
|
@@ -4,26 +4,37 @@ import {createRequire} from 'node:module';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import {fileURLToPath} from 'node:url';
|
|
6
6
|
import {Command} from 'commander';
|
|
7
|
-
import {build, dev, start} from '../dist/cli.js';
|
|
7
|
+
import {build, dev, preview, start} from '../dist/cli.js';
|
|
8
|
+
import {bgGreen, black} from 'kleur/colors';
|
|
8
9
|
|
|
9
10
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
11
|
const require = createRequire(import.meta.url);
|
|
11
12
|
const packageJson = require(path.join(__dirname, '../package.json'));
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
async function main() {
|
|
15
|
+
console.log(`🌱 ${bgGreen(black(' root.js '))} v${packageJson.version}`);
|
|
15
16
|
|
|
16
|
-
program
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
program
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
const program = new Command('root');
|
|
18
|
+
program.version(packageJson.version);
|
|
19
|
+
program
|
|
20
|
+
.command('build [path]')
|
|
21
|
+
.description('generates a static build')
|
|
22
|
+
.option('--ssr-only', 'produce a ssr-only build')
|
|
23
|
+
.option('--mode <mode>', 'see: https://vitejs.dev/guide/env-and-mode.html#modes', 'production')
|
|
24
|
+
.action(build);
|
|
25
|
+
program
|
|
26
|
+
.command('dev [path]')
|
|
27
|
+
.description('starts the server in development mode')
|
|
28
|
+
.action(dev);
|
|
29
|
+
program
|
|
30
|
+
.command('preview [path]')
|
|
31
|
+
.description('starts the server in preview mode')
|
|
32
|
+
.action(preview);
|
|
33
|
+
program
|
|
34
|
+
.command('start [path]')
|
|
35
|
+
.description('starts the server in production mode')
|
|
36
|
+
.action(start);
|
|
37
|
+
await program.parseAsync(process.argv);
|
|
38
|
+
}
|
|
28
39
|
|
|
29
|
-
|
|
40
|
+
main();
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// src/core/components/error-page.tsx
|
|
2
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
3
|
+
function ErrorPage(props) {
|
|
4
|
+
const error = props.error;
|
|
5
|
+
let message = void 0;
|
|
6
|
+
if (import.meta.env.DEV) {
|
|
7
|
+
if (error instanceof Error) {
|
|
8
|
+
message = error.stack;
|
|
9
|
+
} else {
|
|
10
|
+
message = String(error);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return /* @__PURE__ */ jsx("div", {
|
|
14
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
15
|
+
children: [
|
|
16
|
+
/* @__PURE__ */ jsx("p", {
|
|
17
|
+
children: "An error occured during route handling or page rendering."
|
|
18
|
+
}),
|
|
19
|
+
message && /* @__PURE__ */ jsx("pre", {
|
|
20
|
+
children: message
|
|
21
|
+
})
|
|
22
|
+
]
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// src/core/components/head.ts
|
|
28
|
+
import { createContext } from "preact";
|
|
29
|
+
import { useContext } from "preact/hooks";
|
|
30
|
+
var HEAD_CONTEXT = createContext([]);
|
|
31
|
+
function Head(props) {
|
|
32
|
+
let context;
|
|
33
|
+
try {
|
|
34
|
+
context = useContext(HEAD_CONTEXT);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
console.log(err);
|
|
37
|
+
throw new Error(
|
|
38
|
+
"<Head> component is not supported in the browser, or during suspense renders.",
|
|
39
|
+
{ cause: err }
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
context.push(props.children);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/core/components/html.tsx
|
|
47
|
+
import { createContext as createContext2 } from "preact";
|
|
48
|
+
import { useContext as useContext2 } from "preact/hooks";
|
|
49
|
+
import { Fragment, jsx as jsx2 } from "preact/jsx-runtime";
|
|
50
|
+
var HTML_CONTEXT = createContext2({ attrs: {} });
|
|
51
|
+
function Html({ children, ...attrs }) {
|
|
52
|
+
let context;
|
|
53
|
+
try {
|
|
54
|
+
context = useContext2(HTML_CONTEXT);
|
|
55
|
+
context.attrs = attrs;
|
|
56
|
+
} catch (err) {
|
|
57
|
+
console.log(err);
|
|
58
|
+
throw new Error(
|
|
59
|
+
"<Html> component is not supported in the browser, or during suspense renders.",
|
|
60
|
+
{ cause: err }
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return /* @__PURE__ */ jsx2(Fragment, {
|
|
64
|
+
children
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/core/components/script.ts
|
|
69
|
+
import { createContext as createContext3 } from "preact";
|
|
70
|
+
import { useContext as useContext3 } from "preact/hooks";
|
|
71
|
+
var SCRIPT_CONTEXT = createContext3([]);
|
|
72
|
+
function Script(props) {
|
|
73
|
+
let context;
|
|
74
|
+
try {
|
|
75
|
+
context = useContext3(SCRIPT_CONTEXT);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
"<Script> component is not supported in the browser, or during suspense renders.",
|
|
79
|
+
{ cause: err }
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
context.push(props);
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/core/i18n.ts
|
|
87
|
+
import path from "node:path";
|
|
88
|
+
import { createContext as createContext4 } from "preact";
|
|
89
|
+
import { useContext as useContext4 } from "preact/hooks";
|
|
90
|
+
var I18N_CONTEXT = createContext4(null);
|
|
91
|
+
function getTranslations(locale) {
|
|
92
|
+
const translations = {};
|
|
93
|
+
const translationsFiles = import.meta.glob(["/translations/*.json"], {
|
|
94
|
+
eager: true
|
|
95
|
+
});
|
|
96
|
+
Object.keys(translationsFiles).forEach((translationPath) => {
|
|
97
|
+
const parts = path.parse(translationPath);
|
|
98
|
+
const locale2 = parts.name;
|
|
99
|
+
const module = translationsFiles[translationPath];
|
|
100
|
+
if (module && module.default) {
|
|
101
|
+
translations[locale2] = module.default;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return translations[locale] || {};
|
|
105
|
+
}
|
|
106
|
+
function useI18nContext() {
|
|
107
|
+
const context = useContext4(I18N_CONTEXT);
|
|
108
|
+
if (!context) {
|
|
109
|
+
throw new Error("could not find i18n context");
|
|
110
|
+
}
|
|
111
|
+
return context;
|
|
112
|
+
}
|
|
113
|
+
function useTranslations() {
|
|
114
|
+
const context = useI18nContext();
|
|
115
|
+
const translations = context.translations || {};
|
|
116
|
+
const t = (str, params) => {
|
|
117
|
+
let translation = translations[str] || str || "";
|
|
118
|
+
if (params) {
|
|
119
|
+
for (const key of Object.keys(params)) {
|
|
120
|
+
const val = String(params[key] || "");
|
|
121
|
+
translation = translation.replaceAll(`{${key}}`, val);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return translation;
|
|
125
|
+
};
|
|
126
|
+
return t;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// src/core/request-context.ts
|
|
130
|
+
import { createContext as createContext5 } from "preact";
|
|
131
|
+
import { useContext as useContext5 } from "preact/hooks";
|
|
132
|
+
var REQUEST_CONTEXT = createContext5(null);
|
|
133
|
+
function useRequestContext() {
|
|
134
|
+
const context = useContext5(REQUEST_CONTEXT);
|
|
135
|
+
if (!context) {
|
|
136
|
+
throw new Error("could not find request context");
|
|
137
|
+
}
|
|
138
|
+
return context;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export {
|
|
142
|
+
ErrorPage,
|
|
143
|
+
HEAD_CONTEXT,
|
|
144
|
+
Head,
|
|
145
|
+
HTML_CONTEXT,
|
|
146
|
+
Html,
|
|
147
|
+
SCRIPT_CONTEXT,
|
|
148
|
+
Script,
|
|
149
|
+
I18N_CONTEXT,
|
|
150
|
+
getTranslations,
|
|
151
|
+
useI18nContext,
|
|
152
|
+
useTranslations,
|
|
153
|
+
REQUEST_CONTEXT,
|
|
154
|
+
useRequestContext
|
|
155
|
+
};
|
|
156
|
+
//# sourceMappingURL=chunk-BCRXWKTP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/components/error-page.tsx","../src/core/components/head.ts","../src/core/components/html.tsx","../src/core/components/script.ts","../src/core/i18n.ts","../src/core/request-context.ts"],"sourcesContent":["export interface ErrorPageProps {\n error: unknown;\n}\n\nexport function ErrorPage(props: ErrorPageProps) {\n const error = props.error;\n\n let message = undefined;\n if (import.meta.env.DEV) {\n if (error instanceof Error) {\n message = error.stack;\n } else {\n message = String(error);\n }\n }\n\n return (\n <div>\n <div>\n <p>An error occured during route handling or page rendering.</p>\n {message && <pre>{message}</pre>}\n </div>\n </div>\n );\n}\n","import {ComponentChildren, createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nexport const HEAD_CONTEXT = createContext<ComponentChildren[]>([]);\n\nexport interface HeadProps {\n children?: ComponentChildren;\n}\n\n/**\n * The <Head> component can be used for injecting elements into the HTML head\n * tag from any part of a page.\n */\nexport function Head(props: HeadProps) {\n let context: ComponentChildren[];\n try {\n context = useContext(HEAD_CONTEXT);\n } catch (err) {\n console.log(err);\n throw new Error(\n '<Head> component is not supported in the browser, or during suspense renders.',\n {cause: err}\n );\n }\n context.push(props.children);\n return null;\n}\n","import {ComponentChildren, createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nexport interface HtmlContextValue {\n attrs: Record<string, string>;\n}\n\nexport const HTML_CONTEXT = createContext<HtmlContextValue>({attrs: {}});\n\nexport type HtmlProps = preact.JSX.HTMLAttributes<HTMLHtmlElement> & {\n children?: ComponentChildren;\n};\n\n/**\n * The `<Html>` component can be used to update attrs used in the `<html>` tag.\n *\n * Usage:\n *\n * import {Html} from '@blinkk/root';\n *\n * export default function Page() {\n * return (\n * <Html lang={locale}>\n * <h1>Hello world</h1>\n * </Html>\n * );\n * }\n */\nexport function Html({children, ...attrs}: HtmlProps) {\n let context: Record<string, any>;\n try {\n context = useContext(HTML_CONTEXT);\n context.attrs = attrs;\n } catch (err) {\n console.log(err);\n throw new Error(\n '<Html> component is not supported in the browser, or during suspense renders.',\n {cause: err}\n );\n }\n return <>{children}</>;\n}\n","import {createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nexport const SCRIPT_CONTEXT = createContext<ScriptProps[]>([]);\n\nexport interface ScriptProps {\n src: string;\n type?: string;\n}\n\n/**\n * The <Script> component is used for rendering any custom script modules. At\n * the moment, the system only pre-renders and bundles files that are in the\n * `/bundles` folder at the root of the project.\n */\nexport function Script(props: ScriptProps) {\n let context: ScriptProps[];\n try {\n context = useContext(SCRIPT_CONTEXT);\n } catch (err) {\n throw new Error(\n '<Script> component is not supported in the browser, or during suspense renders.',\n {cause: err}\n );\n }\n context.push(props);\n return null;\n}\n","import path from 'node:path';\nimport {createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nexport const I18N_CONTEXT = createContext<I18nContext | null>(null);\n\nexport interface I18nContext {\n locale: string;\n translations: Record<string, string>;\n}\n\nexport function getTranslations(locale: string): Record<string, string> {\n const translations: Record<string, Record<string, string>> = {};\n const translationsFiles = import.meta.glob(['/translations/*.json'], {\n eager: true,\n }) as Record<string, {default?: Record<string, string>}>;\n Object.keys(translationsFiles).forEach((translationPath) => {\n const parts = path.parse(translationPath);\n const locale = parts.name;\n const module = translationsFiles[translationPath];\n if (module && module.default) {\n translations[locale] = module.default;\n }\n });\n return translations[locale] || {};\n}\n\nexport function useI18nContext() {\n const context = useContext(I18N_CONTEXT);\n if (!context) {\n throw new Error('could not find i18n context');\n }\n return context;\n}\n\nexport function useTranslations() {\n const context = useI18nContext();\n const translations = context.translations || {};\n const t = (str: string, params?: Record<string, string>) => {\n let translation = translations[str] || str || '';\n if (params) {\n for (const key of Object.keys(params)) {\n const val = String(params[key] || '');\n translation = translation.replaceAll(`{${key}}`, val);\n }\n }\n return translation;\n };\n return t;\n}\n","import {createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\nimport {Route} from '../render/router';\n\nexport interface RequestContext {\n /** The route file. */\n route: Route;\n /**\n * Route param values. E.g. for a route like `routes/blog/[slug].tsx`,\n * visiting `/blog/foo` will pass {slug: 'foo'} here.\n */\n routeParams: Record<string, string>;\n /** Props passed to the route's server component. */\n props: any;\n /** The current locale. */\n locale: string;\n /** Translations map for the current locale. */\n translations: Record<string, string>;\n}\n\nexport const REQUEST_CONTEXT = createContext<RequestContext | null>(null);\n\nexport function useRequestContext() {\n const context = useContext(REQUEST_CONTEXT);\n if (!context) {\n throw new Error('could not find request context');\n }\n return context;\n}\n"],"mappings":";AAkBM,SACE,KADF;AAdC,SAAS,UAAU,OAAuB;AAC/C,QAAM,QAAQ,MAAM;AAEpB,MAAI,UAAU;AACd,MAAI,YAAY,IAAI,KAAK;AACvB,QAAI,iBAAiB,OAAO;AAC1B,gBAAU,MAAM;AAAA,IAClB,OAAO;AACL,gBAAU,OAAO,KAAK;AAAA,IACxB;AAAA,EACF;AAEA,SACE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,SAAS;AACZ,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AACA,SAAO;AACT;","names":["createContext","useContext","jsx","createContext","useContext","createContext","useContext","locale","createContext","useContext"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/core/plugin.ts
|
|
2
|
+
async function configureServerPlugins(server, callback, plugins, options) {
|
|
3
|
+
const postHooks = [];
|
|
4
|
+
for (const plugin of plugins) {
|
|
5
|
+
if (plugin.configureServer) {
|
|
6
|
+
const postHook = await plugin.configureServer(server, options);
|
|
7
|
+
if (postHook) {
|
|
8
|
+
postHooks.push(postHook);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
callback();
|
|
13
|
+
for (const postHook of postHooks) {
|
|
14
|
+
await postHook();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function getVitePlugins(plugins) {
|
|
18
|
+
const vitePlugins = [];
|
|
19
|
+
for (const plugin of plugins) {
|
|
20
|
+
if (plugin.vitePlugins) {
|
|
21
|
+
vitePlugins.push(...plugin.vitePlugins);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return vitePlugins;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
configureServerPlugins,
|
|
29
|
+
getVitePlugins
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=chunk-ZB7R6ZOY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/plugin.ts"],"sourcesContent":["import {PluginOption as VitePlugin} from 'vite';\nimport {Server} from './types';\n\ntype MaybePromise<T> = T | Promise<T>;\n\nexport type ConfigureServerHook = (\n server: Server,\n options: ConfigureServerOptions\n) => MaybePromise<void> | MaybePromise<() => void>;\n\nexport interface ConfigureServerOptions {\n type: 'dev' | 'preview' | 'prod';\n}\n\nexport interface Plugin {\n name?: string;\n\n /** Configures the root.js express server . */\n configureServer?: ConfigureServerHook;\n\n /** Adds vite plugins. */\n vitePlugins?: VitePlugin[];\n}\n\n/**\n * Runs the pre-hook configureServer method of every plugin, calls a callback\n * function, and then runs the configureServer's post-hook if provided. Plugins\n * provide a post-hook by returning a callback function from configureServer.\n */\nexport async function configureServerPlugins(\n server: Server,\n callback: () => Promise<void>,\n plugins: Plugin[],\n options: ConfigureServerOptions\n) {\n const postHooks: Array<() => void> = [];\n\n // Call the `configureServer()` method for each plugin.\n for (const plugin of plugins) {\n if (plugin.configureServer) {\n const postHook = await plugin.configureServer(server, options);\n if (postHook) {\n postHooks.push(postHook);\n }\n }\n }\n\n // Register any built-in middleware.\n callback();\n\n // Run any post hooks returned by `plugin.configureServer()`.\n for (const postHook of postHooks) {\n await postHook();\n }\n}\n\nexport function getVitePlugins(plugins: Plugin[]): VitePlugin[] {\n const vitePlugins: VitePlugin[] = [];\n for (const plugin of plugins) {\n if (plugin.vitePlugins) {\n vitePlugins.push(...plugin.vitePlugins);\n }\n }\n return vitePlugins;\n}\n"],"mappings":";AA6BA,eAAsB,uBACpB,QACA,UACA,SACA,SACA;AACA,QAAM,YAA+B,CAAC;AAGtC,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,iBAAiB;AAC1B,YAAM,WAAW,MAAM,OAAO,gBAAgB,QAAQ,OAAO;AAC7D,UAAI,UAAU;AACZ,kBAAU,KAAK,QAAQ;AAAA,MACzB;AAAA,IACF;AAAA,EACF;AAGA,WAAS;AAGT,aAAW,YAAY,WAAW;AAChC,UAAM,SAAS;AAAA,EACjB;AACF;AAEO,SAAS,eAAe,SAAiC;AAC9D,QAAM,cAA4B,CAAC;AACnC,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,aAAa;AACtB,kBAAY,KAAK,GAAG,OAAO,WAAW;AAAA,IACxC;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
declare function dev(
|
|
1
|
+
declare function dev(rootProjectDir?: string): Promise<void>;
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface BuildOptions {
|
|
4
|
+
ssrOnly?: boolean;
|
|
5
|
+
mode?: string;
|
|
6
|
+
}
|
|
7
|
+
declare function build(rootProjectDir?: string, options?: BuildOptions): Promise<void>;
|
|
4
8
|
|
|
5
|
-
declare function
|
|
9
|
+
declare function preview(rootProjectDir?: string): Promise<void>;
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
declare function start(rootProjectDir?: string): Promise<void>;
|
|
12
|
+
|
|
13
|
+
export { build, dev, preview, start };
|