@monowind/ascii 0.2.8 → 0.2.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/README.md +2 -1
- package/dist/cdn.js +2 -2
- package/dist/cdn.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/render.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -80,7 +80,8 @@ below.
|
|
|
80
80
|
redistribute (zipped fonts must be extracted first). SGR color
|
|
81
81
|
escapes in fonts render as per-cell color, with the ANSI-16 palette
|
|
82
82
|
mapped to `--mw-ansi-*` (override the tokens to retheme).
|
|
83
|
-
- Content is a single line of text
|
|
83
|
+
- Content is a single line of text: spaces, tabs, and newlines fold
|
|
84
|
+
to one space, so a run of ` ` is the way to widen a gap. Element
|
|
84
85
|
children are ignored (with a warning).
|
|
85
86
|
|
|
86
87
|
## Bundled fonts
|
package/dist/cdn.js
CHANGED
|
@@ -30155,7 +30155,7 @@ 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=`<style>
|
|
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===`\xA0`?32: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=`<style>
|
|
30159
30159
|
:host { display: block; }
|
|
30160
30160
|
#mirror { margin: 0; font: inherit; line-height: inherit; letter-spacing: inherit; white-space: pre; color: transparent; }
|
|
30161
30161
|
/* The engine paints a selection on its grid (specs/wide-characters.md);
|
|
@@ -30163,5 +30163,5 @@ of new full-width/kern/smush alternatives, but default output is NOT changed.
|
|
|
30163
30163
|
#mirror::selection { color: transparent; text-shadow: none; background: transparent; }
|
|
30164
30164
|
.alt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; user-select: none; -webkit-user-select: none; }
|
|
30165
30165
|
</style><pre id="mirror" aria-hidden="true"></pre><span class="alt"><slot></slot></span>`,j=class extends k{#e=null;#t=null;constructor(){super();let e=this.attachShadow({mode:`open`});e.innerHTML=A,this.#t=e.getElementById(`mirror`)}get font(){return this.#e}set font(t){this.#e=t,(0,e.invalidateLeaves)()}syncMirror(e){let t=e.join(`
|
|
30166
|
-
`);this.#t&&this.#t.textContent!==t&&(this.#t.textContent=t)}};function M(e){let t=N(e);return e.syncMirror?.(t.lines),t}function N(e){let t=(e.textContent??``).replace(
|
|
30166
|
+
`);this.#t&&this.#t.textContent!==t&&(this.#t.textContent=t)}};function M(e){let t=N(e);return e.syncMirror?.(t.lines),t}function N(e){let t=(e.textContent??``).replace(/[ \t\r\n\f]+/g,` `).replace(/^ | $/g,``);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 P(){typeof customElements>`u`||customElements.get(`mono-ascii`)||(customElements.define(`mono-ascii`,j),(0,e.registerLeafRenderer)({tag:`mono-ascii`,observedAttributes:[`font`,`effect`],render:M,selectionTarget:e=>e.shadowRoot?.getElementById(`mirror`)??null}))}P();var F=`@layer base{mono-ascii{display:block}}`,I=document.createElement(`style`);I.setAttribute(`data-monowind-ascii`,``),I.textContent=F,document.head.appendChild(I);var L=new Map;function R(e){let t=e.toLowerCase().replace(/\.(flf|tlf)$/,``),n=L.get(t);if(n)return n;let r=z(t).finally(()=>L.delete(t));return L.set(t,r),r}async function z(e){let t=m(e);if(t)return t;for(let t of[`fonts/`,`https://cdn.jsdelivr.net/npm/@monowind/ascii@0.2.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 R(e));var B=globalThis.monowind;Object.assign(globalThis,{monowind:{...B,ascii:{...B?.ascii,asciiFont:m,loadFont:R,registerAsciiFont:p,version:`0.2.10`}}})})(monowind);
|
|
30167
30167
|
//# sourceMappingURL=cdn.js.map
|