@qualcomm-ui/mdx-vite 3.2.0 → 3.3.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
@@ -1,7 +1,7 @@
1
1
  import {createRequire} from "node:module";const require=createRequire(import.meta.url);
2
2
 
3
3
  // src/angular-demo-plugin/angular-demo-plugin.ts
4
- import chalk4 from "chalk";
4
+ import chalk5 from "chalk";
5
5
  import { watch } from "chokidar";
6
6
  import { glob as glob2 } from "glob";
7
7
  import { existsSync, statSync } from "node:fs";
@@ -126,7 +126,8 @@ var configSchema = implement().with({
126
126
  routingStrategy: z2.union([z2.literal("vite-generouted"), z2.any()]).optional(),
127
127
  throwOnError: z2.boolean().optional(),
128
128
  typeDocProps: z2.string().optional(),
129
- typeDocPropsOptions: typeDocPropsSchema.optional()
129
+ typeDocPropsOptions: typeDocPropsSchema.optional(),
130
+ validatePageLinks: z2.boolean().optional()
130
131
  });
131
132
 
132
133
  // src/docs-plugin/config/config-loader.ts
@@ -157,7 +158,8 @@ var ConfigLoader = class {
157
158
  ...conf,
158
159
  appDirectory: conf.appDirectory || "app",
159
160
  filePath: config.filepath,
160
- pageDirectory: conf.pageDirectory ? removeTrailingSlash(conf.pageDirectory) : "routes"
161
+ pageDirectory: conf.pageDirectory ? removeTrailingSlash(conf.pageDirectory) : "routes",
162
+ validatePageLinks: conf.validatePageLinks ?? true
161
163
  };
162
164
  }
