@qualcomm-ui/mdx-vite 3.3.3 → 3.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.
@@ -2,6 +2,7 @@ import { type Plugin } from "unified";
2
2
  import { type PageDocProps, type PageHeading, UniqueIdService } from "@qualcomm-ui/mdx-common";
3
3
  import type { QuiPropTypes } from "@qualcomm-ui/typedoc-common";
4
4
  import { type IndexedSection } from "../markdown";
5
+ export declare const docPropsJsxNodes: string[];
5
6
  interface DocPropEntry {
6
7
  name: string;
7
8
  omitFrom?: string[];
@@ -21,6 +22,7 @@ export declare class DocPropsIndexer {
21
22
  getTypeDocPropsNodes: Plugin;
22
23
  build(fileContents: string, toc: PageHeading[]): IndexedSection[] | null;
23
24
  getDocProps(): PageDocProps;
25
+ private assembleFunctionParams;
24
26
  private assembleProp;
25
27
  }
26
28
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"doc-props-indexer.d.ts","sourceRoot":"","sources":["../../../src/docs-plugin/doc-props/doc-props-indexer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,KAAK,MAAM,EAAU,MAAM,SAAS,CAAA;AAG5C,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAEhB,eAAe,EAChB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAEV,YAAY,EACb,MAAM,6BAA6B,CAAA;AAEpC,OAAO,EAA4B,KAAK,cAAc,EAAC,MAAM,aAAa,CAAA;AAuD1E,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,qBAAa,eAAe;IAC1B,eAAe,EAAE,YAAY,EAAE,CAAK;IACpC,SAAS,EAAE,eAAe,CAAwB;IAClD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA8B;IACpD,OAAO,CAAC,YAAY,CAAmB;gBAE3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY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 @@
1
- {"version":3,"file":"doc-props-plugin.d.ts","sourceRoot":"","sources":["../../../../../src/docs-plugin/markdown/knowledge/plugins/doc-props-plugin.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,SAAS,CAAA;AAGnC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAA;AAO3D,OAAO,KAAK,EAAC,cAAc,EAAE,QAAQ,EAAW,MAAM,UAAU,CAAA;AAoDhE,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAQ;IACtC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,OAAO,EAAE,oBAAoB;IAMnC,YAAY,IAAI,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAoC9C,OAAO,CAAC,kBAAkB;IAoC1B,OAAO,CAAC,aAAa;IAoCrB,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,GAAG,cAAc,EAAE;IA0BzE,OAAO,CAAC,eAAe;IAiBvB;;;OAGG;IACH,mBAAmB,IAAI,MAAM;CA8F9B"}
1
+ {"version":3,"file":"doc-props-plugin.d.ts","sourceRoot":"","sources":["../../../../../src/docs-plugin/markdown/knowledge/plugins/doc-props-plugin.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,SAAS,CAAA;AAGnC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAA;AAQ3D,OAAO,KAAK,EAAC,cAAc,EAAE,QAAQ,EAAW,MAAM,UAAU,CAAA;AAoDhE,MAAM,WA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AC,aAAa,CAAY;IAEjC,IAAI,QAAQ,IAAI,OAAO,EAAE,CAExB;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IACD,OAAO,CAAC,QAAQ,CAAc;IAE9B,IAAI,WAAW,IAAI,WAAW,EAAE,CAE/B;IACD,OAAO,CAAC,YAAY,CAAoB;IAExC,KAAK,IAAI,IAAI;gBASX,MAAM,EAAE,oBAAoB,EAC5B,WAAW,UAAO,EAElB,MAAM,GAAE;QACN,eAAe,CAAC,EAAE,eAAe,CAAA;QACjC,aAAa,CAAC,EAAE,aAAa,CAAA;QAC7B,UAAU,CAAC,EAAE,UAAU,CAAA;QACvB,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;KAC/B;IA+BR;;;OAGG;IACH,OAAO,CAAC,YAAY;IAgEpB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAgKtB,OAAO,CAAC,qBAAqB;IAiB7B,OAAO,CAAC,qBAAqB;IAoB7B,OAAO,CAAC,cAAc;IAqBtB,UAAU,CACR,aAAa,EAAE,MAAM,EAAE,EACvB,WAAW,GAAE,OAAc,GAC1B,eAAe,EAAE;CAsDrB"}
package/dist/index.js CHANGED
@@ -1289,7 +1289,7 @@ function createRemarkProcessor(options = {}) {
1289
1289
  import { minimatch as minimatch2 } from "minimatch";
1290
1290
  import { readdir } from "node:fs/promises";
1291
1291
  import { join as join5, relative } from "node:path";
1292
- import { visit as visit16 } from "unist-util-visit";
1292
+ import { visit as visit17 } from "unist-util-visit";
1293
1293
 
1294
1294
  // src/docs-plugin/nav-builder/get-route-meta.ts
1295
1295
  function getRouteMeta(pathSegments, metaJson) {
@@ -2012,7 +2012,217 @@ function formatDemos(demosFolder, verbose) {
2012
2012
  // src/docs-plugin/markdown/knowledge/plugins/doc-props-plugin.ts
2013
2013
  import { readFile as readFile3 } from "node:fs/promises";
2014
2014
  import { dirname as dirname2, join as join4, resolve as resolve3 } from "node:path";
2015
+ import { visit as visit12 } from "unist-util-visit";
2016
+
2017
+ // src/docs-plugin/doc-props/doc-props-indexer.ts
2018
+ import remarkMdx2 from "remark-mdx";
2019
+ import remarkParse3 from "remark-parse";
2020
+ import remarkStringify3 from "remark-stringify";
2021
+ import { unified as unified3 } from "unified";
2015
2022
  import { visit as visit11 } from "unist-util-visit";
2023
+ import {
2024
+ UniqueIdService
2025
+ } from "@qualcomm-ui/mdx-common";
2026
+ function extractPickPropsRecord(node) {
2027
+ if (node.name !== "unionWithPick" || !node.value || typeof node.value === "string") {
2028
+ return null;
2029
+ }
2030
+ const estree = node.value.data?.estree;
2031
+ if (!estree?.body?.[0] || estree.body[0].type !== "ExpressionStatement") {
2032
+ return null;
2033
+ }
2034
+ const expression = estree.body[0].expression;
2035
+ if (expression.type !== "ObjectExpression") {
2036
+ return null;
2037
+ }
2038
+ const result = {};
2039
+ for (const property of expression.properties) {
2040
+ if (property.type !== "Property" || property.key.type !== "Identifier") {
2041
+ continue;
2042
+ }
2043
+ if (property.value.type !== "ArrayExpression") {
2044
+ continue;
2045
+ }
2046
+ const key = property.key.name;
2047
+ const values = [];
2048
+ for (const element of property.value.elements) {
2049
+ if (element?.type === "Literal" && typeof element.value === "string") {
2050
+ values.push(element.value);
2051
+ }
2052
+ }
2053
+ result[key] = values;
2054
+ }
2055
+ return result;
2056
+ }
2057
+ var docPropsJsxNodes = [
2058
+ "TypeDocProps",
2059
+ "TypeDocAttributes",
2060
+ "TypeDocAngularAttributes",
2061
+ "TypeDocFunction"
2062
+ ];
2063
+ var DocPropsIndexer = class {
2064
+ docPropsEntries = [];
2065
+ idService = new UniqueIdService();
2066
+ props;
2067
+ pageDocProps = {};
2068
+ constructor(props) {
2069
+ this.props = props;
2070
+ }
2071
+ reset() {
2072
+ this.idService.reset();
2073
+ this.docPropsEntries = [];
2074
+ }
2075
+ /**
2076
+ * Finds all JSX `<TypeDocProps />` nodes on the current page and adds their names
2077
+ * to an array. Once all nodes have been collected, we process them into
2078
+ * `PageSection` entries for the search index.
2079
+ */
2080
+ getTypeDocPropsNodes = () => {
2081
+ return (tree, _file, done) => {
2082
+ visit11(tree, "mdxJsxFlowElement", (node) => {
2083
+ if (node && "name" in node && docPropsJsxNodes.includes(node.name)) {
2084
+ const nameAttr = node.attributes?.find(
2085
+ (attr) => attr.name === "name"
2086
+ );
2087
+ const omitFromAttr = node.attributes?.find(
2088
+ (attr) => attr.name === "omitFrom"
2089
+ );
2090
+ const omitFrom = omitFromAttr ? extractNamesFromAttribute(omitFromAttr) : void 0;
2091
+ if (nameAttr) {
2092
+ const names = extractNamesFromAttribute(nameAttr);
2093
+ for (const name of names) {
2094
+ this.docPropsEntries.push({ name, omitFrom });
2095
+ if (name.endsWith("Props")) {
2096
+ this.docPropsEntries.push({ name: name.slice(0, -5), omitFrom });
2097
+ }
2098
+ }
2099
+ }
2100
+ const unionWithPickAttr = node.attributes?.find(
2101
+ (attr) => attr.name === "unionWithPick"
2102
+ );
2103
+ if (unionWithPickAttr) {
2104
+ try {
2105
+ const unionWithPick = extractPickPropsRecord(unionWithPickAttr);
2106
+ if (unionWithPick) {
2107
+ this.docPropsEntries.push(
2108
+ ...Object.keys(unionWithPick).map((entry) => ({
2109
+ name: entry,
2110
+ omitFrom
2111
+ }))
2112
+ );
2113
+ }
2114
+ } catch (e) {
2115
+ }
2116
+ }
2117
+ }
2118
+ });
2119
+ done();
2120
+ };
2121
+ };
2122
+ build(fileContents, toc) {
2123
+ unified3().use(remarkMdx2).use(this.getTypeDocPropsNodes).use(remarkParse3).use(remarkStringify3).processSync(fileContents);
2124
+ if (!this.docPropsEntries.length) {
2125
+ return null;
2126
+ }
2127
+ for (const item of toc) {
2128
+ this.idService.add(item.id);
2129
+ }
2130
+ return this.docPropsEntries.map((entry) => {
2131
+ const propTypes = this.props[entry.name];
2132
+ if (!propTypes) {
2133
+ return [];
2134
+ }
2135
+ const omittedProps = new Set(
2136
+ (entry.omitFrom ?? []).map((entry2) => {
2137
+ const propTypes2 = this.props[entry2];
2138
+ if (!propTypes2) {
2139
+ return [];
2140
+ }
2141
+ return [
2142
+ propTypes2.props,
2143
+ propTypes2.input,
2144
+ propTypes2.output,
2145
+ propTypes2.publicMethods
2146
+ ].reduce((acc, current) => {
2147
+ if (current) {
2148
+ acc.push(...current.map((prop) => prop.name));
2149
+ }
2150
+ return acc;
2151
+ }, []);
2152
+ }).flat(1).filter(Boolean)
2153
+ );
2154
+ const sections = [];
2155
+ const assembleProps = (propsInput) => {
2156
+ if (!propsInput) {
2157
+ return void 0;
2158
+ }
2159
+ const props = [];
2160
+ for (const prop of propsInput) {
2161
+ if (omittedProps.has(prop.name)) {
2162
+ continue;
2163
+ }
2164
+ const id = this.idService.add(prop.name);
2165
+ props.push({ ...prop, id });
2166
+ sections.push(this.assembleProp(prop, id));
2167
+ }
2168
+ return props;
2169
+ };
2170
+ const resolvedType = propTypes.resolvedType;
2171
+ const functionParameters = resolvedType?.type === "signature" && resolvedType.functionParameters?.length ? this.assembleFunctionParams(
2172
+ resolvedType.functionParameters,
2173
+ sections
2174
+ ) : void 0;
2175
+ this.pageDocProps[entry.name] = {
2176
+ ...this.props[entry.name],
2177
+ input: assembleProps(propTypes.input),
2178
+ output: assembleProps(propTypes.output),
2179
+ props: assembleProps(propTypes.props),
2180
+ publicMethods: assembleProps(propTypes.publicMethods),
2181
+ resolvedType: functionParameters ? { ...resolvedType, functionParameters } : resolvedType
2182
+ };
2183
+ return sections;
2184
+ }).flat();
2185
+ }
2186
+ getDocProps() {
2187
+ return this.docPropsEntries.reduce((acc, entry) => {
2188
+ const propTypes = this.pageDocProps[entry.name];
2189
+ if (propTypes) {
2190
+ acc[entry.name] = propTypes;
2191
+ }
2192
+ return acc;
2193
+ }, {});
2194
+ }
2195
+ assembleFunctionParams(params, sections) {
2196
+ return params.map((param) => {
2197
+ const id = this.idService.add(param.name);
2198
+ sections.push(this.assembleProp(param, id));
2199
+ const args = param.args?.length ? this.assembleFunctionParams(param.args, sections) : void 0;
2200
+ return { ...param, args, id };
2201
+ });
2202
+ }
2203
+ assembleProp(prop, id) {
2204
+ const name = prop.name;
2205
+ const heading2 = {
2206
+ headingLevel: 4,
2207
+ id,
2208
+ tagName: "a",
2209
+ textContent: name
2210
+ };
2211
+ const comment = prop.comment;
2212
+ if (!comment) {
2213
+ return { content: [], heading: heading2 };
2214
+ }
2215
+ const content = {
2216
+ tagName: "p",
2217
+ text: [
2218
+ comment.summary.map((entry) => entry.text.replaceAll("\n", " ")).join("")
2219
+ ]
2220
+ };
2221
+ return { content: [content], heading: heading2 };
2222
+ }
2223
+ };
2224
+
2225
+ // src/docs-plugin/markdown/knowledge/plugins/doc-props-plugin.ts
2016
2226
  function extractBestType(propInfo) {
2017
2227
  const type = propInfo.resolvedType?.prettyType || propInfo.type;
2018
2228
  return cleanType(type.startsWith("| ") ? type.substring(2) : type);
@@ -2184,11 +2394,11 @@ ${tagContent.trim()}
2184
2394
  */
2185
2395
  propsToMarkdownList() {
2186
2396
  return () => (tree, _file, done) => {
2187
- visit11(
2397
+ visit12(
2188
2398
  tree,
2189
2399
  "mdxJsxFlowElement",
2190
2400
  (node, index, parent) => {
2191
- if (node?.name !== "TypeDocProps") {
2401
+ if (!node.name || !docPropsJsxNodes.includes(node.name)) {
2192
2402
  return;
2193
2403
  }
2194
2404
  const nameAttr = node.attributes?.find(
@@ -2269,10 +2479,10 @@ ${propsToDefinitionList(outputs)}`);
2269
2479
  };
2270
2480
 
2271
2481
  // src/docs-plugin/markdown/knowledge/plugins/filter-text-directives.ts
2272
- import { visit as visit12 } from "unist-util-visit";
2482
+ import { visit as visit13 } from "unist-util-visit";
2273
2483
  var filterTextDirectives = () => {
2274
2484
  return (tree, _file, done) => {
2275
- visit12(tree, "text", (node) => {
2485
+ visit13(tree, "text", (node) => {
2276
2486
  const value = node.value?.trim?.();
2277
2487
  if (value && (isStepBlock(value) || isSpoilerBlock(value))) {
2278
2488
  Object.assign(node, {
@@ -2285,10 +2495,10 @@ var filterTextDirectives = () => {
2285
2495
  };
2286
2496
 
2287
2497
  // src/docs-plugin/markdown/knowledge/plugins/npm-install-tabs-plugin.ts
2288
- import { visit as visit13 } from "unist-util-visit";
2498
+ import { visit as visit14 } from "unist-util-visit";
2289
2499
  var formatNpmInstallTabs = () => {
2290
2500
  return (tree, _file, done) => {
2291
- visit13(
2501
+ visit14(
2292
2502
  tree,
2293
2503
  "mdxJsxFlowElement",
2294
2504
  (node, index, parent) => {
@@ -2317,7 +2527,7 @@ var formatNpmInstallTabs = () => {
2317
2527
  };
2318
2528
 
2319
2529
  // src/docs-plugin/markdown/knowledge/plugins/qds-theme-plugin.ts
2320
- import { visit as visit14 } from "unist-util-visit";
2530
+ import { visit as visit15 } from "unist-util-visit";
2321
2531
  function themeDataToJson(data, cssPropertyName) {
2322
2532
  if (!data || typeof data !== "object") {
2323
2533
  return "";
@@ -2376,7 +2586,7 @@ async function formatThemeNodes() {
2376
2586
  }
2377
2587
  };
2378
2588
  return () => (tree, _file, done) => {
2379
- visit14(tree, "mdxJsxFlowElement", (node) => {
2589
+ visit15(tree, "mdxJsxFlowElement", (node) => {
2380
2590
  const handler = node.name && handlers[node.name];
2381
2591
  if (!handler) {
2382
2592
  return;
@@ -2410,14 +2620,14 @@ async function formatThemeNodes() {
2410
2620
  // src/docs-plugin/markdown/knowledge/section-extractor.ts
2411
2621
  import { toString as toString2 } from "mdast-util-to-string";
2412
2622
  import remarkGfm2 from "remark-gfm";
2413
- import remarkStringify3 from "remark-stringify";
2414
- import { unified as unified3 } from "unified";
2415
- import { visit as visit15 } from "unist-util-visit";
2623
+ import remarkStringify4 from "remark-stringify";
2624
+ import { unified as unified4 } from "unified";
2625
+ import { visit as visit16 } from "unist-util-visit";
2416
2626
  function transformLinks() {
2417
2627
  return () => (tree) => {
2418
- visit15(tree, "link", (node) => {
2628
+ visit16(tree, "link", (node) => {
2419
2629
  let text = "";
2420
- visit15(node, "text", (textNode) => {
2630
+ visit16(node, "text", (textNode) => {
2421
2631
  text += textNode.value;
2422
2632
  });
2423
2633
  Object.assign(node, {
@@ -2429,8 +2639,8 @@ function transformLinks() {
2429
2639
  });
2430
2640
  };
2431
2641
  }
2432
- var rawProcessor = unified3().use(remarkGfm2).use(remarkStringify3);
2433
- var contentProcessor = unified3().use(remarkGfm2).use(transformLinks()).use(remarkStringify3);
2642
+ var rawProcessor = unified4().use(remarkGfm2).use(remarkStringify4);
2643
+ var contentProcessor = unified4().use(remarkGfm2).use(transformLinks()).use(remarkStringify4);
2434
2644
  var SectionExtractor = class {
2435
2645
  depths;
2436
2646
  minContentLength;
@@ -2827,7 +3037,7 @@ ${pageEntry.content}`;
2827
3037
  }
2828
3038
  formatFrontmatterExpressions(frontmatter) {
2829
3039
  return () => (tree) => {
2830
- visit16(
3040
+ visit17(
2831
3041
  tree,
2832
3042
  "mdxFlowExpression",
2833
3043
  (node, index, parent) => {
@@ -2866,7 +3076,7 @@ ${pageEntry.content}`;
2866
3076
  if (!baseUrl) {
2867
3077
  return;
2868
3078
  }
2869
- visit16(tree, "link", (node) => {
3079
+ visit17(tree, "link", (node) => {
2870
3080
  if (node.url.startsWith("/")) {
2871
3081
  node.url = `${baseUrl}${node.url}`;
2872
3082
  }
@@ -2969,199 +3179,6 @@ ${pageEntry.content}`;
2969
3179
  import chalk3 from "chalk";
2970
3180
  import { defined as defined2 } from "@qualcomm-ui/utils/guard";
2971
3181
 
2972
- // src/docs-plugin/doc-props/doc-props-indexer.ts
2973
- import remarkMdx2 from "remark-mdx";
2974
- import remarkParse3 from "remark-parse";
2975
- import remarkStringify4 from "remark-stringify";
2976
- import { unified as unified4 } from "unified";
2977
- import { visit as visit17 } from "unist-util-visit";
2978
- import {
2979
- UniqueIdService
2980
- } from "@qualcomm-ui/mdx-common";
2981
- function extractPickPropsRecord(node) {
2982
- if (node.name !== "unionWithPick" || !node.value || typeof node.value === "string") {
2983
- return null;
2984
- }
2985
- const estree = node.value.data?.estree;
2986
- if (!estree?.body?.[0] || estree.body[0].type !== "ExpressionStatement") {
2987
- return null;
2988
- }
2989
- const expression = estree.body[0].expression;
2990
- if (expression.type !== "ObjectExpression") {
2991
- return null;
2992
- }
2993
- const result = {};
2994
- for (const property of expression.properties) {
2995
- if (property.type !== "Property" || property.key.type !== "Identifier") {
2996
- continue;
2997
- }
2998
- if (property.value.type !== "ArrayExpression") {
2999
- continue;
3000
- }
3001
- const key = property.key.name;
3002
- const values = [];
3003
- for (const element of property.value.elements) {
3004
- if (element?.type === "Literal" && typeof element.value === "string") {
3005
- values.push(element.value);
3006
- }
3007
- }
3008
- result[key] = values;
3009
- }
3010
- return result;
3011
- }
3012
- var targetMdxElements = [
3013
- "TypeDocProps",
3014
- "TypeDocAttributes",
3015
- "TypeDocAngularAttributes"
3016
- ];
3017
- var DocPropsIndexer = class {
3018
- docPropsEntries = [];
3019
- idService = new UniqueIdService();
3020
- props;
3021
- pageDocProps = {};
3022
- constructor(props) {
3023
- this.props = props;
3024
- }
3025
- reset() {
3026
- this.idService.reset();
3027
- this.docPropsEntries = [];
3028
- }
3029
- /**
3030
- * Finds all JSX `<TypeDocProps />` nodes on the current page and adds their names
3031
- * to an array. Once all nodes have been collected, we process them into
3032
- * `PageSection` entries for the search index.
3033
- */
3034
- getTypeDocPropsNodes = () => {
3035
- return (tree, _file, done) => {
3036
- visit17(tree, "mdxJsxFlowElement", (node) => {
3037
- if (node && "name" in node && targetMdxElements.includes(node.name)) {
3038
- const nameAttr = node.attributes?.find(
3039
- (attr) => attr.name === "name"
3040
- );
3041
- const omitFromAttr = node.attributes?.find(
3042
- (attr) => attr.name === "omitFrom"
3043
- );
3044
- const omitFrom = omitFromAttr ? extractNamesFromAttribute(omitFromAttr) : void 0;
3045
- if (nameAttr) {
3046
- const names = extractNamesFromAttribute(nameAttr);
3047
- for (const name of names) {
3048
- this.docPropsEntries.push({ name, omitFrom });
3049
- if (name.endsWith("Props")) {
3050
- this.docPropsEntries.push({ name: name.slice(0, -5), omitFrom });
3051
- }
3052
- }
3053
- }
3054
- const unionWithPickAttr = node.attributes?.find(
3055
- (attr) => attr.name === "unionWithPick"
3056
- );
3057
- if (unionWithPickAttr) {
3058
- try {
3059
- const unionWithPick = extractPickPropsRecord(unionWithPickAttr);
3060
- if (unionWithPick) {
3061
- this.docPropsEntries.push(
3062
- ...Object.keys(unionWithPick).map((entry) => ({
3063
- name: entry,
3064
- omitFrom
3065
- }))
3066
- );
3067
- }
3068
- } catch (e) {
3069
- }
3070
- }
3071
- }
3072
- });
3073
- done();
3074
- };
3075
- };
3076
- build(fileContents, toc) {
3077
- unified4().use(remarkMdx2).use(this.getTypeDocPropsNodes).use(remarkParse3).use(remarkStringify4).processSync(fileContents);
3078
- if (!this.docPropsEntries.length) {
3079
- return null;
3080
- }
3081
- for (const item of toc) {
3082
- this.idService.add(item.id);
3083
- }
3084
- return this.docPropsEntries.map((entry) => {
3085
- const propTypes = this.props[entry.name];
3086
- if (!propTypes) {
3087
- return [];
3088
- }
3089
- const omittedProps = new Set(
3090
- (entry.omitFrom ?? []).map((entry2) => {
3091
- const propTypes2 = this.props[entry2];
3092
- if (!propTypes2) {
3093
- return [];
3094
- }
3095
- return [
3096
- propTypes2.props,
3097
- propTypes2.input,
3098
- propTypes2.output,
3099
- propTypes2.publicMethods
3100
- ].reduce((acc, current) => {
3101
- if (current) {
3102
- acc.push(...current.map((prop) => prop.name));
3103
- }
3104
- return acc;
3105
- }, []);
3106
- }).flat(1).filter(Boolean)
3107
- );
3108
- const sections = [];
3109
- const assembleProps = (propsInput) => {
3110
- if (!propsInput) {
3111
- return void 0;
3112
- }
3113
- const props = [];
3114
- for (const prop of propsInput) {
3115
- if (omittedProps.has(prop.name)) {
3116
- continue;
3117
- }
3118
- const id = this.idService.add(prop.name);
3119
- props.push({ ...prop, id });
3120
- sections.push(this.assembleProp(prop, id));
3121
- }
3122
- return props;
3123
- };
3124
- this.pageDocProps[entry.name] = {
3125
- ...this.props[entry.name],
3126
- input: assembleProps(propTypes.input),
3127
- output: assembleProps(propTypes.output),
3128
- props: assembleProps(propTypes.props),
3129
- publicMethods: assembleProps(propTypes.publicMethods)
3130
- };
3131
- return sections;
3132
- }).flat();
3133
- }
3134
- getDocProps() {
3135
- return this.docPropsEntries.reduce((acc, entry) => {
3136
- const propTypes = this.pageDocProps[entry.name];
3137
- if (propTypes) {
3138
- acc[entry.name] = propTypes;
3139
- }
3140
- return acc;
3141
- }, {});
3142
- }
3143
- assembleProp(prop, id) {
3144
- const name = prop.name;
3145
- const heading2 = {
3146
- headingLevel: 4,
3147
- id,
3148
- tagName: "a",
3149
- textContent: name
3150
- };
3151
- const comment = prop.comment;
3152
- if (!comment) {
3153
- return { content: [], heading: heading2 };
3154
- }
3155
- const content = {
3156
- tagName: "p",
3157
- text: [
3158
- comment.summary.map((entry) => entry.text.replaceAll("\n", " ")).join("")
3159
- ]
3160
- };
3161
- return { content: [content], heading: heading2 };
3162
- }
3163
- };
3164
-
3165
3182
  // src/docs-plugin/link-validator.ts
3166
3183
  import chalk2 from "chalk";
3167
3184
  import { posix } from "node:path";
@@ -3444,7 +3461,8 @@ var SearchIndexer = class {
3444
3461
  docPropSections = cached?.pageDocPropSections || (this.docPropsIndexer.build(fileContents, toc) ?? []);
3445
3462
  docProps = cached?.pageDocProps || this.docPropsIndexer.getDocProps();
3446
3463
  }
3447
- if (docPropSections.length) {
3464
+ const hasDocProps = docPropSections.length || Object.keys(docProps).length;
3465
+ if (hasDocProps) {
3448
3466
  this._pageDocProps[defaultSection.pathname] = docProps;
3449
3467
  if (this.config.validatePageLinks) {
3450
3468
  const ids = /* @__PURE__ */ new Set();