@lowdefy/server-dev 7.0.0 → 7.2.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/client/Inspector.jsx +24 -75
- package/client/Page.jsx +8 -0
- package/client/Routing.jsx +0 -2
- package/client/clientBuildImports.test.mjs +5 -3
- package/client/devStreamConnections.test.mjs +1 -0
- package/client/journeyObserver/startJourneyObserver.test.mjs +11 -11
- package/client/openInEditor/OpenInEditorListener.jsx +36 -29
- package/client/openInEditor/OpenInEditorListener.test.mjs +116 -0
- package/client/{feedback → openInEditor}/elementInspect.js +9 -44
- package/client/openInEditor/findBlockLocation.js +2 -2
- package/client/openInEditor/openInEditorStyles.js +56 -0
- package/client/recorder/createPairingBuffer.test.mjs +27 -9
- package/client/recorder/createRecorder.js +11 -7
- package/client/recorder/createRecorder.test.mjs +9 -9
- package/client/recorder/isPasswordElement.js +41 -0
- package/client/recorder/keyChord.test.mjs +1 -0
- package/{client/recorder/toJsonSafe.js → lib/build/mobileConfig.js} +9 -12
- package/lib/client/auth/AuthConfigured.jsx +75 -48
- package/lib/client/auth/authNotConfiguredParity.test.mjs +1 -0
- package/lib/client/auth/authTemplateSync.test.mjs +1 -0
- package/lib/client/auth/betterAuthSessionContract.test.mjs +2 -1
- package/lib/client/auth/sessionCaller.js +56 -0
- package/lib/client/auth/sessionCaller.test.mjs +78 -0
- package/lib/client/getPagePath.test.mjs +1 -0
- package/lib/client/utils/formatErrorsForCopy.test.mjs +1 -0
- package/lib/client/utils/getErrorBarColor.test.mjs +1 -0
- package/lib/client/utils/usePageConfig.test.mjs +15 -15
- package/lib/configTree/buildConfigTree.test.mjs +6 -8
- package/lib/configTree/collectConfigText.test.mjs +1 -0
- package/lib/configTree/runConfigTreeBuild.mjs +2 -1
- package/lib/configTree/runConfigTreeBuild.skipPluginChecks.test.mjs +11 -11
- package/lib/configTree/runConfigTreeBuild.test.mjs +2 -2
- package/lib/docs/addNestedEndpoints.test.mjs +1 -0
- package/lib/docs/checkAgentFiles.test.mjs +1 -0
- package/lib/docs/checkStepReferences.test.mjs +3 -3
- package/lib/docs/clientErrorStore.test.mjs +4 -4
- package/lib/docs/createBrowserLifecycle.test.mjs +40 -24
- package/lib/docs/createDocsMcpServer.js +195 -138
- package/lib/docs/createDocsMcpServer.test.mjs +331 -25
- package/lib/docs/createDocsMcpServerRunJourney.test.mjs +5 -5
- package/lib/docs/createJourneyActors.chromium.test.mjs +3 -3
- package/lib/docs/createJourneyActors.test.mjs +4 -4
- package/lib/docs/dataSets/checkSharedCollectionIds.js +20 -9
- package/lib/docs/dataSets/dataSetJourneys.chromium.mongodb.test.mjs +59 -11
- package/{src/routes/docs/content.js → lib/docs/dataSets/describeTargetKey.js} +10 -14
- package/lib/docs/dataSets/drainSessionWork.test.mjs +21 -5
- package/lib/docs/dataSets/getDataStore.js +11 -3
- package/lib/docs/dataSets/getDataStore.mongodb.test.mjs +3 -3
- package/lib/docs/dataSets/getDataStore.test.mjs +32 -20
- package/lib/docs/dataSets/groupDataSetByCollection.js +19 -11
- package/lib/docs/dataSets/mergeCollectionIndexes.test.mjs +1 -0
- package/lib/docs/dataSets/openDataSession.js +36 -20
- package/lib/docs/dataSets/openDataSession.mongodb.test.mjs +175 -7
- package/lib/docs/dataSets/pickDataStorePort.test.mjs +2 -2
- package/lib/docs/dataSets/readDataSession.test.mjs +1 -0
- package/lib/docs/dataSets/readDataSet.js +34 -19
- package/lib/docs/dataSets/readDataSet.test.mjs +57 -25
- package/lib/docs/dataSets/resolveJourneyDataSet.test.mjs +1 -0
- package/lib/docs/dataSets/sessionDatabaseName.js +32 -0
- package/lib/docs/dataSets/sweepOrphanDatabases.js +7 -4
- package/lib/docs/dataSets/test/app/lowdefy.yaml +22 -0
- package/lib/docs/dataSets/test/app/tests/data/shop.yaml +4 -0
- package/lib/docs/dataSets/test/buildTestApp.mjs +1 -1
- package/lib/docs/devEventBus.js +7 -2
- package/lib/docs/devEventBus.test.mjs +12 -10
- package/lib/docs/devToolDefinitions.js +87 -135
- package/lib/docs/device/buildDeviceCommand.js +103 -0
- package/lib/docs/device/buildDeviceCommand.test.mjs +142 -0
- package/lib/docs/device/captureDevice.js +85 -0
- package/lib/docs/device/checkShownPage.js +56 -0
- package/lib/docs/device/createFakePhoneTab.mjs +77 -0
- package/lib/docs/device/deviceAction.js +74 -0
- package/lib/docs/device/deviceTools.test.mjs +604 -0
- package/lib/docs/device/findDeviceTab.js +50 -0
- package/lib/docs/device/findDeviceTarget.js +73 -0
- package/lib/docs/device/injectDevice.js +160 -0
- package/lib/docs/device/listDevices.js +100 -0
- package/lib/docs/device/listDevices.test.mjs +105 -0
- package/lib/docs/device/runDeviceJourney.js +68 -0
- package/lib/docs/device/runDeviceSteps.js +164 -0
- package/lib/docs/device/screenshotDevice.js +68 -0
- package/lib/docs/device/sendDeviceStep.js +52 -0
- package/lib/docs/device/startDevice.js +150 -0
- package/lib/docs/docs.test.mjs +44 -28
- package/lib/docs/docsIndex.test.mjs +1 -0
- package/lib/docs/findConfig.js +3 -4
- package/lib/docs/findPageBlock.js +35 -0
- package/lib/docs/findPageBlock.test.mjs +45 -0
- package/lib/docs/fitResponse.js +18 -17
- package/lib/docs/fitResponse.test.mjs +18 -0
- package/lib/docs/getBrowser.js +4 -4
- package/lib/docs/getBrowser.test.mjs +32 -16
- package/lib/docs/getBuildId.test.mjs +1 -0
- package/lib/docs/getBuildStatus.js +29 -3
- package/lib/docs/getBuildStatus.test.mjs +108 -12
- package/lib/docs/getBuildStatusAfterEdits.test.mjs +8 -8
- package/{src/routes/docs/appMap.js → lib/docs/getConfigDirectory.js} +3 -5
- package/lib/docs/getHazards.js +4 -1
- package/lib/docs/getHazards.test.mjs +9 -7
- package/lib/docs/getOverview.js +22 -44
- package/lib/docs/getOverviewBasePath.test.mjs +1 -0
- package/lib/docs/getStaleStatus.test.mjs +1 -0
- package/lib/docs/inspectState.js +78 -3
- package/lib/docs/inspectState.test.mjs +61 -9
- package/lib/docs/inspectStateFromTab.js +38 -6
- package/lib/docs/inspectStateFromTab.test.mjs +79 -0
- package/lib/docs/inspectStateHeadless.js +98 -34
- package/lib/docs/inspectStateHeadless.test.mjs +17 -5
- package/lib/docs/installHeadlessShell.failure.test.mjs +9 -5
- package/lib/docs/installHeadlessShell.js +5 -2
- package/lib/docs/installHeadlessShell.test.mjs +8 -5
- package/lib/docs/installHeadlessShell.timeout.test.mjs +32 -12
- package/lib/docs/isDeepEqual.js +37 -0
- package/lib/docs/isHeadlessShellIncomplete.test.mjs +1 -0
- package/lib/docs/isPageReady.test.mjs +1 -0
- package/lib/docs/journeyMutantCookie.chromium.test.mjs +3 -3
- package/lib/docs/journeyRunRecording.test.mjs +1 -0
- package/lib/docs/keepEventStreamAlive.test.mjs +1 -0
- package/lib/docs/launchBrowser.test.mjs +8 -8
- package/lib/docs/listTypes.js +58 -8
- package/lib/docs/loadFrameworkHazards.test.mjs +1 -0
- package/lib/docs/matchJourneyRoute.test.mjs +1 -0
- package/lib/docs/observe/createJourneyAppErrors.test.mjs +3 -3
- package/lib/docs/observe/evaluateInvariants.test.mjs +1 -0
- package/lib/docs/observe/hasNoEffect.test.mjs +1 -0
- package/lib/docs/observe/withAppErrors.test.mjs +1 -0
- package/lib/docs/openJourneyEmail.test.mjs +6 -6
- package/lib/docs/pageBuildStatus.test.mjs +6 -6
- package/lib/docs/pollTab.js +100 -0
- package/lib/docs/pollTab.test.mjs +64 -0
- package/lib/docs/rails/authEngineActions.test.mjs +1 -0
- package/lib/docs/rails/authEngineMethods.test.mjs +2 -1
- package/lib/docs/rails/checkAuthActionsRan.test.mjs +5 -5
- package/lib/docs/rails/createDataSetRails.test.mjs +1 -0
- package/lib/docs/rails/findExternalBlocks.js +3 -3
- package/lib/docs/rails/findExternalBlocks.test.mjs +1 -0
- package/lib/docs/readJourneyEmailMatch.test.mjs +2 -2
- package/lib/docs/readJourneySession.js +1 -1
- package/lib/docs/reportDevToolFault.js +29 -0
- package/lib/docs/reportDevToolFault.test.mjs +34 -0
- package/lib/docs/requestRestart.test.mjs +1 -0
- package/lib/docs/resolvePageInstance.test.mjs +1 -0
- package/lib/docs/resolveSource.js +2 -2
- package/lib/docs/resolveSource.test.mjs +6 -6
- package/lib/docs/reviewPageBuilds.test.mjs +2 -2
- package/lib/docs/runCheck.test.mjs +3 -3
- package/lib/docs/runCheckChild.js +2 -1
- package/lib/docs/runEndpoint.js +23 -10
- package/lib/docs/runEndpoint.test.mjs +42 -37
- package/lib/docs/runErrorBuffers.test.mjs +1 -0
- package/lib/docs/runJourney.js +21 -1
- package/lib/docs/runJourney.test.mjs +119 -99
- package/lib/docs/runJourneyDataSet.test.mjs +26 -26
- package/lib/docs/runJourneySteps.js +8 -29
- package/lib/docs/runRequest.js +6 -6
- package/lib/docs/runRequest.test.mjs +22 -22
- package/lib/docs/screenshotPage.js +6 -7
- package/lib/docs/screenshotPage.test.mjs +46 -46
- package/lib/docs/screenshotPageClip.test.mjs +10 -10
- package/lib/docs/searchDocs.test.mjs +1 -0
- package/lib/docs/searchIcons.test.mjs +5 -5
- package/lib/docs/selectFinalState.test.mjs +1 -0
- package/lib/docs/serverErrorStore.test.mjs +4 -4
- package/lib/docs/setupTestFixtures.mjs +25 -0
- package/lib/docs/splitSearchTerms.test.mjs +1 -0
- package/lib/docs/tabAvailable.js +1 -1
- package/lib/docs/tabChannel.js +90 -14
- package/lib/docs/tabChannel.test.mjs +40 -15
- package/lib/docs/validateJourneyTimeout.test.mjs +1 -0
- package/lib/docs/validateStateSelection.test.mjs +1 -0
- package/lib/docs/validateViewport.test.mjs +1 -0
- package/lib/docs/waitForBuild.test.mjs +1 -0
- package/lib/docs/withBrowserSlot.test.mjs +5 -5
- package/lib/docs/withDataSession.js +2 -2
- package/lib/server/applyDataSetRedirect.js +14 -5
- package/lib/server/applyDataSetRedirect.test.mjs +121 -15
- package/lib/server/applyDataSetRedirectTenantReach.test.mjs +5 -1
- package/lib/server/applyDataSetRedirectWalled.test.mjs +5 -1
- package/lib/server/auth/getHeadlessUser.js +6 -0
- package/lib/server/auth/getHeadlessUser.test.mjs +13 -2
- package/lib/server/auth/resolveHeadlessUser.test.mjs +1 -0
- package/lib/server/contextMapBudget.test.mjs +3 -3
- package/lib/server/continueJitKeys.test.mjs +1 -0
- package/lib/server/createLowdefyContext.js +8 -4
- package/lib/server/createLowdefyContext.test.mjs +38 -35
- package/lib/server/getClientAddress.test.mjs +2 -2
- package/lib/server/getPageJitEnrichment.test.mjs +1 -0
- package/lib/server/importAppCode.test.mjs +2 -2
- package/lib/server/jitPageBuilder.js +27 -3
- package/lib/server/jitPageBuilder.mobileTypes.test.mjs +65 -0
- package/lib/server/jitPageBuilder.skipPluginChecks.test.mjs +5 -6
- package/lib/server/jitPageBuilder.test.mjs +4 -4
- package/lib/server/journeyCookies.test.mjs +1 -0
- package/lib/server/loadDynamicJsMap.js +10 -1
- package/lib/server/log/createHandleError.js +10 -5
- package/lib/server/log/createHandleError.test.mjs +19 -8
- package/lib/server/log/createLogger.test.mjs +2 -2
- package/lib/server/mutantDataSetWrappers.test.mjs +5 -1
- package/lib/server/mutants/listMutants.test.mjs +1 -0
- package/lib/server/mutants/mutantRuns.test.mjs +1 -0
- package/lib/server/mutants/operators.test.mjs +1 -0
- package/lib/server/pageBuildRecords.test.mjs +1 -0
- package/lib/server/pageCache.test.mjs +1 -0
- package/lib/server/pageRebuilds.test.mjs +3 -3
- package/{src/routes/docs/examples.js → lib/server/pairingHeaders.js} +8 -15
- package/lib/server/pruneJitMaps.test.mjs +1 -0
- package/lib/server/readBuildApiArtifacts.test.mjs +1 -0
- package/lib/server/readInstanceRecord.test.mjs +24 -8
- package/lib/server/readMergedMaps.test.mjs +1 -0
- package/lib/server/recording/errorRecordingStamp.test.mjs +1 -0
- package/lib/server/recording/readRecordingCookie.test.mjs +2 -0
- package/lib/server/recording/servedBuilds.test.mjs +1 -0
- package/lib/server/sinkExternalConnections.test.mjs +6 -6
- package/lib/server/skipStaleMapWrites.test.mjs +12 -12
- package/lib/server/startIdleGc.test.mjs +25 -9
- package/lib/server/testFixtures/importAppCodeTwice.mjs +2 -2
- package/lib/vite/createDevServerExclude.test.mjs +1 -0
- package/manager/getContext.mjs +11 -2
- package/manager/processes/checkPendingPlugins.mjs +49 -0
- package/manager/processes/checkPendingPlugins.test.mjs +107 -0
- package/manager/processes/createIdleChild.mjs +141 -0
- package/manager/processes/createIdleChild.test.mjs +209 -0
- package/manager/processes/initialBuild.mjs +4 -15
- package/manager/processes/initialBuild.test.mjs +8 -37
- package/manager/processes/lowdefyBuild.mjs +11 -7
- package/manager/processes/lowdefyBuild.skipPluginChecks.test.mjs +23 -13
- package/manager/processes/lowdefyBuild.test.mjs +17 -15
- package/manager/processes/restartServer.test.mjs +63 -15
- package/manager/processes/shutdownServer.test.mjs +3 -3
- package/manager/processes/startFirstServer.test.mjs +23 -22
- package/manager/processes/startMailSink.mjs +11 -3
- package/manager/processes/startMailSink.test.mjs +28 -2
- package/manager/processes/startProxy.mjs +158 -27
- package/manager/processes/startProxy.pairing.test.mjs +204 -0
- package/manager/processes/startProxy.test.mjs +127 -2
- package/manager/processes/startServer.mjs +5 -7
- package/manager/processes/startServer.test.mjs +10 -9
- package/manager/processes/syncServer.mjs +31 -4
- package/manager/processes/syncServer.test.mjs +71 -6
- package/manager/processes/waitForDevServer.test.mjs +21 -6
- package/manager/run.mjs +32 -8
- package/manager/utils/BatchChanges.mjs +1 -1
- package/manager/utils/BatchChanges.test.mjs +4 -4
- package/manager/utils/acquireDevInstance.test.mjs +1 -0
- package/manager/utils/checkPairing.mjs +45 -0
- package/manager/utils/checkPairing.test.mjs +53 -0
- package/manager/utils/createBuildActivity.mjs +5 -1
- package/manager/utils/createBuildActivity.test.mjs +2 -2
- package/manager/utils/createChangeSignal.test.mjs +5 -5
- package/manager/utils/createCustomPluginMessagesMap.mjs +8 -3
- package/manager/utils/createCustomPluginTypesMap.mjs +48 -12
- package/manager/utils/createCustomPluginTypesMap.test.mjs +181 -19
- package/manager/utils/createDotPathIgnore.test.mjs +1 -0
- package/manager/utils/createGlobIgnore.mjs +45 -0
- package/manager/utils/createGlobIgnore.test.mjs +58 -0
- package/manager/utils/createGlobWatchPaths.mjs +75 -0
- package/manager/utils/createGlobWatchPaths.test.mjs +67 -0
- package/manager/utils/createIdleGc.test.mjs +31 -15
- package/manager/utils/createLanPairing.mjs +34 -0
- package/manager/utils/createLanPairing.test.mjs +46 -0
- package/manager/utils/createRequestActivity.mjs +30 -3
- package/manager/utils/createRequestActivity.test.mjs +76 -22
- package/manager/utils/createServerArtifactTracker.mjs +1 -0
- package/manager/utils/createServerArtifactTracker.test.mjs +1 -0
- package/manager/utils/findBuildFilesOutsideWatch.test.mjs +1 -0
- package/{client/recorder/collectEventActions.js → manager/utils/findSignInCode.mjs} +13 -10
- package/manager/utils/findSignInCode.test.mjs +33 -0
- package/manager/utils/formatLanPairing.mjs +32 -0
- package/manager/utils/formatLanPairing.test.mjs +40 -0
- package/manager/utils/getLanAddress.mjs +83 -0
- package/manager/utils/getLanAddress.test.mjs +70 -0
- package/manager/utils/importFresh.test.mjs +1 -0
- package/{src/routes/docs/icons.js → manager/utils/isLoopbackAddress.mjs} +11 -10
- package/manager/utils/pluginTypeCache.mjs +100 -0
- package/manager/utils/pluginTypeCache.test.mjs +141 -0
- package/manager/utils/pruneRecordings.test.mjs +1 -0
- package/manager/utils/publishBuildDirectory.order.test.mjs +2 -2
- package/manager/utils/publishBuildDirectory.test.mjs +6 -7
- package/manager/utils/readBasePath.test.mjs +1 -0
- package/manager/utils/readManagerVersion.test.mjs +1 -0
- package/manager/utils/readPluginDefinitions.mjs +6 -6
- package/manager/utils/renderTerminalQr.mjs +54 -0
- package/manager/utils/resolveDevAuthUrl.test.mjs +1 -0
- package/manager/utils/setupWatcher.mjs +19 -4
- package/manager/utils/startRecordingPruner.test.mjs +24 -8
- package/manager/utils/waitForChildExit.test.mjs +2 -2
- package/manager/utils/writeBuildStatus.test.mjs +1 -0
- package/manager/watchers/envWatcher.mjs +3 -0
- package/manager/watchers/envWatcher.test.mjs +19 -7
- package/manager/watchers/listServerPluginFiles.mjs +188 -0
- package/manager/watchers/listServerPluginFiles.test.mjs +257 -0
- package/manager/watchers/lowdefyBuildWatcher.mjs +5 -0
- package/manager/watchers/lowdefyBuildWatcher.test.mjs +63 -10
- package/manager/watchers/pluginSourceWatcher.mjs +45 -17
- package/manager/watchers/pluginSourceWatcher.test.mjs +97 -21
- package/manager/watchers/resolveFile.mjs +46 -0
- package/manager/watchers/resolveFile.test.mjs +67 -0
- package/manager/watchers/resolvePackageSpecifier.mjs +127 -0
- package/manager/watchers/resolvePackageSpecifier.test.mjs +151 -0
- package/manager/watchers/restartRequestWatcher.mjs +7 -4
- package/manager/watchers/restartRequestWatcher.test.mjs +43 -6
- package/manager/watchers/selectLocalPluginPackages.test.mjs +1 -0
- package/package.json +50 -49
- package/package.original.json +50 -49
- package/src/app.js +83 -85
- package/src/html/renderDevPage.test.mjs +1 -0
- package/src/lib/getPathSegments.js +16 -1
- package/src/{routes/docs/checkpointsList.js → lib/getRequestSurface.js} +6 -4
- package/src/lib/isTabAnswer.js +32 -0
- package/src/lib/isTabChannelCaller.js +35 -0
- package/src/middleware/apiContext.js +4 -2
- package/src/middleware/createSameOriginGuard.test.mjs +1 -0
- package/src/middleware/errorHandler.js +33 -45
- package/src/middleware/errorHandler.test.mjs +10 -10
- package/src/middleware/isRebindingSafeHost.test.mjs +1 -0
- package/src/middleware/localDevToolsOnly.js +13 -1
- package/src/middleware/localDevToolsOnly.test.mjs +36 -2
- package/src/middleware/noStore.test.mjs +1 -0
- package/src/middleware/staleFlag.test.mjs +1 -0
- package/src/middleware/stampCaller.test.mjs +1 -0
- package/src/routes/agentBearer.test.mjs +183 -0
- package/src/routes/auth.test.mjs +10 -10
- package/src/routes/clientError.js +21 -4
- package/src/routes/clientError.test.mjs +127 -0
- package/src/routes/devInspect.js +6 -51
- package/src/routes/devInspect.test.mjs +128 -3
- package/src/routes/devRecording.js +6 -17
- package/src/routes/devRecording.test.mjs +54 -3
- package/src/routes/docs/buildStatus.test.mjs +6 -6
- package/src/routes/docs/events.test.mjs +4 -4
- package/src/routes/docs/find.js +3 -3
- package/src/routes/docs/journey.test.mjs +8 -8
- package/src/routes/docs/journeyRefusals.test.mjs +9 -9
- package/src/routes/docs/loadDocsRoutes.js +70 -0
- package/src/routes/docs/loadDocsRoutes.test.mjs +110 -0
- package/src/routes/docs/mcp.test.mjs +5 -5
- package/src/routes/docs/mutants.js +7 -0
- package/src/routes/docs/mutants.test.mjs +20 -6
- package/src/routes/docs/parsePathParamsParam.test.mjs +1 -0
- package/src/routes/docs/parseUserParam.test.mjs +1 -0
- package/src/routes/docs/restart.test.mjs +1 -0
- package/src/routes/endpoints.js +24 -0
- package/src/routes/endpointsLink.test.mjs +111 -0
- package/src/routes/endpointsTextAnswer.test.mjs +8 -8
- package/src/routes/jitPage.js +13 -1
- package/src/routes/jitPage.test.mjs +36 -11
- package/src/routes/mcp.js +6 -0
- package/src/routes/mcp.test.mjs +23 -8
- package/src/routes/mcpMemberToken.test.mjs +8 -8
- package/src/routes/mcpProtectedResourceMetadata.test.mjs +2 -2
- package/src/routes/{docs/checkpointsRevert.js → mobileRoot.js} +10 -13
- package/src/routes/mobileRoutes.test.mjs +223 -0
- package/src/routes/mobileSignIn.js +58 -0
- package/src/routes/mobileSignIn.test.mjs +59 -0
- package/src/routes/mobileSignInCallback.js +34 -0
- package/src/routes/mobileSignInCallback.test.mjs +51 -0
- package/src/routes/mountDevPageRoutes.js +10 -2
- package/src/routes/mountDevPageRoutes.test.mjs +25 -1
- package/src/routes/mountMobileWellKnown.js +35 -0
- package/src/routes/mountMobileWellKnown.test.mjs +79 -0
- package/src/routes/mountOauthDiscovery.test.mjs +5 -5
- package/src/routes/normalizeMcpProtocolVersionHeader.test.mjs +1 -0
- package/src/routes/reload.js +101 -20
- package/src/routes/reload.test.mjs +153 -0
- package/src/routes/request.js +1 -22
- package/src/routes/request.test.mjs +7 -24
- package/src/routes/requestBody.test.mjs +14 -27
- package/src/routes/websocket.test.mjs +2 -2
- package/src/routes/wellKnownFallback.test.mjs +2 -2
- package/src/websocket/devWebSocket.test.mjs +12 -12
- package/vite.config.js +13 -1
- package/client/feedback/FeedbackMount.jsx +0 -83
- package/client/feedback/FeedbackOverlay.jsx +0 -904
- package/client/feedback/captureTabScreenshot.js +0 -84
- package/client/feedback/copyToClipboard.js +0 -45
- package/client/feedback/drawAnnotationsSvg.js +0 -119
- package/client/feedback/feedbackStyles.js +0 -304
- package/client/feedback/pinResponsiveImages.js +0 -59
- package/client/feedback/sendFeedback.js +0 -39
- package/client/feedback/useFeedbackToggle.js +0 -70
- package/client/recorder/buildEngineRecord.js +0 -37
- package/client/recorder/buildInteractionRecord.js +0 -64
- package/client/recorder/buildTraceEvent.js +0 -57
- package/client/recorder/buildTraceEvent.test.mjs +0 -81
- package/client/recorder/chunkRecords.js +0 -69
- package/client/recorder/chunkRecords.test.mjs +0 -59
- package/client/recorder/collectEventEndpoints.js +0 -40
- package/client/recorder/collectEventRequests.js +0 -39
- package/client/recorder/createPairingBuffer.js +0 -187
- package/client/recorder/createPasswordRedactor.js +0 -84
- package/client/recorder/createRecordBatcher.js +0 -54
- package/client/recorder/createRecordBatcher.test.mjs +0 -76
- package/client/recorder/createRecordingSession.js +0 -61
- package/client/recorder/createRecordingSession.test.mjs +0 -72
- package/client/recorder/diffStateWrites.js +0 -77
- package/client/recorder/diffStateWrites.test.mjs +0 -66
- package/client/recorder/isEventCall.js +0 -30
- package/client/recorder/jsonType.js +0 -39
- package/client/recorder/sendRecords.js +0 -40
- package/lib/docs/captureAnnotatedScreenshot.js +0 -99
- package/lib/docs/checkpointPaths.js +0 -91
- package/lib/docs/checkpointStore.js +0 -243
- package/lib/docs/checkpointToMocks.js +0 -65
- package/lib/docs/configCheckpoints.test.mjs +0 -156
- package/lib/docs/createConfigCheckpoint.js +0 -92
- package/lib/docs/dataSets/findCollectionCollisions.js +0 -52
- package/lib/docs/devMockRegistry.js +0 -68
- package/lib/docs/enrichFeedback.js +0 -71
- package/lib/docs/evalOperator.js +0 -49
- package/lib/docs/evalOperator.test.mjs +0 -157
- package/lib/docs/evalOperatorHeadless.js +0 -159
- package/lib/docs/evalOperatorHeadless.test.mjs +0 -78
- package/lib/docs/evalOperatorInTab.js +0 -49
- package/lib/docs/formatFeedback.js +0 -142
- package/lib/docs/formatFeedback.test.mjs +0 -252
- package/lib/docs/getPluginDoc.js +0 -53
- package/lib/docs/listConfigCheckpoints.js +0 -55
- package/lib/docs/loadState.js +0 -220
- package/lib/docs/revertConfigCheckpoint.js +0 -73
- package/lib/docs/saveAnnotatedScreenshot.js +0 -43
- package/lib/docs/scaffoldPage.js +0 -77
- package/lib/docs/scaffoldPage.test.mjs +0 -97
- package/lib/docs/snapshotState.js +0 -67
- package/lib/docs/stateCheckpoints.test.mjs +0 -443
- package/manager/watchers/listServerSidePackages.mjs +0 -47
- package/manager/watchers/listServerSidePackages.test.mjs +0 -38
- package/src/routes/docs/checkpointsCreate.js +0 -28
- package/src/routes/docs/evalOperator.js +0 -70
- package/src/routes/docs/inspectState.js +0 -59
- package/src/routes/docs/loadState.js +0 -51
- package/src/routes/docs/pluginDoc.js +0 -33
- package/src/routes/docs/plugins.js +0 -23
- package/src/routes/docs/runEndpoint.js +0 -54
- package/src/routes/docs/runEndpoint.test.mjs +0 -165
- package/src/routes/docs/runRequest.js +0 -53
- package/src/routes/docs/runRequest.test.mjs +0 -92
- package/src/routes/docs/schema.js +0 -37
- package/src/routes/docs/screenshot.js +0 -120
- package/src/routes/docs/screenshot.test.mjs +0 -117
- package/src/routes/docs/search.js +0 -40
- package/src/routes/docs/snapshotState.js +0 -50
- package/src/routes/docs/stateCheckpointsList.js +0 -26
- package/src/routes/docs/types.js +0 -33
- package/src/routes/feedback.js +0 -107
- package/src/routes/feedback.test.mjs +0 -204
|
@@ -14,63 +14,79 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { vi, afterEach, beforeEach, expect, test } from 'vitest';
|
|
18
18
|
|
|
19
19
|
import createIdleGc from './createIdleGc.mjs';
|
|
20
20
|
|
|
21
21
|
beforeEach(() => {
|
|
22
22
|
// performance is not redefinable on this Node, and nothing here reads it.
|
|
23
|
-
|
|
23
|
+
vi.useFakeTimers({
|
|
24
|
+
toFake: [
|
|
25
|
+
'Date',
|
|
26
|
+
'hrtime',
|
|
27
|
+
'queueMicrotask',
|
|
28
|
+
'requestAnimationFrame',
|
|
29
|
+
'cancelAnimationFrame',
|
|
30
|
+
'requestIdleCallback',
|
|
31
|
+
'cancelIdleCallback',
|
|
32
|
+
'setImmediate',
|
|
33
|
+
'clearImmediate',
|
|
34
|
+
'setInterval',
|
|
35
|
+
'clearInterval',
|
|
36
|
+
'setTimeout',
|
|
37
|
+
'clearTimeout',
|
|
38
|
+
],
|
|
39
|
+
});
|
|
24
40
|
});
|
|
25
41
|
|
|
26
42
|
afterEach(() => {
|
|
27
|
-
|
|
43
|
+
vi.useRealTimers();
|
|
28
44
|
});
|
|
29
45
|
|
|
30
46
|
test('createIdleGc collects once 5 s after the last build ends', () => {
|
|
31
|
-
const gc =
|
|
47
|
+
const gc = vi.fn();
|
|
32
48
|
const idleGc = createIdleGc({ gc });
|
|
33
49
|
|
|
34
50
|
idleGc.onBuildingChange(true);
|
|
35
51
|
idleGc.onBuildingChange(false);
|
|
36
|
-
|
|
52
|
+
vi.advanceTimersByTime(4999);
|
|
37
53
|
expect(gc).not.toHaveBeenCalled();
|
|
38
|
-
|
|
54
|
+
vi.advanceTimersByTime(1);
|
|
39
55
|
|
|
40
56
|
expect(gc).toHaveBeenCalledTimes(1);
|
|
41
|
-
|
|
57
|
+
vi.advanceTimersByTime(60_000);
|
|
42
58
|
expect(gc).toHaveBeenCalledTimes(1);
|
|
43
59
|
});
|
|
44
60
|
|
|
45
61
|
test('createIdleGc cancels the collection when a build starts within 5 s', () => {
|
|
46
|
-
const gc =
|
|
62
|
+
const gc = vi.fn();
|
|
47
63
|
const idleGc = createIdleGc({ gc });
|
|
48
64
|
|
|
49
65
|
idleGc.onBuildingChange(false);
|
|
50
|
-
|
|
66
|
+
vi.advanceTimersByTime(3000);
|
|
51
67
|
idleGc.onBuildingChange(true);
|
|
52
|
-
|
|
68
|
+
vi.advanceTimersByTime(60_000);
|
|
53
69
|
|
|
54
70
|
expect(gc).not.toHaveBeenCalled();
|
|
55
71
|
});
|
|
56
72
|
|
|
57
73
|
test('createIdleGc collects once after several back-to-back builds', () => {
|
|
58
|
-
const gc =
|
|
74
|
+
const gc = vi.fn();
|
|
59
75
|
const idleGc = createIdleGc({ gc });
|
|
60
76
|
|
|
61
77
|
for (let i = 0; i < 4; i += 1) {
|
|
62
78
|
idleGc.onBuildingChange(true);
|
|
63
|
-
|
|
79
|
+
vi.advanceTimersByTime(1000);
|
|
64
80
|
idleGc.onBuildingChange(false);
|
|
65
|
-
|
|
81
|
+
vi.advanceTimersByTime(1000);
|
|
66
82
|
}
|
|
67
|
-
|
|
83
|
+
vi.advanceTimersByTime(5000);
|
|
68
84
|
|
|
69
85
|
expect(gc).toHaveBeenCalledTimes(1);
|
|
70
86
|
});
|
|
71
87
|
|
|
72
88
|
test('createIdleGc exposes a working gc in a process started without --expose-gc', () => {
|
|
73
|
-
|
|
89
|
+
vi.useRealTimers();
|
|
74
90
|
const idleGc = createIdleGc({ delayMs: 0 });
|
|
75
91
|
|
|
76
92
|
expect(() => idleGc.onBuildingChange(true)).not.toThrow();
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import crypto from 'node:crypto';
|
|
18
|
+
|
|
19
|
+
import getLanAddress from './getLanAddress.mjs';
|
|
20
|
+
|
|
21
|
+
// `lowdefy dev --lan [interface]` sets LOWDEFY_SERVER_DEV_LAN to "true" or to
|
|
22
|
+
// the interface name. The token lasts as long as this dev server.
|
|
23
|
+
function createLanPairing({ lan, interfaces }) {
|
|
24
|
+
if (lan === undefined) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const { name, address } = getLanAddress({
|
|
28
|
+
interfaceName: lan === 'true' ? undefined : lan,
|
|
29
|
+
interfaces,
|
|
30
|
+
});
|
|
31
|
+
return { name, address, token: crypto.randomBytes(32).toString('base64url') };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default createLanPairing;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { expect, test } from 'vitest';
|
|
18
|
+
import createLanPairing from './createLanPairing.mjs';
|
|
19
|
+
|
|
20
|
+
const interfaces = {
|
|
21
|
+
en0: [{ address: '192.168.1.20', family: 'IPv4', internal: false }],
|
|
22
|
+
en5: [{ address: '10.1.1.4', family: 'IPv4', internal: false }],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
test('createLanPairing returns null when --lan is off', () => {
|
|
26
|
+
expect(createLanPairing({ lan: undefined, interfaces })).toBe(null);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('createLanPairing picks the private address and a 32-byte token', () => {
|
|
30
|
+
const pairing = createLanPairing({ lan: 'true', interfaces });
|
|
31
|
+
expect(pairing).toMatchObject({ name: 'en0', address: '192.168.1.20' });
|
|
32
|
+
expect(Buffer.from(pairing.token, 'base64url')).toHaveLength(32);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('createLanPairing takes the interface --lan names', () => {
|
|
36
|
+
expect(createLanPairing({ lan: 'en5', interfaces })).toMatchObject({
|
|
37
|
+
name: 'en5',
|
|
38
|
+
address: '10.1.1.4',
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('createLanPairing makes a new token each session', () => {
|
|
43
|
+
expect(createLanPairing({ lan: 'true', interfaces }).token).not.toEqual(
|
|
44
|
+
createLanPairing({ lan: 'true', interfaces }).token
|
|
45
|
+
);
|
|
46
|
+
});
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
/*
|
|
18
18
|
Whether anyone is using this dev server, for readers in other processes: the
|
|
19
19
|
hub stops a server nobody has used for a while, judged from the fields this
|
|
20
|
-
writes into the instance record (lastActivityAt, activeRequests).
|
|
20
|
+
writes into the instance record (lastActivityAt, activeRequests, openTabs).
|
|
21
|
+
The manager
|
|
21
22
|
counts here because it owns the public port and outlives every child restart,
|
|
22
23
|
so it sees every caller (agents, lowdefy test, curl, the browser) and keeps
|
|
23
24
|
its count across restarts.
|
|
@@ -28,9 +29,16 @@ record is then never more than throttleMs behind, far inside the shortest
|
|
|
28
29
|
idle limit. A request starting while the record last said 0 in flight is
|
|
29
30
|
written at once, so a reader never sees a busy server as idle-with-nothing-
|
|
30
31
|
in-flight longer than it takes to write.
|
|
32
|
+
|
|
33
|
+
openTabs counts the browser tabs (headless journey tabs included) holding a
|
|
34
|
+
reload stream open. Streams are not activity, but an open tab is use: it
|
|
35
|
+
keeps the Vite child up (createIdleChild) and the hub reads it here instead
|
|
36
|
+
of asking the child. A tab opening or closing is rare, so it is written at
|
|
37
|
+
once; a tab closing counts as use, so the idle count starts then.
|
|
31
38
|
*/
|
|
32
39
|
function createRequestActivity({ onChange, throttleMs = 5000, now = Date.now }) {
|
|
33
40
|
let activeRequests = 0;
|
|
41
|
+
let openTabs = 0;
|
|
34
42
|
let lastActivityAt = now();
|
|
35
43
|
let lastWriteAt = -Infinity;
|
|
36
44
|
let writtenActiveRequests = 0;
|
|
@@ -43,7 +51,11 @@ function createRequestActivity({ onChange, throttleMs = 5000, now = Date.now })
|
|
|
43
51
|
}
|
|
44
52
|
lastWriteAt = now();
|
|
45
53
|
writtenActiveRequests = activeRequests;
|
|
46
|
-
onChange({
|
|
54
|
+
onChange({
|
|
55
|
+
lastActivityAt: new Date(lastActivityAt).toISOString(),
|
|
56
|
+
activeRequests,
|
|
57
|
+
openTabs,
|
|
58
|
+
});
|
|
47
59
|
}
|
|
48
60
|
|
|
49
61
|
function schedule() {
|
|
@@ -92,9 +104,24 @@ function createRequestActivity({ onChange, throttleMs = 5000, now = Date.now })
|
|
|
92
104
|
res.once('close', onEnd);
|
|
93
105
|
}
|
|
94
106
|
|
|
107
|
+
// Counts one open tab from its reload stream's response start until it closes.
|
|
108
|
+
function trackTab(res) {
|
|
109
|
+
openTabs += 1;
|
|
110
|
+
write();
|
|
111
|
+
res.once('close', () => {
|
|
112
|
+
openTabs -= 1;
|
|
113
|
+
lastActivityAt = now();
|
|
114
|
+
write();
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function snapshot() {
|
|
119
|
+
return { activeRequests, lastActivityAt, openTabs };
|
|
120
|
+
}
|
|
121
|
+
|
|
95
122
|
write();
|
|
96
123
|
|
|
97
|
-
return { begin, end, touch, trackResponse };
|
|
124
|
+
return { begin, end, snapshot, touch, trackResponse, trackTab };
|
|
98
125
|
}
|
|
99
126
|
|
|
100
127
|
export default createRequestActivity;
|
|
@@ -16,106 +16,160 @@
|
|
|
16
16
|
|
|
17
17
|
import { EventEmitter } from 'node:events';
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import { vi, afterEach, beforeEach, expect, test } from 'vitest';
|
|
20
20
|
|
|
21
21
|
import createRequestActivity from './createRequestActivity.mjs';
|
|
22
22
|
|
|
23
23
|
beforeEach(() => {
|
|
24
|
-
|
|
24
|
+
vi.useFakeTimers({
|
|
25
|
+
now: new Date('2026-10-02T10:00:00.000Z'),
|
|
26
|
+
toFake: [
|
|
27
|
+
'Date',
|
|
28
|
+
'hrtime',
|
|
29
|
+
'queueMicrotask',
|
|
30
|
+
'requestAnimationFrame',
|
|
31
|
+
'cancelAnimationFrame',
|
|
32
|
+
'requestIdleCallback',
|
|
33
|
+
'cancelIdleCallback',
|
|
34
|
+
'setImmediate',
|
|
35
|
+
'clearImmediate',
|
|
36
|
+
'setInterval',
|
|
37
|
+
'clearInterval',
|
|
38
|
+
'setTimeout',
|
|
39
|
+
'clearTimeout',
|
|
40
|
+
],
|
|
41
|
+
});
|
|
25
42
|
});
|
|
26
43
|
|
|
27
44
|
afterEach(() => {
|
|
28
|
-
|
|
45
|
+
vi.useRealTimers();
|
|
29
46
|
});
|
|
30
47
|
|
|
31
48
|
test('createRequestActivity writes the starting activity at once', () => {
|
|
32
|
-
const onChange =
|
|
49
|
+
const onChange = vi.fn();
|
|
33
50
|
createRequestActivity({ onChange });
|
|
34
51
|
expect(onChange.mock.calls).toEqual([
|
|
35
|
-
[{ lastActivityAt: '2026-10-02T10:00:00.000Z', activeRequests: 0 }],
|
|
52
|
+
[{ lastActivityAt: '2026-10-02T10:00:00.000Z', activeRequests: 0, openTabs: 0 }],
|
|
36
53
|
]);
|
|
37
54
|
});
|
|
38
55
|
|
|
39
56
|
test('createRequestActivity counts requests in and out of flight', () => {
|
|
40
|
-
const onChange =
|
|
57
|
+
const onChange = vi.fn();
|
|
41
58
|
const activity = createRequestActivity({ onChange });
|
|
42
|
-
|
|
59
|
+
vi.advanceTimersByTime(10000);
|
|
43
60
|
activity.begin();
|
|
44
61
|
activity.begin();
|
|
45
62
|
activity.end();
|
|
46
|
-
|
|
63
|
+
vi.advanceTimersByTime(5000);
|
|
47
64
|
expect(onChange.mock.calls.at(-1)[0].activeRequests).toBe(1);
|
|
48
65
|
activity.end();
|
|
49
|
-
|
|
66
|
+
vi.advanceTimersByTime(5000);
|
|
50
67
|
expect(onChange.mock.calls.at(-1)[0]).toEqual({
|
|
51
68
|
lastActivityAt: '2026-10-02T10:00:15.000Z',
|
|
52
69
|
activeRequests: 0,
|
|
70
|
+
openTabs: 0,
|
|
53
71
|
});
|
|
54
72
|
});
|
|
55
73
|
|
|
56
74
|
test('createRequestActivity writes a request starting on an idle record at once', () => {
|
|
57
|
-
const onChange =
|
|
75
|
+
const onChange = vi.fn();
|
|
58
76
|
const activity = createRequestActivity({ onChange });
|
|
59
|
-
|
|
77
|
+
vi.advanceTimersByTime(1000);
|
|
60
78
|
activity.begin();
|
|
61
79
|
expect(onChange).toHaveBeenCalledTimes(2);
|
|
62
80
|
expect(onChange.mock.calls[1][0]).toEqual({
|
|
63
81
|
lastActivityAt: '2026-10-02T10:00:01.000Z',
|
|
64
82
|
activeRequests: 1,
|
|
83
|
+
openTabs: 0,
|
|
65
84
|
});
|
|
66
85
|
});
|
|
67
86
|
|
|
68
87
|
test('createRequestActivity writes the end of the last request at once when the record is older than the throttle', () => {
|
|
69
|
-
const onChange =
|
|
88
|
+
const onChange = vi.fn();
|
|
70
89
|
const activity = createRequestActivity({ onChange });
|
|
71
90
|
activity.begin();
|
|
72
|
-
|
|
91
|
+
vi.advanceTimersByTime(60000);
|
|
73
92
|
activity.end();
|
|
74
93
|
expect(onChange.mock.calls.at(-1)[0]).toEqual({
|
|
75
94
|
lastActivityAt: '2026-10-02T10:01:00.000Z',
|
|
76
95
|
activeRequests: 0,
|
|
96
|
+
openTabs: 0,
|
|
77
97
|
});
|
|
78
98
|
});
|
|
79
99
|
|
|
80
100
|
test('createRequestActivity bounds the writes for a burst of short requests and lands the final value', () => {
|
|
81
|
-
const onChange =
|
|
101
|
+
const onChange = vi.fn();
|
|
82
102
|
const activity = createRequestActivity({ onChange });
|
|
83
103
|
onChange.mockClear();
|
|
84
104
|
for (let i = 0; i < 100; i += 1) {
|
|
85
105
|
activity.begin();
|
|
86
|
-
|
|
106
|
+
vi.advanceTimersByTime(20);
|
|
87
107
|
activity.end();
|
|
88
|
-
|
|
108
|
+
vi.advanceTimersByTime(20);
|
|
89
109
|
}
|
|
90
|
-
|
|
110
|
+
vi.advanceTimersByTime(5000);
|
|
91
111
|
expect(onChange.mock.calls.length).toBeLessThanOrEqual(3);
|
|
92
112
|
expect(onChange.mock.calls.at(-1)[0]).toEqual({
|
|
93
113
|
lastActivityAt: new Date(Date.parse('2026-10-02T10:00:00.000Z') + 3980).toISOString(),
|
|
94
114
|
activeRequests: 0,
|
|
115
|
+
openTabs: 0,
|
|
95
116
|
});
|
|
96
117
|
});
|
|
97
118
|
|
|
98
119
|
test('createRequestActivity touch refreshes lastActivityAt through the throttle', () => {
|
|
99
|
-
const onChange =
|
|
120
|
+
const onChange = vi.fn();
|
|
100
121
|
const activity = createRequestActivity({ onChange });
|
|
101
|
-
|
|
122
|
+
vi.advanceTimersByTime(2000);
|
|
102
123
|
activity.touch();
|
|
103
124
|
expect(onChange).toHaveBeenCalledTimes(1);
|
|
104
|
-
|
|
125
|
+
vi.advanceTimersByTime(3000);
|
|
105
126
|
expect(onChange).toHaveBeenCalledTimes(2);
|
|
106
127
|
expect(onChange.mock.calls[1][0].lastActivityAt).toBe('2026-10-02T10:00:02.000Z');
|
|
107
128
|
});
|
|
108
129
|
|
|
109
130
|
test('createRequestActivity trackResponse ends a request once, on finish or close', () => {
|
|
110
|
-
const onChange =
|
|
131
|
+
const onChange = vi.fn();
|
|
111
132
|
const activity = createRequestActivity({ onChange });
|
|
112
133
|
const res = new EventEmitter();
|
|
113
134
|
activity.trackResponse(res);
|
|
114
135
|
expect(onChange.mock.calls.at(-1)[0].activeRequests).toBe(1);
|
|
115
136
|
res.emit('finish');
|
|
116
137
|
res.emit('close');
|
|
117
|
-
|
|
138
|
+
vi.advanceTimersByTime(5000);
|
|
118
139
|
expect(onChange.mock.calls.at(-1)[0].activeRequests).toBe(0);
|
|
119
140
|
activity.begin();
|
|
120
141
|
expect(onChange.mock.calls.at(-1)[0].activeRequests).toBe(1);
|
|
121
142
|
});
|
|
143
|
+
|
|
144
|
+
test('createRequestActivity counts open tabs and writes each change at once', () => {
|
|
145
|
+
const onChange = vi.fn();
|
|
146
|
+
const activity = createRequestActivity({ onChange });
|
|
147
|
+
const first = new EventEmitter();
|
|
148
|
+
const second = new EventEmitter();
|
|
149
|
+
activity.trackTab(first);
|
|
150
|
+
activity.trackTab(second);
|
|
151
|
+
expect(onChange.mock.calls.at(-1)[0].openTabs).toBe(2);
|
|
152
|
+
expect(activity.snapshot().openTabs).toBe(2);
|
|
153
|
+
first.emit('close');
|
|
154
|
+
expect(onChange.mock.calls.at(-1)[0].openTabs).toBe(1);
|
|
155
|
+
expect(activity.snapshot().activeRequests).toBe(0);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test('createRequestActivity counts a tab closing as use', () => {
|
|
159
|
+
const onChange = vi.fn();
|
|
160
|
+
const activity = createRequestActivity({ onChange });
|
|
161
|
+
const tab = new EventEmitter();
|
|
162
|
+
activity.trackTab(tab);
|
|
163
|
+
vi.advanceTimersByTime(600000);
|
|
164
|
+
tab.emit('close');
|
|
165
|
+
expect(activity.snapshot()).toEqual({
|
|
166
|
+
activeRequests: 0,
|
|
167
|
+
lastActivityAt: Date.parse('2026-10-02T10:10:00.000Z'),
|
|
168
|
+
openTabs: 0,
|
|
169
|
+
});
|
|
170
|
+
expect(onChange.mock.calls.at(-1)[0]).toEqual({
|
|
171
|
+
lastActivityAt: '2026-10-02T10:10:00.000Z',
|
|
172
|
+
activeRequests: 0,
|
|
173
|
+
openTabs: 0,
|
|
174
|
+
});
|
|
175
|
+
});
|
|
@@ -16,15 +16,18 @@
|
|
|
16
16
|
|
|
17
17
|
import { type } from '@lowdefy/helpers';
|
|
18
18
|
|
|
19
|
-
// The
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
// The stock sign-in email (EmailOTPEmail in @lowdefy/email-templates) puts the
|
|
20
|
+
// one-time code on a line of its own, and so does any template that shows a
|
|
21
|
+
// code to copy. A number inside a sentence (an order or invoice number) is not
|
|
22
|
+
// taken for one.
|
|
23
|
+
const CODE_LINE = /^[ \t]*(\d{4,10})[ \t]*$/m;
|
|
24
|
+
|
|
25
|
+
function findSignInCode({ text }) {
|
|
26
|
+
if (!type.isString(text)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const match = text.match(CODE_LINE);
|
|
30
|
+
return match === null ? null : match[1];
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
export default
|
|
33
|
+
export default findSignInCode;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { expect, test } from 'vitest';
|
|
18
|
+
import findSignInCode from './findSignInCode.mjs';
|
|
19
|
+
|
|
20
|
+
test('findSignInCode reads the code from the stock sign-in email text', () => {
|
|
21
|
+
const text =
|
|
22
|
+
'YOUR SIGN-IN CODE\n\nEnter this code on the sign-in page to continue.\n\n482913\n\nThis code expires in 5 minutes and can only be used once.';
|
|
23
|
+
expect(findSignInCode({ text })).toEqual('482913');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('findSignInCode ignores a number inside a sentence', () => {
|
|
27
|
+
expect(findSignInCode({ text: 'Your order 123456 has shipped.' })).toBe(null);
|
|
28
|
+
expect(findSignInCode({ text: 'Total\n12\n' })).toBe(null);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('findSignInCode returns null for a message with no text', () => {
|
|
32
|
+
expect(findSignInCode({ text: null })).toBe(null);
|
|
33
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import renderTerminalQr from './renderTerminalQr.mjs';
|
|
18
|
+
|
|
19
|
+
// The link Lowdefy Dev opens: it asks "Connect to <host>?" before it attaches.
|
|
20
|
+
function formatLanPairing({ lan, port, basePath }) {
|
|
21
|
+
const url = `http://${lan.address}:${port}${basePath}`;
|
|
22
|
+
const link = `lowdefy-dev://connect?url=${encodeURIComponent(url)}&pair=${lan.token}`;
|
|
23
|
+
return [
|
|
24
|
+
`Phone pairing on ${lan.name} (${url}). Wrong network? Restart with --lan <interface>.`,
|
|
25
|
+
'Scan this with Lowdefy Dev. Requests from other machines need the pairing token,',
|
|
26
|
+
'and the dev tools answer only on this computer.',
|
|
27
|
+
renderTerminalQr(link),
|
|
28
|
+
link,
|
|
29
|
+
].join('\n');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default formatLanPairing;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { expect, test } from 'vitest';
|
|
18
|
+
import formatLanPairing from './formatLanPairing.mjs';
|
|
19
|
+
|
|
20
|
+
const lan = { name: 'en0', address: '192.168.1.20', token: 'tok_en-123' };
|
|
21
|
+
|
|
22
|
+
test('formatLanPairing names the interface and prints the Lowdefy Dev link with the token', () => {
|
|
23
|
+
const lines = formatLanPairing({ lan, port: 3000, basePath: '/app' }).split('\n');
|
|
24
|
+
expect(lines[0]).toEqual(
|
|
25
|
+
'Phone pairing on en0 (http://192.168.1.20:3000/app). Wrong network? Restart with --lan <interface>.'
|
|
26
|
+
);
|
|
27
|
+
expect(lines[lines.length - 1]).toEqual(
|
|
28
|
+
'lowdefy-dev://connect?url=http%3A%2F%2F192.168.1.20%3A3000%2Fapp&pair=tok_en-123'
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('formatLanPairing draws a square QR code in black on white', () => {
|
|
33
|
+
const lines = formatLanPairing({ lan, port: 3000, basePath: '' }).split('\n');
|
|
34
|
+
const qrLines = lines.filter((line) => line.startsWith('\x1b[30;47m'));
|
|
35
|
+
expect(qrLines.length).toBeGreaterThan(10);
|
|
36
|
+
// Two module rows per text line, so the code is about twice as wide as tall.
|
|
37
|
+
const width = qrLines[0].replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
38
|
+
expect(qrLines.every((line) => line.endsWith('\x1b[0m'))).toBe(true);
|
|
39
|
+
expect(Math.abs(width - 2 * qrLines.length)).toBeLessThanOrEqual(1);
|
|
40
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import os from 'node:os';
|
|
18
|
+
|
|
19
|
+
// Ported from the earlier mobile work's `lowdefy mobile dev`, which took the
|
|
20
|
+
// first non-internal IPv4 address. That can be a VPN or Docker address, so
|
|
21
|
+
// this one prefers a private (RFC 1918) address, names the interface it chose,
|
|
22
|
+
// and takes an interface by name.
|
|
23
|
+
|
|
24
|
+
function isIpv4(address) {
|
|
25
|
+
// Node 18.0 to 18.3 report the family as a number.
|
|
26
|
+
return address.family === 'IPv4' || address.family === 4;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function isPrivateIpv4(address) {
|
|
30
|
+
const [first, second] = address.split('.').map(Number);
|
|
31
|
+
if (first === 10) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if (first === 172 && second >= 16 && second <= 31) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return first === 192 && second === 168;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function listExternalIpv4({ interfaces }) {
|
|
41
|
+
const found = [];
|
|
42
|
+
Object.entries(interfaces).forEach(([name, addresses]) => {
|
|
43
|
+
(addresses ?? []).forEach((address) => {
|
|
44
|
+
if (isIpv4(address) && !address.internal) {
|
|
45
|
+
found.push({ name, address: address.address });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
return found;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function describe(found) {
|
|
53
|
+
if (found.length === 0) {
|
|
54
|
+
return 'This computer has no network interface with an IPv4 address.';
|
|
55
|
+
}
|
|
56
|
+
return `Interfaces with an IPv4 address: ${found
|
|
57
|
+
.map(({ name, address }) => `${name} (${address})`)
|
|
58
|
+
.join(', ')}.`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getLanAddress({ interfaceName, interfaces = os.networkInterfaces() }) {
|
|
62
|
+
const found = listExternalIpv4({ interfaces });
|
|
63
|
+
if (interfaceName !== undefined) {
|
|
64
|
+
const named = found.find(({ name }) => name === interfaceName);
|
|
65
|
+
if (named === undefined) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`Network interface "${interfaceName}" has no IPv4 address. ${describe(found)}`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return named;
|
|
71
|
+
}
|
|
72
|
+
const lan = found.find(({ address }) => isPrivateIpv4(address));
|
|
73
|
+
if (lan === undefined) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`No private network address found for --lan. ${describe(
|
|
76
|
+
found
|
|
77
|
+
)} Pass one with --lan <interface>.`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return lan;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default getLanAddress;
|