UNPKG

@zubridge/electron

Version:

A streamlined state management library for Electron applications using Zustand.

576 lines (568 loc) 15.5 kB
// Renderer-safe build with polyfilled Node.js modules import { t as util_default } from "./util-ChrZB-qk.js"; const _defineProperty = Object.defineProperty; //#region ../../node_modules/.pnpm/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/tty/read-stream.mjs var ReadStream = class { constructor(fd) { _defineProperty(this, "fd", void 0); _defineProperty(this, "isRaw", false); _defineProperty(this, "isTTY", false); this.fd = fd; } setRawMode(mode) { this.isRaw = mode; return this; } }; //#endregion //#region ../../node_modules/.pnpm/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/internal/tty/write-stream.mjs var WriteStream = class { constructor(fd) { _defineProperty(this, "fd", void 0); _defineProperty(this, "columns", 80); _defineProperty(this, "rows", 24); _defineProperty(this, "isTTY", false); this.fd = fd; } clearLine(dir, callback) { callback && callback(); return false; } clearScreenDown(callback) { callback && callback(); return false; } cursorTo(x, y, callback) { callback && typeof callback === "function" && callback(); return false; } moveCursor(dx, dy, callback) { callback && callback(); return false; } getColorDepth(env) { return 1; } hasColors(count, env) { return false; } getWindowSize() { return [this.columns, this.rows]; } write(str, encoding, cb) { if (str instanceof Uint8Array) str = new TextDecoder().decode(str); try { console.log(str); } catch {} cb && typeof cb === "function" && cb(); return false; } }; //#endregion //#region ../../node_modules/.pnpm/unenv@2.0.0-rc.24/node_modules/unenv/dist/runtime/node/tty.mjs const isatty = function() { return false; }; var tty_default = { ReadStream, WriteStream, isatty }; //#endregion //#region ../../node_modules/.pnpm/ms@3.0.0-canary.202508261828/node_modules/ms/dist/index.js const e = 1e3, t = e * 60, n = t * 60, r = n * 24, i = r * 7, a = r * 365.25, o = a / 12; function s(e$1, t$1) { if (typeof e$1 == `string`) return l(e$1); if (typeof e$1 == `number`) return p(e$1, t$1); throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(e$1)}`); } var c = s; function l(s$1) { if (typeof s$1 != `string` || s$1.length === 0 || s$1.length > 100) throw Error(`Value provided to ms.parse() must be a string with length between 1 and 99. value=${JSON.stringify(s$1)}`); let c$1 = /^(?<value>-?\d*\.?\d+) *(?<unit>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|months?|mo|years?|yrs?|y)?$/i.exec(s$1); if (!c$1?.groups) return NaN; let { value: l$1, unit: u = `ms` } = c$1.groups, d$1 = parseFloat(l$1), f$1 = u.toLowerCase(); switch (f$1) { case `years`: case `year`: case `yrs`: case `yr`: case `y`: return d$1 * a; case `months`: case `month`: case `mo`: return d$1 * o; case `weeks`: case `week`: case `w`: return d$1 * i; case `days`: case `day`: case `d`: return d$1 * r; case `hours`: case `hour`: case `hrs`: case `hr`: case `h`: return d$1 * n; case `minutes`: case `minute`: case `mins`: case `min`: case `m`: return d$1 * t; case `seconds`: case `second`: case `secs`: case `sec`: case `s`: return d$1 * e; case `milliseconds`: case `millisecond`: case `msecs`: case `msec`: case `ms`: return d$1; default: throw Error(`Unknown unit "${f$1}" provided to ms.parse(). value=${JSON.stringify(s$1)}`); } } function d(s$1) { let c$1 = Math.abs(s$1); return c$1 >= a ? `${Math.round(s$1 / a)}y` : c$1 >= o ? `${Math.round(s$1 / o)}mo` : c$1 >= i ? `${Math.round(s$1 / i)}w` : c$1 >= r ? `${Math.round(s$1 / r)}d` : c$1 >= n ? `${Math.round(s$1 / n)}h` : c$1 >= t ? `${Math.round(s$1 / t)}m` : c$1 >= e ? `${Math.round(s$1 / e)}s` : `${s$1}ms`; } function f(s$1) { let c$1 = Math.abs(s$1); return c$1 >= a ? m(s$1, c$1, a, `year`) : c$1 >= o ? m(s$1, c$1, o, `month`) : c$1 >= i ? m(s$1, c$1, i, `week`) : c$1 >= r ? m(s$1, c$1, r, `day`) : c$1 >= n ? m(s$1, c$1, n, `hour`) : c$1 >= t ? m(s$1, c$1, t, `minute`) : c$1 >= e ? m(s$1, c$1, e, `second`) : `${s$1} ms`; } function p(e$1, t$1) { if (typeof e$1 != `number` || !Number.isFinite(e$1)) throw Error(`Value provided to ms.format() must be of type number.`); return t$1?.long ? f(e$1) : d(e$1); } function m(e$1, t$1, n$1, r$1) { let i$1 = t$1 >= n$1 * 1.5; return `${Math.round(e$1 / n$1)} ${r$1}${i$1 ? `s` : ``}`; } //#endregion //#region ../../node_modules/.pnpm/supports-color@10.2.2/node_modules/supports-color/browser.js const level = (() => { if (!("navigator" in globalThis)) return 0; if (globalThis.navigator.userAgentData) { if (navigator.userAgentData.brands.find(({ brand }) => brand === "Chromium")?.version > 93) return 3; } if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) return 1; return 0; })(); const colorSupport = level !== 0 && { level, hasBasic: true, has256: level >= 2, has16m: level >= 3 }; const supportsColor = { stdout: colorSupport, stderr: colorSupport }; var browser_default = supportsColor; //#endregion //#region ../../node_modules/.pnpm/weald@1.1.1/node_modules/weald/dist/src/common.js /** * This is the common logic for both the Node.js and web browser * implementations of `debug()`. */ function setup(env) { createDebug.debug = createDebug; createDebug.default = createDebug; createDebug.coerce = coerce; createDebug.disable = disable; createDebug.enable = enable; createDebug.enabled = enabled; createDebug.humanize = c; createDebug.destroy = destroy; Object.keys(env).forEach((key) => { createDebug[key] = env[key]; }); /** * The currently active debug mode names, and names to skip. */ createDebug.names = []; createDebug.skips = []; /** * Map of special "%n" handling functions, for the debug "format" argument. * * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". */ createDebug.formatters = {}; /** * Selects a color for a debug namespace * * @param {string} namespace - The namespace string for the debug instance to be colored * @returns {number | string} An ANSI color code for the given namespace */ function selectColor(namespace) { let hash = 0; for (let i$1 = 0; i$1 < namespace.length; i$1++) { hash = (hash << 5) - hash + namespace.charCodeAt(i$1); hash |= 0; } return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; } createDebug.selectColor = selectColor; /** * Create a debugger with the given `namespace`. * * @param {string} namespace * @returns {Function} */ function createDebug(namespace, options) { let prevTime; let enableOverride = null; let namespacesCache; let enabledCache; function debug(...args) { if (!debug.enabled) return; const self = debug; const curr = Number(/* @__PURE__ */ new Date()); self.diff = curr - (prevTime || curr); self.prev = prevTime; self.curr = curr; prevTime = curr; args[0] = createDebug.coerce(args[0]); if (typeof args[0] !== "string") args.unshift("%O"); let index = 0; args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { if (match === "%%") return "%"; index++; const formatter = createDebug.formatters[format]; if (typeof formatter === "function") { const val = args[index]; match = formatter.call(self, val); args.splice(index, 1); index--; } return match; }); createDebug.formatArgs.call(self, args); if (options?.onLog != null) options.onLog(...args); (self.log || createDebug.log).apply(self, args); } debug.namespace = namespace; debug.useColors = createDebug.useColors(); debug.color = createDebug.selectColor(namespace); debug.extend = extend; debug.destroy = createDebug.destroy; Object.defineProperty(debug, "enabled", { enumerable: true, configurable: false, get: () => { if (enableOverride !== null) return enableOverride; if (namespacesCache !== createDebug.namespaces) { namespacesCache = createDebug.namespaces; enabledCache = createDebug.enabled(namespace); } return enabledCache; }, set: (v) => { enableOverride = v; } }); if (typeof createDebug.init === "function") createDebug.init(debug); return debug; } function extend(namespace, delimiter) { const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace); newDebug.log = this.log; return newDebug; } /** * Enables a debug mode by namespaces. This can include modes * separated by a colon and wildcards. * * @param {string} namespaces */ function enable(namespaces) { createDebug.save(namespaces); createDebug.namespaces = namespaces; createDebug.names = []; createDebug.skips = []; let i$1; const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/); const len = split.length; for (i$1 = 0; i$1 < len; i$1++) { if (!split[i$1]) continue; namespaces = split[i$1].replace(/\*/g, ".*?"); if (namespaces[0] === "-") createDebug.skips.push(/* @__PURE__ */ new RegExp("^" + namespaces.substr(1) + "$")); else createDebug.names.push(/* @__PURE__ */ new RegExp("^" + namespaces + "$")); } } /** * Disable debug output. * * @returns {string} namespaces */ function disable() { const namespaces = [...createDebug.names.map(toNamespace), ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)].join(","); createDebug.enable(""); return namespaces; } /** * Returns true if the given mode name is enabled, false otherwise. * * @param {string} name * @returns {boolean} */ function enabled(name) { if (name[name.length - 1] === "*") return true; let i$1; let len; for (i$1 = 0, len = createDebug.skips.length; i$1 < len; i$1++) if (createDebug.skips[i$1].test(name)) return false; for (i$1 = 0, len = createDebug.names.length; i$1 < len; i$1++) if (createDebug.names[i$1].test(name)) return true; return false; } /** * Convert regexp to namespace */ function toNamespace(regexp) { return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*"); } /** * Coerce `val`. */ function coerce(val) { if (val instanceof Error) return val.stack ?? val.message; return val; } /** * XXX DO NOT USE. This is a temporary stub function. * XXX It WILL be removed in the next major release. */ function destroy() { console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); } createDebug.setupFormatters(createDebug.formatters); createDebug.enable(createDebug.load()); return createDebug; } //#endregion //#region ../../node_modules/.pnpm/weald@1.1.1/node_modules/weald/dist/src/node.js /** * @packageDocumentation * * This module is a fork of the [debug](https://www.npmjs.com/package/debug) module. It has been converted to TypeScript and the output is ESM. * * It is API compatible with no extra features or bug fixes, it should only be used if you want a 100% ESM application. * * ESM should be arriving in `debug@5.x.x` so this module can be retired after that. * * Please see [debug](https://www.npmjs.com/package/debug) for API details. */ /** * Module dependencies. */ /** * This is the Node.js implementation of `debug()`. */ /** * Colors. */ let colors = [ 6, 2, 3, 4, 5, 1 ]; if (browser_default.stderr !== false && (browser_default.stderr ?? browser_default).level >= 2) colors = [ 20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221 ]; /** * Build up the default `inspectOpts` object from the environment variables. * * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js */ const inspectOpts = Object.keys(process.env).filter((key) => { return /^debug_/i.test(key); }).reduce((obj, key) => { const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => { return k.toUpperCase(); }); let val = process.env[key]; if (/^(yes|on|true|enabled)$/i.test(val)) val = true; else if (/^(no|off|false|disabled)$/i.test(val)) val = false; else if (val === "null") val = null; else val = Number(val); obj[prop] = val; return obj; }, {}); /** * Is stdout a TTY? Colored output is enabled when `true`. */ function useColors() { return "colors" in inspectOpts ? Boolean(inspectOpts.colors) : tty_default.isatty(process.stderr.fd); } /** * Adds ANSI color escape codes if enabled. */ function formatArgs(args) { const { namespace: name, useColors: useColors$1 } = this; if (useColors$1 === true) { const c$1 = this.color; const colorCode = "\x1B[3" + (c$1 < 8 ? c$1 : "8;5;" + c$1); const prefix = ` ${colorCode};1m${name} \u001B[0m`; args[0] = prefix + args[0].split("\n").join("\n" + prefix); args.push(colorCode + "m+" + c(this.diff) + "\x1B[0m"); } else args[0] = getDate() + name + " " + args[0]; } function getDate() { if (inspectOpts.hideDate != null) return ""; return (/* @__PURE__ */ new Date()).toISOString() + " "; } /** * Invokes `util.format()` with the specified arguments and writes to stderr. */ function log(...args) { return process.stderr.write(util_default.format(...args) + "\n"); } /** * Save `namespaces`. * * @param {string} namespaces */ function save(namespaces) { if (namespaces != null) process.env.DEBUG = namespaces; else delete process.env.DEBUG; } /** * Load `namespaces`. * * @returns {string} returns the previously persisted debug modes */ function load() { return process.env.DEBUG; } /** * Init logic for `debug` instances. * * Create a new `inspectOpts` object in case `useColors` is set * differently for a particular `debug` instance. */ function init(debug) { debug.inspectOpts = {}; const keys = Object.keys(inspectOpts); for (let i$1 = 0; i$1 < keys.length; i$1++) debug.inspectOpts[keys[i$1]] = inspectOpts[keys[i$1]]; } function setupFormatters(formatters) { /** * Map %o to `util.inspect()`, all on a single line. */ formatters.o = function(v) { this.inspectOpts.colors = this.useColors; return util_default.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" "); }; /** * Map %O to `util.inspect()`, allowing multiple lines if needed. */ formatters.O = function(v) { this.inspectOpts.colors = this.useColors; return util_default.inspect(v, this.inspectOpts); }; } var node_default = setup({ init, log, formatArgs, save, load, useColors, setupFormatters, colors, inspectOpts }); //#endregion //#region ../../node_modules/.pnpm/weald@1.1.1/node_modules/weald/dist/src/index.js /** * @packageDocumentation * * This module is a fork of the [debug](https://www.npmjs.com/package/debug) module. It has been converted to TypeScript and the output is ESM. * * It is API compatible with no extra features or bug fixes, it should only be used if you want a 100% ESM application. * * ESM should be arriving in `debug@5.x.x` so this module can be retired after that. * * Please see [debug](https://www.npmjs.com/package/debug) for API details. */ /** * Module dependencies. */ var src_default = node_default; //#endregion export { src_default as default };