flow like the river

This commit is contained in:
root 2025-11-07 00:06:12 +01:00
commit 013fe673f3
42435 changed files with 5764238 additions and 0 deletions

21
VISUALIZACION/node_modules/parcel-bundler/LICENSE generated vendored Executable file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017-present Devon Govett
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

128
VISUALIZACION/node_modules/parcel-bundler/README.md generated vendored Executable file
View file

@ -0,0 +1,128 @@
<p align="center">
<a href="https://parceljs.org/" target="_blank">
<img alt="Parcel" src="https://user-images.githubusercontent.com/19409/31321658-f6aed0f2-ac3d-11e7-8100-1587e676e0ec.png" width="749">
</a>
</p>
[![Backers on Open Collective](https://opencollective.com/parcel/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/parcel/sponsors/badge.svg)](#sponsors)
[![Travis CI Build Status](https://travis-ci.org/parcel-bundler/parcel.svg?branch=master)](https://travis-ci.org/parcel-bundler/parcel)
[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/nr7d6qjxj3wwsw6n/branch/master?svg=true)](https://ci.appveyor.com/project/devongovett/parcel)
[![Coverage](https://img.shields.io/codecov/c/github/parcel-bundler/parcel/master.svg)](https://codecov.io/github/parcel-bundler/parcel/)
[![David Dependancy Status](https://david-dm.org/parcel-bundler/parcel.svg)](https://david-dm.org/parcel-bundler/parcel)
[![npm package](https://img.shields.io/npm/v/parcel-bundler.svg)](https://www.npmjs.com/package/parcel-bundler)
[![npm package](https://img.shields.io/npm/dm/parcel-bundler.svg)](https://www.npmjs.com/package/parcel-bundler)
[![Slack](https://slack.parceljs.org/badge.svg)](https://slack.parceljs.org)
[![Twitter Follow](https://img.shields.io/twitter/follow/parceljs.svg?style=social)](https://twitter.com/parceljs)
## Features
* 🚀 **Blazing fast** bundle times - multicore compilation, and a filesystem cache for fast rebuilds even after a restart.
* 📦 Out of the box support for JS, CSS, HTML, file assets, and more - **no plugins to install**.
* 🐠 **Automatically transforms modules** using Babel, PostCSS, and PostHTML when needed - even `node_modules`.
* ✂️ Zero configuration **code splitting** using dynamic `import()` statements.
* 🔥 Built in support for **hot module replacement**
* 🚨 Friendly error logging experience - syntax highlighted code frames help pinpoint the problem.
## Getting started
1. Install with yarn:
```shell
yarn global add parcel-bundler
```
or with npm:
```shell
npm install -g parcel-bundler
```
2. Parcel can take any type of file as an entry point, but an HTML or JavaScript file is a good place to start. If you link your main JavaScript file in the HTML using a relative path, Parcel will also process it for you, and replace the reference with a URL to the output file.
```html
<html>
<body>
<script src="./index.js"></script>
</body>
</html>
```
3. Parcel has a development server built in, which will automatically rebuild your app as you change files and supports hot module replacement for fast development. Just point it at your entry file:
```shell
parcel index.html
```
4. Now open http://localhost:1234/ in your browser. If needed, you can also override the default port with the `-p` option. Add `--open` to automatically open a browser.
See [parceljs.org](https://parceljs.org) for more documentation!
## Benchmarks
Based on a reasonably sized app, containing 1726 modules, 6.5M uncompressed. Built on a 2016 MacBook Pro with 4 physical CPUs.
| Bundler | Time |
| ----------------------- | --------- |
| browserify       | 22.98s |
| webpack           | 20.71s |
| **parcel** | **9.98s** |
| **parcel - with cache** | **2.64s** |
## Why parcel?
There are many web application bundlers out there with huge adoption, including webpack and browserify. So, why do we need another one? The main reasons are around developer experience.
Many bundlers are built around configuration and plugins, and it is not uncommon to see applications with upwards of 500 lines of configuration just to get things working. This configuration is not just tedious and time consuming, but is also hard to get right and must be duplicated for each application. Oftentimes, this can lead to sub-optimized apps shipping to production. `parcel` is designed to need zero configuration: just point it at the entry point of your application, and it does the right thing.
Existing bundlers are also very slow. Large applications with lots of files and many dependencies can take minutes to build, which is especially painful during development when things change all the time. File watchers can help with rebuilds, but the initial launch is often still very slow. `parcel` utilizes worker processes to compile your code in parallel, utilizing modern multicore processors. This results in a huge speedup for initial builds. It also has a file system cache, which saves the compiled results per file for even faster subsequent startups.
Finally, existing bundlers are built around string loaders/transforms, where the transform takes in a string, parses it, does some transformation, and generates code again. Oftentimes this ends up causing many parses and code generation runs on a single file, which is inefficient. Instead, `parcel`'s transforms work on ASTs so that there is one parse, many transforms, and one code generation per file.
## How it works
`parcel` transforms a tree of assets to a tree of bundles. Many other bundlers are fundamentally based around JavaScript assets, with other formats tacked on - for example, by default inlined as strings into JS files. `parcel` is file-type agnostic - it will work with any type of assets the way you'd expect, with no configuration.
`parcel` takes as input a single entry asset, which could be any file type: JS, HTML, CSS, image, etc. There are various asset types defined in `parcel` which know how to handle specific file types. The assets are parsed, their dependencies are extracted, and they are transformed to their final compiled form. This creates a tree of assets.
Once the asset tree has been constructed, the assets are placed into a bundle tree. A bundle is created for the entry asset, and child bundles are created for dynamic imports, which cause code splitting to occur. Child bundles are also created when assets of a different type are imported, for example if you imported a CSS file from JavaScript, it would be placed into a sibling bundle to the corresponding JavaScript. If an asset is required in more than one bundle, it is hoisted up to the nearest common ancestor in the bundle tree so it is not included more than once.
After the bundle tree is constructed, each bundle is written to a file by a packager specific to the file type. The packagers know how to combine the code from each asset together into the final file that is loaded by a browser.
## Community
All feedback and suggestions are welcome!
* 💬 Chat: Join us on [slack](https://slack.parceljs.org/).
* 📣 Stay up to date on new features and announcements on [@parceljs](https://twitter.com/parceljs).
## Contributors
This project exists thanks to all the people who contribute. [[Contribute]](CONTRIBUTING.md).
<a href="https://github.com/parcel-bundler/parcel/graphs/contributors"><img src="https://opencollective.com/parcel/contributors.svg?width=890" title="contributors" alt="contributors" /></a>
## Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/parcel#backer)]
<a href="https://opencollective.com/parcel#backers" target="_blank"><img src="https://opencollective.com/parcel/backers.svg?width=890"></a>
## Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/parcel#sponsor)]
<a href="https://opencollective.com/parcel/sponsor/0/website" target="_blank"><img src="https://opencollective.com/parcel/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/parcel/sponsor/1/website" target="_blank"><img src="https://opencollective.com/parcel/sponsor/1/avatar.svg"></a>
<a href="https://opencollective.com/parcel/sponsor/2/website" target="_blank"><img src="https://opencollective.com/parcel/sponsor/2/avatar.svg"></a>
<a href="https://opencollective.com/parcel/sponsor/3/website" target="_blank"><img src="https://opencollective.com/parcel/sponsor/3/avatar.svg"></a>
<a href="https://opencollective.com/parcel/sponsor/4/website" target="_blank"><img src="https://opencollective.com/parcel/sponsor/4/avatar.svg"></a>
<a href="https://opencollective.com/parcel/sponsor/5/website" target="_blank"><img src="https://opencollective.com/parcel/sponsor/5/avatar.svg"></a>
<a href="https://opencollective.com/parcel/sponsor/6/website" target="_blank"><img src="https://opencollective.com/parcel/sponsor/6/avatar.svg"></a>
<a href="https://opencollective.com/parcel/sponsor/7/website" target="_blank"><img src="https://opencollective.com/parcel/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/parcel/sponsor/8/website" target="_blank"><img src="https://opencollective.com/parcel/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/parcel/sponsor/9/website" target="_blank"><img src="https://opencollective.com/parcel/sponsor/9/avatar.svg"></a>
## [Changelog](https://github.com/parcel-bundler/parcel/blob/master/changelog.md)
## License
MIT

View file

@ -0,0 +1,6 @@
{
"extends": "../.eslintrc.json",
"rules": {
"no-console": 0
}
}

7
VISUALIZACION/node_modules/parcel-bundler/bin/cli.js generated vendored Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env node
// Node 8 supports native async functions - no need to use compiled code!
module.exports =
parseInt(process.versions.node, 10) < 8
? require('../lib/cli')
: require('../src/cli');

370
VISUALIZACION/node_modules/parcel-bundler/changelog.md generated vendored Executable file
View file

@ -0,0 +1,370 @@
# Changelog
All notable changes to parcel will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and parcel adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [1.8.0] - 2018-05-03
### Added
* Add support for multiple entry points [Details](https://github.com/parcel-bundler/parcel/commit/7cbbeef2bf5b6e2d83af55344218da72006d325c)
* Support source field in package.json to enable babel on symlinked modules [Details](https://github.com/parcel-bundler/parcel/commit/d517132890318586c0ccd45905dc66bf52425844)
* Expose modules as UMD [Details](https://github.com/parcel-bundler/parcel/commit/2af3fe3bb6d241d077f216c4bb711c59aa4069d0)
* Use parcel's resolver for sass imports [Details](https://github.com/parcel-bundler/parcel/commit/31190cff9444f8907bb1e854db1af1be68363f39)
* Update default browser engines to > 0.25% marketshare [Details](https://github.com/parcel-bundler/parcel/commit/e9b249cdc3b9b819c324077c61bd94ac9c429ce3)
* Ignore dependencies in falsy branches [Details](https://github.com/parcel-bundler/parcel/commit/a176dedc3ec60e88f8899614377d3f1fabe54ef7)
* Clear the console in browser on each HMR [Details](https://github.com/parcel-bundler/parcel/commit/1a688cd7684262d55f37eebe6993506f3040ecf6)
* Watch directories instead of individual files to fix EMFILE errors [Details](https://github.com/parcel-bundler/parcel/commit/d67b76c8c62792f37ca5e5071be533198093f1ae)
### Fixed
* Prevent build from breaking when .scss file is empty [Details](https://github.com/parcel-bundler/parcel/commit/7a2ba16de58a11f84e37b62537c4a1cc54f3f478)
* Handle empty config files [Details](https://github.com/parcel-bundler/parcel/commit/11a788247c4e4d2abfba33d56e47c8422b75c447)
* Update dependency with security vuln [Details](https://github.com/parcel-bundler/parcel/commit/06999a08f252b40344f75c5956c04c107d5502f5)
* Minor change to mkHandle in workerfarm [Details](https://github.com/parcel-bundler/parcel/commit/0d984a563f72798cc0c08e9a27bc0e6e077a0b47)
* Don't start server if target isn't browser [Details](https://github.com/parcel-bundler/parcel/commit/9064b3b6b34cba08d6c33e5d88298485b1ee87f7)
* Let worker return early instead of throw on unknown messages [Details](https://github.com/parcel-bundler/parcel/commit/3fe54a690bc8a33ddf0f458893ba108af3329db3)
* change default behaviour to keep default values of HTML form elements [Details](https://github.com/parcel-bundler/parcel/commit/ac3f8ca61b5045d3a3e77a136befe0ac48f81176)
* Fix autoinstall infinite loop [Details](https://github.com/parcel-bundler/parcel/commit/19b9fc67878f189df3a8b8e104245ddcb644436d)
* Allow spaces in filenames [Details](https://github.com/parcel-bundler/parcel/commit/fb6912da20b377be33ea82442579a0244f27ad37)
* Update deps [Details](https://github.com/parcel-bundler/parcel/commit/ec98a951393587a6e1002035c56b3e41134be844)
* Fix reference pass error in package config [Details](https://github.com/parcel-bundler/parcel/commit/a36b9124b559d65a724da74f2611a15d3122626f)
* Remove `eval` usage. Fixes CSP cases. [Details](https://github.com/parcel-bundler/parcel/commit/b032b859a1bcc4f3e734576c704afb52821235fc)
* Remove jsnext:main [Details](https://github.com/parcel-bundler/parcel/commit/f75941c3cfeb189578e3f2f9579dc9909da1d7c0)
* fix for outFile option; respect file-extension [Details](https://github.com/parcel-bundler/parcel/commit/55e27e0b9f83f3588685de8bcba18167e49c3b1f)
## [1.7.1] - 2018-04-15
### Fixed
* Fix scoped plugin packages [Details](https://github.com/parcel-bundler/parcel/commit/9792f48a8f8e9a18ea3d46521f742b36ceffbd04)
* Fix writing files in subfolders inside dist directory [Details](https://github.com/parcel-bundler/parcel/commit/0e1863bd348c03563f7e6d9a0ba0b1c07fcdbe12)
* Update addBundleLoader to accept multiple targets [Details](https://github.com/parcel-bundler/parcel/commit/9f3f30a209c3a9e7534088065cfad16dcf4b9fff)
* Fix sourcemap reference in JS output [Details](https://github.com/parcel-bundler/parcel/commit/28b87cf03425ca4214639bde9fbc334ed04d25b8)
* Sourcemap sourceRoot [Details](https://github.com/parcel-bundler/parcel/commit/3b1a5853b83d0246b3b467b86619019f3884a08f)
* Fix serving files with query params [Details](https://github.com/parcel-bundler/parcel/commit/3435c4c10c7234f292ac6809c5fbd680c6a915c8)
* Give priority to styl files in StylusAsset resolver [Details](https://github.com/parcel-bundler/parcel/commit/89952d70dd98042ce86c39e066f3f4edd5afbaf3)
* Bump dependencies [Details](https://github.com/parcel-bundler/parcel/commit/41895634469a958a0c98f8178a623f91380264fb)
* Fix asset size always be zero when building vue project [Detailds](https://github.com/parcel-bundler/parcel/commit/25a054f30670ffd3ef12890fed145a0bf21c0883)
* Custom workerfarm, BI-Directional IPC - run all npm/yarn installs on the main process [Details](https://github.com/parcel-bundler/parcel/commit/69625e057f350e5f7cbfd6e2f2b162180a289a67)
## [1.7.0] - 2018-03-28
### Added
* Add `.vue` file support [Details](https://github.com/parcel-bundler/parcel/commit/ba93b875f9503646b175890501d199b022ba54b9)
* New faster resolver supporting absolute and tilde paths, and aliases [Details](https://github.com/parcel-bundler/parcel/commit/32c38e599161372cd47924f0f4cf2aae32eb5b83)
* Content hash output file names in production [Details](https://github.com/parcel-bundler/parcel/commit/76fa1edb69af12853743f04488b2b925c058c328)
* Automatically install missing dependencies that you `require` in your code [Details](https://github.com/parcel-bundler/parcel/commit/fc654d76dc5b5691219ba441985bcf71178c1cf3)
* Production sourcemaps support via uglify [Details](https://github.com/parcel-bundler/parcel/commit/d9f3c259c08770ee370ed2b50909c333f9557bdf)
* Add Pug and Jade support [Details](https://github.com/parcel-bundler/parcel/commit/09a959d31bcaa9329f591bace573e2956ce27c7c)
* Add GLSL assets support [Details](https://github.com/parcel-bundler/parcel/commit/01e7c448f5f3a4ccdb832448ab549fdc2acebc92)
* Add overlay for build errors when using HMR [Details](https://github.com/parcel-bundler/parcel/commit/32c796dde989f7a76a8a6c332edf8c77940bd189)
* Implement pipelines to compose multiple asset types together [Details](https://github.com/parcel-bundler/parcel/commit/8a95f70ff04da6cc32c92278155b112cb37105f0)
* Add --hmr-port and --hmr-hostname options to parcel watch [Details](https://github.com/parcel-bundler/parcel/commit/cafb6ef8f96f0159f22de9e3eb89773709ec9e50)
* Add support for specifying SSL certificate & key [Details](https://github.com/parcel-bundler/parcel/commit/e7f9c64016b3f5dc53230bddf36d0d04b0389590)
* Allow specifying which browser to open with `--open` option [Details](https://github.com/parcel-bundler/parcel/commit/9858937e187b2c1d7ce27fcdfb944b168063aab4)
* Add `data` config option so it is possible to include global scss variables [Details](https://github.com/parcel-bundler/parcel/commit/86045d3b81062ddd0e66075182f237d6f7ba883e)
* Add `--log-level` option [Details](https://github.com/parcel-bundler/parcel/commit/fc041d03c36bf41ea73c398e8d177de1a456e796)
* Add support for data attr of object element [Details](https://github.com/parcel-bundler/parcel/commit/6e8ae0d97c8bb1114b3b53cf6ce0a082b066e51d)
* Add useBuiltIns babel-preset-env option [Details](https://github.com/parcel-bundler/parcel/commit/e26d443c3f9327bae3e89a08517789ce00bcf1f0)
* Support code splitting and loading WASM with --target=node [Details](https://github.com/parcel-bundler/parcel/commit/9d6061c2ede15af601764ec102389ba8f3f5f790)
### Fixed
* Fix hmr runtime error [Details](https://github.com/parcel-bundler/parcel/commit/842b9d8ddc449ca5e9b0b2b324229dd6c85b5c27)
* Add server reference to bundler [Details](https://github.com/parcel-bundler/parcel/commit/a24247155e1a21f431d39c9c1c66a782d4353e5f)
* Fix error when no "targets" options in .babelrc [Details](https://github.com/parcel-bundler/parcel/commit/69f7c6d2211ddc30dfbdfb4a8567da4542f094f1)
* Refactor prettifySize [Details](https://github.com/parcel-bundler/parcel/commit/f897bf72819ea0a3bfe6522fc5aa73f47b84f6c2)
* Fix property descriptor of config.internal in transforms/babel.js [Details](https://github.com/parcel-bundler/parcel/commit/eaf51d01462b353aeaf78ebe80d797477ae1938d)
* only transform safe cssnano minifiers [Details](https://github.com/parcel-bundler/parcel/commit/55814c0da0be226924d6f3077d0c2d5f62cc8335)
* fix electon hmr bug [Details](https://github.com/parcel-bundler/parcel/commit/88630f2a7aebf141ae060f9dc6edaa1dc2089f37)
* Fix HMR hostname in browser [Details](https://github.com/parcel-bundler/parcel/commit/0dc062f77e36a19297dac542be33cded04580e89)
* Fix srcset not working for `source` element [Details](https://github.com/parcel-bundler/parcel/commit/c469751e145a426fee2f1de27ccb2a747c7f5d1e)
* Update htmlnano [Details](https://github.com/parcel-bundler/parcel/commit/a7b72f25e275a596e98716cdc15d78fdb23f9992)
* Fix svg dependencies not being found when using minification [Details](https://github.com/parcel-bundler/parcel/commit/e3c90c40f2d7d951b1d6e59f8455d0071a539163)
* Set TypeScript option esModuleInterop to true by default [Details](https://github.com/parcel-bundler/parcel/commit/800268435a8465660f8569f7ba30a94c2b1f75a1)
* HTML bundle serving bug [Details](https://github.com/parcel-bundler/parcel/commit/43cab32ece825e9d38b3abe55fa0fde06052864d)
* Change default public-url to / [Details](https://github.com/parcel-bundler/parcel/commit/3d704c69835f2e7e663dd982851d6a11587f5596)
* Make --help same as help command [Details](https://github.com/parcel-bundler/parcel/commit/59c8d8d57c0a5b7432a37ac5b011f43455e7e228)
* Make -h same as help command [Details](https://github.com/parcel-bundler/parcel/commit/96f1e4abcefe0c5bc127d15a2d8041972f679568)
* Close hmr server when HMRServer.stop() is called [Details](https://github.com/parcel-bundler/parcel/commit/4bd32f2f52dc7fec7af15d4b45a7582926bd27a6)
* Fix methods of LazyPromise [Details](https://github.com/parcel-bundler/parcel/commit/74438d43ed88954c3be9da290df648ff6df1463c)
* Ignore require if it is defined as a local variable [Details](https://github.com/parcel-bundler/parcel/commit/12b649b914901ea0c92700288e57b68da55aafd4)
* Check browserslist prop in package.json for environments [Details](https://github.com/parcel-bundler/parcel/commit/39e4f7a254ae639c67410e6c4daa7de8e557bd33)
## [1.6.2] - 2018-02-19
### Added
* JSX support for Nerv [Details](https://github.com/parcel-bundler/parcel/commit/1e1297509c50016b16ac6d9f9ec67bf9f63ec4db)
* Add JSX support for Hyperapp. [Details](https://github.com/parcel-bundler/parcel/commit/246edd4fdc2682704ea9b19d97bd4fbf5f72c017)
### Fixed
* Fix babel handling for node: DEFAULT_ENGINES [Details](https://github.com/parcel-bundler/parcel/commit/c7ba56a96d2a135d6b95ec458789e5831e1c0828)
* Remove unnecessary files from npm [Details](https://github.com/parcel-bundler/parcel/commit/6d9e68cbdb06f2c8a05ba31fbc9dde01f0f83d96)
* Use babel-register for tests only with node < 8 [Details](https://github.com/parcel-bundler/parcel/commit/83d4e3b3d7357a1765c2dfc3f802f9ca983ec08b)
* remove call to window.location [Details](https://github.com/parcel-bundler/parcel/commit/6e0a7f678b3938f0c59f0a5f0a77c32b9dd48fb5)
## [1.6.1] - 2018-02-15
### Fixed
* Update HMRServer handleSocketError for ErrorEvent [Details](https://github.com/parcel-bundler/parcel/commit/52aec8a44d26dc1a1b54fc7131668caa374df9d9)
## [1.6.0] - 2018-02-15
### Added
* Automatically transpile dependencies with babel-preset-env [Details](https://github.com/parcel-bundler/parcel/commit/665e6b1b81e279f5efa5840c99c565a6befcf8d5)
* Add no-config support for jsx [Details](https://github.com/parcel-bundler/parcel/commit/5e224bd7f03d71e84512400329542424acf136b5)
* Add "--target=node" and "--target=electron" option to produce Node/electron friendly bundles [Details](https://github.com/parcel-bundler/parcel/commit/420ed63ed18c6a09e8b25754d0142b3b87ebcd71)
* Log bundle metrics [Details](https://github.com/parcel-bundler/parcel/commit/6deec80b3491dc5ac690da6550323b51deec6530)
* Node 6 support [Details](https://github.com/parcel-bundler/parcel/commit/95a6ebfd82ad29a8edb091943950f257320a04c9)
* Add WebManifestAsset to handle W3C webmanifest [Details](https://github.com/parcel-bundler/parcel/commit/1d49e4789a4556455ee43bda23fe903f6966f5b9)
* Add support for optional dependencies [Details](https://github.com/parcel-bundler/parcel/commit/47f252bfea604e1e9090076c573cfd6b0e91a077)
* support svg `<use>` elements [Details](https://github.com/parcel-bundler/parcel/commit/f9be8201130c27e7498b98a5b873e9ac1a7c8e98)
* Auto-install peerDependencies [Details](https://github.com/parcel-bundler/parcel/commit/93315f2b2860b7d3a66ff3af1f3d4ef958f3510e)
* Inject HTML tag if missing [Details](https://github.com/parcel-bundler/parcel/commit/5a3732296f8ca1c6c46fc9f8f3de54f67221fa2d)
* Add JSON5 support [Details](https://github.com/parcel-bundler/parcel/commit/9310641bcd11f891657fb02f2e3acd641153a99b)
* Implement support for `<img srcset="...">` [Details](https://github.com/parcel-bundler/parcel/commit/29ac70b0cdf5174237996dd26d59891a5a543bbf)
* Add `.toml` asset support [Details](https://github.com/parcel-bundler/parcel/commit/55b96406644f9f84b34dab2f98c3a6e5d61c7045)
* Warn instead of error when an fs call cannot be evaluated [Details](https://github.com/parcel-bundler/parcel/commit/6d23efd81bd7e2467fd063c15a5fa5610a568f60)
* Add support for HTML meta assets [Details](https://github.com/parcel-bundler/parcel/commit/c1d8d756cf044dfe0077a92770d31591ba270180)
* Add `--out-file` option [Details](https://github.com/parcel-bundler/parcel/commit/96162771397909367479e0af49c52eb228704a5c)
* Add Access-Control header for CORS [Details](https://github.com/parcel-bundler/parcel/commit/1c761fd5683d9bf195ee5eb6fd04bd494ecb6162)
### Fixed
* Remove `-h` alias for `hmr-port` option [Details](https://github.com/parcel-bundler/parcel/commit/c2022b3ee5d62449bebb03589847c389f0cebda6)
* Add 'id' to the module variable [Details](https://github.com/parcel-bundler/parcel/commit/8d51fdcf650088e586a48babce318354113e974b)
* Preserve asset's search and hash [Details](https://github.com/parcel-bundler/parcel/commit/d7098ce5664c3b04edf291bf96187db8a3434c5b)
* Always add bundle-loader module to the bundle [Details](https://github.com/parcel-bundler/parcel/commit/deba5ef50c5fd630dd7d983b4359b743c4b719a9)
* Launch https websocket server is --https [Details](https://github.com/parcel-bundler/parcel/commit/391e17f60fb4bf5a73ddd352883647fe6541d1cc)
* Fix PromiseQueue returning null when there are no jobs [Details](https://github.com/parcel-bundler/parcel/commit/f27d2695e1a709a7f7fc665c8287c3fa4a0ebec1)
* Correctly serialize YAML to JS [Details](https://github.com/parcel-bundler/parcel/commit/58f89002fc719e0b54216f367ec7e04130412c16)
* Update parser to treat file extensions as case-insensitive [Details](https://github.com/parcel-bundler/parcel/commit/ab713a32a5053c48f83c6503016880369ea65c18)
* Add babel-template and babel-types to package.json [Details](https://github.com/parcel-bundler/parcel/commit/74d70f8467ab131b67f85bf821610234a9c5b1a9)
* Improve Code Coverage [Details](https://github.com/parcel-bundler/parcel/commit/fc641fa7988c8c93fd152d45ef94857fb1662f90)
* Safe cssnano transforms by default [Details](https://github.com/parcel-bundler/parcel/commit/fddfdb907f393991a68ca15e48cf02a600e84840)
* Make sure bundles is an array in loadBundlesLazy [Details](https://github.com/parcel-bundler/parcel/commit/e3fcfa0148d8ccb06577701d91ea066e21842c6e)
* Bump dependencies [Details](https://github.com/parcel-bundler/parcel/commit/13864d17058a2018e083ce1c2688026779a95694)
* Allows for dots in lazyloaded file names [Details](https://github.com/parcel-bundler/parcel/commit/dc4313579b9dffd429b59c880b9fe22ba4d460d7)
* Add missing packages for pnpm to work [Details](https://github.com/parcel-bundler/parcel/commit/d3ae5f69eb3a44b4ca94b36ba2e7033fc69872a3)
* pass lowerCaseAttributeNames: true to posthtml-parser (fix version bump) [Details](https://github.com/parcel-bundler/parcel/commit/1d2f82d2e1b76efe9b806f77fde5dcf1e1b0b063)
## [1.5.1] - 2018-01-25
### Added
* Support .htm extension [Details](https://github.com/parcel-bundler/parcel/commit/3d6709142f702a92b04b065de1d05b211855966b)
### Fixed
* Fix rust projects with hyphenated names [Details](https://github.com/parcel-bundler/parcel/commit/e78baca1d0ffc499fffdd21883df1d43e0ab16f1)
* Purify sourcemaps (Prevent babel from giving invalid mappings) [Details](https://github.com/parcel-bundler/parcel/commit/03291804ec9e73b147548a4e89e6d7079f4595d4)
* Don't drop console statements by default in uglifyjs [Details](https://github.com/parcel-bundler/parcel/commit/8d7339aea1965b929ca8186ce8b617d5c46f218e)
* Fix for ipc closed error in tests [Details](https://github.com/parcel-bundler/parcel/commit/aee8510b7bfb856d7a9b49efd897c7de30cd134c)
## [1.5.0] - 2018-01-23
### Added
* SourceMap support [Details](https://github.com/parcel-bundler/parcel/commit/5c5d5f8af634c0e0aa8e8a3542892febe7c27e85)
* Custom bundleloader and wasm support [Details](https://github.com/parcel-bundler/parcel/commit/244f274f710048682505351fbed777ac7bc49406)
* Rust support [Details](https://github.com/parcel-bundler/parcel/commit/a429c52bb4e53effe586d677d53704a78c8d302b)
* Ability to set HMR port [Details](https://github.com/parcel-bundler/parcel/commit/065a49e8f673922e514c5279d79df74f052a1558)
* Support .env files [Details](https://github.com/parcel-bundler/parcel/commit/50de97fb1239b7079f36c3897fe0c0c5f2e39070)
* Hotreload css requires in html [Details](https://github.com/parcel-bundler/parcel/commit/fb3f9d7a5e120766dd3656ce00b4bb07e76d6af1)
* Minify JSON [Details](https://github.com/parcel-bundler/parcel/commit/c858843bb0e72c6ad46a2349b36843e00b86ea76)
* Ability to set HMR hostname [Details](https://github.com/parcel-bundler/parcel/commit/b56b2a9f3c3ff6db2dd27a086b409a8d4af6f2bd)
* Ability to specify amount of workers using `PARCEL_WORKERS` environment variable [Details](https://github.com/parcel-bundler/parcel/commit/0a2f554080db7f7b3f077e07ac62ade9170d1372)
* Warning emoji [Details](https://github.com/parcel-bundler/parcel/commit/25cf21709a0829131311281cb369d792cf666aa3)
### Fixed
* Virtualpaths, throw file not found error [Details](https://github.com/parcel-bundler/parcel/commit/e09575d495d2ac5282671eab88b827191eee7fa7)
* Transform HTML prior to collecting dependencies [Details](https://github.com/parcel-bundler/parcel/commit/2fbba629eaa83d7de5ccba79e01faa1187393f16)
* Find a[href] dependencies when attrs precede it [Details](https://github.com/parcel-bundler/parcel/commit/39c5cfe377be603b16561f914cb9a07c7e5fdd6c)
* Resolve URI-encoded assets [Details](https://github.com/parcel-bundler/parcel/commit/9770acfb7576572715dd672195180d5fec8156a9)
* Public-url not an os path [Details](https://github.com/parcel-bundler/parcel/commit/a852dd2cd0dc856121ebc2e6cbc2589525a3d435)
* Invalidate cache when parent dependencies change [Details](https://github.com/parcel-bundler/parcel/commit/b8e897341e942b04967a1d44f462375292d5b990)
* Invalidate cache on config change [Details](https://github.com/parcel-bundler/parcel/commit/6c3d34f2215a46dd7845193a6f4036930eaddf48)
* Circular bundles [Details](https://github.com/parcel-bundler/parcel/commit/dd26db34fb70b3e40826bf3c4878172eb60afe91)
* Possibly ignore fs using browser-resolve config [Details](https://github.com/parcel-bundler/parcel/commit/bd9fd9f6193c3f18efa03f897a33906869808b96)
* Do not use global window inside hmr, fixes web worker issues [Details](https://github.com/parcel-bundler/parcel/commit/6962a9a96cdedafbf27715bc74b93e6c8ad7eb19)
* Improved worker startup times [Details](https://github.com/parcel-bundler/parcel/commit/072d799d48bb3639c628687937f3641fe2cff74d)
* Parse `//` as a valid url [Details](https://github.com/parcel-bundler/parcel/commit/a78280affa7e02cb142e51259ea4076ed036600a)
* Improve windows emoji console detections [Details](https://github.com/parcel-bundler/parcel/commit/dba3d49be2d30dfe47a9bd9c88d6fba9015be968)
## [1.4.1] - 2017-12-31
### Added
* Changelog [Details](https://github.com/parcel-bundler/parcel/commit/dc4acd8efebf76116b9e06e89827e56cfa217013)
### Fixed
* http hot reload server printing location as `https://...` [Details](https://github.com/parcel-bundler/parcel/commit/0fcdeb9a9feac10be3ff2485e2487588734a6754)
* Execute bundle() when calling Bundler.middleware() [Details](https://github.com/parcel-bundler/parcel/commit/b9004fc3a0092cdfa0b18e196ab25a79e582b2d1)
* Always parse dependencies if babel ran. [Details](https://github.com/parcel-bundler/parcel/commit/c6991116f0759b865f1a55336c32ba0793fa09c3)
## [1.4.0] - 2017-12-31
### Added
* HTTPS server support [Details](https://github.com/parcel-bundler/parcel/commit/90b968432592f38ecca0ad3b2cb5f7fbfbcd684c)
* GraphQL Support [Details](https://github.com/parcel-bundler/parcel/commit/8f1f497945d4e5102c401e3036c4bc30fd692348)
* Webworker Support [Details](https://github.com/parcel-bundler/parcel/commit/c8a1156d4c2dd5902ba500aa9c25547bfab53eac)
* CSSNano configuration [Details](https://github.com/parcel-bundler/parcel/commit/14e7880be2a147503999e21d4c1114874cc500d7)
* HTMLNano configuration [Details](https://github.com/parcel-bundler/parcel/commit/d11a15e1636ea7c7f291d0cfbf73b75cc719e839)
* Support async plugin loading [Details](https://github.com/parcel-bundler/parcel/commit/bb6e6044b7569fd6745ab915dfd49327d0cbb955)
* Add code sample section to `ISSUE_TEMPLATE` [Details](https://github.com/parcel-bundler/parcel/commit/8a65676023f88a53372ab4bf0b6daada49de6b49)
* Add url dependency for serviceWorker.register calls [Details](https://github.com/parcel-bundler/parcel/commit/0ab0acaecece829392cd452f83014df7c470fc83)
* Fix ignored babel files [Details](https://github.com/parcel-bundler/parcel/commit/22478d368216b24da3bd3e94439b02e356fd4310)
### Fixed
* log-symbols fallback for cross-platform emoji compatibility [Details](https://github.com/parcel-bundler/parcel/commit/0eb4487491fd70390697ad413aeac994fca4309c)
* Use hostname for websocket connection [Details](https://github.com/parcel-bundler/parcel/commit/06d5ffc33dac19fa9ca730bbf939052b500a34ec)
* Standardize empty implementation comment [Details](https://github.com/parcel-bundler/parcel/commit/d763a1aaca70a7892cb4c6611c2540ca1506d107)
* Handle appstore url scheme [Details](https://github.com/parcel-bundler/parcel/commit/494fafc33ec0a3c66b423670a24539896015855f)
* bundling issues when asset parent & commonBundle types differ [Details](https://github.com/parcel-bundler/parcel/commit/127c9b72d20847734049a7db27683279c6784ab6)
* Handle empty assets [Details](https://github.com/parcel-bundler/parcel/commit/4c67f03808dca6cf9b9a47bcd92477e09005da75)
* Minify `Prelude.js` [Details](https://github.com/parcel-bundler/parcel/commit/a0ede06395807cc0f7f6caad7aee2cb1463d41ac)
## [1.3.1] - 2017-12-24
### Fixed
* Maintain html spacing between tags when minimizing [Details](https://github.com/parcel-bundler/parcel/commit/0f40da9bd4249b43d22597f80d0306791e9203f6)
* Incorrect bundle path for raw Assets [Details](https://github.com/parcel-bundler/parcel/commit/38f8aaf173a8ff501ddd02741969089576b42bd6)
## [1.3.0] - 2017-12-22
### Added
* Reason Asset Type [Details](https://github.com/parcel-bundler/parcel/commit/47e91926f1d9ed763ad11cbd39a9b9fbc1986b20)
* Automatically install parser dependencies [Details](https://github.com/parcel-bundler/parcel/commit/6f493f030852f557c299b2c26a565c99e1e9de66)
* UglifyES config support [Details](https://github.com/parcel-bundler/parcel/commit/1947a15d40cc2b7dd91bdc64d02a5d79604ba550)
* Display absolute path on failed dependency resolve [Details](https://github.com/parcel-bundler/parcel/commit/dffeb7d81ea14e9739b372132fd32d8d74d9b368)
* Support `.editorconfig` [Details](https://github.com/parcel-bundler/parcel/commit/6c96b6588afc1b774551c5eda3487c2d0fab6dc0)
* Tests for ES6 Modules resolver [Details](https://github.com/parcel-bundler/parcel/commit/76186779b2a24ce1befc7c5d5b3e783c7b9f5c94)
* ESLint [Details](https://github.com/parcel-bundler/parcel/commit/434b86c92b19e2c7de13a121600d0533c1138169)
### Fixed
* Parse port option as integer [Details](https://github.com/parcel-bundler/parcel/commit/1fa9fef1d1165630b0beabba5d546ee3ccffbec1)
* Make cli.js Node 6 compatible [Details](https://github.com/parcel-bundler/parcel/commit/ac0fbaf40b9cc93b3f428c2b6c124027f56e6e78)
* Remove arrow function from hmr-runtime - IE support [Details](https://github.com/parcel-bundler/parcel/commit/9f5b334d6e04136d93ae428a5eef899371b400e0)
* Start server before bundling [Details](https://github.com/parcel-bundler/parcel/commit/44d0bd6633b71ce3b36b4faeee514182dcc9334a)
* Deterministic bundle trees [Details](https://github.com/parcel-bundler/parcel/commit/539ade1820c3e644586e3161f6b2357a68784142)
* Resolve "module", "jsnext:main" and "browser" before "main" in Package.json [Details](https://github.com/parcel-bundler/parcel/commit/7fcae064b205ab30c2393c3ce68171fd9f47ffc1)
* Remove filename unsafe characters [Details](https://github.com/parcel-bundler/parcel/commit/df021967900fd60d7a58a79191daa26caf68c2b5)
* Don't hash root file [Details](https://github.com/parcel-bundler/parcel/commit/075190c9868c5dd01ec4a935a187e21ae00662e5)
* Use cross-spawn for autoinstalling dependencies on windows [Details](https://github.com/parcel-bundler/parcel/commit/ab3a7d61a4f3e19b129583914fb9fad4c54d8dc6)
## [1.2.1] - 2017-12-18
### Added
* Opencollective [Details](https://github.com/parcel-bundler/parcel/commit/0f554dc2f5c8f2557ec84eee5301b90ffb279764)
* Use `JSON5` to parse config files [Details](https://github.com/parcel-bundler/parcel/commit/bd458660ce38e7a1d25bd9758084acc24418e054)
* Move JSAsset options gathering into seperate function [Details](https://github.com/parcel-bundler/parcel/commit/333c3aa5d20f98a5f3c52635751032d12854c13c)
### Fixed
* Don't use template literals in builtins - IE support [Details](https://github.com/parcel-bundler/parcel/commit/b7b2991d69b960d9f2951828b8145a6d9396ee4e)
* Merge `tsconfig.json` with defaults [Details](https://github.com/parcel-bundler/parcel/commit/86835793a513b43af906a02083eed72b7eb9e0d2)
* Change `parse-json` requires to `JSON5` [Details](https://github.com/parcel-bundler/parcel/commit/ed35a0994d34dfead6b8895ae981d9b05edac361)
* Register `.pcss` extension to CSSAsset [Details](https://github.com/parcel-bundler/parcel/commit/f62d47686698807e43923893affb6f4ce22337ac)
* Websocket error handling [Details](https://github.com/parcel-bundler/parcel/commit/9f27e15bfcefc2e629a97c154ec2391e2a962623)
* Development server index file [Details](https://github.com/parcel-bundler/parcel/commit/c008bb0ac492dbac38e2f13017e3143f40359934)
## [1.2.0] - 2017-12-12
### Added
* Coffeescript support [Details](https://github.com/parcel-bundler/parcel/commit/2d680c0e968cbdda46455ae792b4dbac33dc9753)
* Reload html on change [Details](https://github.com/parcel-bundler/parcel/commit/0ff76bea36135a4b1edbd85a588a4e26c86dcc19)
* `--open` option to automatically launch in default browser [Details](https://github.com/parcel-bundler/parcel/commit/f8b3d55288f4c4a15330daf7d950cc496fde47ed)
* Prettier [Details](https://github.com/parcel-bundler/parcel/commit/548eef92e11711db007b7613ba5530de508d21a0)
* Code of conduct [Details](https://github.com/parcel-bundler/parcel/commit/72c4d47a77d0b4419d54130e2ea2f39ae40b74da)
* User friendly server errors and automatic port switching [Details](https://github.com/parcel-bundler/parcel/commit/87350f44223ea77597f5d2f50c3886ebd6126a42)
* Version option to command description [Details](https://github.com/parcel-bundler/parcel/commit/35c65a34ac41508c3a3bed8944bb478cebc3e071)
* Add badges to readme [Details](https://github.com/parcel-bundler/parcel/commit/644f195341c1a47d49af101716ce2fa8b323a0fe)
* Support JSON comments [Details](https://github.com/parcel-bundler/parcel/commit/7bfe232ba1db4f27278025175cf3818fbc34e65f)
* Add AppVeyor CI [Details](https://github.com/parcel-bundler/parcel/commit/0eb7a930ffcd4fc77b5b6c75e490299f92ca8a8e)
* Use `UglifyES` instead of `UglifyJS` [Details](https://github.com/parcel-bundler/parcel/commit/70663cced00e5f98d3e8e3affbc0ee40a9ab4566)
### Fixed
* Bundle-loader when using esModule [Details](https://github.com/parcel-bundler/parcel/commit/7d1f384122431b90e715161e50a5abf39dc8fd9d)
* Use var over let in builtins for IE support [Details](https://github.com/parcel-bundler/parcel/commit/29515f4f713b093bad9cf8fedd796c4eacb4f38b)
* Add jsm to javascript extensions [Details](https://github.com/parcel-bundler/parcel/commit/cdda0442cc9a00dde5f54ffc643a32e58390034f)
* Log pluginload errors [Details](https://github.com/parcel-bundler/parcel/commit/acdf9792ed53a5909cc5ab638ad0f27403b41957)
* Global env problem [Details](https://github.com/parcel-bundler/parcel/commit/355c63bc956bf24dd7d040e52dd3be2fda47ad9c)
* Exit on build error when using build command [Details](https://github.com/parcel-bundler/parcel/commit/34b84e44573fd583689ccefde5a8bd9f46de203b)
* Remove circular require in Asset.js [Details](https://github.com/parcel-bundler/parcel/commit/7c0acb32bc7374a294f53d758e330c52966919dd)
* Give high priotity to extension of parent [Details](https://github.com/parcel-bundler/parcel/commit/2e3266242f7f2dd01fd21c3ba58d0fb575635e43)
* Fallback to `os.cpus()` for cpu count [Details](https://github.com/parcel-bundler/parcel/commit/9d319afd7683468361dc2f04b253aaca38e779ee)
* Windows test issues [Details](https://github.com/parcel-bundler/parcel/commit/0eb7a930ffcd4fc77b5b6c75e490299f92ca8a8e)
* Raw Asset loading [Details](https://github.com/parcel-bundler/parcel/commit/51b90d7458fca5b10dbaa0605c33223b8884b6e1)
* Normalize path on windows [Details](https://github.com/parcel-bundler/parcel/commit/0479dee763fc9d79c057c86233cb660c6022a92c)
* Make hmr-runtime ES3 compatible [Details](https://github.com/parcel-bundler/parcel/commit/d17dccccf4480e440c1898911f304efe6040439f)
* Dynamically importing js assets with raw assets children [Details](https://github.com/parcel-bundler/parcel/commit/dc52638a27d41b1eadf25ecc5d93bfe6727182c7)
* Package.json loading issues for plugin loading [Details](https://github.com/parcel-bundler/parcel/commit/7469a150bf5accecdcfc430365572601527302b9)
## [1.1.0] - 2017-12-08
### Added
* Typescript support [Details](https://github.com/parcel-bundler/parcel/commit/757b67362e1fce076241fa31afe2179db93cff18)
* Browser gets notified of errors [Details](https://github.com/parcel-bundler/parcel/commit/d9d8bab2a9bcd2efd23bd824d4c24af1d66a3f77)
* Community section to Readme [Details](https://github.com/parcel-bundler/parcel/commit/11d109b4b4e03f8ab5da253f9c70b0e6e11e8f3b)
* More helpfull json parsing error messages using `parse-json` [Details](https://github.com/parcel-bundler/parcel/commit/2b26f9691d3dc489c509476718fa852b231ffde1)
* Issue template [Details](https://github.com/parcel-bundler/parcel/commit/f8dd2f2aea167f011a5c885b20390521798c8c9f)
### Fixed
* Print stack traces on error [Details](https://github.com/parcel-bundler/parcel/commit/4ab9b878a2b1ea280afaac690fb0990947c4323e)
* Merge `postcss-modules` config [Details](https://github.com/parcel-bundler/parcel/commit/582f8db1f735ecbbd4f5c93202ba0f6a6c24f8ca)
* Default to `NODE_ENV` development on serve [Details](https://github.com/parcel-bundler/parcel/commit/29f8df78788061a7f406059bc55c8ede428a020d)
* Disable flakey macOS FS events in watcher in the tests [Details](https://github.com/parcel-bundler/parcel/commit/e69c83d9db38fac8d1e525bdf03a883b551f506d)
* Sort child bundles by asset names to avoid race condition in tests [Details](https://github.com/parcel-bundler/parcel/commit/c49e43a5a6f4b602d07f72f76b8443bf37203a3f)
## [1.0.3] - 2017-12-07
### Added
* Add version to cache key [Details](https://github.com/parcel-bundler/parcel/commit/f3287ab76f5921d1ec7273bee42871179fe3ca85)
* Travis tests environment, build script and contribution docs [Details](https://github.com/parcel-bundler/parcel/commit/90f69ff30b9b239b537ca1b01f8ce7fb1d08ce6a)
### Fixed
* File url bugfix for Firefox [Details](https://github.com/parcel-bundler/parcel/commit/90a5373d629bebdc9761ddb784e683190bdcc35a#diff-78cb52acd60299e5f6fd26a716d97293)
* Windows path bugfix [Details](https://github.com/parcel-bundler/parcel/commit/67cd3b0678b835f3a21134800bc0f9c9b8d599e2)
* Default only exports [Details](https://github.com/parcel-bundler/parcel/commit/860a748898f8a0fee749aec2e6bdc3eaabf0ce87)
* Public URL in normalizeOptions [Details](https://github.com/parcel-bundler/parcel/commit/9b066122ed40afc05f5eb20ea0cc1ec9e748592b)
* Do not try to import data:, tel:, mailto:, something: URLS [Details](https://github.com/parcel-bundler/parcel/commit/781b7ecd114edd63fe6ad04dfc1408c9a611f2f5)
## [1.0.2] - 2017-12-06
### Added
* Add github repository to `package.json` [Details](https://github.com/parcel-bundler/parcel/commit/88bdf1e474d8bc8af3f770b431d011239f1ede14)
### Fixed
* Improved public url checking using `is-url` instead of regex [Details](https://github.com/parcel-bundler/parcel/commit/92be140ad55fcdef7b34baa6718bc356274e5e8f)
### Removed
* `babel-preset-es2015` removed from dev dependencies [Details](https://github.com/parcel-bundler/parcel/commit/4d87814f7201d70cfa5db3b457915c508378c9e6)
## [1.0.1] - 2017-12-05
* Initial Parcel-bundler core

4
VISUALIZACION/node_modules/parcel-bundler/index.js generated vendored Executable file
View file

@ -0,0 +1,4 @@
// Node 8 supports native async functions - no need to use compiled code!
module.exports = parseInt(process.versions.node, 10) < 8
? require('./lib/Bundler')
: require('./src/Bundler');

271
VISUALIZACION/node_modules/parcel-bundler/lib/Asset.js generated vendored Executable file
View file

@ -0,0 +1,271 @@
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const URL = require('url');
const path = require('path');
const fs = require('./utils/fs');
const objectHash = require('./utils/objectHash');
const md5 = require('./utils/md5');
const isURL = require('./utils/is-url');
const config = require('./utils/config');
let ASSET_ID = 1;
/**
* An Asset represents a file in the dependency tree. Assets can have multiple
* parents that depend on it, and can be added to multiple output bundles.
* The base Asset class doesn't do much by itself, but sets up an interface
* for subclasses to implement.
*/
class Asset {
constructor(name, pkg, options) {
this.id = ASSET_ID++;
this.name = name;
this.basename = path.basename(this.name);
this.relativeName = path.relative(options.rootDir, this.name);
this.package = pkg || {};
this.options = options;
this.encoding = 'utf8';
this.type = path.extname(this.name).slice(1);
this.processed = false;
this.contents = options.rendition ? options.rendition.value : null;
this.ast = null;
this.generated = null;
this.hash = null;
this.parentDeps = new Set();
this.dependencies = new Map();
this.depAssets = new Map();
this.parentBundle = null;
this.bundles = new Set();
this.cacheData = {};
this.buildTime = 0;
this.bundledSize = 0;
}
shouldInvalidate() {
return false;
}
loadIfNeeded() {
var _this = this;
return _asyncToGenerator(function* () {
if (_this.contents == null) {
_this.contents = yield _this.load();
}
})();
}
parseIfNeeded() {
var _this2 = this;
return _asyncToGenerator(function* () {
yield _this2.loadIfNeeded();
if (!_this2.ast) {
_this2.ast = yield _this2.parse(_this2.contents);
}
})();
}
getDependencies() {
var _this3 = this;
return _asyncToGenerator(function* () {
if (_this3.options.rendition && _this3.options.rendition.hasDependencies === false) {
return;
}
yield _this3.loadIfNeeded();
if (_this3.contents && _this3.mightHaveDependencies()) {
yield _this3.parseIfNeeded();
yield _this3.collectDependencies();
}
})();
}
addDependency(name, opts) {
this.dependencies.set(name, Object.assign({ name }, opts));
}
addURLDependency(url, from = this.name, opts) {
if (!url || isURL(url)) {
return url;
}
if (typeof from === 'object') {
opts = from;
from = this.name;
}
const parsed = URL.parse(url);
const resolved = path.resolve(path.dirname(from), decodeURIComponent(parsed.pathname));
this.addDependency('./' + path.relative(path.dirname(this.name), resolved), Object.assign({ dynamic: true }, opts));
parsed.pathname = this.options.parser.getAsset(resolved, this.package, this.options).generateBundleName();
return URL.format(parsed);
}
getConfig(filenames, opts = {}) {
var _this4 = this;
return _asyncToGenerator(function* () {
// Resolve the config file
let conf = yield config.resolve(opts.path || _this4.name, filenames);
if (conf) {
// Add as a dependency so it is added to the watcher and invalidates
// this asset when the config changes.
_this4.addDependency(conf, { includedInParent: true });
if (opts.load === false) {
return conf;
}
return yield config.load(opts.path || _this4.name, filenames);
}
return null;
})();
}
mightHaveDependencies() {
return true;
}
load() {
var _this5 = this;
return _asyncToGenerator(function* () {
return yield fs.readFile(_this5.name, _this5.encoding);
})();
}
parse() {
// do nothing by default
}
collectDependencies() {
// do nothing by default
}
pretransform() {
// do nothing by default
return _asyncToGenerator(function* () {})();
}
transform() {
// do nothing by default
return _asyncToGenerator(function* () {})();
}
generate() {
var _this6 = this;
return _asyncToGenerator(function* () {
return {
[_this6.type]: _this6.contents
};
})();
}
process() {
var _this7 = this;
return _asyncToGenerator(function* () {
if (!_this7.generated) {
yield _this7.loadIfNeeded();
yield _this7.pretransform();
yield _this7.getDependencies();
yield _this7.transform();
_this7.generated = yield _this7.generate();
_this7.hash = yield _this7.generateHash();
}
return _this7.generated;
})();
}
postProcess(generated) {
return _asyncToGenerator(function* () {
return generated;
})();
}
generateHash() {
return objectHash(this.generated);
}
invalidate() {
this.processed = false;
this.contents = null;
this.ast = null;
this.generated = null;
this.hash = null;
this.dependencies.clear();
this.depAssets.clear();
}
invalidateBundle() {
this.parentBundle = null;
this.bundles.clear();
this.parentDeps.clear();
}
generateBundleName() {
// Generate a unique name. This will be replaced with a nicer
// name later as part of content hashing.
return md5(this.name) + '.' + this.type;
}
replaceBundleNames(bundleNameMap) {
for (let key in this.generated) {
let value = this.generated[key];
if (typeof value === 'string') {
// Replace temporary bundle names in the output with the final content-hashed names.
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = bundleNameMap[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let _ref = _step.value;
var _ref2 = _slicedToArray(_ref, 2);
let name = _ref2[0];
let map = _ref2[1];
value = value.split(name).join(map);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
this.generated[key] = value;
}
}
}
generateErrorMessage(err) {
return err;
}
}
module.exports = Asset;

416
VISUALIZACION/node_modules/parcel-bundler/lib/Bundle.js generated vendored Executable file
View file

@ -0,0 +1,416 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Path = require('path');
const crypto = require('crypto');
/**
* A Bundle represents an output file, containing multiple assets. Bundles can have
* child bundles, which are bundles that are loaded dynamically from this bundle.
* Child bundles are also produced when importing an asset of a different type from
* the bundle, e.g. importing a CSS file from JS.
*/
class Bundle {
constructor(type, name, parent) {
this.type = type;
this.name = name;
this.parentBundle = parent;
this.entryAsset = null;
this.assets = new Set();
this.childBundles = new Set();
this.siblingBundles = new Set();
this.siblingBundlesMap = new Map();
this.offsets = new Map();
this.totalSize = 0;
this.bundleTime = 0;
}
static createWithAsset(asset, parentBundle) {
let bundle = new Bundle(asset.type, Path.join(asset.options.outDir, asset.generateBundleName()), parentBundle);
bundle.entryAsset = asset;
bundle.addAsset(asset);
return bundle;
}
addAsset(asset) {
asset.bundles.add(this);
this.assets.add(asset);
}
removeAsset(asset) {
asset.bundles.delete(this);
this.assets.delete(asset);
}
addOffset(asset, line) {
this.offsets.set(asset, line);
}
getOffset(asset) {
return this.offsets.get(asset) || 0;
}
getSiblingBundle(type) {
if (!type || type === this.type) {
return this;
}
if (!this.siblingBundlesMap.has(type)) {
let bundle = new Bundle(type, Path.join(Path.dirname(this.name), Path.basename(this.name, Path.extname(this.name)) + '.' + type), this);
this.childBundles.add(bundle);
this.siblingBundles.add(bundle);
this.siblingBundlesMap.set(type, bundle);
}
return this.siblingBundlesMap.get(type);
}
createChildBundle(entryAsset) {
let bundle = Bundle.createWithAsset(entryAsset, this);
this.childBundles.add(bundle);
return bundle;
}
createSiblingBundle(entryAsset) {
let bundle = this.createChildBundle(entryAsset);
this.siblingBundles.add(bundle);
return bundle;
}
get isEmpty() {
return this.assets.size === 0;
}
getBundleNameMap(contentHash, hashes = new Map()) {
if (this.name) {
let hashedName = this.getHashedBundleName(contentHash);
hashes.set(Path.basename(this.name), hashedName);
this.name = Path.join(Path.dirname(this.name), hashedName);
}
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = this.childBundles.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let child = _step.value;
child.getBundleNameMap(contentHash, hashes);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return hashes;
}
getHashedBundleName(contentHash) {
// If content hashing is enabled, generate a hash from all assets in the bundle.
// Otherwise, use a hash of the filename so it remains consistent across builds.
let ext = Path.extname(this.name);
let hash = (contentHash ? this.getHash() : Path.basename(this.name, ext)).slice(-8);
let entryAsset = this.entryAsset || this.parentBundle.entryAsset;
let name = Path.basename(entryAsset.name, Path.extname(entryAsset.name));
let isMainEntry = entryAsset.options.entryFiles[0] === entryAsset.name;
let isEntry = entryAsset.options.entryFiles.includes(entryAsset.name) || Array.from(entryAsset.parentDeps).some(dep => dep.entry);
// If this is the main entry file, use the output file option as the name if provided.
if (isMainEntry && entryAsset.options.outFile) {
let extname = Path.extname(entryAsset.options.outFile);
if (extname) {
ext = this.entryAsset ? extname : ext;
name = Path.basename(entryAsset.options.outFile, extname);
} else {
name = entryAsset.options.outFile;
}
}
// If this is an entry asset, don't hash. Return a relative path
// from the main file so we keep the original file paths.
if (isEntry) {
return Path.join(Path.relative(entryAsset.options.rootDir, Path.dirname(entryAsset.name)), name + ext);
}
// If this is an index file, use the parent directory name instead
// which is probably more descriptive.
if (name === 'index') {
name = Path.basename(Path.dirname(entryAsset.name));
}
// Add the content hash and extension.
return name + '.' + hash + ext;
}
package(bundler, oldHashes, newHashes = new Map()) {
var _this = this;
return _asyncToGenerator(function* () {
let promises = [];
let mappings = [];
if (!_this.isEmpty) {
let hash = _this.getHash();
newHashes.set(_this.name, hash);
if (!oldHashes || oldHashes.get(_this.name) !== hash) {
promises.push(_this._package(bundler));
}
}
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = _this.childBundles.values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
let bundle = _step2.value;
if (bundle.type === 'map') {
mappings.push(bundle);
} else {
promises.push(bundle.package(bundler, oldHashes, newHashes));
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
yield Promise.all(promises);
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = mappings[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
let bundle = _step3.value;
yield bundle.package(bundler, oldHashes, newHashes);
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
return newHashes;
})();
}
_package(bundler) {
var _this2 = this;
return _asyncToGenerator(function* () {
let Packager = bundler.packagers.get(_this2.type);
let packager = new Packager(_this2, bundler);
let startTime = Date.now();
yield packager.setup();
yield packager.start();
let included = new Set();
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
try {
for (var _iterator4 = _this2.assets[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
let asset = _step4.value;
yield _this2._addDeps(asset, packager, included);
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4.return) {
_iterator4.return();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
}
}
yield packager.end();
_this2.bundleTime = Date.now() - startTime;
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (var _iterator5 = _this2.assets[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
let asset = _step5.value;
_this2.bundleTime += asset.buildTime;
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5.return) {
_iterator5.return();
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
}
}
}
})();
}
_addDeps(asset, packager, included) {
var _this3 = this;
return _asyncToGenerator(function* () {
if (!_this3.assets.has(asset) || included.has(asset)) {
return;
}
included.add(asset);
var _iteratorNormalCompletion6 = true;
var _didIteratorError6 = false;
var _iteratorError6 = undefined;
try {
for (var _iterator6 = asset.depAssets.values()[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
let depAsset = _step6.value;
yield _this3._addDeps(depAsset, packager, included);
}
} catch (err) {
_didIteratorError6 = true;
_iteratorError6 = err;
} finally {
try {
if (!_iteratorNormalCompletion6 && _iterator6.return) {
_iterator6.return();
}
} finally {
if (_didIteratorError6) {
throw _iteratorError6;
}
}
}
yield packager.addAsset(asset);
const assetSize = packager.getSize() - _this3.totalSize;
if (assetSize > 0) {
_this3.addAssetSize(asset, assetSize);
}
})();
}
addAssetSize(asset, size) {
asset.bundledSize = size;
this.totalSize += size;
}
getParents() {
let parents = [];
let bundle = this;
while (bundle) {
parents.push(bundle);
bundle = bundle.parentBundle;
}
return parents;
}
findCommonAncestor(bundle) {
// Get a list of parent bundles going up to the root
let ourParents = this.getParents();
let theirParents = bundle.getParents();
// Start from the root bundle, and find the first bundle that's different
let a = ourParents.pop();
let b = theirParents.pop();
let last;
while (a === b && ourParents.length > 0 && theirParents.length > 0) {
last = a;
a = ourParents.pop();
b = theirParents.pop();
}
if (a === b) {
// One bundle descended from the other
return a;
}
return last;
}
getHash() {
let hash = crypto.createHash('md5');
var _iteratorNormalCompletion7 = true;
var _didIteratorError7 = false;
var _iteratorError7 = undefined;
try {
for (var _iterator7 = this.assets[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
let asset = _step7.value;
hash.update(asset.hash);
}
} catch (err) {
_didIteratorError7 = true;
_iteratorError7 = err;
} finally {
try {
if (!_iteratorNormalCompletion7 && _iterator7.return) {
_iterator7.return();
}
} finally {
if (_didIteratorError7) {
throw _iteratorError7;
}
}
}
return hash.digest('hex');
}
}
module.exports = Bundle;

968
VISUALIZACION/node_modules/parcel-bundler/lib/Bundler.js generated vendored Executable file
View file

@ -0,0 +1,968 @@
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const fs = require('./utils/fs');
const Resolver = require('./Resolver');
const Parser = require('./Parser');
const WorkerFarm = require('./workerfarm/WorkerFarm');
const Path = require('path');
const Bundle = require('./Bundle');
const Watcher = require('./Watcher');
const FSCache = require('./FSCache');
const HMRServer = require('./HMRServer');
const Server = require('./Server');
var _require = require('events');
const EventEmitter = _require.EventEmitter;
const logger = require('./Logger');
const PackagerRegistry = require('./packagers');
const localRequire = require('./utils/localRequire');
const config = require('./utils/config');
const emoji = require('./utils/emoji');
const loadEnv = require('./utils/env');
const PromiseQueue = require('./utils/PromiseQueue');
const installPackage = require('./utils/installPackage');
const bundleReport = require('./utils/bundleReport');
const prettifyTime = require('./utils/prettifyTime');
const getRootDir = require('./utils/getRootDir');
const glob = require('glob');
/**
* The Bundler is the main entry point. It resolves and loads assets,
* creates the bundle tree, and manages the worker farm, cache, and file watcher.
*/
class Bundler extends EventEmitter {
constructor(entryFiles, options = {}) {
super();
this.entryFiles = this.normalizeEntries(entryFiles);
this.options = this.normalizeOptions(options);
this.resolver = new Resolver(this.options);
this.parser = new Parser(this.options);
this.packagers = new PackagerRegistry();
this.cache = this.options.cache ? new FSCache(this.options) : null;
this.delegate = options.delegate || {};
this.bundleLoaders = {};
this.addBundleLoader('wasm', {
browser: require.resolve('./builtins/loaders/browser/wasm-loader'),
node: require.resolve('./builtins/loaders/node/wasm-loader')
});
this.addBundleLoader('css', {
browser: require.resolve('./builtins/loaders/browser/css-loader'),
node: require.resolve('./builtins/loaders/node/css-loader')
});
this.addBundleLoader('js', {
browser: require.resolve('./builtins/loaders/browser/js-loader'),
node: require.resolve('./builtins/loaders/node/js-loader')
});
this.pending = false;
this.loadedAssets = new Map();
this.watchedAssets = new Map();
this.farm = null;
this.watcher = null;
this.hmr = null;
this.bundleHashes = null;
this.errored = false;
this.buildQueue = new PromiseQueue(this.processAsset.bind(this));
this.rebuildTimeout = null;
logger.setOptions(this.options);
}
normalizeEntries(entryFiles) {
// Support passing a single file
if (entryFiles && !Array.isArray(entryFiles)) {
entryFiles = [entryFiles];
}
// If no entry files provided, resolve the entry point from the current directory.
if (!entryFiles || entryFiles.length === 0) {
entryFiles = [process.cwd()];
}
// Match files as globs
return entryFiles.reduce((p, m) => p.concat(glob.sync(m, { nonull: true })), []).map(f => Path.resolve(f));
}
normalizeOptions(options) {
const isProduction = options.production || process.env.NODE_ENV === 'production';
const publicURL = options.publicUrl || options.publicURL || '/';
const watch = typeof options.watch === 'boolean' ? options.watch : !isProduction;
const target = options.target || 'browser';
return {
production: isProduction,
outDir: Path.resolve(options.outDir || 'dist'),
outFile: options.outFile || '',
publicURL: publicURL,
watch: watch,
cache: typeof options.cache === 'boolean' ? options.cache : true,
cacheDir: Path.resolve(options.cacheDir || '.cache'),
killWorkers: typeof options.killWorkers === 'boolean' ? options.killWorkers : true,
minify: typeof options.minify === 'boolean' ? options.minify : isProduction,
target: target,
hmr: target === 'node' ? false : typeof options.hmr === 'boolean' ? options.hmr : watch,
https: options.https || false,
logLevel: isNaN(options.logLevel) ? 3 : options.logLevel,
entryFiles: this.entryFiles,
hmrPort: options.hmrPort || 0,
rootDir: getRootDir(this.entryFiles),
sourceMaps: typeof options.sourceMaps === 'boolean' ? options.sourceMaps : true,
hmrHostname: options.hmrHostname || (options.target === 'electron' ? 'localhost' : ''),
detailedReport: options.detailedReport || false,
global: options.global,
autoinstall: typeof options.autoinstall === 'boolean' ? options.autoinstall : !isProduction,
contentHash: typeof options.contentHash === 'boolean' ? options.contentHash : isProduction
};
}
addAssetType(extension, path) {
if (typeof path !== 'string') {
throw new Error('Asset type should be a module path.');
}
if (this.farm) {
throw new Error('Asset types must be added before bundling.');
}
this.parser.registerExtension(extension, path);
}
addPackager(type, packager) {
if (this.farm) {
throw new Error('Packagers must be added before bundling.');
}
this.packagers.add(type, packager);
}
addBundleLoader(type, paths) {
if (typeof paths === 'string') {
paths = { node: paths, browser: paths };
} else if (typeof paths !== 'object') {
throw new Error('Bundle loaders should be an object.');
}
for (const target in paths) {
if (target !== 'node' && target !== 'browser') {
throw new Error(`Unknown bundle loader target "${target}".`);
}
if (typeof paths[target] !== 'string') {
throw new Error('Bundle loader should be a string.');
}
}
if (this.farm) {
throw new Error('Bundle loaders must be added before bundling.');
}
this.bundleLoaders[type] = paths;
}
loadPlugins() {
var _this = this;
return _asyncToGenerator(function* () {
let relative = Path.join(_this.options.rootDir, 'index');
let pkg = yield config.load(relative, ['package.json']);
if (!pkg) {
return;
}
try {
let deps = Object.assign({}, pkg.dependencies, pkg.devDependencies);
for (let dep in deps) {
const pattern = /^(@.*\/)?parcel-plugin-.+/;
if (pattern.test(dep)) {
let plugin = yield localRequire(dep, relative);
yield plugin(_this);
}
}
} catch (err) {
logger.warn(err);
}
})();
}
bundle() {
var _this2 = this;
return _asyncToGenerator(function* () {
// If another bundle is already pending, wait for that one to finish and retry.
if (_this2.pending) {
return new Promise(function (resolve, reject) {
_this2.once('buildEnd', function () {
_this2.bundle().then(resolve, reject);
});
});
}
let isInitialBundle = !_this2.entryAssets;
let startTime = Date.now();
_this2.pending = true;
_this2.errored = false;
logger.clear();
logger.status(emoji.progress, 'Building...');
try {
// Start worker farm, watcher, etc. if needed
yield _this2.start();
// If this is the initial bundle, ensure the output directory exists, and resolve the main asset.
if (isInitialBundle) {
yield fs.mkdirp(_this2.options.outDir);
_this2.entryAssets = new Set();
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = _this2.entryFiles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let entry = _step.value;
let asset = yield _this2.resolveAsset(entry);
_this2.buildQueue.add(asset);
_this2.entryAssets.add(asset);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
// Build the queued assets.
let loadedAssets = yield _this2.buildQueue.run();
// The changed assets are any that don't have a parent bundle yet
// plus the ones that were in the build queue.
let changedAssets = [..._this2.findOrphanAssets(), ...loadedAssets];
// Invalidate bundles
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = _this2.loadedAssets.values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
let asset = _step2.value;
asset.invalidateBundle();
}
// Create a root bundle to hold all of the entry assets, and add them to the tree.
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
_this2.mainBundle = new Bundle();
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = _this2.entryAssets[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
let asset = _step3.value;
_this2.createBundleTree(asset, _this2.mainBundle);
}
// If there is only one child bundle, replace the root with that bundle.
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
if (_this2.mainBundle.childBundles.size === 1) {
_this2.mainBundle = Array.from(_this2.mainBundle.childBundles)[0];
}
// Generate the final bundle names, and replace references in the built assets.
_this2.bundleNameMap = _this2.mainBundle.getBundleNameMap(_this2.options.contentHash);
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
try {
for (var _iterator4 = changedAssets[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
let asset = _step4.value;
asset.replaceBundleNames(_this2.bundleNameMap);
}
// Emit an HMR update if this is not the initial bundle.
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4.return) {
_iterator4.return();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
}
}
if (_this2.hmr && !isInitialBundle) {
_this2.hmr.emitUpdate(changedAssets);
}
// Package everything up
_this2.bundleHashes = yield _this2.mainBundle.package(_this2, _this2.bundleHashes);
// Unload any orphaned assets
_this2.unloadOrphanedAssets();
let buildTime = Date.now() - startTime;
let time = prettifyTime(buildTime);
logger.status(emoji.success, `Built in ${time}.`, 'green');
if (!_this2.watcher) {
bundleReport(_this2.mainBundle, _this2.options.detailedReport);
}
_this2.emit('bundled', _this2.mainBundle);
return _this2.mainBundle;
} catch (err) {
_this2.errored = true;
logger.error(err);
if (_this2.hmr) {
_this2.hmr.emitError(err);
}
if (process.env.NODE_ENV === 'production') {
process.exitCode = 1;
} else if (process.env.NODE_ENV === 'test' && !_this2.hmr) {
throw err;
}
} finally {
_this2.pending = false;
_this2.emit('buildEnd');
// If not in watch mode, stop the worker farm so we don't keep the process running.
if (!_this2.watcher && _this2.options.killWorkers) {
_this2.stop();
}
}
})();
}
start() {
var _this3 = this;
return _asyncToGenerator(function* () {
if (_this3.farm) {
return;
}
yield _this3.loadPlugins();
yield loadEnv(Path.join(_this3.options.rootDir, 'index'));
_this3.options.extensions = Object.assign({}, _this3.parser.extensions);
_this3.options.bundleLoaders = _this3.bundleLoaders;
_this3.options.env = process.env;
if (_this3.options.watch) {
_this3.watcher = new Watcher();
_this3.watcher.on('change', _this3.onChange.bind(_this3));
}
if (_this3.options.hmr) {
_this3.hmr = new HMRServer();
_this3.options.hmrPort = yield _this3.hmr.start(_this3.options);
}
_this3.farm = WorkerFarm.getShared(_this3.options);
})();
}
stop() {
if (this.farm) {
this.farm.end();
}
if (this.watcher) {
this.watcher.stop();
}
if (this.hmr) {
this.hmr.stop();
}
}
getAsset(name, parent) {
var _this4 = this;
return _asyncToGenerator(function* () {
let asset = yield _this4.resolveAsset(name, parent);
_this4.buildQueue.add(asset);
yield _this4.buildQueue.run();
return asset;
})();
}
resolveAsset(name, parent) {
var _this5 = this;
return _asyncToGenerator(function* () {
var _ref = yield _this5.resolver.resolve(name, parent);
let path = _ref.path,
pkg = _ref.pkg;
if (_this5.loadedAssets.has(path)) {
return _this5.loadedAssets.get(path);
}
let asset = _this5.parser.getAsset(path, pkg, _this5.options);
_this5.loadedAssets.set(path, asset);
_this5.watch(path, asset);
return asset;
})();
}
watch(path, asset) {
if (!this.watcher) {
return;
}
if (!this.watchedAssets.has(path)) {
this.watcher.watch(path);
this.watchedAssets.set(path, new Set());
}
this.watchedAssets.get(path).add(asset);
}
unwatch(path, asset) {
if (!this.watchedAssets.has(path)) {
return;
}
let watched = this.watchedAssets.get(path);
watched.delete(asset);
if (watched.size === 0) {
this.watchedAssets.delete(path);
this.watcher.unwatch(path);
}
}
resolveDep(asset, dep, install = true) {
var _this6 = this;
return _asyncToGenerator(function* () {
try {
return yield _this6.resolveAsset(dep.name, asset.name);
} catch (err) {
// If the dep is optional, return before we throw
if (dep.optional) {
return;
}
if (err.code === 'MODULE_NOT_FOUND') {
let isLocalFile = /^[/~.]/.test(dep.name);
let fromNodeModules = asset.name.includes(`${Path.sep}node_modules${Path.sep}`);
if (!isLocalFile && !fromNodeModules && _this6.options.autoinstall && install) {
return yield _this6.installDep(asset, dep);
}
err.message = `Cannot resolve dependency '${dep.name}'`;
if (isLocalFile) {
const absPath = Path.resolve(Path.dirname(asset.name), dep.name);
err.message += ` at '${absPath}'`;
}
yield _this6.throwDepError(asset, dep, err);
}
throw err;
}
})();
}
installDep(asset, dep) {
var _this7 = this;
return _asyncToGenerator(function* () {
// Check if module exists, prevents useless installs
let resolved = yield _this7.resolver.resolveModule(dep.name, asset.name);
// If the module resolved (i.e. wasn't a local file), but the module directory wasn't found, install it.
if (resolved.moduleName && !resolved.moduleDir) {
try {
yield installPackage([resolved.moduleName], asset.name, {
saveDev: false
});
} catch (err) {
yield _this7.throwDepError(asset, dep, err);
}
}
return yield _this7.resolveDep(asset, dep, false);
})();
}
throwDepError(asset, dep, err) {
return _asyncToGenerator(function* () {
// Generate a code frame where the dependency was used
if (dep.loc) {
yield asset.loadIfNeeded();
err.loc = dep.loc;
err = asset.generateErrorMessage(err);
}
err.fileName = asset.name;
throw err;
})();
}
processAsset(asset, isRebuild) {
var _this8 = this;
return _asyncToGenerator(function* () {
if (isRebuild) {
asset.invalidate();
if (_this8.cache) {
_this8.cache.invalidate(asset.name);
}
}
yield _this8.loadAsset(asset);
})();
}
loadAsset(asset) {
var _this9 = this;
return _asyncToGenerator(function* () {
if (asset.processed) {
return;
}
if (!_this9.errored) {
logger.status(emoji.progress, `Building ${asset.basename}...`);
}
// Mark the asset processed so we don't load it twice
asset.processed = true;
// First try the cache, otherwise load and compile in the background
let startTime = Date.now();
let processed = _this9.cache && (yield _this9.cache.read(asset.name));
if (!processed || asset.shouldInvalidate(processed.cacheData)) {
processed = yield _this9.farm.run(asset.name, asset.package, _this9.options);
if (_this9.cache) {
_this9.cache.write(asset.name, processed);
}
}
asset.buildTime = Date.now() - startTime;
asset.generated = processed.generated;
asset.hash = processed.hash;
// Call the delegate to get implicit dependencies
let dependencies = processed.dependencies;
if (_this9.delegate.getImplicitDependencies) {
let implicitDeps = yield _this9.delegate.getImplicitDependencies(asset);
if (implicitDeps) {
dependencies = dependencies.concat(implicitDeps);
}
}
// Resolve and load asset dependencies
let assetDeps = yield Promise.all(dependencies.map((() => {
var _ref2 = _asyncToGenerator(function* (dep) {
if (dep.includedInParent) {
// This dependency is already included in the parent's generated output,
// so no need to load it. We map the name back to the parent asset so
// that changing it triggers a recompile of the parent.
_this9.watch(dep.name, asset);
} else {
let assetDep = yield _this9.resolveDep(asset, dep);
if (assetDep) {
yield _this9.loadAsset(assetDep);
}
return assetDep;
}
});
return function (_x) {
return _ref2.apply(this, arguments);
};
})()));
// Store resolved assets in their original order
dependencies.forEach(function (dep, i) {
asset.dependencies.set(dep.name, dep);
let assetDep = assetDeps[i];
if (assetDep) {
asset.depAssets.set(dep, assetDep);
}
});
})();
}
createBundleTree(asset, bundle, dep, parentBundles = new Set()) {
if (dep) {
asset.parentDeps.add(dep);
}
if (asset.parentBundle) {
// If the asset is already in a bundle, it is shared. Move it to the lowest common ancestor.
if (asset.parentBundle !== bundle) {
let commonBundle = bundle.findCommonAncestor(asset.parentBundle);
if (asset.parentBundle !== commonBundle && asset.parentBundle.type === commonBundle.type) {
this.moveAssetToBundle(asset, commonBundle);
return;
}
} else {
return;
}
// Detect circular bundles
if (parentBundles.has(asset.parentBundle)) {
return;
}
}
let isEntryAsset = asset.parentBundle && asset.parentBundle.entryAsset === asset;
if (dep && dep.dynamic || !bundle.type) {
// If the asset is already the entry asset of a bundle, don't create a duplicate.
if (isEntryAsset) {
return;
}
// Create a new bundle for dynamic imports
bundle = bundle.createChildBundle(asset);
} else if (asset.type && !this.packagers.has(asset.type)) {
// If the asset is already the entry asset of a bundle, don't create a duplicate.
if (isEntryAsset) {
return;
}
// No packager is available for this asset type. Create a new bundle with only this asset.
bundle.createSiblingBundle(asset);
} else {
// Add the asset to the common bundle of the asset's type
bundle.getSiblingBundle(asset.type).addAsset(asset);
}
// If the asset generated a representation for the parent bundle type, also add it there
if (asset.generated[bundle.type] != null) {
bundle.addAsset(asset);
}
// Add the asset to sibling bundles for each generated type
if (asset.type && asset.generated[asset.type]) {
for (let t in asset.generated) {
if (asset.generated[t]) {
bundle.getSiblingBundle(t).addAsset(asset);
}
}
}
asset.parentBundle = bundle;
parentBundles.add(bundle);
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (var _iterator5 = asset.depAssets[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
let _ref3 = _step5.value;
var _ref4 = _slicedToArray(_ref3, 2);
let dep = _ref4[0];
let assetDep = _ref4[1];
this.createBundleTree(assetDep, bundle, dep, parentBundles);
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5.return) {
_iterator5.return();
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
}
}
}
parentBundles.delete(bundle);
return bundle;
}
moveAssetToBundle(asset, commonBundle) {
// Never move the entry asset of a bundle, as it was explicitly requested to be placed in a separate bundle.
if (asset.parentBundle.entryAsset === asset) {
return;
}
var _iteratorNormalCompletion6 = true;
var _didIteratorError6 = false;
var _iteratorError6 = undefined;
try {
for (var _iterator6 = Array.from(asset.bundles)[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
let bundle = _step6.value;
bundle.removeAsset(asset);
commonBundle.getSiblingBundle(bundle.type).addAsset(asset);
}
} catch (err) {
_didIteratorError6 = true;
_iteratorError6 = err;
} finally {
try {
if (!_iteratorNormalCompletion6 && _iterator6.return) {
_iterator6.return();
}
} finally {
if (_didIteratorError6) {
throw _iteratorError6;
}
}
}
let oldBundle = asset.parentBundle;
asset.parentBundle = commonBundle;
// Move all dependencies as well
var _iteratorNormalCompletion7 = true;
var _didIteratorError7 = false;
var _iteratorError7 = undefined;
try {
for (var _iterator7 = asset.depAssets.values()[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
let child = _step7.value;
if (child.parentBundle === oldBundle) {
this.moveAssetToBundle(child, commonBundle);
}
}
} catch (err) {
_didIteratorError7 = true;
_iteratorError7 = err;
} finally {
try {
if (!_iteratorNormalCompletion7 && _iterator7.return) {
_iterator7.return();
}
} finally {
if (_didIteratorError7) {
throw _iteratorError7;
}
}
}
}
*findOrphanAssets() {
var _iteratorNormalCompletion8 = true;
var _didIteratorError8 = false;
var _iteratorError8 = undefined;
try {
for (var _iterator8 = this.loadedAssets.values()[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
let asset = _step8.value;
if (!asset.parentBundle) {
yield asset;
}
}
} catch (err) {
_didIteratorError8 = true;
_iteratorError8 = err;
} finally {
try {
if (!_iteratorNormalCompletion8 && _iterator8.return) {
_iterator8.return();
}
} finally {
if (_didIteratorError8) {
throw _iteratorError8;
}
}
}
}
unloadOrphanedAssets() {
var _iteratorNormalCompletion9 = true;
var _didIteratorError9 = false;
var _iteratorError9 = undefined;
try {
for (var _iterator9 = this.findOrphanAssets()[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
let asset = _step9.value;
this.unloadAsset(asset);
}
} catch (err) {
_didIteratorError9 = true;
_iteratorError9 = err;
} finally {
try {
if (!_iteratorNormalCompletion9 && _iterator9.return) {
_iterator9.return();
}
} finally {
if (_didIteratorError9) {
throw _iteratorError9;
}
}
}
}
unloadAsset(asset) {
this.loadedAssets.delete(asset.name);
if (this.watcher) {
this.unwatch(asset.name, asset);
// Unwatch all included dependencies that map to this asset
var _iteratorNormalCompletion10 = true;
var _didIteratorError10 = false;
var _iteratorError10 = undefined;
try {
for (var _iterator10 = asset.dependencies.values()[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
let dep = _step10.value;
if (dep.includedInParent) {
this.unwatch(dep.name, asset);
}
}
} catch (err) {
_didIteratorError10 = true;
_iteratorError10 = err;
} finally {
try {
if (!_iteratorNormalCompletion10 && _iterator10.return) {
_iterator10.return();
}
} finally {
if (_didIteratorError10) {
throw _iteratorError10;
}
}
}
}
}
onChange(path) {
var _this10 = this;
return _asyncToGenerator(function* () {
let assets = _this10.watchedAssets.get(path);
if (!assets || !assets.size) {
return;
}
logger.clear();
logger.status(emoji.progress, `Building ${Path.basename(path)}...`);
// Add the asset to the rebuild queue, and reset the timeout.
var _iteratorNormalCompletion11 = true;
var _didIteratorError11 = false;
var _iteratorError11 = undefined;
try {
for (var _iterator11 = assets[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
let asset = _step11.value;
_this10.buildQueue.add(asset, true);
}
} catch (err) {
_didIteratorError11 = true;
_iteratorError11 = err;
} finally {
try {
if (!_iteratorNormalCompletion11 && _iterator11.return) {
_iterator11.return();
}
} finally {
if (_didIteratorError11) {
throw _iteratorError11;
}
}
}
clearTimeout(_this10.rebuildTimeout);
_this10.rebuildTimeout = setTimeout(_asyncToGenerator(function* () {
yield _this10.bundle();
}), 100);
})();
}
middleware() {
this.bundle();
return Server.middleware(this);
}
serve(port = 1234, https = false) {
var _this11 = this;
return _asyncToGenerator(function* () {
_this11.server = yield Server.serve(_this11, port, https);
_this11.bundle();
return _this11.server;
})();
}
}
module.exports = Bundler;
Bundler.Asset = require('./Asset');
Bundler.Packager = require('./packagers/Packager');

174
VISUALIZACION/node_modules/parcel-bundler/lib/FSCache.js generated vendored Executable file
View file

@ -0,0 +1,174 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const fs = require('./utils/fs');
const path = require('path');
const md5 = require('./utils/md5');
const objectHash = require('./utils/objectHash');
const pkg = require('../package.json');
const logger = require('./Logger');
// These keys can affect the output, so if they differ, the cache should not match
const OPTION_KEYS = ['publicURL', 'minify', 'hmr', 'target'];
class FSCache {
constructor(options) {
this.dir = path.resolve(options.cacheDir || '.cache');
this.dirExists = false;
this.invalidated = new Set();
this.optionsHash = objectHash(OPTION_KEYS.reduce((p, k) => (p[k] = options[k], p), {
version: pkg.version
}));
}
ensureDirExists() {
var _this = this;
return _asyncToGenerator(function* () {
yield fs.mkdirp(_this.dir);
_this.dirExists = true;
})();
}
getCacheFile(filename) {
let hash = md5(this.optionsHash + filename);
return path.join(this.dir, hash + '.json');
}
writeDepMtimes(data) {
return _asyncToGenerator(function* () {
// Write mtimes for each dependent file that is already compiled into this asset
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = data.dependencies[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let dep = _step.value;
if (dep.includedInParent) {
let stats = yield fs.stat(dep.name);
dep.mtime = stats.mtime.getTime();
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
})();
}
write(filename, data) {
var _this2 = this;
return _asyncToGenerator(function* () {
try {
yield _this2.ensureDirExists();
yield _this2.writeDepMtimes(data);
yield fs.writeFile(_this2.getCacheFile(filename), JSON.stringify(data));
_this2.invalidated.delete(filename);
} catch (err) {
logger.error('Error writing to cache', err);
}
})();
}
checkDepMtimes(data) {
return _asyncToGenerator(function* () {
// Check mtimes for files that are already compiled into this asset
// If any of them changed, invalidate.
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = data.dependencies[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
let dep = _step2.value;
if (dep.includedInParent) {
let stats = yield fs.stat(dep.name);
if (stats.mtime > dep.mtime) {
return false;
}
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return true;
})();
}
read(filename) {
var _this3 = this;
return _asyncToGenerator(function* () {
if (_this3.invalidated.has(filename)) {
return null;
}
let cacheFile = _this3.getCacheFile(filename);
try {
let stats = yield fs.stat(filename);
let cacheStats = yield fs.stat(cacheFile);
if (stats.mtime > cacheStats.mtime) {
return null;
}
let json = yield fs.readFile(cacheFile);
let data = JSON.parse(json);
if (!(yield _this3.checkDepMtimes(data))) {
return null;
}
return data;
} catch (err) {
return null;
}
})();
}
invalidate(filename) {
this.invalidated.add(filename);
}
delete(filename) {
var _this4 = this;
return _asyncToGenerator(function* () {
try {
yield fs.unlink(_this4.getCacheFile(filename));
_this4.invalidated.delete(filename);
} catch (err) {
// Fail silently
}
})();
}
}
module.exports = FSCache;

172
VISUALIZACION/node_modules/parcel-bundler/lib/HMRServer.js generated vendored Executable file
View file

@ -0,0 +1,172 @@
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const http = require('http');
const https = require('https');
const WebSocket = require('ws');
const prettyError = require('./utils/prettyError');
const generateCertificate = require('./utils/generateCertificate');
const getCertificate = require('./utils/getCertificate');
const logger = require('./Logger');
class HMRServer {
start(options = {}) {
var _this = this;
return _asyncToGenerator(function* () {
yield new Promise((() => {
var _ref = _asyncToGenerator(function* (resolve) {
if (!options.https) {
_this.server = http.createServer();
} else if (typeof options.https === 'boolean') {
_this.server = https.createServer(generateCertificate(options));
} else {
_this.server = https.createServer((yield getCertificate(options.https)));
}
_this.wss = new WebSocket.Server({ server: _this.server });
_this.server.listen(options.hmrPort, resolve);
});
return function (_x) {
return _ref.apply(this, arguments);
};
})());
_this.wss.on('connection', function (ws) {
ws.onerror = _this.handleSocketError;
if (_this.unresolvedError) {
ws.send(JSON.stringify(_this.unresolvedError));
}
});
_this.wss.on('error', _this.handleSocketError);
return _this.wss._server.address().port;
})();
}
stop() {
this.wss.close();
this.server.close();
}
emitError(err) {
var _prettyError = prettyError(err);
let message = _prettyError.message,
stack = _prettyError.stack;
// store the most recent error so we can notify new connections
// and so we can broadcast when the error is resolved
this.unresolvedError = {
type: 'error',
error: {
message,
stack
}
};
this.broadcast(this.unresolvedError);
}
emitUpdate(assets) {
if (this.unresolvedError) {
this.unresolvedError = null;
this.broadcast({
type: 'error-resolved'
});
}
const containsHtmlAsset = assets.some(asset => asset.type === 'html');
if (containsHtmlAsset) {
this.broadcast({
type: 'reload'
});
} else {
this.broadcast({
type: 'update',
assets: assets.map(asset => {
let deps = {};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = asset.depAssets[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let _ref2 = _step.value;
var _ref3 = _slicedToArray(_ref2, 2);
let dep = _ref3[0];
let depAsset = _ref3[1];
deps[dep.name] = depAsset.id;
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return {
id: asset.id,
generated: asset.generated,
deps: deps
};
})
});
}
}
handleSocketError(err) {
if (err.error.code === 'ECONNRESET') {
// This gets triggered on page refresh, ignore this
return;
}
logger.warn(err);
}
broadcast(msg) {
const json = JSON.stringify(msg);
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = this.wss.clients[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
let ws = _step2.value;
ws.send(json);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
}
module.exports = HMRServer;

300
VISUALIZACION/node_modules/parcel-bundler/lib/Logger.js generated vendored Executable file
View file

@ -0,0 +1,300 @@
'use strict';
const chalk = require('chalk');
const readline = require('readline');
const prettyError = require('./utils/prettyError');
const emoji = require('./utils/emoji');
var _require = require('grapheme-breaker');
const countBreaks = _require.countBreaks;
const stripAnsi = require('strip-ansi');
class Logger {
constructor(options) {
this.lines = 0;
this.statusLine = null;
this.setOptions(options);
}
setOptions(options) {
this.logLevel = options && isNaN(options.logLevel) === false ? Number(options.logLevel) : 3;
this.color = options && typeof options.color === 'boolean' ? options.color : chalk.supportsColor;
this.chalk = new chalk.constructor({ enabled: this.color });
this.isTest = options && typeof options.isTest === 'boolean' ? options.isTest : process.env.NODE_ENV === 'test';
}
countLines(message) {
return message.split('\n').reduce((p, line) => {
if (process.stdout.columns) {
return p + Math.ceil((line.length || 1) / process.stdout.columns);
}
return p + 1;
}, 0);
}
writeRaw(message) {
this.lines += this.countLines(message) - 1;
process.stdout.write(message);
}
write(message, persistent = false) {
if (!persistent) {
this.lines += this.countLines(message);
}
this._log(message);
}
log(message) {
if (this.logLevel < 3) {
return;
}
this.write(message);
}
persistent(message) {
if (this.logLevel < 3) {
return;
}
this.write(this.chalk.bold(message), true);
}
warn(err) {
if (this.logLevel < 2) {
return;
}
var _prettyError = prettyError(err, { color: this.color });
let message = _prettyError.message,
stack = _prettyError.stack;
this.write(this.chalk.yellow(`${emoji.warning} ${message}`));
if (stack) {
this.write(stack);
}
}
error(err) {
if (this.logLevel < 1) {
return;
}
var _prettyError2 = prettyError(err, { color: this.color });
let message = _prettyError2.message,
stack = _prettyError2.stack;
this.status(emoji.error, message, 'red');
if (stack) {
this.write(stack);
}
}
clear() {
if (!this.color || this.isTest) {
return;
}
while (this.lines > 0) {
readline.clearLine(process.stdout, 0);
readline.moveCursor(process.stdout, 0, -1);
this.lines--;
}
readline.cursorTo(process.stdout, 0);
this.statusLine = null;
}
writeLine(line, msg) {
if (!this.color) {
return this.log(msg);
}
let n = this.lines - line;
let stdout = process.stdout;
readline.cursorTo(stdout, 0);
readline.moveCursor(stdout, 0, -n);
stdout.write(msg);
readline.clearLine(stdout, 1);
readline.cursorTo(stdout, 0);
readline.moveCursor(stdout, 0, n);
}
status(emoji, message, color = 'gray') {
if (this.logLevel < 3) {
return;
}
let hasStatusLine = this.statusLine != null;
if (!hasStatusLine) {
this.statusLine = this.lines;
}
this.writeLine(this.statusLine, this.chalk[color].bold(`${emoji} ${message}`));
if (!hasStatusLine) {
process.stdout.write('\n');
this.lines++;
}
}
handleMessage(options) {
this[options.method](...options.args);
}
_log(message) {
console.log(message);
}
table(columns, table) {
// Measure column widths
let colWidths = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = table[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let row = _step.value;
let i = 0;
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = row[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
let item = _step3.value;
colWidths[i] = Math.max(colWidths[i] || 0, stringWidth(item));
i++;
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
}
// Render rows
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = table[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
let row = _step2.value;
let items = row.map((item, i) => {
// Add padding between columns unless the alignment is the opposite to the
// next column and pad to the column width.
let padding = !columns[i + 1] || columns[i + 1].align === columns[i].align ? 4 : 0;
return pad(item, colWidths[i] + padding, columns[i].align);
});
this.log(items.join(''));
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
}
// Pad a string with spaces on either side
function pad(text, length, align = 'left') {
let pad = ' '.repeat(length - stringWidth(text));
if (align === 'right') {
return pad + text;
}
return text + pad;
}
// Count visible characters in a string
function stringWidth(string) {
return countBreaks(stripAnsi('' + string));
}
// If we are in a worker, make a proxy class which will
// send the logger calls to the main process via IPC.
// These are handled in WorkerFarm and directed to handleMessage above.
if (process.send && process.env.WORKER_TYPE === 'parcel-worker') {
const worker = require('./worker');
class LoggerProxy {}
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
try {
for (var _iterator4 = Object.getOwnPropertyNames(Logger.prototype)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
let method = _step4.value;
LoggerProxy.prototype[method] = (...args) => {
worker.addCall({
location: require.resolve('./Logger'),
method,
args
}, false);
};
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4.return) {
_iterator4.return();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
}
}
module.exports = new LoggerProxy();
} else {
module.exports = new Logger();
}

87
VISUALIZACION/node_modules/parcel-bundler/lib/Parser.js generated vendored Executable file
View file

@ -0,0 +1,87 @@
'use strict';
const path = require('path');
const RawAsset = require('./assets/RawAsset');
const GlobAsset = require('./assets/GlobAsset');
const glob = require('glob');
class Parser {
constructor(options = {}) {
this.extensions = {};
this.registerExtension('js', './assets/JSAsset');
this.registerExtension('jsx', './assets/JSAsset');
this.registerExtension('es6', './assets/JSAsset');
this.registerExtension('jsm', './assets/JSAsset');
this.registerExtension('mjs', './assets/JSAsset');
this.registerExtension('ml', './assets/ReasonAsset');
this.registerExtension('re', './assets/ReasonAsset');
this.registerExtension('ts', './assets/TypeScriptAsset');
this.registerExtension('tsx', './assets/TypeScriptAsset');
this.registerExtension('coffee', './assets/CoffeeScriptAsset');
this.registerExtension('vue', './assets/VueAsset');
this.registerExtension('json', './assets/JSONAsset');
this.registerExtension('json5', './assets/JSONAsset');
this.registerExtension('yaml', './assets/YAMLAsset');
this.registerExtension('yml', './assets/YAMLAsset');
this.registerExtension('toml', './assets/TOMLAsset');
this.registerExtension('gql', './assets/GraphqlAsset');
this.registerExtension('graphql', './assets/GraphqlAsset');
this.registerExtension('css', './assets/CSSAsset');
this.registerExtension('pcss', './assets/CSSAsset');
this.registerExtension('styl', './assets/StylusAsset');
this.registerExtension('stylus', './assets/StylusAsset');
this.registerExtension('less', './assets/LESSAsset');
this.registerExtension('sass', './assets/SASSAsset');
this.registerExtension('scss', './assets/SASSAsset');
this.registerExtension('html', './assets/HTMLAsset');
this.registerExtension('htm', './assets/HTMLAsset');
this.registerExtension('rs', './assets/RustAsset');
this.registerExtension('webmanifest', './assets/WebManifestAsset');
this.registerExtension('glsl', './assets/GLSLAsset');
this.registerExtension('vert', './assets/GLSLAsset');
this.registerExtension('frag', './assets/GLSLAsset');
this.registerExtension('jade', './assets/PugAsset');
this.registerExtension('pug', './assets/PugAsset');
let extensions = options.extensions || {};
for (let ext in extensions) {
this.registerExtension(ext, extensions[ext]);
}
}
registerExtension(ext, parser) {
if (!ext.startsWith('.')) {
ext = '.' + ext;
}
this.extensions[ext.toLowerCase()] = parser;
}
findParser(filename) {
if (/[*+{}]/.test(filename) && glob.hasMagic(filename)) {
return GlobAsset;
}
let extension = path.extname(filename).toLowerCase();
let parser = this.extensions[extension] || RawAsset;
if (typeof parser === 'string') {
parser = this.extensions[extension] = require(parser);
}
return parser;
}
getAsset(filename, pkg, options = {}) {
let Asset = this.findParser(filename);
options.parser = this;
return new Asset(filename, pkg, options);
}
}
module.exports = Parser;

156
VISUALIZACION/node_modules/parcel-bundler/lib/Pipeline.js generated vendored Executable file
View file

@ -0,0 +1,156 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Parser = require('./Parser');
const path = require('path');
const md5 = require('./utils/md5');
/**
* A Pipeline composes multiple Asset types together.
*/
class Pipeline {
constructor(options) {
this.options = options;
this.parser = new Parser(options);
}
process(path, pkg, options) {
var _this = this;
return _asyncToGenerator(function* () {
let asset = _this.parser.getAsset(path, pkg, options);
let generated = yield _this.processAsset(asset);
let generatedMap = {};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = generated[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let rendition = _step.value;
generatedMap[rendition.type] = rendition.value;
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return {
dependencies: Array.from(asset.dependencies.values()),
generated: generatedMap,
hash: asset.hash,
cacheData: asset.cacheData
};
})();
}
processAsset(asset) {
var _this2 = this;
return _asyncToGenerator(function* () {
try {
yield asset.process();
} catch (err) {
throw asset.generateErrorMessage(err);
}
let inputType = path.extname(asset.name).slice(1);
let generated = [];
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = _this2.iterateRenditions(asset)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
let rendition = _step2.value;
let type = rendition.type,
value = rendition.value;
if (typeof value !== 'string' || rendition.final) {
generated.push(rendition);
continue;
}
// Find an asset type for the rendition type.
// If the asset is not already an instance of this asset type, process it.
let AssetType = _this2.parser.findParser(asset.name.slice(0, -inputType.length) + type);
if (!(asset instanceof AssetType)) {
let opts = Object.assign({ rendition }, asset.options);
let subAsset = new AssetType(asset.name, asset.package, opts);
subAsset.contents = value;
subAsset.dependencies = asset.dependencies;
let processed = yield _this2.processAsset(subAsset);
generated = generated.concat(processed);
Object.assign(asset.cacheData, subAsset.cacheData);
asset.hash = md5(asset.hash + subAsset.hash);
} else {
generated.push(rendition);
}
}
// Post process. This allows assets a chance to modify the output produced by sub-asset types.
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
asset.generated = generated;
try {
generated = yield asset.postProcess(generated);
} catch (err) {
throw asset.generateErrorMessage(err);
}
return generated;
})();
}
*iterateRenditions(asset) {
if (Array.isArray(asset.generated)) {
return yield* asset.generated;
}
if (typeof asset.generated === 'string') {
return yield {
type: asset.type,
value: asset.generated
};
}
// Backward compatibility support for the old API.
// Assume all renditions are final - don't compose asset types together.
for (let type in asset.generated) {
yield {
type,
value: asset.generated[type],
final: true
};
}
}
}
module.exports = Pipeline;

503
VISUALIZACION/node_modules/parcel-bundler/lib/Resolver.js generated vendored Executable file
View file

@ -0,0 +1,503 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const builtins = require('./builtins');
const path = require('path');
const glob = require('glob');
const fs = require('./utils/fs');
const micromatch = require('micromatch');
const EMPTY_SHIM = require.resolve('./builtins/_empty');
const GLOB_RE = /[*+{}]/;
/**
* This resolver implements a modified version of the node_modules resolution algorithm:
* https://nodejs.org/api/modules.html#modules_all_together
*
* In addition to the standard algorithm, Parcel supports:
* - All file extensions supported by Parcel.
* - Glob file paths
* - Absolute paths (e.g. /foo) resolved relative to the project root.
* - Tilde paths (e.g. ~/foo) resolved relative to the nearest module root in node_modules.
* - The package.json module, jsnext:main, and browser field as replacements for package.main.
* - The package.json browser and alias fields as an alias map within a local module.
* - The package.json alias field in the root package for global aliases across all modules.
*/
class Resolver {
constructor(options = {}) {
this.options = options;
this.cache = new Map();
this.packageCache = new Map();
this.rootPackage = null;
}
resolve(input, parent) {
var _this = this;
return _asyncToGenerator(function* () {
let filename = input;
// Check the cache first
let key = _this.getCacheKey(filename, parent);
if (_this.cache.has(key)) {
return _this.cache.get(key);
}
// Check if this is a glob
if (GLOB_RE.test(filename) && glob.hasMagic(filename)) {
return { path: path.resolve(path.dirname(parent), filename) };
}
// Get file extensions to search
let extensions = Array.isArray(_this.options.extensions) ? _this.options.extensions.slice() : Object.keys(_this.options.extensions);
if (parent) {
// parent's extension given high priority
const parentExt = path.extname(parent);
extensions = [parentExt, ...extensions.filter(function (ext) {
return ext !== parentExt;
})];
}
extensions.unshift('');
// Resolve the module directory or local file path
let module = yield _this.resolveModule(filename, parent);
let resolved;
if (module.moduleDir) {
resolved = yield _this.loadNodeModules(module, extensions);
} else if (module.filePath) {
resolved = yield _this.loadRelative(module.filePath, extensions);
}
if (!resolved) {
let dir = parent ? path.dirname(parent) : process.cwd();
let err = new Error(`Cannot find module '${input}' from '${dir}'`);
err.code = 'MODULE_NOT_FOUND';
throw err;
}
_this.cache.set(key, resolved);
return resolved;
})();
}
resolveModule(filename, parent) {
var _this2 = this;
return _asyncToGenerator(function* () {
let dir = parent ? path.dirname(parent) : process.cwd();
// If this isn't the entrypoint, resolve the input file to an absolute path
if (parent) {
filename = _this2.resolveFilename(filename, dir);
}
// Resolve aliases in the parent module for this file.
filename = yield _this2.loadAlias(filename, dir);
// Return just the file path if this is a file, not in node_modules
if (path.isAbsolute(filename)) {
return {
filePath: filename
};
}
// Resolve the module in node_modules
let resolved;
try {
resolved = yield _this2.findNodeModulePath(filename, dir);
} catch (err) {}
// ignore
// If we couldn't resolve the node_modules path, just return the module name info
if (!resolved) {
let parts = _this2.getModuleParts(filename);
resolved = {
moduleName: parts[0],
subPath: parts[1]
};
}
return resolved;
})();
}
getCacheKey(filename, parent) {
return (parent ? path.dirname(parent) : '') + ':' + filename;
}
resolveFilename(filename, dir) {
switch (filename[0]) {
case '/':
// Absolute path. Resolve relative to project root.
return path.resolve(this.options.rootDir, filename.slice(1));
case '~':
// Tilde path. Resolve relative to nearest node_modules directory,
// or the project root - whichever comes first.
while (dir !== this.options.rootDir && path.basename(path.dirname(dir)) !== 'node_modules') {
dir = path.dirname(dir);
}
return path.join(dir, filename.slice(1));
case '.':
// Relative path.
return path.resolve(dir, filename);
default:
// Module
return path.normalize(filename);
}
}
loadRelative(filename, extensions) {
var _this3 = this;
return _asyncToGenerator(function* () {
// Find a package.json file in the current package.
let pkg = yield _this3.findPackage(path.dirname(filename));
// First try as a file, then as a directory.
return (yield _this3.loadAsFile(filename, extensions, pkg)) || (yield _this3.loadDirectory(filename, extensions, pkg));
})();
}
findNodeModulePath(filename, dir) {
var _this4 = this;
return _asyncToGenerator(function* () {
if (builtins[filename]) {
return { filePath: builtins[filename] };
}
let parts = _this4.getModuleParts(filename);
let root = path.parse(dir).root;
while (dir !== root) {
// Skip node_modules directories
if (path.basename(dir) === 'node_modules') {
dir = path.dirname(dir);
}
try {
// First, check if the module directory exists. This prevents a lot of unnecessary checks later.
let moduleDir = path.join(dir, 'node_modules', parts[0]);
let stats = yield fs.stat(moduleDir);
if (stats.isDirectory()) {
return {
moduleName: parts[0],
subPath: parts[1],
moduleDir: moduleDir,
filePath: path.join(dir, 'node_modules', filename)
};
}
} catch (err) {}
// ignore
// Move up a directory
dir = path.dirname(dir);
}
})();
}
loadNodeModules(module, extensions) {
var _this5 = this;
return _asyncToGenerator(function* () {
try {
// If a module was specified as a module sub-path (e.g. some-module/some/path),
// it is likely a file. Try loading it as a file first.
if (module.subPath) {
let pkg = yield _this5.readPackage(module.moduleDir);
let res = yield _this5.loadAsFile(module.filePath, extensions, pkg);
if (res) {
return res;
}
}
// Otherwise, load as a directory.
return yield _this5.loadDirectory(module.filePath, extensions);
} catch (e) {
// ignore
}
})();
}
isFile(file) {
return _asyncToGenerator(function* () {
try {
let stat = yield fs.stat(file);
return stat.isFile() || stat.isFIFO();
} catch (err) {
return false;
}
})();
}
loadDirectory(dir, extensions, pkg) {
var _this6 = this;
return _asyncToGenerator(function* () {
try {
pkg = yield _this6.readPackage(dir);
// First try loading package.main as a file, then try as a directory.
let main = _this6.getPackageMain(pkg);
let res = (yield _this6.loadAsFile(main, extensions, pkg)) || (yield _this6.loadDirectory(main, extensions, pkg));
if (res) {
return res;
}
} catch (err) {}
// ignore
// Fall back to an index file inside the directory.
return yield _this6.loadAsFile(path.join(dir, 'index'), extensions, pkg);
})();
}
readPackage(dir) {
var _this7 = this;
return _asyncToGenerator(function* () {
let file = path.join(dir, 'package.json');
if (_this7.packageCache.has(file)) {
return _this7.packageCache.get(file);
}
let json = yield fs.readFile(file, 'utf8');
let pkg = JSON.parse(json);
pkg.pkgfile = file;
pkg.pkgdir = dir;
// If the package has a `source` field, check if it is behind a symlink.
// If so, we treat the module as source code rather than a pre-compiled module.
if (pkg.source) {
let realpath = yield fs.realpath(file);
if (realpath === file) {
delete pkg.source;
}
}
_this7.packageCache.set(file, pkg);
return pkg;
})();
}
getPackageMain(pkg) {
// libraries like d3.js specifies node.js specific files in the "main" which breaks the build
// we use the "module" or "browser" field to get the full dependency tree if available.
// If this is a linked module with a `source` field, use that as the entry point.
let main = [pkg.source, pkg.module, pkg.browser, pkg.main].find(entry => typeof entry === 'string');
// Default to index file if no main field find
if (!main || main === '.' || main === './') {
main = 'index';
}
return path.resolve(pkg.pkgdir, main);
}
loadAsFile(file, extensions, pkg) {
var _this8 = this;
return _asyncToGenerator(function* () {
// Try all supported extensions
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = _this8.expandFile(file, extensions, pkg)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let f = _step.value;
if (yield _this8.isFile(f)) {
return { path: f, pkg };
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
})();
}
expandFile(file, extensions, pkg, expandAliases = true) {
// Expand extensions and aliases
let res = [];
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = extensions[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
let ext = _step2.value;
let f = file + ext;
if (expandAliases) {
let alias = this.resolveAliases(file + ext, pkg);
if (alias !== f) {
res = res.concat(this.expandFile(alias, extensions, pkg, false));
}
}
res.push(f);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return res;
}
resolveAliases(filename, pkg) {
// First resolve local package aliases, then project global ones.
return this.resolvePackageAliases(this.resolvePackageAliases(filename, pkg), this.rootPackage);
}
resolvePackageAliases(filename, pkg) {
if (!pkg) {
return filename;
}
// Resolve aliases in the package.source, package.alias, and package.browser fields.
return this.getAlias(filename, pkg.pkgdir, pkg.source) || this.getAlias(filename, pkg.pkgdir, pkg.alias) || this.getAlias(filename, pkg.pkgdir, pkg.browser) || filename;
}
getAlias(filename, dir, aliases) {
if (!filename || !aliases || typeof aliases !== 'object') {
return null;
}
let alias;
// If filename is an absolute path, get one relative to the package.json directory.
if (path.isAbsolute(filename)) {
filename = path.relative(dir, filename);
if (filename[0] !== '.') {
filename = './' + filename;
}
alias = this.lookupAlias(aliases, filename);
} else {
// It is a node_module. First try the entire filename as a key.
alias = aliases[filename];
if (alias == null) {
// If it didn't match, try only the module name.
let parts = this.getModuleParts(filename);
alias = aliases[parts[0]];
if (typeof alias === 'string') {
// Append the filename back onto the aliased module.
alias = path.join(alias, ...parts.slice(1));
}
}
}
// If the alias is set to `false`, return an empty file.
if (alias === false) {
return EMPTY_SHIM;
}
// If the alias is a relative path, then resolve
// relative to the package.json directory.
if (alias && alias[0] === '.') {
return path.resolve(dir, alias);
}
// Otherwise, assume the alias is a module
return alias;
}
lookupAlias(aliases, filename) {
// First, try looking up the exact filename
let alias = aliases[filename];
if (alias != null) {
return alias;
}
// Otherwise, try replacing glob keys
for (let key in aliases) {
if (GLOB_RE.test(key)) {
let re = micromatch.makeRe(key, { capture: true });
if (re.test(filename)) {
return filename.replace(re, aliases[key]);
}
}
}
}
findPackage(dir) {
var _this9 = this;
return _asyncToGenerator(function* () {
// Find the nearest package.json file within the current node_modules folder
let root = path.parse(dir).root;
while (dir !== root && path.basename(dir) !== 'node_modules') {
try {
return yield _this9.readPackage(dir);
} catch (err) {
// ignore
}
dir = path.dirname(dir);
}
})();
}
loadAlias(filename, dir) {
var _this10 = this;
return _asyncToGenerator(function* () {
// Load the root project's package.json file if we haven't already
if (!_this10.rootPackage) {
_this10.rootPackage = yield _this10.findPackage(_this10.options.rootDir);
}
// Load the local package, and resolve aliases
let pkg = yield _this10.findPackage(dir);
return _this10.resolveAliases(filename, pkg);
})();
}
getModuleParts(name) {
let parts = path.normalize(name).split(path.sep);
if (parts[0].charAt(0) === '@') {
// Scoped module (e.g. @scope/module). Merge the first two parts back together.
parts.splice(0, 2, `${parts[0]}/${parts[1]}`);
}
return parts;
}
}
module.exports = Resolver;

126
VISUALIZACION/node_modules/parcel-bundler/lib/Server.js generated vendored Executable file
View file

@ -0,0 +1,126 @@
'use strict';
let serve = (() => {
var _ref = _asyncToGenerator(function* (bundler, port, useHTTPS = false) {
let handler = middleware(bundler);
let server;
if (!useHTTPS) {
server = http.createServer(handler);
} else if (typeof useHTTPS === 'boolean') {
server = https.createServer(generateCertificate(bundler.options), handler);
} else {
server = https.createServer((yield getCertificate(useHTTPS)), handler);
}
let freePort = yield getPort({ port });
server.listen(freePort);
return new Promise(function (resolve, reject) {
server.on('error', function (err) {
logger.error(new Error(serverErrors(err, server.address().port)));
reject(err);
});
server.once('listening', function () {
let addon = server.address().port !== port ? `- ${logger.chalk.yellow(`configured port ${port} could not be used.`)}` : '';
logger.persistent(`Server running at ${logger.chalk.cyan(`${useHTTPS ? 'https' : 'http'}://localhost:${server.address().port}`)} ${addon}`);
resolve(server);
});
});
});
return function serve(_x, _x2) {
return _ref.apply(this, arguments);
};
})();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const http = require('http');
const https = require('https');
const serveStatic = require('serve-static');
const getPort = require('get-port');
const serverErrors = require('./utils/customErrors').serverErrors;
const generateCertificate = require('./utils/generateCertificate');
const getCertificate = require('./utils/getCertificate');
const logger = require('./Logger');
const path = require('path');
const url = require('url');
serveStatic.mime.define({
'application/wasm': ['wasm']
});
function setHeaders(res) {
enableCors(res);
}
function enableCors(res) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, HEAD, PUT, PATCH, POST, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Content-Type');
}
function middleware(bundler) {
const serve = serveStatic(bundler.options.outDir, {
index: false,
setHeaders: setHeaders
});
return function (req, res, next) {
// Wait for the bundler to finish bundling if needed
if (bundler.pending) {
bundler.once('bundled', respond);
} else {
respond();
}
function respond() {
var _url$parse = url.parse(req.url);
let pathname = _url$parse.pathname;
if (bundler.errored) {
return send500();
} else if (!pathname.startsWith(bundler.options.publicURL) || path.extname(pathname) === '') {
// If the URL doesn't start with the public path, or the URL doesn't
// have a file extension, send the main HTML bundle.
return sendIndex();
} else {
// Otherwise, serve the file from the dist folder
req.url = pathname.slice(bundler.options.publicURL.length);
return serve(req, res, send404);
}
}
function sendIndex() {
// If the main asset is an HTML file, serve it
if (bundler.mainBundle.type === 'html') {
req.url = `/${path.basename(bundler.mainBundle.name)}`;
serve(req, res, send404);
} else {
send404();
}
}
function send500() {
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
res.writeHead(500);
res.end('🚨 Build error, check the console for details.');
}
function send404() {
if (next) {
return next();
}
res.writeHead(404);
res.end();
}
};
}
exports.middleware = middleware;
exports.serve = serve;

270
VISUALIZACION/node_modules/parcel-bundler/lib/SourceMap.js generated vendored Executable file
View file

@ -0,0 +1,270 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
var _require = require('source-map');
const SourceMapConsumer = _require.SourceMapConsumer,
SourceMapGenerator = _require.SourceMapGenerator;
const lineCounter = require('./utils/lineCounter');
class SourceMap {
constructor(mappings, sources) {
this.mappings = this.purifyMappings(mappings);
this.sources = sources || {};
this.lineCount = null;
}
purifyMappings(mappings) {
if (Array.isArray(mappings)) {
return mappings.filter(mapping => {
return mapping && mapping.source && mapping.original && typeof mapping.original.line === 'number' && mapping.original.line > 0 && typeof mapping.original.column === 'number' && mapping.generated && typeof mapping.generated.line === 'number' && mapping.generated.line > 0 && typeof mapping.generated.column === 'number';
});
}
return [];
}
getConsumer(map) {
return _asyncToGenerator(function* () {
if (map instanceof SourceMapConsumer) {
return map;
}
map = typeof map === 'string' ? JSON.parse(map) : map;
return yield new SourceMapConsumer(map);
})();
}
addMap(map, lineOffset = 0, columnOffset = 0) {
var _this = this;
return _asyncToGenerator(function* () {
if (!(map instanceof SourceMap) && map.version) {
let consumer = yield _this.getConsumer(map);
consumer.eachMapping(function (mapping) {
_this.addConsumerMapping(mapping, lineOffset, columnOffset);
if (!_this.sources[mapping.source]) {
_this.sources[mapping.source] = consumer.sourceContentFor(mapping.source, true);
}
});
if (consumer.destroy) {
// Only needs to happen in source-map 0.7
consumer.destroy();
}
} else {
if (!map.eachMapping) {
map = new SourceMap(map.mappings, map.sources);
}
if (lineOffset === 0 && columnOffset === 0) {
_this.mappings = _this.mappings.concat(map.mappings);
} else {
map.eachMapping(function (mapping) {
_this.addMapping(mapping, lineOffset, columnOffset);
});
}
Object.keys(map.sources).forEach(function (sourceName) {
if (!_this.sources[sourceName]) {
_this.sources[sourceName] = map.sources[sourceName];
}
});
}
return _this;
})();
}
addMapping(mapping, lineOffset = 0, columnOffset = 0) {
mapping.generated = {
line: mapping.generated.line + lineOffset,
column: mapping.generated.column + columnOffset
};
this.mappings.push(mapping);
}
addConsumerMapping(mapping, lineOffset = 0, columnOffset = 0) {
if (!mapping.source || !mapping.originalLine || !mapping.originalColumn && mapping.originalColumn !== 0) {
return;
}
this.mappings.push({
source: mapping.source,
original: {
line: mapping.originalLine,
column: mapping.originalColumn
},
generated: {
line: mapping.generatedLine + lineOffset,
column: mapping.generatedColumn + columnOffset
},
name: mapping.name
});
}
eachMapping(callback) {
this.mappings.forEach(callback);
}
generateEmptyMap(sourceName, sourceContent) {
this.sources[sourceName] = sourceContent;
this.lineCount = lineCounter(sourceContent);
for (let line = 1; line < this.lineCount + 1; line++) {
this.addMapping({
source: sourceName,
original: {
line: line,
column: 0
},
generated: {
line: line,
column: 0
}
});
}
return this;
}
extendSourceMap(original, extension) {
var _this2 = this;
return _asyncToGenerator(function* () {
if (!(extension instanceof SourceMap)) {
extension = yield new SourceMap().addMap(extension);
}
if (!(original instanceof SourceMap)) {
original = yield _this2.getConsumer(original);
}
extension.eachMapping(function (mapping) {
let originalMapping = original.originalPositionFor({
line: mapping.original.line,
column: mapping.original.column
});
if (!originalMapping.line) {
return false;
}
_this2.addMapping({
source: originalMapping.source,
name: originalMapping.name,
original: {
line: originalMapping.line,
column: originalMapping.column
},
generated: {
line: mapping.generated.line,
column: mapping.generated.column
}
});
if (!_this2.sources[originalMapping.source]) {
_this2.sources[originalMapping.source] = original.sourceContentFor(originalMapping.source, true);
}
});
if (original.destroy) {
// Only needs to happen in source-map 0.7
original.destroy();
}
return _this2;
})();
}
findClosest(line, column, key = 'original') {
if (line < 1) {
throw new Error('Line numbers must be >= 1');
}
if (column < 0) {
throw new Error('Column numbers must be >= 0');
}
if (this.mappings.length < 1) {
return undefined;
}
let startIndex = 0;
let stopIndex = this.mappings.length - 1;
let middleIndex = Math.floor((stopIndex + startIndex) / 2);
while (startIndex < stopIndex && this.mappings[middleIndex][key].line !== line) {
if (line < this.mappings[middleIndex][key].line) {
stopIndex = middleIndex - 1;
} else if (line > this.mappings[middleIndex][key].line) {
startIndex = middleIndex + 1;
}
middleIndex = Math.floor((stopIndex + startIndex) / 2);
}
let mapping = this.mappings[middleIndex];
if (!mapping || mapping[key].line !== line) {
return this.mappings.length - 1;
}
while (middleIndex >= 1 && this.mappings[middleIndex - 1][key].line === line) {
middleIndex--;
}
while (middleIndex < this.mappings.length - 1 && this.mappings[middleIndex + 1][key].line === line && column > this.mappings[middleIndex][key].column) {
middleIndex++;
}
return middleIndex;
}
originalPositionFor(generatedPosition) {
let index = this.findClosest(generatedPosition.line, generatedPosition.column, 'generated');
return {
source: this.mappings[index].source,
name: this.mappings[index].name,
line: this.mappings[index].original.line,
column: this.mappings[index].original.column
};
}
generatedPositionFor(originalPosition) {
let index = this.findClosest(originalPosition.line, originalPosition.column, 'original');
return {
source: this.mappings[index].source,
name: this.mappings[index].name,
line: this.mappings[index].generated.line,
column: this.mappings[index].generated.column
};
}
sourceContentFor(fileName) {
return this.sources[fileName];
}
offset(lineOffset = 0, columnOffset = 0) {
this.mappings.map(mapping => {
mapping.generated.line = mapping.generated.line + lineOffset;
mapping.generated.column = mapping.generated.column + columnOffset;
return mapping;
});
if (this.lineCount != null) {
this.lineCount += lineOffset;
}
}
stringify(file, sourceRoot) {
let generator = new SourceMapGenerator({ file, sourceRoot });
this.eachMapping(mapping => generator.addMapping(mapping));
Object.keys(this.sources).forEach(sourceName => generator.setSourceContent(sourceName, this.sources[sourceName]));
return generator.toString();
}
}
module.exports = SourceMap;

182
VISUALIZACION/node_modules/parcel-bundler/lib/Watcher.js generated vendored Executable file
View file

@ -0,0 +1,182 @@
'use strict';
var _require = require('chokidar');
const FSWatcher = _require.FSWatcher;
const Path = require('path');
/**
* This watcher wraps chokidar so that we watch directories rather than individual files.
* This prevents us from hitting EMFILE errors when running out of file descriptors.
*/
class Watcher {
constructor() {
// FS events on macOS are flakey in the tests, which write lots of files very quickly
// See https://github.com/paulmillr/chokidar/issues/612
this.shouldWatchDirs = process.env.NODE_ENV !== 'test';
this.watcher = new FSWatcher({
useFsEvents: this.shouldWatchDirs,
ignoreInitial: true,
ignored: /\.cache|\.git/
});
this.watchedDirectories = new Map();
// Only close the watcher after the ready event is emitted
this.ready = false;
this.stopped = false;
this.watcher.once('ready', () => {
this.ready = true;
if (this.stopped) {
this.watcher.close();
}
});
}
/**
* Find a parent directory of `path` which is already watched
*/
getWatchedParent(path) {
path = Path.dirname(path);
let root = Path.parse(path).root;
while (path !== root) {
if (this.watchedDirectories.has(path)) {
return path;
}
path = Path.dirname(path);
}
return null;
}
/**
* Find a list of child directories of `path` which are already watched
*/
getWatchedChildren(path) {
path = Path.dirname(path) + Path.sep;
let res = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = this.watchedDirectories.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let dir = _step.value;
if (dir.startsWith(path)) {
res.push(dir);
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return res;
}
/**
* Add a path to the watcher
*/
watch(path) {
if (this.shouldWatchDirs) {
// If there is no parent directory already watching this path, add a new watcher.
let parent = this.getWatchedParent(path);
if (!parent) {
// Find watchers on child directories, and remove them. They will be handled by the new parent watcher.
let children = this.getWatchedChildren(path);
let count = 1;
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = children[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
let dir = _step2.value;
count += this.watchedDirectories.get(dir);
this.watcher._closePath(dir);
this.watchedDirectories.delete(dir);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
let dir = Path.dirname(path);
this.watcher.add(dir);
this.watchedDirectories.set(dir, count);
} else {
// Otherwise, increment the reference count of the parent watcher.
this.watchedDirectories.set(parent, this.watchedDirectories.get(parent) + 1);
}
} else {
this.watcher.add(path);
}
}
/**
* Remove a path from the watcher
*/
unwatch(path) {
if (this.shouldWatchDirs) {
let dir = this.getWatchedParent(path);
if (dir) {
// When the count of files watching a directory reaches zero, unwatch it.
let count = this.watchedDirectories.get(dir) - 1;
if (count === 0) {
this.watchedDirectories.delete(dir);
this.watcher.unwatch(dir);
} else {
this.watchedDirectories.set(dir, count);
}
}
} else {
this.watcher.unwatch(path);
}
}
/**
* Add an event handler
*/
on(event, callback) {
this.watcher.on(event, callback);
}
/**
* Stop watching all paths
*/
stop() {
this.stopped = true;
if (this.ready) {
this.watcher.close();
}
}
}
module.exports = Watcher;

150
VISUALIZACION/node_modules/parcel-bundler/lib/WorkerFarm.js generated vendored Executable file
View file

@ -0,0 +1,150 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
var _require = require('events');
const EventEmitter = _require.EventEmitter;
const os = require('os');
const Farm = require('worker-farm/lib/farm');
const promisify = require('./utils/promisify');
const logger = require('./Logger');
let shared = null;
class WorkerFarm extends Farm {
constructor(options) {
let opts = {
maxConcurrentWorkers: getNumWorkers()
};
let workerPath = parseInt(process.versions.node, 10) < 8 ? require.resolve('../lib/worker') : require.resolve('../src/worker');
super(opts, workerPath);
this.localWorker = this.promisifyWorker(require('./worker'));
this.remoteWorker = this.promisifyWorker(this.setup(['init', 'run']));
this.started = false;
this.warmWorkers = 0;
this.init(options);
}
init(options) {
this.localWorker.init(options);
this.initRemoteWorkers(options);
}
promisifyWorker(worker) {
let res = {};
for (let key in worker) {
res[key] = promisify(worker[key].bind(worker));
}
return res;
}
initRemoteWorkers(options) {
var _this = this;
return _asyncToGenerator(function* () {
_this.started = false;
_this.warmWorkers = 0;
let promises = [];
for (let i = 0; i < _this.options.maxConcurrentWorkers; i++) {
promises.push(_this.remoteWorker.init(options));
}
yield Promise.all(promises);
if (_this.options.maxConcurrentWorkers > 0) {
_this.started = true;
}
})();
}
receive(data) {
if (data.event) {
this.emit(data.event, ...data.args);
} else if (data.type === 'logger') {
if (this.shouldUseRemoteWorkers()) {
logger.handleMessage(data);
}
} else if (this.children[data.child]) {
super.receive(data);
}
}
shouldUseRemoteWorkers() {
return this.started && this.warmWorkers >= this.activeChildren;
}
run(...args) {
var _this2 = this;
return _asyncToGenerator(function* () {
// Child process workers are slow to start (~600ms).
// While we're waiting, just run on the main thread.
// This significantly speeds up startup time.
if (_this2.shouldUseRemoteWorkers()) {
return _this2.remoteWorker.run(...args, false);
} else {
// Workers have started, but are not warmed up yet.
// Send the job to a remote worker in the background,
// but use the result from the local worker - it will be faster.
if (_this2.started) {
_this2.remoteWorker.run(...args, true).then(function () {
_this2.warmWorkers++;
}, function () {
// ignore error
});
}
return _this2.localWorker.run(...args, false);
}
})();
}
end() {
// Force kill all children
this.ending = true;
for (let child in this.children) {
this.stopChild(child);
}
this.ending = false;
shared = null;
}
static getShared(options) {
if (!shared) {
shared = new WorkerFarm(options);
} else {
shared.init(options);
}
return shared;
}
}
for (let key in EventEmitter.prototype) {
WorkerFarm.prototype[key] = EventEmitter.prototype[key];
}
function getNumWorkers() {
if (process.env.PARCEL_WORKERS) {
return parseInt(process.env.PARCEL_WORKERS, 10);
}
let cores;
try {
cores = require('physical-cpu-count');
} catch (err) {
cores = os.cpus().length;
}
return cores || 1;
}
module.exports = WorkerFarm;

View file

@ -0,0 +1,170 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
function _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); }
const Asset = require('../Asset');
const postcss = require('postcss');
const valueParser = require('postcss-value-parser');
const postcssTransform = require('../transforms/postcss');
const CssSyntaxError = require('postcss/lib/css-syntax-error');
const URL_RE = /url\s*\("?(?![a-z]+:)/;
const IMPORT_RE = /@import/;
const PROTOCOL_RE = /^[a-z]+:/;
class CSSAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'css';
}
mightHaveDependencies() {
return !/\.css$/.test(this.name) || IMPORT_RE.test(this.contents) || URL_RE.test(this.contents);
}
parse(code) {
let root = postcss.parse(code, { from: this.name, to: this.name });
return new CSSAst(code, root);
}
collectDependencies() {
this.ast.root.walkAtRules('import', rule => {
let params = valueParser(rule.params).nodes;
var _params = _toArray(params);
let name = _params[0],
media = _params.slice(1);
let dep;
if (name.type === 'string') {
dep = name.value;
} else if (name.type === 'function' && name.value === 'url' && name.nodes.length) {
dep = name.nodes[0].value;
}
if (!dep) {
throw new Error('Could not find import name for ' + rule);
}
if (PROTOCOL_RE.test(dep)) {
return;
}
media = valueParser.stringify(media).trim();
this.addDependency(dep, { media, loc: rule.source.start });
rule.remove();
this.ast.dirty = true;
});
this.ast.root.walkDecls(decl => {
if (URL_RE.test(decl.value)) {
let parsed = valueParser(decl.value);
let dirty = false;
parsed.walk(node => {
if (node.type === 'function' && node.value === 'url' && node.nodes.length) {
let url = this.addURLDependency(node.nodes[0].value, {
loc: decl.source.start
});
dirty = node.nodes[0].value !== url;
node.nodes[0].value = url;
}
});
if (dirty) {
decl.value = parsed.toString();
this.ast.dirty = true;
}
}
});
}
transform() {
var _this = this;
return _asyncToGenerator(function* () {
yield postcssTransform(_this);
})();
}
getCSSAst() {
// Converts the ast to a CSS ast if needed, so we can apply postcss transforms.
if (!(this.ast instanceof CSSAst)) {
this.ast = CSSAsset.prototype.parse.call(this, this.ast.render());
}
return this.ast.root;
}
generate() {
let css = this.ast ? this.ast.render() : this.contents;
let js = '';
if (this.options.hmr) {
this.addDependency('_css_loader');
js = `
var reloadCSS = require('_css_loader');
module.hot.dispose(reloadCSS);
module.hot.accept(reloadCSS);
`;
}
if (this.cssModules) {
js += 'module.exports = ' + JSON.stringify(this.cssModules, false, 2) + ';';
}
return [{
type: 'css',
value: css,
cssModules: this.cssModules
}, {
type: 'js',
value: js,
final: true
}];
}
generateErrorMessage(err) {
// Wrap the error in a CssSyntaxError if needed so we can generate a code frame
if (err.loc && !err.showSourceCode) {
err = new CssSyntaxError(err.message, err.loc.line, err.loc.column, this.contents);
}
err.message = err.reason || err.message;
err.loc = {
line: err.line,
column: err.column
};
if (err.showSourceCode) {
err.codeFrame = err.showSourceCode();
err.highlightedCodeFrame = err.showSourceCode(true);
}
return err;
}
}
class CSSAst {
constructor(css, root) {
this.css = css;
this.root = root;
this.dirty = false;
}
render() {
if (this.dirty) {
this.css = '';
postcss.stringify(this.root, c => this.css += c);
}
return this.css;
}
}
module.exports = CSSAsset;

View file

@ -0,0 +1,42 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Asset = require('../Asset');
const localRequire = require('../utils/localRequire');
class CoffeeScriptAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'js';
}
generate() {
var _this = this;
return _asyncToGenerator(function* () {
// require coffeescript, installed locally in the app
let coffee = yield localRequire('coffeescript', _this.name);
// Transpile Module using CoffeeScript and parse result as ast format through babylon
let transpiled = coffee.compile(_this.contents, {
sourceMap: _this.options.sourceMaps
});
let sourceMap;
if (transpiled.sourceMap) {
sourceMap = transpiled.sourceMap.generate();
sourceMap.sources = [_this.relativeName];
sourceMap.sourcesContent = [_this.contents];
}
return [{
type: 'js',
value: _this.options.sourceMaps ? transpiled.js : transpiled,
sourceMap
}];
})();
}
}
module.exports = CoffeeScriptAsset;

View file

@ -0,0 +1,98 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Asset = require('../Asset');
const localRequire = require('../utils/localRequire');
const path = require('path');
const promisify = require('../utils/promisify');
const Resolver = require('../Resolver');
class GLSLAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'js';
}
parse() {
var _this = this;
return _asyncToGenerator(function* () {
const glslifyDeps = yield localRequire('glslify-deps', _this.name);
// Use the Parcel resolver rather than the default glslify one.
// This adds support for parcel features like alises, and tilde paths.
const resolver = new Resolver({
extensions: ['.glsl', '.vert', '.frag'],
rootDir: _this.options.rootDir
});
// Parse and collect dependencies with glslify-deps
let cwd = path.dirname(_this.name);
let depper = glslifyDeps({
cwd,
resolve: (() => {
var _ref = _asyncToGenerator(function* (target, opts, next) {
try {
let res = yield resolver.resolve(target, path.join(opts.basedir, 'index'));
next(null, res.path);
} catch (err) {
next(err);
}
});
return function resolve(_x, _x2, _x3) {
return _ref.apply(this, arguments);
};
})()
});
return yield promisify(depper.inline.bind(depper))(_this.contents, cwd);
})();
}
collectDependencies() {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = this.ast[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let dep = _step.value;
if (!dep.entry) {
this.addDependency(dep.file, { includedInParent: true });
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
generate() {
var _this2 = this;
return _asyncToGenerator(function* () {
// Generate the bundled glsl file
const glslifyBundle = yield localRequire('glslify-bundle', _this2.name);
let glsl = glslifyBundle(_this2.ast);
return {
js: `module.exports=${JSON.stringify(glsl)};`
};
})();
}
}
module.exports = GLSLAsset;

View file

@ -0,0 +1,107 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Asset = require('../Asset');
const glob = require('glob');
const micromatch = require('micromatch');
const path = require('path');
class GlobAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = null; // allows this asset to be included in any type bundle
}
load() {
var _this = this;
return _asyncToGenerator(function* () {
let regularExpressionSafeName = _this.name;
if (process.platform === 'win32') regularExpressionSafeName = regularExpressionSafeName.replace(/\\/g, '/');
let files = glob.sync(regularExpressionSafeName, {
strict: true,
nodir: true
});
let re = micromatch.makeRe(regularExpressionSafeName, { capture: true });
let matches = {};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let file = _step.value;
let match = file.match(re);
let parts = match.slice(1).filter(Boolean).reduce(function (a, p) {
return a.concat(p.split('/'));
}, []);
let relative = './' + path.relative(path.dirname(_this.name), file.normalize('NFC'));
set(matches, parts, relative);
_this.addDependency(relative);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return matches;
})();
}
generate() {
return {
js: 'module.exports = ' + generate(this.contents) + ';'
};
}
}
function generate(matches, indent = '') {
if (typeof matches === 'string') {
return `require(${JSON.stringify(matches)})`;
}
let res = indent + '{';
let first = true;
for (let key in matches) {
if (!first) {
res += ',';
}
res += `\n${indent} ${JSON.stringify(key)}: ${generate(matches[key], indent + ' ')}`;
first = false;
}
res += '\n' + indent + '}';
return res;
}
function set(obj, path, value) {
for (let i = 0; i < path.length - 1; i++) {
let part = path[i];
if (obj[part] == null) {
obj[part] = {};
}
obj = obj[part];
}
obj[path[path.length - 1]] = value;
}
module.exports = GlobAsset;

View file

@ -0,0 +1,30 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Asset = require('../Asset');
const localRequire = require('../utils/localRequire');
class GraphqlAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'js';
}
parse(code) {
var _this = this;
return _asyncToGenerator(function* () {
let gql = yield localRequire('graphql-tag', _this.name);
return gql(code);
})();
}
generate() {
return {
js: `module.exports=${JSON.stringify(this.ast, false, 2)};`
};
}
}
module.exports = GraphqlAsset;

View file

@ -0,0 +1,165 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Asset = require('../Asset');
const parse = require('posthtml-parser');
const api = require('posthtml/lib/api');
const urlJoin = require('../utils/urlJoin');
const render = require('posthtml-render');
const posthtmlTransform = require('../transforms/posthtml');
const htmlnanoTransform = require('../transforms/htmlnano');
const isURL = require('../utils/is-url');
// A list of all attributes that may produce a dependency
// Based on https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
const ATTRS = {
src: ['script', 'img', 'audio', 'video', 'source', 'track', 'iframe', 'embed'],
href: ['link', 'a', 'use'],
srcset: ['img', 'source'],
poster: ['video'],
'xlink:href': ['use'],
content: ['meta'],
data: ['object']
};
// A list of metadata that should produce a dependency
// Based on:
// - http://schema.org/
// - http://ogp.me
// - https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/markup
// - https://msdn.microsoft.com/en-us/library/dn255024.aspx
const META = {
property: ['og:image', 'og:image:url', 'og:image:secure_url', 'og:audio', 'og:audio:secure_url', 'og:video', 'og:video:secure_url'],
name: ['twitter:image', 'msapplication-square150x150logo', 'msapplication-square310x310logo', 'msapplication-square70x70logo', 'msapplication-wide310x150logo', 'msapplication-TileImage'],
itemprop: ['image', 'logo', 'screenshot', 'thumbnailUrl', 'contentUrl', 'downloadUrl']
};
// Options to be passed to `addURLDependency` for certain tags + attributes
const OPTIONS = {
a: {
href: { entry: true }
},
iframe: {
src: { entry: true }
}
};
class HTMLAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'html';
this.isAstDirty = false;
}
parse(code) {
let res = parse(code, { lowerCaseAttributeNames: true });
res.walk = api.walk;
res.match = api.match;
return res;
}
processSingleDependency(path, opts) {
let assetPath = this.addURLDependency(path, opts);
if (!isURL(assetPath)) {
assetPath = urlJoin(this.options.publicURL, assetPath);
}
return assetPath;
}
collectSrcSetDependencies(srcset, opts) {
const newSources = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = srcset.split(',')[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
const source = _step.value;
const pair = source.trim().split(' ');
if (pair.length === 0) continue;
pair[0] = this.processSingleDependency(pair[0], opts);
newSources.push(pair.join(' '));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return newSources.join(',');
}
getAttrDepHandler(attr) {
if (attr === 'srcset') {
return this.collectSrcSetDependencies;
}
return this.processSingleDependency;
}
collectDependencies() {
this.ast.walk(node => {
if (node.attrs) {
if (node.tag === 'meta') {
if (!Object.keys(node.attrs).some(attr => {
let values = META[attr];
return values && values.includes(node.attrs[attr]);
})) {
return node;
}
}
for (let attr in node.attrs) {
let elements = ATTRS[attr];
// Check for virtual paths
if (node.tag === 'a' && node.attrs[attr].lastIndexOf('.') < 1) {
continue;
}
if (elements && elements.includes(node.tag)) {
let depHandler = this.getAttrDepHandler(attr);
let options = OPTIONS[node.tag];
node.attrs[attr] = depHandler.call(this, node.attrs[attr], options && options[attr]);
this.isAstDirty = true;
}
}
}
return node;
});
}
pretransform() {
var _this = this;
return _asyncToGenerator(function* () {
yield posthtmlTransform(_this);
})();
}
transform() {
var _this2 = this;
return _asyncToGenerator(function* () {
if (_this2.options.minify) {
yield htmlnanoTransform(_this2);
}
})();
}
generate() {
return this.isAstDirty ? render(this.ast) : this.contents;
}
}
module.exports = HTMLAsset;

View file

@ -0,0 +1,209 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
var _require = require('babel-core');
const BabelFile = _require.File;
const traverse = require('babel-traverse').default;
const codeFrame = require('babel-code-frame');
const collectDependencies = require('../visitors/dependencies');
const walk = require('babylon-walk');
const Asset = require('../Asset');
const babylon = require('babylon');
const insertGlobals = require('../visitors/globals');
const fsVisitor = require('../visitors/fs');
const envVisitor = require('../visitors/env');
const babel = require('../transforms/babel');
const generate = require('babel-generator').default;
const uglify = require('../transforms/uglify');
const SourceMap = require('../SourceMap');
const IMPORT_RE = /\b(?:import\b|export\b|require\s*\()/;
const ENV_RE = /\b(?:process\.env)\b/;
const GLOBAL_RE = /\b(?:process|__dirname|__filename|global|Buffer|define)\b/;
const FS_RE = /\breadFileSync\b/;
const SW_RE = /\bnavigator\s*\.\s*serviceWorker\s*\.\s*register\s*\(/;
const WORKER_RE = /\bnew\s*Worker\s*\(/;
class JSAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'js';
this.globals = new Map();
this.isAstDirty = false;
this.isES6Module = false;
this.outputCode = null;
this.cacheData.env = {};
this.sourceMap = options.rendition ? options.rendition.sourceMap : null;
}
shouldInvalidate(cacheData) {
for (let key in cacheData.env) {
if (cacheData.env[key] !== process.env[key]) {
return true;
}
}
return false;
}
mightHaveDependencies() {
return this.isAstDirty || !/.js$/.test(this.name) || IMPORT_RE.test(this.contents) || GLOBAL_RE.test(this.contents) || SW_RE.test(this.contents) || WORKER_RE.test(this.contents);
}
getParserOptions() {
var _this = this;
return _asyncToGenerator(function* () {
// Babylon options. We enable a few plugins by default.
const options = {
filename: _this.name,
allowReturnOutsideFunction: true,
allowHashBang: true,
ecmaVersion: Infinity,
strictMode: false,
sourceType: 'module',
locations: true,
plugins: ['exportExtensions', 'dynamicImport']
};
// Check if there is a babel config file. If so, determine which parser plugins to enable
_this.babelConfig = yield babel.getConfig(_this);
if (_this.babelConfig) {
const file = new BabelFile(_this.babelConfig);
options.plugins.push(...file.parserOpts.plugins);
}
return options;
})();
}
parse(code) {
var _this2 = this;
return _asyncToGenerator(function* () {
const options = yield _this2.getParserOptions();
return babylon.parse(code, options);
})();
}
traverse(visitor) {
return traverse(this.ast, visitor, null, this);
}
traverseFast(visitor) {
return walk.simple(this.ast, visitor, this);
}
collectDependencies() {
walk.ancestor(this.ast, collectDependencies, this);
}
pretransform() {
var _this3 = this;
return _asyncToGenerator(function* () {
yield babel(_this3);
// Inline environment variables
if (ENV_RE.test(_this3.contents)) {
yield _this3.parseIfNeeded();
_this3.traverseFast(envVisitor);
}
})();
}
transform() {
var _this4 = this;
return _asyncToGenerator(function* () {
if (_this4.options.target === 'browser') {
if (_this4.dependencies.has('fs') && FS_RE.test(_this4.contents)) {
yield _this4.parseIfNeeded();
_this4.traverse(fsVisitor);
}
if (GLOBAL_RE.test(_this4.contents)) {
yield _this4.parseIfNeeded();
walk.ancestor(_this4.ast, insertGlobals, _this4);
}
}
if (_this4.isES6Module) {
yield babel(_this4);
}
if (_this4.options.minify) {
yield uglify(_this4);
}
})();
}
generate() {
var _this5 = this;
return _asyncToGenerator(function* () {
let code;
if (_this5.isAstDirty) {
let opts = {
sourceMaps: _this5.options.sourceMaps,
sourceFileName: _this5.relativeName
};
let generated = generate(_this5.ast, opts, _this5.contents);
if (_this5.options.sourceMaps && generated.rawMappings) {
let rawMap = new SourceMap(generated.rawMappings, {
[_this5.relativeName]: _this5.contents
});
// Check if we already have a source map (e.g. from TypeScript or CoffeeScript)
// In that case, we need to map the original source map to the babel generated one.
if (_this5.sourceMap) {
_this5.sourceMap = yield new SourceMap().extendSourceMap(_this5.sourceMap, rawMap);
} else {
_this5.sourceMap = rawMap;
}
}
code = generated.code;
} else {
code = _this5.outputCode || _this5.contents;
}
if (_this5.options.sourceMaps && !_this5.sourceMap) {
_this5.sourceMap = new SourceMap().generateEmptyMap(_this5.relativeName, _this5.contents);
}
if (_this5.globals.size > 0) {
code = Array.from(_this5.globals.values()).join('\n') + '\n' + code;
if (_this5.options.sourceMaps) {
if (!(_this5.sourceMap instanceof SourceMap)) {
_this5.sourceMap = yield new SourceMap().addMap(_this5.sourceMap);
}
_this5.sourceMap.offset(_this5.globals.size);
}
}
return {
js: code,
map: _this5.sourceMap
};
})();
}
generateErrorMessage(err) {
const loc = err.loc;
if (loc) {
err.codeFrame = codeFrame(this.contents, loc.line, loc.column + 1);
err.highlightedCodeFrame = codeFrame(this.contents, loc.line, loc.column + 1, { highlightCode: true });
}
return err;
}
}
module.exports = JSAsset;

View file

@ -0,0 +1,40 @@
'use strict';
const Asset = require('../Asset');
const path = require('path');
const json5 = require('json5');
var _require = require('uglify-es');
const minify = _require.minify;
class JSONAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'js';
}
parse(code) {
return path.extname(this.name) === '.json5' ? json5.parse(code) : null;
}
generate() {
let code = `module.exports = ${this.ast ? JSON.stringify(this.ast, null, 2) : this.contents};`;
if (this.options.minify) {
let minified = minify(code);
if (minified.error) {
throw minified.error;
}
code = minified.code;
}
return {
js: code
};
}
}
module.exports = JSONAsset;

View file

@ -0,0 +1,83 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Asset = require('../Asset');
const localRequire = require('../utils/localRequire');
const promisify = require('../utils/promisify');
class LESSAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'css';
}
parse(code) {
var _this = this;
return _asyncToGenerator(function* () {
// less should be installed locally in the module that's being required
let less = yield localRequire('less', _this.name);
let render = promisify(less.render.bind(less));
let opts = Object.assign({}, _this.package.less || (yield _this.getConfig(['.lessrc', '.lessrc.js'])));
opts.filename = _this.name;
opts.plugins = (opts.plugins || []).concat(urlPlugin(_this));
return yield render(code, opts);
})();
}
collectDependencies() {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = this.ast.imports[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let dep = _step.value;
this.addDependency(dep, { includedInParent: true });
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
generate() {
return [{
type: 'css',
value: this.ast ? this.ast.css : '',
hasDependencies: false
}];
}
}
function urlPlugin(asset) {
return {
install: (less, pluginManager) => {
let visitor = new less.visitors.Visitor({
visitUrl: node => {
node.value.value = asset.addURLDependency(node.value.value, node.currentFileInfo.filename);
return node;
}
});
visitor.run = visitor.visit;
pluginManager.addVisitor(visitor);
}
};
}
module.exports = LESSAsset;

View file

@ -0,0 +1,67 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const path = require('path');
const Asset = require('../Asset');
const localRequire = require('../utils/localRequire');
class PugAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'html';
}
generate() {
var _this = this;
return _asyncToGenerator(function* () {
const pug = yield localRequire('pug', _this.name);
const config = (yield _this.getConfig(['.pugrc', '.pugrc.js', 'pug.config.js'])) || {};
const compiled = pug.compile(_this.contents, {
compileDebug: false,
filename: _this.name,
basedir: path.dirname(_this.name),
pretty: !_this.options.minify,
templateName: path.basename(_this.basename, path.extname(_this.basename)),
filters: config.filters,
filterOptions: config.filterOptions,
filterAliases: config.filterAliases
});
if (compiled.dependencies) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = compiled.dependencies[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let item = _step.value;
_this.addDependency(item, {
includedInParent: true
});
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
return compiled();
})();
}
}
module.exports = PugAsset;

View file

@ -0,0 +1,36 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Asset = require('../Asset');
const urlJoin = require('../utils/urlJoin');
const md5 = require('../utils/md5');
class RawAsset extends Asset {
// Don't load raw assets. They will be copied by the RawPackager directly.
load() {}
generate() {
// Don't return a URL to the JS bundle if there is a bundle loader defined for this asset type.
// This will cause the actual asset to be automatically preloaded prior to the JS bundle running.
if (this.options.bundleLoaders[this.type]) {
return {};
}
const pathToAsset = urlJoin(this.options.publicURL, this.generateBundleName());
return {
js: `module.exports=${JSON.stringify(pathToAsset)};`
};
}
generateHash() {
var _this = this;
return _asyncToGenerator(function* () {
return yield md5.file(_this.name);
})();
}
}
module.exports = RawAsset;

View file

@ -0,0 +1,38 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Asset = require('../Asset');
const fs = require('../utils/fs');
const localRequire = require('../utils/localRequire');
class ReasonAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'js';
}
generate() {
var _this = this;
return _asyncToGenerator(function* () {
const bsb = yield localRequire('bsb-js', _this.name);
// This runs BuckleScript - the Reason to JS compiler.
// Other Asset types use `localRequire` but the `bsb-js` package already
// does that internally. This should also take care of error handling in
// the Reason compilation process.
if (process.env.NODE_ENV !== 'test') {
yield bsb.runBuild();
}
// This is a simplified use-case for Reason - it only loads the recommended
// BuckleScript configuration to simplify the file processing.
const outputFile = _this.name.replace(/\.(re|ml)$/, '.bs.js');
const outputContent = yield fs.readFile(outputFile);
return outputContent.toString();
})();
}
}
module.exports = ReasonAsset;

View file

@ -0,0 +1,245 @@
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const path = require('path');
const commandExists = require('command-exists');
const childProcess = require('child_process');
const promisify = require('../utils/promisify');
const exec = promisify(childProcess.execFile);
const tomlify = require('tomlify-j0.4');
const fs = require('../utils/fs');
const Asset = require('../Asset');
const config = require('../utils/config');
const pipeSpawn = require('../utils/pipeSpawn');
const md5 = require('../utils/md5');
const RUST_TARGET = 'wasm32-unknown-unknown';
const MAIN_FILES = ['src/lib.rs', 'src/main.rs'];
// Track installation status so we don't need to check more than once
let rustInstalled = false;
let wasmGCInstalled = false;
class RustAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'wasm';
}
process() {
// We don't want to process this asset if the worker is in a warm up phase
// since the asset will also be processed by the main process, which
// may cause errors since rust writes to the filesystem.
if (this.options.isWarmUp) {
return;
}
return super.process();
}
parse() {
var _this = this;
return _asyncToGenerator(function* () {
// Install rust toolchain and target if needed
yield _this.installRust();
// See if there is a Cargo config in the project
let cargoConfig = yield _this.getConfig(['Cargo.toml']);
let cargoDir;
let isMainFile = false;
if (cargoConfig) {
const mainFiles = MAIN_FILES.slice();
if (cargoConfig.lib && cargoConfig.lib.path) {
mainFiles.push(cargoConfig.lib.path);
}
cargoDir = path.dirname((yield config.resolve(_this.name, ['Cargo.toml'])));
isMainFile = mainFiles.some(function (file) {
return path.join(cargoDir, file) === _this.name;
});
}
// If this is the main file of a Cargo build, use the cargo command to compile.
// Otherwise, use rustc directly.
if (isMainFile) {
yield _this.cargoBuild(cargoConfig, cargoDir);
} else {
yield _this.rustcBuild();
}
// If this is a prod build, use wasm-gc to remove unused code
if (_this.options.minify) {
yield _this.installWasmGC();
yield exec('wasm-gc', [_this.wasmPath, _this.wasmPath]);
}
})();
}
installRust() {
return _asyncToGenerator(function* () {
if (rustInstalled) {
return;
}
// Check for rustup
try {
yield commandExists('rustup');
} catch (e) {
throw new Error("Rust isn't installed. Visit https://www.rustup.rs/ for more info");
}
// Ensure nightly toolchain is installed
var _ref = yield exec('rustup', ['show']),
_ref2 = _slicedToArray(_ref, 1);
let stdout = _ref2[0];
if (!stdout.includes('nightly')) {
yield pipeSpawn('rustup', ['update']);
yield pipeSpawn('rustup', ['toolchain', 'install', 'nightly']);
}
// Ensure wasm target is installed
var _ref3 = yield exec('rustup', ['target', 'list', '--toolchain', 'nightly']);
var _ref4 = _slicedToArray(_ref3, 1);
stdout = _ref4[0];
if (!stdout.includes(RUST_TARGET + ' (installed)')) {
yield pipeSpawn('rustup', ['target', 'add', RUST_TARGET, '--toolchain', 'nightly']);
}
rustInstalled = true;
})();
}
installWasmGC() {
return _asyncToGenerator(function* () {
if (wasmGCInstalled) {
return;
}
try {
yield commandExists('wasm-gc');
} catch (e) {
yield pipeSpawn('cargo', ['install', '--git', 'https://github.com/alexcrichton/wasm-gc']);
}
wasmGCInstalled = true;
})();
}
cargoBuild(cargoConfig, cargoDir) {
var _this2 = this;
return _asyncToGenerator(function* () {
// Ensure the cargo config has cdylib as the crate-type
if (!cargoConfig.lib) {
cargoConfig.lib = {};
}
if (!Array.isArray(cargoConfig.lib['crate-type'])) {
cargoConfig.lib['crate-type'] = [];
}
if (!cargoConfig.lib['crate-type'].includes('cdylib')) {
cargoConfig.lib['crate-type'].push('cdylib');
yield fs.writeFile(path.join(cargoDir, 'Cargo.toml'), tomlify.toToml(cargoConfig));
}
// Run cargo
let args = ['+nightly', 'build', '--target', RUST_TARGET, '--release'];
yield exec('cargo', args, { cwd: cargoDir });
// Get output file paths
let outDir = path.join(cargoDir, 'target', RUST_TARGET, 'release');
// Rust converts '-' to '_' when outputting files.
let rustName = cargoConfig.package.name.replace(/-/g, '_');
_this2.wasmPath = path.join(outDir, rustName + '.wasm');
_this2.depsPath = path.join(outDir, rustName + '.d');
})();
}
rustcBuild() {
var _this3 = this;
return _asyncToGenerator(function* () {
// Get output filename
yield fs.mkdirp(_this3.options.cacheDir);
let name = md5(_this3.name);
_this3.wasmPath = path.join(_this3.options.cacheDir, name + '.wasm');
// Run rustc to compile the code
const args = ['+nightly', '--target', RUST_TARGET, '-O', '--crate-type=cdylib', _this3.name, '-o', _this3.wasmPath];
yield exec('rustc', args);
// Run again to collect dependencies
_this3.depsPath = path.join(_this3.options.cacheDir, name + '.d');
yield exec('rustc', [_this3.name, '--emit=dep-info', '-o', _this3.depsPath]);
})();
}
collectDependencies() {
var _this4 = this;
return _asyncToGenerator(function* () {
// Read deps file
let contents = yield fs.readFile(_this4.depsPath, 'utf8');
let dir = path.dirname(_this4.name);
let deps = contents.split('\n').filter(Boolean).slice(1);
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = deps[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let dep = _step.value;
dep = path.resolve(dir, dep.slice(0, dep.indexOf(':')));
if (dep !== _this4.name) {
_this4.addDependency(dep, { includedInParent: true });
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
})();
}
generate() {
var _this5 = this;
return _asyncToGenerator(function* () {
return {
wasm: {
path: _this5.wasmPath, // pass output path to RawPackager
mtime: Date.now() // force re-bundling since otherwise the hash would never change
}
};
})();
}
}
module.exports = RustAsset;

View file

@ -0,0 +1,95 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Asset = require('../Asset');
const localRequire = require('../utils/localRequire');
const promisify = require('../utils/promisify');
const path = require('path');
const os = require('os');
const Resolver = require('../Resolver');
const syncPromise = require('../utils/syncPromise');
class SASSAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'css';
}
parse(code) {
var _this = this;
return _asyncToGenerator(function* () {
// node-sass should be installed locally in the module that's being required
let sass = yield localRequire('node-sass', _this.name);
let render = promisify(sass.render.bind(sass));
const resolver = new Resolver({
extensions: ['.scss', '.sass'],
rootDir: _this.options.rootDir
});
let opts = Object.assign({}, _this.package.sass || (yield _this.getConfig(['.sassrc', '.sassrc.js'])));
opts.includePaths = (opts.includePaths || []).concat(path.dirname(_this.name));
opts.data = opts.data ? opts.data + os.EOL + code : code;
opts.indentedSyntax = typeof opts.indentedSyntax === 'boolean' ? opts.indentedSyntax : path.extname(_this.name).toLowerCase() === '.sass';
opts.functions = Object.assign({}, opts.functions, {
url: function url(node) {
let filename = _this.addURLDependency(node.getValue());
return new sass.types.String(`url(${JSON.stringify(filename)})`);
}
});
opts.importer = function (url, prev, done) {
let resolved;
try {
resolved = syncPromise(resolver.resolve(url, prev === 'stdin' ? _this.name : prev)).path;
} catch (e) {
resolved = url;
}
return done({
file: resolved
});
};
return yield render(opts);
})();
}
collectDependencies() {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = this.ast.stats.includedFiles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let dep = _step.value;
this.addDependency(dep, { includedInParent: true });
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
generate() {
return [{
type: 'css',
value: this.ast ? this.ast.css.toString() : '',
hasDependencies: false
}];
}
}
module.exports = SASSAsset;

View file

@ -0,0 +1,138 @@
'use strict';
let createEvaluator = (() => {
var _ref = _asyncToGenerator(function* (asset) {
const Evaluator = yield localRequire('stylus/lib/visitor/evaluator', asset.name);
const utils = yield localRequire('stylus/lib/utils', asset.name);
const resolver = new Resolver(Object.assign({}, asset.options, {
extensions: ['.styl', '.css']
}));
// This is a custom stylus evaluator that extends stylus with support for the node
// require resolution algorithm. It also adds all dependencies to the parcel asset
// tree so the file watcher works correctly, etc.
class CustomEvaluator extends Evaluator {
visitImport(imported) {
let node = this.visit(imported.path).first;
let path = node.string;
if (node.name !== 'url' && path && !URL_RE.test(path)) {
try {
// First try resolving using the node require resolution algorithm.
// This allows stylus files in node_modules to be resolved properly.
// If we find something, update the AST so stylus gets the absolute path to load later.
node.string = syncPromise(resolver.resolve(path, imported.filename)).path;
asset.addDependency(node.string, { includedInParent: true });
} catch (err) {
// If we couldn't resolve, try the normal stylus resolver.
// We just need to do this to keep track of the dependencies - stylus does the real work.
// support optional .styl
if (!/\.styl$/i.test(path)) {
path += '.styl';
}
let found = utils.find(path, this.paths, this.filename);
if (!found) {
found = utils.lookupIndex(node.string, this.paths, this.filename);
}
if (!found) {
let nodeName = imported.once ? 'require' : 'import';
throw new Error('failed to locate @' + nodeName + ' file ' + node.string);
}
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = found[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let file = _step.value;
asset.addDependency(file, { includedInParent: true });
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
}
// Done. Let stylus do its thing.
return super.visitImport(imported);
}
}
return CustomEvaluator;
});
return function createEvaluator(_x) {
return _ref.apply(this, arguments);
};
})();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
// const CSSAsset = require('./CSSAsset');
const Asset = require('../Asset');
const localRequire = require('../utils/localRequire');
const Resolver = require('../Resolver');
const syncPromise = require('../utils/syncPromise');
const URL_RE = /^(?:url\s*\(\s*)?['"]?(?:[#/]|(?:https?:)?\/\/)/i;
class StylusAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'css';
}
parse(code) {
var _this = this;
return _asyncToGenerator(function* () {
// stylus should be installed locally in the module that's being required
let stylus = yield localRequire('stylus', _this.name);
let opts = _this.package.stylus || (yield _this.getConfig(['.stylusrc', '.stylusrc.js']));
let style = stylus(code, opts);
style.set('filename', _this.name);
style.set('include css', true);
style.set('Evaluator', (yield createEvaluator(_this)));
// Setup a handler for the URL function so we add dependencies for linked assets.
style.define('url', function (node) {
let filename = _this.addURLDependency(node.val, node.filename);
return new stylus.nodes.Literal(`url(${JSON.stringify(filename)})`);
});
return style;
})();
}
generate() {
return [{
type: 'css',
value: this.ast.render(),
hasDependencies: false
}];
}
generateErrorMessage(err) {
let index = err.message.indexOf('\n');
err.codeFrame = err.message.slice(index + 1);
err.message = err.message.slice(0, index);
return err;
}
}
module.exports = StylusAsset;

View file

@ -0,0 +1,24 @@
'use strict';
const Asset = require('../Asset');
const toml = require('toml');
const serializeObject = require('../utils/serializeObject');
class TOMLAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'js';
}
parse(code) {
return toml.parse(code);
}
generate() {
return {
js: serializeObject(this.ast, this.options.minify)
};
}
}
module.exports = TOMLAsset;

View file

@ -0,0 +1,64 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Asset = require('../Asset');
const localRequire = require('../utils/localRequire');
class TypeScriptAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'js';
}
generate() {
var _this = this;
return _asyncToGenerator(function* () {
// require typescript, installed locally in the app
let typescript = yield localRequire('typescript', _this.name);
let transpilerOptions = {
compilerOptions: {
module: typescript.ModuleKind.CommonJS,
jsx: typescript.JsxEmit.Preserve,
// it brings the generated output from TypeScript closer to that generated by Babel
// see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html
esModuleInterop: true
},
fileName: _this.relativeName
};
let tsconfig = yield _this.getConfig(['tsconfig.json']);
// Overwrite default if config is found
if (tsconfig) {
transpilerOptions.compilerOptions = Object.assign(transpilerOptions.compilerOptions, tsconfig.compilerOptions);
}
transpilerOptions.compilerOptions.noEmit = false;
transpilerOptions.compilerOptions.sourceMap = _this.options.sourceMaps;
// Transpile Module using TypeScript and parse result as ast format through babylon
let transpiled = typescript.transpileModule(_this.contents, transpilerOptions);
let sourceMap = transpiled.sourceMapText;
if (sourceMap) {
sourceMap = JSON.parse(sourceMap);
sourceMap.sources = [_this.relativeName];
sourceMap.sourcesContent = [_this.contents];
// Remove the source map URL
let content = transpiled.outputText;
transpiled.outputText = content.substring(0, content.lastIndexOf('//# sourceMappingURL'));
}
return [{
type: 'js',
value: transpiled.outputText,
sourceMap
}];
})();
}
}
module.exports = TypeScriptAsset;

View file

@ -0,0 +1,309 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Asset = require('../Asset');
const localRequire = require('../utils/localRequire');
const md5 = require('../utils/md5');
var _require = require('uglify-es');
const minify = _require.minify;
class VueAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'js';
}
parse(code) {
var _this = this;
return _asyncToGenerator(function* () {
// Is being used in component-compiler-utils, errors if not installed...
_this.vueTemplateCompiler = yield localRequire('vue-template-compiler', _this.name);
_this.vue = yield localRequire('@vue/component-compiler-utils', _this.name);
return _this.vue.parse({
source: code,
needMap: _this.options.sourceMaps,
filename: _this.relativeName, // Used for sourcemaps
sourceRoot: '' // Used for sourcemaps. Override so it doesn't use cwd
});
})();
}
generate() {
var _this2 = this;
return _asyncToGenerator(function* () {
let descriptor = _this2.ast;
let parts = [];
if (descriptor.script) {
parts.push({
type: descriptor.script.lang || 'js',
value: descriptor.script.content,
sourceMap: descriptor.script.map
});
}
if (descriptor.template) {
parts.push({
type: descriptor.template.lang || 'html',
value: descriptor.template.content.trim()
});
}
if (descriptor.styles) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = descriptor.styles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let style = _step.value;
parts.push({
type: style.lang || 'css',
value: style.content.trim(),
modules: !!style.module
});
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
return parts;
})();
}
postProcess(generated) {
var _this3 = this;
return _asyncToGenerator(function* () {
let result = [];
let hasScoped = _this3.ast.styles.some(function (s) {
return s.scoped;
});
let id = md5(_this3.name).slice(-6);
let scopeId = hasScoped ? `data-v-${id}` : null;
let optsVar = '$' + id;
// Generate JS output.
let js = _this3.ast.script ? generated[0].value : '';
let supplemental = `
var ${optsVar} = exports.default || module.exports;
if (typeof ${optsVar} === 'function') {
${optsVar} = ${optsVar}.options;
}
`;
supplemental += _this3.compileTemplate(generated, scopeId, optsVar);
supplemental += _this3.compileCSSModules(generated, optsVar);
supplemental += _this3.compileHMR(generated, optsVar);
if (_this3.options.minify && supplemental) {
var _minify = minify(supplemental, { toplevel: true });
let code = _minify.code,
error = _minify.error;
if (error) {
throw error;
}
supplemental = code;
}
js += supplemental;
if (js) {
result.push({
type: 'js',
value: js
});
}
let map = generated.find(function (r) {
return r.type === 'map';
});
if (map) {
result.push(map);
}
let css = _this3.compileStyle(generated, scopeId);
if (css) {
result.push({
type: 'css',
value: css
});
}
return result;
})();
}
compileTemplate(generated, scopeId, optsVar) {
let html = generated.find(r => r.type === 'html');
if (html) {
let isFunctional = this.ast.template.attrs.functional;
let template = this.vue.compileTemplate({
source: html.value,
filename: this.relativeName,
compiler: this.vueTemplateCompiler,
isProduction: this.options.production,
isFunctional,
compilerOptions: {
scopeId
}
});
if (Array.isArray(template.errors) && template.errors.length >= 1) {
throw new Error(template.errors[0]);
}
return `
/* template */
Object.assign(${optsVar}, (function () {
${template.code}
return {
render: render,
staticRenderFns: staticRenderFns,
_compiled: true,
_scopeId: ${JSON.stringify(scopeId)},
functional: ${JSON.stringify(isFunctional)}
};
})());
`;
}
return '';
}
compileCSSModules(generated, optsVar) {
let cssRenditions = generated.filter(r => r.type === 'css');
let cssModulesCode = '';
this.ast.styles.forEach((style, index) => {
if (style.module) {
let cssModules = JSON.stringify(cssRenditions[index].cssModules);
let name = style.module === true ? '$style' : style.module;
cssModulesCode += `\nthis[${JSON.stringify(name)}] = ${cssModules};`;
}
});
if (cssModulesCode) {
cssModulesCode = `function hook(){${cssModulesCode}\n}`;
let isFunctional = this.ast.template && this.ast.template.attrs.functional;
if (isFunctional) {
return `
/* css modules */
(function () {
${cssModulesCode}
${optsVar}._injectStyles = hook;
var originalRender = ${optsVar}.render;
${optsVar}.render = function (h, context) {
hook.call(context);
return originalRender(h, context);
};
})();
`;
} else {
return `
/* css modules */
(function () {
${cssModulesCode}
${optsVar}.beforeCreate = ${optsVar}.beforeCreate ? ${optsVar}.beforeCreate.concat(hook) : [hook];
})();
`;
}
}
return '';
}
compileStyle(generated, scopeId) {
return generated.filter(r => r.type === 'css').reduce((p, r, i) => {
let css = r.value;
let scoped = this.ast.styles[i].scoped;
// Process scoped styles if needed.
if (scoped) {
var _vue$compileStyle = this.vue.compileStyle({
source: css,
filename: this.relativeName,
id: scopeId,
scoped
});
let code = _vue$compileStyle.code,
errors = _vue$compileStyle.errors;
if (errors.length) {
throw errors[0];
}
css = code;
}
return p + css;
}, '');
}
compileHMR(generated, optsVar) {
if (!this.options.hmr) {
return '';
}
this.addDependency('vue-hot-reload-api');
this.addDependency('vue');
let cssHMR = '';
if (this.ast.styles.length) {
cssHMR = `
var reloadCSS = require('_css_loader');
module.hot.dispose(reloadCSS);
module.hot.accept(reloadCSS);
`;
}
let isFunctional = this.ast.template && this.ast.template.attrs.functional;
return `
/* hot reload */
(function () {
if (module.hot) {
var api = require('vue-hot-reload-api');
api.install(require('vue'));
if (api.compatible) {
module.hot.accept();
if (!module.hot.data) {
api.createRecord('${optsVar}', ${optsVar});
} else {
api.${isFunctional ? 'rerender' : 'reload'}('${optsVar}', ${optsVar});
}
}
${cssHMR}
}
})();`;
}
}
module.exports = VueAsset;

View file

@ -0,0 +1,80 @@
'use strict';
const Asset = require('../Asset');
class WebManifestAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'webmanifest';
}
parse(content) {
return JSON.parse(content);
}
collectDependencies() {
if (Array.isArray(this.ast.icons)) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = this.ast.icons[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let icon = _step.value;
icon.src = this.addURLDependency(icon.src);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
if (Array.isArray(this.ast.screenshots)) {
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = this.ast.screenshots[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
let shot = _step2.value;
shot.src = this.addURLDependency(shot.src);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
if (this.ast.serviceworker && this.ast.serviceworker.src) {
this.ast.serviceworker.src = this.addURLDependency(this.ast.serviceworker.src);
}
}
generate() {
return JSON.stringify(this.ast);
}
}
module.exports = WebManifestAsset;

View file

@ -0,0 +1,24 @@
'use strict';
const Asset = require('../Asset');
const yaml = require('js-yaml');
const serializeObject = require('../utils/serializeObject');
class YAMLAsset extends Asset {
constructor(name, pkg, options) {
super(name, pkg, options);
this.type = 'js';
}
parse(code) {
return yaml.safeLoad(code);
}
generate() {
return {
js: serializeObject(this.ast, this.options.minify)
};
}
}
module.exports = YAMLAsset;

View file

@ -0,0 +1,12 @@
{
"extends": "../.eslintrc.json",
"parserOptions": {
"ecmaVersion": 5
},
"env": {
"browser": true
},
"rules": {
"no-global-assign": 1
}
}

View file

View file

@ -0,0 +1,12 @@
{
"extends": "../.eslintrc.json",
"parserOptions": {
"ecmaVersion": 5
},
"env": {
"browser": true
},
"rules": {
"no-global-assign": 1
}
}

View file

View file

@ -0,0 +1,92 @@
var getBundleURL = require('./bundle-url').getBundleURL;
function loadBundles(bundles) {
var id = Array.isArray(bundles) ? bundles[bundles.length - 1] : bundles;
try {
return Promise.resolve(require(id));
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
return new LazyPromise(function (resolve, reject) {
Promise.all(bundles.slice(0, -1).map(loadBundle)).then(function () {
return require(id);
}).then(resolve, reject);
});
}
throw err;
}
}
module.exports = exports = loadBundles;
var bundles = {};
var bundleLoaders = {
js: loadJSBundle,
css: loadCSSBundle
};
function loadBundle(bundle) {
if (bundles[bundle]) {
return bundles[bundle];
}
var type = bundle.match(/\.(.+)$/)[1].toLowerCase();
var bundleLoader = bundleLoaders[type];
if (bundleLoader) {
return bundles[bundle] = bundleLoader(getBundleURL() + bundle);
}
}
function loadJSBundle(bundle) {
return new Promise(function (resolve, reject) {
var script = document.createElement('script');
script.async = true;
script.type = 'text/javascript';
script.charset = 'utf-8';
script.src = bundle;
script.onerror = function (e) {
script.onerror = script.onload = null;
reject(e);
};
script.onload = function () {
script.onerror = script.onload = null;
resolve();
};
document.getElementsByTagName('head')[0].appendChild(script);
});
}
function loadCSSBundle(bundle) {
return new Promise(function (resolve, reject) {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.href = bundle;
link.onerror = function (e) {
link.onerror = link.onload = null;
reject(e);
};
link.onload = function () {
link.onerror = link.onload = null;
resolve();
};
document.getElementsByTagName('head')[0].appendChild(link);
});
}
function LazyPromise(executor) {
this.executor = executor;
this.promise = null;
}
LazyPromise.prototype.then = function (onSuccess, onError) {
return this.promise || (this.promise = new Promise(this.executor).then(onSuccess, onError));
};
LazyPromise.prototype.catch = function (onError) {
return this.promise || (this.promise = new Promise(this.executor).catch(onError));
};

View file

@ -0,0 +1,29 @@
var bundleURL = null;
function getBundleURLCached() {
if (!bundleURL) {
bundleURL = getBundleURL();
}
return bundleURL;
}
function getBundleURL() {
// Attempt to find the URL of the current script and use that as the base URL
try {
throw new Error;
} catch (err) {
var matches = ('' + err.stack).match(/(https?|file|ftp):\/\/[^)\n]+/g);
if (matches) {
return getBaseURL(matches[0]);
}
}
return '/';
}
function getBaseURL(url) {
return ('' + url).replace(/^((?:https?|file|ftp):\/\/.+)\/[^/]+$/, '$1') + '/';
}
exports.getBundleURL = getBundleURLCached;
exports.getBaseURL = getBaseURL;

View file

@ -0,0 +1,30 @@
var bundle = require('./bundle-url');
function updateLink(link) {
var newLink = link.cloneNode();
newLink.onload = function () {
link.remove();
};
newLink.href = link.href.split('?')[0] + '?' + Date.now();
link.parentNode.insertBefore(newLink, link.nextSibling);
}
var cssTimeout = null;
function reloadCSS() {
if (cssTimeout) {
return;
}
cssTimeout = setTimeout(function () {
var links = document.querySelectorAll('link[rel="stylesheet"]');
for (var i = 0; i < links.length; i++) {
if (bundle.getBaseURL(links[i].href) === bundle.getBundleURL()) {
updateLink(links[i]);
}
}
cssTimeout = null;
}, 50);
}
module.exports = reloadCSS;

View file

@ -0,0 +1,118 @@
var global = (1, eval)('this');
var OldModule = module.bundle.Module;
function Module() {
OldModule.call(this);
this.hot = {
accept: function (fn) {
this._acceptCallback = fn || function () {};
},
dispose: function (fn) {
this._disposeCallback = fn;
}
};
}
module.bundle.Module = Module;
if (!module.bundle.parent && typeof WebSocket !== 'undefined') {
var ws = new WebSocket('ws://' + window.location.hostname + ':{{HMR_PORT}}/');
ws.onmessage = function(event) {
var data = JSON.parse(event.data);
if (data.type === 'update') {
data.assets.forEach(function (asset) {
hmrApply(global.require, asset);
});
data.assets.forEach(function (asset) {
if (!asset.isNew) {
hmrAccept(global.require, asset.id);
}
});
}
if (data.type === 'reload') {
ws.close();
ws.onclose = function () {
window.location.reload();
}
}
if (data.type === 'error-resolved') {
console.log('[parcel] ✨ Error resolved');
}
if (data.type === 'error') {
console.error('[parcel] 🚨 ' + data.error.message + '\n' + 'data.error.stack');
}
};
}
function getParents(bundle, id) {
var modules = bundle.modules;
if (!modules) {
return [];
}
var parents = [];
var k, d, dep;
for (k in modules) {
for (d in modules[k][1]) {
dep = modules[k][1][d];
if (dep === id || (Array.isArray(dep) && dep[dep.length - 1] === id)) {
parents.push(+k);
}
}
}
if (bundle.parent) {
parents = parents.concat(getParents(bundle.parent, id));
}
return parents;
}
function hmrApply(bundle, asset) {
var modules = bundle.modules;
if (!modules) {
return;
}
if (modules[asset.id] || !bundle.parent) {
var fn = new Function('require', 'module', 'exports', asset.generated.js);
asset.isNew = !modules[asset.id];
modules[asset.id] = [fn, asset.deps];
} else if (bundle.parent) {
hmrApply(bundle.parent, asset);
}
}
function hmrAccept(bundle, id) {
var modules = bundle.modules;
if (!modules) {
return;
}
if (!modules[id] && bundle.parent) {
return hmrAccept(bundle.parent, id);
}
var cached = bundle.cache[id];
if (cached && cached.hot._disposeCallback) {
cached.hot._disposeCallback();
}
delete bundle.cache[id];
bundle(id);
cached = bundle.cache[id];
if (cached && cached.hot && cached.hot._acceptCallback) {
cached.hot._acceptCallback();
return true;
}
return getParents(global.require, id).some(function (id) {
return hmrAccept(global.require, id)
});
}

View file

@ -0,0 +1,12 @@
var builtins = require('node-libs-browser');
for (var key in builtins) {
if (builtins[key] == null) {
builtins[key] = require.resolve('./_empty.js');
}
}
builtins['_bundle_loader'] = require.resolve('./bundle-loader.js');
builtins['_css_loader'] = require.resolve('./css-loader.js');
module.exports = builtins;

View file

@ -0,0 +1,18 @@
module.exports = function loadCSSBundle(bundle) {
return new Promise(function (resolve, reject) {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.href = bundle;
link.onerror = function (e) {
link.onerror = link.onload = null;
reject(e);
};
link.onload = function () {
link.onerror = link.onload = null;
resolve();
};
document.getElementsByTagName('head')[0].appendChild(link);
});
};

View file

@ -0,0 +1,20 @@
module.exports = function loadJSBundle(bundle) {
return new Promise(function (resolve, reject) {
var script = document.createElement('script');
script.async = true;
script.type = 'text/javascript';
script.charset = 'utf-8';
script.src = bundle;
script.onerror = function (e) {
script.onerror = script.onload = null;
reject(e);
};
script.onload = function () {
script.onerror = script.onload = null;
resolve();
};
document.getElementsByTagName('head')[0].appendChild(script);
});
};

View file

@ -0,0 +1,16 @@
module.exports = function loadWASMBundle(bundle) {
return fetch(bundle)
.then(function (res) {
if (WebAssembly.compileStreaming) {
return WebAssembly.compileStreaming(res);
} else {
return res.arrayBuffer()
.then(function (data) {
return WebAssembly.compile(data);
});
}
})
.then(function (wasmModule) {
return new WebAssembly.Instance(wasmModule).exports;
});
};

View file

@ -0,0 +1,72 @@
// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles
// eslint-disable-next-line no-global-assign
require = (function (modules, cache, entry) {
// Save the require from previous bundle to this closure if any
var previousRequire = typeof require === "function" && require;
function newRequire(name, jumped) {
if (!cache[name]) {
if (!modules[name]) {
// if we cannot find the module within our internal map or
// cache jump to the current global require ie. the last bundle
// that was added to the page.
var currentRequire = typeof require === "function" && require;
if (!jumped && currentRequire) {
return currentRequire(name, true);
}
// If there are other bundles on this page the require from the
// previous one is saved to 'previousRequire'. Repeat this as
// many times as there are bundles until the module is found or
// we exhaust the require chain.
if (previousRequire) {
return previousRequire(name, true);
}
var err = new Error('Cannot find module \'' + name + '\'');
err.code = 'MODULE_NOT_FOUND';
throw err;
}
localRequire.resolve = resolve;
var module = cache[name] = new newRequire.Module;
modules[name][0].call(module.exports, localRequire, module, module.exports);
}
return cache[name].exports;
function localRequire(x){
return newRequire(localRequire.resolve(x));
}
function resolve(x){
return modules[name][1][x] || x;
}
}
function Module() {
this.bundle = newRequire;
this.exports = {};
}
newRequire.Module = Module;
newRequire.modules = modules;
newRequire.cache = cache;
newRequire.parent = previousRequire;
for (var i = 0; i < entry.length; i++) {
newRequire(entry[i]);
}
// Override the current require with this new one
return newRequire;
})

View file

@ -0,0 +1 @@
require=function(r,e,n){function t(n,o){function i(r){return t(i.resolve(r))}function f(e){return r[n][1][e]||e}if(!e[n]){if(!r[n]){var c="function"==typeof require&&require;if(!o&&c)return c(n,!0);if(u)return u(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}i.resolve=f;var a=e[n]=new t.Module;r[n][0].call(a.exports,i,a,a.exports)}return e[n].exports}function o(){this.bundle=t,this.exports={}}var u="function"==typeof require&&require;t.Module=o,t.modules=r,t.cache=e,t.parent=u;for(var i=0;i<n.length;i++)t(n[i]);return t};

View file

@ -0,0 +1,83 @@
var getBundleURL = require('./bundle-url').getBundleURL;
function loadBundlesLazy(bundles) {
if (!Array.isArray(bundles)) {
bundles = [bundles]
}
var id = bundles[bundles.length - 1];
try {
return Promise.resolve(require(id));
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
return new LazyPromise(function (resolve, reject) {
loadBundles(bundles)
.then(resolve, reject);
});
}
throw err;
}
}
function loadBundles(bundles) {
var id = bundles[bundles.length - 1];
return Promise.all(bundles.slice(0, -1).map(loadBundle))
.then(function () {
return require(id);
});
}
var bundleLoaders = {};
function registerBundleLoader(type, loader) {
bundleLoaders[type] = loader;
}
module.exports = exports = loadBundlesLazy;
exports.load = loadBundles;
exports.register = registerBundleLoader;
var bundles = {};
function loadBundle(bundle) {
var id;
if (Array.isArray(bundle)) {
id = bundle[1];
bundle = bundle[0];
}
if (bundles[bundle]) {
return bundles[bundle];
}
var type = (bundle.substring(bundle.lastIndexOf('.') + 1, bundle.length) || bundle).toLowerCase();
var bundleLoader = bundleLoaders[type];
if (bundleLoader) {
return bundles[bundle] = bundleLoader(getBundleURL() + bundle)
.then(function (resolved) {
if (resolved) {
module.bundle.modules[id] = [function (require, module) {
module.exports = resolved;
}, {}];
}
return resolved;
});
}
}
function LazyPromise(executor) {
this.executor = executor;
this.promise = null;
}
LazyPromise.prototype.then = function (onSuccess, onError) {
if (this.promise === null) this.promise = new Promise(this.executor)
return this.promise.then(onSuccess, onError)
};
LazyPromise.prototype.catch = function (onError) {
if (this.promise === null) this.promise = new Promise(this.executor)
return this.promise.catch(onError)
};

View file

@ -0,0 +1,29 @@
var bundleURL = null;
function getBundleURLCached() {
if (!bundleURL) {
bundleURL = getBundleURL();
}
return bundleURL;
}
function getBundleURL() {
// Attempt to find the URL of the current script and use that as the base URL
try {
throw new Error;
} catch (err) {
var matches = ('' + err.stack).match(/(https?|file|ftp):\/\/[^)\n]+/g);
if (matches) {
return getBaseURL(matches[0]);
}
}
return '/';
}
function getBaseURL(url) {
return ('' + url).replace(/^((?:https?|file|ftp):\/\/.+)\/[^/]+$/, '$1') + '/';
}
exports.getBundleURL = getBundleURLCached;
exports.getBaseURL = getBaseURL;

View file

@ -0,0 +1,30 @@
var bundle = require('./bundle-url');
function updateLink(link) {
var newLink = link.cloneNode();
newLink.onload = function () {
link.remove();
};
newLink.href = link.href.split('?')[0] + '?' + Date.now();
link.parentNode.insertBefore(newLink, link.nextSibling);
}
var cssTimeout = null;
function reloadCSS() {
if (cssTimeout) {
return;
}
cssTimeout = setTimeout(function () {
var links = document.querySelectorAll('link[rel="stylesheet"]');
for (var i = 0; i < links.length; i++) {
if (bundle.getBaseURL(links[i].href) === bundle.getBundleURL()) {
updateLink(links[i]);
}
}
cssTimeout = null;
}, 50);
}
module.exports = reloadCSS;

View file

@ -0,0 +1,176 @@
var OVERLAY_ID = '__parcel__error__overlay__';
var OldModule = module.bundle.Module;
function Module(moduleName) {
OldModule.call(this, moduleName);
this.hot = {
data: module.bundle.hotData,
_acceptCallbacks: [],
_disposeCallbacks: [],
accept: function (fn) {
this._acceptCallbacks.push(fn || function () {});
},
dispose: function (fn) {
this._disposeCallbacks.push(fn);
}
};
module.bundle.hotData = null;
}
module.bundle.Module = Module;
var parent = module.bundle.parent;
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
var hostname = process.env.HMR_HOSTNAME || location.hostname;
var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
var ws = new WebSocket(protocol + '://' + hostname + ':' + process.env.HMR_PORT + '/');
ws.onmessage = function(event) {
var data = JSON.parse(event.data);
if (data.type === 'update') {
data.assets.forEach(function (asset) {
hmrApply(global.parcelRequire, asset);
});
data.assets.forEach(function (asset) {
if (!asset.isNew) {
hmrAccept(global.parcelRequire, asset.id);
}
});
// Clear the console after HMR
console.clear();
}
if (data.type === 'reload') {
ws.close();
ws.onclose = function () {
location.reload();
}
}
if (data.type === 'error-resolved') {
console.log('[parcel] ✨ Error resolved');
removeErrorOverlay();
}
if (data.type === 'error') {
console.error('[parcel] 🚨 ' + data.error.message + '\n' + data.error.stack);
removeErrorOverlay();
var overlay = createErrorOverlay(data);
document.body.appendChild(overlay);
}
};
}
function removeErrorOverlay() {
var overlay = document.getElementById(OVERLAY_ID);
if (overlay) {
overlay.remove();
}
}
function createErrorOverlay(data) {
var overlay = document.createElement('div');
overlay.id = OVERLAY_ID;
// html encode message and stack trace
var message = document.createElement('div');
var stackTrace = document.createElement('pre');
message.innerText = data.error.message;
stackTrace.innerText = data.error.stack;
overlay.innerHTML = (
'<div style="background: black; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; opacity: 0.85; font-family: Menlo, Consolas, monospace; z-index: 9999;">' +
'<span style="background: red; padding: 2px 4px; border-radius: 2px;">ERROR</span>' +
'<span style="top: 2px; margin-left: 5px; position: relative;">🚨</span>' +
'<div style="font-size: 18px; font-weight: bold; margin-top: 20px;">' + message.innerHTML + '</div>' +
'<pre>' + stackTrace.innerHTML + '</pre>' +
'</div>'
);
return overlay;
}
function getParents(bundle, id) {
var modules = bundle.modules;
if (!modules) {
return [];
}
var parents = [];
var k, d, dep;
for (k in modules) {
for (d in modules[k][1]) {
dep = modules[k][1][d];
if (dep === id || (Array.isArray(dep) && dep[dep.length - 1] === id)) {
parents.push(+k);
}
}
}
if (bundle.parent) {
parents = parents.concat(getParents(bundle.parent, id));
}
return parents;
}
function hmrApply(bundle, asset) {
var modules = bundle.modules;
if (!modules) {
return;
}
if (modules[asset.id] || !bundle.parent) {
var fn = new Function('require', 'module', 'exports', asset.generated.js);
asset.isNew = !modules[asset.id];
modules[asset.id] = [fn, asset.deps];
} else if (bundle.parent) {
hmrApply(bundle.parent, asset);
}
}
function hmrAccept(bundle, id) {
var modules = bundle.modules;
if (!modules) {
return;
}
if (!modules[id] && bundle.parent) {
return hmrAccept(bundle.parent, id);
}
var cached = bundle.cache[id];
bundle.hotData = {};
if (cached) {
cached.hot.data = bundle.hotData;
}
if (cached && cached.hot && cached.hot._disposeCallbacks.length) {
cached.hot._disposeCallbacks.forEach(function (cb) {
cb(bundle.hotData);
});
}
delete bundle.cache[id];
bundle(id);
cached = bundle.cache[id];
if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
cached.hot._acceptCallbacks.forEach(function (cb) {
cb();
});
return true;
}
return getParents(global.parcelRequire, id).some(function (id) {
return hmrAccept(global.parcelRequire, id)
});
}

View file

@ -0,0 +1,12 @@
var builtins = require('node-libs-browser');
for (var key in builtins) {
if (builtins[key] == null) {
builtins[key] = require.resolve('./_empty.js');
}
}
builtins['_bundle_loader'] = require.resolve('./bundle-loader.js');
builtins['_css_loader'] = require.resolve('./css-loader.js');
module.exports = builtins;

View file

@ -0,0 +1,18 @@
module.exports = function loadCSSBundle(bundle) {
return new Promise(function (resolve, reject) {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.href = bundle;
link.onerror = function (e) {
link.onerror = link.onload = null;
reject(e);
};
link.onload = function () {
link.onerror = link.onload = null;
resolve();
};
document.getElementsByTagName('head')[0].appendChild(link);
});
};

View file

@ -0,0 +1,20 @@
module.exports = function loadJSBundle(bundle) {
return new Promise(function (resolve, reject) {
var script = document.createElement('script');
script.async = true;
script.type = 'text/javascript';
script.charset = 'utf-8';
script.src = bundle;
script.onerror = function (e) {
script.onerror = script.onload = null;
reject(e);
};
script.onload = function () {
script.onerror = script.onload = null;
resolve();
};
document.getElementsByTagName('head')[0].appendChild(script);
});
};

View file

@ -0,0 +1,16 @@
module.exports = function loadWASMBundle(bundle) {
return fetch(bundle)
.then(function (res) {
if (WebAssembly.instantiateStreaming) {
return WebAssembly.instantiateStreaming(res);
} else {
return res.arrayBuffer()
.then(function (data) {
return WebAssembly.instantiate(data);
});
}
})
.then(function (wasmModule) {
return wasmModule.instance.exports;
});
};

View file

@ -0,0 +1,18 @@
module.exports = function loadCSSBundle(bundle) {
return new Promise(function (resolve, reject) {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.href = bundle;
link.onerror = function (e) {
link.onerror = link.onload = null;
reject(e);
};
link.onload = function () {
link.onerror = link.onload = null;
resolve();
};
document.getElementsByTagName('head')[0].appendChild(link);
});
};

View file

@ -0,0 +1,20 @@
module.exports = function loadJSBundle(bundle) {
return new Promise(function (resolve, reject) {
var script = document.createElement('script');
script.async = true;
script.type = 'text/javascript';
script.charset = 'utf-8';
script.src = bundle;
script.onerror = function (e) {
script.onerror = script.onload = null;
reject(e);
};
script.onload = function () {
script.onerror = script.onload = null;
resolve();
};
document.getElementsByTagName('head')[0].appendChild(script);
});
};

View file

@ -0,0 +1,4 @@
// loading a CSS style is a no-op in Node.js
module.exports = function loadCSSBundle() {
return Promise.resolve();
};

View file

@ -0,0 +1,20 @@
var fs = require('fs');
module.exports = function loadJSBundle(bundle) {
return new Promise(function(resolve, reject) {
fs.readFile(__dirname + bundle, 'utf8', function(err, data) {
if (err) {
reject(err);
} else {
// wait for the next event loop iteration, so we are sure
// the current module is fully loaded
setImmediate(function() {
resolve(data);
});
}
});
})
.then(function(code) {
new Function('', code)();
});
};

View file

@ -0,0 +1,19 @@
var fs = require('fs');
module.exports = function loadWASMBundle(bundle) {
return new Promise(function(resolve, reject) {
fs.readFile(__dirname + bundle, function(err, data) {
if (err) {
reject(err);
} else {
resolve(data.buffer);
}
});
})
.then(function(data) {
return WebAssembly.instantiate(data);
})
.then(function(wasmModule) {
return wasmModule.instance.exports;
});
};

View file

@ -0,0 +1,16 @@
module.exports = function loadWASMBundle(bundle) {
return fetch(bundle)
.then(function (res) {
if (WebAssembly.instantiateStreaming) {
return WebAssembly.instantiateStreaming(res);
} else {
return res.arrayBuffer()
.then(function (data) {
return WebAssembly.instantiate(data);
});
}
})
.then(function (wasmModule) {
return wasmModule.instance.exports;
});
};

View file

@ -0,0 +1,101 @@
// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles
// eslint-disable-next-line no-global-assign
parcelRequire = (function (modules, cache, entry, globalName) {
// Save the require from previous bundle to this closure if any
var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
var nodeRequire = typeof require === 'function' && require;
function newRequire(name, jumped) {
if (!cache[name]) {
if (!modules[name]) {
// if we cannot find the module within our internal map or
// cache jump to the current global require ie. the last bundle
// that was added to the page.
var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
if (!jumped && currentRequire) {
return currentRequire(name, true);
}
// If there are other bundles on this page the require from the
// previous one is saved to 'previousRequire'. Repeat this as
// many times as there are bundles until the module is found or
// we exhaust the require chain.
if (previousRequire) {
return previousRequire(name, true);
}
// Try the node require function if it exists.
if (nodeRequire && typeof name === 'string') {
return nodeRequire(name);
}
var err = new Error('Cannot find module \'' + name + '\'');
err.code = 'MODULE_NOT_FOUND';
throw err;
}
localRequire.resolve = resolve;
var module = cache[name] = new newRequire.Module(name);
modules[name][0].call(module.exports, localRequire, module, module.exports, this);
}
return cache[name].exports;
function localRequire(x){
return newRequire(localRequire.resolve(x));
}
function resolve(x){
return modules[name][1][x] || x;
}
}
function Module(moduleName) {
this.id = moduleName;
this.bundle = newRequire;
this.exports = {};
}
newRequire.isParcelRequire = true;
newRequire.Module = Module;
newRequire.modules = modules;
newRequire.cache = cache;
newRequire.parent = previousRequire;
for (var i = 0; i < entry.length; i++) {
newRequire(entry[i]);
}
if (entry.length) {
// Expose entry point to Node, AMD or browser globals
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
var mainExports = newRequire(entry[entry.length - 1]);
// CommonJS
if (typeof exports === "object" && typeof module !== "undefined") {
module.exports = mainExports;
// RequireJS
} else if (typeof define === "function" && define.amd) {
define(function () {
return mainExports;
});
// <script>
} else if (globalName) {
this[globalName] = mainExports;
}
}
// Override the current require with this new one
return newRequire;
})

View file

@ -0,0 +1 @@
parcelRequire=function(e,r,n,t){function i(n,t){function o(e){return i(o.resolve(e))}function c(r){return e[n][1][r]||r}if(!r[n]){if(!e[n]){var l="function"==typeof parcelRequire&&parcelRequire;if(!t&&l)return l(n,!0);if(u)return u(n,!0);if(f&&"string"==typeof n)return f(n);var p=new Error("Cannot find module '"+n+"'");throw p.code="MODULE_NOT_FOUND",p}o.resolve=c;var a=r[n]=new i.Module(n);e[n][0].call(a.exports,o,a,a.exports,this)}return r[n].exports}function o(e){this.id=e,this.bundle=i,this.exports={}}var u="function"==typeof parcelRequire&&parcelRequire,f="function"==typeof require&&require;i.isParcelRequire=!0,i.Module=o,i.modules=e,i.cache=r,i.parent=u;for(var c=0;c<n.length;c++)i(n[c]);if(n.length){var l=i(n[n.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):t&&(this[t]=l)}return i};

View file

@ -0,0 +1,41 @@
parcelRequire = (function (init) {
// Save the require from previous bundle to this closure if any
var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
var nodeRequire = typeof require === 'function' && require;
var modules = {};
function localRequire(name, jumped) {
if (modules[name]) {
return modules[name];
}
// if we cannot find the module within our internal map or
// cache jump to the current global require ie. the last bundle
// that was added to the page.
var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
if (!jumped && currentRequire) {
return currentRequire(name, true);
}
// If there are other bundles on this page the require from the
// previous one is saved to 'previousRequire'. Repeat this as
// many times as there are bundles until the module is found or
// we exhaust the require chain.
if (previousRequire) {
return previousRequire(name, true);
}
// Try the node require function if it exists.
if (nodeRequire && typeof name === 'string') {
return nodeRequire(name);
}
var err = new Error('Cannot find module \'' + name + '\'');
err.code = 'MODULE_NOT_FOUND';
throw err;
}
modules = init(localRequire);
localRequire.modules = modules;
return localRequire;
})

72
VISUALIZACION/node_modules/parcel-bundler/lib/cli.js generated vendored Executable file
View file

@ -0,0 +1,72 @@
'use strict';
let bundle = (() => {
var _ref = _asyncToGenerator(function* (main, command) {
// Require bundler here so the help command is fast
const Bundler = require('../');
if (command.name() === 'build') {
process.env.NODE_ENV = 'production';
} else {
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
}
if (command.cert && command.key) {
command.https = {
cert: command.cert,
key: command.key
};
}
const bundler = new Bundler(main, command);
command.target = command.target || 'browser';
if (command.name() === 'serve' && command.target === 'browser') {
const server = yield bundler.serve(command.port || 1234, command.https);
if (server && command.open) {
yield require('./utils/openInBrowser')(`${command.https ? 'https' : 'http'}://localhost:${server.address().port}`, command.open);
}
} else {
bundler.bundle();
}
});
return function bundle(_x, _x2) {
return _ref.apply(this, arguments);
};
})();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
require('v8-compile-cache');
const chalk = require('chalk');
const program = require('commander');
const version = require('../package.json').version;
program.version(version);
program.command('serve [input...]').description('starts a development server').option('-p, --port <port>', 'set the port to serve on. defaults to 1234', parseInt).option('--hmr-port <port>', 'set the port to serve HMR websockets, defaults to random', parseInt).option('--hmr-hostname <hostname>', 'set the hostname of HMR websockets, defaults to location.hostname of current window').option('--https', 'serves files over HTTPS').option('--cert <path>', 'path to certificate to use with HTTPS').option('--key <path>', 'path to private key to use with HTTPS').option('--open [browser]', 'automatically open in specified browser, defaults to default browser').option('-d, --out-dir <path>', 'set the output directory. defaults to "dist"').option('-o, --out-file <filename>', 'set the output filename for the application entry point.').option('--public-url <url>', 'set the public URL to serve on. defaults to the same as the --out-dir option').option('--global <variable>', 'expose your module through a global variable').option('--no-hmr', 'disable hot module replacement').option('--no-cache', 'disable the filesystem cache').option('--no-source-maps', 'disable sourcemaps').option('--no-autoinstall', 'disable autoinstall').option('-t, --target [target]', 'set the runtime environment, either "node", "browser" or "electron". defaults to "browser"', /^(node|browser|electron)$/).option('-V, --version', 'output the version number').option('--log-level <level>', 'set the log level, either "0" (no output), "1" (errors), "2" (warnings + errors) or "3" (all).', /^([0-3])$/).action(bundle);
program.command('watch [input...]').description('starts the bundler in watch mode').option('-d, --out-dir <path>', 'set the output directory. defaults to "dist"').option('-o, --out-file <filename>', 'set the output filename for the application entry point.').option('--public-url <url>', 'set the public URL to serve on. defaults to the same as the --out-dir option').option('--global <variable>', 'expose your module through a global variable').option('--hmr-port <port>', 'set the port to serve HMR websockets, defaults to random', parseInt).option('--hmr-hostname <hostname>', 'set the hostname of HMR websockets, defaults to location.hostname of current window').option('--no-hmr', 'disable hot module replacement').option('--no-cache', 'disable the filesystem cache').option('--no-source-maps', 'disable sourcemaps').option('--no-autoinstall', 'disable autoinstall').option('-t, --target [target]', 'set the runtime environment, either "node", "browser" or "electron". defaults to "browser"', /^(node|browser|electron)$/).option('--log-level <level>', 'set the log level, either "0" (no output), "1" (errors), "2" (warnings + errors) or "3" (all).', /^([0-3])$/).action(bundle);
program.command('build [input...]').description('bundles for production').option('-d, --out-dir <path>', 'set the output directory. defaults to "dist"').option('-o, --out-file <filename>', 'set the output filename for the application entry point.').option('--public-url <url>', 'set the public URL to serve on. defaults to the same as the --out-dir option').option('--global <variable>', 'expose your module through a global variable').option('--no-minify', 'disable minification').option('--no-cache', 'disable the filesystem cache').option('--no-source-maps', 'disable sourcemaps').option('-t, --target <target>', 'set the runtime environment, either "node", "browser" or "electron". defaults to "browser"', /^(node|browser|electron)$/).option('--detailed-report', 'print a detailed build report after a completed build').option('--log-level <level>', 'set the log level, either "0" (no output), "1" (errors), "2" (warnings + errors) or "3" (all).', /^([0-3])$/).action(bundle);
program.command('help [command]').description('display help information for a command').action(function (command) {
let cmd = program.commands.find(c => c.name() === command) || program;
cmd.help();
});
program.on('--help', function () {
console.log('');
console.log(' Run `' + chalk.bold('parcel help <command>') + '` for more information on specific commands');
console.log('');
});
// Make serve the default command except for --help
var args = process.argv;
if (args[2] === '--help' || args[2] === '-h') args[2] = 'help';
if (!args[2] || !program.commands.some(c => c.name() === args[2])) {
args.splice(2, 0, 'serve');
}
program.parse(args);

View file

@ -0,0 +1,59 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Packager = require('./Packager');
class CSSPackager extends Packager {
addAsset(asset) {
var _this = this;
return _asyncToGenerator(function* () {
let css = asset.generated.css || '';
// Figure out which media types this asset was imported with.
// We only want to import the asset once, so group them all together.
let media = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = asset.parentDeps[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let dep = _step.value;
if (!dep.media) {
// Asset was imported without a media type. Don't wrap in @media.
media.length = 0;
break;
} else {
media.push(dep.media);
}
}
// If any, wrap in an @media block
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
if (media.length) {
css = `@media ${media.join(', ')} {\n${css.trim()}\n}\n`;
}
yield _this.write(css);
})();
}
}
module.exports = CSSPackager;

View file

@ -0,0 +1,119 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Packager = require('./Packager');
const posthtml = require('posthtml');
const path = require('path');
const urlJoin = require('../utils/urlJoin');
// https://www.w3.org/TR/html5/dom.html#metadata-content-2
const metadataContent = new Set(['base', 'link', 'meta', 'noscript', 'script', 'style', 'template', 'title']);
class HTMLPackager extends Packager {
addAsset(asset) {
var _this = this;
return _asyncToGenerator(function* () {
let html = asset.generated.html || '';
// Find child bundles that have JS or CSS sibling bundles,
// add them to the head so they are loaded immediately.
let siblingBundles = Array.from(_this.bundle.childBundles).reduce(function (p, b) {
return p.concat([...b.siblingBundles.values()]);
}, []).filter(function (b) {
return b.type === 'css' || b.type === 'js';
});
if (siblingBundles.length > 0) {
html = posthtml(_this.insertSiblingBundles.bind(_this, siblingBundles)).process(html, { sync: true }).html;
}
yield _this.write(html);
})();
}
addBundlesToTree(bundles, tree) {
const head = find(tree, 'head');
if (head) {
const content = head.content || (head.content = []);
content.push(...bundles);
return;
}
const html = find(tree, 'html');
const content = html ? html.content || (html.content = []) : tree;
const index = findBundleInsertIndex(content);
content.splice(index, 0, ...bundles);
}
insertSiblingBundles(siblingBundles, tree) {
const bundles = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = siblingBundles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let bundle = _step.value;
if (bundle.type === 'css') {
bundles.push({
tag: 'link',
attrs: {
rel: 'stylesheet',
href: urlJoin(this.options.publicURL, path.basename(bundle.name))
}
});
} else if (bundle.type === 'js') {
bundles.push({
tag: 'script',
attrs: {
src: urlJoin(this.options.publicURL, path.basename(bundle.name))
}
});
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
this.addBundlesToTree(bundles, tree);
}
}
function find(tree, tag) {
let res;
tree.match({ tag }, node => {
res = node;
return node;
});
return res;
}
function findBundleInsertIndex(content) {
for (let index = 0; index < content.length; index++) {
const node = content[index];
if (node && node.tag && !metadataContent.has(node.tag)) {
return index;
}
}
return 0;
}
module.exports = HTMLPackager;

View file

@ -0,0 +1,360 @@
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Packager = require('./Packager');
const t = require('babel-types');
const path = require('path');
const fs = require('fs');
const concat = require('../transforms/concat');
const prelude = fs.readFileSync(path.join(__dirname, '../builtins/prelude2.js'), 'utf8').trim();
class JSConcatPackager extends Packager {
write(string) {
var _this = this;
return _asyncToGenerator(function* () {
_this.buffer += string;
})();
}
start() {
var _this2 = this;
return _asyncToGenerator(function* () {
_this2.addedAssets = new Set();
_this2.exposedModules = new Set();
_this2.buffer = '';
_this2.exports = new Map();
_this2.wildcards = new Map();
_this2.moduleMap = new Map();
_this2.needsPrelude = process.env.NODE_ENV === 'test';
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = _this2.bundle.assets[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let asset = _step.value;
// If this module is referenced by another bundle, it needs to be exposed externally.
let isExposed = !Array.from(asset.parentDeps).every(function (dep) {
return _this2.bundle.assets.has(_this2.bundler.loadedAssets.get(dep.parent));
});
if (isExposed || _this2.bundle.entryAsset === asset && _this2.bundle.parentBundle) {
_this2.exposedModules.add(asset);
_this2.needsPrelude = true;
}
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = asset.depAssets.values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
let mod = _step2.value;
if (!_this2.bundle.assets.has(mod)) {
_this2.needsPrelude = true;
break;
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
if (_this2.needsPrelude) {
if (_this2.bundle.entryAsset) {
_this2.exposedModules.add(_this2.bundle.entryAsset);
}
yield _this2.write(prelude + '(function (require) {\n');
} else {
yield _this2.write('(function () {\n');
}
})();
}
getExportIdentifier(asset) {
return '$' + asset.id + '$exports';
}
addAsset(asset) {
var _this3 = this;
return _asyncToGenerator(function* () {
if (_this3.addedAssets.has(asset)) {
return;
}
_this3.addedAssets.add(asset);
let js = asset.generated.js;
_this3.moduleMap.set(asset.id, asset);
_this3.wildcards.set(asset.id, asset.cacheData.wildcards);
for (let key in asset.cacheData.exports) {
let local = '$' + asset.id + '$export$' + asset.cacheData.exports[key];
if (key !== local) {
_this3.exports.set(key, local);
}
}
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = asset.depAssets[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
let _ref = _step3.value;
var _ref2 = _slicedToArray(_ref, 2);
let dep = _ref2[0];
let mod = _ref2[1];
let depName = '$' + asset.id + '$require$' + t.toIdentifier(dep.name);
let moduleName = _this3.getExportIdentifier(mod);
// If this module is not in the current bundle, generate a `require` call for it.
if (!_this3.bundle.assets.has(mod)) {
moduleName = `require(${mod.id})`;
}
js = js.split(depName).join(moduleName);
// If this was an ES6 export all (e.g. export * from 'foo'), resolve to the original exports.
if (dep.isExportAll) {
for (let exp in mod.cacheData.exports) {
let id = mod.cacheData.exports[exp];
if (id !== 'default') {
let key = '$' + asset.id + '$export$' + id;
asset.cacheData.exports[key] = id;
_this3.exports.set(key, _this3.exports.get('$' + mod.id + '$export$' + id) || exp);
}
}
}
if (dep.isES6Import) {
if (mod.cacheData.isES6Module) {
js = js.split('$' + asset.id + '$import$' + t.toIdentifier(dep.name)).join('$' + mod.id + '$export');
} else {
js = js.split('$' + asset.id + '$import$' + t.toIdentifier(dep.name) + '$default').join('$' + mod.id + '$exports');
js = js.split('$' + asset.id + '$import$' + t.toIdentifier(dep.name) + '$').join('$' + mod.id + '$exports.');
}
}
let depResolve = '$' + asset.id + '$require_resolve$' + t.toIdentifier(dep.name);
let resolved = '' + mod.id;
if (dep.dynamic && _this3.bundle.childBundles.has(mod.parentBundle)) {
let bundles = [_this3.getBundleSpecifier(mod.parentBundle)];
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
try {
for (var _iterator4 = mod.parentBundle.siblingBundles[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
let child = _step4.value;
if (!child.isEmpty) {
bundles.push(_this3.getBundleSpecifier(child));
yield _this3.addBundleLoader(child.type);
}
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4.return) {
_iterator4.return();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
}
}
bundles.push(mod.id);
resolved = JSON.stringify(bundles);
yield _this3.addBundleLoader(mod.type);
}
js = js.split(depResolve).join(resolved);
}
// Replace all re-exported variables
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
js = js.trim() + '\n';
yield _this3.write(`\n/* ASSET: ${asset.id} - ${path.relative(_this3.options.rootDir, asset.name)} */\n${js}`);
})();
}
getBundleSpecifier(bundle) {
let name = path.basename(bundle.name);
if (bundle.entryAsset) {
return [name, bundle.entryAsset.id];
}
return name;
}
addAssetToBundle(asset) {
var _this4 = this;
return _asyncToGenerator(function* () {
if (_this4.bundle.assets.has(asset)) {
return;
}
_this4.bundle.addAsset(asset);
if (!asset.parentBundle) {
asset.parentBundle = _this4.bundle;
}
// Add all dependencies as well
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (var _iterator5 = asset.depAssets.values()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
let child = _step5.value;
yield _this4.addAssetToBundle(child, _this4.bundle);
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5.return) {
_iterator5.return();
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
}
}
}
yield _this4.addAsset(asset);
})();
}
addBundleLoader(bundleType) {
var _this5 = this;
return _asyncToGenerator(function* () {
let bundleLoader = _this5.bundler.loadedAssets.get(require.resolve('../builtins/bundle-loader'));
if (!bundleLoader) {
bundleLoader = yield _this5.bundler.getAsset('_bundle_loader');
}
if (bundleLoader) {
yield _this5.addAssetToBundle(bundleLoader);
} else {
return;
}
let loader = _this5.options.bundleLoaders[bundleType];
if (loader) {
let asset = yield _this5.bundler.getAsset(loader);
if (!_this5.bundle.assets.has(asset)) {
yield _this5.addAssetToBundle(asset);
yield _this5.write(`${_this5.getExportIdentifier(bundleLoader)}.register(${JSON.stringify(bundleType)},${_this5.getExportIdentifier(asset)});\n`);
}
}
})();
}
end() {
var _this6 = this;
return _asyncToGenerator(function* () {
if (_this6.needsPrelude) {
let exposed = [];
var _iteratorNormalCompletion6 = true;
var _didIteratorError6 = false;
var _iteratorError6 = undefined;
try {
for (var _iterator6 = _this6.exposedModules[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
let m = _step6.value;
exposed.push(`${m.id}: ${_this6.getExportIdentifier(m)}`);
}
} catch (err) {
_didIteratorError6 = true;
_iteratorError6 = err;
} finally {
try {
if (!_iteratorNormalCompletion6 && _iterator6.return) {
_iterator6.return();
}
} finally {
if (_didIteratorError6) {
throw _iteratorError6;
}
}
}
yield _this6.write(`return {${exposed.join(', ')}};\n})`);
} else {
yield _this6.write('})();');
}
Packager.prototype.write.call(_this6, concat(_this6.buffer, _this6.exports, _this6.moduleMap, _this6.wildcards));
})();
}
}
module.exports = JSConcatPackager;

View file

@ -0,0 +1,333 @@
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const fs = require('fs');
const path = require('path');
const Packager = require('./Packager');
const urlJoin = require('../utils/urlJoin');
const lineCounter = require('../utils/lineCounter');
const prelude = {
source: fs.readFileSync(path.join(__dirname, '../builtins/prelude.js'), 'utf8').trim(),
minified: fs.readFileSync(path.join(__dirname, '../builtins/prelude.min.js'), 'utf8').trim().replace(/;$/, '')
};
class JSPackager extends Packager {
start() {
var _this = this;
return _asyncToGenerator(function* () {
_this.first = true;
_this.dedupe = new Map();
_this.bundleLoaders = new Set();
_this.externalModules = new Set();
let preludeCode = _this.options.minify ? prelude.minified : prelude.source;
if (_this.options.target === 'electron') {
preludeCode = `process.env.HMR_PORT=${_this.options.hmrPort};process.env.HMR_HOSTNAME=${JSON.stringify(_this.options.hmrHostname)};` + preludeCode;
}
yield _this.write(preludeCode + '({');
_this.lineOffset = lineCounter(preludeCode);
})();
}
addAsset(asset) {
var _this2 = this;
return _asyncToGenerator(function* () {
if (_this2.dedupe.has(asset.generated.js)) {
return;
}
// Don't dedupe when HMR is turned on since it messes with the asset ids
if (!_this2.options.hmr) {
_this2.dedupe.set(asset.generated.js, asset.id);
}
let deps = {};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = asset.depAssets[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let _ref = _step.value;
var _ref2 = _slicedToArray(_ref, 2);
let dep = _ref2[0];
let mod = _ref2[1];
// For dynamic dependencies, list the child bundles to load along with the module id
if (dep.dynamic && _this2.bundle.childBundles.has(mod.parentBundle)) {
let bundles = [_this2.getBundleSpecifier(mod.parentBundle)];
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = mod.parentBundle.siblingBundles[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
let child = _step2.value;
if (!child.isEmpty) {
bundles.push(_this2.getBundleSpecifier(child));
_this2.bundleLoaders.add(child.type);
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
bundles.push(mod.id);
deps[dep.name] = bundles;
_this2.bundleLoaders.add(mod.type);
} else {
deps[dep.name] = _this2.dedupe.get(mod.generated.js) || mod.id;
// If the dep isn't in this bundle, add it to the list of external modules to preload.
// Only do this if this is the root JS bundle, otherwise they will have already been
// loaded in parallel with this bundle as part of a dynamic import.
if (!_this2.bundle.assets.has(mod) && (!_this2.bundle.parentBundle || _this2.bundle.parentBundle.type !== 'js')) {
_this2.externalModules.add(mod);
_this2.bundleLoaders.add(mod.type);
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
_this2.bundle.addOffset(asset, _this2.lineOffset);
yield _this2.writeModule(asset.id, asset.generated.js, deps, asset.generated.map);
})();
}
getBundleSpecifier(bundle) {
let name = path.basename(bundle.name);
if (bundle.entryAsset) {
return [name, bundle.entryAsset.id];
}
return name;
}
writeModule(id, code, deps = {}, map) {
var _this3 = this;
return _asyncToGenerator(function* () {
let wrapped = _this3.first ? '' : ',';
wrapped += id + ':[function(require,module,exports) {\n' + (code || '') + '\n},';
wrapped += JSON.stringify(deps);
wrapped += ']';
_this3.first = false;
yield _this3.write(wrapped);
// Use the pre-computed line count from the source map if possible
let lineCount = map && map.lineCount ? map.lineCount : lineCounter(code);
_this3.lineOffset += 1 + lineCount;
})();
}
addAssetToBundle(asset) {
var _this4 = this;
return _asyncToGenerator(function* () {
if (_this4.bundle.assets.has(asset)) {
return;
}
_this4.bundle.addAsset(asset);
if (!asset.parentBundle) {
asset.parentBundle = _this4.bundle;
}
// Add all dependencies as well
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = asset.depAssets.values()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
let child = _step3.value;
yield _this4.addAssetToBundle(child, _this4.bundle);
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
yield _this4.addAsset(asset);
})();
}
writeBundleLoaders() {
var _this5 = this;
return _asyncToGenerator(function* () {
if (_this5.bundleLoaders.size === 0) {
return false;
}
let bundleLoader = _this5.bundler.loadedAssets.get(require.resolve('../builtins/bundle-loader'));
if (_this5.externalModules.size > 0 && !bundleLoader) {
bundleLoader = yield _this5.bundler.getAsset('_bundle_loader');
}
if (bundleLoader) {
yield _this5.addAssetToBundle(bundleLoader);
} else {
return;
}
// Generate a module to register the bundle loaders that are needed
let loads = 'var b=require(' + bundleLoader.id + ');';
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
try {
for (var _iterator4 = _this5.bundleLoaders[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
let bundleType = _step4.value;
let loader = _this5.options.bundleLoaders[bundleType];
if (loader) {
let target = _this5.options.target === 'node' ? 'node' : 'browser';
let asset = yield _this5.bundler.getAsset(loader[target]);
yield _this5.addAssetToBundle(asset);
loads += 'b.register(' + JSON.stringify(bundleType) + ',require(' + asset.id + '));';
}
}
// Preload external modules before running entry point if needed
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4.return) {
_iterator4.return();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
}
}
if (_this5.externalModules.size > 0) {
let preload = [];
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (var _iterator5 = _this5.externalModules[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
let mod = _step5.value;
// Find the bundle that has the module as its entry point
let bundle = Array.from(mod.bundles).find(function (b) {
return b.entryAsset === mod;
});
if (bundle) {
preload.push([path.basename(bundle.name), mod.id]);
}
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5.return) {
_iterator5.return();
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
}
}
}
if (_this5.bundle.entryAsset) {
preload.push(_this5.bundle.entryAsset.id);
}
loads += 'b.load(' + JSON.stringify(preload) + ');';
}
// Asset ids normally start at 1, so this should be safe.
yield _this5.writeModule(0, loads, {});
return true;
})();
}
end() {
var _this6 = this;
return _asyncToGenerator(function* () {
let entry = [];
// Add the HMR runtime if needed.
if (_this6.options.hmr) {
let asset = yield _this6.bundler.getAsset(require.resolve('../builtins/hmr-runtime'));
yield _this6.addAssetToBundle(asset);
entry.push(asset.id);
}
if (yield _this6.writeBundleLoaders()) {
entry.push(0);
}
if (_this6.bundle.entryAsset && _this6.externalModules.size === 0) {
entry.push(_this6.bundle.entryAsset.id);
}
yield _this6.dest.write('},{},' + JSON.stringify(entry) + ', ' + JSON.stringify(_this6.options.global || null) + ')');
if (_this6.options.sourceMaps) {
// Add source map url if a map bundle exists
let mapBundle = _this6.bundle.siblingBundlesMap.get('map');
if (mapBundle) {
yield _this6.write(`\n//# sourceMappingURL=${urlJoin(_this6.options.publicURL, path.basename(mapBundle.name))}`);
}
}
yield _this6.dest.end();
})();
}
}
module.exports = JSPackager;

View file

@ -0,0 +1,68 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const fs = require('fs');
const promisify = require('../utils/promisify');
const path = require('path');
var _require = require('../utils/fs');
const mkdirp = _require.mkdirp;
class Packager {
constructor(bundle, bundler) {
this.bundle = bundle;
this.bundler = bundler;
this.options = bundler.options;
}
setup() {
var _this = this;
return _asyncToGenerator(function* () {
// Create sub-directories if needed
if (_this.bundle.name.includes(path.sep)) {
yield mkdirp(path.dirname(_this.bundle.name));
}
_this.dest = fs.createWriteStream(_this.bundle.name);
_this.dest.write = promisify(_this.dest.write.bind(_this.dest));
_this.dest.end = promisify(_this.dest.end.bind(_this.dest));
})();
}
write(string) {
var _this2 = this;
return _asyncToGenerator(function* () {
yield _this2.dest.write(string);
})();
}
start() {
return _asyncToGenerator(function* () {})();
}
// eslint-disable-next-line no-unused-vars
addAsset(asset) {
return _asyncToGenerator(function* () {
throw new Error('Must be implemented by subclasses');
})();
}
getSize() {
return this.dest.bytesWritten;
}
end() {
var _this3 = this;
return _asyncToGenerator(function* () {
yield _this3.dest.end();
})();
}
}
module.exports = Packager;

View file

@ -0,0 +1,40 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const Packager = require('./Packager');
const path = require('path');
const fs = require('../utils/fs');
class RawPackager extends Packager {
// Override so we don't create a file for this bundle.
// Each asset will be emitted as a separate file instead.
setup() {}
addAsset(asset) {
var _this = this;
return _asyncToGenerator(function* () {
let contents = asset.generated[asset.type];
if (!contents || contents && contents.path) {
contents = yield fs.readFile(contents ? contents.path : asset.name);
}
// Create sub-directories if needed
if (_this.bundle.name.includes(path.sep)) {
yield fs.mkdirp(path.dirname(_this.bundle.name));
}
_this.size = contents.length;
yield fs.writeFile(_this.bundle.name, contents);
})();
}
getSize() {
return this.size || 0;
}
end() {}
}
module.exports = RawPackager;

View file

@ -0,0 +1,37 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const path = require('path');
const Packager = require('./Packager');
const SourceMap = require('../SourceMap');
class SourceMapPackager extends Packager {
start() {
var _this = this;
return _asyncToGenerator(function* () {
_this.sourceMap = new SourceMap();
})();
}
addAsset(asset) {
var _this2 = this;
return _asyncToGenerator(function* () {
yield _this2.sourceMap.addMap(asset.generated.map, _this2.bundle.parentBundle.getOffset(asset));
})();
}
end() {
var _this3 = this;
return _asyncToGenerator(function* () {
let file = path.basename(_this3.bundle.name);
yield _this3.write(_this3.sourceMap.stringify(file, path.relative(_this3.options.outDir, _this3.options.rootDir)));
yield Packager.prototype.end.call(_this3);
})();
}
}
module.exports = SourceMapPackager;

View file

@ -0,0 +1,36 @@
'use strict';
const JSPackager = require('./JSPackager');
const CSSPackager = require('./CSSPackager');
const HTMLPackager = require('./HTMLPackager');
const SourceMapPackager = require('./SourceMapPackager');
const RawPackager = require('./RawPackager');
class PackagerRegistry {
constructor() {
this.packagers = new Map();
this.add('js', JSPackager);
this.add('css', CSSPackager);
this.add('html', HTMLPackager);
this.add('map', SourceMapPackager);
}
add(type, packager) {
if (typeof packager === 'string') {
packager = require(packager);
}
this.packagers.set(type, packager);
}
has(type) {
return this.packagers.has(type);
}
get(type) {
return this.packagers.get(type) || RawPackager;
}
}
module.exports = PackagerRegistry;

View file

@ -0,0 +1,341 @@
'use strict';
let babelTransform = (() => {
var _ref = _asyncToGenerator(function* (asset) {
let config = yield getConfig(asset);
if (!config) {
return;
}
yield asset.parseIfNeeded();
// If this is an internally generated config, use our internal babel-core,
// otherwise require a local version from the package we're compiling.
let babel = config.internal ? require('babel-core') : yield localRequire('babel-core', asset.name);
// TODO: support other versions of babel
if (parseInt(babel.version, 10) !== 6) {
throw new Error(`Unsupported babel version: ${babel.version}`);
}
let res = babel.transformFromAst(asset.ast, asset.contents, config);
if (!res.ignored) {
asset.ast = res.ast;
asset.isAstDirty = true;
}
});
return function babelTransform(_x) {
return _ref.apply(this, arguments);
};
})();
let getConfig = (() => {
var _ref2 = _asyncToGenerator(function* (asset) {
let config = yield getBabelConfig(asset);
if (config) {
config.code = false;
config.filename = asset.name;
config.babelrc = false;
// Hide the internal property from babel
let internal = config.internal;
delete config.internal;
Object.defineProperty(config, 'internal', {
value: internal,
configurable: true
});
}
return config;
});
return function getConfig(_x2) {
return _ref2.apply(this, arguments);
};
})();
let getBabelConfig = (() => {
var _ref3 = _asyncToGenerator(function* (asset) {
// If asset is marked as an ES6 modules, this is a second pass after dependencies are extracted.
// Just compile modules to CommonJS.
if (asset.isES6Module) {
return {
internal: true,
plugins: [require('babel-plugin-transform-es2015-modules-commonjs')]
};
}
if (asset.babelConfig) {
return asset.babelConfig;
}
// Consider the module source code rather than precompiled if the resolver
// used the `source` field, or it is not in node_modules.
let isSource = !!(asset.package && asset.package.source) || !asset.name.includes(NODE_MODULES);
// Try to resolve a .babelrc file. If one is found, consider the module source code.
let babelrc = yield getBabelRc(asset, isSource);
isSource = isSource || !!babelrc;
let envConfig = yield getEnvConfig(asset, isSource);
let jsxConfig = getJSXConfig(asset, isSource);
// Merge the babel-preset-env config and the babelrc if needed
if (babelrc && !shouldIgnoreBabelrc(asset.name, babelrc)) {
if (envConfig) {
// Filter out presets that are already applied by babel-preset-env
if (Array.isArray(babelrc.presets)) {
babelrc.presets = babelrc.presets.filter(function (preset) {
return !ENV_PRESETS[getPluginName(preset)];
});
}
// Filter out plugins that are already applied by babel-preset-env
if (Array.isArray(babelrc.plugins)) {
babelrc.plugins = babelrc.plugins.filter(function (plugin) {
return !ENV_PLUGINS[getPluginName(plugin)];
});
}
// Add plugins generated by babel-preset-env to get to the app's target engines.
mergeConfigs(babelrc, envConfig);
}
// Add JSX config if it isn't already specified in the babelrc
let hasReact = hasPlugin(babelrc.presets, 'react') || hasPlugin(babelrc.plugins, 'transform-react-jsx');
if (!hasReact) {
mergeConfigs(babelrc, jsxConfig);
}
return babelrc;
}
// If there is a babel-preset-env config, and it isn't empty use that
if (envConfig && (envConfig.plugins.length > 0 || jsxConfig)) {
mergeConfigs(envConfig, jsxConfig);
return envConfig;
}
// If there is a JSX config, return that
if (jsxConfig) {
return jsxConfig;
}
// Otherwise, don't run babel at all
return null;
});
return function getBabelConfig(_x3) {
return _ref3.apply(this, arguments);
};
})();
/**
* Finds a .babelrc for an asset. By default, .babelrc files inside node_modules are not used.
* However, there are some exceptions:
* - if `browserify.transforms` includes "babelify" in package.json (for legacy module compat)
* - the `source` field in package.json is used by the resolver
*/
let getBabelRc = (() => {
var _ref4 = _asyncToGenerator(function* (asset, isSource) {
// Support legacy browserify packages
let browserify = asset.package && asset.package.browserify;
if (browserify && Array.isArray(browserify.transform)) {
// Look for babelify in the browserify transform list
let babelify = browserify.transform.find(function (t) {
return (Array.isArray(t) ? t[0] : t) === 'babelify';
});
// If specified as an array, override the config with the one specified
if (Array.isArray(babelify) && babelify[1]) {
return babelify[1];
}
// Otherwise, return the .babelrc if babelify was found
return babelify ? yield findBabelRc(asset) : null;
}
// If this asset is not in node_modules, always use the .babelrc
if (isSource) {
return yield findBabelRc(asset);
}
// Otherwise, don't load .babelrc for node_modules.
// See https://github.com/parcel-bundler/parcel/issues/13.
return null;
});
return function getBabelRc(_x4, _x5) {
return _ref4.apply(this, arguments);
};
})();
let findBabelRc = (() => {
var _ref5 = _asyncToGenerator(function* (asset) {
if (asset.package && asset.package.babel) {
return asset.package.babel;
}
return yield asset.getConfig(['.babelrc', '.babelrc.js']);
});
return function findBabelRc(_x6) {
return _ref5.apply(this, arguments);
};
})();
/**
* Generates a babel-preset-env config for an asset.
* This is done by finding the source module's target engines, and the app's
* target engines, and doing a diff to include only the necessary plugins.
*/
let getEnvConfig = (() => {
var _ref6 = _asyncToGenerator(function* (asset, isSourceModule) {
// Load the target engines for the app and generate a babel-preset-env config
let targetEngines = yield getTargetEngines(asset, true);
let targetEnv = yield getEnvPlugins(targetEngines, true);
if (!targetEnv) {
return null;
}
// If this is the app module, the source and target will be the same, so just compile everything.
// Otherwise, load the source engines and generate a babel-present-env config.
if (!isSourceModule) {
let sourceEngines = yield getTargetEngines(asset, false);
let sourceEnv = (yield getEnvPlugins(sourceEngines, false)) || targetEnv;
// Do a diff of the returned plugins. We only need to process the remaining plugins to get to the app target.
let sourcePlugins = new Set(sourceEnv.map(function (p) {
return p[0];
}));
targetEnv = targetEnv.filter(function (plugin) {
return !sourcePlugins.has(plugin[0]);
});
}
return { plugins: targetEnv, internal: true };
});
return function getEnvConfig(_x7, _x8) {
return _ref6.apply(this, arguments);
};
})();
let getEnvPlugins = (() => {
var _ref7 = _asyncToGenerator(function* (targets, useBuiltIns = false) {
if (!targets) {
return null;
}
let key = JSON.stringify(targets);
if (envCache.has(key)) {
return envCache.get(key);
}
let plugins = presetEnv.default({}, { targets, modules: false, useBuiltIns: useBuiltIns ? 'entry' : false }).plugins;
envCache.set(key, plugins);
return plugins;
});
return function getEnvPlugins(_x9) {
return _ref7.apply(this, arguments);
};
})();
/**
* Generates a babel config for JSX. Attempts to detect react or react-like libraries
* and changes the pragma accordingly.
*/
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const presetEnv = require('babel-preset-env');
const getTargetEngines = require('../utils/getTargetEngines');
const localRequire = require('../utils/localRequire');
const path = require('path');
var _require = require('babel-core');
const babelUtils = _require.util;
const NODE_MODULES = `${path.sep}node_modules${path.sep}`;
const ENV_PLUGINS = require('babel-preset-env/data/plugins');
const ENV_PRESETS = {
es2015: true,
es2016: true,
es2017: true,
latest: true,
env: true
};
const JSX_EXTENSIONS = {
'.jsx': true,
'.tsx': true
};
const JSX_PRAGMA = {
react: 'React.createElement',
preact: 'h',
nervjs: 'Nerv.createElement',
hyperapp: 'h'
};
module.exports = babelTransform;
babelTransform.getConfig = getConfig;
function mergeConfigs(a, b) {
if (b) {
a.presets = (a.presets || []).concat(b.presets || []);
a.plugins = (a.plugins || []).concat(b.plugins || []);
}
return a;
}
function hasPlugin(arr, plugin) {
return Array.isArray(arr) && arr.some(p => getPluginName(p) === plugin);
}
function getPluginName(p) {
return Array.isArray(p) ? p[0] : p;
}
function shouldIgnoreBabelrc(filename, babelrc) {
// Determine if we should ignore this babelrc file. We do this here instead of
// letting babel-core handle it because this config might be merged with our
// autogenerated one later which shouldn't be ignored.
let ignore = babelUtils.arrayify(babelrc.ignore, babelUtils.regexify);
let only = babelrc.only && babelUtils.arrayify(babelrc.only, babelUtils.regexify);
return babelUtils.shouldIgnore(filename, ignore, only);
}
const envCache = new Map();
function getJSXConfig(asset, isSourceModule) {
// Don't enable JSX in node_modules
if (!isSourceModule) {
return null;
}
// Find a dependency that we can map to a JSX pragma
let pragma = null;
for (let dep in JSX_PRAGMA) {
let pkg = asset.package;
if (pkg && (pkg.dependencies && pkg.dependencies[dep] || pkg.devDependencies && pkg.devDependencies[dep])) {
pragma = JSX_PRAGMA[dep];
break;
}
}
if (pragma || JSX_EXTENSIONS[path.extname(asset.name)]) {
return {
plugins: [[require('babel-plugin-transform-react-jsx'), { pragma }]],
internal: true
};
}
}

View file

@ -0,0 +1,218 @@
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
const babylon = require('babylon');
const t = require('babel-types');
const traverse = require('babel-traverse').default;
const generate = require('babel-generator').default;
const EXPORTS_RE = /^\$([\d]+)\$exports$/;
const EXPORT_RE = /^\$([\d]+)\$export\$(.+)$/;
// TODO: minify
// TODO: source-map
module.exports = (code, exports, moduleMap, wildcards) => {
let ast = babylon.parse(code);
let addedExports = new Set();
let commentedBindings = new Set();
let resolveModule = (id, name) => {
let module = moduleMap.get(id);
return module.depAssets.get(module.dependencies.get(name)).id;
};
function replaceExportNode(id, name, path) {
path = getOuterStatement(path);
let node = tail(id, id => `$${id}$export$${name}`);
if (!node) {
// if there is no named export then lookup for a CommonJS export
node = tail(id, id => `$${id}$exports`) || t.identifier(`$${id}$exports`);
// if there is a CommonJS export return $id$exports.name
if (node) {
return t.memberExpression(node, t.identifier(name));
}
}
return node;
function tail(id, symbol) {
let computedSymbol = symbol(id);
// if the symbol is in the scope there is not need to remap it
if (path.scope.hasBinding(computedSymbol)) {
return t.identifier(computedSymbol);
}
if (exports.has(computedSymbol)) {
return t.identifier(exports.get(computedSymbol));
}
// if there is a wildcard for the module
// default exports are excluded from wildcard exports
if (wildcards.has(id) && name !== 'default') {
/* recursively lookup the symbol
* this is needed when there is deep export wildcards, like in the following:
* - a.js
* > export * from './b'
* - b.js
* > export * from './c'
* - c.js in es6
* > export * from 'lodash'
* - c.js in cjs
* > module.exports = require('lodash')
*/
let node = null;
wildcards.get(id).find(name => node = tail(resolveModule(id, name), symbol));
return node;
}
return null;
}
}
traverse(ast, {
CallExpression(path) {
var _path$node = path.node;
let args = _path$node.arguments,
callee = _path$node.callee;
// each require('module') call gets replaced with $parcel$require(id, 'module')
if (t.isIdentifier(callee, { name: '$parcel$require' })) {
var _args = _slicedToArray(args, 2);
let id = _args[0],
name = _args[1];
if (args.length !== 2 || !t.isNumericLiteral(id) || !t.isStringLiteral(name)) {
throw new Error('invariant: invalid signature, expected : $parcel$require(number, string)');
}
const mod = resolveModule(id.value, name.value);
if (typeof mod === 'undefined') {
throw new Error(`Cannot find module "${name.value}"`);
}
path.replaceWith(t.identifier(`$${mod}$exports`));
}
},
MemberExpression(path) {
if (!path.isReferenced()) {
return;
}
var _path$node2 = path.node;
let object = _path$node2.object,
property = _path$node2.property;
if (!t.isIdentifier(object) || !t.isIdentifier(property)) {
return;
}
let match = object.name.match(EXPORTS_RE);
if (match) {
let exportName = '$' + match[1] + '$export$' + property.name;
if (path.scope.hasBinding(exportName)) {
path.replaceWith(t.identifier(exportName));
}
}
},
Identifier(path) {
let name = path.node.name;
if (typeof name !== 'string') {
return;
}
let match = name.match(EXPORTS_RE);
if (match) {
if (!path.scope.hasBinding(name) && !addedExports.has(name)) {
let moduleExports = moduleMap.get(+match[1]).cacheData.exports;
addedExports.add(name);
getOuterStatement(path).insertBefore(t.variableDeclaration('var', [t.variableDeclarator(t.identifier(name), t.objectExpression(Object.keys(moduleExports).map(key => {
let binding = path.scope.getBinding(exports.get(key) || key);
if (!binding) {
return null;
}
let exportName = key.match(EXPORT_RE)[2];
let expr = replaceExportNode(+match[1], exportName, path);
if (expr === null) {
return null;
}
if (binding.constant) {
return t.objectProperty(t.identifier(exportName), expr);
} else {
if (!commentedBindings.has(binding)) {
commentedBindings.add(binding);
binding.constantViolations.forEach(path => path.getFunctionParent().addComment('leading', ` bailout: mutates ${generate(expr).code}`, '\n'));
}
return t.objectMethod('get', t.identifier(exportName), [], t.blockStatement([t.returnStatement(expr)]));
}
}).filter(property => property !== null)))]));
}
return;
}
match = name.match(EXPORT_RE);
if (match && !path.scope.hasBinding(name) && !addedExports.has(name)) {
let id = Number(match[1]);
let exportName = match[2];
let node = replaceExportNode(id, exportName, path);
addedExports.add(name);
if (node) {
path.replaceWith(node);
}
}
}
});
return generate(ast, code).code;
};
function getOuterStatement(path) {
if (validate(path)) {
return path;
}
return path.findParent(validate);
function validate(path) {
if (!t.isStatement(path.node) || t.isBlockStatement(path.node)) {
return false;
}
// TODO: use scope?
let outerBlocks = 0;
path.findParent(parent => {
if (t.isBlockStatement(parent.node)) {
outerBlocks++;
}
return false;
});
return outerBlocks === 1;
}
}

View file

@ -0,0 +1,25 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const posthtml = require('posthtml');
const htmlnano = require('htmlnano');
module.exports = (() => {
var _ref = _asyncToGenerator(function* (asset) {
yield asset.parseIfNeeded();
const htmlNanoConfig = asset.package.htmlnano || (yield asset.getConfig(['.htmlnanorc', '.htmlnanorc.js'])) || {};
let res = yield posthtml([htmlnano(htmlNanoConfig)]).process(asset.ast, {
skipParse: true
});
asset.ast = res.tree;
asset.isAstDirty = true;
});
return function (_x) {
return _ref.apply(this, arguments);
};
})();

View file

@ -0,0 +1,76 @@
'use strict';
let getConfig = (() => {
var _ref2 = _asyncToGenerator(function* (asset) {
let config = asset.package.postcss || (yield asset.getConfig(['.postcssrc', '.postcssrc.js', 'postcss.config.js']));
let enableModules = asset.options.rendition && asset.options.rendition.modules;
if (!config && !asset.options.minify && !enableModules) {
return;
}
config = Object.assign({}, config);
let postcssModulesConfig = {
getJSON: function getJSON(filename, json) {
return asset.cssModules = json;
}
};
if (config.plugins && config.plugins['postcss-modules']) {
postcssModulesConfig = Object.assign(config.plugins['postcss-modules'], postcssModulesConfig);
delete config.plugins['postcss-modules'];
}
config.plugins = yield loadPlugins(config.plugins, asset.name);
if (config.modules || enableModules) {
let postcssModules = yield localRequire('postcss-modules', asset.name);
config.plugins.push(postcssModules(postcssModulesConfig));
}
if (asset.options.minify) {
config.plugins.push(cssnano((yield asset.getConfig(['cssnano.config.js'])) || {
// Only enable safe css transforms by default.
// See: https://github.com/parcel-bundler/parcel/issues/698
// Note: Remove when upgrading cssnano to v4
// See: https://github.com/ben-eb/cssnano/releases/tag/v4.0.0-rc.0
safe: true
}));
}
config.from = asset.name;
config.to = asset.name;
return config;
});
return function getConfig(_x2) {
return _ref2.apply(this, arguments);
};
})();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const localRequire = require('../utils/localRequire');
const loadPlugins = require('../utils/loadPlugins');
const postcss = require('postcss');
const cssnano = require('cssnano');
module.exports = (() => {
var _ref = _asyncToGenerator(function* (asset) {
let config = yield getConfig(asset);
if (!config) {
return;
}
yield asset.parseIfNeeded();
let res = yield postcss(config.plugins).process(asset.getCSSAst(), config);
asset.ast.css = res.css;
asset.ast.dirty = false;
});
return function (_x) {
return _ref.apply(this, arguments);
};
})();

View file

@ -0,0 +1,43 @@
'use strict';
let getConfig = (() => {
var _ref2 = _asyncToGenerator(function* (asset) {
let config = asset.package.posthtml || (yield asset.getConfig(['.posthtmlrc', '.posthtmlrc.js', 'posthtml.config.js']));
if (!config && !asset.options.minify) {
return;
}
config = Object.assign({}, config);
config.plugins = yield loadPlugins(config.plugins, asset.name);
config.skipParse = true;
return config;
});
return function getConfig(_x2) {
return _ref2.apply(this, arguments);
};
})();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const loadPlugins = require('../utils/loadPlugins');
const posthtml = require('posthtml');
module.exports = (() => {
var _ref = _asyncToGenerator(function* (asset) {
let config = yield getConfig(asset);
if (!config) {
return;
}
yield asset.parseIfNeeded();
let res = yield posthtml(config.plugins).process(asset.ast, config);
asset.ast = res.tree;
asset.isAstDirty = true;
});
return function (_x) {
return _ref.apply(this, arguments);
};
})();

View file

@ -0,0 +1,76 @@
'use strict';
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
var _require = require('uglify-es');
const minify = _require.minify;
const SourceMap = require('../SourceMap');
module.exports = (() => {
var _ref = _asyncToGenerator(function* (asset) {
yield asset.parseIfNeeded();
// Convert AST into JS
let source = (yield asset.generate()).js;
let customConfig = yield asset.getConfig(['.uglifyrc']);
let options = {
warnings: true,
mangle: {
toplevel: true
}
};
let sourceMap;
if (asset.options.sourceMap) {
sourceMap = new SourceMap();
options.output = {
source_map: {
add(source, gen_line, gen_col, orig_line, orig_col, name) {
sourceMap.addMapping({
source,
name,
original: {
line: orig_line,
column: orig_col
},
generated: {
line: gen_line,
column: gen_col
}
});
}
}
};
}
if (customConfig) {
options = Object.assign(options, customConfig);
}
let result = minify(source, options);
if (result.error) {
throw result.error;
}
if (sourceMap) {
if (asset.sourceMap) {
asset.sourceMap = yield new SourceMap().extendSourceMap(asset.sourceMap, sourceMap);
} else {
asset.sourceMap = sourceMap;
}
}
// babel-generator did our code generation for us, so remove the old AST
asset.ast = null;
asset.outputCode = result.code;
asset.isAstDirty = false;
});
return function (_x) {
return _ref.apply(this, arguments);
};
})();

View file

@ -0,0 +1,100 @@
"use strict";
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
class PromiseQueue {
constructor(callback, options = {}) {
this.process = callback;
this.maxConcurrent = options.maxConcurrent || Infinity;
this.retry = options.retry !== false;
this.queue = [];
this.processing = new Set();
this.processed = new Set();
this.numRunning = 0;
this.runPromise = null;
this.resolve = null;
this.reject = null;
}
add(job, ...args) {
if (this.processing.has(job)) {
return;
}
if (this.runPromise && this.numRunning < this.maxConcurrent) {
this._runJob(job, args);
} else {
this.queue.push([job, args]);
}
this.processing.add(job);
}
run() {
if (this.runPromise) {
return this.runPromise;
}
const runPromise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
this.runPromise = runPromise;
this._next();
return runPromise;
}
_runJob(job, args) {
var _this = this;
return _asyncToGenerator(function* () {
try {
_this.numRunning++;
yield _this.process(job, ...args);
_this.processing.delete(job);
_this.processed.add(job);
_this.numRunning--;
_this._next();
} catch (err) {
_this.numRunning--;
if (_this.retry) {
_this.queue.push([job, args]);
} else {
_this.processing.delete(job);
}
if (_this.reject) {
_this.reject(err);
}
_this._reset();
}
})();
}
_next() {
if (!this.runPromise) {
return;
}
if (this.queue.length > 0) {
while (this.queue.length > 0 && this.numRunning < this.maxConcurrent) {
this._runJob(...this.queue.shift());
}
} else if (this.processing.size === 0) {
this.resolve(this.processed);
this._reset();
}
}
_reset() {
this.processed = new Set();
this.runPromise = null;
this.resolve = null;
this.reject = null;
}
}
module.exports = PromiseQueue;

View file

@ -0,0 +1,140 @@
'use strict';
const path = require('path');
const prettifyTime = require('./prettifyTime');
const logger = require('../Logger');
const emoji = require('./emoji');
const filesize = require('filesize');
const LARGE_BUNDLE_SIZE = 1024 * 1024;
const NUM_LARGE_ASSETS = 10;
const COLUMNS = [{ align: 'left' }, // name
{ align: 'right' }, // size
{ align: 'right' // time
}];
function bundleReport(mainBundle, detailed = false) {
// Get a list of bundles sorted by size
let bundles = Array.from(iterateBundles(mainBundle)).sort((a, b) => b.totalSize - a.totalSize);
let rows = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = bundles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let bundle = _step.value;
// Add a row for the bundle
rows.push([formatFilename(bundle.name, logger.chalk.cyan.bold), logger.chalk.bold(prettifySize(bundle.totalSize, bundle.totalSize > LARGE_BUNDLE_SIZE)), logger.chalk.green.bold(prettifyTime(bundle.bundleTime))]);
// If detailed, generate a list of the top 10 largest assets in the bundle
if (detailed && bundle.assets.size > 1) {
let assets = Array.from(bundle.assets).filter(a => a.type === bundle.type).sort((a, b) => b.bundledSize - a.bundledSize);
let largestAssets = assets.slice(0, NUM_LARGE_ASSETS);
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = largestAssets[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
let asset = _step2.value;
// Add a row for the asset.
rows.push([(asset == assets[assets.length - 1] ? '└── ' : '├── ') + formatFilename(asset.name, logger.chalk.reset), logger.chalk.dim(prettifySize(asset.bundledSize)), logger.chalk.dim(logger.chalk.green(prettifyTime(asset.buildTime)))]);
}
// Show how many more assets there are
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
if (assets.length > largestAssets.length) {
rows.push(['└── ' + logger.chalk.dim(`+ ${assets.length - largestAssets.length} more assets`)]);
}
// If this isn't the last bundle, add an empty row before the next one
if (bundle !== bundles[bundles.length - 1]) {
rows.push([]);
}
}
}
// Render table
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
logger.log('');
logger.table(COLUMNS, rows);
}
module.exports = bundleReport;
function* iterateBundles(bundle) {
if (!bundle.isEmpty) {
yield bundle;
}
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = bundle.childBundles[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
let child = _step3.value;
yield* iterateBundles(child);
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
}
function prettifySize(size, isLarge) {
let res = filesize(size);
if (isLarge) {
return logger.chalk.yellow(emoji.warning + ' ' + res);
}
return logger.chalk.magenta(res);
}
function formatFilename(filename, color = logger.chalk.reset) {
let dir = path.relative(process.cwd(), path.dirname(filename));
return logger.chalk.dim(dir + (dir ? path.sep : '')) + color(path.basename(filename));
}

View file

@ -0,0 +1,94 @@
'use strict';
let resolve = (() => {
var _ref = _asyncToGenerator(function* (filepath, filenames, root = path.parse(filepath).root) {
filepath = path.dirname(filepath);
// Don't traverse above the module root
if (filepath === root || path.basename(filepath) === 'node_modules') {
return null;
}
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = filenames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
const filename = _step.value;
let file = path.join(filepath, filename);
let exists = existsCache.has(file) ? existsCache.get(file) : yield fs.exists(file);
if (exists) {
existsCache.set(file, true);
return file;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return resolve(filepath, filenames, root);
});
return function resolve(_x, _x2) {
return _ref.apply(this, arguments);
};
})();
let load = (() => {
var _ref2 = _asyncToGenerator(function* (filepath, filenames, root = path.parse(filepath).root) {
let configFile = yield resolve(filepath, filenames, root);
if (configFile) {
try {
let extname = path.extname(configFile).slice(1);
if (extname === 'js') {
return require(configFile);
}
let configContent = (yield fs.readFile(configFile)).toString();
let parse = PARSERS[extname] || PARSERS.json;
return configContent ? parse(configContent) : null;
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND' || err.code === 'ENOENT') {
existsCache.delete(configFile);
return null;
}
throw err;
}
}
return null;
});
return function load(_x3, _x4) {
return _ref2.apply(this, arguments);
};
})();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const fs = require('./fs');
const path = require('path');
const PARSERS = {
json: require('json5').parse,
toml: require('toml').parse
};
const existsCache = new Map();
exports.resolve = resolve;
exports.load = load;

View file

@ -0,0 +1,18 @@
"use strict";
const serverErrorList = {
EACCES: "You don't have access to bind the server to port {port}.",
EADDRINUSE: 'There is already a process listening on port {port}.'
};
function serverErrors(err, port) {
let desc = `Error: ${err.code} occurred while setting up server on port ${port}.`;
if (serverErrorList[err.code]) {
desc = serverErrorList[err.code].replace(/{port}/g, port);
}
return desc;
}
module.exports.serverErrors = serverErrors;

View file

@ -0,0 +1,14 @@
"use strict";
module.exports = function deferred() {
let resolve, reject;
let promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
promise.resolve = resolve;
promise.reject = reject;
return promise;
};

View file

@ -0,0 +1,9 @@
'use strict';
const supportsEmoji = process.platform !== 'win32' || process.env.TERM === 'xterm-256color';
// Fallback symbols for Windows from https://en.wikipedia.org/wiki/Code_page_437
exports.progress = supportsEmoji ? '⏳' : '∞';
exports.success = supportsEmoji ? '✨' : '√';
exports.error = supportsEmoji ? '🚨' : '×';
exports.warning = supportsEmoji ? '⚠️' : '‼';

36
VISUALIZACION/node_modules/parcel-bundler/lib/utils/env.js generated vendored Executable file
View file

@ -0,0 +1,36 @@
'use strict';
let loadEnv = (() => {
var _ref = _asyncToGenerator(function* (filepath) {
const NODE_ENV = process.env.NODE_ENV || 'development';
const dotenvFiles = [`.env.${NODE_ENV}.local`, `.env.${NODE_ENV}`,
// Don't include `.env.local` for `test` environment
// since normally you expect tests to produce the same
// results for everyone
NODE_ENV !== 'test' && '.env.local', '.env'].filter(Boolean);
yield Promise.all(dotenvFiles.map((() => {
var _ref2 = _asyncToGenerator(function* (dotenvFile) {
const envPath = yield config.resolve(filepath, [dotenvFile]);
if (envPath) {
dotenv.config({ path: envPath });
}
});
return function (_x2) {
return _ref2.apply(this, arguments);
};
})()));
});
return function loadEnv(_x) {
return _ref.apply(this, arguments);
};
})();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const config = require('./config');
const dotenv = require('dotenv');
module.exports = loadEnv;

20
VISUALIZACION/node_modules/parcel-bundler/lib/utils/fs.js generated vendored Executable file
View file

@ -0,0 +1,20 @@
'use strict';
const promisify = require('./promisify');
const fs = require('fs');
const mkdirp = require('mkdirp');
exports.readFile = promisify(fs.readFile);
exports.writeFile = promisify(fs.writeFile);
exports.stat = promisify(fs.stat);
exports.readdir = promisify(fs.readdir);
exports.unlink = promisify(fs.unlink);
exports.realpath = promisify(fs.realpath);
exports.exists = function (filename) {
return new Promise(resolve => {
fs.exists(filename, resolve);
});
};
exports.mkdirp = promisify(mkdirp);

View file

@ -0,0 +1,114 @@
'use strict';
const forge = require('node-forge');
const fs = require('fs');
const mkdirp = require('mkdirp');
const path = require('path');
const logger = require('../Logger');
function generateCertificate(options = {}) {
const privateKeyPath = path.join(options.cacheDir, 'private.pem');
const certPath = path.join(options.cacheDir, 'primary.crt');
if (options.cache) {
const cachedKey = fs.existsSync(privateKeyPath) && fs.readFileSync(privateKeyPath);
const cachedCert = fs.existsSync(certPath) && fs.readFileSync(certPath);
if (cachedKey && cachedCert) {
return {
key: cachedKey,
cert: cachedCert
};
}
}
logger.log('Generating SSL Certificate...');
const pki = forge.pki;
const keys = pki.rsa.generateKeyPair(2048);
const cert = pki.createCertificate();
cert.publicKey = keys.publicKey;
cert.serialNumber = '01';
cert.validity.notBefore = new Date();
cert.validity.notAfter = new Date();
cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + 1);
const attrs = [{
name: 'commonName',
value: 'parceljs.org'
}, {
name: 'countryName',
value: 'US'
}, {
shortName: 'ST',
value: 'Virginia'
}, {
name: 'localityName',
value: 'Blacksburg'
}, {
name: 'organizationName',
value: 'parcelBundler'
}, {
shortName: 'OU',
value: 'Test'
}];
cert.setSubject(attrs);
cert.setIssuer(attrs);
cert.setExtensions([{
name: 'basicConstraints',
cA: true
}, {
name: 'keyUsage',
keyCertSign: true,
digitalSignature: true,
nonRepudiation: true,
keyEncipherment: true,
dataEncipherment: true
}, {
name: 'extKeyUsage',
serverAuth: true,
clientAuth: true,
codeSigning: true,
emailProtection: true,
timeStamping: true
}, {
name: 'nsCertType',
client: true,
server: true,
email: true,
objsign: true,
sslCA: true,
emailCA: true,
objCA: true
}, {
name: 'subjectAltName',
altNames: [{
type: 6, // URI
value: 'http://example.org/webid#me'
}, {
type: 7, // IP
ip: '127.0.0.1'
}]
}, {
name: 'subjectKeyIdentifier'
}]);
cert.sign(keys.privateKey, forge.md.sha256.create());
const privPem = pki.privateKeyToPem(keys.privateKey);
const certPem = pki.certificateToPem(cert);
if (options.cache) {
mkdirp.sync(options.cacheDir);
fs.writeFileSync(privateKeyPath, privPem);
fs.writeFileSync(certPath, certPem);
}
return {
key: privPem,
cert: certPem
};
}
module.exports = generateCertificate;

View file

@ -0,0 +1,23 @@
'use strict';
let getCertificate = (() => {
var _ref = _asyncToGenerator(function* (options) {
try {
let cert = yield fs.readFile(options.cert);
let key = yield fs.readFile(options.key);
return { key, cert };
} catch (err) {
throw new Error('Certificate and/or key not found');
}
});
return function getCertificate(_x) {
return _ref.apply(this, arguments);
};
})();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const fs = require('./fs');
module.exports = getCertificate;

View file

@ -0,0 +1,54 @@
'use strict';
const path = require('path');
function getRootDir(files) {
let cur = null;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
let file = _step.value;
let parsed = path.parse(file);
if (!cur) {
cur = parsed;
} else if (parsed.root !== cur.root) {
// bail out. there is no common root.
// this can happen on windows, e.g. C:\foo\bar vs. D:\foo\bar
return process.cwd();
} else {
// find the common path parts.
let curParts = cur.dir.split(path.sep);
let newParts = parsed.dir.split(path.sep);
let len = Math.min(curParts.length, newParts.length);
let i = 0;
while (i < len && curParts[i] === newParts[i]) {
i++;
}
cur.dir = i > 1 ? curParts.slice(0, i).join(path.sep) : cur.root;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return cur ? cur.dir : process.cwd();
}
module.exports = getRootDir;

View file

@ -0,0 +1,135 @@
'use strict';
/**
* Loads target node and browser versions from the following locations:
* - package.json engines field
* - package.json browserslist field
* - browserslist or .browserslistrc files
* - .babelrc or .babelrc.js files with babel-preset-env
*/
let getTargetEngines = (() => {
var _ref = _asyncToGenerator(function* (asset, isTargetApp) {
let targets = {};
let path = isTargetApp ? Path.join(asset.options.rootDir, 'index') : asset.name;
let compileTarget = asset.options.target === 'browser' ? 'browsers' : asset.options.target;
let pkg = yield asset.getConfig(['package.json'], { path });
let engines = pkg && pkg.engines;
let nodeVersion = engines && getMinSemver(engines.node);
if (compileTarget === 'node') {
// Use package.engines.node by default if we are compiling for node.
if (typeof nodeVersion === 'string') {
targets.node = nodeVersion;
}
} else {
if (engines && (typeof engines.browsers === 'string' || Array.isArray(engines.browsers))) {
targets.browsers = engines.browsers;
} else if (pkg && pkg.browserslist) {
targets.browsers = pkg.browserslist;
} else {
let browserslist = yield loadBrowserslist(asset, path);
if (browserslist) {
targets.browsers = browserslist;
} else {
let babelTargets = yield loadBabelrc(asset, path);
if (babelTargets && babelTargets.browsers) {
targets.browsers = babelTargets.browsers;
} else if (babelTargets && babelTargets.node && !nodeVersion) {
nodeVersion = babelTargets.node;
}
}
}
// Fall back to package.engines.node for node_modules without any browser target info.
if (!isTargetApp && !targets.browsers && typeof nodeVersion === 'string') {
targets.node = nodeVersion;
}
}
// If we didn't find any targets, set some default engines for the target app.
if (isTargetApp && !targets[compileTarget] && DEFAULT_ENGINES[compileTarget]) {
targets[compileTarget] = DEFAULT_ENGINES[compileTarget];
}
// Parse browser targets
if (targets.browsers) {
if (typeof targets.browsers === 'object' && !Array.isArray(targets.browsers)) {
let env = asset.options.production ? 'production' : process.env.NODE_ENV || 'development';
targets.browsers = targets.browsers[env] || targets.browsers.defaults;
}
if (targets.browsers) {
targets.browsers = browserslist(targets.browsers).sort();
}
}
// Dont compile if we couldn't find any targets
if (Object.keys(targets).length === 0) {
return null;
}
return targets;
});
return function getTargetEngines(_x, _x2) {
return _ref.apply(this, arguments);
};
})();
let loadBrowserslist = (() => {
var _ref2 = _asyncToGenerator(function* (asset, path) {
let config = yield asset.getConfig(['browserslist', '.browserslistrc'], {
path,
load: false
});
if (config) {
return browserslist.readConfig(config);
}
});
return function loadBrowserslist(_x3, _x4) {
return _ref2.apply(this, arguments);
};
})();
let loadBabelrc = (() => {
var _ref3 = _asyncToGenerator(function* (asset, path) {
let config = yield asset.getConfig(['.babelrc', '.babelrc.js'], { path });
if (config && config.presets) {
let env = config.presets.find(function (plugin) {
return Array.isArray(plugin) && (plugin[0] === 'env' || plugin[0] === '@babel/env');
});
if (env && env[1] && env[1].targets) {
return env[1].targets;
}
}
});
return function loadBabelrc(_x5, _x6) {
return _ref3.apply(this, arguments);
};
})();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const browserslist = require('browserslist');
const semver = require('semver');
const Path = require('path');
const DEFAULT_ENGINES = {
browsers: ['> 0.25%'],
node: '6'
};
function getMinSemver(version) {
try {
let range = new semver.Range(version);
let sorted = range.set.sort((a, b) => a[0].semver.compare(b[0].semver));
return sorted[0][0].semver.version;
} catch (err) {
return null;
}
}
module.exports = getTargetEngines;

View file

@ -0,0 +1,141 @@
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
let install = (() => {
var _ref = _asyncToGenerator(function* (modules, filepath, options = {}) {
var _options$installPeers = options.installPeers;
let installPeers = _options$installPeers === undefined ? true : _options$installPeers;
var _options$saveDev = options.saveDev;
let saveDev = _options$saveDev === undefined ? true : _options$saveDev,
packageManager = options.packageManager;
logger.status(emoji.progress, `Installing ${modules.join(', ')}...`);
let packageLocation = yield config.resolve(filepath, ['package.json']);
let cwd = packageLocation ? path.dirname(packageLocation) : process.cwd();
if (!packageManager) {
packageManager = yield determinePackageManager(filepath);
}
let commandToUse = packageManager === 'npm' ? 'install' : 'add';
let args = [commandToUse, ...modules];
if (saveDev) {
args.push('-D');
} else if (packageManager === 'npm') {
args.push('--save');
}
// npm doesn't auto-create a package.json when installing,
// so create an empty one if needed.
if (packageManager === 'npm' && !packageLocation) {
yield fs.writeFile(path.join(cwd, 'package.json'), '{}');
}
try {
yield pipeSpawn(packageManager, args, { cwd });
} catch (err) {
throw new Error(`Failed to install ${modules.join(', ')}.`);
}
if (installPeers) {
yield Promise.all(modules.map(function (m) {
return installPeerDependencies(filepath, m, options);
}));
}
});
return function install(_x, _x2) {
return _ref.apply(this, arguments);
};
})();
let installPeerDependencies = (() => {
var _ref2 = _asyncToGenerator(function* (filepath, name, options) {
let basedir = path.dirname(filepath);
var _ref3 = yield resolve(name, { basedir }),
_ref4 = _slicedToArray(_ref3, 1);
const resolved = _ref4[0];
const pkg = yield config.load(resolved, ['package.json']);
const peers = pkg.peerDependencies || {};
const modules = [];
for (const peer in peers) {
modules.push(`${peer}@${peers[peer]}`);
}
if (modules.length) {
yield install(modules, filepath, Object.assign({}, options, { installPeers: false }));
}
});
return function installPeerDependencies(_x3, _x4, _x5) {
return _ref2.apply(this, arguments);
};
})();
let determinePackageManager = (() => {
var _ref5 = _asyncToGenerator(function* (filepath) {
let configFile = yield config.resolve(filepath, ['yarn.lock', 'package-lock.json']);
let hasYarn = yield checkForYarnCommand();
// If Yarn isn't available, or there is a package-lock.json file, use npm.
let configName = configFile && path.basename(configFile);
if (!hasYarn || configName === 'package-lock.json') {
return 'npm';
}
return 'yarn';
});
return function determinePackageManager(_x6) {
return _ref5.apply(this, arguments);
};
})();
let checkForYarnCommand = (() => {
var _ref6 = _asyncToGenerator(function* () {
if (hasYarn != null) {
return hasYarn;
}
try {
hasYarn = yield commandExists('yarn');
} catch (err) {
hasYarn = false;
}
return hasYarn;
});
return function checkForYarnCommand() {
return _ref6.apply(this, arguments);
};
})();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
const config = require('./config');
const promisify = require('./promisify');
const resolve = promisify(require('resolve'));
const commandExists = require('command-exists');
const logger = require('../Logger');
const emoji = require('./emoji');
const pipeSpawn = require('./pipeSpawn');
const PromiseQueue = require('./PromiseQueue');
const path = require('path');
const fs = require('./fs');
let hasYarn = null;
let queue = new PromiseQueue(install, { maxConcurrent: 1, retry: false });
module.exports = function (...args) {
queue.add(...args);
return queue.run();
};

View file

@ -0,0 +1,13 @@
'use strict';
const isURL = require('is-url');
// Matches anchor (ie: #raptors)
const ANCHOR_REGEXP = /^#/;
// Matches scheme (ie: tel:, mailto:, data:, itms-apps:)
const SCHEME_REGEXP = /^[a-z][a-z0-9\-+.]*:/i;
module.exports = function (url) {
return isURL(url) || ANCHOR_REGEXP.test(url) || SCHEME_REGEXP.test(url);
};

View file

@ -0,0 +1,14 @@
'use strict';
function lineCounter(string) {
let lines = 1;
for (let i = 0; i < string.length; i++) {
if (string.charAt(i) === '\n') {
lines++;
}
}
return lines;
}
module.exports = lineCounter;

Some files were not shown because too many files have changed in this diff Show more