-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TypeScript to all packages except 'cli' (#33)
- Loading branch information
1 parent
88c006f
commit f32488f
Showing
41 changed files
with
444 additions
and
289 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
src | ||
tsconfig.json | ||
tsconfig.tsbuildinfo |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 @@ | ||
export { components } from './lib/export-components'; |
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,38 @@ | ||
import { | ||
FigmaExportPageNode, | ||
} from '@figma-export/types/src'; | ||
import { Document } from 'figma-js'; | ||
|
||
import { | ||
getClient, | ||
getPages, | ||
enrichPagesWithSvg, | ||
} from './figma'; | ||
|
||
type FigmaExportComponentsProps = { | ||
[key: string]: any; | ||
token: string; | ||
} | ||
|
||
export const components = async ({ | ||
token, | ||
fileId, | ||
onlyFromPages = [], | ||
transformers = [], | ||
outputters = [], | ||
log = (msg: string): void => { console.log(msg); }, | ||
}: FigmaExportComponentsProps): Promise<FigmaExportPageNode[]> => { | ||
const client = getClient(token); | ||
|
||
log('fetching document'); | ||
const { data: { document } = {} }: { data?: { document?: Document } } = await client.file(fileId); | ||
|
||
const pages = getPages((document as unknown as DocumentNode), { only: onlyFromPages }); | ||
|
||
log('fetching components'); | ||
const pagesWithSvg = await enrichPagesWithSvg(client, fileId, pages, transformers); | ||
|
||
await Promise.all(outputters.map((outputter: Function) => outputter(pagesWithSvg))); | ||
|
||
return pagesWithSvg; | ||
}; |
Oops, something went wrong.