storybook-addon-source-link
Version:
Add a button to the Storybook toolbar that opens the file containing the Story in an IDE like VSCode.
1 lines • 1.32 kB
Source Map (JSON)
{"version":3,"sources":["../src/linkUtil.ts"],"names":["join","normalize","parse","getFileUrl","rootPath","importPath","joinPath","paths","parsePath","path","normalizePath"],"mappings":"AAAA,OAAS,QAAAA,EAAM,aAAAC,EAAW,SAAAC,MAAa,kBAEhC,IAAMC,EAAa,CAACC,EAAkBC,IACrC,IAAI,IAAI,WAAWL,EAAKI,EAAUC,CAAU,CAAC,EAAE,EAM1CC,EAAW,IAAIC,IACpBP,EAAK,GAAGO,CAAK,EASRC,EAAaC,GAClBP,EAAMO,CAAI,EAQLC,EAAiBD,GACtBR,EAAUQ,CAAI","sourcesContent":["import { join, normalize, parse } from \"@std/path/posix\";\n\nexport const getFileUrl = (rootPath: string, importPath: string) => {\n\treturn new URL(`file:///${join(rootPath, importPath)}`);\n};\n\n/**\n * Joins path segments into a path.\n */\nexport const joinPath = (...paths: [string, ...string[]]): string => {\n\treturn join(...paths);\n};\n\n/**\n * Parses a path into an object.\n *\n * @example \"./src/stories/Button.stories.tsx\"\n * -> { root: \"\", dir: \"./src/stories\", base: \"Button.stories.tsx\", ext: \".tsx\", name: \"Button.stories\" }\n */\nexport const parsePath = (path: string) => {\n\treturn parse(path);\n};\n\n/**\n * Normalizes a path, resolving `.` and `..` segments.\n *\n * @example \"./src/stories/Button.stories.tsx\" -> \"src/stories/Button.stories.tsx\"\n */\nexport const normalizePath = (path: string) => {\n\treturn normalize(path);\n};\n"]}