diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..a3d789ae81 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +.DS_Store +build +docs/_build +__pycache__ +*.swp +node_modules +.project + +# editors +.idea/ +.vscode/ +.Rproj.user + +# misc +/work diff --git a/.eslintrc.js b/.eslintrc.js index 1561b367b1..3d7e7b9bf1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,71 +1,86 @@ module.exports = { - "env": { - "browser": true, - "es6": true, - "node": true, - "mocha": true - }, - "extends": [ - "eslint:recommended", - "standard" - ], - "globals": { - "Atomics": "readonly", - "SharedArrayBuffer": "readonly" - }, - "parserOptions": { - "ecmaVersion": 2018, - "sourceType": "module" - }, - "parser": '@typescript-eslint/parser', - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "array-callback-return": "error", - "block-scoped-var": "error", - // we like our semi-colons - "semi": ["error","always"], - // our codebase doesn't do this at all, so disabled for now - "space-before-function-paren": ["error","never"], - // for now ignore diff between types of quoting - "quotes": "off", - // this is the style we are already using - "operator-linebreak": ["error","before", { "overrides": { "?": "after", ":": "after", "+": "after" } }], - // sometimes we declare variables with extra spacing - "indent": ["error", 2, {"VariableDeclarator":2}], - // seems like a good idea not to use explicit undefined - "no-undefined": "error", - // ensure import specifier contains file extension - "import/extensions": ["error", "always"], - - // TODO maybe - "camelcase": "off", // TODO: turn on later - "init-declarations": ["error","always"] + env: { + browser: true, + es6: true, + node: true, + mocha: true + }, + extends: [ + "eslint:recommended", + "standard" + ], + globals: { + Atomics: "readonly", + SharedArrayBuffer: "readonly" + }, + parserOptions: { + ecmaVersion: 2015, + sourceType: "module" + }, + // parser: '@typescript-eslint/parser', + plugins: [ + "@typescript-eslint" + ], + rules: { + "no-var": 1, + "init-declarations": ["error", "always"], + "array-callback-return": "error", + "block-scoped-var": "error", + // we like our semi-colons + semi: ["error", "always"], + // our codebase doesn't do this at all, so disabled for now + "space-before-function-paren": ["error", "never"], + // for now ignore diff between types of quoting + quotes: "off", + // this is the style we are already using + "operator-linebreak": ["error", "before", { overrides: { "=": "after", "?": "after", ":": "after", "+": "after" } }], + // sometimes we declare variables with extra spacing + indent: ["error", 2, { VariableDeclarator: 2 }], + // seems like a good idea not to use explicit undefined + "no-undefined": "error", + // ensure import specifier contains file extension + "import/extensions": ["error", "always"] + }, + overrides: [ + { + files: ["src/**/*.js"], + rules: { + // make sure there is no Node.js specific API slipping into the source files + "import/no-nodejs-modules": "error", + "import/no-commonjs": "error" + } }, - "overrides": [ - { - "files": ["src/**/*.js"], - "rules": { - // make sure there is no Node.js specific API slipping into the source files - "import/no-nodejs-modules": "error", - "import/no-commonjs": "error", - } - }, - { - "files": ["src/languages/*.js"], - "rules": { - "no-unused-expressions": "off", - // languages are all over the map and we don't want to - // do a mass edit so turn off the most egregious rule violations - "indent": "off", - "comma-dangle": "off", - "array-bracket-spacing": "off", - "object-curly-spacing": "off", - "key-spacing": "off", - "object-curly-newline": "off", - "object-property-newline": "off" - } + { + files: ["src/languages/*.js"], + rules: { + "no-unused-expressions": "off", + // // languages are all over the map and we don't want to + // // do a mass edit so turn off the most egregious rule violations + // indent: "off", + "camelcase": 0, + "no-control-regex": 0, + "no-useless-escape": 0, + "comma-dangle": 1, + "array-bracket-spacing": ["error", "always" + // { + // objectsInArrays: true + // } + ], + // "object-curly-spacing": 1, + // "key-spacing": "off", + // "array-bracket-spacing": [1], + "array-bracket-newline": [1, { + multiline: true, + minItems: 2 + }], + "array-element-newline": 1, + "object-curly-newline": [1, { + minProperties: 1 + }], + "object-property-newline": [2, + { allowAllPropertiesOnSameLine: false } + ] } - ] + } + ] }; diff --git a/.eslintrc.lang.js b/.eslintrc.lang.js new file mode 100644 index 0000000000..da193b1a51 --- /dev/null +++ b/.eslintrc.lang.js @@ -0,0 +1,20 @@ +module.exports = { + env: { + browser: true, + es6: true, + node: true, + mocha: true + }, + extends: [], + globals: { + Atomics: "readonly", + SharedArrayBuffer: "readonly" + }, + parserOptions: { + ecmaVersion: 2015, + sourceType: "module" + }, + // no rules, this file exists only to lint the grammars and check + // that no ES2018 or newer syntax has crept in by accident + rules: {} +}; diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000000..21245f47e6 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,12 @@ + + + + + +### Changes + + +### Checklist +- [ ] Added markup tests, or they don't apply here because... +- [ ] Updated the changelog at `CHANGES.md` +- [ ] Added myself to `AUTHORS.txt`, under Contributors diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000000..187b5f8d45 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Lint + +on: +# push: + # branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [15.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - name: Lint the main source + run: npx eslint src/*.js src/lib/*.js + - name: Lint the language grammars + run: npx eslint --no-eslintrc -c .eslintrc.lang.js src/languages/**/*.js diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000000..f3a91de333 --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,48 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x, 14.x, 15.x] + build-how: ["node", "browser", "browser -n"] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: node ./tools/build.js -t ${{ matrix.build-how }} + # normal browser build + - if: contains(matrix.build-how, 'browser') + name: Test browser build + run: | + npm run test-browser + node test/builds/browser_build_as_commonjs.js + + - if: contains(matrix.build-how, 'node') + name: Test Node.js build + run: | + npm test + + # test that our build is "use strict" safe for use with packaging + # systems importing our source thru ES6 modules (rollup, etc.) + - if: contains(matrix.build-how, 'node') + name: Test Node.js build is "use strict" safe + run: | + ./node_modules/.bin/rollup -c test/builds/rollup_import_via_commonjs.js + node build/bundle.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..31bdad66c4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,131 @@ +name: Release + +on: + push: + tags: + - "*beta*" + - "*pre*" + - "1[0-9]+.[0-9]+.[0-9]+" + +jobs: + prerelease: + name: Pre-release + runs-on: ubuntu-latest + steps: + - name: Checkout highlight.js + uses: actions/checkout@v2 + + - name: Tag is ${{ github.ref }}. + # we have to repeat ourselves here since the environment is not actually updated + # until the next step executes, so we can't access $TAG_NAME yet + run: | + echo "TAG_NAME=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + echo "MAJOR_VERSION=$(echo ${GITHUB_REF/refs\/tags\//} | cut -d'.' -f1)" >> $GITHUB_ENV + - name: Make sure we are pushing a tag... + if: ${{ !contains(github.ref,'refs/tags/') }} + run: false + # run: echo "TAG_NAME=0.0.0-test0" >> $GITHUB_ENV + + - if: contains(github.ref, 'beta') || contains(github.ref, 'pre') + run: | + echo "NPM_TAG=beta" >> $GITHUB_ENV + echo "RELEASING=beta" >> $GITHUB_ENV + + - if: ${{ !(contains(github.ref, 'beta') || contains(github.ref, 'pre')) }} + run: | + echo "NPM_TAG=latest" >> $GITHUB_ENV + echo "RELEASING=stable" >> $GITHUB_ENV + + - name: match-tag-to-package-version + uses: geritol/match-tag-to-package-version@0.0.2 + env: + TAG_PREFIX: refs/tags/ # Optional, default prefix refs/tags/ + + - name: Use Node.js 15.x + uses: actions/setup-node@v1 + with: + node-version: 15.x + - name: Build Node.js package + run: | + npm install + node ./tools/build.js -t node + npm test + + - name: Publish highlight.js to NPM + id: publish + uses: JS-DevTools/npm-publish@v1 + with: + check-version: true + token: ${{ secrets.NPM_TOKEN }} + package: ./build/package.json + tag: ${{ env.NPM_TAG }} + + - if: steps.publish.outputs.type != 'none' + run: | + echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}" + + # if stable release + - name: Stable Release + if: env.RELEASING == 'stable' + run: echo "BRANCH_NAME=${MAJOR_VERSION}-stable" >> $GITHUB_ENV + # else (beta) + - name: Beta Release + if: env.RELEASING == 'beta' + run: echo "BRANCH_NAME=master" >> $GITHUB_ENV + - name: Confirm release is either stable or beta + if: ${{ !(env.RELEASING == 'stable' || env.RELEASING == 'beta') }} + run: | + echo We seem to be releasing `${RELEASING}`. + false + + - name: Checkout cdn-release + uses: actions/checkout@v2 + with: + repository: 'highlightjs/cdn-release' + path: 'cdn-release' + token: ${{ secrets.CDN_REPO_TOKEN }} + ref: ${{ env.BRANCH_NAME }} + + - name: Build CDN package + run: node ./tools/build.js -t cdn :common + + - name: Commmit & Push cdn-release ${{ env.TAG_NAME }} + working-directory: ./cdn-release + run: | + rm -r ./build + mv ../build/ ./build/ + git config user.name github-actions + git config user.email github-actions@github.com + git add ./build/ + git commit -m'Update to version ${{ env.TAG_NAME }}' + git tag ${TAG_NAME} + git push -f --atomic origin ${BRANCH_NAME} ${TAG_NAME} + + - name: Publish cdn-assets to NPM + id: publish_cdn + uses: JS-DevTools/npm-publish@v1 + with: + check-version: true + token: ${{ secrets.NPM_TOKEN }} + package: ./cdn-release/build/package.json + tag: ${{ env.NPM_TAG }} + + # log.info('Updating CDN repo at %s' % settings.HLJS_CDN_SOURCE) + # run(['nodejs', 'tools/build.js', '--target', 'cdn', ':common']) + # os.chdir(settings.HLJS_CDN_SOURCE) + # run(['git', 'pull', '-f']) + # lines = run(['git', '--git-dir', os.path.join(settings.HLJS_CDN_SOURCE, '.git'), 'tag']) + # build_dir = os.path.join(settings.HLJS_CDN_SOURCE, 'build') + # if version in lines: + # log.info('Tag %s already exists in the local CDN repo' % version) + # else: + # if os.path.exists(build_dir): + # shutil.rmtree(build_dir) + # shutil.move(os.path.join(settings.HLJS_SOURCE, 'build'), build_dir) + # run(['git', 'add', '.']) + # run(['git', 'commit', '-m', 'Update to version %s' % version]) + # run(['git', 'tag', version]) + # run(['git', 'push']) + # run(['git', 'push', '--tags']) + # npm_publish(build_dir) + # os.chdir(settings.HLJS_SOURCE) diff --git a/.gitignore b/.gitignore index 52ed616381..c61bf80d10 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ extra/ # misc /work +/website diff --git a/.mocharc.json b/.mocharc.json new file mode 100644 index 0000000000..ef2f5d36c8 --- /dev/null +++ b/.mocharc.json @@ -0,0 +1,3 @@ +{ + "require": "should" +} diff --git a/.tokeignore b/.tokeignore new file mode 100644 index 0000000000..783c23bc18 --- /dev/null +++ b/.tokeignore @@ -0,0 +1,7 @@ +test/* +src/styles/* +*.md +*.json +tools +docs +types diff --git a/.travis.yml b/.travis.yml index 67fd1364cf..01429794df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ script: if [ "x$BUILD" = "xnode" ]; then npm run test else - npm run test-browser + npm run test-browser || exit 1 # our browser build should also work fine as a Node.js CommonJS module node test/builds/browser_build_as_commonjs.js fi diff --git a/AUTHORS.txt b/AUTHORS.txt index 131f873ad8..68d7233d31 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -2,20 +2,27 @@ Syntax highlighting with language autodetection. URL: https://highlightjs.org/ -Current core developers (alphabetical): + +Current Core Team: + +- Josh Goebel (maintainer) +- Egor Rogov +- Vladimir Jimenez + +Former maintainers: + +- Ivan Sagalaev (original author) +- Jeremy Hull +- Oleg Efimov + +Former Core Team members: - Gidi Meir Morris - Jan T. Sott - Li Xuanji - Marcos Cáceres - Sang Dang -- Josh Goebel - -Former maintainers: -- Ivan Sagalaev (original author) -- Jeremy Hull -- Oleg Efimov Contributors: @@ -288,3 +295,18 @@ Contributors: - Alexandre Grison - Jim Mason - lioshi +- David Pine +- Konrad Rudolph +- Tom Wallace +- Michael Newton +- Richard Gibson +- Fredrik Ekre +- Jan Pilzer +- Jonathan Sharpe +- Michael Rush +- Florian Bezdeka +- Marat Nagayev +- Patrick Scheibe +- Kyle Brown +- Marcus Ortiz +- Guillaume Grossetie diff --git a/CHANGES.md b/CHANGES.md index cc343b00d6..c570079808 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,260 @@ +## Version 10.4.1 + +Security + +- (fix) Exponential backtracking fixes for: [Josh Goebel][] + - cpp + - handlebars + - gams + - perl + - jboss-cli + - r + - erlang-repl + - powershell + - routeros +- (fix) Polynomial backtracking fixes for: [Josh Goebel][] + - asciidoc + - reasonml + - latex + - kotlin + - gcode + - d + - aspectj + - moonscript + - coffeescript/livescript + - csharp + - scilab + - crystal + - elixir + - basic + - ebnf + - ruby + - fortran/irpf90 + - livecodeserver + - yaml + - x86asm + - dsconfig + - markdown + - ruleslanguage + - xquery + - sqf + +Very grateful to [Michael Schmidt][] for all the help. + +[Michael Schmidt]: https://github.com/RunDevelopment +[Josh Goebel]: https://github.com/joshgoebel + + +## Version 10.4.0 + +A largish release with many improvements and fixes from quite a few different contributors. Enjoy! + +Deprecations: + +- (chore) `requireLanguage` is deprecated. + - Prefer `getLanguage` (with custom error handling) or built-time dependencies. + - See [Library API](https://highlightjs.readthedocs.io/en/latest/api.html#requirelanguage-name) for more information. + +Parser: + +- enh(parser) use negative look-ahead for `beginKeywords` support (#2813) [Josh Goebel][] +- enh(grammars) allow `classNameAliases` for more complex grammars [Josh Goebel][] +- fix(vue): Language name now appears in CSS class (#2807) [Michael Rush][] +- (chore) Clean up all regexs to be UTF-8 compliant/ready (#2759) [Josh Goebel][] + +New Languages: + +- Added 3rd party Chapel grammar to SUPPORTED_LANGUAGES (#2806) [Brad Chamberlain][] +- Added BBCode grammar to SUPPORTED_LANGUAGES (#2867) [Paul Reid][] +- enh(javascript) Added `node-repl` for Node.js REPL sessions (#2792) [Marat Nagayev][] + +Language Improvements: + +- enh(shell) Recognize prompts which contain tilde `~` (#2859) [Guillaume Grossetie][] +- enh(shell) Add support for multiline commands with line continuation `\` (#2861) [Guillaume Grossetie][] +- enh(autodetect) Over 30+ improvements to auto-detect (#2745) [Josh Goebel][] + - 4-5% improvement in auto-detect against large sample set + - properties, angelscript, lsl, javascript, n1ql, ocaml, ruby + - protobuf, hy, scheme, crystal, yaml, r, vbscript, groovy + - python, java, php, lisp, matlab, clojure, csharp, css +- fix(r) fixed keywords not properly spaced (#2852) [Josh Goebel][] +- fix(javascript) fix potential catastrophic backtracking (#2852) [Josh Goebel][] +- fix(livescript) fix potential catastrophic backtracking (#2852) [Josh Goebel][] +- bug(xml) XML grammar was far too imprecise/fuzzy [Josh Goebel][] +- enh(xml) Improve precision to prevent false auto-detect positives [Josh Goebel][] +- fix(js/ts) Prevent for/while/if/switch from falsly matching as functions (#2803) [Josh Goebel][] +- enh(julia) Update keyword lists for Julia 1.x (#2781) [Fredrik Ekre][] +- enh(python) Match numeric literals per the language reference [Richard Gibson][] +- enh(ruby) Match numeric literals per language documentation [Richard Gibson][] +- enh(javascript) Match numeric literals per ECMA-262 spec [Richard Gibson][] +- enh(java) Match numeric literals per Java Language Specification [Richard Gibson][] +- enh(swift) Match numeric literals per language reference [Richard Gibson][] +- enh(php) highlight variables (#2785) [Taufik Nurrohman][] +- fix(python) Handle comments on decorators (#2804) [Jonathan Sharpe][] +- enh(diff) improve highlighting of diff for git patches [Florian Bezdeka][] +- fix(llvm) lots of small improvements and fixes (#2830) [Josh Goebel][] +- enh(mathematica) Rework entire implementation [Patrick Scheibe][] + - Correct matching of the many variations of Mathematica's numbers + - Matching of named-characters aka special symbols like `\[Gamma]` + - Updated list of version 12.1 built-in symbols + - Matching of patterns, slots, message-names and braces +- fix(swift) Handle keywords that start with `#` [Marcus Ortiz][] +- enh(swift) Match `some` keyword [Marcus Ortiz][] +- enh(swift) Match `@main` attribute [Marcus Ortiz][] + +Dev Improvements: + +- chore(dev) add theme picker to the tools/developer tool (#2770) [Josh Goebel][] +- fix(dev) the Vue.js plugin no longer throws an exception when hljs is not in the global namespace [Kyle Brown][] + +New themes: + +- *StackOverflow Dark* by [Jan Pilzer][] +- *StackOverflow Light* by [Jan Pilzer][] + +[Guillaume Grossetie]: https://github.com/mogztter +[Brad Chamberlain]: https://github.com/bradcray +[Marat Nagayev]: https://github.com/nagayev +[Fredrik Ekre]: https://github.com/fredrikekre +[Richard Gibson]: https://github.com/gibson042 +[Josh Goebel]: https://github.com/joshgoebel +[Taufik Nurrohman]: https://github.com/taufik-nurrohman +[Jan Pilzer]: https://github.com/Hirse +[Jonathan Sharpe]: https://github.com/textbook +[Michael Rush]: https://github.com/rushimusmaximus +[Patrick Scheibe]: https://github.com/halirutan +[Kyle Brown]: https://github.com/kylebrown9 +[Marcus Ortiz]: https://github.com/mportiz08 +[Paul Reid]: https://github.com/RedGuy12 + + +## Version 10.3.1 + +Prior version let some look-behind regex sneak in, which does not work +yet on Safari. This release removes those incompatible regexes. + +Fix: + +- fix(Safari) Remove currently unsupported look-behind regex ([fix][187e7cfc]) [Josh Goebel][] + +[Josh Goebel]: https://github.com/joshgoebel +[187e7cfc]: https://github.com/highlightjs/highlight.js/commit/187e7cfcb06277ce13b5f35fb6c37ab7a7b46de9 + + +## Version 10.3.0 + +Language Improvements: + +- enh(latex) Complete ground up rewrite of LaTex grammar [schtandard][] +- fix(cpp) implement backslash line continuation in comments (#2757) [Konrad Rudolph][] +- fix(cpp) improve parsing issues with templates (#2752) [Josh Goebel][] +- enh(cpp) add support for `enum (struct|class)` and `union` (#2752) [Josh Goebel][] +- fix(js/ts) Fix nesting of `{}` inside template literals SUBST expression (#2748) [Josh Goebel][] +- enh(js/ts) Highlight class methods as functions (#2727) [Josh Goebel][] +- fix(js/ts) `constructor` is now highlighted as a function title (not keyword) (#2727) [Josh Goebel][] +- fix(c-like) preprocessor directives not detected after else (#2738) [Josh Goebel][] +- enh(javascript) allow `#` for private class fields (#2701) [Chris Krycho][] +- fix(js) prevent runaway regex (#2746) [Josh Goebel][] +- fix(bash) enh(bash) allow nested params (#2731) [Josh Goebel][] +- fix(python) Fix highlighting of keywords and strings (#2713, #2715) [Konrad Rudolph][] +- fix(fsharp) Prevent `(*)` from being detected as a multi-line comment [Josh Goebel][] +- enh(bash) add support for heredocs (#2684) [Josh Goebel][] +- enh(r) major overhaul of the R language grammar (and fix a few bugs) (#2680) [Konrad Rudolph][] +- enh(csharp) Add all C# 9 keywords, and other missing keywords (#2679) [David Pine][] +- enh(objectivec) Add `objective-c++` and `obj-c++` aliases for Objective-C [Josh Goebel][] +- enh(java) Add support for `record` (#2685) [Josh Goebel][] +- fix(csharp) prevent modifier keywords wrongly flagged as `title` (#2683) [Josh Goebel][] +- enh(axapta) Update keyword list for Axapta (X++) (#2686) [Ryan Jonasson][] +- fix(fortran) FORTRAN 77-style comments (#2677) [Philipp Engel][] +- fix(javascript) Comments inside params should be highlighted (#2702) [Josh Goebel][] +- fix(scala) Comments inside class header should be highlighted (#1559) [Josh Goebel][] +- fix(c-like) Correctly highlight modifiers (`final`) in class declaration (#2696) [Josh Goebel][] +- enh(angelscript) Improve heredocs, numbers, metadata blocks (#2724) [Melissa Geels][] +- enh(javascript) Implement Numeric Separators (#2617) [Antoine du Hamel][] +- enh(typescript) TypeScript also gains support for numeric separators (#2617) [Antoine du Hamel][] +- enh(php) Add support for PHP 8 `match` keyword and add `php8` as an alias (#2733) [Ayesh Karunaratne][] +- fix(handlebars) Support if else keyboards (#2659) [Tom Wallace][] + +Deprecations: + +- `useBR` option deprecated and will be removed in v11.0. (#2559) [Josh Goebel][] + +[Chris Krycho]: https://github.com/chriskrycho +[David Pine]: https://github.com/IEvangelist + + +[Ryan Jonasson]: https://github.com/ryanjonasson +[Philipp Engel]: https://github.com/interkosmos +[Konrad Rudolph]: https://github.com/klmr +[Melissa Geels]: https://github.com/codecat +[Antoine du Hamel]: https://github.com/aduh95 +[Ayesh Karunaratne]: https://github.com/Ayesh +[Tom Wallace]: https://github.com/thomasmichaelwallace +[schtandard]: https://github.com/schtandard + + +## Version 10.2.1 + + Parser Engine: + + - fix(parser) complete fix for resuming matches from same index (#2678) [Josh Goebel][] + + [Josh Goebel]: https://github.com/yyyc514 + + +## Version 10.2.0 + +Parser Engine: + +- (fix) When ignoring a potential match highlighting can terminate early (#2649) [Josh Goebel][] + +New themes: + +- *Gradient Light* by [Samia Ali]() + +Deprecations: + +- `fixMarkup` is now deprecated and will be removed in v11.0. (#2534) [Josh Goebel][] + +Big picture: + +- Add simple Vue plugin for basic use cases (#2544) [Josh Goebel][] + +Language Improvements: + +- fix(bash) Fewer false positives for keywords in arguments (#2669) [sirosen][] +- fix(js) Prevent long series of /////// from causing freezes (#2656) [Josh Goebel][] +- enh(csharp) Add `init` and `record` keywords for C# 9.0 (#2660) [Youssef Victor][] +- enh(matlab) Add new R2019b `arguments` keyword and fix `enumeration` keyword (#2619) [Andrew Janke][] +- fix(kotlin) Remove very old keywords and update example code (#2623) [kageru][] +- fix(night) Prevent object prototypes method values from being returned in `getLanguage` (#2636) [night][] +- enh(java) Add support for `enum`, which will identify as a `class` now (#2643) [ezksd][] +- enh(nsis) Add support for NSIS 3.06 commands (#2653) [idleberg][] +- enh(php) detect newer more flexible HEREdoc syntax (#2658) [eytienne][] + +[Youssef Victor]: https://github.com/Youssef1313 +[Josh Goebel]: https://github.com/joshgoebel +[Andrew Janke]: https://github.com/apjanke +[Samia Ali]: https://github.com/samiaab1990 +[kageru]: https://github.com/kageru +[night]: https://github.com/night +[ezksd]: https://github.com/ezksd +[idleberg]: https://github.com/idleberg +[eytienne]: https://github.com/eytienne +[sirosen]: https://github.com/sirosen + + +## Version 10.1.1 + +Fixes: + +- Resolve issue on Node 6 due to dangling comma (#2608) [Edwin Hoogerbeets][] +- Resolve `index.d.ts is not a module` error (#2603) [Josh Goebel][] + +[Josh Goebel]: https://github.com/joshgoebel +[Edwin Hoogerbeets]: https://github.com/ehoogerbeets + + ## Version 10.1.0 New themes: @@ -50,7 +307,7 @@ Language Improvements: - enh(protobuf) Support multiline comments (#2597) [Pavel Evstigneev][] - fix(toml) Improve key parsing (#2595) [Antoine du Hamel][] -[Josh Goebel]: https://github.com/yyyc514 +[Josh Goebel]: https://github.com/joshgoebel [Peter Plantinga]: https://github.com/pplantinga [David Benjamin]: https://github.com/davidben [Vania Kucher]: https://github.com/qWici @@ -78,7 +335,7 @@ Parser Engine Changes: - [Issue](https://github.com/highlightjs/highlight.js/issues/2522) fix(parser) Fix freez issue with illegal 0 width matches (#2524) [Josh Goebel][] -[Josh Goebel]: https://github.com/yyyc514 +[Josh Goebel]: https://github.com/joshgoebel ## Version 10.0.1 @@ -87,7 +344,7 @@ Parser Engine Changes: - (bug) Fix sublanguage with no relevance score (#2506) [Josh Goebel][] -[Josh Goebel]: https://github.com/yyyc514 +[Josh Goebel]: https://github.com/joshgoebel ## Version 10.0.0 @@ -156,12 +413,12 @@ Developer Tools: [Omid Golparvar]: https://github.com/omidgolparvar [Alexandre Grison]: https://github.com/agrison -[Josh Goebel]: https://github.com/yyyc514 +[Josh Goebel]: https://github.com/joshgoebel [Chen Bin]: https://github.com/redguardtoo [Sam Miller]: https://github.com/smillerc [Robert Riebisch]: https://github.com/bttrx [Taufik Nurrohman]: https://github.com/taufik-nurrohman -[Josh Goebel]: https://github.com/yyyc514 +[Josh Goebel]: https://github.com/joshgoebel [Sean Williams]: https://github.com/hmmwhatsthisdo [Adnan Yaqoob]: https://github.com/adnanyaqoobvirk [Álvaro Mondéjar]: https://github.com/mondeja @@ -173,7 +430,7 @@ Grammar Improvements: - bug(coffeescript) fix freezing bug due to badly behaved regex (#2376) [Josh Goebel][] -[Josh Goebel]: https://github.com/yyyc514 +[Josh Goebel]: https://github.com/joshgoebel ## Version 9.18.0 @@ -208,7 +465,7 @@ Developer Tools: - feat(developer): add button to show parsed structure (#2345) [Nils Knappmeier][] [Jeffrey Arnold]: https://github.com/jrnold -[Josh Goebel]: https://github.com/yyyc514 +[Josh Goebel]: https://github.com/joshgoebel [Philipp Engel]: https://github.com/interkosmos [Youssef Victor]: https://github.com/Youssef1313 [Nils Knappmeier]: https://github.com/nknapp @@ -220,7 +477,7 @@ Fixes: - fix(parser): resolve IE 11 issue with Object.freeze() (#2319) [Josh Goebel][] -[Josh Goebel]: https://github.com/yyyc514 +[Josh Goebel]: https://github.com/joshgoebel ## Version 9.17.0 @@ -270,7 +527,7 @@ Language Improvements: - fix(objectivec): Handle multibyte character literals (#2268) [David Benjamin][] - enh(cpp): Add additional keywords (#2289) [Adrian Ostrowski][] -[Josh Goebel]: https://github.com/yyyc514 +[Josh Goebel]: https://github.com/joshgoebel [Liam Nobel]: https://github.com/liamnobel [Carl Baxter]: https://github.com/cdbax [Milutin Kristofic]: https://github.com/milutin @@ -1179,7 +1436,7 @@ Notable fixes and improvements to existing languages: - HTML ` + href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.4.1/styles/default.min.css"> + + src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.4.1/languages/go.min.js"> ``` **jsdelivr** ([link](https://www.jsdelivr.com/package/gh/highlightjs/cdn-release)) ```html - + href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.4.1/build/styles/default.min.css"> + +``` + +**unpkg** ([link](https://unpkg.com/browse/@highlightjs/cdn-assets/)) + +```html + + ``` **Note:** *The CDN-hosted `highlight.min.js` package doesn't bundle every language.* It would be -very large. You can find our list "common" languages that we bundle by default on our [download page][5]. +very large. You can find our list "common" languages that we bundle by default on our [download page][5]. ### Self Hosting diff --git a/README.ru.md b/README.ru.md index a448e217ed..26afb40106 100644 --- a/README.ru.md +++ b/README.ru.md @@ -108,7 +108,7 @@ Highlight.js можно использовать в браузере прямо ```html + src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/languages/go.min.js"> ``` **Про Almond.** Нужно задать имя модуля в оптимизаторе, например: diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000000..76821036ba --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,19 @@ +# Security Policy + +## Supported Versions + +Due to both time and resource constrains the Highlight.js core team only fully supports the current major/minor release of the library. Problems with minor releases are often resolved by upgrading to the most recent release. + +| Version | Supported | Status | +| :-----: | :-: | :------ | +| 10.4.1 | :white_check_mark:   :closed_lock_with_key: | The 10.x series recieves regular updates, new features & bug fixes. | +| <= 10.4.0 | :x: | Known vulnerabities. *Please upgrade to a more recent 10.x release.* | +| 9.18.5 | :x: | [EOL](https://github.com/highlightjs/highlight.js/issues/2877). No longer supported. See [VERSION_10_UPGRADE.md](https://github.com/highlightjs/highlight.js/blob/master/VERSION_10_UPGRADE.md). | +| <= 9.18.3 | :x: | No longer supported. Known vulnerabities. | +| <= 8.x | :x: | Obsolete. | + + +## Reporting a Vulnerability + +Minor vulnerabilities can simply be reported (and tracked) via our [GitHub issues](https://github.com/highlightjs/highlight.js/issues). If you feel your issue is more sensitive than that you can always reach us via email: [security@highlightjs.org](mailto:security@highlightjs.org) + diff --git a/SUPPORTED_LANGUAGES.md b/SUPPORTED_LANGUAGES.md index 482595f134..8c4661ac98 100644 --- a/SUPPORTED_LANGUAGES.md +++ b/SUPPORTED_LANGUAGES.md @@ -12,10 +12,12 @@ Languages that listed a **Package** below are 3rd party languages and are not bu | ABNF | abnf | | | Access logs | accesslog | | | Ada | ada | | +| Arduino (C++ w/Arduino libs) | arduino ino | | | ARM assembler | armasm, arm | | | AVR assembler | avrasm | | | ActionScript | actionscript, as | | -| Alan | alan, i | [highlightjs-alan](https://github.com/highlightjs/highlightjs-alan) | +| Alan IF | alan, i | [highlightjs-alan](https://github.com/highlightjs/highlightjs-alan) | +| Alan | ln | [highlightjs-alan](https://github.com/alantech/highlightjs-alan) | | AngelScript | angelscript, asc | | | Apache | apache, apacheconf | | | AppleScript | applescript, osascript | | @@ -25,9 +27,9 @@ Languages that listed a **Package** below are 3rd party languages and are not bu | AutoHotkey | autohotkey | | | AutoIt | autoit | | | Awk | awk, mawk, nawk, gawk | | -| Axapta | axapta | | | Bash | bash, sh, zsh | | | Basic | basic | | +| BBCode | bbcode | [highlightjs-bbcode](https://github.com/RedGuy7/highlightjs-bbcode) | | BNF | bnf | | | Brainfuck | brainfuck, bf | | | C# | csharp, cs | | @@ -41,6 +43,7 @@ Languages that listed a **Package** below are 3rd party languages and are not bu | CSS | css | | | Cap’n Proto | capnproto, capnp | | | Chaos | chaos, kaos | [highlightjs-chaos](https://github.com/chaos-lang/highlightjs-chaos) | +| Chapel | chapel, chpl | [highlightjs-chapel](https://github.com/chapel-lang/highlightjs-chapel) | | Cisco CLI | cisco | [highlightjs-cisco-cli](https://github.com/BMatheas/highlightjs-cisco-cli) | | Clojure | clojure, clj | | | CoffeeScript | coffeescript, coffee, cson, iced | | @@ -94,6 +97,7 @@ Languages that listed a **Package** below are 3rd party languages and are not bu | Java | java, jsp | | | JavaScript | javascript, js, jsx | | | Jolie | jolie, iol, ol | [highlightjs-jolie](https://github.com/xiroV/highlightjs-jolie) | +| Julia | julia, julia-repl | | | Kotlin | kotlin, kt | | | LaTeX | tex | | | Leaf | leaf | | @@ -121,11 +125,11 @@ Languages that listed a **Package** below are 3rd party languages and are not bu | NSIS | nsis | | | Never | never | [highlightjs-never](https://github.com/never-lang/highlightjs-never) | | Nginx | nginx, nginxconf | | -| Nim | nimrod | | +| Nim | nim, nimrod | | | Nix | nix | | | Object Constraint Language | ocl | [highlightjs-ocl](https://github.com/nhomble/highlightjs-ocl) | | OCaml | ocaml, ml | | -| Objective C | objectivec, mm, objc, obj-c | | +| Objective C | objectivec, mm, objc, obj-c, obj-c++, objective-c++ | | | OpenGL Shading Language | glsl | | | OpenSCAD | openscad, scad | | | Oracle Rules Language | ruleslanguage | | @@ -169,6 +173,7 @@ Languages that listed a **Package** below are 3rd party languages and are not bu | Shell | shell, console | | | Smali | smali | | | Smalltalk | smalltalk, st | | +| SML | sml, ml | | | Solidity | solidity, sol | [highlightjs-solidity](https://github.com/highlightjs/highlightjs-solidity) | | Stan | stan, stanfuncs | | | Stata | stata | | @@ -194,6 +199,7 @@ Languages that listed a **Package** below are 3rd party languages and are not bu | Vala | vala | | | Verilog | verilog, v | | | Vim Script | vim | | +| X++ | axapta, x++ | | | x86 Assembly | x86asm | | | XL | xl, tao | | | XQuery | xquery, xpath, xq | | @@ -201,5 +207,18 @@ Languages that listed a **Package** below are 3rd party languages and are not bu | Zephir | zephir, zep | | + +## Alias Overlap + +If you are using either of these languages at the same time please be sure to +use the full name and not the alias to avoid any ambiguity. + +| Language | Overlap | +| :-----------------------| :--------------------- | +| SML | ml | +| OCaml | ml | +| Lasso | ls | +| LiveScript | ls | + [1]: https://github.com/highlightjs/highlight.js#getting-the-library diff --git a/VERSION_10_BREAKING_CHANGES.md b/VERSION_10_BREAKING_CHANGES.md index f60a6c00d5..cc9ac1cce5 100644 --- a/VERSION_10_BREAKING_CHANGES.md +++ b/VERSION_10_BREAKING_CHANGES.md @@ -32,7 +32,7 @@ Removed styles: - chore(styles): darkula.css (use darcula.css instead) [Josh Goebel][] -[Josh Goebel]: https://github.com/yyyc514 +[Josh Goebel]: https://github.com/joshgoebel --- diff --git a/demo/demo.js b/demo/demo.js index bb46e7a605..cd90785bf7 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -13,11 +13,9 @@ var screenHeight = $window.height() $categoryContainer.css('max-height', screenHeight / 4); - $categoryContainer.perfectScrollbar('update'); $styleContainer.height( screenHeight - $styleContainer.position().top - 20 ); - $styleContainer.perfectScrollbar('update'); } function selectCategory(category) { @@ -83,7 +81,6 @@ }); $categories.first().click(); - $categoryContainer.perfectScrollbar(); } function selectStyle(style) { @@ -109,7 +106,6 @@ selectStyle($style.text()); }); $styles.first().click(); - $styleContainer.perfectScrollbar(); } $(function() { diff --git a/demo/index.html b/demo/index.html index 6ff356a32c..8177631787 100644 --- a/demo/index.html +++ b/demo/index.html @@ -5,7 +5,6 @@ highlight.js demo - <% _.each(styles, function(style) { %> @@ -21,12 +20,12 @@

