Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
277 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/next/src/server/future/normalizers/built/app/app-bundle-path-normalizer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Normalizers } from '../../normalizers' | ||
import { Normalizer } from '../../normalizer' | ||
import { PrefixingNormalizer } from '../../prefixing-normalizer' | ||
|
||
export class AppBundlePathNormalizer extends PrefixingNormalizer { | ||
constructor() { | ||
super('app') | ||
} | ||
|
||
public normalize(page: string): string { | ||
return super.normalize(page) | ||
} | ||
} | ||
|
||
export class DevAppBundlePathNormalizer extends Normalizers { | ||
constructor(pageNormalizer: Normalizer) { | ||
super([ | ||
// This should normalize the filename to a page. | ||
pageNormalizer, | ||
// Normalize the app page to a pathname. | ||
new AppBundlePathNormalizer(), | ||
]) | ||
} | ||
|
||
public normalize(filename: string): string { | ||
return super.normalize(filename) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/next/src/server/future/normalizers/built/app/app-filename-normalizer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { SERVER_DIRECTORY } from '../../../../../shared/lib/constants' | ||
import { PrefixingNormalizer } from '../../prefixing-normalizer' | ||
|
||
export class AppFilenameNormalizer extends PrefixingNormalizer { | ||
constructor(distDir: string) { | ||
super(distDir, SERVER_DIRECTORY) | ||
} | ||
|
||
public normalize(manifestFilename: string): string { | ||
return super.normalize(manifestFilename) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/next/src/server/future/normalizers/built/app/app-page-normalizer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { AbsoluteFilenameNormalizer } from '../../absolute-filename-normalizer' | ||
|
||
/** | ||
* DevAppPageNormalizer is a normalizer that is used to normalize a pathname | ||
* to a page in the `app` directory. | ||
*/ | ||
export class DevAppPageNormalizer extends AbsoluteFilenameNormalizer { | ||
constructor(appDir: string, extensions: ReadonlyArray<string>) { | ||
super(appDir, extensions, 'app') | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
packages/next/src/server/future/normalizers/built/app/app-pathname-normalizer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { normalizeAppPath } from '../../../../../shared/lib/router/utils/app-paths' | ||
import { Normalizers } from '../../normalizers' | ||
import { wrapNormalizerFn } from '../../wrap-normalizer-fn' | ||
import { UnderscoreNormalizer } from '../../underscore-normalizer' | ||
import { Normalizer } from '../../normalizer' | ||
|
||
export class AppPathnameNormalizer extends Normalizers { | ||
constructor() { | ||
super([ | ||
// The pathname to match should have the trailing `/page` and other route | ||
// group information stripped from it. | ||
wrapNormalizerFn(normalizeAppPath), | ||
// The page should have the `%5F` characters replaced with `_` characters. | ||
new UnderscoreNormalizer(), | ||
]) | ||
} | ||
|
||
public normalize(page: string): string { | ||
return super.normalize(page) | ||
} | ||
} | ||
|
||
export class DevAppPathnameNormalizer extends Normalizers { | ||
constructor(pageNormalizer: Normalizer) { | ||
super([ | ||
// This should normalize the filename to a page. | ||
pageNormalizer, | ||
// Normalize the app page to a pathname. | ||
new AppPathnameNormalizer(), | ||
]) | ||
} | ||
|
||
public normalize(filename: string): string { | ||
return super.normalize(filename) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
packages/next/src/server/future/normalizers/built/app/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
AppBundlePathNormalizer, | ||
DevAppBundlePathNormalizer, | ||
} from './app-bundle-path-normalizer' | ||
import { AppFilenameNormalizer } from './app-filename-normalizer' | ||
import { DevAppPageNormalizer } from './app-page-normalizer' | ||
import { | ||
AppPathnameNormalizer, | ||
DevAppPathnameNormalizer, | ||
} from './app-pathname-normalizer' | ||
|
||
export class AppNormalizers { | ||
public readonly filename: AppFilenameNormalizer | ||
public readonly pathname: AppPathnameNormalizer | ||
public readonly bundlePath: AppBundlePathNormalizer | ||
|
||
constructor(distDir: string) { | ||
this.filename = new AppFilenameNormalizer(distDir) | ||
this.pathname = new AppPathnameNormalizer() | ||
this.bundlePath = new AppBundlePathNormalizer() | ||
} | ||
} | ||
|
||
export class DevAppNormalizers { | ||
public readonly page: DevAppPageNormalizer | ||
public readonly pathname: DevAppPathnameNormalizer | ||
public readonly bundlePath: DevAppBundlePathNormalizer | ||
|
||
constructor(appDir: string, extensions: ReadonlyArray<string>) { | ||
this.page = new DevAppPageNormalizer(appDir, extensions) | ||
this.pathname = new DevAppPathnameNormalizer(this.page) | ||
this.bundlePath = new DevAppBundlePathNormalizer(this.page) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/next/src/server/future/normalizers/built/pages/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
DevPagesBundlePathNormalizer, | ||
PagesBundlePathNormalizer, | ||
} from './pages-bundle-path-normalizer' | ||
import { PagesFilenameNormalizer } from './pages-filename-normalizer' | ||
import { DevPagesPageNormalizer } from './pages-page-normalizer' | ||
import { DevPagesPathnameNormalizer } from './pages-pathname-normalizer' | ||
|
||
export class PagesNormalizers { | ||
public readonly filename: PagesFilenameNormalizer | ||
public readonly bundlePath: PagesBundlePathNormalizer | ||
|
||
constructor(distDir: string) { | ||
this.filename = new PagesFilenameNormalizer(distDir) | ||
this.bundlePath = new PagesBundlePathNormalizer() | ||
|
||
// You'd think that we'd require a `pathname` normalizer here, but for | ||
// `/pages` we have to handle i18n routes, which means that we need to | ||
// analyze the page path to determine the locale prefix and it's locale. | ||
} | ||
} | ||
|
||
export class DevPagesNormalizers { | ||
public readonly page: DevPagesPageNormalizer | ||
public readonly pathname: DevPagesPathnameNormalizer | ||
public readonly bundlePath: DevPagesBundlePathNormalizer | ||
|
||
constructor(pagesDir: string, extensions: ReadonlyArray<string>) { | ||
this.page = new DevPagesPageNormalizer(pagesDir, extensions) | ||
this.pathname = new DevPagesPathnameNormalizer(pagesDir, extensions) | ||
this.bundlePath = new DevPagesBundlePathNormalizer(this.page) | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
packages/next/src/server/future/normalizers/built/pages/pages-bundle-path-normalizer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { normalizePagePath } from '../../../../../shared/lib/page-path/normalize-page-path' | ||
import { Normalizer } from '../../normalizer' | ||
import { Normalizers } from '../../normalizers' | ||
import { PrefixingNormalizer } from '../../prefixing-normalizer' | ||
import { wrapNormalizerFn } from '../../wrap-normalizer-fn' | ||
|
||
export class PagesBundlePathNormalizer extends Normalizers { | ||
constructor() { | ||
super([ | ||
// The bundle path should have the trailing `/index` stripped from | ||
// it. | ||
wrapNormalizerFn(normalizePagePath), | ||
// The page should prefixed with `pages/`. | ||
new PrefixingNormalizer('pages'), | ||
]) | ||
} | ||
|
||
public normalize(page: string): string { | ||
return super.normalize(page) | ||
} | ||
} | ||
|
||
export class DevPagesBundlePathNormalizer extends Normalizers { | ||
constructor(pagesNormalizer: Normalizer) { | ||
super([ | ||
// This should normalize the filename to a page. | ||
pagesNormalizer, | ||
// Normalize the app page to a pathname. | ||
new PagesBundlePathNormalizer(), | ||
]) | ||
} | ||
|
||
public normalize(filename: string): string { | ||
return super.normalize(filename) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/next/src/server/future/normalizers/built/pages/pages-filename-normalizer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { SERVER_DIRECTORY } from '../../../../../shared/lib/constants' | ||
import { PrefixingNormalizer } from '../../prefixing-normalizer' | ||
|
||
export class PagesFilenameNormalizer extends PrefixingNormalizer { | ||
constructor(distDir: string) { | ||
super(distDir, SERVER_DIRECTORY) | ||
} | ||
|
||
public normalize(manifestFilename: string): string { | ||
return super.normalize(manifestFilename) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/next/src/server/future/normalizers/built/pages/pages-page-normalizer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { AbsoluteFilenameNormalizer } from '../../absolute-filename-normalizer' | ||
|
||
export class DevPagesPageNormalizer extends AbsoluteFilenameNormalizer { | ||
constructor(pagesDir: string, extensions: ReadonlyArray<string>) { | ||
super(pagesDir, extensions, 'pages') | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/next/src/server/future/normalizers/built/pages/pages-pathname-normalizer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { AbsoluteFilenameNormalizer } from '../../absolute-filename-normalizer' | ||
|
||
export class DevPagesPathnameNormalizer extends AbsoluteFilenameNormalizer { | ||
constructor(pagesDir: string, extensions: ReadonlyArray<string>) { | ||
super(pagesDir, extensions, 'pages') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.