@jsdocs-io/extractor
Advanced tools
Comparing version
@@ -427,14 +427,2 @@ import { SourceFile, ModuleDeclaration, Project } from 'ts-morph'; | ||
declare const PackageNameError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & { | ||
readonly _tag: "PackageNameError"; | ||
} & Readonly<A>; | ||
/** @internal */ | ||
declare class PackageNameError extends PackageNameError_base<{ | ||
warnings?: string[]; | ||
errors?: string[]; | ||
}> { | ||
} | ||
/** @internal */ | ||
declare const packageName: (pkg: string) => Effect.Effect<string, PackageNameError, never>; | ||
declare const PackageJsonError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & { | ||
@@ -461,4 +449,16 @@ readonly _tag: "PackageJsonError"; | ||
/** @internal */ | ||
declare const extractPackageApiEffect: ({ pkg, subpath, maxDepth, }: Omit<ExtractPackageApiOptions, "bunPath">) => Effect.Effect<PackageApi, InstallPackageError | ProjectError | PackageDeclarationsError | PackageJsonError | PackageNameError | PackageTypesError | WorkDirError, PackageManager | effect_Scope.Scope>; | ||
declare const extractPackageApiEffect: ({ pkg, subpath, maxDepth, }: Omit<ExtractPackageApiOptions, "bunPath">) => Effect.Effect<PackageApi, InstallPackageError | ProjectError | PackageDeclarationsError | PackageJsonError | PackageTypesError | WorkDirError, PackageManager | effect_Scope.Scope>; | ||
declare const PackageNameError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & { | ||
readonly _tag: "PackageNameError"; | ||
} & Readonly<A>; | ||
/** @internal */ | ||
declare class PackageNameError extends PackageNameError_base<{ | ||
warnings?: string[]; | ||
errors?: string[]; | ||
}> { | ||
} | ||
/** @internal */ | ||
declare const packageName: (pkg: string) => Effect.Effect<string, PackageNameError, never>; | ||
/** | ||
@@ -465,0 +465,0 @@ `parseDocComment` parses a JSDoc comment using `@microsoft/tsdoc`. |
@@ -342,3 +342,3 @@ // src/bun-package-manager.ts | ||
const signature = headText(declaration); | ||
return formatSignature("class", signature); | ||
return await formatSignature("class", signature); | ||
}; | ||
@@ -384,3 +384,3 @@ var extractClassConstructors = async (classId, classDeclaration) => { | ||
const signature = `${modifiers} constructor(${params});`; | ||
return formatSignature("class-constructor", signature); | ||
return await formatSignature("class-constructor", signature); | ||
}; | ||
@@ -421,3 +421,3 @@ var extractClassProperties = async (classId, classDeclaration) => { | ||
const signature = `${staticKeyword} ${readonlyKeyword} ${name}: ${type}`; | ||
return formatSignature("class-property", signature); | ||
return await formatSignature("class-property", signature); | ||
}; | ||
@@ -455,3 +455,3 @@ var extractClassMethods = async (classId, classDeclaration) => { | ||
const type = typeCheckerType(declaration); | ||
return formatSignature("class-method", `${modifiers} ${name}: ${type}`); | ||
return await formatSignature("class-method", `${modifiers} ${name}: ${type}`); | ||
}; | ||
@@ -476,3 +476,3 @@ | ||
const signature = headText(declaration); | ||
return formatSignature("enum", signature); | ||
return await formatSignature("enum", signature); | ||
}; | ||
@@ -500,3 +500,3 @@ var extractEnumMembers = async (enumId, enumDeclaration) => { | ||
const signature = declaration.getText(); | ||
return formatSignature("enum-member", signature); | ||
return await formatSignature("enum-member", signature); | ||
}; | ||
@@ -517,3 +517,3 @@ | ||
const type = apparentType(declaration); | ||
return formatSignature("variable", `${kind} ${name}: ${type}`); | ||
return await formatSignature("variable", `${kind} ${name}: ${type}`); | ||
}; | ||
@@ -542,3 +542,3 @@ | ||
const filename = declaration.getSourceFile().getBaseName(); | ||
return formatSignature("namespace", `module "${filename}" {}`); | ||
return await formatSignature("namespace", `module "${filename}" {}`); | ||
}; | ||
@@ -558,3 +558,3 @@ | ||
const type = typeCheckerType(declaration); | ||
return formatSignature("function", `${name}: ${type}`); | ||
return await formatSignature("function", `${name}: ${type}`); | ||
}; | ||
@@ -574,3 +574,3 @@ | ||
const type = typeCheckerType(declaration); | ||
return formatSignature("function", `${name}: ${type}`); | ||
return await formatSignature("function", `${name}: ${type}`); | ||
}; | ||
@@ -602,3 +602,3 @@ | ||
const signature = headText(declaration); | ||
return formatSignature("interface", signature); | ||
return await formatSignature("interface", signature); | ||
}; | ||
@@ -626,3 +626,3 @@ var extractInterfaceProperties = async (interfaceId, interfaceDeclaration) => { | ||
const signature = declaration.getText(); | ||
return formatSignature("interface-property", signature); | ||
return await formatSignature("interface-property", signature); | ||
}; | ||
@@ -655,3 +655,3 @@ var extractInterfaceMethods = async (interfaceId, interfaceDeclaration) => { | ||
const type = typeCheckerType(declaration); | ||
return formatSignature("interface-method", `${name}: ${type}`); | ||
return await formatSignature("interface-method", `${name}: ${type}`); | ||
}; | ||
@@ -678,3 +678,3 @@ var extractInterfaceConstructSignatures = async (interfaceId, interfaceDeclaration) => { | ||
const signature = declaration.getText(); | ||
return formatSignature("interface-construct-signature", signature); | ||
return await formatSignature("interface-construct-signature", signature); | ||
}; | ||
@@ -701,3 +701,3 @@ var extractInterfaceCallSignatures = async (interfaceId, interfaceDeclaration) => { | ||
const signature = declaration.getText(); | ||
return formatSignature("interface-call-signature", signature); | ||
return await formatSignature("interface-call-signature", signature); | ||
}; | ||
@@ -724,3 +724,3 @@ var extractInterfaceIndexSignatures = async (interfaceId, interfaceDeclaration) => { | ||
const signature = declaration.getText(); | ||
return formatSignature("interface-index-signature", signature); | ||
return await formatSignature("interface-index-signature", signature); | ||
}; | ||
@@ -748,3 +748,3 @@ var extractInterfaceGetAccessors = async (interfaceId, interfaceDeclaration) => { | ||
const signature = declaration.getText(); | ||
return formatSignature("interface-get-accessor", signature); | ||
return await formatSignature("interface-get-accessor", signature); | ||
}; | ||
@@ -772,3 +772,3 @@ var extractInterfaceSetAccessors = async (interfaceId, interfaceDeclaration) => { | ||
const signature = declaration.getText(); | ||
return formatSignature("interface-get-accessor", signature); | ||
return await formatSignature("interface-get-accessor", signature); | ||
}; | ||
@@ -791,3 +791,3 @@ | ||
const signature = `${containerKeyword} ${exportName} {}`; | ||
return formatSignature("namespace", signature); | ||
return await formatSignature("namespace", signature); | ||
}; | ||
@@ -807,3 +807,3 @@ | ||
const signature = declaration.getText(); | ||
return formatSignature("type", signature); | ||
return await formatSignature("type", signature); | ||
}; | ||
@@ -824,3 +824,3 @@ | ||
const type = apparentType(declaration); | ||
return formatSignature("variable", `${kind} ${name}: ${type}`); | ||
return await formatSignature("variable", `${kind} ${name}: ${type}`); | ||
}; | ||
@@ -850,3 +850,3 @@ | ||
const type = variableType !== "any" ? variableType : expressionType; | ||
return formatSignature("variable", `${kind} ${name}: ${type}`); | ||
return await formatSignature("variable", `${kind} ${name}: ${type}`); | ||
}; | ||
@@ -982,9 +982,9 @@ | ||
if (isVariable(declaration)) { | ||
return extractVariable(containerName, exportName, declaration); | ||
return await extractVariable(containerName, exportName, declaration); | ||
} | ||
if (isVariableAssignmentExpression(declaration)) { | ||
return extractVariableAssignmentExpression(containerName, exportName, declaration); | ||
return await extractVariableAssignmentExpression(containerName, exportName, declaration); | ||
} | ||
if (isExpression(declaration)) { | ||
return extractExpression(containerName, exportName, declaration); | ||
return await extractExpression(containerName, exportName, declaration); | ||
} | ||
@@ -996,18 +996,18 @@ if (isFunction(declaration)) { | ||
seenFunctions.add(exportName); | ||
return extractFunction(containerName, exportName, declaration); | ||
return await extractFunction(containerName, exportName, declaration); | ||
} | ||
if (isFunctionExpression(declaration)) { | ||
return extractFunctionExpression(containerName, exportName, declaration); | ||
return await extractFunctionExpression(containerName, exportName, declaration); | ||
} | ||
if (isClass(declaration)) { | ||
return extractClass(containerName, exportName, declaration); | ||
return await extractClass(containerName, exportName, declaration); | ||
} | ||
if (isInterface(declaration)) { | ||
return extractInterface(containerName, exportName, declaration); | ||
return await extractInterface(containerName, exportName, declaration); | ||
} | ||
if (isEnum(declaration)) { | ||
return extractEnum(containerName, exportName, declaration); | ||
return await extractEnum(containerName, exportName, declaration); | ||
} | ||
if (isTypeAlias(declaration)) { | ||
return extractTypeAlias(containerName, exportName, declaration); | ||
return await extractTypeAlias(containerName, exportName, declaration); | ||
} | ||
@@ -1024,3 +1024,3 @@ if (isNamespace(declaration) && maxDepth > 0) { | ||
}); | ||
return extractNamespace(containerName, exportName, declaration, innerDeclarations); | ||
return await extractNamespace(containerName, exportName, declaration, innerDeclarations); | ||
} | ||
@@ -1033,3 +1033,3 @@ if (isFileModule(declaration) && maxDepth > 0) { | ||
}); | ||
return extractFileModule(containerName, exportName, declaration, innerDeclarations); | ||
return await extractFileModule(containerName, exportName, declaration, innerDeclarations); | ||
} | ||
@@ -1040,7 +1040,7 @@ return void 0; | ||
// src/extract-package-api.ts | ||
import { Effect as Effect10 } from "effect"; | ||
import { Effect as Effect9 } from "effect"; | ||
// src/extract-package-api-effect.ts | ||
import { Effect as Effect9 } from "effect"; | ||
import { performance } from "node:perf_hooks"; | ||
import { Effect as Effect8 } from "effect"; | ||
import { performance } from "perf_hooks"; | ||
import { join } from "pathe"; | ||
@@ -1078,17 +1078,2 @@ | ||
// src/package-name.ts | ||
import { Data as Data5, Effect as Effect6 } from "effect"; | ||
import validate from "validate-npm-package-name"; | ||
var PackageNameError = class extends Data5.TaggedError("PackageNameError") { | ||
}; | ||
var packageName = (pkg) => Effect6.gen(function* () { | ||
const versionMarker = pkg.lastIndexOf("@"); | ||
const pkgName = pkg.slice(0, versionMarker > 0 ? versionMarker : void 0); | ||
const { validForNewPackages, warnings, errors } = validate(pkgName); | ||
if (!validForNewPackages) { | ||
return yield* new PackageNameError({ warnings, errors }); | ||
} | ||
return pkgName; | ||
}); | ||
// src/package-overview.ts | ||
@@ -1101,9 +1086,8 @@ import { SyntaxKind as SyntaxKind8 } from "ts-morph"; | ||
// src/package-types.ts | ||
import { Data as Data6, Effect as Effect7 } from "effect"; | ||
import { Data as Data5, Effect as Effect6 } from "effect"; | ||
import { exports } from "resolve.exports"; | ||
var PackageTypesError = class extends Data6.TaggedError("PackageTypesError") { | ||
var PackageTypesError = class extends Data5.TaggedError("PackageTypesError") { | ||
}; | ||
var packageTypes = (pkgJson, subpath) => Effect7.gen(function* () { | ||
const resolvedPaths = yield* resolveExports(pkgJson, subpath); | ||
const firstPath = resolvedPaths[0]; | ||
var packageTypes = (pkgJson, subpath) => Effect6.gen(function* () { | ||
const firstPath = yield* resolveExports(pkgJson, subpath); | ||
if (firstPath && isTypesFile(firstPath)) { | ||
@@ -1124,8 +1108,8 @@ return firstPath; | ||
const resolvedPaths = exports(pkgJson, subpath, { | ||
conditions: ["types"], | ||
conditions: ["types", "import", "node"], | ||
unsafe: true | ||
}) ?? []; | ||
return Effect7.succeed(resolvedPaths); | ||
return Effect6.succeed(resolvedPaths[0]); | ||
} catch { | ||
return Effect7.succeed([]); | ||
return Effect6.succeed(void 0); | ||
} | ||
@@ -1136,8 +1120,8 @@ }; | ||
// src/work-dir.ts | ||
import { Data as Data7, Effect as Effect8 } from "effect"; | ||
import { rm } from "node:fs/promises"; | ||
import { Data as Data6, Effect as Effect7 } from "effect"; | ||
import { rm } from "fs/promises"; | ||
import { temporaryDirectory } from "tempy"; | ||
var WorkDirError = class extends Data7.TaggedError("WorkDirError") { | ||
var WorkDirError = class extends Data6.TaggedError("WorkDirError") { | ||
}; | ||
var acquire = Effect8.try({ | ||
var acquire = Effect7.try({ | ||
try: () => { | ||
@@ -1157,4 +1141,4 @@ const path = temporaryDirectory(); | ||
}); | ||
var release = (workDir2) => Effect8.promise(() => workDir2.close()); | ||
var workDir = Effect8.acquireRelease(acquire, release); | ||
var release = (workDir2) => Effect7.promise(() => workDir2.close()); | ||
var workDir = Effect7.acquireRelease(acquire, release); | ||
@@ -1166,8 +1150,9 @@ // src/extract-package-api-effect.ts | ||
maxDepth = 5 | ||
}) => Effect9.gen(function* () { | ||
}) => Effect8.gen(function* () { | ||
const startTime = performance.now(); | ||
const pkgName = yield* packageName(pkg); | ||
const { path: cwd } = yield* workDir; | ||
const pm = yield* PackageManager; | ||
const packages = yield* pm.installPackage({ pkg, cwd }); | ||
const workDirPkgJson = yield* packageJson(cwd); | ||
const pkgName = Object.keys(workDirPkgJson.dependencies)[0]; | ||
const pkgDir = join(cwd, "node_modules", pkgName); | ||
@@ -1195,3 +1180,3 @@ const pkgJson = yield* packageJson(pkgDir); | ||
// src/extract-package-api.ts | ||
var extractPackageApi = ({ | ||
var extractPackageApi = async ({ | ||
pkg, | ||
@@ -1201,7 +1186,24 @@ subpath = ".", | ||
bunPath = "bun" | ||
}) => extractPackageApiEffect({ pkg, subpath, maxDepth }).pipe( | ||
Effect10.scoped, | ||
Effect10.provideService(PackageManager, bunPackageManager(bunPath)), | ||
Effect10.runPromise | ||
); | ||
}) => { | ||
return await extractPackageApiEffect({ pkg, subpath, maxDepth }).pipe( | ||
Effect9.scoped, | ||
Effect9.provideService(PackageManager, bunPackageManager(bunPath)), | ||
Effect9.runPromise | ||
); | ||
}; | ||
// src/package-name.ts | ||
import { Data as Data7, Effect as Effect10 } from "effect"; | ||
import validate from "validate-npm-package-name"; | ||
var PackageNameError = class extends Data7.TaggedError("PackageNameError") { | ||
}; | ||
var packageName = (pkg) => Effect10.gen(function* () { | ||
const versionMarker = pkg.lastIndexOf("@"); | ||
const pkgName = pkg.slice(0, versionMarker > 0 ? versionMarker : void 0); | ||
const { validForNewPackages, warnings, errors } = validate(pkgName); | ||
if (!validForNewPackages) { | ||
return yield* new PackageNameError({ warnings, errors }); | ||
} | ||
return pkgName; | ||
}); | ||
export { | ||
@@ -1208,0 +1210,0 @@ InstallPackageError, |
170
package.json
{ | ||
"name": "@jsdocs-io/extractor", | ||
"version": "1.0.0-13", | ||
"description": "The API extractor for npm packages powering jsdocs.io", | ||
"license": "AGPL-3.0-or-later", | ||
"author": { | ||
"name": "Edoardo Scibona", | ||
"url": "http://github.com/velut" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jsdocs-io/extractor.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/jsdocs-io/extractor/issues" | ||
}, | ||
"keywords": [ | ||
"npm", | ||
"registry", | ||
"package", | ||
"analyze", | ||
"api", | ||
"extractor", | ||
"documentation", | ||
"generator", | ||
"typescript", | ||
"javascript", | ||
"jsdoc", | ||
"tsdoc", | ||
"jsdocs.io" | ||
], | ||
"sideEffects": false, | ||
"type": "module", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"engines": { | ||
"node": ">=20" | ||
}, | ||
"dependencies": { | ||
"@microsoft/tsdoc": "^0.15.0", | ||
"effect": "^3.9.1", | ||
"execa": "^9.4.0", | ||
"memoize": "^10.0.0", | ||
"natural-orderby": "^4.0.0", | ||
"pathe": "^1.1.2", | ||
"prettier": "^3.3.3", | ||
"read-pkg": "^9.0.1", | ||
"resolve.exports": "^2.0.2", | ||
"tempy": "^3.1.0", | ||
"ts-morph": "^24.0.0", | ||
"validate-npm-package-name": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "^0.16.4", | ||
"@total-typescript/shoehorn": "^0.1.2", | ||
"@types/node": "^22.7.5", | ||
"@types/validate-npm-package-name": "^4.0.2", | ||
"@vitest/coverage-v8": "^2.1.2", | ||
"np": "^10.0.7", | ||
"ts-dedent": "^2.2.0", | ||
"tsup": "^8.3.0", | ||
"typescript": "^5.6.3", | ||
"vitest": "^2.1.2" | ||
}, | ||
"scripts": { | ||
"check": "tsc --noEmit", | ||
"build": "tsc --noEmit && tsup", | ||
"attw": "attw --pack . --ignore-rules cjs-resolves-to-esm", | ||
"test": "bun --revision && vitest run src test/declarations --coverage --bail 1", | ||
"test:ci": "bun --revision && vitest run src test/declarations test/packages --coverage --bail 1", | ||
"test:update": "bun --revision && vitest run src test/declarations test/packages --update", | ||
"lint": "prettier --check .", | ||
"format": "prettier --write .", | ||
"pre-push": "bun --revision && pnpm i && pnpm lint && pnpm build && pnpm test:ci", | ||
"release": "np" | ||
} | ||
} | ||
"name": "@jsdocs-io/extractor", | ||
"version": "1.0.0-14", | ||
"description": "The API extractor for npm packages powering jsdocs.io", | ||
"license": "AGPL-3.0-or-later", | ||
"author": { | ||
"name": "Edoardo Scibona", | ||
"url": "http://github.com/velut" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jsdocs-io/extractor.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/jsdocs-io/extractor/issues" | ||
}, | ||
"keywords": [ | ||
"npm", | ||
"registry", | ||
"package", | ||
"analyze", | ||
"api", | ||
"extractor", | ||
"documentation", | ||
"generator", | ||
"typescript", | ||
"javascript", | ||
"jsdoc", | ||
"tsdoc", | ||
"jsdocs.io" | ||
], | ||
"sideEffects": false, | ||
"type": "module", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"engines": { | ||
"node": ">=20" | ||
}, | ||
"scripts": { | ||
"check": "tsc --noEmit", | ||
"build": "tsc --noEmit && tsup", | ||
"attw": "attw --pack . --ignore-rules cjs-resolves-to-esm", | ||
"test": "bun --revision && vitest run src test/declarations --coverage --bail 1", | ||
"test:ci": "bun --revision && vitest run src test/declarations test/packages --coverage --bail 1", | ||
"test:update": "bun --revision && vitest run src test/declarations test/packages --update", | ||
"lint": "prettier --check .", | ||
"format": "prettier --write .", | ||
"pre-push": "bun --revision && bun i && bun run lint && bun run build && bun run test:ci && bun run attw", | ||
"release": "np --no-cleanup" | ||
}, | ||
"dependencies": { | ||
"@microsoft/tsdoc": "^0.15.1", | ||
"effect": "^3.15.2", | ||
"execa": "^9.5.3", | ||
"memoize": "^10.1.0", | ||
"natural-orderby": "^5.0.0", | ||
"pathe": "^2.0.3", | ||
"prettier": "^3.5.3", | ||
"read-pkg": "^9.0.1", | ||
"resolve.exports": "^2.0.3", | ||
"tempy": "^3.1.0", | ||
"ts-morph": "^25.0.1", | ||
"validate-npm-package-name": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "^0.18.1", | ||
"@total-typescript/shoehorn": "^0.1.2", | ||
"@types/node": "^22.15.19", | ||
"@types/validate-npm-package-name": "^4.0.2", | ||
"@vitest/coverage-v8": "^3.1.3", | ||
"np": "^10.2.0", | ||
"ts-dedent": "^2.2.0", | ||
"tsup": "^8.5.0", | ||
"typescript": "^5.8.3", | ||
"vitest": "^3.1.3" | ||
} | ||
} |
@@ -57,3 +57,3 @@ # @jsdocs-io/extractor | ||
Copyright (C) 2024 Edoardo Scibona. See [LICENSE](LICENSE). | ||
Copyright (C) 2025 Edoardo Scibona. See [LICENSE](LICENSE). | ||
@@ -60,0 +60,0 @@ This program is free software: you can redistribute it and/or modify |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
97403
0.16%1567
0.13%2
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated
Updated
Updated
Updated
Updated