Skip to content

Commit 759d040

Browse files
Varixowmertens
authored andcommitted
chore: change route data and router config names
1 parent 8844bc5 commit 759d040

35 files changed

+165
-149
lines changed

packages/docs/src/routes/api/qwik-router/api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@
796796
}
797797
],
798798
"kind": "TypeAlias",
799-
"content": "```typescript\nexport type RouteData = [routeName: string, loaders: ModuleLoader[]] | [\n routeName: string,\n loaders: ModuleLoader[],\n originalPathname: string,\n routeBundleNames: string[]\n];\n```",
799+
"content": "```typescript\nexport type RouteData = [\n routeName: string,\n moduleLoaders: ModuleLoader[]\n] | [\n routeName: string,\n moduleLoaders: ModuleLoader[],\n originalPathname: string,\n routeBundleNames: string[]\n];\n```",
800800
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik-router/src/runtime/src/types.ts",
801801
"mdFile": "router.routedata.md"
802802
},

packages/docs/src/routes/api/qwik-router/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,10 +1854,10 @@ routeAction$: ActionConstructor;
18541854

18551855
```typescript
18561856
export type RouteData =
1857-
| [routeName: string, loaders: ModuleLoader[]]
1857+
| [routeName: string, moduleLoaders: ModuleLoader[]]
18581858
| [
18591859
routeName: string,
1860-
loaders: ModuleLoader[],
1860+
moduleLoaders: ModuleLoader[],
18611861
originalPathname: string,
18621862
routeBundleNames: string[],
18631863
];

packages/qwik-router/src/adapters/shared/vite/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { StaticGenerateOptions, SsgRenderOptions } from 'packages/qwik-rout
33
import type { QwikRouterPlugin } from '@qwik.dev/router/vite';
44
import { basename, dirname, join, resolve } from 'node:path';
55
import type { Plugin, UserConfig } from 'vite';
6-
import type { BuildRoute } from '../../../buildtime/types';
6+
import type { BuiltRoute } from '../../../buildtime/types';
77
import { postBuild } from './post-build';
88

99
/**
@@ -299,7 +299,7 @@ interface ViteAdapterPluginOptions {
299299
clientPublicOutDir: string;
300300
serverOutDir: string;
301301
basePathname: string;
302-
routes: BuildRoute[];
302+
routes: BuiltRoute[];
303303
assetsDir?: string;
304304
warn: (message: string) => void;
305305
error: (message: string) => void;

packages/qwik-router/src/buildtime/build.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { addError, addWarning } from '../utils/format';
22
import { resolveSourceFiles } from './routing/resolve-source-file';
33
import { walkRoutes } from './routing/walk-routes-dir';
44
import { walkServerPlugins } from './routing/walk-server-plugins';
5-
import type { BuildContext, BuildRoute, RewriteRouteOption } from './types';
5+
import type { RoutingContext, BuiltRoute, RewriteRouteOption } from './types';
66

7-
export async function build(ctx: BuildContext) {
7+
export async function parseRoutesDir(ctx: RoutingContext) {
88
try {
9-
await updateBuildContext(ctx);
9+
await updateRoutingContext(ctx);
1010
validateBuild(ctx);
1111
} catch (e) {
1212
addError(ctx, e);
@@ -21,7 +21,7 @@ export async function build(ctx: BuildContext) {
2121
}
2222
}
2323

24-
export async function updateBuildContext(ctx: BuildContext) {
24+
export async function updateRoutingContext(ctx: RoutingContext) {
2525
if (!ctx.activeBuild) {
2626
ctx.activeBuild = new Promise<void>((resolve, reject) => {
2727
walkServerPlugins(ctx.opts)
@@ -47,12 +47,12 @@ export async function updateBuildContext(ctx: BuildContext) {
4747
return ctx.activeBuild;
4848
}
4949

50-
function rewriteRoutes(ctx: BuildContext, resolvedFiles: ReturnType<typeof resolveSourceFiles>) {
50+
function rewriteRoutes(ctx: RoutingContext, resolvedFiles: ReturnType<typeof resolveSourceFiles>) {
5151
if (!ctx.opts.rewriteRoutes || !resolvedFiles.routes) {
5252
return;
5353
}
5454

55-
const translatedRoutes: BuildRoute[] = [];
55+
const translatedRoutes: BuiltRoute[] = [];
5656

5757
let segmentsToTranslate = ctx.opts.rewriteRoutes.flatMap((rewriteConfig) => {
5858
return Object.keys(rewriteConfig.paths || {});
@@ -95,10 +95,10 @@ function rewriteRoutes(ctx: BuildContext, resolvedFiles: ReturnType<typeof resol
9595
}
9696

9797
function translateRoute(
98-
route: BuildRoute,
98+
route: BuiltRoute,
9999
config: RewriteRouteOption,
100100
configIndex: number
101-
): BuildRoute {
101+
): BuiltRoute {
102102
const replacePath = (part: string) => (config.paths || {})[part] ?? part;
103103

104104
const pathnamePrefix = config.prefix ? '/' + config.prefix : '';
@@ -156,7 +156,7 @@ function translateRoute(
156156
return routeToPush;
157157
}
158158

159-
function validateBuild(ctx: BuildContext) {
159+
function validateBuild(ctx: RoutingContext) {
160160
const pathnames = Array.from(new Set(ctx.routes.map((r) => r.pathname))).sort();
161161

162162
for (const pathname of pathnames) {

packages/qwik-router/src/buildtime/context.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { isAbsolute, resolve } from 'node:path';
22
import { normalizePath } from '../utils/fs';
3-
import type { BuildContext, NormalizedPluginOptions, PluginOptions } from './types';
3+
import type { RoutingContext, NormalizedPluginOptions, PluginOptions } from './types';
44

55
export function createBuildContext(
66
rootDir: string,
@@ -9,7 +9,7 @@ export function createBuildContext(
99
target?: 'ssr' | 'client',
1010
dynamicImports?: boolean
1111
) {
12-
const ctx: BuildContext = {
12+
const ctx: RoutingContext = {
1313
rootDir: normalizePath(rootDir),
1414
opts: normalizeOptions(rootDir, viteBasePath, userOpts),
1515
routes: [],
@@ -28,7 +28,7 @@ export function createBuildContext(
2828
return ctx;
2929
}
3030

31-
export function resetBuildContext(ctx: BuildContext | null) {
31+
export function resetBuildContext(ctx: RoutingContext | null) {
3232
if (ctx) {
3333
ctx.routes.length = 0;
3434
ctx.layouts.length = 0;

packages/qwik-router/src/buildtime/markdown/frontmatter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { Transformer } from 'unified';
2-
import type { BuildContext, FrontmatterAttrs } from '../types';
2+
import type { RoutingContext, FrontmatterAttrs } from '../types';
33
import { normalizePath } from '../../utils/fs';
44
import { visit } from 'unist-util-visit';
55
import { parse as parseYaml } from 'yaml';
66
import type { ResolvedDocumentHead } from '../../runtime/src';
77
import type { DocumentMeta, Editable } from '../../runtime/src/types';
88

9-
export function parseFrontmatter(ctx: BuildContext): Transformer {
9+
export function parseFrontmatter(ctx: RoutingContext): Transformer {
1010
return (mdast, vfile) => {
1111
const attrs: FrontmatterAttrs = {};
1212

packages/qwik-router/src/buildtime/markdown/mdx.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { CompileOptions } from '@mdx-js/mdx';
22
import { SourceMapGenerator } from 'source-map';
33
import { getExtension } from '../../utils/fs';
4-
import type { BuildContext } from '../types';
4+
import type { RoutingContext } from '../types';
55
import { parseFrontmatter } from './frontmatter';
66
import { rehypePage, rehypeSlug, renameClassname, wrapTableWithDiv } from './rehype';
77
import { rehypeSyntaxHighlight } from './syntax-highlight';
88

9-
export async function createMdxTransformer(ctx: BuildContext): Promise<MdxTransform> {
9+
export async function createMdxTransformer(ctx: RoutingContext): Promise<MdxTransform> {
1010
const { compile } = await import('@mdx-js/mdx');
1111
const { default: remarkFrontmatter } = await import('remark-frontmatter');
1212
const { default: remarkGfm } = await import('remark-gfm');

packages/qwik-router/src/buildtime/markdown/menu.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { NormalizedPluginOptions, BuildMenu, ParsedMenuItem, RouteSourceFile } from '../types';
1+
import type { NormalizedPluginOptions, BuiltMenu, ParsedMenuItem, RouteSourceFile } from '../types';
22
import { marked } from 'marked';
33
import { createFileId, getMenuPathname } from '../../utils/fs';
44
import { getMarkdownRelativeUrl } from './markdown-url';
55

66
export function createMenu(opts: NormalizedPluginOptions, filePath: string) {
7-
const menu: BuildMenu = {
7+
const menu: BuiltMenu = {
88
pathname: getMenuPathname(opts, filePath),
99
filePath,
1010
};

packages/qwik-router/src/buildtime/markdown/rehype.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { headingRank } from 'hast-util-heading-rank';
77
import { toString } from 'hast-util-to-string';
88
import { visit } from 'unist-util-visit';
99
import type { ContentHeading } from '../../runtime/src';
10-
import type { BuildContext, NormalizedPluginOptions } from '../types';
10+
import type { RoutingContext, NormalizedPluginOptions } from '../types';
1111
import { getExtension, isMarkdownExt, normalizePath } from '../../utils/fs';
1212
import { frontmatterAttrsToDocumentHead } from './frontmatter';
1313
import { isSameOriginUrl } from '../../utils/pathname';
@@ -31,7 +31,7 @@ export function rehypeSlug(): Transformer {
3131
};
3232
}
3333

34-
export function rehypePage(ctx: BuildContext): Transformer {
34+
export function rehypePage(ctx: RoutingContext): Transformer {
3535
return (ast, vfile) => {
3636
const mdast = ast as Root;
3737
const sourcePath = normalizePath(vfile.path);
@@ -96,12 +96,12 @@ function updateContentLinks(mdast: Root, opts: NormalizedPluginOptions, sourcePa
9696
});
9797
}
9898

99-
function exportFrontmatter(ctx: BuildContext, mdast: Root, sourcePath: string) {
99+
function exportFrontmatter(ctx: RoutingContext, mdast: Root, sourcePath: string) {
100100
const attrs = ctx.frontmatter.get(sourcePath);
101101
createExport(mdast, 'frontmatter', attrs);
102102
}
103103

104-
function exportContentHead(ctx: BuildContext, mdast: Root, sourcePath: string) {
104+
function exportContentHead(ctx: RoutingContext, mdast: Root, sourcePath: string) {
105105
const attrs = ctx.frontmatter.get(sourcePath);
106106
const head = frontmatterAttrsToDocumentHead(attrs);
107107
if (head) {

packages/qwik-router/src/buildtime/routing/resolve-source-file.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { dirname } from 'node:path';
22
import { resolveMenu } from '../markdown/menu';
33
import type {
4-
BuildEntry,
5-
BuildLayout,
6-
BuildRoute,
7-
BuildServerPlugin,
4+
BuiltEntry,
5+
BuiltLayout,
6+
BuiltRoute,
7+
BuiltServerPlugin,
88
NormalizedPluginOptions,
99
RouteSourceFile,
1010
} from '../types';
@@ -93,7 +93,7 @@ export function resolveLayout(opts: NormalizedPluginOptions, layoutSourceFile: R
9393
layoutName = '';
9494
}
9595

96-
const layout: BuildLayout = {
96+
const layout: BuiltLayout = {
9797
id: createFileId(opts.routesDir, filePath),
9898
filePath,
9999
dirPath,
@@ -110,11 +110,11 @@ const LAYOUT_TOP_SUFFIX = '!';
110110

111111
export function resolveRoute(
112112
opts: NormalizedPluginOptions,
113-
appLayouts: BuildLayout[],
113+
appLayouts: BuiltLayout[],
114114
sourceFile: RouteSourceFile
115115
) {
116116
const filePath = sourceFile.filePath;
117-
const layouts: BuildLayout[] = [];
117+
const layouts: BuiltLayout[] = [];
118118
const routesDir = opts.routesDir;
119119
const { layoutName, layoutStop } = parseRouteIndexName(sourceFile.extlessName);
120120
let pathname = getPathnameFromDirPath(opts, sourceFile.dirPath);
@@ -129,7 +129,7 @@ export function resolveRoute(
129129
const hasNamedLayout = layoutName !== '';
130130

131131
for (let i = 0; i < 20; i++) {
132-
let layout: BuildLayout | undefined = undefined;
132+
let layout: BuiltLayout | undefined = undefined;
133133

134134
if (hasNamedLayout && !hasFoundNamedLayout) {
135135
layout = appLayouts.find((l) => l.dirPath === currentDir && l.layoutName === layoutName);
@@ -155,7 +155,7 @@ export function resolveRoute(
155155
}
156156
}
157157

158-
const buildRoute: BuildRoute = {
158+
const buildRoute: BuiltRoute = {
159159
id: createFileId(opts.routesDir, filePath, 'Route'),
160160
filePath,
161161
pathname,
@@ -169,7 +169,7 @@ export function resolveRoute(
169169

170170
export function resolveServerPlugin(opts: NormalizedPluginOptions, sourceFile: RouteSourceFile) {
171171
const filePath = sourceFile.filePath;
172-
const buildRoute: BuildServerPlugin = {
172+
const buildRoute: BuiltServerPlugin = {
173173
id: createFileId(opts.serverPluginsDir, filePath, 'Plugin'),
174174
filePath,
175175
ext: sourceFile.ext,
@@ -181,7 +181,7 @@ function resolveEntry(opts: NormalizedPluginOptions, sourceFile: RouteSourceFile
181181
const pathname = getPathnameFromDirPath(opts, sourceFile.dirPath);
182182
const chunkFileName = pathname.slice(opts.basePathname.length);
183183

184-
const buildEntry: BuildEntry = {
184+
const buildEntry: BuiltEntry = {
185185
id: createFileId(opts.routesDir, sourceFile.filePath, 'Route'),
186186
filePath: sourceFile.filePath,
187187
chunkFileName,
@@ -196,7 +196,7 @@ function resolveServiceWorkerEntry(opts: NormalizedPluginOptions, sourceFile: Ro
196196
const pathname = dirPathname + sourceFile.extlessName + '.js';
197197
const chunkFileName = pathname.slice(opts.basePathname.length);
198198

199-
const buildEntry: BuildEntry = {
199+
const buildEntry: BuiltEntry = {
200200
id: createFileId(opts.routesDir, sourceFile.filePath, 'ServiceWorker'),
201201
filePath: sourceFile.filePath,
202202
chunkFileName,

0 commit comments

Comments
 (0)