@storybook/vue3-vite
Advanced tools
Comparing version 0.0.0-pr-29756-sha-24626315 to 0.0.0-pr-29802-sha-ecb67932
@@ -1,3 +0,3 @@ | ||
"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 __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 preset_exports={};__export(preset_exports,{core:()=>core,viteFinal:()=>viteFinal});module.exports=__toCommonJS(preset_exports);var import_node_path2=require("path");var import_promises=require("fs/promises"),import_node_path=require("path"),import_find_package_json=__toESM(require("find-package-json")),import_magic_string=__toESM(require("magic-string")),import_vue_component_meta=require("vue-component-meta"),import_vue_docgen_api=require("vue-docgen-api");async function vueComponentMeta(tsconfigPath="tsconfig.json"){let{createFilter}=await import("vite"),filter=createFilter(/\.(vue|ts|js|tsx|jsx)$/,/\.stories\.(ts|tsx|js|jsx)$|^\0\/virtual:|^\/virtual:|^\/sb-preview\/|\.storybook\/.*\.(ts|js)$/),checker=await createVueComponentMetaChecker(tsconfigPath);return{name:"storybook:vue-component-meta-plugin",async transform(src,id){if(filter(id))try{let exportNames=checker.getExportNames(id),componentsMeta=exportNames.map(name=>checker.getComponentMeta(id,name));componentsMeta=await applyTempFixForEventDescriptions(id,componentsMeta);let metaSources=[];if(componentsMeta.forEach((meta,index)=>{if(!meta.props.length&&!meta.events.length&&!meta.slots.length&&!meta.exposed.length||meta.type===import_vue_component_meta.TypeMeta.Unknown)return;let exportName=exportNames[index];["props","events","slots","exposed"].forEach(key=>{meta[key].forEach(value=>{Array.isArray(value.schema)?value.schema.forEach(eventSchema=>removeNestedSchemas(eventSchema)):removeNestedSchemas(value.schema)})});let exposed=meta.exposed.filter(expose=>{let nameWithoutOnPrefix=expose.name;return nameWithoutOnPrefix.startsWith("on")&&(nameWithoutOnPrefix=lowercaseFirstLetter(expose.name.replace("on",""))),!meta.events.find(event=>event.name===nameWithoutOnPrefix)}).filter(expose=>expose.name==="$slots"?!meta.slots.map(slot=>slot.name).every(slotName=>expose.type.includes(slotName)):!0);metaSources.push({exportName,displayName:exportName==="default"?getFilenameWithoutExtension(id):exportName,...meta,exposed,sourceFiles:id})}),metaSources.length===0)return;let s=new import_magic_string.default(src);return metaSources.forEach(meta=>{let isDefaultExport=meta.exportName==="default",name=isDefaultExport?"_sfc_main":meta.exportName;new RegExp(`export {.*${name}.*}`).test(src)||new RegExp(`export \\* from ['"]\\S*${name}['"]`).test(src)||!src.includes(name)||(!id.endsWith(".vue")&&isDefaultExport&&(s.replace("export default ","const _sfc_main = "),s.append(` | ||
"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 __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 preset_exports={};__export(preset_exports,{core:()=>core,viteFinal:()=>viteFinal});module.exports=__toCommonJS(preset_exports);var import_node_path2=require("path");var import_promises=require("fs/promises"),import_node_path=require("path"),import_find_package_json=__toESM(require("find-package-json")),import_magic_string=__toESM(require("magic-string")),import_vue_component_meta=require("vue-component-meta"),import_vue_docgen_api=require("vue-docgen-api");async function vueComponentMeta(tsconfigPath="tsconfig.json"){let{createFilter}=await import("vite"),filter=createFilter(/\.(vue|ts|js|tsx|jsx)$/,/\.stories\.(ts|tsx|js|jsx)$|^\0\/virtual:|^\/virtual:|\.storybook\/.*\.(ts|js)$/),checker=await createVueComponentMetaChecker(tsconfigPath);return{name:"storybook:vue-component-meta-plugin",async transform(src,id){if(filter(id))try{let exportNames=checker.getExportNames(id),componentsMeta=exportNames.map(name=>checker.getComponentMeta(id,name));componentsMeta=await applyTempFixForEventDescriptions(id,componentsMeta);let metaSources=[];if(componentsMeta.forEach((meta,index)=>{if(!meta.props.length&&!meta.events.length&&!meta.slots.length&&!meta.exposed.length||meta.type===import_vue_component_meta.TypeMeta.Unknown)return;let exportName=exportNames[index];["props","events","slots","exposed"].forEach(key=>{meta[key].forEach(value=>{Array.isArray(value.schema)?value.schema.forEach(eventSchema=>removeNestedSchemas(eventSchema)):removeNestedSchemas(value.schema)})});let exposed=meta.exposed.filter(expose=>{let nameWithoutOnPrefix=expose.name;return nameWithoutOnPrefix.startsWith("on")&&(nameWithoutOnPrefix=lowercaseFirstLetter(expose.name.replace("on",""))),!meta.events.find(event=>event.name===nameWithoutOnPrefix)}).filter(expose=>expose.name==="$slots"?!meta.slots.map(slot=>slot.name).every(slotName=>expose.type.includes(slotName)):!0);metaSources.push({exportName,displayName:exportName==="default"?getFilenameWithoutExtension(id):exportName,...meta,exposed,sourceFiles:id})}),metaSources.length===0)return;let s=new import_magic_string.default(src);return metaSources.forEach(meta=>{let isDefaultExport=meta.exportName==="default",name=isDefaultExport?"_sfc_main":meta.exportName;new RegExp(`export {.*${name}.*}`).test(src)||new RegExp(`export \\* from ['"]\\S*${name}['"]`).test(src)||!src.includes(name)||(!id.endsWith(".vue")&&isDefaultExport&&(s.replace("export default ","const _sfc_main = "),s.append(` | ||
export default _sfc_main;`)),s.append(` | ||
;${name}.__docgenInfo = ${JSON.stringify(meta)}`))}),{code:s.toString(),map:s.generateMap({hires:!0,source:id})}}catch{return}},async handleHotUpdate({file,read,server,modules,timestamp}){let content=await read();checker.updateFile(file,content);let invalidatedModules=new Set;for(let mod of modules)server.moduleGraph.invalidateModule(mod,invalidatedModules,timestamp,!0);return server.ws.send({type:"full-reload"}),[]}}}async function createVueComponentMetaChecker(tsconfigPath="tsconfig.json"){let checkerOptions={forceUseTs:!0,noDeclarations:!0,printer:{newLine:1}},projectRoot=getProjectRoot(),projectTsConfigPath=(0,import_node_path.join)(projectRoot,tsconfigPath),defaultChecker=(0,import_vue_component_meta.createCheckerByJson)(projectRoot,{include:["**/*"]},checkerOptions);return await fileExists(projectTsConfigPath)?(await getTsConfigReferences(projectTsConfigPath)).length>0?defaultChecker:(0,import_vue_component_meta.createChecker)(projectTsConfigPath,checkerOptions):defaultChecker}function getProjectRoot(){let projectRoot=(0,import_find_package_json.default)().next().value?.path??"",currentFileDir=(0,import_node_path.dirname)(__filename),relativePathToProjectRoot=(0,import_node_path.relative)(currentFileDir,projectRoot);return(0,import_node_path.resolve)(currentFileDir,relativePathToProjectRoot)}function getFilenameWithoutExtension(filename){return(0,import_node_path.parse)(filename).name}function lowercaseFirstLetter(string){return string.charAt(0).toLowerCase()+string.slice(1)}async function fileExists(fullPath){try{return await(0,import_promises.stat)(fullPath),!0}catch{return!1}}async function applyTempFixForEventDescriptions(filename,componentMeta){if(!componentMeta.some(meta=>meta.events.length))return componentMeta;try{let parsedComponentDocs=await(0,import_vue_docgen_api.parseMulti)(filename);componentMeta.map((meta,index)=>{let eventsWithDescription=parsedComponentDocs[index].events;return!meta.events.length||!eventsWithDescription?.length||(meta.events=meta.events.map(event=>{let description=eventsWithDescription.find(i=>i.name===event.name)?.description;return description&&(event.description=description),event})),meta})}catch{}return componentMeta}async function getTsConfigReferences(tsConfigPath){try{let content=JSON.parse(await(0,import_promises.readFile)(tsConfigPath,"utf-8"));return!("references"in content)||!Array.isArray(content.references)?[]:content.references}catch{return[]}}function removeNestedSchemas(schema){if(typeof schema=="object"){if(schema.kind==="enum"){schema.schema?.forEach(enumSchema=>removeNestedSchemas(enumSchema));return}delete schema.schema}}var import_magic_string2=__toESM(require("magic-string")),import_vue_docgen_api2=require("vue-docgen-api");async function vueDocgen(){let{createFilter}=await import("vite"),filter=createFilter(/\.(vue)$/);return{name:"storybook:vue-docgen-plugin",async transform(src,id){if(!filter(id))return;let metaData=await(0,import_vue_docgen_api2.parse)(id),s=new import_magic_string2.default(src);return s.append(`;_sfc_main.__docgenInfo = ${JSON.stringify(metaData)}`),{code:s.toString(),map:s.generateMap({hires:!0,source:id})}}}}async function templateCompilation(){return{name:"storybook:vue-template-compilation",config:()=>({resolve:{alias:{vue:"vue/dist/vue.esm-bundler.js"}}})}}var getAbsolutePath=input=>(0,import_node_path2.dirname)(require.resolve((0,import_node_path2.join)(input,"package.json"))),core={builder:getAbsolutePath("@storybook/builder-vite"),renderer:getAbsolutePath("@storybook/vue3")},viteFinal=async(config,options)=>{let plugins=[templateCompilation()],framework=await options.presets.apply("framework"),frameworkOptions=typeof framework=="string"?{}:framework.options??{},docgen=resolveDocgenOptions(frameworkOptions.docgen);docgen.plugin==="vue-component-meta"?plugins.push(await vueComponentMeta(docgen.tsconfig)):plugins.push(await vueDocgen());let{mergeConfig}=await import("vite");return mergeConfig(config,{plugins})},resolveDocgenOptions=docgen=>docgen?typeof docgen=="string"?{plugin:docgen}:docgen:{plugin:"vue-docgen-api"};0&&(module.exports={core,viteFinal}); |
{ | ||
"name": "@storybook/vue3-vite", | ||
"version": "0.0.0-pr-29756-sha-24626315", | ||
"version": "0.0.0-pr-29802-sha-ecb67932", | ||
"description": "Storybook for Vue3 and Vite: Develop Vue3 components in isolation with Hot Reloading.", | ||
@@ -55,4 +55,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@storybook/builder-vite": "0.0.0-pr-29756-sha-24626315", | ||
"@storybook/vue3": "0.0.0-pr-29756-sha-24626315", | ||
"@storybook/builder-vite": "0.0.0-pr-29802-sha-ecb67932", | ||
"@storybook/vue3": "0.0.0-pr-29802-sha-ecb67932", | ||
"find-package-json": "^1.2.0", | ||
@@ -71,3 +71,3 @@ "magic-string": "^0.30.0", | ||
"peerDependencies": { | ||
"storybook": "^0.0.0-pr-29756-sha-24626315", | ||
"storybook": "^0.0.0-pr-29802-sha-ecb67932", | ||
"vite": "^4.0.0 || ^5.0.0 || ^6.0.0" | ||
@@ -74,0 +74,0 @@ }, |
15653
125
+ Added@storybook/builder-vite@0.0.0-pr-29802-sha-ecb67932(transitive)
+ Added@storybook/components@0.0.0-pr-29802-sha-ecb67932(transitive)
+ Added@storybook/csf-plugin@0.0.0-pr-29802-sha-ecb67932(transitive)
+ Added@storybook/manager-api@0.0.0-pr-29802-sha-ecb67932(transitive)
+ Added@storybook/preview-api@0.0.0-pr-29802-sha-ecb67932(transitive)
+ Added@storybook/theming@0.0.0-pr-29802-sha-ecb67932(transitive)
+ Added@storybook/vue3@0.0.0-pr-29802-sha-ecb67932(transitive)
- Removed@storybook/builder-vite@0.0.0-pr-29756-sha-24626315(transitive)
- Removed@storybook/components@0.0.0-pr-29756-sha-24626315(transitive)
- Removed@storybook/csf-plugin@0.0.0-pr-29756-sha-24626315(transitive)
- Removed@storybook/manager-api@0.0.0-pr-29756-sha-24626315(transitive)
- Removed@storybook/preview-api@0.0.0-pr-29756-sha-24626315(transitive)
- Removed@storybook/theming@0.0.0-pr-29756-sha-24626315(transitive)
- Removed@storybook/vue3@0.0.0-pr-29756-sha-24626315(transitive)