@monowind/ascii 0.1.9 → 0.1.10
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/cdn.js +1 -1
- package/dist/cdn.js.map +1 -1
- package/package.json +3 -3
- package/src/styles.css +4 -5
package/dist/cdn.js
CHANGED
|
@@ -30155,5 +30155,5 @@ of new full-width/kern/smush alternatives, but default output is NOT changed.
|
|
|
30155
30155
|
███▀▄██@
|
|
30156
30156
|
▀█▀▄███@
|
|
30157
30157
|
@@
|
|
30158
|
-
`);function h(e,t){let n=Array.from({length:t.height},()=>({chars:[],paints:[]})),r={lines:Array.from({length:t.height},()=>` `),width:1},i=!0;for(let a of e){let e=t.glyphs.get(a.codePointAt(0))??r;_(n,e,i?0:g(n,e,t),t),i=!1}return{lines:n.map(e=>e.chars.map(e=>e===t.hardblank?` `:e).join(``)),runs:y(n)}}function g(e,t,n){if(n.layout===`full`)return 0;let r=1/0;for(let i=0;i<e.length;i++){let a=e[i].chars,o=t.lines[i]??``,s=0;for(;s<a.length&&a[a.length-1-s]===` `;)s++;let c=0;for(;c<o.length&&o.charAt(c)===` `;)c++;let l=s+c;if(n.layout!==`kerning`){let e=a[a.length-1-s],t=o.charAt(c);e!==void 0&&t!==``&&v(e,t,n)!==null&&l++}r=Math.min(r,l)}return Number.isFinite(r)?r:0}function _(e,t,n,r){for(let i=0;i<e.length;i++){let a=e[i],o=t.lines[i]??``,s=t.colors?.[i],c=Math.min(n,a.chars.length,o.length),l=a.chars.length-c;for(let e=0;e<c;e++){let t=a.chars[l+e],n=o.charAt(e),i=a.paints[l+e],c=s?.[e];if(t===` `)a.chars[l+e]=n,a.paints[l+e]=n===` `?i:c;else if(n!==` `){let o=v(t,n,r);a.chars[l+e]=o??n,a.paints[l+e]=o===t?i:c}}for(let e=c;e<o.length;e++)a.chars.push(o.charAt(e)),a.paints.push(s?.[e])}}function v(e,t,n){if(e===` `)return t;if(t===` `)return e;let{hardblank:r}=n;if(n.layout===`smush-universal`)return e===r||t===r?null:t;let i=n.rules;if(e===r||t===r)return i&32&&e===r&&t===r?r:null;if(i&1&&e===t)return e;if(i&2){if(e===`_`&&`|/\\[]{}()<>`.includes(t))return t;if(t===`_`&&`|/\\[]{}()<>`.includes(e))return e}if(i&4){let n=e=>e===`|`?1:`/\\`.includes(e)?2:`[]`.includes(e)?3:`{}`.includes(e)?4:`()`.includes(e)?5:`<>`.includes(e)?6:0,r=n(e),i=n(t);if(r&&i&&r!==i)return r>i?e:t}if(i&8&&[`[]`,`][`,`{}`,`}{`,`()`,`)(`].includes(e+t))return`|`;if(i&16){if(e===`/`&&t===`\\`)return`|`;if(e===`\\`&&t===`/`)return`Y`;if(e===`>`&&t===`<`)return`X`}return null}function y(e){let t=[];return e.forEach((e,n)=>{let r=-1,i,a=e=>{r>=0&&i&&t.push({line:n,start:r,end:e,paint:b(i)}),r=-1,i=void 0};e.paints.forEach((e,t)=>{x(e,i)||(a(t),e&&(r=t,i=e))}),a(e.paints.length)}),t}function b(e){let t={};return e.color&&(t.color=e.color),e.backgroundColor&&(t.backgroundColor=e.backgroundColor),e.bold&&(t.fontWeight=`bold`),t}function x(e,t){return e===t?!0:!e||!t?!1:e.color===t.color&&e.backgroundColor===t.backgroundColor&&e.bold===t.bold}var S={rainbow:[`red`,`yellow`,`green`,`cyan`,`blue`,`magenta`],metal:[`bright-white`,`white`,`bright-cyan`,`bright-blue`,`blue`]};function C(e){return e in S}function w(e,t){let n=S[e],r=e=>`var(--mw-ansi-${n[e%n.length]})`,i=[];return e===`metal`?(t.forEach((e,a)=>{e.length>0&&i.push({line:a,start:0,end:e.length,paint:{color:r(Math.floor(a*n.length/Math.max(1,t.length)))}})}),i):(t.forEach((e,t)=>{for(let n=0;n<e.length;n+=2)i.push({line:t,start:n,end:Math.min(e.length,n+2),paint:{color:r(Math.floor(n/2))}})}),i)}var T=new Set,E=new WeakSet,D=null;function O(e){D=e}var k=typeof HTMLElement>`u`?class{}:HTMLElement,A=class extends k{#e=null;get font(){return this.#e}set font(t){this.#e=t,(0,e.invalidateLeaves)()}};function j(e){let t=(e.textContent??``).replace(/\s+/g,` `).trim();e.children.length>0&&!E.has(e)&&(E.add(e),console.warn(`[monowind] <mono-ascii> takes text only; element children are ignored.`,e));let n=e.getAttribute(`font`)??`standard`,r=e.font??m(n);if(!r)return T.has(`font:${n}`)||(T.add(`font:${n}`),D?D(n):console.warn(`[monowind] <mono-ascii>: no registered font "${n}"; rendering plain text.`,e)),{lines:t?[t]:[]};if(!t)return{lines:[]};let i=h(t,r),a=e.getAttribute(`effect`);return a&&C(a)?{lines:i.lines,runs:w(a,i.lines)}:{lines:i.lines,runs:i.runs}}function M(){typeof customElements>`u`||customElements.get(`mono-ascii`)||(customElements.define(`mono-ascii`,A),(0,e.registerLeafRenderer)({tag:`mono-ascii`,observedAttributes:[`font`,`effect`],render:j}))}M();var N=`@layer base{mono-ascii{
|
|
30158
|
+
`);function h(e,t){let n=Array.from({length:t.height},()=>({chars:[],paints:[]})),r={lines:Array.from({length:t.height},()=>` `),width:1},i=!0;for(let a of e){let e=t.glyphs.get(a.codePointAt(0))??r;_(n,e,i?0:g(n,e,t),t),i=!1}return{lines:n.map(e=>e.chars.map(e=>e===t.hardblank?` `:e).join(``)),runs:y(n)}}function g(e,t,n){if(n.layout===`full`)return 0;let r=1/0;for(let i=0;i<e.length;i++){let a=e[i].chars,o=t.lines[i]??``,s=0;for(;s<a.length&&a[a.length-1-s]===` `;)s++;let c=0;for(;c<o.length&&o.charAt(c)===` `;)c++;let l=s+c;if(n.layout!==`kerning`){let e=a[a.length-1-s],t=o.charAt(c);e!==void 0&&t!==``&&v(e,t,n)!==null&&l++}r=Math.min(r,l)}return Number.isFinite(r)?r:0}function _(e,t,n,r){for(let i=0;i<e.length;i++){let a=e[i],o=t.lines[i]??``,s=t.colors?.[i],c=Math.min(n,a.chars.length,o.length),l=a.chars.length-c;for(let e=0;e<c;e++){let t=a.chars[l+e],n=o.charAt(e),i=a.paints[l+e],c=s?.[e];if(t===` `)a.chars[l+e]=n,a.paints[l+e]=n===` `?i:c;else if(n!==` `){let o=v(t,n,r);a.chars[l+e]=o??n,a.paints[l+e]=o===t?i:c}}for(let e=c;e<o.length;e++)a.chars.push(o.charAt(e)),a.paints.push(s?.[e])}}function v(e,t,n){if(e===` `)return t;if(t===` `)return e;let{hardblank:r}=n;if(n.layout===`smush-universal`)return e===r||t===r?null:t;let i=n.rules;if(e===r||t===r)return i&32&&e===r&&t===r?r:null;if(i&1&&e===t)return e;if(i&2){if(e===`_`&&`|/\\[]{}()<>`.includes(t))return t;if(t===`_`&&`|/\\[]{}()<>`.includes(e))return e}if(i&4){let n=e=>e===`|`?1:`/\\`.includes(e)?2:`[]`.includes(e)?3:`{}`.includes(e)?4:`()`.includes(e)?5:`<>`.includes(e)?6:0,r=n(e),i=n(t);if(r&&i&&r!==i)return r>i?e:t}if(i&8&&[`[]`,`][`,`{}`,`}{`,`()`,`)(`].includes(e+t))return`|`;if(i&16){if(e===`/`&&t===`\\`)return`|`;if(e===`\\`&&t===`/`)return`Y`;if(e===`>`&&t===`<`)return`X`}return null}function y(e){let t=[];return e.forEach((e,n)=>{let r=-1,i,a=e=>{r>=0&&i&&t.push({line:n,start:r,end:e,paint:b(i)}),r=-1,i=void 0};e.paints.forEach((e,t)=>{x(e,i)||(a(t),e&&(r=t,i=e))}),a(e.paints.length)}),t}function b(e){let t={};return e.color&&(t.color=e.color),e.backgroundColor&&(t.backgroundColor=e.backgroundColor),e.bold&&(t.fontWeight=`bold`),t}function x(e,t){return e===t?!0:!e||!t?!1:e.color===t.color&&e.backgroundColor===t.backgroundColor&&e.bold===t.bold}var S={rainbow:[`red`,`yellow`,`green`,`cyan`,`blue`,`magenta`],metal:[`bright-white`,`white`,`bright-cyan`,`bright-blue`,`blue`]};function C(e){return e in S}function w(e,t){let n=S[e],r=e=>`var(--mw-ansi-${n[e%n.length]})`,i=[];return e===`metal`?(t.forEach((e,a)=>{e.length>0&&i.push({line:a,start:0,end:e.length,paint:{color:r(Math.floor(a*n.length/Math.max(1,t.length)))}})}),i):(t.forEach((e,t)=>{for(let n=0;n<e.length;n+=2)i.push({line:t,start:n,end:Math.min(e.length,n+2),paint:{color:r(Math.floor(n/2))}})}),i)}var T=new Set,E=new WeakSet,D=null;function O(e){D=e}var k=typeof HTMLElement>`u`?class{}:HTMLElement,A=class extends k{#e=null;get font(){return this.#e}set font(t){this.#e=t,(0,e.invalidateLeaves)()}};function j(e){let t=(e.textContent??``).replace(/\s+/g,` `).trim();e.children.length>0&&!E.has(e)&&(E.add(e),console.warn(`[monowind] <mono-ascii> takes text only; element children are ignored.`,e));let n=e.getAttribute(`font`)??`standard`,r=e.font??m(n);if(!r)return T.has(`font:${n}`)||(T.add(`font:${n}`),D?D(n):console.warn(`[monowind] <mono-ascii>: no registered font "${n}"; rendering plain text.`,e)),{lines:t?[t]:[]};if(!t)return{lines:[]};let i=h(t,r),a=e.getAttribute(`effect`);return a&&C(a)?{lines:i.lines,runs:w(a,i.lines)}:{lines:i.lines,runs:i.runs}}function M(){typeof customElements>`u`||customElements.get(`mono-ascii`)||(customElements.define(`mono-ascii`,A),(0,e.registerLeafRenderer)({tag:`mono-ascii`,observedAttributes:[`font`,`effect`],render:j}))}M();var N=`@layer base{mono-ascii{display:block}mono-wind{--mw-ansi-black:#000;--mw-ansi-red:#cd3131;--mw-ansi-green:#0dbc79;--mw-ansi-yellow:#e5e510;--mw-ansi-blue:#2472c8;--mw-ansi-magenta:#bc3fbc;--mw-ansi-cyan:#11a8cd;--mw-ansi-white:#e5e5e5;--mw-ansi-bright-black:#666;--mw-ansi-bright-red:#f14c4c;--mw-ansi-bright-green:#23d18b;--mw-ansi-bright-yellow:#f5f543;--mw-ansi-bright-blue:#3b8eea;--mw-ansi-bright-magenta:#d670d6;--mw-ansi-bright-cyan:#29b8db;--mw-ansi-bright-white:#fff}}`,P=document.createElement(`style`);P.setAttribute(`data-monowind-ascii`,``),P.textContent=N,document.head.appendChild(P);var F=new Map;function I(e){let t=e.toLowerCase().replace(/\.(flf|tlf)$/,``),n=F.get(t);if(n)return n;let r=L(t).finally(()=>F.delete(t));return F.set(t,r),r}async function L(e){let t=m(e);if(t)return t;for(let t of[`fonts/`,`https://cdn.jsdelivr.net/npm/@monowind/ascii@0.1.10/fonts/`])for(let n of[`flf`,`tlf`])try{let r=await fetch(`${t}${e}.${n}`);if(r.ok)return p(e,await r.text())}catch{}return console.warn(`[monowind] loadFont("${e}"): no such bundled font.`),null}O(e=>void I(e));var R=globalThis.monowind;Object.assign(globalThis,{monowind:{...R,ascii:{...R?.ascii,asciiFont:m,loadFont:I,registerAsciiFont:p,version:`0.1.10`}}})})(monowind);
|
|
30159
30159
|
//# sourceMappingURL=cdn.js.map
|