@xenon-device-management/xenon 2.14.0 → 2.16.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.
- package/README.md +44 -29
- package/lib/package.json +6 -5
- package/lib/public/assets/{AnnotationOverlay-B_VNtKBH.js → AnnotationOverlay-2W4JvEyZ.js} +1 -1
- package/lib/public/assets/{ApiKeyGate-BwuaMjkX.js → ApiKeyGate-GmckX_7r.js} +1 -1
- package/lib/public/assets/DeviceMosaicView-DqODzkyo.js +2 -0
- package/lib/public/assets/{EmptyState-BSjhk_IV.js → EmptyState-7hETKEWb.js} +1 -1
- package/lib/public/assets/{FieldGroup-Cb5QZsE1.js → FieldGroup-GOgssFEP.js} +1 -1
- package/lib/public/assets/{FilterMenu-BAaSlWbW.js → FilterMenu-Yvf6RGMd.js} +1 -1
- package/lib/public/assets/{Menu-JGGYrSQQ.js → Menu-KrPnfdsf.js} +1 -1
- package/lib/public/assets/{Modal-CFCp3n9d.js → Modal-C6WjZFeI.js} +1 -1
- package/lib/public/assets/{RecordingPage-CbJj_EBT.js → RecordingPage-CSRIhZEh.js} +1 -1
- package/lib/public/assets/{RecordingsPage-BJeYnygR.js → RecordingsPage-CB8ST3nE.js} +1 -1
- package/lib/public/assets/{SegmentedControl-Bg42Atjy.js → SegmentedControl-C9o90KId.js} +1 -1
- package/lib/public/assets/{SettingCard-Njz1pUIJ.js → SettingCard-CPm3w9l2.js} +1 -1
- package/lib/public/assets/{Table-BcTm5xV2.js → Table-DwIgERRt.js} +1 -1
- package/lib/public/assets/{activity-DOVdsfMQ.js → activity-DrLbHifn.js} +1 -1
- package/lib/public/assets/ai-settings-DU_Ls06P.js +16 -0
- package/lib/public/assets/{api-keys-BKnNSTw9.js → api-keys-CWYdEzJ_.js} +1 -1
- package/lib/public/assets/{apps-D0SC6uw6.js → apps-BqNVdln7.js} +1 -1
- package/lib/public/assets/{arrow-left-MMbTmgoE.js → arrow-left-BtB0_Jg_.js} +1 -1
- package/lib/public/assets/{arrow-right-BMfnGmxW.js → arrow-right-C8NhdtyN.js} +1 -1
- package/lib/public/assets/{arrow-up-right-DuAftMWB.js → arrow-up-right-gMg0ffvv.js} +1 -1
- package/lib/public/assets/{auth-shell-nZC2JNDO.js → auth-shell-CiYZ3N4M.js} +2 -2
- package/lib/public/assets/{builds-page-hDCgTwkS.js → builds-page-EaaqDmLN.js} +1 -1
- package/lib/public/assets/{button-Dda4irn_.js → button-DDau4Axv.js} +1 -1
- package/lib/public/assets/{calendar-BMr0Q62v.js → calendar-DQ83B1ed.js} +1 -1
- package/lib/public/assets/{check-CZ9iw9-e.js → check-K1ovTQam.js} +1 -1
- package/lib/public/assets/{chevron-right-BRYJJVC9.js → chevron-right-Biq00pMt.js} +1 -1
- package/lib/public/assets/{circle-check-CqAJjQ5O.js → circle-check-CBv88cH7.js} +1 -1
- package/lib/public/assets/{circle-x-DlDJtnVz.js → circle-x-Bmltailn.js} +1 -1
- package/lib/public/assets/{clock-CpuDKysU.js → clock-BPrld-3h.js} +1 -1
- package/lib/public/assets/{copy-CAQydNFe.js → copy-t0QB14JI.js} +1 -1
- package/lib/public/assets/derive-UnLRp4r3.js +1 -0
- package/lib/public/assets/device-explorer-BgGZ8AvV.js +282 -0
- package/lib/public/assets/{download-C9XG6lLv.js → download-BroHxNOh.js} +1 -1
- package/lib/public/assets/forgot-password-Bjmf49i6.js +1 -0
- package/lib/public/assets/{h264Stream-VQBphYhg.js → h264Stream-DeD__6wa.js} +6 -6
- package/lib/public/assets/{index-DJGc1M2f.js → index-72oF89LJ.js} +1 -1
- package/lib/public/assets/index-B0JeuZbg.js +15 -0
- package/lib/public/assets/index-B0gQkEg0.js +219 -0
- package/lib/public/assets/{input-Cm0tmSoc.js → input-DIc4MSC7.js} +1 -1
- package/lib/public/assets/{line-chart-D2DyJCml.js → line-chart-BcWm2vW8.js} +1 -1
- package/lib/public/assets/{list-checks-UWf1GY99.js → list-checks-B06IJJad.js} +1 -1
- package/lib/public/assets/{lock-CCJv9m_I.js → lock-pVLvnN30.js} +1 -1
- package/lib/public/assets/{login-f8vOVW-U.js → login-CN77vy--.js} +1 -1
- package/lib/public/assets/{maintenance-settings-C1PrkuAH.js → maintenance-settings-CSdzQSkY.js} +1 -1
- package/lib/public/assets/{monitor-B2jDgwm7.js → monitor-BtrN5IkI.js} +1 -1
- package/lib/public/assets/{mouse-pointer-2-DLI1RtzU.js → mouse-pointer-2-CNsQfo6w.js} +1 -1
- package/lib/public/assets/{network-ebT86qoi.js → network-BSfA8ZxG.js} +1 -1
- package/lib/public/assets/{overview-C0aykVrd.js → overview-BfTebCK5.js} +1 -1
- package/lib/public/assets/{page-header-BjzgWz-T.js → page-header-D8KUX6Qg.js} +1 -1
- package/lib/public/assets/{play-DLG9t8FU.js → play-Cvc8xzic.js} +1 -1
- package/lib/public/assets/{plus-nBFSMu_X.js → plus-C9Zj84UF.js} +1 -1
- package/lib/public/assets/{profile-page-CSl0UYlv.js → profile-page-Bi27STgs.js} +1 -1
- package/lib/public/assets/{reset-password-LeOuHqmB.js → reset-password-CPsOuwSu.js} +1 -1
- package/lib/public/assets/runbook-page-DEQ-DBOX.js +304 -0
- package/lib/public/assets/{select-88jHcl-Z.js → select-BWpnhWXj.js} +1 -1
- package/lib/public/assets/{selector-detail-redirect-BbXKJjZM.js → selector-detail-redirect-BefSCSpe.js} +1 -1
- package/lib/public/assets/{selector-health-page-B4rA1Xkv.js → selector-health-page-MSk96Zz7.js} +1 -1
- package/lib/public/assets/session-detail-page-DPyBNef_.js +4 -0
- package/lib/public/assets/{settings-Dep_3kbA.css → settings-K8UHWMdI.css} +1 -1
- package/lib/public/assets/{settings-GF6ZMSQ6.js → settings-V6x-cXwy.js} +1 -1
- package/lib/public/assets/{stat-tile-BV98e_Sv.js → stat-tile-Duex-GZD.js} +1 -1
- package/lib/public/assets/{tablet-BiAsnFDj.js → tablet-BBcoqBmL.js} +1 -1
- package/lib/public/assets/{teams-B4-jrr-1.js → teams-ts8p5rEh.js} +1 -1
- package/lib/public/assets/{trash-2-C5RSuX0e.js → trash-2-CZ2ew6AZ.js} +1 -1
- package/lib/public/assets/{upload-BG7_rMXK.js → upload-Dv99y_le.js} +1 -1
- package/lib/public/assets/{use-builds-data-J-riQYyC.js → use-builds-data-DrYC8JCF.js} +1 -1
- package/lib/public/assets/{use-password-reset-mode-C8-eH-UG.js → use-password-reset-mode-C7QkBNkP.js} +1 -1
- package/lib/public/assets/{users-CFba5TSy.js → users-D7tKMESH.js} +1 -1
- package/lib/public/assets/{users-Cp0beJm3.js → users-gJ5Y01yo.js} +1 -1
- package/lib/public/assets/{video-off-DDsEISjV.js → video-off-CqZVuZGs.js} +1 -1
- package/lib/public/assets/{webhook-settings-BGu32vSB.js → webhook-settings-DI5DSW99.js} +1 -1
- package/lib/public/assets/{zap-l4VaXzq8.js → zap-ClcHFxfo.js} +1 -1
- package/lib/public/index.html +1 -1
- package/lib/schema.json +16 -12
- package/lib/src/InternalHttpClient.js +27 -5
- package/lib/src/XenonCapabilityManager.js +10 -3
- package/lib/src/app/dashboardPluginLink.js +117 -0
- package/lib/src/app/index.js +13 -34
- package/lib/src/app/openapi/control.yaml +6 -4
- package/lib/src/app/openapi/grid.yaml +8 -2
- package/lib/src/app/openapi/identity.yaml +103 -31
- package/lib/src/app/openapi/platform.yaml +33 -15
- package/lib/src/app/openapi/sessions.yaml +12 -3
- package/lib/src/app/routers/apikeys.js +14 -2
- package/lib/src/app/routers/auth.js +31 -6
- package/lib/src/app/routers/control.js +13 -5
- package/lib/src/app/routers/dashboard.js +42 -27
- package/lib/src/app/routers/grid.js +5 -3
- package/lib/src/app/routers/profile.js +21 -0
- package/lib/src/app/routers/users.js +12 -6
- package/lib/src/app/swagger.js +2 -0
- package/lib/src/app/ws/h264StreamWs.js +10 -1
- package/lib/src/app/ws/nodeSocketRelay.js +77 -11
- package/lib/src/config.js +1 -0
- package/lib/src/dashboard/commandLogFields.js +42 -0
- package/lib/src/dashboard/commands.js +5 -5
- package/lib/src/dashboard/event-manager.js +64 -204
- package/lib/src/dashboard/services/failure-analysis-service.js +118 -105
- package/lib/src/dashboard/services/failureCategories.js +264 -0
- package/lib/src/dashboard/sessionCommandSummary.js +39 -0
- package/lib/src/data-service/device-store.js +14 -1
- package/lib/src/data-service/prisma-store.js +19 -7
- package/lib/src/data-service/web-config-service.js +7 -0
- package/lib/src/device-managers/AndroidDeviceManager.js +61 -23
- package/lib/src/device-managers/IOSDeviceManager.js +10 -0
- package/lib/src/device-managers/android/AndroidH264StreamService.js +69 -20
- package/lib/src/device-managers/android/H264Multiplexer.js +38 -4
- package/lib/src/device-utils.js +29 -3
- package/lib/src/gateway/defaultGateway.js +1 -1
- package/lib/src/gateway/forwardToNode.js +6 -11
- package/lib/src/gateway/healReport.js +87 -0
- package/lib/src/gateway/hubSessionToken.js +27 -4
- package/lib/src/gateway/nodeWebDriverUrl.js +3 -5
- package/lib/src/gateway/sessionGateway.js +12 -2
- package/lib/src/generated/client/edge.js +4 -3
- package/lib/src/generated/client/index-browser.js +1 -0
- package/lib/src/generated/client/index.d.ts +32 -0
- package/lib/src/generated/client/index.js +4 -3
- package/lib/src/generated/client/package.json +1 -1
- package/lib/src/generated/client/schema.prisma +3 -0
- package/lib/src/generated/client/wasm.js +1 -0
- package/lib/src/helpers/outboundProxy.js +219 -0
- package/lib/src/index.js +21 -0
- package/lib/src/interceptors/CommandInterceptor.js +256 -196
- package/lib/src/interceptors/xenonScripts.js +28 -7
- package/lib/src/logger.js +3 -1
- package/lib/src/middleware/authMiddleware.js +15 -3
- package/lib/src/middleware/commandCaller.js +3 -3
- package/lib/src/middleware/verifyCredential.js +58 -1
- package/lib/src/plugin.js +16 -6
- package/lib/src/scripts/database-check.js +3 -3
- package/lib/src/scripts/initialize-database.js +35 -33
- package/lib/src/scripts/run-migrations.js +1079 -27
- package/lib/src/services/AICommandService.js +9 -2
- package/lib/src/services/AIService.js +192 -42
- package/lib/src/services/ApiKeyService.js +16 -5
- package/lib/src/services/EmailService.js +29 -0
- package/lib/src/services/InterceptorService.js +6 -2
- package/lib/src/services/OrphanSweeper.js +8 -0
- package/lib/src/services/SelectorStateService.js +11 -7
- package/lib/src/services/SelectorVerificationJob.js +21 -6
- package/lib/src/services/ServerManager.js +11 -1
- package/lib/src/services/SessionLifecycleService.js +118 -44
- package/lib/src/services/SocketClient.js +11 -0
- package/lib/src/services/SocketServer.js +380 -45
- package/lib/src/services/TeamService.js +5 -1
- package/lib/src/services/TracingService.js +171 -60
- package/lib/src/services/UserService.js +14 -3
- package/lib/src/services/UserSessionService.js +16 -4
- package/lib/src/services/bug-report/video-slice.js +4 -1
- package/lib/src/services/device-access/leaseOverride.js +7 -5
- package/lib/src/services/healing/FuzzyXmlHealingProvider.js +51 -0
- package/lib/src/services/healing/HealEtalonService.js +3 -2
- package/lib/src/services/healing/HealingOrchestrator.js +57 -72
- package/lib/src/services/healing/OcrHealingProvider.js +41 -64
- package/lib/src/services/healing/ResilioTreeHealingProvider.js +41 -50
- package/lib/src/services/healing/VisualAiHealingProvider.js +1 -1
- package/lib/src/services/healing/fingerprintIdentity.js +126 -0
- package/lib/src/services/healing/resilioPath.js +274 -0
- package/lib/src/services/identity/identityChanges.js +41 -0
- package/lib/src/services/logcat/SessionDeviceLogs.js +358 -0
- package/lib/src/services/logcat/deviceLogBook.js +164 -0
- package/lib/src/services/logcat/iosDriverLog.js +178 -0
- package/lib/src/services/ocr/ocrData.js +118 -0
- package/lib/src/services/ocr/vendor/LICENSE-tessdata.txt +202 -0
- package/lib/src/services/ocr/vendor/eng.traineddata.gz +0 -0
- package/lib/src/services/omni-vision/OmniVisionService.js +83 -56
- package/lib/src/services/passwordResetLink.js +50 -9
- package/lib/src/services/passwordResetMode.js +3 -1
- package/lib/src/services/publicUrl.js +45 -0
- package/lib/src/services/selector-health/SelectorVisibilityResolver.js +121 -0
- package/lib/src/services/session/sessionIdentity.js +5 -3
- package/lib/src/services/session/shutdownReason.js +26 -0
- package/lib/src/services/settings/aiEngineSettings.js +219 -0
- package/lib/src/services/token/JwtKeyService.js +8 -2
- package/lib/src/services/token/mcpTokenTtl.js +27 -0
- package/lib/src/services/token/mintedLifetime.js +51 -0
- package/lib/src/sessions/LocalSession.js +29 -1
- package/lib/src/sessions/RemoteSession.js +12 -2
- package/lib/src/sessions/SessionManager.js +4 -1
- package/lib/src/sessions/sessionMemory.js +25 -0
- package/lib/test/helpers/driver-log.js +38 -0
- package/lib/test/helpers/fake-ai-provider.js +188 -0
- package/lib/test/helpers/fake-http-proxy.js +106 -0
- package/lib/test/helpers/loki-stores.js +33 -0
- package/lib/test/helpers/otlp-probe.js +107 -0
- package/lib/test/helpers/page-sources.js +164 -0
- package/lib/test/helpers/scratch-database.js +57 -13
- package/lib/test/integration/androidDevices.spec.js +1 -1
- package/lib/test/integration/audit-ingest.spec.js +10 -10
- package/lib/test/integration/auth-flow.spec.js +9 -14
- package/lib/test/integration/auth-rate-limit.spec.js +6 -3
- package/lib/test/integration/bug-report-route.spec.js +22 -2
- package/lib/test/integration/forgot-password-rate-limit.spec.js +6 -3
- package/lib/test/integration/forgot-password.spec.js +17 -18
- package/lib/test/integration/ios/01iOSSimulator.spec.js +1 -1
- package/lib/test/integration/ios/02iOSDevices.spec.js +1 -1
- package/lib/test/integration/legacy-deprecation-headers.spec.js +5 -2
- package/lib/test/integration/migration.spec.js +6 -1
- package/lib/test/integration/node-pair-auth-rest.spec.js +5 -9
- package/lib/test/integration/ports-router.spec.js +4 -4
- package/lib/test/integration/prisma-device-store-add-devices.spec.js +2 -3
- package/lib/test/integration/prisma-device-store-team-filter.spec.js +2 -5
- package/lib/test/integration/profile-tokens.spec.js +10 -16
- package/lib/test/integration/recordings-router.spec.js +16 -16
- package/lib/test/integration/reset-revokes-sessions.spec.js +4 -9
- package/lib/test/integration/role-matrix.spec.js +4 -9
- package/lib/test/integration/sdk-leases-router.spec.js +9 -9
- package/lib/test/integration/sdk-version.spec.js +2 -2
- package/lib/test/integration/selector-health-endpoint.spec.js +5 -5
- package/lib/test/integration/selector-state-flow.spec.js +5 -5
- package/lib/test/integration/team-membership-migration.spec.js +73 -12
- package/lib/test/integration/team-visibility-apps.spec.js +15 -22
- package/lib/test/integration/team-visibility-control.spec.js +96 -69
- package/lib/test/integration/team-visibility-dashboard.spec.js +7 -23
- package/lib/test/integration/team-visibility-grid.spec.js +16 -15
- package/lib/test/integration/team-visibility-leases.spec.js +8 -11
- package/lib/test/integration/team-visibility-recordings.spec.js +6 -19
- package/lib/test/integration/team-visibility-sessions.spec.js +6 -19
- package/lib/test/integration/users-flow.spec.js +7 -12
- package/lib/test/integration/users-lockout.spec.js +5 -3
- package/lib/test/unit/EmailService.test.js +66 -0
- package/lib/test/unit/ResilioTreeHealingProvider.test.js +46 -19
- package/lib/test/unit/XenonCapabilityManager.spec.js +23 -0
- package/lib/test/unit/ai-call-time-limit.spec.js +130 -0
- package/lib/test/unit/ai-engine-settings.spec.js +338 -0
- package/lib/test/unit/ai-provider-switch.spec.js +130 -0
- package/lib/test/unit/ai-rate-limit.spec.js +126 -0
- package/lib/test/unit/android-adb-retry.spec.js +112 -0
- package/lib/test/unit/android-h264-viewers.spec.js +272 -0
- package/lib/test/unit/android-preview-hold.spec.js +3 -2
- package/lib/test/unit/apikeys-router.spec.js +84 -0
- package/lib/test/unit/authMiddleware.bearer.spec.js +9 -0
- package/lib/test/unit/authMiddleware.credentialLifetime.spec.js +149 -0
- package/lib/test/unit/bug-report/video-slice.spec.js +19 -0
- package/lib/test/unit/command-log-network-capture.spec.js +191 -0
- package/lib/test/unit/dashboard-events-device-logs.spec.js +255 -0
- package/lib/test/unit/dashboard-events-team-scope.spec.js +6 -3
- package/lib/test/unit/dashboard-plugin-link.spec.js +213 -0
- package/lib/test/unit/database-check.spec.js +1 -0
- package/lib/test/unit/device-log-book.spec.js +180 -0
- package/lib/test/unit/device-utils.spec.js +13 -4
- package/lib/test/unit/enable-dashboard-option.spec.js +57 -0
- package/lib/test/unit/event-log-session-data.spec.js +251 -0
- package/lib/test/unit/failure-analysis.spec.js +196 -0
- package/lib/test/unit/failure-categories.spec.js +130 -0
- package/lib/test/unit/failure-categorization.spec.js +393 -0
- package/lib/test/unit/fingerprint-identity.spec.js +433 -0
- package/lib/test/unit/h264-multiplexer.spec.js +46 -0
- package/lib/test/unit/heal-report.spec.js +71 -0
- package/lib/test/unit/healing-instrumentation.spec.js +6 -1
- package/lib/test/unit/healing-tier-gate.spec.js +74 -29
- package/lib/test/unit/healing-tiers-every-session.spec.js +219 -0
- package/lib/test/unit/hub-node-gateway-appium-server.spec.js +243 -1
- package/lib/test/unit/interceptor-visual-elements.spec.js +192 -0
- package/lib/test/unit/ios-driver-log.spec.js +168 -0
- package/lib/test/unit/ios-simulator-session-readiness.spec.js +187 -0
- package/lib/test/unit/ios-simulator-session-teardown.spec.js +158 -0
- package/lib/test/unit/lease/lease-override.spec.js +23 -6
- package/lib/test/unit/lease/session-lease-proof.spec.js +16 -4
- package/lib/test/unit/logcat-ws.spec.js +78 -37
- package/lib/test/unit/logger-json-levels.spec.js +44 -0
- package/lib/test/unit/mcp-token-ttl.spec.js +38 -0
- package/lib/test/unit/observability-example-loki.spec.js +25 -0
- package/lib/test/unit/ocr-healing-tier-real-ocr.spec.js +113 -0
- package/lib/test/unit/ocr-healing-tier.spec.js +122 -0
- package/lib/test/unit/ocr-offline.spec.js +213 -0
- package/lib/test/unit/omni-virtual-element-store.spec.js +301 -0
- package/lib/test/unit/omni-vision-ios-points.spec.js +0 -2
- package/lib/test/unit/omni-vision.spec.js +5 -7
- package/lib/test/unit/openapi-for-site.spec.js +80 -0
- package/lib/test/unit/outbound-proxy.spec.js +320 -0
- package/lib/test/unit/package-engines.spec.js +27 -0
- package/lib/test/unit/passwordResetMode.test.js +10 -2
- package/lib/test/unit/port-exhaustion.spec.js +2 -1
- package/lib/test/unit/profile-router.test.js +122 -1
- package/lib/test/unit/proxy-option.spec.js +358 -0
- package/lib/test/unit/queue-requester.spec.js +1 -1
- package/lib/test/unit/reset-link-address.spec.js +266 -0
- package/lib/test/unit/reset-link.test.js +10 -4
- package/lib/test/unit/resilio-path-healing.spec.js +270 -0
- package/lib/test/unit/run-migrations-database.spec.js +807 -0
- package/lib/test/unit/run-migrations-fail-fast.test.js +41 -27
- package/lib/test/unit/run-migrations.test.js +864 -0
- package/lib/test/unit/selector-health-actions.spec.js +3 -1
- package/lib/test/unit/selector-learning-every-session.spec.js +179 -0
- package/lib/test/unit/selector-state-service.spec.js +72 -23
- package/lib/test/unit/selector-verification-clean-build.spec.js +130 -0
- package/lib/test/unit/selector-verification-job.spec.js +28 -19
- package/lib/test/unit/selector-verification-missed-regression.spec.js +2 -2
- package/lib/test/unit/selector-visibility-resolver.spec.js +209 -0
- package/lib/test/unit/self-healing-boot.spec.js +10 -5
- package/lib/test/unit/self-healing-setting.spec.js +7 -6
- package/lib/test/unit/session-app-resolution.spec.js +5 -1
- package/lib/test/unit/session-attribution-wiring.spec.js +41 -13
- package/lib/test/unit/session-create-credential-owner.spec.js +242 -0
- package/lib/test/unit/session-credential-strip.spec.js +1 -1
- package/lib/test/unit/session-device-logs-ios.spec.js +180 -0
- package/lib/test/unit/session-device-logs.spec.js +356 -0
- package/lib/test/unit/session-end-failure-analysis.spec.js +133 -0
- package/lib/test/unit/session-log-indexes.spec.js +64 -3
- package/lib/test/unit/socket-team-scope.integration.spec.js +749 -0
- package/lib/test/unit/socketServer.scopedEmit.spec.js +237 -5
- package/lib/test/unit/socketServer.sessionCookie.spec.js +2 -1
- package/lib/test/unit/stream-start-pipelines.spec.js +72 -18
- package/lib/test/unit/token-mint-limits.spec.js +165 -0
- package/lib/test/unit/tracing-export-routing.spec.js +137 -0
- package/lib/test/unit/tracing-session-spans.spec.js +337 -0
- package/lib/test/unit/unexpected-shutdown-reason.spec.js +163 -0
- package/lib/test/unit/verify-credential.spec.js +33 -0
- package/lib/test/unit/vision-assertion.spec.js +3 -2
- package/lib/test/unit/web-config-service.spec.js +19 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/prisma/migrations/20261004174413_locator_etalon_path/migration.sql +2 -0
- package/prisma/schema.prisma +3 -0
- package/schema.json +16 -12
- package/scripts/dev/readme-screenshots.js +276 -23
- package/scripts/dev/screenshot-fixtures/logcat.js +157 -0
- package/scripts/dev/screenshot-fixtures/phone-screen.html +469 -0
- package/scripts/dev/screenshot-fixtures/session.js +242 -0
- package/scripts/export-openapi.js +32 -0
- package/scripts/lib/openapi-for-site.js +79 -0
- package/lib/public/assets/BugReportButton-BAt0_pzq.js +0 -15
- package/lib/public/assets/DeviceMosaicView-BYaQHhTf.js +0 -2
- package/lib/public/assets/ai-settings-CsuJroRf.js +0 -21
- package/lib/public/assets/device-explorer-CdO6_nrn.js +0 -282
- package/lib/public/assets/forgot-password-CGnkRgE9.js +0 -1
- package/lib/public/assets/index-BbKEXUFH.js +0 -219
- package/lib/public/assets/runbook-page-CMMeQml9.js +0 -124
- package/lib/public/assets/session-detail-page-COL_RZxw.js +0 -4
- package/lib/src/scripts/prepare-prisma.js +0 -89
- /package/lib/public/assets/{BugReportButton-CPBjfiv4.css → index-CPBjfiv4.css} +0 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeviceLogBook = exports.DEVICE_CLOCK_COMMAND = exports.UNKNOWN_CLOCK = exports.WINDOW_SLACK_MS = exports.DEVICE_LOG_ERROR_LIMIT = exports.DEVICE_LOG_LINE_LIMIT = void 0;
|
|
4
|
+
exports.parseDeviceClock = parseDeviceClock;
|
|
5
|
+
exports.formatThreadtime = formatThreadtime;
|
|
6
|
+
const logcatParse_1 = require("./logcatParse");
|
|
7
|
+
/**
|
|
8
|
+
* Which of a phone's log records a session keeps, and as what. Pure: the
|
|
9
|
+
* service (SessionDeviceLogs) feeds it the records of the phone's shared log
|
|
10
|
+
* stream and writes what it returns.
|
|
11
|
+
*
|
|
12
|
+
* - **The session's lines only.** The stream starts with up to 2000 lines of
|
|
13
|
+
* history (`-T`, or the multiplexer's replay to a late joiner), so a line
|
|
14
|
+
* counts from shortly before the phone was given to the session.
|
|
15
|
+
* - **Its own time, on this server's clock.** A line is stamped with the
|
|
16
|
+
* moment the phone logged it, moved by the phone's clock offset, so it
|
|
17
|
+
* lines up with the session's commands; its text keeps the time the phone
|
|
18
|
+
* printed. A phone's clock is often seconds off, and one with no network
|
|
19
|
+
* time can be minutes off.
|
|
20
|
+
* - **Each line once.** A stream delivers a record once. When the stream
|
|
21
|
+
* ends mid-session and is started again, its history overlaps what was
|
|
22
|
+
* kept, so a resumed stream counts only lines after the newest one seen,
|
|
23
|
+
* compared by time and, at that same millisecond, by content.
|
|
24
|
+
* - **Bounded.** DEVICE_LOG_LINE_LIMIT lines of any level, then errors only
|
|
25
|
+
* (a crash's "FATAL EXCEPTION" is an error) up to DEVICE_LOG_ERROR_LIMIT
|
|
26
|
+
* more, each step said in the log itself.
|
|
27
|
+
*/
|
|
28
|
+
/** Lines of any level a session keeps. */
|
|
29
|
+
exports.DEVICE_LOG_LINE_LIMIT = 10000;
|
|
30
|
+
/** Errors (E and F) kept after DEVICE_LOG_LINE_LIMIT; nothing more after them. */
|
|
31
|
+
exports.DEVICE_LOG_ERROR_LIMIT = 2000;
|
|
32
|
+
/**
|
|
33
|
+
* How long before the phone was given to the session a line may be and still
|
|
34
|
+
* count: the phone's clock offset, read once, is only about that good.
|
|
35
|
+
*/
|
|
36
|
+
exports.WINDOW_SLACK_MS = 2000;
|
|
37
|
+
/** A phone whose clock couldn't be read: taken to be this server's. */
|
|
38
|
+
exports.UNKNOWN_CLOCK = { zoneShiftMs: 0, skewMs: 0 };
|
|
39
|
+
const QUARTER_HOUR_MS = 15 * 60000;
|
|
40
|
+
/**
|
|
41
|
+
* The phone's `date` command for {@link parseDeviceClock}: seconds since the
|
|
42
|
+
* epoch, nanoseconds, and the local time logcat prints, at one instant, with
|
|
43
|
+
* no spaces (it goes through the phone's shell as one word). An older
|
|
44
|
+
* toybox prints no nanoseconds.
|
|
45
|
+
*/
|
|
46
|
+
exports.DEVICE_CLOCK_COMMAND = 'date +%s.%N.%m-%d.%H:%M:%S';
|
|
47
|
+
/**
|
|
48
|
+
* The phone's clock from {@link DEVICE_CLOCK_COMMAND}'s output, or null if it
|
|
49
|
+
* isn't that. `hostNowMs` is this server's time when the phone answered.
|
|
50
|
+
*
|
|
51
|
+
* The local time is read the way parseThreadtimeLine reads a log line, so the
|
|
52
|
+
* difference to the phone's epoch is exactly the shift its lines need,
|
|
53
|
+
* whatever either time zone is. Rounded to a quarter hour: time zones differ
|
|
54
|
+
* by whole quarters.
|
|
55
|
+
*/
|
|
56
|
+
function parseDeviceClock(output, hostNowMs) {
|
|
57
|
+
const m = /(\d{9,})\.(\S*?)\.(\d{2})-(\d{2})\.(\d{2}):(\d{2}):(\d{2})/.exec(output);
|
|
58
|
+
if (!m)
|
|
59
|
+
return null;
|
|
60
|
+
const [, secs, nanos, mo, d, h, mi, s] = m;
|
|
61
|
+
const asLogged = (0, logcatParse_1.parseThreadtimeLine)(`${mo}-${d} ${h}:${mi}:${s}.000 0 0 I clock: now`, new Date(hostNowMs));
|
|
62
|
+
if (!asLogged)
|
|
63
|
+
return null;
|
|
64
|
+
// Without nanoseconds, the phone's instant was within the second after `%s`.
|
|
65
|
+
const fraction = /^\d{9}$/.test(nanos) ? Math.floor(Number(nanos) / 1e6) : 500;
|
|
66
|
+
const phoneNow = Number(secs) * 1000 + fraction;
|
|
67
|
+
return {
|
|
68
|
+
zoneShiftMs: Math.round((phoneNow - asLogged.ts) / QUARTER_HOUR_MS) * QUARTER_HOUR_MS,
|
|
69
|
+
skewMs: hostNowMs - phoneNow,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const pad = (n, width = 2) => String(n).padStart(width, '0');
|
|
73
|
+
/**
|
|
74
|
+
* A record as logcat's threadtime format prints it (logprint.cpp,
|
|
75
|
+
* `"%s %5d %5d %c %-8s: "`): the time as the phone printed it, then the pid,
|
|
76
|
+
* the tid, the level, the tag and the message. The dashboard reads the level
|
|
77
|
+
* from this text (log-derive.ts), and it is what Android developers know.
|
|
78
|
+
*/
|
|
79
|
+
function formatThreadtime(rec) {
|
|
80
|
+
// `ts` was built from the printed fields as this server's local time, so
|
|
81
|
+
// its local fields are the printed ones.
|
|
82
|
+
const t = new Date(rec.ts);
|
|
83
|
+
const time = `${pad(t.getMonth() + 1)}-${pad(t.getDate())} ` +
|
|
84
|
+
`${pad(t.getHours())}:${pad(t.getMinutes())}:${pad(t.getSeconds())}.${pad(t.getMilliseconds(), 3)}`;
|
|
85
|
+
const pid = String(rec.pid).padStart(5);
|
|
86
|
+
const tid = String(rec.tid).padStart(5);
|
|
87
|
+
return `${time} ${pid} ${tid} ${rec.level} ${rec.tag.padEnd(8)}: ${rec.message}`;
|
|
88
|
+
}
|
|
89
|
+
const count = (n) => n.toLocaleString('en-US');
|
|
90
|
+
const keyOf = (r) => `${r.pid} ${r.tid} ${r.level} ${r.tag} ${r.message}`;
|
|
91
|
+
const isError = (r) => r.level === 'E' || r.level === 'F';
|
|
92
|
+
class DeviceLogBook {
|
|
93
|
+
constructor(opts) {
|
|
94
|
+
var _a, _b, _c;
|
|
95
|
+
this.kept = 0;
|
|
96
|
+
this.leftOut = 0;
|
|
97
|
+
this.limitNoted = false;
|
|
98
|
+
this.clock = opts.clock;
|
|
99
|
+
this.format = (_a = opts.format) !== null && _a !== void 0 ? _a : formatThreadtime;
|
|
100
|
+
this.lineLimit = (_b = opts.lineLimit) !== null && _b !== void 0 ? _b : exports.DEVICE_LOG_LINE_LIMIT;
|
|
101
|
+
this.errorLimit = (_c = opts.errorLimit) !== null && _c !== void 0 ? _c : exports.DEVICE_LOG_ERROR_LIMIT;
|
|
102
|
+
// A record at `ts` was logged at ts + zoneShift + skew by this server's
|
|
103
|
+
// clock (timeOf); it counts from WINDOW_SLACK_MS before `since`.
|
|
104
|
+
const first = opts.since - exports.WINDOW_SLACK_MS - this.clock.zoneShiftMs - this.clock.skewMs;
|
|
105
|
+
this.floor = { ts: Math.ceil(first), keys: new Set() };
|
|
106
|
+
}
|
|
107
|
+
/** The rows a record adds: none, its own, or a note before it. */
|
|
108
|
+
add(rec) {
|
|
109
|
+
// The stream's own notes (a slow viewer's dropped lines, its end) aren't
|
|
110
|
+
// the phone's; the service notes an interruption itself.
|
|
111
|
+
if (rec.synthetic)
|
|
112
|
+
return [];
|
|
113
|
+
const key = keyOf(rec);
|
|
114
|
+
if (rec.ts < this.floor.ts || (rec.ts === this.floor.ts && this.floor.keys.has(key))) {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
if (!this.newest || rec.ts > this.newest.ts)
|
|
118
|
+
this.newest = { ts: rec.ts, keys: new Set([key]) };
|
|
119
|
+
else if (rec.ts === this.newest.ts)
|
|
120
|
+
this.newest.keys.add(key);
|
|
121
|
+
const out = [];
|
|
122
|
+
if (this.kept >= this.lineLimit && !this.limitNoted) {
|
|
123
|
+
this.limitNoted = true;
|
|
124
|
+
out.push(this.note(`This session reached ${count(this.lineLimit)} device log lines. ` +
|
|
125
|
+
'From here on, only errors are kept.', this.timeOf(rec)));
|
|
126
|
+
}
|
|
127
|
+
const room = this.kept < this.lineLimit || (isError(rec) && this.kept < this.lineLimit + this.errorLimit);
|
|
128
|
+
if (room) {
|
|
129
|
+
this.kept += 1;
|
|
130
|
+
out.push({ message: this.format(rec), timestamp: this.timeOf(rec) });
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
this.leftOut += 1;
|
|
134
|
+
}
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The stream ended while the session runs. The next one starts with
|
|
139
|
+
* history, so it may deliver only what is newer than what was seen.
|
|
140
|
+
*/
|
|
141
|
+
interrupted(at) {
|
|
142
|
+
if (this.newest)
|
|
143
|
+
this.floor = { ts: this.newest.ts, keys: new Set(this.newest.keys) };
|
|
144
|
+
return [this.note("The phone's log was interrupted. Lines may be missing from here.", at)];
|
|
145
|
+
}
|
|
146
|
+
/** The session ended: what was left out, if anything. */
|
|
147
|
+
finish(at) {
|
|
148
|
+
if (this.leftOut === 0)
|
|
149
|
+
return [];
|
|
150
|
+
const lines = this.leftOut === 1 ? '1 device log line was' : `${count(this.leftOut)} device log lines were`;
|
|
151
|
+
return [this.note(`${lines} left out to keep this session's log within its limit.`, at)];
|
|
152
|
+
}
|
|
153
|
+
/** Lines kept so far. */
|
|
154
|
+
get keptLines() {
|
|
155
|
+
return this.kept;
|
|
156
|
+
}
|
|
157
|
+
timeOf(rec) {
|
|
158
|
+
return new Date(rec.ts + this.clock.zoneShiftMs + this.clock.skewMs);
|
|
159
|
+
}
|
|
160
|
+
note(text, at) {
|
|
161
|
+
return { message: `Xenon: ${text}`, timestamp: at };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.DeviceLogBook = DeviceLogBook;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IosAppLines = exports.iosLineText = void 0;
|
|
4
|
+
exports.iosLineLevel = iosLineLevel;
|
|
5
|
+
exports.recordFromDriverLog = recordFromDriverLog;
|
|
6
|
+
exports.bufferedDriverLog = bufferedDriverLog;
|
|
7
|
+
exports.isDriverLog = isDriverLog;
|
|
8
|
+
// A real iPhone's syslog line: "Oct 5 20:31:40 iPhone SpringBoard(FrontBoard)[57] <Notice>: …".
|
|
9
|
+
const SYSLOG_LEVEL = /<(Fault|Error|Warning|Notice|Default|Info|Debug)>:/;
|
|
10
|
+
// A simulator's compact line: "2026-10-05 20:31:40.123 E SpringBoard[1234:5678] …".
|
|
11
|
+
const COMPACT_LEVEL = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+\s+(Df|Db|E|F|I|A)\s/;
|
|
12
|
+
const SYSLOG_LETTERS = {
|
|
13
|
+
Fault: 'F',
|
|
14
|
+
Error: 'E',
|
|
15
|
+
Warning: 'W',
|
|
16
|
+
Notice: 'I',
|
|
17
|
+
Default: 'I',
|
|
18
|
+
Info: 'I',
|
|
19
|
+
Debug: 'D',
|
|
20
|
+
};
|
|
21
|
+
const COMPACT_LETTERS = {
|
|
22
|
+
F: 'F',
|
|
23
|
+
E: 'E',
|
|
24
|
+
Df: 'I',
|
|
25
|
+
I: 'I',
|
|
26
|
+
A: 'I',
|
|
27
|
+
Db: 'D',
|
|
28
|
+
};
|
|
29
|
+
/** The level an iOS log line carries, as a logcat letter; `I` when it carries none. */
|
|
30
|
+
function iosLineLevel(message) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const syslog = (_a = SYSLOG_LEVEL.exec(message)) === null || _a === void 0 ? void 0 : _a[1];
|
|
33
|
+
if (syslog)
|
|
34
|
+
return SYSLOG_LETTERS[syslog];
|
|
35
|
+
const compact = (_b = COMPACT_LEVEL.exec(message)) === null || _b === void 0 ? void 0 : _b[1];
|
|
36
|
+
if (compact)
|
|
37
|
+
return COMPACT_LETTERS[compact];
|
|
38
|
+
return 'I';
|
|
39
|
+
}
|
|
40
|
+
// What `log stream` prints before its first line: not the device's.
|
|
41
|
+
const STREAM_BANNER = /^(Filtering the log data using |Timestamp\s+Ty\s+Process)/;
|
|
42
|
+
/**
|
|
43
|
+
* A driver entry as a record for the session's book, or null for what isn't
|
|
44
|
+
* a device line. A line without a level of its own (a message's continuation)
|
|
45
|
+
* is kept, as `I`.
|
|
46
|
+
*/
|
|
47
|
+
function recordFromDriverLog(entry) {
|
|
48
|
+
if (!entry || typeof entry.message !== 'string')
|
|
49
|
+
return null;
|
|
50
|
+
const message = entry.message.replace(/\s+$/, '');
|
|
51
|
+
if (!message || STREAM_BANNER.test(message))
|
|
52
|
+
return null;
|
|
53
|
+
const ts = Number(entry.timestamp);
|
|
54
|
+
return {
|
|
55
|
+
ts: Number.isFinite(ts) ? ts : Date.now(),
|
|
56
|
+
pid: 0,
|
|
57
|
+
tid: 0,
|
|
58
|
+
level: iosLineLevel(message),
|
|
59
|
+
tag: '',
|
|
60
|
+
message,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** An iOS record's row text: the line as the phone or simulator printed it. */
|
|
64
|
+
const iosLineText = (rec) => rec.message;
|
|
65
|
+
exports.iosLineText = iosLineText;
|
|
66
|
+
/**
|
|
67
|
+
* The lines the driver's log already holds, oldest first, without taking
|
|
68
|
+
* them: the ones from the create, before Xenon could listen. Reads the
|
|
69
|
+
* driver's internals (`logs`, an LRU cache keyed by arrival, and
|
|
70
|
+
* `_deserializeEntry`, as its own `getLogs()` does), so any other shape gives
|
|
71
|
+
* nothing rather than an error.
|
|
72
|
+
*/
|
|
73
|
+
function bufferedDriverLog(driverLog) {
|
|
74
|
+
var _a;
|
|
75
|
+
const log = driverLog;
|
|
76
|
+
if (typeof ((_a = log === null || log === void 0 ? void 0 : log.logs) === null || _a === void 0 ? void 0 : _a.rvalues) !== 'function' || typeof log._deserializeEntry !== 'function') {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const out = [];
|
|
81
|
+
for (const value of log.logs.rvalues())
|
|
82
|
+
out.push(log._deserializeEntry(value));
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
catch (_b) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** Whether `value` can be listened to as a driver log. */
|
|
90
|
+
function isDriverLog(value) {
|
|
91
|
+
const v = value;
|
|
92
|
+
return typeof (v === null || v === void 0 ? void 0 : v.on) === 'function' && typeof (v === null || v === void 0 ? void 0 : v.removeListener) === 'function';
|
|
93
|
+
}
|
|
94
|
+
// A line's process, the library that logged it and its pid: an iPhone's
|
|
95
|
+
// "… Rabindras-iPhone Edge(UIKitCore)[8788] <Notice>: …" or a simulator's
|
|
96
|
+
// "2026-10-05 20:31:40.123 Df Shop[4127:8812] (UIKitCore) …".
|
|
97
|
+
const SYSLOG_HEADER = /^\w{3}\s+\d+ \d\d:\d\d:\d\d \S+ ([^\s[(]+)(?:\(([^)]*)\))?\[(\d+)\]/;
|
|
98
|
+
const COMPACT_HEADER = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+\s+\S+\s+([^\s[]+)\[(\d+)(?::\d+)?\](?:\s+\(([^)]*)\))?/;
|
|
99
|
+
function headerOf(message) {
|
|
100
|
+
const syslog = SYSLOG_HEADER.exec(message);
|
|
101
|
+
if (syslog)
|
|
102
|
+
return { name: syslog[1], sender: syslog[2] || undefined, pid: syslog[3] };
|
|
103
|
+
const compact = COMPACT_HEADER.exec(message);
|
|
104
|
+
if (compact)
|
|
105
|
+
return { name: compact[1], sender: compact[3] || undefined, pid: compact[2] };
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
109
|
+
/**
|
|
110
|
+
* Which of an iPhone's or simulator's lines a session keeps: what the app
|
|
111
|
+
* under test's own code logs, every error and fault inside its process, what
|
|
112
|
+
* the phone's app manager says about it (its launch, its state, how it
|
|
113
|
+
* ended), the crash reports and memory kills that name it, and every fault.
|
|
114
|
+
*
|
|
115
|
+
* A phone logs hundreds of lines a second. Measured on an iPhone 14 Plus
|
|
116
|
+
* (iOS 26.5): about 53,000 in a one-minute session, which filled the
|
|
117
|
+
* 10,000-line limit during the create. Keeping the app's whole process wasn't
|
|
118
|
+
* enough either: Edge's process logged about 110 lines a second, of which
|
|
119
|
+
* its own code wrote 5 in 8,839. The rest was Apple's frameworks inside it
|
|
120
|
+
* (UIKit, Network, CFNetwork, WebKit), so their ordinary lines are left out
|
|
121
|
+
* and their errors kept. Only `runningboardd` and `SpringBoard` are kept for
|
|
122
|
+
* naming the app: about twenty other daemons each log every change of its
|
|
123
|
+
* state ("Received state update for 8723 (app<…"), 3,000 lines in 78 s.
|
|
124
|
+
*
|
|
125
|
+
* The app's process is learnt from the lines: the phone announces it by
|
|
126
|
+
* bundle id and pid (`app<com.example.shop(…)>:4127`, `pid: 4127 bundleID:
|
|
127
|
+
* com.example.shop`), and the lines of that pid give its executable's name,
|
|
128
|
+
* so a crash report or a memory kill that names it (`Shop[4127]`, `[Shop]`,
|
|
129
|
+
* `corpse[4127]`) is kept too. A line with no header of its own continues
|
|
130
|
+
* the one before.
|
|
131
|
+
*/
|
|
132
|
+
// The processes whose lines about the app say how it lives and ends: its
|
|
133
|
+
// launch, assertions and exit with its reason (RunningBoard), its scenes and
|
|
134
|
+
// windows (SpringBoard).
|
|
135
|
+
const APP_MANAGERS = new Set(['runningboardd', 'SpringBoard']);
|
|
136
|
+
class IosAppLines {
|
|
137
|
+
constructor(bundleId) {
|
|
138
|
+
this.bundleId = bundleId;
|
|
139
|
+
this.pids = new Set();
|
|
140
|
+
this.names = new Set();
|
|
141
|
+
this.lastKept = false;
|
|
142
|
+
const id = escapeRegExp(bundleId);
|
|
143
|
+
this.pidAnnounced = [
|
|
144
|
+
new RegExp(`app<${id}[^>]*>:(\\d+)`, 'g'),
|
|
145
|
+
new RegExp(`pid:? (\\d+),? bundleID:? ${id}\\b`, 'g'),
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
/** Learns the app's pid and executable from a line, without deciding on it. */
|
|
149
|
+
learn(message) {
|
|
150
|
+
if (message.includes(this.bundleId)) {
|
|
151
|
+
for (const re of this.pidAnnounced) {
|
|
152
|
+
for (const m of message.matchAll(re))
|
|
153
|
+
this.pids.add(m[1]);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const header = headerOf(message);
|
|
157
|
+
if (header && this.pids.has(header.pid))
|
|
158
|
+
this.names.add(header.name);
|
|
159
|
+
}
|
|
160
|
+
/** Whether the session keeps the line. */
|
|
161
|
+
keeps(message, level) {
|
|
162
|
+
this.learn(message);
|
|
163
|
+
const header = headerOf(message);
|
|
164
|
+
if (!header)
|
|
165
|
+
return this.lastKept;
|
|
166
|
+
const { name, sender, pid } = header;
|
|
167
|
+
const inApp = this.pids.has(pid) || this.names.has(name);
|
|
168
|
+
const keep = level === 'F' ||
|
|
169
|
+
(inApp && (level === 'E' || !sender || this.names.has(sender))) ||
|
|
170
|
+
(APP_MANAGERS.has(name) && message.includes(this.bundleId)) ||
|
|
171
|
+
(!inApp &&
|
|
172
|
+
([...this.names].some((n) => message.includes(`${n}[`) || message.includes(`[${n}]`)) ||
|
|
173
|
+
[...this.pids].some((p) => message.includes(`[${p}]`))));
|
|
174
|
+
this.lastKept = keep;
|
|
175
|
+
return keep;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.IosAppLines = IosAppLines;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OCR_START_RETRY_MS = exports.OCR_DATA_SHA256 = exports.OCR_DATA_FILE = exports.OCR_DATA_DIR = exports.OCR_LANGUAGE = void 0;
|
|
16
|
+
exports.ocrWorkerOptions = ocrWorkerOptions;
|
|
17
|
+
exports.createOcrWorker = createOcrWorker;
|
|
18
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
19
|
+
const fs_1 = __importDefault(require("fs"));
|
|
20
|
+
const path_1 = __importDefault(require("path"));
|
|
21
|
+
const tesseract_js_1 = __importDefault(require("tesseract.js"));
|
|
22
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
23
|
+
/**
|
|
24
|
+
* The language data every OCR worker reads, shipped with the plugin
|
|
25
|
+
* (vendor/README.md says where it comes from).
|
|
26
|
+
*
|
|
27
|
+
* Left to its defaults, tesseract.js downloads eng.traineddata from
|
|
28
|
+
* cdn.jsdelivr.net when a worker starts, and caches it in the process's working
|
|
29
|
+
* directory. So a server with no internet couldn't run OCR at all, and one with
|
|
30
|
+
* internet left a 5 MB eng.traineddata wherever it was started (the home
|
|
31
|
+
* directory, ~/.appium). Through 2.14 that was every Xenon server.
|
|
32
|
+
*/
|
|
33
|
+
exports.OCR_LANGUAGE = 'eng';
|
|
34
|
+
exports.OCR_DATA_DIR = path_1.default.join(__dirname, 'vendor');
|
|
35
|
+
exports.OCR_DATA_FILE = path_1.default.join(exports.OCR_DATA_DIR, `${exports.OCR_LANGUAGE}.traineddata.gz`);
|
|
36
|
+
/** The shipped file's SHA-256, as vendor/README.md gives it. */
|
|
37
|
+
exports.OCR_DATA_SHA256 = '45b4cb346724ac1774f1c36f42f182b887bcdb28ebe63e6fff90ac41f3fcff91';
|
|
38
|
+
/**
|
|
39
|
+
* What a worker is given: read the data from `dataDir` (a directory, never a
|
|
40
|
+
* URL, so nothing is fetched), and cache it nowhere. A job's own failure
|
|
41
|
+
* rejects its promise; without an errorHandler tesseract.js also throws it from
|
|
42
|
+
* the worker's message handler, where nothing can catch it.
|
|
43
|
+
*/
|
|
44
|
+
function ocrWorkerOptions(dataDir = exports.OCR_DATA_DIR) {
|
|
45
|
+
return {
|
|
46
|
+
langPath: dataDir,
|
|
47
|
+
cacheMethod: 'none',
|
|
48
|
+
gzip: true,
|
|
49
|
+
errorHandler: (err) => logger_1.default.warn(`OCR: ${err}`),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* How long a worker that wouldn't start is remembered. tesseract.js hands back
|
|
54
|
+
* no worker when its start fails, so its thread can't be ended; starting one
|
|
55
|
+
* per OCR call would leave one more each time.
|
|
56
|
+
*/
|
|
57
|
+
exports.OCR_START_RETRY_MS = 60000;
|
|
58
|
+
const startFailures = new Map();
|
|
59
|
+
/** Files whose data checked out, so each is read and hashed once per process. */
|
|
60
|
+
const checked = new Set();
|
|
61
|
+
/**
|
|
62
|
+
* The data is the file the plugin ships, whole. tesseract.js 7, given data it
|
|
63
|
+
* can't load, answers a job it has already refused and throws a TypeError from
|
|
64
|
+
* its message handler, which ends the server (src/index.ts exits on an
|
|
65
|
+
* uncaught exception). So a damaged install is refused here, before a worker
|
|
66
|
+
* sees it.
|
|
67
|
+
*/
|
|
68
|
+
function checkData(file) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
if (checked.has(file))
|
|
71
|
+
return;
|
|
72
|
+
let data;
|
|
73
|
+
try {
|
|
74
|
+
data = yield fs_1.default.promises.readFile(file);
|
|
75
|
+
}
|
|
76
|
+
catch (_a) {
|
|
77
|
+
throw new Error(`OCR can't start: its language data is missing (${file})`);
|
|
78
|
+
}
|
|
79
|
+
if (crypto_1.default.createHash('sha256').update(data).digest('hex') !== exports.OCR_DATA_SHA256) {
|
|
80
|
+
throw new Error(`OCR can't start: its language data is damaged (${file})`);
|
|
81
|
+
}
|
|
82
|
+
checked.add(file);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* An OCR worker for English, from the data that ships with the plugin. Fails
|
|
87
|
+
* with the reason when it can't start: a worker whose data won't load never
|
|
88
|
+
* settles otherwise, and OmniVisionService's lock would wait on it for ever.
|
|
89
|
+
*/
|
|
90
|
+
function createOcrWorker() {
|
|
91
|
+
return __awaiter(this, arguments, void 0, function* (dataDir = exports.OCR_DATA_DIR) {
|
|
92
|
+
const recent = startFailures.get(dataDir);
|
|
93
|
+
if (recent && Date.now() - recent.at < exports.OCR_START_RETRY_MS)
|
|
94
|
+
throw recent.error;
|
|
95
|
+
yield checkData(path_1.default.join(dataDir, `${exports.OCR_LANGUAGE}.traineddata.gz`));
|
|
96
|
+
let failed;
|
|
97
|
+
const failure = new Promise((_, reject) => {
|
|
98
|
+
failed = reject;
|
|
99
|
+
});
|
|
100
|
+
const options = ocrWorkerOptions(dataDir);
|
|
101
|
+
const logError = options.errorHandler;
|
|
102
|
+
const worker = tesseract_js_1.default.createWorker(exports.OCR_LANGUAGE, tesseract_js_1.default.OEM.LSTM_ONLY, Object.assign(Object.assign({}, options), { errorHandler: (err) => {
|
|
103
|
+
logError(err);
|
|
104
|
+
failed(new Error(`OCR can't start: ${err}`));
|
|
105
|
+
} }));
|
|
106
|
+
try {
|
|
107
|
+
// Once the worker has started, a later job's failure is only logged.
|
|
108
|
+
const started = yield Promise.race([worker, failure]);
|
|
109
|
+
startFailures.delete(dataDir);
|
|
110
|
+
return started;
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
const error = err instanceof Error ? err : new Error(`OCR can't start: ${err}`);
|
|
114
|
+
startFailures.set(dataDir, { at: Date.now(), error });
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
Binary file
|