noofpi 2.0.1 → 3.1.0
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/README.md +6 -2
- package/client.d.ts +2 -0
- package/dist/build-YRW44BZG.js +212 -0
- package/dist/{chunk-YJVMBHNL.js → chunk-JUVQEKLE.js} +43 -12
- package/dist/chunk-LJEKK4AK.js +51 -0
- package/dist/chunk-O5JRC252.js +245 -0
- package/dist/{chunk-G35DW4NA.js → chunk-PC3ZJN4D.js} +11 -1
- package/dist/{chunk-NHBXVKEQ.js → chunk-PL3CA2JF.js} +160 -86
- package/dist/{chunk-MN5PVHC5.js → chunk-W7ASRDAJ.js} +229 -7
- package/dist/{chunk-IE3WF5XF.js → chunk-YN4TKMDX.js} +87 -4
- package/dist/chunk-YN64WQ2B.js +562 -0
- package/dist/cli.js +21 -9
- package/dist/{dev-OAGCOGHA.js → dev-A7VK5V4H.js} +7 -6
- package/dist/{devtools-PLUN2DYV.js → devtools-C3PFU57C.js} +1 -1
- package/dist/handler-oYl9j0Qa.d.ts +26 -0
- package/dist/index.d.ts +26 -11
- package/dist/index.js +3 -2
- package/dist/payload-DfhHnXAn.d.ts +66 -0
- package/dist/{prepare-BN7NMCVQ.js → prepare-JT2NPD5S.js} +6 -5
- package/dist/runtime/entry-client.js +4 -4
- package/dist/runtime/entry-server.d.ts +6 -4
- package/dist/runtime/entry-server.js +88 -25
- package/dist/runtime/index.d.ts +24 -6
- package/dist/runtime/index.js +5 -3
- package/dist/server/bun.d.ts +3 -3
- package/dist/server/index.d.ts +35 -7
- package/dist/server/index.js +12 -7
- package/dist/server/node.d.ts +3 -3
- package/dist/session-CLvYihOU.d.ts +275 -0
- package/dist/{start-ITRND3BY.js → start-J6ZIUG66.js} +7 -6
- package/dist/{types-B6rQOOxS.d.ts → types-Czld0vOH.d.ts} +30 -5
- package/package.json +12 -7
- package/dist/build-WPHZ7TYZ.js +0 -49
- package/dist/chunk-MTXQR32N.js +0 -8
- package/dist/chunk-X3DYEZLK.js +0 -253
- package/dist/handler-C6NnwBfC.d.ts +0 -17
- package/dist/payload-CL6tYBin.d.ts +0 -121
- package/dist/route-rules-COilNsVT.d.ts +0 -127
|
@@ -1,20 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveSession
|
|
3
|
+
} from "./chunk-O5JRC252.js";
|
|
1
4
|
import {
|
|
2
5
|
resolveI18n
|
|
3
6
|
} from "./chunk-ELXCFUA4.js";
|
|
4
7
|
import {
|
|
5
8
|
FETCH_MODES,
|
|
9
|
+
isServerRendered,
|
|
10
|
+
matchRouteRules,
|
|
6
11
|
matchesRoutePattern,
|
|
7
12
|
resolveSecurity,
|
|
8
13
|
toPublicRouteRules,
|
|
9
14
|
usesFetchMode,
|
|
10
15
|
validateRouteRules
|
|
11
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-W7ASRDAJ.js";
|
|
12
17
|
|
|
13
18
|
// src/build-preset.ts
|
|
14
19
|
var BUILD_PRESETS = [
|
|
15
20
|
"node",
|
|
16
21
|
"bun",
|
|
17
|
-
"docker",
|
|
22
|
+
"docker-node",
|
|
23
|
+
"docker-bun",
|
|
18
24
|
"cloudflare-worker",
|
|
19
25
|
"cloudflare-pages",
|
|
20
26
|
"github-pages"
|
|
@@ -22,6 +28,16 @@ var BUILD_PRESETS = [
|
|
|
22
28
|
function isCloudflarePreset(preset) {
|
|
23
29
|
return preset === "cloudflare-worker" || preset === "cloudflare-pages";
|
|
24
30
|
}
|
|
31
|
+
var STATIC_PRESETS = ["github-pages", "cloudflare-pages"];
|
|
32
|
+
var isStaticPreset = (preset) => STATIC_PRESETS.includes(preset);
|
|
33
|
+
function generatePreset(requested, configured) {
|
|
34
|
+
const preset = requested ?? (isStaticPreset(configured) ? configured : "github-pages");
|
|
35
|
+
if (!isStaticPreset(preset))
|
|
36
|
+
throw new Error(
|
|
37
|
+
`[noofpi] noofpi generate writes static files, so its preset must be ${STATIC_PRESETS.join(" or ")} (got "${preset}")`
|
|
38
|
+
);
|
|
39
|
+
return preset;
|
|
40
|
+
}
|
|
25
41
|
function assertBuildPreset(value, source) {
|
|
26
42
|
if (!BUILD_PRESETS.includes(value)) {
|
|
27
43
|
throw new Error(
|
|
@@ -185,6 +201,61 @@ function variantWidths(imageWidth, widths) {
|
|
|
185
201
|
return [...widths.filter((width) => width < imageWidth), imageWidth];
|
|
186
202
|
}
|
|
187
203
|
|
|
204
|
+
// src/prerender.ts
|
|
205
|
+
var PATH = /^\/(?!\/)[^\s?#\\]*$/;
|
|
206
|
+
var normalizeRoute = (route) => route.length > 1 ? route.replace(/\/+$/, "") || "/" : route;
|
|
207
|
+
function resolvePrerender(input = {}) {
|
|
208
|
+
const routes = input.routes ?? [];
|
|
209
|
+
if (!Array.isArray(routes))
|
|
210
|
+
throw new Error("[noofpi] prerender.routes must be a list of URL paths");
|
|
211
|
+
for (const route of routes)
|
|
212
|
+
if (typeof route !== "string" || !PATH.test(route))
|
|
213
|
+
throw new Error(
|
|
214
|
+
`[noofpi] prerender.routes must be URL paths starting with "/", without a query or hash (got "${String(route)}")`
|
|
215
|
+
);
|
|
216
|
+
if (input.crawlLinks !== void 0 && typeof input.crawlLinks !== "boolean")
|
|
217
|
+
throw new Error("[noofpi] prerender.crawlLinks must be a boolean");
|
|
218
|
+
return {
|
|
219
|
+
routes: routes.map(normalizeRoute),
|
|
220
|
+
crawlLinks: input.crawlLinks ?? true
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function routeToFile(route) {
|
|
224
|
+
const path = normalizeRoute(route).replace(/^\/+/, "");
|
|
225
|
+
return path ? `${path}/index.html` : "index.html";
|
|
226
|
+
}
|
|
227
|
+
function planPrerender(options) {
|
|
228
|
+
const { pages, rules, ssr } = options;
|
|
229
|
+
const explicit = new Set(options.routes);
|
|
230
|
+
const marked = explicit.size > 0 || Object.values(rules).some((rule) => rule.prerender === true);
|
|
231
|
+
const accepts = (route) => {
|
|
232
|
+
if (!isServerRendered(ssr, rules, route)) return false;
|
|
233
|
+
if (explicit.has(normalizeRoute(route))) return true;
|
|
234
|
+
const { prerender } = matchRouteRules(rules, route);
|
|
235
|
+
return prerender === true || !marked && prerender !== false;
|
|
236
|
+
};
|
|
237
|
+
const seeds = [
|
|
238
|
+
.../* @__PURE__ */ new Set([
|
|
239
|
+
...pages.filter((page) => !page.includes(":")).map(normalizeRoute),
|
|
240
|
+
...explicit
|
|
241
|
+
])
|
|
242
|
+
].filter(accepts).sort();
|
|
243
|
+
return { marked, seeds, accepts };
|
|
244
|
+
}
|
|
245
|
+
var ANCHOR = /<a\s[^>]*?\bhref\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;
|
|
246
|
+
var decodeEntities = (value) => value.replace(/&/g, "&").replace(/"/g, '"').replace(/�*39;|'/g, "'");
|
|
247
|
+
function extractLinks(html) {
|
|
248
|
+
const links = /* @__PURE__ */ new Set();
|
|
249
|
+
for (const match of html.matchAll(ANCHOR)) {
|
|
250
|
+
const href = decodeEntities(match[1] ?? match[2] ?? "").trim();
|
|
251
|
+
if (!href.startsWith("/") || href.startsWith("//")) continue;
|
|
252
|
+
const path = href.replace(/[?#].*$/, "");
|
|
253
|
+
if (!PATH.test(path) || /\.[a-z0-9]+$/i.test(path)) continue;
|
|
254
|
+
links.add(normalizeRoute(path));
|
|
255
|
+
}
|
|
256
|
+
return [...links];
|
|
257
|
+
}
|
|
258
|
+
|
|
188
259
|
// src/seo.ts
|
|
189
260
|
function resolveSeo(input = {}) {
|
|
190
261
|
let siteUrl;
|
|
@@ -269,6 +340,10 @@ function resolveConfig(input = {}) {
|
|
|
269
340
|
}
|
|
270
341
|
const routeRules = input.routeRules ?? {};
|
|
271
342
|
validateRouteRules(routeRules, ssr);
|
|
343
|
+
if (input.streaming !== void 0 && typeof input.streaming !== "boolean")
|
|
344
|
+
throw new Error("[noofpi] streaming must be a boolean");
|
|
345
|
+
if (input.streaming && !ssr)
|
|
346
|
+
throw new Error("[noofpi] streaming: true needs ssr: true");
|
|
272
347
|
let url = input.doofpi?.url;
|
|
273
348
|
const remoteRule = Object.entries(routeRules).find(
|
|
274
349
|
([, rule]) => rule.fetch !== void 0 && rule.fetch !== "lfetch"
|
|
@@ -312,7 +387,10 @@ function resolveConfig(input = {}) {
|
|
|
312
387
|
);
|
|
313
388
|
return {
|
|
314
389
|
ssr,
|
|
390
|
+
streaming: input.streaming ?? false,
|
|
315
391
|
routeRules,
|
|
392
|
+
prerender: resolvePrerender(input.prerender),
|
|
393
|
+
session: resolveSession(input.session),
|
|
316
394
|
head: input.head ?? {},
|
|
317
395
|
tailwind: input.tailwind ?? false,
|
|
318
396
|
autoImports: input.autoImports ?? true,
|
|
@@ -340,20 +418,25 @@ function toPublicConfig(config) {
|
|
|
340
418
|
routeRules: toPublicRouteRules(config.routeRules),
|
|
341
419
|
head: config.head,
|
|
342
420
|
doofpi: { fetch, url: direct ? url : void 0, root },
|
|
421
|
+
session: config.session !== void 0,
|
|
343
422
|
devtools: config.devtools
|
|
344
423
|
};
|
|
345
424
|
}
|
|
346
425
|
function toServerConfig(config) {
|
|
347
|
-
const { ssr, doofpi, routeRules, head, security } = config;
|
|
348
|
-
return { ssr, doofpi, routeRules, head, security };
|
|
426
|
+
const { ssr, streaming, doofpi, routeRules, head, security, session } = config;
|
|
427
|
+
return { ssr, streaming, doofpi, routeRules, head, security, session };
|
|
349
428
|
}
|
|
350
429
|
|
|
351
430
|
export {
|
|
352
431
|
BUILD_PRESETS,
|
|
353
432
|
isCloudflarePreset,
|
|
433
|
+
generatePreset,
|
|
354
434
|
assertBuildPreset,
|
|
355
435
|
FONT_PROVIDERS,
|
|
356
436
|
variantWidths,
|
|
437
|
+
routeToFile,
|
|
438
|
+
planPrerender,
|
|
439
|
+
extractLinks,
|
|
357
440
|
sitemapRoutes,
|
|
358
441
|
sitemapXml,
|
|
359
442
|
robotsTxt,
|