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-import-map
**Protocol:** `bare-import-map/v1`
package.json imports map for Bare. See [`docs/api.md`](docs/api.md).
```bash
npm install && npm test
```
@@ -0,0 +1,5 @@
# API: hyper-bare-import-map
**Protocol:** `bare-import-map/v1` · **Export:** `{ HyperBareImportMap, PROTOCOL }`
See [`index.js`](../index.js) for methods and `getStats()`.
@@ -0,0 +1,3 @@
# Architecture: hyper-bare-import-map
Pear/Bare platform module. Replaces or complements deprecated `pear run` flows via embeddable `pear-runtime`.
@@ -0,0 +1,9 @@
require('bare-process/global')
const { HyperBareImportMap } = require('../index.js')
async function main () {
const m = new HyperBareImportMap()
await m.ready()
console.log(m.getStats())
await m.close()
}
main().catch((e) => { console.error(e); process.exit(1) })
@@ -0,0 +1,45 @@
require('bare-process/global')
const EventEmitter = require('bare-events')
const { platformStats } = require('../../_shared/pear-platform-base.js')
const PROTOCOL = 'bare-import-map/v1'
class HyperBareImportMap extends EventEmitter {
constructor (opts = {}) {
super()
this._imports = {}
this._stats = { loaded: 0, resolved: 0 }
}
loadFromPackage (pkg) {
if (!pkg || typeof pkg !== 'object') throw new Error('package object required')
this._imports = { ...(pkg.imports || {}) }
this._stats.loaded++
this.emit('load', { count: Object.keys(this._imports).length })
return this._imports
}
resolve (specifier) {
const hit = this._imports[specifier]
if (!hit) return null
const target = typeof hit === 'string' ? hit : hit.default || hit.bare || null
this._stats.resolved++
return target
}
map () { return { ...this._imports } }
set (specifier, target) {
this._imports[String(specifier)] = target
return target
}
getStats () {
return platformStats(this._stats, PROTOCOL, { entries: Object.keys(this._imports).length })
}
async ready () { return this }
async close () { this._imports = {}; this.emit('closed') }
}
module.exports = { HyperBareImportMap, HyperP2PBareImportMap: HyperBareImportMap, PROTOCOL }
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,21 @@
{
"name": "hyper-bare-import-map",
"version": "0.0.0-scaffold",
"description": "package.json imports map for Bare.",
"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 { HyperBareImportMap } = require('../index.js')
test('imports map', async (t) => {
const m = new HyperBareImportMap()
m.loadFromPackage({ imports: { fs: { bare: 'bare-fs' } } })
t.is(m.resolve('fs'), 'bare-fs')
await m.close()
})