From 9f68d00356a12bb52a252c32b9da71672c7d594f Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Fri, 3 Jul 2020 19:30:13 +0100 Subject: [PATCH] fix: point docs to `main` not `master` branch (#17) * fix: pptr.dev now points to the main branch Updated any references to the master branch. * chore: build changes --- docs/index.js | 6 +++--- docs/sw.js | 2 +- src/pptr/APIDocumentation.js | 2 +- src/pptr/PPTRProduct.js | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/index.js b/docs/index.js index 04128f7..6ff0280 100644 --- a/docs/index.js +++ b/docs/index.js @@ -1,6 +1,6 @@ /* THIS FILE IS GENERATED BY build.js */ -window.__WEBSITE_VERSION__ = "0.3.7+c48a657"; +window.__WEBSITE_VERSION__ = "0.3.7+421d835"; !function(){"use strict";Element.prototype.scrollIntoViewIfNeeded||(Element.prototype.scrollIntoViewIfNeeded=function(e){e=0===arguments.length||!!e;var t=this.parentNode,r=window.getComputedStyle(t,null),n=parseInt(r.getPropertyValue("border-top-width")),i=parseInt(r.getPropertyValue("border-left-width")),s=this.offsetTop-t.offsetTopt.scrollTop+t.clientHeight,a=this.offsetLeft-t.offsetLeftt.scrollLeft+t.clientWidth,u=s&&!o;(s||o)&&e&&(t.scrollTop=this.offsetTop-t.offsetTop-t.clientHeight/2-n+this.clientHeight/2),(a||l)&&e&&(t.scrollLeft=this.offsetLeft-t.offsetLeft-t.clientWidth/2-i+this.clientWidth/2),(s||o||a||l)&&!e&&this.scrollIntoView(u)});const e=new Map,t=new Set(["async","autofocus","autoplay","checked","contenteditable","controls","default","defer","disabled","formNoValidate","frameborder","hidden","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","readonly","required","reversed","scoped","selected","typemustmatch"]);function r(r,...n){let o=e.get(r);o||(o=function(e){const t=document.createElement("template");let r="";for(let t=0;t1||s.length>1)&&a.push({node:e,nameParts:n,valueParts:s,isSimpleValue:o,attr:r})}else if(e.nodeType===Node.TEXT_NODE&&i.test(e.data)){const t=e.data.split(i);e.data=t[0];const r=e.nextSibling;for(let n=1;n{let t=e[0];for(let r=1;r`,this.element.tabIndex=0}show(e,t){this.element.innerHTML="",this.element.scrollTop=0,this.element.appendChild(e),t&&t.scrollIntoView()}}class a{constructor(){this.element=r``,this.element.addEventListener("click",this._onClick.bind(this),!1),this.glasspane=r``,this.glasspane.addEventListener("click",e=>{this.hideOnMobile(),e.stopPropagation(),e.preventDefault()},!1),this._selectedItem=null}_onClick(e){let t=e.target;for(;t&&t.parentElement!==this.element;)t=t.parentElement;t&&this._selectedItem!==t&&(this.hideOnMobile(),this._selectedItem&&this._selectedItem.classList.remove("selected"),this._selectedItem=t,this._selectedItem.classList.add("selected"))}setElements(e){this.element.innerHTML="";for(const t of e)this.element.appendChild(r` ${t} `)}hideOnMobile(){this.element.classList.remove("show-on-mobile"),this.glasspane.classList.remove("show-on-mobile")}toggleOnMobile(){this.element.classList.toggle("show-on-mobile"),this.glasspane.classList.toggle("show-on-mobile")}setSelected(e){if(this._selectedItem&&(this._selectedItem.classList.remove("selected"),this._selectedItem=null),!e)return;const t=e.parentElement;t&&t.parentElement===this.element&&(this._selectedItem=t,this._selectedItem.classList.add("selected"))}}class l{constructor(){this.element=r` @@ -118,7 +118,7 @@ window.__WEBSITE_VERSION__ = "0.3.7+c48a657"; ${D(n.firstChild,s[0])} - `,a=new w(e,i,o);for(let e=0;e{this.element.appendChild(r` + `,a=new w(e,i,o);for(let e=0;e{this.element.appendChild(r`

${e}

    ${t.map(e=>r`
  • ${e.createTableOfContentsElement()}
  • @@ -156,7 +156,7 @@ window.__WEBSITE_VERSION__ = "0.3.7+c48a657"; ${n} - `)}constructor(e,t,r){super(e.api,t,r),this.tableOfContentsText=`${e.loweredName}.on('${t}')`,this.apiClass=e}}function D(e,t){const r=document.createDocumentFragment();let n=e;for(;n&&n!==t;){const e=n.nextSibling;r.appendChild(n),n=e}return r}const L="pptr-api-data",S="Puppeteer";class F extends f.Product{static async fetchReleaseAndReadme(e){const t=Date.now(),[r,n]=await Promise.all([fetch("https://api.github.com/repos/GoogleChrome/puppeteer/releases").then(e=>e.text()),fetch("https://raw.githubusercontent.com/GoogleChrome/puppeteer/master/README.md").then(e=>e.text())]),i=JSON.parse(r).map(e=>({name:e.tag_name,releaseNotes:e.body,timestamp:new Date(e.published_at).getTime(),apiText:""}));i.push({name:"v0.9.0",timestamp:new Date("August 16, 2017").getTime(),releaseNotes:"",apiText:""});for(const e of i){const[t,r,n]=e.name.substring(1).split(".").map(e=>parseInt(e,10));e.priority=100*t*100+100*r+n}if(i.sort((e,t)=>t.priority-e.priority),e){const t=new Map(e.releases.map(e=>[e.name,e.apiText]));for(const e of i)e.apiText=t.get(e.name)}for(const e of i)"v0.9.0"===e.name?e.chromiumVersion="Chromium 62.0.3188.0 (r494755)":"v0.10.0"===e.name||"v0.10.1"===e.name?e.chromiumVersion="Chromium 62.0.3193.0 (r496140)":"v0.13.0"===e.name?e.chromiumVersion="Chromium 64.0.3265.0 (r515411)":"v1.1.0"===e.name||"v1.1.1"===e.name?e.chromiumVersion="Chromium 66.0.3347.0 (r536395)":"v1.3.0"===e.name&&(e.chromiumVersion="Chromium 67.0.3392.0 (r536395)");i.unshift({name:"master",chromiumVersion:"N/A",releaseNotes:"",apiText:""});for(const e of i){if(!e.releaseNotes||e.chromiumVersion)continue;const t=e.releaseNotes.match(/Chromium\s+(\d+\.\d+.\d+.\d+)\s*\((r\d{6})\)/i);t&&(e.chromiumVersion=`Chromium ${t[1]} (${t[2]})`)}return await Promise.all(i.map(async e=>{"master"!==e.name&&e.apiText||(e.apiText=await fetch(`https://raw.githubusercontent.com/GoogleChrome/puppeteer/${e.name}/docs/api.md`).then(e=>e.text()))})),{fetchTimestamp:t,readmeText:n,releases:i}}static async create(e){const t=new g("pptr-db","pptr-store"),r=await function(){if(!("MozAppearance"in document.documentElement.style))return Promise.resolve(!1);const e=indexedDB.open("test");return new Promise(t=>{e.onerror=t.bind(null,!0),e.onsuccess=t.bind(null,!1)})}();let n=await async function(e,n){return r?JSON.parse(localStorage.getItem(e)):function(e,t=v()){let r;return t._withIDBStore("readonly",t=>{r=t.get(e)}).then(()=>r.result)}(L,t)}(L);const i=!e||n&&!!n.releases.find(t=>t.name===e);if(n&&i)Date.now()-n.fetchTimestamp>3e5&&F.fetchReleaseAndReadme(n).then(e=>s(L,e));else{const t=n?"Downloading Puppeteer release "+e:"Please give us a few seconds to download Puppeteer releases for the first time.\n Next time we'll do it in background.";app.setLoadingScreen(!0,t),n=await F.fetchReleaseAndReadme(n),await s(L,n),app.setLoadingScreen(!1)}return new F(n.readmeText,n.releases,n.fetchTimestamp);async function s(e,n){return r?localStorage.setItem(e,JSON.stringify(n)):function(e,t,r=v()){return r._withIDBStore("readwrite",r=>{r.put(t,e)})}(L,n,t)}}constructor(e,t,r){super(),this._readmeText=e,this._releases=t,this._fetchTimestamp=r,this._initializeAPILifespan()}toolbarElements(){function e(e,t,n){return r``}return[e("https://stackoverflow.com/questions/tagged/puppeteer","./images/stackoverflow.svg","pptr-stackoverflow"),e("https://join.slack.com/t/puppeteer/shared_invite/enQtMzU4MjIyMDA5NTM4LTM1OTdkNDhlM2Y4ZGUzZDdjYjM5ZWZlZGFiZjc4MTkyYTVlYzIzYjU5NDIyNzgyMmFiNDFjN2UzNWU0N2ZhZDc","./images/slack.svg","pptr-slack"),e("https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md","./images/wrench.svg","pptr-troubleshooting"),e("https://github.com/GoogleChrome/puppeteer","./images/github.png","pptr-github")]}_initializeAPILifespan(){const e=/### class:\s+(\w+)\s*$/,t=/#### event:\s+'(\w+)'\s*$/,r=/#### \w+\.([\w$]+)\(/,n=/#### \w+\.(\w+)\s*$/;for(const i of this._releases){i.classesLifespan=new Map;let s=null;const o=i.apiText.split("\n").filter(e=>e.startsWith("###"));for(const a of o)if(e.test(a)){s&&i.classesLifespan.set(s.name,s),s={name:a.match(e)[1],since:i.name,until:"",eventsSince:new Map,methodsSince:new Map,namespacesSince:new Map,eventsUntil:new Map,methodsUntil:new Map,namespacesUntil:new Map}}else if(t.test(a)){console.assert(s);const e=a.match(t)[1];s.eventsSince.set(e,i.name)}else if(r.test(a)){console.assert(s);const e=a.match(r)[1];s.methodsSince.set(e,i.name)}else if(n.test(a)){console.assert(s);const e=a.match(n)[1];s.namespacesSince.set(e,i.name)}s&&i.classesLifespan.set(s.name,s)}for(let e=this._releases.length-2;e>=0;--e){const t=this._releases[e+1],r=this._releases[e];for(const[e,n]of r.classesLifespan){const r=t.classesLifespan.get(e);if(r){n.since=r.since;for(const[e,t]of r.eventsSince)n.eventsSince.has(e)&&n.eventsSince.set(e,t);for(const[e,t]of r.methodsSince)n.methodsSince.has(e)&&n.methodsSince.set(e,t);for(const[e,t]of r.namespacesSince)n.namespacesSince.has(e)&&n.namespacesSince.set(e,t)}}}for(let e=0;ee.name)}versionDescriptions(){return this._releases.map(e=>({name:e.name,description:e.chromiumVersion,date:e.timestamp?new Date(e.timestamp):null}))}settingsFooterElement(){const e=Date.now()-this._fetchTimestamp;let t="";return e<1e3?t="Just Now":1e3<=e&&e<=6e4?t=`${Math.round(e/1e3)} seconds ago`:6e4<=e&&e<=36e5?t=`${Math.round(e/60/1e3)} minutes ago`:36e5<=e&&e<=864e5?t=`${Math.round(e/60/60/1e3)} hours ago`:864e5<=e&&(t=`${Math.round(e/24/60/60/1e3)} days ago`),r`Data fetched ${t}`}create404(e=""){return{element:r` + `)}constructor(e,t,r){super(e.api,t,r),this.tableOfContentsText=`${e.loweredName}.on('${t}')`,this.apiClass=e}}function D(e,t){const r=document.createDocumentFragment();let n=e;for(;n&&n!==t;){const e=n.nextSibling;r.appendChild(n),n=e}return r}const L="pptr-api-data",S="Puppeteer";class F extends f.Product{static async fetchReleaseAndReadme(e){const t=Date.now(),[r,n]=await Promise.all([fetch("https://api.github.com/repos/GoogleChrome/puppeteer/releases").then(e=>e.text()),fetch("https://raw.githubusercontent.com/GoogleChrome/puppeteer/main/README.md").then(e=>e.text())]),i=JSON.parse(r).map(e=>({name:e.tag_name,releaseNotes:e.body,timestamp:new Date(e.published_at).getTime(),apiText:""}));i.push({name:"v0.9.0",timestamp:new Date("August 16, 2017").getTime(),releaseNotes:"",apiText:""});for(const e of i){const[t,r,n]=e.name.substring(1).split(".").map(e=>parseInt(e,10));e.priority=100*t*100+100*r+n}if(i.sort((e,t)=>t.priority-e.priority),e){const t=new Map(e.releases.map(e=>[e.name,e.apiText]));for(const e of i)e.apiText=t.get(e.name)}for(const e of i)"v0.9.0"===e.name?e.chromiumVersion="Chromium 62.0.3188.0 (r494755)":"v0.10.0"===e.name||"v0.10.1"===e.name?e.chromiumVersion="Chromium 62.0.3193.0 (r496140)":"v0.13.0"===e.name?e.chromiumVersion="Chromium 64.0.3265.0 (r515411)":"v1.1.0"===e.name||"v1.1.1"===e.name?e.chromiumVersion="Chromium 66.0.3347.0 (r536395)":"v1.3.0"===e.name&&(e.chromiumVersion="Chromium 67.0.3392.0 (r536395)");i.unshift({name:"master",chromiumVersion:"N/A",releaseNotes:"",apiText:""});for(const e of i){if(!e.releaseNotes||e.chromiumVersion)continue;const t=e.releaseNotes.match(/Chromium\s+(\d+\.\d+.\d+.\d+)\s*\((r\d{6})\)/i);t&&(e.chromiumVersion=`Chromium ${t[1]} (${t[2]})`)}return await Promise.all(i.map(async e=>{"main"!==e.name&&e.apiText||(e.apiText=await fetch(`https://raw.githubusercontent.com/GoogleChrome/puppeteer/${e.name}/docs/api.md`).then(e=>e.text()))})),{fetchTimestamp:t,readmeText:n,releases:i}}static async create(e){const t=new g("pptr-db","pptr-store"),r=await function(){if(!("MozAppearance"in document.documentElement.style))return Promise.resolve(!1);const e=indexedDB.open("test");return new Promise(t=>{e.onerror=t.bind(null,!0),e.onsuccess=t.bind(null,!1)})}();let n=await async function(e,n){return r?JSON.parse(localStorage.getItem(e)):function(e,t=v()){let r;return t._withIDBStore("readonly",t=>{r=t.get(e)}).then(()=>r.result)}(L,t)}(L);const i=!e||n&&!!n.releases.find(t=>t.name===e);if(n&&i)Date.now()-n.fetchTimestamp>3e5&&F.fetchReleaseAndReadme(n).then(e=>s(L,e));else{const t=n?"Downloading Puppeteer release "+e:"Please give us a few seconds to download Puppeteer releases for the first time.\n Next time we'll do it in background.";app.setLoadingScreen(!0,t),n=await F.fetchReleaseAndReadme(n),await s(L,n),app.setLoadingScreen(!1)}return new F(n.readmeText,n.releases,n.fetchTimestamp);async function s(e,n){return r?localStorage.setItem(e,JSON.stringify(n)):function(e,t,r=v()){return r._withIDBStore("readwrite",r=>{r.put(t,e)})}(L,n,t)}}constructor(e,t,r){super(),this._readmeText=e,this._releases=t,this._fetchTimestamp=r,this._initializeAPILifespan()}toolbarElements(){function e(e,t,n){return r``}return[e("https://stackoverflow.com/questions/tagged/puppeteer","./images/stackoverflow.svg","pptr-stackoverflow"),e("https://join.slack.com/t/puppeteer/shared_invite/enQtMzU4MjIyMDA5NTM4LTM1OTdkNDhlM2Y4ZGUzZDdjYjM5ZWZlZGFiZjc4MTkyYTVlYzIzYjU5NDIyNzgyMmFiNDFjN2UzNWU0N2ZhZDc","./images/slack.svg","pptr-slack"),e("https://github.com/GoogleChrome/puppeteer/blob/main/docs/troubleshooting.md","./images/wrench.svg","pptr-troubleshooting"),e("https://github.com/GoogleChrome/puppeteer","./images/github.png","pptr-github")]}_initializeAPILifespan(){const e=/### class:\s+(\w+)\s*$/,t=/#### event:\s+'(\w+)'\s*$/,r=/#### \w+\.([\w$]+)\(/,n=/#### \w+\.(\w+)\s*$/;for(const i of this._releases){i.classesLifespan=new Map;let s=null;const o=i.apiText.split("\n").filter(e=>e.startsWith("###"));for(const a of o)if(e.test(a)){s&&i.classesLifespan.set(s.name,s),s={name:a.match(e)[1],since:i.name,until:"",eventsSince:new Map,methodsSince:new Map,namespacesSince:new Map,eventsUntil:new Map,methodsUntil:new Map,namespacesUntil:new Map}}else if(t.test(a)){console.assert(s);const e=a.match(t)[1];s.eventsSince.set(e,i.name)}else if(r.test(a)){console.assert(s);const e=a.match(r)[1];s.methodsSince.set(e,i.name)}else if(n.test(a)){console.assert(s);const e=a.match(n)[1];s.namespacesSince.set(e,i.name)}s&&i.classesLifespan.set(s.name,s)}for(let e=this._releases.length-2;e>=0;--e){const t=this._releases[e+1],r=this._releases[e];for(const[e,n]of r.classesLifespan){const r=t.classesLifespan.get(e);if(r){n.since=r.since;for(const[e,t]of r.eventsSince)n.eventsSince.has(e)&&n.eventsSince.set(e,t);for(const[e,t]of r.methodsSince)n.methodsSince.has(e)&&n.methodsSince.set(e,t);for(const[e,t]of r.namespacesSince)n.namespacesSince.has(e)&&n.namespacesSince.set(e,t)}}}for(let e=0;ee.name)}versionDescriptions(){return this._releases.map(e=>({name:e.name,description:e.chromiumVersion,date:e.timestamp?new Date(e.timestamp):null}))}settingsFooterElement(){const e=Date.now()-this._fetchTimestamp;let t="";return e<1e3?t="Just Now":1e3<=e&&e<=6e4?t=`${Math.round(e/1e3)} seconds ago`:6e4<=e&&e<=36e5?t=`${Math.round(e/60/1e3)} minutes ago`:36e5<=e&&e<=864e5?t=`${Math.round(e/60/60/1e3)} hours ago`:864e5<=e&&(t=`${Math.round(e/24/60/60/1e3)} days ago`),r`Data fetched ${t}`}create404(e=""){return{element:r`

    Not Found

    diff --git a/docs/sw.js b/docs/sw.js index 63d9448..987c0ee 100644 --- a/docs/sw.js +++ b/docs/sw.js @@ -113,7 +113,7 @@ workbox.precaching.precacheAndRoute([ }, { "url": "index.js", - "revision": "7314c1066d5085b1b1641c7ea74b3322" + "revision": "5efe7957951a47e1ddd72a886f50670d" }, { "url": "style.css", diff --git a/src/pptr/APIDocumentation.js b/src/pptr/APIDocumentation.js index b1cb22b..f1309a0 100644 --- a/src/pptr/APIDocumentation.js +++ b/src/pptr/APIDocumentation.js @@ -132,7 +132,7 @@ export class APIDocumentation { } else if (href.startsWith('/') || href.startsWith('../') || href.startsWith('./')) { // Link pointing somewhere to PPTR repository. const isRelease = /^\d+\.\d+\.\d+$/.test(version); - const branch = isRelease ? 'v' + version : 'master'; + const branch = isRelease ? 'v' + version : 'main'; anchor.setAttribute('href', `https://github.com/GoogleChrome/puppeteer/blob/${branch}/docs/${href}`); } } diff --git a/src/pptr/PPTRProduct.js b/src/pptr/PPTRProduct.js index 294e096..a131ab3 100644 --- a/src/pptr/PPTRProduct.js +++ b/src/pptr/PPTRProduct.js @@ -41,7 +41,7 @@ export class PPTRProduct extends App.Product { const fetchTimestamp = Date.now(); const [releasesText, readmeText] = await Promise.all([ fetch('https://api.github.com/repos/GoogleChrome/puppeteer/releases').then(r => r.text()), - fetch('https://raw.githubusercontent.com/GoogleChrome/puppeteer/master/README.md').then(r => r.text()), + fetch('https://raw.githubusercontent.com/GoogleChrome/puppeteer/main/README.md').then(r => r.text()), ]); const releases = JSON.parse(releasesText).map(release => ({ name: release.tag_name, @@ -89,7 +89,7 @@ export class PPTRProduct extends App.Product { // Add tip-of-tree version. releases.unshift({ - name: 'master', + name: 'main', chromiumVersion: 'N/A', releaseNotes: '', apiText: '' @@ -105,9 +105,9 @@ export class PPTRProduct extends App.Product { } // Download api.md for every release. - // Forcefully re-download it for "master" release. + // Forcefully re-download it for "main" release. await Promise.all(releases.map(async release => { - if (release.name === 'master' || !release.apiText) + if (release.name === 'main' || !release.apiText) release.apiText = await fetch(`https://raw.githubusercontent.com/GoogleChrome/puppeteer/${release.name}/docs/api.md`).then(r => r.text()) })); return {fetchTimestamp, readmeText, releases}; @@ -160,7 +160,7 @@ export class PPTRProduct extends App.Product { return [ iconButton('https://stackoverflow.com/questions/tagged/puppeteer', './images/stackoverflow.svg', 'pptr-stackoverflow'), iconButton('https://join.slack.com/t/puppeteer/shared_invite/enQtMzU4MjIyMDA5NTM4LTM1OTdkNDhlM2Y4ZGUzZDdjYjM5ZWZlZGFiZjc4MTkyYTVlYzIzYjU5NDIyNzgyMmFiNDFjN2UzNWU0N2ZhZDc', './images/slack.svg', 'pptr-slack'), - iconButton('https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md', './images/wrench.svg', 'pptr-troubleshooting'), + iconButton('https://github.com/GoogleChrome/puppeteer/blob/main/docs/troubleshooting.md', './images/wrench.svg', 'pptr-troubleshooting'), iconButton('https://github.com/GoogleChrome/puppeteer', './images/github.png', 'pptr-github'), ];