@uipath/solution-tool
Advanced tools
| import { | ||
| getGlobalThis | ||
| } from "./packager-tool-9qecd4wb.js"; | ||
| import { | ||
| AUTH_CANCELLED_ERROR_CODE | ||
| } from "./packager-tool-5arsyj36.js"; | ||
| import"./packager-tool-0v6na3yp.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"./packager-tool-0v6na3yp.js"; | ||
| // ../../node_modules/@jmespath-community/jmespath/dist/index.mjs | ||
| var isObject = (obj) => { | ||
| return obj !== null && Object.prototype.toString.call(obj) === "[object Object]"; | ||
| }; | ||
| var strictDeepEqual = (first, second) => { | ||
| if (first === second) { | ||
| return true; | ||
| } | ||
| if (typeof first !== typeof second) { | ||
| return false; | ||
| } | ||
| if (Array.isArray(first) && Array.isArray(second)) { | ||
| if (first.length !== second.length) { | ||
| return false; | ||
| } | ||
| for (let i = 0;i < first.length; i += 1) { | ||
| if (!strictDeepEqual(first[i], second[i])) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
| if (isObject(first) && isObject(second)) { | ||
| const firstEntries = Object.entries(first); | ||
| const secondKeys = new Set(Object.keys(second)); | ||
| if (firstEntries.length !== secondKeys.size) { | ||
| return false; | ||
| } | ||
| for (const [key, value] of firstEntries) { | ||
| if (!strictDeepEqual(value, second[key])) { | ||
| return false; | ||
| } | ||
| secondKeys.delete(key); | ||
| } | ||
| return secondKeys.size === 0; | ||
| } | ||
| return false; | ||
| }; | ||
| var isFalse = (obj) => { | ||
| if (obj === null || obj === undefined || obj === false) { | ||
| return true; | ||
| } | ||
| if (typeof obj === "string") { | ||
| return obj === ""; | ||
| } | ||
| if (typeof obj === "object") { | ||
| if (Array.isArray(obj)) { | ||
| return obj.length === 0; | ||
| } | ||
| if (obj === null) { | ||
| return true; | ||
| } | ||
| return Object.keys(obj).length === 0; | ||
| } | ||
| return false; | ||
| }; | ||
| var isAlpha = (ch) => { | ||
| return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch === "_"; | ||
| }; | ||
| var isNum = (ch) => { | ||
| return ch >= "0" && ch <= "9" || ch === "-"; | ||
| }; | ||
| var isAlphaNum = (ch) => { | ||
| return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch >= "0" && ch <= "9" || ch === "_"; | ||
| }; | ||
| var ensureInteger = (value) => { | ||
| if (!(typeof value === "number") || Math.floor(value) !== value) { | ||
| throw new Error("invalid-value: expecting an integer."); | ||
| } | ||
| return value; | ||
| }; | ||
| var ensurePositiveInteger = (value) => { | ||
| if (!(typeof value === "number") || value < 0 || Math.floor(value) !== value) { | ||
| throw new Error("invalid-value: expecting a non-negative integer."); | ||
| } | ||
| return value; | ||
| }; | ||
| var ensureNumbers = (...operands) => { | ||
| for (let i = 0;i < operands.length; i++) { | ||
| if (operands[i] === null || operands[i] === undefined) { | ||
| throw new Error("not-a-number: undefined"); | ||
| } | ||
| if (typeof operands[i] !== "number") { | ||
| throw new Error("not-a-number"); | ||
| } | ||
| } | ||
| }; | ||
| var notZero = (n) => { | ||
| n = +n; | ||
| if (!n) { | ||
| throw new Error("not-a-number: divide by zero"); | ||
| } | ||
| return n; | ||
| }; | ||
| var add = (left, right) => { | ||
| ensureNumbers(left, right); | ||
| const result = left + right; | ||
| return result; | ||
| }; | ||
| var sub = (left, right) => { | ||
| ensureNumbers(left, right); | ||
| const result = left - right; | ||
| return result; | ||
| }; | ||
| var mul = (left, right) => { | ||
| ensureNumbers(left, right); | ||
| const result = left * right; | ||
| return result; | ||
| }; | ||
| var divide = (left, right) => { | ||
| ensureNumbers(left, right); | ||
| const result = left / notZero(right); | ||
| return result; | ||
| }; | ||
| var div = (left, right) => { | ||
| ensureNumbers(left, right); | ||
| const result = Math.floor(left / notZero(right)); | ||
| return result; | ||
| }; | ||
| var mod = (left, right) => { | ||
| ensureNumbers(left, right); | ||
| const result = left % right; | ||
| return result; | ||
| }; | ||
| var findFirst = (subject, sub2, start, end) => { | ||
| if (!subject || !sub2) { | ||
| return null; | ||
| } | ||
| start = Math.max(ensureInteger(start = start || 0), 0); | ||
| end = Math.min(ensureInteger(end = end || subject.length), subject.length); | ||
| const offset = subject.slice(start, end).indexOf(sub2); | ||
| return offset === -1 ? null : offset + start; | ||
| }; | ||
| var findLast = (subject, sub2, start, end) => { | ||
| if (!subject || !sub2) { | ||
| return null; | ||
| } | ||
| start = Math.max(ensureInteger(start = start || 0), 0); | ||
| end = Math.min(ensureInteger(end = end || subject.length), subject.length); | ||
| const offset = subject.slice(start, end).lastIndexOf(sub2); | ||
| const result = offset === -1 ? null : offset + start; | ||
| return result; | ||
| }; | ||
| var lower = (subject) => subject.toLowerCase(); | ||
| var ensurePadFuncParams = (name, width, padding) => { | ||
| padding = padding || " "; | ||
| if (padding.length > 1) { | ||
| throw new Error(`invalid value, ${name} expects its 'pad' parameter to be a valid string with a single codepoint`); | ||
| } | ||
| ensurePositiveInteger(width); | ||
| return padding; | ||
| }; | ||
| var padLeft = (subject, width, padding) => { | ||
| padding = ensurePadFuncParams("pad_left", width, padding); | ||
| return subject && subject.padStart(width, padding) || ""; | ||
| }; | ||
| var padRight = (subject, width, padding) => { | ||
| padding = ensurePadFuncParams("pad_right", width, padding); | ||
| return subject && subject.padEnd(width, padding) || ""; | ||
| }; | ||
| var replace = (subject, string, by, count) => { | ||
| if (count === 0) { | ||
| return subject; | ||
| } | ||
| if (!count) { | ||
| return subject.split(string).join(by); | ||
| } | ||
| ensurePositiveInteger(count); | ||
| [...Array(count).keys()].map(() => subject = subject.replace(string, by)); | ||
| return subject; | ||
| }; | ||
| var split = (subject, search2, count) => { | ||
| if (subject.length == 0 && search2.length === 0) { | ||
| return []; | ||
| } | ||
| if (count === null || count === undefined) { | ||
| return subject.split(search2); | ||
| } | ||
| ensurePositiveInteger(count); | ||
| if (count === 0) { | ||
| return [subject]; | ||
| } | ||
| const split2 = subject.split(search2); | ||
| return [...split2.slice(0, count), split2.slice(count).join(search2)]; | ||
| }; | ||
| var trim = (subject, chars) => { | ||
| return trimLeft(trimRight(subject, chars), chars); | ||
| }; | ||
| var trimLeft = (subject, chars) => { | ||
| return trimImpl(subject, (list) => new RegExp(`^[${list}]*(.*?)`), chars); | ||
| }; | ||
| var trimRight = (subject, chars) => { | ||
| return trimImpl(subject, (list) => new RegExp(`(.*?)[${list}]*$`), chars); | ||
| }; | ||
| var trimImpl = (subject, regExper, chars) => { | ||
| const pattern = chars ? chars.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&") : "\\s "; | ||
| return subject.replace(regExper(pattern), "$1"); | ||
| }; | ||
| var upper = (subject) => subject.toUpperCase(); | ||
| var basicTokens = { | ||
| "(": "Lparen", | ||
| ")": "Rparen", | ||
| "*": "Star", | ||
| ",": "Comma", | ||
| ".": "Dot", | ||
| ":": "Colon", | ||
| "@": "Current", | ||
| "]": "Rbracket", | ||
| "{": "Lbrace", | ||
| "}": "Rbrace", | ||
| "+": "Plus", | ||
| "%": "Modulo", | ||
| "?": "Question", | ||
| "−": "Minus", | ||
| "×": "Multiply", | ||
| "÷": "Divide" | ||
| }; | ||
| var operatorStartToken = { | ||
| "!": true, | ||
| "<": true, | ||
| "=": true, | ||
| ">": true, | ||
| "&": true, | ||
| "|": true, | ||
| "/": true | ||
| }; | ||
| var skipChars = { | ||
| "\t": true, | ||
| "\n": true, | ||
| "\r": true, | ||
| " ": true | ||
| }; | ||
| var StreamLexer = class { | ||
| _current = 0; | ||
| _enable_legacy_literals = false; | ||
| tokenize(stream, options) { | ||
| const tokens = []; | ||
| this._current = 0; | ||
| this._enable_legacy_literals = options?.enable_legacy_literals || false; | ||
| let start; | ||
| let identifier; | ||
| let token; | ||
| while (this._current < stream.length) { | ||
| if (isAlpha(stream[this._current])) { | ||
| start = this._current; | ||
| identifier = this.consumeUnquotedIdentifier(stream); | ||
| tokens.push({ | ||
| start, | ||
| type: "UnquotedIdentifier", | ||
| value: identifier | ||
| }); | ||
| } else if (basicTokens[stream[this._current]] !== undefined) { | ||
| tokens.push({ | ||
| start: this._current, | ||
| type: basicTokens[stream[this._current]], | ||
| value: stream[this._current] | ||
| }); | ||
| this._current += 1; | ||
| } else if (stream[this._current] === "$") { | ||
| start = this._current; | ||
| if (this._current + 1 < stream.length && isAlpha(stream[this._current + 1])) { | ||
| this._current += 1; | ||
| identifier = this.consumeUnquotedIdentifier(stream); | ||
| tokens.push({ | ||
| start, | ||
| type: "Variable", | ||
| value: identifier | ||
| }); | ||
| } else { | ||
| tokens.push({ | ||
| start, | ||
| type: "Root", | ||
| value: stream[this._current] | ||
| }); | ||
| this._current += 1; | ||
| } | ||
| } else if (stream[this._current] === "-") { | ||
| if (this._current + 1 < stream.length && isNum(stream[this._current + 1])) { | ||
| const token2 = this.consumeNumber(stream); | ||
| token2 && tokens.push(token2); | ||
| } else { | ||
| const token2 = { | ||
| start: this._current, | ||
| type: "Minus", | ||
| value: "-" | ||
| }; | ||
| tokens.push(token2); | ||
| this._current += 1; | ||
| } | ||
| } else if (isNum(stream[this._current])) { | ||
| token = this.consumeNumber(stream); | ||
| tokens.push(token); | ||
| } else if (stream[this._current] === "[") { | ||
| token = this.consumeLBracket(stream); | ||
| tokens.push(token); | ||
| } else if (stream[this._current] === '"') { | ||
| start = this._current; | ||
| identifier = this.consumeQuotedIdentifier(stream); | ||
| tokens.push({ | ||
| start, | ||
| type: "QuotedIdentifier", | ||
| value: identifier | ||
| }); | ||
| } else if (stream[this._current] === `'`) { | ||
| start = this._current; | ||
| identifier = this.consumeRawStringLiteral(stream); | ||
| tokens.push({ | ||
| start, | ||
| type: "Literal", | ||
| value: identifier | ||
| }); | ||
| } else if (stream[this._current] === "`") { | ||
| start = this._current; | ||
| const literal = this.consumeLiteral(stream); | ||
| tokens.push({ | ||
| start, | ||
| type: "Literal", | ||
| value: literal | ||
| }); | ||
| } else if (operatorStartToken[stream[this._current]] !== undefined) { | ||
| token = this.consumeOperator(stream); | ||
| token && tokens.push(token); | ||
| } else if (skipChars[stream[this._current]] !== undefined) { | ||
| this._current += 1; | ||
| } else { | ||
| const error = new Error(`Syntax error: unknown character: ${stream[this._current]}`); | ||
| error.name = "LexerError"; | ||
| throw error; | ||
| } | ||
| } | ||
| return tokens; | ||
| } | ||
| consumeUnquotedIdentifier(stream) { | ||
| const start = this._current; | ||
| this._current += 1; | ||
| while (this._current < stream.length && isAlphaNum(stream[this._current])) { | ||
| this._current += 1; | ||
| } | ||
| return stream.slice(start, this._current); | ||
| } | ||
| consumeQuotedIdentifier(stream) { | ||
| const start = this._current; | ||
| this._current += 1; | ||
| const maxLength = stream.length; | ||
| while (stream[this._current] !== '"' && this._current < maxLength) { | ||
| let current = this._current; | ||
| if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === '"')) { | ||
| current += 2; | ||
| } else { | ||
| current += 1; | ||
| } | ||
| this._current = current; | ||
| } | ||
| this._current += 1; | ||
| const [value, ok] = this.parseJSON(stream.slice(start, this._current)); | ||
| if (!ok) { | ||
| const error = new Error(`syntax: unexpected end of JSON input`); | ||
| error.name = "LexerError"; | ||
| throw error; | ||
| } | ||
| return value; | ||
| } | ||
| consumeRawStringLiteral(stream) { | ||
| const start = this._current; | ||
| this._current += 1; | ||
| const maxLength = stream.length; | ||
| while (stream[this._current] !== `'` && this._current < maxLength) { | ||
| let current = this._current; | ||
| if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === `'`)) { | ||
| current += 2; | ||
| } else { | ||
| current += 1; | ||
| } | ||
| this._current = current; | ||
| } | ||
| this._current += 1; | ||
| const literal = stream.slice(start + 1, this._current - 1); | ||
| return replace(replace(literal, `\\\\`, `\\`), `\\'`, `'`); | ||
| } | ||
| consumeNumber(stream) { | ||
| const start = this._current; | ||
| this._current += 1; | ||
| const maxLength = stream.length; | ||
| while (isNum(stream[this._current]) && this._current < maxLength) { | ||
| this._current += 1; | ||
| } | ||
| const value = parseInt(stream.slice(start, this._current), 10); | ||
| return { start, value, type: "Number" }; | ||
| } | ||
| consumeLBracket(stream) { | ||
| const start = this._current; | ||
| this._current += 1; | ||
| if (stream[this._current] === "?") { | ||
| this._current += 1; | ||
| return { start, type: "Filter", value: "[?" }; | ||
| } | ||
| if (stream[this._current] === "]") { | ||
| this._current += 1; | ||
| return { start, type: "Flatten", value: "[]" }; | ||
| } | ||
| return { start, type: "Lbracket", value: "[" }; | ||
| } | ||
| consumeOrElse(stream, peek, token, orElse) { | ||
| const start = this._current; | ||
| this._current += 1; | ||
| if (this._current < stream.length && stream[this._current] === peek) { | ||
| this._current += 1; | ||
| return { | ||
| start, | ||
| type: orElse, | ||
| value: stream.slice(start, this._current) | ||
| }; | ||
| } | ||
| return { start, type: token, value: stream[start] }; | ||
| } | ||
| consumeOperator(stream) { | ||
| const start = this._current; | ||
| const startingChar = stream[start]; | ||
| switch (startingChar) { | ||
| case "!": | ||
| return this.consumeOrElse(stream, "=", "Not", "NE"); | ||
| case "<": | ||
| return this.consumeOrElse(stream, "=", "LT", "LTE"); | ||
| case ">": | ||
| return this.consumeOrElse(stream, "=", "GT", "GTE"); | ||
| case "=": | ||
| return this.consumeOrElse(stream, "=", "Assign", "EQ"); | ||
| case "&": | ||
| return this.consumeOrElse(stream, "&", "Expref", "And"); | ||
| case "|": | ||
| return this.consumeOrElse(stream, "|", "Pipe", "Or"); | ||
| case "/": | ||
| return this.consumeOrElse(stream, "/", "Divide", "Div"); | ||
| } | ||
| } | ||
| consumeLiteral(stream) { | ||
| this._current += 1; | ||
| const start = this._current; | ||
| const maxLength = stream.length; | ||
| while (stream[this._current] !== "`" && this._current < maxLength) { | ||
| let current = this._current; | ||
| if (stream[current] === "\\" && (stream[current + 1] === "\\" || stream[current + 1] === "`")) { | ||
| current += 2; | ||
| } else { | ||
| current += 1; | ||
| } | ||
| this._current = current; | ||
| } | ||
| let literalString = stream.slice(start, this._current).trimStart(); | ||
| literalString = literalString.replace("\\`", "`"); | ||
| let literal = null; | ||
| let ok = false; | ||
| if (this.looksLikeJSON(literalString)) { | ||
| [literal, ok] = this.parseJSON(literalString); | ||
| } | ||
| if (!ok && this._enable_legacy_literals) { | ||
| [literal, ok] = this.parseJSON(`"${literalString}"`); | ||
| } | ||
| if (!ok) { | ||
| const error = new Error(`Syntax error: unexpected end of JSON input or invalid format for a JSON literal: ${stream[this._current]}`); | ||
| error.name = "LexerError"; | ||
| throw error; | ||
| } | ||
| this._current += 1; | ||
| return literal; | ||
| } | ||
| looksLikeJSON(literalString) { | ||
| const startingChars = '[{"'; | ||
| const jsonLiterals = ["true", "false", "null"]; | ||
| const numberLooking = "-0123456789"; | ||
| if (literalString === "") { | ||
| return false; | ||
| } | ||
| if (startingChars.includes(literalString[0])) { | ||
| return true; | ||
| } | ||
| if (jsonLiterals.includes(literalString)) { | ||
| return true; | ||
| } | ||
| if (numberLooking.includes(literalString[0])) { | ||
| const [_, ok] = this.parseJSON(literalString); | ||
| return ok; | ||
| } | ||
| return false; | ||
| } | ||
| parseJSON(text) { | ||
| try { | ||
| const json = JSON.parse(text); | ||
| return [json, true]; | ||
| } catch { | ||
| return [null, false]; | ||
| } | ||
| } | ||
| }; | ||
| var Lexer = new StreamLexer; | ||
| var Lexer_default = Lexer; | ||
| var bindingPower = { | ||
| ["EOF"]: 0, | ||
| ["Variable"]: 0, | ||
| ["UnquotedIdentifier"]: 0, | ||
| ["QuotedIdentifier"]: 0, | ||
| ["Rbracket"]: 0, | ||
| ["Rparen"]: 0, | ||
| ["Comma"]: 0, | ||
| ["Rbrace"]: 0, | ||
| ["Number"]: 0, | ||
| ["Current"]: 0, | ||
| ["Expref"]: 0, | ||
| ["Root"]: 0, | ||
| ["Assign"]: 1, | ||
| ["Pipe"]: 1, | ||
| ["Question"]: 2, | ||
| ["Or"]: 3, | ||
| ["And"]: 4, | ||
| ["EQ"]: 5, | ||
| ["GT"]: 5, | ||
| ["LT"]: 5, | ||
| ["GTE"]: 5, | ||
| ["LTE"]: 5, | ||
| ["NE"]: 5, | ||
| ["Minus"]: 6, | ||
| ["Plus"]: 6, | ||
| ["Div"]: 7, | ||
| ["Divide"]: 7, | ||
| ["Modulo"]: 7, | ||
| ["Multiply"]: 7, | ||
| ["Flatten"]: 9, | ||
| ["Star"]: 20, | ||
| ["Filter"]: 21, | ||
| ["Dot"]: 40, | ||
| ["Not"]: 45, | ||
| ["Lbrace"]: 50, | ||
| ["Lbracket"]: 55, | ||
| ["Lparen"]: 60 | ||
| }; | ||
| var TokenParser = class _TokenParser { | ||
| index = 0; | ||
| tokens = []; | ||
| parse(expression, options) { | ||
| this.loadTokens(expression, options || { enable_legacy_literals: false }); | ||
| this.index = 0; | ||
| const ast = this.expression(0); | ||
| if (this.lookahead(0) !== "EOF") { | ||
| const token = this.lookaheadToken(0); | ||
| this.errorToken(token, `Syntax error: unexpected token type: ${token.type}, value: ${token.value}`); | ||
| } | ||
| return ast; | ||
| } | ||
| loadTokens(expression, options) { | ||
| this.tokens = Lexer_default.tokenize(expression, options); | ||
| this.tokens.push({ type: "EOF", value: "", start: expression.length }); | ||
| } | ||
| expression(rbp) { | ||
| const leftToken = this.lookaheadToken(0); | ||
| this.advance(); | ||
| let left = this.nud(leftToken); | ||
| let currentTokenType = this.lookahead(0); | ||
| while (rbp < bindingPower[currentTokenType]) { | ||
| this.advance(); | ||
| left = this.led(currentTokenType, left); | ||
| currentTokenType = this.lookahead(0); | ||
| } | ||
| return left; | ||
| } | ||
| lookahead(offset) { | ||
| return this.tokens[this.index + offset].type; | ||
| } | ||
| lookaheadToken(offset) { | ||
| return this.tokens[this.index + offset]; | ||
| } | ||
| advance() { | ||
| this.index += 1; | ||
| } | ||
| nud(token) { | ||
| switch (token.type) { | ||
| case "Variable": | ||
| return { type: "Variable", name: token.value }; | ||
| case "Literal": | ||
| return { type: "Literal", value: token.value }; | ||
| case "UnquotedIdentifier": { | ||
| if (_TokenParser.isKeyword(token, "let") && this.lookahead(0) === "Variable") { | ||
| return this.parseLetExpression(); | ||
| } else { | ||
| return { type: "Field", name: token.value }; | ||
| } | ||
| } | ||
| case "QuotedIdentifier": | ||
| if (this.lookahead(0) === "Lparen") { | ||
| throw new Error("Syntax error: quoted identifier not allowed for function names."); | ||
| } else { | ||
| return { type: "Field", name: token.value }; | ||
| } | ||
| case "Not": { | ||
| const child = this.expression(bindingPower.Not); | ||
| return { type: "NotExpression", child }; | ||
| } | ||
| case "Minus": { | ||
| const child = this.expression(bindingPower.Minus); | ||
| return { | ||
| type: "Unary", | ||
| operator: token.type, | ||
| operand: child | ||
| }; | ||
| } | ||
| case "Plus": { | ||
| const child = this.expression(bindingPower.Plus); | ||
| return { | ||
| type: "Unary", | ||
| operator: token.type, | ||
| operand: child | ||
| }; | ||
| } | ||
| case "Star": { | ||
| const left = { type: "Identity" }; | ||
| return { type: "ValueProjection", left, right: this.parseProjectionRHS(bindingPower.Star) }; | ||
| } | ||
| case "Filter": | ||
| return this.led(token.type, { type: "Identity" }); | ||
| case "Lbrace": | ||
| return this.parseMultiselectHash(); | ||
| case "Flatten": { | ||
| const left = { | ||
| type: "Flatten", | ||
| child: { type: "Identity" } | ||
| }; | ||
| const right = this.parseProjectionRHS(bindingPower.Flatten); | ||
| return { type: "Projection", left, right }; | ||
| } | ||
| case "Lbracket": { | ||
| if (this.lookahead(0) === "Number" || this.lookahead(0) === "Colon") { | ||
| const right = this.parseIndexExpression(); | ||
| return this.projectIfSlice({ type: "Identity" }, right); | ||
| } | ||
| if (this.lookahead(0) === "Star" && this.lookahead(1) === "Rbracket") { | ||
| this.advance(); | ||
| this.advance(); | ||
| const right = this.parseProjectionRHS(bindingPower.Star); | ||
| return { | ||
| left: { type: "Identity" }, | ||
| right, | ||
| type: "Projection" | ||
| }; | ||
| } | ||
| return this.parseMultiselectList(); | ||
| } | ||
| case "Current": | ||
| return { type: "Current" }; | ||
| case "Root": | ||
| return { type: "Root" }; | ||
| case "Expref": { | ||
| const child = this.expression(bindingPower.Expref); | ||
| return { type: "ExpressionReference", child }; | ||
| } | ||
| case "Lparen": { | ||
| const expression = this.expression(0); | ||
| this.match("Rparen"); | ||
| return expression; | ||
| } | ||
| default: | ||
| this.errorToken(token); | ||
| } | ||
| } | ||
| led(tokenName, left) { | ||
| switch (tokenName) { | ||
| case "Question": { | ||
| const trueExpr = this.expression(0); | ||
| this.match("Colon"); | ||
| const falseExpr = this.expression(0); | ||
| return { | ||
| type: "Ternary", | ||
| condition: left, | ||
| trueExpr, | ||
| falseExpr | ||
| }; | ||
| } | ||
| case "Dot": { | ||
| const rbp = bindingPower.Dot; | ||
| if (this.lookahead(0) !== "Star") { | ||
| const right2 = this.parseDotRHS(rbp); | ||
| return { type: "Subexpression", left, right: right2 }; | ||
| } | ||
| this.advance(); | ||
| const right = this.parseProjectionRHS(rbp); | ||
| return { type: "ValueProjection", left, right }; | ||
| } | ||
| case "Pipe": { | ||
| const right = this.expression(bindingPower.Pipe); | ||
| return { type: "Pipe", left, right }; | ||
| } | ||
| case "Or": { | ||
| const right = this.expression(bindingPower.Or); | ||
| return { type: "OrExpression", left, right }; | ||
| } | ||
| case "And": { | ||
| const right = this.expression(bindingPower.And); | ||
| return { type: "AndExpression", left, right }; | ||
| } | ||
| case "Lparen": { | ||
| if (left.type !== "Field") { | ||
| throw new Error("Syntax error: expected a Field node"); | ||
| } | ||
| const name = left.name; | ||
| const args = this.parseCommaSeparatedExpressionsUntilToken("Rparen"); | ||
| const node = { name, type: "Function", children: args }; | ||
| return node; | ||
| } | ||
| case "Filter": { | ||
| const condition = this.expression(0); | ||
| this.match("Rbracket"); | ||
| const right = this.lookahead(0) === "Flatten" ? { type: "Identity" } : this.parseProjectionRHS(bindingPower.Filter); | ||
| return { type: "FilterProjection", left, right, condition }; | ||
| } | ||
| case "Flatten": { | ||
| const leftNode = { type: "Flatten", child: left }; | ||
| const right = this.parseProjectionRHS(bindingPower.Flatten); | ||
| return { type: "Projection", left: leftNode, right }; | ||
| } | ||
| case "Assign": { | ||
| const leftNode = left; | ||
| const right = this.expression(0); | ||
| return { | ||
| type: "Binding", | ||
| variable: leftNode.name, | ||
| reference: right | ||
| }; | ||
| } | ||
| case "EQ": | ||
| case "NE": | ||
| case "GT": | ||
| case "GTE": | ||
| case "LT": | ||
| case "LTE": | ||
| return this.parseComparator(left, tokenName); | ||
| case "Plus": | ||
| case "Minus": | ||
| case "Multiply": | ||
| case "Star": | ||
| case "Divide": | ||
| case "Modulo": | ||
| case "Div": | ||
| return this.parseArithmetic(left, tokenName); | ||
| case "Lbracket": { | ||
| const token = this.lookaheadToken(0); | ||
| if (token.type === "Number" || token.type === "Colon") { | ||
| const right2 = this.parseIndexExpression(); | ||
| return this.projectIfSlice(left, right2); | ||
| } | ||
| this.match("Star"); | ||
| this.match("Rbracket"); | ||
| const right = this.parseProjectionRHS(bindingPower.Star); | ||
| return { type: "Projection", left, right }; | ||
| } | ||
| default: | ||
| return this.errorToken(this.lookaheadToken(0)); | ||
| } | ||
| } | ||
| static isKeyword(token, keyword) { | ||
| return token.type === "UnquotedIdentifier" && token.value === keyword; | ||
| } | ||
| match(tokenType) { | ||
| if (this.lookahead(0) === tokenType) { | ||
| this.advance(); | ||
| return; | ||
| } else { | ||
| const token = this.lookaheadToken(0); | ||
| this.errorToken(token, `Syntax error: expected ${tokenType}, got: ${token.type}`); | ||
| } | ||
| } | ||
| errorToken(token, message = "") { | ||
| const error = new Error(message || `Syntax error: invalid token (${token.type}): "${token.value}"`); | ||
| error.name = "ParserError"; | ||
| throw error; | ||
| } | ||
| parseIndexExpression() { | ||
| if (this.lookahead(0) === "Colon" || this.lookahead(1) === "Colon") { | ||
| return this.parseSliceExpression(); | ||
| } | ||
| const value = Number(this.lookaheadToken(0).value); | ||
| this.advance(); | ||
| this.match("Rbracket"); | ||
| return { type: "Index", value }; | ||
| } | ||
| projectIfSlice(left, right) { | ||
| const indexExpr = { | ||
| type: "IndexExpression", | ||
| left, | ||
| right | ||
| }; | ||
| if (right.type === "Slice") { | ||
| return { | ||
| left: indexExpr, | ||
| right: this.parseProjectionRHS(bindingPower.Star), | ||
| type: "Projection" | ||
| }; | ||
| } | ||
| return indexExpr; | ||
| } | ||
| parseSliceExpression() { | ||
| const parts = [null, null, null]; | ||
| let index = 0; | ||
| let current = this.lookaheadToken(0); | ||
| while (current.type != "Rbracket" && index < 3) { | ||
| if (current.type === "Colon") { | ||
| index++; | ||
| if (index === 3) { | ||
| this.errorToken(this.lookaheadToken(0), "Syntax error, too many colons in slice expression"); | ||
| } | ||
| this.advance(); | ||
| } else if (current.type === "Number") { | ||
| const part = this.lookaheadToken(0).value; | ||
| parts[index] = part; | ||
| this.advance(); | ||
| } else { | ||
| const next = this.lookaheadToken(0); | ||
| this.errorToken(next, `Syntax error, unexpected token: ${next.value}(${next.type})`); | ||
| } | ||
| current = this.lookaheadToken(0); | ||
| } | ||
| this.match("Rbracket"); | ||
| const [start, stop, step] = parts; | ||
| return { type: "Slice", start, stop, step }; | ||
| } | ||
| parseLetExpression() { | ||
| const separated = this.parseCommaSeparatedExpressionsUntilKeyword("in"); | ||
| const expression = this.expression(0); | ||
| const bindings = separated.map((binding) => binding); | ||
| return { | ||
| type: "LetExpression", | ||
| bindings, | ||
| expression | ||
| }; | ||
| } | ||
| parseCommaSeparatedExpressionsUntilKeyword(keyword) { | ||
| return this.parseCommaSeparatedExpressionsUntil(() => { | ||
| return _TokenParser.isKeyword(this.lookaheadToken(0), keyword); | ||
| }, () => { | ||
| this.advance(); | ||
| }); | ||
| } | ||
| parseCommaSeparatedExpressionsUntilToken(token) { | ||
| return this.parseCommaSeparatedExpressionsUntil(() => { | ||
| return this.lookahead(0) === token; | ||
| }, () => { | ||
| return this.match(token); | ||
| }); | ||
| } | ||
| parseCommaSeparatedExpressionsUntil(isEndToken, matchEndToken) { | ||
| const args = []; | ||
| let expression; | ||
| while (!isEndToken()) { | ||
| expression = this.expression(0); | ||
| if (this.lookahead(0) === "Comma") { | ||
| this.match("Comma"); | ||
| } | ||
| args.push(expression); | ||
| } | ||
| matchEndToken(); | ||
| return args; | ||
| } | ||
| parseComparator(left, comparator) { | ||
| const right = this.expression(bindingPower[comparator]); | ||
| return { type: "Comparator", name: comparator, left, right }; | ||
| } | ||
| parseArithmetic(left, operator) { | ||
| const right = this.expression(bindingPower[operator]); | ||
| return { type: "Arithmetic", operator, left, right }; | ||
| } | ||
| parseDotRHS(rbp) { | ||
| const lookahead = this.lookahead(0); | ||
| const exprTokens = ["UnquotedIdentifier", "QuotedIdentifier", "Star"]; | ||
| if (exprTokens.includes(lookahead)) { | ||
| return this.expression(rbp); | ||
| } | ||
| if (lookahead === "Lbracket") { | ||
| this.match("Lbracket"); | ||
| return this.parseMultiselectList(); | ||
| } | ||
| if (lookahead === "Lbrace") { | ||
| this.match("Lbrace"); | ||
| return this.parseMultiselectHash(); | ||
| } | ||
| const token = this.lookaheadToken(0); | ||
| this.errorToken(token, `Syntax error, unexpected token: ${token.value}(${token.type})`); | ||
| } | ||
| parseProjectionRHS(rbp) { | ||
| if (bindingPower[this.lookahead(0)] < 10) { | ||
| return { type: "Identity" }; | ||
| } | ||
| if (this.lookahead(0) === "Lbracket") { | ||
| return this.expression(rbp); | ||
| } | ||
| if (this.lookahead(0) === "Filter") { | ||
| return this.expression(rbp); | ||
| } | ||
| if (this.lookahead(0) === "Dot") { | ||
| this.match("Dot"); | ||
| return this.parseDotRHS(rbp); | ||
| } | ||
| const token = this.lookaheadToken(0); | ||
| this.errorToken(token, `Syntax error, unexpected token: ${token.value}(${token.type})`); | ||
| } | ||
| parseMultiselectList() { | ||
| const expressions = []; | ||
| while (this.lookahead(0) !== "Rbracket") { | ||
| const expression = this.expression(0); | ||
| expressions.push(expression); | ||
| if (this.lookahead(0) === "Comma") { | ||
| this.match("Comma"); | ||
| if (this.lookahead(0) === "Rbracket") { | ||
| throw new Error("Syntax error: unexpected token Rbracket"); | ||
| } | ||
| } | ||
| } | ||
| this.match("Rbracket"); | ||
| return { type: "MultiSelectList", children: expressions }; | ||
| } | ||
| parseMultiselectHash() { | ||
| const pairs = []; | ||
| const identifierTypes = ["UnquotedIdentifier", "QuotedIdentifier"]; | ||
| let keyToken; | ||
| let keyName; | ||
| let value; | ||
| for (;; ) { | ||
| keyToken = this.lookaheadToken(0); | ||
| if (!identifierTypes.includes(keyToken.type)) { | ||
| throw new Error(`Syntax error: expecting an identifier token, got: ${keyToken.type}`); | ||
| } | ||
| keyName = keyToken.value; | ||
| this.advance(); | ||
| this.match("Colon"); | ||
| value = this.expression(0); | ||
| pairs.push({ value, type: "KeyValuePair", name: keyName }); | ||
| if (this.lookahead(0) === "Comma") { | ||
| this.match("Comma"); | ||
| } else if (this.lookahead(0) === "Rbrace") { | ||
| this.match("Rbrace"); | ||
| break; | ||
| } | ||
| } | ||
| return { type: "MultiSelectHash", children: pairs }; | ||
| } | ||
| }; | ||
| var Parser = new TokenParser; | ||
| var Parser_default = Parser; | ||
| var Text = class _Text { | ||
| _text; | ||
| constructor(text) { | ||
| this._text = text; | ||
| } | ||
| get string() { | ||
| return this._text; | ||
| } | ||
| get length() { | ||
| return this.codePoints.length; | ||
| } | ||
| compareTo(other) { | ||
| return _Text.compare(this, new _Text(other)); | ||
| } | ||
| static get comparer() { | ||
| const stringComparer = (left, right) => { | ||
| return new _Text(left).compareTo(right); | ||
| }; | ||
| return stringComparer; | ||
| } | ||
| static compare(left, right) { | ||
| const leftCp = left.codePoints; | ||
| const rightCp = right.codePoints; | ||
| for (let index = 0;index < Math.min(leftCp.length, rightCp.length); index++) { | ||
| if (leftCp[index] === rightCp[index]) { | ||
| continue; | ||
| } | ||
| return leftCp[index] - rightCp[index] > 0 ? 1 : -1; | ||
| } | ||
| return leftCp.length - rightCp.length > 0 ? 1 : -1; | ||
| } | ||
| reverse() { | ||
| return String.fromCodePoint(...this.codePoints.reverse()); | ||
| } | ||
| get codePoints() { | ||
| const array = [...this._text].map((s) => s.codePointAt(0)); | ||
| return array; | ||
| } | ||
| }; | ||
| var createMathFunction = (mathFn) => ([value]) => mathFn(value); | ||
| var createStringFunction = (stringFn) => ([subject]) => stringFn(subject); | ||
| var createObjectFunction = (objFn) => ([obj]) => objFn(obj); | ||
| var Runtime = class { | ||
| _interpreter; | ||
| _functionTable; | ||
| _customFunctions = /* @__PURE__ */ new Set; | ||
| TYPE_NAME_TABLE = Object.freeze({ | ||
| [0]: "number", | ||
| [1]: "any", | ||
| [2]: "string", | ||
| [3]: "array", | ||
| [4]: "object", | ||
| [5]: "boolean", | ||
| [6]: "expression", | ||
| [7]: "null", | ||
| [8]: "Array<number>", | ||
| [10]: "Array<object>", | ||
| [9]: "Array<string>", | ||
| [11]: "Array<Array<any>>" | ||
| }); | ||
| constructor(interpreter) { | ||
| this._interpreter = interpreter; | ||
| this._functionTable = this.buildFunctionTable(); | ||
| } | ||
| buildFunctionTable() { | ||
| return { | ||
| abs: { _func: createMathFunction(Math.abs), _signature: [{ types: [0] }] }, | ||
| ceil: { _func: createMathFunction(Math.ceil), _signature: [{ types: [0] }] }, | ||
| floor: { _func: createMathFunction(Math.floor), _signature: [{ types: [0] }] }, | ||
| lower: { _func: createStringFunction(lower), _signature: [{ types: [2] }] }, | ||
| upper: { _func: createStringFunction(upper), _signature: [{ types: [2] }] }, | ||
| keys: { _func: createObjectFunction(Object.keys), _signature: [{ types: [4] }] }, | ||
| values: { _func: createObjectFunction(Object.values), _signature: [{ types: [4] }] }, | ||
| avg: { _func: this.functionAvg, _signature: [{ types: [8] }] }, | ||
| contains: { | ||
| _func: this.functionContains, | ||
| _signature: [ | ||
| { types: [2, 3] }, | ||
| { types: [1] } | ||
| ] | ||
| }, | ||
| ends_with: { | ||
| _func: this.functionEndsWith, | ||
| _signature: [{ types: [2] }, { types: [2] }] | ||
| }, | ||
| find_first: { | ||
| _func: this.functionFindFirst, | ||
| _signature: [ | ||
| { types: [2] }, | ||
| { types: [2] }, | ||
| { types: [0], optional: true }, | ||
| { types: [0], optional: true } | ||
| ] | ||
| }, | ||
| find_last: { | ||
| _func: this.functionFindLast, | ||
| _signature: [ | ||
| { types: [2] }, | ||
| { types: [2] }, | ||
| { types: [0], optional: true }, | ||
| { types: [0], optional: true } | ||
| ] | ||
| }, | ||
| from_items: { _func: this.functionFromItems, _signature: [{ types: [11] }] }, | ||
| group_by: { | ||
| _func: this.functionGroupBy, | ||
| _signature: [{ types: [3] }, { types: [6] }] | ||
| }, | ||
| items: { _func: this.functionItems, _signature: [{ types: [4] }] }, | ||
| join: { | ||
| _func: this.functionJoin, | ||
| _signature: [{ types: [2] }, { types: [9] }] | ||
| }, | ||
| length: { | ||
| _func: this.functionLength, | ||
| _signature: [{ types: [2, 3, 4] }] | ||
| }, | ||
| map: { | ||
| _func: this.functionMap, | ||
| _signature: [{ types: [6] }, { types: [3] }] | ||
| }, | ||
| max: { | ||
| _func: this.functionMax, | ||
| _signature: [{ types: [8, 9] }] | ||
| }, | ||
| max_by: { | ||
| _func: this.functionMaxBy, | ||
| _signature: [{ types: [3] }, { types: [6] }] | ||
| }, | ||
| merge: { _func: this.functionMerge, _signature: [{ types: [4], variadic: true }] }, | ||
| min: { | ||
| _func: this.functionMin, | ||
| _signature: [{ types: [8, 9] }] | ||
| }, | ||
| min_by: { | ||
| _func: this.functionMinBy, | ||
| _signature: [{ types: [3] }, { types: [6] }] | ||
| }, | ||
| not_null: { _func: this.functionNotNull, _signature: [{ types: [1], variadic: true }] }, | ||
| pad_left: { | ||
| _func: this.functionPadLeft, | ||
| _signature: [ | ||
| { types: [2] }, | ||
| { types: [0] }, | ||
| { types: [2], optional: true } | ||
| ] | ||
| }, | ||
| pad_right: { | ||
| _func: this.functionPadRight, | ||
| _signature: [ | ||
| { types: [2] }, | ||
| { types: [0] }, | ||
| { types: [2], optional: true } | ||
| ] | ||
| }, | ||
| replace: { | ||
| _func: this.functionReplace, | ||
| _signature: [ | ||
| { types: [2] }, | ||
| { types: [2] }, | ||
| { types: [2] }, | ||
| { types: [0], optional: true } | ||
| ] | ||
| }, | ||
| reverse: { | ||
| _func: this.functionReverse, | ||
| _signature: [{ types: [2, 3] }] | ||
| }, | ||
| sort: { | ||
| _func: this.functionSort, | ||
| _signature: [{ types: [9, 8] }] | ||
| }, | ||
| sort_by: { | ||
| _func: this.functionSortBy, | ||
| _signature: [{ types: [3] }, { types: [6] }] | ||
| }, | ||
| split: { | ||
| _func: this.functionSplit, | ||
| _signature: [ | ||
| { types: [2] }, | ||
| { types: [2] }, | ||
| { types: [0], optional: true } | ||
| ] | ||
| }, | ||
| starts_with: { | ||
| _func: this.functionStartsWith, | ||
| _signature: [{ types: [2] }, { types: [2] }] | ||
| }, | ||
| sum: { _func: this.functionSum, _signature: [{ types: [8] }] }, | ||
| to_array: { _func: this.functionToArray, _signature: [{ types: [1] }] }, | ||
| to_number: { _func: this.functionToNumber, _signature: [{ types: [1] }] }, | ||
| to_string: { _func: this.functionToString, _signature: [{ types: [1] }] }, | ||
| trim: { | ||
| _func: this.functionTrim, | ||
| _signature: [{ types: [2] }, { types: [2], optional: true }] | ||
| }, | ||
| trim_left: { | ||
| _func: this.functionTrimLeft, | ||
| _signature: [{ types: [2] }, { types: [2], optional: true }] | ||
| }, | ||
| trim_right: { | ||
| _func: this.functionTrimRight, | ||
| _signature: [{ types: [2] }, { types: [2], optional: true }] | ||
| }, | ||
| type: { _func: this.functionType, _signature: [{ types: [1] }] }, | ||
| zip: { _func: this.functionZip, _signature: [{ types: [3], variadic: true }] } | ||
| }; | ||
| } | ||
| registerFunction(name, customFunction, signature, options) { | ||
| const result = this._registerInternal(name, customFunction, signature, options); | ||
| if (!result.success) { | ||
| throw new Error(result.message); | ||
| } | ||
| } | ||
| _registerInternal(name, customFunction, signature, options = {}) { | ||
| if (!name || typeof name !== "string" || name.trim() === "") { | ||
| return { | ||
| success: false, | ||
| reason: "invalid-name", | ||
| message: "Function name must be a non-empty string" | ||
| }; | ||
| } | ||
| try { | ||
| this.validateInputSignatures(name, signature); | ||
| } catch (error) { | ||
| return { | ||
| success: false, | ||
| reason: "invalid-signature", | ||
| message: error instanceof Error ? error.message : "Invalid function signature" | ||
| }; | ||
| } | ||
| const { override = false, warn = false } = options; | ||
| const exists = name in this._functionTable; | ||
| if (exists && !override) { | ||
| return { | ||
| success: false, | ||
| reason: "already-exists", | ||
| message: `Function already defined: ${name}(). Use { override: true } to replace it.` | ||
| }; | ||
| } | ||
| if (exists && override && warn) { | ||
| console.warn(`Warning: Overriding existing function: ${name}()`); | ||
| } | ||
| this._functionTable[name] = { | ||
| _func: customFunction.bind(this), | ||
| _signature: signature | ||
| }; | ||
| this._customFunctions.add(name); | ||
| const message = exists ? `Function ${name}() overridden successfully` : `Function ${name}() registered successfully`; | ||
| return { success: true, message }; | ||
| } | ||
| register(name, customFunction, signature, options = {}) { | ||
| return this._registerInternal(name, customFunction, signature, options); | ||
| } | ||
| unregister(name) { | ||
| if (!this._customFunctions.has(name)) { | ||
| return false; | ||
| } | ||
| delete this._functionTable[name]; | ||
| this._customFunctions.delete(name); | ||
| return true; | ||
| } | ||
| isRegistered(name) { | ||
| return name in this._functionTable; | ||
| } | ||
| getRegistered() { | ||
| return Object.keys(this._functionTable); | ||
| } | ||
| getCustomFunctions() { | ||
| return Array.from(this._customFunctions); | ||
| } | ||
| clearCustomFunctions() { | ||
| for (const name of this._customFunctions) { | ||
| delete this._functionTable[name]; | ||
| } | ||
| this._customFunctions.clear(); | ||
| } | ||
| callFunction(name, resolvedArgs) { | ||
| const functionEntry = this._functionTable[name]; | ||
| if (functionEntry === undefined) { | ||
| throw new Error(`Unknown function: ${name}()`); | ||
| } | ||
| this.validateArgs(name, resolvedArgs, functionEntry._signature); | ||
| return functionEntry._func.call(this, resolvedArgs); | ||
| } | ||
| validateInputSignatures(name, signature) { | ||
| for (let i = 0;i < signature.length; i += 1) { | ||
| if ("variadic" in signature[i] && i !== signature.length - 1) { | ||
| throw new Error(`Invalid arity: ${name}() 'variadic' argument ${i + 1} must occur last`); | ||
| } | ||
| } | ||
| } | ||
| validateArgs(name, args, signature) { | ||
| this.validateInputSignatures(name, signature); | ||
| this.validateArity(name, args, signature); | ||
| this.validateTypes(name, args, signature); | ||
| } | ||
| validateArity(name, args, signature) { | ||
| const numberOfRequiredArgs = signature.filter((argSignature) => !(argSignature.optional ?? false)).length; | ||
| const lastArgIsVariadic = signature[signature.length - 1]?.variadic ?? false; | ||
| const tooFewArgs = args.length < numberOfRequiredArgs; | ||
| const tooManyArgs = args.length > signature.length; | ||
| if (lastArgIsVariadic && tooFewArgs || !lastArgIsVariadic && (tooFewArgs || tooManyArgs)) { | ||
| const tooFewModifier = tooFewArgs && (!lastArgIsVariadic && numberOfRequiredArgs > 1 || lastArgIsVariadic) ? "at least " : ""; | ||
| const pluralized = signature.length > 1; | ||
| throw new Error(`Invalid arity: ${name}() takes ${tooFewModifier}${numberOfRequiredArgs} argument${pluralized && "s" || ""} but received ${args.length}`); | ||
| } | ||
| } | ||
| validateTypes(name, args, signature) { | ||
| for (let i = 0;i < signature.length; i += 1) { | ||
| const currentSpec = signature[i].types; | ||
| const actualType = this.getTypeName(args[i]); | ||
| if (actualType === undefined) { | ||
| continue; | ||
| } | ||
| const typeMatched = currentSpec.some((expectedType) => this.typeMatches(actualType, expectedType, args[i])); | ||
| if (!typeMatched) { | ||
| const expected = currentSpec.map((typeId) => this.TYPE_NAME_TABLE[typeId]).join(" | "); | ||
| throw new Error(`Invalid type: ${name}() expected argument ${i + 1} to be type (${expected}) but received type ${this.TYPE_NAME_TABLE[actualType]} instead.`); | ||
| } | ||
| } | ||
| } | ||
| typeMatches(actual, expected, argValue) { | ||
| if (expected === 1) { | ||
| return true; | ||
| } | ||
| if (expected === 9 || expected === 8 || expected === 10 || expected === 11 || expected === 3) { | ||
| if (expected === 3) { | ||
| return actual === 3; | ||
| } | ||
| if (actual === 3) { | ||
| let subtype; | ||
| if (expected === 8) { | ||
| subtype = 0; | ||
| } else if (expected === 10) { | ||
| subtype = 4; | ||
| } else if (expected === 9) { | ||
| subtype = 2; | ||
| } else if (expected === 11) { | ||
| subtype = 3; | ||
| } | ||
| const array = argValue; | ||
| for (let i = 0;i < array.length; i += 1) { | ||
| const typeName = this.getTypeName(array[i]); | ||
| if (typeName !== undefined && subtype !== undefined && !this.typeMatches(typeName, subtype, array[i])) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
| } else { | ||
| return actual === expected; | ||
| } | ||
| return false; | ||
| } | ||
| getTypeName(obj) { | ||
| if (obj === null) { | ||
| return 7; | ||
| } | ||
| if (typeof obj === "string") { | ||
| return 2; | ||
| } | ||
| if (typeof obj === "number") { | ||
| return 0; | ||
| } | ||
| if (typeof obj === "boolean") { | ||
| return 5; | ||
| } | ||
| if (Array.isArray(obj)) { | ||
| return 3; | ||
| } | ||
| if (typeof obj === "object") { | ||
| if (obj.expref) { | ||
| return 6; | ||
| } | ||
| return 4; | ||
| } | ||
| return; | ||
| } | ||
| createKeyFunction(exprefNode, allowedTypes) { | ||
| const interpreter = this._interpreter; | ||
| const keyFunc = (x) => { | ||
| const current = interpreter.visit(exprefNode, x); | ||
| if (!allowedTypes.includes(this.getTypeName(current))) { | ||
| const msg = `Invalid type: expected one of (${allowedTypes.map((t) => this.TYPE_NAME_TABLE[t]).join(" | ")}), received ${this.TYPE_NAME_TABLE[this.getTypeName(current)]}`; | ||
| throw new Error(msg); | ||
| } | ||
| return current; | ||
| }; | ||
| return keyFunc; | ||
| } | ||
| functionAvg = ([inputArray]) => { | ||
| if (!inputArray || inputArray.length == 0) { | ||
| return null; | ||
| } | ||
| let sum = 0; | ||
| for (let i = 0;i < inputArray.length; i += 1) { | ||
| sum += inputArray[i]; | ||
| } | ||
| return sum / inputArray.length; | ||
| }; | ||
| functionContains = ([ | ||
| searchable, | ||
| searchValue | ||
| ]) => { | ||
| if (Array.isArray(searchable)) { | ||
| const array = searchable; | ||
| return array.includes(searchValue); | ||
| } | ||
| if (typeof searchable === "string") { | ||
| const text = searchable; | ||
| if (typeof searchValue === "string") { | ||
| return text.includes(searchValue); | ||
| } | ||
| } | ||
| return null; | ||
| }; | ||
| functionEndsWith = (resolvedArgs) => { | ||
| const [searchStr, suffix] = resolvedArgs; | ||
| return searchStr.includes(suffix, searchStr.length - suffix.length); | ||
| }; | ||
| functionFindFirst = this.createFindFunction(findFirst); | ||
| functionFindLast = this.createFindFunction(findLast); | ||
| createFindFunction(findFn) { | ||
| return (resolvedArgs) => { | ||
| const subject = resolvedArgs[0]; | ||
| const search2 = resolvedArgs[1]; | ||
| const start = resolvedArgs.length > 2 ? resolvedArgs[2] : undefined; | ||
| const end = resolvedArgs.length > 3 ? resolvedArgs[3] : undefined; | ||
| return findFn(subject, search2, start, end); | ||
| }; | ||
| } | ||
| functionFromItems = ([array]) => { | ||
| array.map((pair) => { | ||
| if (pair.length != 2 || typeof pair[0] !== "string") { | ||
| throw new Error("invalid value, each array must contain two elements, a pair of string and value"); | ||
| } | ||
| }); | ||
| return Object.fromEntries(array); | ||
| }; | ||
| functionGroupBy = ([array, exprefNode]) => { | ||
| const keyFunction = this.createKeyFunction(exprefNode, [2]); | ||
| return array.reduce((acc, cur) => { | ||
| const k = keyFunction(cur ?? {}); | ||
| const target = acc[k] = acc[k] || []; | ||
| target.push(cur); | ||
| return acc; | ||
| }, {}); | ||
| }; | ||
| functionItems = ([inputValue]) => { | ||
| return Object.entries(inputValue); | ||
| }; | ||
| functionJoin = (resolvedArgs) => { | ||
| const [joinChar, listJoin] = resolvedArgs; | ||
| return listJoin.join(joinChar); | ||
| }; | ||
| functionLength = ([inputValue]) => { | ||
| if (typeof inputValue === "string") { | ||
| return new Text(inputValue).length; | ||
| } | ||
| if (Array.isArray(inputValue)) { | ||
| return inputValue.length; | ||
| } | ||
| return Object.keys(inputValue).length; | ||
| }; | ||
| functionMap = ([exprefNode, elements]) => { | ||
| if (!this._interpreter) { | ||
| return []; | ||
| } | ||
| const mapped = []; | ||
| const interpreter = this._interpreter; | ||
| for (let i = 0;i < elements.length; i += 1) { | ||
| mapped.push(interpreter.visit(exprefNode, elements[i])); | ||
| } | ||
| return mapped; | ||
| }; | ||
| functionMax = ([inputValue]) => { | ||
| if (!inputValue.length) { | ||
| return null; | ||
| } | ||
| const typeName = this.getTypeName(inputValue[0]); | ||
| if (typeName === 0) { | ||
| return Math.max(...inputValue); | ||
| } | ||
| const elements = inputValue; | ||
| let maxElement = elements[0]; | ||
| for (let i = 1;i < elements.length; i += 1) { | ||
| if (maxElement.localeCompare(elements[i]) < 0) { | ||
| maxElement = elements[i]; | ||
| } | ||
| } | ||
| return maxElement; | ||
| }; | ||
| functionMaxBy = (resolvedArgs) => { | ||
| const exprefNode = resolvedArgs[1]; | ||
| const resolvedArray = resolvedArgs[0]; | ||
| const keyFunction = this.createKeyFunction(exprefNode, [0, 2]); | ||
| let maxNumber = -Infinity; | ||
| let maxRecord; | ||
| let current; | ||
| for (let i = 0;i < resolvedArray.length; i += 1) { | ||
| current = keyFunction && keyFunction(resolvedArray[i]); | ||
| if (current !== undefined && current > maxNumber) { | ||
| maxNumber = current; | ||
| maxRecord = resolvedArray[i]; | ||
| } | ||
| } | ||
| return maxRecord || null; | ||
| }; | ||
| functionMerge = (resolvedArgs) => { | ||
| let merged = {}; | ||
| for (let i = 0;i < resolvedArgs.length; i += 1) { | ||
| const current = resolvedArgs[i]; | ||
| merged = Object.assign(merged, current); | ||
| } | ||
| return merged; | ||
| }; | ||
| functionMin = ([inputValue]) => { | ||
| if (!inputValue.length) { | ||
| return null; | ||
| } | ||
| const typeName = this.getTypeName(inputValue[0]); | ||
| if (typeName === 0) { | ||
| return Math.min(...inputValue); | ||
| } | ||
| const elements = inputValue; | ||
| let minElement = elements[0]; | ||
| for (let i = 1;i < elements.length; i += 1) { | ||
| if (elements[i].localeCompare(minElement) < 0) { | ||
| minElement = elements[i]; | ||
| } | ||
| } | ||
| return minElement; | ||
| }; | ||
| functionMinBy = (resolvedArgs) => { | ||
| const exprefNode = resolvedArgs[1]; | ||
| const resolvedArray = resolvedArgs[0]; | ||
| const keyFunction = this.createKeyFunction(exprefNode, [0, 2]); | ||
| let minNumber = Infinity; | ||
| let minRecord; | ||
| let current; | ||
| for (let i = 0;i < resolvedArray.length; i += 1) { | ||
| current = keyFunction && keyFunction(resolvedArray[i]); | ||
| if (current !== undefined && current < minNumber) { | ||
| minNumber = current; | ||
| minRecord = resolvedArray[i]; | ||
| } | ||
| } | ||
| return minRecord || null; | ||
| }; | ||
| functionNotNull = (resolvedArgs) => { | ||
| for (let i = 0;i < resolvedArgs.length; i += 1) { | ||
| if (this.getTypeName(resolvedArgs[i]) !== 7) { | ||
| return resolvedArgs[i]; | ||
| } | ||
| } | ||
| return null; | ||
| }; | ||
| functionPadLeft = this.createPadFunction(padLeft); | ||
| functionPadRight = this.createPadFunction(padRight); | ||
| createPadFunction(padFn) { | ||
| return (resolvedArgs) => { | ||
| const subject = resolvedArgs[0]; | ||
| const width = resolvedArgs[1]; | ||
| const padding = resolvedArgs.length > 2 ? resolvedArgs[2] : undefined; | ||
| return padFn(subject, width, padding); | ||
| }; | ||
| } | ||
| functionReplace = (resolvedArgs) => { | ||
| const subject = resolvedArgs[0]; | ||
| const string = resolvedArgs[1]; | ||
| const by = resolvedArgs[2]; | ||
| return replace(subject, string, by, resolvedArgs.length > 3 ? resolvedArgs[3] : undefined); | ||
| }; | ||
| functionSplit = (resolvedArgs) => { | ||
| const subject = resolvedArgs[0]; | ||
| const search2 = resolvedArgs[1]; | ||
| return split(subject, search2, resolvedArgs.length > 2 ? resolvedArgs[2] : undefined); | ||
| }; | ||
| functionReverse = ([inputValue]) => { | ||
| const typeName = this.getTypeName(inputValue); | ||
| if (typeName === 2) { | ||
| return new Text(inputValue).reverse(); | ||
| } | ||
| const reversedArray = inputValue.slice(0); | ||
| reversedArray.reverse(); | ||
| return reversedArray; | ||
| }; | ||
| functionSort = ([inputValue]) => { | ||
| if (inputValue.length == 0) { | ||
| return inputValue; | ||
| } | ||
| if (typeof inputValue[0] === "string") { | ||
| return [...inputValue].sort(Text.comparer); | ||
| } | ||
| return [...inputValue].sort(); | ||
| }; | ||
| functionSortBy = (resolvedArgs) => { | ||
| const sortedArray = resolvedArgs[0].slice(0); | ||
| if (sortedArray.length === 0) { | ||
| return sortedArray; | ||
| } | ||
| const interpreter = this._interpreter; | ||
| const exprefNode = resolvedArgs[1]; | ||
| const requiredType = this.getTypeName(interpreter.visit(exprefNode, sortedArray[0])); | ||
| if (requiredType !== undefined && ![0, 2].includes(requiredType)) { | ||
| throw new Error(`Invalid type: unexpected type (${this.TYPE_NAME_TABLE[requiredType]})`); | ||
| } | ||
| function throwInvalidTypeError(rt, item) { | ||
| throw new Error(`Invalid type: expected (${rt.TYPE_NAME_TABLE[requiredType]}), received ${rt.TYPE_NAME_TABLE[rt.getTypeName(item)]}`); | ||
| } | ||
| return sortedArray.sort((a, b) => { | ||
| const exprA = interpreter.visit(exprefNode, a); | ||
| const exprB = interpreter.visit(exprefNode, b); | ||
| if (this.getTypeName(exprA) !== requiredType) { | ||
| throwInvalidTypeError(this, exprA); | ||
| } else if (this.getTypeName(exprB) !== requiredType) { | ||
| throwInvalidTypeError(this, exprB); | ||
| } | ||
| if (requiredType === 2) { | ||
| return Text.comparer(exprA, exprB); | ||
| } | ||
| return exprA - exprB; | ||
| }); | ||
| }; | ||
| functionStartsWith = ([searchable, searchStr]) => { | ||
| return searchable.startsWith(searchStr); | ||
| }; | ||
| functionSum = ([inputValue]) => { | ||
| return inputValue.reduce((x, y) => x + y, 0); | ||
| }; | ||
| functionToArray = ([inputValue]) => { | ||
| if (this.getTypeName(inputValue) === 3) { | ||
| return inputValue; | ||
| } | ||
| return [inputValue]; | ||
| }; | ||
| functionToNumber = ([inputValue]) => { | ||
| const typeName = this.getTypeName(inputValue); | ||
| let convertedValue; | ||
| if (typeName === 0) { | ||
| return inputValue; | ||
| } | ||
| if (typeName === 2) { | ||
| convertedValue = +inputValue; | ||
| if (!isNaN(convertedValue)) { | ||
| return convertedValue; | ||
| } | ||
| } | ||
| return null; | ||
| }; | ||
| functionToString = ([inputValue]) => { | ||
| if (this.getTypeName(inputValue) === 2) { | ||
| return inputValue; | ||
| } | ||
| return JSON.stringify(inputValue); | ||
| }; | ||
| functionTrim = this.createTrimFunction(trim); | ||
| functionTrimLeft = this.createTrimFunction(trimLeft); | ||
| functionTrimRight = this.createTrimFunction(trimRight); | ||
| createTrimFunction(trimFn) { | ||
| return (resolvedArgs) => { | ||
| const subject = resolvedArgs[0]; | ||
| const chars = resolvedArgs.length > 1 ? resolvedArgs[1] : undefined; | ||
| return trimFn(subject, chars); | ||
| }; | ||
| } | ||
| functionType = ([inputValue]) => { | ||
| switch (this.getTypeName(inputValue)) { | ||
| case 0: | ||
| return "number"; | ||
| case 2: | ||
| return "string"; | ||
| case 3: | ||
| return "array"; | ||
| case 4: | ||
| return "object"; | ||
| case 5: | ||
| return "boolean"; | ||
| case 7: | ||
| return "null"; | ||
| default: | ||
| throw new Error("invalid-type"); | ||
| } | ||
| }; | ||
| functionZip = (array) => { | ||
| const length = Math.min(...array.map((arr) => arr.length)); | ||
| const result = Array(length).fill(null).map((_, index) => array.map((arr) => arr[index])); | ||
| return result; | ||
| }; | ||
| }; | ||
| var ScopeChain = class _ScopeChain { | ||
| inner = undefined; | ||
| data = {}; | ||
| get currentScopeData() { | ||
| return this.data; | ||
| } | ||
| withScope(data) { | ||
| const outer = new _ScopeChain; | ||
| outer.inner = this; | ||
| outer.data = data; | ||
| return outer; | ||
| } | ||
| getValue(identifier) { | ||
| if (Object.prototype.hasOwnProperty.call(this.data, identifier)) { | ||
| return this.data[identifier]; | ||
| } | ||
| if (this.inner) { | ||
| return this.inner.getValue(identifier); | ||
| } | ||
| return null; | ||
| } | ||
| }; | ||
| var emptyScopeChain = new ScopeChain; | ||
| var TreeInterpreter = class _TreeInterpreter { | ||
| runtime; | ||
| _rootValue = null; | ||
| _scope; | ||
| constructor() { | ||
| this.runtime = new Runtime(this); | ||
| this._scope = new ScopeChain; | ||
| } | ||
| withScope(scope) { | ||
| const interpreter = new _TreeInterpreter; | ||
| interpreter.runtime._functionTable = this.runtime._functionTable; | ||
| interpreter._rootValue = this._rootValue; | ||
| interpreter._scope = this._scope.withScope(scope); | ||
| return interpreter; | ||
| } | ||
| search(node, value) { | ||
| this._rootValue = value; | ||
| this._scope = emptyScopeChain; | ||
| return this.visit(node, value); | ||
| } | ||
| visit(node, value) { | ||
| switch (node.type) { | ||
| case "Ternary": { | ||
| const condition = this.visit(node.condition, value); | ||
| if (!isFalse(condition)) { | ||
| return this.visit(node.trueExpr, value); | ||
| } | ||
| return this.visit(node.falseExpr, value); | ||
| } | ||
| case "Field": | ||
| const identifier = node.name; | ||
| if (value === null || typeof value !== "object" || Array.isArray(value)) { | ||
| return null; | ||
| } | ||
| return value[identifier] ?? null; | ||
| case "LetExpression": { | ||
| const { bindings, expression } = node; | ||
| let scope = {}; | ||
| bindings.forEach((binding) => { | ||
| const reference = this.visit(binding, value); | ||
| scope = { | ||
| ...scope, | ||
| ...reference | ||
| }; | ||
| }); | ||
| return this.withScope(scope).visit(expression, value); | ||
| } | ||
| case "Binding": { | ||
| const { variable, reference } = node; | ||
| const result = this.visit(reference, value); | ||
| return { [variable]: result }; | ||
| } | ||
| case "Variable": { | ||
| const variable = node.name; | ||
| if (!this._scope.getValue(variable) && !Object.prototype.hasOwnProperty.call(this._scope.currentScopeData, variable)) { | ||
| throw new Error(`Error referencing undefined variable ${variable}`); | ||
| } | ||
| return this._scope.getValue(variable); | ||
| } | ||
| case "IndexExpression": | ||
| return this.visit(node.right, this.visit(node.left, value)); | ||
| case "Subexpression": { | ||
| const result = this.visit(node.left, value); | ||
| return result != null ? this.visit(node.right, result) ?? null : null; | ||
| } | ||
| case "Index": { | ||
| if (!Array.isArray(value)) { | ||
| return null; | ||
| } | ||
| const index = node.value < 0 ? value.length + node.value : node.value; | ||
| return value[index] ?? null; | ||
| } | ||
| case "Slice": { | ||
| if (!Array.isArray(value) && typeof value !== "string") { | ||
| return null; | ||
| } | ||
| const { start, stop, step } = this.computeSliceParams(value.length, node); | ||
| if (typeof value === "string") { | ||
| const chars = [...value]; | ||
| const sliced = this.slice(chars, start, stop, step); | ||
| return sliced.join(""); | ||
| } else { | ||
| return this.slice(value, start, stop, step); | ||
| } | ||
| } | ||
| case "Projection": { | ||
| const { left, right } = node; | ||
| let allowString = false; | ||
| if (left.type === "IndexExpression" && left.right.type === "Slice") { | ||
| allowString = true; | ||
| } | ||
| const base = this.visit(left, value); | ||
| if (allowString && typeof base === "string") { | ||
| return this.visit(right, base); | ||
| } | ||
| if (!Array.isArray(base)) { | ||
| return null; | ||
| } | ||
| const collected = []; | ||
| for (const elem of base) { | ||
| const current = this.visit(right, elem); | ||
| if (current !== null) { | ||
| collected.push(current); | ||
| } | ||
| } | ||
| return collected; | ||
| } | ||
| case "ValueProjection": { | ||
| const { left, right } = node; | ||
| const base = this.visit(left, value); | ||
| if (base === null || typeof base !== "object" || Array.isArray(base)) { | ||
| return null; | ||
| } | ||
| const collected = []; | ||
| const values = Object.values(base); | ||
| for (const elem of values) { | ||
| const current = this.visit(right, elem); | ||
| if (current !== null) { | ||
| collected.push(current); | ||
| } | ||
| } | ||
| return collected; | ||
| } | ||
| case "FilterProjection": { | ||
| const { left, right, condition } = node; | ||
| const base = this.visit(left, value); | ||
| if (!Array.isArray(base)) { | ||
| return null; | ||
| } | ||
| const results = []; | ||
| for (const elem of base) { | ||
| const matched = this.visit(condition, elem); | ||
| if (isFalse(matched)) { | ||
| continue; | ||
| } | ||
| const result = this.visit(right, elem); | ||
| if (result !== null) { | ||
| results.push(result); | ||
| } | ||
| } | ||
| return results; | ||
| } | ||
| case "Arithmetic": { | ||
| const first = this.visit(node.left, value); | ||
| const second = this.visit(node.right, value); | ||
| switch (node.operator) { | ||
| case "Plus": | ||
| return add(first, second); | ||
| case "Minus": | ||
| return sub(first, second); | ||
| case "Multiply": | ||
| case "Star": | ||
| return mul(first, second); | ||
| case "Divide": | ||
| return divide(first, second); | ||
| case "Modulo": | ||
| return mod(first, second); | ||
| case "Div": | ||
| return div(first, second); | ||
| default: | ||
| throw new Error(`Syntax error: unknown arithmetic operator: ${node.operator}`); | ||
| } | ||
| } | ||
| case "Unary": { | ||
| const operand = this.visit(node.operand, value); | ||
| switch (node.operator) { | ||
| case "Plus": | ||
| ensureNumbers(operand); | ||
| return operand; | ||
| case "Minus": | ||
| ensureNumbers(operand); | ||
| return -operand; | ||
| default: | ||
| throw new Error(`Syntax error: unknown arithmetic operator: ${node.operator}`); | ||
| } | ||
| } | ||
| case "Comparator": { | ||
| const first = this.visit(node.left, value); | ||
| const second = this.visit(node.right, value); | ||
| switch (node.name) { | ||
| case "EQ": | ||
| return strictDeepEqual(first, second); | ||
| case "NE": | ||
| return !strictDeepEqual(first, second); | ||
| } | ||
| if (typeof first !== "number" || typeof second !== "number") { | ||
| return null; | ||
| } | ||
| switch (node.name) { | ||
| case "GT": | ||
| return first > second; | ||
| case "GTE": | ||
| return first >= second; | ||
| case "LT": | ||
| return first < second; | ||
| case "LTE": | ||
| return first <= second; | ||
| } | ||
| } | ||
| case "Flatten": { | ||
| const original = this.visit(node.child, value); | ||
| return Array.isArray(original) ? original.flat() : null; | ||
| } | ||
| case "Root": | ||
| return this._rootValue; | ||
| case "MultiSelectList": { | ||
| const collected = []; | ||
| for (const child of node.children) { | ||
| collected.push(this.visit(child, value)); | ||
| } | ||
| return collected; | ||
| } | ||
| case "MultiSelectHash": { | ||
| const collected = {}; | ||
| for (const child of node.children) { | ||
| collected[child.name] = this.visit(child.value, value); | ||
| } | ||
| return collected; | ||
| } | ||
| case "OrExpression": { | ||
| const result = this.visit(node.left, value); | ||
| if (isFalse(result)) { | ||
| return this.visit(node.right, value); | ||
| } | ||
| return result; | ||
| } | ||
| case "AndExpression": { | ||
| const result = this.visit(node.left, value); | ||
| if (isFalse(result)) { | ||
| return result; | ||
| } | ||
| return this.visit(node.right, value); | ||
| } | ||
| case "NotExpression": | ||
| return isFalse(this.visit(node.child, value)); | ||
| case "Literal": | ||
| return node.value; | ||
| case "Pipe": | ||
| return this.visit(node.right, this.visit(node.left, value)); | ||
| case "Function": { | ||
| const args = []; | ||
| for (const child of node.children) { | ||
| args.push(this.visit(child, value)); | ||
| } | ||
| return this.runtime.callFunction(node.name, args); | ||
| } | ||
| case "ExpressionReference": | ||
| return { | ||
| expref: true, | ||
| ...node.child | ||
| }; | ||
| case "Current": | ||
| case "Identity": | ||
| return value; | ||
| } | ||
| } | ||
| computeSliceParams(arrayLength, sliceNode) { | ||
| let { start, stop, step } = sliceNode; | ||
| if (step === null) { | ||
| step = 1; | ||
| } else if (step === 0) { | ||
| const error = new Error("Invalid value: slice step cannot be 0"); | ||
| error.name = "RuntimeError"; | ||
| throw error; | ||
| } | ||
| start = start === null ? step < 0 ? arrayLength - 1 : 0 : this.capSliceRange(arrayLength, start, step); | ||
| stop = stop === null ? step < 0 ? -1 : arrayLength : this.capSliceRange(arrayLength, stop, step); | ||
| return { start, stop, step }; | ||
| } | ||
| capSliceRange(arrayLength, actualValue, step) { | ||
| let nextActualValue = actualValue; | ||
| if (nextActualValue < 0) { | ||
| nextActualValue += arrayLength; | ||
| if (nextActualValue < 0) { | ||
| nextActualValue = step < 0 ? -1 : 0; | ||
| } | ||
| } else if (nextActualValue >= arrayLength) { | ||
| nextActualValue = step < 0 ? arrayLength - 1 : arrayLength; | ||
| } | ||
| return nextActualValue; | ||
| } | ||
| slice(collection, start, end, step) { | ||
| const result = []; | ||
| if (step > 0) { | ||
| for (let i = start;i < end; i += step) { | ||
| result.push(collection[i]); | ||
| } | ||
| } else { | ||
| for (let i = start;i > end; i += step) { | ||
| result.push(collection[i]); | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| }; | ||
| var TreeInterpreterInstance = new TreeInterpreter; | ||
| var TreeInterpreter_default = TreeInterpreterInstance; | ||
| var TYPE_ANY = 1; | ||
| var TYPE_ARRAY = 3; | ||
| var TYPE_ARRAY_ARRAY = 11; | ||
| var TYPE_ARRAY_NUMBER = 8; | ||
| var TYPE_ARRAY_OBJECT = 10; | ||
| var TYPE_ARRAY_STRING = 9; | ||
| var TYPE_BOOLEAN = 5; | ||
| var TYPE_EXPREF = 6; | ||
| var TYPE_NULL = 7; | ||
| var TYPE_NUMBER = 0; | ||
| var TYPE_OBJECT = 4; | ||
| var TYPE_STRING = 2; | ||
| function compile(expression, options) { | ||
| const nodeTree = Parser_default.parse(expression, options); | ||
| return nodeTree; | ||
| } | ||
| function tokenize(expression, options) { | ||
| return Lexer_default.tokenize(expression, options); | ||
| } | ||
| var registerFunction = (functionName, customFunction, signature, options) => { | ||
| TreeInterpreter_default.runtime.registerFunction(functionName, customFunction, signature, options); | ||
| }; | ||
| var register = (name, customFunction, signature, options) => { | ||
| return TreeInterpreter_default.runtime.register(name, customFunction, signature, options); | ||
| }; | ||
| var unregisterFunction = (name) => { | ||
| return TreeInterpreter_default.runtime.unregister(name); | ||
| }; | ||
| var isRegistered = (name) => { | ||
| return TreeInterpreter_default.runtime.isRegistered(name); | ||
| }; | ||
| var getRegisteredFunctions = () => { | ||
| return TreeInterpreter_default.runtime.getRegistered(); | ||
| }; | ||
| var getCustomFunctions = () => { | ||
| return TreeInterpreter_default.runtime.getCustomFunctions(); | ||
| }; | ||
| var clearCustomFunctions = () => { | ||
| TreeInterpreter_default.runtime.clearCustomFunctions(); | ||
| }; | ||
| function search(data, expression, options) { | ||
| const nodeTree = Parser_default.parse(expression, options); | ||
| return TreeInterpreter_default.search(nodeTree, data); | ||
| } | ||
| function Scope() { | ||
| return new ScopeChain; | ||
| } | ||
| var TreeInterpreter2 = TreeInterpreter_default; | ||
| var jmespath = { | ||
| compile, | ||
| registerFunction, | ||
| register, | ||
| unregisterFunction, | ||
| isRegistered, | ||
| getRegisteredFunctions, | ||
| getCustomFunctions, | ||
| clearCustomFunctions, | ||
| search, | ||
| tokenize, | ||
| TreeInterpreter: TreeInterpreter2, | ||
| TYPE_ANY, | ||
| TYPE_ARRAY_NUMBER, | ||
| TYPE_ARRAY_STRING, | ||
| TYPE_ARRAY, | ||
| TYPE_BOOLEAN, | ||
| TYPE_EXPREF, | ||
| TYPE_NULL, | ||
| TYPE_NUMBER, | ||
| TYPE_OBJECT, | ||
| TYPE_STRING | ||
| }; | ||
| export { | ||
| unregisterFunction, | ||
| tokenize, | ||
| search, | ||
| registerFunction, | ||
| register, | ||
| jmespath, | ||
| isRegistered, | ||
| getRegisteredFunctions, | ||
| getCustomFunctions, | ||
| jmespath as default, | ||
| compile, | ||
| clearCustomFunctions, | ||
| TreeInterpreter2 as TreeInterpreter, | ||
| TYPE_STRING, | ||
| TYPE_OBJECT, | ||
| TYPE_NUMBER, | ||
| TYPE_NULL, | ||
| TYPE_EXPREF, | ||
| TYPE_BOOLEAN, | ||
| TYPE_ARRAY_STRING, | ||
| TYPE_ARRAY_OBJECT, | ||
| TYPE_ARRAY_NUMBER, | ||
| TYPE_ARRAY_ARRAY, | ||
| TYPE_ARRAY, | ||
| TYPE_ANY, | ||
| Scope | ||
| }; | ||
| //# debugId=FA9FB28BF9A093C864756E2164756E21 |
| import"./packager-tool-0v6na3yp.js"; | ||
| // ../../node_modules/open/index.js | ||
| import process7 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 process 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 (process.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 = process.env.__IS_WSL_TEST__ ? isWsl : isWsl(); | ||
| // ../../node_modules/powershell-utils/index.js | ||
| import process2 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 = () => `${process2.env.SYSTEMROOT || process2.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 process5 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 process3 from "node:process"; | ||
| import { execFile as execFile3 } from "node:child_process"; | ||
| var execFileAsync = promisify3(execFile3); | ||
| async function defaultBrowserId() { | ||
| if (process3.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 process4 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 (process4.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 (process5.platform === "darwin") { | ||
| const id = await defaultBrowserId(); | ||
| const name = await bundleName(id); | ||
| return { name, id }; | ||
| } | ||
| if (process5.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 (process5.platform === "win32") { | ||
| return defaultBrowser(); | ||
| } | ||
| throw new Error("Only macOS, Linux, and Windows are supported"); | ||
| } | ||
| // ../../node_modules/is-in-ssh/index.js | ||
| import process6 from "node:process"; | ||
| var isInSsh = Boolean(process6.env.SSH_CONNECTION || process6.env.SSH_CLIENT || process6.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 } = process7; | ||
| 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 = process7.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 | ||
| }); | ||
| }; | ||
| var openApp = (name, options) => { | ||
| if (typeof name !== "string" && !Array.isArray(name)) { | ||
| throw new TypeError("Expected a valid `name`"); | ||
| } | ||
| const { arguments: appArguments = [] } = options ?? {}; | ||
| if (appArguments !== undefined && appArguments !== null && !Array.isArray(appArguments)) { | ||
| throw new TypeError("Expected `appArguments` as Array type"); | ||
| } | ||
| return baseOpen({ | ||
| ...options, | ||
| app: { | ||
| name, | ||
| arguments: appArguments | ||
| } | ||
| }); | ||
| }; | ||
| 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; | ||
| export { | ||
| openApp, | ||
| open_default as default, | ||
| apps | ||
| }; | ||
| //# debugId=75EAFE8AF98B350C64756E2164756E21 |
Sorry, the diff of this file is too big to display
| import { | ||
| catchError, | ||
| getFileSystem | ||
| } from "./packager-tool-7eva0peq.js"; | ||
| import { | ||
| AUTH_CANCELLED_ERROR_CODE, | ||
| AUTH_TIMEOUT_ERROR_CODE, | ||
| DEFAULT_AUTH_TIMEOUT_MS | ||
| } from "./packager-tool-5arsyj36.js"; | ||
| import { | ||
| __require | ||
| } from "./packager-tool-0v6na3yp.js"; | ||
| // ../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 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((resolve, 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(); | ||
| resolve(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); | ||
| }); | ||
| }); | ||
| }; | ||
| // ../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=A8160D47DD46BDEC64756E2164756E21 |
| // ../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_TIMEOUT_ERROR_CODE = "EAUTHTIMEOUT"; | ||
| var AUTH_CANCELLED_ERROR_CODE = "EAUTHCANCELLED"; | ||
| export { UIPATH_HOME_DIR, AUTH_FILENAME, DEFAULT_BASE_URL, DEFAULT_AUTH_TIMEOUT_MS, AUTH_TIMEOUT_ERROR_CODE, AUTH_CANCELLED_ERROR_CODE }; | ||
| //# debugId=E98AE5255EE78AC164756E2164756E21 |
| import { | ||
| __require | ||
| } from "./packager-tool-0v6na3yp.js"; | ||
| // ../filesystem/src/node.ts | ||
| import { randomUUID } from "node:crypto"; | ||
| import { existsSync } from "node:fs"; | ||
| import * as fs from "node:fs/promises"; | ||
| import * as os from "node:os"; | ||
| import * as path from "node:path"; | ||
| 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: path.join, | ||
| resolve: path.resolve, | ||
| relative: path.relative, | ||
| dirname: path.dirname, | ||
| isAbsolute: path.isAbsolute, | ||
| basename: path.basename | ||
| }; | ||
| env = { | ||
| cwd: process.cwd, | ||
| homedir: os.homedir, | ||
| tmpdir: os.tmpdir, | ||
| getenv: (key) => process.env[key] | ||
| }; | ||
| utils = { | ||
| open: async (url) => { | ||
| const { default: open } = await import("./index-w03qc9m8.js"); | ||
| await open(url); | ||
| } | ||
| }; | ||
| async readFile(path2, options) { | ||
| try { | ||
| if (options) { | ||
| return await fs.readFile(path2, "utf-8"); | ||
| } | ||
| return await fs.readFile(path2); | ||
| } catch (error) { | ||
| if (this.isEnoent(error)) | ||
| return null; | ||
| throw error; | ||
| } | ||
| } | ||
| async writeFile(filePath, data) { | ||
| const dir = path.dirname(filePath); | ||
| if (dir) { | ||
| await fs.mkdir(dir, { recursive: true }); | ||
| } | ||
| await fs.writeFile(filePath, data); | ||
| } | ||
| async appendFile(filePath, data) { | ||
| const dir = path.dirname(filePath); | ||
| if (dir) { | ||
| await fs.mkdir(dir, { recursive: true }); | ||
| } | ||
| await fs.appendFile(filePath, data); | ||
| } | ||
| async readdir(dirPath) { | ||
| try { | ||
| return await fs.readdir(dirPath); | ||
| } catch (error) { | ||
| if (this.isEnoent(error)) | ||
| return []; | ||
| throw error; | ||
| } | ||
| } | ||
| async stat(filePath) { | ||
| try { | ||
| const stats = await fs.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 fs.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 fs.writeFile(lockFile, ownerId, { flag: "wx" }); | ||
| return this.createLockRelease(lockFile, ownerId); | ||
| } catch (error) { | ||
| if (!this.hasErrnoCode(error, "EEXIST")) { | ||
| throw error; | ||
| } | ||
| const stats = await fs.stat(lockFile).catch(() => null); | ||
| if (stats && Date.now() - stats.mtimeMs > LOCK_STALE_MS) { | ||
| const reclaimed = await fs.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 = path.resolve(lockPath); | ||
| const fullReal = await fs.realpath(absolute).catch(() => null); | ||
| if (fullReal) | ||
| return fullReal; | ||
| const parent = path.dirname(absolute); | ||
| const base = path.basename(absolute); | ||
| const canonicalParent = await fs.realpath(parent).catch(() => parent); | ||
| return path.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 fs.readFile(lockFile, "utf-8").catch(() => null); | ||
| if (stopped) | ||
| return; | ||
| if (current !== ownerId) { | ||
| stopped = true; | ||
| return; | ||
| } | ||
| const now = Date.now() / 1000; | ||
| await fs.utimes(lockFile, now, now).catch(() => {}); | ||
| scheduleNextHeartbeat(); | ||
| }; | ||
| scheduleNextHeartbeat(); | ||
| let released = false; | ||
| return async () => { | ||
| if (released) | ||
| return; | ||
| released = true; | ||
| stopHeartbeat(); | ||
| const current = await fs.readFile(lockFile, "utf-8").catch(() => null); | ||
| if (current === ownerId) { | ||
| await fs.rm(lockFile, { force: true }); | ||
| } | ||
| }; | ||
| } | ||
| async rm(filePath) { | ||
| await fs.rm(filePath, { recursive: true, force: true }); | ||
| } | ||
| async rename(oldPath, newPath) { | ||
| await fs.rename(oldPath, newPath); | ||
| } | ||
| async realpath(filePath) { | ||
| try { | ||
| return await fs.realpath(filePath); | ||
| } catch (error) { | ||
| if (this.isEnoent(error)) | ||
| return filePath; | ||
| throw error; | ||
| } | ||
| } | ||
| async getTempDir() { | ||
| return await fs.mkdtemp(path.join(os.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 = path.join(sourcePath, entry); | ||
| const destEntry = 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 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 | ||
| ]); | ||
| } | ||
| export { getFileSystem, catchError }; | ||
| //# debugId=7C969342331D7A5864756E2164756E21 |
| import { | ||
| catchError | ||
| } from "./packager-tool-r9n45rjm.js"; | ||
| import { | ||
| getFileSystem | ||
| } from "./packager-tool-7eva0peq.js"; | ||
| // src/services/solution-init-service.ts | ||
| var AGENTS_FILENAME = "AGENTS.md"; | ||
| var CLAUDE_FILENAME = "CLAUDE.md"; | ||
| class SolutionInitError extends Error { | ||
| stage; | ||
| constructor(stage, cause) { | ||
| super(cause instanceof Error ? cause.message : String(cause), { | ||
| cause | ||
| }); | ||
| this.stage = stage; | ||
| this.name = "SolutionInitError"; | ||
| } | ||
| } | ||
| async function solutionInitAsync(solutionName, options = {}) { | ||
| const fs = getFileSystem(); | ||
| const base = fs.path.basename(solutionName); | ||
| const hasExtension = base.lastIndexOf(".") > 0; | ||
| const nameWithoutExt = hasExtension ? base.slice(0, base.lastIndexOf(".")) : base; | ||
| const fileName = hasExtension ? base : `${base}.uipx`; | ||
| const parentDir = fs.path.resolve(options.cwd ?? ".", fs.path.dirname(solutionName), nameWithoutExt); | ||
| const [mkdirError] = await catchError(fs.mkdir(parentDir)); | ||
| if (mkdirError) { | ||
| throw new SolutionInitError("directory", mkdirError); | ||
| } | ||
| let agentsPath; | ||
| let claudePath; | ||
| if (options.briefingContent !== undefined) { | ||
| agentsPath = fs.path.join(parentDir, AGENTS_FILENAME); | ||
| claudePath = fs.path.join(parentDir, CLAUDE_FILENAME); | ||
| const [agentsError] = await catchError(fs.writeFile(agentsPath, options.briefingContent)); | ||
| if (agentsError) { | ||
| throw new SolutionInitError("briefing", agentsError); | ||
| } | ||
| const [claudeError] = await catchError(fs.writeFile(claudePath, options.briefingContent)); | ||
| if (claudeError) { | ||
| throw new SolutionInitError("briefing", claudeError); | ||
| } | ||
| } | ||
| const filePath = fs.path.join(parentDir, fileName); | ||
| const solution = { | ||
| DocVersion: "1.0.0", | ||
| StudioMinVersion: "2025.10.0", | ||
| SolutionId: crypto.randomUUID(), | ||
| Projects: [] | ||
| }; | ||
| const [manifestError] = await catchError(fs.writeFile(filePath, `${JSON.stringify(solution, null, 2)} | ||
| `)); | ||
| if (manifestError) { | ||
| throw new SolutionInitError("manifest", manifestError); | ||
| } | ||
| return { | ||
| solutionFile: filePath, | ||
| solutionDir: parentDir, | ||
| solutionName: nameWithoutExt, | ||
| agentsPath, | ||
| claudePath | ||
| }; | ||
| } | ||
| export { SolutionInitError, solutionInitAsync }; | ||
| //# debugId=533229F41EC9DD9664756E2164756E21 |
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
| import { | ||
| Configuration, | ||
| Configuration1 as Configuration2, | ||
| PackagesApi, | ||
| PipelinesApi, | ||
| resolveFeedScope | ||
| } from "./packager-tool-arbagkf2.js"; | ||
| import { | ||
| PollOutcome, | ||
| catchError, | ||
| extractErrorDetails, | ||
| getSolutionAuthContext, | ||
| logger, | ||
| mapPollFailure, | ||
| pollUntil | ||
| } from "./packager-tool-r9n45rjm.js"; | ||
| import { | ||
| getFileSystem | ||
| } from "./packager-tool-7eva0peq.js"; | ||
| import { | ||
| strFromU8, | ||
| strToU8, | ||
| unzipSync, | ||
| zipSync | ||
| } from "./packager-tool-129wn232.js"; | ||
| // src/services/package-metadata-rewrite.ts | ||
| import { randomUUID } from "node:crypto"; | ||
| var SOLUTION_METADATA_ENTRY = "solutionMetadata.json"; | ||
| function isRecord(value) { | ||
| return typeof value === "object" && value !== null && !Array.isArray(value); | ||
| } | ||
| var requireValue = (value, flag) => { | ||
| const trimmed = value.trim(); | ||
| if (!trimmed) { | ||
| throw new Error(`${flag} cannot be empty.`); | ||
| } | ||
| return trimmed; | ||
| }; | ||
| function rewritePackageMetadata(archive, overrides) { | ||
| const entries = unzipSync(archive); | ||
| const metadataBytes = entries[SOLUTION_METADATA_ENTRY]; | ||
| if (!metadataBytes) { | ||
| throw new Error(`Package archive has no ${SOLUTION_METADATA_ENTRY} at its root, so its name and version cannot be rewritten. Only a .zip produced by 'uip solution pack' carries that file.`); | ||
| } | ||
| let parsed; | ||
| try { | ||
| parsed = JSON.parse(strFromU8(metadataBytes)); | ||
| } catch (err) { | ||
| throw new Error(`${SOLUTION_METADATA_ENTRY} in the package archive is not valid JSON: ${err instanceof Error ? err.message : String(err)}`); | ||
| } | ||
| if (!isRecord(parsed) || !isRecord(parsed.spec)) { | ||
| throw new Error(`${SOLUTION_METADATA_ENTRY} in the package archive has no 'spec' object, so its name and version cannot be rewritten.`); | ||
| } | ||
| const spec = parsed.spec; | ||
| const packageName = overrides.packageName === undefined ? String(spec.packageName ?? "") : requireValue(overrides.packageName, "--package-name"); | ||
| const packageVersion = overrides.packageVersion === undefined ? String(spec.packageVersion ?? "") : requireValue(overrides.packageVersion, "--package-version"); | ||
| const packageVersionKey = randomUUID(); | ||
| const rewritten = { | ||
| ...parsed, | ||
| spec: { ...spec, packageName, packageVersion, packageVersionKey } | ||
| }; | ||
| const zipInput = {}; | ||
| for (const [entryName, entryBytes] of Object.entries(entries)) { | ||
| const level = entryName.toLowerCase().endsWith(".nupkg") ? 0 : 6; | ||
| zipInput[entryName] = [entryBytes, { level }]; | ||
| } | ||
| zipInput[SOLUTION_METADATA_ENTRY] = [ | ||
| strToU8(JSON.stringify(rewritten)), | ||
| { level: 6 } | ||
| ]; | ||
| return { | ||
| archive: zipSync(zipInput), | ||
| packageName, | ||
| packageVersion, | ||
| packageVersionKey | ||
| }; | ||
| } | ||
| // src/services/publish-service.ts | ||
| var TERMINAL_STATES = new Set([ | ||
| "Ready", | ||
| "Active", | ||
| "Failed" | ||
| ]); | ||
| var VERSION_CONFLICT_PATTERNS = [ | ||
| /\balready exists\b/i, | ||
| /\bduplicate\b.*\bversion\b/i, | ||
| /\bversion\b.*\bduplicate\b/i, | ||
| /\bpackage[-\s]?version\b.*\bexists\b/i, | ||
| /\bversion[-\s]?exists\b/i, | ||
| /\bversion\b.*\balready exists\b/i | ||
| ]; | ||
| var isVersionConflictError = (message, details) => { | ||
| const errorText = `${message} ${details ?? ""}`; | ||
| return VERSION_CONFLICT_PATTERNS.some((pattern) => pattern.test(errorText)); | ||
| }; | ||
| var HTTP_STATUS_PATTERNS = [ | ||
| /^HTTP\s+(\d{3})(?::|\s|-|$)/i, | ||
| /["']httpStatus["']\s*:\s*(\d{3})\b/i, | ||
| /["']statusCode["']\s*:\s*(\d{3})\b/i, | ||
| /["']status["']\s*:\s*(\d{3})\b/i, | ||
| /\bhttpStatus\s*[:=]\s*(\d{3})\b/i, | ||
| /\bstatusCode\s*[:=]\s*(\d{3})\b/i | ||
| ]; | ||
| var ERROR_CODE_PATTERNS = [ | ||
| /["']errorCode["']\s*:\s*["']([^"']+)["']/i, | ||
| /["']errorCode["']\s*:\s*(\d+)\b/i, | ||
| /\berrorCode\s*[:=]\s*["']?([A-Za-z0-9_.-]+)["']?/i, | ||
| /["']code["']\s*:\s*["']([^"']+)["']/i, | ||
| /["']code["']\s*:\s*(\d+)\b/i | ||
| ]; | ||
| function extractFirstPatternValue(text, patterns) { | ||
| if (!text) | ||
| return; | ||
| for (const pattern of patterns) { | ||
| const match = pattern.exec(text); | ||
| if (match?.[1]) | ||
| return match[1]; | ||
| } | ||
| return; | ||
| } | ||
| function extractUploadHttpStatus(message, details) { | ||
| const rawStatus = extractFirstPatternValue(message, HTTP_STATUS_PATTERNS) ?? extractFirstPatternValue(details, HTTP_STATUS_PATTERNS); | ||
| if (!rawStatus) | ||
| return; | ||
| const status = Number(rawStatus); | ||
| return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined; | ||
| } | ||
| function extractUploadErrorCode(message, details) { | ||
| return extractFirstPatternValue(details, ERROR_CODE_PATTERNS) ?? extractFirstPatternValue(message, ERROR_CODE_PATTERNS); | ||
| } | ||
| function retryHintForUploadStatus(httpStatus) { | ||
| if (httpStatus === 400 || httpStatus === 409 || httpStatus === 422) { | ||
| return "RetryWillNotFix"; | ||
| } | ||
| if (httpStatus === 408 || httpStatus === 429 || httpStatus !== undefined && httpStatus >= 500 && httpStatus < 600) { | ||
| return "RetryLater"; | ||
| } | ||
| return; | ||
| } | ||
| function mergeUploadErrorContext(context, httpStatus, errorCode) { | ||
| if (!context && httpStatus === undefined && errorCode === undefined) { | ||
| return; | ||
| } | ||
| return { | ||
| ...context ?? {}, | ||
| ...httpStatus !== undefined ? { httpStatus } : {}, | ||
| ...errorCode !== undefined ? { errorCode } : {} | ||
| }; | ||
| } | ||
| async function publishSolutionAsync(packagePath, options = {}) { | ||
| const [authError, auth] = await catchError(getSolutionAuthContext({ | ||
| tenant: options.tenant, | ||
| loginValidity: options.loginValidity, | ||
| envFilePath: options.envFilePath | ||
| })); | ||
| if (authError) { | ||
| return { | ||
| ok: false, | ||
| reason: "auth_failed", | ||
| message: authError.message | ||
| }; | ||
| } | ||
| const fs = getFileSystem(); | ||
| const resolvedPath = fs.path.resolve(packagePath); | ||
| if (!await fs.exists(resolvedPath)) { | ||
| return { | ||
| ok: false, | ||
| reason: "file_not_found", | ||
| message: `File not found: ${resolvedPath}` | ||
| }; | ||
| } | ||
| if (!resolvedPath.endsWith(".zip")) { | ||
| const stats = await fs.stat(resolvedPath); | ||
| const isSolutionSource = stats?.isDirectory() === true || resolvedPath.endsWith(".uis") || resolvedPath.endsWith(".uipx"); | ||
| if (isSolutionSource) { | ||
| return { | ||
| ok: false, | ||
| reason: "not_packed", | ||
| message: `'${packagePath}' is a solution source, not a packed package. 'publish' uploads the .zip produced by 'solution pack'.`, | ||
| details: resolvedPath | ||
| }; | ||
| } | ||
| return { | ||
| ok: false, | ||
| reason: "not_a_zip", | ||
| message: `Invalid file type. Expected a .zip file, got: ${resolvedPath}` | ||
| }; | ||
| } | ||
| const [fileBufferError, readBuffer] = await catchError(fs.readFile(resolvedPath)); | ||
| if (fileBufferError) { | ||
| const { message } = await extractErrorDetails(fileBufferError); | ||
| return { | ||
| ok: false, | ||
| reason: "file_read_failed", | ||
| message, | ||
| details: resolvedPath | ||
| }; | ||
| } | ||
| if (!readBuffer) { | ||
| return { | ||
| ok: false, | ||
| reason: "file_read_failed", | ||
| message: `File is empty or unreadable: ${resolvedPath}`, | ||
| details: resolvedPath | ||
| }; | ||
| } | ||
| let fileBuffer = readBuffer; | ||
| if (options.packageName !== undefined || options.packageVersion !== undefined) { | ||
| const [rewriteError, rewritten] = await catchError(Promise.resolve().then(() => rewritePackageMetadata(new Uint8Array(fileBuffer), { | ||
| packageName: options.packageName, | ||
| packageVersion: options.packageVersion | ||
| }))); | ||
| if (rewriteError || !rewritten) { | ||
| return { | ||
| ok: false, | ||
| reason: "metadata_rewrite_failed", | ||
| message: rewriteError?.message ?? "Could not rewrite the package name/version.", | ||
| details: resolvedPath | ||
| }; | ||
| } | ||
| logger.info(`Publishing ${resolvedPath} as ${rewritten.packageName} ${rewritten.packageVersion} (package version key ${rewritten.packageVersionKey}); the file on disk is unchanged.`); | ||
| fileBuffer = rewritten.archive; | ||
| } | ||
| const [scopeError, scope] = await catchError(resolveFeedScope({ | ||
| personalWorkspace: options.personalWorkspace, | ||
| feed: options.feed, | ||
| tenant: options.tenant, | ||
| loginValidity: options.loginValidity, | ||
| envFilePath: options.envFilePath | ||
| })); | ||
| if (scopeError) { | ||
| return { | ||
| ok: false, | ||
| reason: options.feed !== undefined ? "feed_resolution_failed" : "personal_workspace_resolution_failed", | ||
| message: scopeError.message | ||
| }; | ||
| } | ||
| if (scope.kind !== "tenant") { | ||
| return publishToFeed(auth, fileBuffer, scope, options); | ||
| } | ||
| const configuration = new Configuration({ | ||
| basePath: auth.basePath, | ||
| accessToken: auth.accessToken | ||
| }); | ||
| const api = new PipelinesApi(configuration); | ||
| const [uploadError, uploadResult] = await catchError(api.pipelinesPackageUpload({ body: fileBuffer })); | ||
| if (uploadError) { | ||
| return mapUploadError(uploadError); | ||
| } | ||
| let packageVersionInfo = uploadResult; | ||
| if (options.wait) { | ||
| const pollResult = await pollUntil({ | ||
| fn: () => api.pipelinesGetPackageVersion({ | ||
| packageName: uploadResult.packageName, | ||
| packageVersion: uploadResult.packageVersion | ||
| }), | ||
| until: (result) => TERMINAL_STATES.has(result.state), | ||
| getStatus: (result) => result.state, | ||
| label: `publish ${uploadResult.packageName}:${uploadResult.packageVersion}`, | ||
| logPrefix: "publish", | ||
| timeoutMs: (options.timeout ?? 360) * 1000, | ||
| intervalMs: options.pollInterval ?? 5000, | ||
| signal: options.signal | ||
| }); | ||
| if (pollResult.outcome !== PollOutcome.Completed) { | ||
| const { reason, message } = mapPollFailure(pollResult, "Package publish"); | ||
| return { ok: false, reason, message }; | ||
| } | ||
| if (!pollResult.data) { | ||
| return { | ||
| ok: false, | ||
| reason: "poll_failed", | ||
| message: "Package publish did not return a final state." | ||
| }; | ||
| } | ||
| packageVersionInfo = pollResult.data; | ||
| if (packageVersionInfo.state === "Failed") { | ||
| return { | ||
| ok: false, | ||
| reason: "publish_failed", | ||
| message: `Package publish failed with state: ${packageVersionInfo.state}` | ||
| }; | ||
| } | ||
| } | ||
| return { | ||
| ok: true, | ||
| packageVersionKey: packageVersionInfo.key, | ||
| packageName: packageVersionInfo.packageName, | ||
| packageVersion: packageVersionInfo.packageVersion, | ||
| state: packageVersionInfo.state, | ||
| feedKind: "tenant" | ||
| }; | ||
| } | ||
| async function publishToFeed(auth, fileBuffer, scope, options) { | ||
| const config = new Configuration2({ | ||
| basePath: auth.basePath, | ||
| accessToken: auth.accessToken | ||
| }); | ||
| const api = new PackagesApi(config); | ||
| const [uploadError, packageVersionKey] = await catchError(api.packagesUpload({ | ||
| body: fileBuffer, | ||
| locationKey: scope.folderKey | ||
| })); | ||
| if (uploadError) { | ||
| return mapUploadError(uploadError); | ||
| } | ||
| const [getError, initialInfo] = await catchError(api.packagesGetVersion({ packageVersionKey })); | ||
| if (getError) { | ||
| logger.warn(`Package uploaded (key ${packageVersionKey}) but its metadata was not yet retrievable; PackageName/PackageVersion/State will be absent from output: ${getError.message}`); | ||
| } | ||
| let packageVersionInfo = getError ? undefined : initialInfo; | ||
| if (options.wait) { | ||
| const pollResult = await pollUntil({ | ||
| fn: () => api.packagesGetVersion({ packageVersionKey }), | ||
| until: (result) => TERMINAL_STATES.has(result.state), | ||
| getStatus: (result) => result.state, | ||
| label: `publish ${packageVersionInfo ? `${packageVersionInfo.packageName}:${packageVersionInfo.packageVersion}` : packageVersionKey}`, | ||
| logPrefix: "publish", | ||
| timeoutMs: (options.timeout ?? 360) * 1000, | ||
| intervalMs: options.pollInterval ?? 5000, | ||
| signal: options.signal | ||
| }); | ||
| if (pollResult.outcome !== PollOutcome.Completed) { | ||
| const { reason, message } = mapPollFailure(pollResult, "Package publish"); | ||
| return { ok: false, reason, message }; | ||
| } | ||
| if (!pollResult.data) { | ||
| return { | ||
| ok: false, | ||
| reason: "poll_failed", | ||
| message: "Package publish did not return a final state." | ||
| }; | ||
| } | ||
| packageVersionInfo = pollResult.data; | ||
| if (packageVersionInfo.state === "Failed") { | ||
| return { | ||
| ok: false, | ||
| reason: "publish_failed", | ||
| message: `Package publish failed with state: ${packageVersionInfo.state}` | ||
| }; | ||
| } | ||
| } | ||
| return { | ||
| ok: true, | ||
| packageVersionKey: packageVersionInfo?.key ?? packageVersionKey, | ||
| packageName: packageVersionInfo?.packageName, | ||
| packageVersion: packageVersionInfo?.packageVersion, | ||
| state: packageVersionInfo?.state, | ||
| feedKind: scope.kind | ||
| }; | ||
| } | ||
| async function mapUploadError(uploadError) { | ||
| const { message, details, context, retry } = await extractErrorDetails(uploadError); | ||
| const httpStatus = context?.httpStatus ?? extractUploadHttpStatus(message, details); | ||
| const errorCode = context?.errorCode ?? extractUploadErrorCode(message, details); | ||
| const resolvedContext = mergeUploadErrorContext(context, httpStatus, errorCode); | ||
| const resolvedRetry = context?.httpStatus === undefined ? retryHintForUploadStatus(httpStatus) ?? retry : retry; | ||
| const fetchCause = uploadError instanceof Error && uploadError.name === "FetchError" && uploadError.cause instanceof Error ? uploadError.cause : null; | ||
| const surfacedMessage = fetchCause ? `Failed to upload package: ${fetchCause.message}` : message; | ||
| let reason = "upload_failed"; | ||
| if (isVersionConflictError(message, details)) { | ||
| reason = "upload_version_conflict"; | ||
| } else if (fetchCause || httpStatus !== undefined && httpStatus >= 500) { | ||
| reason = "upload_network"; | ||
| } else if (httpStatus === 400 || httpStatus === 422) { | ||
| reason = "upload_rejected"; | ||
| } | ||
| return { | ||
| ok: false, | ||
| reason, | ||
| message: surfacedMessage, | ||
| details, | ||
| errorCode, | ||
| retry: resolvedRetry, | ||
| context: resolvedContext | ||
| }; | ||
| } | ||
| export { publishSolutionAsync }; | ||
| //# debugId=2D4FA6DDA83F407764756E2164756E21 |
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
Sorry, the diff of this file is too big to display
+5
-5
@@ -7,8 +7,8 @@ import { | ||
| uninstallDeploymentAsync | ||
| } from "./packager-tool-br2aa2fh.js"; | ||
| import"./packager-tool-gkwmyc48.js"; | ||
| import"./packager-tool-y4wacqkp.js"; | ||
| } from "./packager-tool-n49qbf8m.js"; | ||
| import"./packager-tool-arbagkf2.js"; | ||
| import"./packager-tool-r9n45rjm.js"; | ||
| import"./packager-tool-9qecd4wb.js"; | ||
| import"./packager-tool-q90kqh83.js"; | ||
| import"./packager-tool-1ps2qeqg.js"; | ||
| import"./packager-tool-7eva0peq.js"; | ||
| import"./packager-tool-5arsyj36.js"; | ||
| import"./packager-tool-129wn232.js"; | ||
@@ -15,0 +15,0 @@ import"./packager-tool-0v6na3yp.js"; |
+11
-11
@@ -5,17 +5,17 @@ #!/usr/bin/env bun | ||
| registerCommands | ||
| } from "./packager-tool-gnmkvkz3.js"; | ||
| import"./packager-tool-br2aa2fh.js"; | ||
| import"./packager-tool-kfzzznjr.js"; | ||
| import"./packager-tool-7efxm815.js"; | ||
| import"./packager-tool-sdhdmkt8.js"; | ||
| import"./packager-tool-rdxaysxe.js"; | ||
| import"./packager-tool-gkwmyc48.js"; | ||
| import"./packager-tool-37g19zk3.js"; | ||
| } from "./packager-tool-9x8dbxbn.js"; | ||
| import"./packager-tool-n49qbf8m.js"; | ||
| import"./packager-tool-85x8cje1.js"; | ||
| import"./packager-tool-y35nbbkm.js"; | ||
| import"./packager-tool-9vehmnke.js"; | ||
| import"./packager-tool-c84z58bt.js"; | ||
| import"./packager-tool-arbagkf2.js"; | ||
| import"./packager-tool-ngh4qwjv.js"; | ||
| import"./packager-tool-vpr77gre.js"; | ||
| import { | ||
| Command | ||
| } from "./packager-tool-y4wacqkp.js"; | ||
| } from "./packager-tool-r9n45rjm.js"; | ||
| import"./packager-tool-9qecd4wb.js"; | ||
| import"./packager-tool-q90kqh83.js"; | ||
| import"./packager-tool-1ps2qeqg.js"; | ||
| import"./packager-tool-7eva0peq.js"; | ||
| import"./packager-tool-5arsyj36.js"; | ||
| import"./packager-tool-129wn232.js"; | ||
@@ -22,0 +22,0 @@ import"./packager-tool-0v6na3yp.js"; |
+5
-5
| import { | ||
| SolutionInitError, | ||
| solutionInitAsync | ||
| } from "./packager-tool-kfzzznjr.js"; | ||
| } from "./packager-tool-85x8cje1.js"; | ||
| import { | ||
| addProjectArtifactsToSolutionAsync | ||
| } from "./packager-tool-37g19zk3.js"; | ||
| } from "./packager-tool-ngh4qwjv.js"; | ||
| import"./packager-tool-vpr77gre.js"; | ||
| import"./packager-tool-y4wacqkp.js"; | ||
| import"./packager-tool-r9n45rjm.js"; | ||
| import"./packager-tool-9qecd4wb.js"; | ||
| import"./packager-tool-q90kqh83.js"; | ||
| import"./packager-tool-1ps2qeqg.js"; | ||
| import"./packager-tool-7eva0peq.js"; | ||
| import"./packager-tool-5arsyj36.js"; | ||
| import"./packager-tool-129wn232.js"; | ||
@@ -14,0 +14,0 @@ import"./packager-tool-0v6na3yp.js"; |
+8
-20
| import { | ||
| PackCommandService | ||
| } from "./packager-tool-7efxm815.js"; | ||
| import"./packager-tool-sdhdmkt8.js"; | ||
| import"./packager-tool-37g19zk3.js"; | ||
| packSolutionAsync | ||
| } from "./packager-tool-y35nbbkm.js"; | ||
| import"./packager-tool-9vehmnke.js"; | ||
| import"./packager-tool-ngh4qwjv.js"; | ||
| import"./packager-tool-vpr77gre.js"; | ||
| import"./packager-tool-y4wacqkp.js"; | ||
| import"./packager-tool-r9n45rjm.js"; | ||
| import"./packager-tool-9qecd4wb.js"; | ||
| import"./packager-tool-q90kqh83.js"; | ||
| import"./packager-tool-1ps2qeqg.js"; | ||
| import"./packager-tool-7eva0peq.js"; | ||
| import"./packager-tool-5arsyj36.js"; | ||
| import"./packager-tool-129wn232.js"; | ||
| import"./packager-tool-0v6na3yp.js"; | ||
| // src/services/pack-service.ts | ||
| async function packSolutionAsync(solutionPath, options) { | ||
| const service = new PackCommandService; | ||
| const result = await service.executeAsync(solutionPath, options); | ||
| return { | ||
| ok: result.errorCode === "SUCCESS" /* Success */, | ||
| errorCode: result.errorCode, | ||
| message: result.message ?? "", | ||
| packages: result.packages | ||
| }; | ||
| } | ||
| export { | ||
@@ -29,2 +17,2 @@ packSolutionAsync | ||
| //# debugId=81B14BA8DAA0CCD864756E2164756E21 | ||
| //# debugId=628CD0E0345A06B764756E2164756E21 |
| import { | ||
| registerPackagerFactories | ||
| } from "./packager-tool-sdhdmkt8.js"; | ||
| } from "./packager-tool-9vehmnke.js"; | ||
| import"./packager-tool-vpr77gre.js"; | ||
@@ -5,0 +5,0 @@ import"./packager-tool-129wn232.js"; |
+5
-5
| import { | ||
| publishSolutionAsync | ||
| } from "./packager-tool-rdxaysxe.js"; | ||
| import"./packager-tool-gkwmyc48.js"; | ||
| import"./packager-tool-y4wacqkp.js"; | ||
| } from "./packager-tool-c84z58bt.js"; | ||
| import"./packager-tool-arbagkf2.js"; | ||
| import"./packager-tool-r9n45rjm.js"; | ||
| import"./packager-tool-9qecd4wb.js"; | ||
| import"./packager-tool-q90kqh83.js"; | ||
| import"./packager-tool-1ps2qeqg.js"; | ||
| import"./packager-tool-7eva0peq.js"; | ||
| import"./packager-tool-5arsyj36.js"; | ||
| import"./packager-tool-129wn232.js"; | ||
@@ -10,0 +10,0 @@ import"./packager-tool-0v6na3yp.js"; |
+4
-4
| import { | ||
| resourceRefreshAsync | ||
| } from "./packager-tool-37g19zk3.js"; | ||
| } from "./packager-tool-ngh4qwjv.js"; | ||
| import"./packager-tool-vpr77gre.js"; | ||
| import"./packager-tool-y4wacqkp.js"; | ||
| import"./packager-tool-r9n45rjm.js"; | ||
| import"./packager-tool-9qecd4wb.js"; | ||
| import"./packager-tool-q90kqh83.js"; | ||
| import"./packager-tool-1ps2qeqg.js"; | ||
| import"./packager-tool-7eva0peq.js"; | ||
| import"./packager-tool-5arsyj36.js"; | ||
| import"./packager-tool-129wn232.js"; | ||
@@ -10,0 +10,0 @@ import"./packager-tool-0v6na3yp.js"; |
@@ -0,1 +1,2 @@ | ||
| import type { InitOverrideFunction } from "@uipath/solution-sdk"; | ||
| /** Which feed a publish/deploy/query is scoped to. */ | ||
@@ -20,7 +21,4 @@ export type FeedKind = "tenant" | "personal" | "folder"; | ||
| */ | ||
| export declare function feedScopeInitOverride(scope: FeedScope): ((context: { | ||
| init: RequestInit; | ||
| }) => { | ||
| headers: HeadersInit; | ||
| }) | undefined; | ||
| export declare function folderKeyInitOverride(folderKey: string): InitOverrideFunction; | ||
| export declare function feedScopeInitOverride(scope: FeedScope): InitOverrideFunction | undefined; | ||
| export interface ResolveFeedScopeOptions { | ||
@@ -35,2 +33,3 @@ /** Target the caller's own Personal Workspace feed. */ | ||
| } | ||
| export declare function feedResolutionFailureInstructions(options: Pick<ResolveFeedScopeOptions, "personalWorkspace" | "feed">): string; | ||
| /** | ||
@@ -37,0 +36,0 @@ * Turn the CLI feed flags into a validated {@link FeedScope} — the single |
@@ -61,3 +61,2 @@ # UiPath Solution Workspace | ||
| | `Process` | RPA process — Studio workflow (XAML, Coded C#, or Hybrid) | `uip rpa create-project --name <name>` | `uipath-rpa` | | ||
| | `Library` | Reusable RPA library | `uip rpa create-project --template-id LibraryProcessTemplate --name <name>` | `uipath-rpa` | | ||
| | `Tests` | Test Automation project | `uip rpa create-project --template-id TestAutomationProjectTemplate --name <name>` | `uipath-rpa` | | ||
@@ -76,2 +75,4 @@ | `Flow` | Maestro Flow — long-running orchestrated workflow | `uip maestro flow init <name>` | `uipath-maestro-flow` | | ||
| **`Library` is not a project type here.** A library is a reusable `.nupkg` consumed as a NuGet dependency, so `projects add` / `import` reject it and auto-registration returns `SolutionRegistration.Status: "Skipped"`. Publish it on its own (`uip rpa pack <project-dir> <output-path>`, then `uip or libraries upload --file <nupkg-path>`) and either reference it from a project's dependencies or attach it to this solution as a resource: `uip solution resources add --source remote --kind Library --name <library-name>`. | ||
| The type lives in either `project.uiproj` (top-level `ProjectType`) or `project.json` (`designOptions.outputType`, falling back to top-level `ProjectType` when `outputType` is absent — read or write either field). The `init` scaffolders above auto-register when run inside a solution directory (unless `--skip-solution-registration` is passed). For other scaffolders, register the project with the solution after scaffolding: use `uip solution projects add <project-path> [<solution-file>]` when the project already lives inside the solution directory (registers in place, no copy), or `uip solution projects import <path>` to copy a project from outside the solution dir into it and register it. If you pass an unknown type to those commands, they reject with the exhaustive accepted list — trust that error over this table. | ||
@@ -78,0 +79,0 @@ |
+11
-11
| import { | ||
| metadata, | ||
| registerCommands | ||
| } from "./packager-tool-gnmkvkz3.js"; | ||
| import"./packager-tool-br2aa2fh.js"; | ||
| import"./packager-tool-kfzzznjr.js"; | ||
| import"./packager-tool-7efxm815.js"; | ||
| import"./packager-tool-sdhdmkt8.js"; | ||
| import"./packager-tool-rdxaysxe.js"; | ||
| import"./packager-tool-gkwmyc48.js"; | ||
| import"./packager-tool-37g19zk3.js"; | ||
| } from "./packager-tool-9x8dbxbn.js"; | ||
| import"./packager-tool-n49qbf8m.js"; | ||
| import"./packager-tool-85x8cje1.js"; | ||
| import"./packager-tool-y35nbbkm.js"; | ||
| import"./packager-tool-9vehmnke.js"; | ||
| import"./packager-tool-c84z58bt.js"; | ||
| import"./packager-tool-arbagkf2.js"; | ||
| import"./packager-tool-ngh4qwjv.js"; | ||
| import"./packager-tool-vpr77gre.js"; | ||
| import"./packager-tool-y4wacqkp.js"; | ||
| import"./packager-tool-r9n45rjm.js"; | ||
| import"./packager-tool-9qecd4wb.js"; | ||
| import"./packager-tool-q90kqh83.js"; | ||
| import"./packager-tool-1ps2qeqg.js"; | ||
| import"./packager-tool-7eva0peq.js"; | ||
| import"./packager-tool-5arsyj36.js"; | ||
| import"./packager-tool-129wn232.js"; | ||
@@ -18,0 +18,0 @@ import"./packager-tool-0v6na3yp.js"; |
+2
-2
| { | ||
| "name": "@uipath/solution-tool", | ||
| "license": "MIT", | ||
| "version": "1.200.0-preview.109", | ||
| "version": "1.201.0-preview.115", | ||
| "description": "Create, pack, publish, and deploy UiPath Automation Solutions.", | ||
@@ -50,3 +50,3 @@ "repository": { | ||
| "private": false, | ||
| "gitHead": "fcc01cdae81bbd0c25d3d4fc287537a9d19d99f4" | ||
| "gitHead": "f1086b73654d7728cb71f280588b3e0c77d535fc" | ||
| } |
| import { | ||
| getGlobalThis | ||
| } from "./packager-tool-9qecd4wb.js"; | ||
| import { | ||
| AUTH_CANCELLED_ERROR_CODE | ||
| } from "./packager-tool-1ps2qeqg.js"; | ||
| import"./packager-tool-0v6na3yp.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 { | ||
| catchError, | ||
| getFileSystem, | ||
| startServer | ||
| } from "./packager-tool-q90kqh83.js"; | ||
| import"./packager-tool-1ps2qeqg.js"; | ||
| import"./packager-tool-0v6na3yp.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 |
| // ../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 |
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
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| import { | ||
| catchError | ||
| } from "./packager-tool-y4wacqkp.js"; | ||
| import { | ||
| getFileSystem | ||
| } from "./packager-tool-q90kqh83.js"; | ||
| // src/services/solution-init-service.ts | ||
| var AGENTS_FILENAME = "AGENTS.md"; | ||
| var CLAUDE_FILENAME = "CLAUDE.md"; | ||
| class SolutionInitError extends Error { | ||
| stage; | ||
| constructor(stage, cause) { | ||
| super(cause instanceof Error ? cause.message : String(cause), { | ||
| cause | ||
| }); | ||
| this.stage = stage; | ||
| this.name = "SolutionInitError"; | ||
| } | ||
| } | ||
| async function solutionInitAsync(solutionName, options = {}) { | ||
| const fs = getFileSystem(); | ||
| const base = fs.path.basename(solutionName); | ||
| const hasExtension = base.lastIndexOf(".") > 0; | ||
| const nameWithoutExt = hasExtension ? base.slice(0, base.lastIndexOf(".")) : base; | ||
| const fileName = hasExtension ? base : `${base}.uipx`; | ||
| const parentDir = fs.path.resolve(options.cwd ?? ".", fs.path.dirname(solutionName), nameWithoutExt); | ||
| const [mkdirError] = await catchError(fs.mkdir(parentDir)); | ||
| if (mkdirError) { | ||
| throw new SolutionInitError("directory", mkdirError); | ||
| } | ||
| let agentsPath; | ||
| let claudePath; | ||
| if (options.briefingContent !== undefined) { | ||
| agentsPath = fs.path.join(parentDir, AGENTS_FILENAME); | ||
| claudePath = fs.path.join(parentDir, CLAUDE_FILENAME); | ||
| const [agentsError] = await catchError(fs.writeFile(agentsPath, options.briefingContent)); | ||
| if (agentsError) { | ||
| throw new SolutionInitError("briefing", agentsError); | ||
| } | ||
| const [claudeError] = await catchError(fs.writeFile(claudePath, options.briefingContent)); | ||
| if (claudeError) { | ||
| throw new SolutionInitError("briefing", claudeError); | ||
| } | ||
| } | ||
| const filePath = fs.path.join(parentDir, fileName); | ||
| const solution = { | ||
| DocVersion: "1.0.0", | ||
| StudioMinVersion: "2025.10.0", | ||
| SolutionId: crypto.randomUUID(), | ||
| Projects: [] | ||
| }; | ||
| const [manifestError] = await catchError(fs.writeFile(filePath, `${JSON.stringify(solution, null, 2)} | ||
| `)); | ||
| if (manifestError) { | ||
| throw new SolutionInitError("manifest", manifestError); | ||
| } | ||
| return { | ||
| solutionFile: filePath, | ||
| solutionDir: parentDir, | ||
| solutionName: nameWithoutExt, | ||
| agentsPath, | ||
| claudePath | ||
| }; | ||
| } | ||
| export { SolutionInitError, solutionInitAsync }; | ||
| //# debugId=533229F41EC9DD9664756E2164756E21 |
| import { | ||
| AUTH_CANCELLED_ERROR_CODE, | ||
| DEFAULT_AUTH_TIMEOUT_MS | ||
| } from "./packager-tool-1ps2qeqg.js"; | ||
| import { | ||
| __require | ||
| } from "./packager-tool-0v6na3yp.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 |
| import { | ||
| Configuration, | ||
| Configuration1 as Configuration2, | ||
| PackagesApi, | ||
| PipelinesApi, | ||
| resolveFeedScope | ||
| } from "./packager-tool-gkwmyc48.js"; | ||
| import { | ||
| PollOutcome, | ||
| catchError, | ||
| extractErrorDetails, | ||
| getSolutionAuthContext, | ||
| logger, | ||
| mapPollFailure, | ||
| pollUntil | ||
| } from "./packager-tool-y4wacqkp.js"; | ||
| import { | ||
| getFileSystem | ||
| } from "./packager-tool-q90kqh83.js"; | ||
| import { | ||
| strFromU8, | ||
| strToU8, | ||
| unzipSync, | ||
| zipSync | ||
| } from "./packager-tool-129wn232.js"; | ||
| // src/services/package-metadata-rewrite.ts | ||
| import { randomUUID } from "node:crypto"; | ||
| var SOLUTION_METADATA_ENTRY = "solutionMetadata.json"; | ||
| function isRecord(value) { | ||
| return typeof value === "object" && value !== null && !Array.isArray(value); | ||
| } | ||
| var requireValue = (value, flag) => { | ||
| const trimmed = value.trim(); | ||
| if (!trimmed) { | ||
| throw new Error(`${flag} cannot be empty.`); | ||
| } | ||
| return trimmed; | ||
| }; | ||
| function rewritePackageMetadata(archive, overrides) { | ||
| const entries = unzipSync(archive); | ||
| const metadataBytes = entries[SOLUTION_METADATA_ENTRY]; | ||
| if (!metadataBytes) { | ||
| throw new Error(`Package archive has no ${SOLUTION_METADATA_ENTRY} at its root, so its name and version cannot be rewritten. Only a .zip produced by 'uip solution pack' carries that file.`); | ||
| } | ||
| let parsed; | ||
| try { | ||
| parsed = JSON.parse(strFromU8(metadataBytes)); | ||
| } catch (err) { | ||
| throw new Error(`${SOLUTION_METADATA_ENTRY} in the package archive is not valid JSON: ${err instanceof Error ? err.message : String(err)}`); | ||
| } | ||
| if (!isRecord(parsed) || !isRecord(parsed.spec)) { | ||
| throw new Error(`${SOLUTION_METADATA_ENTRY} in the package archive has no 'spec' object, so its name and version cannot be rewritten.`); | ||
| } | ||
| const spec = parsed.spec; | ||
| const packageName = overrides.packageName === undefined ? String(spec.packageName ?? "") : requireValue(overrides.packageName, "--package-name"); | ||
| const packageVersion = overrides.packageVersion === undefined ? String(spec.packageVersion ?? "") : requireValue(overrides.packageVersion, "--package-version"); | ||
| const packageVersionKey = randomUUID(); | ||
| const rewritten = { | ||
| ...parsed, | ||
| spec: { ...spec, packageName, packageVersion, packageVersionKey } | ||
| }; | ||
| const zipInput = {}; | ||
| for (const [entryName, entryBytes] of Object.entries(entries)) { | ||
| const level = entryName.toLowerCase().endsWith(".nupkg") ? 0 : 6; | ||
| zipInput[entryName] = [entryBytes, { level }]; | ||
| } | ||
| zipInput[SOLUTION_METADATA_ENTRY] = [ | ||
| strToU8(JSON.stringify(rewritten)), | ||
| { level: 6 } | ||
| ]; | ||
| return { | ||
| archive: zipSync(zipInput), | ||
| packageName, | ||
| packageVersion, | ||
| packageVersionKey | ||
| }; | ||
| } | ||
| // src/services/publish-service.ts | ||
| var TERMINAL_STATES = new Set([ | ||
| "Ready", | ||
| "Active", | ||
| "Failed" | ||
| ]); | ||
| var VERSION_CONFLICT_PATTERNS = [ | ||
| /\balready exists\b/i, | ||
| /\bduplicate\b.*\bversion\b/i, | ||
| /\bversion\b.*\bduplicate\b/i, | ||
| /\bpackage[-\s]?version\b.*\bexists\b/i, | ||
| /\bversion[-\s]?exists\b/i, | ||
| /\bversion\b.*\balready exists\b/i | ||
| ]; | ||
| var isVersionConflictError = (message, details) => { | ||
| const errorText = `${message} ${details ?? ""}`; | ||
| return VERSION_CONFLICT_PATTERNS.some((pattern) => pattern.test(errorText)); | ||
| }; | ||
| async function publishSolutionAsync(packagePath, options = {}) { | ||
| const [authError, auth] = await catchError(getSolutionAuthContext({ | ||
| tenant: options.tenant, | ||
| loginValidity: options.loginValidity, | ||
| envFilePath: options.envFilePath | ||
| })); | ||
| if (authError) { | ||
| return { | ||
| ok: false, | ||
| reason: "auth_failed", | ||
| message: authError.message | ||
| }; | ||
| } | ||
| const fs = getFileSystem(); | ||
| const resolvedPath = fs.path.resolve(packagePath); | ||
| if (!await fs.exists(resolvedPath)) { | ||
| return { | ||
| ok: false, | ||
| reason: "file_not_found", | ||
| message: `File not found: ${resolvedPath}` | ||
| }; | ||
| } | ||
| if (!resolvedPath.endsWith(".zip")) { | ||
| const stats = await fs.stat(resolvedPath); | ||
| const isSolutionSource = stats?.isDirectory() === true || resolvedPath.endsWith(".uis") || resolvedPath.endsWith(".uipx"); | ||
| if (isSolutionSource) { | ||
| return { | ||
| ok: false, | ||
| reason: "not_packed", | ||
| message: `'${packagePath}' is a solution source, not a packed package. 'publish' uploads the .zip produced by 'solution pack'.`, | ||
| details: resolvedPath | ||
| }; | ||
| } | ||
| return { | ||
| ok: false, | ||
| reason: "not_a_zip", | ||
| message: `Invalid file type. Expected a .zip file, got: ${resolvedPath}` | ||
| }; | ||
| } | ||
| const [fileBufferError, readBuffer] = await catchError(fs.readFile(resolvedPath)); | ||
| if (fileBufferError) { | ||
| const { message } = await extractErrorDetails(fileBufferError); | ||
| return { | ||
| ok: false, | ||
| reason: "file_read_failed", | ||
| message, | ||
| details: resolvedPath | ||
| }; | ||
| } | ||
| if (!readBuffer) { | ||
| return { | ||
| ok: false, | ||
| reason: "file_read_failed", | ||
| message: `File is empty or unreadable: ${resolvedPath}`, | ||
| details: resolvedPath | ||
| }; | ||
| } | ||
| let fileBuffer = readBuffer; | ||
| if (options.packageName !== undefined || options.packageVersion !== undefined) { | ||
| const [rewriteError, rewritten] = await catchError(Promise.resolve().then(() => rewritePackageMetadata(new Uint8Array(fileBuffer), { | ||
| packageName: options.packageName, | ||
| packageVersion: options.packageVersion | ||
| }))); | ||
| if (rewriteError || !rewritten) { | ||
| return { | ||
| ok: false, | ||
| reason: "metadata_rewrite_failed", | ||
| message: rewriteError?.message ?? "Could not rewrite the package name/version.", | ||
| details: resolvedPath | ||
| }; | ||
| } | ||
| logger.info(`Publishing ${resolvedPath} as ${rewritten.packageName} ${rewritten.packageVersion} (package version key ${rewritten.packageVersionKey}); the file on disk is unchanged.`); | ||
| fileBuffer = rewritten.archive; | ||
| } | ||
| const [scopeError, scope] = await catchError(resolveFeedScope({ | ||
| personalWorkspace: options.personalWorkspace, | ||
| feed: options.feed, | ||
| tenant: options.tenant, | ||
| loginValidity: options.loginValidity, | ||
| envFilePath: options.envFilePath | ||
| })); | ||
| if (scopeError) { | ||
| return { | ||
| ok: false, | ||
| reason: options.feed !== undefined ? "feed_resolution_failed" : "personal_workspace_resolution_failed", | ||
| message: scopeError.message | ||
| }; | ||
| } | ||
| if (scope.kind !== "tenant") { | ||
| return publishToFeed(auth, fileBuffer, scope, options); | ||
| } | ||
| const configuration = new Configuration({ | ||
| basePath: auth.basePath, | ||
| accessToken: auth.accessToken | ||
| }); | ||
| const api = new PipelinesApi(configuration); | ||
| const [uploadError, uploadResult] = await catchError(api.pipelinesPackageUpload({ body: fileBuffer })); | ||
| if (uploadError) { | ||
| return mapUploadError(uploadError); | ||
| } | ||
| let packageVersionInfo = uploadResult; | ||
| if (options.wait) { | ||
| const pollResult = await pollUntil({ | ||
| fn: () => api.pipelinesGetPackageVersion({ | ||
| packageName: uploadResult.packageName, | ||
| packageVersion: uploadResult.packageVersion | ||
| }), | ||
| until: (result) => TERMINAL_STATES.has(result.state), | ||
| getStatus: (result) => result.state, | ||
| label: `publish ${uploadResult.packageName}:${uploadResult.packageVersion}`, | ||
| logPrefix: "publish", | ||
| timeoutMs: (options.timeout ?? 360) * 1000, | ||
| intervalMs: options.pollInterval ?? 5000, | ||
| signal: options.signal | ||
| }); | ||
| if (pollResult.outcome !== PollOutcome.Completed) { | ||
| const { reason, message } = mapPollFailure(pollResult, "Package publish"); | ||
| return { ok: false, reason, message }; | ||
| } | ||
| if (!pollResult.data) { | ||
| return { | ||
| ok: false, | ||
| reason: "poll_failed", | ||
| message: "Package publish did not return a final state." | ||
| }; | ||
| } | ||
| packageVersionInfo = pollResult.data; | ||
| if (packageVersionInfo.state === "Failed") { | ||
| return { | ||
| ok: false, | ||
| reason: "publish_failed", | ||
| message: `Package publish failed with state: ${packageVersionInfo.state}` | ||
| }; | ||
| } | ||
| } | ||
| return { | ||
| ok: true, | ||
| packageVersionKey: packageVersionInfo.key, | ||
| packageName: packageVersionInfo.packageName, | ||
| packageVersion: packageVersionInfo.packageVersion, | ||
| state: packageVersionInfo.state, | ||
| feedKind: "tenant" | ||
| }; | ||
| } | ||
| async function publishToFeed(auth, fileBuffer, scope, options) { | ||
| const config = new Configuration2({ | ||
| basePath: auth.basePath, | ||
| accessToken: auth.accessToken | ||
| }); | ||
| const api = new PackagesApi(config); | ||
| const [uploadError, packageVersionKey] = await catchError(api.packagesUpload({ | ||
| body: fileBuffer, | ||
| locationKey: scope.folderKey | ||
| })); | ||
| if (uploadError) { | ||
| return mapUploadError(uploadError); | ||
| } | ||
| const [getError, initialInfo] = await catchError(api.packagesGetVersion({ packageVersionKey })); | ||
| if (getError) { | ||
| logger.warn(`Package uploaded (key ${packageVersionKey}) but its metadata was not yet retrievable; PackageName/PackageVersion/State will be absent from output: ${getError.message}`); | ||
| } | ||
| let packageVersionInfo = getError ? undefined : initialInfo; | ||
| if (options.wait) { | ||
| const pollResult = await pollUntil({ | ||
| fn: () => api.packagesGetVersion({ packageVersionKey }), | ||
| until: (result) => TERMINAL_STATES.has(result.state), | ||
| getStatus: (result) => result.state, | ||
| label: `publish ${packageVersionInfo ? `${packageVersionInfo.packageName}:${packageVersionInfo.packageVersion}` : packageVersionKey}`, | ||
| logPrefix: "publish", | ||
| timeoutMs: (options.timeout ?? 360) * 1000, | ||
| intervalMs: options.pollInterval ?? 5000, | ||
| signal: options.signal | ||
| }); | ||
| if (pollResult.outcome !== PollOutcome.Completed) { | ||
| const { reason, message } = mapPollFailure(pollResult, "Package publish"); | ||
| return { ok: false, reason, message }; | ||
| } | ||
| if (!pollResult.data) { | ||
| return { | ||
| ok: false, | ||
| reason: "poll_failed", | ||
| message: "Package publish did not return a final state." | ||
| }; | ||
| } | ||
| packageVersionInfo = pollResult.data; | ||
| if (packageVersionInfo.state === "Failed") { | ||
| return { | ||
| ok: false, | ||
| reason: "publish_failed", | ||
| message: `Package publish failed with state: ${packageVersionInfo.state}` | ||
| }; | ||
| } | ||
| } | ||
| return { | ||
| ok: true, | ||
| packageVersionKey: packageVersionInfo?.key ?? packageVersionKey, | ||
| packageName: packageVersionInfo?.packageName, | ||
| packageVersion: packageVersionInfo?.packageVersion, | ||
| state: packageVersionInfo?.state, | ||
| feedKind: scope.kind | ||
| }; | ||
| } | ||
| async function mapUploadError(uploadError) { | ||
| const { message, details, context, retry } = await extractErrorDetails(uploadError); | ||
| const fetchCause = uploadError instanceof Error && uploadError.name === "FetchError" && uploadError.cause instanceof Error ? uploadError.cause : null; | ||
| const surfacedMessage = fetchCause ? `Failed to upload package: ${fetchCause.message}` : message; | ||
| const httpStatus = context?.httpStatus; | ||
| let reason = "upload_failed"; | ||
| if (isVersionConflictError(message, details)) { | ||
| reason = "upload_version_conflict"; | ||
| } else if (fetchCause || httpStatus !== undefined && httpStatus >= 500) { | ||
| reason = "upload_network"; | ||
| } else if (httpStatus === 400 || httpStatus === 422) { | ||
| reason = "upload_rejected"; | ||
| } | ||
| return { | ||
| ok: false, | ||
| reason, | ||
| message: surfacedMessage, | ||
| details, | ||
| errorCode: context?.errorCode, | ||
| retry, | ||
| context | ||
| }; | ||
| } | ||
| export { publishSolutionAsync }; | ||
| //# debugId=696E04915672C64A64756E2164756E21 |
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.
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
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.
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 2 instances
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
5828222
0.82%62
5.08%103998
1.32%26
-3.7%