@storybook/builder-webpack5 9.2.0-alpha.3 → 10.0.0-beta.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.
- package/README.md +2 -0
- package/dist/_node-chunks/chunk-GDYYM33D.js +85 -0
- package/dist/_node-chunks/chunk-UUTIIQLO.js +50 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1032 -1
- package/dist/loaders/export-order-loader.js +58 -1
- package/dist/presets/custom-webpack-preset.js +154 -1
- package/dist/presets/preview-preset.js +279 -2
- package/package.json +26 -45
- package/dist/chunk-LGGOBZAG.mjs +0 -3
- package/dist/index.mjs +0 -19
- package/dist/loaders/export-order-loader.d.ts +0 -5
- package/dist/loaders/export-order-loader.mjs +0 -9
- package/dist/presets/custom-webpack-preset.d.ts +0 -10
- package/dist/presets/preview-preset.d.ts +0 -7
package/dist/index.js
CHANGED
|
@@ -1 +1,1032 @@
|
|
|
1
|
-
"use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __commonJS=(cb,mod)=>function(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var require_pretty_hrtime=__commonJS({"../../node_modules/pretty-hrtime/index.js"(exports2,module2){"use strict";var minimalDesc=["h","min","s","ms","\u03BCs","ns"],verboseDesc=["hour","minute","second","millisecond","microsecond","nanosecond"],convert=[3600,60,1,1e6,1e3,1];module2.exports=function(source,opts){var verbose,precise,i,spot,sourceAtStep,valAtStep,decimals,strAtStep,results,totalSeconds;if(verbose=!1,precise=!1,opts&&(verbose=opts.verbose||!1,precise=opts.precise||!1),!Array.isArray(source)||source.length!==2||typeof source[0]!="number"||typeof source[1]!="number")return"";for(source[1]<0&&(totalSeconds=source[0]+source[1]/1e9,source[0]=parseInt(totalSeconds),source[1]=parseFloat((totalSeconds%1).toPrecision(9))*1e9),results="",i=0;i<6&&(spot=i<3?0:1,sourceAtStep=source[spot],i!==3&&i!==0&&(sourceAtStep=sourceAtStep%convert[i-1]),i===2&&(sourceAtStep+=source[1]/1e9),valAtStep=sourceAtStep/convert[i],!(valAtStep>=1&&(verbose&&(valAtStep=Math.floor(valAtStep)),precise?strAtStep=valAtStep.toString():(decimals=valAtStep>=10?0:2,strAtStep=valAtStep.toFixed(decimals)),strAtStep.indexOf(".")>-1&&strAtStep[strAtStep.length-1]==="0"&&(strAtStep=strAtStep.replace(/\.?0+$/,"")),results&&(results+=" "),results+=strAtStep,verbose?(results+=" "+verboseDesc[i],strAtStep!=="1"&&(results+="s")):results+=" "+minimalDesc[i],!verbose)));i++);return results}}});var index_exports={};__export(index_exports,{WebpackDefinePlugin:()=>WebpackDefinePlugin,WebpackIgnorePlugin:()=>WebpackIgnorePlugin,bail:()=>bail,build:()=>build,corePresets:()=>corePresets,executor:()=>executor,getConfig:()=>getConfig,getVirtualModules:()=>getVirtualModules,overridePresets:()=>overridePresets,printDuration:()=>printDuration,start:()=>start});module.exports=__toCommonJS(index_exports);var import_promises=require("fs/promises"),import_node_path2=require("path"),import_core_events=require("storybook/internal/core-events"),import_node_logger=require("storybook/internal/node-logger"),import_server_errors=require("storybook/internal/server-errors"),import_core_webpack2=require("@storybook/core-webpack"),import_pretty_hrtime=__toESM(require_pretty_hrtime());var fs=__toESM(require("fs"),1),import_path2=require("path");var import_path=require("path"),import_fs=require("fs");function totalist(dir,callback,pre=""){dir=(0,import_path.resolve)(".",dir);let arr=(0,import_fs.readdirSync)(dir),i=0,abs,stats;for(;i<arr.length;i++)abs=(0,import_path.join)(dir,arr[i]),stats=(0,import_fs.statSync)(abs),stats.isDirectory()?totalist(abs,callback,(0,import_path.join)(pre,arr[i])):callback((0,import_path.join)(pre,arr[i]),abs,stats)}var qs=__toESM(require("querystring"),1);function parse2(req){let raw=req.url;if(raw==null)return;let prev=req._parsedUrl;if(prev&&prev.raw===raw)return prev;let pathname=raw,search="",query,hash;if(raw.length>1){let idx=raw.indexOf("#",1);idx!==-1&&(hash=raw.substring(idx),pathname=raw.substring(0,idx)),idx=pathname.indexOf("?",1),idx!==-1&&(search=pathname.substring(idx),pathname=pathname.substring(0,idx),search.length>1&&(query=qs.parse(search.substring(1))))}return req._parsedUrl={pathname,search,query,hash,raw}}var mimes={"3g2":"video/3gpp2","3gp":"video/3gpp","3gpp":"video/3gpp","3mf":"model/3mf",aac:"audio/aac",ac:"application/pkix-attr-cert",adp:"audio/adpcm",adts:"audio/aac",ai:"application/postscript",aml:"application/automationml-aml+xml",amlx:"application/automationml-amlx+zip",amr:"audio/amr",apng:"image/apng",appcache:"text/cache-manifest",appinstaller:"application/appinstaller",appx:"application/appx",appxbundle:"application/appxbundle",asc:"application/pgp-keys",atom:"application/atom+xml",atomcat:"application/atomcat+xml",atomdeleted:"application/atomdeleted+xml",atomsvc:"application/atomsvc+xml",au:"audio/basic",avci:"image/avci",avcs:"image/avcs",avif:"image/avif",aw:"application/applixware",bdoc:"application/bdoc",bin:"application/octet-stream",bmp:"image/bmp",bpk:"application/octet-stream",btf:"image/prs.btif",btif:"image/prs.btif",buffer:"application/octet-stream",ccxml:"application/ccxml+xml",cdfx:"application/cdfx+xml",cdmia:"application/cdmi-capability",cdmic:"application/cdmi-container",cdmid:"application/cdmi-domain",cdmio:"application/cdmi-object",cdmiq:"application/cdmi-queue",cer:"application/pkix-cert",cgm:"image/cgm",cjs:"application/node",class:"application/java-vm",coffee:"text/coffeescript",conf:"text/plain",cpl:"application/cpl+xml",cpt:"application/mac-compactpro",crl:"application/pkix-crl",css:"text/css",csv:"text/csv",cu:"application/cu-seeme",cwl:"application/cwl",cww:"application/prs.cww",davmount:"application/davmount+xml",dbk:"application/docbook+xml",deb:"application/octet-stream",def:"text/plain",deploy:"application/octet-stream",dib:"image/bmp","disposition-notification":"message/disposition-notification",dist:"application/octet-stream",distz:"application/octet-stream",dll:"application/octet-stream",dmg:"application/octet-stream",dms:"application/octet-stream",doc:"application/msword",dot:"application/msword",dpx:"image/dpx",drle:"image/dicom-rle",dsc:"text/prs.lines.tag",dssc:"application/dssc+der",dtd:"application/xml-dtd",dump:"application/octet-stream",dwd:"application/atsc-dwd+xml",ear:"application/java-archive",ecma:"application/ecmascript",elc:"application/octet-stream",emf:"image/emf",eml:"message/rfc822",emma:"application/emma+xml",emotionml:"application/emotionml+xml",eps:"application/postscript",epub:"application/epub+zip",exe:"application/octet-stream",exi:"application/exi",exp:"application/express",exr:"image/aces",ez:"application/andrew-inset",fdf:"application/fdf",fdt:"application/fdt+xml",fits:"image/fits",g3:"image/g3fax",gbr:"application/rpki-ghostbusters",geojson:"application/geo+json",gif:"image/gif",glb:"model/gltf-binary",gltf:"model/gltf+json",gml:"application/gml+xml",gpx:"application/gpx+xml",gram:"application/srgs",grxml:"application/srgs+xml",gxf:"application/gxf",gz:"application/gzip",h261:"video/h261",h263:"video/h263",h264:"video/h264",heic:"image/heic",heics:"image/heic-sequence",heif:"image/heif",heifs:"image/heif-sequence",hej2:"image/hej2k",held:"application/atsc-held+xml",hjson:"application/hjson",hlp:"application/winhlp",hqx:"application/mac-binhex40",hsj2:"image/hsj2",htm:"text/html",html:"text/html",ics:"text/calendar",ief:"image/ief",ifb:"text/calendar",iges:"model/iges",igs:"model/iges",img:"application/octet-stream",in:"text/plain",ini:"text/plain",ink:"application/inkml+xml",inkml:"application/inkml+xml",ipfix:"application/ipfix",iso:"application/octet-stream",its:"application/its+xml",jade:"text/jade",jar:"application/java-archive",jhc:"image/jphc",jls:"image/jls",jp2:"image/jp2",jpe:"image/jpeg",jpeg:"image/jpeg",jpf:"image/jpx",jpg:"image/jpeg",jpg2:"image/jp2",jpgm:"image/jpm",jpgv:"video/jpeg",jph:"image/jph",jpm:"image/jpm",jpx:"image/jpx",js:"text/javascript",json:"application/json",json5:"application/json5",jsonld:"application/ld+json",jsonml:"application/jsonml+json",jsx:"text/jsx",jt:"model/jt",jxl:"image/jxl",jxr:"image/jxr",jxra:"image/jxra",jxrs:"image/jxrs",jxs:"image/jxs",jxsc:"image/jxsc",jxsi:"image/jxsi",jxss:"image/jxss",kar:"audio/midi",ktx:"image/ktx",ktx2:"image/ktx2",less:"text/less",lgr:"application/lgr+xml",list:"text/plain",litcoffee:"text/coffeescript",log:"text/plain",lostxml:"application/lost+xml",lrf:"application/octet-stream",m1v:"video/mpeg",m21:"application/mp21",m2a:"audio/mpeg",m2t:"video/mp2t",m2ts:"video/mp2t",m2v:"video/mpeg",m3a:"audio/mpeg",m4a:"audio/mp4",m4p:"application/mp4",m4s:"video/iso.segment",ma:"application/mathematica",mads:"application/mads+xml",maei:"application/mmt-aei+xml",man:"text/troff",manifest:"text/cache-manifest",map:"application/json",mar:"application/octet-stream",markdown:"text/markdown",mathml:"application/mathml+xml",mb:"application/mathematica",mbox:"application/mbox",md:"text/markdown",mdx:"text/mdx",me:"text/troff",mesh:"model/mesh",meta4:"application/metalink4+xml",metalink:"application/metalink+xml",mets:"application/mets+xml",mft:"application/rpki-manifest",mid:"audio/midi",midi:"audio/midi",mime:"message/rfc822",mj2:"video/mj2",mjp2:"video/mj2",mjs:"text/javascript",mml:"text/mathml",mods:"application/mods+xml",mov:"video/quicktime",mp2:"audio/mpeg",mp21:"application/mp21",mp2a:"audio/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mp4a:"audio/mp4",mp4s:"application/mp4",mp4v:"video/mp4",mpd:"application/dash+xml",mpe:"video/mpeg",mpeg:"video/mpeg",mpf:"application/media-policy-dataset+xml",mpg:"video/mpeg",mpg4:"video/mp4",mpga:"audio/mpeg",mpp:"application/dash-patch+xml",mrc:"application/marc",mrcx:"application/marcxml+xml",ms:"text/troff",mscml:"application/mediaservercontrol+xml",msh:"model/mesh",msi:"application/octet-stream",msix:"application/msix",msixbundle:"application/msixbundle",msm:"application/octet-stream",msp:"application/octet-stream",mtl:"model/mtl",mts:"video/mp2t",musd:"application/mmt-usd+xml",mxf:"application/mxf",mxmf:"audio/mobile-xmf",mxml:"application/xv+xml",n3:"text/n3",nb:"application/mathematica",nq:"application/n-quads",nt:"application/n-triples",obj:"model/obj",oda:"application/oda",oga:"audio/ogg",ogg:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",omdoc:"application/omdoc+xml",onepkg:"application/onenote",onetmp:"application/onenote",onetoc:"application/onenote",onetoc2:"application/onenote",opf:"application/oebps-package+xml",opus:"audio/ogg",otf:"font/otf",owl:"application/rdf+xml",oxps:"application/oxps",p10:"application/pkcs10",p7c:"application/pkcs7-mime",p7m:"application/pkcs7-mime",p7s:"application/pkcs7-signature",p8:"application/pkcs8",pdf:"application/pdf",pfr:"application/font-tdpfr",pgp:"application/pgp-encrypted",pkg:"application/octet-stream",pki:"application/pkixcmp",pkipath:"application/pkix-pkipath",pls:"application/pls+xml",png:"image/png",prc:"model/prc",prf:"application/pics-rules",provx:"application/provenance+xml",ps:"application/postscript",pskcxml:"application/pskc+xml",pti:"image/prs.pti",qt:"video/quicktime",raml:"application/raml+yaml",rapd:"application/route-apd+xml",rdf:"application/rdf+xml",relo:"application/p2p-overlay+xml",rif:"application/reginfo+xml",rl:"application/resource-lists+xml",rld:"application/resource-lists-diff+xml",rmi:"audio/midi",rnc:"application/relax-ng-compact-syntax",rng:"application/xml",roa:"application/rpki-roa",roff:"text/troff",rq:"application/sparql-query",rs:"application/rls-services+xml",rsat:"application/atsc-rsat+xml",rsd:"application/rsd+xml",rsheet:"application/urc-ressheet+xml",rss:"application/rss+xml",rtf:"text/rtf",rtx:"text/richtext",rusd:"application/route-usd+xml",s3m:"audio/s3m",sbml:"application/sbml+xml",scq:"application/scvp-cv-request",scs:"application/scvp-cv-response",sdp:"application/sdp",senmlx:"application/senml+xml",sensmlx:"application/sensml+xml",ser:"application/java-serialized-object",setpay:"application/set-payment-initiation",setreg:"application/set-registration-initiation",sgi:"image/sgi",sgm:"text/sgml",sgml:"text/sgml",shex:"text/shex",shf:"application/shf+xml",shtml:"text/html",sieve:"application/sieve",sig:"application/pgp-signature",sil:"audio/silk",silo:"model/mesh",siv:"application/sieve",slim:"text/slim",slm:"text/slim",sls:"application/route-s-tsid+xml",smi:"application/smil+xml",smil:"application/smil+xml",snd:"audio/basic",so:"application/octet-stream",spdx:"text/spdx",spp:"application/scvp-vp-response",spq:"application/scvp-vp-request",spx:"audio/ogg",sql:"application/sql",sru:"application/sru+xml",srx:"application/sparql-results+xml",ssdl:"application/ssdl+xml",ssml:"application/ssml+xml",stk:"application/hyperstudio",stl:"model/stl",stpx:"model/step+xml",stpxz:"model/step-xml+zip",stpz:"model/step+zip",styl:"text/stylus",stylus:"text/stylus",svg:"image/svg+xml",svgz:"image/svg+xml",swidtag:"application/swid+xml",t:"text/troff",t38:"image/t38",td:"application/urc-targetdesc+xml",tei:"application/tei+xml",teicorpus:"application/tei+xml",text:"text/plain",tfi:"application/thraud+xml",tfx:"image/tiff-fx",tif:"image/tiff",tiff:"image/tiff",toml:"application/toml",tr:"text/troff",trig:"application/trig",ts:"video/mp2t",tsd:"application/timestamped-data",tsv:"text/tab-separated-values",ttc:"font/collection",ttf:"font/ttf",ttl:"text/turtle",ttml:"application/ttml+xml",txt:"text/plain",u3d:"model/u3d",u8dsn:"message/global-delivery-status",u8hdr:"message/global-headers",u8mdn:"message/global-disposition-notification",u8msg:"message/global",ubj:"application/ubjson",uri:"text/uri-list",uris:"text/uri-list",urls:"text/uri-list",vcard:"text/vcard",vrml:"model/vrml",vtt:"text/vtt",vxml:"application/voicexml+xml",war:"application/java-archive",wasm:"application/wasm",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webmanifest:"application/manifest+json",webp:"image/webp",wgsl:"text/wgsl",wgt:"application/widget",wif:"application/watcherinfo+xml",wmf:"image/wmf",woff:"font/woff",woff2:"font/woff2",wrl:"model/vrml",wsdl:"application/wsdl+xml",wspolicy:"application/wspolicy+xml",x3d:"model/x3d+xml",x3db:"model/x3d+fastinfoset",x3dbz:"model/x3d+binary",x3dv:"model/x3d-vrml",x3dvz:"model/x3d+vrml",x3dz:"model/x3d+xml",xaml:"application/xaml+xml",xav:"application/xcap-att+xml",xca:"application/xcap-caps+xml",xcs:"application/calendar+xml",xdf:"application/xcap-diff+xml",xdssc:"application/dssc+xml",xel:"application/xcap-el+xml",xenc:"application/xenc+xml",xer:"application/patch-ops-error+xml",xfdf:"application/xfdf",xht:"application/xhtml+xml",xhtml:"application/xhtml+xml",xhvml:"application/xv+xml",xlf:"application/xliff+xml",xm:"audio/xm",xml:"text/xml",xns:"application/xcap-ns+xml",xop:"application/xop+xml",xpl:"application/xproc+xml",xsd:"application/xml",xsf:"application/prs.xsf+xml",xsl:"application/xml",xslt:"application/xml",xspf:"application/xspf+xml",xvm:"application/xv+xml",xvml:"application/xv+xml",yaml:"text/yaml",yang:"application/yang",yin:"application/yin+xml",yml:"text/yaml",zip:"application/zip"};function lookup(extn){let tmp=(""+extn).trim().toLowerCase(),idx=tmp.lastIndexOf(".");return mimes[~idx?tmp.substring(++idx):tmp]}var noop=()=>{};function isMatch(uri,arr){for(let i=0;i<arr.length;i++)if(arr[i].test(uri))return!0}function toAssume(uri,extns){let i=0,x,len=uri.length-1;uri.charCodeAt(len)===47&&(uri=uri.substring(0,len));let arr=[],tmp=`${uri}/index`;for(;i<extns.length;i++)x=extns[i]?`.${extns[i]}`:"",uri&&arr.push(uri+x),arr.push(tmp+x);return arr}function viaCache(cache,uri,extns){let i=0,data,arr=toAssume(uri,extns);for(;i<arr.length;i++)if(data=cache[arr[i]])return data}function viaLocal(dir,isEtag,uri,extns){let i=0,arr=toAssume(uri,extns),abs,stats,name,headers;for(;i<arr.length;i++)if(abs=(0,import_path2.normalize)((0,import_path2.join)(dir,name=arr[i])),abs.startsWith(dir)&&fs.existsSync(abs)){if(stats=fs.statSync(abs),stats.isDirectory())continue;return headers=toHeaders(name,stats,isEtag),headers["Cache-Control"]=isEtag?"no-cache":"no-store",{abs,stats,headers}}}function is404(req,res){return res.statusCode=404,res.end()}function send(req,res,file,stats,headers){let code=200,tmp,opts={};headers={...headers};for(let key in headers)tmp=res.getHeader(key),tmp&&(headers[key]=tmp);if((tmp=res.getHeader("content-type"))&&(headers["Content-Type"]=tmp),req.headers.range){code=206;let[x,y]=req.headers.range.replace("bytes=","").split("-"),end=opts.end=parseInt(y,10)||stats.size-1,start2=opts.start=parseInt(x,10)||0;if(end>=stats.size&&(end=stats.size-1),start2>=stats.size)return res.setHeader("Content-Range",`bytes */${stats.size}`),res.statusCode=416,res.end();headers["Content-Range"]=`bytes ${start2}-${end}/${stats.size}`,headers["Content-Length"]=end-start2+1,headers["Accept-Ranges"]="bytes"}res.writeHead(code,headers),fs.createReadStream(file,opts).pipe(res)}var ENCODING={".br":"br",".gz":"gzip"};function toHeaders(name,stats,isEtag){let enc=ENCODING[name.slice(-3)],ctype=lookup(name.slice(0,enc&&-3))||"";ctype==="text/html"&&(ctype+=";charset=utf-8");let headers={"Content-Length":stats.size,"Content-Type":ctype,"Last-Modified":stats.mtime.toUTCString()};return enc&&(headers["Content-Encoding"]=enc),isEtag&&(headers.ETag=`W/"${stats.size}-${stats.mtime.getTime()}"`),headers}function build_default(dir,opts={}){dir=(0,import_path2.resolve)(dir||".");let isNotFound=opts.onNoMatch||is404,setHeaders=opts.setHeaders||noop,extensions=opts.extensions||["html","htm"],gzips=opts.gzip&&extensions.map(x=>`${x}.gz`).concat("gz"),brots=opts.brotli&&extensions.map(x=>`${x}.br`).concat("br"),FILES={},fallback="/",isEtag=!!opts.etag,isSPA=!!opts.single;if(typeof opts.single=="string"){let idx=opts.single.lastIndexOf(".");fallback+=~idx?opts.single.substring(0,idx):opts.single}let ignores=[];opts.ignores!==!1&&(ignores.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/),opts.dotfiles?ignores.push(/\/\.\w/):ignores.push(/\/\.well-known/),[].concat(opts.ignores||[]).forEach(x=>{ignores.push(new RegExp(x,"i"))}));let cc=opts.maxAge!=null&&`public,max-age=${opts.maxAge}`;cc&&opts.immutable?cc+=",immutable":cc&&opts.maxAge===0&&(cc+=",must-revalidate"),opts.dev||totalist(dir,(name,abs,stats)=>{if(!/\.well-known[\\+\/]/.test(name)){if(!opts.dotfiles&&/(^\.|[\\+|\/+]\.)/.test(name))return}let headers=toHeaders(name,stats,isEtag);cc&&(headers["Cache-Control"]=cc),FILES["/"+name.normalize().replace(/\\+/g,"/")]={abs,stats,headers}});let lookup2=opts.dev?viaLocal.bind(0,dir,isEtag):viaCache.bind(0,FILES);return function(req,res,next){let extns=[""],pathname=parse2(req).pathname,val=req.headers["accept-encoding"]||"";if(gzips&&val.includes("gzip")&&extns.unshift(...gzips),brots&&/(br|brotli)/i.test(val)&&extns.unshift(...brots),extns.push(...extensions),pathname.indexOf("%")!==-1)try{pathname=decodeURI(pathname)}catch{}let data=lookup2(pathname,extns)||isSPA&&!isMatch(pathname,ignores)&&lookup2(fallback,extns);if(!data)return next?next():isNotFound(req,res);if(isEtag&&req.headers["if-none-match"]===data.headers.ETag)return res.writeHead(304),res.end();(gzips||brots)&&res.setHeader("Vary","Accept-Encoding"),setHeaders(res,pathname,data.stats),send(req,res,data.abs,data.stats,data.headers)}}var import_webpack=__toESM(require("webpack")),import_webpack_dev_middleware=__toESM(require("webpack-dev-middleware")),import_webpack_hot_middleware=__toESM(require("webpack-hot-middleware"));var import_node_path=require("path"),import_common=require("storybook/internal/common"),import_core_webpack=require("@storybook/core-webpack");function slash(path){return path.startsWith("\\\\?\\")?path:path.replace(/\\/g,"/")}var getVirtualModules=async options=>{let virtualModules={},builderOptions=await(0,import_common.getBuilderOptions)(options),workingDir=process.cwd(),isProd=options.configType==="PRODUCTION",nonNormalizedStories=await options.presets.apply("stories",[]),entries=[],stories=(0,import_common.normalizeStories)(nonNormalizedStories,{configDir:options.configDir,workingDir}),previewAnnotations=[...(await options.presets.apply("previewAnnotations",[],options)).map(entry=>typeof entry=="object"?entry.absolute:slash(entry)),(0,import_common.loadPreviewOrConfigFile)(options)].filter(Boolean),storiesFilename="storybook-stories.js",storiesPath=(0,import_node_path.resolve)((0,import_node_path.join)(workingDir,storiesFilename)),needPipelinedImport=!!builderOptions.lazyCompilation&&!isProd;virtualModules[storiesPath]=(0,import_core_webpack.toImportFn)(stories,{needPipelinedImport});let configEntryPath=(0,import_node_path.resolve)((0,import_node_path.join)(workingDir,"storybook-config-entry.js"));return virtualModules[configEntryPath]=(await(0,import_common.readTemplate)(require.resolve("@storybook/builder-webpack5/templates/virtualModuleModernEntry.js"))).replaceAll("'{{storiesFilename}}'",`'./${storiesFilename}'`).replaceAll("'{{previewAnnotations}}'",previewAnnotations.filter(Boolean).map(entry=>`'${entry}'`).join(",")).replaceAll("'{{previewAnnotations_requires}}'",previewAnnotations.filter(Boolean).map(entry=>`require('${entry}')`).join(",")).replace(/\\/g,"\\\\"),entries.push(configEntryPath),{virtualModules,entries}};var WebpackDefinePlugin=import_webpack.DefinePlugin,WebpackIgnorePlugin=import_webpack.IgnorePlugin,printDuration=startTime=>(0,import_pretty_hrtime.default)(process.hrtime(startTime)).replace(" ms"," milliseconds").replace(" s"," seconds").replace(" min"," minutes"),corePath=(0,import_node_path2.dirname)(require.resolve("storybook/internal/package.json")),compilation,reject,executor={get:async options=>{let version=await options.presets.apply("webpackVersion")||"5",webpackInstance=(await options.presets.apply("webpackInstance"))?.default||import_webpack.default;return(0,import_core_webpack2.checkWebpackVersion)({version},"5","builder-webpack5"),webpackInstance}},getConfig=async options=>{let{presets}=options,typescriptOptions=await presets.apply("typescript",{},options),frameworkOptions=await presets.apply("frameworkOptions");return presets.apply("webpack",{},{...options,typescriptOptions,frameworkOptions})},asyncIterator,bail=async()=>{if(asyncIterator)try{await asyncIterator.throw(new Error)}catch{}return reject&&reject(),new Promise((res,rej)=>{if(process&&compilation)try{compilation.close(()=>res()),import_node_logger.logger.warn("Force closed preview build")}catch{import_node_logger.logger.warn("Unable to close preview build!"),res()}else res()})},starter=async function*({startTime,options,router,channel}){let webpackInstance=await executor.get(options);yield;let config=await getConfig(options);if(config.stats==="none"||config.stats==="summary")throw new import_server_errors.WebpackMissingStatsError;yield;let compiler=webpackInstance(config);if(!compiler)throw new import_server_errors.WebpackInvocationError({error:new Error("Missing Webpack compiler at runtime!")});yield;let modulesCount=await options.cache?.get("modulesCount",1e3),totalModules,value=0;new import_webpack.ProgressPlugin({handler:(newValue,message,arg3)=>{value=Math.max(newValue,value);let progress={value,message:message.charAt(0).toUpperCase()+message.slice(1)};if(message==="building"){let counts=arg3&&arg3.match(/entries (\d+)\/(\d+)/)||[],complete=parseInt(counts[1],10),total=parseInt(counts[2],10);!Number.isNaN(complete)&&!Number.isNaN(total)&&(progress.modules={complete,total},totalModules=total)}value===1&&(options.cache&&options.cache.set("modulesCount",totalModules),progress.message||(progress.message=`Completed in ${printDuration(startTime)}.`)),channel.emit(import_core_events.PREVIEW_BUILDER_PROGRESS,progress)},modulesCount}).apply(compiler);let middlewareOptions={publicPath:config.output?.publicPath,writeToDisk:!0,stats:"errors-only"};compilation=(0,import_webpack_dev_middleware.default)(compiler,middlewareOptions);let previewResolvedDir=(0,import_node_path2.join)(corePath,"dist/preview");router.use("/sb-preview",build_default(previewResolvedDir,{maxAge:3e5,dev:!0,immutable:!0})),router.use(compilation),router.use((0,import_webpack_hot_middleware.default)(compiler,{log:!1}));let stats=await new Promise((res,rej)=>{compilation?.waitUntilValid(res),reject=rej});if(yield,!stats)throw new import_server_errors.WebpackMissingStatsError;let{warnings,errors}=getWebpackStats({config,stats});if(warnings.length>0&&warnings?.forEach(e=>import_node_logger.logger.warn(e.message)),errors.length>0)throw new import_server_errors.WebpackCompilationError({errors});return{bail,stats,totalTime:process.hrtime(startTime)}};function getWebpackStats({config,stats}){let statsOptions=typeof config.stats=="string"?config.stats:{...config.stats,warnings:!0,errors:!0},{warnings=[],errors=[]}=stats?.toJson(statsOptions)||{};return{warnings,errors}}var builder=async function*({startTime,options}){let webpackInstance=await executor.get(options);yield;let config=await getConfig(options);if(config.stats==="none"||config.stats==="summary")throw new import_server_errors.WebpackMissingStatsError;yield;let compiler=webpackInstance(config);if(!compiler)throw new import_server_errors.WebpackInvocationError({error:new Error("Missing Webpack compiler at runtime!")});let webpackCompilation=new Promise((succeed,fail)=>{compiler.run((error,stats)=>{if(error){compiler.close(()=>fail(new import_server_errors.WebpackInvocationError({error})));return}if(!stats)throw new import_server_errors.WebpackMissingStatsError;let{warnings,errors}=getWebpackStats({config,stats});if(warnings.length>0&&warnings?.forEach(e=>import_node_logger.logger.warn(e.message)),errors.length>0){errors.forEach(e=>import_node_logger.logger.error(e.message)),compiler.close(()=>fail(new import_server_errors.WebpackCompilationError({errors})));return}compiler.close(closeErr=>closeErr?fail(new import_server_errors.WebpackInvocationError({error:closeErr})):succeed(stats))})}),previewResolvedDir=(0,import_node_path2.join)(corePath,"dist/preview"),previewDirTarget=(0,import_node_path2.join)(options.outputDir||"","sb-preview"),previewFiles=(0,import_promises.cp)(previewResolvedDir,previewDirTarget,{filter:src=>{let{ext}=(0,import_node_path2.parse)(src);return ext?ext===".js":!0},recursive:!0}),[webpackCompilationOutput]=await Promise.all([webpackCompilation,previewFiles]);return webpackCompilationOutput},start=async options=>{asyncIterator=starter(options);let result;do result=await asyncIterator.next();while(!result.done);return result.value},build=async options=>{asyncIterator=builder(options);let result;do result=await asyncIterator.next();while(!result.done);return result.value},corePresets=[(0,import_node_path2.join)(__dirname,"presets/preview-preset.js")],overridePresets=[(0,import_node_path2.join)(__dirname,"./presets/custom-webpack-preset.js")];0&&(module.exports={WebpackDefinePlugin,WebpackIgnorePlugin,bail,build,corePresets,executor,getConfig,getVirtualModules,overridePresets,printDuration,start});
|
|
1
|
+
import CJS_COMPAT_NODE_URL_rmubg21st2 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_rmubg21st2 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_rmubg21st2 from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_rmubg21st2.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_rmubg21st2.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_rmubg21st2.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
getVirtualModules
|
|
14
|
+
} from "./_node-chunks/chunk-GDYYM33D.js";
|
|
15
|
+
import {
|
|
16
|
+
__commonJS,
|
|
17
|
+
__name,
|
|
18
|
+
__require,
|
|
19
|
+
__toESM
|
|
20
|
+
} from "./_node-chunks/chunk-UUTIIQLO.js";
|
|
21
|
+
|
|
22
|
+
// ../../node_modules/pretty-hrtime/index.js
|
|
23
|
+
var require_pretty_hrtime = __commonJS({
|
|
24
|
+
"../../node_modules/pretty-hrtime/index.js"(exports, module) {
|
|
25
|
+
"use strict";
|
|
26
|
+
var minimalDesc = ["h", "min", "s", "ms", "\u03BCs", "ns"];
|
|
27
|
+
var verboseDesc = ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"];
|
|
28
|
+
var convert = [60 * 60, 60, 1, 1e6, 1e3, 1];
|
|
29
|
+
module.exports = function(source, opts) {
|
|
30
|
+
var verbose, precise, i, spot, sourceAtStep, valAtStep, decimals, strAtStep, results, totalSeconds;
|
|
31
|
+
verbose = false;
|
|
32
|
+
precise = false;
|
|
33
|
+
if (opts) {
|
|
34
|
+
verbose = opts.verbose || false;
|
|
35
|
+
precise = opts.precise || false;
|
|
36
|
+
}
|
|
37
|
+
if (!Array.isArray(source) || source.length !== 2) {
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
if (typeof source[0] !== "number" || typeof source[1] !== "number") {
|
|
41
|
+
return "";
|
|
42
|
+
}
|
|
43
|
+
if (source[1] < 0) {
|
|
44
|
+
totalSeconds = source[0] + source[1] / 1e9;
|
|
45
|
+
source[0] = parseInt(totalSeconds);
|
|
46
|
+
source[1] = parseFloat((totalSeconds % 1).toPrecision(9)) * 1e9;
|
|
47
|
+
}
|
|
48
|
+
results = "";
|
|
49
|
+
for (i = 0; i < 6; i++) {
|
|
50
|
+
spot = i < 3 ? 0 : 1;
|
|
51
|
+
sourceAtStep = source[spot];
|
|
52
|
+
if (i !== 3 && i !== 0) {
|
|
53
|
+
sourceAtStep = sourceAtStep % convert[i - 1];
|
|
54
|
+
}
|
|
55
|
+
if (i === 2) {
|
|
56
|
+
sourceAtStep += source[1] / 1e9;
|
|
57
|
+
}
|
|
58
|
+
valAtStep = sourceAtStep / convert[i];
|
|
59
|
+
if (valAtStep >= 1) {
|
|
60
|
+
if (verbose) {
|
|
61
|
+
valAtStep = Math.floor(valAtStep);
|
|
62
|
+
}
|
|
63
|
+
if (!precise) {
|
|
64
|
+
decimals = valAtStep >= 10 ? 0 : 2;
|
|
65
|
+
strAtStep = valAtStep.toFixed(decimals);
|
|
66
|
+
} else {
|
|
67
|
+
strAtStep = valAtStep.toString();
|
|
68
|
+
}
|
|
69
|
+
if (strAtStep.indexOf(".") > -1 && strAtStep[strAtStep.length - 1] === "0") {
|
|
70
|
+
strAtStep = strAtStep.replace(/\.?0+$/, "");
|
|
71
|
+
}
|
|
72
|
+
if (results) {
|
|
73
|
+
results += " ";
|
|
74
|
+
}
|
|
75
|
+
results += strAtStep;
|
|
76
|
+
if (verbose) {
|
|
77
|
+
results += " " + verboseDesc[i];
|
|
78
|
+
if (strAtStep !== "1") {
|
|
79
|
+
results += "s";
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
results += " " + minimalDesc[i];
|
|
83
|
+
}
|
|
84
|
+
if (!verbose) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return results;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// ../../node_modules/totalist/sync/index.js
|
|
95
|
+
var require_sync = __commonJS({
|
|
96
|
+
"../../node_modules/totalist/sync/index.js"(exports) {
|
|
97
|
+
var { join: join2, resolve } = __require("path");
|
|
98
|
+
var { readdirSync, statSync } = __require("fs");
|
|
99
|
+
function totalist(dir, callback, pre = "") {
|
|
100
|
+
dir = resolve(".", dir);
|
|
101
|
+
let arr = readdirSync(dir);
|
|
102
|
+
let i = 0, abs, stats;
|
|
103
|
+
for (; i < arr.length; i++) {
|
|
104
|
+
abs = join2(dir, arr[i]);
|
|
105
|
+
stats = statSync(abs);
|
|
106
|
+
stats.isDirectory() ? totalist(abs, callback, join2(pre, arr[i])) : callback(join2(pre, arr[i]), abs, stats);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
__name(totalist, "totalist");
|
|
110
|
+
exports.totalist = totalist;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// ../../node_modules/@polka/url/build.js
|
|
115
|
+
var require_build = __commonJS({
|
|
116
|
+
"../../node_modules/@polka/url/build.js"(exports) {
|
|
117
|
+
var qs = __require("querystring");
|
|
118
|
+
function parse2(req) {
|
|
119
|
+
let raw = req.url;
|
|
120
|
+
if (raw == null) return;
|
|
121
|
+
let prev = req._parsedUrl;
|
|
122
|
+
if (prev && prev.raw === raw) return prev;
|
|
123
|
+
let pathname = raw, search = "", query, hash;
|
|
124
|
+
if (raw.length > 1) {
|
|
125
|
+
let idx = raw.indexOf("#", 1);
|
|
126
|
+
if (idx !== -1) {
|
|
127
|
+
hash = raw.substring(idx);
|
|
128
|
+
pathname = raw.substring(0, idx);
|
|
129
|
+
}
|
|
130
|
+
idx = pathname.indexOf("?", 1);
|
|
131
|
+
if (idx !== -1) {
|
|
132
|
+
search = pathname.substring(idx);
|
|
133
|
+
pathname = pathname.substring(0, idx);
|
|
134
|
+
if (search.length > 1) {
|
|
135
|
+
query = qs.parse(search.substring(1));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return req._parsedUrl = { pathname, search, query, hash, raw };
|
|
140
|
+
}
|
|
141
|
+
__name(parse2, "parse");
|
|
142
|
+
exports.parse = parse2;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// ../../node_modules/mrmime/index.js
|
|
147
|
+
var require_mrmime = __commonJS({
|
|
148
|
+
"../../node_modules/mrmime/index.js"(exports) {
|
|
149
|
+
var mimes = {
|
|
150
|
+
"3g2": "video/3gpp2",
|
|
151
|
+
"3gp": "video/3gpp",
|
|
152
|
+
"3gpp": "video/3gpp",
|
|
153
|
+
"3mf": "model/3mf",
|
|
154
|
+
"aac": "audio/aac",
|
|
155
|
+
"ac": "application/pkix-attr-cert",
|
|
156
|
+
"adp": "audio/adpcm",
|
|
157
|
+
"adts": "audio/aac",
|
|
158
|
+
"ai": "application/postscript",
|
|
159
|
+
"aml": "application/automationml-aml+xml",
|
|
160
|
+
"amlx": "application/automationml-amlx+zip",
|
|
161
|
+
"amr": "audio/amr",
|
|
162
|
+
"apng": "image/apng",
|
|
163
|
+
"appcache": "text/cache-manifest",
|
|
164
|
+
"appinstaller": "application/appinstaller",
|
|
165
|
+
"appx": "application/appx",
|
|
166
|
+
"appxbundle": "application/appxbundle",
|
|
167
|
+
"asc": "application/pgp-keys",
|
|
168
|
+
"atom": "application/atom+xml",
|
|
169
|
+
"atomcat": "application/atomcat+xml",
|
|
170
|
+
"atomdeleted": "application/atomdeleted+xml",
|
|
171
|
+
"atomsvc": "application/atomsvc+xml",
|
|
172
|
+
"au": "audio/basic",
|
|
173
|
+
"avci": "image/avci",
|
|
174
|
+
"avcs": "image/avcs",
|
|
175
|
+
"avif": "image/avif",
|
|
176
|
+
"aw": "application/applixware",
|
|
177
|
+
"bdoc": "application/bdoc",
|
|
178
|
+
"bin": "application/octet-stream",
|
|
179
|
+
"bmp": "image/bmp",
|
|
180
|
+
"bpk": "application/octet-stream",
|
|
181
|
+
"btf": "image/prs.btif",
|
|
182
|
+
"btif": "image/prs.btif",
|
|
183
|
+
"buffer": "application/octet-stream",
|
|
184
|
+
"ccxml": "application/ccxml+xml",
|
|
185
|
+
"cdfx": "application/cdfx+xml",
|
|
186
|
+
"cdmia": "application/cdmi-capability",
|
|
187
|
+
"cdmic": "application/cdmi-container",
|
|
188
|
+
"cdmid": "application/cdmi-domain",
|
|
189
|
+
"cdmio": "application/cdmi-object",
|
|
190
|
+
"cdmiq": "application/cdmi-queue",
|
|
191
|
+
"cer": "application/pkix-cert",
|
|
192
|
+
"cgm": "image/cgm",
|
|
193
|
+
"cjs": "application/node",
|
|
194
|
+
"class": "application/java-vm",
|
|
195
|
+
"coffee": "text/coffeescript",
|
|
196
|
+
"conf": "text/plain",
|
|
197
|
+
"cpl": "application/cpl+xml",
|
|
198
|
+
"cpt": "application/mac-compactpro",
|
|
199
|
+
"crl": "application/pkix-crl",
|
|
200
|
+
"css": "text/css",
|
|
201
|
+
"csv": "text/csv",
|
|
202
|
+
"cu": "application/cu-seeme",
|
|
203
|
+
"cwl": "application/cwl",
|
|
204
|
+
"cww": "application/prs.cww",
|
|
205
|
+
"davmount": "application/davmount+xml",
|
|
206
|
+
"dbk": "application/docbook+xml",
|
|
207
|
+
"deb": "application/octet-stream",
|
|
208
|
+
"def": "text/plain",
|
|
209
|
+
"deploy": "application/octet-stream",
|
|
210
|
+
"dib": "image/bmp",
|
|
211
|
+
"disposition-notification": "message/disposition-notification",
|
|
212
|
+
"dist": "application/octet-stream",
|
|
213
|
+
"distz": "application/octet-stream",
|
|
214
|
+
"dll": "application/octet-stream",
|
|
215
|
+
"dmg": "application/octet-stream",
|
|
216
|
+
"dms": "application/octet-stream",
|
|
217
|
+
"doc": "application/msword",
|
|
218
|
+
"dot": "application/msword",
|
|
219
|
+
"dpx": "image/dpx",
|
|
220
|
+
"drle": "image/dicom-rle",
|
|
221
|
+
"dsc": "text/prs.lines.tag",
|
|
222
|
+
"dssc": "application/dssc+der",
|
|
223
|
+
"dtd": "application/xml-dtd",
|
|
224
|
+
"dump": "application/octet-stream",
|
|
225
|
+
"dwd": "application/atsc-dwd+xml",
|
|
226
|
+
"ear": "application/java-archive",
|
|
227
|
+
"ecma": "application/ecmascript",
|
|
228
|
+
"elc": "application/octet-stream",
|
|
229
|
+
"emf": "image/emf",
|
|
230
|
+
"eml": "message/rfc822",
|
|
231
|
+
"emma": "application/emma+xml",
|
|
232
|
+
"emotionml": "application/emotionml+xml",
|
|
233
|
+
"eps": "application/postscript",
|
|
234
|
+
"epub": "application/epub+zip",
|
|
235
|
+
"exe": "application/octet-stream",
|
|
236
|
+
"exi": "application/exi",
|
|
237
|
+
"exp": "application/express",
|
|
238
|
+
"exr": "image/aces",
|
|
239
|
+
"ez": "application/andrew-inset",
|
|
240
|
+
"fdf": "application/fdf",
|
|
241
|
+
"fdt": "application/fdt+xml",
|
|
242
|
+
"fits": "image/fits",
|
|
243
|
+
"g3": "image/g3fax",
|
|
244
|
+
"gbr": "application/rpki-ghostbusters",
|
|
245
|
+
"geojson": "application/geo+json",
|
|
246
|
+
"gif": "image/gif",
|
|
247
|
+
"glb": "model/gltf-binary",
|
|
248
|
+
"gltf": "model/gltf+json",
|
|
249
|
+
"gml": "application/gml+xml",
|
|
250
|
+
"gpx": "application/gpx+xml",
|
|
251
|
+
"gram": "application/srgs",
|
|
252
|
+
"grxml": "application/srgs+xml",
|
|
253
|
+
"gxf": "application/gxf",
|
|
254
|
+
"gz": "application/gzip",
|
|
255
|
+
"h261": "video/h261",
|
|
256
|
+
"h263": "video/h263",
|
|
257
|
+
"h264": "video/h264",
|
|
258
|
+
"heic": "image/heic",
|
|
259
|
+
"heics": "image/heic-sequence",
|
|
260
|
+
"heif": "image/heif",
|
|
261
|
+
"heifs": "image/heif-sequence",
|
|
262
|
+
"hej2": "image/hej2k",
|
|
263
|
+
"held": "application/atsc-held+xml",
|
|
264
|
+
"hjson": "application/hjson",
|
|
265
|
+
"hlp": "application/winhlp",
|
|
266
|
+
"hqx": "application/mac-binhex40",
|
|
267
|
+
"hsj2": "image/hsj2",
|
|
268
|
+
"htm": "text/html",
|
|
269
|
+
"html": "text/html",
|
|
270
|
+
"ics": "text/calendar",
|
|
271
|
+
"ief": "image/ief",
|
|
272
|
+
"ifb": "text/calendar",
|
|
273
|
+
"iges": "model/iges",
|
|
274
|
+
"igs": "model/iges",
|
|
275
|
+
"img": "application/octet-stream",
|
|
276
|
+
"in": "text/plain",
|
|
277
|
+
"ini": "text/plain",
|
|
278
|
+
"ink": "application/inkml+xml",
|
|
279
|
+
"inkml": "application/inkml+xml",
|
|
280
|
+
"ipfix": "application/ipfix",
|
|
281
|
+
"iso": "application/octet-stream",
|
|
282
|
+
"its": "application/its+xml",
|
|
283
|
+
"jade": "text/jade",
|
|
284
|
+
"jar": "application/java-archive",
|
|
285
|
+
"jhc": "image/jphc",
|
|
286
|
+
"jls": "image/jls",
|
|
287
|
+
"jp2": "image/jp2",
|
|
288
|
+
"jpe": "image/jpeg",
|
|
289
|
+
"jpeg": "image/jpeg",
|
|
290
|
+
"jpf": "image/jpx",
|
|
291
|
+
"jpg": "image/jpeg",
|
|
292
|
+
"jpg2": "image/jp2",
|
|
293
|
+
"jpgm": "image/jpm",
|
|
294
|
+
"jpgv": "video/jpeg",
|
|
295
|
+
"jph": "image/jph",
|
|
296
|
+
"jpm": "image/jpm",
|
|
297
|
+
"jpx": "image/jpx",
|
|
298
|
+
"js": "text/javascript",
|
|
299
|
+
"json": "application/json",
|
|
300
|
+
"json5": "application/json5",
|
|
301
|
+
"jsonld": "application/ld+json",
|
|
302
|
+
"jsonml": "application/jsonml+json",
|
|
303
|
+
"jsx": "text/jsx",
|
|
304
|
+
"jt": "model/jt",
|
|
305
|
+
"jxl": "image/jxl",
|
|
306
|
+
"jxr": "image/jxr",
|
|
307
|
+
"jxra": "image/jxra",
|
|
308
|
+
"jxrs": "image/jxrs",
|
|
309
|
+
"jxs": "image/jxs",
|
|
310
|
+
"jxsc": "image/jxsc",
|
|
311
|
+
"jxsi": "image/jxsi",
|
|
312
|
+
"jxss": "image/jxss",
|
|
313
|
+
"kar": "audio/midi",
|
|
314
|
+
"ktx": "image/ktx",
|
|
315
|
+
"ktx2": "image/ktx2",
|
|
316
|
+
"less": "text/less",
|
|
317
|
+
"lgr": "application/lgr+xml",
|
|
318
|
+
"list": "text/plain",
|
|
319
|
+
"litcoffee": "text/coffeescript",
|
|
320
|
+
"log": "text/plain",
|
|
321
|
+
"lostxml": "application/lost+xml",
|
|
322
|
+
"lrf": "application/octet-stream",
|
|
323
|
+
"m1v": "video/mpeg",
|
|
324
|
+
"m21": "application/mp21",
|
|
325
|
+
"m2a": "audio/mpeg",
|
|
326
|
+
"m2t": "video/mp2t",
|
|
327
|
+
"m2ts": "video/mp2t",
|
|
328
|
+
"m2v": "video/mpeg",
|
|
329
|
+
"m3a": "audio/mpeg",
|
|
330
|
+
"m4a": "audio/mp4",
|
|
331
|
+
"m4p": "application/mp4",
|
|
332
|
+
"m4s": "video/iso.segment",
|
|
333
|
+
"ma": "application/mathematica",
|
|
334
|
+
"mads": "application/mads+xml",
|
|
335
|
+
"maei": "application/mmt-aei+xml",
|
|
336
|
+
"man": "text/troff",
|
|
337
|
+
"manifest": "text/cache-manifest",
|
|
338
|
+
"map": "application/json",
|
|
339
|
+
"mar": "application/octet-stream",
|
|
340
|
+
"markdown": "text/markdown",
|
|
341
|
+
"mathml": "application/mathml+xml",
|
|
342
|
+
"mb": "application/mathematica",
|
|
343
|
+
"mbox": "application/mbox",
|
|
344
|
+
"md": "text/markdown",
|
|
345
|
+
"mdx": "text/mdx",
|
|
346
|
+
"me": "text/troff",
|
|
347
|
+
"mesh": "model/mesh",
|
|
348
|
+
"meta4": "application/metalink4+xml",
|
|
349
|
+
"metalink": "application/metalink+xml",
|
|
350
|
+
"mets": "application/mets+xml",
|
|
351
|
+
"mft": "application/rpki-manifest",
|
|
352
|
+
"mid": "audio/midi",
|
|
353
|
+
"midi": "audio/midi",
|
|
354
|
+
"mime": "message/rfc822",
|
|
355
|
+
"mj2": "video/mj2",
|
|
356
|
+
"mjp2": "video/mj2",
|
|
357
|
+
"mjs": "text/javascript",
|
|
358
|
+
"mml": "text/mathml",
|
|
359
|
+
"mods": "application/mods+xml",
|
|
360
|
+
"mov": "video/quicktime",
|
|
361
|
+
"mp2": "audio/mpeg",
|
|
362
|
+
"mp21": "application/mp21",
|
|
363
|
+
"mp2a": "audio/mpeg",
|
|
364
|
+
"mp3": "audio/mpeg",
|
|
365
|
+
"mp4": "video/mp4",
|
|
366
|
+
"mp4a": "audio/mp4",
|
|
367
|
+
"mp4s": "application/mp4",
|
|
368
|
+
"mp4v": "video/mp4",
|
|
369
|
+
"mpd": "application/dash+xml",
|
|
370
|
+
"mpe": "video/mpeg",
|
|
371
|
+
"mpeg": "video/mpeg",
|
|
372
|
+
"mpf": "application/media-policy-dataset+xml",
|
|
373
|
+
"mpg": "video/mpeg",
|
|
374
|
+
"mpg4": "video/mp4",
|
|
375
|
+
"mpga": "audio/mpeg",
|
|
376
|
+
"mpp": "application/dash-patch+xml",
|
|
377
|
+
"mrc": "application/marc",
|
|
378
|
+
"mrcx": "application/marcxml+xml",
|
|
379
|
+
"ms": "text/troff",
|
|
380
|
+
"mscml": "application/mediaservercontrol+xml",
|
|
381
|
+
"msh": "model/mesh",
|
|
382
|
+
"msi": "application/octet-stream",
|
|
383
|
+
"msix": "application/msix",
|
|
384
|
+
"msixbundle": "application/msixbundle",
|
|
385
|
+
"msm": "application/octet-stream",
|
|
386
|
+
"msp": "application/octet-stream",
|
|
387
|
+
"mtl": "model/mtl",
|
|
388
|
+
"mts": "video/mp2t",
|
|
389
|
+
"musd": "application/mmt-usd+xml",
|
|
390
|
+
"mxf": "application/mxf",
|
|
391
|
+
"mxmf": "audio/mobile-xmf",
|
|
392
|
+
"mxml": "application/xv+xml",
|
|
393
|
+
"n3": "text/n3",
|
|
394
|
+
"nb": "application/mathematica",
|
|
395
|
+
"nq": "application/n-quads",
|
|
396
|
+
"nt": "application/n-triples",
|
|
397
|
+
"obj": "model/obj",
|
|
398
|
+
"oda": "application/oda",
|
|
399
|
+
"oga": "audio/ogg",
|
|
400
|
+
"ogg": "audio/ogg",
|
|
401
|
+
"ogv": "video/ogg",
|
|
402
|
+
"ogx": "application/ogg",
|
|
403
|
+
"omdoc": "application/omdoc+xml",
|
|
404
|
+
"onepkg": "application/onenote",
|
|
405
|
+
"onetmp": "application/onenote",
|
|
406
|
+
"onetoc": "application/onenote",
|
|
407
|
+
"onetoc2": "application/onenote",
|
|
408
|
+
"opf": "application/oebps-package+xml",
|
|
409
|
+
"opus": "audio/ogg",
|
|
410
|
+
"otf": "font/otf",
|
|
411
|
+
"owl": "application/rdf+xml",
|
|
412
|
+
"oxps": "application/oxps",
|
|
413
|
+
"p10": "application/pkcs10",
|
|
414
|
+
"p7c": "application/pkcs7-mime",
|
|
415
|
+
"p7m": "application/pkcs7-mime",
|
|
416
|
+
"p7s": "application/pkcs7-signature",
|
|
417
|
+
"p8": "application/pkcs8",
|
|
418
|
+
"pdf": "application/pdf",
|
|
419
|
+
"pfr": "application/font-tdpfr",
|
|
420
|
+
"pgp": "application/pgp-encrypted",
|
|
421
|
+
"pkg": "application/octet-stream",
|
|
422
|
+
"pki": "application/pkixcmp",
|
|
423
|
+
"pkipath": "application/pkix-pkipath",
|
|
424
|
+
"pls": "application/pls+xml",
|
|
425
|
+
"png": "image/png",
|
|
426
|
+
"prc": "model/prc",
|
|
427
|
+
"prf": "application/pics-rules",
|
|
428
|
+
"provx": "application/provenance+xml",
|
|
429
|
+
"ps": "application/postscript",
|
|
430
|
+
"pskcxml": "application/pskc+xml",
|
|
431
|
+
"pti": "image/prs.pti",
|
|
432
|
+
"qt": "video/quicktime",
|
|
433
|
+
"raml": "application/raml+yaml",
|
|
434
|
+
"rapd": "application/route-apd+xml",
|
|
435
|
+
"rdf": "application/rdf+xml",
|
|
436
|
+
"relo": "application/p2p-overlay+xml",
|
|
437
|
+
"rif": "application/reginfo+xml",
|
|
438
|
+
"rl": "application/resource-lists+xml",
|
|
439
|
+
"rld": "application/resource-lists-diff+xml",
|
|
440
|
+
"rmi": "audio/midi",
|
|
441
|
+
"rnc": "application/relax-ng-compact-syntax",
|
|
442
|
+
"rng": "application/xml",
|
|
443
|
+
"roa": "application/rpki-roa",
|
|
444
|
+
"roff": "text/troff",
|
|
445
|
+
"rq": "application/sparql-query",
|
|
446
|
+
"rs": "application/rls-services+xml",
|
|
447
|
+
"rsat": "application/atsc-rsat+xml",
|
|
448
|
+
"rsd": "application/rsd+xml",
|
|
449
|
+
"rsheet": "application/urc-ressheet+xml",
|
|
450
|
+
"rss": "application/rss+xml",
|
|
451
|
+
"rtf": "text/rtf",
|
|
452
|
+
"rtx": "text/richtext",
|
|
453
|
+
"rusd": "application/route-usd+xml",
|
|
454
|
+
"s3m": "audio/s3m",
|
|
455
|
+
"sbml": "application/sbml+xml",
|
|
456
|
+
"scq": "application/scvp-cv-request",
|
|
457
|
+
"scs": "application/scvp-cv-response",
|
|
458
|
+
"sdp": "application/sdp",
|
|
459
|
+
"senmlx": "application/senml+xml",
|
|
460
|
+
"sensmlx": "application/sensml+xml",
|
|
461
|
+
"ser": "application/java-serialized-object",
|
|
462
|
+
"setpay": "application/set-payment-initiation",
|
|
463
|
+
"setreg": "application/set-registration-initiation",
|
|
464
|
+
"sgi": "image/sgi",
|
|
465
|
+
"sgm": "text/sgml",
|
|
466
|
+
"sgml": "text/sgml",
|
|
467
|
+
"shex": "text/shex",
|
|
468
|
+
"shf": "application/shf+xml",
|
|
469
|
+
"shtml": "text/html",
|
|
470
|
+
"sieve": "application/sieve",
|
|
471
|
+
"sig": "application/pgp-signature",
|
|
472
|
+
"sil": "audio/silk",
|
|
473
|
+
"silo": "model/mesh",
|
|
474
|
+
"siv": "application/sieve",
|
|
475
|
+
"slim": "text/slim",
|
|
476
|
+
"slm": "text/slim",
|
|
477
|
+
"sls": "application/route-s-tsid+xml",
|
|
478
|
+
"smi": "application/smil+xml",
|
|
479
|
+
"smil": "application/smil+xml",
|
|
480
|
+
"snd": "audio/basic",
|
|
481
|
+
"so": "application/octet-stream",
|
|
482
|
+
"spdx": "text/spdx",
|
|
483
|
+
"spp": "application/scvp-vp-response",
|
|
484
|
+
"spq": "application/scvp-vp-request",
|
|
485
|
+
"spx": "audio/ogg",
|
|
486
|
+
"sql": "application/sql",
|
|
487
|
+
"sru": "application/sru+xml",
|
|
488
|
+
"srx": "application/sparql-results+xml",
|
|
489
|
+
"ssdl": "application/ssdl+xml",
|
|
490
|
+
"ssml": "application/ssml+xml",
|
|
491
|
+
"stk": "application/hyperstudio",
|
|
492
|
+
"stl": "model/stl",
|
|
493
|
+
"stpx": "model/step+xml",
|
|
494
|
+
"stpxz": "model/step-xml+zip",
|
|
495
|
+
"stpz": "model/step+zip",
|
|
496
|
+
"styl": "text/stylus",
|
|
497
|
+
"stylus": "text/stylus",
|
|
498
|
+
"svg": "image/svg+xml",
|
|
499
|
+
"svgz": "image/svg+xml",
|
|
500
|
+
"swidtag": "application/swid+xml",
|
|
501
|
+
"t": "text/troff",
|
|
502
|
+
"t38": "image/t38",
|
|
503
|
+
"td": "application/urc-targetdesc+xml",
|
|
504
|
+
"tei": "application/tei+xml",
|
|
505
|
+
"teicorpus": "application/tei+xml",
|
|
506
|
+
"text": "text/plain",
|
|
507
|
+
"tfi": "application/thraud+xml",
|
|
508
|
+
"tfx": "image/tiff-fx",
|
|
509
|
+
"tif": "image/tiff",
|
|
510
|
+
"tiff": "image/tiff",
|
|
511
|
+
"toml": "application/toml",
|
|
512
|
+
"tr": "text/troff",
|
|
513
|
+
"trig": "application/trig",
|
|
514
|
+
"ts": "video/mp2t",
|
|
515
|
+
"tsd": "application/timestamped-data",
|
|
516
|
+
"tsv": "text/tab-separated-values",
|
|
517
|
+
"ttc": "font/collection",
|
|
518
|
+
"ttf": "font/ttf",
|
|
519
|
+
"ttl": "text/turtle",
|
|
520
|
+
"ttml": "application/ttml+xml",
|
|
521
|
+
"txt": "text/plain",
|
|
522
|
+
"u3d": "model/u3d",
|
|
523
|
+
"u8dsn": "message/global-delivery-status",
|
|
524
|
+
"u8hdr": "message/global-headers",
|
|
525
|
+
"u8mdn": "message/global-disposition-notification",
|
|
526
|
+
"u8msg": "message/global",
|
|
527
|
+
"ubj": "application/ubjson",
|
|
528
|
+
"uri": "text/uri-list",
|
|
529
|
+
"uris": "text/uri-list",
|
|
530
|
+
"urls": "text/uri-list",
|
|
531
|
+
"vcard": "text/vcard",
|
|
532
|
+
"vrml": "model/vrml",
|
|
533
|
+
"vtt": "text/vtt",
|
|
534
|
+
"vxml": "application/voicexml+xml",
|
|
535
|
+
"war": "application/java-archive",
|
|
536
|
+
"wasm": "application/wasm",
|
|
537
|
+
"wav": "audio/wav",
|
|
538
|
+
"weba": "audio/webm",
|
|
539
|
+
"webm": "video/webm",
|
|
540
|
+
"webmanifest": "application/manifest+json",
|
|
541
|
+
"webp": "image/webp",
|
|
542
|
+
"wgsl": "text/wgsl",
|
|
543
|
+
"wgt": "application/widget",
|
|
544
|
+
"wif": "application/watcherinfo+xml",
|
|
545
|
+
"wmf": "image/wmf",
|
|
546
|
+
"woff": "font/woff",
|
|
547
|
+
"woff2": "font/woff2",
|
|
548
|
+
"wrl": "model/vrml",
|
|
549
|
+
"wsdl": "application/wsdl+xml",
|
|
550
|
+
"wspolicy": "application/wspolicy+xml",
|
|
551
|
+
"x3d": "model/x3d+xml",
|
|
552
|
+
"x3db": "model/x3d+fastinfoset",
|
|
553
|
+
"x3dbz": "model/x3d+binary",
|
|
554
|
+
"x3dv": "model/x3d-vrml",
|
|
555
|
+
"x3dvz": "model/x3d+vrml",
|
|
556
|
+
"x3dz": "model/x3d+xml",
|
|
557
|
+
"xaml": "application/xaml+xml",
|
|
558
|
+
"xav": "application/xcap-att+xml",
|
|
559
|
+
"xca": "application/xcap-caps+xml",
|
|
560
|
+
"xcs": "application/calendar+xml",
|
|
561
|
+
"xdf": "application/xcap-diff+xml",
|
|
562
|
+
"xdssc": "application/dssc+xml",
|
|
563
|
+
"xel": "application/xcap-el+xml",
|
|
564
|
+
"xenc": "application/xenc+xml",
|
|
565
|
+
"xer": "application/patch-ops-error+xml",
|
|
566
|
+
"xfdf": "application/xfdf",
|
|
567
|
+
"xht": "application/xhtml+xml",
|
|
568
|
+
"xhtml": "application/xhtml+xml",
|
|
569
|
+
"xhvml": "application/xv+xml",
|
|
570
|
+
"xlf": "application/xliff+xml",
|
|
571
|
+
"xm": "audio/xm",
|
|
572
|
+
"xml": "text/xml",
|
|
573
|
+
"xns": "application/xcap-ns+xml",
|
|
574
|
+
"xop": "application/xop+xml",
|
|
575
|
+
"xpl": "application/xproc+xml",
|
|
576
|
+
"xsd": "application/xml",
|
|
577
|
+
"xsf": "application/prs.xsf+xml",
|
|
578
|
+
"xsl": "application/xml",
|
|
579
|
+
"xslt": "application/xml",
|
|
580
|
+
"xspf": "application/xspf+xml",
|
|
581
|
+
"xvm": "application/xv+xml",
|
|
582
|
+
"xvml": "application/xv+xml",
|
|
583
|
+
"yaml": "text/yaml",
|
|
584
|
+
"yang": "application/yang",
|
|
585
|
+
"yin": "application/yin+xml",
|
|
586
|
+
"yml": "text/yaml",
|
|
587
|
+
"zip": "application/zip"
|
|
588
|
+
};
|
|
589
|
+
function lookup(extn) {
|
|
590
|
+
let tmp = ("" + extn).trim().toLowerCase();
|
|
591
|
+
let idx = tmp.lastIndexOf(".");
|
|
592
|
+
return mimes[!~idx ? tmp : tmp.substring(++idx)];
|
|
593
|
+
}
|
|
594
|
+
__name(lookup, "lookup");
|
|
595
|
+
exports.mimes = mimes;
|
|
596
|
+
exports.lookup = lookup;
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
// ../../node_modules/sirv/build.js
|
|
601
|
+
var require_build2 = __commonJS({
|
|
602
|
+
"../../node_modules/sirv/build.js"(exports, module) {
|
|
603
|
+
var fs = __require("fs");
|
|
604
|
+
var { join: join2, normalize, resolve } = __require("path");
|
|
605
|
+
var { totalist } = require_sync();
|
|
606
|
+
var { parse: parse2 } = require_build();
|
|
607
|
+
var { lookup } = require_mrmime();
|
|
608
|
+
var noop = /* @__PURE__ */ __name(() => {
|
|
609
|
+
}, "noop");
|
|
610
|
+
function isMatch(uri, arr) {
|
|
611
|
+
for (let i = 0; i < arr.length; i++) {
|
|
612
|
+
if (arr[i].test(uri)) return true;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
__name(isMatch, "isMatch");
|
|
616
|
+
function toAssume(uri, extns) {
|
|
617
|
+
let i = 0, x, len = uri.length - 1;
|
|
618
|
+
if (uri.charCodeAt(len) === 47) {
|
|
619
|
+
uri = uri.substring(0, len);
|
|
620
|
+
}
|
|
621
|
+
let arr = [], tmp = `${uri}/index`;
|
|
622
|
+
for (; i < extns.length; i++) {
|
|
623
|
+
x = extns[i] ? `.${extns[i]}` : "";
|
|
624
|
+
if (uri) arr.push(uri + x);
|
|
625
|
+
arr.push(tmp + x);
|
|
626
|
+
}
|
|
627
|
+
return arr;
|
|
628
|
+
}
|
|
629
|
+
__name(toAssume, "toAssume");
|
|
630
|
+
function viaCache(cache, uri, extns) {
|
|
631
|
+
let i = 0, data, arr = toAssume(uri, extns);
|
|
632
|
+
for (; i < arr.length; i++) {
|
|
633
|
+
if (data = cache[arr[i]]) return data;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
__name(viaCache, "viaCache");
|
|
637
|
+
function viaLocal(dir, isEtag, uri, extns) {
|
|
638
|
+
let i = 0, arr = toAssume(uri, extns);
|
|
639
|
+
let abs, stats, name, headers;
|
|
640
|
+
for (; i < arr.length; i++) {
|
|
641
|
+
abs = normalize(join2(dir, name = arr[i]));
|
|
642
|
+
if (abs.startsWith(dir) && fs.existsSync(abs)) {
|
|
643
|
+
stats = fs.statSync(abs);
|
|
644
|
+
if (stats.isDirectory()) continue;
|
|
645
|
+
headers = toHeaders(name, stats, isEtag);
|
|
646
|
+
headers["Cache-Control"] = isEtag ? "no-cache" : "no-store";
|
|
647
|
+
return { abs, stats, headers };
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
__name(viaLocal, "viaLocal");
|
|
652
|
+
function is404(req, res) {
|
|
653
|
+
return res.statusCode = 404, res.end();
|
|
654
|
+
}
|
|
655
|
+
__name(is404, "is404");
|
|
656
|
+
function send(req, res, file, stats, headers) {
|
|
657
|
+
let code = 200, tmp, opts = {};
|
|
658
|
+
headers = { ...headers };
|
|
659
|
+
for (let key in headers) {
|
|
660
|
+
tmp = res.getHeader(key);
|
|
661
|
+
if (tmp) headers[key] = tmp;
|
|
662
|
+
}
|
|
663
|
+
if (tmp = res.getHeader("content-type")) {
|
|
664
|
+
headers["Content-Type"] = tmp;
|
|
665
|
+
}
|
|
666
|
+
if (req.headers.range) {
|
|
667
|
+
code = 206;
|
|
668
|
+
let [x, y] = req.headers.range.replace("bytes=", "").split("-");
|
|
669
|
+
let end = opts.end = parseInt(y, 10) || stats.size - 1;
|
|
670
|
+
let start2 = opts.start = parseInt(x, 10) || 0;
|
|
671
|
+
if (end >= stats.size) {
|
|
672
|
+
end = stats.size - 1;
|
|
673
|
+
}
|
|
674
|
+
if (start2 >= stats.size) {
|
|
675
|
+
res.setHeader("Content-Range", `bytes */${stats.size}`);
|
|
676
|
+
res.statusCode = 416;
|
|
677
|
+
return res.end();
|
|
678
|
+
}
|
|
679
|
+
headers["Content-Range"] = `bytes ${start2}-${end}/${stats.size}`;
|
|
680
|
+
headers["Content-Length"] = end - start2 + 1;
|
|
681
|
+
headers["Accept-Ranges"] = "bytes";
|
|
682
|
+
}
|
|
683
|
+
res.writeHead(code, headers);
|
|
684
|
+
fs.createReadStream(file, opts).pipe(res);
|
|
685
|
+
}
|
|
686
|
+
__name(send, "send");
|
|
687
|
+
var ENCODING = {
|
|
688
|
+
".br": "br",
|
|
689
|
+
".gz": "gzip"
|
|
690
|
+
};
|
|
691
|
+
function toHeaders(name, stats, isEtag) {
|
|
692
|
+
let enc = ENCODING[name.slice(-3)];
|
|
693
|
+
let ctype = lookup(name.slice(0, enc && -3)) || "";
|
|
694
|
+
if (ctype === "text/html") ctype += ";charset=utf-8";
|
|
695
|
+
let headers = {
|
|
696
|
+
"Content-Length": stats.size,
|
|
697
|
+
"Content-Type": ctype,
|
|
698
|
+
"Last-Modified": stats.mtime.toUTCString()
|
|
699
|
+
};
|
|
700
|
+
if (enc) headers["Content-Encoding"] = enc;
|
|
701
|
+
if (isEtag) headers["ETag"] = `W/"${stats.size}-${stats.mtime.getTime()}"`;
|
|
702
|
+
return headers;
|
|
703
|
+
}
|
|
704
|
+
__name(toHeaders, "toHeaders");
|
|
705
|
+
module.exports = function(dir, opts = {}) {
|
|
706
|
+
dir = resolve(dir || ".");
|
|
707
|
+
let isNotFound = opts.onNoMatch || is404;
|
|
708
|
+
let setHeaders = opts.setHeaders || noop;
|
|
709
|
+
let extensions = opts.extensions || ["html", "htm"];
|
|
710
|
+
let gzips = opts.gzip && extensions.map((x) => `${x}.gz`).concat("gz");
|
|
711
|
+
let brots = opts.brotli && extensions.map((x) => `${x}.br`).concat("br");
|
|
712
|
+
const FILES = {};
|
|
713
|
+
let fallback = "/";
|
|
714
|
+
let isEtag = !!opts.etag;
|
|
715
|
+
let isSPA = !!opts.single;
|
|
716
|
+
if (typeof opts.single === "string") {
|
|
717
|
+
let idx = opts.single.lastIndexOf(".");
|
|
718
|
+
fallback += !!~idx ? opts.single.substring(0, idx) : opts.single;
|
|
719
|
+
}
|
|
720
|
+
let ignores = [];
|
|
721
|
+
if (opts.ignores !== false) {
|
|
722
|
+
ignores.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/);
|
|
723
|
+
if (opts.dotfiles) ignores.push(/\/\.\w/);
|
|
724
|
+
else ignores.push(/\/\.well-known/);
|
|
725
|
+
[].concat(opts.ignores || []).forEach((x) => {
|
|
726
|
+
ignores.push(new RegExp(x, "i"));
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
let cc = opts.maxAge != null && `public,max-age=${opts.maxAge}`;
|
|
730
|
+
if (cc && opts.immutable) cc += ",immutable";
|
|
731
|
+
else if (cc && opts.maxAge === 0) cc += ",must-revalidate";
|
|
732
|
+
if (!opts.dev) {
|
|
733
|
+
totalist(dir, (name, abs, stats) => {
|
|
734
|
+
if (/\.well-known[\\+\/]/.test(name)) {
|
|
735
|
+
} else if (!opts.dotfiles && /(^\.|[\\+|\/+]\.)/.test(name)) return;
|
|
736
|
+
let headers = toHeaders(name, stats, isEtag);
|
|
737
|
+
if (cc) headers["Cache-Control"] = cc;
|
|
738
|
+
FILES["/" + name.normalize().replace(/\\+/g, "/")] = { abs, stats, headers };
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
let lookup2 = opts.dev ? viaLocal.bind(0, dir, isEtag) : viaCache.bind(0, FILES);
|
|
742
|
+
return function(req, res, next) {
|
|
743
|
+
let extns = [""];
|
|
744
|
+
let pathname = parse2(req).pathname;
|
|
745
|
+
let val = req.headers["accept-encoding"] || "";
|
|
746
|
+
if (gzips && val.includes("gzip")) extns.unshift(...gzips);
|
|
747
|
+
if (brots && /(br|brotli)/i.test(val)) extns.unshift(...brots);
|
|
748
|
+
extns.push(...extensions);
|
|
749
|
+
if (pathname.indexOf("%") !== -1) {
|
|
750
|
+
try {
|
|
751
|
+
pathname = decodeURI(pathname);
|
|
752
|
+
} catch (err) {
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
let data = lookup2(pathname, extns) || isSPA && !isMatch(pathname, ignores) && lookup2(fallback, extns);
|
|
756
|
+
if (!data) return next ? next() : isNotFound(req, res);
|
|
757
|
+
if (isEtag && req.headers["if-none-match"] === data.headers["ETag"]) {
|
|
758
|
+
res.writeHead(304);
|
|
759
|
+
return res.end();
|
|
760
|
+
}
|
|
761
|
+
if (gzips || brots) {
|
|
762
|
+
res.setHeader("Vary", "Accept-Encoding");
|
|
763
|
+
}
|
|
764
|
+
setHeaders(res, pathname, data.stats);
|
|
765
|
+
send(req, res, data.abs, data.stats, data.headers);
|
|
766
|
+
};
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
// src/index.ts
|
|
772
|
+
var import_pretty_hrtime = __toESM(require_pretty_hrtime(), 1);
|
|
773
|
+
var import_sirv = __toESM(require_build2(), 1);
|
|
774
|
+
import { cp } from "node:fs/promises";
|
|
775
|
+
import { dirname, join, parse } from "node:path";
|
|
776
|
+
import { fileURLToPath } from "node:url";
|
|
777
|
+
import { PREVIEW_BUILDER_PROGRESS } from "storybook/internal/core-events";
|
|
778
|
+
import { logger } from "storybook/internal/node-logger";
|
|
779
|
+
import {
|
|
780
|
+
WebpackCompilationError,
|
|
781
|
+
WebpackInvocationError,
|
|
782
|
+
WebpackMissingStatsError
|
|
783
|
+
} from "storybook/internal/server-errors";
|
|
784
|
+
import { checkWebpackVersion } from "@storybook/core-webpack";
|
|
785
|
+
import webpackModule from "webpack";
|
|
786
|
+
import webpackDevMiddleware from "webpack-dev-middleware";
|
|
787
|
+
import webpackHotMiddleware from "webpack-hot-middleware";
|
|
788
|
+
var { DefinePlugin, IgnorePlugin, ProgressPlugin } = webpackModule;
|
|
789
|
+
var WebpackDefinePlugin = DefinePlugin;
|
|
790
|
+
var WebpackIgnorePlugin = IgnorePlugin;
|
|
791
|
+
var printDuration = /* @__PURE__ */ __name((startTime) => (0, import_pretty_hrtime.default)(process.hrtime(startTime)).replace(" ms", " milliseconds").replace(" s", " seconds").replace(" min", " minutes"), "printDuration");
|
|
792
|
+
var corePath = dirname(fileURLToPath(import.meta.resolve("storybook/package.json")));
|
|
793
|
+
var compilation;
|
|
794
|
+
var reject;
|
|
795
|
+
var executor = {
|
|
796
|
+
get: /* @__PURE__ */ __name(async (options) => {
|
|
797
|
+
const version = await options.presets.apply("webpackVersion") || "5";
|
|
798
|
+
const webpackInstance = (await options.presets.apply("webpackInstance"))?.default || webpackModule;
|
|
799
|
+
checkWebpackVersion({ version }, "5", "builder-webpack5");
|
|
800
|
+
return webpackInstance;
|
|
801
|
+
}, "get")
|
|
802
|
+
};
|
|
803
|
+
var getConfig = /* @__PURE__ */ __name(async (options) => {
|
|
804
|
+
const { presets } = options;
|
|
805
|
+
const typescriptOptions = await presets.apply("typescript", {}, options);
|
|
806
|
+
const frameworkOptions = await presets.apply("frameworkOptions");
|
|
807
|
+
return presets.apply(
|
|
808
|
+
"webpack",
|
|
809
|
+
{},
|
|
810
|
+
{
|
|
811
|
+
...options,
|
|
812
|
+
typescriptOptions,
|
|
813
|
+
frameworkOptions
|
|
814
|
+
}
|
|
815
|
+
);
|
|
816
|
+
}, "getConfig");
|
|
817
|
+
var asyncIterator;
|
|
818
|
+
var bail = /* @__PURE__ */ __name(async () => {
|
|
819
|
+
if (asyncIterator) {
|
|
820
|
+
try {
|
|
821
|
+
await asyncIterator.throw(new Error());
|
|
822
|
+
} catch (e) {
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
if (reject) {
|
|
826
|
+
reject();
|
|
827
|
+
}
|
|
828
|
+
return new Promise((res, rej) => {
|
|
829
|
+
if (process && compilation) {
|
|
830
|
+
try {
|
|
831
|
+
compilation.close(() => res());
|
|
832
|
+
logger.warn("Force closed preview build");
|
|
833
|
+
} catch (err) {
|
|
834
|
+
logger.warn("Unable to close preview build!");
|
|
835
|
+
res();
|
|
836
|
+
}
|
|
837
|
+
} else {
|
|
838
|
+
res();
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
}, "bail");
|
|
842
|
+
var starter = /* @__PURE__ */ __name(async function* starterGeneratorFn({
|
|
843
|
+
startTime,
|
|
844
|
+
options,
|
|
845
|
+
router,
|
|
846
|
+
channel
|
|
847
|
+
}) {
|
|
848
|
+
const webpackInstance = await executor.get(options);
|
|
849
|
+
yield;
|
|
850
|
+
const config = await getConfig(options);
|
|
851
|
+
if (config.stats === "none" || config.stats === "summary") {
|
|
852
|
+
throw new WebpackMissingStatsError();
|
|
853
|
+
}
|
|
854
|
+
yield;
|
|
855
|
+
const compiler = webpackInstance(config);
|
|
856
|
+
if (!compiler) {
|
|
857
|
+
throw new WebpackInvocationError({
|
|
858
|
+
// eslint-disable-next-line local-rules/no-uncategorized-errors
|
|
859
|
+
error: new Error(`Missing Webpack compiler at runtime!`)
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
yield;
|
|
863
|
+
const modulesCount = await options.cache?.get("modulesCount", 1e3);
|
|
864
|
+
let totalModules;
|
|
865
|
+
let value = 0;
|
|
866
|
+
new ProgressPlugin({
|
|
867
|
+
handler: /* @__PURE__ */ __name((newValue, message, arg3) => {
|
|
868
|
+
value = Math.max(newValue, value);
|
|
869
|
+
const progress = { value, message: message.charAt(0).toUpperCase() + message.slice(1) };
|
|
870
|
+
if (message === "building") {
|
|
871
|
+
const counts = arg3 && arg3.match(/entries (\d+)\/(\d+)/) || [];
|
|
872
|
+
const complete = parseInt(counts[1], 10);
|
|
873
|
+
const total = parseInt(counts[2], 10);
|
|
874
|
+
if (!Number.isNaN(complete) && !Number.isNaN(total)) {
|
|
875
|
+
progress.modules = { complete, total };
|
|
876
|
+
totalModules = total;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
if (value === 1) {
|
|
880
|
+
if (options.cache) {
|
|
881
|
+
options.cache.set("modulesCount", totalModules);
|
|
882
|
+
}
|
|
883
|
+
if (!progress.message) {
|
|
884
|
+
progress.message = `Completed in ${printDuration(startTime)}.`;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
channel.emit(PREVIEW_BUILDER_PROGRESS, progress);
|
|
888
|
+
}, "handler"),
|
|
889
|
+
modulesCount
|
|
890
|
+
}).apply(compiler);
|
|
891
|
+
const middlewareOptions = {
|
|
892
|
+
publicPath: config.output?.publicPath,
|
|
893
|
+
writeToDisk: true,
|
|
894
|
+
stats: "errors-only"
|
|
895
|
+
};
|
|
896
|
+
compilation = webpackDevMiddleware(compiler, middlewareOptions);
|
|
897
|
+
const previewResolvedDir = join(corePath, "dist/preview");
|
|
898
|
+
router.use(
|
|
899
|
+
"/sb-preview",
|
|
900
|
+
(0, import_sirv.default)(previewResolvedDir, {
|
|
901
|
+
maxAge: 3e5,
|
|
902
|
+
dev: true,
|
|
903
|
+
immutable: true
|
|
904
|
+
})
|
|
905
|
+
);
|
|
906
|
+
router.use(compilation);
|
|
907
|
+
router.use(webpackHotMiddleware(compiler, { log: false }));
|
|
908
|
+
const stats = await new Promise((res, rej) => {
|
|
909
|
+
compilation?.waitUntilValid(res);
|
|
910
|
+
reject = rej;
|
|
911
|
+
});
|
|
912
|
+
yield;
|
|
913
|
+
if (!stats) {
|
|
914
|
+
throw new WebpackMissingStatsError();
|
|
915
|
+
}
|
|
916
|
+
const { warnings, errors } = getWebpackStats({ config, stats });
|
|
917
|
+
if (warnings.length > 0) {
|
|
918
|
+
warnings?.forEach((e) => logger.warn(e.message));
|
|
919
|
+
}
|
|
920
|
+
if (errors.length > 0) {
|
|
921
|
+
throw new WebpackCompilationError({ errors });
|
|
922
|
+
}
|
|
923
|
+
return {
|
|
924
|
+
bail,
|
|
925
|
+
stats,
|
|
926
|
+
totalTime: process.hrtime(startTime)
|
|
927
|
+
};
|
|
928
|
+
}, "starterGeneratorFn");
|
|
929
|
+
function getWebpackStats({ config, stats }) {
|
|
930
|
+
const statsOptions = typeof config.stats === "string" ? config.stats : {
|
|
931
|
+
...config.stats,
|
|
932
|
+
warnings: true,
|
|
933
|
+
errors: true
|
|
934
|
+
};
|
|
935
|
+
const { warnings = [], errors = [] } = stats?.toJson(statsOptions) || {};
|
|
936
|
+
return {
|
|
937
|
+
warnings,
|
|
938
|
+
errors
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
__name(getWebpackStats, "getWebpackStats");
|
|
942
|
+
var builder = /* @__PURE__ */ __name(async function* builderGeneratorFn({ startTime, options }) {
|
|
943
|
+
const webpackInstance = await executor.get(options);
|
|
944
|
+
yield;
|
|
945
|
+
const config = await getConfig(options);
|
|
946
|
+
if (config.stats === "none" || config.stats === "summary") {
|
|
947
|
+
throw new WebpackMissingStatsError();
|
|
948
|
+
}
|
|
949
|
+
yield;
|
|
950
|
+
const compiler = webpackInstance(config);
|
|
951
|
+
if (!compiler) {
|
|
952
|
+
throw new WebpackInvocationError({
|
|
953
|
+
// eslint-disable-next-line local-rules/no-uncategorized-errors
|
|
954
|
+
error: new Error(`Missing Webpack compiler at runtime!`)
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
const webpackCompilation = new Promise((succeed, fail) => {
|
|
958
|
+
compiler.run((error, stats) => {
|
|
959
|
+
if (error) {
|
|
960
|
+
compiler.close(() => fail(new WebpackInvocationError({ error })));
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
if (!stats) {
|
|
964
|
+
throw new WebpackMissingStatsError();
|
|
965
|
+
}
|
|
966
|
+
const { warnings, errors } = getWebpackStats({ config, stats });
|
|
967
|
+
if (warnings.length > 0) {
|
|
968
|
+
warnings?.forEach((e) => logger.warn(e.message));
|
|
969
|
+
}
|
|
970
|
+
if (errors.length > 0) {
|
|
971
|
+
errors.forEach((e) => logger.error(e.message));
|
|
972
|
+
compiler.close(() => fail(new WebpackCompilationError({ errors })));
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
compiler.close((closeErr) => {
|
|
976
|
+
if (closeErr) {
|
|
977
|
+
return fail(new WebpackInvocationError({ error: closeErr }));
|
|
978
|
+
}
|
|
979
|
+
return succeed(stats);
|
|
980
|
+
});
|
|
981
|
+
});
|
|
982
|
+
});
|
|
983
|
+
const previewResolvedDir = join(corePath, "dist/preview");
|
|
984
|
+
const previewDirTarget = join(options.outputDir || "", `sb-preview`);
|
|
985
|
+
const previewFiles = cp(previewResolvedDir, previewDirTarget, {
|
|
986
|
+
filter: /* @__PURE__ */ __name((src) => {
|
|
987
|
+
const { ext } = parse(src);
|
|
988
|
+
if (ext) {
|
|
989
|
+
return ext === ".js";
|
|
990
|
+
}
|
|
991
|
+
return true;
|
|
992
|
+
}, "filter"),
|
|
993
|
+
recursive: true
|
|
994
|
+
});
|
|
995
|
+
const [webpackCompilationOutput] = await Promise.all([webpackCompilation, previewFiles]);
|
|
996
|
+
return webpackCompilationOutput;
|
|
997
|
+
}, "builderGeneratorFn");
|
|
998
|
+
var start = /* @__PURE__ */ __name(async (options) => {
|
|
999
|
+
asyncIterator = starter(options);
|
|
1000
|
+
let result;
|
|
1001
|
+
do {
|
|
1002
|
+
result = await asyncIterator.next();
|
|
1003
|
+
} while (!result.done);
|
|
1004
|
+
return result.value;
|
|
1005
|
+
}, "start");
|
|
1006
|
+
var build = /* @__PURE__ */ __name(async (options) => {
|
|
1007
|
+
asyncIterator = builder(options);
|
|
1008
|
+
let result;
|
|
1009
|
+
do {
|
|
1010
|
+
result = await asyncIterator.next();
|
|
1011
|
+
} while (!result.done);
|
|
1012
|
+
return result.value;
|
|
1013
|
+
}, "build");
|
|
1014
|
+
var corePresets = [
|
|
1015
|
+
import.meta.resolve("@storybook/builder-webpack5/presets/preview-preset")
|
|
1016
|
+
];
|
|
1017
|
+
var overridePresets = [
|
|
1018
|
+
import.meta.resolve("@storybook/builder-webpack5/presets/custom-webpack-preset")
|
|
1019
|
+
];
|
|
1020
|
+
export {
|
|
1021
|
+
WebpackDefinePlugin,
|
|
1022
|
+
WebpackIgnorePlugin,
|
|
1023
|
+
bail,
|
|
1024
|
+
build,
|
|
1025
|
+
corePresets,
|
|
1026
|
+
executor,
|
|
1027
|
+
getConfig,
|
|
1028
|
+
getVirtualModules,
|
|
1029
|
+
overridePresets,
|
|
1030
|
+
printDuration,
|
|
1031
|
+
start
|
|
1032
|
+
};
|