bitwrench 2.0.18 → 2.0.19
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 +86 -81
- package/dist/bitwrench-bccl.cjs.js +221 -48
- package/dist/bitwrench-bccl.cjs.min.js +3 -3
- package/dist/bitwrench-bccl.esm.js +221 -48
- package/dist/bitwrench-bccl.esm.min.js +3 -3
- package/dist/bitwrench-bccl.umd.js +221 -48
- package/dist/bitwrench-bccl.umd.min.js +3 -3
- package/dist/bitwrench-code-edit.cjs.js +7 -9
- package/dist/bitwrench-code-edit.cjs.min.js +5 -7
- package/dist/bitwrench-code-edit.es5.js +6 -8
- package/dist/bitwrench-code-edit.es5.min.js +5 -7
- package/dist/bitwrench-code-edit.esm.js +7 -9
- package/dist/bitwrench-code-edit.esm.min.js +5 -7
- package/dist/bitwrench-code-edit.umd.js +7 -9
- package/dist/bitwrench-code-edit.umd.min.js +5 -7
- package/dist/bitwrench-debug.js +268 -0
- package/dist/bitwrench-debug.min.js +3 -0
- package/dist/bitwrench-lean.cjs.js +250 -1574
- package/dist/bitwrench-lean.cjs.min.js +6 -6
- package/dist/bitwrench-lean.es5.js +344 -1661
- package/dist/bitwrench-lean.es5.min.js +4 -4
- package/dist/bitwrench-lean.esm.js +250 -1574
- package/dist/bitwrench-lean.esm.min.js +6 -6
- package/dist/bitwrench-lean.umd.js +250 -1574
- package/dist/bitwrench-lean.umd.min.js +6 -6
- package/dist/bitwrench-util-css.cjs.js +1 -1
- package/dist/bitwrench-util-css.cjs.min.js +1 -1
- package/dist/bitwrench-util-css.es5.js +1 -1
- package/dist/bitwrench-util-css.es5.min.js +1 -1
- package/dist/bitwrench-util-css.esm.js +1 -1
- package/dist/bitwrench-util-css.esm.min.js +1 -1
- package/dist/bitwrench-util-css.umd.js +1 -1
- package/dist/bitwrench-util-css.umd.min.js +1 -1
- package/dist/bitwrench.cjs.js +510 -1660
- package/dist/bitwrench.cjs.min.js +7 -7
- package/dist/bitwrench.css +80 -33
- package/dist/bitwrench.es5.js +569 -1694
- package/dist/bitwrench.es5.min.js +5 -5
- package/dist/bitwrench.esm.js +510 -1660
- package/dist/bitwrench.esm.min.js +7 -7
- package/dist/bitwrench.min.css +1 -1
- package/dist/bitwrench.umd.js +510 -1660
- package/dist/bitwrench.umd.min.js +7 -7
- package/dist/builds.json +133 -111
- package/dist/bwserve.cjs.js +2 -2
- package/dist/bwserve.esm.js +2 -2
- package/dist/sri.json +46 -44
- package/package.json +5 -3
- package/readme.html +86 -75
- package/src/bitwrench-bccl-entry.js +3 -4
- package/src/bitwrench-bccl.js +217 -43
- package/src/bitwrench-code-edit.js +6 -8
- package/src/bitwrench-debug.js +245 -0
- package/src/bitwrench-styles.js +35 -8
- package/src/bitwrench.js +212 -1563
- package/src/cli/attach.js +53 -21
- package/src/cli/serve.js +179 -3
- package/src/version.js +3 -3
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
/*! bitwrench v2.0.
|
|
1
|
+
/*! bitwrench v2.0.19 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
|
|
2
2
|
/**
|
|
3
3
|
* bitwrench-code-edit.js - syntax-highlighted contenteditable code editor addon
|
|
4
4
|
*
|
|
5
5
|
* Provides bw.highlight() for tokenizing JS/CSS/HTML into TACO spans,
|
|
6
6
|
* and bw.codeEditor() for a live editable code block with syntax coloring.
|
|
7
7
|
*
|
|
8
|
-
* Theme integration: The editor chrome
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* highlighting colors are intentionally fixed (they are a code color scheme,
|
|
12
|
-
* not brand colors). The bw_ce_light class is still supported for manual
|
|
8
|
+
* Theme integration: The editor chrome uses self-contained dark defaults.
|
|
9
|
+
* Syntax highlighting colors are intentionally fixed (they are a code color
|
|
10
|
+
* scheme, not brand colors). The bw_ce_light class is supported for manual
|
|
13
11
|
* light-mode override.
|
|
14
12
|
*
|
|
15
13
|
* Can be loaded standalone (browser script tag after bitwrench.umd.js),
|
|
@@ -18,5 +16,5 @@
|
|
|
18
16
|
* @module bitwrench-code-edit
|
|
19
17
|
* @license BSD-2-Clause
|
|
20
18
|
*/
|
|
21
|
-
var e=!1,t='.bw_ce{background:var(--bw_code_bg,#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:var(--bw_font_mono,"SF Mono",Monaco,"Cascadia Code",Consolas,monospace);font-size:0.875rem;line-height:1.6;color:var(--bw_code_text,#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}.bw_ce_wrap{display:flex;flex-direction:row}.bw_ce_gutter{flex:0 0 auto;padding:0.75rem 0;text-align:right;user-select:none;-webkit-user-select:none;color:#546e7a;font-family:var(--bw_font_mono,"SF Mono",Monaco,"Cascadia Code",Consolas,monospace);font-size:0.875rem;line-height:1.6;border-right:1px solid rgba(255,255,255,0.08);overflow:hidden}.bw_ce_gutter span{display:block;padding:0 0.5rem 0 0.75rem}.bw_ce_light .bw_ce_gutter{color:#9ca3af;border-right-color:#d8d8d8}';var o={};function r(e){var t=[],c=0,n=e.length,a="";function l(e){a.length&&(t.push({type:e,text:a}),a="")}for(;c<n;){var s=e[c],i=e[c+1];if("/"!==s||"/"!==i)if("/"!==s||"*"!==i){if("/"===s&&"/"!==i&&"*"!==i){var p=t.length?t[t.length-1]:null,_=!1;if(a.trim().length||p&&"operator"!==p.type&&"punctuation"!==p.type&&"keyword"!==p.type||(_=!0),_){l("plain");for(var u="/",f=c+1,b=!1,w=!1;f<n;){var d=e[f];if(b)u+=d,b=!1,f++;else if("\\"!==d)if("["!==d)if("]"!==d){if("/"===d&&!w){u+=d,f++;break}if("\n"===d)break;u+=d,f++}else w=!1,u+=d,f++;else w=!0,u+=d,f++;else b=!0,u+=d,f++}for(;f<n&&/[gimsuvy]/.test(e[f]);)u+=e[f],f++;t.push({type:"string",text:u}),c=f;continue}}if('"'!==s&&"'"!==s&&"`"!==s)if(/[0-9]/.test(s)||"."===s&&i&&/[0-9]/.test(i)){l("plain");var h="";if("0"===s&&i&&/[xXbBoO]/.test(i))for(h=s+i,c+=2;c<n&&/[0-9a-fA-F_]/.test(e[c]);)h+=e[c],c++;else for(;c<n&&/[0-9._eE]/.test(e[c]);)"e"!==e[c]&&"E"!==e[c]||!e[c+1]||!/[+\-0-9]/.test(e[c+1])?(h+=e[c],c++):(h+=e[c]+e[c+1],c+=2);t.push({type:"number",text:h})}else if(/[a-zA-Z_$]/.test(s)){l("plain");for(var g="";c<n&&/[a-zA-Z0-9_$]/.test(e[c]);)g+=e[c],c++;for(var v=c;v<n&&(" "===e[v]||"\t"===e[v]);)v++;var y=t.length?t[t.length-1]:null,x=y&&"punctuation"===y.type&&"."===y.text;o[g]?t.push({type:"keyword",text:g}):x?v<n&&"("===e[v]?t.push({type:"function",text:g}):t.push({type:"property",text:g}):v<n&&"("===e[v]?t.push({type:"function",text:g}):t.push({type:"plain",text:g})}else if(-1==="=+-*/%!<>&|^~?:".indexOf(s))-1==="(){}[];,.".indexOf(s)?(a+=s,c++):(l("plain"),t.push({type:"punctuation",text:s}),c++);else{l("plain");var m=s;++c<n&&-1!=="=+-*/%!<>&|^~?:".indexOf(e[c])&&(m+=e[c],++c<n&&-1!=="=>&|".indexOf(e[c])&&(m+=e[c],c++)),t.push({type:"operator",text:m})}else{l("plain");var k=s,C=s,S=c+1;if("`"===k){for(;S<n;){var A=e[S];if("\\"!==A)if("$"!==A||"{"!==e[S+1]){if("`"===A){C+=A,S++;break}C+=A,S++}else{C.length&&t.push({type:"string",text:C}),C="",t.push({type:"template-interp",text:"${"}),S+=2;for(var T=1,E="";S<n&&T>0;){if("{"===e[S])T++;else if("}"===e[S]&&0===--T)break;E+=e[S],S++}var O=r(E);(t=t.concat(O)).push({type:"template-interp",text:"}"}),S++}else C+=A+(e[S+1]||""),S+=2}C.length&&t.push({type:"string",text:C})}else{for(;S<n;){var z=e[S];if("\\"!==z){if(z===k){C+=z,S++;break}if("\n"===z)break;C+=z,S++}else C+=z+(e[S+1]||""),S+=2}t.push({type:"string",text:C})}c=S}}else{l("plain");var R=e.indexOf("*/",c+2);-1===R&&(R=n-2),t.push({type:"comment",text:e.substring(c,R+2)}),c=R+2}else{l("plain");var Z=e.indexOf("\n",c);-1===Z&&(Z=n),t.push({type:"comment",text:e.substring(c,Z)}),c=Z}}return l("plain"),t}function c(e){var t=[],o=0,r=e.length,c="selector",n="";function a(e){n.length&&(t.push({type:e||"plain",text:n}),n="")}for(;o<r;){var l=e[o],s=e[o+1];if("/"!==l||"*"!==s)if('"'!==l&&"'"!==l||"value"!==c&&"selector"!==c)if("@"!==l||"selector"!==c)if("#"!==l||"value"!==c)if("value"===c&&/[0-9]/.test(l)){a("css-value");for(var i="";o<r&&/[0-9.]/.test(e[o]);)i+=e[o],o++;for(var p="";o<r&&/[a-zA-Z%]/.test(e[o]);)p+=e[o],o++;t.push({type:"number",text:i+p})}else"{"!==l?"}"!==l?":"!==l||"prop"!==c?";"!==l?","!==l?(n+=l,o++):(a("selector"===c?"selector":"value"===c?"css-value":"plain"),t.push({type:"punctuation",text:l}),o++):(a("value"===c?"css-value":"plain"),t.push({type:"punctuation",text:l}),c="prop",o++):(a("css-prop"),t.push({type:"punctuation",text:l}),c="value",o++):(a("prop"===c?"css-prop":"value"===c?"css-value":"plain"),t.push({type:"punctuation",text:l}),c="selector",o++):(a("selector"===c?"selector":"plain"),t.push({type:"punctuation",text:l}),c="prop",o++);else{a("css-value");var _="#";for(o++;o<r&&/[0-9a-fA-F]/.test(e[o]);)_+=e[o],o++;t.push({type:"color",text:_})}else{a("selector");var u="@";for(o++;o<r&&/[a-zA-Z\-]/.test(e[o]);)u+=e[o],o++;t.push({type:"at-rule",text:u})}else{a("selector"===c?"selector":"css-value");var f=l,b=l;for(o++;o<r;)if("\\"!==e[o]){if(e[o]===f){b+=e[o],o++;break}b+=e[o],o++}else b+=e[o]+(e[o+1]||""),o+=2;t.push({type:"string",text:b})}else{a("selector"===c?"selector":"prop"===c?"css-prop":"css-value");var w=e.indexOf("*/",o+2);-1===w&&(w=r-2),t.push({type:"comment",text:e.substring(o,w+2)}),o=w+2}}return a("selector"===c?"selector":"prop"===c?"css-prop":"css-value"),t}function n(e){var t=[],o=0,r=e.length,c="";function n(e){c.length&&(t.push({type:e,text:c}),c="")}for(;o<r;){var a=e[o];if("<"!==a||"\x3c!--"!==e.substring(o,o+4))if("<"!==a)if("&"!==a)c+=a,o++;else{n("plain");var l="&";for(o++;o<r&&";"!==e[o]&&/[a-zA-Z0-9#]/.test(e[o]);)l+=e[o],o++;o<r&&";"===e[o]&&(l+=";",o++),t.push({type:"string",text:l})}else{n("plain");var s="<";for(++o<r&&"/"===e[o]&&(s+="/",o++);o<r&&/[a-zA-Z0-9\-]/.test(e[o]);)s+=e[o],o++;for(t.push({type:"tag",text:s});o<r&&">"!==e[o]&&("/"!==e[o]||">"!==e[o+1]);)if(/\s/.test(e[o])){for(var i="";o<r&&/\s/.test(e[o]);)i+=e[o],o++;t.push({type:"plain",text:i})}else if(/[a-zA-Z_\-@:]/.test(e[o])){for(var p="";o<r&&/[a-zA-Z0-9_\-@:]/.test(e[o]);)p+=e[o],o++;if(t.push({type:"attr-name",text:p}),o<r&&"="===e[o])if(t.push({type:"punctuation",text:"="}),++o<r&&('"'===e[o]||"'"===e[o])){var _=e[o],u=_;for(o++;o<r&&e[o]!==_;)u+=e[o],o++;o<r&&(u+=e[o],o++),t.push({type:"attr-value",text:u})}else{for(var f="";o<r&&!/[\s>]/.test(e[o]);)f+=e[o],o++;t.push({type:"attr-value",text:f})}}else c+=e[o],o++,n("plain");var b="";o<r&&"/"===e[o]&&(b+="/",o++),o<r&&">"===e[o]&&(b+=">",o++),b&&t.push({type:"tag",text:b})}else{n("plain");var w=e.indexOf("--\x3e",o+4);-1===w&&(w=r-3),t.push({type:"comment",text:e.substring(o,w+3)}),o=w+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){o[e]=!0});var a={js:r,javascript:r,css:c,html:n};function l(e,t){return function(e){for(var t=[],o=0;o<e.length;o++){var r=e[o];"plain"===r.type?t.push(r.text):t.push({t:"span",a:{class:"bw_ce_"+r.type},c:r.text})}return t}((a[t]||r)(e))}function s(e){var t=(e=e||{}).code||"",o=e.lang||"js",r=e.height||"180px",c=!!e.readOnly,n=!!e.lineNumbers,a="bw_ce"+(e.className?" "+e.className:""),s=l(t,o),i={spellcheck:"false",class:"bw_ce_code"};c||(i.contenteditable="true");var p=null;if(n){for(var _=(t.match(/\n/g)||[]).length+1,u=[],f=1;f<=_;f++)u.push({t:"span",c:String(f)});p={t:"div",a:{class:"bw_ce_gutter"},c:u}}var b={t:"pre",a:{style:"flex:1;min-width:0;margin:0"},c:{t:"code",a:i,c:s}};return{t:"div",a:{class:a,style:"max-height:"+r+";overflow:auto"},c:[n?{t:"div",a:{class:"bw_ce_wrap"},c:[p,b]}:b],o:{mounted:function(r){var a=r.querySelector(".bw_ce_code");if(a){var s=t,i=null,p=n?r.querySelector(".bw_ce_gutter"):null,_="undefined"!=typeof window&&window.bw||{};if(r._bwCodeEdit={getValue:f,setValue:function(e){s=e;var t=l(e,o);_.html&&(a.innerHTML=_.html({t:"span",c:t})),b(e)}},p){var u=a.closest(".bw_ce")||r;u.addEventListener("scroll",function(){p.style.transform="translateY("+-u.scrollTop+"px)"}),r.addEventListener("scroll",function(){p.style.transform="translateY("+-r.scrollTop+"px)"})}c||(a.addEventListener("input",function(){clearTimeout(i),i=setTimeout(w,50)}),a.addEventListener("keydown",function(e){"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," "))}))}function f(){return a.textContent||""}function b(e){if(p){for(var t=(e.match(/\n/g)||[]).length+1,o="",r=1;r<=t;r++)o+="<span>"+r+"</span>";p.innerHTML=o}}function w(){var t=f();if(t!==s){s=t;var r=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}(a),c=l(t,o);_.html&&(a.innerHTML=_.html({t:"span",c:c})),function(e,t){for(var o,r=window.getSelection(),c=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 c.setStart(o,t-a),c.collapse(!0),r.removeAllRanges(),void r.addRange(c);a+=l}c.selectNodeContents(e),c.collapse(!1),r.removeAllRanges(),r.addRange(c)}(a,r),b(t),e.onChange&&e.onChange(t)}}}}}}function i(o){o&&(o.highlight=l,o.codeEditor=function(r){return function(o){e||(e=!0,o&&o.injectCSS&&o.injectCSS(t,{id:"bw_code_edit_styles"}))}(o),s(r)})}"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,c as tokenizeCSS,n as tokenizeHTML,r as tokenizeJS};
|
|
19
|
+
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}.bw_ce_wrap{display:flex;flex-direction:row}.bw_ce_gutter{flex:0 0 auto;padding:0.75rem 0;text-align:right;user-select:none;-webkit-user-select:none;color:#546e7a;font-family:"SF Mono",Monaco,"Cascadia Code",Consolas,monospace;font-size:0.875rem;line-height:1.6;border-right:1px solid rgba(255,255,255,0.08);overflow:hidden}.bw_ce_gutter span{display:block;padding:0 0.5rem 0 0.75rem}.bw_ce_light .bw_ce_gutter{color:#9ca3af;border-right-color:#d8d8d8}';var r={};function c(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 s=e[o],i=e[o+1];if("/"!==s||"/"!==i)if("/"!==s||"*"!==i){if("/"===s&&"/"!==i&&"*"!==i){var p=t.length?t[t.length-1]:null,_=!1;if(a.trim().length||p&&"operator"!==p.type&&"punctuation"!==p.type&&"keyword"!==p.type||(_=!0),_){l("plain");for(var u="/",f=o+1,b=!1,w=!1;f<n;){var d=e[f];if(b)u+=d,b=!1,f++;else if("\\"!==d)if("["!==d)if("]"!==d){if("/"===d&&!w){u+=d,f++;break}if("\n"===d)break;u+=d,f++}else w=!1,u+=d,f++;else w=!0,u+=d,f++;else b=!0,u+=d,f++}for(;f<n&&/[gimsuvy]/.test(e[f]);)u+=e[f],f++;t.push({type:"string",text:u}),o=f;continue}}if('"'!==s&&"'"!==s&&"`"!==s)if(/[0-9]/.test(s)||"."===s&&i&&/[0-9]/.test(i)){l("plain");var h="";if("0"===s&&i&&/[xXbBoO]/.test(i))for(h=s+i,o+=2;o<n&&/[0-9a-fA-F_]/.test(e[o]);)h+=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])?(h+=e[o],o++):(h+=e[o]+e[o+1],o+=2);t.push({type:"number",text:h})}else if(/[a-zA-Z_$]/.test(s)){l("plain");for(var g="";o<n&&/[a-zA-Z0-9_$]/.test(e[o]);)g+=e[o],o++;for(var v=o;v<n&&(" "===e[v]||"\t"===e[v]);)v++;var y=t.length?t[t.length-1]:null,x=y&&"punctuation"===y.type&&"."===y.text;r[g]?t.push({type:"keyword",text:g}):x?v<n&&"("===e[v]?t.push({type:"function",text:g}):t.push({type:"property",text:g}):v<n&&"("===e[v]?t.push({type:"function",text:g}):t.push({type:"plain",text:g})}else if(-1==="=+-*/%!<>&|^~?:".indexOf(s))-1==="(){}[];,.".indexOf(s)?(a+=s,o++):(l("plain"),t.push({type:"punctuation",text:s}),o++);else{l("plain");var m=s;++o<n&&-1!=="=+-*/%!<>&|^~?:".indexOf(e[o])&&(m+=e[o],++o<n&&-1!=="=>&|".indexOf(e[o])&&(m+=e[o],o++)),t.push({type:"operator",text:m})}else{l("plain");var k=s,C=s,S=o+1;if("`"===k){for(;S<n;){var A=e[S];if("\\"!==A)if("$"!==A||"{"!==e[S+1]){if("`"===A){C+=A,S++;break}C+=A,S++}else{C.length&&t.push({type:"string",text:C}),C="",t.push({type:"template-interp",text:"${"}),S+=2;for(var T=1,E="";S<n&&T>0;){if("{"===e[S])T++;else if("}"===e[S]&&0===--T)break;E+=e[S],S++}var O=c(E);(t=t.concat(O)).push({type:"template-interp",text:"}"}),S++}else C+=A+(e[S+1]||""),S+=2}C.length&&t.push({type:"string",text:C})}else{for(;S<n;){var z=e[S];if("\\"!==z){if(z===k){C+=z,S++;break}if("\n"===z)break;C+=z,S++}else C+=z+(e[S+1]||""),S+=2}t.push({type:"string",text:C})}o=S}}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 o(e){var t=[],r=0,c=e.length,o="selector",n="";function a(e){n.length&&(t.push({type:e||"plain",text:n}),n="")}for(;r<c;){var l=e[r],s=e[r+1];if("/"!==l||"*"!==s)if('"'!==l&&"'"!==l||"value"!==o&&"selector"!==o)if("@"!==l||"selector"!==o)if("#"!==l||"value"!==o)if("value"===o&&/[0-9]/.test(l)){a("css-value");for(var i="";r<c&&/[0-9.]/.test(e[r]);)i+=e[r],r++;for(var p="";r<c&&/[a-zA-Z%]/.test(e[r]);)p+=e[r],r++;t.push({type:"number",text:i+p})}else"{"!==l?"}"!==l?":"!==l||"prop"!==o?";"!==l?","!==l?(n+=l,r++):(a("selector"===o?"selector":"value"===o?"css-value":"plain"),t.push({type:"punctuation",text:l}),r++):(a("value"===o?"css-value":"plain"),t.push({type:"punctuation",text:l}),o="prop",r++):(a("css-prop"),t.push({type:"punctuation",text:l}),o="value",r++):(a("prop"===o?"css-prop":"value"===o?"css-value":"plain"),t.push({type:"punctuation",text:l}),o="selector",r++):(a("selector"===o?"selector":"plain"),t.push({type:"punctuation",text:l}),o="prop",r++);else{a("css-value");var _="#";for(r++;r<c&&/[0-9a-fA-F]/.test(e[r]);)_+=e[r],r++;t.push({type:"color",text:_})}else{a("selector");var u="@";for(r++;r<c&&/[a-zA-Z\-]/.test(e[r]);)u+=e[r],r++;t.push({type:"at-rule",text:u})}else{a("selector"===o?"selector":"css-value");var f=l,b=l;for(r++;r<c;)if("\\"!==e[r]){if(e[r]===f){b+=e[r],r++;break}b+=e[r],r++}else b+=e[r]+(e[r+1]||""),r+=2;t.push({type:"string",text:b})}else{a("selector"===o?"selector":"prop"===o?"css-prop":"css-value");var w=e.indexOf("*/",r+2);-1===w&&(w=c-2),t.push({type:"comment",text:e.substring(r,w+2)}),r=w+2}}return a("selector"===o?"selector":"prop"===o?"css-prop":"css-value"),t}function n(e){var t=[],r=0,c=e.length,o="";function n(e){o.length&&(t.push({type:e,text:o}),o="")}for(;r<c;){var a=e[r];if("<"!==a||"\x3c!--"!==e.substring(r,r+4))if("<"!==a)if("&"!==a)o+=a,r++;else{n("plain");var l="&";for(r++;r<c&&";"!==e[r]&&/[a-zA-Z0-9#]/.test(e[r]);)l+=e[r],r++;r<c&&";"===e[r]&&(l+=";",r++),t.push({type:"string",text:l})}else{n("plain");var s="<";for(++r<c&&"/"===e[r]&&(s+="/",r++);r<c&&/[a-zA-Z0-9\-]/.test(e[r]);)s+=e[r],r++;for(t.push({type:"tag",text:s});r<c&&">"!==e[r]&&("/"!==e[r]||">"!==e[r+1]);)if(/\s/.test(e[r])){for(var i="";r<c&&/\s/.test(e[r]);)i+=e[r],r++;t.push({type:"plain",text:i})}else if(/[a-zA-Z_\-@:]/.test(e[r])){for(var p="";r<c&&/[a-zA-Z0-9_\-@:]/.test(e[r]);)p+=e[r],r++;if(t.push({type:"attr-name",text:p}),r<c&&"="===e[r])if(t.push({type:"punctuation",text:"="}),++r<c&&('"'===e[r]||"'"===e[r])){var _=e[r],u=_;for(r++;r<c&&e[r]!==_;)u+=e[r],r++;r<c&&(u+=e[r],r++),t.push({type:"attr-value",text:u})}else{for(var f="";r<c&&!/[\s>]/.test(e[r]);)f+=e[r],r++;t.push({type:"attr-value",text:f})}}else o+=e[r],r++,n("plain");var b="";r<c&&"/"===e[r]&&(b+="/",r++),r<c&&">"===e[r]&&(b+=">",r++),b&&t.push({type:"tag",text:b})}else{n("plain");var w=e.indexOf("--\x3e",r+4);-1===w&&(w=c-3),t.push({type:"comment",text:e.substring(r,w+3)}),r=w+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){r[e]=!0});var a={js:c,javascript:c,css:o,html:n};function l(e,t){return function(e){for(var t=[],r=0;r<e.length;r++){var c=e[r];"plain"===c.type?t.push(c.text):t.push({t:"span",a:{class:"bw_ce_"+c.type},c:c.text})}return t}((a[t]||c)(e))}function s(e){var t=(e=e||{}).code||"",r=e.lang||"js",c=e.height||"180px",o=!!e.readOnly,n=!!e.lineNumbers,a="bw_ce"+(e.className?" "+e.className:""),s=l(t,r),i={spellcheck:"false",class:"bw_ce_code"};o||(i.contenteditable="true");var p=null;if(n){for(var _=(t.match(/\n/g)||[]).length+1,u=[],f=1;f<=_;f++)u.push({t:"span",c:String(f)});p={t:"div",a:{class:"bw_ce_gutter"},c:u}}var b={t:"pre",a:{style:"flex:1;min-width:0;margin:0"},c:{t:"code",a:i,c:s}};return{t:"div",a:{class:a,style:"max-height:"+c+";overflow:auto"},c:[n?{t:"div",a:{class:"bw_ce_wrap"},c:[p,b]}:b],o:{mounted:function(c){var a=c.querySelector(".bw_ce_code");if(a){var s=t,i=null,p=n?c.querySelector(".bw_ce_gutter"):null,_="undefined"!=typeof window&&window.bw||{};if(c._bwCodeEdit={getValue:f,setValue:function(e){s=e;var t=l(e,r);_.html&&(a.innerHTML=_.html({t:"span",c:t})),b(e)}},p){var u=a.closest(".bw_ce")||c;u.addEventListener("scroll",function(){p.style.transform="translateY("+-u.scrollTop+"px)"}),c.addEventListener("scroll",function(){p.style.transform="translateY("+-c.scrollTop+"px)"})}o||(a.addEventListener("input",function(){clearTimeout(i),i=setTimeout(w,50)}),a.addEventListener("keydown",function(e){"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," "))}))}function f(){return a.textContent||""}function b(e){if(p){for(var t=(e.match(/\n/g)||[]).length+1,r="",c=1;c<=t;c++)r+="<span>"+c+"</span>";p.innerHTML=r}}function w(){var t=f();if(t!==s){s=t;var c=function(e){var t=window.getSelection();if(!t.rangeCount)return 0;var r=t.getRangeAt(0).cloneRange();return r.selectNodeContents(e),r.setEnd(t.getRangeAt(0).startContainer,t.getRangeAt(0).startOffset),r.toString().length}(a),o=l(t,r);_.html&&(a.innerHTML=_.html({t:"span",c:o})),function(e,t){for(var r,c=window.getSelection(),o=document.createRange(),n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null,!1),a=0;r=n.nextNode();){var l=r.textContent.length;if(a+l>=t)return o.setStart(r,t-a),o.collapse(!0),c.removeAllRanges(),void c.addRange(o);a+=l}o.selectNodeContents(e),o.collapse(!1),c.removeAllRanges(),c.addRange(o)}(a,c),b(t),e.onChange&&e.onChange(t)}}}}}}function i(r){r&&(r.highlight=l,r.codeEditor=function(c){return function(r){e||(e=!0,r&&r.injectCSS&&r.injectCSS(t,{id:"bw_code_edit_styles"}))}(r),s(c)})}"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,o as tokenizeCSS,n as tokenizeHTML,c as tokenizeJS};
|
|
22
20
|
//# sourceMappingURL=bitwrench-code-edit.esm.min.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! bitwrench v2.0.
|
|
1
|
+
/*! bitwrench v2.0.19 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
|
|
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) :
|
|
@@ -11,11 +11,9 @@
|
|
|
11
11
|
* Provides bw.highlight() for tokenizing JS/CSS/HTML into TACO spans,
|
|
12
12
|
* and bw.codeEditor() for a live editable code block with syntax coloring.
|
|
13
13
|
*
|
|
14
|
-
* Theme integration: The editor chrome
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* highlighting colors are intentionally fixed (they are a code color scheme,
|
|
18
|
-
* not brand colors). The bw_ce_light class is still supported for manual
|
|
14
|
+
* Theme integration: The editor chrome uses self-contained dark defaults.
|
|
15
|
+
* Syntax highlighting colors are intentionally fixed (they are a code color
|
|
16
|
+
* scheme, not brand colors). The bw_ce_light class is supported for manual
|
|
19
17
|
* light-mode override.
|
|
20
18
|
*
|
|
21
19
|
* Can be loaded standalone (browser script tag after bitwrench.umd.js),
|
|
@@ -28,9 +26,9 @@
|
|
|
28
26
|
// -- CSS (injected once) ----------------------------------------------
|
|
29
27
|
var _cssInjected = false;
|
|
30
28
|
var CSS_TEXT =
|
|
31
|
-
'.bw_ce{background
|
|
29
|
+
'.bw_ce{background:#1e293b;border-radius:6px;border:1px solid rgba(255,255,255,0.08);overflow:auto}' +
|
|
32
30
|
'.bw_ce pre{margin:0;padding:0}' +
|
|
33
|
-
'.bw_ce code{font-family:
|
|
31
|
+
'.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}' +
|
|
34
32
|
'.bw_ce code:empty::before{content:"\\200b"}' +
|
|
35
33
|
'.bw_ce .bw_ce_keyword{color:#c792ea}' +
|
|
36
34
|
'.bw_ce .bw_ce_string{color:#c3e88d}' +
|
|
@@ -71,7 +69,7 @@
|
|
|
71
69
|
'.bw_ce_light.bw_ce .bw_ce_template_interp{color:#0891b2}' +
|
|
72
70
|
// Line number gutter (opt-in via lineNumbers option)
|
|
73
71
|
'.bw_ce_wrap{display:flex;flex-direction:row}' +
|
|
74
|
-
'.bw_ce_gutter{flex:0 0 auto;padding:0.75rem 0;text-align:right;user-select:none;-webkit-user-select:none;color:#546e7a;font-family:
|
|
72
|
+
'.bw_ce_gutter{flex:0 0 auto;padding:0.75rem 0;text-align:right;user-select:none;-webkit-user-select:none;color:#546e7a;font-family:"SF Mono",Monaco,"Cascadia Code",Consolas,monospace;font-size:0.875rem;line-height:1.6;border-right:1px solid rgba(255,255,255,0.08);overflow:hidden}' +
|
|
75
73
|
'.bw_ce_gutter span{display:block;padding:0 0.5rem 0 0.75rem}' +
|
|
76
74
|
'.bw_ce_light .bw_ce_gutter{color:#9ca3af;border-right-color:#d8d8d8}';
|
|
77
75
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! bitwrench v2.0.
|
|
1
|
+
/*! bitwrench v2.0.19 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
|
|
2
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
|
|
@@ -6,11 +6,9 @@
|
|
|
6
6
|
* Provides bw.highlight() for tokenizing JS/CSS/HTML into TACO spans,
|
|
7
7
|
* and bw.codeEditor() for a live editable code block with syntax coloring.
|
|
8
8
|
*
|
|
9
|
-
* Theme integration: The editor chrome
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* highlighting colors are intentionally fixed (they are a code color scheme,
|
|
13
|
-
* not brand colors). The bw_ce_light class is still supported for manual
|
|
9
|
+
* Theme integration: The editor chrome uses self-contained dark defaults.
|
|
10
|
+
* Syntax highlighting colors are intentionally fixed (they are a code color
|
|
11
|
+
* scheme, not brand colors). The bw_ce_light class is supported for manual
|
|
14
12
|
* light-mode override.
|
|
15
13
|
*
|
|
16
14
|
* Can be loaded standalone (browser script tag after bitwrench.umd.js),
|
|
@@ -18,5 +16,5 @@
|
|
|
18
16
|
*
|
|
19
17
|
* @module bitwrench-code-edit
|
|
20
18
|
* @license BSD-2-Clause
|
|
21
|
-
*/var t=!1,o='.bw_ce{background:var(--bw_code_bg,#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:var(--bw_font_mono,"SF Mono",Monaco,"Cascadia Code",Consolas,monospace);font-size:0.875rem;line-height:1.6;color:var(--bw_code_text,#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}.bw_ce_wrap{display:flex;flex-direction:row}.bw_ce_gutter{flex:0 0 auto;padding:0.75rem 0;text-align:right;user-select:none;-webkit-user-select:none;color:#546e7a;font-family:var(--bw_font_mono,"SF Mono",Monaco,"Cascadia Code",Consolas,monospace);font-size:0.875rem;line-height:1.6;border-right:1px solid rgba(255,255,255,0.08);overflow:hidden}.bw_ce_gutter span{display:block;padding:0 0.5rem 0 0.75rem}.bw_ce_light .bw_ce_gutter{color:#9ca3af;border-right-color:#d8d8d8}';var r={};function c(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,_=!1;if(a.trim().length||p&&"operator"!==p.type&&"punctuation"!==p.type&&"keyword"!==p.type||(_=!0),_){l("plain");for(var u="/",f=o+1,b=!1,w=!1;f<n;){var d=e[f];if(b)u+=d,b=!1,f++;else if("\\"!==d)if("["!==d)if("]"!==d){if("/"===d&&!w){u+=d,f++;break}if("\n"===d)break;u+=d,f++}else w=!1,u+=d,f++;else w=!0,u+=d,f++;else b=!0,u+=d,f++}for(;f<n&&/[gimsuvy]/.test(e[f]);)u+=e[f],f++;t.push({type:"string",text:u}),o=f;continue}}if('"'!==i&&"'"!==i&&"`"!==i)if(/[0-9]/.test(i)||"."===i&&s&&/[0-9]/.test(s)){l("plain");var h="";if("0"===i&&s&&/[xXbBoO]/.test(s))for(h=i+s,o+=2;o<n&&/[0-9a-fA-F_]/.test(e[o]);)h+=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])?(h+=e[o],o++):(h+=e[o]+e[o+1],o+=2);t.push({type:"number",text:h})}else if(/[a-zA-Z_$]/.test(i)){l("plain");for(var g="";o<n&&/[a-zA-Z0-9_$]/.test(e[o]);)g+=e[o],o++;for(var v=o;v<n&&(" "===e[v]||"\t"===e[v]);)v++;var y=t.length?t[t.length-1]:null,x=y&&"punctuation"===y.type&&"."===y.text;r[g]?t.push({type:"keyword",text:g}):x?v<n&&"("===e[v]?t.push({type:"function",text:g}):t.push({type:"property",text:g}):v<n&&"("===e[v]?t.push({type:"function",text:g}):t.push({type:"plain",text:g})}else if(-1==="=+-*/%!<>&|^~?:".indexOf(i))-1==="(){}[];,.".indexOf(i)?(a+=i,o++):(l("plain"),t.push({type:"punctuation",text:i}),o++);else{l("plain");var m=i;++o<n&&-1!=="=+-*/%!<>&|^~?:".indexOf(e[o])&&(m+=e[o],++o<n&&-1!=="=>&|".indexOf(e[o])&&(m+=e[o],o++)),t.push({type:"operator",text:m})}else{l("plain");var k=i,C=i,S=o+1;if("`"===k){for(;S<n;){var T=e[S];if("\\"!==T)if("$"!==T||"{"!==e[S+1]){if("`"===T){C+=T,S++;break}C+=T,S++}else{C.length&&t.push({type:"string",text:C}),C="",t.push({type:"template-interp",text:"${"}),S+=2;for(var E=1,A="";S<n&&E>0;){if("{"===e[S])E++;else if("}"===e[S]&&0===--E)break;A+=e[S],S++}var z=c(A);(t=t.concat(z)).push({type:"template-interp",text:"}"}),S++}else C+=T+(e[S+1]||""),S+=2}C.length&&t.push({type:"string",text:C})}else{for(;S<n;){var O=e[S];if("\\"!==O){if(O===k){C+=O,S++;break}if("\n"===O)break;C+=O,S++}else C+=O+(e[S+1]||""),S+=2}t.push({type:"string",text:C})}o=S}}else{l("plain");var M=e.indexOf("*/",o+2);-1===M&&(M=n-2),t.push({type:"comment",text:e.substring(o,M+2)}),o=M+2}else{l("plain");var R=e.indexOf("\n",o);-1===R&&(R=n),t.push({type:"comment",text:e.substring(o,R)}),o=R}}return l("plain"),t}function n(e){var t=[],o=0,r=e.length,c="selector",n="";function a(e){n.length&&(t.push({type:e||"plain",text:n}),n="")}for(;o<r;){var l=e[o],i=e[o+1];if("/"!==l||"*"!==i)if('"'!==l&&"'"!==l||"value"!==c&&"selector"!==c)if("@"!==l||"selector"!==c)if("#"!==l||"value"!==c)if("value"===c&&/[0-9]/.test(l)){a("css-value");for(var s="";o<r&&/[0-9.]/.test(e[o]);)s+=e[o],o++;for(var p="";o<r&&/[a-zA-Z%]/.test(e[o]);)p+=e[o],o++;t.push({type:"number",text:s+p})}else"{"!==l?"}"!==l?":"!==l||"prop"!==c?";"!==l?","!==l?(n+=l,o++):(a("selector"===c?"selector":"value"===c?"css-value":"plain"),t.push({type:"punctuation",text:l}),o++):(a("value"===c?"css-value":"plain"),t.push({type:"punctuation",text:l}),c="prop",o++):(a("css-prop"),t.push({type:"punctuation",text:l}),c="value",o++):(a("prop"===c?"css-prop":"value"===c?"css-value":"plain"),t.push({type:"punctuation",text:l}),c="selector",o++):(a("selector"===c?"selector":"plain"),t.push({type:"punctuation",text:l}),c="prop",o++);else{a("css-value");var _="#";for(o++;o<r&&/[0-9a-fA-F]/.test(e[o]);)_+=e[o],o++;t.push({type:"color",text:_})}else{a("selector");var u="@";for(o++;o<r&&/[a-zA-Z\-]/.test(e[o]);)u+=e[o],o++;t.push({type:"at-rule",text:u})}else{a("selector"===c?"selector":"css-value");var f=l,b=l;for(o++;o<r;)if("\\"!==e[o]){if(e[o]===f){b+=e[o],o++;break}b+=e[o],o++}else b+=e[o]+(e[o+1]||""),o+=2;t.push({type:"string",text:b})}else{a("selector"===c?"selector":"prop"===c?"css-prop":"css-value");var w=e.indexOf("*/",o+2);-1===w&&(w=r-2),t.push({type:"comment",text:e.substring(o,w+2)}),o=w+2}}return a("selector"===c?"selector":"prop"===c?"css-prop":"css-value"),t}function a(e){var t=[],o=0,r=e.length,c="";function n(e){c.length&&(t.push({type:e,text:c}),c="")}for(;o<r;){var a=e[o];if("<"!==a||"\x3c!--"!==e.substring(o,o+4))if("<"!==a)if("&"!==a)c+=a,o++;else{n("plain");var l="&";for(o++;o<r&&";"!==e[o]&&/[a-zA-Z0-9#]/.test(e[o]);)l+=e[o],o++;o<r&&";"===e[o]&&(l+=";",o++),t.push({type:"string",text:l})}else{n("plain");var i="<";for(++o<r&&"/"===e[o]&&(i+="/",o++);o<r&&/[a-zA-Z0-9\-]/.test(e[o]);)i+=e[o],o++;for(t.push({type:"tag",text:i});o<r&&">"!==e[o]&&("/"!==e[o]||">"!==e[o+1]);)if(/\s/.test(e[o])){for(var s="";o<r&&/\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<r&&/[a-zA-Z0-9_\-@:]/.test(e[o]);)p+=e[o],o++;if(t.push({type:"attr-name",text:p}),o<r&&"="===e[o])if(t.push({type:"punctuation",text:"="}),++o<r&&('"'===e[o]||"'"===e[o])){var _=e[o],u=_;for(o++;o<r&&e[o]!==_;)u+=e[o],o++;o<r&&(u+=e[o],o++),t.push({type:"attr-value",text:u})}else{for(var f="";o<r&&!/[\s>]/.test(e[o]);)f+=e[o],o++;t.push({type:"attr-value",text:f})}}else c+=e[o],o++,n("plain");var b="";o<r&&"/"===e[o]&&(b+="/",o++),o<r&&">"===e[o]&&(b+=">",o++),b&&t.push({type:"tag",text:b})}else{n("plain");var w=e.indexOf("--\x3e",o+4);-1===w&&(w=r-3),t.push({type:"comment",text:e.substring(o,w+3)}),o=w+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){r[e]=!0});var l={js:c,javascript:c,css:n,html:a};function i(e,t){return function(e){for(var t=[],o=0;o<e.length;o++){var r=e[o];"plain"===r.type?t.push(r.text):t.push({t:"span",a:{class:"bw_ce_"+r.type},c:r.text})}return t}((l[t]||c)(e))}function s(e){var t=(e=e||{}).code||"",o=e.lang||"js",r=e.height||"180px",c=!!e.readOnly,n=!!e.lineNumbers,a="bw_ce"+(e.className?" "+e.className:""),l=i(t,o),s={spellcheck:"false",class:"bw_ce_code"};c||(s.contenteditable="true");var p=null;if(n){for(var _=(t.match(/\n/g)||[]).length+1,u=[],f=1;f<=_;f++)u.push({t:"span",c:String(f)});p={t:"div",a:{class:"bw_ce_gutter"},c:u}}var b={t:"pre",a:{style:"flex:1;min-width:0;margin:0"},c:{t:"code",a:s,c:l}};return{t:"div",a:{class:a,style:"max-height:"+r+";overflow:auto"},c:[n?{t:"div",a:{class:"bw_ce_wrap"},c:[p,b]}:b],o:{mounted:function(r){var a=r.querySelector(".bw_ce_code");if(a){var l=t,s=null,p=n?r.querySelector(".bw_ce_gutter"):null,_="undefined"!=typeof window&&window.bw||{};if(r._bwCodeEdit={getValue:f,setValue:function(e){l=e;var t=i(e,o);_.html&&(a.innerHTML=_.html({t:"span",c:t})),b(e)}},p){var u=a.closest(".bw_ce")||r;u.addEventListener("scroll",function(){p.style.transform="translateY("+-u.scrollTop+"px)"}),r.addEventListener("scroll",function(){p.style.transform="translateY("+-r.scrollTop+"px)"})}c||(a.addEventListener("input",function(){clearTimeout(s),s=setTimeout(w,50)}),a.addEventListener("keydown",function(e){"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," "))}))}function f(){return a.textContent||""}function b(e){if(p){for(var t=(e.match(/\n/g)||[]).length+1,o="",r=1;r<=t;r++)o+="<span>"+r+"</span>";p.innerHTML=o}}function w(){var t=f();if(t!==l){l=t;var r=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}(a),c=i(t,o);_.html&&(a.innerHTML=_.html({t:"span",c:c})),function(e,t){for(var o,r=window.getSelection(),c=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 c.setStart(o,t-a),c.collapse(!0),r.removeAllRanges(),void r.addRange(c);a+=l}c.selectNodeContents(e),c.collapse(!1),r.removeAllRanges(),r.addRange(c)}(a,r),b(t),e.onChange&&e.onChange(t)}}}}}}function p(e){e&&(e.highlight=i,e.codeEditor=function(r){return function(e){t||(t=!0,e&&e.injectCSS&&e.injectCSS(o,{id:"bw_code_edit_styles"}))}(e),s(r)})}"undefined"!=typeof window&&window.bw&&p(window.bw);var _={highlight:i,codeEditor:s,install:p,CSS_TEXT:o};e.CSS_TEXT=o,e.codeEditor=s,e.default=_,e.highlight=i,e.install=p,e.tokenizeCSS=n,e.tokenizeHTML=a,e.tokenizeJS=c,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
19
|
+
*/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}.bw_ce_wrap{display:flex;flex-direction:row}.bw_ce_gutter{flex:0 0 auto;padding:0.75rem 0;text-align:right;user-select:none;-webkit-user-select:none;color:#546e7a;font-family:"SF Mono",Monaco,"Cascadia Code",Consolas,monospace;font-size:0.875rem;line-height:1.6;border-right:1px solid rgba(255,255,255,0.08);overflow:hidden}.bw_ce_gutter span{display:block;padding:0 0.5rem 0 0.75rem}.bw_ce_light .bw_ce_gutter{color:#9ca3af;border-right-color:#d8d8d8}';var r={};function c(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,_=!1;if(a.trim().length||p&&"operator"!==p.type&&"punctuation"!==p.type&&"keyword"!==p.type||(_=!0),_){l("plain");for(var u="/",f=o+1,b=!1,w=!1;f<n;){var d=e[f];if(b)u+=d,b=!1,f++;else if("\\"!==d)if("["!==d)if("]"!==d){if("/"===d&&!w){u+=d,f++;break}if("\n"===d)break;u+=d,f++}else w=!1,u+=d,f++;else w=!0,u+=d,f++;else b=!0,u+=d,f++}for(;f<n&&/[gimsuvy]/.test(e[f]);)u+=e[f],f++;t.push({type:"string",text:u}),o=f;continue}}if('"'!==i&&"'"!==i&&"`"!==i)if(/[0-9]/.test(i)||"."===i&&s&&/[0-9]/.test(s)){l("plain");var h="";if("0"===i&&s&&/[xXbBoO]/.test(s))for(h=i+s,o+=2;o<n&&/[0-9a-fA-F_]/.test(e[o]);)h+=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])?(h+=e[o],o++):(h+=e[o]+e[o+1],o+=2);t.push({type:"number",text:h})}else if(/[a-zA-Z_$]/.test(i)){l("plain");for(var g="";o<n&&/[a-zA-Z0-9_$]/.test(e[o]);)g+=e[o],o++;for(var v=o;v<n&&(" "===e[v]||"\t"===e[v]);)v++;var y=t.length?t[t.length-1]:null,x=y&&"punctuation"===y.type&&"."===y.text;r[g]?t.push({type:"keyword",text:g}):x?v<n&&"("===e[v]?t.push({type:"function",text:g}):t.push({type:"property",text:g}):v<n&&"("===e[v]?t.push({type:"function",text:g}):t.push({type:"plain",text:g})}else if(-1==="=+-*/%!<>&|^~?:".indexOf(i))-1==="(){}[];,.".indexOf(i)?(a+=i,o++):(l("plain"),t.push({type:"punctuation",text:i}),o++);else{l("plain");var m=i;++o<n&&-1!=="=+-*/%!<>&|^~?:".indexOf(e[o])&&(m+=e[o],++o<n&&-1!=="=>&|".indexOf(e[o])&&(m+=e[o],o++)),t.push({type:"operator",text:m})}else{l("plain");var k=i,C=i,S=o+1;if("`"===k){for(;S<n;){var T=e[S];if("\\"!==T)if("$"!==T||"{"!==e[S+1]){if("`"===T){C+=T,S++;break}C+=T,S++}else{C.length&&t.push({type:"string",text:C}),C="",t.push({type:"template-interp",text:"${"}),S+=2;for(var E=1,A="";S<n&&E>0;){if("{"===e[S])E++;else if("}"===e[S]&&0===--E)break;A+=e[S],S++}var z=c(A);(t=t.concat(z)).push({type:"template-interp",text:"}"}),S++}else C+=T+(e[S+1]||""),S+=2}C.length&&t.push({type:"string",text:C})}else{for(;S<n;){var O=e[S];if("\\"!==O){if(O===k){C+=O,S++;break}if("\n"===O)break;C+=O,S++}else C+=O+(e[S+1]||""),S+=2}t.push({type:"string",text:C})}o=S}}else{l("plain");var M=e.indexOf("*/",o+2);-1===M&&(M=n-2),t.push({type:"comment",text:e.substring(o,M+2)}),o=M+2}else{l("plain");var R=e.indexOf("\n",o);-1===R&&(R=n),t.push({type:"comment",text:e.substring(o,R)}),o=R}}return l("plain"),t}function n(e){var t=[],o=0,r=e.length,c="selector",n="";function a(e){n.length&&(t.push({type:e||"plain",text:n}),n="")}for(;o<r;){var l=e[o],i=e[o+1];if("/"!==l||"*"!==i)if('"'!==l&&"'"!==l||"value"!==c&&"selector"!==c)if("@"!==l||"selector"!==c)if("#"!==l||"value"!==c)if("value"===c&&/[0-9]/.test(l)){a("css-value");for(var s="";o<r&&/[0-9.]/.test(e[o]);)s+=e[o],o++;for(var p="";o<r&&/[a-zA-Z%]/.test(e[o]);)p+=e[o],o++;t.push({type:"number",text:s+p})}else"{"!==l?"}"!==l?":"!==l||"prop"!==c?";"!==l?","!==l?(n+=l,o++):(a("selector"===c?"selector":"value"===c?"css-value":"plain"),t.push({type:"punctuation",text:l}),o++):(a("value"===c?"css-value":"plain"),t.push({type:"punctuation",text:l}),c="prop",o++):(a("css-prop"),t.push({type:"punctuation",text:l}),c="value",o++):(a("prop"===c?"css-prop":"value"===c?"css-value":"plain"),t.push({type:"punctuation",text:l}),c="selector",o++):(a("selector"===c?"selector":"plain"),t.push({type:"punctuation",text:l}),c="prop",o++);else{a("css-value");var _="#";for(o++;o<r&&/[0-9a-fA-F]/.test(e[o]);)_+=e[o],o++;t.push({type:"color",text:_})}else{a("selector");var u="@";for(o++;o<r&&/[a-zA-Z\-]/.test(e[o]);)u+=e[o],o++;t.push({type:"at-rule",text:u})}else{a("selector"===c?"selector":"css-value");var f=l,b=l;for(o++;o<r;)if("\\"!==e[o]){if(e[o]===f){b+=e[o],o++;break}b+=e[o],o++}else b+=e[o]+(e[o+1]||""),o+=2;t.push({type:"string",text:b})}else{a("selector"===c?"selector":"prop"===c?"css-prop":"css-value");var w=e.indexOf("*/",o+2);-1===w&&(w=r-2),t.push({type:"comment",text:e.substring(o,w+2)}),o=w+2}}return a("selector"===c?"selector":"prop"===c?"css-prop":"css-value"),t}function a(e){var t=[],o=0,r=e.length,c="";function n(e){c.length&&(t.push({type:e,text:c}),c="")}for(;o<r;){var a=e[o];if("<"!==a||"\x3c!--"!==e.substring(o,o+4))if("<"!==a)if("&"!==a)c+=a,o++;else{n("plain");var l="&";for(o++;o<r&&";"!==e[o]&&/[a-zA-Z0-9#]/.test(e[o]);)l+=e[o],o++;o<r&&";"===e[o]&&(l+=";",o++),t.push({type:"string",text:l})}else{n("plain");var i="<";for(++o<r&&"/"===e[o]&&(i+="/",o++);o<r&&/[a-zA-Z0-9\-]/.test(e[o]);)i+=e[o],o++;for(t.push({type:"tag",text:i});o<r&&">"!==e[o]&&("/"!==e[o]||">"!==e[o+1]);)if(/\s/.test(e[o])){for(var s="";o<r&&/\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<r&&/[a-zA-Z0-9_\-@:]/.test(e[o]);)p+=e[o],o++;if(t.push({type:"attr-name",text:p}),o<r&&"="===e[o])if(t.push({type:"punctuation",text:"="}),++o<r&&('"'===e[o]||"'"===e[o])){var _=e[o],u=_;for(o++;o<r&&e[o]!==_;)u+=e[o],o++;o<r&&(u+=e[o],o++),t.push({type:"attr-value",text:u})}else{for(var f="";o<r&&!/[\s>]/.test(e[o]);)f+=e[o],o++;t.push({type:"attr-value",text:f})}}else c+=e[o],o++,n("plain");var b="";o<r&&"/"===e[o]&&(b+="/",o++),o<r&&">"===e[o]&&(b+=">",o++),b&&t.push({type:"tag",text:b})}else{n("plain");var w=e.indexOf("--\x3e",o+4);-1===w&&(w=r-3),t.push({type:"comment",text:e.substring(o,w+3)}),o=w+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){r[e]=!0});var l={js:c,javascript:c,css:n,html:a};function i(e,t){return function(e){for(var t=[],o=0;o<e.length;o++){var r=e[o];"plain"===r.type?t.push(r.text):t.push({t:"span",a:{class:"bw_ce_"+r.type},c:r.text})}return t}((l[t]||c)(e))}function s(e){var t=(e=e||{}).code||"",o=e.lang||"js",r=e.height||"180px",c=!!e.readOnly,n=!!e.lineNumbers,a="bw_ce"+(e.className?" "+e.className:""),l=i(t,o),s={spellcheck:"false",class:"bw_ce_code"};c||(s.contenteditable="true");var p=null;if(n){for(var _=(t.match(/\n/g)||[]).length+1,u=[],f=1;f<=_;f++)u.push({t:"span",c:String(f)});p={t:"div",a:{class:"bw_ce_gutter"},c:u}}var b={t:"pre",a:{style:"flex:1;min-width:0;margin:0"},c:{t:"code",a:s,c:l}};return{t:"div",a:{class:a,style:"max-height:"+r+";overflow:auto"},c:[n?{t:"div",a:{class:"bw_ce_wrap"},c:[p,b]}:b],o:{mounted:function(r){var a=r.querySelector(".bw_ce_code");if(a){var l=t,s=null,p=n?r.querySelector(".bw_ce_gutter"):null,_="undefined"!=typeof window&&window.bw||{};if(r._bwCodeEdit={getValue:f,setValue:function(e){l=e;var t=i(e,o);_.html&&(a.innerHTML=_.html({t:"span",c:t})),b(e)}},p){var u=a.closest(".bw_ce")||r;u.addEventListener("scroll",function(){p.style.transform="translateY("+-u.scrollTop+"px)"}),r.addEventListener("scroll",function(){p.style.transform="translateY("+-r.scrollTop+"px)"})}c||(a.addEventListener("input",function(){clearTimeout(s),s=setTimeout(w,50)}),a.addEventListener("keydown",function(e){"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertText",!1," "))}))}function f(){return a.textContent||""}function b(e){if(p){for(var t=(e.match(/\n/g)||[]).length+1,o="",r=1;r<=t;r++)o+="<span>"+r+"</span>";p.innerHTML=o}}function w(){var t=f();if(t!==l){l=t;var r=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}(a),c=i(t,o);_.html&&(a.innerHTML=_.html({t:"span",c:c})),function(e,t){for(var o,r=window.getSelection(),c=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 c.setStart(o,t-a),c.collapse(!0),r.removeAllRanges(),void r.addRange(c);a+=l}c.selectNodeContents(e),c.collapse(!1),r.removeAllRanges(),r.addRange(c)}(a,r),b(t),e.onChange&&e.onChange(t)}}}}}}function p(e){e&&(e.highlight=i,e.codeEditor=function(r){return function(e){t||(t=!0,e&&e.injectCSS&&e.injectCSS(o,{id:"bw_code_edit_styles"}))}(e),s(r)})}"undefined"!=typeof window&&window.bw&&p(window.bw);var _={highlight:i,codeEditor:s,install:p,CSS_TEXT:o};e.CSS_TEXT=o,e.codeEditor=s,e.default=_,e.highlight=i,e.install=p,e.tokenizeCSS=n,e.tokenizeHTML=a,e.tokenizeJS=c,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
22
20
|
//# sourceMappingURL=bitwrench-code-edit.umd.min.js.map
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/*! bitwrench-debug v2.0.19 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
|
|
2
|
+
(function (global, factory) {
|
|
3
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
5
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bwd = factory());
|
|
6
|
+
})(this, (function () { 'use strict';
|
|
7
|
+
|
|
8
|
+
function getDefaultExportFromCjs (x) {
|
|
9
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
var bitwrenchDebug = {exports: {}};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* bitwrench-debug.js -- Standalone debug toolkit for bitwrench pages.
|
|
16
|
+
*
|
|
17
|
+
* Installs window.bwd with helper functions ported from bwcli attach:
|
|
18
|
+
* bwd.tree(sel, depth) -- print DOM tree to console
|
|
19
|
+
* bwd.listen(sel, event) -- delegated event logging
|
|
20
|
+
* bwd.unlisten(sel, event) -- remove event listener
|
|
21
|
+
* bwd.state(sel?) -- dump stateful elements via console.table
|
|
22
|
+
* bwd.screenshot(sel?) -- capture screenshot via html2canvas
|
|
23
|
+
*
|
|
24
|
+
* NOT bundled into bitwrench core. Load separately via script tag or
|
|
25
|
+
* console paste. Auto-loads bitwrench from CDN if not present.
|
|
26
|
+
*
|
|
27
|
+
* @module bitwrench-debug
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
(function (module) {
|
|
31
|
+
(function() {
|
|
32
|
+
|
|
33
|
+
var CDN_BW = 'https://cdn.jsdelivr.net/npm/bitwrench@2/dist/bitwrench.umd.min.js';
|
|
34
|
+
var CDN_H2C = 'https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js';
|
|
35
|
+
var _listeners = {};
|
|
36
|
+
|
|
37
|
+
function _loadScript(url) {
|
|
38
|
+
return new Promise(function(resolve, reject) {
|
|
39
|
+
var s = document.createElement('script');
|
|
40
|
+
s.src = url;
|
|
41
|
+
s.onload = function() { resolve(); };
|
|
42
|
+
s.onerror = function() { reject(new Error('Failed to load ' + url)); };
|
|
43
|
+
document.head.appendChild(s);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// -- tree -------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
function _walk(el, depth, maxDepth) {
|
|
50
|
+
if (!el || depth > maxDepth) return null;
|
|
51
|
+
var info = { tag: el.tagName ? el.tagName.toLowerCase() : '#text' };
|
|
52
|
+
if (el.id) info.id = el.id;
|
|
53
|
+
if (el.className && typeof el.className === 'string') {
|
|
54
|
+
info.cls = el.className.split(' ').slice(0, 5).join(' ');
|
|
55
|
+
}
|
|
56
|
+
if (el.children && el.children.length > 0 && depth < maxDepth) {
|
|
57
|
+
info.children = [];
|
|
58
|
+
for (var i = 0; i < Math.min(el.children.length, 20); i++) {
|
|
59
|
+
var c = _walk(el.children[i], depth + 1, maxDepth);
|
|
60
|
+
if (c) info.children.push(c);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return info;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function _print(node, indent) {
|
|
67
|
+
if (!node) return;
|
|
68
|
+
var label = node.tag || '?';
|
|
69
|
+
if (node.id) label += '#' + node.id;
|
|
70
|
+
if (node.cls) label += '.' + node.cls.split(' ').join('.');
|
|
71
|
+
console.log(' '.repeat(indent) + label);
|
|
72
|
+
if (node.children) {
|
|
73
|
+
for (var i = 0; i < node.children.length; i++) {
|
|
74
|
+
_print(node.children[i], indent + 1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Print an indented DOM tree to the console.
|
|
81
|
+
* @param {string} [sel='body'] - CSS selector for the root element
|
|
82
|
+
* @param {number} [depth=3] - Max depth to walk
|
|
83
|
+
* @returns {object|null} The tree data structure
|
|
84
|
+
*/
|
|
85
|
+
function tree(sel, depth) {
|
|
86
|
+
sel = sel || 'body';
|
|
87
|
+
depth = depth || 3;
|
|
88
|
+
var root = document.querySelector(sel);
|
|
89
|
+
if (!root) {
|
|
90
|
+
console.log('(no element found for "' + sel + '")');
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
var data = _walk(root, 0, depth);
|
|
94
|
+
_print(data, 0);
|
|
95
|
+
return data;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// -- listen / unlisten ------------------------------------------------------
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Add a delegated event listener that logs matching events to the console.
|
|
102
|
+
* @param {string} sel - CSS selector to match via closest()
|
|
103
|
+
* @param {string} event - DOM event name (e.g. 'click')
|
|
104
|
+
*/
|
|
105
|
+
function listen(sel, event) {
|
|
106
|
+
var key = sel + ':::' + event;
|
|
107
|
+
if (_listeners[key]) {
|
|
108
|
+
console.log('[bwd] already listening for ' + event + ' on ' + sel);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
var fn = function(e) {
|
|
112
|
+
var el = e.target.closest ? e.target.closest(sel) : null;
|
|
113
|
+
if (!el) return;
|
|
114
|
+
console.log('[bwd] ' + event + ' on ' + sel + ' -> ' +
|
|
115
|
+
el.tagName + (el.id ? '#' + el.id : '') +
|
|
116
|
+
(el.textContent ? ' "' + el.textContent.slice(0, 50).trim() + '"' : ''));
|
|
117
|
+
};
|
|
118
|
+
document.addEventListener(event, fn, true);
|
|
119
|
+
_listeners[key] = { fn: fn, event: event };
|
|
120
|
+
console.log('[bwd] listening for ' + event + ' on ' + sel);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Remove a previously added delegated event listener.
|
|
125
|
+
* @param {string} sel - CSS selector used in listen()
|
|
126
|
+
* @param {string} event - DOM event name used in listen()
|
|
127
|
+
*/
|
|
128
|
+
function unlisten(sel, event) {
|
|
129
|
+
var key = sel + ':::' + event;
|
|
130
|
+
var entry = _listeners[key];
|
|
131
|
+
if (!entry) {
|
|
132
|
+
console.log('[bwd] no listener for ' + event + ' on ' + sel);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
document.removeEventListener(entry.event, entry.fn, true);
|
|
136
|
+
delete _listeners[key];
|
|
137
|
+
console.log('[bwd] stopped listening for ' + event + ' on ' + sel);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// -- state ------------------------------------------------------------------
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Dump all stateful (.bw_lc) elements and their _bw_state via console.table.
|
|
144
|
+
* @param {string} [sel='.bw_lc'] - CSS selector to query
|
|
145
|
+
* @returns {Array} Array of {id, uuid, state} objects
|
|
146
|
+
*/
|
|
147
|
+
function state(sel) {
|
|
148
|
+
sel = sel || '.bw_lc';
|
|
149
|
+
var els = document.querySelectorAll(sel);
|
|
150
|
+
var rows = [];
|
|
151
|
+
for (var i = 0; i < els.length; i++) {
|
|
152
|
+
var el = els[i];
|
|
153
|
+
var uuid = '';
|
|
154
|
+
if (typeof window !== 'undefined' && window.bw && window.bw.getUUID) {
|
|
155
|
+
uuid = window.bw.getUUID(el) || '';
|
|
156
|
+
}
|
|
157
|
+
rows.push({
|
|
158
|
+
id: el.id || '',
|
|
159
|
+
uuid: uuid,
|
|
160
|
+
state: el._bw_state || null
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (rows.length === 0) {
|
|
164
|
+
console.log('[bwd] no stateful elements found for "' + sel + '"');
|
|
165
|
+
} else if (typeof console.table === 'function') {
|
|
166
|
+
console.table(rows);
|
|
167
|
+
} else {
|
|
168
|
+
console.log(rows);
|
|
169
|
+
}
|
|
170
|
+
return rows;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// -- screenshot -------------------------------------------------------------
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Capture a screenshot via html2canvas and trigger a download.
|
|
177
|
+
* Loads html2canvas from CDN if not present.
|
|
178
|
+
* @param {string} [sel='body'] - CSS selector for the element to capture
|
|
179
|
+
* @returns {Promise} Resolves when screenshot is saved
|
|
180
|
+
*/
|
|
181
|
+
function screenshot(sel) {
|
|
182
|
+
sel = sel || 'body';
|
|
183
|
+
var el = document.querySelector(sel);
|
|
184
|
+
if (!el) {
|
|
185
|
+
console.log('[bwd] no element found for "' + sel + '"');
|
|
186
|
+
return Promise.resolve(null);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
var p = (typeof window !== 'undefined' && window.html2canvas)
|
|
190
|
+
? Promise.resolve(window.html2canvas)
|
|
191
|
+
: _loadScript(CDN_H2C).then(function() { return window.html2canvas; });
|
|
192
|
+
|
|
193
|
+
return p.then(function(h2c) {
|
|
194
|
+
console.log('[bwd] capturing ' + sel + ' ...');
|
|
195
|
+
return h2c(el, { useCORS: true });
|
|
196
|
+
}).then(function(canvas) {
|
|
197
|
+
var filename = 'screenshot-' + Date.now() + '.png';
|
|
198
|
+
canvas.toBlob(function(blob) {
|
|
199
|
+
if (typeof window !== 'undefined' && window.bw && window.bw.saveClientFile) {
|
|
200
|
+
window.bw.saveClientFile(filename, blob);
|
|
201
|
+
} else {
|
|
202
|
+
// Fallback: create a download link
|
|
203
|
+
var a = document.createElement('a');
|
|
204
|
+
a.href = URL.createObjectURL(blob);
|
|
205
|
+
a.download = filename;
|
|
206
|
+
a.click();
|
|
207
|
+
URL.revokeObjectURL(a.href);
|
|
208
|
+
}
|
|
209
|
+
console.log('[bwd] saved: ' + filename);
|
|
210
|
+
});
|
|
211
|
+
}).catch(function(err) {
|
|
212
|
+
console.error('[bwd] screenshot failed: ' + err.message);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// -- init -------------------------------------------------------------------
|
|
217
|
+
|
|
218
|
+
var bwd = {
|
|
219
|
+
tree: tree,
|
|
220
|
+
listen: listen,
|
|
221
|
+
unlisten: unlisten,
|
|
222
|
+
state: state,
|
|
223
|
+
screenshot: screenshot,
|
|
224
|
+
_listeners: _listeners
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// Expose for testing in Node (module.exports) or browser (window.bwd)
|
|
228
|
+
if (module.exports) {
|
|
229
|
+
module.exports = bwd;
|
|
230
|
+
}
|
|
231
|
+
if (typeof window !== 'undefined') {
|
|
232
|
+
window.bwd = bwd;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function _printReady() {
|
|
236
|
+
console.log('[bwd] bitwrench debug toolkit ready');
|
|
237
|
+
console.log(' bwd.tree(sel?, depth?) -- print DOM tree');
|
|
238
|
+
console.log(' bwd.listen(sel, event) -- log events');
|
|
239
|
+
console.log(' bwd.unlisten(sel, event) -- stop logging');
|
|
240
|
+
console.log(' bwd.state(sel?) -- dump stateful elements');
|
|
241
|
+
console.log(' bwd.screenshot(sel?) -- capture screenshot');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Auto-load bitwrench from CDN if not present
|
|
245
|
+
if (typeof window !== 'undefined') {
|
|
246
|
+
if (window.bw && window.bw.version) {
|
|
247
|
+
_printReady();
|
|
248
|
+
} else {
|
|
249
|
+
console.log('[bwd] bitwrench not detected, loading from CDN...');
|
|
250
|
+
_loadScript(CDN_BW).then(function() {
|
|
251
|
+
_printReady();
|
|
252
|
+
}).catch(function(err) {
|
|
253
|
+
console.warn('[bwd] could not load bitwrench: ' + err.message);
|
|
254
|
+
console.log('[bwd] toolkit ready (limited -- bw.* not available)');
|
|
255
|
+
console.log(' bwd.tree, bwd.listen, bwd.unlisten still work');
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
})();
|
|
260
|
+
} (bitwrenchDebug));
|
|
261
|
+
|
|
262
|
+
var bitwrenchDebugExports = bitwrenchDebug.exports;
|
|
263
|
+
var bitwrenchDebug_default = /*@__PURE__*/getDefaultExportFromCjs(bitwrenchDebugExports);
|
|
264
|
+
|
|
265
|
+
return bitwrenchDebug_default;
|
|
266
|
+
|
|
267
|
+
}));
|
|
268
|
+
//# sourceMappingURL=bitwrench-debug.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! bitwrench-debug v2.0.19 | BSD-2-Clause | https://deftio.github.com/bitwrench/pages */
|
|
2
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).bwd=n()}(this,function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n={exports:{}};return function(e){!function(){var n={};function o(e){return new Promise(function(n,o){var t=document.createElement("script");t.src=e,t.onload=function(){n()},t.onerror=function(){o(new Error("Failed to load "+e))},document.head.appendChild(t)})}function t(e,n,o){if(!e||n>o)return null;var l={tag:e.tagName?e.tagName.toLowerCase():"#text"};if(e.id&&(l.id=e.id),e.className&&"string"==typeof e.className&&(l.cls=e.className.split(" ").slice(0,5).join(" ")),e.children&&e.children.length>0&&n<o){l.children=[];for(var i=0;i<Math.min(e.children.length,20);i++){var r=t(e.children[i],n+1,o);r&&l.children.push(r)}}return l}function l(e,n){if(e){var o=e.tag||"?";if(e.id&&(o+="#"+e.id),e.cls&&(o+="."+e.cls.split(" ").join(".")),console.log(" ".repeat(n)+o),e.children)for(var t=0;t<e.children.length;t++)l(e.children[t],n+1)}}var i={tree:function(e,n){e=e||"body",n=n||3;var o=document.querySelector(e);if(!o)return console.log('(no element found for "'+e+'")'),null;var i=t(o,0,n);return l(i,0),i},listen:function(e,o){var t=e+":::"+o;if(n[t])console.log("[bwd] already listening for "+o+" on "+e);else{var l=function(n){var t=n.target.closest?n.target.closest(e):null;t&&console.log("[bwd] "+o+" on "+e+" -> "+t.tagName+(t.id?"#"+t.id:"")+(t.textContent?' "'+t.textContent.slice(0,50).trim()+'"':""))};document.addEventListener(o,l,!0),n[t]={fn:l,event:o},console.log("[bwd] listening for "+o+" on "+e)}},unlisten:function(e,o){var t=e+":::"+o,l=n[t];l?(document.removeEventListener(l.event,l.fn,!0),delete n[t],console.log("[bwd] stopped listening for "+o+" on "+e)):console.log("[bwd] no listener for "+o+" on "+e)},state:function(e){e=e||".bw_lc";for(var n=document.querySelectorAll(e),o=[],t=0;t<n.length;t++){var l=n[t],i="";"undefined"!=typeof window&&window.bw&&window.bw.getUUID&&(i=window.bw.getUUID(l)||""),o.push({id:l.id||"",uuid:i,state:l._bw_state||null})}return 0===o.length?console.log('[bwd] no stateful elements found for "'+e+'"'):"function"==typeof console.table?console.table(o):console.log(o),o},screenshot:function(e){e=e||"body";var n=document.querySelector(e);return n?("undefined"!=typeof window&&window.html2canvas?Promise.resolve(window.html2canvas):o("https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js").then(function(){return window.html2canvas})).then(function(o){return console.log("[bwd] capturing "+e+" ..."),o(n,{useCORS:!0})}).then(function(e){var n="screenshot-"+Date.now()+".png";e.toBlob(function(e){if("undefined"!=typeof window&&window.bw&&window.bw.saveClientFile)window.bw.saveClientFile(n,e);else{var o=document.createElement("a");o.href=URL.createObjectURL(e),o.download=n,o.click(),URL.revokeObjectURL(o.href)}console.log("[bwd] saved: "+n)})}).catch(function(e){console.error("[bwd] screenshot failed: "+e.message)}):(console.log('[bwd] no element found for "'+e+'"'),Promise.resolve(null))},_listeners:n};function r(){console.log("[bwd] bitwrench debug toolkit ready"),console.log(" bwd.tree(sel?, depth?) -- print DOM tree"),console.log(" bwd.listen(sel, event) -- log events"),console.log(" bwd.unlisten(sel, event) -- stop logging"),console.log(" bwd.state(sel?) -- dump stateful elements"),console.log(" bwd.screenshot(sel?) -- capture screenshot")}e.exports&&(e.exports=i),"undefined"!=typeof window&&(window.bwd=i),"undefined"!=typeof window&&(window.bw&&window.bw.version?r():(console.log("[bwd] bitwrench not detected, loading from CDN..."),o("https://cdn.jsdelivr.net/npm/bitwrench@2/dist/bitwrench.umd.min.js").then(function(){r()}).catch(function(e){console.warn("[bwd] could not load bitwrench: "+e.message),console.log("[bwd] toolkit ready (limited -- bw.* not available)"),console.log(" bwd.tree, bwd.listen, bwd.unlisten still work")})))}()}(n),e(n.exports)});
|
|
3
|
+
//# sourceMappingURL=bitwrench-debug.min.js.map
|