@shopify/cli-hydrogen 1.1.0 → 2.0.1

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.
@@ -1,3337 +1,47 @@
1
- import { Request, MiniflareCore, CorePlugin } from '@miniflare/core';
2
- import require$$0$1 from 'tty';
3
- import require$$0$2 from 'util';
4
- import require$$0$3 from 'fs';
5
- import require$$4 from 'net';
6
- import require$$0$4 from 'events';
7
- import require$$7 from 'url';
8
- import require$$3 from 'http';
9
- import { path, output, file, error } from '@shopify/cli-kit';
10
- import { URL } from 'node:url';
11
- import { MemoryStorage } from '@miniflare/storage-memory';
12
- import { CachePlugin } from '@miniflare/cache';
13
- import { VMScriptRunner } from '@miniflare/runner-vm';
14
- import { Log, LogLevel } from '@miniflare/shared';
1
+ import { error, file, path, system } from '@shopify/cli-kit';
2
+ import { fileURLToPath } from 'url';
15
3
  import { Flags, Command } from '@oclif/core';
16
4
 
17
- /**
18
- * @param typeMap [Object] Map of MIME type -> Array[extensions]
19
- * @param ...
20
- */
21
- function Mime$1() {
22
- this._types = Object.create(null);
23
- this._extensions = Object.create(null);
24
-
25
- for (let i = 0; i < arguments.length; i++) {
26
- this.define(arguments[i]);
27
- }
28
-
29
- this.define = this.define.bind(this);
30
- this.getType = this.getType.bind(this);
31
- this.getExtension = this.getExtension.bind(this);
32
- }
33
-
34
- /**
35
- * Define mimetype -> extension mappings. Each key is a mime-type that maps
36
- * to an array of extensions associated with the type. The first extension is
37
- * used as the default extension for the type.
38
- *
39
- * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
40
- *
41
- * If a type declares an extension that has already been defined, an error will
42
- * be thrown. To suppress this error and force the extension to be associated
43
- * with the new type, pass `force`=true. Alternatively, you may prefix the
44
- * extension with "*" to map the type to extension, without mapping the
45
- * extension to the type.
46
- *
47
- * e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']});
48
- *
49
- *
50
- * @param map (Object) type definitions
51
- * @param force (Boolean) if true, force overriding of existing definitions
52
- */
53
- Mime$1.prototype.define = function(typeMap, force) {
54
- for (let type in typeMap) {
55
- let extensions = typeMap[type].map(function(t) {
56
- return t.toLowerCase();
57
- });
58
- type = type.toLowerCase();
59
-
60
- for (let i = 0; i < extensions.length; i++) {
61
- const ext = extensions[i];
62
-
63
- // '*' prefix = not the preferred type for this extension. So fixup the
64
- // extension, and skip it.
65
- if (ext[0] === '*') {
66
- continue;
67
- }
68
-
69
- if (!force && (ext in this._types)) {
70
- throw new Error(
71
- 'Attempt to change mapping for "' + ext +
72
- '" extension from "' + this._types[ext] + '" to "' + type +
73
- '". Pass `force=true` to allow this, otherwise remove "' + ext +
74
- '" from the list of extensions for "' + type + '".'
75
- );
76
- }
77
-
78
- this._types[ext] = type;
79
- }
80
-
81
- // Use first extension as default
82
- if (force || !this._extensions[type]) {
83
- const ext = extensions[0];
84
- this._extensions[type] = (ext[0] !== '*') ? ext : ext.substr(1);
85
- }
86
- }
87
- };
88
-
89
- /**
90
- * Lookup a mime type based on extension
91
- */
92
- Mime$1.prototype.getType = function(path) {
93
- path = String(path);
94
- let last = path.replace(/^.*[/\\]/, '').toLowerCase();
95
- let ext = last.replace(/^.*\./, '').toLowerCase();
96
-
97
- let hasPath = last.length < path.length;
98
- let hasDot = ext.length < last.length - 1;
99
-
100
- return (hasDot || !hasPath) && this._types[ext] || null;
101
- };
102
-
103
- /**
104
- * Return file extension associated with a mime type
105
- */
106
- Mime$1.prototype.getExtension = function(type) {
107
- type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
108
- return type && this._extensions[type.toLowerCase()] || null;
109
- };
110
-
111
- var Mime_1 = Mime$1;
112
-
113
- 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"]};
114
-
115
- 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"]};
116
-
117
- let Mime = Mime_1;
118
- var mime = new Mime(standard, other);
119
-
120
- var src$1 = {exports: {}};
121
-
122
- var browser$1 = {exports: {}};
123
-
124
- var debug$3 = {exports: {}};
125
-
126
- /**
127
- * Helpers.
128
- */
129
-
130
- var s$1 = 1000;
131
- var m$1 = s$1 * 60;
132
- var h$1 = m$1 * 60;
133
- var d$1 = h$1 * 24;
134
- var y$1 = d$1 * 365.25;
135
-
136
- /**
137
- * Parse or format the given `val`.
138
- *
139
- * Options:
140
- *
141
- * - `long` verbose formatting [false]
142
- *
143
- * @param {String|Number} val
144
- * @param {Object} [options]
145
- * @throws {Error} throw an error if val is not a non-empty string or a number
146
- * @return {String|Number}
147
- * @api public
148
- */
149
-
150
- var ms$1 = function(val, options) {
151
- options = options || {};
152
- var type = typeof val;
153
- if (type === 'string' && val.length > 0) {
154
- return parse$2(val);
155
- } else if (type === 'number' && isNaN(val) === false) {
156
- return options.long ? fmtLong$1(val) : fmtShort$1(val);
157
- }
158
- throw new Error(
159
- 'val is not a non-empty string or a valid number. val=' +
160
- JSON.stringify(val)
161
- );
162
- };
163
-
164
- /**
165
- * Parse the given `str` and return milliseconds.
166
- *
167
- * @param {String} str
168
- * @return {Number}
169
- * @api private
170
- */
171
-
172
- function parse$2(str) {
173
- str = String(str);
174
- if (str.length > 100) {
175
- return;
176
- }
177
- var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
178
- str
179
- );
180
- if (!match) {
181
- return;
182
- }
183
- var n = parseFloat(match[1]);
184
- var type = (match[2] || 'ms').toLowerCase();
185
- switch (type) {
186
- case 'years':
187
- case 'year':
188
- case 'yrs':
189
- case 'yr':
190
- case 'y':
191
- return n * y$1;
192
- case 'days':
193
- case 'day':
194
- case 'd':
195
- return n * d$1;
196
- case 'hours':
197
- case 'hour':
198
- case 'hrs':
199
- case 'hr':
200
- case 'h':
201
- return n * h$1;
202
- case 'minutes':
203
- case 'minute':
204
- case 'mins':
205
- case 'min':
206
- case 'm':
207
- return n * m$1;
208
- case 'seconds':
209
- case 'second':
210
- case 'secs':
211
- case 'sec':
212
- case 's':
213
- return n * s$1;
214
- case 'milliseconds':
215
- case 'millisecond':
216
- case 'msecs':
217
- case 'msec':
218
- case 'ms':
219
- return n;
220
- default:
221
- return undefined;
222
- }
223
- }
224
-
225
- /**
226
- * Short format for `ms`.
227
- *
228
- * @param {Number} ms
229
- * @return {String}
230
- * @api private
231
- */
232
-
233
- function fmtShort$1(ms) {
234
- if (ms >= d$1) {
235
- return Math.round(ms / d$1) + 'd';
236
- }
237
- if (ms >= h$1) {
238
- return Math.round(ms / h$1) + 'h';
239
- }
240
- if (ms >= m$1) {
241
- return Math.round(ms / m$1) + 'm';
242
- }
243
- if (ms >= s$1) {
244
- return Math.round(ms / s$1) + 's';
245
- }
246
- return ms + 'ms';
247
- }
248
-
249
- /**
250
- * Long format for `ms`.
251
- *
252
- * @param {Number} ms
253
- * @return {String}
254
- * @api private
255
- */
256
-
257
- function fmtLong$1(ms) {
258
- return plural$1(ms, d$1, 'day') ||
259
- plural$1(ms, h$1, 'hour') ||
260
- plural$1(ms, m$1, 'minute') ||
261
- plural$1(ms, s$1, 'second') ||
262
- ms + ' ms';
263
- }
264
-
265
- /**
266
- * Pluralization helper.
267
- */
268
-
269
- function plural$1(ms, n, name) {
270
- if (ms < n) {
271
- return;
272
- }
273
- if (ms < n * 1.5) {
274
- return Math.floor(ms / n) + ' ' + name;
275
- }
276
- return Math.ceil(ms / n) + ' ' + name + 's';
277
- }
278
-
279
- (function (module, exports) {
280
- /**
281
- * This is the common logic for both the Node.js and web browser
282
- * implementations of `debug()`.
283
- *
284
- * Expose `debug()` as the module.
285
- */
286
-
287
- exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
288
- exports.coerce = coerce;
289
- exports.disable = disable;
290
- exports.enable = enable;
291
- exports.enabled = enabled;
292
- exports.humanize = ms$1;
293
-
294
- /**
295
- * The currently active debug mode names, and names to skip.
296
- */
297
-
298
- exports.names = [];
299
- exports.skips = [];
300
-
301
- /**
302
- * Map of special "%n" handling functions, for the debug "format" argument.
303
- *
304
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
305
- */
306
-
307
- exports.formatters = {};
308
-
309
- /**
310
- * Previous log timestamp.
311
- */
312
-
313
- var prevTime;
314
-
315
- /**
316
- * Select a color.
317
- * @param {String} namespace
318
- * @return {Number}
319
- * @api private
320
- */
321
-
322
- function selectColor(namespace) {
323
- var hash = 0, i;
324
-
325
- for (i in namespace) {
326
- hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
327
- hash |= 0; // Convert to 32bit integer
328
- }
329
-
330
- return exports.colors[Math.abs(hash) % exports.colors.length];
331
- }
332
-
333
- /**
334
- * Create a debugger with the given `namespace`.
335
- *
336
- * @param {String} namespace
337
- * @return {Function}
338
- * @api public
339
- */
340
-
341
- function createDebug(namespace) {
342
-
343
- function debug() {
344
- // disabled?
345
- if (!debug.enabled) return;
346
-
347
- var self = debug;
348
-
349
- // set `diff` timestamp
350
- var curr = +new Date();
351
- var ms = curr - (prevTime || curr);
352
- self.diff = ms;
353
- self.prev = prevTime;
354
- self.curr = curr;
355
- prevTime = curr;
356
-
357
- // turn the `arguments` into a proper Array
358
- var args = new Array(arguments.length);
359
- for (var i = 0; i < args.length; i++) {
360
- args[i] = arguments[i];
361
- }
362
-
363
- args[0] = exports.coerce(args[0]);
364
-
365
- if ('string' !== typeof args[0]) {
366
- // anything else let's inspect with %O
367
- args.unshift('%O');
368
- }
369
-
370
- // apply any `formatters` transformations
371
- var index = 0;
372
- args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
373
- // if we encounter an escaped % then don't increase the array index
374
- if (match === '%%') return match;
375
- index++;
376
- var formatter = exports.formatters[format];
377
- if ('function' === typeof formatter) {
378
- var val = args[index];
379
- match = formatter.call(self, val);
380
-
381
- // now we need to remove `args[index]` since it's inlined in the `format`
382
- args.splice(index, 1);
383
- index--;
384
- }
385
- return match;
386
- });
387
-
388
- // apply env-specific formatting (colors, etc.)
389
- exports.formatArgs.call(self, args);
390
-
391
- var logFn = debug.log || exports.log || console.log.bind(console);
392
- logFn.apply(self, args);
393
- }
394
-
395
- debug.namespace = namespace;
396
- debug.enabled = exports.enabled(namespace);
397
- debug.useColors = exports.useColors();
398
- debug.color = selectColor(namespace);
399
-
400
- // env-specific initialization logic for debug instances
401
- if ('function' === typeof exports.init) {
402
- exports.init(debug);
403
- }
404
-
405
- return debug;
406
- }
407
-
408
- /**
409
- * Enables a debug mode by namespaces. This can include modes
410
- * separated by a colon and wildcards.
411
- *
412
- * @param {String} namespaces
413
- * @api public
414
- */
415
-
416
- function enable(namespaces) {
417
- exports.save(namespaces);
418
-
419
- exports.names = [];
420
- exports.skips = [];
421
-
422
- var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
423
- var len = split.length;
424
-
425
- for (var i = 0; i < len; i++) {
426
- if (!split[i]) continue; // ignore empty strings
427
- namespaces = split[i].replace(/\*/g, '.*?');
428
- if (namespaces[0] === '-') {
429
- exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
430
- } else {
431
- exports.names.push(new RegExp('^' + namespaces + '$'));
432
- }
433
- }
434
- }
435
-
436
- /**
437
- * Disable debug output.
438
- *
439
- * @api public
440
- */
441
-
442
- function disable() {
443
- exports.enable('');
444
- }
445
-
446
- /**
447
- * Returns true if the given mode name is enabled, false otherwise.
448
- *
449
- * @param {String} name
450
- * @return {Boolean}
451
- * @api public
452
- */
453
-
454
- function enabled(name) {
455
- var i, len;
456
- for (i = 0, len = exports.skips.length; i < len; i++) {
457
- if (exports.skips[i].test(name)) {
458
- return false;
459
- }
460
- }
461
- for (i = 0, len = exports.names.length; i < len; i++) {
462
- if (exports.names[i].test(name)) {
463
- return true;
464
- }
465
- }
466
- return false;
467
- }
468
-
469
- /**
470
- * Coerce `val`.
471
- *
472
- * @param {Mixed} val
473
- * @return {Mixed}
474
- * @api private
475
- */
476
-
477
- function coerce(val) {
478
- if (val instanceof Error) return val.stack || val.message;
479
- return val;
480
- }
481
- }(debug$3, debug$3.exports));
482
-
483
- /**
484
- * This is the web browser implementation of `debug()`.
485
- *
486
- * Expose `debug()` as the module.
487
- */
488
-
489
- (function (module, exports) {
490
- exports = module.exports = debug$3.exports;
491
- exports.log = log;
492
- exports.formatArgs = formatArgs;
493
- exports.save = save;
494
- exports.load = load;
495
- exports.useColors = useColors;
496
- exports.storage = 'undefined' != typeof chrome
497
- && 'undefined' != typeof chrome.storage
498
- ? chrome.storage.local
499
- : localstorage();
500
-
501
- /**
502
- * Colors.
503
- */
504
-
505
- exports.colors = [
506
- 'lightseagreen',
507
- 'forestgreen',
508
- 'goldenrod',
509
- 'dodgerblue',
510
- 'darkorchid',
511
- 'crimson'
512
- ];
513
-
514
- /**
515
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
516
- * and the Firebug extension (any Firefox version) are known
517
- * to support "%c" CSS customizations.
518
- *
519
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
520
- */
521
-
522
- function useColors() {
523
- // NB: In an Electron preload script, document will be defined but not fully
524
- // initialized. Since we know we're in Chrome, we'll just detect this case
525
- // explicitly
526
- if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
527
- return true;
528
- }
529
-
530
- // is webkit? http://stackoverflow.com/a/16459606/376773
531
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
532
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
533
- // is firebug? http://stackoverflow.com/a/398120/376773
534
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
535
- // is firefox >= v31?
536
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
537
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
538
- // double check webkit in userAgent just in case we are in a worker
539
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
540
- }
541
-
542
- /**
543
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
544
- */
545
-
546
- exports.formatters.j = function(v) {
547
- try {
548
- return JSON.stringify(v);
549
- } catch (err) {
550
- return '[UnexpectedJSONParseError]: ' + err.message;
551
- }
552
- };
553
-
554
-
555
- /**
556
- * Colorize log arguments if enabled.
557
- *
558
- * @api public
559
- */
560
-
561
- function formatArgs(args) {
562
- var useColors = this.useColors;
563
-
564
- args[0] = (useColors ? '%c' : '')
565
- + this.namespace
566
- + (useColors ? ' %c' : ' ')
567
- + args[0]
568
- + (useColors ? '%c ' : ' ')
569
- + '+' + exports.humanize(this.diff);
570
-
571
- if (!useColors) return;
572
-
573
- var c = 'color: ' + this.color;
574
- args.splice(1, 0, c, 'color: inherit');
575
-
576
- // the final "%c" is somewhat tricky, because there could be other
577
- // arguments passed either before or after the %c, so we need to
578
- // figure out the correct index to insert the CSS into
579
- var index = 0;
580
- var lastC = 0;
581
- args[0].replace(/%[a-zA-Z%]/g, function(match) {
582
- if ('%%' === match) return;
583
- index++;
584
- if ('%c' === match) {
585
- // we only are interested in the *last* %c
586
- // (the user may have provided their own)
587
- lastC = index;
588
- }
589
- });
590
-
591
- args.splice(lastC, 0, c);
592
- }
593
-
594
- /**
595
- * Invokes `console.log()` when available.
596
- * No-op when `console.log` is not a "function".
597
- *
598
- * @api public
599
- */
600
-
601
- function log() {
602
- // this hackery is required for IE8/9, where
603
- // the `console.log` function doesn't have 'apply'
604
- return 'object' === typeof console
605
- && console.log
606
- && Function.prototype.apply.call(console.log, console, arguments);
607
- }
608
-
609
- /**
610
- * Save `namespaces`.
611
- *
612
- * @param {String} namespaces
613
- * @api private
614
- */
615
-
616
- function save(namespaces) {
617
- try {
618
- if (null == namespaces) {
619
- exports.storage.removeItem('debug');
620
- } else {
621
- exports.storage.debug = namespaces;
622
- }
623
- } catch(e) {}
624
- }
625
-
626
- /**
627
- * Load `namespaces`.
628
- *
629
- * @return {String} returns the previously persisted debug modes
630
- * @api private
631
- */
632
-
633
- function load() {
634
- var r;
635
- try {
636
- r = exports.storage.debug;
637
- } catch(e) {}
638
-
639
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
640
- if (!r && typeof process !== 'undefined' && 'env' in process) {
641
- r = process.env.DEBUG;
642
- }
643
-
644
- return r;
645
- }
646
-
647
- /**
648
- * Enable namespaces listed in `localStorage.debug` initially.
649
- */
650
-
651
- exports.enable(load());
652
-
653
- /**
654
- * Localstorage attempts to return the localstorage.
655
- *
656
- * This is necessary because safari throws
657
- * when a user disables cookies/localstorage
658
- * and you attempt to access it.
659
- *
660
- * @return {LocalStorage}
661
- * @api private
662
- */
663
-
664
- function localstorage() {
665
- try {
666
- return window.localStorage;
667
- } catch (e) {}
668
- }
669
- }(browser$1, browser$1.exports));
670
-
671
- var node$1 = {exports: {}};
672
-
673
- /**
674
- * Module dependencies.
675
- */
676
-
677
- (function (module, exports) {
678
- var tty = require$$0$1;
679
- var util = require$$0$2;
680
-
681
- /**
682
- * This is the Node.js implementation of `debug()`.
683
- *
684
- * Expose `debug()` as the module.
685
- */
686
-
687
- exports = module.exports = debug$3.exports;
688
- exports.init = init;
689
- exports.log = log;
690
- exports.formatArgs = formatArgs;
691
- exports.save = save;
692
- exports.load = load;
693
- exports.useColors = useColors;
694
-
695
- /**
696
- * Colors.
697
- */
698
-
699
- exports.colors = [6, 2, 3, 4, 5, 1];
700
-
701
- /**
702
- * Build up the default `inspectOpts` object from the environment variables.
703
- *
704
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
705
- */
706
-
707
- exports.inspectOpts = Object.keys(process.env).filter(function (key) {
708
- return /^debug_/i.test(key);
709
- }).reduce(function (obj, key) {
710
- // camel-case
711
- var prop = key
712
- .substring(6)
713
- .toLowerCase()
714
- .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
715
-
716
- // coerce string value into JS value
717
- var val = process.env[key];
718
- if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
719
- else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
720
- else if (val === 'null') val = null;
721
- else val = Number(val);
722
-
723
- obj[prop] = val;
724
- return obj;
725
- }, {});
726
-
727
- /**
728
- * The file descriptor to write the `debug()` calls to.
729
- * Set the `DEBUG_FD` env variable to override with another value. i.e.:
730
- *
731
- * $ DEBUG_FD=3 node script.js 3>debug.log
732
- */
733
-
734
- var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
735
-
736
- if (1 !== fd && 2 !== fd) {
737
- 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)')();
738
- }
739
-
740
- var stream = 1 === fd ? process.stdout :
741
- 2 === fd ? process.stderr :
742
- createWritableStdioStream(fd);
743
-
744
- /**
745
- * Is stdout a TTY? Colored output is enabled when `true`.
746
- */
747
-
748
- function useColors() {
749
- return 'colors' in exports.inspectOpts
750
- ? Boolean(exports.inspectOpts.colors)
751
- : tty.isatty(fd);
752
- }
753
-
754
- /**
755
- * Map %o to `util.inspect()`, all on a single line.
756
- */
757
-
758
- exports.formatters.o = function(v) {
759
- this.inspectOpts.colors = this.useColors;
760
- return util.inspect(v, this.inspectOpts)
761
- .split('\n').map(function(str) {
762
- return str.trim()
763
- }).join(' ');
764
- };
765
-
766
- /**
767
- * Map %o to `util.inspect()`, allowing multiple lines if needed.
768
- */
769
-
770
- exports.formatters.O = function(v) {
771
- this.inspectOpts.colors = this.useColors;
772
- return util.inspect(v, this.inspectOpts);
773
- };
774
-
775
- /**
776
- * Adds ANSI color escape codes if enabled.
777
- *
778
- * @api public
779
- */
780
-
781
- function formatArgs(args) {
782
- var name = this.namespace;
783
- var useColors = this.useColors;
784
-
785
- if (useColors) {
786
- var c = this.color;
787
- var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
788
-
789
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
790
- args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
791
- } else {
792
- args[0] = new Date().toUTCString()
793
- + ' ' + name + ' ' + args[0];
794
- }
795
- }
796
-
797
- /**
798
- * Invokes `util.format()` with the specified arguments and writes to `stream`.
799
- */
800
-
801
- function log() {
802
- return stream.write(util.format.apply(util, arguments) + '\n');
803
- }
804
-
805
- /**
806
- * Save `namespaces`.
807
- *
808
- * @param {String} namespaces
809
- * @api private
810
- */
811
-
812
- function save(namespaces) {
813
- if (null == namespaces) {
814
- // If you set a process.env field to null or undefined, it gets cast to the
815
- // string 'null' or 'undefined'. Just delete instead.
816
- delete process.env.DEBUG;
817
- } else {
818
- process.env.DEBUG = namespaces;
819
- }
820
- }
821
-
822
- /**
823
- * Load `namespaces`.
824
- *
825
- * @return {String} returns the previously persisted debug modes
826
- * @api private
827
- */
828
-
829
- function load() {
830
- return process.env.DEBUG;
831
- }
832
-
833
- /**
834
- * Copied from `node/src/node.js`.
835
- *
836
- * XXX: It's lame that node doesn't expose this API out-of-the-box. It also
837
- * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
838
- */
839
-
840
- function createWritableStdioStream (fd) {
841
- var stream;
842
- var tty_wrap = process.binding('tty_wrap');
843
-
844
- // Note stream._type is used for test-module-load-list.js
845
-
846
- switch (tty_wrap.guessHandleType(fd)) {
847
- case 'TTY':
848
- stream = new tty.WriteStream(fd);
849
- stream._type = 'tty';
850
-
851
- // Hack to have stream not keep the event loop alive.
852
- // See https://github.com/joyent/node/issues/1726
853
- if (stream._handle && stream._handle.unref) {
854
- stream._handle.unref();
855
- }
856
- break;
857
-
858
- case 'FILE':
859
- var fs = require$$0$3;
860
- stream = new fs.SyncWriteStream(fd, { autoClose: false });
861
- stream._type = 'fs';
862
- break;
863
-
864
- case 'PIPE':
865
- case 'TCP':
866
- var net = require$$4;
867
- stream = new net.Socket({
868
- fd: fd,
869
- readable: false,
870
- writable: true
871
- });
872
-
873
- // FIXME Should probably have an option in net.Socket to create a
874
- // stream from an existing fd which is writable only. But for now
875
- // we'll just add this hack and set the `readable` member to false.
876
- // Test: ./node test/fixtures/echo.js < /etc/passwd
877
- stream.readable = false;
878
- stream.read = null;
879
- stream._type = 'pipe';
880
-
881
- // FIXME Hack to have stream not keep the event loop alive.
882
- // See https://github.com/joyent/node/issues/1726
883
- if (stream._handle && stream._handle.unref) {
884
- stream._handle.unref();
885
- }
886
- break;
887
-
888
- default:
889
- // Probably an error on in uv_guess_handle()
890
- throw new Error('Implement me. Unknown stream file type!');
891
- }
892
-
893
- // For supporting legacy API we put the FD here.
894
- stream.fd = fd;
895
-
896
- stream._isStdio = true;
897
-
898
- return stream;
899
- }
900
-
901
- /**
902
- * Init logic for `debug` instances.
903
- *
904
- * Create a new `inspectOpts` object in case `useColors` is set
905
- * differently for a particular `debug` instance.
906
- */
907
-
908
- function init (debug) {
909
- debug.inspectOpts = {};
910
-
911
- var keys = Object.keys(exports.inspectOpts);
912
- for (var i = 0; i < keys.length; i++) {
913
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
914
- }
915
- }
916
-
917
- /**
918
- * Enable namespaces listed in `process.env.DEBUG` initially.
919
- */
920
-
921
- exports.enable(load());
922
- }(node$1, node$1.exports));
923
-
924
- /**
925
- * Detect Electron renderer process, which is node, but we should
926
- * treat as a browser.
927
- */
928
-
929
- if (typeof process !== 'undefined' && process.type === 'renderer') {
930
- src$1.exports = browser$1.exports;
931
- } else {
932
- src$1.exports = node$1.exports;
933
- }
934
-
935
- var src = {exports: {}};
936
-
937
- var browser = {exports: {}};
938
-
939
- var debug$2 = {exports: {}};
940
-
941
- /**
942
- * Helpers.
943
- */
944
-
945
- var s = 1000;
946
- var m = s * 60;
947
- var h = m * 60;
948
- var d = h * 24;
949
- var y = d * 365.25;
950
-
951
- /**
952
- * Parse or format the given `val`.
953
- *
954
- * Options:
955
- *
956
- * - `long` verbose formatting [false]
957
- *
958
- * @param {String|Number} val
959
- * @param {Object} [options]
960
- * @throws {Error} throw an error if val is not a non-empty string or a number
961
- * @return {String|Number}
962
- * @api public
963
- */
964
-
965
- var ms = function(val, options) {
966
- options = options || {};
967
- var type = typeof val;
968
- if (type === 'string' && val.length > 0) {
969
- return parse$1(val);
970
- } else if (type === 'number' && isNaN(val) === false) {
971
- return options.long ? fmtLong(val) : fmtShort(val);
972
- }
973
- throw new Error(
974
- 'val is not a non-empty string or a valid number. val=' +
975
- JSON.stringify(val)
976
- );
977
- };
978
-
979
- /**
980
- * Parse the given `str` and return milliseconds.
981
- *
982
- * @param {String} str
983
- * @return {Number}
984
- * @api private
985
- */
986
-
987
- function parse$1(str) {
988
- str = String(str);
989
- if (str.length > 100) {
990
- return;
991
- }
992
- var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
993
- str
994
- );
995
- if (!match) {
996
- return;
997
- }
998
- var n = parseFloat(match[1]);
999
- var type = (match[2] || 'ms').toLowerCase();
1000
- switch (type) {
1001
- case 'years':
1002
- case 'year':
1003
- case 'yrs':
1004
- case 'yr':
1005
- case 'y':
1006
- return n * y;
1007
- case 'days':
1008
- case 'day':
1009
- case 'd':
1010
- return n * d;
1011
- case 'hours':
1012
- case 'hour':
1013
- case 'hrs':
1014
- case 'hr':
1015
- case 'h':
1016
- return n * h;
1017
- case 'minutes':
1018
- case 'minute':
1019
- case 'mins':
1020
- case 'min':
1021
- case 'm':
1022
- return n * m;
1023
- case 'seconds':
1024
- case 'second':
1025
- case 'secs':
1026
- case 'sec':
1027
- case 's':
1028
- return n * s;
1029
- case 'milliseconds':
1030
- case 'millisecond':
1031
- case 'msecs':
1032
- case 'msec':
1033
- case 'ms':
1034
- return n;
1035
- default:
1036
- return undefined;
1037
- }
1038
- }
1039
-
1040
- /**
1041
- * Short format for `ms`.
1042
- *
1043
- * @param {Number} ms
1044
- * @return {String}
1045
- * @api private
1046
- */
1047
-
1048
- function fmtShort(ms) {
1049
- if (ms >= d) {
1050
- return Math.round(ms / d) + 'd';
1051
- }
1052
- if (ms >= h) {
1053
- return Math.round(ms / h) + 'h';
1054
- }
1055
- if (ms >= m) {
1056
- return Math.round(ms / m) + 'm';
1057
- }
1058
- if (ms >= s) {
1059
- return Math.round(ms / s) + 's';
1060
- }
1061
- return ms + 'ms';
1062
- }
1063
-
1064
- /**
1065
- * Long format for `ms`.
1066
- *
1067
- * @param {Number} ms
1068
- * @return {String}
1069
- * @api private
1070
- */
1071
-
1072
- function fmtLong(ms) {
1073
- return plural(ms, d, 'day') ||
1074
- plural(ms, h, 'hour') ||
1075
- plural(ms, m, 'minute') ||
1076
- plural(ms, s, 'second') ||
1077
- ms + ' ms';
1078
- }
1079
-
1080
- /**
1081
- * Pluralization helper.
1082
- */
1083
-
1084
- function plural(ms, n, name) {
1085
- if (ms < n) {
1086
- return;
1087
- }
1088
- if (ms < n * 1.5) {
1089
- return Math.floor(ms / n) + ' ' + name;
1090
- }
1091
- return Math.ceil(ms / n) + ' ' + name + 's';
1092
- }
1093
-
1094
- (function (module, exports) {
1095
- /**
1096
- * This is the common logic for both the Node.js and web browser
1097
- * implementations of `debug()`.
1098
- *
1099
- * Expose `debug()` as the module.
1100
- */
1101
-
1102
- exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
1103
- exports.coerce = coerce;
1104
- exports.disable = disable;
1105
- exports.enable = enable;
1106
- exports.enabled = enabled;
1107
- exports.humanize = ms;
1108
-
1109
- /**
1110
- * The currently active debug mode names, and names to skip.
1111
- */
1112
-
1113
- exports.names = [];
1114
- exports.skips = [];
1115
-
1116
- /**
1117
- * Map of special "%n" handling functions, for the debug "format" argument.
1118
- *
1119
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
1120
- */
1121
-
1122
- exports.formatters = {};
1123
-
1124
- /**
1125
- * Previous log timestamp.
1126
- */
1127
-
1128
- var prevTime;
1129
-
1130
- /**
1131
- * Select a color.
1132
- * @param {String} namespace
1133
- * @return {Number}
1134
- * @api private
1135
- */
1136
-
1137
- function selectColor(namespace) {
1138
- var hash = 0, i;
1139
-
1140
- for (i in namespace) {
1141
- hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
1142
- hash |= 0; // Convert to 32bit integer
1143
- }
1144
-
1145
- return exports.colors[Math.abs(hash) % exports.colors.length];
1146
- }
1147
-
1148
- /**
1149
- * Create a debugger with the given `namespace`.
1150
- *
1151
- * @param {String} namespace
1152
- * @return {Function}
1153
- * @api public
1154
- */
1155
-
1156
- function createDebug(namespace) {
1157
-
1158
- function debug() {
1159
- // disabled?
1160
- if (!debug.enabled) return;
1161
-
1162
- var self = debug;
1163
-
1164
- // set `diff` timestamp
1165
- var curr = +new Date();
1166
- var ms = curr - (prevTime || curr);
1167
- self.diff = ms;
1168
- self.prev = prevTime;
1169
- self.curr = curr;
1170
- prevTime = curr;
1171
-
1172
- // turn the `arguments` into a proper Array
1173
- var args = new Array(arguments.length);
1174
- for (var i = 0; i < args.length; i++) {
1175
- args[i] = arguments[i];
1176
- }
1177
-
1178
- args[0] = exports.coerce(args[0]);
1179
-
1180
- if ('string' !== typeof args[0]) {
1181
- // anything else let's inspect with %O
1182
- args.unshift('%O');
1183
- }
1184
-
1185
- // apply any `formatters` transformations
1186
- var index = 0;
1187
- args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
1188
- // if we encounter an escaped % then don't increase the array index
1189
- if (match === '%%') return match;
1190
- index++;
1191
- var formatter = exports.formatters[format];
1192
- if ('function' === typeof formatter) {
1193
- var val = args[index];
1194
- match = formatter.call(self, val);
1195
-
1196
- // now we need to remove `args[index]` since it's inlined in the `format`
1197
- args.splice(index, 1);
1198
- index--;
1199
- }
1200
- return match;
1201
- });
1202
-
1203
- // apply env-specific formatting (colors, etc.)
1204
- exports.formatArgs.call(self, args);
1205
-
1206
- var logFn = debug.log || exports.log || console.log.bind(console);
1207
- logFn.apply(self, args);
1208
- }
1209
-
1210
- debug.namespace = namespace;
1211
- debug.enabled = exports.enabled(namespace);
1212
- debug.useColors = exports.useColors();
1213
- debug.color = selectColor(namespace);
1214
-
1215
- // env-specific initialization logic for debug instances
1216
- if ('function' === typeof exports.init) {
1217
- exports.init(debug);
1218
- }
1219
-
1220
- return debug;
1221
- }
1222
-
1223
- /**
1224
- * Enables a debug mode by namespaces. This can include modes
1225
- * separated by a colon and wildcards.
1226
- *
1227
- * @param {String} namespaces
1228
- * @api public
1229
- */
1230
-
1231
- function enable(namespaces) {
1232
- exports.save(namespaces);
1233
-
1234
- exports.names = [];
1235
- exports.skips = [];
1236
-
1237
- var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
1238
- var len = split.length;
1239
-
1240
- for (var i = 0; i < len; i++) {
1241
- if (!split[i]) continue; // ignore empty strings
1242
- namespaces = split[i].replace(/\*/g, '.*?');
1243
- if (namespaces[0] === '-') {
1244
- exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
1245
- } else {
1246
- exports.names.push(new RegExp('^' + namespaces + '$'));
1247
- }
1248
- }
1249
- }
1250
-
1251
- /**
1252
- * Disable debug output.
1253
- *
1254
- * @api public
1255
- */
1256
-
1257
- function disable() {
1258
- exports.enable('');
1259
- }
1260
-
1261
- /**
1262
- * Returns true if the given mode name is enabled, false otherwise.
1263
- *
1264
- * @param {String} name
1265
- * @return {Boolean}
1266
- * @api public
1267
- */
1268
-
1269
- function enabled(name) {
1270
- var i, len;
1271
- for (i = 0, len = exports.skips.length; i < len; i++) {
1272
- if (exports.skips[i].test(name)) {
1273
- return false;
1274
- }
1275
- }
1276
- for (i = 0, len = exports.names.length; i < len; i++) {
1277
- if (exports.names[i].test(name)) {
1278
- return true;
1279
- }
1280
- }
1281
- return false;
1282
- }
1283
-
1284
- /**
1285
- * Coerce `val`.
1286
- *
1287
- * @param {Mixed} val
1288
- * @return {Mixed}
1289
- * @api private
1290
- */
1291
-
1292
- function coerce(val) {
1293
- if (val instanceof Error) return val.stack || val.message;
1294
- return val;
1295
- }
1296
- }(debug$2, debug$2.exports));
1297
-
1298
- /**
1299
- * This is the web browser implementation of `debug()`.
1300
- *
1301
- * Expose `debug()` as the module.
1302
- */
1303
-
1304
- (function (module, exports) {
1305
- exports = module.exports = debug$2.exports;
1306
- exports.log = log;
1307
- exports.formatArgs = formatArgs;
1308
- exports.save = save;
1309
- exports.load = load;
1310
- exports.useColors = useColors;
1311
- exports.storage = 'undefined' != typeof chrome
1312
- && 'undefined' != typeof chrome.storage
1313
- ? chrome.storage.local
1314
- : localstorage();
1315
-
1316
- /**
1317
- * Colors.
1318
- */
1319
-
1320
- exports.colors = [
1321
- 'lightseagreen',
1322
- 'forestgreen',
1323
- 'goldenrod',
1324
- 'dodgerblue',
1325
- 'darkorchid',
1326
- 'crimson'
1327
- ];
1328
-
1329
- /**
1330
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
1331
- * and the Firebug extension (any Firefox version) are known
1332
- * to support "%c" CSS customizations.
1333
- *
1334
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
1335
- */
1336
-
1337
- function useColors() {
1338
- // NB: In an Electron preload script, document will be defined but not fully
1339
- // initialized. Since we know we're in Chrome, we'll just detect this case
1340
- // explicitly
1341
- if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
1342
- return true;
1343
- }
1344
-
1345
- // is webkit? http://stackoverflow.com/a/16459606/376773
1346
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
1347
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
1348
- // is firebug? http://stackoverflow.com/a/398120/376773
1349
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
1350
- // is firefox >= v31?
1351
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
1352
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
1353
- // double check webkit in userAgent just in case we are in a worker
1354
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
1355
- }
1356
-
1357
- /**
1358
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
1359
- */
1360
-
1361
- exports.formatters.j = function(v) {
1362
- try {
1363
- return JSON.stringify(v);
1364
- } catch (err) {
1365
- return '[UnexpectedJSONParseError]: ' + err.message;
1366
- }
1367
- };
1368
-
1369
-
1370
- /**
1371
- * Colorize log arguments if enabled.
1372
- *
1373
- * @api public
1374
- */
1375
-
1376
- function formatArgs(args) {
1377
- var useColors = this.useColors;
1378
-
1379
- args[0] = (useColors ? '%c' : '')
1380
- + this.namespace
1381
- + (useColors ? ' %c' : ' ')
1382
- + args[0]
1383
- + (useColors ? '%c ' : ' ')
1384
- + '+' + exports.humanize(this.diff);
1385
-
1386
- if (!useColors) return;
1387
-
1388
- var c = 'color: ' + this.color;
1389
- args.splice(1, 0, c, 'color: inherit');
1390
-
1391
- // the final "%c" is somewhat tricky, because there could be other
1392
- // arguments passed either before or after the %c, so we need to
1393
- // figure out the correct index to insert the CSS into
1394
- var index = 0;
1395
- var lastC = 0;
1396
- args[0].replace(/%[a-zA-Z%]/g, function(match) {
1397
- if ('%%' === match) return;
1398
- index++;
1399
- if ('%c' === match) {
1400
- // we only are interested in the *last* %c
1401
- // (the user may have provided their own)
1402
- lastC = index;
1403
- }
1404
- });
1405
-
1406
- args.splice(lastC, 0, c);
1407
- }
1408
-
1409
- /**
1410
- * Invokes `console.log()` when available.
1411
- * No-op when `console.log` is not a "function".
1412
- *
1413
- * @api public
1414
- */
1415
-
1416
- function log() {
1417
- // this hackery is required for IE8/9, where
1418
- // the `console.log` function doesn't have 'apply'
1419
- return 'object' === typeof console
1420
- && console.log
1421
- && Function.prototype.apply.call(console.log, console, arguments);
1422
- }
1423
-
1424
- /**
1425
- * Save `namespaces`.
1426
- *
1427
- * @param {String} namespaces
1428
- * @api private
1429
- */
1430
-
1431
- function save(namespaces) {
1432
- try {
1433
- if (null == namespaces) {
1434
- exports.storage.removeItem('debug');
1435
- } else {
1436
- exports.storage.debug = namespaces;
1437
- }
1438
- } catch(e) {}
1439
- }
1440
-
1441
- /**
1442
- * Load `namespaces`.
1443
- *
1444
- * @return {String} returns the previously persisted debug modes
1445
- * @api private
1446
- */
1447
-
1448
- function load() {
1449
- var r;
1450
- try {
1451
- r = exports.storage.debug;
1452
- } catch(e) {}
1453
-
1454
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
1455
- if (!r && typeof process !== 'undefined' && 'env' in process) {
1456
- r = process.env.DEBUG;
1457
- }
1458
-
1459
- return r;
1460
- }
1461
-
1462
- /**
1463
- * Enable namespaces listed in `localStorage.debug` initially.
1464
- */
1465
-
1466
- exports.enable(load());
1467
-
1468
- /**
1469
- * Localstorage attempts to return the localstorage.
1470
- *
1471
- * This is necessary because safari throws
1472
- * when a user disables cookies/localstorage
1473
- * and you attempt to access it.
1474
- *
1475
- * @return {LocalStorage}
1476
- * @api private
1477
- */
1478
-
1479
- function localstorage() {
1480
- try {
1481
- return window.localStorage;
1482
- } catch (e) {}
1483
- }
1484
- }(browser, browser.exports));
1485
-
1486
- var node = {exports: {}};
1487
-
1488
- /**
1489
- * Module dependencies.
1490
- */
1491
-
1492
- (function (module, exports) {
1493
- var tty = require$$0$1;
1494
- var util = require$$0$2;
1495
-
1496
- /**
1497
- * This is the Node.js implementation of `debug()`.
1498
- *
1499
- * Expose `debug()` as the module.
1500
- */
1501
-
1502
- exports = module.exports = debug$2.exports;
1503
- exports.init = init;
1504
- exports.log = log;
1505
- exports.formatArgs = formatArgs;
1506
- exports.save = save;
1507
- exports.load = load;
1508
- exports.useColors = useColors;
1509
-
1510
- /**
1511
- * Colors.
1512
- */
1513
-
1514
- exports.colors = [6, 2, 3, 4, 5, 1];
1515
-
1516
- /**
1517
- * Build up the default `inspectOpts` object from the environment variables.
1518
- *
1519
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
1520
- */
1521
-
1522
- exports.inspectOpts = Object.keys(process.env).filter(function (key) {
1523
- return /^debug_/i.test(key);
1524
- }).reduce(function (obj, key) {
1525
- // camel-case
1526
- var prop = key
1527
- .substring(6)
1528
- .toLowerCase()
1529
- .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
1530
-
1531
- // coerce string value into JS value
1532
- var val = process.env[key];
1533
- if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
1534
- else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
1535
- else if (val === 'null') val = null;
1536
- else val = Number(val);
1537
-
1538
- obj[prop] = val;
1539
- return obj;
1540
- }, {});
1541
-
1542
- /**
1543
- * The file descriptor to write the `debug()` calls to.
1544
- * Set the `DEBUG_FD` env variable to override with another value. i.e.:
1545
- *
1546
- * $ DEBUG_FD=3 node script.js 3>debug.log
1547
- */
1548
-
1549
- var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
1550
-
1551
- if (1 !== fd && 2 !== fd) {
1552
- 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)')();
1553
- }
1554
-
1555
- var stream = 1 === fd ? process.stdout :
1556
- 2 === fd ? process.stderr :
1557
- createWritableStdioStream(fd);
1558
-
1559
- /**
1560
- * Is stdout a TTY? Colored output is enabled when `true`.
1561
- */
1562
-
1563
- function useColors() {
1564
- return 'colors' in exports.inspectOpts
1565
- ? Boolean(exports.inspectOpts.colors)
1566
- : tty.isatty(fd);
1567
- }
1568
-
1569
- /**
1570
- * Map %o to `util.inspect()`, all on a single line.
1571
- */
1572
-
1573
- exports.formatters.o = function(v) {
1574
- this.inspectOpts.colors = this.useColors;
1575
- return util.inspect(v, this.inspectOpts)
1576
- .split('\n').map(function(str) {
1577
- return str.trim()
1578
- }).join(' ');
1579
- };
1580
-
1581
- /**
1582
- * Map %o to `util.inspect()`, allowing multiple lines if needed.
1583
- */
1584
-
1585
- exports.formatters.O = function(v) {
1586
- this.inspectOpts.colors = this.useColors;
1587
- return util.inspect(v, this.inspectOpts);
1588
- };
1589
-
1590
- /**
1591
- * Adds ANSI color escape codes if enabled.
1592
- *
1593
- * @api public
1594
- */
1595
-
1596
- function formatArgs(args) {
1597
- var name = this.namespace;
1598
- var useColors = this.useColors;
1599
-
1600
- if (useColors) {
1601
- var c = this.color;
1602
- var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m';
1603
-
1604
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
1605
- args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
1606
- } else {
1607
- args[0] = new Date().toUTCString()
1608
- + ' ' + name + ' ' + args[0];
1609
- }
1610
- }
1611
-
1612
- /**
1613
- * Invokes `util.format()` with the specified arguments and writes to `stream`.
1614
- */
1615
-
1616
- function log() {
1617
- return stream.write(util.format.apply(util, arguments) + '\n');
1618
- }
1619
-
1620
- /**
1621
- * Save `namespaces`.
1622
- *
1623
- * @param {String} namespaces
1624
- * @api private
1625
- */
1626
-
1627
- function save(namespaces) {
1628
- if (null == namespaces) {
1629
- // If you set a process.env field to null or undefined, it gets cast to the
1630
- // string 'null' or 'undefined'. Just delete instead.
1631
- delete process.env.DEBUG;
1632
- } else {
1633
- process.env.DEBUG = namespaces;
1634
- }
1635
- }
1636
-
1637
- /**
1638
- * Load `namespaces`.
1639
- *
1640
- * @return {String} returns the previously persisted debug modes
1641
- * @api private
1642
- */
1643
-
1644
- function load() {
1645
- return process.env.DEBUG;
1646
- }
1647
-
1648
- /**
1649
- * Copied from `node/src/node.js`.
1650
- *
1651
- * XXX: It's lame that node doesn't expose this API out-of-the-box. It also
1652
- * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
1653
- */
1654
-
1655
- function createWritableStdioStream (fd) {
1656
- var stream;
1657
- var tty_wrap = process.binding('tty_wrap');
1658
-
1659
- // Note stream._type is used for test-module-load-list.js
1660
-
1661
- switch (tty_wrap.guessHandleType(fd)) {
1662
- case 'TTY':
1663
- stream = new tty.WriteStream(fd);
1664
- stream._type = 'tty';
1665
-
1666
- // Hack to have stream not keep the event loop alive.
1667
- // See https://github.com/joyent/node/issues/1726
1668
- if (stream._handle && stream._handle.unref) {
1669
- stream._handle.unref();
1670
- }
1671
- break;
1672
-
1673
- case 'FILE':
1674
- var fs = require$$0$3;
1675
- stream = new fs.SyncWriteStream(fd, { autoClose: false });
1676
- stream._type = 'fs';
1677
- break;
1678
-
1679
- case 'PIPE':
1680
- case 'TCP':
1681
- var net = require$$4;
1682
- stream = new net.Socket({
1683
- fd: fd,
1684
- readable: false,
1685
- writable: true
1686
- });
1687
-
1688
- // FIXME Should probably have an option in net.Socket to create a
1689
- // stream from an existing fd which is writable only. But for now
1690
- // we'll just add this hack and set the `readable` member to false.
1691
- // Test: ./node test/fixtures/echo.js < /etc/passwd
1692
- stream.readable = false;
1693
- stream.read = null;
1694
- stream._type = 'pipe';
1695
-
1696
- // FIXME Hack to have stream not keep the event loop alive.
1697
- // See https://github.com/joyent/node/issues/1726
1698
- if (stream._handle && stream._handle.unref) {
1699
- stream._handle.unref();
1700
- }
1701
- break;
1702
-
1703
- default:
1704
- // Probably an error on in uv_guess_handle()
1705
- throw new Error('Implement me. Unknown stream file type!');
1706
- }
1707
-
1708
- // For supporting legacy API we put the FD here.
1709
- stream.fd = fd;
1710
-
1711
- stream._isStdio = true;
1712
-
1713
- return stream;
1714
- }
1715
-
1716
- /**
1717
- * Init logic for `debug` instances.
1718
- *
1719
- * Create a new `inspectOpts` object in case `useColors` is set
1720
- * differently for a particular `debug` instance.
1721
- */
1722
-
1723
- function init (debug) {
1724
- debug.inspectOpts = {};
1725
-
1726
- var keys = Object.keys(exports.inspectOpts);
1727
- for (var i = 0; i < keys.length; i++) {
1728
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
1729
- }
1730
- }
1731
-
1732
- /**
1733
- * Enable namespaces listed in `process.env.DEBUG` initially.
1734
- */
1735
-
1736
- exports.enable(load());
1737
- }(node, node.exports));
1738
-
1739
- /**
1740
- * Detect Electron renderer process, which is node, but we should
1741
- * treat as a browser.
1742
- */
1743
-
1744
- if (typeof process !== 'undefined' && process.type === 'renderer') {
1745
- src.exports = browser.exports;
1746
- } else {
1747
- src.exports = node.exports;
1748
- }
1749
-
1750
- /*!
1751
- * encodeurl
1752
- * Copyright(c) 2016 Douglas Christopher Wilson
1753
- * MIT Licensed
1754
- */
1755
-
1756
- /**
1757
- * Module exports.
1758
- * @public
1759
- */
1760
-
1761
- var encodeurl = encodeUrl$1;
1762
-
1763
- /**
1764
- * RegExp to match non-URL code points, *after* encoding (i.e. not including "%")
1765
- * and including invalid escape sequences.
1766
- * @private
1767
- */
1768
-
1769
- 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;
1770
-
1771
- /**
1772
- * RegExp to match unmatched surrogate pair.
1773
- * @private
1774
- */
1775
-
1776
- var UNMATCHED_SURROGATE_PAIR_REGEXP = /(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g;
1777
-
1778
- /**
1779
- * String to replace unmatched surrogate pair with.
1780
- * @private
1781
- */
1782
-
1783
- var UNMATCHED_SURROGATE_PAIR_REPLACE = '$1\uFFFD$2';
1784
-
1785
- /**
1786
- * Encode a URL to a percent-encoded form, excluding already-encoded sequences.
1787
- *
1788
- * This function will take an already-encoded URL and encode all the non-URL
1789
- * code points. This function will not encode the "%" character unless it is
1790
- * not part of a valid sequence (`%20` will be left as-is, but `%foo` will
1791
- * be encoded as `%25foo`).
1792
- *
1793
- * This encode is meant to be "safe" and does not throw errors. It will try as
1794
- * hard as it can to properly encode the given URL, including replacing any raw,
1795
- * unpaired surrogate pairs with the Unicode replacement character prior to
1796
- * encoding.
1797
- *
1798
- * @param {string} url
1799
- * @return {string}
1800
- * @public
1801
- */
1802
-
1803
- function encodeUrl$1 (url) {
1804
- return String(url)
1805
- .replace(UNMATCHED_SURROGATE_PAIR_REGEXP, UNMATCHED_SURROGATE_PAIR_REPLACE)
1806
- .replace(ENCODE_CHARS_REGEXP, encodeURI)
1807
- }
1808
-
1809
- /*!
1810
- * escape-html
1811
- * Copyright(c) 2012-2013 TJ Holowaychuk
1812
- * Copyright(c) 2015 Andreas Lubbe
1813
- * Copyright(c) 2015 Tiancheng "Timothy" Gu
1814
- * MIT Licensed
1815
- */
1816
-
1817
- /**
1818
- * Module variables.
1819
- * @private
1820
- */
1821
-
1822
- var matchHtmlRegExp = /["'&<>]/;
1823
-
1824
- /**
1825
- * Module exports.
1826
- * @public
1827
- */
1828
-
1829
- var escapeHtml_1 = escapeHtml$1;
1830
-
1831
- /**
1832
- * Escape special characters in the given string of html.
1833
- *
1834
- * @param {string} string The string to escape for inserting into HTML
1835
- * @return {string}
1836
- * @public
1837
- */
1838
-
1839
- function escapeHtml$1(string) {
1840
- var str = '' + string;
1841
- var match = matchHtmlRegExp.exec(str);
1842
-
1843
- if (!match) {
1844
- return str;
1845
- }
1846
-
1847
- var escape;
1848
- var html = '';
1849
- var index = 0;
1850
- var lastIndex = 0;
1851
-
1852
- for (index = match.index; index < str.length; index++) {
1853
- switch (str.charCodeAt(index)) {
1854
- case 34: // "
1855
- escape = '&quot;';
1856
- break;
1857
- case 38: // &
1858
- escape = '&amp;';
1859
- break;
1860
- case 39: // '
1861
- escape = '&#39;';
1862
- break;
1863
- case 60: // <
1864
- escape = '&lt;';
1865
- break;
1866
- case 62: // >
1867
- escape = '&gt;';
1868
- break;
1869
- default:
1870
- continue;
1871
- }
1872
-
1873
- if (lastIndex !== index) {
1874
- html += str.substring(lastIndex, index);
1875
- }
1876
-
1877
- lastIndex = index + 1;
1878
- html += escape;
1879
- }
1880
-
1881
- return lastIndex !== index
1882
- ? html + str.substring(lastIndex, index)
1883
- : html;
1884
- }
1885
-
1886
- var onFinished$2 = {exports: {}};
1887
-
1888
- /*!
1889
- * ee-first
1890
- * Copyright(c) 2014 Jonathan Ong
1891
- * MIT Licensed
1892
- */
1893
-
1894
- /**
1895
- * Module exports.
1896
- * @public
1897
- */
1898
-
1899
- var eeFirst = first$1;
1900
-
1901
- /**
1902
- * Get the first event in a set of event emitters and event pairs.
1903
- *
1904
- * @param {array} stuff
1905
- * @param {function} done
1906
- * @public
1907
- */
1908
-
1909
- function first$1(stuff, done) {
1910
- if (!Array.isArray(stuff))
1911
- throw new TypeError('arg must be an array of [ee, events...] arrays')
1912
-
1913
- var cleanups = [];
1914
-
1915
- for (var i = 0; i < stuff.length; i++) {
1916
- var arr = stuff[i];
1917
-
1918
- if (!Array.isArray(arr) || arr.length < 2)
1919
- throw new TypeError('each array member must be [ee, events...]')
1920
-
1921
- var ee = arr[0];
1922
-
1923
- for (var j = 1; j < arr.length; j++) {
1924
- var event = arr[j];
1925
- var fn = listener(event, callback);
1926
-
1927
- // listen to the event
1928
- ee.on(event, fn);
1929
- // push this listener to the list of cleanups
1930
- cleanups.push({
1931
- ee: ee,
1932
- event: event,
1933
- fn: fn,
1934
- });
1935
- }
1936
- }
1937
-
1938
- function callback() {
1939
- cleanup();
1940
- done.apply(null, arguments);
1941
- }
1942
-
1943
- function cleanup() {
1944
- var x;
1945
- for (var i = 0; i < cleanups.length; i++) {
1946
- x = cleanups[i];
1947
- x.ee.removeListener(x.event, x.fn);
1948
- }
1949
- }
1950
-
1951
- function thunk(fn) {
1952
- done = fn;
1953
- }
1954
-
1955
- thunk.cancel = cleanup;
1956
-
1957
- return thunk
1958
- }
1959
-
1960
- /**
1961
- * Create the event listener.
1962
- * @private
1963
- */
1964
-
1965
- function listener(event, done) {
1966
- return function onevent(arg1) {
1967
- var args = new Array(arguments.length);
1968
- var ee = this;
1969
- var err = event === 'error'
1970
- ? arg1
1971
- : null;
1972
-
1973
- // copy args to prevent arguments escaping scope
1974
- for (var i = 0; i < args.length; i++) {
1975
- args[i] = arguments[i];
1976
- }
1977
-
1978
- done(err, ee, event, args);
1979
- }
1980
- }
1981
-
1982
- /*!
1983
- * on-finished
1984
- * Copyright(c) 2013 Jonathan Ong
1985
- * Copyright(c) 2014 Douglas Christopher Wilson
1986
- * MIT Licensed
1987
- */
1988
-
1989
- /**
1990
- * Module exports.
1991
- * @public
1992
- */
1993
-
1994
- onFinished$2.exports = onFinished$1;
1995
- onFinished$2.exports.isFinished = isFinished$1;
1996
-
1997
- /**
1998
- * Module dependencies.
1999
- * @private
2000
- */
2001
-
2002
- var first = eeFirst;
2003
-
2004
- /**
2005
- * Variables.
2006
- * @private
2007
- */
2008
-
2009
- /* istanbul ignore next */
2010
- var defer$2 = typeof setImmediate === 'function'
2011
- ? setImmediate
2012
- : function(fn){ process.nextTick(fn.bind.apply(fn, arguments)); };
2013
-
2014
- /**
2015
- * Invoke callback when the response has finished, useful for
2016
- * cleaning up resources afterwards.
2017
- *
2018
- * @param {object} msg
2019
- * @param {function} listener
2020
- * @return {object}
2021
- * @public
2022
- */
2023
-
2024
- function onFinished$1(msg, listener) {
2025
- if (isFinished$1(msg) !== false) {
2026
- defer$2(listener, null, msg);
2027
- return msg
2028
- }
2029
-
2030
- // attach the listener to the message
2031
- attachListener(msg, listener);
2032
-
2033
- return msg
2034
- }
2035
-
2036
- /**
2037
- * Determine if message is already finished.
2038
- *
2039
- * @param {object} msg
2040
- * @return {boolean}
2041
- * @public
2042
- */
2043
-
2044
- function isFinished$1(msg) {
2045
- var socket = msg.socket;
2046
-
2047
- if (typeof msg.finished === 'boolean') {
2048
- // OutgoingMessage
2049
- return Boolean(msg.finished || (socket && !socket.writable))
2050
- }
2051
-
2052
- if (typeof msg.complete === 'boolean') {
2053
- // IncomingMessage
2054
- return Boolean(msg.upgrade || !socket || !socket.readable || (msg.complete && !msg.readable))
2055
- }
2056
-
2057
- // don't know
2058
- return undefined
2059
- }
2060
-
2061
- /**
2062
- * Attach a finished listener to the message.
2063
- *
2064
- * @param {object} msg
2065
- * @param {function} callback
2066
- * @private
2067
- */
2068
-
2069
- function attachFinishedListener(msg, callback) {
2070
- var eeMsg;
2071
- var eeSocket;
2072
- var finished = false;
2073
-
2074
- function onFinish(error) {
2075
- eeMsg.cancel();
2076
- eeSocket.cancel();
2077
-
2078
- finished = true;
2079
- callback(error);
2080
- }
2081
-
2082
- // finished on first message event
2083
- eeMsg = eeSocket = first([[msg, 'end', 'finish']], onFinish);
2084
-
2085
- function onSocket(socket) {
2086
- // remove listener
2087
- msg.removeListener('socket', onSocket);
2088
-
2089
- if (finished) return
2090
- if (eeMsg !== eeSocket) return
2091
-
2092
- // finished on first socket event
2093
- eeSocket = first([[socket, 'error', 'close']], onFinish);
2094
- }
2095
-
2096
- if (msg.socket) {
2097
- // socket already assigned
2098
- onSocket(msg.socket);
2099
- return
2100
- }
2101
-
2102
- // wait for socket to be assigned
2103
- msg.on('socket', onSocket);
2104
-
2105
- if (msg.socket === undefined) {
2106
- // node.js 0.8 patch
2107
- patchAssignSocket(msg, onSocket);
2108
- }
2109
- }
2110
-
2111
- /**
2112
- * Attach the listener to the message.
2113
- *
2114
- * @param {object} msg
2115
- * @return {function}
2116
- * @private
2117
- */
2118
-
2119
- function attachListener(msg, listener) {
2120
- var attached = msg.__onFinished;
2121
-
2122
- // create a private single listener with queue
2123
- if (!attached || !attached.queue) {
2124
- attached = msg.__onFinished = createListener(msg);
2125
- attachFinishedListener(msg, attached);
2126
- }
2127
-
2128
- attached.queue.push(listener);
2129
- }
2130
-
2131
- /**
2132
- * Create listener on message.
2133
- *
2134
- * @param {object} msg
2135
- * @return {function}
2136
- * @private
2137
- */
2138
-
2139
- function createListener(msg) {
2140
- function listener(err) {
2141
- if (msg.__onFinished === listener) msg.__onFinished = null;
2142
- if (!listener.queue) return
2143
-
2144
- var queue = listener.queue;
2145
- listener.queue = null;
2146
-
2147
- for (var i = 0; i < queue.length; i++) {
2148
- queue[i](err, msg);
2149
- }
2150
- }
2151
-
2152
- listener.queue = [];
2153
-
2154
- return listener
2155
- }
2156
-
2157
- /**
2158
- * Patch ServerResponse.prototype.assignSocket for node.js 0.8.
2159
- *
2160
- * @param {ServerResponse} res
2161
- * @param {function} callback
2162
- * @private
2163
- */
2164
-
2165
- function patchAssignSocket(res, callback) {
2166
- var assignSocket = res.assignSocket;
2167
-
2168
- if (typeof assignSocket !== 'function') return
2169
-
2170
- // res.on('socket', callback) is broken in 0.8
2171
- res.assignSocket = function _assignSocket(socket) {
2172
- assignSocket.call(this, socket);
2173
- callback(socket);
2174
- };
2175
- }
2176
-
2177
- var parseurl$1 = {exports: {}};
2178
-
2179
- /*!
2180
- * parseurl
2181
- * Copyright(c) 2014 Jonathan Ong
2182
- * Copyright(c) 2014-2017 Douglas Christopher Wilson
2183
- * MIT Licensed
2184
- */
2185
-
2186
- /**
2187
- * Module dependencies.
2188
- * @private
2189
- */
2190
-
2191
- var url = require$$7;
2192
- var parse = url.parse;
2193
- var Url = url.Url;
2194
-
2195
- /**
2196
- * Module exports.
2197
- * @public
2198
- */
2199
-
2200
- parseurl$1.exports = parseurl;
2201
- parseurl$1.exports.original = originalurl;
2202
-
2203
- /**
2204
- * Parse the `req` url with memoization.
2205
- *
2206
- * @param {ServerRequest} req
2207
- * @return {Object}
2208
- * @public
2209
- */
2210
-
2211
- function parseurl (req) {
2212
- var url = req.url;
2213
-
2214
- if (url === undefined) {
2215
- // URL is undefined
2216
- return undefined
2217
- }
2218
-
2219
- var parsed = req._parsedUrl;
2220
-
2221
- if (fresh(url, parsed)) {
2222
- // Return cached URL parse
2223
- return parsed
2224
- }
2225
-
2226
- // Parse the URL
2227
- parsed = fastparse(url);
2228
- parsed._raw = url;
2229
-
2230
- return (req._parsedUrl = parsed)
2231
- }
2232
- /**
2233
- * Parse the `req` original url with fallback and memoization.
2234
- *
2235
- * @param {ServerRequest} req
2236
- * @return {Object}
2237
- * @public
2238
- */
2239
-
2240
- function originalurl (req) {
2241
- var url = req.originalUrl;
2242
-
2243
- if (typeof url !== 'string') {
2244
- // Fallback
2245
- return parseurl(req)
2246
- }
2247
-
2248
- var parsed = req._parsedOriginalUrl;
2249
-
2250
- if (fresh(url, parsed)) {
2251
- // Return cached URL parse
2252
- return parsed
2253
- }
2254
-
2255
- // Parse the URL
2256
- parsed = fastparse(url);
2257
- parsed._raw = url;
2258
-
2259
- return (req._parsedOriginalUrl = parsed)
2260
- }
2261
- /**
2262
- * Parse the `str` url with fast-path short-cut.
2263
- *
2264
- * @param {string} str
2265
- * @return {Object}
2266
- * @private
2267
- */
2268
-
2269
- function fastparse (str) {
2270
- if (typeof str !== 'string' || str.charCodeAt(0) !== 0x2f /* / */) {
2271
- return parse(str)
2272
- }
2273
-
2274
- var pathname = str;
2275
- var query = null;
2276
- var search = null;
2277
-
2278
- // This takes the regexp from https://github.com/joyent/node/pull/7878
2279
- // Which is /^(\/[^?#\s]*)(\?[^#\s]*)?$/
2280
- // And unrolls it into a for loop
2281
- for (var i = 1; i < str.length; i++) {
2282
- switch (str.charCodeAt(i)) {
2283
- case 0x3f: /* ? */
2284
- if (search === null) {
2285
- pathname = str.substring(0, i);
2286
- query = str.substring(i + 1);
2287
- search = str.substring(i);
2288
- }
2289
- break
2290
- case 0x09: /* \t */
2291
- case 0x0a: /* \n */
2292
- case 0x0c: /* \f */
2293
- case 0x0d: /* \r */
2294
- case 0x20: /* */
2295
- case 0x23: /* # */
2296
- case 0xa0:
2297
- case 0xfeff:
2298
- return parse(str)
2299
- }
2300
- }
2301
-
2302
- var url = Url !== undefined
2303
- ? new Url()
2304
- : {};
2305
-
2306
- url.path = str;
2307
- url.href = str;
2308
- url.pathname = pathname;
2309
-
2310
- if (search !== null) {
2311
- url.query = query;
2312
- url.search = search;
2313
- }
2314
-
2315
- return url
2316
- }
2317
-
2318
- /**
2319
- * Determine if parsed is still fresh for url.
2320
- *
2321
- * @param {string} url
2322
- * @param {object} parsedUrl
2323
- * @return {boolean}
2324
- * @private
2325
- */
2326
-
2327
- function fresh (url, parsedUrl) {
2328
- return typeof parsedUrl === 'object' &&
2329
- parsedUrl !== null &&
2330
- (Url === undefined || parsedUrl instanceof Url) &&
2331
- parsedUrl._raw === url
2332
- }
2333
-
2334
- var require$$0 = {
2335
- "100": "Continue",
2336
- "101": "Switching Protocols",
2337
- "102": "Processing",
2338
- "103": "Early Hints",
2339
- "200": "OK",
2340
- "201": "Created",
2341
- "202": "Accepted",
2342
- "203": "Non-Authoritative Information",
2343
- "204": "No Content",
2344
- "205": "Reset Content",
2345
- "206": "Partial Content",
2346
- "207": "Multi-Status",
2347
- "208": "Already Reported",
2348
- "226": "IM Used",
2349
- "300": "Multiple Choices",
2350
- "301": "Moved Permanently",
2351
- "302": "Found",
2352
- "303": "See Other",
2353
- "304": "Not Modified",
2354
- "305": "Use Proxy",
2355
- "306": "(Unused)",
2356
- "307": "Temporary Redirect",
2357
- "308": "Permanent Redirect",
2358
- "400": "Bad Request",
2359
- "401": "Unauthorized",
2360
- "402": "Payment Required",
2361
- "403": "Forbidden",
2362
- "404": "Not Found",
2363
- "405": "Method Not Allowed",
2364
- "406": "Not Acceptable",
2365
- "407": "Proxy Authentication Required",
2366
- "408": "Request Timeout",
2367
- "409": "Conflict",
2368
- "410": "Gone",
2369
- "411": "Length Required",
2370
- "412": "Precondition Failed",
2371
- "413": "Payload Too Large",
2372
- "414": "URI Too Long",
2373
- "415": "Unsupported Media Type",
2374
- "416": "Range Not Satisfiable",
2375
- "417": "Expectation Failed",
2376
- "418": "I'm a teapot",
2377
- "421": "Misdirected Request",
2378
- "422": "Unprocessable Entity",
2379
- "423": "Locked",
2380
- "424": "Failed Dependency",
2381
- "425": "Unordered Collection",
2382
- "426": "Upgrade Required",
2383
- "428": "Precondition Required",
2384
- "429": "Too Many Requests",
2385
- "431": "Request Header Fields Too Large",
2386
- "451": "Unavailable For Legal Reasons",
2387
- "500": "Internal Server Error",
2388
- "501": "Not Implemented",
2389
- "502": "Bad Gateway",
2390
- "503": "Service Unavailable",
2391
- "504": "Gateway Timeout",
2392
- "505": "HTTP Version Not Supported",
2393
- "506": "Variant Also Negotiates",
2394
- "507": "Insufficient Storage",
2395
- "508": "Loop Detected",
2396
- "509": "Bandwidth Limit Exceeded",
2397
- "510": "Not Extended",
2398
- "511": "Network Authentication Required"
2399
- };
2400
-
2401
- /*!
2402
- * statuses
2403
- * Copyright(c) 2014 Jonathan Ong
2404
- * Copyright(c) 2016 Douglas Christopher Wilson
2405
- * MIT Licensed
2406
- */
2407
-
2408
- /**
2409
- * Module dependencies.
2410
- * @private
2411
- */
2412
-
2413
- var codes = require$$0;
2414
-
2415
- /**
2416
- * Module exports.
2417
- * @public
2418
- */
2419
-
2420
- var statuses$1 = status;
2421
-
2422
- // status code to message map
2423
- status.STATUS_CODES = codes;
2424
-
2425
- // array of status codes
2426
- status.codes = populateStatusesMap(status, codes);
2427
-
2428
- // status codes for redirects
2429
- status.redirect = {
2430
- 300: true,
2431
- 301: true,
2432
- 302: true,
2433
- 303: true,
2434
- 305: true,
2435
- 307: true,
2436
- 308: true
2437
- };
2438
-
2439
- // status codes for empty bodies
2440
- status.empty = {
2441
- 204: true,
2442
- 205: true,
2443
- 304: true
2444
- };
2445
-
2446
- // status codes for when you should retry the request
2447
- status.retry = {
2448
- 502: true,
2449
- 503: true,
2450
- 504: true
2451
- };
2452
-
2453
- /**
2454
- * Populate the statuses map for given codes.
2455
- * @private
2456
- */
2457
-
2458
- function populateStatusesMap (statuses, codes) {
2459
- var arr = [];
2460
-
2461
- Object.keys(codes).forEach(function forEachCode (code) {
2462
- var message = codes[code];
2463
- var status = Number(code);
2464
-
2465
- // Populate properties
2466
- statuses[status] = message;
2467
- statuses[message] = status;
2468
- statuses[message.toLowerCase()] = status;
2469
-
2470
- // Add to array
2471
- arr.push(status);
2472
- });
2473
-
2474
- return arr
2475
- }
2476
-
2477
- /**
2478
- * Get the status code.
2479
- *
2480
- * Given a number, this will throw if it is not a known status
2481
- * code, otherwise the code will be returned. Given a string,
2482
- * the string will be parsed for a number and return the code
2483
- * if valid, otherwise will lookup the code assuming this is
2484
- * the status message.
2485
- *
2486
- * @param {string|number} code
2487
- * @returns {number}
2488
- * @public
2489
- */
2490
-
2491
- function status (code) {
2492
- if (typeof code === 'number') {
2493
- if (!status[code]) throw new Error('invalid status code: ' + code)
2494
- return code
2495
- }
2496
-
2497
- if (typeof code !== 'string') {
2498
- throw new TypeError('code must be a number or string')
2499
- }
2500
-
2501
- // '403'
2502
- var n = parseInt(code, 10);
2503
- if (!isNaN(n)) {
2504
- if (!status[n]) throw new Error('invalid status code: ' + n)
2505
- return n
2506
- }
2507
-
2508
- n = status[code.toLowerCase()];
2509
- if (!n) throw new Error('invalid status message: "' + code + '"')
2510
- return n
2511
- }
2512
-
2513
- /*!
2514
- * unpipe
2515
- * Copyright(c) 2015 Douglas Christopher Wilson
2516
- * MIT Licensed
2517
- */
2518
-
2519
- /**
2520
- * Module exports.
2521
- * @public
2522
- */
2523
-
2524
- var unpipe_1 = unpipe$1;
2525
-
2526
- /**
2527
- * Determine if there are Node.js pipe-like data listeners.
2528
- * @private
2529
- */
2530
-
2531
- function hasPipeDataListeners(stream) {
2532
- var listeners = stream.listeners('data');
2533
-
2534
- for (var i = 0; i < listeners.length; i++) {
2535
- if (listeners[i].name === 'ondata') {
2536
- return true
2537
- }
2538
- }
2539
-
2540
- return false
2541
- }
2542
-
2543
- /**
2544
- * Unpipe a stream from all destinations.
2545
- *
2546
- * @param {object} stream
2547
- * @public
2548
- */
2549
-
2550
- function unpipe$1(stream) {
2551
- if (!stream) {
2552
- throw new TypeError('argument stream is required')
2553
- }
2554
-
2555
- if (typeof stream.unpipe === 'function') {
2556
- // new-style
2557
- stream.unpipe();
2558
- return
2559
- }
2560
-
2561
- // Node.js 0.8 hack
2562
- if (!hasPipeDataListeners(stream)) {
2563
- return
2564
- }
2565
-
2566
- var listener;
2567
- var listeners = stream.listeners('close');
2568
-
2569
- for (var i = 0; i < listeners.length; i++) {
2570
- listener = listeners[i];
2571
-
2572
- if (listener.name !== 'cleanup' && listener.name !== 'onclose') {
2573
- continue
2574
- }
2575
-
2576
- // invoke the listener
2577
- listener.call(stream);
2578
- }
2579
- }
2580
-
2581
- /*!
2582
- * finalhandler
2583
- * Copyright(c) 2014-2017 Douglas Christopher Wilson
2584
- * MIT Licensed
2585
- */
2586
-
2587
- /**
2588
- * Module dependencies.
2589
- * @private
2590
- */
2591
-
2592
- var debug$1 = src.exports('finalhandler');
2593
- var encodeUrl = encodeurl;
2594
- var escapeHtml = escapeHtml_1;
2595
- var onFinished = onFinished$2.exports;
2596
- var parseUrl$1 = parseurl$1.exports;
2597
- var statuses = statuses$1;
2598
- var unpipe = unpipe_1;
2599
-
2600
- /**
2601
- * Module variables.
2602
- * @private
2603
- */
2604
-
2605
- var DOUBLE_SPACE_REGEXP = /\x20{2}/g;
2606
- var NEWLINE_REGEXP = /\n/g;
2607
-
2608
- /* istanbul ignore next */
2609
- var defer$1 = typeof setImmediate === 'function'
2610
- ? setImmediate
2611
- : function (fn) { process.nextTick(fn.bind.apply(fn, arguments)); };
2612
- var isFinished = onFinished.isFinished;
2613
-
2614
- /**
2615
- * Create a minimal HTML document.
2616
- *
2617
- * @param {string} message
2618
- * @private
2619
- */
2620
-
2621
- function createHtmlDocument (message) {
2622
- var body = escapeHtml(message)
2623
- .replace(NEWLINE_REGEXP, '<br>')
2624
- .replace(DOUBLE_SPACE_REGEXP, ' &nbsp;');
2625
-
2626
- return '<!DOCTYPE html>\n' +
2627
- '<html lang="en">\n' +
2628
- '<head>\n' +
2629
- '<meta charset="utf-8">\n' +
2630
- '<title>Error</title>\n' +
2631
- '</head>\n' +
2632
- '<body>\n' +
2633
- '<pre>' + body + '</pre>\n' +
2634
- '</body>\n' +
2635
- '</html>\n'
2636
- }
2637
-
2638
- /**
2639
- * Module exports.
2640
- * @public
2641
- */
2642
-
2643
- var finalhandler_1 = finalhandler$1;
2644
-
2645
- /**
2646
- * Create a function to handle the final response.
2647
- *
2648
- * @param {Request} req
2649
- * @param {Response} res
2650
- * @param {Object} [options]
2651
- * @return {Function}
2652
- * @public
2653
- */
2654
-
2655
- function finalhandler$1 (req, res, options) {
2656
- var opts = options || {};
2657
-
2658
- // get environment
2659
- var env = opts.env || process.env.NODE_ENV || 'development';
2660
-
2661
- // get error callback
2662
- var onerror = opts.onerror;
2663
-
2664
- return function (err) {
2665
- var headers;
2666
- var msg;
2667
- var status;
2668
-
2669
- // ignore 404 on in-flight response
2670
- if (!err && headersSent(res)) {
2671
- debug$1('cannot 404 after headers sent');
2672
- return
2673
- }
2674
-
2675
- // unhandled error
2676
- if (err) {
2677
- // respect status code from error
2678
- status = getErrorStatusCode(err);
2679
-
2680
- if (status === undefined) {
2681
- // fallback to status code on response
2682
- status = getResponseStatusCode(res);
2683
- } else {
2684
- // respect headers from error
2685
- headers = getErrorHeaders(err);
2686
- }
2687
-
2688
- // get error message
2689
- msg = getErrorMessage(err, status, env);
2690
- } else {
2691
- // not found
2692
- status = 404;
2693
- msg = 'Cannot ' + req.method + ' ' + encodeUrl(getResourceName(req));
2694
- }
2695
-
2696
- debug$1('default %s', status);
2697
-
2698
- // schedule onerror callback
2699
- if (err && onerror) {
2700
- defer$1(onerror, err, req, res);
2701
- }
2702
-
2703
- // cannot actually respond
2704
- if (headersSent(res)) {
2705
- debug$1('cannot %d after headers sent', status);
2706
- req.socket.destroy();
2707
- return
2708
- }
2709
-
2710
- // send response
2711
- send(req, res, status, headers, msg);
2712
- }
2713
- }
2714
-
2715
- /**
2716
- * Get headers from Error object.
2717
- *
2718
- * @param {Error} err
2719
- * @return {object}
2720
- * @private
2721
- */
2722
-
2723
- function getErrorHeaders (err) {
2724
- if (!err.headers || typeof err.headers !== 'object') {
2725
- return undefined
2726
- }
2727
-
2728
- var headers = Object.create(null);
2729
- var keys = Object.keys(err.headers);
2730
-
2731
- for (var i = 0; i < keys.length; i++) {
2732
- var key = keys[i];
2733
- headers[key] = err.headers[key];
2734
- }
2735
-
2736
- return headers
2737
- }
2738
-
2739
- /**
2740
- * Get message from Error object, fallback to status message.
2741
- *
2742
- * @param {Error} err
2743
- * @param {number} status
2744
- * @param {string} env
2745
- * @return {string}
2746
- * @private
2747
- */
2748
-
2749
- function getErrorMessage (err, status, env) {
2750
- var msg;
2751
-
2752
- if (env !== 'production') {
2753
- // use err.stack, which typically includes err.message
2754
- msg = err.stack;
2755
-
2756
- // fallback to err.toString() when possible
2757
- if (!msg && typeof err.toString === 'function') {
2758
- msg = err.toString();
2759
- }
2760
- }
2761
-
2762
- return msg || statuses[status]
2763
- }
2764
-
2765
- /**
2766
- * Get status code from Error object.
2767
- *
2768
- * @param {Error} err
2769
- * @return {number}
2770
- * @private
2771
- */
2772
-
2773
- function getErrorStatusCode (err) {
2774
- // check err.status
2775
- if (typeof err.status === 'number' && err.status >= 400 && err.status < 600) {
2776
- return err.status
2777
- }
2778
-
2779
- // check err.statusCode
2780
- if (typeof err.statusCode === 'number' && err.statusCode >= 400 && err.statusCode < 600) {
2781
- return err.statusCode
2782
- }
2783
-
2784
- return undefined
2785
- }
2786
-
2787
- /**
2788
- * Get resource name for the request.
2789
- *
2790
- * This is typically just the original pathname of the request
2791
- * but will fallback to "resource" is that cannot be determined.
2792
- *
2793
- * @param {IncomingMessage} req
2794
- * @return {string}
2795
- * @private
2796
- */
2797
-
2798
- function getResourceName (req) {
2799
- try {
2800
- return parseUrl$1.original(req).pathname
2801
- } catch (e) {
2802
- return 'resource'
2803
- }
2804
- }
2805
-
2806
- /**
2807
- * Get status code from response.
2808
- *
2809
- * @param {OutgoingMessage} res
2810
- * @return {number}
2811
- * @private
2812
- */
2813
-
2814
- function getResponseStatusCode (res) {
2815
- var status = res.statusCode;
2816
-
2817
- // default status code to 500 if outside valid range
2818
- if (typeof status !== 'number' || status < 400 || status > 599) {
2819
- status = 500;
2820
- }
2821
-
2822
- return status
2823
- }
2824
-
2825
- /**
2826
- * Determine if the response headers have been sent.
2827
- *
2828
- * @param {object} res
2829
- * @returns {boolean}
2830
- * @private
2831
- */
2832
-
2833
- function headersSent (res) {
2834
- return typeof res.headersSent !== 'boolean'
2835
- ? Boolean(res._header)
2836
- : res.headersSent
2837
- }
2838
-
2839
- /**
2840
- * Send response.
2841
- *
2842
- * @param {IncomingMessage} req
2843
- * @param {OutgoingMessage} res
2844
- * @param {number} status
2845
- * @param {object} headers
2846
- * @param {string} message
2847
- * @private
2848
- */
2849
-
2850
- function send (req, res, status, headers, message) {
2851
- function write () {
2852
- // response body
2853
- var body = createHtmlDocument(message);
2854
-
2855
- // response status
2856
- res.statusCode = status;
2857
- res.statusMessage = statuses[status];
2858
-
2859
- // response headers
2860
- setHeaders(res, headers);
2861
-
2862
- // security headers
2863
- res.setHeader('Content-Security-Policy', "default-src 'none'");
2864
- res.setHeader('X-Content-Type-Options', 'nosniff');
2865
-
2866
- // standard headers
2867
- res.setHeader('Content-Type', 'text/html; charset=utf-8');
2868
- res.setHeader('Content-Length', Buffer.byteLength(body, 'utf8'));
2869
-
2870
- if (req.method === 'HEAD') {
2871
- res.end();
2872
- return
2873
- }
2874
-
2875
- res.end(body, 'utf8');
2876
- }
2877
-
2878
- if (isFinished(req)) {
2879
- write();
2880
- return
2881
- }
2882
-
2883
- // unpipe everything from the request
2884
- unpipe(req);
2885
-
2886
- // flush the request
2887
- onFinished(req, write);
2888
- req.resume();
2889
- }
2890
-
2891
- /**
2892
- * Set response headers from an object.
2893
- *
2894
- * @param {OutgoingMessage} res
2895
- * @param {object} headers
2896
- * @private
2897
- */
2898
-
2899
- function setHeaders (res, headers) {
2900
- if (!headers) {
2901
- return
2902
- }
2903
-
2904
- var keys = Object.keys(headers);
2905
- for (var i = 0; i < keys.length; i++) {
2906
- var key = keys[i];
2907
- res.setHeader(key, headers[key]);
2908
- }
2909
- }
2910
-
2911
- var utilsMerge = {exports: {}};
2912
-
2913
- /**
2914
- * Merge object b with object a.
2915
- *
2916
- * var a = { foo: 'bar' }
2917
- * , b = { bar: 'baz' };
2918
- *
2919
- * merge(a, b);
2920
- * // => { foo: 'bar', bar: 'baz' }
2921
- *
2922
- * @param {Object} a
2923
- * @param {Object} b
2924
- * @return {Object}
2925
- * @api public
2926
- */
2927
-
2928
- (function (module, exports) {
2929
- module.exports = function(a, b){
2930
- if (a && b) {
2931
- for (var key in b) {
2932
- a[key] = b[key];
2933
- }
2934
- }
2935
- return a;
2936
- };
2937
- }(utilsMerge));
2938
-
2939
- /*!
2940
- * connect
2941
- * Copyright(c) 2010 Sencha Inc.
2942
- * Copyright(c) 2011 TJ Holowaychuk
2943
- * Copyright(c) 2015 Douglas Christopher Wilson
2944
- * MIT Licensed
2945
- */
2946
-
2947
- /**
2948
- * Module dependencies.
2949
- * @private
2950
- */
2951
-
2952
- var debug = src$1.exports('connect:dispatcher');
2953
- var EventEmitter = require$$0$4.EventEmitter;
2954
- var finalhandler = finalhandler_1;
2955
- var http = require$$3;
2956
- var merge = utilsMerge.exports;
2957
- var parseUrl = parseurl$1.exports;
2958
-
2959
- /**
2960
- * Module exports.
2961
- * @public
2962
- */
2963
-
2964
- var connect = createServer$1;
2965
-
2966
- /**
2967
- * Module variables.
2968
- * @private
2969
- */
2970
-
2971
- var env = process.env.NODE_ENV || 'development';
2972
- var proto = {};
2973
-
2974
- /* istanbul ignore next */
2975
- var defer = typeof setImmediate === 'function'
2976
- ? setImmediate
2977
- : function(fn){ process.nextTick(fn.bind.apply(fn, arguments)); };
2978
-
2979
- /**
2980
- * Create a new connect server.
2981
- *
2982
- * @return {function}
2983
- * @public
2984
- */
2985
-
2986
- function createServer$1() {
2987
- function app(req, res, next){ app.handle(req, res, next); }
2988
- merge(app, proto);
2989
- merge(app, EventEmitter.prototype);
2990
- app.route = '/';
2991
- app.stack = [];
2992
- return app;
2993
- }
2994
-
2995
- /**
2996
- * Utilize the given middleware `handle` to the given `route`,
2997
- * defaulting to _/_. This "route" is the mount-point for the
2998
- * middleware, when given a value other than _/_ the middleware
2999
- * is only effective when that segment is present in the request's
3000
- * pathname.
3001
- *
3002
- * For example if we were to mount a function at _/admin_, it would
3003
- * be invoked on _/admin_, and _/admin/settings_, however it would
3004
- * not be invoked for _/_, or _/posts_.
3005
- *
3006
- * @param {String|Function|Server} route, callback or server
3007
- * @param {Function|Server} callback or server
3008
- * @return {Server} for chaining
3009
- * @public
3010
- */
3011
-
3012
- proto.use = function use(route, fn) {
3013
- var handle = fn;
3014
- var path = route;
3015
-
3016
- // default route to '/'
3017
- if (typeof route !== 'string') {
3018
- handle = route;
3019
- path = '/';
3020
- }
3021
-
3022
- // wrap sub-apps
3023
- if (typeof handle.handle === 'function') {
3024
- var server = handle;
3025
- server.route = path;
3026
- handle = function (req, res, next) {
3027
- server.handle(req, res, next);
3028
- };
3029
- }
3030
-
3031
- // wrap vanilla http.Servers
3032
- if (handle instanceof http.Server) {
3033
- handle = handle.listeners('request')[0];
3034
- }
3035
-
3036
- // strip trailing slash
3037
- if (path[path.length - 1] === '/') {
3038
- path = path.slice(0, -1);
3039
- }
3040
-
3041
- // add the middleware
3042
- debug('use %s %s', path || '/', handle.name || 'anonymous');
3043
- this.stack.push({ route: path, handle: handle });
3044
-
3045
- return this;
3046
- };
3047
-
3048
- /**
3049
- * Handle server requests, punting them down
3050
- * the middleware stack.
3051
- *
3052
- * @private
3053
- */
3054
-
3055
- proto.handle = function handle(req, res, out) {
3056
- var index = 0;
3057
- var protohost = getProtohost(req.url) || '';
3058
- var removed = '';
3059
- var slashAdded = false;
3060
- var stack = this.stack;
3061
-
3062
- // final function handler
3063
- var done = out || finalhandler(req, res, {
3064
- env: env,
3065
- onerror: logerror
3066
- });
3067
-
3068
- // store the original URL
3069
- req.originalUrl = req.originalUrl || req.url;
3070
-
3071
- function next(err) {
3072
- if (slashAdded) {
3073
- req.url = req.url.substr(1);
3074
- slashAdded = false;
3075
- }
3076
-
3077
- if (removed.length !== 0) {
3078
- req.url = protohost + removed + req.url.substr(protohost.length);
3079
- removed = '';
3080
- }
3081
-
3082
- // next callback
3083
- var layer = stack[index++];
3084
-
3085
- // all done
3086
- if (!layer) {
3087
- defer(done, err);
3088
- return;
3089
- }
3090
-
3091
- // route data
3092
- var path = parseUrl(req).pathname || '/';
3093
- var route = layer.route;
3094
-
3095
- // skip this layer if the route doesn't match
3096
- if (path.toLowerCase().substr(0, route.length) !== route.toLowerCase()) {
3097
- return next(err);
3098
- }
3099
-
3100
- // skip if route match does not border "/", ".", or end
3101
- var c = path.length > route.length && path[route.length];
3102
- if (c && c !== '/' && c !== '.') {
3103
- return next(err);
3104
- }
3105
-
3106
- // trim off the part of the url that matches the route
3107
- if (route.length !== 0 && route !== '/') {
3108
- removed = route;
3109
- req.url = protohost + req.url.substr(protohost.length + removed.length);
3110
-
3111
- // ensure leading slash
3112
- if (!protohost && req.url[0] !== '/') {
3113
- req.url = '/' + req.url;
3114
- slashAdded = true;
3115
- }
3116
- }
3117
-
3118
- // call the layer handle
3119
- call(layer.handle, route, err, req, res, next);
3120
- }
3121
-
3122
- next();
3123
- };
3124
-
3125
- /**
3126
- * Listen for connections.
3127
- *
3128
- * This method takes the same arguments
3129
- * as node's `http.Server#listen()`.
3130
- *
3131
- * HTTP and HTTPS:
3132
- *
3133
- * If you run your application both as HTTP
3134
- * and HTTPS you may wrap them individually,
3135
- * since your Connect "server" is really just
3136
- * a JavaScript `Function`.
3137
- *
3138
- * var connect = require('connect')
3139
- * , http = require('http')
3140
- * , https = require('https');
3141
- *
3142
- * var app = connect();
3143
- *
3144
- * http.createServer(app).listen(80);
3145
- * https.createServer(options, app).listen(443);
3146
- *
3147
- * @return {http.Server}
3148
- * @api public
3149
- */
3150
-
3151
- proto.listen = function listen() {
3152
- var server = http.createServer(this);
3153
- return server.listen.apply(server, arguments);
3154
- };
3155
-
3156
- /**
3157
- * Invoke a route handle.
3158
- * @private
3159
- */
3160
-
3161
- function call(handle, route, err, req, res, next) {
3162
- var arity = handle.length;
3163
- var error = err;
3164
- var hasError = Boolean(err);
3165
-
3166
- debug('%s %s : %s', handle.name || '<anonymous>', route, req.originalUrl);
3167
-
3168
- try {
3169
- if (hasError && arity === 4) {
3170
- // error-handling middleware
3171
- handle(err, req, res, next);
3172
- return;
3173
- } else if (!hasError && arity < 4) {
3174
- // request-handling middleware
3175
- handle(req, res, next);
3176
- return;
3177
- }
3178
- } catch (e) {
3179
- // replace the error
3180
- error = e;
3181
- }
3182
-
3183
- // continue
3184
- next(error);
3185
- }
3186
-
3187
- /**
3188
- * Log error using console.error.
3189
- *
3190
- * @param {Error} err
3191
- * @private
3192
- */
3193
-
3194
- function logerror(err) {
3195
- if (env !== 'test') console.error(err.stack || err.toString());
3196
- }
3197
-
3198
- /**
3199
- * Get get protocol + host for a URL.
3200
- *
3201
- * @param {string} url
3202
- * @private
3203
- */
3204
-
3205
- function getProtohost(url) {
3206
- if (url.length === 0 || url[0] === '/') {
3207
- return undefined;
3208
- }
3209
-
3210
- var fqdnIndex = url.indexOf('://');
3211
-
3212
- return fqdnIndex !== -1 && url.lastIndexOf('?', fqdnIndex) === -1
3213
- ? url.substr(0, url.indexOf('/', 3 + fqdnIndex))
3214
- : undefined;
3215
- }
3216
-
3217
- function createAssetMiddleware({ assets, root }) {
3218
- return (req, res, next) => {
3219
- const filePath = path.join(root ?? process.cwd(), "./dist/client", req.url);
3220
- if (assets.includes(filePath)) {
3221
- const rs = require$$0$3.createReadStream(filePath);
3222
- const { size } = require$$0$3.statSync(filePath);
3223
- res.setHeader("Content-Type", mime.getType(filePath));
3224
- res.setHeader("Content-Length", size);
3225
- return rs.pipe(res);
3226
- }
3227
- return next();
3228
- };
3229
- }
3230
- function createRequestMiddleware(mf) {
3231
- return async (req, res) => {
3232
- let response;
3233
- let status = 500;
3234
- let headers = {};
3235
- const request = new Request(urlFromRequest(req), {
3236
- ...req
3237
- });
3238
- try {
3239
- response = await mf.dispatchFetch(request);
3240
- status = response.status;
3241
- headers = response.headers;
3242
- res.writeHead(status, headers);
3243
- if (response.body) {
3244
- for await (const chunk of response.body) {
3245
- if (chunk)
3246
- res.write(chunk);
3247
- }
3248
- }
3249
- res.end();
3250
- } catch (error) {
3251
- res.writeHead(500, { "Content-Type": "text/plain; charset=UTF-8" });
3252
- res.end(error.stack, "utf8");
3253
- }
3254
- return response;
3255
- };
3256
- }
3257
- async function createServer(mf, options = { assets: [] }) {
3258
- const app = connect();
3259
- app.use(createAssetMiddleware(options));
3260
- app.use(createRequestMiddleware(mf));
3261
- const server = require$$3.createServer(app);
3262
- return server;
3263
- }
3264
- function urlFromRequest(req) {
3265
- const protocol = req.socket.encrypted ? "https" : "http";
3266
- const origin = `${protocol}://${req.headers.host ?? "localhost"}`;
3267
- const url = new URL(req.url ?? "", origin);
3268
- return url;
3269
- }
3270
-
3271
- class StorageFactory {
3272
- constructor() {
3273
- this.storages = /* @__PURE__ */ new Map();
3274
- }
3275
- storage(namespace) {
3276
- let storage = this.storages.get(namespace);
3277
- if (storage)
3278
- return storage;
3279
- this.storages.set(namespace, storage = new MemoryStorage());
3280
- return storage;
3281
- }
3282
- }
3283
-
3284
- class MiniOxygen extends MiniflareCore {
3285
- constructor(options) {
3286
- const storageFactory = new StorageFactory();
3287
- super(PLUGINS, {
3288
- log: new Log(LogLevel.VERBOSE),
3289
- storageFactory,
3290
- scriptRunner: new VMScriptRunner()
3291
- }, {
3292
- ...options
3293
- });
3294
- }
3295
- async dispose() {
3296
- await super.dispose();
3297
- }
3298
- createServer({ assets = [], root } = {}) {
3299
- return createServer(this, { assets, root });
3300
- }
3301
- }
3302
- const PLUGINS = {
3303
- CorePlugin,
3304
- CachePlugin
3305
- };
3306
-
3307
5
  async function preview({ directory, port }) {
3308
- await runPreview({ directory, port });
3309
- }
3310
- async function runPreview({ directory, port }) {
3311
- const files = await path.glob(path.join(directory, "dist/client/**/*"));
3312
- const mf = new MiniOxygen({
3313
- modules: true,
6
+ const config = {
7
+ port,
8
+ workerFile: "dist/worker/index.js",
9
+ assetsDir: "dist/client",
3314
10
  buildCommand: "yarn build",
3315
- globals: { Oxygen: {} },
3316
- scriptPath: path.resolve(directory, "dist/worker/index.js"),
3317
- sitePath: path.resolve(directory, "dist/client")
3318
- });
3319
- const app = await mf.createServer({ root: directory, assets: files });
3320
- app.listen(port, () => {
3321
- output.info(`
3322
- Started miniOxygen server. Listening at http://localhost:${port}
3323
- `);
11
+ modules: true,
12
+ watch: true,
13
+ buildWatchPaths: ["./src"],
14
+ autoReload: true
15
+ };
16
+ await file.write(path.resolve(directory, "mini-oxygen.config.json"), JSON.stringify(config, null, 2));
17
+ function cleanUp(options) {
18
+ if (options.exit) {
19
+ file.remove(path.resolve(directory, "mini-oxygen.config.json"));
20
+ }
21
+ }
22
+ process.on("SIGINT", cleanUp.bind(null, { exit: true }));
23
+ const executable = await oxygenPreviewExecutable();
24
+ await system.exec(executable, [], {
25
+ env: { NODE_OPTIONS: "--experimental-vm-modules" },
26
+ cwd: directory,
27
+ stdout: process.stdout
3324
28
  });
3325
29
  }
30
+ const OxygenPreviewExecutableNotFound = new error.Abort("Could not locate the executable file to run Oxygen locally.");
31
+ async function oxygenPreviewExecutable() {
32
+ const cwd = path.dirname(fileURLToPath(import.meta.url));
33
+ const executablePath = await path.findUp("node_modules/.bin/oxygen-preview", { type: "file", cwd });
34
+ if (!executablePath) {
35
+ throw OxygenPreviewExecutableNotFound;
36
+ }
37
+ return executablePath;
38
+ }
3326
39
 
3327
40
  const _Preview = class extends Command {
3328
41
  async run() {
3329
42
  const { flags } = await this.parse(_Preview);
3330
43
  const directory = flags.path ? path.resolve(flags.path) : process.cwd();
3331
44
  const port = parseInt(flags.port, 10);
3332
- if (!await file.exists(path.resolve(directory, "dist/worker"))) {
3333
- throw new error.Abort(`Couldn't find worker build. Run "yarn build" in ${directory}, and try again.`);
3334
- }
3335
45
  await preview({ directory, port });
3336
46
  }
3337
47
  };