@blinkk/root 1.0.0-rc.2 → 1.0.0-rc.20
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-CY3DVKXO.js → chunk-4H7UTBRX.js} +126 -43
- package/dist/chunk-4H7UTBRX.js.map +1 -0
- package/dist/chunk-IUQLRDFW.js +237 -0
- package/dist/chunk-IUQLRDFW.js.map +1 -0
- package/dist/{chunk-J2ANSYAE.js → chunk-JH33OQEK.js} +64 -2
- package/dist/chunk-JH33OQEK.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +3 -3
- package/dist/core.d.ts +3 -3
- package/dist/core.js.map +1 -1
- package/dist/functions.d.ts +1 -1
- package/dist/functions.js +3 -3
- package/dist/middleware.d.ts +2 -2
- package/dist/node.d.ts +10 -2
- package/dist/node.js +5 -1
- package/dist/render.d.ts +1 -1
- package/dist/render.js +200 -266
- package/dist/render.js.map +1 -1
- package/dist/{types-9209ea89.d.ts → types-3pEO32yG.d.ts} +23 -8
- package/package.json +6 -6
- package/dist/chunk-CY3DVKXO.js.map +0 -1
- package/dist/chunk-DFBTOMQF.js +0 -61
- package/dist/chunk-DFBTOMQF.js.map +0 -1
- package/dist/chunk-J2ANSYAE.js.map +0 -1
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// src/utils/elements.ts
|
|
2
|
+
var ELEMENT_RE = /^[a-z][\w-]*-[\w-]*$/;
|
|
3
|
+
var HTML_ELEMENTS_REGEX = /<([a-z][\w-]*-[\w-]*)/g;
|
|
4
|
+
function isValidTagName(tagName) {
|
|
5
|
+
return ELEMENT_RE.test(tagName);
|
|
6
|
+
}
|
|
7
|
+
function parseTagNames(src) {
|
|
8
|
+
const tagNames = /* @__PURE__ */ new Set();
|
|
9
|
+
const matches = Array.from(src.matchAll(HTML_ELEMENTS_REGEX));
|
|
10
|
+
for (const match of matches) {
|
|
11
|
+
const tagName = match[1];
|
|
12
|
+
tagNames.add(tagName);
|
|
13
|
+
}
|
|
14
|
+
return Array.from(tagNames);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/render/html-minify.ts
|
|
18
|
+
import { createRequire } from "module";
|
|
19
|
+
var require2 = createRequire(import.meta.url);
|
|
20
|
+
var { minify } = require2("html-minifier-terser");
|
|
21
|
+
async function htmlMinify(html, options) {
|
|
22
|
+
const minifyOptions = options || {
|
|
23
|
+
collapseWhitespace: true,
|
|
24
|
+
removeComments: true,
|
|
25
|
+
preserveLineBreaks: true
|
|
26
|
+
};
|
|
27
|
+
try {
|
|
28
|
+
const min = await minify(html, minifyOptions);
|
|
29
|
+
return min.trimStart();
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.error("failed to minify html:", e);
|
|
32
|
+
return html;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/render/html-pretty.ts
|
|
37
|
+
import { createRequire as createRequire2 } from "module";
|
|
38
|
+
var require3 = createRequire2(import.meta.url);
|
|
39
|
+
var beautify = require3("js-beautify");
|
|
40
|
+
async function htmlPretty(html, options) {
|
|
41
|
+
const prettyOptions = options || {
|
|
42
|
+
indent_size: 0,
|
|
43
|
+
end_with_newline: true,
|
|
44
|
+
extra_liners: []
|
|
45
|
+
};
|
|
46
|
+
try {
|
|
47
|
+
const output = beautify.html(html, prettyOptions);
|
|
48
|
+
return output.trimStart();
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.error("failed to pretty html:", e);
|
|
51
|
+
return html;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/render/route-trie.ts
|
|
56
|
+
var RouteTrie = class _RouteTrie {
|
|
57
|
+
constructor() {
|
|
58
|
+
this.children = {};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Adds a route to the trie.
|
|
62
|
+
*/
|
|
63
|
+
add(path, route) {
|
|
64
|
+
path = this.normalizePath(path);
|
|
65
|
+
if (path === "") {
|
|
66
|
+
this.route = route;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const [head, tail] = this.splitPath(path);
|
|
70
|
+
if (head.startsWith("[[...") && head.endsWith("]]")) {
|
|
71
|
+
const paramName = head.slice(5, -2);
|
|
72
|
+
this.optCatchAllNodes = new CatchAllNode(paramName, route);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (head.startsWith("[...") && head.endsWith("]")) {
|
|
76
|
+
const paramName = head.slice(4, -1);
|
|
77
|
+
this.catchAllNodes = new CatchAllNode(paramName, route);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
let nextNode;
|
|
81
|
+
if (head.startsWith("[") && head.endsWith("]")) {
|
|
82
|
+
if (!this.paramNodes) {
|
|
83
|
+
this.paramNodes = {};
|
|
84
|
+
}
|
|
85
|
+
const paramName = head.slice(1, -1);
|
|
86
|
+
if (!this.paramNodes[paramName]) {
|
|
87
|
+
this.paramNodes[paramName] = new ParamNode(paramName);
|
|
88
|
+
}
|
|
89
|
+
nextNode = this.paramNodes[paramName].trie;
|
|
90
|
+
} else {
|
|
91
|
+
nextNode = this.children[head];
|
|
92
|
+
if (!nextNode) {
|
|
93
|
+
nextNode = new _RouteTrie();
|
|
94
|
+
this.children[head] = nextNode;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
nextNode.add(tail, route);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns a route mapped to the given path and any parameter values from the
|
|
101
|
+
* URL.
|
|
102
|
+
*/
|
|
103
|
+
get(path) {
|
|
104
|
+
const params = {};
|
|
105
|
+
const route = this.getRoute(path, params);
|
|
106
|
+
return [route, params];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Walks the route trie and calls a callback function for each route.
|
|
110
|
+
*/
|
|
111
|
+
walk(cb) {
|
|
112
|
+
const promises = [];
|
|
113
|
+
const addPromise = (promise) => {
|
|
114
|
+
if (promise) {
|
|
115
|
+
promises.push(promise);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
if (this.route) {
|
|
119
|
+
addPromise(cb("/", this.route));
|
|
120
|
+
}
|
|
121
|
+
if (this.paramNodes) {
|
|
122
|
+
Object.values(this.paramNodes).forEach((paramChild) => {
|
|
123
|
+
const param = `[${paramChild.name}]`;
|
|
124
|
+
paramChild.trie.walk((childPath, route) => {
|
|
125
|
+
const paramUrlPath = `/${param}${childPath}`;
|
|
126
|
+
addPromise(cb(paramUrlPath, route));
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (this.catchAllNodes) {
|
|
131
|
+
const wildcardUrlPath = `/[...${this.catchAllNodes.name}]`;
|
|
132
|
+
addPromise(cb(wildcardUrlPath, this.catchAllNodes.route));
|
|
133
|
+
}
|
|
134
|
+
if (this.optCatchAllNodes) {
|
|
135
|
+
const wildcardUrlPath = `/[[...${this.optCatchAllNodes.name}]]`;
|
|
136
|
+
addPromise(cb(wildcardUrlPath, this.optCatchAllNodes.route));
|
|
137
|
+
}
|
|
138
|
+
for (const subpath of Object.keys(this.children)) {
|
|
139
|
+
const childTrie = this.children[subpath];
|
|
140
|
+
childTrie.walk((childPath, childRoute) => {
|
|
141
|
+
addPromise(cb(`/${subpath}${childPath}`, childRoute));
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return Promise.all(promises).then(() => {
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Removes all routes from the trie.
|
|
149
|
+
*/
|
|
150
|
+
clear() {
|
|
151
|
+
this.children = {};
|
|
152
|
+
this.paramNodes = void 0;
|
|
153
|
+
this.catchAllNodes = void 0;
|
|
154
|
+
this.optCatchAllNodes = void 0;
|
|
155
|
+
this.route = void 0;
|
|
156
|
+
}
|
|
157
|
+
getRoute(urlPath, params) {
|
|
158
|
+
urlPath = this.normalizePath(urlPath);
|
|
159
|
+
if (urlPath === "") {
|
|
160
|
+
if (this.route) {
|
|
161
|
+
return this.route;
|
|
162
|
+
}
|
|
163
|
+
if (this.optCatchAllNodes) {
|
|
164
|
+
if (urlPath) {
|
|
165
|
+
params[this.optCatchAllNodes.name] = urlPath;
|
|
166
|
+
}
|
|
167
|
+
return this.optCatchAllNodes.route;
|
|
168
|
+
}
|
|
169
|
+
return void 0;
|
|
170
|
+
}
|
|
171
|
+
const [head, tail] = this.splitPath(urlPath);
|
|
172
|
+
const child = this.children[head];
|
|
173
|
+
if (child) {
|
|
174
|
+
const route = child.getRoute(tail, params);
|
|
175
|
+
if (route) {
|
|
176
|
+
return route;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (this.paramNodes) {
|
|
180
|
+
for (const paramChild of Object.values(this.paramNodes)) {
|
|
181
|
+
const route = paramChild.trie.getRoute(tail, params);
|
|
182
|
+
if (route) {
|
|
183
|
+
params[paramChild.name] = head;
|
|
184
|
+
return route;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (this.catchAllNodes) {
|
|
189
|
+
params[this.catchAllNodes.name] = urlPath;
|
|
190
|
+
return this.catchAllNodes.route;
|
|
191
|
+
}
|
|
192
|
+
if (this.optCatchAllNodes) {
|
|
193
|
+
params[this.optCatchAllNodes.name] = urlPath;
|
|
194
|
+
return this.optCatchAllNodes.route;
|
|
195
|
+
}
|
|
196
|
+
return void 0;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Normalizes a path for inclusion into the route trie.
|
|
200
|
+
*/
|
|
201
|
+
normalizePath(path) {
|
|
202
|
+
return path.replace(/^\/+/g, "").replace(/\/+$/g, "");
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Splits the parent directory from its children, e.g.:
|
|
206
|
+
*
|
|
207
|
+
* splitPath("foo/bar/baz") -> ["foo", "bar/baz"]
|
|
208
|
+
*/
|
|
209
|
+
splitPath(path) {
|
|
210
|
+
const i = path.indexOf("/");
|
|
211
|
+
if (i === -1) {
|
|
212
|
+
return [path, ""];
|
|
213
|
+
}
|
|
214
|
+
return [path.slice(0, i), path.slice(i + 1)];
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
var ParamNode = class {
|
|
218
|
+
constructor(name) {
|
|
219
|
+
this.trie = new RouteTrie();
|
|
220
|
+
this.name = name;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
var CatchAllNode = class {
|
|
224
|
+
constructor(name, route) {
|
|
225
|
+
this.name = name;
|
|
226
|
+
this.route = route;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export {
|
|
231
|
+
isValidTagName,
|
|
232
|
+
parseTagNames,
|
|
233
|
+
htmlMinify,
|
|
234
|
+
htmlPretty,
|
|
235
|
+
RouteTrie
|
|
236
|
+
};
|
|
237
|
+
//# sourceMappingURL=chunk-IUQLRDFW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/elements.ts","../src/render/html-minify.ts","../src/render/html-pretty.ts","../src/render/route-trie.ts"],"sourcesContent":["export const ELEMENT_RE = /^[a-z][\\w-]*-[\\w-]*$/;\nexport const HTML_ELEMENTS_REGEX = /<([a-z][\\w-]*-[\\w-]*)/g;\n\n/**\n * Returns true if the tagName is a valid custom element tag.\n */\nexport function isValidTagName(tagName: string) {\n return ELEMENT_RE.test(tagName);\n}\n\n/**\n * Returns a list of custom elements used in a src string (e.g. HTML, jsx, lit).\n * NOTE: the impl uses a simple regex, so tagNames used in comments and attr\n * values may be included.\n */\nexport function parseTagNames(src: string): string[] {\n const tagNames = new Set<string>();\n const matches = Array.from(src.matchAll(HTML_ELEMENTS_REGEX));\n for (const match of matches) {\n const tagName = match[1];\n tagNames.add(tagName);\n }\n return Array.from(tagNames);\n}\n","import {createRequire} from 'module';\n\nconst require = createRequire(import.meta.url);\nimport type {Options} from 'html-minifier-terser';\n\nconst {minify} = require('html-minifier-terser');\n\nexport type HtmlMinifyOptions = Options;\n\nexport async function htmlMinify(\n html: string,\n options?: HtmlMinifyOptions\n): Promise<string> {\n const minifyOptions = options || {\n collapseWhitespace: true,\n removeComments: true,\n preserveLineBreaks: true,\n };\n try {\n const min = await minify(html, minifyOptions);\n return min.trimStart();\n } catch (e) {\n console.error('failed to minify html:', e);\n return html;\n }\n}\n","import {createRequire} from 'module';\n\nconst require = createRequire(import.meta.url);\nimport type {HTMLBeautifyOptions} from 'js-beautify';\n\nconst beautify = require('js-beautify');\n\nexport type HtmlPrettyOptions = HTMLBeautifyOptions;\n\nexport async function htmlPretty(\n html: string,\n options?: HtmlPrettyOptions\n): Promise<string> {\n const prettyOptions = options || {\n indent_size: 0,\n end_with_newline: true,\n extra_liners: [],\n };\n try {\n const output = beautify.html(html, prettyOptions);\n return output.trimStart();\n } catch (e) {\n console.error('failed to pretty html:', e);\n return html;\n }\n}\n","/**\n * A trie data structure that stores routes. Supports Next-style routing using\n * [param], [...catchall], and [[...optcatchall]] placeholders.\n */\nexport class RouteTrie<T> {\n private children: Record<string, RouteTrie<T>> = {};\n private paramNodes?: {[param: string]: ParamNode<T>};\n private catchAllNodes?: CatchAllNode<T>;\n private optCatchAllNodes?: CatchAllNode<T>;\n private route?: T;\n\n /**\n * Adds a route to the trie.\n */\n add(path: string, route: T) {\n path = this.normalizePath(path);\n\n // If the end was reached, save the value to the node.\n if (path === '') {\n this.route = route;\n return;\n }\n\n const [head, tail] = this.splitPath(path);\n\n if (head.startsWith('[[...') && head.endsWith(']]')) {\n const paramName = head.slice(5, -2);\n this.optCatchAllNodes = new CatchAllNode(paramName, route);\n return;\n }\n if (head.startsWith('[...') && head.endsWith(']')) {\n const paramName = head.slice(4, -1);\n this.catchAllNodes = new CatchAllNode(paramName, route);\n return;\n }\n\n let nextNode: RouteTrie<T>;\n if (head.startsWith('[') && head.endsWith(']')) {\n if (!this.paramNodes) {\n this.paramNodes = {};\n }\n const paramName = head.slice(1, -1);\n if (!this.paramNodes[paramName]) {\n this.paramNodes[paramName] = new ParamNode(paramName);\n }\n nextNode = this.paramNodes[paramName].trie;\n } else {\n nextNode = this.children[head];\n if (!nextNode) {\n nextNode = new RouteTrie();\n this.children[head] = nextNode;\n }\n }\n nextNode.add(tail, route);\n }\n\n /**\n * Returns a route mapped to the given path and any parameter values from the\n * URL.\n */\n get(path: string): [T | undefined, Record<string, string>] {\n const params = {};\n const route = this.getRoute(path, params);\n return [route, params];\n }\n\n /**\n * Walks the route trie and calls a callback function for each route.\n */\n walk(cb: (urlPath: string, route: T) => Promise<void> | void): Promise<void> {\n const promises: Array<Promise<void>> = [];\n const addPromise = (promise: Promise<void> | void) => {\n if (promise) {\n promises.push(promise);\n }\n };\n if (this.route) {\n addPromise(cb('/', this.route));\n }\n if (this.paramNodes) {\n Object.values(this.paramNodes).forEach((paramChild) => {\n const param = `[${paramChild.name}]`;\n paramChild.trie.walk((childPath: string, route: T) => {\n const paramUrlPath = `/${param}${childPath}`;\n addPromise(cb(paramUrlPath, route));\n });\n });\n }\n if (this.catchAllNodes) {\n const wildcardUrlPath = `/[...${this.catchAllNodes.name}]`;\n addPromise(cb(wildcardUrlPath, this.catchAllNodes.route));\n }\n if (this.optCatchAllNodes) {\n const wildcardUrlPath = `/[[...${this.optCatchAllNodes.name}]]`;\n addPromise(cb(wildcardUrlPath, this.optCatchAllNodes.route));\n }\n for (const subpath of Object.keys(this.children)) {\n const childTrie = this.children[subpath];\n childTrie.walk((childPath: string, childRoute: T) => {\n addPromise(cb(`/${subpath}${childPath}`, childRoute));\n });\n }\n return Promise.all(promises).then(() => {});\n }\n\n /**\n * Removes all routes from the trie.\n */\n clear() {\n this.children = {};\n this.paramNodes = undefined;\n this.catchAllNodes = undefined;\n this.optCatchAllNodes = undefined;\n this.route = undefined;\n }\n\n private getRoute(\n urlPath: string,\n params: Record<string, string>\n ): T | undefined {\n urlPath = this.normalizePath(urlPath);\n if (urlPath === '') {\n if (this.route) {\n return this.route;\n }\n if (this.optCatchAllNodes) {\n if (urlPath) {\n params[this.optCatchAllNodes.name] = urlPath;\n }\n return this.optCatchAllNodes.route;\n }\n return undefined;\n }\n\n const [head, tail] = this.splitPath(urlPath);\n\n const child = this.children[head];\n if (child) {\n const route = child.getRoute(tail, params);\n if (route) {\n return route;\n }\n }\n\n if (this.paramNodes) {\n for (const paramChild of Object.values(this.paramNodes)) {\n const route = paramChild.trie.getRoute(tail, params);\n if (route) {\n params[paramChild.name] = head;\n return route;\n }\n }\n }\n\n if (this.catchAllNodes) {\n params[this.catchAllNodes.name] = urlPath;\n return this.catchAllNodes.route;\n }\n\n if (this.optCatchAllNodes) {\n params[this.optCatchAllNodes.name] = urlPath;\n return this.optCatchAllNodes.route;\n }\n\n return undefined;\n }\n\n /**\n * Normalizes a path for inclusion into the route trie.\n */\n private normalizePath(path: string) {\n // Remove leading/trailing slashes.\n return path.replace(/^\\/+/g, '').replace(/\\/+$/g, '');\n }\n\n /**\n * Splits the parent directory from its children, e.g.:\n *\n * splitPath(\"foo/bar/baz\") -> [\"foo\", \"bar/baz\"]\n */\n private splitPath(path: string): [string, string] {\n const i = path.indexOf('/');\n if (i === -1) {\n return [path, ''];\n }\n return [path.slice(0, i), path.slice(i + 1)];\n }\n}\n\n/**\n * A node in the RouteTrie for a :param child.\n */\nclass ParamNode<T> {\n readonly name: string;\n readonly trie: RouteTrie<T> = new RouteTrie();\n\n constructor(name: string) {\n this.name = name;\n }\n}\n\n/**\n * A node in the RouteTrie for a *wildcard child.\n */\nclass CatchAllNode<T> {\n readonly name: string;\n readonly route: T;\n\n constructor(name: string, route: T) {\n this.name = name;\n this.route = route;\n }\n}\n"],"mappings":";AAAO,IAAM,aAAa;AACnB,IAAM,sBAAsB;AAK5B,SAAS,eAAe,SAAiB;AAC9C,SAAO,WAAW,KAAK,OAAO;AAChC;AAOO,SAAS,cAAc,KAAuB;AACnD,QAAM,WAAW,oBAAI,IAAY;AACjC,QAAM,UAAU,MAAM,KAAK,IAAI,SAAS,mBAAmB,CAAC;AAC5D,aAAW,SAAS,SAAS;AAC3B,UAAM,UAAU,MAAM,CAAC;AACv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":["require","createRequire","require"]}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
// src/node/load-config.ts
|
|
6
6
|
import path2 from "node:path";
|
|
7
7
|
import { bundleRequire } from "bundle-require";
|
|
8
|
+
import { build } from "esbuild";
|
|
8
9
|
|
|
9
10
|
// src/utils/fsutils.ts
|
|
10
11
|
import { promises as fs } from "node:fs";
|
|
@@ -89,6 +90,52 @@ async function loadRootConfig(rootDir, options) {
|
|
|
89
90
|
}
|
|
90
91
|
return Object.assign({}, config, { rootDir });
|
|
91
92
|
}
|
|
93
|
+
async function bundleRootConfig(rootDir, outPath) {
|
|
94
|
+
const configPath = path2.resolve(rootDir, "root.config.ts");
|
|
95
|
+
const exists = await fileExists(configPath);
|
|
96
|
+
if (!exists) {
|
|
97
|
+
throw new Error(`${configPath} does not exist`);
|
|
98
|
+
}
|
|
99
|
+
await build({
|
|
100
|
+
entryPoints: [configPath],
|
|
101
|
+
bundle: true,
|
|
102
|
+
minify: true,
|
|
103
|
+
platform: "node",
|
|
104
|
+
outfile: outPath,
|
|
105
|
+
sourcemap: "inline",
|
|
106
|
+
metafile: true,
|
|
107
|
+
format: "esm",
|
|
108
|
+
plugins: [
|
|
109
|
+
{
|
|
110
|
+
name: "externalize-deps",
|
|
111
|
+
setup(build2) {
|
|
112
|
+
build2.onResolve({ filter: /.*/ }, (args) => {
|
|
113
|
+
const id = args.path;
|
|
114
|
+
if (id[0] !== "." && !path2.isAbsolute(id)) {
|
|
115
|
+
return {
|
|
116
|
+
external: true
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
async function loadBundledConfig(rootDir, options) {
|
|
127
|
+
const configPath = path2.resolve(rootDir, "dist/root.config.js");
|
|
128
|
+
const exists = await fileExists(configPath);
|
|
129
|
+
if (!exists) {
|
|
130
|
+
throw new Error(`${configPath} does not exist`);
|
|
131
|
+
}
|
|
132
|
+
const module = await import(configPath);
|
|
133
|
+
let config = module.default || {};
|
|
134
|
+
if (typeof config === "function") {
|
|
135
|
+
config = await config(options) || {};
|
|
136
|
+
}
|
|
137
|
+
return Object.assign({}, config, { rootDir });
|
|
138
|
+
}
|
|
92
139
|
|
|
93
140
|
// src/node/vite.ts
|
|
94
141
|
import { createServer } from "vite";
|
|
@@ -117,6 +164,19 @@ async function createViteServer(rootConfig, options) {
|
|
|
117
164
|
},
|
|
118
165
|
appType: "custom",
|
|
119
166
|
optimizeDeps: {
|
|
167
|
+
// As of vite v5 / esbuild v19, experimentalDecorators need to be
|
|
168
|
+
// explicitly set, and for some reason this option isn't read from the
|
|
169
|
+
// project's tsconfig.json file by default.
|
|
170
|
+
// See: https://vitejs.dev/blog/announcing-vite5
|
|
171
|
+
esbuildOptions: {
|
|
172
|
+
tsconfigRaw: {
|
|
173
|
+
compilerOptions: {
|
|
174
|
+
target: "esnext",
|
|
175
|
+
experimentalDecorators: true,
|
|
176
|
+
useDefineForClassFields: false
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
120
180
|
...viteConfig.optimizeDeps || {},
|
|
121
181
|
include: [
|
|
122
182
|
...(options == null ? void 0 : options.optimizeDeps) || [],
|
|
@@ -126,7 +186,7 @@ async function createViteServer(rootConfig, options) {
|
|
|
126
186
|
},
|
|
127
187
|
ssr: {
|
|
128
188
|
...viteConfig.ssr || {},
|
|
129
|
-
noExternal: ["@blinkk/root"]
|
|
189
|
+
noExternal: ["@blinkk/root", "@blinkk/root-cms/richtext"]
|
|
130
190
|
},
|
|
131
191
|
esbuild: {
|
|
132
192
|
...viteConfig.esbuild || {},
|
|
@@ -159,7 +219,9 @@ export {
|
|
|
159
219
|
dirExists,
|
|
160
220
|
directoryContains,
|
|
161
221
|
loadRootConfig,
|
|
222
|
+
bundleRootConfig,
|
|
223
|
+
loadBundledConfig,
|
|
162
224
|
createViteServer,
|
|
163
225
|
viteSsrLoadModule
|
|
164
226
|
};
|
|
165
|
-
//# sourceMappingURL=chunk-
|
|
227
|
+
//# sourceMappingURL=chunk-JH33OQEK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node/load-config.ts","../src/utils/fsutils.ts","../src/node/vite.ts"],"sourcesContent":["import path from 'node:path';\nimport {bundleRequire} from 'bundle-require';\nimport {build} from 'esbuild';\nimport {RootConfig} from '../core/config';\nimport {fileExists} from '../utils/fsutils';\n\nexport interface ConfigOptions {\n command: string;\n}\n\nexport async function loadRootConfig(\n rootDir: string,\n options: ConfigOptions\n): Promise<RootConfig> {\n const configPath = path.resolve(rootDir, 'root.config.ts');\n const exists = await fileExists(configPath);\n if (!exists) {\n throw new Error(`${configPath} does not exist`);\n }\n const configBundle = await bundleRequire({\n filepath: configPath,\n });\n let config = configBundle.mod.default || {};\n if (typeof config === 'function') {\n config = (await config(options)) || {};\n }\n return Object.assign({}, config, {rootDir});\n}\n\n/**\n * Compiles a root.config.ts file to root.config.js.\n */\nexport async function bundleRootConfig(rootDir: string, outPath: string) {\n const configPath = path.resolve(rootDir, 'root.config.ts');\n const exists = await fileExists(configPath);\n if (!exists) {\n throw new Error(`${configPath} does not exist`);\n }\n await build({\n entryPoints: [configPath],\n bundle: true,\n minify: true,\n platform: 'node',\n outfile: outPath,\n sourcemap: 'inline',\n metafile: true,\n format: 'esm',\n plugins: [\n {\n name: 'externalize-deps',\n setup(build) {\n build.onResolve({filter: /.*/}, (args) => {\n const id = args.path;\n if (id[0] !== '.' && !path.isAbsolute(id)) {\n return {\n external: true,\n };\n }\n return null;\n });\n },\n },\n ],\n });\n}\n\n/**\n * Loads a pre-bundled config file from dist/root.config.js.\n */\nexport async function loadBundledConfig(\n rootDir: string,\n options: ConfigOptions\n): Promise<RootConfig> {\n const configPath = path.resolve(rootDir, 'dist/root.config.js');\n const exists = await fileExists(configPath);\n if (!exists) {\n throw new Error(`${configPath} does not exist`);\n }\n const module = await import(configPath);\n let config = module.default || {};\n if (typeof config === 'function') {\n config = (await config(options)) || {};\n }\n return Object.assign({}, config, {rootDir});\n}\n","import {promises as fs} from 'node:fs';\nimport path from 'node:path';\n\nimport fsExtra from 'fs-extra';\nimport glob from 'tiny-glob';\n\nexport function isJsFile(filename: string) {\n return !!filename.match(/\\.(j|t)sx?$/);\n}\n\nexport async function writeFile(filepath: string, content: string) {\n const dirPath = path.dirname(filepath);\n await makeDir(dirPath);\n await fs.writeFile(filepath, content);\n}\n\nexport async function makeDir(dirpath: string) {\n try {\n await fs.access(dirpath);\n } catch (e) {\n await fs.mkdir(dirpath, {recursive: true});\n }\n}\n\nexport async function copyDir(srcdir: string, dstdir: string) {\n if (!fsExtra.existsSync(srcdir)) {\n return;\n }\n fsExtra.copySync(srcdir, dstdir, {overwrite: true});\n}\n\n/**\n * Copies a glob of files from one directory to another.\n *\n * Example:\n *\n * ```\n * await copyGlob('*.css', 'src/styles', 'dist/html/styles');\n * ```\n */\nexport async function copyGlob(\n pattern: string,\n srcdir: string,\n dstdir: string\n) {\n const files = await glob(pattern, {cwd: srcdir});\n if (files.length > 0) {\n await makeDir(dstdir);\n }\n files.forEach((file) => {\n fsExtra.copySync(path.resolve(srcdir, file), path.resolve(dstdir, file));\n });\n}\n\nexport async function rmDir(dirpath: string) {\n await fs.rm(dirpath, {recursive: true, force: true});\n}\n\nexport async function loadJson<T = unknown>(filepath: string): Promise<T> {\n const content = await fs.readFile(filepath, 'utf-8');\n return JSON.parse(content);\n}\n\nexport async function isDirectory(dirpath: string) {\n return fs\n .stat(dirpath)\n .then((fsStat) => {\n return fsStat.isDirectory();\n })\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return false;\n }\n throw err;\n });\n}\n\nexport function fileExists(filepath: string): Promise<boolean> {\n return fs\n .access(filepath)\n .then(() => true)\n .catch(() => false);\n}\n\nexport async function dirExists(dirpath: string): Promise<boolean> {\n try {\n const stat = await fs.stat(dirpath);\n return stat.isDirectory();\n } catch (error) {\n if (error.code === 'ENOENT') {\n return false;\n }\n throw error;\n }\n}\n\nexport async function directoryContains(\n dirpath: string,\n subpath: string\n): Promise<boolean> {\n const outer = await fs.realpath(dirpath);\n const inner = await fs.realpath(subpath);\n const rel = path.relative(outer, inner);\n return !rel.startsWith('..');\n}\n\nexport async function listFilesRecursive(dirPath: string): Promise<string[]> {\n const files: string[] = [];\n const entries = await fs.readdir(dirPath, {withFileTypes: true});\n for (const entry of entries) {\n const fullPath = path.join(dirPath, entry.name);\n if (entry.isDirectory()) {\n const subFiles = await listFilesRecursive(fullPath);\n files.push(...subFiles);\n } else {\n files.push(fullPath);\n }\n }\n return files;\n}\n","import path from 'node:path';\n\nimport {createServer, ViteDevServer} from 'vite';\n\nimport {RootConfig} from '../core/config.js';\nimport {getVitePlugins} from '../core/plugin.js';\n\nexport interface CreateViteServerOptions {\n /** Override HMR settings. */\n hmr?: boolean;\n /** The port the server will run on. */\n port?: number;\n /** List of files to include in the optimizeDeps.include config. */\n optimizeDeps?: string[];\n}\n\n/**\n * Returns a vite dev server.\n */\nexport async function createViteServer(\n rootConfig: RootConfig,\n options?: CreateViteServerOptions\n): Promise<ViteDevServer> {\n const rootDir = rootConfig.rootDir;\n const viteConfig = rootConfig.vite || {};\n\n let hmrOptions = viteConfig.server?.hmr;\n if (options?.hmr === false) {\n hmrOptions = false;\n } else if (typeof hmrOptions === 'undefined' && options?.port) {\n // Automatically set the HMR port to `port + 10`. This allows multiple\n // root.js dev servers to run without conflicts.\n hmrOptions = {port: options.port + 10};\n }\n\n const viteServer = await createServer({\n ...viteConfig,\n mode: 'development',\n root: rootDir,\n // publicDir is disabled from the vite dev server since it's handled by the\n // root dev server directly, which allows user middlewares to override\n // files in the public dir.\n publicDir: false,\n server: {\n ...(viteConfig.server || {}),\n middlewareMode: true,\n hmr: hmrOptions,\n },\n appType: 'custom',\n optimizeDeps: {\n // As of vite v5 / esbuild v19, experimentalDecorators need to be\n // explicitly set, and for some reason this option isn't read from the\n // project's tsconfig.json file by default.\n // See: https://vitejs.dev/blog/announcing-vite5\n esbuildOptions: {\n tsconfigRaw: {\n compilerOptions: {\n target: 'esnext',\n experimentalDecorators: true,\n useDefineForClassFields: false,\n },\n },\n },\n ...(viteConfig.optimizeDeps || {}),\n include: [\n ...(options?.optimizeDeps || []),\n ...(viteConfig.optimizeDeps?.include || []),\n ],\n extensions: [...(viteConfig.optimizeDeps?.extensions || []), '.tsx'],\n },\n ssr: {\n ...(viteConfig.ssr || {}),\n noExternal: ['@blinkk/root', '@blinkk/root-cms/richtext'],\n },\n esbuild: {\n ...(viteConfig.esbuild || {}),\n jsx: 'automatic',\n jsxImportSource: 'preact',\n },\n plugins: [\n ...(viteConfig.plugins || []),\n ...getVitePlugins(rootConfig.plugins || []),\n ],\n });\n return viteServer;\n}\n\n/**\n * Shortcut `viteServer.ssrLoadModule()` without starting an actual dev server.\n */\nexport async function viteSsrLoadModule(\n rootConfig: RootConfig,\n file: string\n): Promise<Record<string, any>> {\n const viteServer = await createViteServer(rootConfig, {hmr: false});\n const module = await viteServer.ssrLoadModule(file);\n await viteServer.close();\n return module;\n}\n"],"mappings":";;;;;AAAA,OAAOA,WAAU;AACjB,SAAQ,qBAAoB;AAC5B,SAAQ,aAAY;;;ACFpB,SAAQ,YAAY,UAAS;AAC7B,OAAO,UAAU;AAEjB,OAAO,aAAa;AACpB,OAAO,UAAU;AAEV,SAAS,SAAS,UAAkB;AACzC,SAAO,CAAC,CAAC,SAAS,MAAM,aAAa;AACvC;AAEA,eAAsB,UAAU,UAAkB,SAAiB;AACjE,QAAM,UAAU,KAAK,QAAQ,QAAQ;AACrC,QAAM,QAAQ,OAAO;AACrB,QAAM,GAAG,UAAU,UAAU,OAAO;AACtC;AAEA,eAAsB,QAAQ,SAAiB;AAC7C,MAAI;AACF,UAAM,GAAG,OAAO,OAAO;AAAA,EACzB,SAAS,GAAG;AACV,UAAM,GAAG,MAAM,SAAS,EAAC,WAAW,KAAI,CAAC;AAAA,EAC3C;AACF;AAkBA,eA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AgB,CAAC;AAAA,QAC9B,KAAI,gBAAW,iBAAX,mBAAyB,YAAW,CAAC;AAAA,MAC3C;AAAA,MACA,YAAY,CAAC,KAAI,gBAAW,iBAAX,mBAAyB,eAAc,CAAC,GAAI,MAAM;AAAA,IACrE;AAAA,IACA,KAAK;AAAA,MACH,GAAI,WAAW,OAAO,CAAC;AAAA,MACvB,YAAY,CAAC,gBAAgB,2BAA2B;AAAA,IAC1D;AAAA,IACA,SAAS;AAAA,MACP,GAAI,WAAW,WAAW,CAAC;AAAA,MAC3B,KAAK;AAAA,MACL,iBAAiB;AAAA,IACnB;AAAA,IACA,SAAS;AAAA,MACP,GAAI,WAAW,WAAW,CAAC;AAAA,MAC3B,GAAG,eAAe,WAAW,WAAW,CAAC,CAAC;AAAA,IAC5C;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAKA,eAAsB,kBACpB,YACA,MAC8B;AAC9B,QAAM,aAAa,MAAM,iBAAiB,YAAY,EAAC,KAAK,MAAK,CAAC;AAClE,QAAM,SAAS,MAAM,WAAW,cAAc,IAAI;AAClD,QAAM,WAAW,MAAM;AACvB,SAAO;AACT;","names":["path","path","build"]}
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
dev,
|
|
7
7
|
preview,
|
|
8
8
|
start
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4H7UTBRX.js";
|
|
10
10
|
import "./chunk-WNXIRMFF.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-JH33OQEK.js";
|
|
12
12
|
import "./chunk-QKBMWK5B.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-IUQLRDFW.js";
|
|
14
14
|
export {
|
|
15
15
|
build,
|
|
16
16
|
createDevServer,
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as Route } from './types-
|
|
2
|
-
export { C as ConfigureServerHook,
|
|
1
|
+
import { R as Route } from './types-3pEO32yG.js';
|
|
2
|
+
export { C as ConfigureServerHook, g as ConfigureServerOptions, k as GetStaticPaths, G as GetStaticProps, o as Handler, H as HandlerContext, r as HandlerRenderFn, q as HandlerRenderOptions, L as LocaleGroup, M as MultipartFile, N as NextFunction, P as Plugin, m as Request, l as RequestMiddleware, n as Response, b as RootConfig, c as RootI18nConfig, d as RootRedirectConfig, e as RootServerConfig, a as RootUserConfig, p as RouteModule, j as RouteParams, S as Server, h as configureServerPlugins, f as defineConfig, i as getVitePlugins } from './types-3pEO32yG.js';
|
|
3
3
|
import * as preact$1 from 'preact';
|
|
4
4
|
import { FunctionalComponent, ComponentChildren } from 'preact';
|
|
5
5
|
import 'express';
|
|
@@ -144,4 +144,4 @@ declare function useRequestContext(): RequestContext;
|
|
|
144
144
|
*/
|
|
145
145
|
declare function useTranslations(): (str: string, params?: Record<string, string | number>) => string;
|
|
146
146
|
|
|
147
|
-
export { Body, HTML_CONTEXT, Head, Html, I18nContext, RequestContext, Route, Script, getTranslations, useI18nContext, useRequestContext, useTranslations };
|
|
147
|
+
export { Body, HTML_CONTEXT, Head, Html, type I18nContext, type RequestContext, Route, Script, getTranslations, useI18nContext, useRequestContext, useTranslations };
|
package/dist/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/config.ts","../src/core/components/Body.tsx","../src/core/components/Head.ts","../src/core/components/Script.ts","../src/core/hooks/useTranslations.ts"],"sourcesContent":["import {UserConfig as ViteUserConfig} from 'vite';\n\nimport {HtmlMinifyOptions} from '../render/html-minify';\nimport {HtmlPrettyOptions} from '../render/html-pretty';\n\nimport {Plugin} from './plugin';\nimport {RequestMiddleware} from './types';\n\nexport interface RootUserConfig {\n /**\n * Canonical domain the website will serve on. Useful for things like the\n * sitemap, SEO tags, etc.\n */\n domain?: string;\n\n /**\n * Config for auto-injecting custom element dependencies.\n */\n elements?: {\n /**\n * A list of directories to use to look for custom elements. The dir path\n * should be relative to the project dir, e.g. \"path/to/elements\".\n */\n include?: string[];\n\n /**\n * A list of RegEx patterns to exclude. The string passed to the RegEx is\n * the file URL relative to the project root, e.g. \"/elements/foo/foo.ts\".\n */\n exclude?: RegExp[];\n };\n\n /**\n * Config options for localization and internationalization.\n */\n i18n?: RootI18nConfig;\n\n /**\n * Config options for the Root.js express server.\n */\n server?: RootServerConfig;\n\n /**\n * Vite config.\n * @see {@link https://vitejs.dev/config/} for more information.\n */\n vite?: ViteUserConfig;\n\n /**\n * Whether to automatically minify HTML output. This is enabled by default,\n * in order to disable, pass `minifyHtml: false` to root.config.ts.\n */\n minifyHtml?: boolean;\n\n /**\n * Options to pass to html-minifier-terser.\n */\n minifyHtmlOptions?: HtmlMinifyOptions;\n\n /**\n * Whether to pretty print HTML output.\n */\n prettyHtml?: boolean;\n\n /**\n * Options to pass to js-beautify.\n */\n prettyHtmlOptions?: HtmlPrettyOptions;\n\n /**\n * Whether to include a sitemap.xml file to the build output.\n */\n sitemap?: boolean;\n\n /**\n * Plugins.\n */\n plugins?: Plugin[];\n}\n\nexport type RootConfig = RootUserConfig & {\n rootDir: string;\n};\n\nexport interface LocaleGroup {\n label?: string;\n locales: string[];\n}\n\nexport interface RootI18nConfig {\n /**\n * Locales enabled for the site.\n */\n locales?: string[];\n\n /**\n * The default locale to use. Defaults is `en`.\n */\n defaultLocale?: string;\n\n /**\n * URL format for localized content. Default is `/
|
|
1
|
+
{"version":3,"sources":["../src/core/config.ts","../src/core/components/Body.tsx","../src/core/components/Head.ts","../src/core/components/Script.ts","../src/core/hooks/useTranslations.ts"],"sourcesContent":["import {UserConfig as ViteUserConfig} from 'vite';\n\nimport {HtmlMinifyOptions} from '../render/html-minify';\nimport {HtmlPrettyOptions} from '../render/html-pretty';\n\nimport {Plugin} from './plugin';\nimport {RequestMiddleware} from './types';\n\nexport interface RootUserConfig {\n /**\n * Canonical domain the website will serve on. Useful for things like the\n * sitemap, SEO tags, etc.\n */\n domain?: string;\n\n /**\n * The base URL path that the site will serve on. Defaults to `/`;\n */\n base?: string;\n\n /**\n * Config for auto-injecting custom element dependencies.\n */\n elements?: {\n /**\n * A list of directories to use to look for custom elements. The dir path\n * should be relative to the project dir, e.g. \"path/to/elements\".\n */\n include?: string[];\n\n /**\n * A list of RegEx patterns to exclude. The string passed to the RegEx is\n * the file URL relative to the project root, e.g. \"/elements/foo/foo.ts\".\n */\n exclude?: RegExp[];\n };\n\n /**\n * Config options for localization and internationalization.\n */\n i18n?: RootI18nConfig;\n\n /**\n * Config options for the Root.js express server.\n */\n server?: RootServerConfig;\n\n /**\n * Vite config.\n * @see {@link https://vitejs.dev/config/} for more information.\n */\n vite?: ViteUserConfig;\n\n /**\n * Whether to automatically minify HTML output. This is enabled by default,\n * in order to disable, pass `minifyHtml: false` to root.config.ts.\n */\n minifyHtml?: boolean;\n\n /**\n * Options to pass to html-minifier-terser.\n */\n minifyHtmlOptions?: HtmlMinifyOptions;\n\n /**\n * Whether to pretty print HTML output.\n */\n prettyHtml?: boolean;\n\n /**\n * Options to pass to js-beautify.\n */\n prettyHtmlOptions?: HtmlPrettyOptions;\n\n /**\n * Whether to include a sitemap.xml file to the build output.\n */\n sitemap?: boolean;\n\n /**\n * Plugins.\n */\n plugins?: Plugin[];\n}\n\nexport type RootConfig = RootUserConfig & {\n rootDir: string;\n};\n\nexport interface LocaleGroup {\n label?: string;\n locales: string[];\n}\n\nexport interface RootI18nConfig {\n /**\n * Locales enabled for the site.\n */\n locales?: string[];\n\n /**\n * The default locale to use. Defaults is `en`.\n */\n defaultLocale?: string;\n\n /**\n * URL format for localized content. Default is `/[locale]/[base]/[path]`.\n */\n urlFormat?: string;\n\n /**\n * Localization groups, to help UIs (like Root.js CMS) logically group\n * locales.\n */\n groups?: Record<string, LocaleGroup>;\n}\n\nexport interface RootRedirectConfig {\n source?: string;\n destination?: string;\n type?: number;\n}\n\nexport interface RootServerConfig {\n /**\n * An array of middleware to add to the express server. These middleware are\n * added to the beginning of the express app.\n */\n middlewares?: RequestMiddleware[];\n\n /**\n * The `trailingSlash` config allows you to control how the server handles\n * trailing slashes. This config only affects URLs that do not have a file\n * extension (i.e. HTML paths).\n *\n * - When `true`, the server redirects URLs to add a trailing slash\n * - When `false`, the server redirects URLs to remove a trailing slash\n * - When unspecified, the server allows URLs with and without trailing slash\n */\n trailingSlash?: boolean;\n\n /**\n * Cookie secret for the session middleware.\n */\n sessionCookieSecret?: string | string[];\n\n /**\n * List of redirects.\n */\n redirects?: RootRedirectConfig[];\n}\n\nexport function defineConfig(config: RootUserConfig): RootUserConfig {\n return config;\n}\n","import {ComponentChildren, FunctionalComponent} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nimport {HTML_CONTEXT} from './Html';\n\nexport type BodyProps = preact.JSX.HTMLAttributes<HTMLBodyElement> & {\n children?: ComponentChildren;\n};\n\n/**\n * The `<Body>` component can be used to update attrs in the `<body>` tag.\n *\n * Usage:\n *\n * ```tsx\n * <Body className=\"body\">\n * <h1>Hello world</h1>\n * </Body>\n * ```\n *\n * Output:\n *\n * ```html\n * <body class=\"body\">\n * <h1>Hello world</h1>\n * </body>\n */\nexport const Body: FunctionalComponent<BodyProps> = ({children, ...attrs}) => {\n const context = useContext(HTML_CONTEXT);\n if (!context) {\n throw new Error(\n 'HTML_CONTEXT not found, double-check usage of the <Body> component'\n );\n }\n context.bodyAttrs = attrs;\n return <>{children}</>;\n};\n","import {ComponentChildren, FunctionalComponent} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nimport {HTML_CONTEXT} from './Html';\n\nexport type HeadProps = preact.JSX.HTMLAttributes<HTMLHeadElement> & {\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. The <Head> can be added via any component or\n * sub-component and will automatically be hoisted to the `<head>` element.\n *\n * Usage:\n *\n * ```tsx\n * <Head>\n * <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\" />\n * </Head>\n * ```\n */\nexport const Head: FunctionalComponent<HeadProps> = ({children, ...attrs}) => {\n const context = useContext(HTML_CONTEXT);\n if (!context) {\n throw new Error(\n 'HTML_CONTEXT not found, double-check usage of the <Head> component'\n );\n }\n context.headComponents.push(children);\n context.headAttrs = attrs;\n return null;\n};\n","import {FunctionalComponent} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nimport {HTML_CONTEXT} from './Html';\n\nexport type ScriptProps = preact.JSX.HTMLAttributes<HTMLScriptElement>;\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 *\n * Usage:\n *\n * ```tsx\n * <Script src=\"/bundles/main.ts\" />\n * ```\n */\nexport const Script: FunctionalComponent<ScriptProps> = (props) => {\n const context = useContext(HTML_CONTEXT);\n if (!context) {\n throw new Error(\n 'HTML_CONTEXT not found, double-check usage of the <Script> component'\n );\n }\n context.scriptDeps.push(props);\n return null;\n};\n","import {useI18nContext} from './useI18nContext';\n\n/**\n * A hook that returns a function that can be used to translate a string, and\n * optionally replace any parameterized values that are surrounded in curly\n * braces.\n *\n * Usage:\n *\n * ```ts\n * const t = useTranslations();\n * t('Hello {name}', {name: 'Bob'});\n * // => 'Bounjour Bob'\n */\nexport function useTranslations() {\n const context = useI18nContext();\n const translations = context.translations || {};\n const t = (str: string, params?: Record<string, string | number>) => {\n const key = normalizeString(str);\n let translation = translations[key] ?? key ?? '';\n if (params) {\n for (const param of Object.keys(params)) {\n const val = String(params[param] ?? '');\n translation = translation.replaceAll(`{${param}}`, val);\n }\n }\n return translation;\n };\n return t;\n}\n\n/**\n * Cleans a string that's used for translations. Performs the following:\n * - Removes any leading/trailing whitespace\n * - Removes spaces at the end of any line\n */\nexport function normalizeString(str: string) {\n const lines = String(str)\n .trim()\n .split('\\n')\n .map((line) => line.trimEnd());\n return lines.join('\\n');\n}\n"],"mappings":";;;;;;;;;;;;;AAwJO,SAAS,aAAa,QAAwC;AACnE,SAAO;AACT;;;ACzJA,SAAQ,kBAAiB;AAk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AAK,QAAQ,CAAC;AAC/B,SAAO,MAAM,KAAK,IAAI;AACxB;","names":["useContext","useContext","useContext","useContext"]}
|
package/dist/functions.d.ts
CHANGED
package/dist/functions.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPreviewServer,
|
|
3
3
|
createProdServer
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4H7UTBRX.js";
|
|
5
5
|
import "./chunk-WNXIRMFF.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-JH33OQEK.js";
|
|
7
7
|
import "./chunk-QKBMWK5B.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-IUQLRDFW.js";
|
|
9
9
|
|
|
10
10
|
// src/functions/server.ts
|
|
11
11
|
import path from "node:path";
|
package/dist/middleware.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as RootConfig,
|
|
2
|
-
export {
|
|
1
|
+
import { b as RootConfig, m as Request, n as Response, N as NextFunction } from './types-3pEO32yG.js';
|
|
2
|
+
export { s as SESSION_COOKIE, u as SaveSessionOptions, w as Session, t as SessionMiddlewareOptions, v as sessionMiddleware } from './types-3pEO32yG.js';
|
|
3
3
|
import 'express';
|
|
4
4
|
import 'preact';
|
|
5
5
|
import 'vite';
|
package/dist/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as RootConfig } from './types-
|
|
1
|
+
import { b as RootConfig } from './types-3pEO32yG.js';
|
|
2
2
|
import { ViteDevServer } from 'vite';
|
|
3
3
|
import 'express';
|
|
4
4
|
import 'preact';
|
|
@@ -9,6 +9,14 @@ interface ConfigOptions {
|
|
|
9
9
|
command: string;
|
|
10
10
|
}
|
|
11
11
|
declare function loadRootConfig(rootDir: string, options: ConfigOptions): Promise<RootConfig>;
|
|
12
|
+
/**
|
|
13
|
+
* Compiles a root.config.ts file to root.config.js.
|
|
14
|
+
*/
|
|
15
|
+
declare function bundleRootConfig(rootDir: string, outPath: string): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Loads a pre-bundled config file from dist/root.config.js.
|
|
18
|
+
*/
|
|
19
|
+
declare function loadBundledConfig(rootDir: string, options: ConfigOptions): Promise<RootConfig>;
|
|
12
20
|
|
|
13
21
|
interface CreateViteServerOptions {
|
|
14
22
|
/** Override HMR settings. */
|
|
@@ -27,4 +35,4 @@ declare function createViteServer(rootConfig: RootConfig, options?: CreateViteSe
|
|
|
27
35
|
*/
|
|
28
36
|
declare function viteSsrLoadModule(rootConfig: RootConfig, file: string): Promise<Record<string, any>>;
|
|
29
37
|
|
|
30
|
-
export { ConfigOptions, CreateViteServerOptions, createViteServer, loadRootConfig, viteSsrLoadModule };
|
|
38
|
+
export { type ConfigOptions, type CreateViteServerOptions, bundleRootConfig, createViteServer, loadBundledConfig, loadRootConfig, viteSsrLoadModule };
|
package/dist/node.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
+
bundleRootConfig,
|
|
2
3
|
createViteServer,
|
|
4
|
+
loadBundledConfig,
|
|
3
5
|
loadRootConfig,
|
|
4
6
|
viteSsrLoadModule
|
|
5
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-JH33OQEK.js";
|
|
6
8
|
import "./chunk-QKBMWK5B.js";
|
|
7
9
|
export {
|
|
10
|
+
bundleRootConfig,
|
|
8
11
|
createViteServer,
|
|
12
|
+
loadBundledConfig,
|
|
9
13
|
loadRootConfig,
|
|
10
14
|
viteSsrLoadModule
|
|
11
15
|
};
|
package/dist/render.d.ts
CHANGED