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-bare-argv-bridge
**Protocol:** `bare-argv-bridge/v1`
CLI argv and flag parsing for Bare apps. See [`docs/api.md`](docs/api.md).
```bash
npm install && npm test
```
@@ -0,0 +1,5 @@
# API: hyper-bare-argv-bridge
**Protocol:** `bare-argv-bridge/v1` · **Export:** `{ HyperBareArgvBridge, PROTOCOL }`
See [`index.js`](../index.js) for methods and `getStats()`.
@@ -0,0 +1,3 @@
# Architecture: hyper-bare-argv-bridge
Pear/Bare platform module. Replaces or complements deprecated `pear run` flows via embeddable `pear-runtime`.
@@ -0,0 +1,9 @@
require('bare-process/global')
const { HyperBareArgvBridge } = require('../index.js')
async function main () {
const m = new HyperBareArgvBridge()
await m.ready()
console.log(m.getStats())
await m.close()
}
main().catch((e) => { console.error(e); process.exit(1) })
@@ -0,0 +1,60 @@
require('bare-process/global')
const EventEmitter = require('bare-events')
const { platformStats } = require('../../_shared/pear-platform-base.js')
const PROTOCOL = 'bare-argv-bridge/v1'
class HyperBareArgvBridge extends EventEmitter {
constructor (opts = {}) {
super()
this._argv = opts.argv ? [...opts.argv] : []
this._rest = []
this._flags = new Map()
this._stats = { parsed: 0 }
}
setArgv (argv) {
this._argv = Array.isArray(argv) ? [...argv] : []
this._parse()
return { flags: Object.fromEntries(this._flags), rest: [...this._rest] }
}
_parse () {
this._flags.clear()
this._rest = []
const a = this._argv
for (let i = 0; i < a.length; i++) {
const tok = a[i]
if (tok.startsWith('--')) {
const eq = tok.indexOf('=')
if (eq > 0) {
this._flags.set(tok.slice(2, eq), tok.slice(eq + 1))
} else {
const next = a[i + 1]
if (next && !next.startsWith('-')) {
this._flags.set(tok.slice(2), next)
i++
} else {
this._flags.set(tok.slice(2), true)
}
}
} else if (!tok.startsWith('-')) {
this._rest.push(tok)
}
}
this._stats.parsed++
}
flag (name) { return this._flags.get(name) }
rest () { return [...this._rest] }
hasFlag (name) { return this._flags.has(name) }
getStats () {
return platformStats(this._stats, PROTOCOL, { flags: this._flags.size, rest: this._rest.length })
}
async ready () { return this }
async close () { this.emit('closed') }
}
module.exports = { HyperBareArgvBridge, HyperP2PBareArgvBridge: HyperBareArgvBridge, PROTOCOL }
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,21 @@
{
"name": "hyper-bare-argv-bridge",
"version": "0.0.0-scaffold",
"description": "CLI argv and flag parsing for Bare apps.",
"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,11 @@
require('bare-process/global')
const test = require('brittle')
const { HyperBareArgvBridge } = require('../index.js')
test('parse argv', async (t) => {
const a = new HyperBareArgvBridge()
a.setArgv(['run', '--dev=true', 'pear://x', 'extra'])
t.is(a.flag('dev'), 'true')
t.ok(a.rest().includes('pear://x'))
await a.close()
})