themes
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
# /lib/bare (system image)
|
||||
|
||||
Self-contained **`ctx.bare` support** on the system Hyperdrive:
|
||||
|
||||
- **`bare-module-manifest.json`** — copy of the booter manifest (same keys and packages as host resolution).
|
||||
- **`manifest.json`** — drive loader index: `bundles` lists IIFE paths that assign into `globalThis.__bare_os_stdlib__`; `bundleStats` summarizes esbuild success vs stub-only placeholders.
|
||||
- **`bundles/*.js`** — one file per manifest row. Successful builds are full IIFE bundles; failures are no-op stubs (see file header). Regenerate with `npm run build -w bare-os-bare-libs`.
|
||||
|
||||
At boot the booter runs **drive bundles first**, then (unless **`BARE_OS_BARE_HOST_IMPORTS=0`**) fills any missing keys via host `import()`.
|
||||
|
||||
Trusted image only: executing these bundles is equivalent to running seeded `/bin` utilities.
|
||||
@@ -0,0 +1,15 @@
|
||||
# bare-os-bare-libs
|
||||
|
||||
Builds trusted IIFE bundles from [`bare-module-manifest.json`](../bare-os-booter/lib/bare-module-manifest.json) entries marked `"bundle": true`. Output:
|
||||
|
||||
- `kernel/lib/bare/bundles/<ctxKey>.js`
|
||||
- `kernel/lib/bare/manifest.json` (paths for the booter drive merge)
|
||||
- Mirrored under `packages/bare-os-seeder/kernel/lib/bare/` for seeder parity
|
||||
|
||||
Run from repo root:
|
||||
|
||||
```bash
|
||||
npm run build -w bare-os-bare-libs
|
||||
```
|
||||
|
||||
The booter loads these only when `BARE_OS_BARE_MODULES` is enabled and `BARE_OS_BARE_DRIVE_BUNDLES` is not disabled; see the developer guide.
|
||||
@@ -0,0 +1,193 @@
|
||||
/**
|
||||
* Bundle every bare-module-manifest entry into IIFE scripts under bundles/ so the
|
||||
* system image can populate ctx.bare without relying on the Pear host node_modules.
|
||||
* Entries that fail esbuild still get a no-op .js placeholder on disk for a full tree.
|
||||
*/
|
||||
import { readFile, writeFile, mkdir, copyFile } from 'node:fs/promises'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
import * as esbuild from 'esbuild'
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
const repoRoot = join(__dirname, '..', '..')
|
||||
const manifestPath = join(
|
||||
repoRoot,
|
||||
'packages/bare-os-booter/lib/bare-module-manifest.json'
|
||||
)
|
||||
const kernelLibBare = join(repoRoot, 'kernel/lib/bare')
|
||||
const seederLibBare = join(repoRoot, 'packages/bare-os-seeder/kernel/lib/bare')
|
||||
const bundlesKernel = join(kernelLibBare, 'bundles')
|
||||
const bundlesSeeder = join(seederLibBare, 'bundles')
|
||||
|
||||
const STDLIB_GLOBAL = '__bare_os_stdlib__'
|
||||
const IIFE_GLOBAL = '__bare_os_bundle_exports__'
|
||||
|
||||
const BUNDLE_CONCURRENCY = 6
|
||||
|
||||
/** Resolve bare-native `imports` subpath specifiers (#web-view / #window) for the host OS. */
|
||||
function bareNativeConditionalImportsPlugin() {
|
||||
const bareNativeRoot = join(repoRoot, 'node_modules/bare-native')
|
||||
function webViewAbs() {
|
||||
const p = process.platform
|
||||
if (p === 'darwin' || p === 'ios') return join(bareNativeRoot, 'lib/web-view/apple.js')
|
||||
if (p === 'win32') return join(bareNativeRoot, 'lib/web-view/win32.js')
|
||||
if (p === 'android') return join(bareNativeRoot, 'lib/web-view/android.js')
|
||||
return join(bareNativeRoot, 'lib/web-view/linux.js')
|
||||
}
|
||||
function windowAbs() {
|
||||
const p = process.platform
|
||||
if (p === 'darwin') return join(bareNativeRoot, 'lib/window/darwin.js')
|
||||
if (p === 'ios') return join(bareNativeRoot, 'lib/window/ios.js')
|
||||
if (p === 'win32') return join(bareNativeRoot, 'lib/window/win32.js')
|
||||
if (p === 'android') return join(bareNativeRoot, 'lib/window/android.js')
|
||||
return join(bareNativeRoot, 'lib/window/linux.js')
|
||||
}
|
||||
return {
|
||||
name: 'bare-native-subpath-imports',
|
||||
setup(build) {
|
||||
build.onResolve({ filter: /^#web-view$/ }, () => ({ path: webViewAbs() }))
|
||||
build.onResolve({ filter: /^#window$/ }, () => ({ path: windowAbs() }))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {T[]} items
|
||||
* @param {number} concurrency
|
||||
* @param {(item: T, index: number) => Promise<void>} fn
|
||||
*/
|
||||
async function runPool(items, concurrency, fn) {
|
||||
let i = 0
|
||||
async function worker() {
|
||||
while (i < items.length) {
|
||||
const idx = i++
|
||||
await fn(items[idx], idx)
|
||||
}
|
||||
}
|
||||
await Promise.all(Array.from({ length: concurrency }, () => worker()))
|
||||
}
|
||||
|
||||
function stdinForEntry(ent) {
|
||||
const pkg = ent.package
|
||||
if (ent.sideEffectImport) {
|
||||
return `import ${JSON.stringify(pkg)};\nexport default true;\n`
|
||||
}
|
||||
if (ent.export === '*') {
|
||||
return `import * as _m from ${JSON.stringify(pkg)};\nexport default _m;\n`
|
||||
}
|
||||
return `import _m from ${JSON.stringify(pkg)};\nexport default _m;\n`
|
||||
}
|
||||
|
||||
export async function buildBareLibs() {
|
||||
const manifest = JSON.parse(await readFile(manifestPath, 'utf8'))
|
||||
const entries = Array.isArray(manifest.entries) ? manifest.entries : []
|
||||
const toBundle = entries.filter((e) => e.ctxKey && e.package)
|
||||
|
||||
await mkdir(bundlesKernel, { recursive: true })
|
||||
await mkdir(bundlesSeeder, { recursive: true })
|
||||
|
||||
/** @type {{ path: string, keys: string[] }[]} */
|
||||
const bundles = []
|
||||
let ok = 0
|
||||
let fail = 0
|
||||
|
||||
await runPool(toBundle, BUNDLE_CONCURRENCY, async (ent) => {
|
||||
const ctxKey = ent.ctxKey
|
||||
const pkg = ent.package
|
||||
const outfile = join(bundlesKernel, `${ctxKey}.js`)
|
||||
const outfileSeeder = join(bundlesSeeder, `${ctxKey}.js`)
|
||||
const footer = `;(function(){var g=globalThis;var s=${JSON.stringify(STDLIB_GLOBAL)};g[s]=g[s]||{};g[s][${JSON.stringify(ctxKey)}]=typeof ${IIFE_GLOBAL}!=="undefined"?${IIFE_GLOBAL}:void 0;})();`
|
||||
|
||||
try {
|
||||
await esbuild.build({
|
||||
stdin: {
|
||||
contents: stdinForEntry(ent),
|
||||
resolveDir: repoRoot,
|
||||
sourcefile: `bare-lib-entry-${ctxKey}.js`,
|
||||
loader: 'js'
|
||||
},
|
||||
bundle: true,
|
||||
format: 'iife',
|
||||
globalName: IIFE_GLOBAL,
|
||||
platform: 'node',
|
||||
nodePaths: [join(repoRoot, 'node_modules')],
|
||||
plugins: [bareNativeConditionalImportsPlugin()],
|
||||
outfile,
|
||||
footer: { js: footer },
|
||||
logLevel: 'silent'
|
||||
})
|
||||
} catch (err) {
|
||||
fail++
|
||||
console.warn(
|
||||
'[bare-os-bare-libs] bundle failed',
|
||||
ctxKey,
|
||||
'(' + pkg + '):',
|
||||
err?.message || err
|
||||
)
|
||||
const stub = `/* bare-os-bare-libs: esbuild failed for ${pkg} — ${String(err?.message || err).replace(/\*\//g, '')} */\n;(function(){})();\n`
|
||||
try {
|
||||
await writeFile(outfile, stub)
|
||||
await writeFile(outfileSeeder, stub)
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
ok++
|
||||
bundles.push({
|
||||
path: `/lib/bare/bundles/${ctxKey}.js`,
|
||||
keys: [ctxKey]
|
||||
})
|
||||
|
||||
const built = await readFile(outfile)
|
||||
await writeFile(outfileSeeder, built)
|
||||
})
|
||||
|
||||
const driveManifest = {
|
||||
version: 1,
|
||||
bundles,
|
||||
bundleStats: { ok, failed: fail, attempted: toBundle.length }
|
||||
}
|
||||
const json = JSON.stringify(driveManifest, null, 2) + '\n'
|
||||
await writeFile(join(kernelLibBare, 'manifest.json'), json)
|
||||
await writeFile(join(seederLibBare, 'manifest.json'), json)
|
||||
|
||||
await copyFile(
|
||||
manifestPath,
|
||||
join(kernelLibBare, 'bare-module-manifest.json')
|
||||
)
|
||||
await copyFile(
|
||||
manifestPath,
|
||||
join(seederLibBare, 'bare-module-manifest.json')
|
||||
)
|
||||
|
||||
const readmeSrc = join(__dirname, 'README.kernel-lib-bare.md')
|
||||
const readmeDstKernel = join(kernelLibBare, 'README.md')
|
||||
const readmeDstSeeder = join(seederLibBare, 'README.md')
|
||||
try {
|
||||
await copyFile(readmeSrc, readmeDstKernel)
|
||||
await copyFile(readmeSrc, readmeDstSeeder)
|
||||
} catch {
|
||||
/* optional */
|
||||
}
|
||||
|
||||
console.log(
|
||||
'[bare-os-bare-libs] bundles:',
|
||||
ok,
|
||||
'ok,',
|
||||
fail,
|
||||
'failed,',
|
||||
toBundle.length,
|
||||
'attempted →',
|
||||
kernelLibBare
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
process.argv[1] &&
|
||||
import.meta.url === pathToFileURL(process.argv[1]).href
|
||||
) {
|
||||
await buildBareLibs()
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "bare-os-bare-libs",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "Builds IIFE bundles under kernel/lib/bare/bundles for ctx.bare drive merge",
|
||||
"scripts": {
|
||||
"build": "node build.mjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.25.0"
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
| Version | Booter (workspace) | Notes |
|
||||
| ------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| 1.7.0 | 0.1.0 | **`ctx.bare`**: frozen map of Holepunch-style npm modules for in-image scripts (manifest-driven host `import()` + optional trusted **`/lib/bare/bundles/*.js`** merge). Caps **`bareCtxModules`**, **`bareDriveBundles`**. Env **`BARE_OS_BARE_MODULES`**, **`BARE_OS_BARE_DRIVE_BUNDLES`**. Workspace **`bare-os-bare-libs`** builds seeded bundles. |
|
||||
| 1.6.0 | 0.1.0 | Abort/timeout on `execLine`, `readLine`, `runBinCommand`, VFS `readFile`/`writeFile`; IPC fan-out + JSON-RPC token/line limits; HTTP allow/deny + audit; `/proc/bare_os_resources`, `/proc/bare_os_features`; `/run/bare-os/virtual/*`; booter boot phases in `boot.json` (`booterPhases`); optional `ctx.bareOsHostStats`, `ctx.httpFetch` policy wrapper; initd `ReadinessPath` / `ReadinessTimeoutSec`; Pear/sandbox stubs. |
|
||||
| 1.5.0 | (prior) | Previous documented contract. |
|
||||
|
||||
|
||||
@@ -26,12 +26,14 @@ node index.js
|
||||
| `swarm-disk.js` | Peer mux, MBR/read RPC, replication hooks |
|
||||
| `kernel-runner.js` | `runKernelFromSource`, `runBinCommand`, `resolveBinInPath` (PATH on system drive); `git` / `curl` / `wget` delegates |
|
||||
| `vfs.js` | Two-drive routing; `mkdir`/`rmdir` (`.bareos_empty`), `chmod`, `symlink`, pseudo `/proc`/`/sys`, `watch`, … |
|
||||
| `shell.js` | Tokenize, pipelines, redirections, builtins (`unset`, `readonly`, `umask`, `command`, `type`, …), `execShellLine` |
|
||||
| `shell.js` | Tokenize, pipelines, redirections, builtins (`barerc`, `unset`, `readonly`, `umask`, `command`, `type`, …), `execShellLine`, `loadBarerc` |
|
||||
| `bare-os-theme-presets.js` | Named themes (`BARE_OS_THEME`), `applyBareOsThemeFromEnv`, `BARE_OS_COLOR_DEPTH` downgrades for REPL colors |
|
||||
| `bare-os-ipc.js` | FIFOs, JSON-RPC (`pushJson`/`takeJson`, token + line limits), fan-out pub/sub, `stats` |
|
||||
| `bare-os-abort.js` | `raceWithAbortAndTimeout` for `execLine` / `readLine` / VFS / `runBinCommand` |
|
||||
| `bare-os-http-policy.js` | Optional HTTP allow/deny lists for wrapped `ctx.httpFetch` |
|
||||
| `bare-os-ctx-api.js` / `bare-os-ctx.d.ts` | Semantic version of the `ctx` contract + optional TypeScript shapes |
|
||||
| `bare-os-runtime-caps.js` | Frozen caps: pipeline limits, `quotas`, pseudo paths, `features` flags |
|
||||
| `bare-os-ctx-bare.js` / `bare-module-manifest.json` | **`ctx.bare`** host imports + optional **`/lib/bare/`** drive bundle merge |
|
||||
| `identity-session.js` / `identity-account.js` | Guest vs unlocked user, `/.bare/account`, vault |
|
||||
| `hdms-manager.js` | Extra Hyperdrives, mounts under `/mnt`, Autopass pair/invite |
|
||||
| `bare-initd.js` | Service registry, unit drop-ins, socket-activation, **ReadinessPath** polling, `startBareInitd`, **kernel-logger** |
|
||||
@@ -55,7 +57,7 @@ node index.js
|
||||
| `BARE_OS_FISH` | Set `0` to disable fish-style editor |
|
||||
| `HYPERSWARM_BOOTSTRAP` | Optional comma-separated bootstrap nodes (HDMS / replication) |
|
||||
|
||||
**Copied from host into the guest session when set** (non-exhaustive; see [DOCUMENTATION.md](../../DOCUMENTATION.md) §14 and [CHANGELOG.md](./CHANGELOG.md)): `BARE_OS_PIPELINE_MAX_STAGES`, `BARE_OS_PIPELINE_MAX_BYTES`, `BARE_OS_PIPELINE_MAX_LINES`, `BARE_OS_BOOT_PROFILE`, `BARE_OS_ONBOOT`, `BARE_OS_BOOT_STRICT`, `BARE_OS_RC_D_SKIP`, `BARE_OS_BOOT_MINIMAL`, `BARE_OS_BOOT_SKIP`, `BARE_OS_BOOT_TRACE`, `BARE_OS_KERNEL_SELFTEST`, `BARE_OS_SELFTEST_FORMAT`, `BARE_OS_AUDIT`, `BARE_OS_AUDIT_JSON`, `BARE_OS_AUDIT_REDACT`, `BARE_OS_BOOT_ALLOWLIST`, `BARE_OS_EXEC_MAX_DEPTH`, `BARE_OS_IPC_MAX_BYTES`, `BARE_OS_IPC_RPC_TOKEN`, `BARE_OS_IPC_FANOUT`, `BARE_OS_IPC_JSON_MAX_BYTES`, `BARE_OS_HTTP_ALLOWLIST`, `BARE_OS_HTTP_DENYLIST`, `BARE_OS_TLS_PIN_SHA256`, `BARE_OS_VFS_WATCH`, `BARE_OS_IMAGE_DIGEST`, `BARE_OS_PEAR_CHANNEL`, `BARE_OS_PEAR_RELEASE`, `PEAR_CHANNEL`.
|
||||
**Copied from host into the guest session when set** (non-exhaustive; see [DOCUMENTATION.md](../../DOCUMENTATION.md) §14 and [CHANGELOG.md](./CHANGELOG.md)): `BARE_OS_PIPELINE_MAX_STAGES`, `BARE_OS_PIPELINE_MAX_BYTES`, `BARE_OS_PIPELINE_MAX_LINES`, `BARE_OS_BOOT_PROFILE`, `BARE_OS_ONBOOT`, `BARE_OS_BOOT_STRICT`, `BARE_OS_RC_D_SKIP`, `BARE_OS_BOOT_MINIMAL`, `BARE_OS_BOOT_SKIP`, `BARE_OS_BOOT_TRACE`, `BARE_OS_KERNEL_SELFTEST`, `BARE_OS_SELFTEST_FORMAT`, `BARE_OS_AUDIT`, `BARE_OS_AUDIT_JSON`, `BARE_OS_AUDIT_REDACT`, `BARE_OS_BOOT_ALLOWLIST`, `BARE_OS_EXEC_MAX_DEPTH`, `BARE_OS_IPC_MAX_BYTES`, `BARE_OS_IPC_RPC_TOKEN`, `BARE_OS_IPC_FANOUT`, `BARE_OS_IPC_JSON_MAX_BYTES`, `BARE_OS_HTTP_ALLOWLIST`, `BARE_OS_HTTP_DENYLIST`, `BARE_OS_TLS_PIN_SHA256`, `BARE_OS_VFS_WATCH`, `BARE_OS_IMAGE_DIGEST`, `BARE_OS_PEAR_CHANNEL`, `BARE_OS_PEAR_RELEASE`, `BARE_OS_BARE_MODULES`, `BARE_OS_BARE_DRIVE_BUNDLES`, `TERM`, `COLORTERM`, `PEAR_CHANNEL`.
|
||||
|
||||
## Tests
|
||||
|
||||
@@ -72,5 +74,6 @@ npm test -w bare-os-booter
|
||||
|
||||
## See also
|
||||
|
||||
- [Developer guide — Bare modules](../../developer-guide/12-bare-modules-and-pear-ecosystem.md)
|
||||
- [Handbook — Booter runtime](../../handbook/04-the-booter-runtime.md)
|
||||
- [DOCUMENTATION.md](../../DOCUMENTATION.md) §12 (detailed; some lists may lag code)
|
||||
|
||||
@@ -53,11 +53,21 @@ import {
|
||||
import { appendVarLog, AUDIT_LOG } from './lib/bare-os-var-log.js'
|
||||
import { BARE_OS_CTX_API_VERSION } from './lib/bare-os-ctx-api.js'
|
||||
import { buildBareOsRuntimeCaps } from './lib/bare-os-runtime-caps.js'
|
||||
import {
|
||||
bareOsBareModulesEnabled,
|
||||
buildBareCtxObjectFromHost,
|
||||
maybeMergeBareFromDrive,
|
||||
bareOsBareHostImportsEnabled
|
||||
} from './lib/bare-os-ctx-bare.js'
|
||||
import { raceWithAbortAndTimeout } from './lib/bare-os-abort.js'
|
||||
import {
|
||||
bareOsHttpPolicyFromEnv,
|
||||
wrapFetchWithBareOsHttpPolicy
|
||||
} from './lib/bare-os-http-policy.js'
|
||||
import {
|
||||
applyBareOsThemeFromEnv,
|
||||
bareOsListThemeNames
|
||||
} from './lib/bare-os-theme-presets.js'
|
||||
import './lib/bare-cron.js'
|
||||
|
||||
const { randomUUID, randomBytes } = bareCrypto
|
||||
@@ -281,11 +291,19 @@ async function executeKernel(disk, store, swarm, initSource) {
|
||||
'BARE_OS_IPC_JSON_MAX_BYTES',
|
||||
'BARE_OS_HTTP_ALLOWLIST',
|
||||
'BARE_OS_HTTP_DENYLIST',
|
||||
'BARE_OS_TLS_PIN_SHA256'
|
||||
'BARE_OS_TLS_PIN_SHA256',
|
||||
'BARE_OS_BARE_MODULES',
|
||||
'BARE_OS_BARE_DRIVE_BUNDLES'
|
||||
]) {
|
||||
const v = hostEnv[k]
|
||||
if (v != null && v !== '') shellEnv[k] = v
|
||||
}
|
||||
if (hostEnv.TERM != null && String(hostEnv.TERM).trim()) {
|
||||
shellEnv.TERM = String(hostEnv.TERM)
|
||||
}
|
||||
if (hostEnv.COLORTERM != null && String(hostEnv.COLORTERM).trim()) {
|
||||
shellEnv.COLORTERM = String(hostEnv.COLORTERM)
|
||||
}
|
||||
}
|
||||
let bootProfileResolved = ''
|
||||
const bpfEarly = shellEnv.BARE_OS_BOOT_PROFILE
|
||||
@@ -480,6 +498,15 @@ async function executeKernel(disk, store, swarm, initSource) {
|
||||
|
||||
emitBooterBootPhase('vfs')
|
||||
|
||||
/** @type {Record<string, unknown>} */
|
||||
const bareLibrary = {}
|
||||
if (bareOsBareModulesEnabled(shellEnv)) {
|
||||
await maybeMergeBareFromDrive(shellEnv, vfs, bareLibrary)
|
||||
if (bareOsBareHostImportsEnabled(shellEnv)) {
|
||||
await buildBareCtxObjectFromHost(shellEnv, bareLibrary)
|
||||
}
|
||||
}
|
||||
|
||||
const hdmsController = new HdmsController()
|
||||
disk.hdmsController = hdmsController
|
||||
|
||||
@@ -526,6 +553,9 @@ async function executeKernel(disk, store, swarm, initSource) {
|
||||
env: shellEnv,
|
||||
console,
|
||||
b4a,
|
||||
...(bareOsBareModulesEnabled(shellEnv)
|
||||
? { bare: Object.freeze(bareLibrary) }
|
||||
: {}),
|
||||
topic: topicKey(),
|
||||
readLine: async () => null,
|
||||
writeScreen: () => {},
|
||||
@@ -739,6 +769,14 @@ async function executeKernel(disk, store, swarm, initSource) {
|
||||
hint: 'Host Pear runtime (pear-runtime-updater) must apply reload; kernel only exposes env hints.',
|
||||
env
|
||||
}
|
||||
},
|
||||
/** Re-apply `BARE_OS_THEME` / `LS_COLORS` / `BARE_OS_DIRCOLORS` to `vfs.env` (fish + ls pick up on next render). */
|
||||
async bareOsApplyTheme() {
|
||||
return applyBareOsThemeFromEnv(this)
|
||||
},
|
||||
/** Preset names for `/bin/theme` and docs. */
|
||||
bareOsListThemes() {
|
||||
return bareOsListThemeNames()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -798,6 +836,7 @@ async function executeKernel(disk, store, swarm, initSource) {
|
||||
|
||||
ctx.replStdin = sessionStdin
|
||||
ctx.replStdout = sessionStdout
|
||||
ctx.stdout = sessionStdout
|
||||
|
||||
await applyGuestEnv(ctx)
|
||||
await ensureGuestHome(ctx)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,4 +2,4 @@
|
||||
* Semantic version of the booter `ctx` contract for custom kernels.
|
||||
* Bump when adding/removing/renaming documented `ctx` fields or changing behavior.
|
||||
*/
|
||||
export const BARE_OS_CTX_API_VERSION = '1.6.0'
|
||||
export const BARE_OS_CTX_API_VERSION = '1.7.0'
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
/**
|
||||
* Host-resolved Bare / companion npm modules for in-image scripts (`ctx.bare`),
|
||||
* plus optional merge from trusted IIFE bundles on the system drive.
|
||||
*/
|
||||
|
||||
import { readFileSync, statSync } from 'fs'
|
||||
import { dirname, join, resolve } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
export const BARE_OS_STDLIB_GLOBAL = '__bare_os_stdlib__'
|
||||
|
||||
const MANIFEST_NAME = 'bare-module-manifest.json'
|
||||
|
||||
/** @param {string} root */
|
||||
function libDirIfManifestAtRoot(root) {
|
||||
if (!root || root === '/' || root === '') return null
|
||||
const tries = [
|
||||
join(root, 'lib', MANIFEST_NAME),
|
||||
join(root, 'packages', 'bare-os-booter', 'lib', MANIFEST_NAME)
|
||||
]
|
||||
for (const f of tries) {
|
||||
try {
|
||||
if (statSync(f).isFile()) return dirname(f)
|
||||
} catch {
|
||||
/* continue */
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* `pear://app/lib/foo.js` → try **`join(mount, 'lib')`** for each bundle mount (manifest must exist).
|
||||
* @param {string} href
|
||||
* @param {string[]} mounts
|
||||
*/
|
||||
function pearUrlLibDir(href, mounts) {
|
||||
if (!href.startsWith('pear:')) return null
|
||||
let u
|
||||
try {
|
||||
u = new URL(href)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
const segs = u.pathname.split('/').filter(Boolean)
|
||||
if (segs.length < 2) return null
|
||||
segs.pop()
|
||||
const rel = segs.join('/')
|
||||
if (!rel) return null
|
||||
for (const m of mounts) {
|
||||
if (!m || m === '/') continue
|
||||
const candidate = resolve(join(String(m), rel))
|
||||
try {
|
||||
if (statSync(join(candidate, MANIFEST_NAME)).isFile()) return candidate
|
||||
} catch {
|
||||
/* continue */
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Directory containing `bare-module-manifest.json`. Resolved lazily so Pear **`cwd`** / mounts are valid.
|
||||
* Never fall back to **`/lib`** (happens when **`join('/', 'lib')`** after a bogus **`/`** candidate).
|
||||
*/
|
||||
function resolveBareCtxLibDir() {
|
||||
const href = String(import.meta.url)
|
||||
if (href.startsWith('file:')) {
|
||||
return dirname(fileURLToPath(href))
|
||||
}
|
||||
|
||||
const rti = globalThis.Pear?.constructor?.RTI?.mount
|
||||
const swap = globalThis.Pear?.config?.swapDir
|
||||
const cwdRaw =
|
||||
typeof globalThis.process?.cwd === 'function'
|
||||
? globalThis.process.cwd()
|
||||
: ''
|
||||
const cwd = cwdRaw ? resolve(String(cwdRaw)) : resolve('.')
|
||||
|
||||
let d = cwd
|
||||
for (let i = 0; i < 48; i++) {
|
||||
const found = libDirIfManifestAtRoot(d)
|
||||
if (found) return found
|
||||
const parent = dirname(d)
|
||||
if (parent === d) break
|
||||
d = parent
|
||||
}
|
||||
|
||||
const mounts = []
|
||||
const seenM = new Set()
|
||||
for (const c of [rti, swap].filter(Boolean)) {
|
||||
const p = resolve(String(c))
|
||||
if (p === '/' || !p || seenM.has(p)) continue
|
||||
seenM.add(p)
|
||||
mounts.push(p)
|
||||
}
|
||||
const fromPear = pearUrlLibDir(href, mounts)
|
||||
if (fromPear) return fromPear
|
||||
|
||||
const seen = new Set()
|
||||
for (const c of [cwd, ...mounts].filter(Boolean)) {
|
||||
const p = resolve(String(c))
|
||||
if (p === '/' || !p || seen.has(p)) continue
|
||||
seen.add(p)
|
||||
const found = libDirIfManifestAtRoot(p)
|
||||
if (found) return found
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`[bare-os-booter] Cannot find ${MANIFEST_NAME}. ` +
|
||||
`cwd=${JSON.stringify(cwdRaw)} pearMount=${JSON.stringify(rti ?? null)} import.meta.url=${JSON.stringify(href.slice(0, 120))}`
|
||||
)
|
||||
}
|
||||
|
||||
/** @type {{ version: number, entries: Array<{ ctxKey: string, package: string, export?: string, bundle?: boolean, optional?: boolean }> }} */
|
||||
let _cachedManifest = null
|
||||
|
||||
export function loadBareModuleManifest() {
|
||||
if (_cachedManifest) return _cachedManifest
|
||||
const libDir = resolveBareCtxLibDir()
|
||||
const raw = readFileSync(join(libDir, MANIFEST_NAME), 'utf8')
|
||||
_cachedManifest = JSON.parse(raw)
|
||||
return _cachedManifest
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, string>} shellEnv
|
||||
*/
|
||||
export function bareOsBareModulesEnabled(shellEnv) {
|
||||
if (!shellEnv || typeof shellEnv !== 'object') return true
|
||||
const v = shellEnv.BARE_OS_BARE_MODULES
|
||||
return v !== '0' && v !== 'false'
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, string>} shellEnv
|
||||
*/
|
||||
export function bareOsBareDriveBundlesEnabled(shellEnv) {
|
||||
if (!shellEnv || typeof shellEnv !== 'object') return true
|
||||
const v = shellEnv.BARE_OS_BARE_DRIVE_BUNDLES
|
||||
if (v === '0' || v === 'false') return false
|
||||
return bareOsBareModulesEnabled(shellEnv)
|
||||
}
|
||||
|
||||
/**
|
||||
* When false, skip host `import(pkg)` for ctx.bare (use only `/lib/bare` IIFEs).
|
||||
* Set **`BARE_OS_BARE_HOST_IMPORTS=0`** for a fully image-local stdlib.
|
||||
*/
|
||||
export function bareOsBareHostImportsEnabled(shellEnv) {
|
||||
if (!shellEnv || typeof shellEnv !== 'object') return true
|
||||
const v = shellEnv.BARE_OS_BARE_HOST_IMPORTS
|
||||
if (v === '0' || v === 'false') return false
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate object with host `import()` results (per manifest). Mutates `target`.
|
||||
* @param {Record<string, string>} shellEnv
|
||||
* @param {Record<string, unknown>} target
|
||||
*/
|
||||
function bareHostRuntime() {
|
||||
if (typeof globalThis.Bare !== 'undefined') return true
|
||||
const v = globalThis.process?.versions
|
||||
return Boolean(v && typeof v.bare === 'string')
|
||||
}
|
||||
|
||||
export async function buildBareCtxObjectFromHost(shellEnv, target) {
|
||||
if (!bareOsBareModulesEnabled(shellEnv)) return
|
||||
if (!bareOsBareHostImportsEnabled(shellEnv)) return
|
||||
const { entries } = loadBareModuleManifest()
|
||||
const onBare = bareHostRuntime()
|
||||
const tasks = entries.map(async (ent) => {
|
||||
if (!onBare && ent.nativeHint === true) return null
|
||||
const key = ent.ctxKey
|
||||
if (!key || target[key] !== undefined) return null
|
||||
try {
|
||||
const mod = await import(/* webpackIgnore: true */ ent.package)
|
||||
const val = ent.sideEffectImport
|
||||
? mod?.default !== undefined
|
||||
? mod.default
|
||||
: true
|
||||
: ent.export === '*'
|
||||
? mod
|
||||
: mod?.default !== undefined
|
||||
? mod.default
|
||||
: mod
|
||||
return { key, ent, val }
|
||||
} catch (err) {
|
||||
return { key, ent, err }
|
||||
}
|
||||
})
|
||||
const settled = await Promise.all(tasks)
|
||||
for (const r of settled) {
|
||||
if (!r) continue
|
||||
const { key, ent, val, err } = r
|
||||
if (err) {
|
||||
if (!ent.optional) {
|
||||
console.warn(
|
||||
`[bare-os-booter] ctx.bare.${key}: failed to load "${ent.package}":`,
|
||||
err?.message || err
|
||||
)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if (val !== undefined) target[key] = val
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute trusted bundle sources that assign `globalThis.__bare_os_stdlib__[ctxKey]`.
|
||||
* Fills missing keys on `target` only.
|
||||
* @param {Record<string, string>} shellEnv
|
||||
* @param {{ readFile: (p: string, opts?: unknown) => Promise<Uint8Array | null> }} vfs
|
||||
* @param {Record<string, unknown>} target
|
||||
*/
|
||||
export async function maybeMergeBareFromDrive(shellEnv, vfs, target) {
|
||||
if (!bareOsBareModulesEnabled(shellEnv)) return
|
||||
if (!bareOsBareDriveBundlesEnabled(shellEnv)) return
|
||||
if (!vfs || typeof vfs.readFile !== 'function') return
|
||||
|
||||
let metaBuf
|
||||
try {
|
||||
metaBuf = await vfs.readFile('/lib/bare/manifest.json')
|
||||
} catch {
|
||||
metaBuf = null
|
||||
}
|
||||
if (!metaBuf || metaBuf.byteLength === 0) return
|
||||
|
||||
let meta
|
||||
try {
|
||||
const text = new TextDecoder().decode(metaBuf)
|
||||
meta = JSON.parse(text)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
const bundles = meta?.bundles
|
||||
if (!Array.isArray(bundles)) return
|
||||
|
||||
const g = globalThis
|
||||
const sym = BARE_OS_STDLIB_GLOBAL
|
||||
g[sym] = g[sym] && typeof g[sym] === 'object' ? g[sym] : {}
|
||||
|
||||
for (const b of bundles) {
|
||||
const path = typeof b?.path === 'string' ? b.path : ''
|
||||
const keys = Array.isArray(b?.keys) ? b.keys : []
|
||||
if (!path.startsWith('/lib/bare/')) continue
|
||||
|
||||
let srcBuf
|
||||
try {
|
||||
srcBuf = await vfs.readFile(path)
|
||||
} catch {
|
||||
srcBuf = null
|
||||
}
|
||||
if (!srcBuf || srcBuf.byteLength === 0) continue
|
||||
|
||||
const source = new TextDecoder().decode(srcBuf)
|
||||
if (source.length > 12 * 1024 * 1024) continue
|
||||
|
||||
try {
|
||||
const run = new Function(
|
||||
`"use strict"; ${source}\n//# sourceURL=bare-drive-bundle:${path}`
|
||||
)
|
||||
run()
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
`[bare-os-booter] drive bundle failed ${path}:`,
|
||||
err?.message || err
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
const snap = g[sym]
|
||||
if (!snap || typeof snap !== 'object') continue
|
||||
|
||||
for (const k of keys) {
|
||||
if (typeof k !== 'string' || !k) continue
|
||||
if (target[k] !== undefined) continue
|
||||
if (Object.prototype.hasOwnProperty.call(snap, k)) {
|
||||
target[k] = snap[k]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,6 +91,8 @@ export interface BareOsKernelContext {
|
||||
env: string[]
|
||||
}
|
||||
bareOsHostStats?: Readonly<BareOsHostStats>
|
||||
/** Host-resolved (and optional drive-bundled) Holepunch-style modules; absent when `BARE_OS_BARE_MODULES=0`. */
|
||||
bare?: Readonly<Record<string, unknown>>
|
||||
httpFetch?: typeof fetch
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
*/
|
||||
|
||||
import { BARE_OS_CTX_API_VERSION } from './bare-os-ctx-api.js'
|
||||
import {
|
||||
bareOsBareDriveBundlesEnabled,
|
||||
bareOsBareHostImportsEnabled,
|
||||
bareOsBareModulesEnabled
|
||||
} from './bare-os-ctx-bare.js'
|
||||
import {
|
||||
DEFAULT_PIPELINE_MAX_CAPTURE_BYTES,
|
||||
DEFAULT_PIPELINE_MAX_CAPTURE_LINES,
|
||||
@@ -138,7 +143,14 @@ export function buildBareOsRuntimeCaps(shellEnv) {
|
||||
abortableExecLine: true,
|
||||
httpFetchPolicy: true,
|
||||
virtualRegisterFiles: true,
|
||||
hostStatsBridge: true
|
||||
hostStatsBridge: true,
|
||||
bareCtxModules: bareOsBareModulesEnabled(shellEnv),
|
||||
bareHostImportsForCtx:
|
||||
bareOsBareModulesEnabled(shellEnv) &&
|
||||
bareOsBareHostImportsEnabled(shellEnv),
|
||||
bareDriveBundles:
|
||||
bareOsBareModulesEnabled(shellEnv) &&
|
||||
bareOsBareDriveBundlesEnabled(shellEnv)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
/**
|
||||
* Named UI themes: REPL ANSI tokens + LS_COLORS strings for Bare OS.
|
||||
*/
|
||||
|
||||
import {
|
||||
bareDefaultLsColorsString,
|
||||
bareParseDircolorsDatabase,
|
||||
bareSerializeLsColors
|
||||
} from 'bare-os-lscolors'
|
||||
|
||||
/** @typedef {{ colors: Record<string, string>, lsColors?: string }} BareOsThemePreset */
|
||||
|
||||
/** @type {Record<string, BareOsThemePreset>} */
|
||||
export const BARE_OS_THEME_PRESETS = {
|
||||
default: {
|
||||
colors: {
|
||||
prompt: '\x1b[32m',
|
||||
command: '\x1b[36m',
|
||||
path: '\x1b[33m',
|
||||
envset: '\x1b[35m',
|
||||
envunset: '\x1b[31m',
|
||||
ghost: '\x1b[90m',
|
||||
search: '\x1b[36m'
|
||||
}
|
||||
},
|
||||
dracula: {
|
||||
colors: {
|
||||
prompt: '\x1b[38;2;80;250;123m',
|
||||
command: '\x1b[38;2;139;233;253m',
|
||||
path: '\x1b[38;2;241;250;140m',
|
||||
envset: '\x1b[38;2;189;147;249m',
|
||||
envunset: '\x1b[38;2;255;85;85m',
|
||||
ghost: '\x1b[38;2;98;114;164m',
|
||||
search: '\x1b[38;2;139;233;253m'
|
||||
},
|
||||
lsColors:
|
||||
'no=00:fi=00:di=01;36:ln=01;35:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:tw=30;42:ow=34;43:st=37;44:ex=01;33'
|
||||
},
|
||||
nord: {
|
||||
colors: {
|
||||
prompt: '\x1b[38;2;163;190;140m',
|
||||
command: '\x1b[38;2;136;192;208m',
|
||||
path: '\x1b[38;2;235;203;139m',
|
||||
envset: '\x1b[38;2;180;142;173m',
|
||||
envunset: '\x1b[38;2;191;97;106m',
|
||||
ghost: '\x1b[38;2;76;86;106m',
|
||||
search: '\x1b[38;2;136;192;208m'
|
||||
},
|
||||
lsColors:
|
||||
'no=00:fi=00:di=01;34:ln=01;36:pi=33:so=01;35:bd=33;01:cd=33;01:or=31;01:mi=00:su=37;41:sg=30;43:tw=30;42:ow=34;43:st=37;44:ex=01;32'
|
||||
},
|
||||
solarized_dark: {
|
||||
colors: {
|
||||
prompt: '\x1b[38;2;133;153;0m',
|
||||
command: '\x1b[38;2;38;139;210m',
|
||||
path: '\x1b[38;2;181;137;0m',
|
||||
envset: '\x1b[38;2;108;113;196m',
|
||||
envunset: '\x1b[38;2;220;50;47m',
|
||||
ghost: '\x1b[38;2;88;110;117m',
|
||||
search: '\x1b[38;2;38;139;210m'
|
||||
},
|
||||
lsColors:
|
||||
'no=00:fi=00:di=01;34:ln=01;36:pi=33:so=01;35:bd=33;01:cd=33;01:or=31;01:mi=00:su=37;41:sg=30;43:tw=30;42:ow=34;43:st=37;44:ex=01;32'
|
||||
},
|
||||
gruvbox_dark: {
|
||||
colors: {
|
||||
prompt: '\x1b[38;2;184;187;38m',
|
||||
command: '\x1b[38;2;131;165;152m',
|
||||
path: '\x1b[38;2;250;189;47m',
|
||||
envset: '\x1b[38;2;211;134;155m',
|
||||
envunset: '\x1b[38;2;251;73;52m',
|
||||
ghost: '\x1b[38;2;102;92;84m',
|
||||
search: '\x1b[38;2;131;165;152m'
|
||||
},
|
||||
lsColors:
|
||||
'no=00:fi=00:di=01;34:ln=01;36:pi=33:so=01;35:bd=33;01:cd=33;01:or=31;01:mi=00:su=37;41:sg=30;43:tw=30;42:ow=34;43:st=37;44:ex=01;32'
|
||||
},
|
||||
catppuccin_mocha: {
|
||||
colors: {
|
||||
prompt: '\x1b[38;2;166;227;161m',
|
||||
command: '\x1b[38;2;137;180;250m',
|
||||
path: '\x1b[38;2;249;226;175m',
|
||||
envset: '\x1b[38;2;203;166;247m',
|
||||
envunset: '\x1b[38;2;243;139;168m',
|
||||
ghost: '\x1b[38;2;108;112;134m',
|
||||
search: '\x1b[38;2;137;180;250m'
|
||||
},
|
||||
lsColors:
|
||||
'no=00:fi=00:di=01;36:ln=01;35:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:tw=30;42:ow=34;43:st=37;44:ex=01;33'
|
||||
},
|
||||
tokyo_night: {
|
||||
colors: {
|
||||
prompt: '\x1b[38;2;158;206;106m',
|
||||
command: '\x1b[38;2;122;162;247m',
|
||||
path: '\x1b[38;2;224;163;82m',
|
||||
envset: '\x1b[38;2;187;154;247m',
|
||||
envunset: '\x1b[38;2;247;118;142m',
|
||||
ghost: '\x1b[38;2;86;95;137m',
|
||||
search: '\x1b[38;2;122;162;247m'
|
||||
},
|
||||
lsColors:
|
||||
'no=00:fi=00:di=01;34:ln=01;36:pi=33:so=01;35:bd=33;01:cd=33;01:or=31;01:mi=00:su=37;41:sg=30;43:tw=30;42:ow=34;43:st=37;44:ex=01;32'
|
||||
},
|
||||
github_dark: {
|
||||
colors: {
|
||||
prompt: '\x1b[38;2;63;185;80m',
|
||||
command: '\x1b[38;2;121;192;255m',
|
||||
path: '\x1b[38;2;210;153;34m',
|
||||
envset: '\x1b[38;2;188;140;255m',
|
||||
envunset: '\x1b[38;2;248;81;73m',
|
||||
ghost: '\x1b[38;2;110;118;129m',
|
||||
search: '\x1b[38;2;121;192;255m'
|
||||
},
|
||||
lsColors:
|
||||
'no=00:fi=00:di=01;34:ln=01;36:pi=33:so=01;35:bd=33;01:cd=33;01:or=31;01:mi=00:su=37;41:sg=30;43:tw=30;42:ow=34;43:st=37;44:ex=01;32'
|
||||
}
|
||||
}
|
||||
|
||||
BARE_OS_THEME_PRESETS.default.lsColors = bareDefaultLsColorsString()
|
||||
|
||||
/**
|
||||
* Downgrade truecolor REPL sequences in BARE_OS_COLOR_* for limited terminals.
|
||||
* @param {Record<string, unknown>} env
|
||||
*/
|
||||
export function bareOsDowngradeReplColorsForDepth(env) {
|
||||
if (!env || typeof env !== 'object') return
|
||||
const depth = String(env.BARE_OS_COLOR_DEPTH ?? 'truecolor')
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
if (
|
||||
depth === '' ||
|
||||
depth === 'truecolor' ||
|
||||
depth === '24bit' ||
|
||||
depth === 'rgb'
|
||||
)
|
||||
return
|
||||
|
||||
const keys = Object.keys(env).filter((k) => k.startsWith('BARE_OS_COLOR_'))
|
||||
for (const k of keys) {
|
||||
const raw = env[k]
|
||||
if (raw == null) continue
|
||||
let v = String(raw)
|
||||
if (depth === '256' || depth === '8bit') {
|
||||
v = v.replace(
|
||||
/\x1b\[38;2;(\d+);(\d+);(\d+)m/g,
|
||||
(_, rs, gs, bs) => {
|
||||
const r = Math.min(255, Math.max(0, Number(rs)))
|
||||
const g = Math.min(255, Math.max(0, Number(gs)))
|
||||
const b = Math.min(255, Math.max(0, Number(bs)))
|
||||
const ri = Math.min(5, Math.round((r / 255) * 5))
|
||||
const gi = Math.min(5, Math.round((g / 255) * 5))
|
||||
const bi = Math.min(5, Math.round((b / 255) * 5))
|
||||
const idx = 16 + 36 * ri + 6 * gi + bi
|
||||
return '\x1b[38;5;' + idx + 'm'
|
||||
}
|
||||
)
|
||||
} else if (depth === '16' || depth === '8' || depth === 'ansi') {
|
||||
v = v.replace(
|
||||
/\x1b\[38;2;(\d+);(\d+);(\d+)m/g,
|
||||
(_, rs, gs, bs) => {
|
||||
const r = Number(rs)
|
||||
const g = Number(gs)
|
||||
const b = Number(bs)
|
||||
const lum = 0.299 * r + 0.587 * g + 0.114 * b
|
||||
const bold = lum > 195 ? '1;' : ''
|
||||
const max = Math.max(r, g, b)
|
||||
if (max < 48) return '\x1b[90m'
|
||||
if (r > g * 1.25 && r > b * 1.25) return '\x1b[' + bold + '31m'
|
||||
if (g > r * 1.25 && g > b * 1.25) return '\x1b[' + bold + '32m'
|
||||
if (b > r * 1.25 && b > g * 1.25) return '\x1b[' + bold + '34m'
|
||||
if (r > 200 && g > 200 && b < 120) return '\x1b[' + bold + '33m'
|
||||
if (g > 180 && b > 180) return '\x1b[' + bold + '36m'
|
||||
if (r > 180 && b > 180) return '\x1b[' + bold + '35m'
|
||||
return '\x1b[' + bold + '37m'
|
||||
}
|
||||
)
|
||||
}
|
||||
env[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string[]}
|
||||
*/
|
||||
export function bareOsListThemeNames() {
|
||||
return Object.keys(BARE_OS_THEME_PRESETS).sort()
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns {BareOsThemePreset | null}
|
||||
*/
|
||||
export function bareOsGetThemePreset(name) {
|
||||
const k = String(name || 'default')
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/\s+/g, '_')
|
||||
return BARE_OS_THEME_PRESETS[k] || null
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply active theme to ctx.vfs.env (REPL colors + LS_COLORS when not user-locked).
|
||||
* @param {Record<string, unknown>} ctx
|
||||
*/
|
||||
export async function applyBareOsThemeFromEnv(ctx) {
|
||||
const vfs = ctx.vfs
|
||||
const env = vfs && vfs.env
|
||||
if (!env || typeof env !== 'object') return
|
||||
|
||||
const rawName = env.BARE_OS_THEME
|
||||
const themeKey = String(rawName != null && rawName !== '' ? rawName : 'default')
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/\s+/g, '_')
|
||||
|
||||
const preset =
|
||||
BARE_OS_THEME_PRESETS[themeKey] || BARE_OS_THEME_PRESETS.default
|
||||
|
||||
for (const [short, seq] of Object.entries(preset.colors || {})) {
|
||||
env['BARE_OS_COLOR_' + short.toUpperCase()] = seq
|
||||
}
|
||||
|
||||
const locked = env.BARE_OS_LS_COLORS_LOCKED === '1'
|
||||
const hadLsColors =
|
||||
env.LS_COLORS != null && String(env.LS_COLORS).trim() !== ''
|
||||
|
||||
const dcPath = env.BARE_OS_DIRCOLORS
|
||||
if (dcPath && String(dcPath).trim() && !locked) {
|
||||
try {
|
||||
const buf = await vfs.readFile(dcPath)
|
||||
if (buf && ctx.b4a) {
|
||||
const text = ctx.b4a.toString(buf)
|
||||
const term = env.TERM || ''
|
||||
const db = bareParseDircolorsDatabase(text, term)
|
||||
env.LS_COLORS = bareSerializeLsColors(db)
|
||||
}
|
||||
} catch {
|
||||
/* keep existing LS_COLORS */
|
||||
}
|
||||
} else if (!hadLsColors && !locked) {
|
||||
env.LS_COLORS =
|
||||
preset.lsColors != null ? preset.lsColors : bareDefaultLsColorsString()
|
||||
}
|
||||
|
||||
bareOsDowngradeReplColorsForDepth(env)
|
||||
}
|
||||
@@ -7,7 +7,14 @@
|
||||
*/
|
||||
|
||||
/** @type {readonly string[]} */
|
||||
export const SHELL_BUILTINS = ['cd', 'export', 'exit', 'login', 'logout']
|
||||
export const SHELL_BUILTINS = [
|
||||
'barerc',
|
||||
'cd',
|
||||
'export',
|
||||
'exit',
|
||||
'login',
|
||||
'logout'
|
||||
]
|
||||
|
||||
/** @param {Record<string, unknown>} ctx */
|
||||
function replHistoryDrivePath(ctx) {
|
||||
@@ -300,6 +307,11 @@ export async function createFishReadLine(ctx, { stdin, stdout, writeScreen }) {
|
||||
let inputBuffer = ''
|
||||
let processing = false
|
||||
|
||||
function colorFromEnv(key, fallback) {
|
||||
const v = env[key]
|
||||
return v != null && String(v) !== '' ? String(v) : fallback
|
||||
}
|
||||
|
||||
function getPromptBase(isContinuation = false) {
|
||||
let displayPath = vfs.getcwd()
|
||||
const home = env.HOME || '/home/guest'
|
||||
@@ -310,7 +322,8 @@ export async function createFishReadLine(ctx, { stdin, stdout, writeScreen }) {
|
||||
}
|
||||
const user = env.USER || 'user'
|
||||
const host = env.HOSTNAME || 'bare-os'
|
||||
const base = `\x1b[32m[${user}@${host}:${displayPath}]\x1b[0m`
|
||||
const open = colorFromEnv('BARE_OS_COLOR_PROMPT', '\x1b[32m')
|
||||
const base = `${open}[${user}@${host}:${displayPath}]\x1b[0m`
|
||||
return isContinuation ? `${base} ` : `${base} `
|
||||
}
|
||||
|
||||
@@ -340,20 +353,26 @@ export async function createFishReadLine(ctx, { stdin, stdout, writeScreen }) {
|
||||
const cmd = parts[0]
|
||||
const knownCmd = new Set([...SHELL_BUILTINS, ...(cachedBinNames || [])])
|
||||
let coloredLine = firstLine
|
||||
const cmdOpen = colorFromEnv('BARE_OS_COLOR_COMMAND', '\x1b[36m')
|
||||
const pathOpen = colorFromEnv('BARE_OS_COLOR_PATH', '\x1b[33m')
|
||||
const envSetOpen = colorFromEnv('BARE_OS_COLOR_ENVSET', '\x1b[35m')
|
||||
const envUnsetOpen = colorFromEnv('BARE_OS_COLOR_ENVUNSET', '\x1b[31m')
|
||||
if (cmd && knownCmd.has(cmd)) {
|
||||
coloredLine = `\x1b[36m${cmd}\x1b[0m${firstLine.slice(cmd.length)}`
|
||||
coloredLine = `${cmdOpen}${cmd}\x1b[0m${firstLine.slice(cmd.length)}`
|
||||
}
|
||||
|
||||
const pathRegex = /(\/[^\s]+|\.\/[^\s]+|\.\.\/[^\s]+)/g
|
||||
coloredLine = coloredLine.replace(
|
||||
pathRegex,
|
||||
(match) => `\x1b[33m${match}\x1b[0m`
|
||||
(match) => `${pathOpen}${match}\x1b[0m`
|
||||
)
|
||||
|
||||
const envRegex = /\$(\w+)/g
|
||||
coloredLine = coloredLine.replace(envRegex, (match, varName) => {
|
||||
const value = env[varName]
|
||||
return value ? `\x1b[35m${match}\x1b[0m` : `\x1b[31m${match}\x1b[0m`
|
||||
return value
|
||||
? `${envSetOpen}${match}\x1b[0m`
|
||||
: `${envUnsetOpen}${match}\x1b[0m`
|
||||
})
|
||||
return coloredLine
|
||||
}
|
||||
@@ -401,14 +420,16 @@ export async function createFishReadLine(ctx, { stdin, stdout, writeScreen }) {
|
||||
ghost.startsWith(currentLine) &&
|
||||
!historySearchActive
|
||||
) {
|
||||
stdout.write(`\x1b[90m${ghost.slice(currentLine.length)}\x1b[0m`)
|
||||
stdout.write(
|
||||
`${colorFromEnv('BARE_OS_COLOR_GHOST', '\x1b[90m')}${ghost.slice(currentLine.length)}\x1b[0m`
|
||||
)
|
||||
}
|
||||
if (!isLastLine) stdout.write('\n')
|
||||
}
|
||||
|
||||
if (showHistorySearch || historySearchActive) {
|
||||
stdout.write(
|
||||
`\n\x1b[36m(reverse-i-search)'${historySearchQuery}':\x1b[0m ${historySearchResults[historySearchIndex] || ''}`
|
||||
`\n${colorFromEnv('BARE_OS_COLOR_SEARCH', '\x1b[36m')}(reverse-i-search)'${historySearchQuery}':\x1b[0m ${historySearchResults[historySearchIndex] || ''}`
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
import { runBinCommand, resolveBinInPath } from './kernel-runner.js'
|
||||
import {
|
||||
applyBareOsThemeFromEnv,
|
||||
bareOsGetThemePreset,
|
||||
bareOsListThemeNames
|
||||
} from './bare-os-theme-presets.js'
|
||||
|
||||
const SHELL_BUILTINS = new Set([
|
||||
'alias',
|
||||
'unalias',
|
||||
'barerc',
|
||||
'cd',
|
||||
'export',
|
||||
'unset',
|
||||
@@ -197,15 +203,19 @@ function applyBarercUnalias(ctx, rest) {
|
||||
* Comment-only template written on first login when `~/.barerc` is absent
|
||||
* (`loadBarerc(ctx, { createSkeletonIfMissing: true })`).
|
||||
*/
|
||||
export const BARERC_SKELETON = `# Bare OS — ~/.barerc (not full sh; only export, alias, unalias, # comments).
|
||||
export const BARERC_SKELETON = `# Bare OS — ~/.barerc (not full sh; only export, alias, unalias, theme, # comments).
|
||||
#
|
||||
# export MY_VAR=value
|
||||
# theme default
|
||||
# export BARE_OS_COLOR_DEPTH=truecolor
|
||||
# export BARE_OS_DIRCOLORS=~/.dir_colors
|
||||
# export BARE_OS_LS_COLORS_LOCKED=1
|
||||
# alias gst='git status'
|
||||
# unalias ll
|
||||
`
|
||||
|
||||
/**
|
||||
* Load `~/.barerc`: only `export`, `alias`, `unalias`, comments, blank lines.
|
||||
* Load `~/.barerc`: only `export`, `alias`, `unalias`, `theme`, comments, blank lines.
|
||||
* Resets aliases to defaults first, then applies file.
|
||||
* @param {Record<string, unknown>} ctx
|
||||
* @param {{ createSkeletonIfMissing?: boolean }} [opts] If true and the file is missing, write {@link BARERC_SKELETON} (login / unlock only).
|
||||
@@ -236,7 +246,10 @@ export async function loadBarerc(ctx, opts = {}) {
|
||||
}
|
||||
|
||||
if (!text) {
|
||||
if (!buf) return
|
||||
if (!buf) {
|
||||
await applyBareOsThemeFromEnv(ctx)
|
||||
return
|
||||
}
|
||||
text = ctx.b4a.toString(buf)
|
||||
}
|
||||
for (const line of text.split(/\r?\n/)) {
|
||||
@@ -252,6 +265,24 @@ export async function loadBarerc(ctx, opts = {}) {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if (t.startsWith('theme ') || t === 'theme') {
|
||||
const name = t === 'theme' ? '' : t.slice(6).trim()
|
||||
if (!name) {
|
||||
if (strict) ctx.console?.error?.('barerc: theme requires a name')
|
||||
continue
|
||||
}
|
||||
if (!/^[a-zA-Z0-9_.-]+$/.test(name)) {
|
||||
if (strict) ctx.console?.error?.('barerc: invalid theme name: ' + name)
|
||||
continue
|
||||
}
|
||||
const norm = name.toLowerCase().replace(/\s+/g, '_')
|
||||
if (!bareOsGetThemePreset(norm)) {
|
||||
ctx.console?.error?.('barerc: unknown theme: ' + name)
|
||||
continue
|
||||
}
|
||||
env.BARE_OS_THEME = norm
|
||||
continue
|
||||
}
|
||||
if (t.startsWith('alias ')) {
|
||||
const ok = applyAliasDefinition(ctx, t.slice(6).trim())
|
||||
if (!ok && strict) ctx.console?.error?.('barerc: ignored: ' + t)
|
||||
@@ -263,6 +294,7 @@ export async function loadBarerc(ctx, opts = {}) {
|
||||
}
|
||||
if (strict) ctx.console?.error?.('barerc: ignored: ' + t)
|
||||
}
|
||||
await applyBareOsThemeFromEnv(ctx)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -831,6 +863,14 @@ async function execParsedPipeline(ctx, pipeline) {
|
||||
origErr.call(ctx.console, m)
|
||||
ctx.exitCode = 1
|
||||
})
|
||||
} else if (name === 'barerc') {
|
||||
const sub = argv[1]
|
||||
if (sub === 'reload') {
|
||||
await loadBarerc(ctx, { createSkeletonIfMissing: false })
|
||||
} else {
|
||||
origErr.call(ctx.console, 'barerc: usage: barerc reload')
|
||||
ctx.exitCode = 1
|
||||
}
|
||||
} else if (name === 'cd') {
|
||||
try {
|
||||
await vfs.chdir(argv[1] || vfs.home)
|
||||
|
||||
@@ -14,11 +14,16 @@
|
||||
"autopass": "^3.4.0",
|
||||
"b4a": "^1.6.7",
|
||||
"bare-crypto": "^1.13.4",
|
||||
"bare-encoding": "^1.0.3",
|
||||
"bare-events": "^2.8.2",
|
||||
"bare-fetch": "^2.8.1",
|
||||
"bare-os": "^3.8.7",
|
||||
"bare-os-lscolors": "*",
|
||||
"bare-os-protocol": "*",
|
||||
"bare-path": "^3.0.0",
|
||||
"bare-readline": "^1.3.1",
|
||||
"bare-stdio": "^1.0.2",
|
||||
"bare-url": "^2.4.0",
|
||||
"compact-encoding": "^2.18.0",
|
||||
"corestore": "^7.2.1",
|
||||
"hypercore-id-encoding": "^1.3.0",
|
||||
@@ -71,5 +76,125 @@
|
||||
"bare": "bare-url",
|
||||
"default": "node:url"
|
||||
}
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"bare-abort": "^2.0.13",
|
||||
"bare-abort-controller": "^1.1.1",
|
||||
"bare-addon-resolve": "^1.10.0",
|
||||
"bare-ansi-escapes": "^2.2.3",
|
||||
"bare-apk": "^0.1.2",
|
||||
"bare-app-kit": "^0.1.0",
|
||||
"bare-assert": "^1.2.0",
|
||||
"bare-async-hooks": "^0.0.0",
|
||||
"bare-atomics": "^3.0.7",
|
||||
"bare-bluetooth-apple": "^0.1.2",
|
||||
"bare-bmp": "^1.0.0",
|
||||
"bare-boot": "^4.0.0",
|
||||
"bare-buffer": "^3.6.0",
|
||||
"bare-bundle": "^1.10.0",
|
||||
"bare-bundle-compile": "^1.2.2",
|
||||
"bare-bundle-evaluate": "^2.0.0",
|
||||
"bare-bundle-id": "^1.0.2",
|
||||
"bare-channel": "^5.2.3",
|
||||
"bare-console": "^6.1.0",
|
||||
"bare-cov": "^1.2.1",
|
||||
"bare-daemon": "^1.2.4",
|
||||
"bare-debug-log": "^2.0.0",
|
||||
"bare-delta": "^1.1.0",
|
||||
"bare-dev": "^0.14.11",
|
||||
"bare-dgram": "^1.0.1",
|
||||
"bare-diagnostics-channel": "^1.1.0",
|
||||
"bare-dns": "^2.1.4",
|
||||
"bare-env": "^3.0.0",
|
||||
"bare-exif": "^1.0.1",
|
||||
"bare-ffmpeg": "^1.2.2",
|
||||
"bare-ffmpeg-encodings": "^1.2.1",
|
||||
"bare-file-logger": "^1.2.1",
|
||||
"bare-form-data": "^1.2.1",
|
||||
"bare-format": "^1.0.2",
|
||||
"bare-fs": "^4.6.0",
|
||||
"bare-gif": "^1.1.3",
|
||||
"bare-gtk": "^0.1.1",
|
||||
"bare-heif": "^1.0.10",
|
||||
"bare-hrtime": "^2.1.1",
|
||||
"bare-http-parser": "^1.1.3",
|
||||
"bare-http1": "^4.5.5",
|
||||
"bare-https": "^2.1.3",
|
||||
"bare-ico": "^1.0.0",
|
||||
"bare-image-resample": "^1.0.2",
|
||||
"bare-inspect": "^3.1.4",
|
||||
"bare-inspector": "^6.0.0",
|
||||
"bare-intl": "^0.0.0",
|
||||
"bare-ipc": "^1.1.1",
|
||||
"bare-jpeg": "^1.0.4",
|
||||
"bare-lief": "^0.2.1",
|
||||
"bare-link": "^3.1.0",
|
||||
"bare-logger": "^2.0.3",
|
||||
"bare-make": "^1.7.2",
|
||||
"bare-media": "^2.5.0",
|
||||
"bare-module": "^6.1.3",
|
||||
"bare-module-lexer": "^1.4.7",
|
||||
"bare-module-resolve": "^1.12.1",
|
||||
"bare-module-traverse": "^2.0.1",
|
||||
"bare-native": "^0.1.2",
|
||||
"bare-ndk": "^0.1.4",
|
||||
"bare-net": "^2.3.1",
|
||||
"bare-node-fetch": "^1.0.0",
|
||||
"bare-node-runtime": "^1.2.0",
|
||||
"bare-open": "^1.0.3",
|
||||
"bare-pack": "^2.0.1",
|
||||
"bare-pack-drive": "^2.0.0",
|
||||
"bare-performance": "^2.0.0",
|
||||
"bare-pipe": "^4.1.5",
|
||||
"bare-png": "^1.0.5",
|
||||
"bare-prebuild": "^1.1.2",
|
||||
"bare-process": "^4.4.1",
|
||||
"bare-prom-client": "^15.1.6",
|
||||
"bare-punycode": "^0.0.0",
|
||||
"bare-querystring": "^1.0.0",
|
||||
"bare-queue-microtask": "^1.0.0",
|
||||
"bare-realm": "^2.0.1",
|
||||
"bare-repl": "^6.0.2",
|
||||
"bare-rpc": "^1.2.0",
|
||||
"bare-run": "^0.0.3",
|
||||
"bare-runtime": "^1.28.1",
|
||||
"bare-sdl": "^1.0.0-5",
|
||||
"bare-semver": "^1.0.2",
|
||||
"bare-sidecar": "^0.3.0",
|
||||
"bare-signals": "^4.2.0",
|
||||
"bare-storage": "^1.1.0",
|
||||
"bare-stream": "^2.12.0",
|
||||
"bare-string-decoder": "^1.0.0",
|
||||
"bare-structured-clone": "^1.5.3",
|
||||
"bare-subprocess": "^5.2.3",
|
||||
"bare-svg": "^1.0.1",
|
||||
"bare-system-logger": "^1.0.3",
|
||||
"bare-tap": "^1.0.0",
|
||||
"bare-tcp": "^2.2.7",
|
||||
"bare-thread": "^1.2.0",
|
||||
"bare-tiff": "^1.0.2",
|
||||
"bare-timers": "^3.2.1",
|
||||
"bare-tls": "^2.2.1",
|
||||
"bare-tpl": "^1.0.0",
|
||||
"bare-tty": "^5.1.0",
|
||||
"bare-type": "^1.1.0",
|
||||
"bare-ui-kit": "^0.1.1",
|
||||
"bare-union-bundle": "^1.1.1",
|
||||
"bare-unpack": "^1.1.3",
|
||||
"bare-utils": "^1.6.0",
|
||||
"bare-v8": "^1.0.1",
|
||||
"bare-v8-to-istanbul": "^1.0.2",
|
||||
"bare-vm": "^1.0.1",
|
||||
"bare-walk-handles": "^2.0.10",
|
||||
"bare-web-kit": "^0.1.2",
|
||||
"bare-web-kit-gtk": "^0.1.0",
|
||||
"bare-webp": "^1.3.0",
|
||||
"bare-which": "^2.0.0",
|
||||
"bare-win-ui": "^0.1.0",
|
||||
"bare-worker": "^4.1.6",
|
||||
"bare-ws": "^2.1.0",
|
||||
"bare-xdiff": "^2.0.1",
|
||||
"bare-zlib": "^1.3.1",
|
||||
"bare-zmq": "^1.2.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,25 @@ import {
|
||||
getBareOsPipelineLimits,
|
||||
DEFAULT_PIPELINE_MAX_STAGES
|
||||
} from './lib/shell.js'
|
||||
import {
|
||||
applyBareOsThemeFromEnv,
|
||||
bareOsListThemeNames
|
||||
} from './lib/bare-os-theme-presets.js'
|
||||
import {
|
||||
bareParseLsColors,
|
||||
bareSerializeLsColors,
|
||||
bareLsColorOpenSgrFromMap,
|
||||
bareDefaultDircolorsDatabase,
|
||||
bareParseDircolorsDatabase
|
||||
} from 'bare-os-lscolors'
|
||||
import { BARE_OS_CTX_API_VERSION } from './lib/bare-os-ctx-api.js'
|
||||
import { buildBareOsRuntimeCaps } from './lib/bare-os-runtime-caps.js'
|
||||
import {
|
||||
bareOsBareModulesEnabled,
|
||||
buildBareCtxObjectFromHost,
|
||||
loadBareModuleManifest,
|
||||
maybeMergeBareFromDrive
|
||||
} from './lib/bare-os-ctx-bare.js'
|
||||
import {
|
||||
fuzzyMatch,
|
||||
stripAnsi,
|
||||
@@ -91,15 +108,22 @@ function testCtx(drive, personal, env) {
|
||||
}
|
||||
const bareOsIpc = createBareOsIpc()
|
||||
const vfs = createVfs(drive, personal, shellEnv, null, { bareOsIpc })
|
||||
return {
|
||||
const ctx = {
|
||||
drive,
|
||||
personalDrive: personal,
|
||||
vfs,
|
||||
bareOsIpc,
|
||||
env: shellEnv,
|
||||
console,
|
||||
b4a
|
||||
b4a,
|
||||
async bareOsApplyTheme() {
|
||||
return applyBareOsThemeFromEnv(this)
|
||||
},
|
||||
bareOsListThemes() {
|
||||
return bareOsListThemeNames()
|
||||
}
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
/** Personal-drive path backing logical `/home/<seg>/…` (matches `vfs.js`). */
|
||||
@@ -555,6 +579,88 @@ test('ls -l long listing uses session user and regular file mode', async (t) =>
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
test('ls --color=always colors directory blue and executable green', async (t) => {
|
||||
const lsPath = path.join(__dirname, '../../kernel/bin/ls')
|
||||
const lsSrc = await readFile(lsPath, 'utf8')
|
||||
const dir = testCorestoreDir('lscolor')
|
||||
const store = new Corestore(dir)
|
||||
const drive = new Hyperdrive(store)
|
||||
const personal = new Hyperdrive(store.namespace('plsc'))
|
||||
await drive.ready()
|
||||
await personal.ready()
|
||||
await drive.put('/bin/ls', b4a.from(lsSrc))
|
||||
const lines = []
|
||||
const ctx = testCtx(drive, personal)
|
||||
ctx.console = {
|
||||
log: (s) => lines.push(String(s)),
|
||||
error: (...a) => lines.push(a.join(' '))
|
||||
}
|
||||
await ctx.vfs.mkdir('subdir', { recursive: true })
|
||||
await ctx.vfs.writeFile('xfile', b4a.from(''))
|
||||
await ctx.vfs.chmod('xfile', 0o755)
|
||||
await runBinCommand(ctx, ['ls', '--color=always'])
|
||||
const shortLine = lines.find((l) => l.includes('subdir') && l.includes('xfile'))
|
||||
t.ok(shortLine)
|
||||
t.ok(
|
||||
/\x1b\[[0-9;]*msubdir\x1b\[0m/.test(shortLine),
|
||||
'directory uses LS_COLORS di SGR'
|
||||
)
|
||||
t.ok(
|
||||
/\x1b\[[0-9;]*mxfile\x1b\[0m/.test(shortLine),
|
||||
'executable uses LS_COLORS ex SGR'
|
||||
)
|
||||
await store.close()
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
test('ls honors NO_COLOR over --color=always', async (t) => {
|
||||
const lsPath = path.join(__dirname, '../../kernel/bin/ls')
|
||||
const lsSrc = await readFile(lsPath, 'utf8')
|
||||
const dir = testCorestoreDir('lscolornc')
|
||||
const store = new Corestore(dir)
|
||||
const drive = new Hyperdrive(store)
|
||||
const personal = new Hyperdrive(store.namespace('plsn'))
|
||||
await drive.ready()
|
||||
await personal.ready()
|
||||
await drive.put('/bin/ls', b4a.from(lsSrc))
|
||||
const lines = []
|
||||
const ctx = testCtx(drive, personal, { NO_COLOR: '1' })
|
||||
ctx.console = {
|
||||
log: (s) => lines.push(String(s)),
|
||||
error: (...a) => lines.push(a.join(' '))
|
||||
}
|
||||
await ctx.vfs.mkdir('onlydir', { recursive: true })
|
||||
await runBinCommand(ctx, ['ls', '--color=always'])
|
||||
const shortLine = lines.find((l) => l.includes('onlydir'))
|
||||
t.ok(shortLine)
|
||||
t.ok(!shortLine.includes('\x1b['), 'NO_COLOR strips ANSI')
|
||||
await store.close()
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
test('ls rejects unknown long option', async (t) => {
|
||||
const lsPath = path.join(__dirname, '../../kernel/bin/ls')
|
||||
const lsSrc = await readFile(lsPath, 'utf8')
|
||||
const dir = testCorestoreDir('lsbadopt')
|
||||
const store = new Corestore(dir)
|
||||
const drive = new Hyperdrive(store)
|
||||
const personal = new Hyperdrive(store.namespace('plbo'))
|
||||
await drive.ready()
|
||||
await personal.ready()
|
||||
await drive.put('/bin/ls', b4a.from(lsSrc))
|
||||
const errs = []
|
||||
const ctx = testCtx(drive, personal)
|
||||
ctx.console = {
|
||||
log: () => {},
|
||||
error: (...a) => errs.push(a.join(' '))
|
||||
}
|
||||
await runBinCommand(ctx, ['ls', '--not-a-real-option'])
|
||||
t.is(ctx.exitCode, 2)
|
||||
t.ok(errs.some((e) => e.includes('unrecognized')))
|
||||
await store.close()
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
test('vfs readFile missing path in home does not throw (touch pattern)', async (t) => {
|
||||
const dir = testCorestoreDir('vfsreadmiss')
|
||||
const store = new Corestore(dir)
|
||||
@@ -1050,6 +1156,57 @@ test('buildBareOsRuntimeCaps matches ctx API version and pipeline env', async (t
|
||||
t.is(caps.features.httpDelegate, true)
|
||||
t.is(caps.features.gitDelegate, true)
|
||||
t.is(caps.features.systemctlDelegate, true)
|
||||
t.is(caps.features.bareCtxModules, true)
|
||||
t.is(caps.features.bareDriveBundles, true)
|
||||
t.is(caps.features.bareHostImportsForCtx, true)
|
||||
const capsOff = buildBareOsRuntimeCaps({ BARE_OS_BARE_MODULES: '0' })
|
||||
t.is(capsOff.features.bareCtxModules, false)
|
||||
t.is(capsOff.features.bareDriveBundles, false)
|
||||
t.is(capsOff.features.bareHostImportsForCtx, false)
|
||||
const capsIso = buildBareOsRuntimeCaps({ BARE_OS_BARE_HOST_IMPORTS: '0' })
|
||||
t.is(capsIso.features.bareHostImportsForCtx, false)
|
||||
t.is(capsIso.features.bareCtxModules, true)
|
||||
})
|
||||
|
||||
test('bareOsBareModulesEnabled respects BARE_OS_BARE_MODULES', async (t) => {
|
||||
t.ok(bareOsBareModulesEnabled({}))
|
||||
t.ok(!bareOsBareModulesEnabled({ BARE_OS_BARE_MODULES: '0' }))
|
||||
t.ok(!bareOsBareModulesEnabled({ BARE_OS_BARE_MODULES: 'false' }))
|
||||
})
|
||||
|
||||
test('loadBareModuleManifest has entries', async (t) => {
|
||||
const m = loadBareModuleManifest()
|
||||
t.ok(m.version >= 1)
|
||||
t.ok(Array.isArray(m.entries))
|
||||
t.ok(m.entries.some((e) => e.ctxKey === 'b4a'))
|
||||
})
|
||||
|
||||
test('buildBareCtxObjectFromHost loads core keys on Node', async (t) => {
|
||||
const target = {}
|
||||
await buildBareCtxObjectFromHost({}, target)
|
||||
t.ok(target.b4a)
|
||||
t.ok(target.compactEncoding)
|
||||
t.ok(target.protomux)
|
||||
})
|
||||
|
||||
test('maybeMergeBareFromDrive fills missing keys from bundle (mock vfs)', async (t) => {
|
||||
const repoRoot = path.join(fileURLToPath(new URL('.', import.meta.url)), '..', '..')
|
||||
const bundleAbs = path.join(repoRoot, 'kernel/lib/bare/bundles/b4a.js')
|
||||
const bundleSrc = await readFile(bundleAbs)
|
||||
const manifest = {
|
||||
version: 1,
|
||||
bundles: [{ path: '/lib/bare/bundles/b4a.js', keys: ['b4a'] }]
|
||||
}
|
||||
const target = {}
|
||||
const vfs = {
|
||||
async readFile(p) {
|
||||
if (p === '/lib/bare/manifest.json') return b4a.from(JSON.stringify(manifest))
|
||||
if (p === '/lib/bare/bundles/b4a.js') return new Uint8Array(bundleSrc)
|
||||
return null
|
||||
}
|
||||
}
|
||||
await maybeMergeBareFromDrive({}, vfs, target)
|
||||
t.ok(target.b4a)
|
||||
})
|
||||
|
||||
test('expandArgvAliases expands first word and keeps trailing argv', async (t) => {
|
||||
@@ -1116,6 +1273,172 @@ test('loadBarerc createSkeletonIfMissing writes ~/.barerc when absent', async (t
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
test('loadBarerc theme nord sets REPL color env and LS_COLORS', async (t) => {
|
||||
const dir = testCorestoreDir('barerctheme')
|
||||
const store = new Corestore(dir)
|
||||
const drive = new Hyperdrive(store)
|
||||
const personal = new Hyperdrive(store.namespace('brcth'))
|
||||
await drive.ready()
|
||||
await personal.ready()
|
||||
await personal.put(
|
||||
personalHomeBacking('/home/user', '.barerc'),
|
||||
b4a.from('theme nord\n')
|
||||
)
|
||||
const ctx = testCtx(drive, personal)
|
||||
await loadBarerc(ctx)
|
||||
t.is(ctx.vfs.env.BARE_OS_THEME, 'nord')
|
||||
t.ok(
|
||||
String(ctx.vfs.env.BARE_OS_COLOR_PROMPT || '').includes('38;2;'),
|
||||
'nord preset uses truecolor prompt'
|
||||
)
|
||||
t.ok(
|
||||
String(ctx.vfs.env.LS_COLORS || '').includes('di='),
|
||||
'LS_COLORS set from preset'
|
||||
)
|
||||
await store.close()
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
test('execShellLine barerc reload reapplies barerc', async (t) => {
|
||||
const dir = testCorestoreDir('barercrel')
|
||||
const store = new Corestore(dir)
|
||||
const drive = new Hyperdrive(store)
|
||||
const personal = new Hyperdrive(store.namespace('brcrel'))
|
||||
await drive.ready()
|
||||
await personal.ready()
|
||||
await personal.put(
|
||||
personalHomeBacking('/home/user', '.barerc'),
|
||||
b4a.from('export MARK=before\n')
|
||||
)
|
||||
const ctx = testCtx(drive, personal)
|
||||
await loadBarerc(ctx)
|
||||
t.is(ctx.vfs.env.MARK, 'before')
|
||||
await personal.put(
|
||||
personalHomeBacking('/home/user', '.barerc'),
|
||||
b4a.from('export MARK=after\n')
|
||||
)
|
||||
await execShellLine(ctx, 'barerc reload')
|
||||
t.is(ctx.vfs.env.MARK, 'after')
|
||||
await store.close()
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
test('bareParseLsColors roundtrip', async (t) => {
|
||||
const s = 'di=01;34:ln=36:ex=32:*.tar=01;31'
|
||||
const m = bareParseLsColors(s)
|
||||
t.is(m.di, '01;34')
|
||||
t.is(m.ln, '36')
|
||||
t.alike(bareParseLsColors(bareSerializeLsColors(m)), m)
|
||||
})
|
||||
|
||||
test('bareLsColorOpenSgrFromMap directory and glob', async (t) => {
|
||||
const map = bareParseLsColors('di=01;34:*.md=00;32')
|
||||
const d = bareLsColorOpenSgrFromMap(
|
||||
{ type: 'directory', mode: 0o040755 },
|
||||
'foo',
|
||||
map
|
||||
)
|
||||
t.ok(d.startsWith('\x1b['), 'directory colored')
|
||||
const md = bareLsColorOpenSgrFromMap(
|
||||
{ type: 'file', mode: 0o100644 },
|
||||
'README.md',
|
||||
map
|
||||
)
|
||||
t.ok(md.includes('32'), 'markdown glob')
|
||||
})
|
||||
|
||||
test('bareLsColorOpenSgrFromMap mh for multi-link regular file', async (t) => {
|
||||
const map = bareParseLsColors('mh=01;44:fi=40;31')
|
||||
const one = bareLsColorOpenSgrFromMap(
|
||||
{ type: 'file', mode: 0o100644, nlink: 1 },
|
||||
'a',
|
||||
map
|
||||
)
|
||||
const two = bareLsColorOpenSgrFromMap(
|
||||
{ type: 'file', mode: 0o100644, nlink: 2 },
|
||||
'a',
|
||||
map
|
||||
)
|
||||
t.ok(two.includes('44'), 'nlink>1 uses mh SGR')
|
||||
t.ok(one.includes('31'), 'nlink 1 uses fi')
|
||||
})
|
||||
|
||||
test('bareLsColorOpenSgrFromMap ca when stat has capabilities', async (t) => {
|
||||
const map = bareParseLsColors('ca=30;41:fi=00')
|
||||
const sgr = bareLsColorOpenSgrFromMap(
|
||||
{ type: 'file', mode: 0o100644, nlink: 1, capabilities: true },
|
||||
'cap',
|
||||
map
|
||||
)
|
||||
t.ok(sgr.includes('41'), 'capabilities use ca')
|
||||
})
|
||||
|
||||
test('applyBareOsThemeFromEnv BARE_OS_COLOR_DEPTH=256 drops truecolor', async (t) => {
|
||||
const ctx = { vfs: { env: { BARE_OS_THEME: 'nord', BARE_OS_COLOR_DEPTH: '256' } } }
|
||||
await applyBareOsThemeFromEnv(ctx)
|
||||
const p = String(ctx.vfs.env.BARE_OS_COLOR_PROMPT || '')
|
||||
t.ok(p.includes('38;5;'), '256-color palette index SGR')
|
||||
t.ok(!p.includes('38;2;'), 'no RGB truecolor')
|
||||
})
|
||||
|
||||
test('dircolors -p includes TERM and di', async (t) => {
|
||||
const db = bareDefaultDircolorsDatabase()
|
||||
t.ok(db.includes('TERM'))
|
||||
t.ok(db.includes('di '))
|
||||
})
|
||||
|
||||
test('bareParseDircolorsDatabase TERM block', async (t) => {
|
||||
const text =
|
||||
'TERM xterm\ndi 01;34\nTERM none\nfi 00\nTERM *\nln 01;36\n'
|
||||
const m = bareParseDircolorsDatabase(text, 'xterm')
|
||||
t.is(m.di, '01;34')
|
||||
t.is(m.ln, '01;36')
|
||||
})
|
||||
|
||||
test('runBinCommand theme set writes barerc and updates env', async (t) => {
|
||||
const themePath = path.join(__dirname, '../../kernel/bin/theme')
|
||||
const themeSrc = await readFile(themePath, 'utf8')
|
||||
const dir = testCorestoreDir('themecmd')
|
||||
const store = new Corestore(dir)
|
||||
const drive = new Hyperdrive(store)
|
||||
const personal = new Hyperdrive(store.namespace('thcmd'))
|
||||
await drive.ready()
|
||||
await personal.ready()
|
||||
await drive.put('/bin/theme', b4a.from(themeSrc))
|
||||
const ctx = testCtx(drive, personal)
|
||||
await loadBarerc(ctx)
|
||||
await runBinCommand(ctx, ['theme', 'set', 'dracula'])
|
||||
t.is(ctx.vfs.env.BARE_OS_THEME, 'dracula')
|
||||
const barc = ctx.b4a.toString(await ctx.vfs.readFile('~/.barerc'))
|
||||
t.ok(barc.includes('theme dracula'))
|
||||
await store.close()
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
test('runBinCommand dircolors -p prints database', async (t) => {
|
||||
const dcPath = path.join(__dirname, '../../kernel/bin/dircolors')
|
||||
const dcSrc = await readFile(dcPath, 'utf8')
|
||||
const dir = testCorestoreDir('dircolp')
|
||||
const store = new Corestore(dir)
|
||||
const drive = new Hyperdrive(store)
|
||||
const personal = new Hyperdrive(store.namespace('dcp'))
|
||||
await drive.ready()
|
||||
await personal.ready()
|
||||
await drive.put('/bin/dircolors', b4a.from(dcSrc))
|
||||
const lines = []
|
||||
const ctx = testCtx(drive, personal)
|
||||
ctx.console = {
|
||||
log: (s) => lines.push(String(s)),
|
||||
error: (...a) => lines.push(a.join(' '))
|
||||
}
|
||||
await runBinCommand(ctx, ['dircolors', '-p'])
|
||||
const out = lines.join('\n')
|
||||
t.ok(out.includes('TERM'))
|
||||
t.ok(out.includes('di'))
|
||||
await store.close()
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
test('tokenize leaves echo 2 > file as stdout redirect not 2>', async (t) => {
|
||||
const toks = tokenize('echo 2 > /tmp/x')
|
||||
const words = toks.filter((x) => x.type === 'word').map((x) => x.value)
|
||||
|
||||
@@ -33,7 +33,9 @@ Or `node packages/bare-os-coreutils/build.mjs`.
|
||||
|
||||
**Source of truth:** **`lib/commands.mjs`** — **`COREUTILS_COMMANDS`** (imported by **`build.mjs`** and **`scripts/build-man-db.mjs`**). Each name must have **`man/pages/<name>.json`**.
|
||||
|
||||
`awk`, `basename`, `cat`, `chgrp`, `chmod`, `chown`, `cksum`, `clear`, `cp`, `crontab`, `cut`, `date`, `dirname`, `du`, `echo`, `env`, `exit`, `false`, `find`, `getconf`, `git-pear`, `grep`, `head`, `hdms`, `help`, `hostname`, `id`, `jq`, `ln`, `login`, `logout`, `logname`, `ls`, `man`, `mkdir`, `mkfifo`, `mktemp`, `mv`, `nl`, `od`, `pathchk`, `printenv`, `printf`, `pwd`, `readlink`, `rm`, `rmdir`, `savevault`, `sed`, `seq`, `sleep`, `sort`, `stat`, `tail`, `tee`, `test`, `time`, `touch`, `tr`, `true`, `tty`, `uname`, `wc`, `which`, `whoami`, `xargs`
|
||||
`awk`, `basename`, `cat`, `chgrp`, `chmod`, `chown`, `cksum`, `clear`, `cp`, `crontab`, `cut`, `date`, `dirname`, `dircolors`, `du`, `echo`, `env`, `exit`, `false`, `find`, `getconf`, `git-pear`, `grep`, `head`, `hdms`, `help`, `hostname`, `id`, `jq`, `ln`, `login`, `logout`, `logname`, `ls`, `man`, `mkdir`, `mkfifo`, `mktemp`, `mv`, `nl`, `od`, `pathchk`, `printenv`, `printf`, `pwd`, `readlink`, `rm`, `rmdir`, `savevault`, `sed`, `seq`, `sleep`, `sort`, `stat`, `tail`, `tee`, `test`, `theme`, `time`, `touch`, `tr`, `true`, `tty`, `uname`, `wc`, `which`, `whoami`, `xargs`
|
||||
|
||||
**`ls`** prepends **[`bare-os-lscolors`](../bare-os-lscolors/bare-os-lscolors.js)** for **`LS_COLORS`** / dircolors parsing. **`dircolors`** and **`theme`** integrate with the booter’s **`bare-os-theme-presets.js`** (see [docs/themes/README.md](../../docs/themes/README.md)).
|
||||
|
||||
**`grep`** uses JavaScript **`RegExp`** (and **`-F`** fixed strings); POSIX/GNU-like **subset** (including **`-x`**, **`-m`**, **`-o`** among common flags).
|
||||
|
||||
|
||||
@@ -15,11 +15,19 @@ const preamble = {
|
||||
sed: ['sed-engine.js'],
|
||||
awk: ['awk-engine.js'],
|
||||
jq: ['jq-engine.js'],
|
||||
man: ['man-render.js']
|
||||
man: ['man-render.js'],
|
||||
ls: ['bare-os-lscolors.js', 'ls-colors.js'],
|
||||
dircolors: ['bare-os-lscolors.js']
|
||||
}
|
||||
|
||||
const commands = COREUTILS_COMMANDS
|
||||
|
||||
/** @param {string} src */
|
||||
function stripLscolorsBundleExport(src) {
|
||||
const i = src.indexOf('// BARE_OS_LSCOLORS_BUNDLE_END')
|
||||
return i >= 0 ? src.slice(0, i).trimEnd() + '\n' : src
|
||||
}
|
||||
|
||||
export async function build() {
|
||||
await buildManDb()
|
||||
const runtime = await readFile(join(__dirname, 'lib/runtime.js'), 'utf8')
|
||||
@@ -31,7 +39,13 @@ export async function build() {
|
||||
const extras = preamble[name]
|
||||
if (extras) {
|
||||
for (const f of extras) {
|
||||
pre += (await readFile(join(__dirname, 'lib', f), 'utf8')) + '\n'
|
||||
const chunkPath =
|
||||
f === 'bare-os-lscolors.js'
|
||||
? join(repoRoot, 'packages/bare-os-lscolors/bare-os-lscolors.js')
|
||||
: join(__dirname, 'lib', f)
|
||||
let chunk = await readFile(chunkPath, 'utf8')
|
||||
if (f === 'bare-os-lscolors.js') chunk = stripLscolorsBundleExport(chunk)
|
||||
pre += chunk + '\n'
|
||||
}
|
||||
}
|
||||
const body = await readFile(join(__dirname, 'src', `${name}.js`), 'utf8')
|
||||
|
||||
@@ -16,6 +16,7 @@ export const COREUTILS_COMMANDS = [
|
||||
'cut',
|
||||
'date',
|
||||
'dirname',
|
||||
'dircolors',
|
||||
'du',
|
||||
'echo',
|
||||
'env',
|
||||
@@ -59,6 +60,7 @@ export const COREUTILS_COMMANDS = [
|
||||
'tail',
|
||||
'tee',
|
||||
'test',
|
||||
'theme',
|
||||
'time',
|
||||
'touch',
|
||||
'tr',
|
||||
@@ -73,6 +75,7 @@ export const COREUTILS_COMMANDS = [
|
||||
|
||||
/** Extra manual pages not built as /bin scripts on the system drive. */
|
||||
export const MAN_EXTRA_PAGES = [
|
||||
'bare-os-ctx-bare',
|
||||
'bare-os-shell',
|
||||
'systemctl',
|
||||
'curl',
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/** ANSI coloring for /bin/ls (after bare-os-lscolors.js preamble). */
|
||||
|
||||
const BARE_LS_RESET = '\x1b[0m'
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} [ctx]
|
||||
* @returns {import('stream').Writable | undefined}
|
||||
*/
|
||||
function bareLsResolveStdout(ctx) {
|
||||
if (!ctx || typeof ctx !== 'object') return globalThis.process?.stdout
|
||||
const c = /** @type {{ replStdout?: unknown, stdout?: unknown }} */ (ctx)
|
||||
const out = c.replStdout || c.stdout || globalThis.process?.stdout
|
||||
return /** @type {import('stream').Writable | undefined} */ (out)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} [ctx]
|
||||
* @param {'never' | 'auto' | 'always'} colorMode
|
||||
*/
|
||||
function bareLsUseColor(ctx, colorMode) {
|
||||
const env =
|
||||
ctx && typeof ctx === 'object' && ctx.env && typeof ctx.env === 'object'
|
||||
? /** @type {Record<string, string>} */ (ctx.env)
|
||||
: {}
|
||||
if (env.NO_COLOR != null && String(env.NO_COLOR) !== '') return false
|
||||
if (colorMode === 'never') return false
|
||||
if (colorMode === 'always') return true
|
||||
const out = bareLsResolveStdout(ctx)
|
||||
return Boolean(out && /** @type {{ isTTY?: boolean }} */ (out).isTTY)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} [ctx]
|
||||
* @returns {Record<string, string>}
|
||||
*/
|
||||
function bareLsGetLsColorsMap(ctx) {
|
||||
const env =
|
||||
ctx && typeof ctx === 'object' && ctx.env && typeof ctx.env === 'object'
|
||||
? /** @type {Record<string, string>} */ (ctx.env)
|
||||
: {}
|
||||
const raw = env.LS_COLORS
|
||||
if (raw == null || !String(raw).trim()) {
|
||||
return bareParseLsColors(bareDefaultLsColorsString())
|
||||
}
|
||||
return bareParseLsColors(String(raw))
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ mode?: number, type?: string, linkname?: string, targetMissing?: boolean, nlink?: number, capabilities?: boolean } | null | undefined} st
|
||||
* @param {string} filename basename
|
||||
* @param {Record<string, unknown>} [ctx]
|
||||
*/
|
||||
function bareLsOpenSgr(st, filename, ctx) {
|
||||
const map = bareLsGetLsColorsMap(ctx)
|
||||
return bareLsColorOpenSgrFromMap(st, filename, map)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {{ mode?: number, type?: string } | null | undefined} st
|
||||
* @param {boolean} on
|
||||
* @param {Record<string, unknown>} [ctx]
|
||||
*/
|
||||
function bareLsColorWrap(name, st, on, ctx) {
|
||||
if (!on) return name
|
||||
const open = bareLsOpenSgr(st, name, ctx)
|
||||
if (!open) return name
|
||||
return open + name + BARE_LS_RESET
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {string} arrow
|
||||
* @param {{ mode?: number, type?: string, linkname?: string, targetMissing?: boolean, nlink?: number, capabilities?: boolean } | null | undefined} st
|
||||
* @param {boolean} on
|
||||
* @param {Record<string, unknown>} [ctx]
|
||||
*/
|
||||
function bareLsColorLongTail(name, arrow, st, on, ctx) {
|
||||
if (!on) return name + arrow
|
||||
if (st && st.type === 'symlink') {
|
||||
const map = bareLsGetLsColorsMap(ctx)
|
||||
const ln = map.ln
|
||||
const open = ln ? bareLscolorsToOpenSgr(ln) : '\x1b[36m'
|
||||
return open + name + arrow + BARE_LS_RESET
|
||||
}
|
||||
return bareLsColorWrap(name, st, true, ctx) + arrow
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "bare-os-ctx-bare",
|
||||
"section": 7,
|
||||
"title": "ctx.bare library and drive bundles",
|
||||
"synopsis": ["# reference — not a shell command"],
|
||||
"description": "Documents BARE_OS_BARE_MODULES and BARE_OS_BARE_DRIVE_BUNDLES for the booter ctx.bare registry. In-image scripts (AsyncFunction) use ctx.bare.<key> instead of import(). Keys come from host dynamic import of packages listed in packages/bare-os-booter/lib/bare-module-manifest.json, then optional merge from trusted IIFE bundles under /lib/bare/bundles/ on the system image (see manifest.json there). Set BARE_OS_BARE_MODULES=0 to omit ctx.bare entirely. Set BARE_OS_BARE_DRIVE_BUNDLES=0 to skip executing drive bundles (host imports only). Rebuild bundles with npm run build -w bare-os-bare-libs.",
|
||||
"options": [],
|
||||
"keywords": [
|
||||
"BARE_OS_BARE_MODULES",
|
||||
"BARE_OS_BARE_DRIVE_BUNDLES",
|
||||
"ctx.bare",
|
||||
"bare-module-manifest",
|
||||
"bare-os-bare-libs"
|
||||
],
|
||||
"environment": [
|
||||
"BARE_OS_BARE_MODULES — set to 0 or false to disable ctx.bare (hardened sessions).",
|
||||
"BARE_OS_BARE_DRIVE_BUNDLES — set to 0 or false to skip loading /lib/bare/bundles/*.js into ctx.bare."
|
||||
],
|
||||
"seeAlso": [
|
||||
{
|
||||
"name": "bare-os-developer-guide",
|
||||
"section": 7
|
||||
}
|
||||
],
|
||||
"bareOsNotes": "See developer-guide/05-modules-and-imports.md and 12-bare-modules-and-pear-ecosystem.md.",
|
||||
"examples": []
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "dircolors",
|
||||
"section": 1,
|
||||
"title": "print LS_COLORS from dircolors database",
|
||||
"synopsis": [
|
||||
"dircolors [-b] [FILE]",
|
||||
"dircolors -p"
|
||||
],
|
||||
"description": "With -p, prints the default GNU-like dircolors database. Otherwise reads FILE (or the default database), applies TERM blocks, and outputs LS_COLORS. With -b, prints Bourne-shell export commands.",
|
||||
"options": [
|
||||
{ "flag": "-b, --sh", "meaning": "Print LS_COLORS=… and export LS_COLORS" },
|
||||
{ "flag": "-p, --print-database", "meaning": "Print default database text" }
|
||||
],
|
||||
"keywords": ["dircolors", "LS_COLORS", "ls", "color"],
|
||||
"bareOsNotes": "Subset of GNU dircolors; FILE is read via VFS.",
|
||||
"examples": [
|
||||
{ "caption": "default database", "code": "dircolors -p" },
|
||||
{ "caption": "eval in shell", "code": "eval \"$(dircolors -b ~/.dir_colors)\"" }
|
||||
]
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
"name": "ls",
|
||||
"section": 1,
|
||||
"title": "list directory contents",
|
||||
"synopsis": ["ls [-1al] [FILE...]"],
|
||||
"description": "Lists directory contents. Long format shows mode, links, owner, group, size, mtime, and symlink targets.",
|
||||
"synopsis": ["ls [-1al] [--color[=never|auto|always]] [FILE...]"],
|
||||
"description": "Lists directory contents. Long format shows mode, links, owner, group, size, mtime, and symlink targets. With color (default auto on a TTY), directories, symlinks, executables, and permission bits are highlighted.",
|
||||
"options": [
|
||||
{
|
||||
"flag": "-a",
|
||||
@@ -16,8 +16,15 @@
|
||||
{
|
||||
"flag": "-1",
|
||||
"meaning": "One name per line (short format)"
|
||||
},
|
||||
{
|
||||
"flag": "--color[=never|auto|always]",
|
||||
"meaning": "ANSI colors: never, auto (TTY only), or always; plain --color is auto"
|
||||
}
|
||||
],
|
||||
"environment": [
|
||||
"NO_COLOR — disable color even when a TTY or --color=always"
|
||||
],
|
||||
"keywords": ["ls", "list", "directory", "dir"],
|
||||
"bareOsNotes": "Hides .bareos_empty marker like other tools.",
|
||||
"examples": [
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "theme",
|
||||
"section": 1,
|
||||
"title": "switch Bare OS color theme",
|
||||
"synopsis": ["theme [list|current|set <name>|apply]"],
|
||||
"description": "Lists bundled theme presets, shows the active BARE_OS_THEME, writes theme <name> to ~/.barerc and reapplies colors (when the booter provides bareOsApplyTheme), or reapplies the current theme without editing the file.",
|
||||
"options": [],
|
||||
"keywords": ["theme", "colors", "LS_COLORS", "prompt"],
|
||||
"bareOsNotes": "Requires ctx.bareOsApplyTheme for set/apply to refresh env; list/current work with static preset names.",
|
||||
"examples": [
|
||||
{ "caption": "list presets", "code": "theme list" },
|
||||
{ "caption": "switch to Nord palette", "code": "theme set nord" },
|
||||
{ "caption": "re-apply after manual env edits", "code": "theme apply" }
|
||||
]
|
||||
}
|
||||
@@ -451,15 +451,39 @@ EXTRA.awk = {
|
||||
],
|
||||
bareOsNotes: 'See handbook ch.9 for divergence from Issue 7.'
|
||||
}
|
||||
EXTRA.ls = {
|
||||
synopsis: ['ls [-1al] [FILE...]'],
|
||||
EXTRA.dircolors = {
|
||||
synopsis: ['dircolors [-b] [FILE]', 'dircolors -p'],
|
||||
description:
|
||||
'Lists directory contents. Long format shows mode, links, owner, group, size, mtime, and symlink targets.',
|
||||
'Print LS_COLORS from a dircolors database (GNU subset: TERM blocks, key/value pairs). -p prints the default Bare OS database.',
|
||||
options: [
|
||||
{ flag: '-b, --sh', meaning: 'Bourne-shell export LS_COLORS' },
|
||||
{ flag: '-p, --print-database', meaning: 'Print default database' }
|
||||
],
|
||||
keywords: ['dircolors', 'LS_COLORS', 'color'],
|
||||
bareOsNotes: 'FILE read via VFS.'
|
||||
}
|
||||
EXTRA.theme = {
|
||||
synopsis: ['theme [list|current|set <name>|apply]'],
|
||||
description:
|
||||
'Switch Bare OS UI preset: updates ~/.barerc theme line, sets BARE_OS_THEME, calls bareOsApplyTheme when available.',
|
||||
keywords: ['theme', 'colors', 'prompt'],
|
||||
bareOsNotes: 'list/current work without booter hooks; set/apply need ctx.bareOsApplyTheme.'
|
||||
}
|
||||
EXTRA.ls = {
|
||||
synopsis: ['ls [-1al] [--color[=never|auto|always]] [FILE...]'],
|
||||
description:
|
||||
'Lists directory contents. Long format shows mode, links, owner, group, size, mtime, and symlink targets. With color (default auto on a TTY), directories, symlinks, executables, and permission bits are highlighted.',
|
||||
options: [
|
||||
{ flag: '-a', meaning: 'Include names starting with .' },
|
||||
{ flag: '-l', meaning: 'Long listing' },
|
||||
{ flag: '-1', meaning: 'One name per line (short format)' }
|
||||
{ flag: '-1', meaning: 'One name per line (short format)' },
|
||||
{
|
||||
flag: '--color[=never|auto|always]',
|
||||
meaning:
|
||||
'ANSI colors: never, auto (TTY only), or always; plain --color is auto'
|
||||
}
|
||||
],
|
||||
environment: ['NO_COLOR — disable color even when a TTY or --color=always'],
|
||||
keywords: ['ls', 'list', 'directory', 'dir'],
|
||||
bareOsNotes: 'Hides .bareos_empty marker like other tools.'
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
async function run(ctx, argv) {
|
||||
const env = ctx.env || {}
|
||||
let bourne = false
|
||||
let printDefault = false
|
||||
/** @type {string | null} */
|
||||
let file = null
|
||||
for (let i = 1; i < argv.length; i++) {
|
||||
const a = argv[i]
|
||||
if (a === '--') continue
|
||||
if (a === '-b' || a === '--sh' || a === '--bourne-shell') bourne = true
|
||||
else if (a === '-p' || a === '--print-database') printDefault = true
|
||||
else if (a.startsWith('-')) {
|
||||
ctx.console.error('dircolors: unrecognized option: ' + a)
|
||||
ctx.exitCode = 2
|
||||
return
|
||||
} else file = a
|
||||
}
|
||||
if (printDefault) {
|
||||
ctx.console.log(bareDefaultDircolorsDatabase())
|
||||
return
|
||||
}
|
||||
let text = bareDefaultDircolorsDatabase()
|
||||
if (file) {
|
||||
const buf = await ctx.vfs.readFile(file)
|
||||
if (!buf) {
|
||||
ctx.console.error('dircolors: cannot read ' + file)
|
||||
ctx.exitCode = 2
|
||||
return
|
||||
}
|
||||
text = ctx.b4a.toString(buf)
|
||||
}
|
||||
const term = env.TERM || ''
|
||||
const db = bareParseDircolorsDatabase(text, term)
|
||||
const ls = bareSerializeLsColors(db)
|
||||
if (bourne) {
|
||||
const q = "'" + ls.replace(/'/g, "'\\''") + "'"
|
||||
ctx.console.log('LS_COLORS=' + q)
|
||||
ctx.console.log('export LS_COLORS')
|
||||
} else {
|
||||
ctx.console.log(ls)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
async function run(ctx, argv) {
|
||||
ctx.console.log(
|
||||
'Bare OS — default user: guest | shell builtins: alias, cd, command, export, exit, login, logout, readonly, type, umask, unalias, unset, : | /bin: awk basename cat chgrp chmod chown cksum clear cp crontab curl cut date dirname du echo env exit false find getconf grep head hdms help hostname id journalctl jq ln login logout logname ls man mkdir mkfifo mv nl od pathchk printenv printf pwd readlink rm rmdir savevault sed seq sleep sort stat systemctl tail tee test time touch tr true tty uname wc wget which whoami xargs'
|
||||
'Bare OS — default user: guest | shell builtins: alias, barerc, cd, command, export, exit, login, logout, readonly, type, umask, unalias, unset, : | /bin: awk basename cat chgrp chmod chown cksum clear cp crontab curl cut date dirname dircolors du echo env exit false find getconf grep head hdms help hostname id journalctl jq ln login logout logname ls man mkdir mkfifo mv nl od pathchk printenv printf pwd readlink rm rmdir savevault sed seq sleep sort stat systemctl tail tee test theme time touch tr true tty uname wc wget which whoami xargs'
|
||||
)
|
||||
ctx.console.log(
|
||||
'Docs: man <command> | man handbook (full handbook, section 7) | man bare-os-shell | man -k <word> | man -l'
|
||||
|
||||
@@ -2,6 +2,8 @@ async function run(ctx, argv) {
|
||||
const vfs = ctx.vfs
|
||||
let showAll = false
|
||||
let longFmt = false
|
||||
/** @type {'never' | 'auto' | 'always'} */
|
||||
let colorMode = 'auto'
|
||||
const paths = []
|
||||
for (let i = 1; i < argv.length; i++) {
|
||||
const a = argv[i]
|
||||
@@ -9,6 +11,22 @@ async function run(ctx, argv) {
|
||||
paths.push(...argv.slice(i + 1))
|
||||
break
|
||||
}
|
||||
if (a.startsWith('--')) {
|
||||
if (a === '--color') {
|
||||
colorMode = 'auto'
|
||||
continue
|
||||
}
|
||||
if (a.startsWith('--color=')) {
|
||||
const v = a.slice(8).toLowerCase()
|
||||
if (v === 'never' || v === 'none' || v === 'no') colorMode = 'never'
|
||||
else if (v === 'always' || v === 'yes' || v === 'force') colorMode = 'always'
|
||||
else colorMode = 'auto'
|
||||
continue
|
||||
}
|
||||
ctx.console.error('ls: unrecognized option ' + a)
|
||||
ctx.exitCode = 2
|
||||
return
|
||||
}
|
||||
if (a.startsWith('-') && a.length > 1) {
|
||||
for (let j = 1; j < a.length; j++) {
|
||||
const c = a[j]
|
||||
@@ -21,6 +39,7 @@ async function run(ctx, argv) {
|
||||
paths.push(a)
|
||||
}
|
||||
const targets = paths.length ? paths : ['.']
|
||||
const useColor = bareLsUseColor(ctx, colorMode)
|
||||
|
||||
for (const t of targets) {
|
||||
if (targets.length > 1) ctx.console.log(t + ':')
|
||||
@@ -42,7 +61,27 @@ async function run(ctx, argv) {
|
||||
}
|
||||
if (!showAll) names = names.filter((n) => !n.startsWith('.'))
|
||||
if (!longFmt) {
|
||||
ctx.console.log(names.join(' '))
|
||||
if (!useColor) {
|
||||
ctx.console.log(names.join(' '))
|
||||
} else {
|
||||
const parts = []
|
||||
for (const n of names) {
|
||||
const sub =
|
||||
singleEntryPath != null
|
||||
? singleEntryPath
|
||||
: t === '.' || t === './'
|
||||
? n
|
||||
: t.replace(/\/$/, '') + '/' + n
|
||||
let st = null
|
||||
try {
|
||||
st = await vfs.lstat(sub)
|
||||
} catch {
|
||||
st = null
|
||||
}
|
||||
parts.push(bareLsColorWrap(n, st, true, ctx))
|
||||
}
|
||||
ctx.console.log(parts.join(' '))
|
||||
}
|
||||
} else {
|
||||
let totalBlocks = 0
|
||||
const rows = []
|
||||
@@ -63,7 +102,8 @@ async function run(ctx, argv) {
|
||||
size: 0,
|
||||
mtimeStr: '?',
|
||||
name: n,
|
||||
arrow: ''
|
||||
arrow: '',
|
||||
st: null
|
||||
})
|
||||
continue
|
||||
}
|
||||
@@ -89,11 +129,13 @@ async function run(ctx, argv) {
|
||||
size,
|
||||
mtimeStr,
|
||||
name: n,
|
||||
arrow
|
||||
arrow,
|
||||
st
|
||||
})
|
||||
}
|
||||
if (singleEntryPath == null) ctx.console.log('total ' + totalBlocks)
|
||||
for (const r of rows) {
|
||||
const tail = bareLsColorLongTail(r.name, r.arrow, r.st, useColor, ctx)
|
||||
ctx.console.log(
|
||||
r.modeStr +
|
||||
' ' +
|
||||
@@ -107,8 +149,7 @@ async function run(ctx, argv) {
|
||||
' ' +
|
||||
r.mtimeStr +
|
||||
' ' +
|
||||
r.name +
|
||||
r.arrow
|
||||
tail
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* Theme switcher: list presets, show current, set preset (updates ~/.barerc), re-apply.
|
||||
* Uses ctx.bareOsListThemes / ctx.bareOsApplyTheme when provided by the booter.
|
||||
*/
|
||||
|
||||
const FALLBACK_THEMES = [
|
||||
'catppuccin_mocha',
|
||||
'default',
|
||||
'dracula',
|
||||
'github_dark',
|
||||
'gruvbox_dark',
|
||||
'nord',
|
||||
'solarized_dark',
|
||||
'tokyo_night'
|
||||
]
|
||||
|
||||
function themeListFromCtx(ctx) {
|
||||
if (typeof ctx.bareOsListThemes === 'function') {
|
||||
try {
|
||||
const names = ctx.bareOsListThemes()
|
||||
if (Array.isArray(names) && names.length) return names
|
||||
} catch {
|
||||
/* fall through */
|
||||
}
|
||||
}
|
||||
return FALLBACK_THEMES.slice().sort()
|
||||
}
|
||||
|
||||
async function readBarerc(ctx) {
|
||||
try {
|
||||
const buf = await ctx.vfs.readFile('~/.barerc')
|
||||
return buf ? ctx.b4a.toString(buf) : ''
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
async function writeBarerc(ctx, text) {
|
||||
await ctx.vfs.writeFile('~/.barerc', ctx.b4a.from(text))
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure ~/.barerc contains `theme <name>` (replace first theme line or append).
|
||||
* @param {Record<string, unknown>} ctx
|
||||
* @param {string} name
|
||||
*/
|
||||
async function persistThemeLine(ctx, name) {
|
||||
let text = await readBarerc(ctx)
|
||||
const lines = text.split(/\r?\n/)
|
||||
const themeRe = /^\s*theme\s+/
|
||||
let replaced = false
|
||||
const out = []
|
||||
for (const line of lines) {
|
||||
if (themeRe.test(line)) {
|
||||
if (!replaced) {
|
||||
out.push('theme ' + name)
|
||||
replaced = true
|
||||
}
|
||||
} else out.push(line)
|
||||
}
|
||||
if (!replaced) {
|
||||
if (out.length && out[out.length - 1].trim() !== '') out.push('')
|
||||
out.push('theme ' + name)
|
||||
}
|
||||
const newText = out.join('\n')
|
||||
if (!/\n$/.test(newText) && newText.length) await writeBarerc(ctx, newText + '\n')
|
||||
else await writeBarerc(ctx, newText || 'theme ' + name + '\n')
|
||||
}
|
||||
|
||||
async function run(ctx, argv) {
|
||||
const env = ctx.vfs?.env || ctx.env || {}
|
||||
const sub = argv[1] || 'list'
|
||||
|
||||
if (sub === 'list') {
|
||||
for (const n of themeListFromCtx(ctx)) ctx.console.log(n)
|
||||
return
|
||||
}
|
||||
|
||||
if (sub === 'current') {
|
||||
const t = env.BARE_OS_THEME != null ? String(env.BARE_OS_THEME) : 'default'
|
||||
ctx.console.log(t)
|
||||
const ls = env.LS_COLORS
|
||||
if (ls != null && String(ls).length) {
|
||||
ctx.console.log('LS_COLORS_len=' + String(ls).length)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (sub === 'apply') {
|
||||
if (typeof ctx.bareOsApplyTheme === 'function') {
|
||||
await ctx.bareOsApplyTheme()
|
||||
} else {
|
||||
ctx.console.error('theme: bareOsApplyTheme not available')
|
||||
ctx.exitCode = 1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (sub === 'set') {
|
||||
const name = argv[2]
|
||||
if (!name) {
|
||||
ctx.console.error('theme: usage: theme set <name>')
|
||||
ctx.exitCode = 1
|
||||
return
|
||||
}
|
||||
const norm = String(name)
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/\s+/g, '_')
|
||||
const valid = new Set(themeListFromCtx(ctx).map((s) => s.toLowerCase()))
|
||||
if (!valid.has(norm)) {
|
||||
ctx.console.error('theme: unknown preset: ' + name)
|
||||
ctx.exitCode = 1
|
||||
return
|
||||
}
|
||||
try {
|
||||
await persistThemeLine(ctx, norm)
|
||||
} catch (e) {
|
||||
ctx.console.error('theme: ' + ((e && e.message) || e))
|
||||
ctx.exitCode = 2
|
||||
return
|
||||
}
|
||||
env.BARE_OS_THEME = norm
|
||||
if (typeof ctx.bareOsApplyTheme === 'function') {
|
||||
await ctx.bareOsApplyTheme()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
ctx.console.error(
|
||||
'theme: usage: theme [list|current|set <name>|apply]'
|
||||
)
|
||||
ctx.exitCode = 1
|
||||
}
|
||||
@@ -0,0 +1,336 @@
|
||||
/**
|
||||
* GNU-style LS_COLORS string + dircolors(5) database parsing and file classification.
|
||||
* Consumed by bare-os-booter (ESM import). Prepended into /bin/ls and /bin/dircolors by bare-os-coreutils build (no import there).
|
||||
*/
|
||||
|
||||
/** Default LS_COLORS (subset aligned with GNU dircolors -p essentials + common globs). */
|
||||
function bareDefaultLsColorsString() {
|
||||
return [
|
||||
'no=00',
|
||||
'fi=00',
|
||||
'di=01;34',
|
||||
'ln=01;36',
|
||||
'pi=40;33',
|
||||
'so=01;35',
|
||||
'do=01;35',
|
||||
'bd=40;33;01',
|
||||
'cd=40;33;01',
|
||||
'or=40;31;01',
|
||||
'mi=00',
|
||||
'su=37;41',
|
||||
'sg=30;43',
|
||||
'ca=30;41',
|
||||
'tw=30;42',
|
||||
'ow=34;43',
|
||||
'st=37;44',
|
||||
'ex=01;32',
|
||||
'mh=00',
|
||||
'*.tar=01;31',
|
||||
'*.tgz=01;31',
|
||||
'*.arc=01;31',
|
||||
'*.arj=01;31',
|
||||
'*.taz=01;31',
|
||||
'*.lha=01;31',
|
||||
'*.lz4=01;31',
|
||||
'*.lzh=01;31',
|
||||
'*.tlz=01;31',
|
||||
'*.txz=01;31',
|
||||
'*.tzo=01;31',
|
||||
'*.tzst=01;31',
|
||||
'*.bz2=01;31',
|
||||
'*.bz=01;31',
|
||||
'*.tbz=01;31',
|
||||
'*.tbz2=01;31',
|
||||
'*.tz=01;31',
|
||||
'*.deb=01;31',
|
||||
'*.rpm=01;31',
|
||||
'*.jar=01;31',
|
||||
'*.war=01;31',
|
||||
'*.ear=01;31',
|
||||
'*.sar=01;31',
|
||||
'*.rar=01;31',
|
||||
'*.alz=01;31',
|
||||
'*.ace=01;31',
|
||||
'*.zoo=01;31',
|
||||
'*.cpio=01;31',
|
||||
'*.7z=01;31',
|
||||
'*.rz=01;31',
|
||||
'*.cab=01;31',
|
||||
'*.wim=01;31',
|
||||
'*.swm=01;31',
|
||||
'*.dwm=01;31',
|
||||
'*.esd=01;31',
|
||||
'*.jpg=01;35',
|
||||
'*.jpeg=01;35',
|
||||
'*.mjpg=01;35',
|
||||
'*.mjpeg=01;35',
|
||||
'*.gif=01;35',
|
||||
'*.bmp=01;35',
|
||||
'*.pbm=01;35',
|
||||
'*.pgm=01;35',
|
||||
'*.ppm=01;35',
|
||||
'*.tga=01;35',
|
||||
'*.xbm=01;35',
|
||||
'*.xpm=01;35',
|
||||
'*.tif=01;35',
|
||||
'*.tiff=01;35',
|
||||
'*.png=01;35',
|
||||
'*.svg=01;35',
|
||||
'*.svgz=01;35',
|
||||
'*.mng=01;35',
|
||||
'*.pcx=01;35',
|
||||
'*.mov=01;35',
|
||||
'*.mpg=01;35',
|
||||
'*.mpeg=01;35',
|
||||
'*.m2v=01;35',
|
||||
'*.mkv=01;35',
|
||||
'*.webm=01;35',
|
||||
'*.ogm=01;35',
|
||||
'*.mp4=01;35',
|
||||
'*.m4v=01;35',
|
||||
'*.mp4v=01;35',
|
||||
'*.vob=01;35',
|
||||
'*.qt=01;35',
|
||||
'*.nuv=01;35',
|
||||
'*.wmv=01;35',
|
||||
'*.asf=01;35',
|
||||
'*.rm=01;35',
|
||||
'*.rmvb=01;35',
|
||||
'*.flc=01;35',
|
||||
'*.avi=01;35',
|
||||
'*.fli=01;35',
|
||||
'*.flv=01;35',
|
||||
'*.gl=01;35',
|
||||
'*.dl=01;35',
|
||||
'*.xcf=01;35',
|
||||
'*.xwd=01;35',
|
||||
'*.yuv=01;35',
|
||||
'*.cgm=01;35',
|
||||
'*.emf=01;35',
|
||||
'*.ogv=01;35',
|
||||
'*.ogx=01;35',
|
||||
'*.aac=00;36',
|
||||
'*.au=00;36',
|
||||
'*.flac=00;36',
|
||||
'*.m4a=00;36',
|
||||
'*.mid=00;36',
|
||||
'*.midi=00;36',
|
||||
'*.mka=00;36',
|
||||
'*.mp3=00;36',
|
||||
'*.mpc=00;36',
|
||||
'*.ogg=00;36',
|
||||
'*.ra=00;36',
|
||||
'*.wav=00;36',
|
||||
'*.oga=00;36',
|
||||
'*.opus=00;36',
|
||||
'*.spx=00;36',
|
||||
'*.xspf=00;36',
|
||||
'*.pdf=00;32',
|
||||
'*.ps=00;32',
|
||||
'*.txt=00;32',
|
||||
'*.patch=00;32',
|
||||
'*.diff=00;32',
|
||||
'*.log=00;32',
|
||||
'*.tex=00;32',
|
||||
'*.doc=00;32',
|
||||
'*.docx=00;32',
|
||||
'*.rtf=00;32',
|
||||
'*.odt=00;32',
|
||||
'*.md=00;32',
|
||||
'*.markdown=00;32',
|
||||
'*.css=00;32',
|
||||
'*.htm=00;32',
|
||||
'*.html=00;32',
|
||||
'*.xml=00;32',
|
||||
'*.json=00;32',
|
||||
'*.yaml=00;32',
|
||||
'*.yml=00;32',
|
||||
'*.c=00;32',
|
||||
'*.h=00;32',
|
||||
'*.js=00;32',
|
||||
'*.mjs=00;32',
|
||||
'*.java=00;32',
|
||||
'*.py=00;32',
|
||||
'*.go=00;32',
|
||||
'*.rs=00;32',
|
||||
'*.cpp=00;32',
|
||||
'*.cc=00;32',
|
||||
'*.cxx=00;32',
|
||||
'*.hpp=00;32',
|
||||
'*.shlib=01;32',
|
||||
'*.so=01;32',
|
||||
'*.dylib=01;32',
|
||||
'*.dll=01;32',
|
||||
'*.a=01;32',
|
||||
'*.lib=01;32',
|
||||
'*.ko=01;32',
|
||||
'*.sh=01;32',
|
||||
'*.bash=01;32',
|
||||
'*.zsh=01;32',
|
||||
'*.bat=01;32',
|
||||
'*.cmd=01;32',
|
||||
'*.exe=01;32',
|
||||
'*.com=01;32',
|
||||
'*.btm=01;32',
|
||||
'*.msi=01;32'
|
||||
].join(':')
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} s
|
||||
* @returns {Record<string, string>}
|
||||
*/
|
||||
function bareParseLsColors(s) {
|
||||
const out = /** @type {Record<string, string>} */ ({})
|
||||
if (s == null || !String(s).trim()) return out
|
||||
for (const part of String(s).split(':')) {
|
||||
const p = part.trim()
|
||||
if (!p) continue
|
||||
const eq = p.indexOf('=')
|
||||
if (eq <= 0) continue
|
||||
const k = p.slice(0, eq)
|
||||
const v = p.slice(eq + 1)
|
||||
if (k) out[k] = v
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, string>} map
|
||||
*/
|
||||
function bareSerializeLsColors(map) {
|
||||
const keys = Object.keys(map).sort()
|
||||
return keys.map((k) => k + '=' + map[k]).join(':')
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} code dircolors value (e.g. 01;34)
|
||||
* @returns {string} opening SGR including ESC
|
||||
*/
|
||||
function bareLscolorsToOpenSgr(code) {
|
||||
if (code == null || code === '' || code === '0' || code === '00') return ''
|
||||
return '\x1b[' + code + 'm'
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse dircolors database (GNU subset): # comments, blank lines, TERM blocks, KEY VALUE pairs.
|
||||
* @param {string} text
|
||||
* @param {string} termEnv value of TERM
|
||||
* @returns {Record<string, string>}
|
||||
*/
|
||||
function bareParseDircolorsDatabase(text, termEnv) {
|
||||
const term = termEnv != null ? String(termEnv) : ''
|
||||
/** @type {Record<string, string>} */
|
||||
const out = {}
|
||||
let blockActive = true
|
||||
const lines = String(text).split(/\r?\n/)
|
||||
for (let raw of lines) {
|
||||
const line = raw.replace(/#.*$/, '').trim()
|
||||
if (!line) continue
|
||||
const upper = line.toUpperCase()
|
||||
if (upper.startsWith('TERM ')) {
|
||||
const rest = line.slice(5).trim()
|
||||
if (rest === 'none') blockActive = false
|
||||
else
|
||||
blockActive =
|
||||
rest === '*' || rest === '' || rest === term || term.indexOf(rest) === 0
|
||||
continue
|
||||
}
|
||||
if (upper.startsWith('COLOR ') || upper.startsWith('OPTIONS ')) continue
|
||||
if (!blockActive) continue
|
||||
const ws = line.search(/\s/)
|
||||
if (ws <= 0) continue
|
||||
const key = line.slice(0, ws).trim()
|
||||
const val = line.slice(ws + 1).trim()
|
||||
if (!key || !val) continue
|
||||
if (key === 'TERM' || key === 'COLOR' || key === 'OPTIONS') continue
|
||||
out[key] = val
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} filename basename only
|
||||
* @param {Record<string, string>} map
|
||||
*/
|
||||
function bareLsColorsGlobMatch(filename, map) {
|
||||
const keys = Object.keys(map).filter((k) => k.startsWith('*.'))
|
||||
keys.sort((a, b) => b.length - a.length)
|
||||
const lower = filename.toLowerCase()
|
||||
for (const k of keys) {
|
||||
const suf = k.slice(1).toLowerCase()
|
||||
if (lower.endsWith(suf)) return map[k]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ type?: string, mode?: number, linkname?: string, targetMissing?: boolean, nlink?: number, capabilities?: boolean } | null} st
|
||||
* @param {string} filename basename
|
||||
* @param {Record<string, string>} map from LS_COLORS
|
||||
* @returns {string} SGR open sequence or ''
|
||||
*/
|
||||
function bareLsColorOpenSgrFromMap(st, filename, map) {
|
||||
if (!st) {
|
||||
const no = map.no
|
||||
return no ? bareLscolorsToOpenSgr(no) : ''
|
||||
}
|
||||
const mode = Number(st.mode) || 0
|
||||
const perm = mode & 0o777
|
||||
const t = st.type
|
||||
let key = 'fi'
|
||||
|
||||
if (t === 'symlink') {
|
||||
key = st.targetMissing ? 'or' : 'ln'
|
||||
} else if (t === 'directory') {
|
||||
const ow = (perm & 0o002) !== 0
|
||||
const sticky = (mode & 0o1000) !== 0
|
||||
if (ow && sticky) key = 'tw'
|
||||
else if (ow) key = 'ow'
|
||||
else if (sticky) key = 'st'
|
||||
else key = 'di'
|
||||
} else if (t === 'file') {
|
||||
if (st.capabilities) key = 'ca'
|
||||
else if (mode & 0o4000) key = 'su'
|
||||
else if (mode & 0o2000) key = 'sg'
|
||||
else if (perm & 0o111) key = 'ex'
|
||||
else {
|
||||
const nlink = Number(st.nlink)
|
||||
if (nlink > 1 && map.mh != null && String(map.mh).trim() !== '') {
|
||||
const mhOpen = bareLscolorsToOpenSgr(map.mh)
|
||||
if (mhOpen) return mhOpen
|
||||
}
|
||||
const g = bareLsColorsGlobMatch(filename, map)
|
||||
if (g != null) return bareLscolorsToOpenSgr(g)
|
||||
key = 'fi'
|
||||
}
|
||||
}
|
||||
|
||||
const code = map[key] != null ? map[key] : map.fi
|
||||
return code ? bareLscolorsToOpenSgr(code) : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} multiline dircolors database (default colors)
|
||||
*/
|
||||
function bareDefaultDircolorsDatabase() {
|
||||
const pairs = bareParseLsColors(bareDefaultLsColorsString())
|
||||
const lines = ['# Bare OS default dircolors (GNU-like)', 'TERM *', '']
|
||||
for (const k of Object.keys(pairs).sort()) {
|
||||
lines.push(k + ' ' + pairs[k])
|
||||
}
|
||||
return lines.join('\n') + '\n'
|
||||
}
|
||||
|
||||
// BARE_OS_LSCOLORS_BUNDLE_END (lines below are stripped when embedding in /bin/*)
|
||||
|
||||
export {
|
||||
bareDefaultLsColorsString,
|
||||
bareParseLsColors,
|
||||
bareSerializeLsColors,
|
||||
bareLscolorsToOpenSgr,
|
||||
bareParseDircolorsDatabase,
|
||||
bareLsColorsGlobMatch,
|
||||
bareLsColorOpenSgrFromMap,
|
||||
bareDefaultDircolorsDatabase
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "bare-os-lscolors",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "GNU-style LS_COLORS + dircolors parsing (shared by bare-os-booter and bare-os-coreutils build)",
|
||||
"exports": "./bare-os-lscolors.js"
|
||||
}
|
||||
@@ -32,8 +32,8 @@ npm run os:seeder
|
||||
|
||||
## Pear vs Node
|
||||
|
||||
- **`import.meta.url` is `file:`** — seeder may **dynamically import** `bare-os-coreutils/build.mjs` and rebuild `/bin` before staging.
|
||||
- **`pear:` bundle** — coreutils must be **pre-built** into `kernel/bin/`; run `npm run build -w bare-os-coreutils` before `pear run`.
|
||||
- **`import.meta.url` is `file:`** — seeder may **dynamically import** `bare-os-coreutils/build.mjs` and **`bare-os-bare-libs/build.mjs`**, rebuilding `/bin` and **`kernel/lib/bare`** before staging.
|
||||
- **`pear:` bundle** — coreutils and **`/lib/bare`** bundles must be **pre-built** into `kernel/`; run `npm run build -w bare-os-coreutils` and `npm run build -w bare-os-bare-libs` before `pear run` (root **`npm run os:seeder`** does both).
|
||||
|
||||
## Layout
|
||||
|
||||
|
||||
@@ -75,11 +75,26 @@ async function maybeBuildCoreutilsFromSource() {
|
||||
console.log('Coreutils emitted to kernel/bin')
|
||||
}
|
||||
|
||||
async function maybeBuildBareLibsFromSource() {
|
||||
if (!import.meta.url.startsWith('file:')) {
|
||||
console.log(
|
||||
'Pear bundle: using vendored kernel/lib/bare (run `npm run build -w bare-os-bare-libs` to refresh bundles)'
|
||||
)
|
||||
return
|
||||
}
|
||||
const { buildBareLibs } = await import(
|
||||
new URL('../bare-os-bare-libs/build.mjs', import.meta.url).href
|
||||
)
|
||||
await buildBareLibs()
|
||||
console.log('bare-os-bare-libs emitted to kernel/lib/bare')
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.clear?.()
|
||||
console.log('--- bare-os-seeder (Hyperdrive + MBR) ---')
|
||||
|
||||
await maybeBuildCoreutilsFromSource()
|
||||
await maybeBuildBareLibsFromSource()
|
||||
|
||||
const kernelRoot = defaultKernelRoot(_pkg, import.meta.url)
|
||||
|
||||
|
||||
@@ -10,12 +10,14 @@ Files in this directory are **read from disk by the seeder** (or copied into `pa
|
||||
| `bin/<name>` | `/bin/<name>` |
|
||||
| `etc/...` | `/etc/...` |
|
||||
| `share/man/...` | `/share/man/...` |
|
||||
| `lib/bare/...` | `/lib/bare/...` (optional **`ctx.bare`** bundles; see **`bare-os-bare-libs`**) |
|
||||
| Any other file | `/<relative path>` |
|
||||
|
||||
## Contents
|
||||
|
||||
- **`init.js`** — Kernel entry: must define `async function start(ctx)`. Boot order: **`/etc/os-release`** → **`/etc/motd`** → optional **`/etc/bare-os/rc.profile.<profile>`** (profile from **`BARE_OS_BOOT_PROFILE`** or first line of **`/etc/bare-os/profile`**; the booter mirrors the resolved name in **`ctx.env.BARE_OS_BOOT_PROFILE_RESOLVED`** and **`/run/bare-os/boot_profile`**) → **`/etc/bare-os/rc`** → **`/etc/bare-os/rc.d/*`** (sorted; digit-prefixed names only; skip dotfiles, `*~`, `README*`, `*.md`; optional **`BARE_OS_RC_D_SKIP`** comma list and **`prefix*`** patterns) → optional **`/etc/bare-os/rc.local`** → **`/etc/bare-os/kernel.d/*`** (same rules as **`rc.d`**) → banner → when **`BARE_OS_SKIP_REPL`**, optional **onboot** lines from **`BARE_OS_ONBOOT`** or **`/etc/bare-os/onboot`** → **`readLine` / `execLine`** loop. Boot **`execLine`** errors in trusted snippets are logged; with **`BARE_OS_BOOT_STRICT=1`** or **`true`**, the first throw calls **`requestBooterExit(1)`** and stops later boot phases. Custom kernels may call **`ctx.registerKernelShutdownHook(fn)`** before initd disposers; use **`ctx.bareOsRuntimeCaps`** for limits, pseudo paths, and **`features`** ([`developer-guide/02-the-context-object.md`](../developer-guide/02-the-context-object.md)).
|
||||
- **`bin/`** — **Tier-1 utilities** built by [bare-os-coreutils](../packages/bare-os-coreutils/README.md). Each file is **`runtime.js`** + optional **`lib/*-engine.js`** (**`sed`**, **`awk`**) or **`lib/man-render.js`** (**`man`**) + **`async function run(ctx, argv)`** (no ESM **`import`** in **`src/`**).
|
||||
- **`lib/bare/`** — Optional IIFE bundles + **`manifest.json`** for **`ctx.bare`** drive merge, built by [bare-os-bare-libs](../packages/bare-os-bare-libs/README.md). Same trust model as **`bin/`** (trusted seeded image).
|
||||
- **`share/man/man.json`** — Merged manual database for **`/bin/man`** (built by **`bare-os-coreutils`**; see [handbook ch.10](../handbook/10-manpages-and-online-help.md)).
|
||||
- **`etc/os-release`** — Static OS metadata (`NAME`, `VERSION`, …).
|
||||
- **`etc/motd`** — Optional message printed after **`os-release`** (distributors can customize).
|
||||
@@ -27,9 +29,10 @@ Files in this directory are **read from disk by the seeder** (or copied into `pa
|
||||
|
||||
1. Change sources under `kernel/` or `packages/bare-os-coreutils/src/`.
|
||||
2. Run `npm run build -w bare-os-coreutils` to refresh `kernel/bin/*`.
|
||||
3. Run seeder again to re-stage the drive (or use a fresh Corestore for a clean image).
|
||||
3. Run `npm run build -w bare-os-bare-libs` when **`packages/bare-os-booter/lib/bare-module-manifest.json`** or bundle entries change.
|
||||
4. Run seeder again to re-stage the drive (or use a fresh Corestore for a clean image).
|
||||
|
||||
Pear bundles use the **vendored** tree under `packages/bare-os-seeder/kernel/`; keep it in sync by running the same build before `pear stage`. **`npm test`** runs **`scripts/verify-kernel-seeder-parity.mjs`** (after **`bare-os-coreutils`** build) so the two trees match byte-for-byte and every **`kernel/bin/*`** file contains the **`BARE_OS_BIN_API`** pragma (coreutils **`runtime.js`** and hand-written stubs such as **`systemctl`** / **`journalctl`**).
|
||||
Pear bundles use the **vendored** tree under `packages/bare-os-seeder/kernel/`; keep it in sync by running the same builds before `pear stage`. **`npm test`** runs **`scripts/verify-kernel-seeder-parity.mjs`** (after **`bare-os-coreutils`** and **`bare-os-bare-libs`** builds) so the two trees match byte-for-byte and every **`kernel/bin/*`** file contains the **`BARE_OS_BIN_API`** pragma (coreutils **`runtime.js`** and hand-written stubs such as **`systemctl`** / **`journalctl`**).
|
||||
|
||||
Optional **system** image examples: **`etc/bare-os/boot.allow.example`** (copy to **`boot.allow`** when using host **`BARE_OS_BOOT_ALLOWLIST=1`**), **`etc/bare-os/crontab.example`** (system-wide cron lines merged ahead of user **`~/.crontab`**).
|
||||
|
||||
|
||||
@@ -0,0 +1,428 @@
|
||||
/* BARE_OS_BIN_API 1.0.0 — bump when staged /bin script semantics change (see developer guide). */
|
||||
/** Shared helpers for drive-resident /bin scripts (prepended before each command). */
|
||||
function bareStdin(ctx) {
|
||||
return typeof ctx.shellStdin === 'string' ? ctx.shellStdin : ''
|
||||
}
|
||||
|
||||
/** @param {number} mode @param {'file' | 'directory' | 'symlink'} type */
|
||||
function bareFormatModeString(mode, type) {
|
||||
const typeChar = type === 'directory' ? 'd' : type === 'symlink' ? 'l' : '-'
|
||||
const perm = mode & 0o777
|
||||
const r = (bit) => (perm & bit ? 'r' : '-')
|
||||
const w = (bit) => (perm & bit ? 'w' : '-')
|
||||
const x = (bit) => (perm & bit ? 'x' : '-')
|
||||
return (
|
||||
typeChar +
|
||||
r(0o400) +
|
||||
w(0o200) +
|
||||
x(0o100) +
|
||||
r(0o040) +
|
||||
w(0o020) +
|
||||
x(0o010) +
|
||||
r(0o004) +
|
||||
w(0o002) +
|
||||
x(0o001)
|
||||
)
|
||||
}
|
||||
|
||||
/** @param {number} mtimeMs @param {number} [nowMs] */
|
||||
function bareFormatLsMtime(mtimeMs, nowMs) {
|
||||
const now = nowMs != null ? nowMs : Date.now()
|
||||
const d = new Date(mtimeMs)
|
||||
const months = [
|
||||
'Jan',
|
||||
'Feb',
|
||||
'Mar',
|
||||
'Apr',
|
||||
'May',
|
||||
'Jun',
|
||||
'Jul',
|
||||
'Aug',
|
||||
'Sep',
|
||||
'Oct',
|
||||
'Nov',
|
||||
'Dec'
|
||||
]
|
||||
const mon = months[d.getMonth()]
|
||||
const day = String(d.getDate()).padStart(2, ' ')
|
||||
const sixMo = 180 * 24 * 3600 * 1000
|
||||
if (Math.abs(now - mtimeMs) > sixMo) {
|
||||
const yr = String(d.getFullYear()).padStart(4, ' ')
|
||||
return mon + ' ' + day + ' ' + yr
|
||||
}
|
||||
const hh = String(d.getHours()).padStart(2, '0')
|
||||
const mm = String(d.getMinutes()).padStart(2, '0')
|
||||
return mon + ' ' + day + ' ' + hh + ':' + mm
|
||||
}
|
||||
|
||||
/** @param {number} size */
|
||||
function barePosixBlocks(size) {
|
||||
return Math.ceil(Number(size) / 512) || 0
|
||||
}
|
||||
|
||||
/**
|
||||
* GNU-style LS_COLORS string + dircolors(5) database parsing and file classification.
|
||||
* Consumed by bare-os-booter (ESM import). Prepended into /bin/ls and /bin/dircolors by bare-os-coreutils build (no import there).
|
||||
*/
|
||||
|
||||
/** Default LS_COLORS (subset aligned with GNU dircolors -p essentials + common globs). */
|
||||
function bareDefaultLsColorsString() {
|
||||
return [
|
||||
'no=00',
|
||||
'fi=00',
|
||||
'di=01;34',
|
||||
'ln=01;36',
|
||||
'pi=40;33',
|
||||
'so=01;35',
|
||||
'do=01;35',
|
||||
'bd=40;33;01',
|
||||
'cd=40;33;01',
|
||||
'or=40;31;01',
|
||||
'mi=00',
|
||||
'su=37;41',
|
||||
'sg=30;43',
|
||||
'ca=30;41',
|
||||
'tw=30;42',
|
||||
'ow=34;43',
|
||||
'st=37;44',
|
||||
'ex=01;32',
|
||||
'mh=00',
|
||||
'*.tar=01;31',
|
||||
'*.tgz=01;31',
|
||||
'*.arc=01;31',
|
||||
'*.arj=01;31',
|
||||
'*.taz=01;31',
|
||||
'*.lha=01;31',
|
||||
'*.lz4=01;31',
|
||||
'*.lzh=01;31',
|
||||
'*.tlz=01;31',
|
||||
'*.txz=01;31',
|
||||
'*.tzo=01;31',
|
||||
'*.tzst=01;31',
|
||||
'*.bz2=01;31',
|
||||
'*.bz=01;31',
|
||||
'*.tbz=01;31',
|
||||
'*.tbz2=01;31',
|
||||
'*.tz=01;31',
|
||||
'*.deb=01;31',
|
||||
'*.rpm=01;31',
|
||||
'*.jar=01;31',
|
||||
'*.war=01;31',
|
||||
'*.ear=01;31',
|
||||
'*.sar=01;31',
|
||||
'*.rar=01;31',
|
||||
'*.alz=01;31',
|
||||
'*.ace=01;31',
|
||||
'*.zoo=01;31',
|
||||
'*.cpio=01;31',
|
||||
'*.7z=01;31',
|
||||
'*.rz=01;31',
|
||||
'*.cab=01;31',
|
||||
'*.wim=01;31',
|
||||
'*.swm=01;31',
|
||||
'*.dwm=01;31',
|
||||
'*.esd=01;31',
|
||||
'*.jpg=01;35',
|
||||
'*.jpeg=01;35',
|
||||
'*.mjpg=01;35',
|
||||
'*.mjpeg=01;35',
|
||||
'*.gif=01;35',
|
||||
'*.bmp=01;35',
|
||||
'*.pbm=01;35',
|
||||
'*.pgm=01;35',
|
||||
'*.ppm=01;35',
|
||||
'*.tga=01;35',
|
||||
'*.xbm=01;35',
|
||||
'*.xpm=01;35',
|
||||
'*.tif=01;35',
|
||||
'*.tiff=01;35',
|
||||
'*.png=01;35',
|
||||
'*.svg=01;35',
|
||||
'*.svgz=01;35',
|
||||
'*.mng=01;35',
|
||||
'*.pcx=01;35',
|
||||
'*.mov=01;35',
|
||||
'*.mpg=01;35',
|
||||
'*.mpeg=01;35',
|
||||
'*.m2v=01;35',
|
||||
'*.mkv=01;35',
|
||||
'*.webm=01;35',
|
||||
'*.ogm=01;35',
|
||||
'*.mp4=01;35',
|
||||
'*.m4v=01;35',
|
||||
'*.mp4v=01;35',
|
||||
'*.vob=01;35',
|
||||
'*.qt=01;35',
|
||||
'*.nuv=01;35',
|
||||
'*.wmv=01;35',
|
||||
'*.asf=01;35',
|
||||
'*.rm=01;35',
|
||||
'*.rmvb=01;35',
|
||||
'*.flc=01;35',
|
||||
'*.avi=01;35',
|
||||
'*.fli=01;35',
|
||||
'*.flv=01;35',
|
||||
'*.gl=01;35',
|
||||
'*.dl=01;35',
|
||||
'*.xcf=01;35',
|
||||
'*.xwd=01;35',
|
||||
'*.yuv=01;35',
|
||||
'*.cgm=01;35',
|
||||
'*.emf=01;35',
|
||||
'*.ogv=01;35',
|
||||
'*.ogx=01;35',
|
||||
'*.aac=00;36',
|
||||
'*.au=00;36',
|
||||
'*.flac=00;36',
|
||||
'*.m4a=00;36',
|
||||
'*.mid=00;36',
|
||||
'*.midi=00;36',
|
||||
'*.mka=00;36',
|
||||
'*.mp3=00;36',
|
||||
'*.mpc=00;36',
|
||||
'*.ogg=00;36',
|
||||
'*.ra=00;36',
|
||||
'*.wav=00;36',
|
||||
'*.oga=00;36',
|
||||
'*.opus=00;36',
|
||||
'*.spx=00;36',
|
||||
'*.xspf=00;36',
|
||||
'*.pdf=00;32',
|
||||
'*.ps=00;32',
|
||||
'*.txt=00;32',
|
||||
'*.patch=00;32',
|
||||
'*.diff=00;32',
|
||||
'*.log=00;32',
|
||||
'*.tex=00;32',
|
||||
'*.doc=00;32',
|
||||
'*.docx=00;32',
|
||||
'*.rtf=00;32',
|
||||
'*.odt=00;32',
|
||||
'*.md=00;32',
|
||||
'*.markdown=00;32',
|
||||
'*.css=00;32',
|
||||
'*.htm=00;32',
|
||||
'*.html=00;32',
|
||||
'*.xml=00;32',
|
||||
'*.json=00;32',
|
||||
'*.yaml=00;32',
|
||||
'*.yml=00;32',
|
||||
'*.c=00;32',
|
||||
'*.h=00;32',
|
||||
'*.js=00;32',
|
||||
'*.mjs=00;32',
|
||||
'*.java=00;32',
|
||||
'*.py=00;32',
|
||||
'*.go=00;32',
|
||||
'*.rs=00;32',
|
||||
'*.cpp=00;32',
|
||||
'*.cc=00;32',
|
||||
'*.cxx=00;32',
|
||||
'*.hpp=00;32',
|
||||
'*.shlib=01;32',
|
||||
'*.so=01;32',
|
||||
'*.dylib=01;32',
|
||||
'*.dll=01;32',
|
||||
'*.a=01;32',
|
||||
'*.lib=01;32',
|
||||
'*.ko=01;32',
|
||||
'*.sh=01;32',
|
||||
'*.bash=01;32',
|
||||
'*.zsh=01;32',
|
||||
'*.bat=01;32',
|
||||
'*.cmd=01;32',
|
||||
'*.exe=01;32',
|
||||
'*.com=01;32',
|
||||
'*.btm=01;32',
|
||||
'*.msi=01;32'
|
||||
].join(':')
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} s
|
||||
* @returns {Record<string, string>}
|
||||
*/
|
||||
function bareParseLsColors(s) {
|
||||
const out = /** @type {Record<string, string>} */ ({})
|
||||
if (s == null || !String(s).trim()) return out
|
||||
for (const part of String(s).split(':')) {
|
||||
const p = part.trim()
|
||||
if (!p) continue
|
||||
const eq = p.indexOf('=')
|
||||
if (eq <= 0) continue
|
||||
const k = p.slice(0, eq)
|
||||
const v = p.slice(eq + 1)
|
||||
if (k) out[k] = v
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, string>} map
|
||||
*/
|
||||
function bareSerializeLsColors(map) {
|
||||
const keys = Object.keys(map).sort()
|
||||
return keys.map((k) => k + '=' + map[k]).join(':')
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} code dircolors value (e.g. 01;34)
|
||||
* @returns {string} opening SGR including ESC
|
||||
*/
|
||||
function bareLscolorsToOpenSgr(code) {
|
||||
if (code == null || code === '' || code === '0' || code === '00') return ''
|
||||
return '\x1b[' + code + 'm'
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse dircolors database (GNU subset): # comments, blank lines, TERM blocks, KEY VALUE pairs.
|
||||
* @param {string} text
|
||||
* @param {string} termEnv value of TERM
|
||||
* @returns {Record<string, string>}
|
||||
*/
|
||||
function bareParseDircolorsDatabase(text, termEnv) {
|
||||
const term = termEnv != null ? String(termEnv) : ''
|
||||
/** @type {Record<string, string>} */
|
||||
const out = {}
|
||||
let blockActive = true
|
||||
const lines = String(text).split(/\r?\n/)
|
||||
for (let raw of lines) {
|
||||
const line = raw.replace(/#.*$/, '').trim()
|
||||
if (!line) continue
|
||||
const upper = line.toUpperCase()
|
||||
if (upper.startsWith('TERM ')) {
|
||||
const rest = line.slice(5).trim()
|
||||
if (rest === 'none') blockActive = false
|
||||
else
|
||||
blockActive =
|
||||
rest === '*' || rest === '' || rest === term || term.indexOf(rest) === 0
|
||||
continue
|
||||
}
|
||||
if (upper.startsWith('COLOR ') || upper.startsWith('OPTIONS ')) continue
|
||||
if (!blockActive) continue
|
||||
const ws = line.search(/\s/)
|
||||
if (ws <= 0) continue
|
||||
const key = line.slice(0, ws).trim()
|
||||
const val = line.slice(ws + 1).trim()
|
||||
if (!key || !val) continue
|
||||
if (key === 'TERM' || key === 'COLOR' || key === 'OPTIONS') continue
|
||||
out[key] = val
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} filename basename only
|
||||
* @param {Record<string, string>} map
|
||||
*/
|
||||
function bareLsColorsGlobMatch(filename, map) {
|
||||
const keys = Object.keys(map).filter((k) => k.startsWith('*.'))
|
||||
keys.sort((a, b) => b.length - a.length)
|
||||
const lower = filename.toLowerCase()
|
||||
for (const k of keys) {
|
||||
const suf = k.slice(1).toLowerCase()
|
||||
if (lower.endsWith(suf)) return map[k]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ type?: string, mode?: number, linkname?: string, targetMissing?: boolean, nlink?: number, capabilities?: boolean } | null} st
|
||||
* @param {string} filename basename
|
||||
* @param {Record<string, string>} map from LS_COLORS
|
||||
* @returns {string} SGR open sequence or ''
|
||||
*/
|
||||
function bareLsColorOpenSgrFromMap(st, filename, map) {
|
||||
if (!st) {
|
||||
const no = map.no
|
||||
return no ? bareLscolorsToOpenSgr(no) : ''
|
||||
}
|
||||
const mode = Number(st.mode) || 0
|
||||
const perm = mode & 0o777
|
||||
const t = st.type
|
||||
let key = 'fi'
|
||||
|
||||
if (t === 'symlink') {
|
||||
key = st.targetMissing ? 'or' : 'ln'
|
||||
} else if (t === 'directory') {
|
||||
const ow = (perm & 0o002) !== 0
|
||||
const sticky = (mode & 0o1000) !== 0
|
||||
if (ow && sticky) key = 'tw'
|
||||
else if (ow) key = 'ow'
|
||||
else if (sticky) key = 'st'
|
||||
else key = 'di'
|
||||
} else if (t === 'file') {
|
||||
if (st.capabilities) key = 'ca'
|
||||
else if (mode & 0o4000) key = 'su'
|
||||
else if (mode & 0o2000) key = 'sg'
|
||||
else if (perm & 0o111) key = 'ex'
|
||||
else {
|
||||
const nlink = Number(st.nlink)
|
||||
if (nlink > 1 && map.mh != null && String(map.mh).trim() !== '') {
|
||||
const mhOpen = bareLscolorsToOpenSgr(map.mh)
|
||||
if (mhOpen) return mhOpen
|
||||
}
|
||||
const g = bareLsColorsGlobMatch(filename, map)
|
||||
if (g != null) return bareLscolorsToOpenSgr(g)
|
||||
key = 'fi'
|
||||
}
|
||||
}
|
||||
|
||||
const code = map[key] != null ? map[key] : map.fi
|
||||
return code ? bareLscolorsToOpenSgr(code) : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} multiline dircolors database (default colors)
|
||||
*/
|
||||
function bareDefaultDircolorsDatabase() {
|
||||
const pairs = bareParseLsColors(bareDefaultLsColorsString())
|
||||
const lines = ['# Bare OS default dircolors (GNU-like)', 'TERM *', '']
|
||||
for (const k of Object.keys(pairs).sort()) {
|
||||
lines.push(k + ' ' + pairs[k])
|
||||
}
|
||||
return lines.join('\n') + '\n'
|
||||
}
|
||||
|
||||
async function run(ctx, argv) {
|
||||
const env = ctx.env || {}
|
||||
let bourne = false
|
||||
let printDefault = false
|
||||
/** @type {string | null} */
|
||||
let file = null
|
||||
for (let i = 1; i < argv.length; i++) {
|
||||
const a = argv[i]
|
||||
if (a === '--') continue
|
||||
if (a === '-b' || a === '--sh' || a === '--bourne-shell') bourne = true
|
||||
else if (a === '-p' || a === '--print-database') printDefault = true
|
||||
else if (a.startsWith('-')) {
|
||||
ctx.console.error('dircolors: unrecognized option: ' + a)
|
||||
ctx.exitCode = 2
|
||||
return
|
||||
} else file = a
|
||||
}
|
||||
if (printDefault) {
|
||||
ctx.console.log(bareDefaultDircolorsDatabase())
|
||||
return
|
||||
}
|
||||
let text = bareDefaultDircolorsDatabase()
|
||||
if (file) {
|
||||
const buf = await ctx.vfs.readFile(file)
|
||||
if (!buf) {
|
||||
ctx.console.error('dircolors: cannot read ' + file)
|
||||
ctx.exitCode = 2
|
||||
return
|
||||
}
|
||||
text = ctx.b4a.toString(buf)
|
||||
}
|
||||
const term = env.TERM || ''
|
||||
const db = bareParseDircolorsDatabase(text, term)
|
||||
const ls = bareSerializeLsColors(db)
|
||||
if (bourne) {
|
||||
const q = "'" + ls.replace(/'/g, "'\\''") + "'"
|
||||
ctx.console.log('LS_COLORS=' + q)
|
||||
ctx.console.log('export LS_COLORS')
|
||||
} else {
|
||||
ctx.console.log(ls)
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ function barePosixBlocks(size) {
|
||||
|
||||
async function run(ctx, argv) {
|
||||
ctx.console.log(
|
||||
'Bare OS — default user: guest | shell builtins: alias, cd, command, export, exit, login, logout, readonly, type, umask, unalias, unset, : | /bin: awk basename cat chgrp chmod chown cksum clear cp crontab curl cut date dirname du echo env exit false find getconf grep head hdms help hostname id journalctl jq ln login logout logname ls man mkdir mkfifo mv nl od pathchk printenv printf pwd readlink rm rmdir savevault sed seq sleep sort stat systemctl tail tee test time touch tr true tty uname wc wget which whoami xargs'
|
||||
'Bare OS — default user: guest | shell builtins: alias, barerc, cd, command, export, exit, login, logout, readonly, type, umask, unalias, unset, : | /bin: awk basename cat chgrp chmod chown cksum clear cp crontab curl cut date dirname dircolors du echo env exit false find getconf grep head hdms help hostname id journalctl jq ln login logout logname ls man mkdir mkfifo mv nl od pathchk printenv printf pwd readlink rm rmdir savevault sed seq sleep sort stat systemctl tail tee test theme time touch tr true tty uname wc wget which whoami xargs'
|
||||
)
|
||||
ctx.console.log(
|
||||
'Docs: man <command> | man handbook (full handbook, section 7) | man bare-os-shell | man -k <word> | man -l'
|
||||
|
||||
@@ -60,10 +60,424 @@ function barePosixBlocks(size) {
|
||||
return Math.ceil(Number(size) / 512) || 0
|
||||
}
|
||||
|
||||
/**
|
||||
* GNU-style LS_COLORS string + dircolors(5) database parsing and file classification.
|
||||
* Consumed by bare-os-booter (ESM import). Prepended into /bin/ls and /bin/dircolors by bare-os-coreutils build (no import there).
|
||||
*/
|
||||
|
||||
/** Default LS_COLORS (subset aligned with GNU dircolors -p essentials + common globs). */
|
||||
function bareDefaultLsColorsString() {
|
||||
return [
|
||||
'no=00',
|
||||
'fi=00',
|
||||
'di=01;34',
|
||||
'ln=01;36',
|
||||
'pi=40;33',
|
||||
'so=01;35',
|
||||
'do=01;35',
|
||||
'bd=40;33;01',
|
||||
'cd=40;33;01',
|
||||
'or=40;31;01',
|
||||
'mi=00',
|
||||
'su=37;41',
|
||||
'sg=30;43',
|
||||
'ca=30;41',
|
||||
'tw=30;42',
|
||||
'ow=34;43',
|
||||
'st=37;44',
|
||||
'ex=01;32',
|
||||
'mh=00',
|
||||
'*.tar=01;31',
|
||||
'*.tgz=01;31',
|
||||
'*.arc=01;31',
|
||||
'*.arj=01;31',
|
||||
'*.taz=01;31',
|
||||
'*.lha=01;31',
|
||||
'*.lz4=01;31',
|
||||
'*.lzh=01;31',
|
||||
'*.tlz=01;31',
|
||||
'*.txz=01;31',
|
||||
'*.tzo=01;31',
|
||||
'*.tzst=01;31',
|
||||
'*.bz2=01;31',
|
||||
'*.bz=01;31',
|
||||
'*.tbz=01;31',
|
||||
'*.tbz2=01;31',
|
||||
'*.tz=01;31',
|
||||
'*.deb=01;31',
|
||||
'*.rpm=01;31',
|
||||
'*.jar=01;31',
|
||||
'*.war=01;31',
|
||||
'*.ear=01;31',
|
||||
'*.sar=01;31',
|
||||
'*.rar=01;31',
|
||||
'*.alz=01;31',
|
||||
'*.ace=01;31',
|
||||
'*.zoo=01;31',
|
||||
'*.cpio=01;31',
|
||||
'*.7z=01;31',
|
||||
'*.rz=01;31',
|
||||
'*.cab=01;31',
|
||||
'*.wim=01;31',
|
||||
'*.swm=01;31',
|
||||
'*.dwm=01;31',
|
||||
'*.esd=01;31',
|
||||
'*.jpg=01;35',
|
||||
'*.jpeg=01;35',
|
||||
'*.mjpg=01;35',
|
||||
'*.mjpeg=01;35',
|
||||
'*.gif=01;35',
|
||||
'*.bmp=01;35',
|
||||
'*.pbm=01;35',
|
||||
'*.pgm=01;35',
|
||||
'*.ppm=01;35',
|
||||
'*.tga=01;35',
|
||||
'*.xbm=01;35',
|
||||
'*.xpm=01;35',
|
||||
'*.tif=01;35',
|
||||
'*.tiff=01;35',
|
||||
'*.png=01;35',
|
||||
'*.svg=01;35',
|
||||
'*.svgz=01;35',
|
||||
'*.mng=01;35',
|
||||
'*.pcx=01;35',
|
||||
'*.mov=01;35',
|
||||
'*.mpg=01;35',
|
||||
'*.mpeg=01;35',
|
||||
'*.m2v=01;35',
|
||||
'*.mkv=01;35',
|
||||
'*.webm=01;35',
|
||||
'*.ogm=01;35',
|
||||
'*.mp4=01;35',
|
||||
'*.m4v=01;35',
|
||||
'*.mp4v=01;35',
|
||||
'*.vob=01;35',
|
||||
'*.qt=01;35',
|
||||
'*.nuv=01;35',
|
||||
'*.wmv=01;35',
|
||||
'*.asf=01;35',
|
||||
'*.rm=01;35',
|
||||
'*.rmvb=01;35',
|
||||
'*.flc=01;35',
|
||||
'*.avi=01;35',
|
||||
'*.fli=01;35',
|
||||
'*.flv=01;35',
|
||||
'*.gl=01;35',
|
||||
'*.dl=01;35',
|
||||
'*.xcf=01;35',
|
||||
'*.xwd=01;35',
|
||||
'*.yuv=01;35',
|
||||
'*.cgm=01;35',
|
||||
'*.emf=01;35',
|
||||
'*.ogv=01;35',
|
||||
'*.ogx=01;35',
|
||||
'*.aac=00;36',
|
||||
'*.au=00;36',
|
||||
'*.flac=00;36',
|
||||
'*.m4a=00;36',
|
||||
'*.mid=00;36',
|
||||
'*.midi=00;36',
|
||||
'*.mka=00;36',
|
||||
'*.mp3=00;36',
|
||||
'*.mpc=00;36',
|
||||
'*.ogg=00;36',
|
||||
'*.ra=00;36',
|
||||
'*.wav=00;36',
|
||||
'*.oga=00;36',
|
||||
'*.opus=00;36',
|
||||
'*.spx=00;36',
|
||||
'*.xspf=00;36',
|
||||
'*.pdf=00;32',
|
||||
'*.ps=00;32',
|
||||
'*.txt=00;32',
|
||||
'*.patch=00;32',
|
||||
'*.diff=00;32',
|
||||
'*.log=00;32',
|
||||
'*.tex=00;32',
|
||||
'*.doc=00;32',
|
||||
'*.docx=00;32',
|
||||
'*.rtf=00;32',
|
||||
'*.odt=00;32',
|
||||
'*.md=00;32',
|
||||
'*.markdown=00;32',
|
||||
'*.css=00;32',
|
||||
'*.htm=00;32',
|
||||
'*.html=00;32',
|
||||
'*.xml=00;32',
|
||||
'*.json=00;32',
|
||||
'*.yaml=00;32',
|
||||
'*.yml=00;32',
|
||||
'*.c=00;32',
|
||||
'*.h=00;32',
|
||||
'*.js=00;32',
|
||||
'*.mjs=00;32',
|
||||
'*.java=00;32',
|
||||
'*.py=00;32',
|
||||
'*.go=00;32',
|
||||
'*.rs=00;32',
|
||||
'*.cpp=00;32',
|
||||
'*.cc=00;32',
|
||||
'*.cxx=00;32',
|
||||
'*.hpp=00;32',
|
||||
'*.shlib=01;32',
|
||||
'*.so=01;32',
|
||||
'*.dylib=01;32',
|
||||
'*.dll=01;32',
|
||||
'*.a=01;32',
|
||||
'*.lib=01;32',
|
||||
'*.ko=01;32',
|
||||
'*.sh=01;32',
|
||||
'*.bash=01;32',
|
||||
'*.zsh=01;32',
|
||||
'*.bat=01;32',
|
||||
'*.cmd=01;32',
|
||||
'*.exe=01;32',
|
||||
'*.com=01;32',
|
||||
'*.btm=01;32',
|
||||
'*.msi=01;32'
|
||||
].join(':')
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} s
|
||||
* @returns {Record<string, string>}
|
||||
*/
|
||||
function bareParseLsColors(s) {
|
||||
const out = /** @type {Record<string, string>} */ ({})
|
||||
if (s == null || !String(s).trim()) return out
|
||||
for (const part of String(s).split(':')) {
|
||||
const p = part.trim()
|
||||
if (!p) continue
|
||||
const eq = p.indexOf('=')
|
||||
if (eq <= 0) continue
|
||||
const k = p.slice(0, eq)
|
||||
const v = p.slice(eq + 1)
|
||||
if (k) out[k] = v
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, string>} map
|
||||
*/
|
||||
function bareSerializeLsColors(map) {
|
||||
const keys = Object.keys(map).sort()
|
||||
return keys.map((k) => k + '=' + map[k]).join(':')
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} code dircolors value (e.g. 01;34)
|
||||
* @returns {string} opening SGR including ESC
|
||||
*/
|
||||
function bareLscolorsToOpenSgr(code) {
|
||||
if (code == null || code === '' || code === '0' || code === '00') return ''
|
||||
return '\x1b[' + code + 'm'
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse dircolors database (GNU subset): # comments, blank lines, TERM blocks, KEY VALUE pairs.
|
||||
* @param {string} text
|
||||
* @param {string} termEnv value of TERM
|
||||
* @returns {Record<string, string>}
|
||||
*/
|
||||
function bareParseDircolorsDatabase(text, termEnv) {
|
||||
const term = termEnv != null ? String(termEnv) : ''
|
||||
/** @type {Record<string, string>} */
|
||||
const out = {}
|
||||
let blockActive = true
|
||||
const lines = String(text).split(/\r?\n/)
|
||||
for (let raw of lines) {
|
||||
const line = raw.replace(/#.*$/, '').trim()
|
||||
if (!line) continue
|
||||
const upper = line.toUpperCase()
|
||||
if (upper.startsWith('TERM ')) {
|
||||
const rest = line.slice(5).trim()
|
||||
if (rest === 'none') blockActive = false
|
||||
else
|
||||
blockActive =
|
||||
rest === '*' || rest === '' || rest === term || term.indexOf(rest) === 0
|
||||
continue
|
||||
}
|
||||
if (upper.startsWith('COLOR ') || upper.startsWith('OPTIONS ')) continue
|
||||
if (!blockActive) continue
|
||||
const ws = line.search(/\s/)
|
||||
if (ws <= 0) continue
|
||||
const key = line.slice(0, ws).trim()
|
||||
const val = line.slice(ws + 1).trim()
|
||||
if (!key || !val) continue
|
||||
if (key === 'TERM' || key === 'COLOR' || key === 'OPTIONS') continue
|
||||
out[key] = val
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} filename basename only
|
||||
* @param {Record<string, string>} map
|
||||
*/
|
||||
function bareLsColorsGlobMatch(filename, map) {
|
||||
const keys = Object.keys(map).filter((k) => k.startsWith('*.'))
|
||||
keys.sort((a, b) => b.length - a.length)
|
||||
const lower = filename.toLowerCase()
|
||||
for (const k of keys) {
|
||||
const suf = k.slice(1).toLowerCase()
|
||||
if (lower.endsWith(suf)) return map[k]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ type?: string, mode?: number, linkname?: string, targetMissing?: boolean, nlink?: number, capabilities?: boolean } | null} st
|
||||
* @param {string} filename basename
|
||||
* @param {Record<string, string>} map from LS_COLORS
|
||||
* @returns {string} SGR open sequence or ''
|
||||
*/
|
||||
function bareLsColorOpenSgrFromMap(st, filename, map) {
|
||||
if (!st) {
|
||||
const no = map.no
|
||||
return no ? bareLscolorsToOpenSgr(no) : ''
|
||||
}
|
||||
const mode = Number(st.mode) || 0
|
||||
const perm = mode & 0o777
|
||||
const t = st.type
|
||||
let key = 'fi'
|
||||
|
||||
if (t === 'symlink') {
|
||||
key = st.targetMissing ? 'or' : 'ln'
|
||||
} else if (t === 'directory') {
|
||||
const ow = (perm & 0o002) !== 0
|
||||
const sticky = (mode & 0o1000) !== 0
|
||||
if (ow && sticky) key = 'tw'
|
||||
else if (ow) key = 'ow'
|
||||
else if (sticky) key = 'st'
|
||||
else key = 'di'
|
||||
} else if (t === 'file') {
|
||||
if (st.capabilities) key = 'ca'
|
||||
else if (mode & 0o4000) key = 'su'
|
||||
else if (mode & 0o2000) key = 'sg'
|
||||
else if (perm & 0o111) key = 'ex'
|
||||
else {
|
||||
const nlink = Number(st.nlink)
|
||||
if (nlink > 1 && map.mh != null && String(map.mh).trim() !== '') {
|
||||
const mhOpen = bareLscolorsToOpenSgr(map.mh)
|
||||
if (mhOpen) return mhOpen
|
||||
}
|
||||
const g = bareLsColorsGlobMatch(filename, map)
|
||||
if (g != null) return bareLscolorsToOpenSgr(g)
|
||||
key = 'fi'
|
||||
}
|
||||
}
|
||||
|
||||
const code = map[key] != null ? map[key] : map.fi
|
||||
return code ? bareLscolorsToOpenSgr(code) : ''
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} multiline dircolors database (default colors)
|
||||
*/
|
||||
function bareDefaultDircolorsDatabase() {
|
||||
const pairs = bareParseLsColors(bareDefaultLsColorsString())
|
||||
const lines = ['# Bare OS default dircolors (GNU-like)', 'TERM *', '']
|
||||
for (const k of Object.keys(pairs).sort()) {
|
||||
lines.push(k + ' ' + pairs[k])
|
||||
}
|
||||
return lines.join('\n') + '\n'
|
||||
}
|
||||
|
||||
/** ANSI coloring for /bin/ls (after bare-os-lscolors.js preamble). */
|
||||
|
||||
const BARE_LS_RESET = '\x1b[0m'
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} [ctx]
|
||||
* @returns {import('stream').Writable | undefined}
|
||||
*/
|
||||
function bareLsResolveStdout(ctx) {
|
||||
if (!ctx || typeof ctx !== 'object') return globalThis.process?.stdout
|
||||
const c = /** @type {{ replStdout?: unknown, stdout?: unknown }} */ (ctx)
|
||||
const out = c.replStdout || c.stdout || globalThis.process?.stdout
|
||||
return /** @type {import('stream').Writable | undefined} */ (out)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} [ctx]
|
||||
* @param {'never' | 'auto' | 'always'} colorMode
|
||||
*/
|
||||
function bareLsUseColor(ctx, colorMode) {
|
||||
const env =
|
||||
ctx && typeof ctx === 'object' && ctx.env && typeof ctx.env === 'object'
|
||||
? /** @type {Record<string, string>} */ (ctx.env)
|
||||
: {}
|
||||
if (env.NO_COLOR != null && String(env.NO_COLOR) !== '') return false
|
||||
if (colorMode === 'never') return false
|
||||
if (colorMode === 'always') return true
|
||||
const out = bareLsResolveStdout(ctx)
|
||||
return Boolean(out && /** @type {{ isTTY?: boolean }} */ (out).isTTY)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>} [ctx]
|
||||
* @returns {Record<string, string>}
|
||||
*/
|
||||
function bareLsGetLsColorsMap(ctx) {
|
||||
const env =
|
||||
ctx && typeof ctx === 'object' && ctx.env && typeof ctx.env === 'object'
|
||||
? /** @type {Record<string, string>} */ (ctx.env)
|
||||
: {}
|
||||
const raw = env.LS_COLORS
|
||||
if (raw == null || !String(raw).trim()) {
|
||||
return bareParseLsColors(bareDefaultLsColorsString())
|
||||
}
|
||||
return bareParseLsColors(String(raw))
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ mode?: number, type?: string, linkname?: string, targetMissing?: boolean, nlink?: number, capabilities?: boolean } | null | undefined} st
|
||||
* @param {string} filename basename
|
||||
* @param {Record<string, unknown>} [ctx]
|
||||
*/
|
||||
function bareLsOpenSgr(st, filename, ctx) {
|
||||
const map = bareLsGetLsColorsMap(ctx)
|
||||
return bareLsColorOpenSgrFromMap(st, filename, map)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {{ mode?: number, type?: string } | null | undefined} st
|
||||
* @param {boolean} on
|
||||
* @param {Record<string, unknown>} [ctx]
|
||||
*/
|
||||
function bareLsColorWrap(name, st, on, ctx) {
|
||||
if (!on) return name
|
||||
const open = bareLsOpenSgr(st, name, ctx)
|
||||
if (!open) return name
|
||||
return open + name + BARE_LS_RESET
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {string} arrow
|
||||
* @param {{ mode?: number, type?: string, linkname?: string, targetMissing?: boolean, nlink?: number, capabilities?: boolean } | null | undefined} st
|
||||
* @param {boolean} on
|
||||
* @param {Record<string, unknown>} [ctx]
|
||||
*/
|
||||
function bareLsColorLongTail(name, arrow, st, on, ctx) {
|
||||
if (!on) return name + arrow
|
||||
if (st && st.type === 'symlink') {
|
||||
const map = bareLsGetLsColorsMap(ctx)
|
||||
const ln = map.ln
|
||||
const open = ln ? bareLscolorsToOpenSgr(ln) : '\x1b[36m'
|
||||
return open + name + arrow + BARE_LS_RESET
|
||||
}
|
||||
return bareLsColorWrap(name, st, true, ctx) + arrow
|
||||
}
|
||||
|
||||
async function run(ctx, argv) {
|
||||
const vfs = ctx.vfs
|
||||
let showAll = false
|
||||
let longFmt = false
|
||||
/** @type {'never' | 'auto' | 'always'} */
|
||||
let colorMode = 'auto'
|
||||
const paths = []
|
||||
for (let i = 1; i < argv.length; i++) {
|
||||
const a = argv[i]
|
||||
@@ -71,6 +485,22 @@ async function run(ctx, argv) {
|
||||
paths.push(...argv.slice(i + 1))
|
||||
break
|
||||
}
|
||||
if (a.startsWith('--')) {
|
||||
if (a === '--color') {
|
||||
colorMode = 'auto'
|
||||
continue
|
||||
}
|
||||
if (a.startsWith('--color=')) {
|
||||
const v = a.slice(8).toLowerCase()
|
||||
if (v === 'never' || v === 'none' || v === 'no') colorMode = 'never'
|
||||
else if (v === 'always' || v === 'yes' || v === 'force') colorMode = 'always'
|
||||
else colorMode = 'auto'
|
||||
continue
|
||||
}
|
||||
ctx.console.error('ls: unrecognized option ' + a)
|
||||
ctx.exitCode = 2
|
||||
return
|
||||
}
|
||||
if (a.startsWith('-') && a.length > 1) {
|
||||
for (let j = 1; j < a.length; j++) {
|
||||
const c = a[j]
|
||||
@@ -83,6 +513,7 @@ async function run(ctx, argv) {
|
||||
paths.push(a)
|
||||
}
|
||||
const targets = paths.length ? paths : ['.']
|
||||
const useColor = bareLsUseColor(ctx, colorMode)
|
||||
|
||||
for (const t of targets) {
|
||||
if (targets.length > 1) ctx.console.log(t + ':')
|
||||
@@ -104,7 +535,27 @@ async function run(ctx, argv) {
|
||||
}
|
||||
if (!showAll) names = names.filter((n) => !n.startsWith('.'))
|
||||
if (!longFmt) {
|
||||
ctx.console.log(names.join(' '))
|
||||
if (!useColor) {
|
||||
ctx.console.log(names.join(' '))
|
||||
} else {
|
||||
const parts = []
|
||||
for (const n of names) {
|
||||
const sub =
|
||||
singleEntryPath != null
|
||||
? singleEntryPath
|
||||
: t === '.' || t === './'
|
||||
? n
|
||||
: t.replace(/\/$/, '') + '/' + n
|
||||
let st = null
|
||||
try {
|
||||
st = await vfs.lstat(sub)
|
||||
} catch {
|
||||
st = null
|
||||
}
|
||||
parts.push(bareLsColorWrap(n, st, true, ctx))
|
||||
}
|
||||
ctx.console.log(parts.join(' '))
|
||||
}
|
||||
} else {
|
||||
let totalBlocks = 0
|
||||
const rows = []
|
||||
@@ -125,7 +576,8 @@ async function run(ctx, argv) {
|
||||
size: 0,
|
||||
mtimeStr: '?',
|
||||
name: n,
|
||||
arrow: ''
|
||||
arrow: '',
|
||||
st: null
|
||||
})
|
||||
continue
|
||||
}
|
||||
@@ -151,11 +603,13 @@ async function run(ctx, argv) {
|
||||
size,
|
||||
mtimeStr,
|
||||
name: n,
|
||||
arrow
|
||||
arrow,
|
||||
st
|
||||
})
|
||||
}
|
||||
if (singleEntryPath == null) ctx.console.log('total ' + totalBlocks)
|
||||
for (const r of rows) {
|
||||
const tail = bareLsColorLongTail(r.name, r.arrow, r.st, useColor, ctx)
|
||||
ctx.console.log(
|
||||
r.modeStr +
|
||||
' ' +
|
||||
@@ -169,8 +623,7 @@ async function run(ctx, argv) {
|
||||
' ' +
|
||||
r.mtimeStr +
|
||||
' ' +
|
||||
r.name +
|
||||
r.arrow
|
||||
tail
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
/* BARE_OS_BIN_API 1.0.0 — bump when staged /bin script semantics change (see developer guide). */
|
||||
/** Shared helpers for drive-resident /bin scripts (prepended before each command). */
|
||||
function bareStdin(ctx) {
|
||||
return typeof ctx.shellStdin === 'string' ? ctx.shellStdin : ''
|
||||
}
|
||||
|
||||
/** @param {number} mode @param {'file' | 'directory' | 'symlink'} type */
|
||||
function bareFormatModeString(mode, type) {
|
||||
const typeChar = type === 'directory' ? 'd' : type === 'symlink' ? 'l' : '-'
|
||||
const perm = mode & 0o777
|
||||
const r = (bit) => (perm & bit ? 'r' : '-')
|
||||
const w = (bit) => (perm & bit ? 'w' : '-')
|
||||
const x = (bit) => (perm & bit ? 'x' : '-')
|
||||
return (
|
||||
typeChar +
|
||||
r(0o400) +
|
||||
w(0o200) +
|
||||
x(0o100) +
|
||||
r(0o040) +
|
||||
w(0o020) +
|
||||
x(0o010) +
|
||||
r(0o004) +
|
||||
w(0o002) +
|
||||
x(0o001)
|
||||
)
|
||||
}
|
||||
|
||||
/** @param {number} mtimeMs @param {number} [nowMs] */
|
||||
function bareFormatLsMtime(mtimeMs, nowMs) {
|
||||
const now = nowMs != null ? nowMs : Date.now()
|
||||
const d = new Date(mtimeMs)
|
||||
const months = [
|
||||
'Jan',
|
||||
'Feb',
|
||||
'Mar',
|
||||
'Apr',
|
||||
'May',
|
||||
'Jun',
|
||||
'Jul',
|
||||
'Aug',
|
||||
'Sep',
|
||||
'Oct',
|
||||
'Nov',
|
||||
'Dec'
|
||||
]
|
||||
const mon = months[d.getMonth()]
|
||||
const day = String(d.getDate()).padStart(2, ' ')
|
||||
const sixMo = 180 * 24 * 3600 * 1000
|
||||
if (Math.abs(now - mtimeMs) > sixMo) {
|
||||
const yr = String(d.getFullYear()).padStart(4, ' ')
|
||||
return mon + ' ' + day + ' ' + yr
|
||||
}
|
||||
const hh = String(d.getHours()).padStart(2, '0')
|
||||
const mm = String(d.getMinutes()).padStart(2, '0')
|
||||
return mon + ' ' + day + ' ' + hh + ':' + mm
|
||||
}
|
||||
|
||||
/** @param {number} size */
|
||||
function barePosixBlocks(size) {
|
||||
return Math.ceil(Number(size) / 512) || 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme switcher: list presets, show current, set preset (updates ~/.barerc), re-apply.
|
||||
* Uses ctx.bareOsListThemes / ctx.bareOsApplyTheme when provided by the booter.
|
||||
*/
|
||||
|
||||
const FALLBACK_THEMES = [
|
||||
'catppuccin_mocha',
|
||||
'default',
|
||||
'dracula',
|
||||
'github_dark',
|
||||
'gruvbox_dark',
|
||||
'nord',
|
||||
'solarized_dark',
|
||||
'tokyo_night'
|
||||
]
|
||||
|
||||
function themeListFromCtx(ctx) {
|
||||
if (typeof ctx.bareOsListThemes === 'function') {
|
||||
try {
|
||||
const names = ctx.bareOsListThemes()
|
||||
if (Array.isArray(names) && names.length) return names
|
||||
} catch {
|
||||
/* fall through */
|
||||
}
|
||||
}
|
||||
return FALLBACK_THEMES.slice().sort()
|
||||
}
|
||||
|
||||
async function readBarerc(ctx) {
|
||||
try {
|
||||
const buf = await ctx.vfs.readFile('~/.barerc')
|
||||
return buf ? ctx.b4a.toString(buf) : ''
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
async function writeBarerc(ctx, text) {
|
||||
await ctx.vfs.writeFile('~/.barerc', ctx.b4a.from(text))
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure ~/.barerc contains `theme <name>` (replace first theme line or append).
|
||||
* @param {Record<string, unknown>} ctx
|
||||
* @param {string} name
|
||||
*/
|
||||
async function persistThemeLine(ctx, name) {
|
||||
let text = await readBarerc(ctx)
|
||||
const lines = text.split(/\r?\n/)
|
||||
const themeRe = /^\s*theme\s+/
|
||||
let replaced = false
|
||||
const out = []
|
||||
for (const line of lines) {
|
||||
if (themeRe.test(line)) {
|
||||
if (!replaced) {
|
||||
out.push('theme ' + name)
|
||||
replaced = true
|
||||
}
|
||||
} else out.push(line)
|
||||
}
|
||||
if (!replaced) {
|
||||
if (out.length && out[out.length - 1].trim() !== '') out.push('')
|
||||
out.push('theme ' + name)
|
||||
}
|
||||
const newText = out.join('\n')
|
||||
if (!/\n$/.test(newText) && newText.length) await writeBarerc(ctx, newText + '\n')
|
||||
else await writeBarerc(ctx, newText || 'theme ' + name + '\n')
|
||||
}
|
||||
|
||||
async function run(ctx, argv) {
|
||||
const env = ctx.vfs?.env || ctx.env || {}
|
||||
const sub = argv[1] || 'list'
|
||||
|
||||
if (sub === 'list') {
|
||||
for (const n of themeListFromCtx(ctx)) ctx.console.log(n)
|
||||
return
|
||||
}
|
||||
|
||||
if (sub === 'current') {
|
||||
const t = env.BARE_OS_THEME != null ? String(env.BARE_OS_THEME) : 'default'
|
||||
ctx.console.log(t)
|
||||
const ls = env.LS_COLORS
|
||||
if (ls != null && String(ls).length) {
|
||||
ctx.console.log('LS_COLORS_len=' + String(ls).length)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (sub === 'apply') {
|
||||
if (typeof ctx.bareOsApplyTheme === 'function') {
|
||||
await ctx.bareOsApplyTheme()
|
||||
} else {
|
||||
ctx.console.error('theme: bareOsApplyTheme not available')
|
||||
ctx.exitCode = 1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (sub === 'set') {
|
||||
const name = argv[2]
|
||||
if (!name) {
|
||||
ctx.console.error('theme: usage: theme set <name>')
|
||||
ctx.exitCode = 1
|
||||
return
|
||||
}
|
||||
const norm = String(name)
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(/\s+/g, '_')
|
||||
const valid = new Set(themeListFromCtx(ctx).map((s) => s.toLowerCase()))
|
||||
if (!valid.has(norm)) {
|
||||
ctx.console.error('theme: unknown preset: ' + name)
|
||||
ctx.exitCode = 1
|
||||
return
|
||||
}
|
||||
try {
|
||||
await persistThemeLine(ctx, norm)
|
||||
} catch (e) {
|
||||
ctx.console.error('theme: ' + ((e && e.message) || e))
|
||||
ctx.exitCode = 2
|
||||
return
|
||||
}
|
||||
env.BARE_OS_THEME = norm
|
||||
if (typeof ctx.bareOsApplyTheme === 'function') {
|
||||
await ctx.bareOsApplyTheme()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
ctx.console.error(
|
||||
'theme: usage: theme [list|current|set <name>|apply]'
|
||||
)
|
||||
ctx.exitCode = 1
|
||||
}
|
||||
@@ -557,6 +557,10 @@ async function runKernelSelftest(ctx) {
|
||||
'proc-bare_os_features'
|
||||
],
|
||||
['echo selftest_vfs | tee /dev/null', 'pipeline-tee-devnull'],
|
||||
[
|
||||
'test -f /lib/bare/manifest.json && echo selftest_bare_manifest',
|
||||
'lib-bare-manifest'
|
||||
],
|
||||
['systemctl list-units 2>/dev/null || true', 'systemctl-list']
|
||||
]
|
||||
for (const [line, name] of specs) {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# /lib/bare (system image)
|
||||
|
||||
Self-contained **`ctx.bare` support** on the system Hyperdrive:
|
||||
|
||||
- **`bare-module-manifest.json`** — copy of the booter manifest (same keys and packages as host resolution).
|
||||
- **`manifest.json`** — drive loader index: `bundles` lists IIFE paths that assign into `globalThis.__bare_os_stdlib__`; `bundleStats` summarizes esbuild success vs stub-only placeholders.
|
||||
- **`bundles/*.js`** — one file per manifest row. Successful builds are full IIFE bundles; failures are no-op stubs (see file header). Regenerate with `npm run build -w bare-os-bare-libs`.
|
||||
|
||||
At boot the booter runs **drive bundles first**, then (unless **`BARE_OS_BARE_HOST_IMPORTS=0`**) fills any missing keys via host `import()`.
|
||||
|
||||
Trusted image only: executing these bundles is equivalent to running seeded `/bin` utilities.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,199 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function __require() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/b4a/index.js
|
||||
var require_b4a = __commonJS({
|
||||
"../../node_modules/b4a/index.js"(exports, module) {
|
||||
function isBuffer(value) {
|
||||
return Buffer.isBuffer(value) || value instanceof Uint8Array;
|
||||
}
|
||||
function isEncoding(encoding) {
|
||||
return Buffer.isEncoding(encoding);
|
||||
}
|
||||
function alloc(size, fill2, encoding) {
|
||||
return Buffer.alloc(size, fill2, encoding);
|
||||
}
|
||||
function allocUnsafe(size) {
|
||||
return Buffer.allocUnsafe(size);
|
||||
}
|
||||
function allocUnsafeSlow(size) {
|
||||
return Buffer.allocUnsafeSlow(size);
|
||||
}
|
||||
function byteLength(string, encoding) {
|
||||
return Buffer.byteLength(string, encoding);
|
||||
}
|
||||
function compare(a, b) {
|
||||
return Buffer.compare(a, b);
|
||||
}
|
||||
function concat(buffers, totalLength) {
|
||||
return Buffer.concat(buffers, totalLength);
|
||||
}
|
||||
function copy(source, target, targetStart, start, end) {
|
||||
return toBuffer(source).copy(target, targetStart, start, end);
|
||||
}
|
||||
function equals(a, b) {
|
||||
return toBuffer(a).equals(b);
|
||||
}
|
||||
function fill(buffer, value, offset, end, encoding) {
|
||||
return toBuffer(buffer).fill(value, offset, end, encoding);
|
||||
}
|
||||
function from(value, encodingOrOffset, length) {
|
||||
return Buffer.from(value, encodingOrOffset, length);
|
||||
}
|
||||
function includes(buffer, value, byteOffset, encoding) {
|
||||
return toBuffer(buffer).includes(value, byteOffset, encoding);
|
||||
}
|
||||
function indexOf(buffer, value, byfeOffset, encoding) {
|
||||
return toBuffer(buffer).indexOf(value, byfeOffset, encoding);
|
||||
}
|
||||
function lastIndexOf(buffer, value, byteOffset, encoding) {
|
||||
return toBuffer(buffer).lastIndexOf(value, byteOffset, encoding);
|
||||
}
|
||||
function swap16(buffer) {
|
||||
return toBuffer(buffer).swap16();
|
||||
}
|
||||
function swap32(buffer) {
|
||||
return toBuffer(buffer).swap32();
|
||||
}
|
||||
function swap64(buffer) {
|
||||
return toBuffer(buffer).swap64();
|
||||
}
|
||||
function toBuffer(buffer) {
|
||||
if (Buffer.isBuffer(buffer)) return buffer;
|
||||
return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
||||
}
|
||||
function toString(buffer, encoding, start, end) {
|
||||
return toBuffer(buffer).toString(encoding, start, end);
|
||||
}
|
||||
function write(buffer, string, offset, length, encoding) {
|
||||
return toBuffer(buffer).write(string, offset, length, encoding);
|
||||
}
|
||||
function readDoubleBE(buffer, offset) {
|
||||
return toBuffer(buffer).readDoubleBE(offset);
|
||||
}
|
||||
function readDoubleLE(buffer, offset) {
|
||||
return toBuffer(buffer).readDoubleLE(offset);
|
||||
}
|
||||
function readFloatBE(buffer, offset) {
|
||||
return toBuffer(buffer).readFloatBE(offset);
|
||||
}
|
||||
function readFloatLE(buffer, offset) {
|
||||
return toBuffer(buffer).readFloatLE(offset);
|
||||
}
|
||||
function readInt32BE(buffer, offset) {
|
||||
return toBuffer(buffer).readInt32BE(offset);
|
||||
}
|
||||
function readInt32LE(buffer, offset) {
|
||||
return toBuffer(buffer).readInt32LE(offset);
|
||||
}
|
||||
function readUInt32BE(buffer, offset) {
|
||||
return toBuffer(buffer).readUInt32BE(offset);
|
||||
}
|
||||
function readUInt32LE(buffer, offset) {
|
||||
return toBuffer(buffer).readUInt32LE(offset);
|
||||
}
|
||||
function writeDoubleBE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeDoubleBE(value, offset);
|
||||
}
|
||||
function writeDoubleLE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeDoubleLE(value, offset);
|
||||
}
|
||||
function writeFloatBE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeFloatBE(value, offset);
|
||||
}
|
||||
function writeFloatLE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeFloatLE(value, offset);
|
||||
}
|
||||
function writeInt32BE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeInt32BE(value, offset);
|
||||
}
|
||||
function writeInt32LE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeInt32LE(value, offset);
|
||||
}
|
||||
function writeUInt32BE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeUInt32BE(value, offset);
|
||||
}
|
||||
function writeUInt32LE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeUInt32LE(value, offset);
|
||||
}
|
||||
module.exports = {
|
||||
isBuffer,
|
||||
isEncoding,
|
||||
alloc,
|
||||
allocUnsafe,
|
||||
allocUnsafeSlow,
|
||||
byteLength,
|
||||
compare,
|
||||
concat,
|
||||
copy,
|
||||
equals,
|
||||
fill,
|
||||
from,
|
||||
includes,
|
||||
indexOf,
|
||||
lastIndexOf,
|
||||
swap16,
|
||||
swap32,
|
||||
swap64,
|
||||
toBuffer,
|
||||
toString,
|
||||
write,
|
||||
readDoubleBE,
|
||||
readDoubleLE,
|
||||
readFloatBE,
|
||||
readFloatLE,
|
||||
readInt32BE,
|
||||
readInt32LE,
|
||||
readUInt32BE,
|
||||
readUInt32LE,
|
||||
writeDoubleBE,
|
||||
writeDoubleLE,
|
||||
writeFloatBE,
|
||||
writeFloatLE,
|
||||
writeInt32BE,
|
||||
writeInt32LE,
|
||||
writeUInt32BE,
|
||||
writeUInt32LE
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-b4a.js
|
||||
var bare_lib_entry_b4a_exports = {};
|
||||
__export(bare_lib_entry_b4a_exports, {
|
||||
default: () => bare_lib_entry_b4a_default
|
||||
});
|
||||
var import_b4a = __toESM(require_b4a());
|
||||
var bare_lib_entry_b4a_default = import_b4a.default;
|
||||
return __toCommonJS(bare_lib_entry_b4a_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["b4a"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,63 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-abort/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-abort/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-abort/index.js
|
||||
var require_bare_abort = __commonJS({
|
||||
"../../node_modules/bare-abort/index.js"(exports, module) {
|
||||
var binding = require_binding();
|
||||
module.exports = binding.abort;
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareAbort.js
|
||||
var bare_lib_entry_bareAbort_exports = {};
|
||||
__export(bare_lib_entry_bareAbort_exports, {
|
||||
default: () => bare_lib_entry_bareAbort_default
|
||||
});
|
||||
var import_bare_abort = __toESM(require_bare_abort());
|
||||
var bare_lib_entry_bareAbort_default = import_bare_abort.default;
|
||||
return __toCommonJS(bare_lib_entry_bareAbort_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareAbort"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,429 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function __require() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-events/web.js
|
||||
var require_web = __commonJS({
|
||||
"../../node_modules/bare-events/web.js"(exports) {
|
||||
var BUBBLES = 1;
|
||||
var CANCELABLE = 2;
|
||||
var COMPOSED = 4;
|
||||
var CANCELED = 8;
|
||||
var DISPATCH = 16;
|
||||
var STOP = 32;
|
||||
var CAPTURE = 1;
|
||||
var PASSIVE = 2;
|
||||
var ONCE = 4;
|
||||
var Event = class _Event {
|
||||
// https://dom.spec.whatwg.org/#dom-event-event
|
||||
constructor(type, options = {}) {
|
||||
const { bubbles = false, cancelable = false, composed = false } = options;
|
||||
this._type = type;
|
||||
this._target = null;
|
||||
this._state = 0;
|
||||
if (bubbles) this._state |= BUBBLES;
|
||||
if (cancelable) this._state |= CANCELABLE;
|
||||
if (composed) this._state |= COMPOSED;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-event-type
|
||||
get type() {
|
||||
return this._type;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-event-target
|
||||
get target() {
|
||||
return this._target;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-event-currenttarget
|
||||
get currentTarget() {
|
||||
return null;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-event-bubbles
|
||||
get bubbles() {
|
||||
return (this._state & BUBBLES) !== 0;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-event-cancelable
|
||||
get cancelable() {
|
||||
return (this._state & CANCELABLE) !== 0;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-event-composed
|
||||
get composed() {
|
||||
return (this._state & COMPOSED) !== 0;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-event-defaultprevented
|
||||
get defaultPrevented() {
|
||||
return (this._state & CANCELED) !== 0;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-event-istrusted
|
||||
get isTrusted() {
|
||||
return false;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-event-preventdefault
|
||||
preventDefault() {
|
||||
if (this._state & CANCELABLE) this._state |= CANCELED;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-event-stoppropagation
|
||||
stopPropagation() {
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation
|
||||
stopImmediatePropagation() {
|
||||
this._state |= STOP;
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type,
|
||||
target: this.target,
|
||||
bubbles: this.bubbles,
|
||||
cancelable: this.cancelable,
|
||||
composed: this.composed,
|
||||
defaultPrevented: this.defaultPrevented,
|
||||
isTrusted: this.isTrusted
|
||||
};
|
||||
}
|
||||
[Symbol.for("bare.inspect")]() {
|
||||
return {
|
||||
__proto__: { constructor: _Event },
|
||||
type: this.type,
|
||||
target: this.target,
|
||||
bubbles: this.bubbles,
|
||||
cancelable: this.cancelable,
|
||||
composed: this.composed,
|
||||
defaultPrevented: this.defaultPrevented,
|
||||
isTrusted: this.isTrusted
|
||||
};
|
||||
}
|
||||
};
|
||||
exports.Event = Event;
|
||||
exports.CustomEvent = class CustomEvent extends Event {
|
||||
constructor(type, options = {}) {
|
||||
super(type, options);
|
||||
const { detail = null } = options;
|
||||
this._detail = detail;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-customevent-detail
|
||||
get detail() {
|
||||
return this._detail;
|
||||
}
|
||||
};
|
||||
exports.EventTarget = class EventTarget {
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-eventtarget
|
||||
constructor() {
|
||||
this._listeners = /* @__PURE__ */ new Map();
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener
|
||||
addEventListener(type, callback = null, options = {}) {
|
||||
if (typeof options === "boolean") options = { capture: options };
|
||||
const { capture = false, passive = false, once = false, signal = null } = options;
|
||||
if (signal !== null && signal.aborted) return;
|
||||
if (callback === null) return;
|
||||
const listener = new EventListener(type, callback, capture, passive, once, signal);
|
||||
const listeners = this._listeners.get(type);
|
||||
if (listeners === void 0) this._listeners.set(type, listener);
|
||||
else {
|
||||
for (const existing of listeners) {
|
||||
if (callback === existing.callback && capture === existing.capture) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
listener.link(listeners);
|
||||
if (signal !== null) {
|
||||
let onabort2 = function() {
|
||||
listener.unlink();
|
||||
};
|
||||
var onabort = onabort2;
|
||||
signal.addEventListener("abort", onabort2);
|
||||
}
|
||||
}
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
|
||||
removeEventListener(type, callback = null, options = {}) {
|
||||
if (typeof options === "boolean") options = { capture: options };
|
||||
const { capture = false } = options;
|
||||
const listeners = this._listeners.get(type);
|
||||
if (listeners === void 0) return;
|
||||
for (const existing of listeners) {
|
||||
if (callback === existing.callback && capture === existing.capture) {
|
||||
const next = existing.unlink();
|
||||
if (listeners === existing) this._listeners.set(type, next);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
|
||||
dispatchEvent(event) {
|
||||
event._target = this;
|
||||
event._state |= DISPATCH;
|
||||
const listeners = this._listeners.get(event.type);
|
||||
try {
|
||||
if (listeners === void 0) return true;
|
||||
for (const listener of listeners) {
|
||||
if (listener.once) listener.unlink();
|
||||
let callback = listener.callback;
|
||||
let context = this;
|
||||
if (typeof callback === "object") {
|
||||
context = callback;
|
||||
callback = callback.handleEvent;
|
||||
}
|
||||
Reflect.apply(callback, context, [event]);
|
||||
if (event._state & STOP) break;
|
||||
}
|
||||
return (event._state & CANCELED) === 0;
|
||||
} finally {
|
||||
event._state &= ~DISPATCH;
|
||||
event._state &= ~STOP;
|
||||
}
|
||||
}
|
||||
toJSON() {
|
||||
return {};
|
||||
}
|
||||
[Symbol.for("bare.inspect")]() {
|
||||
return {
|
||||
__proto__: { constructor: EventTarget }
|
||||
};
|
||||
}
|
||||
};
|
||||
var EventListener = class _EventListener {
|
||||
constructor(type, callback, capture, passive, once, signal) {
|
||||
this._type = type;
|
||||
this._callback = callback;
|
||||
this._signal = signal;
|
||||
this._state = 0;
|
||||
if (capture) this._state |= CAPTURE;
|
||||
if (passive) this._state |= PASSIVE;
|
||||
if (once) this._state |= ONCE;
|
||||
this._previous = this;
|
||||
this._next = this;
|
||||
}
|
||||
get type() {
|
||||
return this._type;
|
||||
}
|
||||
get callback() {
|
||||
return this._callback;
|
||||
}
|
||||
get capture() {
|
||||
return (this._state & CAPTURE) !== 0;
|
||||
}
|
||||
get passive() {
|
||||
return (this._state & PASSIVE) !== 0;
|
||||
}
|
||||
get once() {
|
||||
return (this._state & ONCE) !== 0;
|
||||
}
|
||||
get removed() {
|
||||
return this._previous === this && this._next === this;
|
||||
}
|
||||
link(listener) {
|
||||
const next = this._next;
|
||||
const previous = listener._previous;
|
||||
this._next = listener;
|
||||
listener._previous = this;
|
||||
previous._next = next;
|
||||
next._previous = previous;
|
||||
return listener;
|
||||
}
|
||||
unlink() {
|
||||
if (this.removed) return this;
|
||||
const next = this._next;
|
||||
const previous = this._previous;
|
||||
this._next = this;
|
||||
this._previous = this;
|
||||
previous._next = next;
|
||||
next._previous = previous;
|
||||
return next;
|
||||
}
|
||||
*[Symbol.iterator]() {
|
||||
let current = this;
|
||||
while (true) {
|
||||
const next = current._next;
|
||||
yield current;
|
||||
if (next === this) break;
|
||||
current = next;
|
||||
}
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type,
|
||||
capture: this.capture,
|
||||
passive: this.passive,
|
||||
once: this.once,
|
||||
removed: this.removed
|
||||
};
|
||||
}
|
||||
[Symbol.for("bare.inspect")]() {
|
||||
return {
|
||||
__proto__: { constructor: _EventListener },
|
||||
type: this.type,
|
||||
callback: this.callback,
|
||||
capture: this.capture,
|
||||
passive: this.passive,
|
||||
once: this.once,
|
||||
removed: this.removed
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-abort-controller/index.js
|
||||
var require_bare_abort_controller = __commonJS({
|
||||
"../../node_modules/bare-abort-controller/index.js"(exports, module) {
|
||||
var { Event, EventTarget } = require_web();
|
||||
var AbortError = class extends Error {
|
||||
get name() {
|
||||
return "AbortError";
|
||||
}
|
||||
};
|
||||
var TimeoutError = class extends Error {
|
||||
get name() {
|
||||
return "TimeoutError";
|
||||
}
|
||||
};
|
||||
var AbortSignal = class _AbortSignal extends EventTarget {
|
||||
constructor() {
|
||||
super();
|
||||
this._reason = void 0;
|
||||
this._dependent = false;
|
||||
this._sources = [];
|
||||
this._dependents = [];
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-abortsignal-aborted
|
||||
get aborted() {
|
||||
return this._reason !== void 0;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-abortsignal-reason
|
||||
get reason() {
|
||||
return this._reason;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#abortsignal-signal-abort
|
||||
_abort(reason = new AbortError("The operation was aborted")) {
|
||||
if (this.aborted) return;
|
||||
this._reason = reason;
|
||||
this.dispatchEvent(new Event("abort"));
|
||||
for (const signal of this._dependents) {
|
||||
signal._abort(reason);
|
||||
}
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-abortsignal-throwifaborted
|
||||
throwIfAborted() {
|
||||
if (this._reason !== void 0) throw this._reason;
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
aborted: this.aborted,
|
||||
reason: this.reason
|
||||
};
|
||||
}
|
||||
[Symbol.for("bare.inspect")]() {
|
||||
return {
|
||||
__proto__: { constructor: _AbortSignal },
|
||||
aborted: this.aborted,
|
||||
reason: this.reason
|
||||
};
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-abortsignal-abort
|
||||
static abort(reason) {
|
||||
const signal = new _AbortSignal();
|
||||
signal._reason = reason;
|
||||
return signal;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-abortsignal-timeout
|
||||
static timeout(ms) {
|
||||
const signal = new _AbortSignal();
|
||||
const timer = setTimeout(
|
||||
() => signal._abort(new TimeoutError("The operation timed out")),
|
||||
ms
|
||||
);
|
||||
timer.unref();
|
||||
return signal;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-abortsignal-any
|
||||
static any(signals) {
|
||||
const result = new _AbortSignal();
|
||||
for (const signal of signals) {
|
||||
if (signal.aborted) {
|
||||
result._reason = signal.reason;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
result._dependent = true;
|
||||
for (const signal of signals) {
|
||||
if (signal._dependent === false) {
|
||||
result._sources.push(signal);
|
||||
signal._dependents.push(result);
|
||||
} else {
|
||||
for (const source of signal._sources) {
|
||||
result._sources.push(source);
|
||||
source._dependents.push(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
var AbortController = class _AbortController {
|
||||
constructor() {
|
||||
this._signal = new AbortSignal();
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-abortcontroller-signal
|
||||
get signal() {
|
||||
return this._signal;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#dom-abortcontroller-abort
|
||||
abort(reason) {
|
||||
this._signal._abort(reason);
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
signal: this.signal
|
||||
};
|
||||
}
|
||||
[Symbol.for("bare.inspect")]() {
|
||||
return {
|
||||
__proto__: { constructor: _AbortController },
|
||||
signal: this.signal
|
||||
};
|
||||
}
|
||||
};
|
||||
module.exports = exports = AbortController;
|
||||
exports.AbortController = exports;
|
||||
exports.AbortSignal = AbortSignal;
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareAbortController.js
|
||||
var bare_lib_entry_bareAbortController_exports = {};
|
||||
__export(bare_lib_entry_bareAbortController_exports, {
|
||||
default: () => bare_lib_entry_bareAbortController_default
|
||||
});
|
||||
var import_bare_abort_controller = __toESM(require_bare_abort_controller());
|
||||
var bare_lib_entry_bareAbortController_default = import_bare_abort_controller.default;
|
||||
return __toCommonJS(bare_lib_entry_bareAbortController_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareAbortController"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,117 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function __require() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-ansi-escapes/index.js
|
||||
var require_bare_ansi_escapes = __commonJS({
|
||||
"../../node_modules/bare-ansi-escapes/index.js"(exports) {
|
||||
var ESC = "\x1B";
|
||||
var CSI = ESC + "[";
|
||||
var SGR = (n) => CSI + n + "m";
|
||||
exports.constants = {
|
||||
ESC,
|
||||
CSI,
|
||||
SGR
|
||||
};
|
||||
exports.cursorHide = CSI + "?25l";
|
||||
exports.cursorShow = CSI + "?25h";
|
||||
exports.cursorUp = function cursorUp(n = 1) {
|
||||
return CSI + n + "A";
|
||||
};
|
||||
exports.cursorDown = function cursorDown(n = 1) {
|
||||
return CSI + n + "B";
|
||||
};
|
||||
exports.cursorForward = function cursorForward(n = 1) {
|
||||
return CSI + n + "C";
|
||||
};
|
||||
exports.cursorBack = function cursorBack(n = 1) {
|
||||
return CSI + n + "D";
|
||||
};
|
||||
exports.cursorNextLine = function cursorNextLine(n = 1) {
|
||||
return CSI + n + "E";
|
||||
};
|
||||
exports.cursorPreviousLine = function cursorPreviousLine(n = 1) {
|
||||
return CSI + n + "F";
|
||||
};
|
||||
exports.cursorPosition = function cursorPosition(column, row = 0) {
|
||||
if (row === 0) return CSI + (column + 1) + "G";
|
||||
return CSI + (row + 1) + ";" + (column + 1) + "H";
|
||||
};
|
||||
exports.eraseDisplayEnd = CSI + "J";
|
||||
exports.eraseDisplayStart = CSI + "1J";
|
||||
exports.eraseDisplay = CSI + "2J";
|
||||
exports.eraseLineEnd = CSI + "K";
|
||||
exports.eraseLineStart = CSI + "1K";
|
||||
exports.eraseLine = CSI + "2K";
|
||||
exports.scrollUp = function scrollUp(n = 1) {
|
||||
return CSI + n + "S";
|
||||
};
|
||||
exports.scrollDown = function scrollDown(n = 1) {
|
||||
return CSI + n + "T";
|
||||
};
|
||||
exports.modifierReset = SGR(0);
|
||||
exports.modifierBold = SGR(1);
|
||||
exports.modifierDim = SGR(2);
|
||||
exports.modifierItalic = SGR(3);
|
||||
exports.modifierUnderline = SGR(4);
|
||||
exports.modifierNormal = SGR(22);
|
||||
exports.modifierNotItalic = SGR(23);
|
||||
exports.modifierNotUnderline = SGR(24);
|
||||
exports.colorBlack = SGR(30);
|
||||
exports.colorRed = SGR(31);
|
||||
exports.colorGreen = SGR(32);
|
||||
exports.colorYellow = SGR(33);
|
||||
exports.colorBlue = SGR(34);
|
||||
exports.colorMagenta = SGR(35);
|
||||
exports.colorCyan = SGR(36);
|
||||
exports.colorWhite = SGR(37);
|
||||
exports.colorDefault = SGR(39);
|
||||
exports.colorBrightBlack = SGR(90);
|
||||
exports.colorBrightRed = SGR(91);
|
||||
exports.colorBrightGreen = SGR(92);
|
||||
exports.colorBrightYellow = SGR(93);
|
||||
exports.colorBrightBlue = SGR(94);
|
||||
exports.colorBrightMagenta = SGR(95);
|
||||
exports.colorBrightCyan = SGR(96);
|
||||
exports.colorBrightWhite = SGR(97);
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareAnsiEscapes.js
|
||||
var bare_lib_entry_bareAnsiEscapes_exports = {};
|
||||
__export(bare_lib_entry_bareAnsiEscapes_exports, {
|
||||
default: () => bare_lib_entry_bareAnsiEscapes_default
|
||||
});
|
||||
var import_bare_ansi_escapes = __toESM(require_bare_ansi_escapes());
|
||||
var bare_lib_entry_bareAnsiEscapes_default = import_bare_ansi_escapes.default;
|
||||
return __toCommonJS(bare_lib_entry_bareAnsiEscapes_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareAnsiEscapes"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
/* bare-os-bare-libs: esbuild failed for bare-app-image — Build failed with 1 error:
|
||||
../../bare-lib-entry-bareAppImage.js:1:15: ERROR: Could not resolve "bare-app-image" */
|
||||
;(function(){})();
|
||||
@@ -0,0 +1,461 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-events/lib/errors.js
|
||||
var require_errors = __commonJS({
|
||||
"../../node_modules/bare-events/lib/errors.js"(exports, module) {
|
||||
module.exports = class EventEmitterError extends Error {
|
||||
constructor(msg, code, fn = EventEmitterError, opts) {
|
||||
super(`${code}: ${msg}`, opts);
|
||||
this.code = code;
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, fn);
|
||||
}
|
||||
}
|
||||
get name() {
|
||||
return "EventEmitterError";
|
||||
}
|
||||
static OPERATION_ABORTED(cause, msg = "Operation aborted") {
|
||||
return new EventEmitterError(msg, "OPERATION_ABORTED", EventEmitterError.OPERATION_ABORTED, {
|
||||
cause
|
||||
});
|
||||
}
|
||||
static UNHANDLED_ERROR(cause, msg = "Unhandled error") {
|
||||
return new EventEmitterError(msg, "UNHANDLED_ERROR", EventEmitterError.UNHANDLED_ERROR, {
|
||||
cause
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-events/index.js
|
||||
var require_bare_events = __commonJS({
|
||||
"../../node_modules/bare-events/index.js"(exports, module) {
|
||||
var errors = require_errors();
|
||||
var EventListener = class {
|
||||
constructor() {
|
||||
this.list = [];
|
||||
this.count = 0;
|
||||
}
|
||||
append(ctx, name, fn, once) {
|
||||
this.count++;
|
||||
ctx.emit("newListener", name, fn);
|
||||
this.list.push([fn, once]);
|
||||
}
|
||||
prepend(ctx, name, fn, once) {
|
||||
this.count++;
|
||||
ctx.emit("newListener", name, fn);
|
||||
this.list.unshift([fn, once]);
|
||||
}
|
||||
remove(ctx, name, fn) {
|
||||
for (let i = 0, n = this.list.length; i < n; i++) {
|
||||
const l = this.list[i];
|
||||
if (l[0] === fn) {
|
||||
this.list.splice(i, 1);
|
||||
if (this.count === 1) delete ctx._events[name];
|
||||
ctx.emit("removeListener", name, fn);
|
||||
this.count--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
removeAll(ctx, name) {
|
||||
const list = [...this.list];
|
||||
this.list = [];
|
||||
if (this.count === list.length) delete ctx._events[name];
|
||||
for (let i = list.length - 1; i >= 0; i--) {
|
||||
ctx.emit("removeListener", name, list[i][0]);
|
||||
}
|
||||
this.count -= list.length;
|
||||
}
|
||||
emit(ctx, name, ...args) {
|
||||
const list = [...this.list];
|
||||
for (let i = 0, n = list.length; i < n; i++) {
|
||||
const l = list[i];
|
||||
if (l[1] === true) this.remove(ctx, name, l[0]);
|
||||
Reflect.apply(l[0], ctx, args);
|
||||
}
|
||||
return list.length > 0;
|
||||
}
|
||||
};
|
||||
function appendListener(ctx, name, fn, once) {
|
||||
if (ctx._events === void 0) ctx._events = /* @__PURE__ */ Object.create(null);
|
||||
const e = ctx._events[name] || (ctx._events[name] = new EventListener());
|
||||
e.append(ctx, name, fn, once);
|
||||
return ctx;
|
||||
}
|
||||
function prependListener(ctx, name, fn, once) {
|
||||
if (ctx._events === void 0) ctx._events = /* @__PURE__ */ Object.create(null);
|
||||
const e = ctx._events[name] || (ctx._events[name] = new EventListener());
|
||||
e.prepend(ctx, name, fn, once);
|
||||
return ctx;
|
||||
}
|
||||
function removeListener(ctx, name, fn) {
|
||||
if (ctx._events === void 0) return ctx;
|
||||
const e = ctx._events[name];
|
||||
if (e !== void 0) e.remove(ctx, name, fn);
|
||||
return ctx;
|
||||
}
|
||||
function throwUnhandledError(...args) {
|
||||
let err;
|
||||
if (args.length > 0) err = args[0];
|
||||
if (err instanceof Error === false) err = errors.UNHANDLED_ERROR(err);
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(err, exports.prototype.emit);
|
||||
}
|
||||
queueMicrotask(() => {
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
module.exports = exports = class EventEmitter {
|
||||
constructor() {
|
||||
this._events = /* @__PURE__ */ Object.create(null);
|
||||
}
|
||||
addListener(name, fn) {
|
||||
return appendListener(this, name, fn, false);
|
||||
}
|
||||
addOnceListener(name, fn) {
|
||||
return appendListener(this, name, fn, true);
|
||||
}
|
||||
prependListener(name, fn) {
|
||||
return prependListener(this, name, fn, false);
|
||||
}
|
||||
prependOnceListener(name, fn) {
|
||||
return prependListener(this, name, fn, true);
|
||||
}
|
||||
removeListener(name, fn) {
|
||||
return removeListener(this, name, fn);
|
||||
}
|
||||
on(name, fn) {
|
||||
return appendListener(this, name, fn, false);
|
||||
}
|
||||
once(name, fn) {
|
||||
return appendListener(this, name, fn, true);
|
||||
}
|
||||
off(name, fn) {
|
||||
return removeListener(this, name, fn);
|
||||
}
|
||||
emit(name, ...args) {
|
||||
if (name === "error" && this._events !== void 0 && this._events.error === void 0) {
|
||||
throwUnhandledError(...args);
|
||||
}
|
||||
if (this._events === void 0) return false;
|
||||
const e = this._events[name];
|
||||
return e === void 0 ? false : e.emit(this, name, ...args);
|
||||
}
|
||||
listeners(name) {
|
||||
if (this._events === void 0) return [];
|
||||
const e = this._events[name];
|
||||
return e === void 0 ? [] : [...e.list];
|
||||
}
|
||||
listenerCount(name) {
|
||||
if (this._events === void 0) return 0;
|
||||
const e = this._events[name];
|
||||
return e === void 0 ? 0 : e.list.length;
|
||||
}
|
||||
getMaxListeners() {
|
||||
return EventEmitter.defaultMaxListeners;
|
||||
}
|
||||
setMaxListeners(n) {
|
||||
}
|
||||
removeAllListeners(name) {
|
||||
if (arguments.length === 0) {
|
||||
for (const key of Reflect.ownKeys(this._events)) {
|
||||
if (key === "removeListener") continue;
|
||||
this.removeAllListeners(key);
|
||||
}
|
||||
this.removeAllListeners("removeListener");
|
||||
} else {
|
||||
const e = this._events[name];
|
||||
if (e !== void 0) e.removeAll(this, name);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
};
|
||||
exports.EventEmitter = exports;
|
||||
exports.errors = errors;
|
||||
exports.defaultMaxListeners = 10;
|
||||
exports.on = function on(emitter, name, opts = {}) {
|
||||
const { signal } = opts;
|
||||
if (signal && signal.aborted) {
|
||||
throw errors.OPERATION_ABORTED(signal.reason);
|
||||
}
|
||||
let error = null;
|
||||
let done = false;
|
||||
const events = [];
|
||||
const promises = [];
|
||||
if (name !== "error") emitter.on("error", onerror);
|
||||
if (signal) signal.addEventListener("abort", onabort);
|
||||
emitter.on(name, onevent);
|
||||
return {
|
||||
next() {
|
||||
if (events.length) {
|
||||
return Promise.resolve({ value: events.shift(), done: false });
|
||||
}
|
||||
if (error) {
|
||||
const err = error;
|
||||
error = null;
|
||||
return Promise.reject(err);
|
||||
}
|
||||
if (done) return onclose();
|
||||
return new Promise((resolve, reject) => promises.push({ resolve, reject }));
|
||||
},
|
||||
return() {
|
||||
return onclose();
|
||||
},
|
||||
throw(err) {
|
||||
return onerror(err);
|
||||
},
|
||||
[Symbol.asyncIterator]() {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
function onevent(...args) {
|
||||
if (promises.length) {
|
||||
promises.shift().resolve({ value: args, done: false });
|
||||
} else {
|
||||
events.push(args);
|
||||
}
|
||||
}
|
||||
function onerror(err) {
|
||||
emitter.off(name, onevent).off("error", onerror);
|
||||
if (promises.length) {
|
||||
promises.shift().reject(err);
|
||||
} else {
|
||||
error = err;
|
||||
}
|
||||
return Promise.resolve({ done: true });
|
||||
}
|
||||
function onabort() {
|
||||
signal.removeEventListener("abort", onabort);
|
||||
onerror(errors.OPERATION_ABORTED(signal.reason));
|
||||
}
|
||||
function onclose() {
|
||||
emitter.off(name, onevent);
|
||||
if (name !== "error") emitter.off("error", onerror);
|
||||
if (signal) signal.removeEventListener("abort", onabort);
|
||||
done = true;
|
||||
if (promises.length) promises.shift().resolve({ done: true });
|
||||
return Promise.resolve({ done: true });
|
||||
}
|
||||
};
|
||||
exports.once = function once(emitter, name, opts = {}) {
|
||||
const { signal } = opts;
|
||||
if (signal && signal.aborted) {
|
||||
return Promise.reject(errors.OPERATION_ABORTED(signal.reason));
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
if (name !== "error") emitter.on("error", onerror);
|
||||
if (signal) signal.addEventListener("abort", onabort);
|
||||
emitter.once(name, onevent);
|
||||
function onevent(...args) {
|
||||
if (name !== "error") emitter.off("error", onerror);
|
||||
if (signal) signal.removeEventListener("abort", onabort);
|
||||
resolve(args);
|
||||
}
|
||||
function onerror(err) {
|
||||
emitter.off(name, onevent);
|
||||
if (name !== "error") emitter.off("error", onerror);
|
||||
reject(err);
|
||||
}
|
||||
function onabort() {
|
||||
signal.removeEventListener("abort", onabort);
|
||||
onerror(errors.OPERATION_ABORTED(signal.reason));
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.forward = function forward(from, to, names, opts = {}) {
|
||||
if (typeof names === "string") names = [names];
|
||||
const { emit = to.emit.bind(to) } = opts;
|
||||
const listeners = names.map(
|
||||
(name) => function onevent(...args) {
|
||||
emit(name, ...args);
|
||||
}
|
||||
);
|
||||
to.on("newListener", (name) => {
|
||||
const i = names.indexOf(name);
|
||||
if (i !== -1 && to.listenerCount(name) === 0) {
|
||||
from.on(name, listeners[i]);
|
||||
}
|
||||
}).on("removeListener", (name) => {
|
||||
const i = names.indexOf(name);
|
||||
if (i !== -1 && to.listenerCount(name) === 0) {
|
||||
from.off(name, listeners[i]);
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.listenerCount = function listenerCount(emitter, name) {
|
||||
return emitter.listenerCount(name);
|
||||
};
|
||||
exports.getMaxListeners = function getMaxListeners(emitter) {
|
||||
if (typeof emitter.getMaxListeners === "function") {
|
||||
return emitter.getMaxListeners();
|
||||
}
|
||||
return exports.defaultMaxListeners;
|
||||
};
|
||||
exports.setMaxListeners = function setMaxListeners(n, ...emitters) {
|
||||
if (emitters.length === 0) exports.defaultMaxListeners = n;
|
||||
else {
|
||||
for (const emitter of emitters) {
|
||||
if (typeof emitter.setMaxListeners === "function") {
|
||||
emitter.setMaxListeners(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-app-kit/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-app-kit/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-app-kit/lib/view.js
|
||||
var require_view = __commonJS({
|
||||
"../../node_modules/bare-app-kit/lib/view.js"(exports, module) {
|
||||
module.exports = class AppKitView {
|
||||
constructor(handle) {
|
||||
this._handle = handle;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-app-kit/lib/window.js
|
||||
var require_window = __commonJS({
|
||||
"../../node_modules/bare-app-kit/lib/window.js"(exports, module) {
|
||||
var EventEmitter = require_bare_events();
|
||||
var binding = require_binding();
|
||||
var View = require_view();
|
||||
module.exports = exports = class AppKitWindow extends EventEmitter {
|
||||
constructor(opts = {}) {
|
||||
super();
|
||||
const { x = 0, y = 0, width = 0, height = 0, styleMask = 0, defer = false } = opts;
|
||||
this._handle = binding.windowInit(
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
styleMask,
|
||||
defer,
|
||||
this,
|
||||
this._ondidresize,
|
||||
this._ondidmove,
|
||||
this._onwillclose
|
||||
);
|
||||
}
|
||||
get contentView() {
|
||||
return new View(binding.windowContentView(this._handle));
|
||||
}
|
||||
set contentView(view) {
|
||||
binding.windowContentView(this._handle, view._handle);
|
||||
}
|
||||
get titlebarAppearsTransparent() {
|
||||
return binding.windowTitlebarAppearsTransparent(this._handle);
|
||||
}
|
||||
set titlebarAppearsTransparent(value) {
|
||||
binding.windowTitlebarAppearsTransparent(this._handle, value);
|
||||
}
|
||||
center() {
|
||||
binding.windowCenter(this._handle);
|
||||
return this;
|
||||
}
|
||||
close() {
|
||||
binding.windowClose(this._handle);
|
||||
return this;
|
||||
}
|
||||
makeKeyWindow() {
|
||||
binding.windowMakeKeyWindow(this._handle);
|
||||
return this;
|
||||
}
|
||||
orderBack() {
|
||||
binding.windowOrderBack(this._handle);
|
||||
return this;
|
||||
}
|
||||
orderFront() {
|
||||
binding.windowOrderFront(this._handle);
|
||||
return this;
|
||||
}
|
||||
[Symbol.for("bare.inspect")]() {
|
||||
return {
|
||||
__proto__: { constructor: AppKitWindow }
|
||||
};
|
||||
}
|
||||
_ondidresize() {
|
||||
this.emit("did-resize");
|
||||
}
|
||||
_ondidmove() {
|
||||
this.emit("did-move");
|
||||
}
|
||||
_onwillclose() {
|
||||
this.emit("will-close");
|
||||
}
|
||||
};
|
||||
exports.STYLE_MASK = {
|
||||
BORDERLESS: binding.WINDOW_STYLE_MASK_BORDERLESS,
|
||||
TITLED: binding.WINDOW_STYLE_MASK_TITLED,
|
||||
CLOSABLE: binding.WINDOW_STYLE_MASK_CLOSABLE,
|
||||
MINIATURIZABLE: binding.WINDOW_STYLE_MASK_MINIATURIZABLE,
|
||||
RESIZABLE: binding.WINDOW_STYLE_MASK_RESIZABLE,
|
||||
FULL_SCREEN: binding.WINDOW_STYLE_MASK_FULL_SCREEN,
|
||||
FULL_SIZE_CONTENT_VIEW: binding.WINDOW_STYLE_MASK_FULL_SIZE_CONTENT_VIEW
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-app-kit/index.js
|
||||
var require_bare_app_kit = __commonJS({
|
||||
"../../node_modules/bare-app-kit/index.js"(exports) {
|
||||
exports.Window = require_window();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareAppKit.js
|
||||
var bare_lib_entry_bareAppKit_exports = {};
|
||||
__export(bare_lib_entry_bareAppKit_exports, {
|
||||
default: () => bare_lib_entry_bareAppKit_default
|
||||
});
|
||||
var import_bare_app_kit = __toESM(require_bare_app_kit());
|
||||
var bare_lib_entry_bareAppKit_default = import_bare_app_kit.default;
|
||||
return __toCommonJS(bare_lib_entry_bareAppKit_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareAppKit"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,85 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function __require() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-async-hooks/index.js
|
||||
var require_bare_async_hooks = __commonJS({
|
||||
"../../node_modules/bare-async-hooks/index.js"(exports) {
|
||||
var AsyncHook = class {
|
||||
enable() {
|
||||
}
|
||||
disable() {
|
||||
}
|
||||
};
|
||||
exports.AsyncHook = AsyncHook;
|
||||
exports.createHook = function createHook(opts) {
|
||||
return new AsyncHook(opts);
|
||||
};
|
||||
exports.executionAsyncId = function executionAsyncId() {
|
||||
return -1;
|
||||
};
|
||||
exports.triggerAsyncId = function triggerAsyncId() {
|
||||
return -1;
|
||||
};
|
||||
var AsyncResource = class {
|
||||
bind() {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
static bind() {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
runInAsyncScope() {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
emitDestroy() {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
asyncId() {
|
||||
return -1;
|
||||
}
|
||||
triggerAsyncId() {
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
exports.AsyncResource = AsyncResource;
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareAsyncHooks.js
|
||||
var bare_lib_entry_bareAsyncHooks_exports = {};
|
||||
__export(bare_lib_entry_bareAsyncHooks_exports, {
|
||||
default: () => bare_lib_entry_bareAsyncHooks_default
|
||||
});
|
||||
var import_bare_async_hooks = __toESM(require_bare_async_hooks());
|
||||
var bare_lib_entry_bareAsyncHooks_default = import_bare_async_hooks.default;
|
||||
return __toCommonJS(bare_lib_entry_bareAsyncHooks_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareAsyncHooks"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,159 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-atomics/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-atomics/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-atomics/index.js
|
||||
var require_bare_atomics = __commonJS({
|
||||
"../../node_modules/bare-atomics/index.js"(exports) {
|
||||
var binding = require_binding();
|
||||
exports.Mutex = class Mutex {
|
||||
constructor(opts = {}) {
|
||||
const { recursive = false, handle = binding.mutexInit(recursive) } = opts;
|
||||
this.handle = handle;
|
||||
this.recursive = recursive;
|
||||
this.held = false;
|
||||
}
|
||||
lock() {
|
||||
if (this.held && !this.recursive)
|
||||
throw new Error("cannot relock already held mutex");
|
||||
binding.mutexLock(this.handle);
|
||||
this.held = true;
|
||||
}
|
||||
tryLock() {
|
||||
if (this.held && !this.recursive)
|
||||
throw new Error("cannot relock already held mutex");
|
||||
return binding.mutexTryLock(this.handle);
|
||||
}
|
||||
unlock() {
|
||||
if (!this.held) throw new Error("cannot unlock unheld mutex");
|
||||
binding.mutexUnlock(this.handle);
|
||||
this.held = false;
|
||||
}
|
||||
destroy() {
|
||||
if (this.held) throw new Error("cannot destroy held mutex");
|
||||
binding.mutexDestroy(this.handle);
|
||||
}
|
||||
static from(handle, opts = {}) {
|
||||
return new Mutex({ ...opts, handle });
|
||||
}
|
||||
};
|
||||
exports.Semaphore = class Semaphore {
|
||||
constructor(value, opts = {}) {
|
||||
if (typeof value === "object") {
|
||||
opts = value;
|
||||
value = 0;
|
||||
}
|
||||
const { handle = binding.semaphoreInit(value) } = opts;
|
||||
this.handle = handle;
|
||||
}
|
||||
wait() {
|
||||
binding.semaphoreWait(this.handle);
|
||||
}
|
||||
tryWait() {
|
||||
return binding.semaphoreTryWait(this.handle);
|
||||
}
|
||||
post() {
|
||||
binding.semaphorePost(this.handle);
|
||||
}
|
||||
destroy() {
|
||||
binding.semaphoreDestroy(this.handle);
|
||||
}
|
||||
static from(handle, opts = {}) {
|
||||
return new Semaphore({ ...opts, handle });
|
||||
}
|
||||
};
|
||||
exports.Condition = class Condition {
|
||||
constructor(opts = {}) {
|
||||
const { handle = binding.conditionInit() } = opts;
|
||||
this.handle = handle;
|
||||
}
|
||||
wait(mutex, timeout = -1) {
|
||||
if (!mutex.held) throw new Error("cannot wait with unheld mutex");
|
||||
return binding.conditionWait(this.handle, mutex.handle, timeout);
|
||||
}
|
||||
signal() {
|
||||
binding.conditionSignal(this.handle);
|
||||
}
|
||||
broadcast() {
|
||||
binding.conditionBroadcast(this.handle);
|
||||
}
|
||||
destroy() {
|
||||
binding.conditionDestroy(this.handle);
|
||||
}
|
||||
static from(handle, opts = {}) {
|
||||
return new Condition({ ...opts, handle });
|
||||
}
|
||||
};
|
||||
exports.Barrier = class Barrier {
|
||||
constructor(count, opts = {}) {
|
||||
if (typeof count === "object") {
|
||||
opts = count;
|
||||
count = 0;
|
||||
}
|
||||
const { handle = binding.barrierInit(count) } = opts;
|
||||
this.handle = handle;
|
||||
}
|
||||
wait() {
|
||||
return binding.barrierWait(this.handle);
|
||||
}
|
||||
destroy() {
|
||||
binding.barrierDestroy(this.handle);
|
||||
}
|
||||
static from(handle, opts = {}) {
|
||||
return new Barrier({ ...opts, handle });
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareAtomics.js
|
||||
var bare_lib_entry_bareAtomics_exports = {};
|
||||
__export(bare_lib_entry_bareAtomics_exports, {
|
||||
default: () => bare_lib_entry_bareAtomics_default
|
||||
});
|
||||
var import_bare_atomics = __toESM(require_bare_atomics());
|
||||
var bare_lib_entry_bareAtomics_default = import_bare_atomics.default;
|
||||
return __toCommonJS(bare_lib_entry_bareAtomics_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareAtomics"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,77 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-bmp/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-bmp/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-bmp/index.js
|
||||
var require_bare_bmp = __commonJS({
|
||||
"../../node_modules/bare-bmp/index.js"(exports) {
|
||||
var binding = require_binding();
|
||||
exports.decode = function decode(buffer) {
|
||||
const { width, height, data } = binding.decode(buffer);
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
data: Buffer.from(data)
|
||||
};
|
||||
};
|
||||
exports.encode = function encode(image, opts = {}) {
|
||||
const buffer = binding.encode(image, opts);
|
||||
return Buffer.from(buffer);
|
||||
};
|
||||
exports.encodeAnimated = function encodeAnimated() {
|
||||
return binding.encodeAnimated();
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareBmp.js
|
||||
var bare_lib_entry_bareBmp_exports = {};
|
||||
__export(bare_lib_entry_bareBmp_exports, {
|
||||
default: () => bare_lib_entry_bareBmp_default
|
||||
});
|
||||
var import_bare_bmp = __toESM(require_bare_bmp());
|
||||
var bare_lib_entry_bareBmp_default = import_bare_bmp.default;
|
||||
return __toCommonJS(bare_lib_entry_bareBmp_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareBmp"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
/* bare-os-bare-libs: esbuild failed for bare-build — Build failed with 1 error:
|
||||
../../node_modules/bare-build/lib/platform/linux/create-app-image.js:5:37: ERROR: Could not resolve "bare-app-image" */
|
||||
;(function(){})();
|
||||
@@ -0,0 +1,480 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function __require() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-bundle/lib/errors.js
|
||||
var require_errors = __commonJS({
|
||||
"../../node_modules/bare-bundle/lib/errors.js"(exports, module) {
|
||||
module.exports = class BundleError extends Error {
|
||||
constructor(msg, fn = BundleError, opts = {}) {
|
||||
const { cause, code = fn.name } = opts;
|
||||
super(`${code}: ${msg}`, { cause });
|
||||
this.code = code;
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, fn);
|
||||
}
|
||||
}
|
||||
get name() {
|
||||
return "BundleError";
|
||||
}
|
||||
static INVALID_BUNDLE_HEADER(msg, cause) {
|
||||
return new BundleError(msg, BundleError.INVALID_BUNDLE_HEADER, { cause });
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-bundle/index.js
|
||||
var require_bare_bundle = __commonJS({
|
||||
"../../node_modules/bare-bundle/index.js"(exports, module) {
|
||||
var errors = require_errors();
|
||||
var kind = Symbol.for("bare.bundle.kind");
|
||||
var MemoryFile = class _MemoryFile {
|
||||
constructor(data, opts = {}) {
|
||||
const { executable = false, mode = executable ? 493 : 420 } = opts;
|
||||
this._data = typeof data === "string" ? Buffer.from(data) : data;
|
||||
this._mode = mode;
|
||||
}
|
||||
size() {
|
||||
return this._data.byteLength;
|
||||
}
|
||||
mode() {
|
||||
return this._mode;
|
||||
}
|
||||
read() {
|
||||
return this._data;
|
||||
}
|
||||
inspect() {
|
||||
return {
|
||||
__proto__: { constructor: _MemoryFile },
|
||||
data: this._data,
|
||||
mode: this._mode.toString(8)
|
||||
};
|
||||
}
|
||||
[Symbol.for("bare.inspect")]() {
|
||||
return this.inspect();
|
||||
}
|
||||
[Symbol.for("nodejs.util.inspect.custom")]() {
|
||||
return this.inspect();
|
||||
}
|
||||
};
|
||||
module.exports = exports = class Bundle2 {
|
||||
static get [kind]() {
|
||||
return 0;
|
||||
}
|
||||
static get version() {
|
||||
return 0;
|
||||
}
|
||||
constructor(opts = {}) {
|
||||
const { File = MemoryFile } = opts;
|
||||
this._File = File;
|
||||
this._id = null;
|
||||
this._main = null;
|
||||
this._imports = {};
|
||||
this._resolutions = {};
|
||||
this._addons = [];
|
||||
this._assets = [];
|
||||
this._files = /* @__PURE__ */ new Map();
|
||||
}
|
||||
get [kind]() {
|
||||
return Bundle2[kind];
|
||||
}
|
||||
get version() {
|
||||
return Bundle2.version;
|
||||
}
|
||||
get id() {
|
||||
return this._id;
|
||||
}
|
||||
set id(value) {
|
||||
if (typeof value !== "string" && value !== null) {
|
||||
throw new TypeError(`ID must be a string or null. Received type ${typeof value} (${value})`);
|
||||
}
|
||||
this._id = value;
|
||||
}
|
||||
get main() {
|
||||
return this._main;
|
||||
}
|
||||
set main(value) {
|
||||
if (typeof value !== "string" && value !== null) {
|
||||
throw new TypeError(`Main must be a string or null. Received type ${typeof value} (${value})`);
|
||||
}
|
||||
this._main = value;
|
||||
}
|
||||
get imports() {
|
||||
return this._imports;
|
||||
}
|
||||
set imports(value) {
|
||||
this._imports = cloneImportsMap(value);
|
||||
}
|
||||
get resolutions() {
|
||||
return this._resolutions;
|
||||
}
|
||||
set resolutions(value) {
|
||||
this._resolutions = cloneResolutionsMap(value);
|
||||
}
|
||||
get addons() {
|
||||
return this._addons;
|
||||
}
|
||||
set addons(value) {
|
||||
this._addons = cloneFilesList(value, "Addons");
|
||||
}
|
||||
get assets() {
|
||||
return this._assets;
|
||||
}
|
||||
set assets(value) {
|
||||
this._assets = cloneFilesList(value, "Assets");
|
||||
}
|
||||
get files() {
|
||||
return Object.fromEntries(this._files.entries());
|
||||
}
|
||||
*[Symbol.iterator]() {
|
||||
for (const [key, file] of this._files) {
|
||||
yield [key, file.read(), file.mode()];
|
||||
}
|
||||
}
|
||||
empty() {
|
||||
return this._files.size === 0;
|
||||
}
|
||||
keys() {
|
||||
return this._files.keys();
|
||||
}
|
||||
exists(key) {
|
||||
return this._files.has(key);
|
||||
}
|
||||
size(key) {
|
||||
const file = this._files.get(key) || null;
|
||||
if (file === null) return 0;
|
||||
return file.size();
|
||||
}
|
||||
mode(key) {
|
||||
const file = this._files.get(key) || null;
|
||||
if (file === null) return 0;
|
||||
return file.mode();
|
||||
}
|
||||
read(key) {
|
||||
const file = this._files.get(key) || null;
|
||||
if (file === null) return null;
|
||||
return file.read();
|
||||
}
|
||||
write(key, data, opts = {}) {
|
||||
if (typeof key !== "string") {
|
||||
throw new TypeError(`File path must be a string. Received type ${typeof key} (${key})`);
|
||||
}
|
||||
const { main = false, alias = null, imports = null, addon = false, asset = false } = opts;
|
||||
this._files.set(key, new MemoryFile(data, opts));
|
||||
if (main) this._main = key;
|
||||
if (alias) this._imports[alias] = key;
|
||||
if (imports) this._resolutions[key] = cloneImportsMap(imports);
|
||||
if (addon) this._addons.push(key);
|
||||
if (asset) this._assets.push(key);
|
||||
return this;
|
||||
}
|
||||
mount(root, opts = {}) {
|
||||
const bundle = new Bundle2();
|
||||
bundle._File = this._File;
|
||||
bundle._id = this._id;
|
||||
if (this._main) bundle._main = mountSpecifier(this._main, root);
|
||||
bundle._imports = transformImportsMap(this._imports, root, null, opts, mountSpecifier);
|
||||
bundle._resolutions = transformResolutionsMap(this._resolutions, root, opts, mountSpecifier);
|
||||
for (const [key, file] of this._files) {
|
||||
bundle._files.set(mountSpecifier(key, root), file);
|
||||
}
|
||||
bundle._addons = transformFilesList(this._addons, root, mountSpecifier);
|
||||
bundle._assets = transformFilesList(this._assets, root, mountSpecifier);
|
||||
return bundle;
|
||||
}
|
||||
unmount(root, opts = {}) {
|
||||
const bundle = new Bundle2();
|
||||
bundle._File = this._File;
|
||||
bundle._id = this._id;
|
||||
if (this._main) bundle._main = unmountSpecifier(this._main, root);
|
||||
bundle._imports = transformImportsMap(this._imports, root, null, opts, unmountSpecifier);
|
||||
bundle._resolutions = transformResolutionsMap(this._resolutions, root, opts, unmountSpecifier);
|
||||
for (const [key, file] of this._files) {
|
||||
bundle._files.set(unmountSpecifier(key, root), file);
|
||||
}
|
||||
bundle._addons = transformFilesList(this._addons, root, unmountSpecifier);
|
||||
bundle._assets = transformFilesList(this._assets, root, unmountSpecifier);
|
||||
return bundle;
|
||||
}
|
||||
toBuffer(opts = {}) {
|
||||
const { indent = 0, shared = false } = opts;
|
||||
const header = {
|
||||
version: Bundle2.version,
|
||||
id: this._id,
|
||||
main: this._main,
|
||||
imports: cloneImportsMap(this._imports),
|
||||
resolutions: cloneResolutionsMap(this._resolutions),
|
||||
addons: cloneFilesList(this._addons, "Addons"),
|
||||
assets: cloneFilesList(this._assets, "Assets"),
|
||||
files: {}
|
||||
};
|
||||
const keys = [...this._files.keys()].sort();
|
||||
let offset = 0;
|
||||
for (const key of keys) {
|
||||
const length2 = this.size(key);
|
||||
header.files[key] = { offset, length: length2, mode: this.mode(key) };
|
||||
offset += length2;
|
||||
}
|
||||
const json = Buffer.from(`
|
||||
${JSON.stringify(header, null, indent)}
|
||||
`);
|
||||
const length = Buffer.from(json.byteLength.toString(10));
|
||||
const total = length.byteLength + json.byteLength + offset;
|
||||
const storage = shared ? new SharedArrayBuffer(total) : new ArrayBuffer(total);
|
||||
const buffer = Buffer.from(storage);
|
||||
offset = 0;
|
||||
buffer.set(length, offset);
|
||||
offset += length.byteLength;
|
||||
buffer.set(json, offset);
|
||||
offset += json.byteLength;
|
||||
for (const key of keys) {
|
||||
buffer.set(this.read(key), offset);
|
||||
offset += this.size(key);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
inspect() {
|
||||
return {
|
||||
__proto__: { constructor: Bundle2 },
|
||||
version: this.version,
|
||||
id: this.id,
|
||||
main: this.main,
|
||||
imports: this.imports,
|
||||
resolutions: this.resolutions,
|
||||
addons: this.addons,
|
||||
assets: this.assets,
|
||||
files: this.files
|
||||
};
|
||||
}
|
||||
[Symbol.for("bare.inspect")]() {
|
||||
return this.inspect();
|
||||
}
|
||||
[Symbol.for("nodejs.util.inspect.custom")]() {
|
||||
return this.inspect();
|
||||
}
|
||||
};
|
||||
var Bundle = exports;
|
||||
exports.errors = errors;
|
||||
exports.isBundle = function isBundle(value) {
|
||||
if (value instanceof Bundle) return true;
|
||||
return typeof value === "object" && value !== null && value[kind] === Bundle[kind];
|
||||
};
|
||||
exports.from = function from(value) {
|
||||
if (typeof value === "string") return fromString(value);
|
||||
if (Buffer.isBuffer(value)) return fromBuffer(value);
|
||||
return value;
|
||||
};
|
||||
function fromString(string) {
|
||||
return fromBuffer(Buffer.from(string));
|
||||
}
|
||||
function fromBuffer(buffer) {
|
||||
if (buffer[0] === 35 && buffer[1] === 33) {
|
||||
let end2 = 2;
|
||||
while (buffer[end2] !== 10) end2++;
|
||||
buffer = buffer.subarray(end2 + 1);
|
||||
}
|
||||
let end = 0;
|
||||
while (isDecimal(buffer[end])) end++;
|
||||
const len = parseInt(buffer.toString("utf8", 0, end), 10);
|
||||
let header;
|
||||
try {
|
||||
header = JSON.parse(buffer.toString("utf8", end, end + len));
|
||||
} catch (err) {
|
||||
throw errors.INVALID_BUNDLE_HEADER("Invalid bundle header", err);
|
||||
}
|
||||
const bundle = new Bundle();
|
||||
if (header.id) bundle.id = header.id;
|
||||
if (header.main) bundle.main = header.main;
|
||||
if (header.imports) bundle.imports = header.imports;
|
||||
if (header.resolutions) bundle.resolutions = header.resolutions;
|
||||
if (header.addons) bundle.addons = header.addons;
|
||||
if (header.assets) bundle.assets = header.assets;
|
||||
let offset = end + len;
|
||||
for (const [file, info] of Object.entries(header.files)) {
|
||||
bundle.write(file, buffer.subarray(offset, offset + info.length), {
|
||||
mode: info.mode || 420
|
||||
});
|
||||
offset += info.length;
|
||||
}
|
||||
return bundle;
|
||||
}
|
||||
function isDecimal(c) {
|
||||
return c >= 48 && c <= 57;
|
||||
}
|
||||
function compareKeys([a], [b]) {
|
||||
return a > b ? 1 : a < b ? -1 : 0;
|
||||
}
|
||||
function cloneImportsMap(value) {
|
||||
if (typeof value === "object" && value !== null) {
|
||||
const imports = {};
|
||||
for (const entry of Object.entries(value).sort(compareKeys)) {
|
||||
imports[entry[0]] = cloneImportsMapEntry(entry[1]);
|
||||
}
|
||||
return imports;
|
||||
}
|
||||
throw new TypeError(`Imports map must be an object. Received type ${typeof value} (${value})`);
|
||||
}
|
||||
function cloneImportsMapEntry(value) {
|
||||
if (typeof value === "string") return value;
|
||||
if (typeof value === "object" && value !== null) {
|
||||
const imports = {};
|
||||
for (const entry of Object.entries(value)) {
|
||||
imports[entry[0]] = cloneImportsMapEntry(entry[1]);
|
||||
}
|
||||
return imports;
|
||||
}
|
||||
throw new TypeError(
|
||||
`Imports map entry must be a string or object. Received type ${typeof value} (${value})`
|
||||
);
|
||||
}
|
||||
function cloneResolutionsMap(value) {
|
||||
if (typeof value === "object" && value !== null) {
|
||||
const resolutions = {};
|
||||
for (const entry of Object.entries(value).sort(compareKeys)) {
|
||||
resolutions[entry[0]] = cloneImportsMap(entry[1]);
|
||||
}
|
||||
return resolutions;
|
||||
}
|
||||
throw new TypeError(`Resolutions map must be an object. Received type ${typeof value} (${value})`);
|
||||
}
|
||||
function cloneFilesList(value, name) {
|
||||
if (Array.isArray(value)) {
|
||||
const files = [];
|
||||
for (const entry of value) {
|
||||
if (typeof entry !== "string") {
|
||||
throw new TypeError(
|
||||
`${name} entry must be a string. Received type ${typeof entry} (${entry})`
|
||||
);
|
||||
}
|
||||
files.push(entry);
|
||||
}
|
||||
return files.sort();
|
||||
}
|
||||
throw new TypeError(`${name} list must be an array. Received type ${typeof value} (${value})`);
|
||||
}
|
||||
function transformImportsMap(value, root, conditionalRoot, opts, fn) {
|
||||
const { conditions = {} } = opts;
|
||||
const imports = {};
|
||||
for (const entry of Object.entries(value)) {
|
||||
const condition = entry[0];
|
||||
imports[condition] = transformImportsMapEntry(
|
||||
entry[1],
|
||||
root,
|
||||
conditionalRoot || conditions[condition],
|
||||
opts,
|
||||
fn
|
||||
);
|
||||
}
|
||||
return imports;
|
||||
}
|
||||
function transformImportsMapEntry(value, root, conditionalRoot, opts, fn) {
|
||||
const { conditions = {} } = opts;
|
||||
if (typeof value === "string") {
|
||||
return fn(value, conditionalRoot || conditions.default || root);
|
||||
}
|
||||
return transformImportsMap(value, root, conditionalRoot, opts, fn);
|
||||
}
|
||||
function transformResolutionsMap(value, root, opts, fn) {
|
||||
const resolutions = {};
|
||||
for (const entry of Object.entries(value)) {
|
||||
resolutions[fn(entry[0], root)] = transformImportsMap(entry[1], root, null, opts, fn);
|
||||
}
|
||||
return resolutions;
|
||||
}
|
||||
function transformFilesList(value, root, fn) {
|
||||
const files = [];
|
||||
for (const entry of value) {
|
||||
files.push(fn(entry, root));
|
||||
}
|
||||
return files;
|
||||
}
|
||||
function mountSpecifier(specifier, root) {
|
||||
if (startsWithWindowsDriveLetter(specifier)) {
|
||||
specifier = "/" + specifier;
|
||||
}
|
||||
if (specifier[0] === "/" || specifier[0] === "\\") {
|
||||
specifier = "." + specifier;
|
||||
}
|
||||
if (specifier.startsWith("./") || specifier.startsWith(".\\")) {
|
||||
return new URL(specifier, root).href;
|
||||
}
|
||||
return specifier;
|
||||
}
|
||||
function unmountSpecifier(specifier, root) {
|
||||
specifier = new URL(specifier);
|
||||
if (typeof root === "string") root = new URL(root);
|
||||
if (specifier.protocol !== root.protocol || specifier.host !== root.host || specifier.port !== root.port) {
|
||||
return specifier.href;
|
||||
}
|
||||
const specifierPath = splitPath(specifier.pathname);
|
||||
const rootPath = splitPath(root.pathname);
|
||||
while (specifierPath.length > 0 && rootPath[0] === specifierPath[0]) {
|
||||
specifierPath.shift();
|
||||
rootPath.shift();
|
||||
}
|
||||
rootPath.fill("..");
|
||||
return "/" + rootPath.concat(specifierPath).join("/");
|
||||
}
|
||||
function splitPath(path) {
|
||||
const parts = path.split("/");
|
||||
if (!parts[0]) parts.shift();
|
||||
if (!parts[parts.length - 1]) parts.pop();
|
||||
return parts;
|
||||
}
|
||||
function isASCIIUpperAlpha(c) {
|
||||
return c >= 65 && c <= 90;
|
||||
}
|
||||
function isASCIILowerAlpha(c) {
|
||||
return c >= 97 && c <= 122;
|
||||
}
|
||||
function isASCIIAlpha(c) {
|
||||
return isASCIIUpperAlpha(c) || isASCIILowerAlpha(c);
|
||||
}
|
||||
function isWindowsDriveLetter(input) {
|
||||
return input.length >= 2 && isASCIIAlpha(input.charCodeAt(0)) && (input.charCodeAt(1) === 58 || input.charCodeAt(1) === 124);
|
||||
}
|
||||
function startsWithWindowsDriveLetter(input) {
|
||||
return input.length >= 2 && isWindowsDriveLetter(input) && (input.length === 2 || input.charCodeAt(2) === 47 || input.charCodeAt(2) === 92 || input.charCodeAt(2) === 63 || input.charCodeAt(2) === 35);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareBundle.js
|
||||
var bare_lib_entry_bareBundle_exports = {};
|
||||
__export(bare_lib_entry_bareBundle_exports, {
|
||||
default: () => bare_lib_entry_bareBundle_default
|
||||
});
|
||||
var import_bare_bundle = __toESM(require_bare_bundle());
|
||||
var bare_lib_entry_bareBundle_default = import_bare_bundle.default;
|
||||
return __toCommonJS(bare_lib_entry_bareBundle_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareBundle"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,181 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function __require() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-bundle-compile/index.js
|
||||
var require_bare_bundle_compile = __commonJS({
|
||||
"../../node_modules/bare-bundle-compile/index.js"(exports, module) {
|
||||
module.exports = function compile(bundle) {
|
||||
return `{
|
||||
const __bundle = {
|
||||
imports: ${JSON.stringify(bundle.imports)},
|
||||
resolutions: ${JSON.stringify(bundle.resolutions)},
|
||||
modules: {${[...bundle].map(
|
||||
([key, source]) => `${JSON.stringify(key)}: (require, module, exports, __filename, __dirname, __bundle) => {${compileModule(
|
||||
key,
|
||||
source
|
||||
)}}`
|
||||
)}
|
||||
},
|
||||
builtinRequire: typeof require === 'function' ? require : null,
|
||||
load(cache, url, referrer = null, attributes = null) {
|
||||
const type = url.endsWith('.json')
|
||||
? 'json'
|
||||
: url.endsWith('.bin')
|
||||
? 'binary'
|
||||
: url.endsWith('.txt')
|
||||
? 'text'
|
||||
: 'script'
|
||||
|
||||
if (typeof attributes === 'object' && attributes !== null && attributes.type !== type) {
|
||||
throw new Error(\`Module '\${url}' is not of type '\${attributes.type}'\`)
|
||||
}
|
||||
|
||||
let module = cache[url] || null
|
||||
|
||||
if (module !== null) return module
|
||||
|
||||
const { imports, resolutions } = __bundle
|
||||
|
||||
const filename = url
|
||||
const dirname = url.slice(0, url.lastIndexOf('/')) || '/'
|
||||
|
||||
module = cache[url] = {
|
||||
url,
|
||||
type,
|
||||
filename,
|
||||
dirname,
|
||||
imports,
|
||||
resolutions,
|
||||
main: null,
|
||||
exports: {}
|
||||
}
|
||||
|
||||
if (url.startsWith('builtin:')) {
|
||||
module.exports = __bundle.builtinRequire(url.replace(/^builtin:/, ''))
|
||||
|
||||
return module
|
||||
}
|
||||
|
||||
module.main = referrer ? referrer.main : module
|
||||
|
||||
const fn = __bundle.modules[url] || null
|
||||
|
||||
if (fn === null) throw new Error(\`Cannot find module '\${url}'\`)
|
||||
|
||||
function require(specifier, opts = {}) {
|
||||
const attributes = opts && opts.with
|
||||
|
||||
return __bundle.load(cache, __bundle.resolve(specifier, url), module, attributes).exports
|
||||
}
|
||||
|
||||
require.main = module.main
|
||||
require.cache = cache
|
||||
|
||||
require.resolve = function resolve(specifier, parentURL = url) {
|
||||
return __bundle.resolve(specifier, parentURL)
|
||||
}
|
||||
|
||||
require.addon = function addon(specifier = '.', parentURL = url) {
|
||||
return __bundle.builtinRequire.addon(__bundle.addon(specifier, parentURL))
|
||||
}
|
||||
|
||||
require.addon.host = __bundle.builtinRequire.addon?.host
|
||||
|
||||
require.addon.resolve = function resolve(specifier = '.', parentURL = url) {
|
||||
return __bundle.addon(specifier, parentURL)
|
||||
}
|
||||
|
||||
require.asset = function asset(specifier, parentURL = url) {
|
||||
return __bundle.asset(specifier, parentURL)
|
||||
}
|
||||
|
||||
fn(require, module, module.exports, module.filename, module.dirname)
|
||||
|
||||
return module
|
||||
},
|
||||
resolve(specifier, parentURL) {
|
||||
const resolved = __bundle.imports[specifier] || __bundle.resolutions[parentURL]?.[specifier]
|
||||
|
||||
if (!resolved || (typeof resolved === 'object' && !resolved.default)) {
|
||||
throw new Error(\`Cannot find module '\${specifier}' imported from '\${parentURL}'\`)
|
||||
}
|
||||
|
||||
return typeof resolved === 'object' ? resolved.default : resolved
|
||||
},
|
||||
addon(specifier = '.', parentURL) {
|
||||
const resolved = __bundle.imports[specifier] || __bundle.resolutions[parentURL]?.[specifier]
|
||||
|
||||
if (!resolved || (typeof resolved === 'object' && !resolved.addon)) {
|
||||
throw new Error(\`Cannot find addon '\${specifier}' imported from '\${parentURL}'\`)
|
||||
}
|
||||
|
||||
return typeof resolved === 'object' ? resolved.addon : resolved
|
||||
},
|
||||
asset(specifier, parentURL) {
|
||||
const resolved = __bundle.imports[specifier] || __bundle.resolutions[parentURL]?.[specifier]
|
||||
|
||||
if (!resolved || (typeof resolved === 'object' && !resolved.asset)) {
|
||||
throw new Error(\`Cannot find asset '\${specifier}' imported from '\${parentURL}'\`)
|
||||
}
|
||||
|
||||
return typeof resolved === 'object' ? resolved.asset : resolved
|
||||
}
|
||||
}
|
||||
|
||||
__bundle.load(Object.create(null), ${JSON.stringify(bundle.main)})
|
||||
}`;
|
||||
};
|
||||
function compileModule(key, source) {
|
||||
if (key.endsWith(".json")) {
|
||||
return `module.exports = ${source}`;
|
||||
}
|
||||
if (key.endsWith(".bin")) {
|
||||
return `module.exports = new Uint8Array([${Array.from(source)}])`;
|
||||
}
|
||||
if (key.endsWith(".txt")) {
|
||||
return `module.exports = ${JSON.stringify(source.toString())}`;
|
||||
}
|
||||
return source;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareBundleCompile.js
|
||||
var bare_lib_entry_bareBundleCompile_exports = {};
|
||||
__export(bare_lib_entry_bareBundleCompile_exports, {
|
||||
default: () => bare_lib_entry_bareBundleCompile_default
|
||||
});
|
||||
var import_bare_bundle_compile = __toESM(require_bare_bundle_compile());
|
||||
var bare_lib_entry_bareBundleCompile_default = import_bare_bundle_compile.default;
|
||||
return __toCommonJS(bare_lib_entry_bareBundleCompile_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareBundleCompile"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
/* bare-os-bare-libs: esbuild failed for bare-compat-napi — Build failed with 1 error:
|
||||
../../bare-lib-entry-bareCompatNapi.js:1:15: ERROR: Could not resolve "bare-compat-napi" */
|
||||
;(function(){})();
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,218 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-os/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-os/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-os/lib/errors.js
|
||||
var require_errors = __commonJS({
|
||||
"../../node_modules/bare-os/lib/errors.js"(exports, module) {
|
||||
module.exports = class OSError extends Error {
|
||||
constructor(msg, code, fn = OSError) {
|
||||
super(`${code}: ${msg}`);
|
||||
this.code = code;
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, fn);
|
||||
}
|
||||
}
|
||||
get name() {
|
||||
return "OSError";
|
||||
}
|
||||
static UNKNOWN_SIGNAL(msg) {
|
||||
return new OSError(msg, "UNKNOWN_SIGNAL", OSError.UNKNOWN_SIGNAL);
|
||||
}
|
||||
static TITLE_OVERFLOW(msg) {
|
||||
return new OSError(msg, "TITLE_OVERFLOW", OSError.TITLE_OVERFLOW);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-os/lib/constants.js
|
||||
var require_constants = __commonJS({
|
||||
"../../node_modules/bare-os/lib/constants.js"(exports, module) {
|
||||
var binding = require_binding();
|
||||
module.exports = {
|
||||
signals: binding.signals,
|
||||
errnos: binding.errnos,
|
||||
priority: binding.priority
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-os/index.js
|
||||
var require_bare_os = __commonJS({
|
||||
"../../node_modules/bare-os/index.js"(exports) {
|
||||
var binding = require_binding();
|
||||
var errors = require_errors();
|
||||
var constants = require_constants();
|
||||
exports.constants = constants;
|
||||
exports.EOL = binding.platform === "win32" ? "\r\n" : "\n";
|
||||
exports.devNull = binding.platform === "win32" ? "\\\\.\\nul" : "/dev/null";
|
||||
exports.platform = function platform() {
|
||||
return binding.platform;
|
||||
};
|
||||
exports.arch = function arch() {
|
||||
return binding.arch;
|
||||
};
|
||||
exports.type = binding.type;
|
||||
exports.version = binding.version;
|
||||
exports.release = binding.release;
|
||||
exports.machine = binding.machine;
|
||||
exports.execPath = binding.execPath;
|
||||
exports.pid = binding.pid;
|
||||
exports.ppid = binding.ppid;
|
||||
exports.cwd = binding.cwd;
|
||||
exports.chdir = binding.chdir;
|
||||
exports.tmpdir = binding.tmpdir;
|
||||
exports.homedir = binding.homedir;
|
||||
exports.hostname = binding.hostname;
|
||||
exports.userInfo = binding.userInfo;
|
||||
exports.networkInterfaces = function networkInterfaces() {
|
||||
const result = {};
|
||||
for (const entry of binding.networkInterfaces()) {
|
||||
const { name, ...properties } = entry;
|
||||
if (result[name]) result[name].push(properties);
|
||||
else result[name] = [properties];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.kill = function kill(pid, signal = constants.signals.SIGTERM) {
|
||||
if (typeof signal === "string") {
|
||||
if (signal in constants.signals === false) {
|
||||
throw errors.UNKNOWN_SIGNAL("Unknown signal: " + signal);
|
||||
}
|
||||
signal = constants.signals[signal];
|
||||
}
|
||||
binding.kill(pid, signal);
|
||||
};
|
||||
exports.endianness = function endianness() {
|
||||
return binding.isLittleEndian ? "LE" : "BE";
|
||||
};
|
||||
exports.availableParallelism = binding.availableParallelism;
|
||||
exports.cpuUsage = function cpuUsage(previous) {
|
||||
const current = binding.cpuUsage();
|
||||
if (previous) {
|
||||
return {
|
||||
user: current.user - previous.user,
|
||||
system: current.system - previous.system
|
||||
};
|
||||
}
|
||||
return current;
|
||||
};
|
||||
exports.threadCpuUsage = function threadCpuUsage(previous) {
|
||||
const current = binding.threadCpuUsage();
|
||||
if (previous) {
|
||||
return {
|
||||
user: current.user - previous.user,
|
||||
system: current.system - previous.system
|
||||
};
|
||||
}
|
||||
return current;
|
||||
};
|
||||
exports.resourceUsage = binding.resourceUsage;
|
||||
exports.memoryUsage = binding.memoryUsage;
|
||||
exports.freemem = binding.freemem;
|
||||
exports.totalmem = binding.totalmem;
|
||||
exports.availableMemory = binding.availableMemory;
|
||||
exports.constrainedMemory = binding.constrainedMemory;
|
||||
exports.uptime = binding.uptime;
|
||||
exports.loadavg = binding.loadavg;
|
||||
exports.cpus = binding.cpus;
|
||||
exports.getProcessTitle = binding.getProcessTitle;
|
||||
exports.setProcessTitle = function setProcessTitle(title) {
|
||||
if (typeof title !== "string") title = title.toString();
|
||||
if (title.length >= 256) {
|
||||
throw errors.TITLE_OVERFLOW("Process title is too long");
|
||||
}
|
||||
binding.setProcessTitle(title);
|
||||
};
|
||||
exports.getPriority = function getPriority(pid = 0) {
|
||||
return binding.getPriority(pid);
|
||||
};
|
||||
exports.setPriority = function setPriority(pid, priority) {
|
||||
if (priority === void 0) {
|
||||
priority = pid;
|
||||
pid = 0;
|
||||
}
|
||||
binding.setPriority(pid, priority);
|
||||
};
|
||||
exports.getEnvKeys = binding.getEnvKeys;
|
||||
exports.getEnv = binding.getEnv;
|
||||
exports.hasEnv = binding.hasEnv;
|
||||
exports.setEnv = binding.setEnv;
|
||||
exports.unsetEnv = binding.unsetEnv;
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-debug-log/index.js
|
||||
var require_bare_debug_log = __commonJS({
|
||||
"../../node_modules/bare-debug-log/index.js"(exports, module) {
|
||||
var os = require_bare_os();
|
||||
var pid = os.pid();
|
||||
var env = os.getEnv("BARE_DEBUG") || os.getEnv("NODE_DEBUG") || "";
|
||||
var test = new RegExp(
|
||||
`^${env.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*").replace(/,/g, "$|^")}$`,
|
||||
"i"
|
||||
);
|
||||
module.exports = function debug(section) {
|
||||
section = section.toUpperCase();
|
||||
const enabled = test.test(section);
|
||||
function debug2(...args) {
|
||||
if (enabled) console.error("%s %s:", section, pid, ...args);
|
||||
}
|
||||
debug2.enabled = enabled;
|
||||
return debug2;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareDebugLog.js
|
||||
var bare_lib_entry_bareDebugLog_exports = {};
|
||||
__export(bare_lib_entry_bareDebugLog_exports, {
|
||||
default: () => bare_lib_entry_bareDebugLog_default
|
||||
});
|
||||
var import_bare_debug_log = __toESM(require_bare_debug_log());
|
||||
var bare_lib_entry_bareDebugLog_default = import_bare_debug_log.default;
|
||||
return __toCommonJS(bare_lib_entry_bareDebugLog_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareDebugLog"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,262 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-delta/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-delta/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/b4a/index.js
|
||||
var require_b4a = __commonJS({
|
||||
"../../node_modules/b4a/index.js"(exports, module) {
|
||||
function isBuffer(value) {
|
||||
return Buffer.isBuffer(value) || value instanceof Uint8Array;
|
||||
}
|
||||
function isEncoding(encoding) {
|
||||
return Buffer.isEncoding(encoding);
|
||||
}
|
||||
function alloc(size, fill2, encoding) {
|
||||
return Buffer.alloc(size, fill2, encoding);
|
||||
}
|
||||
function allocUnsafe(size) {
|
||||
return Buffer.allocUnsafe(size);
|
||||
}
|
||||
function allocUnsafeSlow(size) {
|
||||
return Buffer.allocUnsafeSlow(size);
|
||||
}
|
||||
function byteLength(string, encoding) {
|
||||
return Buffer.byteLength(string, encoding);
|
||||
}
|
||||
function compare(a, b) {
|
||||
return Buffer.compare(a, b);
|
||||
}
|
||||
function concat(buffers, totalLength) {
|
||||
return Buffer.concat(buffers, totalLength);
|
||||
}
|
||||
function copy(source, target, targetStart, start, end) {
|
||||
return toBuffer(source).copy(target, targetStart, start, end);
|
||||
}
|
||||
function equals(a, b) {
|
||||
return toBuffer(a).equals(b);
|
||||
}
|
||||
function fill(buffer, value, offset, end, encoding) {
|
||||
return toBuffer(buffer).fill(value, offset, end, encoding);
|
||||
}
|
||||
function from(value, encodingOrOffset, length) {
|
||||
return Buffer.from(value, encodingOrOffset, length);
|
||||
}
|
||||
function includes(buffer, value, byteOffset, encoding) {
|
||||
return toBuffer(buffer).includes(value, byteOffset, encoding);
|
||||
}
|
||||
function indexOf(buffer, value, byfeOffset, encoding) {
|
||||
return toBuffer(buffer).indexOf(value, byfeOffset, encoding);
|
||||
}
|
||||
function lastIndexOf(buffer, value, byteOffset, encoding) {
|
||||
return toBuffer(buffer).lastIndexOf(value, byteOffset, encoding);
|
||||
}
|
||||
function swap16(buffer) {
|
||||
return toBuffer(buffer).swap16();
|
||||
}
|
||||
function swap32(buffer) {
|
||||
return toBuffer(buffer).swap32();
|
||||
}
|
||||
function swap64(buffer) {
|
||||
return toBuffer(buffer).swap64();
|
||||
}
|
||||
function toBuffer(buffer) {
|
||||
if (Buffer.isBuffer(buffer)) return buffer;
|
||||
return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
||||
}
|
||||
function toString(buffer, encoding, start, end) {
|
||||
return toBuffer(buffer).toString(encoding, start, end);
|
||||
}
|
||||
function write(buffer, string, offset, length, encoding) {
|
||||
return toBuffer(buffer).write(string, offset, length, encoding);
|
||||
}
|
||||
function readDoubleBE(buffer, offset) {
|
||||
return toBuffer(buffer).readDoubleBE(offset);
|
||||
}
|
||||
function readDoubleLE(buffer, offset) {
|
||||
return toBuffer(buffer).readDoubleLE(offset);
|
||||
}
|
||||
function readFloatBE(buffer, offset) {
|
||||
return toBuffer(buffer).readFloatBE(offset);
|
||||
}
|
||||
function readFloatLE(buffer, offset) {
|
||||
return toBuffer(buffer).readFloatLE(offset);
|
||||
}
|
||||
function readInt32BE(buffer, offset) {
|
||||
return toBuffer(buffer).readInt32BE(offset);
|
||||
}
|
||||
function readInt32LE(buffer, offset) {
|
||||
return toBuffer(buffer).readInt32LE(offset);
|
||||
}
|
||||
function readUInt32BE(buffer, offset) {
|
||||
return toBuffer(buffer).readUInt32BE(offset);
|
||||
}
|
||||
function readUInt32LE(buffer, offset) {
|
||||
return toBuffer(buffer).readUInt32LE(offset);
|
||||
}
|
||||
function writeDoubleBE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeDoubleBE(value, offset);
|
||||
}
|
||||
function writeDoubleLE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeDoubleLE(value, offset);
|
||||
}
|
||||
function writeFloatBE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeFloatBE(value, offset);
|
||||
}
|
||||
function writeFloatLE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeFloatLE(value, offset);
|
||||
}
|
||||
function writeInt32BE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeInt32BE(value, offset);
|
||||
}
|
||||
function writeInt32LE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeInt32LE(value, offset);
|
||||
}
|
||||
function writeUInt32BE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeUInt32BE(value, offset);
|
||||
}
|
||||
function writeUInt32LE(buffer, value, offset) {
|
||||
return toBuffer(buffer).writeUInt32LE(value, offset);
|
||||
}
|
||||
module.exports = {
|
||||
isBuffer,
|
||||
isEncoding,
|
||||
alloc,
|
||||
allocUnsafe,
|
||||
allocUnsafeSlow,
|
||||
byteLength,
|
||||
compare,
|
||||
concat,
|
||||
copy,
|
||||
equals,
|
||||
fill,
|
||||
from,
|
||||
includes,
|
||||
indexOf,
|
||||
lastIndexOf,
|
||||
swap16,
|
||||
swap32,
|
||||
swap64,
|
||||
toBuffer,
|
||||
toString,
|
||||
write,
|
||||
readDoubleBE,
|
||||
readDoubleLE,
|
||||
readFloatBE,
|
||||
readFloatLE,
|
||||
readInt32BE,
|
||||
readInt32LE,
|
||||
readUInt32BE,
|
||||
readUInt32LE,
|
||||
writeDoubleBE,
|
||||
writeDoubleLE,
|
||||
writeFloatBE,
|
||||
writeFloatLE,
|
||||
writeInt32BE,
|
||||
writeInt32LE,
|
||||
writeUInt32BE,
|
||||
writeUInt32LE
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-delta/index.js
|
||||
var require_bare_delta = __commonJS({
|
||||
"../../node_modules/bare-delta/index.js"(exports, module) {
|
||||
var binding = require_binding();
|
||||
var b4a = require_b4a();
|
||||
async function create(source, target, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
binding.create(source, target, options, (err, result) => {
|
||||
if (err) reject(err);
|
||||
else resolve(b4a.toBuffer(result));
|
||||
});
|
||||
});
|
||||
}
|
||||
async function apply(source, delta) {
|
||||
return new Promise((resolve, reject) => {
|
||||
binding.apply(source, delta, (err, result) => {
|
||||
if (err) reject(err);
|
||||
else resolve(b4a.toBuffer(result));
|
||||
});
|
||||
});
|
||||
}
|
||||
function createSync(source, target, options = {}) {
|
||||
const result = binding.createSync(source, target, options);
|
||||
return b4a.toBuffer(result);
|
||||
}
|
||||
function applySync(source, delta) {
|
||||
return b4a.toBuffer(binding.applySync(source, delta));
|
||||
}
|
||||
async function applyBatch(source, deltas) {
|
||||
return new Promise((resolve, reject) => {
|
||||
binding.applyBatch(source, deltas, (err, result) => {
|
||||
if (err) reject(err);
|
||||
else resolve(b4a.toBuffer(result));
|
||||
});
|
||||
});
|
||||
}
|
||||
function applyBatchSync(source, deltas) {
|
||||
return b4a.toBuffer(binding.applyBatchSync(source, deltas));
|
||||
}
|
||||
module.exports = {
|
||||
create,
|
||||
apply,
|
||||
createSync,
|
||||
applySync,
|
||||
applyBatch,
|
||||
applyBatchSync
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareDelta.js
|
||||
var bare_lib_entry_bareDelta_exports = {};
|
||||
__export(bare_lib_entry_bareDelta_exports, {
|
||||
default: () => bare_lib_entry_bareDelta_default
|
||||
});
|
||||
var import_bare_delta = __toESM(require_bare_delta());
|
||||
var bare_lib_entry_bareDelta_default = import_bare_delta.default;
|
||||
return __toCommonJS(bare_lib_entry_bareDelta_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareDelta"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,155 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function __require() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-diagnostics-channel/index.js
|
||||
var require_bare_diagnostics_channel = __commonJS({
|
||||
"../../node_modules/bare-diagnostics-channel/index.js"(exports, module) {
|
||||
var DiagnosticsChannel = class _DiagnosticsChannel {
|
||||
static _channels = /* @__PURE__ */ new Map();
|
||||
constructor(name) {
|
||||
this._name = name;
|
||||
this._subscribers = [];
|
||||
_DiagnosticsChannel._channels.set(name, this);
|
||||
}
|
||||
get name() {
|
||||
return this._name;
|
||||
}
|
||||
get hasSubscribers() {
|
||||
return this._subscribers.length > 0;
|
||||
}
|
||||
subscribe(subscription) {
|
||||
this._subscribers = [...this._subscribers, subscription];
|
||||
}
|
||||
unsubscribe(subscription) {
|
||||
const i = this._subscribers.indexOf(subscription);
|
||||
if (i === -1) return false;
|
||||
this._subscribers = [
|
||||
...this._subscribers.slice(0, i),
|
||||
...this._subscribers.slice(i + 1)
|
||||
];
|
||||
return true;
|
||||
}
|
||||
publish(data) {
|
||||
const subscribers = this._subscribers;
|
||||
for (let i = 0, n = subscribers.length; i < n; i++) {
|
||||
try {
|
||||
subscribers[i](data, this._name);
|
||||
} catch (err) {
|
||||
setImmediate(() => {
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
module.exports = exports = DiagnosticsChannel;
|
||||
exports.Channel = DiagnosticsChannel;
|
||||
function channel(name) {
|
||||
const channel2 = DiagnosticsChannel._channels.get(name);
|
||||
if (channel2 !== void 0) return channel2;
|
||||
return new DiagnosticsChannel(name);
|
||||
}
|
||||
exports.channel = channel;
|
||||
exports.subscribe = function subscribe(name, subscription) {
|
||||
return channel(name).subscribe(subscription);
|
||||
};
|
||||
exports.unsubscribe = function unsubscribe(name, subscription) {
|
||||
return channel(name).unsubscribe(subscription);
|
||||
};
|
||||
exports.hasSubscribers = function hasSubscribers(name) {
|
||||
const channel2 = DiagnosticsChannel._channels.get(name);
|
||||
if (channel2 === void 0) return false;
|
||||
return channel2.hasSubscribers;
|
||||
};
|
||||
var TracingChannel = class {
|
||||
constructor(nameOrChannels) {
|
||||
if (typeof nameOrChannels === "string") {
|
||||
this.start = channel(`tracing:${nameOrChannels}:start`);
|
||||
this.end = channel(`tracing:${nameOrChannels}:end`);
|
||||
this.error = channel(`tracing:${nameOrChannels}:error`);
|
||||
} else {
|
||||
this.start = nameOrChannels.start;
|
||||
this.end = nameOrChannels.end;
|
||||
this.error = nameOrChannels.error;
|
||||
}
|
||||
}
|
||||
get hasSubscribers() {
|
||||
return this.start.hasSubscribers || this.end.hasSubscribers || this.error.hasSubscribers;
|
||||
}
|
||||
subscribe(subscriptions) {
|
||||
const events = ["start", "end", "error"];
|
||||
for (const event of events) {
|
||||
const subscription = subscriptions[event];
|
||||
if (subscription) this[event].subscribe(subscription);
|
||||
}
|
||||
}
|
||||
unsubscribe(subscriptions) {
|
||||
const events = ["start", "end", "error"];
|
||||
return events.reduce((done, event) => {
|
||||
const subscription = subscriptions[event];
|
||||
if (subscription) {
|
||||
return this[event].unsubscribe(subscription) && done;
|
||||
} else {
|
||||
return done;
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
traceSync(fn, context = {}, thisArg, ...args) {
|
||||
try {
|
||||
this.start.publish(context);
|
||||
context.result = fn.call(thisArg, ...args);
|
||||
return context.result;
|
||||
} catch (err) {
|
||||
context.error = err;
|
||||
this.error.publish(context);
|
||||
} finally {
|
||||
this.end.publish(context);
|
||||
}
|
||||
}
|
||||
};
|
||||
function tracingChannel(nameOrChannels) {
|
||||
return new TracingChannel(nameOrChannels);
|
||||
}
|
||||
exports.tracingChannel = tracingChannel;
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareDiagnosticsChannel.js
|
||||
var bare_lib_entry_bareDiagnosticsChannel_exports = {};
|
||||
__export(bare_lib_entry_bareDiagnosticsChannel_exports, {
|
||||
default: () => bare_lib_entry_bareDiagnosticsChannel_default
|
||||
});
|
||||
var import_bare_diagnostics_channel = __toESM(require_bare_diagnostics_channel());
|
||||
var bare_lib_entry_bareDiagnosticsChannel_default = import_bare_diagnostics_channel.default;
|
||||
return __toCommonJS(bare_lib_entry_bareDiagnosticsChannel_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareDiagnosticsChannel"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,121 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-dns/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-dns/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-dns/index.js
|
||||
var require_bare_dns = __commonJS({
|
||||
"../../node_modules/bare-dns/index.js"(exports) {
|
||||
var binding = require_binding();
|
||||
exports.Resolver = class DNSResolver {
|
||||
constructor() {
|
||||
this._handle = binding.initResolver();
|
||||
}
|
||||
resolveTxt(hostname, cb = noop) {
|
||||
binding.resolveTxt(this._handle, hostname, cb, this);
|
||||
}
|
||||
destroy() {
|
||||
binding.destroyResolver(this._handle);
|
||||
this._handle = null;
|
||||
}
|
||||
static global = new this();
|
||||
};
|
||||
function onlookup(err, addresses) {
|
||||
const req = this;
|
||||
if (err) return req.cb(err, null, 0);
|
||||
const { address, family } = addresses[0];
|
||||
return req.cb(null, address, family);
|
||||
}
|
||||
function onlookupall(err, addresses) {
|
||||
const req = this;
|
||||
if (err) return req.cb(err, null);
|
||||
return req.cb(null, addresses);
|
||||
}
|
||||
exports.lookup = function lookup(hostname, opts = {}, cb) {
|
||||
if (typeof opts === "function") {
|
||||
cb = opts;
|
||||
opts = {};
|
||||
}
|
||||
let { family = 0, all = false } = opts;
|
||||
if (typeof family === "string") {
|
||||
switch (family) {
|
||||
case "IPv4":
|
||||
family = 4;
|
||||
break;
|
||||
case "IPv6":
|
||||
family = 6;
|
||||
break;
|
||||
default:
|
||||
family = 0;
|
||||
}
|
||||
}
|
||||
const req = {
|
||||
cb,
|
||||
handle: null
|
||||
};
|
||||
req.handle = binding.lookup(
|
||||
hostname,
|
||||
family || 0,
|
||||
all,
|
||||
req,
|
||||
all ? onlookupall : onlookup
|
||||
);
|
||||
};
|
||||
exports.resolveTxt = function resolveTxt(hostname, cb) {
|
||||
exports.Resolver.global.resolveTxt(hostname, cb);
|
||||
};
|
||||
function noop() {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareDns.js
|
||||
var bare_lib_entry_bareDns_exports = {};
|
||||
__export(bare_lib_entry_bareDns_exports, {
|
||||
default: () => bare_lib_entry_bareDns_default
|
||||
});
|
||||
var import_bare_dns = __toESM(require_bare_dns());
|
||||
var bare_lib_entry_bareDns_default = import_bare_dns.default;
|
||||
return __toCommonJS(bare_lib_entry_bareDns_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareDns"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,247 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function __require() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-encoding/lib/utf8-decoder.js
|
||||
var require_utf8_decoder = __commonJS({
|
||||
"../../node_modules/bare-encoding/lib/utf8-decoder.js"(exports, module) {
|
||||
module.exports = class UTF8Decoder {
|
||||
constructor() {
|
||||
this.codePoint = 0;
|
||||
this.bytesSeen = 0;
|
||||
this.bytesNeeded = 0;
|
||||
this.lowerBoundary = 128;
|
||||
this.upperBoundary = 191;
|
||||
}
|
||||
get remaining() {
|
||||
return this.bytesSeen;
|
||||
}
|
||||
decode(data) {
|
||||
if (ArrayBuffer.isView(data)) {
|
||||
data = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
||||
} else {
|
||||
data = Buffer.from(data);
|
||||
}
|
||||
if (this.bytesNeeded === 0) {
|
||||
let isBoundary = true;
|
||||
for (let i = Math.max(0, data.byteLength - 4), n = data.byteLength; i < n && isBoundary; i++) {
|
||||
isBoundary = data[i] <= 127;
|
||||
}
|
||||
if (isBoundary) return data.toString("utf8");
|
||||
}
|
||||
let result = "";
|
||||
for (let i = 0, n = data.byteLength; i < n; i++) {
|
||||
const byte = data[i];
|
||||
if (this.bytesNeeded === 0) {
|
||||
if (byte <= 127) {
|
||||
this.bytesSeen = 0;
|
||||
result += String.fromCharCode(byte);
|
||||
} else {
|
||||
this.bytesSeen = 1;
|
||||
if (byte >= 194 && byte <= 223) {
|
||||
this.bytesNeeded = 2;
|
||||
this.codePoint = byte & 31;
|
||||
} else if (byte >= 224 && byte <= 239) {
|
||||
if (byte === 224) this.lowerBoundary = 160;
|
||||
else if (byte === 237) this.upperBoundary = 159;
|
||||
this.bytesNeeded = 3;
|
||||
this.codePoint = byte & 15;
|
||||
} else if (byte >= 240 && byte <= 244) {
|
||||
if (byte === 240) this.lowerBoundary = 144;
|
||||
if (byte === 244) this.upperBoundary = 143;
|
||||
this.bytesNeeded = 4;
|
||||
this.codePoint = byte & 7;
|
||||
} else {
|
||||
result += "\uFFFD";
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (byte < this.lowerBoundary || byte > this.upperBoundary) {
|
||||
this.codePoint = 0;
|
||||
this.bytesNeeded = 0;
|
||||
this.bytesSeen = 0;
|
||||
this.lowerBoundary = 128;
|
||||
this.upperBoundary = 191;
|
||||
result += "\uFFFD";
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
this.lowerBoundary = 128;
|
||||
this.upperBoundary = 191;
|
||||
this.codePoint = this.codePoint << 6 | byte & 63;
|
||||
this.bytesSeen++;
|
||||
if (this.bytesSeen !== this.bytesNeeded) continue;
|
||||
result += String.fromCodePoint(this.codePoint);
|
||||
this.codePoint = 0;
|
||||
this.bytesNeeded = 0;
|
||||
this.bytesSeen = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
flush() {
|
||||
const result = this.bytesNeeded > 0 ? "\uFFFD" : "";
|
||||
this.codePoint = 0;
|
||||
this.bytesNeeded = 0;
|
||||
this.bytesSeen = 0;
|
||||
this.lowerBoundary = 128;
|
||||
this.upperBoundary = 191;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-encoding/lib/pass-through-decoder.js
|
||||
var require_pass_through_decoder = __commonJS({
|
||||
"../../node_modules/bare-encoding/lib/pass-through-decoder.js"(exports, module) {
|
||||
module.exports = class PassThroughDecoder {
|
||||
constructor(encoding) {
|
||||
this.encoding = encoding;
|
||||
}
|
||||
get remaining() {
|
||||
return 0;
|
||||
}
|
||||
decode(data) {
|
||||
if (ArrayBuffer.isView(data)) {
|
||||
data = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
||||
} else {
|
||||
data = Buffer.from(data);
|
||||
}
|
||||
return data.toString(this.encoding);
|
||||
}
|
||||
flush() {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-encoding/lib/errors.js
|
||||
var require_errors = __commonJS({
|
||||
"../../node_modules/bare-encoding/lib/errors.js"(exports, module) {
|
||||
module.exports = class EncodingError extends Error {
|
||||
constructor(msg, code, fn = EncodingError) {
|
||||
super(`${code}: ${msg}`);
|
||||
this.code = code;
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, fn);
|
||||
}
|
||||
}
|
||||
get name() {
|
||||
return "EncodingError";
|
||||
}
|
||||
static INVALID_LABEL(msg) {
|
||||
return new EncodingError(msg, "INVALID_LABEL", EncodingError.INVALID_LABEL);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-encoding/index.js
|
||||
var require_bare_encoding = __commonJS({
|
||||
"../../node_modules/bare-encoding/index.js"(exports) {
|
||||
var UTF8Decoder = require_utf8_decoder();
|
||||
var PassThroughDecoder = require_pass_through_decoder();
|
||||
var errors = require_errors();
|
||||
exports.TextEncoder = class TextEncoder {
|
||||
// https://encoding.spec.whatwg.org/#dom-textencoder-encoding
|
||||
get encoding() {
|
||||
return "utf-8";
|
||||
}
|
||||
// https://encoding.spec.whatwg.org/#dom-textencoder-encode
|
||||
encode(input) {
|
||||
return Buffer.from(input);
|
||||
}
|
||||
// https://encoding.spec.whatwg.org/#dom-textencoder-encodeinto
|
||||
encodeInto(input, destination) {
|
||||
if (ArrayBuffer.isView(destination)) {
|
||||
destination = Buffer.from(
|
||||
destination.buffer,
|
||||
destination.byteOffset,
|
||||
destination.byteLength
|
||||
);
|
||||
} else {
|
||||
destination = Buffer.from(destination);
|
||||
}
|
||||
return {
|
||||
read: input.length,
|
||||
written: destination.write(input)
|
||||
};
|
||||
}
|
||||
};
|
||||
exports.TextDecoder = class TextDecoder {
|
||||
// https://encoding.spec.whatwg.org/#dom-textdecoder
|
||||
constructor(label = "utf-8") {
|
||||
this.encoding = getEncoding(label);
|
||||
switch (this.encoding) {
|
||||
case "utf-8":
|
||||
this.decoder = new UTF8Decoder();
|
||||
break;
|
||||
default:
|
||||
this.decoder = new PassThroughDecoder(this.encoding);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// https://encoding.spec.whatwg.org/#dom-textdecoder-decode
|
||||
decode(input, options = {}) {
|
||||
const result = this.decoder.decode(input);
|
||||
if (options.stream) return result;
|
||||
return result + this.decoder.flush();
|
||||
}
|
||||
};
|
||||
function getEncoding(label) {
|
||||
switch (label.trim().toLowerCase()) {
|
||||
case "unicode-1-1-utf-8":
|
||||
case "unicode11utf8":
|
||||
case "unicode11utf8":
|
||||
case "unicode20utf8":
|
||||
case "utf-8":
|
||||
case "utf8":
|
||||
case "x-unicode20utf8":
|
||||
return "utf-8";
|
||||
default:
|
||||
throw errors.INVALID_LABEL(`The label '${label}' is not a valid encoding`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareEncoding.js
|
||||
var bare_lib_entry_bareEncoding_exports = {};
|
||||
__export(bare_lib_entry_bareEncoding_exports, {
|
||||
default: () => bare_lib_entry_bareEncoding_default
|
||||
});
|
||||
var import_bare_encoding = __toESM(require_bare_encoding());
|
||||
var bare_lib_entry_bareEncoding_default = import_bare_encoding.default;
|
||||
return __toCommonJS(bare_lib_entry_bareEncoding_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareEncoding"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,238 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-os/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-os/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-os/lib/errors.js
|
||||
var require_errors = __commonJS({
|
||||
"../../node_modules/bare-os/lib/errors.js"(exports, module) {
|
||||
module.exports = class OSError extends Error {
|
||||
constructor(msg, code, fn = OSError) {
|
||||
super(`${code}: ${msg}`);
|
||||
this.code = code;
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, fn);
|
||||
}
|
||||
}
|
||||
get name() {
|
||||
return "OSError";
|
||||
}
|
||||
static UNKNOWN_SIGNAL(msg) {
|
||||
return new OSError(msg, "UNKNOWN_SIGNAL", OSError.UNKNOWN_SIGNAL);
|
||||
}
|
||||
static TITLE_OVERFLOW(msg) {
|
||||
return new OSError(msg, "TITLE_OVERFLOW", OSError.TITLE_OVERFLOW);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-os/lib/constants.js
|
||||
var require_constants = __commonJS({
|
||||
"../../node_modules/bare-os/lib/constants.js"(exports, module) {
|
||||
var binding = require_binding();
|
||||
module.exports = {
|
||||
signals: binding.signals,
|
||||
errnos: binding.errnos,
|
||||
priority: binding.priority
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-os/index.js
|
||||
var require_bare_os = __commonJS({
|
||||
"../../node_modules/bare-os/index.js"(exports) {
|
||||
var binding = require_binding();
|
||||
var errors = require_errors();
|
||||
var constants = require_constants();
|
||||
exports.constants = constants;
|
||||
exports.EOL = binding.platform === "win32" ? "\r\n" : "\n";
|
||||
exports.devNull = binding.platform === "win32" ? "\\\\.\\nul" : "/dev/null";
|
||||
exports.platform = function platform() {
|
||||
return binding.platform;
|
||||
};
|
||||
exports.arch = function arch() {
|
||||
return binding.arch;
|
||||
};
|
||||
exports.type = binding.type;
|
||||
exports.version = binding.version;
|
||||
exports.release = binding.release;
|
||||
exports.machine = binding.machine;
|
||||
exports.execPath = binding.execPath;
|
||||
exports.pid = binding.pid;
|
||||
exports.ppid = binding.ppid;
|
||||
exports.cwd = binding.cwd;
|
||||
exports.chdir = binding.chdir;
|
||||
exports.tmpdir = binding.tmpdir;
|
||||
exports.homedir = binding.homedir;
|
||||
exports.hostname = binding.hostname;
|
||||
exports.userInfo = binding.userInfo;
|
||||
exports.networkInterfaces = function networkInterfaces() {
|
||||
const result = {};
|
||||
for (const entry of binding.networkInterfaces()) {
|
||||
const { name, ...properties } = entry;
|
||||
if (result[name]) result[name].push(properties);
|
||||
else result[name] = [properties];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.kill = function kill(pid, signal = constants.signals.SIGTERM) {
|
||||
if (typeof signal === "string") {
|
||||
if (signal in constants.signals === false) {
|
||||
throw errors.UNKNOWN_SIGNAL("Unknown signal: " + signal);
|
||||
}
|
||||
signal = constants.signals[signal];
|
||||
}
|
||||
binding.kill(pid, signal);
|
||||
};
|
||||
exports.endianness = function endianness() {
|
||||
return binding.isLittleEndian ? "LE" : "BE";
|
||||
};
|
||||
exports.availableParallelism = binding.availableParallelism;
|
||||
exports.cpuUsage = function cpuUsage(previous) {
|
||||
const current = binding.cpuUsage();
|
||||
if (previous) {
|
||||
return {
|
||||
user: current.user - previous.user,
|
||||
system: current.system - previous.system
|
||||
};
|
||||
}
|
||||
return current;
|
||||
};
|
||||
exports.threadCpuUsage = function threadCpuUsage(previous) {
|
||||
const current = binding.threadCpuUsage();
|
||||
if (previous) {
|
||||
return {
|
||||
user: current.user - previous.user,
|
||||
system: current.system - previous.system
|
||||
};
|
||||
}
|
||||
return current;
|
||||
};
|
||||
exports.resourceUsage = binding.resourceUsage;
|
||||
exports.memoryUsage = binding.memoryUsage;
|
||||
exports.freemem = binding.freemem;
|
||||
exports.totalmem = binding.totalmem;
|
||||
exports.availableMemory = binding.availableMemory;
|
||||
exports.constrainedMemory = binding.constrainedMemory;
|
||||
exports.uptime = binding.uptime;
|
||||
exports.loadavg = binding.loadavg;
|
||||
exports.cpus = binding.cpus;
|
||||
exports.getProcessTitle = binding.getProcessTitle;
|
||||
exports.setProcessTitle = function setProcessTitle(title) {
|
||||
if (typeof title !== "string") title = title.toString();
|
||||
if (title.length >= 256) {
|
||||
throw errors.TITLE_OVERFLOW("Process title is too long");
|
||||
}
|
||||
binding.setProcessTitle(title);
|
||||
};
|
||||
exports.getPriority = function getPriority(pid = 0) {
|
||||
return binding.getPriority(pid);
|
||||
};
|
||||
exports.setPriority = function setPriority(pid, priority) {
|
||||
if (priority === void 0) {
|
||||
priority = pid;
|
||||
pid = 0;
|
||||
}
|
||||
binding.setPriority(pid, priority);
|
||||
};
|
||||
exports.getEnvKeys = binding.getEnvKeys;
|
||||
exports.getEnv = binding.getEnv;
|
||||
exports.hasEnv = binding.hasEnv;
|
||||
exports.setEnv = binding.setEnv;
|
||||
exports.unsetEnv = binding.unsetEnv;
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-env/index.js
|
||||
var require_bare_env = __commonJS({
|
||||
"../../node_modules/bare-env/index.js"(exports, module) {
|
||||
var os = require_bare_os();
|
||||
module.exports = new Proxy(/* @__PURE__ */ Object.create(null), {
|
||||
ownKeys(target) {
|
||||
return os.getEnvKeys();
|
||||
},
|
||||
get(target, property) {
|
||||
if (typeof property !== "string") return;
|
||||
return os.getEnv(property);
|
||||
},
|
||||
has(target, property) {
|
||||
if (typeof property !== "string") return false;
|
||||
return os.hasEnv(property);
|
||||
},
|
||||
set(target, property, value) {
|
||||
if (typeof property !== "string") return;
|
||||
const type = typeof value;
|
||||
if (type !== "string" && type !== "number" && type !== "boolean") {
|
||||
throw new Error("Environment variable must be of type string, number, or boolean");
|
||||
}
|
||||
value = String(value);
|
||||
os.setEnv(property, value);
|
||||
return true;
|
||||
},
|
||||
deleteProperty(target, property) {
|
||||
if (typeof property !== "string") return;
|
||||
os.unsetEnv(property);
|
||||
},
|
||||
getOwnPropertyDescriptor(target, property) {
|
||||
return {
|
||||
value: this.get(target, property),
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareEnv.js
|
||||
var bare_lib_entry_bareEnv_exports = {};
|
||||
__export(bare_lib_entry_bareEnv_exports, {
|
||||
default: () => bare_lib_entry_bareEnv_default
|
||||
});
|
||||
var import_bare_env = __toESM(require_bare_env());
|
||||
var bare_lib_entry_bareEnv_default = import_bare_env.default;
|
||||
return __toCommonJS(bare_lib_entry_bareEnv_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareEnv"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,348 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function __require() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-events/lib/errors.js
|
||||
var require_errors = __commonJS({
|
||||
"../../node_modules/bare-events/lib/errors.js"(exports, module) {
|
||||
module.exports = class EventEmitterError extends Error {
|
||||
constructor(msg, code, fn = EventEmitterError, opts) {
|
||||
super(`${code}: ${msg}`, opts);
|
||||
this.code = code;
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, fn);
|
||||
}
|
||||
}
|
||||
get name() {
|
||||
return "EventEmitterError";
|
||||
}
|
||||
static OPERATION_ABORTED(cause, msg = "Operation aborted") {
|
||||
return new EventEmitterError(msg, "OPERATION_ABORTED", EventEmitterError.OPERATION_ABORTED, {
|
||||
cause
|
||||
});
|
||||
}
|
||||
static UNHANDLED_ERROR(cause, msg = "Unhandled error") {
|
||||
return new EventEmitterError(msg, "UNHANDLED_ERROR", EventEmitterError.UNHANDLED_ERROR, {
|
||||
cause
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-events/index.js
|
||||
var require_bare_events = __commonJS({
|
||||
"../../node_modules/bare-events/index.js"(exports, module) {
|
||||
var errors = require_errors();
|
||||
var EventListener = class {
|
||||
constructor() {
|
||||
this.list = [];
|
||||
this.count = 0;
|
||||
}
|
||||
append(ctx, name, fn, once) {
|
||||
this.count++;
|
||||
ctx.emit("newListener", name, fn);
|
||||
this.list.push([fn, once]);
|
||||
}
|
||||
prepend(ctx, name, fn, once) {
|
||||
this.count++;
|
||||
ctx.emit("newListener", name, fn);
|
||||
this.list.unshift([fn, once]);
|
||||
}
|
||||
remove(ctx, name, fn) {
|
||||
for (let i = 0, n = this.list.length; i < n; i++) {
|
||||
const l = this.list[i];
|
||||
if (l[0] === fn) {
|
||||
this.list.splice(i, 1);
|
||||
if (this.count === 1) delete ctx._events[name];
|
||||
ctx.emit("removeListener", name, fn);
|
||||
this.count--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
removeAll(ctx, name) {
|
||||
const list = [...this.list];
|
||||
this.list = [];
|
||||
if (this.count === list.length) delete ctx._events[name];
|
||||
for (let i = list.length - 1; i >= 0; i--) {
|
||||
ctx.emit("removeListener", name, list[i][0]);
|
||||
}
|
||||
this.count -= list.length;
|
||||
}
|
||||
emit(ctx, name, ...args) {
|
||||
const list = [...this.list];
|
||||
for (let i = 0, n = list.length; i < n; i++) {
|
||||
const l = list[i];
|
||||
if (l[1] === true) this.remove(ctx, name, l[0]);
|
||||
Reflect.apply(l[0], ctx, args);
|
||||
}
|
||||
return list.length > 0;
|
||||
}
|
||||
};
|
||||
function appendListener(ctx, name, fn, once) {
|
||||
if (ctx._events === void 0) ctx._events = /* @__PURE__ */ Object.create(null);
|
||||
const e = ctx._events[name] || (ctx._events[name] = new EventListener());
|
||||
e.append(ctx, name, fn, once);
|
||||
return ctx;
|
||||
}
|
||||
function prependListener(ctx, name, fn, once) {
|
||||
if (ctx._events === void 0) ctx._events = /* @__PURE__ */ Object.create(null);
|
||||
const e = ctx._events[name] || (ctx._events[name] = new EventListener());
|
||||
e.prepend(ctx, name, fn, once);
|
||||
return ctx;
|
||||
}
|
||||
function removeListener(ctx, name, fn) {
|
||||
if (ctx._events === void 0) return ctx;
|
||||
const e = ctx._events[name];
|
||||
if (e !== void 0) e.remove(ctx, name, fn);
|
||||
return ctx;
|
||||
}
|
||||
function throwUnhandledError(...args) {
|
||||
let err;
|
||||
if (args.length > 0) err = args[0];
|
||||
if (err instanceof Error === false) err = errors.UNHANDLED_ERROR(err);
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(err, exports.prototype.emit);
|
||||
}
|
||||
queueMicrotask(() => {
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
module.exports = exports = class EventEmitter {
|
||||
constructor() {
|
||||
this._events = /* @__PURE__ */ Object.create(null);
|
||||
}
|
||||
addListener(name, fn) {
|
||||
return appendListener(this, name, fn, false);
|
||||
}
|
||||
addOnceListener(name, fn) {
|
||||
return appendListener(this, name, fn, true);
|
||||
}
|
||||
prependListener(name, fn) {
|
||||
return prependListener(this, name, fn, false);
|
||||
}
|
||||
prependOnceListener(name, fn) {
|
||||
return prependListener(this, name, fn, true);
|
||||
}
|
||||
removeListener(name, fn) {
|
||||
return removeListener(this, name, fn);
|
||||
}
|
||||
on(name, fn) {
|
||||
return appendListener(this, name, fn, false);
|
||||
}
|
||||
once(name, fn) {
|
||||
return appendListener(this, name, fn, true);
|
||||
}
|
||||
off(name, fn) {
|
||||
return removeListener(this, name, fn);
|
||||
}
|
||||
emit(name, ...args) {
|
||||
if (name === "error" && this._events !== void 0 && this._events.error === void 0) {
|
||||
throwUnhandledError(...args);
|
||||
}
|
||||
if (this._events === void 0) return false;
|
||||
const e = this._events[name];
|
||||
return e === void 0 ? false : e.emit(this, name, ...args);
|
||||
}
|
||||
listeners(name) {
|
||||
if (this._events === void 0) return [];
|
||||
const e = this._events[name];
|
||||
return e === void 0 ? [] : [...e.list];
|
||||
}
|
||||
listenerCount(name) {
|
||||
if (this._events === void 0) return 0;
|
||||
const e = this._events[name];
|
||||
return e === void 0 ? 0 : e.list.length;
|
||||
}
|
||||
getMaxListeners() {
|
||||
return EventEmitter.defaultMaxListeners;
|
||||
}
|
||||
setMaxListeners(n) {
|
||||
}
|
||||
removeAllListeners(name) {
|
||||
if (arguments.length === 0) {
|
||||
for (const key of Reflect.ownKeys(this._events)) {
|
||||
if (key === "removeListener") continue;
|
||||
this.removeAllListeners(key);
|
||||
}
|
||||
this.removeAllListeners("removeListener");
|
||||
} else {
|
||||
const e = this._events[name];
|
||||
if (e !== void 0) e.removeAll(this, name);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
};
|
||||
exports.EventEmitter = exports;
|
||||
exports.errors = errors;
|
||||
exports.defaultMaxListeners = 10;
|
||||
exports.on = function on(emitter, name, opts = {}) {
|
||||
const { signal } = opts;
|
||||
if (signal && signal.aborted) {
|
||||
throw errors.OPERATION_ABORTED(signal.reason);
|
||||
}
|
||||
let error = null;
|
||||
let done = false;
|
||||
const events = [];
|
||||
const promises = [];
|
||||
if (name !== "error") emitter.on("error", onerror);
|
||||
if (signal) signal.addEventListener("abort", onabort);
|
||||
emitter.on(name, onevent);
|
||||
return {
|
||||
next() {
|
||||
if (events.length) {
|
||||
return Promise.resolve({ value: events.shift(), done: false });
|
||||
}
|
||||
if (error) {
|
||||
const err = error;
|
||||
error = null;
|
||||
return Promise.reject(err);
|
||||
}
|
||||
if (done) return onclose();
|
||||
return new Promise((resolve, reject) => promises.push({ resolve, reject }));
|
||||
},
|
||||
return() {
|
||||
return onclose();
|
||||
},
|
||||
throw(err) {
|
||||
return onerror(err);
|
||||
},
|
||||
[Symbol.asyncIterator]() {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
function onevent(...args) {
|
||||
if (promises.length) {
|
||||
promises.shift().resolve({ value: args, done: false });
|
||||
} else {
|
||||
events.push(args);
|
||||
}
|
||||
}
|
||||
function onerror(err) {
|
||||
emitter.off(name, onevent).off("error", onerror);
|
||||
if (promises.length) {
|
||||
promises.shift().reject(err);
|
||||
} else {
|
||||
error = err;
|
||||
}
|
||||
return Promise.resolve({ done: true });
|
||||
}
|
||||
function onabort() {
|
||||
signal.removeEventListener("abort", onabort);
|
||||
onerror(errors.OPERATION_ABORTED(signal.reason));
|
||||
}
|
||||
function onclose() {
|
||||
emitter.off(name, onevent);
|
||||
if (name !== "error") emitter.off("error", onerror);
|
||||
if (signal) signal.removeEventListener("abort", onabort);
|
||||
done = true;
|
||||
if (promises.length) promises.shift().resolve({ done: true });
|
||||
return Promise.resolve({ done: true });
|
||||
}
|
||||
};
|
||||
exports.once = function once(emitter, name, opts = {}) {
|
||||
const { signal } = opts;
|
||||
if (signal && signal.aborted) {
|
||||
return Promise.reject(errors.OPERATION_ABORTED(signal.reason));
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
if (name !== "error") emitter.on("error", onerror);
|
||||
if (signal) signal.addEventListener("abort", onabort);
|
||||
emitter.once(name, onevent);
|
||||
function onevent(...args) {
|
||||
if (name !== "error") emitter.off("error", onerror);
|
||||
if (signal) signal.removeEventListener("abort", onabort);
|
||||
resolve(args);
|
||||
}
|
||||
function onerror(err) {
|
||||
emitter.off(name, onevent);
|
||||
if (name !== "error") emitter.off("error", onerror);
|
||||
reject(err);
|
||||
}
|
||||
function onabort() {
|
||||
signal.removeEventListener("abort", onabort);
|
||||
onerror(errors.OPERATION_ABORTED(signal.reason));
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.forward = function forward(from, to, names, opts = {}) {
|
||||
if (typeof names === "string") names = [names];
|
||||
const { emit = to.emit.bind(to) } = opts;
|
||||
const listeners = names.map(
|
||||
(name) => function onevent(...args) {
|
||||
emit(name, ...args);
|
||||
}
|
||||
);
|
||||
to.on("newListener", (name) => {
|
||||
const i = names.indexOf(name);
|
||||
if (i !== -1 && to.listenerCount(name) === 0) {
|
||||
from.on(name, listeners[i]);
|
||||
}
|
||||
}).on("removeListener", (name) => {
|
||||
const i = names.indexOf(name);
|
||||
if (i !== -1 && to.listenerCount(name) === 0) {
|
||||
from.off(name, listeners[i]);
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.listenerCount = function listenerCount(emitter, name) {
|
||||
return emitter.listenerCount(name);
|
||||
};
|
||||
exports.getMaxListeners = function getMaxListeners(emitter) {
|
||||
if (typeof emitter.getMaxListeners === "function") {
|
||||
return emitter.getMaxListeners();
|
||||
}
|
||||
return exports.defaultMaxListeners;
|
||||
};
|
||||
exports.setMaxListeners = function setMaxListeners(n, ...emitters) {
|
||||
if (emitters.length === 0) exports.defaultMaxListeners = n;
|
||||
else {
|
||||
for (const emitter of emitters) {
|
||||
if (typeof emitter.setMaxListeners === "function") {
|
||||
emitter.setMaxListeners(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareEvents.js
|
||||
var bare_lib_entry_bareEvents_exports = {};
|
||||
__export(bare_lib_entry_bareEvents_exports, {
|
||||
default: () => bare_lib_entry_bareEvents_default
|
||||
});
|
||||
var import_bare_events = __toESM(require_bare_events());
|
||||
var bare_lib_entry_bareEvents_default = import_bare_events.default;
|
||||
return __toCommonJS(bare_lib_entry_bareEvents_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareEvents"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,167 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-exif/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-exif/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-exif/index.js
|
||||
var require_bare_exif = __commonJS({
|
||||
"../../node_modules/bare-exif/index.js"(exports) {
|
||||
var binding = require_binding();
|
||||
exports.constants = {
|
||||
tags: binding.tags,
|
||||
ifds: binding.ifds,
|
||||
formats: binding.formats,
|
||||
byteOrders: binding.byteOrders
|
||||
};
|
||||
var EXIFEntry = class {
|
||||
constructor(data) {
|
||||
this._handle = data.handle;
|
||||
this.tag = data.tag;
|
||||
this.format = data.format;
|
||||
this.components = data.components;
|
||||
this.data = data.data;
|
||||
this.size = data.size;
|
||||
this.byteOrder = data.byte_order;
|
||||
}
|
||||
#readComponent(index) {
|
||||
const { formats, byteOrders } = binding;
|
||||
const littleEndian = this.byteOrder === byteOrders.INTEL;
|
||||
const view = new DataView(this.data);
|
||||
switch (this.format) {
|
||||
case formats.BYTE:
|
||||
return view.getUint8(index);
|
||||
case formats.SBYTE:
|
||||
return view.getInt8(index);
|
||||
case formats.SHORT:
|
||||
return view.getUint16(index * 2, littleEndian);
|
||||
case formats.SSHORT:
|
||||
return view.getInt16(index * 2, littleEndian);
|
||||
case formats.LONG:
|
||||
return view.getUint32(index * 4, littleEndian);
|
||||
case formats.SLONG:
|
||||
return view.getInt32(index * 4, littleEndian);
|
||||
case formats.FLOAT:
|
||||
return view.getFloat32(index * 4, littleEndian);
|
||||
case formats.DOUBLE:
|
||||
return view.getFloat64(index * 8, littleEndian);
|
||||
case formats.RATIONAL: {
|
||||
return {
|
||||
numerator: view.getUint32(index * 4, littleEndian),
|
||||
denominator: view.getUint32(index * 4 + 4, littleEndian)
|
||||
};
|
||||
}
|
||||
case formats.SRATIONAL: {
|
||||
return {
|
||||
numerator: view.getInt32(index * 4, littleEndian),
|
||||
denominator: view.getInt32(index * 4 + 4, littleEndian)
|
||||
};
|
||||
}
|
||||
case formats.ASCII: {
|
||||
let text = "";
|
||||
for (let i = 0; i < view.byteLength; i++) {
|
||||
const c = view.getUint8(i);
|
||||
if (c === 0) break;
|
||||
text += String.fromCharCode(c);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
case formats.UNDEFINED:
|
||||
return Buffer.from(this.data);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
read() {
|
||||
if (!this.components || this.components < 0) return null;
|
||||
if (this.components === 1 || this.format === binding.formats.ASCII || this.format === binding.formats.UNDEFINED) {
|
||||
return this.#readComponent(0);
|
||||
}
|
||||
const values = [];
|
||||
for (let i = 0; i < this.components; i++) {
|
||||
values.push(this.#readComponent(i));
|
||||
}
|
||||
return values;
|
||||
}
|
||||
value() {
|
||||
return binding.entryValue(this._handle);
|
||||
}
|
||||
destroy() {
|
||||
if (this._handle === null) return;
|
||||
binding.destroyEntry(this._handle);
|
||||
this._handle = null;
|
||||
}
|
||||
[Symbol.dispose]() {
|
||||
this.destroy();
|
||||
}
|
||||
};
|
||||
exports.Data = class EXIFData {
|
||||
constructor(data) {
|
||||
this._handle = binding.initData(data.buffer, data.byteOffset, data.byteLength);
|
||||
}
|
||||
entry(tag) {
|
||||
const data = binding.entry(this._handle, tag);
|
||||
if (!data) return null;
|
||||
return new EXIFEntry(data);
|
||||
}
|
||||
destroy() {
|
||||
if (this._handle === null) return;
|
||||
binding.destroyData(this._handle);
|
||||
this._handle = null;
|
||||
}
|
||||
[Symbol.dispose]() {
|
||||
this.destroy();
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareExif.js
|
||||
var bare_lib_entry_bareExif_exports = {};
|
||||
__export(bare_lib_entry_bareExif_exports, {
|
||||
default: () => bare_lib_entry_bareExif_default
|
||||
});
|
||||
var import_bare_exif = __toESM(require_bare_exif());
|
||||
var bare_lib_entry_bareExif_default = import_bare_exif.default;
|
||||
return __toCommonJS(bare_lib_entry_bareExif_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareExif"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,86 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-gif/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-gif/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-gif/index.js
|
||||
var require_bare_gif = __commonJS({
|
||||
"../../node_modules/bare-gif/index.js"(exports) {
|
||||
var binding = require_binding();
|
||||
exports.decode = function decode(image) {
|
||||
const { width, height, data } = binding.decode(image);
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
data: Buffer.from(data)
|
||||
};
|
||||
};
|
||||
exports.decodeAnimated = function decodeAnimated(image) {
|
||||
const { width, height, frames } = binding.decodeAnimated(image);
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
frames: frames.map((frame) => {
|
||||
const { width: width2, height: height2, timestamp, data } = frame;
|
||||
return {
|
||||
width: width2,
|
||||
height: height2,
|
||||
timestamp,
|
||||
data: Buffer.from(data)
|
||||
};
|
||||
})
|
||||
};
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareGif.js
|
||||
var bare_lib_entry_bareGif_exports = {};
|
||||
__export(bare_lib_entry_bareGif_exports, {
|
||||
default: () => bare_lib_entry_bareGif_default
|
||||
});
|
||||
var import_bare_gif = __toESM(require_bare_gif());
|
||||
var bare_lib_entry_bareGif_default = import_bare_gif.default;
|
||||
return __toCommonJS(bare_lib_entry_bareGif_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareGif"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,423 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-events/lib/errors.js
|
||||
var require_errors = __commonJS({
|
||||
"../../node_modules/bare-events/lib/errors.js"(exports, module) {
|
||||
module.exports = class EventEmitterError extends Error {
|
||||
constructor(msg, code, fn = EventEmitterError, opts) {
|
||||
super(`${code}: ${msg}`, opts);
|
||||
this.code = code;
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, fn);
|
||||
}
|
||||
}
|
||||
get name() {
|
||||
return "EventEmitterError";
|
||||
}
|
||||
static OPERATION_ABORTED(cause, msg = "Operation aborted") {
|
||||
return new EventEmitterError(msg, "OPERATION_ABORTED", EventEmitterError.OPERATION_ABORTED, {
|
||||
cause
|
||||
});
|
||||
}
|
||||
static UNHANDLED_ERROR(cause, msg = "Unhandled error") {
|
||||
return new EventEmitterError(msg, "UNHANDLED_ERROR", EventEmitterError.UNHANDLED_ERROR, {
|
||||
cause
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-events/index.js
|
||||
var require_bare_events = __commonJS({
|
||||
"../../node_modules/bare-events/index.js"(exports, module) {
|
||||
var errors = require_errors();
|
||||
var EventListener = class {
|
||||
constructor() {
|
||||
this.list = [];
|
||||
this.count = 0;
|
||||
}
|
||||
append(ctx, name, fn, once) {
|
||||
this.count++;
|
||||
ctx.emit("newListener", name, fn);
|
||||
this.list.push([fn, once]);
|
||||
}
|
||||
prepend(ctx, name, fn, once) {
|
||||
this.count++;
|
||||
ctx.emit("newListener", name, fn);
|
||||
this.list.unshift([fn, once]);
|
||||
}
|
||||
remove(ctx, name, fn) {
|
||||
for (let i = 0, n = this.list.length; i < n; i++) {
|
||||
const l = this.list[i];
|
||||
if (l[0] === fn) {
|
||||
this.list.splice(i, 1);
|
||||
if (this.count === 1) delete ctx._events[name];
|
||||
ctx.emit("removeListener", name, fn);
|
||||
this.count--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
removeAll(ctx, name) {
|
||||
const list = [...this.list];
|
||||
this.list = [];
|
||||
if (this.count === list.length) delete ctx._events[name];
|
||||
for (let i = list.length - 1; i >= 0; i--) {
|
||||
ctx.emit("removeListener", name, list[i][0]);
|
||||
}
|
||||
this.count -= list.length;
|
||||
}
|
||||
emit(ctx, name, ...args) {
|
||||
const list = [...this.list];
|
||||
for (let i = 0, n = list.length; i < n; i++) {
|
||||
const l = list[i];
|
||||
if (l[1] === true) this.remove(ctx, name, l[0]);
|
||||
Reflect.apply(l[0], ctx, args);
|
||||
}
|
||||
return list.length > 0;
|
||||
}
|
||||
};
|
||||
function appendListener(ctx, name, fn, once) {
|
||||
if (ctx._events === void 0) ctx._events = /* @__PURE__ */ Object.create(null);
|
||||
const e = ctx._events[name] || (ctx._events[name] = new EventListener());
|
||||
e.append(ctx, name, fn, once);
|
||||
return ctx;
|
||||
}
|
||||
function prependListener(ctx, name, fn, once) {
|
||||
if (ctx._events === void 0) ctx._events = /* @__PURE__ */ Object.create(null);
|
||||
const e = ctx._events[name] || (ctx._events[name] = new EventListener());
|
||||
e.prepend(ctx, name, fn, once);
|
||||
return ctx;
|
||||
}
|
||||
function removeListener(ctx, name, fn) {
|
||||
if (ctx._events === void 0) return ctx;
|
||||
const e = ctx._events[name];
|
||||
if (e !== void 0) e.remove(ctx, name, fn);
|
||||
return ctx;
|
||||
}
|
||||
function throwUnhandledError(...args) {
|
||||
let err;
|
||||
if (args.length > 0) err = args[0];
|
||||
if (err instanceof Error === false) err = errors.UNHANDLED_ERROR(err);
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(err, exports.prototype.emit);
|
||||
}
|
||||
queueMicrotask(() => {
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
module.exports = exports = class EventEmitter {
|
||||
constructor() {
|
||||
this._events = /* @__PURE__ */ Object.create(null);
|
||||
}
|
||||
addListener(name, fn) {
|
||||
return appendListener(this, name, fn, false);
|
||||
}
|
||||
addOnceListener(name, fn) {
|
||||
return appendListener(this, name, fn, true);
|
||||
}
|
||||
prependListener(name, fn) {
|
||||
return prependListener(this, name, fn, false);
|
||||
}
|
||||
prependOnceListener(name, fn) {
|
||||
return prependListener(this, name, fn, true);
|
||||
}
|
||||
removeListener(name, fn) {
|
||||
return removeListener(this, name, fn);
|
||||
}
|
||||
on(name, fn) {
|
||||
return appendListener(this, name, fn, false);
|
||||
}
|
||||
once(name, fn) {
|
||||
return appendListener(this, name, fn, true);
|
||||
}
|
||||
off(name, fn) {
|
||||
return removeListener(this, name, fn);
|
||||
}
|
||||
emit(name, ...args) {
|
||||
if (name === "error" && this._events !== void 0 && this._events.error === void 0) {
|
||||
throwUnhandledError(...args);
|
||||
}
|
||||
if (this._events === void 0) return false;
|
||||
const e = this._events[name];
|
||||
return e === void 0 ? false : e.emit(this, name, ...args);
|
||||
}
|
||||
listeners(name) {
|
||||
if (this._events === void 0) return [];
|
||||
const e = this._events[name];
|
||||
return e === void 0 ? [] : [...e.list];
|
||||
}
|
||||
listenerCount(name) {
|
||||
if (this._events === void 0) return 0;
|
||||
const e = this._events[name];
|
||||
return e === void 0 ? 0 : e.list.length;
|
||||
}
|
||||
getMaxListeners() {
|
||||
return EventEmitter.defaultMaxListeners;
|
||||
}
|
||||
setMaxListeners(n) {
|
||||
}
|
||||
removeAllListeners(name) {
|
||||
if (arguments.length === 0) {
|
||||
for (const key of Reflect.ownKeys(this._events)) {
|
||||
if (key === "removeListener") continue;
|
||||
this.removeAllListeners(key);
|
||||
}
|
||||
this.removeAllListeners("removeListener");
|
||||
} else {
|
||||
const e = this._events[name];
|
||||
if (e !== void 0) e.removeAll(this, name);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
};
|
||||
exports.EventEmitter = exports;
|
||||
exports.errors = errors;
|
||||
exports.defaultMaxListeners = 10;
|
||||
exports.on = function on(emitter, name, opts = {}) {
|
||||
const { signal } = opts;
|
||||
if (signal && signal.aborted) {
|
||||
throw errors.OPERATION_ABORTED(signal.reason);
|
||||
}
|
||||
let error = null;
|
||||
let done = false;
|
||||
const events = [];
|
||||
const promises = [];
|
||||
if (name !== "error") emitter.on("error", onerror);
|
||||
if (signal) signal.addEventListener("abort", onabort);
|
||||
emitter.on(name, onevent);
|
||||
return {
|
||||
next() {
|
||||
if (events.length) {
|
||||
return Promise.resolve({ value: events.shift(), done: false });
|
||||
}
|
||||
if (error) {
|
||||
const err = error;
|
||||
error = null;
|
||||
return Promise.reject(err);
|
||||
}
|
||||
if (done) return onclose();
|
||||
return new Promise((resolve, reject) => promises.push({ resolve, reject }));
|
||||
},
|
||||
return() {
|
||||
return onclose();
|
||||
},
|
||||
throw(err) {
|
||||
return onerror(err);
|
||||
},
|
||||
[Symbol.asyncIterator]() {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
function onevent(...args) {
|
||||
if (promises.length) {
|
||||
promises.shift().resolve({ value: args, done: false });
|
||||
} else {
|
||||
events.push(args);
|
||||
}
|
||||
}
|
||||
function onerror(err) {
|
||||
emitter.off(name, onevent).off("error", onerror);
|
||||
if (promises.length) {
|
||||
promises.shift().reject(err);
|
||||
} else {
|
||||
error = err;
|
||||
}
|
||||
return Promise.resolve({ done: true });
|
||||
}
|
||||
function onabort() {
|
||||
signal.removeEventListener("abort", onabort);
|
||||
onerror(errors.OPERATION_ABORTED(signal.reason));
|
||||
}
|
||||
function onclose() {
|
||||
emitter.off(name, onevent);
|
||||
if (name !== "error") emitter.off("error", onerror);
|
||||
if (signal) signal.removeEventListener("abort", onabort);
|
||||
done = true;
|
||||
if (promises.length) promises.shift().resolve({ done: true });
|
||||
return Promise.resolve({ done: true });
|
||||
}
|
||||
};
|
||||
exports.once = function once(emitter, name, opts = {}) {
|
||||
const { signal } = opts;
|
||||
if (signal && signal.aborted) {
|
||||
return Promise.reject(errors.OPERATION_ABORTED(signal.reason));
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
if (name !== "error") emitter.on("error", onerror);
|
||||
if (signal) signal.addEventListener("abort", onabort);
|
||||
emitter.once(name, onevent);
|
||||
function onevent(...args) {
|
||||
if (name !== "error") emitter.off("error", onerror);
|
||||
if (signal) signal.removeEventListener("abort", onabort);
|
||||
resolve(args);
|
||||
}
|
||||
function onerror(err) {
|
||||
emitter.off(name, onevent);
|
||||
if (name !== "error") emitter.off("error", onerror);
|
||||
reject(err);
|
||||
}
|
||||
function onabort() {
|
||||
signal.removeEventListener("abort", onabort);
|
||||
onerror(errors.OPERATION_ABORTED(signal.reason));
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.forward = function forward(from, to, names, opts = {}) {
|
||||
if (typeof names === "string") names = [names];
|
||||
const { emit = to.emit.bind(to) } = opts;
|
||||
const listeners = names.map(
|
||||
(name) => function onevent(...args) {
|
||||
emit(name, ...args);
|
||||
}
|
||||
);
|
||||
to.on("newListener", (name) => {
|
||||
const i = names.indexOf(name);
|
||||
if (i !== -1 && to.listenerCount(name) === 0) {
|
||||
from.on(name, listeners[i]);
|
||||
}
|
||||
}).on("removeListener", (name) => {
|
||||
const i = names.indexOf(name);
|
||||
if (i !== -1 && to.listenerCount(name) === 0) {
|
||||
from.off(name, listeners[i]);
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.listenerCount = function listenerCount(emitter, name) {
|
||||
return emitter.listenerCount(name);
|
||||
};
|
||||
exports.getMaxListeners = function getMaxListeners(emitter) {
|
||||
if (typeof emitter.getMaxListeners === "function") {
|
||||
return emitter.getMaxListeners();
|
||||
}
|
||||
return exports.defaultMaxListeners;
|
||||
};
|
||||
exports.setMaxListeners = function setMaxListeners(n, ...emitters) {
|
||||
if (emitters.length === 0) exports.defaultMaxListeners = n;
|
||||
else {
|
||||
for (const emitter of emitters) {
|
||||
if (typeof emitter.setMaxListeners === "function") {
|
||||
emitter.setMaxListeners(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-gtk/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-gtk/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-gtk/lib/widget.js
|
||||
var require_widget = __commonJS({
|
||||
"../../node_modules/bare-gtk/lib/widget.js"(exports, module) {
|
||||
var EventEmitter = require_bare_events();
|
||||
var binding = require_binding();
|
||||
module.exports = class GTKWidget extends EventEmitter {
|
||||
constructor(handle = null) {
|
||||
super();
|
||||
this._handle = handle;
|
||||
}
|
||||
get visible() {
|
||||
return binding.widgetVisible(this._handle);
|
||||
}
|
||||
set visible(value) {
|
||||
binding.widgetVisible(this._handle, value);
|
||||
}
|
||||
get sizeRequest() {
|
||||
return binding.widgetSizeRequest(this._handle);
|
||||
}
|
||||
set sizeRequest([width, height]) {
|
||||
binding.widgetSizeRequest(this._handle, width, height);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-gtk/lib/window.js
|
||||
var require_window = __commonJS({
|
||||
"../../node_modules/bare-gtk/lib/window.js"(exports, module) {
|
||||
var binding = require_binding();
|
||||
var GTKWidget = require_widget();
|
||||
module.exports = exports = class GTKWindow extends GTKWidget {
|
||||
constructor() {
|
||||
super();
|
||||
this._handle = binding.windowInit(this);
|
||||
}
|
||||
get defaultSize() {
|
||||
return binding.windowDefaultSize(this._handle);
|
||||
}
|
||||
set defaultSize([width, height]) {
|
||||
binding.windowDefaultSize(this._handle, width, height);
|
||||
}
|
||||
get child() {
|
||||
const handle = binding.windowChild(this._handle);
|
||||
if (handle === null) return null;
|
||||
return new GTKWidget(handle);
|
||||
}
|
||||
set child(widget) {
|
||||
binding.windowChild(this._handle, widget._handle);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-gtk/index.js
|
||||
var require_bare_gtk = __commonJS({
|
||||
"../../node_modules/bare-gtk/index.js"(exports) {
|
||||
exports.Widget = require_widget();
|
||||
exports.Window = require_window();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareGtk.js
|
||||
var bare_lib_entry_bareGtk_exports = {};
|
||||
__export(bare_lib_entry_bareGtk_exports, {
|
||||
default: () => bare_lib_entry_bareGtk_default
|
||||
});
|
||||
var import_bare_gtk = __toESM(require_bare_gtk());
|
||||
var bare_lib_entry_bareGtk_default = import_bare_gtk.default;
|
||||
return __toCommonJS(bare_lib_entry_bareGtk_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareGtk"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,3 @@
|
||||
/* bare-os-bare-libs: esbuild failed for bare-headers — Build failed with 1 error:
|
||||
../../bare-lib-entry-bareHeaders.js:1:15: ERROR: Could not resolve "bare-headers" */
|
||||
;(function(){})();
|
||||
@@ -0,0 +1,70 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-heif/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-heif/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-heif/index.js
|
||||
var require_bare_heif = __commonJS({
|
||||
"../../node_modules/bare-heif/index.js"(exports) {
|
||||
var binding = require_binding();
|
||||
exports.decode = function decode(image) {
|
||||
const { width, height, data } = binding.decode(image);
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
data: Buffer.from(data)
|
||||
};
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareHeif.js
|
||||
var bare_lib_entry_bareHeif_exports = {};
|
||||
__export(bare_lib_entry_bareHeif_exports, {
|
||||
default: () => bare_lib_entry_bareHeif_default
|
||||
});
|
||||
var import_bare_heif = __toESM(require_bare_heif());
|
||||
var bare_lib_entry_bareHeif_default = import_bare_heif.default;
|
||||
return __toCommonJS(bare_lib_entry_bareHeif_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareHeif"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,70 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-hrtime/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-hrtime/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-hrtime/index.js
|
||||
var require_bare_hrtime = __commonJS({
|
||||
"../../node_modules/bare-hrtime/index.js"(exports, module) {
|
||||
var binding = require_binding();
|
||||
module.exports = exports = function hrtime(past) {
|
||||
let now = binding.hrtime();
|
||||
if (past) now -= BigInt(past[0]) * 1000000000n + BigInt(past[1]);
|
||||
return [Number(now / 1000000000n), Number(now % 1000000000n)];
|
||||
};
|
||||
exports.bigint = function hrtime() {
|
||||
return binding.hrtime();
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareHrtime.js
|
||||
var bare_lib_entry_bareHrtime_exports = {};
|
||||
__export(bare_lib_entry_bareHrtime_exports, {
|
||||
default: () => bare_lib_entry_bareHrtime_default
|
||||
});
|
||||
var import_bare_hrtime = __toESM(require_bare_hrtime());
|
||||
var bare_lib_entry_bareHrtime_default = import_bare_hrtime.default;
|
||||
return __toCommonJS(bare_lib_entry_bareHrtime_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareHrtime"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,708 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __commonJS = (cb, mod) => function __require() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-http-parser/lib/errors.js
|
||||
var require_errors = __commonJS({
|
||||
"../../node_modules/bare-http-parser/lib/errors.js"(exports, module) {
|
||||
module.exports = class HTTPParserError extends Error {
|
||||
constructor(msg, fn = HTTPParserError, code = fn.name) {
|
||||
super(`${code}: ${msg}`);
|
||||
this.code = code;
|
||||
if (Error.captureStackTrace) Error.captureStackTrace(this, fn);
|
||||
}
|
||||
get name() {
|
||||
return "HTTPParserError";
|
||||
}
|
||||
static INVALID_MESSAGE(msg = "Invalid HTTP message") {
|
||||
return new HTTPParserError(msg, HTTPParserError.INVALID_MESSAGE);
|
||||
}
|
||||
static INVALID_HEADER(msg = "Invalid HTTP header") {
|
||||
return new HTTPParserError(msg, HTTPParserError.INVALID_HEADER);
|
||||
}
|
||||
static INVALID_CONTENT_LENGTH(msg = "Invalid HTTP Content-Length") {
|
||||
return new HTTPParserError(msg, HTTPParserError.INVALID_CONTENT_LENGTH);
|
||||
}
|
||||
static INVALID_CHUNK_LENGTH(msg = "Invalid HTTP chunk length") {
|
||||
return new HTTPParserError(msg, HTTPParserError.INVALID_CHUNK_LENGTH);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-http-parser/index.js
|
||||
var require_bare_http_parser = __commonJS({
|
||||
"../../node_modules/bare-http-parser/index.js"(exports, module) {
|
||||
var errors = require_errors();
|
||||
var constants = {
|
||||
REQUEST: 1,
|
||||
RESPONSE: 2,
|
||||
DATA: 3,
|
||||
END: 4
|
||||
};
|
||||
var TAB = 9;
|
||||
var LF = 10;
|
||||
var CR = 13;
|
||||
var SP = 32;
|
||||
var ZERO = 48;
|
||||
var NINE = 57;
|
||||
var UPPER_A = 65;
|
||||
var UPPER_F = 70;
|
||||
var UPPER_Z = 90;
|
||||
var LOWER_A = 97;
|
||||
var LOWER_F = 102;
|
||||
var COLON = 58;
|
||||
var MAX_CHUNK_SIZE_LENGTH = 16;
|
||||
var FIRST_TOKEN = 0;
|
||||
var REQUEST_URL = 1;
|
||||
var REQUEST_VERSION = 2;
|
||||
var STATUS_CODE = 3;
|
||||
var STATUS_REASON = 4;
|
||||
var FIRST_LINE_LF = 5;
|
||||
var HEADER_START = 6;
|
||||
var HEADER_NAME = 7;
|
||||
var HEADER_VALUE_WS = 8;
|
||||
var HEADER_VALUE = 9;
|
||||
var HEADER_LINE_LF = 10;
|
||||
var HEADER_END_LF = 11;
|
||||
var BODY = 12;
|
||||
var CHUNK_SIZE = 13;
|
||||
var CHUNK_SIZE_LF = 14;
|
||||
var CHUNK_DATA = 15;
|
||||
var CHUNK_EXTENSION = 16;
|
||||
var LAST_CHUNK_LF = 17;
|
||||
var TRAILER_CR = 18;
|
||||
var TRAILER_LF = 19;
|
||||
module.exports = exports = class HTTPParser {
|
||||
constructor(opts = {}) {
|
||||
const { maxHeaderSize = 16384, maxHeadersCount = 2e3 } = opts;
|
||||
this._maxHeaderSize = maxHeaderSize;
|
||||
this._maxHeadersCount = maxHeadersCount;
|
||||
this._state = FIRST_TOKEN;
|
||||
this._buffer = [];
|
||||
this._bufferIndex = 0;
|
||||
this._byteIndex = 0;
|
||||
this._buffered = 0;
|
||||
this._accumulator = [];
|
||||
this._isResponse = false;
|
||||
this._method = "";
|
||||
this._url = "";
|
||||
this._version = "";
|
||||
this._code = 0;
|
||||
this._reason = "";
|
||||
this._headerName = "";
|
||||
this._headers = {};
|
||||
this._headerCount = 0;
|
||||
this._headerSize = 0;
|
||||
this._remaining = 0;
|
||||
}
|
||||
*push(data, encoding) {
|
||||
if (typeof data === "string") data = Buffer.from(data, encoding);
|
||||
this._buffer.push(data);
|
||||
this._buffered += data.byteLength;
|
||||
yield* this._parse();
|
||||
this._compact();
|
||||
}
|
||||
end() {
|
||||
const buffers = this._buffer;
|
||||
const bufferIndex = this._bufferIndex;
|
||||
const byteIndex = this._byteIndex;
|
||||
this._buffer = [];
|
||||
this._bufferIndex = 0;
|
||||
this._byteIndex = 0;
|
||||
this._buffered = 0;
|
||||
if (bufferIndex >= buffers.length) return Buffer.alloc(0);
|
||||
buffers[bufferIndex] = buffers[bufferIndex].subarray(byteIndex);
|
||||
const remaining = buffers.slice(bufferIndex);
|
||||
if (remaining.length === 0) return Buffer.alloc(0);
|
||||
if (remaining.length === 1) return remaining[0];
|
||||
return Buffer.concat(remaining);
|
||||
}
|
||||
_compact() {
|
||||
if (this._bufferIndex > 0) {
|
||||
this._buffer = this._buffer.slice(this._bufferIndex);
|
||||
this._bufferIndex = 0;
|
||||
}
|
||||
if (this._byteIndex > 0 && this._buffer.length > 0) {
|
||||
this._buffer[0] = this._buffer[0].subarray(this._byteIndex);
|
||||
this._byteIndex = 0;
|
||||
}
|
||||
}
|
||||
_consume(n) {
|
||||
this._buffered -= n;
|
||||
const current = this._buffer[this._bufferIndex];
|
||||
if (this._byteIndex + n <= current.byteLength) {
|
||||
const slice = current.subarray(this._byteIndex, this._byteIndex + n);
|
||||
this._byteIndex += n;
|
||||
if (this._byteIndex >= current.byteLength) {
|
||||
this._bufferIndex++;
|
||||
this._byteIndex = 0;
|
||||
}
|
||||
return slice;
|
||||
}
|
||||
const result = Buffer.allocUnsafe(n);
|
||||
let written = 0;
|
||||
while (written < n) {
|
||||
const buffer = this._buffer[this._bufferIndex];
|
||||
const available = buffer.byteLength - this._byteIndex;
|
||||
const take = Math.min(available, n - written);
|
||||
buffer.copy(result, written, this._byteIndex, this._byteIndex + take);
|
||||
written += take;
|
||||
this._byteIndex += take;
|
||||
if (this._byteIndex >= buffer.byteLength) {
|
||||
this._bufferIndex++;
|
||||
this._byteIndex = 0;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
_buildString() {
|
||||
const string = String.fromCharCode.apply(null, this._accumulator);
|
||||
this._accumulator = [];
|
||||
return string;
|
||||
}
|
||||
_checkHeaderSize() {
|
||||
if (++this._headerSize > this._maxHeaderSize) {
|
||||
throw errors.INVALID_MESSAGE("Header exceeds limit of " + this._maxHeaderSize + " bytes");
|
||||
}
|
||||
}
|
||||
_storeHeader(name, value) {
|
||||
let end = value.length;
|
||||
while (end > 0 && (value.charCodeAt(end - 1) === SP || value.charCodeAt(end - 1) === TAB)) {
|
||||
end--;
|
||||
}
|
||||
if (end < value.length) value = value.substring(0, end);
|
||||
this._headerCount++;
|
||||
if (this._headerCount > this._maxHeadersCount) {
|
||||
throw errors.INVALID_MESSAGE("Header count exceeds limit of " + this._maxHeadersCount);
|
||||
}
|
||||
switch (name) {
|
||||
case "__proto__":
|
||||
case "constructor":
|
||||
case "prototype":
|
||||
throw errors.INVALID_HEADER("Unsafe header name '" + name + "'");
|
||||
case "host":
|
||||
case "content-length":
|
||||
case "transfer-encoding":
|
||||
if (name in this._headers) {
|
||||
throw errors.INVALID_HEADER("Duplicate header '" + name + "'");
|
||||
}
|
||||
this._headers[name] = value;
|
||||
break;
|
||||
default:
|
||||
const delimiter = name === "cookie" ? "; " : ", ";
|
||||
if (name in this._headers) {
|
||||
this._headers[name] += delimiter + value;
|
||||
} else {
|
||||
this._headers[name] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
*_parse() {
|
||||
while (true) {
|
||||
if (this._state === BODY) {
|
||||
if (this._buffered === 0) return;
|
||||
const available = Math.min(this._buffered, this._remaining);
|
||||
const data = this._consume(available);
|
||||
this._remaining -= available;
|
||||
const ended = this._remaining === 0;
|
||||
if (ended) this._state = FIRST_TOKEN;
|
||||
yield { type: constants.DATA, data };
|
||||
if (ended) yield { type: constants.END };
|
||||
continue;
|
||||
}
|
||||
if (this._state === CHUNK_DATA) {
|
||||
if (this._buffered < this._remaining) return;
|
||||
const consumed = this._consume(this._remaining);
|
||||
if (consumed[this._remaining - 2] !== CR || consumed[this._remaining - 1] !== LF) {
|
||||
throw errors.INVALID_MESSAGE("Expected CRLF after chunk data");
|
||||
}
|
||||
const data = consumed.subarray(0, this._remaining - 2);
|
||||
this._remaining = 0;
|
||||
this._state = CHUNK_SIZE;
|
||||
yield { type: constants.DATA, data };
|
||||
continue;
|
||||
}
|
||||
if (this._buffered === 0) return;
|
||||
const byte = this._buffer[this._bufferIndex][this._byteIndex++];
|
||||
this._buffered--;
|
||||
if (this._byteIndex >= this._buffer[this._bufferIndex].byteLength) {
|
||||
this._bufferIndex++;
|
||||
this._byteIndex = 0;
|
||||
}
|
||||
switch (this._state) {
|
||||
case FIRST_TOKEN: {
|
||||
this._checkHeaderSize();
|
||||
if (byte === SP) {
|
||||
const token = this._buildString();
|
||||
if (token.length === 0) throw errors.INVALID_MESSAGE();
|
||||
this._isResponse = token.startsWith("HTTP/");
|
||||
if (this._isResponse) {
|
||||
if (token !== "HTTP/1.0" && token !== "HTTP/1.1") {
|
||||
throw errors.INVALID_MESSAGE();
|
||||
}
|
||||
this._version = token;
|
||||
this._state = STATUS_CODE;
|
||||
} else {
|
||||
this._method = token;
|
||||
this._state = REQUEST_URL;
|
||||
}
|
||||
} else if (byte === CR) {
|
||||
throw errors.INVALID_MESSAGE();
|
||||
} else if (isTokenByte(byte)) {
|
||||
this._accumulator.push(byte);
|
||||
} else if (byte === 47 && this._accumulator.length === 4 && this._accumulator[0] === 72 && this._accumulator[1] === 84 && this._accumulator[2] === 84 && this._accumulator[3] === 80) {
|
||||
this._accumulator.push(byte);
|
||||
} else {
|
||||
throw errors.INVALID_MESSAGE();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case REQUEST_URL: {
|
||||
this._checkHeaderSize();
|
||||
if (byte === SP) {
|
||||
this._url = this._buildString();
|
||||
if (this._url.length === 0) throw errors.INVALID_MESSAGE();
|
||||
this._state = REQUEST_VERSION;
|
||||
} else if (byte === CR) {
|
||||
throw errors.INVALID_MESSAGE();
|
||||
} else if (byte >= 33 && byte !== 127) {
|
||||
this._accumulator.push(byte);
|
||||
} else {
|
||||
throw errors.INVALID_MESSAGE();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case REQUEST_VERSION: {
|
||||
this._checkHeaderSize();
|
||||
if (byte === CR) {
|
||||
this._version = this._buildString();
|
||||
if (this._version !== "HTTP/1.0" && this._version !== "HTTP/1.1") {
|
||||
throw errors.INVALID_MESSAGE();
|
||||
}
|
||||
this._state = FIRST_LINE_LF;
|
||||
} else if (byte >= 33 && byte !== 127) {
|
||||
this._accumulator.push(byte);
|
||||
} else {
|
||||
throw errors.INVALID_MESSAGE();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case STATUS_CODE: {
|
||||
this._checkHeaderSize();
|
||||
if (byte === SP) {
|
||||
if (this._accumulator.length === 0) throw errors.INVALID_MESSAGE();
|
||||
let code = 0;
|
||||
for (let i = 0, n = this._accumulator.length; i < n; i++) {
|
||||
code = code * 10 + this._accumulator[i];
|
||||
}
|
||||
this._accumulator = [];
|
||||
if (code < 100 || code > 999) throw errors.INVALID_MESSAGE();
|
||||
this._code = code;
|
||||
this._state = STATUS_REASON;
|
||||
} else if (byte >= ZERO && byte <= NINE) {
|
||||
this._accumulator.push(byte - ZERO);
|
||||
} else {
|
||||
throw errors.INVALID_MESSAGE();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case STATUS_REASON: {
|
||||
this._checkHeaderSize();
|
||||
if (byte === CR) {
|
||||
this._reason = this._buildString();
|
||||
this._state = FIRST_LINE_LF;
|
||||
} else if (isFieldByte(byte)) {
|
||||
this._accumulator.push(byte);
|
||||
} else {
|
||||
throw errors.INVALID_MESSAGE();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FIRST_LINE_LF: {
|
||||
if (byte !== LF) throw errors.INVALID_MESSAGE();
|
||||
this._headers = {};
|
||||
this._headerCount = 0;
|
||||
this._state = HEADER_START;
|
||||
break;
|
||||
}
|
||||
case HEADER_START: {
|
||||
this._checkHeaderSize();
|
||||
if (byte === CR) {
|
||||
this._state = HEADER_END_LF;
|
||||
} else if (byte !== COLON && isTokenByte(byte)) {
|
||||
this._accumulator.push(byte >= UPPER_A && byte <= UPPER_Z ? byte + 32 : byte);
|
||||
this._state = HEADER_NAME;
|
||||
} else {
|
||||
throw errors.INVALID_HEADER();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HEADER_NAME: {
|
||||
this._checkHeaderSize();
|
||||
if (byte === COLON) {
|
||||
this._headerName = this._buildString();
|
||||
this._state = HEADER_VALUE_WS;
|
||||
} else if (byte !== COLON && isTokenByte(byte)) {
|
||||
this._accumulator.push(byte >= UPPER_A && byte <= UPPER_Z ? byte + 32 : byte);
|
||||
} else {
|
||||
throw errors.INVALID_HEADER();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HEADER_VALUE_WS: {
|
||||
this._checkHeaderSize();
|
||||
if (byte === SP || byte === TAB) break;
|
||||
if (byte === CR) {
|
||||
this._storeHeader(this._headerName, "");
|
||||
this._headerName = "";
|
||||
this._state = HEADER_LINE_LF;
|
||||
break;
|
||||
}
|
||||
if (!isFieldByte(byte)) throw errors.INVALID_HEADER();
|
||||
this._accumulator.push(byte);
|
||||
this._state = HEADER_VALUE;
|
||||
break;
|
||||
}
|
||||
case HEADER_VALUE: {
|
||||
this._checkHeaderSize();
|
||||
if (byte === CR) {
|
||||
this._storeHeader(this._headerName, this._buildString());
|
||||
this._headerName = "";
|
||||
this._state = HEADER_LINE_LF;
|
||||
} else if (isFieldByte(byte)) {
|
||||
this._accumulator.push(byte);
|
||||
} else {
|
||||
throw errors.INVALID_HEADER();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HEADER_LINE_LF: {
|
||||
if (byte !== LF) throw errors.INVALID_HEADER();
|
||||
this._state = HEADER_START;
|
||||
break;
|
||||
}
|
||||
case HEADER_END_LF: {
|
||||
if (byte !== LF) throw errors.INVALID_MESSAGE();
|
||||
const headers = this._headers;
|
||||
if (this._isResponse) {
|
||||
yield {
|
||||
type: constants.RESPONSE,
|
||||
version: this._version,
|
||||
code: this._code,
|
||||
reason: this._reason,
|
||||
headers
|
||||
};
|
||||
} else {
|
||||
if (this._version === "HTTP/1.1" && !("host" in headers)) {
|
||||
throw errors.INVALID_HEADER("Header 'Host' is missing");
|
||||
}
|
||||
yield {
|
||||
type: constants.REQUEST,
|
||||
version: this._version,
|
||||
method: this._method,
|
||||
url: this._url,
|
||||
headers
|
||||
};
|
||||
}
|
||||
const transferEncoding = headers["transfer-encoding"];
|
||||
const contentLength = headers["content-length"];
|
||||
const encodings = transferEncoding ? transferEncoding.split(",") : null;
|
||||
const lastEncoding = encodings ? encodings[encodings.length - 1].trim().toLowerCase() : null;
|
||||
if (lastEncoding === "chunked") {
|
||||
if (contentLength) {
|
||||
throw errors.INVALID_MESSAGE(
|
||||
"Conflicting 'Content-Length' and 'Transfer-Encoding' headers"
|
||||
);
|
||||
}
|
||||
this._state = CHUNK_SIZE;
|
||||
this._headerSize = 0;
|
||||
continue;
|
||||
}
|
||||
if (contentLength) {
|
||||
if (contentLength.length === 0) throw errors.INVALID_CONTENT_LENGTH();
|
||||
let length = 0;
|
||||
for (let i = 0, n = contentLength.length; i < n; i++) {
|
||||
const c = contentLength.charCodeAt(i);
|
||||
if (c < ZERO || c > NINE) throw errors.INVALID_CONTENT_LENGTH();
|
||||
length = length * 10 + (c - ZERO);
|
||||
}
|
||||
if (!Number.isSafeInteger(length) || length < 0) {
|
||||
throw errors.INVALID_CONTENT_LENGTH();
|
||||
}
|
||||
if (length === 0) {
|
||||
this._state = FIRST_TOKEN;
|
||||
this._headerSize = 0;
|
||||
yield { type: constants.END };
|
||||
} else {
|
||||
this._state = BODY;
|
||||
this._remaining = length;
|
||||
this._headerSize = 0;
|
||||
}
|
||||
} else {
|
||||
this._state = FIRST_TOKEN;
|
||||
this._headerSize = 0;
|
||||
yield { type: constants.END };
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHUNK_SIZE: {
|
||||
if (byte === CR || byte === 59) {
|
||||
if (this._accumulator.length === 0) throw errors.INVALID_CHUNK_LENGTH();
|
||||
let length = 0;
|
||||
for (let i = 0, n = this._accumulator.length; i < n; i++) {
|
||||
length = length * 16 + this._accumulator[i];
|
||||
}
|
||||
this._accumulator = [];
|
||||
if (!Number.isSafeInteger(length)) throw errors.INVALID_CHUNK_LENGTH();
|
||||
if (byte === 59) {
|
||||
this._remaining = length;
|
||||
this._state = CHUNK_EXTENSION;
|
||||
} else if (length === 0) {
|
||||
this._state = LAST_CHUNK_LF;
|
||||
} else {
|
||||
this._remaining = length + 2;
|
||||
this._state = CHUNK_SIZE_LF;
|
||||
}
|
||||
} else if (isHex(byte)) {
|
||||
if (this._accumulator.length >= MAX_CHUNK_SIZE_LENGTH) {
|
||||
throw errors.INVALID_CHUNK_LENGTH();
|
||||
}
|
||||
this._accumulator.push(hexValue(byte));
|
||||
} else {
|
||||
throw errors.INVALID_CHUNK_LENGTH();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHUNK_EXTENSION: {
|
||||
this._checkHeaderSize();
|
||||
if (byte === CR) {
|
||||
if (this._remaining === 0) {
|
||||
this._state = LAST_CHUNK_LF;
|
||||
} else {
|
||||
this._remaining += 2;
|
||||
this._state = CHUNK_SIZE_LF;
|
||||
}
|
||||
} else if (!isFieldByte(byte)) {
|
||||
throw errors.INVALID_CHUNK_LENGTH();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHUNK_SIZE_LF: {
|
||||
if (byte !== LF) throw errors.INVALID_CHUNK_LENGTH();
|
||||
this._state = CHUNK_DATA;
|
||||
break;
|
||||
}
|
||||
case LAST_CHUNK_LF: {
|
||||
if (byte !== LF) throw errors.INVALID_CHUNK_LENGTH();
|
||||
this._state = TRAILER_CR;
|
||||
break;
|
||||
}
|
||||
case TRAILER_CR: {
|
||||
if (byte !== CR) throw errors.INVALID_MESSAGE();
|
||||
this._state = TRAILER_LF;
|
||||
break;
|
||||
}
|
||||
case TRAILER_LF: {
|
||||
if (byte !== LF) throw errors.INVALID_MESSAGE();
|
||||
this._state = FIRST_TOKEN;
|
||||
this._headerSize = 0;
|
||||
yield { type: constants.END };
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw errors.INVALID_MESSAGE();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.constants = constants;
|
||||
var TOKEN_BYTES = Buffer.from([
|
||||
// 0x00-0x1f (control characters) + 0x20 (space)
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
// 0x21-0x41: ! " # $ % & ' ( ) * + , - . / 0-9 : ; < = > ? @ A
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
// 0x42-0x62: B-Z [ \ ] ^ _ ` a b
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
// 0x63-0x7f: c-z { | } ~ DEL
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0
|
||||
]);
|
||||
function isTokenByte(b) {
|
||||
return TOKEN_BYTES[b] === 1;
|
||||
}
|
||||
function isFieldByte(b) {
|
||||
return b === TAB || b >= 32 && b <= 126;
|
||||
}
|
||||
function isHex(b) {
|
||||
return b >= ZERO && b <= NINE || b >= UPPER_A && b <= UPPER_F || b >= LOWER_A && b <= LOWER_F;
|
||||
}
|
||||
function hexValue(b) {
|
||||
if (b >= ZERO && b <= NINE) return b - ZERO;
|
||||
if (b >= UPPER_A && b <= UPPER_F) return b - UPPER_A + 10;
|
||||
return b - LOWER_A + 10;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareHttpParser.js
|
||||
var bare_lib_entry_bareHttpParser_exports = {};
|
||||
__export(bare_lib_entry_bareHttpParser_exports, {
|
||||
default: () => bare_lib_entry_bareHttpParser_default
|
||||
});
|
||||
var import_bare_http_parser = __toESM(require_bare_http_parser());
|
||||
var bare_lib_entry_bareHttpParser_default = import_bare_http_parser.default;
|
||||
return __toCommonJS(bare_lib_entry_bareHttpParser_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareHttpParser"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,77 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-ico/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-ico/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-ico/index.js
|
||||
var require_bare_ico = __commonJS({
|
||||
"../../node_modules/bare-ico/index.js"(exports) {
|
||||
var binding = require_binding();
|
||||
exports.decode = function decode(ico, opts = {}) {
|
||||
const result = binding.decode(ico, opts);
|
||||
return {
|
||||
width: result.width,
|
||||
height: result.height,
|
||||
data: Buffer.from(result.data),
|
||||
sizes: result.sizes
|
||||
};
|
||||
};
|
||||
exports.encode = function encode(rgba, opts = {}) {
|
||||
throw new Error("ICO encoding not yet implemented");
|
||||
};
|
||||
exports.encodeAnimated = function encodeAnimated(frames, opts = {}) {
|
||||
throw new Error("Animated ICO not supported");
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareIco.js
|
||||
var bare_lib_entry_bareIco_exports = {};
|
||||
__export(bare_lib_entry_bareIco_exports, {
|
||||
default: () => bare_lib_entry_bareIco_default
|
||||
});
|
||||
var import_bare_ico = __toESM(require_bare_ico());
|
||||
var bare_lib_entry_bareIco_default = import_bare_ico.default;
|
||||
return __toCommonJS(bare_lib_entry_bareIco_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareIco"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
@@ -0,0 +1,88 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-image-resample/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-image-resample/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-image-resample/index.js
|
||||
var require_bare_image_resample = __commonJS({
|
||||
"../../node_modules/bare-image-resample/index.js"(exports) {
|
||||
var binding = require_binding();
|
||||
exports.resize = function resize(image, width = 0, height = 0, opts = {}) {
|
||||
if (typeof width === "object") {
|
||||
opts = width;
|
||||
width = opts.width || 0;
|
||||
height = opts.height || 0;
|
||||
}
|
||||
let scale = opts.scale || 1;
|
||||
if (width) scale = width / image.width;
|
||||
else if (height) scale = height / image.height;
|
||||
if (width <= 0) width = image.width * scale;
|
||||
if (height <= 0) height = image.height * scale;
|
||||
width = Math.round(width);
|
||||
height = Math.round(height);
|
||||
const buffer = binding.resize(
|
||||
image.data,
|
||||
image.width,
|
||||
image.height,
|
||||
width,
|
||||
height
|
||||
);
|
||||
return {
|
||||
data: Buffer.from(buffer),
|
||||
width,
|
||||
height
|
||||
};
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareImageResample.js
|
||||
var bare_lib_entry_bareImageResample_exports = {};
|
||||
__export(bare_lib_entry_bareImageResample_exports, {
|
||||
default: () => bare_lib_entry_bareImageResample_default
|
||||
});
|
||||
var import_bare_image_resample = __toESM(require_bare_image_resample());
|
||||
var bare_lib_entry_bareImageResample_default = import_bare_image_resample.default;
|
||||
return __toCommonJS(bare_lib_entry_bareImageResample_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareImageResample"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,83 @@
|
||||
var __bare_os_bundle_exports__ = (() => {
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined") return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
var __commonJS = (cb, mod) => function __require2() {
|
||||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||
};
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// ../../node_modules/bare-jpeg/binding.js
|
||||
var require_binding = __commonJS({
|
||||
"../../node_modules/bare-jpeg/binding.js"(exports, module) {
|
||||
module.exports = __require.addon();
|
||||
}
|
||||
});
|
||||
|
||||
// ../../node_modules/bare-jpeg/index.js
|
||||
var require_bare_jpeg = __commonJS({
|
||||
"../../node_modules/bare-jpeg/index.js"(exports) {
|
||||
var binding = require_binding();
|
||||
exports.decode = function decode(image) {
|
||||
const { width, height, data } = binding.decode(image);
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
data: Buffer.from(data)
|
||||
};
|
||||
};
|
||||
exports.encode = function encode(image, opts = {}) {
|
||||
const { quality = 90 } = opts;
|
||||
const buffer = binding.encode(
|
||||
image.data,
|
||||
image.width,
|
||||
image.height,
|
||||
clamp(quality, 0, 100)
|
||||
);
|
||||
return Buffer.from(buffer);
|
||||
};
|
||||
function clamp(value, min, max) {
|
||||
return Math.max(min, Math.min(max, value));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ../../bare-lib-entry-bareJpeg.js
|
||||
var bare_lib_entry_bareJpeg_exports = {};
|
||||
__export(bare_lib_entry_bareJpeg_exports, {
|
||||
default: () => bare_lib_entry_bareJpeg_default
|
||||
});
|
||||
var import_bare_jpeg = __toESM(require_bare_jpeg());
|
||||
var bare_lib_entry_bareJpeg_default = import_bare_jpeg.default;
|
||||
return __toCommonJS(bare_lib_entry_bareJpeg_exports);
|
||||
})();
|
||||
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};g[s]["bareJpeg"]=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;})();
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user