Add 20 Pear/Bare platform modules replacing deprecated pear run.

Introduces hyper-bare-entry-runner, pear-runtime embed/link/config stack,
and scaffold helpers for argv, storage, OTA, Electron, and headless UI.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-21 01:29:28 -04:00
co-authored by Cursor
parent ad3fc106f1
commit 64a2a824b5
187 changed files with 28587 additions and 21 deletions
@@ -0,0 +1,5 @@
# Changelog
## 0.0.0-scaffold
- Initial Pear platform module.
@@ -0,0 +1,9 @@
# hyper-pear-deep-link
**Protocol:** `pear-deep-link/v1`
Deep-link entrypoint routing. See [`docs/api.md`](docs/api.md).
```bash
npm install && npm test
```
@@ -0,0 +1,5 @@
# API: hyper-pear-deep-link
**Protocol:** `pear-deep-link/v1` · **Export:** `{ HyperPearDeepLink, PROTOCOL }`
See [`index.js`](../index.js) for methods and `getStats()`.
@@ -0,0 +1,3 @@
# Architecture: hyper-pear-deep-link
Pear/Bare platform module. Replaces or complements deprecated `pear run` flows via embeddable `pear-runtime`.
@@ -0,0 +1,9 @@
require('bare-process/global')
const { HyperPearDeepLink } = require('../index.js')
async function main () {
const m = new HyperPearDeepLink()
await m.ready()
console.log(m.getStats())
await m.close()
}
main().catch((e) => { console.error(e); process.exit(1) })
@@ -0,0 +1,51 @@
require('bare-process/global')
const EventEmitter = require('bare-events')
const { classifyTarget, LINK_PREFIX, platformStats } = require('../../_shared/pear-platform-base.js')
const PROTOCOL = 'pear-deep-link/v1'
class HyperPearDeepLink extends EventEmitter {
constructor (opts = {}) {
super()
this.defaultEntry = opts.defaultEntry || 'index.js'
this._stats = { opened: 0 }
}
open (link) {
const c = classifyTarget(link)
let entrypoint = this.defaultEntry
let route = '/'
if (c.kind === 'pear-link') {
const rest = c.href.slice(LINK_PREFIX.length)
const slash = rest.indexOf('/')
if (slash >= 0) {
const sub = rest.slice(slash + 1)
const parts = sub.split('/')
entrypoint = parts[0] || this.defaultEntry
route = '/' + parts.slice(1).join('/')
}
} else if (c.kind === 'file' || c.kind === 'absolute-path') {
entrypoint = c.path.split('/').pop() || this.defaultEntry
}
const out = { link, entrypoint, route, resolved: c, at: Date.now() }
this._stats.opened++
this.emit('open', out)
return out
}
build (key, entrypoint, route = '/') {
let href = `${LINK_PREFIX}${key}`
if (entrypoint) href += `/${entrypoint}`
if (route && route !== '/') href += route.startsWith('/') ? route : `/${route}`
return href
}
getStats () {
return platformStats(this._stats, PROTOCOL, {})
}
async ready () { return this }
async close () { this.emit('closed') }
}
module.exports = { HyperPearDeepLink, HyperP2PPearDeepLink: HyperPearDeepLink, PROTOCOL }
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,21 @@
{
"name": "hyper-pear-deep-link",
"version": "0.0.0-scaffold",
"description": "Deep-link entrypoint routing.",
"main": "index.js",
"type": "commonjs",
"license": "Apache-2.0",
"scripts": { "test": "brittle-bare test/test.js" },
"dependencies": {
"bare-events": "^2.8.0",
"bare-process": "^4.4.0",
"b4a": "^1.6.7",
"hypercore-crypto": "^3.0.0"
},
"peerDependencies": { "bare": ">=1.0.0" },
"devDependencies": { "brittle": "^3.0.0" },
"imports": {
"process": { "bare": "bare-process", "default": "process" },
"events": { "bare": "bare-events", "default": "events" }
}
}
@@ -0,0 +1,10 @@
require('bare-process/global')
const test = require('brittle')
const { HyperPearDeepLink } = require('../index.js')
test('open deep link', async (t) => {
const d = new HyperPearDeepLink()
const o = d.open('pear://key/ui/page.js/sub')
t.ok(o.entrypoint)
await d.close()
})