From e16c74bcaa43618ff596e2e1e33ce8ea1d6b0892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Wed, 7 Sep 2022 15:19:54 +0200 Subject: [PATCH 01/69] chore: turn off debug mode on issue validator (#40301) The issue validator GitHub action has been running in the background for a while, and the output looks good: https://github.com/vercel/next.js/actions/workflows/validate_issue.yml This PR switches off debug mode and will start commenting on improper bug reports to make triaging more effective. --- .github/workflows/validate_issue.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/validate_issue.yml b/.github/workflows/validate_issue.yml index 3c6e3a4a2e43..abd6c0784d5f 100644 --- a/.github/workflows/validate_issue.yml +++ b/.github/workflows/validate_issue.yml @@ -15,4 +15,3 @@ jobs: run: node ./.github/actions/issue-validator/index.mjs env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DEBUG: 1 From 084ad964a0ed9af5c7594f40b73ca77ed1b460be Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Wed, 7 Sep 2022 18:28:15 +0200 Subject: [PATCH 02/69] Fix static info parsing when export data fetching method as variable (#40317) Fix the ssr/ssg detection when you export a nextjs data fetching method as a variable instead of an async function. - [x] Add case support in `checkExports` - [x] Add unit tests for `getPageStaticInfo` --- .../build/analysis/get-page-static-info.ts | 13 +++++++++ .../page-runtime/ssr-variable-gssp.js | 12 +++++++++ ...test.ts => parse-page-static-info.test.ts} | 27 +++++++++++++++---- 3 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 test/unit/fixtures/page-runtime/ssr-variable-gssp.js rename test/unit/{parse-page-runtime.test.ts => parse-page-static-info.test.ts} (69%) diff --git a/packages/next/build/analysis/get-page-static-info.ts b/packages/next/build/analysis/get-page-static-info.ts index cc18cc8d743a..bcaaac6bd2cc 100644 --- a/packages/next/build/analysis/get-page-static-info.ts +++ b/packages/next/build/analysis/get-page-static-info.ts @@ -53,6 +53,19 @@ export function checkExports(swcAST: any): { ssr: boolean; ssg: boolean } { } } + if ( + node.type === 'ExportDeclaration' && + node.declaration?.type === 'VariableDeclaration' + ) { + const id = node.declaration?.declarations[0]?.id.value + if (['getStaticProps', 'getServerSideProps'].includes(id)) { + return { + ssg: id === 'getStaticProps', + ssr: id === 'getServerSideProps', + } + } + } + if (node.type === 'ExportNamedDeclaration') { const values = node.specifiers.map( (specifier: any) => diff --git a/test/unit/fixtures/page-runtime/ssr-variable-gssp.js b/test/unit/fixtures/page-runtime/ssr-variable-gssp.js new file mode 100644 index 000000000000..e09007babef5 --- /dev/null +++ b/test/unit/fixtures/page-runtime/ssr-variable-gssp.js @@ -0,0 +1,12 @@ +export default function Nodejs() { + return 'nodejs' +} + +// export an identifier instead of function +export const getServerSideProps = async () => { + return { props: {} } +} + +export const config = { + runtime: 'experimental-edge', +} diff --git a/test/unit/parse-page-runtime.test.ts b/test/unit/parse-page-static-info.test.ts similarity index 69% rename from test/unit/parse-page-runtime.test.ts rename to test/unit/parse-page-static-info.test.ts index a9c4a358faaf..772081e53fb0 100644 --- a/test/unit/parse-page-runtime.test.ts +++ b/test/unit/parse-page-static-info.test.ts @@ -9,21 +9,25 @@ function createNextConfig(runtime?: 'experimental-edge' | 'nodejs') { } } -describe('parse page runtime config', () => { +describe('parse page static info', () => { it('should parse nodejs runtime correctly', async () => { - const { runtime } = await getPageStaticInfo({ + const { runtime, ssr, ssg } = await getPageStaticInfo({ pageFilePath: join(fixtureDir, 'page-runtime/nodejs-ssr.js'), nextConfig: createNextConfig(), }) expect(runtime).toBe('nodejs') + expect(ssr).toBe(true) + expect(ssg).toBe(false) }) it('should parse static runtime correctly', async () => { - const { runtime } = await getPageStaticInfo({ + const { runtime, ssr, ssg } = await getPageStaticInfo({ pageFilePath: join(fixtureDir, 'page-runtime/nodejs.js'), nextConfig: createNextConfig(), }) expect(runtime).toBe(undefined) + expect(ssr).toBe(false) + expect(ssg).toBe(false) }) it('should parse edge runtime correctly', async () => { @@ -41,22 +45,35 @@ describe('parse page runtime config', () => { }) expect(runtime).toBe(undefined) }) + + it('should parse ssr info with variable exported gSSP correctly', async () => { + const { ssr, ssg } = await getPageStaticInfo({ + pageFilePath: join(fixtureDir, 'page-runtime/ssr-variable-gssp.js'), + nextConfig: createNextConfig(), + }) + expect(ssr).toBe(true) + expect(ssg).toBe(false) + }) }) describe('fallback to the global runtime configuration', () => { it('should fallback when gSP is defined and exported', async () => { - const { runtime } = await getPageStaticInfo({ + const { runtime, ssr, ssg } = await getPageStaticInfo({ pageFilePath: join(fixtureDir, 'page-runtime/fallback-with-gsp.js'), nextConfig: createNextConfig('experimental-edge'), }) expect(runtime).toBe('experimental-edge') + expect(ssr).toBe(false) + expect(ssg).toBe(true) }) it('should fallback when gSP is re-exported from other module', async () => { - const { runtime } = await getPageStaticInfo({ + const { runtime, ssr, ssg } = await getPageStaticInfo({ pageFilePath: join(fixtureDir, 'page-runtime/fallback-re-export-gsp.js'), nextConfig: createNextConfig('experimental-edge'), }) expect(runtime).toBe('experimental-edge') + expect(ssr).toBe(false) + expect(ssg).toBe(true) }) }) From 35253e1a938eb773310a7a28d8ab3f3be8462b08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Wed, 7 Sep 2022 22:12:13 +0200 Subject: [PATCH 03/69] fix(switchable-runtime): make dev server not break when wrong runtime config is exported (#40312) Currently the DEV server can't recover if you export an invalid runtime config. It ends up in a state where it stops to work but nothing is printed to the terminal. It now prints an error but keeps working. When building it should crash, there's an existing test for that https://github.com/vercel/next.js/blob/canary/test/production/exported-runtimes-value-validation/index.test.ts#L5-L17 #### Reproduce ```tsx export default function Page() { return

hello world

} export const config = { runtime: 'something-odd', } ``` --- .../build/analysis/get-page-static-info.ts | 13 ++-- packages/next/server/dev/hot-reloader.ts | 1 + packages/next/server/dev/next-dev-server.ts | 1 + .../server/dev/on-demand-entry-handler.ts | 1 + test/e2e/switchable-runtime/index.test.ts | 68 +++++++++++++++++++ .../pages/invalid-runtime.js | 3 + 6 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 test/e2e/switchable-runtime/pages/invalid-runtime.js diff --git a/packages/next/build/analysis/get-page-static-info.ts b/packages/next/build/analysis/get-page-static-info.ts index bcaaac6bd2cc..37d95e9bdcdd 100644 --- a/packages/next/build/analysis/get-page-static-info.ts +++ b/packages/next/build/analysis/get-page-static-info.ts @@ -239,21 +239,22 @@ export async function getPageStaticInfo(params: { } if ( - typeof config.runtime !== 'string' && - typeof config.runtime !== 'undefined' + typeof config.runtime !== 'undefined' && + !isServerRuntime(config.runtime) ) { - throw new Error(`Provided runtime `) - } else if (!isServerRuntime(config.runtime)) { const options = Object.values(SERVER_RUNTIME).join(', ') if (typeof config.runtime !== 'string') { - throw new Error( + Log.error( `The \`runtime\` config must be a string. Please leave it empty or choose one of: ${options}` ) } else { - throw new Error( + Log.error( `Provided runtime "${config.runtime}" is not supported. Please leave it empty or choose one of: ${options}` ) } + if (!isDev) { + process.exit(1) + } } let runtime = diff --git a/packages/next/server/dev/hot-reloader.ts b/packages/next/server/dev/hot-reloader.ts index 8e1d195b7c7b..7a7584b43bdc 100644 --- a/packages/next/server/dev/hot-reloader.ts +++ b/packages/next/server/dev/hot-reloader.ts @@ -602,6 +602,7 @@ export default class HotReloader { ? await getPageStaticInfo({ pageFilePath: entryData.absolutePagePath, nextConfig: this.config, + isDev: true, }) : {} diff --git a/packages/next/server/dev/next-dev-server.ts b/packages/next/server/dev/next-dev-server.ts index 920a6264845d..d360778905f4 100644 --- a/packages/next/server/dev/next-dev-server.ts +++ b/packages/next/server/dev/next-dev-server.ts @@ -369,6 +369,7 @@ export default class DevServer extends Server { pageFilePath: fileName, nextConfig: this.nextConfig, page: rootFile, + isDev: true, }) if (isMiddlewareFile(rootFile)) { diff --git a/packages/next/server/dev/on-demand-entry-handler.ts b/packages/next/server/dev/on-demand-entry-handler.ts index a0a2fe8bf171..1c752b7b296d 100644 --- a/packages/next/server/dev/on-demand-entry-handler.ts +++ b/packages/next/server/dev/on-demand-entry-handler.ts @@ -632,6 +632,7 @@ export function onDemandEntryHandler({ const staticInfo = await getPageStaticInfo({ pageFilePath: pagePathData.absolutePagePath, nextConfig, + isDev: true, }) const added = new Map>() diff --git a/test/e2e/switchable-runtime/index.test.ts b/test/e2e/switchable-runtime/index.test.ts index f21f94dba24b..b9cef7819887 100644 --- a/test/e2e/switchable-runtime/index.test.ts +++ b/test/e2e/switchable-runtime/index.test.ts @@ -202,6 +202,74 @@ describe('Switchable runtime', () => { }) } }) + + it('should not crash the dev server when invalid runtime is configured', async () => { + await check( + () => renderViaHTTP(next.url, '/invalid-runtime'), + /Hello from page without errors/ + ) + + // Invalid runtime type + await next.patchFile( + 'pages/invalid-runtime.js', + ` + export default function Page() { + return

Hello from page with invalid type

+ } + + export const config = { + runtime: 10, + } + ` + ) + await check( + () => renderViaHTTP(next.url, '/invalid-runtime'), + /Hello from page with invalid type/ + ) + expect(next.cliOutput).toInclude( + 'error - The `runtime` config must be a string. Please leave it empty or choose one of:' + ) + + // Invalid runtime + await next.patchFile( + 'pages/invalid-runtime.js', + ` + export default function Page() { + return

Hello from page with invalid runtime

+ } + + export const config = { + runtime: "asd" + } + ` + ) + await check( + () => renderViaHTTP(next.url, '/invalid-runtime'), + /Hello from page with invalid runtime/ + ) + expect(next.cliOutput).toInclude( + 'error - Provided runtime "asd" is not supported. Please leave it empty or choose one of:' + ) + + // Fix the runtime + await next.patchFile( + 'pages/invalid-runtime.js', + ` + export default function Page() { + return

Hello from page without errors

+ } + + export const config = { + runtime: 'experimental-edge', + } + + ` + ) + await check( + () => renderViaHTTP(next.url, '/invalid-runtime'), + /Hello from page without errors/ + ) + }) }) } else { describe('Switchable runtime (prod)', () => { diff --git a/test/e2e/switchable-runtime/pages/invalid-runtime.js b/test/e2e/switchable-runtime/pages/invalid-runtime.js new file mode 100644 index 000000000000..17235157127b --- /dev/null +++ b/test/e2e/switchable-runtime/pages/invalid-runtime.js @@ -0,0 +1,3 @@ +export default function Page() { + return

Hello from page without errors

+} From d5e6eb1ef221ddc8d27de11792595c452c4303c2 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 7 Sep 2022 13:24:29 -0700 Subject: [PATCH 04/69] Revert "Refactor Server Router" (#40328) This temporarily reverts the refactor while we investigate https://github.com/vercel/next.js/issues/40241 further. Reverts vercel/next.js#39902 --- packages/next/server/dev/next-dev-server.ts | 1 + packages/next/server/router.ts | 478 +++++++++----------- 2 files changed, 214 insertions(+), 265 deletions(-) diff --git a/packages/next/server/dev/next-dev-server.ts b/packages/next/server/dev/next-dev-server.ts index d360778905f4..a67bfb58bcbb 100644 --- a/packages/next/server/dev/next-dev-server.ts +++ b/packages/next/server/dev/next-dev-server.ts @@ -221,6 +221,7 @@ export default class DevServer extends Server { for (const path in exportPathMap) { const { page, query = {} } = exportPathMap[path] + // We use unshift so that we're sure the routes is defined before Next's default routes this.router.addFsRoute({ match: getPathMatch(path), type: 'route', diff --git a/packages/next/server/router.ts b/packages/next/server/router.ts index ca2ce97b1a7d..0cb309f823af 100644 --- a/packages/next/server/router.ts +++ b/packages/next/server/router.ts @@ -40,7 +40,7 @@ export type Route = { res: BaseNextResponse, params: Params, parsedUrl: NextUrlWithParsedQuery, - upgradeHead?: Buffer + upgradeHead?: any ) => Promise | RouteResult } @@ -49,37 +49,21 @@ export type DynamicRoutes = Array<{ page: string; match: RouteMatch }> export type PageChecker = (pathname: string) => Promise export default class Router { - public catchAllMiddleware: ReadonlyArray - - private readonly headers: ReadonlyArray - private readonly fsRoutes: Route[] - private readonly redirects: ReadonlyArray - private readonly rewrites: { - beforeFiles: ReadonlyArray - afterFiles: ReadonlyArray - fallback: ReadonlyArray + headers: Route[] + fsRoutes: Route[] + redirects: Route[] + rewrites: { + beforeFiles: Route[] + afterFiles: Route[] + fallback: Route[] } - private readonly catchAllRoute: Route - private readonly pageChecker: PageChecker - private dynamicRoutes: DynamicRoutes - private readonly useFileSystemPublicRoutes: boolean - private readonly nextConfig: NextConfig - private compiledRoutes: ReadonlyArray - private needsRecompilation: boolean - - /** - * context stores information used by the router. - */ - private readonly context = new WeakMap< - BaseNextRequest, - { - /** - * pageChecks is the memoized record of all checks made against pages to - * help de-duplicate work. - */ - pageChecks: Record - } - >() + catchAllRoute: Route + catchAllMiddleware: Route[] + pageChecker: PageChecker + dynamicRoutes: DynamicRoutes + useFileSystemPublicRoutes: boolean + seenRequests: Set + nextConfig: NextConfig constructor({ headers = [], @@ -97,16 +81,16 @@ export default class Router { useFileSystemPublicRoutes, nextConfig, }: { - headers: ReadonlyArray - fsRoutes: ReadonlyArray + headers: Route[] + fsRoutes: Route[] rewrites: { - beforeFiles: ReadonlyArray - afterFiles: ReadonlyArray - fallback: ReadonlyArray + beforeFiles: Route[] + afterFiles: Route[] + fallback: Route[] } - redirects: ReadonlyArray + redirects: Route[] catchAllRoute: Route - catchAllMiddleware: ReadonlyArray + catchAllMiddleware: Route[] dynamicRoutes: DynamicRoutes | undefined pageChecker: PageChecker useFileSystemPublicRoutes: boolean @@ -114,7 +98,7 @@ export default class Router { }) { this.nextConfig = nextConfig this.headers = headers - this.fsRoutes = [...fsRoutes] + this.fsRoutes = fsRoutes this.rewrites = rewrites this.redirects = redirects this.pageChecker = pageChecker @@ -122,32 +106,7 @@ export default class Router { this.catchAllMiddleware = catchAllMiddleware this.dynamicRoutes = dynamicRoutes this.useFileSystemPublicRoutes = useFileSystemPublicRoutes - - // Perform the initial route compilation. - this.compiledRoutes = this.compileRoutes() - this.needsRecompilation = false - } - - private async checkPage( - req: BaseNextRequest, - pathname: string - ): Promise { - pathname = normalizeLocalePath(pathname, this.locales).pathname - - const context = this.context.get(req) - if (!context) { - throw new Error( - 'Invariant: request is not available inside the context, this is an internal error please open an issue.' - ) - } - - if (context.pageChecks[pathname] !== undefined) { - return context.pageChecks[pathname] - } - - const result = await this.pageChecker(pathname) - context.pageChecks[pathname] = result - return result + this.seenRequests = new Set() } get locales() { @@ -158,201 +117,192 @@ export default class Router { return this.nextConfig.basePath || '' } - public setDynamicRoutes(dynamicRoutes: DynamicRoutes) { - this.dynamicRoutes = dynamicRoutes - this.needsRecompilation = true + setDynamicRoutes(routes: DynamicRoutes = []) { + this.dynamicRoutes = routes } - public setCatchallMiddleware(catchAllMiddleware: ReadonlyArray) { - this.catchAllMiddleware = catchAllMiddleware - this.needsRecompilation = true + setCatchallMiddleware(route?: Route[]) { + this.catchAllMiddleware = route || [] } - public addFsRoute(fsRoute: Route) { - // We use unshift so that we're sure the routes is defined before Next's - // default routes. + addFsRoute(fsRoute: Route) { this.fsRoutes.unshift(fsRoute) - this.needsRecompilation = true - } - - private compileRoutes(): ReadonlyArray { - /* - Desired routes order - - headers - - redirects - - Check filesystem (including pages), if nothing found continue - - User rewrites (checking filesystem and pages each match) - */ - - const [middlewareCatchAllRoute] = this.catchAllMiddleware - - return [ - ...(middlewareCatchAllRoute - ? this.fsRoutes - .filter((route) => route.name === '_next/data catchall') - .map((route) => ({ ...route, check: false })) - : []), - ...this.headers, - ...this.redirects, - ...(this.useFileSystemPublicRoutes && middlewareCatchAllRoute - ? [middlewareCatchAllRoute] - : []), - ...this.rewrites.beforeFiles, - ...this.fsRoutes, - // We only check the catch-all route if public page routes hasn't been - // disabled - ...(this.useFileSystemPublicRoutes - ? [ - { - type: 'route', - name: 'page checker', - match: getPathMatch('/:path*'), - fn: async (req, res, params, parsedUrl, upgradeHead) => { - const pathname = removeTrailingSlash(parsedUrl.pathname || '/') - if (!pathname) { - return { finished: false } - } - - if (await this.checkPage(req, pathname)) { - return this.catchAllRoute.fn( - req, - res, - params, - parsedUrl, - upgradeHead - ) - } - - return { finished: false } - }, - } as Route, - ] - : []), - ...this.rewrites.afterFiles, - ...(this.rewrites.fallback.length - ? [ - { - type: 'route', - name: 'dynamic route/page check', - match: getPathMatch('/:path*'), - fn: async (req, res, _params, parsedCheckerUrl, upgradeHead) => { - return { - finished: await this.checkFsRoutes( - req, - res, - parsedCheckerUrl, - upgradeHead - ), - } - }, - } as Route, - ...this.rewrites.fallback, - ] - : []), - - // We only check the catch-all route if public page routes hasn't been - // disabled - ...(this.useFileSystemPublicRoutes ? [this.catchAllRoute] : []), - ] } - private async checkFsRoutes( + async execute( req: BaseNextRequest, res: BaseNextResponse, parsedUrl: NextUrlWithParsedQuery, - upgradeHead?: Buffer - ) { - const originalFsPathname = parsedUrl.pathname - const fsPathname = removePathPrefix(originalFsPathname!, this.basePath) - - for (const route of this.fsRoutes) { - const params = route.match(fsPathname) - - if (params) { - parsedUrl.pathname = fsPathname - - const { finished } = await route.fn(req, res, params, parsedUrl) - if (finished) { - return true - } - - parsedUrl.pathname = originalFsPathname - } + upgradeHead?: any + ): Promise { + if (this.seenRequests.has(req)) { + throw new Error( + `Invariant: request has already been processed: ${req.url}, this is an internal error please open an issue.` + ) } + this.seenRequests.add(req) + try { + // memoize page check calls so we don't duplicate checks for pages + const pageChecks: { [name: string]: Promise } = {} + const memoizedPageChecker = async (p: string): Promise => { + p = normalizeLocalePath(p, this.locales).pathname - let matchedPage = await this.checkPage(req, fsPathname) - - // If we didn't match a page check dynamic routes - if (!matchedPage) { - const normalizedFsPathname = normalizeLocalePath( - fsPathname, - this.locales - ).pathname - - for (const dynamicRoute of this.dynamicRoutes) { - if (dynamicRoute.match(normalizedFsPathname)) { - matchedPage = true + if (pageChecks[p] !== undefined) { + return pageChecks[p] } + const result = this.pageChecker(p) + pageChecks[p] = result + return result } - } - // Matched a page or dynamic route so render it using catchAllRoute - if (matchedPage) { - const params = this.catchAllRoute.match(parsedUrl.pathname) - if (!params) { - throw new Error( - `Invariant: could not match params, this is an internal error please open an issue.` - ) - } + let parsedUrlUpdated = parsedUrl - parsedUrl.pathname = fsPathname - parsedUrl.query._nextBubbleNoFallback = '1' + const applyCheckTrue = async (checkParsedUrl: NextUrlWithParsedQuery) => { + const originalFsPathname = checkParsedUrl.pathname + const fsPathname = removePathPrefix(originalFsPathname!, this.basePath) - const { finished } = await this.catchAllRoute.fn( - req, - res, - params, - parsedUrl, - upgradeHead - ) + for (const fsRoute of this.fsRoutes) { + const fsParams = fsRoute.match(fsPathname) - return finished - } + if (fsParams) { + checkParsedUrl.pathname = fsPathname - return false - } + const fsResult = await fsRoute.fn( + req, + res, + fsParams, + checkParsedUrl + ) - async execute( - req: BaseNextRequest, - res: BaseNextResponse, - parsedUrl: NextUrlWithParsedQuery, - upgradeHead?: Buffer - ): Promise { - // Only recompile if the routes need to be recompiled, this should only - // happen in development. - if (this.needsRecompilation) { - this.compiledRoutes = this.compileRoutes() - this.needsRecompilation = false - } + if (fsResult.finished) { + return true + } - if (this.context.has(req)) { - throw new Error( - `Invariant: request has already been processed: ${req.url}, this is an internal error please open an issue.` - ) - } - this.context.set(req, { pageChecks: {} }) + checkParsedUrl.pathname = originalFsPathname + } + } + let matchedPage = await memoizedPageChecker(fsPathname) + + // If we didn't match a page check dynamic routes + if (!matchedPage) { + const normalizedFsPathname = normalizeLocalePath( + fsPathname, + this.locales + ).pathname + + for (const dynamicRoute of this.dynamicRoutes) { + if (dynamicRoute.match(normalizedFsPathname)) { + matchedPage = true + } + } + } - try { - // Create a deep copy of the parsed URL. - const parsedUrlUpdated = { - ...parsedUrl, - query: { - ...parsedUrl.query, - }, + // Matched a page or dynamic route so render it using catchAllRoute + if (matchedPage) { + const pageParams = this.catchAllRoute.match(checkParsedUrl.pathname) + checkParsedUrl.pathname = fsPathname + checkParsedUrl.query._nextBubbleNoFallback = '1' + + const result = await this.catchAllRoute.fn( + req, + res, + pageParams as Params, + checkParsedUrl + ) + return result.finished + } } - for (const route of this.compiledRoutes) { + /* + Desired routes order + - headers + - redirects + - Check filesystem (including pages), if nothing found continue + - User rewrites (checking filesystem and pages each match) + */ + + const [middlewareCatchAllRoute] = this.catchAllMiddleware + const allRoutes = [ + ...(middlewareCatchAllRoute + ? this.fsRoutes + .filter((r) => r.name === '_next/data catchall') + .map((r) => { + return { + ...r, + check: false, + } + }) + : []), + ...this.headers, + ...this.redirects, + ...(this.useFileSystemPublicRoutes && middlewareCatchAllRoute + ? [middlewareCatchAllRoute] + : []), + ...this.rewrites.beforeFiles, + ...this.fsRoutes, + // We only check the catch-all route if public page routes hasn't been + // disabled + ...(this.useFileSystemPublicRoutes + ? [ + { + type: 'route', + name: 'page checker', + match: getPathMatch('/:path*'), + fn: async ( + checkerReq, + checkerRes, + params, + parsedCheckerUrl + ) => { + let { pathname } = parsedCheckerUrl + pathname = removeTrailingSlash(pathname || '/') + + if (!pathname) { + return { finished: false } + } + + if (await memoizedPageChecker(pathname)) { + return this.catchAllRoute.fn( + checkerReq, + checkerRes, + params, + parsedCheckerUrl + ) + } + return { finished: false } + }, + } as Route, + ] + : []), + ...this.rewrites.afterFiles, + ...(this.rewrites.fallback.length + ? [ + { + type: 'route', + name: 'dynamic route/page check', + match: getPathMatch('/:path*'), + fn: async ( + _checkerReq, + _checkerRes, + _params, + parsedCheckerUrl + ) => { + return { + finished: await applyCheckTrue(parsedCheckerUrl), + } + }, + } as Route, + ...this.rewrites.fallback, + ] + : []), + + // We only check the catch-all route if public page routes hasn't been + // disabled + ...(this.useFileSystemPublicRoutes ? [this.catchAllRoute] : []), + ] + + for (const testRoute of allRoutes) { // only process rewrites for upgrade request - if (upgradeHead && route.type !== 'rewrite') { + if (upgradeHead && testRoute.type !== 'rewrite') { continue } @@ -364,7 +314,7 @@ export default class Router { if ( pathnameInfo.locale && - !route.matchesLocaleAPIRoutes && + !testRoute.matchesLocaleAPIRoutes && pathnameInfo.pathname.match(/^\/api(?:\/|$)/) ) { continue @@ -375,20 +325,20 @@ export default class Router { } const basePath = pathnameInfo.basePath - if (!route.matchesBasePath) { + if (!testRoute.matchesBasePath) { pathnameInfo.basePath = '' } if ( - route.matchesLocale && - parsedUrlUpdated.query.__nextLocale && + testRoute.matchesLocale && + parsedUrl.query.__nextLocale && !pathnameInfo.locale ) { - pathnameInfo.locale = parsedUrlUpdated.query.__nextLocale + pathnameInfo.locale = parsedUrl.query.__nextLocale } if ( - !route.matchesLocale && + !testRoute.matchesLocale && pathnameInfo.locale === this.nextConfig.i18n?.defaultLocale && pathnameInfo.locale ) { @@ -396,7 +346,7 @@ export default class Router { } if ( - route.matchesTrailingSlash && + testRoute.matchesTrailingSlash && getRequestMeta(req, '__nextHadTrailingSlash') ) { pathnameInfo.trailingSlash = true @@ -407,13 +357,13 @@ export default class Router { ...pathnameInfo, }) - let params = route.match(matchPathname) - if (route.has && params) { - const hasParams = matchHas(req, route.has, parsedUrlUpdated.query) + let newParams = testRoute.match(matchPathname) + if (testRoute.has && newParams) { + const hasParams = matchHas(req, testRoute.has, parsedUrlUpdated.query) if (hasParams) { - Object.assign(params, hasParams) + Object.assign(newParams, hasParams) } else { - params = false + newParams = false } } @@ -423,34 +373,35 @@ export default class Router { * never there, we consider this an invalid match and keep routing. */ if ( - params && + newParams && this.basePath && - !route.matchesBasePath && + !testRoute.matchesBasePath && !getRequestMeta(req, '_nextDidRewrite') && !basePath ) { continue } - if (params) { + if (newParams) { parsedUrlUpdated.pathname = matchPathname - const result = await route.fn( + const result = await testRoute.fn( req, res, - params, + newParams, parsedUrlUpdated, upgradeHead ) + if (result.finished) { return true } + // since the fs route didn't finish routing we need to re-add the + // basePath to continue checking with the basePath present + parsedUrlUpdated.pathname = originalPathname + if (result.pathname) { parsedUrlUpdated.pathname = result.pathname - } else { - // since the fs route didn't finish routing we need to re-add the - // basePath to continue checking with the basePath present - parsedUrlUpdated.pathname = originalPathname } if (result.query) { @@ -461,19 +412,16 @@ export default class Router { } // check filesystem - if ( - route.check && - (await this.checkFsRoutes(req, res, parsedUrlUpdated)) - ) { - return true + if (testRoute.check === true) { + if (await applyCheckTrue(parsedUrlUpdated)) { + return true + } } } } - - // All routes were tested, none were found. return false } finally { - this.context.delete(req) + this.seenRequests.delete(req) } } } From a9b9e007033a3e2618352d3e0516d9870a70069b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Born=C3=B6?= Date: Wed, 7 Sep 2022 22:42:32 +0200 Subject: [PATCH 05/69] fix(switchable-runtime): Make it possible to switch between edge and server runtime in dev (#39327) Makes it possible to switch between edge/server runtime in dev without breaking the server. Fixes slack: [1](https://vercel.slack.com/archives/CGU8HUTUH/p1659082535540549) [2](https://vercel.slack.com/archives/C02CDC2ALJH/p1658978287244359) [3](https://vercel.slack.com/archives/C03KAR5DCKC/p1656869427468779) #### middleware-plugin.ts `middlewareManifest` moved from module scope to local scope. Stale state from earlier builds ended up in `middleware-manifest.json`. Functions that changed from edge to server runtime stayed in the manifest as edge functions. #### on-demand-entry-handler.ts When a server or edge entry is added we check if it has switched runtime. If that's the case the old entry is removed. #### Reproduce Create edge API route and visit `/api/hello` ```js // pages/api/hello.js export const config = { runtime: 'experimental-edge', } export default () => new Response('Hello') ``` Change it to a server api route and visit `/api/hello`, it will explode. ```js // pages/api/hello.js export default function (req, res) { res.send('Hello') } ``` #### Bug not fixed One EDGE case is not fixed. It occurs if you switch between edge and server runtime several times without changing the content of the file: Edge runtime ```js export const config = { runtime: 'experimental-edge', } export default () => new Response('Hello') ``` Change it to a server runtime ```js export default function (req, res) { res.send('Hello') } ``` Change back to edge runtime, the content of the file is the same as the first time we compiled the edge runtime version. ```js export const config = { runtime: 'experimental-edge', } export default () => new Response('Hello') ``` The reason is that both the edge and server compiler emits to the same file (/.next/server/pages/api/hello.js) which makes this check fail in webpack: https://github.com/webpack/webpack/blob/main/lib/Compiler.js#L849-L861 Possible solution is to use different output folders for edge and server https://vercel.slack.com/archives/CGU8HUTUH/p1661163106667559 Co-authored-by: JJ Kasper --- .../webpack/plugins/middleware-plugin.ts | 12 +- .../server/dev/on-demand-entry-handler.ts | 10 + test/e2e/switchable-runtime/index.test.ts | 184 ++++++++++++++++++ .../pages/api/switch-in-dev-same-content.js | 3 + .../pages/api/switch-in-dev.js | 3 + .../pages/api/syntax-error-in-dev.js | 5 + .../switchable-runtime/pages/switch-in-dev.js | 7 + 7 files changed, 218 insertions(+), 6 deletions(-) create mode 100644 test/e2e/switchable-runtime/pages/api/switch-in-dev-same-content.js create mode 100644 test/e2e/switchable-runtime/pages/api/switch-in-dev.js create mode 100644 test/e2e/switchable-runtime/pages/api/syntax-error-in-dev.js create mode 100644 test/e2e/switchable-runtime/pages/switch-in-dev.js diff --git a/packages/next/build/webpack/plugins/middleware-plugin.ts b/packages/next/build/webpack/plugins/middleware-plugin.ts index 82b94f8b4101..6711ade2f916 100644 --- a/packages/next/build/webpack/plugins/middleware-plugin.ts +++ b/packages/next/build/webpack/plugins/middleware-plugin.ts @@ -46,12 +46,6 @@ interface EntryMetadata { } const NAME = 'MiddlewarePlugin' -const middlewareManifest: MiddlewareManifest = { - sortedMiddleware: [], - middleware: {}, - functions: {}, - version: 2, -} /** * Checks the value of usingIndirectEval and when it is a set of modules it @@ -121,6 +115,12 @@ function getCreateAssets(params: { }) { const { compilation, metadataByEntry } = params return (assets: any) => { + const middlewareManifest: MiddlewareManifest = { + sortedMiddleware: [], + middleware: {}, + functions: {}, + version: 2, + } for (const entrypoint of compilation.entrypoints.values()) { if (!entrypoint.name) { continue diff --git a/packages/next/server/dev/on-demand-entry-handler.ts b/packages/next/server/dev/on-demand-entry-handler.ts index 1c752b7b296d..4784fcf4489f 100644 --- a/packages/next/server/dev/on-demand-entry-handler.ts +++ b/packages/next/server/dev/on-demand-entry-handler.ts @@ -649,12 +649,22 @@ export function onDemandEntryHandler({ }, onServer: () => { added.set(COMPILER_NAMES.server, addEntry(COMPILER_NAMES.server)) + const edgeServerEntry = `${COMPILER_NAMES.edgeServer}${pagePathData.page}` + if (entries[edgeServerEntry]) { + // Runtime switched from edge to server + delete entries[edgeServerEntry] + } }, onEdgeServer: () => { added.set( COMPILER_NAMES.edgeServer, addEntry(COMPILER_NAMES.edgeServer) ) + const serverEntry = `${COMPILER_NAMES.server}${pagePathData.page}` + if (entries[serverEntry]) { + // Runtime switched from server to edge + delete entries[serverEntry] + } }, }) diff --git a/test/e2e/switchable-runtime/index.test.ts b/test/e2e/switchable-runtime/index.test.ts index b9cef7819887..5485116ebc5c 100644 --- a/test/e2e/switchable-runtime/index.test.ts +++ b/test/e2e/switchable-runtime/index.test.ts @@ -203,6 +203,190 @@ describe('Switchable runtime', () => { } }) + it('should be possible to switch between runtimes in API routes', async () => { + await check( + () => renderViaHTTP(next.url, '/api/switch-in-dev'), + 'server response' + ) + + // Edge + await next.patchFile( + 'pages/api/switch-in-dev.js', + ` + export const config = { + runtime: 'experimental-edge', + } + + export default () => new Response('edge response') + ` + ) + await check( + () => renderViaHTTP(next.url, '/api/switch-in-dev'), + 'edge response' + ) + + // Server + await next.patchFile( + 'pages/api/switch-in-dev.js', + ` + export default function (req, res) { + res.send('server response again') + } + ` + ) + await check( + () => renderViaHTTP(next.url, '/api/switch-in-dev'), + 'server response again' + ) + + // Edge + await next.patchFile( + 'pages/api/switch-in-dev.js', + ` + export const config = { + runtime: 'experimental-edge', + } + + export default () => new Response('edge response again') + ` + ) + await check( + () => renderViaHTTP(next.url, '/api/switch-in-dev'), + 'edge response again' + ) + }) + + it('should be possible to switch between runtimes in pages', async () => { + await check( + () => renderViaHTTP(next.url, '/switch-in-dev'), + /Hello from edge page/ + ) + + // Server + await next.patchFile( + 'pages/switch-in-dev.js', + ` + export default function Page() { + return

Hello from server page

+ } + ` + ) + await check( + () => renderViaHTTP(next.url, '/switch-in-dev'), + /Hello from server page/ + ) + + // Edge + await next.patchFile( + 'pages/switch-in-dev.js', + ` + export default function Page() { + return

Hello from edge page again

+ } + + export const config = { + runtime: 'experimental-edge', + } + ` + ) + await check( + () => renderViaHTTP(next.url, '/switch-in-dev'), + /Hello from edge page again/ + ) + + // Server + await next.patchFile( + 'pages/switch-in-dev.js', + ` + export default function Page() { + return

Hello from server page again

+ } + ` + ) + await check( + () => renderViaHTTP(next.url, '/switch-in-dev'), + /Hello from server page again/ + ) + }) + + // Doesn't work, see https://github.com/vercel/next.js/pull/39327 + it.skip('should be possible to switch between runtimes with same content', async () => { + const fileContent = await next.readFile( + 'pages/api/switch-in-dev-same-content.js' + ) + console.log({ fileContent }) + await check( + () => renderViaHTTP(next.url, '/api/switch-in-dev-same-content'), + 'server response' + ) + + // Edge + await next.patchFile( + 'pages/api/switch-in-dev-same-content.js', + ` + export const config = { + runtime: 'experimental-edge', + } + + export default () => new Response('edge response') + ` + ) + await check( + () => renderViaHTTP(next.url, '/api/switch-in-dev-same-content'), + 'edge response' + ) + + // Server - same content as first compilation of the server runtime version + await next.patchFile( + 'pages/api/switch-in-dev-same-content.js', + fileContent + ) + await check( + () => renderViaHTTP(next.url, '/api/switch-in-dev-same-content'), + 'server response' + ) + }) + + it('should recover from syntax error when using edge runtime', async () => { + await check( + () => renderViaHTTP(next.url, '/api/syntax-error-in-dev'), + 'edge response' + ) + + // Syntax error + await next.patchFile( + 'pages/api/syntax-error-in-dev.js', + ` + export const config = { + runtime: 'experimental-edge', + } + + export default => new Response('edge response') + ` + ) + await check( + () => renderViaHTTP(next.url, '/api/syntax-error-in-dev'), + /Unexpected token/ + ) + + // Fix syntax error + await next.patchFile( + 'pages/api/syntax-error-in-dev.js', + ` + export default () => new Response('edge response again') + + export const config = { + runtime: 'experimental-edge', + } + + ` + ) + await check( + () => renderViaHTTP(next.url, '/api/syntax-error-in-dev'), + 'edge response again' + ) + }) + it('should not crash the dev server when invalid runtime is configured', async () => { await check( () => renderViaHTTP(next.url, '/invalid-runtime'), diff --git a/test/e2e/switchable-runtime/pages/api/switch-in-dev-same-content.js b/test/e2e/switchable-runtime/pages/api/switch-in-dev-same-content.js new file mode 100644 index 000000000000..a587c8cb1a71 --- /dev/null +++ b/test/e2e/switchable-runtime/pages/api/switch-in-dev-same-content.js @@ -0,0 +1,3 @@ +export default (req, res) => { + res.send('server response') +} diff --git a/test/e2e/switchable-runtime/pages/api/switch-in-dev.js b/test/e2e/switchable-runtime/pages/api/switch-in-dev.js new file mode 100644 index 000000000000..a587c8cb1a71 --- /dev/null +++ b/test/e2e/switchable-runtime/pages/api/switch-in-dev.js @@ -0,0 +1,3 @@ +export default (req, res) => { + res.send('server response') +} diff --git a/test/e2e/switchable-runtime/pages/api/syntax-error-in-dev.js b/test/e2e/switchable-runtime/pages/api/syntax-error-in-dev.js new file mode 100644 index 000000000000..3b7243a1205e --- /dev/null +++ b/test/e2e/switchable-runtime/pages/api/syntax-error-in-dev.js @@ -0,0 +1,5 @@ +export default () => new Response('edge response') + +export const config = { + runtime: `experimental-edge`, +} diff --git a/test/e2e/switchable-runtime/pages/switch-in-dev.js b/test/e2e/switchable-runtime/pages/switch-in-dev.js new file mode 100644 index 000000000000..b67d4cabd53c --- /dev/null +++ b/test/e2e/switchable-runtime/pages/switch-in-dev.js @@ -0,0 +1,7 @@ +export default function Page() { + return

Hello from edge page

+} + +export const config = { + runtime: 'experimental-edge', +} From b86bf075639c0a899087831e731046e22af823b5 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 7 Sep 2022 13:44:58 -0700 Subject: [PATCH 06/69] v12.2.6-canary.11 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/eslint-config-next/package.json | 4 ++-- packages/eslint-plugin-next/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-codemod/package.json | 2 +- packages/next-env/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-storybook/package.json | 2 +- packages/next-polyfill-module/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next-swc/package.json | 2 +- packages/next/package.json | 14 +++++++------- packages/react-dev-overlay/package.json | 2 +- packages/react-refresh-utils/package.json | 2 +- pnpm-lock.yaml | 14 +++++++------- 16 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lerna.json b/lerna.json index 29350f4a08fa..65ad1559e7ba 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "12.2.6-canary.10" + "version": "12.2.6-canary.11" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 721fd07b6fed..7768ac4351e9 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 5ea10aa13205..2d05f1dd73b5 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -9,7 +9,7 @@ "directory": "packages/eslint-config-next" }, "dependencies": { - "@next/eslint-plugin-next": "12.2.6-canary.10", + "@next/eslint-plugin-next": "12.2.6-canary.11", "@rushstack/eslint-patch": "^1.1.3", "@typescript-eslint/parser": "^5.21.0", "eslint-import-resolver-node": "^0.3.6", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 35c47b9c1c3a..c962b79d34cd 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "description": "ESLint plugin for NextJS.", "main": "lib/index.js", "license": "MIT", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 8118628540f6..96e40b6f4ed7 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 947d444897b8..9dd1e3367111 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "license": "MIT", "dependencies": { "chalk": "4.1.0", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 70c1be3643b4..e2a73c53f4f5 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index 5154b092531f..f4a25c98ffc8 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 43d3c0859537..7facfee704ff 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index 6f96414c44fe..412946be8dab 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)", "main": "dist/polyfill-module.js", "license": "MIT", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index 25c6807234f4..d4ae98531996 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 05c0aa843831..99b6702820ff 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "private": true, "scripts": { "build-native": "napi build --platform -p next-swc-napi --cargo-name next_swc_napi native --features plugin", diff --git a/packages/next/package.json b/packages/next/package.json index 5c6ab9517a11..faa1fc761280 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -70,7 +70,7 @@ ] }, "dependencies": { - "@next/env": "12.2.6-canary.10", + "@next/env": "12.2.6-canary.11", "@swc/helpers": "0.4.11", "caniuse-lite": "^1.0.30001332", "postcss": "8.4.14", @@ -121,11 +121,11 @@ "@hapi/accept": "5.0.2", "@napi-rs/cli": "2.7.0", "@napi-rs/triples": "1.1.0", - "@next/polyfill-module": "12.2.6-canary.10", - "@next/polyfill-nomodule": "12.2.6-canary.10", - "@next/react-dev-overlay": "12.2.6-canary.10", - "@next/react-refresh-utils": "12.2.6-canary.10", - "@next/swc": "12.2.6-canary.10", + "@next/polyfill-module": "12.2.6-canary.11", + "@next/polyfill-nomodule": "12.2.6-canary.11", + "@next/react-dev-overlay": "12.2.6-canary.11", + "@next/react-refresh-utils": "12.2.6-canary.11", + "@next/swc": "12.2.6-canary.11", "@segment/ajv-human-errors": "2.1.2", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index 9008d34e3e7b..f7b9a6e6714a 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index 13f37d3be78c..40c1d1442215 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "12.2.6-canary.10", + "version": "12.2.6-canary.11", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5c2a8952141b..a57007b5348c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -363,7 +363,7 @@ importers: packages/eslint-config-next: specifiers: - '@next/eslint-plugin-next': 12.2.6-canary.10 + '@next/eslint-plugin-next': 12.2.6-canary.11 '@rushstack/eslint-patch': ^1.1.3 '@typescript-eslint/parser': ^5.21.0 eslint-import-resolver-node: ^0.3.6 @@ -419,12 +419,12 @@ importers: '@hapi/accept': 5.0.2 '@napi-rs/cli': 2.7.0 '@napi-rs/triples': 1.1.0 - '@next/env': 12.2.6-canary.10 - '@next/polyfill-module': 12.2.6-canary.10 - '@next/polyfill-nomodule': 12.2.6-canary.10 - '@next/react-dev-overlay': 12.2.6-canary.10 - '@next/react-refresh-utils': 12.2.6-canary.10 - '@next/swc': 12.2.6-canary.10 + '@next/env': 12.2.6-canary.11 + '@next/polyfill-module': 12.2.6-canary.11 + '@next/polyfill-nomodule': 12.2.6-canary.11 + '@next/react-dev-overlay': 12.2.6-canary.11 + '@next/react-refresh-utils': 12.2.6-canary.11 + '@next/swc': 12.2.6-canary.11 '@segment/ajv-human-errors': 2.1.2 '@swc/helpers': 0.4.11 '@taskr/clear': 1.1.0 From 62c7eff35435f346f56f9f107bead86a51c60bae Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 7 Sep 2022 16:38:10 -0700 Subject: [PATCH 07/69] Revert "Revert "Refactor Server Router" (#40328)" (#40333) This unreverts https://github.com/vercel/next.js/pull/40328 as it wasn't the cause for https://github.com/vercel/next.js/issues/40241 like initially suspected and the actual fix has been included here as well with regression test. Fixes: https://github.com/vercel/next.js/issues/40241 ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` --- packages/next/server/base-server.ts | 6 +- packages/next/server/dev/next-dev-server.ts | 1 - packages/next/server/router.ts | 478 ++++++++++-------- test/production/required-server-files.test.ts | 6 + 4 files changed, 276 insertions(+), 215 deletions(-) diff --git a/packages/next/server/base-server.ts b/packages/next/server/base-server.ts index d2e5db5bf051..a518b36cfcfb 100644 --- a/packages/next/server/base-server.ts +++ b/packages/next/server/base-server.ts @@ -959,7 +959,11 @@ export default abstract class Server { // Toggle whether or not this is a Data request const isDataReq = - !!(query.__nextDataReq || req.headers['x-nextjs-data']) && + !!( + query.__nextDataReq || + (req.headers['x-nextjs-data'] && + (this.serverOptions as any).webServerConfig) + ) && (isSSG || hasServerProps || isServerComponent) delete query.__nextDataReq diff --git a/packages/next/server/dev/next-dev-server.ts b/packages/next/server/dev/next-dev-server.ts index a67bfb58bcbb..d360778905f4 100644 --- a/packages/next/server/dev/next-dev-server.ts +++ b/packages/next/server/dev/next-dev-server.ts @@ -221,7 +221,6 @@ export default class DevServer extends Server { for (const path in exportPathMap) { const { page, query = {} } = exportPathMap[path] - // We use unshift so that we're sure the routes is defined before Next's default routes this.router.addFsRoute({ match: getPathMatch(path), type: 'route', diff --git a/packages/next/server/router.ts b/packages/next/server/router.ts index 0cb309f823af..ca2ce97b1a7d 100644 --- a/packages/next/server/router.ts +++ b/packages/next/server/router.ts @@ -40,7 +40,7 @@ export type Route = { res: BaseNextResponse, params: Params, parsedUrl: NextUrlWithParsedQuery, - upgradeHead?: any + upgradeHead?: Buffer ) => Promise | RouteResult } @@ -49,21 +49,37 @@ export type DynamicRoutes = Array<{ page: string; match: RouteMatch }> export type PageChecker = (pathname: string) => Promise export default class Router { - headers: Route[] - fsRoutes: Route[] - redirects: Route[] - rewrites: { - beforeFiles: Route[] - afterFiles: Route[] - fallback: Route[] + public catchAllMiddleware: ReadonlyArray + + private readonly headers: ReadonlyArray + private readonly fsRoutes: Route[] + private readonly redirects: ReadonlyArray + private readonly rewrites: { + beforeFiles: ReadonlyArray + afterFiles: ReadonlyArray + fallback: ReadonlyArray } - catchAllRoute: Route - catchAllMiddleware: Route[] - pageChecker: PageChecker - dynamicRoutes: DynamicRoutes - useFileSystemPublicRoutes: boolean - seenRequests: Set - nextConfig: NextConfig + private readonly catchAllRoute: Route + private readonly pageChecker: PageChecker + private dynamicRoutes: DynamicRoutes + private readonly useFileSystemPublicRoutes: boolean + private readonly nextConfig: NextConfig + private compiledRoutes: ReadonlyArray + private needsRecompilation: boolean + + /** + * context stores information used by the router. + */ + private readonly context = new WeakMap< + BaseNextRequest, + { + /** + * pageChecks is the memoized record of all checks made against pages to + * help de-duplicate work. + */ + pageChecks: Record + } + >() constructor({ headers = [], @@ -81,16 +97,16 @@ export default class Router { useFileSystemPublicRoutes, nextConfig, }: { - headers: Route[] - fsRoutes: Route[] + headers: ReadonlyArray + fsRoutes: ReadonlyArray rewrites: { - beforeFiles: Route[] - afterFiles: Route[] - fallback: Route[] + beforeFiles: ReadonlyArray + afterFiles: ReadonlyArray + fallback: ReadonlyArray } - redirects: Route[] + redirects: ReadonlyArray catchAllRoute: Route - catchAllMiddleware: Route[] + catchAllMiddleware: ReadonlyArray dynamicRoutes: DynamicRoutes | undefined pageChecker: PageChecker useFileSystemPublicRoutes: boolean @@ -98,7 +114,7 @@ export default class Router { }) { this.nextConfig = nextConfig this.headers = headers - this.fsRoutes = fsRoutes + this.fsRoutes = [...fsRoutes] this.rewrites = rewrites this.redirects = redirects this.pageChecker = pageChecker @@ -106,7 +122,32 @@ export default class Router { this.catchAllMiddleware = catchAllMiddleware this.dynamicRoutes = dynamicRoutes this.useFileSystemPublicRoutes = useFileSystemPublicRoutes - this.seenRequests = new Set() + + // Perform the initial route compilation. + this.compiledRoutes = this.compileRoutes() + this.needsRecompilation = false + } + + private async checkPage( + req: BaseNextRequest, + pathname: string + ): Promise { + pathname = normalizeLocalePath(pathname, this.locales).pathname + + const context = this.context.get(req) + if (!context) { + throw new Error( + 'Invariant: request is not available inside the context, this is an internal error please open an issue.' + ) + } + + if (context.pageChecks[pathname] !== undefined) { + return context.pageChecks[pathname] + } + + const result = await this.pageChecker(pathname) + context.pageChecks[pathname] = result + return result } get locales() { @@ -117,192 +158,201 @@ export default class Router { return this.nextConfig.basePath || '' } - setDynamicRoutes(routes: DynamicRoutes = []) { - this.dynamicRoutes = routes + public setDynamicRoutes(dynamicRoutes: DynamicRoutes) { + this.dynamicRoutes = dynamicRoutes + this.needsRecompilation = true } - setCatchallMiddleware(route?: Route[]) { - this.catchAllMiddleware = route || [] + public setCatchallMiddleware(catchAllMiddleware: ReadonlyArray) { + this.catchAllMiddleware = catchAllMiddleware + this.needsRecompilation = true } - addFsRoute(fsRoute: Route) { + public addFsRoute(fsRoute: Route) { + // We use unshift so that we're sure the routes is defined before Next's + // default routes. this.fsRoutes.unshift(fsRoute) + this.needsRecompilation = true } - async execute( + private compileRoutes(): ReadonlyArray { + /* + Desired routes order + - headers + - redirects + - Check filesystem (including pages), if nothing found continue + - User rewrites (checking filesystem and pages each match) + */ + + const [middlewareCatchAllRoute] = this.catchAllMiddleware + + return [ + ...(middlewareCatchAllRoute + ? this.fsRoutes + .filter((route) => route.name === '_next/data catchall') + .map((route) => ({ ...route, check: false })) + : []), + ...this.headers, + ...this.redirects, + ...(this.useFileSystemPublicRoutes && middlewareCatchAllRoute + ? [middlewareCatchAllRoute] + : []), + ...this.rewrites.beforeFiles, + ...this.fsRoutes, + // We only check the catch-all route if public page routes hasn't been + // disabled + ...(this.useFileSystemPublicRoutes + ? [ + { + type: 'route', + name: 'page checker', + match: getPathMatch('/:path*'), + fn: async (req, res, params, parsedUrl, upgradeHead) => { + const pathname = removeTrailingSlash(parsedUrl.pathname || '/') + if (!pathname) { + return { finished: false } + } + + if (await this.checkPage(req, pathname)) { + return this.catchAllRoute.fn( + req, + res, + params, + parsedUrl, + upgradeHead + ) + } + + return { finished: false } + }, + } as Route, + ] + : []), + ...this.rewrites.afterFiles, + ...(this.rewrites.fallback.length + ? [ + { + type: 'route', + name: 'dynamic route/page check', + match: getPathMatch('/:path*'), + fn: async (req, res, _params, parsedCheckerUrl, upgradeHead) => { + return { + finished: await this.checkFsRoutes( + req, + res, + parsedCheckerUrl, + upgradeHead + ), + } + }, + } as Route, + ...this.rewrites.fallback, + ] + : []), + + // We only check the catch-all route if public page routes hasn't been + // disabled + ...(this.useFileSystemPublicRoutes ? [this.catchAllRoute] : []), + ] + } + + private async checkFsRoutes( req: BaseNextRequest, res: BaseNextResponse, parsedUrl: NextUrlWithParsedQuery, - upgradeHead?: any - ): Promise { - if (this.seenRequests.has(req)) { - throw new Error( - `Invariant: request has already been processed: ${req.url}, this is an internal error please open an issue.` - ) - } - this.seenRequests.add(req) - try { - // memoize page check calls so we don't duplicate checks for pages - const pageChecks: { [name: string]: Promise } = {} - const memoizedPageChecker = async (p: string): Promise => { - p = normalizeLocalePath(p, this.locales).pathname + upgradeHead?: Buffer + ) { + const originalFsPathname = parsedUrl.pathname + const fsPathname = removePathPrefix(originalFsPathname!, this.basePath) + + for (const route of this.fsRoutes) { + const params = route.match(fsPathname) - if (pageChecks[p] !== undefined) { - return pageChecks[p] + if (params) { + parsedUrl.pathname = fsPathname + + const { finished } = await route.fn(req, res, params, parsedUrl) + if (finished) { + return true } - const result = this.pageChecker(p) - pageChecks[p] = result - return result + + parsedUrl.pathname = originalFsPathname } + } + + let matchedPage = await this.checkPage(req, fsPathname) + + // If we didn't match a page check dynamic routes + if (!matchedPage) { + const normalizedFsPathname = normalizeLocalePath( + fsPathname, + this.locales + ).pathname - let parsedUrlUpdated = parsedUrl + for (const dynamicRoute of this.dynamicRoutes) { + if (dynamicRoute.match(normalizedFsPathname)) { + matchedPage = true + } + } + } - const applyCheckTrue = async (checkParsedUrl: NextUrlWithParsedQuery) => { - const originalFsPathname = checkParsedUrl.pathname - const fsPathname = removePathPrefix(originalFsPathname!, this.basePath) + // Matched a page or dynamic route so render it using catchAllRoute + if (matchedPage) { + const params = this.catchAllRoute.match(parsedUrl.pathname) + if (!params) { + throw new Error( + `Invariant: could not match params, this is an internal error please open an issue.` + ) + } - for (const fsRoute of this.fsRoutes) { - const fsParams = fsRoute.match(fsPathname) + parsedUrl.pathname = fsPathname + parsedUrl.query._nextBubbleNoFallback = '1' - if (fsParams) { - checkParsedUrl.pathname = fsPathname + const { finished } = await this.catchAllRoute.fn( + req, + res, + params, + parsedUrl, + upgradeHead + ) - const fsResult = await fsRoute.fn( - req, - res, - fsParams, - checkParsedUrl - ) + return finished + } - if (fsResult.finished) { - return true - } + return false + } - checkParsedUrl.pathname = originalFsPathname - } - } - let matchedPage = await memoizedPageChecker(fsPathname) - - // If we didn't match a page check dynamic routes - if (!matchedPage) { - const normalizedFsPathname = normalizeLocalePath( - fsPathname, - this.locales - ).pathname - - for (const dynamicRoute of this.dynamicRoutes) { - if (dynamicRoute.match(normalizedFsPathname)) { - matchedPage = true - } - } - } + async execute( + req: BaseNextRequest, + res: BaseNextResponse, + parsedUrl: NextUrlWithParsedQuery, + upgradeHead?: Buffer + ): Promise { + // Only recompile if the routes need to be recompiled, this should only + // happen in development. + if (this.needsRecompilation) { + this.compiledRoutes = this.compileRoutes() + this.needsRecompilation = false + } - // Matched a page or dynamic route so render it using catchAllRoute - if (matchedPage) { - const pageParams = this.catchAllRoute.match(checkParsedUrl.pathname) - checkParsedUrl.pathname = fsPathname - checkParsedUrl.query._nextBubbleNoFallback = '1' + if (this.context.has(req)) { + throw new Error( + `Invariant: request has already been processed: ${req.url}, this is an internal error please open an issue.` + ) + } + this.context.set(req, { pageChecks: {} }) - const result = await this.catchAllRoute.fn( - req, - res, - pageParams as Params, - checkParsedUrl - ) - return result.finished - } + try { + // Create a deep copy of the parsed URL. + const parsedUrlUpdated = { + ...parsedUrl, + query: { + ...parsedUrl.query, + }, } - /* - Desired routes order - - headers - - redirects - - Check filesystem (including pages), if nothing found continue - - User rewrites (checking filesystem and pages each match) - */ - - const [middlewareCatchAllRoute] = this.catchAllMiddleware - const allRoutes = [ - ...(middlewareCatchAllRoute - ? this.fsRoutes - .filter((r) => r.name === '_next/data catchall') - .map((r) => { - return { - ...r, - check: false, - } - }) - : []), - ...this.headers, - ...this.redirects, - ...(this.useFileSystemPublicRoutes && middlewareCatchAllRoute - ? [middlewareCatchAllRoute] - : []), - ...this.rewrites.beforeFiles, - ...this.fsRoutes, - // We only check the catch-all route if public page routes hasn't been - // disabled - ...(this.useFileSystemPublicRoutes - ? [ - { - type: 'route', - name: 'page checker', - match: getPathMatch('/:path*'), - fn: async ( - checkerReq, - checkerRes, - params, - parsedCheckerUrl - ) => { - let { pathname } = parsedCheckerUrl - pathname = removeTrailingSlash(pathname || '/') - - if (!pathname) { - return { finished: false } - } - - if (await memoizedPageChecker(pathname)) { - return this.catchAllRoute.fn( - checkerReq, - checkerRes, - params, - parsedCheckerUrl - ) - } - return { finished: false } - }, - } as Route, - ] - : []), - ...this.rewrites.afterFiles, - ...(this.rewrites.fallback.length - ? [ - { - type: 'route', - name: 'dynamic route/page check', - match: getPathMatch('/:path*'), - fn: async ( - _checkerReq, - _checkerRes, - _params, - parsedCheckerUrl - ) => { - return { - finished: await applyCheckTrue(parsedCheckerUrl), - } - }, - } as Route, - ...this.rewrites.fallback, - ] - : []), - - // We only check the catch-all route if public page routes hasn't been - // disabled - ...(this.useFileSystemPublicRoutes ? [this.catchAllRoute] : []), - ] - - for (const testRoute of allRoutes) { + for (const route of this.compiledRoutes) { // only process rewrites for upgrade request - if (upgradeHead && testRoute.type !== 'rewrite') { + if (upgradeHead && route.type !== 'rewrite') { continue } @@ -314,7 +364,7 @@ export default class Router { if ( pathnameInfo.locale && - !testRoute.matchesLocaleAPIRoutes && + !route.matchesLocaleAPIRoutes && pathnameInfo.pathname.match(/^\/api(?:\/|$)/) ) { continue @@ -325,20 +375,20 @@ export default class Router { } const basePath = pathnameInfo.basePath - if (!testRoute.matchesBasePath) { + if (!route.matchesBasePath) { pathnameInfo.basePath = '' } if ( - testRoute.matchesLocale && - parsedUrl.query.__nextLocale && + route.matchesLocale && + parsedUrlUpdated.query.__nextLocale && !pathnameInfo.locale ) { - pathnameInfo.locale = parsedUrl.query.__nextLocale + pathnameInfo.locale = parsedUrlUpdated.query.__nextLocale } if ( - !testRoute.matchesLocale && + !route.matchesLocale && pathnameInfo.locale === this.nextConfig.i18n?.defaultLocale && pathnameInfo.locale ) { @@ -346,7 +396,7 @@ export default class Router { } if ( - testRoute.matchesTrailingSlash && + route.matchesTrailingSlash && getRequestMeta(req, '__nextHadTrailingSlash') ) { pathnameInfo.trailingSlash = true @@ -357,13 +407,13 @@ export default class Router { ...pathnameInfo, }) - let newParams = testRoute.match(matchPathname) - if (testRoute.has && newParams) { - const hasParams = matchHas(req, testRoute.has, parsedUrlUpdated.query) + let params = route.match(matchPathname) + if (route.has && params) { + const hasParams = matchHas(req, route.has, parsedUrlUpdated.query) if (hasParams) { - Object.assign(newParams, hasParams) + Object.assign(params, hasParams) } else { - newParams = false + params = false } } @@ -373,35 +423,34 @@ export default class Router { * never there, we consider this an invalid match and keep routing. */ if ( - newParams && + params && this.basePath && - !testRoute.matchesBasePath && + !route.matchesBasePath && !getRequestMeta(req, '_nextDidRewrite') && !basePath ) { continue } - if (newParams) { + if (params) { parsedUrlUpdated.pathname = matchPathname - const result = await testRoute.fn( + const result = await route.fn( req, res, - newParams, + params, parsedUrlUpdated, upgradeHead ) - if (result.finished) { return true } - // since the fs route didn't finish routing we need to re-add the - // basePath to continue checking with the basePath present - parsedUrlUpdated.pathname = originalPathname - if (result.pathname) { parsedUrlUpdated.pathname = result.pathname + } else { + // since the fs route didn't finish routing we need to re-add the + // basePath to continue checking with the basePath present + parsedUrlUpdated.pathname = originalPathname } if (result.query) { @@ -412,16 +461,19 @@ export default class Router { } // check filesystem - if (testRoute.check === true) { - if (await applyCheckTrue(parsedUrlUpdated)) { - return true - } + if ( + route.check && + (await this.checkFsRoutes(req, res, parsedUrlUpdated)) + ) { + return true } } } + + // All routes were tested, none were found. return false } finally { - this.seenRequests.delete(req) + this.context.delete(req) } } } diff --git a/test/production/required-server-files.test.ts b/test/production/required-server-files.test.ts index 9f2446f93c99..1d97b5bc5be3 100644 --- a/test/production/required-server-files.test.ts +++ b/test/production/required-server-files.test.ts @@ -324,6 +324,12 @@ describe('should set-up next', () => { it('should de-dupe HTML/data requests', async () => { const res = await fetchViaHTTP(appPort, '/gsp', undefined, { redirect: 'manual', + headers: { + // ensure the nextjs-data header being present + // doesn't incorrectly return JSON for HTML path + // during prerendering + 'x-nextjs-data': '1', + }, }) expect(res.status).toBe(200) expect(res.headers.get('x-nextjs-cache')).toBeFalsy() From aa5be3ff64f84b0cf93ed175d29ca6078e9f7517 Mon Sep 17 00:00:00 2001 From: Henrik Wenz Date: Thu, 8 Sep 2022 01:39:35 +0200 Subject: [PATCH 08/69] [Docs] Migrate with-react-jss to typescript (#40308) ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) --- examples/with-react-jss/.babelrc | 3 --- examples/with-react-jss/package.json | 11 +++++++--- .../pages/{_app.js => _app.tsx} | 5 +++-- .../pages/{_document.js => _document.tsx} | 4 ++-- .../pages/{index.js => index.tsx} | 4 +--- examples/with-react-jss/tsconfig.json | 20 +++++++++++++++++++ 6 files changed, 34 insertions(+), 13 deletions(-) delete mode 100644 examples/with-react-jss/.babelrc rename examples/with-react-jss/pages/{_app.js => _app.tsx} (60%) rename examples/with-react-jss/pages/{_document.js => _document.tsx} (87%) rename examples/with-react-jss/pages/{index.js => index.tsx} (90%) create mode 100644 examples/with-react-jss/tsconfig.json diff --git a/examples/with-react-jss/.babelrc b/examples/with-react-jss/.babelrc deleted file mode 100644 index 1ff94f7ed28e..000000000000 --- a/examples/with-react-jss/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["next/babel"] -} diff --git a/examples/with-react-jss/package.json b/examples/with-react-jss/package.json index 17ac6c57e840..2ee0fa080925 100644 --- a/examples/with-react-jss/package.json +++ b/examples/with-react-jss/package.json @@ -7,8 +7,13 @@ }, "dependencies": { "next": "latest", - "react": "^17.0.2", - "react-dom": "^17.0.2", - "react-jss": "^10.3.0" + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-jss": "^10.9.2" + }, + "devDependencies": { + "@types/node": "18.7.15", + "@types/react": "18.0.18", + "typescript": "4.8.2" } } diff --git a/examples/with-react-jss/pages/_app.js b/examples/with-react-jss/pages/_app.tsx similarity index 60% rename from examples/with-react-jss/pages/_app.js rename to examples/with-react-jss/pages/_app.tsx index ad98bbd6bf42..74b569b67fac 100644 --- a/examples/with-react-jss/pages/_app.js +++ b/examples/with-react-jss/pages/_app.tsx @@ -1,9 +1,10 @@ +import type { AppProps } from 'next/app' import { useEffect } from 'react' -export default function App({ Component, pageProps }) { +export default function App({ Component, pageProps }: AppProps) { useEffect(() => { const style = document.getElementById('server-side-styles') - if (style) { + if (style && style.parentNode) { style.parentNode.removeChild(style) } }, []) diff --git a/examples/with-react-jss/pages/_document.js b/examples/with-react-jss/pages/_document.tsx similarity index 87% rename from examples/with-react-jss/pages/_document.js rename to examples/with-react-jss/pages/_document.tsx index 53ad6b117efe..a20015c58ad7 100644 --- a/examples/with-react-jss/pages/_document.js +++ b/examples/with-react-jss/pages/_document.tsx @@ -1,8 +1,8 @@ -import Document from 'next/document' +import Document, { DocumentContext } from 'next/document' import { SheetsRegistry, JssProvider, createGenerateId } from 'react-jss' export default class JssDocument extends Document { - static async getInitialProps(ctx) { + static async getInitialProps(ctx: DocumentContext) { const registry = new SheetsRegistry() const generateId = createGenerateId() const originalRenderPage = ctx.renderPage diff --git a/examples/with-react-jss/pages/index.js b/examples/with-react-jss/pages/index.tsx similarity index 90% rename from examples/with-react-jss/pages/index.js rename to examples/with-react-jss/pages/index.tsx index f8bafce6daad..1726845c1f76 100644 --- a/examples/with-react-jss/pages/index.js +++ b/examples/with-react-jss/pages/index.tsx @@ -12,7 +12,7 @@ const useStyles = createUseStyles({ }, }) -function Index() { +export default function IndexPage() { const classes = useStyles() return ( @@ -23,5 +23,3 @@ function Index() { ) } - -export default Index diff --git a/examples/with-react-jss/tsconfig.json b/examples/with-react-jss/tsconfig.json new file mode 100644 index 000000000000..ccaea0672d6e --- /dev/null +++ b/examples/with-react-jss/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "incremental": true, + "esModuleInterop": true, + "moduleResolution": "node", + "module": "esnext", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve" + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "exclude": ["node_modules"] +} From 34fa5f8535c5e7d663c8bec829b681497c1801c3 Mon Sep 17 00:00:00 2001 From: William Duplenne Date: Thu, 8 Sep 2022 01:53:42 +0200 Subject: [PATCH 09/69] [Docs] Update react-remove-properties example (#40307) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi 👋 Based on https://nextjs.org/docs/advanced-features/compiler#remove-react-properties, this is not experimental but lives under `compiler` now. ## Documentation / Examples - [x] Make sure the linting passes by running pnpm lint - [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) --- examples/react-remove-properties/next.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/react-remove-properties/next.config.js b/examples/react-remove-properties/next.config.js index 7d3aca8225d8..37db77a9c2a5 100644 --- a/examples/react-remove-properties/next.config.js +++ b/examples/react-remove-properties/next.config.js @@ -1,6 +1,6 @@ /** @type {import('next').NextConfig} */ module.exports = { - experimental: { + compiler: { reactRemoveProperties: true, // Or, specify a custom list of regular expressions to match properties to remove. // The regexes defined here are processed in Rust so the syntax is different from From 588a61b432b0d2350f96cfac47d7d4dfad773183 Mon Sep 17 00:00:00 2001 From: Henrik Wenz Date: Thu, 8 Sep 2022 01:59:49 +0200 Subject: [PATCH 10/69] [Docs] Migrate using-preact example to typescript (#40295) ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) --- examples/using-preact/next.config.js | 7 ++++-- examples/using-preact/package.json | 20 ++++++++++------- examples/using-preact/pages/about.js | 3 --- examples/using-preact/pages/about.tsx | 3 +++ .../pages/{index.js => index.tsx} | 2 +- examples/using-preact/pages/ssg.js | 9 -------- examples/using-preact/pages/ssg.tsx | 13 +++++++++++ examples/using-preact/pages/ssr.js | 9 -------- examples/using-preact/pages/ssr.tsx | 13 +++++++++++ examples/using-preact/tsconfig.json | 22 +++++++++++++++++++ 10 files changed, 69 insertions(+), 32 deletions(-) delete mode 100644 examples/using-preact/pages/about.js create mode 100644 examples/using-preact/pages/about.tsx rename examples/using-preact/pages/{index.js => index.tsx} (91%) delete mode 100644 examples/using-preact/pages/ssg.js create mode 100644 examples/using-preact/pages/ssg.tsx delete mode 100644 examples/using-preact/pages/ssr.js create mode 100644 examples/using-preact/pages/ssr.tsx create mode 100644 examples/using-preact/tsconfig.json diff --git a/examples/using-preact/next.config.js b/examples/using-preact/next.config.js index cffe26659035..f0e665c2218a 100644 --- a/examples/using-preact/next.config.js +++ b/examples/using-preact/next.config.js @@ -1,5 +1,8 @@ const withPreact = require('next-plugin-preact') -module.exports = withPreact({ +/** @type {import('next').NextConfig} */ +const nextConfig = { /* regular next.js config options here */ -}) +} + +module.exports = withPreact(nextConfig) diff --git a/examples/using-preact/package.json b/examples/using-preact/package.json index 0f8d828fc183..dc2b8b3f46da 100644 --- a/examples/using-preact/package.json +++ b/examples/using-preact/package.json @@ -5,14 +5,18 @@ "build": "next build", "start": "next start" }, - "devDependencies": {}, "dependencies": { - "next": "^12.0.0", - "next-plugin-preact": "^3.0.6", - "preact": "^10.5.15", - "preact-render-to-string": "^5.1.19", - "react": "npm:@preact/compat@^17.0.2", - "react-dom": "npm:@preact/compat@^17.0.2", - "react-ssr-prepass": "npm:preact-ssr-prepass@^1.2.0" + "next": "latest", + "next-plugin-preact": "latest", + "preact": "^10.10.6", + "preact-render-to-string": "^5.2.3", + "react": "npm:@preact/compat@^17.1.1", + "react-dom": "npm:@preact/compat@^17.1.1", + "react-ssr-prepass": "npm:preact-ssr-prepass@1.2.0" + }, + "devDependencies": { + "@types/node": "18.7.15", + "@types/react": "16.9.17", + "typescript": "4.8.2" } } diff --git a/examples/using-preact/pages/about.js b/examples/using-preact/pages/about.js deleted file mode 100644 index 46817af02a5c..000000000000 --- a/examples/using-preact/pages/about.js +++ /dev/null @@ -1,3 +0,0 @@ -export default function About() { - return
About us
-} diff --git a/examples/using-preact/pages/about.tsx b/examples/using-preact/pages/about.tsx new file mode 100644 index 000000000000..71c7703a7bd2 --- /dev/null +++ b/examples/using-preact/pages/about.tsx @@ -0,0 +1,3 @@ +export default function AboutPage() { + return
About us
+} diff --git a/examples/using-preact/pages/index.js b/examples/using-preact/pages/index.tsx similarity index 91% rename from examples/using-preact/pages/index.js rename to examples/using-preact/pages/index.tsx index 62301b996922..a0051fe32b9f 100644 --- a/examples/using-preact/pages/index.js +++ b/examples/using-preact/pages/index.tsx @@ -1,6 +1,6 @@ import Link from 'next/link' -export default function Home() { +export default function IndexPage() { return (
Hello World.{' '} diff --git a/examples/using-preact/pages/ssg.js b/examples/using-preact/pages/ssg.js deleted file mode 100644 index 58adabc4b5b7..000000000000 --- a/examples/using-preact/pages/ssg.js +++ /dev/null @@ -1,9 +0,0 @@ -export default function SSG({ framework }) { - return
{framework} ssg example
-} - -export function getStaticProps() { - return { - props: { framework: 'preact' }, - } -} diff --git a/examples/using-preact/pages/ssg.tsx b/examples/using-preact/pages/ssg.tsx new file mode 100644 index 000000000000..ef13cface3bb --- /dev/null +++ b/examples/using-preact/pages/ssg.tsx @@ -0,0 +1,13 @@ +import { InferGetStaticPropsType } from 'next' + +export function getStaticProps() { + return { + props: { framework: 'preact' }, + } +} + +export default function SSGPage({ + framework, +}: InferGetStaticPropsType) { + return
{framework} ssg example
+} diff --git a/examples/using-preact/pages/ssr.js b/examples/using-preact/pages/ssr.js deleted file mode 100644 index 695e329a8591..000000000000 --- a/examples/using-preact/pages/ssr.js +++ /dev/null @@ -1,9 +0,0 @@ -export default function SSR({ framework }) { - return
{framework} ssr example
-} - -export function getServerSideProps() { - return { - props: { framework: 'preact' }, - } -} diff --git a/examples/using-preact/pages/ssr.tsx b/examples/using-preact/pages/ssr.tsx new file mode 100644 index 000000000000..24c86325aa72 --- /dev/null +++ b/examples/using-preact/pages/ssr.tsx @@ -0,0 +1,13 @@ +import { InferGetServerSidePropsType } from 'next' + +export function getServerSideProps() { + return { + props: { framework: 'preact' }, + } +} + +export default function SSRPage({ + framework, +}: InferGetServerSidePropsType) { + return
{framework} ssr example
+} diff --git a/examples/using-preact/tsconfig.json b/examples/using-preact/tsconfig.json new file mode 100644 index 000000000000..f83cb8071c2e --- /dev/null +++ b/examples/using-preact/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "incremental": true, + "esModuleInterop": true, + "moduleResolution": "node", + "module": "esnext", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "jsxFactory": "h", + "jsxFragmentFactory": "Fragment" + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "exclude": ["node_modules"] +} From 0c58621796a94810671dad393e67c78a9b9f5af1 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 7 Sep 2022 17:02:46 -0700 Subject: [PATCH 11/69] v12.2.6-canary.12 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/eslint-config-next/package.json | 4 ++-- packages/eslint-plugin-next/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-codemod/package.json | 2 +- packages/next-env/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-storybook/package.json | 2 +- packages/next-polyfill-module/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next-swc/package.json | 2 +- packages/next/package.json | 14 +++++++------- packages/react-dev-overlay/package.json | 2 +- packages/react-refresh-utils/package.json | 2 +- pnpm-lock.yaml | 14 +++++++------- 16 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lerna.json b/lerna.json index 65ad1559e7ba..dc5ab3db5feb 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "12.2.6-canary.11" + "version": "12.2.6-canary.12" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 7768ac4351e9..45f18996dabe 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 2d05f1dd73b5..4617fbec97a4 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -9,7 +9,7 @@ "directory": "packages/eslint-config-next" }, "dependencies": { - "@next/eslint-plugin-next": "12.2.6-canary.11", + "@next/eslint-plugin-next": "12.2.6-canary.12", "@rushstack/eslint-patch": "^1.1.3", "@typescript-eslint/parser": "^5.21.0", "eslint-import-resolver-node": "^0.3.6", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index c962b79d34cd..80240a527714 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "description": "ESLint plugin for NextJS.", "main": "lib/index.js", "license": "MIT", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 96e40b6f4ed7..18adefc11bdb 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 9dd1e3367111..ae97f89ed5c3 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "license": "MIT", "dependencies": { "chalk": "4.1.0", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index e2a73c53f4f5..73473cc501c5 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index f4a25c98ffc8..ec912d883e69 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 7facfee704ff..945a51992ee1 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index 412946be8dab..198897f4bf50 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)", "main": "dist/polyfill-module.js", "license": "MIT", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index d4ae98531996..6b227552f52f 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 99b6702820ff..4b5172b8236d 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "private": true, "scripts": { "build-native": "napi build --platform -p next-swc-napi --cargo-name next_swc_napi native --features plugin", diff --git a/packages/next/package.json b/packages/next/package.json index faa1fc761280..aa572d7b39f5 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -70,7 +70,7 @@ ] }, "dependencies": { - "@next/env": "12.2.6-canary.11", + "@next/env": "12.2.6-canary.12", "@swc/helpers": "0.4.11", "caniuse-lite": "^1.0.30001332", "postcss": "8.4.14", @@ -121,11 +121,11 @@ "@hapi/accept": "5.0.2", "@napi-rs/cli": "2.7.0", "@napi-rs/triples": "1.1.0", - "@next/polyfill-module": "12.2.6-canary.11", - "@next/polyfill-nomodule": "12.2.6-canary.11", - "@next/react-dev-overlay": "12.2.6-canary.11", - "@next/react-refresh-utils": "12.2.6-canary.11", - "@next/swc": "12.2.6-canary.11", + "@next/polyfill-module": "12.2.6-canary.12", + "@next/polyfill-nomodule": "12.2.6-canary.12", + "@next/react-dev-overlay": "12.2.6-canary.12", + "@next/react-refresh-utils": "12.2.6-canary.12", + "@next/swc": "12.2.6-canary.12", "@segment/ajv-human-errors": "2.1.2", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index f7b9a6e6714a..11602ec757a0 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index 40c1d1442215..eb8a3c1762fe 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "12.2.6-canary.11", + "version": "12.2.6-canary.12", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a57007b5348c..d204490f545a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -363,7 +363,7 @@ importers: packages/eslint-config-next: specifiers: - '@next/eslint-plugin-next': 12.2.6-canary.11 + '@next/eslint-plugin-next': 12.2.6-canary.12 '@rushstack/eslint-patch': ^1.1.3 '@typescript-eslint/parser': ^5.21.0 eslint-import-resolver-node: ^0.3.6 @@ -419,12 +419,12 @@ importers: '@hapi/accept': 5.0.2 '@napi-rs/cli': 2.7.0 '@napi-rs/triples': 1.1.0 - '@next/env': 12.2.6-canary.11 - '@next/polyfill-module': 12.2.6-canary.11 - '@next/polyfill-nomodule': 12.2.6-canary.11 - '@next/react-dev-overlay': 12.2.6-canary.11 - '@next/react-refresh-utils': 12.2.6-canary.11 - '@next/swc': 12.2.6-canary.11 + '@next/env': 12.2.6-canary.12 + '@next/polyfill-module': 12.2.6-canary.12 + '@next/polyfill-nomodule': 12.2.6-canary.12 + '@next/react-dev-overlay': 12.2.6-canary.12 + '@next/react-refresh-utils': 12.2.6-canary.12 + '@next/swc': 12.2.6-canary.12 '@segment/ajv-human-errors': 2.1.2 '@swc/helpers': 0.4.11 '@taskr/clear': 1.1.0 From a4d907a564e0f73adcaeaa684a00a3faefc5a678 Mon Sep 17 00:00:00 2001 From: "JH.Lee" Date: Thu, 8 Sep 2022 09:42:19 +0900 Subject: [PATCH 12/69] refactor(next/swc): remove unnecessary field in `RemoveConsole` (#40296) This PR removes `in_function_params` field in `RemoveConsole` module. It's an unnecessary field that does not affect the module. --- packages/next-swc/crates/core/src/remove_console.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/next-swc/crates/core/src/remove_console.rs b/packages/next-swc/crates/core/src/remove_console.rs index 0068cbe16034..035b7dba776c 100644 --- a/packages/next-swc/crates/core/src/remove_console.rs +++ b/packages/next-swc/crates/core/src/remove_console.rs @@ -34,7 +34,6 @@ pub struct Options { struct RemoveConsole { exclude: Vec, bindings: Vec>, - in_function_params: bool, } impl RemoveConsole { @@ -91,12 +90,10 @@ impl Fold for RemoveConsole { } fn fold_function(&mut self, mut func: Function) -> Function { - self.in_function_params = true; let mut new_params: AHashSet = AHashSet::default(); for param in &func.params { new_params.extend(collect_top_level_decls(param)); } - self.in_function_params = false; self.bindings.push(new_params); self.bindings.push(collect_top_level_decls(&func)); @@ -129,6 +126,5 @@ pub fn remove_console(config: Config) -> impl Fold { RemoveConsole { exclude, bindings: Default::default(), - in_function_params: false, } } From 220e144a6a9b164cba7162c2941363c620460953 Mon Sep 17 00:00:00 2001 From: Gal Schlezinger Date: Thu, 8 Sep 2022 14:19:18 +0300 Subject: [PATCH 13/69] [edge] fix URLSearchParams lacking data from rewrite (#40260) Given the change in #40076, when a middleware rewrites into an Edge API route and changes the querystring, the changed querystring does not appear in the incoming NextRequest object in the Edge API route ```ts // middleware.ts export function middleware(req: NextRequest) { const url = req.nextUrl; url.pathname = "/api/hello"; url.searchParams.set("foo", "bar"); return NextResponse.rewrite(url); } // pages/api/hello.ts import { NextRequest } from "next/server"; export default function handler(req: NextRequest) { return NextResponse.json(req.nextUrl.searchParams.get("foo")); } export const config = { runtime: "experimental-edge" }; ``` Our expectation when requesting `/api/hello` is to see `"bar"`, but instead we are getting `null` back. This commit fixes this issue by reading the given `query` instead of using the initial querystring provided with the user request (prior to rewriting) ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` --- packages/next/server/next-server.ts | 4 +--- test/e2e/middleware-general/app/middleware.js | 6 ++++++ .../app/pages/api/edge-search-params.js | 10 ++++++++++ test/e2e/middleware-general/test/index.test.ts | 16 +++++++++++++++- 4 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 test/e2e/middleware-general/app/pages/api/edge-search-params.js diff --git a/packages/next/server/next-server.ts b/packages/next/server/next-server.ts index 7084d982f18a..27316dd1fd3e 100644 --- a/packages/next/server/next-server.ts +++ b/packages/next/server/next-server.ts @@ -2049,9 +2049,7 @@ export default class NextNodeServer extends BaseServer { // For middleware to "fetch" we must always provide an absolute URL const isDataReq = !!params.query.__nextDataReq - const query = urlQueryToSearchParams( - Object.assign({}, getRequestMeta(params.req, '__NEXT_INIT_QUERY') || {}) - ).toString() + const query = urlQueryToSearchParams(params.query).toString() const locale = params.query.__nextLocale // Use original pathname (without `/page`) instead of appPath for url let normalizedPathname = params.page diff --git a/test/e2e/middleware-general/app/middleware.js b/test/e2e/middleware-general/app/middleware.js index 83ba6722ff61..5a5f2f903d01 100644 --- a/test/e2e/middleware-general/app/middleware.js +++ b/test/e2e/middleware-general/app/middleware.js @@ -47,6 +47,12 @@ export async function middleware(request) { return NextResponse.next() } + if (url.pathname === '/api/edge-search-params') { + const newUrl = url.clone() + newUrl.searchParams.set('foo', 'bar') + return NextResponse.rewrite(newUrl) + } + if (url.pathname === '/') { url.pathname = '/ssg/first' return NextResponse.rewrite(url) diff --git a/test/e2e/middleware-general/app/pages/api/edge-search-params.js b/test/e2e/middleware-general/app/pages/api/edge-search-params.js new file mode 100644 index 000000000000..a67cecdf18ec --- /dev/null +++ b/test/e2e/middleware-general/app/pages/api/edge-search-params.js @@ -0,0 +1,10 @@ +import { NextResponse } from 'next/server' + +export const config = { runtime: 'experimental-edge' } + +/** + * @param {import('next/server').NextRequest} + */ +export default (req) => { + return NextResponse.json(Object.fromEntries(req.nextUrl.searchParams)) +} diff --git a/test/e2e/middleware-general/test/index.test.ts b/test/e2e/middleware-general/test/index.test.ts index a99d002b1201..e5e19c6bc1e9 100644 --- a/test/e2e/middleware-general/test/index.test.ts +++ b/test/e2e/middleware-general/test/index.test.ts @@ -116,7 +116,10 @@ describe('Middleware Runtime', () => { 'ANOTHER_MIDDLEWARE_TEST', 'STRING_ENV_VAR', ], - files: ['server/edge-runtime-webpack.js', 'server/middleware.js'], + files: expect.arrayContaining([ + 'server/edge-runtime-webpack.js', + 'server/middleware.js', + ]), name: 'middleware', page: '/', matchers: [{ regexp: '^/.*$' }], @@ -157,6 +160,17 @@ describe('Middleware Runtime', () => { }) } + it('passes search params with rewrites', async () => { + const response = await fetchViaHTTP(next.url, `/api/edge-search-params`, { + a: 'b', + }) + await expect(response.json()).resolves.toMatchObject({ + a: 'b', + // included from middleware + foo: 'bar', + }) + }) + it('should have init header for NextResponse.redirect', async () => { const res = await fetchViaHTTP( next.url, From 45d68ae5096929a810b02463f21c8103e83eb75e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Thu, 8 Sep 2022 13:43:12 +0200 Subject: [PATCH 14/69] Update README.md Closes #40336 --- packages/next/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/README.md b/packages/next/README.md index a85ea7acb225..824aab204216 100644 --- a/packages/next/README.md +++ b/packages/next/README.md @@ -46,7 +46,7 @@ Please see our [contributing.md](/contributing.md). ### Good First Issues -We have a list of [good first issues](https://github.com/vercel/next.js/labels/good%20first%20issue) that contain bugs which have a relatively limited scope. This is a great place to get started, gain experience, and get familiar with our contribution process. +We have a list of [good first issues](https://github.com/vercel/next.js/labels/good%20first%20issue) that contain bugs that have a relatively limited scope. This is a great place to get started, gain experience, and get familiar with our contribution process. ## Authors From 1aa341f635e0e47e31fd94c3d4504bbb51725c9d Mon Sep 17 00:00:00 2001 From: S0UPernova <79978982+S0UPernova@users.noreply.github.com> Date: Thu, 8 Sep 2022 05:44:38 -0700 Subject: [PATCH 15/69] added type to clientPromise in with-mongodb/lib (#40339) ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) --- examples/with-mongodb/lib/mongodb.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/with-mongodb/lib/mongodb.ts b/examples/with-mongodb/lib/mongodb.ts index 7aaf63e04cec..9397929118bb 100644 --- a/examples/with-mongodb/lib/mongodb.ts +++ b/examples/with-mongodb/lib/mongodb.ts @@ -8,7 +8,7 @@ const uri = process.env.MONGODB_URI const options = {} let client -let clientPromise +let clientPromise: Promise if (!process.env.MONGODB_URI) { throw new Error('Please add your Mongo URI to .env.local') From b85fceac635314066b178fa7c7e35edd0da690d9 Mon Sep 17 00:00:00 2001 From: Henrik Wenz Date: Thu, 8 Sep 2022 14:50:53 +0200 Subject: [PATCH 16/69] [Docs] Remove babel from custom-server-typescript example (#40309) ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) --- examples/custom-server-typescript/.babelrc | 3 --- examples/custom-server-typescript/package.json | 18 +++++++++--------- .../custom-server-typescript/tsconfig.json | 3 ++- 3 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 examples/custom-server-typescript/.babelrc diff --git a/examples/custom-server-typescript/.babelrc b/examples/custom-server-typescript/.babelrc deleted file mode 100644 index 1ff94f7ed28e..000000000000 --- a/examples/custom-server-typescript/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["next/babel"] -} diff --git a/examples/custom-server-typescript/package.json b/examples/custom-server-typescript/package.json index dd8cf92cc482..9e79d47ca0a3 100644 --- a/examples/custom-server-typescript/package.json +++ b/examples/custom-server-typescript/package.json @@ -6,17 +6,17 @@ "start": "cross-env NODE_ENV=production node dist/index.js" }, "dependencies": { - "cross-env": "^7.0.2", + "cross-env": "^7.0.3", "next": "latest", - "react": "^17.0.2", - "react-dom": "^17.0.2" + "react": "^18.2.0", + "react-dom": "^18.2.0" }, "devDependencies": { - "@types/node": "^12.0.12", - "@types/react": "^16.9.44", - "@types/react-dom": "^16.9.8", - "nodemon": "^2.0.4", - "ts-node": "^8.10.2", - "typescript": "4.0" + "@types/node": "^18.7.15", + "@types/react": "^18.0.18", + "@types/react-dom": "^18.0.6", + "nodemon": "^2.0.19", + "ts-node": "^10.9.1", + "typescript": "~4.8.2" } } diff --git a/examples/custom-server-typescript/tsconfig.json b/examples/custom-server-typescript/tsconfig.json index 919ea44a15e9..4097ef5f16ea 100644 --- a/examples/custom-server-typescript/tsconfig.json +++ b/examples/custom-server-typescript/tsconfig.json @@ -19,7 +19,8 @@ "preserveConstEnums": true, "sourceMap": true, "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true + "resolveJsonModule": true, + "incremental": true }, "exclude": ["dist", ".next", "out", "next.config.js"], "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"] From 2b9268a91171f76fb83b45b155b9f9bda3b348c4 Mon Sep 17 00:00:00 2001 From: Henrik Wenz Date: Thu, 8 Sep 2022 14:56:12 +0200 Subject: [PATCH 17/69] [Docs] Merge with-mobx-state-tree with with-mobx-state-tree-typescript example (#40306) ## Changes see commits ## Context As discussed in https://github.com/vercel/next.js/pull/40302#issuecomment-1239238966 we are going to merge the mobx examples. #40302 ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) --- .../with-mobx-state-tree-typescript/.babelrc | 4 -- .../.gitignore | 36 ------------- .../with-mobx-state-tree-typescript/README.md | 34 +----------- .../next-env.d.ts | 5 -- .../package.json | 24 --------- examples/with-mobx-state-tree/.babelrc | 4 -- examples/with-mobx-state-tree/README.md | 12 ++--- .../with-mobx-state-tree/components/Clock.js | 25 --------- .../components/Clock.tsx | 0 .../components/SampleComponent.js | 35 ------------- .../components/SampleComponent.tsx | 0 examples/with-mobx-state-tree/package.json | 16 +++--- examples/with-mobx-state-tree/pages/_app.js | 12 ----- .../pages/_app.tsx | 0 examples/with-mobx-state-tree/pages/index.js | 5 -- .../pages/index.tsx | 0 examples/with-mobx-state-tree/pages/other.js | 5 -- .../pages/other.tsx | 0 examples/with-mobx-state-tree/pages/ssg.js | 17 ------ .../pages/ssg.tsx | 0 examples/with-mobx-state-tree/pages/ssr.js | 18 ------- .../pages/ssr.tsx | 0 examples/with-mobx-state-tree/store.js | 52 ------------------- .../store.ts | 0 .../tsconfig.json | 2 +- 25 files changed, 17 insertions(+), 289 deletions(-) delete mode 100644 examples/with-mobx-state-tree-typescript/.babelrc delete mode 100644 examples/with-mobx-state-tree-typescript/.gitignore delete mode 100644 examples/with-mobx-state-tree-typescript/next-env.d.ts delete mode 100644 examples/with-mobx-state-tree-typescript/package.json delete mode 100644 examples/with-mobx-state-tree/.babelrc delete mode 100644 examples/with-mobx-state-tree/components/Clock.js rename examples/{with-mobx-state-tree-typescript => with-mobx-state-tree}/components/Clock.tsx (100%) delete mode 100644 examples/with-mobx-state-tree/components/SampleComponent.js rename examples/{with-mobx-state-tree-typescript => with-mobx-state-tree}/components/SampleComponent.tsx (100%) delete mode 100644 examples/with-mobx-state-tree/pages/_app.js rename examples/{with-mobx-state-tree-typescript => with-mobx-state-tree}/pages/_app.tsx (100%) delete mode 100644 examples/with-mobx-state-tree/pages/index.js rename examples/{with-mobx-state-tree-typescript => with-mobx-state-tree}/pages/index.tsx (100%) delete mode 100644 examples/with-mobx-state-tree/pages/other.js rename examples/{with-mobx-state-tree-typescript => with-mobx-state-tree}/pages/other.tsx (100%) delete mode 100644 examples/with-mobx-state-tree/pages/ssg.js rename examples/{with-mobx-state-tree-typescript => with-mobx-state-tree}/pages/ssg.tsx (100%) delete mode 100644 examples/with-mobx-state-tree/pages/ssr.js rename examples/{with-mobx-state-tree-typescript => with-mobx-state-tree}/pages/ssr.tsx (100%) delete mode 100644 examples/with-mobx-state-tree/store.js rename examples/{with-mobx-state-tree-typescript => with-mobx-state-tree}/store.ts (100%) rename examples/{with-mobx-state-tree-typescript => with-mobx-state-tree}/tsconfig.json (93%) diff --git a/examples/with-mobx-state-tree-typescript/.babelrc b/examples/with-mobx-state-tree-typescript/.babelrc deleted file mode 100644 index 1bbd4ca8f2cd..000000000000 --- a/examples/with-mobx-state-tree-typescript/.babelrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "presets": ["next/babel"], - "plugins": [["@babel/plugin-proposal-decorators", { "legacy": true }]] -} diff --git a/examples/with-mobx-state-tree-typescript/.gitignore b/examples/with-mobx-state-tree-typescript/.gitignore deleted file mode 100644 index c87c9b392c02..000000000000 --- a/examples/with-mobx-state-tree-typescript/.gitignore +++ /dev/null @@ -1,36 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -.pnpm-debug.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts diff --git a/examples/with-mobx-state-tree-typescript/README.md b/examples/with-mobx-state-tree-typescript/README.md index 5c169956f27c..ee22d0490016 100644 --- a/examples/with-mobx-state-tree-typescript/README.md +++ b/examples/with-mobx-state-tree-typescript/README.md @@ -1,35 +1,3 @@ # MobX State Tree with TypeScript example -Usually splitting your app state into `pages` feels natural but sometimes you'll want to have global state for your app. This is an example on how you can use mobx that also works with our universal rendering approach. - -In this example we are going to display a digital clock that updates every second. The first render is happening in the server and the date will be `00:00:00`, then the browser will take over and it will start updating the date. - -To illustrate SSG and SSR, go to `/ssg` and `/ssr`, those pages are using Next.js data fetching methods to get the date in the server and return it as props to the page, and then the browser will hydrate the store and continue updating the date. - -The trick here for supporting universal mobx is to separate the cases for the client and the server. When we are on the server we want to create a new store every time, otherwise different users data will be mixed up. If we are in the client we want to use always the same store. That's what we accomplish on `store.js` - -The clock, under `components/Clock.js`, has access to the state using the `inject` and `observer` functions from `mobx-react`. In this case Clock is a direct child from the page but it could be deep down the render tree. - -## Deploy your own - -Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-mobx-state-tree-typescript) - -[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-mobx-state-tree-typescript&project-name=with-mobx-state-tree-typescript&repository-name=with-mobx-state-tree-typescript) - -## How to use - -Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example: - -```bash -npx create-next-app --example with-mobx-state-tree-typescript with-mobx-state-tree-typescript-app -``` - -```bash -yarn create next-app --example with-mobx-state-tree-typescript with-mobx-state-tree-typescript-app -``` - -```bash -pnpm create next-app --example with-mobx-state-tree-typescript with-mobx-state-tree-typescript-app -``` - -Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). +**Note:** This example has been moved to [examples/with-mobx-state-tree](../with-mobx-state-tree/) diff --git a/examples/with-mobx-state-tree-typescript/next-env.d.ts b/examples/with-mobx-state-tree-typescript/next-env.d.ts deleted file mode 100644 index 4f11a03dc6cc..000000000000 --- a/examples/with-mobx-state-tree-typescript/next-env.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// -/// - -// NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/examples/with-mobx-state-tree-typescript/package.json b/examples/with-mobx-state-tree-typescript/package.json deleted file mode 100644 index 7e05b342b506..000000000000 --- a/examples/with-mobx-state-tree-typescript/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "private": true, - "scripts": { - "dev": "next", - "build": "next build", - "start": "next start" - }, - "dependencies": { - "mobx": "^5.9.0", - "mobx-react": "^5.4.3", - "mobx-react-lite": "^2.0.7", - "mobx-state-tree": "^3.11.0", - "next": "latest", - "react": "^17.0.2", - "react-dom": "^17.0.2", - "typescript": "^3.0.1" - }, - "devDependencies": { - "@babel/core": "7.14.3", - "@babel/plugin-proposal-decorators": "^7.3.0", - "@types/node": "^14.0.23", - "@types/react": "^16.4.12" - } -} diff --git a/examples/with-mobx-state-tree/.babelrc b/examples/with-mobx-state-tree/.babelrc deleted file mode 100644 index 1bbd4ca8f2cd..000000000000 --- a/examples/with-mobx-state-tree/.babelrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "presets": ["next/babel"], - "plugins": [["@babel/plugin-proposal-decorators", { "legacy": true }]] -} diff --git a/examples/with-mobx-state-tree/README.md b/examples/with-mobx-state-tree/README.md index af8e00e1306e..5c169956f27c 100644 --- a/examples/with-mobx-state-tree/README.md +++ b/examples/with-mobx-state-tree/README.md @@ -1,4 +1,4 @@ -# MobX State Tree example +# MobX State Tree with TypeScript example Usually splitting your app state into `pages` feels natural but sometimes you'll want to have global state for your app. This is an example on how you can use mobx that also works with our universal rendering approach. @@ -12,24 +12,24 @@ The clock, under `components/Clock.js`, has access to the state using the `injec ## Deploy your own -Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-mobx-state-tree) +Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-mobx-state-tree-typescript) -[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-mobx-state-tree&project-name=with-mobx-state-tree&repository-name=with-mobx-state-tree) +[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-mobx-state-tree-typescript&project-name=with-mobx-state-tree-typescript&repository-name=with-mobx-state-tree-typescript) ## How to use Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example: ```bash -npx create-next-app --example with-mobx-state-tree with-mobx-state-tree-app +npx create-next-app --example with-mobx-state-tree-typescript with-mobx-state-tree-typescript-app ``` ```bash -yarn create next-app --example with-mobx-state-tree with-mobx-state-tree-app +yarn create next-app --example with-mobx-state-tree-typescript with-mobx-state-tree-typescript-app ``` ```bash -pnpm create next-app --example with-mobx-state-tree with-mobx-state-tree-app +pnpm create next-app --example with-mobx-state-tree-typescript with-mobx-state-tree-typescript-app ``` Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)). diff --git a/examples/with-mobx-state-tree/components/Clock.js b/examples/with-mobx-state-tree/components/Clock.js deleted file mode 100644 index cfbddeae67ab..000000000000 --- a/examples/with-mobx-state-tree/components/Clock.js +++ /dev/null @@ -1,25 +0,0 @@ -export default function Clock(props) { - return ( -
- {format(new Date(props.lastUpdate))} - -
- ) -} - -const format = (t) => - `${pad(t.getUTCHours())}:${pad(t.getUTCMinutes())}:${pad(t.getUTCSeconds())}` - -const pad = (n) => (n < 10 ? `0${n}` : n) diff --git a/examples/with-mobx-state-tree-typescript/components/Clock.tsx b/examples/with-mobx-state-tree/components/Clock.tsx similarity index 100% rename from examples/with-mobx-state-tree-typescript/components/Clock.tsx rename to examples/with-mobx-state-tree/components/Clock.tsx diff --git a/examples/with-mobx-state-tree/components/SampleComponent.js b/examples/with-mobx-state-tree/components/SampleComponent.js deleted file mode 100644 index 6478d9319aba..000000000000 --- a/examples/with-mobx-state-tree/components/SampleComponent.js +++ /dev/null @@ -1,35 +0,0 @@ -import React from 'react' -import Link from 'next/link' -import { inject, observer } from 'mobx-react' -import Clock from './Clock' - -@inject('store') -@observer -class SampleComponent extends React.Component { - componentDidMount() { - this.props.store.start() - } - - componentWillUnmount() { - this.props.store.stop() - } - - render() { - return ( -
-

{this.props.title}

- - -
- ) - } -} - -export default SampleComponent diff --git a/examples/with-mobx-state-tree-typescript/components/SampleComponent.tsx b/examples/with-mobx-state-tree/components/SampleComponent.tsx similarity index 100% rename from examples/with-mobx-state-tree-typescript/components/SampleComponent.tsx rename to examples/with-mobx-state-tree/components/SampleComponent.tsx diff --git a/examples/with-mobx-state-tree/package.json b/examples/with-mobx-state-tree/package.json index 819eed5e194c..0a2de828056c 100644 --- a/examples/with-mobx-state-tree/package.json +++ b/examples/with-mobx-state-tree/package.json @@ -6,15 +6,17 @@ "start": "next start" }, "dependencies": { - "mobx": "3.3.1", - "mobx-react": "^4.0.4", - "mobx-state-tree": "1.0.1", + "mobx": "^6.6.1", + "mobx-react": "^7.5.2", + "mobx-react-lite": "^3.4.0", + "mobx-state-tree": "^5.1.6", "next": "latest", - "react": "^17.0.2", - "react-dom": "^17.0.2" + "react": "^18.2.0", + "react-dom": "^18.2.0" }, "devDependencies": { - "@babel/core": "7.14.5", - "@babel/plugin-proposal-decorators": "^7.1.2" + "@types/node": "^18.7.15", + "@types/react": "^18.0.18", + "typescript": "^4.8.2" } } diff --git a/examples/with-mobx-state-tree/pages/_app.js b/examples/with-mobx-state-tree/pages/_app.js deleted file mode 100644 index e75b81d85556..000000000000 --- a/examples/with-mobx-state-tree/pages/_app.js +++ /dev/null @@ -1,12 +0,0 @@ -import { Provider } from 'mobx-react' -import { useStore } from '../store' - -export default function App({ Component, pageProps }) { - const store = useStore(pageProps.initialState) - - return ( - - - - ) -} diff --git a/examples/with-mobx-state-tree-typescript/pages/_app.tsx b/examples/with-mobx-state-tree/pages/_app.tsx similarity index 100% rename from examples/with-mobx-state-tree-typescript/pages/_app.tsx rename to examples/with-mobx-state-tree/pages/_app.tsx diff --git a/examples/with-mobx-state-tree/pages/index.js b/examples/with-mobx-state-tree/pages/index.js deleted file mode 100644 index 00b3a426d77d..000000000000 --- a/examples/with-mobx-state-tree/pages/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import SampleComponent from '../components/SampleComponent' - -export default function Home() { - return -} diff --git a/examples/with-mobx-state-tree-typescript/pages/index.tsx b/examples/with-mobx-state-tree/pages/index.tsx similarity index 100% rename from examples/with-mobx-state-tree-typescript/pages/index.tsx rename to examples/with-mobx-state-tree/pages/index.tsx diff --git a/examples/with-mobx-state-tree/pages/other.js b/examples/with-mobx-state-tree/pages/other.js deleted file mode 100644 index 64baaaeeddfb..000000000000 --- a/examples/with-mobx-state-tree/pages/other.js +++ /dev/null @@ -1,5 +0,0 @@ -import SampleComponent from '../components/SampleComponent' - -export default function Other() { - return -} diff --git a/examples/with-mobx-state-tree-typescript/pages/other.tsx b/examples/with-mobx-state-tree/pages/other.tsx similarity index 100% rename from examples/with-mobx-state-tree-typescript/pages/other.tsx rename to examples/with-mobx-state-tree/pages/other.tsx diff --git a/examples/with-mobx-state-tree/pages/ssg.js b/examples/with-mobx-state-tree/pages/ssg.js deleted file mode 100644 index 4191006042e6..000000000000 --- a/examples/with-mobx-state-tree/pages/ssg.js +++ /dev/null @@ -1,17 +0,0 @@ -import { getSnapshot } from 'mobx-state-tree' -import SampleComponent from '../components/SampleComponent' -import { initializeStore } from '../store' - -export default function Ssg() { - return -} - -// If you build and start the app, the date returned here will have the same -// value for all requests, as this method gets executed at build time. -export function getStaticProps() { - const store = initializeStore() - - store.update() - - return { props: { initialState: getSnapshot(store) } } -} diff --git a/examples/with-mobx-state-tree-typescript/pages/ssg.tsx b/examples/with-mobx-state-tree/pages/ssg.tsx similarity index 100% rename from examples/with-mobx-state-tree-typescript/pages/ssg.tsx rename to examples/with-mobx-state-tree/pages/ssg.tsx diff --git a/examples/with-mobx-state-tree/pages/ssr.js b/examples/with-mobx-state-tree/pages/ssr.js deleted file mode 100644 index 8bdb3f3e50ad..000000000000 --- a/examples/with-mobx-state-tree/pages/ssr.js +++ /dev/null @@ -1,18 +0,0 @@ -import { getSnapshot } from 'mobx-state-tree' -import SampleComponent from '../components/SampleComponent' -import { initializeStore } from '../store' - -export default function Ssr() { - return -} - -// The date returned here will be different for every request that hits the page, -// that is because the page becomes a serverless function instead of being statically -// exported when you use `getServerSideProps` or `getInitialProps` -export function getServerSideProps() { - const store = initializeStore() - - store.update() - - return { props: { initialState: getSnapshot(store) } } -} diff --git a/examples/with-mobx-state-tree-typescript/pages/ssr.tsx b/examples/with-mobx-state-tree/pages/ssr.tsx similarity index 100% rename from examples/with-mobx-state-tree-typescript/pages/ssr.tsx rename to examples/with-mobx-state-tree/pages/ssr.tsx diff --git a/examples/with-mobx-state-tree/store.js b/examples/with-mobx-state-tree/store.js deleted file mode 100644 index 879feca16f04..000000000000 --- a/examples/with-mobx-state-tree/store.js +++ /dev/null @@ -1,52 +0,0 @@ -import { useMemo } from 'react' -import { types, applySnapshot } from 'mobx-state-tree' - -let store - -const Store = types - .model({ - lastUpdate: types.Date, - light: false, - }) - .actions((self) => { - let timer - function start() { - timer = setInterval(() => { - // mobx-state-tree doesn't allow anonymous callbacks changing data - // pass off to another action instead - self.update() - }, 1000) - } - - function update() { - self.lastUpdate = Date.now() - self.light = true - } - - function stop() { - clearInterval(timer) - } - - return { start, stop, update } - }) - -export function initializeStore(snapshot = null) { - const _store = store ?? Store.create({ lastUpdate: 0 }) - - // If your page has Next.js data fetching methods that use a Mobx store, it will - // get hydrated here, check `pages/ssg.js` and `pages/ssr.js` for more details - if (snapshot) { - applySnapshot(_store, snapshot) - } - // For SSG and SSR always create a new store - if (typeof window === 'undefined') return _store - // Create the store once in the client - if (!store) store = _store - - return store -} - -export function useStore(initialState) { - const store = useMemo(() => initializeStore(initialState), [initialState]) - return store -} diff --git a/examples/with-mobx-state-tree-typescript/store.ts b/examples/with-mobx-state-tree/store.ts similarity index 100% rename from examples/with-mobx-state-tree-typescript/store.ts rename to examples/with-mobx-state-tree/store.ts diff --git a/examples/with-mobx-state-tree-typescript/tsconfig.json b/examples/with-mobx-state-tree/tsconfig.json similarity index 93% rename from examples/with-mobx-state-tree-typescript/tsconfig.json rename to examples/with-mobx-state-tree/tsconfig.json index b5d1e2f17bbe..e1e1e26feec7 100644 --- a/examples/with-mobx-state-tree-typescript/tsconfig.json +++ b/examples/with-mobx-state-tree/tsconfig.json @@ -13,7 +13,7 @@ "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", - "experimentalDecorators": true + "incremental": true }, "exclude": ["node_modules"], "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"] From 66834d5c153f5473859e5a499f5b0cf13d902a5a Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 8 Sep 2022 11:09:46 -0400 Subject: [PATCH 18/69] Fix `image-component` example types (#40352) --- examples/image-component/pages/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/image-component/pages/index.tsx b/examples/image-component/pages/index.tsx index 55e23411e7d2..012011cf1ec7 100644 --- a/examples/image-component/pages/index.tsx +++ b/examples/image-component/pages/index.tsx @@ -5,7 +5,7 @@ import ViewSource from '../components/view-source' import vercel from '../public/vercel.png' import type { PropsWithChildren } from 'react' -const Code = (props: PropsWithChildren) => ( +const Code = (props: PropsWithChildren<{}>) => ( ) From 712d98d3d7ba3ca9849c964aa611e805291a7f7f Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 8 Sep 2022 11:19:55 -0400 Subject: [PATCH 19/69] Update docs for `remotePatterns` image config (#40350) This updates the docs to favor `remotePatterns` image config (instead of `domains`) --- docs/api-reference/next/future/image.md | 4 +++- docs/api-reference/next/image.md | 4 +++- docs/basic-features/image-optimization.md | 12 ++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/api-reference/next/future/image.md b/docs/api-reference/next/future/image.md index b0a8883262c6..2aba62f711ad 100644 --- a/docs/api-reference/next/future/image.md +++ b/docs/api-reference/next/future/image.md @@ -151,7 +151,7 @@ Must be one of the following: 2. A path string. This can be either an absolute external URL, or an internal path depending on the [loader](#loader) prop. -When using an external URL, you must add it to [domains](#domains) in `next.config.js`. +When using an external URL, you must add it to [remotePatterns](#remote-patterns) in `next.config.js`. ### width @@ -430,6 +430,8 @@ The `**` syntax does not work in the middle of the pattern. ### Domains +> Note: We recommend using [`remotePatterns`](#remote-patterns) instead so you can restrict protocol and pathname. + Similar to [`remotePatterns`](#remote-patterns), the `domains` configuration can be used to provide a list of allowed hostnames for external images. However, the `domains` configuration does not support wildcard pattern matching and it cannot restrict protocol, port, or pathname. diff --git a/docs/api-reference/next/image.md b/docs/api-reference/next/image.md index 60ffe36f20da..5c0bc210e088 100644 --- a/docs/api-reference/next/image.md +++ b/docs/api-reference/next/image.md @@ -45,7 +45,7 @@ Must be one of the following: or an internal path depending on the [loader](#loader) prop or [loader configuration](#loader-configuration). When using an external URL, you must add it to -[domains](#domains) in +[remotePatterns](#remote-patterns) in `next.config.js`. ### width @@ -393,6 +393,8 @@ The `**` syntax does not work in the middle of the pattern. ### Domains +> Note: We recommend using [`remotePatterns`](#remote-patterns) instead so you can restrict protocol and pathname. + Similar to [`remotePatterns`](#remote-patterns), the `domains` configuration can be used to provide a list of allowed hostnames for external images. However, the `domains` configuration does not support wildcard pattern matching and it cannot restrict protocol, port, or pathname. diff --git a/docs/basic-features/image-optimization.md b/docs/basic-features/image-optimization.md index 1b5ac21aa200..e53e61f8b773 100644 --- a/docs/basic-features/image-optimization.md +++ b/docs/basic-features/image-optimization.md @@ -72,7 +72,7 @@ function Home() { ### Remote Images -To use a remote image, the `src` property should be a URL string, which can be [relative](#loaders) or [absolute](/docs/api-reference/next/image.md#domains). Because Next.js does not have access to remote files during the build process, you'll need to provide the [`width`](/docs/api-reference/next/image.md#width), [`height`](/docs/api-reference/next/image.md#height) and optional [`blurDataURL`](/docs/api-reference/next/image.md#blurdataurl) props manually: +To use a remote image, the `src` property should be a URL string, which can be [relative](#loaders) or [absolute](/docs/api-reference/next/image.md#remote-patterns). Because Next.js does not have access to remote files during the build process, you'll need to provide the [`width`](/docs/api-reference/next/image.md#width), [`height`](/docs/api-reference/next/image.md#height) and optional [`blurDataURL`](/docs/api-reference/next/image.md#blurdataurl) props manually: ```jsx import Image from 'next/image' @@ -97,17 +97,17 @@ export default function Home() { ### Domains -Sometimes you may want to access a remote image, but still use the built-in Next.js Image Optimization API. To do this, leave the `loader` at its default setting and enter an absolute URL for the Image `src`. +Sometimes you may want to optimize a remote image, but still use the built-in Next.js Image Optimization API. To do this, leave the `loader` at its default setting and enter an absolute URL for the Image `src` prop. -To protect your application from malicious users, you must define a list of remote hostnames you intend to allow remote access. +To protect your application from malicious users, you must define a list of remote hostnames you intend to use with the `next/image` component. -> Learn more about [`domains`](/docs/api-reference/next/image.md#domains) configuration. +> Learn more about [`remotePatterns`](/docs/api-reference/next/image.md#remote-patterns) configuration. ### Loaders Note that in the [example earlier](#remote-images), a partial URL (`"/me.png"`) is provided for a remote image. This is possible because of the `next/image` [loader](/docs/api-reference/next/image.md#loader) architecture. -A loader is a function that generates the URLs for your image. It appends a root domain to your provided `src`, and generates multiple URLs to request the image at different sizes. These multiple URLs are used in the automatic [srcset](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/srcset) generation, so that visitors to your site will be served an image that is the right size for their viewport. +A loader is a function that generates the URLs for your image. It modifies the provided `src`, and generates multiple URLs to request the image at different sizes. These multiple URLs are used in the automatic [srcset](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/srcset) generation, so that visitors to your site will be served an image that is the right size for their viewport. The default loader for Next.js applications uses the built-in Image Optimization API, which optimizes images from anywhere on the web, and then serves them directly from the Next.js web server. If you would like to serve your images directly from a CDN or image server, you can use one of the [built-in loaders](/docs/api-reference/next/image.md#built-in-loaders) or write your own with a few lines of JavaScript. @@ -209,7 +209,7 @@ For examples of the Image component used with the various fill modes, see the [I ## Configuration -The `next/image` component and Next.js Image Optimization API can be configured in the [`next.config.js` file](/docs/api-reference/next.config.js/introduction.md). These configurations allow you to [enable remote images](/docs/api-reference/next/image.md#domains), [define custom image breakpoints](/docs/api-reference/next/image.md#device-sizes), [change caching behavior](/docs/api-reference/next/image.md#caching-behavior) and more. +The `next/image` component and Next.js Image Optimization API can be configured in the [`next.config.js` file](/docs/api-reference/next.config.js/introduction.md). These configurations allow you to [enable remote images](/docs/api-reference/next/image.md#remote-patterns), [define custom image breakpoints](/docs/api-reference/next/image.md#device-sizes), [change caching behavior](/docs/api-reference/next/image.md#caching-behavior) and more. [**Read the full image configuration documentation for more information.**](/docs/api-reference/next/image.md#configuration-options) From 5793301c609036b7845a909e8420e8c0e0778624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Thu, 8 Sep 2022 17:21:36 +0200 Subject: [PATCH 20/69] fix(lint): disable `react/no-unknown-property` (#40331) ~(PR https://github.com/jsx-eslint/eslint-plugin-react/pull/3377) introduced a change in `eslint-plugin-react@7.31.2` that will now show an error when unknown properties appear on elements. We can opt out of this by overriding the default.~ As discussed internally, we are turning `react/no-unknown-property` off, as it might be confusing even if different props are being used, (eg.: `css` for `emotion`). It's easy to fix https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md#rule-options, but it might not be clear at first glance that Next.js is using `eslint-plugin-react` internally. If the user wants to enforce this rule, they can still add it to their own `rules` config. Fixes #40321, ref: https://github.com/vercel/next.js/discussions/40269, https://github.com/vercel/next.js/issues/38333 --- packages/eslint-config-next/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-next/index.js b/packages/eslint-config-next/index.js index 5c846dee12af..24a28c0c523b 100644 --- a/packages/eslint-config-next/index.js +++ b/packages/eslint-config-next/index.js @@ -60,6 +60,7 @@ module.exports = { plugins: ['import', 'react', 'jsx-a11y'], rules: { 'import/no-anonymous-default-export': 'warn', + 'react/no-unknown-property': 'off', 'react/react-in-jsx-scope': 'off', 'react/prop-types': 'off', 'jsx-a11y/alt-text': [ From 75e5616ce4d20db7f8c58839b806527a03a6d119 Mon Sep 17 00:00:00 2001 From: Carl von Buelow Date: Thu, 8 Sep 2022 11:37:41 -0400 Subject: [PATCH 21/69] Update `onLoadingComplete` for `next/future/image` to receive reference to `` (#40326) * fixes #18398 * fixes #38864 Co-authored-by: Steven --- docs/api-reference/next/future/image.md | 16 +++++++--------- packages/next/client/future/image.tsx | 10 ++-------- .../default/pages/on-loading-complete.js | 6 ++++-- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/docs/api-reference/next/future/image.md b/docs/api-reference/next/future/image.md index 2aba62f711ad..bd97cbeced80 100644 --- a/docs/api-reference/next/future/image.md +++ b/docs/api-reference/next/future/image.md @@ -7,11 +7,11 @@ description: Try the latest Image Optimization with the new `next/future/image`
Version History -| Version | Changes | -| --------- | --------------------------------------------------------------------------------------------------------------------------- | -| `v12.3.0` | `next/future/image` component stable. `remotePatterns` config stable. `unoptimized` config stable. `alt` property required. | -| `v12.2.4` | `fill` property added. | -| `v12.2.0` | Experimental `next/future/image` component introduced. | +| Version | Changes | +| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `v12.3.0` | `next/future/image` component stable. `remotePatterns` config stable. `unoptimized` config stable. `alt` property required. `onLoadingComplete` receives `` | +| `v12.2.4` | `fill` property added. | +| `v12.2.0` | Experimental `next/future/image` component introduced. |
@@ -33,6 +33,7 @@ Compared to `next/image`, the new `next/future/image` component has the followin - Removes `lazyRoot` prop since there is no native equivalent - Removes `loader` config in favor of [`loader`](#loader) prop - Changed `alt` prop from optional to required +- Changed `onLoadingComplete` callback to receive reference to `` element ## Known Browser Bugs @@ -306,10 +307,7 @@ Also keep in mind that the required `width` and `height` props can interact with A callback function that is invoked once the image is completely loaded and the [placeholder](#placeholder) has been removed. -The callback function will be called with one argument, an object with the following properties: - -- [`naturalWidth`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/naturalWidth) -- [`naturalHeight`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/naturalHeight) +The callback function will be called with one argument, a reference to the underlying `` element. ### onLoad diff --git a/packages/next/client/future/image.tsx b/packages/next/client/future/image.tsx index bef68231bd7c..24081c4b7d7a 100644 --- a/packages/next/client/future/image.tsx +++ b/packages/next/client/future/image.tsx @@ -47,10 +47,7 @@ type ImageLoaderPropsWithConfig = ImageLoaderProps & { type PlaceholderValue = 'blur' | 'empty' -type OnLoadingComplete = (result: { - naturalWidth: number - naturalHeight: number -}) => void +type OnLoadingComplete = (img: HTMLImageElement) => void type ImgElementStyle = NonNullable @@ -265,10 +262,7 @@ function handleLoading( setBlurComplete(true) } if (onLoadingCompleteRef?.current) { - const { naturalWidth, naturalHeight } = img - // Pass back read-only primitive values but not the - // underlying DOM element because it could be misused. - onLoadingCompleteRef.current({ naturalWidth, naturalHeight }) + onLoadingCompleteRef.current(img) } if (process.env.NODE_ENV !== 'production') { if (img.getAttribute('data-nimg') === 'future-fill') { diff --git a/test/integration/image-future/default/pages/on-loading-complete.js b/test/integration/image-future/default/pages/on-loading-complete.js index b89d655268e3..da60e069f319 100644 --- a/test/integration/image-future/default/pages/on-loading-complete.js +++ b/test/integration/image-future/default/pages/on-loading-complete.js @@ -105,13 +105,15 @@ function ImageWithMessage({ id, idToCount, setIdToCount, ...props }) {
{ + onLoadingComplete={(img) => { + const { naturalWidth, naturalHeight, nodeName } = img let count = idToCount[id] || 0 count++ idToCount[id] = count setIdToCount(idToCount) + const name = nodeName.toLocaleLowerCase() setMsg( - `loaded ${count} img${id} with dimensions ${naturalWidth}x${naturalHeight}` + `loaded ${count} ${name}${id} with dimensions ${naturalWidth}x${naturalHeight}` ) }} {...props} From 56c5abd3de120551d65f6d43c385c9c460672f6f Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 8 Sep 2022 08:43:20 -0700 Subject: [PATCH 22/69] Remove warning for swcMinify being enabled (#40359) This removes the warning for `swcMinify` as a release candidate as it is now being marked as stable. x-ref: [slack thread](https://vercel.slack.com/archives/CGU8HUTUH/p1662647498560729) ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) --- packages/next/server/config.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/next/server/config.ts b/packages/next/server/config.ts index e5c1260a8d10..07406b6b32c0 100644 --- a/packages/next/server/config.ts +++ b/packages/next/server/config.ts @@ -511,10 +511,6 @@ function assignDefaults(userConfig: { [key: string]: any }) { result.compiler.removeConsole = (result.experimental as any).removeConsole } - if (result.swcMinify) { - Log.info('SWC minify release candidate enabled. https://nextjs.link/swcmin') - } - if (result.experimental?.swcMinifyDebugOptions) { Log.warn( 'SWC minify debug option specified. This option is for debugging minifier issues and will be removed once SWC minifier is stable.' From 0376534a29324ded4b52ad9a39d7fa1938bac1ae Mon Sep 17 00:00:00 2001 From: Leon Si Date: Thu, 8 Sep 2022 11:44:58 -0400 Subject: [PATCH 23/69] docs: fix typo (#40354) ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) --- docs/migrating/incremental-adoption.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/migrating/incremental-adoption.md b/docs/migrating/incremental-adoption.md index a52182e37667..4334ad640ec6 100644 --- a/docs/migrating/incremental-adoption.md +++ b/docs/migrating/incremental-adoption.md @@ -92,4 +92,4 @@ Once your monorepo is set up, push changes to your Git repository as usual and y ## Conclusion -To learn more, read about [subpaths](/docs/api-reference/next.config.js/basepath.md) and [rewrites](/docs/api-reference/next.config.js/rewrites.md) or [deploy a Next.jsmonorepo](https://vercel.com/templates/next.js/monorepo). +To learn more, read about [subpaths](/docs/api-reference/next.config.js/basepath.md) and [rewrites](/docs/api-reference/next.config.js/rewrites.md) or [deploy a Next.js monorepo](https://vercel.com/templates/next.js/monorepo). From 9576a278b6d7b1b1562a095675500497ae6bd6ac Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 8 Sep 2022 08:48:54 -0700 Subject: [PATCH 24/69] v12.2.6-canary.13 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/eslint-config-next/package.json | 4 ++-- packages/eslint-plugin-next/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-codemod/package.json | 2 +- packages/next-env/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-storybook/package.json | 2 +- packages/next-polyfill-module/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next-swc/package.json | 2 +- packages/next/package.json | 14 +++++++------- packages/react-dev-overlay/package.json | 2 +- packages/react-refresh-utils/package.json | 2 +- pnpm-lock.yaml | 14 +++++++------- 16 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lerna.json b/lerna.json index dc5ab3db5feb..450e7435427e 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "12.2.6-canary.12" + "version": "12.2.6-canary.13" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 45f18996dabe..b87647623a66 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 4617fbec97a4..c9a3d4d58fbd 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -9,7 +9,7 @@ "directory": "packages/eslint-config-next" }, "dependencies": { - "@next/eslint-plugin-next": "12.2.6-canary.12", + "@next/eslint-plugin-next": "12.2.6-canary.13", "@rushstack/eslint-patch": "^1.1.3", "@typescript-eslint/parser": "^5.21.0", "eslint-import-resolver-node": "^0.3.6", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 80240a527714..e96d8afecb8d 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "description": "ESLint plugin for NextJS.", "main": "lib/index.js", "license": "MIT", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 18adefc11bdb..39e26ee312a4 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index ae97f89ed5c3..4917d36e919c 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "license": "MIT", "dependencies": { "chalk": "4.1.0", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 73473cc501c5..c6886bb1c817 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index ec912d883e69..c6486435da59 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 945a51992ee1..5ac9ab58f229 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index 198897f4bf50..445d1e498542 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)", "main": "dist/polyfill-module.js", "license": "MIT", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index 6b227552f52f..8d5544828b02 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 4b5172b8236d..b8ea7be2130d 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "private": true, "scripts": { "build-native": "napi build --platform -p next-swc-napi --cargo-name next_swc_napi native --features plugin", diff --git a/packages/next/package.json b/packages/next/package.json index aa572d7b39f5..6437962bcf9d 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -70,7 +70,7 @@ ] }, "dependencies": { - "@next/env": "12.2.6-canary.12", + "@next/env": "12.2.6-canary.13", "@swc/helpers": "0.4.11", "caniuse-lite": "^1.0.30001332", "postcss": "8.4.14", @@ -121,11 +121,11 @@ "@hapi/accept": "5.0.2", "@napi-rs/cli": "2.7.0", "@napi-rs/triples": "1.1.0", - "@next/polyfill-module": "12.2.6-canary.12", - "@next/polyfill-nomodule": "12.2.6-canary.12", - "@next/react-dev-overlay": "12.2.6-canary.12", - "@next/react-refresh-utils": "12.2.6-canary.12", - "@next/swc": "12.2.6-canary.12", + "@next/polyfill-module": "12.2.6-canary.13", + "@next/polyfill-nomodule": "12.2.6-canary.13", + "@next/react-dev-overlay": "12.2.6-canary.13", + "@next/react-refresh-utils": "12.2.6-canary.13", + "@next/swc": "12.2.6-canary.13", "@segment/ajv-human-errors": "2.1.2", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index 11602ec757a0..a1f96790dc5e 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index eb8a3c1762fe..dd9ea6620338 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "12.2.6-canary.12", + "version": "12.2.6-canary.13", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d204490f545a..0d6e4f010786 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -363,7 +363,7 @@ importers: packages/eslint-config-next: specifiers: - '@next/eslint-plugin-next': 12.2.6-canary.12 + '@next/eslint-plugin-next': 12.2.6-canary.13 '@rushstack/eslint-patch': ^1.1.3 '@typescript-eslint/parser': ^5.21.0 eslint-import-resolver-node: ^0.3.6 @@ -419,12 +419,12 @@ importers: '@hapi/accept': 5.0.2 '@napi-rs/cli': 2.7.0 '@napi-rs/triples': 1.1.0 - '@next/env': 12.2.6-canary.12 - '@next/polyfill-module': 12.2.6-canary.12 - '@next/polyfill-nomodule': 12.2.6-canary.12 - '@next/react-dev-overlay': 12.2.6-canary.12 - '@next/react-refresh-utils': 12.2.6-canary.12 - '@next/swc': 12.2.6-canary.12 + '@next/env': 12.2.6-canary.13 + '@next/polyfill-module': 12.2.6-canary.13 + '@next/polyfill-nomodule': 12.2.6-canary.13 + '@next/react-dev-overlay': 12.2.6-canary.13 + '@next/react-refresh-utils': 12.2.6-canary.13 + '@next/swc': 12.2.6-canary.13 '@segment/ajv-human-errors': 2.1.2 '@swc/helpers': 0.4.11 '@taskr/clear': 1.1.0 From ba4c575334796db92c93957afa97ef483cea3f2e Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 8 Sep 2022 09:00:04 -0700 Subject: [PATCH 25/69] v12.3.0 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/eslint-config-next/package.json | 4 ++-- packages/eslint-plugin-next/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-codemod/package.json | 2 +- packages/next-env/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-storybook/package.json | 2 +- packages/next-polyfill-module/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next-swc/package.json | 2 +- packages/next/package.json | 14 +++++++------- packages/react-dev-overlay/package.json | 2 +- packages/react-refresh-utils/package.json | 2 +- pnpm-lock.yaml | 14 +++++++------- 16 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lerna.json b/lerna.json index 450e7435427e..2299fc6a2892 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "12.2.6-canary.13" + "version": "12.3.0" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index b87647623a66..9d5d6bbbea59 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "12.2.6-canary.13", + "version": "12.3.0", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index c9a3d4d58fbd..8d1f5a1527f6 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "12.2.6-canary.13", + "version": "12.3.0", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -9,7 +9,7 @@ "directory": "packages/eslint-config-next" }, "dependencies": { - "@next/eslint-plugin-next": "12.2.6-canary.13", + "@next/eslint-plugin-next": "12.3.0", "@rushstack/eslint-patch": "^1.1.3", "@typescript-eslint/parser": "^5.21.0", "eslint-import-resolver-node": "^0.3.6", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index e96d8afecb8d..ae49513012ee 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "12.2.6-canary.13", + "version": "12.3.0", "description": "ESLint plugin for NextJS.", "main": "lib/index.js", "license": "MIT", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 39e26ee312a4..8e359412211d 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "12.2.6-canary.13", + "version": "12.3.0", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 4917d36e919c..7620d642f30f 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "12.2.6-canary.13", + "version": "12.3.0", "license": "MIT", "dependencies": { "chalk": "4.1.0", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index c6886bb1c817..e54b40ee6dfc 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "12.2.6-canary.13", + "version": "12.3.0", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index c6486435da59..edc6bc183a99 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "12.2.6-canary.13", + "version": "12.3.0", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 5ac9ab58f229..aa646820bcba 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "12.2.6-canary.13", + "version": "12.3.0", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index 445d1e498542..2c5ffae3a4e9 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "12.2.6-canary.13", + "version": "12.3.0", "description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)", "main": "dist/polyfill-module.js", "license": "MIT", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index 8d5544828b02..2393b3243d5e 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "12.2.6-canary.13", + "version": "12.3.0", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index b8ea7be2130d..0a3075d91e24 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "12.2.6-canary.13", + "version": "12.3.0", "private": true, "scripts": { "build-native": "napi build --platform -p next-swc-napi --cargo-name next_swc_napi native --features plugin", diff --git a/packages/next/package.json b/packages/next/package.json index 6437962bcf9d..310749e59a4a 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "12.2.6-canary.13", + "version": "12.3.0", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -70,7 +70,7 @@ ] }, "dependencies": { - "@next/env": "12.2.6-canary.13", + "@next/env": "12.3.0", "@swc/helpers": "0.4.11", "caniuse-lite": "^1.0.30001332", "postcss": "8.4.14", @@ -121,11 +121,11 @@ "@hapi/accept": "5.0.2", "@napi-rs/cli": "2.7.0", "@napi-rs/triples": "1.1.0", - "@next/polyfill-module": "12.2.6-canary.13", - "@next/polyfill-nomodule": "12.2.6-canary.13", - "@next/react-dev-overlay": "12.2.6-canary.13", - "@next/react-refresh-utils": "12.2.6-canary.13", - "@next/swc": "12.2.6-canary.13", + "@next/polyfill-module": "12.3.0", + "@next/polyfill-nomodule": "12.3.0", + "@next/react-dev-overlay": "12.3.0", + "@next/react-refresh-utils": "12.3.0", + "@next/swc": "12.3.0", "@segment/ajv-human-errors": "2.1.2", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index a1f96790dc5e..fcd9f37f6dcf 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "12.2.6-canary.13", + "version": "12.3.0", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index dd9ea6620338..ef30d2385de0 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "12.2.6-canary.13", + "version": "12.3.0", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0d6e4f010786..268f116d32d9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -363,7 +363,7 @@ importers: packages/eslint-config-next: specifiers: - '@next/eslint-plugin-next': 12.2.6-canary.13 + '@next/eslint-plugin-next': 12.3.0 '@rushstack/eslint-patch': ^1.1.3 '@typescript-eslint/parser': ^5.21.0 eslint-import-resolver-node: ^0.3.6 @@ -419,12 +419,12 @@ importers: '@hapi/accept': 5.0.2 '@napi-rs/cli': 2.7.0 '@napi-rs/triples': 1.1.0 - '@next/env': 12.2.6-canary.13 - '@next/polyfill-module': 12.2.6-canary.13 - '@next/polyfill-nomodule': 12.2.6-canary.13 - '@next/react-dev-overlay': 12.2.6-canary.13 - '@next/react-refresh-utils': 12.2.6-canary.13 - '@next/swc': 12.2.6-canary.13 + '@next/env': 12.3.0 + '@next/polyfill-module': 12.3.0 + '@next/polyfill-nomodule': 12.3.0 + '@next/react-dev-overlay': 12.3.0 + '@next/react-refresh-utils': 12.3.0 + '@next/swc': 12.3.0 '@segment/ajv-human-errors': 2.1.2 '@swc/helpers': 0.4.11 '@taskr/clear': 1.1.0 From c8d3fa6a77186ec7805261312b0ce406efd46d79 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Thu, 8 Sep 2022 20:10:32 +0200 Subject: [PATCH 26/69] Update react-server-dom-webpack (#40356) Bump `react-server-dom-webpack` for support of `experimental_use` API --- package.json | 4 +- ...bpack-writer.browser.development.server.js | 212 +++++++++++++++++- ...ck-writer.browser.production.min.server.js | 72 +++--- .../react-server-dom-webpack.development.js | 9 +- ...react-server-dom-webpack.production.min.js | 4 +- packages/next/package.json | 2 +- pnpm-lock.yaml | 34 +-- 7 files changed, 267 insertions(+), 70 deletions(-) diff --git a/package.json b/package.json index 5f5ac0dfcb40..758a6b8200af 100644 --- a/package.json +++ b/package.json @@ -177,8 +177,8 @@ "react-17": "npm:react@17.0.2", "react-dom": "18.2.0", "react-dom-17": "npm:react-dom@17.0.2", - "react-dom-exp": "npm:react-dom@0.0.0-experimental-0de3ddf56-20220825", - "react-exp": "npm:react@0.0.0-experimental-0de3ddf56-20220825", + "react-dom-exp": "npm:react-dom@0.0.0-experimental-7028ce745-20220907", + "react-exp": "npm:react@0.0.0-experimental-7028ce745-20220907", "react-ssr-prepass": "1.0.8", "react-virtualized": "9.22.3", "relay-compiler": "13.0.2", diff --git a/packages/next/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.development.server.js b/packages/next/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.development.server.js index a4dfaa018c81..b5e1d259afd5 100644 --- a/packages/next/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.development.server.js +++ b/packages/next/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.development.server.js @@ -894,18 +894,109 @@ function readContext(context) { return value; } +// Corresponds to ReactFiberWakeable module. Generally, changes to one module +// should be reflected in the other. +// TODO: Rename this module and the corresponding Fiber one to "Thenable" +// instead of "Wakeable". Or some other more appropriate name. +// TODO: Sparse arrays are bad for performance. +function createThenableState() { + // The ThenableState is created the first time a component suspends. If it + // suspends again, we'll reuse the same state. + return []; +} +function trackSuspendedWakeable(wakeable) { + // If this wakeable isn't already a thenable, turn it into one now. Then, + // when we resume the work loop, we can check if its status is + // still pending. + // TODO: Get rid of the Wakeable type? It's superseded by UntrackedThenable. + var thenable = wakeable; // We use an expando to track the status and result of a thenable so that we + // can synchronously unwrap the value. Think of this as an extension of the + // Promise API, or a custom interface that is a superset of Thenable. + // + // If the thenable doesn't have a status, set it to "pending" and attach + // a listener that will update its status and result when it resolves. + + switch (thenable.status) { + case 'pending': + // Since the status is already "pending", we can assume it will be updated + // when it resolves, either by React or something in userspace. + break; + + case 'fulfilled': + case 'rejected': + // A thenable that already resolved shouldn't have been thrown, so this is + // unexpected. Suggests a mistake in a userspace data library. Don't track + // this thenable, because if we keep trying it will likely infinite loop + // without ever resolving. + // TODO: Log a warning? + break; + + default: + { + // TODO: Only instrument the thenable if the status if not defined. If + // it's defined, but an unknown value, assume it's been instrumented by + // some custom userspace implementation. + var pendingThenable = thenable; + pendingThenable.status = 'pending'; + pendingThenable.then(function (fulfilledValue) { + if (thenable.status === 'pending') { + var fulfilledThenable = thenable; + fulfilledThenable.status = 'fulfilled'; + fulfilledThenable.value = fulfilledValue; + } + }, function (error) { + if (thenable.status === 'pending') { + var rejectedThenable = thenable; + rejectedThenable.status = 'rejected'; + rejectedThenable.reason = error; + } + }); + break; + } + } +} +function trackUsedThenable(thenableState, thenable, index) { + // This is only a separate function from trackSuspendedWakeable for symmetry + // with Fiber. + // TODO: Disallow throwing a thenable directly. It must go through `use` (or + // some equivalent for internal Suspense implementations). We can't do this in + // Fiber yet because it's a breaking change but we can do it in Server + // Components because Server Components aren't released yet. + thenableState[index] = thenable; +} +function getPreviouslyUsedThenableAtIndex(thenableState, index) { + if (thenableState !== null) { + var thenable = thenableState[index]; + + if (thenable !== undefined) { + return thenable; + } + } + + return null; +} + var currentRequest = null; +var thenableIndexCounter = 0; +var thenableState = null; function prepareToUseHooksForRequest(request) { currentRequest = request; } function resetHooksForRequest() { currentRequest = null; } +function prepareToUseHooksForComponent(prevThenableState) { + thenableIndexCounter = 0; + thenableState = prevThenableState; +} +function getThenableStateAfterSuspending() { + return thenableState; +} function readContext$1(context) { { if (context.$$typeof !== REACT_SERVER_CONTEXT_TYPE) { - error('Only ServerContext is supported in Flight'); + error('Only createServerContext is supported in Server Components.'); } if (currentCache === null) { @@ -958,7 +1049,8 @@ var Dispatcher = { }, useMemoCache: function (size) { return new Array(size); - } + }, + use: use }; function unsupportedHook() { @@ -990,6 +1082,80 @@ function useId() { return ':' + currentRequest.identifierPrefix + 'S' + id.toString(32) + ':'; } +function use(usable) { + if (usable !== null && typeof usable === 'object') { + if (typeof usable.then === 'function') { + // This is a thenable. + var thenable = usable; // Track the position of the thenable within this fiber. + + var index = thenableIndexCounter; + thenableIndexCounter += 1; + + switch (thenable.status) { + case 'fulfilled': + { + var fulfilledValue = thenable.value; + return fulfilledValue; + } + + case 'rejected': + { + var rejectedError = thenable.reason; + throw rejectedError; + } + + default: + { + var prevThenableAtIndex = getPreviouslyUsedThenableAtIndex(thenableState, index); + + if (prevThenableAtIndex !== null) { + switch (prevThenableAtIndex.status) { + case 'fulfilled': + { + var _fulfilledValue = prevThenableAtIndex.value; + return _fulfilledValue; + } + + case 'rejected': + { + var _rejectedError = prevThenableAtIndex.reason; + throw _rejectedError; + } + + default: + { + // The thenable still hasn't resolved. Suspend with the same + // thenable as last time to avoid redundant listeners. + throw prevThenableAtIndex; + } + } + } else { + // This is the first time something has been used at this index. + // Stash the thenable at the current index so we can reuse it during + // the next attempt. + if (thenableState === null) { + thenableState = createThenableState(); + } + + trackUsedThenable(thenableState, thenable, index); // Suspend. + // TODO: Throwing here is an implementation detail that allows us to + // unwind the call stack. But we shouldn't allow it to leak into + // userspace. Throw an opaque placeholder value instead of the + // actual thenable. If it doesn't get captured by the work loop, log + // a warning, because that means something in userspace must have + // caught it. + + throw thenable; + } + } + } + } + } // eslint-disable-next-line react-internal/safe-string-coercion + + + throw new Error('An unsupported type was passed to use(): ' + String(usable)); +} + var ContextRegistry = ReactSharedInternals.ContextRegistry; function getOrCreateServerContext(globalName) { if (!ContextRegistry[globalName]) { @@ -1051,7 +1217,7 @@ function createRootContext(reqContext) { var POP = {}; -function attemptResolveElement(type, key, ref, props) { +function attemptResolveElement(type, key, ref, props, prevThenableState) { if (ref !== null && ref !== undefined) { // When the ref moves to the regular props object this will implicitly // throw for functions. We could probably relax it to a DEV warning for other @@ -1066,6 +1232,7 @@ function attemptResolveElement(type, key, ref, props) { } // This is a server-side component. + prepareToUseHooksForComponent(prevThenableState); return type(props); } else if (typeof type === 'string') { // This is a host element. E.g. HTML. @@ -1094,18 +1261,19 @@ function attemptResolveElement(type, key, ref, props) { var payload = type._payload; var init = type._init; var wrappedType = init(payload); - return attemptResolveElement(wrappedType, key, ref, props); + return attemptResolveElement(wrappedType, key, ref, props, prevThenableState); } case REACT_FORWARD_REF_TYPE: { var render = type.render; + prepareToUseHooksForComponent(prevThenableState); return render(props, undefined); } case REACT_MEMO_TYPE: { - return attemptResolveElement(type.type, key, ref, props); + return attemptResolveElement(type.type, key, ref, props, prevThenableState); } case REACT_PROVIDER_TYPE: @@ -1159,7 +1327,8 @@ function createTask(request, model, context, abortSet) { context: context, ping: function () { return pingTask(request, task); - } + }, + thenableState: null }; abortSet.add(task); return task; @@ -1426,7 +1595,7 @@ function resolveModelToJSON(request, parent, key, value) { // TODO: Concatenate keys of parents onto children. var element = value; // Attempt to render the server component. - value = attemptResolveElement(element.type, element.key, element.ref, element.props); + value = attemptResolveElement(element.type, element.key, element.ref, element.props, null); break; } @@ -1445,6 +1614,9 @@ function resolveModelToJSON(request, parent, key, value) { var newTask = createTask(request, value, getActiveContext(), request.abortableTasks); var ping = newTask.ping; x.then(ping, ping); + var wakeable = x; + trackSuspendedWakeable(wakeable); + newTask.thenableState = getThenableStateAfterSuspending(); return serializeByRefID(newTask.id); } else { logRecoverableError(request, x); // Something errored. We'll still send everything we have up until this point. @@ -1625,14 +1797,29 @@ function retryTask(request, task) { try { var _value3 = task.model; - while (typeof _value3 === 'object' && _value3 !== null && _value3.$$typeof === REACT_ELEMENT_TYPE) { + if (typeof _value3 === 'object' && _value3 !== null && _value3.$$typeof === REACT_ELEMENT_TYPE) { // TODO: Concatenate keys of parents onto children. - var element = _value3; // Attempt to render the server component. + var element = _value3; // When retrying a component, reuse the thenableState from the + // previous attempt. + + var prevThenableState = task.thenableState; // Attempt to render the server component. // Doing this here lets us reuse this same task if the next component // also suspends. task.model = _value3; - _value3 = attemptResolveElement(element.type, element.key, element.ref, element.props); + _value3 = attemptResolveElement(element.type, element.key, element.ref, element.props, prevThenableState); // Successfully finished this component. We're going to keep rendering + // using the same task, but we reset its thenable state before continuing. + + task.thenableState = null; // Keep rendering and reuse the same task. This inner loop is separate + // from the render above because we don't need to reset the thenable state + // until the next time something suspends and retries. + + while (typeof _value3 === 'object' && _value3 !== null && _value3.$$typeof === REACT_ELEMENT_TYPE) { + // TODO: Concatenate keys of parents onto children. + var nextElement = _value3; + task.model = _value3; + _value3 = attemptResolveElement(nextElement.type, nextElement.key, nextElement.ref, nextElement.props, null); + } } var processedChunk = processModelChunk(request, task.id, _value3); @@ -1644,6 +1831,9 @@ function retryTask(request, task) { // Something suspended again, let's pick it back up later. var ping = task.ping; x.then(ping, ping); + var wakeable = x; + trackSuspendedWakeable(wakeable); + task.thenableState = getThenableStateAfterSuspending(); return; } else { request.abortableTasks.delete(task); @@ -1690,7 +1880,7 @@ function abortTask(task, request, errorId) { var ref = serializeByValueID(errorId); var processedChunk = processReferenceChunk(request, task.id, ref); - request.completedJSONChunks.push(processedChunk); + request.completedErrorChunks.push(processedChunk); } function flushCompletedChunks(request, destination) { diff --git a/packages/next/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.production.min.server.js b/packages/next/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.production.min.server.js index 95a6f04e34bb..892fa9bace9b 100644 --- a/packages/next/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.production.min.server.js +++ b/packages/next/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-writer.browser.production.min.server.js @@ -7,42 +7,44 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -'use strict';var e=require("react"),l=null,m=0;function n(a,c){if(0!==c.length)if(512
+ ) +} diff --git a/test/integration/preload-viewport/test/index.test.js b/test/integration/preload-viewport/test/index.test.js index b8aad8d5a45f..9f0e023ea54c 100644 --- a/test/integration/preload-viewport/test/index.test.js +++ b/test/integration/preload-viewport/test/index.test.js @@ -110,6 +110,38 @@ describe('Prefetching Links in viewport', () => { } }) + it('should prefetch with non-bot UA', async () => { + let browser + try { + browser = await webdriver( + appPort, + `/bot-user-agent?useragent=${encodeURIComponent( + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36' + )}` + ) + const links = await browser.elementsByCss('link[rel=prefetch]') + expect(links).toHaveLength(1) + } finally { + if (browser) await browser.close() + } + }) + + it('should not prefetch with bot UA', async () => { + let browser + try { + browser = await webdriver( + appPort, + `/bot-user-agent?useragent=${encodeURIComponent( + 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/W.X.Y.Z Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' + )}` + ) + const links = await browser.elementsByCss('link[rel=prefetch]') + expect(links).toHaveLength(0) + } finally { + if (browser) await browser.close() + } + }) + it('should prefetch rewritten href with link in viewport onload', async () => { let browser try { From 0a093c0e8275f3aa809dca5fd6b8a0a20f66b7ed Mon Sep 17 00:00:00 2001 From: Ryan Parker Date: Mon, 12 Sep 2022 17:44:43 -0700 Subject: [PATCH 56/69] docs(errors/large-page-data): how to see data being passed to page (#40491) ## Summary This PR adds a note about how to see the data that this error is complaining about: ```sh Warning: data for page "/" is xxx which exceeds the threshold of 128 kB, this amount of data can reduce performance. ``` This debug trick was something I came across in a [discussion](https://github.com/vercel/next.js/discussions/39880) and I thought it would be helpful to others like it was for me. ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com> --- errors/large-page-data.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/errors/large-page-data.md b/errors/large-page-data.md index 9969b380299e..6a195072f43f 100644 --- a/errors/large-page-data.md +++ b/errors/large-page-data.md @@ -8,6 +8,12 @@ One of your pages includes a large amount of page data (>= 128kB). This can nega Reduce the amount of data returned from `getStaticProps`, `getServerSideProps`, or `getInitialProps` to only the essential data to render the page. The default threshold of 128kB can be configured in `largePageDataBytes` if absolutely necessary and the performance implications are understood. +To inspect the props passed to your page, you can inspect the below element's content in your browser devtools: + +```sh +document.getElementById("__NEXT_DATA__").text +``` + ### Useful Links - [Data Fetching Documentation](https://nextjs.org/docs/basic-features/data-fetching/overview) From 3f2b4bc904f9704be7ada9891cf80cb1373f37fe Mon Sep 17 00:00:00 2001 From: Victor Boucher Date: Tue, 13 Sep 2022 03:06:58 +0200 Subject: [PATCH 57/69] docs(basic-features/script): update script version history (#40263) Made an addition to the version history within the Script component docs. In the docs there are examples where the Script component is being used within a _document.js/tsx file, but it does not get mentioned that this is only supported from version 12.2.2 onwards. ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` Co-authored-by: JJ Kasper --- docs/basic-features/script.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/basic-features/script.md b/docs/basic-features/script.md index 33df31800f43..0f92fad1c3d2 100644 --- a/docs/basic-features/script.md +++ b/docs/basic-features/script.md @@ -19,10 +19,11 @@ description: Next.js helps you optimize loading third-party scripts with the bui
Version History -| Version | Changes | -| --------- | ------------------------- | -| `v12.2.4` | `onReady` prop added. | -| `v11.0.0` | `next/script` introduced. | +| Version | Changes | +| --------- | ------------------------------------------------------------------------- | +| `v12.2.4` | `onReady` prop added. | +| `v12.2.2` | Allow `next/script` with `beforeInteractive` to be placed in `_document`. | +| `v11.0.0` | `next/script` introduced. |
From f33c23c1442357d2ec82ed0378ff336d64f4cdd4 Mon Sep 17 00:00:00 2001 From: Steven Tey Date: Mon, 12 Sep 2022 18:26:40 -0700 Subject: [PATCH 58/69] Added "negative matcher" documentation (#40282) ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) Co-authored-by: JJ Kasper --- docs/advanced-features/middleware.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/advanced-features/middleware.md b/docs/advanced-features/middleware.md index 3d2029b3ff93..7812da86b3aa 100644 --- a/docs/advanced-features/middleware.md +++ b/docs/advanced-features/middleware.md @@ -88,6 +88,22 @@ export const config = { } ``` +The `matcher` config allows full regex so matching like negative lookaheads or character matching is supported. An example of a negative lookahead to match all except specific paths can be seen here: + +```js +export const config = { + matcher: [ + /* + * Match all request paths except for the ones starting with: + * - api (API routes) + * - static (static files) + * - favicon.ico (favicon file) + */ + '/((?!api|static|favicon.ico).*)', + ], +} +``` + > **Note:** The `matcher` values need to be constants so they can be statically analyzed at build-time. Dynamic values such as variables will be ignored. Configured matchers: @@ -101,8 +117,6 @@ Read more details on [path-to-regexp](https://github.com/pillarjs/path-to-regexp > **Note:** For backward compatibility, Next.js always considers `/public` as `/public/index`. Therefore, a matcher of `/public/:path` will match. -> **Note:** It is not possible to exclude middleware from matching static path starting with `_next/`. This allow enforcing security with middleware. - ### Conditional Statements ```typescript From d0903a5c5be184f3656a9c8dc2f5c297cb280a4b Mon Sep 17 00:00:00 2001 From: JDansercoer Date: Tue, 13 Sep 2022 03:55:44 +0200 Subject: [PATCH 59/69] Update semver of eslint-plugin-react (#40246) `eslint-plugin-react` has a broken version between v7.31.2-6. Upping the version range ensure that only functioning packages get installed. Fixes #40245 ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com> --- packages/eslint-config-next/package.json | 2 +- packages/next/compiled/assert/assert.js | 4 +- packages/next/compiled/util/util.js | 2 +- pnpm-lock.yaml | 291 ++++++++++++++++++++--- 4 files changed, 265 insertions(+), 34 deletions(-) diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index c46b3c036089..ce5dd619aa38 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -16,7 +16,7 @@ "eslint-import-resolver-typescript": "^2.7.1", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.29.4", + "eslint-plugin-react": "^7.31.7", "eslint-plugin-react-hooks": "^4.5.0" }, "peerDependencies": { diff --git a/packages/next/compiled/assert/assert.js b/packages/next/compiled/assert/assert.js index 0f53af4925ad..7a6161991d9e 100644 --- a/packages/next/compiled/assert/assert.js +++ b/packages/next/compiled/assert/assert.js @@ -1,7 +1,7 @@ -(function(){var e={992:function(e){e.exports=function(e,r,n){if(e.filter)return e.filter(r,n);if(void 0===e||null===e)throw new TypeError;if("function"!=typeof r)throw new TypeError;var o=[];for(var i=0;i1?t-1:0),n=1;n1?t-1:0),n=1;n1?t-1:0),n=1;n1?t-1:0),n=1;ne.length){r=e.length}return e.substring(r-t.length,r)===t}function repeat(e,t){t=Math.floor(t);if(e.length==0||t==0)return"";var r=e.length*t;t=Math.floor(Math.log(t)/Math.log(2));while(t){e+=e;t--}e+=e.substring(0,r-e.length);return e}var c="";var u="";var f="";var s="";var l={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"};var p=10;function copyError(e){var t=Object.keys(e);var r=Object.create(Object.getPrototypeOf(e));t.forEach((function(t){r[t]=e[t]}));Object.defineProperty(r,"message",{value:e.message});return r}function inspectValue(e){return o(e,{compact:false,customInspect:false,depth:1e3,maxArrayLength:Infinity,showHidden:false,breakLength:Infinity,showProxy:false,sorted:true,getters:true})}function createErrDiff(e,t,r){var n="";var o="";var i=0;var a="";var y=false;var g=inspectValue(e);var v=g.split("\n");var d=inspectValue(t).split("\n");var b=0;var h="";if(r==="strictEqual"&&_typeof(e)==="object"&&_typeof(t)==="object"&&e!==null&&t!==null){r="strictEqualObject"}if(v.length===1&&d.length===1&&v[0]!==d[0]){var m=v[0].length+d[0].length;if(m<=p){if((_typeof(e)!=="object"||e===null)&&(_typeof(t)!=="object"||t===null)&&(e!==0||t!==0)){return"".concat(l[r],"\n\n")+"".concat(v[0]," !== ").concat(d[0],"\n")}}else if(r!=="strictEqualObject"){var S=process.stderr&&process.stderr.isTTY?process.stderr.columns:80;if(m2){h="\n ".concat(repeat(" ",b),"^");b=0}}}}var E=v[v.length-1];var O=d[d.length-1];while(E===O){if(b++<2){a="\n ".concat(E).concat(a)}else{n=E}v.pop();d.pop();if(v.length===0||d.length===0)break;E=v[v.length-1];O=d[d.length-1]}var A=Math.max(v.length,d.length);if(A===0){var w=g.split("\n");if(w.length>30){w[26]="".concat(c,"...").concat(s);while(w.length>27){w.pop()}}return"".concat(l.notIdentical,"\n\n").concat(w.join("\n"),"\n")}if(b>3){a="\n".concat(c,"...").concat(s).concat(a);y=true}if(n!==""){a="\n ".concat(n).concat(a);n=""}var j=0;var _=l[r]+"\n".concat(u,"+ actual").concat(s," ").concat(f,"- expected").concat(s);var P=" ".concat(c,"...").concat(s," Lines skipped");for(b=0;b1&&b>2){if(x>4){o+="\n".concat(c,"...").concat(s);y=true}else if(x>3){o+="\n ".concat(d[b-2]);j++}o+="\n ".concat(d[b-1]);j++}i=b;n+="\n".concat(f,"-").concat(s," ").concat(d[b]);j++}else if(d.length1&&b>2){if(x>4){o+="\n".concat(c,"...").concat(s);y=true}else if(x>3){o+="\n ".concat(v[b-2]);j++}o+="\n ".concat(v[b-1]);j++}i=b;o+="\n".concat(u,"+").concat(s," ").concat(v[b]);j++}else{var k=d[b];var T=v[b];var I=T!==k&&(!endsWith(T,",")||T.slice(0,-1)!==k);if(I&&endsWith(k,",")&&k.slice(0,-1)===T){I=false;T+=","}if(I){if(x>1&&b>2){if(x>4){o+="\n".concat(c,"...").concat(s);y=true}else if(x>3){o+="\n ".concat(v[b-2]);j++}o+="\n ".concat(v[b-1]);j++}i=b;o+="\n".concat(u,"+").concat(s," ").concat(T);n+="\n".concat(f,"-").concat(s," ").concat(k);j+=2}else{o+=n;n="";if(x===1||b===0){o+="\n ".concat(T);j++}}}if(j>20&&b30){v[26]="".concat(c,"...").concat(s);while(v.length>27){v.pop()}}if(v.length===1){t=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError).call(this,"".concat(g," ").concat(v[0])))}else{t=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError).call(this,"".concat(g,"\n\n").concat(v.join("\n"),"\n")))}}else{var d=inspectValue(i);var b="";var h=l[n];if(n==="notDeepEqual"||n==="notEqual"){d="".concat(l[n],"\n\n").concat(d);if(d.length>1024){d="".concat(d.slice(0,1021),"...")}}else{b="".concat(inspectValue(p));if(d.length>512){d="".concat(d.slice(0,509),"...")}if(b.length>512){b="".concat(b.slice(0,509),"...")}if(n==="deepEqual"||n==="equal"){d="".concat(h,"\n\n").concat(d,"\n\nshould equal\n\n")}else{b=" ".concat(n," ").concat(b)}}t=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError).call(this,"".concat(d).concat(b)))}}Error.stackTraceLimit=y;t.generatedMessage=!r;Object.defineProperty(_assertThisInitialized(t),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:false,writable:true,configurable:true});t.code="ERR_ASSERTION";t.actual=i;t.expected=p;t.operator=n;if(Error.captureStackTrace){Error.captureStackTrace(_assertThisInitialized(t),o)}t.stack;t.name="AssertionError";return _possibleConstructorReturn(t)}_createClass(AssertionError,[{key:"toString",value:function toString(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:o.custom,value:function value(e,t){return o(this,_objectSpread({},t,{customInspect:false,depth:0}))}}]);return AssertionError}(_wrapNativeSuper(Error));e.exports=y},23:function(e,t,r){"use strict";function _typeof(e){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(e){return typeof e}}else{_typeof=function _typeof(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}}return _typeof(e)}function _classCallCheck(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(e,t){if(t&&(_typeof(t)==="object"||typeof t==="function")){return t}return _assertThisInitialized(e)}function _assertThisInitialized(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function _getPrototypeOf(e){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)};return _getPrototypeOf(e)}function _inherits(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});if(t)_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(e,t){e.__proto__=t;return e};return _setPrototypeOf(e,t)}var n={};var o;var i;function createErrorType(e,t,r){if(!r){r=Error}function getMessage(e,r,n){if(typeof t==="string"){return t}else{return t(e,r,n)}}var o=function(t){_inherits(NodeError,t);function NodeError(t,r,n){var o;_classCallCheck(this,NodeError);o=_possibleConstructorReturn(this,_getPrototypeOf(NodeError).call(this,getMessage(t,r,n)));o.code=e;return o}return NodeError}(r);n[e]=o}function oneOf(e,t){if(Array.isArray(e)){var r=e.length;e=e.map((function(e){return String(e)}));if(r>2){return"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]}else if(r===2){return"one of ".concat(t," ").concat(e[0]," or ").concat(e[1])}else{return"of ".concat(t," ").concat(e[0])}}else{return"of ".concat(t," ").concat(String(e))}}function startsWith(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function endsWith(e,t,r){if(r===undefined||r>e.length){r=e.length}return e.substring(r-t.length,r)===t}function includes(e,t,r){if(typeof r!=="number"){r=0}if(r+t.length>e.length){return false}else{return e.indexOf(t,r)!==-1}}createErrorType("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);createErrorType("ERR_INVALID_ARG_TYPE",(function(e,t,n){if(o===undefined)o=r(167);o(typeof e==="string","'name' must be a string");var i;if(typeof t==="string"&&startsWith(t,"not ")){i="must not be";t=t.replace(/^not /,"")}else{i="must be"}var a;if(endsWith(e," argument")){a="The ".concat(e," ").concat(i," ").concat(oneOf(t,"type"))}else{var c=includes(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(c," ").concat(i," ").concat(oneOf(t,"type"))}a+=". Received type ".concat(_typeof(n));return a}),TypeError);createErrorType("ERR_INVALID_ARG_VALUE",(function(e,t){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"is invalid";if(i===undefined)i=r(177);var o=i.inspect(t);if(o.length>128){o="".concat(o.slice(0,128),"...")}return"The argument '".concat(e,"' ").concat(n,". Received ").concat(o)}),TypeError,RangeError);createErrorType("ERR_INVALID_RETURN_VALUE",(function(e,t,r){var n;if(r&&r.constructor&&r.constructor.name){n="instance of ".concat(r.constructor.name)}else{n="type ".concat(_typeof(r))}return"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(n,".")}),TypeError);createErrorType("ERR_MISSING_ARGS",(function(){for(var e=arguments.length,t=new Array(e),n=0;n0,"At least one arg needs to be specified");var i="The ";var a=t.length;t=t.map((function(e){return'"'.concat(e,'"')}));switch(a){case 1:i+="".concat(t[0]," argument");break;case 2:i+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:i+=t.slice(0,a-1).join(", ");i+=", and ".concat(t[a-1]," arguments");break}return"".concat(i," must be specified")}),TypeError);e.exports.codes=n},176:function(e,t,r){"use strict";function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(e,t){var r=[];var n=true;var o=false;var i=undefined;try{for(var a=e[Symbol.iterator](),c;!(n=(c=a.next()).done);n=true){r.push(c.value);if(t&&r.length===t)break}}catch(e){o=true;i=e}finally{try{if(!n&&a["return"]!=null)a["return"]()}finally{if(o)throw i}}return r}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _typeof(e){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(e){return typeof e}}else{_typeof=function _typeof(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}}return _typeof(e)}var n=/a/g.flags!==undefined;var o=function arrayFromSet(e){var t=[];e.forEach((function(e){return t.push(e)}));return t};var i=function arrayFromMap(e){var t=[];e.forEach((function(e,r){return t.push([r,e])}));return t};var a=Object.is?Object.is:r(208);var c=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]};var u=Number.isNaN?Number.isNaN:r(718);function uncurryThis(e){return e.call.bind(e)}var f=uncurryThis(Object.prototype.hasOwnProperty);var s=uncurryThis(Object.prototype.propertyIsEnumerable);var l=uncurryThis(Object.prototype.toString);var p=r(177).types,y=p.isAnyArrayBuffer,g=p.isArrayBufferView,v=p.isDate,d=p.isMap,b=p.isRegExp,h=p.isSet,m=p.isNativeError,S=p.isBoxedPrimitive,E=p.isNumberObject,O=p.isStringObject,A=p.isBooleanObject,w=p.isBigIntObject,j=p.isSymbolObject,_=p.isFloat32Array,P=p.isFloat64Array;function isNonIndex(e){if(e.length===0||e.length>10)return true;for(var t=0;t57)return true}return e.length===10&&e>=Math.pow(2,32)}function getOwnNonIndexProperties(e){return Object.keys(e).filter(isNonIndex).concat(c(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))} +(function(){var e={992:function(e){e.exports=function(e,r,n){if(e.filter)return e.filter(r,n);if(void 0===e||null===e)throw new TypeError;if("function"!=typeof r)throw new TypeError;var o=[];for(var i=0;i1?t-1:0),n=1;n1?t-1:0),n=1;n1?t-1:0),n=1;n1?t-1:0),n=1;ne.length){r=e.length}return e.substring(r-t.length,r)===t}function repeat(e,t){t=Math.floor(t);if(e.length==0||t==0)return"";var r=e.length*t;t=Math.floor(Math.log(t)/Math.log(2));while(t){e+=e;t--}e+=e.substring(0,r-e.length);return e}var c="";var u="";var f="";var s="";var l={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"};var p=10;function copyError(e){var t=Object.keys(e);var r=Object.create(Object.getPrototypeOf(e));t.forEach((function(t){r[t]=e[t]}));Object.defineProperty(r,"message",{value:e.message});return r}function inspectValue(e){return o(e,{compact:false,customInspect:false,depth:1e3,maxArrayLength:Infinity,showHidden:false,breakLength:Infinity,showProxy:false,sorted:true,getters:true})}function createErrDiff(e,t,r){var n="";var o="";var i=0;var a="";var y=false;var g=inspectValue(e);var v=g.split("\n");var d=inspectValue(t).split("\n");var b=0;var h="";if(r==="strictEqual"&&_typeof(e)==="object"&&_typeof(t)==="object"&&e!==null&&t!==null){r="strictEqualObject"}if(v.length===1&&d.length===1&&v[0]!==d[0]){var m=v[0].length+d[0].length;if(m<=p){if((_typeof(e)!=="object"||e===null)&&(_typeof(t)!=="object"||t===null)&&(e!==0||t!==0)){return"".concat(l[r],"\n\n")+"".concat(v[0]," !== ").concat(d[0],"\n")}}else if(r!=="strictEqualObject"){var S=process.stderr&&process.stderr.isTTY?process.stderr.columns:80;if(m2){h="\n ".concat(repeat(" ",b),"^");b=0}}}}var E=v[v.length-1];var O=d[d.length-1];while(E===O){if(b++<2){a="\n ".concat(E).concat(a)}else{n=E}v.pop();d.pop();if(v.length===0||d.length===0)break;E=v[v.length-1];O=d[d.length-1]}var w=Math.max(v.length,d.length);if(w===0){var A=g.split("\n");if(A.length>30){A[26]="".concat(c,"...").concat(s);while(A.length>27){A.pop()}}return"".concat(l.notIdentical,"\n\n").concat(A.join("\n"),"\n")}if(b>3){a="\n".concat(c,"...").concat(s).concat(a);y=true}if(n!==""){a="\n ".concat(n).concat(a);n=""}var j=0;var P=l[r]+"\n".concat(u,"+ actual").concat(s," ").concat(f,"- expected").concat(s);var _=" ".concat(c,"...").concat(s," Lines skipped");for(b=0;b1&&b>2){if(x>4){o+="\n".concat(c,"...").concat(s);y=true}else if(x>3){o+="\n ".concat(d[b-2]);j++}o+="\n ".concat(d[b-1]);j++}i=b;n+="\n".concat(f,"-").concat(s," ").concat(d[b]);j++}else if(d.length1&&b>2){if(x>4){o+="\n".concat(c,"...").concat(s);y=true}else if(x>3){o+="\n ".concat(v[b-2]);j++}o+="\n ".concat(v[b-1]);j++}i=b;o+="\n".concat(u,"+").concat(s," ").concat(v[b]);j++}else{var k=d[b];var T=v[b];var I=T!==k&&(!endsWith(T,",")||T.slice(0,-1)!==k);if(I&&endsWith(k,",")&&k.slice(0,-1)===T){I=false;T+=","}if(I){if(x>1&&b>2){if(x>4){o+="\n".concat(c,"...").concat(s);y=true}else if(x>3){o+="\n ".concat(v[b-2]);j++}o+="\n ".concat(v[b-1]);j++}i=b;o+="\n".concat(u,"+").concat(s," ").concat(T);n+="\n".concat(f,"-").concat(s," ").concat(k);j+=2}else{o+=n;n="";if(x===1||b===0){o+="\n ".concat(T);j++}}}if(j>20&&b30){v[26]="".concat(c,"...").concat(s);while(v.length>27){v.pop()}}if(v.length===1){t=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError).call(this,"".concat(g," ").concat(v[0])))}else{t=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError).call(this,"".concat(g,"\n\n").concat(v.join("\n"),"\n")))}}else{var d=inspectValue(i);var b="";var h=l[n];if(n==="notDeepEqual"||n==="notEqual"){d="".concat(l[n],"\n\n").concat(d);if(d.length>1024){d="".concat(d.slice(0,1021),"...")}}else{b="".concat(inspectValue(p));if(d.length>512){d="".concat(d.slice(0,509),"...")}if(b.length>512){b="".concat(b.slice(0,509),"...")}if(n==="deepEqual"||n==="equal"){d="".concat(h,"\n\n").concat(d,"\n\nshould equal\n\n")}else{b=" ".concat(n," ").concat(b)}}t=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError).call(this,"".concat(d).concat(b)))}}Error.stackTraceLimit=y;t.generatedMessage=!r;Object.defineProperty(_assertThisInitialized(t),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:false,writable:true,configurable:true});t.code="ERR_ASSERTION";t.actual=i;t.expected=p;t.operator=n;if(Error.captureStackTrace){Error.captureStackTrace(_assertThisInitialized(t),o)}t.stack;t.name="AssertionError";return _possibleConstructorReturn(t)}_createClass(AssertionError,[{key:"toString",value:function toString(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:o.custom,value:function value(e,t){return o(this,_objectSpread({},t,{customInspect:false,depth:0}))}}]);return AssertionError}(_wrapNativeSuper(Error));e.exports=y},23:function(e,t,r){"use strict";function _typeof(e){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(e){return typeof e}}else{_typeof=function _typeof(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}}return _typeof(e)}function _classCallCheck(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(e,t){if(t&&(_typeof(t)==="object"||typeof t==="function")){return t}return _assertThisInitialized(e)}function _assertThisInitialized(e){if(e===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return e}function _getPrototypeOf(e){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)};return _getPrototypeOf(e)}function _inherits(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function")}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}});if(t)_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(e,t){e.__proto__=t;return e};return _setPrototypeOf(e,t)}var n={};var o;var i;function createErrorType(e,t,r){if(!r){r=Error}function getMessage(e,r,n){if(typeof t==="string"){return t}else{return t(e,r,n)}}var o=function(t){_inherits(NodeError,t);function NodeError(t,r,n){var o;_classCallCheck(this,NodeError);o=_possibleConstructorReturn(this,_getPrototypeOf(NodeError).call(this,getMessage(t,r,n)));o.code=e;return o}return NodeError}(r);n[e]=o}function oneOf(e,t){if(Array.isArray(e)){var r=e.length;e=e.map((function(e){return String(e)}));if(r>2){return"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]}else if(r===2){return"one of ".concat(t," ").concat(e[0]," or ").concat(e[1])}else{return"of ".concat(t," ").concat(e[0])}}else{return"of ".concat(t," ").concat(String(e))}}function startsWith(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function endsWith(e,t,r){if(r===undefined||r>e.length){r=e.length}return e.substring(r-t.length,r)===t}function includes(e,t,r){if(typeof r!=="number"){r=0}if(r+t.length>e.length){return false}else{return e.indexOf(t,r)!==-1}}createErrorType("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError);createErrorType("ERR_INVALID_ARG_TYPE",(function(e,t,n){if(o===undefined)o=r(167);o(typeof e==="string","'name' must be a string");var i;if(typeof t==="string"&&startsWith(t,"not ")){i="must not be";t=t.replace(/^not /,"")}else{i="must be"}var a;if(endsWith(e," argument")){a="The ".concat(e," ").concat(i," ").concat(oneOf(t,"type"))}else{var c=includes(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(c," ").concat(i," ").concat(oneOf(t,"type"))}a+=". Received type ".concat(_typeof(n));return a}),TypeError);createErrorType("ERR_INVALID_ARG_VALUE",(function(e,t){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"is invalid";if(i===undefined)i=r(177);var o=i.inspect(t);if(o.length>128){o="".concat(o.slice(0,128),"...")}return"The argument '".concat(e,"' ").concat(n,". Received ").concat(o)}),TypeError,RangeError);createErrorType("ERR_INVALID_RETURN_VALUE",(function(e,t,r){var n;if(r&&r.constructor&&r.constructor.name){n="instance of ".concat(r.constructor.name)}else{n="type ".concat(_typeof(r))}return"Expected ".concat(e,' to be returned from the "').concat(t,'"')+" function but got ".concat(n,".")}),TypeError);createErrorType("ERR_MISSING_ARGS",(function(){for(var e=arguments.length,t=new Array(e),n=0;n0,"At least one arg needs to be specified");var i="The ";var a=t.length;t=t.map((function(e){return'"'.concat(e,'"')}));switch(a){case 1:i+="".concat(t[0]," argument");break;case 2:i+="".concat(t[0]," and ").concat(t[1]," arguments");break;default:i+=t.slice(0,a-1).join(", ");i+=", and ".concat(t[a-1]," arguments");break}return"".concat(i," must be specified")}),TypeError);e.exports.codes=n},176:function(e,t,r){"use strict";function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(e,t){var r=[];var n=true;var o=false;var i=undefined;try{for(var a=e[Symbol.iterator](),c;!(n=(c=a.next()).done);n=true){r.push(c.value);if(t&&r.length===t)break}}catch(e){o=true;i=e}finally{try{if(!n&&a["return"]!=null)a["return"]()}finally{if(o)throw i}}return r}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _typeof(e){if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(e){return typeof e}}else{_typeof=function _typeof(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}}return _typeof(e)}var n=/a/g.flags!==undefined;var o=function arrayFromSet(e){var t=[];e.forEach((function(e){return t.push(e)}));return t};var i=function arrayFromMap(e){var t=[];e.forEach((function(e,r){return t.push([r,e])}));return t};var a=Object.is?Object.is:r(208);var c=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]};var u=Number.isNaN?Number.isNaN:r(718);function uncurryThis(e){return e.call.bind(e)}var f=uncurryThis(Object.prototype.hasOwnProperty);var s=uncurryThis(Object.prototype.propertyIsEnumerable);var l=uncurryThis(Object.prototype.toString);var p=r(177).types,y=p.isAnyArrayBuffer,g=p.isArrayBufferView,v=p.isDate,d=p.isMap,b=p.isRegExp,h=p.isSet,m=p.isNativeError,S=p.isBoxedPrimitive,E=p.isNumberObject,O=p.isStringObject,w=p.isBooleanObject,A=p.isBigIntObject,j=p.isSymbolObject,P=p.isFloat32Array,_=p.isFloat64Array;function isNonIndex(e){if(e.length===0||e.length>10)return true;for(var t=0;t57)return true}return e.length===10&&e>=Math.pow(2,32)}function getOwnNonIndexProperties(e){return Object.keys(e).filter(isNonIndex).concat(c(e).filter(Object.prototype.propertyIsEnumerable.bind(e)))} /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT - */function compare(e,t){if(e===t){return 0}var r=e.length;var n=t.length;for(var o=0,i=Math.min(r,n);o-1){return o(r)}return r}},139:function(e,t,r){"use strict";var n=r(174);var o=r(838);var i=o("%Function.prototype.apply%");var a=o("%Function.prototype.call%");var c=o("%Reflect.apply%",true)||n.call(a,i);var u=o("%Object.getOwnPropertyDescriptor%",true);var f=o("%Object.defineProperty%",true);var s=o("%Math.max%");if(f){try{f({},"a",{value:1})}catch(e){f=null}}e.exports=function callBind(e){var t=c(n,a,arguments);if(u&&f){var r=u(t,"length");if(r.configurable){f(t,"length",{value:1+s(0,e.length-(arguments.length-1))})}}return t};var l=function applyBind(){return c(n,i,arguments)};if(f){f(e.exports,"apply",{value:l})}else{e.exports.apply=l}},69:function(e,t,r){"use strict";var n=r(935);var o=typeof Symbol==="function"&&typeof Symbol("foo")==="symbol";var i=Object.prototype.toString;var a=Array.prototype.concat;var c=Object.defineProperty;var isFunction=function(e){return typeof e==="function"&&i.call(e)==="[object Function]"};var arePropertyDescriptorsSupported=function(){var e={};try{c(e,"x",{enumerable:false,value:e});for(var t in e){return false}return e.x===e}catch(e){return false}};var u=c&&arePropertyDescriptorsSupported();var defineProperty=function(e,t,r,n){if(t in e&&(!isFunction(n)||!n())){return}if(u){c(e,t,{configurable:true,enumerable:false,value:r,writable:true})}else{e[t]=r}};var defineProperties=function(e,t){var r=arguments.length>2?arguments[2]:{};var i=n(t);if(o){i=a.call(i,Object.getOwnPropertySymbols(t))}for(var c=0;c1&&typeof t!=="boolean"){throw new a('"allowMissing" argument must be a boolean')}var r=w(e);var i=r.length>0?r[0]:"";var u=j("%"+i+"%",t);var f=u.name;var s=u.value;var l=false;var p=u.alias;if(p){i=p[0];m(r,h([0,1],p))}for(var g=1,v=true;g=r.length){var A=c(s,d);v=!!A;if(v&&"get"in A&&!("originalValue"in A.get)){s=A.get}else{s=s[d]}}else{v=b(s,d);s=s[d]}if(v&&!l){y[f]=s}}}return s}},942:function(e,t,r){"use strict";var n=typeof Symbol!=="undefined"&&Symbol;var o=r(773);e.exports=function hasNativeSymbols(){if(typeof n!=="function"){return false}if(typeof Symbol!=="function"){return false}if(typeof n("foo")!=="symbol"){return false}if(typeof Symbol("bar")!=="symbol"){return false}return o()}},773:function(e){"use strict";e.exports=function hasSymbols(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function"){return false}if(typeof Symbol.iterator==="symbol"){return true}var e={};var t=Symbol("test");var r=Object(t);if(typeof t==="string"){return false}if(Object.prototype.toString.call(t)!=="[object Symbol]"){return false}if(Object.prototype.toString.call(r)!=="[object Symbol]"){return false}var n=42;e[t]=n;for(t in e){return false}if(typeof Object.keys==="function"&&Object.keys(e).length!==0){return false}if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(e).length!==0){return false}var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==t){return false}if(!Object.prototype.propertyIsEnumerable.call(e,t)){return false}if(typeof Object.getOwnPropertyDescriptor==="function"){var i=Object.getOwnPropertyDescriptor(e,t);if(i.value!==n||i.enumerable!==true){return false}}return true}},101:function(e,t,r){"use strict";var n=r(174);e.exports=n.call(Function.call,Object.prototype.hasOwnProperty)},782:function(e){if(typeof Object.create==="function"){e.exports=function inherits(e,t){if(t){e.super_=t;e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}}}else{e.exports=function inherits(e,t){if(t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype;e.prototype=new TempCtor;e.prototype.constructor=e}}}},157:function(e){"use strict";var t=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var r=Object.prototype.toString;var n=function isArguments(e){if(t&&e&&typeof e==="object"&&Symbol.toStringTag in e){return false}return r.call(e)==="[object Arguments]"};var o=function isArguments(e){if(n(e)){return true}return e!==null&&typeof e==="object"&&typeof e.length==="number"&&e.length>=0&&r.call(e)!=="[object Array]"&&r.call(e.callee)==="[object Function]"};var i=function(){return n(arguments)}();n.isLegacyArguments=o;e.exports=i?n:o},391:function(e){"use strict";var t=Object.prototype.toString;var r=Function.prototype.toString;var n=/^\s*(?:function)?\*/;var o=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var i=Object.getPrototypeOf;var getGeneratorFunc=function(){if(!o){return false}try{return Function("return function*() {}")()}catch(e){}};var a=getGeneratorFunc();var c=a?i(a):{};e.exports=function isGeneratorFunction(e){if(typeof e!=="function"){return false}if(n.test(r.call(e))){return true}if(!o){var a=t.call(e);return a==="[object GeneratorFunction]"}return i(e)===c}},460:function(e){"use strict";e.exports=function isNaN(e){return e!==e}},718:function(e,t,r){"use strict";var n=r(139);var o=r(69);var i=r(460);var a=r(625);var c=r(171);var u=n(a(),Number);o(u,{getPolyfill:a,implementation:i,shim:c});e.exports=u},625:function(e,t,r){"use strict";var n=r(460);e.exports=function getPolyfill(){if(Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")){return Number.isNaN}return n}},171:function(e,t,r){"use strict";var n=r(69);var o=r(625);e.exports=function shimNumberIsNaN(){var e=o();n(Number,{isNaN:e},{isNaN:function testIsNaN(){return Number.isNaN!==e}});return e}},994:function(e,t,r){"use strict";var n=r(144);var o=r(349);var i=r(256);var a=i("Object.prototype.toString");var c=r(942)();var u=c&&typeof Symbol.toStringTag==="symbol";var f=o();var s=i("Array.prototype.indexOf",true)||function indexOf(e,t){for(var r=0;r-1}if(!y){return false}return v(e)}},208:function(e){"use strict";var numberIsNaN=function(e){return e!==e};e.exports=function is(e,t){if(e===0&&t===0){return 1/e===1/t}if(e===t){return true}if(numberIsNaN(e)&&numberIsNaN(t)){return true}return false}},579:function(e,t,r){"use strict";var n;if(!Object.keys){var o=Object.prototype.hasOwnProperty;var i=Object.prototype.toString;var a=r(412);var c=Object.prototype.propertyIsEnumerable;var u=!c.call({toString:null},"toString");var f=c.call((function(){}),"prototype");var s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"];var equalsConstructorPrototype=function(e){var t=e.constructor;return t&&t.prototype===e};var l={$applicationCache:true,$console:true,$external:true,$frame:true,$frameElement:true,$frames:true,$innerHeight:true,$innerWidth:true,$onmozfullscreenchange:true,$onmozfullscreenerror:true,$outerHeight:true,$outerWidth:true,$pageXOffset:true,$pageYOffset:true,$parent:true,$scrollLeft:true,$scrollTop:true,$scrollX:true,$scrollY:true,$self:true,$webkitIndexedDB:true,$webkitStorageInfo:true,$window:true};var p=function(){if(typeof window==="undefined"){return false}for(var e in window){try{if(!l["$"+e]&&o.call(window,e)&&window[e]!==null&&typeof window[e]==="object"){try{equalsConstructorPrototype(window[e])}catch(e){return true}}}catch(e){return true}}return false}();var equalsConstructorPrototypeIfNotBuggy=function(e){if(typeof window==="undefined"||!p){return equalsConstructorPrototype(e)}try{return equalsConstructorPrototype(e)}catch(e){return false}};n=function keys(e){var t=e!==null&&typeof e==="object";var r=i.call(e)==="[object Function]";var n=a(e);var c=t&&i.call(e)==="[object String]";var l=[];if(!t&&!r&&!n){throw new TypeError("Object.keys called on a non-object")}var p=f&&r;if(c&&e.length>0&&!o.call(e,0)){for(var y=0;y0){for(var g=0;g=0&&t.call(e.callee)==="[object Function]"}return n}},369:function(e){e.exports=function isBuffer(e){return e instanceof Buffer}},584:function(e,t,r){"use strict";var n=r(157);var o=r(391);var i=r(490);var a=r(994);function uncurryThis(e){return e.call.bind(e)}var c=typeof BigInt!=="undefined";var u=typeof Symbol!=="undefined";var f=uncurryThis(Object.prototype.toString);var s=uncurryThis(Number.prototype.valueOf);var l=uncurryThis(String.prototype.valueOf);var p=uncurryThis(Boolean.prototype.valueOf);if(c){var y=uncurryThis(BigInt.prototype.valueOf)}if(u){var g=uncurryThis(Symbol.prototype.valueOf)}function checkBoxedPrimitive(e,t){if(typeof e!=="object"){return false}try{t(e);return true}catch(e){return false}}t.isArgumentsObject=n;t.isGeneratorFunction=o;t.isTypedArray=a;function isPromise(e){return typeof Promise!=="undefined"&&e instanceof Promise||e!==null&&typeof e==="object"&&typeof e.then==="function"&&typeof e.catch==="function"}t.isPromise=isPromise;function isArrayBufferView(e){if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){return ArrayBuffer.isView(e)}return a(e)||isDataView(e)}t.isArrayBufferView=isArrayBufferView;function isUint8Array(e){return i(e)==="Uint8Array"}t.isUint8Array=isUint8Array;function isUint8ClampedArray(e){return i(e)==="Uint8ClampedArray"}t.isUint8ClampedArray=isUint8ClampedArray;function isUint16Array(e){return i(e)==="Uint16Array"}t.isUint16Array=isUint16Array;function isUint32Array(e){return i(e)==="Uint32Array"}t.isUint32Array=isUint32Array;function isInt8Array(e){return i(e)==="Int8Array"}t.isInt8Array=isInt8Array;function isInt16Array(e){return i(e)==="Int16Array"}t.isInt16Array=isInt16Array;function isInt32Array(e){return i(e)==="Int32Array"}t.isInt32Array=isInt32Array;function isFloat32Array(e){return i(e)==="Float32Array"}t.isFloat32Array=isFloat32Array;function isFloat64Array(e){return i(e)==="Float64Array"}t.isFloat64Array=isFloat64Array;function isBigInt64Array(e){return i(e)==="BigInt64Array"}t.isBigInt64Array=isBigInt64Array;function isBigUint64Array(e){return i(e)==="BigUint64Array"}t.isBigUint64Array=isBigUint64Array;function isMapToString(e){return f(e)==="[object Map]"}isMapToString.working=typeof Map!=="undefined"&&isMapToString(new Map);function isMap(e){if(typeof Map==="undefined"){return false}return isMapToString.working?isMapToString(e):e instanceof Map}t.isMap=isMap;function isSetToString(e){return f(e)==="[object Set]"}isSetToString.working=typeof Set!=="undefined"&&isSetToString(new Set);function isSet(e){if(typeof Set==="undefined"){return false}return isSetToString.working?isSetToString(e):e instanceof Set}t.isSet=isSet;function isWeakMapToString(e){return f(e)==="[object WeakMap]"}isWeakMapToString.working=typeof WeakMap!=="undefined"&&isWeakMapToString(new WeakMap);function isWeakMap(e){if(typeof WeakMap==="undefined"){return false}return isWeakMapToString.working?isWeakMapToString(e):e instanceof WeakMap}t.isWeakMap=isWeakMap;function isWeakSetToString(e){return f(e)==="[object WeakSet]"}isWeakSetToString.working=typeof WeakSet!=="undefined"&&isWeakSetToString(new WeakSet);function isWeakSet(e){return isWeakSetToString(e)}t.isWeakSet=isWeakSet;function isArrayBufferToString(e){return f(e)==="[object ArrayBuffer]"}isArrayBufferToString.working=typeof ArrayBuffer!=="undefined"&&isArrayBufferToString(new ArrayBuffer);function isArrayBuffer(e){if(typeof ArrayBuffer==="undefined"){return false}return isArrayBufferToString.working?isArrayBufferToString(e):e instanceof ArrayBuffer}t.isArrayBuffer=isArrayBuffer;function isDataViewToString(e){return f(e)==="[object DataView]"}isDataViewToString.working=typeof ArrayBuffer!=="undefined"&&typeof DataView!=="undefined"&&isDataViewToString(new DataView(new ArrayBuffer(1),0,1));function isDataView(e){if(typeof DataView==="undefined"){return false}return isDataViewToString.working?isDataViewToString(e):e instanceof DataView}t.isDataView=isDataView;var v=typeof SharedArrayBuffer!=="undefined"?SharedArrayBuffer:undefined;function isSharedArrayBufferToString(e){return f(e)==="[object SharedArrayBuffer]"}function isSharedArrayBuffer(e){if(typeof v==="undefined"){return false}if(typeof isSharedArrayBufferToString.working==="undefined"){isSharedArrayBufferToString.working=isSharedArrayBufferToString(new v)}return isSharedArrayBufferToString.working?isSharedArrayBufferToString(e):e instanceof v}t.isSharedArrayBuffer=isSharedArrayBuffer;function isAsyncFunction(e){return f(e)==="[object AsyncFunction]"}t.isAsyncFunction=isAsyncFunction;function isMapIterator(e){return f(e)==="[object Map Iterator]"}t.isMapIterator=isMapIterator;function isSetIterator(e){return f(e)==="[object Set Iterator]"}t.isSetIterator=isSetIterator;function isGeneratorObject(e){return f(e)==="[object Generator]"}t.isGeneratorObject=isGeneratorObject;function isWebAssemblyCompiledModule(e){return f(e)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=isWebAssemblyCompiledModule;function isNumberObject(e){return checkBoxedPrimitive(e,s)}t.isNumberObject=isNumberObject;function isStringObject(e){return checkBoxedPrimitive(e,l)}t.isStringObject=isStringObject;function isBooleanObject(e){return checkBoxedPrimitive(e,p)}t.isBooleanObject=isBooleanObject;function isBigIntObject(e){return c&&checkBoxedPrimitive(e,y)}t.isBigIntObject=isBigIntObject;function isSymbolObject(e){return u&&checkBoxedPrimitive(e,g)}t.isSymbolObject=isSymbolObject;function isBoxedPrimitive(e){return isNumberObject(e)||isStringObject(e)||isBooleanObject(e)||isBigIntObject(e)||isSymbolObject(e)}t.isBoxedPrimitive=isBoxedPrimitive;function isAnyArrayBuffer(e){return typeof Uint8Array!=="undefined"&&(isArrayBuffer(e)||isSharedArrayBuffer(e))}t.isAnyArrayBuffer=isAnyArrayBuffer;["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(e){Object.defineProperty(t,e,{enumerable:false,value:function(){throw new Error(e+" is not supported in userland")}})}))},177:function(e,t,r){var n=Object.getOwnPropertyDescriptors||function getOwnPropertyDescriptors(e){var t=Object.keys(e);var r={};for(var n=0;n=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}));for(var c=n[r];r=3)n.depth=arguments[2];if(arguments.length>=4)n.colors=arguments[3];if(isBoolean(r)){n.showHidden=r}else if(r){t._extend(n,r)}if(isUndefined(n.showHidden))n.showHidden=false;if(isUndefined(n.depth))n.depth=2;if(isUndefined(n.colors))n.colors=false;if(isUndefined(n.customInspect))n.customInspect=true;if(n.colors)n.stylize=stylizeWithColor;return formatValue(n,e,n.depth)}t.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(e,t){var r=inspect.styles[t];if(r){return"["+inspect.colors[r][0]+"m"+e+"["+inspect.colors[r][1]+"m"}else{return e}}function stylizeNoColor(e,t){return e}function arrayToHash(e){var t={};e.forEach((function(e,r){t[e]=true}));return t}function formatValue(e,r,n){if(e.customInspect&&r&&isFunction(r.inspect)&&r.inspect!==t.inspect&&!(r.constructor&&r.constructor.prototype===r)){var o=r.inspect(n,e);if(!isString(o)){o=formatValue(e,o,n)}return o}var i=formatPrimitive(e,r);if(i){return i}var a=Object.keys(r);var c=arrayToHash(a);if(e.showHidden){a=Object.getOwnPropertyNames(r)}if(isError(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0)){return formatError(r)}if(a.length===0){if(isFunction(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(isRegExp(r)){return e.stylize(RegExp.prototype.toString.call(r),"regexp")}if(isDate(r)){return e.stylize(Date.prototype.toString.call(r),"date")}if(isError(r)){return formatError(r)}}var f="",s=false,l=["{","}"];if(isArray(r)){s=true;l=["[","]"]}if(isFunction(r)){var p=r.name?": "+r.name:"";f=" [Function"+p+"]"}if(isRegExp(r)){f=" "+RegExp.prototype.toString.call(r)}if(isDate(r)){f=" "+Date.prototype.toUTCString.call(r)}if(isError(r)){f=" "+formatError(r)}if(a.length===0&&(!s||r.length==0)){return l[0]+f+l[1]}if(n<0){if(isRegExp(r)){return e.stylize(RegExp.prototype.toString.call(r),"regexp")}else{return e.stylize("[Object]","special")}}e.seen.push(r);var y;if(s){y=formatArray(e,r,n,c,a)}else{y=a.map((function(t){return formatProperty(e,r,n,c,t,s)}))}e.seen.pop();return reduceToSingleString(y,f,l)}function formatPrimitive(e,t){if(isUndefined(t))return e.stylize("undefined","undefined");if(isString(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(isNumber(t))return e.stylize(""+t,"number");if(isBoolean(t))return e.stylize(""+t,"boolean");if(isNull(t))return e.stylize("null","null")}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatArray(e,t,r,n,o){var i=[];for(var a=0,c=t.length;a-1){if(i){c=c.split("\n").map((function(e){return" "+e})).join("\n").substr(2)}else{c="\n"+c.split("\n").map((function(e){return" "+e})).join("\n")}}}else{c=e.stylize("[Circular]","special")}}if(isUndefined(a)){if(i&&o.match(/^\d+$/)){return c}a=JSON.stringify(""+o);if(a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){a=a.substr(1,a.length-2);a=e.stylize(a,"name")}else{a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");a=e.stylize(a,"string")}}return a+": "+c}function reduceToSingleString(e,t,r){var n=0;var o=e.reduce((function(e,t){n++;if(t.indexOf("\n")>=0)n++;return e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);if(o>60){return r[0]+(t===""?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]}return r[0]+t+" "+e.join(", ")+" "+r[1]}t.types=r(584);function isArray(e){return Array.isArray(e)}t.isArray=isArray;function isBoolean(e){return typeof e==="boolean"}t.isBoolean=isBoolean;function isNull(e){return e===null}t.isNull=isNull;function isNullOrUndefined(e){return e==null}t.isNullOrUndefined=isNullOrUndefined;function isNumber(e){return typeof e==="number"}t.isNumber=isNumber;function isString(e){return typeof e==="string"}t.isString=isString;function isSymbol(e){return typeof e==="symbol"}t.isSymbol=isSymbol;function isUndefined(e){return e===void 0}t.isUndefined=isUndefined;function isRegExp(e){return isObject(e)&&objectToString(e)==="[object RegExp]"}t.isRegExp=isRegExp;t.types.isRegExp=isRegExp;function isObject(e){return typeof e==="object"&&e!==null}t.isObject=isObject;function isDate(e){return isObject(e)&&objectToString(e)==="[object Date]"}t.isDate=isDate;t.types.isDate=isDate;function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}t.isError=isError;t.types.isNativeError=isError;function isFunction(e){return typeof e==="function"}t.isFunction=isFunction;function isPrimitive(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}t.isPrimitive=isPrimitive;t.isBuffer=r(369);function objectToString(e){return Object.prototype.toString.call(e)}function pad(e){return e<10?"0"+e.toString(10):e.toString(10)}var u=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var e=new Date;var t=[pad(e.getHours()),pad(e.getMinutes()),pad(e.getSeconds())].join(":");return[e.getDate(),u[e.getMonth()],t].join(" ")}t.log=function(){console.log("%s - %s",timestamp(),t.format.apply(t,arguments))};t.inherits=r(782);t._extend=function(e,t){if(!t||!isObject(t))return e;var r=Object.keys(t);var n=r.length;while(n--){e[r[n]]=t[r[n]]}return e};function hasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var f=typeof Symbol!=="undefined"?Symbol("util.promisify.custom"):undefined;t.promisify=function promisify(e){if(typeof e!=="function")throw new TypeError('The "original" argument must be of type Function');if(f&&e[f]){var t=e[f];if(typeof t!=="function"){throw new TypeError('The "util.promisify.custom" argument must be of type Function')}Object.defineProperty(t,f,{value:t,enumerable:false,writable:false,configurable:true});return t}function t(){var t,r;var n=new Promise((function(e,n){t=e;r=n}));var o=[];for(var i=0;i-1){return o(r)}return r}},139:function(e,t,r){"use strict";var n=r(174);var o=r(838);var i=o("%Function.prototype.apply%");var a=o("%Function.prototype.call%");var c=o("%Reflect.apply%",true)||n.call(a,i);var u=o("%Object.getOwnPropertyDescriptor%",true);var f=o("%Object.defineProperty%",true);var s=o("%Math.max%");if(f){try{f({},"a",{value:1})}catch(e){f=null}}e.exports=function callBind(e){var t=c(n,a,arguments);if(u&&f){var r=u(t,"length");if(r.configurable){f(t,"length",{value:1+s(0,e.length-(arguments.length-1))})}}return t};var l=function applyBind(){return c(n,i,arguments)};if(f){f(e.exports,"apply",{value:l})}else{e.exports.apply=l}},69:function(e,t,r){"use strict";var n=r(935);var o=typeof Symbol==="function"&&typeof Symbol("foo")==="symbol";var i=Object.prototype.toString;var a=Array.prototype.concat;var c=Object.defineProperty;var isFunction=function(e){return typeof e==="function"&&i.call(e)==="[object Function]"};var arePropertyDescriptorsSupported=function(){var e={};try{c(e,"x",{enumerable:false,value:e});for(var t in e){return false}return e.x===e}catch(e){return false}};var u=c&&arePropertyDescriptorsSupported();var defineProperty=function(e,t,r,n){if(t in e&&(!isFunction(n)||!n())){return}if(u){c(e,t,{configurable:true,enumerable:false,value:r,writable:true})}else{e[t]=r}};var defineProperties=function(e,t){var r=arguments.length>2?arguments[2]:{};var i=n(t);if(o){i=a.call(i,Object.getOwnPropertySymbols(t))}for(var c=0;c1&&typeof t!=="boolean"){throw new a('"allowMissing" argument must be a boolean')}var r=A(e);var i=r.length>0?r[0]:"";var u=j("%"+i+"%",t);var f=u.name;var s=u.value;var l=false;var p=u.alias;if(p){i=p[0];m(r,h([0,1],p))}for(var g=1,v=true;g=r.length){var w=c(s,d);v=!!w;if(v&&"get"in w&&!("originalValue"in w.get)){s=w.get}else{s=s[d]}}else{v=b(s,d);s=s[d]}if(v&&!l){y[f]=s}}}return s}},942:function(e,t,r){"use strict";var n=typeof Symbol!=="undefined"&&Symbol;var o=r(773);e.exports=function hasNativeSymbols(){if(typeof n!=="function"){return false}if(typeof Symbol!=="function"){return false}if(typeof n("foo")!=="symbol"){return false}if(typeof Symbol("bar")!=="symbol"){return false}return o()}},773:function(e){"use strict";e.exports=function hasSymbols(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function"){return false}if(typeof Symbol.iterator==="symbol"){return true}var e={};var t=Symbol("test");var r=Object(t);if(typeof t==="string"){return false}if(Object.prototype.toString.call(t)!=="[object Symbol]"){return false}if(Object.prototype.toString.call(r)!=="[object Symbol]"){return false}var n=42;e[t]=n;for(t in e){return false}if(typeof Object.keys==="function"&&Object.keys(e).length!==0){return false}if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(e).length!==0){return false}var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==t){return false}if(!Object.prototype.propertyIsEnumerable.call(e,t)){return false}if(typeof Object.getOwnPropertyDescriptor==="function"){var i=Object.getOwnPropertyDescriptor(e,t);if(i.value!==n||i.enumerable!==true){return false}}return true}},115:function(e,t,r){"use strict";var n=typeof Symbol!=="undefined"&&Symbol;var o=r(832);e.exports=function hasNativeSymbols(){if(typeof n!=="function"){return false}if(typeof Symbol!=="function"){return false}if(typeof n("foo")!=="symbol"){return false}if(typeof Symbol("bar")!=="symbol"){return false}return o()}},832:function(e){"use strict";e.exports=function hasSymbols(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function"){return false}if(typeof Symbol.iterator==="symbol"){return true}var e={};var t=Symbol("test");var r=Object(t);if(typeof t==="string"){return false}if(Object.prototype.toString.call(t)!=="[object Symbol]"){return false}if(Object.prototype.toString.call(r)!=="[object Symbol]"){return false}var n=42;e[t]=n;for(t in e){return false}if(typeof Object.keys==="function"&&Object.keys(e).length!==0){return false}if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(e).length!==0){return false}var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==t){return false}if(!Object.prototype.propertyIsEnumerable.call(e,t)){return false}if(typeof Object.getOwnPropertyDescriptor==="function"){var i=Object.getOwnPropertyDescriptor(e,t);if(i.value!==n||i.enumerable!==true){return false}}return true}},101:function(e,t,r){"use strict";var n=r(174);e.exports=n.call(Function.call,Object.prototype.hasOwnProperty)},782:function(e){if(typeof Object.create==="function"){e.exports=function inherits(e,t){if(t){e.super_=t;e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}}}else{e.exports=function inherits(e,t){if(t){e.super_=t;var TempCtor=function(){};TempCtor.prototype=t.prototype;e.prototype=new TempCtor;e.prototype.constructor=e}}}},157:function(e){"use strict";var t=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var r=Object.prototype.toString;var n=function isArguments(e){if(t&&e&&typeof e==="object"&&Symbol.toStringTag in e){return false}return r.call(e)==="[object Arguments]"};var o=function isArguments(e){if(n(e)){return true}return e!==null&&typeof e==="object"&&typeof e.length==="number"&&e.length>=0&&r.call(e)!=="[object Array]"&&r.call(e.callee)==="[object Function]"};var i=function(){return n(arguments)}();n.isLegacyArguments=o;e.exports=i?n:o},391:function(e){"use strict";var t=Object.prototype.toString;var r=Function.prototype.toString;var n=/^\s*(?:function)?\*/;var o=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var i=Object.getPrototypeOf;var getGeneratorFunc=function(){if(!o){return false}try{return Function("return function*() {}")()}catch(e){}};var a=getGeneratorFunc();var c=a?i(a):{};e.exports=function isGeneratorFunction(e){if(typeof e!=="function"){return false}if(n.test(r.call(e))){return true}if(!o){var a=t.call(e);return a==="[object GeneratorFunction]"}return i(e)===c}},460:function(e){"use strict";e.exports=function isNaN(e){return e!==e}},718:function(e,t,r){"use strict";var n=r(139);var o=r(69);var i=r(460);var a=r(625);var c=r(171);var u=n(a(),Number);o(u,{getPolyfill:a,implementation:i,shim:c});e.exports=u},625:function(e,t,r){"use strict";var n=r(460);e.exports=function getPolyfill(){if(Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")){return Number.isNaN}return n}},171:function(e,t,r){"use strict";var n=r(69);var o=r(625);e.exports=function shimNumberIsNaN(){var e=o();n(Number,{isNaN:e},{isNaN:function testIsNaN(){return Number.isNaN!==e}});return e}},994:function(e,t,r){"use strict";var n=r(144);var o=r(349);var i=r(256);var a=i("Object.prototype.toString");var c=r(942)();var u=c&&typeof Symbol.toStringTag==="symbol";var f=o();var s=i("Array.prototype.indexOf",true)||function indexOf(e,t){for(var r=0;r-1}if(!y){return false}return v(e)}},208:function(e){"use strict";var numberIsNaN=function(e){return e!==e};e.exports=function is(e,t){if(e===0&&t===0){return 1/e===1/t}if(e===t){return true}if(numberIsNaN(e)&&numberIsNaN(t)){return true}return false}},579:function(e,t,r){"use strict";var n;if(!Object.keys){var o=Object.prototype.hasOwnProperty;var i=Object.prototype.toString;var a=r(412);var c=Object.prototype.propertyIsEnumerable;var u=!c.call({toString:null},"toString");var f=c.call((function(){}),"prototype");var s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"];var equalsConstructorPrototype=function(e){var t=e.constructor;return t&&t.prototype===e};var l={$applicationCache:true,$console:true,$external:true,$frame:true,$frameElement:true,$frames:true,$innerHeight:true,$innerWidth:true,$onmozfullscreenchange:true,$onmozfullscreenerror:true,$outerHeight:true,$outerWidth:true,$pageXOffset:true,$pageYOffset:true,$parent:true,$scrollLeft:true,$scrollTop:true,$scrollX:true,$scrollY:true,$self:true,$webkitIndexedDB:true,$webkitStorageInfo:true,$window:true};var p=function(){if(typeof window==="undefined"){return false}for(var e in window){try{if(!l["$"+e]&&o.call(window,e)&&window[e]!==null&&typeof window[e]==="object"){try{equalsConstructorPrototype(window[e])}catch(e){return true}}}catch(e){return true}}return false}();var equalsConstructorPrototypeIfNotBuggy=function(e){if(typeof window==="undefined"||!p){return equalsConstructorPrototype(e)}try{return equalsConstructorPrototype(e)}catch(e){return false}};n=function keys(e){var t=e!==null&&typeof e==="object";var r=i.call(e)==="[object Function]";var n=a(e);var c=t&&i.call(e)==="[object String]";var l=[];if(!t&&!r&&!n){throw new TypeError("Object.keys called on a non-object")}var p=f&&r;if(c&&e.length>0&&!o.call(e,0)){for(var y=0;y0){for(var g=0;g=0&&t.call(e.callee)==="[object Function]"}return n}},369:function(e){e.exports=function isBuffer(e){return e instanceof Buffer}},584:function(e,t,r){"use strict";var n=r(157);var o=r(391);var i=r(490);var a=r(994);function uncurryThis(e){return e.call.bind(e)}var c=typeof BigInt!=="undefined";var u=typeof Symbol!=="undefined";var f=uncurryThis(Object.prototype.toString);var s=uncurryThis(Number.prototype.valueOf);var l=uncurryThis(String.prototype.valueOf);var p=uncurryThis(Boolean.prototype.valueOf);if(c){var y=uncurryThis(BigInt.prototype.valueOf)}if(u){var g=uncurryThis(Symbol.prototype.valueOf)}function checkBoxedPrimitive(e,t){if(typeof e!=="object"){return false}try{t(e);return true}catch(e){return false}}t.isArgumentsObject=n;t.isGeneratorFunction=o;t.isTypedArray=a;function isPromise(e){return typeof Promise!=="undefined"&&e instanceof Promise||e!==null&&typeof e==="object"&&typeof e.then==="function"&&typeof e.catch==="function"}t.isPromise=isPromise;function isArrayBufferView(e){if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){return ArrayBuffer.isView(e)}return a(e)||isDataView(e)}t.isArrayBufferView=isArrayBufferView;function isUint8Array(e){return i(e)==="Uint8Array"}t.isUint8Array=isUint8Array;function isUint8ClampedArray(e){return i(e)==="Uint8ClampedArray"}t.isUint8ClampedArray=isUint8ClampedArray;function isUint16Array(e){return i(e)==="Uint16Array"}t.isUint16Array=isUint16Array;function isUint32Array(e){return i(e)==="Uint32Array"}t.isUint32Array=isUint32Array;function isInt8Array(e){return i(e)==="Int8Array"}t.isInt8Array=isInt8Array;function isInt16Array(e){return i(e)==="Int16Array"}t.isInt16Array=isInt16Array;function isInt32Array(e){return i(e)==="Int32Array"}t.isInt32Array=isInt32Array;function isFloat32Array(e){return i(e)==="Float32Array"}t.isFloat32Array=isFloat32Array;function isFloat64Array(e){return i(e)==="Float64Array"}t.isFloat64Array=isFloat64Array;function isBigInt64Array(e){return i(e)==="BigInt64Array"}t.isBigInt64Array=isBigInt64Array;function isBigUint64Array(e){return i(e)==="BigUint64Array"}t.isBigUint64Array=isBigUint64Array;function isMapToString(e){return f(e)==="[object Map]"}isMapToString.working=typeof Map!=="undefined"&&isMapToString(new Map);function isMap(e){if(typeof Map==="undefined"){return false}return isMapToString.working?isMapToString(e):e instanceof Map}t.isMap=isMap;function isSetToString(e){return f(e)==="[object Set]"}isSetToString.working=typeof Set!=="undefined"&&isSetToString(new Set);function isSet(e){if(typeof Set==="undefined"){return false}return isSetToString.working?isSetToString(e):e instanceof Set}t.isSet=isSet;function isWeakMapToString(e){return f(e)==="[object WeakMap]"}isWeakMapToString.working=typeof WeakMap!=="undefined"&&isWeakMapToString(new WeakMap);function isWeakMap(e){if(typeof WeakMap==="undefined"){return false}return isWeakMapToString.working?isWeakMapToString(e):e instanceof WeakMap}t.isWeakMap=isWeakMap;function isWeakSetToString(e){return f(e)==="[object WeakSet]"}isWeakSetToString.working=typeof WeakSet!=="undefined"&&isWeakSetToString(new WeakSet);function isWeakSet(e){return isWeakSetToString(e)}t.isWeakSet=isWeakSet;function isArrayBufferToString(e){return f(e)==="[object ArrayBuffer]"}isArrayBufferToString.working=typeof ArrayBuffer!=="undefined"&&isArrayBufferToString(new ArrayBuffer);function isArrayBuffer(e){if(typeof ArrayBuffer==="undefined"){return false}return isArrayBufferToString.working?isArrayBufferToString(e):e instanceof ArrayBuffer}t.isArrayBuffer=isArrayBuffer;function isDataViewToString(e){return f(e)==="[object DataView]"}isDataViewToString.working=typeof ArrayBuffer!=="undefined"&&typeof DataView!=="undefined"&&isDataViewToString(new DataView(new ArrayBuffer(1),0,1));function isDataView(e){if(typeof DataView==="undefined"){return false}return isDataViewToString.working?isDataViewToString(e):e instanceof DataView}t.isDataView=isDataView;var v=typeof SharedArrayBuffer!=="undefined"?SharedArrayBuffer:undefined;function isSharedArrayBufferToString(e){return f(e)==="[object SharedArrayBuffer]"}function isSharedArrayBuffer(e){if(typeof v==="undefined"){return false}if(typeof isSharedArrayBufferToString.working==="undefined"){isSharedArrayBufferToString.working=isSharedArrayBufferToString(new v)}return isSharedArrayBufferToString.working?isSharedArrayBufferToString(e):e instanceof v}t.isSharedArrayBuffer=isSharedArrayBuffer;function isAsyncFunction(e){return f(e)==="[object AsyncFunction]"}t.isAsyncFunction=isAsyncFunction;function isMapIterator(e){return f(e)==="[object Map Iterator]"}t.isMapIterator=isMapIterator;function isSetIterator(e){return f(e)==="[object Set Iterator]"}t.isSetIterator=isSetIterator;function isGeneratorObject(e){return f(e)==="[object Generator]"}t.isGeneratorObject=isGeneratorObject;function isWebAssemblyCompiledModule(e){return f(e)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=isWebAssemblyCompiledModule;function isNumberObject(e){return checkBoxedPrimitive(e,s)}t.isNumberObject=isNumberObject;function isStringObject(e){return checkBoxedPrimitive(e,l)}t.isStringObject=isStringObject;function isBooleanObject(e){return checkBoxedPrimitive(e,p)}t.isBooleanObject=isBooleanObject;function isBigIntObject(e){return c&&checkBoxedPrimitive(e,y)}t.isBigIntObject=isBigIntObject;function isSymbolObject(e){return u&&checkBoxedPrimitive(e,g)}t.isSymbolObject=isSymbolObject;function isBoxedPrimitive(e){return isNumberObject(e)||isStringObject(e)||isBooleanObject(e)||isBigIntObject(e)||isSymbolObject(e)}t.isBoxedPrimitive=isBoxedPrimitive;function isAnyArrayBuffer(e){return typeof Uint8Array!=="undefined"&&(isArrayBuffer(e)||isSharedArrayBuffer(e))}t.isAnyArrayBuffer=isAnyArrayBuffer;["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(e){Object.defineProperty(t,e,{enumerable:false,value:function(){throw new Error(e+" is not supported in userland")}})}))},177:function(e,t,r){var n=Object.getOwnPropertyDescriptors||function getOwnPropertyDescriptors(e){var t=Object.keys(e);var r={};for(var n=0;n=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}));for(var c=n[r];r=3)n.depth=arguments[2];if(arguments.length>=4)n.colors=arguments[3];if(isBoolean(r)){n.showHidden=r}else if(r){t._extend(n,r)}if(isUndefined(n.showHidden))n.showHidden=false;if(isUndefined(n.depth))n.depth=2;if(isUndefined(n.colors))n.colors=false;if(isUndefined(n.customInspect))n.customInspect=true;if(n.colors)n.stylize=stylizeWithColor;return formatValue(n,e,n.depth)}t.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(e,t){var r=inspect.styles[t];if(r){return"["+inspect.colors[r][0]+"m"+e+"["+inspect.colors[r][1]+"m"}else{return e}}function stylizeNoColor(e,t){return e}function arrayToHash(e){var t={};e.forEach((function(e,r){t[e]=true}));return t}function formatValue(e,r,n){if(e.customInspect&&r&&isFunction(r.inspect)&&r.inspect!==t.inspect&&!(r.constructor&&r.constructor.prototype===r)){var o=r.inspect(n,e);if(!isString(o)){o=formatValue(e,o,n)}return o}var i=formatPrimitive(e,r);if(i){return i}var a=Object.keys(r);var c=arrayToHash(a);if(e.showHidden){a=Object.getOwnPropertyNames(r)}if(isError(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0)){return formatError(r)}if(a.length===0){if(isFunction(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(isRegExp(r)){return e.stylize(RegExp.prototype.toString.call(r),"regexp")}if(isDate(r)){return e.stylize(Date.prototype.toString.call(r),"date")}if(isError(r)){return formatError(r)}}var f="",s=false,l=["{","}"];if(isArray(r)){s=true;l=["[","]"]}if(isFunction(r)){var p=r.name?": "+r.name:"";f=" [Function"+p+"]"}if(isRegExp(r)){f=" "+RegExp.prototype.toString.call(r)}if(isDate(r)){f=" "+Date.prototype.toUTCString.call(r)}if(isError(r)){f=" "+formatError(r)}if(a.length===0&&(!s||r.length==0)){return l[0]+f+l[1]}if(n<0){if(isRegExp(r)){return e.stylize(RegExp.prototype.toString.call(r),"regexp")}else{return e.stylize("[Object]","special")}}e.seen.push(r);var y;if(s){y=formatArray(e,r,n,c,a)}else{y=a.map((function(t){return formatProperty(e,r,n,c,t,s)}))}e.seen.pop();return reduceToSingleString(y,f,l)}function formatPrimitive(e,t){if(isUndefined(t))return e.stylize("undefined","undefined");if(isString(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(isNumber(t))return e.stylize(""+t,"number");if(isBoolean(t))return e.stylize(""+t,"boolean");if(isNull(t))return e.stylize("null","null")}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatArray(e,t,r,n,o){var i=[];for(var a=0,c=t.length;a-1){if(i){c=c.split("\n").map((function(e){return" "+e})).join("\n").substr(2)}else{c="\n"+c.split("\n").map((function(e){return" "+e})).join("\n")}}}else{c=e.stylize("[Circular]","special")}}if(isUndefined(a)){if(i&&o.match(/^\d+$/)){return c}a=JSON.stringify(""+o);if(a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){a=a.substr(1,a.length-2);a=e.stylize(a,"name")}else{a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");a=e.stylize(a,"string")}}return a+": "+c}function reduceToSingleString(e,t,r){var n=0;var o=e.reduce((function(e,t){n++;if(t.indexOf("\n")>=0)n++;return e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);if(o>60){return r[0]+(t===""?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]}return r[0]+t+" "+e.join(", ")+" "+r[1]}t.types=r(584);function isArray(e){return Array.isArray(e)}t.isArray=isArray;function isBoolean(e){return typeof e==="boolean"}t.isBoolean=isBoolean;function isNull(e){return e===null}t.isNull=isNull;function isNullOrUndefined(e){return e==null}t.isNullOrUndefined=isNullOrUndefined;function isNumber(e){return typeof e==="number"}t.isNumber=isNumber;function isString(e){return typeof e==="string"}t.isString=isString;function isSymbol(e){return typeof e==="symbol"}t.isSymbol=isSymbol;function isUndefined(e){return e===void 0}t.isUndefined=isUndefined;function isRegExp(e){return isObject(e)&&objectToString(e)==="[object RegExp]"}t.isRegExp=isRegExp;t.types.isRegExp=isRegExp;function isObject(e){return typeof e==="object"&&e!==null}t.isObject=isObject;function isDate(e){return isObject(e)&&objectToString(e)==="[object Date]"}t.isDate=isDate;t.types.isDate=isDate;function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}t.isError=isError;t.types.isNativeError=isError;function isFunction(e){return typeof e==="function"}t.isFunction=isFunction;function isPrimitive(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}t.isPrimitive=isPrimitive;t.isBuffer=r(369);function objectToString(e){return Object.prototype.toString.call(e)}function pad(e){return e<10?"0"+e.toString(10):e.toString(10)}var u=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var e=new Date;var t=[pad(e.getHours()),pad(e.getMinutes()),pad(e.getSeconds())].join(":");return[e.getDate(),u[e.getMonth()],t].join(" ")}t.log=function(){console.log("%s - %s",timestamp(),t.format.apply(t,arguments))};t.inherits=r(782);t._extend=function(e,t){if(!t||!isObject(t))return e;var r=Object.keys(t);var n=r.length;while(n--){e[r[n]]=t[r[n]]}return e};function hasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var f=typeof Symbol!=="undefined"?Symbol("util.promisify.custom"):undefined;t.promisify=function promisify(e){if(typeof e!=="function")throw new TypeError('The "original" argument must be of type Function');if(f&&e[f]){var t=e[f];if(typeof t!=="function"){throw new TypeError('The "util.promisify.custom" argument must be of type Function')}Object.defineProperty(t,f,{value:t,enumerable:false,writable:false,configurable:true});return t}function t(){var t,r;var n=new Promise((function(e,n){t=e;r=n}));var o=[];for(var i=0;i-1){return o(t)}return t}},139:function(r,e,t){"use strict";var n=t(174);var o=t(838);var i=o("%Function.prototype.apply%");var a=o("%Function.prototype.call%");var f=o("%Reflect.apply%",true)||n.call(a,i);var u=o("%Object.getOwnPropertyDescriptor%",true);var s=o("%Object.defineProperty%",true);var c=o("%Math.max%");if(s){try{s({},"a",{value:1})}catch(r){s=null}}r.exports=function callBind(r){var e=f(n,a,arguments);if(u&&s){var t=u(e,"length");if(t.configurable){s(e,"length",{value:1+c(0,r.length-(arguments.length-1))})}}return e};var y=function applyBind(){return f(n,i,arguments)};if(s){s(r.exports,"apply",{value:y})}else{r.exports.apply=y}},144:function(r){var e=Object.prototype.hasOwnProperty;var t=Object.prototype.toString;r.exports=function forEach(r,n,o){if(t.call(n)!=="[object Function]"){throw new TypeError("iterator must be a function")}var i=r.length;if(i===+i){for(var a=0;a1&&typeof e!=="boolean"){throw new a('"allowMissing" argument must be a boolean')}var t=j(r);var i=t.length>0?t[0]:"";var u=P("%"+i+"%",e);var s=u.name;var c=u.value;var y=false;var p=u.alias;if(p){i=p[0];m(t,A([0,1],p))}for(var g=1,d=true;g=t.length){var w=f(c,v);d=!!w;if(d&&"get"in w&&!("originalValue"in w.get)){c=w.get}else{c=c[v]}}else{d=b(c,v);c=c[v]}if(d&&!y){l[s]=c}}}return c}},942:function(r,e,t){"use strict";var n=typeof Symbol!=="undefined"&&Symbol;var o=t(773);r.exports=function hasNativeSymbols(){if(typeof n!=="function"){return false}if(typeof Symbol!=="function"){return false}if(typeof n("foo")!=="symbol"){return false}if(typeof Symbol("bar")!=="symbol"){return false}return o()}},773:function(r){"use strict";r.exports=function hasSymbols(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function"){return false}if(typeof Symbol.iterator==="symbol"){return true}var r={};var e=Symbol("test");var t=Object(e);if(typeof e==="string"){return false}if(Object.prototype.toString.call(e)!=="[object Symbol]"){return false}if(Object.prototype.toString.call(t)!=="[object Symbol]"){return false}var n=42;r[e]=n;for(e in r){return false}if(typeof Object.keys==="function"&&Object.keys(r).length!==0){return false}if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(r).length!==0){return false}var o=Object.getOwnPropertySymbols(r);if(o.length!==1||o[0]!==e){return false}if(!Object.prototype.propertyIsEnumerable.call(r,e)){return false}if(typeof Object.getOwnPropertyDescriptor==="function"){var i=Object.getOwnPropertyDescriptor(r,e);if(i.value!==n||i.enumerable!==true){return false}}return true}},101:function(r,e,t){"use strict";var n=t(174);r.exports=n.call(Function.call,Object.prototype.hasOwnProperty)},782:function(r){if(typeof Object.create==="function"){r.exports=function inherits(r,e){if(e){r.super_=e;r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}})}}}else{r.exports=function inherits(r,e){if(e){r.super_=e;var TempCtor=function(){};TempCtor.prototype=e.prototype;r.prototype=new TempCtor;r.prototype.constructor=r}}}},157:function(r){"use strict";var e=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var t=Object.prototype.toString;var n=function isArguments(r){if(e&&r&&typeof r==="object"&&Symbol.toStringTag in r){return false}return t.call(r)==="[object Arguments]"};var o=function isArguments(r){if(n(r)){return true}return r!==null&&typeof r==="object"&&typeof r.length==="number"&&r.length>=0&&t.call(r)!=="[object Array]"&&t.call(r.callee)==="[object Function]"};var i=function(){return n(arguments)}();n.isLegacyArguments=o;r.exports=i?n:o},391:function(r){"use strict";var e=Object.prototype.toString;var t=Function.prototype.toString;var n=/^\s*(?:function)?\*/;var o=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var i=Object.getPrototypeOf;var getGeneratorFunc=function(){if(!o){return false}try{return Function("return function*() {}")()}catch(r){}};var a=getGeneratorFunc();var f=a?i(a):{};r.exports=function isGeneratorFunction(r){if(typeof r!=="function"){return false}if(n.test(t.call(r))){return true}if(!o){var a=e.call(r);return a==="[object GeneratorFunction]"}return i(r)===f}},994:function(r,e,t){"use strict";var n=t(144);var o=t(349);var i=t(256);var a=i("Object.prototype.toString");var f=t(942)();var u=f&&typeof Symbol.toStringTag==="symbol";var s=o();var c=i("Array.prototype.indexOf",true)||function indexOf(r,e){for(var t=0;t-1}if(!l){return false}return d(r)}},369:function(r){r.exports=function isBuffer(r){return r instanceof Buffer}},584:function(r,e,t){"use strict";var n=t(157);var o=t(391);var i=t(490);var a=t(994);function uncurryThis(r){return r.call.bind(r)}var f=typeof BigInt!=="undefined";var u=typeof Symbol!=="undefined";var s=uncurryThis(Object.prototype.toString);var c=uncurryThis(Number.prototype.valueOf);var y=uncurryThis(String.prototype.valueOf);var p=uncurryThis(Boolean.prototype.valueOf);if(f){var l=uncurryThis(BigInt.prototype.valueOf)}if(u){var g=uncurryThis(Symbol.prototype.valueOf)}function checkBoxedPrimitive(r,e){if(typeof r!=="object"){return false}try{e(r);return true}catch(r){return false}}e.isArgumentsObject=n;e.isGeneratorFunction=o;e.isTypedArray=a;function isPromise(r){return typeof Promise!=="undefined"&&r instanceof Promise||r!==null&&typeof r==="object"&&typeof r.then==="function"&&typeof r.catch==="function"}e.isPromise=isPromise;function isArrayBufferView(r){if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){return ArrayBuffer.isView(r)}return a(r)||isDataView(r)}e.isArrayBufferView=isArrayBufferView;function isUint8Array(r){return i(r)==="Uint8Array"}e.isUint8Array=isUint8Array;function isUint8ClampedArray(r){return i(r)==="Uint8ClampedArray"}e.isUint8ClampedArray=isUint8ClampedArray;function isUint16Array(r){return i(r)==="Uint16Array"}e.isUint16Array=isUint16Array;function isUint32Array(r){return i(r)==="Uint32Array"}e.isUint32Array=isUint32Array;function isInt8Array(r){return i(r)==="Int8Array"}e.isInt8Array=isInt8Array;function isInt16Array(r){return i(r)==="Int16Array"}e.isInt16Array=isInt16Array;function isInt32Array(r){return i(r)==="Int32Array"}e.isInt32Array=isInt32Array;function isFloat32Array(r){return i(r)==="Float32Array"}e.isFloat32Array=isFloat32Array;function isFloat64Array(r){return i(r)==="Float64Array"}e.isFloat64Array=isFloat64Array;function isBigInt64Array(r){return i(r)==="BigInt64Array"}e.isBigInt64Array=isBigInt64Array;function isBigUint64Array(r){return i(r)==="BigUint64Array"}e.isBigUint64Array=isBigUint64Array;function isMapToString(r){return s(r)==="[object Map]"}isMapToString.working=typeof Map!=="undefined"&&isMapToString(new Map);function isMap(r){if(typeof Map==="undefined"){return false}return isMapToString.working?isMapToString(r):r instanceof Map}e.isMap=isMap;function isSetToString(r){return s(r)==="[object Set]"}isSetToString.working=typeof Set!=="undefined"&&isSetToString(new Set);function isSet(r){if(typeof Set==="undefined"){return false}return isSetToString.working?isSetToString(r):r instanceof Set}e.isSet=isSet;function isWeakMapToString(r){return s(r)==="[object WeakMap]"}isWeakMapToString.working=typeof WeakMap!=="undefined"&&isWeakMapToString(new WeakMap);function isWeakMap(r){if(typeof WeakMap==="undefined"){return false}return isWeakMapToString.working?isWeakMapToString(r):r instanceof WeakMap}e.isWeakMap=isWeakMap;function isWeakSetToString(r){return s(r)==="[object WeakSet]"}isWeakSetToString.working=typeof WeakSet!=="undefined"&&isWeakSetToString(new WeakSet);function isWeakSet(r){return isWeakSetToString(r)}e.isWeakSet=isWeakSet;function isArrayBufferToString(r){return s(r)==="[object ArrayBuffer]"}isArrayBufferToString.working=typeof ArrayBuffer!=="undefined"&&isArrayBufferToString(new ArrayBuffer);function isArrayBuffer(r){if(typeof ArrayBuffer==="undefined"){return false}return isArrayBufferToString.working?isArrayBufferToString(r):r instanceof ArrayBuffer}e.isArrayBuffer=isArrayBuffer;function isDataViewToString(r){return s(r)==="[object DataView]"}isDataViewToString.working=typeof ArrayBuffer!=="undefined"&&typeof DataView!=="undefined"&&isDataViewToString(new DataView(new ArrayBuffer(1),0,1));function isDataView(r){if(typeof DataView==="undefined"){return false}return isDataViewToString.working?isDataViewToString(r):r instanceof DataView}e.isDataView=isDataView;var d=typeof SharedArrayBuffer!=="undefined"?SharedArrayBuffer:undefined;function isSharedArrayBufferToString(r){return s(r)==="[object SharedArrayBuffer]"}function isSharedArrayBuffer(r){if(typeof d==="undefined"){return false}if(typeof isSharedArrayBufferToString.working==="undefined"){isSharedArrayBufferToString.working=isSharedArrayBufferToString(new d)}return isSharedArrayBufferToString.working?isSharedArrayBufferToString(r):r instanceof d}e.isSharedArrayBuffer=isSharedArrayBuffer;function isAsyncFunction(r){return s(r)==="[object AsyncFunction]"}e.isAsyncFunction=isAsyncFunction;function isMapIterator(r){return s(r)==="[object Map Iterator]"}e.isMapIterator=isMapIterator;function isSetIterator(r){return s(r)==="[object Set Iterator]"}e.isSetIterator=isSetIterator;function isGeneratorObject(r){return s(r)==="[object Generator]"}e.isGeneratorObject=isGeneratorObject;function isWebAssemblyCompiledModule(r){return s(r)==="[object WebAssembly.Module]"}e.isWebAssemblyCompiledModule=isWebAssemblyCompiledModule;function isNumberObject(r){return checkBoxedPrimitive(r,c)}e.isNumberObject=isNumberObject;function isStringObject(r){return checkBoxedPrimitive(r,y)}e.isStringObject=isStringObject;function isBooleanObject(r){return checkBoxedPrimitive(r,p)}e.isBooleanObject=isBooleanObject;function isBigIntObject(r){return f&&checkBoxedPrimitive(r,l)}e.isBigIntObject=isBigIntObject;function isSymbolObject(r){return u&&checkBoxedPrimitive(r,g)}e.isSymbolObject=isSymbolObject;function isBoxedPrimitive(r){return isNumberObject(r)||isStringObject(r)||isBooleanObject(r)||isBigIntObject(r)||isSymbolObject(r)}e.isBoxedPrimitive=isBoxedPrimitive;function isAnyArrayBuffer(r){return typeof Uint8Array!=="undefined"&&(isArrayBuffer(r)||isSharedArrayBuffer(r))}e.isAnyArrayBuffer=isAnyArrayBuffer;["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(r){Object.defineProperty(e,r,{enumerable:false,value:function(){throw new Error(r+" is not supported in userland")}})}))},177:function(r,e,t){var n=Object.getOwnPropertyDescriptors||function getOwnPropertyDescriptors(r){var e=Object.keys(r);var t={};for(var n=0;n=i)return r;switch(r){case"%s":return String(n[t++]);case"%d":return Number(n[t++]);case"%j":try{return JSON.stringify(n[t++])}catch(r){return"[Circular]"}default:return r}}));for(var f=n[t];t=3)n.depth=arguments[2];if(arguments.length>=4)n.colors=arguments[3];if(isBoolean(t)){n.showHidden=t}else if(t){e._extend(n,t)}if(isUndefined(n.showHidden))n.showHidden=false;if(isUndefined(n.depth))n.depth=2;if(isUndefined(n.colors))n.colors=false;if(isUndefined(n.customInspect))n.customInspect=true;if(n.colors)n.stylize=stylizeWithColor;return formatValue(n,r,n.depth)}e.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(r,e){var t=inspect.styles[e];if(t){return"["+inspect.colors[t][0]+"m"+r+"["+inspect.colors[t][1]+"m"}else{return r}}function stylizeNoColor(r,e){return r}function arrayToHash(r){var e={};r.forEach((function(r,t){e[r]=true}));return e}function formatValue(r,t,n){if(r.customInspect&&t&&isFunction(t.inspect)&&t.inspect!==e.inspect&&!(t.constructor&&t.constructor.prototype===t)){var o=t.inspect(n,r);if(!isString(o)){o=formatValue(r,o,n)}return o}var i=formatPrimitive(r,t);if(i){return i}var a=Object.keys(t);var f=arrayToHash(a);if(r.showHidden){a=Object.getOwnPropertyNames(t)}if(isError(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0)){return formatError(t)}if(a.length===0){if(isFunction(t)){var u=t.name?": "+t.name:"";return r.stylize("[Function"+u+"]","special")}if(isRegExp(t)){return r.stylize(RegExp.prototype.toString.call(t),"regexp")}if(isDate(t)){return r.stylize(Date.prototype.toString.call(t),"date")}if(isError(t)){return formatError(t)}}var s="",c=false,y=["{","}"];if(isArray(t)){c=true;y=["[","]"]}if(isFunction(t)){var p=t.name?": "+t.name:"";s=" [Function"+p+"]"}if(isRegExp(t)){s=" "+RegExp.prototype.toString.call(t)}if(isDate(t)){s=" "+Date.prototype.toUTCString.call(t)}if(isError(t)){s=" "+formatError(t)}if(a.length===0&&(!c||t.length==0)){return y[0]+s+y[1]}if(n<0){if(isRegExp(t)){return r.stylize(RegExp.prototype.toString.call(t),"regexp")}else{return r.stylize("[Object]","special")}}r.seen.push(t);var l;if(c){l=formatArray(r,t,n,f,a)}else{l=a.map((function(e){return formatProperty(r,t,n,f,e,c)}))}r.seen.pop();return reduceToSingleString(l,s,y)}function formatPrimitive(r,e){if(isUndefined(e))return r.stylize("undefined","undefined");if(isString(e)){var t="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return r.stylize(t,"string")}if(isNumber(e))return r.stylize(""+e,"number");if(isBoolean(e))return r.stylize(""+e,"boolean");if(isNull(e))return r.stylize("null","null")}function formatError(r){return"["+Error.prototype.toString.call(r)+"]"}function formatArray(r,e,t,n,o){var i=[];for(var a=0,f=e.length;a-1){if(i){f=f.split("\n").map((function(r){return" "+r})).join("\n").substr(2)}else{f="\n"+f.split("\n").map((function(r){return" "+r})).join("\n")}}}else{f=r.stylize("[Circular]","special")}}if(isUndefined(a)){if(i&&o.match(/^\d+$/)){return f}a=JSON.stringify(""+o);if(a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){a=a.substr(1,a.length-2);a=r.stylize(a,"name")}else{a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");a=r.stylize(a,"string")}}return a+": "+f}function reduceToSingleString(r,e,t){var n=0;var o=r.reduce((function(r,e){n++;if(e.indexOf("\n")>=0)n++;return r+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0);if(o>60){return t[0]+(e===""?"":e+"\n ")+" "+r.join(",\n ")+" "+t[1]}return t[0]+e+" "+r.join(", ")+" "+t[1]}e.types=t(584);function isArray(r){return Array.isArray(r)}e.isArray=isArray;function isBoolean(r){return typeof r==="boolean"}e.isBoolean=isBoolean;function isNull(r){return r===null}e.isNull=isNull;function isNullOrUndefined(r){return r==null}e.isNullOrUndefined=isNullOrUndefined;function isNumber(r){return typeof r==="number"}e.isNumber=isNumber;function isString(r){return typeof r==="string"}e.isString=isString;function isSymbol(r){return typeof r==="symbol"}e.isSymbol=isSymbol;function isUndefined(r){return r===void 0}e.isUndefined=isUndefined;function isRegExp(r){return isObject(r)&&objectToString(r)==="[object RegExp]"}e.isRegExp=isRegExp;e.types.isRegExp=isRegExp;function isObject(r){return typeof r==="object"&&r!==null}e.isObject=isObject;function isDate(r){return isObject(r)&&objectToString(r)==="[object Date]"}e.isDate=isDate;e.types.isDate=isDate;function isError(r){return isObject(r)&&(objectToString(r)==="[object Error]"||r instanceof Error)}e.isError=isError;e.types.isNativeError=isError;function isFunction(r){return typeof r==="function"}e.isFunction=isFunction;function isPrimitive(r){return r===null||typeof r==="boolean"||typeof r==="number"||typeof r==="string"||typeof r==="symbol"||typeof r==="undefined"}e.isPrimitive=isPrimitive;e.isBuffer=t(369);function objectToString(r){return Object.prototype.toString.call(r)}function pad(r){return r<10?"0"+r.toString(10):r.toString(10)}var u=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var r=new Date;var e=[pad(r.getHours()),pad(r.getMinutes()),pad(r.getSeconds())].join(":");return[r.getDate(),u[r.getMonth()],e].join(" ")}e.log=function(){console.log("%s - %s",timestamp(),e.format.apply(e,arguments))};e.inherits=t(782);e._extend=function(r,e){if(!e||!isObject(e))return r;var t=Object.keys(e);var n=t.length;while(n--){r[t[n]]=e[t[n]]}return r};function hasOwnProperty(r,e){return Object.prototype.hasOwnProperty.call(r,e)}var s=typeof Symbol!=="undefined"?Symbol("util.promisify.custom"):undefined;e.promisify=function promisify(r){if(typeof r!=="function")throw new TypeError('The "original" argument must be of type Function');if(s&&r[s]){var e=r[s];if(typeof e!=="function"){throw new TypeError('The "util.promisify.custom" argument must be of type Function')}Object.defineProperty(e,s,{value:e,enumerable:false,writable:false,configurable:true});return e}function e(){var e,t;var n=new Promise((function(r,n){e=r;t=n}));var o=[];for(var i=0;i-1){return o(t)}return t}},139:function(r,e,t){"use strict";var n=t(174);var o=t(838);var i=o("%Function.prototype.apply%");var a=o("%Function.prototype.call%");var f=o("%Reflect.apply%",true)||n.call(a,i);var u=o("%Object.getOwnPropertyDescriptor%",true);var s=o("%Object.defineProperty%",true);var y=o("%Math.max%");if(s){try{s({},"a",{value:1})}catch(r){s=null}}r.exports=function callBind(r){var e=f(n,a,arguments);if(u&&s){var t=u(e,"length");if(t.configurable){s(e,"length",{value:1+y(0,r.length-(arguments.length-1))})}}return e};var c=function applyBind(){return f(n,i,arguments)};if(s){s(r.exports,"apply",{value:c})}else{r.exports.apply=c}},144:function(r){var e=Object.prototype.hasOwnProperty;var t=Object.prototype.toString;r.exports=function forEach(r,n,o){if(t.call(n)!=="[object Function]"){throw new TypeError("iterator must be a function")}var i=r.length;if(i===+i){for(var a=0;a1&&typeof e!=="boolean"){throw new a('"allowMissing" argument must be a boolean')}var t=w(r);var i=t.length>0?t[0]:"";var u=P("%"+i+"%",e);var s=u.name;var y=u.value;var c=false;var p=u.alias;if(p){i=p[0];S(t,m([0,1],p))}for(var g=1,b=true;g=t.length){var j=f(y,d);b=!!j;if(b&&"get"in j&&!("originalValue"in j.get)){y=j.get}else{y=y[d]}}else{b=v(y,d);y=y[d]}if(b&&!c){l[s]=y}}}return y}},942:function(r,e,t){"use strict";var n=typeof Symbol!=="undefined"&&Symbol;var o=t(773);r.exports=function hasNativeSymbols(){if(typeof n!=="function"){return false}if(typeof Symbol!=="function"){return false}if(typeof n("foo")!=="symbol"){return false}if(typeof Symbol("bar")!=="symbol"){return false}return o()}},773:function(r){"use strict";r.exports=function hasSymbols(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function"){return false}if(typeof Symbol.iterator==="symbol"){return true}var r={};var e=Symbol("test");var t=Object(e);if(typeof e==="string"){return false}if(Object.prototype.toString.call(e)!=="[object Symbol]"){return false}if(Object.prototype.toString.call(t)!=="[object Symbol]"){return false}var n=42;r[e]=n;for(e in r){return false}if(typeof Object.keys==="function"&&Object.keys(r).length!==0){return false}if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(r).length!==0){return false}var o=Object.getOwnPropertySymbols(r);if(o.length!==1||o[0]!==e){return false}if(!Object.prototype.propertyIsEnumerable.call(r,e)){return false}if(typeof Object.getOwnPropertyDescriptor==="function"){var i=Object.getOwnPropertyDescriptor(r,e);if(i.value!==n||i.enumerable!==true){return false}}return true}},115:function(r,e,t){"use strict";var n=typeof Symbol!=="undefined"&&Symbol;var o=t(832);r.exports=function hasNativeSymbols(){if(typeof n!=="function"){return false}if(typeof Symbol!=="function"){return false}if(typeof n("foo")!=="symbol"){return false}if(typeof Symbol("bar")!=="symbol"){return false}return o()}},832:function(r){"use strict";r.exports=function hasSymbols(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function"){return false}if(typeof Symbol.iterator==="symbol"){return true}var r={};var e=Symbol("test");var t=Object(e);if(typeof e==="string"){return false}if(Object.prototype.toString.call(e)!=="[object Symbol]"){return false}if(Object.prototype.toString.call(t)!=="[object Symbol]"){return false}var n=42;r[e]=n;for(e in r){return false}if(typeof Object.keys==="function"&&Object.keys(r).length!==0){return false}if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(r).length!==0){return false}var o=Object.getOwnPropertySymbols(r);if(o.length!==1||o[0]!==e){return false}if(!Object.prototype.propertyIsEnumerable.call(r,e)){return false}if(typeof Object.getOwnPropertyDescriptor==="function"){var i=Object.getOwnPropertyDescriptor(r,e);if(i.value!==n||i.enumerable!==true){return false}}return true}},101:function(r,e,t){"use strict";var n=t(174);r.exports=n.call(Function.call,Object.prototype.hasOwnProperty)},782:function(r){if(typeof Object.create==="function"){r.exports=function inherits(r,e){if(e){r.super_=e;r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}})}}}else{r.exports=function inherits(r,e){if(e){r.super_=e;var TempCtor=function(){};TempCtor.prototype=e.prototype;r.prototype=new TempCtor;r.prototype.constructor=r}}}},157:function(r){"use strict";var e=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var t=Object.prototype.toString;var n=function isArguments(r){if(e&&r&&typeof r==="object"&&Symbol.toStringTag in r){return false}return t.call(r)==="[object Arguments]"};var o=function isArguments(r){if(n(r)){return true}return r!==null&&typeof r==="object"&&typeof r.length==="number"&&r.length>=0&&t.call(r)!=="[object Array]"&&t.call(r.callee)==="[object Function]"};var i=function(){return n(arguments)}();n.isLegacyArguments=o;r.exports=i?n:o},391:function(r){"use strict";var e=Object.prototype.toString;var t=Function.prototype.toString;var n=/^\s*(?:function)?\*/;var o=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var i=Object.getPrototypeOf;var getGeneratorFunc=function(){if(!o){return false}try{return Function("return function*() {}")()}catch(r){}};var a=getGeneratorFunc();var f=a?i(a):{};r.exports=function isGeneratorFunction(r){if(typeof r!=="function"){return false}if(n.test(t.call(r))){return true}if(!o){var a=e.call(r);return a==="[object GeneratorFunction]"}return i(r)===f}},994:function(r,e,t){"use strict";var n=t(144);var o=t(349);var i=t(256);var a=i("Object.prototype.toString");var f=t(942)();var u=f&&typeof Symbol.toStringTag==="symbol";var s=o();var y=i("Array.prototype.indexOf",true)||function indexOf(r,e){for(var t=0;t-1}if(!l){return false}return b(r)}},369:function(r){r.exports=function isBuffer(r){return r instanceof Buffer}},584:function(r,e,t){"use strict";var n=t(157);var o=t(391);var i=t(490);var a=t(994);function uncurryThis(r){return r.call.bind(r)}var f=typeof BigInt!=="undefined";var u=typeof Symbol!=="undefined";var s=uncurryThis(Object.prototype.toString);var y=uncurryThis(Number.prototype.valueOf);var c=uncurryThis(String.prototype.valueOf);var p=uncurryThis(Boolean.prototype.valueOf);if(f){var l=uncurryThis(BigInt.prototype.valueOf)}if(u){var g=uncurryThis(Symbol.prototype.valueOf)}function checkBoxedPrimitive(r,e){if(typeof r!=="object"){return false}try{e(r);return true}catch(r){return false}}e.isArgumentsObject=n;e.isGeneratorFunction=o;e.isTypedArray=a;function isPromise(r){return typeof Promise!=="undefined"&&r instanceof Promise||r!==null&&typeof r==="object"&&typeof r.then==="function"&&typeof r.catch==="function"}e.isPromise=isPromise;function isArrayBufferView(r){if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){return ArrayBuffer.isView(r)}return a(r)||isDataView(r)}e.isArrayBufferView=isArrayBufferView;function isUint8Array(r){return i(r)==="Uint8Array"}e.isUint8Array=isUint8Array;function isUint8ClampedArray(r){return i(r)==="Uint8ClampedArray"}e.isUint8ClampedArray=isUint8ClampedArray;function isUint16Array(r){return i(r)==="Uint16Array"}e.isUint16Array=isUint16Array;function isUint32Array(r){return i(r)==="Uint32Array"}e.isUint32Array=isUint32Array;function isInt8Array(r){return i(r)==="Int8Array"}e.isInt8Array=isInt8Array;function isInt16Array(r){return i(r)==="Int16Array"}e.isInt16Array=isInt16Array;function isInt32Array(r){return i(r)==="Int32Array"}e.isInt32Array=isInt32Array;function isFloat32Array(r){return i(r)==="Float32Array"}e.isFloat32Array=isFloat32Array;function isFloat64Array(r){return i(r)==="Float64Array"}e.isFloat64Array=isFloat64Array;function isBigInt64Array(r){return i(r)==="BigInt64Array"}e.isBigInt64Array=isBigInt64Array;function isBigUint64Array(r){return i(r)==="BigUint64Array"}e.isBigUint64Array=isBigUint64Array;function isMapToString(r){return s(r)==="[object Map]"}isMapToString.working=typeof Map!=="undefined"&&isMapToString(new Map);function isMap(r){if(typeof Map==="undefined"){return false}return isMapToString.working?isMapToString(r):r instanceof Map}e.isMap=isMap;function isSetToString(r){return s(r)==="[object Set]"}isSetToString.working=typeof Set!=="undefined"&&isSetToString(new Set);function isSet(r){if(typeof Set==="undefined"){return false}return isSetToString.working?isSetToString(r):r instanceof Set}e.isSet=isSet;function isWeakMapToString(r){return s(r)==="[object WeakMap]"}isWeakMapToString.working=typeof WeakMap!=="undefined"&&isWeakMapToString(new WeakMap);function isWeakMap(r){if(typeof WeakMap==="undefined"){return false}return isWeakMapToString.working?isWeakMapToString(r):r instanceof WeakMap}e.isWeakMap=isWeakMap;function isWeakSetToString(r){return s(r)==="[object WeakSet]"}isWeakSetToString.working=typeof WeakSet!=="undefined"&&isWeakSetToString(new WeakSet);function isWeakSet(r){return isWeakSetToString(r)}e.isWeakSet=isWeakSet;function isArrayBufferToString(r){return s(r)==="[object ArrayBuffer]"}isArrayBufferToString.working=typeof ArrayBuffer!=="undefined"&&isArrayBufferToString(new ArrayBuffer);function isArrayBuffer(r){if(typeof ArrayBuffer==="undefined"){return false}return isArrayBufferToString.working?isArrayBufferToString(r):r instanceof ArrayBuffer}e.isArrayBuffer=isArrayBuffer;function isDataViewToString(r){return s(r)==="[object DataView]"}isDataViewToString.working=typeof ArrayBuffer!=="undefined"&&typeof DataView!=="undefined"&&isDataViewToString(new DataView(new ArrayBuffer(1),0,1));function isDataView(r){if(typeof DataView==="undefined"){return false}return isDataViewToString.working?isDataViewToString(r):r instanceof DataView}e.isDataView=isDataView;var b=typeof SharedArrayBuffer!=="undefined"?SharedArrayBuffer:undefined;function isSharedArrayBufferToString(r){return s(r)==="[object SharedArrayBuffer]"}function isSharedArrayBuffer(r){if(typeof b==="undefined"){return false}if(typeof isSharedArrayBufferToString.working==="undefined"){isSharedArrayBufferToString.working=isSharedArrayBufferToString(new b)}return isSharedArrayBufferToString.working?isSharedArrayBufferToString(r):r instanceof b}e.isSharedArrayBuffer=isSharedArrayBuffer;function isAsyncFunction(r){return s(r)==="[object AsyncFunction]"}e.isAsyncFunction=isAsyncFunction;function isMapIterator(r){return s(r)==="[object Map Iterator]"}e.isMapIterator=isMapIterator;function isSetIterator(r){return s(r)==="[object Set Iterator]"}e.isSetIterator=isSetIterator;function isGeneratorObject(r){return s(r)==="[object Generator]"}e.isGeneratorObject=isGeneratorObject;function isWebAssemblyCompiledModule(r){return s(r)==="[object WebAssembly.Module]"}e.isWebAssemblyCompiledModule=isWebAssemblyCompiledModule;function isNumberObject(r){return checkBoxedPrimitive(r,y)}e.isNumberObject=isNumberObject;function isStringObject(r){return checkBoxedPrimitive(r,c)}e.isStringObject=isStringObject;function isBooleanObject(r){return checkBoxedPrimitive(r,p)}e.isBooleanObject=isBooleanObject;function isBigIntObject(r){return f&&checkBoxedPrimitive(r,l)}e.isBigIntObject=isBigIntObject;function isSymbolObject(r){return u&&checkBoxedPrimitive(r,g)}e.isSymbolObject=isSymbolObject;function isBoxedPrimitive(r){return isNumberObject(r)||isStringObject(r)||isBooleanObject(r)||isBigIntObject(r)||isSymbolObject(r)}e.isBoxedPrimitive=isBoxedPrimitive;function isAnyArrayBuffer(r){return typeof Uint8Array!=="undefined"&&(isArrayBuffer(r)||isSharedArrayBuffer(r))}e.isAnyArrayBuffer=isAnyArrayBuffer;["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(r){Object.defineProperty(e,r,{enumerable:false,value:function(){throw new Error(r+" is not supported in userland")}})}))},177:function(r,e,t){var n=Object.getOwnPropertyDescriptors||function getOwnPropertyDescriptors(r){var e=Object.keys(r);var t={};for(var n=0;n=i)return r;switch(r){case"%s":return String(n[t++]);case"%d":return Number(n[t++]);case"%j":try{return JSON.stringify(n[t++])}catch(r){return"[Circular]"}default:return r}}));for(var f=n[t];t=3)n.depth=arguments[2];if(arguments.length>=4)n.colors=arguments[3];if(isBoolean(t)){n.showHidden=t}else if(t){e._extend(n,t)}if(isUndefined(n.showHidden))n.showHidden=false;if(isUndefined(n.depth))n.depth=2;if(isUndefined(n.colors))n.colors=false;if(isUndefined(n.customInspect))n.customInspect=true;if(n.colors)n.stylize=stylizeWithColor;return formatValue(n,r,n.depth)}e.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(r,e){var t=inspect.styles[e];if(t){return"["+inspect.colors[t][0]+"m"+r+"["+inspect.colors[t][1]+"m"}else{return r}}function stylizeNoColor(r,e){return r}function arrayToHash(r){var e={};r.forEach((function(r,t){e[r]=true}));return e}function formatValue(r,t,n){if(r.customInspect&&t&&isFunction(t.inspect)&&t.inspect!==e.inspect&&!(t.constructor&&t.constructor.prototype===t)){var o=t.inspect(n,r);if(!isString(o)){o=formatValue(r,o,n)}return o}var i=formatPrimitive(r,t);if(i){return i}var a=Object.keys(t);var f=arrayToHash(a);if(r.showHidden){a=Object.getOwnPropertyNames(t)}if(isError(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0)){return formatError(t)}if(a.length===0){if(isFunction(t)){var u=t.name?": "+t.name:"";return r.stylize("[Function"+u+"]","special")}if(isRegExp(t)){return r.stylize(RegExp.prototype.toString.call(t),"regexp")}if(isDate(t)){return r.stylize(Date.prototype.toString.call(t),"date")}if(isError(t)){return formatError(t)}}var s="",y=false,c=["{","}"];if(isArray(t)){y=true;c=["[","]"]}if(isFunction(t)){var p=t.name?": "+t.name:"";s=" [Function"+p+"]"}if(isRegExp(t)){s=" "+RegExp.prototype.toString.call(t)}if(isDate(t)){s=" "+Date.prototype.toUTCString.call(t)}if(isError(t)){s=" "+formatError(t)}if(a.length===0&&(!y||t.length==0)){return c[0]+s+c[1]}if(n<0){if(isRegExp(t)){return r.stylize(RegExp.prototype.toString.call(t),"regexp")}else{return r.stylize("[Object]","special")}}r.seen.push(t);var l;if(y){l=formatArray(r,t,n,f,a)}else{l=a.map((function(e){return formatProperty(r,t,n,f,e,y)}))}r.seen.pop();return reduceToSingleString(l,s,c)}function formatPrimitive(r,e){if(isUndefined(e))return r.stylize("undefined","undefined");if(isString(e)){var t="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return r.stylize(t,"string")}if(isNumber(e))return r.stylize(""+e,"number");if(isBoolean(e))return r.stylize(""+e,"boolean");if(isNull(e))return r.stylize("null","null")}function formatError(r){return"["+Error.prototype.toString.call(r)+"]"}function formatArray(r,e,t,n,o){var i=[];for(var a=0,f=e.length;a-1){if(i){f=f.split("\n").map((function(r){return" "+r})).join("\n").substr(2)}else{f="\n"+f.split("\n").map((function(r){return" "+r})).join("\n")}}}else{f=r.stylize("[Circular]","special")}}if(isUndefined(a)){if(i&&o.match(/^\d+$/)){return f}a=JSON.stringify(""+o);if(a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){a=a.substr(1,a.length-2);a=r.stylize(a,"name")}else{a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");a=r.stylize(a,"string")}}return a+": "+f}function reduceToSingleString(r,e,t){var n=0;var o=r.reduce((function(r,e){n++;if(e.indexOf("\n")>=0)n++;return r+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0);if(o>60){return t[0]+(e===""?"":e+"\n ")+" "+r.join(",\n ")+" "+t[1]}return t[0]+e+" "+r.join(", ")+" "+t[1]}e.types=t(584);function isArray(r){return Array.isArray(r)}e.isArray=isArray;function isBoolean(r){return typeof r==="boolean"}e.isBoolean=isBoolean;function isNull(r){return r===null}e.isNull=isNull;function isNullOrUndefined(r){return r==null}e.isNullOrUndefined=isNullOrUndefined;function isNumber(r){return typeof r==="number"}e.isNumber=isNumber;function isString(r){return typeof r==="string"}e.isString=isString;function isSymbol(r){return typeof r==="symbol"}e.isSymbol=isSymbol;function isUndefined(r){return r===void 0}e.isUndefined=isUndefined;function isRegExp(r){return isObject(r)&&objectToString(r)==="[object RegExp]"}e.isRegExp=isRegExp;e.types.isRegExp=isRegExp;function isObject(r){return typeof r==="object"&&r!==null}e.isObject=isObject;function isDate(r){return isObject(r)&&objectToString(r)==="[object Date]"}e.isDate=isDate;e.types.isDate=isDate;function isError(r){return isObject(r)&&(objectToString(r)==="[object Error]"||r instanceof Error)}e.isError=isError;e.types.isNativeError=isError;function isFunction(r){return typeof r==="function"}e.isFunction=isFunction;function isPrimitive(r){return r===null||typeof r==="boolean"||typeof r==="number"||typeof r==="string"||typeof r==="symbol"||typeof r==="undefined"}e.isPrimitive=isPrimitive;e.isBuffer=t(369);function objectToString(r){return Object.prototype.toString.call(r)}function pad(r){return r<10?"0"+r.toString(10):r.toString(10)}var u=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var r=new Date;var e=[pad(r.getHours()),pad(r.getMinutes()),pad(r.getSeconds())].join(":");return[r.getDate(),u[r.getMonth()],e].join(" ")}e.log=function(){console.log("%s - %s",timestamp(),e.format.apply(e,arguments))};e.inherits=t(782);e._extend=function(r,e){if(!e||!isObject(e))return r;var t=Object.keys(e);var n=t.length;while(n--){r[t[n]]=e[t[n]]}return r};function hasOwnProperty(r,e){return Object.prototype.hasOwnProperty.call(r,e)}var s=typeof Symbol!=="undefined"?Symbol("util.promisify.custom"):undefined;e.promisify=function promisify(r){if(typeof r!=="function")throw new TypeError('The "original" argument must be of type Function');if(s&&r[s]){var e=r[s];if(typeof e!=="function"){throw new TypeError('The "util.promisify.custom" argument must be of type Function')}Object.defineProperty(e,s,{value:e,enumerable:false,writable:false,configurable:true});return e}function e(){var e,t;var n=new Promise((function(r,n){e=r;t=n}));var o=[];for(var i=0;i= 0.4' } dependencies: call-bind: 1.0.2 - define-properties: 1.1.3 - es-abstract: 1.19.1 + define-properties: 1.1.4 + es-abstract: 1.20.2 + get-intrinsic: 1.1.1 + is-string: 1.0.7 + + /array-includes/3.1.5: + resolution: + { + integrity: sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ==, + } + engines: { node: '>= 0.4' } + dependencies: + call-bind: 1.0.2 + define-properties: 1.1.4 + es-abstract: 1.20.2 get-intrinsic: 1.1.1 is-string: 1.0.7 @@ -8815,8 +8828,8 @@ packages: engines: { node: '>= 0.4' } dependencies: call-bind: 1.0.2 - define-properties: 1.1.3 - es-abstract: 1.19.1 + define-properties: 1.1.4 + es-abstract: 1.20.2 /array.prototype.flatmap/1.2.5: resolution: @@ -8828,6 +8841,20 @@ packages: call-bind: 1.0.2 define-properties: 1.1.3 es-abstract: 1.19.1 + dev: true + + /array.prototype.flatmap/1.3.0: + resolution: + { + integrity: sha512-PZC9/8TKAIxcWKdyeb77EzULHPrIX/tIZebLJUQOMR1OwYosT8yggdfWScfTBCDj5utONvOuPQQumYsU2ULbkg==, + } + engines: { node: '>= 0.4' } + dependencies: + call-bind: 1.0.2 + define-properties: 1.1.4 + es-abstract: 1.20.2 + es-shim-unscopables: 1.0.0 + dev: false /arrify/1.0.1: resolution: @@ -10956,7 +10983,10 @@ packages: dev: true /concat-map/0.0.1: - resolution: { integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= } + resolution: + { + integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==, + } /concat-stream/1.6.2: resolution: @@ -12356,6 +12386,16 @@ packages: dependencies: object-keys: 1.1.1 + /define-properties/1.1.4: + resolution: + { + integrity: sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==, + } + engines: { node: '>= 0.4' } + dependencies: + has-property-descriptors: 1.0.0 + object-keys: 1.1.1 + /define-property/0.2.5: resolution: { @@ -13132,7 +13172,7 @@ packages: get-intrinsic: 1.1.1 get-symbol-description: 1.0.0 has: 1.0.3 - has-symbols: 1.0.2 + has-symbols: 1.0.3 internal-slot: 1.0.3 is-callable: 1.2.4 is-negative-zero: 2.0.1 @@ -13147,6 +13187,37 @@ packages: string.prototype.trimstart: 1.0.4 unbox-primitive: 1.0.1 + /es-abstract/1.20.2: + resolution: + { + integrity: sha512-XxXQuVNrySBNlEkTYJoDNFe5+s2yIOpzq80sUHEdPdQr0S5nTLz4ZPPPswNIpKseDDUS5yghX1gfLIHQZ1iNuQ==, + } + engines: { node: '>= 0.4' } + dependencies: + call-bind: 1.0.2 + es-to-primitive: 1.2.1 + function-bind: 1.1.1 + function.prototype.name: 1.1.5 + get-intrinsic: 1.1.2 + get-symbol-description: 1.0.0 + has: 1.0.3 + has-property-descriptors: 1.0.0 + has-symbols: 1.0.3 + internal-slot: 1.0.3 + is-callable: 1.2.4 + is-negative-zero: 2.0.2 + is-regex: 1.1.4 + is-shared-array-buffer: 1.0.2 + is-string: 1.0.7 + is-weakref: 1.0.2 + object-inspect: 1.12.2 + object-keys: 1.1.1 + object.assign: 4.1.4 + regexp.prototype.flags: 1.4.3 + string.prototype.trimend: 1.0.5 + string.prototype.trimstart: 1.0.5 + unbox-primitive: 1.0.2 + /es-module-lexer/0.9.0: resolution: { @@ -13154,6 +13225,15 @@ packages: } dev: true + /es-shim-unscopables/1.0.0: + resolution: + { + integrity: sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==, + } + dependencies: + has: 1.0.3 + dev: false + /es-to-primitive/1.2.1: resolution: { @@ -13545,17 +13625,17 @@ packages: string.prototype.matchall: 4.0.6 dev: true - /eslint-plugin-react/7.29.4_eslint@7.32.0: + /eslint-plugin-react/7.31.8_eslint@7.32.0: resolution: { - integrity: sha512-CVCXajliVh509PcZYRFyu/BoUEz452+jtQJq2b3Bae4v3xBUWPLCmtmBM+ZinG4MzwmxJgJ2M5rMqhqLVn7MtQ==, + integrity: sha512-5lBTZmgQmARLLSYiwI71tiGVTLUuqXantZM6vlSY39OaDSV0M7+32K5DnLkmFrwTe+Ksz0ffuLUC91RUviVZfw==, } engines: { node: '>=4' } peerDependencies: eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 dependencies: - array-includes: 3.1.4 - array.prototype.flatmap: 1.2.5 + array-includes: 3.1.5 + array.prototype.flatmap: 1.3.0 doctrine: 2.1.0 eslint: 7.32.0 estraverse: 5.3.0 @@ -13563,12 +13643,12 @@ packages: minimatch: 3.1.2 object.entries: 1.1.5 object.fromentries: 2.0.5 - object.hasown: 1.1.0 + object.hasown: 1.1.1 object.values: 1.1.5 prop-types: 15.8.1 resolve: 2.0.0-next.3 semver: 6.3.0 - string.prototype.matchall: 4.0.6 + string.prototype.matchall: 4.0.7 dev: false /eslint-scope/5.1.1: @@ -14881,12 +14961,30 @@ packages: integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==, } + /function.prototype.name/1.1.5: + resolution: + { + integrity: sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==, + } + engines: { node: '>= 0.4' } + dependencies: + call-bind: 1.0.2 + define-properties: 1.1.4 + es-abstract: 1.20.2 + functions-have-names: 1.2.3 + /functional-red-black-tree/1.0.1: resolution: { integrity: sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==, } + /functions-have-names/1.2.3: + resolution: + { + integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==, + } + /gauge/2.7.4: resolution: { @@ -14935,7 +15033,17 @@ packages: dependencies: function-bind: 1.1.1 has: 1.0.3 - has-symbols: 1.0.2 + has-symbols: 1.0.3 + + /get-intrinsic/1.1.2: + resolution: + { + integrity: sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==, + } + dependencies: + function-bind: 1.1.1 + has: 1.0.3 + has-symbols: 1.0.3 /get-orientation/1.1.2: resolution: @@ -15025,7 +15133,7 @@ packages: engines: { node: '>= 0.4' } dependencies: call-bind: 1.0.2 - get-intrinsic: 1.1.1 + get-intrinsic: 1.1.2 /get-value/2.0.6: resolution: @@ -15641,6 +15749,12 @@ packages: integrity: sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==, } + /has-bigints/1.0.2: + resolution: + { + integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==, + } + /has-flag/1.0.0: resolution: { @@ -15671,6 +15785,14 @@ packages: engines: { node: '>=8' } dev: true + /has-property-descriptors/1.0.0: + resolution: + { + integrity: sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==, + } + dependencies: + get-intrinsic: 1.1.1 + /has-symbol-support-x/1.4.2: resolution: { @@ -15684,6 +15806,14 @@ packages: integrity: sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==, } engines: { node: '>= 0.4' } + dev: true + + /has-symbols/1.0.3: + resolution: + { + integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==, + } + engines: { node: '>= 0.4' } /has-to-string-tag-x/1.4.1: resolution: @@ -15701,7 +15831,7 @@ packages: } engines: { node: '>= 0.4' } dependencies: - has-symbols: 1.0.2 + has-symbols: 1.0.3 /has-unicode/2.0.1: resolution: @@ -17127,6 +17257,13 @@ packages: } engines: { node: '>= 0.4' } + /is-negative-zero/2.0.2: + resolution: + { + integrity: sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==, + } + engines: { node: '>= 0.4' } + /is-npm/4.0.0: resolution: { @@ -17333,6 +17470,14 @@ packages: integrity: sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA==, } + /is-shared-array-buffer/1.0.2: + resolution: + { + integrity: sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==, + } + dependencies: + call-bind: 1.0.2 + /is-ssh/1.3.1: resolution: { @@ -17379,7 +17524,7 @@ packages: } engines: { node: '>= 0.4' } dependencies: - has-symbols: 1.0.2 + has-symbols: 1.0.3 /is-text-path/1.0.1: resolution: { integrity: sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4= } @@ -17456,6 +17601,14 @@ packages: dependencies: call-bind: 1.0.2 + /is-weakref/1.0.2: + resolution: + { + integrity: sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==, + } + dependencies: + call-bind: 1.0.2 + /is-whitespace-character/1.0.3: resolution: { @@ -18693,7 +18846,7 @@ packages: } engines: { node: '>=4.0' } dependencies: - array-includes: 3.1.4 + array-includes: 3.1.5 object.assign: 4.1.2 /jszip/3.7.1: @@ -21282,6 +21435,12 @@ packages: integrity: sha512-jp7ikS6Sd3GxQfZJPyH3cjcbJF6GZPClgdV+EFygjFLQ5FmW/dRUnTd9PQ9k0JhoNDabWFbpF1yCdSWCC6gexg==, } + /object-inspect/1.12.2: + resolution: + { + integrity: sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==, + } + /object-is/1.0.2: resolution: { @@ -21322,8 +21481,20 @@ packages: engines: { node: '>= 0.4' } dependencies: call-bind: 1.0.2 - define-properties: 1.1.3 - has-symbols: 1.0.2 + define-properties: 1.1.4 + has-symbols: 1.0.3 + object-keys: 1.1.1 + + /object.assign/4.1.4: + resolution: + { + integrity: sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==, + } + engines: { node: '>= 0.4' } + dependencies: + call-bind: 1.0.2 + define-properties: 1.1.4 + has-symbols: 1.0.3 object-keys: 1.1.1 /object.defaults/1.1.0: @@ -21344,8 +21515,8 @@ packages: engines: { node: '>= 0.4' } dependencies: call-bind: 1.0.2 - define-properties: 1.1.3 - es-abstract: 1.19.1 + define-properties: 1.1.4 + es-abstract: 1.20.2 /object.fromentries/2.0.5: resolution: @@ -21369,14 +21540,14 @@ packages: es-abstract: 1.19.1 dev: true - /object.hasown/1.1.0: + /object.hasown/1.1.1: resolution: { - integrity: sha512-MhjYRfj3GBlhSkDHo6QmvgjRLXQ2zndabdf3nX0yTyZK9rPfxb6uRpAac8HXNLy1GpqWtZ81Qh4v3uOls2sRAg==, + integrity: sha512-LYLe4tivNQzq4JdaWW6WO3HMZZJWzkkH8fnI6EebWl0VZth2wL2Lovm74ep2/gZzlaTdV62JZHEqHQ2yVn8Q/A==, } dependencies: - define-properties: 1.1.3 - es-abstract: 1.19.1 + define-properties: 1.1.4 + es-abstract: 1.20.2 dev: false /object.map/1.0.1: @@ -24738,6 +24909,18 @@ packages: dependencies: call-bind: 1.0.2 define-properties: 1.1.3 + dev: true + + /regexp.prototype.flags/1.4.3: + resolution: + { + integrity: sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==, + } + engines: { node: '>= 0.4' } + dependencies: + call-bind: 1.0.2 + define-properties: 1.1.4 + functions-have-names: 1.2.3 /regexpp/3.1.0: resolution: @@ -26617,6 +26800,23 @@ packages: internal-slot: 1.0.3 regexp.prototype.flags: 1.3.1 side-channel: 1.0.4 + dev: true + + /string.prototype.matchall/4.0.7: + resolution: + { + integrity: sha512-f48okCX7JiwVi1NXCVWcFnZgADDC/n2vePlQ/KUCNqCikLLilQvwjMO8+BHVKvgzH0JB0J9LEPgxOGT02RoETg==, + } + dependencies: + call-bind: 1.0.2 + define-properties: 1.1.3 + es-abstract: 1.19.1 + get-intrinsic: 1.1.1 + has-symbols: 1.0.3 + internal-slot: 1.0.3 + regexp.prototype.flags: 1.4.3 + side-channel: 1.0.4 + dev: false /string.prototype.padend/3.1.0: resolution: @@ -26636,7 +26836,17 @@ packages: } dependencies: call-bind: 1.0.2 - define-properties: 1.1.3 + define-properties: 1.1.4 + + /string.prototype.trimend/1.0.5: + resolution: + { + integrity: sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog==, + } + dependencies: + call-bind: 1.0.2 + define-properties: 1.1.4 + es-abstract: 1.20.2 /string.prototype.trimstart/1.0.4: resolution: @@ -26645,7 +26855,17 @@ packages: } dependencies: call-bind: 1.0.2 - define-properties: 1.1.3 + define-properties: 1.1.4 + + /string.prototype.trimstart/1.0.5: + resolution: + { + integrity: sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg==, + } + dependencies: + call-bind: 1.0.2 + define-properties: 1.1.4 + es-abstract: 1.20.2 /string_decoder/0.10.31: resolution: @@ -28138,7 +28358,18 @@ packages: dependencies: function-bind: 1.1.1 has-bigints: 1.0.1 - has-symbols: 1.0.2 + has-symbols: 1.0.3 + which-boxed-primitive: 1.0.2 + + /unbox-primitive/1.0.2: + resolution: + { + integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==, + } + dependencies: + call-bind: 1.0.2 + has-bigints: 1.0.2 + has-symbols: 1.0.3 which-boxed-primitive: 1.0.2 /unc-path-regex/0.1.2: From baf6046bf3c479e347af4b5fc123c840bf4240e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Tue, 13 Sep 2022 12:56:53 +0200 Subject: [PATCH 60/69] chore: use `link:` instead of `file:` in CONTRIBUTING.md (#40510) Closes #40497 Ref: https://pnpm.io/cli/link, https://stackoverflow.com/a/70266777 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) --- contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributing.md b/contributing.md index b3ec843cf2e7..e5403bdef11b 100644 --- a/contributing.md +++ b/contributing.md @@ -147,7 +147,7 @@ There are two options to develop with your local version of the codebase: with: ```json - "next": "file:/path/to/next.js/packages/next", + "next": "link:/path/to/next.js/packages/next", ``` 2. In your app's root directory, make sure to remove `next` from `node_modules` with: From c11310b0f152c1aef20016c6dc0e2833c35badcf Mon Sep 17 00:00:00 2001 From: Jan Klimo Date: Tue, 13 Sep 2022 13:22:25 +0200 Subject: [PATCH 61/69] Fix a typo in docs (#40501) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) Co-authored-by: Balázs Orbán --- errors/invalid-page-config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/errors/invalid-page-config.md b/errors/invalid-page-config.md index c9feeb38dbaa..a535a29056c7 100644 --- a/errors/invalid-page-config.md +++ b/errors/invalid-page-config.md @@ -7,7 +7,7 @@ In one of your pages or API Routes you did `export const config` with an invalid #### Possible Ways to Fix It The page's config must be an object initialized directly when being exported and not modified dynamically. -The config object must only contains static constant literals without expressions. +The config object must only contain static constant literals without expressions. From e6ed8ef56e93e8ff516b8c750a6f227a43137e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Tue, 13 Sep 2022 13:23:03 +0200 Subject: [PATCH 62/69] =?UTF-8?q?add=20Bal=C3=A1zs=20as=20codeowner=20to?= =?UTF-8?q?=20`/errors/`=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ref: #40501 --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b601a1f32f53..eacdc887f86c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4,6 +4,7 @@ * @timneutkens @ijjk @shuding @huozhi /.github/ @timneutkens @ijjk @shuding @styfle @huozhi @padmaia @balazsorban44 /docs/ @timneutkens @ijjk @shuding @styfle @huozhi @padmaia @leerob @balazsorban44 +/errors/ @balazsorban44 /examples/ @timneutkens @ijjk @shuding @leerob @steven-tey @balazsorban44 # SWC Build & Telemetry (@padmaia) From 629c7f584ebbb8d651441e111c1a5919d4248e73 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 13 Sep 2022 13:47:20 +0200 Subject: [PATCH 63/69] Clean up startTransition in Link (#40505) - Use React.startTransition instead of useTransition - Upgrade to latest React experimental - Split router cache invalidate into separate function Some minor cleanup while verifying behaviors. --- package.json | 4 +- packages/next/client/components/reducer.ts | 44 +++++++++++++++------- packages/next/client/link.tsx | 19 +++------- pnpm-lock.yaml | 24 ++++++------ 4 files changed, 50 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index bfab57a860fc..a0c2544af4b4 100644 --- a/package.json +++ b/package.json @@ -178,8 +178,8 @@ "react-17": "npm:react@17.0.2", "react-dom": "18.2.0", "react-dom-17": "npm:react-dom@17.0.2", - "react-dom-exp": "npm:react-dom@0.0.0-experimental-7028ce745-20220907", - "react-exp": "npm:react@0.0.0-experimental-7028ce745-20220907", + "react-dom-exp": "npm:react-dom@0.0.0-experimental-c739cef2f-20220912", + "react-exp": "npm:react@0.0.0-experimental-c739cef2f-20220912", "react-ssr-prepass": "1.0.8", "react-virtualized": "9.22.3", "relay-compiler": "13.0.2", diff --git a/packages/next/client/components/reducer.ts b/packages/next/client/components/reducer.ts index 90c081d2f059..f4b013528ceb 100644 --- a/packages/next/client/components/reducer.ts +++ b/packages/next/client/components/reducer.ts @@ -9,6 +9,31 @@ import type { import { matchSegment } from './match-segments' import { fetchServerResponse } from './app-router.client' +/** + * Invalidate cache one level down from the router state. + */ +// TODO-APP: Verify if this needs to be recursive. +function invalidateCacheByRouterState( + newCache: CacheNode, + existingCache: CacheNode, + routerState: FlightRouterState +) { + // Remove segment that we got data for so that it is filled in during rendering of subTreeData. + for (const key in routerState[1]) { + const segmentForParallelRoute = routerState[1][key][0] + const cacheKey = Array.isArray(segmentForParallelRoute) + ? segmentForParallelRoute[1] + : segmentForParallelRoute + const existingParallelRoutesCacheNode = + existingCache.parallelRoutes.get(key) + if (existingParallelRoutesCacheNode) { + let parallelRouteCacheNode = new Map(existingParallelRoutesCacheNode) + parallelRouteCacheNode.delete(cacheKey) + newCache.parallelRoutes.set(key, parallelRouteCacheNode) + } + } +} + /** * Fill cache with subTreeData based on flightDataPath */ @@ -56,19 +81,12 @@ function fillCacheWithNewSubTreeData( : new Map(), } - // Remove segment that we got data for so that it is filled in during rendering of subTreeData. - for (const key in flightDataPath[2][1]) { - const segmentForParallelRoute = flightDataPath[2][1][key][0] - const cacheKey = Array.isArray(segmentForParallelRoute) - ? segmentForParallelRoute[1] - : segmentForParallelRoute - const existingParallelRoutesCacheNode = - existingChildCacheNode?.parallelRoutes.get(key) - if (existingParallelRoutesCacheNode) { - let parallelRouteCacheNode = new Map(existingParallelRoutesCacheNode) - parallelRouteCacheNode.delete(cacheKey) - childCacheNode.parallelRoutes.set(key, parallelRouteCacheNode) - } + if (existingChildCacheNode) { + invalidateCacheByRouterState( + childCacheNode, + existingChildCacheNode, + flightDataPath[2] + ) } childSegmentMap.set(segmentForCache, childCacheNode) diff --git a/packages/next/client/link.tsx b/packages/next/client/link.tsx index 26ed48d1404c..805dd857bdab 100644 --- a/packages/next/client/link.tsx +++ b/packages/next/client/link.tsx @@ -16,9 +16,6 @@ import { useIntersection } from './use-intersection' import { getDomainLocale } from './get-domain-locale' import { addBasePath } from './add-base-path' -// @ts-ignore useTransition exist -const hasUseTransition = typeof React.useTransition !== 'undefined' - type Url = string | UrlObject type RequiredKeys = { [K in keyof T]-?: {} extends Pick ? never : K @@ -110,7 +107,7 @@ function linkClicked( shallow?: boolean, scroll?: boolean, locale?: string | false, - startTransition?: (cb: any) => void, + isAppRouter?: boolean, prefetchEnabled?: boolean ): void { const { nodeName } = e.currentTarget @@ -141,8 +138,9 @@ function linkClicked( } } - if (startTransition) { - startTransition(navigate) + if (isAppRouter) { + // @ts-expect-error startTransition exists. + React.startTransition(navigate) } else { navigate() } @@ -305,13 +303,6 @@ const Link = React.forwardRef( } const p = prefetchProp !== false - const [, /* isPending */ startTransition] = hasUseTransition - ? // Rules of hooks is disabled here because the useTransition will always exist with React 18. - // There is no difference between renders in this case, only between using React 18 vs 17. - // @ts-ignore useTransition exists - // eslint-disable-next-line react-hooks/rules-of-hooks - React.useTransition() - : [] let router = React.useContext(RouterContext) // TODO-APP: type error. Remove `as any` @@ -442,7 +433,7 @@ const Link = React.forwardRef( shallow, scroll, locale, - appRouter ? startTransition : undefined, + Boolean(appRouter), p ) } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f9da48226515..8bb382bf1ae0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -140,8 +140,8 @@ importers: react-17: npm:react@17.0.2 react-dom: 18.2.0 react-dom-17: npm:react-dom@17.0.2 - react-dom-exp: npm:react-dom@0.0.0-experimental-7028ce745-20220907 - react-exp: npm:react@0.0.0-experimental-7028ce745-20220907 + react-dom-exp: npm:react-dom@0.0.0-experimental-c739cef2f-20220912 + react-exp: npm:react@0.0.0-experimental-c739cef2f-20220912 react-ssr-prepass: 1.0.8 react-virtualized: 9.22.3 relay-compiler: 13.0.2 @@ -295,8 +295,8 @@ importers: react-17: /react/17.0.2 react-dom: 18.2.0_react@18.2.0 react-dom-17: /react-dom/17.0.2_react@18.2.0 - react-dom-exp: /react-dom/0.0.0-experimental-7028ce745-20220907_react@18.2.0 - react-exp: /react/0.0.0-experimental-7028ce745-20220907 + react-dom-exp: /react-dom/0.0.0-experimental-c739cef2f-20220912_react@18.2.0 + react-exp: /react/0.0.0-experimental-c739cef2f-20220912 react-ssr-prepass: 1.0.8_qncsgtzehe3fgiqp6tr7lwq6fm react-virtualized: 9.22.3_biqbaboplfbrettd7655fr4n2y relay-compiler: 13.0.2 @@ -24369,17 +24369,17 @@ packages: strip-json-comments: 2.0.1 dev: true - /react-dom/0.0.0-experimental-7028ce745-20220907_react@18.2.0: + /react-dom/0.0.0-experimental-c739cef2f-20220912_react@18.2.0: resolution: { - integrity: sha512-vNt0UKStPB47hPjpk6I1JEnxjl3vb0VItCtpZolzcNtYlMyfDmZFInh6IGiMtfBpm6Fp1LCztfopAnuiYoEb3Q==, + integrity: sha512-RbKxCHjX+H/n9yRvB2LFVhHUsFxWOiOlnhSGQ/JO45odUVreNVw0W7hez3biBF1r32f+0dp8RDVfvvKcF1sQyg==, } peerDependencies: - react: 0.0.0-experimental-7028ce745-20220907 + react: 0.0.0-experimental-c739cef2f-20220912 dependencies: loose-envify: 1.4.0 react: 18.2.0 - scheduler: 0.0.0-experimental-7028ce745-20220907 + scheduler: 0.0.0-experimental-c739cef2f-20220912 dev: true /react-dom/17.0.2_react@18.2.0: @@ -24493,10 +24493,10 @@ packages: react-lifecycles-compat: 3.0.4 dev: true - /react/0.0.0-experimental-7028ce745-20220907: + /react/0.0.0-experimental-c739cef2f-20220912: resolution: { - integrity: sha512-GJkc7NNWnUV7imij/n8YxJTQEY+OsE8qSmHB4esfFV/Gdi5zFOtzXr9LEB8CItAIoIpZ0eK1LXcOAO3cenDzLQ==, + integrity: sha512-K3T+R0lw7LzA3HSPHtI4CIYXw6tXKV5ewvuvuY7vfom/0rDvgoUkWHpdkykFUiEaShMKrQyeK6+faq41LeucKA==, } engines: { node: '>=0.10.0' } dependencies: @@ -25838,10 +25838,10 @@ packages: xmlchars: 2.2.0 dev: true - /scheduler/0.0.0-experimental-7028ce745-20220907: + /scheduler/0.0.0-experimental-c739cef2f-20220912: resolution: { - integrity: sha512-vmk4QI8sXQYFk7rtB9omwlsyNOhdsai4BKvud+XE+CfZuI5iTV+Nzj2EQq19PcfS7cmf1UOQ83wgv4yGgsefUQ==, + integrity: sha512-6HcdQoIp5PENl8IWJfCkIHcMx9Z+PVYxiTzFURS58bdkYhF8vsl65w/z6dpq6Ii/05miYi16VzrLc9T61EmexQ==, } dependencies: loose-envify: 1.4.0 From 814144af7f3a6e760634896924692a29b8bc3ee4 Mon Sep 17 00:00:00 2001 From: hiro Date: Tue, 13 Sep 2022 20:53:55 +0900 Subject: [PATCH 64/69] update(examples): Emotion modules (#40242) ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) --- examples/with-emotion-swc/package.json | 4 ++-- examples/with-emotion-vanilla/package.json | 6 +++--- examples/with-emotion/package.json | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/with-emotion-swc/package.json b/examples/with-emotion-swc/package.json index 89f0df6f3f3a..cd16c715d0b1 100644 --- a/examples/with-emotion-swc/package.json +++ b/examples/with-emotion-swc/package.json @@ -6,8 +6,8 @@ "start": "next start" }, "dependencies": { - "@emotion/react": "11.9.3", - "@emotion/styled": "11.9.3", + "@emotion/react": "11.10.4", + "@emotion/styled": "11.10.4", "next": "latest", "react": "18.2.0", "react-dom": "18.2.0" diff --git a/examples/with-emotion-vanilla/package.json b/examples/with-emotion-vanilla/package.json index 3a0c6ed052b4..904d9083f852 100644 --- a/examples/with-emotion-vanilla/package.json +++ b/examples/with-emotion-vanilla/package.json @@ -6,11 +6,11 @@ "start": "next start" }, "devDependencies": { - "@emotion/babel-plugin": "11.0.0" + "@emotion/babel-plugin": "11.10.2" }, "dependencies": { - "@emotion/css": "11.0.0", - "@emotion/server": "11.0.0", + "@emotion/css": "11.10.0", + "@emotion/server": "11.10.0", "next": "latest", "react": "^17.0.2", "react-dom": "^17.0.2" diff --git a/examples/with-emotion/package.json b/examples/with-emotion/package.json index 2cad72a46681..b9445b646b19 100644 --- a/examples/with-emotion/package.json +++ b/examples/with-emotion/package.json @@ -6,11 +6,11 @@ "start": "next start" }, "devDependencies": { - "@emotion/babel-plugin": "11.0.0" + "@emotion/babel-plugin": "11.10.2" }, "dependencies": { - "@emotion/react": "11.1.1", - "@emotion/styled": "11.0.0", + "@emotion/react": "11.10.4", + "@emotion/styled": "11.10.4", "next": "latest", "react": "^17.0.2", "react-dom": "^17.0.2" From 260ea550e07a753310c2ec998ad367d2461595b6 Mon Sep 17 00:00:00 2001 From: Steven Tey Date: Tue, 13 Sep 2022 05:21:05 -0700 Subject: [PATCH 65/69] Added comments to middleware-matcher example (#40273) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com> --- examples/middleware-matcher/middleware.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/middleware-matcher/middleware.js b/examples/middleware-matcher/middleware.js index 2d555ddfa773..a14196a4ccf3 100644 --- a/examples/middleware-matcher/middleware.js +++ b/examples/middleware-matcher/middleware.js @@ -11,5 +11,8 @@ export default function middleware(req) { } export const config = { - matcher: ['/public/disclaimer', '/((?!public|static).*)'], + matcher: [ + '/disclaimer', // match a single, specific page + '/((?!public|static).*)', // match all paths not starting with 'public' or 'static' + ], } From 3cf7a30df92d8885daaec215c16fc2f22e8efc29 Mon Sep 17 00:00:00 2001 From: Sukka Date: Tue, 13 Sep 2022 22:39:52 +0800 Subject: [PATCH 66/69] docs(README): next.js logo with dark mode (#40223) This PR follows #40181, adding the dark mode support for the brand new Next.js logo (BTW, the new logo is awesome!). The dark version of the logo is also served from `assets.vercel.com` (I just change the original logo URL, replace the `light` with `dark`, and surprisingly find out that doesn't result in 404). cc @Nutlope @steven-tey Ref: [Specify theme context for images in Markdown (Beta) - GitHub Blog](https://github.blog/changelog/2022-05-19-specify-theme-context-for-images-in-markdown-beta/) Currently, the Next.js README in dark mode: image After the PR: image Preview link: https://github.com/SukkaW/next.js/tree/readme-logo-darkmode --- packages/next/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/next/README.md b/packages/next/README.md index 824aab204216..a156ba206dca 100644 --- a/packages/next/README.md +++ b/packages/next/README.md @@ -1,6 +1,9 @@

- + + + +

Next.js

From a4ff04124290081939452167d84ada0d69cce0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Tue, 13 Sep 2022 22:51:44 +0200 Subject: [PATCH 67/69] fix(cli): tune filter for extracting example `.tar` (#40513) As pointed out in https://github.com/vercel/next.js/issues/40389#issuecomment-1243039792, the `filter` matched more files than necessary and merged different example directories together. This change makes the filter match the example directory name precisely. Fixes #40389 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) --- packages/create-next-app/helpers/examples.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-next-app/helpers/examples.ts b/packages/create-next-app/helpers/examples.ts index 961199628d3e..06fef57d27b1 100644 --- a/packages/create-next-app/helpers/examples.ts +++ b/packages/create-next-app/helpers/examples.ts @@ -122,7 +122,7 @@ export async function downloadAndExtractExample(root: string, name: string) { file: tempFile, cwd: root, strip: 3, - filter: (p) => p.includes(`next.js-canary/examples/${name}`), + filter: (p) => p.includes(`next.js-canary/examples/${name}/`), }) await fs.unlink(tempFile) From 69d0e6082caa5b3130c9b0b28de9efd2ec7e5773 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Tue, 13 Sep 2022 23:42:09 +0200 Subject: [PATCH 68/69] Passing down original sourcemap for flight client loader (#40508) Consume the original sourcemap in flight client loader if there's any, to avoid source map is generated based on the module proxy which make debugging hard Testing with adding `debugger` in layout router, screenshot: image --- .../webpack/loaders/next-flight-client-loader/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/next/build/webpack/loaders/next-flight-client-loader/index.ts b/packages/next/build/webpack/loaders/next-flight-client-loader/index.ts index 6c27a5a49f2d..f36ed00d6dfb 100644 --- a/packages/next/build/webpack/loaders/next-flight-client-loader/index.ts +++ b/packages/next/build/webpack/loaders/next-flight-client-loader/index.ts @@ -16,12 +16,14 @@ function containsPath(parent: string, child: string) { export default async function transformSource( this: any, - source: string -): Promise { + source: string, + map: any +) { if (typeof source !== 'string') { throw new Error('Expected source to have been transformed to a string.') } + const callback = this.async() const appDir = path.join(this.rootContext, 'app') const isUnderAppDir = containsPath(appDir, this.resourcePath) const filename = path.basename(this.resourcePath) @@ -50,5 +52,7 @@ export default async function transformSource( const { createProxy } = require("next/dist/build/webpack/loaders/next-flight-client-loader/module-proxy")\n module.exports = createProxy(${JSON.stringify(this.resourcePath)}) ` - return output + // Pass empty sourcemap + callback(null, output, map) + return } From eadaca780b57a561e13200078d5b0626e69af633 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Wed, 14 Sep 2022 01:01:43 +0200 Subject: [PATCH 69/69] Add additional tests for prefetch and trailingSlash (#40517) Adds some of the tests we didn't have yet for app. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples) --- .../app/dashboard/layout.server.js | 4 +- .../app-prefetch/app/dashboard/page.server.js | 2 +- .../app-dir/app-prefetch/app/page.server.js | 4 +- test/e2e/app-dir/index.test.ts | 10 +-- test/e2e/app-dir/prefetching.test.ts | 57 ++++++++++++++++ test/e2e/app-dir/rendering.test.ts | 7 +- test/e2e/app-dir/rsc-basic.test.ts | 9 +-- test/e2e/app-dir/trailingslash.test.ts | 66 +++++++++++++++++++ .../trailingslash/app/a/page.server.js | 9 +++ .../trailingslash/app/layout.server.js | 10 +++ .../app-dir/trailingslash/app/page.server.js | 12 ++++ test/e2e/app-dir/trailingslash/next.config.js | 9 +++ 12 files changed, 172 insertions(+), 27 deletions(-) create mode 100644 test/e2e/app-dir/prefetching.test.ts create mode 100644 test/e2e/app-dir/trailingslash.test.ts create mode 100644 test/e2e/app-dir/trailingslash/app/a/page.server.js create mode 100644 test/e2e/app-dir/trailingslash/app/layout.server.js create mode 100644 test/e2e/app-dir/trailingslash/app/page.server.js create mode 100644 test/e2e/app-dir/trailingslash/next.config.js diff --git a/test/e2e/app-dir/app-prefetch/app/dashboard/layout.server.js b/test/e2e/app-dir/app-prefetch/app/dashboard/layout.server.js index 84ebbb490d40..8c83d8e7a216 100644 --- a/test/e2e/app-dir/app-prefetch/app/dashboard/layout.server.js +++ b/test/e2e/app-dir/app-prefetch/app/dashboard/layout.server.js @@ -1,5 +1,5 @@ export async function getServerSideProps() { - await new Promise((resolve) => setTimeout(resolve, 2000)) + await new Promise((resolve) => setTimeout(resolve, 400)) return { props: { message: 'Hello World', @@ -9,7 +9,7 @@ export async function getServerSideProps() { export default function DashboardLayout({ children, message }) { return ( <> -

Dashboard {message}

+

Dashboard {message}

{children} ) diff --git a/test/e2e/app-dir/app-prefetch/app/dashboard/page.server.js b/test/e2e/app-dir/app-prefetch/app/dashboard/page.server.js index d22dfdf51e84..5171e25e542d 100644 --- a/test/e2e/app-dir/app-prefetch/app/dashboard/page.server.js +++ b/test/e2e/app-dir/app-prefetch/app/dashboard/page.server.js @@ -9,7 +9,7 @@ export async function getServerSideProps() { export default function DashboardPage({ message }) { return ( <> -

{message}

+

{message}

) } diff --git a/test/e2e/app-dir/app-prefetch/app/page.server.js b/test/e2e/app-dir/app-prefetch/app/page.server.js index 5cb37da2ad8a..be3690c6321b 100644 --- a/test/e2e/app-dir/app-prefetch/app/page.server.js +++ b/test/e2e/app-dir/app-prefetch/app/page.server.js @@ -2,7 +2,9 @@ import Link from 'next/link' export default function HomePage() { return ( <> - To Dashboard + + To Dashboard + ) } diff --git a/test/e2e/app-dir/index.test.ts b/test/e2e/app-dir/index.test.ts index 6af635e765ed..0bf456d2dbdc 100644 --- a/test/e2e/app-dir/index.test.ts +++ b/test/e2e/app-dir/index.test.ts @@ -23,15 +23,7 @@ describe('app dir', () => { function runTests({ assetPrefix }: { assetPrefix?: boolean }) { beforeAll(async () => { next = await createNext({ - files: { - public: new FileRef(path.join(__dirname, 'app/public')), - styles: new FileRef(path.join(__dirname, 'app/styles')), - pages: new FileRef(path.join(__dirname, 'app/pages')), - app: new FileRef(path.join(__dirname, 'app/app')), - 'next.config.js': new FileRef( - path.join(__dirname, 'app/next.config.js') - ), - }, + files: new FileRef(path.join(__dirname, 'app')), dependencies: { react: 'experimental', 'react-dom': 'experimental', diff --git a/test/e2e/app-dir/prefetching.test.ts b/test/e2e/app-dir/prefetching.test.ts new file mode 100644 index 000000000000..5f9f6bdb5474 --- /dev/null +++ b/test/e2e/app-dir/prefetching.test.ts @@ -0,0 +1,57 @@ +import { createNext, FileRef } from 'e2e-utils' +import { NextInstance } from 'test/lib/next-modes/base' +import { waitFor } from 'next-test-utils' +import path from 'path' +import webdriver from 'next-webdriver' + +describe('app dir prefetching', () => { + if ((global as any).isNextDeploy) { + it('should skip next deploy for now', () => {}) + return + } + + if (process.env.NEXT_TEST_REACT_VERSION === '^17') { + it('should skip for react v17', () => {}) + return + } + let next: NextInstance + + beforeAll(async () => { + next = await createNext({ + files: new FileRef(path.join(__dirname, 'app-prefetch')), + dependencies: { + react: 'experimental', + 'react-dom': 'experimental', + }, + skipStart: true, + }) + await next.start() + }) + afterAll(() => next.destroy()) + + it('should show layout eagerly when prefetched with loading one level down', async () => { + const browser = await webdriver(next.url, '/') + // Ensure the page is prefetched + await waitFor(1000) + + const before = Date.now() + await browser + .elementByCss('#to-dashboard') + .click() + .waitForElementByCss('#dashboard-layout') + const after = Date.now() + const timeToComplete = after - before + + expect(timeToComplete < 1000).toBe(true) + + expect(await browser.elementByCss('#dashboard-layout').text()).toBe( + 'Dashboard Hello World' + ) + + await browser.waitForElementByCss('#dashboard-page') + + expect(await browser.waitForElementByCss('#dashboard-page').text()).toBe( + 'Welcome to the dashboard' + ) + }) +}) diff --git a/test/e2e/app-dir/rendering.test.ts b/test/e2e/app-dir/rendering.test.ts index 69f1f0dd3859..d7168bcd275d 100644 --- a/test/e2e/app-dir/rendering.test.ts +++ b/test/e2e/app-dir/rendering.test.ts @@ -20,12 +20,7 @@ describe('app dir rendering', () => { beforeAll(async () => { next = await createNext({ - files: { - app: new FileRef(path.join(__dirname, 'app-rendering/app')), - 'next.config.js': new FileRef( - path.join(__dirname, 'app-rendering/next.config.js') - ), - }, + files: new FileRef(path.join(__dirname, 'app-rendering')), dependencies: { react: 'experimental', 'react-dom': 'experimental', diff --git a/test/e2e/app-dir/rsc-basic.test.ts b/test/e2e/app-dir/rsc-basic.test.ts index 0debb6818399..e548c458445f 100644 --- a/test/e2e/app-dir/rsc-basic.test.ts +++ b/test/e2e/app-dir/rsc-basic.test.ts @@ -35,15 +35,8 @@ describe('app dir - react server components', () => { } beforeAll(async () => { - const appDir = path.join(__dirname, './rsc-basic') next = await createNext({ - files: { - node_modules_bak: new FileRef(path.join(appDir, 'node_modules_bak')), - public: new FileRef(path.join(appDir, 'public')), - components: new FileRef(path.join(appDir, 'components')), - app: new FileRef(path.join(appDir, 'app')), - 'next.config.js': new FileRef(path.join(appDir, 'next.config.js')), - }, + files: new FileRef(path.join(__dirname, './rsc-basic')), dependencies: { 'styled-components': '6.0.0-alpha.5', react: 'experimental', diff --git a/test/e2e/app-dir/trailingslash.test.ts b/test/e2e/app-dir/trailingslash.test.ts new file mode 100644 index 000000000000..0b8ca82f7553 --- /dev/null +++ b/test/e2e/app-dir/trailingslash.test.ts @@ -0,0 +1,66 @@ +import { createNext, FileRef } from 'e2e-utils' +import { NextInstance } from 'test/lib/next-modes/base' +import { fetchViaHTTP, renderViaHTTP } from 'next-test-utils' +import path from 'path' +import cheerio from 'cheerio' +import webdriver from 'next-webdriver' + +describe('app-dir trailingSlash handling', () => { + if ((global as any).isNextDeploy) { + it('should skip next deploy for now', () => {}) + return + } + + if (process.env.NEXT_TEST_REACT_VERSION === '^17') { + it('should skip for react v17', () => {}) + return + } + let next: NextInstance + + beforeAll(async () => { + next = await createNext({ + files: new FileRef(path.join(__dirname, 'trailingslash')), + dependencies: { + react: 'experimental', + 'react-dom': 'experimental', + }, + skipStart: true, + }) + + await next.start() + }) + afterAll(() => next.destroy()) + + it('should redirect route when requesting it directly', async () => { + const res = await fetchViaHTTP( + next.url, + '/a', + {}, + { + redirect: 'manual', + } + ) + expect(res.status).toBe(308) + expect(res.headers.get('location')).toBe(next.url + '/a/') + }) + + it('should render link with trailing slash', async () => { + const html = await renderViaHTTP(next.url, '/') + const $ = cheerio.load(html) + expect($('#to-a-trailing-slash').attr('href')).toBe('/a/') + }) + + it('should redirect route when requesting it directly by browser', async () => { + const browser = await webdriver(next.url, '/a') + expect(await browser.waitForElementByCss('#a-page').text()).toBe('A page') + }) + + it('should redirect route when clicking link', async () => { + const browser = await webdriver(next.url, '/') + await browser + .elementByCss('#to-a-trailing-slash') + .click() + .waitForElementByCss('#a-page') + expect(await browser.waitForElementByCss('#a-page').text()).toBe('A page') + }) +}) diff --git a/test/e2e/app-dir/trailingslash/app/a/page.server.js b/test/e2e/app-dir/trailingslash/app/a/page.server.js new file mode 100644 index 000000000000..d61256ee9f3d --- /dev/null +++ b/test/e2e/app-dir/trailingslash/app/a/page.server.js @@ -0,0 +1,9 @@ +import Link from 'next/link' +export default function HomePage() { + return ( + <> +

A page

+ To home + + ) +} diff --git a/test/e2e/app-dir/trailingslash/app/layout.server.js b/test/e2e/app-dir/trailingslash/app/layout.server.js new file mode 100644 index 000000000000..05b841b280b3 --- /dev/null +++ b/test/e2e/app-dir/trailingslash/app/layout.server.js @@ -0,0 +1,10 @@ +export default function Root({ children }) { + return ( + + + Hello + + {children} + + ) +} diff --git a/test/e2e/app-dir/trailingslash/app/page.server.js b/test/e2e/app-dir/trailingslash/app/page.server.js new file mode 100644 index 000000000000..f02fd1b341b1 --- /dev/null +++ b/test/e2e/app-dir/trailingslash/app/page.server.js @@ -0,0 +1,12 @@ +import Link from 'next/link' +export default function HomePage() { + return ( + <> +

+ + To a with trailing slash + +

+ + ) +} diff --git a/test/e2e/app-dir/trailingslash/next.config.js b/test/e2e/app-dir/trailingslash/next.config.js new file mode 100644 index 000000000000..a4194e110b51 --- /dev/null +++ b/test/e2e/app-dir/trailingslash/next.config.js @@ -0,0 +1,9 @@ +module.exports = { + experimental: { + appDir: true, + serverComponents: true, + legacyBrowsers: false, + browsersListForSwc: true, + }, + trailingSlash: true, +}