@darkrymit/crunes-cli 0.5.7 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -73977,7 +73977,7 @@ var init_embedded = __esm({
|
|
|
73977
73977
|
init_require_shim();
|
|
73978
73978
|
md = "export function h1(text) { return `# ${text}\\n`; }\nexport function h2(text) { return `## ${text}\\n`; }\nexport function h3(text) { return `### ${text}\\n`; }\nexport function p(text) { return `${text}\\n`; }\nexport function bold(text) { return `**${text}**`; }\nexport function italic(text) { return `_${text}_`; }\nexport function code(text) { return `\\`${text}\\``; }\n\nexport function codeBlock(text, lang = '') {\n return `\\`\\`\\`${lang}\\n${text}\\n\\`\\`\\`\\n`;\n}\n\nexport function ul(items) {\n return items.map(i => `- ${i}`).join('\\n') + '\\n';\n}\n\nexport function ol(items) {\n return items.map((i, n) => `${n + 1}. ${i}`).join('\\n') + '\\n';\n}\n\nexport function link(text, url) {\n return `[${text}](${url})`;\n}\n\nexport function table(headers, rows) {\n const sep = headers.map(() => '---');\n const lines = [\n `| ${headers.join(' | ')} |`,\n `| ${sep.join(' | ')} |`,\n ...rows.map(r => `| ${r.join(' | ')} |`),\n ];\n return lines.join('\\n') + '\\n';\n}\n\nexport function blockquote(text) {\n return text.split('\\n').map(line => `> ${line}`).join('\\n') + '\\n';\n}\n";
|
|
73979
73979
|
tree = "export function node(name, description, children = []) {\n return { name, description, children };\n}\n\n/**\n * Formats a tree node to a string.\n * options.style: 'tree' (default, ASCII art) | 'list' (nested markdown list)\n * options.bullet: '-' (default) | '*' | '+' \u2014 only used for 'list' style\n */\nexport function format(root, options = {}) {\n const { style = 'tree', bullet = '-' } = options;\n if (style === 'list') return formatList(root, bullet, 0);\n return formatTree(root);\n}\n\nfunction formatTree(root) {\n if (!root) return '';\n const lines = [`${root.name.padEnd(12)}${root.description}`];\n appendTreeChildren(root.children ?? [], '', lines);\n return lines.join('\\n');\n}\n\nfunction appendTreeChildren(children, prefix, lines) {\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n const isLast = i === children.length - 1;\n const connector = isLast ? '\u2514\u2500\u2500 ' : '\u251C\u2500\u2500 ';\n const childPrefix = prefix + (isLast ? ' ' : '\u2502 ');\n lines.push(`${prefix}${connector}${child.name.padEnd(12)}${child.description}`);\n appendTreeChildren(child.children ?? [], childPrefix, lines);\n }\n}\n\nfunction formatList(node, bullet, depth) {\n const indent = ' '.repeat(depth);\n const lines = [`${indent}${bullet} **${node.name}** \u2014 ${node.description}`];\n for (const child of (node.children ?? [])) {\n lines.push(formatList(child, bullet, depth + 1));\n }\n return lines.join('\\n');\n}\n";
|
|
73980
|
-
utils = "// Assembled inside the V8 isolate. Imports from pre-compiled isolate modules for\n// md and tree; wires host-side Reference callbacks for fs, shell, and section.\n// $__utils_* globals are injected by the host before this module is evaluated.\n\nimport * as md from 'crunes:md'\nimport * as tree from 'crunes:tree'\n\nconst __vars = JSON.parse($__vars)\n\nclass TextEncoder {\n encode(str) {\n const bytes = []\n for (let i = 0; i < str.length; i++) {\n let code = str.charCodeAt(i)\n if (code < 0x80) {\n bytes.push(code)\n } else if (code < 0x800) {\n bytes.push(0xc0 | (code >> 6), 0x80 | (code & 0x3f))\n } else if (code < 0xd800 || code >= 0xe000) {\n bytes.push(0xe0 | (code >> 12), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f))\n } else {\n i++\n code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff))\n bytes.push(0xf0 | (code >> 18), 0x80 | ((code >> 12) & 0x3f), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f))\n }\n }\n return new Uint8Array(bytes)\n }\n}\n\nclass TextDecoder {\n decode(bytes) {\n let str = ''\n let i = 0\n while (i < bytes.length) {\n const b = bytes[i++]\n if (b < 0x80) {\n str += String.fromCharCode(b)\n } else if (b < 0xe0) {\n str += String.fromCharCode(((b & 0x1f) << 6) | (bytes[i++] & 0x3f))\n } else if (b < 0xf0) {\n str += String.fromCharCode(((b & 0x0f) << 12) | ((bytes[i++] & 0x3f) << 6) | (bytes[i++] & 0x3f))\n } else {\n let code = ((b & 0x07) << 18) | ((bytes[i++] & 0x3f) << 12) | ((bytes[i++] & 0x3f) << 6) | (bytes[i++] & 0x3f)\n code -= 0x10000\n str += String.fromCharCode(0xd800 | (code >> 10), 0xdc00 | (code & 0x3ff))\n }\n }\n return str\n }\n}\n\nglobalThis.TextEncoder = TextEncoder\nglobalThis.TextDecoder = TextDecoder\n\nglobalThis.utils = {\n fs: {\n cwd: () => $__projectDir,\n resolve:(p) => $__utils_fs_resolve.apply(undefined, [p], { result: { promise: true, copy: true } }),\n read: (p, o) => $__utils_fs_read.apply(undefined, [p, o], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n exists: (p) => $__utils_fs_exists.apply(undefined, [p], { result: { promise: true } }),\n glob: (p, o) => $__utils_fs_glob.apply(undefined, [p, o], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n write: (p, c) => $__utils_fs_write.apply(undefined, [p, c], { arguments: { copy: true }, result: { promise: true } }),\n copy: (src, dest) => $__utils_fs_copy.apply(undefined, [src, dest], { result: { promise: true } }),\n remove: (path, opts) => $__utils_fs_remove.apply(undefined, [path, opts], { result: { promise: true } }),\n move: (src, dest) => $__utils_fs_move.apply(undefined, [src, dest], { result: { promise: true } }),\n stat: (path) => $__utils_fs_stat.apply(undefined, [path], { result: { promise: true, copy: true } }),\n mkdir: (path) => $__utils_fs_mkdir.apply(undefined, [path], { result: { promise: true } }),\n readAsBytes: async (path, opts) => {\n const ab = await $__utils_fs_read_bytes.apply(undefined, [path, opts], { result: { promise: true, copy: true } })\n return ab ? new Uint8Array(ab) : null\n },\n writeAsBytes: (path, content) => {\n if (!(content instanceof Uint8Array)) throw new TypeError('writeAsBytes requires a Uint8Array')\n return $__utils_fs_write_bytes.apply(undefined, [path, content.buffer], { arguments: { copy: true }, result: { promise: true } })\n },\n replace: async (p, regex, replacement) => {\n const content = await globalThis.utils.fs.read(p);\n const newContent = content.replace(regex, replacement);\n await globalThis.utils.fs.write(p, newContent);\n },\n },\n shell: {\n exec: (cmd, o) => $__utils_shell_exec.apply(undefined, [cmd, o], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n execInSession: (cmd, o) => {\n const id = $__utils_shell_execInSession_open.applySync(undefined, [cmd, o], { arguments: { copy: true } })\n return {\n write: (text) => $__utils_shell_execInSession_write.applySync(undefined, [id, text]),\n expect: (pattern, timeoutMs) => {\n const pat = pattern instanceof RegExp ? { type: 'regex', source: pattern.source, flags: pattern.flags } : pattern\n return $__utils_shell_execInSession_expect.apply(undefined, [id, pat, timeoutMs], { arguments: { copy: true }, result: { promise: true, copy: true } })\n },\n output: () => $__utils_shell_execInSession_output.applySync(undefined, [id]),\n waitForExit: () => $__utils_shell_execInSession_waitForExit.apply(undefined, [id], { result: { promise: true } }),\n kill: () => $__utils_shell_execInSession_kill.applySync(undefined, [id])\n }\n }\n },\n section: {\n create: (name, data, o) => $__utils_section_create.applySync(undefined, [name, data, o], { arguments: { copy: true }, result: { copy: true } }),\n match: (sectionName, patterns) => $__utils_section_match.applySync(undefined, [sectionName, patterns], { arguments: { copy: true }, result: { copy: true } }),\n selected: () => $__utils_section_selected.applySync(undefined, [], { result: { copy: true } }),\n },\n rune: {\n use: (key, args) => $__utils_rune\n .apply(undefined, [key, args], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n spawn: (key, args) => $__utils_rune_spawn\n .apply(undefined, [key, args], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n kill: (id, signal) => $__utils_rune_kill\n .apply(undefined, [id, signal ?? null], { result: { promise: true } }),\n exists: (id) => $__utils_rune_exists\n .apply(undefined, [id], { result: { promise: true } }),\n },\n json: {\n read: (p, o) => $__utils_json_read.apply(undefined, [p, o], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n readPath: (p, q, d) => $__utils_json_readPath.apply(undefined, [p, q, d], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n readPathAll: (p, q, d) => $__utils_json_readPathAll.apply(undefined, [p, q, d], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n write: (p, d, o) => $__utils_json_write.apply(undefined, [p, d, o], { arguments: { copy: true }, result: { promise: true } }),\n modify: async (filepath, callback, opts = {}) => {\n const { initial, spaces = 2 } = opts\n const missing = !(await globalThis.utils.fs.exists(filepath))\n if (missing && initial === undefined) {\n await globalThis.utils.json.read(filepath)\n }\n const data = missing ? JSON.parse(JSON.stringify(initial)) : await globalThis.utils.json.read(filepath)\n const result = await callback(data, { exists: !missing })\n await globalThis.utils.json.write(filepath, result !== undefined ? result : data, { spaces })\n },\n },\n yaml: {\n read: (p, o) => $__utils_yaml_read.apply(undefined, [p, o], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n write: (p, d, o) => $__utils_yaml_write.apply(undefined, [p, d, o], { arguments: { copy: true }, result: { promise: true } }),\n modify: async (filepath, callback, opts = {}) => {\n const { initial, indent = 2 } = opts\n const missing = !(await globalThis.utils.fs.exists(filepath))\n if (missing && initial === undefined) {\n await globalThis.utils.yaml.read(filepath)\n }\n const data = missing\n ? JSON.parse(JSON.stringify(initial))\n : await globalThis.utils.yaml.read(filepath)\n const result = await callback(data, { exists: !missing })\n await globalThis.utils.yaml.write(filepath, result !== undefined ? result : data, { indent })\n },\n },\n xml: {\n read: (p, o) => $__utils_xml_read.apply(undefined, [p, o], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n write: (p, d, o) => $__utils_xml_write.apply(undefined, [p, d, o], { arguments: { copy: true }, result: { promise: true } }),\n modify: async (filepath, callback, opts = {}) => {\n const { initial, indent = 2 } = opts\n const missing = !(await globalThis.utils.fs.exists(filepath))\n if (missing && initial === undefined) {\n await globalThis.utils.xml.read(filepath)\n }\n const data = missing ? JSON.parse(JSON.stringify(initial)) : await globalThis.utils.xml.read(filepath)\n const result = await callback(data, { exists: !missing })\n await globalThis.utils.xml.write(filepath, result !== undefined ? result : data, { indent })\n },\n },\n http: {\n fetch: async (url, opts = {}) => {\n let body = opts.body\n if (Array.isArray(body)) {\n body = body.map(entry => {\n if (entry.value instanceof Uint8Array) {\n return { ...entry, value: { type: 'Buffer', data: Array.from(entry.value) } }\n }\n return entry\n })\n }\n const raw = await $__utils_http_fetch.apply(undefined, [url, { ...opts, body }], { arguments: { copy: true }, result: { promise: true, copy: true } })\n return {\n ok: raw.ok,\n status: raw.status,\n statusText: raw.statusText,\n headers: raw.headers,\n text: () => Promise.resolve(raw._text),\n json: () => Promise.resolve(JSON.parse(raw._text)),\n }\n },\n },\n env: {\n read: (key, fallback) => $__utils_env_read\n .apply(undefined, [key, fallback], { arguments: { copy: true }, result: { promise: true, copy: true } })\n .then(r => r !== null ? r : fallback),\n has: (key) => $__utils_env_has\n .apply(undefined, [key], { result: { promise: true } }),\n },\n vars: {\n read: (key, fallback = undefined) => Object.hasOwn(__vars, key) ? __vars[key] : fallback,\n has: (key) => Object.hasOwn(__vars, key),\n },\n archive: {\n zip: (s, d) => $__utils_archive_zip.apply(undefined, [s, d], { result: { promise: true } }),\n unzip: (s, d) => $__utils_archive_unzip.apply(undefined, [s, d], { result: { promise: true } }),\n tar: (s, d, o) => $__utils_archive_tar.apply(undefined, [s, d, o], { arguments: { copy: true }, result: { promise: true } }),\n untar: (s, d, o) => $__utils_archive_untar.apply(undefined, [s, d, o], { arguments: { copy: true }, result: { promise: true } }),\n },\n cache: {\n open: async (location, name) => {\n const id = await $__utils_cache_open.apply(undefined, [location, name ?? null], { result: { promise: true } })\n return {\n set: (k, v, ttl) => $__utils_cache_set.apply(undefined, [id, k, v, ttl ?? null], { arguments: { copy: true }, result: { promise: true } }),\n get: (k) => $__utils_cache_get.apply(undefined, [id, k], { result: { promise: true, copy: true } }),\n delete: (k) => $__utils_cache_delete.apply(undefined, [id, k], { result: { promise: true } }),\n clear: () => $__utils_cache_clear.apply(undefined, [id], { result: { promise: true } }),\n }\n },\n },\n sqlite: {\n open: async (location, name) => {\n const id = await $__utils_sqlite_open.apply(undefined, [location, name ?? null], { result: { promise: true } })\n const db = {\n query: (sql, params = []) =>\n $__utils_sqlite_query.apply(undefined, [id, sql, params], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n get: (sql, params = []) =>\n $__utils_sqlite_get.apply(undefined, [id, sql, params], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n exec: (sql, params = []) =>\n $__utils_sqlite_exec.apply(undefined, [id, sql, params], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n transaction: async (fn) => {\n await db.exec('BEGIN')\n try { await fn(); await db.exec('COMMIT') }\n catch (e) { await db.exec('ROLLBACK'); throw e }\n },\n close: () =>\n $__utils_sqlite_close.apply(undefined, [id], { result: { promise: true } }),\n }\n return db\n },\n },\n crypto: {\n hash: (algorithm, data) => {\n const d = data instanceof Uint8Array ? data.buffer : data\n return $__crypto_hash.apply(undefined, [algorithm, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n .then(arr => new Uint8Array(arr))\n },\n hashAsHex: (algorithm, data) => {\n const d = data instanceof Uint8Array ? data.buffer : data\n return $__crypto_hash_hex.apply(undefined, [algorithm, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n },\n hashAsBase64: (algorithm, data) => {\n const d = data instanceof Uint8Array ? data.buffer : data\n return $__crypto_hash_base64.apply(undefined, [algorithm, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n },\n uuid: () => $__crypto_uuid.applySync(undefined, []),\n randomHex: (size) => $__crypto_random_hex.applySync(undefined, [size]),\n randomBase64: (size) => $__crypto_random_base64.applySync(undefined, [size]),\n\n hmac: (algorithm, key, data) => {\n const k = key instanceof Uint8Array ? key.buffer : key\n const d = data instanceof Uint8Array ? data.buffer : data\n return $__crypto_hmac.apply(undefined, [algorithm, k, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n .then(arr => new Uint8Array(arr))\n },\n hmacAsHex: (algorithm, key, data) => {\n const k = key instanceof Uint8Array ? key.buffer : key\n const d = data instanceof Uint8Array ? data.buffer : data\n return $__crypto_hmac_hex.apply(undefined, [algorithm, k, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n },\n hmacAsBase64: (algorithm, key, data) => {\n const k = key instanceof Uint8Array ? key.buffer : key\n const d = data instanceof Uint8Array ? data.buffer : data\n return $__crypto_hmac_base64.apply(undefined, [algorithm, k, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n },\n\n encrypt: (algorithm, key, iv, data) => {\n const k = key instanceof Uint8Array ? Array.from(key) : key\n const i = iv instanceof Uint8Array ? Array.from(iv) : iv\n const d = data instanceof Uint8Array ? Array.from(data) : data\n return $__crypto_encrypt.apply(undefined, [algorithm, k, i, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n .then(ab => new Uint8Array(ab))\n },\n\n decrypt: (algorithm, key, iv, ciphertext) => {\n const k = key instanceof Uint8Array ? Array.from(key) : key\n const i = iv instanceof Uint8Array ? Array.from(iv) : iv\n const c = ciphertext instanceof Uint8Array ? Array.from(ciphertext) : ciphertext\n return $__crypto_decrypt.apply(undefined, [algorithm, k, i, c], { arguments: { copy: true }, result: { promise: true, copy: true } })\n .then(ab => new Uint8Array(ab))\n },\n\n // Encoding Conversions\n toHex: (data) => {\n const bytes = typeof data === 'string' ? new TextEncoder().encode(data) : data\n let hex = ''\n for (let i = 0; i < bytes.length; i++) {\n hex += bytes[i].toString(16).padStart(2, '0')\n }\n return hex\n },\n fromHex: (hex) => {\n const len = hex.length / 2\n const bytes = new Uint8Array(len)\n for (let i = 0; i < len; i++) {\n bytes[i] = parseInt(hex.substring(i * 2, i * 2 + 2), 16)\n }\n return bytes\n },\n toBase64: (data) => {\n const bytes = typeof data === 'string' ? new TextEncoder().encode(data) : data\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\n let result = ''\n const len = bytes.length\n for (let i = 0; i < len; i += 3) {\n const b1 = bytes[i]\n const b2 = i + 1 < len ? bytes[i + 1] : NaN\n const b3 = i + 2 < len ? bytes[i + 2] : NaN\n const enc1 = b1 >> 2\n const enc2 = ((b1 & 3) << 4) | (isNaN(b2) ? 0 : b2 >> 4)\n const enc3 = isNaN(b2) ? 64 : ((b2 & 15) << 2) | (isNaN(b3) ? 0 : b3 >> 6)\n const enc4 = isNaN(b3) ? 64 : b3 & 63\n result += chars[enc1] + chars[enc2] + (enc3 === 64 ? '=' : chars[enc3]) + (enc4 === 64 ? '=' : chars[enc4])\n }\n return result\n },\n fromBase64: (base64) => {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\n const lookup = new Uint8Array(256)\n for (let i = 0; i < chars.length; i++) lookup[chars.charCodeAt(i)] = i\n const clean = base64.replace(/=/g, '')\n const len = clean.length\n const bytes = new Uint8Array(Math.floor(len * 0.75))\n let p = 0\n for (let i = 0; i < len; i += 4) {\n const w1 = lookup[clean.charCodeAt(i)]\n const w2 = i + 1 < len ? lookup[clean.charCodeAt(i + 1)] : 0\n const w3 = i + 2 < len ? lookup[clean.charCodeAt(i + 2)] : 0\n const w4 = i + 3 < len ? lookup[clean.charCodeAt(i + 3)] : 0\n bytes[p++] = (w1 << 2) | (w2 >> 4)\n if (p < bytes.length) bytes[p++] = ((w2 & 15) << 4) | (w3 >> 2)\n if (p < bytes.length) bytes[p++] = ((w3 & 3) << 6) | w4\n }\n return bytes\n },\n fromUtf8: (utf8) => {\n return new TextEncoder().encode(utf8)\n },\n toUtf8: (data) => {\n return new TextDecoder().decode(data)\n }\n },\n ws: {\n client(url, opts) {\n const id = $__utils_ws_client.applySync(\n undefined,\n [url, opts],\n { arguments: { copy: true } },\n )\n return {\n on(event, handler) {\n const isolateHandler = event === 'error'\n ? async (errJson) => {\n let d\n try { d = JSON.parse(errJson) }\n catch { d = { message: errJson } }\n const errorObj = new Error(d.message)\n errorObj.name = 'WebSocketError'\n if (d.code) errorObj.code = d.code\n if (d.stack) errorObj.stack = d.stack\n handler(errorObj)\n }\n : event === 'binary'\n ? async (arrayBuffer) => {\n handler(new Uint8Array(arrayBuffer))\n }\n : handler\n $__utils_ws_on.applySync(undefined, [id, event, isolateHandler], {\n arguments: { reference: true },\n })\n },\n open: () => $__utils_ws_open.apply(undefined, [id], { result: { promise: true } }),\n sendText: (msg) => $__utils_ws_send_text.apply(undefined, [id, msg], { result: { promise: true } }),\n sendBinary: (data) => {\n if (data instanceof Uint8Array) {\n return $__utils_ws_send_binary.apply(undefined, [id, data.buffer, data.byteOffset, data.byteLength], {\n arguments: { copy: true },\n result: { promise: true }\n })\n } else if (data instanceof ArrayBuffer) {\n return $__utils_ws_send_binary.apply(undefined, [id, data, 0, data.byteLength], {\n arguments: { copy: true },\n result: { promise: true }\n })\n } else {\n throw new TypeError('sendBinary requires an ArrayBuffer or Uint8Array')\n }\n },\n close: () => $__utils_ws_close.apply(undefined, [id], { result: { promise: true, copy: true } }),\n closed: () => $__utils_ws_closed.apply(undefined, [id], { result: { promise: true, copy: true } }),\n }\n },\n },\n time: {\n after: (ms) => $__utils_time_after_ref.apply(undefined, [ms], { result: { promise: true } }),\n },\n md,\n tree,\n}\n\nexport const { fs, shell, section, rune, json, yaml, xml, http, env, vars, archive, cache, sqlite, crypto, ws, time } = globalThis.utils\nexport { md, tree }\n\n// \u2500\u2500\u2500 Global Sandbox Timers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nconst timers = new Map()\nlet nextTimerId = 1\n\nglobalThis.setTimeout = function(callback, delay = 0, ...args) {\n if (typeof callback !== 'function') throw new TypeError('callback must be a function')\n const id = nextTimerId++\n let active = true\n\n timers.set(id, {\n clear() {\n active = false\n timers.delete(id)\n }\n })\n\n globalThis.utils.time.after(delay).then(() => {\n if (active) {\n timers.delete(id)\n callback(...args)\n }\n })\n\n return id\n}\n\nglobalThis.clearTimeout = function(id) {\n const timer = timers.get(id)\n if (timer) timer.clear()\n}\n\nglobalThis.setInterval = function(callback, delay = 0, ...args) {\n if (typeof callback !== 'function') throw new TypeError('callback must be a function')\n const id = nextTimerId++\n let active = true\n\n const run = () => {\n $__utils_time_after_ref.apply(undefined, [delay], { result: { promise: true } }).then(() => {\n if (active) {\n callback(...args)\n run() // Schedule next execution\n }\n })\n }\n\n timers.set(id, {\n clear() {\n active = false\n timers.delete(id)\n }\n })\n\n run()\n return id\n}\n\nglobalThis.clearInterval = function(id) {\n const timer = timers.get(id)\n if (timer) timer.clear()\n}\n";
|
|
73980
|
+
utils = "// Assembled inside the V8 isolate. Imports from pre-compiled isolate modules for\n// md and tree; wires host-side Reference callbacks for fs, shell, and section.\n// $__utils_* globals are injected by the host before this module is evaluated.\n\nimport * as md from 'crunes:md'\nimport * as tree from 'crunes:tree'\n\nconst __vars = JSON.parse($__vars)\n\nclass TextEncoder {\n encode(str) {\n const bytes = []\n for (let i = 0; i < str.length; i++) {\n let code = str.charCodeAt(i)\n if (code < 0x80) {\n bytes.push(code)\n } else if (code < 0x800) {\n bytes.push(0xc0 | (code >> 6), 0x80 | (code & 0x3f))\n } else if (code < 0xd800 || code >= 0xe000) {\n bytes.push(0xe0 | (code >> 12), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f))\n } else {\n i++\n code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff))\n bytes.push(0xf0 | (code >> 18), 0x80 | ((code >> 12) & 0x3f), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f))\n }\n }\n return new Uint8Array(bytes)\n }\n}\n\nclass TextDecoder {\n decode(bytes) {\n let str = ''\n let i = 0\n while (i < bytes.length) {\n const b = bytes[i++]\n if (b < 0x80) {\n str += String.fromCharCode(b)\n } else if (b < 0xe0) {\n str += String.fromCharCode(((b & 0x1f) << 6) | (bytes[i++] & 0x3f))\n } else if (b < 0xf0) {\n str += String.fromCharCode(((b & 0x0f) << 12) | ((bytes[i++] & 0x3f) << 6) | (bytes[i++] & 0x3f))\n } else {\n let code = ((b & 0x07) << 18) | ((bytes[i++] & 0x3f) << 12) | ((bytes[i++] & 0x3f) << 6) | (bytes[i++] & 0x3f)\n code -= 0x10000\n str += String.fromCharCode(0xd800 | (code >> 10), 0xdc00 | (code & 0x3ff))\n }\n }\n return str\n }\n}\n\nglobalThis.TextEncoder = TextEncoder\nglobalThis.TextDecoder = TextDecoder\n\nglobalThis.utils = {\n fs: {\n cwd: () => $__projectDir,\n resolve:(p) => $__utils_fs_resolve.apply(undefined, [p], { result: { promise: true, copy: true } }),\n read: (p, o) => $__utils_fs_read.apply(undefined, [p, o], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n exists: (p) => $__utils_fs_exists.apply(undefined, [p], { result: { promise: true } }),\n glob: (p, o) => $__utils_fs_glob.apply(undefined, [p, o], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n write: (p, c) => $__utils_fs_write.apply(undefined, [p, c], { arguments: { copy: true }, result: { promise: true } }),\n copy: (src, dest) => $__utils_fs_copy.apply(undefined, [src, dest], { result: { promise: true } }),\n remove: (path, opts) => $__utils_fs_remove.apply(undefined, [path, opts], { result: { promise: true } }),\n move: (src, dest) => $__utils_fs_move.apply(undefined, [src, dest], { result: { promise: true } }),\n stat: (path) => $__utils_fs_stat.apply(undefined, [path], { result: { promise: true, copy: true } }),\n mkdir: (path) => $__utils_fs_mkdir.apply(undefined, [path], { result: { promise: true } }),\n readAsBytes: async (path, opts) => {\n const ab = await $__utils_fs_read_bytes.apply(undefined, [path, opts], { result: { promise: true, copy: true } })\n return ab ? new Uint8Array(ab) : null\n },\n writeAsBytes: (path, content) => {\n if (!(content instanceof Uint8Array)) throw new TypeError('writeAsBytes requires a Uint8Array')\n return $__utils_fs_write_bytes.apply(undefined, [path, content.buffer], { arguments: { copy: true }, result: { promise: true } })\n },\n replace: async (p, regex, replacement) => {\n const content = await globalThis.utils.fs.read(p);\n const newContent = content.replace(regex, replacement);\n await globalThis.utils.fs.write(p, newContent);\n },\n },\n shell: {\n exec: (cmd, o) => $__utils_shell_exec.apply(undefined, [cmd, o], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n execInSession: (cmd, o) => {\n const id = $__utils_shell_execInSession_open.applySync(undefined, [cmd, o], { arguments: { copy: true } })\n return {\n write: (text) => $__utils_shell_execInSession_write.applySync(undefined, [id, text]),\n expect: (pattern, timeoutMs) => {\n const pat = pattern instanceof RegExp ? { type: 'regex', source: pattern.source, flags: pattern.flags } : pattern\n return $__utils_shell_execInSession_expect.apply(undefined, [id, pat, timeoutMs], { arguments: { copy: true }, result: { promise: true, copy: true } })\n },\n output: () => $__utils_shell_execInSession_output.applySync(undefined, [id]),\n waitForExit: () => $__utils_shell_execInSession_waitForExit.apply(undefined, [id], { result: { promise: true } }),\n kill: () => $__utils_shell_execInSession_kill.applySync(undefined, [id])\n }\n }\n },\n section: {\n create: (name, data, o) => $__utils_section_create.applySync(undefined, [name, data, o], { arguments: { copy: true }, result: { copy: true } }),\n match: (sectionName, patterns) => $__utils_section_match.applySync(undefined, [sectionName, patterns], { arguments: { copy: true }, result: { copy: true } }),\n selected: () => $__utils_section_selected.applySync(undefined, [], { result: { copy: true } }),\n },\n rune: {\n use: (key, args) => $__utils_rune\n .apply(undefined, [key, args], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n spawn: (key, args) => $__utils_rune_spawn\n .apply(undefined, [key, args], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n kill: (id, signal) => $__utils_rune_kill\n .apply(undefined, [id, signal ?? null], { result: { promise: true } }),\n exists: (id) => $__utils_rune_exists\n .apply(undefined, [id], { result: { promise: true } }),\n },\n json: {\n read: (p, o) => $__utils_json_read.apply(undefined, [p, o], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n readPath: (p, q, d) => $__utils_json_readPath.apply(undefined, [p, q, d], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n readPathAll: (p, q, d) => $__utils_json_readPathAll.apply(undefined, [p, q, d], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n write: (p, d, o) => $__utils_json_write.apply(undefined, [p, d, o], { arguments: { copy: true }, result: { promise: true } }),\n modify: async (filepath, callback, opts = {}) => {\n const { initial, spaces = 2 } = opts\n const missing = !(await globalThis.utils.fs.exists(filepath))\n if (missing && initial === undefined) {\n await globalThis.utils.json.read(filepath)\n }\n const data = missing ? JSON.parse(JSON.stringify(initial)) : await globalThis.utils.json.read(filepath)\n const result = await callback(data, { exists: !missing })\n await globalThis.utils.json.write(filepath, result !== undefined ? result : data, { spaces })\n },\n },\n yaml: {\n read: (p, o) => $__utils_yaml_read.apply(undefined, [p, o], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n write: (p, d, o) => $__utils_yaml_write.apply(undefined, [p, d, o], { arguments: { copy: true }, result: { promise: true } }),\n modify: async (filepath, callback, opts = {}) => {\n const { initial, indent = 2 } = opts\n const missing = !(await globalThis.utils.fs.exists(filepath))\n if (missing && initial === undefined) {\n await globalThis.utils.yaml.read(filepath)\n }\n const data = missing\n ? JSON.parse(JSON.stringify(initial))\n : await globalThis.utils.yaml.read(filepath)\n const result = await callback(data, { exists: !missing })\n await globalThis.utils.yaml.write(filepath, result !== undefined ? result : data, { indent })\n },\n },\n xml: {\n read: (p, o) => $__utils_xml_read.apply(undefined, [p, o], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n write: (p, d, o) => $__utils_xml_write.apply(undefined, [p, d, o], { arguments: { copy: true }, result: { promise: true } }),\n modify: async (filepath, callback, opts = {}) => {\n const { initial, indent = 2 } = opts\n const missing = !(await globalThis.utils.fs.exists(filepath))\n if (missing && initial === undefined) {\n await globalThis.utils.xml.read(filepath)\n }\n const data = missing ? JSON.parse(JSON.stringify(initial)) : await globalThis.utils.xml.read(filepath)\n const result = await callback(data, { exists: !missing })\n await globalThis.utils.xml.write(filepath, result !== undefined ? result : data, { indent })\n },\n },\n http: {\n fetch: async (url, opts = {}) => {\n let body = opts.body\n if (Array.isArray(body)) {\n body = body.map(entry => {\n if (entry.value instanceof Uint8Array) {\n return { ...entry, value: { type: 'Buffer', data: Array.from(entry.value) } }\n }\n return entry\n })\n }\n const raw = await $__utils_http_fetch.apply(undefined, [url, { ...opts, body }], { arguments: { copy: true }, result: { promise: true, copy: true } })\n return {\n ok: raw.ok,\n status: raw.status,\n statusText: raw.statusText,\n headers: raw.headers,\n text: () => Promise.resolve(raw._text),\n json: () => Promise.resolve(JSON.parse(raw._text)),\n }\n },\n },\n env: {\n read: (key, fallback) => $__utils_env_read\n .apply(undefined, [key, fallback], { arguments: { copy: true }, result: { promise: true, copy: true } })\n .then(r => r !== null ? r : fallback),\n has: (key) => $__utils_env_has\n .apply(undefined, [key], { result: { promise: true } }),\n },\n vars: {\n read: (key, fallback = undefined) => Object.hasOwn(__vars, key) ? __vars[key] : fallback,\n has: (key) => Object.hasOwn(__vars, key),\n },\n archive: {\n zip: (s, d) => $__utils_archive_zip.apply(undefined, [s, d], { result: { promise: true } }),\n unzip: (s, d) => $__utils_archive_unzip.apply(undefined, [s, d], { result: { promise: true } }),\n tar: (s, d, o) => $__utils_archive_tar.apply(undefined, [s, d, o], { arguments: { copy: true }, result: { promise: true } }),\n untar: (s, d, o) => $__utils_archive_untar.apply(undefined, [s, d, o], { arguments: { copy: true }, result: { promise: true } }),\n },\n cache: {\n open: async (location, name) => {\n const id = await $__utils_cache_open.apply(undefined, [location, name ?? null], { result: { promise: true } })\n return {\n set: (k, v, ttl) => $__utils_cache_set.apply(undefined, [id, k, v, ttl ?? null], { arguments: { copy: true }, result: { promise: true } }),\n get: (k) => $__utils_cache_get.apply(undefined, [id, k], { result: { promise: true, copy: true } }),\n delete: (k) => $__utils_cache_delete.apply(undefined, [id, k], { result: { promise: true } }),\n clear: () => $__utils_cache_clear.apply(undefined, [id], { result: { promise: true } }),\n }\n },\n },\n sqlite: {\n open: async (location, name) => {\n const id = await $__utils_sqlite_open.apply(undefined, [location, name ?? null], { result: { promise: true } })\n const db = {\n query: (sql, params = []) =>\n $__utils_sqlite_query.apply(undefined, [id, sql, params], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n get: (sql, params = []) =>\n $__utils_sqlite_get.apply(undefined, [id, sql, params], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n exec: (sql, params = []) =>\n $__utils_sqlite_exec.apply(undefined, [id, sql, params], { arguments: { copy: true }, result: { promise: true, copy: true } }),\n transaction: async (fn) => {\n await db.exec('BEGIN')\n try { await fn(); await db.exec('COMMIT') }\n catch (e) { await db.exec('ROLLBACK'); throw e }\n },\n close: () =>\n $__utils_sqlite_close.apply(undefined, [id], { result: { promise: true } }),\n }\n return db\n },\n },\n crypto: {\n hash: (algorithm, data) => {\n const d = data instanceof Uint8Array ? data.buffer : data\n return $__crypto_hash.apply(undefined, [algorithm, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n .then(arr => new Uint8Array(arr))\n },\n hashAsHex: (algorithm, data) => {\n const d = data instanceof Uint8Array ? data.buffer : data\n return $__crypto_hash_hex.apply(undefined, [algorithm, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n },\n hashAsBase64: (algorithm, data) => {\n const d = data instanceof Uint8Array ? data.buffer : data\n return $__crypto_hash_base64.apply(undefined, [algorithm, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n },\n uuid: () => $__crypto_uuid.applySync(undefined, []),\n randomHex: (size) => $__crypto_random_hex.applySync(undefined, [size]),\n randomBase64: (size) => $__crypto_random_base64.applySync(undefined, [size]),\n\n hmac: (algorithm, key, data) => {\n const k = key instanceof Uint8Array ? key.buffer : key\n const d = data instanceof Uint8Array ? data.buffer : data\n return $__crypto_hmac.apply(undefined, [algorithm, k, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n .then(arr => new Uint8Array(arr))\n },\n hmacAsHex: (algorithm, key, data) => {\n const k = key instanceof Uint8Array ? key.buffer : key\n const d = data instanceof Uint8Array ? data.buffer : data\n return $__crypto_hmac_hex.apply(undefined, [algorithm, k, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n },\n hmacAsBase64: (algorithm, key, data) => {\n const k = key instanceof Uint8Array ? key.buffer : key\n const d = data instanceof Uint8Array ? data.buffer : data\n return $__crypto_hmac_base64.apply(undefined, [algorithm, k, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n },\n\n encrypt: (algorithm, key, iv, data) => {\n const k = key instanceof Uint8Array ? Array.from(key) : key\n const i = iv instanceof Uint8Array ? Array.from(iv) : iv\n const d = data instanceof Uint8Array ? Array.from(data) : data\n return $__crypto_encrypt.apply(undefined, [algorithm, k, i, d], { arguments: { copy: true }, result: { promise: true, copy: true } })\n .then(ab => new Uint8Array(ab))\n },\n\n decrypt: (algorithm, key, iv, ciphertext) => {\n const k = key instanceof Uint8Array ? Array.from(key) : key\n const i = iv instanceof Uint8Array ? Array.from(iv) : iv\n const c = ciphertext instanceof Uint8Array ? Array.from(ciphertext) : ciphertext\n return $__crypto_decrypt.apply(undefined, [algorithm, k, i, c], { arguments: { copy: true }, result: { promise: true, copy: true } })\n .then(ab => new Uint8Array(ab))\n },\n\n // Encoding Conversions\n toHex: (data) => {\n const bytes = typeof data === 'string' ? new TextEncoder().encode(data) : data\n let hex = ''\n for (let i = 0; i < bytes.length; i++) {\n hex += bytes[i].toString(16).padStart(2, '0')\n }\n return hex\n },\n fromHex: (hex) => {\n const len = hex.length / 2\n const bytes = new Uint8Array(len)\n for (let i = 0; i < len; i++) {\n bytes[i] = parseInt(hex.substring(i * 2, i * 2 + 2), 16)\n }\n return bytes\n },\n toBase64: (data) => {\n const bytes = typeof data === 'string' ? new TextEncoder().encode(data) : data\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\n let result = ''\n const len = bytes.length\n for (let i = 0; i < len; i += 3) {\n const b1 = bytes[i]\n const b2 = i + 1 < len ? bytes[i + 1] : NaN\n const b3 = i + 2 < len ? bytes[i + 2] : NaN\n const enc1 = b1 >> 2\n const enc2 = ((b1 & 3) << 4) | (isNaN(b2) ? 0 : b2 >> 4)\n const enc3 = isNaN(b2) ? 64 : ((b2 & 15) << 2) | (isNaN(b3) ? 0 : b3 >> 6)\n const enc4 = isNaN(b3) ? 64 : b3 & 63\n result += chars[enc1] + chars[enc2] + (enc3 === 64 ? '=' : chars[enc3]) + (enc4 === 64 ? '=' : chars[enc4])\n }\n return result\n },\n fromBase64: (base64) => {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\n const lookup = new Uint8Array(256)\n for (let i = 0; i < chars.length; i++) lookup[chars.charCodeAt(i)] = i\n const clean = base64.replace(/=/g, '')\n const len = clean.length\n const bytes = new Uint8Array(Math.floor(len * 0.75))\n let p = 0\n for (let i = 0; i < len; i += 4) {\n const w1 = lookup[clean.charCodeAt(i)]\n const w2 = i + 1 < len ? lookup[clean.charCodeAt(i + 1)] : 0\n const w3 = i + 2 < len ? lookup[clean.charCodeAt(i + 2)] : 0\n const w4 = i + 3 < len ? lookup[clean.charCodeAt(i + 3)] : 0\n bytes[p++] = (w1 << 2) | (w2 >> 4)\n if (p < bytes.length) bytes[p++] = ((w2 & 15) << 4) | (w3 >> 2)\n if (p < bytes.length) bytes[p++] = ((w3 & 3) << 6) | w4\n }\n return bytes\n },\n fromUtf8: (utf8) => {\n return new TextEncoder().encode(utf8)\n },\n toUtf8: (data) => {\n return new TextDecoder().decode(data)\n }\n },\n ws: {\n client(url, opts) {\n const id = $__utils_ws_client.applySync(\n undefined,\n [url, opts],\n { arguments: { copy: true } },\n )\n return {\n on(event, handler) {\n const isolateHandler = event === 'error'\n ? async (errJson) => {\n let d\n try { d = JSON.parse(errJson) }\n catch { d = { message: errJson } }\n const errorObj = new Error(d.message)\n errorObj.name = 'WebSocketError'\n if (d.code) errorObj.code = d.code\n if (d.stack) errorObj.stack = d.stack\n handler(errorObj)\n }\n : event === 'binary'\n ? async (arrayBuffer) => {\n handler(new Uint8Array(arrayBuffer))\n }\n : handler\n $__utils_ws_on.applySync(undefined, [id, event, isolateHandler], {\n arguments: { reference: true },\n })\n },\n open: () => $__utils_ws_open.apply(undefined, [id], { result: { promise: true } }),\n sendText: (msg) => $__utils_ws_send_text.apply(undefined, [id, msg], { result: { promise: true } }),\n sendBinary: (data) => {\n if (data instanceof Uint8Array) {\n return $__utils_ws_send_binary.apply(undefined, [id, data.buffer, data.byteOffset, data.byteLength], {\n arguments: { copy: true },\n result: { promise: true }\n })\n } else if (data instanceof ArrayBuffer) {\n return $__utils_ws_send_binary.apply(undefined, [id, data, 0, data.byteLength], {\n arguments: { copy: true },\n result: { promise: true }\n })\n } else {\n throw new TypeError('sendBinary requires an ArrayBuffer or Uint8Array')\n }\n },\n close: () => $__utils_ws_close.apply(undefined, [id], { result: { promise: true, copy: true } }),\n closed: () => $__utils_ws_closed.apply(undefined, [id], { result: { promise: true, copy: true } }),\n }\n },\n },\n time: {\n after: (ms) => $__utils_time_after_ref.apply(undefined, [ms], { result: { promise: true } }),\n },\n md,\n tree,\n}\n\nexport const { fs, shell, section, rune, json, yaml, xml, http, env, vars, archive, cache, sqlite, crypto, ws, time } = globalThis.utils\nexport { md, tree }\n\n// \u2500\u2500\u2500 Global Sandbox Timers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nconst timers = new Map()\nlet nextTimerId = 1\n\nglobalThis.setTimeout = function(callback, delay = 0, ...args) {\n if (typeof callback !== 'function') throw new TypeError('callback must be a function')\n const id = nextTimerId++\n let active = true\n\n timers.set(id, {\n clear() {\n active = false\n timers.delete(id)\n }\n })\n\n $__utils_time_after.apply(undefined, [delay], { result: { promise: true } }).then(() => {\n if (active) {\n timers.delete(id)\n callback(...args)\n }\n })\n\n return id\n}\n\nglobalThis.clearTimeout = function(id) {\n const timer = timers.get(id)\n if (timer) timer.clear()\n}\n\nglobalThis.setInterval = function(callback, delay = 0, ...args) {\n if (typeof callback !== 'function') throw new TypeError('callback must be a function')\n const id = nextTimerId++\n let active = true\n\n const run = () => {\n $__utils_time_after_ref.apply(undefined, [delay], { result: { promise: true } }).then(() => {\n if (active) {\n callback(...args)\n run() // Schedule next execution\n }\n })\n }\n\n timers.set(id, {\n clear() {\n active = false\n timers.delete(id)\n }\n })\n\n run()\n return id\n}\n\nglobalThis.clearInterval = function(id) {\n const timer = timers.get(id)\n if (timer) timer.clear()\n}\n";
|
|
73981
73981
|
console2 = "// Console shim for the isolate. $__log and $__err are ivm.Reference globals\n// set by the host before this module is evaluated.\nglobalThis.console = {\n log: (...a) => $__log.applyIgnored(undefined, a.map(String)),\n error: (...a) => $__err.applyIgnored(undefined, a.map(String)),\n warn: (...a) => $__err.applyIgnored(undefined, a.map(String)),\n}\n";
|
|
73982
73982
|
}
|
|
73983
73983
|
});
|
|
@@ -92038,7 +92038,7 @@ var init_package = __esm({
|
|
|
92038
92038
|
"package.json"() {
|
|
92039
92039
|
package_default = {
|
|
92040
92040
|
name: "@darkrymit/crunes-cli",
|
|
92041
|
-
version: "0.5.
|
|
92041
|
+
version: "0.5.8",
|
|
92042
92042
|
description: "CLI tool for querying crunes enrichers",
|
|
92043
92043
|
type: "module",
|
|
92044
92044
|
bin: {
|