UNPKG

@jimpick/fireproof-partykit

Version:

PartyKit gateway for Fireproof

1,539 lines (1,520 loc) 144 kB
"use strict"; var Connect = (() => { 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, from2, except, desc) => { if (from2 && typeof from2 === "object" || typeof from2 === "function") { for (let key of __getOwnPropNames(from2)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, 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/.pnpm/ws@8.18.0/node_modules/ws/browser.js var require_browser = __commonJS({ "node_modules/.pnpm/ws@8.18.0/node_modules/ws/browser.js"(exports, module) { "use strict"; module.exports = function() { throw new Error( "ws does not work in the browser. Browser clients must use the native WebSocket object" ); }; } }); // src/partykit/index.ts var partykit_exports = {}; __export(partykit_exports, { connect: () => connect }); // node_modules/.pnpm/@adviser+cement@0.2.41_typescript@5.7.2/node_modules/@adviser/cement/chunk-GES3MUGV.js var __defProp2 = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp2 = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __typeError = (msg) => { throw TypeError(msg); }; var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp2.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); var __export2 = (target, all) => { for (var name in all) __defProp2(target, name, { get: all[name], enumerable: true }); }; var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg); var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)); var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value); var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value); var encoder = new TextEncoder(); var decoder = new TextDecoder(); var Utf8EnDecoder = class { encode(str) { return encoder.encode(str); } decode(data) { return decoder.decode(data); } }; var utf8EnDecoder = new Utf8EnDecoder(); function Utf8EnDecoderSingleton() { return utf8EnDecoder; } // node_modules/.pnpm/@adviser+cement@0.2.41_typescript@5.7.2/node_modules/@adviser/cement/chunk-USQXEZHL.js var utils_exports = {}; __export2(utils_exports, { ConsoleWriterStream: () => ConsoleWriterStream, ConsoleWriterStreamDefaultWriter: () => ConsoleWriterStreamDefaultWriter, FanoutWriteStream: () => FanoutWriteStream, array2stream: () => array2stream, devnull: () => devnull, rebuffer: () => rebuffer, rebufferArray: () => rebufferArray, stream2array: () => stream2array, stream2string: () => stream2string, stream2uint8array: () => stream2uint8array, streamMap: () => streamMap, string2stream: () => string2stream, uint8array2stream: () => uint8array2stream }); function streamMap(s, sm) { const state = { reader: s.getReader(), streamMap: sm, idx: 0 }; return new ReadableStream({ async pull(controller) { const { done, value } = await state.reader.read(); if (done) { if (state.streamMap.Close) { state.streamMap.Close(); } controller.close(); return; } const promiseOrU = state.streamMap.Map(value, state.idx++); let mapped; if (promiseOrU instanceof Promise || typeof promiseOrU.then === "function") { mapped = await promiseOrU; } else { mapped = promiseOrU; } controller.enqueue(mapped); } }); } async function devnull(a) { const reader = a.getReader(); let cnt = 0; while (true) { const { done } = await reader.read(); if (done) { break; } cnt++; } return cnt; } function array2stream(a) { let i = 0; return new ReadableStream({ pull(controller) { if (i >= a.length) { controller.close(); return; } controller.enqueue(a[i]); i++; } }); } async function stream2array(a) { const ret = []; const reader = a.getReader(); while (true) { const { done, value } = await reader.read(); if (done) { break; } ret.push(value); } return ret; } async function rebufferArray(a, chunkSize) { return stream2array(rebuffer(array2stream(a), chunkSize)); } function reChunk(cs, chunkSize) { const len = cs.reduce((acc, v) => acc + v.length, 0); const last = cs[cs.length - 1]; const lastOfs = len - last.length; const rest = last.subarray(chunkSize - lastOfs); cs[cs.length - 1] = last.subarray(0, chunkSize - lastOfs); const chunk = new Uint8Array(chunkSize); let ofs = 0; for (const c of cs) { chunk.set(c, ofs); ofs += c.length; } return { rest, chunk }; } function pump(ps, controller, next) { ps.reader.read().then(({ done, value }) => { if (done) { if (ps.tmpLen > 0) { controller.enqueue(reChunk(ps.tmp, ps.tmpLen).chunk); } controller.close(); next(); return; } if (ps.tmpLen + value.length > ps.chunkSize) { ps.tmp.push(value); const res = reChunk(ps.tmp, ps.chunkSize); controller.enqueue(res.chunk); ps.tmp = [res.rest]; ps.tmpLen = res.rest.length; next(); return; } else if (value.length) { ps.tmp.push(value); ps.tmpLen += value.length; } pump(ps, controller, next); }); } function rebuffer(a, chunkSize) { const state = { reader: a.getReader(), tmp: [], tmpLen: 0, chunkSize }; return new ReadableStream({ async pull(controller) { return new Promise((resolve) => { pump(state, controller, resolve); }); } }); } async function stream2string(stream, maxSize) { if (!stream) { return Promise.resolve(""); } const reader = stream.getReader(); let res = ""; const decoder2 = new TextDecoder(); let rSize = 0; while (typeof maxSize === "undefined" || rSize < maxSize) { try { const read = await reader.read(); if (read.done) { break; } if (maxSize && rSize + read.value.length > maxSize) { read.value = read.value.slice(0, maxSize - rSize); } const block = decoder2.decode(read.value, { stream: true }); rSize += read.value.length; res += block; } catch (err2) { return Promise.reject(err2); } } return Promise.resolve(res); } async function stream2uint8array(stream) { if (!stream) { return Promise.resolve(new Uint8Array()); } const reader = stream.getReader(); let res = new Uint8Array(); while (1) { try { const { done, value } = await reader.read(); if (done) { break; } res = new Uint8Array([...res, ...value]); } catch (err2) { return Promise.reject(err2); } } return Promise.resolve(res); } function string2stream(str, ende = Utf8EnDecoderSingleton()) { return uint8array2stream(ende.encode(str)); } function uint8array2stream(str) { return new ReadableStream({ start(controller) { controller.enqueue(str); controller.close(); } }); } var ConsoleWriterStreamDefaultWriter = class { constructor(stream) { this.stream = stream; this.desiredSize = null; this.decoder = new TextDecoder(); this._stream = stream; this.ready = Promise.resolve(void 0); this.closed = Promise.resolve(void 0); } // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any abort(reason) { throw new Error("Method not implemented."); } async close() { } releaseLock() { this._stream.locked = false; this.ready = Promise.resolve(void 0); this.closed = Promise.resolve(void 0); } async write(chunk) { let strObj = this.decoder.decode(chunk).trimEnd(); let output = "log"; try { strObj = JSON.parse(strObj); output = strObj.level; } catch (e) { } switch (output) { case "error": console.error(strObj); break; case "warn": console.warn(strObj); break; default: console.log(strObj); } } }; var ConsoleWriterStream = class { constructor() { this.locked = false; } // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars abort(reason) { throw new Error("Method not implemented."); } async close() { return; } getWriter() { if (this.locked) { throw new Error("Stream is locked"); } this.locked = true; if (!this._writer) { this._writer = new ConsoleWriterStreamDefaultWriter(this); } return this._writer; } }; var FanoutWriteStream = class { constructor(writers) { this.desiredSize = null; this._writers = writers; this.ready = Promise.all(this._writers.map((w) => w.ready)).then(() => void 0); this.closed = Promise.all(this._writers.map((w) => w.closed)).then(() => void 0); } // eslint-disable-next-line @typescript-eslint/no-explicit-any abort(reason) { return Promise.all(this._writers.map((w) => w.abort(reason))).then(() => { }); } close() { return Promise.all(this._writers.map((w) => w.close())).then(() => { }); } releaseLock() { this._writers.map((w) => w.releaseLock()); } write(chunk) { return Promise.all(this._writers.map((w) => w.write(chunk))).then(() => { }); } }; // node_modules/.pnpm/@adviser+cement@0.2.41_typescript@5.7.2/node_modules/@adviser/cement/chunk-F5W6VELE.js var _promise; var _resolveFn; var _rejectFn; var Future = class { constructor() { __privateAdd(this, _promise); __privateAdd(this, _resolveFn, () => { throw new Error("This Promise is not working as expected."); }); __privateAdd(this, _rejectFn, () => { throw new Error("This Promise is not working as expected."); }); __privateSet(this, _promise, new Promise((resolve, reject) => { __privateSet(this, _resolveFn, resolve); __privateSet(this, _rejectFn, reject); })); } async asPromise() { return __privateGet(this, _promise); } resolve(value) { __privateGet(this, _resolveFn).call(this, value); } reject(reason) { __privateGet(this, _rejectFn).call(this, reason); } }; _promise = /* @__PURE__ */ new WeakMap(); _resolveFn = /* @__PURE__ */ new WeakMap(); _rejectFn = /* @__PURE__ */ new WeakMap(); var ResolveOnce = class { constructor(ctx) { this._onceDone = false; this._onceFutures = []; this._onceOk = false; this._isPromise = false; this.ctx = ctx; } get ready() { return this._onceDone; } reset() { this._onceDone = false; this._onceOk = false; this._onceValue = void 0; this._onceError = void 0; this._onceFutures.length = 0; } // T extends Option<infer U> ? U : T once(fn) { if (this._onceDone) { if (this._onceError) { if (this._isPromise) { return Promise.reject(this._onceError); } else { throw this._onceError; } } if (this._onceOk) { if (this._isPromise) { return Promise.resolve(this._onceValue); } else { return this._onceValue; } } throw new Error("ResolveOnce.once impossible"); } const future = new Future(); this._onceFutures.push(future); if (this._onceFutures.length === 1) { const okFn = (value) => { this._onceValue = value; this._onceOk = true; this._onceDone = true; if (this._isPromise) { this._onceFutures.forEach((f) => f.resolve(this._onceValue)); } this._onceFutures.length = 0; }; const catchFn = (e) => { this._onceError = e; this._onceOk = false; this._onceValue = void 0; this._onceDone = true; if (this._isPromise) { this._onceFutures.forEach((f) => f.reject(this._onceError)); } this._onceFutures.length = 0; }; try { const ret = fn(this.ctx); if (typeof ret.then === "function") { this._isPromise = true; ret.then(okFn).catch(catchFn); } else { okFn(ret); } } catch (e) { catchFn(e); } } if (this._isPromise) { return future.asPromise(); } else { return this.once(fn); } } }; var Keyed = class { constructor(factory) { this._map = /* @__PURE__ */ new Map(); this.factory = factory; } async asyncGet(key) { return this.get(await key()); } get(key) { if (typeof key === "function") { key = key(); } let keyed = this._map.get(key); if (!keyed) { keyed = this.factory(key); this._map.set(key, keyed); } return keyed; } unget(key) { const keyed = this._map.get(key); keyed == null ? void 0 : keyed.reset(); this._map.delete(key); } reset() { this._map.forEach((keyed) => keyed.reset()); this._map.clear(); } }; var KeyedResolvOnce = class extends Keyed { constructor() { super((key) => new ResolveOnce(key)); } }; var _node; _node = /* @__PURE__ */ new WeakMap(); var _deno; _deno = /* @__PURE__ */ new WeakMap(); var _envFactory = new ResolveOnce(); // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/nodes/identity.js var ALIAS = Symbol.for("yaml.alias"); var DOC = Symbol.for("yaml.document"); var MAP = Symbol.for("yaml.map"); var PAIR = Symbol.for("yaml.pair"); var SCALAR = Symbol.for("yaml.scalar"); var SEQ = Symbol.for("yaml.seq"); var NODE_TYPE = Symbol.for("yaml.node.type"); var isAlias = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === ALIAS; var isDocument = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === DOC; var isMap = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === MAP; var isPair = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === PAIR; var isScalar = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === SCALAR; var isSeq = (node) => !!node && typeof node === "object" && node[NODE_TYPE] === SEQ; function isCollection(node) { if (node && typeof node === "object") switch (node[NODE_TYPE]) { case MAP: case SEQ: return true; } return false; } function isNode(node) { if (node && typeof node === "object") switch (node[NODE_TYPE]) { case ALIAS: case MAP: case SCALAR: case SEQ: return true; } return false; } var hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor; // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/visit.js var BREAK = Symbol("break visit"); var SKIP = Symbol("skip children"); var REMOVE = Symbol("remove node"); function visit(node, visitor) { const visitor_ = initVisitor(visitor); if (isDocument(node)) { const cd = visit_(null, node.contents, visitor_, Object.freeze([node])); if (cd === REMOVE) node.contents = null; } else visit_(null, node, visitor_, Object.freeze([])); } visit.BREAK = BREAK; visit.SKIP = SKIP; visit.REMOVE = REMOVE; function visit_(key, node, visitor, path) { const ctrl = callVisitor(key, node, visitor, path); if (isNode(ctrl) || isPair(ctrl)) { replaceNode(key, path, ctrl); return visit_(key, ctrl, visitor, path); } if (typeof ctrl !== "symbol") { if (isCollection(node)) { path = Object.freeze(path.concat(node)); for (let i = 0; i < node.items.length; ++i) { const ci = visit_(i, node.items[i], visitor, path); if (typeof ci === "number") i = ci - 1; else if (ci === BREAK) return BREAK; else if (ci === REMOVE) { node.items.splice(i, 1); i -= 1; } } } else if (isPair(node)) { path = Object.freeze(path.concat(node)); const ck = visit_("key", node.key, visitor, path); if (ck === BREAK) return BREAK; else if (ck === REMOVE) node.key = null; const cv = visit_("value", node.value, visitor, path); if (cv === BREAK) return BREAK; else if (cv === REMOVE) node.value = null; } } return ctrl; } async function visitAsync(node, visitor) { const visitor_ = initVisitor(visitor); if (isDocument(node)) { const cd = await visitAsync_(null, node.contents, visitor_, Object.freeze([node])); if (cd === REMOVE) node.contents = null; } else await visitAsync_(null, node, visitor_, Object.freeze([])); } visitAsync.BREAK = BREAK; visitAsync.SKIP = SKIP; visitAsync.REMOVE = REMOVE; async function visitAsync_(key, node, visitor, path) { const ctrl = await callVisitor(key, node, visitor, path); if (isNode(ctrl) || isPair(ctrl)) { replaceNode(key, path, ctrl); return visitAsync_(key, ctrl, visitor, path); } if (typeof ctrl !== "symbol") { if (isCollection(node)) { path = Object.freeze(path.concat(node)); for (let i = 0; i < node.items.length; ++i) { const ci = await visitAsync_(i, node.items[i], visitor, path); if (typeof ci === "number") i = ci - 1; else if (ci === BREAK) return BREAK; else if (ci === REMOVE) { node.items.splice(i, 1); i -= 1; } } } else if (isPair(node)) { path = Object.freeze(path.concat(node)); const ck = await visitAsync_("key", node.key, visitor, path); if (ck === BREAK) return BREAK; else if (ck === REMOVE) node.key = null; const cv = await visitAsync_("value", node.value, visitor, path); if (cv === BREAK) return BREAK; else if (cv === REMOVE) node.value = null; } } return ctrl; } function initVisitor(visitor) { if (typeof visitor === "object" && (visitor.Collection || visitor.Node || visitor.Value)) { return Object.assign({ Alias: visitor.Node, Map: visitor.Node, Scalar: visitor.Node, Seq: visitor.Node }, visitor.Value && { Map: visitor.Value, Scalar: visitor.Value, Seq: visitor.Value }, visitor.Collection && { Map: visitor.Collection, Seq: visitor.Collection }, visitor); } return visitor; } function callVisitor(key, node, visitor, path) { if (typeof visitor === "function") return visitor(key, node, path); if (isMap(node)) return visitor.Map?.(key, node, path); if (isSeq(node)) return visitor.Seq?.(key, node, path); if (isPair(node)) return visitor.Pair?.(key, node, path); if (isScalar(node)) return visitor.Scalar?.(key, node, path); if (isAlias(node)) return visitor.Alias?.(key, node, path); return void 0; } function replaceNode(key, path, node) { const parent = path[path.length - 1]; if (isCollection(parent)) { parent.items[key] = node; } else if (isPair(parent)) { if (key === "key") parent.key = node; else parent.value = node; } else if (isDocument(parent)) { parent.contents = node; } else { const pt = isAlias(parent) ? "alias" : "scalar"; throw new Error(`Cannot replace node with ${pt} parent`); } } // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/doc/directives.js var escapeChars = { "!": "%21", ",": "%2C", "[": "%5B", "]": "%5D", "{": "%7B", "}": "%7D" }; var escapeTagName = (tn) => tn.replace(/[!,[\]{}]/g, (ch) => escapeChars[ch]); var Directives = class _Directives { constructor(yaml, tags) { this.docStart = null; this.docEnd = false; this.yaml = Object.assign({}, _Directives.defaultYaml, yaml); this.tags = Object.assign({}, _Directives.defaultTags, tags); } clone() { const copy = new _Directives(this.yaml, this.tags); copy.docStart = this.docStart; return copy; } /** * During parsing, get a Directives instance for the current document and * update the stream state according to the current version's spec. */ atDocument() { const res = new _Directives(this.yaml, this.tags); switch (this.yaml.version) { case "1.1": this.atNextDocument = true; break; case "1.2": this.atNextDocument = false; this.yaml = { explicit: _Directives.defaultYaml.explicit, version: "1.2" }; this.tags = Object.assign({}, _Directives.defaultTags); break; } return res; } /** * @param onError - May be called even if the action was successful * @returns `true` on success */ add(line, onError) { if (this.atNextDocument) { this.yaml = { explicit: _Directives.defaultYaml.explicit, version: "1.1" }; this.tags = Object.assign({}, _Directives.defaultTags); this.atNextDocument = false; } const parts = line.trim().split(/[ \t]+/); const name = parts.shift(); switch (name) { case "%TAG": { if (parts.length !== 2) { onError(0, "%TAG directive should contain exactly two parts"); if (parts.length < 2) return false; } const [handle, prefix] = parts; this.tags[handle] = prefix; return true; } case "%YAML": { this.yaml.explicit = true; if (parts.length !== 1) { onError(0, "%YAML directive should contain exactly one part"); return false; } const [version] = parts; if (version === "1.1" || version === "1.2") { this.yaml.version = version; return true; } else { const isValid = /^\d+\.\d+$/.test(version); onError(6, `Unsupported YAML version ${version}`, isValid); return false; } } default: onError(0, `Unknown directive ${name}`, true); return false; } } /** * Resolves a tag, matching handles to those defined in %TAG directives. * * @returns Resolved tag, which may also be the non-specific tag `'!'` or a * `'!local'` tag, or `null` if unresolvable. */ tagName(source, onError) { if (source === "!") return "!"; if (source[0] !== "!") { onError(`Not a valid tag: ${source}`); return null; } if (source[1] === "<") { const verbatim = source.slice(2, -1); if (verbatim === "!" || verbatim === "!!") { onError(`Verbatim tags aren't resolved, so ${source} is invalid.`); return null; } if (source[source.length - 1] !== ">") onError("Verbatim tags must end with a >"); return verbatim; } const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/s); if (!suffix) onError(`The ${source} tag has no suffix`); const prefix = this.tags[handle]; if (prefix) { try { return prefix + decodeURIComponent(suffix); } catch (error) { onError(String(error)); return null; } } if (handle === "!") return source; onError(`Could not resolve tag: ${source}`); return null; } /** * Given a fully resolved tag, returns its printable string form, * taking into account current tag prefixes and defaults. */ tagString(tag) { for (const [handle, prefix] of Object.entries(this.tags)) { if (tag.startsWith(prefix)) return handle + escapeTagName(tag.substring(prefix.length)); } return tag[0] === "!" ? tag : `!<${tag}>`; } toString(doc) { const lines = this.yaml.explicit ? [`%YAML ${this.yaml.version || "1.2"}`] : []; const tagEntries = Object.entries(this.tags); let tagNames; if (doc && tagEntries.length > 0 && isNode(doc.contents)) { const tags = {}; visit(doc.contents, (_key, node) => { if (isNode(node) && node.tag) tags[node.tag] = true; }); tagNames = Object.keys(tags); } else tagNames = []; for (const [handle, prefix] of tagEntries) { if (handle === "!!" && prefix === "tag:yaml.org,2002:") continue; if (!doc || tagNames.some((tn) => tn.startsWith(prefix))) lines.push(`%TAG ${handle} ${prefix}`); } return lines.join("\n"); } }; Directives.defaultYaml = { explicit: false, version: "1.2" }; Directives.defaultTags = { "!!": "tag:yaml.org,2002:" }; // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/doc/anchors.js function anchorIsValid(anchor) { if (/[\x00-\x19\s,[\]{}]/.test(anchor)) { const sa = JSON.stringify(anchor); const msg = `Anchor must not contain whitespace or control characters: ${sa}`; throw new Error(msg); } return true; } // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/doc/applyReviver.js function applyReviver(reviver, obj, key, val) { if (val && typeof val === "object") { if (Array.isArray(val)) { for (let i = 0, len = val.length; i < len; ++i) { const v0 = val[i]; const v1 = applyReviver(reviver, val, String(i), v0); if (v1 === void 0) delete val[i]; else if (v1 !== v0) val[i] = v1; } } else if (val instanceof Map) { for (const k of Array.from(val.keys())) { const v0 = val.get(k); const v1 = applyReviver(reviver, val, k, v0); if (v1 === void 0) val.delete(k); else if (v1 !== v0) val.set(k, v1); } } else if (val instanceof Set) { for (const v0 of Array.from(val)) { const v1 = applyReviver(reviver, val, v0, v0); if (v1 === void 0) val.delete(v0); else if (v1 !== v0) { val.delete(v0); val.add(v1); } } } else { for (const [k, v0] of Object.entries(val)) { const v1 = applyReviver(reviver, val, k, v0); if (v1 === void 0) delete val[k]; else if (v1 !== v0) val[k] = v1; } } } return reviver.call(obj, key, val); } // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/nodes/toJS.js function toJS(value, arg, ctx) { if (Array.isArray(value)) return value.map((v, i) => toJS(v, String(i), ctx)); if (value && typeof value.toJSON === "function") { if (!ctx || !hasAnchor(value)) return value.toJSON(arg, ctx); const data = { aliasCount: 0, count: 1, res: void 0 }; ctx.anchors.set(value, data); ctx.onCreate = (res2) => { data.res = res2; delete ctx.onCreate; }; const res = value.toJSON(arg, ctx); if (ctx.onCreate) ctx.onCreate(res); return res; } if (typeof value === "bigint" && !ctx?.keep) return Number(value); return value; } // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/nodes/Node.js var NodeBase = class { constructor(type) { Object.defineProperty(this, NODE_TYPE, { value: type }); } /** Create a copy of this node. */ clone() { const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this)); if (this.range) copy.range = this.range.slice(); return copy; } /** A plain JavaScript representation of this node. */ toJS(doc, { mapAsMap, maxAliasCount, onAnchor, reviver } = {}) { if (!isDocument(doc)) throw new TypeError("A document argument is required"); const ctx = { anchors: /* @__PURE__ */ new Map(), doc, keep: true, mapAsMap: mapAsMap === true, mapKeyWarned: false, maxAliasCount: typeof maxAliasCount === "number" ? maxAliasCount : 100 }; const res = toJS(this, "", ctx); if (typeof onAnchor === "function") for (const { count, res: res2 } of ctx.anchors.values()) onAnchor(res2, count); return typeof reviver === "function" ? applyReviver(reviver, { "": res }, "", res) : res; } }; // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/nodes/Alias.js var Alias = class extends NodeBase { constructor(source) { super(ALIAS); this.source = source; Object.defineProperty(this, "tag", { set() { throw new Error("Alias nodes cannot have tags"); } }); } /** * Resolve the value of this alias within `doc`, finding the last * instance of the `source` anchor before this node. */ resolve(doc) { let found = void 0; visit(doc, { Node: (_key, node) => { if (node === this) return visit.BREAK; if (node.anchor === this.source) found = node; } }); return found; } toJSON(_arg, ctx) { if (!ctx) return { source: this.source }; const { anchors, doc, maxAliasCount } = ctx; const source = this.resolve(doc); if (!source) { const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`; throw new ReferenceError(msg); } let data = anchors.get(source); if (!data) { toJS(source, null, ctx); data = anchors.get(source); } if (!data || data.res === void 0) { const msg = "This should not happen: Alias anchor was not resolved?"; throw new ReferenceError(msg); } if (maxAliasCount >= 0) { data.count += 1; if (data.aliasCount === 0) data.aliasCount = getAliasCount(doc, source, anchors); if (data.count * data.aliasCount > maxAliasCount) { const msg = "Excessive alias count indicates a resource exhaustion attack"; throw new ReferenceError(msg); } } return data.res; } toString(ctx, _onComment, _onChompKeep) { const src = `*${this.source}`; if (ctx) { anchorIsValid(this.source); if (ctx.options.verifyAliasOrder && !ctx.anchors.has(this.source)) { const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`; throw new Error(msg); } if (ctx.implicitKey) return `${src} `; } return src; } }; function getAliasCount(doc, node, anchors) { if (isAlias(node)) { const source = node.resolve(doc); const anchor = anchors && source && anchors.get(source); return anchor ? anchor.count * anchor.aliasCount : 0; } else if (isCollection(node)) { let count = 0; for (const item of node.items) { const c = getAliasCount(doc, item, anchors); if (c > count) count = c; } return count; } else if (isPair(node)) { const kc = getAliasCount(doc, node.key, anchors); const vc = getAliasCount(doc, node.value, anchors); return Math.max(kc, vc); } return 1; } // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/nodes/Scalar.js var isScalarValue = (value) => !value || typeof value !== "function" && typeof value !== "object"; var Scalar = class extends NodeBase { constructor(value) { super(SCALAR); this.value = value; } toJSON(arg, ctx) { return ctx?.keep ? this.value : toJS(this.value, arg, ctx); } toString() { return String(this.value); } }; Scalar.BLOCK_FOLDED = "BLOCK_FOLDED"; Scalar.BLOCK_LITERAL = "BLOCK_LITERAL"; Scalar.PLAIN = "PLAIN"; Scalar.QUOTE_DOUBLE = "QUOTE_DOUBLE"; Scalar.QUOTE_SINGLE = "QUOTE_SINGLE"; // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/doc/createNode.js var defaultTagPrefix = "tag:yaml.org,2002:"; function findTagObject(value, tagName, tags) { if (tagName) { const match = tags.filter((t) => t.tag === tagName); const tagObj = match.find((t) => !t.format) ?? match[0]; if (!tagObj) throw new Error(`Tag ${tagName} not found`); return tagObj; } return tags.find((t) => t.identify?.(value) && !t.format); } function createNode(value, tagName, ctx) { if (isDocument(value)) value = value.contents; if (isNode(value)) return value; if (isPair(value)) { const map2 = ctx.schema[MAP].createNode?.(ctx.schema, null, ctx); map2.items.push(value); return map2; } if (value instanceof String || value instanceof Number || value instanceof Boolean || typeof BigInt !== "undefined" && value instanceof BigInt) { value = value.valueOf(); } const { aliasDuplicateObjects, onAnchor, onTagObj, schema: schema4, sourceObjects } = ctx; let ref = void 0; if (aliasDuplicateObjects && value && typeof value === "object") { ref = sourceObjects.get(value); if (ref) { if (!ref.anchor) ref.anchor = onAnchor(value); return new Alias(ref.anchor); } else { ref = { anchor: null, node: null }; sourceObjects.set(value, ref); } } if (tagName?.startsWith("!!")) tagName = defaultTagPrefix + tagName.slice(2); let tagObj = findTagObject(value, tagName, schema4.tags); if (!tagObj) { if (value && typeof value.toJSON === "function") { value = value.toJSON(); } if (!value || typeof value !== "object") { const node2 = new Scalar(value); if (ref) ref.node = node2; return node2; } tagObj = value instanceof Map ? schema4[MAP] : Symbol.iterator in Object(value) ? schema4[SEQ] : schema4[MAP]; } if (onTagObj) { onTagObj(tagObj); delete ctx.onTagObj; } const node = tagObj?.createNode ? tagObj.createNode(ctx.schema, value, ctx) : typeof tagObj?.nodeClass?.from === "function" ? tagObj.nodeClass.from(ctx.schema, value, ctx) : new Scalar(value); if (tagName) node.tag = tagName; else if (!tagObj.default) node.tag = tagObj.tag; if (ref) ref.node = node; return node; } // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/nodes/Collection.js function collectionFromPath(schema4, path, value) { let v = value; for (let i = path.length - 1; i >= 0; --i) { const k = path[i]; if (typeof k === "number" && Number.isInteger(k) && k >= 0) { const a = []; a[k] = v; v = a; } else { v = /* @__PURE__ */ new Map([[k, v]]); } } return createNode(v, void 0, { aliasDuplicateObjects: false, keepUndefined: false, onAnchor: () => { throw new Error("This should not happen, please report a bug."); }, schema: schema4, sourceObjects: /* @__PURE__ */ new Map() }); } var isEmptyPath = (path) => path == null || typeof path === "object" && !!path[Symbol.iterator]().next().done; var Collection = class extends NodeBase { constructor(type, schema4) { super(type); Object.defineProperty(this, "schema", { value: schema4, configurable: true, enumerable: false, writable: true }); } /** * Create a copy of this collection. * * @param schema - If defined, overwrites the original's schema */ clone(schema4) { const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this)); if (schema4) copy.schema = schema4; copy.items = copy.items.map((it) => isNode(it) || isPair(it) ? it.clone(schema4) : it); if (this.range) copy.range = this.range.slice(); return copy; } /** * Adds a value to the collection. For `!!map` and `!!omap` the value must * be a Pair instance or a `{ key, value }` object, which may not have a key * that already exists in the map. */ addIn(path, value) { if (isEmptyPath(path)) this.add(value); else { const [key, ...rest] = path; const node = this.get(key, true); if (isCollection(node)) node.addIn(rest, value); else if (node === void 0 && this.schema) this.set(key, collectionFromPath(this.schema, rest, value)); else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); } } /** * Removes a value from the collection. * @returns `true` if the item was found and removed. */ deleteIn(path) { const [key, ...rest] = path; if (rest.length === 0) return this.delete(key); const node = this.get(key, true); if (isCollection(node)) return node.deleteIn(rest); else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); } /** * Returns item at `key`, or `undefined` if not found. By default unwraps * scalar values from their surrounding node; to disable set `keepScalar` to * `true` (collections are always returned intact). */ getIn(path, keepScalar) { const [key, ...rest] = path; const node = this.get(key, true); if (rest.length === 0) return !keepScalar && isScalar(node) ? node.value : node; else return isCollection(node) ? node.getIn(rest, keepScalar) : void 0; } hasAllNullValues(allowScalar) { return this.items.every((node) => { if (!isPair(node)) return false; const n = node.value; return n == null || allowScalar && isScalar(n) && n.value == null && !n.commentBefore && !n.comment && !n.tag; }); } /** * Checks if the collection includes a value with the key `key`. */ hasIn(path) { const [key, ...rest] = path; if (rest.length === 0) return this.has(key); const node = this.get(key, true); return isCollection(node) ? node.hasIn(rest) : false; } /** * Sets a value in this collection. For `!!set`, `value` needs to be a * boolean to add/remove the item from the set. */ setIn(path, value) { const [key, ...rest] = path; if (rest.length === 0) { this.set(key, value); } else { const node = this.get(key, true); if (isCollection(node)) node.setIn(rest, value); else if (node === void 0 && this.schema) this.set(key, collectionFromPath(this.schema, rest, value)); else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); } } }; // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/stringify/stringifyComment.js var stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, "#"); function indentComment(comment, indent) { if (/^\n+$/.test(comment)) return comment.substring(1); return indent ? comment.replace(/^(?! *$)/gm, indent) : comment; } var lineComment = (str, indent, comment) => str.endsWith("\n") ? indentComment(comment, indent) : comment.includes("\n") ? "\n" + indentComment(comment, indent) : (str.endsWith(" ") ? "" : " ") + comment; // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/stringify/foldFlowLines.js var FOLD_FLOW = "flow"; var FOLD_BLOCK = "block"; var FOLD_QUOTED = "quoted"; function foldFlowLines(text, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) { if (!lineWidth || lineWidth < 0) return text; if (lineWidth < minContentWidth) minContentWidth = 0; const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length); if (text.length <= endStep) return text; const folds = []; const escapedFolds = {}; let end = lineWidth - indent.length; if (typeof indentAtStart === "number") { if (indentAtStart > lineWidth - Math.max(2, minContentWidth)) folds.push(0); else end = lineWidth - indentAtStart; } let split = void 0; let prev = void 0; let overflow = false; let i = -1; let escStart = -1; let escEnd = -1; if (mode === FOLD_BLOCK) { i = consumeMoreIndentedLines(text, i, indent.length); if (i !== -1) end = i + endStep; } for (let ch; ch = text[i += 1]; ) { if (mode === FOLD_QUOTED && ch === "\\") { escStart = i; switch (text[i + 1]) { case "x": i += 3; break; case "u": i += 5; break; case "U": i += 9; break; default: i += 1; } escEnd = i; } if (ch === "\n") { if (mode === FOLD_BLOCK) i = consumeMoreIndentedLines(text, i, indent.length); end = i + indent.length + endStep; split = void 0; } else { if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") { const next = text[i + 1]; if (next && next !== " " && next !== "\n" && next !== " ") split = i; } if (i >= end) { if (split) { folds.push(split); end = split + endStep; split = void 0; } else if (mode === FOLD_QUOTED) { while (prev === " " || prev === " ") { prev = ch; ch = text[i += 1]; overflow = true; } const j = i > escEnd + 1 ? i - 2 : escStart - 1; if (escapedFolds[j]) return text; folds.push(j); escapedFolds[j] = true; end = j + endStep; split = void 0; } else { overflow = true; } } } prev = ch; } if (overflow && onOverflow) onOverflow(); if (folds.length === 0) return text; if (onFold) onFold(); let res = text.slice(0, folds[0]); for (let i2 = 0; i2 < folds.length; ++i2) { const fold = folds[i2]; const end2 = folds[i2 + 1] || text.length; if (fold === 0) res = ` ${indent}${text.slice(0, end2)}`; else { if (mode === FOLD_QUOTED && escapedFolds[fold]) res += `${text[fold]}\\`; res += ` ${indent}${text.slice(fold + 1, end2)}`; } } return res; } function consumeMoreIndentedLines(text, i, indent) { let end = i; let start = i + 1; let ch = text[start]; while (ch === " " || ch === " ") { if (i < start + indent) { ch = text[++i]; } else { do { ch = text[++i]; } while (ch && ch !== "\n"); end = i; start = i + 1; ch = text[start]; } } return end; } // node_modules/.pnpm/yaml@2.5.1/node_modules/yaml/browser/dist/stringify/stringifyString.js var getFoldOptions = (ctx, isBlock) => ({ indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart, lineWidth: ctx.options.lineWidth, minContentWidth: ctx.options.minContentWidth }); var containsDocumentMarker = (str) => /^(%|---|\.\.\.)/m.test(str); function lineLengthOverLimit(str, lineWidth, indentLength) { if (!lineWidth || lineWidth < 0) return false; const limit = lineWidth - indentLength; const strLen = str.length; if (strLen <= limit) return false; for (let i = 0, start = 0; i < strLen; ++i) { if (str[i] === "\n") { if (i - start > limit) return true; start = i + 1; if (strLen - start <= limit) return false; } } return true; } function doubleQuotedString(value, ctx) { const json = JSON.stringify(value); if (ctx.options.doubleQuotedAsJSON) return json; const { implicitKey } = ctx; const minMultiLineLength = ctx.options.doubleQuotedMinMultiLineLength; const indent = ctx.indent || (containsDocumentMarker(value) ? " " : ""); let str = ""; let start = 0; for (let i = 0, ch = json[i]; ch; ch = json[++i]) { if (ch === " " && json[i + 1] === "\\" && json[i + 2] === "n") { str += json.slice(start, i) + "\\ "; i += 1; start = i; ch = "\\"; } if (ch === "\\") switch (json[i + 1]) { case "u": { str += json.slice(start, i); const code = json.substr(i + 2, 4); switch (code) { case "0000": str += "\\0"; break; case "0007": str += "\\a"; break; case "000b": str += "\\v"; break; case "001b": str += "\\e"; break; case "0085": str += "\\N"; break; case "00a0": str += "\\_"; break; case "2028": str += "\\L"; break; case "2029": str += "\\P"; break; default: if (code.substr(0, 2) === "00") str += "\\x" + code.substr(2); else str += json.substr(i, 6); } i += 5; start = i + 1; } break; case "n": if (implicitKey || json[i + 2] === '"' || json.length < minMultiLineLength) { i += 1; } else { str += json.slice(start, i) + "\n\n"; while (json[i + 2] === "\\" && json[i + 3] === "n" && json[i + 4] !== '"') { str += "\n"; i += 2; } str += indent; if (json[i + 2] === " ") str += "\\"; i += 1; start = i + 1; } break; default: i += 1; } } str = start ? str + json.slice(start) : json; return implicitKey ? str : foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx, false)); } function singleQuotedString(value, ctx) { if (ctx.options.singleQuote === false || ctx.implicitKey && value.includes("\n") || /[ \t]\n|\n[ \t]/.test(value)) return doubleQuotedString(value, ctx); const indent = ctx.indent || (containsDocumentMarker(value) ? " " : ""); const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$& ${indent}`) + "'"; return ctx.implicitKey ? res : foldFlowLines(res, i