update bitty to 6.0.0-rc1
This commit is contained in:
4 files changed
+5
-5
No files matched your search
+1
-1
@@ -74,7 +74,7 @@ Repo: https://github.com/emcconville/wand
|
||||
|
||||
## Bitty
|
||||
|
||||
Affected files: [`data/static/js/vnd/bitty-5.1.0-rc6.min.js`](./data/static/js/vnd/bitty-5.1.0-rc6.min.js)
|
||||
Affected files: [`data/static/js/vnd/bitty-6.0.0-rc1.min.js`](./data/static/js/vnd/bitty-6.0.0-rc1.min.js)
|
||||
URL: https://bitty.alanwsmith.com/
|
||||
Copyright: `Copyright (c) 2025 Alan Smith - https://www.alanwsmith.com/`
|
||||
License: MIT
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
{% endif %}
|
||||
<link rel="stylesheet" href="{{ ("/static/css/%s.css" % get_prefers_theme()) | cachebust }}">
|
||||
<link rel="icon" type="image/png" href="/static/favicon.png">
|
||||
<script src="/static/js/vnd/bitty-5.1.0-rc6.min.js" type="module"></script>
|
||||
<script src="/static/js/vnd/bitty-6.0.0-rc1.min.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
<bitty-5-1 data-connect="/static/js/bitties/pyrom-bitty.js">
|
||||
<bitty-6-0 data-connect="/static/js/bitties/pyrom-bitty.js">
|
||||
{% include 'common/topnav.html' %}
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
@@ -26,7 +26,7 @@
|
||||
<footer class="darkbg">
|
||||
<span>Pyrom commit <a href="{{ "https://git.poto.cafe/yagich/pyrom/commit/" + __commit }}">{{ __commit[:8] }}</a></span>
|
||||
</footer>
|
||||
</bitty-5-1>
|
||||
</bitty-6-0>
|
||||
<script src="{{ "/static/js/ui.js" | cachebust }}"></script>
|
||||
<script src="{{ "/static/js/date-fmt.js" | cachebust }}"></script>
|
||||
</body>
|
||||
-1
@@ -1 +0,0 @@
|
||||
const t=[5,1,0],e=`bitty-${t[0]}-${t[1]}`,n=new CSSStyleSheet;n.replaceSync(`${e} { display: block; }`),document.adoptedStyleSheets.push(n);class s extends Error{constructor(t){super(),Error.captureStackTrace&&Error.captureStackTrace(this,s),this.name="BittyError";for(let[e,n]of Object.entries(t))this[e]=n}}class i extends Event{constructor(t,e){super("bittyforward",{bubbles:!0}),this.fEvent=t,this.fSignal=e}}class a extends Event{constructor(t){super("bittytrigger",{bubbles:!0}),this.fSignal=t}}class o extends HTMLElement{constructor(){super(),this.config={listeners:["click","input"],license:"MIT",version:t}}async connectedCallback(){this.dataset.bittyid=self.crypto.randomUUID(),await this.makeConnection(),this.conn&&(this.conn.api=this,this.handleCatchBridge=this.handleCatch.bind(this),this.handleEventBridge=this.handleEvent.bind(this),this.setIds(this),this.addEventListeners(),await this.callBittyInit(),this.runElementDataInits(),this.runSendFromComponent(),await this.callBittyReady())}addEventListeners(){["bittyforward","bittytrigger"].forEach(t=>{document.addEventListener(t,t=>{this.handleEventBridge.call(this,t)})}),this.dataset.listeners&&(this.config.listeners=this.dataset.listeners.split(/\s+/m).map(t=>t.trim())),this.config.listeners.forEach(t=>{document.addEventListener(t,t=>{t.target&&t.target.nodeName&&t.target.nodeName.toLowerCase()!==e&&t.target.dataset&&t.target.dataset.send?this.handleEventBridge.call(this,t):this.handleCatchBridge.call(this,t)})})}async callBittyInit(){"function"==typeof this.conn.bittyInit&&("AsyncFunction"===this.conn.bittyInit[Symbol.toStringTag]?await this.conn.bittyInit():this.conn.bittyInit())}async callBittyReady(){"function"==typeof this.conn.bittyReady&&("AsyncFunction"===this.conn.bittyReady[Symbol.toStringTag]?await this.conn.bittyReady():this.conn.bittyReady())}connectedMoveCallback(){}doSubs(t,e){return e.forEach(e=>{const n=typeof e[1],s=Object.prototype.toString.call(e[1]);if("object"===n&&"[object Array]"===s){const n=e[1].map(t=>{const e=typeof t,n=Object.prototype.toString.call(t);return"object"===e&&"[object DocumentFragment]"===n?[...t.childNodes].map(t=>"[object Text]"===Object.prototype.toString.call(t)?t.wholeText:t.outerHTML).join(""):"object"===e?t.outerHTML:t}).join("");t=t.replaceAll(e[0],n)}else if("object"===n&&"[object DocumentFragment]"===s){const n=[];[...e[1].childNodes].forEach(t=>{"[object Text]"===Object.prototype.toString.call(t)?n.push(t.wholeText):n.push(t.outerHTML)}),t=t.replaceAll(e[0],n.join(""))}else t="object"==typeof e[1]?t.replaceAll(e[0],e[1].outerHTML):t.replaceAll(e[0],e[1])}),t}forward(t,e){const n=new i(t,e);this.dispatchEvent(n)}trigger(t){const e=new a(t);this.dispatchEvent(e)}async getElement(t,e=[],n={}){const s=await this.getHTML(t,e,n,"getElement");if(s.value){return{value:s.value.firstChild}}return s}async getHTML(t,e=[],n={}){const s=await this.getTXT(t,e,n,"getHTML");return s.error?s:{value:this.makeHTML(s.value,e)}}async getJSON(t,e=[],n={}){const i=await this.getTXT(t,e,n,"getJSON");if(i.error)return i;try{const t=JSON.parse(i.value);return{value:t}}catch(t){return{error:new s({type:"parsing"})}}}async getSVG(t,e=[],n={}){const s=await this.getTXT(t,e,n,"getSVG");if(s.error)return s;{const t=document.createElement("template");t.innerHTML=s.value;return{value:t.content.cloneNode(!0).querySelector("svg")}}}async getTXT(t,e=[],n={},i="getTXT"){let a=await fetch(t,n);try{if(a.ok){return{value:this.doSubs(await a.text(),e)}}throw new s({type:"fetching",message:`${i}() returned ${a.status} [${a.statusText}] in:\n${i}(${a.url}, ${JSON.stringify(e)}, ${JSON.stringify(n)})`,statusText:a.statusText,status:a.status,url:a.url,incomingMethod:i,subs:e,options:n})}catch(t){return console.error(`BittyError: ${t.message}`),{error:t}}}async handleCatch(t){"function"==typeof this.conn.bittyCatch&&await this.conn.bittyCatch(t)}async handleEvent(t){const e=this.querySelectorAll("[data-receive]");let n;"bittyforward"===t.type?(n=t.fSignal,t=t.fEvent):n="bittytrigger"===t.type?t.fSignal:t.target.dataset.send;for(const s of n.split(/\s+/)){let n=!1,i=s;const a=s.split(":");2===a.length&&"await"===a[0]&&(n=!0,i=a[1]);let o=!1;for(const s of e){const e=s.dataset.receive.split(/\s+/m);for(const a of e){let e=a;const r=a.split(":");2===r.length&&"await"===r[0]&&(e=r[1],n=!0),e===i&&this.conn[i]&&(n?await this.conn[i](t,s):this.conn[i](t,s),o=!0)}}!o&&this.conn[i]&&(n?await this.conn[i](t,null):this.conn[i](t,null))}}async loadCSS(t,e,n){const s=await this.getTXT(t,e,n,"loadCSS");if(s.error)return s;{const t=new CSSStyleSheet;t.replaceSync(s.value),document.adoptedStyleSheets.push(t);return{value:s.value}}}async makeConnection(){try{if(this.dataset.connect){const t=this.dataset.connect.split(/\s+/m).map(t=>t.trim());if(void 0!==window[t[0]])this.conn=new window[t[0]];else{const e=await import(t[0]);void 0===t[1]?this.conn=new e.default:this.conn=new e[t[1]]}}else window.BittyClass?this.conn=new window.BittyClass:console.error(`${e} error:
Line truncated
|
||||
+1
@@ -0,0 +1 @@
|
||||
const t=[6,0,0],e=`bitty-${t[0]}-${t[1]}`;class n extends Error{constructor(t){super(),Error.captureStackTrace&&Error.captureStackTrace(this,n),this.name="BittyError";for(let[e,n]of Object.entries(t))this[e]=n}}class i extends Event{constructor(){super("bittybittyinit",{bubbles:!0})}}class s extends Event{constructor(){super("bittybittyready",{bubbles:!0})}}class a extends Event{constructor(t,e){super("bittydatainit",{bubbles:!0}),this.signal=t,this.el=e}}class r extends Event{constructor(t,e){super("bittyforward",{bubbles:!0}),this.forwardedEvent=t,this.forwardedSignal=e}}class o extends Event{constructor(t){super("bittylocaltrigger",{bubbles:!0}),this.signal=t}}class c extends Event{constructor(t){super("bittytrigger",{bubbles:!0}),this.signal=t}}function l(t,e){return void 0!==t.dataset[e]?t.dataset[e]:t.parentNode?l(t.parentNode,e):null}class d extends HTMLElement{constructor(){super(),this.config={listeners:["click","input"],license:"CC0",version:t}}async connectedCallback(){this.dataset.bittyid=self.crypto.randomUUID(),this.style.display="block",await this.makeConnection(),this.conn&&(this.conn.api=this,this.handleEventBridge=this.handleEvent.bind(this),this.setIds(this),this.addEventListeners(),await this.runBittyInit(),this.runDataInits(),await this.runBittyReady())}addEventListeners(){const t=["bittybittyinit","bittybittyready","bittydatainit","bittyforward","bittylocaltrigger","bittytrigger"];this.dataset.listeners?this.trimInput(this.dataset.listeners).forEach(e=>{t.push(e)}):(t.push("click"),t.push("input")),t.forEach(t=>{window.addEventListener(t,t=>{this.handleEventBridge.call(this,t)})})}connectedMoveCallback(){}doSubs(t,e){return e.forEach(e=>{const n=typeof e[1],i=Object.prototype.toString.call(e[1]);if("object"===n&&"[object Array]"===i){const n=e[1].map(t=>{const e=typeof t,n=Object.prototype.toString.call(t);return"object"===e&&"[object DocumentFragment]"===n?[...t.childNodes].map(t=>"[object Text]"===Object.prototype.toString.call(t)?t.wholeText:t.outerHTML).join(""):"object"===e?t.outerHTML:t}).join("");t=t.replaceAll(e[0],n)}else if("object"===n&&"[object DocumentFragment]"===i){const n=[];[...e[1].childNodes].forEach(t=>{"[object Text]"===Object.prototype.toString.call(t)?n.push(t.wholeText):n.push(t.outerHTML)}),t=t.replaceAll(e[0],n.join(""))}else t="object"==typeof e[1]?t.replaceAll(e[0],e[1].outerHTML):t.replaceAll(e[0],e[1])}),t}forward(t,e){const n=new r(t,e);this.dispatchEvent(n)}getBittyParent(t){return t.localName.toLowerCase()===e?t:t.parentNode?this.getBittyParent(t.parentNode):null}async getElement(t,e=[],n={}){const i=await this.getHTML(t,e,n,"getElement");if(i.value){return{value:i.value.firstChild}}return i}async getHTML(t,e=[],n={}){const i=await this.getTXT(t,e,n,"getHTML");return i.error?i:{value:this.makeHTML(i.value,e)}}async getJSON(t,e=[],i={}){const s=await this.getTXT(t,e,i,"getJSON");if(s.error)return s;try{const t=JSON.parse(s.value);return{value:t}}catch(t){return{error:new n({type:"parsing"})}}}async getSVG(t,e=[],n={}){const i=await this.getTXT(t,e,n,"getSVG");if(i.error)return i;{const t=document.createElement("template");t.innerHTML=i.value;return{value:t.content.cloneNode(!0).querySelector("svg")}}}async getTXT(t,e=[],i={},s="getTXT"){let a=await fetch(t,i);try{if(a.ok){return{value:this.doSubs(await a.text(),e)}}throw new n({type:"fetching",message:`${s}() returned ${a.status} [${a.statusText}] in:\n${s}(${a.url}, ${JSON.stringify(e)}, ${JSON.stringify(i)})`,statusText:a.statusText,status:a.status,url:a.url,incomingMethod:s,subs:e,options:i})}catch(t){return console.error(`BittyError: ${t.message}`),{error:t}}}findSender(t,e){e.dataset&&e.dataset.send?t.sender=e:e.parentNode&&this.findSender(t,e.parentNode)}async handleEvent(t){if("bittybittyinit"===t.type)this.dataset.bittyid===t.target.dataset.bittyid&&"function"==typeof this.conn.bittyInit&&("AsyncFunction"===this.conn.bittyInit[Symbol.toStringTag]?await this.conn.bittyInit():this.conn.bittyInit());else if("bittybittyready"===t.type)this.dataset.bittyid===t.target.dataset.bittyid&&"function"==typeof this.conn.bittyReady&&("AsyncFunction"===this.conn.bittyReady[Symbol.toStringTag]?await this.conn.bittyReady():this.conn.bittyReady());else if("bittylocaltrigger"===t.type){t.sender=t.target;const e=this.trimInput(t.signal),n=this.querySelectorAll("[data-receive]");for(let i of e){let e=!1;const s=i.split(":");if(2===s.length&&"await"===s[0]&&(e=!0,i=s[1]),this.conn[i]){const s=this.getBittyParent(t.target);let a=!1;for(let r of n){const n=this.getBittyParent(r);if(s.dataset.bittyid===n.dataset.bittyid){const n=this.trimInput(r.dataset.receive);for(let s of n){const n=s.split(":");2===n.length&&"await"===n[0]&&(e=!0,s=n[1]),s===i&&(a=!0,this.prepElements(t,r),e?await this.conn[i](t,r):this.conn[i](t,r))}}}!1===a&&s.dataset.bittyid===this.dataset.bittyid&&(e?await this.conn[i](t,null):this.conn[i](t,null))}}}else if("bittytrigger"===t.type){t.sender=t.target;const e=this.trimInput(t.signal),n=this.queryLine truncated
|
||||
Reference in new issue
Block a user