{"name":"vue-component-meta","version":"1.8.0-patch.1","license":"MIT","_id":"vue-component-meta@1.8.0-patch.1","maintainers":[{"name":"johnsoncodehk","email":"johnsoncodehk@gmail.com"}],"homepage":"https://github.com/vuejs/language-tools#readme","bugs":{"url":"https://github.com/vuejs/language-tools/issues"},"dist":{"shasum":"b39076b3d8930079aaa23d3a8fde009b1ba67c0d","tarball":"http://registry-npm.ywwl.com/vue-component-meta/download/vue-component-meta-1.8.0-patch.1.tgz","fileCount":7,"integrity":"sha512-8ja8AC1fO2QNAssc5ptx0Lq/yCRP9hoNmP+o/a/yfm7l8T38u5UvNcKojiNBMgEJMUkx21mgG5pnj309B/WFog==","signatures":[{"sig":"MEUCIB+5Nt44YWFRMPX79VEAdf8qlpogkPJDDAdQ/osHIQpMAiEAplYisg/6wFAy5H+O8g50TwedrCwpxcEeqcRxd7SwQ4Q=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":39789,"size":9632,"noattachment":false,"key":"/vue-component-meta/-/vue-component-meta-1.8.0-patch.1.tgz"},"main":"out/index.js","types":"./out/index.d.ts","gitHead":"5d5fc89edd2897b5eb2a143524a1f04775cffda3","_npmUser":{"name":"johnsoncodehk","email":"johnsoncodehk@gmail.com"},"repository":{"url":"git+https://github.com/vuejs/language-tools.git","type":"git","directory":"packages/vue-component-meta"},"_npmVersion":"lerna/2.4.1/node@v18.16.0+arm64 (darwin)","description":"`vue-component-meta` allows you to extract the meta-data like props, slots, events, etc from your components via static code analysis. You can even generate description for your props from your source code. This helps document your components via automati","directories":{},"_nodeVersion":"18.16.0","dependencies":{"typesafe-path":"^0.2.2","@volar/typescript":"1.7.7","@vue/language-core":"1.8.0-patch.1","vue-component-type-helpers":"1.8.0-patch.1"},"_hasShrinkwrap":false,"readmeFilename":"README.md","peerDependencies":{"typescript":"*"},"peerDependenciesMeta":{"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/vue-component-meta_1.8.0-patch.1_1687051504901_0.9764173854617435","host":"s3://npm-registry-packages"},"readme":"# vue-component-meta\n\n<p>\n  <a href=\"https://www.npmjs.com/package/vue-component-meta\"><img src=\"https://img.shields.io/npm/v/vue-component-meta.svg?labelColor=18181B&color=1584FC\" alt=\"NPM version\"></a>\n  <a href=\"https://github.com/vuejs/language-tools/blob/master/LICENSE\"><img src=\"https://img.shields.io/github/license/vuejs/language-tools.svg?labelColor=18181B&color=1584FC\" alt=\"License\"></a>\n</p>\n\nStatically extract metadata such as props, events, slots, and exposed from Vue components. Useful for auto-generating component documentation or displaying component APIs in tools like Storybook.\n\n## Installation\n\n```bash\nnpm install vue-component-meta typescript\n```\n\n## Usage\n\n### Create a Checker from tsconfig.json\n\n```typescript\nimport { createChecker } from 'vue-component-meta';\n\nconst checker = createChecker('/path/to/tsconfig.json', {\n  schema: true, // Enable schema parsing\n});\n\nconst meta = checker.getComponentMeta('/path/to/MyComponent.vue');\n```\n\n### Create a Checker from JSON Configuration\n\n```typescript\nimport { createCheckerByJson } from 'vue-component-meta';\n\nconst checker = createCheckerByJson('/project/root', {\n  include: ['src/**/*.vue'],\n  compilerOptions: { /* ... */ },\n  vueCompilerOptions: { /* ... */ },\n});\n```\n\n## API\n\n### `checker.getComponentMeta(filePath, exportName?)`\n\nGet the metadata of a component. `exportName` defaults to `'default'`.\n\nThe returned `ComponentMeta` object contains:\n\n```typescript\ninterface ComponentMeta {\n  name?: string;\n  description?: string;\n  type: TypeMeta;\n  props: PropertyMeta[];\n  events: EventMeta[];\n  slots: SlotMeta[];\n  exposed: ExposeMeta[];\n}\n```\n\n### `checker.getExportNames(filePath)`\n\nGet all export names of a file.\n\n### `checker.updateFile(filePath, content)`\n\nUpdate file content (for virtual files or live editing).\n\n### `checker.deleteFile(filePath)`\n\nRemove a file from the project.\n\n### `checker.reload()`\n\nReload the tsconfig.json configuration.\n\n### `checker.clearCache()`\n\nClear cached file content.\n\n### `checker.getProgram()`\n\nGet the underlying TypeScript Program instance.\n\n## Metadata Structures\n\n### PropertyMeta (Props)\n\n```typescript\ninterface PropertyMeta {\n  name: string;\n  description: string;      // Read from JSDoc\n  type: string;             // Type string\n  default?: string;         // Default value\n  required: boolean;\n  global: boolean;          // Whether it's a global prop\n  tags: { name: string; text?: string }[];  // JSDoc tags\n  schema: PropertyMetaSchema;\n  getDeclarations(): Declaration[];\n  getTypeObject(): ts.Type;\n}\n```\n\n### EventMeta\n\n```typescript\ninterface EventMeta {\n  name: string;\n  description: string;\n  type: string;\n  signature: string;\n  tags: { name: string; text?: string }[];\n  schema: PropertyMetaSchema[];\n  getDeclarations(): Declaration[];\n  getTypeObject(): ts.Type | undefined;\n}\n```\n\n### SlotMeta\n\n```typescript\ninterface SlotMeta {\n  name: string;\n  description: string;\n  type: string;\n  tags: { name: string; text?: string }[];\n  schema: PropertyMetaSchema;\n  getDeclarations(): Declaration[];\n  getTypeObject(): ts.Type;\n}\n```\n\n### ExposeMeta\n\n```typescript\ninterface ExposeMeta {\n  name: string;\n  description: string;\n  type: string;\n  tags: { name: string; text?: string }[];\n  schema: PropertyMetaSchema;\n  getDeclarations(): Declaration[];\n  getTypeObject(): ts.Type;\n}\n```\n\n## Options\n\n```typescript\ninterface MetaCheckerOptions {\n  schema?: boolean | {\n    ignore?: (string | ((name: string, type: ts.Type, typeChecker: ts.TypeChecker) => boolean))[];\n  };\n  printer?: ts.PrinterOptions;\n}\n```\n\n### `schema`\n\nControls whether to parse the schema structure of types. Set to `true` to enable, or pass an object to configure types to ignore.\n\n```typescript\nconst checker = createChecker(tsconfig, {\n  schema: {\n    ignore: ['HTMLElement', (name) => name.startsWith('Internal')],\n  },\n});\n```\n\n## Related Packages\n\n- [`vue-component-type-helpers`](../component-type-helpers) - Type helper utilities\n\n## License\n\n[MIT](https://github.com/vuejs/language-tools/blob/master/LICENSE) License\n","publish_time":1687051505149,"_cnpm_publish_time":1687051505149,"dist-tags":{"alpha":"4.0.0-alpha.3","latest":"3.3.14","v3.0":"3.0.11"}}