minecodex 2.0.37 → 2.0.39
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/README.md +26 -89
- package/features/markdown-reading/assets/qv-dependencies.js +4412 -0
- package/features/markdown-reading/assets/qv-export.js +2 -0
- package/features/markdown-reading/assets/qv-loading.css +4 -0
- package/features/markdown-reading/assets/qv-template.json +1 -0
- package/features/markdown-reading/codex-feature.json +6 -1
- package/features/markdown-reading/src/adapters/codex/mermaid-viewer.mjs +95 -0
- package/features/markdown-reading/src/adapters/codex/mermaid.mjs +91 -0
- package/features/markdown-reading/src/adapters/codex/preview.mjs +2 -2
- package/features/markdown-reading/src/adapters/codex/reading-runtime.mjs +10 -0
- package/features/markdown-reading/src/adapters/codex/table-actions.mjs +14 -0
- package/features/markdown-reading/src/injection-source.mjs +16 -1
- package/features/markdown-reading/src/markdown-reading.mjs +5 -3
- package/features/markdown-reading/src/mermaid/export.mjs +83 -0
- package/features/markdown-reading/src/mermaid/frame.mjs +109 -0
- package/features/markdown-reading/src/mermaid/loading.mjs +27 -0
- package/features/markdown-reading/src/mermaid/theme.css +8 -0
- package/features/markdown-reading/src/mermaid/viewport.mjs +75 -0
- package/features/markdown-reading/vendor/qv/LICENSE +21 -0
- package/features/markdown-reading/vendor/qv/THIRD_PARTY_NOTICES.txt +3009 -0
- package/features/markdown-reading/vendor/qv/provenance.json +55 -0
- package/features/usage-meter/src/adapters/codex/renderer.mjs +11 -3
- package/features/usage-meter/src/usage-meter.mjs +19 -4
- package/package.json +14 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(()=>{function D(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;let r=document.implementation.createHTMLDocument(),n=r.createElement("base"),o=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(o),e&&(n.href=e),o.href=t,o.href}var A=(()=>{let t=0,e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${e()}${t}`)})();function f(t){let e=[];for(let r=0,n=t.length;r<n;r++)e.push(t[r]);return e}var g=null;function E(t={}){return g||(t.includeStyleProperties?(g=t.includeStyleProperties,g):(g=f(window.getComputedStyle(document.documentElement)),g))}function S(t,e){let n=(t.ownerDocument.defaultView||window).getComputedStyle(t).getPropertyValue(e);return n?parseFloat(n.replace("px","")):0}function N(t){let e=S(t,"border-left-width"),r=S(t,"border-right-width");return t.clientWidth+e+r}function tt(t){let e=S(t,"border-top-width"),r=S(t,"border-bottom-width");return t.clientHeight+e+r}function P(t,e={}){let r=e.width||N(t),n=e.height||tt(t);return{width:r,height:n}}function U(){let t,e;try{e=process}catch{}let r=e&&e.env?e.env.devicePixelRatio:null;return r&&(t=parseInt(r,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}var u=16384;function v(t){(t.width>u||t.height>u)&&(t.width>u&&t.height>u?t.width>t.height?(t.height*=u/t.width,t.width=u):(t.width*=u/t.height,t.height=u):t.width>u?(t.height*=u/t.width,t.width=u):(t.width*=u/t.height,t.height=u))}function k(t,e={}){return t.toBlob?new Promise(r=>{t.toBlob(r,e.type?e.type:"image/png",e.quality?e.quality:1)}):new Promise(r=>{let n=window.atob(t.toDataURL(e.type?e.type:void 0,e.quality?e.quality:void 0).split(",")[1]),o=n.length,i=new Uint8Array(o);for(let a=0;a<o;a+=1)i[a]=n.charCodeAt(a);r(new Blob([i],{type:e.type?e.type:"image/png"}))})}function d(t){return new Promise((e,r)=>{let n=new Image;n.onload=()=>{n.decode().then(()=>{requestAnimationFrame(()=>e(n))})},n.onerror=r,n.crossOrigin="anonymous",n.decoding="async",n.src=t})}async function et(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function M(t,e,r){let n="http://www.w3.org/2000/svg",o=document.createElementNS(n,"svg"),i=document.createElementNS(n,"foreignObject");return o.setAttribute("width",`${e}`),o.setAttribute("height",`${r}`),o.setAttribute("viewBox",`0 0 ${e} ${r}`),i.setAttribute("width","100%"),i.setAttribute("height","100%"),i.setAttribute("x","0"),i.setAttribute("y","0"),i.setAttribute("externalResourcesRequired","true"),o.appendChild(i),i.appendChild(t),et(o)}var l=(t,e)=>{if(t instanceof e)return!0;let r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===e.name||l(r,e)};function rt(t){let e=t.getPropertyValue("content");return`${t.cssText} content: '${e.replace(/'|"/g,"")}';`}function nt(t,e){return E(e).map(r=>{let n=t.getPropertyValue(r),o=t.getPropertyPriority(r);return`${r}: ${n}${o?" !important":""};`}).join(" ")}function it(t,e,r,n){let o=`.${t}:${e}`,i=r.cssText?rt(r):nt(r,n);return document.createTextNode(`${o}{${i}}`)}function V(t,e,r,n){let o=window.getComputedStyle(t,r),i=o.getPropertyValue("content");if(i===""||i==="none")return;let a=A();try{e.className=`${e.className} ${a}`}catch{return}let s=document.createElement("style");s.appendChild(it(a,r,o,n)),e.appendChild(s)}function H(t,e,r){V(t,e,":before",r),V(t,e,":after",r)}var O="application/font-woff",_="image/jpeg",ot={woff:O,woff2:O,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:_,jpeg:_,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function at(t){let e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}function p(t){let e=at(t).toLowerCase();return ot[e]||""}function st(t){return t.split(/,/)[1]}function x(t){return t.search(/^(data:)/)!==-1}function L(t,e){return`data:${e};base64,${t}`}async function $(t,e,r){let n=await fetch(t,e);if(n.status===404)throw new Error(`Resource "${n.url}" not found`);let o=await n.blob();return new Promise((i,a)=>{let s=new FileReader;s.onerror=a,s.onloadend=()=>{try{i(r({res:n,result:s.result}))}catch(c){a(c)}},s.readAsDataURL(o)})}var T={};function ct(t,e,r){let n=t.replace(/\?.*/,"");return r&&(n=t),/ttf|otf|eot|woff2?/i.test(n)&&(n=n.replace(/.*\//,"")),e?`[${e}]${n}`:n}async function y(t,e,r){let n=ct(t,e,r.includeQueryParams);if(T[n]!=null)return T[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let o;try{let i=await $(t,r.fetchRequestInit,({res:a,result:s})=>(e||(e=a.headers.get("Content-Type")||""),st(s)));o=L(i,e)}catch(i){o=r.imagePlaceholder||"";let a=`Failed to fetch resource: ${t}`;i&&(a=typeof i=="string"?i:i.message),a&&console.warn(a)}return T[n]=o,o}async function lt(t){let e=t.toDataURL();return e==="data:,"?t.cloneNode(!1):d(e)}async function ut(t,e){if(t.currentSrc){let i=document.createElement("canvas"),a=i.getContext("2d");i.width=t.clientWidth,i.height=t.clientHeight,a?.drawImage(t,0,0,i.width,i.height);let s=i.toDataURL();return d(s)}let r=t.poster,n=p(r),o=await y(r,n,e);return d(o)}async function ft(t,e){var r;try{if(!((r=t?.contentDocument)===null||r===void 0)&&r.body)return await b(t.contentDocument.body,e,!0)}catch{}return t.cloneNode(!1)}async function mt(t,e){return l(t,HTMLCanvasElement)?lt(t):l(t,HTMLVideoElement)?ut(t,e):l(t,HTMLIFrameElement)?ft(t,e):t.cloneNode(W(t))}var ht=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",W=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function gt(t,e,r){var n,o;if(W(e))return e;let i=[];return ht(t)&&t.assignedNodes?i=f(t.assignedNodes()):l(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?i=f(t.contentDocument.body.childNodes):i=f(((o=t.shadowRoot)!==null&&o!==void 0?o:t).childNodes),i.length===0||l(t,HTMLVideoElement)||await i.reduce((a,s)=>a.then(()=>b(s,r)).then(c=>{c&&e.appendChild(c)}),Promise.resolve()),e}function dt(t,e,r){let n=e.style;if(!n)return;let o=window.getComputedStyle(t);o.cssText?(n.cssText=o.cssText,n.transformOrigin=o.transformOrigin):E(r).forEach(i=>{let a=o.getPropertyValue(i);i==="font-size"&&a.endsWith("px")&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),l(t,HTMLIFrameElement)&&i==="display"&&a==="inline"&&(a="block"),i==="d"&&e.getAttribute("d")&&(a=`path(${e.getAttribute("d")})`),n.setProperty(i,a,o.getPropertyPriority(i))})}function pt(t,e){l(t,HTMLTextAreaElement)&&(e.innerHTML=t.value),l(t,HTMLInputElement)&&e.setAttribute("value",t.value)}function yt(t,e){if(l(t,HTMLSelectElement)){let n=Array.from(e.children).find(o=>t.value===o.getAttribute("value"));n&&n.setAttribute("selected","")}}function wt(t,e,r){return l(e,Element)&&(dt(t,e,r),H(t,e,r),pt(t,e),yt(t,e)),e}async function xt(t,e){let r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;let n={};for(let i=0;i<r.length;i++){let s=r[i].getAttribute("xlink:href");if(s){let c=t.querySelector(s),m=document.querySelector(s);!c&&m&&!n[s]&&(n[s]=await b(m,e,!0))}}let o=Object.values(n);if(o.length){let i="http://www.w3.org/1999/xhtml",a=document.createElementNS(i,"svg");a.setAttribute("xmlns",i),a.style.position="absolute",a.style.width="0",a.style.height="0",a.style.overflow="hidden",a.style.display="none";let s=document.createElementNS(i,"defs");a.appendChild(s);for(let c=0;c<o.length;c++)s.appendChild(o[c]);t.appendChild(a)}return t}async function b(t,e,r){return!r&&e.filter&&!e.filter(t)?null:Promise.resolve(t).then(n=>mt(n,e)).then(n=>gt(t,n,e)).then(n=>wt(t,n,e)).then(n=>xt(n,e))}var B=/url\((['"]?)([^'"]+?)\1\)/g,bt=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,St=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Et(t){let e=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}function Rt(t){let e=[];return t.replace(B,(r,n,o)=>(e.push(o),r)),e.filter(r=>!x(r))}async function Ct(t,e,r,n,o){try{let i=r?D(e,r):e,a=p(e),s;if(o){let c=await o(i);s=L(c,a)}else s=await y(i,a,n);return t.replace(Et(e),`$1${s}$3`)}catch{}return t}function Pt(t,{preferredFontFormat:e}){return e?t.replace(St,r=>{for(;;){let[n,,o]=bt.exec(r)||[];if(!o)return"";if(o===e)return`src: ${n};`}}):t}function F(t){return t.search(B)!==-1}async function R(t,e,r){if(!F(t))return t;let n=Pt(t,r);return Rt(n).reduce((i,a)=>i.then(s=>Ct(s,a,e,r)),Promise.resolve(n))}async function w(t,e,r){var n;let o=(n=e.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(o){let i=await R(o,null,r);return e.style.setProperty(t,i,e.style.getPropertyPriority(t)),!0}return!1}async function Tt(t,e){await w("background",t,e)||await w("background-image",t,e),await w("mask",t,e)||await w("-webkit-mask",t,e)||await w("mask-image",t,e)||await w("-webkit-mask-image",t,e)}async function Lt(t,e){let r=l(t,HTMLImageElement);if(!(r&&!x(t.src))&&!(l(t,SVGImageElement)&&!x(t.href.baseVal)))return;let n=r?t.src:t.href.baseVal,o=await y(n,p(n),e);await new Promise((i,a)=>{t.onload=i,t.onerror=e.onImageErrorHandler?(...c)=>{try{i(e.onImageErrorHandler(...c))}catch(m){a(m)}}:a;let s=t;s.decode&&(s.decode=i),s.loading==="lazy"&&(s.loading="eager"),r?(t.srcset="",t.src=o):t.href.baseVal=o})}async function $t(t,e){let n=f(t.childNodes).map(o=>I(o,e));await Promise.all(n).then(()=>t)}async function I(t,e){l(t,Element)&&(await Tt(t,e),await Lt(t,e),await $t(t,e))}function q(t,e){let{style:r}=t;e.backgroundColor&&(r.backgroundColor=e.backgroundColor),e.width&&(r.width=`${e.width}px`),e.height&&(r.height=`${e.height}px`);let n=e.style;return n!=null&&Object.keys(n).forEach(o=>{r[o]=n[o]}),t}var j={};async function z(t){let e=j[t];if(e!=null)return e;let n=await(await fetch(t)).text();return e={url:t,cssText:n},j[t]=e,e}async function G(t,e){let r=t.cssText,n=/url\(["']?([^"')]+)["']?\)/g,i=(r.match(/url\([^)]+\)/g)||[]).map(async a=>{let s=a.replace(n,"$1");return s.startsWith("https://")||(s=new URL(s,t.url).href),$(s,e.fetchRequestInit,({result:c})=>(r=r.replace(a,`url(${c})`),[a,c]))});return Promise.all(i).then(()=>r)}function X(t){if(t==null)return[];let e=[],r=/(\/\*[\s\S]*?\*\/)/gi,n=t.replace(r,""),o=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){let c=o.exec(n);if(c===null)break;e.push(c[0])}n=n.replace(o,"");let i=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",s=new RegExp(a,"gi");for(;;){let c=i.exec(n);if(c===null){if(c=s.exec(n),c===null)break;i.lastIndex=s.lastIndex}else s.lastIndex=i.lastIndex;e.push(c[0])}return e}async function Ft(t,e){let r=[],n=[];return t.forEach(o=>{if("cssRules"in o)try{f(o.cssRules||[]).forEach((i,a)=>{if(i.type===CSSRule.IMPORT_RULE){let s=a+1,c=i.href,m=z(c).then(h=>G(h,e)).then(h=>X(h).forEach(C=>{try{o.insertRule(C,C.startsWith("@import")?s+=1:o.cssRules.length)}catch(Z){console.error("Error inserting rule from remote css",{rule:C,error:Z})}})).catch(h=>{console.error("Error loading remote css",h.toString())});n.push(m)}})}catch(i){let a=t.find(s=>s.href==null)||document.styleSheets[0];o.href!=null&&n.push(z(o.href).then(s=>G(s,e)).then(s=>X(s).forEach(c=>{a.insertRule(c,a.cssRules.length)})).catch(s=>{console.error("Error loading remote stylesheet",s)})),console.error("Error inlining remote css file",i)}}),Promise.all(n).then(()=>(t.forEach(o=>{if("cssRules"in o)try{f(o.cssRules||[]).forEach(i=>{r.push(i)})}catch(i){console.error(`Error while reading CSS rules from ${o.href}`,i)}}),r))}function It(t){return t.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>F(e.style.getPropertyValue("src")))}async function Dt(t,e){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");let r=f(t.ownerDocument.styleSheets),n=await Ft(r,e);return It(n)}function J(t){return t.trim().replace(/["']/g,"")}function At(t){let e=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(i=>{e.add(J(i))}),Array.from(n.children).forEach(i=>{i instanceof HTMLElement&&r(i)})}return r(t),e}async function K(t,e){let r=await Dt(t,e),n=At(t);return(await Promise.all(r.filter(i=>n.has(J(i.style.fontFamily))).map(i=>{let a=i.parentStyleSheet?i.parentStyleSheet.href:null;return R(i.cssText,a,e)}))).join(`
|
|
2
|
+
`)}async function Q(t,e){let r=e.fontEmbedCSS!=null?e.fontEmbedCSS:e.skipFonts?null:await K(t,e);if(r){let n=document.createElement("style"),o=document.createTextNode(r);n.appendChild(o),t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)}}async function Ut(t,e={}){let{width:r,height:n}=P(t,e),o=await b(t,e,!0);return await Q(o,e),await I(o,e),q(o,e),await M(o,r,n)}async function vt(t,e={}){let{width:r,height:n}=P(t,e),o=await Ut(t,e),i=await d(o),a=document.createElement("canvas"),s=a.getContext("2d"),c=e.pixelRatio||U(),m=e.canvasWidth||r,h=e.canvasHeight||n;return a.width=m*c,a.height=h*c,e.skipAutoScale||v(a),a.style.width=`${m}`,a.style.height=`${h}`,e.backgroundColor&&(s.fillStyle=e.backgroundColor,s.fillRect(0,0,a.width,a.height)),s.drawImage(i,0,0,a.width,a.height),a}async function Y(t,e={}){let r=await vt(t,e);return await k(r)}globalThis.__mcxQVExport={toBlob:Y};})();
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
.mcx-reading-qv-status[data-mcx-qv-loading]>.qv-loading-field{position:absolute;inset:32px 0 0;overflow:hidden;pointer-events:none;color:var(--mcx-color-text-foreground-secondary);opacity:.38;animation:mcx-qv-loading-field 1.75s ease-in-out infinite;mask-image:linear-gradient(to top left,transparent 0%,black 30% 70%,transparent 100%)}
|
|
2
|
+
.mcx-reading-qv-status[data-mcx-qv-loading] .qv-loading-canvas{display:block;width:100%;height:100%}
|
|
3
|
+
@keyframes mcx-qv-loading-field{50%{opacity:.56}}
|
|
4
|
+
@media(prefers-reduced-motion:reduce){.mcx-reading-qv-status[data-mcx-qv-loading]>.qv-loading-field{animation:none}}
|