md2x 0.7.4 → 0.7.6

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.
Files changed (136) hide show
  1. package/README.md +61 -23
  2. package/dist/chunks/chunk-Q6QMPHEY.js +1552 -0
  3. package/dist/chunks/chunk-UZ7TETMS.js +415 -0
  4. package/dist/chunks/docx-exporter-GL6CNCQD.js +1 -0
  5. package/dist/chunks/mcp-server-4TPUOZXJ.js +49 -0
  6. package/dist/core-worker.js +1764 -0
  7. package/dist/index.js +1 -1
  8. package/dist/md2x.js +8 -5
  9. package/dist/renderer/core-worker-browser.js +1775 -0
  10. package/dist/renderer/live-runtime-canvas.js +1 -1
  11. package/dist/renderer/live-runtime-dot.js +1 -1
  12. package/dist/renderer/live-runtime-html.js +1 -1
  13. package/dist/renderer/live-runtime-infographic.js +1 -1
  14. package/dist/renderer/live-runtime-md2x.js +4 -4
  15. package/dist/renderer/live-runtime-mermaid.js +1 -1
  16. package/dist/renderer/live-runtime-svg.js +1 -1
  17. package/dist/renderer/live-runtime-vega.js +1 -1
  18. package/dist/types/node/src/host/browser-renderer.d.ts +1 -175
  19. package/dist/types/node/src/host/core.d.ts +59 -0
  20. package/dist/types/node/src/host/index.d.ts +4 -49
  21. package/dist/types/node/src/host/node-exporter.d.ts +1 -90
  22. package/dist/types/node/src/host/node-platform.d.ts +1 -23
  23. package/dist/types/node/src/host/templates-data.d.ts +5 -0
  24. package/dist/types/node/src/host/themes-data.d.ts +2385 -0
  25. package/dist/types/node/src/host/types.d.ts +251 -0
  26. package/dist/types/node/src/index.d.ts +2 -3
  27. package/package.json +13 -3
  28. package/dist/chunks/chunk-2LPNL4GA.js +0 -1
  29. package/dist/chunks/chunk-3P5X57NT.js +0 -262
  30. package/dist/chunks/chunk-3VL755NO.js +0 -1
  31. package/dist/chunks/chunk-5DPTQTJJ.js +0 -1
  32. package/dist/chunks/chunk-AK6TXLWO.js +0 -1
  33. package/dist/chunks/chunk-CN4F5HOV.js +0 -5
  34. package/dist/chunks/chunk-CVKZIRZW.js +0 -5
  35. package/dist/chunks/chunk-DFROP2PD.js +0 -11
  36. package/dist/chunks/chunk-DJGIYXVP.js +0 -3
  37. package/dist/chunks/chunk-EFKQH5UR.js +0 -108
  38. package/dist/chunks/chunk-FXZD57XY.js +0 -532
  39. package/dist/chunks/chunk-IENSDROB.js +0 -1
  40. package/dist/chunks/chunk-LLCWR7UA.js +0 -1
  41. package/dist/chunks/chunk-MHCTK6WW.js +0 -1
  42. package/dist/chunks/chunk-NM6J3ND7.js +0 -1
  43. package/dist/chunks/chunk-PARPCLXM.js +0 -1
  44. package/dist/chunks/chunk-PUOHPY5L.js +0 -16
  45. package/dist/chunks/chunk-R65AQGTF.js +0 -1
  46. package/dist/chunks/chunk-R6G2575A.js +0 -3
  47. package/dist/chunks/chunk-TRGQPVRY.js +0 -2
  48. package/dist/chunks/chunk-URO5RPHJ.js +0 -9
  49. package/dist/chunks/chunk-YFL3W3OS.js +0 -1
  50. package/dist/chunks/chunk-Z4LVGK7Y.js +0 -1
  51. package/dist/chunks/docx-exporter-ZZ76JXFU.js +0 -1
  52. package/dist/chunks/rehype-highlight-Y4Q4RX67.js +0 -1
  53. package/dist/chunks/rehype-katex-FXTCTSUE.js +0 -1
  54. package/dist/chunks/rehype-stringify-4CQSSRDL.js +0 -1
  55. package/dist/chunks/remark-gfm-BUZ4SLP3.js +0 -1
  56. package/dist/chunks/remark-math-HEZQAPFK.js +0 -1
  57. package/dist/chunks/remark-parse-QC7TSXTK.js +0 -1
  58. package/dist/chunks/remark-rehype-C2LX643P.js +0 -1
  59. package/dist/chunks/remark-super-sub-EP2AQS54.js +0 -1
  60. package/dist/chunks/theme-manager-AZBU2SLL.js +0 -1
  61. package/dist/chunks/theme-to-css-GLV3WYDU.js +0 -85
  62. package/dist/chunks/unified-PU53JLVJ.js +0 -1
  63. package/dist/chunks/unist-util-visit-SBSD62C6.js +0 -1
  64. package/dist/templates/html/example.html +0 -35
  65. package/dist/templates/svelte/example.svelte +0 -18
  66. package/dist/templates/vue/PrinterComponent.vue +0 -875
  67. package/dist/templates/vue/example.vue +0 -17
  68. package/dist/templates/vue/mapLibre.vue +0 -371
  69. package/dist/themes/code-themes/business-contrast.json +0 -31
  70. package/dist/themes/code-themes/colorful.json +0 -32
  71. package/dist/themes/code-themes/cool-modern.json +0 -31
  72. package/dist/themes/code-themes/high-contrast.json +0 -31
  73. package/dist/themes/code-themes/light-clean.json +0 -31
  74. package/dist/themes/code-themes/warm-book.json +0 -31
  75. package/dist/themes/color-schemes/candy.json +0 -34
  76. package/dist/themes/color-schemes/cool.json +0 -34
  77. package/dist/themes/color-schemes/coral.json +0 -34
  78. package/dist/themes/color-schemes/dino.json +0 -34
  79. package/dist/themes/color-schemes/forest.json +0 -34
  80. package/dist/themes/color-schemes/garden.json +0 -34
  81. package/dist/themes/color-schemes/neutral.json +0 -34
  82. package/dist/themes/color-schemes/ocean.json +0 -34
  83. package/dist/themes/color-schemes/rainbow.json +0 -43
  84. package/dist/themes/color-schemes/sakura.json +0 -34
  85. package/dist/themes/color-schemes/sepia.json +0 -34
  86. package/dist/themes/color-schemes/space.json +0 -34
  87. package/dist/themes/color-schemes/starry.json +0 -34
  88. package/dist/themes/color-schemes/sunset.json +0 -34
  89. package/dist/themes/color-schemes/warm.json +0 -34
  90. package/dist/themes/font-config.json +0 -184
  91. package/dist/themes/layout-schemes/academic.json +0 -40
  92. package/dist/themes/layout-schemes/book.json +0 -40
  93. package/dist/themes/layout-schemes/document.json +0 -40
  94. package/dist/themes/layout-schemes/magazine.json +0 -40
  95. package/dist/themes/layout-schemes/student.json +0 -40
  96. package/dist/themes/layout-schemes/technical.json +0 -40
  97. package/dist/themes/presets/academic.json +0 -24
  98. package/dist/themes/presets/business.json +0 -22
  99. package/dist/themes/presets/candy.json +0 -23
  100. package/dist/themes/presets/century.json +0 -22
  101. package/dist/themes/presets/coral.json +0 -22
  102. package/dist/themes/presets/default.json +0 -22
  103. package/dist/themes/presets/dinosaur.json +0 -23
  104. package/dist/themes/presets/elegant.json +0 -22
  105. package/dist/themes/presets/forest.json +0 -22
  106. package/dist/themes/presets/garamond.json +0 -22
  107. package/dist/themes/presets/garden.json +0 -23
  108. package/dist/themes/presets/handwritten.json +0 -23
  109. package/dist/themes/presets/heiti.json +0 -22
  110. package/dist/themes/presets/magazine.json +0 -24
  111. package/dist/themes/presets/manuscript.json +0 -22
  112. package/dist/themes/presets/minimal.json +0 -22
  113. package/dist/themes/presets/mixed.json +0 -24
  114. package/dist/themes/presets/newspaper.json +0 -24
  115. package/dist/themes/presets/ocean.json +0 -22
  116. package/dist/themes/presets/palatino.json +0 -22
  117. package/dist/themes/presets/rainbow.json +0 -23
  118. package/dist/themes/presets/space.json +0 -23
  119. package/dist/themes/presets/starry.json +0 -23
  120. package/dist/themes/presets/sunset.json +0 -22
  121. package/dist/themes/presets/swiss.json +0 -22
  122. package/dist/themes/presets/technical.json +0 -22
  123. package/dist/themes/presets/typewriter.json +0 -23
  124. package/dist/themes/presets/verdana.json +0 -22
  125. package/dist/themes/presets/water.json +0 -22
  126. package/dist/themes/registry.json +0 -270
  127. package/dist/themes/table-styles/academic.json +0 -30
  128. package/dist/themes/table-styles/borderless.json +0 -26
  129. package/dist/themes/table-styles/compact.json +0 -24
  130. package/dist/themes/table-styles/grid.json +0 -22
  131. package/dist/themes/table-styles/high-contrast.json +0 -22
  132. package/dist/themes/table-styles/minimal-gray.json +0 -26
  133. package/dist/themes/table-styles/modern-tech.json +0 -34
  134. package/dist/themes/table-styles/professional.json +0 -34
  135. package/dist/themes/table-styles/zebra.json +0 -22
  136. package/dist/types/src/utils/theme-to-css.d.ts +0 -171
