@uipath/api-workflow-tool
Advanced tools
| import { | ||
| getGlobalThis | ||
| } from "./packager-tool-9qecd4wb.js"; | ||
| import { | ||
| AUTH_CANCELLED_ERROR_CODE | ||
| } from "./packager-tool-1ps2qeqg.js"; | ||
| import"./packager-tool-wckvcay0.js"; | ||
| // ../auth/src/strategies/browser-strategy.ts | ||
| class BrowserAuthStrategy { | ||
| async execute(url, _redirectUri, expectedState, opts) { | ||
| const global = getGlobalThis(); | ||
| if (!global?.window) { | ||
| throw new Error("Browser environment required for authentication"); | ||
| } | ||
| const screenWidth = global.window.screen?.width ?? 1024; | ||
| const screenHeight = global.window.screen?.height ?? 768; | ||
| const width = 600; | ||
| const height = 700; | ||
| const left = screenWidth / 2 - width / 2; | ||
| const top = screenHeight / 2 - height / 2; | ||
| if (!global.window.open) { | ||
| throw new Error("window.open is not available"); | ||
| } | ||
| const popupResult = global.window.open(url, "uip_auth", `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes,status=yes`); | ||
| const popup = popupResult; | ||
| if (!popup) { | ||
| throw new Error(`Authentication popup was blocked by your browser. | ||
| ` + `To continue: | ||
| ` + `1. Look for a popup blocker icon in your address bar | ||
| ` + `2. Allow popups for this site | ||
| ` + `3. Try logging in again | ||
| ` + "If using an ad blocker, you may need to temporarily disable it."); | ||
| } | ||
| return new Promise((resolve, reject) => { | ||
| let timer; | ||
| const messageHandler = (event) => { | ||
| if (event.data?.type === "UIP_AUTH_CODE" && event.data.code) { | ||
| if (event.data.state !== expectedState) { | ||
| cleanup(); | ||
| reject(new Error("OAuth state mismatch — the callback state does not match the expected value. " + "This may indicate a CSRF attack. Please try signing in again.")); | ||
| popup.close(); | ||
| return; | ||
| } | ||
| cleanup(); | ||
| resolve(event.data.code); | ||
| popup.close(); | ||
| } else if (event.data?.type === "UIP_AUTH_ERROR") { | ||
| cleanup(); | ||
| const errorMsg = event.data.error || "Authentication failed"; | ||
| reject(new Error(`Authentication failed: ${errorMsg} | ||
| ` + "Please check your credentials and try again. " + "If the problem persists, verify your UiPath account is active.")); | ||
| popup.close(); | ||
| } | ||
| }; | ||
| const cleanup = () => { | ||
| global.window?.removeEventListener?.("message", messageHandler); | ||
| opts?.signal?.removeEventListener("abort", onAbort); | ||
| if (timer) | ||
| clearInterval(timer); | ||
| }; | ||
| const onAbort = () => { | ||
| cleanup(); | ||
| const err = new Error(`Authentication was cancelled. | ||
| ` + "The sign-in was cancelled before completing the login process. " + "Please try again and complete the authentication flow."); | ||
| err.code = AUTH_CANCELLED_ERROR_CODE; | ||
| reject(err); | ||
| popup.close(); | ||
| }; | ||
| if (opts?.signal) { | ||
| if (opts.signal.aborted) { | ||
| onAbort(); | ||
| return; | ||
| } | ||
| opts.signal.addEventListener("abort", onAbort, { once: true }); | ||
| } | ||
| if (global.window?.addEventListener) { | ||
| global.window.addEventListener("message", messageHandler); | ||
| } | ||
| timer = setInterval(() => { | ||
| if (popup.closed) { | ||
| cleanup(); | ||
| reject(new Error(`Authentication was cancelled. | ||
| ` + "The authentication popup was closed before completing the login process. " + "Please try again and complete the authentication flow.")); | ||
| } | ||
| }, 1000); | ||
| }); | ||
| } | ||
| } | ||
| export { | ||
| BrowserAuthStrategy | ||
| }; | ||
| //# debugId=B13A3005E9EE6C6564756E2164756E21 |
| import { | ||
| BrowserContextStorage, | ||
| ConsoleTelemetryProvider, | ||
| ProjectPackager, | ||
| TelemetryService, | ||
| ToolLogger, | ||
| setGlobalLogHandler | ||
| } from "./packager-tool-9yfnj0t1.js"; | ||
| import { | ||
| translate | ||
| } from "./packager-tool-h1tyrbff.js"; | ||
| import"./packager-tool-wckvcay0.js"; | ||
| // ../filesystem/dist/index.browser.js | ||
| var __create = Object.create; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| function __accessProp(key) { | ||
| return this[key]; | ||
| } | ||
| var __toESMCache_node; | ||
| var __toESMCache_esm; | ||
| var __toESM = (mod, isNodeMode, target) => { | ||
| var canCache = mod != null && typeof mod === "object"; | ||
| if (canCache) { | ||
| var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap; | ||
| var cached = cache.get(mod); | ||
| if (cached) | ||
| return cached; | ||
| } | ||
| target = mod != null ? __create(__getProtoOf(mod)) : {}; | ||
| const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target; | ||
| for (let key of __getOwnPropNames(mod)) | ||
| if (!__hasOwnProp.call(to, key)) | ||
| __defProp(to, key, { | ||
| get: __accessProp.bind(mod, key), | ||
| enumerable: true | ||
| }); | ||
| if (canCache) | ||
| cache.set(mod, to); | ||
| return to; | ||
| }; | ||
| var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports); | ||
| var require_just_once = __commonJS((exports, module) => { | ||
| module.exports = once; | ||
| function once(fn) { | ||
| var called, value; | ||
| if (typeof fn !== "function") { | ||
| throw new Error("expected a function but got " + fn); | ||
| } | ||
| return function wrap() { | ||
| if (called) { | ||
| return value; | ||
| } | ||
| called = true; | ||
| value = fn.apply(this, arguments); | ||
| return value; | ||
| }; | ||
| } | ||
| }); | ||
| var require_text_min = __commonJS((exports) => { | ||
| (function(scope) { | ||
| function B(r, e) { | ||
| var f; | ||
| return r instanceof Buffer ? f = r : f = Buffer.from(r.buffer, r.byteOffset, r.byteLength), f.toString(e); | ||
| } | ||
| var w = function(r) { | ||
| return Buffer.from(r); | ||
| }; | ||
| function h(r) { | ||
| for (var e = 0, f = Math.min(256 * 256, r.length + 1), n = new Uint16Array(f), i = [], o = 0;; ) { | ||
| var t = e < r.length; | ||
| if (!t || o >= f - 1) { | ||
| var s = n.subarray(0, o), m = s; | ||
| if (i.push(String.fromCharCode.apply(null, m)), !t) | ||
| return i.join(""); | ||
| r = r.subarray(e), e = 0, o = 0; | ||
| } | ||
| var a = r[e++]; | ||
| if ((a & 128) === 0) | ||
| n[o++] = a; | ||
| else if ((a & 224) === 192) { | ||
| var d = r[e++] & 63; | ||
| n[o++] = (a & 31) << 6 | d; | ||
| } else if ((a & 240) === 224) { | ||
| var d = r[e++] & 63, l = r[e++] & 63; | ||
| n[o++] = (a & 31) << 12 | d << 6 | l; | ||
| } else if ((a & 248) === 240) { | ||
| var d = r[e++] & 63, l = r[e++] & 63, R = r[e++] & 63, c = (a & 7) << 18 | d << 12 | l << 6 | R; | ||
| c > 65535 && (c -= 65536, n[o++] = c >>> 10 & 1023 | 55296, c = 56320 | c & 1023), n[o++] = c; | ||
| } | ||
| } | ||
| } | ||
| function F(r) { | ||
| for (var e = 0, f = r.length, n = 0, i = Math.max(32, f + (f >>> 1) + 7), o = new Uint8Array(i >>> 3 << 3);e < f; ) { | ||
| var t = r.charCodeAt(e++); | ||
| if (t >= 55296 && t <= 56319) { | ||
| if (e < f) { | ||
| var s = r.charCodeAt(e); | ||
| (s & 64512) === 56320 && (++e, t = ((t & 1023) << 10) + (s & 1023) + 65536); | ||
| } | ||
| if (t >= 55296 && t <= 56319) | ||
| continue; | ||
| } | ||
| if (n + 4 > o.length) { | ||
| i += 8, i *= 1 + e / r.length * 2, i = i >>> 3 << 3; | ||
| var m = new Uint8Array(i); | ||
| m.set(o), o = m; | ||
| } | ||
| if ((t & 4294967168) === 0) { | ||
| o[n++] = t; | ||
| continue; | ||
| } else if ((t & 4294965248) === 0) | ||
| o[n++] = t >>> 6 & 31 | 192; | ||
| else if ((t & 4294901760) === 0) | ||
| o[n++] = t >>> 12 & 15 | 224, o[n++] = t >>> 6 & 63 | 128; | ||
| else if ((t & 4292870144) === 0) | ||
| o[n++] = t >>> 18 & 7 | 240, o[n++] = t >>> 12 & 63 | 128, o[n++] = t >>> 6 & 63 | 128; | ||
| else | ||
| continue; | ||
| o[n++] = t & 63 | 128; | ||
| } | ||
| return o.slice ? o.slice(0, n) : o.subarray(0, n); | ||
| } | ||
| var u = "Failed to ", p = function(r, e, f) { | ||
| if (r) | ||
| throw new Error("".concat(u).concat(e, ": the '").concat(f, "' option is unsupported.")); | ||
| }; | ||
| var x = typeof Buffer == "function" && Buffer.from; | ||
| var A = x ? w : F; | ||
| function v() { | ||
| this.encoding = "utf-8"; | ||
| } | ||
| v.prototype.encode = function(r, e) { | ||
| return p(e && e.stream, "encode", "stream"), A(r); | ||
| }; | ||
| function U(r) { | ||
| var e; | ||
| try { | ||
| var f = new Blob([r], { type: "text/plain;charset=UTF-8" }); | ||
| e = URL.createObjectURL(f); | ||
| var n = new XMLHttpRequest; | ||
| return n.open("GET", e, false), n.send(), n.responseText; | ||
| } finally { | ||
| e && URL.revokeObjectURL(e); | ||
| } | ||
| } | ||
| var O = !x && typeof Blob == "function" && typeof URL == "function" && typeof URL.createObjectURL == "function", S = ["utf-8", "utf8", "unicode-1-1-utf-8"], T = h; | ||
| x ? T = B : O && (T = function(r) { | ||
| try { | ||
| return U(r); | ||
| } catch (e) { | ||
| return h(r); | ||
| } | ||
| }); | ||
| var y = "construct 'TextDecoder'", E = "".concat(u, " ").concat(y, ": the "); | ||
| function g(r, e) { | ||
| p(e && e.fatal, y, "fatal"), r = r || "utf-8"; | ||
| var f; | ||
| if (x ? f = Buffer.isEncoding(r) : f = S.indexOf(r.toLowerCase()) !== -1, !f) | ||
| throw new RangeError("".concat(E, " encoding label provided ('").concat(r, "') is invalid.")); | ||
| this.encoding = r, this.fatal = false, this.ignoreBOM = false; | ||
| } | ||
| g.prototype.decode = function(r, e) { | ||
| p(e && e.stream, "decode", "stream"); | ||
| var f; | ||
| return r instanceof Uint8Array ? f = r : r.buffer instanceof ArrayBuffer ? f = new Uint8Array(r.buffer) : f = new Uint8Array(r), T(f, this.encoding); | ||
| }; | ||
| scope.TextEncoder = scope.TextEncoder || v; | ||
| scope.TextDecoder = scope.TextDecoder || g; | ||
| })(typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : exports); | ||
| }); | ||
| var require_browser = __commonJS((exports, module) => { | ||
| require_text_min(); | ||
| module.exports = { | ||
| encode: (string) => new TextEncoder().encode(string), | ||
| decode: (buffer) => new TextDecoder().decode(buffer) | ||
| }; | ||
| }); | ||
| var require_just_debounce_it = __commonJS((exports, module) => { | ||
| module.exports = debounce; | ||
| function debounce(fn, wait, callFirst) { | ||
| var timeout; | ||
| return function() { | ||
| if (!wait) { | ||
| return fn.apply(this, arguments); | ||
| } | ||
| var context = this; | ||
| var args = arguments; | ||
| var callNow = callFirst && !timeout; | ||
| clearTimeout(timeout); | ||
| timeout = setTimeout(function() { | ||
| timeout = null; | ||
| if (!callNow) { | ||
| return fn.apply(context, args); | ||
| } | ||
| }, wait); | ||
| if (callNow) { | ||
| return fn.apply(this, arguments); | ||
| } | ||
| }; | ||
| } | ||
| }); | ||
| var require_path = __commonJS((exports, module) => { | ||
| function normalizePath(path) { | ||
| if (path.length === 0) { | ||
| return "."; | ||
| } | ||
| let parts = splitPath(path); | ||
| parts = parts.reduce(reducer, []); | ||
| return joinPath(...parts); | ||
| } | ||
| function resolvePath(...paths) { | ||
| let result = ""; | ||
| for (let path of paths) { | ||
| if (path.startsWith("/")) { | ||
| result = path; | ||
| } else { | ||
| result = normalizePath(joinPath(result, path)); | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| function joinPath(...parts) { | ||
| if (parts.length === 0) | ||
| return ""; | ||
| let path = parts.join("/"); | ||
| path = path.replace(/\/{2,}/g, "/"); | ||
| return path; | ||
| } | ||
| function splitPath(path) { | ||
| if (path.length === 0) | ||
| return []; | ||
| if (path === "/") | ||
| return ["/"]; | ||
| let parts = path.split("/"); | ||
| if (parts[parts.length - 1] === "") { | ||
| parts.pop(); | ||
| } | ||
| if (path[0] === "/") { | ||
| parts[0] = "/"; | ||
| } else { | ||
| if (parts[0] !== ".") { | ||
| parts.unshift("."); | ||
| } | ||
| } | ||
| return parts; | ||
| } | ||
| function dirname(path) { | ||
| const last = path.lastIndexOf("/"); | ||
| if (last === -1) | ||
| throw new Error(`Cannot get dirname of "${path}"`); | ||
| if (last === 0) | ||
| return "/"; | ||
| return path.slice(0, last); | ||
| } | ||
| function basename(path) { | ||
| if (path === "/") | ||
| throw new Error(`Cannot get basename of "${path}"`); | ||
| const last = path.lastIndexOf("/"); | ||
| if (last === -1) | ||
| return path; | ||
| return path.slice(last + 1); | ||
| } | ||
| function reducer(ancestors, current) { | ||
| if (ancestors.length === 0) { | ||
| ancestors.push(current); | ||
| return ancestors; | ||
| } | ||
| if (current === ".") | ||
| return ancestors; | ||
| if (current === "..") { | ||
| if (ancestors.length === 1) { | ||
| if (ancestors[0] === "/") { | ||
| throw new Error("Unable to normalize path - traverses above root directory"); | ||
| } | ||
| if (ancestors[0] === ".") { | ||
| ancestors.push(current); | ||
| return ancestors; | ||
| } | ||
| } | ||
| if (ancestors[ancestors.length - 1] === "..") { | ||
| ancestors.push(".."); | ||
| return ancestors; | ||
| } else { | ||
| ancestors.pop(); | ||
| return ancestors; | ||
| } | ||
| } | ||
| ancestors.push(current); | ||
| return ancestors; | ||
| } | ||
| module.exports = { | ||
| join: joinPath, | ||
| normalize: normalizePath, | ||
| split: splitPath, | ||
| basename, | ||
| dirname, | ||
| resolve: resolvePath | ||
| }; | ||
| }); | ||
| var require_errors = __commonJS((exports, module) => { | ||
| function Err(name) { | ||
| return class extends Error { | ||
| constructor(...args) { | ||
| super(...args); | ||
| this.code = name; | ||
| if (this.message) { | ||
| this.message = name + ": " + this.message; | ||
| } else { | ||
| this.message = name; | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| var EEXIST = Err("EEXIST"); | ||
| var ENOENT = Err("ENOENT"); | ||
| var ENOTDIR = Err("ENOTDIR"); | ||
| var ENOTEMPTY = Err("ENOTEMPTY"); | ||
| var ETIMEDOUT = Err("ETIMEDOUT"); | ||
| var EISDIR = Err("EISDIR"); | ||
| module.exports = { EEXIST, ENOENT, ENOTDIR, ENOTEMPTY, ETIMEDOUT, EISDIR }; | ||
| }); | ||
| var require_CacheFS = __commonJS((exports, module) => { | ||
| var path = require_path(); | ||
| var { EEXIST, ENOENT, ENOTDIR, ENOTEMPTY, EISDIR } = require_errors(); | ||
| var STAT = 0; | ||
| module.exports = class CacheFS { | ||
| constructor() {} | ||
| _makeRoot(root = new Map) { | ||
| root.set(STAT, { mode: 511, type: "dir", size: 0, ino: 0, mtimeMs: Date.now() }); | ||
| return root; | ||
| } | ||
| activate(superblock = null) { | ||
| if (superblock === null) { | ||
| this._root = new Map([["/", this._makeRoot()]]); | ||
| } else if (typeof superblock === "string") { | ||
| this._root = new Map([["/", this._makeRoot(this.parse(superblock))]]); | ||
| } else { | ||
| this._root = superblock; | ||
| } | ||
| } | ||
| get activated() { | ||
| return !!this._root; | ||
| } | ||
| deactivate() { | ||
| this._root = undefined; | ||
| } | ||
| size() { | ||
| return this._countInodes(this._root.get("/")) - 1; | ||
| } | ||
| _countInodes(map) { | ||
| let count = 1; | ||
| for (let [key, val] of map) { | ||
| if (key === STAT) | ||
| continue; | ||
| count += this._countInodes(val); | ||
| } | ||
| return count; | ||
| } | ||
| autoinc() { | ||
| let val = this._maxInode(this._root.get("/")) + 1; | ||
| return val; | ||
| } | ||
| _maxInode(map) { | ||
| let max = map.get(STAT).ino; | ||
| for (let [key, val] of map) { | ||
| if (key === STAT) | ||
| continue; | ||
| max = Math.max(max, this._maxInode(val)); | ||
| } | ||
| return max; | ||
| } | ||
| print(root = this._root.get("/")) { | ||
| let str = ""; | ||
| const printTree = (root2, indent) => { | ||
| for (let [file, node] of root2) { | ||
| if (file === 0) | ||
| continue; | ||
| let stat = node.get(STAT); | ||
| let mode = stat.mode.toString(8); | ||
| str += `${"\t".repeat(indent)}${file} ${mode}`; | ||
| if (stat.type === "file") { | ||
| str += ` ${stat.size} ${stat.mtimeMs} | ||
| `; | ||
| } else { | ||
| str += ` | ||
| `; | ||
| printTree(node, indent + 1); | ||
| } | ||
| } | ||
| }; | ||
| printTree(root, 0); | ||
| return str; | ||
| } | ||
| parse(print) { | ||
| let autoinc = 0; | ||
| function mk(stat) { | ||
| const ino = ++autoinc; | ||
| const type = stat.length === 1 ? "dir" : "file"; | ||
| let [mode, size, mtimeMs] = stat; | ||
| mode = parseInt(mode, 8); | ||
| size = size ? parseInt(size) : 0; | ||
| mtimeMs = mtimeMs ? parseInt(mtimeMs) : Date.now(); | ||
| return new Map([[STAT, { mode, type, size, mtimeMs, ino }]]); | ||
| } | ||
| let lines = print.trim().split(` | ||
| `); | ||
| let _root = this._makeRoot(); | ||
| let stack = [ | ||
| { indent: -1, node: _root }, | ||
| { indent: 0, node: null } | ||
| ]; | ||
| for (let line of lines) { | ||
| let prefix = line.match(/^\t*/)[0]; | ||
| let indent = prefix.length; | ||
| line = line.slice(indent); | ||
| let [filename, ...stat] = line.split("\t"); | ||
| let node = mk(stat); | ||
| if (indent <= stack[stack.length - 1].indent) { | ||
| while (indent <= stack[stack.length - 1].indent) { | ||
| stack.pop(); | ||
| } | ||
| } | ||
| stack.push({ indent, node }); | ||
| let cd = stack[stack.length - 2].node; | ||
| cd.set(filename, node); | ||
| } | ||
| return _root; | ||
| } | ||
| _lookup(filepath, follow = true) { | ||
| let dir = this._root; | ||
| let partialPath = "/"; | ||
| let parts = path.split(filepath); | ||
| for (let i = 0;i < parts.length; ++i) { | ||
| let part = parts[i]; | ||
| dir = dir.get(part); | ||
| if (!dir) | ||
| throw new ENOENT(filepath); | ||
| if (follow || i < parts.length - 1) { | ||
| const stat = dir.get(STAT); | ||
| if (stat.type === "symlink") { | ||
| let target = path.resolve(partialPath, stat.target); | ||
| dir = this._lookup(target); | ||
| } | ||
| if (!partialPath) { | ||
| partialPath = part; | ||
| } else { | ||
| partialPath = path.join(partialPath, part); | ||
| } | ||
| } | ||
| } | ||
| return dir; | ||
| } | ||
| mkdir(filepath, { mode }) { | ||
| if (filepath === "/") | ||
| throw new EEXIST; | ||
| let dir = this._lookup(path.dirname(filepath)); | ||
| let basename = path.basename(filepath); | ||
| if (dir.has(basename)) { | ||
| throw new EEXIST; | ||
| } | ||
| let entry = new Map; | ||
| let stat = { | ||
| mode, | ||
| type: "dir", | ||
| size: 0, | ||
| mtimeMs: Date.now(), | ||
| ino: this.autoinc() | ||
| }; | ||
| entry.set(STAT, stat); | ||
| dir.set(basename, entry); | ||
| } | ||
| rmdir(filepath) { | ||
| let dir = this._lookup(filepath); | ||
| if (dir.get(STAT).type !== "dir") | ||
| throw new ENOTDIR; | ||
| if (dir.size > 1) | ||
| throw new ENOTEMPTY; | ||
| let parent = this._lookup(path.dirname(filepath)); | ||
| let basename = path.basename(filepath); | ||
| parent.delete(basename); | ||
| } | ||
| readdir(filepath) { | ||
| let dir = this._lookup(filepath); | ||
| if (dir.get(STAT).type !== "dir") | ||
| throw new ENOTDIR; | ||
| return [...dir.keys()].filter((key) => typeof key === "string"); | ||
| } | ||
| writeStat(filepath, size, { mode }) { | ||
| let ino; | ||
| let oldStat; | ||
| try { | ||
| oldStat = this.stat(filepath); | ||
| } catch (err) {} | ||
| if (oldStat !== undefined) { | ||
| if (oldStat.type === "dir") { | ||
| throw new EISDIR; | ||
| } | ||
| if (mode == null) { | ||
| mode = oldStat.mode; | ||
| } | ||
| ino = oldStat.ino; | ||
| } | ||
| if (mode == null) { | ||
| mode = 438; | ||
| } | ||
| if (ino == null) { | ||
| ino = this.autoinc(); | ||
| } | ||
| let dir = this._lookup(path.dirname(filepath)); | ||
| let basename = path.basename(filepath); | ||
| let stat = { | ||
| mode, | ||
| type: "file", | ||
| size, | ||
| mtimeMs: Date.now(), | ||
| ino | ||
| }; | ||
| let entry = new Map; | ||
| entry.set(STAT, stat); | ||
| dir.set(basename, entry); | ||
| return stat; | ||
| } | ||
| unlink(filepath) { | ||
| let parent = this._lookup(path.dirname(filepath)); | ||
| let basename = path.basename(filepath); | ||
| parent.delete(basename); | ||
| } | ||
| rename(oldFilepath, newFilepath) { | ||
| let basename = path.basename(newFilepath); | ||
| let entry = this._lookup(oldFilepath); | ||
| let destDir = this._lookup(path.dirname(newFilepath)); | ||
| destDir.set(basename, entry); | ||
| this.unlink(oldFilepath); | ||
| } | ||
| stat(filepath) { | ||
| return this._lookup(filepath).get(STAT); | ||
| } | ||
| lstat(filepath) { | ||
| return this._lookup(filepath, false).get(STAT); | ||
| } | ||
| readlink(filepath) { | ||
| return this._lookup(filepath, false).get(STAT).target; | ||
| } | ||
| symlink(target, filepath) { | ||
| let ino, mode; | ||
| try { | ||
| let oldStat = this.stat(filepath); | ||
| if (mode === null) { | ||
| mode = oldStat.mode; | ||
| } | ||
| ino = oldStat.ino; | ||
| } catch (err) {} | ||
| if (mode == null) { | ||
| mode = 40960; | ||
| } | ||
| if (ino == null) { | ||
| ino = this.autoinc(); | ||
| } | ||
| let dir = this._lookup(path.dirname(filepath)); | ||
| let basename = path.basename(filepath); | ||
| let stat = { | ||
| mode, | ||
| type: "symlink", | ||
| target, | ||
| size: 0, | ||
| mtimeMs: Date.now(), | ||
| ino | ||
| }; | ||
| let entry = new Map; | ||
| entry.set(STAT, stat); | ||
| dir.set(basename, entry); | ||
| return stat; | ||
| } | ||
| _du(dir) { | ||
| let size = 0; | ||
| for (const [name, entry] of dir.entries()) { | ||
| if (name === STAT) { | ||
| size += entry.size; | ||
| } else { | ||
| size += this._du(entry); | ||
| } | ||
| } | ||
| return size; | ||
| } | ||
| du(filepath) { | ||
| let dir = this._lookup(filepath); | ||
| return this._du(dir); | ||
| } | ||
| }; | ||
| }); | ||
| var require_idb_keyval_cjs = __commonJS((exports) => { | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| class Store { | ||
| constructor(dbName = "keyval-store", storeName = "keyval") { | ||
| this.storeName = storeName; | ||
| this._dbName = dbName; | ||
| this._storeName = storeName; | ||
| this._init(); | ||
| } | ||
| _init() { | ||
| if (this._dbp) { | ||
| return; | ||
| } | ||
| this._dbp = new Promise((resolve, reject) => { | ||
| const openreq = indexedDB.open(this._dbName); | ||
| openreq.onerror = () => reject(openreq.error); | ||
| openreq.onsuccess = () => resolve(openreq.result); | ||
| openreq.onupgradeneeded = () => { | ||
| openreq.result.createObjectStore(this._storeName); | ||
| }; | ||
| }); | ||
| } | ||
| _withIDBStore(type, callback) { | ||
| this._init(); | ||
| return this._dbp.then((db) => new Promise((resolve, reject) => { | ||
| const transaction = db.transaction(this.storeName, type); | ||
| transaction.oncomplete = () => resolve(); | ||
| transaction.onabort = transaction.onerror = () => reject(transaction.error); | ||
| callback(transaction.objectStore(this.storeName)); | ||
| })); | ||
| } | ||
| _close() { | ||
| this._init(); | ||
| return this._dbp.then((db) => { | ||
| db.close(); | ||
| this._dbp = undefined; | ||
| }); | ||
| } | ||
| } | ||
| var store; | ||
| function getDefaultStore() { | ||
| if (!store) | ||
| store = new Store; | ||
| return store; | ||
| } | ||
| function get(key, store2 = getDefaultStore()) { | ||
| let req; | ||
| return store2._withIDBStore("readwrite", (store3) => { | ||
| req = store3.get(key); | ||
| }).then(() => req.result); | ||
| } | ||
| function set(key, value, store2 = getDefaultStore()) { | ||
| return store2._withIDBStore("readwrite", (store3) => { | ||
| store3.put(value, key); | ||
| }); | ||
| } | ||
| function update(key, updater, store2 = getDefaultStore()) { | ||
| return store2._withIDBStore("readwrite", (store3) => { | ||
| const req = store3.get(key); | ||
| req.onsuccess = () => { | ||
| store3.put(updater(req.result), key); | ||
| }; | ||
| }); | ||
| } | ||
| function del(key, store2 = getDefaultStore()) { | ||
| return store2._withIDBStore("readwrite", (store3) => { | ||
| store3.delete(key); | ||
| }); | ||
| } | ||
| function clear(store2 = getDefaultStore()) { | ||
| return store2._withIDBStore("readwrite", (store3) => { | ||
| store3.clear(); | ||
| }); | ||
| } | ||
| function keys(store2 = getDefaultStore()) { | ||
| const keys2 = []; | ||
| return store2._withIDBStore("readwrite", (store3) => { | ||
| (store3.openKeyCursor || store3.openCursor).call(store3).onsuccess = function() { | ||
| if (!this.result) | ||
| return; | ||
| keys2.push(this.result.key); | ||
| this.result.continue(); | ||
| }; | ||
| }).then(() => keys2); | ||
| } | ||
| function close(store2 = getDefaultStore()) { | ||
| return store2._close(); | ||
| } | ||
| exports.Store = Store; | ||
| exports.get = get; | ||
| exports.set = set; | ||
| exports.update = update; | ||
| exports.del = del; | ||
| exports.clear = clear; | ||
| exports.keys = keys; | ||
| exports.close = close; | ||
| }); | ||
| var require_IdbBackend = __commonJS((exports, module) => { | ||
| var idb = require_idb_keyval_cjs(); | ||
| module.exports = class IdbBackend { | ||
| constructor(dbname, storename) { | ||
| this._database = dbname; | ||
| this._storename = storename; | ||
| this._store = new idb.Store(this._database, this._storename); | ||
| } | ||
| saveSuperblock(superblock) { | ||
| return idb.set("!root", superblock, this._store); | ||
| } | ||
| loadSuperblock() { | ||
| return idb.get("!root", this._store); | ||
| } | ||
| readFile(inode) { | ||
| return idb.get(inode, this._store); | ||
| } | ||
| writeFile(inode, data) { | ||
| return idb.set(inode, data, this._store); | ||
| } | ||
| unlink(inode) { | ||
| return idb.del(inode, this._store); | ||
| } | ||
| wipe() { | ||
| return idb.clear(this._store); | ||
| } | ||
| close() { | ||
| return idb.close(this._store); | ||
| } | ||
| }; | ||
| }); | ||
| var require_HttpBackend = __commonJS((exports, module) => { | ||
| module.exports = class HttpBackend { | ||
| constructor(url) { | ||
| this._url = url; | ||
| } | ||
| loadSuperblock() { | ||
| return fetch(this._url + "/.superblock.txt").then((res) => res.ok ? res.text() : null); | ||
| } | ||
| async readFile(filepath) { | ||
| const res = await fetch(this._url + filepath); | ||
| if (res.status === 200) { | ||
| return res.arrayBuffer(); | ||
| } else { | ||
| throw new Error("ENOENT"); | ||
| } | ||
| } | ||
| async sizeFile(filepath) { | ||
| const res = await fetch(this._url + filepath, { method: "HEAD" }); | ||
| if (res.status === 200) { | ||
| return res.headers.get("content-length"); | ||
| } else { | ||
| throw new Error("ENOENT"); | ||
| } | ||
| } | ||
| }; | ||
| }); | ||
| var require_Mutex = __commonJS((exports, module) => { | ||
| var idb = require_idb_keyval_cjs(); | ||
| var sleep = (ms) => new Promise((r) => setTimeout(r, ms)); | ||
| module.exports = class Mutex { | ||
| constructor(dbname, storename) { | ||
| this._id = Math.random(); | ||
| this._database = dbname; | ||
| this._storename = storename; | ||
| this._store = new idb.Store(this._database, this._storename); | ||
| this._lock = null; | ||
| } | ||
| async has({ margin = 2000 } = {}) { | ||
| if (this._lock && this._lock.holder === this._id) { | ||
| const now = Date.now(); | ||
| if (this._lock.expires > now + margin) { | ||
| return true; | ||
| } else { | ||
| return await this.renew(); | ||
| } | ||
| } else { | ||
| return false; | ||
| } | ||
| } | ||
| async renew({ ttl = 5000 } = {}) { | ||
| let success; | ||
| await idb.update("lock", (current) => { | ||
| const now = Date.now(); | ||
| const expires = now + ttl; | ||
| success = current && current.holder === this._id; | ||
| this._lock = success ? { holder: this._id, expires } : current; | ||
| return this._lock; | ||
| }, this._store); | ||
| return success; | ||
| } | ||
| async acquire({ ttl = 5000 } = {}) { | ||
| let success; | ||
| let expired; | ||
| let doubleLock; | ||
| await idb.update("lock", (current) => { | ||
| const now = Date.now(); | ||
| const expires = now + ttl; | ||
| expired = current && current.expires < now; | ||
| success = current === undefined || expired; | ||
| doubleLock = current && current.holder === this._id; | ||
| this._lock = success ? { holder: this._id, expires } : current; | ||
| return this._lock; | ||
| }, this._store); | ||
| if (doubleLock) { | ||
| throw new Error("Mutex double-locked"); | ||
| } | ||
| return success; | ||
| } | ||
| async wait({ interval = 100, limit = 6000, ttl } = {}) { | ||
| while (limit--) { | ||
| if (await this.acquire({ ttl })) | ||
| return true; | ||
| await sleep(interval); | ||
| } | ||
| throw new Error("Mutex timeout"); | ||
| } | ||
| async release({ force = false } = {}) { | ||
| let success; | ||
| let doubleFree; | ||
| let someoneElseHasIt; | ||
| await idb.update("lock", (current) => { | ||
| success = force || current && current.holder === this._id; | ||
| doubleFree = current === undefined; | ||
| someoneElseHasIt = current && current.holder !== this._id; | ||
| this._lock = success ? undefined : current; | ||
| return this._lock; | ||
| }, this._store); | ||
| await idb.close(this._store); | ||
| if (!success && !force) { | ||
| if (doubleFree) | ||
| throw new Error("Mutex double-freed"); | ||
| if (someoneElseHasIt) | ||
| throw new Error("Mutex lost ownership"); | ||
| } | ||
| return success; | ||
| } | ||
| }; | ||
| }); | ||
| var require_Mutex2 = __commonJS((exports, module) => { | ||
| module.exports = class Mutex { | ||
| constructor(name) { | ||
| this._id = Math.random(); | ||
| this._database = name; | ||
| this._has = false; | ||
| this._release = null; | ||
| } | ||
| async has() { | ||
| return this._has; | ||
| } | ||
| async acquire() { | ||
| return new Promise((resolve) => { | ||
| navigator.locks.request(this._database + "_lock", { ifAvailable: true }, (lock) => { | ||
| this._has = !!lock; | ||
| resolve(!!lock); | ||
| return new Promise((resolve2) => { | ||
| this._release = resolve2; | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| async wait({ timeout = 600000 } = {}) { | ||
| return new Promise((resolve, reject) => { | ||
| const controller = new AbortController; | ||
| setTimeout(() => { | ||
| controller.abort(); | ||
| reject(new Error("Mutex timeout")); | ||
| }, timeout); | ||
| navigator.locks.request(this._database + "_lock", { signal: controller.signal }, (lock) => { | ||
| this._has = !!lock; | ||
| resolve(!!lock); | ||
| return new Promise((resolve2) => { | ||
| this._release = resolve2; | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| async release({ force = false } = {}) { | ||
| this._has = false; | ||
| if (this._release) { | ||
| this._release(); | ||
| } else if (force) { | ||
| navigator.locks.request(this._database + "_lock", { steal: true }, (lock) => true); | ||
| } | ||
| } | ||
| }; | ||
| }); | ||
| var require_DefaultBackend = __commonJS((exports, module) => { | ||
| var { encode, decode } = require_browser(); | ||
| var debounce = require_just_debounce_it(); | ||
| var CacheFS = require_CacheFS(); | ||
| var { ENOENT, ENOTEMPTY, ETIMEDOUT } = require_errors(); | ||
| var IdbBackend = require_IdbBackend(); | ||
| var HttpBackend = require_HttpBackend(); | ||
| var Mutex = require_Mutex(); | ||
| var Mutex2 = require_Mutex2(); | ||
| var path = require_path(); | ||
| module.exports = class DefaultBackend { | ||
| constructor() { | ||
| this.saveSuperblock = debounce(() => { | ||
| this.flush(); | ||
| }, 500); | ||
| } | ||
| async init(name, { | ||
| wipe, | ||
| url, | ||
| urlauto, | ||
| fileDbName = name, | ||
| db = null, | ||
| fileStoreName = name + "_files", | ||
| lockDbName = name + "_lock", | ||
| lockStoreName = name + "_lock" | ||
| } = {}) { | ||
| this._name = name; | ||
| this._idb = db || new IdbBackend(fileDbName, fileStoreName); | ||
| this._mutex = navigator.locks ? new Mutex2(name) : new Mutex(lockDbName, lockStoreName); | ||
| this._cache = new CacheFS(name); | ||
| this._opts = { wipe, url }; | ||
| this._needsWipe = !!wipe; | ||
| if (url) { | ||
| this._http = new HttpBackend(url); | ||
| this._urlauto = !!urlauto; | ||
| } | ||
| } | ||
| async activate() { | ||
| if (this._cache.activated) | ||
| return; | ||
| if (this._needsWipe) { | ||
| this._needsWipe = false; | ||
| await this._idb.wipe(); | ||
| await this._mutex.release({ force: true }); | ||
| } | ||
| if (!await this._mutex.has()) | ||
| await this._mutex.wait(); | ||
| const root = await this._idb.loadSuperblock(); | ||
| if (root) { | ||
| this._cache.activate(root); | ||
| } else if (this._http) { | ||
| const text = await this._http.loadSuperblock(); | ||
| this._cache.activate(text); | ||
| await this._saveSuperblock(); | ||
| } else { | ||
| this._cache.activate(); | ||
| } | ||
| if (await this._mutex.has()) { | ||
| return; | ||
| } else { | ||
| throw new ETIMEDOUT; | ||
| } | ||
| } | ||
| async deactivate() { | ||
| if (await this._mutex.has()) { | ||
| await this._saveSuperblock(); | ||
| } | ||
| this._cache.deactivate(); | ||
| try { | ||
| await this._mutex.release(); | ||
| } catch (e) { | ||
| console.log(e); | ||
| } | ||
| await this._idb.close(); | ||
| } | ||
| async _saveSuperblock() { | ||
| if (this._cache.activated) { | ||
| this._lastSavedAt = Date.now(); | ||
| await this._idb.saveSuperblock(this._cache._root); | ||
| } | ||
| } | ||
| _writeStat(filepath, size, opts) { | ||
| let dirparts = path.split(path.dirname(filepath)); | ||
| let dir = dirparts.shift(); | ||
| for (let dirpart of dirparts) { | ||
| dir = path.join(dir, dirpart); | ||
| try { | ||
| this._cache.mkdir(dir, { mode: 511 }); | ||
| } catch (e) {} | ||
| } | ||
| return this._cache.writeStat(filepath, size, opts); | ||
| } | ||
| async readFile(filepath, opts) { | ||
| const encoding = typeof opts === "string" ? opts : opts && opts.encoding; | ||
| if (encoding && encoding !== "utf8") | ||
| throw new Error('Only "utf8" encoding is supported in readFile'); | ||
| let data = null, stat = null; | ||
| try { | ||
| stat = this._cache.stat(filepath); | ||
| data = await this._idb.readFile(stat.ino); | ||
| } catch (e) { | ||
| if (!this._urlauto) | ||
| throw e; | ||
| } | ||
| if (!data && this._http) { | ||
| let lstat = this._cache.lstat(filepath); | ||
| while (lstat.type === "symlink") { | ||
| filepath = path.resolve(path.dirname(filepath), lstat.target); | ||
| lstat = this._cache.lstat(filepath); | ||
| } | ||
| data = await this._http.readFile(filepath); | ||
| } | ||
| if (data) { | ||
| if (!stat || stat.size != data.byteLength) { | ||
| stat = await this._writeStat(filepath, data.byteLength, { mode: stat ? stat.mode : 438 }); | ||
| this.saveSuperblock(); | ||
| } | ||
| if (encoding === "utf8") { | ||
| data = decode(data); | ||
| } else { | ||
| data.toString = () => decode(data); | ||
| } | ||
| } | ||
| if (!stat) | ||
| throw new ENOENT(filepath); | ||
| return data; | ||
| } | ||
| async writeFile(filepath, data, opts) { | ||
| const { mode, encoding = "utf8" } = opts; | ||
| if (typeof data === "string") { | ||
| if (encoding !== "utf8") { | ||
| throw new Error('Only "utf8" encoding is supported in writeFile'); | ||
| } | ||
| data = encode(data); | ||
| } | ||
| const stat = await this._cache.writeStat(filepath, data.byteLength, { mode }); | ||
| await this._idb.writeFile(stat.ino, data); | ||
| } | ||
| async unlink(filepath, opts) { | ||
| const stat = this._cache.lstat(filepath); | ||
| this._cache.unlink(filepath); | ||
| if (stat.type !== "symlink") { | ||
| await this._idb.unlink(stat.ino); | ||
| } | ||
| } | ||
| readdir(filepath, opts) { | ||
| return this._cache.readdir(filepath); | ||
| } | ||
| mkdir(filepath, opts) { | ||
| const { mode = 511 } = opts; | ||
| this._cache.mkdir(filepath, { mode }); | ||
| } | ||
| rmdir(filepath, opts) { | ||
| if (filepath === "/") { | ||
| throw new ENOTEMPTY; | ||
| } | ||
| this._cache.rmdir(filepath); | ||
| } | ||
| rename(oldFilepath, newFilepath) { | ||
| this._cache.rename(oldFilepath, newFilepath); | ||
| } | ||
| stat(filepath, opts) { | ||
| return this._cache.stat(filepath); | ||
| } | ||
| lstat(filepath, opts) { | ||
| return this._cache.lstat(filepath); | ||
| } | ||
| readlink(filepath, opts) { | ||
| return this._cache.readlink(filepath); | ||
| } | ||
| symlink(target, filepath) { | ||
| this._cache.symlink(target, filepath); | ||
| } | ||
| async backFile(filepath, opts) { | ||
| let size = await this._http.sizeFile(filepath); | ||
| await this._writeStat(filepath, size, opts); | ||
| } | ||
| du(filepath) { | ||
| return this._cache.du(filepath); | ||
| } | ||
| flush() { | ||
| return this._saveSuperblock(); | ||
| } | ||
| }; | ||
| }); | ||
| var require_Stat = __commonJS((exports, module) => { | ||
| module.exports = class Stat { | ||
| constructor(stats) { | ||
| this.type = stats.type; | ||
| this.mode = stats.mode; | ||
| this.size = stats.size; | ||
| this.ino = stats.ino; | ||
| this.mtimeMs = stats.mtimeMs; | ||
| this.ctimeMs = stats.ctimeMs || stats.mtimeMs; | ||
| this.uid = 1; | ||
| this.gid = 1; | ||
| this.dev = 1; | ||
| } | ||
| isFile() { | ||
| return this.type === "file"; | ||
| } | ||
| isDirectory() { | ||
| return this.type === "dir"; | ||
| } | ||
| isSymbolicLink() { | ||
| return this.type === "symlink"; | ||
| } | ||
| }; | ||
| }); | ||
| var require_PromisifiedFS = __commonJS((exports, module) => { | ||
| var DefaultBackend = require_DefaultBackend(); | ||
| var Stat = require_Stat(); | ||
| var path = require_path(); | ||
| function cleanParamsFilepathOpts(filepath, opts, ...rest) { | ||
| filepath = path.normalize(filepath); | ||
| if (typeof opts === "undefined" || typeof opts === "function") { | ||
| opts = {}; | ||
| } | ||
| if (typeof opts === "string") { | ||
| opts = { | ||
| encoding: opts | ||
| }; | ||
| } | ||
| return [filepath, opts, ...rest]; | ||
| } | ||
| function cleanParamsFilepathDataOpts(filepath, data, opts, ...rest) { | ||
| filepath = path.normalize(filepath); | ||
| if (typeof opts === "undefined" || typeof opts === "function") { | ||
| opts = {}; | ||
| } | ||
| if (typeof opts === "string") { | ||
| opts = { | ||
| encoding: opts | ||
| }; | ||
| } | ||
| return [filepath, data, opts, ...rest]; | ||
| } | ||
| function cleanParamsFilepathFilepath(oldFilepath, newFilepath, ...rest) { | ||
| return [path.normalize(oldFilepath), path.normalize(newFilepath), ...rest]; | ||
| } | ||
| module.exports = class PromisifiedFS { | ||
| constructor(name, options = {}) { | ||
| this.init = this.init.bind(this); | ||
| this.readFile = this._wrap(this.readFile, cleanParamsFilepathOpts, false); | ||
| this.writeFile = this._wrap(this.writeFile, cleanParamsFilepathDataOpts, true); | ||
| this.unlink = this._wrap(this.unlink, cleanParamsFilepathOpts, true); | ||
| this.readdir = this._wrap(this.readdir, cleanParamsFilepathOpts, false); | ||
| this.mkdir = this._wrap(this.mkdir, cleanParamsFilepathOpts, true); | ||
| this.rmdir = this._wrap(this.rmdir, cleanParamsFilepathOpts, true); | ||
| this.rename = this._wrap(this.rename, cleanParamsFilepathFilepath, true); | ||
| this.stat = this._wrap(this.stat, cleanParamsFilepathOpts, false); | ||
| this.lstat = this._wrap(this.lstat, cleanParamsFilepathOpts, false); | ||
| this.readlink = this._wrap(this.readlink, cleanParamsFilepathOpts, false); | ||
| this.symlink = this._wrap(this.symlink, cleanParamsFilepathFilepath, true); | ||
| this.backFile = this._wrap(this.backFile, cleanParamsFilepathOpts, true); | ||
| this.du = this._wrap(this.du, cleanParamsFilepathOpts, false); | ||
| this._deactivationPromise = null; | ||
| this._deactivationTimeout = null; | ||
| this._activationPromise = null; | ||
| this._operations = new Set; | ||
| if (name) { | ||
| this.init(name, options); | ||
| } | ||
| } | ||
| async init(...args) { | ||
| if (this._initPromiseResolve) | ||
| await this._initPromise; | ||
| this._initPromise = this._init(...args); | ||
| return this._initPromise; | ||
| } | ||
| async _init(name, options = {}) { | ||
| await this._gracefulShutdown(); | ||
| if (this._activationPromise) | ||
| await this._deactivate(); | ||
| if (this._backend && this._backend.destroy) { | ||
| await this._backend.destroy(); | ||
| } | ||
| this._backend = options.backend || new DefaultBackend; | ||
| if (this._backend.init) { | ||
| await this._backend.init(name, options); | ||
| } | ||
| if (this._initPromiseResolve) { | ||
| this._initPromiseResolve(); | ||
| this._initPromiseResolve = null; | ||
| } | ||
| if (!options.defer) { | ||
| this.stat("/"); | ||
| } | ||
| } | ||
| async _gracefulShutdown() { | ||
| if (this._operations.size > 0) { | ||
| this._isShuttingDown = true; | ||
| await new Promise((resolve) => this._gracefulShutdownResolve = resolve); | ||
| this._isShuttingDown = false; | ||
| this._gracefulShutdownResolve = null; | ||
| } | ||
| } | ||
| _wrap(fn, paramCleaner, mutating) { | ||
| return async (...args) => { | ||
| args = paramCleaner(...args); | ||
| let op = { | ||
| name: fn.name, | ||
| args | ||
| }; | ||
| this._operations.add(op); | ||
| try { | ||
| await this._activate(); | ||
| return await fn.apply(this, args); | ||
| } finally { | ||
| this._operations.delete(op); | ||
| if (mutating) | ||
| this._backend.saveSuperblock(); | ||
| if (this._operations.size === 0) { | ||
| if (!this._deactivationTimeout) | ||
| clearTimeout(this._deactivationTimeout); | ||
| this._deactivationTimeout = setTimeout(this._deactivate.bind(this), 500); | ||
| } | ||
| } | ||
| }; | ||
| } | ||
| async _activate() { | ||
| if (!this._initPromise) | ||
| console.warn(new Error(`Attempted to use LightningFS ${this._name} before it was initialized.`)); | ||
| await this._initPromise; | ||
| if (this._deactivationTimeout) { | ||
| clearTimeout(this._deactivationTimeout); | ||
| this._deactivationTimeout = null; | ||
| } | ||
| if (this._deactivationPromise) | ||
| await this._deactivationPromise; | ||
| this._deactivationPromise = null; | ||
| if (!this._activationPromise) { | ||
| this._activationPromise = this._backend.activate ? this._backend.activate() : Promise.resolve(); | ||
| } | ||
| await this._activationPromise; | ||
| } | ||
| async _deactivate() { | ||
| if (this._activationPromise) | ||
| await this._activationPromise; | ||
| if (!this._deactivationPromise) { | ||
| this._deactivationPromise = this._backend.deactivate ? this._backend.deactivate() : Promise.resolve(); | ||
| } | ||
| this._activationPromise = null; | ||
| if (this._gracefulShutdownResolve) | ||
| this._gracefulShutdownResolve(); | ||
| return this._deactivationPromise; | ||
| } | ||
| async readFile(filepath, opts) { | ||
| return this._backend.readFile(filepath, opts); | ||
| } | ||
| async writeFile(filepath, data, opts) { | ||
| await this._backend.writeFile(filepath, data, opts); | ||
| return null; | ||
| } | ||
| async unlink(filepath, opts) { | ||
| await this._backend.unlink(filepath, opts); | ||
| return null; | ||
| } | ||
| async readdir(filepath, opts) { | ||
| return this._backend.readdir(filepath, opts); | ||
| } | ||
| async mkdir(filepath, opts) { | ||
| await this._backend.mkdir(filepath, opts); | ||
| return null; | ||
| } | ||
| async rmdir(filepath, opts) { | ||
| await this._backend.rmdir(filepath, opts); | ||
| return null; | ||
| } | ||
| async rename(oldFilepath, newFilepath) { | ||
| await this._backend.rename(oldFilepath, newFilepath); | ||
| return null; | ||
| } | ||
| async stat(filepath, opts) { | ||
| const data = await this._backend.stat(filepath, opts); | ||
| return new Stat(data); | ||
| } | ||
| async lstat(filepath, opts) { | ||
| const data = await this._backend.lstat(filepath, opts); | ||
| return new Stat(data); | ||
| } | ||
| async readlink(filepath, opts) { | ||
| return this._backend.readlink(filepath, opts); | ||
| } | ||
| async symlink(target, filepath) { | ||
| await this._backend.symlink(target, filepath); | ||
| return null; | ||
| } | ||
| async backFile(filepath, opts) { | ||
| await this._backend.backFile(filepath, opts); | ||
| return null; | ||
| } | ||
| async du(filepath) { | ||
| return this._backend.du(filepath); | ||
| } | ||
| async flush() { | ||
| return this._backend.flush(); | ||
| } | ||
| }; | ||
| }); | ||
| var require_src = __commonJS((exports, module) => { | ||
| var once = require_just_once(); | ||
| var PromisifiedFS = require_PromisifiedFS(); | ||
| function wrapCallback(opts, cb) { | ||
| if (typeof opts === "function") { | ||
| cb = opts; | ||
| } | ||
| cb = once(cb); | ||
| const resolve = (...args) => cb(null, ...args); | ||
| return [resolve, cb]; | ||
| } | ||
| module.exports = class FS { | ||
| constructor(...args) { | ||
| this.promises = new PromisifiedFS(...args); | ||
| this.init = this.init.bind(this); | ||
| this.readFile = this.readFile.bind(this); | ||
| this.writeFile = this.writeFile.bind(this); | ||
| this.unlink = this.unlink.bind(this); | ||
| this.readdir = this.readdir.bind(this); | ||
| this.mkdir = this.mkdir.bind(this); | ||
| this.rmdir = this.rmdir.bind(this); | ||
| this.rename = this.rename.bind(this); | ||
| this.stat = this.stat.bind(this); | ||
| this.lstat = this.lstat.bind(this); | ||
| this.readlink = this.readlink.bind(this); | ||
| this.symlink = this.symlink.bind(this); | ||
| this.backFile = this.backFile.bind(this); | ||
| this.du = this.du.bind(this); | ||
| this.flush = this.flush.bind(this); | ||
| } | ||
| init(name, options) { | ||
| return this.promises.init(name, options); | ||
| } | ||
| readFile(filepath, opts, cb) { | ||
| const [resolve, reject] = wrapCallback(opts, cb); | ||
| this.promises.readFile(filepath, opts).then(resolve).catch(reject); | ||
| } | ||
| writeFile(filepath, data, opts, cb) { | ||
| const [resolve, reject] = wrapCallback(opts, cb); | ||
| this.promises.writeFile(filepath, data, opts).then(resolve).catch(reject); | ||
| } | ||
| unlink(filepath, opts, cb) { | ||
| const [resolve, reject] = wrapCallback(opts, cb); | ||
| this.promises.unlink(filepath, opts).then(resolve).catch(reject); | ||
| } | ||
| readdir(filepath, opts, cb) { | ||
| const [resolve, reject] = wrapCallback(opts, cb); | ||
| this.promises.readdir(filepath, opts).then(resolve).catch(reject); | ||
| } | ||
| mkdir(filepath, opts, cb) { | ||
| const [resolve, reject] = wrapCallback(opts, cb); | ||
| this.promises.mkdir(filepath, opts).then(resolve).catch(reject); | ||
| } | ||
| rmdir(filepath, opts, cb) { | ||
| const [resolve, reject] = wrapCallback(opts, cb); | ||
| this.promises.rmdir(filepath, opts).then(resolve).catch(reject); | ||
| } | ||
| rename(oldFilepath, newFilepath, cb) { | ||
| const [resolve, reject] = wrapCallback(cb); | ||
| this.promises.rename(oldFilepath, newFilepath).then(resolve).catch(reject); | ||
| } | ||
| stat(filepath, opts, cb) { | ||
| const [resolve, reject] = wrapCallback(opts, cb); | ||
| this.promises.stat(filepath).then(resolve).catch(reject); | ||
| } | ||
| lstat(filepath, opts, cb) { | ||
| const [resolve, reject] = wrapCallback(opts, cb); | ||
| this.promises.lstat(filepath).then(resolve).catch(reject); | ||
| } | ||
| readlink(filepath, opts, cb) { | ||
| const [resolve, reject] = wrapCallback(opts, cb); | ||
| this.promises.readlink(filepath).then(resolve).catch(reject); | ||
| } | ||
| symlink(target, filepath, cb) { | ||
| const [resolve, reject] = wrapCallback(cb); | ||
| this.promises.symlink(target, filepath).then(resolve).catch(reject); | ||
| } | ||
| backFile(filepath, opts, cb) { | ||
| const [resolve, reject] = wrapCallback(opts, cb); | ||
| this.promises.backFile(filepath, opts).then(resolve).catch(reject); | ||
| } | ||
| du(filepath, cb) { | ||
| const [resolve, reject] = wrapCallback(cb); | ||
| this.promises.du(filepath).then(resolve).catch(reject); | ||
| } | ||
| flush(cb) { | ||
| const [resolve, reject] = wrapCallback(cb); | ||
| this.promises.flush().then(resolve).catch(reject); | ||
| } | ||
| }; | ||
| }); | ||
| var import_lightning_fs = __toESM(require_src(), 1); | ||
| var LOCK_MAX_WAIT_MS = 20000; | ||
| var IN_MEMORY_LOCK_TAILS_KEY = Symbol.for("@uipath/filesystem/lock-tails"); | ||
| var getInMemoryLockTails = () => { | ||
| const globalsHost = globalThis; | ||
| const existing = globalsHost[IN_MEMORY_LOCK_TAILS_KEY]; | ||
| if (existing && typeof existing.get === "function" && typeof existing.set === "function" && typeof existing.delete === "function") { | ||
| return existing; | ||
| } | ||
| const created = new Map; | ||
| globalsHost[IN_MEMORY_LOCK_TAILS_KEY] = created; | ||
| return created; | ||
| }; | ||
| var getWebLocks = () => { | ||
| if (typeof navigator === "undefined") | ||
| return; | ||
| return navigator.locks; | ||
| }; | ||
| class BrowserFileSystem { | ||
| initialized = false; | ||
| fsInstance = null; | ||
| async init() { | ||
| if (this.initialized) | ||
| return; | ||
| this.fsInstance = new import_lightning_fs.default("uipcli-fs"); | ||
| this.initialized = true; | ||
| } | ||
| normalizePath(p) { | ||
| const isAbs = p.startsWith("/"); | ||
| const segments = p.split("/"); | ||
| const normalized = []; | ||
| for (const seg of segments) { | ||
| if (seg === "." || seg === "") | ||
| continue; | ||
| if (seg === "..") { | ||
| normalized.pop(); | ||
| } else { | ||
| normalized.push(seg); | ||
| } | ||
| } | ||
| return (isAbs ? "/" : "") + normalized.join("/"); | ||
| } | ||
| path = { | ||
| join: (...paths) => { | ||
| const joined = paths.filter(Boolean).join("/"); | ||
| return this.normalizePath(joined); | ||
| }, | ||
| resolve: (...paths) => { | ||
| let resolved = ""; | ||
| for (let i = paths.length - 1;i >= 0; i--) { | ||
| const p = paths[i]; | ||
| if (!p) | ||
| continue; | ||
| resolved = resolved ? `${p}/${resolved}` : p; | ||
| if (p.startsWith("/")) | ||
| break; | ||
| } | ||
| if (!resolved.startsWith("/")) { | ||
| resolved = `/${resolved}`; | ||
| } | ||
| return this.normalizePath(resolved); | ||
| }, | ||
| relative: (from, to) => { | ||
| const fromParts = this.normalizePath(from).split("/").filter(Boolean); | ||
| const toParts = this.normalizePath(to).split("/").filter(Boolean); | ||
| let common = 0; | ||
| while (common < fromParts.length && common < toParts.length && fromParts[common] === toParts[common]) { | ||
| common++; | ||
| } | ||
| const ups = Array(fromParts.length - common).fill(".."); | ||
| const downs = toParts.slice(common); | ||
| return [...ups, ...downs].join("/") || "."; | ||
| }, | ||
| dirname: (p) => { | ||
| const parts = p.split("/").filter(Boolean); | ||
| parts.pop(); | ||
| return `/${parts.join("/")}`; | ||
| }, | ||
| isAbsolute: (p) => p.startsWith("/"), | ||
| basename: (p, ext) => { | ||
| const parts = p.split("/").filter(Boolean); | ||
| const base = parts[parts.length - 1] || ""; | ||
| if (ext && base.endsWith(ext)) | ||
| return base.slice(0, -ext.length); | ||
| return base; | ||
| } | ||
| }; | ||
| env = { | ||
| cwd: () => "/", | ||
| homedir: () => "/home", | ||
| tmpdir: () => "/tmp", | ||
| getenv: (_key) => { | ||
| return; | ||
| } | ||
| }; | ||
| utils = { | ||
| open: async (url) => { | ||
| if (typeof window !== "undefined") { | ||
| window.open(url, "_blank"); | ||
| } | ||
| } | ||
| }; | ||
| async prepare() { | ||
| await this.init(); | ||
| } | ||
| getFs() { | ||
| if (!this.fsInstance) { | ||
| throw new Error("Browser filesystem is not initialized."); | ||
| } | ||
| return this.fsInstance; | ||
| } | ||
| async readFile(path, options) { | ||
| try { | ||
| await this.init(); | ||
| const fs = this.getFs(); | ||
| if (options) { | ||
| return await fs.promises.readFile(path, "utf8"); | ||
| } | ||
| const content = await fs.promises.readFile(path); | ||
| return new Uint8Array(content); | ||
| } catch (error) { | ||
| if (this.isEnoent(error)) | ||
| return null; | ||
| throw error; | ||
| } | ||
| } | ||
| async writeFile(filePath, data) { | ||
| await this.init(); | ||
| const fs = this.getFs(); | ||
| const dir = this.path.dirname(filePath); | ||
| if (dir && dir !== "/") { | ||
| await this.mkdir(dir); | ||
| } | ||
| await fs.promises.writeFile(filePath, data); | ||
| } | ||
| async appendFile(filePath, data) { | ||
| await this.init(); | ||
| const fs = this.getFs(); | ||
| const dir = this.path.dirname(filePath); | ||
| if (dir && dir !== "/") { | ||
| await this.mkdir(dir); | ||
| } | ||
| const existing = await this.readFile(filePath, "utf-8"); | ||
| const head = existing ?? ""; | ||
| const tail = typeof data === "string" ? data : new TextDecoder().decode(data); | ||
| await fs.promises.writeFile(filePath, head + tail); | ||
| } | ||
| async readdir(path) { | ||
| try { | ||
| await this.init(); | ||
| const fs = this.getFs(); | ||
| return await fs.promises.readdir(path); | ||
| } catch (error) { | ||
| if (this.isEnoent(error)) | ||
| return []; | ||
| throw error; | ||
| } | ||
| } | ||
| async stat(path) { | ||
| try { | ||
| await this.init(); | ||
| const fs = this.getFs(); | ||
| const stats = await fs.promises.stat(path); | ||
| return { | ||
| isFile: () => stats.isFile(), | ||
| isDirectory: () => stats.isDirectory(), | ||
| size: stats.size, | ||
| mtimeMs: stats.mtimeMs | ||
| }; | ||
| } catch (error) { | ||
| if (this.isEnoent(error)) | ||
| return null; | ||
| throw error; | ||
| } | ||
| } | ||
| async exists(path) { | ||
| return await this.stat(path) !== null; | ||
| } | ||
| async mkdir(path) { | ||
| await this.init(); | ||
| const fs = this.getFs(); | ||
| const normalizedPath = this.normalizePath(path); | ||
| if (normalizedPath === "/" || normalizedPath === "") { | ||
| return; | ||
| } | ||
| const parentDir = this.path.dirname(normalizedPath); | ||
| if (parentDir !== normalizedPath && parentDir !== "/") { | ||
| await this.mkdir(parentDir); | ||
| } else if (parentDir === "/") { | ||
| await this.checkRootDirectory(); | ||
| } | ||
| try { | ||
| await fs.promises.mkdir(normalizedPath); | ||
| } catch (error) { | ||
| if (this.isEexist(error)) | ||
| return; | ||
| throw error; | ||
| } | ||
| } | ||
| async acquireLock(lockPath) { | ||
| const canonical = this.normalizePath(this.path.isAbsolute(lockPath) ? lockPath : `/${lockPath}`); | ||
| const name = `@uipath/filesystem:lock:${canonical}`; | ||
| const webLocks = getWebLocks(); | ||
| if (webLocks) { | ||
| return await this.acquireWebLock(webLocks, name); | ||
| } | ||
| return this.acquireInMemoryLock(name); | ||
| } | ||
| async acquireWebLock(webLocks, name) { | ||
| const abortController = new AbortController; | ||
| const timeoutHandle = setTimeout(() => { | ||
| abortController.abort(); | ||
| }, LOCK_MAX_WAIT_MS); | ||
| return await new Promise((resolveAcquire, rejectAcquire) => { | ||
| let releaseHeld; | ||
| const requested = webLocks.request(name, { signal: abortController.signal }, () => new Promise((resolveHeld) => { | ||
| clearTimeout(timeoutHandle); | ||
| releaseHeld = resolveHeld; | ||
| resolveAcquire(async () => { | ||
| resolveHeld(); | ||
| }); | ||
| })); | ||
| requested.catch((error) => { | ||
| clearTimeout(timeoutHandle); | ||
| if (releaseHeld) { | ||
| return; | ||
| } | ||
| if (error?.name === "AbortError") { | ||
| rejectAcquire(new Error(`ELOCKED: timed out waiting for lock on ${name}`)); | ||
| return; | ||
| } | ||
| rejectAcquire(error); | ||
| }); | ||
| }); | ||
| } | ||
| acquireInMemoryLock(name) { | ||
| const tails = getInMemoryLockTails(); | ||
| const prior = tails.get(name) ?? Promise.resolve(); | ||
| let releaseHeld; | ||
| const held = new Promise((resolve) => { | ||
| releaseHeld = resolve; | ||
| }); | ||
| const chained = prior.then(() => held); | ||
| tails.set(name, chained); | ||
| chained.then(() => { | ||
| if (tails.get(name) === chained) { | ||
| tails.delete(name); | ||
| } | ||
| }); | ||
| return new Promise((resolveAcquire, rejectAcquire) => { | ||
| const timer = setTimeout(() => { | ||
| releaseHeld(); | ||
| rejectAcquire(new Error(`ELOCKED: timed out waiting for lock on ${name}`)); | ||
| }, LOCK_MAX_WAIT_MS); | ||
| prior.then(() => { | ||
| clearTimeout(timer); | ||
| resolveAcquire(async () => { | ||
| releaseHeld(); | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| async rm(path) { | ||
| await this.init(); | ||
| const fs = this.getFs(); | ||
| const stats = await this.stat(path); | ||
| if (!stats) { | ||
| return; | ||
| } | ||
| if (stats.isDirectory()) { | ||
| const entries = await this.readdir(path); | ||
| for (const entry of entries) { | ||
| await this.rm(this.path.join(path, entry)); | ||
| } | ||
| try { | ||
| await fs.promises.rmdir(path); | ||
| } catch (error) { | ||
| if (this.isEnoent(error)) | ||
| return; | ||
| throw error; | ||
| } | ||
| return; | ||
| } | ||
| try { | ||
| await fs.promises.unlink(path); | ||
| } catch (error) { | ||
| if (this.isEnoent(error)) | ||
| return; | ||
| throw error; | ||
| } | ||
| } | ||
| async rename(oldPath, newPath) { | ||
| await this.init(); | ||
| const fs = this.getFs(); | ||
| await fs.promises.rename(oldPath, newPath); | ||
| } | ||
| async realpath(filePath) { | ||
| return filePath; | ||
| } | ||
| async getTempDir() { | ||
| const dir = `/tmp/uipath-fs-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`; | ||
| await this.mkdir(dir); | ||
| return dir; | ||
| } | ||
| async copyDirectory(sourcePath, destPath) { | ||
| const sourceStats = await this.stat(sourcePath); | ||
| if (!sourceStats) { | ||
| throw new Error(`Source directory does not exist: ${sourcePath}`); | ||
| } | ||
| if (!sourceStats.isDirectory()) { | ||
| throw new Error(`Source path is not a directory: ${sourcePath}`); | ||
| } | ||
| await this.mkdir(destPath); | ||
| const entries = await this.readdir(sourcePath); | ||
| for (const entry of entries) { | ||
| const srcEntry = this.path.join(sourcePath, entry); | ||
| const destEntry = this.path.join(destPath, entry); | ||
| const entryStats = await this.stat(srcEntry); | ||
| if (!entryStats) | ||
| continue; | ||
| if (entryStats.isDirectory()) { | ||
| await this.copyDirectory(srcEntry, destEntry); | ||
| } else if (entryStats.isFile()) { | ||
| const content = await this.readFile(srcEntry); | ||
| if (content !== null) { | ||
| await this.writeFile(destEntry, content); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| isEnoent(error) { | ||
| return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT"; | ||
| } | ||
| isEexist(error) { | ||
| return typeof error === "object" && error !== null && "code" in error && error.code === "EEXIST"; | ||
| } | ||
| async checkRootDirectory() { | ||
| try { | ||
| const fs = this.getFs(); | ||
| await fs.promises.stat("/"); | ||
| } catch (error) { | ||
| if (this.isEnoent(error)) { | ||
| const fs = this.getFs(); | ||
| await fs.promises.mkdir("/"); | ||
| return; | ||
| } | ||
| throw error; | ||
| } | ||
| } | ||
| } | ||
| var defaultFs = new BrowserFileSystem; | ||
| var initPromise = defaultFs.init(); | ||
| // ../packager/project-packager/src/base-browser-packager-factory.ts | ||
| var sharedFileSystem = null; | ||
| var GLOBAL_FS_KEY = "__uipath_sharedFileSystem"; | ||
| class BaseBrowserPackagerFactory { | ||
| async getOrCreateFileSystem(config) { | ||
| if (config?.fileSystem) { | ||
| return config.fileSystem; | ||
| } | ||
| const globalRecord = globalThis; | ||
| if (!sharedFileSystem) { | ||
| sharedFileSystem = globalRecord[GLOBAL_FS_KEY] ?? null; | ||
| } | ||
| if (!sharedFileSystem) { | ||
| const fs = new BrowserFileSystem; | ||
| try { | ||
| await fs.init(); | ||
| } catch (error) { | ||
| if (error instanceof Error && error.message.includes("Mount point is already in use")) { | ||
| fs.initialized = true; | ||
| } else { | ||
| throw error; | ||
| } | ||
| } | ||
| sharedFileSystem = fs; | ||
| globalRecord[GLOBAL_FS_KEY] = fs; | ||
| } | ||
| return sharedFileSystem; | ||
| } | ||
| getOrCreateTelemetryService(config) { | ||
| if (config?.telemetryService) { | ||
| return config.telemetryService; | ||
| } | ||
| const provider = new ConsoleTelemetryProvider; | ||
| const contextStorage = new BrowserContextStorage; | ||
| return new TelemetryService(provider, contextStorage); | ||
| } | ||
| configureLogHandler(config) { | ||
| if (config?.logHandler) { | ||
| setGlobalLogHandler(config.logHandler); | ||
| } | ||
| } | ||
| configureLanguage(config) { | ||
| const language = config?.language ?? "en"; | ||
| translate.setLocale(language); | ||
| } | ||
| } | ||
| // ../packager/project-packager/src/browser-project-packager-factory.ts | ||
| class BrowserProjectPackagerFactory extends BaseBrowserPackagerFactory { | ||
| async createAsync(config) { | ||
| const logger = new ToolLogger("ProjectPackagerFactory", "Create"); | ||
| this.configureLanguage(config); | ||
| this.configureLogHandler(config); | ||
| logger.info("Creating ProjectPackager instance..."); | ||
| const fileSystem = await this.getOrCreateFileSystem(config); | ||
| const telemetryService = this.getOrCreateTelemetryService(config); | ||
| const projectPackager = new ProjectPackager(fileSystem, telemetryService); | ||
| logger.info("ProjectPackager created successfully."); | ||
| return projectPackager; | ||
| } | ||
| } | ||
| async function createBrowserProjectPackager(options) { | ||
| const factory = new BrowserProjectPackagerFactory; | ||
| return factory.createAsync(options); | ||
| } | ||
| export { | ||
| createBrowserProjectPackager, | ||
| BaseBrowserPackagerFactory | ||
| }; | ||
| //# debugId=BEA0DF616EA4E56964756E2164756E21 |
Sorry, the diff of this file is too big to display
| import { | ||
| BrowserContextStorage, | ||
| ConsoleTelemetryProvider, | ||
| GovernancePolicyService, | ||
| PackService, | ||
| PackagerParameters, | ||
| PackagerParametersValidator, | ||
| ProjectBuildOptionsValidator, | ||
| ProjectLoader, | ||
| ProjectPackager, | ||
| ProjectToolExecutor, | ||
| ProjectValidateOptionsValidator, | ||
| RulesConfigFileType, | ||
| TelemetryNames, | ||
| TelemetryService, | ||
| ToolLogger, | ||
| ToolsFactory, | ||
| resolveProducedNupkgsAsync, | ||
| setGlobalLogHandler, | ||
| signNupkgsAsync | ||
| } from "./packager-tool-9yfnj0t1.js"; | ||
| import { | ||
| ToolErrorCodes, | ||
| ToolResult, | ||
| translate | ||
| } from "./packager-tool-h1tyrbff.js"; | ||
| import"./packager-tool-wckvcay0.js"; | ||
| // ../packager/project-packager/src/models/project-restore-options.ts | ||
| class ProjectRestoreOptions extends PackagerParameters { | ||
| } | ||
| // ../packager/project-packager/src/models/project-validate-options.ts | ||
| class ProjectValidateOptions extends ProjectRestoreOptions { | ||
| validateOptions = { | ||
| skipAnalyze: false, | ||
| skipValidate: false, | ||
| governanceFileType: "Default" /* Default */ | ||
| }; | ||
| } | ||
| // ../packager/project-packager/src/models/project-build-options.ts | ||
| class ProjectBuildOptions extends ProjectValidateOptions { | ||
| outputType; | ||
| } | ||
| // ../packager/project-packager/src/models/project-cleanup-options.ts | ||
| class ProjectCleanupOptions extends PackagerParameters { | ||
| dryRun = false; | ||
| skipImports = false; | ||
| lockKey; | ||
| } | ||
| // ../packager/project-packager/src/models/project-pack-options.ts | ||
| class ProjectPackOptions extends ProjectBuildOptions { | ||
| destinationPath; | ||
| package; | ||
| signingInfo; | ||
| packOptions; | ||
| } | ||
| // ../packager/project-packager/src/publish/models/publish-options.ts | ||
| var PublishDestinationKind; | ||
| ((PublishDestinationKind2) => { | ||
| PublishDestinationKind2["LocalFolder"] = "LocalFolder"; | ||
| PublishDestinationKind2["NugetFeed"] = "NugetFeed"; | ||
| PublishDestinationKind2["OrchestratorPersonalWorkspace"] = "OrchestratorPersonalWorkspace"; | ||
| PublishDestinationKind2["OrchestratorTenantProcesses"] = "OrchestratorTenantProcesses"; | ||
| PublishDestinationKind2["OrchestratorSharedLibraries"] = "OrchestratorSharedLibraries"; | ||
| PublishDestinationKind2["OrchestratorCustom"] = "OrchestratorCustom"; | ||
| })(PublishDestinationKind ||= {}); | ||
| class ProjectPublishOptions { | ||
| packagePaths; | ||
| destination; | ||
| constructor(packagePaths, destination) { | ||
| this.packagePaths = packagePaths; | ||
| this.destination = destination; | ||
| } | ||
| } | ||
| // ../packager/project-packager/src/publish/services/local-folder-publisher.ts | ||
| class LocalFolderPublisher { | ||
| fileSystem; | ||
| logger; | ||
| constructor(fileSystem) { | ||
| this.fileSystem = fileSystem; | ||
| this.logger = new ToolLogger("ProjectPublisher", "LocalFolder"); | ||
| } | ||
| async publishAsync(packagePaths, destination) { | ||
| const overwrite = destination.overwrite ?? true; | ||
| if (!destination.folderPath) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.localFolderRequired")); | ||
| } | ||
| if (!await this.fileSystem.exists(destination.folderPath)) { | ||
| await this.fileSystem.mkdir(destination.folderPath); | ||
| } | ||
| const written = []; | ||
| for (const sourcePath of packagePaths) { | ||
| const fileName = this.fileSystem.path.basename(sourcePath); | ||
| const destPath = this.fileSystem.path.join(destination.folderPath, fileName); | ||
| if (!overwrite && await this.fileSystem.exists(destPath)) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.localFolderFileExists", { path: destPath })); | ||
| } | ||
| const data = await this.fileSystem.readFile(sourcePath); | ||
| if (!data) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.failedToReadPackage", { path: sourcePath })); | ||
| } | ||
| await this.fileSystem.writeFile(destPath, data); | ||
| written.push(destPath); | ||
| this.logger.info(`Copied package to ${destPath}`); | ||
| } | ||
| return new ToolResult(ToolErrorCodes.Success, undefined, written); | ||
| } | ||
| } | ||
| // ../packager/project-packager/src/publish/services/nuget-feed-publisher.ts | ||
| var NUGET_V3_PACKAGE_PUBLISH_TYPE = "PackagePublish/2.0.0"; | ||
| class NugetFeedPublisher { | ||
| fileSystem; | ||
| logger; | ||
| constructor(fileSystem) { | ||
| this.fileSystem = fileSystem; | ||
| this.logger = new ToolLogger("ProjectPublisher", "NugetFeed"); | ||
| } | ||
| async publishAsync(packagePaths, destination) { | ||
| if (!destination.feedUrl) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.nugetFeedUrlRequired")); | ||
| } | ||
| let pushUrl; | ||
| try { | ||
| pushUrl = await this.resolvePushUrl(destination.feedUrl, destination.apiKey); | ||
| } catch (error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.nugetPushUrlResolutionFailed", { feedUrl: destination.feedUrl, message })); | ||
| } | ||
| const published = []; | ||
| for (const packagePath of packagePaths) { | ||
| const data = await this.fileSystem.readFile(packagePath); | ||
| if (!data) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.failedToReadPackage", { path: packagePath })); | ||
| } | ||
| const fileName = this.fileSystem.path.basename(packagePath); | ||
| const form = new FormData; | ||
| form.append("package", new Blob([data], { | ||
| type: "application/octet-stream" | ||
| }), fileName); | ||
| const headers = {}; | ||
| if (destination.apiKey) { | ||
| headers["X-NuGet-ApiKey"] = destination.apiKey; | ||
| } | ||
| this.logger.info(`Pushing ${fileName} to ${pushUrl}`); | ||
| const response = await fetch(pushUrl, { | ||
| method: "PUT", | ||
| headers, | ||
| body: form | ||
| }); | ||
| if (!response.ok) { | ||
| const body = await this.safeReadBody(response); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.nugetPushFailed", { | ||
| fileName, | ||
| status: response.status, | ||
| statusText: response.statusText, | ||
| body: body ? ` - ${body}` : "" | ||
| })); | ||
| } | ||
| published.push(packagePath); | ||
| this.logger.info(`Pushed ${fileName} successfully.`); | ||
| } | ||
| return new ToolResult(ToolErrorCodes.Success, undefined, published); | ||
| } | ||
| async resolvePushUrl(feedUrl, apiKey) { | ||
| let end = feedUrl.length; | ||
| while (end > 0 && feedUrl.charCodeAt(end - 1) === 47) | ||
| end--; | ||
| const trimmed = feedUrl.slice(0, end); | ||
| if (/\/api\/v2\/package\/?$/i.test(trimmed)) { | ||
| return trimmed; | ||
| } | ||
| if (/\.json$/i.test(trimmed)) { | ||
| return this.resolveFromServiceIndex(trimmed, apiKey); | ||
| } | ||
| return `${trimmed}/api/v2/package`; | ||
| } | ||
| async resolveFromServiceIndex(serviceIndexUrl, apiKey) { | ||
| const headers = { Accept: "application/json" }; | ||
| if (apiKey) { | ||
| headers["X-NuGet-ApiKey"] = apiKey; | ||
| } | ||
| const response = await fetch(serviceIndexUrl, { headers }); | ||
| if (!response.ok) { | ||
| throw new Error(`service index returned ${response.status} ${response.statusText}`); | ||
| } | ||
| const index = await response.json(); | ||
| const resource = index.resources?.find((r) => r["@type"] === NUGET_V3_PACKAGE_PUBLISH_TYPE); | ||
| if (!resource?.["@id"]) { | ||
| throw new Error(`service index has no ${NUGET_V3_PACKAGE_PUBLISH_TYPE} resource`); | ||
| } | ||
| return resource["@id"]; | ||
| } | ||
| async safeReadBody(response) { | ||
| try { | ||
| const text = await response.text(); | ||
| return text.slice(0, 500); | ||
| } catch { | ||
| return ""; | ||
| } | ||
| } | ||
| } | ||
| // ../packager/project-packager/src/publish/services/orchestrator-feed-types.ts | ||
| var PackageFeedDtoPurposeEnum = { | ||
| Undefined: "Undefined", | ||
| Processes: "Processes", | ||
| Libraries: "Libraries", | ||
| PersonalWorkspace: "PersonalWorkspace", | ||
| FolderHierarchy: "FolderHierarchy" | ||
| }; | ||
| var PackageFeedDtoAuthenticationTypeEnum = { | ||
| Secure: "Secure", | ||
| ApiKey: "ApiKey", | ||
| Basic: "Basic" | ||
| }; | ||
| var ExtendedFolderDtoFeedTypeEnum = { | ||
| Undefined: "Undefined", | ||
| Processes: "Processes", | ||
| Libraries: "Libraries", | ||
| PersonalWorkspace: "PersonalWorkspace", | ||
| FolderHierarchy: "FolderHierarchy" | ||
| }; | ||
| // ../common/dist/sdk-user-agent.js | ||
| var PREFIX = "@uipath/common/"; | ||
| var _g = globalThis; | ||
| function singleton(ctorOrName) { | ||
| const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name; | ||
| const key = Symbol.for(PREFIX + name); | ||
| return { | ||
| get(fallback) { | ||
| return _g[key] ?? fallback; | ||
| }, | ||
| set(value) { | ||
| _g[key] = value; | ||
| }, | ||
| clear() { | ||
| delete _g[key]; | ||
| }, | ||
| getOrInit(factory, guard) { | ||
| const existing = _g[key]; | ||
| if (existing != null && typeof existing === "object") { | ||
| if (!guard || guard(existing)) { | ||
| return existing; | ||
| } | ||
| } | ||
| const instance = factory(); | ||
| _g[key] = instance; | ||
| return instance; | ||
| } | ||
| }; | ||
| } | ||
| var telemetryPropsSlot = singleton("TelemetryDefaultProps"); | ||
| var USER_AGENT_HEADER = "User-Agent"; | ||
| var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken"); | ||
| function splitUserAgentTokens(value) { | ||
| return value?.trim().split(/\s+/).filter(Boolean) ?? []; | ||
| } | ||
| function appendUserAgentToken(value, userAgent) { | ||
| const tokens = splitUserAgentTokens(value); | ||
| const seen = new Set(tokens); | ||
| for (const token of splitUserAgentTokens(userAgent)) { | ||
| if (!seen.has(token)) { | ||
| tokens.push(token); | ||
| seen.add(token); | ||
| } | ||
| } | ||
| return tokens.join(" "); | ||
| } | ||
| function getEffectiveUserAgent(userAgent) { | ||
| return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent); | ||
| } | ||
| function getHeaderName(headers, headerName) { | ||
| return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase()); | ||
| } | ||
| function addSdkUserAgentHeader(headers, userAgent) { | ||
| const result = { ...headers ?? {} }; | ||
| const headerName = getHeaderName(result, USER_AGENT_HEADER); | ||
| result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent)); | ||
| return result; | ||
| } | ||
| // ../packager/project-packager/package.json | ||
| var package_default = { | ||
| name: "@uipath/project-packager", | ||
| license: "MIT", | ||
| version: "1.200.0-preview.109", | ||
| description: "UiPath Project Packager - core library for packing individual UiPath projects", | ||
| type: "module", | ||
| main: "./dist/index.js", | ||
| exports: { | ||
| ".": { | ||
| types: "./dist/src/index.d.ts", | ||
| default: "./dist/index.js" | ||
| }, | ||
| "./node": { | ||
| types: "./dist/src/node.d.ts", | ||
| default: "./dist/node.js" | ||
| }, | ||
| "./browser": { | ||
| types: "./dist/src/browser.d.ts", | ||
| default: "./dist/browser.js" | ||
| } | ||
| }, | ||
| types: "./dist/src/index.d.ts", | ||
| repository: { | ||
| type: "git", | ||
| url: "https://github.com/UiPath/cli.git", | ||
| directory: "packages/packager/project-packager" | ||
| }, | ||
| publishConfig: { | ||
| registry: "https://npm.pkg.github.com/" | ||
| }, | ||
| files: [ | ||
| "dist" | ||
| ], | ||
| scripts: { | ||
| build: "bun build ./src/index.ts --outdir dist --format esm --target browser --external @uipath/solutionpackager-tool-core --external '@uipath/filesystem/*' --external @uipath/filesystem --sourcemap=linked && bun build ./src/browser.ts --outdir dist --format esm --target browser --external @uipath/solutionpackager-tool-core --external '@uipath/filesystem/*' --external @uipath/filesystem --sourcemap=linked && bun build ./src/node.ts --outdir dist --format esm --target node --external @uipath/solutionpackager-tool-core --external '@uipath/filesystem/*' --external @uipath/filesystem --sourcemap=linked && tsc --emitDeclarationOnly --outDir dist", | ||
| clean: "rimraf dist", | ||
| test: "vitest run", | ||
| e2e: "vitest run --config vitest.e2e.config.ts", | ||
| "test:coverage": "vitest run --coverage", | ||
| prepack: "bun run build", | ||
| "publish:dry": "bun publish --dry-run", | ||
| "publish:gh": "bun publish", | ||
| "version:patch": "bun version patch --no-git-tag-version", | ||
| "version:minor": "bun version minor --no-git-tag-version", | ||
| "version:major": "bun version major --no-git-tag-version", | ||
| lint: "biome check ." | ||
| }, | ||
| dependencies: { | ||
| "@uipath/filesystem": "workspace:*", | ||
| "@uipath/solutionpackager-tool-core": "workspace:*", | ||
| "@uipath/common": "workspace:*" | ||
| }, | ||
| peerDependencies: { | ||
| fflate: "^0.8.2" | ||
| }, | ||
| devDependencies: { | ||
| "@types/node": "^25.5.2", | ||
| "@uipath/resource-builder-tool": "2025.11.0-alpha4535-3530", | ||
| "@uipath/tool-agent": "^2.0.0", | ||
| "@uipath/packager-tool-apiworkflow": "workspace:*", | ||
| "@uipath/packager-tool-connector": "workspace:*", | ||
| "@uipath/packager-tool-flow": "workspace:*", | ||
| "@uipath/packager-tool-functions": "workspace:*", | ||
| "@uipath/packager-tool-webapp": "workspace:*", | ||
| "@uipath/packager-tool-workflowcompiler": "workspace:*", | ||
| "@vitest/coverage-v8": "^4.1.6", | ||
| jsdom: "^30.0.1", | ||
| typescript: "^7.0.2", | ||
| "vite-tsconfig-paths": "^6.1.1", | ||
| vitest: "^4.1.6" | ||
| } | ||
| }; | ||
| // ../packager/project-packager/src/publish/services/orchestrator-feeds-service.ts | ||
| var HEADER_TENANT_ID = "X-UIPATH-TenantId"; | ||
| var FEEDS_PATH = "/api/PackageFeeds/GetFeeds"; | ||
| var FOLDERS_PATH = "/api/FoldersNavigation/GetAllFoldersForCurrentUser"; | ||
| var SDK_USER_AGENT = `${package_default.name.replace(/^@uipath\//, "")}/${package_default.version}`; | ||
| class OrchestratorFeedsService { | ||
| logger; | ||
| constructor() { | ||
| this.logger = new ToolLogger("OrchestratorFeedsService", "Feeds"); | ||
| } | ||
| async getAccessibleFeedsAsync(connection) { | ||
| this.ensureOrchestratorUrl(connection); | ||
| this.logger.info(`Fetching accessible feeds from ${connection.orchestratorUrl}`); | ||
| try { | ||
| const json = await orchestratorGet(connection, FEEDS_PATH); | ||
| return Array.isArray(json) ? json : []; | ||
| } catch (error) { | ||
| const { status, statusText, body } = await describeResponseError(error); | ||
| throw new Error(translate.t("solutionpackager.publish.errors.getAccessibleFeedsFailed", { status, statusText, body })); | ||
| } | ||
| } | ||
| async getFoldersForCurrentUserAsync(connection) { | ||
| this.ensureOrchestratorUrl(connection); | ||
| this.logger.info(`Fetching folders from ${connection.orchestratorUrl}`); | ||
| try { | ||
| const json = await orchestratorGet(connection, FOLDERS_PATH); | ||
| return Array.isArray(json) ? json.map(mapExtendedFolder) : []; | ||
| } catch (error) { | ||
| const { status, statusText, body } = await describeResponseError(error); | ||
| throw new Error(translate.t("solutionpackager.publish.errors.getFoldersForCurrentUserFailed", { status, statusText, body })); | ||
| } | ||
| } | ||
| ensureOrchestratorUrl(connection) { | ||
| if (!connection.orchestratorUrl) { | ||
| throw new Error(translate.t("solutionpackager.publish.errors.orchestratorUrlRequired")); | ||
| } | ||
| } | ||
| } | ||
| function mapExtendedFolder(json) { | ||
| return { | ||
| isSelectable: json.IsSelectable, | ||
| hasChildren: json.HasChildren, | ||
| level: json.Level, | ||
| key: json.Key, | ||
| displayName: json.DisplayName, | ||
| fullyQualifiedName: json.FullyQualifiedName, | ||
| description: json.Description, | ||
| folderType: json.FolderType, | ||
| isPersonal: json.IsPersonal, | ||
| provisionType: json.ProvisionType, | ||
| permissionModel: json.PermissionModel, | ||
| parentId: json.ParentId, | ||
| parentKey: json.ParentKey, | ||
| feedType: json.FeedType, | ||
| id: json.Id | ||
| }; | ||
| } | ||
| class OrchestratorResponseError extends Error { | ||
| response; | ||
| constructor(response) { | ||
| super(`Orchestrator request failed with status ${response.status}.`); | ||
| this.response = response; | ||
| this.name = "OrchestratorResponseError"; | ||
| } | ||
| } | ||
| async function orchestratorGet(connection, relativePath) { | ||
| const url = `${normalizeOrchestratorBasePath(connection.orchestratorUrl)}${relativePath}`; | ||
| const response = await fetch(url, { | ||
| method: "GET", | ||
| headers: buildHeaders(connection) | ||
| }); | ||
| if (!response.ok) { | ||
| throw new OrchestratorResponseError(response); | ||
| } | ||
| const text = await response.text(); | ||
| if (text === "" || text === "null") { | ||
| return null; | ||
| } | ||
| return JSON.parse(text); | ||
| } | ||
| function buildHeaders(connection) { | ||
| const headers = {}; | ||
| if (connection.accessToken) { | ||
| headers.Authorization = `Bearer ${connection.accessToken}`; | ||
| } | ||
| if (connection.tenantId) { | ||
| headers[HEADER_TENANT_ID] = connection.tenantId; | ||
| } | ||
| return addSdkUserAgentHeader(headers, SDK_USER_AGENT); | ||
| } | ||
| function normalizeOrchestratorBasePath(orchestratorUrl) { | ||
| let end = orchestratorUrl.length; | ||
| while (end > 0 && orchestratorUrl.charCodeAt(end - 1) === 47) | ||
| end--; | ||
| const trimmed = orchestratorUrl.slice(0, end); | ||
| return /\/orchestrator_$/i.test(trimmed) ? trimmed : `${trimmed}/orchestrator_`; | ||
| } | ||
| async function describeResponseError(error) { | ||
| const response = error?.response; | ||
| if (response) { | ||
| let body = ""; | ||
| try { | ||
| body = (await response.text()).slice(0, 500); | ||
| } catch { | ||
| body = ""; | ||
| } | ||
| return { | ||
| status: response.status, | ||
| statusText: response.statusText, | ||
| body: body ? ` - ${body}` : "" | ||
| }; | ||
| } | ||
| const cause = error?.cause; | ||
| const message = cause instanceof Error ? cause.message : error instanceof Error ? error.message : String(error); | ||
| return { status: "?", statusText: message, body: "" }; | ||
| } | ||
| // ../packager/project-packager/src/publish/services/orchestrator-publisher.ts | ||
| var HEADER_FOLDER_ID = "X-UIPATH-OrganizationUnitId"; | ||
| var HEADER_TENANT_ID2 = "X-UIPATH-TenantId"; | ||
| var HEADER_NUGET_API_KEY = "X-NuGet-ApiKey"; | ||
| var ORCHESTRATOR_RELATIVE_URL = "/orchestrator_"; | ||
| var PROCESSES_UPLOAD_PATH = "/odata/Processes/UiPath.Server.Configuration.OData.UploadPackage"; | ||
| var LIBRARIES_UPLOAD_PATH = "/odata/Libraries/UiPath.Server.Configuration.OData.UploadPackage"; | ||
| class OrchestratorPublisher { | ||
| fileSystem; | ||
| logger; | ||
| feedsService; | ||
| constructor(fileSystem, feedsService) { | ||
| this.fileSystem = fileSystem; | ||
| this.logger = new ToolLogger("ProjectPublisher", "Orchestrator"); | ||
| this.feedsService = feedsService ?? new OrchestratorFeedsService; | ||
| } | ||
| async publishAsync(packagePaths, destination) { | ||
| if (packagePaths.length === 0) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorNoPackages")); | ||
| } | ||
| if (destination.kind === "OrchestratorCustom" /* OrchestratorCustom */) { | ||
| if (!destination.publishUrl) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorCustomPublishUrlRequired")); | ||
| } | ||
| this.logger.info(`Publishing ${packagePaths.length} package(s) to ${destination.publishUrl} (custom)`); | ||
| return this.postPackages(packagePaths, destination.publishUrl, this.buildCustomHeaders(destination)); | ||
| } | ||
| if (!destination.connectionInfo?.cloudUrl) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorCloudUrlRequired")); | ||
| } | ||
| const orchestratorUrl = this.deriveOrchestratorUrl(destination.connectionInfo); | ||
| let feed; | ||
| try { | ||
| feed = await this.resolveFeed(destination, orchestratorUrl); | ||
| } catch (error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorFeedResolutionFailed", { message })); | ||
| } | ||
| const targetUrl = this.buildPublishUrl(orchestratorUrl, feed); | ||
| const headers = this.buildHeaders(destination, feed); | ||
| this.logger.info(`Publishing ${packagePaths.length} package(s) to ${targetUrl} (feed ${feed.name}, ${feed.purpose})`); | ||
| return this.postPackages(packagePaths, targetUrl, headers); | ||
| } | ||
| async postPackages(packagePaths, targetUrl, headers) { | ||
| const form = new FormData; | ||
| for (const packagePath of packagePaths) { | ||
| const data = await this.fileSystem.readFile(packagePath); | ||
| if (!data) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.failedToReadPackage", { path: packagePath })); | ||
| } | ||
| const fileName = this.fileSystem.path.basename(packagePath); | ||
| form.append("file", new Blob([data], { | ||
| type: "application/octet-stream" | ||
| }), fileName); | ||
| } | ||
| const response = await fetch(targetUrl, { | ||
| method: "POST", | ||
| headers, | ||
| body: form | ||
| }); | ||
| if (!response.ok) { | ||
| const body = await this.safeReadBody(response); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorPublishFailed", { | ||
| status: response.status, | ||
| statusText: response.statusText, | ||
| body: body ? ` - ${body}` : "" | ||
| })); | ||
| } | ||
| this.logger.info("Orchestrator publish completed."); | ||
| return new ToolResult(ToolErrorCodes.Success, undefined, packagePaths); | ||
| } | ||
| async resolveFeed(destination, orchestratorUrl) { | ||
| const connection = { | ||
| orchestratorUrl, | ||
| accessToken: destination.connectionInfo.accessToken, | ||
| tenantId: destination.connectionInfo.tenantId | ||
| }; | ||
| const feeds = await this.feedsService.getAccessibleFeedsAsync(connection); | ||
| if (destination.kind === "OrchestratorPersonalWorkspace" /* OrchestratorPersonalWorkspace */) { | ||
| const folders = await this.feedsService.getFoldersForCurrentUserAsync(connection); | ||
| const personalFolder = folders.find((f) => f.feedType === ExtendedFolderDtoFeedTypeEnum.PersonalWorkspace); | ||
| if (!personalFolder) { | ||
| const foldersDebug = folders.length === 0 ? "<none>" : folders.map((f) => `${f.displayName} (id=${f.id}, feedType=${f.feedType})`).join(", "); | ||
| throw new Error(translate.t("solutionpackager.publish.errors.orchestratorPersonalWorkspaceFolderNotFound", { folders: foldersDebug })); | ||
| } | ||
| if (personalFolder.id == null) { | ||
| throw new Error(`Personal-workspace folder "${personalFolder.displayName}" has no id; cannot resolve its feed.`); | ||
| } | ||
| const match2 = feeds.find((f) => f.folderId === personalFolder.id); | ||
| if (!match2) { | ||
| this.throwFeedNotFound(destination, feeds); | ||
| } | ||
| return match2; | ||
| } | ||
| const expectedPurpose = destination.kind === "OrchestratorSharedLibraries" /* OrchestratorSharedLibraries */ ? PackageFeedDtoPurposeEnum.Libraries : PackageFeedDtoPurposeEnum.Processes; | ||
| const match = feeds.find((f) => f.purpose === expectedPurpose && f.folderId == null); | ||
| if (!match) { | ||
| this.throwFeedNotFound(destination, feeds); | ||
| } | ||
| return match; | ||
| } | ||
| throwFeedNotFound(destination, feeds) { | ||
| const available = feeds.length === 0 ? "<none>" : feeds.map((f) => `${f.name} (purpose=${f.purpose}, folderId=${f.folderId ?? "null"})`).join(", "); | ||
| throw new Error(translate.t("solutionpackager.publish.errors.orchestratorFeedNotFound", { | ||
| kind: destination.kind, | ||
| available | ||
| })); | ||
| } | ||
| buildPublishUrl(orchestratorUrl, feed) { | ||
| const baseUrl = feed.publishUrl ? feed.publishUrl : `${orchestratorUrl}${feed.purpose === PackageFeedDtoPurposeEnum.Libraries ? LIBRARIES_UPLOAD_PATH : PROCESSES_UPLOAD_PATH}`; | ||
| const parsed = new URL(baseUrl); | ||
| if (feed.id) { | ||
| parsed.searchParams.set("feedId", feed.id); | ||
| } | ||
| return parsed.toString(); | ||
| } | ||
| deriveOrchestratorUrl(connectionInfo) { | ||
| const raw = connectionInfo.cloudUrl ?? ""; | ||
| let end = raw.length; | ||
| while (end > 0 && raw.charCodeAt(end - 1) === 47) | ||
| end--; | ||
| return `${raw.slice(0, end)}${ORCHESTRATOR_RELATIVE_URL}`; | ||
| } | ||
| buildHeaders(destination, feed) { | ||
| const headers = this.buildAuthHeaders(destination.connectionInfo); | ||
| const folderHeader = destination.kind === "OrchestratorSharedLibraries" /* OrchestratorSharedLibraries */ ? destination.folderId : feed.folderId; | ||
| if (folderHeader != null) { | ||
| headers[HEADER_FOLDER_ID] = String(folderHeader); | ||
| } | ||
| if (feed.authenticationType === PackageFeedDtoAuthenticationTypeEnum.ApiKey && feed.apiKey) { | ||
| headers[HEADER_NUGET_API_KEY] = feed.apiKey; | ||
| } | ||
| return headers; | ||
| } | ||
| buildCustomHeaders(destination) { | ||
| const headers = this.buildAuthHeaders(destination.connectionInfo); | ||
| if (destination.folderId != null) { | ||
| headers[HEADER_FOLDER_ID] = String(destination.folderId); | ||
| } | ||
| if (destination.apiKey) { | ||
| headers[HEADER_NUGET_API_KEY] = destination.apiKey; | ||
| } | ||
| return headers; | ||
| } | ||
| buildAuthHeaders(connectionInfo) { | ||
| const headers = {}; | ||
| if (connectionInfo.accessToken) { | ||
| headers.Authorization = `Bearer ${connectionInfo.accessToken}`; | ||
| } | ||
| if (connectionInfo.tenantId) { | ||
| headers[HEADER_TENANT_ID2] = connectionInfo.tenantId; | ||
| } | ||
| return headers; | ||
| } | ||
| async safeReadBody(response) { | ||
| try { | ||
| const text = await response.text(); | ||
| return text.slice(0, 500); | ||
| } catch { | ||
| return ""; | ||
| } | ||
| } | ||
| } | ||
| // ../packager/project-packager/src/publish/services/project-publisher.ts | ||
| class ProjectPublisher { | ||
| fileSystem; | ||
| logger; | ||
| localFolderPublisher; | ||
| nugetFeedPublisher; | ||
| orchestratorPublisher; | ||
| constructor(fileSystem, publishers) { | ||
| this.fileSystem = fileSystem; | ||
| this.logger = new ToolLogger("ProjectPublisher", "Publish"); | ||
| this.localFolderPublisher = publishers?.localFolder ?? new LocalFolderPublisher(fileSystem); | ||
| this.nugetFeedPublisher = publishers?.nugetFeed ?? new NugetFeedPublisher(fileSystem); | ||
| this.orchestratorPublisher = publishers?.orchestrator ?? new OrchestratorPublisher(fileSystem); | ||
| } | ||
| async publishAsync(options) { | ||
| if (!options.packagePaths || options.packagePaths.length === 0) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.atLeastOnePackage")); | ||
| } | ||
| for (const path of options.packagePaths) { | ||
| if (!await this.fileSystem.exists(path)) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.packageNotFound", { path })); | ||
| } | ||
| } | ||
| try { | ||
| const destination = options.destination; | ||
| switch (destination.kind) { | ||
| case "LocalFolder" /* LocalFolder */: | ||
| return await this.localFolderPublisher.publishAsync(options.packagePaths, destination); | ||
| case "NugetFeed" /* NugetFeed */: | ||
| return await this.nugetFeedPublisher.publishAsync(options.packagePaths, destination); | ||
| case "OrchestratorPersonalWorkspace" /* OrchestratorPersonalWorkspace */: | ||
| case "OrchestratorTenantProcesses" /* OrchestratorTenantProcesses */: | ||
| case "OrchestratorSharedLibraries" /* OrchestratorSharedLibraries */: | ||
| case "OrchestratorCustom" /* OrchestratorCustom */: | ||
| return await this.orchestratorPublisher.publishAsync(options.packagePaths, destination); | ||
| default: { | ||
| const exhaustive = destination; | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.unknownDestination", { destination: JSON.stringify(exhaustive) })); | ||
| } | ||
| } | ||
| } catch (error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| const localized = translate.t("solutionpackager.publish.errors.publishFailed", { message }); | ||
| this.logger.error(localized); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, localized); | ||
| } | ||
| } | ||
| } | ||
| export { | ||
| signNupkgsAsync, | ||
| setGlobalLogHandler, | ||
| resolveProducedNupkgsAsync, | ||
| ToolsFactory, | ||
| ToolLogger, | ||
| TelemetryService, | ||
| TelemetryNames, | ||
| RulesConfigFileType, | ||
| PublishDestinationKind, | ||
| ProjectValidateOptionsValidator, | ||
| ProjectValidateOptions, | ||
| ProjectToolExecutor, | ||
| ProjectRestoreOptions, | ||
| ProjectPublisher, | ||
| ProjectPublishOptions, | ||
| ProjectPackager, | ||
| ProjectPackOptions, | ||
| ProjectLoader, | ||
| ProjectCleanupOptions, | ||
| ProjectBuildOptionsValidator, | ||
| ProjectBuildOptions, | ||
| PackagerParametersValidator, | ||
| PackagerParameters, | ||
| PackService, | ||
| GovernancePolicyService, | ||
| ConsoleTelemetryProvider, | ||
| BrowserContextStorage | ||
| }; | ||
| //# debugId=09DA3D1EF197419C64756E2164756E21 |
Sorry, the diff of this file is too big to display
| import { | ||
| catchError, | ||
| getFileSystem, | ||
| startServer | ||
| } from "./packager-tool-4f38v0ry.js"; | ||
| import"./packager-tool-1ps2qeqg.js"; | ||
| import"./packager-tool-wckvcay0.js"; | ||
| // ../auth/src/strategies/node-strategy.ts | ||
| class NodeAuthStrategy { | ||
| async execute(url, redirectUri, expectedState, opts) { | ||
| const fs = getFileSystem(); | ||
| const callbackUrl = await startServer({ | ||
| redirectUri, | ||
| timeoutMs: opts?.timeoutMs, | ||
| signal: opts?.signal, | ||
| onListening: async () => { | ||
| let safeUrl = ""; | ||
| for (const ch of url) { | ||
| const c = ch.charCodeAt(0); | ||
| if (c > 31 && (c < 128 || c > 159)) | ||
| safeUrl += ch; | ||
| } | ||
| if (opts?.noBrowser) { | ||
| if (!opts.onAuthUrl) { | ||
| throw new Error("Headless login (noBrowser) requires an onAuthUrl handler " + "to surface the authorize URL, but none was provided."); | ||
| } | ||
| opts.onAuthUrl(safeUrl); | ||
| return; | ||
| } | ||
| const [openError] = await catchError(fs.utils.open(url)); | ||
| if (!openError) | ||
| return; | ||
| const isSpawnError = "code" in openError && openError.code === "ENOENT"; | ||
| if (isSpawnError) { | ||
| throw new Error("Could not open a browser. No supported browser launcher was found. " + `On a headless or minimal system, use non-interactive login instead: | ||
| ` + ` uip login --client-id <id> --client-secret <secret> -t <tenant> | ||
| ` + "Or install a browser opener for your OS (e.g. xdg-utils on Linux).", { cause: openError }); | ||
| } | ||
| throw new Error("Could not open the browser automatically. " + `Visit this URL to authenticate: | ||
| ${safeUrl} | ||
| `, { cause: openError }); | ||
| } | ||
| }); | ||
| const returnedState = callbackUrl.searchParams.get("state"); | ||
| if (returnedState !== expectedState) { | ||
| throw new Error("OAuth state mismatch — the callback state does not match the expected value. " + "This may indicate a CSRF attack. Please try signing in again."); | ||
| } | ||
| const code = callbackUrl.searchParams.get("code"); | ||
| if (!code) { | ||
| throw new Error("No authorization code received"); | ||
| } | ||
| return code; | ||
| } | ||
| } | ||
| export { | ||
| NodeAuthStrategy | ||
| }; | ||
| //# debugId=E5B2BD2B3B179D3D64756E2164756E21 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| // ../auth/src/constants.ts | ||
| var UIPATH_HOME_DIR = ".uipath"; | ||
| var AUTH_FILENAME = ".auth"; | ||
| var DEFAULT_BASE_URL = "https://cloud.uipath.com"; | ||
| var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000; | ||
| var AUTH_CANCELLED_ERROR_CODE = "EAUTHCANCELLED"; | ||
| export { UIPATH_HOME_DIR, AUTH_FILENAME, DEFAULT_BASE_URL, DEFAULT_AUTH_TIMEOUT_MS, AUTH_CANCELLED_ERROR_CODE }; | ||
| //# debugId=6DCB1840782D2B3E64756E2164756E21 |
| import { | ||
| I18nManager, | ||
| NugetConstants, | ||
| NugetPackager, | ||
| Path, | ||
| ProjectTool, | ||
| ProjectTypes, | ||
| TemporaryStorageService, | ||
| ToolErrorCodes, | ||
| ToolResult, | ||
| ensureContentOperateFile, | ||
| translate | ||
| } from "./packager-tool-h1tyrbff.js"; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/de.json | ||
| var de_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/en.ts | ||
| var en = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/es.json | ||
| var es_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/es-MX.json | ||
| var es_MX_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/fr.json | ||
| var fr_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/ja.json | ||
| var ja_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/ko.json | ||
| var ko_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/pt.json | ||
| var pt_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/pt-BR.json | ||
| var pt_BR_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/ro.json | ||
| var ro_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/ru.json | ||
| var ru_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/tr.json | ||
| var tr_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/zh-CN.json | ||
| var zh_CN_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/zh-TW.json | ||
| var zh_TW_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/locales/zu.json | ||
| var zu_default = { | ||
| toolApiworkflow: { | ||
| info: { | ||
| restoreNotRequired: "Restore operation is not required for API projects", | ||
| validateNotRequired: "Validate operation is not required for API projects", | ||
| disposing: "Disposing API Workflows Tool" | ||
| }, | ||
| progress: { | ||
| copyingFiles: "Copying files...", | ||
| creatingOperateFile: "Creating operate.json file...", | ||
| creatingPackageDescriptor: "Creating package-descriptor.json file...", | ||
| creatingNugetPackage: "Creating NuGet package...", | ||
| packageCreatedSuccessfully: "Package created successfully" | ||
| }, | ||
| success: { | ||
| done: "done" | ||
| }, | ||
| errors: { | ||
| buildFailed: "An error occurred while building API project files", | ||
| packFailed: "An error occurred while packing API project" | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-tool-apiworkflow/src/i18n/index.ts | ||
| I18nManager.registerTranslations("en", en); | ||
| I18nManager.registerTranslations("de", de_default); | ||
| I18nManager.registerTranslations("es", es_default); | ||
| I18nManager.registerTranslations("es-MX", es_MX_default); | ||
| I18nManager.registerTranslations("fr", fr_default); | ||
| I18nManager.registerTranslations("ja", ja_default); | ||
| I18nManager.registerTranslations("ko", ko_default); | ||
| I18nManager.registerTranslations("pt", pt_default); | ||
| I18nManager.registerTranslations("pt-BR", pt_BR_default); | ||
| I18nManager.registerTranslations("ro", ro_default); | ||
| I18nManager.registerTranslations("ru", ru_default); | ||
| I18nManager.registerTranslations("tr", tr_default); | ||
| I18nManager.registerTranslations("zh-CN", zh_CN_default); | ||
| I18nManager.registerTranslations("zh-TW", zh_TW_default); | ||
| I18nManager.registerTranslations("zu", zu_default); | ||
| // ../packager/packager-tool-apiworkflow/src/api-workflows-tool.ts | ||
| class ApiWorkflowsTool extends ProjectTool { | ||
| _temporaryStorage; | ||
| constructor(fileSystem, logger) { | ||
| super(fileSystem, logger); | ||
| this._temporaryStorage = new TemporaryStorageService(fileSystem); | ||
| } | ||
| async restoreAsync(_options, _cancellationToken) { | ||
| this.logger.info(translate.t("toolApiworkflow.info.restoreNotRequired")); | ||
| return ToolResult.success(); | ||
| } | ||
| async validateAsync(_options, _cancellationToken) { | ||
| this.logger.info(translate.t("toolApiworkflow.info.validateNotRequired")); | ||
| return ToolResult.success(); | ||
| } | ||
| async buildAsync(options, _cancellationToken) { | ||
| const tempFolder = await this._temporaryStorage.getTempFolderPath(); | ||
| const localBuildFolder = Path.join(tempFolder, NugetConstants.OutputFolderName); | ||
| const contentFolder = Path.join(localBuildFolder, NugetConstants.ContentFolderName); | ||
| try { | ||
| this.logger.progress(translate.t("toolApiworkflow.progress.copyingFiles")); | ||
| await this.copyFiles(options.projectPath, contentFolder); | ||
| this.logger.progress(translate.t("toolApiworkflow.progress.creatingOperateFile")); | ||
| await this.createOperateFile(options, contentFolder); | ||
| this.logger.progress(translate.t("toolApiworkflow.progress.creatingPackageDescriptor")); | ||
| await this.createPackageDescriptor(localBuildFolder); | ||
| return new ToolResult(ToolErrorCodes.Success, translate.t("toolApiworkflow.success.done"), [localBuildFolder]); | ||
| } catch (error) { | ||
| const errorMessage = error instanceof Error ? error.toString() : String(error); | ||
| this.logger.error(errorMessage); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("toolApiworkflow.errors.buildFailed")); | ||
| } | ||
| } | ||
| async packAsync(options, cancellationToken) { | ||
| const buildResult = await this.buildAsync(options, cancellationToken); | ||
| if (!buildResult.isSuccess) { | ||
| return buildResult; | ||
| } | ||
| const localBuildFolder = buildResult.packages[0]; | ||
| try { | ||
| this.logger.progress(translate.t("toolApiworkflow.progress.creatingNugetPackage")); | ||
| const nupkgFileName = `${options.package.id}.${options.package.version}.nupkg`; | ||
| const nupkgPath = Path.join(options.outputPath, nupkgFileName); | ||
| const packager = new NugetPackager(this.fileSystem); | ||
| const result = await packager.packAsync(localBuildFolder, options.package, nupkgPath); | ||
| this.logger.progress(translate.t("toolApiworkflow.progress.packageCreatedSuccessfully")); | ||
| return new ToolResult(ToolErrorCodes.Success, translate.t("toolApiworkflow.success.done"), [result.outputPath]); | ||
| } catch (error) { | ||
| const errorMessage = error instanceof Error ? error.toString() : String(error); | ||
| this.logger.error(errorMessage); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("toolApiworkflow.errors.packFailed")); | ||
| } | ||
| } | ||
| async dispose() { | ||
| this.logger.info(translate.t("toolApiworkflow.info.disposing")); | ||
| try { | ||
| await this._temporaryStorage.cleanup(); | ||
| } catch {} | ||
| } | ||
| async copyFiles(sourcePath, destinationPath) { | ||
| await this.fileSystem.mkdir(destinationPath); | ||
| const files = await this.fileSystem.readdir(sourcePath); | ||
| for (const file of files) { | ||
| const sourceFile = Path.join(sourcePath, file); | ||
| const destinationFile = Path.join(destinationPath, file); | ||
| const stat = await this.fileSystem.stat(sourceFile); | ||
| if (stat?.isFile()) { | ||
| const content = await this.fileSystem.readFile(sourceFile); | ||
| if (content) { | ||
| await this.fileSystem.writeFile(destinationFile, content); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| async createOperateFile(options, contentFolder) { | ||
| await ensureContentOperateFile(this.fileSystem, { | ||
| contentFolder, | ||
| projectPath: options.projectPath, | ||
| projectStorageId: options.projectStorageId, | ||
| contentType: ProjectTypes.Api | ||
| }); | ||
| } | ||
| async createPackageDescriptor(localBuildFolder) { | ||
| const packageDescriptor = { | ||
| files: {} | ||
| }; | ||
| this.addFileIfExists(packageDescriptor, localBuildFolder, NugetConstants.OperateFileName, NugetConstants.OperateFileName); | ||
| this.addFileIfExists(packageDescriptor, localBuildFolder, NugetConstants.EntryPointsFileName, NugetConstants.EntryPointsFileName); | ||
| this.addFileIfExists(packageDescriptor, localBuildFolder, NugetConstants.BindingsFileId, NugetConstants.BindingsV2FileName); | ||
| const packageDescriptorPath = Path.join(localBuildFolder, NugetConstants.ContentFolderName, NugetConstants.PackageDescriptorFileName); | ||
| const packageDescriptorJson = JSON.stringify({ | ||
| $schema: "https://cloud.uipath.com/draft/2024-12/package-descriptor", | ||
| ...packageDescriptor | ||
| }, null, 2); | ||
| await this.fileSystem.writeFile(packageDescriptorPath, packageDescriptorJson); | ||
| } | ||
| addFileIfExists(packageDescriptor, _rootFolder, key, fileName) { | ||
| const relativePath = Path.join(NugetConstants.ContentFolderName, fileName); | ||
| packageDescriptor.files[key] = relativePath; | ||
| } | ||
| } | ||
| // ../packager/packager-tool-apiworkflow/src/api-workflow-tool-factory.ts | ||
| class ApiWorkflowToolFactory { | ||
| supportedTypes = [ProjectTypes.Api]; | ||
| async createAsync(logger, fileSystem) { | ||
| return new ApiWorkflowsTool(fileSystem, logger); | ||
| } | ||
| } | ||
| // ../packager/packager-core/src/i18n/types.ts | ||
| function isPluralForm(value) { | ||
| return typeof value === "object" && value !== null && "other" in value; | ||
| } | ||
| function selectPluralForm(forms, count) { | ||
| if (count === 0 && forms.zero !== undefined) { | ||
| return forms.zero; | ||
| } | ||
| if (count === 1 && forms.one !== undefined) { | ||
| return forms.one; | ||
| } | ||
| if (count === 2 && forms.two !== undefined) { | ||
| return forms.two; | ||
| } | ||
| if (forms.few !== undefined) { | ||
| const mod10 = count % 10; | ||
| const mod100 = count % 100; | ||
| if (mod10 >= 2 && mod10 <= 4 && (mod100 < 10 || mod100 >= 20)) { | ||
| return forms.few; | ||
| } | ||
| } | ||
| if (forms.many !== undefined) { | ||
| const mod10 = count % 10; | ||
| const mod100 = count % 100; | ||
| if (count === 0 || mod10 === 0 && mod100 !== 0 || mod10 >= 5 && mod10 <= 9 || mod100 >= 11 && mod100 <= 14) { | ||
| return forms.many; | ||
| } | ||
| } | ||
| return forms.other; | ||
| } | ||
| // ../packager/packager-core/src/i18n/i18n-manager.ts | ||
| class I18nManager2 { | ||
| static translations = {}; | ||
| static currentLocale = "en"; | ||
| static fallbackLocale = "en"; | ||
| static registerTranslations(locale, catalog) { | ||
| if (!I18nManager2.translations[locale]) { | ||
| I18nManager2.translations[locale] = {}; | ||
| } | ||
| I18nManager2.translations[locale] = I18nManager2.deepMerge(I18nManager2.translations[locale], catalog); | ||
| } | ||
| static setLocale(locale) { | ||
| const normalized = I18nManager2.normalizeLocale(locale); | ||
| if (I18nManager2.translations[normalized]) { | ||
| I18nManager2.currentLocale = normalized; | ||
| return normalized; | ||
| } | ||
| const baseLocale = normalized.split("-")[0]; | ||
| if (baseLocale !== normalized && I18nManager2.translations[baseLocale]) { | ||
| I18nManager2.currentLocale = baseLocale; | ||
| return baseLocale; | ||
| } | ||
| return I18nManager2.currentLocale; | ||
| } | ||
| static getLocale() { | ||
| return I18nManager2.currentLocale; | ||
| } | ||
| static setFallbackLocale(locale) { | ||
| I18nManager2.fallbackLocale = I18nManager2.normalizeLocale(locale); | ||
| } | ||
| static t(key, params, locale) { | ||
| const targetLocale = locale ? I18nManager2.normalizeLocale(locale) : I18nManager2.currentLocale; | ||
| let value = I18nManager2.getTranslationValue(key, targetLocale); | ||
| if (value === undefined && targetLocale !== I18nManager2.fallbackLocale) { | ||
| value = I18nManager2.getTranslationValue(key, I18nManager2.fallbackLocale); | ||
| } | ||
| if (value === undefined) { | ||
| return key; | ||
| } | ||
| if (isPluralForm(value) && params && "count" in params) { | ||
| const count = typeof params.count === "number" ? params.count : Number(params.count); | ||
| value = selectPluralForm(value, count); | ||
| } else if (isPluralForm(value)) { | ||
| value = value.other; | ||
| } | ||
| if (typeof value !== "string") { | ||
| return key; | ||
| } | ||
| return params ? I18nManager2.interpolate(value, params) : value; | ||
| } | ||
| static has(key, locale) { | ||
| const targetLocale = locale ? I18nManager2.normalizeLocale(locale) : I18nManager2.currentLocale; | ||
| const value = I18nManager2.getTranslationValue(key, targetLocale); | ||
| if (value !== undefined) { | ||
| return true; | ||
| } | ||
| if (targetLocale !== I18nManager2.fallbackLocale) { | ||
| return I18nManager2.getTranslationValue(key, I18nManager2.fallbackLocale) !== undefined; | ||
| } | ||
| return false; | ||
| } | ||
| static getAvailableLocales() { | ||
| return Object.keys(I18nManager2.translations); | ||
| } | ||
| static clearTranslations() { | ||
| I18nManager2.translations = {}; | ||
| I18nManager2.currentLocale = "en"; | ||
| } | ||
| static getTranslationValue(key, locale) { | ||
| const catalog = I18nManager2.translations[locale]; | ||
| if (!catalog) { | ||
| return; | ||
| } | ||
| const keys = key.split("."); | ||
| let value = catalog; | ||
| for (const k of keys) { | ||
| if (value && typeof value === "object" && k in value) { | ||
| value = value[k]; | ||
| } else { | ||
| return; | ||
| } | ||
| } | ||
| return value; | ||
| } | ||
| static interpolate(template, params) { | ||
| return template.replace(/\{(\w+)\}/g, (_, key) => { | ||
| const value = params[key]; | ||
| return value !== undefined ? String(value) : `{${key}}`; | ||
| }); | ||
| } | ||
| static normalizeLocale(locale) { | ||
| const normalized = locale.toLowerCase().replace(/_/g, "-"); | ||
| const specialLocales = ["es-mx", "pt-br", "zh-cn", "zh-tw"]; | ||
| if (specialLocales.includes(normalized)) { | ||
| return normalized; | ||
| } | ||
| return normalized.split("-")[0]; | ||
| } | ||
| static deepMerge(target, source) { | ||
| const result = { ...target }; | ||
| for (const key of Object.keys(source)) { | ||
| const sourceValue = source[key]; | ||
| const targetValue = result[key]; | ||
| if (sourceValue && typeof sourceValue === "object" && !Array.isArray(sourceValue) && targetValue && typeof targetValue === "object" && !Array.isArray(targetValue)) { | ||
| result[key] = I18nManager2.deepMerge(targetValue, sourceValue); | ||
| } else { | ||
| result[key] = sourceValue; | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| } | ||
| // ../packager/packager-core/src/i18n/locales/de.ts | ||
| var de = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/en.ts | ||
| var en2 = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/es.ts | ||
| var es = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/es-MX.ts | ||
| var es_MX = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/fr.ts | ||
| var fr = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/ja.ts | ||
| var ja = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/ko.ts | ||
| var ko = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/pt.ts | ||
| var pt = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/pt-BR.ts | ||
| var pt_BR = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/ro.ts | ||
| var ro = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/ru.ts | ||
| var ru = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/tr.ts | ||
| var tr = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/zh-CN.ts | ||
| var zh_CN = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/zh-TW.ts | ||
| var zh_TW = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/locales/zu.ts | ||
| var zu = { | ||
| toolCore: { | ||
| errors: { | ||
| internal: "Internal error: {message}", | ||
| fileNotFound: "File not found: {path}", | ||
| fileReadFailed: "Failed to read file: {path}", | ||
| fileWriteFailed: "Failed to write file: {path}", | ||
| directoryNotFound: "Directory not found: {path}", | ||
| invalidPath: "{path} is not a valid path", | ||
| operationCanceled: "Operation was canceled", | ||
| invalidParameter: "Invalid parameter: {parameter}" | ||
| }, | ||
| progress: { | ||
| copying: "Copying files...", | ||
| building: "Building project...", | ||
| packaging: "Creating package...", | ||
| validating: "Validating...", | ||
| analyzing: "Analyzing...", | ||
| restoring: "Restoring dependencies..." | ||
| }, | ||
| validation: { | ||
| requiredField: "{field} is required", | ||
| invalidValue: "Invalid value for {field}", | ||
| pathNotFound: "Path not found: {path}", | ||
| fileRequired: "File is required: {path}", | ||
| directoryRequired: "Directory is required: {path}" | ||
| }, | ||
| warnings: { | ||
| factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration." | ||
| }, | ||
| info: { | ||
| operationComplete: "Operation completed successfully", | ||
| filesProcessed: { | ||
| zero: "No files processed", | ||
| one: "{count} file processed", | ||
| other: "{count} files processed" | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| // ../packager/packager-core/src/i18n/translation-service.ts | ||
| class TranslationService { | ||
| static instance; | ||
| currentLocale = "en"; | ||
| constructor() {} | ||
| static getInstance() { | ||
| if (!TranslationService.instance) { | ||
| TranslationService.instance = new TranslationService; | ||
| } | ||
| return TranslationService.instance; | ||
| } | ||
| setLocale(locale) { | ||
| this.currentLocale = I18nManager2.setLocale(locale); | ||
| } | ||
| getLocale() { | ||
| return this.currentLocale; | ||
| } | ||
| t(key, params) { | ||
| return I18nManager2.t(key, params, this.currentLocale); | ||
| } | ||
| tLocale(key, locale, params) { | ||
| return I18nManager2.t(key, params, locale); | ||
| } | ||
| has(key) { | ||
| return I18nManager2.has(key, this.currentLocale); | ||
| } | ||
| getAvailableLocales() { | ||
| return I18nManager2.getAvailableLocales(); | ||
| } | ||
| } | ||
| var translate2 = TranslationService.getInstance(); | ||
| // ../packager/packager-core/src/i18n/index.ts | ||
| I18nManager2.registerTranslations("en", en2); | ||
| I18nManager2.registerTranslations("de", de); | ||
| I18nManager2.registerTranslations("es", es); | ||
| I18nManager2.registerTranslations("es-mx", es_MX); | ||
| I18nManager2.registerTranslations("fr", fr); | ||
| I18nManager2.registerTranslations("ja", ja); | ||
| I18nManager2.registerTranslations("ko", ko); | ||
| I18nManager2.registerTranslations("pt", pt); | ||
| I18nManager2.registerTranslations("pt-br", pt_BR); | ||
| I18nManager2.registerTranslations("ro", ro); | ||
| I18nManager2.registerTranslations("ru", ru); | ||
| I18nManager2.registerTranslations("tr", tr); | ||
| I18nManager2.registerTranslations("zh-cn", zh_CN); | ||
| I18nManager2.registerTranslations("zh-tw", zh_TW); | ||
| I18nManager2.registerTranslations("zu", zu); | ||
| I18nManager2.setLocale("en"); | ||
| // ../packager/packager-core/src/services/tools-factory-repository.ts | ||
| class ToolsFactoryRepository { | ||
| projectFactoryMap = new Map; | ||
| solutionFactory = null; | ||
| registerProjectToolFactory(factory) { | ||
| for (const type of factory.supportedTypes) { | ||
| const existing = this.projectFactoryMap.get(type); | ||
| if (existing) { | ||
| if (existing.constructor?.name !== factory.constructor?.name) { | ||
| console.warn(`Tool factory conflict for project type '${type}': ` + `'${existing.constructor?.name}' already registered, ` + `ignoring '${factory.constructor?.name}'.`); | ||
| } | ||
| continue; | ||
| } | ||
| this.projectFactoryMap.set(type, factory); | ||
| } | ||
| } | ||
| registerSolutionToolFactory(factory) { | ||
| this.solutionFactory = factory; | ||
| } | ||
| getSolutionToolFactory() { | ||
| if (!this.solutionFactory) { | ||
| throw new Error("No solution tool factory is registered"); | ||
| } | ||
| return this.solutionFactory; | ||
| } | ||
| canHandleProject(projectType) { | ||
| return this.projectFactoryMap.has(projectType); | ||
| } | ||
| getProjectToolFactory(projectType) { | ||
| const factory = this.projectFactoryMap.get(projectType); | ||
| if (!factory) { | ||
| throw new Error(`No tool factory found for project type '${projectType}'`); | ||
| } | ||
| return factory; | ||
| } | ||
| reset() { | ||
| this.projectFactoryMap.clear(); | ||
| this.solutionFactory = null; | ||
| } | ||
| } | ||
| var REGISTRY_KEY = Symbol.for("@uipath/solutionpackager-tool-core/toolsFactoryRepository"); | ||
| var _global = globalThis; | ||
| if (!_global[REGISTRY_KEY]) { | ||
| _global[REGISTRY_KEY] = new ToolsFactoryRepository; | ||
| } | ||
| var toolsFactoryRepository = _global[REGISTRY_KEY]; | ||
| // src/packager-tool.ts | ||
| function registerPackagerFactories() { | ||
| toolsFactoryRepository.registerProjectToolFactory(new ApiWorkflowToolFactory); | ||
| } | ||
| export { registerPackagerFactories }; | ||
| //# debugId=9E99B96F468A8D8864756E2164756E21 |
| import { | ||
| AUTH_CANCELLED_ERROR_CODE, | ||
| DEFAULT_AUTH_TIMEOUT_MS | ||
| } from "./packager-tool-1ps2qeqg.js"; | ||
| import { | ||
| __require | ||
| } from "./packager-tool-wckvcay0.js"; | ||
| // ../filesystem/src/node.ts | ||
| import { randomUUID } from "node:crypto"; | ||
| import { existsSync } from "node:fs"; | ||
| import * as fs6 from "node:fs/promises"; | ||
| import * as os2 from "node:os"; | ||
| import * as path2 from "node:path"; | ||
| // ../../node_modules/open/index.js | ||
| import process8 from "node:process"; | ||
| import path from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
| import childProcess3 from "node:child_process"; | ||
| import fs5, { constants as fsConstants2 } from "node:fs/promises"; | ||
| // ../../node_modules/wsl-utils/index.js | ||
| import { promisify as promisify2 } from "node:util"; | ||
| import childProcess2 from "node:child_process"; | ||
| import fs4, { constants as fsConstants } from "node:fs/promises"; | ||
| // ../../node_modules/wsl-utils/node_modules/is-wsl/index.js | ||
| import process2 from "node:process"; | ||
| import os from "node:os"; | ||
| import fs3 from "node:fs"; | ||
| // ../../node_modules/is-inside-container/index.js | ||
| import fs2 from "node:fs"; | ||
| // ../../node_modules/is-inside-container/node_modules/is-docker/index.js | ||
| import fs from "node:fs"; | ||
| var isDockerCached; | ||
| function hasDockerEnv() { | ||
| try { | ||
| fs.statSync("/.dockerenv"); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| function hasDockerCGroup() { | ||
| try { | ||
| return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker"); | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| function isDocker() { | ||
| if (isDockerCached === undefined) { | ||
| isDockerCached = hasDockerEnv() || hasDockerCGroup(); | ||
| } | ||
| return isDockerCached; | ||
| } | ||
| // ../../node_modules/is-inside-container/index.js | ||
| var cachedResult; | ||
| var hasContainerEnv = () => { | ||
| try { | ||
| fs2.statSync("/run/.containerenv"); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } | ||
| }; | ||
| function isInsideContainer() { | ||
| if (cachedResult === undefined) { | ||
| cachedResult = hasContainerEnv() || isDocker(); | ||
| } | ||
| return cachedResult; | ||
| } | ||
| // ../../node_modules/wsl-utils/node_modules/is-wsl/index.js | ||
| var isWsl = () => { | ||
| if (process2.platform !== "linux") { | ||
| return false; | ||
| } | ||
| if (os.release().toLowerCase().includes("microsoft")) { | ||
| if (isInsideContainer()) { | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
| try { | ||
| if (fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) { | ||
| return !isInsideContainer(); | ||
| } | ||
| } catch {} | ||
| if (fs3.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs3.existsSync("/run/WSL")) { | ||
| return !isInsideContainer(); | ||
| } | ||
| return false; | ||
| }; | ||
| var is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl(); | ||
| // ../../node_modules/powershell-utils/index.js | ||
| import process3 from "node:process"; | ||
| import { Buffer } from "node:buffer"; | ||
| import { promisify } from "node:util"; | ||
| import childProcess from "node:child_process"; | ||
| var execFile = promisify(childProcess.execFile); | ||
| var powerShellPath = () => `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`; | ||
| var executePowerShell = async (command, options = {}) => { | ||
| const { | ||
| powerShellPath: psPath, | ||
| ...execFileOptions | ||
| } = options; | ||
| const encodedCommand = executePowerShell.encodeCommand(command); | ||
| return execFile(psPath ?? powerShellPath(), [ | ||
| ...executePowerShell.argumentsPrefix, | ||
| encodedCommand | ||
| ], { | ||
| encoding: "utf8", | ||
| ...execFileOptions | ||
| }); | ||
| }; | ||
| executePowerShell.argumentsPrefix = [ | ||
| "-NoProfile", | ||
| "-NonInteractive", | ||
| "-ExecutionPolicy", | ||
| "Bypass", | ||
| "-EncodedCommand" | ||
| ]; | ||
| executePowerShell.encodeCommand = (command) => Buffer.from(command, "utf16le").toString("base64"); | ||
| executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`; | ||
| // ../../node_modules/wsl-utils/utilities.js | ||
| function parseMountPointFromConfig(content) { | ||
| for (const line of content.split(` | ||
| `)) { | ||
| if (/^\s*#/.test(line)) { | ||
| continue; | ||
| } | ||
| const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line); | ||
| if (!match) { | ||
| continue; | ||
| } | ||
| return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, ""); | ||
| } | ||
| } | ||
| // ../../node_modules/wsl-utils/index.js | ||
| var execFile2 = promisify2(childProcess2.execFile); | ||
| var wslDrivesMountPoint = (() => { | ||
| const defaultMountPoint = "/mnt/"; | ||
| let mountPoint; | ||
| return async function() { | ||
| if (mountPoint) { | ||
| return mountPoint; | ||
| } | ||
| const configFilePath = "/etc/wsl.conf"; | ||
| let isConfigFileExists = false; | ||
| try { | ||
| await fs4.access(configFilePath, fsConstants.F_OK); | ||
| isConfigFileExists = true; | ||
| } catch {} | ||
| if (!isConfigFileExists) { | ||
| return defaultMountPoint; | ||
| } | ||
| const configContent = await fs4.readFile(configFilePath, { encoding: "utf8" }); | ||
| const parsedMountPoint = parseMountPointFromConfig(configContent); | ||
| if (parsedMountPoint === undefined) { | ||
| return defaultMountPoint; | ||
| } | ||
| mountPoint = parsedMountPoint; | ||
| mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`; | ||
| return mountPoint; | ||
| }; | ||
| })(); | ||
| var powerShellPathFromWsl = async () => { | ||
| const mountPoint = await wslDrivesMountPoint(); | ||
| return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`; | ||
| }; | ||
| var powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath; | ||
| var canAccessPowerShellPromise; | ||
| var canAccessPowerShell = async () => { | ||
| canAccessPowerShellPromise ??= (async () => { | ||
| try { | ||
| const psPath = await powerShellPath2(); | ||
| await fs4.access(psPath, fsConstants.X_OK); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } | ||
| })(); | ||
| return canAccessPowerShellPromise; | ||
| }; | ||
| var wslDefaultBrowser = async () => { | ||
| const psPath = await powerShellPath2(); | ||
| const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`; | ||
| const { stdout } = await executePowerShell(command, { powerShellPath: psPath }); | ||
| return stdout.trim(); | ||
| }; | ||
| var convertWslPathToWindows = async (path) => { | ||
| if (/^[a-z]+:\/\//i.test(path)) { | ||
| return path; | ||
| } | ||
| try { | ||
| const { stdout } = await execFile2("wslpath", ["-aw", path], { encoding: "utf8" }); | ||
| return stdout.trim(); | ||
| } catch { | ||
| return path; | ||
| } | ||
| }; | ||
| // ../../node_modules/open/node_modules/define-lazy-prop/index.js | ||
| function defineLazyProperty(object, propertyName, valueGetter) { | ||
| const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true }); | ||
| Object.defineProperty(object, propertyName, { | ||
| configurable: true, | ||
| enumerable: true, | ||
| get() { | ||
| const result = valueGetter(); | ||
| define(result); | ||
| return result; | ||
| }, | ||
| set(value) { | ||
| define(value); | ||
| } | ||
| }); | ||
| return object; | ||
| } | ||
| // ../../node_modules/default-browser/index.js | ||
| import { promisify as promisify6 } from "node:util"; | ||
| import process6 from "node:process"; | ||
| import { execFile as execFile6 } from "node:child_process"; | ||
| // ../../node_modules/default-browser-id/index.js | ||
| import { promisify as promisify3 } from "node:util"; | ||
| import process4 from "node:process"; | ||
| import { execFile as execFile3 } from "node:child_process"; | ||
| var execFileAsync = promisify3(execFile3); | ||
| async function defaultBrowserId() { | ||
| if (process4.platform !== "darwin") { | ||
| throw new Error("macOS only"); | ||
| } | ||
| const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]); | ||
| const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout); | ||
| const browserId = match?.groups.id ?? "com.apple.Safari"; | ||
| if (browserId === "com.apple.safari") { | ||
| return "com.apple.Safari"; | ||
| } | ||
| return browserId; | ||
| } | ||
| // ../../node_modules/run-applescript/index.js | ||
| import process5 from "node:process"; | ||
| import { promisify as promisify4 } from "node:util"; | ||
| import { execFile as execFile4, execFileSync } from "node:child_process"; | ||
| var execFileAsync2 = promisify4(execFile4); | ||
| async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) { | ||
| if (process5.platform !== "darwin") { | ||
| throw new Error("macOS only"); | ||
| } | ||
| const outputArguments = humanReadableOutput ? [] : ["-ss"]; | ||
| const execOptions = {}; | ||
| if (signal) { | ||
| execOptions.signal = signal; | ||
| } | ||
| const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions); | ||
| return stdout.trim(); | ||
| } | ||
| // ../../node_modules/bundle-name/index.js | ||
| async function bundleName(bundleId) { | ||
| return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string | ||
| tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`); | ||
| } | ||
| // ../../node_modules/default-browser/windows.js | ||
| import { promisify as promisify5 } from "node:util"; | ||
| import { execFile as execFile5 } from "node:child_process"; | ||
| var execFileAsync3 = promisify5(execFile5); | ||
| var windowsBrowserProgIds = { | ||
| MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" }, | ||
| MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" }, | ||
| MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" }, | ||
| AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" }, | ||
| ChromeHTML: { name: "Chrome", id: "com.google.chrome" }, | ||
| ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" }, | ||
| ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" }, | ||
| ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" }, | ||
| BraveHTML: { name: "Brave", id: "com.brave.Browser" }, | ||
| BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" }, | ||
| BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" }, | ||
| BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" }, | ||
| FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" }, | ||
| OperaStable: { name: "Opera", id: "com.operasoftware.Opera" }, | ||
| VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" }, | ||
| "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" } | ||
| }; | ||
| var _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds)); | ||
| class UnknownBrowserError extends Error { | ||
| } | ||
| async function defaultBrowser(_execFileAsync = execFileAsync3) { | ||
| const { stdout } = await _execFileAsync("reg", [ | ||
| "QUERY", | ||
| " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice", | ||
| "/v", | ||
| "ProgId" | ||
| ]); | ||
| const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout); | ||
| if (!match) { | ||
| throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`); | ||
| } | ||
| const { id } = match.groups; | ||
| const dotIndex = id.lastIndexOf("."); | ||
| const hyphenIndex = id.lastIndexOf("-"); | ||
| const baseIdByDot = dotIndex === -1 ? undefined : id.slice(0, dotIndex); | ||
| const baseIdByHyphen = hyphenIndex === -1 ? undefined : id.slice(0, hyphenIndex); | ||
| return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id }; | ||
| } | ||
| // ../../node_modules/default-browser/index.js | ||
| var execFileAsync4 = promisify6(execFile6); | ||
| var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase()); | ||
| async function defaultBrowser2() { | ||
| if (process6.platform === "darwin") { | ||
| const id = await defaultBrowserId(); | ||
| const name = await bundleName(id); | ||
| return { name, id }; | ||
| } | ||
| if (process6.platform === "linux") { | ||
| const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]); | ||
| const id = stdout.trim(); | ||
| const name = titleize(id.replace(/.desktop$/, "").replace("-", " ")); | ||
| return { name, id }; | ||
| } | ||
| if (process6.platform === "win32") { | ||
| return defaultBrowser(); | ||
| } | ||
| throw new Error("Only macOS, Linux, and Windows are supported"); | ||
| } | ||
| // ../../node_modules/is-in-ssh/index.js | ||
| import process7 from "node:process"; | ||
| var isInSsh = Boolean(process7.env.SSH_CONNECTION || process7.env.SSH_CLIENT || process7.env.SSH_TTY); | ||
| var is_in_ssh_default = isInSsh; | ||
| // ../../node_modules/open/index.js | ||
| var fallbackAttemptSymbol = Symbol("fallbackAttempt"); | ||
| var __dirname2 = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : ""; | ||
| var localXdgOpenPath = path.join(__dirname2, "xdg-open"); | ||
| var { platform, arch } = process8; | ||
| var tryEachApp = async (apps, opener) => { | ||
| if (apps.length === 0) { | ||
| return; | ||
| } | ||
| const errors = []; | ||
| for (const app of apps) { | ||
| try { | ||
| return await opener(app); | ||
| } catch (error) { | ||
| errors.push(error); | ||
| } | ||
| } | ||
| throw new AggregateError(errors, "Failed to open in all supported apps"); | ||
| }; | ||
| var baseOpen = async (options) => { | ||
| options = { | ||
| wait: false, | ||
| background: false, | ||
| newInstance: false, | ||
| allowNonzeroExitCode: false, | ||
| ...options | ||
| }; | ||
| const isFallbackAttempt = options[fallbackAttemptSymbol] === true; | ||
| delete options[fallbackAttemptSymbol]; | ||
| if (Array.isArray(options.app)) { | ||
| return tryEachApp(options.app, (singleApp) => baseOpen({ | ||
| ...options, | ||
| app: singleApp, | ||
| [fallbackAttemptSymbol]: true | ||
| })); | ||
| } | ||
| let { name: app, arguments: appArguments = [] } = options.app ?? {}; | ||
| appArguments = [...appArguments]; | ||
| if (Array.isArray(app)) { | ||
| return tryEachApp(app, (appName) => baseOpen({ | ||
| ...options, | ||
| app: { | ||
| name: appName, | ||
| arguments: appArguments | ||
| }, | ||
| [fallbackAttemptSymbol]: true | ||
| })); | ||
| } | ||
| if (app === "browser" || app === "browserPrivate") { | ||
| const ids = { | ||
| "com.google.chrome": "chrome", | ||
| "google-chrome.desktop": "chrome", | ||
| "com.brave.browser": "brave", | ||
| "org.mozilla.firefox": "firefox", | ||
| "firefox.desktop": "firefox", | ||
| "com.microsoft.msedge": "edge", | ||
| "com.microsoft.edge": "edge", | ||
| "com.microsoft.edgemac": "edge", | ||
| "microsoft-edge.desktop": "edge", | ||
| "com.apple.safari": "safari" | ||
| }; | ||
| const flags = { | ||
| chrome: "--incognito", | ||
| brave: "--incognito", | ||
| firefox: "--private-window", | ||
| edge: "--inPrivate" | ||
| }; | ||
| let browser; | ||
| if (is_wsl_default) { | ||
| const progId = await wslDefaultBrowser(); | ||
| const browserInfo = _windowsBrowserProgIdMap.get(progId); | ||
| browser = browserInfo ?? {}; | ||
| } else { | ||
| browser = await defaultBrowser2(); | ||
| } | ||
| if (browser.id in ids) { | ||
| const browserName = ids[browser.id.toLowerCase()]; | ||
| if (app === "browserPrivate") { | ||
| if (browserName === "safari") { | ||
| throw new Error("Safari doesn't support opening in private mode via command line"); | ||
| } | ||
| appArguments.push(flags[browserName]); | ||
| } | ||
| return baseOpen({ | ||
| ...options, | ||
| app: { | ||
| name: apps[browserName], | ||
| arguments: appArguments | ||
| } | ||
| }); | ||
| } | ||
| throw new Error(`${browser.name} is not supported as a default browser`); | ||
| } | ||
| let command; | ||
| const cliArguments = []; | ||
| const childProcessOptions = {}; | ||
| let shouldUseWindowsInWsl = false; | ||
| if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) { | ||
| shouldUseWindowsInWsl = await canAccessPowerShell(); | ||
| } | ||
| if (platform === "darwin") { | ||
| command = "open"; | ||
| if (options.wait) { | ||
| cliArguments.push("--wait-apps"); | ||
| } | ||
| if (options.background) { | ||
| cliArguments.push("--background"); | ||
| } | ||
| if (options.newInstance) { | ||
| cliArguments.push("--new"); | ||
| } | ||
| if (app) { | ||
| cliArguments.push("-a", app); | ||
| } | ||
| } else if (platform === "win32" || shouldUseWindowsInWsl) { | ||
| command = await powerShellPath2(); | ||
| cliArguments.push(...executePowerShell.argumentsPrefix); | ||
| if (!is_wsl_default) { | ||
| childProcessOptions.windowsVerbatimArguments = true; | ||
| } | ||
| if (is_wsl_default && options.target) { | ||
| options.target = await convertWslPathToWindows(options.target); | ||
| } | ||
| const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"]; | ||
| if (options.wait) { | ||
| encodedArguments.push("-Wait"); | ||
| } | ||
| if (app) { | ||
| encodedArguments.push(executePowerShell.escapeArgument(app)); | ||
| if (options.target) { | ||
| appArguments.push(options.target); | ||
| } | ||
| } else if (options.target) { | ||
| encodedArguments.push(executePowerShell.escapeArgument(options.target)); | ||
| } | ||
| if (appArguments.length > 0) { | ||
| appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument)); | ||
| encodedArguments.push("-ArgumentList", appArguments.join(",")); | ||
| } | ||
| options.target = executePowerShell.encodeCommand(encodedArguments.join(" ")); | ||
| if (!options.wait) { | ||
| childProcessOptions.stdio = "ignore"; | ||
| } | ||
| } else { | ||
| if (app) { | ||
| command = app; | ||
| } else { | ||
| const isBundled = !__dirname2 || __dirname2 === "/"; | ||
| let exeLocalXdgOpen = false; | ||
| try { | ||
| await fs5.access(localXdgOpenPath, fsConstants2.X_OK); | ||
| exeLocalXdgOpen = true; | ||
| } catch {} | ||
| const useSystemXdgOpen = process8.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen); | ||
| command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath; | ||
| } | ||
| if (appArguments.length > 0) { | ||
| cliArguments.push(...appArguments); | ||
| } | ||
| if (!options.wait) { | ||
| childProcessOptions.stdio = "ignore"; | ||
| childProcessOptions.detached = true; | ||
| } | ||
| } | ||
| if (platform === "darwin" && appArguments.length > 0) { | ||
| cliArguments.push("--args", ...appArguments); | ||
| } | ||
| if (options.target) { | ||
| cliArguments.push(options.target); | ||
| } | ||
| const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions); | ||
| if (options.wait) { | ||
| return new Promise((resolve, reject) => { | ||
| subprocess.once("error", reject); | ||
| subprocess.once("close", (exitCode) => { | ||
| if (!options.allowNonzeroExitCode && exitCode !== 0) { | ||
| reject(new Error(`Exited with code ${exitCode}`)); | ||
| return; | ||
| } | ||
| resolve(subprocess); | ||
| }); | ||
| }); | ||
| } | ||
| if (isFallbackAttempt) { | ||
| return new Promise((resolve, reject) => { | ||
| subprocess.once("error", reject); | ||
| subprocess.once("spawn", () => { | ||
| subprocess.once("close", (exitCode) => { | ||
| subprocess.off("error", reject); | ||
| if (exitCode !== 0) { | ||
| reject(new Error(`Exited with code ${exitCode}`)); | ||
| return; | ||
| } | ||
| subprocess.unref(); | ||
| resolve(subprocess); | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| subprocess.unref(); | ||
| return new Promise((resolve, reject) => { | ||
| subprocess.once("error", reject); | ||
| subprocess.once("spawn", () => { | ||
| subprocess.off("error", reject); | ||
| resolve(subprocess); | ||
| }); | ||
| }); | ||
| }; | ||
| var open = (target, options) => { | ||
| if (typeof target !== "string") { | ||
| throw new TypeError("Expected a `target`"); | ||
| } | ||
| return baseOpen({ | ||
| ...options, | ||
| target | ||
| }); | ||
| }; | ||
| function detectArchBinary(binary) { | ||
| if (typeof binary === "string" || Array.isArray(binary)) { | ||
| return binary; | ||
| } | ||
| const { [arch]: archBinary } = binary; | ||
| if (!archBinary) { | ||
| throw new Error(`${arch} is not supported`); | ||
| } | ||
| return archBinary; | ||
| } | ||
| function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) { | ||
| if (wsl && is_wsl_default) { | ||
| return detectArchBinary(wsl); | ||
| } | ||
| if (!platformBinary) { | ||
| throw new Error(`${platform} is not supported`); | ||
| } | ||
| return detectArchBinary(platformBinary); | ||
| } | ||
| var apps = { | ||
| browser: "browser", | ||
| browserPrivate: "browserPrivate" | ||
| }; | ||
| defineLazyProperty(apps, "chrome", () => detectPlatformBinary({ | ||
| darwin: "google chrome", | ||
| win32: "chrome", | ||
| linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"] | ||
| }, { | ||
| wsl: { | ||
| ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe", | ||
| x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"] | ||
| } | ||
| })); | ||
| defineLazyProperty(apps, "brave", () => detectPlatformBinary({ | ||
| darwin: "brave browser", | ||
| win32: "brave", | ||
| linux: ["brave-browser", "brave"] | ||
| }, { | ||
| wsl: { | ||
| ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe", | ||
| x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"] | ||
| } | ||
| })); | ||
| defineLazyProperty(apps, "firefox", () => detectPlatformBinary({ | ||
| darwin: "firefox", | ||
| win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`, | ||
| linux: "firefox" | ||
| }, { | ||
| wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe" | ||
| })); | ||
| defineLazyProperty(apps, "edge", () => detectPlatformBinary({ | ||
| darwin: "microsoft edge", | ||
| win32: "msedge", | ||
| linux: ["microsoft-edge", "microsoft-edge-dev"] | ||
| }, { | ||
| wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" | ||
| })); | ||
| defineLazyProperty(apps, "safari", () => detectPlatformBinary({ | ||
| darwin: "Safari" | ||
| })); | ||
| var open_default = open; | ||
| // ../filesystem/src/node.ts | ||
| var LOCK_HEARTBEAT_MS = 5000; | ||
| var LOCK_STALE_MS = 15000; | ||
| var LOCK_MAX_WAIT_MS = 20000; | ||
| var LOCK_MAX_HOLD_MS = 60000; | ||
| var LOCK_RETRY_MIN_MS = 100; | ||
| var LOCK_RETRY_JITTER_MS = 200; | ||
| class NodeFileSystem { | ||
| path = { | ||
| join: path2.join, | ||
| resolve: path2.resolve, | ||
| relative: path2.relative, | ||
| dirname: path2.dirname, | ||
| isAbsolute: path2.isAbsolute, | ||
| basename: path2.basename | ||
| }; | ||
| env = { | ||
| cwd: process.cwd, | ||
| homedir: os2.homedir, | ||
| tmpdir: os2.tmpdir, | ||
| getenv: (key) => process.env[key] | ||
| }; | ||
| utils = { | ||
| open: async (url) => { | ||
| await open_default(url); | ||
| } | ||
| }; | ||
| async readFile(path3, options) { | ||
| try { | ||
| if (options) { | ||
| return await fs6.readFile(path3, "utf-8"); | ||
| } | ||
| return await fs6.readFile(path3); | ||
| } catch (error) { | ||
| if (this.isEnoent(error)) | ||
| return null; | ||
| throw error; | ||
| } | ||
| } | ||
| async writeFile(filePath, data) { | ||
| const dir = path2.dirname(filePath); | ||
| if (dir) { | ||
| await fs6.mkdir(dir, { recursive: true }); | ||
| } | ||
| await fs6.writeFile(filePath, data); | ||
| } | ||
| async appendFile(filePath, data) { | ||
| const dir = path2.dirname(filePath); | ||
| if (dir) { | ||
| await fs6.mkdir(dir, { recursive: true }); | ||
| } | ||
| await fs6.appendFile(filePath, data); | ||
| } | ||
| async readdir(dirPath) { | ||
| try { | ||
| return await fs6.readdir(dirPath); | ||
| } catch (error) { | ||
| if (this.isEnoent(error)) | ||
| return []; | ||
| throw error; | ||
| } | ||
| } | ||
| async stat(filePath) { | ||
| try { | ||
| const stats = await fs6.stat(filePath); | ||
| return { | ||
| isFile: () => stats.isFile(), | ||
| isDirectory: () => stats.isDirectory(), | ||
| size: stats.size, | ||
| mtimeMs: stats.mtimeMs | ||
| }; | ||
| } catch (error) { | ||
| if (this.isEnoent(error)) | ||
| return null; | ||
| throw error; | ||
| } | ||
| } | ||
| async exists(filePath) { | ||
| return existsSync(filePath); | ||
| } | ||
| async mkdir(dirPath) { | ||
| await fs6.mkdir(dirPath, { recursive: true }); | ||
| } | ||
| async acquireLock(lockPath) { | ||
| const canonicalPath = await this.canonicalizeLockTarget(lockPath); | ||
| const lockFile = `${canonicalPath}.lock`; | ||
| const ownerId = randomUUID(); | ||
| const start = Date.now(); | ||
| while (true) { | ||
| try { | ||
| await fs6.writeFile(lockFile, ownerId, { flag: "wx" }); | ||
| return this.createLockRelease(lockFile, ownerId); | ||
| } catch (error) { | ||
| if (!this.hasErrnoCode(error, "EEXIST")) { | ||
| throw error; | ||
| } | ||
| const stats = await fs6.stat(lockFile).catch(() => null); | ||
| if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) { | ||
| const reclaimed = await fs6.rm(lockFile, { force: true }).then(() => true).catch(() => false); | ||
| if (reclaimed) | ||
| continue; | ||
| } | ||
| if (Date.now() - start > LOCK_MAX_WAIT_MS) { | ||
| throw new Error(`ELOCKED: timed out waiting for lock on ${canonicalPath}`); | ||
| } | ||
| await new Promise((resolve2) => setTimeout(resolve2, LOCK_RETRY_MIN_MS + Math.random() * LOCK_RETRY_JITTER_MS)); | ||
| } | ||
| } | ||
| } | ||
| async canonicalizeLockTarget(lockPath) { | ||
| const absolute = path2.resolve(lockPath); | ||
| const fullReal = await fs6.realpath(absolute).catch(() => null); | ||
| if (fullReal) | ||
| return fullReal; | ||
| const parent = path2.dirname(absolute); | ||
| const base = path2.basename(absolute); | ||
| const canonicalParent = await fs6.realpath(parent).catch(() => parent); | ||
| return path2.join(canonicalParent, base); | ||
| } | ||
| createLockRelease(lockFile, ownerId) { | ||
| const heartbeatStart = Date.now(); | ||
| let heartbeatTimer; | ||
| let stopped = false; | ||
| const stopHeartbeat = () => { | ||
| stopped = true; | ||
| if (heartbeatTimer) | ||
| clearTimeout(heartbeatTimer); | ||
| }; | ||
| const scheduleNextHeartbeat = () => { | ||
| if (stopped) | ||
| return; | ||
| if (Date.now() - heartbeatStart >= LOCK_MAX_HOLD_MS) { | ||
| stopped = true; | ||
| return; | ||
| } | ||
| heartbeatTimer = setTimeout(() => { | ||
| runHeartbeat(); | ||
| }, LOCK_HEARTBEAT_MS); | ||
| heartbeatTimer.unref?.(); | ||
| }; | ||
| const runHeartbeat = async () => { | ||
| if (stopped) | ||
| return; | ||
| const current = await fs6.readFile(lockFile, "utf-8").catch(() => null); | ||
| if (stopped) | ||
| return; | ||
| if (current !== ownerId) { | ||
| stopped = true; | ||
| return; | ||
| } | ||
| const now = Date.now() / 1000; | ||
| await fs6.utimes(lockFile, now, now).catch(() => {}); | ||
| scheduleNextHeartbeat(); | ||
| }; | ||
| scheduleNextHeartbeat(); | ||
| let released = false; | ||
| return async () => { | ||
| if (released) | ||
| return; | ||
| released = true; | ||
| stopHeartbeat(); | ||
| const current = await fs6.readFile(lockFile, "utf-8").catch(() => null); | ||
| if (current === ownerId) { | ||
| await fs6.rm(lockFile, { force: true }); | ||
| } | ||
| }; | ||
| } | ||
| async rm(filePath) { | ||
| await fs6.rm(filePath, { recursive: true, force: true }); | ||
| } | ||
| async rename(oldPath, newPath) { | ||
| await fs6.rename(oldPath, newPath); | ||
| } | ||
| async realpath(filePath) { | ||
| try { | ||
| return await fs6.realpath(filePath); | ||
| } catch (error) { | ||
| if (this.isEnoent(error)) | ||
| return filePath; | ||
| throw error; | ||
| } | ||
| } | ||
| async getTempDir() { | ||
| return await fs6.mkdtemp(path2.join(os2.tmpdir(), "uipath-fs-")); | ||
| } | ||
| async copyDirectory(sourcePath, destPath) { | ||
| const sourceStats = await this.stat(sourcePath); | ||
| if (!sourceStats) { | ||
| throw new Error(`Source directory does not exist: ${sourcePath}`); | ||
| } | ||
| if (!sourceStats.isDirectory()) { | ||
| throw new Error(`Source path is not a directory: ${sourcePath}`); | ||
| } | ||
| await this.mkdir(destPath); | ||
| const entries = await this.readdir(sourcePath); | ||
| for (const entry of entries) { | ||
| const srcEntry = path2.join(sourcePath, entry); | ||
| const destEntry = path2.join(destPath, entry); | ||
| const entryStats = await this.stat(srcEntry); | ||
| if (!entryStats) | ||
| continue; | ||
| if (entryStats.isDirectory()) { | ||
| await this.copyDirectory(srcEntry, destEntry); | ||
| } else if (entryStats.isFile()) { | ||
| const content = await this.readFile(srcEntry); | ||
| if (content !== null) { | ||
| await this.writeFile(destEntry, content); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| isEnoent(error) { | ||
| return this.hasErrnoCode(error, "ENOENT"); | ||
| } | ||
| hasErrnoCode(error, code) { | ||
| return typeof error === "object" && error !== null && "code" in error && error.code === code; | ||
| } | ||
| } | ||
| // ../filesystem/src/index.ts | ||
| var fsInstance = new NodeFileSystem; | ||
| var getFileSystem = () => fsInstance; | ||
| // ../auth/src/catch-error.ts | ||
| function isPromiseLike(value) { | ||
| return value !== null && typeof value === "object" && typeof value.then === "function"; | ||
| } | ||
| function catchError(fnOrPromise) { | ||
| if (isPromiseLike(fnOrPromise)) { | ||
| return settlePromiseLike(fnOrPromise); | ||
| } | ||
| try { | ||
| const result = fnOrPromise(); | ||
| if (isPromiseLike(result)) { | ||
| return settlePromiseLike(result); | ||
| } | ||
| return [undefined, result]; | ||
| } catch (error) { | ||
| return [ | ||
| error instanceof Error ? error : new Error(String(error)), | ||
| undefined | ||
| ]; | ||
| } | ||
| } | ||
| function settlePromiseLike(thenable) { | ||
| return Promise.resolve(thenable).then((data) => [undefined, data]).catch((error) => [ | ||
| error instanceof Error ? error : new Error(String(error)), | ||
| undefined | ||
| ]); | ||
| } | ||
| // ../auth/src/getBaseHtml.ts | ||
| var escapeHtml = (value) => value.replace(/[&<>"']/g, (char) => { | ||
| switch (char) { | ||
| case "&": | ||
| return "&"; | ||
| case "<": | ||
| return "<"; | ||
| case ">": | ||
| return ">"; | ||
| case '"': | ||
| return """; | ||
| case "'": | ||
| return "'"; | ||
| default: | ||
| return char; | ||
| } | ||
| }); | ||
| var getBaseHtml = ({ title, message, type }) => { | ||
| const icon = type === "success" ? "✓" : "✕"; | ||
| const iconClass = type === "success" ? "icon-success" : "icon-error"; | ||
| const safeTitle = escapeHtml(title); | ||
| const safeMessage = escapeHtml(message); | ||
| return ` | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>${safeTitle} - UiPath CLI</title> | ||
| <link rel="preconnect" href="https://fonts.googleapis.com"> | ||
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400&family=Poppins:wght@600&display=swap" rel="stylesheet"> | ||
| <style> | ||
| :root { | ||
| --bg-page: #F6F6F6; | ||
| --bg-card: #FFFFFF; | ||
| --border-card: #D9D9D9; | ||
| --text-heading: #182126; | ||
| --text-body: #616161; | ||
| --text-footer: #9D9D9D; | ||
| --color-success: #16a34a; | ||
| --color-success-bg: #f0fdf4; | ||
| --color-error: #A32200; | ||
| --color-error-bg: #fef2f2; | ||
| --color-accent: #FA4616; | ||
| } | ||
| @media (prefers-color-scheme: dark) { | ||
| :root { | ||
| --bg-page: #182126; | ||
| --bg-card: #2D373C; | ||
| --border-card: #3C464B; | ||
| --text-heading: #F6F6F6; | ||
| --text-body: #B9B9B9; | ||
| --text-footer: #9D9D9D; | ||
| --color-success: #4ade80; | ||
| --color-success-bg: #052e16; | ||
| --color-error: #FA7678; | ||
| --color-error-bg: #450a0a; | ||
| --color-accent: #FA4616; | ||
| } | ||
| } | ||
| * { | ||
| margin: 0; | ||
| padding: 0; | ||
| box-sizing: border-box; | ||
| } | ||
| body { | ||
| font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; | ||
| background: var(--bg-page); | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| min-height: 100vh; | ||
| padding: 20px; | ||
| } | ||
| .container { | ||
| max-width: 480px; | ||
| width: 100%; | ||
| } | ||
| .card { | ||
| background: var(--bg-card); | ||
| border: 1px solid var(--border-card); | ||
| border-top: 3px solid var(--color-accent); | ||
| border-radius: 12px; | ||
| padding: 40px 32px; | ||
| text-align: center; | ||
| } | ||
| .logo { | ||
| display: flex; | ||
| justify-content: center; | ||
| margin-bottom: 24px; | ||
| } | ||
| .logo svg { | ||
| width: 160px; | ||
| height: auto; | ||
| } | ||
| .logo-dark { display: none; } | ||
| .logo-light { display: block; } | ||
| @media (prefers-color-scheme: dark) { | ||
| .logo-dark { display: block; } | ||
| .logo-light { display: none; } | ||
| } | ||
| .icon { | ||
| width: 56px; | ||
| height: 56px; | ||
| border-radius: 50%; | ||
| font-size: 28px; | ||
| display: inline-flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| margin-bottom: 16px; | ||
| font-weight: 600; | ||
| } | ||
| .icon-success { | ||
| background: var(--color-success-bg); | ||
| color: var(--color-success); | ||
| } | ||
| .icon-error { | ||
| background: var(--color-error-bg); | ||
| color: var(--color-error); | ||
| } | ||
| h1 { | ||
| font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; | ||
| color: var(--text-heading); | ||
| font-size: 24px; | ||
| font-weight: 600; | ||
| margin-bottom: 8px; | ||
| } | ||
| p { | ||
| color: var(--text-body); | ||
| font-size: 14px; | ||
| line-height: 1.5; | ||
| } | ||
| .footer { | ||
| margin-top: 24px; | ||
| padding-top: 24px; | ||
| border-top: 1px solid var(--border-card); | ||
| color: var(--text-footer); | ||
| font-size: 13px; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <div class="container"> | ||
| <div class="card"> | ||
| <div class="logo"> | ||
| <div class="logo-light"> | ||
| <svg aria-hidden="true" width="400" height="116" viewBox="0 0 400 116" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M62.6439 33.1429H60.885C56.2918 33.1429 53.4387 35.9377 53.4387 40.4355V76.6177C53.4387 93.7722 48.1098 100.769 35.0451 100.769C21.9804 100.769 16.6514 93.7405 16.6514 76.5097V40.4355C16.6514 35.9377 13.7982 33.1429 9.20575 33.1429H7.44592C2.85326 33.1429 0 35.9377 0 40.4355V76.6177C0 102.75 11.7912 116 35.0451 116C58.2991 116 70.0897 102.75 70.0897 76.6177V40.4355C70.0897 35.9377 67.2364 33.1429 62.6439 33.1429Z" fill="black"/><path d="M91.1326 55.0988H89.6751C84.9685 55.0988 82.0451 58.0021 82.0451 62.6744V108.425C82.0451 113.097 84.9685 116 89.6751 116H91.1326C95.8386 116 98.762 113.097 98.762 108.425V62.6744C98.762 58.0021 95.8386 55.0988 91.1326 55.0988Z" fill="#FA4616"/><path d="M111.322 26.7778C100.684 25.0967 92.2902 16.8376 90.5818 6.37143C90.5496 6.17388 90.2894 6.17388 90.2572 6.37143C88.5488 16.8376 80.1548 25.0967 69.5175 26.7778C69.3167 26.8094 69.3167 27.0656 69.5175 27.0973C80.1548 28.7781 88.5488 37.0375 90.2572 47.5037C90.2894 47.7012 90.5496 47.7012 90.5818 47.5037C92.2902 37.0375 100.684 28.7781 111.322 27.0973C111.522 27.0656 111.522 26.8095 111.322 26.7778ZM100.87 27.0174C95.5518 27.8578 91.3548 31.9875 90.5007 37.2206C90.4845 37.3194 90.3544 37.3194 90.3383 37.2206C89.4841 31.9875 85.2871 27.8578 79.9685 27.0174C79.868 27.0016 79.868 26.8735 79.9685 26.8577C85.2871 26.0171 89.4841 21.8876 90.3383 16.6545C90.3544 16.5557 90.4845 16.5557 90.5007 16.6545C91.3548 21.8876 95.5518 26.0171 100.87 26.8577C100.971 26.8735 100.971 27.0016 100.87 27.0174Z" fill="#FA4616"/><path d="M117.694 10.4371C112.376 11.2774 108.179 15.4071 107.325 20.6402C107.308 20.739 107.178 20.739 107.162 20.6402C106.308 15.4071 102.111 11.2774 96.7923 10.4371C96.6919 10.4212 96.6919 10.2931 96.7923 10.2773C102.111 9.43674 106.308 5.3072 107.162 0.0740898C107.178 -0.0246966 107.308 -0.0246966 107.325 0.0740898C108.179 5.3072 112.376 9.43672 117.694 10.2773C117.795 10.2931 117.795 10.4212 117.694 10.4371Z" fill="#FA4616"/><path d="M135.312 33.1429H119.087C114.445 33.1429 111.561 35.9675 111.561 40.5133V108.63C111.561 113.175 114.445 116 119.087 116H120.865C125.507 116 128.391 113.175 128.391 108.63V92.5058H135.423C163.58 92.5058 175.066 83.9066 175.066 62.8243C175.066 41.742 163.548 33.1429 135.312 33.1429ZM158.014 62.6068C158.014 73.4525 152.762 77.1123 137.201 77.1123H128.391V48.2095H137.201C152.762 48.2095 158.014 51.8421 158.014 62.6068Z" fill="black"/><path d="M237.564 48.4739H236.23C231.589 48.4739 228.705 51.2986 228.705 55.8444V55.8538C223.938 50.4474 216.554 47.2772 208.114 47.2772C199.516 47.2772 191.74 50.3711 186.22 55.9903C180.207 62.1094 177.029 70.9412 177.029 81.5299C177.029 92.1647 180.226 101.047 186.274 107.217C191.825 112.881 199.621 116 208.225 116C216.505 116 223.944 112.79 228.711 107.462C228.711 107.468 228.711 108.998 228.712 109.004C228.866 113.33 231.717 116 236.23 116H237.564C242.206 116 245.089 113.176 245.089 108.631V55.8444C245.089 51.2986 242.206 48.4739 237.564 48.4739ZM229.038 81.5299C229.038 93.9678 222.256 101.695 211.337 101.695C200.281 101.695 193.414 93.9678 193.414 81.5299C193.414 69.1579 200.196 61.473 211.115 61.473C222.003 61.473 229.038 69.3462 229.038 81.5299Z" fill="black"/><path d="M334.448 47.3426C325.733 47.3426 319.516 50.7418 315.624 55.0257V40.518C315.624 35.9693 312.738 33.1429 308.094 33.1429H306.759C302.115 33.1429 299.229 35.9693 299.229 40.518V108.625C299.229 113.174 302.115 116 306.759 116H308.094C312.738 116 315.624 113.174 315.624 108.625V81.2897C315.624 63.7895 324.146 61.7658 330.556 61.7658C341.32 61.7658 345.711 67.0126 345.711 79.8747V108.625C345.711 113.174 348.596 116 353.241 116H354.576C359.22 116 362.105 113.174 362.105 108.625V78.8939C362.105 57.6628 353.059 47.3426 334.448 47.3426Z" fill="black"/><path d="M294.515 107.664C294.284 105.472 292.945 102.34 286.565 102.34C279.021 102.34 275.431 100.037 275.431 86.9529V61.7659H286.675C291.313 61.7659 294.194 59.19 294.194 55.0447C294.194 50.9661 291.313 48.4318 286.675 48.4318H275.444V40.518C275.444 35.9693 272.541 33.1429 267.869 33.1429H266.526C261.854 33.1429 258.951 35.9693 258.951 40.518V48.4318H256.366C252.276 48.4318 249.736 50.9661 249.736 55.0447C249.736 59.19 252.617 61.7659 257.254 61.7659H258.951V88.369C258.951 107.737 266.645 116 284.677 116C284.707 116 284.736 115.999 284.765 115.998C285.813 115.997 286.937 115.981 288.081 115.881C290.354 115.67 292.073 114.886 293.191 113.546C294.305 112.213 294.75 109.871 294.515 107.664Z" fill="black"/><path d="M367.331 47.6328V36.4082H364.1C362.823 36.4082 362.105 35.8367 362.105 34.7755C362.105 33.7143 362.823 33.1428 364.1 33.1428H373.952C375.228 33.1428 375.946 33.7143 375.946 34.7755C375.946 35.8367 375.228 36.4082 373.952 36.4082H370.801V47.6328C370.801 48.939 370.203 49.6733 369.086 49.6733C367.969 49.6733 367.331 48.939 367.331 47.6328ZM377.822 49.7139C376.745 49.7139 376.174 48.8937 376.465 47.4695L379.018 34.9388C379.258 33.7553 379.976 33.1428 381.172 33.1428H381.771C382.887 33.1428 383.637 33.6775 384.044 34.7341L388.192 45.5096L392.38 34.7341C392.795 33.6652 393.577 33.1428 394.694 33.1428H395.252C396.449 33.1428 397.167 33.7553 397.406 34.9388L399.919 47.4695C400.206 48.8979 399.72 49.7143 398.643 49.7143C397.486 49.7143 396.772 49.1022 396.529 47.9183L394.415 37.6736L390.426 48.1226C390.007 49.2164 389.309 49.7139 388.232 49.7139C387.115 49.7139 386.417 49.2164 385.998 48.1226L382.01 37.6736L379.935 47.9183C379.696 49.1022 378.978 49.7139 377.822 49.7139Z" fill="black"/></svg> | ||
| </div> | ||
| <div class="logo-dark"> | ||
| <svg aria-hidden="true" width="400" height="116" viewBox="0 0 400 116" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M62.6439 33.1428H60.885C56.2918 33.1428 53.4387 35.9376 53.4387 40.4354V76.6177C53.4387 93.7722 48.1098 100.769 35.0451 100.769C21.9804 100.769 16.6514 93.7404 16.6514 76.5096V40.4354C16.6514 35.9377 13.7982 33.1428 9.20575 33.1428H7.44592C2.85326 33.1428 0 35.9377 0 40.4354V76.6177C0 102.75 11.7912 116 35.0451 116C58.2991 116 70.0897 102.75 70.0897 76.6177V40.4354C70.0897 35.9377 67.2364 33.1428 62.6439 33.1428Z" fill="white"/><path d="M91.1326 55.0989H89.6751C84.9685 55.0989 82.0451 58.0021 82.0451 62.6744V108.425C82.0451 113.097 84.9685 116 89.6751 116H91.1326C95.8386 116 98.762 113.097 98.762 108.425V62.6744C98.762 58.0021 95.8386 55.0989 91.1326 55.0989Z" fill="white"/><path d="M111.322 26.7778C100.684 25.0967 92.2902 16.8376 90.5818 6.37143C90.5496 6.17388 90.2894 6.17388 90.2572 6.37143C88.5488 16.8376 80.1548 25.0967 69.5175 26.7778C69.3167 26.8094 69.3167 27.0656 69.5175 27.0973C80.1548 28.7781 88.5488 37.0375 90.2572 47.5037C90.2894 47.7012 90.5496 47.7012 90.5818 47.5037C92.2902 37.0375 100.684 28.7781 111.322 27.0973C111.522 27.0656 111.522 26.8095 111.322 26.7778ZM100.87 27.0174C95.5518 27.8578 91.3548 31.9875 90.5007 37.2206C90.4845 37.3194 90.3544 37.3194 90.3383 37.2206C89.4841 31.9875 85.2871 27.8578 79.9685 27.0174C79.868 27.0016 79.868 26.8735 79.9685 26.8577C85.2871 26.0171 89.4841 21.8876 90.3383 16.6545C90.3544 16.5557 90.4845 16.5557 90.5007 16.6545C91.3548 21.8876 95.5518 26.0171 100.87 26.8577C100.971 26.8735 100.971 27.0016 100.87 27.0174Z" fill="white"/><path d="M117.694 10.4371C112.376 11.2774 108.179 15.4071 107.325 20.6402C107.308 20.739 107.178 20.739 107.162 20.6402C106.308 15.4071 102.111 11.2774 96.7923 10.4371C96.6919 10.4212 96.6919 10.2931 96.7923 10.2773C102.111 9.43674 106.308 5.3072 107.162 0.0740898C107.178 -0.0246966 107.308 -0.0246966 107.325 0.0740898C108.179 5.3072 112.376 9.43672 117.694 10.2773C117.795 10.2931 117.795 10.4212 117.694 10.4371Z" fill="white"/><path d="M135.312 33.1428H119.087C114.445 33.1428 111.561 35.9674 111.561 40.5133V108.63C111.561 113.175 114.445 116 119.087 116H120.865C125.507 116 128.391 113.175 128.391 108.63V92.5057H135.423C163.58 92.5057 175.066 83.9066 175.066 62.8243C175.066 41.7419 163.548 33.1428 135.312 33.1428ZM158.014 62.6067C158.014 73.4525 152.762 77.1123 137.201 77.1123H128.391V48.2095H137.201C152.762 48.2095 158.014 51.842 158.014 62.6067Z" fill="white"/><path d="M237.564 48.4739H236.23C231.589 48.4739 228.705 51.2986 228.705 55.8444V55.8538C223.938 50.4474 216.554 47.2772 208.114 47.2772C199.516 47.2772 191.74 50.3711 186.22 55.9903C180.207 62.1094 177.029 70.9412 177.029 81.5299C177.029 92.1647 180.226 101.047 186.274 107.217C191.825 112.881 199.621 116 208.225 116C216.505 116 223.944 112.79 228.711 107.462C228.711 107.468 228.711 108.998 228.712 109.004C228.866 113.33 231.717 116 236.23 116H237.564C242.206 116 245.089 113.176 245.089 108.631V55.8444C245.089 51.2986 242.206 48.4739 237.564 48.4739ZM229.038 81.5299C229.038 93.9678 222.256 101.695 211.337 101.695C200.281 101.695 193.414 93.9678 193.414 81.5299C193.414 69.1579 200.196 61.473 211.115 61.473C222.003 61.473 229.038 69.3462 229.038 81.5299Z" fill="white"/><path d="M334.448 47.3425C325.733 47.3425 319.516 50.7417 315.624 55.0256V40.5179C315.624 35.9693 312.738 33.1428 308.094 33.1428H306.759C302.115 33.1428 299.229 35.9693 299.229 40.5179V108.625C299.229 113.174 302.115 116 306.759 116H308.094C312.738 116 315.624 113.174 315.624 108.625V81.2897C315.624 63.7894 324.146 61.7657 330.556 61.7657C341.32 61.7657 345.711 67.0125 345.711 79.8746V108.625C345.711 113.174 348.596 116 353.241 116H354.576C359.22 116 362.105 113.174 362.105 108.625V78.8938C362.105 57.6627 353.059 47.3425 334.448 47.3425Z" fill="white"/><path d="M294.515 107.664C294.284 105.472 292.945 102.34 286.565 102.34C279.021 102.34 275.431 100.037 275.431 86.9529V61.7658H286.675C291.313 61.7658 294.194 59.19 294.194 55.0446C294.194 50.966 291.313 48.4317 286.675 48.4317H275.444V40.5179C275.444 35.9693 272.541 33.1428 267.869 33.1428H266.526C261.854 33.1428 258.951 35.9693 258.951 40.5179V48.4317H256.366C252.276 48.4317 249.736 50.966 249.736 55.0446C249.736 59.19 252.617 61.7658 257.254 61.7658H258.951V88.3689C258.951 107.737 266.645 116 284.677 116C284.707 116 284.736 115.999 284.765 115.998C285.813 115.997 286.937 115.981 288.081 115.881C290.354 115.67 292.073 114.885 293.191 113.546C294.305 112.213 294.75 109.87 294.515 107.664Z" fill="white"/><path d="M367.331 47.6328V36.4082H364.1C362.823 36.4082 362.105 35.8367 362.105 34.7755C362.105 33.7143 362.823 33.1428 364.1 33.1428H373.952C375.228 33.1428 375.946 33.7143 375.946 34.7755C375.946 35.8367 375.228 36.4082 373.952 36.4082H370.801V47.6328C370.801 48.939 370.203 49.6733 369.086 49.6733C367.969 49.6733 367.331 48.939 367.331 47.6328ZM377.822 49.7139C376.745 49.7139 376.174 48.8937 376.465 47.4695L379.018 34.9388C379.258 33.7553 379.976 33.1428 381.172 33.1428H381.771C382.887 33.1428 383.637 33.6775 384.044 34.7341L388.192 45.5096L392.38 34.7341C392.795 33.6652 393.577 33.1428 394.694 33.1428H395.252C396.449 33.1428 397.167 33.7553 397.406 34.9388L399.919 47.4695C400.206 48.8979 399.72 49.7143 398.643 49.7143C397.486 49.7143 396.772 49.1022 396.529 47.9183L394.415 37.6736L390.426 48.1226C390.007 49.2164 389.309 49.7139 388.232 49.7139C387.115 49.7139 386.417 49.2164 385.998 48.1226L382.01 37.6736L379.935 47.9183C379.696 49.1022 378.978 49.7139 377.822 49.7139Z" fill="white"/></svg> | ||
| </div> | ||
| </div> | ||
| <div class="icon ${iconClass}">${icon}</div> | ||
| <h1>${safeTitle}</h1> | ||
| <p>${safeMessage}</p> | ||
| <div class="footer">You can close this window</div> | ||
| </div> | ||
| </div> | ||
| </body> | ||
| </html>`; | ||
| }; | ||
| // ../auth/src/server.ts | ||
| var AUTH_TIMEOUT_ERROR_CODE = "EAUTHTIMEOUT"; | ||
| var startServer = async ({ | ||
| redirectUri, | ||
| timeoutMs = DEFAULT_AUTH_TIMEOUT_MS, | ||
| onListening, | ||
| signal | ||
| }) => { | ||
| let http; | ||
| try { | ||
| http = await import("node:http"); | ||
| } catch { | ||
| throw new Error("Local server authentication is not supported in this environment."); | ||
| } | ||
| return new Promise((resolve2, reject) => { | ||
| const server = http.createServer((req, res) => { | ||
| if (!req.url) { | ||
| res.writeHead(400, { | ||
| "Content-Type": "text/html; charset=utf-8", | ||
| Connection: "close" | ||
| }); | ||
| res.end(getBaseHtml({ | ||
| title: "Let's try that again", | ||
| message: "We got an unexpected request. Head back to your terminal and try signing in again.", | ||
| type: "error" | ||
| })); | ||
| server.close(); | ||
| reject(new Error("No URL received")); | ||
| return; | ||
| } | ||
| const url = new URL(req.url, redirectUri); | ||
| const error = url.searchParams.get("error"); | ||
| if (error) { | ||
| res.writeHead(400, { | ||
| "Content-Type": "text/html; charset=utf-8", | ||
| Connection: "close" | ||
| }); | ||
| res.end(getBaseHtml({ | ||
| title: "Let's try that again", | ||
| message: `The sign-in didn't go through: ${error}. Head back to your terminal and take another shot.`, | ||
| type: "error" | ||
| })); | ||
| server.close(); | ||
| reject(new Error(`OAuth error: ${error}`)); | ||
| return; | ||
| } | ||
| const code = url.searchParams.get("code"); | ||
| if (code) { | ||
| res.writeHead(200, { | ||
| "Content-Type": "text/html; charset=utf-8", | ||
| Connection: "close" | ||
| }); | ||
| res.end(getBaseHtml({ | ||
| title: "Ready to automate!", | ||
| message: "You're in. Head back to your terminal and let's get to work.", | ||
| type: "success" | ||
| })); | ||
| server.close(); | ||
| resolve2(url); | ||
| return; | ||
| } | ||
| res.writeHead(400, { | ||
| "Content-Type": "text/html; charset=utf-8", | ||
| Connection: "close" | ||
| }); | ||
| res.end(getBaseHtml({ | ||
| title: "We hit a snag", | ||
| message: "No authorization came back from the server. Head back to your terminal and try once more.", | ||
| type: "error" | ||
| })); | ||
| server.close(); | ||
| reject(new Error("No authorization code received")); | ||
| return; | ||
| }); | ||
| let timeoutHandle; | ||
| const onAbort = () => { | ||
| clearTimeout(timeoutHandle); | ||
| server.close(); | ||
| const err = new Error("Authentication cancelled"); | ||
| err.code = AUTH_CANCELLED_ERROR_CODE; | ||
| reject(err); | ||
| }; | ||
| if (signal) { | ||
| if (signal.aborted) { | ||
| onAbort(); | ||
| return; | ||
| } | ||
| signal.addEventListener("abort", onAbort, { once: true }); | ||
| } | ||
| timeoutHandle = setTimeout(() => { | ||
| server.close(); | ||
| signal?.removeEventListener("abort", onAbort); | ||
| const err = new Error("Authentication timeout"); | ||
| err.code = AUTH_TIMEOUT_ERROR_CODE; | ||
| reject(err); | ||
| }, timeoutMs); | ||
| const bindHost = redirectUri.hostname === "localhost" ? "127.0.0.1" : redirectUri.hostname; | ||
| server.on("error", (err) => { | ||
| clearTimeout(timeoutHandle); | ||
| signal?.removeEventListener("abort", onAbort); | ||
| reject(err); | ||
| }); | ||
| server.listen(Number(redirectUri.port), bindHost, () => { | ||
| if (onListening) { | ||
| Promise.resolve(onListening()).catch((err) => { | ||
| server.close(); | ||
| clearTimeout(timeoutHandle); | ||
| reject(err); | ||
| }); | ||
| } | ||
| }); | ||
| server.on("close", () => { | ||
| clearTimeout(timeoutHandle); | ||
| signal?.removeEventListener("abort", onAbort); | ||
| }); | ||
| }); | ||
| }; | ||
| export { getFileSystem, catchError, startServer }; | ||
| //# debugId=14B5757F539D1DD064756E2164756E21 |
| // ../auth/src/utils/platform.ts | ||
| function isBrowser() { | ||
| return typeof globalThis !== "undefined" && "window" in globalThis && "document" in globalThis; | ||
| } | ||
| function getGlobalThis() { | ||
| if (typeof globalThis !== "undefined") { | ||
| return globalThis; | ||
| } | ||
| return; | ||
| } | ||
| export { isBrowser, getGlobalThis }; | ||
| //# debugId=718223FBC10121D064756E2164756E21 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| import { createRequire } from "node:module"; | ||
| var __create = Object.create; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| function __accessProp(key) { | ||
| return this[key]; | ||
| } | ||
| var __toESMCache_node; | ||
| var __toESMCache_esm; | ||
| var __toESM = (mod, isNodeMode, target) => { | ||
| var canCache = mod != null && typeof mod === "object"; | ||
| if (canCache) { | ||
| var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap; | ||
| var cached = cache.get(mod); | ||
| if (cached) | ||
| return cached; | ||
| } | ||
| target = mod != null ? __create(__getProtoOf(mod)) : {}; | ||
| const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target; | ||
| for (let key of __getOwnPropNames(mod)) | ||
| if (!__hasOwnProp.call(to, key)) | ||
| __defProp(to, key, { | ||
| get: __accessProp.bind(mod, key), | ||
| enumerable: true | ||
| }); | ||
| if (canCache) | ||
| cache.set(mod, to); | ||
| return to; | ||
| }; | ||
| var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports); | ||
| var __returnValue = (v) => v; | ||
| function __exportSetter(name, newValue) { | ||
| this[name] = __returnValue.bind(null, newValue); | ||
| } | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { | ||
| get: all[name], | ||
| enumerable: true, | ||
| configurable: true, | ||
| set: __exportSetter.bind(all, name) | ||
| }); | ||
| }; | ||
| var __require = /* @__PURE__ */ createRequire(import.meta.url); | ||
| export { __toESM, __commonJS, __export, __require }; | ||
| //# debugId=42F86BC5AE2E70AC64756E2164756E21 |
Sorry, the diff of this file is too big to display
+4
-3
| { | ||
| "name": "@uipath/api-workflow-tool", | ||
| "license": "MIT", | ||
| "version": "1.199.0-preview.108", | ||
| "version": "1.200.0-preview.109", | ||
| "description": "Run UiPath API Workflows locally.", | ||
@@ -21,3 +21,4 @@ "private": false, | ||
| "exports": { | ||
| ".": "./dist/tool.js" | ||
| ".": "./dist/tool.js", | ||
| "./packager-tool": "./dist/packager-tool.js" | ||
| }, | ||
@@ -27,3 +28,3 @@ "files": [ | ||
| ], | ||
| "gitHead": "171f68daab68809916e8df10ea198c259f688ede" | ||
| "gitHead": "fcc01cdae81bbd0c25d3d4fc287537a9d19d99f4" | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Network access
Supply chain riskThis module accesses the network.
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 2 instances
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
5258763
26.26%20
400%130444
24.42%48
1500%47
Infinity%