@uipath/rpa-tool 1.196.1 → 1.197.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/dist/index.js +717 -1449
  2. package/dist/packager-tool.js +10306 -9997
  3. package/dist/tool.js +57553 -48255
  4. package/package.json +14 -12
package/dist/index.js CHANGED
@@ -2250,7 +2250,6 @@ import { execFile as execFile5 } from "node:child_process";
2250
2250
  import process7 from "node:process";
2251
2251
  import { execFileSync as execFileSync2 } from "node:child_process";
2252
2252
  import { AsyncLocalStorage } from "node:async_hooks";
2253
- import vm from "vm";
2254
2253
  var __create2 = Object.create;
2255
2254
  var __getProtoOf2 = Object.getPrototypeOf;
2256
2255
  var __defProp2 = Object.defineProperty;
@@ -5163,6 +5162,18 @@ var NETWORK_ERROR_CODES = new Set([
5163
5162
  "ENETUNREACH",
5164
5163
  "EAI_FAIL"
5165
5164
  ]);
5165
+ var TLS_ERROR_CODES = new Set([
5166
+ "SELF_SIGNED_CERT_IN_CHAIN",
5167
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
5168
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
5169
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
5170
+ "UNABLE_TO_GET_ISSUER_CERT",
5171
+ "CERT_HAS_EXPIRED",
5172
+ "CERT_UNTRUSTED",
5173
+ "ERR_TLS_CERT_ALTNAME_INVALID"
5174
+ ]);
5175
+ var TLS_INSTRUCTIONS = "The server's TLS certificate could not be verified. Most often a " + "corporate proxy/firewall re-signs HTTPS with a root CA that Node does " + "not trust — set NODE_EXTRA_CA_CERTS to that CA's PEM file (and HTTPS_PROXY " + "if you connect through a proxy). If the certificate is instead expired or " + "its hostname does not match, fix the endpoint URL or the system clock. " + "Then retry.";
5176
+ var NETWORK_INSTRUCTIONS = "Could not reach the UiPath service. Check your network connection and " + "VPN, confirm any HTTP_PROXY/HTTPS_PROXY/NO_PROXY settings are correct, " + "then retry.";
5166
5177
  var import__2 = __toESM2(require_commander2(), 1);
