olova 2.0.57 → 2.0.60

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/olova.cjs CHANGED
@@ -206,7 +206,7 @@ function generateRouteTree(routes, notFoundPages, layouts, loadingPages, errorPa
206
206
  };
207
207
  const routeNames = [];
208
208
  const routeImports = routes.map((route) => {
209
- const relativePath = stripImportExtension("./" + path5__default.default.relative(srcDir, route.component).replace(/\\/g, "/"));
209
+ const relativePath = stripImportExtension("./app/" + path5__default.default.relative(srcDir, route.component).replace(/\\/g, "/"));
210
210
  const moduleName = getRouteName2(route.component, "RouteModule");
211
211
  const lazyName = getRouteName2(route.component, "Route");
212
212
  routeNames.push({ moduleName, lazyName, eager: true });
@@ -214,7 +214,7 @@ function generateRouteTree(routes, notFoundPages, layouts, loadingPages, errorPa
214
214
  }).join("\n");
215
215
  const notFoundNames = [];
216
216
  const notFoundImports = notFoundPages.map((nf) => {
217
- const relativePath = stripImportExtension("./" + path5__default.default.relative(srcDir, nf.filePath).replace(/\\/g, "/"));
217
+ const relativePath = stripImportExtension("./app/" + path5__default.default.relative(srcDir, nf.filePath).replace(/\\/g, "/"));
218
218
  if (nf.hasMetadata) {
219
219
  const moduleName = getRouteName2(nf.filePath, "NotFoundModule");
220
220
  notFoundNames.push(moduleName);
@@ -228,7 +228,7 @@ function generateRouteTree(routes, notFoundPages, layouts, loadingPages, errorPa
228
228
  }).join("\n");
229
229
  const layoutNames = [];
230
230
  const layoutImports = layouts.map((layout) => {
231
- const relativePath = stripImportExtension("./" + path5__default.default.relative(srcDir, layout.filePath).replace(/\\/g, "/"));
231
+ const relativePath = stripImportExtension("./app/" + path5__default.default.relative(srcDir, layout.filePath).replace(/\\/g, "/"));
232
232
  if (layout.hasMetadata) {
233
233
  const moduleName = getRouteName2(layout.filePath, "LayoutModule");
234
234
  layoutNames.push(moduleName);
@@ -242,7 +242,7 @@ function generateRouteTree(routes, notFoundPages, layouts, loadingPages, errorPa
242
242
  }).join("\n");
243
243
  const loadingNames = [];
244
244
  const loadingImports = loadingPages.map((lp) => {
245
- const relativePath = stripImportExtension("./" + path5__default.default.relative(srcDir, lp.filePath).replace(/\\/g, "/"));
245
+ const relativePath = stripImportExtension("./app/" + path5__default.default.relative(srcDir, lp.filePath).replace(/\\/g, "/"));
246
246
  const importName = getRouteName2(lp.filePath, "Loading");
247
247
  loadingNames.push(importName);
248
248
  if (lp.hasDefault) return `import ${importName} from '${relativePath}';`;
@@ -251,7 +251,7 @@ function generateRouteTree(routes, notFoundPages, layouts, loadingPages, errorPa
251
251
  }).join("\n");
252
252
  const errorNames = [];
253
253
  const errorImports = errorPages.map((ep) => {
254
- const relativePath = stripImportExtension("./" + path5__default.default.relative(srcDir, ep.filePath).replace(/\\/g, "/"));
254
+ const relativePath = stripImportExtension("./app/" + path5__default.default.relative(srcDir, ep.filePath).replace(/\\/g, "/"));
255
255
  const importName = getRouteName2(ep.filePath, "Error");
256
256
  errorNames.push(importName);
257
257
  if (ep.hasDefault) return `import ${importName} from '${relativePath}';`;
@@ -260,7 +260,7 @@ function generateRouteTree(routes, notFoundPages, layouts, loadingPages, errorPa
260
260
  }).join("\n");
261
261
  const middlewareNames = [];
262
262
  const middlewareImports = middlewares.map((mw) => {
263
- const relativePath = stripImportExtension("./" + path5__default.default.relative(srcDir, mw.filePath).replace(/\\/g, "/"));
263
+ const relativePath = stripImportExtension("./app/" + path5__default.default.relative(srcDir, mw.filePath).replace(/\\/g, "/"));
264
264
  const importName = getRouteName2(mw.filePath, "Middleware");
265
265
  middlewareNames.push(importName);
266
266
  if (mw.hasDefault) return `import ${importName} from '${relativePath}';`;
@@ -490,14 +490,12 @@ export type {
490
490
  `;
491
491
  }
492
492
  var RESERVED_NAMES = /* @__PURE__ */ new Set([
493
- "index",
493
+ "page",
494
494
  "layout",
495
495
  "loading",
496
496
  "error",
497
- "404",
497
+ "not-found",
498
498
  "middleware",
499
- "App",
500
- "main",
501
499
  "route.tree"
502
500
  ]);
503
501
  function scanDirectory(dir, rootDir, extensions, routes, notFoundPages, layouts, loadingPages, errorPages, middlewares, isRoot = false) {
@@ -539,15 +537,13 @@ function scanDirectory(dir, rootDir, extensions, routes, notFoundPages, layouts,
539
537
  path: isRoot ? "/" : routePath,
540
538
  filePath: fullPath
541
539
  });
542
- } else if (baseName === "404" && extensions.includes(ext)) {
540
+ } else if ((baseName === "not-found" || baseName === "404") && extensions.includes(ext)) {
543
541
  const relativeParts = path5__default.default.relative(rootDir, dir).split(path5__default.default.sep).filter(Boolean);
544
542
  const filteredParts = relativeParts.filter((p) => !isRouteGroup(p));
545
543
  const pathPrefix = isRoot ? "" : "/" + filteredParts.join("/");
546
544
  notFoundPages.push({ pathPrefix: pathPrefix || "", filePath: fullPath });
547
- } else if (isRoot && baseName === "App" && extensions.includes(ext)) {
548
- routes.push({ path: "/", filePath: fullPath, isDynamic: false, params: [] });
549
- } else if (!isRoot && baseName === "index" && extensions.includes(ext)) {
550
- const relativePath = path5__default.default.relative(rootDir, path5__default.default.dirname(fullPath));
545
+ } else if (baseName === "page" && extensions.includes(ext)) {
546
+ const relativePath = path5__default.default.relative(rootDir, dir);
551
547
  const { routePath, params } = pathToRoute(relativePath, path5__default.default.sep);
552
548
  routes.push({ path: routePath, filePath: fullPath, isDynamic: params.length > 0, params });
553
549
  } else if (!RESERVED_NAMES.has(baseName) && !baseName.endsWith(".d") && !baseName.startsWith("_") && extensions.includes(ext)) {
@@ -582,7 +578,7 @@ function scanRoutes(rootDir, extensions) {
582
578
 
583
579
  // src/plugin/index.ts
584
580
  function olovaRouter(options = {}) {
585
- const rootDir = options.rootDir || "src";
581
+ const rootDir = options.rootDir || "src/app";
586
582
  const extensions = options.extensions || [".tsx", ".ts", ".mdx"];
587
583
  const packageName = options.packageName || "olovastart";
588
584
  let config;
@@ -661,7 +657,7 @@ function olovaRouter(options = {}) {
661
657
  };
662
658
  });
663
659
  const content = generateRouteTree(routeConfigs, notFoundConfigs, layoutConfigs, loadingConfigs, errorConfigs, middlewareConfigs, absoluteRootDir, packageName);
664
- const treePath = path5__default.default.resolve(absoluteRootDir, "route.tree.ts");
660
+ const treePath = path5__default.default.resolve(config.root, "src", "route.tree.ts");
665
661
  const existing = fs3__default.default.existsSync(treePath) ? fs3__default.default.readFileSync(treePath, "utf-8") : "";
666
662
  if (existing !== content) {
667
663
  fs3__default.default.writeFileSync(treePath, content);
@@ -675,9 +671,9 @@ function olovaRouter(options = {}) {
675
671
  if (filename.includes("route.tree.ts")) return;
676
672
  const ext = path5__default.default.extname(filename);
677
673
  const isConfiguredExtension = extensions.includes(ext);
678
- const isIndexFile = filename.includes("index") && isConfiguredExtension;
679
- const isAppFile = filename.includes("App") && isConfiguredExtension;
674
+ const isPageFile = filename.includes("page") && isConfiguredExtension;
680
675
  const is404File = filename.includes("404") && isConfiguredExtension;
676
+ const isNotFoundFile = filename.includes("not-found") && isConfiguredExtension;
681
677
  const isLayoutFile = filename.includes("layout") && isConfiguredExtension;
682
678
  const isLoadingFile = filename.includes("loading") && isConfiguredExtension;
683
679
  const isErrorFile = filename.includes("error") && isConfiguredExtension;
@@ -685,8 +681,8 @@ function olovaRouter(options = {}) {
685
681
  const isDirectory = !filename.includes(".");
686
682
  const isDynamicSegment = filename.includes("[");
687
683
  const isRenameEvent = eventType === "rename";
688
- if (isIndexFile || isAppFile || is404File || isLayoutFile || isLoadingFile || isErrorFile || isMiddlewareFile || isDirectory || isDynamicSegment || isRenameEvent) {
689
- if (isIndexFile && filename) {
684
+ if (isPageFile || is404File || isNotFoundFile || isLayoutFile || isLoadingFile || isErrorFile || isMiddlewareFile || isDirectory || isDynamicSegment || isRenameEvent) {
685
+ if (isPageFile && filename) {
690
686
  const fullPath = path5__default.default.join(absoluteRootDir, filename);
691
687
  if (fs3__default.default.existsSync(fullPath)) {
692
688
  const stat = fs3__default.default.statSync(fullPath);