@webority/chat-core 0.151.2 → 0.152.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/figures.js +1 -1
- package/package.json +2 -2
package/dist/figures.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`×`,t=`[-+\\u2212]?\\d{1,3}`,n=/* @__PURE__ */ new Map([[`times`,e],[`cdot`,`·`],[`sum`,`∑`],[`leq`,`≤`],[`le`,`≤`],[`geq`,`≥`],[`ge`,`≥`],[`neq`,`≠`],[`approx`,`≈`],[`pm`,`±`],[`rightarrow`,`→`],[`to`,`→`],[`alpha`,`α`],[`beta`,`β`],[`gamma`,`γ`],[`delta`,`δ`],[`lambda`,`λ`],[`mu`,`μ`],[`pi`,`π`],[`rho`,`ρ`],[`sigma`,`σ`],[`tau`,`τ`],[`Delta`,`Δ`],[`Omega`,`Ω`]]),r=/\\\((.*?)\\\)|\\\[(.*?)\\\]|\$\$(.*?)\$\$/gs,i=/`[^`]+`/g,a=/([_^])(\{[^}]*\}|[A-Za-z0-9])/g,o=e=>`(?<${e}>\\{\\s*${t}\\s*\\}|\\(\\s*${t}\\s*\\)|${t})`,s=`(?<tensMantissa>\\d+(?:\\.\\d+)?) *[xX*] *10 ?\\^ ?${o(`tensExp`)}`,c=`\\b10 ?\\^ ?${o(`powExp`)}`,l=`(?<![A-Za-z0-9_.#-])(?<etoken>\\d+(?:\\.\\d+)?[eE]${t})(?![A-Za-z0-9_.-])`,u=RegExp(`${s}|${c}|${l}|(?<![A-Za-z0-9_])(?<symLetter>[A-Za-z])_(?<symSub>[A-Za-z0-9]+)(?<symPrime>')?(?![A-Za-z0-9_])`,`g`),d=e=>e.replace(/\\(?:left|right)\b/g,``).replace(/\\(?:text|mathrm|mathbf|mathit|operatorname)\{([^{}]*)\}/g,`$1`).replace(/\\frac\{([^{}]*)\}\{([^{}]*)\}/g,`($1)/($2)`).replace(/\\sqrt\{([^{}]*)\}/g,`√($1)`).replace(/\\[,;:! ]/g,` `).replace(/\\([A-Za-z]+)/g,(e,t)=>n.get(t)??t),f=e=>{let t=e.replace(/^[{(]\s*/,``).replace(/\s*[})]$/,``).trim().replace(/\u2212/g,`-`),n=``;return t.startsWith(`-`)?(n=`-`,t=t.slice(1)):t.startsWith(`+`)&&(t=t.slice(1)),t=t.replace(/^0+(?=\d)/,``),t===`0`?`0`:n+t},p=t=>{if(!Number.isFinite(t))return[{kind:`text`,text:String(t)}];if(t===0)return[{kind:`text`,text:`0`}];if(t<0)return[{kind:`text`,text:`-`},...p(-t)];let n=Math.floor(Math.log10(t)),r=t/10**n;Number(r.toFixed(2))>=10&&(r/=10,n+=1);let i=Math.abs(r-Math.round(r))<1e-9?String(Math.round(r)):String(Number(r.toFixed(2)));return n===0?[{kind:`text`,text:i}]:[{kind:`text`,text:`${i} ${e} 10`},{kind:`sup`,text:String(n)}]},m=(e,t)=>{let n=t.replace(/[{}]/g,``);n!==``&&e.push({kind:`text`,text:n})},h=e=>{let t=[],n=0;for(let r of e.matchAll(a)){let{index:i}=r,[,a,o]=r;if(i===void 0||a===void 0||o===void 0)throw Error(`figure script match is incomplete in "${e}"`);m(t,e.slice(n,i));let s=o.startsWith(`{`)?o.slice(1,-1):o;t.push({kind:a===`_`?`sub`:`sup`,text:s}),n=i+r[0].length}return m(t,e.slice(n)),t},g=t=>{let n=[],r=0;for(let i of t.matchAll(u)){let a=i.index??0;a>r&&n.push({kind:`text`,text:t.slice(r,a)});let o=i.groups??{};o.tensMantissa===void 0?o.powExp===void 0?o.etoken===void 0?(n.push({kind:`text`,text:o.symLetter??``}),n.push({kind:`sub`,text:o.symSub??``}),o.symPrime!==void 0&&n.push({kind:`text`,text:`'`})):n.push(...p(Number(o.etoken.replace(/\u2212/g,`-`)))):(n.push({kind:`text`,text:`10`}),n.push({kind:`sup`,text:f(o.powExp)})):(n.push({kind:`text`,text:`${o.tensMantissa} ${e} 10`}),n.push({kind:`sup`,text:f(o.tensExp??``)})),r=a+i[0].length}return r<t.length&&n.push({kind:`text`,text:t.slice(r)}),n},_=e=>{let t=[],n=0;for(let r of e.matchAll(i)){let i=r.index??0;t.push(...g(e.slice(n,i))),t.push({kind:`text`,text:r[0]}),n=i+r[0].length}return t.push(...g(e.slice(n))),t},v=e=>{let t=[];for(let n of e){if(n.text===``)continue;let e=t.
|
|
1
|
+
var e=`×`,t=`[-+\\u2212]?\\d{1,3}`,n=/* @__PURE__ */ new Map([[`times`,e],[`cdot`,`·`],[`sum`,`∑`],[`leq`,`≤`],[`le`,`≤`],[`geq`,`≥`],[`ge`,`≥`],[`neq`,`≠`],[`approx`,`≈`],[`pm`,`±`],[`rightarrow`,`→`],[`to`,`→`],[`alpha`,`α`],[`beta`,`β`],[`gamma`,`γ`],[`delta`,`δ`],[`lambda`,`λ`],[`mu`,`μ`],[`pi`,`π`],[`rho`,`ρ`],[`sigma`,`σ`],[`tau`,`τ`],[`Delta`,`Δ`],[`Omega`,`Ω`]]),r=/\\\((.*?)\\\)|\\\[(.*?)\\\]|\$\$(.*?)\$\$/gs,i=/`[^`]+`/g,a=/([_^])(\{[^}]*\}|[A-Za-z0-9])/g,o=e=>`(?<${e}>\\{\\s*${t}\\s*\\}|\\(\\s*${t}\\s*\\)|${t})`,s=`(?<tensMantissa>\\d+(?:\\.\\d+)?) *[xX*] *10 ?\\^ ?${o(`tensExp`)}`,c=`\\b10 ?\\^ ?${o(`powExp`)}`,l=`(?<![A-Za-z0-9_.#-])(?<etoken>\\d+(?:\\.\\d+)?[eE]${t})(?![A-Za-z0-9_.-])`,u=RegExp(`${s}|${c}|${l}|(?<![A-Za-z0-9_])(?<symLetter>[A-Za-z])_(?<symSub>[A-Za-z0-9]+)(?<symPrime>')?(?![A-Za-z0-9_])`,`g`),d=e=>e.replace(/\\(?:left|right)\b/g,``).replace(/\\(?:text|mathrm|mathbf|mathit|operatorname)\{([^{}]*)\}/g,`$1`).replace(/\\frac\{([^{}]*)\}\{([^{}]*)\}/g,`($1)/($2)`).replace(/\\sqrt\{([^{}]*)\}/g,`√($1)`).replace(/\\[,;:! ]/g,` `).replace(/\\([A-Za-z]+)/g,(e,t)=>n.get(t)??t),f=e=>{let t=e.replace(/^[{(]\s*/,``).replace(/\s*[})]$/,``).trim().replace(/\u2212/g,`-`),n=``;return t.startsWith(`-`)?(n=`-`,t=t.slice(1)):t.startsWith(`+`)&&(t=t.slice(1)),t=t.replace(/^0+(?=\d)/,``),t===`0`?`0`:n+t},p=t=>{if(!Number.isFinite(t))return[{kind:`text`,text:String(t)}];if(t===0)return[{kind:`text`,text:`0`}];if(t<0)return[{kind:`text`,text:`-`},...p(-t)];let n=Math.floor(Math.log10(t)),r=t/10**n;Number(r.toFixed(2))>=10&&(r/=10,n+=1);let i=Math.abs(r-Math.round(r))<1e-9?String(Math.round(r)):String(Number(r.toFixed(2)));return n===0?[{kind:`text`,text:i}]:[{kind:`text`,text:`${i} ${e} 10`},{kind:`sup`,text:String(n)}]},m=(e,t)=>{let n=t.replace(/[{}]/g,``);n!==``&&e.push({kind:`text`,text:n})},h=e=>{let t=[],n=0;for(let r of e.matchAll(a)){let{index:i}=r,[,a,o]=r;if(i===void 0||a===void 0||o===void 0)throw Error(`figure script match is incomplete in "${e}"`);m(t,e.slice(n,i));let s=o.startsWith(`{`)?o.slice(1,-1):o;t.push({kind:a===`_`?`sub`:`sup`,text:s}),n=i+r[0].length}return m(t,e.slice(n)),t},g=t=>{let n=[],r=0;for(let i of t.matchAll(u)){let a=i.index??0;a>r&&n.push({kind:`text`,text:t.slice(r,a)});let o=i.groups??{};o.tensMantissa===void 0?o.powExp===void 0?o.etoken===void 0?(n.push({kind:`text`,text:o.symLetter??``}),n.push({kind:`sub`,text:o.symSub??``}),o.symPrime!==void 0&&n.push({kind:`text`,text:`'`})):n.push(...p(Number(o.etoken.replace(/\u2212/g,`-`)))):(n.push({kind:`text`,text:`10`}),n.push({kind:`sup`,text:f(o.powExp)})):(n.push({kind:`text`,text:`${o.tensMantissa} ${e} 10`}),n.push({kind:`sup`,text:f(o.tensExp??``)})),r=a+i[0].length}return r<t.length&&n.push({kind:`text`,text:t.slice(r)}),n},_=e=>{let t=[],n=0;for(let r of e.matchAll(i)){let i=r.index??0;t.push(...g(e.slice(n,i))),t.push({kind:`text`,text:r[0]}),n=i+r[0].length}return t.push(...g(e.slice(n))),t},v=e=>{let t=[];for(let n of e){if(n.text===``)continue;let e=t[t.length-1];n.kind===`text`&&e?.kind===`text`?t[t.length-1]={kind:`text`,text:e.text+n.text}:t.push(n)}return t};function y(e){if(typeof e!=`string`||e===``)return[];let t=[],n=0;for(let i of e.matchAll(r)){let r=i.index??0;t.push(..._(e.slice(n,r)));let a=i[1]??i[2]??i[3]??``;t.push(...h(d(a))),n=r+i[0].length}return t.push(..._(e.slice(n))),v(t)}function b(e){return y(e).map(e=>e.kind===`sup`?`^${e.text}`:e.text).join(``)}function x(e){return Number.isFinite(e)&&e!==0&&Math.abs(e)<.001?p(e):Number.isFinite(e)?[{kind:`text`,text:new Intl.NumberFormat(`en-IN`,{maximumFractionDigits:10}).format(e)}]:[{kind:`text`,text:String(e)}]}export{x as formatFigure,y as toFigureRuns,b as toFigureText};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/chat-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.152.0",
|
|
4
4
|
"description": "The headless Webority Chat engine: the client over the chat routes, the session state machine over message parts, the stream reader, profile resolution with screen narrowing, the default English labels and a fixture client for sandboxes and tests. No DOM and no UI.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@webority/markdown-core": "^0.174.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@webority/markdown-core": "0.174.
|
|
32
|
+
"@webority/markdown-core": "0.174.1",
|
|
33
33
|
"typescript": "^7.0.2",
|
|
34
34
|
"vite": "^8.1.6",
|
|
35
35
|
"vitest": "5.1.0"
|