@auto-engineer/design-system-importer 0.11.2 → 0.11.3
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 +6 -0
- package/.turbo/turbo-format.log +4 -0
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +15 -0
- package/.turbo/turbo-type-check.log +5 -0
- package/CHANGELOG.md +7 -0
- package/dist/src/FigmaComponentsBuilder.d.ts +17 -0
- package/dist/src/FigmaComponentsBuilder.d.ts.map +1 -0
- package/dist/src/FigmaComponentsBuilder.js +287 -0
- package/dist/src/FigmaComponentsBuilder.js.map +1 -0
- package/dist/src/commands/import-design-system.d.ts +27 -0
- package/dist/src/commands/import-design-system.d.ts.map +1 -0
- package/dist/src/commands/import-design-system.js +126 -0
- package/dist/src/commands/import-design-system.js.map +1 -0
- package/dist/src/figma-api.d.ts +6 -0
- package/dist/src/figma-api.d.ts.map +1 -0
- package/dist/src/figma-api.js +38 -0
- package/dist/src/figma-api.js.map +1 -0
- package/dist/src/figma-importer.d.ts +8 -0
- package/dist/src/figma-importer.d.ts.map +1 -0
- package/dist/src/figma-importer.js +79 -0
- package/dist/src/figma-importer.js.map +1 -0
- package/dist/src/file-operations.d.ts +4 -0
- package/dist/src/file-operations.d.ts.map +1 -0
- package/dist/src/file-operations.js +102 -0
- package/dist/src/file-operations.js.map +1 -0
- package/dist/src/index.d.ts +16 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +8 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/markdown-generator.d.ts +7 -0
- package/dist/src/markdown-generator.d.ts.map +1 -0
- package/dist/src/markdown-generator.js +44 -0
- package/dist/src/markdown-generator.js.map +1 -0
- package/dist/src/utils/FilterLoader.d.ts +13 -0
- package/dist/src/utils/FilterLoader.d.ts.map +1 -0
- package/dist/src/utils/FilterLoader.js +250 -0
- package/dist/src/utils/FilterLoader.js.map +1 -0
- package/dist/src/utils/templates/tsx-export.mjs +17 -0
- package/dist/src/utils/templates/tsx-final-loader.mjs +10 -0
- package/dist/src/utils/templates/tsx-loader.mjs +48 -0
- package/dist/src/utils/templates/tsx-wrapper.mjs +15 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +3 -3
- package/src/FigmaComponentsBuilder.ts +5 -5
- package/src/commands/import-design-system.ts +4 -4
- package/src/figma-api.ts +1 -1
- package/src/figma-importer.ts +4 -4
- package/src/file-operations.ts +3 -3
- package/src/markdown-generator.ts +1 -1
- package/src/utils/FilterLoader.ts +5 -5
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs/promises';
|
|
3
|
+
import createDebug from 'debug';
|
|
4
|
+
import { generateMarkdownFromComponents } from './markdown-generator.js';
|
|
5
|
+
const debug = createDebug('auto:design-system-importer');
|
|
6
|
+
const debugComponents = createDebug('auto:design-system-importer:components');
|
|
7
|
+
const debugMarkdown = createDebug('auto:design-system-importer:markdown');
|
|
8
|
+
const debugFiles = createDebug('auto:design-system-importer:files');
|
|
9
|
+
export var ImportStrategy;
|
|
10
|
+
(function (ImportStrategy) {
|
|
11
|
+
ImportStrategy["WITH_COMPONENTS"] = "WITH_COMPONENTS";
|
|
12
|
+
ImportStrategy["WITH_COMPONENT_SETS"] = "WITH_COMPONENT_SETS";
|
|
13
|
+
ImportStrategy["WITH_ALL_FIGMA_INSTANCES"] = "WITH_ALL_FIGMA_INSTANCES";
|
|
14
|
+
})(ImportStrategy || (ImportStrategy = {}));
|
|
15
|
+
export async function importDesignSystemComponentsFromFigma(outputDir, strategy = ImportStrategy.WITH_COMPONENT_SETS, filterFn) {
|
|
16
|
+
debug('Starting Figma design system import');
|
|
17
|
+
debug('Output directory: %s', outputDir);
|
|
18
|
+
debug('Import strategy: %s', strategy);
|
|
19
|
+
debug('Filter function provided: %s', filterFn ? 'yes' : 'no');
|
|
20
|
+
// const figmaComponentsBuilder = new FigmaComponentsBuilder();
|
|
21
|
+
// debugComponents('FigmaComponentsBuilder instance created');
|
|
22
|
+
// if (strategy === ImportStrategy.WITH_COMPONENTS) {
|
|
23
|
+
// debugComponents('Using strategy: WITH_COMPONENTS');
|
|
24
|
+
// await figmaComponentsBuilder.withFigmaComponents();
|
|
25
|
+
// } else if (strategy === ImportStrategy.WITH_COMPONENT_SETS) {
|
|
26
|
+
// debugComponents('Using strategy: WITH_COMPONENT_SETS');
|
|
27
|
+
// await figmaComponentsBuilder.withFigmaComponentSets();
|
|
28
|
+
// } else if (strategy === ImportStrategy.WITH_ALL_FIGMA_INSTANCES) {
|
|
29
|
+
// debugComponents('Using strategy: WITH_ALL_FIGMA_INSTANCES');
|
|
30
|
+
// await figmaComponentsBuilder.withAllFigmaInstanceNames();
|
|
31
|
+
// }
|
|
32
|
+
debugComponents('Strategy applied successfully');
|
|
33
|
+
// figmaComponentsBuilder.withFilteredNamesForMui();
|
|
34
|
+
// figmaComponentsBuilder.withFilteredNamesForShadcn();
|
|
35
|
+
let figmaComponents = [];
|
|
36
|
+
if (filterFn) {
|
|
37
|
+
debugComponents('Applying custom filter function');
|
|
38
|
+
// figmaComponentsBuilder.withFilter(filterFn);
|
|
39
|
+
const absolutePath = path.resolve(outputDir, 'figma-file.json');
|
|
40
|
+
const rawFigmaFile = await fs.readFile(absolutePath, 'utf-8');
|
|
41
|
+
const parsedFile = JSON.parse(rawFigmaFile);
|
|
42
|
+
const nodes = parsedFile.root;
|
|
43
|
+
figmaComponents = filterFn(nodes);
|
|
44
|
+
}
|
|
45
|
+
debugComponents('Building Figma components...');
|
|
46
|
+
// const figmaComponents = figmaComponentsBuilder.build();
|
|
47
|
+
debugComponents('Built %d Figma components', figmaComponents.length);
|
|
48
|
+
console.log(figmaComponents.length);
|
|
49
|
+
debugMarkdown('Generating markdown from Figma components');
|
|
50
|
+
const generatedComponentsMDFile = generateMarkdownFromComponents(figmaComponents);
|
|
51
|
+
debugMarkdown('Markdown generated, size: %d bytes', generatedComponentsMDFile.length);
|
|
52
|
+
// const mdWithImageAnalysis = await generateTextWithAI(
|
|
53
|
+
// `
|
|
54
|
+
// Given this markdown file content:
|
|
55
|
+
// ${generatedComponentsMDFile}
|
|
56
|
+
//
|
|
57
|
+
// ------ INSTRUCTIONS -------
|
|
58
|
+
// !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
|
|
59
|
+
// For every component Image: Analyze the given image and add to the given component.
|
|
60
|
+
// - add more content to the "Description:" part of the component.
|
|
61
|
+
// - add "Hierarchy:" part under the component, returning the parts a component is build of. like [Button, Input]
|
|
62
|
+
// `,
|
|
63
|
+
// undefined,
|
|
64
|
+
// { temperature: 0.2, maxTokens: 8000 },
|
|
65
|
+
// );
|
|
66
|
+
// await fs.mkdir(outputDir, { recursive: true });
|
|
67
|
+
// Parse the outputDir to determine if it's a file path or directory
|
|
68
|
+
const isFilePath = outputDir.endsWith('.md');
|
|
69
|
+
const actualOutputDir = isFilePath ? path.dirname(outputDir) : outputDir;
|
|
70
|
+
const fileName = isFilePath ? path.basename(outputDir) : 'design-system.md';
|
|
71
|
+
debugFiles('Creating output directory: %s', actualOutputDir);
|
|
72
|
+
await fs.mkdir(actualOutputDir, { recursive: true });
|
|
73
|
+
const outPath = path.join(actualOutputDir, fileName);
|
|
74
|
+
debugFiles('Writing markdown to: %s', outPath);
|
|
75
|
+
await fs.writeFile(outPath, generatedComponentsMDFile);
|
|
76
|
+
debugFiles('Design system markdown written successfully');
|
|
77
|
+
debug('Figma design system import complete');
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=figma-importer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figma-importer.js","sourceRoot":"","sources":["../../src/figma-importer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,WAAW,MAAM,OAAO,CAAC;AAEh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AAE,IAAI,EAAE,CAAC,CAAC;IAErD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;IACrD,UAAU,CAAC,yBAAyB,EAAE,OAAO,CAAC,CAAC;IAC/C,MAAM,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC;IACvD,UAAU,CAAC,6CAA6C,CAAC,CAAC;IAE1D,KAAK,CAAC,qCAAqC,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function getAllTsxFiles(dir: string): Promise<string[]>;
|
|
2
|
+
export declare function getComponentNameFromFile(filePath: string): string;
|
|
3
|
+
export declare function copyDesignSystemDocsAndUserPreferences(inputDir: string, outputDir: string): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=file-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-operations.d.ts","sourceRoot":"","sources":["../../src/file-operations.ts"],"names":[],"mappings":"AAQA,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA0BnE;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOjE;AAwBD,wBAAsB,sCAAsC,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA6C/G"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs/promises';
|
|
3
|
+
import createDebug from 'debug';
|
|
4
|
+
const debugFiles = createDebug('auto:design-system-importer:files');
|
|
5
|
+
const debugComponents = createDebug('auto:design-system-importer:components');
|
|
6
|
+
const debugCopy = createDebug('auto:design-system-importer:copy');
|
|
7
|
+
export async function getAllTsxFiles(dir) {
|
|
8
|
+
debugFiles('Scanning directory for TSX files: %s', dir);
|
|
9
|
+
let results = [];
|
|
10
|
+
try {
|
|
11
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
12
|
+
debugFiles('Found %d entries in %s', entries.length, dir);
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
const fullPath = path.join(dir, entry.name);
|
|
15
|
+
if (entry.isDirectory()) {
|
|
16
|
+
debugFiles('Entering subdirectory: %s', entry.name);
|
|
17
|
+
const subResults = await getAllTsxFiles(fullPath);
|
|
18
|
+
results = results.concat(subResults);
|
|
19
|
+
debugFiles('Found %d TSX files in %s', subResults.length, entry.name);
|
|
20
|
+
}
|
|
21
|
+
else if (entry.isFile() && entry.name.endsWith('.tsx')) {
|
|
22
|
+
debugFiles('Found TSX file: %s', entry.name);
|
|
23
|
+
results.push(fullPath);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
debugFiles('Error reading directory %s: %O', dir, error);
|
|
29
|
+
}
|
|
30
|
+
debugFiles('Total TSX files found in %s: %d', dir, results.length);
|
|
31
|
+
return results;
|
|
32
|
+
}
|
|
33
|
+
export function getComponentNameFromFile(filePath) {
|
|
34
|
+
debugComponents('Extracting component name from: %s', filePath);
|
|
35
|
+
const file = path.basename(filePath, '.tsx');
|
|
36
|
+
// Capitalize first letter
|
|
37
|
+
const componentName = file.charAt(0).toUpperCase() + file.slice(1);
|
|
38
|
+
debugComponents('Component name: %s', componentName);
|
|
39
|
+
return componentName;
|
|
40
|
+
}
|
|
41
|
+
async function copyFile(inputDir, outputDir, file) {
|
|
42
|
+
const srcPath = path.join(inputDir, file);
|
|
43
|
+
const destPath = path.join(outputDir, file);
|
|
44
|
+
debugCopy('Attempting to copy file: %s from %s to %s', file, inputDir, outputDir);
|
|
45
|
+
// Check if source file exists
|
|
46
|
+
try {
|
|
47
|
+
await fs.access(srcPath);
|
|
48
|
+
debugCopy('Source file exists: %s', srcPath);
|
|
49
|
+
debugCopy('Creating output directory: %s', outputDir);
|
|
50
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
51
|
+
await fs.copyFile(srcPath, destPath);
|
|
52
|
+
debugCopy('Successfully copied %s to %s', file, destPath);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
// File doesn't exist, skip copying
|
|
56
|
+
debugCopy('File %s not found in %s, error: %O', file, inputDir, error);
|
|
57
|
+
console.log(`File ${file} not found in ${inputDir}, skipping...`, error);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export async function copyDesignSystemDocsAndUserPreferences(inputDir, outputDir) {
|
|
61
|
+
debugCopy('Copying design system docs from %s to %s', inputDir, outputDir);
|
|
62
|
+
// Ensure output directory exists
|
|
63
|
+
debugCopy('Creating output directory: %s', outputDir);
|
|
64
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
65
|
+
// Try to copy existing files
|
|
66
|
+
debugCopy('Copying design-system.md...');
|
|
67
|
+
await copyFile(inputDir, outputDir, 'design-system.md');
|
|
68
|
+
debugCopy('Copying design-system-principles.md...');
|
|
69
|
+
await copyFile(inputDir, outputDir, 'design-system-principles.md');
|
|
70
|
+
// If design-system.md doesn't exist in output, try to generate it from TSX files
|
|
71
|
+
const designSystemPath = path.join(outputDir, 'design-system.md');
|
|
72
|
+
debugCopy('Checking if design-system.md exists at: %s', designSystemPath);
|
|
73
|
+
try {
|
|
74
|
+
await fs.access(designSystemPath);
|
|
75
|
+
debugCopy('design-system.md already exists');
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
debugCopy('design-system.md does not exist, attempting to generate from TSX files');
|
|
79
|
+
// File doesn't exist, try to generate from TSX files if inputDir exists
|
|
80
|
+
try {
|
|
81
|
+
await fs.access(inputDir);
|
|
82
|
+
debugCopy('Input directory is accessible: %s', inputDir);
|
|
83
|
+
const { generateDesignSystemMarkdown } = await import('./markdown-generator.js');
|
|
84
|
+
const files = await getAllTsxFiles(inputDir);
|
|
85
|
+
if (files.length > 0) {
|
|
86
|
+
debugCopy('Found %d TSX files, generating design-system.md', files.length);
|
|
87
|
+
await generateDesignSystemMarkdown(inputDir, outputDir);
|
|
88
|
+
console.log(`Generated design-system.md from ${files.length} component files`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
debugCopy('No TSX files found in %s', inputDir);
|
|
92
|
+
console.log(`No .tsx files found in ${inputDir} to generate design-system.md`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
debugCopy('Input directory %s not accessible: %O', inputDir, error);
|
|
97
|
+
console.log(`Input directory ${inputDir} not accessible`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
debugCopy('Design system docs copy/generation complete');
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=file-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-operations.js","sourceRoot":"","sources":["../../src/file-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,WAAW,MAAM,OAAO,CAAC;AAEhC,MAAM,UAAU,GAAG,WAAW,CAAC,mCAAmC,CAAC,CAAC;AACpE,MAAM,eAAe,GAAG,WAAW,CAAC,wCAAwC,CAAC,CAAC;AAC9E,MAAM,SAAS,GAAG,WAAW,CAAC,kCAAkC,CAAC,CAAC;AAElE,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAW;IAC9C,UAAU,CAAC,sCAAsC,EAAE,GAAG,CAAC,CAAC;IACxD,IAAI,OAAO,GAAa,EAAE,CAAC;IAE3B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,UAAU,CAAC,wBAAwB,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAE1D,KAAK,MAAM,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CAAC;gBACN,SAAS,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAC;gBAChD,OAAO,CAAC,GAAG,CAAC,0BAA0B,QAAQ,+BAA+B,CAAC,CAAC;YACjF,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,SAAS,CAAC,uCAAuC,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;YACpE,OAAO,CAAC,GAAG,CAAC,mBAAmB,QAAQ,iBAAiB,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,SAAS,CAAC,6CAA6C,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { generateDesignSystemMarkdown } from './markdown-generator.js';
|
|
2
|
+
export { copyDesignSystemDocsAndUserPreferences } from './file-operations.js';
|
|
3
|
+
export { importDesignSystemComponentsFromFigma, ImportStrategy } from './figma-importer.js';
|
|
4
|
+
export type { FilterFunctionType } from './FigmaComponentsBuilder.js';
|
|
5
|
+
export declare const COMMANDS: import("@auto-engineer/message-bus").UnifiedCommandHandler<Readonly<{
|
|
6
|
+
type: "ImportDesignSystem";
|
|
7
|
+
data: Readonly<{
|
|
8
|
+
outputDir: string;
|
|
9
|
+
strategy?: keyof typeof import("./figma-importer.js").ImportStrategy;
|
|
10
|
+
filterPath?: string;
|
|
11
|
+
}>;
|
|
12
|
+
timestamp?: Date;
|
|
13
|
+
requestId?: string;
|
|
14
|
+
correlationId?: string;
|
|
15
|
+
}>>[];
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,sCAAsC,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,qCAAqC,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC5F,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAItE,eAAO,MAAM,QAAQ;;;;;;;;;;KAA8B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Barrel exports
|
|
2
|
+
export { generateDesignSystemMarkdown } from './markdown-generator.js';
|
|
3
|
+
export { copyDesignSystemDocsAndUserPreferences } from './file-operations.js';
|
|
4
|
+
export { importDesignSystemComponentsFromFigma, ImportStrategy } from './figma-importer.js';
|
|
5
|
+
// Command exports
|
|
6
|
+
import importDesignSystemHandler from './commands/import-design-system.js';
|
|
7
|
+
export const COMMANDS = [importDesignSystemHandler];
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,sCAAsC,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,qCAAqC,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG5F,kBAAkB;AAClB,OAAO,yBAAyB,MAAM,oCAAoC,CAAC;AAC3E,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,yBAAyB,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function generateDesignSystemMarkdown(inputDir: string, outputDir: string): Promise<void>;
|
|
2
|
+
export declare function generateMarkdownFromComponents(components: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
thumbnail: string;
|
|
6
|
+
}[]): string;
|
|
7
|
+
//# sourceMappingURL=markdown-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-generator.d.ts","sourceRoot":"","sources":["../../src/markdown-generator.ts"],"names":[],"mappings":"AAOA,wBAAsB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BrG;AAED,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAAE,GACrE,MAAM,CAiBR"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs/promises';
|
|
3
|
+
import createDebug from 'debug';
|
|
4
|
+
import { getAllTsxFiles, getComponentNameFromFile } from './file-operations.js';
|
|
5
|
+
const debugMarkdown = createDebug('auto:design-system-importer:markdown');
|
|
6
|
+
export async function generateDesignSystemMarkdown(inputDir, outputDir) {
|
|
7
|
+
debugMarkdown('Generating design system markdown from: %s to: %s', inputDir, outputDir);
|
|
8
|
+
const files = await getAllTsxFiles(inputDir);
|
|
9
|
+
if (files.length === 0) {
|
|
10
|
+
debugMarkdown('WARNING: No .tsx files found in input directory');
|
|
11
|
+
console.warn('No .tsx files found in input directory.');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
debugMarkdown('Processing %d TSX files', files.length);
|
|
15
|
+
const componentNames = files.map(getComponentNameFromFile).sort();
|
|
16
|
+
debugMarkdown('Found %d unique components', componentNames.length);
|
|
17
|
+
let md = '# Design System\n\n## Components\n\n';
|
|
18
|
+
for (const name of componentNames) {
|
|
19
|
+
md += `- ${name}\n`;
|
|
20
|
+
debugMarkdown('Added component to markdown: %s', name);
|
|
21
|
+
}
|
|
22
|
+
debugMarkdown('Creating output directory: %s', outputDir);
|
|
23
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
24
|
+
const outPath = path.join(outputDir, 'design-system.md');
|
|
25
|
+
debugMarkdown('Writing markdown to: %s', outPath);
|
|
26
|
+
await fs.writeFile(outPath, md);
|
|
27
|
+
debugMarkdown('Markdown file written successfully, size: %d bytes', md.length);
|
|
28
|
+
}
|
|
29
|
+
export function generateMarkdownFromComponents(components) {
|
|
30
|
+
debugMarkdown('Generating markdown from %d components', components.length);
|
|
31
|
+
let md = '# Design System\n\n## Components\n\n';
|
|
32
|
+
if (components.length === 0) {
|
|
33
|
+
debugMarkdown('WARNING: No components found to generate markdown');
|
|
34
|
+
console.warn('No components found');
|
|
35
|
+
}
|
|
36
|
+
for (const [index, component] of components.entries()) {
|
|
37
|
+
debugMarkdown('Processing component %d/%d: %s', index + 1, components.length, component.name);
|
|
38
|
+
md += `### ${component.name}\nDescription: ${component.description}\nImage: \n\n`;
|
|
39
|
+
debugMarkdown('Added component %s with description length: %d', component.name, component.description.length);
|
|
40
|
+
}
|
|
41
|
+
debugMarkdown('Generated markdown document, total size: %d bytes', md.length);
|
|
42
|
+
return md;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=markdown-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-generator.js","sourceRoot":"","sources":["../../src/markdown-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,WAAW,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhF,MAAM,aAAa,GAAG,WAAW,CAAC,sCAAsC,CAAC,CAAC;AAE1E,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,QAAgB,EAAE,SAAiB;IACpF,aAAa,CAAC,mDAAmD,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAExF,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,aAAa,CAAC,iDAAiD,CAAC,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,yCAAyC,CAAC,C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C;QACtD,aAAa,CAAC,gCAAgC,EAAE,KAAK,GAAG,CAAC,EAAE,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9F,EAAE,IAAI,OAAO,SAAS,CAAC,IAAI,kBAAkB,SAAS,CAAC,WAAW,cAAc,SAAS,CAAC,IAAI,WAAW,SAAS,CAAC,SAAS,OAAO,CAAC;QACpI,aAAa,CAAC,gDAAgD,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAChH,CAAC;IAED,aAAa,CAAC,mDAAmD,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IAC9E,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FilterFunctionType } from '../FigmaComponentsBuilder';
|
|
2
|
+
export declare class FilterLoader {
|
|
3
|
+
private templatesDir;
|
|
4
|
+
constructor();
|
|
5
|
+
loadFilter(filePath: string): Promise<FilterFunctionType>;
|
|
6
|
+
private loadTypeScriptFilter;
|
|
7
|
+
private tryNodeDirectLoad;
|
|
8
|
+
private tryNpxTsxExport;
|
|
9
|
+
private tryNodeLoaderOptions;
|
|
10
|
+
private prepareTemplate;
|
|
11
|
+
cleanup(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=FilterLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterLoader.d.ts","sourceRoot":"","sources":["../../../src/utils/FilterLoader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AASpE,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAAS;;IAUvB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAiDjD,oBAAoB;YAuDpB,iBAAiB;YAgCjB,eAAe;YAyCf,oBAAoB;IAwClC,OAAO,CAAC,eAAe;IAsCvB,OAAO,IAAI,IAAI;CAIhB"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { extname, resolve as resolvePath, dirname, join } from 'path';
|
|
2
|
+
import { pathToFileURL, fileURLToPath } from 'url';
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync, mkdtempSync, rmSync } from 'fs';
|
|
4
|
+
import { spawnSync } from 'child_process';
|
|
5
|
+
import { tmpdir } from 'os';
|
|
6
|
+
import createDebug from 'debug';
|
|
7
|
+
const debug = createDebug('auto:design-system-importer:filter-loader');
|
|
8
|
+
const debugLoad = createDebug('auto:design-system-importer:filter-loader:load');
|
|
9
|
+
const debugTS = createDebug('auto:design-system-importer:filter-loader:typescript');
|
|
10
|
+
const debugStrategy = createDebug('auto:design-system-importer:filter-loader:strategy');
|
|
11
|
+
const debugTemplate = createDebug('auto:design-system-importer:filter-loader:template');
|
|
12
|
+
export class FilterLoader {
|
|
13
|
+
constructor() {
|
|
14
|
+
debug('FilterLoader instance created');
|
|
15
|
+
// Get the directory where template files are stored
|
|
16
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
17
|
+
this.templatesDir = join(dirname(currentFile), 'templates');
|
|
18
|
+
debug('Templates directory: %s', this.templatesDir);
|
|
19
|
+
}
|
|
20
|
+
async loadFilter(filePath) {
|
|
21
|
+
debugLoad('Loading filter from: %s', filePath);
|
|
22
|
+
if (typeof filePath !== 'string' || filePath.trim().length === 0) {
|
|
23
|
+
debugLoad('ERROR: Invalid filter path provided');
|
|
24
|
+
throw new Error('Filter file path is required');
|
|
25
|
+
}
|
|
26
|
+
const absolutePath = resolvePath(process.cwd(), filePath);
|
|
27
|
+
debugLoad('Resolved absolute path: %s', absolutePath);
|
|
28
|
+
if (!existsSync(absolutePath)) {
|
|
29
|
+
debugLoad('ERROR: Filter file not found at %s', absolutePath);
|
|
30
|
+
throw new Error(`Filter file not found: ${absolutePath}`);
|
|
31
|
+
}
|
|
32
|
+
const ext = extname(absolutePath).toLowerCase();
|
|
33
|
+
debugLoad('File extension: %s', ext);
|
|
34
|
+
// For TypeScript files, use tsx to load them
|
|
35
|
+
if (ext === '.ts' || ext === '.tsx') {
|
|
36
|
+
debugLoad('Detected TypeScript file, using TypeScript loader');
|
|
37
|
+
return this.loadTypeScriptFilter(absolutePath);
|
|
38
|
+
}
|
|
39
|
+
// For JavaScript files, load directly
|
|
40
|
+
debugLoad('Loading JavaScript file directly');
|
|
41
|
+
const fileUrl = pathToFileURL(absolutePath).href;
|
|
42
|
+
debugLoad('File URL: %s', fileUrl);
|
|
43
|
+
const loadedUnknown = await import(fileUrl);
|
|
44
|
+
const loadedModule = loadedUnknown;
|
|
45
|
+
debugLoad('Module loaded, checking for filter function');
|
|
46
|
+
if (typeof loadedModule.filter === 'function') {
|
|
47
|
+
debugLoad('Found named export "filter"');
|
|
48
|
+
return loadedModule.filter;
|
|
49
|
+
}
|
|
50
|
+
if (typeof loadedModule.default === 'function') {
|
|
51
|
+
debugLoad('Found default export, using as filter');
|
|
52
|
+
console.warn('Using default export from filter module. Prefer a named export "filter".');
|
|
53
|
+
return loadedModule.default;
|
|
54
|
+
}
|
|
55
|
+
debugLoad('ERROR: No filter function found in module');
|
|
56
|
+
throw new Error('No filter function found. Export a function named "filter" or as a default export from the file.');
|
|
57
|
+
}
|
|
58
|
+
async loadTypeScriptFilter(filePath) {
|
|
59
|
+
debugTS('Loading TypeScript filter from: %s', filePath);
|
|
60
|
+
// Create a temporary directory for our scripts
|
|
61
|
+
const tempDir = mkdtempSync(join(tmpdir(), 'tsx-filter-'));
|
|
62
|
+
debugTS('Created temp directory: %s', tempDir);
|
|
63
|
+
try {
|
|
64
|
+
const filterUrl = pathToFileURL(filePath).href;
|
|
65
|
+
debugTS('Filter URL: %s', filterUrl);
|
|
66
|
+
// Try different loading strategies in order
|
|
67
|
+
const strategies = [
|
|
68
|
+
() => this.tryNodeDirectLoad(tempDir, filterUrl),
|
|
69
|
+
() => this.tryNpxTsxExport(tempDir, filterUrl),
|
|
70
|
+
() => this.tryNodeLoaderOptions(tempDir, filterUrl),
|
|
71
|
+
];
|
|
72
|
+
debugTS('Will try %d loading strategies', strategies.length);
|
|
73
|
+
for (let i = 0; i < strategies.length; i++) {
|
|
74
|
+
debugTS('Trying strategy %d/%d', i + 1, strategies.length);
|
|
75
|
+
const result = await strategies[i]();
|
|
76
|
+
if (result) {
|
|
77
|
+
debugTS('Strategy %d succeeded!', i + 1);
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
debugTS('Strategy %d failed, trying next...', i + 1);
|
|
81
|
+
}
|
|
82
|
+
debugTS('ERROR: All strategies failed to load TypeScript filter');
|
|
83
|
+
throw new Error(`TypeScript filter cannot be loaded. ` +
|
|
84
|
+
`Please ensure tsx is installed in your project:\n` +
|
|
85
|
+
` npm install -D tsx\n` +
|
|
86
|
+
`Or provide a JavaScript version of your filter.`);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
debugTS('ERROR: Failed to load TypeScript filter: %O', error);
|
|
90
|
+
throw new Error(`Failed to load TypeScript filter.\n` +
|
|
91
|
+
`Error: ${error instanceof Error ? error.message : String(error)}\n` +
|
|
92
|
+
`Please ensure tsx is installed locally: npm install -D tsx`);
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
debugTS('Cleaning up temp directory: %s', tempDir);
|
|
96
|
+
// Clean up temp files
|
|
97
|
+
try {
|
|
98
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
99
|
+
debugTS('Temp directory cleaned up successfully');
|
|
100
|
+
}
|
|
101
|
+
catch (cleanupError) {
|
|
102
|
+
debugTS('Warning: Failed to clean up temp directory: %O', cleanupError);
|
|
103
|
+
// Ignore cleanup errors
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async tryNodeDirectLoad(tempDir, filterUrl) {
|
|
108
|
+
debugStrategy('Strategy: Node direct load');
|
|
109
|
+
// First attempt: Try to run the loader script with Node.js directly
|
|
110
|
+
const loaderFile = this.prepareTemplate(tempDir, 'tsx-loader.mjs', filterUrl);
|
|
111
|
+
debugStrategy('Prepared loader file: %s', loaderFile);
|
|
112
|
+
debugStrategy('Spawning node with experimental loader...');
|
|
113
|
+
const result = spawnSync('node', [loaderFile], {
|
|
114
|
+
cwd: process.cwd(),
|
|
115
|
+
encoding: 'utf-8',
|
|
116
|
+
env: {
|
|
117
|
+
...process.env,
|
|
118
|
+
NODE_OPTIONS: '--experimental-loader tsx',
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
debugStrategy('Node process exit code: %d', result.status);
|
|
122
|
+
if (result.status === 0) {
|
|
123
|
+
debugStrategy('Node direct load succeeded, importing module');
|
|
124
|
+
// Success! Now import the loader module to get the filter
|
|
125
|
+
const loaderModule = (await import(pathToFileURL(loaderFile).href));
|
|
126
|
+
debugStrategy('Filter function retrieved from module');
|
|
127
|
+
return loaderModule.filter;
|
|
128
|
+
}
|
|
129
|
+
debugStrategy('Node direct load failed');
|
|
130
|
+
if (result.stderr) {
|
|
131
|
+
debugStrategy('Error output: %s', result.stderr);
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
async tryNpxTsxExport(tempDir, filterUrl) {
|
|
136
|
+
debugStrategy('Strategy: npx tsx export');
|
|
137
|
+
// Second attempt: Use npx tsx to run a script that exports the filter
|
|
138
|
+
const exportFile = this.prepareTemplate(tempDir, 'tsx-export.mjs', filterUrl);
|
|
139
|
+
debugStrategy('Prepared export file: %s', exportFile);
|
|
140
|
+
debugStrategy('Spawning npx tsx...');
|
|
141
|
+
const npxResult = spawnSync('npx', ['tsx', exportFile], {
|
|
142
|
+
cwd: process.cwd(),
|
|
143
|
+
encoding: 'utf-8',
|
|
144
|
+
shell: true,
|
|
145
|
+
});
|
|
146
|
+
debugStrategy('npx process exit code: %d', npxResult.status);
|
|
147
|
+
if (npxResult.status === 0 && npxResult.stdout) {
|
|
148
|
+
debugStrategy('npx tsx succeeded, parsing output');
|
|
149
|
+
try {
|
|
150
|
+
const output = JSON.parse(npxResult.stdout);
|
|
151
|
+
if (output.success === true && typeof output.filterCode === 'string' && output.filterCode.length > 0) {
|
|
152
|
+
debugStrategy('Successfully parsed filter code, creating function');
|
|
153
|
+
// Create a function from the filter code
|
|
154
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval, @typescript-eslint/no-unsafe-call
|
|
155
|
+
const filter = new Function('return ' + output.filterCode)();
|
|
156
|
+
debugStrategy('Filter function created successfully');
|
|
157
|
+
return filter;
|
|
158
|
+
}
|
|
159
|
+
debugStrategy('Output missing success flag or filter code');
|
|
160
|
+
}
|
|
161
|
+
catch (parseError) {
|
|
162
|
+
debugStrategy('Failed to parse npx output: %O', parseError);
|
|
163
|
+
// JSON parse failed, try another approach
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
debugStrategy('npx tsx failed or no output');
|
|
168
|
+
if (npxResult.stderr) {
|
|
169
|
+
debugStrategy('Error output: %s', npxResult.stderr);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
async tryNodeLoaderOptions(tempDir, filterUrl) {
|
|
175
|
+
debugStrategy('Strategy: Node loader options');
|
|
176
|
+
// Third attempt: Create a wrapper that uses dynamic import with tsx
|
|
177
|
+
const wrapperFile = this.prepareTemplate(tempDir, 'tsx-wrapper.mjs', filterUrl);
|
|
178
|
+
debugStrategy('Prepared wrapper file: %s', wrapperFile);
|
|
179
|
+
// Try with various Node.js loader configurations
|
|
180
|
+
const loaderOptions = [
|
|
181
|
+
['--loader', 'tsx'],
|
|
182
|
+
['--experimental-loader', 'tsx'],
|
|
183
|
+
['--require', 'tsx'],
|
|
184
|
+
['--import', 'tsx'],
|
|
185
|
+
];
|
|
186
|
+
debugStrategy('Will try %d loader configurations', loaderOptions.length);
|
|
187
|
+
for (const options of loaderOptions) {
|
|
188
|
+
debugStrategy('Trying loader options: %s', options.join(' '));
|
|
189
|
+
const testResult = spawnSync('node', [...options, wrapperFile], {
|
|
190
|
+
cwd: process.cwd(),
|
|
191
|
+
encoding: 'utf-8',
|
|
192
|
+
env: { ...process.env },
|
|
193
|
+
});
|
|
194
|
+
debugStrategy('Exit code: %d', testResult.status);
|
|
195
|
+
if (testResult.status === 0) {
|
|
196
|
+
debugStrategy('Configuration works! Loading final filter');
|
|
197
|
+
// This configuration works! Use it to load the actual filter
|
|
198
|
+
const finalFile = this.prepareTemplate(tempDir, 'tsx-final-loader.mjs', filterUrl);
|
|
199
|
+
const finalModule = (await import(pathToFileURL(finalFile).href));
|
|
200
|
+
debugStrategy('Filter loaded successfully with options: %s', options.join(' '));
|
|
201
|
+
return finalModule.filter;
|
|
202
|
+
}
|
|
203
|
+
else if (testResult.stderr) {
|
|
204
|
+
debugStrategy('Error with %s: %s', options.join(' '), testResult.stderr);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
debugStrategy('All loader options failed');
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
prepareTemplate(tempDir, templateName, filterPath) {
|
|
211
|
+
debugTemplate('Preparing template: %s', templateName);
|
|
212
|
+
debugTemplate('Filter path: %s', filterPath);
|
|
213
|
+
const templatePath = join(this.templatesDir, templateName);
|
|
214
|
+
const outputPath = join(tempDir, templateName);
|
|
215
|
+
debugTemplate('Template path: %s', templatePath);
|
|
216
|
+
debugTemplate('Output path: %s', outputPath);
|
|
217
|
+
// Read the template
|
|
218
|
+
let content;
|
|
219
|
+
if (existsSync(templatePath)) {
|
|
220
|
+
debugTemplate('Reading template from source');
|
|
221
|
+
content = readFileSync(templatePath, 'utf-8');
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
debugTemplate('Template not in source, checking dist');
|
|
225
|
+
// Fallback to dist directory if running from compiled code
|
|
226
|
+
const distTemplatePath = templatePath.replace('/src/', '/dist/');
|
|
227
|
+
debugTemplate('Checking dist path: %s', distTemplatePath);
|
|
228
|
+
if (existsSync(distTemplatePath)) {
|
|
229
|
+
debugTemplate('Reading template from dist');
|
|
230
|
+
content = readFileSync(distTemplatePath, 'utf-8');
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
debugTemplate('ERROR: Template not found in source or dist');
|
|
234
|
+
throw new Error(`Template not found: ${templateName}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// Replace the placeholder with the actual filter path
|
|
238
|
+
content = content.replace(/__FILTER_PATH__/g, filterPath);
|
|
239
|
+
debugTemplate('Replaced filter path placeholder');
|
|
240
|
+
// Write the prepared script
|
|
241
|
+
writeFileSync(outputPath, content);
|
|
242
|
+
debugTemplate('Written prepared script to: %s', outputPath);
|
|
243
|
+
return outputPath;
|
|
244
|
+
}
|
|
245
|
+
cleanup() {
|
|
246
|
+
debug('FilterLoader cleanup called');
|
|
247
|
+
// No cleanup needed
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=FilterLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterLoader.js","sourceRoot":"","sources":["../../../src/utils/FilterLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAE5B,OAAO,WAAW,MAAM,OAAO,CAAC;AAEhC,MAAM,KAAK,GAAG,WAAW,CAAC,2CAA2C,CAAC,CAAC;AACvE,MAAM,SAAS,GAAG,WAAW,CAAC,gDAAgD,CAAC,CAAC;AAChF,MAAM,OAA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AAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// This script exports the filter function as JSON for serialization
|
|
2
|
+
import * as filterModule from '__FILTER_PATH__';
|
|
3
|
+
|
|
4
|
+
const filter = filterModule.filter || filterModule.default;
|
|
5
|
+
|
|
6
|
+
if (typeof filter === 'function') {
|
|
7
|
+
// Output the filter as a module we can import
|
|
8
|
+
console.log(JSON.stringify({
|
|
9
|
+
success: true,
|
|
10
|
+
filterCode: filter.toString()
|
|
11
|
+
}));
|
|
12
|
+
} else {
|
|
13
|
+
console.log(JSON.stringify({
|
|
14
|
+
success: false,
|
|
15
|
+
error: 'No filter function found'
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { register } from 'node:module';
|
|
2
|
+
|
|
3
|
+
// Register tsx for TypeScript support
|
|
4
|
+
register('tsx', import.meta.url);
|
|
5
|
+
|
|
6
|
+
// Import the TypeScript filter module
|
|
7
|
+
const filterModule = await import('__FILTER_PATH__');
|
|
8
|
+
|
|
9
|
+
// Export the filter function
|
|
10
|
+
export const filter = filterModule.filter || filterModule.default;
|