@@ -1 +0,0 @@
1
- function l(){return globalThis.platform}async function o(r){let e=await g(r);return JSON.parse(e)}async function g(r){let e=l();if(e?.resource?.fetch){let i=f(r);return e.resource.fetch(i)}let t=await fetch(r);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);return t.text()}function f(r){if(r.startsWith("./"))return r.slice(2);if(r.startsWith("chrome-extension://"))return new URL(r).pathname.slice(1);if(r.includes("vscode-resource")||r.includes("vscode-webview")){let e=r.indexOf("/webview/");if(e!==-1)return r.slice(e+9)}return r}function s(){return globalThis.platform}var a=class{constructor(){this.currentTheme=null;this.fontConfig=null;this.registry=null;this.initialized=!1;this.currentTheme=null,this.fontConfig=null,this.registry=null,this.initialized=!1}initializeWithData(e,t){this.fontConfig=e,t&&(this.currentTheme=t),this.initialized=!0}async initialize(){if(!this.initialized)try{let e=s();if(!e)throw new Error("Platform not available");let t=e.resource.getURL("themes/font-config.json");this.fontConfig=await o(t);let i=e.resource.getURL("themes/registry.json");this.registry=await o(i),this.initialized=!0}catch(e){let t=e instanceof Error?e.message:String(e);throw console.error("Failed to initialize theme manager:",t),e}}getFontFallback(e){if(!this.fontConfig)return console.warn("Font config not loaded yet"),e;let t=this.fontConfig.fonts[e];return t?t.webFallback:(console.warn(`Font '${e}' not found in font-config.json, using as-is`),e)}buildFontFamily(e){return typeof e=="string"?this.getFontFallback(e):String(e)}getDocxFont(e){if(!this.fontConfig)return console.warn("Font config not loaded yet"),{ascii:e,eastAsia:e,hAnsi:e,cs:e};let t=this.fontConfig.fonts[e];if(!t||!t.docx)return console.warn(`DOCX font config for '${e}' not found, using as-is`),{ascii:e,eastAsia:e,hAnsi:e,cs:e};let i=t.docx;return{ascii:i.ascii,eastAsia:i.eastAsia,hAnsi:i.ascii,cs:i.ascii}}async loadTheme(e){await this.initialize();try{let t=s();if(!t)throw new Error("Platform not available");let i=await o(t.resource.getURL(`themes/presets/${e}.json`));return this.currentTheme=i,i}catch(t){throw console.error("Error loading theme:",t),t}}async loadSelectedTheme(){let e=s();return e&&(await e.storage.get(["selectedTheme"])).selectedTheme||"default"}async saveSelectedTheme(e){let t=s();t&&await t.storage.set({selectedTheme:e})}getCurrentTheme(){return this.currentTheme}ptToPx(e){return`${parseFloat(e)*4/3}px`}ptToHalfPt(e){return parseFloat(e)*2}ptToTwips(e){let t=parseFloat(e);return Math.round(t*20)}async getAvailableThemes(){if(await this.initialize(),!this.registry)return[];let e=s();return e?(await Promise.all(this.registry.themes.map(async i=>{try{let n=await(await fetch(e.resource.getURL(`themes/presets/${i.file}`))).json();return{id:n.id,name:n.name,name_en:n.name_en,description:n.description,description_en:n.description_en,category:i.category,featured:i.featured||!1}}catch(c){return console.error(`Failed to load theme metadata for ${i.id}:`,c),null}}))).filter(i=>i!==null):[]}async getThemesByCategory(){await this.initialize();let e=await this.getAvailableThemes(),t={};return this.registry&&(Object.keys(this.registry.categories).forEach(i=>{t[i]={...this.registry.categories[i],themes:[]}}),e.forEach(i=>{t[i.category]&&t[i.category].themes.push(i)})),t}async switchTheme(e){let t=await this.loadTheme(e);return await this.saveSelectedTheme(e),t}},h=new a,d=h;export{o as a,d as b};
@@ -1 +0,0 @@
1
- import{f as a}from"./chunk-Z4LVGK7Y.js";function c(r){let i=[],s=r,n=/(?<!\^)\^([^\s^][^^]*?[^\s^]|[^\s^])\^(?!\^)|(?<!~)~([^\s~][^~]*?[^\s~]|[^\s~])~(?!~)/g,t=0,e;for(;(e=n.exec(r))!==null;){e.index>t&&i.push({type:"text",value:r.slice(t,e.index)});let p=e[0].startsWith("^"),u=p?e[1]:e[2];p?i.push({type:"superscript",children:[{type:"text",value:u}],data:{hName:"sup"}}):i.push({type:"subscript",children:[{type:"text",value:u}],data:{hName:"sub"}}),t=e.index+e[0].length}return t<r.length&&i.push({type:"text",value:r.slice(t)}),i}var l=function(){return r=>{a(r,"text",(i,s,n)=>{if(s===void 0||!n)return;let t=i.value;if(!t.includes("^")&&!t.includes("~"))return;let e=c(t);e.length===1&&e[0].type==="text"||n.children.splice(s,1,...e)})}},o=l;export{o as a};
@@ -1 +0,0 @@
1
- function o(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?t(n.position):"start"in n||"end"in n?t(n):"line"in n||"column"in n?i(n):""}function i(n){return r(n&&n.line)+":"+r(n&&n.column)}function t(n){return i(n&&n.start)+"-"+i(n&&n.end)}function r(n){return n&&typeof n=="number"?n:1}export{o as a};
@@ -1,5 +0,0 @@
1
- import{a as $}from"./chunk-LLCWR7UA.js";import{a as M}from"./chunk-PARPCLXM.js";import{h as g}from"./chunk-IENSDROB.js";function k(){return{enter:{mathFlow:t,mathFlowFenceMeta:o,mathText:s},exit:{mathFlow:e,mathFlowFence:r,mathFlowFenceMeta:l,mathFlowValue:x,mathText:m,mathTextData:x}};function t(i){let u={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[u]}},i)}function o(){this.buffer()}function l(){let i=this.resume(),u=this.stack[this.stack.length-1];u.type,u.meta=i}function r(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function e(i){let u=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),h=this.stack[this.stack.length-1];h.type,this.exit(i),h.value=u;let c=h.data.hChildren[0];c.type,c.tagName,c.children.push({type:"text",value:u}),this.data.mathFlowInside=void 0}function s(i){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},i),this.buffer()}function m(i){let u=this.resume(),h=this.stack[this.stack.length-1];h.type,this.exit(i),h.value=u,h.data.hChildren.push({type:"text",value:u})}function x(i){this.config.enter.data.call(this,i),this.config.exit.data.call(this,i)}}function y(t){let o=(t||{}).singleDollarTextMath;return o==null&&(o=!0),r.peek=e,{unsafe:[{character:"\r",inConstruct:"mathFlowMeta"},{character:`
2
- `,inConstruct:"mathFlowMeta"},{character:"$",after:o?void 0:"\\$",inConstruct:"phrasing"},{character:"$",inConstruct:"mathFlowMeta"},{atBreak:!0,character:"$",after:"\\$"}],handlers:{math:l,inlineMath:r}};function l(s,m,x,i){let u=s.value||"",h=x.createTracker(i),c="$".repeat(Math.max($(u,"$")+1,2)),f=x.enter("mathFlow"),p=h.move(c);if(s.meta){let w=x.enter("mathFlowMeta");p+=h.move(x.safe(s.meta,{after:`
3
- `,before:p,encode:["$"],...h.current()})),w()}return p+=h.move(`
4
- `),u&&(p+=h.move(u+`
5
- `)),p+=h.move(c),f(),p}function r(s,m,x){let i=s.value||"",u=1;for(o||u++;new RegExp("(^|[^$])"+"\\$".repeat(u)+"([^$]|$)").test(i);)u++;let h="$".repeat(u);/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^\$|\$$/.test(i))&&(i=" "+i+" ");let c=-1;for(;++c<x.unsafe.length;){let f=x.unsafe[c];if(!f.atBreak)continue;let p=x.compilePattern(f),w;for(;w=p.exec(i);){let d=w.index;i.codePointAt(d)===10&&i.codePointAt(d-1)===13&&d--,i=i.slice(0,d)+" "+i.slice(w.index+1)}}return h+i+h}function e(){return"$"}}var q={tokenize:L,concrete:!0,name:"mathFlow"},S={tokenize:O,partial:!0};function L(t,o,l){let r=this,e=r.events[r.events.length-1],s=e&&e[1].type==="linePrefix"?e[2].sliceSerialize(e[1],!0).length:0,m=0;return x;function x(n){return t.enter("mathFlow"),t.enter("mathFlowFence"),t.enter("mathFlowFenceSequence"),i(n)}function i(n){return n===36?(t.consume(n),m++,i):m<2?l(n):(t.exit("mathFlowFenceSequence"),M(t,u,"whitespace")(n))}function u(n){return n===null||g(n)?c(n):(t.enter("mathFlowFenceMeta"),t.enter("chunkString",{contentType:"string"}),h(n))}function h(n){return n===null||g(n)?(t.exit("chunkString"),t.exit("mathFlowFenceMeta"),c(n)):n===36?l(n):(t.consume(n),h)}function c(n){return t.exit("mathFlowFence"),r.interrupt?o(n):t.attempt(S,f,a)(n)}function f(n){return t.attempt({tokenize:D,partial:!0},a,p)(n)}function p(n){return(s?M(t,w,"linePrefix",s+1):w)(n)}function w(n){return n===null?a(n):g(n)?t.attempt(S,f,a)(n):(t.enter("mathFlowValue"),d(n))}function d(n){return n===null||g(n)?(t.exit("mathFlowValue"),w(n)):(t.consume(n),d)}function a(n){return t.exit("mathFlow"),o(n)}function D(n,v,E){let z=0;return M(n,N,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function N(F){return n.enter("mathFlowFence"),n.enter("mathFlowFenceSequence"),C(F)}function C(F){return F===36?(z++,n.consume(F),C):z<m?E(F):(n.exit("mathFlowFenceSequence"),M(n,I,"whitespace")(F))}function I(F){return F===null||g(F)?(n.exit("mathFlowFence"),v(F)):E(F)}}}function O(t,o,l){let r=this;return e;function e(m){return m===null?o(m):(t.enter("lineEnding"),t.consume(m),t.exit("lineEnding"),s)}function s(m){return r.parser.lazy[r.now().line]?l(m):o(m)}}function b(t){let l=(t||{}).singleDollarTextMath;return l==null&&(l=!0),{tokenize:r,resolve:_,previous:A,name:"mathText"};function r(e,s,m){let x=this,i=0,u,h;return c;function c(a){return e.enter("mathText"),e.enter("mathTextSequence"),f(a)}function f(a){return a===36?(e.consume(a),i++,f):i<2&&!l?m(a):(e.exit("mathTextSequence"),p(a))}function p(a){return a===null?m(a):a===36?(h=e.enter("mathTextSequence"),u=0,d(a)):a===32?(e.enter("space"),e.consume(a),e.exit("space"),p):g(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),p):(e.enter("mathTextData"),w(a))}function w(a){return a===null||a===32||a===36||g(a)?(e.exit("mathTextData"),p(a)):(e.consume(a),w)}function d(a){return a===36?(e.consume(a),u++,d):u===i?(e.exit("mathTextSequence"),e.exit("mathText"),s(a)):(h.type="mathTextData",w(a))}}}function _(t){let o=t.length-4,l=3,r,e;if((t[l][1].type==="lineEnding"||t[l][1].type==="space")&&(t[o][1].type==="lineEnding"||t[o][1].type==="space")){for(r=l;++r<o;)if(t[r][1].type==="mathTextData"){t[o][1].type="mathTextPadding",t[l][1].type="mathTextPadding",l+=2,o-=2;break}}for(r=l-1,o++;++r<=o;)e===void 0?r!==o&&t[r][1].type!=="lineEnding"&&(e=r):(r===o||t[r][1].type==="lineEnding")&&(t[e][1].type="mathTextData",r!==e+2&&(t[e][1].end=t[r-1][1].end,t.splice(e+2,r-e-2),o-=r-e-2,r=e+2),e=void 0);return t}function A(t){return t!==36||this.events[this.events.length-1][1].type==="characterEscape"}function T(t){return{flow:{36:q},text:{36:b(t)}}}var B={};function P(t){let o=this,l=t||B,r=o.data(),e=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),m=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);e.push(T(l)),s.push(k()),m.push(y(l))}export{P as a};