bitwrench 2.0.8 → 2.0.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.
@@ -1,4 +1,4 @@
1
- /*! bitwrench v2.0.8 | BSD-2-Clause | http://deftio.com/bitwrench */
1
+ /*! bitwrench v2.0.10 | BSD-2-Clause | http://deftio.com/bitwrench */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,4 +1,4 @@
1
- /*! bitwrench v2.0.8 | BSD-2-Clause | http://deftio.com/bitwrench */
1
+ /*! bitwrench v2.0.10 | BSD-2-Clause | http://deftio.com/bitwrench */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
4
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -1,5 +1,5 @@
1
- /*! bitwrench v2.0.8 | BSD-2-Clause | http://deftio.com/bitwrench */
2
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).bwCodeEdit={})}(this,(function(e){"use strict";
1
+ /*! bitwrench v2.0.10 | BSD-2-Clause | http://deftio.com/bitwrench */
2
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).bwCodeEdit={})}(this,function(e){"use strict";
3
3
  /**
4
4
  * bitwrench-code-edit.js - syntax-highlighted contenteditable code editor addon
5
5
  *
@@ -11,5 +11,5 @@
11
11
  *
12
12
  * @module bitwrench-code-edit
13
13
  * @license BSD-2-Clause
14
- */var t=!1,o='.bw-ce{background:#1e293b;border-radius:6px;border:1px solid rgba(255,255,255,0.08);overflow:auto}.bw-ce pre{margin:0;padding:0}.bw-ce code{font-family:"SF Mono",Monaco,"Cascadia Code",Consolas,monospace;font-size:0.875rem;line-height:1.6;color:#e2e8f0;outline:none;white-space:pre-wrap;display:block;padding:0.75rem 1rem}.bw-ce code:empty::before{content:"\\200b"}.bw-ce .bw-ce-keyword{color:#c792ea}.bw-ce .bw-ce-string{color:#c3e88d}.bw-ce .bw-ce-comment{color:#546e7a;font-style:italic}.bw-ce .bw-ce-number{color:#f78c6c}.bw-ce .bw-ce-operator{color:#89ddff}.bw-ce .bw-ce-punctuation{color:#89ddff}.bw-ce .bw-ce-property{color:#82aaff}.bw-ce .bw-ce-function{color:#82aaff}.bw-ce .bw-ce-tag{color:#f07178}.bw-ce .bw-ce-attr-name{color:#ffcb6b}.bw-ce .bw-ce-attr-value{color:#c3e88d}.bw-ce .bw-ce-selector{color:#c792ea}.bw-ce .bw-ce-css-prop{color:#82aaff}.bw-ce .bw-ce-css-value{color:#f78c6c}.bw-ce .bw-ce-at-rule{color:#c792ea;font-style:italic}.bw-ce .bw-ce-color{color:#f78c6c}.bw-ce .bw-ce-template-interp{color:#89ddff}.bw-ce-light.bw-ce{background:#fafafa;border-color:#d8d8d8}.bw-ce-light.bw-ce code{color:#1a1a1a}.bw-ce-light.bw-ce .bw-ce-keyword{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-string{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-comment{color:#9ca3af;font-style:italic}.bw-ce-light.bw-ce .bw-ce-number{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-operator{color:#0891b2}.bw-ce-light.bw-ce .bw-ce-punctuation{color:#6b7280}.bw-ce-light.bw-ce .bw-ce-property{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-function{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-tag{color:#dc2626}.bw-ce-light.bw-ce .bw-ce-attr-name{color:#d97706}.bw-ce-light.bw-ce .bw-ce-attr-value{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-selector{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-css-prop{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-css-value{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-at-rule{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-color{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-template-interp{color:#0891b2}';var c={};function r(e){var t=[],o=0,n=e.length,a="";function l(e){a.length&&(t.push({type:e,text:a}),a="")}for(;o<n;){var i=e[o],s=e[o+1];if("/"!==i||"/"!==s)if("/"!==i||"*"!==s){if("/"===i&&"/"!==s&&"*"!==s){var p=t.length?t[t.length-1]:null,u=!1;if(a.trim().length||p&&"operator"!==p.type&&"punctuation"!==p.type&&"keyword"!==p.type||(u=!0),u){l("plain");for(var f="/",b=o+1,w=!1,d=!1;b<n;){var h=e[b];if(w)f+=h,w=!1,b++;else if("\\"!==h)if("["!==h)if("]"!==h){if("/"===h&&!d){f+=h,b++;break}if("\n"===h)break;f+=h,b++}else d=!1,f+=h,b++;else d=!0,f+=h,b++;else w=!0,f+=h,b++}for(;b<n&&/[gimsuvy]/.test(e[b]);)f+=e[b],b++;t.push({type:"string",text:f}),o=b;continue}}if('"'!==i&&"'"!==i&&"`"!==i)if(/[0-9]/.test(i)||"."===i&&s&&/[0-9]/.test(s)){l("plain");var g="";if("0"===i&&s&&/[xXbBoO]/.test(s))for(g=i+s,o+=2;o<n&&/[0-9a-fA-F_]/.test(e[o]);)g+=e[o],o++;else for(;o<n&&/[0-9._eE]/.test(e[o]);)"e"!==e[o]&&"E"!==e[o]||!e[o+1]||!/[+\-0-9]/.test(e[o+1])?(g+=e[o],o++):(g+=e[o]+e[o+1],o+=2);t.push({type:"number",text:g})}else if(/[a-zA-Z_$]/.test(i)){l("plain");for(var v="";o<n&&/[a-zA-Z0-9_$]/.test(e[o]);)v+=e[o],o++;for(var y=o;y<n&&(" "===e[y]||"\t"===e[y]);)y++;var x=t.length?t[t.length-1]:null,m=x&&"punctuation"===x.type&&"."===x.text;c[v]?t.push({type:"keyword",text:v}):m?y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"property",text:v}):y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"plain",text:v})}else if(-1==="=+-*/%!<>&|^~?:".indexOf(i))-1==="(){}[];,.".indexOf(i)?(a+=i,o++):(l("plain"),t.push({type:"punctuation",text:i}),o++);else{l("plain");var k=i;++o<n&&-1!=="=+-*/%!<>&|^~?:".indexOf(e[o])&&(k+=e[o],++o<n&&-1!=="=>&|".indexOf(e[o])&&(k+=e[o],o++)),t.push({type:"operator",text:k})}else{l("plain");var C=i,S=i,T=o+1;if("`"===C){for(;T<n;){var A=e[T];if("\\"!==A)if("$"!==A||"{"!==e[T+1]){if("`"===A){S+=A,T++;break}S+=A,T++}else{S.length&&t.push({type:"string",text:S}),S="",t.push({type:"template-interp",text:"${"}),T+=2;for(var E=1,O="";T<n&&E>0;){if("{"===e[T])E++;else if("}"===e[T]&&0===--E)break;O+=e[T],T++}var z=r(O);(t=t.concat(z)).push({type:"template-interp",text:"}"}),T++}else S+=A+(e[T+1]||""),T+=2}S.length&&t.push({type:"string",text:S})}else{for(;T<n;){var _=e[T];if("\\"!==_){if(_===C){S+=_,T++;break}if("\n"===_)break;S+=_,T++}else S+=_+(e[T+1]||""),T+=2}t.push({type:"string",text:S})}o=T}}else{l("plain");var R=e.indexOf("*/",o+2);-1===R&&(R=n-2),t.push({type:"comment",text:e.substring(o,R+2)}),o=R+2}else{l("plain");var Z=e.indexOf("\n",o);-1===Z&&(Z=n),t.push({type:"comment",text:e.substring(o,Z)}),o=Z}}return l("plain"),t}function n(e){var t=[],o=0,c=e.length,r="selector",n="";function a(e){n.length&&(t.push({type:e||"plain",text:n}),n="")}for(;o<c;){var l=e[o],i=e[o+1];if("/"!==l||"*"!==i)if('"'!==l&&"'"!==l||"value"!==r&&"selector"!==r)if("@"!==l||"selector"!==r)if("#"!==l||"value"!==r)if("value"===r&&/[0-9]/.test(l)){a("css-value");for(var s="";o<c&&/[0-9.]/.test(e[o]);)s+=e[o],o++;for(var p="";o<c&&/[a-zA-Z%]/.test(e[o]);)p+=e[o],o++;t.push({type:"number",text:s+p})}else"{"!==l?"}"!==l?":"!==l||"prop"!==r?";"!==l?","!==l?(n+=l,o++):(a("selector"===r?"selector":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),o++):(a("value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="prop",o++):(a("css-prop"),t.push({type:"punctuation",text:l}),r="value",o++):(a("prop"===r?"css-prop":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="selector",o++):(a("selector"===r?"selector":"plain"),t.push({type:"punctuation",text:l}),r="prop",o++);else{a("css-value");var u="#";for(o++;o<c&&/[0-9a-fA-F]/.test(e[o]);)u+=e[o],o++;t.push({type:"color",text:u})}else{a("selector");var f="@";for(o++;o<c&&/[a-zA-Z\-]/.test(e[o]);)f+=e[o],o++;t.push({type:"at-rule",text:f})}else{a("selector"===r?"selector":"css-value");var b=l,w=l;for(o++;o<c;)if("\\"!==e[o]){if(e[o]===b){w+=e[o],o++;break}w+=e[o],o++}else w+=e[o]+(e[o+1]||""),o+=2;t.push({type:"string",text:w})}else{a("selector"===r?"selector":"prop"===r?"css-prop":"css-value");var d=e.indexOf("*/",o+2);-1===d&&(d=c-2),t.push({type:"comment",text:e.substring(o,d+2)}),o=d+2}}return a("selector"===r?"selector":"prop"===r?"css-prop":"css-value"),t}function a(e){var t=[],o=0,c=e.length,r="";function n(e){r.length&&(t.push({type:e,text:r}),r="")}for(;o<c;){var a=e[o];if("<"!==a||"\x3c!--"!==e.substring(o,o+4))if("<"!==a)if("&"!==a)r+=a,o++;else{n("plain");var l="&";for(o++;o<c&&";"!==e[o]&&/[a-zA-Z0-9#]/.test(e[o]);)l+=e[o],o++;o<c&&";"===e[o]&&(l+=";",o++),t.push({type:"string",text:l})}else{n("plain");var i="<";for(++o<c&&"/"===e[o]&&(i+="/",o++);o<c&&/[a-zA-Z0-9\-]/.test(e[o]);)i+=e[o],o++;for(t.push({type:"tag",text:i});o<c&&">"!==e[o]&&("/"!==e[o]||">"!==e[o+1]);)if(/\s/.test(e[o])){for(var s="";o<c&&/\s/.test(e[o]);)s+=e[o],o++;t.push({type:"plain",text:s})}else if(/[a-zA-Z_\-@:]/.test(e[o])){for(var p="";o<c&&/[a-zA-Z0-9_\-@:]/.test(e[o]);)p+=e[o],o++;if(t.push({type:"attr-name",text:p}),o<c&&"="===e[o])if(t.push({type:"punctuation",text:"="}),++o<c&&('"'===e[o]||"'"===e[o])){var u=e[o],f=u;for(o++;o<c&&e[o]!==u;)f+=e[o],o++;o<c&&(f+=e[o],o++),t.push({type:"attr-value",text:f})}else{for(var b="";o<c&&!/[\s>]/.test(e[o]);)b+=e[o],o++;t.push({type:"attr-value",text:b})}}else r+=e[o],o++,n("plain");var w="";o<c&&"/"===e[o]&&(w+="/",o++),o<c&&">"===e[o]&&(w+=">",o++),w&&t.push({type:"tag",text:w})}else{n("plain");var d=e.indexOf("--\x3e",o+4);-1===d&&(d=c-3),t.push({type:"comment",text:e.substring(o,d+3)}),o=d+3}}return n("plain"),t}"var,const,let,function,return,if,else,for,while,do,switch,case,break,continue,new,typeof,instanceof,this,class,extends,import,export,default,from,true,false,null,undefined,try,catch,throw,finally,async,await,yield,of,in,delete,void,with,super,static,get,set,debugger".split(",").forEach((function(e){c[e]=!0}));var l={js:r,javascript:r,css:n,html:a};function i(e,t){return function(e){for(var t=[],o=0;o<e.length;o++){var c=e[o];"plain"===c.type?t.push(c.text):t.push({t:"span",a:{class:"bw-ce-"+c.type},c:c.text})}return t}((l[t]||r)(e))}function s(e){var t=(e=e||{}).code||"",o=e.lang||"js",c=e.height||"180px",r=!!e.readOnly,n="bw-ce"+(e.className?" "+e.className:""),a=i(t,o),l={spellcheck:"false",class:"bw-ce-code"};return r||(l.contenteditable="true"),{t:"div",a:{class:n,style:"max-height:"+c+";overflow:auto"},c:[{t:"pre",c:{t:"code",a:l,c:a}}],o:{mounted:function(c){var n=c.querySelector(".bw-ce-code");if(n){var a=t,l=null,s="undefined"!=typeof window&&window.bw||{};c._bwCodeEdit={getValue:p,setValue:function(e){a=e;var t=i(e,o);s.html&&(n.innerHTML=s.html({t:"span",c:t}))}},r||(n.addEventListener("input",(function(){clearTimeout(l),l=setTimeout(u,50)})),n.addEventListener("keydown",(function(e){"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," "))})))}function p(){return n.textContent||""}function u(){var t=p();if(t!==a){a=t;var c=function(e){var t=window.getSelection();if(!t.rangeCount)return 0;var o=t.getRangeAt(0).cloneRange();return o.selectNodeContents(e),o.setEnd(t.getRangeAt(0).startContainer,t.getRangeAt(0).startOffset),o.toString().length}(n),r=i(t,o);s.html&&(n.innerHTML=s.html({t:"span",c:r})),function(e,t){for(var o,c=window.getSelection(),r=document.createRange(),n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),a=0;o=n.nextNode();){var l=o.textContent.length;if(a+l>=t)return r.setStart(o,t-a),r.collapse(!0),c.removeAllRanges(),void c.addRange(r);a+=l}r.selectNodeContents(e),r.collapse(!1),c.removeAllRanges(),c.addRange(r)}(n,c),e.onChange&&e.onChange(t)}}}}}}function p(e){e&&(e.highlight=i,e.codeEditor=function(c){return function(e){t||(t=!0,e&&e.injectCSS&&e.injectCSS(o,{id:"bw-code-edit-styles"}))}(e),s(c)})}"undefined"!=typeof window&&window.bw&&p(window.bw);var u={highlight:i,codeEditor:s,install:p,CSS_TEXT:o};e.CSS_TEXT=o,e.codeEditor=s,e.default=u,e.highlight=i,e.install=p,e.tokenizeCSS=n,e.tokenizeHTML=a,e.tokenizeJS=r,Object.defineProperty(e,"__esModule",{value:!0})}));
14
+ */var t=!1,o='.bw-ce{background:#1e293b;border-radius:6px;border:1px solid rgba(255,255,255,0.08);overflow:auto}.bw-ce pre{margin:0;padding:0}.bw-ce code{font-family:"SF Mono",Monaco,"Cascadia Code",Consolas,monospace;font-size:0.875rem;line-height:1.6;color:#e2e8f0;outline:none;white-space:pre-wrap;display:block;padding:0.75rem 1rem}.bw-ce code:empty::before{content:"\\200b"}.bw-ce .bw-ce-keyword{color:#c792ea}.bw-ce .bw-ce-string{color:#c3e88d}.bw-ce .bw-ce-comment{color:#546e7a;font-style:italic}.bw-ce .bw-ce-number{color:#f78c6c}.bw-ce .bw-ce-operator{color:#89ddff}.bw-ce .bw-ce-punctuation{color:#89ddff}.bw-ce .bw-ce-property{color:#82aaff}.bw-ce .bw-ce-function{color:#82aaff}.bw-ce .bw-ce-tag{color:#f07178}.bw-ce .bw-ce-attr-name{color:#ffcb6b}.bw-ce .bw-ce-attr-value{color:#c3e88d}.bw-ce .bw-ce-selector{color:#c792ea}.bw-ce .bw-ce-css-prop{color:#82aaff}.bw-ce .bw-ce-css-value{color:#f78c6c}.bw-ce .bw-ce-at-rule{color:#c792ea;font-style:italic}.bw-ce .bw-ce-color{color:#f78c6c}.bw-ce .bw-ce-template-interp{color:#89ddff}.bw-ce-light.bw-ce{background:#fafafa;border-color:#d8d8d8}.bw-ce-light.bw-ce code{color:#1a1a1a}.bw-ce-light.bw-ce .bw-ce-keyword{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-string{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-comment{color:#9ca3af;font-style:italic}.bw-ce-light.bw-ce .bw-ce-number{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-operator{color:#0891b2}.bw-ce-light.bw-ce .bw-ce-punctuation{color:#6b7280}.bw-ce-light.bw-ce .bw-ce-property{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-function{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-tag{color:#dc2626}.bw-ce-light.bw-ce .bw-ce-attr-name{color:#d97706}.bw-ce-light.bw-ce .bw-ce-attr-value{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-selector{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-css-prop{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-css-value{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-at-rule{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-color{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-template-interp{color:#0891b2}';var c={};function r(e){var t=[],o=0,n=e.length,a="";function l(e){a.length&&(t.push({type:e,text:a}),a="")}for(;o<n;){var i=e[o],s=e[o+1];if("/"!==i||"/"!==s)if("/"!==i||"*"!==s){if("/"===i&&"/"!==s&&"*"!==s){var p=t.length?t[t.length-1]:null,u=!1;if(a.trim().length||p&&"operator"!==p.type&&"punctuation"!==p.type&&"keyword"!==p.type||(u=!0),u){l("plain");for(var f="/",b=o+1,w=!1,d=!1;b<n;){var h=e[b];if(w)f+=h,w=!1,b++;else if("\\"!==h)if("["!==h)if("]"!==h){if("/"===h&&!d){f+=h,b++;break}if("\n"===h)break;f+=h,b++}else d=!1,f+=h,b++;else d=!0,f+=h,b++;else w=!0,f+=h,b++}for(;b<n&&/[gimsuvy]/.test(e[b]);)f+=e[b],b++;t.push({type:"string",text:f}),o=b;continue}}if('"'!==i&&"'"!==i&&"`"!==i)if(/[0-9]/.test(i)||"."===i&&s&&/[0-9]/.test(s)){l("plain");var g="";if("0"===i&&s&&/[xXbBoO]/.test(s))for(g=i+s,o+=2;o<n&&/[0-9a-fA-F_]/.test(e[o]);)g+=e[o],o++;else for(;o<n&&/[0-9._eE]/.test(e[o]);)"e"!==e[o]&&"E"!==e[o]||!e[o+1]||!/[+\-0-9]/.test(e[o+1])?(g+=e[o],o++):(g+=e[o]+e[o+1],o+=2);t.push({type:"number",text:g})}else if(/[a-zA-Z_$]/.test(i)){l("plain");for(var v="";o<n&&/[a-zA-Z0-9_$]/.test(e[o]);)v+=e[o],o++;for(var y=o;y<n&&(" "===e[y]||"\t"===e[y]);)y++;var x=t.length?t[t.length-1]:null,m=x&&"punctuation"===x.type&&"."===x.text;c[v]?t.push({type:"keyword",text:v}):m?y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"property",text:v}):y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"plain",text:v})}else if(-1==="=+-*/%!<>&|^~?:".indexOf(i))-1==="(){}[];,.".indexOf(i)?(a+=i,o++):(l("plain"),t.push({type:"punctuation",text:i}),o++);else{l("plain");var k=i;++o<n&&-1!=="=+-*/%!<>&|^~?:".indexOf(e[o])&&(k+=e[o],++o<n&&-1!=="=>&|".indexOf(e[o])&&(k+=e[o],o++)),t.push({type:"operator",text:k})}else{l("plain");var C=i,S=i,T=o+1;if("`"===C){for(;T<n;){var A=e[T];if("\\"!==A)if("$"!==A||"{"!==e[T+1]){if("`"===A){S+=A,T++;break}S+=A,T++}else{S.length&&t.push({type:"string",text:S}),S="",t.push({type:"template-interp",text:"${"}),T+=2;for(var E=1,O="";T<n&&E>0;){if("{"===e[T])E++;else if("}"===e[T]&&0===--E)break;O+=e[T],T++}var z=r(O);(t=t.concat(z)).push({type:"template-interp",text:"}"}),T++}else S+=A+(e[T+1]||""),T+=2}S.length&&t.push({type:"string",text:S})}else{for(;T<n;){var _=e[T];if("\\"!==_){if(_===C){S+=_,T++;break}if("\n"===_)break;S+=_,T++}else S+=_+(e[T+1]||""),T+=2}t.push({type:"string",text:S})}o=T}}else{l("plain");var R=e.indexOf("*/",o+2);-1===R&&(R=n-2),t.push({type:"comment",text:e.substring(o,R+2)}),o=R+2}else{l("plain");var Z=e.indexOf("\n",o);-1===Z&&(Z=n),t.push({type:"comment",text:e.substring(o,Z)}),o=Z}}return l("plain"),t}function n(e){var t=[],o=0,c=e.length,r="selector",n="";function a(e){n.length&&(t.push({type:e||"plain",text:n}),n="")}for(;o<c;){var l=e[o],i=e[o+1];if("/"!==l||"*"!==i)if('"'!==l&&"'"!==l||"value"!==r&&"selector"!==r)if("@"!==l||"selector"!==r)if("#"!==l||"value"!==r)if("value"===r&&/[0-9]/.test(l)){a("css-value");for(var s="";o<c&&/[0-9.]/.test(e[o]);)s+=e[o],o++;for(var p="";o<c&&/[a-zA-Z%]/.test(e[o]);)p+=e[o],o++;t.push({type:"number",text:s+p})}else"{"!==l?"}"!==l?":"!==l||"prop"!==r?";"!==l?","!==l?(n+=l,o++):(a("selector"===r?"selector":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),o++):(a("value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="prop",o++):(a("css-prop"),t.push({type:"punctuation",text:l}),r="value",o++):(a("prop"===r?"css-prop":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="selector",o++):(a("selector"===r?"selector":"plain"),t.push({type:"punctuation",text:l}),r="prop",o++);else{a("css-value");var u="#";for(o++;o<c&&/[0-9a-fA-F]/.test(e[o]);)u+=e[o],o++;t.push({type:"color",text:u})}else{a("selector");var f="@";for(o++;o<c&&/[a-zA-Z\-]/.test(e[o]);)f+=e[o],o++;t.push({type:"at-rule",text:f})}else{a("selector"===r?"selector":"css-value");var b=l,w=l;for(o++;o<c;)if("\\"!==e[o]){if(e[o]===b){w+=e[o],o++;break}w+=e[o],o++}else w+=e[o]+(e[o+1]||""),o+=2;t.push({type:"string",text:w})}else{a("selector"===r?"selector":"prop"===r?"css-prop":"css-value");var d=e.indexOf("*/",o+2);-1===d&&(d=c-2),t.push({type:"comment",text:e.substring(o,d+2)}),o=d+2}}return a("selector"===r?"selector":"prop"===r?"css-prop":"css-value"),t}function a(e){var t=[],o=0,c=e.length,r="";function n(e){r.length&&(t.push({type:e,text:r}),r="")}for(;o<c;){var a=e[o];if("<"!==a||"\x3c!--"!==e.substring(o,o+4))if("<"!==a)if("&"!==a)r+=a,o++;else{n("plain");var l="&";for(o++;o<c&&";"!==e[o]&&/[a-zA-Z0-9#]/.test(e[o]);)l+=e[o],o++;o<c&&";"===e[o]&&(l+=";",o++),t.push({type:"string",text:l})}else{n("plain");var i="<";for(++o<c&&"/"===e[o]&&(i+="/",o++);o<c&&/[a-zA-Z0-9\-]/.test(e[o]);)i+=e[o],o++;for(t.push({type:"tag",text:i});o<c&&">"!==e[o]&&("/"!==e[o]||">"!==e[o+1]);)if(/\s/.test(e[o])){for(var s="";o<c&&/\s/.test(e[o]);)s+=e[o],o++;t.push({type:"plain",text:s})}else if(/[a-zA-Z_\-@:]/.test(e[o])){for(var p="";o<c&&/[a-zA-Z0-9_\-@:]/.test(e[o]);)p+=e[o],o++;if(t.push({type:"attr-name",text:p}),o<c&&"="===e[o])if(t.push({type:"punctuation",text:"="}),++o<c&&('"'===e[o]||"'"===e[o])){var u=e[o],f=u;for(o++;o<c&&e[o]!==u;)f+=e[o],o++;o<c&&(f+=e[o],o++),t.push({type:"attr-value",text:f})}else{for(var b="";o<c&&!/[\s>]/.test(e[o]);)b+=e[o],o++;t.push({type:"attr-value",text:b})}}else r+=e[o],o++,n("plain");var w="";o<c&&"/"===e[o]&&(w+="/",o++),o<c&&">"===e[o]&&(w+=">",o++),w&&t.push({type:"tag",text:w})}else{n("plain");var d=e.indexOf("--\x3e",o+4);-1===d&&(d=c-3),t.push({type:"comment",text:e.substring(o,d+3)}),o=d+3}}return n("plain"),t}"var,const,let,function,return,if,else,for,while,do,switch,case,break,continue,new,typeof,instanceof,this,class,extends,import,export,default,from,true,false,null,undefined,try,catch,throw,finally,async,await,yield,of,in,delete,void,with,super,static,get,set,debugger".split(",").forEach(function(e){c[e]=!0});var l={js:r,javascript:r,css:n,html:a};function i(e,t){return function(e){for(var t=[],o=0;o<e.length;o++){var c=e[o];"plain"===c.type?t.push(c.text):t.push({t:"span",a:{class:"bw-ce-"+c.type},c:c.text})}return t}((l[t]||r)(e))}function s(e){var t=(e=e||{}).code||"",o=e.lang||"js",c=e.height||"180px",r=!!e.readOnly,n="bw-ce"+(e.className?" "+e.className:""),a=i(t,o),l={spellcheck:"false",class:"bw-ce-code"};return r||(l.contenteditable="true"),{t:"div",a:{class:n,style:"max-height:"+c+";overflow:auto"},c:[{t:"pre",c:{t:"code",a:l,c:a}}],o:{mounted:function(c){var n=c.querySelector(".bw-ce-code");if(n){var a=t,l=null,s="undefined"!=typeof window&&window.bw||{};c._bwCodeEdit={getValue:p,setValue:function(e){a=e;var t=i(e,o);s.html&&(n.innerHTML=s.html({t:"span",c:t}))}},r||(n.addEventListener("input",function(){clearTimeout(l),l=setTimeout(u,50)}),n.addEventListener("keydown",function(e){"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," "))}))}function p(){return n.textContent||""}function u(){var t=p();if(t!==a){a=t;var c=function(e){var t=window.getSelection();if(!t.rangeCount)return 0;var o=t.getRangeAt(0).cloneRange();return o.selectNodeContents(e),o.setEnd(t.getRangeAt(0).startContainer,t.getRangeAt(0).startOffset),o.toString().length}(n),r=i(t,o);s.html&&(n.innerHTML=s.html({t:"span",c:r})),function(e,t){for(var o,c=window.getSelection(),r=document.createRange(),n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),a=0;o=n.nextNode();){var l=o.textContent.length;if(a+l>=t)return r.setStart(o,t-a),r.collapse(!0),c.removeAllRanges(),void c.addRange(r);a+=l}r.selectNodeContents(e),r.collapse(!1),c.removeAllRanges(),c.addRange(r)}(n,c),e.onChange&&e.onChange(t)}}}}}}function p(e){e&&(e.highlight=i,e.codeEditor=function(c){return function(e){t||(t=!0,e&&e.injectCSS&&e.injectCSS(o,{id:"bw-code-edit-styles"}))}(e),s(c)})}"undefined"!=typeof window&&window.bw&&p(window.bw);var u={highlight:i,codeEditor:s,install:p,CSS_TEXT:o};e.CSS_TEXT=o,e.codeEditor=s,e.default=u,e.highlight=i,e.install=p,e.tokenizeCSS=n,e.tokenizeHTML=a,e.tokenizeJS=r,Object.defineProperty(e,"__esModule",{value:!0})});
15
15
  //# sourceMappingURL=bitwrench-code-edit.es5.min.js.map
@@ -1,4 +1,4 @@
1
- /*! bitwrench v2.0.8 | BSD-2-Clause | http://deftio.com/bitwrench */
1
+ /*! bitwrench v2.0.10 | BSD-2-Clause | http://deftio.com/bitwrench */
2
2
  /**
3
3
  * bitwrench-code-edit.js - syntax-highlighted contenteditable code editor addon
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! bitwrench v2.0.8 | BSD-2-Clause | http://deftio.com/bitwrench */
1
+ /*! bitwrench v2.0.10 | BSD-2-Clause | http://deftio.com/bitwrench */
2
2
  /**
3
3
  * bitwrench-code-edit.js - syntax-highlighted contenteditable code editor addon
4
4
  *
@@ -11,5 +11,5 @@
11
11
  * @module bitwrench-code-edit
12
12
  * @license BSD-2-Clause
13
13
  */
14
- var e=!1,t='.bw-ce{background:#1e293b;border-radius:6px;border:1px solid rgba(255,255,255,0.08);overflow:auto}.bw-ce pre{margin:0;padding:0}.bw-ce code{font-family:"SF Mono",Monaco,"Cascadia Code",Consolas,monospace;font-size:0.875rem;line-height:1.6;color:#e2e8f0;outline:none;white-space:pre-wrap;display:block;padding:0.75rem 1rem}.bw-ce code:empty::before{content:"\\200b"}.bw-ce .bw-ce-keyword{color:#c792ea}.bw-ce .bw-ce-string{color:#c3e88d}.bw-ce .bw-ce-comment{color:#546e7a;font-style:italic}.bw-ce .bw-ce-number{color:#f78c6c}.bw-ce .bw-ce-operator{color:#89ddff}.bw-ce .bw-ce-punctuation{color:#89ddff}.bw-ce .bw-ce-property{color:#82aaff}.bw-ce .bw-ce-function{color:#82aaff}.bw-ce .bw-ce-tag{color:#f07178}.bw-ce .bw-ce-attr-name{color:#ffcb6b}.bw-ce .bw-ce-attr-value{color:#c3e88d}.bw-ce .bw-ce-selector{color:#c792ea}.bw-ce .bw-ce-css-prop{color:#82aaff}.bw-ce .bw-ce-css-value{color:#f78c6c}.bw-ce .bw-ce-at-rule{color:#c792ea;font-style:italic}.bw-ce .bw-ce-color{color:#f78c6c}.bw-ce .bw-ce-template-interp{color:#89ddff}.bw-ce-light.bw-ce{background:#fafafa;border-color:#d8d8d8}.bw-ce-light.bw-ce code{color:#1a1a1a}.bw-ce-light.bw-ce .bw-ce-keyword{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-string{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-comment{color:#9ca3af;font-style:italic}.bw-ce-light.bw-ce .bw-ce-number{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-operator{color:#0891b2}.bw-ce-light.bw-ce .bw-ce-punctuation{color:#6b7280}.bw-ce-light.bw-ce .bw-ce-property{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-function{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-tag{color:#dc2626}.bw-ce-light.bw-ce .bw-ce-attr-name{color:#d97706}.bw-ce-light.bw-ce .bw-ce-attr-value{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-selector{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-css-prop{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-css-value{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-at-rule{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-color{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-template-interp{color:#0891b2}';var c={};function o(e){var t=[],r=0,n=e.length,a="";function l(e){a.length&&(t.push({type:e,text:a}),a="")}for(;r<n;){var s=e[r],i=e[r+1];if("/"!==s||"/"!==i)if("/"!==s||"*"!==i){if("/"===s&&"/"!==i&&"*"!==i){var p=t.length?t[t.length-1]:null,u=!1;if(a.trim().length||p&&"operator"!==p.type&&"punctuation"!==p.type&&"keyword"!==p.type||(u=!0),u){l("plain");for(var f="/",b=r+1,w=!1,h=!1;b<n;){var d=e[b];if(w)f+=d,w=!1,b++;else if("\\"!==d)if("["!==d)if("]"!==d){if("/"===d&&!h){f+=d,b++;break}if("\n"===d)break;f+=d,b++}else h=!1,f+=d,b++;else h=!0,f+=d,b++;else w=!0,f+=d,b++}for(;b<n&&/[gimsuvy]/.test(e[b]);)f+=e[b],b++;t.push({type:"string",text:f}),r=b;continue}}if('"'!==s&&"'"!==s&&"`"!==s)if(/[0-9]/.test(s)||"."===s&&i&&/[0-9]/.test(i)){l("plain");var g="";if("0"===s&&i&&/[xXbBoO]/.test(i))for(g=s+i,r+=2;r<n&&/[0-9a-fA-F_]/.test(e[r]);)g+=e[r],r++;else for(;r<n&&/[0-9._eE]/.test(e[r]);)"e"!==e[r]&&"E"!==e[r]||!e[r+1]||!/[+\-0-9]/.test(e[r+1])?(g+=e[r],r++):(g+=e[r]+e[r+1],r+=2);t.push({type:"number",text:g})}else if(/[a-zA-Z_$]/.test(s)){l("plain");for(var v="";r<n&&/[a-zA-Z0-9_$]/.test(e[r]);)v+=e[r],r++;for(var y=r;y<n&&(" "===e[y]||"\t"===e[y]);)y++;var x=t.length?t[t.length-1]:null,m=x&&"punctuation"===x.type&&"."===x.text;c[v]?t.push({type:"keyword",text:v}):m?y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"property",text:v}):y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"plain",text:v})}else if(-1==="=+-*/%!<>&|^~?:".indexOf(s))-1==="(){}[];,.".indexOf(s)?(a+=s,r++):(l("plain"),t.push({type:"punctuation",text:s}),r++);else{l("plain");var k=s;++r<n&&-1!=="=+-*/%!<>&|^~?:".indexOf(e[r])&&(k+=e[r],++r<n&&-1!=="=>&|".indexOf(e[r])&&(k+=e[r],r++)),t.push({type:"operator",text:k})}else{l("plain");var C=s,A=s,S=r+1;if("`"===C){for(;S<n;){var O=e[S];if("\\"!==O)if("$"!==O||"{"!==e[S+1]){if("`"===O){A+=O,S++;break}A+=O,S++}else{A.length&&t.push({type:"string",text:A}),A="",t.push({type:"template-interp",text:"${"}),S+=2;for(var E=1,T="";S<n&&E>0;){if("{"===e[S])E++;else if("}"===e[S]&&0===--E)break;T+=e[S],S++}var z=o(T);(t=t.concat(z)).push({type:"template-interp",text:"}"}),S++}else A+=O+(e[S+1]||""),S+=2}A.length&&t.push({type:"string",text:A})}else{for(;S<n;){var R=e[S];if("\\"!==R){if(R===C){A+=R,S++;break}if("\n"===R)break;A+=R,S++}else A+=R+(e[S+1]||""),S+=2}t.push({type:"string",text:A})}r=S}}else{l("plain");var _=e.indexOf("*/",r+2);-1===_&&(_=n-2),t.push({type:"comment",text:e.substring(r,_+2)}),r=_+2}else{l("plain");var Z=e.indexOf("\n",r);-1===Z&&(Z=n),t.push({type:"comment",text:e.substring(r,Z)}),r=Z}}return l("plain"),t}function r(e){var t=[],c=0,o=e.length,r="selector",n="";function a(e){n.length&&(t.push({type:e||"plain",text:n}),n="")}for(;c<o;){var l=e[c],s=e[c+1];if("/"!==l||"*"!==s)if('"'!==l&&"'"!==l||"value"!==r&&"selector"!==r)if("@"!==l||"selector"!==r)if("#"!==l||"value"!==r)if("value"===r&&/[0-9]/.test(l)){a("css-value");for(var i="";c<o&&/[0-9.]/.test(e[c]);)i+=e[c],c++;for(var p="";c<o&&/[a-zA-Z%]/.test(e[c]);)p+=e[c],c++;t.push({type:"number",text:i+p})}else"{"!==l?"}"!==l?":"!==l||"prop"!==r?";"!==l?","!==l?(n+=l,c++):(a("selector"===r?"selector":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),c++):(a("value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="prop",c++):(a("css-prop"),t.push({type:"punctuation",text:l}),r="value",c++):(a("prop"===r?"css-prop":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="selector",c++):(a("selector"===r?"selector":"plain"),t.push({type:"punctuation",text:l}),r="prop",c++);else{a("css-value");var u="#";for(c++;c<o&&/[0-9a-fA-F]/.test(e[c]);)u+=e[c],c++;t.push({type:"color",text:u})}else{a("selector");var f="@";for(c++;c<o&&/[a-zA-Z\-]/.test(e[c]);)f+=e[c],c++;t.push({type:"at-rule",text:f})}else{a("selector"===r?"selector":"css-value");var b=l,w=l;for(c++;c<o;)if("\\"!==e[c]){if(e[c]===b){w+=e[c],c++;break}w+=e[c],c++}else w+=e[c]+(e[c+1]||""),c+=2;t.push({type:"string",text:w})}else{a("selector"===r?"selector":"prop"===r?"css-prop":"css-value");var h=e.indexOf("*/",c+2);-1===h&&(h=o-2),t.push({type:"comment",text:e.substring(c,h+2)}),c=h+2}}return a("selector"===r?"selector":"prop"===r?"css-prop":"css-value"),t}function n(e){var t=[],c=0,o=e.length,r="";function n(e){r.length&&(t.push({type:e,text:r}),r="")}for(;c<o;){var a=e[c];if("<"!==a||"\x3c!--"!==e.substring(c,c+4))if("<"!==a)if("&"!==a)r+=a,c++;else{n("plain");var l="&";for(c++;c<o&&";"!==e[c]&&/[a-zA-Z0-9#]/.test(e[c]);)l+=e[c],c++;c<o&&";"===e[c]&&(l+=";",c++),t.push({type:"string",text:l})}else{n("plain");var s="<";for(++c<o&&"/"===e[c]&&(s+="/",c++);c<o&&/[a-zA-Z0-9\-]/.test(e[c]);)s+=e[c],c++;for(t.push({type:"tag",text:s});c<o&&">"!==e[c]&&("/"!==e[c]||">"!==e[c+1]);)if(/\s/.test(e[c])){for(var i="";c<o&&/\s/.test(e[c]);)i+=e[c],c++;t.push({type:"plain",text:i})}else if(/[a-zA-Z_\-@:]/.test(e[c])){for(var p="";c<o&&/[a-zA-Z0-9_\-@:]/.test(e[c]);)p+=e[c],c++;if(t.push({type:"attr-name",text:p}),c<o&&"="===e[c])if(t.push({type:"punctuation",text:"="}),++c<o&&('"'===e[c]||"'"===e[c])){var u=e[c],f=u;for(c++;c<o&&e[c]!==u;)f+=e[c],c++;c<o&&(f+=e[c],c++),t.push({type:"attr-value",text:f})}else{for(var b="";c<o&&!/[\s>]/.test(e[c]);)b+=e[c],c++;t.push({type:"attr-value",text:b})}}else r+=e[c],c++,n("plain");var w="";c<o&&"/"===e[c]&&(w+="/",c++),c<o&&">"===e[c]&&(w+=">",c++),w&&t.push({type:"tag",text:w})}else{n("plain");var h=e.indexOf("--\x3e",c+4);-1===h&&(h=o-3),t.push({type:"comment",text:e.substring(c,h+3)}),c=h+3}}return n("plain"),t}"var,const,let,function,return,if,else,for,while,do,switch,case,break,continue,new,typeof,instanceof,this,class,extends,import,export,default,from,true,false,null,undefined,try,catch,throw,finally,async,await,yield,of,in,delete,void,with,super,static,get,set,debugger".split(",").forEach((function(e){c[e]=!0}));var a={js:o,javascript:o,css:r,html:n};function l(e,t){return function(e){for(var t=[],c=0;c<e.length;c++){var o=e[c];"plain"===o.type?t.push(o.text):t.push({t:"span",a:{class:"bw-ce-"+o.type},c:o.text})}return t}((a[t]||o)(e))}function s(e){var t=(e=e||{}).code||"",c=e.lang||"js",o=e.height||"180px",r=!!e.readOnly,n="bw-ce"+(e.className?" "+e.className:""),a=l(t,c),s={spellcheck:"false",class:"bw-ce-code"};return r||(s.contenteditable="true"),{t:"div",a:{class:n,style:"max-height:"+o+";overflow:auto"},c:[{t:"pre",c:{t:"code",a:s,c:a}}],o:{mounted:function(o){var n=o.querySelector(".bw-ce-code");if(n){var a=t,s=null,i="undefined"!=typeof window&&window.bw||{};o._bwCodeEdit={getValue:p,setValue:function(e){a=e;var t=l(e,c);i.html&&(n.innerHTML=i.html({t:"span",c:t}))}},r||(n.addEventListener("input",(function(){clearTimeout(s),s=setTimeout(u,50)})),n.addEventListener("keydown",(function(e){"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," "))})))}function p(){return n.textContent||""}function u(){var t=p();if(t!==a){a=t;var o=function(e){var t=window.getSelection();if(!t.rangeCount)return 0;var c=t.getRangeAt(0).cloneRange();return c.selectNodeContents(e),c.setEnd(t.getRangeAt(0).startContainer,t.getRangeAt(0).startOffset),c.toString().length}(n),r=l(t,c);i.html&&(n.innerHTML=i.html({t:"span",c:r})),function(e,t){for(var c,o=window.getSelection(),r=document.createRange(),n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),a=0;c=n.nextNode();){var l=c.textContent.length;if(a+l>=t)return r.setStart(c,t-a),r.collapse(!0),o.removeAllRanges(),void o.addRange(r);a+=l}r.selectNodeContents(e),r.collapse(!1),o.removeAllRanges(),o.addRange(r)}(n,o),e.onChange&&e.onChange(t)}}}}}}function i(c){c&&(c.highlight=l,c.codeEditor=function(o){return function(c){e||(e=!0,c&&c.injectCSS&&c.injectCSS(t,{id:"bw-code-edit-styles"}))}(c),s(o)})}"undefined"!=typeof window&&window.bw&&i(window.bw);var p={highlight:l,codeEditor:s,install:i,CSS_TEXT:t};export{t as CSS_TEXT,s as codeEditor,p as default,l as highlight,i as install,r as tokenizeCSS,n as tokenizeHTML,o as tokenizeJS};
14
+ var e=!1,t='.bw-ce{background:#1e293b;border-radius:6px;border:1px solid rgba(255,255,255,0.08);overflow:auto}.bw-ce pre{margin:0;padding:0}.bw-ce code{font-family:"SF Mono",Monaco,"Cascadia Code",Consolas,monospace;font-size:0.875rem;line-height:1.6;color:#e2e8f0;outline:none;white-space:pre-wrap;display:block;padding:0.75rem 1rem}.bw-ce code:empty::before{content:"\\200b"}.bw-ce .bw-ce-keyword{color:#c792ea}.bw-ce .bw-ce-string{color:#c3e88d}.bw-ce .bw-ce-comment{color:#546e7a;font-style:italic}.bw-ce .bw-ce-number{color:#f78c6c}.bw-ce .bw-ce-operator{color:#89ddff}.bw-ce .bw-ce-punctuation{color:#89ddff}.bw-ce .bw-ce-property{color:#82aaff}.bw-ce .bw-ce-function{color:#82aaff}.bw-ce .bw-ce-tag{color:#f07178}.bw-ce .bw-ce-attr-name{color:#ffcb6b}.bw-ce .bw-ce-attr-value{color:#c3e88d}.bw-ce .bw-ce-selector{color:#c792ea}.bw-ce .bw-ce-css-prop{color:#82aaff}.bw-ce .bw-ce-css-value{color:#f78c6c}.bw-ce .bw-ce-at-rule{color:#c792ea;font-style:italic}.bw-ce .bw-ce-color{color:#f78c6c}.bw-ce .bw-ce-template-interp{color:#89ddff}.bw-ce-light.bw-ce{background:#fafafa;border-color:#d8d8d8}.bw-ce-light.bw-ce code{color:#1a1a1a}.bw-ce-light.bw-ce .bw-ce-keyword{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-string{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-comment{color:#9ca3af;font-style:italic}.bw-ce-light.bw-ce .bw-ce-number{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-operator{color:#0891b2}.bw-ce-light.bw-ce .bw-ce-punctuation{color:#6b7280}.bw-ce-light.bw-ce .bw-ce-property{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-function{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-tag{color:#dc2626}.bw-ce-light.bw-ce .bw-ce-attr-name{color:#d97706}.bw-ce-light.bw-ce .bw-ce-attr-value{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-selector{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-css-prop{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-css-value{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-at-rule{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-color{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-template-interp{color:#0891b2}';var c={};function o(e){var t=[],r=0,n=e.length,a="";function l(e){a.length&&(t.push({type:e,text:a}),a="")}for(;r<n;){var s=e[r],i=e[r+1];if("/"!==s||"/"!==i)if("/"!==s||"*"!==i){if("/"===s&&"/"!==i&&"*"!==i){var p=t.length?t[t.length-1]:null,u=!1;if(a.trim().length||p&&"operator"!==p.type&&"punctuation"!==p.type&&"keyword"!==p.type||(u=!0),u){l("plain");for(var f="/",b=r+1,w=!1,h=!1;b<n;){var d=e[b];if(w)f+=d,w=!1,b++;else if("\\"!==d)if("["!==d)if("]"!==d){if("/"===d&&!h){f+=d,b++;break}if("\n"===d)break;f+=d,b++}else h=!1,f+=d,b++;else h=!0,f+=d,b++;else w=!0,f+=d,b++}for(;b<n&&/[gimsuvy]/.test(e[b]);)f+=e[b],b++;t.push({type:"string",text:f}),r=b;continue}}if('"'!==s&&"'"!==s&&"`"!==s)if(/[0-9]/.test(s)||"."===s&&i&&/[0-9]/.test(i)){l("plain");var g="";if("0"===s&&i&&/[xXbBoO]/.test(i))for(g=s+i,r+=2;r<n&&/[0-9a-fA-F_]/.test(e[r]);)g+=e[r],r++;else for(;r<n&&/[0-9._eE]/.test(e[r]);)"e"!==e[r]&&"E"!==e[r]||!e[r+1]||!/[+\-0-9]/.test(e[r+1])?(g+=e[r],r++):(g+=e[r]+e[r+1],r+=2);t.push({type:"number",text:g})}else if(/[a-zA-Z_$]/.test(s)){l("plain");for(var v="";r<n&&/[a-zA-Z0-9_$]/.test(e[r]);)v+=e[r],r++;for(var y=r;y<n&&(" "===e[y]||"\t"===e[y]);)y++;var x=t.length?t[t.length-1]:null,m=x&&"punctuation"===x.type&&"."===x.text;c[v]?t.push({type:"keyword",text:v}):m?y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"property",text:v}):y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"plain",text:v})}else if(-1==="=+-*/%!<>&|^~?:".indexOf(s))-1==="(){}[];,.".indexOf(s)?(a+=s,r++):(l("plain"),t.push({type:"punctuation",text:s}),r++);else{l("plain");var k=s;++r<n&&-1!=="=+-*/%!<>&|^~?:".indexOf(e[r])&&(k+=e[r],++r<n&&-1!=="=>&|".indexOf(e[r])&&(k+=e[r],r++)),t.push({type:"operator",text:k})}else{l("plain");var C=s,A=s,S=r+1;if("`"===C){for(;S<n;){var O=e[S];if("\\"!==O)if("$"!==O||"{"!==e[S+1]){if("`"===O){A+=O,S++;break}A+=O,S++}else{A.length&&t.push({type:"string",text:A}),A="",t.push({type:"template-interp",text:"${"}),S+=2;for(var E=1,T="";S<n&&E>0;){if("{"===e[S])E++;else if("}"===e[S]&&0===--E)break;T+=e[S],S++}var z=o(T);(t=t.concat(z)).push({type:"template-interp",text:"}"}),S++}else A+=O+(e[S+1]||""),S+=2}A.length&&t.push({type:"string",text:A})}else{for(;S<n;){var R=e[S];if("\\"!==R){if(R===C){A+=R,S++;break}if("\n"===R)break;A+=R,S++}else A+=R+(e[S+1]||""),S+=2}t.push({type:"string",text:A})}r=S}}else{l("plain");var _=e.indexOf("*/",r+2);-1===_&&(_=n-2),t.push({type:"comment",text:e.substring(r,_+2)}),r=_+2}else{l("plain");var Z=e.indexOf("\n",r);-1===Z&&(Z=n),t.push({type:"comment",text:e.substring(r,Z)}),r=Z}}return l("plain"),t}function r(e){var t=[],c=0,o=e.length,r="selector",n="";function a(e){n.length&&(t.push({type:e||"plain",text:n}),n="")}for(;c<o;){var l=e[c],s=e[c+1];if("/"!==l||"*"!==s)if('"'!==l&&"'"!==l||"value"!==r&&"selector"!==r)if("@"!==l||"selector"!==r)if("#"!==l||"value"!==r)if("value"===r&&/[0-9]/.test(l)){a("css-value");for(var i="";c<o&&/[0-9.]/.test(e[c]);)i+=e[c],c++;for(var p="";c<o&&/[a-zA-Z%]/.test(e[c]);)p+=e[c],c++;t.push({type:"number",text:i+p})}else"{"!==l?"}"!==l?":"!==l||"prop"!==r?";"!==l?","!==l?(n+=l,c++):(a("selector"===r?"selector":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),c++):(a("value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="prop",c++):(a("css-prop"),t.push({type:"punctuation",text:l}),r="value",c++):(a("prop"===r?"css-prop":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="selector",c++):(a("selector"===r?"selector":"plain"),t.push({type:"punctuation",text:l}),r="prop",c++);else{a("css-value");var u="#";for(c++;c<o&&/[0-9a-fA-F]/.test(e[c]);)u+=e[c],c++;t.push({type:"color",text:u})}else{a("selector");var f="@";for(c++;c<o&&/[a-zA-Z\-]/.test(e[c]);)f+=e[c],c++;t.push({type:"at-rule",text:f})}else{a("selector"===r?"selector":"css-value");var b=l,w=l;for(c++;c<o;)if("\\"!==e[c]){if(e[c]===b){w+=e[c],c++;break}w+=e[c],c++}else w+=e[c]+(e[c+1]||""),c+=2;t.push({type:"string",text:w})}else{a("selector"===r?"selector":"prop"===r?"css-prop":"css-value");var h=e.indexOf("*/",c+2);-1===h&&(h=o-2),t.push({type:"comment",text:e.substring(c,h+2)}),c=h+2}}return a("selector"===r?"selector":"prop"===r?"css-prop":"css-value"),t}function n(e){var t=[],c=0,o=e.length,r="";function n(e){r.length&&(t.push({type:e,text:r}),r="")}for(;c<o;){var a=e[c];if("<"!==a||"\x3c!--"!==e.substring(c,c+4))if("<"!==a)if("&"!==a)r+=a,c++;else{n("plain");var l="&";for(c++;c<o&&";"!==e[c]&&/[a-zA-Z0-9#]/.test(e[c]);)l+=e[c],c++;c<o&&";"===e[c]&&(l+=";",c++),t.push({type:"string",text:l})}else{n("plain");var s="<";for(++c<o&&"/"===e[c]&&(s+="/",c++);c<o&&/[a-zA-Z0-9\-]/.test(e[c]);)s+=e[c],c++;for(t.push({type:"tag",text:s});c<o&&">"!==e[c]&&("/"!==e[c]||">"!==e[c+1]);)if(/\s/.test(e[c])){for(var i="";c<o&&/\s/.test(e[c]);)i+=e[c],c++;t.push({type:"plain",text:i})}else if(/[a-zA-Z_\-@:]/.test(e[c])){for(var p="";c<o&&/[a-zA-Z0-9_\-@:]/.test(e[c]);)p+=e[c],c++;if(t.push({type:"attr-name",text:p}),c<o&&"="===e[c])if(t.push({type:"punctuation",text:"="}),++c<o&&('"'===e[c]||"'"===e[c])){var u=e[c],f=u;for(c++;c<o&&e[c]!==u;)f+=e[c],c++;c<o&&(f+=e[c],c++),t.push({type:"attr-value",text:f})}else{for(var b="";c<o&&!/[\s>]/.test(e[c]);)b+=e[c],c++;t.push({type:"attr-value",text:b})}}else r+=e[c],c++,n("plain");var w="";c<o&&"/"===e[c]&&(w+="/",c++),c<o&&">"===e[c]&&(w+=">",c++),w&&t.push({type:"tag",text:w})}else{n("plain");var h=e.indexOf("--\x3e",c+4);-1===h&&(h=o-3),t.push({type:"comment",text:e.substring(c,h+3)}),c=h+3}}return n("plain"),t}"var,const,let,function,return,if,else,for,while,do,switch,case,break,continue,new,typeof,instanceof,this,class,extends,import,export,default,from,true,false,null,undefined,try,catch,throw,finally,async,await,yield,of,in,delete,void,with,super,static,get,set,debugger".split(",").forEach(function(e){c[e]=!0});var a={js:o,javascript:o,css:r,html:n};function l(e,t){return function(e){for(var t=[],c=0;c<e.length;c++){var o=e[c];"plain"===o.type?t.push(o.text):t.push({t:"span",a:{class:"bw-ce-"+o.type},c:o.text})}return t}((a[t]||o)(e))}function s(e){var t=(e=e||{}).code||"",c=e.lang||"js",o=e.height||"180px",r=!!e.readOnly,n="bw-ce"+(e.className?" "+e.className:""),a=l(t,c),s={spellcheck:"false",class:"bw-ce-code"};return r||(s.contenteditable="true"),{t:"div",a:{class:n,style:"max-height:"+o+";overflow:auto"},c:[{t:"pre",c:{t:"code",a:s,c:a}}],o:{mounted:function(o){var n=o.querySelector(".bw-ce-code");if(n){var a=t,s=null,i="undefined"!=typeof window&&window.bw||{};o._bwCodeEdit={getValue:p,setValue:function(e){a=e;var t=l(e,c);i.html&&(n.innerHTML=i.html({t:"span",c:t}))}},r||(n.addEventListener("input",function(){clearTimeout(s),s=setTimeout(u,50)}),n.addEventListener("keydown",function(e){"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," "))}))}function p(){return n.textContent||""}function u(){var t=p();if(t!==a){a=t;var o=function(e){var t=window.getSelection();if(!t.rangeCount)return 0;var c=t.getRangeAt(0).cloneRange();return c.selectNodeContents(e),c.setEnd(t.getRangeAt(0).startContainer,t.getRangeAt(0).startOffset),c.toString().length}(n),r=l(t,c);i.html&&(n.innerHTML=i.html({t:"span",c:r})),function(e,t){for(var c,o=window.getSelection(),r=document.createRange(),n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),a=0;c=n.nextNode();){var l=c.textContent.length;if(a+l>=t)return r.setStart(c,t-a),r.collapse(!0),o.removeAllRanges(),void o.addRange(r);a+=l}r.selectNodeContents(e),r.collapse(!1),o.removeAllRanges(),o.addRange(r)}(n,o),e.onChange&&e.onChange(t)}}}}}}function i(c){c&&(c.highlight=l,c.codeEditor=function(o){return function(c){e||(e=!0,c&&c.injectCSS&&c.injectCSS(t,{id:"bw-code-edit-styles"}))}(c),s(o)})}"undefined"!=typeof window&&window.bw&&i(window.bw);var p={highlight:l,codeEditor:s,install:i,CSS_TEXT:t};export{t as CSS_TEXT,s as codeEditor,p as default,l as highlight,i as install,r as tokenizeCSS,n as tokenizeHTML,o as tokenizeJS};
15
15
  //# sourceMappingURL=bitwrench-code-edit.esm.min.js.map
@@ -1,4 +1,4 @@
1
- /*! bitwrench v2.0.8 | BSD-2-Clause | http://deftio.com/bitwrench */
1
+ /*! bitwrench v2.0.10 | BSD-2-Clause | http://deftio.com/bitwrench */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
4
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -1,5 +1,5 @@
1
- /*! bitwrench v2.0.8 | BSD-2-Clause | http://deftio.com/bitwrench */
2
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).bwCodeEdit={})}(this,(function(e){"use strict";
1
+ /*! bitwrench v2.0.10 | BSD-2-Clause | http://deftio.com/bitwrench */
2
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).bwCodeEdit={})}(this,function(e){"use strict";
3
3
  /**
4
4
  * bitwrench-code-edit.js - syntax-highlighted contenteditable code editor addon
5
5
  *
@@ -11,5 +11,5 @@
11
11
  *
12
12
  * @module bitwrench-code-edit
13
13
  * @license BSD-2-Clause
14
- */var t=!1,o='.bw-ce{background:#1e293b;border-radius:6px;border:1px solid rgba(255,255,255,0.08);overflow:auto}.bw-ce pre{margin:0;padding:0}.bw-ce code{font-family:"SF Mono",Monaco,"Cascadia Code",Consolas,monospace;font-size:0.875rem;line-height:1.6;color:#e2e8f0;outline:none;white-space:pre-wrap;display:block;padding:0.75rem 1rem}.bw-ce code:empty::before{content:"\\200b"}.bw-ce .bw-ce-keyword{color:#c792ea}.bw-ce .bw-ce-string{color:#c3e88d}.bw-ce .bw-ce-comment{color:#546e7a;font-style:italic}.bw-ce .bw-ce-number{color:#f78c6c}.bw-ce .bw-ce-operator{color:#89ddff}.bw-ce .bw-ce-punctuation{color:#89ddff}.bw-ce .bw-ce-property{color:#82aaff}.bw-ce .bw-ce-function{color:#82aaff}.bw-ce .bw-ce-tag{color:#f07178}.bw-ce .bw-ce-attr-name{color:#ffcb6b}.bw-ce .bw-ce-attr-value{color:#c3e88d}.bw-ce .bw-ce-selector{color:#c792ea}.bw-ce .bw-ce-css-prop{color:#82aaff}.bw-ce .bw-ce-css-value{color:#f78c6c}.bw-ce .bw-ce-at-rule{color:#c792ea;font-style:italic}.bw-ce .bw-ce-color{color:#f78c6c}.bw-ce .bw-ce-template-interp{color:#89ddff}.bw-ce-light.bw-ce{background:#fafafa;border-color:#d8d8d8}.bw-ce-light.bw-ce code{color:#1a1a1a}.bw-ce-light.bw-ce .bw-ce-keyword{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-string{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-comment{color:#9ca3af;font-style:italic}.bw-ce-light.bw-ce .bw-ce-number{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-operator{color:#0891b2}.bw-ce-light.bw-ce .bw-ce-punctuation{color:#6b7280}.bw-ce-light.bw-ce .bw-ce-property{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-function{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-tag{color:#dc2626}.bw-ce-light.bw-ce .bw-ce-attr-name{color:#d97706}.bw-ce-light.bw-ce .bw-ce-attr-value{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-selector{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-css-prop{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-css-value{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-at-rule{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-color{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-template-interp{color:#0891b2}';var c={};function r(e){var t=[],o=0,n=e.length,a="";function l(e){a.length&&(t.push({type:e,text:a}),a="")}for(;o<n;){var i=e[o],s=e[o+1];if("/"!==i||"/"!==s)if("/"!==i||"*"!==s){if("/"===i&&"/"!==s&&"*"!==s){var p=t.length?t[t.length-1]:null,u=!1;if(a.trim().length||p&&"operator"!==p.type&&"punctuation"!==p.type&&"keyword"!==p.type||(u=!0),u){l("plain");for(var f="/",b=o+1,w=!1,d=!1;b<n;){var h=e[b];if(w)f+=h,w=!1,b++;else if("\\"!==h)if("["!==h)if("]"!==h){if("/"===h&&!d){f+=h,b++;break}if("\n"===h)break;f+=h,b++}else d=!1,f+=h,b++;else d=!0,f+=h,b++;else w=!0,f+=h,b++}for(;b<n&&/[gimsuvy]/.test(e[b]);)f+=e[b],b++;t.push({type:"string",text:f}),o=b;continue}}if('"'!==i&&"'"!==i&&"`"!==i)if(/[0-9]/.test(i)||"."===i&&s&&/[0-9]/.test(s)){l("plain");var g="";if("0"===i&&s&&/[xXbBoO]/.test(s))for(g=i+s,o+=2;o<n&&/[0-9a-fA-F_]/.test(e[o]);)g+=e[o],o++;else for(;o<n&&/[0-9._eE]/.test(e[o]);)"e"!==e[o]&&"E"!==e[o]||!e[o+1]||!/[+\-0-9]/.test(e[o+1])?(g+=e[o],o++):(g+=e[o]+e[o+1],o+=2);t.push({type:"number",text:g})}else if(/[a-zA-Z_$]/.test(i)){l("plain");for(var v="";o<n&&/[a-zA-Z0-9_$]/.test(e[o]);)v+=e[o],o++;for(var y=o;y<n&&(" "===e[y]||"\t"===e[y]);)y++;var x=t.length?t[t.length-1]:null,m=x&&"punctuation"===x.type&&"."===x.text;c[v]?t.push({type:"keyword",text:v}):m?y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"property",text:v}):y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"plain",text:v})}else if(-1==="=+-*/%!<>&|^~?:".indexOf(i))-1==="(){}[];,.".indexOf(i)?(a+=i,o++):(l("plain"),t.push({type:"punctuation",text:i}),o++);else{l("plain");var k=i;++o<n&&-1!=="=+-*/%!<>&|^~?:".indexOf(e[o])&&(k+=e[o],++o<n&&-1!=="=>&|".indexOf(e[o])&&(k+=e[o],o++)),t.push({type:"operator",text:k})}else{l("plain");var C=i,S=i,T=o+1;if("`"===C){for(;T<n;){var A=e[T];if("\\"!==A)if("$"!==A||"{"!==e[T+1]){if("`"===A){S+=A,T++;break}S+=A,T++}else{S.length&&t.push({type:"string",text:S}),S="",t.push({type:"template-interp",text:"${"}),T+=2;for(var E=1,O="";T<n&&E>0;){if("{"===e[T])E++;else if("}"===e[T]&&0===--E)break;O+=e[T],T++}var z=r(O);(t=t.concat(z)).push({type:"template-interp",text:"}"}),T++}else S+=A+(e[T+1]||""),T+=2}S.length&&t.push({type:"string",text:S})}else{for(;T<n;){var _=e[T];if("\\"!==_){if(_===C){S+=_,T++;break}if("\n"===_)break;S+=_,T++}else S+=_+(e[T+1]||""),T+=2}t.push({type:"string",text:S})}o=T}}else{l("plain");var R=e.indexOf("*/",o+2);-1===R&&(R=n-2),t.push({type:"comment",text:e.substring(o,R+2)}),o=R+2}else{l("plain");var Z=e.indexOf("\n",o);-1===Z&&(Z=n),t.push({type:"comment",text:e.substring(o,Z)}),o=Z}}return l("plain"),t}function n(e){var t=[],o=0,c=e.length,r="selector",n="";function a(e){n.length&&(t.push({type:e||"plain",text:n}),n="")}for(;o<c;){var l=e[o],i=e[o+1];if("/"!==l||"*"!==i)if('"'!==l&&"'"!==l||"value"!==r&&"selector"!==r)if("@"!==l||"selector"!==r)if("#"!==l||"value"!==r)if("value"===r&&/[0-9]/.test(l)){a("css-value");for(var s="";o<c&&/[0-9.]/.test(e[o]);)s+=e[o],o++;for(var p="";o<c&&/[a-zA-Z%]/.test(e[o]);)p+=e[o],o++;t.push({type:"number",text:s+p})}else"{"!==l?"}"!==l?":"!==l||"prop"!==r?";"!==l?","!==l?(n+=l,o++):(a("selector"===r?"selector":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),o++):(a("value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="prop",o++):(a("css-prop"),t.push({type:"punctuation",text:l}),r="value",o++):(a("prop"===r?"css-prop":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="selector",o++):(a("selector"===r?"selector":"plain"),t.push({type:"punctuation",text:l}),r="prop",o++);else{a("css-value");var u="#";for(o++;o<c&&/[0-9a-fA-F]/.test(e[o]);)u+=e[o],o++;t.push({type:"color",text:u})}else{a("selector");var f="@";for(o++;o<c&&/[a-zA-Z\-]/.test(e[o]);)f+=e[o],o++;t.push({type:"at-rule",text:f})}else{a("selector"===r?"selector":"css-value");var b=l,w=l;for(o++;o<c;)if("\\"!==e[o]){if(e[o]===b){w+=e[o],o++;break}w+=e[o],o++}else w+=e[o]+(e[o+1]||""),o+=2;t.push({type:"string",text:w})}else{a("selector"===r?"selector":"prop"===r?"css-prop":"css-value");var d=e.indexOf("*/",o+2);-1===d&&(d=c-2),t.push({type:"comment",text:e.substring(o,d+2)}),o=d+2}}return a("selector"===r?"selector":"prop"===r?"css-prop":"css-value"),t}function a(e){var t=[],o=0,c=e.length,r="";function n(e){r.length&&(t.push({type:e,text:r}),r="")}for(;o<c;){var a=e[o];if("<"!==a||"\x3c!--"!==e.substring(o,o+4))if("<"!==a)if("&"!==a)r+=a,o++;else{n("plain");var l="&";for(o++;o<c&&";"!==e[o]&&/[a-zA-Z0-9#]/.test(e[o]);)l+=e[o],o++;o<c&&";"===e[o]&&(l+=";",o++),t.push({type:"string",text:l})}else{n("plain");var i="<";for(++o<c&&"/"===e[o]&&(i+="/",o++);o<c&&/[a-zA-Z0-9\-]/.test(e[o]);)i+=e[o],o++;for(t.push({type:"tag",text:i});o<c&&">"!==e[o]&&("/"!==e[o]||">"!==e[o+1]);)if(/\s/.test(e[o])){for(var s="";o<c&&/\s/.test(e[o]);)s+=e[o],o++;t.push({type:"plain",text:s})}else if(/[a-zA-Z_\-@:]/.test(e[o])){for(var p="";o<c&&/[a-zA-Z0-9_\-@:]/.test(e[o]);)p+=e[o],o++;if(t.push({type:"attr-name",text:p}),o<c&&"="===e[o])if(t.push({type:"punctuation",text:"="}),++o<c&&('"'===e[o]||"'"===e[o])){var u=e[o],f=u;for(o++;o<c&&e[o]!==u;)f+=e[o],o++;o<c&&(f+=e[o],o++),t.push({type:"attr-value",text:f})}else{for(var b="";o<c&&!/[\s>]/.test(e[o]);)b+=e[o],o++;t.push({type:"attr-value",text:b})}}else r+=e[o],o++,n("plain");var w="";o<c&&"/"===e[o]&&(w+="/",o++),o<c&&">"===e[o]&&(w+=">",o++),w&&t.push({type:"tag",text:w})}else{n("plain");var d=e.indexOf("--\x3e",o+4);-1===d&&(d=c-3),t.push({type:"comment",text:e.substring(o,d+3)}),o=d+3}}return n("plain"),t}"var,const,let,function,return,if,else,for,while,do,switch,case,break,continue,new,typeof,instanceof,this,class,extends,import,export,default,from,true,false,null,undefined,try,catch,throw,finally,async,await,yield,of,in,delete,void,with,super,static,get,set,debugger".split(",").forEach((function(e){c[e]=!0}));var l={js:r,javascript:r,css:n,html:a};function i(e,t){return function(e){for(var t=[],o=0;o<e.length;o++){var c=e[o];"plain"===c.type?t.push(c.text):t.push({t:"span",a:{class:"bw-ce-"+c.type},c:c.text})}return t}((l[t]||r)(e))}function s(e){var t=(e=e||{}).code||"",o=e.lang||"js",c=e.height||"180px",r=!!e.readOnly,n="bw-ce"+(e.className?" "+e.className:""),a=i(t,o),l={spellcheck:"false",class:"bw-ce-code"};return r||(l.contenteditable="true"),{t:"div",a:{class:n,style:"max-height:"+c+";overflow:auto"},c:[{t:"pre",c:{t:"code",a:l,c:a}}],o:{mounted:function(c){var n=c.querySelector(".bw-ce-code");if(n){var a=t,l=null,s="undefined"!=typeof window&&window.bw||{};c._bwCodeEdit={getValue:p,setValue:function(e){a=e;var t=i(e,o);s.html&&(n.innerHTML=s.html({t:"span",c:t}))}},r||(n.addEventListener("input",(function(){clearTimeout(l),l=setTimeout(u,50)})),n.addEventListener("keydown",(function(e){"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," "))})))}function p(){return n.textContent||""}function u(){var t=p();if(t!==a){a=t;var c=function(e){var t=window.getSelection();if(!t.rangeCount)return 0;var o=t.getRangeAt(0).cloneRange();return o.selectNodeContents(e),o.setEnd(t.getRangeAt(0).startContainer,t.getRangeAt(0).startOffset),o.toString().length}(n),r=i(t,o);s.html&&(n.innerHTML=s.html({t:"span",c:r})),function(e,t){for(var o,c=window.getSelection(),r=document.createRange(),n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),a=0;o=n.nextNode();){var l=o.textContent.length;if(a+l>=t)return r.setStart(o,t-a),r.collapse(!0),c.removeAllRanges(),void c.addRange(r);a+=l}r.selectNodeContents(e),r.collapse(!1),c.removeAllRanges(),c.addRange(r)}(n,c),e.onChange&&e.onChange(t)}}}}}}function p(e){e&&(e.highlight=i,e.codeEditor=function(c){return function(e){t||(t=!0,e&&e.injectCSS&&e.injectCSS(o,{id:"bw-code-edit-styles"}))}(e),s(c)})}"undefined"!=typeof window&&window.bw&&p(window.bw);var u={highlight:i,codeEditor:s,install:p,CSS_TEXT:o};e.CSS_TEXT=o,e.codeEditor=s,e.default=u,e.highlight=i,e.install=p,e.tokenizeCSS=n,e.tokenizeHTML=a,e.tokenizeJS=r,Object.defineProperty(e,"__esModule",{value:!0})}));
14
+ */var t=!1,o='.bw-ce{background:#1e293b;border-radius:6px;border:1px solid rgba(255,255,255,0.08);overflow:auto}.bw-ce pre{margin:0;padding:0}.bw-ce code{font-family:"SF Mono",Monaco,"Cascadia Code",Consolas,monospace;font-size:0.875rem;line-height:1.6;color:#e2e8f0;outline:none;white-space:pre-wrap;display:block;padding:0.75rem 1rem}.bw-ce code:empty::before{content:"\\200b"}.bw-ce .bw-ce-keyword{color:#c792ea}.bw-ce .bw-ce-string{color:#c3e88d}.bw-ce .bw-ce-comment{color:#546e7a;font-style:italic}.bw-ce .bw-ce-number{color:#f78c6c}.bw-ce .bw-ce-operator{color:#89ddff}.bw-ce .bw-ce-punctuation{color:#89ddff}.bw-ce .bw-ce-property{color:#82aaff}.bw-ce .bw-ce-function{color:#82aaff}.bw-ce .bw-ce-tag{color:#f07178}.bw-ce .bw-ce-attr-name{color:#ffcb6b}.bw-ce .bw-ce-attr-value{color:#c3e88d}.bw-ce .bw-ce-selector{color:#c792ea}.bw-ce .bw-ce-css-prop{color:#82aaff}.bw-ce .bw-ce-css-value{color:#f78c6c}.bw-ce .bw-ce-at-rule{color:#c792ea;font-style:italic}.bw-ce .bw-ce-color{color:#f78c6c}.bw-ce .bw-ce-template-interp{color:#89ddff}.bw-ce-light.bw-ce{background:#fafafa;border-color:#d8d8d8}.bw-ce-light.bw-ce code{color:#1a1a1a}.bw-ce-light.bw-ce .bw-ce-keyword{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-string{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-comment{color:#9ca3af;font-style:italic}.bw-ce-light.bw-ce .bw-ce-number{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-operator{color:#0891b2}.bw-ce-light.bw-ce .bw-ce-punctuation{color:#6b7280}.bw-ce-light.bw-ce .bw-ce-property{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-function{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-tag{color:#dc2626}.bw-ce-light.bw-ce .bw-ce-attr-name{color:#d97706}.bw-ce-light.bw-ce .bw-ce-attr-value{color:#16a34a}.bw-ce-light.bw-ce .bw-ce-selector{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-css-prop{color:#2563eb}.bw-ce-light.bw-ce .bw-ce-css-value{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-at-rule{color:#7c3aed}.bw-ce-light.bw-ce .bw-ce-color{color:#ea580c}.bw-ce-light.bw-ce .bw-ce-template-interp{color:#0891b2}';var c={};function r(e){var t=[],o=0,n=e.length,a="";function l(e){a.length&&(t.push({type:e,text:a}),a="")}for(;o<n;){var i=e[o],s=e[o+1];if("/"!==i||"/"!==s)if("/"!==i||"*"!==s){if("/"===i&&"/"!==s&&"*"!==s){var p=t.length?t[t.length-1]:null,u=!1;if(a.trim().length||p&&"operator"!==p.type&&"punctuation"!==p.type&&"keyword"!==p.type||(u=!0),u){l("plain");for(var f="/",b=o+1,w=!1,d=!1;b<n;){var h=e[b];if(w)f+=h,w=!1,b++;else if("\\"!==h)if("["!==h)if("]"!==h){if("/"===h&&!d){f+=h,b++;break}if("\n"===h)break;f+=h,b++}else d=!1,f+=h,b++;else d=!0,f+=h,b++;else w=!0,f+=h,b++}for(;b<n&&/[gimsuvy]/.test(e[b]);)f+=e[b],b++;t.push({type:"string",text:f}),o=b;continue}}if('"'!==i&&"'"!==i&&"`"!==i)if(/[0-9]/.test(i)||"."===i&&s&&/[0-9]/.test(s)){l("plain");var g="";if("0"===i&&s&&/[xXbBoO]/.test(s))for(g=i+s,o+=2;o<n&&/[0-9a-fA-F_]/.test(e[o]);)g+=e[o],o++;else for(;o<n&&/[0-9._eE]/.test(e[o]);)"e"!==e[o]&&"E"!==e[o]||!e[o+1]||!/[+\-0-9]/.test(e[o+1])?(g+=e[o],o++):(g+=e[o]+e[o+1],o+=2);t.push({type:"number",text:g})}else if(/[a-zA-Z_$]/.test(i)){l("plain");for(var v="";o<n&&/[a-zA-Z0-9_$]/.test(e[o]);)v+=e[o],o++;for(var y=o;y<n&&(" "===e[y]||"\t"===e[y]);)y++;var x=t.length?t[t.length-1]:null,m=x&&"punctuation"===x.type&&"."===x.text;c[v]?t.push({type:"keyword",text:v}):m?y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"property",text:v}):y<n&&"("===e[y]?t.push({type:"function",text:v}):t.push({type:"plain",text:v})}else if(-1==="=+-*/%!<>&|^~?:".indexOf(i))-1==="(){}[];,.".indexOf(i)?(a+=i,o++):(l("plain"),t.push({type:"punctuation",text:i}),o++);else{l("plain");var k=i;++o<n&&-1!=="=+-*/%!<>&|^~?:".indexOf(e[o])&&(k+=e[o],++o<n&&-1!=="=>&|".indexOf(e[o])&&(k+=e[o],o++)),t.push({type:"operator",text:k})}else{l("plain");var C=i,S=i,T=o+1;if("`"===C){for(;T<n;){var A=e[T];if("\\"!==A)if("$"!==A||"{"!==e[T+1]){if("`"===A){S+=A,T++;break}S+=A,T++}else{S.length&&t.push({type:"string",text:S}),S="",t.push({type:"template-interp",text:"${"}),T+=2;for(var E=1,O="";T<n&&E>0;){if("{"===e[T])E++;else if("}"===e[T]&&0===--E)break;O+=e[T],T++}var z=r(O);(t=t.concat(z)).push({type:"template-interp",text:"}"}),T++}else S+=A+(e[T+1]||""),T+=2}S.length&&t.push({type:"string",text:S})}else{for(;T<n;){var _=e[T];if("\\"!==_){if(_===C){S+=_,T++;break}if("\n"===_)break;S+=_,T++}else S+=_+(e[T+1]||""),T+=2}t.push({type:"string",text:S})}o=T}}else{l("plain");var R=e.indexOf("*/",o+2);-1===R&&(R=n-2),t.push({type:"comment",text:e.substring(o,R+2)}),o=R+2}else{l("plain");var Z=e.indexOf("\n",o);-1===Z&&(Z=n),t.push({type:"comment",text:e.substring(o,Z)}),o=Z}}return l("plain"),t}function n(e){var t=[],o=0,c=e.length,r="selector",n="";function a(e){n.length&&(t.push({type:e||"plain",text:n}),n="")}for(;o<c;){var l=e[o],i=e[o+1];if("/"!==l||"*"!==i)if('"'!==l&&"'"!==l||"value"!==r&&"selector"!==r)if("@"!==l||"selector"!==r)if("#"!==l||"value"!==r)if("value"===r&&/[0-9]/.test(l)){a("css-value");for(var s="";o<c&&/[0-9.]/.test(e[o]);)s+=e[o],o++;for(var p="";o<c&&/[a-zA-Z%]/.test(e[o]);)p+=e[o],o++;t.push({type:"number",text:s+p})}else"{"!==l?"}"!==l?":"!==l||"prop"!==r?";"!==l?","!==l?(n+=l,o++):(a("selector"===r?"selector":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),o++):(a("value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="prop",o++):(a("css-prop"),t.push({type:"punctuation",text:l}),r="value",o++):(a("prop"===r?"css-prop":"value"===r?"css-value":"plain"),t.push({type:"punctuation",text:l}),r="selector",o++):(a("selector"===r?"selector":"plain"),t.push({type:"punctuation",text:l}),r="prop",o++);else{a("css-value");var u="#";for(o++;o<c&&/[0-9a-fA-F]/.test(e[o]);)u+=e[o],o++;t.push({type:"color",text:u})}else{a("selector");var f="@";for(o++;o<c&&/[a-zA-Z\-]/.test(e[o]);)f+=e[o],o++;t.push({type:"at-rule",text:f})}else{a("selector"===r?"selector":"css-value");var b=l,w=l;for(o++;o<c;)if("\\"!==e[o]){if(e[o]===b){w+=e[o],o++;break}w+=e[o],o++}else w+=e[o]+(e[o+1]||""),o+=2;t.push({type:"string",text:w})}else{a("selector"===r?"selector":"prop"===r?"css-prop":"css-value");var d=e.indexOf("*/",o+2);-1===d&&(d=c-2),t.push({type:"comment",text:e.substring(o,d+2)}),o=d+2}}return a("selector"===r?"selector":"prop"===r?"css-prop":"css-value"),t}function a(e){var t=[],o=0,c=e.length,r="";function n(e){r.length&&(t.push({type:e,text:r}),r="")}for(;o<c;){var a=e[o];if("<"!==a||"\x3c!--"!==e.substring(o,o+4))if("<"!==a)if("&"!==a)r+=a,o++;else{n("plain");var l="&";for(o++;o<c&&";"!==e[o]&&/[a-zA-Z0-9#]/.test(e[o]);)l+=e[o],o++;o<c&&";"===e[o]&&(l+=";",o++),t.push({type:"string",text:l})}else{n("plain");var i="<";for(++o<c&&"/"===e[o]&&(i+="/",o++);o<c&&/[a-zA-Z0-9\-]/.test(e[o]);)i+=e[o],o++;for(t.push({type:"tag",text:i});o<c&&">"!==e[o]&&("/"!==e[o]||">"!==e[o+1]);)if(/\s/.test(e[o])){for(var s="";o<c&&/\s/.test(e[o]);)s+=e[o],o++;t.push({type:"plain",text:s})}else if(/[a-zA-Z_\-@:]/.test(e[o])){for(var p="";o<c&&/[a-zA-Z0-9_\-@:]/.test(e[o]);)p+=e[o],o++;if(t.push({type:"attr-name",text:p}),o<c&&"="===e[o])if(t.push({type:"punctuation",text:"="}),++o<c&&('"'===e[o]||"'"===e[o])){var u=e[o],f=u;for(o++;o<c&&e[o]!==u;)f+=e[o],o++;o<c&&(f+=e[o],o++),t.push({type:"attr-value",text:f})}else{for(var b="";o<c&&!/[\s>]/.test(e[o]);)b+=e[o],o++;t.push({type:"attr-value",text:b})}}else r+=e[o],o++,n("plain");var w="";o<c&&"/"===e[o]&&(w+="/",o++),o<c&&">"===e[o]&&(w+=">",o++),w&&t.push({type:"tag",text:w})}else{n("plain");var d=e.indexOf("--\x3e",o+4);-1===d&&(d=c-3),t.push({type:"comment",text:e.substring(o,d+3)}),o=d+3}}return n("plain"),t}"var,const,let,function,return,if,else,for,while,do,switch,case,break,continue,new,typeof,instanceof,this,class,extends,import,export,default,from,true,false,null,undefined,try,catch,throw,finally,async,await,yield,of,in,delete,void,with,super,static,get,set,debugger".split(",").forEach(function(e){c[e]=!0});var l={js:r,javascript:r,css:n,html:a};function i(e,t){return function(e){for(var t=[],o=0;o<e.length;o++){var c=e[o];"plain"===c.type?t.push(c.text):t.push({t:"span",a:{class:"bw-ce-"+c.type},c:c.text})}return t}((l[t]||r)(e))}function s(e){var t=(e=e||{}).code||"",o=e.lang||"js",c=e.height||"180px",r=!!e.readOnly,n="bw-ce"+(e.className?" "+e.className:""),a=i(t,o),l={spellcheck:"false",class:"bw-ce-code"};return r||(l.contenteditable="true"),{t:"div",a:{class:n,style:"max-height:"+c+";overflow:auto"},c:[{t:"pre",c:{t:"code",a:l,c:a}}],o:{mounted:function(c){var n=c.querySelector(".bw-ce-code");if(n){var a=t,l=null,s="undefined"!=typeof window&&window.bw||{};c._bwCodeEdit={getValue:p,setValue:function(e){a=e;var t=i(e,o);s.html&&(n.innerHTML=s.html({t:"span",c:t}))}},r||(n.addEventListener("input",function(){clearTimeout(l),l=setTimeout(u,50)}),n.addEventListener("keydown",function(e){"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," "))}))}function p(){return n.textContent||""}function u(){var t=p();if(t!==a){a=t;var c=function(e){var t=window.getSelection();if(!t.rangeCount)return 0;var o=t.getRangeAt(0).cloneRange();return o.selectNodeContents(e),o.setEnd(t.getRangeAt(0).startContainer,t.getRangeAt(0).startOffset),o.toString().length}(n),r=i(t,o);s.html&&(n.innerHTML=s.html({t:"span",c:r})),function(e,t){for(var o,c=window.getSelection(),r=document.createRange(),n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),a=0;o=n.nextNode();){var l=o.textContent.length;if(a+l>=t)return r.setStart(o,t-a),r.collapse(!0),c.removeAllRanges(),void c.addRange(r);a+=l}r.selectNodeContents(e),r.collapse(!1),c.removeAllRanges(),c.addRange(r)}(n,c),e.onChange&&e.onChange(t)}}}}}}function p(e){e&&(e.highlight=i,e.codeEditor=function(c){return function(e){t||(t=!0,e&&e.injectCSS&&e.injectCSS(o,{id:"bw-code-edit-styles"}))}(e),s(c)})}"undefined"!=typeof window&&window.bw&&p(window.bw);var u={highlight:i,codeEditor:s,install:p,CSS_TEXT:o};e.CSS_TEXT=o,e.codeEditor=s,e.default=u,e.highlight=i,e.install=p,e.tokenizeCSS=n,e.tokenizeHTML=a,e.tokenizeJS=r,Object.defineProperty(e,"__esModule",{value:!0})});
15
15
  //# sourceMappingURL=bitwrench-code-edit.umd.min.js.map
@@ -1,4 +1,4 @@
1
- /*! bitwrench v2.0.8 | BSD-2-Clause | http://deftio.com/bitwrench */
1
+ /*! bitwrench v2.0.10 | BSD-2-Clause | http://deftio.com/bitwrench */
2
2
  'use strict';
3
3
 
4
4
  /**
@@ -7,14 +7,14 @@
7
7
  */
8
8
 
9
9
  const VERSION_INFO = {
10
- version: '2.0.8',
10
+ version: '2.0.10',
11
11
  name: 'bitwrench',
12
12
  description: 'A library for javascript UI functions.',
13
13
  license: 'BSD-2-Clause',
14
14
  homepage: 'http://deftio.com/bitwrench',
15
15
  repository: 'git+https://github.com/deftio/bitwrench.git',
16
16
  author: 'manu a. chatterjee <deftio@deftio.com> (https://deftio.com/)',
17
- buildDate: '2026-03-06T17:39:43.301Z'
17
+ buildDate: '2026-03-07T03:14:16.606Z'
18
18
  };
19
19
 
20
20
  /**
@@ -3665,6 +3665,27 @@ const bw = {
3665
3665
  _unmountCallbacks: new Map(),
3666
3666
  _topics: {}, // topic → [{handler, id}] (plain object for IE11 compat)
3667
3667
  _subIdCounter: 0, // monotonic ID for subscriptions
3668
+
3669
+ // ── Node reference cache ──────────────────────────────────────────────
3670
+ // Fast O(1) lookup for elements by bw_id, id attribute, or bw_uuid.
3671
+ //
3672
+ // Populated by bw.createDOM() when elements have:
3673
+ // - data-bw-id attribute (user-declared addressable elements)
3674
+ // - id attribute (standard HTML id)
3675
+ // - bw_uuid (internal, for lifecycle-managed elements)
3676
+ //
3677
+ // Cleaned up by bw.cleanup() when elements are destroyed via bitwrench APIs.
3678
+ // On cache miss, falls back to querySelector/getElementById — never fails,
3679
+ // just slower. Stale entries (refs to detached nodes) are removed on miss
3680
+ // via parentNode === null check (IE11-safe, unlike el.isConnected).
3681
+ //
3682
+ // Elements created via bw.createDOM() also get el._bw_refs — a local map of
3683
+ // child bw_id → DOM node ref for fast parent→child access in o.render.
3684
+ // This is the bitwrench equivalent of React's compiled template "holes".
3685
+ //
3686
+ // Contract: if you remove elements outside of bitwrench APIs (raw el.remove()),
3687
+ // map entries may linger until the next lookup attempt cleans them.
3688
+ _nodeMap: {},
3668
3689
 
3669
3690
  // Monkey patch for testing (same as v1)
3670
3691
  __monkey_patch_is_nodejs__: {
@@ -3895,6 +3916,108 @@ bw.uuid = function(prefix) {
3895
3916
  return `${tag}${timestamp}_${counter}_${random}`;
3896
3917
  };
3897
3918
 
3919
+ /**
3920
+ * Look up a DOM element by ID string, using the node cache for O(1) access.
3921
+ *
3922
+ * Resolution order:
3923
+ * 1. Check `bw._nodeMap[id]` — if found and still attached (parentNode !== null), return it
3924
+ * 2. If cached ref is detached (parentNode === null), remove stale entry
3925
+ * 3. Fall back to `document.getElementById(id)` then `document.querySelector(...)`
3926
+ * 4. If fallback finds the element, cache it for next time
3927
+ * 5. If not found anywhere, return null
3928
+ *
3929
+ * Accepts a DOM element directly (pass-through) or a string identifier.
3930
+ * String identifiers are tried as: direct map key, getElementById,
3931
+ * querySelector (for CSS selectors starting with . or #), and
3932
+ * data-bw-id attribute selector.
3933
+ *
3934
+ * @param {string|Element} id - Element ID, CSS selector, data-bw-id value, or DOM element
3935
+ * @returns {Element|null} The DOM element, or null if not found
3936
+ * @category Internal
3937
+ */
3938
+ bw._el = function(id) {
3939
+ // Pass-through for DOM elements
3940
+ if (typeof id !== 'string') return id || null;
3941
+ if (!id) return null;
3942
+ if (!bw._isBrowser) return null;
3943
+
3944
+ // 1. Check cache
3945
+ var cached = bw._nodeMap[id];
3946
+ if (cached) {
3947
+ // Verify not detached (parentNode check is IE11-safe)
3948
+ if (cached.parentNode !== null) {
3949
+ return cached;
3950
+ }
3951
+ // Stale — remove and fall through
3952
+ delete bw._nodeMap[id];
3953
+ }
3954
+
3955
+ // 2. DOM fallback: try getElementById first (fastest native lookup)
3956
+ var el = document.getElementById(id);
3957
+
3958
+ // 3. Try querySelector for CSS selectors (starts with # or .)
3959
+ if (!el && (id.charAt(0) === '#' || id.charAt(0) === '.')) {
3960
+ el = document.querySelector(id);
3961
+ }
3962
+
3963
+ // 4. Try data-bw-id attribute (for bw.uuid-generated IDs)
3964
+ if (!el) {
3965
+ el = document.querySelector('[data-bw-id="' + id + '"]');
3966
+ }
3967
+
3968
+ // 5. Cache the result for next time
3969
+ if (el) {
3970
+ bw._nodeMap[id] = el;
3971
+ }
3972
+
3973
+ return el;
3974
+ };
3975
+
3976
+ /**
3977
+ * Register a DOM element in the node cache under one or more keys.
3978
+ *
3979
+ * Called internally by `bw.createDOM()`. Registers elements that have
3980
+ * id attributes, data-bw-id attributes, or both.
3981
+ *
3982
+ * @param {Element} el - DOM element to register
3983
+ * @param {string} [bwId] - data-bw-id value to register under
3984
+ * @category Internal
3985
+ */
3986
+ bw._registerNode = function(el, bwId) {
3987
+ if (!el) return;
3988
+ // Register under data-bw-id
3989
+ if (bwId) {
3990
+ bw._nodeMap[bwId] = el;
3991
+ }
3992
+ // Register under id attribute
3993
+ var htmlId = el.getAttribute ? el.getAttribute('id') : null;
3994
+ if (htmlId) {
3995
+ bw._nodeMap[htmlId] = el;
3996
+ }
3997
+ };
3998
+
3999
+ /**
4000
+ * Remove a DOM element from the node cache.
4001
+ *
4002
+ * Called internally by `bw.cleanup()` when elements are destroyed
4003
+ * through bitwrench APIs.
4004
+ *
4005
+ * @param {Element} el - DOM element to deregister
4006
+ * @param {string} [bwId] - data-bw-id value to remove
4007
+ * @category Internal
4008
+ */
4009
+ bw._deregisterNode = function(el, bwId) {
4010
+ // Remove data-bw-id entry
4011
+ if (bwId) {
4012
+ delete bw._nodeMap[bwId];
4013
+ }
4014
+ // Remove id attribute entry
4015
+ var htmlId = el && el.getAttribute ? el.getAttribute('id') : null;
4016
+ if (htmlId) {
4017
+ delete bw._nodeMap[htmlId];
4018
+ }
4019
+ };
4020
+
3898
4021
  /**
3899
4022
  * Escape HTML special characters to prevent XSS.
3900
4023
  *
@@ -4119,26 +4242,66 @@ bw.createDOM = function(taco, options = {}) {
4119
4242
  }
4120
4243
  }
4121
4244
 
4122
- // Add children
4245
+ // Add children, building _bw_refs for fast parent→child access.
4246
+ // Children with data-bw-id or id attributes get local refs on the parent,
4247
+ // so o.render functions can access them without any DOM lookup.
4123
4248
  if (content != null) {
4124
4249
  if (Array.isArray(content)) {
4125
4250
  content.forEach(child => {
4126
4251
  if (child != null) {
4127
- el.appendChild(bw.createDOM(child, options));
4252
+ var childEl = bw.createDOM(child, options);
4253
+ el.appendChild(childEl);
4254
+ // Build local refs for addressable children
4255
+ var childBwId = (child && child.a) ? (child.a['data-bw-id'] || child.a.id) : null;
4256
+ if (childBwId) {
4257
+ if (!el._bw_refs) el._bw_refs = {};
4258
+ el._bw_refs[childBwId] = childEl;
4259
+ }
4260
+ // Bubble up grandchild refs (flatten one level)
4261
+ if (childEl._bw_refs) {
4262
+ if (!el._bw_refs) el._bw_refs = {};
4263
+ for (var rk in childEl._bw_refs) {
4264
+ if (Object.prototype.hasOwnProperty.call(childEl._bw_refs, rk)) {
4265
+ el._bw_refs[rk] = childEl._bw_refs[rk];
4266
+ }
4267
+ }
4268
+ }
4128
4269
  }
4129
4270
  });
4130
4271
  } else if (typeof content === 'object' && content.t) {
4131
- el.appendChild(bw.createDOM(content, options));
4272
+ var childEl = bw.createDOM(content, options);
4273
+ el.appendChild(childEl);
4274
+ var childBwId = content.a ? (content.a['data-bw-id'] || content.a.id) : null;
4275
+ if (childBwId) {
4276
+ if (!el._bw_refs) el._bw_refs = {};
4277
+ el._bw_refs[childBwId] = childEl;
4278
+ }
4279
+ if (childEl._bw_refs) {
4280
+ if (!el._bw_refs) el._bw_refs = {};
4281
+ for (var rk in childEl._bw_refs) {
4282
+ if (Object.prototype.hasOwnProperty.call(childEl._bw_refs, rk)) {
4283
+ el._bw_refs[rk] = childEl._bw_refs[rk];
4284
+ }
4285
+ }
4286
+ }
4132
4287
  } else {
4133
4288
  el.textContent = String(content);
4134
4289
  }
4135
4290
  }
4136
-
4291
+
4292
+ // Register element in node cache if it has an id attribute
4293
+ if (attrs.id) {
4294
+ bw._registerNode(el, null);
4295
+ }
4296
+
4137
4297
  // Handle lifecycle hooks and state
4138
4298
  if (opts.mounted || opts.unmount || opts.render || opts.state) {
4139
4299
  const id = attrs['data-bw-id'] || bw.uuid();
4140
4300
  el.setAttribute('data-bw-id', id);
4141
4301
 
4302
+ // Register in node cache under data-bw-id
4303
+ bw._registerNode(el, id);
4304
+
4142
4305
  // Store state
4143
4306
  if (opts.state) {
4144
4307
  el._bw_state = opts.state;
@@ -4181,8 +4344,11 @@ bw.createDOM = function(taco, options = {}) {
4181
4344
  opts.unmount(el, el._bw_state || {});
4182
4345
  });
4183
4346
  }
4347
+ } else if (attrs['data-bw-id']) {
4348
+ // Element has explicit data-bw-id but no lifecycle hooks — still register it
4349
+ bw._registerNode(el, attrs['data-bw-id']);
4184
4350
  }
4185
-
4351
+
4186
4352
  return el;
4187
4353
  };
4188
4354
 
@@ -4215,10 +4381,8 @@ bw.DOM = function(target, taco, options = {}) {
4215
4381
  throw new Error('bw.DOM requires a DOM environment (document/window). Use bw.html() instead.');
4216
4382
  }
4217
4383
 
4218
- // Get target element
4219
- const targetEl = typeof target === 'string'
4220
- ? document.querySelector(target)
4221
- : target;
4384
+ // Get target element (use cache-backed lookup)
4385
+ const targetEl = bw._el(target);
4222
4386
 
4223
4387
  if (!targetEl) {
4224
4388
  console.error('bw.DOM: Target element not found:', target);
@@ -4241,7 +4405,11 @@ bw.DOM = function(target, taco, options = {}) {
4241
4405
  // Restore the target's own state/render/subs after cleanup
4242
4406
  if (savedState !== undefined) targetEl._bw_state = savedState;
4243
4407
  if (savedRender) targetEl._bw_render = savedRender;
4244
- if (savedBwId) targetEl.setAttribute('data-bw-id', savedBwId);
4408
+ if (savedBwId) {
4409
+ targetEl.setAttribute('data-bw-id', savedBwId);
4410
+ // Re-register mount point in node cache (cleanup deregistered it)
4411
+ bw._registerNode(targetEl, savedBwId);
4412
+ }
4245
4413
  if (savedSubs) targetEl._bw_subs = savedSubs;
4246
4414
 
4247
4415
  // Clear and mount new content
@@ -4504,15 +4672,19 @@ bw.cleanup = function(element) {
4504
4672
  bw._unmountCallbacks.delete(id);
4505
4673
  }
4506
4674
 
4675
+ // Deregister from node cache
4676
+ bw._deregisterNode(el, id);
4677
+
4507
4678
  // Clean up pub/sub subscriptions tied to this element
4508
4679
  if (el._bw_subs) {
4509
4680
  el._bw_subs.forEach(function(unsub) { unsub(); });
4510
4681
  delete el._bw_subs;
4511
4682
  }
4512
4683
 
4513
- // Clean up state and render
4684
+ // Clean up state, render, and local refs
4514
4685
  delete el._bw_state;
4515
4686
  delete el._bw_render;
4687
+ delete el._bw_refs;
4516
4688
  });
4517
4689
 
4518
4690
  // Check element itself
@@ -4523,6 +4695,10 @@ bw.cleanup = function(element) {
4523
4695
  callback();
4524
4696
  bw._unmountCallbacks.delete(id);
4525
4697
  }
4698
+
4699
+ // Deregister from node cache
4700
+ bw._deregisterNode(element, id);
4701
+
4526
4702
  // Clean up pub/sub subscriptions tied to element itself
4527
4703
  if (element._bw_subs) {
4528
4704
  element._bw_subs.forEach(function(unsub) { unsub(); });
@@ -4530,6 +4706,7 @@ bw.cleanup = function(element) {
4530
4706
  }
4531
4707
  delete element._bw_state;
4532
4708
  delete element._bw_render;
4709
+ delete element._bw_refs;
4533
4710
  }
4534
4711
  };
4535
4712
 
@@ -4544,7 +4721,7 @@ bw.cleanup = function(element) {
4544
4721
  * Calls `el._bw_render(el, state)` and emits `bw:statechange` so other
4545
4722
  * components can react without tight coupling.
4546
4723
  *
4547
- * @param {string|Element} target - CSS selector or DOM element with _bw_render
4724
+ * @param {string|Element} target - Element ID, data-bw-id, CSS selector, or DOM element
4548
4725
  * @returns {Element|null} The element, or null if not found / no render function
4549
4726
  * @category State Management
4550
4727
  * @see bw.patch
@@ -4554,7 +4731,7 @@ bw.cleanup = function(element) {
4554
4731
  * bw.update(el); // re-renders, emits bw:statechange
4555
4732
  */
4556
4733
  bw.update = function(target) {
4557
- var el = typeof target === 'string' ? document.querySelector(target) : target;
4734
+ var el = bw._el(target);
4558
4735
  if (el && el._bw_render) {
4559
4736
  el._bw_render(el, el._bw_state || {});
4560
4737
  bw.emit(el, 'statechange', el._bw_state);
@@ -4569,7 +4746,8 @@ bw.update = function(target) {
4569
4746
  * Use `bw.patch()` for lightweight value updates (scores, labels, counters)
4570
4747
  * and `bw.update()` for full structural re-renders.
4571
4748
  *
4572
- * @param {string|Element} id - Element ID string or DOM element
4749
+ * @param {string|Element} id - Element ID, data-bw-id, CSS selector, or DOM element.
4750
+ * Uses node cache for O(1) lookup; falls back to DOM query on cache miss.
4573
4751
  * @param {string|Object} content - New text content, or TACO object to replace children
4574
4752
  * @param {string} [attr] - If provided, sets this attribute instead of content
4575
4753
  * @returns {Element|null} The patched element, or null if not found
@@ -4582,7 +4760,7 @@ bw.update = function(target) {
4582
4760
  * bw.patch('info', { t: 'em', c: 'new' }); // replace children with TACO
4583
4761
  */
4584
4762
  bw.patch = function(id, content, attr) {
4585
- var el = typeof id === 'string' ? document.getElementById(id) : id;
4763
+ var el = bw._el(id);
4586
4764
  if (!el) return null;
4587
4765
 
4588
4766
  if (attr) {
@@ -4633,7 +4811,8 @@ bw.patchAll = function(patches) {
4633
4811
  * bubble by default so ancestor elements can listen. Use with `bw.on()` for
4634
4812
  * DOM-scoped communication between components.
4635
4813
  *
4636
- * @param {string|Element} target - CSS selector or DOM element
4814
+ * @param {string|Element} target - Element ID, data-bw-id, CSS selector, or DOM element.
4815
+ * Uses node cache for O(1) lookup; falls back to DOM query on cache miss.
4637
4816
  * @param {string} eventName - Event name (will be prefixed with 'bw:')
4638
4817
  * @param {*} [detail] - Data to pass with the event
4639
4818
  * @category Events (DOM)
@@ -4643,7 +4822,7 @@ bw.patchAll = function(patches) {
4643
4822
  * // Dispatches CustomEvent 'bw:statechange' on the element
4644
4823
  */
4645
4824
  bw.emit = function(target, eventName, detail) {
4646
- var el = typeof target === 'string' ? document.querySelector(target) : target;
4825
+ var el = bw._el(target);
4647
4826
  if (el) {
4648
4827
  el.dispatchEvent(new CustomEvent('bw:' + eventName, {
4649
4828
  bubbles: true,
@@ -4659,7 +4838,8 @@ bw.emit = function(target, eventName, detail) {
4659
4838
  * is the first argument so you don't need to destructure `e.detail`.
4660
4839
  * Events bubble, so you can listen on an ancestor element.
4661
4840
  *
4662
- * @param {string|Element} target - CSS selector or DOM element
4841
+ * @param {string|Element} target - Element ID, data-bw-id, CSS selector, or DOM element.
4842
+ * Uses node cache for O(1) lookup; falls back to DOM query on cache miss.
4663
4843
  * @param {string} eventName - Event name (will be prefixed with 'bw:')
4664
4844
  * @param {Function} handler - Called with (detail, event)
4665
4845
  * @returns {Element|null} The element (for chaining), or null if not found
@@ -4671,7 +4851,7 @@ bw.emit = function(target, eventName, detail) {
4671
4851
  * });
4672
4852
  */
4673
4853
  bw.on = function(target, eventName, handler) {
4674
- var el = typeof target === 'string' ? document.querySelector(target) : target;
4854
+ var el = bw._el(target);
4675
4855
  if (el) {
4676
4856
  el.addEventListener('bw:' + eventName, function(e) {
4677
4857
  handler(e.detail, e);