5167
5178
  var {
5168
5179
  program: program2,
@@ -5231,6 +5242,7 @@ var CONSOLE_FALLBACK = {
5231
5242
  writeLog: (str) => process.stdout.write(str),
5232
5243
  capabilities: {
5233
5244
  isInteractive: false,
5245
+ canReadInput: false,
5234
5246
  supportsColor: false,
5235
5247
  outputWidth: 80
5236
5248
  }
@@ -10145,6 +10157,7 @@ function getLogFilePath() {
10145
10157
  }
10146
10158
  var formatSlot = singleton("OutputFormat");
10147
10159
  var formatExplicitSlot = singleton("OutputFormatExplicit");
10160
+ var helpRequestedSlot = singleton("HelpRequested");
10148
10161
  var filterSlot = singleton("OutputFilter");
10149
10162
  function setOutputFormat(format) {
10150
10163
  formatSlot.set(format);
@@ -10155,8 +10168,225 @@ function getOutputFormat() {
10155
10168
  function getOutputFilter() {
10156
10169
  return filterSlot.get();
10157
10170
  }
10171
+ var recordedFailureSlot = singleton("CommandTelemetryFailure");
10172
+ var AUTH_ERROR_CODES = new Set([
10173
+ "authentication_required",
10174
+ "permission_denied"
10175
+ ]);
10176
+ var VALIDATION_ERROR_CODES = new Set(["invalid_argument"]);
10177
+ var NETWORK_HTTP_ERROR_CODES = new Set([
10178
+ "network_error",
10179
+ "rate_limited",
10180
+ "server_error",
10181
+ "not_found",
10182
+ "method_not_allowed"
10183
+ ]);
10184
+ var TIMEOUT_ERROR_CODES = new Set(["timeout"]);
10185
+ var NETWORK_OS_ERROR_CODES = new Set([
10186
+ "ECONNREFUSED",
10187
+ "ECONNRESET",
10188
+ "ENOTFOUND",
10189
+ "EAI_AGAIN",
10190
+ "EPIPE",
10191
+ "EHOSTUNREACH",
10192
+ "ENETUNREACH",
10193
+ "EAI_FAIL"
10194
+ ]);
10195
+ var TIMEOUT_OS_ERROR_CODES = new Set(["ETIMEDOUT", "ESOCKETTIMEDOUT"]);
10196
+ var TLS_ERROR_CODES2 = new Set([
10197
+ "SELF_SIGNED_CERT_IN_CHAIN",
10198
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
10199
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
10200
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
10201
+ "UNABLE_TO_GET_ISSUER_CERT",
10202
+ "CERT_HAS_EXPIRED",
10203
+ "CERT_UNTRUSTED",
10204
+ "ERR_TLS_CERT_ALTNAME_INVALID"
10205
+ ]);
10206
+ var MISSING_DEPENDENCY_CODES = new Set([
10207
+ "MODULE_NOT_FOUND",
10208
+ "ERR_MODULE_NOT_FOUND"
10209
+ ]);
10210
+ var INTERNAL_ERROR_NAMES = new Set([
10211
+ "TypeError",
10212
+ "ReferenceError",
10213
+ "SyntaxError",
10214
+ "RangeError"
10215
+ ]);
10216
+ function isRecord(value) {
10217
+ return value !== null && typeof value === "object";
10218
+ }
10219
+ function stringField(value, field) {
10220
+ if (!isRecord(value)) {
10221
+ return;
10222
+ }
10223
+ const raw = value[field];
10224
+ return typeof raw === "string" ? raw : undefined;
10225
+ }
10226
+ function numberField(value, field) {
10227
+ if (!isRecord(value)) {
10228
+ return;
10229
+ }
10230
+ const raw = value[field];
10231
+ return typeof raw === "number" ? raw : undefined;
10232
+ }
10233
+ function findStringInCauseChain(error, field) {
10234
+ let current = error;
10235
+ for (let depth = 0;depth < 5 && current !== null && typeof current === "object"; depth++) {
10236
+ const value = stringField(current, field);
10237
+ if (value) {
10238
+ return value;
10239
+ }
10240
+ current = current.cause;
10241
+ }
10242
+ return;
10243
+ }
10244
+ function findCodeInCauseChain(error) {
10245
+ return findStringInCauseChain(error, "code");
10246
+ }
10247
+ function isSpawnEnoent(error) {
10248
+ const code = findCodeInCauseChain(error);
10249
+ if (code !== "ENOENT") {
10250
+ return false;
10251
+ }
10252
+ const syscall = findStringInCauseChain(error, "syscall");
10253
+ return syscall?.startsWith("spawn") === true;
10254
+ }
10255
+ function isCancellationError(error, exitCode, pollSignal) {
10256
+ if (exitCode === 130) {
10257
+ return true;
10258
+ }
10259
+ if (!isRecord(error)) {
10260
+ return false;
10261
+ }
10262
+ if (numberField(error, "exitCode") === 130) {
10263
+ return true;
10264
+ }
10265
+ const name = stringField(error, "name");
10266
+ if (name === "ExitPromptError") {
10267
+ return true;
10268
+ }
10269
+ if (name === "AbortError" && pollSignal?.aborted) {
10270
+ return true;
10271
+ }
10272
+ const message = stringField(error, "message");
10273
+ return message?.includes("SIGINT") === true;
10274
+ }
10275
+ function terminalSignalFor(input, outcome) {
10276
+ if (input.recordedFailure?.terminalSignal) {
10277
+ return input.recordedFailure.terminalSignal;
10278
+ }
10279
+ const explicit = findStringInCauseChain(input.error, "terminalSignal") ?? findStringInCauseChain(input.error, "signal");
10280
+ if (explicit) {
10281
+ return explicit;
10282
+ }
10283
+ return outcome === "cancelled" ? "SIGINT" : undefined;
10284
+ }
10285
+ function classifyHttpStatus(status) {
10286
+ if (status === 401 || status === 403) {
10287
+ return "auth";
10288
+ }
10289
+ if (status === 400 || status === 409 || status === 422) {
10290
+ return "validation";
10291
+ }
10292
+ if (status === 408) {
10293
+ return "timeout";
10294
+ }
10295
+ return "network_http";
10296
+ }
10297
+ function classifyFromResult(result) {
10298
+ switch (result) {
10299
+ case "AuthenticationError":
10300
+ return "auth";
10301
+ case "ValidationError":
10302
+ return "validation";
10303
+ case "TimeoutError":
10304
+ return "timeout";
10305
+ default:
10306
+ return;
10307
+ }
10308
+ }
10309
+ function classifyFromErrorCode(errorCode) {
10310
+ if (!errorCode) {
10311
+ return;
10312
+ }
10313
+ if (AUTH_ERROR_CODES.has(errorCode)) {
10314
+ return "auth";
10315
+ }
10316
+ if (VALIDATION_ERROR_CODES.has(errorCode)) {
10317
+ return "validation";
10318
+ }
10319
+ if (TIMEOUT_ERROR_CODES.has(errorCode)) {
10320
+ return "timeout";
10321
+ }
10322
+ if (NETWORK_HTTP_ERROR_CODES.has(errorCode)) {
10323
+ return "network_http";
10324
+ }
10325
+ return;
10326
+ }
10327
+ function classifyFromError(error) {
10328
+ const code = findCodeInCauseChain(error);
10329
+ if (code) {
10330
+ if (code.startsWith("commander.")) {
10331
+ return "validation";
10332
+ }
10333
+ if (NETWORK_OS_ERROR_CODES.has(code) || TLS_ERROR_CODES2.has(code)) {
10334
+ return "network_http";
10335
+ }
10336
+ if (TIMEOUT_OS_ERROR_CODES.has(code)) {
10337
+ return "timeout";
10338
+ }
10339
+ if (MISSING_DEPENDENCY_CODES.has(code) || isSpawnEnoent(error)) {
10340
+ return "missing_dependency";
10341
+ }
10342
+ }
10343
+ const message = stringField(error, "message");
10344
+ if (message?.includes("fetch failed") === true) {
10345
+ return "network_http";
10346
+ }
10347
+ const name = stringField(error, "name");
10348
+ if (name && INTERNAL_ERROR_NAMES.has(name)) {
10349
+ return "internal";
10350
+ }
10351
+ return;
10352
+ }
10353
+ function classifyError2(input) {
10354
+ const recorded = input.recordedFailure;
10355
+ if (recorded?.errorClass) {
10356
+ return recorded.errorClass;
10357
+ }
10358
+ const status = recorded?.context?.httpStatus;
10359
+ if (status !== undefined) {
10360
+ return classifyHttpStatus(status);
10361
+ }
10362
+ return classifyFromResult(recorded?.result) ?? classifyFromErrorCode(recorded?.errorCode) ?? classifyFromError(input.error) ?? "unknown";
10363
+ }
10364
+ function recordCommandFailureTelemetry(failure) {
10365
+ recordedFailureSlot.set(failure);
10366
+ }
10367
+ function clearRecordedCommandFailureTelemetry() {
10368
+ recordedFailureSlot.clear();
10369
+ }
10370
+ function takeRecordedCommandFailureTelemetry() {
10371
+ const failure = recordedFailureSlot.get();
10372
+ recordedFailureSlot.clear();
10373
+ return failure;
10374
+ }
10375
+ function buildCommandTerminalTelemetryProperties(input) {
10376
+ const cancelled = isCancellationError(input.error, input.exitCode, input.pollSignal);
10377
+ const outcome = input.recordedFailure?.terminalOutcome ?? (input.exitCode === 0 ? "success" : cancelled ? "cancelled" : "failure");
10378
+ const errorClass = outcome === "success" || outcome === "no_op" ? undefined : outcome === "cancelled" ? "user_cancelled" : classifyError2(input);
10379
+ const terminalSignal = terminalSignalFor(input, outcome);
10380
+ return {
10381
+ exit_code: input.exitCode,
10382
+ terminal_outcome: outcome,
10383
+ ...errorClass ? { error_class: errorClass } : {},
10384
+ ...terminalSignal ? { terminal_signal: terminalSignal } : {}
10385
+ };
10386
+ }
10158
10387
  var CommonTelemetryEvents = {
10159
- Error: "uip.error"
10388
+ Error: "uip.error",
10389
+ ShipSucceeded: "ship_succeeded"
10160
10390
  };
10161
10391
  function readRegistryValue(keyPath, valueName) {
10162
10392
  if (process.platform !== "win32") {
@@ -10219,6 +10449,134 @@ function formatMessage(category, name, properties) {
10219
10449
  }
10220
10450
  return message;
10221
10451
  }
10452
+ var KNOWN_AGENTS = [
10453
+ { envVar: "CLAUDECODE", value: "1", id: "claude-code" },
10454
+ { envVar: "CURSOR_AGENT", value: "1", id: "cursor" },
10455
+ { envVar: "GEMINI_CLI", value: "1", id: "gemini-cli" },
10456
+ { envVar: "CODEX_THREAD_ID", id: "codex" },
10457
+ { envVar: "CODEX_SANDBOX", id: "codex" },
10458
+ { envVar: "AUGMENT_AGENT", value: "1", id: "augment" },
10459
+ { envVar: "CLINE_ACTIVE", value: "true", id: "cline" }
10460
+ ];
10461
+ function detectAgentFromEnv(env) {
10462
+ for (const agent of KNOWN_AGENTS) {
10463
+ const envValue = env[agent.envVar];
10464
+ if (agent.value !== undefined) {
10465
+ if (envValue === agent.value)
10466
+ return agent.id;
10467
+ } else {
10468
+ if (envValue)
10469
+ return agent.id;
10470
+ }
10471
+ }
10472
+ const agentEnv = env.AGENT;
10473
+ if (agentEnv) {
10474
+ if (agentEnv === "1" || agentEnv === "true")
10475
+ return "unknown";
10476
+ if (agentEnv.length <= 32)
10477
+ return agentEnv.toLowerCase();
10478
+ }
10479
+ return;
10480
+ }
10481
+ var LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
10482
+ var authSignalSlot = singleton("TelemetryExecutionContextAuthSignal");
10483
+ var isTruthy = (value) => value !== undefined && value !== "" && value !== "0" && value.toLowerCase() !== "false";
10484
+ var isEqual = (value, expected) => value?.toLowerCase() === expected;
10485
+ var CI_SIGNATURES = [
10486
+ {
10487
+ provider: "github_actions",
10488
+ matches: (env) => isTruthy(env.GITHUB_ACTIONS),
10489
+ isScheduler: (env) => env.GITHUB_EVENT_NAME === "schedule"
10490
+ },
10491
+ {
10492
+ provider: "azure_devops",
10493
+ matches: (env) => isTruthy(env.TF_BUILD),
10494
+ isScheduler: (env) => isEqual(env.BUILD_REASON, "schedule")
10495
+ },
10496
+ {
10497
+ provider: "gitlab",
10498
+ matches: (env) => isTruthy(env.GITLAB_CI),
10499
+ isScheduler: (env) => env.CI_PIPELINE_SOURCE === "schedule"
10500
+ },
10501
+ {
10502
+ provider: "circleci",
10503
+ matches: (env) => isTruthy(env.CIRCLECI),
10504
+ isScheduler: (env) => env.CIRCLE_PIPELINE_TRIGGER_SOURCE === "scheduled_pipeline"
10505
+ },
10506
+ {
10507
+ provider: "jenkins",
10508
+ matches: (env) => isTruthy(env.JENKINS_URL) || isTruthy(env.JENKINS_HOME)
10509
+ },
10510
+ {
10511
+ provider: "teamcity",
10512
+ matches: (env) => isTruthy(env.TEAMCITY_VERSION)
10513
+ },
10514
+ {
10515
+ provider: "buildkite",
10516
+ matches: (env) => isTruthy(env.BUILDKITE),
10517
+ isScheduler: (env) => env.BUILDKITE_SOURCE === "schedule"
10518
+ },
10519
+ {
10520
+ provider: "bitbucket",
10521
+ matches: (env) => isTruthy(env.BITBUCKET_BUILD_NUMBER)
10522
+ },
10523
+ {
10524
+ provider: "travis",
10525
+ matches: (env) => isTruthy(env.TRAVIS)
10526
+ },
10527
+ {
10528
+ provider: "appveyor",
10529
+ matches: (env) => isTruthy(env.APPVEYOR)
10530
+ },
10531
+ {
10532
+ provider: "generic",
10533
+ matches: (env) => isTruthy(env.CI)
10534
+ }
10535
+ ];
10536
+ function currentEnv() {
10537
+ return typeof process === "undefined" ? {} : process.env;
10538
+ }
10539
+ function currentTtyState() {
10540
+ if (typeof process === "undefined")
10541
+ return false;
10542
+ return Boolean(process.stdout?.isTTY || process.stdin?.isTTY || process.stderr?.isTTY);
10543
+ }
10544
+ function detectCi(env) {
10545
+ const signature = CI_SIGNATURES.find((candidate) => candidate.matches(env));
10546
+ if (!signature)
10547
+ return;
10548
+ return {
10549
+ executionContext: signature.isScheduler?.(env) ? "scheduler" : "ci",
10550
+ ciProvider: signature.provider
10551
+ };
10552
+ }
10553
+ function detectExecutionContext(options = {}) {
10554
+ const env = options.env ?? currentEnv();
10555
+ const ci = detectCi(env);
10556
+ if (ci)
10557
+ return ci;
10558
+ const agent = options.agent ?? detectAgentFromEnv(env);
10559
+ if (agent) {
10560
+ return { executionContext: "agent" };
10561
+ }
10562
+ const authSignal = options.authSignal ?? authSignalSlot.get();
10563
+ if (authSignal === "service_account") {
10564
+ return { executionContext: "service_account" };
10565
+ }
10566
+ const isTty = options.isTty ?? currentTtyState();
10567
+ if (isTty) {
10568
+ return { executionContext: "manual" };
10569
+ }
10570
+ return { executionContext: "unknown" };
10571
+ }
10572
+ function getExecutionContextTelemetryProperties() {
10573
+ const detected = detectExecutionContext();
10574
+ return {
10575
+ execution_context: detected.executionContext,
10576
+ ...detected.ciProvider ? { ci_provider: detected.ciProvider } : {}
10577
+ };
10578
+ }
10579
+
10222
10580
  class NodeContextStorage {
10223
10581
  storage = new AsyncLocalStorage;
10224
10582
  run(context, fn) {
@@ -10228,6 +10586,38 @@ class NodeContextStorage {
10228
10586
  return this.storage.getStore();
10229
10587
  }
10230
10588
  }
10589
+ var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
10590
+ var TELEMETRY_SESSION_ID_PROPERTY = "session_id";
10591
+ var telemetrySessionIdSlot = singleton("TelemetrySessionId");
10592
+ function getProcessEnv() {
10593
+ return globalThis.process?.env;
10594
+ }
10595
+ function normalizeSessionId(value) {
10596
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
10597
+ return;
10598
+ }
10599
+ const trimmed = String(value).trim();
10600
+ return trimmed || undefined;
10601
+ }
10602
+ function getConfiguredTelemetrySessionId() {
10603
+ return normalizeSessionId(getProcessEnv()?.[TELEMETRY_SESSION_ID_ENV]);
10604
+ }
10605
+ function getTelemetrySessionId() {
10606
+ const envSessionId = getConfiguredTelemetrySessionId();
10607
+ if (envSessionId) {
10608
+ return envSessionId;
10609
+ }
10610
+ const existing = telemetrySessionIdSlot.get();
10611
+ if (existing) {
10612
+ return existing;
10613
+ }
10614
+ const generated = crypto.randomUUID();
10615
+ telemetrySessionIdSlot.set(generated);
10616
+ return generated;
10617
+ }
10618
+ function resolveTelemetrySessionId(existingSessionId) {
10619
+ return getConfiguredTelemetrySessionId() ?? normalizeSessionId(existingSessionId);
10620
+ }
10231
10621
  var telemetryPropsSlot = singleton("TelemetryDefaultProps");
10232
10622
  function setGlobalTelemetryProperties(properties) {
10233
10623
  const existing = getGlobalTelemetryProperties();
@@ -10314,12 +10704,22 @@ class TelemetryService {
10314
10704
  return this.contextStorage.getContext();
10315
10705
  }
10316
10706
  enrichPropertiesWithContext(properties, context) {
10317
- return {
10318
- ...getGlobalTelemetryProperties(),
10707
+ const globalProperties = getGlobalTelemetryProperties();
10708
+ const existingSessionId = properties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? this.defaultProperties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? globalProperties?.[TELEMETRY_SESSION_ID_PROPERTY];
10709
+ const sessionId = resolveTelemetrySessionId(existingSessionId);
10710
+ const enriched = {
10711
+ ...getExecutionContextTelemetryProperties(),
10712
+ ...globalProperties,
10319
10713
  ...this.defaultProperties,
10320
10714
  ...properties,
10321
10715
  ...context
10322
10716
  };
10717
+ if (sessionId === undefined) {
10718
+ delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
10719
+ } else {
10720
+ enriched[TELEMETRY_SESSION_ID_PROPERTY] = sessionId;
10721
+ }
10722
+ return enriched;
10323
10723
  }
10324
10724
  generateId() {
10325
10725
  return crypto.randomUUID().replaceAll("-", "");
@@ -10333,7 +10733,7 @@ function toOperationUrn(name) {
10333
10733
  const sanitized = encodeURIComponent(name).replace(/%2F/g, "/");
10334
10734
  return `urn:uip:${sanitized}`;
10335
10735
  }
10336
- function isRecord(value) {
10736
+ function isRecord2(value) {
10337
10737
  return value !== null && typeof value === "object";
10338
10738
  }
10339
10739
  function formatFlushJsonError(error) {
@@ -10341,7 +10741,7 @@ function formatFlushJsonError(error) {
10341
10741
  return error.message;
10342
10742
  if (typeof error === "string")
10343
10743
  return error;
10344
- if (!isRecord(error))
10744
+ if (!isRecord2(error))
10345
10745
  return String(error);
10346
10746
  const parts = [];
10347
10747
  if (error.index !== undefined) {
@@ -10383,7 +10783,7 @@ function normalizeFlushCallbackError(response) {
10383
10783
  return;
10384
10784
  const [parseError, parsed] = catchError(() => JSON.parse(text));
10385
10785
  if (!parseError) {
10386
- const errors = isRecord(parsed) ? parsed.errors : undefined;
10786
+ const errors = isRecord2(parsed) ? parsed.errors : undefined;
10387
10787
  if (Array.isArray(errors) && errors.length > 0) {
10388
10788
  return errors.map(formatFlushJsonError).join("; ");
10389
10789
  }
@@ -10435,7 +10835,7 @@ class NodeAppInsightsTelemetryProvider {
10435
10835
  initialized = false;
10436
10836
  constructor(connectionString) {
10437
10837
  this.connectionString = connectionString;
10438
- this._sessionId = crypto.randomUUID();
10838
+ this._sessionId = getTelemetrySessionId();
10439
10839
  }
10440
10840
  async initialize() {
10441
10841
  if (this.initialized)
@@ -10589,6 +10989,10 @@ async function getOrCreateProvider(connectionString) {
10589
10989
  providerSlot.set(initPromise);
10590
10990
  return initPromise;
10591
10991
  }
10992
+ function isTelemetryDisabled() {
10993
+ const value = process.env.UIPATH_TELEMETRY_DISABLED;
10994
+ return value === "1" || value === "true";
10995
+ }
10592
10996
  var telemetryInstanceSlot = singleton("TelemetryService");
10593
10997
  var DEFAULT_AI_CONNECTION_STRING = atob("SW5zdHJ1bWVudGF0aW9uS2V5PTliZDM3NDgyLTgxMGUtNDQyYS1hYWE2LWQzOGVmNjVjNjY3NDtJbmdlc3Rpb25FbmRwb2ludD1odHRwczovL3dlc3RldXJvcGUtNS5pbi5hcHBsaWNhdGlvbmluc2lnaHRzLmF6dXJlLmNvbS87TGl2ZUVuZHBvaW50PWh0dHBzOi8vd2VzdGV1cm9wZS5saXZlZGlhZ25vc3RpY3MubW9uaXRvci5henVyZS5jb20vO0FwcGxpY2F0aW9uSWQ9MzU2OTdlZjEtOGJkMC00ZjE5LWEyN2MtZDg3Y2NhYzY2ZDJj");
10594
10998
  function getConnectionString() {
@@ -10597,10 +11001,6 @@ function getConnectionString() {
10597
11001
  async function createAppInsightsProvider() {
10598
11002
  return getOrCreateProvider(getConnectionString());
10599
11003
  }
10600
- function isTelemetryDisabled() {
10601
- const value = process.env.UIPATH_TELEMETRY_DISABLED;
10602
- return value === "1" || value === "true";
10603
- }
10604
11004
  var telemetryProviderInstance;
10605
11005
  var telemetryFlushShutdownPromise;
10606
11006
  async function createTelemetryProvider() {
@@ -10776,6 +11176,29 @@ function isPlainRecord(value) {
10776
11176
  const prototype = Object.getPrototypeOf(value);
10777
11177
  return prototype === Object.prototype || prototype === null;
10778
11178
  }
11179
+ function extractPagedRows(value) {
11180
+ if (Array.isArray(value) || !isPlainRecord(value))
11181
+ return null;
11182
+ const entries = Object.values(value);
11183
+ if (entries.length === 0)
11184
+ return null;
11185
+ let rows = null;
11186
+ let hasScalarSibling = false;
11187
+ for (const entry of entries) {
11188
+ if (Array.isArray(entry)) {
11189
+ if (rows !== null)
11190
+ return null;
11191
+ rows = entry;
11192
+ } else if (entry !== null && typeof entry === "object") {
11193
+ return null;
11194
+ } else {
11195
+ hasScalarSibling = true;
11196
+ }
11197
+ }
11198
+ if (rows === null || !hasScalarSibling)
11199
+ return null;
11200
+ return rows;
11201
+ }
10779
11202
  function toLowerCamelCaseKey(key) {
10780
11203
  if (!key)
10781
11204
  return key;
@@ -10840,7 +11263,8 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
10840
11263
  break;
10841
11264
  case "plain": {
10842
11265
  if ("Data" in data && data.Data != null) {
10843
- const items = Array.isArray(data.Data) ? data.Data : [data.Data];
11266
+ const pagedRows = extractPagedRows(data.Data);
11267
+ const items = pagedRows ?? (Array.isArray(data.Data) ? data.Data : [data.Data]);
10844
11268
  items.forEach((item) => {
10845
11269
  const values = Object.values(item).map((v) => v ?? "").join("\t");
10846
11270
  logFn(values);
@@ -10852,10 +11276,13 @@ function printOutput(data, format = "json", logFn, asciiSafe = false) {
10852
11276
  break;
10853
11277
  }
10854
11278
  default: {
10855
- if ("Data" in data && data.Data != null && !(Array.isArray(data.Data) && data.Data.length === 0)) {
11279
+ const hasData = "Data" in data && data.Data != null;
11280
+ const pagedRows = hasData ? extractPagedRows(data.Data) : null;
11281
+ const rows = pagedRows ? pagedRows : Array.isArray(data.Data) ? data.Data : null;
11282
+ if (hasData && !(rows !== null && rows.length === 0)) {
10856
11283
  const logValue = data.Log;
10857
- if (Array.isArray(data.Data)) {
10858
- printResizableTable(data.Data, logFn, logValue);
11284
+ if (rows !== null) {
11285
+ printResizableTable(rows, logFn, logValue);
10859
11286
  } else {
10860
11287
  printVerticalTable(data.Data, logFn, logValue);
10861
11288
  }
@@ -11043,6 +11470,44 @@ function defaultErrorCodeForResult(result) {
11043
11470
  return "unknown_error";
11044
11471
  }
11045
11472
  }
11473
+ function parseHttpStatusFromMessage2(message) {
11474
+ const match = /^HTTP\s+(\d{3})(?::|\s|-|$)/i.exec(message.trim());
11475
+ if (!match)
11476
+ return;
11477
+ const status = Number(match[1]);
11478
+ return Number.isInteger(status) && status >= 100 && status <= 599 ? status : undefined;
11479
+ }
11480
+ function defaultErrorCodeForHttpStatus(status) {
11481
+ if (status === undefined)
11482
+ return;
11483
+ if (status === 400 || status === 409 || status === 422) {
11484
+ return "invalid_argument";
11485
+ }
11486
+ if (status === 401)
11487
+ return "authentication_required";
11488
+ if (status === 403)
11489
+ return "permission_denied";
11490
+ if (status === 404)
11491
+ return "not_found";
11492
+ if (status === 405)
11493
+ return "method_not_allowed";
11494
+ if (status === 408)
11495
+ return "timeout";
11496
+ if (status === 429)
11497
+ return "rate_limited";
11498
+ if (status >= 500 && status < 600)
11499
+ return "server_error";
11500
+ return;
11501
+ }
11502
+ function defaultErrorCodeForFailure(data) {
11503
+ if (data.Result === RESULTS.Failure) {
11504
+ const status = data.Context?.httpStatus ?? parseHttpStatusFromMessage2(data.Message);
11505
+ const errorCode = defaultErrorCodeForHttpStatus(status);
11506
+ if (errorCode)
11507
+ return errorCode;
11508
+ }
11509
+ return defaultErrorCodeForResult(data.Result);
11510
+ }
11046
11511
  function defaultRetryForErrorCode(errorCode) {
11047
11512
  switch (errorCode) {
11048
11513
  case "network_error":
@@ -11072,16 +11537,35 @@ var OutputFormatter;
11072
11537
  OutputFormatter2.success = success;
11073
11538
  function error(data) {
11074
11539
  data.Log ??= getLogFilePath() || undefined;
11075
- data.ErrorCode ??= defaultErrorCodeForResult(data.Result);
11540
+ data.ErrorCode ??= defaultErrorCodeForFailure(data);
11076
11541
  data.Retry ??= defaultRetryForErrorCode(data.ErrorCode);
11077
11542
  process.exitCode = EXIT_CODES[data.Result] ?? 1;
11078
- telemetry.trackEvent(CommonTelemetryEvents.Error, {
11543
+ recordCommandFailureTelemetry({
11079
11544
  result: data.Result,
11080
11545
  errorCode: data.ErrorCode,
11081
11546
  retry: data.Retry,
11082
- message: data.Message
11547
+ message: data.Message,
11548
+ context: data.Context,
11549
+ exitCode: process.exitCode,
11550
+ errorClass: data.TelemetryErrorClass,
11551
+ terminalOutcome: data.TelemetryTerminalOutcome,
11552
+ terminalSignal: data.TelemetryTerminalSignal
11083
11553
  });
11084
- logOutput(normalizeOutputKeys(data), getOutputFormat());
11554
+ const suppressTelemetry = data.SuppressTelemetry === true;
11555
+ const envelope = { ...data };
11556
+ delete envelope.SuppressTelemetry;
11557
+ delete envelope.TelemetryErrorClass;
11558
+ delete envelope.TelemetryTerminalOutcome;
11559
+ delete envelope.TelemetryTerminalSignal;
11560
+ if (!suppressTelemetry) {
11561
+ telemetry.trackEvent(CommonTelemetryEvents.Error, {
11562
+ result: data.Result,
11563
+ errorCode: data.ErrorCode,
11564
+ retry: data.Retry,
11565
+ message: data.Message
11566
+ });
11567
+ }
11568
+ logOutput(normalizeOutputKeys(envelope), getOutputFormat());
11085
11569
  }
11086
11570
  OutputFormatter2.error = error;
11087
11571
  function emitList(code, items, opts) {
@@ -11096,6 +11580,9 @@ var OutputFormatter;
11096
11580
  if (opts?.warning) {
11097
11581
  data.Warning = opts.warning;
11098
11582
  }
11583
+ if (opts?.pagination) {
11584
+ data.Pagination = opts.pagination;
11585
+ }
11099
11586
  success(data);
11100
11587
  }
11101
11588
  OutputFormatter2.emitList = emitList;
@@ -11135,6 +11622,156 @@ var OutputFormatter;
11135
11622
  }
11136
11623
  OutputFormatter2.formatToString = formatToString;
11137
11624
  })(OutputFormatter ||= {});
11625
+ var LEGACY_SKILL_NAMESPACE = "uipath:";
11626
+ var MAX_SKILL_NAME_LENGTH = 80;
11627
+ var SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
11628
+ function productMode(productArea, mode) {
11629
+ return { product_area: productArea, mode };
11630
+ }
11631
+ function attributionRecord(groups) {
11632
+ const record = {};
11633
+ for (const [productArea, mode, names] of groups) {
11634
+ const attribution = productMode(productArea, mode);
11635
+ for (const name of names) {
11636
+ record[name] = attribution;
11637
+ }
11638
+ }
11639
+ return record;
11640
+ }
11641
+ function commandAttribution(groups) {
11642
+ const entries = [];
11643
+ for (const [productArea, mode, prefixes] of groups) {
11644
+ const attribution = productMode(productArea, mode);
11645
+ for (const prefix of prefixes) {
11646
+ entries.push({ prefix, attribution });
11647
+ }
11648
+ }
11649
+ return entries;
11650
+ }
11651
+ var SKILL_ATTRIBUTION = attributionRecord([
11652
+ ["admin", "operate", ["uipath-admin"]],
11653
+ ["agents", "build", ["uipath-agents"]],
11654
+ ["api-workflow", "build", ["uipath-api-workflow"]],
11655
+ ["automation-discovery", "build", ["uipath-automation-discovery"]],
11656
+ ["coded-apps", "build", ["uipath-coded-apps"]],
11657
+ ["data-fabric", "operate", ["uipath-data-fabric"]],
11658
+ ["cli", "troubleshoot", ["uipath-feedback"]],
11659
+ ["governance", "operate", ["uipath-governance"]],
11660
+ ["action-center", "build", ["uipath-human-in-the-loop"]],
11661
+ ["document-understanding", "build", ["uipath-ixp"]],
11662
+ [
11663
+ "maestro",
11664
+ "build",
11665
+ ["uipath-maestro-bpmn", "uipath-maestro-case", "uipath-maestro-flow"]
11666
+ ],
11667
+ ["agenthub", "build", ["uipath-mcp-servers"]],
11668
+ ["solution", "build", ["uipath-planner", "uipath-solution"]],
11669
+ ["platform", "operate", ["uipath-platform"]],
11670
+ ["quality", "troubleshoot", ["uipath-review"]],
11671
+ ["rpa", "build", ["uipath-rpa"]],
11672
+ ["cli", "operate", ["uipath-skill-catalog"]],
11673
+ ["action-center", "operate", ["uipath-tasks"]],
11674
+ ["test-manager", "operate", ["uipath-test"]],
11675
+ ["platform", "troubleshoot", ["uipath-troubleshoot"]]
11676
+ ]);
11677
+ var KNOWN_SKILL_NAMES = new Set(Object.keys(SKILL_ATTRIBUTION));
11678
+ var COMMAND_ATTRIBUTION = commandAttribution([
11679
+ ["cli", "troubleshoot", ["uip.feedback"]],
11680
+ ["llm-gateway", "operate", ["uip.llm-configuration", "uip.model-hub"]],
11681
+ ["context-grounding", "build", ["uip.context-grounding"]],
11682
+ ["api-workflow", "build", ["uip.api-workflow"]],
11683
+ ["rpa", "build", ["uip.rpa-legacy"]],
11684
+ ["conversational", "operate", ["uip.conversational"]],
11685
+ ["agents", "build", ["uip.codedagent", "uip.agent"]],
11686
+ ["agenthub", "build", ["uip.agenthub"]],
11687
+ ["coded-apps", "build", ["uip.codedapp"]],
11688
+ ["functions", "build", ["uip.functions"]],
11689
+ ["solution", "build", ["uip.solution"]],
11690
+ ["maestro", "build", ["uip.maestro", "uip.case", "uip.flow"]],
11691
+ ["llm-observability", "troubleshoot", ["uip.traces"]],
11692
+ ["platform", "operate", ["uip.platform"]],
11693
+ ["admin", "operate", ["uip.admin"]],
11694
+ ["automation-ops", "operate", ["uip.aops"]],
11695
+ ["documentation", "troubleshoot", ["uip.docsai"]],
11696
+ ["governance", "operate", ["uip.gov"]],
11697
+ ["insights", "operate", ["uip.insights"]],
11698
+ ["document-understanding", "build", ["uip.ixp"]],
11699
+ ["process-mining", "operate", ["uip.pm"]],
11700
+ ["action-center", "operate", ["uip.tasks"]],
11701
+ ["test-manager", "operate", ["uip.tm"]],
11702
+ ["vertical-solutions", "build", ["uip.vss"]],
11703
+ ["data-fabric", "operate", ["uip.df"]],
11704
+ ["integration-service", "build", ["uip.is"]],
11705
+ ["orchestrator", "operate", ["uip.or"]],
11706
+ [
11707
+ "cli",
11708
+ "operate",
11709
+ [
11710
+ "uip.login",
11711
+ "uip.logout",
11712
+ "uip.user",
11713
+ "uip.config",
11714
+ "uip.tools",
11715
+ "uip.skills",
11716
+ "uip.completion",
11717
+ "uip.update",
11718
+ "uip.mcp",
11719
+ "uip.track"
11720
+ ]
11721
+ ]
11722
+ ]).sort((a, b) => b.prefix.length - a.prefix.length);
11723
+ function normalizeCommandPath(value) {
11724
+ if (typeof value !== "string") {
11725
+ return;
11726
+ }
11727
+ const trimmed = value.trim().toLowerCase();
11728
+ if (!trimmed) {
11729
+ return;
11730
+ }
11731
+ const tokens = trimmed.includes(" ") ? trimmed.split(/\s+/).filter((token) => token.length > 0).filter((token) => !token.startsWith("-")) : trimmed.split(".").filter((token) => token.length > 0);
11732
+ if (tokens.length === 0) {
11733
+ return;
11734
+ }
11735
+ const commandTokens = tokens[0] === "uip" ? tokens : ["uip", ...tokens];
11736
+ return commandTokens.join(".");
11737
+ }
11738
+ function getCommandProductModeAttribution(commandPath) {
11739
+ const normalized = normalizeCommandPath(commandPath);
11740
+ if (!normalized) {
11741
+ return;
11742
+ }
11743
+ return COMMAND_ATTRIBUTION.find(({ prefix }) => normalized === prefix || normalized.startsWith(`${prefix}.`))?.attribution;
11744
+ }
11745
+ function normalizeSkillNameWithOptions(value, options) {
11746
+ if (typeof value !== "string") {
11747
+ return;
11748
+ }
11749
+ const normalized = value.trim().toLowerCase();
11750
+ if (!normalized) {
11751
+ return;
11752
+ }
11753
+ const hasLegacyNamespace = normalized.startsWith(LEGACY_SKILL_NAMESPACE);
11754
+ if (hasLegacyNamespace && !options.allowLegacyNamespace) {
11755
+ return;
11756
+ }
11757
+ const skillName = hasLegacyNamespace ? normalized.slice(LEGACY_SKILL_NAMESPACE.length) : normalized;
11758
+ if (skillName.length > MAX_SKILL_NAME_LENGTH || !SKILL_NAME_PATTERN.test(skillName) || !KNOWN_SKILL_NAMES.has(skillName)) {
11759
+ return;
11760
+ }
11761
+ return skillName;
11762
+ }
11763
+ function normalizeSkillName(value) {
11764
+ return normalizeSkillNameWithOptions(value, {
11765
+ allowLegacyNamespace: false
11766
+ });
11767
+ }
11768
+ function buildCommandTelemetryAttribution(commandPath, skillSource) {
11769
+ const skillName = normalizeSkillName(skillSource);
11770
+ return {
11771
+ ...skillName ? { skill_name: skillName } : {},
11772
+ ...getCommandProductModeAttribution(commandPath)
11773
+ };
11774
+ }
11138
11775
  var REDACTED = "[REDACTED]";
11139
11776
  var MAX_VALUE_LENGTH = 200;
11140
11777
  var SENSITIVE_NAME_TOKENS = new Set([
@@ -11309,6 +11946,12 @@ function commandHelpHint(commandPath) {
11309
11946
  const command = commandPath.replace(/\./g, " ");
11310
11947
  return `An unexpected error occurred. Run '${command} --help' to verify command syntax, or run with --log-level debug for details.`;
11311
11948
  }
11949
+ function isPromptCancellation(error) {
11950
+ return error instanceof Error && error.name === "ExitPromptError";
11951
+ }
11952
+ function exitCodeFromProcess(fallback) {
11953
+ return typeof process.exitCode === "number" ? process.exitCode : fallback;
11954
+ }
11312
11955
  Command2.prototype.trackedAction = function(context, fn, properties) {
11313
11956
  const command = this;
11314
11957
  return this.action(async (...args) => {
@@ -11316,6 +11959,8 @@ Command2.prototype.trackedAction = function(context, fn, properties) {
11316
11959
  const props = typeof properties === "function" ? properties(...args) : properties;
11317
11960
  const startTime = performance.now();
11318
11961
  let errorMessage;
11962
+ let fallbackExitCode = EXIT_CODES.Success;
11963
+ clearRecordedCommandFailureTelemetry();
11319
11964
  const [error] = await catchError(fn(...args));
11320
11965
  if (error) {
11321
11966
  errorMessage = error instanceof Error ? error.message : String(error);
@@ -11330,6 +11975,8 @@ Command2.prototype.trackedAction = function(context, fn, properties) {
11330
11975
  const customRetry = isRetryHint(typedRetry) ? typedRetry : undefined;
11331
11976
  const typedContext = typed.context ?? typed.Context;
11332
11977
  const customContext = isErrorContext(typedContext) ? typedContext : undefined;
11978
+ const cancellationExitCode = typed.exitCode === 130 || isPromptCancellation(error) ? 130 : undefined;
11979
+ fallbackExitCode = cancellationExitCode ?? EXIT_CODES[finalResult];
11333
11980
  OutputFormatter.error({
11334
11981
  Result: finalResult,
11335
11982
  ...customErrorCode ? { ErrorCode: customErrorCode } : {},
@@ -11338,16 +11985,26 @@ Command2.prototype.trackedAction = function(context, fn, properties) {
11338
11985
  ...customRetry ? { Retry: customRetry } : {},
11339
11986
  ...customContext ? { Context: customContext } : {}
11340
11987
  });
11341
- context.exit(EXIT_CODES[finalResult]);
11988
+ context.exit(fallbackExitCode);
11342
11989
  }
11343
11990
  const durationMs = performance.now() - startTime;
11344
- const success = !error && (process.exitCode === undefined || process.exitCode === 0);
11991
+ const exitCode = fallbackExitCode === 130 ? fallbackExitCode : exitCodeFromProcess(fallbackExitCode);
11992
+ const recordedFailure = takeRecordedCommandFailureTelemetry();
11993
+ const success = !error && exitCode === 0;
11994
+ const terminalTelemetry = buildCommandTerminalTelemetryProperties({
11995
+ error,
11996
+ exitCode,
11997
+ recordedFailure,
11998
+ pollSignal: context.pollSignal
11999
+ });
11345
12000
  telemetry.trackEvent(telemetryName, redactProperties({
11346
12001
  ...extractCommandParams(command),
11347
12002
  ...props,
12003
+ ...buildCommandTelemetryAttribution(telemetryName, process.env.UIPATH_SKILL),
11348
12004
  command: "true",
11349
12005
  duration: String(durationMs),
11350
12006
  success: String(success),
12007
+ ...terminalTelemetry,
11351
12008
  ...errorMessage ? { errorMessage } : {}
11352
12009
  }));
11353
12010
  });
@@ -11356,1436 +12013,46 @@ var guardInstalledSlot = singleton("ConsoleGuardInstalled");
11356
12013
  var savedOriginalsSlot = singleton("ConsoleGuardOriginals");
11357
12014
  var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
11358
12015
  var modeSlot = singleton("InteractivityMode");
11359
- class Hooks {
11360
- add(name, callback, first) {
11361
- if (typeof arguments[0] != "string") {
11362
- for (let name2 in arguments[0]) {
11363
- this.add(name2, arguments[0][name2], arguments[1]);
11364
- }
11365
- } else {
11366
- (Array.isArray(name) ? name : [name]).forEach(function(name2) {
11367
- this[name2] = this[name2] || [];
11368
- if (callback) {
11369
- this[name2][first ? "unshift" : "push"](callback);
11370
- }
11371
- }, this);
11372
- }
11373
- }
11374
- run(name, env) {
11375
- this[name] = this[name] || [];
11376
- this[name].forEach(function(callback) {
11377
- callback.call(env && env.context ? env.context : env, env);
11378
- });
11379
- }
11380
- }
11381
-
11382
- class Plugins {
11383
- constructor(jsep) {
11384
- this.jsep = jsep;
11385
- this.registered = {};
11386
- }
11387
- register(...plugins) {
11388
- plugins.forEach((plugin) => {
11389
- if (typeof plugin !== "object" || !plugin.name || !plugin.init) {
11390
- throw new Error("Invalid JSEP plugin format");
11391
- }
11392
- if (this.registered[plugin.name]) {
11393
- return;
11394
- }
11395
- plugin.init(this.jsep);
11396
- this.registered[plugin.name] = plugin;
11397
- });
11398
- }
12016
+ var PollOutcome = {
12017
+ Completed: "completed",
12018
+ Timeout: "timeout",
12019
+ Interrupted: "interrupted",
12020
+ Aborted: "aborted",
12021
+ Failed: "failed"
12022
+ };
12023
+ var REASON_BY_OUTCOME = {
12024
+ [PollOutcome.Timeout]: "poll_timeout",
12025
+ [PollOutcome.Failed]: "poll_failed",
12026
+ [PollOutcome.Interrupted]: "poll_failed",
12027
+ [PollOutcome.Aborted]: "poll_aborted"
12028
+ };
12029
+ var TERMINAL_STATUSES = new Set([
12030
+ "completed",
12031
+ "successful",
12032
+ "faulted",
12033
+ "failed",
12034
+ "cancelled",
12035
+ "canceled",
12036
+ "stopped",
12037
+ "finished"
12038
+ ]);
12039
+ var FAILURE_STATUSES = new Set([
12040
+ "faulted",
12041
+ "failed",
12042
+ "cancelled",
12043
+ "canceled",
12044
+ "stopped"
12045
+ ]);
12046
+ var previewSlot = singleton("PreviewBuild");
12047
+ function isPreviewBuild() {
12048
+ return previewSlot.get(false) ?? false;
11399
12049
  }
11400
-
11401
- class Jsep {
11402
- static get version() {
11403
- return "1.4.0";
11404
- }
11405
- static toString() {
11406
- return "JavaScript Expression Parser (JSEP) v" + Jsep.version;
11407
- }
11408
- static addUnaryOp(op_name) {
11409
- Jsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);
11410
- Jsep.unary_ops[op_name] = 1;
11411
- return Jsep;
11412
- }
11413
- static addBinaryOp(op_name, precedence, isRightAssociative) {
11414
- Jsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);
11415
- Jsep.binary_ops[op_name] = precedence;
11416
- if (isRightAssociative) {
11417
- Jsep.right_associative.add(op_name);
11418
- } else {
11419
- Jsep.right_associative.delete(op_name);
11420
- }
11421
- return Jsep;
11422
- }
11423
- static addIdentifierChar(char) {
11424
- Jsep.additional_identifier_chars.add(char);
11425
- return Jsep;
11426
- }
11427
- static addLiteral(literal_name, literal_value) {
11428
- Jsep.literals[literal_name] = literal_value;
11429
- return Jsep;
11430
- }
11431
- static removeUnaryOp(op_name) {
11432
- delete Jsep.unary_ops[op_name];
11433
- if (op_name.length === Jsep.max_unop_len) {
11434
- Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
11435
- }
11436
- return Jsep;
11437
- }
11438
- static removeAllUnaryOps() {
11439
- Jsep.unary_ops = {};
11440
- Jsep.max_unop_len = 0;
11441
- return Jsep;
11442
- }
11443
- static removeIdentifierChar(char) {
11444
- Jsep.additional_identifier_chars.delete(char);
11445
- return Jsep;
11446
- }
11447
- static removeBinaryOp(op_name) {
11448
- delete Jsep.binary_ops[op_name];
11449
- if (op_name.length === Jsep.max_binop_len) {
11450
- Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
11451
- }
11452
- Jsep.right_associative.delete(op_name);
11453
- return Jsep;
11454
- }
11455
- static removeAllBinaryOps() {
11456
- Jsep.binary_ops = {};
11457
- Jsep.max_binop_len = 0;
11458
- return Jsep;
11459
- }
11460
- static removeLiteral(literal_name) {
11461
- delete Jsep.literals[literal_name];
11462
- return Jsep;
12050
+ Command2.prototype.previewCommand = function(nameAndArgs, opts) {
12051
+ if (isPreviewBuild()) {
12052
+ return this.command(nameAndArgs, opts);
11463
12053
  }
11464
- static removeAllLiterals() {
11465
- Jsep.literals = {};
11466
- return Jsep;
11467
- }
11468
- get char() {
11469
- return this.expr.charAt(this.index);
11470
- }
11471
- get code() {
11472
- return this.expr.charCodeAt(this.index);
11473
- }
11474
- constructor(expr) {
11475
- this.expr = expr;
11476
- this.index = 0;
11477
- }
11478
- static parse(expr) {
11479
- return new Jsep(expr).parse();
11480
- }
11481
- static getMaxKeyLen(obj) {
11482
- return Math.max(0, ...Object.keys(obj).map((k) => k.length));
11483
- }
11484
- static isDecimalDigit(ch) {
11485
- return ch >= 48 && ch <= 57;
11486
- }
11487
- static binaryPrecedence(op_val) {
11488
- return Jsep.binary_ops[op_val] || 0;
11489
- }
11490
- static isIdentifierStart(ch) {
11491
- return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 128 && !Jsep.binary_ops[String.fromCharCode(ch)] || Jsep.additional_identifier_chars.has(String.fromCharCode(ch));
11492
- }
11493
- static isIdentifierPart(ch) {
11494
- return Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);
11495
- }
11496
- throwError(message) {
11497
- const error = new Error(message + " at character " + this.index);
11498
- error.index = this.index;
11499
- error.description = message;
11500
- throw error;
11501
- }
11502
- runHook(name, node) {
11503
- if (Jsep.hooks[name]) {
11504
- const env = {
11505
- context: this,
11506
- node
11507
- };
11508
- Jsep.hooks.run(name, env);
11509
- return env.node;
11510
- }
11511
- return node;
11512
- }
11513
- searchHook(name) {
11514
- if (Jsep.hooks[name]) {
11515
- const env = {
11516
- context: this
11517
- };
11518
- Jsep.hooks[name].find(function(callback) {
11519
- callback.call(env.context, env);
11520
- return env.node;
11521
- });
11522
- return env.node;
11523
- }
11524
- }
11525
- gobbleSpaces() {
11526
- let ch = this.code;
11527
- while (ch === Jsep.SPACE_CODE || ch === Jsep.TAB_CODE || ch === Jsep.LF_CODE || ch === Jsep.CR_CODE) {
11528
- ch = this.expr.charCodeAt(++this.index);
11529
- }
11530
- this.runHook("gobble-spaces");
11531
- }
11532
- parse() {
11533
- this.runHook("before-all");
11534
- const nodes = this.gobbleExpressions();
11535
- const node = nodes.length === 1 ? nodes[0] : {
11536
- type: Jsep.COMPOUND,
11537
- body: nodes
11538
- };
11539
- return this.runHook("after-all", node);
11540
- }
11541
- gobbleExpressions(untilICode) {
11542
- let nodes = [], ch_i, node;
11543
- while (this.index < this.expr.length) {
11544
- ch_i = this.code;
11545
- if (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {
11546
- this.index++;
11547
- } else {
11548
- if (node = this.gobbleExpression()) {
11549
- nodes.push(node);
11550
- } else if (this.index < this.expr.length) {
11551
- if (ch_i === untilICode) {
11552
- break;
11553
- }
11554
- this.throwError('Unexpected "' + this.char + '"');
11555
- }
11556
- }
11557
- }
11558
- return nodes;
11559
- }
11560
- gobbleExpression() {
11561
- const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
11562
- this.gobbleSpaces();
11563
- return this.runHook("after-expression", node);
11564
- }
11565
- gobbleBinaryOp() {
11566
- this.gobbleSpaces();
11567
- let to_check = this.expr.substr(this.index, Jsep.max_binop_len);
11568
- let tc_len = to_check.length;
11569
- while (tc_len > 0) {
11570
- if (Jsep.binary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
11571
- this.index += tc_len;
11572
- return to_check;
11573
- }
11574
- to_check = to_check.substr(0, --tc_len);
11575
- }
11576
- return false;
11577
- }
11578
- gobbleBinaryExpression() {
11579
- let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
11580
- left = this.gobbleToken();
11581
- if (!left) {
11582
- return left;
11583
- }
11584
- biop = this.gobbleBinaryOp();
11585
- if (!biop) {
11586
- return left;
11587
- }
11588
- biop_info = {
11589
- value: biop,
11590
- prec: Jsep.binaryPrecedence(biop),
11591
- right_a: Jsep.right_associative.has(biop)
11592
- };
11593
- right = this.gobbleToken();
11594
- if (!right) {
11595
- this.throwError("Expected expression after " + biop);
11596
- }
11597
- stack = [left, biop_info, right];
11598
- while (biop = this.gobbleBinaryOp()) {
11599
- prec = Jsep.binaryPrecedence(biop);
11600
- if (prec === 0) {
11601
- this.index -= biop.length;
11602
- break;
11603
- }
11604
- biop_info = {
11605
- value: biop,
11606
- prec,
11607
- right_a: Jsep.right_associative.has(biop)
11608
- };
11609
- cur_biop = biop;
11610
- const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
11611
- while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
11612
- right = stack.pop();
11613
- biop = stack.pop().value;
11614
- left = stack.pop();
11615
- node = {
11616
- type: Jsep.BINARY_EXP,
11617
- operator: biop,
11618
- left,
11619
- right
11620
- };
11621
- stack.push(node);
11622
- }
11623
- node = this.gobbleToken();
11624
- if (!node) {
11625
- this.throwError("Expected expression after " + cur_biop);
11626
- }
11627
- stack.push(biop_info, node);
11628
- }
11629
- i = stack.length - 1;
11630
- node = stack[i];
11631
- while (i > 1) {
11632
- node = {
11633
- type: Jsep.BINARY_EXP,
11634
- operator: stack[i - 1].value,
11635
- left: stack[i - 2],
11636
- right: node
11637
- };
11638
- i -= 2;
11639
- }
11640
- return node;
11641
- }
11642
- gobbleToken() {
11643
- let ch, to_check, tc_len, node;
11644
- this.gobbleSpaces();
11645
- node = this.searchHook("gobble-token");
11646
- if (node) {
11647
- return this.runHook("after-token", node);
11648
- }
11649
- ch = this.code;
11650
- if (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {
11651
- return this.gobbleNumericLiteral();
11652
- }
11653
- if (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {
11654
- node = this.gobbleStringLiteral();
11655
- } else if (ch === Jsep.OBRACK_CODE) {
11656
- node = this.gobbleArray();
11657
- } else {
11658
- to_check = this.expr.substr(this.index, Jsep.max_unop_len);
11659
- tc_len = to_check.length;
11660
- while (tc_len > 0) {
11661
- if (Jsep.unary_ops.hasOwnProperty(to_check) && (!Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
11662
- this.index += tc_len;
11663
- const argument = this.gobbleToken();
11664
- if (!argument) {
11665
- this.throwError("missing unaryOp argument");
11666
- }
11667
- return this.runHook("after-token", {
11668
- type: Jsep.UNARY_EXP,
11669
- operator: to_check,
11670
- argument,
11671
- prefix: true
11672
- });
11673
- }
11674
- to_check = to_check.substr(0, --tc_len);
11675
- }
11676
- if (Jsep.isIdentifierStart(ch)) {
11677
- node = this.gobbleIdentifier();
11678
- if (Jsep.literals.hasOwnProperty(node.name)) {
11679
- node = {
11680
- type: Jsep.LITERAL,
11681
- value: Jsep.literals[node.name],
11682
- raw: node.name
11683
- };
11684
- } else if (node.name === Jsep.this_str) {
11685
- node = {
11686
- type: Jsep.THIS_EXP
11687
- };
11688
- }
11689
- } else if (ch === Jsep.OPAREN_CODE) {
11690
- node = this.gobbleGroup();
11691
- }
11692
- }
11693
- if (!node) {
11694
- return this.runHook("after-token", false);
11695
- }
11696
- node = this.gobbleTokenProperty(node);
11697
- return this.runHook("after-token", node);
11698
- }
11699
- gobbleTokenProperty(node) {
11700
- this.gobbleSpaces();
11701
- let ch = this.code;
11702
- while (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {
11703
- let optional;
11704
- if (ch === Jsep.QUMARK_CODE) {
11705
- if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {
11706
- break;
11707
- }
11708
- optional = true;
11709
- this.index += 2;
11710
- this.gobbleSpaces();
11711
- ch = this.code;
11712
- }
11713
- this.index++;
11714
- if (ch === Jsep.OBRACK_CODE) {
11715
- node = {
11716
- type: Jsep.MEMBER_EXP,
11717
- computed: true,
11718
- object: node,
11719
- property: this.gobbleExpression()
11720
- };
11721
- if (!node.property) {
11722
- this.throwError('Unexpected "' + this.char + '"');
11723
- }
11724
- this.gobbleSpaces();
11725
- ch = this.code;
11726
- if (ch !== Jsep.CBRACK_CODE) {
11727
- this.throwError("Unclosed [");
11728
- }
11729
- this.index++;
11730
- } else if (ch === Jsep.OPAREN_CODE) {
11731
- node = {
11732
- type: Jsep.CALL_EXP,
11733
- arguments: this.gobbleArguments(Jsep.CPAREN_CODE),
11734
- callee: node
11735
- };
11736
- } else if (ch === Jsep.PERIOD_CODE || optional) {
11737
- if (optional) {
11738
- this.index--;
11739
- }
11740
- this.gobbleSpaces();
11741
- node = {
11742
- type: Jsep.MEMBER_EXP,
11743
- computed: false,
11744
- object: node,
11745
- property: this.gobbleIdentifier()
11746
- };
11747
- }
11748
- if (optional) {
11749
- node.optional = true;
11750
- }
11751
- this.gobbleSpaces();
11752
- ch = this.code;
11753
- }
11754
- return node;
11755
- }
11756
- gobbleNumericLiteral() {
11757
- let number = "", ch, chCode;
11758
- while (Jsep.isDecimalDigit(this.code)) {
11759
- number += this.expr.charAt(this.index++);
11760
- }
11761
- if (this.code === Jsep.PERIOD_CODE) {
11762
- number += this.expr.charAt(this.index++);
11763
- while (Jsep.isDecimalDigit(this.code)) {
11764
- number += this.expr.charAt(this.index++);
11765
- }
11766
- }
11767
- ch = this.char;
11768
- if (ch === "e" || ch === "E") {
11769
- number += this.expr.charAt(this.index++);
11770
- ch = this.char;
11771
- if (ch === "+" || ch === "-") {
11772
- number += this.expr.charAt(this.index++);
11773
- }
11774
- while (Jsep.isDecimalDigit(this.code)) {
11775
- number += this.expr.charAt(this.index++);
11776
- }
11777
- if (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
11778
- this.throwError("Expected exponent (" + number + this.char + ")");
11779
- }
11780
- }
11781
- chCode = this.code;
11782
- if (Jsep.isIdentifierStart(chCode)) {
11783
- this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
11784
- } else if (chCode === Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE) {
11785
- this.throwError("Unexpected period");
11786
- }
11787
- return {
11788
- type: Jsep.LITERAL,
11789
- value: parseFloat(number),
11790
- raw: number
11791
- };
11792
- }
11793
- gobbleStringLiteral() {
11794
- let str = "";
11795
- const startIndex = this.index;
11796
- const quote = this.expr.charAt(this.index++);
11797
- let closed = false;
11798
- while (this.index < this.expr.length) {
11799
- let ch = this.expr.charAt(this.index++);
11800
- if (ch === quote) {
11801
- closed = true;
11802
- break;
11803
- } else if (ch === "\\") {
11804
- ch = this.expr.charAt(this.index++);
11805
- switch (ch) {
11806
- case "n":
11807
- str += `
11808
- `;
11809
- break;
11810
- case "r":
11811
- str += "\r";
11812
- break;
11813
- case "t":
11814
- str += "\t";
11815
- break;
11816
- case "b":
11817
- str += "\b";
11818
- break;
11819
- case "f":
11820
- str += "\f";
11821
- break;
11822
- case "v":
11823
- str += "\v";
11824
- break;
11825
- default:
11826
- str += ch;
11827
- }
11828
- } else {
11829
- str += ch;
11830
- }
11831
- }
11832
- if (!closed) {
11833
- this.throwError('Unclosed quote after "' + str + '"');
11834
- }
11835
- return {
11836
- type: Jsep.LITERAL,
11837
- value: str,
11838
- raw: this.expr.substring(startIndex, this.index)
11839
- };
11840
- }
11841
- gobbleIdentifier() {
11842
- let ch = this.code, start = this.index;
11843
- if (Jsep.isIdentifierStart(ch)) {
11844
- this.index++;
11845
- } else {
11846
- this.throwError("Unexpected " + this.char);
11847
- }
11848
- while (this.index < this.expr.length) {
11849
- ch = this.code;
11850
- if (Jsep.isIdentifierPart(ch)) {
11851
- this.index++;
11852
- } else {
11853
- break;
11854
- }
11855
- }
11856
- return {
11857
- type: Jsep.IDENTIFIER,
11858
- name: this.expr.slice(start, this.index)
11859
- };
11860
- }
11861
- gobbleArguments(termination) {
11862
- const args = [];
11863
- let closed = false;
11864
- let separator_count = 0;
11865
- while (this.index < this.expr.length) {
11866
- this.gobbleSpaces();
11867
- let ch_i = this.code;
11868
- if (ch_i === termination) {
11869
- closed = true;
11870
- this.index++;
11871
- if (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
11872
- this.throwError("Unexpected token " + String.fromCharCode(termination));
11873
- }
11874
- break;
11875
- } else if (ch_i === Jsep.COMMA_CODE) {
11876
- this.index++;
11877
- separator_count++;
11878
- if (separator_count !== args.length) {
11879
- if (termination === Jsep.CPAREN_CODE) {
11880
- this.throwError("Unexpected token ,");
11881
- } else if (termination === Jsep.CBRACK_CODE) {
11882
- for (let arg = args.length;arg < separator_count; arg++) {
11883
- args.push(null);
11884
- }
11885
- }
11886
- }
11887
- } else if (args.length !== separator_count && separator_count !== 0) {
11888
- this.throwError("Expected comma");
11889
- } else {
11890
- const node = this.gobbleExpression();
11891
- if (!node || node.type === Jsep.COMPOUND) {
11892
- this.throwError("Expected comma");
11893
- }
11894
- args.push(node);
11895
- }
11896
- }
11897
- if (!closed) {
11898
- this.throwError("Expected " + String.fromCharCode(termination));
11899
- }
11900
- return args;
11901
- }
11902
- gobbleGroup() {
11903
- this.index++;
11904
- let nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);
11905
- if (this.code === Jsep.CPAREN_CODE) {
11906
- this.index++;
11907
- if (nodes.length === 1) {
11908
- return nodes[0];
11909
- } else if (!nodes.length) {
11910
- return false;
11911
- } else {
11912
- return {
11913
- type: Jsep.SEQUENCE_EXP,
11914
- expressions: nodes
11915
- };
11916
- }
11917
- } else {
11918
- this.throwError("Unclosed (");
11919
- }
11920
- }
11921
- gobbleArray() {
11922
- this.index++;
11923
- return {
11924
- type: Jsep.ARRAY_EXP,
11925
- elements: this.gobbleArguments(Jsep.CBRACK_CODE)
11926
- };
11927
- }
11928
- }
11929
- var hooks = new Hooks;
11930
- Object.assign(Jsep, {
11931
- hooks,
11932
- plugins: new Plugins(Jsep),
11933
- COMPOUND: "Compound",
11934
- SEQUENCE_EXP: "SequenceExpression",
11935
- IDENTIFIER: "Identifier",
11936
- MEMBER_EXP: "MemberExpression",
11937
- LITERAL: "Literal",
11938
- THIS_EXP: "ThisExpression",
11939
- CALL_EXP: "CallExpression",
11940
- UNARY_EXP: "UnaryExpression",
11941
- BINARY_EXP: "BinaryExpression",
11942
- ARRAY_EXP: "ArrayExpression",
11943
- TAB_CODE: 9,
11944
- LF_CODE: 10,
11945
- CR_CODE: 13,
11946
- SPACE_CODE: 32,
11947
- PERIOD_CODE: 46,
11948
- COMMA_CODE: 44,
11949
- SQUOTE_CODE: 39,
11950
- DQUOTE_CODE: 34,
11951
- OPAREN_CODE: 40,
11952
- CPAREN_CODE: 41,
11953
- OBRACK_CODE: 91,
11954
- CBRACK_CODE: 93,
11955
- QUMARK_CODE: 63,
11956
- SEMCOL_CODE: 59,
11957
- COLON_CODE: 58,
11958
- unary_ops: {
11959
- "-": 1,
11960
- "!": 1,
11961
- "~": 1,
11962
- "+": 1
11963
- },
11964
- binary_ops: {
11965
- "||": 1,
11966
- "??": 1,
11967
- "&&": 2,
11968
- "|": 3,
11969
- "^": 4,
11970
- "&": 5,
11971
- "==": 6,
11972
- "!=": 6,
11973
- "===": 6,
11974
- "!==": 6,
11975
- "<": 7,
11976
- ">": 7,
11977
- "<=": 7,
11978
- ">=": 7,
11979
- "<<": 8,
11980
- ">>": 8,
11981
- ">>>": 8,
11982
- "+": 9,
11983
- "-": 9,
11984
- "*": 10,
11985
- "/": 10,
11986
- "%": 10,
11987
- "**": 11
11988
- },
11989
- right_associative: new Set(["**"]),
11990
- additional_identifier_chars: new Set(["$", "_"]),
11991
- literals: {
11992
- true: true,
11993
- false: false,
11994
- null: null
11995
- },
11996
- this_str: "this"
11997
- });
11998
- Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
11999
- Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
12000
- var jsep = (expr) => new Jsep(expr).parse();
12001
- var stdClassProps = Object.getOwnPropertyNames(class Test {
12002
- });
12003
- Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === undefined).forEach((m) => {
12004
- jsep[m] = Jsep[m];
12005
- });
12006
- jsep.Jsep = Jsep;
12007
- var CONDITIONAL_EXP = "ConditionalExpression";
12008
- var ternary = {
12009
- name: "ternary",
12010
- init(jsep2) {
12011
- jsep2.hooks.add("after-expression", function gobbleTernary(env) {
12012
- if (env.node && this.code === jsep2.QUMARK_CODE) {
12013
- this.index++;
12014
- const test = env.node;
12015
- const consequent = this.gobbleExpression();
12016
- if (!consequent) {
12017
- this.throwError("Expected expression");
12018
- }
12019
- this.gobbleSpaces();
12020
- if (this.code === jsep2.COLON_CODE) {
12021
- this.index++;
12022
- const alternate = this.gobbleExpression();
12023
- if (!alternate) {
12024
- this.throwError("Expected expression");
12025
- }
12026
- env.node = {
12027
- type: CONDITIONAL_EXP,
12028
- test,
12029
- consequent,
12030
- alternate
12031
- };
12032
- if (test.operator && jsep2.binary_ops[test.operator] <= 0.9) {
12033
- let newTest = test;
12034
- while (newTest.right.operator && jsep2.binary_ops[newTest.right.operator] <= 0.9) {
12035
- newTest = newTest.right;
12036
- }
12037
- env.node.test = newTest.right;
12038
- newTest.right = env.node;
12039
- env.node = test;
12040
- }
12041
- } else {
12042
- this.throwError("Expected :");
12043
- }
12044
- }
12045
- });
12046
- }
12047
- };
12048
- jsep.plugins.register(ternary);
12049
- var FSLASH_CODE = 47;
12050
- var BSLASH_CODE = 92;
12051
- var index = {
12052
- name: "regex",
12053
- init(jsep2) {
12054
- jsep2.hooks.add("gobble-token", function gobbleRegexLiteral(env) {
12055
- if (this.code === FSLASH_CODE) {
12056
- const patternIndex = ++this.index;
12057
- let inCharSet = false;
12058
- while (this.index < this.expr.length) {
12059
- if (this.code === FSLASH_CODE && !inCharSet) {
12060
- const pattern = this.expr.slice(patternIndex, this.index);
12061
- let flags = "";
12062
- while (++this.index < this.expr.length) {
12063
- const code = this.code;
12064
- if (code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57) {
12065
- flags += this.char;
12066
- } else {
12067
- break;
12068
- }
12069
- }
12070
- let value;
12071
- try {
12072
- value = new RegExp(pattern, flags);
12073
- } catch (e) {
12074
- this.throwError(e.message);
12075
- }
12076
- env.node = {
12077
- type: jsep2.LITERAL,
12078
- value,
12079
- raw: this.expr.slice(patternIndex - 1, this.index)
12080
- };
12081
- env.node = this.gobbleTokenProperty(env.node);
12082
- return env.node;
12083
- }
12084
- if (this.code === jsep2.OBRACK_CODE) {
12085
- inCharSet = true;
12086
- } else if (inCharSet && this.code === jsep2.CBRACK_CODE) {
12087
- inCharSet = false;
12088
- }
12089
- this.index += this.code === BSLASH_CODE ? 2 : 1;
12090
- }
12091
- this.throwError("Unclosed Regex");
12092
- }
12093
- });
12094
- }
12095
- };
12096
- var PLUS_CODE = 43;
12097
- var MINUS_CODE = 45;
12098
- var plugin = {
12099
- name: "assignment",
12100
- assignmentOperators: new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|=", "||=", "&&=", "??="]),
12101
- updateOperators: [PLUS_CODE, MINUS_CODE],
12102
- assignmentPrecedence: 0.9,
12103
- init(jsep2) {
12104
- const updateNodeTypes = [jsep2.IDENTIFIER, jsep2.MEMBER_EXP];
12105
- plugin.assignmentOperators.forEach((op) => jsep2.addBinaryOp(op, plugin.assignmentPrecedence, true));
12106
- jsep2.hooks.add("gobble-token", function gobbleUpdatePrefix(env) {
12107
- const code = this.code;
12108
- if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
12109
- this.index += 2;
12110
- env.node = {
12111
- type: "UpdateExpression",
12112
- operator: code === PLUS_CODE ? "++" : "--",
12113
- argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
12114
- prefix: true
12115
- };
12116
- if (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {
12117
- this.throwError(`Unexpected ${env.node.operator}`);
12118
- }
12119
- }
12120
- });
12121
- jsep2.hooks.add("after-token", function gobbleUpdatePostfix(env) {
12122
- if (env.node) {
12123
- const code = this.code;
12124
- if (plugin.updateOperators.some((c) => c === code && c === this.expr.charCodeAt(this.index + 1))) {
12125
- if (!updateNodeTypes.includes(env.node.type)) {
12126
- this.throwError(`Unexpected ${env.node.operator}`);
12127
- }
12128
- this.index += 2;
12129
- env.node = {
12130
- type: "UpdateExpression",
12131
- operator: code === PLUS_CODE ? "++" : "--",
12132
- argument: env.node,
12133
- prefix: false
12134
- };
12135
- }
12136
- }
12137
- });
12138
- jsep2.hooks.add("after-expression", function gobbleAssignment(env) {
12139
- if (env.node) {
12140
- updateBinariesToAssignments(env.node);
12141
- }
12142
- });
12143
- function updateBinariesToAssignments(node) {
12144
- if (plugin.assignmentOperators.has(node.operator)) {
12145
- node.type = "AssignmentExpression";
12146
- updateBinariesToAssignments(node.left);
12147
- updateBinariesToAssignments(node.right);
12148
- } else if (!node.operator) {
12149
- Object.values(node).forEach((val) => {
12150
- if (val && typeof val === "object") {
12151
- updateBinariesToAssignments(val);
12152
- }
12153
- });
12154
- }
12155
- }
12156
- }
12157
- };
12158
- jsep.plugins.register(index, plugin);
12159
- jsep.addUnaryOp("typeof");
12160
- jsep.addUnaryOp("void");
12161
- jsep.addLiteral("null", null);
12162
- jsep.addLiteral("undefined", undefined);
12163
- var BLOCKED_PROTO_PROPERTIES = new Set(["constructor", "__proto__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"]);
12164
- var SafeEval = {
12165
- evalAst(ast, subs) {
12166
- switch (ast.type) {
12167
- case "BinaryExpression":
12168
- case "LogicalExpression":
12169
- return SafeEval.evalBinaryExpression(ast, subs);
12170
- case "Compound":
12171
- return SafeEval.evalCompound(ast, subs);
12172
- case "ConditionalExpression":
12173
- return SafeEval.evalConditionalExpression(ast, subs);
12174
- case "Identifier":
12175
- return SafeEval.evalIdentifier(ast, subs);
12176
- case "Literal":
12177
- return SafeEval.evalLiteral(ast, subs);
12178
- case "MemberExpression":
12179
- return SafeEval.evalMemberExpression(ast, subs);
12180
- case "UnaryExpression":
12181
- return SafeEval.evalUnaryExpression(ast, subs);
12182
- case "ArrayExpression":
12183
- return SafeEval.evalArrayExpression(ast, subs);
12184
- case "CallExpression":
12185
- return SafeEval.evalCallExpression(ast, subs);
12186
- case "AssignmentExpression":
12187
- return SafeEval.evalAssignmentExpression(ast, subs);
12188
- default:
12189
- throw SyntaxError("Unexpected expression", ast);
12190
- }
12191
- },
12192
- evalBinaryExpression(ast, subs) {
12193
- const result = {
12194
- "||": (a, b) => a || b(),
12195
- "&&": (a, b) => a && b(),
12196
- "|": (a, b) => a | b(),
12197
- "^": (a, b) => a ^ b(),
12198
- "&": (a, b) => a & b(),
12199
- "==": (a, b) => a == b(),
12200
- "!=": (a, b) => a != b(),
12201
- "===": (a, b) => a === b(),
12202
- "!==": (a, b) => a !== b(),
12203
- "<": (a, b) => a < b(),
12204
- ">": (a, b) => a > b(),
12205
- "<=": (a, b) => a <= b(),
12206
- ">=": (a, b) => a >= b(),
12207
- "<<": (a, b) => a << b(),
12208
- ">>": (a, b) => a >> b(),
12209
- ">>>": (a, b) => a >>> b(),
12210
- "+": (a, b) => a + b(),
12211
- "-": (a, b) => a - b(),
12212
- "*": (a, b) => a * b(),
12213
- "/": (a, b) => a / b(),
12214
- "%": (a, b) => a % b()
12215
- }[ast.operator](SafeEval.evalAst(ast.left, subs), () => SafeEval.evalAst(ast.right, subs));
12216
- return result;
12217
- },
12218
- evalCompound(ast, subs) {
12219
- let last;
12220
- for (let i = 0;i < ast.body.length; i++) {
12221
- if (ast.body[i].type === "Identifier" && ["var", "let", "const"].includes(ast.body[i].name) && ast.body[i + 1] && ast.body[i + 1].type === "AssignmentExpression") {
12222
- i += 1;
12223
- }
12224
- const expr = ast.body[i];
12225
- last = SafeEval.evalAst(expr, subs);
12226
- }
12227
- return last;
12228
- },
12229
- evalConditionalExpression(ast, subs) {
12230
- if (SafeEval.evalAst(ast.test, subs)) {
12231
- return SafeEval.evalAst(ast.consequent, subs);
12232
- }
12233
- return SafeEval.evalAst(ast.alternate, subs);
12234
- },
12235
- evalIdentifier(ast, subs) {
12236
- if (Object.hasOwn(subs, ast.name)) {
12237
- return subs[ast.name];
12238
- }
12239
- throw ReferenceError(`${ast.name} is not defined`);
12240
- },
12241
- evalLiteral(ast) {
12242
- return ast.value;
12243
- },
12244
- evalMemberExpression(ast, subs) {
12245
- const prop = String(ast.computed ? SafeEval.evalAst(ast.property) : ast.property.name);
12246
- const obj = SafeEval.evalAst(ast.object, subs);
12247
- if (obj === undefined || obj === null) {
12248
- throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
12249
- }
12250
- if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {
12251
- throw TypeError(`Cannot read properties of ${obj} (reading '${prop}')`);
12252
- }
12253
- const result = obj[prop];
12254
- if (typeof result === "function") {
12255
- return result.bind(obj);
12256
- }
12257
- return result;
12258
- },
12259
- evalUnaryExpression(ast, subs) {
12260
- const result = {
12261
- "-": (a) => -SafeEval.evalAst(a, subs),
12262
- "!": (a) => !SafeEval.evalAst(a, subs),
12263
- "~": (a) => ~SafeEval.evalAst(a, subs),
12264
- "+": (a) => +SafeEval.evalAst(a, subs),
12265
- typeof: (a) => typeof SafeEval.evalAst(a, subs),
12266
- void: (a) => void SafeEval.evalAst(a, subs)
12267
- }[ast.operator](ast.argument);
12268
- return result;
12269
- },
12270
- evalArrayExpression(ast, subs) {
12271
- return ast.elements.map((el) => SafeEval.evalAst(el, subs));
12272
- },
12273
- evalCallExpression(ast, subs) {
12274
- const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));
12275
- const func = SafeEval.evalAst(ast.callee, subs);
12276
- if (func === Function) {
12277
- throw new Error("Function constructor is disabled");
12278
- }
12279
- return func(...args);
12280
- },
12281
- evalAssignmentExpression(ast, subs) {
12282
- if (ast.left.type !== "Identifier") {
12283
- throw SyntaxError("Invalid left-hand side in assignment");
12284
- }
12285
- const id = ast.left.name;
12286
- const value = SafeEval.evalAst(ast.right, subs);
12287
- subs[id] = value;
12288
- return subs[id];
12289
- }
12290
- };
12291
-
12292
- class SafeScript {
12293
- constructor(expr) {
12294
- this.code = expr;
12295
- this.ast = jsep(this.code);
12296
- }
12297
- runInNewContext(context) {
12298
- const keyMap = Object.assign(Object.create(null), context);
12299
- return SafeEval.evalAst(this.ast, keyMap);
12300
- }
12301
- }
12302
- function push(arr, item) {
12303
- arr = arr.slice();
12304
- arr.push(item);
12305
- return arr;
12306
- }
12307
- function unshift(item, arr) {
12308
- arr = arr.slice();
12309
- arr.unshift(item);
12310
- return arr;
12311
- }
12312
-
12313
- class NewError extends Error {
12314
- constructor(value) {
12315
- super('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');
12316
- this.avoidNew = true;
12317
- this.value = value;
12318
- this.name = "NewError";
12319
- }
12320
- }
12321
- function JSONPath(opts, expr, obj, callback, otherTypeCallback) {
12322
- if (!(this instanceof JSONPath)) {
12323
- try {
12324
- return new JSONPath(opts, expr, obj, callback, otherTypeCallback);
12325
- } catch (e) {
12326
- if (!e.avoidNew) {
12327
- throw e;
12328
- }
12329
- return e.value;
12330
- }
12331
- }
12332
- if (typeof opts === "string") {
12333
- otherTypeCallback = callback;
12334
- callback = obj;
12335
- obj = expr;
12336
- expr = opts;
12337
- opts = null;
12338
- }
12339
- const optObj = opts && typeof opts === "object";
12340
- opts = opts || {};
12341
- this.json = opts.json || obj;
12342
- this.path = opts.path || expr;
12343
- this.resultType = opts.resultType || "value";
12344
- this.flatten = opts.flatten || false;
12345
- this.wrap = Object.hasOwn(opts, "wrap") ? opts.wrap : true;
12346
- this.sandbox = opts.sandbox || {};
12347
- this.eval = opts.eval === undefined ? "safe" : opts.eval;
12348
- this.ignoreEvalErrors = typeof opts.ignoreEvalErrors === "undefined" ? false : opts.ignoreEvalErrors;
12349
- this.parent = opts.parent || null;
12350
- this.parentProperty = opts.parentProperty || null;
12351
- this.callback = opts.callback || callback || null;
12352
- this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function() {
12353
- throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.");
12354
- };
12355
- if (opts.autostart !== false) {
12356
- const args = {
12357
- path: optObj ? opts.path : expr
12358
- };
12359
- if (!optObj) {
12360
- args.json = obj;
12361
- } else if ("json" in opts) {
12362
- args.json = opts.json;
12363
- }
12364
- const ret = this.evaluate(args);
12365
- if (!ret || typeof ret !== "object") {
12366
- throw new NewError(ret);
12367
- }
12368
- return ret;
12369
- }
12370
- }
12371
- JSONPath.prototype.evaluate = function(expr, json, callback, otherTypeCallback) {
12372
- let currParent = this.parent, currParentProperty = this.parentProperty;
12373
- let {
12374
- flatten,
12375
- wrap
12376
- } = this;
12377
- this.currResultType = this.resultType;
12378
- this.currEval = this.eval;
12379
- this.currSandbox = this.sandbox;
12380
- callback = callback || this.callback;
12381
- this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback;
12382
- json = json || this.json;
12383
- expr = expr || this.path;
12384
- if (expr && typeof expr === "object" && !Array.isArray(expr)) {
12385
- if (!expr.path && expr.path !== "") {
12386
- throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');
12387
- }
12388
- if (!Object.hasOwn(expr, "json")) {
12389
- throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');
12390
- }
12391
- ({
12392
- json
12393
- } = expr);
12394
- flatten = Object.hasOwn(expr, "flatten") ? expr.flatten : flatten;
12395
- this.currResultType = Object.hasOwn(expr, "resultType") ? expr.resultType : this.currResultType;
12396
- this.currSandbox = Object.hasOwn(expr, "sandbox") ? expr.sandbox : this.currSandbox;
12397
- wrap = Object.hasOwn(expr, "wrap") ? expr.wrap : wrap;
12398
- this.currEval = Object.hasOwn(expr, "eval") ? expr.eval : this.currEval;
12399
- callback = Object.hasOwn(expr, "callback") ? expr.callback : callback;
12400
- this.currOtherTypeCallback = Object.hasOwn(expr, "otherTypeCallback") ? expr.otherTypeCallback : this.currOtherTypeCallback;
12401
- currParent = Object.hasOwn(expr, "parent") ? expr.parent : currParent;
12402
- currParentProperty = Object.hasOwn(expr, "parentProperty") ? expr.parentProperty : currParentProperty;
12403
- expr = expr.path;
12404
- }
12405
- currParent = currParent || null;
12406
- currParentProperty = currParentProperty || null;
12407
- if (Array.isArray(expr)) {
12408
- expr = JSONPath.toPathString(expr);
12409
- }
12410
- if (!expr && expr !== "" || !json) {
12411
- return;
12412
- }
12413
- const exprList = JSONPath.toPathArray(expr);
12414
- if (exprList[0] === "$" && exprList.length > 1) {
12415
- exprList.shift();
12416
- }
12417
- this._hasParentSelector = null;
12418
- const result = this._trace(exprList, json, ["$"], currParent, currParentProperty, callback).filter(function(ea) {
12419
- return ea && !ea.isParentSelector;
12420
- });
12421
- if (!result.length) {
12422
- return wrap ? [] : undefined;
12423
- }
12424
- if (!wrap && result.length === 1 && !result[0].hasArrExpr) {
12425
- return this._getPreferredOutput(result[0]);
12426
- }
12427
- return result.reduce((rslt, ea) => {
12428
- const valOrPath = this._getPreferredOutput(ea);
12429
- if (flatten && Array.isArray(valOrPath)) {
12430
- rslt = rslt.concat(valOrPath);
12431
- } else {
12432
- rslt.push(valOrPath);
12433
- }
12434
- return rslt;
12435
- }, []);
12436
- };
12437
- JSONPath.prototype._getPreferredOutput = function(ea) {
12438
- const resultType = this.currResultType;
12439
- switch (resultType) {
12440
- case "all": {
12441
- const path3 = Array.isArray(ea.path) ? ea.path : JSONPath.toPathArray(ea.path);
12442
- ea.pointer = JSONPath.toPointer(path3);
12443
- ea.path = typeof ea.path === "string" ? ea.path : JSONPath.toPathString(ea.path);
12444
- return ea;
12445
- }
12446
- case "value":
12447
- case "parent":
12448
- case "parentProperty":
12449
- return ea[resultType];
12450
- case "path":
12451
- return JSONPath.toPathString(ea[resultType]);
12452
- case "pointer":
12453
- return JSONPath.toPointer(ea.path);
12454
- default:
12455
- throw new TypeError("Unknown result type");
12456
- }
12457
- };
12458
- JSONPath.prototype._handleCallback = function(fullRetObj, callback, type) {
12459
- if (callback) {
12460
- const preferredOutput = this._getPreferredOutput(fullRetObj);
12461
- fullRetObj.path = typeof fullRetObj.path === "string" ? fullRetObj.path : JSONPath.toPathString(fullRetObj.path);
12462
- callback(preferredOutput, type, fullRetObj);
12463
- }
12464
- };
12465
- JSONPath.prototype._trace = function(expr, val, path3, parent, parentPropName, callback, hasArrExpr, literalPriority) {
12466
- let retObj;
12467
- if (!expr.length) {
12468
- retObj = {
12469
- path: path3,
12470
- value: val,
12471
- parent,
12472
- parentProperty: parentPropName,
12473
- hasArrExpr
12474
- };
12475
- this._handleCallback(retObj, callback, "value");
12476
- return retObj;
12477
- }
12478
- const loc = expr[0], x = expr.slice(1);
12479
- const ret = [];
12480
- function addRet(elems) {
12481
- if (Array.isArray(elems)) {
12482
- elems.forEach((t) => {
12483
- ret.push(t);
12484
- });
12485
- } else {
12486
- ret.push(elems);
12487
- }
12488
- }
12489
- if ((typeof loc !== "string" || literalPriority) && val && Object.hasOwn(val, loc)) {
12490
- addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr));
12491
- } else if (loc === "*") {
12492
- this._walk(val, (m) => {
12493
- addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true, true));
12494
- });
12495
- } else if (loc === "..") {
12496
- addRet(this._trace(x, val, path3, parent, parentPropName, callback, hasArrExpr));
12497
- this._walk(val, (m) => {
12498
- if (typeof val[m] === "object") {
12499
- addRet(this._trace(expr.slice(), val[m], push(path3, m), val, m, callback, true));
12500
- }
12501
- });
12502
- } else if (loc === "^") {
12503
- this._hasParentSelector = true;
12504
- return {
12505
- path: path3.slice(0, -1),
12506
- expr: x,
12507
- isParentSelector: true
12508
- };
12509
- } else if (loc === "~") {
12510
- retObj = {
12511
- path: push(path3, loc),
12512
- value: parentPropName,
12513
- parent,
12514
- parentProperty: null
12515
- };
12516
- this._handleCallback(retObj, callback, "property");
12517
- return retObj;
12518
- } else if (loc === "$") {
12519
- addRet(this._trace(x, val, path3, null, null, callback, hasArrExpr));
12520
- } else if (/^(-?\d*):(-?\d*):?(\d*)$/u.test(loc)) {
12521
- addRet(this._slice(loc, x, val, path3, parent, parentPropName, callback));
12522
- } else if (loc.indexOf("?(") === 0) {
12523
- if (this.currEval === false) {
12524
- throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
12525
- }
12526
- const safeLoc = loc.replace(/^\?\((.*?)\)$/u, "$1");
12527
- const nested = /@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(safeLoc);
12528
- if (nested) {
12529
- this._walk(val, (m) => {
12530
- const npath = [nested[2]];
12531
- const nvalue = nested[1] ? val[m][nested[1]] : val[m];
12532
- const filterResults = this._trace(npath, nvalue, path3, parent, parentPropName, callback, true);
12533
- if (filterResults.length > 0) {
12534
- addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
12535
- }
12536
- });
12537
- } else {
12538
- this._walk(val, (m) => {
12539
- if (this._eval(safeLoc, val[m], m, path3, parent, parentPropName)) {
12540
- addRet(this._trace(x, val[m], push(path3, m), val, m, callback, true));
12541
- }
12542
- });
12543
- }
12544
- } else if (loc[0] === "(") {
12545
- if (this.currEval === false) {
12546
- throw new Error("Eval [(expr)] prevented in JSONPath expression.");
12547
- }
12548
- addRet(this._trace(unshift(this._eval(loc, val, path3.at(-1), path3.slice(0, -1), parent, parentPropName), x), val, path3, parent, parentPropName, callback, hasArrExpr));
12549
- } else if (loc[0] === "@") {
12550
- let addType = false;
12551
- const valueType = loc.slice(1, -2);
12552
- switch (valueType) {
12553
- case "scalar":
12554
- if (!val || !["object", "function"].includes(typeof val)) {
12555
- addType = true;
12556
- }
12557
- break;
12558
- case "boolean":
12559
- case "string":
12560
- case "undefined":
12561
- case "function":
12562
- if (typeof val === valueType) {
12563
- addType = true;
12564
- }
12565
- break;
12566
- case "integer":
12567
- if (Number.isFinite(val) && !(val % 1)) {
12568
- addType = true;
12569
- }
12570
- break;
12571
- case "number":
12572
- if (Number.isFinite(val)) {
12573
- addType = true;
12574
- }
12575
- break;
12576
- case "nonFinite":
12577
- if (typeof val === "number" && !Number.isFinite(val)) {
12578
- addType = true;
12579
- }
12580
- break;
12581
- case "object":
12582
- if (val && typeof val === valueType) {
12583
- addType = true;
12584
- }
12585
- break;
12586
- case "array":
12587
- if (Array.isArray(val)) {
12588
- addType = true;
12589
- }
12590
- break;
12591
- case "other":
12592
- addType = this.currOtherTypeCallback(val, path3, parent, parentPropName);
12593
- break;
12594
- case "null":
12595
- if (val === null) {
12596
- addType = true;
12597
- }
12598
- break;
12599
- default:
12600
- throw new TypeError("Unknown value type " + valueType);
12601
- }
12602
- if (addType) {
12603
- retObj = {
12604
- path: path3,
12605
- value: val,
12606
- parent,
12607
- parentProperty: parentPropName
12608
- };
12609
- this._handleCallback(retObj, callback, "value");
12610
- return retObj;
12611
- }
12612
- } else if (loc[0] === "`" && val && Object.hasOwn(val, loc.slice(1))) {
12613
- const locProp = loc.slice(1);
12614
- addRet(this._trace(x, val[locProp], push(path3, locProp), val, locProp, callback, hasArrExpr, true));
12615
- } else if (loc.includes(",")) {
12616
- const parts = loc.split(",");
12617
- for (const part of parts) {
12618
- addRet(this._trace(unshift(part, x), val, path3, parent, parentPropName, callback, true));
12619
- }
12620
- } else if (!literalPriority && val && Object.hasOwn(val, loc)) {
12621
- addRet(this._trace(x, val[loc], push(path3, loc), val, loc, callback, hasArrExpr, true));
12622
- }
12623
- if (this._hasParentSelector) {
12624
- for (let t = 0;t < ret.length; t++) {
12625
- const rett = ret[t];
12626
- if (rett && rett.isParentSelector) {
12627
- const tmp = this._trace(rett.expr, val, rett.path, parent, parentPropName, callback, hasArrExpr);
12628
- if (Array.isArray(tmp)) {
12629
- ret[t] = tmp[0];
12630
- const tl = tmp.length;
12631
- for (let tt = 1;tt < tl; tt++) {
12632
- t++;
12633
- ret.splice(t, 0, tmp[tt]);
12634
- }
12635
- } else {
12636
- ret[t] = tmp;
12637
- }
12638
- }
12639
- }
12640
- }
12641
- return ret;
12642
- };
12643
- JSONPath.prototype._walk = function(val, f) {
12644
- if (Array.isArray(val)) {
12645
- const n = val.length;
12646
- for (let i = 0;i < n; i++) {
12647
- f(i);
12648
- }
12649
- } else if (val && typeof val === "object") {
12650
- Object.keys(val).forEach((m) => {
12651
- f(m);
12652
- });
12653
- }
12654
- };
12655
- JSONPath.prototype._slice = function(loc, expr, val, path3, parent, parentPropName, callback) {
12656
- if (!Array.isArray(val)) {
12657
- return;
12658
- }
12659
- const len = val.length, parts = loc.split(":"), step = parts[2] && Number.parseInt(parts[2]) || 1;
12660
- let start = parts[0] && Number.parseInt(parts[0]) || 0, end = parts[1] && Number.parseInt(parts[1]) || len;
12661
- start = start < 0 ? Math.max(0, start + len) : Math.min(len, start);
12662
- end = end < 0 ? Math.max(0, end + len) : Math.min(len, end);
12663
- const ret = [];
12664
- for (let i = start;i < end; i += step) {
12665
- const tmp = this._trace(unshift(i, expr), val, path3, parent, parentPropName, callback, true);
12666
- tmp.forEach((t) => {
12667
- ret.push(t);
12668
- });
12669
- }
12670
- return ret;
12671
- };
12672
- JSONPath.prototype._eval = function(code, _v, _vname, path3, parent, parentPropName) {
12673
- this.currSandbox._$_parentProperty = parentPropName;
12674
- this.currSandbox._$_parent = parent;
12675
- this.currSandbox._$_property = _vname;
12676
- this.currSandbox._$_root = this.json;
12677
- this.currSandbox._$_v = _v;
12678
- const containsPath = code.includes("@path");
12679
- if (containsPath) {
12680
- this.currSandbox._$_path = JSONPath.toPathString(path3.concat([_vname]));
12681
- }
12682
- const scriptCacheKey = this.currEval + "Script:" + code;
12683
- if (!JSONPath.cache[scriptCacheKey]) {
12684
- let script = code.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([.\s)[])/gu, "_$_v$1");
12685
- if (containsPath) {
12686
- script = script.replaceAll("@path", "_$_path");
12687
- }
12688
- if (this.currEval === "safe" || this.currEval === true || this.currEval === undefined) {
12689
- JSONPath.cache[scriptCacheKey] = new this.safeVm.Script(script);
12690
- } else if (this.currEval === "native") {
12691
- JSONPath.cache[scriptCacheKey] = new this.vm.Script(script);
12692
- } else if (typeof this.currEval === "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
12693
- const CurrEval = this.currEval;
12694
- JSONPath.cache[scriptCacheKey] = new CurrEval(script);
12695
- } else if (typeof this.currEval === "function") {
12696
- JSONPath.cache[scriptCacheKey] = {
12697
- runInNewContext: (context) => this.currEval(script, context)
12698
- };
12699
- } else {
12700
- throw new TypeError(`Unknown "eval" property "${this.currEval}"`);
12701
- }
12702
- }
12703
- try {
12704
- return JSONPath.cache[scriptCacheKey].runInNewContext(this.currSandbox);
12705
- } catch (e) {
12706
- if (this.ignoreEvalErrors) {
12707
- return false;
12708
- }
12709
- throw new Error("jsonPath: " + e.message + ": " + code);
12710
- }
12711
- };
12712
- JSONPath.cache = {};
12713
- JSONPath.toPathString = function(pathArr) {
12714
- const x = pathArr, n = x.length;
12715
- let p = "$";
12716
- for (let i = 1;i < n; i++) {
12717
- if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
12718
- p += /^[0-9*]+$/u.test(x[i]) ? "[" + x[i] + "]" : "['" + x[i] + "']";
12719
- }
12720
- }
12721
- return p;
12722
- };
12723
- JSONPath.toPointer = function(pointer) {
12724
- const x = pointer, n = x.length;
12725
- let p = "";
12726
- for (let i = 1;i < n; i++) {
12727
- if (!/^(~|\^|@.*?\(\))$/u.test(x[i])) {
12728
- p += "/" + x[i].toString().replaceAll("~", "~0").replaceAll("/", "~1");
12729
- }
12730
- }
12731
- return p;
12732
- };
12733
- JSONPath.toPathArray = function(expr) {
12734
- const {
12735
- cache
12736
- } = JSONPath;
12737
- if (cache[expr]) {
12738
- return cache[expr].concat();
12739
- }
12740
- const subx = [];
12741
- const normalized = expr.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ";$&;").replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function($0, $1) {
12742
- return "[#" + (subx.push($1) - 1) + "]";
12743
- }).replaceAll(/\[['"]([^'\]]*)['"]\]/gu, function($0, prop) {
12744
- return "['" + prop.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
12745
- }).replaceAll("~", ";~;").replaceAll(/['"]?\.['"]?(?![^[]*\])|\[['"]?/gu, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/gu, function($0, ups) {
12746
- return ";" + ups.split("").join(";") + ";";
12747
- }).replaceAll(/;;;|;;/gu, ";..;").replaceAll(/;$|'?\]|'$/gu, "");
12748
- const exprList = normalized.split(";").map(function(exp) {
12749
- const match = exp.match(/#(\d+)/u);
12750
- return !match || !match[1] ? exp : subx[match[1]];
12751
- });
12752
- cache[expr] = exprList;
12753
- return cache[expr].concat();
12754
- };
12755
- JSONPath.prototype.safeVm = {
12756
- Script: SafeScript
12054
+ return new Command2(nameAndArgs.split(/\s+/)[0] ?? nameAndArgs);
12757
12055
  };
12758
- JSONPath.prototype.vm = vm;
12759
- var PollOutcome = {
12760
- Completed: "completed",
12761
- Timeout: "timeout",
12762
- Interrupted: "interrupted",
12763
- Aborted: "aborted",
12764
- Failed: "failed"
12765
- };
12766
- var REASON_BY_OUTCOME = {
12767
- [PollOutcome.Timeout]: "poll_timeout",
12768
- [PollOutcome.Failed]: "poll_failed",
12769
- [PollOutcome.Interrupted]: "poll_failed",
12770
- [PollOutcome.Aborted]: "poll_aborted"
12771
- };
12772
- var TERMINAL_STATUSES = new Set([
12773
- "completed",
12774
- "successful",
12775
- "faulted",
12776
- "failed",
12777
- "cancelled",
12778
- "canceled",
12779
- "stopped",
12780
- "finished"
12781
- ]);
12782
- var FAILURE_STATUSES = new Set([
12783
- "faulted",
12784
- "failed",
12785
- "cancelled",
12786
- "canceled",
12787
- "stopped"
12788
- ]);
12789
12056
  var ScreenLogger;
12790
12057
  ((ScreenLogger2) => {
12791
12058
  function progress(message) {
@@ -12795,6 +12062,7 @@ var ScreenLogger;
12795
12062
  ScreenLogger2.progress = progress;
12796
12063
  })(ScreenLogger ||= {});
12797
12064
  var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
12065
+ var shippedKeysSlot = singleton("ShipSucceededDedupeKeys");
12798
12066
  var factorySlot = singleton("PackagerFactoryProvider");
12799
12067
 
12800
12068
  // src/argv.ts