rari 0.2.21 → 0.2.22
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/index.js +1 -1
- package/dist/{server-D-ZsD18Z.js → server-BK7rNurU.js} +12 -7
- package/dist/server.js +1 -1
- package/package.json +1 -1
- package/src/vite/index.ts +41 -13
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent, RouterProvider, Routes, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-BXoadxa8.js";
|
|
2
|
-
import { FileRouteGenerator, convertFilePatternToRoutePattern, createRouteManifest, defineRariConfig, defineRariOptions, generateFileRoutes, loadRouteManifest, rari, rariRouter, validateRoutes, watchFileRoutes } from "./server-
|
|
2
|
+
import { FileRouteGenerator, convertFilePatternToRoutePattern, createRouteManifest, defineRariConfig, defineRariOptions, generateFileRoutes, loadRouteManifest, rari, rariRouter, validateRoutes, watchFileRoutes } from "./server-BK7rNurU.js";
|
|
3
3
|
import "./server-build-BM8_GFF5.js";
|
|
4
4
|
|
|
5
5
|
export { FileRouteGenerator, HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent as Route, RouterProvider, Routes, buildSearchString, buildUrl, convertFilePatternToRoutePattern, createHttpRuntimeClient, createRouteManifest, defineRariConfig, defineRariOptions, extractParamNames, findMatchingRoute, generateFileRoutes, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, loadRouteManifest, normalizePathname, parseSearchParams, parseUrl, rari, rariRouter, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, validateRoutes, watchFileRoutes, withRouter };
|
|
@@ -5108,7 +5108,7 @@ var require_chokidar = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/ch
|
|
|
5108
5108
|
|
|
5109
5109
|
//#endregion
|
|
5110
5110
|
//#region src/router/file-routes.ts
|
|
5111
|
-
var import_chokidar$1 = /* @__PURE__ */ __toESM(require_chokidar());
|
|
5111
|
+
var import_chokidar$1 = /* @__PURE__ */ __toESM(require_chokidar(), 1);
|
|
5112
5112
|
var FileRouteGenerator = class {
|
|
5113
5113
|
pagesDir;
|
|
5114
5114
|
extensions;
|
|
@@ -5417,7 +5417,7 @@ function convertFilePatternToRoutePattern(pattern) {
|
|
|
5417
5417
|
|
|
5418
5418
|
//#endregion
|
|
5419
5419
|
//#region src/router/vite-plugin.ts
|
|
5420
|
-
var import_chokidar = /* @__PURE__ */ __toESM(require_chokidar());
|
|
5420
|
+
var import_chokidar = /* @__PURE__ */ __toESM(require_chokidar(), 1);
|
|
5421
5421
|
const DEFAULT_OPTIONS = {
|
|
5422
5422
|
pagesDir: "src/pages",
|
|
5423
5423
|
extensions: [
|
|
@@ -5636,11 +5636,16 @@ function scanForClientComponents(srcDir) {
|
|
|
5636
5636
|
return clientComponents;
|
|
5637
5637
|
}
|
|
5638
5638
|
function extractCacheConfigFromContent(content) {
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5639
|
+
let ast;
|
|
5640
|
+
try {
|
|
5641
|
+
ast = acorn.parse(content, {
|
|
5642
|
+
ecmaVersion: 2022,
|
|
5643
|
+
sourceType: "module",
|
|
5644
|
+
allowImportExportEverywhere: true
|
|
5645
|
+
});
|
|
5646
|
+
} catch {
|
|
5647
|
+
return void 0;
|
|
5648
|
+
}
|
|
5644
5649
|
for (const node of ast.body) if (node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "VariableDeclaration") {
|
|
5645
5650
|
for (const declarator of node.declaration.declarations) if (declarator.id && declarator.id.name === "cacheConfig" && declarator.init && declarator.init.type === "ObjectExpression") {
|
|
5646
5651
|
const config = {};
|
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent, RouterProvider, Routes, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-BXoadxa8.js";
|
|
2
|
-
import { FileRouteGenerator, convertFilePatternToRoutePattern, createRouteManifest, defineRariConfig, defineRariOptions, generateFileRoutes, loadRouteManifest, rari, rariRouter, validateRoutes, watchFileRoutes } from "./server-
|
|
2
|
+
import { FileRouteGenerator, convertFilePatternToRoutePattern, createRouteManifest, defineRariConfig, defineRariOptions, generateFileRoutes, loadRouteManifest, rari, rariRouter, validateRoutes, watchFileRoutes } from "./server-BK7rNurU.js";
|
|
3
3
|
import "./server-build-BM8_GFF5.js";
|
|
4
4
|
|
|
5
5
|
export { FileRouteGenerator, HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent as Route, RouterProvider, Routes, buildSearchString, buildUrl, convertFilePatternToRoutePattern, createHttpRuntimeClient, createRouteManifest, defineRariConfig, defineRariOptions, extractParamNames, findMatchingRoute, generateFileRoutes, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, loadRouteManifest, normalizePathname, parseSearchParams, parseUrl, rari, rariRouter, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, validateRoutes, watchFileRoutes, withRouter };
|
package/package.json
CHANGED
package/src/vite/index.ts
CHANGED
|
@@ -52,12 +52,20 @@ function scanForClientComponents(srcDir: string): Set<string> {
|
|
|
52
52
|
return clientComponents
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
function extractCacheConfigFromContent(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
function extractCacheConfigFromContent(
|
|
56
|
+
content: string,
|
|
57
|
+
): PageCacheConfig | undefined {
|
|
58
|
+
let ast: any
|
|
59
|
+
try {
|
|
60
|
+
ast = acorn.parse(content, {
|
|
61
|
+
ecmaVersion: 2022,
|
|
62
|
+
sourceType: 'module',
|
|
63
|
+
allowImportExportEverywhere: true,
|
|
64
|
+
}) as any
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return undefined
|
|
68
|
+
}
|
|
61
69
|
|
|
62
70
|
for (const node of ast.body) {
|
|
63
71
|
if (
|
|
@@ -81,9 +89,11 @@ function extractCacheConfigFromContent(content: string): PageCacheConfig | undef
|
|
|
81
89
|
&& prop.value
|
|
82
90
|
&& prop.value.type === 'Literal'
|
|
83
91
|
) {
|
|
84
|
-
const keyName
|
|
92
|
+
const keyName
|
|
93
|
+
= prop.key.type === 'Literal' ? prop.key.value : prop.key.name
|
|
85
94
|
if (keyName === 'cache-control' || keyName === 'vary') {
|
|
86
|
-
config[keyName as keyof PageCacheConfig] = prop.value
|
|
95
|
+
config[keyName as keyof PageCacheConfig] = prop.value
|
|
96
|
+
.value as string
|
|
87
97
|
}
|
|
88
98
|
}
|
|
89
99
|
}
|
|
@@ -2489,9 +2499,16 @@ ${registrations.join('\n')}
|
|
|
2489
2499
|
const url = req.url || ''
|
|
2490
2500
|
const pathname = url.split('?')[0]
|
|
2491
2501
|
|
|
2492
|
-
if (
|
|
2502
|
+
if (
|
|
2503
|
+
pathname
|
|
2504
|
+
&& !pathname.includes('.')
|
|
2505
|
+
&& !pathname.startsWith('/api')
|
|
2506
|
+
&& !pathname.startsWith('/rsc')
|
|
2507
|
+
) {
|
|
2493
2508
|
if (options.caching?.routes) {
|
|
2494
|
-
for (const [pattern, cacheControl] of Object.entries(
|
|
2509
|
+
for (const [pattern, cacheControl] of Object.entries(
|
|
2510
|
+
options.caching.routes,
|
|
2511
|
+
)) {
|
|
2495
2512
|
if (matchesPattern(pattern, pathname)) {
|
|
2496
2513
|
res.setHeader('cache-control', cacheControl)
|
|
2497
2514
|
break
|
|
@@ -2500,7 +2517,11 @@ ${registrations.join('\n')}
|
|
|
2500
2517
|
}
|
|
2501
2518
|
|
|
2502
2519
|
const pagePath = pathname === '/' ? '/index' : pathname
|
|
2503
|
-
const pageFilePath = path.join(
|
|
2520
|
+
const pageFilePath = path.join(
|
|
2521
|
+
process.cwd(),
|
|
2522
|
+
'src/pages',
|
|
2523
|
+
`${pagePath.slice(1) || 'index'}.tsx`,
|
|
2524
|
+
)
|
|
2504
2525
|
|
|
2505
2526
|
if (fs.existsSync(pageFilePath)) {
|
|
2506
2527
|
const pageContent = fs.readFileSync(pageFilePath, 'utf-8')
|
|
@@ -2521,8 +2542,15 @@ ${registrations.join('\n')}
|
|
|
2521
2542
|
},
|
|
2522
2543
|
writeBundle() {
|
|
2523
2544
|
if (options.caching) {
|
|
2524
|
-
const cacheConfigPath = path.join(
|
|
2525
|
-
|
|
2545
|
+
const cacheConfigPath = path.join(
|
|
2546
|
+
process.cwd(),
|
|
2547
|
+
'dist',
|
|
2548
|
+
'cache-config.json',
|
|
2549
|
+
)
|
|
2550
|
+
fs.writeFileSync(
|
|
2551
|
+
cacheConfigPath,
|
|
2552
|
+
JSON.stringify(options.caching, null, 2),
|
|
2553
|
+
)
|
|
2526
2554
|
}
|
|
2527
2555
|
},
|
|
2528
2556
|
}
|