@bigmistqke/workpad 0.20.1 → 0.20.2
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/dist/client/runtime.js +1 -1
- package/dist/plugins/progress/public/client.js +1 -1
- package/dist/plugins/toc/public/client.js +1 -1
- package/dist/src/client/page/main.js +2 -2
- package/dist/src/files.js +26 -3
- package/dist/src/pages/render.js +14 -7
- package/dist/src/server.js +27 -6
- package/package.json +1 -1
- package/plugins/progress/client.ts +1 -1
- package/plugins/toc/client.ts +1 -1
- package/src/client/page/fresh.ts +1 -1
- package/src/client/page/waiting.ts +2 -1
- package/src/client/scroll.ts +1 -1
- package/src/define.ts +10 -3
- package/src/files.ts +31 -4
- package/src/pages/render.ts +11 -7
- package/src/server.ts +35 -11
package/dist/client/runtime.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=(e,t)=>`${e}\n${t}`,t=e=>typeof e==`number`&&Number.isFinite(e)?e:null;function n(n){let r=/* @__PURE__ */ new Map;for(let i of n){if(i.type!==`progress:update`||i.from!==`cli`)continue;let n=i.data??{},a=typeof n.id==`string`?n.id:``;if(!a)continue;let o=e(i.page,a),s=r.get(o),c=n.state===`done`||n.state===`failed`?n.state:`running`,l=t(n.n),u=t(n.total),d=!s||s.state!==`running`,f=d?i.ts:s.started,p=d?null:s.first;r.set(o,{page:i.page,id:a,n:l,total:u,note:typeof n.note==`string`?n.note:``,state:c,eta:t(n.eta),ts:i.ts,started:f,first:p??(l==null?null:{n:l,ts:i.ts}),by:i.by??null,event:i.id})}return r}const r=(e,t)=>[...n(e.filter(e=>e.page===t)).values()];function i(e,t){if(e.state!==`running`)return null;let n=Date.parse(e.ts);if(e.eta!=null)return n+e.eta*1e3-t;if(e.n==null||e.total==null||!e.first||e.n<=e.first.n)return null;let r=(e.n-e.first.n)/(n-Date.parse(e.first.ts));return r>0?n+(e.total-e.n)/r-t:null}function a(e,t,n=9e5){return e.state===`running`?t-Date.parse(e.ts)>=n||e.eta!=null&&Date.parse(e.ts)+e.eta*1e3<t:!1}const o=e=>e.toLocaleString(`en-US`),s=e=>e.n!=null&&e.total!=null?`${o(e.n)} / ${o(e.total)}`:``;function c(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t} s`;let n=Math.round(t/60);if(n<60)return`${n} min`;let r=Math.floor(n/60),i=n%60;return i?`${r} h ${i} min`:`${r} h`}const l=e=>e<1e4?`just now`:`${c(e)} ago`;function u(e,t){let n=i(e,t);return n==null||n<=0?``:`~${c(n)} left`}function d(e,t,n){let r=document.createElement(e);return r.className=t,n!=null&&(r.textContent=n),r}const f=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),p=e=>e.n!=null&&e.total?e.n/e.total:null,m={running:`running`,done:`done`,failed:`failed`};function h(e,t,n,r){let i=e.querySelector(`:scope > .wp-progress-body`);if(!i)return;if(!t){e.dataset.wpProgress=`waiting`,e.removeAttribute(`data-wp-stale`),i.replaceChildren(d(`span`,`wp-progress-note`,`waiting to start`));return}let o=a(t,n,r);e.dataset.wpProgress=t.state,e.toggleAttribute(`data-wp-stale`,o);let h=[],g=p(t);if(t.state===`running`&&g!=null){let e=d(`span`,`wp-progress-bar`),n=d(`span`,``);n.style.width=`${Math.round(g*1e3)/10}%`,e.append(n),e.setAttribute(`role`,`progressbar`),e.setAttribute(`aria-valuemin`,`0`),e.setAttribute(`aria-valuemax`,String(t.total)),e.setAttribute(`aria-valuenow`,String(t.n)),h.push(e,d(`span`,`wp-progress-count`,s(t)))}else h.push(d(`span`,`wp-progress-state`,m[t.state]));t.note&&h.push(d(`span`,`wp-progress-note`,t.note));let _=[];if(t.state!==`running`)_.push(f(t.ts));else if(o)_.push(`no update for ${c(n-Date.parse(t.ts))}`);else{let e=u(t,n);e&&_.push(e),_.push(l(n-Date.parse(t.ts)))}h.push(d(`span`,`wp-progress-when`,_.join(` · `))),i.replaceChildren(...h),e.title=`${t.id}: ${t.state}${t.by?`, moved by ${t.by}`:``}`}function g(e,t,n){let r=e.state===`running`?s(e)||e.note:e.note||m[e.state],i=`${e.state===`done`?`✓ `:e.state===`failed`?`✗ `:``}${e.id}${r?` · ${r}`:``}`;return e.state===`running`?{text:i,meta:a(e,t,n)?`no update ${c(t-Date.parse(e.ts))}`:u(e,t)||l(t-Date.parse(e.ts)),bar:{value:p(e),tone:`accent`}}:{text:i,meta:l(t-Date.parse(e.ts)),bar:{value:1,tone:e.state===`done`?`good`:`bad`}}}const _=(e,t,n)=>{if(!t.live)return;let i=Number(document.querySelector(`meta[name=wp-progress]`)?.dataset.staleAfter)||9e5,a=`wp-progress-seen:${location.pathname}`,o=/* @__PURE__ */ new Set;try{o=new Set(JSON.parse(localStorage.getItem(a)??`[]`))}catch{}let s=e=>{o.add(e);try{localStorage.setItem(a,JSON.stringify([...o].slice(-200)))}catch{}},c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map,d=t=>[...e.querySelectorAll(`.wp-progress[data-progress]`)].filter(e=>e.dataset.progress===t);function f(e){let t=l.get(e);t&&t.state!==`running`&&(s(t.event),c.get(e)?.close(),c.delete(e));let n=d(e);if(!n.length)return;let r=((u.get(e)??-1)+1)%n.length;u.set(e,r);let i=n[r];i.scrollIntoView({block:`center`,behavior:`
|
|
1
|
+
const e=(e,t)=>`${e}\n${t}`,t=e=>typeof e==`number`&&Number.isFinite(e)?e:null;function n(n){let r=/* @__PURE__ */ new Map;for(let i of n){if(i.type!==`progress:update`||i.from!==`cli`)continue;let n=i.data??{},a=typeof n.id==`string`?n.id:``;if(!a)continue;let o=e(i.page,a),s=r.get(o),c=n.state===`done`||n.state===`failed`?n.state:`running`,l=t(n.n),u=t(n.total),d=!s||s.state!==`running`,f=d?i.ts:s.started,p=d?null:s.first;r.set(o,{page:i.page,id:a,n:l,total:u,note:typeof n.note==`string`?n.note:``,state:c,eta:t(n.eta),ts:i.ts,started:f,first:p??(l==null?null:{n:l,ts:i.ts}),by:i.by??null,event:i.id})}return r}const r=(e,t)=>[...n(e.filter(e=>e.page===t)).values()];function i(e,t){if(e.state!==`running`)return null;let n=Date.parse(e.ts);if(e.eta!=null)return n+e.eta*1e3-t;if(e.n==null||e.total==null||!e.first||e.n<=e.first.n)return null;let r=(e.n-e.first.n)/(n-Date.parse(e.first.ts));return r>0?n+(e.total-e.n)/r-t:null}function a(e,t,n=9e5){return e.state===`running`?t-Date.parse(e.ts)>=n||e.eta!=null&&Date.parse(e.ts)+e.eta*1e3<t:!1}const o=e=>e.toLocaleString(`en-US`),s=e=>e.n!=null&&e.total!=null?`${o(e.n)} / ${o(e.total)}`:``;function c(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t} s`;let n=Math.round(t/60);if(n<60)return`${n} min`;let r=Math.floor(n/60),i=n%60;return i?`${r} h ${i} min`:`${r} h`}const l=e=>e<1e4?`just now`:`${c(e)} ago`;function u(e,t){let n=i(e,t);return n==null||n<=0?``:`~${c(n)} left`}function d(e,t,n){let r=document.createElement(e);return r.className=t,n!=null&&(r.textContent=n),r}const f=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),p=e=>e.n!=null&&e.total?e.n/e.total:null,m={running:`running`,done:`done`,failed:`failed`};function h(e,t,n,r){let i=e.querySelector(`:scope > .wp-progress-body`);if(!i)return;if(!t){e.dataset.wpProgress=`waiting`,e.removeAttribute(`data-wp-stale`),i.replaceChildren(d(`span`,`wp-progress-note`,`waiting to start`));return}let o=a(t,n,r);e.dataset.wpProgress=t.state,e.toggleAttribute(`data-wp-stale`,o);let h=[],g=p(t);if(t.state===`running`&&g!=null){let e=d(`span`,`wp-progress-bar`),n=d(`span`,``);n.style.width=`${Math.round(g*1e3)/10}%`,e.append(n),e.setAttribute(`role`,`progressbar`),e.setAttribute(`aria-valuemin`,`0`),e.setAttribute(`aria-valuemax`,String(t.total)),e.setAttribute(`aria-valuenow`,String(t.n)),h.push(e,d(`span`,`wp-progress-count`,s(t)))}else h.push(d(`span`,`wp-progress-state`,m[t.state]));t.note&&h.push(d(`span`,`wp-progress-note`,t.note));let _=[];if(t.state!==`running`)_.push(f(t.ts));else if(o)_.push(`no update for ${c(n-Date.parse(t.ts))}`);else{let e=u(t,n);e&&_.push(e),_.push(l(n-Date.parse(t.ts)))}h.push(d(`span`,`wp-progress-when`,_.join(` · `))),i.replaceChildren(...h),e.title=`${t.id}: ${t.state}${t.by?`, moved by ${t.by}`:``}`}function g(e,t,n){let r=e.state===`running`?s(e)||e.note:e.note||m[e.state],i=`${e.state===`done`?`✓ `:e.state===`failed`?`✗ `:``}${e.id}${r?` · ${r}`:``}`;return e.state===`running`?{text:i,meta:a(e,t,n)?`no update ${c(t-Date.parse(e.ts))}`:u(e,t)||l(t-Date.parse(e.ts)),bar:{value:p(e),tone:`accent`}}:{text:i,meta:l(t-Date.parse(e.ts)),bar:{value:1,tone:e.state===`done`?`good`:`bad`}}}const _=(e,t,n)=>{if(!t.live)return;let i=Number(document.querySelector(`meta[name=wp-progress]`)?.dataset.staleAfter)||9e5,a=`wp-progress-seen:${location.pathname}`,o=/* @__PURE__ */ new Set;try{o=new Set(JSON.parse(localStorage.getItem(a)??`[]`))}catch{}let s=e=>{o.add(e);try{localStorage.setItem(a,JSON.stringify([...o].slice(-200)))}catch{}},c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map,d=t=>[...e.querySelectorAll(`.wp-progress[data-progress]`)].filter(e=>e.dataset.progress===t);function f(e){let t=l.get(e);t&&t.state!==`running`&&(s(t.event),c.get(e)?.close(),c.delete(e));let n=d(e);if(!n.length)return;let r=((u.get(e)??-1)+1)%n.length;u.set(e,r);let i=n[r];i.scrollIntoView({block:`center`,behavior:`instant`}),i.classList.remove(`wp-flash`),i.offsetWidth,i.classList.add(`wp-flash`)}function p(){let t=Date.now(),a=r(n.events(),n.page),s=new Map(a.map(e=>[e.id,e]));for(let n of e.querySelectorAll(`.wp-progress[data-progress]`))h(n,s.get(n.dataset.progress),t,i);for(let e of a){let r=e.state===`running`||!o.has(e.event),a=c.get(e.id);if(!r){a?.close(),c.delete(e.id);continue}l.set(e.id,e);let{text:s,meta:u,bar:d}=g(e,t,i);a?a.update(s,{meta:u??null,bar:d??null}):(a=n.toast(s,{kind:`quiet`,ms:0,name:`progress-${e.id}`,order:-3,meta:u,bar:d,onClick:()=>f(e.id)}),c.set(e.id,a))}for(let[e,t]of c)s.has(e)||(t.close(),c.delete(e))}p(),n.events.on(p),n.onRendered(p),setInterval(p,1e4)};export{_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=document.createElement(`nav`);e.className=`wp-toc`,e.setAttribute(`aria-label`,`Contents`);const t=document.createElement(`ol`);e.append(t);const n=document.createElement(`button`);n.type=`button`,n.className=`wp-toc-toggle`,n.title=n.ariaLabel=`Contents`,n.setAttribute(`aria-expanded`,`false`),n.innerHTML=`<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><path d="M2.5 4h11M2.5 8h11M2.5 12h7"/></svg>`;let r,i,a=[];const o=()=>document.querySelector(`.wp-nav`)?.getBoundingClientRect().height??0,s=()=>document.documentElement.clientWidth-r.offsetWidth-16-40;function c(){let t=parseFloat(getComputedStyle(e).minWidth)||0;return s()>=t}const l=e=>{let t=/^(\d+(?:\.\d+)?)(px|em|rem|ch|vw)?$/.exec(String(e??``).trim());return t&&Number(t[1])>0?t[1]+(t[2]??`px`):null};function u(){let t=document.querySelector(`meta[name=wp-toc]`),n=f.settings(),r=n&&typeof n==`object`?n:{};for(let[n,i]of[[`minWidth`,`--wp-toc-min-width`],[`maxWidth`,`--wp-toc-max-width`]]){let a=l(r[n])??l(t?.dataset[n]);a?e.style.setProperty(i,a):e.style.removeProperty(i)}}function d(t){let n=document.documentElement.style;if(e.style.setProperty(`--wp-toc-room`,`${s()}px`),!t)return n.removeProperty(`--wp-aside`);n.setProperty(`--wp-aside`,`${16+e.getBoundingClientRect().width}px`)}let f;function p(t){e.classList.toggle(`wp-toc-open`,t),e.hidden=!t,n.setAttribute(`aria-expanded`,String(t))}function m(){let e=f.settings(),t=document.querySelector(`meta[name=wp-toc]`)?.getAttribute(`content`)===`always`;return e===!1?!1:e===!0||e&&typeof e==`object`?!0:t}function h(e){let t=e.cloneNode(!0);return t.querySelectorAll(`.wp-badge, .wp-when`).forEach(e=>e.remove()),t.textContent?.trim()??``}function g(){a=m()?[...r.querySelectorAll(`:scope > :is(h2, h3, h4, h5, h6)`)]:[];let i=[0,0,0,0,0],o=[{level:1,list:t}];t.replaceChildren(),a.forEach((e,t)=>{let n=Number(e.tagName[1]);for(i[n-2]++,i.fill(0,n-1);o.length>1&&o.at(-1).level>=n;)o.pop();let r=o.at(-1);r.item&&!r.item.querySelector(`:scope > ol`)&&r.item.append(document.createElement(`ol`));let a=r.item?r.item.querySelector(`:scope > ol`):r.list,s=document.createElement(`li`);s.dataset.level=String(n);let c=document.createElement(`a`);c.href=`#`,c.dataset.index=String(t),c.innerHTML=`<span class="wp-toc-number"></span><span class="wp-toc-text"></span>`,c.querySelector(`.wp-toc-number`).textContent=i.slice(0,n-1).join(`.`),c.querySelector(`.wp-toc-text`).textContent=h(e),s.append(c),a.append(s),o.push({level:n,list:a,item:s})});let s=a.length>1;u();let l=s&&c();n.hidden=!s||l,e.hidden=!s||!l&&!e.classList.contains(`wp-toc-open`),e.classList.toggle(`wp-toc-docked`,l),d(l),v(),y()}function _(e){let t=-1;for(let n=0;n<a.length&&a[n].compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING;n++)t=n;return t}function v(){let e=/* @__PURE__ */ new Set,n=new Set(i.unread().map(e=>e.id)),o=[...r.querySelectorAll(`form[data-wp-open]`),...[...r.querySelectorAll(`[data-wp-message]`)].filter(e=>n.has(e.dataset.wpMessage))];for(let t of o)e.add(_(t));for(let t of document.querySelectorAll(`[data-wp-holds]`)){if(!t.dataset.wpHolds.split(` `).some(e=>n.has(e)))continue;let r=t.getBoundingClientRect().top,i=-1;a.forEach((e,t)=>{e.getBoundingClientRect().top<=r&&(i=t)}),e.add(i)}t.querySelectorAll(`a`).forEach((t,n)=>t.toggleAttribute(`data-waiting`,e.has(n)))}function y(){let e=o()+40,n=0;a.forEach((t,r)=>{t.getBoundingClientRect().top<=e&&(n=r)}),t.querySelectorAll(`a`).forEach((e,t)=>e.toggleAttribute(`aria-current`,t===n&&a.length>0))}function b(e){let t=a[e];t&&(scrollTo({top:Math.max(0,scrollY+t.getBoundingClientRect().top-o()-12),behavior:`
|
|
1
|
+
const e=document.createElement(`nav`);e.className=`wp-toc`,e.setAttribute(`aria-label`,`Contents`);const t=document.createElement(`ol`);e.append(t);const n=document.createElement(`button`);n.type=`button`,n.className=`wp-toc-toggle`,n.title=n.ariaLabel=`Contents`,n.setAttribute(`aria-expanded`,`false`),n.innerHTML=`<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><path d="M2.5 4h11M2.5 8h11M2.5 12h7"/></svg>`;let r,i,a=[];const o=()=>document.querySelector(`.wp-nav`)?.getBoundingClientRect().height??0,s=()=>document.documentElement.clientWidth-r.offsetWidth-16-40;function c(){let t=parseFloat(getComputedStyle(e).minWidth)||0;return s()>=t}const l=e=>{let t=/^(\d+(?:\.\d+)?)(px|em|rem|ch|vw)?$/.exec(String(e??``).trim());return t&&Number(t[1])>0?t[1]+(t[2]??`px`):null};function u(){let t=document.querySelector(`meta[name=wp-toc]`),n=f.settings(),r=n&&typeof n==`object`?n:{};for(let[n,i]of[[`minWidth`,`--wp-toc-min-width`],[`maxWidth`,`--wp-toc-max-width`]]){let a=l(r[n])??l(t?.dataset[n]);a?e.style.setProperty(i,a):e.style.removeProperty(i)}}function d(t){let n=document.documentElement.style;if(e.style.setProperty(`--wp-toc-room`,`${s()}px`),!t)return n.removeProperty(`--wp-aside`);n.setProperty(`--wp-aside`,`${16+e.getBoundingClientRect().width}px`)}let f;function p(t){e.classList.toggle(`wp-toc-open`,t),e.hidden=!t,n.setAttribute(`aria-expanded`,String(t))}function m(){let e=f.settings(),t=document.querySelector(`meta[name=wp-toc]`)?.getAttribute(`content`)===`always`;return e===!1?!1:e===!0||e&&typeof e==`object`?!0:t}function h(e){let t=e.cloneNode(!0);return t.querySelectorAll(`.wp-badge, .wp-when`).forEach(e=>e.remove()),t.textContent?.trim()??``}function g(){a=m()?[...r.querySelectorAll(`:scope > :is(h2, h3, h4, h5, h6)`)]:[];let i=[0,0,0,0,0],o=[{level:1,list:t}];t.replaceChildren(),a.forEach((e,t)=>{let n=Number(e.tagName[1]);for(i[n-2]++,i.fill(0,n-1);o.length>1&&o.at(-1).level>=n;)o.pop();let r=o.at(-1);r.item&&!r.item.querySelector(`:scope > ol`)&&r.item.append(document.createElement(`ol`));let a=r.item?r.item.querySelector(`:scope > ol`):r.list,s=document.createElement(`li`);s.dataset.level=String(n);let c=document.createElement(`a`);c.href=`#`,c.dataset.index=String(t),c.innerHTML=`<span class="wp-toc-number"></span><span class="wp-toc-text"></span>`,c.querySelector(`.wp-toc-number`).textContent=i.slice(0,n-1).join(`.`),c.querySelector(`.wp-toc-text`).textContent=h(e),s.append(c),a.append(s),o.push({level:n,list:a,item:s})});let s=a.length>1;u();let l=s&&c();n.hidden=!s||l,e.hidden=!s||!l&&!e.classList.contains(`wp-toc-open`),e.classList.toggle(`wp-toc-docked`,l),d(l),v(),y()}function _(e){let t=-1;for(let n=0;n<a.length&&a[n].compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING;n++)t=n;return t}function v(){let e=/* @__PURE__ */ new Set,n=new Set(i.unread().map(e=>e.id)),o=[...r.querySelectorAll(`form[data-wp-open]`),...[...r.querySelectorAll(`[data-wp-message]`)].filter(e=>n.has(e.dataset.wpMessage))];for(let t of o)e.add(_(t));for(let t of document.querySelectorAll(`[data-wp-holds]`)){if(!t.dataset.wpHolds.split(` `).some(e=>n.has(e)))continue;let r=t.getBoundingClientRect().top,i=-1;a.forEach((e,t)=>{e.getBoundingClientRect().top<=r&&(i=t)}),e.add(i)}t.querySelectorAll(`a`).forEach((t,n)=>t.toggleAttribute(`data-waiting`,e.has(n)))}function y(){let e=o()+40,n=0;a.forEach((t,r)=>{t.getBoundingClientRect().top<=e&&(n=r)}),t.querySelectorAll(`a`).forEach((e,t)=>e.toggleAttribute(`aria-current`,t===n&&a.length>0))}function b(e){let t=a[e];t&&(scrollTo({top:Math.max(0,scrollY+t.getBoundingClientRect().top-o()-12),behavior:`instant`}),c()||p(!1))}const x=(a,o,s)=>{if(o.kind!==`page`&&o.kind!==`file`)return;f=o,r=a.querySelector(`#wp-main`)??a,i=s,s.slot(`aside`,t=>(t.append(e),()=>e.remove())),s.slot(`header`,e=>(e.append(n),()=>n.remove())),t.addEventListener(`click`,e=>{let t=e.target.closest(`a[data-index]`);t&&(e.preventDefault(),b(Number(t.dataset.index)))}),n.addEventListener(`click`,()=>p(!e.classList.contains(`wp-toc-open`))),document.addEventListener(`keydown`,t=>{t.key===`Escape`&&e.classList.contains(`wp-toc-open`)&&n.click()});let c=0,l=e=>()=>{cancelAnimationFrame(c),c=requestAnimationFrame(e)};addEventListener(`scroll`,l(y),{passive:!0}),addEventListener(`resize`,l(g)),i.onRendered(g),o.settings.on(g),i.forms.on(()=>v()),i.events.on(()=>requestAnimationFrame(v)),g()};export{x as default};
|
|
@@ -662,7 +662,7 @@ function update$1() {
|
|
|
662
662
|
function go(dir) {
|
|
663
663
|
const { above, below } = split();
|
|
664
664
|
(dir === "up" ? above : below)[0]?.scrollIntoView({
|
|
665
|
-
behavior: "
|
|
665
|
+
behavior: "instant",
|
|
666
666
|
block: "start"
|
|
667
667
|
});
|
|
668
668
|
}
|
|
@@ -1125,7 +1125,7 @@ function jumpTo(target) {
|
|
|
1125
1125
|
scrolledTo = Math.max(0, Math.min(scrollY + r.top + r.height / 2 - viewBottom() / 2, document.documentElement.scrollHeight - innerHeight));
|
|
1126
1126
|
scrollTo({
|
|
1127
1127
|
top: scrolledTo,
|
|
1128
|
-
behavior: "
|
|
1128
|
+
behavior: "instant"
|
|
1129
1129
|
});
|
|
1130
1130
|
if (target instanceof HTMLFormElement) {
|
|
1131
1131
|
if (target.hasAttribute("data-wp-open")) target.querySelector("input:not([type=hidden]), textarea, select, button")?.focus({ preventScroll: true });
|
package/dist/src/files.js
CHANGED
|
@@ -11,6 +11,15 @@ const ALWAYS_EXCLUDED = ["**/node_modules", "**/.git"];
|
|
|
11
11
|
function glob(rel, g) {
|
|
12
12
|
const parts = g.split("/");
|
|
13
13
|
const segs = rel.split("/");
|
|
14
|
+
const segment = (name, part) => {
|
|
15
|
+
const key = `${part}\0${name}`;
|
|
16
|
+
let hit = SEGMENTS.get(key);
|
|
17
|
+
if (hit === void 0) {
|
|
18
|
+
if (SEGMENTS.size > 1e5) SEGMENTS.clear();
|
|
19
|
+
SEGMENTS.set(key, hit = path.posix.matchesGlob(name, part));
|
|
20
|
+
}
|
|
21
|
+
return hit;
|
|
22
|
+
};
|
|
14
23
|
const seen = /* @__PURE__ */ new Set();
|
|
15
24
|
const at = (i, j) => {
|
|
16
25
|
if (i === parts.length) return j === segs.length;
|
|
@@ -21,10 +30,11 @@ function glob(rel, g) {
|
|
|
21
30
|
for (let k = j; k <= segs.length; k++) if (at(i + 1, k)) return true;
|
|
22
31
|
return false;
|
|
23
32
|
}
|
|
24
|
-
return j < segs.length &&
|
|
33
|
+
return j < segs.length && segment(segs[j], parts[i]) && at(i + 1, j + 1);
|
|
25
34
|
};
|
|
26
35
|
return at(0, 0);
|
|
27
36
|
}
|
|
37
|
+
const SEGMENTS = /* @__PURE__ */ new Map();
|
|
28
38
|
const ALWAYS_NAMES = new Set(ALWAYS_EXCLUDED.map((g) => g.slice(3)));
|
|
29
39
|
/** The path and each folder above it: `a/b/c` → `a/b/c`, `a/b`, `a`. */
|
|
30
40
|
function* upward(rel) {
|
|
@@ -51,8 +61,21 @@ function fileFilter(files) {
|
|
|
51
61
|
const config = typeof files === "object" && files ? files : {};
|
|
52
62
|
const exclude = [...ALWAYS_EXCLUDED, ...config.exclude ?? []];
|
|
53
63
|
const include = config.include?.length ? config.include : null;
|
|
54
|
-
const
|
|
55
|
-
|
|
64
|
+
const memo = (test) => {
|
|
65
|
+
const seen = /* @__PURE__ */ new Map();
|
|
66
|
+
return (p) => {
|
|
67
|
+
let hit = seen.get(p);
|
|
68
|
+
if (hit === void 0) {
|
|
69
|
+
if (seen.size > 5e4) seen.clear();
|
|
70
|
+
seen.set(p, hit = test(p));
|
|
71
|
+
}
|
|
72
|
+
return hit;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
const excludes = memo((p) => exclude.some((g) => glob(p, g)));
|
|
76
|
+
const includes = memo((p) => !!include?.some((g) => glob(p, g)));
|
|
77
|
+
const excluded = (rel) => rel.split("/").some((s) => ALWAYS_NAMES.has(s)) || [...upward(rel)].some(excludes);
|
|
78
|
+
const included = (rel) => !include || [...upward(rel)].some(includes);
|
|
56
79
|
return {
|
|
57
80
|
key: JSON.stringify({
|
|
58
81
|
include,
|
package/dist/src/pages/render.js
CHANGED
|
@@ -107,7 +107,7 @@ const MARKDOWN = /\.(md|markdown)$/i;
|
|
|
107
107
|
* built copies and dependencies stay out; elsewhere a walk that skips the usual build and
|
|
108
108
|
* dependency folders. The project's own pages (.workpad/) are listed apart.
|
|
109
109
|
*/
|
|
110
|
-
function documentsIn(dir, shows
|
|
110
|
+
function documentsIn(dir, { shows, mayHold } = fileFilter()) {
|
|
111
111
|
let files;
|
|
112
112
|
try {
|
|
113
113
|
files = execFileSync("git", [
|
|
@@ -136,9 +136,12 @@ function documentsIn(dir, shows = (rel) => fileFilter().shows(rel)) {
|
|
|
136
136
|
} catch {
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
|
-
for (const e of entries)
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
for (const e of entries) {
|
|
140
|
+
const child = path.posix.join(rel, e.name);
|
|
141
|
+
if (e.isDirectory()) {
|
|
142
|
+
if (!SKIP.has(e.name) && !e.name.startsWith(".") && (!mayHold || mayHold(child))) walk(child);
|
|
143
|
+
} else if (MARKDOWN.test(e.name)) files.push(child);
|
|
144
|
+
}
|
|
142
145
|
};
|
|
143
146
|
walk("");
|
|
144
147
|
}
|
|
@@ -246,7 +249,11 @@ async function filesFold(dir, base) {
|
|
|
246
249
|
* written here), by when last updated, or by title; each row carries what it is sorted by.
|
|
247
250
|
*/
|
|
248
251
|
function documentList(ctx) {
|
|
249
|
-
|
|
252
|
+
const { shows, mayHold } = ctx.project;
|
|
253
|
+
return documentsOf(ctx.project.dir, ctx.base ?? "", ctx.urlFor, false, shows && {
|
|
254
|
+
shows,
|
|
255
|
+
mayHold
|
|
256
|
+
});
|
|
250
257
|
}
|
|
251
258
|
/**
|
|
252
259
|
* A project's documents by the folder they are in, each folder a fold with how many it holds, the
|
|
@@ -312,8 +319,8 @@ function documentFolders(docs, dir, base, urlFor) {
|
|
|
312
319
|
* A project's documents, as its overview lists them: from its folder, linked where it serves them.
|
|
313
320
|
* `folded`: in a fold that says how many (the shared server's overview, where each project has them).
|
|
314
321
|
*/
|
|
315
|
-
function documentsOf(dir, base, urlFor, folded = false,
|
|
316
|
-
const docs = documentsIn(dir,
|
|
322
|
+
function documentsOf(dir, base, urlFor, folded = false, filter, open = false) {
|
|
323
|
+
const docs = documentsIn(dir, filter).map((f) => docOf(dir, f));
|
|
317
324
|
if (!docs.length) return "";
|
|
318
325
|
if (folded) return documentTree(docs, dir, base, urlFor, open);
|
|
319
326
|
const ctx = {
|
package/dist/src/server.js
CHANGED
|
@@ -78,10 +78,25 @@ function createServer(project, { base = "", entry, label, name, files: filesOpti
|
|
|
78
78
|
const streams = /* @__PURE__ */ new Set();
|
|
79
79
|
const watch = (dir, options, fn) => {
|
|
80
80
|
try {
|
|
81
|
-
|
|
81
|
+
const w = fs.watch(dir, options, (_evt, name) => {
|
|
82
82
|
if (name) fn(String(name));
|
|
83
|
-
})
|
|
84
|
-
|
|
83
|
+
});
|
|
84
|
+
w.on("error", (err) => {
|
|
85
|
+
outOfWatches(err);
|
|
86
|
+
w.close();
|
|
87
|
+
watchers.delete(w);
|
|
88
|
+
});
|
|
89
|
+
watchers.add(w);
|
|
90
|
+
} catch (err) {
|
|
91
|
+
outOfWatches(err);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
let told = false;
|
|
95
|
+
const outOfWatches = (err) => {
|
|
96
|
+
const code = err?.code;
|
|
97
|
+
if (told || code !== "EMFILE" && code !== "ENOSPC") return;
|
|
98
|
+
told = true;
|
|
99
|
+
console.error(`workpad: ${project.dir}: out of watches (${code}); some of its files won't go live. Narrow the config's files, or raise the limit`);
|
|
85
100
|
};
|
|
86
101
|
const setups = /* @__PURE__ */ new WeakMap();
|
|
87
102
|
const pluginDirs = /* @__PURE__ */ new Set();
|
|
@@ -193,7 +208,8 @@ function createServer(project, { base = "", entry, label, name, files: filesOpti
|
|
|
193
208
|
name: projectName(),
|
|
194
209
|
dir: project.dir,
|
|
195
210
|
files: !!FILES,
|
|
196
|
-
shows: (rel) => FILTER.shows(rel)
|
|
211
|
+
shows: (rel) => FILTER.shows(rel),
|
|
212
|
+
mayHold: (rel) => FILTER.mayHold(rel)
|
|
197
213
|
},
|
|
198
214
|
asset,
|
|
199
215
|
urlFor,
|
|
@@ -682,10 +698,15 @@ function createServer(project, { base = "", entry, label, name, files: filesOpti
|
|
|
682
698
|
watchFolder(child);
|
|
683
699
|
}
|
|
684
700
|
});
|
|
685
|
-
w.on("error", () =>
|
|
701
|
+
w.on("error", (err) => {
|
|
702
|
+
outOfWatches(err);
|
|
703
|
+
drop(key);
|
|
704
|
+
});
|
|
686
705
|
projectWatchers.set(key, w);
|
|
687
706
|
watchers.add(w);
|
|
688
|
-
} catch {
|
|
707
|
+
} catch (err) {
|
|
708
|
+
outOfWatches(err);
|
|
709
|
+
}
|
|
689
710
|
};
|
|
690
711
|
const isDir = (dir) => {
|
|
691
712
|
try {
|
package/package.json
CHANGED
|
@@ -120,7 +120,7 @@ const mount: PluginMount = (root: HTMLElement, page: PageHandle, api: Api) => {
|
|
|
120
120
|
const i = ((turn.get(id) ?? -1) + 1) % list.length
|
|
121
121
|
turn.set(id, i)
|
|
122
122
|
const el = list[i]!
|
|
123
|
-
el.scrollIntoView({ block: 'center', behavior: '
|
|
123
|
+
el.scrollIntoView({ block: 'center', behavior: 'instant' })
|
|
124
124
|
el.classList.remove('wp-flash')
|
|
125
125
|
void el.offsetWidth
|
|
126
126
|
el.classList.add('wp-flash')
|
package/plugins/toc/client.ts
CHANGED
|
@@ -191,7 +191,7 @@ function current() {
|
|
|
191
191
|
function go(i: number) {
|
|
192
192
|
const h = headings[i]
|
|
193
193
|
if (!h) return
|
|
194
|
-
scrollTo({ top: Math.max(0, scrollY + h.getBoundingClientRect().top - navHeight() - 12), behavior: '
|
|
194
|
+
scrollTo({ top: Math.max(0, scrollY + h.getBoundingClientRect().top - navHeight() - 12), behavior: 'instant' })
|
|
195
195
|
if (!fits()) setOpen(false)
|
|
196
196
|
}
|
|
197
197
|
|
package/src/client/page/fresh.ts
CHANGED
|
@@ -228,7 +228,7 @@ function update() {
|
|
|
228
228
|
|
|
229
229
|
function go(dir: 'up' | 'down') {
|
|
230
230
|
const { above, below } = split()
|
|
231
|
-
;(dir === 'up' ? above : below)[0]?.scrollIntoView({ behavior: '
|
|
231
|
+
;(dir === 'up' ? above : below)[0]?.scrollIntoView({ behavior: 'instant', block: 'start' })
|
|
232
232
|
}
|
|
233
233
|
const seeAll = () => {
|
|
234
234
|
for (const el of [...unseen]) markSeen(el)
|
|
@@ -231,7 +231,8 @@ function jumpTo(target: HTMLElement) {
|
|
|
231
231
|
0,
|
|
232
232
|
Math.min(scrollY + r.top + r.height / 2 - viewBottom() / 2, document.documentElement.scrollHeight - innerHeight),
|
|
233
233
|
)
|
|
234
|
-
|
|
234
|
+
// at once, not scrolled to: the reader asked to be there (the overview's count, a toast)
|
|
235
|
+
scrollTo({ top: scrolledTo, behavior: 'instant' })
|
|
235
236
|
if (target instanceof HTMLFormElement) {
|
|
236
237
|
if (target.hasAttribute('data-wp-open'))
|
|
237
238
|
target
|
package/src/client/scroll.ts
CHANGED
|
@@ -80,7 +80,7 @@ function goTo(target: HTMLElement | null): boolean {
|
|
|
80
80
|
const summary = d.querySelector<HTMLElement>(':scope > summary')
|
|
81
81
|
if (summary && summary !== target) offset += summary.getBoundingClientRect().height
|
|
82
82
|
}
|
|
83
|
-
scrollTo({ top: Math.max(0, scrollY + target.getBoundingClientRect().top - offset), behavior: '
|
|
83
|
+
scrollTo({ top: Math.max(0, scrollY + target.getBoundingClientRect().top - offset), behavior: 'instant' })
|
|
84
84
|
target.classList.remove('wp-flash')
|
|
85
85
|
void target.offsetWidth
|
|
86
86
|
target.classList.add('wp-flash')
|
package/src/define.ts
CHANGED
|
@@ -571,9 +571,16 @@ export interface PagesSource extends StoredBase {
|
|
|
571
571
|
export interface RenderContext {
|
|
572
572
|
/**
|
|
573
573
|
* `files`: whether its own files are served; `shows`: which of them (a path in the project
|
|
574
|
-
* folder, with `/`), as its `files` setting says
|
|
575
|
-
|
|
576
|
-
|
|
574
|
+
* folder, with `/`), as its `files` setting says; `mayHold`: whether a folder can hold one, so a
|
|
575
|
+
* walk looking for them goes into no other
|
|
576
|
+
*/
|
|
577
|
+
project: {
|
|
578
|
+
name: string
|
|
579
|
+
dir: string
|
|
580
|
+
files: boolean
|
|
581
|
+
shows?: (rel: string) => boolean
|
|
582
|
+
mayHold?: (rel: string) => boolean
|
|
583
|
+
}
|
|
577
584
|
/**
|
|
578
585
|
* The URL the browser loads a file from: a client module, a stylesheet, an image next to a
|
|
579
586
|
* block. Files are served only once asked for, and are watched from then on:
|
package/src/files.ts
CHANGED
|
@@ -35,6 +35,17 @@ export interface FileFilter {
|
|
|
35
35
|
export function glob(rel: string, g: string): boolean {
|
|
36
36
|
const parts = g.split('/')
|
|
37
37
|
const segs = rel.split('/')
|
|
38
|
+
// matchesGlob compiles its pattern on each call, and a project's paths repeat the same few names
|
|
39
|
+
// (docs, README.md) in every folder and worktree: each name and segment is matched once
|
|
40
|
+
const segment = (name: string, part: string) => {
|
|
41
|
+
const key = `${part}\0${name}`
|
|
42
|
+
let hit = SEGMENTS.get(key)
|
|
43
|
+
if (hit === undefined) {
|
|
44
|
+
if (SEGMENTS.size > 100_000) SEGMENTS.clear()
|
|
45
|
+
SEGMENTS.set(key, (hit = path.posix.matchesGlob(name, part)))
|
|
46
|
+
}
|
|
47
|
+
return hit
|
|
48
|
+
}
|
|
38
49
|
const seen = new Set<string>()
|
|
39
50
|
const at = (i: number, j: number): boolean => {
|
|
40
51
|
if (i === parts.length) return j === segs.length
|
|
@@ -45,11 +56,14 @@ export function glob(rel: string, g: string): boolean {
|
|
|
45
56
|
for (let k = j; k <= segs.length; k++) if (at(i + 1, k)) return true
|
|
46
57
|
return false
|
|
47
58
|
}
|
|
48
|
-
return j < segs.length &&
|
|
59
|
+
return j < segs.length && segment(segs[j]!, parts[i]!) && at(i + 1, j + 1)
|
|
49
60
|
}
|
|
50
61
|
return at(0, 0)
|
|
51
62
|
}
|
|
52
63
|
|
|
64
|
+
// a glob segment against a name: whether it matches, as matchesGlob said the first time
|
|
65
|
+
const SEGMENTS = new Map<string, boolean>()
|
|
66
|
+
|
|
53
67
|
// the always-excluded by folder name: checked first, it settles most of a burst cheaply
|
|
54
68
|
const ALWAYS_NAMES = new Set(ALWAYS_EXCLUDED.map(g => g.slice('**/'.length)))
|
|
55
69
|
|
|
@@ -81,11 +95,24 @@ export function fileFilter(files?: boolean | FilesConfig): FileFilter {
|
|
|
81
95
|
const config = typeof files === 'object' && files ? files : {}
|
|
82
96
|
const exclude = [...ALWAYS_EXCLUDED, ...(config.exclude ?? [])]
|
|
83
97
|
const include = config.include?.length ? config.include : null
|
|
98
|
+
// what a path itself matches, kept: each file's folders are asked again for every file in them
|
|
99
|
+
const memo = (test: (p: string) => boolean) => {
|
|
100
|
+
const seen = new Map<string, boolean>()
|
|
101
|
+
return (p: string) => {
|
|
102
|
+
let hit = seen.get(p)
|
|
103
|
+
if (hit === undefined) {
|
|
104
|
+
if (seen.size > 50_000) seen.clear()
|
|
105
|
+
seen.set(p, (hit = test(p)))
|
|
106
|
+
}
|
|
107
|
+
return hit
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const excludes = memo(p => exclude.some(g => glob(p, g)))
|
|
111
|
+
const includes = memo(p => !!include?.some(g => glob(p, g)))
|
|
84
112
|
// left out: it, or a folder it is in, matches an exclude
|
|
85
|
-
const excluded = (rel: string) =>
|
|
86
|
-
rel.split('/').some(s => ALWAYS_NAMES.has(s)) || [...upward(rel)].some(p => exclude.some(g => glob(p, g)))
|
|
113
|
+
const excluded = (rel: string) => rel.split('/').some(s => ALWAYS_NAMES.has(s)) || [...upward(rel)].some(excludes)
|
|
87
114
|
// taken in: it, or a folder it is in, matches an include
|
|
88
|
-
const included = (rel: string) => !include || [...upward(rel)].some(
|
|
115
|
+
const included = (rel: string) => !include || [...upward(rel)].some(includes)
|
|
89
116
|
return {
|
|
90
117
|
key: JSON.stringify({ include, exclude }),
|
|
91
118
|
shows: rel => !!rel && !excluded(rel) && included(rel),
|
package/src/pages/render.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// directives and fences handed to the plugins' blocks (markdown.ts); repository files show as highlighted
|
|
3
3
|
// code, folders as listings with their README on top; around all of it goes the page's frame.
|
|
4
4
|
// What the page draws itself is built with `html` (../html.ts), which escapes every value.
|
|
5
|
-
import { fileFilter } from '../files.ts'
|
|
5
|
+
import { fileFilter, type FileFilter } from '../files.ts'
|
|
6
6
|
import { FRONTMATTER } from '../site.ts'
|
|
7
7
|
import fs from 'node:fs'
|
|
8
8
|
import os from 'node:os'
|
|
@@ -135,7 +135,7 @@ const MARKDOWN = /\.(md|markdown)$/i
|
|
|
135
135
|
* built copies and dependencies stay out; elsewhere a walk that skips the usual build and
|
|
136
136
|
* dependency folders. The project's own pages (.workpad/) are listed apart.
|
|
137
137
|
*/
|
|
138
|
-
function documentsIn(dir: string, shows
|
|
138
|
+
function documentsIn(dir: string, { shows, mayHold }: Pick<FileFilter, 'shows'> & Partial<Pick<FileFilter, 'mayHold'>> = fileFilter()) {
|
|
139
139
|
let files: string[]
|
|
140
140
|
try {
|
|
141
141
|
files = execFileSync(
|
|
@@ -155,9 +155,12 @@ function documentsIn(dir: string, shows: (rel: string) => boolean = rel => fileF
|
|
|
155
155
|
return
|
|
156
156
|
}
|
|
157
157
|
for (const e of entries) {
|
|
158
|
+
const child = path.posix.join(rel, e.name)
|
|
158
159
|
if (e.isDirectory()) {
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
// only into a folder that can hold something shown: with an include naming docs, a few
|
|
161
|
+
// folders, not each of a checkout's thousands (a container without git walks)
|
|
162
|
+
if (!SKIP.has(e.name) && !e.name.startsWith('.') && (!mayHold || mayHold(child))) walk(child)
|
|
163
|
+
} else if (MARKDOWN.test(e.name)) files.push(child)
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
166
|
walk('')
|
|
@@ -267,7 +270,8 @@ export async function filesFold(dir: string, base: string): Promise<{ count: num
|
|
|
267
270
|
* written here), by when last updated, or by title; each row carries what it is sorted by.
|
|
268
271
|
*/
|
|
269
272
|
function documentList(ctx: RenderContext) {
|
|
270
|
-
|
|
273
|
+
const { shows, mayHold } = ctx.project
|
|
274
|
+
return documentsOf(ctx.project.dir, ctx.base ?? '', ctx.urlFor, false, shows && { shows, mayHold })
|
|
271
275
|
}
|
|
272
276
|
|
|
273
277
|
/**
|
|
@@ -349,10 +353,10 @@ function documentsOf(
|
|
|
349
353
|
base: string,
|
|
350
354
|
urlFor: (abs: string) => string | null,
|
|
351
355
|
folded = false,
|
|
352
|
-
|
|
356
|
+
filter?: Pick<FileFilter, 'shows'> & Partial<Pick<FileFilter, 'mayHold'>>,
|
|
353
357
|
open = false,
|
|
354
358
|
) {
|
|
355
|
-
const docs = documentsIn(dir,
|
|
359
|
+
const docs = documentsIn(dir, filter).map(f => docOf(dir, f))
|
|
356
360
|
if (!docs.length) return ''
|
|
357
361
|
if (folded) return documentTree(docs, dir, base, urlFor, open)
|
|
358
362
|
const ctx = { project: { dir }, base, urlFor }
|
package/src/server.ts
CHANGED
|
@@ -234,15 +234,30 @@ export function createServer(
|
|
|
234
234
|
const streams = new Set<() => void>()
|
|
235
235
|
const watch = (dir: string, options: fs.WatchOptions, fn: (name: string) => void) => {
|
|
236
236
|
try {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
237
|
+
const w = fs.watch(dir, options, (_evt, name) => {
|
|
238
|
+
if (name) fn(String(name))
|
|
239
|
+
})
|
|
240
|
+
// an error later (the folder gone, the system out of watches) ends this watch, not the server
|
|
241
|
+
w.on('error', err => {
|
|
242
|
+
outOfWatches(err)
|
|
243
|
+
w.close()
|
|
244
|
+
watchers.delete(w)
|
|
245
|
+
})
|
|
246
|
+
watchers.add(w)
|
|
247
|
+
} catch (err) {
|
|
248
|
+
outOfWatches(err) /* else gone, or not built */
|
|
244
249
|
}
|
|
245
250
|
}
|
|
251
|
+
// the system out of watches or open files (EMFILE, ENOSPC): said once, and what was asked goes unwatched
|
|
252
|
+
let told = false
|
|
253
|
+
const outOfWatches = (err: unknown) => {
|
|
254
|
+
const code = (err as NodeJS.ErrnoException)?.code
|
|
255
|
+
if (told || (code !== 'EMFILE' && code !== 'ENOSPC')) return
|
|
256
|
+
told = true
|
|
257
|
+
console.error(
|
|
258
|
+
`workpad: ${project.dir}: out of watches (${code}); some of its files won't go live. Narrow the config's files, or raise the limit`,
|
|
259
|
+
)
|
|
260
|
+
}
|
|
246
261
|
|
|
247
262
|
// ---- plugins --------------------------------------------------------------------------------
|
|
248
263
|
// Behaviour on every page: each one's setup runs once per loaded config.
|
|
@@ -373,7 +388,13 @@ export function createServer(
|
|
|
373
388
|
}
|
|
374
389
|
|
|
375
390
|
const context = () => ({
|
|
376
|
-
project: {
|
|
391
|
+
project: {
|
|
392
|
+
name: projectName(),
|
|
393
|
+
dir: project.dir,
|
|
394
|
+
files: !!FILES,
|
|
395
|
+
shows: (rel: string) => FILTER.shows(rel),
|
|
396
|
+
mayHold: (rel: string) => FILTER.mayHold(rel),
|
|
397
|
+
},
|
|
377
398
|
asset,
|
|
378
399
|
urlFor,
|
|
379
400
|
base,
|
|
@@ -946,11 +967,14 @@ export function createServer(
|
|
|
946
967
|
}
|
|
947
968
|
})
|
|
948
969
|
// a folder that goes: its watcher with it
|
|
949
|
-
w.on('error',
|
|
970
|
+
w.on('error', err => {
|
|
971
|
+
outOfWatches(err)
|
|
972
|
+
drop(key)
|
|
973
|
+
})
|
|
950
974
|
projectWatchers.set(key, w)
|
|
951
975
|
watchers.add(w)
|
|
952
|
-
} catch {
|
|
953
|
-
/* gone meanwhile */
|
|
976
|
+
} catch (err) {
|
|
977
|
+
outOfWatches(err) /* else gone meanwhile */
|
|
954
978
|
}
|
|
955
979
|
}
|
|
956
980
|
const isDir = (dir: string) => {
|