-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
3,742 additions
and
4,286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"source": { | ||
"include": ["src/index.js"] | ||
}, | ||
"opts": { | ||
"destination": "dist", | ||
"outFile": "pcui-graph.d.ts", | ||
"recurse": true, | ||
"template": "node_modules/tsd-jsdoc/dist" | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const fs = require('fs'); | ||
|
||
const path = './dist/pcui-graph.d.ts'; | ||
|
||
var lastClass = ''; | ||
function removeDuplicateClasses(str) { | ||
return str.replace(/(\/\*[\s\S]*?\*\/[\r\n]?)?declare class ([a-zA-Z]+).*\{[\s\S]*?\}/g, function (all, jsdoc, classname) { | ||
if (all == lastClass) { | ||
return `// drop duplicate: ${classname}`; | ||
} | ||
lastClass = all; | ||
return all; | ||
}); | ||
} | ||
|
||
// replace declare with export and add 'export as namespace pc' in the end | ||
let ts = fs.readFileSync(path, 'utf8'); | ||
ts = removeDuplicateClasses(ts); | ||
ts = ts.replace(/^declare /gm, 'export '); | ||
// Remove empty interfaces | ||
ts = ts.replace(/export interface ([a-zA-Z]+).*\{\n\}/g, function (all, interfacename) { | ||
return `// drop empty interface: ${interfacename}` | ||
}); | ||
// export namespace | ||
ts += 'export as namespace pcuiGraph;\n'; | ||
fs.writeFileSync(path, ts); |