flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
359
BACK_BACK/node_modules/parcel-bundler/lib/Asset.js
generated
vendored
Executable file
359
BACK_BACK/node_modules/parcel-bundler/lib/Asset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,359 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const URL = require('url');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const clone = require('clone');
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
const md5 = require('./utils/md5');
|
||||
|
||||
const isURL = require('./utils/is-url');
|
||||
|
||||
const config = require('./utils/config');
|
||||
|
||||
const syncPromise = require('./utils/syncPromise');
|
||||
|
||||
const logger = require('@parcel/logger');
|
||||
|
||||
const Resolver = require('./Resolver');
|
||||
|
||||
const objectHash = require('./utils/objectHash');
|
||||
|
||||
const t = require('babel-types');
|
||||
/**
|
||||
* 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, options) {
|
||||
this.id = null;
|
||||
this.name = name;
|
||||
this.basename = path.basename(this.name);
|
||||
this.relativeName = path.relative(options.rootDir, this.name).replace(/\\/g, '/');
|
||||
this.options = options;
|
||||
this.encoding = 'utf8';
|
||||
this.type = path.extname(this.name).slice(1);
|
||||
this.hmrPageReload = false;
|
||||
this.processed = false;
|
||||
this.contents = options.rendition ? options.rendition.value : null;
|
||||
this.ast = null;
|
||||
this.generated = null;
|
||||
this.hash = null;
|
||||
this.sourceMaps = null;
|
||||
this.parentDeps = new Set();
|
||||
this.dependencies = new Map();
|
||||
this.depAssets = new Map();
|
||||
this.parentBundle = null;
|
||||
this.bundles = new Set();
|
||||
this.cacheData = {};
|
||||
this.startTime = 0;
|
||||
this.endTime = 0;
|
||||
this.buildTime = 0;
|
||||
this.bundledSize = 0;
|
||||
this.resolver = new Resolver(options);
|
||||
}
|
||||
|
||||
shouldInvalidate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
loadIfNeeded() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (_this.contents == null) {
|
||||
_this.contents = yield _this.load();
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
parseIfNeeded() {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
yield _this2.loadIfNeeded();
|
||||
|
||||
if (!_this2.ast) {
|
||||
_this2.ast = yield _this2.parse(_this2.contents);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
getDependencies() {
|
||||
var _this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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));
|
||||
}
|
||||
|
||||
resolveDependency(url, from = this.name) {
|
||||
const parsed = URL.parse(url);
|
||||
let depName;
|
||||
let resolved;
|
||||
let dir = path.dirname(from);
|
||||
const filename = decodeURIComponent(parsed.pathname);
|
||||
|
||||
if (filename[0] === '~' || filename[0] === '/') {
|
||||
if (dir === '.') {
|
||||
dir = this.options.rootDir;
|
||||
}
|
||||
|
||||
depName = resolved = this.resolver.resolveFilename(filename, dir);
|
||||
} else {
|
||||
resolved = path.resolve(dir, filename);
|
||||
depName = './' + path.relative(path.dirname(this.name), resolved);
|
||||
}
|
||||
|
||||
return {
|
||||
depName,
|
||||
resolved
|
||||
};
|
||||
}
|
||||
|
||||
addURLDependency(url, from = this.name, opts) {
|
||||
if (!url || isURL(url)) {
|
||||
return url;
|
||||
}
|
||||
|
||||
if (typeof from === 'object') {
|
||||
opts = from;
|
||||
from = this.name;
|
||||
}
|
||||
|
||||
const _this$resolveDependen = this.resolveDependency(url, from),
|
||||
depName = _this$resolveDependen.depName,
|
||||
resolved = _this$resolveDependen.resolved;
|
||||
|
||||
this.addDependency(depName, Object.assign({
|
||||
dynamic: true,
|
||||
resolved
|
||||
}, opts));
|
||||
const parsed = URL.parse(url);
|
||||
parsed.pathname = this.options.parser.getAsset(resolved, this.options).generateBundleName();
|
||||
return URL.format(parsed);
|
||||
}
|
||||
|
||||
get package() {
|
||||
logger.warn('`asset.package` is deprecated. Please use `await asset.getPackage()` instead.');
|
||||
return syncPromise(this.getPackage());
|
||||
}
|
||||
|
||||
getPackage() {
|
||||
var _this4 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (!_this4._package) {
|
||||
_this4._package = yield _this4.resolver.findPackage(path.dirname(_this4.name));
|
||||
}
|
||||
|
||||
return _this4._package;
|
||||
})();
|
||||
}
|
||||
|
||||
getConfig(filenames, opts = {}) {
|
||||
var _this5 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (opts.packageKey) {
|
||||
let pkg = yield _this5.getPackage();
|
||||
|
||||
if (pkg && pkg[opts.packageKey]) {
|
||||
return clone(pkg[opts.packageKey]);
|
||||
}
|
||||
} // Resolve the config file
|
||||
|
||||
|
||||
let conf = yield config.resolve(opts.path || _this5.name, filenames);
|
||||
|
||||
if (conf) {
|
||||
// Add as a dependency so it is added to the watcher and invalidates
|
||||
// this asset when the config changes.
|
||||
_this5.addDependency(conf, {
|
||||
includedInParent: true
|
||||
});
|
||||
|
||||
if (opts.load === false) {
|
||||
return conf;
|
||||
}
|
||||
|
||||
return config.load(opts.path || _this5.name, filenames);
|
||||
}
|
||||
|
||||
return null;
|
||||
})();
|
||||
}
|
||||
|
||||
mightHaveDependencies() {
|
||||
return true;
|
||||
}
|
||||
|
||||
load() {
|
||||
var _this6 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
return fs.readFile(_this6.name, _this6.encoding);
|
||||
})();
|
||||
}
|
||||
|
||||
parse() {// do nothing by default
|
||||
}
|
||||
|
||||
collectDependencies() {// do nothing by default
|
||||
}
|
||||
|
||||
pretransform() {// do nothing by default
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {})();
|
||||
}
|
||||
|
||||
transform() {// do nothing by default
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {})();
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this7 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
return {
|
||||
[_this7.type]: _this7.contents
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
process() {
|
||||
var _this8 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
// Generate the id for this asset, unless it has already been set.
|
||||
// We do this here rather than in the constructor to avoid unnecessary work in the main process.
|
||||
// In development, the id is just the relative path to the file, for easy debugging and performance.
|
||||
// In production, we use a short hash of the relative path.
|
||||
if (!_this8.id) {
|
||||
_this8.id = _this8.options.production || _this8.options.scopeHoist ? t.toIdentifier(md5(_this8.relativeName, 'base64')).slice(0, 4) : _this8.relativeName;
|
||||
}
|
||||
|
||||
if (!_this8.generated) {
|
||||
yield _this8.loadIfNeeded();
|
||||
yield _this8.pretransform();
|
||||
yield _this8.getDependencies();
|
||||
yield _this8.transform();
|
||||
_this8.generated = yield _this8.generate();
|
||||
}
|
||||
|
||||
return _this8.generated;
|
||||
})();
|
||||
}
|
||||
|
||||
postProcess(generated) {
|
||||
return (0, _asyncToGenerator2.default)(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.relativeName) + '.' + this.type;
|
||||
}
|
||||
|
||||
replaceBundleNames(bundleNameMap) {
|
||||
let copied = false;
|
||||
|
||||
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.
|
||||
let newValue = value;
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(bundleNameMap),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let _step$value = (0, _slicedToArray2.default)(_step.value, 2),
|
||||
name = _step$value[0],
|
||||
map = _step$value[1];
|
||||
|
||||
newValue = newValue.split(name).join(map);
|
||||
} // Copy `this.generated` on write so we don't end up writing the final names to the cache.
|
||||
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
if (newValue !== value && !copied) {
|
||||
this.generated = Object.assign({}, this.generated);
|
||||
copied = true;
|
||||
}
|
||||
|
||||
this.generated[key] = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
generateErrorMessage(err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Asset;
|
||||
352
BACK_BACK/node_modules/parcel-bundler/lib/Bundle.js
generated
vendored
Executable file
352
BACK_BACK/node_modules/parcel-bundler/lib/Bundle.js
generated
vendored
Executable file
|
|
@ -0,0 +1,352 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
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, options = {}) {
|
||||
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;
|
||||
this.isolated = options.isolated;
|
||||
}
|
||||
|
||||
static createWithAsset(asset, parentBundle, options) {
|
||||
let bundle = new Bundle(asset.type, Path.join(asset.options.outDir, asset.generateBundleName()), parentBundle, options);
|
||||
bundle.entryAsset = asset;
|
||||
bundle.addAsset(asset);
|
||||
return bundle;
|
||||
}
|
||||
|
||||
addAsset(asset) {
|
||||
asset.bundles.add(this);
|
||||
this.assets.add(asset);
|
||||
|
||||
if (this.type != 'map' && this.type == asset.type && asset.options.sourceMaps && asset.sourceMaps) {
|
||||
this.getSiblingBundle('map').addAsset(asset);
|
||||
}
|
||||
}
|
||||
|
||||
removeAsset(asset) {
|
||||
asset.bundles.delete(this);
|
||||
this.assets.delete(asset);
|
||||
}
|
||||
|
||||
addOffset(asset, line, column = 0) {
|
||||
this.offsets.set(asset, [line, column]);
|
||||
}
|
||||
|
||||
getOffset(asset) {
|
||||
return this.offsets.get(asset) || [0, 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), // keep the original extension for source map files, so we have
|
||||
// .js.map instead of just .map
|
||||
type === 'map' ? Path.basename(this.name) + '.' + type : 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, options = {}) {
|
||||
let bundle = Bundle.createWithAsset(entryAsset, this, options);
|
||||
this.childBundles.add(bundle);
|
||||
return bundle;
|
||||
}
|
||||
|
||||
createSiblingBundle(entryAsset, options = {}) {
|
||||
let bundle = this.createChildBundle(entryAsset, options);
|
||||
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 _iterator = _createForOfIteratorHelper(this.childBundles.values()),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let child = _step.value;
|
||||
child.getBundleNameMap(contentHash, hashes);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
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.
|
||||
if (this.type == 'map') {
|
||||
return this.parentBundle.getHashedBundleName(contentHash) + '.map';
|
||||
}
|
||||
|
||||
let basename = Path.basename(this.name);
|
||||
let ext = Path.extname(basename);
|
||||
let hash = (contentHash ? this.getHash() : Path.basename(this.name, ext)).slice(-8);
|
||||
let entryAsset = this;
|
||||
|
||||
while (!entryAsset.entryAsset && entryAsset.parentBundle) {
|
||||
entryAsset = entryAsset.parentBundle;
|
||||
}
|
||||
|
||||
entryAsset = entryAsset.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).replace(/\.\.(\/|\\)/g, '__$1');
|
||||
} // 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 (0, _asyncToGenerator2.default)(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 _iterator2 = _createForOfIteratorHelper(_this.childBundles.values()),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
let bundle = _step2.value;
|
||||
|
||||
if (bundle.type === 'map') {
|
||||
mappings.push(bundle);
|
||||
} else {
|
||||
promises.push(bundle.package(bundler, oldHashes, newHashes));
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
|
||||
yield Promise.all(promises);
|
||||
|
||||
for (var _i = 0, _mappings = mappings; _i < _mappings.length; _i++) {
|
||||
let bundle = _mappings[_i];
|
||||
yield bundle.package(bundler, oldHashes, newHashes);
|
||||
}
|
||||
|
||||
return newHashes;
|
||||
})();
|
||||
}
|
||||
|
||||
_package(bundler) {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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 _iterator3 = _createForOfIteratorHelper(_this2.assets),
|
||||
_step3;
|
||||
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
let asset = _step3.value;
|
||||
yield _this2._addDeps(asset, packager, included);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator3.e(err);
|
||||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
|
||||
yield packager.end();
|
||||
_this2.totalSize = packager.getSize();
|
||||
let assetArray = Array.from(_this2.assets);
|
||||
let assetStartTime = _this2.type === 'map' ? 0 : assetArray.sort((a, b) => a.startTime - b.startTime)[0].startTime;
|
||||
let assetEndTime = _this2.type === 'map' ? 0 : assetArray.sort((a, b) => b.endTime - a.endTime)[0].endTime;
|
||||
let packagingTime = Date.now() - startTime;
|
||||
_this2.bundleTime = assetEndTime - assetStartTime + packagingTime;
|
||||
})();
|
||||
}
|
||||
|
||||
_addDeps(asset, packager, included) {
|
||||
var _this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (!_this3.assets.has(asset) || included.has(asset)) {
|
||||
return;
|
||||
}
|
||||
|
||||
included.add(asset);
|
||||
|
||||
var _iterator4 = _createForOfIteratorHelper(asset.depAssets.values()),
|
||||
_step4;
|
||||
|
||||
try {
|
||||
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
||||
let depAsset = _step4.value;
|
||||
yield _this3._addDeps(depAsset, packager, included);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator4.e(err);
|
||||
} finally {
|
||||
_iterator4.f();
|
||||
}
|
||||
|
||||
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 _iterator5 = _createForOfIteratorHelper(this.assets),
|
||||
_step5;
|
||||
|
||||
try {
|
||||
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
||||
let asset = _step5.value;
|
||||
hash.update(asset.hash);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator5.e(err);
|
||||
} finally {
|
||||
_iterator5.f();
|
||||
}
|
||||
|
||||
return hash.digest('hex');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Bundle;
|
||||
1026
BACK_BACK/node_modules/parcel-bundler/lib/Bundler.js
generated
vendored
Executable file
1026
BACK_BACK/node_modules/parcel-bundler/lib/Bundler.js
generated
vendored
Executable file
File diff suppressed because it is too large
Load diff
201
BACK_BACK/node_modules/parcel-bundler/lib/FSCache.js
generated
vendored
Executable file
201
BACK_BACK/node_modules/parcel-bundler/lib/FSCache.js
generated
vendored
Executable file
|
|
@ -0,0 +1,201 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const md5 = require('./utils/md5');
|
||||
|
||||
const objectHash = require('./utils/objectHash');
|
||||
|
||||
const pkg = require('../package.json');
|
||||
|
||||
const logger = require('@parcel/logger');
|
||||
|
||||
const _require = require('./utils/glob'),
|
||||
isGlob = _require.isGlob,
|
||||
glob = _require.glob; // These keys can affect the output, so if they differ, the cache should not match
|
||||
|
||||
|
||||
const OPTION_KEYS = ['publicURL', 'minify', 'hmr', 'target', 'scopeHoist', 'sourceMaps'];
|
||||
|
||||
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 (0, _asyncToGenerator2.default)(function* () {
|
||||
if (_this.dirExists) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield fs.mkdirp(_this.dir); // Create sub-directories for every possible hex value
|
||||
// This speeds up large caches on many file systems since there are fewer files in a single directory.
|
||||
|
||||
for (let i = 0; i < 256; i++) {
|
||||
yield fs.mkdirp(path.join(_this.dir, ('00' + i.toString(16)).slice(-2)));
|
||||
}
|
||||
|
||||
_this.dirExists = true;
|
||||
})();
|
||||
}
|
||||
|
||||
getCacheFile(filename) {
|
||||
let hash = md5(this.optionsHash + filename);
|
||||
return path.join(this.dir, hash.slice(0, 2), hash.slice(2) + '.json');
|
||||
}
|
||||
|
||||
getLastModified(filename) {
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (isGlob(filename)) {
|
||||
let files = yield glob(filename, {
|
||||
onlyFiles: true
|
||||
});
|
||||
return (yield Promise.all(files.map(file => fs.stat(file).then(({
|
||||
mtime
|
||||
}) => mtime.getTime())))).reduce((a, b) => Math.max(a, b), 0);
|
||||
}
|
||||
|
||||
return (yield fs.stat(filename)).mtime.getTime();
|
||||
})();
|
||||
}
|
||||
|
||||
writeDepMtimes(data) {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
// Write mtimes for each dependent file that is already compiled into this asset
|
||||
var _iterator = _createForOfIteratorHelper(data.dependencies),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let dep = _step.value;
|
||||
|
||||
if (dep.includedInParent) {
|
||||
dep.mtime = yield _this2.getLastModified(dep.name);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
write(filename, data) {
|
||||
var _this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
try {
|
||||
yield _this3.ensureDirExists();
|
||||
yield _this3.writeDepMtimes(data);
|
||||
yield fs.writeFile(_this3.getCacheFile(filename), JSON.stringify(data));
|
||||
|
||||
_this3.invalidated.delete(filename);
|
||||
} catch (err) {
|
||||
logger.error(`Error writing to cache: ${err.message}`);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
checkDepMtimes(data) {
|
||||
var _this4 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
// Check mtimes for files that are already compiled into this asset
|
||||
// If any of them changed, invalidate.
|
||||
var _iterator2 = _createForOfIteratorHelper(data.dependencies),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
let dep = _step2.value;
|
||||
|
||||
if (dep.includedInParent) {
|
||||
if ((yield _this4.getLastModified(dep.name)) > dep.mtime) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
|
||||
return true;
|
||||
})();
|
||||
}
|
||||
|
||||
read(filename) {
|
||||
var _this5 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (_this5.invalidated.has(filename)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let cacheFile = _this5.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 _this5.checkDepMtimes(data))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return data;
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
invalidate(filename) {
|
||||
this.invalidated.add(filename);
|
||||
}
|
||||
|
||||
delete(filename) {
|
||||
var _this6 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
try {
|
||||
yield fs.unlink(_this6.getCacheFile(filename));
|
||||
|
||||
_this6.invalidated.delete(filename);
|
||||
} catch (err) {// Fail silently
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = FSCache;
|
||||
173
BACK_BACK/node_modules/parcel-bundler/lib/HMRServer.js
generated
vendored
Executable file
173
BACK_BACK/node_modules/parcel-bundler/lib/HMRServer.js
generated
vendored
Executable file
|
|
@ -0,0 +1,173 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const http = require('http');
|
||||
|
||||
const https = require('https');
|
||||
|
||||
const WebSocket = require('ws');
|
||||
|
||||
const generateCertificate = require('./utils/generateCertificate');
|
||||
|
||||
const getCertificate = require('./utils/getCertificate');
|
||||
|
||||
const logger = require('@parcel/logger');
|
||||
|
||||
class HMRServer {
|
||||
start(options = {}) {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
yield new Promise( /*#__PURE__*/function () {
|
||||
var _ref = (0, _asyncToGenerator2.default)(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));
|
||||
}
|
||||
|
||||
let websocketOptions = {
|
||||
server: _this.server
|
||||
};
|
||||
|
||||
if (options.hmrHostname) {
|
||||
websocketOptions.origin = `${options.https ? 'https' : 'http'}://${options.hmrHostname}`;
|
||||
}
|
||||
|
||||
_this.wss = new WebSocket.Server(websocketOptions);
|
||||
|
||||
_this.server.listen(options.hmrPort, resolve);
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}());
|
||||
|
||||
_this.wss.on('connection', 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) {
|
||||
let _logger$formatError = logger.formatError(err),
|
||||
message = _logger$formatError.message,
|
||||
stack = _logger$formatError.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, reload = false) {
|
||||
if (this.unresolvedError) {
|
||||
this.unresolvedError = null;
|
||||
this.broadcast({
|
||||
type: 'error-resolved'
|
||||
});
|
||||
}
|
||||
|
||||
const shouldReload = reload || assets.some(asset => asset.hmrPageReload);
|
||||
|
||||
if (shouldReload) {
|
||||
this.broadcast({
|
||||
type: 'reload'
|
||||
});
|
||||
} else {
|
||||
this.broadcast({
|
||||
type: 'update',
|
||||
assets: assets.map(asset => {
|
||||
let deps = {};
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(asset.depAssets),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let _step$value = (0, _slicedToArray2.default)(_step.value, 2),
|
||||
dep = _step$value[0],
|
||||
depAsset = _step$value[1];
|
||||
|
||||
deps[dep.name] = depAsset.id;
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
return {
|
||||
id: asset.id,
|
||||
type: asset.type,
|
||||
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 _iterator2 = _createForOfIteratorHelper(this.wss.clients),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
let ws = _step2.value;
|
||||
ws.send(json);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = HMRServer;
|
||||
107
BACK_BACK/node_modules/parcel-bundler/lib/Parser.js
generated
vendored
Executable file
107
BACK_BACK/node_modules/parcel-bundler/lib/Parser.js
generated
vendored
Executable file
|
|
@ -0,0 +1,107 @@
|
|||
"use strict";
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const logger = require('@parcel/logger');
|
||||
|
||||
const RawAsset = require('./assets/RawAsset');
|
||||
|
||||
const GlobAsset = require('./assets/GlobAsset');
|
||||
|
||||
const _require = require('./utils/glob'),
|
||||
isGlob = _require.isGlob;
|
||||
|
||||
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('elm', './assets/ElmAsset');
|
||||
this.registerExtension('vue', './assets/VueAsset');
|
||||
this.registerExtension('json', './assets/JSONAsset');
|
||||
this.registerExtension('json5', './assets/JSONAsset');
|
||||
this.registerExtension('jsonld', './assets/JSONLDAsset');
|
||||
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('kt', './assets/KotlinAsset');
|
||||
this.registerExtension('css', './assets/CSSAsset');
|
||||
this.registerExtension('pcss', './assets/CSSAsset');
|
||||
this.registerExtension('postcss', './assets/CSSAsset');
|
||||
this.registerExtension('sss', './assets/SSSAsset');
|
||||
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');
|
||||
this.registerExtension('md', './assets/MarkdownAsset');
|
||||
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, fromPipeline) {
|
||||
if (!fromPipeline && isGlob(filename)) {
|
||||
return GlobAsset;
|
||||
}
|
||||
|
||||
let extension = path.extname(filename).toLowerCase();
|
||||
let parser = this.extensions[extension] || RawAsset;
|
||||
|
||||
if (typeof parser === 'string') {
|
||||
try {
|
||||
parser = this.extensions[extension] = require(parser);
|
||||
} catch (err) {
|
||||
let relFilename = path.relative(process.cwd(), filename);
|
||||
let relParserName = path.relative(process.cwd(), parser);
|
||||
|
||||
if (relParserName.slice(0, 12) === 'node_modules') {
|
||||
relParserName = relParserName.slice(13);
|
||||
}
|
||||
|
||||
logger.warn(`Parser "${relParserName}" failed to initialize when processing ` + `asset "${relFilename}". Threw the following error:\n` + `${err.stack || err.message || err} falling back to RawAsset`);
|
||||
return RawAsset;
|
||||
}
|
||||
}
|
||||
|
||||
return parser;
|
||||
}
|
||||
|
||||
getAsset(filename, options = {}) {
|
||||
let Asset = this.findParser(filename);
|
||||
options.parser = this;
|
||||
return new Asset(filename, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Parser;
|
||||
214
BACK_BACK/node_modules/parcel-bundler/lib/Pipeline.js
generated
vendored
Executable file
214
BACK_BACK/node_modules/parcel-bundler/lib/Pipeline.js
generated
vendored
Executable file
|
|
@ -0,0 +1,214 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const Parser = require('./Parser');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const _require = require('@parcel/utils'),
|
||||
errorUtils = _require.errorUtils;
|
||||
/**
|
||||
* A Pipeline composes multiple Asset types together.
|
||||
*/
|
||||
|
||||
|
||||
class Pipeline {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
this.parser = new Parser(options);
|
||||
}
|
||||
|
||||
process(path, isWarmUp) {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let options = _this.options;
|
||||
|
||||
if (isWarmUp) {
|
||||
options = Object.assign({
|
||||
isWarmUp
|
||||
}, options);
|
||||
}
|
||||
|
||||
let asset = _this.parser.getAsset(path, options);
|
||||
|
||||
let error = null;
|
||||
let generatedMap = {};
|
||||
|
||||
try {
|
||||
let generated = yield _this.processAsset(asset);
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(generated),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let rendition = _step.value;
|
||||
generatedMap[rendition.type] = rendition.value;
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
} catch (err) {
|
||||
error = errorUtils.errorToJson(err);
|
||||
error.fileName = path;
|
||||
}
|
||||
|
||||
return {
|
||||
id: asset.id,
|
||||
dependencies: Array.from(asset.dependencies.values()),
|
||||
generated: generatedMap,
|
||||
sourceMaps: asset.sourceMaps,
|
||||
error: error,
|
||||
hash: asset.hash,
|
||||
cacheData: asset.cacheData
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
processAsset(asset) {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
try {
|
||||
yield asset.process();
|
||||
} catch (err) {
|
||||
throw asset.generateErrorMessage(err);
|
||||
}
|
||||
|
||||
let inputType = path.extname(asset.name).slice(1);
|
||||
let generated = [];
|
||||
|
||||
var _iterator2 = _createForOfIteratorHelper(_this2.iterateRenditions(asset)),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
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, true);
|
||||
|
||||
if (!(asset instanceof AssetType)) {
|
||||
let opts = Object.assign({}, asset.options, {
|
||||
rendition
|
||||
});
|
||||
let subAsset = new AssetType(asset.name, opts);
|
||||
subAsset.id = asset.id;
|
||||
subAsset.contents = value;
|
||||
subAsset.dependencies = asset.dependencies;
|
||||
subAsset.cacheData = Object.assign(asset.cacheData, subAsset.cacheData);
|
||||
let processed = yield _this2.processAsset(subAsset);
|
||||
|
||||
if (rendition.meta) {
|
||||
var _iterator4 = _createForOfIteratorHelper(processed),
|
||||
_step4;
|
||||
|
||||
try {
|
||||
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
||||
let res = _step4.value;
|
||||
res.meta = rendition.meta;
|
||||
res.isMain = res.type === subAsset.type;
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator4.e(err);
|
||||
} finally {
|
||||
_iterator4.f();
|
||||
}
|
||||
}
|
||||
|
||||
generated = generated.concat(processed);
|
||||
} else {
|
||||
generated.push(rendition);
|
||||
}
|
||||
} // Post process. This allows assets a chance to modify the output produced by sub-asset types.
|
||||
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
|
||||
try {
|
||||
generated = yield asset.postProcess(generated);
|
||||
} catch (err) {
|
||||
throw asset.generateErrorMessage(err);
|
||||
}
|
||||
|
||||
let hasMap = false;
|
||||
let sourceMaps = {};
|
||||
|
||||
var _iterator3 = _createForOfIteratorHelper(generated),
|
||||
_step3;
|
||||
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
let rendition = _step3.value;
|
||||
|
||||
if (rendition.map && rendition.type == asset.type) {
|
||||
sourceMaps[rendition.type] = rendition.map;
|
||||
hasMap = true;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator3.e(err);
|
||||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
|
||||
if (hasMap) {
|
||||
asset.sourceMaps = sourceMaps;
|
||||
}
|
||||
|
||||
asset.generated = generated;
|
||||
asset.hash = yield asset.generateHash();
|
||||
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],
|
||||
// for scope hoisting, we need to post process all JS
|
||||
final: !(type === 'js' && this.options.scopeHoist)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Pipeline;
|
||||
537
BACK_BACK/node_modules/parcel-bundler/lib/Resolver.js
generated
vendored
Executable file
537
BACK_BACK/node_modules/parcel-bundler/lib/Resolver.js
generated
vendored
Executable file
|
|
@ -0,0 +1,537 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const builtins = require('./builtins');
|
||||
|
||||
const nodeBuiltins = require('node-libs-browser');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const _require = require('./utils/glob'),
|
||||
isGlob = _require.isGlob;
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
const micromatch = require('micromatch');
|
||||
|
||||
const getModuleParts = require('./utils/getModuleParts');
|
||||
|
||||
const EMPTY_SHIM = require.resolve('./builtins/_empty');
|
||||
/**
|
||||
* 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 (0, _asyncToGenerator2.default)(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 (isGlob(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(ext => 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 (0, _asyncToGenerator2.default)(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 = 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);
|
||||
|
||||
if (dir === path.dirname(dir)) {
|
||||
dir = this.options.rootDir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return path.join(dir, filename.slice(1));
|
||||
|
||||
case '.':
|
||||
// Relative path.
|
||||
return path.resolve(dir, filename);
|
||||
|
||||
default:
|
||||
// Module
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
|
||||
loadRelative(filename, extensions) {
|
||||
var _this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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)) // eslint-disable-line no-return-await
|
||||
;
|
||||
})();
|
||||
}
|
||||
|
||||
findNodeModulePath(filename, dir) {
|
||||
var _this4 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (builtins[filename]) {
|
||||
if (_this4.options.target === 'node' && filename in nodeBuiltins) {
|
||||
throw new Error('Cannot resolve builtin module for node target');
|
||||
}
|
||||
|
||||
return {
|
||||
filePath: builtins[filename]
|
||||
};
|
||||
}
|
||||
|
||||
let parts = 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 (0, _asyncToGenerator2.default)(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 (0, _asyncToGenerator2.default)(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 (0, _asyncToGenerator2.default)(function* () {
|
||||
try {
|
||||
pkg = yield _this6.readPackage(dir); // Get a list of possible package entry points.
|
||||
|
||||
let entries = _this6.getPackageEntries(pkg);
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(entries),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let file = _step.value;
|
||||
// First try loading package.main as a file, then try as a directory.
|
||||
const res = (yield _this6.loadAsFile(file, extensions, pkg)) || (yield _this6.loadDirectory(file, extensions, pkg));
|
||||
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
} catch (err) {// ignore
|
||||
} // Fall back to an index file inside the directory.
|
||||
|
||||
|
||||
return _this6.loadAsFile(path.join(dir, 'index'), extensions, pkg);
|
||||
})();
|
||||
}
|
||||
|
||||
readPackage(dir) {
|
||||
var _this7 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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;
|
||||
})();
|
||||
}
|
||||
|
||||
getBrowserField(pkg) {
|
||||
let target = this.options.target || 'browser';
|
||||
return target === 'browser' ? pkg.browser : null;
|
||||
}
|
||||
|
||||
getPackageEntries(pkg) {
|
||||
let browser = this.getBrowserField(pkg);
|
||||
|
||||
if (browser && typeof browser === 'object' && browser[pkg.name]) {
|
||||
browser = browser[pkg.name];
|
||||
} // libraries like d3.js specifies node.js specific files in the "main" which breaks the build
|
||||
// we use the "browser" or "module" 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.
|
||||
|
||||
|
||||
return [pkg.source, browser, pkg.module, pkg.main].filter(entry => typeof entry === 'string').map(main => {
|
||||
// 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 (0, _asyncToGenerator2.default)(function* () {
|
||||
// Try all supported extensions
|
||||
var _iterator2 = _createForOfIteratorHelper(_this8.expandFile(file, extensions, pkg)),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
let f = _step2.value;
|
||||
|
||||
if (yield _this8.isFile(f)) {
|
||||
return {
|
||||
path: f,
|
||||
pkg
|
||||
};
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
expandFile(file, extensions, pkg, expandAliases = true) {
|
||||
// Expand extensions and aliases
|
||||
let res = [];
|
||||
|
||||
var _iterator3 = _createForOfIteratorHelper(extensions),
|
||||
_step3;
|
||||
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
let ext = _step3.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) {
|
||||
_iterator3.e(err);
|
||||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
|
||||
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, this.getBrowserField(pkg)) || 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, dir);
|
||||
} else {
|
||||
// It is a node_module. First try the entire filename as a key.
|
||||
alias = this.lookupAlias(aliases, filename, dir);
|
||||
|
||||
if (alias == null) {
|
||||
// If it didn't match, try only the module name.
|
||||
let parts = getModuleParts(filename);
|
||||
alias = this.lookupAlias(aliases, parts[0], dir);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return alias;
|
||||
}
|
||||
|
||||
lookupAlias(aliases, filename, dir) {
|
||||
// First, try looking up the exact filename
|
||||
let alias = aliases[filename];
|
||||
|
||||
if (alias == null) {
|
||||
// Otherwise, try replacing glob keys
|
||||
for (let key in aliases) {
|
||||
if (isGlob(key)) {
|
||||
let re = micromatch.makeRe(key, {
|
||||
capture: true
|
||||
});
|
||||
|
||||
if (re.test(filename)) {
|
||||
alias = filename.replace(re, aliases[key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // Or try a lookup replacing backslash characters with forward slash
|
||||
|
||||
|
||||
if (alias == null && ~filename.indexOf('\\')) {
|
||||
alias = aliases[filename.replace(/\\/g, '/')];
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof alias === 'string') {
|
||||
return this.resolveFilename(alias, dir);
|
||||
}
|
||||
|
||||
return alias;
|
||||
}
|
||||
|
||||
findPackage(dir) {
|
||||
var _this9 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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 (0, _asyncToGenerator2.default)(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);
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Resolver;
|
||||
170
BACK_BACK/node_modules/parcel-bundler/lib/Server.js
generated
vendored
Executable file
170
BACK_BACK/node_modules/parcel-bundler/lib/Server.js
generated
vendored
Executable file
|
|
@ -0,0 +1,170 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
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 AnsiToHtml = require('ansi-to-html');
|
||||
|
||||
const logger = require('@parcel/logger');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const url = require('url');
|
||||
|
||||
const ansiToHtml = new AnsiToHtml({
|
||||
newline: true
|
||||
});
|
||||
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,
|
||||
redirect: false,
|
||||
setHeaders: setHeaders,
|
||||
dotfiles: 'allow'
|
||||
});
|
||||
return function (req, res, next) {
|
||||
logAccessIfVerbose(); // Wait for the bundler to finish bundling if needed
|
||||
|
||||
if (bundler.pending) {
|
||||
bundler.once('bundled', respond);
|
||||
} else {
|
||||
respond();
|
||||
}
|
||||
|
||||
function respond() {
|
||||
let _url$parse = url.parse(req.url),
|
||||
pathname = _url$parse.pathname;
|
||||
|
||||
if (bundler.error) {
|
||||
return send500(bundler.error);
|
||||
} 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, sendIndex);
|
||||
}
|
||||
}
|
||||
|
||||
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(error) {
|
||||
setHeaders(res);
|
||||
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||
res.writeHead(500);
|
||||
let errorMesssge = '<h1>🚨 Build Error</h1>';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
errorMesssge += '<p><b>Check the console for details.</b></p>';
|
||||
} else {
|
||||
const _logger$formatError = logger.formatError(error, {
|
||||
color: true
|
||||
}),
|
||||
message = _logger$formatError.message,
|
||||
stack = _logger$formatError.stack;
|
||||
|
||||
errorMesssge += `<p><b>${message}</b></p>`;
|
||||
|
||||
if (stack) {
|
||||
errorMesssge += `<div style="background: black; padding: 1rem;">${ansiToHtml.toHtml(stack)}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
res.end([`<!doctype html>`, `<head><title>🚨 Build Error</title></head>`, `<body style="font-family: monospace; white-space: pre;">${errorMesssge}</body>`].join(''));
|
||||
}
|
||||
|
||||
function send404() {
|
||||
if (next) {
|
||||
return next();
|
||||
}
|
||||
|
||||
setHeaders(res);
|
||||
res.writeHead(404);
|
||||
res.end();
|
||||
}
|
||||
|
||||
function logAccessIfVerbose() {
|
||||
const protocol = req.connection.encrypted ? 'https' : 'http';
|
||||
const fullUrl = `${protocol}://${req.headers.host}${req.url}`;
|
||||
logger.verbose(`Request: ${fullUrl}`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function serve(_x, _x2, _x3) {
|
||||
return _serve.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _serve() {
|
||||
_serve = (0, _asyncToGenerator2.default)(function* (bundler, port, host, 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, host);
|
||||
return new Promise((resolve, reject) => {
|
||||
server.on('error', err => {
|
||||
console.log(err);
|
||||
logger.error(new Error(serverErrors(err, server.address().port)));
|
||||
reject(err);
|
||||
});
|
||||
server.once('listening', () => {
|
||||
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'}://${host || 'localhost'}:${server.address().port}`)} ${addon}`);
|
||||
resolve(server);
|
||||
});
|
||||
});
|
||||
});
|
||||
return _serve.apply(this, arguments);
|
||||
}
|
||||
|
||||
exports.middleware = middleware;
|
||||
exports.serve = serve;
|
||||
335
BACK_BACK/node_modules/parcel-bundler/lib/SourceMap.js
generated
vendored
Executable file
335
BACK_BACK/node_modules/parcel-bundler/lib/SourceMap.js
generated
vendored
Executable file
|
|
@ -0,0 +1,335 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const _require = require('source-map'),
|
||||
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 => mapping && typeof mapping.original === 'object' && (mapping.original === null || typeof mapping.original.line === 'number' && mapping.original.line > 0 && typeof mapping.original.column === 'number' && mapping.source) && mapping.generated && typeof mapping.generated.line === 'number' && mapping.generated.line > 0 && typeof mapping.generated.column === 'number');
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
getConsumer(map) {
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (map instanceof SourceMapConsumer) {
|
||||
return map;
|
||||
}
|
||||
|
||||
map = typeof map === 'string' ? JSON.parse(map) : map;
|
||||
if (map.sourceRoot) delete map.sourceRoot;
|
||||
return new SourceMapConsumer(map);
|
||||
})();
|
||||
}
|
||||
|
||||
addMap(map, lineOffset = 0, columnOffset = 0) {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (typeof map === 'string' || typeof map === 'object' && map.version) {
|
||||
let consumer = yield _this.getConsumer(map);
|
||||
if (!consumer) return _this;
|
||||
consumer.eachMapping(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.mappings && map.sources) {
|
||||
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(mapping => {
|
||||
_this.addMapping(mapping, lineOffset, columnOffset);
|
||||
});
|
||||
}
|
||||
|
||||
Object.keys(map.sources).forEach(sourceName => {
|
||||
if (!_this.sources[sourceName]) {
|
||||
_this.sources[sourceName] = map.sources[sourceName];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return _this;
|
||||
})();
|
||||
}
|
||||
|
||||
addMapping(mapping, lineOffset = 0, columnOffset = 0) {
|
||||
this.mappings.push({
|
||||
source: mapping.source,
|
||||
name: mapping.name,
|
||||
original: mapping.original,
|
||||
generated: {
|
||||
line: mapping.generated.line + lineOffset,
|
||||
column: mapping.generated.column + columnOffset
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addConsumerMapping(mapping, lineOffset = 0, columnOffset = 0) {
|
||||
let original = null;
|
||||
|
||||
if (typeof mapping.originalLine === 'number' && mapping.originalLine > 0 && typeof mapping.originalColumn === 'number') {
|
||||
original = {
|
||||
line: mapping.originalLine,
|
||||
column: mapping.originalColumn
|
||||
};
|
||||
}
|
||||
|
||||
this.mappings.push({
|
||||
source: original ? mapping.source : null,
|
||||
name: mapping.name,
|
||||
original,
|
||||
generated: {
|
||||
line: mapping.generatedLine + lineOffset,
|
||||
column: mapping.generatedColumn + columnOffset
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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 (0, _asyncToGenerator2.default)(function* () {
|
||||
if (!(extension instanceof SourceMap)) {
|
||||
extension = yield new SourceMap().addMap(extension);
|
||||
}
|
||||
|
||||
if (!(original instanceof SourceMap)) {
|
||||
original = yield _this2.getConsumer(original);
|
||||
}
|
||||
|
||||
extension.eachMapping(mapping => {
|
||||
let originalMapping = original.originalPositionFor({
|
||||
line: mapping.original.line,
|
||||
column: mapping.original.column
|
||||
});
|
||||
|
||||
if (!originalMapping || !originalMapping.line) {
|
||||
return;
|
||||
}
|
||||
|
||||
_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;
|
||||
})();
|
||||
}
|
||||
|
||||
findClosestGenerated(line, column) {
|
||||
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 = stopIndex + startIndex >>> 1;
|
||||
|
||||
while (startIndex < stopIndex && this.mappings[middleIndex].generated.line !== line) {
|
||||
let mid = this.mappings[middleIndex].generated.line;
|
||||
|
||||
if (line < mid) {
|
||||
stopIndex = middleIndex - 1;
|
||||
} else if (line > mid) {
|
||||
startIndex = middleIndex + 1;
|
||||
}
|
||||
|
||||
middleIndex = stopIndex + startIndex >>> 1;
|
||||
}
|
||||
|
||||
let mapping = this.mappings[middleIndex];
|
||||
|
||||
if (!mapping || mapping.generated.line !== line) {
|
||||
return this.mappings.length - 1;
|
||||
}
|
||||
|
||||
while (middleIndex >= 1 && this.mappings[middleIndex - 1].generated.line === line) {
|
||||
middleIndex--;
|
||||
}
|
||||
|
||||
while (middleIndex < this.mappings.length - 1 && this.mappings[middleIndex + 1].generated.line === line && column > this.mappings[middleIndex].generated.column) {
|
||||
middleIndex++;
|
||||
}
|
||||
|
||||
return middleIndex;
|
||||
}
|
||||
|
||||
findClosest(line, column, key) {
|
||||
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);
|
||||
}
|
||||
|
||||
var 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.findClosestGenerated(generatedPosition.line, generatedPosition.column);
|
||||
let mapping = this.mappings[index];
|
||||
|
||||
if (!mapping || !mapping.original) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
source: mapping.source,
|
||||
name: mapping.name,
|
||||
line: mapping.original.line,
|
||||
column: mapping.original.column
|
||||
};
|
||||
}
|
||||
|
||||
generatedPositionFor(originalPosition) {
|
||||
let index = this.findClosest(originalPosition.line, originalPosition.column, 'original');
|
||||
let mapping = this.mappings[index];
|
||||
return {
|
||||
source: mapping.source,
|
||||
name: mapping.name,
|
||||
line: mapping.generated.line,
|
||||
column: mapping.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;
|
||||
287
BACK_BACK/node_modules/parcel-bundler/lib/assets/CSSAsset.js
generated
vendored
Executable file
287
BACK_BACK/node_modules/parcel-bundler/lib/assets/CSSAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,287 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
|
||||
|
||||
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 SourceMap = require('../SourceMap');
|
||||
|
||||
const loadSourceMap = require('../utils/loadSourceMap');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const urlJoin = require('../utils/urlJoin');
|
||||
|
||||
const isURL = require('../utils/is-url');
|
||||
|
||||
const URL_RE = /url\s*\("?(?![a-z]+:)/;
|
||||
const IMPORT_RE = /@import/;
|
||||
const COMPOSES_RE = /composes:.+from\s*("|').*("|')\s*;?/;
|
||||
const FROM_IMPORT_RE = /.+from\s*(?:"|')(.*)(?:"|')\s*;?/;
|
||||
const PROTOCOL_RE = /^[a-z]+:/;
|
||||
|
||||
class CSSAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'css';
|
||||
this.previousSourceMap = this.options.rendition ? this.options.rendition.map : null;
|
||||
}
|
||||
|
||||
mightHaveDependencies() {
|
||||
return !/\.css$/.test(this.name) || IMPORT_RE.test(this.contents) || COMPOSES_RE.test(this.contents) || URL_RE.test(this.contents);
|
||||
}
|
||||
|
||||
parse(code) {
|
||||
let root = postcss.parse(code, {
|
||||
from: this.name
|
||||
});
|
||||
return new CSSAst(code, root);
|
||||
}
|
||||
|
||||
collectDependencies() {
|
||||
this.ast.root.walkAtRules('import', rule => {
|
||||
let params = valueParser(rule.params);
|
||||
|
||||
let _params$nodes = (0, _toArray2.default)(params.nodes),
|
||||
name = _params$nodes[0],
|
||||
media = _params$nodes.slice(1);
|
||||
|
||||
let dep;
|
||||
|
||||
if (name.type === 'function' && name.value === 'url' && name.nodes.length) {
|
||||
name = name.nodes[0];
|
||||
}
|
||||
|
||||
dep = name.value;
|
||||
|
||||
if (!dep) {
|
||||
throw new Error('Could not find import name for ' + rule);
|
||||
}
|
||||
|
||||
if (PROTOCOL_RE.test(dep)) {
|
||||
return;
|
||||
} // If this came from an inline <style> tag, don't inline the imported file. Replace with the correct URL instead.
|
||||
// TODO: run CSSPackager on inline style tags.
|
||||
|
||||
|
||||
let inlineHTML = this.options.rendition && this.options.rendition.inlineHTML;
|
||||
|
||||
if (inlineHTML) {
|
||||
name.value = this.addURLDependency(dep, {
|
||||
loc: rule.source.start
|
||||
});
|
||||
rule.params = params.toString();
|
||||
} else {
|
||||
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
|
||||
});
|
||||
|
||||
if (!isURL(url)) {
|
||||
url = urlJoin(this.options.publicURL, url);
|
||||
}
|
||||
|
||||
dirty = node.nodes[0].value !== url;
|
||||
node.nodes[0].value = url;
|
||||
}
|
||||
});
|
||||
|
||||
if (dirty) {
|
||||
decl.value = parsed.toString();
|
||||
this.ast.dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (decl.prop === 'composes' && FROM_IMPORT_RE.test(decl.value)) {
|
||||
let parsed = valueParser(decl.value);
|
||||
parsed.walk(node => {
|
||||
if (node.type === 'string') {
|
||||
const _FROM_IMPORT_RE$exec = FROM_IMPORT_RE.exec(decl.value),
|
||||
_FROM_IMPORT_RE$exec2 = (0, _slicedToArray2.default)(_FROM_IMPORT_RE$exec, 2),
|
||||
importPath = _FROM_IMPORT_RE$exec2[1];
|
||||
|
||||
this.addURLDependency(importPath, {
|
||||
dynamic: false,
|
||||
loc: decl.source.start
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pretransform() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (_this.options.sourceMaps && !_this.previousSourceMap) {
|
||||
_this.previousSourceMap = yield loadSourceMap(_this);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
transform() {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
yield postcssTransform(_this2);
|
||||
})();
|
||||
}
|
||||
|
||||
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(this.name));
|
||||
}
|
||||
|
||||
return this.ast.root;
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let css;
|
||||
|
||||
if (_this3.ast) {
|
||||
let result = _this3.ast.render(_this3.name);
|
||||
|
||||
css = result.css;
|
||||
if (result.map) _this3.sourceMap = result.map;
|
||||
} else {
|
||||
css = _this3.contents;
|
||||
}
|
||||
|
||||
let js = '';
|
||||
|
||||
if (_this3.options.hmr) {
|
||||
_this3.addDependency('_css_loader');
|
||||
|
||||
js = `
|
||||
var reloadCSS = require('_css_loader');
|
||||
module.hot.dispose(reloadCSS);
|
||||
module.hot.accept(reloadCSS);
|
||||
`;
|
||||
}
|
||||
|
||||
if (_this3.cssModules) {
|
||||
js += 'module.exports = ' + JSON.stringify(_this3.cssModules, null, 2) + ';';
|
||||
}
|
||||
|
||||
if (_this3.options.sourceMaps) {
|
||||
if (_this3.sourceMap) {
|
||||
_this3.sourceMap = yield new SourceMap().addMap(_this3.sourceMap);
|
||||
}
|
||||
|
||||
if (_this3.previousSourceMap) {
|
||||
_this3.previousSourceMap.sources = _this3.previousSourceMap.sources.map(v => path.join(path.dirname(_this3.relativeName), _this3.previousSourceMap.sourceRoot || '', v));
|
||||
|
||||
if (_this3.sourceMap) {
|
||||
_this3.sourceMap = yield new SourceMap().extendSourceMap(_this3.previousSourceMap, _this3.sourceMap);
|
||||
} else {
|
||||
_this3.sourceMap = yield new SourceMap().addMap(_this3.previousSourceMap);
|
||||
}
|
||||
} else if (!_this3.sourceMap) {
|
||||
_this3.sourceMap = new SourceMap().generateEmptyMap(_this3.relativeName, css);
|
||||
}
|
||||
}
|
||||
|
||||
return [{
|
||||
type: 'css',
|
||||
value: css,
|
||||
cssModules: _this3.cssModules,
|
||||
map: _this3.sourceMap
|
||||
}, {
|
||||
type: 'js',
|
||||
value: js,
|
||||
hasDependencies: false
|
||||
}];
|
||||
})();
|
||||
}
|
||||
|
||||
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(name) {
|
||||
if (this.dirty) {
|
||||
let _this$root$toResult = this.root.toResult({
|
||||
to: name,
|
||||
map: {
|
||||
inline: false,
|
||||
annotation: false,
|
||||
sourcesContent: true
|
||||
}
|
||||
}),
|
||||
css = _this$root$toResult.css,
|
||||
map = _this$root$toResult.map;
|
||||
|
||||
this.css = css;
|
||||
return {
|
||||
css: this.css,
|
||||
map: map ? map.toJSON() : null
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
css: this.css
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = CSSAsset;
|
||||
45
BACK_BACK/node_modules/parcel-bundler/lib/assets/CoffeeScriptAsset.js
generated
vendored
Executable file
45
BACK_BACK/node_modules/parcel-bundler/lib/assets/CoffeeScriptAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
class CoffeeScriptAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'js';
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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,
|
||||
map: sourceMap
|
||||
}];
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = CoffeeScriptAsset;
|
||||
172
BACK_BACK/node_modules/parcel-bundler/lib/assets/ElmAsset.js
generated
vendored
Executable file
172
BACK_BACK/node_modules/parcel-bundler/lib/assets/ElmAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,172 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const commandExists = require('command-exists');
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
const _require = require('terser'),
|
||||
minify = _require.minify;
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const spawn = require('cross-spawn');
|
||||
|
||||
class ElmAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'js';
|
||||
}
|
||||
|
||||
parse() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let options = {
|
||||
cwd: path.dirname(_this.name)
|
||||
}; // If elm is not installed globally, install it locally.
|
||||
|
||||
try {
|
||||
yield commandExists('elm');
|
||||
} catch (err) {
|
||||
yield localRequire('elm', _this.name);
|
||||
options.pathToElm = path.join(path.dirname(require.resolve('elm')), 'bin', 'elm');
|
||||
}
|
||||
|
||||
_this.elm = yield localRequire('node-elm-compiler', _this.name); // Ensure that an elm.json file exists, and initialize one if not.
|
||||
|
||||
let elmConfig = yield _this.getConfig(['elm.json'], {
|
||||
load: false
|
||||
});
|
||||
|
||||
if (!elmConfig) {
|
||||
yield _this.createElmConfig(options); // Ensure we are watching elm.json for changes
|
||||
|
||||
yield _this.getConfig(['elm.json'], {
|
||||
load: false
|
||||
});
|
||||
}
|
||||
|
||||
options.debug = !_this.options.production;
|
||||
|
||||
if (_this.options.minify) {
|
||||
options.optimize = true;
|
||||
}
|
||||
|
||||
_this.elmOpts = options;
|
||||
})();
|
||||
}
|
||||
|
||||
collectDependencies() {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let dependencies = yield _this2.elm.findAllDependencies(_this2.name);
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(dependencies),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let dependency = _step.value;
|
||||
|
||||
_this2.addDependency(dependency, {
|
||||
includedInParent: true
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
createElmConfig(options) {
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let cp = spawn(options.pathToElm || 'elm', ['init']);
|
||||
cp.stdin.write('y\n');
|
||||
return new Promise((resolve, reject) => {
|
||||
cp.on('error', reject);
|
||||
cp.on('close', function (code) {
|
||||
if (code !== 0) {
|
||||
return reject(new Error('elm init failed.'));
|
||||
}
|
||||
|
||||
return resolve();
|
||||
});
|
||||
});
|
||||
})();
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let compiled = yield _this3.elm.compileToString(_this3.name, _this3.elmOpts);
|
||||
_this3.contents = compiled.toString();
|
||||
|
||||
if (_this3.options.hmr) {
|
||||
let _yield$localRequire = yield localRequire('elm-hot', _this3.name),
|
||||
inject = _yield$localRequire.inject;
|
||||
|
||||
_this3.contents = inject(_this3.contents);
|
||||
}
|
||||
|
||||
let output = _this3.contents;
|
||||
|
||||
if (_this3.options.minify) {
|
||||
output = pack(output);
|
||||
}
|
||||
|
||||
return {
|
||||
[_this3.type]: output
|
||||
}; // Recommended minification
|
||||
// Based on:
|
||||
// - http://elm-lang.org/0.19.0/optimize
|
||||
|
||||
function pack(source) {
|
||||
let options = {
|
||||
compress: {
|
||||
keep_fargs: false,
|
||||
passes: 2,
|
||||
pure_funcs: ['F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9'],
|
||||
pure_getters: true,
|
||||
unsafe: true,
|
||||
unsafe_comps: true
|
||||
},
|
||||
mangle: true,
|
||||
rename: false
|
||||
};
|
||||
let result = minify(source, options);
|
||||
|
||||
if (result.error) {
|
||||
throw result.error;
|
||||
}
|
||||
|
||||
return result.code;
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
generateErrorMessage(err) {
|
||||
// The generated stack is not useful, but other code may
|
||||
// expect it and try to print it, so make it an empty string.
|
||||
err.stack = '';
|
||||
return err;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = ElmAsset;
|
||||
100
BACK_BACK/node_modules/parcel-bundler/lib/assets/GLSLAsset.js
generated
vendored
Executable file
100
BACK_BACK/node_modules/parcel-bundler/lib/assets/GLSLAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,100 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const _require = require('@parcel/utils'),
|
||||
promisify = _require.promisify;
|
||||
|
||||
const Resolver = require('../Resolver');
|
||||
|
||||
class GLSLAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'js';
|
||||
}
|
||||
|
||||
parse() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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 aliases, 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: function () {
|
||||
var _resolve = (0, _asyncToGenerator2.default)(function* (target, opts, next) {
|
||||
try {
|
||||
let res = yield resolver.resolve(target, path.join(opts.basedir, 'index'));
|
||||
next(null, res.path);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
function resolve(_x, _x2, _x3) {
|
||||
return _resolve.apply(this, arguments);
|
||||
}
|
||||
|
||||
return resolve;
|
||||
}()
|
||||
});
|
||||
return promisify(depper.inline.bind(depper))(_this.contents, cwd);
|
||||
})();
|
||||
}
|
||||
|
||||
collectDependencies() {
|
||||
var _iterator = _createForOfIteratorHelper(this.ast),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let dep = _step.value;
|
||||
|
||||
if (!dep.entry) {
|
||||
this.addDependency(dep.file, {
|
||||
includedInParent: true
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
// Generate the bundled glsl file
|
||||
const glslifyBundle = yield localRequire('glslify-bundle', _this2.name);
|
||||
let glsl = glslifyBundle(_this2.ast);
|
||||
return `module.exports=${JSON.stringify(glsl)};`;
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = GLSLAsset;
|
||||
109
BACK_BACK/node_modules/parcel-bundler/lib/assets/GlobAsset.js
generated
vendored
Executable file
109
BACK_BACK/node_modules/parcel-bundler/lib/assets/GlobAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,109 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const micromatch = require('micromatch');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const _require = require('../utils/glob'),
|
||||
glob = _require.glob;
|
||||
|
||||
class GlobAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = null; // allows this asset to be included in any type bundle
|
||||
}
|
||||
|
||||
load() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let regularExpressionSafeName = _this.name;
|
||||
if (process.platform === 'win32') regularExpressionSafeName = regularExpressionSafeName.replace(/\\/g, '/');
|
||||
let files = yield glob(regularExpressionSafeName, {
|
||||
onlyFiles: true
|
||||
});
|
||||
let re = micromatch.makeRe(regularExpressionSafeName, {
|
||||
capture: true
|
||||
});
|
||||
let matches = {};
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(files),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let file = _step.value;
|
||||
let match = file.match(re);
|
||||
let parts = match.slice(1).filter(Boolean).reduce((a, p) => a.concat(p.split('/')), []);
|
||||
let relative = './' + path.relative(path.dirname(_this.name), file.normalize('NFC'));
|
||||
set(matches, parts, relative);
|
||||
|
||||
_this.addDependency(relative);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
return matches;
|
||||
})();
|
||||
}
|
||||
|
||||
generate() {
|
||||
return [{
|
||||
type: 'js',
|
||||
value: '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;
|
||||
100
BACK_BACK/node_modules/parcel-bundler/lib/assets/GraphqlAsset.js
generated
vendored
Executable file
100
BACK_BACK/node_modules/parcel-bundler/lib/assets/GraphqlAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,100 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
const Resolver = require('../Resolver');
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
const os = require('os');
|
||||
|
||||
const IMPORT_RE = /^# *import +['"](.*)['"] *;? *$/;
|
||||
|
||||
class GraphqlAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'js';
|
||||
this.gqlMap = new Map();
|
||||
this.gqlResolver = new Resolver(Object.assign({}, this.options, {
|
||||
extensions: ['.gql', '.graphql']
|
||||
}));
|
||||
}
|
||||
|
||||
traverseImports(name, code) {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
_this.gqlMap.set(name, code);
|
||||
|
||||
yield Promise.all(code.split(/\r\n?|\n/).map(line => line.match(IMPORT_RE)).filter(match => !!match).map( /*#__PURE__*/function () {
|
||||
var _ref = (0, _asyncToGenerator2.default)(function* ([, importName]) {
|
||||
let _yield$_this$gqlResol = yield _this.gqlResolver.resolve(importName, name),
|
||||
resolved = _yield$_this$gqlResol.path;
|
||||
|
||||
if (_this.gqlMap.has(resolved)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let code = yield fs.readFile(resolved, 'utf8');
|
||||
yield _this.traverseImports(resolved, code);
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}()));
|
||||
})();
|
||||
}
|
||||
|
||||
collectDependencies() {
|
||||
var _iterator = _createForOfIteratorHelper(this.gqlMap),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let _step$value = (0, _slicedToArray2.default)(_step.value, 1),
|
||||
path = _step$value[0];
|
||||
|
||||
this.addDependency(path, {
|
||||
includedInParent: true
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
}
|
||||
|
||||
parse(code) {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let gql = yield localRequire('graphql-tag', _this2.name);
|
||||
yield _this2.traverseImports(_this2.name, code);
|
||||
const allCodes = [..._this2.gqlMap.values()].join(os.EOL);
|
||||
return gql(allCodes);
|
||||
})();
|
||||
}
|
||||
|
||||
generate() {
|
||||
return `module.exports=${JSON.stringify(this.ast, null, 2)};`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = GraphqlAsset;
|
||||
319
BACK_BACK/node_modules/parcel-bundler/lib/assets/HTMLAsset.js
generated
vendored
Executable file
319
BACK_BACK/node_modules/parcel-bundler/lib/assets/HTMLAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,319 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
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', 'image'],
|
||||
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', 'msapplication-config'],
|
||||
itemprop: ['image', 'logo', 'screenshot', 'thumbnailUrl', 'contentUrl', 'downloadUrl']
|
||||
};
|
||||
const SCRIPT_TYPES = {
|
||||
'application/javascript': 'js',
|
||||
'text/javascript': 'js',
|
||||
'application/json': false,
|
||||
'application/ld+json': 'jsonld',
|
||||
'text/html': false
|
||||
}; // 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, options) {
|
||||
super(name, options);
|
||||
this.type = 'html';
|
||||
this.isAstDirty = false;
|
||||
this.hmrPageReload = true;
|
||||
}
|
||||
|
||||
parse(code) {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let res = yield posthtmlTransform.parse(code, _this);
|
||||
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 _iterator = _createForOfIteratorHelper(srcset.split(',')),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
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) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
return newSources.join(',');
|
||||
}
|
||||
|
||||
getAttrDepHandler(attr) {
|
||||
if (attr === 'srcset') {
|
||||
return this.collectSrcSetDependencies;
|
||||
}
|
||||
|
||||
return this.processSingleDependency;
|
||||
}
|
||||
|
||||
collectDependencies() {
|
||||
let ast = this.ast; // Add bundled dependencies from plugins like posthtml-extend or posthtml-include, if any
|
||||
|
||||
if (ast.messages) {
|
||||
ast.messages.forEach(message => {
|
||||
if (message.type === 'dependency') {
|
||||
this.addDependency(message.file, {
|
||||
includedInParent: true
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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]) && node.attrs.content !== '';
|
||||
})) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.tag === 'link' && node.attrs.rel === 'manifest' && node.attrs.href) {
|
||||
node.attrs.href = this.getAttrDepHandler('href').call(this, node.attrs.href, {
|
||||
entry: true
|
||||
});
|
||||
this.isAstDirty = true;
|
||||
return node;
|
||||
}
|
||||
|
||||
for (let attr in node.attrs) {
|
||||
const attrVal = node.attrs[attr];
|
||||
|
||||
if (!attrVal) {
|
||||
continue;
|
||||
} // Check for virtual paths
|
||||
|
||||
|
||||
if (node.tag === 'a' && attrVal.lastIndexOf('.') < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let elements = ATTRS[attr];
|
||||
|
||||
if (elements && elements.includes(node.tag)) {
|
||||
let depHandler = this.getAttrDepHandler(attr);
|
||||
let options = OPTIONS[node.tag];
|
||||
node.attrs[attr] = depHandler.call(this, attrVal, options && options[attr]);
|
||||
this.isAstDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
});
|
||||
}
|
||||
|
||||
pretransform() {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
yield posthtmlTransform.transform(_this2);
|
||||
})();
|
||||
}
|
||||
|
||||
transform() {
|
||||
var _this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (_this3.options.minify) {
|
||||
yield htmlnanoTransform(_this3);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this4 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
// Extract inline <script> and <style> tags for processing.
|
||||
let parts = [];
|
||||
|
||||
if (_this4.ast) {
|
||||
_this4.ast.walk(node => {
|
||||
if (node.tag === 'script' || node.tag === 'style') {
|
||||
let value = node.content && node.content.join('').trim();
|
||||
|
||||
if (value) {
|
||||
let type;
|
||||
|
||||
if (node.tag === 'style') {
|
||||
if (node.attrs && node.attrs.type) {
|
||||
type = node.attrs.type.split('/')[1];
|
||||
} else {
|
||||
type = 'css';
|
||||
}
|
||||
} else if (node.attrs && node.attrs.type) {
|
||||
// Skip JSON
|
||||
if (SCRIPT_TYPES[node.attrs.type] === false) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (SCRIPT_TYPES[node.attrs.type]) {
|
||||
type = SCRIPT_TYPES[node.attrs.type];
|
||||
} else {
|
||||
type = node.attrs.type.split('/')[1];
|
||||
}
|
||||
} else {
|
||||
type = 'js';
|
||||
}
|
||||
|
||||
parts.push({
|
||||
type,
|
||||
value,
|
||||
inlineHTML: true,
|
||||
meta: {
|
||||
type: 'tag',
|
||||
node
|
||||
}
|
||||
});
|
||||
}
|
||||
} // Process inline style attributes.
|
||||
|
||||
|
||||
if (node.attrs && node.attrs.style) {
|
||||
parts.push({
|
||||
type: 'css',
|
||||
value: node.attrs.style,
|
||||
meta: {
|
||||
type: 'attr',
|
||||
node
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return node;
|
||||
});
|
||||
}
|
||||
|
||||
return parts;
|
||||
})();
|
||||
}
|
||||
|
||||
postProcess(generated) {
|
||||
var _this5 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
// Replace inline scripts and styles with processed results.
|
||||
var _iterator2 = _createForOfIteratorHelper(generated),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
let rendition = _step2.value;
|
||||
let _rendition$meta = rendition.meta,
|
||||
type = _rendition$meta.type,
|
||||
node = _rendition$meta.node;
|
||||
|
||||
if (type === 'attr' && rendition.type === 'css') {
|
||||
node.attrs.style = rendition.value;
|
||||
} else if (type === 'tag') {
|
||||
if (rendition.isMain) {
|
||||
node.content = rendition.value;
|
||||
} // Delete "type" attribute, since CSS and JS are the defaults.
|
||||
// Unless it's application/ld+json
|
||||
|
||||
|
||||
if (node.attrs && (node.tag === 'style' || node.attrs.type && SCRIPT_TYPES[node.attrs.type] === 'js')) {
|
||||
delete node.attrs.type;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
|
||||
return [{
|
||||
type: 'html',
|
||||
value: render(_this5.ast)
|
||||
}];
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = HTMLAsset;
|
||||
253
BACK_BACK/node_modules/parcel-bundler/lib/assets/JSAsset.js
generated
vendored
Executable file
253
BACK_BACK/node_modules/parcel-bundler/lib/assets/JSAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,253 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const traverse = require('@babel/traverse').default;
|
||||
|
||||
const codeFrame = require('@babel/code-frame').codeFrameColumns;
|
||||
|
||||
const collectDependencies = require('../visitors/dependencies');
|
||||
|
||||
const walk = require('babylon-walk');
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const babelParser = require('@babel/parser');
|
||||
|
||||
const insertGlobals = require('../visitors/globals');
|
||||
|
||||
const fsVisitor = require('../visitors/fs');
|
||||
|
||||
const envVisitor = require('../visitors/env');
|
||||
|
||||
const processVisitor = require('../visitors/process');
|
||||
|
||||
const babel = require('../transforms/babel/transform');
|
||||
|
||||
const babel7 = require('../transforms/babel/babel7');
|
||||
|
||||
const generate = require('@babel/generator').default;
|
||||
|
||||
const terser = require('../transforms/terser');
|
||||
|
||||
const SourceMap = require('../SourceMap');
|
||||
|
||||
const hoist = require('../scope-hoisting/hoist');
|
||||
|
||||
const loadSourceMap = require('../utils/loadSourceMap');
|
||||
|
||||
const isAccessedVarChanged = require('../utils/isAccessedVarChanged');
|
||||
|
||||
const IMPORT_RE = /\b(?:import\b|export\b|require\s*\()/;
|
||||
const ENV_RE = /\b(?:process\.env)\b/;
|
||||
const BROWSER_RE = /\b(?:process\.browser)\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*(?:Shared)?Worker\s*\(/;
|
||||
|
||||
class JSAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'js';
|
||||
this.globals = new Map();
|
||||
this.isAstDirty = false;
|
||||
this.isES6Module = false;
|
||||
this.outputCode = null;
|
||||
this.cacheData.env = {};
|
||||
this.rendition = options.rendition;
|
||||
this.sourceMap = this.rendition ? this.rendition.map : null;
|
||||
}
|
||||
|
||||
shouldInvalidate(cacheData) {
|
||||
return isAccessedVarChanged(cacheData);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
parse(code) {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
return babelParser.parse(code, {
|
||||
filename: _this.name,
|
||||
allowReturnOutsideFunction: true,
|
||||
strictMode: false,
|
||||
sourceType: 'module',
|
||||
plugins: ['exportDefaultFrom', 'exportNamespaceFrom', 'dynamicImport']
|
||||
});
|
||||
})();
|
||||
}
|
||||
|
||||
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 _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (_this2.options.sourceMaps && !_this2.sourceMap) {
|
||||
_this2.sourceMap = yield loadSourceMap(_this2);
|
||||
}
|
||||
|
||||
yield babel(_this2); // Inline environment variables
|
||||
|
||||
if (_this2.options.target === 'browser' && ENV_RE.test(_this2.contents)) {
|
||||
yield _this2.parseIfNeeded();
|
||||
|
||||
_this2.traverseFast(envVisitor);
|
||||
} // Inline process.browser
|
||||
|
||||
|
||||
if (_this2.options.target === 'browser' && BROWSER_RE.test(_this2.contents)) {
|
||||
yield _this2.parseIfNeeded();
|
||||
|
||||
_this2.traverse(processVisitor);
|
||||
|
||||
_this2.isAstDirty = true;
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
transform() {
|
||||
var _this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (_this3.options.target === 'browser') {
|
||||
if (_this3.dependencies.has('fs') && FS_RE.test(_this3.contents)) {
|
||||
// Check if we should ignore fs calls
|
||||
// See https://github.com/defunctzombie/node-browser-resolve#skip
|
||||
let pkg = yield _this3.getPackage();
|
||||
let ignore = pkg && pkg.browser && pkg.browser.fs === false;
|
||||
|
||||
if (!ignore) {
|
||||
yield _this3.parseIfNeeded();
|
||||
|
||||
_this3.traverse(fsVisitor);
|
||||
}
|
||||
}
|
||||
|
||||
if (GLOBAL_RE.test(_this3.contents)) {
|
||||
yield _this3.parseIfNeeded();
|
||||
walk.ancestor(_this3.ast, insertGlobals, _this3);
|
||||
}
|
||||
}
|
||||
|
||||
if (_this3.options.scopeHoist) {
|
||||
yield _this3.parseIfNeeded();
|
||||
yield _this3.getPackage();
|
||||
|
||||
_this3.traverse(hoist);
|
||||
|
||||
_this3.isAstDirty = true;
|
||||
} else {
|
||||
if (_this3.isES6Module) {
|
||||
yield babel7(_this3, {
|
||||
internal: true,
|
||||
config: {
|
||||
plugins: [require('@babel/plugin-transform-modules-commonjs')]
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (_this3.options.minify) {
|
||||
yield terser(_this3);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this4 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let code;
|
||||
|
||||
if (_this4.isAstDirty) {
|
||||
let opts = {
|
||||
sourceMaps: _this4.options.sourceMaps,
|
||||
sourceFileName: _this4.relativeName
|
||||
};
|
||||
let generated = generate(_this4.ast, opts, _this4.contents);
|
||||
|
||||
if (_this4.options.sourceMaps && generated.rawMappings) {
|
||||
let rawMap = new SourceMap(generated.rawMappings, {
|
||||
[_this4.relativeName]: _this4.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 (_this4.sourceMap) {
|
||||
_this4.sourceMap = yield new SourceMap().extendSourceMap(_this4.sourceMap, rawMap);
|
||||
} else {
|
||||
_this4.sourceMap = rawMap;
|
||||
}
|
||||
}
|
||||
|
||||
code = generated.code;
|
||||
} else {
|
||||
code = _this4.outputCode != null ? _this4.outputCode : _this4.contents;
|
||||
}
|
||||
|
||||
if (_this4.options.sourceMaps && !_this4.sourceMap) {
|
||||
_this4.sourceMap = new SourceMap().generateEmptyMap(_this4.relativeName, _this4.contents);
|
||||
}
|
||||
|
||||
if (_this4.globals.size > 0) {
|
||||
code = Array.from(_this4.globals.values()).join('\n') + '\n' + code;
|
||||
|
||||
if (_this4.options.sourceMaps) {
|
||||
if (!(_this4.sourceMap instanceof SourceMap)) {
|
||||
_this4.sourceMap = yield new SourceMap().addMap(_this4.sourceMap);
|
||||
}
|
||||
|
||||
_this4.sourceMap.offset(_this4.globals.size);
|
||||
}
|
||||
}
|
||||
|
||||
return [{
|
||||
type: 'js',
|
||||
value: code,
|
||||
map: _this4.sourceMap
|
||||
}];
|
||||
})();
|
||||
}
|
||||
|
||||
generateErrorMessage(err) {
|
||||
const loc = err.loc;
|
||||
|
||||
if (loc) {
|
||||
// Babel 7 adds its own code frame on the error message itself
|
||||
// We need to remove it and pass it separately.
|
||||
if (err.message.startsWith(this.name)) {
|
||||
err.message = err.message.slice(this.name.length + 1, err.message.indexOf('\n')).trim();
|
||||
}
|
||||
|
||||
err.codeFrame = codeFrame(this.contents, {
|
||||
start: loc
|
||||
});
|
||||
err.highlightedCodeFrame = codeFrame(this.contents, {
|
||||
start: loc
|
||||
}, {
|
||||
highlightCode: true
|
||||
});
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = JSAsset;
|
||||
40
BACK_BACK/node_modules/parcel-bundler/lib/assets/JSONAsset.js
generated
vendored
Executable file
40
BACK_BACK/node_modules/parcel-bundler/lib/assets/JSONAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
"use strict";
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const json5 = require('json5');
|
||||
|
||||
const _require = require('terser'),
|
||||
minify = _require.minify;
|
||||
|
||||
class JSONAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, 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 && !this.options.scopeHoist) {
|
||||
let minified = minify(code);
|
||||
|
||||
if (minified.error) {
|
||||
throw minified.error;
|
||||
}
|
||||
|
||||
code = minified.code;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = JSONAsset;
|
||||
76
BACK_BACK/node_modules/parcel-bundler/lib/assets/JSONLDAsset.js
generated
vendored
Executable file
76
BACK_BACK/node_modules/parcel-bundler/lib/assets/JSONLDAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,76 @@
|
|||
"use strict";
|
||||
|
||||
const urlJoin = require('../utils/urlJoin');
|
||||
|
||||
const isURL = require('../utils/is-url');
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const logger = require('@parcel/logger'); // A list of all attributes in a schema that may produce a dependency
|
||||
// Based on https://schema.org/ImageObject
|
||||
// Section "Instances of ImageObject may appear as values for the following properties"
|
||||
|
||||
|
||||
const SCHEMA_ATTRS = ['logo', 'photo', 'image', 'thumbnail', 'screenshot', 'primaryImageOfPage', 'embedUrl', 'thumbnailUrl', 'video', 'contentUrl'];
|
||||
|
||||
class JSONLDAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'jsonld';
|
||||
}
|
||||
|
||||
parse(content) {
|
||||
return JSON.parse(content.trim());
|
||||
}
|
||||
|
||||
collectDependencies() {
|
||||
if (!this.options.publicURL.startsWith('http')) {
|
||||
logger.warn("Please specify a publicURL using --public-url, otherwise schema assets won't be collected");
|
||||
return;
|
||||
}
|
||||
|
||||
for (let schemaKey in this.ast) {
|
||||
if (SCHEMA_ATTRS.includes(schemaKey)) {
|
||||
this.collectFromKey(this.ast, schemaKey);
|
||||
this.isAstDirty = true;
|
||||
}
|
||||
}
|
||||
} // Auxiliary method for collectDependencies() to use for recursion
|
||||
|
||||
|
||||
collectFromKey(schema, schemaKey) {
|
||||
if (!schema.hasOwnProperty(schemaKey)) {
|
||||
return;
|
||||
} // values can be strings or objects
|
||||
// if it's not a string, it should have a url
|
||||
|
||||
|
||||
if (typeof schema[schemaKey] === 'string') {
|
||||
let assetPath = this.addURLDependency(schema[schemaKey]);
|
||||
|
||||
if (!isURL(assetPath)) {
|
||||
// paths aren't allowed, values must be urls
|
||||
assetPath = urlJoin(this.options.publicURL, assetPath);
|
||||
}
|
||||
|
||||
schema[schemaKey] = assetPath;
|
||||
} else if (Array.isArray(schema[schemaKey])) {
|
||||
Object.keys(schema[schemaKey]).forEach(i => {
|
||||
this.collectFromKey(schema[schemaKey], i);
|
||||
});
|
||||
} else {
|
||||
this.collectFromKey(schema[schemaKey], 'url');
|
||||
}
|
||||
}
|
||||
|
||||
generate() {
|
||||
if (this.options.production) {
|
||||
return JSON.stringify(this.ast);
|
||||
} else {
|
||||
return JSON.stringify(this.ast, null, 2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = JSONLDAsset;
|
||||
65
BACK_BACK/node_modules/parcel-bundler/lib/assets/KotlinAsset.js
generated
vendored
Executable file
65
BACK_BACK/node_modules/parcel-bundler/lib/assets/KotlinAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
const os = require('os');
|
||||
|
||||
class KotlinAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'js';
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
// require kotlin
|
||||
const kotlinCompiler = yield localRequire('@jetbrains/kotlinc-js-api', _this.name);
|
||||
let id = Math.random().toString(36).slice(3);
|
||||
let dir = path.join(os.tmpdir(), id);
|
||||
let filename = path.join(dir, id + '.js');
|
||||
yield fs.mkdirp(dir);
|
||||
yield kotlinCompiler.compile({
|
||||
output: filename,
|
||||
sources: [_this.name],
|
||||
moduleKind: 'commonjs',
|
||||
noStdlib: false,
|
||||
metaInfo: true,
|
||||
sourceMaps: _this.options.sourceMaps
|
||||
});
|
||||
let source = yield fs.readFile(filename, 'utf8');
|
||||
let sourceMap;
|
||||
|
||||
if (_this.options.sourceMaps) {
|
||||
sourceMap = yield fs.readFile(filename + '.map', 'utf8');
|
||||
sourceMap = JSON.parse(sourceMap);
|
||||
sourceMap.sources = [_this.relativeName];
|
||||
sourceMap.sourcesContent = [_this.contents]; // remove source map url
|
||||
|
||||
source = source.substring(0, source.lastIndexOf('//# sourceMappingURL'));
|
||||
} // delete temp directory
|
||||
|
||||
|
||||
yield fs.rimraf(dir);
|
||||
return [{
|
||||
type: 'js',
|
||||
value: source,
|
||||
sourceMap
|
||||
}];
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = KotlinAsset;
|
||||
141
BACK_BACK/node_modules/parcel-bundler/lib/assets/LESSAsset.js
generated
vendored
Executable file
141
BACK_BACK/node_modules/parcel-bundler/lib/assets/LESSAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,141 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
const _require = require('@parcel/utils'),
|
||||
promisify = _require.promisify;
|
||||
|
||||
const Resolver = require('../Resolver');
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const parseCSSImport = require('../utils/parseCSSImport');
|
||||
|
||||
class LESSAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'css';
|
||||
}
|
||||
|
||||
parse(code) {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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 = (yield _this.getConfig(['.lessrc', '.lessrc.js'], {
|
||||
packageKey: 'less'
|
||||
})) || {};
|
||||
opts.filename = _this.name;
|
||||
opts.plugins = (opts.plugins || []).concat(urlPlugin(_this));
|
||||
|
||||
if (_this.options.sourceMaps) {
|
||||
opts.sourceMap = {
|
||||
outputSourceFiles: true
|
||||
};
|
||||
}
|
||||
|
||||
return render(code, opts);
|
||||
})();
|
||||
}
|
||||
|
||||
collectDependencies() {
|
||||
var _iterator = _createForOfIteratorHelper(this.ast.imports),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let dep = _step.value;
|
||||
this.addDependency(dep, {
|
||||
includedInParent: true
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
}
|
||||
|
||||
generate() {
|
||||
let map;
|
||||
|
||||
if (this.ast && this.ast.map) {
|
||||
map = JSON.parse(this.ast.map.toString());
|
||||
map.sources = map.sources.map(v => path.relative(this.options.rootDir, v));
|
||||
}
|
||||
|
||||
return [{
|
||||
type: 'css',
|
||||
value: this.ast ? this.ast.css : '',
|
||||
hasDependencies: false,
|
||||
map
|
||||
}];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
let LessFileManager = getFileManager(less, asset.options);
|
||||
pluginManager.addFileManager(new LessFileManager());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getFileManager(less, options) {
|
||||
const resolver = new Resolver({
|
||||
extensions: ['.css', '.less'],
|
||||
rootDir: options.rootDir
|
||||
});
|
||||
|
||||
class LessFileManager extends less.FileManager {
|
||||
supports() {
|
||||
return true;
|
||||
}
|
||||
|
||||
supportsSync() {
|
||||
return false;
|
||||
}
|
||||
|
||||
loadFile(filename, currentDirectory) {
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
filename = parseCSSImport(filename);
|
||||
let resolved = yield resolver.resolve(filename, path.join(currentDirectory, 'index'));
|
||||
return {
|
||||
contents: yield fs.readFile(resolved.path, 'utf8'),
|
||||
filename: resolved.path
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return LessFileManager;
|
||||
}
|
||||
|
||||
module.exports = LESSAsset;
|
||||
29
BACK_BACK/node_modules/parcel-bundler/lib/assets/MarkdownAsset.js
generated
vendored
Executable file
29
BACK_BACK/node_modules/parcel-bundler/lib/assets/MarkdownAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
class MarkdownAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'html';
|
||||
this.hmrPageReload = true;
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let marked = yield localRequire('marked', _this.name);
|
||||
return marked(_this.contents);
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = MarkdownAsset;
|
||||
68
BACK_BACK/node_modules/parcel-bundler/lib/assets/PugAsset.js
generated
vendored
Executable file
68
BACK_BACK/node_modules/parcel-bundler/lib/assets/PugAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
class PugAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'html';
|
||||
this.hmrPageReload = true;
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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: config.pretty || false,
|
||||
templateName: path.basename(_this.basename, path.extname(_this.basename)),
|
||||
filters: config.filters,
|
||||
filterOptions: config.filterOptions,
|
||||
filterAliases: config.filterAliases
|
||||
});
|
||||
|
||||
if (compiled.dependencies) {
|
||||
var _iterator = _createForOfIteratorHelper(compiled.dependencies),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let item = _step.value;
|
||||
|
||||
_this.addDependency(item, {
|
||||
includedInParent: true
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
}
|
||||
|
||||
return compiled(config.locals);
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = PugAsset;
|
||||
41
BACK_BACK/node_modules/parcel-bundler/lib/assets/RawAsset.js
generated
vendored
Executable file
41
BACK_BACK/node_modules/parcel-bundler/lib/assets/RawAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
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 [{
|
||||
type: 'js',
|
||||
value: `module.exports=${JSON.stringify(pathToAsset)};`
|
||||
}];
|
||||
}
|
||||
|
||||
generateHash() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
return md5.file(_this.name);
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = RawAsset;
|
||||
43
BACK_BACK/node_modules/parcel-bundler/lib/assets/ReasonAsset.js
generated
vendored
Executable file
43
BACK_BACK/node_modules/parcel-bundler/lib/assets/ReasonAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
class ReasonAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'js';
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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;
|
||||
236
BACK_BACK/node_modules/parcel-bundler/lib/assets/RustAsset.js
generated
vendored
Executable file
236
BACK_BACK/node_modules/parcel-bundler/lib/assets/RustAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,236 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const commandExists = require('command-exists');
|
||||
|
||||
const childProcess = require('child_process');
|
||||
|
||||
const _require = require('@parcel/utils'),
|
||||
promisify = _require.promisify;
|
||||
|
||||
const exec = promisify(childProcess.execFile);
|
||||
|
||||
const toml = require('@iarna/toml');
|
||||
|
||||
const fs = require('@parcel/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;
|
||||
|
||||
class RustAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, 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 (0, _asyncToGenerator2.default)(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(file => 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();
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
installRust() {
|
||||
return (0, _asyncToGenerator2.default)(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
|
||||
|
||||
|
||||
let _yield$exec = yield exec('rustup', ['show']),
|
||||
_yield$exec2 = (0, _slicedToArray2.default)(_yield$exec, 1),
|
||||
stdout = _yield$exec2[0];
|
||||
|
||||
if (!stdout.includes('nightly')) {
|
||||
yield pipeSpawn('rustup', ['update']);
|
||||
yield pipeSpawn('rustup', ['toolchain', 'install', 'nightly']);
|
||||
} // Ensure wasm target is installed
|
||||
|
||||
|
||||
var _yield$exec3 = yield exec('rustup', ['target', 'list', '--toolchain', 'nightly']);
|
||||
|
||||
var _yield$exec4 = (0, _slicedToArray2.default)(_yield$exec3, 1);
|
||||
|
||||
stdout = _yield$exec4[0];
|
||||
|
||||
if (!stdout.includes(RUST_TARGET + ' (installed)')) {
|
||||
yield pipeSpawn('rustup', ['target', 'add', RUST_TARGET, '--toolchain', 'nightly']);
|
||||
}
|
||||
|
||||
rustInstalled = true;
|
||||
})();
|
||||
}
|
||||
|
||||
cargoBuild(cargoConfig, cargoDir) {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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'), toml.stringify(cargoConfig));
|
||||
} // Run cargo
|
||||
|
||||
|
||||
let args = ['+nightly', 'build', '--target', RUST_TARGET, '--release'];
|
||||
yield exec('cargo', args, {
|
||||
cwd: cargoDir
|
||||
}); // Get output file paths
|
||||
|
||||
let _yield$exec5 = yield exec('cargo', ['metadata', '--format-version', '1'], {
|
||||
cwd: cargoDir
|
||||
}),
|
||||
_yield$exec6 = (0, _slicedToArray2.default)(_yield$exec5, 1),
|
||||
stdout = _yield$exec6[0];
|
||||
|
||||
const cargoMetadata = JSON.parse(stdout);
|
||||
const cargoTargetDir = cargoMetadata.target_directory;
|
||||
let outDir = path.join(cargoTargetDir, 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 (0, _asyncToGenerator2.default)(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];
|
||||
const minifyArgs = _this3.options.minify ? ['-Clink-arg=-s'] : [];
|
||||
yield exec('rustc', [...args, ...minifyArgs]); // 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 (0, _asyncToGenerator2.default)(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 _iterator = _createForOfIteratorHelper(deps),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let dep = _step.value;
|
||||
dep = path.resolve(dir, dep.slice(0, dep.indexOf(': ')));
|
||||
|
||||
if (dep !== _this4.name) {
|
||||
_this4.addDependency(dep, {
|
||||
includedInParent: true
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this5 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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;
|
||||
155
BACK_BACK/node_modules/parcel-bundler/lib/assets/SASSAsset.js
generated
vendored
Executable file
155
BACK_BACK/node_modules/parcel-bundler/lib/assets/SASSAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,155 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
const _require = require('@parcel/utils'),
|
||||
promisify = _require.promisify;
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const os = require('os');
|
||||
|
||||
const Resolver = require('../Resolver');
|
||||
|
||||
const parseCSSImport = require('../utils/parseCSSImport');
|
||||
|
||||
class SASSAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'css';
|
||||
}
|
||||
|
||||
parse(code) {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
// node-sass or dart-sass should be installed locally in the module that's being required
|
||||
let sass = yield getSassRuntime(_this.name);
|
||||
let render = promisify(sass.render.bind(sass));
|
||||
const resolver = new Resolver({
|
||||
extensions: ['.scss', '.sass'],
|
||||
rootDir: _this.options.rootDir
|
||||
});
|
||||
let opts = (yield _this.getConfig(['.sassrc', '.sassrc.js'], {
|
||||
packageKey: 'sass'
|
||||
})) || {};
|
||||
opts.includePaths = (opts.includePaths ? opts.includePaths.map(includePath => path.resolve(includePath)) : []).concat(path.dirname(_this.name));
|
||||
opts.data = opts.data ? opts.data + os.EOL + code : code;
|
||||
let type = _this.options.rendition ? _this.options.rendition.type : path.extname(_this.name).toLowerCase().replace('.', '');
|
||||
opts.indentedSyntax = typeof opts.indentedSyntax === 'boolean' ? opts.indentedSyntax : type === 'sass';
|
||||
opts.importer = opts.importer || [];
|
||||
opts.importer = Array.isArray(opts.importer) ? opts.importer : [opts.importer];
|
||||
opts.importer.push((url, prev, done) => {
|
||||
url = url.replace(/^file:\/\//, '');
|
||||
url = parseCSSImport(url);
|
||||
resolver.resolve(url, prev === 'stdin' ? _this.name : prev).then(resolved => resolved.path).catch(() => url).then(file => done({
|
||||
file
|
||||
})).catch(err => done(normalizeError(err)));
|
||||
});
|
||||
|
||||
if (_this.options.sourceMaps) {
|
||||
opts.sourceMap = true;
|
||||
opts.file = _this.name;
|
||||
opts.outFile = _this.name;
|
||||
opts.omitSourceMapUrl = true;
|
||||
opts.sourceMapContents = true;
|
||||
}
|
||||
|
||||
try {
|
||||
return yield render(opts);
|
||||
} catch (err) {
|
||||
// Format the error so it can be handled by parcel's prettyError
|
||||
if (err.formatted) {
|
||||
throw sassToCodeFrame(err);
|
||||
} // Throw original error if there is no codeFrame
|
||||
|
||||
|
||||
throw err;
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
collectDependencies() {
|
||||
var _iterator = _createForOfIteratorHelper(this.ast.stats.includedFiles),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let dep = _step.value;
|
||||
this.addDependency(dep, {
|
||||
includedInParent: true
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
}
|
||||
|
||||
generate() {
|
||||
return [{
|
||||
type: 'css',
|
||||
value: this.ast ? this.ast.css.toString() : '',
|
||||
map: this.ast && this.ast.map ? JSON.parse(this.ast.map.toString()) : undefined
|
||||
}];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = SASSAsset;
|
||||
|
||||
function getSassRuntime(_x) {
|
||||
return _getSassRuntime.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getSassRuntime() {
|
||||
_getSassRuntime = (0, _asyncToGenerator2.default)(function* (searchPath) {
|
||||
try {
|
||||
return yield localRequire('node-sass', searchPath, true);
|
||||
} catch (e) {
|
||||
// If node-sass is not used locally, install dart-sass, as this causes no freezing issues
|
||||
return localRequire('sass', searchPath);
|
||||
}
|
||||
});
|
||||
return _getSassRuntime.apply(this, arguments);
|
||||
}
|
||||
|
||||
function sassToCodeFrame(err) {
|
||||
let error = new Error(err.message);
|
||||
error.codeFrame = err.formatted;
|
||||
error.stack = err.stack;
|
||||
error.fileName = err.file;
|
||||
error.loc = {
|
||||
line: err.line,
|
||||
column: err.column
|
||||
};
|
||||
return error;
|
||||
} // Ensures an error inherits from Error
|
||||
|
||||
|
||||
function normalizeError(err) {
|
||||
let message = 'Unknown error';
|
||||
|
||||
if (err) {
|
||||
if (err instanceof Error) {
|
||||
return err;
|
||||
}
|
||||
|
||||
message = err.stack || err.message || err;
|
||||
}
|
||||
|
||||
return new Error(message);
|
||||
}
|
||||
42
BACK_BACK/node_modules/parcel-bundler/lib/assets/SSSAsset.js
generated
vendored
Executable file
42
BACK_BACK/node_modules/parcel-bundler/lib/assets/SSSAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const postcss = require('postcss');
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
class SSSAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'css';
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let sugarss = yield localRequire('sugarss', _this.name);
|
||||
yield _this.loadIfNeeded();
|
||||
|
||||
let _yield$postcss$proces = yield postcss().process(_this.contents, {
|
||||
from: _this.name,
|
||||
to: _this.name,
|
||||
parser: sugarss
|
||||
}),
|
||||
css = _yield$postcss$proces.css;
|
||||
|
||||
return [{
|
||||
type: 'css',
|
||||
value: css
|
||||
}];
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = SSSAsset;
|
||||
280
BACK_BACK/node_modules/parcel-bundler/lib/assets/StylusAsset.js
generated
vendored
Executable file
280
BACK_BACK/node_modules/parcel-bundler/lib/assets/StylusAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,280 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
// const CSSAsset = require('./CSSAsset');
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
const Resolver = require('../Resolver');
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
const _require = require('path'),
|
||||
dirname = _require.dirname,
|
||||
resolve = _require.resolve,
|
||||
relative = _require.relative;
|
||||
|
||||
const _require2 = require('../utils/glob'),
|
||||
isGlob = _require2.isGlob,
|
||||
glob = _require2.glob;
|
||||
|
||||
const URL_RE = /^(?:url\s*\(\s*)?['"]?(?:[#/]|(?:https?:)?\/\/)/i;
|
||||
|
||||
class StylusAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'css';
|
||||
}
|
||||
|
||||
parse(code) {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
// stylus should be installed locally in the module that's being required
|
||||
let stylus = yield localRequire('stylus', _this.name);
|
||||
let opts = yield _this.getConfig(['.stylusrc', '.stylusrc.js'], {
|
||||
packageKey: 'stylus'
|
||||
});
|
||||
let style = stylus(code, opts);
|
||||
style.set('filename', _this.name);
|
||||
style.set('include css', true); // Setup a handler for the URL function so we add dependencies for linked assets.
|
||||
|
||||
style.define('url', node => {
|
||||
let filename = _this.addURLDependency(node.val, node.filename);
|
||||
|
||||
return new stylus.nodes.Literal(`url(${JSON.stringify(filename)})`);
|
||||
});
|
||||
style.set('Evaluator', yield createEvaluator(code, _this, style.options));
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getDependencies(_x, _x2, _x3, _x4) {
|
||||
return _getDependencies.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getDependencies() {
|
||||
_getDependencies = (0, _asyncToGenerator2.default)(function* (code, filepath, asset, options, seen = new Set()) {
|
||||
seen.add(filepath);
|
||||
|
||||
const _yield$Promise$all = yield Promise.all(['parser', 'visitor/deps-resolver', 'nodes', 'utils'].map(dep => localRequire('stylus/lib/' + dep, filepath))),
|
||||
_yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 4),
|
||||
Parser = _yield$Promise$all2[0],
|
||||
DepsResolver = _yield$Promise$all2[1],
|
||||
nodes = _yield$Promise$all2[2],
|
||||
utils = _yield$Promise$all2[3];
|
||||
|
||||
nodes.filename = asset.name;
|
||||
let parser = new Parser(code, options);
|
||||
let ast = parser.parse();
|
||||
let deps = new Map();
|
||||
let resolver = new Resolver(Object.assign({}, asset.options, {
|
||||
extensions: ['.styl', '.css']
|
||||
}));
|
||||
|
||||
class ImportVisitor extends DepsResolver {
|
||||
visitImport(imported) {
|
||||
let path = imported.path.first.string;
|
||||
|
||||
if (!deps.has(path)) {
|
||||
if (isGlob(path)) {
|
||||
deps.set(path, glob(resolve(dirname(filepath), path), {
|
||||
onlyFiles: true
|
||||
}).then(entries => Promise.all(entries.map(entry => resolver.resolve('./' + relative(dirname(filepath), entry), filepath)))));
|
||||
} else {
|
||||
deps.set(path, resolver.resolve(path, filepath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new ImportVisitor(ast, options).visit(ast); // Recursively process depdendencies, and return a map with all resolved paths.
|
||||
|
||||
let res = new Map();
|
||||
yield Promise.all(Array.from(deps.entries()).map( /*#__PURE__*/function () {
|
||||
var _ref = (0, _asyncToGenerator2.default)(function* ([path, resolved]) {
|
||||
try {
|
||||
resolved = yield resolved;
|
||||
resolved = Array.isArray(resolved) ? resolved.map(r => r.path) : resolved.path;
|
||||
} catch (err) {
|
||||
resolved = null;
|
||||
}
|
||||
|
||||
let found;
|
||||
|
||||
if (resolved) {
|
||||
found = Array.isArray(resolved) ? resolved : [resolved];
|
||||
res.set(path, resolved);
|
||||
} else {
|
||||
// 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
|
||||
let originalPath = path;
|
||||
|
||||
if (!/\.styl$/i.test(path)) {
|
||||
path += '.styl';
|
||||
}
|
||||
|
||||
let paths = (options.paths || []).concat(dirname(filepath || '.'));
|
||||
found = utils.find(path, paths, filepath);
|
||||
|
||||
if (!found) {
|
||||
found = utils.lookupIndex(originalPath, paths, filepath);
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
throw new Error('failed to locate file ' + originalPath);
|
||||
}
|
||||
} // Recursively process resolved files as well to get nested deps
|
||||
|
||||
|
||||
var _iterator2 = _createForOfIteratorHelper(found),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
let resolved = _step2.value;
|
||||
|
||||
if (!seen.has(resolved)) {
|
||||
asset.addDependency(resolved, {
|
||||
includedInParent: true
|
||||
});
|
||||
let code = yield fs.readFile(resolved, 'utf8');
|
||||
|
||||
var _iterator3 = _createForOfIteratorHelper(yield getDependencies(code, resolved, asset, options, seen)),
|
||||
_step3;
|
||||
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
let _step3$value = (0, _slicedToArray2.default)(_step3.value, 2),
|
||||
path = _step3$value[0],
|
||||
resolvedPath = _step3$value[1];
|
||||
|
||||
res.set(path, resolvedPath);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator3.e(err);
|
||||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
});
|
||||
|
||||
return function (_x8) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}()));
|
||||
return res;
|
||||
});
|
||||
return _getDependencies.apply(this, arguments);
|
||||
}
|
||||
|
||||
function createEvaluator(_x5, _x6, _x7) {
|
||||
return _createEvaluator.apply(this, arguments);
|
||||
}
|
||||
/**
|
||||
* Puts the content of all given node blocks into the first one, essentially merging them.
|
||||
*/
|
||||
|
||||
|
||||
function _createEvaluator() {
|
||||
_createEvaluator = (0, _asyncToGenerator2.default)(function* (code, asset, options) {
|
||||
const deps = yield getDependencies(code, asset.name, asset, options);
|
||||
const Evaluator = yield localRequire('stylus/lib/visitor/evaluator', asset.name); // 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)) {
|
||||
let resolved = deps.get(path); // 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.
|
||||
|
||||
if (resolved) {
|
||||
if (!Array.isArray(resolved)) {
|
||||
node.string = resolved;
|
||||
} else {
|
||||
// If the import resolves to multiple files (i.e. glob),
|
||||
// replace it with a separate import node for each file
|
||||
return mergeBlocks(resolved.map(resolvedPath => {
|
||||
node.string = resolvedPath;
|
||||
return super.visitImport(imported.clone());
|
||||
}));
|
||||
}
|
||||
}
|
||||
} // Done. Let stylus do its thing.
|
||||
|
||||
|
||||
return super.visitImport(imported);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return CustomEvaluator;
|
||||
});
|
||||
return _createEvaluator.apply(this, arguments);
|
||||
}
|
||||
|
||||
function mergeBlocks(blocks) {
|
||||
let finalBlock;
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(blocks),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
const block = _step.value;
|
||||
if (!finalBlock) finalBlock = block;else {
|
||||
block.nodes.forEach(node => finalBlock.push(node));
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
return finalBlock;
|
||||
}
|
||||
|
||||
module.exports = StylusAsset;
|
||||
25
BACK_BACK/node_modules/parcel-bundler/lib/assets/TOMLAsset.js
generated
vendored
Executable file
25
BACK_BACK/node_modules/parcel-bundler/lib/assets/TOMLAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
"use strict";
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const toml = require('@iarna/toml');
|
||||
|
||||
const serializeObject = require('../utils/serializeObject');
|
||||
|
||||
class TOMLAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'js';
|
||||
}
|
||||
|
||||
parse(code) {
|
||||
return toml.parse(code);
|
||||
}
|
||||
|
||||
generate() {
|
||||
return serializeObject(this.ast, this.options.minify && !this.options.scopeHoist);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = TOMLAsset;
|
||||
71
BACK_BACK/node_modules/parcel-bundler/lib/assets/TypeScriptAsset.js
generated
vendored
Executable file
71
BACK_BACK/node_modules/parcel-bundler/lib/assets/TypeScriptAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,71 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
const isAccessedVarChanged = require('../utils/isAccessedVarChanged');
|
||||
|
||||
class TypeScriptAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'js';
|
||||
this.cacheData.env = {};
|
||||
}
|
||||
|
||||
shouldInvalidate(cacheData) {
|
||||
return isAccessedVarChanged(cacheData);
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
// require typescript, installed locally in the app
|
||||
let typescript = yield localRequire('typescript', _this.name);
|
||||
let transpilerOptions = {
|
||||
compilerOptions: {
|
||||
module: _this.options.scopeHoist ? typescript.ModuleKind.ESNext : 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,
|
||||
map: sourceMap
|
||||
}];
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = TypeScriptAsset;
|
||||
325
BACK_BACK/node_modules/parcel-bundler/lib/assets/VueAsset.js
generated
vendored
Executable file
325
BACK_BACK/node_modules/parcel-bundler/lib/assets/VueAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,325 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
const md5 = require('../utils/md5');
|
||||
|
||||
const _require = require('terser'),
|
||||
minify = _require.minify;
|
||||
|
||||
const t = require('@babel/types');
|
||||
|
||||
class VueAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'js';
|
||||
}
|
||||
|
||||
parse(code) {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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
|
||||
compiler: _this.vueTemplateCompiler
|
||||
});
|
||||
})();
|
||||
}
|
||||
|
||||
generate() {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let descriptor = _this2.ast;
|
||||
let parts = [];
|
||||
|
||||
if (descriptor.script) {
|
||||
parts.push({
|
||||
type: descriptor.script.lang || 'js',
|
||||
value: descriptor.script.content,
|
||||
map: descriptor.script.map
|
||||
});
|
||||
}
|
||||
|
||||
if (descriptor.template) {
|
||||
parts.push({
|
||||
type: descriptor.template.lang || 'html',
|
||||
value: descriptor.template.content.trim()
|
||||
});
|
||||
}
|
||||
|
||||
if (descriptor.styles) {
|
||||
var _iterator = _createForOfIteratorHelper(descriptor.styles),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let style = _step.value;
|
||||
parts.push({
|
||||
type: style.lang || 'css',
|
||||
value: style.content.trim(),
|
||||
modules: !!style.module
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
}
|
||||
|
||||
return parts;
|
||||
})();
|
||||
}
|
||||
|
||||
postProcess(generated) {
|
||||
var _this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let result = [];
|
||||
|
||||
let hasScoped = _this3.ast.styles.some(s => 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 = ''; // TODO: make it possible to process this code with the normal scope hoister
|
||||
|
||||
if (_this3.options.scopeHoist) {
|
||||
optsVar = `$${t.toIdentifier(_this3.id)}$export$default`;
|
||||
|
||||
if (!js.includes(optsVar)) {
|
||||
optsVar = `$${t.toIdentifier(_this3.id)}$exports`;
|
||||
|
||||
if (!js.includes(optsVar)) {
|
||||
supplemental += `
|
||||
var ${optsVar} = {};
|
||||
`;
|
||||
_this3.cacheData.isCommonJS = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
supplemental += `
|
||||
var ${optsVar} = exports.default || module.exports;
|
||||
`;
|
||||
}
|
||||
|
||||
supplemental += `
|
||||
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 && !_this3.options.scopeHoist) {
|
||||
let _minify = minify(supplemental, {
|
||||
toplevel: true
|
||||
}),
|
||||
code = _minify.code,
|
||||
error = _minify.error;
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
supplemental = code;
|
||||
|
||||
if (supplemental) {
|
||||
supplemental = `\n(function(){${supplemental}})();`;
|
||||
}
|
||||
}
|
||||
|
||||
js += supplemental;
|
||||
|
||||
if (js) {
|
||||
result.push({
|
||||
type: 'js',
|
||||
value: js,
|
||||
map: _this3.options.sourceMaps && _this3.ast.script && generated[0].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) {
|
||||
let _this$vue$compileStyl = this.vue.compileStyle({
|
||||
source: css,
|
||||
filename: this.relativeName,
|
||||
id: scopeId,
|
||||
scoped
|
||||
}),
|
||||
code = _this$vue$compileStyl.code,
|
||||
errors = _this$vue$compileStyl.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;
|
||||
65
BACK_BACK/node_modules/parcel-bundler/lib/assets/WebManifestAsset.js
generated
vendored
Executable file
65
BACK_BACK/node_modules/parcel-bundler/lib/assets/WebManifestAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
"use strict";
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
class WebManifestAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'webmanifest';
|
||||
}
|
||||
|
||||
parse(content) {
|
||||
return JSON.parse(content);
|
||||
}
|
||||
|
||||
collectDependencies() {
|
||||
if (Array.isArray(this.ast.icons)) {
|
||||
var _iterator = _createForOfIteratorHelper(this.ast.icons),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let icon = _step.value;
|
||||
icon.src = this.addURLDependency(icon.src);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(this.ast.screenshots)) {
|
||||
var _iterator2 = _createForOfIteratorHelper(this.ast.screenshots),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
let shot = _step2.value;
|
||||
shot.src = this.addURLDependency(shot.src);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
25
BACK_BACK/node_modules/parcel-bundler/lib/assets/YAMLAsset.js
generated
vendored
Executable file
25
BACK_BACK/node_modules/parcel-bundler/lib/assets/YAMLAsset.js
generated
vendored
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
"use strict";
|
||||
|
||||
const Asset = require('../Asset');
|
||||
|
||||
const yaml = require('js-yaml');
|
||||
|
||||
const serializeObject = require('../utils/serializeObject');
|
||||
|
||||
class YAMLAsset extends Asset {
|
||||
constructor(name, options) {
|
||||
super(name, options);
|
||||
this.type = 'js';
|
||||
}
|
||||
|
||||
parse(code) {
|
||||
return yaml.safeLoad(code);
|
||||
}
|
||||
|
||||
generate() {
|
||||
return serializeObject(this.ast, this.options.minify && !this.options.scopeHoist);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = YAMLAsset;
|
||||
13
BACK_BACK/node_modules/parcel-bundler/lib/builtins/.eslintrc.json
generated
vendored
Executable file
13
BACK_BACK/node_modules/parcel-bundler/lib/builtins/.eslintrc.json
generated
vendored
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"extends": "../.eslintrc.json",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 5
|
||||
},
|
||||
"env": {
|
||||
"browser": true
|
||||
},
|
||||
"rules": {
|
||||
"no-global-assign": 1,
|
||||
"no-unused-vars": 0
|
||||
}
|
||||
}
|
||||
0
BACK_BACK/node_modules/parcel-bundler/lib/builtins/_empty.js
generated
vendored
Executable file
0
BACK_BACK/node_modules/parcel-bundler/lib/builtins/_empty.js
generated
vendored
Executable file
83
BACK_BACK/node_modules/parcel-bundler/lib/builtins/bundle-loader.js
generated
vendored
Executable file
83
BACK_BACK/node_modules/parcel-bundler/lib/builtins/bundle-loader.js
generated
vendored
Executable 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.slice(0, -1))
|
||||
.then(function () {
|
||||
return require(id);
|
||||
})
|
||||
.then(resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
function loadBundles(bundles) {
|
||||
return Promise.all(bundles.map(loadBundle));
|
||||
}
|
||||
|
||||
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.register(id, resolved);
|
||||
}
|
||||
|
||||
return resolved;
|
||||
}).catch(function(e) {
|
||||
delete bundles[bundle];
|
||||
|
||||
throw e;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
};
|
||||
29
BACK_BACK/node_modules/parcel-bundler/lib/builtins/bundle-url.js
generated
vendored
Executable file
29
BACK_BACK/node_modules/parcel-bundler/lib/builtins/bundle-url.js
generated
vendored
Executable 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|chrome-extension|moz-extension):\/\/[^)\n]+/g);
|
||||
if (matches) {
|
||||
return getBaseURL(matches[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return '/';
|
||||
}
|
||||
|
||||
function getBaseURL(url) {
|
||||
return ('' + url).replace(/^((?:https?|file|ftp|chrome-extension|moz-extension):\/\/.+)?\/[^/]+(?:\?.*)?$/, '$1') + '/';
|
||||
}
|
||||
|
||||
exports.getBundleURL = getBundleURLCached;
|
||||
exports.getBaseURL = getBaseURL;
|
||||
30
BACK_BACK/node_modules/parcel-bundler/lib/builtins/css-loader.js
generated
vendored
Executable file
30
BACK_BACK/node_modules/parcel-bundler/lib/builtins/css-loader.js
generated
vendored
Executable 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;
|
||||
34
BACK_BACK/node_modules/parcel-bundler/lib/builtins/helpers.js
generated
vendored
Executable file
34
BACK_BACK/node_modules/parcel-bundler/lib/builtins/helpers.js
generated
vendored
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
function $parcel$interopDefault(a) {
|
||||
return a && a.__esModule
|
||||
? {d: a.default}
|
||||
: {d: a};
|
||||
}
|
||||
|
||||
function $parcel$defineInteropFlag(a) {
|
||||
Object.defineProperty(a, '__esModule', {value: true});
|
||||
}
|
||||
|
||||
function $parcel$exportWildcard(dest, source) {
|
||||
Object.keys(source).forEach(function(key) {
|
||||
if(key === "default" || key === "__esModule") {
|
||||
return;
|
||||
}
|
||||
|
||||
Object.defineProperty(dest, key, {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return source[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
function $parcel$missingModule(name) {
|
||||
var err = new Error("Cannot find module '" + name + "'");
|
||||
err.code = 'MODULE_NOT_FOUND';
|
||||
throw err;
|
||||
}
|
||||
|
||||
var $parcel$global = this;
|
||||
212
BACK_BACK/node_modules/parcel-bundler/lib/builtins/hmr-runtime.js
generated
vendored
Executable file
212
BACK_BACK/node_modules/parcel-bundler/lib/builtins/hmr-runtime.js
generated
vendored
Executable file
|
|
@ -0,0 +1,212 @@
|
|||
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 checkedAssets, assetsToAccept;
|
||||
|
||||
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) {
|
||||
checkedAssets = {};
|
||||
assetsToAccept = [];
|
||||
|
||||
var data = JSON.parse(event.data);
|
||||
|
||||
if (data.type === 'update') {
|
||||
var handled = false;
|
||||
data.assets.forEach(function(asset) {
|
||||
if (!asset.isNew) {
|
||||
var didAccept = hmrAcceptCheck(global.parcelRequire, asset.id);
|
||||
if (didAccept) {
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Enable HMR for CSS by default.
|
||||
handled = handled || data.assets.every(function(asset) {
|
||||
return asset.type === 'css' && asset.generated.js;
|
||||
});
|
||||
|
||||
if (handled) {
|
||||
console.clear();
|
||||
|
||||
data.assets.forEach(function (asset) {
|
||||
hmrApply(global.parcelRequire, asset);
|
||||
});
|
||||
|
||||
assetsToAccept.forEach(function (v) {
|
||||
hmrAcceptRun(v[0], v[1]);
|
||||
});
|
||||
} else if (location.reload) { // `location` global exists in a web worker context but lacks `.reload()` function.
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
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 hmrAcceptCheck(bundle, id) {
|
||||
var modules = bundle.modules;
|
||||
if (!modules) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!modules[id] && bundle.parent) {
|
||||
return hmrAcceptCheck(bundle.parent, id);
|
||||
}
|
||||
|
||||
if (checkedAssets[id]) {
|
||||
return;
|
||||
}
|
||||
checkedAssets[id] = true;
|
||||
|
||||
var cached = bundle.cache[id];
|
||||
|
||||
assetsToAccept.push([bundle, id]);
|
||||
|
||||
if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return getParents(global.parcelRequire, id).some(function (id) {
|
||||
return hmrAcceptCheck(global.parcelRequire, id)
|
||||
});
|
||||
}
|
||||
|
||||
function hmrAcceptRun(bundle, 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;
|
||||
}
|
||||
}
|
||||
13
BACK_BACK/node_modules/parcel-bundler/lib/builtins/index.js
generated
vendored
Executable file
13
BACK_BACK/node_modules/parcel-bundler/lib/builtins/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
var nodeBuiltins = require('node-libs-browser');
|
||||
|
||||
var builtins = Object.create(null);
|
||||
for (var key in nodeBuiltins) {
|
||||
builtins[key] = nodeBuiltins[key] == null
|
||||
? require.resolve('./_empty.js')
|
||||
: nodeBuiltins[key];
|
||||
}
|
||||
|
||||
builtins['_bundle_loader'] = require.resolve('./bundle-loader.js');
|
||||
builtins['_css_loader'] = require.resolve('./css-loader.js');
|
||||
|
||||
module.exports = builtins;
|
||||
18
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/browser/css-loader.js
generated
vendored
Executable file
18
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/browser/css-loader.js
generated
vendored
Executable 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);
|
||||
});
|
||||
};
|
||||
5
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/browser/html-loader.js
generated
vendored
Executable file
5
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/browser/html-loader.js
generated
vendored
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = function loadHTMLBundle(bundle) {
|
||||
return fetch(bundle).then(function (res) {
|
||||
return res.text();
|
||||
});
|
||||
};
|
||||
20
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/browser/js-loader.js
generated
vendored
Executable file
20
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/browser/js-loader.js
generated
vendored
Executable 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);
|
||||
});
|
||||
};
|
||||
16
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/browser/wasm-loader.js
generated
vendored
Executable file
16
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/browser/wasm-loader.js
generated
vendored
Executable 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;
|
||||
});
|
||||
};
|
||||
4
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/node/css-loader.js
generated
vendored
Executable file
4
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/node/css-loader.js
generated
vendored
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
// loading a CSS style is a no-op in Node.js
|
||||
module.exports = function loadCSSBundle() {
|
||||
return Promise.resolve();
|
||||
};
|
||||
17
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/node/html-loader.js
generated
vendored
Executable file
17
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/node/html-loader.js
generated
vendored
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
var fs = require('fs');
|
||||
|
||||
module.exports = function loadHTMLBundle(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);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
20
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/node/js-loader.js
generated
vendored
Executable file
20
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/node/js-loader.js
generated
vendored
Executable 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)();
|
||||
});
|
||||
};
|
||||
19
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/node/wasm-loader.js
generated
vendored
Executable file
19
BACK_BACK/node_modules/parcel-bundler/lib/builtins/loaders/node/wasm-loader.js
generated
vendored
Executable 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;
|
||||
});
|
||||
};
|
||||
120
BACK_BACK/node_modules/parcel-bundler/lib/builtins/prelude.js
generated
vendored
Executable file
120
BACK_BACK/node_modules/parcel-bundler/lib/builtins/prelude.js
generated
vendored
Executable file
|
|
@ -0,0 +1,120 @@
|
|||
// 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
|
||||
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;
|
||||
localRequire.cache = {};
|
||||
|
||||
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;
|
||||
newRequire.register = function (id, exports) {
|
||||
modules[id] = [function (require, module) {
|
||||
module.exports = exports;
|
||||
}, {}];
|
||||
};
|
||||
|
||||
var error;
|
||||
for (var i = 0; i < entry.length; i++) {
|
||||
try {
|
||||
newRequire(entry[i]);
|
||||
} catch (e) {
|
||||
// Save first error but execute all entries
|
||||
if (!error) {
|
||||
error = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
parcelRequire = newRequire;
|
||||
|
||||
if (error) {
|
||||
// throw error from earlier, _after updating parcelRequire_
|
||||
throw error;
|
||||
}
|
||||
|
||||
return newRequire;
|
||||
})
|
||||
1
BACK_BACK/node_modules/parcel-bundler/lib/builtins/prelude.min.js
generated
vendored
Executable file
1
BACK_BACK/node_modules/parcel-bundler/lib/builtins/prelude.min.js
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f};
|
||||
45
BACK_BACK/node_modules/parcel-bundler/lib/builtins/prelude2.js
generated
vendored
Executable file
45
BACK_BACK/node_modules/parcel-bundler/lib/builtins/prelude2.js
generated
vendored
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
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 (name in modules) {
|
||||
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;
|
||||
}
|
||||
|
||||
localRequire.register = function register(id, exports) {
|
||||
modules[id] = exports;
|
||||
};
|
||||
|
||||
modules = init(localRequire);
|
||||
localRequire.modules = modules;
|
||||
return localRequire;
|
||||
})
|
||||
1
BACK_BACK/node_modules/parcel-bundler/lib/builtins/prelude2.min.js
generated
vendored
Executable file
1
BACK_BACK/node_modules/parcel-bundler/lib/builtins/prelude2.min.js
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
parcelRequire=function(e){var r="function"==typeof parcelRequire&&parcelRequire,n="function"==typeof require&&require,i={};function u(e,u){if(e in i)return i[e];var t="function"==typeof parcelRequire&&parcelRequire;if(!u&&t)return t(e,!0);if(r)return r(e,!0);if(n&&"string"==typeof e)return n(e);var o=new Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}return u.register=function(e,r){i[e]=r},i=e(u),u.modules=i,u};
|
||||
94
BACK_BACK/node_modules/parcel-bundler/lib/cli.js
generated
vendored
Executable file
94
BACK_BACK/node_modules/parcel-bundler/lib/cli.js
generated
vendored
Executable file
|
|
@ -0,0 +1,94 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
require('v8-compile-cache');
|
||||
|
||||
const chalk = require('chalk');
|
||||
|
||||
const envinfo = require('envinfo');
|
||||
|
||||
const program = require('commander');
|
||||
|
||||
const version = require('../package.json').version;
|
||||
|
||||
program.version(version).usage('<command> [options]');
|
||||
program.command('serve [input...]').description('starts a development server').option('-p, --port <port>', 'set the port to serve on. defaults to 1234', parseInt).option('--host <host>', 'set the host to listen on, defaults to listening on all interfaces').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 "/"').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('--bundle-node-modules', 'force bundling node modules, even on node/electron target').option('-V, --version', 'output the version number').option('--log-level <level>', 'set the log level, either "0" (no output), "1" (errors), "2" (warnings), "3" (info), "4" (verbose) or "5" (debug, creates a log file).', /^([0-5])$/).option('--cache-dir <path>', 'set the cache directory. defaults to ".cache"').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 "/"').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('--https', 'listen on HTTPS for HMR connections').option('--cert <path>', 'path to certificate to use with HTTPS').option('--key <path>', 'path to private key to use with HTTPS').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('--bundle-node-modules', 'force bundling node modules, even on node/electron target').option('--log-level <level>', 'set the log level, either "0" (no output), "1" (errors), "2" (warnings), "3" (info), "4" (verbose) or "5" (debug, creates a log file).', /^([0-5])$/).option('--cache-dir <path>', 'set the cache directory. defaults to ".cache"').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 "/"').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('--no-autoinstall', 'disable autoinstall').option('--no-content-hash', 'disable content hashing').option('--experimental-scope-hoisting', 'enable experimental scope hoisting/tree shaking support').option('-t, --target <target>', 'set the runtime environment, either "node", "browser" or "electron". defaults to "browser"', /^(node|browser|electron)$/).option('--bundle-node-modules', 'force bundling node modules, even on node/electron target').option('--detailed-report [depth]', 'print a detailed build report after a completed build. If enabled, defaults to depth "10"', /^([0-9]+|all)$/).option('--log-level <level>', 'set the log level, either "0" (no output), "1" (errors), "2" (warnings), "3" (info), "4" (verbose) or "5" (debug, creates a log file).', /^([0-5])$/).option('--cache-dir <path>', 'set the cache directory. defaults to ".cache"').action(bundle);
|
||||
program.command('info').description('Prints debugging information about the local environment').action(function () {
|
||||
console.log(chalk.bold('\nEnvironment Info:'));
|
||||
envinfo.run({
|
||||
System: ['OS', 'CPU'],
|
||||
Binaries: ['Node', 'Yarn', 'npm'],
|
||||
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
|
||||
npmPackages: ['parcel-bundler'],
|
||||
npmGlobalPackages: ['parcel-bundler']
|
||||
}).then(console.log);
|
||||
});
|
||||
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);
|
||||
|
||||
function bundle(_x, _x2) {
|
||||
return _bundle.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _bundle() {
|
||||
_bundle = (0, _asyncToGenerator2.default)(function* (main, command) {
|
||||
// Require bundler here so the help command is fast
|
||||
const Bundler = require('../');
|
||||
|
||||
if (command.name() === 'watch') {
|
||||
command.watch = true;
|
||||
}
|
||||
|
||||
if (command.name() === 'build') {
|
||||
command.production = true;
|
||||
process.env.NODE_ENV = 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
|
||||
};
|
||||
}
|
||||
|
||||
command.throwErrors = false;
|
||||
command.scopeHoist = command.experimentalScopeHoisting || false;
|
||||
const bundler = new Bundler(main, command);
|
||||
command.target = command.target || 'browser';
|
||||
|
||||
if (command.name() === 'serve' && command.target === 'browser') {
|
||||
const port = command.port || process.env.PORT || 1234;
|
||||
const server = yield bundler.serve(port, command.https, command.host);
|
||||
|
||||
if (server && command.open) {
|
||||
yield require('./utils/openInBrowser')(`${command.https ? 'https' : 'http'}://${command.host || 'localhost'}:${server.address().port}`, command.open);
|
||||
}
|
||||
} else {
|
||||
bundler.bundle();
|
||||
}
|
||||
});
|
||||
return _bundle.apply(this, arguments);
|
||||
}
|
||||
119
BACK_BACK/node_modules/parcel-bundler/lib/packagers/CSSPackager.js
generated
vendored
Executable file
119
BACK_BACK/node_modules/parcel-bundler/lib/packagers/CSSPackager.js
generated
vendored
Executable file
|
|
@ -0,0 +1,119 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const Packager = require('./Packager');
|
||||
|
||||
const lineCounter = require('../utils/lineCounter');
|
||||
|
||||
const urlJoin = require('../utils/urlJoin');
|
||||
|
||||
class CSSPackager extends Packager {
|
||||
start() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
_this.lineOffset = 0;
|
||||
_this.columnOffset = 0;
|
||||
})();
|
||||
}
|
||||
|
||||
addAsset(asset) {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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 _iterator = _createForOfIteratorHelper(asset.parentDeps),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
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) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
if (media.length) {
|
||||
css = `@media ${media.join(', ')} {\n${css.trim()}\n}\n`;
|
||||
}
|
||||
|
||||
if (asset.options.sourceMaps) {
|
||||
let lineCount = lineCounter(css);
|
||||
|
||||
if (lineCount == 1) {
|
||||
_this2.bundle.addOffset(asset, _this2.lineOffset, _this2.columnOffset);
|
||||
|
||||
yield _this2.write(css);
|
||||
_this2.columnOffset += css.length;
|
||||
} else {
|
||||
const lines = css.split('\n');
|
||||
|
||||
if (_this2.columnOffset == 0) {
|
||||
_this2.bundle.addOffset(asset, _this2.lineOffset, 0);
|
||||
|
||||
yield _this2.write(css + '\n');
|
||||
} else {
|
||||
_this2.columnOffset = 0;
|
||||
|
||||
_this2.bundle.addOffset(asset, _this2.lineOffset + 1, 0);
|
||||
|
||||
_this2.columnOffset = lines[lines.length - 1].length;
|
||||
yield _this2.write('\n' + css);
|
||||
}
|
||||
|
||||
_this2.lineOffset += lineCount;
|
||||
}
|
||||
} else {
|
||||
yield _this2.write(css);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
end() {
|
||||
var _superprop_getEnd = () => super.end,
|
||||
_this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (_this3.options.sourceMaps) {
|
||||
// Add source map url if a map bundle exists
|
||||
let mapBundle = _this3.bundle.siblingBundlesMap.get('map');
|
||||
|
||||
if (mapBundle) {
|
||||
let mapUrl = urlJoin(_this3.options.publicURL, path.basename(mapBundle.name));
|
||||
yield _this3.write(`\n/*# sourceMappingURL=${mapUrl} */`);
|
||||
}
|
||||
}
|
||||
|
||||
yield _superprop_getEnd().call(_this3);
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = CSSPackager;
|
||||
125
BACK_BACK/node_modules/parcel-bundler/lib/packagers/HTMLPackager.js
generated
vendored
Executable file
125
BACK_BACK/node_modules/parcel-bundler/lib/packagers/HTMLPackager.js
generated
vendored
Executable file
|
|
@ -0,0 +1,125 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
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 {
|
||||
static shouldAddAsset() {
|
||||
// We cannot combine multiple HTML files together - they should be written as separate bundles.
|
||||
return false;
|
||||
}
|
||||
|
||||
addAsset(asset) {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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((p, b) => p.concat([...b.siblingBundles.values()]), []).filter(b => 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 _iterator = _createForOfIteratorHelper(siblingBundles),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
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) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
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;
|
||||
752
BACK_BACK/node_modules/parcel-bundler/lib/packagers/JSConcatPackager.js
generated
vendored
Executable file
752
BACK_BACK/node_modules/parcel-bundler/lib/packagers/JSConcatPackager.js
generated
vendored
Executable file
|
|
@ -0,0 +1,752 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const Packager = require('./Packager');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const concat = require('../scope-hoisting/concat');
|
||||
|
||||
const urlJoin = require('../utils/urlJoin');
|
||||
|
||||
const getExisting = require('../utils/getExisting');
|
||||
|
||||
const walk = require('babylon-walk');
|
||||
|
||||
const babylon = require('@babel/parser');
|
||||
|
||||
const t = require('@babel/types');
|
||||
|
||||
const _require = require('../scope-hoisting/utils'),
|
||||
getName = _require.getName,
|
||||
getIdentifier = _require.getIdentifier;
|
||||
|
||||
const prelude = getExisting(path.join(__dirname, '../builtins/prelude2.min.js'), path.join(__dirname, '../builtins/prelude2.js'));
|
||||
const helpers = getExisting(path.join(__dirname, '../builtins/helpers.min.js'), path.join(__dirname, '../builtins/helpers.js'));
|
||||
|
||||
class JSConcatPackager extends Packager {
|
||||
start() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
_this.addedAssets = new Set();
|
||||
_this.assets = new Map();
|
||||
_this.exposedModules = new Set();
|
||||
_this.externalModules = new Set();
|
||||
_this.size = 0;
|
||||
_this.needsPrelude = false;
|
||||
_this.statements = [];
|
||||
_this.assetPostludes = new Map();
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(_this.bundle.assets),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let asset = _step.value;
|
||||
// If this module is referenced by another JS bundle, it needs to be exposed externally.
|
||||
let isExposed = !Array.from(asset.parentDeps).every(dep => {
|
||||
let depAsset = _this.bundler.loadedAssets.get(dep.parent);
|
||||
|
||||
return _this.bundle.assets.has(depAsset) || depAsset.type !== 'js';
|
||||
});
|
||||
|
||||
if (isExposed || _this.bundle.entryAsset === asset && _this.bundle.parentBundle && _this.bundle.parentBundle.childBundles.size !== 1) {
|
||||
_this.exposedModules.add(asset);
|
||||
|
||||
_this.needsPrelude = true;
|
||||
}
|
||||
|
||||
_this.assets.set(asset.id, asset);
|
||||
|
||||
var _iterator2 = _createForOfIteratorHelper(asset.depAssets.values()),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
let mod = _step2.value;
|
||||
|
||||
if (!_this.bundle.assets.has(mod) && _this.options.bundleLoaders[asset.type]) {
|
||||
_this.needsPrelude = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
if (_this.bundle.entryAsset) {
|
||||
_this.markUsedExports(_this.bundle.entryAsset);
|
||||
}
|
||||
|
||||
if (_this.needsPrelude) {
|
||||
if (_this.bundle.entryAsset && _this.options.bundleLoaders[_this.bundle.entryAsset.type]) {
|
||||
_this.exposedModules.add(_this.bundle.entryAsset);
|
||||
}
|
||||
}
|
||||
|
||||
_this.write(helpers.minified);
|
||||
})();
|
||||
}
|
||||
|
||||
write(string) {
|
||||
this.statements.push(...this.parse(string));
|
||||
}
|
||||
|
||||
getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
markUsedExports(asset) {
|
||||
if (asset.usedExports) {
|
||||
return;
|
||||
}
|
||||
|
||||
asset.usedExports = new Set();
|
||||
|
||||
for (let identifier in asset.cacheData.imports) {
|
||||
let _asset$cacheData$impo = (0, _slicedToArray2.default)(asset.cacheData.imports[identifier], 2),
|
||||
source = _asset$cacheData$impo[0],
|
||||
name = _asset$cacheData$impo[1];
|
||||
|
||||
let dep = asset.depAssets.get(asset.dependencies.get(source));
|
||||
|
||||
if (dep) {
|
||||
if (name === '*') {
|
||||
this.markUsedExports(dep);
|
||||
}
|
||||
|
||||
this.markUsed(dep, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
markUsed(mod, name) {
|
||||
let _this$findExportModul = this.findExportModule(mod.id, name),
|
||||
id = _this$findExportModul.id;
|
||||
|
||||
mod = this.assets.get(id);
|
||||
|
||||
if (!mod) {
|
||||
return;
|
||||
}
|
||||
|
||||
let exp = mod.cacheData.exports[name];
|
||||
|
||||
if (Array.isArray(exp)) {
|
||||
let depMod = mod.depAssets.get(mod.dependencies.get(exp[0]));
|
||||
return this.markUsed(depMod, exp[1]);
|
||||
}
|
||||
|
||||
this.markUsedExports(mod);
|
||||
mod.usedExports.add(name);
|
||||
}
|
||||
|
||||
getExportIdentifier(asset) {
|
||||
let id = getName(asset, 'exports');
|
||||
|
||||
if (this.shouldWrap(asset)) {
|
||||
return `(${getName(asset, 'init')}(), ${id})`;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
addAsset(asset) {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (_this2.addedAssets.has(asset)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_this2.addedAssets.add(asset);
|
||||
|
||||
let js = asset.generated.js; // If the asset has no side effects according to the its package's sideEffects flag,
|
||||
// and there are no used exports marked, exclude the asset from the bundle.
|
||||
|
||||
if (asset.cacheData.sideEffects === false && (!asset.usedExports || asset.usedExports.size === 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var _iterator3 = _createForOfIteratorHelper(asset.depAssets),
|
||||
_step3;
|
||||
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
let _step3$value = (0, _slicedToArray2.default)(_step3.value, 2),
|
||||
dep = _step3$value[0],
|
||||
mod = _step3$value[1];
|
||||
|
||||
if (dep.dynamic) {
|
||||
var _iterator4 = _createForOfIteratorHelper(mod.parentBundle.siblingBundles),
|
||||
_step4;
|
||||
|
||||
try {
|
||||
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
||||
let child = _step4.value;
|
||||
|
||||
if (!child.isEmpty) {
|
||||
yield _this2.addBundleLoader(child.type, asset);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator4.e(err);
|
||||
} finally {
|
||||
_iterator4.f();
|
||||
}
|
||||
|
||||
yield _this2.addBundleLoader(mod.type, asset, true);
|
||||
} else {
|
||||
// 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.options.bundleLoaders[mod.type]) {
|
||||
_this2.externalModules.add(mod);
|
||||
|
||||
yield _this2.addBundleLoader(mod.type, asset);
|
||||
}
|
||||
}
|
||||
} // if (this.bundle.entryAsset === asset && this.externalModules.size > 0) {
|
||||
// js = `
|
||||
// function $parcel$entry() {
|
||||
// ${js.trim()}
|
||||
// }
|
||||
// `;
|
||||
// }
|
||||
// js = js.trim() + '\n';
|
||||
|
||||
} catch (err) {
|
||||
_iterator3.e(err);
|
||||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
|
||||
_this2.size += js.length;
|
||||
})();
|
||||
}
|
||||
|
||||
shouldWrap(asset) {
|
||||
if (!asset) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (asset.cacheData.shouldWrap != null) {
|
||||
return asset.cacheData.shouldWrap;
|
||||
} // Set to false initially so circular deps work
|
||||
|
||||
|
||||
asset.cacheData.shouldWrap = false; // We need to wrap if any of the deps are marked by the hoister, e.g.
|
||||
// when the dep is required inside a function or conditional.
|
||||
// We also need to wrap if any of the parents are wrapped - transitive requires
|
||||
// shouldn't be evaluated until their parents are.
|
||||
|
||||
let shouldWrap = [...asset.parentDeps].some(dep => dep.shouldWrap || this.shouldWrap(this.bundler.loadedAssets.get(dep.parent)));
|
||||
asset.cacheData.shouldWrap = shouldWrap;
|
||||
return shouldWrap;
|
||||
}
|
||||
|
||||
addDeps(asset, included) {
|
||||
if (!this.bundle.assets.has(asset) || included.has(asset)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
included.add(asset);
|
||||
let depAsts = new Map();
|
||||
|
||||
var _iterator5 = _createForOfIteratorHelper(asset.depAssets.values()),
|
||||
_step5;
|
||||
|
||||
try {
|
||||
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
||||
let depAsset = _step5.value;
|
||||
|
||||
if (!depAsts.has(depAsset)) {
|
||||
let depAst = this.addDeps(depAsset, included);
|
||||
depAsts.set(depAsset, depAst);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator5.e(err);
|
||||
} finally {
|
||||
_iterator5.f();
|
||||
}
|
||||
|
||||
let statements;
|
||||
|
||||
if (asset.cacheData.sideEffects === false && (!asset.usedExports || asset.usedExports.size === 0)) {
|
||||
statements = [];
|
||||
} else {
|
||||
statements = this.parse(asset.generated.js, asset.name);
|
||||
}
|
||||
|
||||
if (this.shouldWrap(asset)) {
|
||||
statements = this.wrapModule(asset, statements);
|
||||
}
|
||||
|
||||
if (statements[0]) {
|
||||
if (!statements[0].leadingComments) {
|
||||
statements[0].leadingComments = [];
|
||||
}
|
||||
|
||||
statements[0].leadingComments.push({
|
||||
type: 'CommentLine',
|
||||
value: ` ASSET: ${path.relative(this.options.rootDir, asset.name)}`
|
||||
});
|
||||
}
|
||||
|
||||
let statementIndices = new Map();
|
||||
|
||||
for (let i = 0; i < statements.length; i++) {
|
||||
let statement = statements[i];
|
||||
|
||||
if (t.isExpressionStatement(statement)) {
|
||||
var _iterator6 = _createForOfIteratorHelper(this.findRequires(asset, statement)),
|
||||
_step6;
|
||||
|
||||
try {
|
||||
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
||||
let depAsset = _step6.value;
|
||||
|
||||
if (!statementIndices.has(depAsset)) {
|
||||
statementIndices.set(depAsset, i);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator6.e(err);
|
||||
} finally {
|
||||
_iterator6.f();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let reverseDeps = [...asset.depAssets.values()].reverse();
|
||||
|
||||
var _iterator7 = _createForOfIteratorHelper(reverseDeps),
|
||||
_step7;
|
||||
|
||||
try {
|
||||
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
||||
let dep = _step7.value;
|
||||
let index = statementIndices.has(dep) ? statementIndices.get(dep) : 0;
|
||||
statements.splice(index, 0, ...depAsts.get(dep));
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator7.e(err);
|
||||
} finally {
|
||||
_iterator7.f();
|
||||
}
|
||||
|
||||
if (this.assetPostludes.has(asset)) {
|
||||
statements.push(...this.parse(this.assetPostludes.get(asset)));
|
||||
}
|
||||
|
||||
return statements;
|
||||
}
|
||||
|
||||
wrapModule(asset, statements) {
|
||||
let body = [];
|
||||
let decls = [];
|
||||
let fns = [];
|
||||
|
||||
var _iterator8 = _createForOfIteratorHelper(statements),
|
||||
_step8;
|
||||
|
||||
try {
|
||||
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
||||
let node = _step8.value;
|
||||
|
||||
// Hoist all declarations out of the function wrapper
|
||||
// so that they can be referenced by other modules directly.
|
||||
if (t.isVariableDeclaration(node)) {
|
||||
var _iterator9 = _createForOfIteratorHelper(node.declarations),
|
||||
_step9;
|
||||
|
||||
try {
|
||||
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
||||
let decl = _step9.value;
|
||||
|
||||
if (t.isObjectPattern(decl.id) || t.isArrayPattern(decl.id)) {
|
||||
for (var _i = 0, _Object$values = Object.values(t.getBindingIdentifiers(decl.id)); _i < _Object$values.length; _i++) {
|
||||
let prop = _Object$values[_i];
|
||||
decls.push(t.variableDeclarator(prop));
|
||||
}
|
||||
|
||||
if (decl.init) {
|
||||
body.push(t.expressionStatement(t.assignmentExpression('=', decl.id, decl.init)));
|
||||
}
|
||||
} else {
|
||||
decls.push(t.variableDeclarator(decl.id));
|
||||
|
||||
if (decl.init) {
|
||||
body.push(t.expressionStatement(t.assignmentExpression('=', t.identifier(decl.id.name), decl.init)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator9.e(err);
|
||||
} finally {
|
||||
_iterator9.f();
|
||||
}
|
||||
} else if (t.isFunctionDeclaration(node)) {
|
||||
// Function declarations can be hoisted out of the module initialization function
|
||||
fns.push(node);
|
||||
} else if (t.isClassDeclaration(node)) {
|
||||
// Class declarations are not hoisted. We declare a variable outside the
|
||||
// function convert to a class expression assignment.
|
||||
decls.push(t.variableDeclarator(t.identifier(node.id.name)));
|
||||
body.push(t.expressionStatement(t.assignmentExpression('=', t.identifier(node.id.name), t.toExpression(node))));
|
||||
} else {
|
||||
body.push(node);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator8.e(err);
|
||||
} finally {
|
||||
_iterator8.f();
|
||||
}
|
||||
|
||||
let executed = getName(asset, 'executed');
|
||||
decls.push(t.variableDeclarator(t.identifier(executed), t.booleanLiteral(false)));
|
||||
let init = t.functionDeclaration(getIdentifier(asset, 'init'), [], t.blockStatement([t.ifStatement(t.identifier(executed), t.returnStatement()), t.expressionStatement(t.assignmentExpression('=', t.identifier(executed), t.booleanLiteral(true))), ...body]));
|
||||
return [t.variableDeclaration('var', decls), ...fns, init];
|
||||
}
|
||||
|
||||
parse(code, filename) {
|
||||
let ast = babylon.parse(code, {
|
||||
sourceFilename: filename,
|
||||
allowReturnOutsideFunction: true
|
||||
});
|
||||
return ast.program.body;
|
||||
}
|
||||
|
||||
findRequires(asset, ast) {
|
||||
let result = [];
|
||||
walk.simple(ast, {
|
||||
CallExpression(node) {
|
||||
let args = node.arguments,
|
||||
callee = node.callee;
|
||||
|
||||
if (!t.isIdentifier(callee)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (callee.name === '$parcel$require') {
|
||||
result.push(asset.depAssets.get(asset.dependencies.get(args[1].value)));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
getBundleSpecifier(bundle) {
|
||||
let name = path.relative(path.dirname(this.bundle.name), bundle.name);
|
||||
|
||||
if (bundle.entryAsset) {
|
||||
return [name, bundle.entryAsset.id];
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
addAssetToBundle(asset) {
|
||||
var _this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
if (_this3.bundle.assets.has(asset)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_this3.assets.set(asset.id, asset);
|
||||
|
||||
_this3.bundle.addAsset(asset);
|
||||
|
||||
if (!asset.parentBundle) {
|
||||
asset.parentBundle = _this3.bundle;
|
||||
} // Add all dependencies as well
|
||||
|
||||
|
||||
var _iterator10 = _createForOfIteratorHelper(asset.depAssets.values()),
|
||||
_step10;
|
||||
|
||||
try {
|
||||
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
||||
let child = _step10.value;
|
||||
yield _this3.addAssetToBundle(child, _this3.bundle);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator10.e(err);
|
||||
} finally {
|
||||
_iterator10.f();
|
||||
}
|
||||
|
||||
yield _this3.addAsset(asset);
|
||||
})();
|
||||
}
|
||||
|
||||
addBundleLoader(bundleType, parentAsset, dynamic) {
|
||||
var _this4 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let loader = _this4.options.bundleLoaders[bundleType];
|
||||
|
||||
if (!loader) {
|
||||
return;
|
||||
}
|
||||
|
||||
let bundleLoader = _this4.bundler.loadedAssets.get(require.resolve('../builtins/bundle-loader'));
|
||||
|
||||
if (!bundleLoader && !dynamic) {
|
||||
bundleLoader = yield _this4.bundler.getAsset('_bundle_loader');
|
||||
}
|
||||
|
||||
if (bundleLoader) {
|
||||
// parentAsset.depAssets.set({name: '_bundle_loader'}, bundleLoader);
|
||||
yield _this4.addAssetToBundle(bundleLoader);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
let target = _this4.options.target === 'node' ? 'node' : 'browser';
|
||||
let asset = yield _this4.bundler.getAsset(loader[target]);
|
||||
|
||||
if (!_this4.bundle.assets.has(asset)) {
|
||||
let dep = {
|
||||
name: asset.name
|
||||
};
|
||||
asset.parentDeps.add(dep);
|
||||
parentAsset.dependencies.set(dep.name, dep);
|
||||
parentAsset.depAssets.set(dep, asset);
|
||||
|
||||
_this4.assetPostludes.set(asset, `${_this4.getExportIdentifier(bundleLoader)}.register(${JSON.stringify(bundleType)},${_this4.getExportIdentifier(asset)});\n`);
|
||||
|
||||
yield _this4.addAssetToBundle(asset);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
end() {
|
||||
var _superprop_getWrite = () => super.write,
|
||||
_superprop_getEnd = () => super.end,
|
||||
_this5 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let included = new Set();
|
||||
|
||||
var _iterator11 = _createForOfIteratorHelper(_this5.bundle.assets),
|
||||
_step11;
|
||||
|
||||
try {
|
||||
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
||||
let asset = _step11.value;
|
||||
|
||||
_this5.statements.push(..._this5.addDeps(asset, included));
|
||||
} // Preload external modules before running entry point if needed
|
||||
|
||||
} catch (err) {
|
||||
_iterator11.e(err);
|
||||
} finally {
|
||||
_iterator11.f();
|
||||
}
|
||||
|
||||
if (_this5.externalModules.size > 0) {
|
||||
let bundleLoader = _this5.bundler.loadedAssets.get(require.resolve('../builtins/bundle-loader'));
|
||||
|
||||
let preload = [];
|
||||
|
||||
var _iterator12 = _createForOfIteratorHelper(_this5.externalModules),
|
||||
_step12;
|
||||
|
||||
try {
|
||||
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
||||
let mod = _step12.value;
|
||||
// Find the bundle that has the module as its entry point
|
||||
let bundle = Array.from(mod.bundles).find(b => b.entryAsset === mod);
|
||||
|
||||
if (bundle) {
|
||||
preload.push([path.basename(bundle.name), mod.id]);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator12.e(err);
|
||||
} finally {
|
||||
_iterator12.f();
|
||||
}
|
||||
|
||||
let loads = `${_this5.getExportIdentifier(bundleLoader)}.load(${JSON.stringify(preload)})`;
|
||||
|
||||
if (_this5.bundle.entryAsset) {
|
||||
loads += '.then($parcel$entry)';
|
||||
}
|
||||
|
||||
loads += ';';
|
||||
|
||||
_this5.write(loads);
|
||||
}
|
||||
|
||||
let entryExports = _this5.bundle.entryAsset && _this5.getExportIdentifier(_this5.bundle.entryAsset);
|
||||
|
||||
if (entryExports && _this5.bundle.entryAsset.generated.js.includes(entryExports)) {
|
||||
_this5.write(`
|
||||
if (typeof exports === "object" && typeof module !== "undefined") {
|
||||
// CommonJS
|
||||
module.exports = ${entryExports};
|
||||
} else if (typeof define === "function" && define.amd) {
|
||||
// RequireJS
|
||||
define(function () {
|
||||
return ${entryExports};
|
||||
});
|
||||
} ${_this5.options.global ? `else {
|
||||
// <script>
|
||||
this[${JSON.stringify(_this5.options.global)}] = ${entryExports};
|
||||
}` : ''}
|
||||
`);
|
||||
}
|
||||
|
||||
if (_this5.needsPrelude) {
|
||||
let exposed = [];
|
||||
let prepareModule = [];
|
||||
|
||||
var _iterator13 = _createForOfIteratorHelper(_this5.exposedModules),
|
||||
_step13;
|
||||
|
||||
try {
|
||||
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
||||
let m = _step13.value;
|
||||
|
||||
if (m.cacheData.isES6Module) {
|
||||
prepareModule.push(`${_this5.getExportIdentifier(m)}.__esModule = true;`);
|
||||
}
|
||||
|
||||
exposed.push(`"${m.id}": ${_this5.getExportIdentifier(m)}`);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator13.e(err);
|
||||
} finally {
|
||||
_iterator13.f();
|
||||
}
|
||||
|
||||
_this5.write(`
|
||||
${prepareModule.join('\n')}
|
||||
return {${exposed.join(', ')}};
|
||||
`);
|
||||
}
|
||||
|
||||
try {
|
||||
let ast = t.file(t.program(_this5.statements));
|
||||
|
||||
let _concat = concat(_this5, ast),
|
||||
output = _concat.code;
|
||||
|
||||
if (!_this5.options.minify) {
|
||||
output = '\n' + output + '\n';
|
||||
}
|
||||
|
||||
let preludeCode = _this5.options.minify ? prelude.minified : prelude.source;
|
||||
|
||||
if (_this5.needsPrelude) {
|
||||
output = preludeCode + '(function (require) {' + output + '});';
|
||||
} else {
|
||||
output = '(function () {' + output + '})();';
|
||||
}
|
||||
|
||||
_this5.size = output.length;
|
||||
let sourceMaps = _this5.options.sourceMaps;
|
||||
|
||||
if (sourceMaps) {
|
||||
// Add source map url if a map bundle exists
|
||||
let mapBundle = _this5.bundle.siblingBundlesMap.get('map');
|
||||
|
||||
if (mapBundle) {
|
||||
let mapUrl = urlJoin(_this5.options.publicURL, path.basename(mapBundle.name));
|
||||
output += `\n//# sourceMappingURL=${mapUrl}`;
|
||||
}
|
||||
}
|
||||
|
||||
yield _superprop_getWrite().call(_this5, output);
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} finally {
|
||||
yield _superprop_getEnd().call(_this5);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
resolveModule(id, name) {
|
||||
let module = this.assets.get(id);
|
||||
return module.depAssets.get(module.dependencies.get(name));
|
||||
}
|
||||
|
||||
findExportModule(id, name, replacements) {
|
||||
let asset = this.assets.get(id);
|
||||
let exp = asset && Object.prototype.hasOwnProperty.call(asset.cacheData.exports, name) ? asset.cacheData.exports[name] : null; // If this is a re-export, find the original module.
|
||||
|
||||
if (Array.isArray(exp)) {
|
||||
let mod = this.resolveModule(id, exp[0]);
|
||||
return this.findExportModule(mod.id, exp[1], replacements);
|
||||
} // If this module exports wildcards, resolve the original module.
|
||||
// Default exports are excluded from wildcard exports.
|
||||
|
||||
|
||||
let wildcards = asset && asset.cacheData.wildcards;
|
||||
|
||||
if (wildcards && name !== 'default' && name !== '*') {
|
||||
var _iterator14 = _createForOfIteratorHelper(wildcards),
|
||||
_step14;
|
||||
|
||||
try {
|
||||
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
||||
let source = _step14.value;
|
||||
let mod = this.resolveModule(id, source);
|
||||
let m = this.findExportModule(mod.id, name, replacements);
|
||||
|
||||
if (m.identifier) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator14.e(err);
|
||||
} finally {
|
||||
_iterator14.f();
|
||||
}
|
||||
} // If this is a wildcard import, resolve to the exports object.
|
||||
|
||||
|
||||
if (asset && name === '*') {
|
||||
exp = getName(asset, 'exports');
|
||||
}
|
||||
|
||||
if (replacements && replacements.has(exp)) {
|
||||
exp = replacements.get(exp);
|
||||
}
|
||||
|
||||
return {
|
||||
identifier: exp,
|
||||
name,
|
||||
id
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = JSConcatPackager;
|
||||
326
BACK_BACK/node_modules/parcel-bundler/lib/packagers/JSPackager.js
generated
vendored
Executable file
326
BACK_BACK/node_modules/parcel-bundler/lib/packagers/JSPackager.js
generated
vendored
Executable file
|
|
@ -0,0 +1,326 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const Packager = require('./Packager');
|
||||
|
||||
const getExisting = require('../utils/getExisting');
|
||||
|
||||
const urlJoin = require('../utils/urlJoin');
|
||||
|
||||
const lineCounter = require('../utils/lineCounter');
|
||||
|
||||
const objectHash = require('../utils/objectHash');
|
||||
|
||||
const prelude = getExisting(path.join(__dirname, '../builtins/prelude.min.js'), path.join(__dirname, '../builtins/prelude.js'));
|
||||
|
||||
class JSPackager extends Packager {
|
||||
start() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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 (0, _asyncToGenerator2.default)(function* () {
|
||||
// If this module is referenced by another JS bundle, it needs to be exposed externally.
|
||||
// In that case, don't dedupe the asset as it would affect the module ids that are referenced by other bundles.
|
||||
let isExposed = !Array.from(asset.parentDeps).every(dep => {
|
||||
let depAsset = _this2.bundler.loadedAssets.get(dep.parent);
|
||||
|
||||
return _this2.bundle.assets.has(depAsset) || depAsset.type !== 'js';
|
||||
});
|
||||
|
||||
if (!isExposed) {
|
||||
let key = _this2.dedupeKey(asset);
|
||||
|
||||
if (_this2.dedupe.has(key)) {
|
||||
return;
|
||||
} // Don't dedupe when HMR is turned on since it messes with the asset ids
|
||||
|
||||
|
||||
if (!_this2.options.hmr) {
|
||||
_this2.dedupe.set(key, asset.id);
|
||||
}
|
||||
}
|
||||
|
||||
let deps = {};
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(asset.depAssets),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let _step$value = (0, _slicedToArray2.default)(_step.value, 2),
|
||||
dep = _step$value[0],
|
||||
mod = _step$value[1];
|
||||
|
||||
// For dynamic dependencies, list the child bundles to load along with the module id
|
||||
if (dep.dynamic) {
|
||||
let bundles = [_this2.getBundleSpecifier(mod.parentBundle)];
|
||||
|
||||
var _iterator2 = _createForOfIteratorHelper(mod.parentBundle.siblingBundles),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
let child = _step2.value;
|
||||
|
||||
if (!child.isEmpty) {
|
||||
bundles.push(_this2.getBundleSpecifier(child));
|
||||
|
||||
_this2.bundleLoaders.add(child.type);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
|
||||
bundles.push(mod.id);
|
||||
deps[dep.name] = bundles;
|
||||
|
||||
_this2.bundleLoaders.add(mod.type);
|
||||
} else {
|
||||
deps[dep.name] = _this2.dedupe.get(_this2.dedupeKey(mod)) || 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.externalModules.add(mod);
|
||||
|
||||
if (!_this2.bundle.parentBundle || _this2.bundle.isolated || _this2.bundle.parentBundle.type !== 'js') {
|
||||
_this2.bundleLoaders.add(mod.type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
_this2.bundle.addOffset(asset, _this2.lineOffset);
|
||||
|
||||
yield _this2.writeModule(asset.id, asset.generated.js, deps, asset.generated.map);
|
||||
})();
|
||||
}
|
||||
|
||||
getBundleSpecifier(bundle) {
|
||||
let name = path.relative(path.dirname(this.bundle.name), bundle.name);
|
||||
|
||||
if (bundle.entryAsset) {
|
||||
return [name, bundle.entryAsset.id];
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
dedupeKey(asset) {
|
||||
// cannot rely *only* on generated JS for deduplication because paths like
|
||||
// `../` can cause 2 identical JS files to behave differently depending on
|
||||
// where they are located on the filesystem
|
||||
let deps = Array.from(asset.depAssets.values(), dep => dep.name).sort();
|
||||
return objectHash([asset.generated.js, deps]);
|
||||
}
|
||||
|
||||
writeModule(id, code, deps = {}, map) {
|
||||
var _this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let wrapped = _this3.first ? '' : ',';
|
||||
wrapped += JSON.stringify(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 (0, _asyncToGenerator2.default)(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 _iterator3 = _createForOfIteratorHelper(asset.depAssets.values()),
|
||||
_step3;
|
||||
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
let child = _step3.value;
|
||||
yield _this4.addAssetToBundle(child);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator3.e(err);
|
||||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
|
||||
yield _this4.addAsset(asset);
|
||||
})();
|
||||
}
|
||||
|
||||
writeBundleLoaders() {
|
||||
var _this5 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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(' + JSON.stringify(bundleLoader.id) + ');';
|
||||
|
||||
var _iterator4 = _createForOfIteratorHelper(_this5.bundleLoaders),
|
||||
_step4;
|
||||
|
||||
try {
|
||||
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
||||
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(' + JSON.stringify(asset.id) + '));';
|
||||
}
|
||||
} // Preload external modules before running entry point if needed
|
||||
|
||||
} catch (err) {
|
||||
_iterator4.e(err);
|
||||
} finally {
|
||||
_iterator4.f();
|
||||
}
|
||||
|
||||
if (_this5.externalModules.size > 0) {
|
||||
let preload = [];
|
||||
|
||||
var _iterator5 = _createForOfIteratorHelper(_this5.externalModules),
|
||||
_step5;
|
||||
|
||||
try {
|
||||
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
||||
let mod = _step5.value;
|
||||
// Find the bundle that has the module as its entry point
|
||||
let bundle = Array.from(mod.bundles).find(b => b.entryAsset === mod);
|
||||
|
||||
if (bundle) {
|
||||
preload.push([path.basename(bundle.name), mod.id]);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator5.e(err);
|
||||
} finally {
|
||||
_iterator5.f();
|
||||
}
|
||||
|
||||
loads += 'b.load(' + JSON.stringify(preload) + ')';
|
||||
|
||||
if (_this5.bundle.entryAsset) {
|
||||
loads += `.then(function(){require(${JSON.stringify(_this5.bundle.entryAsset.id)});})`;
|
||||
}
|
||||
|
||||
loads += ';';
|
||||
} // Asset ids normally start at 1, so this should be safe.
|
||||
|
||||
|
||||
yield _this5.writeModule(0, loads, {});
|
||||
return true;
|
||||
})();
|
||||
}
|
||||
|
||||
end() {
|
||||
var _superprop_getEnd = () => super.end,
|
||||
_this6 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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.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) {
|
||||
let mapUrl = urlJoin(_this6.options.publicURL, path.relative(_this6.options.outDir, mapBundle.name));
|
||||
yield _this6.write(`\n//# sourceMappingURL=${mapUrl}`);
|
||||
}
|
||||
}
|
||||
|
||||
yield _superprop_getEnd().call(_this6);
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = JSPackager;
|
||||
76
BACK_BACK/node_modules/parcel-bundler/lib/packagers/Packager.js
generated
vendored
Executable file
76
BACK_BACK/node_modules/parcel-bundler/lib/packagers/Packager.js
generated
vendored
Executable file
|
|
@ -0,0 +1,76 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const _require = require('@parcel/utils'),
|
||||
promisify = _require.promisify;
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const _require2 = require('@parcel/fs'),
|
||||
mkdirp = _require2.mkdirp;
|
||||
|
||||
class Packager {
|
||||
constructor(bundle, bundler) {
|
||||
this.bundle = bundle;
|
||||
this.bundler = bundler;
|
||||
this.options = bundler.options;
|
||||
}
|
||||
|
||||
static shouldAddAsset() {
|
||||
return true;
|
||||
}
|
||||
|
||||
setup() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(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 (0, _asyncToGenerator2.default)(function* () {
|
||||
yield _this2.dest.write(string);
|
||||
})();
|
||||
}
|
||||
|
||||
start() {
|
||||
return (0, _asyncToGenerator2.default)(function* () {})();
|
||||
} // eslint-disable-next-line no-unused-vars
|
||||
|
||||
|
||||
addAsset(asset) {
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
throw new Error('Must be implemented by subclasses');
|
||||
})();
|
||||
}
|
||||
|
||||
getSize() {
|
||||
return this.dest.bytesWritten;
|
||||
}
|
||||
|
||||
end() {
|
||||
var _this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
yield _this3.dest.end();
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Packager;
|
||||
51
BACK_BACK/node_modules/parcel-bundler/lib/packagers/RawPackager.js
generated
vendored
Executable file
51
BACK_BACK/node_modules/parcel-bundler/lib/packagers/RawPackager.js
generated
vendored
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const Packager = require('./Packager');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
class RawPackager extends Packager {
|
||||
static shouldAddAsset() {
|
||||
// We cannot combine multiple raw assets together - they should be written as separate bundles.
|
||||
return false;
|
||||
} // 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 (0, _asyncToGenerator2.default)(function* () {
|
||||
let contents = asset.generated[_this.bundle.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;
|
||||
47
BACK_BACK/node_modules/parcel-bundler/lib/packagers/SourceMapPackager.js
generated
vendored
Executable file
47
BACK_BACK/node_modules/parcel-bundler/lib/packagers/SourceMapPackager.js
generated
vendored
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const Packager = require('./Packager');
|
||||
|
||||
const SourceMap = require('../SourceMap');
|
||||
|
||||
class SourceMapPackager extends Packager {
|
||||
start() {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
_this.sourceMap = new SourceMap();
|
||||
})();
|
||||
}
|
||||
|
||||
addAsset(asset) {
|
||||
var _this2 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let offsets = _this2.bundle.parentBundle.getOffset(asset);
|
||||
|
||||
if (asset.sourceMaps[asset.type]) {
|
||||
yield _this2.sourceMap.addMap(asset.sourceMaps[asset.type], offsets[0], offsets[1]);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
end() {
|
||||
var _superprop_getEnd = () => super.end,
|
||||
_this3 = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let file = path.basename(_this3.bundle.parentBundle.name);
|
||||
yield _this3.write(_this3.sourceMap.stringify(file, path.relative(_this3.options.outDir, _this3.options.rootDir)));
|
||||
yield _superprop_getEnd().call(_this3);
|
||||
})();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = SourceMapPackager;
|
||||
42
BACK_BACK/node_modules/parcel-bundler/lib/packagers/index.js
generated
vendored
Executable file
42
BACK_BACK/node_modules/parcel-bundler/lib/packagers/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
"use strict";
|
||||
|
||||
const JSConcatPackager = require('./JSConcatPackager');
|
||||
|
||||
const JSPackager = require('./JSPackager');
|
||||
|
||||
const CSSPackager = require('./CSSPackager');
|
||||
|
||||
const HTMLPackager = require('./HTMLPackager');
|
||||
|
||||
const SourceMapPackager = require('./SourceMapPackager');
|
||||
|
||||
const RawPackager = require('./RawPackager');
|
||||
|
||||
class PackagerRegistry {
|
||||
constructor(options) {
|
||||
this.packagers = new Map();
|
||||
this.add('css', CSSPackager);
|
||||
this.add('html', HTMLPackager);
|
||||
this.add('map', SourceMapPackager);
|
||||
this.add('js', options.scopeHoist ? JSConcatPackager : JSPackager);
|
||||
}
|
||||
|
||||
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;
|
||||
452
BACK_BACK/node_modules/parcel-bundler/lib/scope-hoisting/concat.js
generated
vendored
Executable file
452
BACK_BACK/node_modules/parcel-bundler/lib/scope-hoisting/concat.js
generated
vendored
Executable file
|
|
@ -0,0 +1,452 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const _require = require('path'),
|
||||
relative = _require.relative;
|
||||
|
||||
const template = require('@babel/template').default;
|
||||
|
||||
const t = require('@babel/types');
|
||||
|
||||
const traverse = require('@babel/traverse').default;
|
||||
|
||||
const generate = require('@babel/generator').default;
|
||||
|
||||
const treeShake = require('./shake');
|
||||
|
||||
const mangleScope = require('./mangler');
|
||||
|
||||
const _require2 = require('./utils'),
|
||||
getName = _require2.getName,
|
||||
getIdentifier = _require2.getIdentifier;
|
||||
|
||||
const EXPORTS_RE = /^\$([^$]+)\$exports$/;
|
||||
const ESMODULE_TEMPLATE = template(`$parcel$defineInteropFlag(EXPORTS);`);
|
||||
const DEFAULT_INTEROP_TEMPLATE = template('var NAME = $parcel$interopDefault(MODULE)');
|
||||
const THROW_TEMPLATE = template('$parcel$missingModule(MODULE)');
|
||||
const REQUIRE_TEMPLATE = template('require(ID)');
|
||||
|
||||
module.exports = (packager, ast) => {
|
||||
let assets = packager.assets;
|
||||
let replacements = new Map();
|
||||
let imports = new Map();
|
||||
let referenced = new Set(); // Build a mapping of all imported identifiers to replace.
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(assets.values()),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let asset = _step.value;
|
||||
|
||||
for (let name in asset.cacheData.imports) {
|
||||
let imp = asset.cacheData.imports[name];
|
||||
imports.set(name, [packager.resolveModule(asset.id, imp[0]), imp[1]]);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
function replaceExportNode(module, originalName, path) {
|
||||
let _packager$findExportM = packager.findExportModule(module.id, originalName, replacements),
|
||||
identifier = _packager$findExportM.identifier,
|
||||
name = _packager$findExportM.name,
|
||||
id = _packager$findExportM.id;
|
||||
|
||||
let mod = assets.get(id);
|
||||
let node;
|
||||
|
||||
if (identifier) {
|
||||
node = findSymbol(path, identifier);
|
||||
} // If the module is not in this bundle, create a `require` call for it.
|
||||
|
||||
|
||||
if (!node && !mod) {
|
||||
node = REQUIRE_TEMPLATE({
|
||||
ID: t.stringLiteral(id)
|
||||
}).expression;
|
||||
return interop(module, name, path, node);
|
||||
} // If this is an ES6 module, throw an error if we cannot resolve the module
|
||||
|
||||
|
||||
if (!node && !mod.cacheData.isCommonJS && mod.cacheData.isES6Module) {
|
||||
let relativePath = relative(packager.options.rootDir, mod.name);
|
||||
throw new Error(`${relativePath} does not export '${name}'`);
|
||||
} // If it is CommonJS, look for an exports object.
|
||||
|
||||
|
||||
if (!node && mod.cacheData.isCommonJS) {
|
||||
node = findSymbol(path, getName(mod, 'exports'));
|
||||
|
||||
if (!node) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return interop(mod, name, path, node);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function findSymbol(path, symbol) {
|
||||
if (replacements.has(symbol)) {
|
||||
symbol = replacements.get(symbol);
|
||||
} // if the symbol is in the scope there is not need to remap it
|
||||
|
||||
|
||||
if (path.scope.getProgramParent().hasBinding(symbol)) {
|
||||
return t.identifier(symbol);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function interop(mod, originalName, path, node) {
|
||||
// Handle interop for default imports of CommonJS modules.
|
||||
if (mod.cacheData.isCommonJS && originalName === 'default') {
|
||||
let name = getName(mod, '$interop$default');
|
||||
|
||||
if (!path.scope.getBinding(name)) {
|
||||
let _path$getStatementPar = path.getStatementParent().insertBefore(DEFAULT_INTEROP_TEMPLATE({
|
||||
NAME: t.identifier(name),
|
||||
MODULE: node
|
||||
})),
|
||||
_path$getStatementPar2 = (0, _slicedToArray2.default)(_path$getStatementPar, 1),
|
||||
decl = _path$getStatementPar2[0];
|
||||
|
||||
let binding = path.scope.getBinding(getName(mod, 'exports'));
|
||||
|
||||
if (binding) {
|
||||
binding.reference(decl.get('declarations.0.init'));
|
||||
}
|
||||
|
||||
path.scope.registerDeclaration(decl);
|
||||
}
|
||||
|
||||
return t.memberExpression(t.identifier(name), t.identifier('d'));
|
||||
} // if there is a CommonJS export return $id$exports.name
|
||||
|
||||
|
||||
if (originalName !== '*') {
|
||||
return t.memberExpression(node, t.identifier(originalName));
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function isUnusedValue(path) {
|
||||
return path.parentPath.isExpressionStatement() || path.parentPath.isSequenceExpression() && (path.key !== path.container.length - 1 || isUnusedValue(path.parentPath));
|
||||
}
|
||||
|
||||
traverse(ast, {
|
||||
CallExpression(path) {
|
||||
let _path$node = path.node,
|
||||
args = _path$node.arguments,
|
||||
callee = _path$node.callee;
|
||||
|
||||
if (!t.isIdentifier(callee)) {
|
||||
return;
|
||||
} // each require('module') call gets replaced with $parcel$require(id, 'module')
|
||||
|
||||
|
||||
if (callee.name === '$parcel$require') {
|
||||
let _args = (0, _slicedToArray2.default)(args, 2),
|
||||
id = _args[0],
|
||||
source = _args[1];
|
||||
|
||||
if (args.length !== 2 || !t.isStringLiteral(id) || !t.isStringLiteral(source)) {
|
||||
throw new Error('invariant: invalid signature, expected : $parcel$require(number, string)');
|
||||
}
|
||||
|
||||
let asset = assets.get(id.value);
|
||||
let mod = packager.resolveModule(id.value, source.value);
|
||||
|
||||
if (!mod) {
|
||||
if (asset.dependencies.get(source.value).optional) {
|
||||
path.replaceWith(THROW_TEMPLATE({
|
||||
MODULE: t.stringLiteral(source.value)
|
||||
}));
|
||||
} else {
|
||||
throw new Error(`Cannot find module "${source.value}" in asset ${id.value}`);
|
||||
}
|
||||
} else {
|
||||
let node;
|
||||
|
||||
if (assets.get(mod.id)) {
|
||||
// Replace with nothing if the require call's result is not used.
|
||||
if (!isUnusedValue(path)) {
|
||||
let name = getName(mod, 'exports');
|
||||
node = t.identifier(replacements.get(name) || name); // Insert __esModule interop flag if the required module is an ES6 module with a default export.
|
||||
// This ensures that code generated by Babel and other tools works properly.
|
||||
|
||||
if (asset.cacheData.isCommonJS && mod.cacheData.isES6Module && mod.cacheData.exports.default) {
|
||||
let binding = path.scope.getBinding(name);
|
||||
|
||||
if (binding && !binding.path.getData('hasESModuleFlag')) {
|
||||
if (binding.path.node.init) {
|
||||
binding.path.getStatementParent().insertAfter(ESMODULE_TEMPLATE({
|
||||
EXPORTS: name
|
||||
}));
|
||||
}
|
||||
|
||||
var _iterator2 = _createForOfIteratorHelper(binding.constantViolations),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
let path = _step2.value;
|
||||
path.insertAfter(ESMODULE_TEMPLATE({
|
||||
EXPORTS: name
|
||||
}));
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
|
||||
binding.path.setData('hasESModuleFlag', true);
|
||||
}
|
||||
}
|
||||
} // We need to wrap the module in a function when a require
|
||||
// call happens inside a non top-level scope, e.g. in a
|
||||
// function, if statement, or conditional expression.
|
||||
|
||||
|
||||
if (mod.cacheData.shouldWrap) {
|
||||
let call = t.callExpression(getIdentifier(mod, 'init'), []);
|
||||
node = node ? t.sequenceExpression([call, node]) : call;
|
||||
}
|
||||
} else {
|
||||
node = REQUIRE_TEMPLATE({
|
||||
ID: t.stringLiteral(mod.id)
|
||||
}).expression;
|
||||
}
|
||||
|
||||
if (node) {
|
||||
path.replaceWith(node);
|
||||
} else {
|
||||
path.remove();
|
||||
}
|
||||
}
|
||||
} else if (callee.name === '$parcel$require$resolve') {
|
||||
let _args2 = (0, _slicedToArray2.default)(args, 2),
|
||||
id = _args2[0],
|
||||
source = _args2[1];
|
||||
|
||||
if (args.length !== 2 || !t.isStringLiteral(id) || !t.isStringLiteral(source)) {
|
||||
throw new Error('invariant: invalid signature, expected : $parcel$require$resolve(number, string)');
|
||||
}
|
||||
|
||||
let mapped = assets.get(id.value);
|
||||
let dep = mapped.dependencies.get(source.value);
|
||||
let mod = mapped.depAssets.get(dep);
|
||||
let bundles = mod.id;
|
||||
|
||||
if (dep.dynamic && packager.bundle.childBundles.has(mod.parentBundle)) {
|
||||
bundles = [];
|
||||
|
||||
var _iterator3 = _createForOfIteratorHelper(mod.parentBundle.siblingBundles),
|
||||
_step3;
|
||||
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
let child = _step3.value;
|
||||
|
||||
if (!child.isEmpty && packager.options.bundleLoaders[child.type]) {
|
||||
bundles.push(packager.getBundleSpecifier(child));
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator3.e(err);
|
||||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
|
||||
bundles.push(packager.getBundleSpecifier(mod.parentBundle));
|
||||
bundles.push(mod.id);
|
||||
}
|
||||
|
||||
path.replaceWith(t.valueToNode(bundles));
|
||||
}
|
||||
},
|
||||
|
||||
VariableDeclarator: {
|
||||
exit(path) {
|
||||
// Replace references to declarations like `var x = require('x')`
|
||||
// with the final export identifier instead.
|
||||
// This allows us to potentially replace accesses to e.g. `x.foo` with
|
||||
// a variable like `$id$export$foo` later, avoiding the exports object altogether.
|
||||
let _path$node2 = path.node,
|
||||
id = _path$node2.id,
|
||||
init = _path$node2.init;
|
||||
|
||||
if (!t.isIdentifier(init)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let match = init.name.match(EXPORTS_RE);
|
||||
|
||||
if (!match) {
|
||||
return;
|
||||
} // Replace patterns like `var {x} = require('y')` with e.g. `$id$export$x`.
|
||||
|
||||
|
||||
if (t.isObjectPattern(id)) {
|
||||
var _iterator4 = _createForOfIteratorHelper(path.get('id.properties')),
|
||||
_step4;
|
||||
|
||||
try {
|
||||
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
||||
let p = _step4.value;
|
||||
let _p$node = p.node,
|
||||
computed = _p$node.computed,
|
||||
key = _p$node.key,
|
||||
value = _p$node.value;
|
||||
|
||||
if (computed || !t.isIdentifier(key) || !t.isIdentifier(value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let _packager$findExportM2 = packager.findExportModule(match[1], key.name, replacements),
|
||||
identifier = _packager$findExportM2.identifier;
|
||||
|
||||
if (identifier) {
|
||||
replace(value.name, identifier, p);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator4.e(err);
|
||||
} finally {
|
||||
_iterator4.f();
|
||||
}
|
||||
|
||||
if (id.properties.length === 0) {
|
||||
path.remove();
|
||||
}
|
||||
} else if (t.isIdentifier(id)) {
|
||||
replace(id.name, init.name, path);
|
||||
}
|
||||
|
||||
function replace(id, init, path) {
|
||||
let binding = path.scope.getBinding(id);
|
||||
|
||||
if (!binding.constant) {
|
||||
return;
|
||||
}
|
||||
|
||||
var _iterator5 = _createForOfIteratorHelper(binding.referencePaths),
|
||||
_step5;
|
||||
|
||||
try {
|
||||
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
||||
let ref = _step5.value;
|
||||
ref.replaceWith(t.identifier(init));
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator5.e(err);
|
||||
} finally {
|
||||
_iterator5.f();
|
||||
}
|
||||
|
||||
replacements.set(id, init);
|
||||
path.remove();
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
MemberExpression: {
|
||||
exit(path) {
|
||||
if (!path.isReferenced()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let _path$node3 = path.node,
|
||||
object = _path$node3.object,
|
||||
property = _path$node3.property,
|
||||
computed = _path$node3.computed;
|
||||
|
||||
if (!(t.isIdentifier(object) && (t.isIdentifier(property) && !computed || t.isStringLiteral(property)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
let match = object.name.match(EXPORTS_RE); // If it's a $id$exports.name expression.
|
||||
|
||||
if (match) {
|
||||
let name = t.isIdentifier(property) ? property.name : property.value;
|
||||
|
||||
let _packager$findExportM3 = packager.findExportModule(match[1], name, replacements),
|
||||
identifier = _packager$findExportM3.identifier; // Check if $id$export$name exists and if so, replace the node by it.
|
||||
|
||||
|
||||
if (identifier) {
|
||||
path.replaceWith(t.identifier(identifier));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
ReferencedIdentifier(path) {
|
||||
let name = path.node.name;
|
||||
|
||||
if (typeof name !== 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (imports.has(name)) {
|
||||
let imp = imports.get(name);
|
||||
let node = replaceExportNode(imp[0], imp[1], path); // If the export does not exist, replace with an empty object.
|
||||
|
||||
if (!node) {
|
||||
node = t.objectExpression([]);
|
||||
}
|
||||
|
||||
path.replaceWith(node);
|
||||
return;
|
||||
}
|
||||
|
||||
let match = name.match(EXPORTS_RE);
|
||||
|
||||
if (match) {
|
||||
referenced.add(name);
|
||||
} // If it's an undefined $id$exports identifier.
|
||||
|
||||
|
||||
if (match && !path.scope.hasBinding(name)) {
|
||||
path.replaceWith(t.objectExpression([]));
|
||||
}
|
||||
},
|
||||
|
||||
Program: {
|
||||
// A small optimization to remove unused CommonJS exports as sometimes Uglify doesn't remove them.
|
||||
exit(path) {
|
||||
treeShake(path.scope);
|
||||
|
||||
if (packager.options.minify) {
|
||||
mangleScope(path.scope);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
let opts = {
|
||||
sourceMaps: packager.options.sourceMaps,
|
||||
sourceFileName: packager.bundle.name,
|
||||
minified: packager.options.minify,
|
||||
comments: !packager.options.minify
|
||||
};
|
||||
return generate(ast, opts);
|
||||
};
|
||||
570
BACK_BACK/node_modules/parcel-bundler/lib/scope-hoisting/hoist.js
generated
vendored
Executable file
570
BACK_BACK/node_modules/parcel-bundler/lib/scope-hoisting/hoist.js
generated
vendored
Executable file
|
|
@ -0,0 +1,570 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const mm = require('micromatch');
|
||||
|
||||
const t = require('@babel/types');
|
||||
|
||||
const template = require('@babel/template').default;
|
||||
|
||||
const traverse = require('@babel/traverse').default;
|
||||
|
||||
const rename = require('./renamer');
|
||||
|
||||
const _require = require('./utils'),
|
||||
getName = _require.getName,
|
||||
getIdentifier = _require.getIdentifier,
|
||||
getExportIdentifier = _require.getExportIdentifier;
|
||||
|
||||
const WRAPPER_TEMPLATE = template(`
|
||||
var NAME = (function () {
|
||||
var exports = this;
|
||||
var module = {exports: this};
|
||||
BODY;
|
||||
return module.exports;
|
||||
}).call({});
|
||||
`);
|
||||
const ESMODULE_TEMPLATE = template(`exports.__esModule = true;`);
|
||||
const EXPORT_ASSIGN_TEMPLATE = template('EXPORTS.NAME = LOCAL');
|
||||
const EXPORT_ALL_TEMPLATE = template('$parcel$exportWildcard(OLD_NAME, $parcel$require(ID, SOURCE))');
|
||||
const REQUIRE_CALL_TEMPLATE = template('$parcel$require(ID, SOURCE)');
|
||||
const REQUIRE_RESOLVE_CALL_TEMPLATE = template('$parcel$require$resolve(ID, SOURCE)');
|
||||
const TYPEOF = {
|
||||
module: 'object',
|
||||
require: 'function'
|
||||
};
|
||||
|
||||
function hasSideEffects(asset, {
|
||||
sideEffects
|
||||
} = asset._package) {
|
||||
switch (typeof sideEffects) {
|
||||
case 'undefined':
|
||||
return true;
|
||||
|
||||
case 'boolean':
|
||||
return sideEffects;
|
||||
|
||||
case 'string':
|
||||
return mm.isMatch(path.relative(asset._package.pkgdir, asset.name), sideEffects, {
|
||||
matchBase: true
|
||||
});
|
||||
|
||||
case 'object':
|
||||
return sideEffects.some(sideEffects => hasSideEffects(asset, {
|
||||
sideEffects
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Program: {
|
||||
enter(path, asset) {
|
||||
traverse.cache.clearScope();
|
||||
path.scope.crawl();
|
||||
asset.cacheData.imports = asset.cacheData.imports || Object.create(null);
|
||||
asset.cacheData.exports = asset.cacheData.exports || Object.create(null);
|
||||
asset.cacheData.wildcards = asset.cacheData.wildcards || [];
|
||||
asset.cacheData.sideEffects = asset._package && hasSideEffects(asset);
|
||||
let shouldWrap = false;
|
||||
path.traverse({
|
||||
CallExpression(path) {
|
||||
// If we see an `eval` call, wrap the module in a function.
|
||||
// Otherwise, local variables accessed inside the eval won't work.
|
||||
let callee = path.node.callee;
|
||||
|
||||
if (t.isIdentifier(callee) && callee.name === 'eval' && !path.scope.hasBinding('eval', true)) {
|
||||
asset.cacheData.isCommonJS = true;
|
||||
shouldWrap = true;
|
||||
path.stop();
|
||||
}
|
||||
},
|
||||
|
||||
ReturnStatement(path) {
|
||||
// Wrap in a function if we see a top-level return statement.
|
||||
if (!path.getFunctionParent()) {
|
||||
shouldWrap = true;
|
||||
asset.cacheData.isCommonJS = true;
|
||||
path.replaceWith(t.returnStatement(t.memberExpression(t.identifier('module'), t.identifier('exports'))));
|
||||
path.stop();
|
||||
}
|
||||
},
|
||||
|
||||
ReferencedIdentifier(path) {
|
||||
// We must wrap if `module` is referenced as a free identifier rather
|
||||
// than a statically resolvable member expression.
|
||||
if (path.node.name === 'module' && (!path.parentPath.isMemberExpression() || path.parent.computed) && !(path.parentPath.isUnaryExpression() && path.parent.operator === 'typeof') && !path.scope.hasBinding('module') && !path.scope.getData('shouldWrap')) {
|
||||
asset.cacheData.isCommonJS = true;
|
||||
shouldWrap = true;
|
||||
path.stop();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
path.scope.setData('shouldWrap', shouldWrap);
|
||||
},
|
||||
|
||||
exit(path, asset) {
|
||||
let scope = path.scope;
|
||||
|
||||
if (scope.getData('shouldWrap')) {
|
||||
if (asset.cacheData.isES6Module) {
|
||||
path.unshiftContainer('body', [ESMODULE_TEMPLATE()]);
|
||||
}
|
||||
|
||||
path.replaceWith(t.program([WRAPPER_TEMPLATE({
|
||||
NAME: getExportsIdentifier(asset),
|
||||
BODY: path.node.body
|
||||
})]));
|
||||
asset.cacheData.exports = {};
|
||||
asset.cacheData.isCommonJS = true;
|
||||
asset.cacheData.isES6Module = false;
|
||||
} else {
|
||||
// Re-crawl scope so we are sure to have all bindings.
|
||||
scope.crawl(); // Rename each binding in the top-level scope to something unique.
|
||||
|
||||
for (let name in scope.bindings) {
|
||||
if (!name.startsWith('$' + t.toIdentifier(asset.id))) {
|
||||
let newName = getName(asset, 'var', name);
|
||||
rename(scope, name, newName);
|
||||
}
|
||||
}
|
||||
|
||||
let exportsIdentifier = getExportsIdentifier(asset); // Add variable that represents module.exports if it is referenced and not declared.
|
||||
|
||||
if (scope.hasGlobal(exportsIdentifier.name) && !scope.hasBinding(exportsIdentifier.name)) {
|
||||
scope.push({
|
||||
id: exportsIdentifier,
|
||||
init: t.objectExpression([])
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
path.stop();
|
||||
asset.isAstDirty = true;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
DirectiveLiteral(path) {
|
||||
// Remove 'use strict' directives, since modules are concatenated - one strict mode
|
||||
// module should not apply to all other modules in the same scope.
|
||||
if (path.node.value === 'use strict') {
|
||||
path.parentPath.remove();
|
||||
}
|
||||
},
|
||||
|
||||
MemberExpression(path, asset) {
|
||||
if (path.scope.hasBinding('module') || path.scope.getData('shouldWrap')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (t.matchesPattern(path.node, 'module.exports')) {
|
||||
path.replaceWith(getExportsIdentifier(asset));
|
||||
asset.cacheData.isCommonJS = true;
|
||||
}
|
||||
|
||||
if (t.matchesPattern(path.node, 'module.id')) {
|
||||
path.replaceWith(t.stringLiteral(asset.id));
|
||||
}
|
||||
|
||||
if (t.matchesPattern(path.node, 'module.hot')) {
|
||||
path.replaceWith(t.identifier('null'));
|
||||
}
|
||||
|
||||
if (t.matchesPattern(path.node, 'module.require') && asset.options.target !== 'node') {
|
||||
path.replaceWith(t.identifier('null'));
|
||||
}
|
||||
|
||||
if (t.matchesPattern(path.node, 'module.bundle')) {
|
||||
path.replaceWith(t.identifier('require'));
|
||||
}
|
||||
},
|
||||
|
||||
ReferencedIdentifier(path, asset) {
|
||||
if (path.node.name === 'exports' && !path.scope.hasBinding('exports') && !path.scope.getData('shouldWrap')) {
|
||||
path.replaceWith(getExportsIdentifier(asset));
|
||||
asset.cacheData.isCommonJS = true;
|
||||
}
|
||||
|
||||
if (path.node.name === 'global' && !path.scope.hasBinding('global')) {
|
||||
path.replaceWith(t.identifier('$parcel$global'));
|
||||
asset.globals.delete('global');
|
||||
}
|
||||
|
||||
let globalCode = asset.globals.get(path.node.name);
|
||||
|
||||
if (globalCode) {
|
||||
path.scope.getProgramParent().path.unshiftContainer('body', [template(globalCode)()]);
|
||||
asset.globals.delete(path.node.name);
|
||||
}
|
||||
},
|
||||
|
||||
ThisExpression(path, asset) {
|
||||
if (!path.scope.parent && !path.scope.getData('shouldWrap')) {
|
||||
path.replaceWith(getExportsIdentifier(asset));
|
||||
asset.cacheData.isCommonJS = true;
|
||||
}
|
||||
},
|
||||
|
||||
AssignmentExpression(path, asset) {
|
||||
if (path.scope.hasBinding('exports') || path.scope.getData('shouldWrap')) {
|
||||
return;
|
||||
}
|
||||
|
||||
let _path$node = path.node,
|
||||
left = _path$node.left,
|
||||
right = _path$node.right;
|
||||
|
||||
if (t.isIdentifier(left) && left.name === 'exports') {
|
||||
path.get('left').replaceWith(getExportsIdentifier(asset));
|
||||
asset.cacheData.isCommonJS = true;
|
||||
} // If we can statically evaluate the name of a CommonJS export, create an ES6-style export for it.
|
||||
// This allows us to remove the CommonJS export object completely in many cases.
|
||||
|
||||
|
||||
if (t.isMemberExpression(left) && t.isIdentifier(left.object, {
|
||||
name: 'exports'
|
||||
}) && (t.isIdentifier(left.property) && !left.computed || t.isStringLiteral(left.property))) {
|
||||
let name = t.isIdentifier(left.property) ? left.property.name : left.property.value;
|
||||
let identifier = getExportIdentifier(asset, name); // Replace the CommonJS assignment with a reference to the ES6 identifier.
|
||||
|
||||
path.get('left.object').replaceWith(getExportsIdentifier(asset));
|
||||
path.get('right').replaceWith(identifier); // If this is the first assignment, create a binding for the ES6-style export identifier.
|
||||
// Otherwise, assign to the existing export binding.
|
||||
|
||||
let scope = path.scope.getProgramParent();
|
||||
|
||||
if (!scope.hasBinding(identifier.name)) {
|
||||
asset.cacheData.exports[name] = identifier.name; // If in the program scope, create a variable declaration and initialize with the exported value.
|
||||
// Otherwise, declare the variable in the program scope, and assign to it here.
|
||||
|
||||
if (path.scope === scope) {
|
||||
let _path$insertBefore = path.insertBefore(t.variableDeclaration('var', [t.variableDeclarator(t.clone(identifier), right)])),
|
||||
_path$insertBefore2 = (0, _slicedToArray2.default)(_path$insertBefore, 1),
|
||||
decl = _path$insertBefore2[0];
|
||||
|
||||
scope.registerDeclaration(decl);
|
||||
} else {
|
||||
scope.push({
|
||||
id: t.clone(identifier)
|
||||
});
|
||||
path.insertBefore(t.assignmentExpression('=', t.clone(identifier), right));
|
||||
}
|
||||
} else {
|
||||
path.insertBefore(t.assignmentExpression('=', t.clone(identifier), right));
|
||||
}
|
||||
|
||||
asset.cacheData.isCommonJS = true;
|
||||
}
|
||||
},
|
||||
|
||||
UnaryExpression(path) {
|
||||
// Replace `typeof module` with "object"
|
||||
if (path.node.operator === 'typeof' && t.isIdentifier(path.node.argument) && TYPEOF[path.node.argument.name] && !path.scope.hasBinding(path.node.argument.name) && !path.scope.getData('shouldWrap')) {
|
||||
path.replaceWith(t.stringLiteral(TYPEOF[path.node.argument.name]));
|
||||
}
|
||||
},
|
||||
|
||||
CallExpression(path, asset) {
|
||||
let _path$node2 = path.node,
|
||||
callee = _path$node2.callee,
|
||||
args = _path$node2.arguments;
|
||||
let ignore = args.length !== 1 || !t.isStringLiteral(args[0]) || path.scope.hasBinding('require');
|
||||
|
||||
if (ignore) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (t.isIdentifier(callee, {
|
||||
name: 'require'
|
||||
})) {
|
||||
let source = args[0].value; // Ignore require calls that were ignored earlier.
|
||||
|
||||
if (!asset.dependencies.has(source)) {
|
||||
return;
|
||||
} // If this require call does not occur in the top-level, e.g. in a function
|
||||
// or inside an if statement, or if it might potentially happen conditionally,
|
||||
// the module must be wrapped in a function so that the module execution order is correct.
|
||||
|
||||
|
||||
let parent = path.getStatementParent().parentPath;
|
||||
let bail = path.findParent(p => p.isConditionalExpression() || p.isLogicalExpression() || p.isSequenceExpression());
|
||||
|
||||
if (!parent.isProgram() || bail) {
|
||||
asset.dependencies.get(source).shouldWrap = true;
|
||||
}
|
||||
|
||||
asset.cacheData.imports['$require$' + source] = [source, '*']; // Generate a variable name based on the current asset id and the module name to require.
|
||||
// This will be replaced by the final variable name of the resolved asset in the packager.
|
||||
|
||||
path.replaceWith(REQUIRE_CALL_TEMPLATE({
|
||||
ID: t.stringLiteral(asset.id),
|
||||
SOURCE: t.stringLiteral(args[0].value)
|
||||
}));
|
||||
}
|
||||
|
||||
if (t.matchesPattern(callee, 'require.resolve')) {
|
||||
path.replaceWith(REQUIRE_RESOLVE_CALL_TEMPLATE({
|
||||
ID: t.stringLiteral(asset.id),
|
||||
SOURCE: args[0]
|
||||
}));
|
||||
}
|
||||
},
|
||||
|
||||
ImportDeclaration(path, asset) {
|
||||
// For each specifier, rename the local variables to point to the imported name.
|
||||
// This will be replaced by the final variable name of the resolved asset in the packager.
|
||||
var _iterator = _createForOfIteratorHelper(path.node.specifiers),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let specifier = _step.value;
|
||||
let id = getIdentifier(asset, 'import', specifier.local.name);
|
||||
rename(path.scope, specifier.local.name, id.name);
|
||||
|
||||
if (t.isImportDefaultSpecifier(specifier)) {
|
||||
asset.cacheData.imports[id.name] = [path.node.source.value, 'default'];
|
||||
} else if (t.isImportSpecifier(specifier)) {
|
||||
asset.cacheData.imports[id.name] = [path.node.source.value, specifier.imported.name];
|
||||
} else if (t.isImportNamespaceSpecifier(specifier)) {
|
||||
asset.cacheData.imports[id.name] = [path.node.source.value, '*'];
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
addImport(asset, path);
|
||||
path.remove();
|
||||
},
|
||||
|
||||
ExportDefaultDeclaration(path, asset) {
|
||||
let declaration = path.node.declaration;
|
||||
let identifier = getExportIdentifier(asset, 'default');
|
||||
let name = declaration.id ? declaration.id.name : declaration.name;
|
||||
|
||||
if (asset.cacheData.imports[name]) {
|
||||
asset.cacheData.exports['default'] = asset.cacheData.imports[name];
|
||||
identifier = t.identifier(name);
|
||||
}
|
||||
|
||||
if (hasExport(asset, name)) {
|
||||
identifier = t.identifier(name);
|
||||
} // Add assignment to exports object for namespace imports and commonjs.
|
||||
|
||||
|
||||
path.insertAfter(EXPORT_ASSIGN_TEMPLATE({
|
||||
EXPORTS: getExportsIdentifier(asset, path.scope),
|
||||
NAME: t.identifier('default'),
|
||||
LOCAL: t.clone(identifier)
|
||||
}));
|
||||
|
||||
if (t.isIdentifier(declaration)) {
|
||||
// Rename the variable being exported.
|
||||
safeRename(path, asset, declaration.name, identifier.name);
|
||||
path.remove();
|
||||
} else if (t.isExpression(declaration) || !declaration.id) {
|
||||
// Declare a variable to hold the exported value.
|
||||
path.replaceWith(t.variableDeclaration('var', [t.variableDeclarator(identifier, t.toExpression(declaration))]));
|
||||
path.scope.registerDeclaration(path);
|
||||
} else {
|
||||
// Rename the declaration to the exported name.
|
||||
safeRename(path, asset, declaration.id.name, identifier.name);
|
||||
path.replaceWith(declaration);
|
||||
}
|
||||
|
||||
if (!asset.cacheData.exports['default']) {
|
||||
asset.cacheData.exports['default'] = identifier.name;
|
||||
} // Mark the asset as an ES6 module, so we handle imports correctly in the packager.
|
||||
|
||||
|
||||
asset.cacheData.isES6Module = true;
|
||||
},
|
||||
|
||||
ExportNamedDeclaration(path, asset) {
|
||||
let _path$node3 = path.node,
|
||||
declaration = _path$node3.declaration,
|
||||
source = _path$node3.source,
|
||||
specifiers = _path$node3.specifiers;
|
||||
|
||||
if (source) {
|
||||
var _iterator2 = _createForOfIteratorHelper(specifiers),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
let specifier = _step2.value;
|
||||
let exported = specifier.exported;
|
||||
|
||||
if (t.isExportDefaultSpecifier(specifier)) {
|
||||
asset.cacheData.exports[exported.name] = [source.value, 'default'];
|
||||
} else if (t.isExportNamespaceSpecifier(specifier)) {
|
||||
asset.cacheData.exports[exported.name] = [source.value, '*'];
|
||||
} else if (t.isExportSpecifier(specifier)) {
|
||||
asset.cacheData.exports[exported.name] = [source.value, specifier.local.name];
|
||||
}
|
||||
|
||||
let id = getIdentifier(asset, 'import', exported.name);
|
||||
asset.cacheData.imports[id.name] = asset.cacheData.exports[exported.name];
|
||||
path.insertAfter(EXPORT_ASSIGN_TEMPLATE({
|
||||
EXPORTS: getExportsIdentifier(asset, path.scope),
|
||||
NAME: exported,
|
||||
LOCAL: id
|
||||
}));
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
|
||||
addImport(asset, path);
|
||||
path.remove();
|
||||
} else if (declaration) {
|
||||
path.replaceWith(declaration);
|
||||
let identifiers = t.isIdentifier(declaration.id) ? [declaration.id] : t.getBindingIdentifiers(declaration);
|
||||
|
||||
for (let id in identifiers) {
|
||||
addExport(asset, path, identifiers[id], identifiers[id]);
|
||||
}
|
||||
} else if (specifiers.length > 0) {
|
||||
var _iterator3 = _createForOfIteratorHelper(specifiers),
|
||||
_step3;
|
||||
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
let specifier = _step3.value;
|
||||
addExport(asset, path, specifier.local, specifier.exported);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator3.e(err);
|
||||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
|
||||
path.remove();
|
||||
} // Mark the asset as an ES6 module, so we handle imports correctly in the packager.
|
||||
|
||||
|
||||
asset.cacheData.isES6Module = true;
|
||||
},
|
||||
|
||||
ExportAllDeclaration(path, asset) {
|
||||
asset.cacheData.wildcards.push(path.node.source.value);
|
||||
asset.cacheData.isES6Module = true;
|
||||
path.replaceWith(EXPORT_ALL_TEMPLATE({
|
||||
OLD_NAME: getExportsIdentifier(asset),
|
||||
SOURCE: t.stringLiteral(path.node.source.value),
|
||||
ID: t.stringLiteral(asset.id)
|
||||
}));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function addImport(asset, path) {
|
||||
// Replace with a $parcel$require call so we know where to insert side effects.
|
||||
let requireCall = REQUIRE_CALL_TEMPLATE({
|
||||
ID: t.stringLiteral(asset.id),
|
||||
SOURCE: t.stringLiteral(path.node.source.value)
|
||||
}); // Hoist the call to the top of the file.
|
||||
|
||||
let lastImport = path.scope.getData('hoistedImport');
|
||||
|
||||
if (lastImport) {
|
||||
var _lastImport$insertAft = lastImport.insertAfter(requireCall);
|
||||
|
||||
var _lastImport$insertAft2 = (0, _slicedToArray2.default)(_lastImport$insertAft, 1);
|
||||
|
||||
lastImport = _lastImport$insertAft2[0];
|
||||
} else {
|
||||
var _path$parentPath$unsh = path.parentPath.unshiftContainer('body', [requireCall]);
|
||||
|
||||
var _path$parentPath$unsh2 = (0, _slicedToArray2.default)(_path$parentPath$unsh, 1);
|
||||
|
||||
lastImport = _path$parentPath$unsh2[0];
|
||||
}
|
||||
|
||||
path.scope.setData('hoistedImport', lastImport);
|
||||
}
|
||||
|
||||
function addExport(asset, path, local, exported) {
|
||||
let scope = path.scope.getProgramParent();
|
||||
let identifier = getExportIdentifier(asset, exported.name);
|
||||
|
||||
if (asset.cacheData.imports[local.name]) {
|
||||
asset.cacheData.exports[exported.name] = asset.cacheData.imports[local.name];
|
||||
identifier = t.identifier(local.name);
|
||||
}
|
||||
|
||||
if (hasExport(asset, local.name)) {
|
||||
identifier = t.identifier(local.name);
|
||||
}
|
||||
|
||||
let assignNode = EXPORT_ASSIGN_TEMPLATE({
|
||||
EXPORTS: getExportsIdentifier(asset, scope),
|
||||
NAME: t.identifier(exported.name),
|
||||
LOCAL: identifier
|
||||
});
|
||||
let binding = scope.getBinding(local.name);
|
||||
let constantViolations = binding ? binding.constantViolations.concat(path) : [path];
|
||||
|
||||
if (!asset.cacheData.exports[exported.name]) {
|
||||
asset.cacheData.exports[exported.name] = identifier.name;
|
||||
}
|
||||
|
||||
try {
|
||||
rename(scope, local.name, identifier.name);
|
||||
} catch (e) {
|
||||
throw new Error('export ' + e.message);
|
||||
}
|
||||
|
||||
constantViolations.forEach(path => path.insertAfter(t.cloneDeep(assignNode)));
|
||||
}
|
||||
|
||||
function hasExport(asset, name) {
|
||||
let exports = asset.cacheData.exports;
|
||||
return Object.keys(exports).some(k => exports[k] === name);
|
||||
}
|
||||
|
||||
function safeRename(path, asset, from, to) {
|
||||
if (from === to) {
|
||||
return;
|
||||
} // If the binding that we're renaming is constant, it's safe to rename it.
|
||||
// Otherwise, create a new binding that references the original.
|
||||
|
||||
|
||||
let binding = path.scope.getBinding(from);
|
||||
|
||||
if (binding && binding.constant) {
|
||||
rename(path.scope, from, to);
|
||||
} else {
|
||||
let _path$insertAfter = path.insertAfter(t.variableDeclaration('var', [t.variableDeclarator(t.identifier(to), t.identifier(from))])),
|
||||
_path$insertAfter2 = (0, _slicedToArray2.default)(_path$insertAfter, 1),
|
||||
decl = _path$insertAfter2[0];
|
||||
|
||||
path.scope.getBinding(from).reference(decl.get('declarations.0.init'));
|
||||
path.scope.registerDeclaration(decl);
|
||||
}
|
||||
}
|
||||
|
||||
function getExportsIdentifier(asset, scope) {
|
||||
if (scope && scope.getData('shouldWrap')) {
|
||||
return t.identifier('exports');
|
||||
} else {
|
||||
return getIdentifier(asset, 'exports');
|
||||
}
|
||||
}
|
||||
82
BACK_BACK/node_modules/parcel-bundler/lib/scope-hoisting/mangler.js
generated
vendored
Executable file
82
BACK_BACK/node_modules/parcel-bundler/lib/scope-hoisting/mangler.js
generated
vendored
Executable file
|
|
@ -0,0 +1,82 @@
|
|||
"use strict";
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const rename = require('./renamer');
|
||||
|
||||
const t = require('@babel/types');
|
||||
|
||||
const CHARSET = ('abcdefghijklmnopqrstuvwxyz' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ$_').split('');
|
||||
/**
|
||||
* This is a very specialized mangler designer to mangle only names in the top-level scope.
|
||||
* Mangling of names in other scopes happens at a file level inside workers, but we can't
|
||||
* mangle the top-level scope until scope hoisting is complete in the packager.
|
||||
*
|
||||
* Based on code from babel-minify!
|
||||
* https://github.com/babel/minify/blob/master/packages/babel-plugin-minify-mangle-names/src/charset.js
|
||||
*/
|
||||
|
||||
function mangleScope(scope) {
|
||||
let newNames = new Set(); // Sort bindings so that more frequently referenced bindings get shorter names.
|
||||
|
||||
let sortedBindings = Object.keys(scope.bindings).sort((a, b) => scope.bindings[b].referencePaths.length - scope.bindings[a].referencePaths.length);
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(sortedBindings),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let oldName = _step.value;
|
||||
let i = 0;
|
||||
let newName = '';
|
||||
|
||||
do {
|
||||
newName = getIdentifier(i++);
|
||||
} while (newNames.has(newName) || !canRename(scope, scope.bindings[oldName], newName));
|
||||
|
||||
rename(scope, oldName, newName);
|
||||
newNames.add(newName);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
}
|
||||
|
||||
function getIdentifier(num) {
|
||||
let ret = '';
|
||||
num++;
|
||||
|
||||
do {
|
||||
num--;
|
||||
ret += CHARSET[num % CHARSET.length];
|
||||
num = Math.floor(num / CHARSET.length);
|
||||
} while (num > 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function canRename(scope, binding, newName) {
|
||||
if (!t.isValidIdentifier(newName)) {
|
||||
return false;
|
||||
} // If there are any references where the parent scope has a binding
|
||||
// for the new name, we cannot rename to this name.
|
||||
|
||||
|
||||
for (let i = 0; i < binding.referencePaths.length; i++) {
|
||||
const ref = binding.referencePaths[i];
|
||||
|
||||
if (ref.scope.hasBinding(newName) || ref.scope.hasReference(newName)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = mangleScope;
|
||||
83
BACK_BACK/node_modules/parcel-bundler/lib/scope-hoisting/renamer.js
generated
vendored
Executable file
83
BACK_BACK/node_modules/parcel-bundler/lib/scope-hoisting/renamer.js
generated
vendored
Executable file
|
|
@ -0,0 +1,83 @@
|
|||
"use strict";
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const t = require('@babel/types');
|
||||
|
||||
function rename(scope, oldName, newName) {
|
||||
if (oldName === newName) {
|
||||
return;
|
||||
}
|
||||
|
||||
let binding = scope.getBinding(oldName);
|
||||
|
||||
if (!binding) {
|
||||
throw new Error("'" + oldName + "' is not defined");
|
||||
} // Rename all constant violations
|
||||
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(binding.constantViolations),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let violation = _step.value;
|
||||
let bindingIds = violation.getBindingIdentifierPaths(true, false);
|
||||
|
||||
for (let name in bindingIds) {
|
||||
if (name === oldName) {
|
||||
var _iterator3 = _createForOfIteratorHelper(bindingIds[name]),
|
||||
_step3;
|
||||
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
let idPath = _step3.value;
|
||||
idPath.node.name = newName;
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator3.e(err);
|
||||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // Rename all references
|
||||
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
var _iterator2 = _createForOfIteratorHelper(binding.referencePaths),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
let path = _step2.value;
|
||||
|
||||
if (t.isExportSpecifier(path.parent) && path.parentPath.parent.source) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (path.node.name === oldName) {
|
||||
path.node.name = newName;
|
||||
}
|
||||
} // Rename binding identifier, and update scope.
|
||||
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
|
||||
scope.removeOwnBinding(oldName);
|
||||
scope.bindings[newName] = binding;
|
||||
binding.identifier.name = newName;
|
||||
}
|
||||
|
||||
module.exports = rename;
|
||||
115
BACK_BACK/node_modules/parcel-bundler/lib/scope-hoisting/shake.js
generated
vendored
Executable file
115
BACK_BACK/node_modules/parcel-bundler/lib/scope-hoisting/shake.js
generated
vendored
Executable file
|
|
@ -0,0 +1,115 @@
|
|||
"use strict";
|
||||
|
||||
const t = require('@babel/types');
|
||||
/**
|
||||
* This is a small small implementation of dead code removal specialized to handle
|
||||
* removing unused exports. All other dead code removal happens in workers on each
|
||||
* individual file by babel-minify.
|
||||
*/
|
||||
|
||||
|
||||
function treeShake(scope) {
|
||||
// Keep passing over all bindings in the scope until we don't remove any.
|
||||
// This handles cases where we remove one binding which had a reference to
|
||||
// another one. That one will get removed in the next pass if it is now unreferenced.
|
||||
let removed;
|
||||
|
||||
do {
|
||||
removed = false; // Recrawl to get all bindings.
|
||||
|
||||
scope.crawl();
|
||||
Object.keys(scope.bindings).forEach(name => {
|
||||
let binding = getUnusedBinding(scope.path, name); // If it is not safe to remove the binding don't touch it.
|
||||
|
||||
if (!binding) {
|
||||
return;
|
||||
} // Remove the binding and all references to it.
|
||||
|
||||
|
||||
binding.path.remove();
|
||||
binding.referencePaths.concat(binding.constantViolations).forEach(remove);
|
||||
scope.removeBinding(name);
|
||||
removed = true;
|
||||
});
|
||||
} while (removed);
|
||||
}
|
||||
|
||||
module.exports = treeShake; // Check if a binding is safe to remove and returns it if it is.
|
||||
|
||||
function getUnusedBinding(path, name) {
|
||||
let binding = path.scope.getBinding(name);
|
||||
|
||||
if (!binding) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let pure = isPure(binding);
|
||||
|
||||
if (!binding.referenced && pure) {
|
||||
return binding;
|
||||
} // Is there any references which aren't simple assignments?
|
||||
|
||||
|
||||
let bailout = binding.referencePaths.some(path => !isExportAssignment(path) && !isUnusedWildcard(path));
|
||||
|
||||
if (!bailout && pure) {
|
||||
return binding;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function isPure(binding) {
|
||||
if (binding.path.isVariableDeclarator() && binding.path.get('id').isIdentifier()) {
|
||||
let init = binding.path.get('init');
|
||||
return init.isPure() || init.isIdentifier() || init.isThisExpression();
|
||||
}
|
||||
|
||||
return binding.path.isPure();
|
||||
}
|
||||
|
||||
function isExportAssignment(path) {
|
||||
return (// match "path.any = any;"
|
||||
path.parentPath.isMemberExpression() && path.parentPath.parentPath.isAssignmentExpression() && path.parentPath.parentPath.node.left === path.parentPath.node
|
||||
);
|
||||
}
|
||||
|
||||
function isUnusedWildcard(path) {
|
||||
let parent = path.parent;
|
||||
return (// match `$parcel$exportWildcard` calls
|
||||
t.isCallExpression(parent) && t.isIdentifier(parent.callee, {
|
||||
name: '$parcel$exportWildcard'
|
||||
}) && parent.arguments[0] === path.node && // check if the $id$exports variable is used
|
||||
!getUnusedBinding(path, parent.arguments[1].name)
|
||||
);
|
||||
}
|
||||
|
||||
function remove(path) {
|
||||
if (path.isAssignmentExpression()) {
|
||||
if (path.parentPath.isSequenceExpression()) {
|
||||
if (path.parent.expressions.length == 1) {
|
||||
// replace sequence expression with it's sole child
|
||||
path.parentPath.replaceWith(path);
|
||||
remove(path.parentPath);
|
||||
} else {
|
||||
path.remove();
|
||||
}
|
||||
} else if (!path.parentPath.isExpressionStatement()) {
|
||||
path.replaceWith(path.node.right);
|
||||
} else {
|
||||
path.remove();
|
||||
}
|
||||
} else if (isExportAssignment(path)) {
|
||||
remove(path.parentPath.parentPath);
|
||||
} else if (isUnusedWildcard(path)) {
|
||||
remove(path.parentPath);
|
||||
} else if (!path.removed) {
|
||||
if (path.parentPath.isSequenceExpression() && path.parent.expressions.length === 1) {
|
||||
// replace sequence expression with it's sole child
|
||||
path.parentPath.replaceWith(path);
|
||||
remove(path.parentPath);
|
||||
} else {
|
||||
path.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
19
BACK_BACK/node_modules/parcel-bundler/lib/scope-hoisting/utils.js
generated
vendored
Executable file
19
BACK_BACK/node_modules/parcel-bundler/lib/scope-hoisting/utils.js
generated
vendored
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
"use strict";
|
||||
|
||||
const t = require('@babel/types');
|
||||
|
||||
function getName(asset, type, ...rest) {
|
||||
return '$' + t.toIdentifier(asset.id) + '$' + type + (rest.length ? '$' + rest.map(name => name === 'default' ? name : t.toIdentifier(name)).join('$') : '');
|
||||
}
|
||||
|
||||
function getIdentifier(asset, type, ...rest) {
|
||||
return t.identifier(getName(asset, type, ...rest));
|
||||
}
|
||||
|
||||
function getExportIdentifier(asset, name) {
|
||||
return getIdentifier(asset, 'export', name);
|
||||
}
|
||||
|
||||
exports.getName = getName;
|
||||
exports.getIdentifier = getIdentifier;
|
||||
exports.getExportIdentifier = getExportIdentifier;
|
||||
101
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/astConverter.js
generated
vendored
Executable file
101
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/astConverter.js
generated
vendored
Executable file
|
|
@ -0,0 +1,101 @@
|
|||
"use strict";
|
||||
|
||||
const traverse = require('@babel/traverse').default; // Convert between babel 7 and babel 6 AST
|
||||
// More info on the AST Changes: https://babeljs.io/docs/en/v7-migration-api#ast-changes
|
||||
|
||||
|
||||
function babel7toBabel6(ast) {
|
||||
const visitor = {
|
||||
ArrowFunctionExpression: node => {
|
||||
node.expression = node.body.type !== 'BlockStatement';
|
||||
},
|
||||
ExistsTypeAnnotation: node => {
|
||||
node.type = 'ExistentialTypeParam';
|
||||
},
|
||||
NumberLiteralTypeAnnotation: node => {
|
||||
node.type = 'NumericLiteralTypeAnnotation';
|
||||
},
|
||||
ObjectTypeIndexer: node => {
|
||||
node.end++;
|
||||
node.loc.end.column++;
|
||||
},
|
||||
ForOfStatement: node => {
|
||||
node.type = 'ForAwaitStatement';
|
||||
delete node.await;
|
||||
},
|
||||
SpreadElement: (node, path) => {
|
||||
if (path.parentPath.isObjectExpression() || path.parentPath.isArrayExpression()) {
|
||||
node.type = 'SpreadProperty';
|
||||
}
|
||||
},
|
||||
RestElement: (node, path) => {
|
||||
if (path.parentPath.isObjectPattern() || path.parentPath.isArrayPattern()) {
|
||||
node.type = 'RestProperty';
|
||||
}
|
||||
}
|
||||
};
|
||||
traverse(ast, {
|
||||
enter(path) {
|
||||
if (path.node.variance && path.node.variance.type === 'Variance') {
|
||||
path.node.variance = path.node.variance.kind;
|
||||
}
|
||||
|
||||
let visitorFunc = visitor[path.node.type];
|
||||
|
||||
if (visitorFunc) {
|
||||
visitorFunc(path.node, path);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return ast;
|
||||
}
|
||||
|
||||
function babel6toBabel7(ast) {
|
||||
const visitor = {
|
||||
ArrowFunctionExpression: node => {
|
||||
delete node.expression;
|
||||
},
|
||||
ExistentialTypeParam: node => {
|
||||
node.type = 'ExistsTypeAnnotation';
|
||||
},
|
||||
NumericLiteralTypeAnnotation: node => {
|
||||
node.type = 'NumberLiteralTypeAnnotation';
|
||||
},
|
||||
ObjectTypeIndexer: node => {
|
||||
node.end--;
|
||||
node.loc.end.column--;
|
||||
},
|
||||
ForAwaitStatement: node => {
|
||||
node.type = 'ForOfStatement';
|
||||
node.await = true;
|
||||
},
|
||||
SpreadProperty: node => {
|
||||
node.type = 'SpreadElement';
|
||||
},
|
||||
RestProperty: node => {
|
||||
node.type = 'RestElement';
|
||||
}
|
||||
};
|
||||
traverse(ast, {
|
||||
enter(path) {
|
||||
if (path.node.variance && typeof path.node.variance === 'string') {
|
||||
path.node.variance = {
|
||||
type: 'VarianceNode',
|
||||
kind: path.node.variance
|
||||
};
|
||||
}
|
||||
|
||||
let visitorFunc = visitor[path.node.type];
|
||||
|
||||
if (visitorFunc) {
|
||||
visitorFunc(path.node);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return ast;
|
||||
}
|
||||
|
||||
exports.babel7toBabel6 = babel7toBabel6;
|
||||
exports.babel6toBabel7 = babel6toBabel7;
|
||||
55
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/babel6.js
generated
vendored
Executable file
55
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/babel6.js
generated
vendored
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const localRequire = require('../../utils/localRequire');
|
||||
|
||||
const _require = require('./astConverter'),
|
||||
babel6toBabel7 = _require.babel6toBabel7;
|
||||
|
||||
function babel6(_x, _x2) {
|
||||
return _babel.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _babel() {
|
||||
_babel = (0, _asyncToGenerator2.default)(function* (asset, options) {
|
||||
let babel = yield localRequire('babel-core', asset.name);
|
||||
let config = options.config;
|
||||
config.code = false;
|
||||
config.ast = true;
|
||||
config.filename = asset.name;
|
||||
config.babelrc = false;
|
||||
config.parserOpts = Object.assign({}, config.parserOpts, {
|
||||
allowReturnOutsideFunction: true,
|
||||
allowHashBang: true,
|
||||
ecmaVersion: Infinity,
|
||||
strictMode: false,
|
||||
sourceType: 'module',
|
||||
locations: true
|
||||
}); // Passing a list of plugins as part of parserOpts seems to override any custom
|
||||
// syntax plugins a user might have added (e.g. decorators). We add dynamicImport
|
||||
// using a plugin instead.
|
||||
|
||||
config.plugins = (config.plugins || []).concat(dynamicImport);
|
||||
let res = babel.transform(asset.contents, config);
|
||||
|
||||
if (res.ast) {
|
||||
asset.ast = babel6toBabel7(res.ast);
|
||||
asset.isAstDirty = true;
|
||||
}
|
||||
});
|
||||
return _babel.apply(this, arguments);
|
||||
}
|
||||
|
||||
function dynamicImport() {
|
||||
return {
|
||||
manipulateOptions(opts, parserOpts) {
|
||||
parserOpts.plugins.push('dynamicImport');
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = babel6;
|
||||
48
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/babel7.js
generated
vendored
Executable file
48
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/babel7.js
generated
vendored
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const localRequire = require('../../utils/localRequire');
|
||||
|
||||
function babel7(_x, _x2) {
|
||||
return _babel.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _babel() {
|
||||
_babel = (0, _asyncToGenerator2.default)(function* (asset, options) {
|
||||
let config = options.config; // 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 = options.internal ? require('@babel/core') : yield localRequire('@babel/core', asset.name);
|
||||
let pkg = yield asset.getPackage();
|
||||
config.code = false;
|
||||
config.ast = true;
|
||||
config.filename = asset.name;
|
||||
config.cwd = pkg ? pkg.pkgdir : asset.options.rootDir;
|
||||
config.babelrc = false;
|
||||
config.configFile = false;
|
||||
config.parserOpts = Object.assign({}, config.parserOpts, {
|
||||
allowReturnOutsideFunction: true,
|
||||
strictMode: false,
|
||||
sourceType: 'module',
|
||||
plugins: ['dynamicImport']
|
||||
});
|
||||
let res;
|
||||
|
||||
if (asset.ast) {
|
||||
res = babel.transformFromAst(asset.ast, asset.contents, config);
|
||||
} else {
|
||||
res = babel.transformSync(asset.contents, config);
|
||||
}
|
||||
|
||||
if (res.ast) {
|
||||
asset.ast = res.ast;
|
||||
asset.isAstDirty = true;
|
||||
}
|
||||
});
|
||||
return _babel.apply(this, arguments);
|
||||
}
|
||||
|
||||
module.exports = babel7;
|
||||
367
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/babelrc.js
generated
vendored
Executable file
367
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/babelrc.js
generated
vendored
Executable file
|
|
@ -0,0 +1,367 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const semver = require('semver');
|
||||
|
||||
const logger = require('@parcel/logger');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const localRequire = require('../../utils/localRequire');
|
||||
|
||||
const installPackage = require('../../utils/installPackage');
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
const micromatch = require('micromatch');
|
||||
|
||||
function getBabelConfig(_x, _x2) {
|
||||
return _getBabelConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getBabelConfig() {
|
||||
_getBabelConfig = (0, _asyncToGenerator2.default)(function* (asset, isSource) {
|
||||
let config = yield getBabelRc(asset, isSource);
|
||||
|
||||
if (!config) {
|
||||
return null;
|
||||
} // Ignore if the config is empty.
|
||||
|
||||
|
||||
if ((!config.plugins || config.plugins.length === 0) && (!config.presets || config.presets.length === 0)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let plugins = yield installPlugins(asset, config);
|
||||
let babelVersion = yield getBabelVersion(asset, plugins);
|
||||
return {
|
||||
babelVersion,
|
||||
config
|
||||
};
|
||||
});
|
||||
return _getBabelConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
module.exports = getBabelConfig;
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
function getBabelRc(_x3, _x4) {
|
||||
return _getBabelRc.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getBabelRc() {
|
||||
_getBabelRc = (0, _asyncToGenerator2.default)(function* (asset, isSource) {
|
||||
// Support legacy browserify packages
|
||||
let pkg = yield asset.getPackage();
|
||||
let browserify = pkg && pkg.browserify;
|
||||
|
||||
if (browserify && Array.isArray(browserify.transform)) {
|
||||
// Look for babelify in the browserify transform list
|
||||
let babelify = browserify.transform.find(t => (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 ? findBabelRc(asset) : null;
|
||||
} // If this asset is not in node_modules, always use the .babelrc
|
||||
|
||||
|
||||
if (isSource) {
|
||||
return findBabelRc(asset);
|
||||
} // Otherwise, don't load .babelrc for node_modules.
|
||||
// See https://github.com/parcel-bundler/parcel/issues/13.
|
||||
|
||||
|
||||
return null;
|
||||
});
|
||||
return _getBabelRc.apply(this, arguments);
|
||||
}
|
||||
|
||||
function findBabelRc(_x5) {
|
||||
return _findBabelRc.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _findBabelRc() {
|
||||
_findBabelRc = (0, _asyncToGenerator2.default)(function* (asset) {
|
||||
// TODO: use the babel API to do this config resolution and support all of its features.
|
||||
// This is not currently possible because babel tries to actually load plugins and presets
|
||||
// while resolving the config, but those plugins might not be installed yet.
|
||||
let config = yield asset.getConfig(['.babelrc', '.babelrc.js'], {
|
||||
packageKey: 'babel'
|
||||
});
|
||||
|
||||
if (!config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof config === 'function') {
|
||||
// We cannot support function configs since there is no exposed method in babel
|
||||
// to create the API that is passed to them...
|
||||
throw new Error('Parcel does not support function configs in .babelrc.js yet.');
|
||||
}
|
||||
|
||||
for (var _i = 0, _arr = ['extends', 'overrides', 'test', 'include', 'exclude']; _i < _arr.length; _i++) {
|
||||
let key = _arr[_i];
|
||||
|
||||
if (config[key]) {
|
||||
throw new Error(`Parcel does not support babel 7 advanced configuration option "${key}" yet.`);
|
||||
}
|
||||
} // Support ignore/only config options.
|
||||
|
||||
|
||||
if (shouldIgnore(asset, config)) {
|
||||
return null;
|
||||
} // Support .babelignore
|
||||
|
||||
|
||||
let ignoreConfig = yield getIgnoreConfig(asset);
|
||||
|
||||
if (ignoreConfig && shouldIgnore(asset, ignoreConfig)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return config;
|
||||
});
|
||||
return _findBabelRc.apply(this, arguments);
|
||||
}
|
||||
|
||||
function getIgnoreConfig(_x6) {
|
||||
return _getIgnoreConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getIgnoreConfig() {
|
||||
_getIgnoreConfig = (0, _asyncToGenerator2.default)(function* (asset) {
|
||||
let ignoreFile = yield asset.getConfig(['.babelignore'], {
|
||||
load: false
|
||||
});
|
||||
|
||||
if (!ignoreFile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let data = yield fs.readFile(ignoreFile, 'utf8');
|
||||
let patterns = data.split('\n').map(line => line.replace(/#.*$/, '').trim()).filter(Boolean);
|
||||
return {
|
||||
ignore: patterns
|
||||
};
|
||||
});
|
||||
return _getIgnoreConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
function shouldIgnore(asset, config) {
|
||||
if (config.ignore && matchesPatterns(config.ignore, asset.name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (config.only && !matchesPatterns(config.only, asset.name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function matchesPatterns(patterns, path) {
|
||||
return patterns.some(pattern => {
|
||||
if (typeof pattern === 'function') {
|
||||
return !!pattern(path);
|
||||
}
|
||||
|
||||
if (typeof pattern === 'string') {
|
||||
return micromatch.isMatch(path, '**/' + pattern + '/**');
|
||||
}
|
||||
|
||||
return pattern.test(path);
|
||||
});
|
||||
}
|
||||
|
||||
function getBabelVersion(_x7, _x8) {
|
||||
return _getBabelVersion.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getBabelVersion() {
|
||||
_getBabelVersion = (0, _asyncToGenerator2.default)(function* (asset, plugins) {
|
||||
// Check the package.json to determine the babel version that is installed
|
||||
let pkg = yield asset.getPackage();
|
||||
let babelLegacy = getDependency(pkg, 'babel-core');
|
||||
let babelModern = getDependency(pkg, '@babel/core');
|
||||
|
||||
if (babelModern) {
|
||||
return getMaxMajor(babelModern);
|
||||
}
|
||||
|
||||
if (babelLegacy) {
|
||||
return 6;
|
||||
} // No version was installed. This is either an old app where we didn't require a version to be installed,
|
||||
// or a new app that just added a .babelrc without manually installing a version of babel core.
|
||||
// We will attempt to infer a verison of babel and install it based on the dependencies of the plugins
|
||||
// in the config. This should only happen once since we save babel core into package.json for subsequent runs.
|
||||
|
||||
|
||||
let inferred = yield inferBabelVersion(asset, plugins);
|
||||
let name = inferred === 6 ? 'babel-core' : `@babel/core`;
|
||||
yield installPackage(name, asset.name);
|
||||
return inferred;
|
||||
});
|
||||
return _getBabelVersion.apply(this, arguments);
|
||||
}
|
||||
|
||||
function getDependency(pkg, dep) {
|
||||
return pkg.dependencies && pkg.dependencies[dep] || pkg.peerDependencies && pkg.peerDependencies[dep] || pkg.devDependencies && pkg.devDependencies[dep];
|
||||
} // Core babel packages we use to infer the major version of babel to use.
|
||||
|
||||
|
||||
const CORE_DEPS = new Set(['@babel/core', '@babel/runtime', '@babel/template', '@babel/traverse', '@babel/types', '@babel/parser', '@babel/cli', '@babel/register', '@babel/generator', 'babel-core', 'babel-runtime', 'babel-template', 'babel-traverse', 'babel-types', 'babylon', 'babel-cli', 'babel-register', 'babel-generator']);
|
||||
|
||||
function inferBabelVersion(_x9, _x10) {
|
||||
return _inferBabelVersion.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _inferBabelVersion() {
|
||||
_inferBabelVersion = (0, _asyncToGenerator2.default)(function* (asset, plugins) {
|
||||
// Attempt to determine version based on dependencies of plugins
|
||||
let version;
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(plugins),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
let pkg = _step.value;
|
||||
|
||||
if (!pkg) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var _iterator2 = _createForOfIteratorHelper(CORE_DEPS),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
let name = _step2.value;
|
||||
let dep = getDependency(pkg, name);
|
||||
|
||||
if (dep) {
|
||||
// Parse version range (ignore prerelease), and ensure it overlaps with the existing version (if any)
|
||||
let range = new semver.Range(dep.replace(/-.*(\s|\|\||$)?/, ''));
|
||||
|
||||
if (version && !version.intersects(range)) {
|
||||
throw new Error('Conflicting babel versions found in .babelrc. Make sure all of your plugins and presets depend on the same major version of babel.');
|
||||
}
|
||||
|
||||
version = range;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
} // Find the maximum major version allowed in the range and use that.
|
||||
// e.g. if ^6 || ^7 were specified, use 7.
|
||||
|
||||
} catch (err) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
version = getMaxMajor(version);
|
||||
|
||||
if (!version) {
|
||||
logger.warn(`Could not infer babel version. Defaulting to babel 7. Please add either babel-core or @babel/core as a dependency.`);
|
||||
version = 7;
|
||||
}
|
||||
|
||||
return version;
|
||||
});
|
||||
return _inferBabelVersion.apply(this, arguments);
|
||||
}
|
||||
|
||||
function getPluginName(p) {
|
||||
return Array.isArray(p) ? p[0] : p;
|
||||
}
|
||||
|
||||
function getMaxMajor(version) {
|
||||
try {
|
||||
let range = new semver.Range(version);
|
||||
let sorted = range.set.sort((a, b) => a[0].semver.compare(b[0].semver));
|
||||
return semver.major(sorted.pop()[0].semver.version);
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function installPlugins(_x11, _x12) {
|
||||
return _installPlugins.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _installPlugins() {
|
||||
_installPlugins = (0, _asyncToGenerator2.default)(function* (asset, babelrc) {
|
||||
let presets = (babelrc.presets || []).map(p => resolveModule('preset', getPluginName(p), asset.name));
|
||||
let plugins = (babelrc.plugins || []).map(p => resolveModule('plugin', getPluginName(p), asset.name));
|
||||
return Promise.all([...presets, ...plugins]);
|
||||
});
|
||||
return _installPlugins.apply(this, arguments);
|
||||
}
|
||||
|
||||
function resolveModule(_x13, _x14, _x15) {
|
||||
return _resolveModule.apply(this, arguments);
|
||||
} // Copied from https://github.com/babel/babel/blob/3a399d1eb907df520f2b85bf9ddbc6533e256f6d/packages/babel-core/src/config/files/plugins.js#L61
|
||||
|
||||
|
||||
function _resolveModule() {
|
||||
_resolveModule = (0, _asyncToGenerator2.default)(function* (type, name, path) {
|
||||
try {
|
||||
name = standardizeName(type, name);
|
||||
|
||||
let _yield$localRequire$r = yield localRequire.resolve(name, path),
|
||||
_yield$localRequire$r2 = (0, _slicedToArray2.default)(_yield$localRequire$r, 2),
|
||||
pkg = _yield$localRequire$r2[1];
|
||||
|
||||
return pkg;
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
return _resolveModule.apply(this, arguments);
|
||||
}
|
||||
|
||||
const EXACT_RE = /^module:/;
|
||||
const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/;
|
||||
const BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-preset-)/;
|
||||
const BABEL_PLUGIN_ORG_RE = /^(@babel\/)(?!plugin-|[^/]+\/)/;
|
||||
const BABEL_PRESET_ORG_RE = /^(@babel\/)(?!preset-|[^/]+\/)/;
|
||||
const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-plugin(?:-|\/|$)|[^/]+\/)/;
|
||||
const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-preset(?:-|\/|$)|[^/]+\/)/;
|
||||
const OTHER_ORG_DEFAULT_RE = /^(@(?!babel$)[^/]+)$/;
|
||||
|
||||
function standardizeName(type, name) {
|
||||
// Let absolute and relative paths through.
|
||||
if (path.isAbsolute(name)) return name;
|
||||
const isPreset = type === 'preset';
|
||||
return name // foo -> babel-preset-foo
|
||||
.replace(isPreset ? BABEL_PRESET_PREFIX_RE : BABEL_PLUGIN_PREFIX_RE, `babel-${type}-`) // @babel/es2015 -> @babel/preset-es2015
|
||||
.replace(isPreset ? BABEL_PRESET_ORG_RE : BABEL_PLUGIN_ORG_RE, `$1${type}-`) // @foo/mypreset -> @foo/babel-preset-mypreset
|
||||
.replace(isPreset ? OTHER_PRESET_ORG_RE : OTHER_PLUGIN_ORG_RE, `$1babel-${type}-`) // @foo -> @foo/babel-preset
|
||||
.replace(OTHER_ORG_DEFAULT_RE, `$1/babel-${type}`) // module:mypreset -> mypreset
|
||||
.replace(EXACT_RE, '');
|
||||
}
|
||||
111
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/config.js
generated
vendored
Executable file
111
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/config.js
generated
vendored
Executable file
|
|
@ -0,0 +1,111 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const getBabelRc = require('./babelrc');
|
||||
|
||||
const getEnvConfig = require('./env');
|
||||
|
||||
const getJSXConfig = require('./jsx');
|
||||
|
||||
const getFlowConfig = require('./flow');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
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,
|
||||
'@babel/preset-env': true,
|
||||
'@babel/env': true
|
||||
};
|
||||
|
||||
function getBabelConfig(_x) {
|
||||
return _getBabelConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getBabelConfig() {
|
||||
_getBabelConfig = (0, _asyncToGenerator2.default)(function* (asset) {
|
||||
// Consider the module source code rather than precompiled if the resolver
|
||||
// used the `source` field, or it is not in node_modules.
|
||||
let pkg = yield asset.getPackage();
|
||||
let isSource = !!(pkg && pkg.source && (yield fs.realpath(asset.name)) !== asset.name) || !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 = yield getJSXConfig(asset, isSource);
|
||||
let flowConfig = getFlowConfig(asset, isSource);
|
||||
|
||||
if (babelrc && envConfig) {
|
||||
// Filter out presets that are already applied by @babel/preset-env
|
||||
if (Array.isArray(babelrc.config.presets)) {
|
||||
babelrc.config.presets = babelrc.config.presets.filter(preset => {
|
||||
return !ENV_PRESETS[getPluginName(preset)];
|
||||
});
|
||||
} // Filter out plugins that are already applied by @babel/preset-env
|
||||
|
||||
|
||||
if (Array.isArray(babelrc.config.plugins)) {
|
||||
babelrc.config.plugins = babelrc.config.plugins.filter(plugin => {
|
||||
return !ENV_PLUGINS[getPluginName(plugin)];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let result = {};
|
||||
mergeConfigs(result, babelrc);
|
||||
mergeConfigs(result, envConfig); // Add JSX config if it isn't already specified in the babelrc
|
||||
|
||||
let hasReact = babelrc && (hasPlugin(babelrc.config.presets, ['react', '@babel/react', '@babel/preset-react']) || hasPlugin(babelrc.config.plugins, ['transform-react-jsx', '@babel/transform-react-jsx', '@babel/plugin-transform-react-jsx']));
|
||||
|
||||
if (!hasReact) {
|
||||
mergeConfigs(result, jsxConfig);
|
||||
} // Add Flow stripping config if it isn't already specified in the babelrc
|
||||
|
||||
|
||||
let hasFlow = babelrc && hasPlugin(babelrc.config.plugins, ['transform-flow-strip-types', '@babel/transform-flow-strip-types', '@babel/plugin-transform-flow-strip-types']);
|
||||
|
||||
if (!hasFlow) {
|
||||
mergeConfigs(result, flowConfig);
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
return _getBabelConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
module.exports = getBabelConfig;
|
||||
|
||||
function mergeConfigs(result, config) {
|
||||
if (!config || (!config.config.presets || config.config.presets.length === 0) && (!config.config.plugins || config.config.plugins.length === 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let merged = result[config.babelVersion];
|
||||
|
||||
if (merged) {
|
||||
merged.config.presets = (merged.config.presets || []).concat(config.config.presets || []);
|
||||
merged.config.plugins = (merged.config.plugins || []).concat(config.config.plugins || []);
|
||||
} else {
|
||||
result[config.babelVersion] = config;
|
||||
}
|
||||
}
|
||||
|
||||
function hasPlugin(arr, plugins) {
|
||||
return Array.isArray(arr) && arr.some(p => plugins.includes(getPluginName(p)));
|
||||
}
|
||||
|
||||
function getPluginName(p) {
|
||||
return Array.isArray(p) ? p[0] : p;
|
||||
}
|
||||
95
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/env.js
generated
vendored
Executable file
95
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/env.js
generated
vendored
Executable file
|
|
@ -0,0 +1,95 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const presetEnv = require('@babel/preset-env');
|
||||
|
||||
const getTargetEngines = require('../../utils/getTargetEngines');
|
||||
|
||||
const babelCore = require('@babel/core');
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
function getEnvConfig(_x, _x2) {
|
||||
return _getEnvConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getEnvConfig() {
|
||||
_getEnvConfig = (0, _asyncToGenerator2.default)(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(p => p[0]));
|
||||
targetEnv = targetEnv.filter(plugin => {
|
||||
return !sourcePlugins.has(plugin[0]);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
internal: true,
|
||||
babelVersion: 7,
|
||||
config: {
|
||||
plugins: targetEnv
|
||||
}
|
||||
};
|
||||
});
|
||||
return _getEnvConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
const envCache = new Map();
|
||||
|
||||
function getEnvPlugins(_x3) {
|
||||
return _getEnvPlugins.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getEnvPlugins() {
|
||||
_getEnvPlugins = (0, _asyncToGenerator2.default)(function* (targets, useBuiltIns = false) {
|
||||
if (!targets) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let key = JSON.stringify(targets);
|
||||
|
||||
if (envCache.has(key)) {
|
||||
return envCache.get(key);
|
||||
}
|
||||
|
||||
const options = {
|
||||
targets,
|
||||
modules: false,
|
||||
useBuiltIns: useBuiltIns ? 'entry' : false,
|
||||
shippedProposals: true
|
||||
};
|
||||
|
||||
if (useBuiltIns) {
|
||||
options.corejs = 2;
|
||||
}
|
||||
|
||||
let plugins = presetEnv.default({
|
||||
version: babelCore.version,
|
||||
assertVersion: () => true
|
||||
}, options).plugins;
|
||||
envCache.set(key, plugins);
|
||||
return plugins;
|
||||
});
|
||||
return _getEnvPlugins.apply(this, arguments);
|
||||
}
|
||||
|
||||
module.exports = getEnvConfig;
|
||||
20
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/flow.js
generated
vendored
Executable file
20
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/flow.js
generated
vendored
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
"use strict";
|
||||
|
||||
/**
|
||||
* Generates a babel config for stripping away Flow types.
|
||||
*/
|
||||
function getFlowConfig(asset) {
|
||||
if (/^(\/{2}|\/\*+) *@flow/.test(asset.contents.substring(0, 20))) {
|
||||
return {
|
||||
internal: true,
|
||||
babelVersion: 7,
|
||||
config: {
|
||||
plugins: [[require('@babel/plugin-transform-flow-strip-types')]]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = getFlowConfig;
|
||||
95
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/jsx.js
generated
vendored
Executable file
95
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/jsx.js
generated
vendored
Executable file
|
|
@ -0,0 +1,95 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const JSX_EXTENSIONS = {
|
||||
'.jsx': true,
|
||||
'.tsx': true
|
||||
};
|
||||
const JSX_PRAGMA = {
|
||||
react: 'React.createElement',
|
||||
preact: 'h',
|
||||
nervjs: 'Nerv.createElement',
|
||||
hyperapp: 'h'
|
||||
};
|
||||
|
||||
function createJSXRegexFor(dependency) {
|
||||
// result looks like /from\s+[`"']react[`"']|require\([`"']react[`"']\)/
|
||||
return new RegExp(`from\\s+[\`"']${dependency}[\`"']|require\\([\`"']${dependency}[\`"']\\)`);
|
||||
}
|
||||
/**
|
||||
* Solves a use case when JSX is used in .js files, but
|
||||
* package.json is empty or missing yet and therefore pragma cannot
|
||||
* be determined based on pkg.dependencies / pkg.devDependencies
|
||||
*/
|
||||
|
||||
|
||||
const cacheJsxRegexFor = {};
|
||||
|
||||
function maybeCreateFallbackPragma(asset) {
|
||||
for (const dep in JSX_PRAGMA) {
|
||||
let regex = cacheJsxRegexFor[dep];
|
||||
|
||||
if (!regex) {
|
||||
regex = createJSXRegexFor(dep);
|
||||
cacheJsxRegexFor[dep] = regex;
|
||||
}
|
||||
|
||||
if (asset.contents.match(regex)) {
|
||||
return JSX_PRAGMA[dep];
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Generates a babel config for JSX. Attempts to detect react or react-like libraries
|
||||
* and changes the pragma accordingly.
|
||||
*/
|
||||
|
||||
|
||||
function getJSXConfig(_x, _x2) {
|
||||
return _getJSXConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getJSXConfig() {
|
||||
_getJSXConfig = (0, _asyncToGenerator2.default)(function* (asset, isSourceModule) {
|
||||
// Don't enable JSX in node_modules
|
||||
if (!isSourceModule) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let pkg = yield asset.getPackage(); // Find a dependency that we can map to a JSX pragma
|
||||
|
||||
let pragma = null;
|
||||
|
||||
for (let dep in JSX_PRAGMA) {
|
||||
if (pkg && (pkg.dependencies && pkg.dependencies[dep] || pkg.devDependencies && pkg.devDependencies[dep])) {
|
||||
pragma = JSX_PRAGMA[dep];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pragma) {
|
||||
pragma = maybeCreateFallbackPragma(asset);
|
||||
}
|
||||
|
||||
if (pragma || JSX_EXTENSIONS[path.extname(asset.name)]) {
|
||||
return {
|
||||
internal: true,
|
||||
babelVersion: 7,
|
||||
config: {
|
||||
plugins: [[require('@babel/plugin-transform-react-jsx'), {
|
||||
pragma,
|
||||
pragmaFrag: 'React.Fragment'
|
||||
}]]
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
return _getJSXConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
module.exports = getJSXConfig;
|
||||
34
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/transform.js
generated
vendored
Executable file
34
BACK_BACK/node_modules/parcel-bundler/lib/transforms/babel/transform.js
generated
vendored
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const babel6 = require('./babel6');
|
||||
|
||||
const babel7 = require('./babel7');
|
||||
|
||||
const getBabelConfig = require('./config');
|
||||
|
||||
function babelTransform(_x) {
|
||||
return _babelTransform.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _babelTransform() {
|
||||
_babelTransform = (0, _asyncToGenerator2.default)(function* (asset) {
|
||||
let config = yield getBabelConfig(asset);
|
||||
|
||||
if (config[6]) {
|
||||
yield babel6(asset, config[6]);
|
||||
}
|
||||
|
||||
if (config[7]) {
|
||||
yield babel7(asset, config[7]);
|
||||
}
|
||||
|
||||
return asset.ast;
|
||||
});
|
||||
return _babelTransform.apply(this, arguments);
|
||||
}
|
||||
|
||||
module.exports = babelTransform;
|
||||
30
BACK_BACK/node_modules/parcel-bundler/lib/transforms/htmlnano.js
generated
vendored
Executable file
30
BACK_BACK/node_modules/parcel-bundler/lib/transforms/htmlnano.js
generated
vendored
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const posthtml = require('posthtml');
|
||||
|
||||
const htmlnano = require('htmlnano');
|
||||
|
||||
module.exports = /*#__PURE__*/function () {
|
||||
var _ref = (0, _asyncToGenerator2.default)(function* (asset) {
|
||||
yield asset.parseIfNeeded();
|
||||
let htmlNanoConfig = Object.assign({}, yield asset.getConfig(['.htmlnanorc', '.htmlnanorc.js'], {
|
||||
packageKey: 'htmlnano'
|
||||
}), {
|
||||
minifyCss: false,
|
||||
minifyJs: false
|
||||
});
|
||||
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);
|
||||
};
|
||||
}();
|
||||
142
BACK_BACK/node_modules/parcel-bundler/lib/transforms/postcss.js
generated
vendored
Executable file
142
BACK_BACK/node_modules/parcel-bundler/lib/transforms/postcss.js
generated
vendored
Executable file
|
|
@ -0,0 +1,142 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const localRequire = require('../utils/localRequire');
|
||||
|
||||
const loadPlugins = require('../utils/loadPlugins');
|
||||
|
||||
const md5 = require('../utils/md5');
|
||||
|
||||
const postcss = require('postcss');
|
||||
|
||||
const FileSystemLoader = require('css-modules-loader-core/lib/file-system-loader');
|
||||
|
||||
const semver = require('semver');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
module.exports = /*#__PURE__*/function () {
|
||||
var _ref = (0, _asyncToGenerator2.default)(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;
|
||||
asset.sourceMap = res.map ? res.map.toJSON() : null;
|
||||
});
|
||||
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
|
||||
function getConfig(_x2) {
|
||||
return _getConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getConfig() {
|
||||
_getConfig = (0, _asyncToGenerator2.default)(function* (asset) {
|
||||
let config = yield asset.getConfig(['.postcssrc', '.postcssrc.json', '.postcssrc.js', 'postcss.config.js'], {
|
||||
packageKey: 'postcss'
|
||||
});
|
||||
let enableModules = asset.options.rendition && asset.options.rendition.modules;
|
||||
|
||||
if (!config && !asset.options.minify && !enableModules) {
|
||||
return;
|
||||
}
|
||||
|
||||
config = config || {};
|
||||
|
||||
if (asset.options.sourceMaps) {
|
||||
config.map = {
|
||||
inline: false,
|
||||
annotation: false,
|
||||
sourcesContent: true
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof config !== 'object') {
|
||||
throw new Error('PostCSS config should be an object.');
|
||||
}
|
||||
|
||||
let postcssModulesConfig = {
|
||||
getJSON: (filename, json) => asset.cssModules = json,
|
||||
Loader: createLoader(asset),
|
||||
generateScopedName: (name, filename) => `_${name}_${md5(filename).substr(0, 5)}`
|
||||
};
|
||||
|
||||
if (config.plugins && config.plugins['postcss-modules']) {
|
||||
postcssModulesConfig = Object.assign(postcssModulesConfig, config.plugins['postcss-modules']);
|
||||
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) {
|
||||
let cssnano = yield localRequire('cssnano', asset.name);
|
||||
|
||||
let _yield$localRequire = yield localRequire('cssnano/package.json', asset.name),
|
||||
version = _yield$localRequire.version;
|
||||
|
||||
config.plugins.push(cssnano((yield asset.getConfig(['cssnano.config.js'])) || {
|
||||
// Only enable safe css transforms if cssnano < 4
|
||||
// See: https://github.com/parcel-bundler/parcel/issues/698
|
||||
// See: https://github.com/ben-eb/cssnano/releases/tag/v4.0.0-rc.0
|
||||
safe: semver.satisfies(version, '<4.0.0-rc')
|
||||
}));
|
||||
}
|
||||
|
||||
config.from = asset.name;
|
||||
config.to = asset.name;
|
||||
return config;
|
||||
});
|
||||
return _getConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
const createLoader = asset => class ParcelFileSystemLoader extends FileSystemLoader {
|
||||
fetch(composesPath, relativeTo) {
|
||||
var _this = this;
|
||||
|
||||
return (0, _asyncToGenerator2.default)(function* () {
|
||||
let importPath = composesPath.replace(/^["']|["']$/g, '');
|
||||
|
||||
const _asset$resolveDepende = asset.resolveDependency(importPath, relativeTo),
|
||||
resolved = _asset$resolveDepende.resolved;
|
||||
|
||||
let rootRelativePath = path.resolve(path.dirname(relativeTo), resolved);
|
||||
const root = path.resolve('/'); // fixes an issue on windows which is part of the css-modules-loader-core
|
||||
// see https://github.com/css-modules/css-modules-loader-core/issues/230
|
||||
|
||||
if (rootRelativePath.startsWith(root)) {
|
||||
rootRelativePath = rootRelativePath.substr(root.length);
|
||||
}
|
||||
|
||||
const source = yield fs.readFile(resolved, 'utf-8');
|
||||
|
||||
const _yield$_this$core$loa = yield _this.core.load(source, rootRelativePath, undefined, _this.fetch.bind(_this)),
|
||||
exportTokens = _yield$_this$core$loa.exportTokens;
|
||||
|
||||
return exportTokens;
|
||||
})();
|
||||
}
|
||||
|
||||
get finalSource() {
|
||||
return '';
|
||||
}
|
||||
|
||||
};
|
||||
90
BACK_BACK/node_modules/parcel-bundler/lib/transforms/posthtml.js
generated
vendored
Executable file
90
BACK_BACK/node_modules/parcel-bundler/lib/transforms/posthtml.js
generated
vendored
Executable file
|
|
@ -0,0 +1,90 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const loadPlugins = require('../utils/loadPlugins');
|
||||
|
||||
const posthtml = require('posthtml');
|
||||
|
||||
const posthtmlParse = require('posthtml-parser');
|
||||
|
||||
function parse(_x, _x2) {
|
||||
return _parse.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _parse() {
|
||||
_parse = (0, _asyncToGenerator2.default)(function* (code, asset) {
|
||||
var config = yield getConfig(asset);
|
||||
|
||||
if (!config) {
|
||||
config = {};
|
||||
}
|
||||
|
||||
return posthtmlParse(code, config);
|
||||
});
|
||||
return _parse.apply(this, arguments);
|
||||
}
|
||||
|
||||
function transform(_x3) {
|
||||
return _transform.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _transform() {
|
||||
_transform = (0, _asyncToGenerator2.default)(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 _transform.apply(this, arguments);
|
||||
}
|
||||
|
||||
function getConfig(_x4) {
|
||||
return _getConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getConfig() {
|
||||
_getConfig = (0, _asyncToGenerator2.default)(function* (asset) {
|
||||
let config = yield asset.getConfig(['.posthtmlrc', '.posthtmlrc.js', 'posthtml.config.js'], {
|
||||
packageKey: 'posthtml'
|
||||
});
|
||||
|
||||
if (!config && !asset.options.minify) {
|
||||
return;
|
||||
}
|
||||
|
||||
config = config || {};
|
||||
const plugins = config.plugins;
|
||||
|
||||
if (typeof plugins === 'object') {
|
||||
// This is deprecated in favor of result messages but kept for compatibility
|
||||
// See https://github.com/posthtml/posthtml-include/blob/e4f2a57c2e52ff721eed747b65eddf7d7a1451e3/index.js#L18-L26
|
||||
const depConfig = {
|
||||
addDependencyTo: {
|
||||
addDependency: name => asset.addDependency(name, {
|
||||
includedInParent: true
|
||||
})
|
||||
}
|
||||
};
|
||||
Object.keys(plugins).forEach(p => Object.assign(plugins[p], depConfig));
|
||||
}
|
||||
|
||||
config.plugins = yield loadPlugins(plugins, asset.name);
|
||||
config.skipParse = true;
|
||||
return config;
|
||||
});
|
||||
return _getConfig.apply(this, arguments);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
parse,
|
||||
transform
|
||||
};
|
||||
77
BACK_BACK/node_modules/parcel-bundler/lib/transforms/terser.js
generated
vendored
Executable file
77
BACK_BACK/node_modules/parcel-bundler/lib/transforms/terser.js
generated
vendored
Executable file
|
|
@ -0,0 +1,77 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const _require = require('terser'),
|
||||
minify = _require.minify;
|
||||
|
||||
const SourceMap = require('../SourceMap');
|
||||
|
||||
module.exports = /*#__PURE__*/function () {
|
||||
var _ref = (0, _asyncToGenerator2.default)(function* (asset) {
|
||||
yield asset.parseIfNeeded(); // Convert AST into JS
|
||||
|
||||
let source = (yield asset.generate())[0].value;
|
||||
let customConfig = yield asset.getConfig(['.uglifyrc', '.terserrc']);
|
||||
let options = {
|
||||
warnings: true,
|
||||
safari10: true,
|
||||
mangle: {
|
||||
toplevel: !asset.options.scopeHoist
|
||||
}
|
||||
};
|
||||
let sourceMap;
|
||||
|
||||
if (asset.options.sourceMaps) {
|
||||
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);
|
||||
};
|
||||
}();
|
||||
109
BACK_BACK/node_modules/parcel-bundler/lib/utils/PromiseQueue.js
generated
vendored
Executable file
109
BACK_BACK/node_modules/parcel-bundler/lib/utils/PromiseQueue.js
generated
vendored
Executable file
|
|
@ -0,0 +1,109 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
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 (0, _asyncToGenerator2.default)(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;
|
||||
127
BACK_BACK/node_modules/parcel-bundler/lib/utils/bundleReport.js
generated
vendored
Executable file
127
BACK_BACK/node_modules/parcel-bundler/lib/utils/bundleReport.js
generated
vendored
Executable file
|
|
@ -0,0 +1,127 @@
|
|||
"use strict";
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const prettifyTime = require('./prettifyTime');
|
||||
|
||||
const logger = require('@parcel/logger');
|
||||
|
||||
const filesize = require('filesize');
|
||||
|
||||
const LARGE_BUNDLE_SIZE = 1024 * 1024;
|
||||
const DEFAULT_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 _iterator = _createForOfIteratorHelper(bundles),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
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 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 = (() => {
|
||||
if (detailed === 'all') {
|
||||
return assets;
|
||||
}
|
||||
|
||||
return assets.slice(0, isNaN(detailed) || typeof detailed === 'boolean' ? DEFAULT_NUM_LARGE_ASSETS : parseInt(detailed, 10));
|
||||
})();
|
||||
|
||||
var _iterator2 = _createForOfIteratorHelper(largestAssets),
|
||||
_step2;
|
||||
|
||||
try {
|
||||
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
||||
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) {
|
||||
_iterator2.e(err);
|
||||
} finally {
|
||||
_iterator2.f();
|
||||
}
|
||||
|
||||
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) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
logger.log('');
|
||||
logger.table(COLUMNS, rows);
|
||||
}
|
||||
|
||||
module.exports = bundleReport;
|
||||
|
||||
function* iterateBundles(bundle) {
|
||||
if (!bundle.isEmpty) {
|
||||
yield bundle;
|
||||
}
|
||||
|
||||
var _iterator3 = _createForOfIteratorHelper(bundle.childBundles),
|
||||
_step3;
|
||||
|
||||
try {
|
||||
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
||||
let child = _step3.value;
|
||||
yield* iterateBundles(child);
|
||||
}
|
||||
} catch (err) {
|
||||
_iterator3.e(err);
|
||||
} finally {
|
||||
_iterator3.f();
|
||||
}
|
||||
}
|
||||
|
||||
function prettifySize(size, isLarge) {
|
||||
let res = filesize(size);
|
||||
|
||||
if (isLarge) {
|
||||
return logger.chalk.yellow(logger.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));
|
||||
}
|
||||
97
BACK_BACK/node_modules/parcel-bundler/lib/utils/config.js
generated
vendored
Executable file
97
BACK_BACK/node_modules/parcel-bundler/lib/utils/config.js
generated
vendored
Executable file
|
|
@ -0,0 +1,97 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const clone = require('clone');
|
||||
|
||||
const PARSERS = {
|
||||
json: require('json5').parse,
|
||||
toml: require('@iarna/toml').parse
|
||||
};
|
||||
const existsCache = new Map();
|
||||
|
||||
function resolve(_x, _x2) {
|
||||
return _resolve.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _resolve() {
|
||||
_resolve = (0, _asyncToGenerator2.default)(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 _iterator = _createForOfIteratorHelper(filenames),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
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) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
return resolve(filepath, filenames, root);
|
||||
});
|
||||
return _resolve.apply(this, arguments);
|
||||
}
|
||||
|
||||
function load(_x3, _x4) {
|
||||
return _load.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _load() {
|
||||
_load = (0, _asyncToGenerator2.default)(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 clone(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 _load.apply(this, arguments);
|
||||
}
|
||||
|
||||
exports.resolve = resolve;
|
||||
exports.load = load;
|
||||
18
BACK_BACK/node_modules/parcel-bundler/lib/utils/customErrors.js
generated
vendored
Executable file
18
BACK_BACK/node_modules/parcel-bundler/lib/utils/customErrors.js
generated
vendored
Executable 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;
|
||||
44
BACK_BACK/node_modules/parcel-bundler/lib/utils/env.js
generated
vendored
Executable file
44
BACK_BACK/node_modules/parcel-bundler/lib/utils/env.js
generated
vendored
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const config = require('./config');
|
||||
|
||||
const dotenv = require('dotenv');
|
||||
|
||||
const variableExpansion = require('dotenv-expand');
|
||||
|
||||
function loadEnv(_x) {
|
||||
return _loadEnv.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _loadEnv() {
|
||||
_loadEnv = (0, _asyncToGenerator2.default)(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( /*#__PURE__*/function () {
|
||||
var _ref = (0, _asyncToGenerator2.default)(function* (dotenvFile) {
|
||||
const envPath = yield config.resolve(filepath, [dotenvFile]);
|
||||
|
||||
if (envPath) {
|
||||
const envs = dotenv.config({
|
||||
path: envPath
|
||||
});
|
||||
variableExpansion(envs);
|
||||
}
|
||||
});
|
||||
|
||||
return function (_x2) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}()));
|
||||
});
|
||||
return _loadEnv.apply(this, arguments);
|
||||
}
|
||||
|
||||
module.exports = loadEnv;
|
||||
115
BACK_BACK/node_modules/parcel-bundler/lib/utils/generateCertificate.js
generated
vendored
Executable file
115
BACK_BACK/node_modules/parcel-bundler/lib/utils/generateCertificate.js
generated
vendored
Executable file
|
|
@ -0,0 +1,115 @@
|
|||
"use strict";
|
||||
|
||||
const forge = require('node-forge');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const mkdirp = require('mkdirp');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const logger = require('@parcel/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.progress('Generating SSL Certificate...');
|
||||
const pki = forge.pki;
|
||||
const keys = pki.rsa.generateKeyPair(2048);
|
||||
const cert = pki.createCertificate();
|
||||
cert.publicKey = keys.publicKey;
|
||||
cert.serialNumber = Date.now().toString();
|
||||
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;
|
||||
29
BACK_BACK/node_modules/parcel-bundler/lib/utils/getCertificate.js
generated
vendored
Executable file
29
BACK_BACK/node_modules/parcel-bundler/lib/utils/getCertificate.js
generated
vendored
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
function getCertificate(_x) {
|
||||
return _getCertificate.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getCertificate() {
|
||||
_getCertificate = (0, _asyncToGenerator2.default)(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 _getCertificate.apply(this, arguments);
|
||||
}
|
||||
|
||||
module.exports = getCertificate;
|
||||
16
BACK_BACK/node_modules/parcel-bundler/lib/utils/getExisting.js
generated
vendored
Executable file
16
BACK_BACK/node_modules/parcel-bundler/lib/utils/getExisting.js
generated
vendored
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
|
||||
const fs = require('fs');
|
||||
/**
|
||||
* Creates an object that contains both source and minified (using the source as a fallback).
|
||||
* e.g. builtins.min.js and builtins.js.
|
||||
*/
|
||||
|
||||
|
||||
module.exports = (minifiedPath, sourcePath) => {
|
||||
let source = fs.readFileSync(sourcePath, 'utf8').trim();
|
||||
return {
|
||||
source,
|
||||
minified: fs.existsSync(minifiedPath) ? fs.readFileSync(minifiedPath, 'utf8').trim().replace(/;$/, '') : source
|
||||
};
|
||||
};
|
||||
14
BACK_BACK/node_modules/parcel-bundler/lib/utils/getModuleParts.js
generated
vendored
Executable file
14
BACK_BACK/node_modules/parcel-bundler/lib/utils/getModuleParts.js
generated
vendored
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
const path = require('path');
|
||||
|
||||
module.exports = function (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;
|
||||
};
|
||||
51
BACK_BACK/node_modules/parcel-bundler/lib/utils/getRootDir.js
generated
vendored
Executable file
51
BACK_BACK/node_modules/parcel-bundler/lib/utils/getRootDir.js
generated
vendored
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
"use strict";
|
||||
|
||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
||||
|
||||
const path = require('path');
|
||||
|
||||
function getRootDir(files) {
|
||||
let cur = null;
|
||||
|
||||
var _iterator = _createForOfIteratorHelper(files),
|
||||
_step;
|
||||
|
||||
try {
|
||||
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
||||
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) {
|
||||
_iterator.e(err);
|
||||
} finally {
|
||||
_iterator.f();
|
||||
}
|
||||
|
||||
return cur ? cur.dir : process.cwd();
|
||||
}
|
||||
|
||||
module.exports = getRootDir;
|
||||
148
BACK_BACK/node_modules/parcel-bundler/lib/utils/getTargetEngines.js
generated
vendored
Executable file
148
BACK_BACK/node_modules/parcel-bundler/lib/utils/getTargetEngines.js
generated
vendored
Executable file
|
|
@ -0,0 +1,148 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const browserslist = require('browserslist');
|
||||
|
||||
const semver = require('semver');
|
||||
|
||||
const Path = require('path');
|
||||
|
||||
const DEFAULT_ENGINES = {
|
||||
browsers: ['> 0.25%'],
|
||||
node: '8'
|
||||
};
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
function getTargetEngines(_x, _x2) {
|
||||
return _getTargetEngines.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _getTargetEngines() {
|
||||
_getTargetEngines = (0, _asyncToGenerator2.default)(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 _getTargetEngines.apply(this, arguments);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
function loadBrowserslist(_x3, _x4) {
|
||||
return _loadBrowserslist.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _loadBrowserslist() {
|
||||
_loadBrowserslist = (0, _asyncToGenerator2.default)(function* (asset, path) {
|
||||
let config = yield asset.getConfig(['browserslist', '.browserslistrc'], {
|
||||
path,
|
||||
load: false
|
||||
});
|
||||
|
||||
if (config) {
|
||||
return browserslist.readConfig(config);
|
||||
}
|
||||
});
|
||||
return _loadBrowserslist.apply(this, arguments);
|
||||
}
|
||||
|
||||
function loadBabelrc(_x5, _x6) {
|
||||
return _loadBabelrc.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _loadBabelrc() {
|
||||
_loadBabelrc = (0, _asyncToGenerator2.default)(function* (asset, path) {
|
||||
let config = yield asset.getConfig(['.babelrc', '.babelrc.js'], {
|
||||
path
|
||||
});
|
||||
|
||||
if (config && config.presets) {
|
||||
let env = config.presets.find(plugin => Array.isArray(plugin) && (plugin[0] === 'env' || plugin[0] === '@babel/env'));
|
||||
|
||||
if (env && env[1] && env[1].targets) {
|
||||
return env[1].targets;
|
||||
}
|
||||
}
|
||||
});
|
||||
return _loadBabelrc.apply(this, arguments);
|
||||
}
|
||||
|
||||
module.exports = getTargetEngines;
|
||||
21
BACK_BACK/node_modules/parcel-bundler/lib/utils/glob.js
generated
vendored
Executable file
21
BACK_BACK/node_modules/parcel-bundler/lib/utils/glob.js
generated
vendored
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
"use strict";
|
||||
|
||||
const isGlob = require('is-glob');
|
||||
|
||||
const fastGlob = require('fast-glob');
|
||||
|
||||
function normalisePath(p) {
|
||||
return p.replace(/\\/g, '/');
|
||||
}
|
||||
|
||||
exports.isGlob = function (p) {
|
||||
return isGlob(normalisePath(p));
|
||||
};
|
||||
|
||||
exports.glob = function (p, options) {
|
||||
return fastGlob(normalisePath(p), options);
|
||||
};
|
||||
|
||||
exports.glob.sync = function (p, options) {
|
||||
return fastGlob.sync(normalisePath(p), options);
|
||||
};
|
||||
191
BACK_BACK/node_modules/parcel-bundler/lib/utils/installPackage.js
generated
vendored
Executable file
191
BACK_BACK/node_modules/parcel-bundler/lib/utils/installPackage.js
generated
vendored
Executable file
|
|
@ -0,0 +1,191 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const config = require('./config');
|
||||
|
||||
const _require = require('@parcel/utils'),
|
||||
promisify = _require.promisify;
|
||||
|
||||
const resolve = promisify(require('resolve'));
|
||||
|
||||
const commandExists = require('command-exists');
|
||||
|
||||
const logger = require('@parcel/logger');
|
||||
|
||||
const pipeSpawn = require('./pipeSpawn');
|
||||
|
||||
const PromiseQueue = require('./PromiseQueue');
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const fs = require('@parcel/fs');
|
||||
|
||||
const WorkerFarm = require('@parcel/workers');
|
||||
|
||||
const YARN_LOCK = 'yarn.lock';
|
||||
|
||||
function install(_x, _x2) {
|
||||
return _install.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _install() {
|
||||
_install = (0, _asyncToGenerator2.default)(function* (modules, filepath, options = {}) {
|
||||
let _options$installPeers = options.installPeers,
|
||||
installPeers = _options$installPeers === void 0 ? true : _options$installPeers,
|
||||
_options$saveDev = options.saveDev,
|
||||
saveDev = _options$saveDev === void 0 ? true : _options$saveDev,
|
||||
packageManager = options.packageManager;
|
||||
|
||||
if (typeof modules === 'string') {
|
||||
modules = [modules];
|
||||
}
|
||||
|
||||
logger.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(m => installPeerDependencies(filepath, m, options)));
|
||||
}
|
||||
});
|
||||
return _install.apply(this, arguments);
|
||||
}
|
||||
|
||||
function installPeerDependencies(_x3, _x4, _x5) {
|
||||
return _installPeerDependencies.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _installPeerDependencies() {
|
||||
_installPeerDependencies = (0, _asyncToGenerator2.default)(function* (filepath, name, options) {
|
||||
let basedir = path.dirname(filepath);
|
||||
|
||||
const _yield$resolve = yield resolve(name, {
|
||||
basedir
|
||||
}),
|
||||
_yield$resolve2 = (0, _slicedToArray2.default)(_yield$resolve, 1),
|
||||
resolved = _yield$resolve2[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 _installPeerDependencies.apply(this, arguments);
|
||||
}
|
||||
|
||||
function determinePackageManager(_x6) {
|
||||
return _determinePackageManager.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _determinePackageManager() {
|
||||
_determinePackageManager = (0, _asyncToGenerator2.default)(function* (filepath) {
|
||||
const yarnLockFile = yield config.resolve(filepath, [YARN_LOCK]);
|
||||
/**
|
||||
* no yarn.lock => use npm
|
||||
* yarn.lock => Use yarn, fallback to npm
|
||||
*/
|
||||
|
||||
if (!yarnLockFile) {
|
||||
return 'npm';
|
||||
}
|
||||
|
||||
const hasYarn = yield checkForYarnCommand();
|
||||
|
||||
if (hasYarn) {
|
||||
return 'yarn';
|
||||
}
|
||||
|
||||
return 'npm';
|
||||
});
|
||||
return _determinePackageManager.apply(this, arguments);
|
||||
}
|
||||
|
||||
let hasYarn = null;
|
||||
|
||||
function checkForYarnCommand() {
|
||||
return _checkForYarnCommand.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _checkForYarnCommand() {
|
||||
_checkForYarnCommand = (0, _asyncToGenerator2.default)(function* () {
|
||||
if (hasYarn != null) {
|
||||
return hasYarn;
|
||||
}
|
||||
|
||||
try {
|
||||
hasYarn = yield commandExists('yarn');
|
||||
} catch (err) {
|
||||
hasYarn = false;
|
||||
}
|
||||
|
||||
return hasYarn;
|
||||
});
|
||||
return _checkForYarnCommand.apply(this, arguments);
|
||||
}
|
||||
|
||||
let queue = new PromiseQueue(install, {
|
||||
maxConcurrent: 1,
|
||||
retry: false
|
||||
});
|
||||
|
||||
module.exports = /*#__PURE__*/function () {
|
||||
var _ref = (0, _asyncToGenerator2.default)(function* (...args) {
|
||||
// Ensure that this function is always called on the master process so we
|
||||
// don't call multiple installs in parallel.
|
||||
if (WorkerFarm.isWorker()) {
|
||||
yield WorkerFarm.callMaster({
|
||||
location: __filename,
|
||||
args
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
queue.add(...args);
|
||||
return queue.run();
|
||||
});
|
||||
|
||||
return function () {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
12
BACK_BACK/node_modules/parcel-bundler/lib/utils/is-url.js
generated
vendored
Executable file
12
BACK_BACK/node_modules/parcel-bundler/lib/utils/is-url.js
generated
vendored
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
"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);
|
||||
};
|
||||
16
BACK_BACK/node_modules/parcel-bundler/lib/utils/isAccessedVarChanged.js
generated
vendored
Executable file
16
BACK_BACK/node_modules/parcel-bundler/lib/utils/isAccessedVarChanged.js
generated
vendored
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
|
||||
/*
|
||||
Checks if any of the used variable from process.env is changed
|
||||
*/
|
||||
function isAccessedVarChanged(cacheData) {
|
||||
for (let key in cacheData.env) {
|
||||
if (cacheData.env[key] !== process.env[key]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = isAccessedVarChanged;
|
||||
15
BACK_BACK/node_modules/parcel-bundler/lib/utils/lineCounter.js
generated
vendored
Executable file
15
BACK_BACK/node_modules/parcel-bundler/lib/utils/lineCounter.js
generated
vendored
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
"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;
|
||||
52
BACK_BACK/node_modules/parcel-bundler/lib/utils/loadPlugins.js
generated
vendored
Executable file
52
BACK_BACK/node_modules/parcel-bundler/lib/utils/loadPlugins.js
generated
vendored
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
const localRequire = require('./localRequire');
|
||||
|
||||
module.exports = /*#__PURE__*/function () {
|
||||
var _loadPlugins = (0, _asyncToGenerator2.default)(function* (plugins, relative) {
|
||||
if (Array.isArray(plugins)) {
|
||||
return Promise.all(plugins.map(p => loadPlugin(p, relative)).filter(Boolean));
|
||||
} else if (typeof plugins === 'object') {
|
||||
let mapPlugins = yield Promise.all(Object.keys(plugins).map(p => loadPlugin(p, relative, plugins[p])));
|
||||
return mapPlugins.filter(Boolean);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
function loadPlugins(_x, _x2) {
|
||||
return _loadPlugins.apply(this, arguments);
|
||||
}
|
||||
|
||||
return loadPlugins;
|
||||
}();
|
||||
|
||||
function loadPlugin(_x3, _x4, _x5) {
|
||||
return _loadPlugin.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _loadPlugin() {
|
||||
_loadPlugin = (0, _asyncToGenerator2.default)(function* (plugin, relative, options) {
|
||||
if (typeof plugin === 'string') {
|
||||
plugin = yield localRequire(plugin, relative);
|
||||
plugin = plugin.default || plugin;
|
||||
|
||||
if (typeof options !== 'object') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
if (Object.keys(options).length > 0) {
|
||||
plugin = plugin(options);
|
||||
}
|
||||
|
||||
plugin = plugin.default || plugin;
|
||||
}
|
||||
|
||||
return plugin;
|
||||
});
|
||||
return _loadPlugin.apply(this, arguments);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue