@qualcomm-ui/mdx-vite 3.2.2 → 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 = {}) {
@@ -3850,7 +3967,7 @@ import remarkMdxFrontmatter from "remark-mdx-frontmatter";
3850
3967
  // src/docs-plugin/rehype/rehype-slug.ts
3851
3968
  import { headingRank } from "hast-util-heading-rank";
3852
3969
  import { toString as toString3 } from "hast-util-to-string";
3853
- import { visit as visit18 } from "unist-util-visit";
3970
+ import { visit as visit19 } from "unist-util-visit";
3854
3971
  var emptyOptions2 = {};
3855
3972
  var rehypeSlug = (options) => {
3856
3973
  const settings = options || emptyOptions2;
@@ -3861,7 +3978,7 @@ var rehypeSlug = (options) => {
3861
3978
  const slugGenerator = new SlugGenerator();
3862
3979
  return (tree) => {
3863
3980
  slugGenerator.reset();
3864
- visit18(tree, "element", function(node) {
3981
+ visit19(tree, "element", function(node) {
3865
3982
  if (headingRank(node) && !node.properties.id && allowedHeadings.has(node.tagName)) {
3866
3983
  node.properties.id = prefix + slugGenerator.createSlug(toString3(node));
3867
3984
  }
@@ -4230,7 +4347,7 @@ import { readFile as readFile4 } from "node:fs/promises";
4230
4347
  import postcss from "postcss";
4231
4348
  import selectorParser from "postcss-selector-parser";
4232
4349
  import { compile } from "tailwindcss";
4233
- import { visit as visit19 } from "unist-util-visit";
4350
+ import { visit as visit20 } from "unist-util-visit";
4234
4351
  import { camelCase } from "@qualcomm-ui/utils/change-case";
4235
4352
  async function loadStylesheetContent(id) {
4236
4353
  const resolveId = id === "tailwindcss" ? "tailwindcss/index.css" : id;
@@ -4676,15 +4793,15 @@ function angularDemoPlugin({
4676
4793
  langs: ["angular-ts", "angular-html", "css"],
4677
4794
  themes: [theme.dark, theme.light]
4678
4795
  });
4679
- logDev(`${chalk4.blue.bold(LOG_PREFIX)} Shiki highlighter initialized`);
4796
+ logDev(`${chalk5.blue.bold(LOG_PREFIX)} Shiki highlighter initialized`);
4680
4797
  } catch (error) {
4681
4798
  console.warn(
4682
- `${chalk4.blue.bold(LOG_PREFIX)} Failed to initialize highlighter:`,
4799
+ `${chalk5.blue.bold(LOG_PREFIX)} Failed to initialize highlighter:`,
4683
4800
  error
4684
4801
  );
4685
4802
  }
4686
4803
  }
4687
- logDev(`${chalk4.blue.bold(LOG_PREFIX)} Initializing Angular demo scanner`);
4804
+ logDev(`${chalk5.blue.bold(LOG_PREFIX)} Initializing Angular demo scanner`);
4688
4805
  await collectAngularDemos();
4689
4806
  if (process.env.NODE_ENV === "development") {
4690
4807
  if (!hasWatcherInitialized) {
@@ -4692,7 +4809,7 @@ function angularDemoPlugin({
4692
4809
  setupAngularWatcher();
4693
4810
  } else {
4694
4811
  logDev(
4695
- `${chalk4.blue.bold(LOG_PREFIX)} Watcher already initialized by another instance`
4812
+ `${chalk5.blue.bold(LOG_PREFIX)} Watcher already initialized by another instance`
4696
4813
  );
4697
4814
  }
4698
4815
  }
@@ -4749,7 +4866,7 @@ function angularDemoPlugin({
4749
4866
  return [];
4750
4867
  }
4751
4868
  logDev(
4752
- `${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)}`
4753
4870
  );
4754
4871
  const code = await readFile5(file, "utf-8");
4755
4872
  const demoInfo = await parseAngularDemo(file, code);
@@ -4803,14 +4920,14 @@ function angularDemoPlugin({
4803
4920
  },
4804
4921
  writeBundle() {
4805
4922
  console.log(
4806
- `${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`
4807
4924
  );
4808
4925
  }
4809
4926
  };
4810
4927
  async function collectAngularDemos() {
4811
4928
  if (demoRegistry.size) {
4812
4929
  logDev(
4813
- `${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`
4814
4931
  );
4815
4932
  return;
4816
4933
  }
@@ -4829,7 +4946,7 @@ function angularDemoPlugin({
4829
4946
  for (const [demoId, demo] of demoRegistry.entries()) {
4830
4947
  if (demo.sourceCode.find((entry) => entry.filePath === file)) {
4831
4948
  logDev(
4832
- `${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)}`
4833
4950
  );
4834
4951
  const code = await readFile5(demo.filePath, "utf-8");
4835
4952
  const updatedDemo = await parseAngularDemo(demo.filePath, code);
@@ -4897,7 +5014,7 @@ function angularDemoPlugin({
4897
5014
  };
4898
5015
  } catch (error) {
4899
5016
  console.warn(
4900
- `${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:`,
4901
5018
  error
4902
5019
  );
4903
5020
  return { full: code };
@@ -4905,7 +5022,7 @@ function angularDemoPlugin({
4905
5022
  }
4906
5023
  async function extractRelativeImports2(filePath) {
4907
5024
  try {
4908
- let visit21 = function(node) {
5025
+ let visit22 = function(node) {
4909
5026
  if (ts2.isImportDeclaration(node)) {
4910
5027
  const moduleSpecifier = node.moduleSpecifier;
4911
5028
  if (ts2.isStringLiteral(moduleSpecifier)) {
@@ -4924,9 +5041,9 @@ function angularDemoPlugin({
4924
5041
  }
4925
5042
  }
4926
5043
  }
4927
- ts2.forEachChild(node, visit21);
5044
+ ts2.forEachChild(node, visit22);
4928
5045
  };
4929
- var visit20 = visit21;
5046
+ var visit21 = visit22;
4930
5047
  const content = await readFile5(filePath, "utf-8");
4931
5048
  const sourceFile = ts2.createSourceFile(
4932
5049
  filePath,
@@ -4936,11 +5053,11 @@ function angularDemoPlugin({
4936
5053
  ts2.ScriptKind.TS
4937
5054
  );
4938
5055
  const relativeImports = [];
4939
- visit21(sourceFile);
5056
+ visit22(sourceFile);
4940
5057
  return relativeImports;
4941
5058
  } catch (error) {
4942
5059
  logDev(
4943
- `${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)}:`,
4944
5061
  error
4945
5062
  );
4946
5063
  return [];
@@ -4959,16 +5076,16 @@ function angularDemoPlugin({
4959
5076
  }
4960
5077
  function stripImports(code, fileName) {
4961
5078
  try {
4962
- let visit21 = function(node) {
5079
+ let visit22 = function(node) {
4963
5080
  if (ts2.isImportDeclaration(node)) {
4964
5081
  importRanges.push({
4965
5082
  end: node.getEnd(),
4966
5083
  start: node.getFullStart()
4967
5084
  });
4968
5085
  }
4969
- ts2.forEachChild(node, visit21);
5086
+ ts2.forEachChild(node, visit22);
4970
5087
  };
4971
- var visit20 = visit21;
5088
+ var visit21 = visit22;
4972
5089
  const sourceFile = ts2.createSourceFile(
4973
5090
  fileName,
4974
5091
  code,
@@ -4977,7 +5094,7 @@ function angularDemoPlugin({
4977
5094
  ts2.ScriptKind.TS
4978
5095
  );
4979
5096
  const importRanges = [];
4980
- visit21(sourceFile);
5097
+ visit22(sourceFile);
4981
5098
  return importRanges.map((range) => {
4982
5099
  let endPos = range.end;
4983
5100
  if (code[endPos] === "\n") {
@@ -4987,7 +5104,7 @@ function angularDemoPlugin({
4987
5104
  });
4988
5105
  } catch (error) {
4989
5106
  logDev(
4990
- `${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)}:`,
4991
5108
  error
4992
5109
  );
4993
5110
  return [];
@@ -5069,7 +5186,7 @@ function angularDemoPlugin({
5069
5186
  };
5070
5187
  } catch (error) {
5071
5188
  console.error(
5072
- `${chalk4.blue.bold(LOG_PREFIX)} Failed to parse Angular demo ${filePath}:`,
5189
+ `${chalk5.blue.bold(LOG_PREFIX)} Failed to parse Angular demo ${filePath}:`,
5073
5190
  error
5074
5191
  );
5075
5192
  return null;
@@ -5089,7 +5206,7 @@ function angularDemoPlugin({
5089
5206
  let templateUrl = null;
5090
5207
  let hasDefaultExport = false;
5091
5208
  const importsFromAst = [];
5092
- function visit20(node) {
5209
+ function visit21(node) {
5093
5210
  if (ts2.isImportDeclaration(node)) {
5094
5211
  importsFromAst.push(node.getFullText(sourceFile).trim());
5095
5212
  }
@@ -5137,9 +5254,9 @@ function angularDemoPlugin({
5137
5254
  if (ts2.isExportAssignment(node) && !node.isExportEquals) {
5138
5255
  hasDefaultExport = true;
5139
5256
  }
5140
- ts2.forEachChild(node, visit20);
5257
+ ts2.forEachChild(node, visit21);
5141
5258
  }
5142
- visit20(sourceFile);
5259
+ visit21(sourceFile);
5143
5260
  return {
5144
5261
  componentClass,
5145
5262
  hasDefaultExport,
@@ -5197,7 +5314,7 @@ function angularDemoPlugin({
5197
5314
  });
5198
5315
  } catch (error) {
5199
5316
  console.log(
5200
- `${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)}`,
5201
5318
  error
5202
5319
  );
5203
5320
  return null;
@@ -5218,7 +5335,7 @@ function angularDemoPlugin({
5218
5335
  entries.push(entry);
5219
5336
  } catch (error) {
5220
5337
  logDev(
5221
- `${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)}`
5222
5339
  );
5223
5340
  }
5224
5341
  }
@@ -5377,7 +5494,7 @@ export function getAngularDemoInfo(demoId) {
5377
5494
  });
5378
5495
  watcher.on("ready", () => {
5379
5496
  logDev(
5380
- `${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...`
5381
5498
  );
5382
5499
  });
5383
5500
  watcher.on("add", (filePath) => {
@@ -5389,7 +5506,7 @@ export function getAngularDemoInfo(demoId) {
5389
5506
  }
5390
5507
  if (isAngularDemoFile(filePath)) {
5391
5508
  logDev(
5392
- `${chalk4.blue.bold(LOG_PREFIX)} New Angular demo: ${chalk4.green(filePath)}`
5509
+ `${chalk5.blue.bold(LOG_PREFIX)} New Angular demo: ${chalk5.green(filePath)}`
5393
5510
  );
5394
5511
  void handleAngularDemoUpdate(filePath).then(() => {
5395
5512
  triggerRegistryUpdate();
@@ -5408,7 +5525,7 @@ export function getAngularDemoInfo(demoId) {
5408
5525
  const [demoId] = demoEntry;
5409
5526
  demoRegistry.delete(demoId);
5410
5527
  logDev(
5411
- `${chalk4.blue.bold(LOG_PREFIX)} Removed demo: ${chalk4.red(demoId)}`
5528
+ `${chalk5.blue.bold(LOG_PREFIX)} Removed demo: ${chalk5.red(demoId)}`
5412
5529
  );
5413
5530
  triggerRegistryUpdate();
5414
5531
  }
@@ -5557,7 +5674,7 @@ var NODE_BUILTINS = [
5557
5674
  ];
5558
5675
 
5559
5676
  // src/react-demo-plugin/demo-plugin-utils.ts
5560
- import chalk5 from "chalk";
5677
+ import chalk6 from "chalk";
5561
5678
  import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
5562
5679
  import { readFile as readFile6 } from "node:fs/promises";
5563
5680
  import { dirname as dirname4, join as join9, relative as relative3, resolve as resolve6, sep } from "node:path";
@@ -5580,7 +5697,7 @@ async function extractFileImports(filePath) {
5580
5697
  return extractImports(content, filePath);
5581
5698
  } catch (error) {
5582
5699
  console.log(
5583
- `${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)}:`,
5584
5701
  error
5585
5702
  );
5586
5703
  return null;
@@ -5596,7 +5713,7 @@ function extractImports(code, fileName) {
5596
5713
  );
5597
5714
  const thirdPartyImports = [];
5598
5715
  const relativeImports = [];
5599
- function visit20(node) {
5716
+ function visit21(node) {
5600
5717
  if (ts3.isImportDeclaration(node)) {
5601
5718
  const importSpec = parseImportDeclaration(node, fileName);
5602
5719
  if (importSpec) {
@@ -5607,9 +5724,9 @@ function extractImports(code, fileName) {
5607
5724
  }
5608
5725
  }
5609
5726
  }
5610
- ts3.forEachChild(node, visit20);
5727
+ ts3.forEachChild(node, visit21);
5611
5728
  }
5612
- visit20(sourceFile);
5729
+ visit21(sourceFile);
5613
5730
  return { relativeImports, thirdPartyImports };
5614
5731
  }
5615
5732
  function getScriptKind(fileName) {
@@ -5854,7 +5971,7 @@ function isDemoFile(filePath) {
5854
5971
  }
5855
5972
 
5856
5973
  // src/react-demo-plugin/react-demo-plugin.ts
5857
- import chalk6 from "chalk";
5974
+ import chalk7 from "chalk";
5858
5975
  import { glob as glob3 } from "glob";
5859
5976
  import { readFile as readFile7 } from "node:fs/promises";
5860
5977
  import { basename as basename3, resolve as resolve7 } from "node:path";
@@ -5901,11 +6018,11 @@ function reactDemoPlugin({
5901
6018
  themes: [theme.dark, theme.light]
5902
6019
  });
5903
6020
  console.log(
5904
- `${chalk6.magenta.bold(LOG_PREFIX2)} Shiki highlighter initialized`
6021
+ `${chalk7.magenta.bold(LOG_PREFIX2)} Shiki highlighter initialized`
5905
6022
  );
5906
6023
  } catch (error) {
5907
6024
  console.warn(
5908
- `${chalk6.magenta.bold(LOG_PREFIX2)} Failed to initialize highlighter:`,
6025
+ `${chalk7.magenta.bold(LOG_PREFIX2)} Failed to initialize highlighter:`,
5909
6026
  error
5910
6027
  );
5911
6028
  } finally {
@@ -5960,7 +6077,7 @@ function reactDemoPlugin({
5960
6077
  },
5961
6078
  writeBundle() {
5962
6079
  console.log(
5963
- `${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`
5964
6081
  );
5965
6082
  }
5966
6083
  };
@@ -6048,7 +6165,7 @@ function reactDemoPlugin({
6048
6165
  };
6049
6166
  } catch (error) {
6050
6167
  console.warn(
6051
- `${chalk6.magenta.bold(LOG_PREFIX2)} Failed to highlight code:`,
6168
+ `${chalk7.magenta.bold(LOG_PREFIX2)} Failed to highlight code:`,
6052
6169
  error
6053
6170
  );
6054
6171
  return { full: code };
@@ -6206,16 +6323,16 @@ function reactDemoPlugin({
6206
6323
  }
6207
6324
  function stripImports(code, fileName) {
6208
6325
  try {
6209
- let visit21 = function(node) {
6326
+ let visit22 = function(node) {
6210
6327
  if (ts4.isImportDeclaration(node)) {
6211
6328
  importRanges.push({
6212
6329
  end: node.getEnd(),
6213
6330
  start: node.getFullStart()
6214
6331
  });
6215
6332
  }
6216
- ts4.forEachChild(node, visit21);
6333
+ ts4.forEachChild(node, visit22);
6217
6334
  };
6218
- var visit20 = visit21;
6335
+ var visit21 = visit22;
6219
6336
  const sourceFile = ts4.createSourceFile(
6220
6337
  fileName,
6221
6338
  code,
@@ -6224,7 +6341,7 @@ function reactDemoPlugin({
6224
6341
  getScriptKind(fileName)
6225
6342
  );
6226
6343
  const importRanges = [];
6227
- visit21(sourceFile);
6344
+ visit22(sourceFile);
6228
6345
  return importRanges.map((range) => {
6229
6346
  let endPos = range.end;
6230
6347
  if (code[endPos] === "\n") {