@shopify/cli-hydrogen 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/Command-05a807a5.js +61600 -0
- package/dist/Command-05a807a5.js.map +1 -0
- package/dist/commands/hydrogen/check.js +2213 -0
- package/dist/commands/hydrogen/check.js.map +1 -0
- package/dist/commands/hydrogen/init.js +14743 -0
- package/dist/commands/hydrogen/init.js.map +1 -0
- package/dist/commands/hydrogen/preview.js +3358 -0
- package/dist/commands/hydrogen/preview.js.map +1 -0
- package/dist/eslintrc-js-6f6a13b8.js +12 -0
- package/dist/eslintrc-js-6f6a13b8.js.map +1 -0
- package/dist/package-224e3f45.js +105 -0
- package/dist/package-224e3f45.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,3358 @@
|
|
|
1
|
+
import require$$0$5, { resolve } from 'path';
|
|
2
|
+
import { C as Command, H as HelpfulError } from '../../Command-05a807a5.js';
|
|
3
|
+
import 'prettier';
|
|
4
|
+
import { Request, MiniflareCore, CorePlugin } from '@miniflare/core';
|
|
5
|
+
import { CachePlugin } from '@miniflare/cache';
|
|
6
|
+
import { VMScriptRunner } from '@miniflare/runner-vm';
|
|
7
|
+
import { Log, LogLevel } from '@miniflare/shared';
|
|
8
|
+
import require$$3 from 'http';
|
|
9
|
+
import require$$0$3 from 'fs';
|
|
10
|
+
import require$$7, { URL } from 'url';
|
|
11
|
+
import require$$0$1 from 'tty';
|
|
12
|
+
import require$$0$2 from 'util';
|
|
13
|
+
import require$$4 from 'net';
|
|
14
|
+
import require$$0$4 from 'events';
|
|
15
|
+
import { MemoryStorage } from '@miniflare/storage-memory';
|
|
16
|
+
import '@oclif/core';
|
|
17
|
+
import 'constants';
|
|
18
|
+
import 'stream';
|
|
19
|
+
import 'assert';
|
|
20
|
+
import 'os';
|
|
21
|
+
import 'readline';
|
|
22
|
+
import 'buffer';
|
|
23
|
+
import 'child_process';
|
|
24
|
+
import 'string_decoder';
|
|
25
|
+
import 'crypto';
|
|
26
|
+
import '@shopify/cli-kit';
|
|
27
|
+
import 'module';
|
|
28
|
+
import 'vm';
|
|
29
|
+
import 'v8';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param typeMap [Object] Map of MIME type -> Array[extensions]
|
|
33
|
+
* @param ...
|
|
34
|
+
*/
|
|
35
|
+
function Mime$1() {
|
|
36
|
+
this._types = Object.create(null);
|
|
37
|
+
this._extensions = Object.create(null);
|
|
38
|
+
|
|
39
|
+
for (let i = 0; i < arguments.length; i++) {
|
|
40
|
+
this.define(arguments[i]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.define = this.define.bind(this);
|
|
44
|
+
this.getType = this.getType.bind(this);
|
|
45
|
+
this.getExtension = this.getExtension.bind(this);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Define mimetype -> extension mappings. Each key is a mime-type that maps
|
|
50
|
+
* to an array of extensions associated with the type. The first extension is
|
|
51
|
+
* used as the default extension for the type.
|
|
52
|
+
*
|
|
53
|
+
* e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
|
|
54
|
+
*
|
|
55
|
+
* If a type declares an extension that has already been defined, an error will
|
|
56
|
+
* be thrown. To suppress this error and force the extension to be associated
|
|
57
|
+
* with the new type, pass `force`=true. Alternatively, you may prefix the
|
|
58
|
+
* extension with "*" to map the type to extension, without mapping the
|
|
59
|
+
* extension to the type.
|
|
60
|
+
*
|
|
61
|
+
* e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']});
|
|
62
|
+
*
|
|
63
|
+
*
|
|
64
|
+
* @param map (Object) type definitions
|
|
65
|
+
* @param force (Boolean) if true, force overriding of existing definitions
|
|
66
|
+
*/
|
|
67
|
+
Mime$1.prototype.define = function(typeMap, force) {
|
|
68
|
+
for (let type in typeMap) {
|
|
69
|
+
let extensions = typeMap[type].map(function(t) {
|
|
70
|
+
return t.toLowerCase();
|
|
71
|
+
});
|
|
72
|
+
type = type.toLowerCase();
|
|
73
|
+
|
|
74
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
75
|
+
const ext = extensions[i];
|
|
76
|
+
|
|
77
|
+
// '*' prefix = not the preferred type for this extension. So fixup the
|
|
78
|
+
// extension, and skip it.
|
|
79
|
+
if (ext[0] === '*') {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!force && (ext in this._types)) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
'Attempt to change mapping for "' + ext +
|
|
86
|
+
'" extension from "' + this._types[ext] + '" to "' + type +
|
|
87
|
+
'". Pass `force=true` to allow this, otherwise remove "' + ext +
|
|
88
|
+
'" from the list of extensions for "' + type + '".'
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this._types[ext] = type;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Use first extension as default
|
|
96
|
+
if (force || !this._extensions[type]) {
|
|
97
|
+
const ext = extensions[0];
|
|
98
|
+
this._extensions[type] = (ext[0] !== '*') ? ext : ext.substr(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Lookup a mime type based on extension
|
|
105
|
+
*/
|
|
106
|
+
Mime$1.prototype.getType = function(path) {
|
|
107
|
+
path = String(path);
|
|
108
|
+
let last = path.replace(/^.*[/\\]/, '').toLowerCase();
|
|
109
|
+
let ext = last.replace(/^.*\./, '').toLowerCase();
|
|
110
|
+
|
|
111
|
+
let hasPath = last.length < path.length;
|
|
112
|
+
let hasDot = ext.length < last.length - 1;
|
|
113
|
+
|
|
114
|
+
return (hasDot || !hasPath) && this._types[ext] || null;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Return file extension associated with a mime type
|
|
119
|
+
*/
|
|
120
|
+
Mime$1.prototype.getExtension = function(type) {
|
|
121
|
+
type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
|
|
122
|
+
return type && this._extensions[type.toLowerCase()] || null;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
var Mime_1 = Mime$1;
|
|
126
|
+
|
|
127
|
+
var standard = {"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["es","ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avif":["avif"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};
|
|
128
|
+
|
|
129
|
+
var other = {"application/prs.cww":["cww"],"application/vnd.1000minds.decision-model+xml":["1km"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.keynote":["key"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.apple.numbers":["numbers"],"application/vnd.apple.pages":["pages"],"application/vnd.apple.pkpass":["pkpass"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.balsamiq.bmml+xml":["bmml"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.citationstyles.style+xml":["csl"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dbf":["dbf"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mapbox-vector-tile":["mvt"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.rar":["rar"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-iwork-keynote-sffkey":["*key"],"application/x-iwork-numbers-sffnumbers":["*numbers"],"application/x-iwork-pages-sffpages":["*pages"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["*rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.pco.b16":["b16"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.sap.vds":["vds"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]};
|
|
130
|
+
|
|
131
|
+
let Mime = Mime_1;
|
|
132
|
+
var mime = new Mime(standard, other);
|
|
133
|
+
|
|
134
|
+
var src$1 = {exports: {}};
|
|
135
|
+
|
|
136
|
+
var browser$1 = {exports: {}};
|
|
137
|
+
|
|
138
|
+
var debug$3 = {exports: {}};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Helpers.
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
var s$1 = 1000;
|
|
145
|
+
var m$1 = s$1 * 60;
|
|
146
|
+
var h$1 = m$1 * 60;
|
|
147
|
+
var d$1 = h$1 * 24;
|
|
148
|
+
var y$1 = d$1 * 365.25;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Parse or format the given `val`.
|
|
152
|
+
*
|
|
153
|
+
* Options:
|
|
154
|
+
*
|
|
155
|
+
* - `long` verbose formatting [false]
|
|
156
|
+
*
|
|
157
|
+
* @param {String|Number} val
|
|
158
|
+
* @param {Object} [options]
|
|
159
|
+
* @throws {Error} throw an error if val is not a non-empty string or a number
|
|
160
|
+
* @return {String|Number}
|
|
161
|
+
* @api public
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
var ms$1 = function(val, options) {
|
|
165
|
+
options = options || {};
|
|
166
|
+
var type = typeof val;
|
|
167
|
+
if (type === 'string' && val.length > 0) {
|
|
168
|
+
return parse$2(val);
|
|
169
|
+
} else if (type === 'number' && isNaN(val) === false) {
|
|
170
|
+
return options.long ? fmtLong$1(val) : fmtShort$1(val);
|
|
171
|
+
}
|
|
172
|
+
throw new Error(
|
|
173
|
+
'val is not a non-empty string or a valid number. val=' +
|
|
174
|
+
JSON.stringify(val)
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Parse the given `str` and return milliseconds.
|
|
180
|
+
*
|
|
181
|
+
* @param {String} str
|
|
182
|
+
* @return {Number}
|
|
183
|
+
* @api private
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
function parse$2(str) {
|
|
187
|
+
str = String(str);
|
|
188
|
+
if (str.length > 100) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
|
|
192
|
+
str
|
|
193
|
+
);
|
|
194
|
+
if (!match) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
var n = parseFloat(match[1]);
|
|
198
|
+
var type = (match[2] || 'ms').toLowerCase();
|
|
199
|
+
switch (type) {
|
|
200
|
+
case 'years':
|
|
201
|
+
case 'year':
|
|
202
|
+
case 'yrs':
|
|
203
|
+
case 'yr':
|
|
204
|
+
case 'y':
|
|
205
|
+
return n * y$1;
|
|
206
|
+
case 'days':
|
|
207
|
+
case 'day':
|
|
208
|
+
case 'd':
|
|
209
|
+
return n * d$1;
|
|
210
|
+
case 'hours':
|
|
211
|
+
case 'hour':
|
|
212
|
+
case 'hrs':
|
|
213
|
+
case 'hr':
|
|
214
|
+
case 'h':
|
|
215
|
+
return n * h$1;
|
|
216
|
+
case 'minutes':
|
|
217
|
+
case 'minute':
|
|
218
|
+
case 'mins':
|
|
219
|
+
case 'min':
|
|
220
|
+
case 'm':
|
|
221
|
+
return n * m$1;
|
|
222
|
+
case 'seconds':
|
|
223
|
+
case 'second':
|
|
224
|
+
case 'secs':
|
|
225
|
+
case 'sec':
|
|
226
|
+
case 's':
|
|
227
|
+
return n * s$1;
|
|
228
|
+
case 'milliseconds':
|
|
229
|
+
case 'millisecond':
|
|
230
|
+
case 'msecs':
|
|
231
|
+
case 'msec':
|
|
232
|
+
case 'ms':
|
|
233
|
+
return n;
|
|
234
|
+
default:
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Short format for `ms`.
|
|
241
|
+
*
|
|
242
|
+
* @param {Number} ms
|
|
243
|
+
* @return {String}
|
|
244
|
+
* @api private
|
|
245
|
+
*/
|
|
246
|
+
|
|
247
|
+
function fmtShort$1(ms) {
|
|
248
|
+
if (ms >= d$1) {
|
|
249
|
+
return Math.round(ms / d$1) + 'd';
|
|
250
|
+
}
|
|
251
|
+
if (ms >= h$1) {
|
|
252
|
+
return Math.round(ms / h$1) + 'h';
|
|
253
|
+
}
|
|
254
|
+
if (ms >= m$1) {
|
|
255
|
+
return Math.round(ms / m$1) + 'm';
|
|
256
|
+
}
|
|
257
|
+
if (ms >= s$1) {
|
|
258
|
+
return Math.round(ms / s$1) + 's';
|
|
259
|
+
}
|
|
260
|
+
return ms + 'ms';
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Long format for `ms`.
|
|
265
|
+
*
|
|
266
|
+
* @param {Number} ms
|
|
267
|
+
* @return {String}
|
|
268
|
+
* @api private
|
|
269
|
+
*/
|
|
270
|
+
|
|
271
|
+
function fmtLong$1(ms) {
|
|
272
|
+
return plural$1(ms, d$1, 'day') ||
|
|
273
|
+
plural$1(ms, h$1, 'hour') ||
|
|
274
|
+
plural$1(ms, m$1, 'minute') ||
|
|
275
|
+
plural$1(ms, s$1, 'second') ||
|
|
276
|
+
ms + ' ms';
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Pluralization helper.
|
|
281
|
+
*/
|
|
282
|
+
|
|
283
|
+
function plural$1(ms, n, name) {
|
|
284
|
+
if (ms < n) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (ms < n * 1.5) {
|
|
288
|
+
return Math.floor(ms / n) + ' ' + name;
|
|
289
|
+
}
|
|
290
|
+
return Math.ceil(ms / n) + ' ' + name + 's';
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
(function (module, exports) {
|
|
294
|
+
/**
|
|
295
|
+
* This is the common logic for both the Node.js and web browser
|
|
296
|
+
* implementations of `debug()`.
|
|
297
|
+
*
|
|
298
|
+
* Expose `debug()` as the module.
|
|
299
|
+
*/
|
|
300
|
+
|
|
301
|
+
exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
|
|
302
|
+
exports.coerce = coerce;
|
|
303
|
+
exports.disable = disable;
|
|
304
|
+
exports.enable = enable;
|
|
305
|
+
exports.enabled = enabled;
|
|
306
|
+
exports.humanize = ms$1;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The currently active debug mode names, and names to skip.
|
|
310
|
+
*/
|
|
311
|
+
|
|
312
|
+
exports.names = [];
|
|
313
|
+
exports.skips = [];
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Map of special "%n" handling functions, for the debug "format" argument.
|
|
317
|
+
*
|
|
318
|
+
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
|
319
|
+
*/
|
|
320
|
+
|
|
321
|
+
exports.formatters = {};
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Previous log timestamp.
|
|
325
|
+
*/
|
|
326
|
+
|
|
327
|
+
var prevTime;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Select a color.
|
|
331
|
+
* @param {String} namespace
|
|
332
|
+
* @return {Number}
|
|
333
|
+
* @api private
|
|
334
|
+
*/
|
|
335
|
+
|
|
336
|
+
function selectColor(namespace) {
|
|
337
|
+
var hash = 0, i;
|
|
338
|
+
|
|
339
|
+
for (i in namespace) {
|
|
340
|
+
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
|
341
|
+
hash |= 0; // Convert to 32bit integer
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return exports.colors[Math.abs(hash) % exports.colors.length];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Create a debugger with the given `namespace`.
|
|
349
|
+
*
|
|
350
|
+
* @param {String} namespace
|
|
351
|
+
* @return {Function}
|
|
352
|
+
* @api public
|
|
353
|
+
*/
|
|
354
|
+
|
|
355
|
+
function createDebug(namespace) {
|
|
356
|
+
|
|
357
|
+
function debug() {
|
|
358
|
+
// disabled?
|
|
359
|
+
if (!debug.enabled) return;
|
|
360
|
+
|
|
361
|
+
var self = debug;
|
|
362
|
+
|
|
363
|
+
// set `diff` timestamp
|
|
364
|
+
var curr = +new Date();
|
|
365
|
+
var ms = curr - (prevTime || curr);
|
|
366
|
+
self.diff = ms;
|
|
367
|
+
self.prev = prevTime;
|
|
368
|
+
self.curr = curr;
|
|
369
|
+
prevTime = curr;
|
|
370
|
+
|
|
371
|
+
// turn the `arguments` into a proper Array
|
|
372
|
+
var args = new Array(arguments.length);
|
|
373
|
+
for (var i = 0; i < args.length; i++) {
|
|
374
|
+
args[i] = arguments[i];
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
args[0] = exports.coerce(args[0]);
|
|
378
|
+
|
|
379
|
+
if ('string' !== typeof args[0]) {
|
|
380
|
+
// anything else let's inspect with %O
|
|
381
|
+
args.unshift('%O');
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// apply any `formatters` transformations
|
|
385
|
+
var index = 0;
|
|
386
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
|
|
387
|
+
// if we encounter an escaped % then don't increase the array index
|
|
388
|
+
if (match === '%%') return match;
|
|
389
|
+
index++;
|
|
390
|
+
var formatter = exports.formatters[format];
|
|
391
|
+
if ('function' === typeof formatter) {
|
|
392
|
+
var val = args[index];
|
|
393
|
+
match = formatter.call(self, val);
|
|
394
|
+
|
|
395
|
+
// now we need to remove `args[index]` since it's inlined in the `format`
|
|
396
|
+
args.splice(index, 1);
|
|
397
|
+
index--;
|
|
398
|
+
}
|
|
399
|
+
return match;
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
// apply env-specific formatting (colors, etc.)
|
|
403
|
+
exports.formatArgs.call(self, args);
|
|
404
|
+
|
|
405
|
+
var logFn = debug.log || exports.log || console.log.bind(console);
|
|
406
|
+
logFn.apply(self, args);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
debug.namespace = namespace;
|
|
410
|
+
debug.enabled = exports.enabled(namespace);
|
|
411
|
+
debug.useColors = exports.useColors();
|
|
412
|
+
debug.color = selectColor(namespace);
|
|
413
|
+
|
|
414
|
+
// env-specific initialization logic for debug instances
|
|
415
|
+
if ('function' === typeof exports.init) {
|
|
416
|
+
exports.init(debug);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return debug;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Enables a debug mode by namespaces. This can include modes
|
|
424
|
+
* separated by a colon and wildcards.
|
|
425
|
+
*
|
|
426
|
+
* @param {String} namespaces
|
|
427
|
+
* @api public
|
|
428
|
+
*/
|
|
429
|
+
|
|
430
|
+
function enable(namespaces) {
|
|
431
|
+
exports.save(namespaces);
|
|
432
|
+
|
|
433
|
+
exports.names = [];
|
|
434
|
+
exports.skips = [];
|
|
435
|
+
|
|
436
|
+
var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
|
437
|
+
var len = split.length;
|
|
438
|
+
|
|
439
|
+
for (var i = 0; i < len; i++) {
|
|
440
|
+
if (!split[i]) continue; // ignore empty strings
|
|
441
|
+
namespaces = split[i].replace(/\*/g, '.*?');
|
|
442
|
+
if (namespaces[0] === '-') {
|
|
443
|
+
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
|
444
|
+
} else {
|
|
445
|
+
exports.names.push(new RegExp('^' + namespaces + '$'));
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Disable debug output.
|
|
452
|
+
*
|
|
453
|
+
* @api public
|
|
454
|
+
*/
|
|
455
|
+
|
|
456
|
+
function disable() {
|
|
457
|
+
exports.enable('');
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Returns true if the given mode name is enabled, false otherwise.
|
|
462
|
+
*
|
|
463
|
+
* @param {String} name
|
|
464
|
+
* @return {Boolean}
|
|
465
|
+
* @api public
|
|
466
|
+
*/
|
|
467
|
+
|
|
468
|
+
function enabled(name) {
|
|
469
|
+
var i, len;
|
|
470
|
+
for (i = 0, len = exports.skips.length; i < len; i++) {
|
|
471
|
+
if (exports.skips[i].test(name)) {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
for (i = 0, len = exports.names.length; i < len; i++) {
|
|
476
|
+
if (exports.names[i].test(name)) {
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Coerce `val`.
|
|
485
|
+
*
|
|
486
|
+
* @param {Mixed} val
|
|
487
|
+
* @return {Mixed}
|
|
488
|
+
* @api private
|
|
489
|
+
*/
|
|
490
|
+
|
|
491
|
+
function coerce(val) {
|
|
492
|
+
if (val instanceof Error) return val.stack || val.message;
|
|
493
|
+
return val;
|
|
494
|
+
}
|
|
495
|
+
}(debug$3, debug$3.exports));
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* This is the web browser implementation of `debug()`.
|
|
499
|
+
*
|
|
500
|
+
* Expose `debug()` as the module.
|
|
501
|
+
*/
|
|
502
|
+
|
|
503
|
+
(function (module, exports) {
|
|
504
|
+
exports = module.exports = debug$3.exports;
|
|
505
|
+
exports.log = log;
|
|
506
|
+
exports.formatArgs = formatArgs;
|
|
507
|
+
exports.save = save;
|
|
508
|
+
exports.load = load;
|
|
509
|
+
exports.useColors = useColors;
|
|
510
|
+
exports.storage = 'undefined' != typeof chrome
|
|
511
|
+
&& 'undefined' != typeof chrome.storage
|
|
512
|
+
? chrome.storage.local
|
|
513
|
+
: localstorage();
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Colors.
|
|
517
|
+
*/
|
|
518
|
+
|
|
519
|
+
exports.colors = [
|
|
520
|
+
'lightseagreen',
|
|
521
|
+
'forestgreen',
|
|
522
|
+
'goldenrod',
|
|
523
|
+
'dodgerblue',
|
|
524
|
+
'darkorchid',
|
|
525
|
+
'crimson'
|
|
526
|
+
];
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
|
530
|
+
* and the Firebug extension (any Firefox version) are known
|
|
531
|
+
* to support "%c" CSS customizations.
|
|
532
|
+
*
|
|
533
|
+
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
|
534
|
+
*/
|
|
535
|
+
|
|
536
|
+
function useColors() {
|
|
537
|
+
// NB: In an Electron preload script, document will be defined but not fully
|
|
538
|
+
// initialized. Since we know we're in Chrome, we'll just detect this case
|
|
539
|
+
// explicitly
|
|
540
|
+
if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
|
|
541
|
+
return true;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// is webkit? http://stackoverflow.com/a/16459606/376773
|
|
545
|
+
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
|
546
|
+
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
|
547
|
+
// is firebug? http://stackoverflow.com/a/398120/376773
|
|
548
|
+
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
|
549
|
+
// is firefox >= v31?
|
|
550
|
+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
551
|
+
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
|
|
552
|
+
// double check webkit in userAgent just in case we are in a worker
|
|
553
|
+
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
|
558
|
+
*/
|
|
559
|
+
|
|
560
|
+
exports.formatters.j = function(v) {
|
|
561
|
+
try {
|
|
562
|
+
return JSON.stringify(v);
|
|
563
|
+
} catch (err) {
|
|
564
|
+
return '[UnexpectedJSONParseError]: ' + err.message;
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Colorize log arguments if enabled.
|
|
571
|
+
*
|
|
572
|
+
* @api public
|
|
573
|
+
*/
|
|
574
|
+
|
|
575
|
+
function formatArgs(args) {
|
|
576
|
+
var useColors = this.useColors;
|
|
577
|
+
|
|
578
|
+
args[0] = (useColors ? '%c' : '')
|
|
579
|
+
+ this.namespace
|
|
580
|
+
+ (useColors ? ' %c' : ' ')
|
|
581
|
+
+ args[0]
|
|
582
|
+
+ (useColors ? '%c ' : ' ')
|
|
583
|
+
+ '+' + exports.humanize(this.diff);
|
|
584
|
+
|
|
585
|
+
if (!useColors) return;
|
|
586
|
+
|
|
587
|
+
var c = 'color: ' + this.color;
|
|
588
|
+
args.splice(1, 0, c, 'color: inherit');
|
|
589
|
+
|
|
590
|
+
// the final "%c" is somewhat tricky, because there could be other
|
|
591
|
+
// arguments passed either before or after the %c, so we need to
|
|
592
|
+
// figure out the correct index to insert the CSS into
|
|
593
|
+
var index = 0;
|
|
594
|
+
var lastC = 0;
|
|
595
|
+
args[0].replace(/%[a-zA-Z%]/g, function(match) {
|
|
596
|
+
if ('%%' === match) return;
|
|
597
|
+
index++;
|
|
598
|
+
if ('%c' === match) {
|
|
599
|
+
// we only are interested in the *last* %c
|
|
600
|
+
// (the user may have provided their own)
|
|
601
|
+
lastC = index;
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
args.splice(lastC, 0, c);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Invokes `console.log()` when available.
|
|
610
|
+
* No-op when `console.log` is not a "function".
|
|
611
|
+
*
|
|
612
|
+
* @api public
|
|
613
|
+
*/
|
|
614
|
+
|
|
615
|
+
function log() {
|
|
616
|
+
// this hackery is required for IE8/9, where
|
|
617
|
+
// the `console.log` function doesn't have 'apply'
|
|
618
|
+
return 'object' === typeof console
|
|
619
|
+
&& console.log
|
|
620
|
+
&& Function.prototype.apply.call(console.log, console, arguments);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Save `namespaces`.
|
|
625
|
+
*
|
|
626
|
+
* @param {String} namespaces
|
|
627
|
+
* @api private
|
|
628
|
+
*/
|
|
629
|
+
|
|
630
|
+
function save(namespaces) {
|
|
631
|
+
try {
|
|
632
|
+
if (null == namespaces) {
|
|
633
|
+
exports.storage.removeItem('debug');
|
|
634
|
+
} else {
|
|
635
|
+
exports.storage.debug = namespaces;
|
|
636
|
+
}
|
|
637
|
+
} catch(e) {}
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Load `namespaces`.
|
|
642
|
+
*
|
|
643
|
+
* @return {String} returns the previously persisted debug modes
|
|
644
|
+
* @api private
|
|
645
|
+
*/
|
|
646
|
+
|
|
647
|
+
function load() {
|
|
648
|
+
var r;
|
|
649
|
+
try {
|
|
650
|
+
r = exports.storage.debug;
|
|
651
|
+
} catch(e) {}
|
|
652
|
+
|
|
653
|
+
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
|
654
|
+
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
|
655
|
+
r = process.env.DEBUG;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
return r;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Enable namespaces listed in `localStorage.debug` initially.
|
|
663
|
+
*/
|
|
664
|
+
|
|
665
|
+
exports.enable(load());
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Localstorage attempts to return the localstorage.
|
|
669
|
+
*
|
|
670
|
+
* This is necessary because safari throws
|
|
671
|
+
* when a user disables cookies/localstorage
|
|
672
|
+
* and you attempt to access it.
|
|
673
|
+
*
|
|
674
|
+
* @return {LocalStorage}
|
|
675
|
+
* @api private
|
|
676
|
+
*/
|
|
677
|
+
|
|
678
|
+
function localstorage() {
|
|
679
|
+
try {
|
|
680
|
+
return window.localStorage;
|
|
681
|
+
} catch (e) {}
|
|
682
|
+
}
|
|
683
|
+
}(browser$1, browser$1.exports));
|
|
684
|
+
|
|
685
|
+
var node$1 = {exports: {}};
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Module dependencies.
|
|
689
|
+
*/
|
|
690
|
+
|
|
691
|
+
(function (module, exports) {
|
|
692
|
+
var tty = require$$0$1;
|
|
693
|
+
var util = require$$0$2;
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* This is the Node.js implementation of `debug()`.
|
|
697
|
+
*
|
|
698
|
+
* Expose `debug()` as the module.
|
|
699
|
+
*/
|
|
700
|
+
|
|
701
|
+
exports = module.exports = debug$3.exports;
|
|
702
|
+
exports.init = init;
|
|
703
|
+
exports.log = log;
|
|
704
|
+
exports.formatArgs = formatArgs;
|
|
705
|
+
exports.save = save;
|
|
706
|
+
exports.load = load;
|
|
707
|
+
exports.useColors = useColors;
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Colors.
|
|
711
|
+
*/
|
|
712
|
+
|
|
713
|
+
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Build up the default `inspectOpts` object from the environment variables.
|
|
717
|
+
*
|
|
718
|
+
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
|
719
|
+
*/
|
|
720
|
+
|
|
721
|
+
exports.inspectOpts = Object.keys(process.env).filter(function (key) {
|
|
722
|
+
return /^debug_/i.test(key);
|
|
723
|
+
}).reduce(function (obj, key) {
|
|
724
|
+
// camel-case
|
|
725
|
+
var prop = key
|
|
726
|
+
.substring(6)
|
|
727
|
+
.toLowerCase()
|
|
728
|
+
.replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
|
|
729
|
+
|
|
730
|
+
// coerce string value into JS value
|
|
731
|
+
var val = process.env[key];
|
|
732
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
|
|
733
|
+
else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
|
|
734
|
+
else if (val === 'null') val = null;
|
|
735
|
+
else val = Number(val);
|
|
736
|
+
|
|
737
|
+
obj[prop] = val;
|
|
738
|
+
return obj;
|
|
739
|
+
}, {});
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* The file descriptor to write the `debug()` calls to.
|
|
743
|
+
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
|
|
744
|
+
*
|
|
745
|
+
* $ DEBUG_FD=3 node script.js 3>debug.log
|
|
746
|
+
*/
|
|
747
|
+
|
|
748
|
+
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
|
|
749
|
+
|
|
750
|
+
if (1 !== fd && 2 !== fd) {
|
|
751
|
+
util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')();
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
var stream = 1 === fd ? process.stdout :
|
|
755
|
+
2 === fd ? process.stderr :
|
|
756
|
+
createWritableStdioStream(fd);
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Is stdout a TTY? Colored output is enabled when `true`.
|
|
760
|
+
*/
|
|
761
|
+
|
|
762
|
+
function useColors() {
|
|
763
|
+
return 'colors' in exports.inspectOpts
|
|
764
|
+
? Boolean(exports.inspectOpts.colors)
|
|
765
|
+
: tty.isatty(fd);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Map %o to `util.inspect()`, all on a single line.
|
|
770
|
+
*/
|
|
771
|
+
|
|
772
|
+
exports.formatters.o = function(v) {
|
|
773
|
+
this.inspectOpts.colors = this.useColors;
|
|
774
|
+
return util.inspect(v, this.inspectOpts)
|
|
775
|
+
.split('\n').map(function(str) {
|
|
776
|
+
return str.trim()
|
|
777
|
+
}).join(' ');
|
|
778
|
+
};
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Map %o to `util.inspect()`, allowing multiple lines if needed.
|
|
782
|
+
*/
|
|
783
|
+
|
|
784
|
+
exports.formatters.O = function(v) {
|
|
785
|
+
this.inspectOpts.colors = this.useColors;
|
|
786
|
+
return util.inspect(v, this.inspectOpts);
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Adds ANSI color escape codes if enabled.
|
|
791
|
+
*
|
|
792
|
+
* @api public
|
|
793
|
+
*/
|
|
794
|
+
|
|
795
|
+
function formatArgs(args) {
|
|
796
|
+
var name = this.namespace;
|
|
797
|
+
var useColors = this.useColors;
|
|
798
|
+
|
|
799
|
+
if (useColors) {
|
|
800
|
+
var c = this.color;
|
|
801
|
+
var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
|
|
802
|
+
|
|
803
|
+
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
|
804
|
+
args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
|
|
805
|
+
} else {
|
|
806
|
+
args[0] = new Date().toUTCString()
|
|
807
|
+
+ ' ' + name + ' ' + args[0];
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Invokes `util.format()` with the specified arguments and writes to `stream`.
|
|
813
|
+
*/
|
|
814
|
+
|
|
815
|
+
function log() {
|
|
816
|
+
return stream.write(util.format.apply(util, arguments) + '\n');
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Save `namespaces`.
|
|
821
|
+
*
|
|
822
|
+
* @param {String} namespaces
|
|
823
|
+
* @api private
|
|
824
|
+
*/
|
|
825
|
+
|
|
826
|
+
function save(namespaces) {
|
|
827
|
+
if (null == namespaces) {
|
|
828
|
+
// If you set a process.env field to null or undefined, it gets cast to the
|
|
829
|
+
// string 'null' or 'undefined'. Just delete instead.
|
|
830
|
+
delete process.env.DEBUG;
|
|
831
|
+
} else {
|
|
832
|
+
process.env.DEBUG = namespaces;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Load `namespaces`.
|
|
838
|
+
*
|
|
839
|
+
* @return {String} returns the previously persisted debug modes
|
|
840
|
+
* @api private
|
|
841
|
+
*/
|
|
842
|
+
|
|
843
|
+
function load() {
|
|
844
|
+
return process.env.DEBUG;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Copied from `node/src/node.js`.
|
|
849
|
+
*
|
|
850
|
+
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also
|
|
851
|
+
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
|
|
852
|
+
*/
|
|
853
|
+
|
|
854
|
+
function createWritableStdioStream (fd) {
|
|
855
|
+
var stream;
|
|
856
|
+
var tty_wrap = process.binding('tty_wrap');
|
|
857
|
+
|
|
858
|
+
// Note stream._type is used for test-module-load-list.js
|
|
859
|
+
|
|
860
|
+
switch (tty_wrap.guessHandleType(fd)) {
|
|
861
|
+
case 'TTY':
|
|
862
|
+
stream = new tty.WriteStream(fd);
|
|
863
|
+
stream._type = 'tty';
|
|
864
|
+
|
|
865
|
+
// Hack to have stream not keep the event loop alive.
|
|
866
|
+
// See https://github.com/joyent/node/issues/1726
|
|
867
|
+
if (stream._handle && stream._handle.unref) {
|
|
868
|
+
stream._handle.unref();
|
|
869
|
+
}
|
|
870
|
+
break;
|
|
871
|
+
|
|
872
|
+
case 'FILE':
|
|
873
|
+
var fs = require$$0$3;
|
|
874
|
+
stream = new fs.SyncWriteStream(fd, { autoClose: false });
|
|
875
|
+
stream._type = 'fs';
|
|
876
|
+
break;
|
|
877
|
+
|
|
878
|
+
case 'PIPE':
|
|
879
|
+
case 'TCP':
|
|
880
|
+
var net = require$$4;
|
|
881
|
+
stream = new net.Socket({
|
|
882
|
+
fd: fd,
|
|
883
|
+
readable: false,
|
|
884
|
+
writable: true
|
|
885
|
+
});
|
|
886
|
+
|
|
887
|
+
// FIXME Should probably have an option in net.Socket to create a
|
|
888
|
+
// stream from an existing fd which is writable only. But for now
|
|
889
|
+
// we'll just add this hack and set the `readable` member to false.
|
|
890
|
+
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
|
891
|
+
stream.readable = false;
|
|
892
|
+
stream.read = null;
|
|
893
|
+
stream._type = 'pipe';
|
|
894
|
+
|
|
895
|
+
// FIXME Hack to have stream not keep the event loop alive.
|
|
896
|
+
// See https://github.com/joyent/node/issues/1726
|
|
897
|
+
if (stream._handle && stream._handle.unref) {
|
|
898
|
+
stream._handle.unref();
|
|
899
|
+
}
|
|
900
|
+
break;
|
|
901
|
+
|
|
902
|
+
default:
|
|
903
|
+
// Probably an error on in uv_guess_handle()
|
|
904
|
+
throw new Error('Implement me. Unknown stream file type!');
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// For supporting legacy API we put the FD here.
|
|
908
|
+
stream.fd = fd;
|
|
909
|
+
|
|
910
|
+
stream._isStdio = true;
|
|
911
|
+
|
|
912
|
+
return stream;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Init logic for `debug` instances.
|
|
917
|
+
*
|
|
918
|
+
* Create a new `inspectOpts` object in case `useColors` is set
|
|
919
|
+
* differently for a particular `debug` instance.
|
|
920
|
+
*/
|
|
921
|
+
|
|
922
|
+
function init (debug) {
|
|
923
|
+
debug.inspectOpts = {};
|
|
924
|
+
|
|
925
|
+
var keys = Object.keys(exports.inspectOpts);
|
|
926
|
+
for (var i = 0; i < keys.length; i++) {
|
|
927
|
+
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Enable namespaces listed in `process.env.DEBUG` initially.
|
|
933
|
+
*/
|
|
934
|
+
|
|
935
|
+
exports.enable(load());
|
|
936
|
+
}(node$1, node$1.exports));
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* Detect Electron renderer process, which is node, but we should
|
|
940
|
+
* treat as a browser.
|
|
941
|
+
*/
|
|
942
|
+
|
|
943
|
+
if (typeof process !== 'undefined' && process.type === 'renderer') {
|
|
944
|
+
src$1.exports = browser$1.exports;
|
|
945
|
+
} else {
|
|
946
|
+
src$1.exports = node$1.exports;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
var src = {exports: {}};
|
|
950
|
+
|
|
951
|
+
var browser = {exports: {}};
|
|
952
|
+
|
|
953
|
+
var debug$2 = {exports: {}};
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Helpers.
|
|
957
|
+
*/
|
|
958
|
+
|
|
959
|
+
var s = 1000;
|
|
960
|
+
var m = s * 60;
|
|
961
|
+
var h = m * 60;
|
|
962
|
+
var d = h * 24;
|
|
963
|
+
var y = d * 365.25;
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* Parse or format the given `val`.
|
|
967
|
+
*
|
|
968
|
+
* Options:
|
|
969
|
+
*
|
|
970
|
+
* - `long` verbose formatting [false]
|
|
971
|
+
*
|
|
972
|
+
* @param {String|Number} val
|
|
973
|
+
* @param {Object} [options]
|
|
974
|
+
* @throws {Error} throw an error if val is not a non-empty string or a number
|
|
975
|
+
* @return {String|Number}
|
|
976
|
+
* @api public
|
|
977
|
+
*/
|
|
978
|
+
|
|
979
|
+
var ms = function(val, options) {
|
|
980
|
+
options = options || {};
|
|
981
|
+
var type = typeof val;
|
|
982
|
+
if (type === 'string' && val.length > 0) {
|
|
983
|
+
return parse$1(val);
|
|
984
|
+
} else if (type === 'number' && isNaN(val) === false) {
|
|
985
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
986
|
+
}
|
|
987
|
+
throw new Error(
|
|
988
|
+
'val is not a non-empty string or a valid number. val=' +
|
|
989
|
+
JSON.stringify(val)
|
|
990
|
+
);
|
|
991
|
+
};
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Parse the given `str` and return milliseconds.
|
|
995
|
+
*
|
|
996
|
+
* @param {String} str
|
|
997
|
+
* @return {Number}
|
|
998
|
+
* @api private
|
|
999
|
+
*/
|
|
1000
|
+
|
|
1001
|
+
function parse$1(str) {
|
|
1002
|
+
str = String(str);
|
|
1003
|
+
if (str.length > 100) {
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
|
|
1007
|
+
str
|
|
1008
|
+
);
|
|
1009
|
+
if (!match) {
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
var n = parseFloat(match[1]);
|
|
1013
|
+
var type = (match[2] || 'ms').toLowerCase();
|
|
1014
|
+
switch (type) {
|
|
1015
|
+
case 'years':
|
|
1016
|
+
case 'year':
|
|
1017
|
+
case 'yrs':
|
|
1018
|
+
case 'yr':
|
|
1019
|
+
case 'y':
|
|
1020
|
+
return n * y;
|
|
1021
|
+
case 'days':
|
|
1022
|
+
case 'day':
|
|
1023
|
+
case 'd':
|
|
1024
|
+
return n * d;
|
|
1025
|
+
case 'hours':
|
|
1026
|
+
case 'hour':
|
|
1027
|
+
case 'hrs':
|
|
1028
|
+
case 'hr':
|
|
1029
|
+
case 'h':
|
|
1030
|
+
return n * h;
|
|
1031
|
+
case 'minutes':
|
|
1032
|
+
case 'minute':
|
|
1033
|
+
case 'mins':
|
|
1034
|
+
case 'min':
|
|
1035
|
+
case 'm':
|
|
1036
|
+
return n * m;
|
|
1037
|
+
case 'seconds':
|
|
1038
|
+
case 'second':
|
|
1039
|
+
case 'secs':
|
|
1040
|
+
case 'sec':
|
|
1041
|
+
case 's':
|
|
1042
|
+
return n * s;
|
|
1043
|
+
case 'milliseconds':
|
|
1044
|
+
case 'millisecond':
|
|
1045
|
+
case 'msecs':
|
|
1046
|
+
case 'msec':
|
|
1047
|
+
case 'ms':
|
|
1048
|
+
return n;
|
|
1049
|
+
default:
|
|
1050
|
+
return undefined;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* Short format for `ms`.
|
|
1056
|
+
*
|
|
1057
|
+
* @param {Number} ms
|
|
1058
|
+
* @return {String}
|
|
1059
|
+
* @api private
|
|
1060
|
+
*/
|
|
1061
|
+
|
|
1062
|
+
function fmtShort(ms) {
|
|
1063
|
+
if (ms >= d) {
|
|
1064
|
+
return Math.round(ms / d) + 'd';
|
|
1065
|
+
}
|
|
1066
|
+
if (ms >= h) {
|
|
1067
|
+
return Math.round(ms / h) + 'h';
|
|
1068
|
+
}
|
|
1069
|
+
if (ms >= m) {
|
|
1070
|
+
return Math.round(ms / m) + 'm';
|
|
1071
|
+
}
|
|
1072
|
+
if (ms >= s) {
|
|
1073
|
+
return Math.round(ms / s) + 's';
|
|
1074
|
+
}
|
|
1075
|
+
return ms + 'ms';
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
/**
|
|
1079
|
+
* Long format for `ms`.
|
|
1080
|
+
*
|
|
1081
|
+
* @param {Number} ms
|
|
1082
|
+
* @return {String}
|
|
1083
|
+
* @api private
|
|
1084
|
+
*/
|
|
1085
|
+
|
|
1086
|
+
function fmtLong(ms) {
|
|
1087
|
+
return plural(ms, d, 'day') ||
|
|
1088
|
+
plural(ms, h, 'hour') ||
|
|
1089
|
+
plural(ms, m, 'minute') ||
|
|
1090
|
+
plural(ms, s, 'second') ||
|
|
1091
|
+
ms + ' ms';
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
/**
|
|
1095
|
+
* Pluralization helper.
|
|
1096
|
+
*/
|
|
1097
|
+
|
|
1098
|
+
function plural(ms, n, name) {
|
|
1099
|
+
if (ms < n) {
|
|
1100
|
+
return;
|
|
1101
|
+
}
|
|
1102
|
+
if (ms < n * 1.5) {
|
|
1103
|
+
return Math.floor(ms / n) + ' ' + name;
|
|
1104
|
+
}
|
|
1105
|
+
return Math.ceil(ms / n) + ' ' + name + 's';
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
(function (module, exports) {
|
|
1109
|
+
/**
|
|
1110
|
+
* This is the common logic for both the Node.js and web browser
|
|
1111
|
+
* implementations of `debug()`.
|
|
1112
|
+
*
|
|
1113
|
+
* Expose `debug()` as the module.
|
|
1114
|
+
*/
|
|
1115
|
+
|
|
1116
|
+
exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
|
|
1117
|
+
exports.coerce = coerce;
|
|
1118
|
+
exports.disable = disable;
|
|
1119
|
+
exports.enable = enable;
|
|
1120
|
+
exports.enabled = enabled;
|
|
1121
|
+
exports.humanize = ms;
|
|
1122
|
+
|
|
1123
|
+
/**
|
|
1124
|
+
* The currently active debug mode names, and names to skip.
|
|
1125
|
+
*/
|
|
1126
|
+
|
|
1127
|
+
exports.names = [];
|
|
1128
|
+
exports.skips = [];
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* Map of special "%n" handling functions, for the debug "format" argument.
|
|
1132
|
+
*
|
|
1133
|
+
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
|
1134
|
+
*/
|
|
1135
|
+
|
|
1136
|
+
exports.formatters = {};
|
|
1137
|
+
|
|
1138
|
+
/**
|
|
1139
|
+
* Previous log timestamp.
|
|
1140
|
+
*/
|
|
1141
|
+
|
|
1142
|
+
var prevTime;
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* Select a color.
|
|
1146
|
+
* @param {String} namespace
|
|
1147
|
+
* @return {Number}
|
|
1148
|
+
* @api private
|
|
1149
|
+
*/
|
|
1150
|
+
|
|
1151
|
+
function selectColor(namespace) {
|
|
1152
|
+
var hash = 0, i;
|
|
1153
|
+
|
|
1154
|
+
for (i in namespace) {
|
|
1155
|
+
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
|
1156
|
+
hash |= 0; // Convert to 32bit integer
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
return exports.colors[Math.abs(hash) % exports.colors.length];
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
/**
|
|
1163
|
+
* Create a debugger with the given `namespace`.
|
|
1164
|
+
*
|
|
1165
|
+
* @param {String} namespace
|
|
1166
|
+
* @return {Function}
|
|
1167
|
+
* @api public
|
|
1168
|
+
*/
|
|
1169
|
+
|
|
1170
|
+
function createDebug(namespace) {
|
|
1171
|
+
|
|
1172
|
+
function debug() {
|
|
1173
|
+
// disabled?
|
|
1174
|
+
if (!debug.enabled) return;
|
|
1175
|
+
|
|
1176
|
+
var self = debug;
|
|
1177
|
+
|
|
1178
|
+
// set `diff` timestamp
|
|
1179
|
+
var curr = +new Date();
|
|
1180
|
+
var ms = curr - (prevTime || curr);
|
|
1181
|
+
self.diff = ms;
|
|
1182
|
+
self.prev = prevTime;
|
|
1183
|
+
self.curr = curr;
|
|
1184
|
+
prevTime = curr;
|
|
1185
|
+
|
|
1186
|
+
// turn the `arguments` into a proper Array
|
|
1187
|
+
var args = new Array(arguments.length);
|
|
1188
|
+
for (var i = 0; i < args.length; i++) {
|
|
1189
|
+
args[i] = arguments[i];
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
args[0] = exports.coerce(args[0]);
|
|
1193
|
+
|
|
1194
|
+
if ('string' !== typeof args[0]) {
|
|
1195
|
+
// anything else let's inspect with %O
|
|
1196
|
+
args.unshift('%O');
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// apply any `formatters` transformations
|
|
1200
|
+
var index = 0;
|
|
1201
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
|
|
1202
|
+
// if we encounter an escaped % then don't increase the array index
|
|
1203
|
+
if (match === '%%') return match;
|
|
1204
|
+
index++;
|
|
1205
|
+
var formatter = exports.formatters[format];
|
|
1206
|
+
if ('function' === typeof formatter) {
|
|
1207
|
+
var val = args[index];
|
|
1208
|
+
match = formatter.call(self, val);
|
|
1209
|
+
|
|
1210
|
+
// now we need to remove `args[index]` since it's inlined in the `format`
|
|
1211
|
+
args.splice(index, 1);
|
|
1212
|
+
index--;
|
|
1213
|
+
}
|
|
1214
|
+
return match;
|
|
1215
|
+
});
|
|
1216
|
+
|
|
1217
|
+
// apply env-specific formatting (colors, etc.)
|
|
1218
|
+
exports.formatArgs.call(self, args);
|
|
1219
|
+
|
|
1220
|
+
var logFn = debug.log || exports.log || console.log.bind(console);
|
|
1221
|
+
logFn.apply(self, args);
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
debug.namespace = namespace;
|
|
1225
|
+
debug.enabled = exports.enabled(namespace);
|
|
1226
|
+
debug.useColors = exports.useColors();
|
|
1227
|
+
debug.color = selectColor(namespace);
|
|
1228
|
+
|
|
1229
|
+
// env-specific initialization logic for debug instances
|
|
1230
|
+
if ('function' === typeof exports.init) {
|
|
1231
|
+
exports.init(debug);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
return debug;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Enables a debug mode by namespaces. This can include modes
|
|
1239
|
+
* separated by a colon and wildcards.
|
|
1240
|
+
*
|
|
1241
|
+
* @param {String} namespaces
|
|
1242
|
+
* @api public
|
|
1243
|
+
*/
|
|
1244
|
+
|
|
1245
|
+
function enable(namespaces) {
|
|
1246
|
+
exports.save(namespaces);
|
|
1247
|
+
|
|
1248
|
+
exports.names = [];
|
|
1249
|
+
exports.skips = [];
|
|
1250
|
+
|
|
1251
|
+
var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
|
1252
|
+
var len = split.length;
|
|
1253
|
+
|
|
1254
|
+
for (var i = 0; i < len; i++) {
|
|
1255
|
+
if (!split[i]) continue; // ignore empty strings
|
|
1256
|
+
namespaces = split[i].replace(/\*/g, '.*?');
|
|
1257
|
+
if (namespaces[0] === '-') {
|
|
1258
|
+
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
|
1259
|
+
} else {
|
|
1260
|
+
exports.names.push(new RegExp('^' + namespaces + '$'));
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* Disable debug output.
|
|
1267
|
+
*
|
|
1268
|
+
* @api public
|
|
1269
|
+
*/
|
|
1270
|
+
|
|
1271
|
+
function disable() {
|
|
1272
|
+
exports.enable('');
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* Returns true if the given mode name is enabled, false otherwise.
|
|
1277
|
+
*
|
|
1278
|
+
* @param {String} name
|
|
1279
|
+
* @return {Boolean}
|
|
1280
|
+
* @api public
|
|
1281
|
+
*/
|
|
1282
|
+
|
|
1283
|
+
function enabled(name) {
|
|
1284
|
+
var i, len;
|
|
1285
|
+
for (i = 0, len = exports.skips.length; i < len; i++) {
|
|
1286
|
+
if (exports.skips[i].test(name)) {
|
|
1287
|
+
return false;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
for (i = 0, len = exports.names.length; i < len; i++) {
|
|
1291
|
+
if (exports.names[i].test(name)) {
|
|
1292
|
+
return true;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
return false;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
/**
|
|
1299
|
+
* Coerce `val`.
|
|
1300
|
+
*
|
|
1301
|
+
* @param {Mixed} val
|
|
1302
|
+
* @return {Mixed}
|
|
1303
|
+
* @api private
|
|
1304
|
+
*/
|
|
1305
|
+
|
|
1306
|
+
function coerce(val) {
|
|
1307
|
+
if (val instanceof Error) return val.stack || val.message;
|
|
1308
|
+
return val;
|
|
1309
|
+
}
|
|
1310
|
+
}(debug$2, debug$2.exports));
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* This is the web browser implementation of `debug()`.
|
|
1314
|
+
*
|
|
1315
|
+
* Expose `debug()` as the module.
|
|
1316
|
+
*/
|
|
1317
|
+
|
|
1318
|
+
(function (module, exports) {
|
|
1319
|
+
exports = module.exports = debug$2.exports;
|
|
1320
|
+
exports.log = log;
|
|
1321
|
+
exports.formatArgs = formatArgs;
|
|
1322
|
+
exports.save = save;
|
|
1323
|
+
exports.load = load;
|
|
1324
|
+
exports.useColors = useColors;
|
|
1325
|
+
exports.storage = 'undefined' != typeof chrome
|
|
1326
|
+
&& 'undefined' != typeof chrome.storage
|
|
1327
|
+
? chrome.storage.local
|
|
1328
|
+
: localstorage();
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* Colors.
|
|
1332
|
+
*/
|
|
1333
|
+
|
|
1334
|
+
exports.colors = [
|
|
1335
|
+
'lightseagreen',
|
|
1336
|
+
'forestgreen',
|
|
1337
|
+
'goldenrod',
|
|
1338
|
+
'dodgerblue',
|
|
1339
|
+
'darkorchid',
|
|
1340
|
+
'crimson'
|
|
1341
|
+
];
|
|
1342
|
+
|
|
1343
|
+
/**
|
|
1344
|
+
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
|
1345
|
+
* and the Firebug extension (any Firefox version) are known
|
|
1346
|
+
* to support "%c" CSS customizations.
|
|
1347
|
+
*
|
|
1348
|
+
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
|
1349
|
+
*/
|
|
1350
|
+
|
|
1351
|
+
function useColors() {
|
|
1352
|
+
// NB: In an Electron preload script, document will be defined but not fully
|
|
1353
|
+
// initialized. Since we know we're in Chrome, we'll just detect this case
|
|
1354
|
+
// explicitly
|
|
1355
|
+
if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
|
|
1356
|
+
return true;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
// is webkit? http://stackoverflow.com/a/16459606/376773
|
|
1360
|
+
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
|
1361
|
+
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
|
1362
|
+
// is firebug? http://stackoverflow.com/a/398120/376773
|
|
1363
|
+
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
|
1364
|
+
// is firefox >= v31?
|
|
1365
|
+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
1366
|
+
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
|
|
1367
|
+
// double check webkit in userAgent just in case we are in a worker
|
|
1368
|
+
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
|
1373
|
+
*/
|
|
1374
|
+
|
|
1375
|
+
exports.formatters.j = function(v) {
|
|
1376
|
+
try {
|
|
1377
|
+
return JSON.stringify(v);
|
|
1378
|
+
} catch (err) {
|
|
1379
|
+
return '[UnexpectedJSONParseError]: ' + err.message;
|
|
1380
|
+
}
|
|
1381
|
+
};
|
|
1382
|
+
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* Colorize log arguments if enabled.
|
|
1386
|
+
*
|
|
1387
|
+
* @api public
|
|
1388
|
+
*/
|
|
1389
|
+
|
|
1390
|
+
function formatArgs(args) {
|
|
1391
|
+
var useColors = this.useColors;
|
|
1392
|
+
|
|
1393
|
+
args[0] = (useColors ? '%c' : '')
|
|
1394
|
+
+ this.namespace
|
|
1395
|
+
+ (useColors ? ' %c' : ' ')
|
|
1396
|
+
+ args[0]
|
|
1397
|
+
+ (useColors ? '%c ' : ' ')
|
|
1398
|
+
+ '+' + exports.humanize(this.diff);
|
|
1399
|
+
|
|
1400
|
+
if (!useColors) return;
|
|
1401
|
+
|
|
1402
|
+
var c = 'color: ' + this.color;
|
|
1403
|
+
args.splice(1, 0, c, 'color: inherit');
|
|
1404
|
+
|
|
1405
|
+
// the final "%c" is somewhat tricky, because there could be other
|
|
1406
|
+
// arguments passed either before or after the %c, so we need to
|
|
1407
|
+
// figure out the correct index to insert the CSS into
|
|
1408
|
+
var index = 0;
|
|
1409
|
+
var lastC = 0;
|
|
1410
|
+
args[0].replace(/%[a-zA-Z%]/g, function(match) {
|
|
1411
|
+
if ('%%' === match) return;
|
|
1412
|
+
index++;
|
|
1413
|
+
if ('%c' === match) {
|
|
1414
|
+
// we only are interested in the *last* %c
|
|
1415
|
+
// (the user may have provided their own)
|
|
1416
|
+
lastC = index;
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1419
|
+
|
|
1420
|
+
args.splice(lastC, 0, c);
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
/**
|
|
1424
|
+
* Invokes `console.log()` when available.
|
|
1425
|
+
* No-op when `console.log` is not a "function".
|
|
1426
|
+
*
|
|
1427
|
+
* @api public
|
|
1428
|
+
*/
|
|
1429
|
+
|
|
1430
|
+
function log() {
|
|
1431
|
+
// this hackery is required for IE8/9, where
|
|
1432
|
+
// the `console.log` function doesn't have 'apply'
|
|
1433
|
+
return 'object' === typeof console
|
|
1434
|
+
&& console.log
|
|
1435
|
+
&& Function.prototype.apply.call(console.log, console, arguments);
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
/**
|
|
1439
|
+
* Save `namespaces`.
|
|
1440
|
+
*
|
|
1441
|
+
* @param {String} namespaces
|
|
1442
|
+
* @api private
|
|
1443
|
+
*/
|
|
1444
|
+
|
|
1445
|
+
function save(namespaces) {
|
|
1446
|
+
try {
|
|
1447
|
+
if (null == namespaces) {
|
|
1448
|
+
exports.storage.removeItem('debug');
|
|
1449
|
+
} else {
|
|
1450
|
+
exports.storage.debug = namespaces;
|
|
1451
|
+
}
|
|
1452
|
+
} catch(e) {}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
/**
|
|
1456
|
+
* Load `namespaces`.
|
|
1457
|
+
*
|
|
1458
|
+
* @return {String} returns the previously persisted debug modes
|
|
1459
|
+
* @api private
|
|
1460
|
+
*/
|
|
1461
|
+
|
|
1462
|
+
function load() {
|
|
1463
|
+
var r;
|
|
1464
|
+
try {
|
|
1465
|
+
r = exports.storage.debug;
|
|
1466
|
+
} catch(e) {}
|
|
1467
|
+
|
|
1468
|
+
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
|
1469
|
+
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
|
1470
|
+
r = process.env.DEBUG;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
return r;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
/**
|
|
1477
|
+
* Enable namespaces listed in `localStorage.debug` initially.
|
|
1478
|
+
*/
|
|
1479
|
+
|
|
1480
|
+
exports.enable(load());
|
|
1481
|
+
|
|
1482
|
+
/**
|
|
1483
|
+
* Localstorage attempts to return the localstorage.
|
|
1484
|
+
*
|
|
1485
|
+
* This is necessary because safari throws
|
|
1486
|
+
* when a user disables cookies/localstorage
|
|
1487
|
+
* and you attempt to access it.
|
|
1488
|
+
*
|
|
1489
|
+
* @return {LocalStorage}
|
|
1490
|
+
* @api private
|
|
1491
|
+
*/
|
|
1492
|
+
|
|
1493
|
+
function localstorage() {
|
|
1494
|
+
try {
|
|
1495
|
+
return window.localStorage;
|
|
1496
|
+
} catch (e) {}
|
|
1497
|
+
}
|
|
1498
|
+
}(browser, browser.exports));
|
|
1499
|
+
|
|
1500
|
+
var node = {exports: {}};
|
|
1501
|
+
|
|
1502
|
+
/**
|
|
1503
|
+
* Module dependencies.
|
|
1504
|
+
*/
|
|
1505
|
+
|
|
1506
|
+
(function (module, exports) {
|
|
1507
|
+
var tty = require$$0$1;
|
|
1508
|
+
var util = require$$0$2;
|
|
1509
|
+
|
|
1510
|
+
/**
|
|
1511
|
+
* This is the Node.js implementation of `debug()`.
|
|
1512
|
+
*
|
|
1513
|
+
* Expose `debug()` as the module.
|
|
1514
|
+
*/
|
|
1515
|
+
|
|
1516
|
+
exports = module.exports = debug$2.exports;
|
|
1517
|
+
exports.init = init;
|
|
1518
|
+
exports.log = log;
|
|
1519
|
+
exports.formatArgs = formatArgs;
|
|
1520
|
+
exports.save = save;
|
|
1521
|
+
exports.load = load;
|
|
1522
|
+
exports.useColors = useColors;
|
|
1523
|
+
|
|
1524
|
+
/**
|
|
1525
|
+
* Colors.
|
|
1526
|
+
*/
|
|
1527
|
+
|
|
1528
|
+
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
1529
|
+
|
|
1530
|
+
/**
|
|
1531
|
+
* Build up the default `inspectOpts` object from the environment variables.
|
|
1532
|
+
*
|
|
1533
|
+
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
|
1534
|
+
*/
|
|
1535
|
+
|
|
1536
|
+
exports.inspectOpts = Object.keys(process.env).filter(function (key) {
|
|
1537
|
+
return /^debug_/i.test(key);
|
|
1538
|
+
}).reduce(function (obj, key) {
|
|
1539
|
+
// camel-case
|
|
1540
|
+
var prop = key
|
|
1541
|
+
.substring(6)
|
|
1542
|
+
.toLowerCase()
|
|
1543
|
+
.replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
|
|
1544
|
+
|
|
1545
|
+
// coerce string value into JS value
|
|
1546
|
+
var val = process.env[key];
|
|
1547
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
|
|
1548
|
+
else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
|
|
1549
|
+
else if (val === 'null') val = null;
|
|
1550
|
+
else val = Number(val);
|
|
1551
|
+
|
|
1552
|
+
obj[prop] = val;
|
|
1553
|
+
return obj;
|
|
1554
|
+
}, {});
|
|
1555
|
+
|
|
1556
|
+
/**
|
|
1557
|
+
* The file descriptor to write the `debug()` calls to.
|
|
1558
|
+
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
|
|
1559
|
+
*
|
|
1560
|
+
* $ DEBUG_FD=3 node script.js 3>debug.log
|
|
1561
|
+
*/
|
|
1562
|
+
|
|
1563
|
+
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
|
|
1564
|
+
|
|
1565
|
+
if (1 !== fd && 2 !== fd) {
|
|
1566
|
+
util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')();
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
var stream = 1 === fd ? process.stdout :
|
|
1570
|
+
2 === fd ? process.stderr :
|
|
1571
|
+
createWritableStdioStream(fd);
|
|
1572
|
+
|
|
1573
|
+
/**
|
|
1574
|
+
* Is stdout a TTY? Colored output is enabled when `true`.
|
|
1575
|
+
*/
|
|
1576
|
+
|
|
1577
|
+
function useColors() {
|
|
1578
|
+
return 'colors' in exports.inspectOpts
|
|
1579
|
+
? Boolean(exports.inspectOpts.colors)
|
|
1580
|
+
: tty.isatty(fd);
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
/**
|
|
1584
|
+
* Map %o to `util.inspect()`, all on a single line.
|
|
1585
|
+
*/
|
|
1586
|
+
|
|
1587
|
+
exports.formatters.o = function(v) {
|
|
1588
|
+
this.inspectOpts.colors = this.useColors;
|
|
1589
|
+
return util.inspect(v, this.inspectOpts)
|
|
1590
|
+
.split('\n').map(function(str) {
|
|
1591
|
+
return str.trim()
|
|
1592
|
+
}).join(' ');
|
|
1593
|
+
};
|
|
1594
|
+
|
|
1595
|
+
/**
|
|
1596
|
+
* Map %o to `util.inspect()`, allowing multiple lines if needed.
|
|
1597
|
+
*/
|
|
1598
|
+
|
|
1599
|
+
exports.formatters.O = function(v) {
|
|
1600
|
+
this.inspectOpts.colors = this.useColors;
|
|
1601
|
+
return util.inspect(v, this.inspectOpts);
|
|
1602
|
+
};
|
|
1603
|
+
|
|
1604
|
+
/**
|
|
1605
|
+
* Adds ANSI color escape codes if enabled.
|
|
1606
|
+
*
|
|
1607
|
+
* @api public
|
|
1608
|
+
*/
|
|
1609
|
+
|
|
1610
|
+
function formatArgs(args) {
|
|
1611
|
+
var name = this.namespace;
|
|
1612
|
+
var useColors = this.useColors;
|
|
1613
|
+
|
|
1614
|
+
if (useColors) {
|
|
1615
|
+
var c = this.color;
|
|
1616
|
+
var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
|
|
1617
|
+
|
|
1618
|
+
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
|
1619
|
+
args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
|
|
1620
|
+
} else {
|
|
1621
|
+
args[0] = new Date().toUTCString()
|
|
1622
|
+
+ ' ' + name + ' ' + args[0];
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
/**
|
|
1627
|
+
* Invokes `util.format()` with the specified arguments and writes to `stream`.
|
|
1628
|
+
*/
|
|
1629
|
+
|
|
1630
|
+
function log() {
|
|
1631
|
+
return stream.write(util.format.apply(util, arguments) + '\n');
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
/**
|
|
1635
|
+
* Save `namespaces`.
|
|
1636
|
+
*
|
|
1637
|
+
* @param {String} namespaces
|
|
1638
|
+
* @api private
|
|
1639
|
+
*/
|
|
1640
|
+
|
|
1641
|
+
function save(namespaces) {
|
|
1642
|
+
if (null == namespaces) {
|
|
1643
|
+
// If you set a process.env field to null or undefined, it gets cast to the
|
|
1644
|
+
// string 'null' or 'undefined'. Just delete instead.
|
|
1645
|
+
delete process.env.DEBUG;
|
|
1646
|
+
} else {
|
|
1647
|
+
process.env.DEBUG = namespaces;
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
/**
|
|
1652
|
+
* Load `namespaces`.
|
|
1653
|
+
*
|
|
1654
|
+
* @return {String} returns the previously persisted debug modes
|
|
1655
|
+
* @api private
|
|
1656
|
+
*/
|
|
1657
|
+
|
|
1658
|
+
function load() {
|
|
1659
|
+
return process.env.DEBUG;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
/**
|
|
1663
|
+
* Copied from `node/src/node.js`.
|
|
1664
|
+
*
|
|
1665
|
+
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also
|
|
1666
|
+
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
|
|
1667
|
+
*/
|
|
1668
|
+
|
|
1669
|
+
function createWritableStdioStream (fd) {
|
|
1670
|
+
var stream;
|
|
1671
|
+
var tty_wrap = process.binding('tty_wrap');
|
|
1672
|
+
|
|
1673
|
+
// Note stream._type is used for test-module-load-list.js
|
|
1674
|
+
|
|
1675
|
+
switch (tty_wrap.guessHandleType(fd)) {
|
|
1676
|
+
case 'TTY':
|
|
1677
|
+
stream = new tty.WriteStream(fd);
|
|
1678
|
+
stream._type = 'tty';
|
|
1679
|
+
|
|
1680
|
+
// Hack to have stream not keep the event loop alive.
|
|
1681
|
+
// See https://github.com/joyent/node/issues/1726
|
|
1682
|
+
if (stream._handle && stream._handle.unref) {
|
|
1683
|
+
stream._handle.unref();
|
|
1684
|
+
}
|
|
1685
|
+
break;
|
|
1686
|
+
|
|
1687
|
+
case 'FILE':
|
|
1688
|
+
var fs = require$$0$3;
|
|
1689
|
+
stream = new fs.SyncWriteStream(fd, { autoClose: false });
|
|
1690
|
+
stream._type = 'fs';
|
|
1691
|
+
break;
|
|
1692
|
+
|
|
1693
|
+
case 'PIPE':
|
|
1694
|
+
case 'TCP':
|
|
1695
|
+
var net = require$$4;
|
|
1696
|
+
stream = new net.Socket({
|
|
1697
|
+
fd: fd,
|
|
1698
|
+
readable: false,
|
|
1699
|
+
writable: true
|
|
1700
|
+
});
|
|
1701
|
+
|
|
1702
|
+
// FIXME Should probably have an option in net.Socket to create a
|
|
1703
|
+
// stream from an existing fd which is writable only. But for now
|
|
1704
|
+
// we'll just add this hack and set the `readable` member to false.
|
|
1705
|
+
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
|
1706
|
+
stream.readable = false;
|
|
1707
|
+
stream.read = null;
|
|
1708
|
+
stream._type = 'pipe';
|
|
1709
|
+
|
|
1710
|
+
// FIXME Hack to have stream not keep the event loop alive.
|
|
1711
|
+
// See https://github.com/joyent/node/issues/1726
|
|
1712
|
+
if (stream._handle && stream._handle.unref) {
|
|
1713
|
+
stream._handle.unref();
|
|
1714
|
+
}
|
|
1715
|
+
break;
|
|
1716
|
+
|
|
1717
|
+
default:
|
|
1718
|
+
// Probably an error on in uv_guess_handle()
|
|
1719
|
+
throw new Error('Implement me. Unknown stream file type!');
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
// For supporting legacy API we put the FD here.
|
|
1723
|
+
stream.fd = fd;
|
|
1724
|
+
|
|
1725
|
+
stream._isStdio = true;
|
|
1726
|
+
|
|
1727
|
+
return stream;
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
/**
|
|
1731
|
+
* Init logic for `debug` instances.
|
|
1732
|
+
*
|
|
1733
|
+
* Create a new `inspectOpts` object in case `useColors` is set
|
|
1734
|
+
* differently for a particular `debug` instance.
|
|
1735
|
+
*/
|
|
1736
|
+
|
|
1737
|
+
function init (debug) {
|
|
1738
|
+
debug.inspectOpts = {};
|
|
1739
|
+
|
|
1740
|
+
var keys = Object.keys(exports.inspectOpts);
|
|
1741
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1742
|
+
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
/**
|
|
1747
|
+
* Enable namespaces listed in `process.env.DEBUG` initially.
|
|
1748
|
+
*/
|
|
1749
|
+
|
|
1750
|
+
exports.enable(load());
|
|
1751
|
+
}(node, node.exports));
|
|
1752
|
+
|
|
1753
|
+
/**
|
|
1754
|
+
* Detect Electron renderer process, which is node, but we should
|
|
1755
|
+
* treat as a browser.
|
|
1756
|
+
*/
|
|
1757
|
+
|
|
1758
|
+
if (typeof process !== 'undefined' && process.type === 'renderer') {
|
|
1759
|
+
src.exports = browser.exports;
|
|
1760
|
+
} else {
|
|
1761
|
+
src.exports = node.exports;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
/*!
|
|
1765
|
+
* encodeurl
|
|
1766
|
+
* Copyright(c) 2016 Douglas Christopher Wilson
|
|
1767
|
+
* MIT Licensed
|
|
1768
|
+
*/
|
|
1769
|
+
|
|
1770
|
+
/**
|
|
1771
|
+
* Module exports.
|
|
1772
|
+
* @public
|
|
1773
|
+
*/
|
|
1774
|
+
|
|
1775
|
+
var encodeurl = encodeUrl$1;
|
|
1776
|
+
|
|
1777
|
+
/**
|
|
1778
|
+
* RegExp to match non-URL code points, *after* encoding (i.e. not including "%")
|
|
1779
|
+
* and including invalid escape sequences.
|
|
1780
|
+
* @private
|
|
1781
|
+
*/
|
|
1782
|
+
|
|
1783
|
+
var ENCODE_CHARS_REGEXP = /(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x61-\x7A\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g;
|
|
1784
|
+
|
|
1785
|
+
/**
|
|
1786
|
+
* RegExp to match unmatched surrogate pair.
|
|
1787
|
+
* @private
|
|
1788
|
+
*/
|
|
1789
|
+
|
|
1790
|
+
var UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g;
|
|
1791
|
+
|
|
1792
|
+
/**
|
|
1793
|
+
* String to replace unmatched surrogate pair with.
|
|
1794
|
+
* @private
|
|
1795
|
+
*/
|
|
1796
|
+
|
|
1797
|
+
var UNMATCHED_SURROGATE_PAIR_REPLACE = '$1\uFFFD$2';
|
|
1798
|
+
|
|
1799
|
+
/**
|
|
1800
|
+
* Encode a URL to a percent-encoded form, excluding already-encoded sequences.
|
|
1801
|
+
*
|
|
1802
|
+
* This function will take an already-encoded URL and encode all the non-URL
|
|
1803
|
+
* code points. This function will not encode the "%" character unless it is
|
|
1804
|
+
* not part of a valid sequence (`%20` will be left as-is, but `%foo` will
|
|
1805
|
+
* be encoded as `%25foo`).
|
|
1806
|
+
*
|
|
1807
|
+
* This encode is meant to be "safe" and does not throw errors. It will try as
|
|
1808
|
+
* hard as it can to properly encode the given URL, including replacing any raw,
|
|
1809
|
+
* unpaired surrogate pairs with the Unicode replacement character prior to
|
|
1810
|
+
* encoding.
|
|
1811
|
+
*
|
|
1812
|
+
* @param {string} url
|
|
1813
|
+
* @return {string}
|
|
1814
|
+
* @public
|
|
1815
|
+
*/
|
|
1816
|
+
|
|
1817
|
+
function encodeUrl$1 (url) {
|
|
1818
|
+
return String(url)
|
|
1819
|
+
.replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE)
|
|
1820
|
+
.replace(ENCODE_CHARS_REGEXP, encodeURI)
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
/*!
|
|
1824
|
+
* escape-html
|
|
1825
|
+
* Copyright(c) 2012-2013 TJ Holowaychuk
|
|
1826
|
+
* Copyright(c) 2015 Andreas Lubbe
|
|
1827
|
+
* Copyright(c) 2015 Tiancheng "Timothy" Gu
|
|
1828
|
+
* MIT Licensed
|
|
1829
|
+
*/
|
|
1830
|
+
|
|
1831
|
+
/**
|
|
1832
|
+
* Module variables.
|
|
1833
|
+
* @private
|
|
1834
|
+
*/
|
|
1835
|
+
|
|
1836
|
+
var matchHtmlRegExp = /["'&<>]/;
|
|
1837
|
+
|
|
1838
|
+
/**
|
|
1839
|
+
* Module exports.
|
|
1840
|
+
* @public
|
|
1841
|
+
*/
|
|
1842
|
+
|
|
1843
|
+
var escapeHtml_1 = escapeHtml$1;
|
|
1844
|
+
|
|
1845
|
+
/**
|
|
1846
|
+
* Escape special characters in the given string of html.
|
|
1847
|
+
*
|
|
1848
|
+
* @param {string} string The string to escape for inserting into HTML
|
|
1849
|
+
* @return {string}
|
|
1850
|
+
* @public
|
|
1851
|
+
*/
|
|
1852
|
+
|
|
1853
|
+
function escapeHtml$1(string) {
|
|
1854
|
+
var str = '' + string;
|
|
1855
|
+
var match = matchHtmlRegExp.exec(str);
|
|
1856
|
+
|
|
1857
|
+
if (!match) {
|
|
1858
|
+
return str;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
var escape;
|
|
1862
|
+
var html = '';
|
|
1863
|
+
var index = 0;
|
|
1864
|
+
var lastIndex = 0;
|
|
1865
|
+
|
|
1866
|
+
for (index = match.index; index < str.length; index++) {
|
|
1867
|
+
switch (str.charCodeAt(index)) {
|
|
1868
|
+
case 34: // "
|
|
1869
|
+
escape = '"';
|
|
1870
|
+
break;
|
|
1871
|
+
case 38: // &
|
|
1872
|
+
escape = '&';
|
|
1873
|
+
break;
|
|
1874
|
+
case 39: // '
|
|
1875
|
+
escape = ''';
|
|
1876
|
+
break;
|
|
1877
|
+
case 60: // <
|
|
1878
|
+
escape = '<';
|
|
1879
|
+
break;
|
|
1880
|
+
case 62: // >
|
|
1881
|
+
escape = '>';
|
|
1882
|
+
break;
|
|
1883
|
+
default:
|
|
1884
|
+
continue;
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
if (lastIndex !== index) {
|
|
1888
|
+
html += str.substring(lastIndex, index);
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
lastIndex = index + 1;
|
|
1892
|
+
html += escape;
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
return lastIndex !== index
|
|
1896
|
+
? html + str.substring(lastIndex, index)
|
|
1897
|
+
: html;
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
var onFinished$2 = {exports: {}};
|
|
1901
|
+
|
|
1902
|
+
/*!
|
|
1903
|
+
* ee-first
|
|
1904
|
+
* Copyright(c) 2014 Jonathan Ong
|
|
1905
|
+
* MIT Licensed
|
|
1906
|
+
*/
|
|
1907
|
+
|
|
1908
|
+
/**
|
|
1909
|
+
* Module exports.
|
|
1910
|
+
* @public
|
|
1911
|
+
*/
|
|
1912
|
+
|
|
1913
|
+
var eeFirst = first$1;
|
|
1914
|
+
|
|
1915
|
+
/**
|
|
1916
|
+
* Get the first event in a set of event emitters and event pairs.
|
|
1917
|
+
*
|
|
1918
|
+
* @param {array} stuff
|
|
1919
|
+
* @param {function} done
|
|
1920
|
+
* @public
|
|
1921
|
+
*/
|
|
1922
|
+
|
|
1923
|
+
function first$1(stuff, done) {
|
|
1924
|
+
if (!Array.isArray(stuff))
|
|
1925
|
+
throw new TypeError('arg must be an array of [ee, events...] arrays')
|
|
1926
|
+
|
|
1927
|
+
var cleanups = [];
|
|
1928
|
+
|
|
1929
|
+
for (var i = 0; i < stuff.length; i++) {
|
|
1930
|
+
var arr = stuff[i];
|
|
1931
|
+
|
|
1932
|
+
if (!Array.isArray(arr) || arr.length < 2)
|
|
1933
|
+
throw new TypeError('each array member must be [ee, events...]')
|
|
1934
|
+
|
|
1935
|
+
var ee = arr[0];
|
|
1936
|
+
|
|
1937
|
+
for (var j = 1; j < arr.length; j++) {
|
|
1938
|
+
var event = arr[j];
|
|
1939
|
+
var fn = listener(event, callback);
|
|
1940
|
+
|
|
1941
|
+
// listen to the event
|
|
1942
|
+
ee.on(event, fn);
|
|
1943
|
+
// push this listener to the list of cleanups
|
|
1944
|
+
cleanups.push({
|
|
1945
|
+
ee: ee,
|
|
1946
|
+
event: event,
|
|
1947
|
+
fn: fn,
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
function callback() {
|
|
1953
|
+
cleanup();
|
|
1954
|
+
done.apply(null, arguments);
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
function cleanup() {
|
|
1958
|
+
var x;
|
|
1959
|
+
for (var i = 0; i < cleanups.length; i++) {
|
|
1960
|
+
x = cleanups[i];
|
|
1961
|
+
x.ee.removeListener(x.event, x.fn);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
function thunk(fn) {
|
|
1966
|
+
done = fn;
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
thunk.cancel = cleanup;
|
|
1970
|
+
|
|
1971
|
+
return thunk
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
/**
|
|
1975
|
+
* Create the event listener.
|
|
1976
|
+
* @private
|
|
1977
|
+
*/
|
|
1978
|
+
|
|
1979
|
+
function listener(event, done) {
|
|
1980
|
+
return function onevent(arg1) {
|
|
1981
|
+
var args = new Array(arguments.length);
|
|
1982
|
+
var ee = this;
|
|
1983
|
+
var err = event === 'error'
|
|
1984
|
+
? arg1
|
|
1985
|
+
: null;
|
|
1986
|
+
|
|
1987
|
+
// copy args to prevent arguments escaping scope
|
|
1988
|
+
for (var i = 0; i < args.length; i++) {
|
|
1989
|
+
args[i] = arguments[i];
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
done(err, ee, event, args);
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
/*!
|
|
1997
|
+
* on-finished
|
|
1998
|
+
* Copyright(c) 2013 Jonathan Ong
|
|
1999
|
+
* Copyright(c) 2014 Douglas Christopher Wilson
|
|
2000
|
+
* MIT Licensed
|
|
2001
|
+
*/
|
|
2002
|
+
|
|
2003
|
+
/**
|
|
2004
|
+
* Module exports.
|
|
2005
|
+
* @public
|
|
2006
|
+
*/
|
|
2007
|
+
|
|
2008
|
+
onFinished$2.exports = onFinished$1;
|
|
2009
|
+
onFinished$2.exports.isFinished = isFinished$1;
|
|
2010
|
+
|
|
2011
|
+
/**
|
|
2012
|
+
* Module dependencies.
|
|
2013
|
+
* @private
|
|
2014
|
+
*/
|
|
2015
|
+
|
|
2016
|
+
var first = eeFirst;
|
|
2017
|
+
|
|
2018
|
+
/**
|
|
2019
|
+
* Variables.
|
|
2020
|
+
* @private
|
|
2021
|
+
*/
|
|
2022
|
+
|
|
2023
|
+
/* istanbul ignore next */
|
|
2024
|
+
var defer$2 = typeof setImmediate === 'function'
|
|
2025
|
+
? setImmediate
|
|
2026
|
+
: function(fn){ process.nextTick(fn.bind.apply(fn, arguments)); };
|
|
2027
|
+
|
|
2028
|
+
/**
|
|
2029
|
+
* Invoke callback when the response has finished, useful for
|
|
2030
|
+
* cleaning up resources afterwards.
|
|
2031
|
+
*
|
|
2032
|
+
* @param {object} msg
|
|
2033
|
+
* @param {function} listener
|
|
2034
|
+
* @return {object}
|
|
2035
|
+
* @public
|
|
2036
|
+
*/
|
|
2037
|
+
|
|
2038
|
+
function onFinished$1(msg, listener) {
|
|
2039
|
+
if (isFinished$1(msg) !== false) {
|
|
2040
|
+
defer$2(listener, null, msg);
|
|
2041
|
+
return msg
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
// attach the listener to the message
|
|
2045
|
+
attachListener(msg, listener);
|
|
2046
|
+
|
|
2047
|
+
return msg
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
/**
|
|
2051
|
+
* Determine if message is already finished.
|
|
2052
|
+
*
|
|
2053
|
+
* @param {object} msg
|
|
2054
|
+
* @return {boolean}
|
|
2055
|
+
* @public
|
|
2056
|
+
*/
|
|
2057
|
+
|
|
2058
|
+
function isFinished$1(msg) {
|
|
2059
|
+
var socket = msg.socket;
|
|
2060
|
+
|
|
2061
|
+
if (typeof msg.finished === 'boolean') {
|
|
2062
|
+
// OutgoingMessage
|
|
2063
|
+
return Boolean(msg.finished || (socket && !socket.writable))
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
if (typeof msg.complete === 'boolean') {
|
|
2067
|
+
// IncomingMessage
|
|
2068
|
+
return Boolean(msg.upgrade || !socket || !socket.readable || (msg.complete && !msg.readable))
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
// don't know
|
|
2072
|
+
return undefined
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
/**
|
|
2076
|
+
* Attach a finished listener to the message.
|
|
2077
|
+
*
|
|
2078
|
+
* @param {object} msg
|
|
2079
|
+
* @param {function} callback
|
|
2080
|
+
* @private
|
|
2081
|
+
*/
|
|
2082
|
+
|
|
2083
|
+
function attachFinishedListener(msg, callback) {
|
|
2084
|
+
var eeMsg;
|
|
2085
|
+
var eeSocket;
|
|
2086
|
+
var finished = false;
|
|
2087
|
+
|
|
2088
|
+
function onFinish(error) {
|
|
2089
|
+
eeMsg.cancel();
|
|
2090
|
+
eeSocket.cancel();
|
|
2091
|
+
|
|
2092
|
+
finished = true;
|
|
2093
|
+
callback(error);
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
// finished on first message event
|
|
2097
|
+
eeMsg = eeSocket = first([[msg, 'end', 'finish']], onFinish);
|
|
2098
|
+
|
|
2099
|
+
function onSocket(socket) {
|
|
2100
|
+
// remove listener
|
|
2101
|
+
msg.removeListener('socket', onSocket);
|
|
2102
|
+
|
|
2103
|
+
if (finished) return
|
|
2104
|
+
if (eeMsg !== eeSocket) return
|
|
2105
|
+
|
|
2106
|
+
// finished on first socket event
|
|
2107
|
+
eeSocket = first([[socket, 'error', 'close']], onFinish);
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
if (msg.socket) {
|
|
2111
|
+
// socket already assigned
|
|
2112
|
+
onSocket(msg.socket);
|
|
2113
|
+
return
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
// wait for socket to be assigned
|
|
2117
|
+
msg.on('socket', onSocket);
|
|
2118
|
+
|
|
2119
|
+
if (msg.socket === undefined) {
|
|
2120
|
+
// node.js 0.8 patch
|
|
2121
|
+
patchAssignSocket(msg, onSocket);
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
/**
|
|
2126
|
+
* Attach the listener to the message.
|
|
2127
|
+
*
|
|
2128
|
+
* @param {object} msg
|
|
2129
|
+
* @return {function}
|
|
2130
|
+
* @private
|
|
2131
|
+
*/
|
|
2132
|
+
|
|
2133
|
+
function attachListener(msg, listener) {
|
|
2134
|
+
var attached = msg.__onFinished;
|
|
2135
|
+
|
|
2136
|
+
// create a private single listener with queue
|
|
2137
|
+
if (!attached || !attached.queue) {
|
|
2138
|
+
attached = msg.__onFinished = createListener(msg);
|
|
2139
|
+
attachFinishedListener(msg, attached);
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
attached.queue.push(listener);
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
/**
|
|
2146
|
+
* Create listener on message.
|
|
2147
|
+
*
|
|
2148
|
+
* @param {object} msg
|
|
2149
|
+
* @return {function}
|
|
2150
|
+
* @private
|
|
2151
|
+
*/
|
|
2152
|
+
|
|
2153
|
+
function createListener(msg) {
|
|
2154
|
+
function listener(err) {
|
|
2155
|
+
if (msg.__onFinished === listener) msg.__onFinished = null;
|
|
2156
|
+
if (!listener.queue) return
|
|
2157
|
+
|
|
2158
|
+
var queue = listener.queue;
|
|
2159
|
+
listener.queue = null;
|
|
2160
|
+
|
|
2161
|
+
for (var i = 0; i < queue.length; i++) {
|
|
2162
|
+
queue[i](err, msg);
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
listener.queue = [];
|
|
2167
|
+
|
|
2168
|
+
return listener
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
/**
|
|
2172
|
+
* Patch ServerResponse.prototype.assignSocket for node.js 0.8.
|
|
2173
|
+
*
|
|
2174
|
+
* @param {ServerResponse} res
|
|
2175
|
+
* @param {function} callback
|
|
2176
|
+
* @private
|
|
2177
|
+
*/
|
|
2178
|
+
|
|
2179
|
+
function patchAssignSocket(res, callback) {
|
|
2180
|
+
var assignSocket = res.assignSocket;
|
|
2181
|
+
|
|
2182
|
+
if (typeof assignSocket !== 'function') return
|
|
2183
|
+
|
|
2184
|
+
// res.on('socket', callback) is broken in 0.8
|
|
2185
|
+
res.assignSocket = function _assignSocket(socket) {
|
|
2186
|
+
assignSocket.call(this, socket);
|
|
2187
|
+
callback(socket);
|
|
2188
|
+
};
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
var parseurl$1 = {exports: {}};
|
|
2192
|
+
|
|
2193
|
+
/*!
|
|
2194
|
+
* parseurl
|
|
2195
|
+
* Copyright(c) 2014 Jonathan Ong
|
|
2196
|
+
* Copyright(c) 2014-2017 Douglas Christopher Wilson
|
|
2197
|
+
* MIT Licensed
|
|
2198
|
+
*/
|
|
2199
|
+
|
|
2200
|
+
/**
|
|
2201
|
+
* Module dependencies.
|
|
2202
|
+
* @private
|
|
2203
|
+
*/
|
|
2204
|
+
|
|
2205
|
+
var url = require$$7;
|
|
2206
|
+
var parse = url.parse;
|
|
2207
|
+
var Url = url.Url;
|
|
2208
|
+
|
|
2209
|
+
/**
|
|
2210
|
+
* Module exports.
|
|
2211
|
+
* @public
|
|
2212
|
+
*/
|
|
2213
|
+
|
|
2214
|
+
parseurl$1.exports = parseurl;
|
|
2215
|
+
parseurl$1.exports.original = originalurl;
|
|
2216
|
+
|
|
2217
|
+
/**
|
|
2218
|
+
* Parse the `req` url with memoization.
|
|
2219
|
+
*
|
|
2220
|
+
* @param {ServerRequest} req
|
|
2221
|
+
* @return {Object}
|
|
2222
|
+
* @public
|
|
2223
|
+
*/
|
|
2224
|
+
|
|
2225
|
+
function parseurl (req) {
|
|
2226
|
+
var url = req.url;
|
|
2227
|
+
|
|
2228
|
+
if (url === undefined) {
|
|
2229
|
+
// URL is undefined
|
|
2230
|
+
return undefined
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
var parsed = req._parsedUrl;
|
|
2234
|
+
|
|
2235
|
+
if (fresh(url, parsed)) {
|
|
2236
|
+
// Return cached URL parse
|
|
2237
|
+
return parsed
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
// Parse the URL
|
|
2241
|
+
parsed = fastparse(url);
|
|
2242
|
+
parsed._raw = url;
|
|
2243
|
+
|
|
2244
|
+
return (req._parsedUrl = parsed)
|
|
2245
|
+
}
|
|
2246
|
+
/**
|
|
2247
|
+
* Parse the `req` original url with fallback and memoization.
|
|
2248
|
+
*
|
|
2249
|
+
* @param {ServerRequest} req
|
|
2250
|
+
* @return {Object}
|
|
2251
|
+
* @public
|
|
2252
|
+
*/
|
|
2253
|
+
|
|
2254
|
+
function originalurl (req) {
|
|
2255
|
+
var url = req.originalUrl;
|
|
2256
|
+
|
|
2257
|
+
if (typeof url !== 'string') {
|
|
2258
|
+
// Fallback
|
|
2259
|
+
return parseurl(req)
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
var parsed = req._parsedOriginalUrl;
|
|
2263
|
+
|
|
2264
|
+
if (fresh(url, parsed)) {
|
|
2265
|
+
// Return cached URL parse
|
|
2266
|
+
return parsed
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
// Parse the URL
|
|
2270
|
+
parsed = fastparse(url);
|
|
2271
|
+
parsed._raw = url;
|
|
2272
|
+
|
|
2273
|
+
return (req._parsedOriginalUrl = parsed)
|
|
2274
|
+
}
|
|
2275
|
+
/**
|
|
2276
|
+
* Parse the `str` url with fast-path short-cut.
|
|
2277
|
+
*
|
|
2278
|
+
* @param {string} str
|
|
2279
|
+
* @return {Object}
|
|
2280
|
+
* @private
|
|
2281
|
+
*/
|
|
2282
|
+
|
|
2283
|
+
function fastparse (str) {
|
|
2284
|
+
if (typeof str !== 'string' || str.charCodeAt(0) !== 0x2f /* / */) {
|
|
2285
|
+
return parse(str)
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
var pathname = str;
|
|
2289
|
+
var query = null;
|
|
2290
|
+
var search = null;
|
|
2291
|
+
|
|
2292
|
+
// This takes the regexp from https://github.com/joyent/node/pull/7878
|
|
2293
|
+
// Which is /^(\/[^?#\s]*)(\?[^#\s]*)?$/
|
|
2294
|
+
// And unrolls it into a for loop
|
|
2295
|
+
for (var i = 1; i < str.length; i++) {
|
|
2296
|
+
switch (str.charCodeAt(i)) {
|
|
2297
|
+
case 0x3f: /* ? */
|
|
2298
|
+
if (search === null) {
|
|
2299
|
+
pathname = str.substring(0, i);
|
|
2300
|
+
query = str.substring(i + 1);
|
|
2301
|
+
search = str.substring(i);
|
|
2302
|
+
}
|
|
2303
|
+
break
|
|
2304
|
+
case 0x09: /* \t */
|
|
2305
|
+
case 0x0a: /* \n */
|
|
2306
|
+
case 0x0c: /* \f */
|
|
2307
|
+
case 0x0d: /* \r */
|
|
2308
|
+
case 0x20: /* */
|
|
2309
|
+
case 0x23: /* # */
|
|
2310
|
+
case 0xa0:
|
|
2311
|
+
case 0xfeff:
|
|
2312
|
+
return parse(str)
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2316
|
+
var url = Url !== undefined
|
|
2317
|
+
? new Url()
|
|
2318
|
+
: {};
|
|
2319
|
+
|
|
2320
|
+
url.path = str;
|
|
2321
|
+
url.href = str;
|
|
2322
|
+
url.pathname = pathname;
|
|
2323
|
+
|
|
2324
|
+
if (search !== null) {
|
|
2325
|
+
url.query = query;
|
|
2326
|
+
url.search = search;
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
return url
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
/**
|
|
2333
|
+
* Determine if parsed is still fresh for url.
|
|
2334
|
+
*
|
|
2335
|
+
* @param {string} url
|
|
2336
|
+
* @param {object} parsedUrl
|
|
2337
|
+
* @return {boolean}
|
|
2338
|
+
* @private
|
|
2339
|
+
*/
|
|
2340
|
+
|
|
2341
|
+
function fresh (url, parsedUrl) {
|
|
2342
|
+
return typeof parsedUrl === 'object' &&
|
|
2343
|
+
parsedUrl !== null &&
|
|
2344
|
+
(Url === undefined || parsedUrl instanceof Url) &&
|
|
2345
|
+
parsedUrl._raw === url
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
var require$$0 = {
|
|
2349
|
+
"100": "Continue",
|
|
2350
|
+
"101": "Switching Protocols",
|
|
2351
|
+
"102": "Processing",
|
|
2352
|
+
"103": "Early Hints",
|
|
2353
|
+
"200": "OK",
|
|
2354
|
+
"201": "Created",
|
|
2355
|
+
"202": "Accepted",
|
|
2356
|
+
"203": "Non-Authoritative Information",
|
|
2357
|
+
"204": "No Content",
|
|
2358
|
+
"205": "Reset Content",
|
|
2359
|
+
"206": "Partial Content",
|
|
2360
|
+
"207": "Multi-Status",
|
|
2361
|
+
"208": "Already Reported",
|
|
2362
|
+
"226": "IM Used",
|
|
2363
|
+
"300": "Multiple Choices",
|
|
2364
|
+
"301": "Moved Permanently",
|
|
2365
|
+
"302": "Found",
|
|
2366
|
+
"303": "See Other",
|
|
2367
|
+
"304": "Not Modified",
|
|
2368
|
+
"305": "Use Proxy",
|
|
2369
|
+
"306": "(Unused)",
|
|
2370
|
+
"307": "Temporary Redirect",
|
|
2371
|
+
"308": "Permanent Redirect",
|
|
2372
|
+
"400": "Bad Request",
|
|
2373
|
+
"401": "Unauthorized",
|
|
2374
|
+
"402": "Payment Required",
|
|
2375
|
+
"403": "Forbidden",
|
|
2376
|
+
"404": "Not Found",
|
|
2377
|
+
"405": "Method Not Allowed",
|
|
2378
|
+
"406": "Not Acceptable",
|
|
2379
|
+
"407": "Proxy Authentication Required",
|
|
2380
|
+
"408": "Request Timeout",
|
|
2381
|
+
"409": "Conflict",
|
|
2382
|
+
"410": "Gone",
|
|
2383
|
+
"411": "Length Required",
|
|
2384
|
+
"412": "Precondition Failed",
|
|
2385
|
+
"413": "Payload Too Large",
|
|
2386
|
+
"414": "URI Too Long",
|
|
2387
|
+
"415": "Unsupported Media Type",
|
|
2388
|
+
"416": "Range Not Satisfiable",
|
|
2389
|
+
"417": "Expectation Failed",
|
|
2390
|
+
"418": "I'm a teapot",
|
|
2391
|
+
"421": "Misdirected Request",
|
|
2392
|
+
"422": "Unprocessable Entity",
|
|
2393
|
+
"423": "Locked",
|
|
2394
|
+
"424": "Failed Dependency",
|
|
2395
|
+
"425": "Unordered Collection",
|
|
2396
|
+
"426": "Upgrade Required",
|
|
2397
|
+
"428": "Precondition Required",
|
|
2398
|
+
"429": "Too Many Requests",
|
|
2399
|
+
"431": "Request Header Fields Too Large",
|
|
2400
|
+
"451": "Unavailable For Legal Reasons",
|
|
2401
|
+
"500": "Internal Server Error",
|
|
2402
|
+
"501": "Not Implemented",
|
|
2403
|
+
"502": "Bad Gateway",
|
|
2404
|
+
"503": "Service Unavailable",
|
|
2405
|
+
"504": "Gateway Timeout",
|
|
2406
|
+
"505": "HTTP Version Not Supported",
|
|
2407
|
+
"506": "Variant Also Negotiates",
|
|
2408
|
+
"507": "Insufficient Storage",
|
|
2409
|
+
"508": "Loop Detected",
|
|
2410
|
+
"509": "Bandwidth Limit Exceeded",
|
|
2411
|
+
"510": "Not Extended",
|
|
2412
|
+
"511": "Network Authentication Required"
|
|
2413
|
+
};
|
|
2414
|
+
|
|
2415
|
+
/*!
|
|
2416
|
+
* statuses
|
|
2417
|
+
* Copyright(c) 2014 Jonathan Ong
|
|
2418
|
+
* Copyright(c) 2016 Douglas Christopher Wilson
|
|
2419
|
+
* MIT Licensed
|
|
2420
|
+
*/
|
|
2421
|
+
|
|
2422
|
+
/**
|
|
2423
|
+
* Module dependencies.
|
|
2424
|
+
* @private
|
|
2425
|
+
*/
|
|
2426
|
+
|
|
2427
|
+
var codes = require$$0;
|
|
2428
|
+
|
|
2429
|
+
/**
|
|
2430
|
+
* Module exports.
|
|
2431
|
+
* @public
|
|
2432
|
+
*/
|
|
2433
|
+
|
|
2434
|
+
var statuses$1 = status;
|
|
2435
|
+
|
|
2436
|
+
// status code to message map
|
|
2437
|
+
status.STATUS_CODES = codes;
|
|
2438
|
+
|
|
2439
|
+
// array of status codes
|
|
2440
|
+
status.codes = populateStatusesMap(status, codes);
|
|
2441
|
+
|
|
2442
|
+
// status codes for redirects
|
|
2443
|
+
status.redirect = {
|
|
2444
|
+
300: true,
|
|
2445
|
+
301: true,
|
|
2446
|
+
302: true,
|
|
2447
|
+
303: true,
|
|
2448
|
+
305: true,
|
|
2449
|
+
307: true,
|
|
2450
|
+
308: true
|
|
2451
|
+
};
|
|
2452
|
+
|
|
2453
|
+
// status codes for empty bodies
|
|
2454
|
+
status.empty = {
|
|
2455
|
+
204: true,
|
|
2456
|
+
205: true,
|
|
2457
|
+
304: true
|
|
2458
|
+
};
|
|
2459
|
+
|
|
2460
|
+
// status codes for when you should retry the request
|
|
2461
|
+
status.retry = {
|
|
2462
|
+
502: true,
|
|
2463
|
+
503: true,
|
|
2464
|
+
504: true
|
|
2465
|
+
};
|
|
2466
|
+
|
|
2467
|
+
/**
|
|
2468
|
+
* Populate the statuses map for given codes.
|
|
2469
|
+
* @private
|
|
2470
|
+
*/
|
|
2471
|
+
|
|
2472
|
+
function populateStatusesMap (statuses, codes) {
|
|
2473
|
+
var arr = [];
|
|
2474
|
+
|
|
2475
|
+
Object.keys(codes).forEach(function forEachCode (code) {
|
|
2476
|
+
var message = codes[code];
|
|
2477
|
+
var status = Number(code);
|
|
2478
|
+
|
|
2479
|
+
// Populate properties
|
|
2480
|
+
statuses[status] = message;
|
|
2481
|
+
statuses[message] = status;
|
|
2482
|
+
statuses[message.toLowerCase()] = status;
|
|
2483
|
+
|
|
2484
|
+
// Add to array
|
|
2485
|
+
arr.push(status);
|
|
2486
|
+
});
|
|
2487
|
+
|
|
2488
|
+
return arr
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
/**
|
|
2492
|
+
* Get the status code.
|
|
2493
|
+
*
|
|
2494
|
+
* Given a number, this will throw if it is not a known status
|
|
2495
|
+
* code, otherwise the code will be returned. Given a string,
|
|
2496
|
+
* the string will be parsed for a number and return the code
|
|
2497
|
+
* if valid, otherwise will lookup the code assuming this is
|
|
2498
|
+
* the status message.
|
|
2499
|
+
*
|
|
2500
|
+
* @param {string|number} code
|
|
2501
|
+
* @returns {number}
|
|
2502
|
+
* @public
|
|
2503
|
+
*/
|
|
2504
|
+
|
|
2505
|
+
function status (code) {
|
|
2506
|
+
if (typeof code === 'number') {
|
|
2507
|
+
if (!status[code]) throw new Error('invalid status code: ' + code)
|
|
2508
|
+
return code
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
if (typeof code !== 'string') {
|
|
2512
|
+
throw new TypeError('code must be a number or string')
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
// '403'
|
|
2516
|
+
var n = parseInt(code, 10);
|
|
2517
|
+
if (!isNaN(n)) {
|
|
2518
|
+
if (!status[n]) throw new Error('invalid status code: ' + n)
|
|
2519
|
+
return n
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
n = status[code.toLowerCase()];
|
|
2523
|
+
if (!n) throw new Error('invalid status message: "' + code + '"')
|
|
2524
|
+
return n
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
/*!
|
|
2528
|
+
* unpipe
|
|
2529
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
2530
|
+
* MIT Licensed
|
|
2531
|
+
*/
|
|
2532
|
+
|
|
2533
|
+
/**
|
|
2534
|
+
* Module exports.
|
|
2535
|
+
* @public
|
|
2536
|
+
*/
|
|
2537
|
+
|
|
2538
|
+
var unpipe_1 = unpipe$1;
|
|
2539
|
+
|
|
2540
|
+
/**
|
|
2541
|
+
* Determine if there are Node.js pipe-like data listeners.
|
|
2542
|
+
* @private
|
|
2543
|
+
*/
|
|
2544
|
+
|
|
2545
|
+
function hasPipeDataListeners(stream) {
|
|
2546
|
+
var listeners = stream.listeners('data');
|
|
2547
|
+
|
|
2548
|
+
for (var i = 0; i < listeners.length; i++) {
|
|
2549
|
+
if (listeners[i].name === 'ondata') {
|
|
2550
|
+
return true
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
return false
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
/**
|
|
2558
|
+
* Unpipe a stream from all destinations.
|
|
2559
|
+
*
|
|
2560
|
+
* @param {object} stream
|
|
2561
|
+
* @public
|
|
2562
|
+
*/
|
|
2563
|
+
|
|
2564
|
+
function unpipe$1(stream) {
|
|
2565
|
+
if (!stream) {
|
|
2566
|
+
throw new TypeError('argument stream is required')
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
if (typeof stream.unpipe === 'function') {
|
|
2570
|
+
// new-style
|
|
2571
|
+
stream.unpipe();
|
|
2572
|
+
return
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
// Node.js 0.8 hack
|
|
2576
|
+
if (!hasPipeDataListeners(stream)) {
|
|
2577
|
+
return
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
var listener;
|
|
2581
|
+
var listeners = stream.listeners('close');
|
|
2582
|
+
|
|
2583
|
+
for (var i = 0; i < listeners.length; i++) {
|
|
2584
|
+
listener = listeners[i];
|
|
2585
|
+
|
|
2586
|
+
if (listener.name !== 'cleanup' && listener.name !== 'onclose') {
|
|
2587
|
+
continue
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
// invoke the listener
|
|
2591
|
+
listener.call(stream);
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
/*!
|
|
2596
|
+
* finalhandler
|
|
2597
|
+
* Copyright(c) 2014-2017 Douglas Christopher Wilson
|
|
2598
|
+
* MIT Licensed
|
|
2599
|
+
*/
|
|
2600
|
+
|
|
2601
|
+
/**
|
|
2602
|
+
* Module dependencies.
|
|
2603
|
+
* @private
|
|
2604
|
+
*/
|
|
2605
|
+
|
|
2606
|
+
var debug$1 = src.exports('finalhandler');
|
|
2607
|
+
var encodeUrl = encodeurl;
|
|
2608
|
+
var escapeHtml = escapeHtml_1;
|
|
2609
|
+
var onFinished = onFinished$2.exports;
|
|
2610
|
+
var parseUrl$1 = parseurl$1.exports;
|
|
2611
|
+
var statuses = statuses$1;
|
|
2612
|
+
var unpipe = unpipe_1;
|
|
2613
|
+
|
|
2614
|
+
/**
|
|
2615
|
+
* Module variables.
|
|
2616
|
+
* @private
|
|
2617
|
+
*/
|
|
2618
|
+
|
|
2619
|
+
var DOUBLE_SPACE_REGEXP = /\x20{2}/g;
|
|
2620
|
+
var NEWLINE_REGEXP = /\n/g;
|
|
2621
|
+
|
|
2622
|
+
/* istanbul ignore next */
|
|
2623
|
+
var defer$1 = typeof setImmediate === 'function'
|
|
2624
|
+
? setImmediate
|
|
2625
|
+
: function (fn) { process.nextTick(fn.bind.apply(fn, arguments)); };
|
|
2626
|
+
var isFinished = onFinished.isFinished;
|
|
2627
|
+
|
|
2628
|
+
/**
|
|
2629
|
+
* Create a minimal HTML document.
|
|
2630
|
+
*
|
|
2631
|
+
* @param {string} message
|
|
2632
|
+
* @private
|
|
2633
|
+
*/
|
|
2634
|
+
|
|
2635
|
+
function createHtmlDocument (message) {
|
|
2636
|
+
var body = escapeHtml(message)
|
|
2637
|
+
.replace(NEWLINE_REGEXP, '<br>')
|
|
2638
|
+
.replace(DOUBLE_SPACE_REGEXP, ' ');
|
|
2639
|
+
|
|
2640
|
+
return '<!DOCTYPE html>\n' +
|
|
2641
|
+
'<html lang="en">\n' +
|
|
2642
|
+
'<head>\n' +
|
|
2643
|
+
'<meta charset="utf-8">\n' +
|
|
2644
|
+
'<title>Error</title>\n' +
|
|
2645
|
+
'</head>\n' +
|
|
2646
|
+
'<body>\n' +
|
|
2647
|
+
'<pre>' + body + '</pre>\n' +
|
|
2648
|
+
'</body>\n' +
|
|
2649
|
+
'</html>\n'
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2652
|
+
/**
|
|
2653
|
+
* Module exports.
|
|
2654
|
+
* @public
|
|
2655
|
+
*/
|
|
2656
|
+
|
|
2657
|
+
var finalhandler_1 = finalhandler$1;
|
|
2658
|
+
|
|
2659
|
+
/**
|
|
2660
|
+
* Create a function to handle the final response.
|
|
2661
|
+
*
|
|
2662
|
+
* @param {Request} req
|
|
2663
|
+
* @param {Response} res
|
|
2664
|
+
* @param {Object} [options]
|
|
2665
|
+
* @return {Function}
|
|
2666
|
+
* @public
|
|
2667
|
+
*/
|
|
2668
|
+
|
|
2669
|
+
function finalhandler$1 (req, res, options) {
|
|
2670
|
+
var opts = options || {};
|
|
2671
|
+
|
|
2672
|
+
// get environment
|
|
2673
|
+
var env = opts.env || process.env.NODE_ENV || 'development';
|
|
2674
|
+
|
|
2675
|
+
// get error callback
|
|
2676
|
+
var onerror = opts.onerror;
|
|
2677
|
+
|
|
2678
|
+
return function (err) {
|
|
2679
|
+
var headers;
|
|
2680
|
+
var msg;
|
|
2681
|
+
var status;
|
|
2682
|
+
|
|
2683
|
+
// ignore 404 on in-flight response
|
|
2684
|
+
if (!err && headersSent(res)) {
|
|
2685
|
+
debug$1('cannot 404 after headers sent');
|
|
2686
|
+
return
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
// unhandled error
|
|
2690
|
+
if (err) {
|
|
2691
|
+
// respect status code from error
|
|
2692
|
+
status = getErrorStatusCode(err);
|
|
2693
|
+
|
|
2694
|
+
if (status === undefined) {
|
|
2695
|
+
// fallback to status code on response
|
|
2696
|
+
status = getResponseStatusCode(res);
|
|
2697
|
+
} else {
|
|
2698
|
+
// respect headers from error
|
|
2699
|
+
headers = getErrorHeaders(err);
|
|
2700
|
+
}
|
|
2701
|
+
|
|
2702
|
+
// get error message
|
|
2703
|
+
msg = getErrorMessage(err, status, env);
|
|
2704
|
+
} else {
|
|
2705
|
+
// not found
|
|
2706
|
+
status = 404;
|
|
2707
|
+
msg = 'Cannot ' + req.method + ' ' + encodeUrl(getResourceName(req));
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
debug$1('default %s', status);
|
|
2711
|
+
|
|
2712
|
+
// schedule onerror callback
|
|
2713
|
+
if (err && onerror) {
|
|
2714
|
+
defer$1(onerror, err, req, res);
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
// cannot actually respond
|
|
2718
|
+
if (headersSent(res)) {
|
|
2719
|
+
debug$1('cannot %d after headers sent', status);
|
|
2720
|
+
req.socket.destroy();
|
|
2721
|
+
return
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
// send response
|
|
2725
|
+
send(req, res, status, headers, msg);
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2729
|
+
/**
|
|
2730
|
+
* Get headers from Error object.
|
|
2731
|
+
*
|
|
2732
|
+
* @param {Error} err
|
|
2733
|
+
* @return {object}
|
|
2734
|
+
* @private
|
|
2735
|
+
*/
|
|
2736
|
+
|
|
2737
|
+
function getErrorHeaders (err) {
|
|
2738
|
+
if (!err.headers || typeof err.headers !== 'object') {
|
|
2739
|
+
return undefined
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2742
|
+
var headers = Object.create(null);
|
|
2743
|
+
var keys = Object.keys(err.headers);
|
|
2744
|
+
|
|
2745
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2746
|
+
var key = keys[i];
|
|
2747
|
+
headers[key] = err.headers[key];
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
return headers
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
/**
|
|
2754
|
+
* Get message from Error object, fallback to status message.
|
|
2755
|
+
*
|
|
2756
|
+
* @param {Error} err
|
|
2757
|
+
* @param {number} status
|
|
2758
|
+
* @param {string} env
|
|
2759
|
+
* @return {string}
|
|
2760
|
+
* @private
|
|
2761
|
+
*/
|
|
2762
|
+
|
|
2763
|
+
function getErrorMessage (err, status, env) {
|
|
2764
|
+
var msg;
|
|
2765
|
+
|
|
2766
|
+
if (env !== 'production') {
|
|
2767
|
+
// use err.stack, which typically includes err.message
|
|
2768
|
+
msg = err.stack;
|
|
2769
|
+
|
|
2770
|
+
// fallback to err.toString() when possible
|
|
2771
|
+
if (!msg && typeof err.toString === 'function') {
|
|
2772
|
+
msg = err.toString();
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
return msg || statuses[status]
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
/**
|
|
2780
|
+
* Get status code from Error object.
|
|
2781
|
+
*
|
|
2782
|
+
* @param {Error} err
|
|
2783
|
+
* @return {number}
|
|
2784
|
+
* @private
|
|
2785
|
+
*/
|
|
2786
|
+
|
|
2787
|
+
function getErrorStatusCode (err) {
|
|
2788
|
+
// check err.status
|
|
2789
|
+
if (typeof err.status === 'number' && err.status >= 400 && err.status < 600) {
|
|
2790
|
+
return err.status
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
// check err.statusCode
|
|
2794
|
+
if (typeof err.statusCode === 'number' && err.statusCode >= 400 && err.statusCode < 600) {
|
|
2795
|
+
return err.statusCode
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2798
|
+
return undefined
|
|
2799
|
+
}
|
|
2800
|
+
|
|
2801
|
+
/**
|
|
2802
|
+
* Get resource name for the request.
|
|
2803
|
+
*
|
|
2804
|
+
* This is typically just the original pathname of the request
|
|
2805
|
+
* but will fallback to "resource" is that cannot be determined.
|
|
2806
|
+
*
|
|
2807
|
+
* @param {IncomingMessage} req
|
|
2808
|
+
* @return {string}
|
|
2809
|
+
* @private
|
|
2810
|
+
*/
|
|
2811
|
+
|
|
2812
|
+
function getResourceName (req) {
|
|
2813
|
+
try {
|
|
2814
|
+
return parseUrl$1.original(req).pathname
|
|
2815
|
+
} catch (e) {
|
|
2816
|
+
return 'resource'
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
|
|
2820
|
+
/**
|
|
2821
|
+
* Get status code from response.
|
|
2822
|
+
*
|
|
2823
|
+
* @param {OutgoingMessage} res
|
|
2824
|
+
* @return {number}
|
|
2825
|
+
* @private
|
|
2826
|
+
*/
|
|
2827
|
+
|
|
2828
|
+
function getResponseStatusCode (res) {
|
|
2829
|
+
var status = res.statusCode;
|
|
2830
|
+
|
|
2831
|
+
// default status code to 500 if outside valid range
|
|
2832
|
+
if (typeof status !== 'number' || status < 400 || status > 599) {
|
|
2833
|
+
status = 500;
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2836
|
+
return status
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
/**
|
|
2840
|
+
* Determine if the response headers have been sent.
|
|
2841
|
+
*
|
|
2842
|
+
* @param {object} res
|
|
2843
|
+
* @returns {boolean}
|
|
2844
|
+
* @private
|
|
2845
|
+
*/
|
|
2846
|
+
|
|
2847
|
+
function headersSent (res) {
|
|
2848
|
+
return typeof res.headersSent !== 'boolean'
|
|
2849
|
+
? Boolean(res._header)
|
|
2850
|
+
: res.headersSent
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
/**
|
|
2854
|
+
* Send response.
|
|
2855
|
+
*
|
|
2856
|
+
* @param {IncomingMessage} req
|
|
2857
|
+
* @param {OutgoingMessage} res
|
|
2858
|
+
* @param {number} status
|
|
2859
|
+
* @param {object} headers
|
|
2860
|
+
* @param {string} message
|
|
2861
|
+
* @private
|
|
2862
|
+
*/
|
|
2863
|
+
|
|
2864
|
+
function send (req, res, status, headers, message) {
|
|
2865
|
+
function write () {
|
|
2866
|
+
// response body
|
|
2867
|
+
var body = createHtmlDocument(message);
|
|
2868
|
+
|
|
2869
|
+
// response status
|
|
2870
|
+
res.statusCode = status;
|
|
2871
|
+
res.statusMessage = statuses[status];
|
|
2872
|
+
|
|
2873
|
+
// response headers
|
|
2874
|
+
setHeaders(res, headers);
|
|
2875
|
+
|
|
2876
|
+
// security headers
|
|
2877
|
+
res.setHeader('Content-Security-Policy', "default-src 'none'");
|
|
2878
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
2879
|
+
|
|
2880
|
+
// standard headers
|
|
2881
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
2882
|
+
res.setHeader('Content-Length', Buffer.byteLength(body, 'utf8'));
|
|
2883
|
+
|
|
2884
|
+
if (req.method === 'HEAD') {
|
|
2885
|
+
res.end();
|
|
2886
|
+
return
|
|
2887
|
+
}
|
|
2888
|
+
|
|
2889
|
+
res.end(body, 'utf8');
|
|
2890
|
+
}
|
|
2891
|
+
|
|
2892
|
+
if (isFinished(req)) {
|
|
2893
|
+
write();
|
|
2894
|
+
return
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2897
|
+
// unpipe everything from the request
|
|
2898
|
+
unpipe(req);
|
|
2899
|
+
|
|
2900
|
+
// flush the request
|
|
2901
|
+
onFinished(req, write);
|
|
2902
|
+
req.resume();
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2905
|
+
/**
|
|
2906
|
+
* Set response headers from an object.
|
|
2907
|
+
*
|
|
2908
|
+
* @param {OutgoingMessage} res
|
|
2909
|
+
* @param {object} headers
|
|
2910
|
+
* @private
|
|
2911
|
+
*/
|
|
2912
|
+
|
|
2913
|
+
function setHeaders (res, headers) {
|
|
2914
|
+
if (!headers) {
|
|
2915
|
+
return
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
var keys = Object.keys(headers);
|
|
2919
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2920
|
+
var key = keys[i];
|
|
2921
|
+
res.setHeader(key, headers[key]);
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
|
|
2925
|
+
var utilsMerge = {exports: {}};
|
|
2926
|
+
|
|
2927
|
+
/**
|
|
2928
|
+
* Merge object b with object a.
|
|
2929
|
+
*
|
|
2930
|
+
* var a = { foo: 'bar' }
|
|
2931
|
+
* , b = { bar: 'baz' };
|
|
2932
|
+
*
|
|
2933
|
+
* merge(a, b);
|
|
2934
|
+
* // => { foo: 'bar', bar: 'baz' }
|
|
2935
|
+
*
|
|
2936
|
+
* @param {Object} a
|
|
2937
|
+
* @param {Object} b
|
|
2938
|
+
* @return {Object}
|
|
2939
|
+
* @api public
|
|
2940
|
+
*/
|
|
2941
|
+
|
|
2942
|
+
(function (module, exports) {
|
|
2943
|
+
module.exports = function(a, b){
|
|
2944
|
+
if (a && b) {
|
|
2945
|
+
for (var key in b) {
|
|
2946
|
+
a[key] = b[key];
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
return a;
|
|
2950
|
+
};
|
|
2951
|
+
}(utilsMerge));
|
|
2952
|
+
|
|
2953
|
+
/*!
|
|
2954
|
+
* connect
|
|
2955
|
+
* Copyright(c) 2010 Sencha Inc.
|
|
2956
|
+
* Copyright(c) 2011 TJ Holowaychuk
|
|
2957
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
2958
|
+
* MIT Licensed
|
|
2959
|
+
*/
|
|
2960
|
+
|
|
2961
|
+
/**
|
|
2962
|
+
* Module dependencies.
|
|
2963
|
+
* @private
|
|
2964
|
+
*/
|
|
2965
|
+
|
|
2966
|
+
var debug = src$1.exports('connect:dispatcher');
|
|
2967
|
+
var EventEmitter = require$$0$4.EventEmitter;
|
|
2968
|
+
var finalhandler = finalhandler_1;
|
|
2969
|
+
var http = require$$3;
|
|
2970
|
+
var merge = utilsMerge.exports;
|
|
2971
|
+
var parseUrl = parseurl$1.exports;
|
|
2972
|
+
|
|
2973
|
+
/**
|
|
2974
|
+
* Module exports.
|
|
2975
|
+
* @public
|
|
2976
|
+
*/
|
|
2977
|
+
|
|
2978
|
+
var connect = createServer$1;
|
|
2979
|
+
|
|
2980
|
+
/**
|
|
2981
|
+
* Module variables.
|
|
2982
|
+
* @private
|
|
2983
|
+
*/
|
|
2984
|
+
|
|
2985
|
+
var env = process.env.NODE_ENV || 'development';
|
|
2986
|
+
var proto = {};
|
|
2987
|
+
|
|
2988
|
+
/* istanbul ignore next */
|
|
2989
|
+
var defer = typeof setImmediate === 'function'
|
|
2990
|
+
? setImmediate
|
|
2991
|
+
: function(fn){ process.nextTick(fn.bind.apply(fn, arguments)); };
|
|
2992
|
+
|
|
2993
|
+
/**
|
|
2994
|
+
* Create a new connect server.
|
|
2995
|
+
*
|
|
2996
|
+
* @return {function}
|
|
2997
|
+
* @public
|
|
2998
|
+
*/
|
|
2999
|
+
|
|
3000
|
+
function createServer$1() {
|
|
3001
|
+
function app(req, res, next){ app.handle(req, res, next); }
|
|
3002
|
+
merge(app, proto);
|
|
3003
|
+
merge(app, EventEmitter.prototype);
|
|
3004
|
+
app.route = '/';
|
|
3005
|
+
app.stack = [];
|
|
3006
|
+
return app;
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3009
|
+
/**
|
|
3010
|
+
* Utilize the given middleware `handle` to the given `route`,
|
|
3011
|
+
* defaulting to _/_. This "route" is the mount-point for the
|
|
3012
|
+
* middleware, when given a value other than _/_ the middleware
|
|
3013
|
+
* is only effective when that segment is present in the request's
|
|
3014
|
+
* pathname.
|
|
3015
|
+
*
|
|
3016
|
+
* For example if we were to mount a function at _/admin_, it would
|
|
3017
|
+
* be invoked on _/admin_, and _/admin/settings_, however it would
|
|
3018
|
+
* not be invoked for _/_, or _/posts_.
|
|
3019
|
+
*
|
|
3020
|
+
* @param {String|Function|Server} route, callback or server
|
|
3021
|
+
* @param {Function|Server} callback or server
|
|
3022
|
+
* @return {Server} for chaining
|
|
3023
|
+
* @public
|
|
3024
|
+
*/
|
|
3025
|
+
|
|
3026
|
+
proto.use = function use(route, fn) {
|
|
3027
|
+
var handle = fn;
|
|
3028
|
+
var path = route;
|
|
3029
|
+
|
|
3030
|
+
// default route to '/'
|
|
3031
|
+
if (typeof route !== 'string') {
|
|
3032
|
+
handle = route;
|
|
3033
|
+
path = '/';
|
|
3034
|
+
}
|
|
3035
|
+
|
|
3036
|
+
// wrap sub-apps
|
|
3037
|
+
if (typeof handle.handle === 'function') {
|
|
3038
|
+
var server = handle;
|
|
3039
|
+
server.route = path;
|
|
3040
|
+
handle = function (req, res, next) {
|
|
3041
|
+
server.handle(req, res, next);
|
|
3042
|
+
};
|
|
3043
|
+
}
|
|
3044
|
+
|
|
3045
|
+
// wrap vanilla http.Servers
|
|
3046
|
+
if (handle instanceof http.Server) {
|
|
3047
|
+
handle = handle.listeners('request')[0];
|
|
3048
|
+
}
|
|
3049
|
+
|
|
3050
|
+
// strip trailing slash
|
|
3051
|
+
if (path[path.length - 1] === '/') {
|
|
3052
|
+
path = path.slice(0, -1);
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
// add the middleware
|
|
3056
|
+
debug('use %s %s', path || '/', handle.name || 'anonymous');
|
|
3057
|
+
this.stack.push({ route: path, handle: handle });
|
|
3058
|
+
|
|
3059
|
+
return this;
|
|
3060
|
+
};
|
|
3061
|
+
|
|
3062
|
+
/**
|
|
3063
|
+
* Handle server requests, punting them down
|
|
3064
|
+
* the middleware stack.
|
|
3065
|
+
*
|
|
3066
|
+
* @private
|
|
3067
|
+
*/
|
|
3068
|
+
|
|
3069
|
+
proto.handle = function handle(req, res, out) {
|
|
3070
|
+
var index = 0;
|
|
3071
|
+
var protohost = getProtohost(req.url) || '';
|
|
3072
|
+
var removed = '';
|
|
3073
|
+
var slashAdded = false;
|
|
3074
|
+
var stack = this.stack;
|
|
3075
|
+
|
|
3076
|
+
// final function handler
|
|
3077
|
+
var done = out || finalhandler(req, res, {
|
|
3078
|
+
env: env,
|
|
3079
|
+
onerror: logerror
|
|
3080
|
+
});
|
|
3081
|
+
|
|
3082
|
+
// store the original URL
|
|
3083
|
+
req.originalUrl = req.originalUrl || req.url;
|
|
3084
|
+
|
|
3085
|
+
function next(err) {
|
|
3086
|
+
if (slashAdded) {
|
|
3087
|
+
req.url = req.url.substr(1);
|
|
3088
|
+
slashAdded = false;
|
|
3089
|
+
}
|
|
3090
|
+
|
|
3091
|
+
if (removed.length !== 0) {
|
|
3092
|
+
req.url = protohost + removed + req.url.substr(protohost.length);
|
|
3093
|
+
removed = '';
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
// next callback
|
|
3097
|
+
var layer = stack[index++];
|
|
3098
|
+
|
|
3099
|
+
// all done
|
|
3100
|
+
if (!layer) {
|
|
3101
|
+
defer(done, err);
|
|
3102
|
+
return;
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3105
|
+
// route data
|
|
3106
|
+
var path = parseUrl(req).pathname || '/';
|
|
3107
|
+
var route = layer.route;
|
|
3108
|
+
|
|
3109
|
+
// skip this layer if the route doesn't match
|
|
3110
|
+
if (path.toLowerCase().substr(0, route.length) !== route.toLowerCase()) {
|
|
3111
|
+
return next(err);
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
// skip if route match does not border "/", ".", or end
|
|
3115
|
+
var c = path.length > route.length && path[route.length];
|
|
3116
|
+
if (c && c !== '/' && c !== '.') {
|
|
3117
|
+
return next(err);
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
// trim off the part of the url that matches the route
|
|
3121
|
+
if (route.length !== 0 && route !== '/') {
|
|
3122
|
+
removed = route;
|
|
3123
|
+
req.url = protohost + req.url.substr(protohost.length + removed.length);
|
|
3124
|
+
|
|
3125
|
+
// ensure leading slash
|
|
3126
|
+
if (!protohost && req.url[0] !== '/') {
|
|
3127
|
+
req.url = '/' + req.url;
|
|
3128
|
+
slashAdded = true;
|
|
3129
|
+
}
|
|
3130
|
+
}
|
|
3131
|
+
|
|
3132
|
+
// call the layer handle
|
|
3133
|
+
call(layer.handle, route, err, req, res, next);
|
|
3134
|
+
}
|
|
3135
|
+
|
|
3136
|
+
next();
|
|
3137
|
+
};
|
|
3138
|
+
|
|
3139
|
+
/**
|
|
3140
|
+
* Listen for connections.
|
|
3141
|
+
*
|
|
3142
|
+
* This method takes the same arguments
|
|
3143
|
+
* as node's `http.Server#listen()`.
|
|
3144
|
+
*
|
|
3145
|
+
* HTTP and HTTPS:
|
|
3146
|
+
*
|
|
3147
|
+
* If you run your application both as HTTP
|
|
3148
|
+
* and HTTPS you may wrap them individually,
|
|
3149
|
+
* since your Connect "server" is really just
|
|
3150
|
+
* a JavaScript `Function`.
|
|
3151
|
+
*
|
|
3152
|
+
* var connect = require('connect')
|
|
3153
|
+
* , http = require('http')
|
|
3154
|
+
* , https = require('https');
|
|
3155
|
+
*
|
|
3156
|
+
* var app = connect();
|
|
3157
|
+
*
|
|
3158
|
+
* http.createServer(app).listen(80);
|
|
3159
|
+
* https.createServer(options, app).listen(443);
|
|
3160
|
+
*
|
|
3161
|
+
* @return {http.Server}
|
|
3162
|
+
* @api public
|
|
3163
|
+
*/
|
|
3164
|
+
|
|
3165
|
+
proto.listen = function listen() {
|
|
3166
|
+
var server = http.createServer(this);
|
|
3167
|
+
return server.listen.apply(server, arguments);
|
|
3168
|
+
};
|
|
3169
|
+
|
|
3170
|
+
/**
|
|
3171
|
+
* Invoke a route handle.
|
|
3172
|
+
* @private
|
|
3173
|
+
*/
|
|
3174
|
+
|
|
3175
|
+
function call(handle, route, err, req, res, next) {
|
|
3176
|
+
var arity = handle.length;
|
|
3177
|
+
var error = err;
|
|
3178
|
+
var hasError = Boolean(err);
|
|
3179
|
+
|
|
3180
|
+
debug('%s %s : %s', handle.name || '<anonymous>', route, req.originalUrl);
|
|
3181
|
+
|
|
3182
|
+
try {
|
|
3183
|
+
if (hasError && arity === 4) {
|
|
3184
|
+
// error-handling middleware
|
|
3185
|
+
handle(err, req, res, next);
|
|
3186
|
+
return;
|
|
3187
|
+
} else if (!hasError && arity < 4) {
|
|
3188
|
+
// request-handling middleware
|
|
3189
|
+
handle(req, res, next);
|
|
3190
|
+
return;
|
|
3191
|
+
}
|
|
3192
|
+
} catch (e) {
|
|
3193
|
+
// replace the error
|
|
3194
|
+
error = e;
|
|
3195
|
+
}
|
|
3196
|
+
|
|
3197
|
+
// continue
|
|
3198
|
+
next(error);
|
|
3199
|
+
}
|
|
3200
|
+
|
|
3201
|
+
/**
|
|
3202
|
+
* Log error using console.error.
|
|
3203
|
+
*
|
|
3204
|
+
* @param {Error} err
|
|
3205
|
+
* @private
|
|
3206
|
+
*/
|
|
3207
|
+
|
|
3208
|
+
function logerror(err) {
|
|
3209
|
+
if (env !== 'test') console.error(err.stack || err.toString());
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
/**
|
|
3213
|
+
* Get get protocol + host for a URL.
|
|
3214
|
+
*
|
|
3215
|
+
* @param {string} url
|
|
3216
|
+
* @private
|
|
3217
|
+
*/
|
|
3218
|
+
|
|
3219
|
+
function getProtohost(url) {
|
|
3220
|
+
if (url.length === 0 || url[0] === '/') {
|
|
3221
|
+
return undefined;
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
var fqdnIndex = url.indexOf('://');
|
|
3225
|
+
|
|
3226
|
+
return fqdnIndex !== -1 && url.lastIndexOf('?', fqdnIndex) === -1
|
|
3227
|
+
? url.substr(0, url.indexOf('/', 3 + fqdnIndex))
|
|
3228
|
+
: undefined;
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3231
|
+
function createAssetMiddleware(assets) {
|
|
3232
|
+
return (req, res, next) => {
|
|
3233
|
+
const filePath = require$$0$5.join(process.cwd(), "./dist/client", req.url);
|
|
3234
|
+
if (assets.includes(filePath)) {
|
|
3235
|
+
const rs = require$$0$3.createReadStream(filePath);
|
|
3236
|
+
const { size } = require$$0$3.statSync(filePath);
|
|
3237
|
+
res.setHeader("Content-Type", mime.getType(filePath));
|
|
3238
|
+
res.setHeader("Content-Length", size);
|
|
3239
|
+
return rs.pipe(res);
|
|
3240
|
+
}
|
|
3241
|
+
next();
|
|
3242
|
+
};
|
|
3243
|
+
}
|
|
3244
|
+
function createRequestMiddleware(mf) {
|
|
3245
|
+
return async (req, res) => {
|
|
3246
|
+
let response;
|
|
3247
|
+
let status = 500;
|
|
3248
|
+
let headers = {};
|
|
3249
|
+
const request = new Request(urlFromRequest(req), {
|
|
3250
|
+
...req
|
|
3251
|
+
});
|
|
3252
|
+
try {
|
|
3253
|
+
response = await mf.dispatchFetch(request);
|
|
3254
|
+
status = response.status;
|
|
3255
|
+
headers = response.headers;
|
|
3256
|
+
res.writeHead(status, headers);
|
|
3257
|
+
if (response.body) {
|
|
3258
|
+
for await (const chunk of response.body) {
|
|
3259
|
+
if (chunk)
|
|
3260
|
+
res.write(chunk);
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
res.end();
|
|
3264
|
+
} catch (e) {
|
|
3265
|
+
res.writeHead(500, { "Content-Type": "text/plain; charset=UTF-8" });
|
|
3266
|
+
res.end(e.stack, "utf8");
|
|
3267
|
+
}
|
|
3268
|
+
return response;
|
|
3269
|
+
};
|
|
3270
|
+
}
|
|
3271
|
+
async function createServer(mf, options = { assets: [] }) {
|
|
3272
|
+
const app = connect();
|
|
3273
|
+
app.use(createAssetMiddleware(options.assets));
|
|
3274
|
+
app.use(createRequestMiddleware(mf));
|
|
3275
|
+
const server = require$$3.createServer(app);
|
|
3276
|
+
return server;
|
|
3277
|
+
}
|
|
3278
|
+
function urlFromRequest(req) {
|
|
3279
|
+
const protocol = req.socket.encrypted ? "https" : "http";
|
|
3280
|
+
const origin = `${protocol}://${req.headers.host ?? "localhost"}`;
|
|
3281
|
+
const url = new URL(req.url ?? "", origin);
|
|
3282
|
+
return url;
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3285
|
+
class StorageFactory {
|
|
3286
|
+
constructor() {
|
|
3287
|
+
this.storages = /* @__PURE__ */ new Map();
|
|
3288
|
+
}
|
|
3289
|
+
storage(namespace) {
|
|
3290
|
+
let storage = this.storages.get(namespace);
|
|
3291
|
+
if (storage)
|
|
3292
|
+
return storage;
|
|
3293
|
+
this.storages.set(namespace, storage = new MemoryStorage());
|
|
3294
|
+
return storage;
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3298
|
+
class MiniOxygen extends MiniflareCore {
|
|
3299
|
+
constructor(options) {
|
|
3300
|
+
const storageFactory = new StorageFactory();
|
|
3301
|
+
super(PLUGINS, {
|
|
3302
|
+
log: new Log(LogLevel.VERBOSE),
|
|
3303
|
+
storageFactory,
|
|
3304
|
+
scriptRunner: new VMScriptRunner()
|
|
3305
|
+
}, {
|
|
3306
|
+
...options
|
|
3307
|
+
});
|
|
3308
|
+
}
|
|
3309
|
+
async dispose() {
|
|
3310
|
+
await super.dispose();
|
|
3311
|
+
}
|
|
3312
|
+
createServer({ assets = [] } = {}) {
|
|
3313
|
+
return createServer(this, { assets });
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
const PLUGINS = {
|
|
3317
|
+
CorePlugin,
|
|
3318
|
+
CachePlugin
|
|
3319
|
+
};
|
|
3320
|
+
|
|
3321
|
+
const port = 4e3;
|
|
3322
|
+
class Preview extends Command {
|
|
3323
|
+
async run() {
|
|
3324
|
+
const hasWorkerBuild = await this.fs.hasFile("dist/worker/worker.js");
|
|
3325
|
+
if (!hasWorkerBuild) {
|
|
3326
|
+
throw new HelpfulError({
|
|
3327
|
+
title: "worker.js not found",
|
|
3328
|
+
content: "A worker build is required for this command.",
|
|
3329
|
+
suggestion: () => `Run \`yarn run build\` to generate a worker build and try again.`
|
|
3330
|
+
});
|
|
3331
|
+
}
|
|
3332
|
+
const files = await this.fs.glob("dist/client/**/*");
|
|
3333
|
+
files.forEach((file) => {
|
|
3334
|
+
this.interface.say(file);
|
|
3335
|
+
});
|
|
3336
|
+
const mf = new MiniOxygen({
|
|
3337
|
+
buildCommand: "yarn build",
|
|
3338
|
+
globals: { Oxygen: {} },
|
|
3339
|
+
scriptPath: resolve(this.root, "dist/worker/worker.js"),
|
|
3340
|
+
sitePath: resolve(this.root, "dist/client")
|
|
3341
|
+
});
|
|
3342
|
+
const app = await mf.createServer({ assets: files });
|
|
3343
|
+
app.listen(port, () => {
|
|
3344
|
+
this.interface.say(`
|
|
3345
|
+
Started miniOxygen server. Listening at http://localhost:${port}
|
|
3346
|
+
`);
|
|
3347
|
+
});
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
Preview.description = "Preview a hydrogen worker build in a worker environment.";
|
|
3351
|
+
Preview.examples = [`$ shopify hydrogen preview`];
|
|
3352
|
+
Preview.flags = {
|
|
3353
|
+
...Command.flags
|
|
3354
|
+
};
|
|
3355
|
+
Preview.args = [];
|
|
3356
|
+
|
|
3357
|
+
export { Preview as default };
|
|
3358
|
+
//# sourceMappingURL=preview.js.map
|