forked from Kitware/vtk-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(ts): allow vtk classes discovery
- Loading branch information
Showing
4 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* | ||
* @param obj | ||
* @return | ||
*/ | ||
declare function vtk(obj: object): any; | ||
|
||
/** | ||
* Nest register method under the vtk function | ||
* @param vtkClassName | ||
* @param constructor | ||
*/ | ||
declare function register(vtkClassName: string, constructor: any): void; | ||
|
||
export default vtk; |
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,36 @@ | ||
import * as fs from 'fs'; | ||
import path from 'path'; | ||
|
||
export function generateDtsReferences(pluginOptions) { | ||
|
||
const rootDts = 'index.d.ts'; | ||
const dtsReferences = [ | ||
'/// <reference path="./types.d.ts" />', | ||
'/// <reference path="./interfaces.d.ts" />', | ||
]; | ||
|
||
return { | ||
name: 'generate-references', | ||
generateBundle(outputOptions, bundle, isWrite) { | ||
const files = Object.keys(bundle); | ||
|
||
for (let i = 0; i < files.length; i++) { | ||
const file = files[i]; | ||
let filename = file.replace('.js', '.d.ts'); | ||
|
||
const dts = path.join(pluginOptions['dest'], filename); | ||
|
||
if (fs.existsSync(dts) && filename !== rootDts) { | ||
filename = filename.replace(/\\/g, '/'); | ||
dtsReferences.push(`/// <reference path="./${filename}" />`); | ||
} | ||
} | ||
|
||
this.emitFile({ | ||
type: 'asset', | ||
fileName: rootDts, | ||
source: dtsReferences.join("\r\n") | ||
}); | ||
} | ||
}; | ||
} |
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