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.3.1
- Initial Pear platform module.
@@ -0,0 +1,9 @@
# hyper-pear-link-resolver
**Protocol:** `pear-link-resolver/v1`
Parse and serialize pear:// application links. See [`docs/api.md`](docs/api.md).
```bash
npm install && npm test
```
@@ -0,0 +1,5 @@
# API: hyper-pear-link-resolver
**Protocol:** `pear-link-resolver/v1` · **Export:** `{ HyperPearLinkResolver, PROTOCOL }`
See [`index.js`](../index.js) for methods and `getStats()`.
@@ -0,0 +1,3 @@
# Architecture: hyper-pear-link-resolver
Pear/Bare platform module. Replaces or complements deprecated `pear run` flows via embeddable `pear-runtime`.
@@ -0,0 +1,9 @@
require('bare-process/global')
const { HyperPearLinkResolver } = require('../index.js')
async function main () {
const m = new HyperPearLinkResolver()
await m.ready()
console.log(m.getStats())
await m.close()
}
main().catch((e) => { console.error(e); process.exit(1) })
@@ -0,0 +1,59 @@
require('bare-process/global')
const EventEmitter = require('bare-events')
const { classifyTarget, platformStats, LINK_PREFIX } = require('../../_shared/pear-platform-base.js')
const PROTOCOL = 'pear-link-resolver/v1'
class HyperPearLinkResolver extends EventEmitter {
constructor (opts = {}) {
super()
this._cache = new Map()
this._stats = { resolved: 0 }
}
parse (link) {
const c = classifyTarget(link)
let fork = null
let length = null
let subpath = ''
if (c.kind === 'pear-link') {
const rest = c.href.slice(LINK_PREFIX.length)
const slash = rest.indexOf('/')
const keyPart = slash >= 0 ? rest.slice(0, slash) : rest
subpath = slash >= 0 ? rest.slice(slash + 1) : ''
const at = keyPart.indexOf('@')
if (at >= 0) {
fork = keyPart.slice(at + 1) || null
}
const key = at >= 0 ? keyPart.slice(0, at) : keyPart
const out = { kind: 'pear-link', key, fork, length, subpath, href: c.href }
this._cache.set(c.href, out)
this._stats.resolved++
this.emit('parse', out)
return out
}
this._stats.resolved++
return { ...c, subpath: '' }
}
serialize (parts) {
if (!parts || !parts.key) throw new Error('key required')
let href = `${LINK_PREFIX}${parts.key}`
if (parts.fork != null) href += `@${parts.fork}`
if (parts.subpath) href += `/${parts.subpath}`
return href
}
getCached (href) {
return this._cache.get(href) || null
}
getStats () {
return platformStats(this._stats, PROTOCOL, { cached: this._cache.size })
}
async ready () { return this }
async close () { this._cache.clear(); this.emit('closed') }
}
module.exports = { HyperPearLinkResolver, HyperP2PPearLinkResolver: HyperPearLinkResolver, PROTOCOL }
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,21 @@
{
"name": "hyper-pear-link-resolver",
"version": "0.3.1",
"description": "Parse and serialize pear:// application links.",
"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,12 @@
require('bare-process/global')
const test = require('brittle')
const { HyperPearLinkResolver, PROTOCOL } = require('../index.js')
test('parse and serialize', async (t) => {
const l = new HyperPearLinkResolver()
const p = l.parse('pear://abc123/sub/index.js')
t.is(p.key, 'abc123')
t.is(p.subpath, 'sub/index.js')
t.is(l.serialize({ key: 'abc123', subpath: 'x' }), 'pear://abc123/x')
await l.close()
})