From 2efc944cb9e2670c24deb089b1567f8002c417ae Mon Sep 17 00:00:00 2001
From: David Brookton <19512437+brookton@users.noreply.github.com>
Date: Wed, 5 Jan 2022 11:25:00 -0700
Subject: [PATCH 01/22] (examples/with-next-translate) Removed Redundancies in
Strings (#29501)
## `with-next-translate` Example Refactor
- [x] Linting passes
## Purpose for changes
- The existing locals folder is using a redundant string structure which continuously repeats "Change language to " in separate instances in separate languages alongside separate language translations.
- This PR is a simple refactor to extract "change language to" to it's own string, and references already existing strings defining the language translation.
## Why they might be helpful
- A user looking to implement this pattern should consider reducing redundancies as early as possible to scale an app, thus I believe it would be helpful for this example.
Notes:
- these original translations were done via google translate
- verified that these strings still make sense and translate properly in every locale / language
- these strings are meant to be examples, translations have not been verified with a translation agency.
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
---
.../with-next-translate/locales/ar/home.json | 5 +----
.../with-next-translate/locales/ca/home.json | 5 +----
.../with-next-translate/locales/en/home.json | 5 +----
.../with-next-translate/locales/he/home.json | 5 +----
examples/with-next-translate/pages/index.js | 16 ++++++++++++----
5 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/examples/with-next-translate/locales/ar/home.json b/examples/with-next-translate/locales/ar/home.json
index 4543b416dda30dd..bfed894f65e73a9 100644
--- a/examples/with-next-translate/locales/ar/home.json
+++ b/examples/with-next-translate/locales/ar/home.json
@@ -1,10 +1,7 @@
{
"arabic": "العربية",
"catalan": "الكاتالونية",
- "change-arabic": "تغيير اللغة إلى العربية ",
- "change-catalan": "تغيير اللغة إلى الكتالانية",
- "change-english": "تغيير اللغة إلى اللغة الإنجليزية ",
- "change-hebrew": "تغيير اللغة إلى العبرية",
+ "change-to": "تغيير اللغة إلى",
"description": "ابدأ بالتعديل",
"english": "الإنجليزية",
"hebrew": "العبرية",
diff --git a/examples/with-next-translate/locales/ca/home.json b/examples/with-next-translate/locales/ca/home.json
index f7ec8cf75f40100..fc59aa86063900e 100644
--- a/examples/with-next-translate/locales/ca/home.json
+++ b/examples/with-next-translate/locales/ca/home.json
@@ -1,10 +1,7 @@
{
"arabic": "Àrab",
"catalan": "Català",
- "change-arabic": "Canvia a la versió en àrab",
- "change-catalan": "Canvia a la versió en català",
- "change-english": "Canvia a la versió en anglès",
- "change-hebrew": "Canvieu a la versió hebrea",
+ "change-to": "Canvieu a la versió en",
"description": "Comença editant",
"english": "Anglès",
"hebrew": "Hebreu",
diff --git a/examples/with-next-translate/locales/en/home.json b/examples/with-next-translate/locales/en/home.json
index 264dd02f23d99fc..83813a7c7853ae6 100644
--- a/examples/with-next-translate/locales/en/home.json
+++ b/examples/with-next-translate/locales/en/home.json
@@ -1,10 +1,7 @@
{
"arabic": "Arabic",
"catalan": "Catalan",
- "change-arabic": "Change language to Arabic",
- "change-catalan": "Change language to Catalan",
- "change-english": "Change language to English",
- "change-hebrew": "Change language to Hebrew",
+ "change-to": "Change language to",
"description": "Get started by editing",
"english": "English",
"hebrew": "Hebrew",
diff --git a/examples/with-next-translate/locales/he/home.json b/examples/with-next-translate/locales/he/home.json
index 3b5a275c66a261b..03be1023c97dab1 100644
--- a/examples/with-next-translate/locales/he/home.json
+++ b/examples/with-next-translate/locales/he/home.json
@@ -1,10 +1,7 @@
{
"arabic": "עֲרָבִית",
"catalan": "קטלאנית",
- "change-arabic": "שנה שפה לערבית",
- "change-catalan": "שנה שפה לקטלונית",
- "change-english": "שנה שפה לאנגלית",
- "change-hebrew": "שנה את השפה לעברית",
+ "change-to": "שנה את השפה ל",
"description": "התחל על ידי עריכה",
"english": "אנגלית",
"hebrew": "עִברִית",
diff --git a/examples/with-next-translate/pages/index.js b/examples/with-next-translate/pages/index.js
index ed065164e734d30..515026bf8572b2e 100644
--- a/examples/with-next-translate/pages/index.js
+++ b/examples/with-next-translate/pages/index.js
@@ -27,28 +27,36 @@ export default function Home() {
{t('home:english')}
-
{t('home:change-english')}
+
+ {t('home:change-to')} {t('home:english')}
+
{t('home:catalan')}
-
{t('home:change-catalan')}
+
+ {t('home:change-to')} {t('home:catalan')}
+
{t('home:arabic')}
-
{t('home:change-arabic')}
+
+ {t('home:change-to')} {t('home:arabic')}
+
{t('home:hebrew')}
-
{t('home:change-hebrew')}
+
+ {t('home:change-to')} {t('home:hebrew')}
+
From 626955d61c7d4d5e57c749cc2383fb5f8ad0b90d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?=
Date: Wed, 5 Jan 2022 20:40:04 +0100
Subject: [PATCH 02/22] fix: ensure revalidation error is logged from
response-cache (#32657)
Something [between `11.0.2-canary.5` and `11.0.2-canary.6`](https://github.com/vercel/next.js/compare/v11.0.2-canary.5...v11.0.2-canary.6) changed the behavior that logged any runtime errors in `getStaticProps` to stderr. This is only observable if `getStaticProps` has a `revalidate` value, and the build did not fail. The error has to happen in a subsequent revalidation step.
This PR reverts the change and fixes #30375.
## Bug
- [x] Related issues linked using `fixes #number`
- [x] 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 `yarn lint`
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
---
packages/next/server/response-cache.ts | 8 +++-
.../data-fetching-errors/test/index.test.js | 47 ++++++++++++++++++-
2 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/packages/next/server/response-cache.ts b/packages/next/server/response-cache.ts
index da10c8c3bd3457d..2279733e721e406 100644
--- a/packages/next/server/response-cache.ts
+++ b/packages/next/server/response-cache.ts
@@ -107,7 +107,13 @@ export default class ResponseCache {
)
}
} catch (err) {
- rejecter(err as Error)
+ // while revalidating in the background we can't reject as
+ // we already resolved the cache entry so log the error here
+ if (resolved) {
+ console.error(err)
+ } else {
+ rejecter(err as Error)
+ }
} finally {
if (key) {
this.pendingResponses.delete(key)
diff --git a/test/integration/data-fetching-errors/test/index.test.js b/test/integration/data-fetching-errors/test/index.test.js
index a04a6ac91857c15..611bdb75310b0ae 100644
--- a/test/integration/data-fetching-errors/test/index.test.js
+++ b/test/integration/data-fetching-errors/test/index.test.js
@@ -7,12 +7,15 @@ import {
launchApp,
nextBuild,
renderViaHTTP,
+ nextStart,
+ check,
} from 'next-test-utils'
import { join } from 'path'
import {
GSP_NO_RETURNED_VALUE,
GSSP_NO_RETURNED_VALUE,
} from '../../../../packages/next/dist/lib/constants'
+import { PHASE_PRODUCTION_BUILD } from '../../../../packages/next/shared/lib/constants'
const appDir = join(__dirname, '..')
const indexPage = join(appDir, 'pages/index.js')
@@ -130,7 +133,49 @@ describe('GS(S)P Page Errors', () => {
runTests(true)
})
- describe('production mode', () => {
+ describe('build mode', () => {
runTests()
})
+
+ describe('start mode', () => {
+ it('Error stack printed to stderr', async () => {
+ try {
+ await fs.writeFile(
+ indexPage,
+ `export default function Page() {
+ return
+ }
+ export function getStaticProps() {
+ // Make it pass on the build phase
+ if(process.env.NEXT_PHASE === "${PHASE_PRODUCTION_BUILD}") {
+ return { props: { foo: 'bar' }, revalidate: 1 }
+ }
+
+ throw new Error("Oops")
+ }
+ `
+ )
+
+ await nextBuild(appDir)
+
+ appPort = await findPort()
+
+ let stderr = ''
+ app = await nextStart(appDir, appPort, {
+ onStderr: (msg) => {
+ stderr += msg || ''
+ },
+ })
+ await check(async () => {
+ await renderViaHTTP(appPort, '/')
+ return stderr
+ }, /error: oops/i)
+
+ expect(stderr).toContain('Error: Oops')
+ expect(stderr).toContain(`\n at getStaticProps`)
+ } finally {
+ await killApp(app)
+ }
+ })
+ })
})
From 5680007fa220adf0f23133040e90cbb236d7da40 Mon Sep 17 00:00:00 2001
From: JJ Kasper
Date: Wed, 5 Jan 2022 13:49:39 -0600
Subject: [PATCH 03/22] v12.0.8-canary.18
---
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 +-
15 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/lerna.json b/lerna.json
index f975ce5a8ff8f84..44fbc60927cbe9f 100644
--- a/lerna.json
+++ b/lerna.json
@@ -17,5 +17,5 @@
"registry": "https://registry.npmjs.org/"
}
},
- "version": "12.0.8-canary.17"
+ "version": "12.0.8-canary.18"
}
diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json
index a095e220fc01396..80146dab41c1457 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.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"keywords": [
"react",
"next",
diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json
index 97a558e6f4a10e5..80365e26084bb10 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.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"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.0.8-canary.17",
+ "@next/eslint-plugin-next": "12.0.8-canary.18",
"@rushstack/eslint-patch": "^1.0.8",
"@typescript-eslint/parser": "^5.0.0",
"eslint-import-resolver-node": "^0.3.4",
diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json
index c25236678930aa5..4f19b355537779b 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.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"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 9f0b2fcb47532c5..51eee97b4502ba5 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.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"main": "index.js",
"license": "MIT",
"repository": {
diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json
index f4d5bbf559895ca..a38013bb2e6df1f 100644
--- a/packages/next-codemod/package.json
+++ b/packages/next-codemod/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
- "version": "12.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
diff --git a/packages/next-env/package.json b/packages/next-env/package.json
index 261cf3779041589..adf1d11f12e0316 100644
--- a/packages/next-env/package.json
+++ b/packages/next-env/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/env",
- "version": "12.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"keywords": [
"react",
"next",
diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json
index 10a51f853ae26ed..1641e387f002ce0 100644
--- a/packages/next-mdx/package.json
+++ b/packages/next-mdx/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
- "version": "12.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"main": "index.js",
"license": "MIT",
"repository": {
diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json
index 7792749f169c608..51cf53080b4a847 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.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"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 34924c34e3f155a..c0b657d5875164f 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.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"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 c7a2fc585bc0f9a..f3f50731507e17d 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.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"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 8da471a5622b10b..70bde1297b9b842 100644
--- a/packages/next-swc/package.json
+++ b/packages/next-swc/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
- "version": "12.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"private": true,
"scripts": {
"build-native": "napi build --platform --cargo-name next_swc_napi native",
diff --git a/packages/next/package.json b/packages/next/package.json
index e7442ee8955a374..a1b72957c4ffe7e 100644
--- a/packages/next/package.json
+++ b/packages/next/package.json
@@ -1,6 +1,6 @@
{
"name": "next",
- "version": "12.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
@@ -71,8 +71,8 @@
]
},
"dependencies": {
- "@next/env": "12.0.8-canary.17",
- "@next/react-refresh-utils": "12.0.8-canary.17",
+ "@next/env": "12.0.8-canary.18",
+ "@next/react-refresh-utils": "12.0.8-canary.18",
"caniuse-lite": "^1.0.30001283",
"jest-worker": "27.0.0-next.5",
"node-fetch": "2.6.1",
@@ -125,10 +125,10 @@
"@hapi/accept": "5.0.2",
"@napi-rs/cli": "1.2.1",
"@napi-rs/triples": "1.0.3",
- "@next/polyfill-module": "12.0.8-canary.17",
- "@next/polyfill-nomodule": "12.0.8-canary.17",
- "@next/react-dev-overlay": "12.0.8-canary.17",
- "@next/swc": "12.0.8-canary.17",
+ "@next/polyfill-module": "12.0.8-canary.18",
+ "@next/polyfill-nomodule": "12.0.8-canary.18",
+ "@next/react-dev-overlay": "12.0.8-canary.18",
+ "@next/swc": "12.0.8-canary.18",
"@peculiar/webcrypto": "1.1.7",
"@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 a22e41895c55c0d..4b5ea474ef3331e 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.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"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 447adca6df43df0..b982e299004cd49 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.0.8-canary.17",
+ "version": "12.0.8-canary.18",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
From 26ddf32f53f24dd4a56b10ee2b668aebe17cb6b1 Mon Sep 17 00:00:00 2001
From: Lee Robinson
Date: Wed, 5 Jan 2022 15:56:05 -0600
Subject: [PATCH 04/22] Update deployment documentation. (#32006)
Building off https://github.com/vercel/next.js/pull/31465 for `next export` docs.
- Clearly explains the standard output from `next build`
- Move Dockerfile snippet to example, instead of embedded directly
- Clarify both Vercel and `next start` use the Build API output spec
- Less emphasis on recommending Vercel (more neutrality)
- Mention Middleware & Edge Functions when discussing Vercel
- Add "Going to Production" link at the bottom for related reading
---
docs/deployment.md | 156 +++++++++++++++++----------------------------
1 file changed, 60 insertions(+), 96 deletions(-)
diff --git a/docs/deployment.md b/docs/deployment.md
index 91d806aa3881a38..8c0498ff95cab68 100644
--- a/docs/deployment.md
+++ b/docs/deployment.md
@@ -1,68 +1,67 @@
---
-description: Deploy your Next.js app to production with Vercel and other hosting options.
+description: Learn how to deploy your Next.js app to production, either managed or self-hosted.
---
# Deployment
-## Vercel (Recommended)
+Congratulations, you are ready to deploy your Next.js application to production. This document will show how to deploy either managed or self-hosted using the [Next.js Build API](#nextjs-build-api).
-The easiest way to deploy Next.js to production is to use the **[Vercel platform](https://vercel.com)** from the creators of Next.js. [Vercel](https://vercel.com) is a cloud platform for static sites, hybrid apps, and Serverless Functions.
+## Next.js Build API
-### Getting started
+`next build` generates an optimized version of your application for production. This standard output includes:
-If you haven’t already done so, push your Next.js app to a Git provider of your choice: [GitHub](https://github.com/), [GitLab](https://gitlab.com/), or [BitBucket](https://bitbucket.org/). Your repository can be private or public.
+- HTML files for pages using `getStaticProps` or [Automatic Static Optimization](/docs/advanced-features/automatic-static-optimization.md)
+- CSS files for global styles or for individually scoped styles
+- JavaScript for pre-rendering dynamic content from the Next.js server
+- JavaScript for interactivity on the client-side through React
-Then, follow these steps:
+This output is generated inside the `.next` folder:
-1. [Sign up to Vercel](https://vercel.com/signup) (no credit card is required).
-2. After signing up, you’ll arrive on the [“Import Project”](https://vercel.com/new) page. Under “From Git Repository”, choose the Git provider you use and set up an integration. (Instructions: [GitHub](https://vercel.com/docs/git/vercel-for-github) / [GitLab](https://vercel.com/docs/git/vercel-for-gitlab) / [BitBucket](https://vercel.com/docs/git/vercel-for-bitbucket)).
-3. Once that’s set up, click “Import Project From …” and import your Next.js app. It auto-detects that your app is using Next.js and sets up the build configuration for you. No need to change anything — everything should work fine!
-4. After importing, it’ll deploy your Next.js app and provide you with a deployment URL. Click “Visit” to see your app in production.
+- `.next/static/chunks/pages` – Each JavaScript file inside this folder relates to the route with the same name. For example, `.next/static/chunks/pages/about.js` would be the JavaScript file loaded when viewing the `/about` route in your application
+- `.next/static/media` – Statically imported images from `next/image` are hashed and copied here
+- `.next/static/css` – Global CSS files for all pages in your application
+- `.next/server/pages` – The HTML and JavaScript entry points prerendered from the server. The `.nft.json` files are created when [Output File Tracing](/docs/advanced-features/output-file-tracing.md) is enabled and contain all the file paths that depend on a given page.
+- `.next/server/chunks` – Shared JavaScript chunks used in multiple places throughout your application
+- `.next/cache` – Output for the build cache and cached images, responses, and pages from the Next.js server. Using a cache helps decrease build times and improve performance of loading images
-Congratulations! You’ve deployed your Next.js app! If you have questions, take a look at the [Vercel documentation](https://vercel.com/docs).
+All JavaScript code inside `.next` has been **compiled** and browser bundles have been **minified** to help achieve the best performance and support [all modern browsers](/docs/basic-features/supported-browsers-features.md).
-> If you’re using a [custom server](/docs/advanced-features/custom-server.md), we strongly recommend migrating away from it (for example, by using [dynamic routing](/docs/routing/dynamic-routes.md)). If you cannot migrate, consider [other hosting options](#other-hosting-options).
+## Managed Next.js with Vercel
-### DPS: Develop, Preview, Ship
+[Vercel](https://vercel.com/) is a frontend cloud platform from the creators of Next.js. It's the fastest way to deploy your managed Next.js application with zero configuration.
-Let’s talk about the workflow we recommend using. [Vercel](https://vercel.com) supports what we call the **DPS** workflow: **D**evelop, **P**review, and **S**hip:
+When deploying to Vercel, the platform automatically detects Next.js, runs `next build`, and optimizes the build output for you, including:
-- **Develop:** Write code in Next.js. Keep the development server running and take advantage of [React Fast Refresh](https://nextjs.org/blog/next-9-4#fast-refresh).
-- **Preview:** Every time you push changes to a branch on GitHub / GitLab / BitBucket, Vercel automatically creates a new deployment with a unique URL. You can view them on GitHub when you open a pull request, or under “Preview Deployments” on your project page on Vercel. [Learn more about it here](https://vercel.com/features/deployment-previews).
-- **Ship:** When you’re ready to ship, merge the pull request to your default branch (e.g. `main`). Vercel will automatically create a production deployment.
+- Persisting cached assets across deployments if unchanged
+- [Immutable deployments](https://vercel.com/features/previews) with a unique URL for every commit
+- [Pages](/docs/basic-features/pages.md) are automatically statically optimized, if possible
+- Assets (JavaScript, CSS, images, fonts) are compressed and served from a [Global Edge Network](https://vercel.com/features/infrastructure)
+- [API Routes](/docs/api-routes/introduction.md) are automatically optimized as isolated [Serverless Functions](https://vercel.com/features/infrastructure) that can scale infinitely
+- [Middleware](/docs/middleware.md) are automatically optimized as [Edge Functions](https://vercel.com/features/edge-functions) that have zero cold starts and boot instantly
-By using the DPS workflow, in addition to doing _code reviews_, you can do _deployment previews_. Each deployment creates a unique URL that can be shared or used for integration tests.
+In addition, Vercel provides features like:
-### Optimized for Next.js
+- Automatic performance monitoring with [Next.js Analytics](/analytics)
+- Automatic HTTPS and SSL certificates
+- Automatic CI/CD (through GitHub, GitLab, Bitbucket, etc.)
+- Support for [Environment Variables](https://vercel.com/docs/environment-variables)
+- Support for [Custom Domains](https://vercel.com/docs/custom-domains)
+- Support for [Image Optimization](/docs/basic-features/image-optimization.md) with `next/image`
+- Instant global deployments via `git push`
-[Vercel](https://vercel.com) is made by the creators of Next.js and has first-class support for Next.js.
+You can start using Vercel (for free) through a personal hobby account, or create a team to start the next big thing. Learn more about [Next.js on Vercel](https://vercel.com/solutions/nextjs) or read the [Vercel Documentation](https://vercel.com/docs).
-For example, the [hybrid pages](/docs/basic-features/pages.md) approach is fully supported out of the box.
+[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/hello-world&project-name=hello-world&repository-name=hello-world&utm_source=github.com&utm_medium=referral&utm_campaign=deployment)
-- Every page can either use [Static Generation](/docs/basic-features/pages.md#static-generation) or [Server-Side Rendering](/docs/basic-features/pages.md#server-side-rendering).
-- Pages that use [Static Generation](/docs/basic-features/pages.md#static-generation) and assets (JS, CSS, images, fonts, etc) will automatically be served from [Vercel's Edge Network](https://vercel.com/docs/edge-network/overview), which is blazingly fast.
-- Pages that use [Server-Side Rendering](/docs/basic-features/pages.md#server-side-rendering) and [API routes](/docs/api-routes/introduction.md) will automatically become isolated Serverless Functions. This allows page rendering and API requests to scale infinitely.
+## Self-Hosting
-### Custom Domains, Environment Variables, Automatic HTTPS, and more
-
-- **Custom Domains:** Once deployed on [Vercel](https://vercel.com), you can assign a custom domain to your Next.js app. Take a look at [our documentation here](https://vercel.com/docs/custom-domains).
-- **Environment Variables:** You can also set environment variables on Vercel. Take a look at [our documentation here](https://vercel.com/docs/environment-variables). You can then [use those environment variables](/docs/api-reference/next.config.js/environment-variables.md) in your Next.js app.
-- **Automatic HTTPS:** HTTPS is enabled by default (including custom domains) and doesn't require extra configuration. We auto-renew SSL certificates.
-- **More:** [Read our documentation](https://vercel.com/docs) to learn more about the Vercel platform.
-
-## Automatic Updates
-
-When you deploy your Next.js application, you want to see the latest version without needing to reload.
-
-Next.js will automatically load the latest version of your application in the background when routing. For client-side navigation, `next/link` will temporarily function as a normal `` tag.
-
-**Note:** If a new page (with an old version) has already been prefetched by `next/link`, Next.js will use the old version. Then, after either a full page refresh or multiple client-side page transitions, Next.js will show the latest version.
-
-## Other hosting options
+You can self-host Next.js with support for all features using Node.js or Docker. You can also do a Static HTML Export, which [has some limitations](/docs/advanced-features/static-html-export.md).
### Node.js Server
-Next.js can be deployed to any hosting provider that supports Node.js. Make sure your `package.json` has the `"build"` and `"start"` scripts:
+Next.js can be deployed to any hosting provider that supports Node.js. For example, [AWS EC2](https://aws.amazon.com/ec2/) or a [DigitalOcean Droplet](https://www.digitalocean.com/products/droplets/).
+
+First, ensure your `package.json` has the `"build"` and `"start"` scripts:
```json
{
@@ -74,73 +73,38 @@ Next.js can be deployed to any hosting provider that supports Node.js. Make sure
}
```
-`next build` builds the production application in the `.next` folder. After building, `next start` starts a Node.js server that supports [hybrid pages](/docs/basic-features/pages.md), serving both statically generated and server-side rendered pages.
+Then, run `next build` to build your application. Finally, run `next start` to start the Node.js server. This server supports all features of Next.js.
-If you are using [`next/image`](/docs/basic-features/image-optimization.md), consider adding `sharp` for more performant [Image Optimization](/docs/basic-features/image-optimization.md) in your production environment by running `npm install sharp` in your project directory. On Linux platforms, `sharp` may require [additional configuration](https://sharp.pixelplumbing.com/install#linux-memory-allocator) to prevent excessive memory usage.
+> If you are using [`next/image`](/docs/basic-features/image-optimization.md), consider adding `sharp` for more performant [Image Optimization](/docs/basic-features/image-optimization.md) in your production environment by running `npm install sharp` in your project directory. On Linux platforms, `sharp` may require [additional configuration](https://sharp.pixelplumbing.com/install#linux-memory-allocator) to prevent excessive memory usage.
### Docker Image
-
- Examples
-
-
-
Next.js can be deployed to any hosting provider that supports [Docker](https://www.docker.com/) containers. You can use this approach when deploying to container orchestrators such as [Kubernetes](https://kubernetes.io/) or [HashiCorp Nomad](https://www.nomadproject.io/), or when running inside a single node in any cloud provider.
-Here is a multi-stage `Dockerfile` using `node:alpine` that you can use:
-
-```Dockerfile
-# Install dependencies only when needed
-FROM node:alpine AS deps
-# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
-RUN apk add --no-cache libc6-compat
-WORKDIR /app
-COPY package.json yarn.lock ./
-RUN yarn install --frozen-lockfile
+1. [Install Docker](https://docs.docker.com/get-docker/) on your machine
+1. Clone the [with-docker](https://github.com/vercel/next.js/tree/canary/examples/with-docker) example
+1. Build your container: `docker build -t nextjs-docker .`
+1. Run your container: `docker run -p 3000:3000 nextjs-docker`
-# Rebuild the source code only when needed
-FROM node:alpine AS builder
-WORKDIR /app
-COPY . .
-COPY --from=deps /app/node_modules ./node_modules
-RUN yarn build && yarn install --production --ignore-scripts --prefer-offline
-
-# Production image, copy all the files and run next
-FROM node:alpine AS runner
-WORKDIR /app
-
-ENV NODE_ENV production
-
-RUN addgroup -g 1001 -S nodejs
-RUN adduser -S nextjs -u 1001
-
-# You only need to copy next.config.js if you are NOT using the default configuration
-# COPY --from=builder /app/next.config.js ./
-COPY --from=builder /app/public ./public
-COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
-COPY --from=builder /app/node_modules ./node_modules
-COPY --from=builder /app/package.json ./package.json
-
-USER nextjs
+### Static HTML Export
-EXPOSE 3000
+If you’d like to do a static HTML export of your Next.js app, follow the directions on our [Static HTML Export documentation](/docs/advanced-features/static-html-export.md).
-ENV PORT 3000
+## Automatic Updates
-# Next.js collects completely anonymous telemetry data about general usage.
-# Learn more here: https://nextjs.org/telemetry
-# Uncomment the following line in case you want to disable telemetry.
-# ENV NEXT_TELEMETRY_DISABLED 1
+When you deploy your Next.js application, you want to see the latest version without needing to reload.
-CMD ["node_modules/.bin/next", "start"]
-```
+Next.js will automatically load the latest version of your application in the background when routing. For client-side navigations, `next/link` will temporarily function as a normal `` tag.
-Make sure to place this Dockerfile in the root folder of your project.
+**Note:** If a new page (with an old version) has already been prefetched by `next/link`, Next.js will use the old version. Navigating to a page that has _not_ been prefetched (and is not cached at the CDN level) will load the latest version.
-You can build your container with `docker build . -t my-next-js-app` and run it with `docker run -p 3000:3000 my-next-js-app`.
+## Related
-### Static HTML Export
+For more information on what to do next, we recommend the following sections:
-If you’d like to do a static HTML export of your Next.js app, follow the directions on [our documentation](/docs/advanced-features/static-html-export.md).
+
- * escope finds lexical scopes in a source program, i.e. areas of that
- * program where different occurrences of the same identifier refer to the same
- * variable. With each scope the contained variables are collected, and each
- * identifier reference in code is linked to its corresponding variable (if
- * possible).
- *
- * escope works on a syntax tree of the parsed source code which has
- * to adhere to the
- * Mozilla Parser API. E.g. espree is a parser
- * that produces such syntax trees.
- *
- * The main interface is the {@link analyze} function.
- * @module escope
- */
-
-
-/* eslint no-underscore-dangle: ["error", { "allow": ["__currentScope"] }] */
-
-const assert = __webpack_require__(39491);
-
-const ScopeManager = __webpack_require__(96988);
-const Referencer = __webpack_require__(44585);
-const Reference = __webpack_require__(64945);
-const Variable = __webpack_require__(82971);
-const Scope = (__webpack_require__(16313).Scope);
-const version = (__webpack_require__(30290)/* .version */ .i8);
-
-/**
- * Set the default options
- * @returns {Object} options
- */
-function defaultOptions() {
- return {
- optimistic: false,
- directive: false,
- nodejsScope: false,
- impliedStrict: false,
- sourceType: "script", // one of ['script', 'module']
- ecmaVersion: 5,
- childVisitorKeys: null,
- fallback: "iteration"
- };
-}
-
-/**
- * Preform deep update on option object
- * @param {Object} target - Options
- * @param {Object} override - Updates
- * @returns {Object} Updated options
- */
-function updateDeeply(target, override) {
-
- /**
- * Is hash object
- * @param {Object} value - Test value
- * @returns {boolean} Result
- */
- function isHashObject(value) {
- return typeof value === "object" && value instanceof Object && !(value instanceof Array) && !(value instanceof RegExp);
- }
-
- for (const key in override) {
- if (Object.prototype.hasOwnProperty.call(override, key)) {
- const val = override[key];
-
- if (isHashObject(val)) {
- if (isHashObject(target[key])) {
- updateDeeply(target[key], val);
- } else {
- target[key] = updateDeeply({}, val);
- }
- } else {
- target[key] = val;
- }
- }
- }
- return target;
-}
-
-/**
- * Main interface function. Takes an Espree syntax tree and returns the
- * analyzed scopes.
- * @function analyze
- * @param {espree.Tree} tree - Abstract Syntax Tree
- * @param {Object} providedOptions - Options that tailor the scope analysis
- * @param {boolean} [providedOptions.optimistic=false] - the optimistic flag
- * @param {boolean} [providedOptions.directive=false]- the directive flag
- * @param {boolean} [providedOptions.ignoreEval=false]- whether to check 'eval()' calls
- * @param {boolean} [providedOptions.nodejsScope=false]- whether the whole
- * script is executed under node.js environment. When enabled, escope adds
- * a function scope immediately following the global scope.
- * @param {boolean} [providedOptions.impliedStrict=false]- implied strict mode
- * (if ecmaVersion >= 5).
- * @param {string} [providedOptions.sourceType='script']- the source type of the script. one of 'script' and 'module'
- * @param {number} [providedOptions.ecmaVersion=5]- which ECMAScript version is considered
- * @param {Object} [providedOptions.childVisitorKeys=null] - Additional known visitor keys. See [esrecurse](https://github.com/estools/esrecurse)'s the `childVisitorKeys` option.
- * @param {string} [providedOptions.fallback='iteration'] - A kind of the fallback in order to encounter with unknown node. See [esrecurse](https://github.com/estools/esrecurse)'s the `fallback` option.
- * @returns {ScopeManager} ScopeManager
- */
-function analyze(tree, providedOptions) {
- const options = updateDeeply(defaultOptions(), providedOptions);
- const scopeManager = new ScopeManager(options);
- const referencer = new Referencer(options, scopeManager);
-
- referencer.visit(tree);
-
- assert(scopeManager.__currentScope === null, "currentScope should be null.");
-
- return scopeManager;
-}
-
-module.exports = {
-
- /** @name module:escope.version */
- version,
-
- /** @name module:escope.Reference */
- Reference,
-
- /** @name module:escope.Variable */
- Variable,
-
- /** @name module:escope.Scope */
- Scope,
-
- /** @name module:escope.ScopeManager */
- ScopeManager,
- analyze
-};
-
-
-/* vim: set sw=4 ts=4 et tw=80 : */
-
-
-/***/ }),
-
-/***/ 54162:
-/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
-
-"use strict";
-/*
- Copyright (C) 2015 Yusuke Suzuki
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-/* eslint-disable no-undefined */
-
-const Syntax = (__webpack_require__(18350).Syntax);
-const esrecurse = __webpack_require__(81217);
-
-/**
- * Get last array element
- * @param {array} xs - array
- * @returns {any} Last elment
- */
-function getLast(xs) {
- return xs[xs.length - 1] || null;
-}
-
-class PatternVisitor extends esrecurse.Visitor {
- static isPattern(node) {
- const nodeType = node.type;
-
- return (
- nodeType === Syntax.Identifier ||
- nodeType === Syntax.ObjectPattern ||
- nodeType === Syntax.ArrayPattern ||
- nodeType === Syntax.SpreadElement ||
- nodeType === Syntax.RestElement ||
- nodeType === Syntax.AssignmentPattern
- );
- }
-
- constructor(options, rootPattern, callback) {
- super(null, options);
- this.rootPattern = rootPattern;
- this.callback = callback;
- this.assignments = [];
- this.rightHandNodes = [];
- this.restElements = [];
- }
-
- Identifier(pattern) {
- const lastRestElement = getLast(this.restElements);
-
- this.callback(pattern, {
- topLevel: pattern === this.rootPattern,
- rest: lastRestElement !== null && lastRestElement !== undefined && lastRestElement.argument === pattern,
- assignments: this.assignments
- });
- }
-
- Property(property) {
-
- // Computed property's key is a right hand node.
- if (property.computed) {
- this.rightHandNodes.push(property.key);
- }
-
- // If it's shorthand, its key is same as its value.
- // If it's shorthand and has its default value, its key is same as its value.left (the value is AssignmentPattern).
- // If it's not shorthand, the name of new variable is its value's.
- this.visit(property.value);
- }
-
- ArrayPattern(pattern) {
- for (let i = 0, iz = pattern.elements.length; i < iz; ++i) {
- const element = pattern.elements[i];
-
- this.visit(element);
- }
- }
-
- AssignmentPattern(pattern) {
- this.assignments.push(pattern);
- this.visit(pattern.left);
- this.rightHandNodes.push(pattern.right);
- this.assignments.pop();
- }
-
- RestElement(pattern) {
- this.restElements.push(pattern);
- this.visit(pattern.argument);
- this.restElements.pop();
- }
-
- MemberExpression(node) {
-
- // Computed property's key is a right hand node.
- if (node.computed) {
- this.rightHandNodes.push(node.property);
- }
-
- // the object is only read, write to its property.
- this.rightHandNodes.push(node.object);
- }
-
- //
- // ForInStatement.left and AssignmentExpression.left are LeftHandSideExpression.
- // By spec, LeftHandSideExpression is Pattern or MemberExpression.
- // (see also: https://github.com/estree/estree/pull/20#issuecomment-74584758)
- // But espree 2.0 parses to ArrayExpression, ObjectExpression, etc...
- //
-
- SpreadElement(node) {
- this.visit(node.argument);
- }
-
- ArrayExpression(node) {
- node.elements.forEach(this.visit, this);
- }
-
- AssignmentExpression(node) {
- this.assignments.push(node);
- this.visit(node.left);
- this.rightHandNodes.push(node.right);
- this.assignments.pop();
- }
-
- CallExpression(node) {
-
- // arguments are right hand nodes.
- node.arguments.forEach(a => {
- this.rightHandNodes.push(a);
- });
- this.visit(node.callee);
- }
-}
-
-module.exports = PatternVisitor;
-
-/* vim: set sw=4 ts=4 et tw=80 : */
-
-
-/***/ }),
-
-/***/ 64945:
-/***/ (function(module) {
-
-"use strict";
-/*
- Copyright (C) 2015 Yusuke Suzuki
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-const READ = 0x1;
-const WRITE = 0x2;
-const RW = READ | WRITE;
-
-/**
- * A Reference represents a single occurrence of an identifier in code.
- * @class Reference
- */
-class Reference {
- constructor(ident, scope, flag, writeExpr, maybeImplicitGlobal, partial, init) {
-
- /**
- * Identifier syntax node.
- * @member {espreeIdentifier} Reference#identifier
- */
- this.identifier = ident;
-
- /**
- * Reference to the enclosing Scope.
- * @member {Scope} Reference#from
- */
- this.from = scope;
-
- /**
- * Whether the reference comes from a dynamic scope (such as 'eval',
- * 'with', etc.), and may be trapped by dynamic scopes.
- * @member {boolean} Reference#tainted
- */
- this.tainted = false;
-
- /**
- * The variable this reference is resolved with.
- * @member {Variable} Reference#resolved
- */
- this.resolved = null;
-
- /**
- * The read-write mode of the reference. (Value is one of {@link
- * Reference.READ}, {@link Reference.RW}, {@link Reference.WRITE}).
- * @member {number} Reference#flag
- * @private
- */
- this.flag = flag;
- if (this.isWrite()) {
-
- /**
- * If reference is writeable, this is the tree being written to it.
- * @member {espreeNode} Reference#writeExpr
- */
- this.writeExpr = writeExpr;
-
- /**
- * Whether the Reference might refer to a partial value of writeExpr.
- * @member {boolean} Reference#partial
- */
- this.partial = partial;
-
- /**
- * Whether the Reference is to write of initialization.
- * @member {boolean} Reference#init
- */
- this.init = init;
- }
- this.__maybeImplicitGlobal = maybeImplicitGlobal;
- }
-
- /**
- * Whether the reference is static.
- * @method Reference#isStatic
- * @returns {boolean} static
- */
- isStatic() {
- return !this.tainted && this.resolved && this.resolved.scope.isStatic();
- }
-
- /**
- * Whether the reference is writeable.
- * @method Reference#isWrite
- * @returns {boolean} write
- */
- isWrite() {
- return !!(this.flag & Reference.WRITE);
- }
-
- /**
- * Whether the reference is readable.
- * @method Reference#isRead
- * @returns {boolean} read
- */
- isRead() {
- return !!(this.flag & Reference.READ);
- }
-
- /**
- * Whether the reference is read-only.
- * @method Reference#isReadOnly
- * @returns {boolean} read only
- */
- isReadOnly() {
- return this.flag === Reference.READ;
- }
-
- /**
- * Whether the reference is write-only.
- * @method Reference#isWriteOnly
- * @returns {boolean} write only
- */
- isWriteOnly() {
- return this.flag === Reference.WRITE;
- }
-
- /**
- * Whether the reference is read-write.
- * @method Reference#isReadWrite
- * @returns {boolean} read write
- */
- isReadWrite() {
- return this.flag === Reference.RW;
- }
-}
-
-/**
- * @constant Reference.READ
- * @private
- */
-Reference.READ = READ;
-
-/**
- * @constant Reference.WRITE
- * @private
- */
-Reference.WRITE = WRITE;
-
-/**
- * @constant Reference.RW
- * @private
- */
-Reference.RW = RW;
-
-module.exports = Reference;
-
-/* vim: set sw=4 ts=4 et tw=80 : */
-
-
-/***/ }),
-
-/***/ 44585:
-/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
-
-"use strict";
-/*
- Copyright (C) 2015 Yusuke Suzuki
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-/* eslint-disable no-underscore-dangle */
-/* eslint-disable no-undefined */
-
-const Syntax = (__webpack_require__(18350).Syntax);
-const esrecurse = __webpack_require__(81217);
-const Reference = __webpack_require__(64945);
-const Variable = __webpack_require__(82971);
-const PatternVisitor = __webpack_require__(54162);
-const definition = __webpack_require__(70665);
-const assert = __webpack_require__(39491);
-
-const ParameterDefinition = definition.ParameterDefinition;
-const Definition = definition.Definition;
-
-/**
- * Traverse identifier in pattern
- * @param {Object} options - options
- * @param {pattern} rootPattern - root pattern
- * @param {Refencer} referencer - referencer
- * @param {callback} callback - callback
- * @returns {void}
- */
-function traverseIdentifierInPattern(options, rootPattern, referencer, callback) {
-
- // Call the callback at left hand identifier nodes, and Collect right hand nodes.
- const visitor = new PatternVisitor(options, rootPattern, callback);
-
- visitor.visit(rootPattern);
-
- // Process the right hand nodes recursively.
- if (referencer !== null && referencer !== undefined) {
- visitor.rightHandNodes.forEach(referencer.visit, referencer);
- }
-}
-
-// Importing ImportDeclaration.
-// http://people.mozilla.org/~jorendorff/es6-draft.html#sec-moduledeclarationinstantiation
-// https://github.com/estree/estree/blob/master/es6.md#importdeclaration
-// FIXME: Now, we don't create module environment, because the context is
-// implementation dependent.
-
-class Importer extends esrecurse.Visitor {
- constructor(declaration, referencer) {
- super(null, referencer.options);
- this.declaration = declaration;
- this.referencer = referencer;
- }
-
- visitImport(id, specifier) {
- this.referencer.visitPattern(id, pattern => {
- this.referencer.currentScope().__define(pattern,
- new Definition(
- Variable.ImportBinding,
- pattern,
- specifier,
- this.declaration,
- null,
- null
- ));
- });
- }
-
- ImportNamespaceSpecifier(node) {
- const local = (node.local || node.id);
-
- if (local) {
- this.visitImport(local, node);
- }
- }
-
- ImportDefaultSpecifier(node) {
- const local = (node.local || node.id);
-
- this.visitImport(local, node);
- }
-
- ImportSpecifier(node) {
- const local = (node.local || node.id);
-
- if (node.name) {
- this.visitImport(node.name, node);
- } else {
- this.visitImport(local, node);
- }
- }
-}
-
-// Referencing variables and creating bindings.
-class Referencer extends esrecurse.Visitor {
- constructor(options, scopeManager) {
- super(null, options);
- this.options = options;
- this.scopeManager = scopeManager;
- this.parent = null;
- this.isInnerMethodDefinition = false;
- }
-
- currentScope() {
- return this.scopeManager.__currentScope;
- }
-
- close(node) {
- while (this.currentScope() && node === this.currentScope().block) {
- this.scopeManager.__currentScope = this.currentScope().__close(this.scopeManager);
- }
- }
-
- pushInnerMethodDefinition(isInnerMethodDefinition) {
- const previous = this.isInnerMethodDefinition;
-
- this.isInnerMethodDefinition = isInnerMethodDefinition;
- return previous;
- }
-
- popInnerMethodDefinition(isInnerMethodDefinition) {
- this.isInnerMethodDefinition = isInnerMethodDefinition;
- }
-
- referencingDefaultValue(pattern, assignments, maybeImplicitGlobal, init) {
- const scope = this.currentScope();
-
- assignments.forEach(assignment => {
- scope.__referencing(
- pattern,
- Reference.WRITE,
- assignment.right,
- maybeImplicitGlobal,
- pattern !== assignment.left,
- init
- );
- });
- }
-
- visitPattern(node, options, callback) {
- let visitPatternOptions = options;
- let visitPatternCallback = callback;
-
- if (typeof options === "function") {
- visitPatternCallback = options;
- visitPatternOptions = { processRightHandNodes: false };
- }
-
- traverseIdentifierInPattern(
- this.options,
- node,
- visitPatternOptions.processRightHandNodes ? this : null,
- visitPatternCallback
- );
- }
-
- visitFunction(node) {
- let i, iz;
-
- // FunctionDeclaration name is defined in upper scope
- // NOTE: Not referring variableScope. It is intended.
- // Since
- // in ES5, FunctionDeclaration should be in FunctionBody.
- // in ES6, FunctionDeclaration should be block scoped.
-
- if (node.type === Syntax.FunctionDeclaration) {
-
- // id is defined in upper scope
- this.currentScope().__define(node.id,
- new Definition(
- Variable.FunctionName,
- node.id,
- node,
- null,
- null,
- null
- ));
- }
-
- // FunctionExpression with name creates its special scope;
- // FunctionExpressionNameScope.
- if (node.type === Syntax.FunctionExpression && node.id) {
- this.scopeManager.__nestFunctionExpressionNameScope(node);
- }
-
- // Consider this function is in the MethodDefinition.
- this.scopeManager.__nestFunctionScope(node, this.isInnerMethodDefinition);
-
- const that = this;
-
- /**
- * Visit pattern callback
- * @param {pattern} pattern - pattern
- * @param {Object} info - info
- * @returns {void}
- */
- function visitPatternCallback(pattern, info) {
- that.currentScope().__define(pattern,
- new ParameterDefinition(
- pattern,
- node,
- i,
- info.rest
- ));
-
- that.referencingDefaultValue(pattern, info.assignments, null, true);
- }
-
- // Process parameter declarations.
- for (i = 0, iz = node.params.length; i < iz; ++i) {
- this.visitPattern(node.params[i], { processRightHandNodes: true }, visitPatternCallback);
- }
-
- // if there's a rest argument, add that
- if (node.rest) {
- this.visitPattern({
- type: "RestElement",
- argument: node.rest
- }, pattern => {
- this.currentScope().__define(pattern,
- new ParameterDefinition(
- pattern,
- node,
- node.params.length,
- true
- ));
- });
- }
-
- // In TypeScript there are a number of function-like constructs which have no body,
- // so check it exists before traversing
- if (node.body) {
-
- // Skip BlockStatement to prevent creating BlockStatement scope.
- if (node.body.type === Syntax.BlockStatement) {
- this.visitChildren(node.body);
- } else {
- this.visit(node.body);
- }
- }
-
- this.close(node);
- }
-
- visitClass(node) {
- if (node.type === Syntax.ClassDeclaration) {
- this.currentScope().__define(node.id,
- new Definition(
- Variable.ClassName,
- node.id,
- node,
- null,
- null,
- null
- ));
- }
-
- this.visit(node.superClass);
-
- this.scopeManager.__nestClassScope(node);
-
- if (node.id) {
- this.currentScope().__define(node.id,
- new Definition(
- Variable.ClassName,
- node.id,
- node
- ));
- }
- this.visit(node.body);
-
- this.close(node);
- }
-
- visitProperty(node) {
- let previous;
-
- if (node.computed) {
- this.visit(node.key);
- }
-
- const isMethodDefinition = node.type === Syntax.MethodDefinition;
-
- if (isMethodDefinition) {
- previous = this.pushInnerMethodDefinition(true);
- }
- this.visit(node.value);
- if (isMethodDefinition) {
- this.popInnerMethodDefinition(previous);
- }
- }
-
- visitForIn(node) {
- if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
- this.scopeManager.__nestForScope(node);
- }
-
- if (node.left.type === Syntax.VariableDeclaration) {
- this.visit(node.left);
- this.visitPattern(node.left.declarations[0].id, pattern => {
- this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
- });
- } else {
- this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
- let maybeImplicitGlobal = null;
-
- if (!this.currentScope().isStrict) {
- maybeImplicitGlobal = {
- pattern,
- node
- };
- }
- this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
- this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, true, false);
- });
- }
- this.visit(node.right);
- this.visit(node.body);
-
- this.close(node);
- }
-
- visitVariableDeclaration(variableTargetScope, type, node, index) {
-
- const decl = node.declarations[index];
- const init = decl.init;
-
- this.visitPattern(decl.id, { processRightHandNodes: true }, (pattern, info) => {
- variableTargetScope.__define(
- pattern,
- new Definition(
- type,
- pattern,
- decl,
- node,
- index,
- node.kind
- )
- );
-
- this.referencingDefaultValue(pattern, info.assignments, null, true);
- if (init) {
- this.currentScope().__referencing(pattern, Reference.WRITE, init, null, !info.topLevel, true);
- }
- });
- }
-
- AssignmentExpression(node) {
- if (PatternVisitor.isPattern(node.left)) {
- if (node.operator === "=") {
- this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
- let maybeImplicitGlobal = null;
-
- if (!this.currentScope().isStrict) {
- maybeImplicitGlobal = {
- pattern,
- node
- };
- }
- this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
- this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, !info.topLevel, false);
- });
- } else {
- this.currentScope().__referencing(node.left, Reference.RW, node.right);
- }
- } else {
- this.visit(node.left);
- }
- this.visit(node.right);
- }
-
- CatchClause(node) {
- this.scopeManager.__nestCatchScope(node);
-
- this.visitPattern(node.param, { processRightHandNodes: true }, (pattern, info) => {
- this.currentScope().__define(pattern,
- new Definition(
- Variable.CatchClause,
- node.param,
- node,
- null,
- null,
- null
- ));
- this.referencingDefaultValue(pattern, info.assignments, null, true);
- });
- this.visit(node.body);
-
- this.close(node);
- }
-
- Program(node) {
- this.scopeManager.__nestGlobalScope(node);
-
- if (this.scopeManager.__isNodejsScope()) {
-
- // Force strictness of GlobalScope to false when using node.js scope.
- this.currentScope().isStrict = false;
- this.scopeManager.__nestFunctionScope(node, false);
- }
-
- if (this.scopeManager.__isES6() && this.scopeManager.isModule()) {
- this.scopeManager.__nestModuleScope(node);
- }
-
- if (this.scopeManager.isStrictModeSupported() && this.scopeManager.isImpliedStrict()) {
- this.currentScope().isStrict = true;
- }
-
- this.visitChildren(node);
- this.close(node);
- }
-
- Identifier(node) {
- this.currentScope().__referencing(node);
- }
-
- UpdateExpression(node) {
- if (PatternVisitor.isPattern(node.argument)) {
- this.currentScope().__referencing(node.argument, Reference.RW, null);
- } else {
- this.visitChildren(node);
- }
- }
-
- MemberExpression(node) {
- this.visit(node.object);
- if (node.computed) {
- this.visit(node.property);
- }
- }
-
- Property(node) {
- this.visitProperty(node);
- }
-
- MethodDefinition(node) {
- this.visitProperty(node);
- }
-
- BreakStatement() {} // eslint-disable-line class-methods-use-this
-
- ContinueStatement() {} // eslint-disable-line class-methods-use-this
-
- LabeledStatement(node) {
- this.visit(node.body);
- }
-
- ForStatement(node) {
-
- // Create ForStatement declaration.
- // NOTE: In ES6, ForStatement dynamically generates
- // per iteration environment. However, escope is
- // a static analyzer, we only generate one scope for ForStatement.
- if (node.init && node.init.type === Syntax.VariableDeclaration && node.init.kind !== "var") {
- this.scopeManager.__nestForScope(node);
- }
-
- this.visitChildren(node);
-
- this.close(node);
- }
-
- ClassExpression(node) {
- this.visitClass(node);
- }
-
- ClassDeclaration(node) {
- this.visitClass(node);
- }
-
- CallExpression(node) {
-
- // Check this is direct call to eval
- if (!this.scopeManager.__ignoreEval() && node.callee.type === Syntax.Identifier && node.callee.name === "eval") {
-
- // NOTE: This should be `variableScope`. Since direct eval call always creates Lexical environment and
- // let / const should be enclosed into it. Only VariableDeclaration affects on the caller's environment.
- this.currentScope().variableScope.__detectEval();
- }
- this.visitChildren(node);
- }
-
- BlockStatement(node) {
- if (this.scopeManager.__isES6()) {
- this.scopeManager.__nestBlockScope(node);
- }
-
- this.visitChildren(node);
-
- this.close(node);
- }
-
- ThisExpression() {
- this.currentScope().variableScope.__detectThis();
- }
-
- WithStatement(node) {
- this.visit(node.object);
-
- // Then nest scope for WithStatement.
- this.scopeManager.__nestWithScope(node);
-
- this.visit(node.body);
-
- this.close(node);
- }
-
- VariableDeclaration(node) {
- const variableTargetScope = (node.kind === "var") ? this.currentScope().variableScope : this.currentScope();
-
- for (let i = 0, iz = node.declarations.length; i < iz; ++i) {
- const decl = node.declarations[i];
-
- this.visitVariableDeclaration(variableTargetScope, Variable.Variable, node, i);
- if (decl.init) {
- this.visit(decl.init);
- }
- }
- }
-
- // sec 13.11.8
- SwitchStatement(node) {
- this.visit(node.discriminant);
-
- if (this.scopeManager.__isES6()) {
- this.scopeManager.__nestSwitchScope(node);
- }
-
- for (let i = 0, iz = node.cases.length; i < iz; ++i) {
- this.visit(node.cases[i]);
- }
-
- this.close(node);
- }
-
- FunctionDeclaration(node) {
- this.visitFunction(node);
- }
-
- FunctionExpression(node) {
- this.visitFunction(node);
- }
-
- ForOfStatement(node) {
- this.visitForIn(node);
- }
-
- ForInStatement(node) {
- this.visitForIn(node);
- }
-
- ArrowFunctionExpression(node) {
- this.visitFunction(node);
- }
-
- ImportDeclaration(node) {
- assert(this.scopeManager.__isES6() && this.scopeManager.isModule(), "ImportDeclaration should appear when the mode is ES6 and in the module context.");
-
- const importer = new Importer(node, this);
-
- importer.visit(node);
- }
-
- visitExportDeclaration(node) {
- if (node.source) {
- return;
- }
- if (node.declaration) {
- this.visit(node.declaration);
- return;
- }
-
- this.visitChildren(node);
- }
-
- // TODO: ExportDeclaration doesn't exist. for bc?
- ExportDeclaration(node) {
- this.visitExportDeclaration(node);
- }
-
- ExportAllDeclaration(node) {
- this.visitExportDeclaration(node);
- }
-
- ExportDefaultDeclaration(node) {
- this.visitExportDeclaration(node);
- }
-
- ExportNamedDeclaration(node) {
- this.visitExportDeclaration(node);
- }
-
- ExportSpecifier(node) {
-
- // TODO: `node.id` doesn't exist. for bc?
- const local = (node.id || node.local);
-
- this.visit(local);
- }
-
- MetaProperty() { // eslint-disable-line class-methods-use-this
-
- // do nothing.
- }
-}
-
-module.exports = Referencer;
-
-/* vim: set sw=4 ts=4 et tw=80 : */
-
-
-/***/ }),
-
-/***/ 96988:
-/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
-
-"use strict";
-/*
- Copyright (C) 2015 Yusuke Suzuki
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-/* eslint-disable no-underscore-dangle */
-
-const Scope = __webpack_require__(16313);
-const assert = __webpack_require__(39491);
-
-const GlobalScope = Scope.GlobalScope;
-const CatchScope = Scope.CatchScope;
-const WithScope = Scope.WithScope;
-const ModuleScope = Scope.ModuleScope;
-const ClassScope = Scope.ClassScope;
-const SwitchScope = Scope.SwitchScope;
-const FunctionScope = Scope.FunctionScope;
-const ForScope = Scope.ForScope;
-const FunctionExpressionNameScope = Scope.FunctionExpressionNameScope;
-const BlockScope = Scope.BlockScope;
-
-/**
- * @class ScopeManager
- */
-class ScopeManager {
- constructor(options) {
- this.scopes = [];
- this.globalScope = null;
- this.__nodeToScope = new WeakMap();
- this.__currentScope = null;
- this.__options = options;
- this.__declaredVariables = new WeakMap();
- }
-
- __useDirective() {
- return this.__options.directive;
- }
-
- __isOptimistic() {
- return this.__options.optimistic;
- }
-
- __ignoreEval() {
- return this.__options.ignoreEval;
- }
-
- __isNodejsScope() {
- return this.__options.nodejsScope;
- }
-
- isModule() {
- return this.__options.sourceType === "module";
- }
-
- isImpliedStrict() {
- return this.__options.impliedStrict;
- }
-
- isStrictModeSupported() {
- return this.__options.ecmaVersion >= 5;
- }
-
- // Returns appropriate scope for this node.
- __get(node) {
- return this.__nodeToScope.get(node);
- }
-
- /**
- * Get variables that are declared by the node.
- *
- * "are declared by the node" means the node is same as `Variable.defs[].node` or `Variable.defs[].parent`.
- * If the node declares nothing, this method returns an empty array.
- * CAUTION: This API is experimental. See https://github.com/estools/escope/pull/69 for more details.
- *
- * @param {Espree.Node} node - a node to get.
- * @returns {Variable[]} variables that declared by the node.
- */
- getDeclaredVariables(node) {
- return this.__declaredVariables.get(node) || [];
- }
-
- /**
- * acquire scope from node.
- * @method ScopeManager#acquire
- * @param {Espree.Node} node - node for the acquired scope.
- * @param {boolean=} inner - look up the most inner scope, default value is false.
- * @returns {Scope?} Scope from node
- */
- acquire(node, inner) {
-
- /**
- * predicate
- * @param {Scope} testScope - scope to test
- * @returns {boolean} predicate
- */
- function predicate(testScope) {
- if (testScope.type === "function" && testScope.functionExpressionScope) {
- return false;
- }
- return true;
- }
-
- const scopes = this.__get(node);
-
- if (!scopes || scopes.length === 0) {
- return null;
- }
-
- // Heuristic selection from all scopes.
- // If you would like to get all scopes, please use ScopeManager#acquireAll.
- if (scopes.length === 1) {
- return scopes[0];
- }
-
- if (inner) {
- for (let i = scopes.length - 1; i >= 0; --i) {
- const scope = scopes[i];
-
- if (predicate(scope)) {
- return scope;
- }
- }
- } else {
- for (let i = 0, iz = scopes.length; i < iz; ++i) {
- const scope = scopes[i];
-
- if (predicate(scope)) {
- return scope;
- }
- }
- }
-
- return null;
- }
-
- /**
- * acquire all scopes from node.
- * @method ScopeManager#acquireAll
- * @param {Espree.Node} node - node for the acquired scope.
- * @returns {Scopes?} Scope array
- */
- acquireAll(node) {
- return this.__get(node);
- }
-
- /**
- * release the node.
- * @method ScopeManager#release
- * @param {Espree.Node} node - releasing node.
- * @param {boolean=} inner - look up the most inner scope, default value is false.
- * @returns {Scope?} upper scope for the node.
- */
- release(node, inner) {
- const scopes = this.__get(node);
-
- if (scopes && scopes.length) {
- const scope = scopes[0].upper;
-
- if (!scope) {
- return null;
- }
- return this.acquire(scope.block, inner);
- }
- return null;
- }
-
- attach() { } // eslint-disable-line class-methods-use-this
-
- detach() { } // eslint-disable-line class-methods-use-this
-
- __nestScope(scope) {
- if (scope instanceof GlobalScope) {
- assert(this.__currentScope === null);
- this.globalScope = scope;
- }
- this.__currentScope = scope;
- return scope;
- }
-
- __nestGlobalScope(node) {
- return this.__nestScope(new GlobalScope(this, node));
- }
-
- __nestBlockScope(node) {
- return this.__nestScope(new BlockScope(this, this.__currentScope, node));
- }
-
- __nestFunctionScope(node, isMethodDefinition) {
- return this.__nestScope(new FunctionScope(this, this.__currentScope, node, isMethodDefinition));
- }
-
- __nestForScope(node) {
- return this.__nestScope(new ForScope(this, this.__currentScope, node));
- }
-
- __nestCatchScope(node) {
- return this.__nestScope(new CatchScope(this, this.__currentScope, node));
- }
-
- __nestWithScope(node) {
- return this.__nestScope(new WithScope(this, this.__currentScope, node));
- }
-
- __nestClassScope(node) {
- return this.__nestScope(new ClassScope(this, this.__currentScope, node));
- }
-
- __nestSwitchScope(node) {
- return this.__nestScope(new SwitchScope(this, this.__currentScope, node));
- }
-
- __nestModuleScope(node) {
- return this.__nestScope(new ModuleScope(this, this.__currentScope, node));
- }
-
- __nestFunctionExpressionNameScope(node) {
- return this.__nestScope(new FunctionExpressionNameScope(this, this.__currentScope, node));
- }
-
- __isES6() {
- return this.__options.ecmaVersion >= 6;
- }
-}
-
-module.exports = ScopeManager;
-
-/* vim: set sw=4 ts=4 et tw=80 : */
-
-
-/***/ }),
-
-/***/ 16313:
-/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
-
-"use strict";
-/*
- Copyright (C) 2015 Yusuke Suzuki
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-/* eslint-disable no-underscore-dangle */
-/* eslint-disable no-undefined */
-
-const Syntax = (__webpack_require__(18350).Syntax);
-
-const Reference = __webpack_require__(64945);
-const Variable = __webpack_require__(82971);
-const Definition = (__webpack_require__(70665).Definition);
-const assert = __webpack_require__(39491);
-
-/**
- * Test if scope is struct
- * @param {Scope} scope - scope
- * @param {Block} block - block
- * @param {boolean} isMethodDefinition - is method definition
- * @param {boolean} useDirective - use directive
- * @returns {boolean} is strict scope
- */
-function isStrictScope(scope, block, isMethodDefinition, useDirective) {
- let body;
-
- // When upper scope is exists and strict, inner scope is also strict.
- if (scope.upper && scope.upper.isStrict) {
- return true;
- }
-
- if (isMethodDefinition) {
- return true;
- }
-
- if (scope.type === "class" || scope.type === "module") {
- return true;
- }
-
- if (scope.type === "block" || scope.type === "switch") {
- return false;
- }
-
- if (scope.type === "function") {
- if (block.type === Syntax.ArrowFunctionExpression && block.body.type !== Syntax.BlockStatement) {
- return false;
- }
-
- if (block.type === Syntax.Program) {
- body = block;
- } else {
- body = block.body;
- }
-
- if (!body) {
- return false;
- }
- } else if (scope.type === "global") {
- body = block;
- } else {
- return false;
- }
-
- // Search 'use strict' directive.
- if (useDirective) {
- for (let i = 0, iz = body.body.length; i < iz; ++i) {
- const stmt = body.body[i];
-
- if (stmt.type !== Syntax.DirectiveStatement) {
- break;
- }
- if (stmt.raw === "\"use strict\"" || stmt.raw === "'use strict'") {
- return true;
- }
- }
- } else {
- for (let i = 0, iz = body.body.length; i < iz; ++i) {
- const stmt = body.body[i];
-
- if (stmt.type !== Syntax.ExpressionStatement) {
- break;
- }
- const expr = stmt.expression;
-
- if (expr.type !== Syntax.Literal || typeof expr.value !== "string") {
- break;
- }
- if (expr.raw !== null && expr.raw !== undefined) {
- if (expr.raw === "\"use strict\"" || expr.raw === "'use strict'") {
- return true;
- }
- } else {
- if (expr.value === "use strict") {
- return true;
- }
- }
- }
- }
- return false;
-}
-
-/**
- * Register scope
- * @param {ScopeManager} scopeManager - scope manager
- * @param {Scope} scope - scope
- * @returns {void}
- */
-function registerScope(scopeManager, scope) {
- scopeManager.scopes.push(scope);
-
- const scopes = scopeManager.__nodeToScope.get(scope.block);
-
- if (scopes) {
- scopes.push(scope);
- } else {
- scopeManager.__nodeToScope.set(scope.block, [scope]);
- }
-}
-
-/**
- * Should be statically
- * @param {Object} def - def
- * @returns {boolean} should be statically
- */
-function shouldBeStatically(def) {
- return (
- (def.type === Variable.ClassName) ||
- (def.type === Variable.Variable && def.parent.kind !== "var")
- );
-}
-
-/**
- * @class Scope
- */
-class Scope {
- constructor(scopeManager, type, upperScope, block, isMethodDefinition) {
-
- /**
- * One of 'module', 'block', 'switch', 'function', 'catch', 'with', 'function', 'class', 'global'.
- * @member {String} Scope#type
- */
- this.type = type;
-
- /**
- * The scoped {@link Variable}s of this scope, as { Variable.name
- * : Variable }.
- * @member {Map} Scope#set
- */
- this.set = new Map();
-
- /**
- * The tainted variables of this scope, as { Variable.name :
- * boolean }.
- * @member {Map} Scope#taints */
- this.taints = new Map();
-
- /**
- * Generally, through the lexical scoping of JS you can always know
- * which variable an identifier in the source code refers to. There are
- * a few exceptions to this rule. With 'global' and 'with' scopes you
- * can only decide at runtime which variable a reference refers to.
- * Moreover, if 'eval()' is used in a scope, it might introduce new
- * bindings in this or its parent scopes.
- * All those scopes are considered 'dynamic'.
- * @member {boolean} Scope#dynamic
- */
- this.dynamic = this.type === "global" || this.type === "with";
-
- /**
- * A reference to the scope-defining syntax node.
- * @member {espree.Node} Scope#block
- */
- this.block = block;
-
- /**
- * The {@link Reference|references} that are not resolved with this scope.
- * @member {Reference[]} Scope#through
- */
- this.through = [];
-
- /**
- * The scoped {@link Variable}s of this scope. In the case of a
- * 'function' scope this includes the automatic argument arguments as
- * its first element, as well as all further formal arguments.
- * @member {Variable[]} Scope#variables
- */
- this.variables = [];
-
- /**
- * Any variable {@link Reference|reference} found in this scope. This
- * includes occurrences of local variables as well as variables from
- * parent scopes (including the global scope). For local variables
- * this also includes defining occurrences (like in a 'var' statement).
- * In a 'function' scope this does not include the occurrences of the
- * formal parameter in the parameter list.
- * @member {Reference[]} Scope#references
- */
- this.references = [];
-
- /**
- * For 'global' and 'function' scopes, this is a self-reference. For
- * other scope types this is the variableScope value of the
- * parent scope.
- * @member {Scope} Scope#variableScope
- */
- this.variableScope =
- (this.type === "global" || this.type === "function" || this.type === "module") ? this : upperScope.variableScope;
-
- /**
- * Whether this scope is created by a FunctionExpression.
- * @member {boolean} Scope#functionExpressionScope
- */
- this.functionExpressionScope = false;
-
- /**
- * Whether this is a scope that contains an 'eval()' invocation.
- * @member {boolean} Scope#directCallToEvalScope
- */
- this.directCallToEvalScope = false;
-
- /**
- * @member {boolean} Scope#thisFound
- */
- this.thisFound = false;
-
- this.__left = [];
-
- /**
- * Reference to the parent {@link Scope|scope}.
- * @member {Scope} Scope#upper
- */
- this.upper = upperScope;
-
- /**
- * Whether 'use strict' is in effect in this scope.
- * @member {boolean} Scope#isStrict
- */
- this.isStrict = isStrictScope(this, block, isMethodDefinition, scopeManager.__useDirective());
-
- /**
- * List of nested {@link Scope}s.
- * @member {Scope[]} Scope#childScopes
- */
- this.childScopes = [];
- if (this.upper) {
- this.upper.childScopes.push(this);
- }
-
- this.__declaredVariables = scopeManager.__declaredVariables;
-
- registerScope(scopeManager, this);
- }
-
- __shouldStaticallyClose(scopeManager) {
- return (!this.dynamic || scopeManager.__isOptimistic());
- }
-
- __shouldStaticallyCloseForGlobal(ref) {
-
- // On global scope, let/const/class declarations should be resolved statically.
- const name = ref.identifier.name;
-
- if (!this.set.has(name)) {
- return false;
- }
-
- const variable = this.set.get(name);
- const defs = variable.defs;
-
- return defs.length > 0 && defs.every(shouldBeStatically);
- }
-
- __staticCloseRef(ref) {
- if (!this.__resolve(ref)) {
- this.__delegateToUpperScope(ref);
- }
- }
-
- __dynamicCloseRef(ref) {
-
- // notify all names are through to global
- let current = this;
-
- do {
- current.through.push(ref);
- current = current.upper;
- } while (current);
- }
-
- __globalCloseRef(ref) {
-
- // let/const/class declarations should be resolved statically.
- // others should be resolved dynamically.
- if (this.__shouldStaticallyCloseForGlobal(ref)) {
- this.__staticCloseRef(ref);
- } else {
- this.__dynamicCloseRef(ref);
- }
- }
-
- __close(scopeManager) {
- let closeRef;
-
- if (this.__shouldStaticallyClose(scopeManager)) {
- closeRef = this.__staticCloseRef;
- } else if (this.type !== "global") {
- closeRef = this.__dynamicCloseRef;
- } else {
- closeRef = this.__globalCloseRef;
- }
-
- // Try Resolving all references in this scope.
- for (let i = 0, iz = this.__left.length; i < iz; ++i) {
- const ref = this.__left[i];
-
- closeRef.call(this, ref);
- }
- this.__left = null;
-
- return this.upper;
- }
-
- // To override by function scopes.
- // References in default parameters isn't resolved to variables which are in their function body.
- __isValidResolution(ref, variable) { // eslint-disable-line class-methods-use-this, no-unused-vars
- return true;
- }
-
- __resolve(ref) {
- const name = ref.identifier.name;
-
- if (!this.set.has(name)) {
- return false;
- }
- const variable = this.set.get(name);
-
- if (!this.__isValidResolution(ref, variable)) {
- return false;
- }
- variable.references.push(ref);
- variable.stack = variable.stack && ref.from.variableScope === this.variableScope;
- if (ref.tainted) {
- variable.tainted = true;
- this.taints.set(variable.name, true);
- }
- ref.resolved = variable;
-
- return true;
- }
-
- __delegateToUpperScope(ref) {
- if (this.upper) {
- this.upper.__left.push(ref);
- }
- this.through.push(ref);
- }
-
- __addDeclaredVariablesOfNode(variable, node) {
- if (node === null || node === undefined) {
- return;
- }
-
- let variables = this.__declaredVariables.get(node);
-
- if (variables === null || variables === undefined) {
- variables = [];
- this.__declaredVariables.set(node, variables);
- }
- if (variables.indexOf(variable) === -1) {
- variables.push(variable);
- }
- }
-
- __defineGeneric(name, set, variables, node, def) {
- let variable;
-
- variable = set.get(name);
- if (!variable) {
- variable = new Variable(name, this);
- set.set(name, variable);
- variables.push(variable);
- }
-
- if (def) {
- variable.defs.push(def);
- this.__addDeclaredVariablesOfNode(variable, def.node);
- this.__addDeclaredVariablesOfNode(variable, def.parent);
- }
- if (node) {
- variable.identifiers.push(node);
- }
- }
-
- __define(node, def) {
- if (node && node.type === Syntax.Identifier) {
- this.__defineGeneric(
- node.name,
- this.set,
- this.variables,
- node,
- def
- );
- }
- }
-
- __referencing(node, assign, writeExpr, maybeImplicitGlobal, partial, init) {
-
- // because Array element may be null
- if (!node || node.type !== Syntax.Identifier) {
- return;
- }
-
- // Specially handle like `this`.
- if (node.name === "super") {
- return;
- }
-
- const ref = new Reference(node, this, assign || Reference.READ, writeExpr, maybeImplicitGlobal, !!partial, !!init);
-
- this.references.push(ref);
- this.__left.push(ref);
- }
-
- __detectEval() {
- let current = this;
-
- this.directCallToEvalScope = true;
- do {
- current.dynamic = true;
- current = current.upper;
- } while (current);
- }
-
- __detectThis() {
- this.thisFound = true;
- }
-
- __isClosed() {
- return this.__left === null;
- }
-
- /**
- * returns resolved {Reference}
- * @method Scope#resolve
- * @param {Espree.Identifier} ident - identifier to be resolved.
- * @returns {Reference} reference
- */
- resolve(ident) {
- let ref, i, iz;
-
- assert(this.__isClosed(), "Scope should be closed.");
- assert(ident.type === Syntax.Identifier, "Target should be identifier.");
- for (i = 0, iz = this.references.length; i < iz; ++i) {
- ref = this.references[i];
- if (ref.identifier === ident) {
- return ref;
- }
- }
- return null;
- }
-
- /**
- * returns this scope is static
- * @method Scope#isStatic
- * @returns {boolean} static
- */
- isStatic() {
- return !this.dynamic;
- }
-
- /**
- * returns this scope has materialized arguments
- * @method Scope#isArgumentsMaterialized
- * @returns {boolean} arguemnts materialized
- */
- isArgumentsMaterialized() { // eslint-disable-line class-methods-use-this
- return true;
- }
-
- /**
- * returns this scope has materialized `this` reference
- * @method Scope#isThisMaterialized
- * @returns {boolean} this materialized
- */
- isThisMaterialized() { // eslint-disable-line class-methods-use-this
- return true;
- }
-
- isUsedName(name) {
- if (this.set.has(name)) {
- return true;
- }
- for (let i = 0, iz = this.through.length; i < iz; ++i) {
- if (this.through[i].identifier.name === name) {
- return true;
- }
- }
- return false;
- }
-}
-
-class GlobalScope extends Scope {
- constructor(scopeManager, block) {
- super(scopeManager, "global", null, block, false);
- this.implicit = {
- set: new Map(),
- variables: [],
-
- /**
- * List of {@link Reference}s that are left to be resolved (i.e. which
- * need to be linked to the variable they refer to).
- * @member {Reference[]} Scope#implicit#left
- */
- left: []
- };
- }
-
- __close(scopeManager) {
- const implicit = [];
-
- for (let i = 0, iz = this.__left.length; i < iz; ++i) {
- const ref = this.__left[i];
-
- if (ref.__maybeImplicitGlobal && !this.set.has(ref.identifier.name)) {
- implicit.push(ref.__maybeImplicitGlobal);
- }
- }
-
- // create an implicit global variable from assignment expression
- for (let i = 0, iz = implicit.length; i < iz; ++i) {
- const info = implicit[i];
-
- this.__defineImplicit(info.pattern,
- new Definition(
- Variable.ImplicitGlobalVariable,
- info.pattern,
- info.node,
- null,
- null,
- null
- ));
-
- }
-
- this.implicit.left = this.__left;
-
- return super.__close(scopeManager);
- }
-
- __defineImplicit(node, def) {
- if (node && node.type === Syntax.Identifier) {
- this.__defineGeneric(
- node.name,
- this.implicit.set,
- this.implicit.variables,
- node,
- def
- );
- }
- }
-}
-
-class ModuleScope extends Scope {
- constructor(scopeManager, upperScope, block) {
- super(scopeManager, "module", upperScope, block, false);
- }
-}
-
-class FunctionExpressionNameScope extends Scope {
- constructor(scopeManager, upperScope, block) {
- super(scopeManager, "function-expression-name", upperScope, block, false);
- this.__define(block.id,
- new Definition(
- Variable.FunctionName,
- block.id,
- block,
- null,
- null,
- null
- ));
- this.functionExpressionScope = true;
- }
-}
-
-class CatchScope extends Scope {
- constructor(scopeManager, upperScope, block) {
- super(scopeManager, "catch", upperScope, block, false);
- }
-}
-
-class WithScope extends Scope {
- constructor(scopeManager, upperScope, block) {
- super(scopeManager, "with", upperScope, block, false);
- }
-
- __close(scopeManager) {
- if (this.__shouldStaticallyClose(scopeManager)) {
- return super.__close(scopeManager);
- }
-
- for (let i = 0, iz = this.__left.length; i < iz; ++i) {
- const ref = this.__left[i];
-
- ref.tainted = true;
- this.__delegateToUpperScope(ref);
- }
- this.__left = null;
-
- return this.upper;
- }
-}
-
-class BlockScope extends Scope {
- constructor(scopeManager, upperScope, block) {
- super(scopeManager, "block", upperScope, block, false);
- }
-}
-
-class SwitchScope extends Scope {
- constructor(scopeManager, upperScope, block) {
- super(scopeManager, "switch", upperScope, block, false);
- }
-}
-
-class FunctionScope extends Scope {
- constructor(scopeManager, upperScope, block, isMethodDefinition) {
- super(scopeManager, "function", upperScope, block, isMethodDefinition);
-
- // section 9.2.13, FunctionDeclarationInstantiation.
- // NOTE Arrow functions never have an arguments objects.
- if (this.block.type !== Syntax.ArrowFunctionExpression) {
- this.__defineArguments();
- }
- }
-
- isArgumentsMaterialized() {
-
- // TODO(Constellation)
- // We can more aggressive on this condition like this.
- //
- // function t() {
- // // arguments of t is always hidden.
- // function arguments() {
- // }
- // }
- if (this.block.type === Syntax.ArrowFunctionExpression) {
- return false;
- }
-
- if (!this.isStatic()) {
- return true;
- }
-
- const variable = this.set.get("arguments");
-
- assert(variable, "Always have arguments variable.");
- return variable.tainted || variable.references.length !== 0;
- }
-
- isThisMaterialized() {
- if (!this.isStatic()) {
- return true;
- }
- return this.thisFound;
- }
-
- __defineArguments() {
- this.__defineGeneric(
- "arguments",
- this.set,
- this.variables,
- null,
- null
- );
- this.taints.set("arguments", true);
- }
-
- // References in default parameters isn't resolved to variables which are in their function body.
- // const x = 1
- // function f(a = x) { // This `x` is resolved to the `x` in the outer scope.
- // const x = 2
- // console.log(a)
- // }
- __isValidResolution(ref, variable) {
-
- // If `options.nodejsScope` is true, `this.block` becomes a Program node.
- if (this.block.type === "Program") {
- return true;
- }
-
- const bodyStart = this.block.body.range[0];
-
- // It's invalid resolution in the following case:
- return !(
- variable.scope === this &&
- ref.identifier.range[0] < bodyStart && // the reference is in the parameter part.
- variable.defs.every(d => d.name.range[0] >= bodyStart) // the variable is in the body.
- );
- }
-}
-
-class ForScope extends Scope {
- constructor(scopeManager, upperScope, block) {
- super(scopeManager, "for", upperScope, block, false);
- }
-}
-
-class ClassScope extends Scope {
- constructor(scopeManager, upperScope, block) {
- super(scopeManager, "class", upperScope, block, false);
- }
-}
-
-module.exports = {
- Scope,
- GlobalScope,
- ModuleScope,
- FunctionExpressionNameScope,
- CatchScope,
- WithScope,
- BlockScope,
- SwitchScope,
- FunctionScope,
- ForScope,
- ClassScope
-};
-
-/* vim: set sw=4 ts=4 et tw=80 : */
-
-
-/***/ }),
-
-/***/ 82971:
-/***/ (function(module) {
-
-"use strict";
-/*
- Copyright (C) 2015 Yusuke Suzuki
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-
-/**
- * A Variable represents a locally scoped identifier. These include arguments to
- * functions.
- * @class Variable
- */
-class Variable {
- constructor(name, scope) {
-
- /**
- * The variable name, as given in the source code.
- * @member {String} Variable#name
- */
- this.name = name;
-
- /**
- * List of defining occurrences of this variable (like in 'var ...'
- * statements or as parameter), as AST nodes.
- * @member {espree.Identifier[]} Variable#identifiers
- */
- this.identifiers = [];
-
- /**
- * List of {@link Reference|references} of this variable (excluding parameter entries)
- * in its defining scope and all nested scopes. For defining
- * occurrences only see {@link Variable#defs}.
- * @member {Reference[]} Variable#references
- */
- this.references = [];
-
- /**
- * List of defining occurrences of this variable (like in 'var ...'
- * statements or as parameter), as custom objects.
- * @member {Definition[]} Variable#defs
- */
- this.defs = [];
-
- this.tainted = false;
-
- /**
- * Whether this is a stack variable.
- * @member {boolean} Variable#stack
- */
- this.stack = true;
-
- /**
- * Reference to the enclosing Scope.
- * @member {Scope} Variable#scope
- */
- this.scope = scope;
- }
-}
-
-Variable.CatchClause = "CatchClause";
-Variable.Parameter = "Parameter";
-Variable.FunctionName = "FunctionName";
-Variable.ClassName = "ClassName";
-Variable.Variable = "Variable";
-Variable.ImportBinding = "ImportBinding";
-Variable.ImplicitGlobalVariable = "ImplicitGlobalVariable";
-
-module.exports = Variable;
-
-/* vim: set sw=4 ts=4 et tw=80 : */
-
-
-/***/ }),
-
-/***/ 81217:
-/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
-
-/*
- Copyright (C) 2014 Yusuke Suzuki
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-(function () {
- 'use strict';
-
- var estraverse = __webpack_require__(50165);
-
- function isNode(node) {
- if (node == null) {
- return false;
- }
- return typeof node === 'object' && typeof node.type === 'string';
- }
-
- function isProperty(nodeType, key) {
- return (nodeType === estraverse.Syntax.ObjectExpression || nodeType === estraverse.Syntax.ObjectPattern) && key === 'properties';
- }
-
- function Visitor(visitor, options) {
- options = options || {};
-
- this.__visitor = visitor || this;
- this.__childVisitorKeys = options.childVisitorKeys
- ? Object.assign({}, estraverse.VisitorKeys, options.childVisitorKeys)
- : estraverse.VisitorKeys;
- if (options.fallback === 'iteration') {
- this.__fallback = Object.keys;
- } else if (typeof options.fallback === 'function') {
- this.__fallback = options.fallback;
- }
- }
-
- /* Default method for visiting children.
- * When you need to call default visiting operation inside custom visiting
- * operation, you can use it with `this.visitChildren(node)`.
- */
- Visitor.prototype.visitChildren = function (node) {
- var type, children, i, iz, j, jz, child;
-
- if (node == null) {
- return;
- }
-
- type = node.type || estraverse.Syntax.Property;
-
- children = this.__childVisitorKeys[type];
- if (!children) {
- if (this.__fallback) {
- children = this.__fallback(node);
- } else {
- throw new Error('Unknown node type ' + type + '.');
- }
- }
-
- for (i = 0, iz = children.length; i < iz; ++i) {
- child = node[children[i]];
- if (child) {
- if (Array.isArray(child)) {
- for (j = 0, jz = child.length; j < jz; ++j) {
- if (child[j]) {
- if (isNode(child[j]) || isProperty(type, children[i])) {
- this.visit(child[j]);
- }
- }
- }
- } else if (isNode(child)) {
- this.visit(child);
- }
- }
- }
- };
-
- /* Dispatching node. */
- Visitor.prototype.visit = function (node) {
- var type;
-
- if (node == null) {
- return;
- }
-
- type = node.type || estraverse.Syntax.Property;
- if (this.__visitor[type]) {
- this.__visitor[type].call(this, node);
- return;
- }
- this.visitChildren(node);
- };
-
- exports.version = __webpack_require__(12166).version;
- exports.Visitor = Visitor;
- exports.visit = function (node, visitor, options) {
- var v = new Visitor(visitor, options);
- v.visit(node);
- };
-}());
-/* vim: set sw=4 ts=4 et tw=80 : */
-
-
-/***/ }),
-
-/***/ 50165:
-/***/ (function(__unused_webpack_module, exports) {
-
-/*
- Copyright (C) 2012-2013 Yusuke Suzuki
- Copyright (C) 2012 Ariya Hidayat
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-/*jslint vars:false, bitwise:true*/
-/*jshint indent:4*/
-/*global exports:true*/
-(function clone(exports) {
- 'use strict';
-
- var Syntax,
- VisitorOption,
- VisitorKeys,
- BREAK,
- SKIP,
- REMOVE;
-
- function deepCopy(obj) {
- var ret = {}, key, val;
- for (key in obj) {
- if (obj.hasOwnProperty(key)) {
- val = obj[key];
- if (typeof val === 'object' && val !== null) {
- ret[key] = deepCopy(val);
- } else {
- ret[key] = val;
- }
- }
- }
- return ret;
- }
-
- // based on LLVM libc++ upper_bound / lower_bound
- // MIT License
-
- function upperBound(array, func) {
- var diff, len, i, current;
-
- len = array.length;
- i = 0;
-
- while (len) {
- diff = len >>> 1;
- current = i + diff;
- if (func(array[current])) {
- len = diff;
- } else {
- i = current + 1;
- len -= diff + 1;
- }
- }
- return i;
- }
-
- Syntax = {
- AssignmentExpression: 'AssignmentExpression',
- AssignmentPattern: 'AssignmentPattern',
- ArrayExpression: 'ArrayExpression',
- ArrayPattern: 'ArrayPattern',
- ArrowFunctionExpression: 'ArrowFunctionExpression',
- AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7.
- BlockStatement: 'BlockStatement',
- BinaryExpression: 'BinaryExpression',
- BreakStatement: 'BreakStatement',
- CallExpression: 'CallExpression',
- CatchClause: 'CatchClause',
- ChainExpression: 'ChainExpression',
- ClassBody: 'ClassBody',
- ClassDeclaration: 'ClassDeclaration',
- ClassExpression: 'ClassExpression',
- ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7.
- ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7.
- ConditionalExpression: 'ConditionalExpression',
- ContinueStatement: 'ContinueStatement',
- DebuggerStatement: 'DebuggerStatement',
- DirectiveStatement: 'DirectiveStatement',
- DoWhileStatement: 'DoWhileStatement',
- EmptyStatement: 'EmptyStatement',
- ExportAllDeclaration: 'ExportAllDeclaration',
- ExportDefaultDeclaration: 'ExportDefaultDeclaration',
- ExportNamedDeclaration: 'ExportNamedDeclaration',
- ExportSpecifier: 'ExportSpecifier',
- ExpressionStatement: 'ExpressionStatement',
- ForStatement: 'ForStatement',
- ForInStatement: 'ForInStatement',
- ForOfStatement: 'ForOfStatement',
- FunctionDeclaration: 'FunctionDeclaration',
- FunctionExpression: 'FunctionExpression',
- GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7.
- Identifier: 'Identifier',
- IfStatement: 'IfStatement',
- ImportExpression: 'ImportExpression',
- ImportDeclaration: 'ImportDeclaration',
- ImportDefaultSpecifier: 'ImportDefaultSpecifier',
- ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
- ImportSpecifier: 'ImportSpecifier',
- Literal: 'Literal',
- LabeledStatement: 'LabeledStatement',
- LogicalExpression: 'LogicalExpression',
- MemberExpression: 'MemberExpression',
- MetaProperty: 'MetaProperty',
- MethodDefinition: 'MethodDefinition',
- ModuleSpecifier: 'ModuleSpecifier',
- NewExpression: 'NewExpression',
- ObjectExpression: 'ObjectExpression',
- ObjectPattern: 'ObjectPattern',
- Program: 'Program',
- Property: 'Property',
- RestElement: 'RestElement',
- ReturnStatement: 'ReturnStatement',
- SequenceExpression: 'SequenceExpression',
- SpreadElement: 'SpreadElement',
- Super: 'Super',
- SwitchStatement: 'SwitchStatement',
- SwitchCase: 'SwitchCase',
- TaggedTemplateExpression: 'TaggedTemplateExpression',
- TemplateElement: 'TemplateElement',
- TemplateLiteral: 'TemplateLiteral',
- ThisExpression: 'ThisExpression',
- ThrowStatement: 'ThrowStatement',
- TryStatement: 'TryStatement',
- UnaryExpression: 'UnaryExpression',
- UpdateExpression: 'UpdateExpression',
- VariableDeclaration: 'VariableDeclaration',
- VariableDeclarator: 'VariableDeclarator',
- WhileStatement: 'WhileStatement',
- WithStatement: 'WithStatement',
- YieldExpression: 'YieldExpression'
- };
-
- VisitorKeys = {
- AssignmentExpression: ['left', 'right'],
- AssignmentPattern: ['left', 'right'],
- ArrayExpression: ['elements'],
- ArrayPattern: ['elements'],
- ArrowFunctionExpression: ['params', 'body'],
- AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7.
- BlockStatement: ['body'],
- BinaryExpression: ['left', 'right'],
- BreakStatement: ['label'],
- CallExpression: ['callee', 'arguments'],
- CatchClause: ['param', 'body'],
- ChainExpression: ['expression'],
- ClassBody: ['body'],
- ClassDeclaration: ['id', 'superClass', 'body'],
- ClassExpression: ['id', 'superClass', 'body'],
- ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7.
- ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
- ConditionalExpression: ['test', 'consequent', 'alternate'],
- ContinueStatement: ['label'],
- DebuggerStatement: [],
- DirectiveStatement: [],
- DoWhileStatement: ['body', 'test'],
- EmptyStatement: [],
- ExportAllDeclaration: ['source'],
- ExportDefaultDeclaration: ['declaration'],
- ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
- ExportSpecifier: ['exported', 'local'],
- ExpressionStatement: ['expression'],
- ForStatement: ['init', 'test', 'update', 'body'],
- ForInStatement: ['left', 'right', 'body'],
- ForOfStatement: ['left', 'right', 'body'],
- FunctionDeclaration: ['id', 'params', 'body'],
- FunctionExpression: ['id', 'params', 'body'],
- GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
- Identifier: [],
- IfStatement: ['test', 'consequent', 'alternate'],
- ImportExpression: ['source'],
- ImportDeclaration: ['specifiers', 'source'],
- ImportDefaultSpecifier: ['local'],
- ImportNamespaceSpecifier: ['local'],
- ImportSpecifier: ['imported', 'local'],
- Literal: [],
- LabeledStatement: ['label', 'body'],
- LogicalExpression: ['left', 'right'],
- MemberExpression: ['object', 'property'],
- MetaProperty: ['meta', 'property'],
- MethodDefinition: ['key', 'value'],
- ModuleSpecifier: [],
- NewExpression: ['callee', 'arguments'],
- ObjectExpression: ['properties'],
- ObjectPattern: ['properties'],
- Program: ['body'],
- Property: ['key', 'value'],
- RestElement: [ 'argument' ],
- ReturnStatement: ['argument'],
- SequenceExpression: ['expressions'],
- SpreadElement: ['argument'],
- Super: [],
- SwitchStatement: ['discriminant', 'cases'],
- SwitchCase: ['test', 'consequent'],
- TaggedTemplateExpression: ['tag', 'quasi'],
- TemplateElement: [],
- TemplateLiteral: ['quasis', 'expressions'],
- ThisExpression: [],
- ThrowStatement: ['argument'],
- TryStatement: ['block', 'handler', 'finalizer'],
- UnaryExpression: ['argument'],
- UpdateExpression: ['argument'],
- VariableDeclaration: ['declarations'],
- VariableDeclarator: ['id', 'init'],
- WhileStatement: ['test', 'body'],
- WithStatement: ['object', 'body'],
- YieldExpression: ['argument']
- };
-
- // unique id
- BREAK = {};
- SKIP = {};
- REMOVE = {};
-
- VisitorOption = {
- Break: BREAK,
- Skip: SKIP,
- Remove: REMOVE
- };
-
- function Reference(parent, key) {
- this.parent = parent;
- this.key = key;
- }
-
- Reference.prototype.replace = function replace(node) {
- this.parent[this.key] = node;
- };
-
- Reference.prototype.remove = function remove() {
- if (Array.isArray(this.parent)) {
- this.parent.splice(this.key, 1);
- return true;
- } else {
- this.replace(null);
- return false;
- }
- };
-
- function Element(node, path, wrap, ref) {
- this.node = node;
- this.path = path;
- this.wrap = wrap;
- this.ref = ref;
- }
-
- function Controller() { }
-
- // API:
- // return property path array from root to current node
- Controller.prototype.path = function path() {
- var i, iz, j, jz, result, element;
-
- function addToPath(result, path) {
- if (Array.isArray(path)) {
- for (j = 0, jz = path.length; j < jz; ++j) {
- result.push(path[j]);
- }
- } else {
- result.push(path);
- }
- }
-
- // root node
- if (!this.__current.path) {
- return null;
- }
-
- // first node is sentinel, second node is root element
- result = [];
- for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
- element = this.__leavelist[i];
- addToPath(result, element.path);
- }
- addToPath(result, this.__current.path);
- return result;
- };
-
- // API:
- // return type of current node
- Controller.prototype.type = function () {
- var node = this.current();
- return node.type || this.__current.wrap;
- };
-
- // API:
- // return array of parent elements
- Controller.prototype.parents = function parents() {
- var i, iz, result;
-
- // first node is sentinel
- result = [];
- for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
- result.push(this.__leavelist[i].node);
- }
-
- return result;
- };
-
- // API:
- // return current node
- Controller.prototype.current = function current() {
- return this.__current.node;
- };
-
- Controller.prototype.__execute = function __execute(callback, element) {
- var previous, result;
-
- result = undefined;
-
- previous = this.__current;
- this.__current = element;
- this.__state = null;
- if (callback) {
- result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
- }
- this.__current = previous;
-
- return result;
- };
-
- // API:
- // notify control skip / break
- Controller.prototype.notify = function notify(flag) {
- this.__state = flag;
- };
-
- // API:
- // skip child nodes of current node
- Controller.prototype.skip = function () {
- this.notify(SKIP);
- };
-
- // API:
- // break traversals
- Controller.prototype['break'] = function () {
- this.notify(BREAK);
- };
-
- // API:
- // remove node
- Controller.prototype.remove = function () {
- this.notify(REMOVE);
- };
-
- Controller.prototype.__initialize = function(root, visitor) {
- this.visitor = visitor;
- this.root = root;
- this.__worklist = [];
- this.__leavelist = [];
- this.__current = null;
- this.__state = null;
- this.__fallback = null;
- if (visitor.fallback === 'iteration') {
- this.__fallback = Object.keys;
- } else if (typeof visitor.fallback === 'function') {
- this.__fallback = visitor.fallback;
- }
-
- this.__keys = VisitorKeys;
- if (visitor.keys) {
- this.__keys = Object.assign(Object.create(this.__keys), visitor.keys);
- }
- };
-
- function isNode(node) {
- if (node == null) {
- return false;
- }
- return typeof node === 'object' && typeof node.type === 'string';
- }
-
- function isProperty(nodeType, key) {
- return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
- }
-
- function candidateExistsInLeaveList(leavelist, candidate) {
- for (var i = leavelist.length - 1; i >= 0; --i) {
- if (leavelist[i].node === candidate) {
- return true;
- }
- }
- return false;
- }
-
- Controller.prototype.traverse = function traverse(root, visitor) {
- var worklist,
- leavelist,
- element,
- node,
- nodeType,
- ret,
- key,
- current,
- current2,
- candidates,
- candidate,
- sentinel;
-
- this.__initialize(root, visitor);
-
- sentinel = {};
-
- // reference
- worklist = this.__worklist;
- leavelist = this.__leavelist;
-
- // initialize
- worklist.push(new Element(root, null, null, null));
- leavelist.push(new Element(null, null, null, null));
-
- while (worklist.length) {
- element = worklist.pop();
-
- if (element === sentinel) {
- element = leavelist.pop();
-
- ret = this.__execute(visitor.leave, element);
-
- if (this.__state === BREAK || ret === BREAK) {
- return;
- }
- continue;
- }
-
- if (element.node) {
-
- ret = this.__execute(visitor.enter, element);
-
- if (this.__state === BREAK || ret === BREAK) {
- return;
- }
-
- worklist.push(sentinel);
- leavelist.push(element);
-
- if (this.__state === SKIP || ret === SKIP) {
- continue;
- }
-
- node = element.node;
- nodeType = node.type || element.wrap;
- candidates = this.__keys[nodeType];
- if (!candidates) {
- if (this.__fallback) {
- candidates = this.__fallback(node);
- } else {
- throw new Error('Unknown node type ' + nodeType + '.');
- }
- }
-
- current = candidates.length;
- while ((current -= 1) >= 0) {
- key = candidates[current];
- candidate = node[key];
- if (!candidate) {
- continue;
- }
-
- if (Array.isArray(candidate)) {
- current2 = candidate.length;
- while ((current2 -= 1) >= 0) {
- if (!candidate[current2]) {
- continue;
- }
-
- if (candidateExistsInLeaveList(leavelist, candidate[current2])) {
- continue;
- }
-
- if (isProperty(nodeType, candidates[current])) {
- element = new Element(candidate[current2], [key, current2], 'Property', null);
- } else if (isNode(candidate[current2])) {
- element = new Element(candidate[current2], [key, current2], null, null);
- } else {
- continue;
- }
- worklist.push(element);
- }
- } else if (isNode(candidate)) {
- if (candidateExistsInLeaveList(leavelist, candidate)) {
- continue;
- }
-
- worklist.push(new Element(candidate, key, null, null));
- }
- }
- }
- }
- };
-
- Controller.prototype.replace = function replace(root, visitor) {
- var worklist,
- leavelist,
- node,
- nodeType,
- target,
- element,
- current,
- current2,
- candidates,
- candidate,
- sentinel,
- outer,
- key;
-
- function removeElem(element) {
- var i,
- key,
- nextElem,
- parent;
-
- if (element.ref.remove()) {
- // When the reference is an element of an array.
- key = element.ref.key;
- parent = element.ref.parent;
-
- // If removed from array, then decrease following items' keys.
- i = worklist.length;
- while (i--) {
- nextElem = worklist[i];
- if (nextElem.ref && nextElem.ref.parent === parent) {
- if (nextElem.ref.key < key) {
- break;
- }
- --nextElem.ref.key;
- }
- }
- }
- }
-
- this.__initialize(root, visitor);
-
- sentinel = {};
-
- // reference
- worklist = this.__worklist;
- leavelist = this.__leavelist;
-
- // initialize
- outer = {
- root: root
- };
- element = new Element(root, null, null, new Reference(outer, 'root'));
- worklist.push(element);
- leavelist.push(element);
-
- while (worklist.length) {
- element = worklist.pop();
-
- if (element === sentinel) {
- element = leavelist.pop();
-
- target = this.__execute(visitor.leave, element);
-
- // node may be replaced with null,
- // so distinguish between undefined and null in this place
- if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
- // replace
- element.ref.replace(target);
- }
-
- if (this.__state === REMOVE || target === REMOVE) {
- removeElem(element);
- }
-
- if (this.__state === BREAK || target === BREAK) {
- return outer.root;
- }
- continue;
- }
-
- target = this.__execute(visitor.enter, element);
-
- // node may be replaced with null,
- // so distinguish between undefined and null in this place
- if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
- // replace
- element.ref.replace(target);
- element.node = target;
- }
-
- if (this.__state === REMOVE || target === REMOVE) {
- removeElem(element);
- element.node = null;
- }
-
- if (this.__state === BREAK || target === BREAK) {
- return outer.root;
- }
-
- // node may be null
- node = element.node;
- if (!node) {
- continue;
- }
-
- worklist.push(sentinel);
- leavelist.push(element);
-
- if (this.__state === SKIP || target === SKIP) {
- continue;
- }
-
- nodeType = node.type || element.wrap;
- candidates = this.__keys[nodeType];
- if (!candidates) {
- if (this.__fallback) {
- candidates = this.__fallback(node);
- } else {
- throw new Error('Unknown node type ' + nodeType + '.');
- }
- }
-
- current = candidates.length;
- while ((current -= 1) >= 0) {
- key = candidates[current];
- candidate = node[key];
- if (!candidate) {
- continue;
- }
-
- if (Array.isArray(candidate)) {
- current2 = candidate.length;
- while ((current2 -= 1) >= 0) {
- if (!candidate[current2]) {
- continue;
- }
- if (isProperty(nodeType, candidates[current])) {
- element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
- } else if (isNode(candidate[current2])) {
- element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
- } else {
- continue;
- }
- worklist.push(element);
- }
- } else if (isNode(candidate)) {
- worklist.push(new Element(candidate, key, null, new Reference(node, key)));
- }
- }
- }
-
- return outer.root;
- };
-
- function traverse(root, visitor) {
- var controller = new Controller();
- return controller.traverse(root, visitor);
- }
-
- function replace(root, visitor) {
- var controller = new Controller();
- return controller.replace(root, visitor);
- }
-
- function extendCommentRange(comment, tokens) {
- var target;
-
- target = upperBound(tokens, function search(token) {
- return token.range[0] > comment.range[0];
- });
-
- comment.extendedRange = [comment.range[0], comment.range[1]];
-
- if (target !== tokens.length) {
- comment.extendedRange[1] = tokens[target].range[0];
- }
-
- target -= 1;
- if (target >= 0) {
- comment.extendedRange[0] = tokens[target].range[1];
- }
-
- return comment;
- }
-
- function attachComments(tree, providedComments, tokens) {
- // At first, we should calculate extended comment ranges.
- var comments = [], comment, len, i, cursor;
-
- if (!tree.range) {
- throw new Error('attachComments needs range information');
- }
-
- // tokens array is empty, we attach comments to tree as 'leadingComments'
- if (!tokens.length) {
- if (providedComments.length) {
- for (i = 0, len = providedComments.length; i < len; i += 1) {
- comment = deepCopy(providedComments[i]);
- comment.extendedRange = [0, tree.range[0]];
- comments.push(comment);
- }
- tree.leadingComments = comments;
- }
- return tree;
- }
-
- for (i = 0, len = providedComments.length; i < len; i += 1) {
- comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
- }
-
- // This is based on John Freeman's implementation.
- cursor = 0;
- traverse(tree, {
- enter: function (node) {
- var comment;
-
- while (cursor < comments.length) {
- comment = comments[cursor];
- if (comment.extendedRange[1] > node.range[0]) {
- break;
- }
-
- if (comment.extendedRange[1] === node.range[0]) {
- if (!node.leadingComments) {
- node.leadingComments = [];
- }
- node.leadingComments.push(comment);
- comments.splice(cursor, 1);
- } else {
- cursor += 1;
- }
- }
-
- // already out of owned node
- if (cursor === comments.length) {
- return VisitorOption.Break;
- }
-
- if (comments[cursor].extendedRange[0] > node.range[1]) {
- return VisitorOption.Skip;
- }
- }
- });
-
- cursor = 0;
- traverse(tree, {
- leave: function (node) {
- var comment;
-
- while (cursor < comments.length) {
- comment = comments[cursor];
- if (node.range[1] < comment.extendedRange[0]) {
- break;
- }
-
- if (node.range[1] === comment.extendedRange[0]) {
- if (!node.trailingComments) {
- node.trailingComments = [];
- }
- node.trailingComments.push(comment);
- comments.splice(cursor, 1);
- } else {
- cursor += 1;
- }
- }
-
- // already out of owned node
- if (cursor === comments.length) {
- return VisitorOption.Break;
- }
-
- if (comments[cursor].extendedRange[0] > node.range[1]) {
- return VisitorOption.Skip;
- }
- }
- });
-
- return tree;
- }
-
- exports.Syntax = Syntax;
- exports.traverse = traverse;
- exports.replace = replace;
- exports.attachComments = attachComments;
- exports.VisitorKeys = VisitorKeys;
- exports.VisitorOption = VisitorOption;
- exports.Controller = Controller;
- exports.cloneEnvironment = function () { return clone({}); };
-
- return exports;
-}(exports));
-/* vim: set sw=4 ts=4 et tw=80 : */
-
-
-/***/ }),
-
-/***/ 18350:
-/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
-
-/*
- Copyright (C) 2012-2013 Yusuke Suzuki
- Copyright (C) 2012 Ariya Hidayat
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-/*jslint vars:false, bitwise:true*/
-/*jshint indent:4*/
-/*global exports:true*/
-(function clone(exports) {
- 'use strict';
-
- var Syntax,
- VisitorOption,
- VisitorKeys,
- BREAK,
- SKIP,
- REMOVE;
-
- function deepCopy(obj) {
- var ret = {}, key, val;
- for (key in obj) {
- if (obj.hasOwnProperty(key)) {
- val = obj[key];
- if (typeof val === 'object' && val !== null) {
- ret[key] = deepCopy(val);
- } else {
- ret[key] = val;
- }
- }
- }
- return ret;
- }
-
- // based on LLVM libc++ upper_bound / lower_bound
- // MIT License
-
- function upperBound(array, func) {
- var diff, len, i, current;
-
- len = array.length;
- i = 0;
-
- while (len) {
- diff = len >>> 1;
- current = i + diff;
- if (func(array[current])) {
- len = diff;
- } else {
- i = current + 1;
- len -= diff + 1;
- }
- }
- return i;
- }
-
- Syntax = {
- AssignmentExpression: 'AssignmentExpression',
- AssignmentPattern: 'AssignmentPattern',
- ArrayExpression: 'ArrayExpression',
- ArrayPattern: 'ArrayPattern',
- ArrowFunctionExpression: 'ArrowFunctionExpression',
- AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7.
- BlockStatement: 'BlockStatement',
- BinaryExpression: 'BinaryExpression',
- BreakStatement: 'BreakStatement',
- CallExpression: 'CallExpression',
- CatchClause: 'CatchClause',
- ClassBody: 'ClassBody',
- ClassDeclaration: 'ClassDeclaration',
- ClassExpression: 'ClassExpression',
- ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7.
- ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7.
- ConditionalExpression: 'ConditionalExpression',
- ContinueStatement: 'ContinueStatement',
- DebuggerStatement: 'DebuggerStatement',
- DirectiveStatement: 'DirectiveStatement',
- DoWhileStatement: 'DoWhileStatement',
- EmptyStatement: 'EmptyStatement',
- ExportAllDeclaration: 'ExportAllDeclaration',
- ExportDefaultDeclaration: 'ExportDefaultDeclaration',
- ExportNamedDeclaration: 'ExportNamedDeclaration',
- ExportSpecifier: 'ExportSpecifier',
- ExpressionStatement: 'ExpressionStatement',
- ForStatement: 'ForStatement',
- ForInStatement: 'ForInStatement',
- ForOfStatement: 'ForOfStatement',
- FunctionDeclaration: 'FunctionDeclaration',
- FunctionExpression: 'FunctionExpression',
- GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7.
- Identifier: 'Identifier',
- IfStatement: 'IfStatement',
- ImportExpression: 'ImportExpression',
- ImportDeclaration: 'ImportDeclaration',
- ImportDefaultSpecifier: 'ImportDefaultSpecifier',
- ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
- ImportSpecifier: 'ImportSpecifier',
- Literal: 'Literal',
- LabeledStatement: 'LabeledStatement',
- LogicalExpression: 'LogicalExpression',
- MemberExpression: 'MemberExpression',
- MetaProperty: 'MetaProperty',
- MethodDefinition: 'MethodDefinition',
- ModuleSpecifier: 'ModuleSpecifier',
- NewExpression: 'NewExpression',
- ObjectExpression: 'ObjectExpression',
- ObjectPattern: 'ObjectPattern',
- Program: 'Program',
- Property: 'Property',
- RestElement: 'RestElement',
- ReturnStatement: 'ReturnStatement',
- SequenceExpression: 'SequenceExpression',
- SpreadElement: 'SpreadElement',
- Super: 'Super',
- SwitchStatement: 'SwitchStatement',
- SwitchCase: 'SwitchCase',
- TaggedTemplateExpression: 'TaggedTemplateExpression',
- TemplateElement: 'TemplateElement',
- TemplateLiteral: 'TemplateLiteral',
- ThisExpression: 'ThisExpression',
- ThrowStatement: 'ThrowStatement',
- TryStatement: 'TryStatement',
- UnaryExpression: 'UnaryExpression',
- UpdateExpression: 'UpdateExpression',
- VariableDeclaration: 'VariableDeclaration',
- VariableDeclarator: 'VariableDeclarator',
- WhileStatement: 'WhileStatement',
- WithStatement: 'WithStatement',
- YieldExpression: 'YieldExpression'
- };
-
- VisitorKeys = {
- AssignmentExpression: ['left', 'right'],
- AssignmentPattern: ['left', 'right'],
- ArrayExpression: ['elements'],
- ArrayPattern: ['elements'],
- ArrowFunctionExpression: ['params', 'body'],
- AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7.
- BlockStatement: ['body'],
- BinaryExpression: ['left', 'right'],
- BreakStatement: ['label'],
- CallExpression: ['callee', 'arguments'],
- CatchClause: ['param', 'body'],
- ClassBody: ['body'],
- ClassDeclaration: ['id', 'superClass', 'body'],
- ClassExpression: ['id', 'superClass', 'body'],
- ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7.
- ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
- ConditionalExpression: ['test', 'consequent', 'alternate'],
- ContinueStatement: ['label'],
- DebuggerStatement: [],
- DirectiveStatement: [],
- DoWhileStatement: ['body', 'test'],
- EmptyStatement: [],
- ExportAllDeclaration: ['source'],
- ExportDefaultDeclaration: ['declaration'],
- ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
- ExportSpecifier: ['exported', 'local'],
- ExpressionStatement: ['expression'],
- ForStatement: ['init', 'test', 'update', 'body'],
- ForInStatement: ['left', 'right', 'body'],
- ForOfStatement: ['left', 'right', 'body'],
- FunctionDeclaration: ['id', 'params', 'body'],
- FunctionExpression: ['id', 'params', 'body'],
- GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
- Identifier: [],
- IfStatement: ['test', 'consequent', 'alternate'],
- ImportExpression: ['source'],
- ImportDeclaration: ['specifiers', 'source'],
- ImportDefaultSpecifier: ['local'],
- ImportNamespaceSpecifier: ['local'],
- ImportSpecifier: ['imported', 'local'],
- Literal: [],
- LabeledStatement: ['label', 'body'],
- LogicalExpression: ['left', 'right'],
- MemberExpression: ['object', 'property'],
- MetaProperty: ['meta', 'property'],
- MethodDefinition: ['key', 'value'],
- ModuleSpecifier: [],
- NewExpression: ['callee', 'arguments'],
- ObjectExpression: ['properties'],
- ObjectPattern: ['properties'],
- Program: ['body'],
- Property: ['key', 'value'],
- RestElement: [ 'argument' ],
- ReturnStatement: ['argument'],
- SequenceExpression: ['expressions'],
- SpreadElement: ['argument'],
- Super: [],
- SwitchStatement: ['discriminant', 'cases'],
- SwitchCase: ['test', 'consequent'],
- TaggedTemplateExpression: ['tag', 'quasi'],
- TemplateElement: [],
- TemplateLiteral: ['quasis', 'expressions'],
- ThisExpression: [],
- ThrowStatement: ['argument'],
- TryStatement: ['block', 'handler', 'finalizer'],
- UnaryExpression: ['argument'],
- UpdateExpression: ['argument'],
- VariableDeclaration: ['declarations'],
- VariableDeclarator: ['id', 'init'],
- WhileStatement: ['test', 'body'],
- WithStatement: ['object', 'body'],
- YieldExpression: ['argument']
- };
-
- // unique id
- BREAK = {};
- SKIP = {};
- REMOVE = {};
-
- VisitorOption = {
- Break: BREAK,
- Skip: SKIP,
- Remove: REMOVE
- };
-
- function Reference(parent, key) {
- this.parent = parent;
- this.key = key;
- }
-
- Reference.prototype.replace = function replace(node) {
- this.parent[this.key] = node;
- };
-
- Reference.prototype.remove = function remove() {
- if (Array.isArray(this.parent)) {
- this.parent.splice(this.key, 1);
- return true;
- } else {
- this.replace(null);
- return false;
- }
- };
-
- function Element(node, path, wrap, ref) {
- this.node = node;
- this.path = path;
- this.wrap = wrap;
- this.ref = ref;
- }
-
- function Controller() { }
-
- // API:
- // return property path array from root to current node
- Controller.prototype.path = function path() {
- var i, iz, j, jz, result, element;
-
- function addToPath(result, path) {
- if (Array.isArray(path)) {
- for (j = 0, jz = path.length; j < jz; ++j) {
- result.push(path[j]);
- }
- } else {
- result.push(path);
- }
- }
-
- // root node
- if (!this.__current.path) {
- return null;
- }
-
- // first node is sentinel, second node is root element
- result = [];
- for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
- element = this.__leavelist[i];
- addToPath(result, element.path);
- }
- addToPath(result, this.__current.path);
- return result;
- };
-
- // API:
- // return type of current node
- Controller.prototype.type = function () {
- var node = this.current();
- return node.type || this.__current.wrap;
- };
-
- // API:
- // return array of parent elements
- Controller.prototype.parents = function parents() {
- var i, iz, result;
-
- // first node is sentinel
- result = [];
- for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
- result.push(this.__leavelist[i].node);
- }
-
- return result;
- };
-
- // API:
- // return current node
- Controller.prototype.current = function current() {
- return this.__current.node;
- };
-
- Controller.prototype.__execute = function __execute(callback, element) {
- var previous, result;
-
- result = undefined;
-
- previous = this.__current;
- this.__current = element;
- this.__state = null;
- if (callback) {
- result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
- }
- this.__current = previous;
-
- return result;
- };
-
- // API:
- // notify control skip / break
- Controller.prototype.notify = function notify(flag) {
- this.__state = flag;
- };
-
- // API:
- // skip child nodes of current node
- Controller.prototype.skip = function () {
- this.notify(SKIP);
- };
-
- // API:
- // break traversals
- Controller.prototype['break'] = function () {
- this.notify(BREAK);
- };
-
- // API:
- // remove node
- Controller.prototype.remove = function () {
- this.notify(REMOVE);
- };
-
- Controller.prototype.__initialize = function(root, visitor) {
- this.visitor = visitor;
- this.root = root;
- this.__worklist = [];
- this.__leavelist = [];
- this.__current = null;
- this.__state = null;
- this.__fallback = null;
- if (visitor.fallback === 'iteration') {
- this.__fallback = Object.keys;
- } else if (typeof visitor.fallback === 'function') {
- this.__fallback = visitor.fallback;
- }
-
- this.__keys = VisitorKeys;
- if (visitor.keys) {
- this.__keys = Object.assign(Object.create(this.__keys), visitor.keys);
- }
- };
-
- function isNode(node) {
- if (node == null) {
- return false;
- }
- return typeof node === 'object' && typeof node.type === 'string';
- }
-
- function isProperty(nodeType, key) {
- return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
- }
-
- Controller.prototype.traverse = function traverse(root, visitor) {
- var worklist,
- leavelist,
- element,
- node,
- nodeType,
- ret,
- key,
- current,
- current2,
- candidates,
- candidate,
- sentinel;
-
- this.__initialize(root, visitor);
-
- sentinel = {};
-
- // reference
- worklist = this.__worklist;
- leavelist = this.__leavelist;
-
- // initialize
- worklist.push(new Element(root, null, null, null));
- leavelist.push(new Element(null, null, null, null));
-
- while (worklist.length) {
- element = worklist.pop();
-
- if (element === sentinel) {
- element = leavelist.pop();
-
- ret = this.__execute(visitor.leave, element);
-
- if (this.__state === BREAK || ret === BREAK) {
- return;
- }
- continue;
- }
-
- if (element.node) {
-
- ret = this.__execute(visitor.enter, element);
-
- if (this.__state === BREAK || ret === BREAK) {
- return;
- }
-
- worklist.push(sentinel);
- leavelist.push(element);
-
- if (this.__state === SKIP || ret === SKIP) {
- continue;
- }
-
- node = element.node;
- nodeType = node.type || element.wrap;
- candidates = this.__keys[nodeType];
- if (!candidates) {
- if (this.__fallback) {
- candidates = this.__fallback(node);
- } else {
- throw new Error('Unknown node type ' + nodeType + '.');
- }
- }
-
- current = candidates.length;
- while ((current -= 1) >= 0) {
- key = candidates[current];
- candidate = node[key];
- if (!candidate) {
- continue;
- }
-
- if (Array.isArray(candidate)) {
- current2 = candidate.length;
- while ((current2 -= 1) >= 0) {
- if (!candidate[current2]) {
- continue;
- }
- if (isProperty(nodeType, candidates[current])) {
- element = new Element(candidate[current2], [key, current2], 'Property', null);
- } else if (isNode(candidate[current2])) {
- element = new Element(candidate[current2], [key, current2], null, null);
- } else {
- continue;
- }
- worklist.push(element);
- }
- } else if (isNode(candidate)) {
- worklist.push(new Element(candidate, key, null, null));
- }
- }
- }
- }
- };
-
- Controller.prototype.replace = function replace(root, visitor) {
- var worklist,
- leavelist,
- node,
- nodeType,
- target,
- element,
- current,
- current2,
- candidates,
- candidate,
- sentinel,
- outer,
- key;
-
- function removeElem(element) {
- var i,
- key,
- nextElem,
- parent;
-
- if (element.ref.remove()) {
- // When the reference is an element of an array.
- key = element.ref.key;
- parent = element.ref.parent;
-
- // If removed from array, then decrease following items' keys.
- i = worklist.length;
- while (i--) {
- nextElem = worklist[i];
- if (nextElem.ref && nextElem.ref.parent === parent) {
- if (nextElem.ref.key < key) {
- break;
- }
- --nextElem.ref.key;
- }
- }
- }
- }
-
- this.__initialize(root, visitor);
-
- sentinel = {};
-
- // reference
- worklist = this.__worklist;
- leavelist = this.__leavelist;
-
- // initialize
- outer = {
- root: root
- };
- element = new Element(root, null, null, new Reference(outer, 'root'));
- worklist.push(element);
- leavelist.push(element);
-
- while (worklist.length) {
- element = worklist.pop();
-
- if (element === sentinel) {
- element = leavelist.pop();
-
- target = this.__execute(visitor.leave, element);
-
- // node may be replaced with null,
- // so distinguish between undefined and null in this place
- if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
- // replace
- element.ref.replace(target);
- }
-
- if (this.__state === REMOVE || target === REMOVE) {
- removeElem(element);
- }
-
- if (this.__state === BREAK || target === BREAK) {
- return outer.root;
- }
- continue;
- }
-
- target = this.__execute(visitor.enter, element);
-
- // node may be replaced with null,
- // so distinguish between undefined and null in this place
- if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
- // replace
- element.ref.replace(target);
- element.node = target;
- }
-
- if (this.__state === REMOVE || target === REMOVE) {
- removeElem(element);
- element.node = null;
- }
-
- if (this.__state === BREAK || target === BREAK) {
- return outer.root;
- }
-
- // node may be null
- node = element.node;
- if (!node) {
- continue;
- }
-
- worklist.push(sentinel);
- leavelist.push(element);
-
- if (this.__state === SKIP || target === SKIP) {
- continue;
- }
-
- nodeType = node.type || element.wrap;
- candidates = this.__keys[nodeType];
- if (!candidates) {
- if (this.__fallback) {
- candidates = this.__fallback(node);
- } else {
- throw new Error('Unknown node type ' + nodeType + '.');
- }
- }
-
- current = candidates.length;
- while ((current -= 1) >= 0) {
- key = candidates[current];
- candidate = node[key];
- if (!candidate) {
- continue;
- }
-
- if (Array.isArray(candidate)) {
- current2 = candidate.length;
- while ((current2 -= 1) >= 0) {
- if (!candidate[current2]) {
- continue;
- }
- if (isProperty(nodeType, candidates[current])) {
- element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
- } else if (isNode(candidate[current2])) {
- element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
- } else {
- continue;
- }
- worklist.push(element);
- }
- } else if (isNode(candidate)) {
- worklist.push(new Element(candidate, key, null, new Reference(node, key)));
- }
- }
- }
-
- return outer.root;
- };
-
- function traverse(root, visitor) {
- var controller = new Controller();
- return controller.traverse(root, visitor);
- }
-
- function replace(root, visitor) {
- var controller = new Controller();
- return controller.replace(root, visitor);
- }
-
- function extendCommentRange(comment, tokens) {
- var target;
-
- target = upperBound(tokens, function search(token) {
- return token.range[0] > comment.range[0];
- });
-
- comment.extendedRange = [comment.range[0], comment.range[1]];
-
- if (target !== tokens.length) {
- comment.extendedRange[1] = tokens[target].range[0];
- }
-
- target -= 1;
- if (target >= 0) {
- comment.extendedRange[0] = tokens[target].range[1];
- }
-
- return comment;
- }
-
- function attachComments(tree, providedComments, tokens) {
- // At first, we should calculate extended comment ranges.
- var comments = [], comment, len, i, cursor;
-
- if (!tree.range) {
- throw new Error('attachComments needs range information');
- }
-
- // tokens array is empty, we attach comments to tree as 'leadingComments'
- if (!tokens.length) {
- if (providedComments.length) {
- for (i = 0, len = providedComments.length; i < len; i += 1) {
- comment = deepCopy(providedComments[i]);
- comment.extendedRange = [0, tree.range[0]];
- comments.push(comment);
- }
- tree.leadingComments = comments;
- }
- return tree;
- }
-
- for (i = 0, len = providedComments.length; i < len; i += 1) {
- comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
- }
-
- // This is based on John Freeman's implementation.
- cursor = 0;
- traverse(tree, {
- enter: function (node) {
- var comment;
-
- while (cursor < comments.length) {
- comment = comments[cursor];
- if (comment.extendedRange[1] > node.range[0]) {
- break;
- }
-
- if (comment.extendedRange[1] === node.range[0]) {
- if (!node.leadingComments) {
- node.leadingComments = [];
- }
- node.leadingComments.push(comment);
- comments.splice(cursor, 1);
- } else {
- cursor += 1;
- }
- }
-
- // already out of owned node
- if (cursor === comments.length) {
- return VisitorOption.Break;
- }
-
- if (comments[cursor].extendedRange[0] > node.range[1]) {
- return VisitorOption.Skip;
- }
- }
- });
-
- cursor = 0;
- traverse(tree, {
- leave: function (node) {
- var comment;
-
- while (cursor < comments.length) {
- comment = comments[cursor];
- if (node.range[1] < comment.extendedRange[0]) {
- break;
- }
-
- if (node.range[1] === comment.extendedRange[0]) {
- if (!node.trailingComments) {
- node.trailingComments = [];
- }
- node.trailingComments.push(comment);
- comments.splice(cursor, 1);
- } else {
- cursor += 1;
- }
- }
-
- // already out of owned node
- if (cursor === comments.length) {
- return VisitorOption.Break;
- }
-
- if (comments[cursor].extendedRange[0] > node.range[1]) {
- return VisitorOption.Skip;
- }
- }
- });
-
- return tree;
- }
-
- exports.version = (__webpack_require__(15535)/* .version */ .i8);
- exports.Syntax = Syntax;
- exports.traverse = traverse;
- exports.replace = replace;
- exports.attachComments = attachComments;
- exports.VisitorKeys = VisitorKeys;
- exports.VisitorOption = VisitorOption;
- exports.Controller = Controller;
- exports.cloneEnvironment = function () { return clone({}); };
-
- return exports;
-}(exports));
-/* vim: set sw=4 ts=4 et tw=80 : */
-
-
-/***/ }),
-
-/***/ 86140:
-/***/ (function(module) {
-
-module.exports = function (glob, opts) {
- if (typeof glob !== 'string') {
- throw new TypeError('Expected a string');
- }
-
- var str = String(glob);
-
- // The regexp we are building, as a string.
- var reStr = "";
-
- // Whether we are matching so called "extended" globs (like bash) and should
- // support single character matching, matching ranges of characters, group
- // matching, etc.
- var extended = opts ? !!opts.extended : false;
-
- // When globstar is _false_ (default), '/foo/*' is translated a regexp like
- // '^\/foo\/.*$' which will match any string beginning with '/foo/'
- // When globstar is _true_, '/foo/*' is translated to regexp like
- // '^\/foo\/[^/]*$' which will match any string beginning with '/foo/' BUT
- // which does not have a '/' to the right of it.
- // E.g. with '/foo/*' these will match: '/foo/bar', '/foo/bar.txt' but
- // these will not '/foo/bar/baz', '/foo/bar/baz.txt'
- // Lastely, when globstar is _true_, '/foo/**' is equivelant to '/foo/*' when
- // globstar is _false_
- var globstar = opts ? !!opts.globstar : false;
-
- // If we are doing extended matching, this boolean is true when we are inside
- // a group (eg {*.html,*.js}), and false otherwise.
- var inGroup = false;
-
- // RegExp flags (eg "i" ) to pass in to RegExp constructor.
- var flags = opts && typeof( opts.flags ) === "string" ? opts.flags : "";
-
- var c;
- for (var i = 0, len = str.length; i < len; i++) {
- c = str[i];
-
- switch (c) {
- case "/":
- case "$":
- case "^":
- case "+":
- case ".":
- case "(":
- case ")":
- case "=":
- case "!":
- case "|":
- reStr += "\\" + c;
- break;
-
- case "?":
- if (extended) {
- reStr += ".";
- break;
- }
-
- case "[":
- case "]":
- if (extended) {
- reStr += c;
- break;
- }
-
- case "{":
- if (extended) {
- inGroup = true;
- reStr += "(";
- break;
- }
-
- case "}":
- if (extended) {
- inGroup = false;
- reStr += ")";
- break;
- }
-
- case ",":
- if (inGroup) {
- reStr += "|";
- break;
- }
- reStr += "\\" + c;
- break;
-
- case "*":
- // Move over all consecutive "*"'s.
- // Also store the previous and next characters
- var prevChar = str[i - 1];
- var starCount = 1;
- while(str[i + 1] === "*") {
- starCount++;
- i++;
- }
- var nextChar = str[i + 1];
-
- if (!globstar) {
- // globstar is disabled, so treat any number of "*" as one
- reStr += ".*";
- } else {
- // globstar is enabled, so determine if this is a globstar segment
- var isGlobstar = starCount > 1 // multiple "*"'s
- && (prevChar === "/" || prevChar === undefined) // from the start of the segment
- && (nextChar === "/" || nextChar === undefined) // to the end of the segment
-
- if (isGlobstar) {
- // it's a globstar, so match zero or more path segments
- reStr += "((?:[^/]*(?:\/|$))*)";
- i++; // move over the "/"
- } else {
- // it's not a globstar, so only match one path segment
- reStr += "([^/]*)";
- }
- }
- break;
-
- default:
- reStr += c;
- }
- }
-
- // When regexp 'g' flag is specified don't
- // constrain the regular expression with ^ & $
- if (!flags || !~flags.indexOf('g')) {
- reStr = "^" + reStr + "$";
- }
-
- return new RegExp(reStr, flags);
-};
-
-
-/***/ }),
-
-/***/ 89132:
-/***/ (function(module) {
-
-"use strict";
-
-
-module.exports = clone
-
-var getPrototypeOf = Object.getPrototypeOf || function (obj) {
- return obj.__proto__
-}
-
-function clone (obj) {
- if (obj === null || typeof obj !== 'object')
- return obj
-
- if (obj instanceof Object)
- var copy = { __proto__: getPrototypeOf(obj) }
- else
- var copy = Object.create(null)
-
- Object.getOwnPropertyNames(obj).forEach(function (key) {
- Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key))
- })
-
- return copy
-}
-
-
-/***/ }),
-
-/***/ 90552:
-/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
-
-var fs = __webpack_require__(57147)
-var polyfills = __webpack_require__(11290)
-var legacy = __webpack_require__(54410)
-var clone = __webpack_require__(89132)
-
-var util = __webpack_require__(73837)
-
-/* istanbul ignore next - node 0.x polyfill */
-var gracefulQueue
-var previousSymbol
-
-/* istanbul ignore else - node 0.x polyfill */
-if (typeof Symbol === 'function' && typeof Symbol.for === 'function') {
- gracefulQueue = Symbol.for('graceful-fs.queue')
- // This is used in testing by future versions
- previousSymbol = Symbol.for('graceful-fs.previous')
-} else {
- gracefulQueue = '___graceful-fs.queue'
- previousSymbol = '___graceful-fs.previous'
-}
-
-function noop () {}
-
-function publishQueue(context, queue) {
- Object.defineProperty(context, gracefulQueue, {
- get: function() {
- return queue
- }
- })
-}
-
-var debug = noop
-if (util.debuglog)
- debug = util.debuglog('gfs4')
-else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ''))
- debug = function() {
- var m = util.format.apply(util, arguments)
- m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ')
- console.error(m)
- }
-
-// Once time initialization
-if (!fs[gracefulQueue]) {
- // This queue can be shared by multiple loaded instances
- var queue = global[gracefulQueue] || []
- publishQueue(fs, queue)
-
- // Patch fs.close/closeSync to shared queue version, because we need
- // to retry() whenever a close happens *anywhere* in the program.
- // This is essential when multiple graceful-fs instances are
- // in play at the same time.
- fs.close = (function (fs$close) {
- function close (fd, cb) {
- return fs$close.call(fs, fd, function (err) {
- // This function uses the graceful-fs shared queue
- if (!err) {
- resetQueue()
- }
-
- if (typeof cb === 'function')
- cb.apply(this, arguments)
- })
- }
-
- Object.defineProperty(close, previousSymbol, {
- value: fs$close
- })
- return close
- })(fs.close)
-
- fs.closeSync = (function (fs$closeSync) {
- function closeSync (fd) {
- // This function uses the graceful-fs shared queue
- fs$closeSync.apply(fs, arguments)
- resetQueue()
- }
-
- Object.defineProperty(closeSync, previousSymbol, {
- value: fs$closeSync
- })
- return closeSync
- })(fs.closeSync)
-
- if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
- process.on('exit', function() {
- debug(fs[gracefulQueue])
- __webpack_require__(39491).equal(fs[gracefulQueue].length, 0)
- })
- }
-}
-
-if (!global[gracefulQueue]) {
- publishQueue(global, fs[gracefulQueue]);
-}
-
-module.exports = patch(clone(fs))
-if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
- module.exports = patch(fs)
- fs.__patched = true;
-}
-
-function patch (fs) {
- // Everything that references the open() function needs to be in here
- polyfills(fs)
- fs.gracefulify = patch
-
- fs.createReadStream = createReadStream
- fs.createWriteStream = createWriteStream
- var fs$readFile = fs.readFile
- fs.readFile = readFile
- function readFile (path, options, cb) {
- if (typeof options === 'function')
- cb = options, options = null
-
- return go$readFile(path, options, cb)
-
- function go$readFile (path, options, cb, startTime) {
- return fs$readFile(path, options, function (err) {
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$readFile, [path, options, cb], err, startTime || Date.now(), Date.now()])
- else {
- if (typeof cb === 'function')
- cb.apply(this, arguments)
- }
- })
- }
- }
-
- var fs$writeFile = fs.writeFile
- fs.writeFile = writeFile
- function writeFile (path, data, options, cb) {
- if (typeof options === 'function')
- cb = options, options = null
-
- return go$writeFile(path, data, options, cb)
-
- function go$writeFile (path, data, options, cb, startTime) {
- return fs$writeFile(path, data, options, function (err) {
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$writeFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()])
- else {
- if (typeof cb === 'function')
- cb.apply(this, arguments)
- }
- })
- }
- }
-
- var fs$appendFile = fs.appendFile
- if (fs$appendFile)
- fs.appendFile = appendFile
- function appendFile (path, data, options, cb) {
- if (typeof options === 'function')
- cb = options, options = null
-
- return go$appendFile(path, data, options, cb)
-
- function go$appendFile (path, data, options, cb, startTime) {
- return fs$appendFile(path, data, options, function (err) {
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$appendFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()])
- else {
- if (typeof cb === 'function')
- cb.apply(this, arguments)
- }
- })
- }
- }
-
- var fs$copyFile = fs.copyFile
- if (fs$copyFile)
- fs.copyFile = copyFile
- function copyFile (src, dest, flags, cb) {
- if (typeof flags === 'function') {
- cb = flags
- flags = 0
- }
- return go$copyFile(src, dest, flags, cb)
-
- function go$copyFile (src, dest, flags, cb, startTime) {
- return fs$copyFile(src, dest, flags, function (err) {
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()])
- else {
- if (typeof cb === 'function')
- cb.apply(this, arguments)
- }
- })
- }
- }
-
- var fs$readdir = fs.readdir
- fs.readdir = readdir
- function readdir (path, options, cb) {
- if (typeof options === 'function')
- cb = options, options = null
-
- return go$readdir(path, options, cb)
-
- function go$readdir (path, options, cb, startTime) {
- return fs$readdir(path, options, function (err, files) {
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$readdir, [path, options, cb], err, startTime || Date.now(), Date.now()])
- else {
- if (files && files.sort)
- files.sort()
-
- if (typeof cb === 'function')
- cb.call(this, err, files)
- }
- })
- }
- }
-
- if (process.version.substr(0, 4) === 'v0.8') {
- var legStreams = legacy(fs)
- ReadStream = legStreams.ReadStream
- WriteStream = legStreams.WriteStream
- }
-
- var fs$ReadStream = fs.ReadStream
- if (fs$ReadStream) {
- ReadStream.prototype = Object.create(fs$ReadStream.prototype)
- ReadStream.prototype.open = ReadStream$open
- }
-
- var fs$WriteStream = fs.WriteStream
- if (fs$WriteStream) {
- WriteStream.prototype = Object.create(fs$WriteStream.prototype)
- WriteStream.prototype.open = WriteStream$open
- }
-
- Object.defineProperty(fs, 'ReadStream', {
- get: function () {
- return ReadStream
- },
- set: function (val) {
- ReadStream = val
- },
- enumerable: true,
- configurable: true
- })
- Object.defineProperty(fs, 'WriteStream', {
- get: function () {
- return WriteStream
- },
- set: function (val) {
- WriteStream = val
- },
- enumerable: true,
- configurable: true
- })
-
- // legacy names
- var FileReadStream = ReadStream
- Object.defineProperty(fs, 'FileReadStream', {
- get: function () {
- return FileReadStream
- },
- set: function (val) {
- FileReadStream = val
- },
- enumerable: true,
- configurable: true
- })
- var FileWriteStream = WriteStream
- Object.defineProperty(fs, 'FileWriteStream', {
- get: function () {
- return FileWriteStream
- },
- set: function (val) {
- FileWriteStream = val
- },
- enumerable: true,
- configurable: true
- })
-
- function ReadStream (path, options) {
- if (this instanceof ReadStream)
- return fs$ReadStream.apply(this, arguments), this
- else
- return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
- }
-
- function ReadStream$open () {
- var that = this
- open(that.path, that.flags, that.mode, function (err, fd) {
- if (err) {
- if (that.autoClose)
- that.destroy()
-
- that.emit('error', err)
- } else {
- that.fd = fd
- that.emit('open', fd)
- that.read()
- }
- })
- }
-
- function WriteStream (path, options) {
- if (this instanceof WriteStream)
- return fs$WriteStream.apply(this, arguments), this
- else
- return WriteStream.apply(Object.create(WriteStream.prototype), arguments)
- }
-
- function WriteStream$open () {
- var that = this
- open(that.path, that.flags, that.mode, function (err, fd) {
- if (err) {
- that.destroy()
- that.emit('error', err)
- } else {
- that.fd = fd
- that.emit('open', fd)
- }
- })
- }
-
- function createReadStream (path, options) {
- return new fs.ReadStream(path, options)
- }
-
- function createWriteStream (path, options) {
- return new fs.WriteStream(path, options)
- }
-
- var fs$open = fs.open
- fs.open = open
- function open (path, flags, mode, cb) {
- if (typeof mode === 'function')
- cb = mode, mode = null
-
- return go$open(path, flags, mode, cb)
-
- function go$open (path, flags, mode, cb, startTime) {
- return fs$open(path, flags, mode, function (err, fd) {
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$open, [path, flags, mode, cb], err, startTime || Date.now(), Date.now()])
- else {
- if (typeof cb === 'function')
- cb.apply(this, arguments)
- }
- })
- }
- }
-
- return fs
-}
-
-function enqueue (elem) {
- debug('ENQUEUE', elem[0].name, elem[1])
- fs[gracefulQueue].push(elem)
- retry()
-}
-
-// keep track of the timeout between retry() calls
-var retryTimer
-
-// reset the startTime and lastTime to now
-// this resets the start of the 60 second overall timeout as well as the
-// delay between attempts so that we'll retry these jobs sooner
-function resetQueue () {
- var now = Date.now()
- for (var i = 0; i < fs[gracefulQueue].length; ++i) {
- // entries that are only a length of 2 are from an older version, don't
- // bother modifying those since they'll be retried anyway.
- if (fs[gracefulQueue][i].length > 2) {
- fs[gracefulQueue][i][3] = now // startTime
- fs[gracefulQueue][i][4] = now // lastTime
- }
- }
- // call retry to make sure we're actively processing the queue
- retry()
-}
-
-function retry () {
- // clear the timer and remove it to help prevent unintended concurrency
- clearTimeout(retryTimer)
- retryTimer = undefined
-
- if (fs[gracefulQueue].length === 0)
- return
-
- var elem = fs[gracefulQueue].shift()
- var fn = elem[0]
- var args = elem[1]
- // these items may be unset if they were added by an older graceful-fs
- var err = elem[2]
- var startTime = elem[3]
- var lastTime = elem[4]
-
- // if we don't have a startTime we have no way of knowing if we've waited
- // long enough, so go ahead and retry this item now
- if (startTime === undefined) {
- debug('RETRY', fn.name, args)
- fn.apply(null, args)
- } else if (Date.now() - startTime >= 60000) {
- // it's been more than 60 seconds total, bail now
- debug('TIMEOUT', fn.name, args)
- var cb = args.pop()
- if (typeof cb === 'function')
- cb.call(null, err)
- } else {
- // the amount of time between the last attempt and right now
- var sinceAttempt = Date.now() - lastTime
- // the amount of time between when we first tried, and when we last tried
- // rounded up to at least 1
- var sinceStart = Math.max(lastTime - startTime, 1)
- // backoff. wait longer than the total time we've been retrying, but only
- // up to a maximum of 100ms
- var desiredDelay = Math.min(sinceStart * 1.2, 100)
- // it's been long enough since the last retry, do it again
- if (sinceAttempt >= desiredDelay) {
- debug('RETRY', fn.name, args)
- fn.apply(null, args.concat([startTime]))
- } else {
- // if we can't do this job yet, push it to the end of the queue
- // and let the next iteration check again
- fs[gracefulQueue].push(elem)
- }
- }
-
- // schedule our next run if one isn't already scheduled
- if (retryTimer === undefined) {
- retryTimer = setTimeout(retry, 0)
- }
-}
-
-
-/***/ }),
-
-/***/ 54410:
-/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
-
-var Stream = (__webpack_require__(12781).Stream)
-
-module.exports = legacy
-
-function legacy (fs) {
- return {
- ReadStream: ReadStream,
- WriteStream: WriteStream
- }
-
- function ReadStream (path, options) {
- if (!(this instanceof ReadStream)) return new ReadStream(path, options);
-
- Stream.call(this);
-
- var self = this;
-
- this.path = path;
- this.fd = null;
- this.readable = true;
- this.paused = false;
-
- this.flags = 'r';
- this.mode = 438; /*=0666*/
- this.bufferSize = 64 * 1024;
-
- options = options || {};
-
- // Mixin options into this
- var keys = Object.keys(options);
- for (var index = 0, length = keys.length; index < length; index++) {
- var key = keys[index];
- this[key] = options[key];
- }
-
- if (this.encoding) this.setEncoding(this.encoding);
-
- if (this.start !== undefined) {
- if ('number' !== typeof this.start) {
- throw TypeError('start must be a Number');
- }
- if (this.end === undefined) {
- this.end = Infinity;
- } else if ('number' !== typeof this.end) {
- throw TypeError('end must be a Number');
- }
-
- if (this.start > this.end) {
- throw new Error('start must be <= end');
- }
-
- this.pos = this.start;
- }
-
- if (this.fd !== null) {
- process.nextTick(function() {
- self._read();
- });
- return;
- }
-
- fs.open(this.path, this.flags, this.mode, function (err, fd) {
- if (err) {
- self.emit('error', err);
- self.readable = false;
- return;
- }
-
- self.fd = fd;
- self.emit('open', fd);
- self._read();
- })
- }
-
- function WriteStream (path, options) {
- if (!(this instanceof WriteStream)) return new WriteStream(path, options);
-
- Stream.call(this);
-
- this.path = path;
- this.fd = null;
- this.writable = true;
-
- this.flags = 'w';
- this.encoding = 'binary';
- this.mode = 438; /*=0666*/
- this.bytesWritten = 0;
-
- options = options || {};
-
- // Mixin options into this
- var keys = Object.keys(options);
- for (var index = 0, length = keys.length; index < length; index++) {
- var key = keys[index];
- this[key] = options[key];
- }
-
- if (this.start !== undefined) {
- if ('number' !== typeof this.start) {
- throw TypeError('start must be a Number');
- }
- if (this.start < 0) {
- throw new Error('start must be >= zero');
- }
-
- this.pos = this.start;
- }
-
- this.busy = false;
- this._queue = [];
-
- if (this.fd === null) {
- this._open = fs.open;
- this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
- this.flush();
- }
- }
-}
-
-
-/***/ }),
-
-/***/ 11290:
-/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
-
-var constants = __webpack_require__(22057)
-
-var origCwd = process.cwd
-var cwd = null
-
-var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform
-
-process.cwd = function() {
- if (!cwd)
- cwd = origCwd.call(process)
- return cwd
-}
-try {
- process.cwd()
-} catch (er) {}
-
-// This check is needed until node.js 12 is required
-if (typeof process.chdir === 'function') {
- var chdir = process.chdir
- process.chdir = function (d) {
- cwd = null
- chdir.call(process, d)
- }
- if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir)
-}
-
-module.exports = patch
-
-function patch (fs) {
- // (re-)implement some things that are known busted or missing.
-
- // lchmod, broken prior to 0.6.2
- // back-port the fix here.
- if (constants.hasOwnProperty('O_SYMLINK') &&
- process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
- patchLchmod(fs)
- }
-
- // lutimes implementation, or no-op
- if (!fs.lutimes) {
- patchLutimes(fs)
- }
-
- // https://github.com/isaacs/node-graceful-fs/issues/4
- // Chown should not fail on einval or eperm if non-root.
- // It should not fail on enosys ever, as this just indicates
- // that a fs doesn't support the intended operation.
-
- fs.chown = chownFix(fs.chown)
- fs.fchown = chownFix(fs.fchown)
- fs.lchown = chownFix(fs.lchown)
-
- fs.chmod = chmodFix(fs.chmod)
- fs.fchmod = chmodFix(fs.fchmod)
- fs.lchmod = chmodFix(fs.lchmod)
-
- fs.chownSync = chownFixSync(fs.chownSync)
- fs.fchownSync = chownFixSync(fs.fchownSync)
- fs.lchownSync = chownFixSync(fs.lchownSync)
-
- fs.chmodSync = chmodFixSync(fs.chmodSync)
- fs.fchmodSync = chmodFixSync(fs.fchmodSync)
- fs.lchmodSync = chmodFixSync(fs.lchmodSync)
-
- fs.stat = statFix(fs.stat)
- fs.fstat = statFix(fs.fstat)
- fs.lstat = statFix(fs.lstat)
-
- fs.statSync = statFixSync(fs.statSync)
- fs.fstatSync = statFixSync(fs.fstatSync)
- fs.lstatSync = statFixSync(fs.lstatSync)
-
- // if lchmod/lchown do not exist, then make them no-ops
- if (!fs.lchmod) {
- fs.lchmod = function (path, mode, cb) {
- if (cb) process.nextTick(cb)
- }
- fs.lchmodSync = function () {}
- }
- if (!fs.lchown) {
- fs.lchown = function (path, uid, gid, cb) {
- if (cb) process.nextTick(cb)
- }
- fs.lchownSync = function () {}
- }
-
- // on Windows, A/V software can lock the directory, causing this
- // to fail with an EACCES or EPERM if the directory contains newly
- // created files. Try again on failure, for up to 60 seconds.
-
- // Set the timeout this long because some Windows Anti-Virus, such as Parity
- // bit9, may lock files for up to a minute, causing npm package install
- // failures. Also, take care to yield the scheduler. Windows scheduling gives
- // CPU to a busy looping process, which can cause the program causing the lock
- // contention to be starved of CPU by node, so the contention doesn't resolve.
- if (platform === "win32") {
- fs.rename = (function (fs$rename) { return function (from, to, cb) {
- var start = Date.now()
- var backoff = 0;
- fs$rename(from, to, function CB (er) {
- if (er
- && (er.code === "EACCES" || er.code === "EPERM")
- && Date.now() - start < 60000) {
- setTimeout(function() {
- fs.stat(to, function (stater, st) {
- if (stater && stater.code === "ENOENT")
- fs$rename(from, to, CB);
- else
- cb(er)
- })
- }, backoff)
- if (backoff < 100)
- backoff += 10;
- return;
- }
- if (cb) cb(er)
- })
- }})(fs.rename)
- }
-
- // if read() returns EAGAIN, then just try it again.
- fs.read = (function (fs$read) {
- function read (fd, buffer, offset, length, position, callback_) {
- var callback
- if (callback_ && typeof callback_ === 'function') {
- var eagCounter = 0
- callback = function (er, _, __) {
- if (er && er.code === 'EAGAIN' && eagCounter < 10) {
- eagCounter ++
- return fs$read.call(fs, fd, buffer, offset, length, position, callback)
- }
- callback_.apply(this, arguments)
- }
- }
- return fs$read.call(fs, fd, buffer, offset, length, position, callback)
- }
-
- // This ensures `util.promisify` works as it does for native `fs.read`.
- if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read)
- return read
- })(fs.read)
-
- fs.readSync = (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
- var eagCounter = 0
- while (true) {
- try {
- return fs$readSync.call(fs, fd, buffer, offset, length, position)
- } catch (er) {
- if (er.code === 'EAGAIN' && eagCounter < 10) {
- eagCounter ++
- continue
- }
- throw er
- }
- }
- }})(fs.readSync)
-
- function patchLchmod (fs) {
- fs.lchmod = function (path, mode, callback) {
- fs.open( path
- , constants.O_WRONLY | constants.O_SYMLINK
- , mode
- , function (err, fd) {
- if (err) {
- if (callback) callback(err)
- return
- }
- // prefer to return the chmod error, if one occurs,
- // but still try to close, and report closing errors if they occur.
- fs.fchmod(fd, mode, function (err) {
- fs.close(fd, function(err2) {
- if (callback) callback(err || err2)
- })
- })
- })
- }
-
- fs.lchmodSync = function (path, mode) {
- var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode)
-
- // prefer to return the chmod error, if one occurs,
- // but still try to close, and report closing errors if they occur.
- var threw = true
- var ret
- try {
- ret = fs.fchmodSync(fd, mode)
- threw = false
- } finally {
- if (threw) {
- try {
- fs.closeSync(fd)
- } catch (er) {}
- } else {
- fs.closeSync(fd)
- }
- }
- return ret
- }
- }
-
- function patchLutimes (fs) {
- if (constants.hasOwnProperty("O_SYMLINK")) {
- fs.lutimes = function (path, at, mt, cb) {
- fs.open(path, constants.O_SYMLINK, function (er, fd) {
- if (er) {
- if (cb) cb(er)
- return
- }
- fs.futimes(fd, at, mt, function (er) {
- fs.close(fd, function (er2) {
- if (cb) cb(er || er2)
- })
- })
- })
- }
-
- fs.lutimesSync = function (path, at, mt) {
- var fd = fs.openSync(path, constants.O_SYMLINK)
- var ret
- var threw = true
- try {
- ret = fs.futimesSync(fd, at, mt)
- threw = false
- } finally {
- if (threw) {
- try {
- fs.closeSync(fd)
- } catch (er) {}
- } else {
- fs.closeSync(fd)
- }
- }
- return ret
- }
-
- } else {
- fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) }
- fs.lutimesSync = function () {}
- }
- }
-
- function chmodFix (orig) {
- if (!orig) return orig
- return function (target, mode, cb) {
- return orig.call(fs, target, mode, function (er) {
- if (chownErOk(er)) er = null
- if (cb) cb.apply(this, arguments)
- })
- }
- }
-
- function chmodFixSync (orig) {
- if (!orig) return orig
- return function (target, mode) {
- try {
- return orig.call(fs, target, mode)
- } catch (er) {
- if (!chownErOk(er)) throw er
- }
- }
- }
-
-
- function chownFix (orig) {
- if (!orig) return orig
- return function (target, uid, gid, cb) {
- return orig.call(fs, target, uid, gid, function (er) {
- if (chownErOk(er)) er = null
- if (cb) cb.apply(this, arguments)
- })
- }
- }
-
- function chownFixSync (orig) {
- if (!orig) return orig
- return function (target, uid, gid) {
- try {
- return orig.call(fs, target, uid, gid)
- } catch (er) {
- if (!chownErOk(er)) throw er
- }
- }
- }
-
- function statFix (orig) {
- if (!orig) return orig
- // Older versions of Node erroneously returned signed integers for
- // uid + gid.
- return function (target, options, cb) {
- if (typeof options === 'function') {
- cb = options
- options = null
- }
- function callback (er, stats) {
- if (stats) {
- if (stats.uid < 0) stats.uid += 0x100000000
- if (stats.gid < 0) stats.gid += 0x100000000
- }
- if (cb) cb.apply(this, arguments)
- }
- return options ? orig.call(fs, target, options, callback)
- : orig.call(fs, target, callback)
- }
- }
-
- function statFixSync (orig) {
- if (!orig) return orig
- // Older versions of Node erroneously returned signed integers for
- // uid + gid.
- return function (target, options) {
- var stats = options ? orig.call(fs, target, options)
- : orig.call(fs, target)
- if (stats) {
- if (stats.uid < 0) stats.uid += 0x100000000
- if (stats.gid < 0) stats.gid += 0x100000000
- }
- return stats;
- }
- }
-
- // ENOSYS means that the fs doesn't support the op. Just ignore
- // that, because it doesn't matter.
- //
- // if there's no getuid, or if getuid() is something other
- // than 0, and the error is EINVAL or EPERM, then just ignore
- // it.
- //
- // This specific case is a silent failure in cp, install, tar,
- // and most other unix tools that manage permissions.
- //
- // When running as root, or if other types of errors are
- // encountered, then it's strict.
- function chownErOk (er) {
- if (!er)
- return true
-
- if (er.code === "ENOSYS")
- return true
-
- var nonroot = !process.getuid || process.getuid() !== 0
- if (nonroot) {
- if (er.code === "EINVAL" || er.code === "EPERM")
- return true
- }
-
- return false
- }
-}
-
-
-/***/ }),
-
-/***/ 15235:
-/***/ (function(module) {
-
-"use strict";
-
-
-module.exports = parseJson
-function parseJson (txt, reviver, context) {
- context = context || 20
- try {
- return JSON.parse(txt, reviver)
- } catch (e) {
- if (typeof txt !== 'string') {
- const isEmptyArray = Array.isArray(txt) && txt.length === 0
- const errorMessage = 'Cannot parse ' +
- (isEmptyArray ? 'an empty array' : String(txt))
- throw new TypeError(errorMessage)
- }
- const syntaxErr = e.message.match(/^Unexpected token.*position\s+(\d+)/i)
- const errIdx = syntaxErr
- ? +syntaxErr[1]
- : e.message.match(/^Unexpected end of JSON.*/i)
- ? txt.length - 1
- : null
- if (errIdx != null) {
- const start = errIdx <= context
- ? 0
- : errIdx - context
- const end = errIdx + context >= txt.length
- ? txt.length
- : errIdx + context
- e.message += ` while parsing near '${
- start === 0 ? '' : '...'
- }${txt.slice(start, end)}${
- end === txt.length ? '' : '...'
- }'`
- } else {
- e.message += ` while parsing '${txt.slice(0, context * 2)}'`
- }
- throw e
- }
-}
-
-
-/***/ }),
-
-/***/ 54983:
-/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
-
-"use strict";
-var __webpack_unused_export__;
-
-
-__webpack_unused_export__ = ({
- value: true
-});
-exports.Z = void 0;
-
-const {
- stringHints,
- numberHints
-} = __webpack_require__(79926);
-/** @typedef {import("json-schema").JSONSchema6} JSONSchema6 */
-
-/** @typedef {import("json-schema").JSONSchema7} JSONSchema7 */
-
-/** @typedef {import("./validate").Schema} Schema */
-
-/** @typedef {import("./validate").ValidationErrorConfiguration} ValidationErrorConfiguration */
-
-/** @typedef {import("./validate").PostFormatter} PostFormatter */
-
-/** @typedef {import("./validate").SchemaUtilErrorObject} SchemaUtilErrorObject */
-
-/** @enum {number} */
-
-
-const SPECIFICITY = {
- type: 1,
- not: 1,
- oneOf: 1,
- anyOf: 1,
- if: 1,
- enum: 1,
- const: 1,
- instanceof: 1,
- required: 2,
- pattern: 2,
- patternRequired: 2,
- format: 2,
- formatMinimum: 2,
- formatMaximum: 2,
- minimum: 2,
- exclusiveMinimum: 2,
- maximum: 2,
- exclusiveMaximum: 2,
- multipleOf: 2,
- uniqueItems: 2,
- contains: 2,
- minLength: 2,
- maxLength: 2,
- minItems: 2,
- maxItems: 2,
- minProperties: 2,
- maxProperties: 2,
- dependencies: 2,
- propertyNames: 2,
- additionalItems: 2,
- additionalProperties: 2,
- absolutePath: 2
-};
-/**
- *
- * @param {Array} array
- * @param {(item: SchemaUtilErrorObject) => number} fn
- * @returns {Array}
- */
-
-function filterMax(array, fn) {
- const evaluatedMax = array.reduce((max, item) => Math.max(max, fn(item)), 0);
- return array.filter(item => fn(item) === evaluatedMax);
-}
-/**
- *
- * @param {Array} children
- * @returns {Array}
- */
-
-
-function filterChildren(children) {
- let newChildren = children;
- newChildren = filterMax(newChildren,
- /**
- *
- * @param {SchemaUtilErrorObject} error
- * @returns {number}
- */
- error => error.dataPath ? error.dataPath.length : 0);
- newChildren = filterMax(newChildren,
- /**
- * @param {SchemaUtilErrorObject} error
- * @returns {number}
- */
- error => SPECIFICITY[
- /** @type {keyof typeof SPECIFICITY} */
- error.keyword] || 2);
- return newChildren;
-}
-/**
- * Find all children errors
- * @param {Array} children
- * @param {Array} schemaPaths
- * @return {number} returns index of first child
- */
-
-
-function findAllChildren(children, schemaPaths) {
- let i = children.length - 1;
-
- const predicate =
- /**
- * @param {string} schemaPath
- * @returns {boolean}
- */
- schemaPath => children[i].schemaPath.indexOf(schemaPath) !== 0;
-
- while (i > -1 && !schemaPaths.every(predicate)) {
- if (children[i].keyword === "anyOf" || children[i].keyword === "oneOf") {
- const refs = extractRefs(children[i]);
- const childrenStart = findAllChildren(children.slice(0, i), refs.concat(children[i].schemaPath));
- i = childrenStart - 1;
- } else {
- i -= 1;
- }
- }
-
- return i + 1;
-}
-/**
- * Extracts all refs from schema
- * @param {SchemaUtilErrorObject} error
- * @return {Array}
- */
-
-
-function extractRefs(error) {
- const {
- schema
- } = error;
-
- if (!Array.isArray(schema)) {
- return [];
- }
-
- return schema.map(({
- $ref
- }) => $ref).filter(s => s);
-}
-/**
- * Groups children by their first level parent (assuming that error is root)
- * @param {Array} children
- * @return {Array}
- */
-
-
-function groupChildrenByFirstChild(children) {
- const result = [];
- let i = children.length - 1;
-
- while (i > 0) {
- const child = children[i];
-
- if (child.keyword === "anyOf" || child.keyword === "oneOf") {
- const refs = extractRefs(child);
- const childrenStart = findAllChildren(children.slice(0, i), refs.concat(child.schemaPath));
-
- if (childrenStart !== i) {
- result.push(Object.assign({}, child, {
- children: children.slice(childrenStart, i)
- }));
- i = childrenStart;
- } else {
- result.push(child);
- }
- } else {
- result.push(child);
- }
-
- i -= 1;
- }
-
- if (i === 0) {
- result.push(children[i]);
- }
-
- return result.reverse();
-}
-/**
- * @param {string} str
- * @param {string} prefix
- * @returns {string}
- */
-
-
-function indent(str, prefix) {
- return str.replace(/\n(?!$)/g, `\n${prefix}`);
-}
-/**
- * @param {Schema} schema
- * @returns {schema is (Schema & {not: Schema})}
- */
-
-
-function hasNotInSchema(schema) {
- return !!schema.not;
-}
-/**
- * @param {Schema} schema
- * @return {Schema}
- */
-
-
-function findFirstTypedSchema(schema) {
- if (hasNotInSchema(schema)) {
- return findFirstTypedSchema(schema.not);
- }
-
- return schema;
-}
-/**
- * @param {Schema} schema
- * @return {boolean}
- */
-
-
-function canApplyNot(schema) {
- const typedSchema = findFirstTypedSchema(schema);
- return likeNumber(typedSchema) || likeInteger(typedSchema) || likeString(typedSchema) || likeNull(typedSchema) || likeBoolean(typedSchema);
-}
-/**
- * @param {any} maybeObj
- * @returns {boolean}
- */
-
-
-function isObject(maybeObj) {
- return typeof maybeObj === "object" && maybeObj !== null;
-}
-/**
- * @param {Schema} schema
- * @returns {boolean}
- */
-
-
-function likeNumber(schema) {
- return schema.type === "number" || typeof schema.minimum !== "undefined" || typeof schema.exclusiveMinimum !== "undefined" || typeof schema.maximum !== "undefined" || typeof schema.exclusiveMaximum !== "undefined" || typeof schema.multipleOf !== "undefined";
-}
-/**
- * @param {Schema} schema
- * @returns {boolean}
- */
-
-
-function likeInteger(schema) {
- return schema.type === "integer" || typeof schema.minimum !== "undefined" || typeof schema.exclusiveMinimum !== "undefined" || typeof schema.maximum !== "undefined" || typeof schema.exclusiveMaximum !== "undefined" || typeof schema.multipleOf !== "undefined";
-}
-/**
- * @param {Schema} schema
- * @returns {boolean}
- */
-
-
-function likeString(schema) {
- return schema.type === "string" || typeof schema.minLength !== "undefined" || typeof schema.maxLength !== "undefined" || typeof schema.pattern !== "undefined" || typeof schema.format !== "undefined" || typeof schema.formatMinimum !== "undefined" || typeof schema.formatMaximum !== "undefined";
-}
-/**
- * @param {Schema} schema
- * @returns {boolean}
- */
-
-
-function likeBoolean(schema) {
- return schema.type === "boolean";
-}
-/**
- * @param {Schema} schema
- * @returns {boolean}
- */
-
-
-function likeArray(schema) {
- return schema.type === "array" || typeof schema.minItems === "number" || typeof schema.maxItems === "number" || typeof schema.uniqueItems !== "undefined" || typeof schema.items !== "undefined" || typeof schema.additionalItems !== "undefined" || typeof schema.contains !== "undefined";
-}
-/**
- * @param {Schema & {patternRequired?: Array}} schema
- * @returns {boolean}
- */
-
-
-function likeObject(schema) {
- return schema.type === "object" || typeof schema.minProperties !== "undefined" || typeof schema.maxProperties !== "undefined" || typeof schema.required !== "undefined" || typeof schema.properties !== "undefined" || typeof schema.patternProperties !== "undefined" || typeof schema.additionalProperties !== "undefined" || typeof schema.dependencies !== "undefined" || typeof schema.propertyNames !== "undefined" || typeof schema.patternRequired !== "undefined";
-}
-/**
- * @param {Schema} schema
- * @returns {boolean}
- */
-
-
-function likeNull(schema) {
- return schema.type === "null";
-}
-/**
- * @param {string} type
- * @returns {string}
- */
-
-
-function getArticle(type) {
- if (/^[aeiou]/i.test(type)) {
- return "an";
- }
-
- return "a";
-}
-/**
- * @param {Schema=} schema
- * @returns {string}
- */
-
-
-function getSchemaNonTypes(schema) {
- if (!schema) {
- return "";
- }
-
- if (!schema.type) {
- if (likeNumber(schema) || likeInteger(schema)) {
- return " | should be any non-number";
- }
-
- if (likeString(schema)) {
- return " | should be any non-string";
- }
-
- if (likeArray(schema)) {
- return " | should be any non-array";
- }
-
- if (likeObject(schema)) {
- return " | should be any non-object";
- }
- }
-
- return "";
-}
-/**
- * @param {Array} hints
- * @returns {string}
- */
-
-
-function formatHints(hints) {
- return hints.length > 0 ? `(${hints.join(", ")})` : "";
-}
-/**
- * @param {Schema} schema
- * @param {boolean} logic
- * @returns {string[]}
- */
-
-
-function getHints(schema, logic) {
- if (likeNumber(schema) || likeInteger(schema)) {
- return numberHints(schema, logic);
- } else if (likeString(schema)) {
- return stringHints(schema, logic);
- }
-
- return [];
-}
-
-class ValidationError extends Error {
- /**
- * @param {Array} errors
- * @param {Schema} schema
- * @param {ValidationErrorConfiguration} configuration
- */
- constructor(errors, schema, configuration = {}) {
- super();
- /** @type {string} */
-
- this.name = "ValidationError";
- /** @type {Array} */
-
- this.errors = errors;
- /** @type {Schema} */
-
- this.schema = schema;
- let headerNameFromSchema;
- let baseDataPathFromSchema;
-
- if (schema.title && (!configuration.name || !configuration.baseDataPath)) {
- const splittedTitleFromSchema = schema.title.match(/^(.+) (.+)$/);
-
- if (splittedTitleFromSchema) {
- if (!configuration.name) {
- [, headerNameFromSchema] = splittedTitleFromSchema;
- }
-
- if (!configuration.baseDataPath) {
- [,, baseDataPathFromSchema] = splittedTitleFromSchema;
- }
- }
- }
- /** @type {string} */
-
-
- this.headerName = configuration.name || headerNameFromSchema || "Object";
- /** @type {string} */
-
- this.baseDataPath = configuration.baseDataPath || baseDataPathFromSchema || "configuration";
- /** @type {PostFormatter | null} */
-
- this.postFormatter = configuration.postFormatter || null;
- const header = `Invalid ${this.baseDataPath} object. ${this.headerName} has been initialized using ${getArticle(this.baseDataPath)} ${this.baseDataPath} object that does not match the API schema.\n`;
- /** @type {string} */
-
- this.message = `${header}${this.formatValidationErrors(errors)}`;
- Error.captureStackTrace(this, this.constructor);
- }
- /**
- * @param {string} path
- * @returns {Schema}
- */
-
-
- getSchemaPart(path) {
- const newPath = path.split("/");
- let schemaPart = this.schema;
-
- for (let i = 1; i < newPath.length; i++) {
- const inner = schemaPart[
- /** @type {keyof Schema} */
- newPath[i]];
-
- if (!inner) {
- break;
- }
-
- schemaPart = inner;
- }
-
- return schemaPart;
- }
- /**
- * @param {Schema} schema
- * @param {boolean} logic
- * @param {Array