@qualcomm-ui/mdx-vite 3.8.1 → 3.8.2
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/cli.js +9 -9
- package/dist/cli.js.map +1 -1
- package/dist/docs-plugin/generate-page-map.d.ts.map +1 -1
- package/dist/index.js +28 -28
- package/dist/index.js.map +1 -1
- package/dist/search-indexer-DOffnbB9.js +14 -0
- package/dist/{search-indexer-D3Y9DkgK.js.map → search-indexer-DOffnbB9.js.map} +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/search-indexer-D3Y9DkgK.js +0 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-page-map.d.ts","sourceRoot":"","sources":["../../src/docs-plugin/generate-page-map.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-page-map.d.ts","sourceRoot":"","sources":["../../src/docs-plugin/generate-page-map.ts"],"names":[],"mappings":"AAmCA,wBAAgB,yBAAyB,SAsDxC"}
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)}var
|
|
1
|
+
import{A as e,C as t,D as n,E as r,F as i,I as a,M as o,N as s,O as c,P as l,S as u,T as d,_ as f,a as p,b as m,c as ee,d as h,f as g,g as te,h as _,i as v,j as ne,k as y,l as re,m as ie,n as ae,o as b,p as oe,r as se,s as ce,t as le,u as ue,v as de,w as fe,x as pe,y as me}from"./search-indexer-DOffnbB9.js";import{basename as x,dirname as S,extname as he,join as C,relative as w,resolve as T,sep as ge}from"node:path";import{existsSync as E,readFileSync as _e,statSync as ve}from"node:fs";import{glob as ye}from"glob";import{mkdir as be,readFile as D,readdir as xe,writeFile as Se}from"node:fs/promises";import O from"chalk";import{visit as k}from"unist-util-visit";import{quiCustomDarkTheme as Ce}from"@qualcomm-ui/mdx-common";import we from"remark-frontmatter";import Te from"remark-gfm";import*as A from"typescript";import{merge as Ee}from"lodash-es";import{camelCase as De,kebabCase as Oe,pascalCase as ke}from"@qualcomm-ui/utils/change-case";import Ae,{watch as je}from"chokidar";import{createHighlighter as Me}from"shiki";import{dedent as j}from"@qualcomm-ui/utils/dedent";import Ne from"pretty-ms";import{minimatch as Pe}from"minimatch";import Fe from"@shikijs/rehype";import{transformerNotationDiff as Ie,transformerNotationErrorLevel as Le,transformerNotationFocus as Re,transformerNotationHighlight as ze,transformerNotationWordHighlight as Be,transformerRemoveNotationEscape as Ve,transformerRenderIndentGuides as He}from"@shikijs/transformers";import Ue from"rehype-mdx-code-props";import We from"remark-mdx-frontmatter";import{headingRank as Ge}from"hast-util-heading-rank";import{toString as Ke}from"hast-util-to-string";import{heading as qe}from"hast-util-heading";import"hast-util-from-html";import"hast-util-to-html";import Je from"postcss";import Ye from"postcss-selector-parser";import{compile as Xe}from"tailwindcss";function Ze(e,t){if(!t?.include?.length)return e;let n=t.include,r=t.exclude??[],i={};for(let[t,a]of Object.entries(e)){if(a===void 0)continue;let e=n.some(e=>Pe(t,e)),o=r.some(e=>Pe(t,e));e&&!o&&(i[t]=a)}return i}async function Qe(e,t,n=new Set,r){let i=[],a=ce(e);for(let e of a){let a=await re(e,t);if(!(!a||n.has(a))){n.add(a);try{let e=await D(a,`utf-8`);i.push({content:e,path:a});let t=await Qe(e,a,n,r);i.push(...t)}catch{r&&console.log(` Could not read import: ${a}`)}}}return i}function $e(e,t){return()=>async n=>{let r=[];k(n,`mdxJsxFlowElement`,(n,i,a)=>{if(!n?.name||![`QdsDemo`,`CodeDemo`,`Demo`].includes(n.name))return;let o=n.attributes?.find(e=>e.type===`mdxJsxAttribute`&&e.name===`name`),s=n.attributes?.find(e=>e.type===`mdxJsxAttribute`&&e.name===`node`),c;if(o&&typeof o.value==`string`)c=o.value;else if(s?.value&&typeof s.value!=`string`){let e=s.value.data?.estree;if(e?.body?.[0]?.type===`ExpressionStatement`){let t=e.body[0].expression;t.type===`MemberExpression`&&t.object.type===`Identifier`&&t.object.name===`Demo`&&t.property.type===`Identifier`&&(c=t.property.name)}}if(!c){a&&i!==void 0&&a.children.splice(i,1);return}r.push((async()=>{let r=Oe(c),o=`${r}.tsx`;if(!e){t&&console.log(` No demos folder for ${c}`),a&&i!==void 0&&a.children.splice(i,1);return}let s=C(e,o),l=!1;if(!await b(s))if(s=C(e,`${r}.ts`),await b(s))l=!0,o=`${Oe(c).replace(`-component`,`.component`)}.ts`,s=C(e,o);else{console.log(` Demo not found ${c}`),a&&i!==void 0&&a.children.splice(i,1);return}try{let e=await D(s,`utf-8`),r=ee(e);t&&console.log(` Replaced demo ${c} with source code`);let o={lang:l?`angular-ts`:`tsx`,meta:null,type:`code`,value:r},u=await Qe(e,s,new Set,t);if(u.length===0||!a||i===void 0)Object.assign(n,o);else{let e=[o];for(let t of u){let n=he(t.path).slice(1),r=x(t.path);e.push({lang:n,meta:`title="${r}"`,type:`code`,value:t.content})}a.children.splice(i,1,...e),t&&console.log(` Added ${u.length} imported file(s) after demo`)}}catch(e){t&&console.log(`Error reading demo ${c}`,e),a&&i!==void 0&&a.children.splice(i,1)}})())}),await Promise.all(r)}}function et(e){let t=e.resolvedType?.prettyType||e.type;return nt(t.startsWith(`| `)?t.substring(2):t)}function tt(e,t){return!!(e.resolvedType?.required&&!t)}function nt(e){return e.replace(/\n/g,` `).replace(/\s+/g,` `).trim()}function rt(e){return e.replace(/^\n+/,``).replace(/\n+$/,``).trim()}function it(e){return e.replace(/\n/g,` `)}function at(e){return e.length===0?``:e.map(e=>{let t=[`- **${e.name}** (\`${it(e.type)}\``];return e.defaultValue&&t.push(`, default: \`${it(e.defaultValue)}\``),e.required&&t.push(`, required`),t.push(`)`),e.description&&t.push(` - ${it(e.description)}`),t.join(``)}).join(`
|
|
2
|
+
`)}var ot=class{constructor(e){this.docProps=null,this.docPropsPath=e.docPropsPath,this.routeDir=e.routeDir,this.verbose=e.verbose??!1}async loadDocProps(){if(this.docProps)return this.docProps;let e=this.docPropsPath?await b(this.docPropsPath)?this.docPropsPath:T(process.cwd(),this.docPropsPath):C(S(this.routeDir),`doc-props.json`);if(!await b(e))return this.verbose&&console.log(`Doc props file not found at: ${e}`),null;try{let t=await D(e,`utf-8`),n=JSON.parse(t);return this.verbose&&(console.log(`Loaded doc props from: ${e}`),console.log(`Found ${Object.keys(n.props).length} component types`)),this.docProps=n,n}catch(e){return this.verbose&&console.log(`Error loading doc props`,e),null}}formatCommentParts(e){return e.map(e=>{switch(e.kind){case`text`:return e.text;case`code`:let t=e.text.replace(/```\w*\n?/g,``).replace(/\n?```/g,``).trim();return t.includes(`
|
|
3
3
|
`)?`\`\`\`\n${t}\n\`\`\``:t;default:return`tag`in e&&e.tag===`@link`&&typeof e.target==`string`&&e.text===`Learn more`?``:e.text}}).join(``).replace(/\n/g,` `).replace(/\s+/g,` `).trim()}formatComment(e){if(!e)return``;let t=[];if(e.summary&&e.summary.length>0){let n=this.formatCommentParts(e.summary);n.trim()&&t.push(n.trim())}if(e.blockTags&&e.blockTags.length>0)for(let n of e.blockTags){let e=this.formatCommentParts(n.content);if(e.trim()){let r=n.tag.replace(`@`,``);if(r===`default`||r===`defaultValue`)continue;r===`example`?t.push(`**Example:**\n\`\`\`\n${e.trim()}\n\`\`\``):t.push(`**${r}:** ${e.trim()}`)}}return t.join(`
|
|
4
4
|
|
|
5
|
-
`)}extractSinceTag(e){return(e?.blockTags?.find(e=>e?.tag===`@since`))?.content?.[0]?.text}extractProps(e,t){let n=[];return e.props?.length&&n.push(...e.props.map(e=>this.convertPropInfo(e,t))),e.input?.length&&n.push(...e.input.map(e=>this.convertPropInfo(e,t,`input`))),e.output?.length&&n.push(...e.output.map(e=>this.convertPropInfo(e,t,`output`))),n}convertPropInfo(e,t,n=void 0){return{name:e.name,type:
|
|
5
|
+
`)}extractSinceTag(e){return(e?.blockTags?.find(e=>e?.tag===`@since`))?.content?.[0]?.text}extractProps(e,t){let n=[];return e.props?.length&&n.push(...e.props.map(e=>this.convertPropInfo(e,t))),e.input?.length&&n.push(...e.input.map(e=>this.convertPropInfo(e,t,`input`))),e.output?.length&&n.push(...e.output.map(e=>this.convertPropInfo(e,t,`output`))),n}convertPropInfo(e,t,n=void 0){return{name:e.name,type:et(e),...e.defaultValue&&{defaultValue:rt(e.defaultValue)},description:this.formatComment(e.comment||null),propType:n,required:tt(e,t)||void 0,since:this.extractSinceTag(e.comment)}}propsToMarkdownList(){return()=>(e,t,n)=>{k(e,`mdxJsxFlowElement`,(e,t,n)=>{if(!e.name||!ue.includes(e.name))return;let r=e.attributes?.find(e=>e.type===`mdxJsxAttribute`&&e.name===`name`),i=e.attributes?.some(e=>e.type===`mdxJsxAttribute`&&e.name===`partial`);if(!this.docProps||!r){n&&t!==void 0&&n.children.splice(t,1);return}let a=y(r);if(a.length===0){n&&t!==void 0&&n.children.splice(t,1);return}let o=a[0],s=this.docProps.props[o];if(!s){this.verbose&&console.log(` TypeDocProps not found: ${o}`),n&&t!==void 0&&n.children.splice(t,1);return}let c=this.extractProps(s,!!i);this.verbose&&console.log(` Replaced TypeDocProps ${o} with API documentation`);let l=c.filter(e=>e.propType===void 0),u=c.filter(e=>e.propType===`input`),d=c.filter(e=>e.propType===`output`),f=[];l.length>0&&f.push(at(l)),u.length>0&&f.push(`**Inputs**\n\n${at(u)}`),d.length>0&&f.push(`**Outputs**\n\n${at(d)}`);let p=f.join(`
|
|
6
6
|
|
|
7
|
-
`);if(!p){n&&t!==void 0&&n.children.splice(t,1);return}Object.assign(e,{data:{typeDocProps:{name:o,props:c,since:this.extractSinceTag(s.comment)}},lang:null,meta:null,type:`code`,value:p})}),n()}}},
|
|
8
|
-
`),s=
|
|
7
|
+
`);if(!p){n&&t!==void 0&&n.children.splice(t,1);return}Object.assign(e,{data:{typeDocProps:{name:o,props:c,since:this.extractSinceTag(s.comment)}},lang:null,meta:null,type:`code`,value:p})}),n()}}},st=()=>(e,t,n)=>{k(e,`text`,e=>{let t=e.value?.trim?.();t&&(g(t)||ie(t)||te(t))&&Object.assign(e,{value:``})}),n()},ct=()=>(e,t,n)=>{k(e,`mdxJsxFlowElement`,(e,t,n)=>{if(e?.name===`NpmInstallTabs`){let r=e.attributes?.find(e=>e.type===`mdxJsxAttribute`&&e.name===`packages`),i=r?y(r):[];if(i.length===0){n&&t!==void 0&&n.children.splice(t,1);return}Object.assign(e,{lang:`shell`,meta:null,type:`code`,value:`npm install ${i.join(` `)}`})}}),n()};function lt(e,t){return!e||typeof e!=`object`?``:JSON.stringify(t?{cssProperty:t,data:e}:e,null,2)}function M(e,t){return t.split(`.`).reduce((e,t)=>e&&typeof e==`object`?e[t]:void 0,e)}function N(e,t){let n=e.attributes?.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return n?.value?typeof n.value==`string`?n.value:typeof n.value==`object`&&`value`in n.value?n.value.value:null:null}async function ut(){let e=null;try{e=await import(`@qualcomm-ui/tailwind-plugin/theme`)}catch{return()=>{}}let t={ColorTable:t=>{let n=N(t,`data`);return n&&M(e,n)},FontTable:t=>{let n=N(t,`data`);return n&&M(e,n)},SpacingTable:t=>{let n=N(t,`data`);return n&&M(e,n)},ThemePropertyTable:t=>{let n=N(t,`data`),r=N(t,`cssProperty`),i=n&&M(e,n);return n&&r?{cssPropertyName:r,data:i}:void 0}};return()=>(e,n,r)=>{k(e,`mdxJsxFlowElement`,e=>{let n=e.name&&t[e.name];if(!n)return;let r=n(e);if(!r){console.warn(`No theme data for ${e.name}`);return}let i;if(typeof r==`object`&&r&&`cssPropertyName`in r&&`data`in r){let{cssPropertyName:e,data:t}=r;i=lt(t,e)}else i=lt(r);i&&Object.assign(e,{lang:`json`,meta:null,type:`code`,value:i})}),r()}}var dt=class{constructor(e,t,n){this.cache=n??new Map,this.config=e,this.fileReader=t,this.propFormatter=new ot({docPropsPath:e.docPropsPath,routeDir:e.routeDir,verbose:e.verbose})}async generate(){this.config.verbose&&(console.log(`Scanning pages in: ${this.config.routeDir}`),this.config.exclude?.length&&console.log(`Excluding patterns: ${this.config.exclude.join(`, `)}`));let[e]=await Promise.all([this.scanPages(),this.propFormatter.loadDocProps()]);e.length===0?console.log(`No pages found.`):this.config.verbose&&console.log(`Found ${e.length} page(s)`);let t=0,n=new Set,r=[],i=[],a=this.config.sections??{},o=new v({depths:a.depths,minContentLength:a.minContentLength,pageIdPrefix:this.config.pageIdPrefix});for(let a of e){n.add(a.mdxFile);try{this.config.verbose&&console.log(`Processing page: ${a.name}`);let{fileContents:e,frontmatter:n}=this.fileReader.readFileSync(a.mdxFile),s=p(e),c=this.cache.get(a.mdxFile);if(c&&c.contentHash===s){t++,r.push(...c.sections),c.pageEntry&&i.push(c.pageEntry);continue}let l=await this.processMdxPage(a,{fileContents:e,frontmatter:n}),u={frontmatter:Ze(l.frontmatter,this.config.frontmatter),id:a.id,pathname:a.pathname,title:l.title,url:l.url},{sections:d}=o.extract(l.sectionAst,u);r.push(...d);let f=o.extractPage(l.sectionAst,u);f&&(f.content=`# ${l.title}\n\n${f.content}`,i.push(f)),this.cache.set(a.mdxFile,{contentHash:s,pageEntry:f??null,processedPage:l,sections:d})}catch(e){throw console.error(`Failed to process page: ${a.name}`),e}}for(let e of this.cache.keys())n.has(e)||this.cache.delete(e);this.config.extraFiles?.length&&await this.processExtraFiles(this.config.extraFiles,o,r,i);let s=p(JSON.stringify(r)),c=p(JSON.stringify(i));return{cachedPageCount:t,pages:{generatedAt:new Date().toISOString(),hash:c,pages:i,totalPages:i.length,version:1},sections:{generatedAt:new Date().toISOString(),hash:s,sections:r,totalSections:r.length,version:1},totalPageCount:e.length}}async scanPages(){let e=[],t=this.config.exclude??[],n=e=>{if(t.length===0)return!1;let n=w(this.config.routeDir,e);return t.some(e=>Pe(n,e,{matchBase:!0}))},r=async t=>{if(n(t)){this.config.verbose&&console.log(`Excluding directory: ${w(this.config.routeDir,t)}`);return}let i=await xe(t,{withFileTypes:!0}),a=i.filter(e=>e.name.endsWith(`.mdx`)&&!n(C(t,e.name)))??[];for(let n of a){let r=i.find(e=>e.name===`demos`),a=r?C(t,r.name):void 0,o=ae(C(t,n.name),this.config.routeDir),s=se(o);e.push({demosFolder:a,filePath:t,id:o.join(`-`).trim(),mdxFile:C(t,n.name),name:o.at(-1),pathname:s,url:this.config.baseUrl?new URL(s,this.config.baseUrl).toString():void 0}),this.config.verbose&&(console.log(`Found file: ${o.at(-1)}`),console.log(` Demos folder: ${a||`NOT FOUND`}`))}for(let e of i)e.isDirectory()&&await r(C(t,e.name))};return await r(this.config.routeDir),e}formatFrontmatterExpressions(e){return()=>t=>{k(t,`mdxFlowExpression`,(t,n,r)=>{t.value.trim()!==`frontmatter.description`||n===void 0||!r||(e.description?r.children.splice(n,1,{children:[{type:`text`,value:e.description}],type:`paragraph`}):r.children.splice(n,1))});let n=t,r=n.children.findIndex(e=>e.type!==`heading`||e.depth!==1?!1:e.children?.some(e=>e.type===`mdxTextExpression`&&e.value?.includes(`frontmatter`)));r>=0&&n.children.splice(r,1)}}transformRelativeUrls(){let e=this.config.baseUrl;return()=>t=>{e&&k(t,`link`,t=>{t.url.startsWith(`/`)&&(t.url=`${e}${t.url}`)})}}async processMdxContent(e,t,n){let r=await ut(),i=h({frontmatter:!0,gfm:!0,mdx:!0,plugins:[f,ct,this.propFormatter.propsToMarkdownList(),this.formatFrontmatterExpressions(n),r,$e(t.demosFolder,this.config.verbose),st,this.transformRelativeUrls()]});return await i.run(i.parse(e))}async processMdxPage(e,t){let{fileContents:n,frontmatter:r}=t??this.fileReader.readFileSync(e.mdxFile),i=await this.processMdxContent(n,e,r),a=h({extractMeta:{},frontmatter:!0,gfm:!0,mdx:!0,output:`md`,removeJsx:!0}),o=a.runSync(i),s=String(a.stringify(o)).replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,``).replace(/(^#{1,6} .*\\<[^>]+)>/gm,`$1\\>`),c=h({extractMeta:{},output:`md`}),l=String(await c.process(s)),u=r.title||e.name;return{content:l.trim(),frontmatter:r,rawContent:s.trim(),sectionAst:o,title:u,url:e.url}}async processExtraFiles(e,t,n,r){await Promise.all(e.map(async e=>{let i=e.contents;if(e.processAsMdx){let e=h({frontmatter:!0,gfm:!0,mdx:!0,output:`md`,plugins:[this.transformRelativeUrls()],removeJsx:!0});i=String(await e.process(i))}let a=[];e.title&&(a.push(`# ${e.title}`),a.push(``)),a.push(i);let o=a.join(`
|
|
8
|
+
`),s=h({gfm:!0,output:`md`}).parse(o),c={frontmatter:{},id:e.id,pathname:`/${e.id}`,title:e.title||e.id},{sections:l}=t.extract(s,c);n.push(...l);let u=t.extractPage(s,c);u&&r.push(u)}))}},ft=process.env.NODE_ENV===`development`,pt=`\0@qualcomm-ui/mdx-vite-plugin`,mt=`\0@qualcomm-ui/docs-plugin/config`,ht=`\0@qualcomm-ui/docs-plugin/markdown-content`,gt=class{constructor(){this.buildCount=0,this.config=null,this.configFilePath=``,this.docPropsFilePath=``,this.exports={dir:``,enabled:!1,pathnames:[]},this.configLoader=null,this.knowledgeConfig=void 0,this.knowledgePageCache=new Map,this.pages=null,this.sections=null,this.servers=[],this.timeout=void 0,this.exportsTimeout=void 0,this.watching=!1}init(e){this.cwd=e}getCwd(){return this.cwd}get docPropsDirectory(){return this.docPropsFilePath?this.docPropsFilePath.substring(0,this.docPropsFilePath.lastIndexOf(`/`)):``}get siteData(){let{filePath:e,...t}=this.config??{};return{config:t,exports:this.exports,navItems:this.indexer.navItems,pageDocProps:this.indexer.pageDocProps,pageMap:this.indexer.pageMap,searchIndex:this.indexer.searchIndex}}resolveDocProps(){if(!this.docPropsFilePath)return{};try{return JSON.parse(_e(this.docPropsFilePath,`utf-8`))?.props}catch{return console.debug(`Invalid doc props file. Unable to parse JSON. Please check the file`),{}}}createIndexer(e){this.knowledgePageCache.clear(),this.config=e,this.configFilePath=e.filePath,this.docPropsFilePath=e.typeDocProps?a(T(this.cwd,e.typeDocProps)):``,this.routesDir=a(T(e.appDirectory,e.pageDirectory)),this.knowledgeConfig=e.knowledge,this.indexer=new le({...e,srcDir:a(T(this.cwd,e.appDirectory)),typeDocProps:this.resolveDocProps()});let t=!!e.knowledge,n=e.knowledge?.outputPath??`exports`;this.exports={dir:t?`/${n}`:``,enabled:t,pathnames:[]}}buildIndex(e){let t=ye.sync([`${this.routesDir}/**/*.mdx`,`${this.routesDir}/**/*.tsx`],{absolute:!0,cwd:this.cwd});if(!t.length)return[];let n=Date.now(),r=this.indexer.buildIndex(t,e);return ft&&e&&console.debug(`${O.magenta.bold(`@qualcomm-ui/mdx-vite/docs-plugin:`)} Compiled search index in: ${O.blueBright.bold(Ne(Date.now()-n))}${this.indexer.cachedFileCount?O.greenBright.bold(` (${this.indexer.cachedFileCount}/${this.indexer.mdxFileCount} files cached)`):``}`),r}sendUpdate(){for(let e of this.servers){let t=e.moduleGraph.getModuleById(pt);t&&(e.moduleGraph.invalidateModule(t),e.reloadModule(t))}}handleChange(e={}){clearTimeout(this.timeout),this.timeout=setTimeout(()=>{this.buildIndex(!0),this.sendUpdate(),e?.onComplete?.()},300)}initWatchers(e){this.watching||=(this.initConfigWatcher(e),!0)}initConfigWatcher(e){let t=[this.configFilePath];this.docPropsFilePath&&t.push(this.docPropsFilePath),Ae.watch(t,{cwd:this.cwd}).on(`change`,()=>{console.debug(`qui-docs config changed, reloading plugin`),this.configLoader=new o({configFile:e});let t=this.configLoader.loadConfig();this.configFilePath=t.filePath,this.createIndexer(t),this.handleChange({onComplete:()=>{this.servers.forEach(e=>e.ws.send({type:`full-reload`}))}})})}async generateKnowledge(t){if(!this.knowledgeConfig)return;let n=C(t,this.knowledgeConfig.outputPath??`exports`),r=Date.now(),i=new e(ft),a=await new dt({baseUrl:this.knowledgeConfig.baseUrl,docPropsPath:this.docPropsFilePath||void 0,exclude:this.knowledgeConfig.exclude,extraFiles:this.knowledgeConfig.extraFiles,frontmatter:this.knowledgeConfig.frontmatter,pageIdPrefix:this.knowledgeConfig.pageIdPrefix,pages:this.knowledgeConfig.pages,routeDir:this.routesDir,sections:this.knowledgeConfig.sections},i,this.knowledgePageCache).generate();this.pages=a.pages,this.sections=a.sections,await be(n,{recursive:!0}),await Se(C(n,`sections.json`),JSON.stringify(a.sections,null,2),`utf-8`),await Se(C(n,`pages.json`),JSON.stringify(a.pages,null,2),`utf-8`),this.exports.pathnames=a.pages.pages.map(e=>e.pathname);let o=a.cachedPageCount>0?O.greenBright.bold(` (${a.cachedPageCount}/${a.totalPageCount} pages cached)`):``;console.debug(`${O.magenta.bold(`@qualcomm-ui/mdx-vite/docs-plugin:`)} Generated knowledge exports in: ${O.blueBright.bold(Ne(Date.now()-r))}${o}`)}debouncedGenerateKnowledge(e,t={}){this.knowledgeConfig&&(clearTimeout(this.exportsTimeout),this.exportsTimeout=setTimeout(()=>{this.generateKnowledge(e).then(()=>{t.onDone?.()})},500))}},_t=process.env.NODE_ENV===`development`,P=new gt;function vt(e){P.init(a(e?.cwd??process.cwd()));let t=new o(e||{}).loadConfig();P.createIndexer(t);let n;function r(){return n.publicDir||C(P.getCwd(),`public`)}return{apply(e,t){return t.mode===`development`&&t.command===`serve`||t.mode===`production`&&t.command===`build`},buildStart:async()=>{P.buildIndex(P.buildCount>0),P.buildCount++,!_t&&P.knowledgeConfig&&await P.generateKnowledge(r())},configResolved(e){n=e},configureServer:async t=>{_t&&(P.initWatchers(e?.configFile),P.knowledgeConfig&&await P.generateKnowledge(r()),t.middlewares.use(`/__qui-docs/pages`,(e,t)=>{t.setHeader(`Content-Type`,`application/json`),t.end(JSON.stringify(P.pages))}),t.middlewares.use(`/__qui-docs/sections`,(e,t)=>{t.setHeader(`Content-Type`,`application/json`),t.end(JSON.stringify(P.sections))}),t.watcher.on(`add`,e=>{e.endsWith(`.mdx`)&&P.handleChange({onComplete:()=>{t.ws.send({type:`full-reload`}),P.debouncedGenerateKnowledge(r())}})}),t.watcher.on(`unlink`,e=>{e.endsWith(`.mdx`)&&P.handleChange({onComplete:()=>{t.ws.send({type:`full-reload`}),P.debouncedGenerateKnowledge(r())}})}),P.servers.push(t))},handleHotUpdate:({file:e,modules:n,server:i})=>{if(e.endsWith(`.css`))return n;let o=a(e);if((!t.hotUpdateIgnore||!t.hotUpdateIgnore.test(o))&&o!==P.configFilePath){if(P.docPropsDirectory&&o.startsWith(P.docPropsFilePath))return[];if(e.endsWith(`.mdx`)){P.debouncedGenerateKnowledge(r());let t=P.buildIndex(!0);if(!i.moduleGraph.getModulesByFile(e)?.size)return console.debug(`no module found for file, returning`,e),[];let n=i.moduleGraph.getModuleById(pt);return n&&(i.moduleGraph.invalidateModule(n),i.ws.send({data:P.siteData,event:`qui-docs-plugin:refresh-site-data`,type:`custom`})),t.some(e=>e.metadata.changed.frontmatter)?(console.debug(`Frontmatter changed, reloading plugin to reflect changes in the page configuration`),n&&i.moduleGraph.invalidateModule(n),i.ws.send({type:`full-reload`}),[]):n?[n]:[]}}return[]},load:e=>{if(e===`\0@qualcomm-ui/mdx-vite-plugin`)return`export const siteData = ${JSON.stringify(P.siteData)}`;if(e===`\0@qualcomm-ui/docs-plugin/config`)return`export const quiDocsConfig = ${JSON.stringify({...P.config,cwd:P.cwd,publicDir:n.publicDir})}`;if(e===`\0@qualcomm-ui/docs-plugin/markdown-content`){if(_t){let{host:e=`localhost`,port:t=5173}=n.server,r=e===!0?`localhost`:e||`localhost`,i=`${n.server.https?`https`:`http`}://${r}:${t}`;return j`
|
|
9
9
|
export const getSections = () => fetch('${i}/__qui-docs/sections').then(r => r.json())
|
|
10
10
|
export const getPages = () => fetch('${i}/__qui-docs/pages').then(r => r.json())
|
|
11
|
-
`}return
|
|
12
|
-
export const getSections = () => Promise.resolve(${JSON.stringify(
|
|
13
|
-
export const getPages = () => Promise.resolve(${JSON.stringify(
|
|
14
|
-
`}},name:`qui-mdx-vite-plugin`,resolveId:e=>{if(e===`@qualcomm-ui/mdx-vite-plugin`)return
|
|
11
|
+
`}return j`
|
|
12
|
+
export const getSections = () => Promise.resolve(${JSON.stringify(P.sections)})
|
|
13
|
+
export const getPages = () => Promise.resolve(${JSON.stringify(P.pages)})
|
|
14
|
+
`}},name:`qui-mdx-vite-plugin`,resolveId:e=>{if(e===`@qualcomm-ui/mdx-vite-plugin`)return pt;if(e===`@qualcomm-ui/docs-plugin/config`)return mt;if(e===`@qualcomm-ui/docs-plugin/markdown-content`)return ht}}}var yt=`virtual:react-router/hmr-runtime`,bt=`/__frontmatter-hmr-fix/full-reload`,xt=/^(\s*)throw Error\(\s*`\[react-router:hmr\] No module update found for route \$\{route\.id\}`,\s*\);/m;function St(e={}){let{exportName:t=`frontmatter`}=e;return{configureServer(e){e.middlewares.use(bt,(t,n,r)=>{if(t.method!==`POST`){r();return}e.ws.send({type:`full-reload`}),n.statusCode=204,n.end()})},name:`frontmatter-hmr-fix`,transform(e,n){if(n.includes(yt))return e.replace(xt,(e,t)=>[`${t}console.debug(\`[react-router:hmr] No module update found for route \${route.id}\`);`,`${t}void fetch("${bt}", {method: "POST"}).catch(() => window.location.reload());`,`${t}return;`].join(`
|
|
15
15
|
`));if(e.includes(`export const ${t}`))return e+=`
|
|
16
16
|
if (typeof ${t} === 'object') {
|
|
17
17
|
Object.defineProperty(${t}, "$$typeof", {
|
|
@@ -19,49 +19,49 @@ import{createRequire as e}from"node:module";e(import.meta.url);import{A as t,C a
|
|
|
19
19
|
value: Symbol.for('react.memo')
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
`,e}}}var
|
|
23
|
-
`).map(
|
|
24
|
-
`)}function
|
|
22
|
+
`,e}}}var Ct={},wt=e=>{let t=e||Ct,n=t.prefix||``,r=new Set(t.allowedHeadings||[`h2`,`h3`,`h4`]),i=new ne;return e=>{i.reset(),k(e,`element`,function(e){Ge(e)&&!e.properties.id&&r.has(e.tagName)&&(e.properties.id=n+i.createSlug(Ke(e)))})}},F={enableRootSection:!1,idPropertyName:`ariaLabelledby`,properties:{},rankPropertyName:`dataHeadingRank`},Tt=(e,t)=>{if(e==null||t==null||!(`properties`in e))throw Error(`rootContent and rankPropertyName must have value`);let n=e.properties?.[t];if(typeof n!=`number`)throw Error(`rankPropertyName(${t}) must be number`);return n},Et=(e,t,n=[])=>{let{idPropertyName:r,properties:i,rankPropertyName:a}=t;if(i!=null&&a!=null&&a in i)throw Error(`rankPropertyName(${a}) dataHeadingRank must exist`);let o=n.at(0)?.properties?.id;return{children:n,properties:{className:[`heading`],...a?{[a]:e}:{},...r&&typeof o==`string`?{[r]:o}:{},...i||{}},tagName:`section`,type:`element`}},Dt=(e=F)=>{let{enableRootSection:t,...n}={enableRootSection:e.enableRootSection??F.enableRootSection,idPropertyName:e.idPropertyName??F.idPropertyName,properties:e.properties??F.properties,rankPropertyName:e.rankPropertyName??F.rankPropertyName};return e=>{let r=Et(0,n),i=[];i.push(r);let a=()=>{let e=i.at(-1);if(e==null||e.type!==`element`)throw Error(`lastStackItem must be Element`);return i.at(-1)};for(let t of e.children)if(qe(t)){let e=Ge(t);if(e==null)throw Error(`heading or headingRank is not working`);if(e>Tt(a(),n.rankPropertyName)){let r=Et(e,n,[t]);a().children.push(r),i.push(r)}else if(e<=Tt(a(),n.rankPropertyName)){for(;e<=Tt(a(),n.rankPropertyName);)i.pop();let r=Et(e,n,[t]);a().children.push(r),i.push(r)}}else{if(t.type===`doctype`)throw Error(`must be used in a fragment`);a().children.push(t)}return{...e,children:t?[r]:r.children}}};function Ot(e){let t=/\/\/\s*\[!code\s+hide(?::\d+)?\]/,n=/\/\/\s*\[!code\s*(?:\S.*)?\]/,r=/\{\s*\/\*\s*\[!code(?:\s+\S+)?\]\s*\*\/\s*\}/,i=/<!--\s*\[!code(?:\s+\S+)?\]\s*-->/,a=/\/\*\s*\[!code(?:\s+\S+)?\]\s*\*\/\s*/,o=/(?:\/\/\s*)?\[!code \+\+\]/;function s(e){let s=e,c=!1,l=t.test(e),u=[o,r,i,a,n];for(let e of u){let t=s.replace(e,``);t!==s&&(c=!0,s=t)}return{hasHideAnnotation:l,processed:s,touched:c}}return e.split(`
|
|
23
|
+
`).map(s).filter(({hasHideAnnotation:e,processed:t,touched:n})=>{if(e)return!1;let r=!t.trim();return!(n&&r)}).map(({processed:e})=>e).join(`
|
|
24
|
+
`)}function kt(e){let t=e.match(/<pre((?:\s+[\w-]+="[^"]*")*)>/),n=e.match(/<code([^>]*)>(.*?)<\/code>/s);if(!t||!n)return null;let r=n[2].split(/<span class="line/).slice(1).filter(e=>e.includes(`data-preview-line="true"`)),i=r.map(e=>{let t=e.match(/<span class="indent">(.+?)<\/span>/g)||[],n=0;for(let e of t){let t=e.match(/<span class="indent">(.+?)<\/span>/);if(t)n+=t[1].length;else break}return n}),a=Math.min(...i.filter(e=>e>0)),o=r.map(e=>{let t=`<span class="line${e}`,n=a;for(;n>0&&t.includes(`<span class="indent">`);){let e=t;if(t=t.replace(/<span class="indent">(.+?)<\/span>/,(e,t)=>{if(t.length<=n)return n-=t.length,``;{let e=t.substring(n);return n=0,`<span class="indent">${e}</span>`}}),e===t)break}return t});return`<pre${t[1]}><code${n[1]}>${o.join(``)}</code></pre>`}function At(e={attributeName:`data-code`}){return{enforce:`post`,name:`shiki-transformer-code-attribute`,pre(t){let n=Ot(this.source),r=e.formatter?.(n)??n;e.attributeName!==null&&(t.properties[e.attributeName??`data-code`]=r),e.onComplete?.(r)}}}function jt(){return{name:`shiki-transformer-notation-hidden`,preprocess(e){let t=e.split(`
|
|
25
25
|
`),n=[],r=0;for(let e of t){let t=e,i=t.match(/\[!code\s+hide(?::(\d+))?\]/);if(i){let e=t.slice(0,i.index??0),n=t.slice((i.index??0)+i[0].length),a=i[1]?Number(i[1]):1,o=Number.isFinite(a)&&a>0?a:0,s=e.trim()===``||/^[\s/]*$/.test(e),c=n.trim()===``;if(s&&c){r+=o;continue}continue}if(r>0){--r;continue}n.push(t)}return n.join(`
|
|
26
|
-
`).trim()}}}function
|
|
27
|
-
`),s=[],c=[],l=!1,u=!1,d=0;for(let e of o){if(
|
|
26
|
+
`).trim()}}}function Mt(e){return e===`// preview`||/^\{\s*\/\*\s*preview\s*\*\/\s*\}$/.test(e)||/^<!--\s*preview\s*-->$/.test(e)}function Nt(e={displayMode:`full-code`}){let t=null,n=-1,r=-1,i=0;return{enforce:`post`,line(e){i>=n&&i<=r&&(e.properties[`data-preview-line`]=`true`),i++},name:`transformer-preview-block`,pre(n){let r=t?Ot(t):null;r&&e.attributeName!=null&&(n.properties[e.attributeName]=r),e.onComplete?.(r||null)},preprocess(a){t=null,i=0,n=-1,r=-1;let o=a.split(`
|
|
27
|
+
`),s=[],c=[],l=!1,u=!1,d=0;for(let e of o){if(Mt(e.trim())){l?(l=!1,r=d-1):(l=!0,u=!0,n=d);continue}s.push(e),l&&c.push(e),d++}return u&&(t=j(c.join(`
|
|
28
28
|
`).trim()),e.displayMode===`only-preview`)?t:s.join(`
|
|
29
|
-
`).trim()}}}function
|
|
29
|
+
`).trim()}}}function I(){return[Ie(),Re(),ze(),Be(),Le(),jt(),He(),Ve()]}function Pt(e={}){let t=new o(e).loadConfig();return[[Ue,{enforce:`pre`}],[wt,{allowedHeadings:t.headings}],Dt,[Fe,Ee({addLanguageClass:!0,defaultColor:`light-dark()`,defaultLanguage:`plaintext`,fallbackLanguage:`plaintext`,themes:{dark:Ce,light:`github-light-high-contrast`},transformers:[...I(),At()]},e.rehypeShikiOptions)]]}function Ft(){return[we,We,Te,c,r,u,fe,_,oe,de,d]}async function It(e){let t=e===`tailwindcss`?`tailwindcss/index.css`:e,n;return n=typeof createRequire<`u`?createRequire(import.meta.url).resolve(t):(await import(`node:module`).then(e=>e.createRequire))(import.meta.url).resolve(t),D(n,`utf-8`)}async function Lt(e){return Xe(e,{loadStylesheet:async(e,t)=>({base:t,content:await It(e),path:`virtual:${e}`})})}function Rt(e){let t=new Map;return Je.parse(e).walkAtRules(`layer`,e=>{e.params===`theme`&&e.walkRules(`:root, :host`,e=>{e.walkDecls(e=>{e.prop.startsWith(`--`)&&t.set(e.prop,e.value)})})}),t}function zt(e){let t=e.trim(),n=t.match(/^([\d.]+)(rem|px|em|%|vh|vw)\s*([*/+-])\s*([\d.]+)$/);if(n){let[,e,t,r,i]=n,a=Bt(parseFloat(e),r,parseFloat(i));return Number.isFinite(a)?L(a)+t:null}let r=t.match(/^([\d.]+)\s*([*/+-])\s*([\d.]+)(rem|px|em|%|vh|vw)$/);if(r){let[,e,t,n,i]=r,a=Bt(parseFloat(e),t,parseFloat(n));return Number.isFinite(a)?L(a)+i:null}let i=t.match(/^([\d.]+)\s*([*/+-])\s*([\d.]+)$/);if(i){let[,e,t,n]=i,r=Bt(parseFloat(e),t,parseFloat(n));return Number.isFinite(r)?L(r):null}return null}function Bt(e,t,n){switch(t){case`*`:return e*n;case`/`:return e/n;case`+`:return e+n;case`-`:return e-n;default:return NaN}}function L(e){let t=Math.round(e*1e4)/1e4;return String(t)}function Vt(e){return e.replace(/([\d.]+)rem/g,(e,t)=>`${L(parseFloat(t)*16)}px`)}function Ht(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]===`(`)n++;else if(e[r]===`)`&&(n--,n===0))return r;return-1}function Ut(e,t){let n=e.indexOf(`var(`,t);if(n===-1)return null;let r=n+4,i=Ht(e,n);if(i===-1)return null;let a=e.slice(r,i),o=-1,s=0;for(let e=0;e<a.length;e++)if(a[e]===`(`)s++;else if(a[e]===`)`)s--;else if(a[e]===`,`&&s===0){o=e;break}return o===-1?{end:i,fallback:null,varName:a.trim()}:{end:i,fallback:a.slice(o+1).trim(),varName:a.slice(0,o).trim()}}function Wt(e,t,n=0){if(n>10)return e;let r=e,i=0;for(;;){let e=Ut(r,i);if(!e)break;let{end:a,fallback:o,varName:s}=e,c=r.indexOf(`var(`,i),l,u=t.get(s);if(u!==void 0)l=Wt(u,t,n+1);else if(o)l=Wt(o,t,n+1);else{i=a+1;continue}r=r.slice(0,c)+l+r.slice(a+1)}return r=r.replace(/calc\(([^)]+)\)/g,(e,t)=>zt(t)??e),r=Vt(r),r}function Gt(e){let t=!0,n=null;return Ye(e=>{if(e.nodes.length!==1){t=!1;return}let r=e.nodes[0];if(r.nodes.length!==1){t=!1;return}let i=r.nodes[0];if(i.type!==`class`){t=!1;return}n=i.value,r.walk(e=>{(e.type===`pseudo`||e.type===`combinator`||e.type===`nesting`||e.type===`attribute`)&&(t=!1)})}).processSync(e),{className:n,inlineable:t}}function Kt(e){let t=[],n=Je.parse(e),r=Rt(e);function i(e,n){let{className:i,inlineable:a}=Gt(e.selector);if(!i)return;let o=!1;e.walkAtRules(()=>{o=!0});let s=[];e.each(e=>{if(e.type===`decl`){let t=Wt(e.value,r);s.push(`${e.prop}: ${t}`)}}),!(s.length===0&&!o)&&t.push({className:i,declarations:s.join(`; `),inlineable:a&&!n&&!o,originalRule:e.toString()})}return n.walkAtRules(`layer`,e=>{e.walkRules(e=>{let t=e.parent;i(e,t?.type===`atrule`&&t.name!==`layer`)}),e.walkAtRules(e=>{e.name!==`layer`&&e.walkRules(e=>{i(e,!0)})})}),n.walkRules(e=>{e.parent?.type===`root`&&i(e,!1)}),t}function qt(e,t){let n=Kt(t.build(e)),r=new Map,i=new Map;for(let e of n)e.inlineable?r.set(e.className,e.declarations):i.set(e.className,e.originalRule);let a=[],o=[];for(let t of e){let e=r.get(t);e?a.push(e):o.push(t)}return{inlineStyles:a,remainingClasses:o,residualRules:i}}function Jt(e){return`{ ${e.flatMap(e=>e.split(`;`).map(e=>e.trim()).filter(Boolean)).map(e=>{let t=e.indexOf(`:`);if(t===-1)return null;let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();return`${De(n)}: '${r}'`}).filter(Boolean).join(`, `)} }`}function Yt(e,t,n=`html`){let r=new Map,i=new Map,a=/(className|class)=(["'`])([^"'`]*)\2/g,o;for(;(o=a.exec(e))!==null;){let e=o[0],a=o[1],s=o[2],c=o[3].split(/\s+/).filter(Boolean);if(c.length===0)continue;let{inlineStyles:l,remainingClasses:u,residualRules:d}=qt(c,t);for(let[e,t]of d)i.set(e,t);if(l.length===0)continue;let f;f=n===`jsx`?`style={${Jt(l)}}`:`style=${s}${l.join(`; `)}${s}`,u.length>0&&(f+=` ${a}=${s}${u.join(` `)}${s}`),r.set(e,f)}return{replacements:r,residualRules:i}}function Xt(e,t,n=`html`){let r=new Map,i=!1,{replacements:a,residualRules:o}=Yt(e,t,n);(a.size>0||o.size>0)&&(i=!0);for(let[e,t]of o)r.set(e,t);let s=e;for(let[e,t]of a)s=s.replaceAll(e,t);return{classesDetected:i,residualRules:r,source:s}}async function Zt(e){let{onClassesDetected:t,onResidualCss:n,styleFormat:r=`html`,styles:i}=e,a=await Lt(i);return{name:`shiki-transformer-tailwind-to-inline`,preprocess(e){let{classesDetected:i,residualRules:o,source:s}=Xt(e,a,r);return t?.(i),n&&o.size>0&&n(o),s}}}var R=`\0virtual:angular-demo-registry`,z=`[angular-demo]`,B=!1;function V(...e){B&&console.log(...e)}var H={},U=null,Qt=0,W=new Map,G=[];function $t({demoPattern:e=`src/routes/**/demos/*.ts`,initialHtml:t,routesDir:n=`src/routes`,theme:r={dark:Ce,light:`github-light-high-contrast`},transformTailwindStyles:i}={}){let a=null,o=null,s={defaultColor:`light-dark()`,themes:{dark:r.dark,light:r.light}};return{async buildEnd(){a&&(await a.close(),a=null,B=!1)},async buildStart(){if(Qt===0){Qt++;return}if(!U)try{U=await Me({langs:[`angular-ts`,`angular-html`,`css`],themes:[r.dark,r.light]}),V(`${O.blue.bold(z)} Shiki highlighter initialized`)}catch(e){console.warn(`${O.blue.bold(z)} Failed to initialize highlighter:`,e)}V(`${O.blue.bold(z)} Initializing Angular demo scanner`),await c(),process.env.NODE_ENV===`development`&&(B?V(`${O.blue.bold(z)} Watcher already initialized by another instance`):(B=!0,oe()))},configureServer(e){o=e;let t=null;e.ws.on(`custom:store-demo-dimensions`,n=>{let r=n.demoId;H[r]=n.dimensions,t&&clearTimeout(t),t=setTimeout(()=>{let t=e.moduleGraph.getModuleById(R);t&&e.moduleGraph.invalidateModule(t)},50)}),e.ws.on(`custom:reset-demo-dimensions`,()=>{H={};let t=e.moduleGraph.getModuleById(R);t&&(e.moduleGraph.invalidateModule(t),e.reloadModule(t))})},async handleHotUpdate({file:e,modules:t,server:n}){if(!v(e)){if(y(e))return t;if(e.endsWith(`main.js`)){let e=[...G];n.ws.send({data:{demoInfo:e.reduce((e,t)=>(e[t]=W.get(t),e),{})},event:`demo-bundle-updated`,type:`custom`})}return[]}V(`${O.blue.bold(z)} Processing Angular demo change: ${O.cyan(e)}`);let r=await m(e,await D(e,`utf-8`));if(!r||!ne(e)){let t=await l(e);if(t.length>0){G=[];for(let e of t)G.push(e.id)}n.ws.send({data:{ids:[...G]},event:`demo-bundle-updating`,type:`custom`});return}delete H[r.id],W.set(r.id,r),G=[r.id],n.ws.send({data:{ids:[...G]},event:`demo-bundle-updating`,type:`custom`});let i=n.moduleGraph.getModuleById(R);i&&n.moduleGraph.invalidateModule(i);let a=n.moduleGraph.getModuleById(e);return a&&n.moduleGraph.invalidateModule(a),[]},load(e){if(e===R)return _()},name:`angular-demo-plugin`,resolveId(e){if(e===`virtual:angular-demo-registry`)return R},writeBundle(){console.log(`${O.blue.bold(z)} Successfully integrated ${O.green(W.size)} component demos`)}};async function c(){if(W.size){V(`${O.magenta.bold(z)} Using cached ${O.cyanBright.bold(W.size)} demos`);return}let t=await ye(e);W.clear();for(let e of t){let t=await m(e,await D(e,`utf-8`));t&&W.set(t.id,t)}}async function l(e){let t=[];for(let[n,r]of W.entries())if(r.sourceCode.find(t=>t.filePath===e)){V(`${O.blue.bold(z)} Reloading demo ${O.cyan(n)} due to imported file change: ${O.yellow(e)}`);let i=await D(r.filePath,`utf-8`),a=await m(r.filePath,i);a&&(delete H[a.id],W.set(a.id,a),t.push(a),G.push(a.id))}return t}async function u(e,t=`angular-ts`,n={}){let{onClassesDetected:r,onResidualCss:a}=n;if(!U)return{full:e};let o=null,c=[];if(i&&a){let e=await Zt({onClassesDetected:e=>{r?.(e)},onResidualCss:a,styleFormat:`html`,styles:j`
|
|
30
30
|
@layer theme, base, components, utilities;
|
|
31
31
|
@import "tailwindcss/theme.css" layer(theme);
|
|
32
32
|
@import "tailwindcss/utilities.css" layer(utilities);
|
|
33
33
|
@import "@qualcomm-ui/tailwind-plugin/qui-strict.css";
|
|
34
|
-
`});c.push(e)}try{let n=
|
|
35
|
-
`&&n++,e.slice(t.start,n).trim()})}catch(e){return
|
|
34
|
+
`});c.push(e)}try{let n=U.codeToHtml(e,{...s,lang:t,transformers:[...I(),...c,Nt({attributeName:`data-preview`,onComplete:e=>{o=e}}),At({attributeName:`data-code`}),{enforce:`post`,name:`shiki-transformer-trim`,preprocess(e){return e.trim()}}]});return{full:n,preview:o?kt(n):null}}catch(n){return console.warn(`${O.blue.bold(z)} Failed to highlight code with ${t} language:`,n),{full:e}}}async function d(e){try{let t=await D(e,`utf-8`),n=A.createSourceFile(e,t,A.ScriptTarget.Latest,!0,A.ScriptKind.TS),r=[];function i(t){if(A.isImportDeclaration(t)){let n=t.moduleSpecifier;if(A.isStringLiteral(n)){let t=n.text;if(re(t)){let n=ae(t,e);r.push({resolvedPath:n,source:t})}else if(!ie(t)){let n=b(e);if(tn(t,n)){let e=nn(t,n);e&&r.push({resolvedPath:e,source:t})}}}}A.forEachChild(t,i)}return i(n),r}catch(t){return V(`${O.blue.bold(z)} ${O.yellowBright(`Failed to extract imports from`)} ${O.cyan(e)}:`,t),[]}}async function f(e,t=new Set){if(t.has(e))return[];t.add(e);let n=await d(e);for(let{resolvedPath:e}of n)await f(e,t);return Array.from(t).slice(1)}function p(e,t){try{let n=A.createSourceFile(t,e,A.ScriptTarget.Latest,!0,A.ScriptKind.TS),r=[];function i(e){A.isImportDeclaration(e)&&r.push({end:e.getEnd(),start:e.getFullStart()}),A.forEachChild(e,i)}return i(n),r.map(t=>{let n=t.end;return e[n]===`
|
|
35
|
+
`&&n++,e.slice(t.start,n).trim()})}catch(e){return V(`${O.blue.bold(z)} ${O.redBright(`Failed to strip imports from`)} ${O.cyan(t)}:`,e),[]}}async function m(e,n){try{let{componentClass:r,hasDefaultExport:i,isStandalone:a,selector:o,templateUrl:s}=ee(e,n);if(!r||!o)return null;let c=r,l=w(process.cwd(),e).replace(/\\/g,`/`),d=x(e),f=p(n,e),m=[],_=new Map,v=await h({code:n,fileName:d,filePath:e,language:`angular-ts`});if(m.push(v.sourceCodeData),v.residualRules)for(let[e,t]of v.residualRules)_.set(e,t);if(s){let t=await g(s,e);if(t&&(m.push(t.sourceCodeData),t.residualRules))for(let[e,n]of t.residualRules)_.set(e,n)}let ne=await te(e);for(let e of ne)if(m.push(e.sourceCodeData),e.residualRules)for(let[t,n]of e.residualRules)_.set(t,n);let y=_.size>0?[..._.values()].join(`
|
|
36
36
|
|
|
37
|
-
`):void 0;if(
|
|
37
|
+
`):void 0;if(y){let e=await u(y,`css`);m.push({fileName:`styles.css`,highlighted:e,type:`residual-css`})}return{componentClass:r,filePath:l.startsWith(`.`)?l:`./${l}`,hasDefaultExport:i,id:c,imports:f,initialHtml:t?.[c]||void 0,isStandalone:a,lastModified:Date.now(),selector:o,sourceCode:m}}catch(t){return console.error(`${O.blue.bold(z)} Failed to parse Angular demo ${e}:`,t),null}}function ee(e,t){let n=A.createSourceFile(e,t,A.ScriptTarget.Latest,!0,A.ScriptKind.TS),r=``,i=``,a=!0,o=null,s=!1,c=[];function l(e){if(A.isImportDeclaration(e)&&c.push(e.getFullText(n).trim()),A.isClassDeclaration(e)){let t=(e.modifiers?.filter(A.isDecorator))?.find(e=>{if(!A.isCallExpression(e.expression))return!1;let t=e.expression.expression;return A.isIdentifier(t)&&t.text===`Component`});if(t&&e.name&&(r=e.name.text,A.isCallExpression(t.expression)&&t.expression.arguments[0]&&A.isObjectLiteralExpression(t.expression.arguments[0]))){let e=t.expression.arguments[0].properties,n=e.find(e=>A.isPropertyAssignment(e)&&A.isIdentifier(e.name)&&e.name.text===`selector`);n&&A.isStringLiteral(n.initializer)&&(i=n.initializer.text);let r=e.find(e=>A.isPropertyAssignment(e)&&A.isIdentifier(e.name)&&e.name.text===`templateUrl`);if(r){let e=r.initializer;(A.isStringLiteral(e)||A.isNoSubstitutionTemplateLiteral(e))&&(o=e.text)}let s=e.find(e=>A.isPropertyAssignment(e)&&A.isIdentifier(e.name)&&e.name.text===`standalone`);s&&s.initializer.kind===A.SyntaxKind.FalseKeyword&&(a=!1)}}A.isExportAssignment(e)&&!e.isExportEquals&&(s=!0),A.forEachChild(e,l)}return l(n),{componentClass:r,hasDefaultExport:s,importsFromAst:c,isStandalone:a,selector:i,templateUrl:o}}async function h(e){let{code:t,fileName:n,filePath:r,language:a}=e,o=await u(t,a),s,c=!1,l;return i&&(s=await u(t,a,{onClassesDetected:e=>{c=e},onResidualCss:e=>{l=e}})),{residualRules:l,sourceCodeData:{fileName:n,filePath:r,highlighted:{full:o.full,preview:o.preview},highlightedInline:c&&s?{full:s.full,preview:s.preview}:void 0,type:`file`}}}async function g(e,t){let n=rn(e,t);if(!E(n))return null;try{return h({code:await D(n,`utf-8`),fileName:x(n),filePath:n,language:`angular-html`})}catch(e){return console.log(`${O.blue.bold(z)} ${O.redBright(`Failed to read template file:`)} ${O.cyan(n)}`,e),null}}async function te(e){let t=[],n=await f(e);for(let e of n)try{let n=await h({code:await D(e,`utf-8`),fileName:x(e),filePath:e,language:`angular-ts`});t.push(n)}catch{V(`${O.blue.bold(z)} ${O.yellowBright(`Failed to process relative import:`)} ${O.cyan(e)}`)}return t}function _(){return`// Auto-generated Angular demo registry
|
|
38
38
|
export const ANGULAR_DEMOS = {
|
|
39
|
-
${Array.from(
|
|
39
|
+
${Array.from(W.values()).map(e=>` "${e.id}": ${JSON.stringify({componentClass:e.componentClass,dimensions:H[e.id],filePath:e.filePath,hasDefaultExport:e.hasDefaultExport,id:e.id,imports:e.imports,initialHtml:e.initialHtml,isStandalone:e.isStandalone,lastModified:e.lastModified,selector:e.selector,sourceCode:e.sourceCode},null,4)}`).join(`,
|
|
40
40
|
`)}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export function getAngularDemoInfo(demoId) {
|
|
44
44
|
return ANGULAR_DEMOS[demoId] || null
|
|
45
|
-
}`}function isAngularDemoFile(e){return e.includes(`/demos/`)&&(e.endsWith(`.ts`)||e.endsWith(`html`))}function isAngularDemoEntrypoint(e){return e.endsWith(`-demo.ts`)||e.endsWith(`-demo.html`)}function isCssAsset(e){return e.endsWith(`.css`)}function isRelativeImport(e){return e.startsWith(`./`)||e.startsWith(`../`)}function isNodeBuiltin(e){return e.startsWith(`node:`)||`assert.buffer.child_process.cluster.crypto.dgram.dns.domain.events.fs.http.https.net.os.path.punycode.querystring.readline.stream.string_decoder.timers.tls.tty.url.util.v8.vm.zlib`.split(`.`).includes(e)}function resolveRelativeImport(e,t){let n=C(b(t),e),r=[`.ts`,`.js`];for(let e of r){let t=n+e;if(w(t))return t}for(let e of r){let t=x(n,`index${e}`);if(w(t))return t}return n}function loadTsConfigPaths(e){let t=b(e),n=[];for(;t!==b(t);){let e=x(t,`tsconfig.json`);if(w(e))try{let r=N.sys.readFile(e);if(!r){t=b(t);continue}let i=N.parseConfigFileTextToJson(e,r);if(i.error){t=b(t);continue}let a=i.config?.compilerOptions?.paths,o=i.config?.compilerOptions?.baseUrl||`./`,s=C(t,o);if(a){for(let[e,t]of Object.entries(a))if(Array.isArray(t)&&t.length>0){let r=t[0],i=RegExp(`^${e.replace(`*`,`(.*)`).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(`\\(\\*\\)`,`(.*)`)}$`),a=C(s,r.replace(`*`,`$1`));n.push({pattern:i,replacement:a})}}let c=i.config?.extends;if(c){let e=loadTsConfigPathsFromFile$1(C(t,c));n.push(...e)}return n}catch{t=b(t);continue}t=b(t)}return n}function setupAngularWatcher(){a=ke(n,{ignoreInitial:!0,persistent:!0}),a.on(`ready`,()=>{logDev(`${O.blue.bold(V)} Registered ${O.green(G.size)} demo files. Watching for file changes...`)}),a.on(`add`,e=>{try{let t=xe(e);if(!t||t.size===0){console.debug(`Failed to read file stats`,e);return}isAngularDemoFile(e)&&(logDev(`${O.blue.bold(V)} New Angular demo: ${O.green(e)}`),handleAngularDemoUpdate(e).then(()=>{triggerRegistryUpdate()}))}catch{console.debug(`Failed to update registry file stats`)}}),a.on(`unlink`,e=>{if(isAngularDemoFile(e)){let t=Array.from(G.entries()).find(([,t])=>t.filePath===e);if(t){let[e]=t;G.delete(e),logDev(`${O.blue.bold(V)} Removed demo: ${O.red(e)}`),triggerRegistryUpdate()}}})}async function handleAngularDemoUpdate(e){let t=await parseAngularDemo(e,await E(e,`utf-8`));t&&G.set(t.id,t)}function triggerRegistryUpdate(){if(!o)return;let e=o.moduleGraph.getModuleById(B);e&&(o.moduleGraph.invalidateModule(e),e.lastHMRTimestamp=Date.now(),o.reloadModule(e))}}function loadTsConfigPathsFromFile$1(e){let t=[],n=b(e);try{let r=N.sys.readFile(e);if(!r)return t;let i=N.parseConfigFileTextToJson(e,r);if(i.error)return t;let a=i.config?.compilerOptions?.paths,o=C(n,i.config?.compilerOptions?.baseUrl||`./`);if(a){for(let[e,n]of Object.entries(a))if(Array.isArray(n)&&n.length>0){let r=n[0],i=RegExp(`^${e.replace(`*`,`(.*)`).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(`\\(\\*\\)`,`(.*)`)}$`),a=C(o,r.replace(`*`,`$1`));t.push({pattern:i,replacement:a})}}let s=i.config?.extends;if(s){let e=C(n,s);if(e.endsWith(`.json`)||(e+=`.json`),w(e)){let n=loadTsConfigPathsFromFile$1(e);t.push(...n)}}}catch{return t}return t}function isPathAliasImport$1(e,t){return t.some(t=>t.pattern.test(e))}function resolvePathAlias$1(e,t){for(let n of t)if(n.pattern.test(e)){let t=e.replace(n.pattern,n.replacement),r=[`.ts`,`.js`];for(let e of r){let n=t+e;if(w(n))return n}for(let e of r){let n=x(t,`index${e}`);if(w(n))return n}return t}return null}function resolveTemplateFile(e,t){let n=C(b(t),e);if(w(n))return n;if(!n.endsWith(`.html`)){let e=`${n}.html`;if(w(e))return e}return n}var q={AUTO:`\0virtual:qui-demo-scope/auto`,CONFIG:`\0virtual:qui-demo-scope/config`,PAGE_PREFIX:`\0virtual:qui-demo-scope/page:`},J=`@qualcomm-ui/mdx-vite/react-demo-plugin:`,nt=[`useState`,`useEffect`,`useMemo`,`useCallback`,`useRef`,`useContext`,`createContext`,`forwardRef`,`memo`,`lazy`,`Suspense`,`Fragment`],rt=[`fs`,`path`,`url`,`util`,`os`,`crypto`,`events`,`stream`,`buffer`];function createDemoName(e){let t=e.includes(`/`)?`/`:`\\`,n=e.substring(e.lastIndexOf(t),e.lastIndexOf(`.`));if(!n)throw Error(`Failed to create demo name for ${e}`);return De(n)}async function extractFileImports(e){try{return extractImports(await E(e,`utf-8`),e)}catch(t){return console.log(`${O.magenta.bold(J)} ${O.yellowBright(`Failed to parse`)} ${O.blueBright.bold(e)}:`,t),null}}function extractImports(e,t){let n=N.createSourceFile(t,e,N.ScriptTarget.Latest,!0,getScriptKind(t)),r=[],i=[];function visit(e){if(N.isImportDeclaration(e)){let n=parseImportDeclaration(e,t);n&&(n.type===`relative`?i.push(n):r.push(n))}N.forEachChild(e,visit)}return visit(n),{relativeImports:i,thirdPartyImports:r}}function getScriptKind(e){return e.endsWith(`.tsx`)||e.endsWith(`.jsx`)?N.ScriptKind.TSX:N.ScriptKind.TS}function parseImportDeclaration(e,t){let n=e.moduleSpecifier;if(!N.isStringLiteral(n))return null;let r=n.text;if(e.importClause?.isTypeOnly)return null;let i=extractSpecifiers(e.importClause);if(i.length===0)return null;if(isRelativeImport(r))return{resolvedPath:resolveRelativeImport(r,t),source:r,specifiers:i,type:`relative`};if(isNodeBuiltin(r))return null;let a=loadTsConfigPaths(t);if(isPathAliasImport(r,a)){let e=resolvePathAlias(r,a);if(e)return{resolvedPath:e,source:r,specifiers:i,type:`relative`}}return{source:r,specifiers:i,type:`thirdParty`}}function extractSpecifiers(e){if(!e)return[];let t=[];return e.name&&t.push({imported:`default`,local:`default`}),e.namedBindings&&(N.isNamespaceImport(e.namedBindings)?t.push({imported:`*`,local:`*`}):N.isNamedImports(e.namedBindings)&&e.namedBindings.elements.forEach(e=>{if(!e.isTypeOnly){let n=e.propertyName?e.propertyName.text:e.name.text,r=e.name.text;t.push({imported:n,local:r})}})),t}function resolveRelativeImport(e,t){let n=C(b(t),e),r=[`.ts`,`.tsx`,`.js`,`.jsx`];for(let e of r){let t=n+e;if(w(t))return t}for(let e of r){let t=x(n,`index${e}`);if(w(t))return t}return n}function isRelativeImport(e){return e.startsWith(`./`)||e.startsWith(`../`)}function isNodeBuiltin(e){return e.startsWith(`node:`)||rt.includes(e)}function loadTsConfigPaths(e){let t=b(e),n=[];for(;t!==b(t);){let e=x(t,`tsconfig.json`);if(w(e))try{let r=N.sys.readFile(e);if(!r){t=b(t);continue}let i=N.parseConfigFileTextToJson(e,r);if(i.error){t=b(t);continue}let a=i.config?.compilerOptions?.paths,o=i.config?.compilerOptions?.baseUrl||`./`,s=C(t,o);if(a){for(let[e,t]of Object.entries(a))if(Array.isArray(t)&&t.length>0){let r=t[0],i=RegExp(`^${e.replace(`*`,`(.*)`).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(`\\(\\*\\)`,`(.*)`)}$`),a=C(s,r.replace(`*`,`$1`));n.push({pattern:i,replacement:a})}}let c=i.config?.extends;if(c){let e=loadTsConfigPathsFromFile(C(t,c));n.push(...e)}return n}catch{t=b(t);continue}t=b(t)}return n}function loadTsConfigPathsFromFile(e){let t=[],n=b(e);try{let r=N.sys.readFile(e);if(!r)return t;let i=N.parseConfigFileTextToJson(e,r);if(i.error)return t;let a=i.config?.compilerOptions?.paths,o=C(n,i.config?.compilerOptions?.baseUrl||`./`);if(a){for(let[e,n]of Object.entries(a))if(Array.isArray(n)&&n.length>0){let r=n[0],i=RegExp(`^${e.replace(`*`,`(.*)`).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(`\\(\\*\\)`,`(.*)`)}$`),a=C(o,r.replace(`*`,`$1`));t.push({pattern:i,replacement:a})}}let s=i.config?.extends;if(s){let e=C(n,s);if(e.endsWith(`.json`)||(e+=`.json`),w(e)){let n=loadTsConfigPathsFromFile(e);t.push(...n)}}}catch{return t}return t}function isPathAliasImport(e,t){return t.some(t=>t.pattern.test(e))}function resolvePathAlias(e,t){for(let n of t)if(n.pattern.test(e)){let t=e.replace(n.pattern,n.replacement),r=[`.ts`,`.tsx`,`.js`,`.jsx`];for(let e of r){let n=t+e;if(w(n))return n}for(let e of r){let n=x(t,`index${e}`);if(w(n))return n}return t}return null}function extractPageId(e,t){let n=S(t,e),r=n.split(ye);if(r.includes(`demos`)){let e=r.indexOf(`demos`);return r.slice(0,e).join(ye)}return b(n)}function isCssAsset(e){return e.endsWith(`.css`)}function isDemoFile(e){try{return e.includes(`/demos/`)&&e.endsWith(`.tsx`)&&!be(e).includes(`export default`)}catch{return!1}}var Y=null,X=!1,Z=new Map,Q=new Map,$=new Map;function reactDemoPlugin({demoPattern:e=`src/routes/**/demos/*.tsx`,routesDir:t=`src/routes`,theme:n={dark:A,light:`github-light-high-contrast`},transformers:r=[],transformLine:i,transformTailwindStyles:a}={}){let o={defaultColor:`light-dark()`,lang:`tsx`,themes:{dark:n.dark,light:n.light}};return{apply(e,t){return t.mode===`development`&&t.command===`serve`||t.mode===`production`&&t.command===`build`},async buildStart(){if(!Y&&!X){X=!0;try{Y=await Ae({langs:[`tsx`,`typescript`,`css`],themes:[n.dark,n.light]}),console.log(`${O.magenta.bold(J)} Shiki highlighter initialized`)}catch(e){console.warn(`${O.magenta.bold(J)} Failed to initialize highlighter:`,e)}finally{X=!1}}await collectReactDemos()},async handleHotUpdate({file:e,modules:t,server:n}){if(isCssAsset(e))return t;if(e.endsWith(`.mdx`))return[];let r=[];if(isDemoFile(e))await handleDemoAdditionOrUpdate({filePath:e}),r.push(createDemoName(e));else{let t=C(e),n=$.get(t);if(!n?.size)return[];for(let e of Array.from(n)){let t=Z.get(e);t&&(await handleDemoAdditionOrUpdate({filePath:t.filePath}),r.push(e))}}let i=n.moduleGraph.getModuleById(q.AUTO);i&&n.moduleGraph.invalidateModule(i);for(let e of r){let t=Z.get(e);t&&n.ws.send({data:t,event:`qui-demo:update`,type:`custom`})}return[]},load(e){if(e===q.AUTO)return generateAutoScopeModule()},name:`auto-demo-scope`,resolveId(e){if(e===`virtual:qui-demo-scope/auto`)return q.AUTO},writeBundle(){console.log(`${O.blue.bold(J)} Successfully integrated ${O.green(Z.size)} component demos`)}};async function handleDemoAdditionOrUpdate({filePath:e}){let n=extractPageId(e,t),r=createDemoName(e),i=Q.get(n)??[];i.includes(e)||(i.push(e),Q.set(n,i));let a=await extractFileData(e);if(a){Z.set(r,{...a,demoName:r,pageId:n});let t=await extractFileImports(e);if(t)for(let e of t.relativeImports){let t=$.get(e.resolvedPath)??new Set;t.add(r),$.set(e.resolvedPath,t)}}}async function highlightCode(e,t={}){let{extraTransformers:n=[],onResidualCss:i}=t;if(!Y)return{full:e};let s=null,c=[];if(a&&i){let e=await createShikiTailwindTransformer({onClassesDetected:e=>{t.onClassesDetected?.(e)},onResidualCss:i,styleFormat:`jsx`,styles:P`
|
|
45
|
+
}`}function v(e){return e.includes(`/demos/`)&&(e.endsWith(`.ts`)||e.endsWith(`html`))}function ne(e){return e.endsWith(`-demo.ts`)||e.endsWith(`-demo.html`)}function y(e){return e.endsWith(`.css`)}function re(e){return e.startsWith(`./`)||e.startsWith(`../`)}function ie(e){return e.startsWith(`node:`)||`assert.buffer.child_process.cluster.crypto.dgram.dns.domain.events.fs.http.https.net.os.path.punycode.querystring.readline.stream.string_decoder.timers.tls.tty.url.util.v8.vm.zlib`.split(`.`).includes(e)}function ae(e,t){let n=T(S(t),e),r=[`.ts`,`.js`];for(let e of r){let t=n+e;if(E(t))return t}for(let e of r){let t=C(n,`index${e}`);if(E(t))return t}return n}function b(e){let t=S(e),n=[];for(;t!==S(t);){let e=C(t,`tsconfig.json`);if(E(e))try{let r=A.sys.readFile(e);if(!r){t=S(t);continue}let i=A.parseConfigFileTextToJson(e,r);if(i.error){t=S(t);continue}let a=i.config?.compilerOptions?.paths,o=i.config?.compilerOptions?.baseUrl||`./`,s=T(t,o);if(a){for(let[e,t]of Object.entries(a))if(Array.isArray(t)&&t.length>0){let r=t[0],i=RegExp(`^${e.replace(`*`,`(.*)`).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(`\\(\\*\\)`,`(.*)`)}$`),a=T(s,r.replace(`*`,`$1`));n.push({pattern:i,replacement:a})}}let c=i.config?.extends;if(c){let e=en(T(t,c));n.push(...e)}return n}catch{t=S(t);continue}t=S(t)}return n}function oe(){a=je(n,{ignoreInitial:!0,persistent:!0}),a.on(`ready`,()=>{V(`${O.blue.bold(z)} Registered ${O.green(W.size)} demo files. Watching for file changes...`)}),a.on(`add`,e=>{try{let t=ve(e);if(!t||t.size===0){console.debug(`Failed to read file stats`,e);return}v(e)&&(V(`${O.blue.bold(z)} New Angular demo: ${O.green(e)}`),se(e).then(()=>{ce()}))}catch{console.debug(`Failed to update registry file stats`)}}),a.on(`unlink`,e=>{if(v(e)){let t=Array.from(W.entries()).find(([,t])=>t.filePath===e);if(t){let[e]=t;W.delete(e),V(`${O.blue.bold(z)} Removed demo: ${O.red(e)}`),ce()}}})}async function se(e){let t=await m(e,await D(e,`utf-8`));t&&W.set(t.id,t)}function ce(){if(!o)return;let e=o.moduleGraph.getModuleById(R);e&&(o.moduleGraph.invalidateModule(e),e.lastHMRTimestamp=Date.now(),o.reloadModule(e))}}function en(e){let t=[],n=S(e);try{let r=A.sys.readFile(e);if(!r)return t;let i=A.parseConfigFileTextToJson(e,r);if(i.error)return t;let a=i.config?.compilerOptions?.paths,o=T(n,i.config?.compilerOptions?.baseUrl||`./`);if(a){for(let[e,n]of Object.entries(a))if(Array.isArray(n)&&n.length>0){let r=n[0],i=RegExp(`^${e.replace(`*`,`(.*)`).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(`\\(\\*\\)`,`(.*)`)}$`),a=T(o,r.replace(`*`,`$1`));t.push({pattern:i,replacement:a})}}let s=i.config?.extends;if(s){let e=T(n,s);if(e.endsWith(`.json`)||(e+=`.json`),E(e)){let n=en(e);t.push(...n)}}}catch{return t}return t}function tn(e,t){return t.some(t=>t.pattern.test(e))}function nn(e,t){for(let n of t)if(n.pattern.test(e)){let t=e.replace(n.pattern,n.replacement),r=[`.ts`,`.js`];for(let e of r){let n=t+e;if(E(n))return n}for(let e of r){let n=C(t,`index${e}`);if(E(n))return n}return t}return null}function rn(e,t){let n=T(S(t),e);if(E(n))return n;if(!n.endsWith(`.html`)){let e=`${n}.html`;if(E(e))return e}return n}var K={AUTO:`\0virtual:qui-demo-scope/auto`,CONFIG:`\0virtual:qui-demo-scope/config`,PAGE_PREFIX:`\0virtual:qui-demo-scope/page:`},q=`@qualcomm-ui/mdx-vite/react-demo-plugin:`,an=[`useState`,`useEffect`,`useMemo`,`useCallback`,`useRef`,`useContext`,`createContext`,`forwardRef`,`memo`,`lazy`,`Suspense`,`Fragment`],on=[`fs`,`path`,`url`,`util`,`os`,`crypto`,`events`,`stream`,`buffer`];function J(e){let t=e.includes(`/`)?`/`:`\\`,n=e.substring(e.lastIndexOf(t),e.lastIndexOf(`.`));if(!n)throw Error(`Failed to create demo name for ${e}`);return ke(n)}async function Y(e){try{return sn(await D(e,`utf-8`),e)}catch(t){return console.log(`${O.magenta.bold(q)} ${O.yellowBright(`Failed to parse`)} ${O.blueBright.bold(e)}:`,t),null}}function sn(e,t){let n=A.createSourceFile(t,e,A.ScriptTarget.Latest,!0,cn(t)),r=[],i=[];function a(e){if(A.isImportDeclaration(e)){let n=ln(e,t);n&&(n.type===`relative`?i.push(n):r.push(n))}A.forEachChild(e,a)}return a(n),{relativeImports:i,thirdPartyImports:r}}function cn(e){return e.endsWith(`.tsx`)||e.endsWith(`.jsx`)?A.ScriptKind.TSX:A.ScriptKind.TS}function ln(e,t){let n=e.moduleSpecifier;if(!A.isStringLiteral(n))return null;let r=n.text;if(e.importClause?.isTypeOnly)return null;let i=un(e.importClause);if(i.length===0)return null;if(fn(r))return{resolvedPath:dn(r,t),source:r,specifiers:i,type:`relative`};if(pn(r))return null;let a=mn(t);if(gn(r,a)){let e=_n(r,a);if(e)return{resolvedPath:e,source:r,specifiers:i,type:`relative`}}return{source:r,specifiers:i,type:`thirdParty`}}function un(e){if(!e)return[];let t=[];return e.name&&t.push({imported:`default`,local:`default`}),e.namedBindings&&(A.isNamespaceImport(e.namedBindings)?t.push({imported:`*`,local:`*`}):A.isNamedImports(e.namedBindings)&&e.namedBindings.elements.forEach(e=>{if(!e.isTypeOnly){let n=e.propertyName?e.propertyName.text:e.name.text,r=e.name.text;t.push({imported:n,local:r})}})),t}function dn(e,t){let n=T(S(t),e),r=[`.ts`,`.tsx`,`.js`,`.jsx`];for(let e of r){let t=n+e;if(E(t))return t}for(let e of r){let t=C(n,`index${e}`);if(E(t))return t}return n}function fn(e){return e.startsWith(`./`)||e.startsWith(`../`)}function pn(e){return e.startsWith(`node:`)||on.includes(e)}function mn(e){let t=S(e),n=[];for(;t!==S(t);){let e=C(t,`tsconfig.json`);if(E(e))try{let r=A.sys.readFile(e);if(!r){t=S(t);continue}let i=A.parseConfigFileTextToJson(e,r);if(i.error){t=S(t);continue}let a=i.config?.compilerOptions?.paths,o=i.config?.compilerOptions?.baseUrl||`./`,s=T(t,o);if(a){for(let[e,t]of Object.entries(a))if(Array.isArray(t)&&t.length>0){let r=t[0],i=RegExp(`^${e.replace(`*`,`(.*)`).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(`\\(\\*\\)`,`(.*)`)}$`),a=T(s,r.replace(`*`,`$1`));n.push({pattern:i,replacement:a})}}let c=i.config?.extends;if(c){let e=hn(T(t,c));n.push(...e)}return n}catch{t=S(t);continue}t=S(t)}return n}function hn(e){let t=[],n=S(e);try{let r=A.sys.readFile(e);if(!r)return t;let i=A.parseConfigFileTextToJson(e,r);if(i.error)return t;let a=i.config?.compilerOptions?.paths,o=T(n,i.config?.compilerOptions?.baseUrl||`./`);if(a){for(let[e,n]of Object.entries(a))if(Array.isArray(n)&&n.length>0){let r=n[0],i=RegExp(`^${e.replace(`*`,`(.*)`).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(`\\(\\*\\)`,`(.*)`)}$`),a=T(o,r.replace(`*`,`$1`));t.push({pattern:i,replacement:a})}}let s=i.config?.extends;if(s){let e=T(n,s);if(e.endsWith(`.json`)||(e+=`.json`),E(e)){let n=hn(e);t.push(...n)}}}catch{return t}return t}function gn(e,t){return t.some(t=>t.pattern.test(e))}function _n(e,t){for(let n of t)if(n.pattern.test(e)){let t=e.replace(n.pattern,n.replacement),r=[`.ts`,`.tsx`,`.js`,`.jsx`];for(let e of r){let n=t+e;if(E(n))return n}for(let e of r){let n=C(t,`index${e}`);if(E(n))return n}return t}return null}function vn(e,t){let n=w(t,e),r=n.split(ge);if(r.includes(`demos`)){let e=r.indexOf(`demos`);return r.slice(0,e).join(ge)}return S(n)}function yn(e){return e.endsWith(`.css`)}function bn(e){try{return e.includes(`/demos/`)&&e.endsWith(`.tsx`)&&!_e(e).includes(`export default`)}catch{return!1}}var X=null,xn=!1,Z=new Map,Q=new Map,$=new Map;function Sn({demoPattern:e=`src/routes/**/demos/*.tsx`,routesDir:t=`src/routes`,theme:n={dark:Ce,light:`github-light-high-contrast`},transformers:r=[],transformLine:i,transformTailwindStyles:a}={}){let o={defaultColor:`light-dark()`,lang:`tsx`,themes:{dark:n.dark,light:n.light}};return{apply(e,t){return t.mode===`development`&&t.command===`serve`||t.mode===`production`&&t.command===`build`},async buildStart(){if(!X&&!xn){xn=!0;try{X=await Me({langs:[`tsx`,`typescript`,`css`],themes:[n.dark,n.light]}),console.log(`${O.magenta.bold(q)} Shiki highlighter initialized`)}catch(e){console.warn(`${O.magenta.bold(q)} Failed to initialize highlighter:`,e)}finally{xn=!1}}await l()},async handleHotUpdate({file:e,modules:t,server:n}){if(yn(e))return t;if(e.endsWith(`.mdx`))return[];let r=[];if(bn(e))await s({filePath:e}),r.push(J(e));else{let t=T(e),n=$.get(t);if(!n?.size)return[];for(let e of Array.from(n)){let t=Z.get(e);t&&(await s({filePath:t.filePath}),r.push(e))}}let i=n.moduleGraph.getModuleById(K.AUTO);i&&n.moduleGraph.invalidateModule(i);for(let e of r){let t=Z.get(e);t&&n.ws.send({data:t,event:`qui-demo:update`,type:`custom`})}return[]},load(e){if(e===K.AUTO)return u()},name:`auto-demo-scope`,resolveId(e){if(e===`virtual:qui-demo-scope/auto`)return K.AUTO},writeBundle(){console.log(`${O.blue.bold(q)} Successfully integrated ${O.green(Z.size)} component demos`)}};async function s({filePath:e}){let n=vn(e,t),r=J(e),i=Q.get(n)??[];i.includes(e)||(i.push(e),Q.set(n,i));let a=await m(e);if(a){Z.set(r,{...a,demoName:r,pageId:n});let t=await Y(e);if(t)for(let e of t.relativeImports){let t=$.get(e.resolvedPath)??new Set;t.add(r),$.set(e.resolvedPath,t)}}}async function c(e,t={}){let{extraTransformers:n=[],onResidualCss:i}=t;if(!X)return{full:e};let s=null,c=[];if(a&&i){let e=await Zt({onClassesDetected:e=>{t.onClassesDetected?.(e)},onResidualCss:i,styleFormat:`jsx`,styles:j`
|
|
46
46
|
@layer theme, base, components, utilities;
|
|
47
47
|
@import "tailwindcss/theme.css" layer(theme);
|
|
48
48
|
@import "tailwindcss/utilities.css" layer(utilities);
|
|
49
49
|
@import "@qualcomm-ui/tailwind-plugin/qui-strict.css";
|
|
50
|
-
`});c.push(e)}else n.length>0&&c.push(...n);try{let t=
|
|
50
|
+
`});c.push(e)}else n.length>0&&c.push(...n);try{let t=X.codeToHtml(e,{...o,transformers:[...I(),...r,...c,Nt({attributeName:`data-preview`,onComplete:e=>{s=e}}),At({attributeName:`data-code`}),{enforce:`post`,name:`shiki-transformer-trim`,preprocess(e){return e.trim()}},...r]});return{full:t,preview:s?kt(t):null}}catch(t){return console.warn(`${O.magenta.bold(q)} Failed to highlight code:`,t),{full:e}}}async function l(){if(Z.size)return;let n=(await ye(e)).filter(bn);for(let e of n){let n=vn(e,t),r=Q.get(n)??[];r.push(e),Q.set(n,r);let i=await m(e);if(i){let t=J(e);Z.set(t,{...i,pageId:n})}let a=await Y(e);if(a)for(let t of a.relativeImports){let n=J(e),r=$.get(t.resolvedPath)??new Set;r.add(n),$.set(t.resolvedPath,r)}}}function u(){let e=[`// Auto-generated demo scope resolver`,h(Z),g()];return process.env.NODE_ENV===`development`&&e.push(d()),e.join(`
|
|
51
51
|
|
|
52
|
-
`)}function
|
|
52
|
+
`)}function d(){return j`
|
|
53
53
|
if (import.meta.hot) {
|
|
54
54
|
import.meta.hot.on("qui-demo:update", (data) => {
|
|
55
55
|
demoRegistry.set(data.demoName, data)
|
|
56
56
|
})
|
|
57
57
|
}
|
|
58
|
-
`}function
|
|
58
|
+
`}function f(e){if(!i)return e;let t=[];for(let n of e.split(`
|
|
59
59
|
`))if(n.trim()){let e=i(n);e&&t.push(e)}else t.push(n);return t.join(`
|
|
60
|
-
`)}async function
|
|
60
|
+
`)}async function p(e,t){try{let n=x(e),r=await c(t),i,o=!1,s;return a&&(i=await c(t,{onClassesDetected:e=>{o=e},onResidualCss:e=>{s=e}})),{residualRules:s,sourceCodeData:{fileName:n,filePath:e,highlighted:{full:r.full,preview:r.preview},highlightedInline:o&&i?{full:i.full,preview:i.preview}:void 0,type:`file`}}}catch{return null}}async function m(e){try{let t=await D(e,`utf-8`).then(f),n=ee(t,e),r=[],i=new Map,a=await p(e,t);if(a&&(r.push(a.sourceCodeData),a.residualRules))for(let[e,t]of a.residualRules)i.set(e,t);let o=await Y(e);if(o)for(let e of o.relativeImports)try{let t=await D(e.resolvedPath,`utf-8`).then(f),n=await p(e.resolvedPath,t);if(n&&(r.push(n.sourceCodeData),n.residualRules))for(let[e,t]of n.residualRules)i.set(e,t)}catch{console.debug(`Failed to process file`,e.resolvedPath)}let s=i.size>0?[...i.values()].join(`
|
|
61
61
|
|
|
62
|
-
`):void 0;return s&&r.push({fileName:`styles.css`,highlighted:await
|
|
63
|
-
`&&n++,e.slice(t.start,n).trim()})}catch{return[]}}function
|
|
64
|
-
`)}\n])`}function
|
|
62
|
+
`):void 0;return s&&r.push({fileName:`styles.css`,highlighted:await c(s),type:`residual-css`}),{demoName:J(e),fileName:a?.sourceCodeData.fileName||x(e),filePath:e,imports:n,sourceCode:r}}catch{return null}}function ee(e,t){try{let n=A.createSourceFile(t,e,A.ScriptTarget.Latest,!0,cn(t)),r=[];function i(e){A.isImportDeclaration(e)&&r.push({end:e.getEnd(),start:e.getFullStart()}),A.forEachChild(e,i)}return i(n),r.map(t=>{let n=t.end;return e[n]===`
|
|
63
|
+
`&&n++,e.slice(t.start,n).trim()})}catch{return[]}}function h(e){return`const demoRegistry = new Map([\n${Array.from(e.entries()).map(([e,{fileName:t,imports:n,pageId:r,sourceCode:i}])=>` ["${e}", { fileName: "${t}", imports: ${JSON.stringify(n)}, pageId: "${r}", sourceCode: ${JSON.stringify(i)}, demoName: "${e}" }]`).join(`,
|
|
64
|
+
`)}\n])`}function g(){return j`
|
|
65
65
|
export function getDemo(demoName) {
|
|
66
66
|
const demo = demoRegistry.get(demoName)
|
|
67
67
|
if (!demo) {
|
|
@@ -75,5 +75,5 @@ export function getAngularDemoInfo(demoId) {
|
|
|
75
75
|
}
|
|
76
76
|
return demo
|
|
77
77
|
}
|
|
78
|
-
`}}export{
|
|
78
|
+
`}}export{o as ConfigLoader,q as LOG_PREFIX,on as NODE_BUILTINS,an as REACT_IMPORTS,K as VIRTUAL_MODULE_IDS,$t as angularDemoPlugin,s as configSchema,J as createDemoName,Y as extractFileImports,vn as extractPageId,St as frontmatterHmrPlugin,n as getAlertIcon,Pt as getRehypePlugins,Ft as getRemarkPlugins,cn as getScriptKind,I as getShikiTransformers,yn as isCssAsset,bn as isDemoFile,te as isSerializeJsxBlock,ie as isSpoilerBlock,g as isStepBlock,l as navMetaSchema,vt as quiDocsPlugin,Sn as reactDemoPlugin,Ue as rehypeMdxCodeProps,Dt as rehypeSectionize,wt as rehypeSlug,c as remarkAlerts,r as remarkCodeTabs,d as remarkExtractMeta,we as remarkFrontmatter,fe as remarkFrontmatterDescription,t as remarkFrontmatterInterpolation,u as remarkFrontmatterTitle,Te as remarkGfm,We as remarkMdxFrontmatter,m as remarkRemoveJsx,pe as remarkRemoveMermaidCodeBlocks,me as remarkSelfLinkHeadings,f as remarkSerializeJsxKnowledge,de as remarkSerializeJsxRender,_ as remarkSpoilers,oe as remarkSteps,i as routeMetaSchema};
|
|
79
79
|
//# sourceMappingURL=index.js.map
|