@bamboocss/extractor 1.12.3 → 1.13.1
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/LICENSE.md +1 -0
- package/dist/index.cjs +48 -12
- package/dist/index.d.cts +10 -1
- package/dist/index.d.mts +10 -1
- package/dist/index.mjs +48 -13
- package/package.json +4 -4
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2023 Segun Adebayo
|
|
4
|
+
Copyright (c) 2026 Gajus Kuizinas
|
|
4
5
|
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
6
7
|
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
package/dist/index.cjs
CHANGED
|
@@ -336,12 +336,12 @@ function getDeclarationFor(node, stack, ctx) {
|
|
|
336
336
|
if ((ts_morph.Node.isVariableDeclaration(parent) || ts_morph.Node.isParameterDeclaration(parent) || ts_morph.Node.isFunctionDeclaration(parent) || ts_morph.Node.isEnumDeclaration(parent) || ts_morph.Node.isBindingElement(parent)) && parent.getNameNode() == node) {
|
|
337
337
|
declarationStack.push(parent);
|
|
338
338
|
declaration = parent;
|
|
339
|
-
} else if (ts_morph.Node.isImportSpecifier(parent) && parent.getNameNode() == node) {
|
|
339
|
+
} else if (ts_morph.Node.isImportSpecifier(parent) && (parent.getNameNode() == node || parent.getAliasNode() == node)) {
|
|
340
340
|
if (ctx.flags?.skipTraverseFiles) return;
|
|
341
341
|
const sourceFile = getModuleSpecifierSourceFile(parent.getImportDeclaration());
|
|
342
342
|
if (sourceFile) {
|
|
343
343
|
const exportStack = [parent, sourceFile];
|
|
344
|
-
const maybeVar = getExportedVarDeclarationWithName(
|
|
344
|
+
const maybeVar = getExportedVarDeclarationWithName(parent.getNameNode().getText(), sourceFile, exportStack, ctx);
|
|
345
345
|
if (maybeVar) {
|
|
346
346
|
declarationStack.push(...exportStack.concat(maybeVar));
|
|
347
347
|
declaration = maybeVar;
|
|
@@ -508,9 +508,23 @@ const getObjectLiteralExpressionPropPairs = (expression, expressionStack, ctx, m
|
|
|
508
508
|
};
|
|
509
509
|
//#endregion
|
|
510
510
|
//#region src/maybe-box-node.ts
|
|
511
|
-
|
|
511
|
+
let cacheMap$1 = /* @__PURE__ */ new WeakMap();
|
|
512
512
|
const isCached = (node) => cacheMap$1.has(node);
|
|
513
513
|
const getCached = (node) => cacheMap$1.get(node);
|
|
514
|
+
/**
|
|
515
|
+
* Drops every memoized resolution.
|
|
516
|
+
*
|
|
517
|
+
* The cache is keyed on AST nodes, and a node's resolved value can depend on
|
|
518
|
+
* another file: `css(button)` folds whatever `./styles` exports. Editing that file
|
|
519
|
+
* replaces only its own nodes, so an importer's nodes stay identical and would
|
|
520
|
+
* otherwise keep serving the value read before the edit.
|
|
521
|
+
*/
|
|
522
|
+
const clearBoxNodeCache = () => {
|
|
523
|
+
if (!hasCachedEntries) return;
|
|
524
|
+
cacheMap$1 = /* @__PURE__ */ new WeakMap();
|
|
525
|
+
hasCachedEntries = false;
|
|
526
|
+
};
|
|
527
|
+
let hasCachedEntries = false;
|
|
514
528
|
const isPlusSyntax = (op) => op === ts_morph.ts.SyntaxKind.PlusToken;
|
|
515
529
|
const isLogicalSyntax = (op) => op === ts_morph.ts.SyntaxKind.BarBarToken || op === ts_morph.ts.SyntaxKind.QuestionQuestionToken || op === ts_morph.ts.SyntaxKind.AmpersandAmpersandToken || op === ts_morph.ts.SyntaxKind.EqualsEqualsEqualsToken || op === ts_morph.ts.SyntaxKind.EqualsEqualsToken || op === ts_morph.ts.SyntaxKind.ExclamationEqualsEqualsToken || op === ts_morph.ts.SyntaxKind.ExclamationEqualsToken || op === ts_morph.ts.SyntaxKind.GreaterThanEqualsToken || op === ts_morph.ts.SyntaxKind.GreaterThanToken || op === ts_morph.ts.SyntaxKind.LessThanEqualsToken || op === ts_morph.ts.SyntaxKind.LessThanToken || op === ts_morph.ts.SyntaxKind.InstanceOfKeyword || op === ts_morph.ts.SyntaxKind.InKeyword;
|
|
516
530
|
const isOperationSyntax = (op) => op === ts_morph.ts.SyntaxKind.AsteriskToken || op === ts_morph.ts.SyntaxKind.SlashToken || op === ts_morph.ts.SyntaxKind.PercentToken || op === ts_morph.ts.SyntaxKind.AsteriskAsteriskToken || op === ts_morph.ts.SyntaxKind.MinusToken;
|
|
@@ -520,6 +534,7 @@ const canReturnWhenTrueInLogicalExpression = (op) => {
|
|
|
520
534
|
function maybeBoxNode(node, stack, ctx, matchProp) {
|
|
521
535
|
const cache = (value) => {
|
|
522
536
|
cacheMap$1.set(node, value);
|
|
537
|
+
hasCachedEntries = true;
|
|
523
538
|
return value;
|
|
524
539
|
};
|
|
525
540
|
if (isCached(node)) return getCached(node);
|
|
@@ -916,17 +931,29 @@ const maybeDefinitionValue = (def, stack, ctx) => {
|
|
|
916
931
|
if (maybeValue) return maybeValue;
|
|
917
932
|
}
|
|
918
933
|
};
|
|
919
|
-
const getExportedVarDeclarationWithName = (varName, sourceFile, stack, ctx) => {
|
|
934
|
+
const getExportedVarDeclarationWithName = (varName, sourceFile, stack, ctx, visited = /* @__PURE__ */ new Set()) => {
|
|
935
|
+
const key = `${sourceFile.getFilePath()}:${varName}`;
|
|
936
|
+
if (visited.has(key)) return;
|
|
937
|
+
visited.add(key);
|
|
920
938
|
const maybeVar = sourceFile.getVariableDeclaration(varName);
|
|
921
939
|
if (maybeVar) return maybeVar;
|
|
922
|
-
const exportDeclaration = resolveVarDeclarationFromExportWithName(varName, sourceFile, stack, ctx);
|
|
940
|
+
const exportDeclaration = resolveVarDeclarationFromExportWithName(varName, sourceFile, stack, ctx, visited);
|
|
923
941
|
if (!exportDeclaration) return;
|
|
924
942
|
return exportDeclaration;
|
|
925
943
|
};
|
|
926
|
-
|
|
944
|
+
/**
|
|
945
|
+
* Given the name a module exposes, the name to look for in the module it came from.
|
|
946
|
+
* Returns `undefined` when this declaration does not provide `name` at all.
|
|
947
|
+
*
|
|
948
|
+
* For `export { btn as button } from './styles'` the two differ: `getAliasNode()`
|
|
949
|
+
* is `button`, the name this module exports, and `getNameNode()` is `btn`, the name
|
|
950
|
+
* to search for in `./styles`. Matching on the wrong one both hides names the
|
|
951
|
+
* module does export and resolves names it does not.
|
|
952
|
+
*/
|
|
953
|
+
const resolveExportedName = (name, exportDeclaration) => {
|
|
927
954
|
const namedExports = exportDeclaration.getNamedExports();
|
|
928
|
-
if (namedExports.length === 0) return
|
|
929
|
-
for (const namedExport of namedExports) if (namedExport.getNameNode().getText() === name) return
|
|
955
|
+
if (namedExports.length === 0) return name;
|
|
956
|
+
for (const namedExport of namedExports) if ((namedExport.getAliasNode() ?? namedExport.getNameNode()).getText() === name) return namedExport.getNameNode().getText();
|
|
930
957
|
};
|
|
931
958
|
/**
|
|
932
959
|
* Faster than declaration.getModuleSpecifierSourceFile()
|
|
@@ -946,14 +973,22 @@ const getModuleSpecifierSourceFile = (declaration) => {
|
|
|
946
973
|
if (!resolved.resolvedModule) return;
|
|
947
974
|
return project.addSourceFileAtPath(resolved.resolvedModule.resolvedFileName);
|
|
948
975
|
};
|
|
949
|
-
function resolveVarDeclarationFromExportWithName(symbolName, sourceFile, stack, ctx) {
|
|
976
|
+
function resolveVarDeclarationFromExportWithName(symbolName, sourceFile, stack, ctx, visited) {
|
|
950
977
|
for (const exportDeclaration of sourceFile.getExportDeclarations()) {
|
|
951
978
|
const exportStack = [exportDeclaration];
|
|
952
|
-
|
|
979
|
+
const sourceName = resolveExportedName(symbolName, exportDeclaration);
|
|
980
|
+
if (sourceName === void 0) continue;
|
|
953
981
|
const maybeFile = getModuleSpecifierSourceFile(exportDeclaration);
|
|
954
|
-
if (!maybeFile)
|
|
982
|
+
if (!maybeFile) {
|
|
983
|
+
const localVar = sourceFile.getVariableDeclaration(sourceName);
|
|
984
|
+
if (localVar) {
|
|
985
|
+
stack.push(...exportStack.concat(localVar));
|
|
986
|
+
return localVar;
|
|
987
|
+
}
|
|
988
|
+
continue;
|
|
989
|
+
}
|
|
955
990
|
exportStack.push(maybeFile);
|
|
956
|
-
const maybeVar = getExportedVarDeclarationWithName(
|
|
991
|
+
const maybeVar = getExportedVarDeclarationWithName(sourceName, maybeFile, stack, ctx, visited);
|
|
957
992
|
if (maybeVar) {
|
|
958
993
|
stack.push(...exportStack.concat(maybeVar));
|
|
959
994
|
return maybeVar;
|
|
@@ -1820,6 +1855,7 @@ exports.BoxNodeMap = BoxNodeMap;
|
|
|
1820
1855
|
exports.BoxNodeObject = BoxNodeObject;
|
|
1821
1856
|
exports.BoxNodeUnresolvable = BoxNodeUnresolvable;
|
|
1822
1857
|
exports.box = box;
|
|
1858
|
+
exports.clearBoxNodeCache = clearBoxNodeCache;
|
|
1823
1859
|
exports.extract = extract;
|
|
1824
1860
|
exports.extractCallExpressionArguments = extractCallExpressionArguments;
|
|
1825
1861
|
exports.extractJsxAttribute = extractJsxAttribute;
|
package/dist/index.d.cts
CHANGED
|
@@ -273,6 +273,15 @@ declare const extractJsxElementProps: (node: JsxOpeningElement | JsxSelfClosingE
|
|
|
273
273
|
};
|
|
274
274
|
//#endregion
|
|
275
275
|
//#region src/maybe-box-node.d.ts
|
|
276
|
+
/**
|
|
277
|
+
* Drops every memoized resolution.
|
|
278
|
+
*
|
|
279
|
+
* The cache is keyed on AST nodes, and a node's resolved value can depend on
|
|
280
|
+
* another file: `css(button)` folds whatever `./styles` exports. Editing that file
|
|
281
|
+
* replaces only its own nodes, so an importer's nodes stay identical and would
|
|
282
|
+
* otherwise keep serving the value read before the edit.
|
|
283
|
+
*/
|
|
284
|
+
declare const clearBoxNodeCache: () => void;
|
|
276
285
|
type MaybeBoxNodeReturn = BoxNode | undefined;
|
|
277
286
|
declare function maybeBoxNode(node: Node, stack: Node[], ctx: BoxContext, matchProp?: (prop: MatchFnPropArgs) => boolean): MaybeBoxNodeReturn;
|
|
278
287
|
declare const maybeIdentifierValue: (identifier: Identifier, _stack: Node[], ctx: BoxContext) => BoxNode;
|
|
@@ -300,4 +309,4 @@ interface Unboxed {
|
|
|
300
309
|
}
|
|
301
310
|
declare const unbox: (node: BoxNodeType, ctx?: Pick<UnboxContext, "cache">) => Unboxed;
|
|
302
311
|
//#endregion
|
|
303
|
-
export { type BoxContext, type BoxNode, BoxNodeArray, BoxNodeConditional, BoxNodeEmptyInitializer, BoxNodeLiteral, BoxNodeMap, BoxNodeObject, BoxNodeUnresolvable, type EvaluateOptions, type ExtractOptions, type ExtractResultByName, type ExtractResultItem, type ExtractedComponentInstance, type ExtractedComponentResult, type ExtractedFunctionInstance, type ExtractedFunctionResult, type NodeRange, type PrimitiveType, type Unboxed, box, extract, extractCallExpressionArguments, extractJsxAttribute, extractJsxElementProps, extractJsxSpreadAttributeValues, findIdentifierValueDeclaration, isBoxNode, maybeBoxNode, maybeIdentifierValue, unbox };
|
|
312
|
+
export { type BoxContext, type BoxNode, BoxNodeArray, BoxNodeConditional, BoxNodeEmptyInitializer, BoxNodeLiteral, BoxNodeMap, BoxNodeObject, BoxNodeUnresolvable, type EvaluateOptions, type ExtractOptions, type ExtractResultByName, type ExtractResultItem, type ExtractedComponentInstance, type ExtractedComponentResult, type ExtractedFunctionInstance, type ExtractedFunctionResult, type NodeRange, type PrimitiveType, type Unboxed, box, clearBoxNodeCache, extract, extractCallExpressionArguments, extractJsxAttribute, extractJsxElementProps, extractJsxSpreadAttributeValues, findIdentifierValueDeclaration, isBoxNode, maybeBoxNode, maybeIdentifierValue, unbox };
|
package/dist/index.d.mts
CHANGED
|
@@ -273,6 +273,15 @@ declare const extractJsxElementProps: (node: JsxOpeningElement | JsxSelfClosingE
|
|
|
273
273
|
};
|
|
274
274
|
//#endregion
|
|
275
275
|
//#region src/maybe-box-node.d.ts
|
|
276
|
+
/**
|
|
277
|
+
* Drops every memoized resolution.
|
|
278
|
+
*
|
|
279
|
+
* The cache is keyed on AST nodes, and a node's resolved value can depend on
|
|
280
|
+
* another file: `css(button)` folds whatever `./styles` exports. Editing that file
|
|
281
|
+
* replaces only its own nodes, so an importer's nodes stay identical and would
|
|
282
|
+
* otherwise keep serving the value read before the edit.
|
|
283
|
+
*/
|
|
284
|
+
declare const clearBoxNodeCache: () => void;
|
|
276
285
|
type MaybeBoxNodeReturn = BoxNode | undefined;
|
|
277
286
|
declare function maybeBoxNode(node: Node, stack: Node[], ctx: BoxContext, matchProp?: (prop: MatchFnPropArgs) => boolean): MaybeBoxNodeReturn;
|
|
278
287
|
declare const maybeIdentifierValue: (identifier: Identifier, _stack: Node[], ctx: BoxContext) => BoxNode;
|
|
@@ -300,4 +309,4 @@ interface Unboxed {
|
|
|
300
309
|
}
|
|
301
310
|
declare const unbox: (node: BoxNodeType, ctx?: Pick<UnboxContext, "cache">) => Unboxed;
|
|
302
311
|
//#endregion
|
|
303
|
-
export { type BoxContext, type BoxNode, BoxNodeArray, BoxNodeConditional, BoxNodeEmptyInitializer, BoxNodeLiteral, BoxNodeMap, BoxNodeObject, BoxNodeUnresolvable, type EvaluateOptions, type ExtractOptions, type ExtractResultByName, type ExtractResultItem, type ExtractedComponentInstance, type ExtractedComponentResult, type ExtractedFunctionInstance, type ExtractedFunctionResult, type NodeRange, type PrimitiveType, type Unboxed, box, extract, extractCallExpressionArguments, extractJsxAttribute, extractJsxElementProps, extractJsxSpreadAttributeValues, findIdentifierValueDeclaration, isBoxNode, maybeBoxNode, maybeIdentifierValue, unbox };
|
|
312
|
+
export { type BoxContext, type BoxNode, BoxNodeArray, BoxNodeConditional, BoxNodeEmptyInitializer, BoxNodeLiteral, BoxNodeMap, BoxNodeObject, BoxNodeUnresolvable, type EvaluateOptions, type ExtractOptions, type ExtractResultByName, type ExtractResultItem, type ExtractedComponentInstance, type ExtractedComponentResult, type ExtractedFunctionInstance, type ExtractedFunctionResult, type NodeRange, type PrimitiveType, type Unboxed, box, clearBoxNodeCache, extract, extractCallExpressionArguments, extractJsxAttribute, extractJsxElementProps, extractJsxSpreadAttributeValues, findIdentifierValueDeclaration, isBoxNode, maybeBoxNode, maybeIdentifierValue, unbox };
|
package/dist/index.mjs
CHANGED
|
@@ -335,12 +335,12 @@ function getDeclarationFor(node, stack, ctx) {
|
|
|
335
335
|
if ((Node.isVariableDeclaration(parent) || Node.isParameterDeclaration(parent) || Node.isFunctionDeclaration(parent) || Node.isEnumDeclaration(parent) || Node.isBindingElement(parent)) && parent.getNameNode() == node) {
|
|
336
336
|
declarationStack.push(parent);
|
|
337
337
|
declaration = parent;
|
|
338
|
-
} else if (Node.isImportSpecifier(parent) && parent.getNameNode() == node) {
|
|
338
|
+
} else if (Node.isImportSpecifier(parent) && (parent.getNameNode() == node || parent.getAliasNode() == node)) {
|
|
339
339
|
if (ctx.flags?.skipTraverseFiles) return;
|
|
340
340
|
const sourceFile = getModuleSpecifierSourceFile(parent.getImportDeclaration());
|
|
341
341
|
if (sourceFile) {
|
|
342
342
|
const exportStack = [parent, sourceFile];
|
|
343
|
-
const maybeVar = getExportedVarDeclarationWithName(
|
|
343
|
+
const maybeVar = getExportedVarDeclarationWithName(parent.getNameNode().getText(), sourceFile, exportStack, ctx);
|
|
344
344
|
if (maybeVar) {
|
|
345
345
|
declarationStack.push(...exportStack.concat(maybeVar));
|
|
346
346
|
declaration = maybeVar;
|
|
@@ -507,9 +507,23 @@ const getObjectLiteralExpressionPropPairs = (expression, expressionStack, ctx, m
|
|
|
507
507
|
};
|
|
508
508
|
//#endregion
|
|
509
509
|
//#region src/maybe-box-node.ts
|
|
510
|
-
|
|
510
|
+
let cacheMap$1 = /* @__PURE__ */ new WeakMap();
|
|
511
511
|
const isCached = (node) => cacheMap$1.has(node);
|
|
512
512
|
const getCached = (node) => cacheMap$1.get(node);
|
|
513
|
+
/**
|
|
514
|
+
* Drops every memoized resolution.
|
|
515
|
+
*
|
|
516
|
+
* The cache is keyed on AST nodes, and a node's resolved value can depend on
|
|
517
|
+
* another file: `css(button)` folds whatever `./styles` exports. Editing that file
|
|
518
|
+
* replaces only its own nodes, so an importer's nodes stay identical and would
|
|
519
|
+
* otherwise keep serving the value read before the edit.
|
|
520
|
+
*/
|
|
521
|
+
const clearBoxNodeCache = () => {
|
|
522
|
+
if (!hasCachedEntries) return;
|
|
523
|
+
cacheMap$1 = /* @__PURE__ */ new WeakMap();
|
|
524
|
+
hasCachedEntries = false;
|
|
525
|
+
};
|
|
526
|
+
let hasCachedEntries = false;
|
|
513
527
|
const isPlusSyntax = (op) => op === ts.SyntaxKind.PlusToken;
|
|
514
528
|
const isLogicalSyntax = (op) => op === ts.SyntaxKind.BarBarToken || op === ts.SyntaxKind.QuestionQuestionToken || op === ts.SyntaxKind.AmpersandAmpersandToken || op === ts.SyntaxKind.EqualsEqualsEqualsToken || op === ts.SyntaxKind.EqualsEqualsToken || op === ts.SyntaxKind.ExclamationEqualsEqualsToken || op === ts.SyntaxKind.ExclamationEqualsToken || op === ts.SyntaxKind.GreaterThanEqualsToken || op === ts.SyntaxKind.GreaterThanToken || op === ts.SyntaxKind.LessThanEqualsToken || op === ts.SyntaxKind.LessThanToken || op === ts.SyntaxKind.InstanceOfKeyword || op === ts.SyntaxKind.InKeyword;
|
|
515
529
|
const isOperationSyntax = (op) => op === ts.SyntaxKind.AsteriskToken || op === ts.SyntaxKind.SlashToken || op === ts.SyntaxKind.PercentToken || op === ts.SyntaxKind.AsteriskAsteriskToken || op === ts.SyntaxKind.MinusToken;
|
|
@@ -519,6 +533,7 @@ const canReturnWhenTrueInLogicalExpression = (op) => {
|
|
|
519
533
|
function maybeBoxNode(node, stack, ctx, matchProp) {
|
|
520
534
|
const cache = (value) => {
|
|
521
535
|
cacheMap$1.set(node, value);
|
|
536
|
+
hasCachedEntries = true;
|
|
522
537
|
return value;
|
|
523
538
|
};
|
|
524
539
|
if (isCached(node)) return getCached(node);
|
|
@@ -915,17 +930,29 @@ const maybeDefinitionValue = (def, stack, ctx) => {
|
|
|
915
930
|
if (maybeValue) return maybeValue;
|
|
916
931
|
}
|
|
917
932
|
};
|
|
918
|
-
const getExportedVarDeclarationWithName = (varName, sourceFile, stack, ctx) => {
|
|
933
|
+
const getExportedVarDeclarationWithName = (varName, sourceFile, stack, ctx, visited = /* @__PURE__ */ new Set()) => {
|
|
934
|
+
const key = `${sourceFile.getFilePath()}:${varName}`;
|
|
935
|
+
if (visited.has(key)) return;
|
|
936
|
+
visited.add(key);
|
|
919
937
|
const maybeVar = sourceFile.getVariableDeclaration(varName);
|
|
920
938
|
if (maybeVar) return maybeVar;
|
|
921
|
-
const exportDeclaration = resolveVarDeclarationFromExportWithName(varName, sourceFile, stack, ctx);
|
|
939
|
+
const exportDeclaration = resolveVarDeclarationFromExportWithName(varName, sourceFile, stack, ctx, visited);
|
|
922
940
|
if (!exportDeclaration) return;
|
|
923
941
|
return exportDeclaration;
|
|
924
942
|
};
|
|
925
|
-
|
|
943
|
+
/**
|
|
944
|
+
* Given the name a module exposes, the name to look for in the module it came from.
|
|
945
|
+
* Returns `undefined` when this declaration does not provide `name` at all.
|
|
946
|
+
*
|
|
947
|
+
* For `export { btn as button } from './styles'` the two differ: `getAliasNode()`
|
|
948
|
+
* is `button`, the name this module exports, and `getNameNode()` is `btn`, the name
|
|
949
|
+
* to search for in `./styles`. Matching on the wrong one both hides names the
|
|
950
|
+
* module does export and resolves names it does not.
|
|
951
|
+
*/
|
|
952
|
+
const resolveExportedName = (name, exportDeclaration) => {
|
|
926
953
|
const namedExports = exportDeclaration.getNamedExports();
|
|
927
|
-
if (namedExports.length === 0) return
|
|
928
|
-
for (const namedExport of namedExports) if (namedExport.getNameNode().getText() === name) return
|
|
954
|
+
if (namedExports.length === 0) return name;
|
|
955
|
+
for (const namedExport of namedExports) if ((namedExport.getAliasNode() ?? namedExport.getNameNode()).getText() === name) return namedExport.getNameNode().getText();
|
|
929
956
|
};
|
|
930
957
|
/**
|
|
931
958
|
* Faster than declaration.getModuleSpecifierSourceFile()
|
|
@@ -945,14 +972,22 @@ const getModuleSpecifierSourceFile = (declaration) => {
|
|
|
945
972
|
if (!resolved.resolvedModule) return;
|
|
946
973
|
return project.addSourceFileAtPath(resolved.resolvedModule.resolvedFileName);
|
|
947
974
|
};
|
|
948
|
-
function resolveVarDeclarationFromExportWithName(symbolName, sourceFile, stack, ctx) {
|
|
975
|
+
function resolveVarDeclarationFromExportWithName(symbolName, sourceFile, stack, ctx, visited) {
|
|
949
976
|
for (const exportDeclaration of sourceFile.getExportDeclarations()) {
|
|
950
977
|
const exportStack = [exportDeclaration];
|
|
951
|
-
|
|
978
|
+
const sourceName = resolveExportedName(symbolName, exportDeclaration);
|
|
979
|
+
if (sourceName === void 0) continue;
|
|
952
980
|
const maybeFile = getModuleSpecifierSourceFile(exportDeclaration);
|
|
953
|
-
if (!maybeFile)
|
|
981
|
+
if (!maybeFile) {
|
|
982
|
+
const localVar = sourceFile.getVariableDeclaration(sourceName);
|
|
983
|
+
if (localVar) {
|
|
984
|
+
stack.push(...exportStack.concat(localVar));
|
|
985
|
+
return localVar;
|
|
986
|
+
}
|
|
987
|
+
continue;
|
|
988
|
+
}
|
|
954
989
|
exportStack.push(maybeFile);
|
|
955
|
-
const maybeVar = getExportedVarDeclarationWithName(
|
|
990
|
+
const maybeVar = getExportedVarDeclarationWithName(sourceName, maybeFile, stack, ctx, visited);
|
|
956
991
|
if (maybeVar) {
|
|
957
992
|
stack.push(...exportStack.concat(maybeVar));
|
|
958
993
|
return maybeVar;
|
|
@@ -1811,4 +1846,4 @@ const unbox = (node, ctx) => {
|
|
|
1811
1846
|
return result;
|
|
1812
1847
|
};
|
|
1813
1848
|
//#endregion
|
|
1814
|
-
export { BoxNodeArray, BoxNodeConditional, BoxNodeEmptyInitializer, BoxNodeLiteral, BoxNodeMap, BoxNodeObject, BoxNodeUnresolvable, box, extract, extractCallExpressionArguments, extractJsxAttribute, extractJsxElementProps, extractJsxSpreadAttributeValues, findIdentifierValueDeclaration, isBoxNode, maybeBoxNode, maybeIdentifierValue, unbox };
|
|
1849
|
+
export { BoxNodeArray, BoxNodeConditional, BoxNodeEmptyInitializer, BoxNodeLiteral, BoxNodeMap, BoxNodeObject, BoxNodeUnresolvable, box, clearBoxNodeCache, extract, extractCallExpressionArguments, extractJsxAttribute, extractJsxElementProps, extractJsxSpreadAttributeValues, findIdentifierValueDeclaration, isBoxNode, maybeBoxNode, maybeIdentifierValue, unbox };
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/extractor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"description": "The css extractor for css bamboo",
|
|
5
|
-
"homepage": "https://
|
|
5
|
+
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"author": "
|
|
7
|
+
"author": "Gajus Kuizinas <gajus@gajus.com>",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/bamboocss/bamboo.git",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"ts-evaluator": "1.2.0",
|
|
37
37
|
"ts-morph": "28.0.0",
|
|
38
|
-
"@bamboocss/shared": "1.
|
|
38
|
+
"@bamboocss/shared": "1.13.1"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsdown src/index.ts --format=cjs,esm --shims --dts",
|