highlight.js demo

-

Language categories

+

Languages

    -

    Styles

    +

    Themes

      @@ -47,9 +46,12 @@

      <%- language.prettyName %>

      + <% if (minify) { %> + <% } else { %> + + <% } %> - diff --git a/demo/perfect-scrollbar.min.css b/demo/perfect-scrollbar.min.css deleted file mode 100644 index fc452aff82..0000000000 --- a/demo/perfect-scrollbar.min.css +++ /dev/null @@ -1,5 +0,0 @@ -/*! perfect-scrollbar - v0.5.7 -* http://noraesae.github.com/perfect-scrollbar/ -* Copyright (c) 2014 Hyunje Alex Jun; Licensed MIT */ - -.ps-container.ps-active-x>.ps-scrollbar-x-rail,.ps-container.ps-active-y>.ps-scrollbar-y-rail{display:block}.ps-container>.ps-scrollbar-x-rail{display:none;position:absolute;-webkit-border-radius:4px;-moz-border-radius:4px;-ms-border-radius:4px;border-radius:4px;opacity:0;-ms-filter:"alpha(Opacity=0)";filter:alpha(opacity=0);-webkit-transition:background-color .2s linear,opacity .2s linear;-moz-transition:background-color .2s linear,opacity .2s linear;-o-transition:background-color .2s linear,opacity .2s linear;transition:background-color .2s linear,opacity .2s linear;bottom:3px;height:8px}.ps-container>.ps-scrollbar-x-rail>.ps-scrollbar-x{position:absolute;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;-ms-border-radius:4px;border-radius:4px;-webkit-transition:background-color .2s linear;-moz-transition:background-color .2s linear;-o-transition:background-color .2s linear;transition:background-color .2s linear;bottom:0;height:8px}.ps-container>.ps-scrollbar-x-rail.in-scrolling{background-color:#eee;opacity:.9;-ms-filter:"alpha(Opacity=90)";filter:alpha(opacity=90)}.ps-container>.ps-scrollbar-y-rail{display:none;position:absolute;-webkit-border-radius:4px;-moz-border-radius:4px;-ms-border-radius:4px;border-radius:4px;opacity:0;-ms-filter:"alpha(Opacity=0)";filter:alpha(opacity=0);-webkit-transition:background-color .2s linear,opacity .2s linear;-moz-transition:background-color .2s linear,opacity .2s linear;-o-transition:background-color .2s linear,opacity .2s linear;transition:background-color .2s linear,opacity .2s linear;right:3px;width:8px}.ps-container>.ps-scrollbar-y-rail>.ps-scrollbar-y{position:absolute;background-color:#aaa;-webkit-border-radius:4px;-moz-border-radius:4px;-ms-border-radius:4px;border-radius:4px;-webkit-transition:background-color .2s linear;-moz-transition:background-color .2s linear;-o-transition:background-color .2s linear;transition:background-color .2s linear;right:0;width:8px}.ps-container>.ps-scrollbar-y-rail.in-scrolling{background-color:#eee;opacity:.9;-ms-filter:"alpha(Opacity=90)";filter:alpha(opacity=90)}.ps-container:hover>.ps-scrollbar-x-rail,.ps-container:hover>.ps-scrollbar-y-rail{opacity:.6;-ms-filter:"alpha(Opacity=60)";filter:alpha(opacity=60)}.ps-container:hover>.ps-scrollbar-x-rail.in-scrolling,.ps-container:hover>.ps-scrollbar-y-rail.in-scrolling{background-color:#eee;opacity:.9;-ms-filter:"alpha(Opacity=90)";filter:alpha(opacity=90)}.ps-container:hover>.ps-scrollbar-x-rail:hover{background-color:#eee;opacity:.9;-ms-filter:"alpha(Opacity=90)";filter:alpha(opacity=90)}.ps-container:hover>.ps-scrollbar-x-rail:hover>.ps-scrollbar-x{background-color:#999}.ps-container:hover>.ps-scrollbar-y-rail:hover{background-color:#eee;opacity:.9;-ms-filter:"alpha(Opacity=90)";filter:alpha(opacity=90)}.ps-container:hover>.ps-scrollbar-y-rail:hover>.ps-scrollbar-y{background-color:#999} \ No newline at end of file diff --git a/demo/perfect-scrollbar.min.js b/demo/perfect-scrollbar.min.js deleted file mode 100644 index ff3f5ac9c8..0000000000 --- a/demo/perfect-scrollbar.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! perfect-scrollbar - v0.5.7 -* http://noraesae.github.com/perfect-scrollbar/ -* Copyright (c) 2014 Hyunje Alex Jun; Licensed MIT */ -(function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):e(jQuery)})(function(e){"use strict";function t(e){return"string"==typeof e?parseInt(e,10):~~e}var o={wheelSpeed:1,wheelPropagation:!1,minScrollbarLength:null,maxScrollbarLength:null,useBothWheelAxes:!1,useKeyboard:!0,suppressScrollX:!1,suppressScrollY:!1,scrollXMarginOffset:0,scrollYMarginOffset:0,includePadding:!1},n=0,r=function(){var e=n++;return function(t){var o=".perfect-scrollbar-"+e;return t===void 0?o:t+o}};e.fn.perfectScrollbar=function(n,l){return this.each(function(){function i(e,o){var n=e+o,r=E-W;I=0>n?0:n>r?r:n;var l=t(I*(D-E)/(E-W));S.scrollTop(l)}function a(e,o){var n=e+o,r=x-Y;X=0>n?0:n>r?r:n;var l=t(X*(M-x)/(x-Y));S.scrollLeft(l)}function c(e){return L.minScrollbarLength&&(e=Math.max(e,L.minScrollbarLength)),L.maxScrollbarLength&&(e=Math.min(e,L.maxScrollbarLength)),e}function s(){var e={width:x};e.left=O?S.scrollLeft()+x-M:S.scrollLeft(),B?e.bottom=q-S.scrollTop():e.top=H+S.scrollTop(),A.css(e);var t={top:S.scrollTop(),height:E};z?t.right=O?M-S.scrollLeft()-Q-N.outerWidth():Q-S.scrollLeft():t.left=O?S.scrollLeft()+2*x-M-F-N.outerWidth():F+S.scrollLeft(),_.css(t),K.css({left:X,width:Y-U}),N.css({top:I,height:W-G})}function d(){S.removeClass("ps-active-x"),S.removeClass("ps-active-y"),x=L.includePadding?S.innerWidth():S.width(),E=L.includePadding?S.innerHeight():S.height(),M=S.prop("scrollWidth"),D=S.prop("scrollHeight"),!L.suppressScrollX&&M>x+L.scrollXMarginOffset?(C=!0,Y=c(t(x*x/M)),X=t(S.scrollLeft()*(x-Y)/(M-x))):(C=!1,Y=0,X=0,S.scrollLeft(0)),!L.suppressScrollY&&D>E+L.scrollYMarginOffset?(k=!0,W=c(t(E*E/D)),I=t(S.scrollTop()*(E-W)/(D-E))):(k=!1,W=0,I=0,S.scrollTop(0)),X>=x-Y&&(X=x-Y),I>=E-W&&(I=E-W),s(),C&&S.addClass("ps-active-x"),k&&S.addClass("ps-active-y")}function u(){var t,o,n=!1;K.bind(j("mousedown"),function(e){o=e.pageX,t=K.position().left,A.addClass("in-scrolling"),n=!0,e.stopPropagation(),e.preventDefault()}),e(R).bind(j("mousemove"),function(e){n&&(a(t,e.pageX-o),d(),e.stopPropagation(),e.preventDefault())}),e(R).bind(j("mouseup"),function(){n&&(n=!1,A.removeClass("in-scrolling"))}),t=o=null}function p(){var t,o,n=!1;N.bind(j("mousedown"),function(e){o=e.pageY,t=N.position().top,n=!0,_.addClass("in-scrolling"),e.stopPropagation(),e.preventDefault()}),e(R).bind(j("mousemove"),function(e){n&&(i(t,e.pageY-o),d(),e.stopPropagation(),e.preventDefault())}),e(R).bind(j("mouseup"),function(){n&&(n=!1,_.removeClass("in-scrolling"))}),t=o=null}function f(e,t){var o=S.scrollTop();if(0===e){if(!k)return!1;if(0===o&&t>0||o>=D-E&&0>t)return!L.wheelPropagation}var n=S.scrollLeft();if(0===t){if(!C)return!1;if(0===n&&0>e||n>=M-x&&e>0)return!L.wheelPropagation}return!0}function v(){function e(e){var t=e.originalEvent.deltaX,o=-1*e.originalEvent.deltaY;return(t===void 0||o===void 0)&&(t=-1*e.originalEvent.wheelDeltaX/6,o=e.originalEvent.wheelDeltaY/6),e.originalEvent.deltaMode&&1===e.originalEvent.deltaMode&&(t*=10,o*=10),t!==t&&o!==o&&(t=0,o=e.originalEvent.wheelDelta),[t,o]}function t(t){var n=e(t),r=n[0],l=n[1];o=!1,L.useBothWheelAxes?k&&!C?(l?S.scrollTop(S.scrollTop()-l*L.wheelSpeed):S.scrollTop(S.scrollTop()+r*L.wheelSpeed),o=!0):C&&!k&&(r?S.scrollLeft(S.scrollLeft()+r*L.wheelSpeed):S.scrollLeft(S.scrollLeft()-l*L.wheelSpeed),o=!0):(S.scrollTop(S.scrollTop()-l*L.wheelSpeed),S.scrollLeft(S.scrollLeft()+r*L.wheelSpeed)),d(),o=o||f(r,l),o&&(t.stopPropagation(),t.preventDefault())}var o=!1;window.onwheel!==void 0?S.bind(j("wheel"),t):window.onmousewheel!==void 0&&S.bind(j("mousewheel"),t)}function g(){var t=!1;S.bind(j("mouseenter"),function(){t=!0}),S.bind(j("mouseleave"),function(){t=!1});var o=!1;e(R).bind(j("keydown"),function(n){if((!n.isDefaultPrevented||!n.isDefaultPrevented())&&t){for(var r=document.activeElement?document.activeElement:R.activeElement;r.shadowRoot;)r=r.shadowRoot.activeElement;if(!e(r).is(":input,[contenteditable]")){var l=0,i=0;switch(n.which){case 37:l=-30;break;case 38:i=30;break;case 39:l=30;break;case 40:i=-30;break;case 33:i=90;break;case 32:case 34:i=-90;break;case 35:i=n.ctrlKey?-D:-E;break;case 36:i=n.ctrlKey?S.scrollTop():E;break;default:return}S.scrollTop(S.scrollTop()-i),S.scrollLeft(S.scrollLeft()+l),o=f(l,i),o&&n.preventDefault()}}})}function b(){function e(e){e.stopPropagation()}N.bind(j("click"),e),_.bind(j("click"),function(e){var o=t(W/2),n=e.pageY-_.offset().top-o,r=E-W,l=n/r;0>l?l=0:l>1&&(l=1),S.scrollTop((D-E)*l)}),K.bind(j("click"),e),A.bind(j("click"),function(e){var o=t(Y/2),n=e.pageX-A.offset().left-o,r=x-Y,l=n/r;0>l?l=0:l>1&&(l=1),S.scrollLeft((M-x)*l)})}function h(){function t(){var e=window.getSelection?window.getSelection():document.getSlection?document.getSlection():{rangeCount:0};return 0===e.rangeCount?null:e.getRangeAt(0).commonAncestorContainer}function o(){r||(r=setInterval(function(){return P()?(S.scrollTop(S.scrollTop()+l.top),S.scrollLeft(S.scrollLeft()+l.left),d(),void 0):(clearInterval(r),void 0)},50))}function n(){r&&(clearInterval(r),r=null),A.removeClass("in-scrolling"),_.removeClass("in-scrolling")}var r=null,l={top:0,left:0},i=!1;e(R).bind(j("selectionchange"),function(){e.contains(S[0],t())?i=!0:(i=!1,n())}),e(window).bind(j("mouseup"),function(){i&&(i=!1,n())}),e(window).bind(j("mousemove"),function(e){if(i){var t={x:e.pageX,y:e.pageY},r=S.offset(),a={left:r.left,right:r.left+S.outerWidth(),top:r.top,bottom:r.top+S.outerHeight()};t.xa.right-3?(l.left=5,A.addClass("in-scrolling")):l.left=0,t.ya.top+3-t.y?-5:-20,_.addClass("in-scrolling")):t.y>a.bottom-3?(l.top=5>t.y-a.bottom+3?5:20,_.addClass("in-scrolling")):l.top=0,0===l.top&&0===l.left?n():o()}})}function w(t,o){function n(e,t){S.scrollTop(S.scrollTop()-t),S.scrollLeft(S.scrollLeft()-e),d()}function r(){b=!0}function l(){b=!1}function i(e){return e.originalEvent.targetTouches?e.originalEvent.targetTouches[0]:e.originalEvent}function a(e){var t=e.originalEvent;return t.targetTouches&&1===t.targetTouches.length?!0:t.pointerType&&"mouse"!==t.pointerType&&t.pointerType!==t.MSPOINTER_TYPE_MOUSE?!0:!1}function c(e){if(a(e)){h=!0;var t=i(e);p.pageX=t.pageX,p.pageY=t.pageY,f=(new Date).getTime(),null!==g&&clearInterval(g),e.stopPropagation()}}function s(e){if(!b&&h&&a(e)){var t=i(e),o={pageX:t.pageX,pageY:t.pageY},r=o.pageX-p.pageX,l=o.pageY-p.pageY;n(r,l),p=o;var c=(new Date).getTime(),s=c-f;s>0&&(v.x=r/s,v.y=l/s,f=c),e.stopPropagation(),e.preventDefault()}}function u(){!b&&h&&(h=!1,clearInterval(g),g=setInterval(function(){return P()?.01>Math.abs(v.x)&&.01>Math.abs(v.y)?(clearInterval(g),void 0):(n(30*v.x,30*v.y),v.x*=.8,v.y*=.8,void 0):(clearInterval(g),void 0)},10))}var p={},f=0,v={},g=null,b=!1,h=!1;t&&(e(window).bind(j("touchstart"),r),e(window).bind(j("touchend"),l),S.bind(j("touchstart"),c),S.bind(j("touchmove"),s),S.bind(j("touchend"),u)),o&&(window.PointerEvent?(e(window).bind(j("pointerdown"),r),e(window).bind(j("pointerup"),l),S.bind(j("pointerdown"),c),S.bind(j("pointermove"),s),S.bind(j("pointerup"),u)):window.MSPointerEvent&&(e(window).bind(j("MSPointerDown"),r),e(window).bind(j("MSPointerUp"),l),S.bind(j("MSPointerDown"),c),S.bind(j("MSPointerMove"),s),S.bind(j("MSPointerUp"),u)))}function m(){S.bind(j("scroll"),function(){d()})}function T(){S.unbind(j()),e(window).unbind(j()),e(R).unbind(j()),S.data("perfect-scrollbar",null),S.data("perfect-scrollbar-update",null),S.data("perfect-scrollbar-destroy",null),K.remove(),N.remove(),A.remove(),_.remove(),S=A=_=K=N=C=k=x=E=M=D=Y=X=q=B=H=W=I=Q=z=F=O=j=null}function y(){d(),m(),u(),p(),b(),h(),v(),(J||V)&&w(J,V),L.useKeyboard&&g(),S.data("perfect-scrollbar",S),S.data("perfect-scrollbar-update",d),S.data("perfect-scrollbar-destroy",T)}var L=e.extend(!0,{},o),S=e(this),P=function(){return!!S};if("object"==typeof n?e.extend(!0,L,n):l=n,"update"===l)return S.data("perfect-scrollbar-update")&&S.data("perfect-scrollbar-update")(),S;if("destroy"===l)return S.data("perfect-scrollbar-destroy")&&S.data("perfect-scrollbar-destroy")(),S;if(S.data("perfect-scrollbar"))return S.data("perfect-scrollbar");S.addClass("ps-container");var x,E,M,D,C,Y,X,k,W,I,O="rtl"===S.css("direction"),j=r(),R=this.ownerDocument||document,A=e("
      ").appendTo(S),K=e("
      ").appendTo(A),q=t(A.css("bottom")),B=q===q,H=B?null:t(A.css("top")),U=t(A.css("borderLeftWidth"))+t(A.css("borderRightWidth")),_=e("
      ").appendTo(S),N=e("
      ").appendTo(_),Q=t(_.css("right")),z=Q===Q,F=z?null:t(_.css("left")),G=t(_.css("borderTopWidth"))+t(_.css("borderBottomWidth")),J="ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch,V=null!==window.navigator.msMaxTouchPoints;return y(),S})}}); \ No newline at end of file diff --git a/demo/style.css b/demo/style.css index 6fa82319b8..103be0c89f 100644 --- a/demo/style.css +++ b/demo/style.css @@ -1,33 +1,51 @@ +@import url(https://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic); + /* Base styles */ body { - color: #F0F0F0; + color: #f0f0f0; background: #500; - font-family: Arial, sans; - margin: 0; padding: 0; + font-family: PT Sans, DejaVu Sans, Arial, sans; + margin: 0; + padding: 0; } a { - color: white; + color: #f0f0f0; } h1 { - font: bold 150% Arial, sans-serif; - margin: 0; padding: 1em 0; + font-size: 150%; + margin: 0; + padding: 1em 0 0.5em; } h2 { - font: bold 120% Arial, sans-serif; + font-size: 120%; margin: 1.5em 0 0.5em 0; } pre { margin: 0; - font-size: medium; +} + +code { + font-family: Consolas, Monaco, monospace; + font-size: 10pt; + scrollbar-width: thin; +} + +body pre code.hljs { + padding-left: 1.5em; + /* compatible with school-book */ + padding-top:15px; } #sidebar { - float: left; width: 16em; height: 1000em; position: fixed; - padding: 1px 1em; + float: left; + width: 16em; + height: 1000em; + position: fixed; + padding: 0 1em; background: #600; box-shadow: 0 0 15px black; } @@ -35,12 +53,38 @@ pre { #sidebar ul, #sidebar li { list-style: none; - margin: 0; padding: 0; + margin: 0; + padding: 0; } #sidebar ul { position: relative; - overflow-y: hidden; + overflow-y: auto; + scrollbar-width: thin; +} + +#sidebar ul::-webkit-scrollbar { + width: 8px; +} + +#sidebar ul::-webkit-scrollbar-track { + background: #4d0607; + border-radius: 5px; +} + +#sidebar ul::-webkit-scrollbar-thumb { + background: #926868; + border-right: 1px solid #4d0607; + border-left: 1px solid #4d0607; + border-radius: 5px; +} + +#sidebar ul::-webkit-scrollbar-thumb:hover { + background: #7f5555; +} + +#sidebar ul::-webkit-scrollbar-thumb:active { + background: #5d3333; } #sidebar li { @@ -53,12 +97,15 @@ pre { } #sidebar li.current:before { - content: '▶'; font-size: smaller; - position: absolute; left: 0; + content: "▶"; + font-size: smaller; + position: absolute; + left: 0; } #content { - margin-left: 19em; + margin-left: 18em; + min-width: 36em; } #languages { diff --git a/demo/vue.js b/demo/vue.js new file mode 100644 index 0000000000..e22cf13003 --- /dev/null +++ b/demo/vue.js @@ -0,0 +1,11965 @@ +/*! + * Vue.js v2.6.11 + * (c) 2014-2019 Evan You + * Released under the MIT License. + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = global || self, global.Vue = factory()); +}(this, function () { 'use strict'; + + /* */ + + var emptyObject = Object.freeze({}); + + // These helpers produce better VM code in JS engines due to their + // explicitness and function inlining. + function isUndef (v) { + return v === undefined || v === null + } + + function isDef (v) { + return v !== undefined && v !== null + } + + function isTrue (v) { + return v === true + } + + function isFalse (v) { + return v === false + } + + /** + * Check if value is primitive. + */ + function isPrimitive (value) { + return ( + typeof value === 'string' || + typeof value === 'number' || + // $flow-disable-line + typeof value === 'symbol' || + typeof value === 'boolean' + ) + } + + /** + * Quick object check - this is primarily used to tell + * Objects from primitive values when we know the value + * is a JSON-compliant type. + */ + function isObject (obj) { + return obj !== null && typeof obj === 'object' + } + + /** + * Get the raw type string of a value, e.g., [object Object]. + */ + var _toString = Object.prototype.toString; + + function toRawType (value) { + return _toString.call(value).slice(8, -1) + } + + /** + * Strict object type check. Only returns true + * for plain JavaScript objects. + */ + function isPlainObject (obj) { + return _toString.call(obj) === '[object Object]' + } + + function isRegExp (v) { + return _toString.call(v) === '[object RegExp]' + } + + /** + * Check if val is a valid array index. + */ + function isValidArrayIndex (val) { + var n = parseFloat(String(val)); + return n >= 0 && Math.floor(n) === n && isFinite(val) + } + + function isPromise (val) { + return ( + isDef(val) && + typeof val.then === 'function' && + typeof val.catch === 'function' + ) + } + + /** + * Convert a value to a string that is actually rendered. + */ + function toString (val) { + return val == null + ? '' + : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString) + ? JSON.stringify(val, null, 2) + : String(val) + } + + /** + * Convert an input value to a number for persistence. + * If the conversion fails, return original string. + */ + function toNumber (val) { + var n = parseFloat(val); + return isNaN(n) ? val : n + } + + /** + * Make a map and return a function for checking if a key + * is in that map. + */ + function makeMap ( + str, + expectsLowerCase + ) { + var map = Object.create(null); + var list = str.split(','); + for (var i = 0; i < list.length; i++) { + map[list[i]] = true; + } + return expectsLowerCase + ? function (val) { return map[val.toLowerCase()]; } + : function (val) { return map[val]; } + } + + /** + * Check if a tag is a built-in tag. + */ + var isBuiltInTag = makeMap('slot,component', true); + + /** + * Check if an attribute is a reserved attribute. + */ + var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is'); + + /** + * Remove an item from an array. + */ + function remove (arr, item) { + if (arr.length) { + var index = arr.indexOf(item); + if (index > -1) { + return arr.splice(index, 1) + } + } + } + + /** + * Check whether an object has the property. + */ + var hasOwnProperty = Object.prototype.hasOwnProperty; + function hasOwn (obj, key) { + return hasOwnProperty.call(obj, key) + } + + /** + * Create a cached version of a pure function. + */ + function cached (fn) { + var cache = Object.create(null); + return (function cachedFn (str) { + var hit = cache[str]; + return hit || (cache[str] = fn(str)) + }) + } + + /** + * Camelize a hyphen-delimited string. + */ + var camelizeRE = /-(\w)/g; + var camelize = cached(function (str) { + return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }) + }); + + /** + * Capitalize a string. + */ + var capitalize = cached(function (str) { + return str.charAt(0).toUpperCase() + str.slice(1) + }); + + /** + * Hyphenate a camelCase string. + */ + var hyphenateRE = /\B([A-Z])/g; + var hyphenate = cached(function (str) { + return str.replace(hyphenateRE, '-$1').toLowerCase() + }); + + /** + * Simple bind polyfill for environments that do not support it, + * e.g., PhantomJS 1.x. Technically, we don't need this anymore + * since native bind is now performant enough in most browsers. + * But removing it would mean breaking code that was able to run in + * PhantomJS 1.x, so this must be kept for backward compatibility. + */ + + /* istanbul ignore next */ + function polyfillBind (fn, ctx) { + function boundFn (a) { + var l = arguments.length; + return l + ? l > 1 + ? fn.apply(ctx, arguments) + : fn.call(ctx, a) + : fn.call(ctx) + } + + boundFn._length = fn.length; + return boundFn + } + + function nativeBind (fn, ctx) { + return fn.bind(ctx) + } + + var bind = Function.prototype.bind + ? nativeBind + : polyfillBind; + + /** + * Convert an Array-like object to a real Array. + */ + function toArray (list, start) { + start = start || 0; + var i = list.length - start; + var ret = new Array(i); + while (i--) { + ret[i] = list[i + start]; + } + return ret + } + + /** + * Mix properties into target object. + */ + function extend (to, _from) { + for (var key in _from) { + to[key] = _from[key]; + } + return to + } + + /** + * Merge an Array of Objects into a single Object. + */ + function toObject (arr) { + var res = {}; + for (var i = 0; i < arr.length; i++) { + if (arr[i]) { + extend(res, arr[i]); + } + } + return res + } + + /* eslint-disable no-unused-vars */ + + /** + * Perform no operation. + * Stubbing args to make Flow happy without leaving useless transpiled code + * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/). + */ + function noop (a, b, c) {} + + /** + * Always return false. + */ + var no = function (a, b, c) { return false; }; + + /* eslint-enable no-unused-vars */ + + /** + * Return the same value. + */ + var identity = function (_) { return _; }; + + /** + * Generate a string containing static keys from compiler modules. + */ + function genStaticKeys (modules) { + return modules.reduce(function (keys, m) { + return keys.concat(m.staticKeys || []) + }, []).join(',') + } + + /** + * Check if two values are loosely equal - that is, + * if they are plain objects, do they have the same shape? + */ + function looseEqual (a, b) { + if (a === b) { return true } + var isObjectA = isObject(a); + var isObjectB = isObject(b); + if (isObjectA && isObjectB) { + try { + var isArrayA = Array.isArray(a); + var isArrayB = Array.isArray(b); + if (isArrayA && isArrayB) { + return a.length === b.length && a.every(function (e, i) { + return looseEqual(e, b[i]) + }) + } else if (a instanceof Date && b instanceof Date) { + return a.getTime() === b.getTime() + } else if (!isArrayA && !isArrayB) { + var keysA = Object.keys(a); + var keysB = Object.keys(b); + return keysA.length === keysB.length && keysA.every(function (key) { + return looseEqual(a[key], b[key]) + }) + } else { + /* istanbul ignore next */ + return false + } + } catch (e) { + /* istanbul ignore next */ + return false + } + } else if (!isObjectA && !isObjectB) { + return String(a) === String(b) + } else { + return false + } + } + + /** + * Return the first index at which a loosely equal value can be + * found in the array (if value is a plain object, the array must + * contain an object of the same shape), or -1 if it is not present. + */ + function looseIndexOf (arr, val) { + for (var i = 0; i < arr.length; i++) { + if (looseEqual(arr[i], val)) { return i } + } + return -1 + } + + /** + * Ensure a function is called only once. + */ + function once (fn) { + var called = false; + return function () { + if (!called) { + called = true; + fn.apply(this, arguments); + } + } + } + + var SSR_ATTR = 'data-server-rendered'; + + var ASSET_TYPES = [ + 'component', + 'directive', + 'filter' + ]; + + var LIFECYCLE_HOOKS = [ + 'beforeCreate', + 'created', + 'beforeMount', + 'mounted', + 'beforeUpdate', + 'updated', + 'beforeDestroy', + 'destroyed', + 'activated', + 'deactivated', + 'errorCaptured', + 'serverPrefetch' + ]; + + /* */ + + + + var config = ({ + /** + * Option merge strategies (used in core/util/options) + */ + // $flow-disable-line + optionMergeStrategies: Object.create(null), + + /** + * Whether to suppress warnings. + */ + silent: false, + + /** + * Show production mode tip message on boot? + */ + productionTip: "development" !== 'production', + + /** + * Whether to enable devtools + */ + devtools: "development" !== 'production', + + /** + * Whether to record perf + */ + performance: false, + + /** + * Error handler for watcher errors + */ + errorHandler: null, + + /** + * Warn handler for watcher warns + */ + warnHandler: null, + + /** + * Ignore certain custom elements + */ + ignoredElements: [], + + /** + * Custom user key aliases for v-on + */ + // $flow-disable-line + keyCodes: Object.create(null), + + /** + * Check if a tag is reserved so that it cannot be registered as a + * component. This is platform-dependent and may be overwritten. + */ + isReservedTag: no, + + /** + * Check if an attribute is reserved so that it cannot be used as a component + * prop. This is platform-dependent and may be overwritten. + */ + isReservedAttr: no, + + /** + * Check if a tag is an unknown element. + * Platform-dependent. + */ + isUnknownElement: no, + + /** + * Get the namespace of an element + */ + getTagNamespace: noop, + + /** + * Parse the real tag name for the specific platform. + */ + parsePlatformTagName: identity, + + /** + * Check if an attribute must be bound using property, e.g. value + * Platform-dependent. + */ + mustUseProp: no, + + /** + * Perform updates asynchronously. Intended to be used by Vue Test Utils + * This will significantly reduce performance if set to false. + */ + async: true, + + /** + * Exposed for legacy reasons + */ + _lifecycleHooks: LIFECYCLE_HOOKS + }); + + /* */ + + /** + * unicode letters used for parsing html tags, component names and property paths. + * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname + * skipping \u10000-\uEFFFF due to it freezing up PhantomJS + */ + var unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/; + + /** + * Check if a string starts with $ or _ + */ + function isReserved (str) { + var c = (str + '').charCodeAt(0); + return c === 0x24 || c === 0x5F + } + + /** + * Define a property. + */ + function def (obj, key, val, enumerable) { + Object.defineProperty(obj, key, { + value: val, + enumerable: !!enumerable, + writable: true, + configurable: true + }); + } + + /** + * Parse simple path. + */ + var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]")); + function parsePath (path) { + if (bailRE.test(path)) { + return + } + var segments = path.split('.'); + return function (obj) { + for (var i = 0; i < segments.length; i++) { + if (!obj) { return } + obj = obj[segments[i]]; + } + return obj + } + } + + /* */ + + // can we use __proto__? + var hasProto = '__proto__' in {}; + + // Browser environment sniffing + var inBrowser = typeof window !== 'undefined'; + var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform; + var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase(); + var UA = inBrowser && window.navigator.userAgent.toLowerCase(); + var isIE = UA && /msie|trident/.test(UA); + var isIE9 = UA && UA.indexOf('msie 9.0') > 0; + var isEdge = UA && UA.indexOf('edge/') > 0; + var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android'); + var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios'); + var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; + var isPhantomJS = UA && /phantomjs/.test(UA); + var isFF = UA && UA.match(/firefox\/(\d+)/); + + // Firefox has a "watch" function on Object.prototype... + var nativeWatch = ({}).watch; + + var supportsPassive = false; + if (inBrowser) { + try { + var opts = {}; + Object.defineProperty(opts, 'passive', ({ + get: function get () { + /* istanbul ignore next */ + supportsPassive = true; + } + })); // https://github.com/facebook/flow/issues/285 + window.addEventListener('test-passive', null, opts); + } catch (e) {} + } + + // this needs to be lazy-evaled because vue may be required before + // vue-server-renderer can set VUE_ENV + var _isServer; + var isServerRendering = function () { + if (_isServer === undefined) { + /* istanbul ignore if */ + if (!inBrowser && !inWeex && typeof global !== 'undefined') { + // detect presence of vue-server-renderer and avoid + // Webpack shimming the process + _isServer = global['process'] && global['process'].env.VUE_ENV === 'server'; + } else { + _isServer = false; + } + } + return _isServer + }; + + // detect devtools + var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__; + + /* istanbul ignore next */ + function isNative (Ctor) { + return typeof Ctor === 'function' && /native code/.test(Ctor.toString()) + } + + var hasSymbol = + typeof Symbol !== 'undefined' && isNative(Symbol) && + typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); + + var _Set; + /* istanbul ignore if */ // $flow-disable-line + if (typeof Set !== 'undefined' && isNative(Set)) { + // use native Set when available. + _Set = Set; + } else { + // a non-standard Set polyfill that only works with primitive keys. + _Set = /*@__PURE__*/(function () { + function Set () { + this.set = Object.create(null); + } + Set.prototype.has = function has (key) { + return this.set[key] === true + }; + Set.prototype.add = function add (key) { + this.set[key] = true; + }; + Set.prototype.clear = function clear () { + this.set = Object.create(null); + }; + + return Set; + }()); + } + + /* */ + + var warn = noop; + var tip = noop; + var generateComponentTrace = (noop); // work around flow check + var formatComponentName = (noop); + + { + var hasConsole = typeof console !== 'undefined'; + var classifyRE = /(?:^|[-_])(\w)/g; + var classify = function (str) { return str + .replace(classifyRE, function (c) { return c.toUpperCase(); }) + .replace(/[-_]/g, ''); }; + + warn = function (msg, vm) { + var trace = vm ? generateComponentTrace(vm) : ''; + + if (config.warnHandler) { + config.warnHandler.call(null, msg, vm, trace); + } else if (hasConsole && (!config.silent)) { + console.error(("[Vue warn]: " + msg + trace)); + } + }; + + tip = function (msg, vm) { + if (hasConsole && (!config.silent)) { + console.warn("[Vue tip]: " + msg + ( + vm ? generateComponentTrace(vm) : '' + )); + } + }; + + formatComponentName = function (vm, includeFile) { + if (vm.$root === vm) { + return '' + } + var options = typeof vm === 'function' && vm.cid != null + ? vm.options + : vm._isVue + ? vm.$options || vm.constructor.options + : vm; + var name = options.name || options._componentTag; + var file = options.__file; + if (!name && file) { + var match = file.match(/([^/\\]+)\.vue$/); + name = match && match[1]; + } + + return ( + (name ? ("<" + (classify(name)) + ">") : "") + + (file && includeFile !== false ? (" at " + file) : '') + ) + }; + + var repeat = function (str, n) { + var res = ''; + while (n) { + if (n % 2 === 1) { res += str; } + if (n > 1) { str += str; } + n >>= 1; + } + return res + }; + + generateComponentTrace = function (vm) { + if (vm._isVue && vm.$parent) { + var tree = []; + var currentRecursiveSequence = 0; + while (vm) { + if (tree.length > 0) { + var last = tree[tree.length - 1]; + if (last.constructor === vm.constructor) { + currentRecursiveSequence++; + vm = vm.$parent; + continue + } else if (currentRecursiveSequence > 0) { + tree[tree.length - 1] = [last, currentRecursiveSequence]; + currentRecursiveSequence = 0; + } + } + tree.push(vm); + vm = vm.$parent; + } + return '\n\nfound in\n\n' + tree + .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm) + ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)") + : formatComponentName(vm))); }) + .join('\n') + } else { + return ("\n\n(found in " + (formatComponentName(vm)) + ")") + } + }; + } + + /* */ + + var uid = 0; + + /** + * A dep is an observable that can have multiple + * directives subscribing to it. + */ + var Dep = function Dep () { + this.id = uid++; + this.subs = []; + }; + + Dep.prototype.addSub = function addSub (sub) { + this.subs.push(sub); + }; + + Dep.prototype.removeSub = function removeSub (sub) { + remove(this.subs, sub); + }; + + Dep.prototype.depend = function depend () { + if (Dep.target) { + Dep.target.addDep(this); + } + }; + + Dep.prototype.notify = function notify () { + // stabilize the subscriber list first + var subs = this.subs.slice(); + if (!config.async) { + // subs aren't sorted in scheduler if not running async + // we need to sort them now to make sure they fire in correct + // order + subs.sort(function (a, b) { return a.id - b.id; }); + } + for (var i = 0, l = subs.length; i < l; i++) { + subs[i].update(); + } + }; + + // The current target watcher being evaluated. + // This is globally unique because only one watcher + // can be evaluated at a time. + Dep.target = null; + var targetStack = []; + + function pushTarget (target) { + targetStack.push(target); + Dep.target = target; + } + + function popTarget () { + targetStack.pop(); + Dep.target = targetStack[targetStack.length - 1]; + } + + /* */ + + var VNode = function VNode ( + tag, + data, + children, + text, + elm, + context, + componentOptions, + asyncFactory + ) { + this.tag = tag; + this.data = data; + this.children = children; + this.text = text; + this.elm = elm; + this.ns = undefined; + this.context = context; + this.fnContext = undefined; + this.fnOptions = undefined; + this.fnScopeId = undefined; + this.key = data && data.key; + this.componentOptions = componentOptions; + this.componentInstance = undefined; + this.parent = undefined; + this.raw = false; + this.isStatic = false; + this.isRootInsert = true; + this.isComment = false; + this.isCloned = false; + this.isOnce = false; + this.asyncFactory = asyncFactory; + this.asyncMeta = undefined; + this.isAsyncPlaceholder = false; + }; + + var prototypeAccessors = { child: { configurable: true } }; + + // DEPRECATED: alias for componentInstance for backwards compat. + /* istanbul ignore next */ + prototypeAccessors.child.get = function () { + return this.componentInstance + }; + + Object.defineProperties( VNode.prototype, prototypeAccessors ); + + var createEmptyVNode = function (text) { + if ( text === void 0 ) text = ''; + + var node = new VNode(); + node.text = text; + node.isComment = true; + return node + }; + + function createTextVNode (val) { + return new VNode(undefined, undefined, undefined, String(val)) + } + + // optimized shallow clone + // used for static nodes and slot nodes because they may be reused across + // multiple renders, cloning them avoids errors when DOM manipulations rely + // on their elm reference. + function cloneVNode (vnode) { + var cloned = new VNode( + vnode.tag, + vnode.data, + // #7975 + // clone children array to avoid mutating original in case of cloning + // a child. + vnode.children && vnode.children.slice(), + vnode.text, + vnode.elm, + vnode.context, + vnode.componentOptions, + vnode.asyncFactory + ); + cloned.ns = vnode.ns; + cloned.isStatic = vnode.isStatic; + cloned.key = vnode.key; + cloned.isComment = vnode.isComment; + cloned.fnContext = vnode.fnContext; + cloned.fnOptions = vnode.fnOptions; + cloned.fnScopeId = vnode.fnScopeId; + cloned.asyncMeta = vnode.asyncMeta; + cloned.isCloned = true; + return cloned + } + + /* + * not type checking this file because flow doesn't play well with + * dynamically accessing methods on Array prototype + */ + + var arrayProto = Array.prototype; + var arrayMethods = Object.create(arrayProto); + + var methodsToPatch = [ + 'push', + 'pop', + 'shift', + 'unshift', + 'splice', + 'sort', + 'reverse' + ]; + + /** + * Intercept mutating methods and emit events + */ + methodsToPatch.forEach(function (method) { + // cache original method + var original = arrayProto[method]; + def(arrayMethods, method, function mutator () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + var result = original.apply(this, args); + var ob = this.__ob__; + var inserted; + switch (method) { + case 'push': + case 'unshift': + inserted = args; + break + case 'splice': + inserted = args.slice(2); + break + } + if (inserted) { ob.observeArray(inserted); } + // notify change + ob.dep.notify(); + return result + }); + }); + + /* */ + + var arrayKeys = Object.getOwnPropertyNames(arrayMethods); + + /** + * In some cases we may want to disable observation inside a component's + * update computation. + */ + var shouldObserve = true; + + function toggleObserving (value) { + shouldObserve = value; + } + + /** + * Observer class that is attached to each observed + * object. Once attached, the observer converts the target + * object's property keys into getter/setters that + * collect dependencies and dispatch updates. + */ + var Observer = function Observer (value) { + this.value = value; + this.dep = new Dep(); + this.vmCount = 0; + def(value, '__ob__', this); + if (Array.isArray(value)) { + if (hasProto) { + protoAugment(value, arrayMethods); + } else { + copyAugment(value, arrayMethods, arrayKeys); + } + this.observeArray(value); + } else { + this.walk(value); + } + }; + + /** + * Walk through all properties and convert them into + * getter/setters. This method should only be called when + * value type is Object. + */ + Observer.prototype.walk = function walk (obj) { + var keys = Object.keys(obj); + for (var i = 0; i < keys.length; i++) { + defineReactive$$1(obj, keys[i]); + } + }; + + /** + * Observe a list of Array items. + */ + Observer.prototype.observeArray = function observeArray (items) { + for (var i = 0, l = items.length; i < l; i++) { + observe(items[i]); + } + }; + + // helpers + + /** + * Augment a target Object or Array by intercepting + * the prototype chain using __proto__ + */ + function protoAugment (target, src) { + /* eslint-disable no-proto */ + target.__proto__ = src; + /* eslint-enable no-proto */ + } + + /** + * Augment a target Object or Array by defining + * hidden properties. + */ + /* istanbul ignore next */ + function copyAugment (target, src, keys) { + for (var i = 0, l = keys.length; i < l; i++) { + var key = keys[i]; + def(target, key, src[key]); + } + } + + /** + * Attempt to create an observer instance for a value, + * returns the new observer if successfully observed, + * or the existing observer if the value already has one. + */ + function observe (value, asRootData) { + if (!isObject(value) || value instanceof VNode) { + return + } + var ob; + if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { + ob = value.__ob__; + } else if ( + shouldObserve && + !isServerRendering() && + (Array.isArray(value) || isPlainObject(value)) && + Object.isExtensible(value) && + !value._isVue + ) { + ob = new Observer(value); + } + if (asRootData && ob) { + ob.vmCount++; + } + return ob + } + + /** + * Define a reactive property on an Object. + */ + function defineReactive$$1 ( + obj, + key, + val, + customSetter, + shallow + ) { + var dep = new Dep(); + + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property && property.configurable === false) { + return + } + + // cater for pre-defined getter/setters + var getter = property && property.get; + var setter = property && property.set; + if ((!getter || setter) && arguments.length === 2) { + val = obj[key]; + } + + var childOb = !shallow && observe(val); + Object.defineProperty(obj, key, { + enumerable: true, + configurable: true, + get: function reactiveGetter () { + var value = getter ? getter.call(obj) : val; + if (Dep.target) { + dep.depend(); + if (childOb) { + childOb.dep.depend(); + if (Array.isArray(value)) { + dependArray(value); + } + } + } + return value + }, + set: function reactiveSetter (newVal) { + var value = getter ? getter.call(obj) : val; + /* eslint-disable no-self-compare */ + if (newVal === value || (newVal !== newVal && value !== value)) { + return + } + /* eslint-enable no-self-compare */ + if (customSetter) { + customSetter(); + } + // #7981: for accessor properties without setter + if (getter && !setter) { return } + if (setter) { + setter.call(obj, newVal); + } else { + val = newVal; + } + childOb = !shallow && observe(newVal); + dep.notify(); + } + }); + } + + /** + * Set a property on an object. Adds the new property and + * triggers change notification if the property doesn't + * already exist. + */ + function set (target, key, val) { + if (isUndef(target) || isPrimitive(target) + ) { + warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target)))); + } + if (Array.isArray(target) && isValidArrayIndex(key)) { + target.length = Math.max(target.length, key); + target.splice(key, 1, val); + return val + } + if (key in target && !(key in Object.prototype)) { + target[key] = val; + return val + } + var ob = (target).__ob__; + if (target._isVue || (ob && ob.vmCount)) { + warn( + 'Avoid adding reactive properties to a Vue instance or its root $data ' + + 'at runtime - declare it upfront in the data option.' + ); + return val + } + if (!ob) { + target[key] = val; + return val + } + defineReactive$$1(ob.value, key, val); + ob.dep.notify(); + return val + } + + /** + * Delete a property and trigger change if necessary. + */ + function del (target, key) { + if (isUndef(target) || isPrimitive(target) + ) { + warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target)))); + } + if (Array.isArray(target) && isValidArrayIndex(key)) { + target.splice(key, 1); + return + } + var ob = (target).__ob__; + if (target._isVue || (ob && ob.vmCount)) { + warn( + 'Avoid deleting properties on a Vue instance or its root $data ' + + '- just set it to null.' + ); + return + } + if (!hasOwn(target, key)) { + return + } + delete target[key]; + if (!ob) { + return + } + ob.dep.notify(); + } + + /** + * Collect dependencies on array elements when the array is touched, since + * we cannot intercept array element access like property getters. + */ + function dependArray (value) { + for (var e = (void 0), i = 0, l = value.length; i < l; i++) { + e = value[i]; + e && e.__ob__ && e.__ob__.dep.depend(); + if (Array.isArray(e)) { + dependArray(e); + } + } + } + + /* */ + + /** + * Option overwriting strategies are functions that handle + * how to merge a parent option value and a child option + * value into the final value. + */ + var strats = config.optionMergeStrategies; + + /** + * Options with restrictions + */ + { + strats.el = strats.propsData = function (parent, child, vm, key) { + if (!vm) { + warn( + "option \"" + key + "\" can only be used during instance " + + 'creation with the `new` keyword.' + ); + } + return defaultStrat(parent, child) + }; + } + + /** + * Helper that recursively merges two data objects together. + */ + function mergeData (to, from) { + if (!from) { return to } + var key, toVal, fromVal; + + var keys = hasSymbol + ? Reflect.ownKeys(from) + : Object.keys(from); + + for (var i = 0; i < keys.length; i++) { + key = keys[i]; + // in case the object is already observed... + if (key === '__ob__') { continue } + toVal = to[key]; + fromVal = from[key]; + if (!hasOwn(to, key)) { + set(to, key, fromVal); + } else if ( + toVal !== fromVal && + isPlainObject(toVal) && + isPlainObject(fromVal) + ) { + mergeData(toVal, fromVal); + } + } + return to + } + + /** + * Data + */ + function mergeDataOrFn ( + parentVal, + childVal, + vm + ) { + if (!vm) { + // in a Vue.extend merge, both should be functions + if (!childVal) { + return parentVal + } + if (!parentVal) { + return childVal + } + // when parentVal & childVal are both present, + // we need to return a function that returns the + // merged result of both functions... no need to + // check if parentVal is a function here because + // it has to be a function to pass previous merges. + return function mergedDataFn () { + return mergeData( + typeof childVal === 'function' ? childVal.call(this, this) : childVal, + typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal + ) + } + } else { + return function mergedInstanceDataFn () { + // instance merge + var instanceData = typeof childVal === 'function' + ? childVal.call(vm, vm) + : childVal; + var defaultData = typeof parentVal === 'function' + ? parentVal.call(vm, vm) + : parentVal; + if (instanceData) { + return mergeData(instanceData, defaultData) + } else { + return defaultData + } + } + } + } + + strats.data = function ( + parentVal, + childVal, + vm + ) { + if (!vm) { + if (childVal && typeof childVal !== 'function') { + warn( + 'The "data" option should be a function ' + + 'that returns a per-instance value in component ' + + 'definitions.', + vm + ); + + return parentVal + } + return mergeDataOrFn(parentVal, childVal) + } + + return mergeDataOrFn(parentVal, childVal, vm) + }; + + /** + * Hooks and props are merged as arrays. + */ + function mergeHook ( + parentVal, + childVal + ) { + var res = childVal + ? parentVal + ? parentVal.concat(childVal) + : Array.isArray(childVal) + ? childVal + : [childVal] + : parentVal; + return res + ? dedupeHooks(res) + : res + } + + function dedupeHooks (hooks) { + var res = []; + for (var i = 0; i < hooks.length; i++) { + if (res.indexOf(hooks[i]) === -1) { + res.push(hooks[i]); + } + } + return res + } + + LIFECYCLE_HOOKS.forEach(function (hook) { + strats[hook] = mergeHook; + }); + + /** + * Assets + * + * When a vm is present (instance creation), we need to do + * a three-way merge between constructor options, instance + * options and parent options. + */ + function mergeAssets ( + parentVal, + childVal, + vm, + key + ) { + var res = Object.create(parentVal || null); + if (childVal) { + assertObjectType(key, childVal, vm); + return extend(res, childVal) + } else { + return res + } + } + + ASSET_TYPES.forEach(function (type) { + strats[type + 's'] = mergeAssets; + }); + + /** + * Watchers. + * + * Watchers hashes should not overwrite one + * another, so we merge them as arrays. + */ + strats.watch = function ( + parentVal, + childVal, + vm, + key + ) { + // work around Firefox's Object.prototype.watch... + if (parentVal === nativeWatch) { parentVal = undefined; } + if (childVal === nativeWatch) { childVal = undefined; } + /* istanbul ignore if */ + if (!childVal) { return Object.create(parentVal || null) } + { + assertObjectType(key, childVal, vm); + } + if (!parentVal) { return childVal } + var ret = {}; + extend(ret, parentVal); + for (var key$1 in childVal) { + var parent = ret[key$1]; + var child = childVal[key$1]; + if (parent && !Array.isArray(parent)) { + parent = [parent]; + } + ret[key$1] = parent + ? parent.concat(child) + : Array.isArray(child) ? child : [child]; + } + return ret + }; + + /** + * Other object hashes. + */ + strats.props = + strats.methods = + strats.inject = + strats.computed = function ( + parentVal, + childVal, + vm, + key + ) { + if (childVal && "development" !== 'production') { + assertObjectType(key, childVal, vm); + } + if (!parentVal) { return childVal } + var ret = Object.create(null); + extend(ret, parentVal); + if (childVal) { extend(ret, childVal); } + return ret + }; + strats.provide = mergeDataOrFn; + + /** + * Default strategy. + */ + var defaultStrat = function (parentVal, childVal) { + return childVal === undefined + ? parentVal + : childVal + }; + + /** + * Validate component names + */ + function checkComponents (options) { + for (var key in options.components) { + validateComponentName(key); + } + } + + function validateComponentName (name) { + if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) { + warn( + 'Invalid component name: "' + name + '". Component names ' + + 'should conform to valid custom element name in html5 specification.' + ); + } + if (isBuiltInTag(name) || config.isReservedTag(name)) { + warn( + 'Do not use built-in or reserved HTML elements as component ' + + 'id: ' + name + ); + } + } + + /** + * Ensure all props option syntax are normalized into the + * Object-based format. + */ + function normalizeProps (options, vm) { + var props = options.props; + if (!props) { return } + var res = {}; + var i, val, name; + if (Array.isArray(props)) { + i = props.length; + while (i--) { + val = props[i]; + if (typeof val === 'string') { + name = camelize(val); + res[name] = { type: null }; + } else { + warn('props must be strings when using array syntax.'); + } + } + } else if (isPlainObject(props)) { + for (var key in props) { + val = props[key]; + name = camelize(key); + res[name] = isPlainObject(val) + ? val + : { type: val }; + } + } else { + warn( + "Invalid value for option \"props\": expected an Array or an Object, " + + "but got " + (toRawType(props)) + ".", + vm + ); + } + options.props = res; + } + + /** + * Normalize all injections into Object-based format + */ + function normalizeInject (options, vm) { + var inject = options.inject; + if (!inject) { return } + var normalized = options.inject = {}; + if (Array.isArray(inject)) { + for (var i = 0; i < inject.length; i++) { + normalized[inject[i]] = { from: inject[i] }; + } + } else if (isPlainObject(inject)) { + for (var key in inject) { + var val = inject[key]; + normalized[key] = isPlainObject(val) + ? extend({ from: key }, val) + : { from: val }; + } + } else { + warn( + "Invalid value for option \"inject\": expected an Array or an Object, " + + "but got " + (toRawType(inject)) + ".", + vm + ); + } + } + + /** + * Normalize raw function directives into object format. + */ + function normalizeDirectives (options) { + var dirs = options.directives; + if (dirs) { + for (var key in dirs) { + var def$$1 = dirs[key]; + if (typeof def$$1 === 'function') { + dirs[key] = { bind: def$$1, update: def$$1 }; + } + } + } + } + + function assertObjectType (name, value, vm) { + if (!isPlainObject(value)) { + warn( + "Invalid value for option \"" + name + "\": expected an Object, " + + "but got " + (toRawType(value)) + ".", + vm + ); + } + } + + /** + * Merge two option objects into a new one. + * Core utility used in both instantiation and inheritance. + */ + function mergeOptions ( + parent, + child, + vm + ) { + { + checkComponents(child); + } + + if (typeof child === 'function') { + child = child.options; + } + + normalizeProps(child, vm); + normalizeInject(child, vm); + normalizeDirectives(child); + + // Apply extends and mixins on the child options, + // but only if it is a raw options object that isn't + // the result of another mergeOptions call. + // Only merged options has the _base property. + if (!child._base) { + if (child.extends) { + parent = mergeOptions(parent, child.extends, vm); + } + if (child.mixins) { + for (var i = 0, l = child.mixins.length; i < l; i++) { + parent = mergeOptions(parent, child.mixins[i], vm); + } + } + } + + var options = {}; + var key; + for (key in parent) { + mergeField(key); + } + for (key in child) { + if (!hasOwn(parent, key)) { + mergeField(key); + } + } + function mergeField (key) { + var strat = strats[key] || defaultStrat; + options[key] = strat(parent[key], child[key], vm, key); + } + return options + } + + /** + * Resolve an asset. + * This function is used because child instances need access + * to assets defined in its ancestor chain. + */ + function resolveAsset ( + options, + type, + id, + warnMissing + ) { + /* istanbul ignore if */ + if (typeof id !== 'string') { + return + } + var assets = options[type]; + // check local registration variations first + if (hasOwn(assets, id)) { return assets[id] } + var camelizedId = camelize(id); + if (hasOwn(assets, camelizedId)) { return assets[camelizedId] } + var PascalCaseId = capitalize(camelizedId); + if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] } + // fallback to prototype chain + var res = assets[id] || assets[camelizedId] || assets[PascalCaseId]; + if (warnMissing && !res) { + warn( + 'Failed to resolve ' + type.slice(0, -1) + ': ' + id, + options + ); + } + return res + } + + /* */ + + + + function validateProp ( + key, + propOptions, + propsData, + vm + ) { + var prop = propOptions[key]; + var absent = !hasOwn(propsData, key); + var value = propsData[key]; + // boolean casting + var booleanIndex = getTypeIndex(Boolean, prop.type); + if (booleanIndex > -1) { + if (absent && !hasOwn(prop, 'default')) { + value = false; + } else if (value === '' || value === hyphenate(key)) { + // only cast empty string / same name to boolean if + // boolean has higher priority + var stringIndex = getTypeIndex(String, prop.type); + if (stringIndex < 0 || booleanIndex < stringIndex) { + value = true; + } + } + } + // check default value + if (value === undefined) { + value = getPropDefaultValue(vm, prop, key); + // since the default value is a fresh copy, + // make sure to observe it. + var prevShouldObserve = shouldObserve; + toggleObserving(true); + observe(value); + toggleObserving(prevShouldObserve); + } + { + assertProp(prop, key, value, vm, absent); + } + return value + } + + /** + * Get the default value of a prop. + */ + function getPropDefaultValue (vm, prop, key) { + // no default, return undefined + if (!hasOwn(prop, 'default')) { + return undefined + } + var def = prop.default; + // warn against non-factory defaults for Object & Array + if (isObject(def)) { + warn( + 'Invalid default value for prop "' + key + '": ' + + 'Props with type Object/Array must use a factory function ' + + 'to return the default value.', + vm + ); + } + // the raw prop value was also undefined from previous render, + // return previous default value to avoid unnecessary watcher trigger + if (vm && vm.$options.propsData && + vm.$options.propsData[key] === undefined && + vm._props[key] !== undefined + ) { + return vm._props[key] + } + // call factory function for non-Function types + // a value is Function if its prototype is function even across different execution context + return typeof def === 'function' && getType(prop.type) !== 'Function' + ? def.call(vm) + : def + } + + /** + * Assert whether a prop is valid. + */ + function assertProp ( + prop, + name, + value, + vm, + absent + ) { + if (prop.required && absent) { + warn( + 'Missing required prop: "' + name + '"', + vm + ); + return + } + if (value == null && !prop.required) { + return + } + var type = prop.type; + var valid = !type || type === true; + var expectedTypes = []; + if (type) { + if (!Array.isArray(type)) { + type = [type]; + } + for (var i = 0; i < type.length && !valid; i++) { + var assertedType = assertType(value, type[i]); + expectedTypes.push(assertedType.expectedType || ''); + valid = assertedType.valid; + } + } + + if (!valid) { + warn( + getInvalidTypeMessage(name, value, expectedTypes), + vm + ); + return + } + var validator = prop.validator; + if (validator) { + if (!validator(value)) { + warn( + 'Invalid prop: custom validator check failed for prop "' + name + '".', + vm + ); + } + } + } + + var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/; + + function assertType (value, type) { + var valid; + var expectedType = getType(type); + if (simpleCheckRE.test(expectedType)) { + var t = typeof value; + valid = t === expectedType.toLowerCase(); + // for primitive wrapper objects + if (!valid && t === 'object') { + valid = value instanceof type; + } + } else if (expectedType === 'Object') { + valid = isPlainObject(value); + } else if (expectedType === 'Array') { + valid = Array.isArray(value); + } else { + valid = value instanceof type; + } + return { + valid: valid, + expectedType: expectedType + } + } + + /** + * Use function string name to check built-in types, + * because a simple equality check will fail when running + * across different vms / iframes. + */ + function getType (fn) { + var match = fn && fn.toString().match(/^\s*function (\w+)/); + return match ? match[1] : '' + } + + function isSameType (a, b) { + return getType(a) === getType(b) + } + + function getTypeIndex (type, expectedTypes) { + if (!Array.isArray(expectedTypes)) { + return isSameType(expectedTypes, type) ? 0 : -1 + } + for (var i = 0, len = expectedTypes.length; i < len; i++) { + if (isSameType(expectedTypes[i], type)) { + return i + } + } + return -1 + } + + function getInvalidTypeMessage (name, value, expectedTypes) { + var message = "Invalid prop: type check failed for prop \"" + name + "\"." + + " Expected " + (expectedTypes.map(capitalize).join(', ')); + var expectedType = expectedTypes[0]; + var receivedType = toRawType(value); + var expectedValue = styleValue(value, expectedType); + var receivedValue = styleValue(value, receivedType); + // check if we need to specify expected value + if (expectedTypes.length === 1 && + isExplicable(expectedType) && + !isBoolean(expectedType, receivedType)) { + message += " with value " + expectedValue; + } + message += ", got " + receivedType + " "; + // check if we need to specify received value + if (isExplicable(receivedType)) { + message += "with value " + receivedValue + "."; + } + return message + } + + function styleValue (value, type) { + if (type === 'String') { + return ("\"" + value + "\"") + } else if (type === 'Number') { + return ("" + (Number(value))) + } else { + return ("" + value) + } + } + + function isExplicable (value) { + var explicitTypes = ['string', 'number', 'boolean']; + return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; }) + } + + function isBoolean () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; }) + } + + /* */ + + function handleError (err, vm, info) { + // Deactivate deps tracking while processing error handler to avoid possible infinite rendering. + // See: https://github.com/vuejs/vuex/issues/1505 + pushTarget(); + try { + if (vm) { + var cur = vm; + while ((cur = cur.$parent)) { + var hooks = cur.$options.errorCaptured; + if (hooks) { + for (var i = 0; i < hooks.length; i++) { + try { + var capture = hooks[i].call(cur, err, vm, info) === false; + if (capture) { return } + } catch (e) { + globalHandleError(e, cur, 'errorCaptured hook'); + } + } + } + } + } + globalHandleError(err, vm, info); + } finally { + popTarget(); + } + } + + function invokeWithErrorHandling ( + handler, + context, + args, + vm, + info + ) { + var res; + try { + res = args ? handler.apply(context, args) : handler.call(context); + if (res && !res._isVue && isPromise(res) && !res._handled) { + res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); }); + // issue #9511 + // avoid catch triggering multiple times when nested calls + res._handled = true; + } + } catch (e) { + handleError(e, vm, info); + } + return res + } + + function globalHandleError (err, vm, info) { + if (config.errorHandler) { + try { + return config.errorHandler.call(null, err, vm, info) + } catch (e) { + // if the user intentionally throws the original error in the handler, + // do not log it twice + if (e !== err) { + logError(e, null, 'config.errorHandler'); + } + } + } + logError(err, vm, info); + } + + function logError (err, vm, info) { + { + warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm); + } + /* istanbul ignore else */ + if ((inBrowser || inWeex) && typeof console !== 'undefined') { + console.error(err); + } else { + throw err + } + } + + /* */ + + var isUsingMicroTask = false; + + var callbacks = []; + var pending = false; + + function flushCallbacks () { + pending = false; + var copies = callbacks.slice(0); + callbacks.length = 0; + for (var i = 0; i < copies.length; i++) { + copies[i](); + } + } + + // Here we have async deferring wrappers using microtasks. + // In 2.5 we used (macro) tasks (in combination with microtasks). + // However, it has subtle problems when state is changed right before repaint + // (e.g. #6813, out-in transitions). + // Also, using (macro) tasks in event handler would cause some weird behaviors + // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109). + // So we now use microtasks everywhere, again. + // A major drawback of this tradeoff is that there are some scenarios + // where microtasks have too high a priority and fire in between supposedly + // sequential events (e.g. #4521, #6690, which have workarounds) + // or even between bubbling of the same event (#6566). + var timerFunc; + + // The nextTick behavior leverages the microtask queue, which can be accessed + // via either native Promise.then or MutationObserver. + // MutationObserver has wider support, however it is seriously bugged in + // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It + // completely stops working after triggering a few times... so, if native + // Promise is available, we will use it: + /* istanbul ignore next, $flow-disable-line */ + if (typeof Promise !== 'undefined' && isNative(Promise)) { + var p = Promise.resolve(); + timerFunc = function () { + p.then(flushCallbacks); + // In problematic UIWebViews, Promise.then doesn't completely break, but + // it can get stuck in a weird state where callbacks are pushed into the + // microtask queue but the queue isn't being flushed, until the browser + // needs to do some other work, e.g. handle a timer. Therefore we can + // "force" the microtask queue to be flushed by adding an empty timer. + if (isIOS) { setTimeout(noop); } + }; + isUsingMicroTask = true; + } else if (!isIE && typeof MutationObserver !== 'undefined' && ( + isNative(MutationObserver) || + // PhantomJS and iOS 7.x + MutationObserver.toString() === '[object MutationObserverConstructor]' + )) { + // Use MutationObserver where native Promise is not available, + // e.g. PhantomJS, iOS7, Android 4.4 + // (#6466 MutationObserver is unreliable in IE11) + var counter = 1; + var observer = new MutationObserver(flushCallbacks); + var textNode = document.createTextNode(String(counter)); + observer.observe(textNode, { + characterData: true + }); + timerFunc = function () { + counter = (counter + 1) % 2; + textNode.data = String(counter); + }; + isUsingMicroTask = true; + } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) { + // Fallback to setImmediate. + // Technically it leverages the (macro) task queue, + // but it is still a better choice than setTimeout. + timerFunc = function () { + setImmediate(flushCallbacks); + }; + } else { + // Fallback to setTimeout. + timerFunc = function () { + setTimeout(flushCallbacks, 0); + }; + } + + function nextTick (cb, ctx) { + var _resolve; + callbacks.push(function () { + if (cb) { + try { + cb.call(ctx); + } catch (e) { + handleError(e, ctx, 'nextTick'); + } + } else if (_resolve) { + _resolve(ctx); + } + }); + if (!pending) { + pending = true; + timerFunc(); + } + // $flow-disable-line + if (!cb && typeof Promise !== 'undefined') { + return new Promise(function (resolve) { + _resolve = resolve; + }) + } + } + + /* */ + + var mark; + var measure; + + { + var perf = inBrowser && window.performance; + /* istanbul ignore if */ + if ( + perf && + perf.mark && + perf.measure && + perf.clearMarks && + perf.clearMeasures + ) { + mark = function (tag) { return perf.mark(tag); }; + measure = function (name, startTag, endTag) { + perf.measure(name, startTag, endTag); + perf.clearMarks(startTag); + perf.clearMarks(endTag); + // perf.clearMeasures(name) + }; + } + } + + /* not type checking this file because flow doesn't play well with Proxy */ + + var initProxy; + + { + var allowedGlobals = makeMap( + 'Infinity,undefined,NaN,isFinite,isNaN,' + + 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + + 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + + 'require' // for Webpack/Browserify + ); + + var warnNonPresent = function (target, key) { + warn( + "Property or method \"" + key + "\" is not defined on the instance but " + + 'referenced during render. Make sure that this property is reactive, ' + + 'either in the data option, or for class-based components, by ' + + 'initializing the property. ' + + 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', + target + ); + }; + + var warnReservedPrefix = function (target, key) { + warn( + "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " + + 'properties starting with "$" or "_" are not proxied in the Vue instance to ' + + 'prevent conflicts with Vue internals. ' + + 'See: https://vuejs.org/v2/api/#data', + target + ); + }; + + var hasProxy = + typeof Proxy !== 'undefined' && isNative(Proxy); + + if (hasProxy) { + var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact'); + config.keyCodes = new Proxy(config.keyCodes, { + set: function set (target, key, value) { + if (isBuiltInModifier(key)) { + warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key)); + return false + } else { + target[key] = value; + return true + } + } + }); + } + + var hasHandler = { + has: function has (target, key) { + var has = key in target; + var isAllowed = allowedGlobals(key) || + (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data)); + if (!has && !isAllowed) { + if (key in target.$data) { warnReservedPrefix(target, key); } + else { warnNonPresent(target, key); } + } + return has || !isAllowed + } + }; + + var getHandler = { + get: function get (target, key) { + if (typeof key === 'string' && !(key in target)) { + if (key in target.$data) { warnReservedPrefix(target, key); } + else { warnNonPresent(target, key); } + } + return target[key] + } + }; + + initProxy = function initProxy (vm) { + if (hasProxy) { + // determine which proxy handler to use + var options = vm.$options; + var handlers = options.render && options.render._withStripped + ? getHandler + : hasHandler; + vm._renderProxy = new Proxy(vm, handlers); + } else { + vm._renderProxy = vm; + } + }; + } + + /* */ + + var seenObjects = new _Set(); + + /** + * Recursively traverse an object to evoke all converted + * getters, so that every nested property inside the object + * is collected as a "deep" dependency. + */ + function traverse (val) { + _traverse(val, seenObjects); + seenObjects.clear(); + } + + function _traverse (val, seen) { + var i, keys; + var isA = Array.isArray(val); + if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) { + return + } + if (val.__ob__) { + var depId = val.__ob__.dep.id; + if (seen.has(depId)) { + return + } + seen.add(depId); + } + if (isA) { + i = val.length; + while (i--) { _traverse(val[i], seen); } + } else { + keys = Object.keys(val); + i = keys.length; + while (i--) { _traverse(val[keys[i]], seen); } + } + } + + /* */ + + var normalizeEvent = cached(function (name) { + var passive = name.charAt(0) === '&'; + name = passive ? name.slice(1) : name; + var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first + name = once$$1 ? name.slice(1) : name; + var capture = name.charAt(0) === '!'; + name = capture ? name.slice(1) : name; + return { + name: name, + once: once$$1, + capture: capture, + passive: passive + } + }); + + function createFnInvoker (fns, vm) { + function invoker () { + var arguments$1 = arguments; + + var fns = invoker.fns; + if (Array.isArray(fns)) { + var cloned = fns.slice(); + for (var i = 0; i < cloned.length; i++) { + invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler"); + } + } else { + // return handler return value for single handlers + return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler") + } + } + invoker.fns = fns; + return invoker + } + + function updateListeners ( + on, + oldOn, + add, + remove$$1, + createOnceHandler, + vm + ) { + var name, def$$1, cur, old, event; + for (name in on) { + def$$1 = cur = on[name]; + old = oldOn[name]; + event = normalizeEvent(name); + if (isUndef(cur)) { + warn( + "Invalid handler for event \"" + (event.name) + "\": got " + String(cur), + vm + ); + } else if (isUndef(old)) { + if (isUndef(cur.fns)) { + cur = on[name] = createFnInvoker(cur, vm); + } + if (isTrue(event.once)) { + cur = on[name] = createOnceHandler(event.name, cur, event.capture); + } + add(event.name, cur, event.capture, event.passive, event.params); + } else if (cur !== old) { + old.fns = cur; + on[name] = old; + } + } + for (name in oldOn) { + if (isUndef(on[name])) { + event = normalizeEvent(name); + remove$$1(event.name, oldOn[name], event.capture); + } + } + } + + /* */ + + function mergeVNodeHook (def, hookKey, hook) { + if (def instanceof VNode) { + def = def.data.hook || (def.data.hook = {}); + } + var invoker; + var oldHook = def[hookKey]; + + function wrappedHook () { + hook.apply(this, arguments); + // important: remove merged hook to ensure it's called only once + // and prevent memory leak + remove(invoker.fns, wrappedHook); + } + + if (isUndef(oldHook)) { + // no existing hook + invoker = createFnInvoker([wrappedHook]); + } else { + /* istanbul ignore if */ + if (isDef(oldHook.fns) && isTrue(oldHook.merged)) { + // already a merged invoker + invoker = oldHook; + invoker.fns.push(wrappedHook); + } else { + // existing plain hook + invoker = createFnInvoker([oldHook, wrappedHook]); + } + } + + invoker.merged = true; + def[hookKey] = invoker; + } + + /* */ + + function extractPropsFromVNodeData ( + data, + Ctor, + tag + ) { + // we are only extracting raw values here. + // validation and default values are handled in the child + // component itself. + var propOptions = Ctor.options.props; + if (isUndef(propOptions)) { + return + } + var res = {}; + var attrs = data.attrs; + var props = data.props; + if (isDef(attrs) || isDef(props)) { + for (var key in propOptions) { + var altKey = hyphenate(key); + { + var keyInLowerCase = key.toLowerCase(); + if ( + key !== keyInLowerCase && + attrs && hasOwn(attrs, keyInLowerCase) + ) { + tip( + "Prop \"" + keyInLowerCase + "\" is passed to component " + + (formatComponentName(tag || Ctor)) + ", but the declared prop name is" + + " \"" + key + "\". " + + "Note that HTML attributes are case-insensitive and camelCased " + + "props need to use their kebab-case equivalents when using in-DOM " + + "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"." + ); + } + } + checkProp(res, props, key, altKey, true) || + checkProp(res, attrs, key, altKey, false); + } + } + return res + } + + function checkProp ( + res, + hash, + key, + altKey, + preserve + ) { + if (isDef(hash)) { + if (hasOwn(hash, key)) { + res[key] = hash[key]; + if (!preserve) { + delete hash[key]; + } + return true + } else if (hasOwn(hash, altKey)) { + res[key] = hash[altKey]; + if (!preserve) { + delete hash[altKey]; + } + return true + } + } + return false + } + + /* */ + + // The template compiler attempts to minimize the need for normalization by + // statically analyzing the template at compile time. + // + // For plain HTML markup, normalization can be completely skipped because the + // generated render function is guaranteed to return Array. There are + // two cases where extra normalization is needed: + + // 1. When the children contains components - because a functional component + // may return an Array instead of a single root. In this case, just a simple + // normalization is needed - if any child is an Array, we flatten the whole + // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep + // because functional components already normalize their own children. + function simpleNormalizeChildren (children) { + for (var i = 0; i < children.length; i++) { + if (Array.isArray(children[i])) { + return Array.prototype.concat.apply([], children) + } + } + return children + } + + // 2. When the children contains constructs that always generated nested Arrays, + // e.g.