@auto-engineer/design-system-importer 0.1.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-format.log +12 -0
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +14 -0
- package/.turbo/turbo-type-check.log +5 -0
- package/CHANGELOG.md +37 -0
- package/README.md +48 -0
- package/dist/FigmaComponentsBuilder.d.ts +16 -0
- package/dist/FigmaComponentsBuilder.d.ts.map +1 -0
- package/dist/FigmaComponentsBuilder.js +175 -0
- package/dist/FigmaComponentsBuilder.js.map +1 -0
- package/dist/commands/import-design-system.d.ts +3 -3
- package/dist/commands/import-design-system.d.ts.map +1 -1
- package/dist/commands/import-design-system.js +20 -25
- package/dist/commands/import-design-system.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +93 -6
- package/dist/index.js.map +1 -1
- package/dist/utils/FilterLoader.d.ts +9 -0
- package/dist/utils/FilterLoader.d.ts.map +1 -0
- package/dist/utils/FilterLoader.js +66 -0
- package/dist/utils/FilterLoader.js.map +1 -0
- package/package.json +4 -2
- package/src/FigmaComponentsBuilder.ts +207 -0
- package/src/commands/import-design-system.ts +19 -28
- package/src/index.ts +112 -6
- package/src/utils/FilterLoader.ts +76 -0
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @auto-engineer/design-system-importer@0.
|
|
2
|
+
> @auto-engineer/design-system-importer@0.3.0 build /Users/sam/WebstormProjects/top/auto-engineer/packages/design-system-importer
|
|
3
3
|
> tsc && tsx ../../scripts/fix-esm-imports.ts
|
|
4
4
|
|
|
5
5
|
Fixed ESM imports in dist/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
> @auto-engineer/design-system-importer@0.2.0 format /Users/sam/WebstormProjects/top/auto-engineer/packages/design-system-importer
|
|
3
|
+
> prettier --write "**/*.{js,ts,json,md,yml,yaml}" --ignore-path ../../.prettierignore
|
|
4
|
+
|
|
5
|
+
CHANGELOG.md 20ms (unchanged)
|
|
6
|
+
package.json 15ms (unchanged)
|
|
7
|
+
README.md 10ms (unchanged)
|
|
8
|
+
src/commands/import-design-system.ts 40ms (unchanged)
|
|
9
|
+
src/FigmaComponentsBuilder.ts 23ms (unchanged)
|
|
10
|
+
src/index.ts 12ms (unchanged)
|
|
11
|
+
src/utils/FilterLoader.ts 3ms (unchanged)
|
|
12
|
+
tsconfig.json 1ms (unchanged)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @auto-engineer/design-system-importer@0.3.0 test /Users/sam/WebstormProjects/top/auto-engineer/packages/design-system-importer
|
|
4
|
+
> vitest run
|
|
5
|
+
|
|
6
|
+
[?25l
|
|
7
|
+
[1m[46m RUN [49m[22m [36mv3.2.4 [39m[90m/Users/sam/WebstormProjects/top/auto-engineer/packages/design-system-importer[39m
|
|
8
|
+
|
|
9
|
+
No test files found, exiting with code 0
|
|
10
|
+
|
|
11
|
+
[31m[2minclude: [22m[33m**/*.specs.{js,ts}[39m[39m
|
|
12
|
+
[31m[2mexclude: [22m[33m**/.tmp/**[2m, [22m**/node_modules/**[2m, [22m**/dist/**[39m[39m
|
|
13
|
+
[31m[39m
|
|
14
|
+
[?25h
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @auto-engineer/design-system-importer
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#22](https://github.com/SamHatoum/auto-engineer/pull/22) [`927b39a`](https://github.com/SamHatoum/auto-engineer/commit/927b39a2c08c0baa1942b2955a8e8015e09364d9) Thanks [@SamHatoum](https://github.com/SamHatoum)! - Some major refactorings of the directory structure
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [`f3e97e5`](https://github.com/SamHatoum/auto-engineer/commit/f3e97e563b79ca8328e802dd502e65285ec58ce9) Thanks [@SamHatoum](https://github.com/SamHatoum)! - global version bump to test release process
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`f3e97e5`](https://github.com/SamHatoum/auto-engineer/commit/f3e97e563b79ca8328e802dd502e65285ec58ce9), [`927b39a`](https://github.com/SamHatoum/auto-engineer/commit/927b39a2c08c0baa1942b2955a8e8015e09364d9)]:
|
|
14
|
+
- @auto-engineer/message-bus@0.3.0
|
|
15
|
+
|
|
16
|
+
## 0.3.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- [`330afa5`](https://github.com/SamHatoum/auto-engineer/commit/330afa565079e3b528d0f448d64919a8dc78d684) Thanks [@SamHatoum](https://github.com/SamHatoum)! - Fix multiple dependency issues
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [[`330afa5`](https://github.com/SamHatoum/auto-engineer/commit/330afa565079e3b528d0f448d64919a8dc78d684)]:
|
|
25
|
+
- @auto-engineer/message-bus@0.2.0
|
|
26
|
+
|
|
27
|
+
## 0.2.0
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- [#24](https://github.com/SamHatoum/auto-engineer/pull/24) [`d4dcacd`](https://github.com/SamHatoum/auto-engineer/commit/d4dcacd18cf2217d3ac9f4354f79ab7ff2ba39a0) Thanks [@SamHatoum](https://github.com/SamHatoum)! - Making commands independent and CLI based
|
|
32
|
+
|
|
33
|
+
- [#22](https://github.com/SamHatoum/auto-engineer/pull/22) [`e39acf3`](https://github.com/SamHatoum/auto-engineer/commit/e39acf31e9051652084d0de99cf8c89b40e6531c) Thanks [@SamHatoum](https://github.com/SamHatoum)! - Some major refactorings of the directory structure
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [[`e39acf3`](https://github.com/SamHatoum/auto-engineer/commit/e39acf31e9051652084d0de99cf8c89b40e6531c)]:
|
|
38
|
+
- @auto-engineer/message-bus@0.1.0
|
|
39
|
+
|
|
3
40
|
## 0.1.2
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Design System Importer
|
|
2
|
+
|
|
3
|
+
Pull in your team’s design system to build consistent, on-brand apps—fast.
|
|
4
|
+
Easily sync shared styles, components, and tokens from design tools or code.
|
|
5
|
+
|
|
6
|
+
## Available Importers
|
|
7
|
+
|
|
8
|
+
- **Figma** – Import components directly from Figma. Use our [Auto plugin]() to export design tokens effortlessly.
|
|
9
|
+
- **Code** – _(coming soon)_ Import tokens and components from an existing codebase.
|
|
10
|
+
- **NPM Package** – _(coming soon)_ Pull in a published design system as a dependency.
|
|
11
|
+
|
|
12
|
+
## Figma Importer
|
|
13
|
+
|
|
14
|
+
Sync your design system directly from Figma and integrate it into your local project.
|
|
15
|
+
|
|
16
|
+
### Prerequisites
|
|
17
|
+
|
|
18
|
+
- A **Figma Personal Access Token**
|
|
19
|
+
- A **Professional Figma Plan** (or higher)
|
|
20
|
+
|
|
21
|
+
### Setup
|
|
22
|
+
|
|
23
|
+
1. **Generate a personal access token**
|
|
24
|
+
Follow [these instructions](https://help.figma.com/hc/en-us/articles/8085703771159-Manage-personal-access-tokens) from Figma.
|
|
25
|
+
|
|
26
|
+
2. **Get your design system file ID**
|
|
27
|
+
Open your Figma file and copy the part of the URL after `/design/`.
|
|
28
|
+
|
|
29
|
+
3. **Configure environment variables**
|
|
30
|
+
- `FIGMA_PERSONAL_TOKEN` – The token from your Figma account
|
|
31
|
+
- `FIGMA_FILE_ID` – The ID of the design file (found in the Figma URL after `/design/`)
|
|
32
|
+
|
|
33
|
+
4. **Publish your components in Figma**
|
|
34
|
+
Right-click anywhere → **Actions** → Search for “Publish changes to library”.
|
|
35
|
+
|
|
36
|
+
> _(Optional)_ If you're using a public design system, you may need to move the file into one of your own Figma projects first.
|
|
37
|
+
|
|
38
|
+
5. **Export tokens with the Auto plugin**
|
|
39
|
+
- Install the [Auto plugin]()
|
|
40
|
+
- Run it inside your Figma file
|
|
41
|
+
- Click **"Export Tokens"**
|
|
42
|
+
- Save the exported file inside the `.context` folder of your output directory
|
|
43
|
+
|
|
44
|
+
6. **Run the importer**
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pnpm import:design-system
|
|
48
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface FigmaComponent {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
thumbnail: string;
|
|
5
|
+
}
|
|
6
|
+
export type FilterFunctionType = (components: FigmaComponent[]) => FigmaComponent[];
|
|
7
|
+
export declare class FigmaComponentsBuilder {
|
|
8
|
+
components: FigmaComponent[];
|
|
9
|
+
withFigmaComponents(): Promise<this>;
|
|
10
|
+
withFigmaComponentSets(): Promise<this>;
|
|
11
|
+
withFilteredNamesForShadcn(): void;
|
|
12
|
+
withFilter(filter: FilterFunctionType): void;
|
|
13
|
+
withAllFigmaInstanceNames(): Promise<this>;
|
|
14
|
+
build(): FigmaComponent[];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=FigmaComponentsBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FigmaComponentsBuilder.d.ts","sourceRoot":"","sources":["../src/FigmaComponentsBuilder.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,UAAU,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,CAAC;AAUpF,qBAAa,sBAAsB;IACjC,UAAU,EAAE,cAAc,EAAE,CAAM;IAE5B,mBAAmB;IAuBnB,sBAAsB;IA+B5B,0BAA0B,IAAI,IAAI;IA2BlC,UAAU,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI;IAQtC,yBAAyB;IAsF/B,KAAK;CAGN"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import * as dotenv from 'dotenv';
|
|
2
|
+
import * as Figma from 'figma-api';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
const figmaApi = new Figma.Api({
|
|
5
|
+
personalAccessToken: process.env.FIGMA_PERSONAL_TOKEN,
|
|
6
|
+
});
|
|
7
|
+
export class FigmaComponentsBuilder {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.components = [];
|
|
10
|
+
}
|
|
11
|
+
async withFigmaComponents() {
|
|
12
|
+
try {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
14
|
+
const response = await figmaApi.getFileComponents({ file_key: process.env.FIGMA_FILE_ID });
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
16
|
+
if (response.meta.components.length > 0) {
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
18
|
+
console.log(JSON.stringify(response.meta.components.length, null, 2));
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
20
|
+
this.components = response.meta.components.map((component) => ({
|
|
21
|
+
name: component.name,
|
|
22
|
+
description: component.description,
|
|
23
|
+
thumbnail: component.thumbnail_url,
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
console.error(e);
|
|
29
|
+
}
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
async withFigmaComponentSets() {
|
|
33
|
+
try {
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
35
|
+
const response = await figmaApi.getFileComponentSets({ file_key: process.env.FIGMA_FILE_ID });
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
37
|
+
if (response.meta.component_sets.length > 0) {
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
39
|
+
this.components = response.meta.component_sets.map((component) => ({
|
|
40
|
+
name: component.name,
|
|
41
|
+
description: component.description ?? 'N/A',
|
|
42
|
+
thumbnail: component.thumbnail_url ?? 'N/A',
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
console.error(e);
|
|
48
|
+
}
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
// extractBracketedComponents(item: FigmaComponent): FigmaComponent | null {
|
|
52
|
+
// const match = item.name.match(/<([^>]+)>/);
|
|
53
|
+
// return match ? { ...item, name: match[1].trim() } : null;
|
|
54
|
+
// }
|
|
55
|
+
//
|
|
56
|
+
// withFilteredNamesForMui() {
|
|
57
|
+
// // eslint-disable-next-line @typescript-eslint/unbound-method
|
|
58
|
+
// this.components = this.components.map(this.extractBracketedComponents).filter(Boolean) as FigmaComponent[];
|
|
59
|
+
// }
|
|
60
|
+
withFilteredNamesForShadcn() {
|
|
61
|
+
this.components = this.components
|
|
62
|
+
.map((comp) => {
|
|
63
|
+
if (!comp?.name)
|
|
64
|
+
return null;
|
|
65
|
+
let str = comp.name.trim();
|
|
66
|
+
if (str.includes('/')) {
|
|
67
|
+
str = str.split('/')[0].trim();
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
str = str.split(' ')[0].trim();
|
|
71
|
+
}
|
|
72
|
+
if (str.length > 0) {
|
|
73
|
+
str = str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
...comp,
|
|
80
|
+
name: str.toLowerCase(),
|
|
81
|
+
};
|
|
82
|
+
})
|
|
83
|
+
.filter((c) => Boolean(c));
|
|
84
|
+
}
|
|
85
|
+
withFilter(filter) {
|
|
86
|
+
try {
|
|
87
|
+
this.components = filter(this.components);
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
console.error('Error applying custom filter:', e);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async withAllFigmaInstanceNames() {
|
|
94
|
+
try {
|
|
95
|
+
/// ----
|
|
96
|
+
const usedComponentMap = new Map();
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
98
|
+
const { document } = await figmaApi.getFile({
|
|
99
|
+
file_key: process.env.FIGMA_FILE_ID,
|
|
100
|
+
depth: 1,
|
|
101
|
+
});
|
|
102
|
+
function walkTree(node) {
|
|
103
|
+
if (node.type === 'INSTANCE' && Boolean(node.name)) {
|
|
104
|
+
if (!usedComponentMap.has(node.name)) {
|
|
105
|
+
usedComponentMap.set(node.name, {
|
|
106
|
+
name: node.name,
|
|
107
|
+
description: node.description ?? '',
|
|
108
|
+
thumbnail: node.thumbnail_url ?? '',
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
113
|
+
if (node.children) {
|
|
114
|
+
for (const child of node.children) {
|
|
115
|
+
walkTree(child);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
walkTree(document);
|
|
120
|
+
this.components = Array.from(usedComponentMap.values());
|
|
121
|
+
/// ----
|
|
122
|
+
// const components = []
|
|
123
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
124
|
+
// const { meta } = await figmaApi.getFileComponentSets({ file_key: process.env.FIGMA_FILE_ID });
|
|
125
|
+
// // console.log(response);
|
|
126
|
+
//
|
|
127
|
+
// console.log('Component sets:', meta.component_sets); // ⬅️ Check this!
|
|
128
|
+
//
|
|
129
|
+
// const componentSetIds = meta.component_sets.map(componentSet => componentSet.node_id); // This must return valid Figma node IDs
|
|
130
|
+
//
|
|
131
|
+
// console.log('ComponentSet IDs:', componentSetIds);
|
|
132
|
+
//
|
|
133
|
+
// const fileNodes = await figmaApi.getFileNodes({
|
|
134
|
+
// file_key: process.env.FIGMA_FILE_ID,
|
|
135
|
+
// }, {
|
|
136
|
+
// ids: componentSetIds.join(','),
|
|
137
|
+
// });
|
|
138
|
+
//
|
|
139
|
+
// for (const node of Object.values(fileNodes.nodes)) {
|
|
140
|
+
// const componentSet = node.document;
|
|
141
|
+
//
|
|
142
|
+
// if (componentSet.type === 'COMPONENT_SET' && componentSet.children?.length) {
|
|
143
|
+
// const variants = componentSet.children;
|
|
144
|
+
// const firstVariant = variants[0]; // or apply filtering logic
|
|
145
|
+
//
|
|
146
|
+
// components.push({
|
|
147
|
+
// name: componentSet.name, // e.g. "Button"
|
|
148
|
+
// id: firstVariant.id, // this is the actual variant node
|
|
149
|
+
// variantName: firstVariant.name // e.g. "primary=true, size=md"
|
|
150
|
+
// });
|
|
151
|
+
// }
|
|
152
|
+
// }
|
|
153
|
+
//
|
|
154
|
+
// fs.writeFileSync('output.json', JSON.stringify(components, null, 2));
|
|
155
|
+
// if (Boolean(response)) {
|
|
156
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
157
|
+
// this.components = response.meta.component_sets.map(
|
|
158
|
+
// (component: { name: string; description: string; thumbnail_url: string }) => ({
|
|
159
|
+
// name: component.name,
|
|
160
|
+
// description: component.description,
|
|
161
|
+
// thumbnail_url: component.thumbnail_url,
|
|
162
|
+
// }),
|
|
163
|
+
// );
|
|
164
|
+
// }
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
console.error(e);
|
|
168
|
+
}
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
build() {
|
|
172
|
+
return this.components;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=FigmaComponentsBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FigmaComponentsBuilder.js","sourceRoot":"","sources":["../src/FigmaComponentsBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,KAAK,MAAM,WAAW,CAAC;AAEnC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,QAAQ,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC;IAC7B,mBAAmB,EAAE,OAAO,CAAC,GAAG,CAAC,oBAA8B;CAChE,CAAC,CAAC;AAkBH,MAAM,OAAO,sBAAsB;IAAnC;QACE,eAAU,GAAqB,EAAE,CAAC;IAoLpC,CAAC;IAlLC,KAAK,CAAC,mBAAmB;QACvB,IAAI,CAAC;YACH,mEAAmE;YACnE,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,CAAC;YAC3F,sEAAsE;YACtE,IAAI,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxC,sEAAsE;gBACtE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBACtE,gJAAgJ;gBAChJ,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAC5C,CAAC,SAAuE,EAAE,EAAE,CAAC,CAAC;oBAC5E,IAAI,EAAE,SAAS,CAAC,IAAI;oBACpB,WAAW,EAAE,SAAS,CAAC,WAAW;oBAClC,SA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EAA0E;YAC1E,uEAAuE;YACvE,UAAU;YACV,MAAM;YACN,IAAI;YACJ,EAAE;YACF,wEAAwE;YAExE,2BAA2B;YAC3B,qJAAqJ;YACrJ,wDAAwD;YACxD,sFAAsF;YACtF,8BAA8B;YAC9B,4CAA4C;YAC5C,gDAAgD;YAChD,UAAU;YACV,OAAO;YACP,IAAI;QACN,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { type CommandHandler, type Command, type Event } from '@auto-engineer/message-bus';
|
|
2
|
+
import { ImportStrategy } from '../index';
|
|
2
3
|
export type ImportDesignSystemCommand = Command<'ImportDesignSystem', {
|
|
3
|
-
inputDir: string;
|
|
4
4
|
outputDir: string;
|
|
5
|
+
strategy?: keyof typeof ImportStrategy;
|
|
6
|
+
filterPath?: string;
|
|
5
7
|
}>;
|
|
6
8
|
export type DesignSystemImportedEvent = Event<'DesignSystemImported', {
|
|
7
|
-
inputDir: string;
|
|
8
9
|
outputDir: string;
|
|
9
10
|
}>;
|
|
10
11
|
export type DesignSystemImportFailedEvent = Event<'DesignSystemImportFailed', {
|
|
11
12
|
error: string;
|
|
12
|
-
inputDir: string;
|
|
13
13
|
outputDir: string;
|
|
14
14
|
}>;
|
|
15
15
|
export declare function handleImportDesignSystemCommand(command: ImportDesignSystemCommand): Promise<DesignSystemImportedEvent | DesignSystemImportFailedEvent>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-design-system.d.ts","sourceRoot":"","sources":["../../src/commands/import-design-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"import-design-system.d.ts","sourceRoot":"","sources":["../../src/commands/import-design-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAyC,cAAc,EAA2B,MAAM,UAAU,CAAC;AAG1G,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAC7C,oBAAoB,EACpB;IACE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,OAAO,cAAc,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CACF,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,KAAK,CAC3C,sBAAsB,EACtB;IACE,SAAS,EAAE,MAAM,CAAC;CACnB,CACF,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,KAAK,CAC/C,0BAA0B,EAC1B;IACE,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CACF,CAAC;AAGF,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,yBAAyB,GAAG,6BAA6B,CAAC,CA8CpE;AAED,eAAO,MAAM,gCAAgC,EAAE,cAAc,CAAC,yBAAyB,CAUtF,CAAC"}
|
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { importDesignSystemComponentsFromFigma, ImportStrategy } from '../index.js';
|
|
2
|
+
import { FilterLoader } from '../utils/FilterLoader.js';
|
|
3
3
|
// Handler
|
|
4
4
|
export async function handleImportDesignSystemCommand(command) {
|
|
5
|
-
const {
|
|
5
|
+
const { outputDir, strategy, filterPath } = command.data;
|
|
6
6
|
try {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
requestId: command.requestId,
|
|
23
|
-
correlationId: command.correlationId,
|
|
24
|
-
};
|
|
7
|
+
const resolvedStrategy = strategy ? ImportStrategy[strategy] : ImportStrategy.WITH_COMPONENT_SETS;
|
|
8
|
+
let filterFn;
|
|
9
|
+
let loader;
|
|
10
|
+
if (typeof filterPath === 'string' && filterPath.trim().length > 0) {
|
|
11
|
+
try {
|
|
12
|
+
loader = new FilterLoader();
|
|
13
|
+
filterFn = await loader.loadFilter(filterPath);
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
console.warn(`Could not import filter from ${filterPath}. Skipping custom filter.`, e);
|
|
17
|
+
}
|
|
18
|
+
finally {
|
|
19
|
+
if (loader)
|
|
20
|
+
loader.cleanup();
|
|
21
|
+
}
|
|
25
22
|
}
|
|
26
|
-
await
|
|
27
|
-
console.log(`Design system files processed
|
|
23
|
+
await importDesignSystemComponentsFromFigma(outputDir, resolvedStrategy, filterFn);
|
|
24
|
+
console.log(`Design system files processed to ${outputDir}`);
|
|
28
25
|
return {
|
|
29
26
|
type: 'DesignSystemImported',
|
|
30
27
|
data: {
|
|
31
|
-
inputDir,
|
|
32
28
|
outputDir,
|
|
33
29
|
},
|
|
34
30
|
timestamp: new Date(),
|
|
@@ -43,7 +39,6 @@ export async function handleImportDesignSystemCommand(command) {
|
|
|
43
39
|
type: 'DesignSystemImportFailed',
|
|
44
40
|
data: {
|
|
45
41
|
error: errorMessage,
|
|
46
|
-
inputDir,
|
|
47
42
|
outputDir,
|
|
48
43
|
},
|
|
49
44
|
timestamp: new Date(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-design-system.js","sourceRoot":"","sources":["../../src/commands/import-design-system.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"import-design-system.js","sourceRoot":"","sources":["../../src/commands/import-design-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,OAAO,CAAC,aAAa;SACrC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;QAEvD,OAAO;YACL,IAAI,EAAE,0BAA0B;YAChC,IAAI,EAAE;gBACJ,KAAK,EAAE,YAAY;gBACnB,SAAS;aACV;YACD,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;SACrC,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,gCAAgC,GAA8C;IACzF,IAAI,EAAE,oBAAoB;IAC1B,MAAM,EAAE,KAAK,EAAE,OAAkC,EAAiB,EAAE;QAClE,MAAM,MAAM,GAAG,MAAM,+BAA+B,CAAC,OAAO,CAAC,CAAC;QAC9D,IAAI,MAAM,CAAC,IAAI,KAAK,sBAAsB,EAAE,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;QACrD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,WAAW,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
+
import { type FilterFunctionType } from './FigmaComponentsBuilder';
|
|
1
2
|
export declare function generateDesignSystemMarkdown(inputDir: string, outputDir: string): Promise<void>;
|
|
2
3
|
export * from './commands/import-design-system';
|
|
4
|
+
export type { FilterFunctionType } from './FigmaComponentsBuilder';
|
|
3
5
|
export declare function copyDesignSystemDocsAndUserPreferences(inputDir: string, outputDir: string): Promise<void>;
|
|
6
|
+
export declare function generateMarkdownFromComponents(components: {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
thumbnail: string;
|
|
10
|
+
}[]): string;
|
|
11
|
+
export declare enum ImportStrategy {
|
|
12
|
+
WITH_COMPONENTS = "WITH_COMPONENTS",
|
|
13
|
+
WITH_COMPONENT_SETS = "WITH_COMPONENT_SETS",
|
|
14
|
+
WITH_ALL_FIGMA_INSTANCES = "WITH_ALL_FIGMA_INSTANCES"
|
|
15
|
+
}
|
|
16
|
+
export declare function importDesignSystemComponentsFromFigma(outputDir: string, strategy?: ImportStrategy, filterFn?: FilterFunctionType): Promise<void>;
|
|
4
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AA+B3F,wBAAsB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBrG;AAED,cAAc,iCAAiC,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAiBnE,wBAAsB,sCAAsC,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2B/G;AAwBD,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAAE,GACrE,MAAM,CAYR;AAED,oBAAY,cAAc;IACxB,eAAe,oBAAoB;IACnC,mBAAmB,wBAAwB;IAC3C,wBAAwB,6BAA6B;CACtD;AAED,wBAAsB,qCAAqC,CACzD,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,cAAmD,EAC7D,QAAQ,CAAC,EAAE,kBAAkB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAwCf"}
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,14 @@ import * as path from 'path';
|
|
|
2
2
|
import * as fs from 'fs/promises';
|
|
3
3
|
import * as dotenv from 'dotenv';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
|
+
import * as Figma from 'figma-api';
|
|
6
|
+
import { FigmaComponentsBuilder } from './FigmaComponentsBuilder.js';
|
|
7
|
+
// import { AIProvider, generateTextWithAI } from '@auto-engineer/ai-gateway';
|
|
5
8
|
dotenv.config();
|
|
6
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const api = new Figma.Api({
|
|
11
|
+
personalAccessToken: process.env.FIGMA_PERSONAL_TOKEN,
|
|
12
|
+
});
|
|
7
13
|
async function getAllTsxFiles(dir) {
|
|
8
14
|
let results = [];
|
|
9
15
|
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
@@ -82,11 +88,84 @@ export async function copyDesignSystemDocsAndUserPreferences(inputDir, outputDir
|
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
90
|
}
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
92
|
+
async function getFigmaComponents() {
|
|
93
|
+
let components = [];
|
|
94
|
+
try {
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
96
|
+
const response = await api.getFileComponentSets({ file_key: process.env.FIGMA_FILE_ID });
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
98
|
+
components = response.meta.component_sets.map((component) => ({
|
|
99
|
+
name: component.name,
|
|
100
|
+
description: component.description,
|
|
101
|
+
thumbnail: component.thumbnail_url,
|
|
102
|
+
}));
|
|
103
|
+
console.log('figma response: ', response);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
console.error(e);
|
|
107
|
+
}
|
|
108
|
+
console.log(components.length);
|
|
109
|
+
return components;
|
|
110
|
+
}
|
|
111
|
+
export function generateMarkdownFromComponents(components) {
|
|
112
|
+
let md = '# Design System\n\n## Components\n\n';
|
|
113
|
+
if (components.length === 0) {
|
|
114
|
+
console.warn('No components found');
|
|
115
|
+
}
|
|
116
|
+
for (const component of components) {
|
|
117
|
+
md += `### ${component.name}\nDescription: ${component.description}\nImage: \n\n`;
|
|
118
|
+
}
|
|
119
|
+
return md;
|
|
120
|
+
}
|
|
121
|
+
export var ImportStrategy;
|
|
122
|
+
(function (ImportStrategy) {
|
|
123
|
+
ImportStrategy["WITH_COMPONENTS"] = "WITH_COMPONENTS";
|
|
124
|
+
ImportStrategy["WITH_COMPONENT_SETS"] = "WITH_COMPONENT_SETS";
|
|
125
|
+
ImportStrategy["WITH_ALL_FIGMA_INSTANCES"] = "WITH_ALL_FIGMA_INSTANCES";
|
|
126
|
+
})(ImportStrategy || (ImportStrategy = {}));
|
|
127
|
+
export async function importDesignSystemComponentsFromFigma(outputDir, strategy = ImportStrategy.WITH_COMPONENT_SETS, filterFn) {
|
|
128
|
+
const figmaComponentsBuilder = new FigmaComponentsBuilder();
|
|
129
|
+
if (strategy === ImportStrategy.WITH_COMPONENTS) {
|
|
130
|
+
await figmaComponentsBuilder.withFigmaComponents();
|
|
131
|
+
}
|
|
132
|
+
else if (strategy === ImportStrategy.WITH_COMPONENT_SETS) {
|
|
133
|
+
await figmaComponentsBuilder.withFigmaComponentSets();
|
|
134
|
+
}
|
|
135
|
+
else if (strategy === ImportStrategy.WITH_ALL_FIGMA_INSTANCES) {
|
|
136
|
+
await figmaComponentsBuilder.withAllFigmaInstanceNames();
|
|
137
|
+
}
|
|
138
|
+
// figmaComponentsBuilder.withFilteredNamesForMui();
|
|
139
|
+
// figmaComponentsBuilder.withFilteredNamesForShadcn();
|
|
140
|
+
if (filterFn) {
|
|
141
|
+
figmaComponentsBuilder.withFilter(filterFn);
|
|
142
|
+
}
|
|
143
|
+
const figmaComponents = figmaComponentsBuilder.build();
|
|
144
|
+
console.log(figmaComponents.length);
|
|
145
|
+
const generatedComponentsMDFile = generateMarkdownFromComponents(figmaComponents);
|
|
146
|
+
// const mdWithImageAnalysis = await generateTextWithAI(
|
|
147
|
+
// `
|
|
148
|
+
// Given this markdown file content:
|
|
149
|
+
// ${generatedComponentsMDFile}
|
|
150
|
+
//
|
|
151
|
+
// ------ INSTRUCTIONS -------
|
|
152
|
+
// !IMPORTANT: Only return with Markdown content, nothing else, I will be putting this straight in a .md file. Don't even start the file with \`\`\`markdown
|
|
153
|
+
// For every component Image: Analyze the given image and add to the given component.
|
|
154
|
+
// - add more content to the "Description:" part of the component.
|
|
155
|
+
// - add "Hierarchy:" part under the component, returning the parts a component is build of. like [Button, Input]
|
|
156
|
+
// `,
|
|
157
|
+
// AIProvider.OpenAI,
|
|
158
|
+
// { temperature: 0.2, maxTokens: 8000 },
|
|
159
|
+
// );
|
|
160
|
+
// await fs.mkdir(outputDir, { recursive: true });
|
|
161
|
+
const outPath = path.join(outputDir, 'design-system.md');
|
|
162
|
+
await fs.writeFile(outPath, generatedComponentsMDFile);
|
|
163
|
+
}
|
|
85
164
|
// Check if this file is being run directly
|
|
86
165
|
if (process.argv[1] === __filename) {
|
|
87
|
-
const [, ,
|
|
88
|
-
if (!
|
|
89
|
-
console.error('Usage: tsx src/index.ts <
|
|
166
|
+
const [, , outputDir] = process.argv;
|
|
167
|
+
if (!outputDir) {
|
|
168
|
+
console.error('Usage: tsx src/index.ts <outputDir>');
|
|
90
169
|
process.exit(1);
|
|
91
170
|
}
|
|
92
171
|
// generateDesignSystemMarkdown(inputDir, outputDir)
|
|
@@ -97,12 +176,20 @@ if (process.argv[1] === __filename) {
|
|
|
97
176
|
// console.error('Error generating design-system.md:', err);
|
|
98
177
|
// process.exit(1);
|
|
99
178
|
// });
|
|
100
|
-
copyDesignSystemDocsAndUserPreferences(inputDir, outputDir)
|
|
179
|
+
// copyDesignSystemDocsAndUserPreferences(inputDir, outputDir)
|
|
180
|
+
// .then(() => {
|
|
181
|
+
// console.log(`design-system.md copied to ${outputDir}`);
|
|
182
|
+
// })
|
|
183
|
+
// .catch((err) => {
|
|
184
|
+
// console.error('Error copying design-system.md:', err);
|
|
185
|
+
// process.exit(1);
|
|
186
|
+
// });
|
|
187
|
+
importDesignSystemComponentsFromFigma(outputDir)
|
|
101
188
|
.then(() => {
|
|
102
|
-
console.log(`design-system.md
|
|
189
|
+
console.log(`design-system.md generated to ${outputDir}`);
|
|
103
190
|
})
|
|
104
191
|
.catch((err) => {
|
|
105
|
-
console.error('Error
|
|
192
|
+
console.error('Error generating design-system.md:', err);
|
|
106
193
|
process.exit(1);
|
|
107
194
|
});
|
|
108
195
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAA2B,MAAM,0BAA0B,CAAC;AAC3F,8EAA8E;AAE9E,MAAM,CAAC,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AED,2CAA2C;AAC3C,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE,CAAC;IACnC,MAAM,CAAC,EAAE,AAAD,EAAG,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IACrC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,oDAAoD;IACpD,kBAAkB;IAClB,iEAAiE;IACjE,OAAO;IACP,sBAAsB;IACtB,gEAAgE;IAChE,uBAAuB;IACvB,QAAQ;IACR,8DAA8D;IAC9D,kBAAkB;IAClB,8DAA8D;IAC9D,OAAO;IACP,sBAAsB;IACtB,6DAA6D;IAC7D,uBAAuB;IACvB,QAAQ;IACR,qCAAqC,CAAC,SAAS,CAAC;SAC7C,IAAI,CAAC,GAAG,EAAE;QACT,OAAO,CAAC,GAAG,CAAC,iCAAiC,SAAS,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FilterFunctionType } from '../FigmaComponentsBuilder';
|
|
2
|
+
export declare class FilterLoader {
|
|
3
|
+
private tsxRegistered;
|
|
4
|
+
private tsxUnregister;
|
|
5
|
+
loadFilter(filePath: string): Promise<FilterFunctionType>;
|
|
6
|
+
private ensureTsxSupport;
|
|
7
|
+
cleanup(): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=FilterLoader.d.ts.map
|