163
165
  loadConfig() {
@@ -171,7 +173,7 @@ import { join as join7 } from "node:path";
171
173
  import { dedent } from "@qualcomm-ui/utils/dedent";
172
174
 
173
175
  // src/docs-plugin/plugin-state.ts
174
- import chalk3 from "chalk";
176
+ import chalk4 from "chalk";
175
177
  import chokidar from "chokidar";
176
178
  import { glob } from "glob";
177
179
  import { readFileSync as readFileSync2 } from "node:fs";
@@ -2965,7 +2967,7 @@ ${pageEntry.content}`;
2965
2967
  };
2966
2968
 
2967
2969
  // src/docs-plugin/search-indexer.ts
2968
- import chalk2 from "chalk";
2970
+ import chalk3 from "chalk";
2969
2971
  import { defined as defined2 } from "@qualcomm-ui/utils/guard";
2970
2972
 
2971
2973
  // src/docs-plugin/doc-props/doc-props-indexer.ts
@@ -3161,6 +3163,93 @@ var DocPropsIndexer = class {
3161
3163
  }
3162
3164
  };
3163
3165
 
3166
+ // src/docs-plugin/link-validator.ts
3167
+ import chalk2 from "chalk";
3168
+ import { posix } from "node:path";
3169
+ import { visit as visit18 } from "unist-util-visit";
3170
+ var externalPrefixes = ["https://", "http://", "mailto:", "tel:"];
3171
+ function isExternal(url) {
3172
+ return externalPrefixes.some((prefix) => url.startsWith(prefix));
3173
+ }
3174
+ function resolveLink(url, sourcePathname) {
3175
+ if (isExternal(url)) {
3176
+ return null;
3177
+ }
3178
+ const [rawPath, fragment] = url.split("#", 2);
3179
+ let pathname;
3180
+ if (!rawPath || rawPath === "./" || rawPath === ".") {
3181
+ pathname = sourcePathname;
3182
+ } else if (rawPath.startsWith("/")) {
3183
+ pathname = rawPath;
3184
+ } else {
3185
+ const sourceDir = sourcePathname.endsWith("/") ? sourcePathname : posix.dirname(sourcePathname);
3186
+ pathname = posix.resolve(sourceDir, rawPath);
3187
+ }
3188
+ if (pathname !== "/" && pathname.endsWith("/")) {
3189
+ pathname = pathname.slice(0, -1);
3190
+ }
3191
+ return { fragment: fragment || void 0, pathname };
3192
+ }
3193
+ function collectLinks(tree, sourceFile, sourcePathname) {
3194
+ const links = [];
3195
+ visit18(tree, "link", (node) => {
3196
+ const resolved = resolveLink(node.url, sourcePathname);
3197
+ if (!resolved) {
3198
+ return;
3199
+ }
3200
+ links.push({
3201
+ fragment: resolved.fragment,
3202
+ sourceFile,
3203
+ sourcePathname,
3204
+ targetPathname: resolved.pathname,
3205
+ url: node.url
3206
+ });
3207
+ });
3208
+ return links;
3209
+ }
3210
+ function validateLinks(links, pageMap, docPropIds) {
3211
+ const invalid = [];
3212
+ for (const link of links) {
3213
+ const page = pageMap[link.targetPathname];
3214
+ if (!page) {
3215
+ invalid.push({ ...link, reason: "page-not-found" });
3216
+ continue;
3217
+ }
3218
+ if (link.fragment) {
3219
+ const inToc = page.toc?.some((h) => h.id === link.fragment);
3220
+ const inDocProps = docPropIds?.[link.targetPathname]?.has(link.fragment);
3221
+ if (!inToc && !inDocProps) {
3222
+ invalid.push({ ...link, reason: "fragment-not-found" });
3223
+ }
3224
+ }
3225
+ }
3226
+ return invalid;
3227
+ }
3228
+ function reportInvalidLinks(invalidLinks) {
3229
+ if (invalidLinks.length === 0) {
3230
+ return;
3231
+ }
3232
+ const grouped = /* @__PURE__ */ new Map();
3233
+ for (const link of invalidLinks) {
3234
+ const existing = grouped.get(link.sourcePathname) ?? [];
3235
+ existing.push(link);
3236
+ grouped.set(link.sourcePathname, existing);
3237
+ }
3238
+ console.debug(
3239
+ `
3240
+ ${chalk2.yellowBright.bold(`Found ${invalidLinks.length} broken link${invalidLinks.length === 1 ? "" : "s"}:`)}`
3241
+ );
3242
+ for (const [sourcePathname, links] of grouped) {
3243
+ console.debug(`
3244
+ ${chalk2.blueBright.bold(sourcePathname)}`);
3245
+ for (const link of links) {
3246
+ const reason = link.reason === "page-not-found" ? "page not found" : `fragment "#${link.fragment}" not found`;
3247
+ console.debug(` ${chalk2.red("x")} ${link.url} \u2014 ${reason}`);
3248
+ }
3249
+ }
3250
+ console.debug("");
3251
+ }
3252
+
3164
3253
  // src/docs-plugin/search-indexer.ts
3165
3254
  var SearchIndexer = class {
3166
3255
  docPropsIndexer;
@@ -3169,6 +3258,8 @@ var SearchIndexer = class {
3169
3258
  mdxFileReader;
3170
3259
  allowedHeadings;
3171
3260
  metaJson;
3261
+ _collectedLinks = [];
3262
+ _docPropIds = {};
3172
3263
  routeMetaNav = {};
3173
3264
  config;
3174
3265
  logWarnings;
@@ -3196,6 +3287,8 @@ var SearchIndexer = class {
3196
3287
  _searchIndex = [];
3197
3288
  reset() {
3198
3289
  this.mdxFileReader.reset();
3290
+ this._collectedLinks = [];
3291
+ this._docPropIds = {};
3199
3292
  this._pageMap = {};
3200
3293
  this._searchIndex = [];
3201
3294
  }
@@ -3306,6 +3399,11 @@ var SearchIndexer = class {
3306
3399
  removeMermaidCodeBlocks: true
3307
3400
  });
3308
3401
  const tree = processor.runSync(processor.parse(fileContents));
3402
+ if (this.config.validatePageLinks) {
3403
+ this._collectedLinks.push(
3404
+ ...collectLinks(tree, filePath, defaultSection.pathname)
3405
+ );
3406
+ }
3309
3407
  const pageInfo = {
3310
3408
  frontmatter,
3311
3409
  id: defaultSection.id,
@@ -3318,9 +3416,9 @@ var SearchIndexer = class {
3318
3416
  }
3319
3417
  } catch (error) {
3320
3418
  console.debug(
3321
- `${chalk2.yellowBright.bold(
3419
+ `${chalk3.yellowBright.bold(
3322
3420
  "Failed to parse mdx page content."
3323
- )} ${chalk2.blueBright.bold(filePath)}`
3421
+ )} ${chalk3.blueBright.bold(filePath)}`
3324
3422
  );
3325
3423
  if (this.config.throwOnError) {
3326
3424
  throw new Error(error);
@@ -3349,6 +3447,17 @@ var SearchIndexer = class {
3349
3447
  }
3350
3448
  if (docPropSections.length) {
3351
3449
  this._pageDocProps[defaultSection.pathname] = docProps;
3450
+ if (this.config.validatePageLinks) {
3451
+ const ids = /* @__PURE__ */ new Set();
3452
+ for (const section of docPropSections) {
3453
+ if (section.heading?.id) {
3454
+ ids.add(section.heading.id);
3455
+ }
3456
+ }
3457
+ if (ids.size) {
3458
+ this._docPropIds[defaultSection.pathname] = ids;
3459
+ }
3460
+ }
3352
3461
  }
3353
3462
  if (!cached) {
3354
3463
  this.mdxFileReader.updateCache(filePath, fileContents, {
@@ -3445,6 +3554,14 @@ var SearchIndexer = class {
3445
3554
  ).map((file) => this.compileTsxFile(file));
3446
3555
  this._searchIndex.push(...mdxIndex.filter((entry) => !entry.hideFromSearch));
3447
3556
  this.navBuilder.build();
3557
+ if (this.config.validatePageLinks) {
3558
+ const invalidLinks = validateLinks(
3559
+ this._collectedLinks,
3560
+ this._pageMap,
3561
+ this._docPropIds
3562
+ );
3563
+ reportInvalidLinks(invalidLinks);
3564
+ }
3448
3565
  return compiledFiles;
3449
3566
  }
3450
3567
  };
@@ -3546,7 +3663,7 @@ var PluginState = class {
3546
3663
  const compiledMdxFiles = this.indexer.buildIndex(files, shouldLog);
3547
3664
  if (isDev && shouldLog) {
3548
3665
  console.debug(
3549
- `${chalk3.magenta.bold(`@qualcomm-ui/mdx-vite/docs-plugin:`)} Compiled search index in: ${chalk3.blueBright.bold(prettyMilliseconds(Date.now() - startTime))}${this.indexer.cachedFileCount ? chalk3.greenBright.bold(` (${this.indexer.cachedFileCount}/${this.indexer.mdxFileCount} files cached)`) : ""}`
3666
+ `${chalk4.magenta.bold(`@qualcomm-ui/mdx-vite/docs-plugin:`)} Compiled search index in: ${chalk4.blueBright.bold(prettyMilliseconds(Date.now() - startTime))}${this.indexer.cachedFileCount ? chalk4.greenBright.bold(` (${this.indexer.cachedFileCount}/${this.indexer.mdxFileCount} files cached)`) : ""}`
3550
3667
  );
3551
3668
  }
3552
3669
  return compiledMdxFiles;
@@ -3639,11 +3756,11 @@ var PluginState = class {
3639
3756
  "utf-8"
3640
3757
  );
3641
3758
  this.exports.pathnames = result.pages.pages.map((p) => p.pathname);
3642
- const cacheInfo = result.cachedPageCount > 0 ? chalk3.greenBright.bold(
3759
+ const cacheInfo = result.cachedPageCount > 0 ? chalk4.greenBright.bold(
3643
3760
  ` (${result.cachedPageCount}/${result.totalPageCount} pages cached)`
3644
3761
  ) : "";
3645
3762
  console.debug(
3646
- `${chalk3.magenta.bold(`@qualcomm-ui/mdx-vite/docs-plugin:`)} Generated knowledge exports in: ${chalk3.blueBright.bold(prettyMilliseconds(Date.now() - startTime))}${cacheInfo}`
3763
+ `${chalk4.magenta.bold(`@qualcomm-ui/mdx-vite/docs-plugin:`)} Generated knowledge exports in: ${chalk4.blueBright.bold(prettyMilliseconds(Date.now() - startTime))}${cacheInfo}`
3647
3764
  );
3648
3765
  }
3649
3766
  debouncedGenerateKnowledge(publicDir, opts = {}) {
@@ -3814,10 +3931,12 @@ function frontmatterHmrPlugin(opts = {}) {
3814
3931
  transform(code) {
3815
3932
  if (code.includes(`export const ${exportName}`)) {
3816
3933
  code += `
3817
- ;Object.defineProperty(${exportName}, "$$typeof", {
3818
- enumerable: false,
3819
- value: Symbol.for('react.memo')
3820
- });
3934
+ if (typeof ${exportName} === 'object') {
3935
+ Object.defineProperty(${exportName}, "$$typeof", {
3936
+ enumerable: false,
3937
+ value: Symbol.for('react.memo')
3938
+ });
3939
+ }
3821
3940
  `;
3822
3941
  return code;
3823
3942
  }
@@ -3848,7 +3967,7 @@ import remarkMdxFrontmatter from "remark-mdx-frontmatter";
3848
3967
  // src/docs-plugin/rehype/rehype-slug.ts
3849
3968
  import { headingRank } from "hast-util-heading-rank";
3850
3969
  import { toString as toString3 } from "hast-util-to-string";
3851
- import { visit as visit18 } from "unist-util-visit";
3970
+ import { visit as visit19 } from "unist-util-visit";
3852
3971
  var emptyOptions2 = {};
3853
3972
  var rehypeSlug = (options) => {
3854
3973
  const settings = options || emptyOptions2;
@@ -3859,7 +3978,7 @@ var rehypeSlug = (options) => {
3859
3978
  const slugGenerator = new SlugGenerator();
3860
3979
  return (tree) => {
3861
3980
  slugGenerator.reset();
3862
- visit18(tree, "element", function(node) {
3981
+ visit19(tree, "element", function(node) {
3863
3982
  if (headingRank(node) && !node.properties.id && allowedHeadings.has(node.tagName)) {
3864
3983
  node.properties.id = prefix + slugGenerator.createSlug(toString3(node));
3865
3984
  }
@@ -4228,7 +4347,7 @@ import { readFile as readFile4 } from "node:fs/promises";
4228
4347
  import postcss from "postcss";
4229
4348
  import selectorParser from "postcss-selector-parser";
4230
4349
  import { compile } from "tailwindcss";
4231
- import { visit as visit19 } from "unist-util-visit";
4350
+ import { visit as visit20 } from "unist-util-visit";
4232
4351
  import { camelCase } from "@qualcomm-ui/utils/change-case";
4233
4352
  async function loadStylesheetContent(id) {
4234
4353
  const resolveId = id === "tailwindcss" ? "tailwindcss/index.css" : id;
@@ -4674,15 +4793,15 @@ function angularDemoPlugin({
4674
4793
  langs: ["angular-ts", "angular-html", "css"],
4675
4794
  themes: [theme.dark, theme.light]
4676
4795
  });
4677
- logDev(`${chalk4.blue.bold(LOG_PREFIX)} Shiki highlighter initialized`);
4796
+ logDev(`${chalk5.blue.bold(LOG_PREFIX)} Shiki highlighter initialized`);
4678
4797
  } catch (error) {
4679
4798
  console.warn(
4680
- `${chalk4.blue.bold(LOG_PREFIX)} Failed to initialize highlighter:`,
4799
+ `${chalk5.blue.bold(LOG_PREFIX)} Failed to initialize highlighter:`,
4681
4800
  error
4682
4801
  );
4683
4802
  }
4684
4803
  }
4685
- logDev(`${chalk4.blue.bold(LOG_PREFIX)} Initializing Angular demo scanner`);
4804
+ logDev(`${chalk5.blue.bold(LOG_PREFIX)} Initializing Angular demo scanner`);
4686
4805
  await collectAngularDemos();
4687
4806
  if (process.env.NODE_ENV === "development") {
4688
4807
  if (!hasWatcherInitialized) {
@@ -4690,7 +4809,7 @@ function angularDemoPlugin({
4690
4809
  setupAngularWatcher();
4691
4810
  } else {
4692
4811
  logDev(
4693
- `${chalk4.blue.bold(LOG_PREFIX)} Watcher already initialized by another instance`
4812
+ `${chalk5.blue.bold(LOG_PREFIX)} Watcher already initialized by another instance`
4694
4813
  );
4695
4814
  }
4696
4815
  }
@@ -4747,7 +4866,7 @@ function angularDemoPlugin({
4747
4866
  return [];
4748
4867
  }
4749
4868
  logDev(
4750
- `${chalk4.blue.bold(LOG_PREFIX)} Processing Angular demo change: ${chalk4.cyan(file)}`
4869
+ `${chalk5.blue.bold(LOG_PREFIX)} Processing Angular demo change: ${chalk5.cyan(file)}`
4751
4870
  );
4752
4871
  const code = await readFile5(file, "utf-8");
4753
4872
  const demoInfo = await parseAngularDemo(file, code);
@@ -4801,14 +4920,14 @@ function angularDemoPlugin({
4801
4920
  },
4802
4921
  writeBundle() {
4803
4922
  console.log(
4804
- `${chalk4.blue.bold(LOG_PREFIX)} Successfully integrated ${chalk4.green(demoRegistry.size)} component demos`
4923
+ `${chalk5.blue.bold(LOG_PREFIX)} Successfully integrated ${chalk5.green(demoRegistry.size)} component demos`
4805
4924
  );
4806
4925
  }
4807
4926
  };
4808
4927
  async function collectAngularDemos() {
4809
4928
  if (demoRegistry.size) {
4810
4929
  logDev(
4811
- `${chalk4.magenta.bold(LOG_PREFIX)} Using cached ${chalk4.cyanBright.bold(demoRegistry.size)} demos`
4930
+ `${chalk5.magenta.bold(LOG_PREFIX)} Using cached ${chalk5.cyanBright.bold(demoRegistry.size)} demos`
4812
4931
  );
4813
4932
  return;
4814
4933
  }
@@ -4827,7 +4946,7 @@ function angularDemoPlugin({
4827
4946
  for (const [demoId, demo] of demoRegistry.entries()) {
4828
4947
  if (demo.sourceCode.find((entry) => entry.filePath === file)) {
4829
4948
  logDev(
4830
- `${chalk4.blue.bold(LOG_PREFIX)} Reloading demo ${chalk4.cyan(demoId)} due to imported file change: ${chalk4.yellow(file)}`
4949
+ `${chalk5.blue.bold(LOG_PREFIX)} Reloading demo ${chalk5.cyan(demoId)} due to imported file change: ${chalk5.yellow(file)}`
4831
4950
  );
4832
4951
  const code = await readFile5(demo.filePath, "utf-8");
4833
4952
  const updatedDemo = await parseAngularDemo(demo.filePath, code);
@@ -4895,7 +5014,7 @@ function angularDemoPlugin({
4895
5014
  };
4896
5015
  } catch (error) {
4897
5016
  console.warn(
4898
- `${chalk4.blue.bold(LOG_PREFIX)} Failed to highlight code with ${language} language:`,
5017
+ `${chalk5.blue.bold(LOG_PREFIX)} Failed to highlight code with ${language} language:`,
4899
5018
  error
4900
5019
  );
4901
5020
  return { full: code };
@@ -4903,7 +5022,7 @@ function angularDemoPlugin({
4903
5022
  }
4904
5023
  async function extractRelativeImports2(filePath) {
4905
5024
  try {
4906
- let visit21 = function(node) {
5025
+ let visit22 = function(node) {
4907
5026
  if (ts2.isImportDeclaration(node)) {
4908
5027
  const moduleSpecifier = node.moduleSpecifier;
4909
5028
  if (ts2.isStringLiteral(moduleSpecifier)) {
@@ -4922,9 +5041,9 @@ function angularDemoPlugin({
4922
5041
  }
4923
5042
  }
4924
5043
  }
4925
- ts2.forEachChild(node, visit21);
5044
+ ts2.forEachChild(node, visit22);
4926
5045
  };
4927
- var visit20 = visit21;
5046
+ var visit21 = visit22;
4928
5047
  const content = await readFile5(filePath, "utf-8");
4929
5048
  const sourceFile = ts2.createSourceFile(
4930
5049
  filePath,
@@ -4934,11 +5053,11 @@ function angularDemoPlugin({
4934
5053
  ts2.ScriptKind.TS
4935
5054
  );
4936
5055
  const relativeImports = [];
4937
- visit21(sourceFile);
5056
+ visit22(sourceFile);
4938
5057
  return relativeImports;
4939
5058
  } catch (error) {
4940
5059
  logDev(
4941
- `${chalk4.blue.bold(LOG_PREFIX)} ${chalk4.yellowBright("Failed to extract imports from")} ${chalk4.cyan(filePath)}:`,
5060
+ `${chalk5.blue.bold(LOG_PREFIX)} ${chalk5.yellowBright("Failed to extract imports from")} ${chalk5.cyan(filePath)}:`,
4942
5061
  error
4943
5062
  );
4944
5063
  return [];
@@ -4957,16 +5076,16 @@ function angularDemoPlugin({
4957
5076
  }
4958
5077
  function stripImports(code, fileName) {
4959
5078
  try {
4960
- let visit21 = function(node) {
5079
+ let visit22 = function(node) {
4961
5080
  if (ts2.isImportDeclaration(node)) {
4962
5081
  importRanges.push({
4963
5082
  end: node.getEnd(),
4964
5083
  start: node.getFullStart()
4965
5084
  });
4966
5085
  }
4967
- ts2.forEachChild(node, visit21);
5086
+ ts2.forEachChild(node, visit22);
4968
5087
  };
4969
- var visit20 = visit21;
5088
+ var visit21 = visit22;
4970
5089
  const sourceFile = ts2.createSourceFile(
4971
5090
  fileName,
4972
5091
  code,
@@ -4975,7 +5094,7 @@ function angularDemoPlugin({
4975
5094
  ts2.ScriptKind.TS
4976
5095
  );
4977
5096
  const importRanges = [];
4978
- visit21(sourceFile);
5097
+ visit22(sourceFile);
4979
5098
  return importRanges.map((range) => {
4980
5099
  let endPos = range.end;
4981
5100
  if (code[endPos] === "\n") {
@@ -4985,7 +5104,7 @@ function angularDemoPlugin({
4985
5104
  });
4986
5105
  } catch (error) {
4987
5106
  logDev(
4988
- `${chalk4.blue.bold(LOG_PREFIX)} ${chalk4.redBright("Failed to strip imports from")} ${chalk4.cyan(fileName)}:`,
5107
+ `${chalk5.blue.bold(LOG_PREFIX)} ${chalk5.redBright("Failed to strip imports from")} ${chalk5.cyan(fileName)}:`,
4989
5108
  error
4990
5109
  );
4991
5110
  return [];
@@ -5067,7 +5186,7 @@ function angularDemoPlugin({
5067
5186
  };
5068
5187
  } catch (error) {
5069
5188
  console.error(
5070
- `${chalk4.blue.bold(LOG_PREFIX)} Failed to parse Angular demo ${filePath}:`,
5189
+ `${chalk5.blue.bold(LOG_PREFIX)} Failed to parse Angular demo ${filePath}:`,
5071
5190
  error
5072
5191
  );
5073
5192
  return null;
@@ -5087,7 +5206,7 @@ function angularDemoPlugin({
5087
5206
  let templateUrl = null;
5088
5207
  let hasDefaultExport = false;
5089
5208
  const importsFromAst = [];
5090
- function visit20(node) {
5209
+ function visit21(node) {
5091
5210
  if (ts2.isImportDeclaration(node)) {
5092
5211
  importsFromAst.push(node.getFullText(sourceFile).trim());
5093
5212
  }
@@ -5135,9 +5254,9 @@ function angularDemoPlugin({
5135
5254
  if (ts2.isExportAssignment(node) && !node.isExportEquals) {
5136
5255
  hasDefaultExport = true;
5137
5256
  }
5138
- ts2.forEachChild(node, visit20);
5257
+ ts2.forEachChild(node, visit21);
5139
5258
  }
5140
- visit20(sourceFile);
5259
+ visit21(sourceFile);
5141
5260
  return {
5142
5261
  componentClass,
5143
5262
  hasDefaultExport,
@@ -5195,7 +5314,7 @@ function angularDemoPlugin({
5195
5314
  });
5196
5315
  } catch (error) {
5197
5316
  console.log(
5198
- `${chalk4.blue.bold(LOG_PREFIX)} ${chalk4.redBright("Failed to read template file:")} ${chalk4.cyan(templatePath)}`,
5317
+ `${chalk5.blue.bold(LOG_PREFIX)} ${chalk5.redBright("Failed to read template file:")} ${chalk5.cyan(templatePath)}`,
5199
5318
  error
5200
5319
  );
5201
5320
  return null;
@@ -5216,7 +5335,7 @@ function angularDemoPlugin({
5216
5335
  entries.push(entry);
5217
5336
  } catch (error) {
5218
5337
  logDev(
5219
- `${chalk4.blue.bold(LOG_PREFIX)} ${chalk4.yellowBright("Failed to process relative import:")} ${chalk4.cyan(resolvedPath)}`
5338
+ `${chalk5.blue.bold(LOG_PREFIX)} ${chalk5.yellowBright("Failed to process relative import:")} ${chalk5.cyan(resolvedPath)}`
5220
5339
  );
5221
5340
  }
5222
5341
  }
@@ -5375,7 +5494,7 @@ export function getAngularDemoInfo(demoId) {
5375
5494
  });
5376
5495
  watcher.on("ready", () => {
5377
5496
  logDev(
5378
- `${chalk4.blue.bold(LOG_PREFIX)} Registered ${chalk4.green(demoRegistry.size)} demo files. Watching for file changes...`
5497
+ `${chalk5.blue.bold(LOG_PREFIX)} Registered ${chalk5.green(demoRegistry.size)} demo files. Watching for file changes...`
5379
5498
  );
5380
5499
  });
5381
5500
  watcher.on("add", (filePath) => {
@@ -5387,7 +5506,7 @@ export function getAngularDemoInfo(demoId) {
5387
5506
  }
5388
5507
  if (isAngularDemoFile(filePath)) {
5389
5508
  logDev(
5390
- `${chalk4.blue.bold(LOG_PREFIX)} New Angular demo: ${chalk4.green(filePath)}`
5509
+ `${chalk5.blue.bold(LOG_PREFIX)} New Angular demo: ${chalk5.green(filePath)}`
5391
5510
  );
5392
5511
  void handleAngularDemoUpdate(filePath).then(() => {
5393
5512
  triggerRegistryUpdate();
@@ -5406,7 +5525,7 @@ export function getAngularDemoInfo(demoId) {
5406
5525
  const [demoId] = demoEntry;
5407
5526
  demoRegistry.delete(demoId);
5408
5527
  logDev(
5409
- `${chalk4.blue.bold(LOG_PREFIX)} Removed demo: ${chalk4.red(demoId)}`
5528
+ `${chalk5.blue.bold(LOG_PREFIX)} Removed demo: ${chalk5.red(demoId)}`
5410
5529
  );
5411
5530
  triggerRegistryUpdate();
5412
5531
  }
@@ -5555,7 +5674,7 @@ var NODE_BUILTINS = [
5555
5674
  ];
5556
5675
 
5557
5676
  // src/react-demo-plugin/demo-plugin-utils.ts
5558
- import chalk5 from "chalk";
5677
+ import chalk6 from "chalk";
5559
5678
  import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
5560
5679
  import { readFile as readFile6 } from "node:fs/promises";
5561
5680
  import { dirname as dirname4, join as join9, relative as relative3, resolve as resolve6, sep } from "node:path";
@@ -5578,7 +5697,7 @@ async function extractFileImports(filePath) {
5578
5697
  return extractImports(content, filePath);
5579
5698
  } catch (error) {
5580
5699
  console.log(
5581
- `${chalk5.magenta.bold(LOG_PREFIX2)} ${chalk5.yellowBright("Failed to parse")} ${chalk5.blueBright.bold(filePath)}:`,
5700
+ `${chalk6.magenta.bold(LOG_PREFIX2)} ${chalk6.yellowBright("Failed to parse")} ${chalk6.blueBright.bold(filePath)}:`,
5582
5701
  error
5583
5702
  );
5584
5703
  return null;
@@ -5594,7 +5713,7 @@ function extractImports(code, fileName) {
5594
5713
  );
5595
5714
  const thirdPartyImports = [];
5596
5715
  const relativeImports = [];
5597
- function visit20(node) {
5716
+ function visit21(node) {
5598
5717
  if (ts3.isImportDeclaration(node)) {
5599
5718
  const importSpec = parseImportDeclaration(node, fileName);
5600
5719
  if (importSpec) {
@@ -5605,9 +5724,9 @@ function extractImports(code, fileName) {
5605
5724
  }
5606
5725
  }
5607
5726
  }
5608
- ts3.forEachChild(node, visit20);
5727
+ ts3.forEachChild(node, visit21);
5609
5728
  }
5610
- visit20(sourceFile);
5729
+ visit21(sourceFile);
5611
5730
  return { relativeImports, thirdPartyImports };
5612
5731
  }
5613
5732
  function getScriptKind(fileName) {
@@ -5852,7 +5971,7 @@ function isDemoFile(filePath) {
5852
5971
  }
5853
5972
 
5854
5973
  // src/react-demo-plugin/react-demo-plugin.ts
5855
- import chalk6 from "chalk";
5974
+ import chalk7 from "chalk";
5856
5975
  import { glob as glob3 } from "glob";
5857
5976
  import { readFile as readFile7 } from "node:fs/promises";
5858
5977
  import { basename as basename3, resolve as resolve7 } from "node:path";
@@ -5899,11 +6018,11 @@ function reactDemoPlugin({
5899
6018
  themes: [theme.dark, theme.light]
5900
6019
  });
5901
6020
  console.log(
5902
- `${chalk6.magenta.bold(LOG_PREFIX2)} Shiki highlighter initialized`
6021
+ `${chalk7.magenta.bold(LOG_PREFIX2)} Shiki highlighter initialized`
5903
6022
  );
5904
6023
  } catch (error) {
5905
6024
  console.warn(
5906
- `${chalk6.magenta.bold(LOG_PREFIX2)} Failed to initialize highlighter:`,
6025
+ `${chalk7.magenta.bold(LOG_PREFIX2)} Failed to initialize highlighter:`,
5907
6026
  error
5908
6027
  );
5909
6028
  } finally {
@@ -5958,7 +6077,7 @@ function reactDemoPlugin({
5958
6077
  },
5959
6078
  writeBundle() {
5960
6079
  console.log(
5961
- `${chalk6.blue.bold(LOG_PREFIX2)} Successfully integrated ${chalk6.green(demoRegistry2.size)} component demos`
6080
+ `${chalk7.blue.bold(LOG_PREFIX2)} Successfully integrated ${chalk7.green(demoRegistry2.size)} component demos`
5962
6081
  );
5963
6082
  }
5964
6083
  };
@@ -6046,7 +6165,7 @@ function reactDemoPlugin({
6046
6165
  };
6047
6166
  } catch (error) {
6048
6167
  console.warn(
6049
- `${chalk6.magenta.bold(LOG_PREFIX2)} Failed to highlight code:`,
6168
+ `${chalk7.magenta.bold(LOG_PREFIX2)} Failed to highlight code:`,
6050
6169
  error
6051
6170
  );
6052
6171
  return { full: code };
@@ -6204,16 +6323,16 @@ function reactDemoPlugin({
6204
6323
  }
6205
6324
  function stripImports(code, fileName) {
6206
6325
  try {
6207
- let visit21 = function(node) {
6326
+ let visit22 = function(node) {
6208
6327
  if (ts4.isImportDeclaration(node)) {
6209
6328
  importRanges.push({
6210
6329
  end: node.getEnd(),
6211
6330
  start: node.getFullStart()
6212
6331
  });
6213
6332
  }
6214
- ts4.forEachChild(node, visit21);
6333
+ ts4.forEachChild(node, visit22);
6215
6334
  };
6216
- var visit20 = visit21;
6335
+ var visit21 = visit22;
6217
6336
  const sourceFile = ts4.createSourceFile(
6218
6337
  fileName,
6219
6338
  code,
@@ -6222,7 +6341,7 @@ function reactDemoPlugin({
6222
6341
  getScriptKind(fileName)
6223
6342
  );
6224
6343
  const importRanges = [];
6225
- visit21(sourceFile);
6344
+ visit22(sourceFile);
6226
6345
  return importRanges.map((range) => {
6227
6346
  let endPos = range.end;
6228
6347
  if (code[endPos] === "\n") {