@bangerpage/core 0.2.0-rc.1 → 0.2.1
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 +3 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/standalone.js +655 -0
- package/dist/standalone.js.LEGAL.txt +67 -0
- package/dist/standalone.js.map +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ The runtime for [Banger](https://github.com/bangerpage/banger): presentations wr
|
|
|
5
5
|
Load it from a CDN with the exact version, then write the deck with `bang-*` elements:
|
|
6
6
|
|
|
7
7
|
```html
|
|
8
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@bangerpage/core@0.2.
|
|
8
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@bangerpage/core@0.2.1/dist/index.js"></script>
|
|
9
9
|
<bang-root theme="light">
|
|
10
10
|
<bang-frame id="intro" at="0,0"><bang-title>Hello</bang-title></bang-frame>
|
|
11
11
|
<bang-path>
|
|
@@ -14,6 +14,8 @@ Load it from a CDN with the exact version, then write the deck with `bang-*` ele
|
|
|
14
14
|
</bang-root>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
`dist/standalone.js` is the same runtime in one file, with the lazy chunks inlined, for a deck that inlines the runtime or opens a saved copy offline.
|
|
18
|
+
|
|
17
19
|
The elements and their attributes are listed in `custom-elements.json` and in the repository's `skill/reference/components.md`. Opening a deck loads fonts from Google Fonts. Versions, themes and the CLI (`@bangerpage/cli`) are described in the repository README.
|
|
18
20
|
|
|
19
21
|
License: MIT. The package bundles Lit and Apache ECharts; see `THIRD-PARTY-LICENSES.txt` and `NOTICE`.
|
package/dist/index.js
CHANGED
|
@@ -328,7 +328,7 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
|
|
|
328
328
|
:host {
|
|
329
329
|
display: none;
|
|
330
330
|
}
|
|
331
|
-
`}render(){return null}};v("bang-theme",se);var me="0.2.
|
|
331
|
+
`}render(){return null}};v("bang-theme",se);var me="0.2.1";var ge=r=>r.id?`frame "${r.id}"`:k(r);function nt(r){let o=new Map;for(let e of r.querySelectorAll("*")){let t=e.localName;if(!t.startsWith("bang-")||customElements.get(t))continue;let n=o.get(t);n?n.count+=1:o.set(t,{selector:k(e),count:1})}return[...o].map(([e,{selector:t,count:n}])=>`${t}: <${e}> is not a Banger element${n>1?` (${n} times)`:""}; check the tag name`)}function rt(r){let o=[];for(let e=0;e<r.length;e++)for(let t=e+1;t<r.length;t++){let n=r[e].rect,s=r[t].rect;n.x<s.x+s.w&&s.x<n.x+n.w&&n.y<s.y+s.h&&s.y<n.y+n.h&&o.push(`${ge(r[e].el)} and ${ge(r[t].el)} overlap on the canvas; give them different at values`)}return o}function Ye(r,o,e){let t={x:0,y:0,worst:null},n=0;for(let s of r.querySelectorAll("*")){if(s.localName==="script"||s.localName==="style"||s.closest("bang-free")||getComputedStyle(s).display==="inline")continue;let a=s.getBoundingClientRect();if(a.width===0&&a.height===0)continue;let i=Math.max(0,(o.left-a.left)/e,(a.right-o.right)/e),l=Math.max(0,(o.top-a.top)/e,(a.bottom-o.bottom)/e);t.x=Math.max(t.x,i),t.y=Math.max(t.y,l),Math.max(i,l)>n&&(n=Math.max(i,l),t.worst=s)}return t}var et=r=>r.worst?` (furthest: ${k(r.worst)})`:"",tt=(r,o)=>[r>ce?`${Math.round(r)}px horizontally`:"",o>ce?`${Math.round(o)}px vertically`:""].filter(Boolean);function st(r){let o=[];for(let{el:e}of r){let t=e.shadowRoot?.querySelector(".frame");if(!t||e.offsetWidth===0)continue;let n=e.getBoundingClientRect(),s=n.width/e.offsetWidth,a=getComputedStyle(t),i={left:n.left+parseFloat(a.paddingLeft)*s,top:n.top+parseFloat(a.paddingTop)*s,right:n.right-parseFloat(a.paddingRight)*s,bottom:n.bottom-parseFloat(a.paddingBottom)*s},l=Ye(e,i,s),u=tt(Math.max(l.x,t.scrollWidth-t.clientWidth),Math.max(l.y,t.scrollHeight-t.clientHeight));u.length>0&&o.push(`${ge(e)}: the content does not fit inside the frame margins by ${u.join(", ")}${et(l)}; what passes the frame edge is cut off, so shorten it or use smaller sizes`);for(let c of e.querySelectorAll("bang-card")){let d=Ye(c,c.getBoundingClientRect(),s),g=tt(d.x,d.y);g.length>0&&o.push(`${k(c)}: the content sticks out of the card by ${g.join(", ")}${et(d)}; shorten it or use smaller sizes`)}}return o}function ot(r,o){let e=[],t=a=>X(a.getAttribute("lang"),o),n=k;for(let a of r.querySelectorAll("bang-frame, bang-stop"))t(a)&&e.push(`${n(a)}: lang is ignored on <${a.localName}>; the frames and stops are the same in every language`);for(let a of r.querySelectorAll("bang-frame, bang-frame *, bang-path > bang-stop")){let i=new Map;for(let l of a.children){let u=t(l);if(u){let c=i.get(l.localName)??new Map;c.set(u,(c.get(u)??0)+1),i.set(l.localName,c)}else{let c=l.getAttribute("lang");c&&e.push(`${n(l)}: lang="${c}" is not in languages (${o.join(" ")}); shown in every language`)}}for(let[l,u]of i){let c=o.map(d=>u.get(d)??0);c.some(d=>d!==c[0])&&e.push(`${n(a)}: <${l}> differs by language (${o.map((d,g)=>`${d}: ${c[g]}`).join(", ")}); give every language the same number of <${l}>`)}if(a.localName==="bang-columns"&&[...a.children].some(l=>t(l))&&e.push(`${n(a)}: <bang-columns> makes a column of every child, so a child with lang adds a column in every language; put lang on the content inside each column`),a.localName==="bang-frame"&&a.getAttribute("valign")!=="spread"){let l=[...a.children],u=l.filter(c=>!(c.localName==="bang-free"&&c.hasAttribute("overlay")));l[0]?.localName==="bang-title"&&(t(l[0])||u.length>0&&t(u[u.length-1]))&&e.push(`${n(a)}: the title or the last child of this frame carries lang, so the layout moves between languages; write the title's languages with <span lang> and put the translated elements inside a bang-stack without lang`)}}let s=[...r.querySelectorAll("bang-frame")];for(let a of s)for(let i of["crumb","label"]){if(!a.getAttribute(i)?.trim())continue;let l=o.slice(1).filter(u=>!a.getAttribute(`${i}-${u.toLowerCase()}`)?.trim());l.length>0&&e.push(`${n(a)}: ${i} has no ${l.map(u=>`${i}-${u.toLowerCase()}`).join(", ")}; the ${o[0]} text is shown in ${l.join(", ")}`)}for(let a of r.querySelectorAll("bang-path > bang-stop[focus]")){let i=s.find(c=>c.id===a.getAttribute("frame")),l=a.getAttribute("focus")?.trim();if(!l)continue;let u=i?.querySelector(`#${CSS.escape(l)}`)??null;for(let c=u;c&&c!==i;c=c.parentElement){let d=t(c);if(d){e.push(`${n(a)}: focus="${l}" points into lang="${d}" content, which is hidden in the other languages; put the id on an element without lang`);break}}}return e}var oe=class{constructor(){this.id=Math.random().toString(36).slice(2);this.channel=new BroadcastChannel(`bang:${location.origin}${location.pathname}`)}send(o){let e={type:"state",stop:o.stop,step:o.step,sender:this.id};this.channel.postMessage(e)}sendLanguage(o){let e={type:"lang",lang:o,sender:this.id};this.channel.postMessage(e)}onRemoteLanguage(o){this.channel.addEventListener("message",e=>{let t=e.data;t?.type==="lang"&&t.sender!==this.id&&o(t.lang)})}onRemote(o){this.channel.addEventListener("message",e=>{let t=e.data;t?.type==="state"&&t.sender!==this.id&&o({stop:t.stop,step:t.step})})}close(){this.channel.close()}},at=r=>String(r).padStart(2,"0");function St(r){let o=Math.floor(r/1e3);return`${at(Math.floor(o/60))}:${at(o%60)}`}function it(r){return m`<div class="presenter">
|
|
332
332
|
<div class="presenter-head">
|
|
333
333
|
<span class="presenter-stop">Stop ${r.stop+1} / ${r.stopCount}</span>
|
|
334
334
|
<span class="presenter-step">Step ${r.step+1} / ${r.steps+1}</span>
|