@storybook/addon-vitest 9.2.0-alpha.2 → 10.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/_browser-chunks/chunk-JK72E6FR.js +6 -0
- package/dist/_browser-chunks/chunk-PMYV6BH2.js +76 -0
- package/dist/_node-chunks/chunk-2LKDLHP2.js +91 -0
- package/dist/_node-chunks/chunk-75PF53UG.js +103 -0
- package/dist/_node-chunks/chunk-EZERIZC2.js +481 -0
- package/dist/_node-chunks/chunk-FJO43W6J.js +37 -0
- package/dist/_node-chunks/chunk-HIDBMPI3.js +247 -0
- package/dist/_node-chunks/chunk-MHHQUJAV.js +50 -0
- package/dist/_node-chunks/chunk-MJKNSUFZ.js +295 -0
- package/dist/_node-chunks/chunk-T7EST64K.js +2264 -0
- package/dist/index.js +9 -6
- package/dist/manager.js +955 -8
- package/dist/node/coverage-reporter.js +1898 -4
- package/dist/node/vitest.js +871 -17
- package/dist/postinstall.js +2076 -88
- package/dist/preset.js +615 -35
- package/dist/vitest-plugin/global-setup.js +200 -6
- package/dist/vitest-plugin/index.js +3823 -43
- package/dist/vitest-plugin/setup-file.js +30 -8
- package/dist/vitest-plugin/test-utils.js +102 -8
- package/manager.js +1 -1
- package/package.json +27 -93
- package/preset.js +1 -1
- package/dist/chunk-55WZLVGN.mjs +0 -11
- package/dist/chunk-JKRQGT2U.mjs +0 -10
- package/dist/index.mjs +0 -5
- package/dist/node/coverage-reporter.d.ts +0 -184
- package/dist/node/coverage-reporter.mjs +0 -12
- package/dist/node/vitest.d.ts +0 -2
- package/dist/node/vitest.mjs +0 -19
- package/dist/vitest-plugin/global-setup.d.ts +0 -6
- package/dist/vitest-plugin/global-setup.mjs +0 -13
- package/dist/vitest-plugin/index.mjs +0 -28
- package/dist/vitest-plugin/setup-file.d.ts +0 -14
- package/dist/vitest-plugin/setup-file.mjs +0 -9
- package/dist/vitest-plugin/test-utils.d.ts +0 -20
- package/dist/vitest-plugin/test-utils.mjs +0 -8
- package/manager.mjs +0 -1
- package/postinstall.js +0 -1
- package/postinstall.mjs +0 -1
- package/preset.mjs +0 -1
package/dist/preset.js
CHANGED
|
@@ -1,37 +1,617 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
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 __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});var __commonJS=(cb,mod)=>function(){return mod||(0, cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __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));var require_picocolors=__commonJS({"../../node_modules/picocolors/picocolors.js"(exports,module){var p=process||{},argv=p.argv||[],env=p.env||{},isColorSupported=!(env.NO_COLOR||argv.includes("--no-color"))&&(!!env.FORCE_COLOR||argv.includes("--color")||p.platform==="win32"||(p.stdout||{}).isTTY&&env.TERM!=="dumb"||!!env.CI),formatter=(open,close,replace=open)=>input=>{let string=""+input,index=string.indexOf(close,open.length);return ~index?open+replaceClose(string,close,replace,index)+close:open+string+close},replaceClose=(string,close,replace,index)=>{let result="",cursor=0;do result+=string.substring(cursor,index)+replace,cursor=index+close.length,index=string.indexOf(close,cursor);while(~index);return result+string.substring(cursor)},createColors=(enabled=isColorSupported)=>{let f=enabled?formatter:()=>String;return {isColorSupported:enabled,reset:f("\x1B[0m","\x1B[0m"),bold:f("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:f("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:f("\x1B[3m","\x1B[23m"),underline:f("\x1B[4m","\x1B[24m"),inverse:f("\x1B[7m","\x1B[27m"),hidden:f("\x1B[8m","\x1B[28m"),strikethrough:f("\x1B[9m","\x1B[29m"),black:f("\x1B[30m","\x1B[39m"),red:f("\x1B[31m","\x1B[39m"),green:f("\x1B[32m","\x1B[39m"),yellow:f("\x1B[33m","\x1B[39m"),blue:f("\x1B[34m","\x1B[39m"),magenta:f("\x1B[35m","\x1B[39m"),cyan:f("\x1B[36m","\x1B[39m"),white:f("\x1B[37m","\x1B[39m"),gray:f("\x1B[90m","\x1B[39m"),bgBlack:f("\x1B[40m","\x1B[49m"),bgRed:f("\x1B[41m","\x1B[49m"),bgGreen:f("\x1B[42m","\x1B[49m"),bgYellow:f("\x1B[43m","\x1B[49m"),bgBlue:f("\x1B[44m","\x1B[49m"),bgMagenta:f("\x1B[45m","\x1B[49m"),bgCyan:f("\x1B[46m","\x1B[49m"),bgWhite:f("\x1B[47m","\x1B[49m"),blackBright:f("\x1B[90m","\x1B[39m"),redBright:f("\x1B[91m","\x1B[39m"),greenBright:f("\x1B[92m","\x1B[39m"),yellowBright:f("\x1B[93m","\x1B[39m"),blueBright:f("\x1B[94m","\x1B[39m"),magentaBright:f("\x1B[95m","\x1B[39m"),cyanBright:f("\x1B[96m","\x1B[39m"),whiteBright:f("\x1B[97m","\x1B[39m"),bgBlackBright:f("\x1B[100m","\x1B[49m"),bgRedBright:f("\x1B[101m","\x1B[49m"),bgGreenBright:f("\x1B[102m","\x1B[49m"),bgYellowBright:f("\x1B[103m","\x1B[49m"),bgBlueBright:f("\x1B[104m","\x1B[49m"),bgMagentaBright:f("\x1B[105m","\x1B[49m"),bgCyanBright:f("\x1B[106m","\x1B[49m"),bgWhiteBright:f("\x1B[107m","\x1B[49m")}};module.exports=createColors();module.exports.createColors=createColors;}});var require_windows=__commonJS({"../../node_modules/isexe/windows.js"(exports,module){module.exports=isexe;isexe.sync=sync;var fs=__require("fs");function checkPathExt(path4,options){var pathext=options.pathExt!==void 0?options.pathExt:process.env.PATHEXT;if(!pathext||(pathext=pathext.split(";"),pathext.indexOf("")!==-1))return !0;for(var i=0;i<pathext.length;i++){var p=pathext[i].toLowerCase();if(p&&path4.substr(-p.length).toLowerCase()===p)return !0}return !1}function checkStat(stat,path4,options){return !stat.isSymbolicLink()&&!stat.isFile()?!1:checkPathExt(path4,options)}function isexe(path4,options,cb){fs.stat(path4,function(er,stat){cb(er,er?!1:checkStat(stat,path4,options));});}function sync(path4,options){return checkStat(fs.statSync(path4),path4,options)}}});var require_mode=__commonJS({"../../node_modules/isexe/mode.js"(exports,module){module.exports=isexe;isexe.sync=sync;var fs=__require("fs");function isexe(path4,options,cb){fs.stat(path4,function(er,stat){cb(er,er?!1:checkStat(stat,options));});}function sync(path4,options){return checkStat(fs.statSync(path4),options)}function checkStat(stat,options){return stat.isFile()&&checkMode(stat,options)}function checkMode(stat,options){var mod=stat.mode,uid=stat.uid,gid=stat.gid,myUid=options.uid!==void 0?options.uid:process.getuid&&process.getuid(),myGid=options.gid!==void 0?options.gid:process.getgid&&process.getgid(),u=parseInt("100",8),g=parseInt("010",8),o=parseInt("001",8),ug=u|g,ret=mod&o||mod&g&&gid===myGid||mod&u&&uid===myUid||mod&ug&&myUid===0;return ret}}});var require_isexe=__commonJS({"../../node_modules/isexe/index.js"(exports,module){__require("fs");var core;process.platform==="win32"||global.TESTING_WINDOWS?core=require_windows():core=require_mode();module.exports=isexe;isexe.sync=sync;function isexe(path4,options,cb){if(typeof options=="function"&&(cb=options,options={}),!cb){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(resolve2,reject){isexe(path4,options||{},function(er,is){er?reject(er):resolve2(is);});})}core(path4,options||{},function(er,is){er&&(er.code==="EACCES"||options&&options.ignoreErrors)&&(er=null,is=!1),cb(er,is);});}function sync(path4,options){try{return core.sync(path4,options||{})}catch(er){if(options&&options.ignoreErrors||er.code==="EACCES")return !1;throw er}}}});var require_which=__commonJS({"../../node_modules/which/which.js"(exports,module){var isWindows=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",path4=__require("path"),COLON=isWindows?";":":",isexe=require_isexe(),getNotFoundError=cmd=>Object.assign(new Error(`not found: ${cmd}`),{code:"ENOENT"}),getPathInfo=(cmd,opt)=>{let colon=opt.colon||COLON,pathEnv=cmd.match(/\//)||isWindows&&cmd.match(/\\/)?[""]:[...isWindows?[process.cwd()]:[],...(opt.path||process.env.PATH||"").split(colon)],pathExtExe=isWindows?opt.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",pathExt=isWindows?pathExtExe.split(colon):[""];return isWindows&&cmd.indexOf(".")!==-1&&pathExt[0]!==""&&pathExt.unshift(""),{pathEnv,pathExt,pathExtExe}},which=(cmd,opt,cb)=>{typeof opt=="function"&&(cb=opt,opt={}),opt||(opt={});let{pathEnv,pathExt,pathExtExe}=getPathInfo(cmd,opt),found=[],step=i=>new Promise((resolve2,reject)=>{if(i===pathEnv.length)return opt.all&&found.length?resolve2(found):reject(getNotFoundError(cmd));let ppRaw=pathEnv[i],pathPart=/^".*"$/.test(ppRaw)?ppRaw.slice(1,-1):ppRaw,pCmd=path4.join(pathPart,cmd),p=!pathPart&&/^\.[\\\/]/.test(cmd)?cmd.slice(0,2)+pCmd:pCmd;resolve2(subStep(p,i,0));}),subStep=(p,i,ii)=>new Promise((resolve2,reject)=>{if(ii===pathExt.length)return resolve2(step(i+1));let ext=pathExt[ii];isexe(p+ext,{pathExt:pathExtExe},(er,is)=>{if(!er&&is)if(opt.all)found.push(p+ext);else return resolve2(p+ext);return resolve2(subStep(p,i,ii+1))});});return cb?step(0).then(res=>cb(null,res),cb):step(0)},whichSync=(cmd,opt)=>{opt=opt||{};let{pathEnv,pathExt,pathExtExe}=getPathInfo(cmd,opt),found=[];for(let i=0;i<pathEnv.length;i++){let ppRaw=pathEnv[i],pathPart=/^".*"$/.test(ppRaw)?ppRaw.slice(1,-1):ppRaw,pCmd=path4.join(pathPart,cmd),p=!pathPart&&/^\.[\\\/]/.test(cmd)?cmd.slice(0,2)+pCmd:pCmd;for(let j=0;j<pathExt.length;j++){let cur=p+pathExt[j];try{if(isexe.sync(cur,{pathExt:pathExtExe}))if(opt.all)found.push(cur);else return cur}catch{}}}if(opt.all&&found.length)return found;if(opt.nothrow)return null;throw getNotFoundError(cmd)};module.exports=which;which.sync=whichSync;}});var require_path_key=__commonJS({"../../node_modules/path-key/index.js"(exports,module){var pathKey2=(options={})=>{let environment=options.env||process.env;return (options.platform||process.platform)!=="win32"?"PATH":Object.keys(environment).reverse().find(key=>key.toUpperCase()==="PATH")||"Path"};module.exports=pathKey2;module.exports.default=pathKey2;}});var require_resolveCommand=__commonJS({"../../node_modules/cross-spawn/lib/util/resolveCommand.js"(exports,module){var path4=__require("path"),which=require_which(),getPathKey=require_path_key();function resolveCommandAttempt(parsed,withoutPathExt){let env=parsed.options.env||process.env,cwd=process.cwd(),hasCustomCwd=parsed.options.cwd!=null,shouldSwitchCwd=hasCustomCwd&&process.chdir!==void 0&&!process.chdir.disabled;if(shouldSwitchCwd)try{process.chdir(parsed.options.cwd);}catch{}let resolved;try{resolved=which.sync(parsed.command,{path:env[getPathKey({env})],pathExt:withoutPathExt?path4.delimiter:void 0});}catch{}finally{shouldSwitchCwd&&process.chdir(cwd);}return resolved&&(resolved=path4.resolve(hasCustomCwd?parsed.options.cwd:"",resolved)),resolved}function resolveCommand(parsed){return resolveCommandAttempt(parsed)||resolveCommandAttempt(parsed,!0)}module.exports=resolveCommand;}});var require_escape=__commonJS({"../../node_modules/cross-spawn/lib/util/escape.js"(exports,module){var metaCharsRegExp=/([()\][%!^"`<>&|;, *?])/g;function escapeCommand(arg){return arg=arg.replace(metaCharsRegExp,"^$1"),arg}function escapeArgument(arg,doubleEscapeMetaChars){return arg=`${arg}`,arg=arg.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),arg=arg.replace(/(?=(\\+?)?)\1$/,"$1$1"),arg=`"${arg}"`,arg=arg.replace(metaCharsRegExp,"^$1"),doubleEscapeMetaChars&&(arg=arg.replace(metaCharsRegExp,"^$1")),arg}module.exports.command=escapeCommand;module.exports.argument=escapeArgument;}});var require_shebang_regex=__commonJS({"../../node_modules/shebang-regex/index.js"(exports,module){module.exports=/^#!(.*)/;}});var require_shebang_command=__commonJS({"../../node_modules/shebang-command/index.js"(exports,module){var shebangRegex=require_shebang_regex();module.exports=(string="")=>{let match=string.match(shebangRegex);if(!match)return null;let[path4,argument]=match[0].replace(/#! ?/,"").split(" "),binary=path4.split("/").pop();return binary==="env"?argument:argument?`${binary} ${argument}`:binary};}});var require_readShebang=__commonJS({"../../node_modules/cross-spawn/lib/util/readShebang.js"(exports,module){var fs=__require("fs"),shebangCommand=require_shebang_command();function readShebang(command){let buffer=Buffer.alloc(150),fd;try{fd=fs.openSync(command,"r"),fs.readSync(fd,buffer,0,150,0),fs.closeSync(fd);}catch{}return shebangCommand(buffer.toString())}module.exports=readShebang;}});var require_parse=__commonJS({"../../node_modules/cross-spawn/lib/parse.js"(exports,module){var path4=__require("path"),resolveCommand=require_resolveCommand(),escape=require_escape(),readShebang=require_readShebang(),isWin=process.platform==="win32",isExecutableRegExp=/\.(?:com|exe)$/i,isCmdShimRegExp=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function detectShebang(parsed){parsed.file=resolveCommand(parsed);let shebang=parsed.file&&readShebang(parsed.file);return shebang?(parsed.args.unshift(parsed.file),parsed.command=shebang,resolveCommand(parsed)):parsed.file}function parseNonShell(parsed){if(!isWin)return parsed;let commandFile=detectShebang(parsed),needsShell=!isExecutableRegExp.test(commandFile);if(parsed.options.forceShell||needsShell){let needsDoubleEscapeMetaChars=isCmdShimRegExp.test(commandFile);parsed.command=path4.normalize(parsed.command),parsed.command=escape.command(parsed.command),parsed.args=parsed.args.map(arg=>escape.argument(arg,needsDoubleEscapeMetaChars));let shellCommand=[parsed.command].concat(parsed.args).join(" ");parsed.args=["/d","/s","/c",`"${shellCommand}"`],parsed.command=process.env.comspec||"cmd.exe",parsed.options.windowsVerbatimArguments=!0;}return parsed}function parse2(command,args,options){args&&!Array.isArray(args)&&(options=args,args=null),args=args?args.slice(0):[],options=Object.assign({},options);let parsed={command,args,options,file:void 0,original:{command,args}};return options.shell?parsed:parseNonShell(parsed)}module.exports=parse2;}});var require_enoent=__commonJS({"../../node_modules/cross-spawn/lib/enoent.js"(exports,module){var isWin=process.platform==="win32";function notFoundError(original,syscall){return Object.assign(new Error(`${syscall} ${original.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${syscall} ${original.command}`,path:original.command,spawnargs:original.args})}function hookChildProcess(cp,parsed){if(!isWin)return;let originalEmit=cp.emit;cp.emit=function(name,arg1){if(name==="exit"){let err=verifyENOENT(arg1,parsed);if(err)return originalEmit.call(cp,"error",err)}return originalEmit.apply(cp,arguments)};}function verifyENOENT(status,parsed){return isWin&&status===1&&!parsed.file?notFoundError(parsed.original,"spawn"):null}function verifyENOENTSync(status,parsed){return isWin&&status===1&&!parsed.file?notFoundError(parsed.original,"spawnSync"):null}module.exports={hookChildProcess,verifyENOENT,verifyENOENTSync,notFoundError};}});var require_cross_spawn=__commonJS({"../../node_modules/cross-spawn/index.js"(exports,module){var cp=__require("child_process"),parse2=require_parse(),enoent=require_enoent();function spawn(command,args,options){let parsed=parse2(command,args,options),spawned=cp.spawn(parsed.command,parsed.args,parsed.options);return enoent.hookChildProcess(spawned,parsed),spawned}function spawnSync(command,args,options){let parsed=parse2(command,args,options),result=cp.spawnSync(parsed.command,parsed.args,parsed.options);return result.error=result.error||enoent.verifyENOENTSync(result.status,parsed),result}module.exports=spawn;module.exports.spawn=spawn;module.exports.sync=spawnSync;module.exports._parse=parse2;module.exports._enoent=enoent;}});var require_merge_stream=__commonJS({"../../node_modules/merge-stream/index.js"(exports,module){var{PassThrough}=__require("stream");module.exports=function(){var sources=[],output=new PassThrough({objectMode:!0});return output.setMaxListeners(0),output.add=add,output.isEmpty=isEmpty,output.on("unpipe",remove),Array.prototype.slice.call(arguments).forEach(add),output;function add(source){return Array.isArray(source)?(source.forEach(add),this):(sources.push(source),source.once("end",remove.bind(null,source)),source.once("error",output.emit.bind(output,"error")),source.pipe(output,{end:!1}),this)}function isEmpty(){return sources.length==0}function remove(source){sources=sources.filter(function(it){return it!==source}),!sources.length&&output.readable&&output.end();}};}});function noop(){}function getSymbols(object){return Object.getOwnPropertySymbols(object).filter(symbol=>Object.prototype.propertyIsEnumerable.call(object,symbol))}function getTag(value){return value==null?value===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(value)}var regexpTag="[object RegExp]",stringTag="[object String]",numberTag="[object Number]",booleanTag="[object Boolean]",argumentsTag="[object Arguments]",symbolTag="[object Symbol]",dateTag="[object Date]",mapTag="[object Map]",setTag="[object Set]",arrayTag="[object Array]",functionTag="[object Function]",arrayBufferTag="[object ArrayBuffer]",objectTag="[object Object]",errorTag="[object Error]",dataViewTag="[object DataView]",uint8ArrayTag="[object Uint8Array]",uint8ClampedArrayTag="[object Uint8ClampedArray]",uint16ArrayTag="[object Uint16Array]",uint32ArrayTag="[object Uint32Array]",bigUint64ArrayTag="[object BigUint64Array]",int8ArrayTag="[object Int8Array]",int16ArrayTag="[object Int16Array]",int32ArrayTag="[object Int32Array]",bigInt64ArrayTag="[object BigInt64Array]",float32ArrayTag="[object Float32Array]",float64ArrayTag="[object Float64Array]";function isPlainObject(value){if(!value||typeof value!="object")return !1;let proto=Object.getPrototypeOf(value);return proto===null||proto===Object.prototype||Object.getPrototypeOf(proto)===null?Object.prototype.toString.call(value)==="[object Object]":!1}function eq(value,other){return value===other||Number.isNaN(value)&&Number.isNaN(other)}function isEqualWith(a,b,areValuesEqual){return isEqualWithImpl(a,b,void 0,void 0,void 0,void 0,areValuesEqual)}function isEqualWithImpl(a,b,property,aParent,bParent,stack,areValuesEqual){let result=areValuesEqual(a,b,property,aParent,bParent,stack);if(result!==void 0)return result;if(typeof a==typeof b)switch(typeof a){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return a===b;case"number":return a===b||Object.is(a,b);case"function":return a===b;case"object":return areObjectsEqual(a,b,stack,areValuesEqual)}return areObjectsEqual(a,b,stack,areValuesEqual)}function areObjectsEqual(a,b,stack,areValuesEqual){if(Object.is(a,b))return !0;let aTag=getTag(a),bTag=getTag(b);if(aTag===argumentsTag&&(aTag=objectTag),bTag===argumentsTag&&(bTag=objectTag),aTag!==bTag)return !1;switch(aTag){case stringTag:return a.toString()===b.toString();case numberTag:{let x=a.valueOf(),y=b.valueOf();return eq(x,y)}case booleanTag:case dateTag:case symbolTag:return Object.is(a.valueOf(),b.valueOf());case regexpTag:return a.source===b.source&&a.flags===b.flags;case functionTag:return a===b}stack=stack??new Map;let aStack=stack.get(a),bStack=stack.get(b);if(aStack!=null&&bStack!=null)return aStack===b;stack.set(a,b),stack.set(b,a);try{switch(aTag){case mapTag:{if(a.size!==b.size)return !1;for(let[key,value]of a.entries())if(!b.has(key)||!isEqualWithImpl(value,b.get(key),key,a,b,stack,areValuesEqual))return !1;return !0}case setTag:{if(a.size!==b.size)return !1;let aValues=Array.from(a.values()),bValues=Array.from(b.values());for(let i=0;i<aValues.length;i++){let aValue=aValues[i],index=bValues.findIndex(bValue=>isEqualWithImpl(aValue,bValue,void 0,a,b,stack,areValuesEqual));if(index===-1)return !1;bValues.splice(index,1);}return !0}case arrayTag:case uint8ArrayTag:case uint8ClampedArrayTag:case uint16ArrayTag:case uint32ArrayTag:case bigUint64ArrayTag:case int8ArrayTag:case int16ArrayTag:case int32ArrayTag:case bigInt64ArrayTag:case float32ArrayTag:case float64ArrayTag:{if(typeof Buffer<"u"&&Buffer.isBuffer(a)!==Buffer.isBuffer(b)||a.length!==b.length)return !1;for(let i=0;i<a.length;i++)if(!isEqualWithImpl(a[i],b[i],i,a,b,stack,areValuesEqual))return !1;return !0}case arrayBufferTag:return a.byteLength!==b.byteLength?!1:areObjectsEqual(new Uint8Array(a),new Uint8Array(b),stack,areValuesEqual);case dataViewTag:return a.byteLength!==b.byteLength||a.byteOffset!==b.byteOffset?!1:areObjectsEqual(new Uint8Array(a),new Uint8Array(b),stack,areValuesEqual);case errorTag:return a.name===b.name&&a.message===b.message;case objectTag:{if(!(areObjectsEqual(a.constructor,b.constructor,stack,areValuesEqual)||isPlainObject(a)&&isPlainObject(b)))return !1;let aKeys=[...Object.keys(a),...getSymbols(a)],bKeys=[...Object.keys(b),...getSymbols(b)];if(aKeys.length!==bKeys.length)return !1;for(let i=0;i<aKeys.length;i++){let propKey=aKeys[i],aProp=a[propKey];if(!Object.hasOwn(b,propKey))return !1;let bProp=b[propKey];if(!isEqualWithImpl(aProp,bProp,propKey,a,b,stack,areValuesEqual))return !1}return !0}default:return !1}}finally{stack.delete(a),stack.delete(b);}}function isEqual(a,b){return isEqualWith(a,b,noop)}var import_picocolors2=__toESM(require_picocolors());var ADDON_ID2="storybook/test",STORYBOOK_ADDON_TEST_CHANNEL="STORYBOOK_ADDON_TEST_CHANNEL";var COVERAGE_DIRECTORY="coverage";var storeOptions={id:ADDON_ID2,initialState:{config:{coverage:!1,a11y:!1},watching:!1,cancelling:!1,fatalError:void 0,indexUrl:void 0,previewAnnotations:[],currentRun:{triggeredBy:void 0,config:{coverage:!1,a11y:!1},componentTestCount:{success:0,error:0},a11yCount:{success:0,warning:0,error:0},storyIds:void 0,totalTestCount:void 0,startedAt:void 0,finishedAt:void 0,unhandledErrors:[],coverageSummary:void 0}}};var STORE_CHANNEL_EVENT_NAME=`UNIVERSAL_STORE:${storeOptions.id}`,STATUS_STORE_CHANNEL_EVENT_NAME="UNIVERSAL_STORE:storybook/status",TEST_PROVIDER_STORE_CHANNEL_EVENT_NAME="UNIVERSAL_STORE:storybook/test-provider";var import_picocolors=__toESM(require_picocolors());var log=message=>{console.log(`${import_picocolors.default.magenta(ADDON_ID2)}: ${message.toString().trim()}`);};var import_cross_spawn=__toESM(require_cross_spawn(),1);function stripFinalNewline(input){let LF=typeof input=="string"?`
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
`);return isError?(error.originalMessage=error.message,error.message=message):error=new Error(message),error.shortMessage=shortMessage,error.command=command,error.escapedCommand=escapedCommand,error.exitCode=exitCode,error.signal=signal,error.signalDescription=signalDescription,error.stdout=stdout,error.stderr=stderr,error.cwd=cwd,all!==void 0&&(error.all=all),"bufferedData"in error&&delete error.bufferedData,error.failed=!0,error.timedOut=!!timedOut,error.isCanceled=isCanceled,error.killed=killed&&!timedOut,error};var aliases=["stdin","stdout","stderr"],hasAlias=options=>aliases.some(alias=>options[alias]!==void 0),normalizeStdio=options=>{if(!options)return;let{stdio}=options;if(stdio===void 0)return aliases.map(alias=>options[alias]);if(hasAlias(options))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias=>`\`${alias}\``).join(", ")}`);if(typeof stdio=="string")return stdio;if(!Array.isArray(stdio))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);let length=Math.max(stdio.length,aliases.length);return Array.from({length},(value,index)=>stdio[index])},normalizeStdioNode=options=>{let stdio=normalizeStdio(options);return stdio==="ipc"?"ipc":stdio===void 0||typeof stdio=="string"?[stdio,stdio,stdio,"ipc"]:stdio.includes("ipc")?stdio:[...stdio,"ipc"]};var signals=[];signals.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&signals.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&signals.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var processOk=process7=>!!process7&&typeof process7=="object"&&typeof process7.removeListener=="function"&&typeof process7.emit=="function"&&typeof process7.reallyExit=="function"&&typeof process7.listeners=="function"&&typeof process7.kill=="function"&&typeof process7.pid=="number"&&typeof process7.on=="function",kExitEmitter=Symbol.for("signal-exit emitter"),global2=globalThis,ObjectDefineProperty=Object.defineProperty.bind(Object),Emitter=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(global2[kExitEmitter])return global2[kExitEmitter];ObjectDefineProperty(global2,kExitEmitter,{value:this,writable:!1,enumerable:!1,configurable:!1});}on(ev,fn){this.listeners[ev].push(fn);}removeListener(ev,fn){let list=this.listeners[ev],i=list.indexOf(fn);i!==-1&&(i===0&&list.length===1?list.length=0:list.splice(i,1));}emit(ev,code,signal){if(this.emitted[ev])return !1;this.emitted[ev]=!0;let ret=!1;for(let fn of this.listeners[ev])ret=fn(code,signal)===!0||ret;return ev==="exit"&&(ret=this.emit("afterExit",code,signal)||ret),ret}},SignalExitBase=class{},signalExitWrap=handler=>({onExit(cb,opts){return handler.onExit(cb,opts)},load(){return handler.load()},unload(){return handler.unload()}}),SignalExitFallback=class extends SignalExitBase{onExit(){return ()=>{}}load(){}unload(){}},SignalExit=class extends SignalExitBase{#hupSig=process4.platform==="win32"?"SIGINT":"SIGHUP";#emitter=new Emitter;#process;#originalProcessEmit;#originalProcessReallyExit;#sigListeners={};#loaded=!1;constructor(process7){super(),this.#process=process7,this.#sigListeners={};for(let sig of signals)this.#sigListeners[sig]=()=>{let listeners=this.#process.listeners(sig),{count}=this.#emitter,p=process7;if(typeof p.__signal_exit_emitter__=="object"&&typeof p.__signal_exit_emitter__.count=="number"&&(count+=p.__signal_exit_emitter__.count),listeners.length===count){this.unload();let ret=this.#emitter.emit("exit",null,sig),s=sig==="SIGHUP"?this.#hupSig:sig;ret||process7.kill(process7.pid,s);}};this.#originalProcessReallyExit=process7.reallyExit,this.#originalProcessEmit=process7.emit;}onExit(cb,opts){if(!processOk(this.#process))return ()=>{};this.#loaded===!1&&this.load();let ev=opts?.alwaysLast?"afterExit":"exit";return this.#emitter.on(ev,cb),()=>{this.#emitter.removeListener(ev,cb),this.#emitter.listeners.exit.length===0&&this.#emitter.listeners.afterExit.length===0&&this.unload();}}load(){if(!this.#loaded){this.#loaded=!0,this.#emitter.count+=1;for(let sig of signals)try{let fn=this.#sigListeners[sig];fn&&this.#process.on(sig,fn);}catch{}this.#process.emit=(ev,...a)=>this.#processEmit(ev,...a),this.#process.reallyExit=code=>this.#processReallyExit(code);}}unload(){this.#loaded&&(this.#loaded=!1,signals.forEach(sig=>{let listener=this.#sigListeners[sig];if(!listener)throw new Error("Listener not defined for signal: "+sig);try{this.#process.removeListener(sig,listener);}catch{}}),this.#process.emit=this.#originalProcessEmit,this.#process.reallyExit=this.#originalProcessReallyExit,this.#emitter.count-=1);}#processReallyExit(code){return processOk(this.#process)?(this.#process.exitCode=code||0,this.#emitter.emit("exit",this.#process.exitCode,null),this.#originalProcessReallyExit.call(this.#process,this.#process.exitCode)):0}#processEmit(ev,...args){let og=this.#originalProcessEmit;if(ev==="exit"&&processOk(this.#process)){typeof args[0]=="number"&&(this.#process.exitCode=args[0]);let ret=og.call(this.#process,ev,...args);return this.#emitter.emit("exit",this.#process.exitCode,null),ret}else return og.call(this.#process,ev,...args)}},process4=globalThis.process,{onExit,load,unload}=signalExitWrap(processOk(process4)?new SignalExit(process4):new SignalExitFallback);var DEFAULT_FORCE_KILL_TIMEOUT=1e3*5,spawnedKill=(kill,signal="SIGTERM",options={})=>{let killResult=kill(signal);return setKillTimeout(kill,signal,options,killResult),killResult},setKillTimeout=(kill,signal,options,killResult)=>{if(!shouldForceKill(signal,options,killResult))return;let timeout=getForceKillAfterTimeout(options),t=setTimeout(()=>{kill("SIGKILL");},timeout);t.unref&&t.unref();},shouldForceKill=(signal,{forceKillAfterTimeout},killResult)=>isSigterm(signal)&&forceKillAfterTimeout!==!1&&killResult,isSigterm=signal=>signal===os__default.default.constants.signals.SIGTERM||typeof signal=="string"&&signal.toUpperCase()==="SIGTERM",getForceKillAfterTimeout=({forceKillAfterTimeout=!0})=>{if(forceKillAfterTimeout===!0)return DEFAULT_FORCE_KILL_TIMEOUT;if(!Number.isFinite(forceKillAfterTimeout)||forceKillAfterTimeout<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);return forceKillAfterTimeout},spawnedCancel=(spawned,context)=>{spawned.kill()&&(context.isCanceled=!0);},timeoutKill=(spawned,signal,reject)=>{spawned.kill(signal),reject(Object.assign(new Error("Timed out"),{timedOut:!0,signal}));},setupTimeout=(spawned,{timeout,killSignal="SIGTERM"},spawnedPromise)=>{if(timeout===0||timeout===void 0)return spawnedPromise;let timeoutId,timeoutPromise=new Promise((resolve2,reject)=>{timeoutId=setTimeout(()=>{timeoutKill(spawned,killSignal,reject);},timeout);}),safeSpawnedPromise=spawnedPromise.finally(()=>{clearTimeout(timeoutId);});return Promise.race([timeoutPromise,safeSpawnedPromise])},validateTimeout=({timeout})=>{if(timeout!==void 0&&(!Number.isFinite(timeout)||timeout<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`)},setExitHandler=async(spawned,{cleanup,detached},timedPromise)=>{if(!cleanup||detached)return timedPromise;let removeExitHandler=onExit(()=>{spawned.kill();});return timedPromise.finally(()=>{removeExitHandler();})};function isStream(stream){return stream!==null&&typeof stream=="object"&&typeof stream.pipe=="function"}function isWritableStream(stream){return isStream(stream)&&stream.writable!==!1&&typeof stream._write=="function"&&typeof stream._writableState=="object"}var isExecaChildProcess=target=>target instanceof childProcess.ChildProcess&&typeof target.then=="function",pipeToTarget=(spawned,streamName,target)=>{if(typeof target=="string")return spawned[streamName].pipe(fs.createWriteStream(target)),spawned;if(isWritableStream(target))return spawned[streamName].pipe(target),spawned;if(!isExecaChildProcess(target))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!isWritableStream(target.stdin))throw new TypeError("The target child process's stdin must be available.");return spawned[streamName].pipe(target.stdin),target},addPipeMethods=spawned=>{spawned.stdout!==null&&(spawned.pipeStdout=pipeToTarget.bind(void 0,spawned,"stdout")),spawned.stderr!==null&&(spawned.pipeStderr=pipeToTarget.bind(void 0,spawned,"stderr")),spawned.all!==void 0&&(spawned.pipeAll=pipeToTarget.bind(void 0,spawned,"all"));};var getStreamContents=async(stream,{init,convertChunk,getSize,truncateChunk,addChunk,getFinalChunk,finalize},{maxBuffer=Number.POSITIVE_INFINITY}={})=>{if(!isAsyncIterable(stream))throw new Error("The first argument must be a Readable, a ReadableStream, or an async iterable.");let state=init();state.length=0;try{for await(let chunk of stream){let chunkType=getChunkType(chunk),convertedChunk=convertChunk[chunkType](chunk,state);appendChunk({convertedChunk,state,getSize,truncateChunk,addChunk,maxBuffer});}return appendFinalChunk({state,convertChunk,getSize,truncateChunk,addChunk,getFinalChunk,maxBuffer}),finalize(state)}catch(error){throw error.bufferedData=finalize(state),error}},appendFinalChunk=({state,getSize,truncateChunk,addChunk,getFinalChunk,maxBuffer})=>{let convertedChunk=getFinalChunk(state);convertedChunk!==void 0&&appendChunk({convertedChunk,state,getSize,truncateChunk,addChunk,maxBuffer});},appendChunk=({convertedChunk,state,getSize,truncateChunk,addChunk,maxBuffer})=>{let chunkSize=getSize(convertedChunk),newLength=state.length+chunkSize;if(newLength<=maxBuffer){addNewChunk(convertedChunk,state,addChunk,newLength);return}let truncatedChunk=truncateChunk(convertedChunk,maxBuffer-state.length);throw truncatedChunk!==void 0&&addNewChunk(truncatedChunk,state,addChunk,maxBuffer),new MaxBufferError},addNewChunk=(convertedChunk,state,addChunk,newLength)=>{state.contents=addChunk(convertedChunk,state,newLength),state.length=newLength;},isAsyncIterable=stream=>typeof stream=="object"&&stream!==null&&typeof stream[Symbol.asyncIterator]=="function",getChunkType=chunk=>{let typeOfChunk=typeof chunk;if(typeOfChunk==="string")return "string";if(typeOfChunk!=="object"||chunk===null)return "others";if(globalThis.Buffer?.isBuffer(chunk))return "buffer";let prototypeName=objectToString.call(chunk);return prototypeName==="[object ArrayBuffer]"?"arrayBuffer":prototypeName==="[object DataView]"?"dataView":Number.isInteger(chunk.byteLength)&&Number.isInteger(chunk.byteOffset)&&objectToString.call(chunk.buffer)==="[object ArrayBuffer]"?"typedArray":"others"},{toString:objectToString}=Object.prototype,MaxBufferError=class extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded");}};var identity=value=>value,noop2=()=>{},getContentsProp=({contents})=>contents,throwObjectStream=chunk=>{throw new Error(`Streams in object mode are not supported: ${String(chunk)}`)},getLengthProp=convertedChunk=>convertedChunk.length;async function getStreamAsArrayBuffer(stream,options){return getStreamContents(stream,arrayBufferMethods,options)}var initArrayBuffer=()=>({contents:new ArrayBuffer(0)}),useTextEncoder=chunk=>textEncoder.encode(chunk),textEncoder=new TextEncoder,useUint8Array=chunk=>new Uint8Array(chunk),useUint8ArrayWithOffset=chunk=>new Uint8Array(chunk.buffer,chunk.byteOffset,chunk.byteLength),truncateArrayBufferChunk=(convertedChunk,chunkSize)=>convertedChunk.slice(0,chunkSize),addArrayBufferChunk=(convertedChunk,{contents,length:previousLength},length)=>{let newContents=hasArrayBufferResize()?resizeArrayBuffer(contents,length):resizeArrayBufferSlow(contents,length);return new Uint8Array(newContents).set(convertedChunk,previousLength),newContents},resizeArrayBufferSlow=(contents,length)=>{if(length<=contents.byteLength)return contents;let arrayBuffer=new ArrayBuffer(getNewContentsLength(length));return new Uint8Array(arrayBuffer).set(new Uint8Array(contents),0),arrayBuffer},resizeArrayBuffer=(contents,length)=>{if(length<=contents.maxByteLength)return contents.resize(length),contents;let arrayBuffer=new ArrayBuffer(length,{maxByteLength:getNewContentsLength(length)});return new Uint8Array(arrayBuffer).set(new Uint8Array(contents),0),arrayBuffer},getNewContentsLength=length=>SCALE_FACTOR**Math.ceil(Math.log(length)/Math.log(SCALE_FACTOR)),SCALE_FACTOR=2,finalizeArrayBuffer=({contents,length})=>hasArrayBufferResize()?contents:contents.slice(0,length),hasArrayBufferResize=()=>"resize"in ArrayBuffer.prototype,arrayBufferMethods={init:initArrayBuffer,convertChunk:{string:useTextEncoder,buffer:useUint8Array,arrayBuffer:useUint8Array,dataView:useUint8ArrayWithOffset,typedArray:useUint8ArrayWithOffset,others:throwObjectStream},getSize:getLengthProp,truncateChunk:truncateArrayBufferChunk,addChunk:addArrayBufferChunk,getFinalChunk:noop2,finalize:finalizeArrayBuffer};async function getStreamAsBuffer(stream,options){if(!("Buffer"in globalThis))throw new Error("getStreamAsBuffer() is only supported in Node.js");try{return arrayBufferToNodeBuffer(await getStreamAsArrayBuffer(stream,options))}catch(error){throw error.bufferedData!==void 0&&(error.bufferedData=arrayBufferToNodeBuffer(error.bufferedData)),error}}var arrayBufferToNodeBuffer=arrayBuffer=>globalThis.Buffer.from(arrayBuffer);async function getStreamAsString(stream,options){return getStreamContents(stream,stringMethods,options)}var initString=()=>({contents:"",textDecoder:new TextDecoder}),useTextDecoder=(chunk,{textDecoder})=>textDecoder.decode(chunk,{stream:!0}),addStringChunk=(convertedChunk,{contents})=>contents+convertedChunk,truncateStringChunk=(convertedChunk,chunkSize)=>convertedChunk.slice(0,chunkSize),getFinalStringChunk=({textDecoder})=>{let finalChunk=textDecoder.decode();return finalChunk===""?void 0:finalChunk},stringMethods={init:initString,convertChunk:{string:identity,buffer:useTextDecoder,arrayBuffer:useTextDecoder,dataView:useTextDecoder,typedArray:useTextDecoder,others:throwObjectStream},getSize:getLengthProp,truncateChunk:truncateStringChunk,addChunk:addStringChunk,getFinalChunk:getFinalStringChunk,finalize:getContentsProp};var import_merge_stream=__toESM(require_merge_stream(),1),validateInputOptions=input=>{if(input!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},getInput=({input,inputFile})=>typeof inputFile!="string"?input:(validateInputOptions(input),fs.createReadStream(inputFile)),handleInput=(spawned,options)=>{let input=getInput(options);input!==void 0&&(isStream(input)?input.pipe(spawned.stdin):spawned.stdin.end(input));},makeAllStream=(spawned,{all})=>{if(!all||!spawned.stdout&&!spawned.stderr)return;let mixed=(0, import_merge_stream.default)();return spawned.stdout&&mixed.add(spawned.stdout),spawned.stderr&&mixed.add(spawned.stderr),mixed},getBufferedData=async(stream,streamPromise)=>{if(!(!stream||streamPromise===void 0)){await promises$1.setTimeout(0),stream.destroy();try{return await streamPromise}catch(error){return error.bufferedData}}},getStreamPromise=(stream,{encoding,buffer,maxBuffer})=>{if(!(!stream||!buffer))return encoding==="utf8"||encoding==="utf-8"?getStreamAsString(stream,{maxBuffer}):encoding===null||encoding==="buffer"?getStreamAsBuffer(stream,{maxBuffer}):applyEncoding(stream,maxBuffer,encoding)},applyEncoding=async(stream,maxBuffer,encoding)=>(await getStreamAsBuffer(stream,{maxBuffer})).toString(encoding),getSpawnedResult=async({stdout,stderr,all},{encoding,buffer,maxBuffer},processDone)=>{let stdoutPromise=getStreamPromise(stdout,{encoding,buffer,maxBuffer}),stderrPromise=getStreamPromise(stderr,{encoding,buffer,maxBuffer}),allPromise=getStreamPromise(all,{encoding,buffer,maxBuffer:maxBuffer*2});try{return await Promise.all([processDone,stdoutPromise,stderrPromise,allPromise])}catch(error){return Promise.all([{error,signal:error.signal,timedOut:error.timedOut},getBufferedData(stdout,stdoutPromise),getBufferedData(stderr,stderrPromise),getBufferedData(all,allPromise)])}};var nativePromisePrototype=(async()=>{})().constructor.prototype,descriptors=["then","catch","finally"].map(property=>[property,Reflect.getOwnPropertyDescriptor(nativePromisePrototype,property)]),mergePromise=(spawned,promise)=>{for(let[property,descriptor]of descriptors){let value=typeof promise=="function"?(...args)=>Reflect.apply(descriptor.value,promise(),args):descriptor.value.bind(promise);Reflect.defineProperty(spawned,property,{...descriptor,value});}},getSpawnedPromise=spawned=>new Promise((resolve2,reject)=>{spawned.on("exit",(exitCode,signal)=>{resolve2({exitCode,signal});}),spawned.on("error",error=>{reject(error);}),spawned.stdin&&spawned.stdin.on("error",error=>{reject(error);});});var normalizeArgs=(file,args=[])=>Array.isArray(args)?[file,...args]:[file],NO_ESCAPE_REGEXP=/^[\w.-]+$/,escapeArg=arg=>typeof arg!="string"||NO_ESCAPE_REGEXP.test(arg)?arg:`"${arg.replaceAll('"','\\"')}"`,joinCommand=(file,args)=>normalizeArgs(file,args).join(" "),getEscapedCommand=(file,args)=>normalizeArgs(file,args).map(arg=>escapeArg(arg)).join(" ");var verboseDefault=util.debuglog("execa").enabled,padField=(field,padding)=>String(field).padStart(padding,"0"),getTimestamp=()=>{let date=new Date;return `${padField(date.getHours(),2)}:${padField(date.getMinutes(),2)}:${padField(date.getSeconds(),2)}.${padField(date.getMilliseconds(),3)}`},logCommand=(escapedCommand,{verbose})=>{verbose&&process6__default.default.stderr.write(`[${getTimestamp()}] ${escapedCommand}
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_nt0sybtpwl from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_nt0sybtpwl from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_nt0sybtpwl from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_nt0sybtpwl.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_nt0sybtpwl.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_nt0sybtpwl.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
log,
|
|
14
|
+
noop
|
|
15
|
+
} from "./_node-chunks/chunk-FJO43W6J.js";
|
|
16
|
+
import {
|
|
17
|
+
execaNode,
|
|
18
|
+
importMetaResolve
|
|
19
|
+
} from "./_node-chunks/chunk-T7EST64K.js";
|
|
20
|
+
import {
|
|
21
|
+
ADDON_ID,
|
|
22
|
+
COVERAGE_DIRECTORY,
|
|
23
|
+
STATUS_STORE_CHANNEL_EVENT_NAME,
|
|
24
|
+
STORE_CHANNEL_EVENT_NAME,
|
|
25
|
+
STORYBOOK_ADDON_TEST_CHANNEL,
|
|
26
|
+
TEST_PROVIDER_STORE_CHANNEL_EVENT_NAME,
|
|
27
|
+
storeOptions
|
|
28
|
+
} from "./_node-chunks/chunk-75PF53UG.js";
|
|
29
|
+
import {
|
|
30
|
+
require_picocolors
|
|
31
|
+
} from "./_node-chunks/chunk-2LKDLHP2.js";
|
|
32
|
+
import {
|
|
33
|
+
normalize
|
|
34
|
+
} from "./_node-chunks/chunk-HIDBMPI3.js";
|
|
35
|
+
import {
|
|
36
|
+
__name,
|
|
37
|
+
__toESM
|
|
38
|
+
} from "./_node-chunks/chunk-MHHQUJAV.js";
|
|
39
|
+
|
|
40
|
+
// src/preset.ts
|
|
41
|
+
import { mkdir } from "node:fs/promises";
|
|
42
|
+
import {
|
|
43
|
+
createFileSystemCache,
|
|
44
|
+
getFrameworkName,
|
|
45
|
+
loadPreviewOrConfigFile,
|
|
46
|
+
resolvePathInStorybookCache
|
|
47
|
+
} from "storybook/internal/common";
|
|
48
|
+
import {
|
|
49
|
+
experimental_UniversalStore,
|
|
50
|
+
experimental_getTestProviderStore
|
|
51
|
+
} from "storybook/internal/core-server";
|
|
52
|
+
import { cleanPaths, oneWayHash, sanitizeError, telemetry } from "storybook/internal/telemetry";
|
|
53
|
+
|
|
54
|
+
// ../../node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
|
|
55
|
+
function isPlainObject(value) {
|
|
56
|
+
if (!value || typeof value !== "object") {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
const proto = Object.getPrototypeOf(value);
|
|
60
|
+
const hasObjectPrototype = proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null;
|
|
61
|
+
if (!hasObjectPrototype) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
65
|
+
}
|
|
66
|
+
__name(isPlainObject, "isPlainObject");
|
|
67
|
+
|
|
68
|
+
// ../../node_modules/es-toolkit/dist/compat/_internal/getSymbols.mjs
|
|
69
|
+
function getSymbols(object) {
|
|
70
|
+
return Object.getOwnPropertySymbols(object).filter((symbol) => Object.prototype.propertyIsEnumerable.call(object, symbol));
|
|
71
|
+
}
|
|
72
|
+
__name(getSymbols, "getSymbols");
|
|
73
|
+
|
|
74
|
+
// ../../node_modules/es-toolkit/dist/compat/_internal/getTag.mjs
|
|
75
|
+
function getTag(value) {
|
|
76
|
+
if (value == null) {
|
|
77
|
+
return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
78
|
+
}
|
|
79
|
+
return Object.prototype.toString.call(value);
|
|
80
|
+
}
|
|
81
|
+
__name(getTag, "getTag");
|
|
32
82
|
|
|
33
|
-
|
|
34
|
-
|
|
83
|
+
// ../../node_modules/es-toolkit/dist/compat/_internal/tags.mjs
|
|
84
|
+
var regexpTag = "[object RegExp]";
|
|
85
|
+
var stringTag = "[object String]";
|
|
86
|
+
var numberTag = "[object Number]";
|
|
87
|
+
var booleanTag = "[object Boolean]";
|
|
88
|
+
var argumentsTag = "[object Arguments]";
|
|
89
|
+
var symbolTag = "[object Symbol]";
|
|
90
|
+
var dateTag = "[object Date]";
|
|
91
|
+
var mapTag = "[object Map]";
|
|
92
|
+
var setTag = "[object Set]";
|
|
93
|
+
var arrayTag = "[object Array]";
|
|
94
|
+
var functionTag = "[object Function]";
|
|
95
|
+
var arrayBufferTag = "[object ArrayBuffer]";
|
|
96
|
+
var objectTag = "[object Object]";
|
|
97
|
+
var errorTag = "[object Error]";
|
|
98
|
+
var dataViewTag = "[object DataView]";
|
|
99
|
+
var uint8ArrayTag = "[object Uint8Array]";
|
|
100
|
+
var uint8ClampedArrayTag = "[object Uint8ClampedArray]";
|
|
101
|
+
var uint16ArrayTag = "[object Uint16Array]";
|
|
102
|
+
var uint32ArrayTag = "[object Uint32Array]";
|
|
103
|
+
var bigUint64ArrayTag = "[object BigUint64Array]";
|
|
104
|
+
var int8ArrayTag = "[object Int8Array]";
|
|
105
|
+
var int16ArrayTag = "[object Int16Array]";
|
|
106
|
+
var int32ArrayTag = "[object Int32Array]";
|
|
107
|
+
var bigInt64ArrayTag = "[object BigInt64Array]";
|
|
108
|
+
var float32ArrayTag = "[object Float32Array]";
|
|
109
|
+
var float64ArrayTag = "[object Float64Array]";
|
|
110
|
+
|
|
111
|
+
// ../../node_modules/es-toolkit/dist/compat/util/eq.mjs
|
|
112
|
+
function eq(value, other) {
|
|
113
|
+
return value === other || Number.isNaN(value) && Number.isNaN(other);
|
|
114
|
+
}
|
|
115
|
+
__name(eq, "eq");
|
|
116
|
+
|
|
117
|
+
// ../../node_modules/es-toolkit/dist/predicate/isEqualWith.mjs
|
|
118
|
+
function isEqualWith(a, b, areValuesEqual) {
|
|
119
|
+
return isEqualWithImpl(a, b, void 0, void 0, void 0, void 0, areValuesEqual);
|
|
120
|
+
}
|
|
121
|
+
__name(isEqualWith, "isEqualWith");
|
|
122
|
+
function isEqualWithImpl(a, b, property, aParent, bParent, stack, areValuesEqual) {
|
|
123
|
+
const result = areValuesEqual(a, b, property, aParent, bParent, stack);
|
|
124
|
+
if (result !== void 0) {
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
if (typeof a === typeof b) {
|
|
128
|
+
switch (typeof a) {
|
|
129
|
+
case "bigint":
|
|
130
|
+
case "string":
|
|
131
|
+
case "boolean":
|
|
132
|
+
case "symbol":
|
|
133
|
+
case "undefined": {
|
|
134
|
+
return a === b;
|
|
135
|
+
}
|
|
136
|
+
case "number": {
|
|
137
|
+
return a === b || Object.is(a, b);
|
|
138
|
+
}
|
|
139
|
+
case "function": {
|
|
140
|
+
return a === b;
|
|
141
|
+
}
|
|
142
|
+
case "object": {
|
|
143
|
+
return areObjectsEqual(a, b, stack, areValuesEqual);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return areObjectsEqual(a, b, stack, areValuesEqual);
|
|
148
|
+
}
|
|
149
|
+
__name(isEqualWithImpl, "isEqualWithImpl");
|
|
150
|
+
function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
151
|
+
if (Object.is(a, b)) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
let aTag = getTag(a);
|
|
155
|
+
let bTag = getTag(b);
|
|
156
|
+
if (aTag === argumentsTag) {
|
|
157
|
+
aTag = objectTag;
|
|
158
|
+
}
|
|
159
|
+
if (bTag === argumentsTag) {
|
|
160
|
+
bTag = objectTag;
|
|
161
|
+
}
|
|
162
|
+
if (aTag !== bTag) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
switch (aTag) {
|
|
166
|
+
case stringTag:
|
|
167
|
+
return a.toString() === b.toString();
|
|
168
|
+
case numberTag: {
|
|
169
|
+
const x = a.valueOf();
|
|
170
|
+
const y = b.valueOf();
|
|
171
|
+
return eq(x, y);
|
|
172
|
+
}
|
|
173
|
+
case booleanTag:
|
|
174
|
+
case dateTag:
|
|
175
|
+
case symbolTag:
|
|
176
|
+
return Object.is(a.valueOf(), b.valueOf());
|
|
177
|
+
case regexpTag: {
|
|
178
|
+
return a.source === b.source && a.flags === b.flags;
|
|
179
|
+
}
|
|
180
|
+
case functionTag: {
|
|
181
|
+
return a === b;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
stack = stack ?? /* @__PURE__ */ new Map();
|
|
185
|
+
const aStack = stack.get(a);
|
|
186
|
+
const bStack = stack.get(b);
|
|
187
|
+
if (aStack != null && bStack != null) {
|
|
188
|
+
return aStack === b;
|
|
189
|
+
}
|
|
190
|
+
stack.set(a, b);
|
|
191
|
+
stack.set(b, a);
|
|
192
|
+
try {
|
|
193
|
+
switch (aTag) {
|
|
194
|
+
case mapTag: {
|
|
195
|
+
if (a.size !== b.size) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
for (const [key, value] of a.entries()) {
|
|
199
|
+
if (!b.has(key) || !isEqualWithImpl(value, b.get(key), key, a, b, stack, areValuesEqual)) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
case setTag: {
|
|
206
|
+
if (a.size !== b.size) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
const aValues = Array.from(a.values());
|
|
210
|
+
const bValues = Array.from(b.values());
|
|
211
|
+
for (let i = 0; i < aValues.length; i++) {
|
|
212
|
+
const aValue = aValues[i];
|
|
213
|
+
const index = bValues.findIndex((bValue) => {
|
|
214
|
+
return isEqualWithImpl(aValue, bValue, void 0, a, b, stack, areValuesEqual);
|
|
215
|
+
});
|
|
216
|
+
if (index === -1) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
bValues.splice(index, 1);
|
|
220
|
+
}
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
case arrayTag:
|
|
224
|
+
case uint8ArrayTag:
|
|
225
|
+
case uint8ClampedArrayTag:
|
|
226
|
+
case uint16ArrayTag:
|
|
227
|
+
case uint32ArrayTag:
|
|
228
|
+
case bigUint64ArrayTag:
|
|
229
|
+
case int8ArrayTag:
|
|
230
|
+
case int16ArrayTag:
|
|
231
|
+
case int32ArrayTag:
|
|
232
|
+
case bigInt64ArrayTag:
|
|
233
|
+
case float32ArrayTag:
|
|
234
|
+
case float64ArrayTag: {
|
|
235
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(a) !== Buffer.isBuffer(b)) {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
if (a.length !== b.length) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
for (let i = 0; i < a.length; i++) {
|
|
242
|
+
if (!isEqualWithImpl(a[i], b[i], i, a, b, stack, areValuesEqual)) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
case arrayBufferTag: {
|
|
249
|
+
if (a.byteLength !== b.byteLength) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
|
|
253
|
+
}
|
|
254
|
+
case dataViewTag: {
|
|
255
|
+
if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
|
|
259
|
+
}
|
|
260
|
+
case errorTag: {
|
|
261
|
+
return a.name === b.name && a.message === b.message;
|
|
262
|
+
}
|
|
263
|
+
case objectTag: {
|
|
264
|
+
const areEqualInstances = areObjectsEqual(a.constructor, b.constructor, stack, areValuesEqual) || isPlainObject(a) && isPlainObject(b);
|
|
265
|
+
if (!areEqualInstances) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
const aKeys = [...Object.keys(a), ...getSymbols(a)];
|
|
269
|
+
const bKeys = [...Object.keys(b), ...getSymbols(b)];
|
|
270
|
+
if (aKeys.length !== bKeys.length) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
for (let i = 0; i < aKeys.length; i++) {
|
|
274
|
+
const propKey = aKeys[i];
|
|
275
|
+
const aProp = a[propKey];
|
|
276
|
+
if (!Object.hasOwn(b, propKey)) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
const bProp = b[propKey];
|
|
280
|
+
if (!isEqualWithImpl(aProp, bProp, propKey, a, b, stack, areValuesEqual)) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
default: {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
} finally {
|
|
291
|
+
stack.delete(a);
|
|
292
|
+
stack.delete(b);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
__name(areObjectsEqual, "areObjectsEqual");
|
|
296
|
+
|
|
297
|
+
// ../../node_modules/es-toolkit/dist/predicate/isEqual.mjs
|
|
298
|
+
function isEqual(a, b) {
|
|
299
|
+
return isEqualWith(a, b, noop);
|
|
300
|
+
}
|
|
301
|
+
__name(isEqual, "isEqual");
|
|
302
|
+
|
|
303
|
+
// src/preset.ts
|
|
304
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
305
|
+
import { dedent } from "ts-dedent";
|
|
306
|
+
|
|
307
|
+
// src/node/boot-test-runner.ts
|
|
308
|
+
import { fileURLToPath } from "node:url";
|
|
309
|
+
import {
|
|
310
|
+
internal_universalStatusStore,
|
|
311
|
+
internal_universalTestProviderStore
|
|
312
|
+
} from "storybook/internal/core-server";
|
|
313
|
+
var MAX_START_TIME = 3e4;
|
|
314
|
+
var vitestModulePath = fileURLToPath(importMetaResolve("@storybook/addon-vitest/vitest"));
|
|
315
|
+
var eventQueue = [];
|
|
316
|
+
var child;
|
|
317
|
+
var ready = false;
|
|
318
|
+
var unsubscribeStore;
|
|
319
|
+
var unsubscribeStatusStore;
|
|
320
|
+
var unsubscribeTestProviderStore;
|
|
321
|
+
var forwardUniversalStoreEvent = /* @__PURE__ */ __name((storeEventName) => (event, eventInfo) => {
|
|
322
|
+
child?.send({
|
|
323
|
+
type: storeEventName,
|
|
324
|
+
args: [{ event, eventInfo }],
|
|
325
|
+
from: "server"
|
|
326
|
+
});
|
|
327
|
+
}, "forwardUniversalStoreEvent");
|
|
328
|
+
var bootTestRunner = /* @__PURE__ */ __name(async ({
|
|
329
|
+
channel,
|
|
330
|
+
store,
|
|
331
|
+
options
|
|
332
|
+
}) => {
|
|
333
|
+
let stderr = [];
|
|
334
|
+
const killChild = /* @__PURE__ */ __name(() => {
|
|
335
|
+
unsubscribeStore?.();
|
|
336
|
+
unsubscribeStatusStore?.();
|
|
337
|
+
unsubscribeTestProviderStore?.();
|
|
338
|
+
child?.kill();
|
|
339
|
+
child = null;
|
|
340
|
+
}, "killChild");
|
|
341
|
+
store.subscribe("FATAL_ERROR", killChild);
|
|
342
|
+
const exit = /* @__PURE__ */ __name((code = 0) => {
|
|
343
|
+
killChild();
|
|
344
|
+
eventQueue.length = 0;
|
|
345
|
+
process.exit(code);
|
|
346
|
+
}, "exit");
|
|
347
|
+
process.on("exit", exit);
|
|
348
|
+
process.on("SIGINT", () => exit(0));
|
|
349
|
+
process.on("SIGTERM", () => exit(0));
|
|
350
|
+
const startChildProcess = /* @__PURE__ */ __name(() => new Promise((resolve, reject) => {
|
|
351
|
+
child = execaNode(vitestModulePath, {
|
|
352
|
+
env: {
|
|
353
|
+
VITEST: "true",
|
|
354
|
+
TEST: "true",
|
|
355
|
+
VITEST_CHILD_PROCESS: "true",
|
|
356
|
+
NODE_ENV: process.env.NODE_ENV ?? "test",
|
|
357
|
+
STORYBOOK_CONFIG_DIR: normalize(options.configDir)
|
|
358
|
+
},
|
|
359
|
+
extendEnv: true
|
|
360
|
+
});
|
|
361
|
+
stderr = [];
|
|
362
|
+
child.stdout?.on("data", log);
|
|
363
|
+
child.stderr?.on("data", (data) => {
|
|
364
|
+
if (!data.toString().match(/^\u001B\[33m/)) {
|
|
365
|
+
log(data);
|
|
366
|
+
stderr.push(data.toString());
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
unsubscribeStore = store.subscribe(forwardUniversalStoreEvent(STORE_CHANNEL_EVENT_NAME));
|
|
370
|
+
unsubscribeStatusStore = internal_universalStatusStore.subscribe(
|
|
371
|
+
forwardUniversalStoreEvent(STATUS_STORE_CHANNEL_EVENT_NAME)
|
|
372
|
+
);
|
|
373
|
+
unsubscribeTestProviderStore = internal_universalTestProviderStore.subscribe(
|
|
374
|
+
forwardUniversalStoreEvent(TEST_PROVIDER_STORE_CHANNEL_EVENT_NAME)
|
|
375
|
+
);
|
|
376
|
+
child.on("message", (event) => {
|
|
377
|
+
if (event.type === "ready") {
|
|
378
|
+
while (eventQueue.length) {
|
|
379
|
+
const { type, args } = eventQueue.shift();
|
|
380
|
+
child?.send({ type, args, from: "server" });
|
|
381
|
+
}
|
|
382
|
+
resolve();
|
|
383
|
+
} else if (event.type === "uncaught-error") {
|
|
384
|
+
store.send({
|
|
385
|
+
type: "FATAL_ERROR",
|
|
386
|
+
payload: event.payload
|
|
387
|
+
});
|
|
388
|
+
reject();
|
|
389
|
+
} else {
|
|
390
|
+
channel.emit(event.type, ...event.args);
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
}), "startChildProcess");
|
|
394
|
+
const timeout = new Promise(
|
|
395
|
+
(_, reject) => setTimeout(
|
|
396
|
+
reject,
|
|
397
|
+
MAX_START_TIME,
|
|
398
|
+
// eslint-disable-next-line local-rules/no-uncategorized-errors
|
|
399
|
+
new Error(
|
|
400
|
+
`Aborting test runner process because it took longer than ${MAX_START_TIME / 1e3} seconds to start.`
|
|
401
|
+
)
|
|
402
|
+
)
|
|
403
|
+
);
|
|
404
|
+
await Promise.race([startChildProcess(), timeout]).catch((error) => {
|
|
405
|
+
store.send({
|
|
406
|
+
type: "FATAL_ERROR",
|
|
407
|
+
payload: {
|
|
408
|
+
message: "Failed to start test runner process",
|
|
409
|
+
error: {
|
|
410
|
+
message: error.message,
|
|
411
|
+
name: error.name,
|
|
412
|
+
stack: error.stack,
|
|
413
|
+
cause: error.cause
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
eventQueue.length = 0;
|
|
418
|
+
throw error;
|
|
419
|
+
});
|
|
420
|
+
}, "bootTestRunner");
|
|
421
|
+
var runTestRunner = /* @__PURE__ */ __name(async ({
|
|
422
|
+
channel,
|
|
423
|
+
store,
|
|
424
|
+
initEvent,
|
|
425
|
+
initArgs,
|
|
426
|
+
options
|
|
427
|
+
}) => {
|
|
428
|
+
if (!ready && initEvent) {
|
|
429
|
+
eventQueue.push({ type: initEvent, args: initArgs });
|
|
430
|
+
}
|
|
431
|
+
if (!child) {
|
|
432
|
+
ready = false;
|
|
433
|
+
await bootTestRunner({ channel, store, options });
|
|
434
|
+
ready = true;
|
|
435
|
+
}
|
|
436
|
+
}, "runTestRunner");
|
|
437
|
+
|
|
438
|
+
// src/preset.ts
|
|
439
|
+
var experimental_serverChannel = /* @__PURE__ */ __name(async (channel, options) => {
|
|
440
|
+
const core = await options.presets.apply("core");
|
|
441
|
+
const previewPath = loadPreviewOrConfigFile({ configDir: options.configDir });
|
|
442
|
+
const previewAnnotations = await options.presets.apply(
|
|
443
|
+
"previewAnnotations",
|
|
444
|
+
[],
|
|
445
|
+
options
|
|
446
|
+
);
|
|
447
|
+
const resolvedPreviewBuilder = typeof core?.builder === "string" ? core.builder : core?.builder?.name;
|
|
448
|
+
const framework = await getFrameworkName(options);
|
|
449
|
+
if (!resolvedPreviewBuilder?.includes("vite")) {
|
|
450
|
+
if (framework.includes("nextjs")) {
|
|
451
|
+
log(dedent`
|
|
452
|
+
You're using ${framework}, which is a Webpack-based builder. In order to use Storybook Test, with your project, you need to use '@storybook/nextjs-vite', a high performance Vite-based equivalent.
|
|
35
453
|
|
|
36
|
-
|
|
37
|
-
|
|
454
|
+
Information on how to upgrade here: ${import_picocolors.default.yellow("https://storybook.js.org/docs/get-started/frameworks/nextjs?ref=upgrade#with-vite")}\n
|
|
455
|
+
`);
|
|
456
|
+
}
|
|
457
|
+
return channel;
|
|
458
|
+
}
|
|
459
|
+
const fsCache = createFileSystemCache({
|
|
460
|
+
basePath: resolvePathInStorybookCache(ADDON_ID.replace("/", "-")),
|
|
461
|
+
ns: "storybook",
|
|
462
|
+
ttl: 14 * 24 * 60 * 60 * 1e3
|
|
463
|
+
// 14 days
|
|
464
|
+
});
|
|
465
|
+
const cachedState = await fsCache.get("state", {
|
|
466
|
+
config: storeOptions.initialState.config
|
|
467
|
+
});
|
|
468
|
+
const selectCachedState = /* @__PURE__ */ __name((s) => ({
|
|
469
|
+
config: s.config
|
|
470
|
+
}), "selectCachedState");
|
|
471
|
+
const store = experimental_UniversalStore.create({
|
|
472
|
+
...storeOptions,
|
|
473
|
+
initialState: {
|
|
474
|
+
...storeOptions.initialState,
|
|
475
|
+
previewAnnotations: (previewAnnotations ?? []).concat(previewPath ?? []),
|
|
476
|
+
...selectCachedState(cachedState)
|
|
477
|
+
},
|
|
478
|
+
leader: true
|
|
479
|
+
});
|
|
480
|
+
store.onStateChange((state, previousState) => {
|
|
481
|
+
if (!isEqual(selectCachedState(state), selectCachedState(previousState))) {
|
|
482
|
+
fsCache.set("state", selectCachedState(state));
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
const testProviderStore = experimental_getTestProviderStore(ADDON_ID);
|
|
486
|
+
store.subscribe("TRIGGER_RUN", (event, eventInfo) => {
|
|
487
|
+
testProviderStore.setState("test-provider-state:running");
|
|
488
|
+
store.setState((s) => ({
|
|
489
|
+
...s,
|
|
490
|
+
fatalError: void 0
|
|
491
|
+
}));
|
|
492
|
+
runTestRunner({
|
|
493
|
+
channel,
|
|
494
|
+
store,
|
|
495
|
+
initEvent: STORE_CHANNEL_EVENT_NAME,
|
|
496
|
+
initArgs: [{ event, eventInfo }],
|
|
497
|
+
options
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
store.subscribe("TOGGLE_WATCHING", (event, eventInfo) => {
|
|
501
|
+
store.setState((s) => ({
|
|
502
|
+
...s,
|
|
503
|
+
watching: event.payload.to,
|
|
504
|
+
currentRun: {
|
|
505
|
+
...s.currentRun,
|
|
506
|
+
// when enabling watch mode, clear the coverage summary too
|
|
507
|
+
...event.payload.to && {
|
|
508
|
+
coverageSummary: void 0
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}));
|
|
512
|
+
if (event.payload.to) {
|
|
513
|
+
runTestRunner({
|
|
514
|
+
channel,
|
|
515
|
+
store,
|
|
516
|
+
initEvent: STORE_CHANNEL_EVENT_NAME,
|
|
517
|
+
initArgs: [{ event, eventInfo }],
|
|
518
|
+
options
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
store.subscribe("FATAL_ERROR", (event) => {
|
|
523
|
+
const { message, error } = event.payload;
|
|
524
|
+
const name = error.name || "Error";
|
|
525
|
+
log(`${name}: ${message}`);
|
|
526
|
+
if (error.stack) {
|
|
527
|
+
log(error.stack);
|
|
528
|
+
}
|
|
529
|
+
function logErrorWithCauses(err) {
|
|
530
|
+
if (!err) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
log(`Caused by: ${err.name ?? "Error"}: ${err.message}`);
|
|
534
|
+
if (err.stack) {
|
|
535
|
+
log(err.stack);
|
|
536
|
+
}
|
|
537
|
+
if (err.cause) {
|
|
538
|
+
logErrorWithCauses(err.cause);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
__name(logErrorWithCauses, "logErrorWithCauses");
|
|
542
|
+
if (error.cause) {
|
|
543
|
+
logErrorWithCauses(error.cause);
|
|
544
|
+
}
|
|
545
|
+
store.setState((s) => ({
|
|
546
|
+
...s,
|
|
547
|
+
fatalError: {
|
|
548
|
+
message,
|
|
549
|
+
error
|
|
550
|
+
}
|
|
551
|
+
}));
|
|
552
|
+
testProviderStore.setState("test-provider-state:crashed");
|
|
553
|
+
});
|
|
554
|
+
testProviderStore.onClearAll(() => {
|
|
555
|
+
store.setState((s) => ({
|
|
556
|
+
...s,
|
|
557
|
+
currentRun: { ...s.currentRun, coverageSummary: void 0, unhandledErrors: [] }
|
|
558
|
+
}));
|
|
559
|
+
});
|
|
560
|
+
if (!core.disableTelemetry) {
|
|
561
|
+
const enableCrashReports = core.enableCrashReports || options.enableCrashReports;
|
|
562
|
+
channel.on(STORYBOOK_ADDON_TEST_CHANNEL, (event) => {
|
|
563
|
+
telemetry("addon-test", {
|
|
564
|
+
...event,
|
|
565
|
+
payload: {
|
|
566
|
+
...event.payload,
|
|
567
|
+
storyId: oneWayHash(event.payload.storyId)
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
|
+
store.subscribe("TOGGLE_WATCHING", async (event) => {
|
|
572
|
+
await telemetry("addon-test", {
|
|
573
|
+
watchMode: event.payload.to
|
|
574
|
+
});
|
|
575
|
+
});
|
|
576
|
+
store.subscribe("TEST_RUN_COMPLETED", async (event) => {
|
|
577
|
+
const { unhandledErrors, startedAt, finishedAt, ...currentRun } = event.payload;
|
|
578
|
+
await telemetry("addon-test", {
|
|
579
|
+
...currentRun,
|
|
580
|
+
duration: (finishedAt ?? 0) - (startedAt ?? 0),
|
|
581
|
+
unhandledErrorCount: unhandledErrors.length,
|
|
582
|
+
...enableCrashReports && unhandledErrors.length > 0 && {
|
|
583
|
+
unhandledErrors: unhandledErrors.map((error) => {
|
|
584
|
+
const { stacks, ...errorWithoutStacks } = error;
|
|
585
|
+
return sanitizeError(errorWithoutStacks);
|
|
586
|
+
})
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
});
|
|
590
|
+
if (enableCrashReports) {
|
|
591
|
+
store.subscribe("FATAL_ERROR", async (event) => {
|
|
592
|
+
await telemetry("addon-test", {
|
|
593
|
+
fatalError: cleanPaths(event.payload.error.message)
|
|
594
|
+
});
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return channel;
|
|
599
|
+
}, "experimental_serverChannel");
|
|
600
|
+
var staticDirs = /* @__PURE__ */ __name(async (values = [], options) => {
|
|
601
|
+
if (options.configType === "PRODUCTION") {
|
|
602
|
+
return values;
|
|
603
|
+
}
|
|
604
|
+
const coverageDirectory = resolvePathInStorybookCache(COVERAGE_DIRECTORY);
|
|
605
|
+
await mkdir(coverageDirectory, { recursive: true });
|
|
606
|
+
return [
|
|
607
|
+
{
|
|
608
|
+
from: coverageDirectory,
|
|
609
|
+
to: "/coverage"
|
|
610
|
+
},
|
|
611
|
+
...values
|
|
612
|
+
];
|
|
613
|
+
}, "staticDirs");
|
|
614
|
+
export {
|
|
615
|
+
experimental_serverChannel,
|
|
616
|
+
staticDirs
|
|
617
|
+
};
|