pasika 0.10.20 → 0.10.22

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.
@@ -63,6 +63,17 @@ function isExported(node) {
63
63
  if (!ts.canHaveModifiers(node)) return false;
64
64
  return (ts.getModifiers(node) ?? []).some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword);
65
65
  }
66
+ function namedExportedLocalNames(sourceFile) {
67
+ const names = /* @__PURE__ */ new Set();
68
+ for (const statement of sourceFile.statements) {
69
+ if (!ts.isExportDeclaration(statement) || statement.moduleSpecifier || !statement.exportClause) continue;
70
+ if (!ts.isNamedExports(statement.exportClause)) continue;
71
+ for (const element of statement.exportClause.elements) {
72
+ names.add((element.propertyName ?? element.name).text);
73
+ }
74
+ }
75
+ return names;
76
+ }
66
77
  function containsJsx(node) {
67
78
  let found = false;
68
79
  const visit = (child) => {
@@ -120,16 +131,20 @@ function componentFromVariable(node) {
120
131
  function parseComponentInfo(text, filename, options) {
121
132
  const sourceFile = ts.createSourceFile(path.resolve(filename), text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
122
133
  const components = [];
134
+ const namedExports = namedExportedLocalNames(sourceFile);
123
135
  for (const statement of sourceFile.statements) {
124
- const exported = isExported(statement);
125
- if (!exported && !options?.includeNonExported) continue;
136
+ const statementExported = isExported(statement);
126
137
  if (ts.isFunctionDeclaration(statement)) {
138
+ const name = statement.name?.text;
139
+ if (!options?.includeNonExported && !statementExported && (!name || !namedExports.has(name))) continue;
127
140
  const component = componentFromFunction(statement);
128
141
  if (component) components.push(component);
129
142
  continue;
130
143
  }
131
144
  if (ts.isVariableStatement(statement)) {
132
145
  for (const declaration of statement.declarationList.declarations) {
146
+ const name = ts.isIdentifier(declaration.name) ? declaration.name.text : void 0;
147
+ if (!options?.includeNonExported && !statementExported && (!name || !namedExports.has(name))) continue;
133
148
  const component = componentFromVariable(declaration);
134
149
  if (component) components.push(component);
135
150
  }
@@ -3093,7 +3108,6 @@ var pureFunctionExtractRule = {
3093
3108
  const exported = node.parent?.type === "ExportNamedDeclaration";
3094
3109
  const moduleLevel = exported || node.parent?.type === "Program";
3095
3110
  if (!moduleLevel) return;
3096
- if (!isRouteFile && !exported) return;
3097
3111
  const name = node.id?.name;
3098
3112
  if (!name) return;
3099
3113
  if (isRouteFile && ROUTE_HANDLER_EXPORT_NAMES.has(name)) return;
@@ -3109,7 +3123,6 @@ var pureFunctionExtractRule = {
3109
3123
  const exported = container?.type === "ExportNamedDeclaration";
3110
3124
  const moduleLevel = exported || container?.type === "Program";
3111
3125
  if (!moduleLevel) return;
3112
- if (!isRouteFile && !exported) return;
3113
3126
  if (isRouteFile && ROUTE_HANDLER_EXPORT_NAMES.has(name)) return;
3114
3127
  if (isComponentLikeName(name) || isHookName2(name)) return;
3115
3128
  const init = node.init;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pasika",
3
- "version": "0.10.20",
3
+ "version": "0.10.22",
4
4
  "description": "Reusable agent setup package",
5
5
  "repository": {
6
6
  "type": "git",