@wix/zero-config-implementation 1.11.0 → 1.13.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/dist/index.js CHANGED
@@ -1475,11 +1475,23 @@ const Ym = (e) => e.declarations && e.declarations.length > 0 ? !e.declarations.
1475
1475
  shouldRemoveUndefinedFromOptional: !0,
1476
1476
  shouldIncludePropTagMap: !0,
1477
1477
  skipChildrenPropWithoutDoc: !0,
1478
- propFilter: Ym
1478
+ propFilter: Ym,
1479
+ // react-docgen-typescript resolves `commentSource` for known wrapper types (MemoExoticComponent,
1480
+ // ForwardRefExoticComponent, etc.) but not for NamedExoticComponent — the base type that
1481
+ // TypeScript reports when a memo-wrapped component is accessed via a default export alias.
1482
+ // Adding it here makes the library correctly resolve the actual variable symbol.
1483
+ customComponentTypes: ["NamedExoticComponent"]
1479
1484
  };
1480
1485
  function Jm(e, t) {
1481
- const r = e.getTypeChecker(), n = e.getCompilerOptions();
1482
- return ym.withCompilerOptions(n, Wm).parseWithProgramProvider([t], () => e).map((o) => qm(o, e, r));
1486
+ const r = e.getTypeChecker(), n = e.getCompilerOptions(), a = (A, u) => {
1487
+ const s = r.getSymbolAtLocation(u);
1488
+ if (!s) return;
1489
+ const c = r.getExportsOfModule(s).find((l) => l.getName() === "default");
1490
+ if (!c || !(c.getFlags() & tt.SymbolFlags.Alias)) return;
1491
+ const h = r.getAliasedSymbol(c).getName();
1492
+ return h !== "default" ? h : void 0;
1493
+ };
1494
+ return ym.withCompilerOptions(n, { ...Wm, componentNameResolver: a }).parseWithProgramProvider([t], () => e).map((A) => qm(A, e, r));
1483
1495
  }
1484
1496
  function Vm(e, t) {
1485
1497
  const r = Km(e, t);
@@ -12038,7 +12050,7 @@ function T0() {
12038
12050
  }
12039
12051
  function Uk() {
12040
12052
  return {
12041
- ariaLabel: Ye.lorem.sentence(),
12053
+ ariaLabel: `mock_ariaLabel_${Ye.string.alphanumeric(6)}`,
12042
12054
  role: Ye.helpers.arrayElement(["button", "link", "img", "region"]),
12043
12055
  tabIndex: Ye.helpers.arrayElement([0, -1])
12044
12056
  };
@@ -12226,7 +12238,7 @@ function $k(e, t) {
12226
12238
  if (r && !r.startsWith("mock_"))
12227
12239
  return Ln(r);
12228
12240
  const n = Vr(e, "aria-label");
12229
- if (n)
12241
+ if (n && !n.startsWith("mock_"))
12230
12242
  return Ln(n);
12231
12243
  const a = Vr(e, "aria-labelledby");
12232
12244
  if (a) {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "registry": "https://registry.npmjs.org/",
5
5
  "access": "public"
6
6
  },
7
- "version": "1.11.0",
7
+ "version": "1.13.0",
8
8
  "description": "Core library for extracting component manifests from JS and CSS files",
9
9
  "type": "module",
10
10
  "main": "dist/index.js",
@@ -74,5 +74,5 @@
74
74
  ]
75
75
  }
76
76
  },
77
- "falconPackageHash": "72ed033142da89f1b47261236ac0406e5d01201b896daec0491a39ff"
77
+ "falconPackageHash": "415f1144395df7902b157f7d63d64cd53a60a5f69c460b61c217594b"
78
78
  }
@@ -154,7 +154,7 @@ function getElementNamePart(element: Element, getElementById: (id: string) => El
154
154
  }
155
155
 
156
156
  const ariaLabel = getAttribute(element, 'aria-label')
157
- if (ariaLabel) {
157
+ if (ariaLabel && !ariaLabel.startsWith('mock_')) {
158
158
  return pascalCase(ariaLabel)
159
159
  }
160
160
 
@@ -377,7 +377,7 @@ function generateMockLink(): Record<string, unknown> {
377
377
 
378
378
  function generateMockA11y(): Record<string, unknown> {
379
379
  return {
380
- ariaLabel: faker.lorem.sentence(),
380
+ ariaLabel: `mock_ariaLabel_${faker.string.alphanumeric(6)}`,
381
381
  role: faker.helpers.arrayElement(['button', 'link', 'img', 'region']),
382
382
  tabIndex: faker.helpers.arrayElement([0, -1]),
383
383
  }
@@ -20,6 +20,11 @@ const sharedParserOptions = {
20
20
  shouldIncludePropTagMap: true,
21
21
  skipChildrenPropWithoutDoc: true,
22
22
  propFilter: sharedPropFilter,
23
+ // react-docgen-typescript resolves `commentSource` for known wrapper types (MemoExoticComponent,
24
+ // ForwardRefExoticComponent, etc.) but not for NamedExoticComponent — the base type that
25
+ // TypeScript reports when a memo-wrapped component is accessed via a default export alias.
26
+ // Adding it here makes the library correctly resolve the actual variable symbol.
27
+ customComponentTypes: ['NamedExoticComponent'],
23
28
  }
24
29
 
25
30
  // ─────────────────────────────────────────────────────────────────────────────
@@ -30,7 +35,21 @@ export function extractAllComponentInfo(program: ts.Program, filePath: string):
30
35
  const checker = program.getTypeChecker()
31
36
  const options = program.getCompilerOptions()
32
37
 
33
- const parser = withCompilerOptions(options, sharedParserOptions)
38
+ // react-docgen-typescript uses the filename stem as displayName fallback when a
39
+ // component symbol has a "generic" React type name (e.g. "FunctionComponent",
40
+ // "__function"). This happens for components only exported via `export default`,
41
+ // not as named exports. We resolve the actual name from the module's default export.
42
+ const componentNameResolver = (_exp: ts.Symbol, source: ts.SourceFile): string | undefined => {
43
+ const moduleSymbol = checker.getSymbolAtLocation(source)
44
+ if (!moduleSymbol) return undefined
45
+ const defaultSym = checker.getExportsOfModule(moduleSymbol).find((s) => s.getName() === 'default')
46
+ if (!defaultSym || !(defaultSym.getFlags() & ts.SymbolFlags.Alias)) return undefined
47
+ const aliased = checker.getAliasedSymbol(defaultSym)
48
+ const name = aliased.getName()
49
+ return name !== 'default' ? name : undefined
50
+ }
51
+
52
+ const parser = withCompilerOptions(options, { ...sharedParserOptions, componentNameResolver })
34
53
 
35
54
  const docs = parser.parseWithProgramProvider([filePath], () => program)
36
55