diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..439b248 --- /dev/null +++ b/.gitignore @@ -0,0 +1,131 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* +package-lock.json \ No newline at end of file diff --git a/lib/docs-viewer.js b/lib/docs-viewer.js new file mode 100644 index 0000000..56bd2bf --- /dev/null +++ b/lib/docs-viewer.js @@ -0,0 +1,83 @@ +/* eslint-env browser */ +import { marked } from 'marked' + +customElements.define('docs-viewer', class extends HTMLElement { + static get observedAttributes () { return ['data-load'] } + attributeChangedCallback (name, _, page) { if (name === 'data-load') this.load(page).catch((err) => this.#error(err)) } + constructor () { + super() + + this.template = document.createElement('template') + this.template.innerHTML = ` +
+ +
+
+ ` + this.root = this.attachShadow({ mode: 'open' }) + + this.root.appendChild(this.template.content.cloneNode(true)) + + this.panel = this.root.querySelector('#panel') + this.header = this.root.querySelector('header') + + this.panel.addEventListener('click', (evt) => { + if (evt.target?.tagName !== 'A') return + const href = evt.target.getAttribute('href') + const { origin } = new URL(location.href) + const url = new URL(href, location.href) + if (url.origin !== origin) return window.open(href) + evt.preventDefault() + document.documentElement.scrollTo(0, 0) + this.load(url.pathname).catch((err) => this.#error(err)).finally(() => { + this.header.querySelector('a').style.display = 'inline-block' + }) + }) + + window.addEventListener('popstate', (evt) => { + document.documentElement.scrollTo(0, 0) + if (evt.state?.page === 'readme.md') this.header.querySelector('a').style.display = 'none' + evt.preventDefault() + this.load(evt.state?.page || this.page, true).catch((err) => this.#error(err)) + }) + window.onbeforeunload = (e) => { + this.#load() + e.returnValue = false + } + this.page = this.dataset.load + this.load(this.page).catch((err) => this.#error(err)) + } + + #error (err) { + try { this.panel.querySelector('slot').innerHTML = err.stack } catch (e) { console.error(err, e) } + } + + load (page = 'readme.md', replace) { + if (replace) history.replaceState({ page }, page, page) + else history.pushState({ page }, page, page) + this.page = page + return this.#load() + } + + async #load () { + this.panel.querySelector('slot').innerHTML = marked.parse(await (await fetch(this.page)).text(), {headerIds: false, mangle: false}) + } +}) \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..e5ebfc8 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "pear", + "main": "pulse.html", + "type": "module", + "pear": { + "gui": { + "backgroundColor": "#151517", + "height": 780, + "width": 1120 + } + }, + "dependencies": { + "marked": "^5.1.0", + "overpass": "github:RedHatOfficial/Overpass#71f18db" + } + } \ No newline at end of file diff --git a/pulse.html b/pulse.html new file mode 100644 index 0000000..22d55ea --- /dev/null +++ b/pulse.html @@ -0,0 +1,162 @@ + + + + +
+
+ + + +
                             
+        __ \    _ \   _` |   __| 
+        |   |   __/  (   |  |    
+        .__/  \___| \__,_| _|    
+      _|                                 
+      
+
+
+
+
+

Pear by Holepunch

+

Welcome to the Internet of Peers

+

Pear is ready to go.

+
+
+
+
+ +
+
+ +