337 lines
12 KiB
JavaScript
337 lines
12 KiB
JavaScript
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
|
|
};
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/z32/index.js
|
|
var require_z32 = __commonJS({
|
|
"../../node_modules/z32/index.js"(exports) {
|
|
var b4a = require_b4a();
|
|
var ALPHABET = "ybndrfg8ejkmcpqxot1uwisza345h769";
|
|
var MIN = 49;
|
|
var MAX = 122;
|
|
var REVERSE = new Int8Array(1 + MAX - MIN);
|
|
REVERSE.fill(-1);
|
|
for (let i = 0; i < ALPHABET.length; i++) {
|
|
const v = ALPHABET.charCodeAt(i) - MIN;
|
|
REVERSE[v] = i;
|
|
}
|
|
exports.encode = encode;
|
|
exports.decode = decode;
|
|
exports.ALPHABET = ALPHABET;
|
|
function decode(s, out) {
|
|
let pb = 0;
|
|
let ps = 0;
|
|
const r = s.length & 7;
|
|
const q = (s.length - r) / 8;
|
|
if (!out) out = b4a.allocUnsafe(Math.ceil(s.length * 5 / 8));
|
|
for (let i = 0; i < q; i++) {
|
|
const a2 = quintet(s, ps++);
|
|
const b2 = quintet(s, ps++);
|
|
const c2 = quintet(s, ps++);
|
|
const d2 = quintet(s, ps++);
|
|
const e2 = quintet(s, ps++);
|
|
const f2 = quintet(s, ps++);
|
|
const g2 = quintet(s, ps++);
|
|
const h2 = quintet(s, ps++);
|
|
out[pb++] = a2 << 3 | b2 >>> 2;
|
|
out[pb++] = (b2 & 3) << 6 | c2 << 1 | d2 >>> 4;
|
|
out[pb++] = (d2 & 15) << 4 | e2 >>> 1;
|
|
out[pb++] = (e2 & 1) << 7 | f2 << 2 | g2 >>> 3;
|
|
out[pb++] = (g2 & 7) << 5 | h2;
|
|
}
|
|
if (r === 0) return out.subarray(0, pb);
|
|
const a = quintet(s, ps++);
|
|
const b = quintet(s, ps++);
|
|
out[pb++] = a << 3 | b >>> 2;
|
|
if (r <= 2) return out.subarray(0, pb);
|
|
const c = quintet(s, ps++);
|
|
const d = quintet(s, ps++);
|
|
out[pb++] = (b & 3) << 6 | c << 1 | d >>> 4;
|
|
if (r <= 4) return out.subarray(0, pb);
|
|
const e = quintet(s, ps++);
|
|
out[pb++] = (d & 15) << 4 | e >>> 1;
|
|
if (r <= 5) return out.subarray(0, pb);
|
|
const f = quintet(s, ps++);
|
|
const g = quintet(s, ps++);
|
|
out[pb++] = (e & 1) << 7 | f << 2 | g >>> 3;
|
|
if (r <= 7) return out.subarray(0, pb);
|
|
const h = quintet(s, ps++);
|
|
out[pb++] = (g & 7) << 5 | h;
|
|
return out.subarray(0, pb);
|
|
}
|
|
function encode(buf) {
|
|
if (typeof buf === "string") buf = b4a.from(buf);
|
|
const max = buf.byteLength * 8;
|
|
let s = "";
|
|
for (let p = 0; p < max; p += 5) {
|
|
const i = p >>> 3;
|
|
const j = p & 7;
|
|
if (j <= 3) {
|
|
s += ALPHABET[buf[i] >>> 3 - j & 31];
|
|
continue;
|
|
}
|
|
const of = j - 3;
|
|
const h = buf[i] << of & 31;
|
|
const l = (i >= buf.byteLength ? 0 : buf[i + 1]) >>> 8 - of;
|
|
s += ALPHABET[h | l];
|
|
}
|
|
return s;
|
|
}
|
|
function quintet(s, i) {
|
|
if (i > s.length) {
|
|
return 0;
|
|
}
|
|
const v = s.charCodeAt(i);
|
|
if (v < MIN || v > MAX) {
|
|
throw Error('Invalid character in base32 input: "' + s[i] + '" at position ' + i);
|
|
}
|
|
const bits = REVERSE[v - MIN];
|
|
if (bits === -1) {
|
|
throw Error('Invalid character in base32 input: "' + s[i] + '" at position ' + i);
|
|
}
|
|
return bits;
|
|
}
|
|
}
|
|
});
|
|
|
|
// ../../node_modules/hypercore-id-encoding/index.js
|
|
var require_hypercore_id_encoding = __commonJS({
|
|
"../../node_modules/hypercore-id-encoding/index.js"(exports, module) {
|
|
var z32 = require_z32();
|
|
var b4a = require_b4a();
|
|
module.exports = {
|
|
encode,
|
|
decode,
|
|
normalize,
|
|
isValid
|
|
};
|
|
function encode(key) {
|
|
if (!b4a.isBuffer(key)) throw new Error("Key must be a Buffer");
|
|
if (key.byteLength !== 32) throw new Error("Key must be 32-bytes long");
|
|
return z32.encode(key);
|
|
}
|
|
function decode(id) {
|
|
if (b4a.isBuffer(id)) {
|
|
if (id.byteLength !== 32) throw new Error("ID must be 32-bytes long");
|
|
return id;
|
|
}
|
|
if (typeof id === "string") {
|
|
if (id.startsWith("pear://")) id = id.slice(7).split("/")[0];
|
|
if (id.length === 52) return z32.decode(id);
|
|
if (id.length === 64) {
|
|
const buf = b4a.from(id, "hex");
|
|
if (buf.byteLength === 32) return buf;
|
|
}
|
|
}
|
|
throw new Error("Invalid Hypercore key");
|
|
}
|
|
function normalize(any) {
|
|
return encode(decode(any));
|
|
}
|
|
function isValid(any) {
|
|
try {
|
|
decode(any);
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// ../../bare-lib-entry-hypercoreIdEncoding.js
|
|
var bare_lib_entry_hypercoreIdEncoding_exports = {};
|
|
__export(bare_lib_entry_hypercoreIdEncoding_exports, {
|
|
default: () => bare_lib_entry_hypercoreIdEncoding_default
|
|
});
|
|
var import_hypercore_id_encoding = __toESM(require_hypercore_id_encoding());
|
|
var bare_lib_entry_hypercoreIdEncoding_default = import_hypercore_id_encoding.default;
|
|
return __toCommonJS(bare_lib_entry_hypercoreIdEncoding_exports);
|
|
})();
|
|
;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};var e=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;var v=e!=null&&typeof e==="object"&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;g[s]["hypercoreIdEncoding"]=v;})();
|