diff --git a/CHANGELOG.md b/CHANGELOG.md index c8f3cae..c7e9c63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ # Changelog +## v0.9.4...main + +[compare changes](https://github.com/stacksjs/dtsx/compare/v0.9.4...main) + +### 🩹 Fixes + +- Comment generation ([b3e430d](https://github.com/stacksjs/dtsx/commit/b3e430d)) + +### ❤️ Contributors + +- Chris ([@chrisbbreuer](https://github.com/chrisbbreuer)) + ## v0.9.3...main [compare changes](https://github.com/stacksjs/dtsx/compare/v0.9.3...main) diff --git a/bun.lock b/bun.lock index 516b258..c6c999e 100644 --- a/bun.lock +++ b/bun.lock @@ -17,7 +17,7 @@ }, "packages/bun-plugin": { "name": "bun-plugin-dtsx", - "version": "0.8.3", + "version": "0.9.4", "bin": { "dtsx": "./dist/bin/cli.js", }, @@ -27,18 +27,18 @@ }, "packages/dtsx": { "name": "@stacksjs/dtsx", - "version": "0.8.3", + "version": "0.9.4", "bin": { "dtsx": "./dist/bin/cli.js", }, "devDependencies": { "bunfig": "^0.10.0", - "tinyglobby": "^0.2.13", + "tinyglobby": "^0.2.14", }, }, "packages/vite-plugin": { "name": "vite-plugin-dtsx", - "version": "0.8.3", + "version": "0.9.4", "bin": { "dtsx": "./dist/bin/cli.js", }, @@ -1617,7 +1617,7 @@ "tinyexec": ["tinyexec@1.0.1", "", {}, "sha512-5uC6DDlmeqiOwCPmK9jMSdOuZTh8bU39Ys6yidB+UTt5hfZUPGAypSgFRiEp+jbi9qH40BLDvy85jIU88wKSqw=="], - "tinyglobby": ["tinyglobby@0.2.13", "", { "dependencies": { "fdir": "^6.4.4", "picomatch": "^4.0.2" } }, "sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw=="], + "tinyglobby": ["tinyglobby@0.2.14", "", { "dependencies": { "fdir": "^6.4.4", "picomatch": "^4.0.2" } }, "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ=="], "to-data-view": ["to-data-view@1.1.0", "", {}, "sha512-1eAdufMg6mwgmlojAx3QeMnzB/BTVp7Tbndi3U7ftcT2zCZadjxkkmLmd97zmaxWi+sgGcgWrokmpEoy0Dn0vQ=="], @@ -1871,12 +1871,18 @@ "@unocss/cli/@unocss/config": ["@unocss/config@66.1.2", "", { "dependencies": { "@unocss/core": "66.1.2", "unconfig": "^7.3.2" } }, "sha512-2sQXj+Qaq4RVDELVTPoXMggZ30g1WKHeCuur396I12Ab0HgAR6bTc/DIrNtqKVHFI3mmlvP1oM1ynhKWSKPsTg=="], + "@unocss/cli/tinyglobby": ["tinyglobby@0.2.13", "", { "dependencies": { "fdir": "^6.4.4", "picomatch": "^4.0.2" } }, "sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw=="], + "@unocss/config/@unocss/core": ["@unocss/core@66.0.0", "", {}, "sha512-PdVbSMHNDDkr++9nkqzsZRAkaU84gxMTEgYbqI7dt2p1DXp/5tomVtmMsr2/whXGYKRiUc0xZ3p4Pzraz8TcXA=="], "@unocss/postcss/@unocss/config": ["@unocss/config@66.1.2", "", { "dependencies": { "@unocss/core": "66.1.2", "unconfig": "^7.3.2" } }, "sha512-2sQXj+Qaq4RVDELVTPoXMggZ30g1WKHeCuur396I12Ab0HgAR6bTc/DIrNtqKVHFI3mmlvP1oM1ynhKWSKPsTg=="], + "@unocss/postcss/tinyglobby": ["tinyglobby@0.2.13", "", { "dependencies": { "fdir": "^6.4.4", "picomatch": "^4.0.2" } }, "sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw=="], + "@unocss/vite/@unocss/config": ["@unocss/config@66.1.2", "", { "dependencies": { "@unocss/core": "66.1.2", "unconfig": "^7.3.2" } }, "sha512-2sQXj+Qaq4RVDELVTPoXMggZ30g1WKHeCuur396I12Ab0HgAR6bTc/DIrNtqKVHFI3mmlvP1oM1ynhKWSKPsTg=="], + "@unocss/vite/tinyglobby": ["tinyglobby@0.2.13", "", { "dependencies": { "fdir": "^6.4.4", "picomatch": "^4.0.2" } }, "sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw=="], + "anymatch/picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="], "babel-plugin-polyfill-corejs2/semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="], @@ -1901,6 +1907,8 @@ "eslint-plugin-n/globals": ["globals@15.15.0", "", {}, "sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg=="], + "eslint-plugin-pnpm/tinyglobby": ["tinyglobby@0.2.13", "", { "dependencies": { "fdir": "^6.4.4", "picomatch": "^4.0.2" } }, "sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw=="], + "eslint-plugin-unicorn/globals": ["globals@15.15.0", "", {}, "sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg=="], "eslint-plugin-vuejs-accessibility/vue-eslint-parser": ["vue-eslint-parser@9.4.3", "", { "dependencies": { "debug": "^4.3.4", "eslint-scope": "^7.1.1", "eslint-visitor-keys": "^3.3.0", "espree": "^9.3.1", "esquery": "^1.4.0", "lodash": "^4.17.21", "semver": "^7.3.6" }, "peerDependencies": { "eslint": ">=6.0.0" } }, "sha512-2rYRLWlIpaiN8xbPiDyXZXRgLGOtWxERV7ND5fFAv5qo1D2N9Fu9MNajBNc6o13lZ+24DAWCkQCvj4klgmcITg=="], @@ -1941,8 +1949,12 @@ "toml-eslint-parser/eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="], + "unplugin-vue-components/tinyglobby": ["tinyglobby@0.2.13", "", { "dependencies": { "fdir": "^6.4.4", "picomatch": "^4.0.2" } }, "sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw=="], + "validate-npm-package-license/spdx-expression-parse": ["spdx-expression-parse@3.0.1", "", { "dependencies": { "spdx-exceptions": "^2.1.0", "spdx-license-ids": "^3.0.0" } }, "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q=="], + "vite-plugin-pwa/tinyglobby": ["tinyglobby@0.2.13", "", { "dependencies": { "fdir": "^6.4.4", "picomatch": "^4.0.2" } }, "sha512-mEwzpUgrLySlveBwEVDMKk5B57bhLPYovRfPAXD5gA/98Opn0rCDj3GtLwFvCvH5RK9uPCExUROW5NjDwvqkxw=="], + "vitepress/shiki": ["shiki@2.5.0", "", { "dependencies": { "@shikijs/core": "2.5.0", "@shikijs/engine-javascript": "2.5.0", "@shikijs/engine-oniguruma": "2.5.0", "@shikijs/langs": "2.5.0", "@shikijs/themes": "2.5.0", "@shikijs/types": "2.5.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-mI//trrsaiCIPsja5CNfsyNOqgAZUb6VpJA+340toL42UpzQlXpwRV9nch69X6gaUxrr9kaOOa6e3y3uAkGFxQ=="], "workbox-build/pretty-bytes": ["pretty-bytes@5.6.0", "", {}, "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg=="], diff --git a/package.json b/package.json index 0c08c14..01fa9a3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@stacksjs/dtsx", "type": "module", - "version": "0.9.4", + "version": "0.9.5", "private": true, "description": "A modern, fast .d.ts generation tool, powered by Bun.", "author": "Chris Breuer ", @@ -45,8 +45,8 @@ "lint": "bunx --bun eslint .", "lint:fix": "bunx --bun eslint . --fix", "fresh": "bunx rimraf node_modules/ bun.lock && bun i", - "changelog": "bunx changelogen --output CHANGELOG.md", - "release": "bun run changelog && bunx bumpp -r --all", + "changelog": "bunx --bun changelogen --output CHANGELOG.md", + "release": "bun run changelog && bunx --bun bumpp -r --all", "test": "bun test", "typecheck": "bunx tsc --noEmit", "dev:docs": "bun --bun vitepress dev docs", diff --git a/packages/bun-plugin/package.json b/packages/bun-plugin/package.json index 3f0a5db..655eaf1 100644 --- a/packages/bun-plugin/package.json +++ b/packages/bun-plugin/package.json @@ -1,7 +1,7 @@ { "name": "bun-plugin-dtsx", "type": "module", - "version": "0.9.4", + "version": "0.9.5", "description": "A Bun Bundler plugin that auto generates your DTS types extremely fast.", "author": "Chris Breuer ", "license": "MIT", diff --git a/packages/dtsx/package.json b/packages/dtsx/package.json index 67480aa..6642b83 100644 --- a/packages/dtsx/package.json +++ b/packages/dtsx/package.json @@ -1,7 +1,7 @@ { "name": "@stacksjs/dtsx", "type": "module", - "version": "0.9.4", + "version": "0.9.5", "description": "A modern, fast .d.ts generation tool, powered by Bun.", "author": "Chris Breuer ", "license": "MIT", @@ -66,7 +66,7 @@ }, "devDependencies": { "bunfig": "^0.10.0", - "tinyglobby": "^0.2.13" + "tinyglobby": "^0.2.14" }, "git-hooks": { "pre-commit": { diff --git a/packages/dtsx/src/processor.ts b/packages/dtsx/src/processor.ts index 0db0597..a77f828 100644 --- a/packages/dtsx/src/processor.ts +++ b/packages/dtsx/src/processor.ts @@ -1394,10 +1394,34 @@ function parseObjectProperties(content: string): Array<[string, string]> { let inString = false let stringChar = '' let inKey = true + let inComment = false + let commentDepth = 0 for (let i = 0; i < content.length; i++) { const char = content[i] const prevChar = i > 0 ? content[i - 1] : '' + const nextChar = i < content.length - 1 ? content[i + 1] : '' + + // Track JSDoc/block comments to avoid parsing colons inside them + if (!inString && !inComment && char === '/' && nextChar === '*') { + inComment = true + commentDepth = 1 + current += char + continue + } + else if (inComment && char === '*' && nextChar === '/') { + commentDepth-- + if (commentDepth === 0) { + inComment = false + } + current += char + continue + } + else if (inComment && char === '/' && nextChar === '*') { + commentDepth++ + current += char + continue + } if (!inString && (char === '"' || char === '\'' || char === '`')) { inString = true @@ -1408,7 +1432,7 @@ function parseObjectProperties(content: string): Array<[string, string]> { inString = false current += char } - else if (!inString) { + else if (!inString && !inComment) { if (char === '{' || char === '[' || char === '(') { depth++ current += char diff --git a/packages/dtsx/test/dts.test.ts b/packages/dtsx/test/dts.test.ts index fde912d..93f26fa 100644 --- a/packages/dtsx/test/dts.test.ts +++ b/packages/dtsx/test/dts.test.ts @@ -27,6 +27,7 @@ describe('dts-generation', () => { // List of all fixture files to test (excluding checker.ts which is too large) const fixtures = [ + 'abseil.io', 'class', 'edge-cases', 'enum', diff --git a/packages/dtsx/test/fixtures/input/abseil.io.ts b/packages/dtsx/test/fixtures/input/abseil.io.ts new file mode 100644 index 0000000..36389cf --- /dev/null +++ b/packages/dtsx/test/fixtures/input/abseil.io.ts @@ -0,0 +1,74 @@ +/** + * **abseil.io** - Abseil Common Libraries (C++) + * + * @domain `abseil.io` + * @version `20250512.0.0` (17 versions available) + * @versions From newest version to oldest. @see https://ts-pkgx.netlify.app/packages/abseil-io.md + * + * @install `sh <(curl https://pkgx.sh) +abseil.io -- $SHELL -i` + * + * @example + * ```typescript + * import { pantry } from 'ts-pkgx' + * + * const pkg = pantry.abseilio + * console.log(pkg.name) // "abseil.io" + * console.log(pkg.description) // "Abseil Common Libraries (C++)" + * console.log(pkg.versions[0]) // "20250512.0.0" (latest) + * ``` + * + * @see https://ts-pkgx.netlify.app/packages/abseil-io.md + * @see https://ts-pkgx.netlify.app/usage + */ +export const abseilioPackage = { + /** + * The display name of this package. + */ + name: 'abseil.io' as const, + /** + * The canonical domain name for this package. + */ + domain: 'abseil.io' as const, + /** + * Brief description of what this package does. + */ + description: 'Abseil Common Libraries (C++)' as const, + packageYmlUrl: 'https://github.com/pkgxdev/pantry/tree/main/projects/abseil.io/package.yml' as const, + homepageUrl: '' as const, + githubUrl: 'https://github.com/pkgxdev/pantry/' as const, + /** + * Command to install this package using pkgx. + * @example sh <(curl https://pkgx.sh) +package-name + */ + installCommand: 'sh <(curl https://pkgx.sh) +abseil.io -- $SHELL -i' as const, + programs: [] as const, + companions: [] as const, + dependencies: [] as const, + /** + * Available versions from newest to oldest. + * @see https://ts-pkgx.netlify.app/usage for installation instructions + */ + versions: [ + '20250512.0.0', + '20250127.1.0', + '20250127.0.0', + '20240722.1.0', + '20240722.0.0', + '20240116.3.0', + '20240116.2.0', + '20240116.1.0', + '20240116.0.0', + '20230802.3.0', + '20230802.2.0', + '20230802.1.0', + '20230802.0.0', + '20230125.4.0', + '20230125.3.0', + '20230125.2.0', + '20220623.2.0', + ] as const, + aliases: [] as const, + fullPath: 'abseil.io' as const, +} + +export type AbseilioPackage = typeof abseilioPackage diff --git a/packages/dtsx/test/fixtures/output/abseil.io.d.ts b/packages/dtsx/test/fixtures/output/abseil.io.d.ts new file mode 100644 index 0000000..611b007 --- /dev/null +++ b/packages/dtsx/test/fixtures/output/abseil.io.d.ts @@ -0,0 +1,55 @@ +/** + * **abseil.io** - Abseil Common Libraries (C++) + * + * @domain `abseil.io` + * @version `20250512.0.0` (17 versions available) + * @versions From newest version to oldest. @see https://ts-pkgx.netlify.app/packages/abseil-io.md + * + * @install `sh <(curl https://pkgx.sh) +abseil.io -- $SHELL -i` + * + * @example + * ```typescript + * import { pantry } from 'ts-pkgx' + * + * const pkg = pantry.abseilio + * console.log(pkg.name) // "abseil.io" + * console.log(pkg.description) // "Abseil Common Libraries (C++)" + * console.log(pkg.versions[0]) // "20250512.0.0" (latest) + * ``` + * + * @see https://ts-pkgx.netlify.app/packages/abseil-io.md + * @see https://ts-pkgx.netlify.app/usage + */ +export declare const abseilioPackage: { + /** + * The display name of this package. + */ + name: 'abseil.io'; + /** + * The canonical domain name for this package. + */ + domain: 'abseil.io'; + /** + * Brief description of what this package does. + */ + description: 'Abseil Common Libraries (C++)'; + packageYmlUrl: 'https://github.com/pkgxdev/pantry/tree/main/projects/abseil.io/package.yml'; + homepageUrl: ''; + githubUrl: 'https://github.com/pkgxdev/pantry/'; + /** + * Command to install this package using pkgx. + * @example sh <(curl https://pkgx.sh) +package-name + */ + installCommand: 'sh <(curl https://pkgx.sh) +abseil.io -- $SHELL -i'; + programs: readonly []; + companions: readonly []; + dependencies: readonly []; + /** + * Available versions from newest to oldest. + * @see https://ts-pkgx.netlify.app/usage for installation instructions + */ + versions: readonly ['20250512.0.0', '20250127.1.0', '20250127.0.0', '20240722.1.0', '20240722.0.0', '20240116.3.0', '20240116.2.0', '20240116.1.0', '20240116.0.0', '20230802.3.0', '20230802.2.0', '20230802.1.0', '20230802.0.0', '20230125.4.0', '20230125.3.0', '20230125.2.0', '20220623.2.0']; + aliases: readonly []; + fullPath: 'abseil.io' +}; +export type AbseilioPackage = typeof abseilioPackage \ No newline at end of file diff --git a/packages/vite-plugin/package.json b/packages/vite-plugin/package.json index 07235f2..e57fa78 100644 --- a/packages/vite-plugin/package.json +++ b/packages/vite-plugin/package.json @@ -1,7 +1,7 @@ { "name": "vite-plugin-dtsx", "type": "module", - "version": "0.9.4", + "version": "0.9.5", "private": true, "description": "A modern, fast .d.ts generation tool, powered by Bun.", "author": "Chris Breuer ",