@lowdefy/server-dev 7.1.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/dataSetJourneys.chromium.mongodb.test.mjs +6 -6
- 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/mergeCollectionIndexes.test.mjs +1 -0
- package/lib/docs/dataSets/openDataSession.js +4 -2
- package/lib/docs/dataSets/openDataSession.mongodb.test.mjs +25 -7
- package/lib/docs/dataSets/pickDataStorePort.test.mjs +2 -2
- package/lib/docs/dataSets/readDataSession.test.mjs +1 -0
- package/lib/docs/dataSets/readDataSet.test.mjs +1 -0
- package/lib/docs/dataSets/resolveJourneyDataSet.test.mjs +1 -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 +3 -3
- package/lib/docs/getBrowser.test.mjs +32 -16
- package/lib/docs/getBuildId.test.mjs +1 -0
- package/lib/docs/getBuildStatus.test.mjs +11 -11
- 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 +20 -42
- 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.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 +25 -25
- 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/server/applyDataSetRedirect.test.mjs +2 -2
- package/lib/server/applyDataSetRedirectTenantReach.test.mjs +1 -0
- package/lib/server/applyDataSetRedirectWalled.test.mjs +1 -0
- 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 +5 -1
- package/lib/server/createLowdefyContext.test.mjs +32 -32
- 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 +1 -0
- 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 +9 -0
- 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 +2 -15
- package/manager/processes/initialBuild.test.mjs +8 -40
- package/manager/processes/lowdefyBuild.mjs +7 -4
- package/manager/processes/lowdefyBuild.skipPluginChecks.test.mjs +13 -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/{src/routes/docs/content.js → manager/utils/createLanPairing.mjs} +14 -13
- 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/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
package/client/Inspector.jsx
CHANGED
|
@@ -117,57 +117,6 @@ function buildSnapshot({ lowdefy, page }) {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
// Dev-only agent-state-xray: puts a human tester's real browser tab into a
|
|
121
|
-
// checkpoint's recorded state when it loads a page with `?_checkpoint=<name>`
|
|
122
|
-
// in the URL. Fetches the checkpoint's state part from
|
|
123
|
-
// GET <basePath>/api/dev-inspect/checkpoint/<name> (src/routes/devInspect.js
|
|
124
|
-
// — that fetch also loads the checkpoint's recorded requests into
|
|
125
|
-
// devMockRegistry server-side, so this tab's own requests replay recorded
|
|
126
|
-
// data), then injects state the same way e2e-utils' setState does:
|
|
127
|
-
// context._internal.State.set(...) + context._internal.update(). Polls
|
|
128
|
-
// briefly for the page context to exist since this can run before the page
|
|
129
|
-
// has finished mounting. Never lets a bad checkpoint or a missing context
|
|
130
|
-
// break the app — every step is try/catch, and failures just leave the app
|
|
131
|
-
// running unmodified.
|
|
132
|
-
async function bootstrapFromCheckpoint({ basePath, instanceKey, checkpointName, isCancelled }) {
|
|
133
|
-
try {
|
|
134
|
-
const response = await fetch(
|
|
135
|
-
`${basePath}/api/dev-inspect/checkpoint/${encodeURIComponent(checkpointName)}`
|
|
136
|
-
);
|
|
137
|
-
const body = await response.json();
|
|
138
|
-
if (!response.ok || body?.error) {
|
|
139
|
-
// eslint-disable-next-line no-console
|
|
140
|
-
console.error(
|
|
141
|
-
`Failed to load checkpoint "${checkpointName}": ${body?.error ?? response.statusText}`
|
|
142
|
-
);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const payload = serializer.deserialize(body);
|
|
146
|
-
|
|
147
|
-
const deadline = Date.now() + 5000;
|
|
148
|
-
let context;
|
|
149
|
-
while (!isCancelled() && Date.now() < deadline) {
|
|
150
|
-
context = window.lowdefy?.contexts?.[instanceKey];
|
|
151
|
-
if (context) {
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
// eslint-disable-next-line no-await-in-loop
|
|
155
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
156
|
-
}
|
|
157
|
-
if (isCancelled() || type.isNone(context)) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
Object.entries(payload.state ?? {}).forEach(([key, value]) => {
|
|
162
|
-
context._internal.State.set(key, value);
|
|
163
|
-
});
|
|
164
|
-
context._internal.update();
|
|
165
|
-
} catch (error) {
|
|
166
|
-
// eslint-disable-next-line no-console
|
|
167
|
-
console.error('Failed to load checkpoint "%s":', checkpointName, error);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
120
|
function evalExpression({ lowdefy, page, expression }) {
|
|
172
121
|
const { context, error } = findContext({ lowdefy, page });
|
|
173
122
|
if (error) {
|
|
@@ -177,10 +126,33 @@ function evalExpression({ lowdefy, page, expression }) {
|
|
|
177
126
|
// or (since it travels as a JSON string end-to-end from an MCP tool
|
|
178
127
|
// argument) as a JSON string that needs one more parse.
|
|
179
128
|
const input = type.isString(expression) ? JSON.parse(expression) : expression;
|
|
180
|
-
|
|
129
|
+
// A read recorder set while the expression is parsed collects the keys its
|
|
130
|
+
// operators read (the engine's block dependency tracking), e.g.
|
|
131
|
+
// "state:customer.name". Mirrors evaluateInPage in inspectStateHeadless.js.
|
|
132
|
+
const reads = new Set();
|
|
133
|
+
const recordRead = (key) => {
|
|
134
|
+
if (type.isString(key)) reads.add(key);
|
|
135
|
+
};
|
|
136
|
+
const ignore = () => {};
|
|
137
|
+
const previousRecorder = context._internal.readRecorder;
|
|
138
|
+
context._internal.readRecorder = {
|
|
139
|
+
read: recordRead,
|
|
140
|
+
engineRead: recordRead,
|
|
141
|
+
pure: ignore,
|
|
142
|
+
volatile: ignore,
|
|
143
|
+
untracked: ignore,
|
|
144
|
+
};
|
|
145
|
+
let parsed;
|
|
146
|
+
try {
|
|
147
|
+
parsed = context._internal.parser.parse({ input, location: 'agent_eval' });
|
|
148
|
+
} finally {
|
|
149
|
+
context._internal.readRecorder = previousRecorder;
|
|
150
|
+
}
|
|
151
|
+
const { output, errors } = parsed;
|
|
181
152
|
return {
|
|
182
153
|
value: serializer.serializeToString(output),
|
|
183
154
|
errors: errors.map((error) => error.message),
|
|
155
|
+
reads: [...reads],
|
|
184
156
|
};
|
|
185
157
|
}
|
|
186
158
|
|
|
@@ -240,29 +212,6 @@ const Inspector = ({ basePath, lowdefy, page }) => {
|
|
|
240
212
|
postTabPage({ basePath, tabId, page });
|
|
241
213
|
}, [basePath, tabId, page]);
|
|
242
214
|
|
|
243
|
-
const instanceKey = page?.instanceKey;
|
|
244
|
-
useEffect(() => {
|
|
245
|
-
if (type.isNone(instanceKey)) {
|
|
246
|
-
return undefined;
|
|
247
|
-
}
|
|
248
|
-
const checkpointName = new URLSearchParams(window.location.search).get('_checkpoint');
|
|
249
|
-
if (type.isNone(checkpointName)) {
|
|
250
|
-
return undefined;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
let cancelled = false;
|
|
254
|
-
bootstrapFromCheckpoint({
|
|
255
|
-
basePath,
|
|
256
|
-
instanceKey,
|
|
257
|
-
checkpointName,
|
|
258
|
-
isCancelled: () => cancelled,
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
return () => {
|
|
262
|
-
cancelled = true;
|
|
263
|
-
};
|
|
264
|
-
}, [basePath, instanceKey]);
|
|
265
|
-
|
|
266
215
|
return null;
|
|
267
216
|
};
|
|
268
217
|
|
package/client/Page.jsx
CHANGED
|
@@ -23,6 +23,8 @@ import InstallingPluginsPage from '../lib/client/InstallingPluginsPage.jsx';
|
|
|
23
23
|
import RedirectingPage from '../lib/client/RedirectingPage.jsx';
|
|
24
24
|
import usePageConfig from '../lib/client/utils/usePageConfig.js';
|
|
25
25
|
|
|
26
|
+
const DEV_HISTORY_LIMITS = { events: 200, calls: 20 };
|
|
27
|
+
|
|
26
28
|
const Page = ({
|
|
27
29
|
auth,
|
|
28
30
|
Components,
|
|
@@ -107,6 +109,12 @@ const Page = ({
|
|
|
107
109
|
// before any interaction on this config.
|
|
108
110
|
lowdefy._devBuildId = pageConfig._buildId ?? null;
|
|
109
111
|
|
|
112
|
+
// Dev tabs live long, so cap the engine's event and call histories (read in initLowdefyContext).
|
|
113
|
+
// Set in place, as recordCallerStamp does: replacing lowdefy._internal on every render would
|
|
114
|
+
// leave anything holding the old object writing to a copy nobody reads.
|
|
115
|
+
lowdefy._internal = lowdefy._internal ?? {};
|
|
116
|
+
lowdefy._internal.historyLimits = DEV_HISTORY_LIMITS;
|
|
117
|
+
|
|
110
118
|
return (
|
|
111
119
|
<Client
|
|
112
120
|
auth={auth}
|
package/client/Routing.jsx
CHANGED
|
@@ -21,7 +21,6 @@ import createLinkComponent from '@lowdefy/client/adapters/Link.js';
|
|
|
21
21
|
|
|
22
22
|
import BuildingPage from '../lib/client/BuildingPage.jsx';
|
|
23
23
|
import RestartingPage from '../lib/client/RestartingPage.jsx';
|
|
24
|
-
import FeedbackMount from './feedback/FeedbackMount.jsx';
|
|
25
24
|
import Inspector from './Inspector.jsx';
|
|
26
25
|
import JourneyObserver from './JourneyObserver.jsx';
|
|
27
26
|
import OpenInEditorListener from './openInEditor/OpenInEditorListener.jsx';
|
|
@@ -87,7 +86,6 @@ function Routing({ auth, lowdefy, recording, router }) {
|
|
|
87
86
|
}
|
|
88
87
|
return (
|
|
89
88
|
<>
|
|
90
|
-
<FeedbackMount basePath={router.basePath} lowdefy={lowdefy} page={shownPage} />
|
|
91
89
|
<OpenInEditorListener basePath={router.basePath} pageId={shownPage?.pageId} />
|
|
92
90
|
<Reload basePath={router.basePath} lowdefy={lowdefy}>
|
|
93
91
|
{(resetContext) => (
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import fs from 'node:fs';
|
|
18
18
|
import path from 'node:path';
|
|
19
19
|
import { fileURLToPath } from 'node:url';
|
|
20
|
+
import { expect, test } from 'vitest';
|
|
20
21
|
|
|
21
22
|
// Everything the client imports from build/ ships in the browser bundle. build/config.json is
|
|
22
23
|
// server-only: it carries every deployment environment's settings (other environments' urls,
|
|
@@ -53,9 +54,10 @@ function listSourceFiles(dir) {
|
|
|
53
54
|
test('client code imports only client-safe build artifacts', () => {
|
|
54
55
|
const imported = ['client', 'lib/client'].flatMap((dir) =>
|
|
55
56
|
listSourceFiles(path.join(root, dir)).flatMap((file) =>
|
|
56
|
-
[...fs.readFileSync(file, 'utf8').matchAll(/from '[^']*\/build\/([^']+)'/g)].map(
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
[...fs.readFileSync(file, 'utf8').matchAll(/from '[^']*\/build\/([^']+)'/g)].map((match) => ({
|
|
58
|
+
file: path.relative(root, file),
|
|
59
|
+
artifact: match[1],
|
|
60
|
+
}))
|
|
59
61
|
)
|
|
60
62
|
);
|
|
61
63
|
expect(imported.length).toBeGreaterThan(0);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { vi, expect, test } from 'vitest';
|
|
18
18
|
|
|
19
19
|
import startJourneyObserver from './startJourneyObserver.js';
|
|
20
20
|
|
|
@@ -24,19 +24,19 @@ function createFakeWindow({ binding } = {}) {
|
|
|
24
24
|
class FakeMutationObserver {
|
|
25
25
|
constructor(callback) {
|
|
26
26
|
this.callback = callback;
|
|
27
|
-
this.disconnect =
|
|
28
|
-
this.observe =
|
|
27
|
+
this.disconnect = vi.fn();
|
|
28
|
+
this.observe = vi.fn();
|
|
29
29
|
observers.push(this);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
const window = {
|
|
33
33
|
document: { body: {} },
|
|
34
34
|
MutationObserver: FakeMutationObserver,
|
|
35
|
-
requestAnimationFrame:
|
|
35
|
+
requestAnimationFrame: vi.fn((callback) => {
|
|
36
36
|
frames.push(callback);
|
|
37
37
|
return frames.length;
|
|
38
38
|
}),
|
|
39
|
-
cancelAnimationFrame:
|
|
39
|
+
cancelAnimationFrame: vi.fn(),
|
|
40
40
|
};
|
|
41
41
|
if (binding !== undefined) {
|
|
42
42
|
window.__lowdefyJourneyObserve = binding;
|
|
@@ -51,9 +51,9 @@ function createFakeWindow({ binding } = {}) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function createFakeTrace() {
|
|
54
|
-
const unsubscribe =
|
|
55
|
-
const trace = { subscribe:
|
|
56
|
-
return { getTrace:
|
|
54
|
+
const unsubscribe = vi.fn();
|
|
55
|
+
const trace = { subscribe: vi.fn(() => unsubscribe) };
|
|
56
|
+
return { getTrace: vi.fn(() => trace), trace, unsubscribe };
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
test('startJourneyObserver does nothing in a developer tab, where there is no binding', () => {
|
|
@@ -63,7 +63,7 @@ test('startJourneyObserver does nothing in a developer tab, where there is no bi
|
|
|
63
63
|
window,
|
|
64
64
|
lowdefy: { pageId: 'home' },
|
|
65
65
|
getTrace,
|
|
66
|
-
collectVisibleBlockIds:
|
|
66
|
+
collectVisibleBlockIds: vi.fn(() => ['a']),
|
|
67
67
|
});
|
|
68
68
|
expect(stop).toBeNull();
|
|
69
69
|
expect(trace.subscribe).not.toHaveBeenCalled();
|
|
@@ -71,7 +71,7 @@ test('startJourneyObserver does nothing in a developer tab, where there is no bi
|
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
test('startJourneyObserver forwards completed events and each newly visible block once', () => {
|
|
74
|
-
const binding =
|
|
74
|
+
const binding = vi.fn(async () => {});
|
|
75
75
|
const { window, observers, mutate, runFrames } = createFakeWindow({ binding });
|
|
76
76
|
const { getTrace, trace, unsubscribe } = createFakeTrace();
|
|
77
77
|
const lowdefy = { pageId: 'home' };
|
|
@@ -132,7 +132,7 @@ test('startJourneyObserver forwards completed events and each newly visible bloc
|
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
test('startJourneyObserver keeps the app running when the binding or a payload throws', () => {
|
|
135
|
-
const binding =
|
|
135
|
+
const binding = vi.fn(() => {
|
|
136
136
|
throw new Error('context closed');
|
|
137
137
|
});
|
|
138
138
|
const { window } = createFakeWindow({ binding });
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
import React, { useEffect, useRef, useState } from 'react';
|
|
18
18
|
import { createPortal } from 'react-dom';
|
|
19
19
|
|
|
20
|
-
import { blockAncestorChain, nearestBlock } from '
|
|
21
|
-
import { highlightBox, labelChip, overlayContainer } from '
|
|
20
|
+
import { blockAncestorChain, nearestBlock } from './elementInspect.js';
|
|
21
|
+
import { highlightBox, labelChip, overlayContainer } from './openInEditorStyles.js';
|
|
22
22
|
import findBlockLocation from './findBlockLocation.js';
|
|
23
23
|
import getCspNonce from '../../lib/client/getCspNonce.js';
|
|
24
24
|
|
|
25
25
|
const STYLE_TAG_ID = 'lowdefy-open-in-editor-style-tag';
|
|
26
26
|
const BODY_CLASS = 'lowdefy-open-in-editor-target';
|
|
27
27
|
|
|
28
|
-
// Cursor over arbitrary app descendants can't be forced from inline styles
|
|
29
|
-
//
|
|
28
|
+
// Cursor over arbitrary app descendants can't be forced from inline styles,
|
|
29
|
+
// so a style tag toggled by a body class sets it.
|
|
30
30
|
function injectStyleTag() {
|
|
31
31
|
if (typeof document === 'undefined' || document.getElementById(STYLE_TAG_ID)) {
|
|
32
32
|
return;
|
|
@@ -49,16 +49,6 @@ function removeStyleTag() {
|
|
|
49
49
|
document.getElementById(STYLE_TAG_ID)?.remove();
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// The feedback overlay owns clicks while it is open (its picking mode claims
|
|
53
|
-
// them) — the Option/Alt+click shortcut stays out of the way until it closes.
|
|
54
|
-
// :not() skips this component's own highlight portal, which carries
|
|
55
|
-
// data-lowdefy-feedback purely for screenshot/picking exclusion.
|
|
56
|
-
function feedbackOverlayOpen() {
|
|
57
|
-
return Boolean(
|
|
58
|
-
document.querySelector('[data-lowdefy-feedback]:not([data-lowdefy-open-in-editor])')
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
52
|
// Option (macOS) / Alt (Windows, Linux) alone is the shortcut. Cmd/Ctrl are left
|
|
63
53
|
// to the browser (open link in new tab) and Shift to text selection, so any of
|
|
64
54
|
// them held alongside means the developer wants the browser's behaviour.
|
|
@@ -68,17 +58,15 @@ function isOpenModifier(event) {
|
|
|
68
58
|
|
|
69
59
|
// Dev-only: Option/Alt+click any element to open the YAML that defines its
|
|
70
60
|
// block in VS Code (vscode://file deep link, at the exact line). While the
|
|
71
|
-
// modifier is held, the hovered block shows
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
// FeedbackMount, and follows their resilience contract — every handler is
|
|
61
|
+
// modifier is held, the hovered block shows a blue highlight box and blockId
|
|
62
|
+
// chip, and the cursor switches to a pointer — so the developer sees exactly
|
|
63
|
+
// what a click will open. Mounted always-on from Routing.jsx alongside
|
|
64
|
+
// Inspector, and follows its resilience contract — every handler is
|
|
76
65
|
// try/caught so this can never take the app down with it.
|
|
77
66
|
//
|
|
78
67
|
// The click resolves the nearest block and, when that id is generated at
|
|
79
68
|
// runtime (list items, Dynamic endpoints), falls back through the ancestor
|
|
80
|
-
// block chain until an id resolves in config
|
|
81
|
-
// feedback pipeline uses in enrichFeedback.js.
|
|
69
|
+
// block chain until an id resolves in config.
|
|
82
70
|
function OpenInEditorListener({ basePath, pageId }) {
|
|
83
71
|
const [hoverBlock, setHoverBlock] = useState(null); // { blockId, rect }
|
|
84
72
|
// Refs keep the freshest values without re-binding the capture listeners
|
|
@@ -88,6 +76,7 @@ function OpenInEditorListener({ basePath, pageId }) {
|
|
|
88
76
|
const hoverRef = useRef(hoverBlock);
|
|
89
77
|
hoverRef.current = hoverBlock;
|
|
90
78
|
const lastPointerRef = useRef(null); // { x, y }
|
|
79
|
+
const frameRef = useRef(null); // pending animation frame of a hover resolve
|
|
91
80
|
|
|
92
81
|
// Style tag lifecycle — the listener is always mounted, so this lives for
|
|
93
82
|
// the app's lifetime and only the body class toggles per hover.
|
|
@@ -115,6 +104,7 @@ function OpenInEditorListener({ basePath, pageId }) {
|
|
|
115
104
|
|
|
116
105
|
useEffect(() => {
|
|
117
106
|
function clearHover() {
|
|
107
|
+
cancelScheduledHover();
|
|
118
108
|
if (hoverRef.current) {
|
|
119
109
|
setHoverBlock(null);
|
|
120
110
|
}
|
|
@@ -123,7 +113,7 @@ function OpenInEditorListener({ basePath, pageId }) {
|
|
|
123
113
|
function resolveHover() {
|
|
124
114
|
try {
|
|
125
115
|
const point = lastPointerRef.current;
|
|
126
|
-
if (!point
|
|
116
|
+
if (!point) {
|
|
127
117
|
clearHover();
|
|
128
118
|
return;
|
|
129
119
|
}
|
|
@@ -144,11 +134,30 @@ function OpenInEditorListener({ basePath, pageId }) {
|
|
|
144
134
|
}
|
|
145
135
|
}
|
|
146
136
|
|
|
137
|
+
// elementFromPoint and getBoundingClientRect force layout, so pointer moves
|
|
138
|
+
// resolve the hover at most once per animation frame, at the latest point.
|
|
139
|
+
function scheduleResolveHover() {
|
|
140
|
+
if (frameRef.current !== null) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
frameRef.current = requestAnimationFrame(() => {
|
|
144
|
+
frameRef.current = null;
|
|
145
|
+
resolveHover();
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function cancelScheduledHover() {
|
|
150
|
+
if (frameRef.current !== null) {
|
|
151
|
+
cancelAnimationFrame(frameRef.current);
|
|
152
|
+
frameRef.current = null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
147
156
|
function onPointerMove(event) {
|
|
148
157
|
try {
|
|
149
158
|
lastPointerRef.current = { x: event.clientX, y: event.clientY };
|
|
150
159
|
if (isOpenModifier(event)) {
|
|
151
|
-
|
|
160
|
+
scheduleResolveHover();
|
|
152
161
|
} else {
|
|
153
162
|
clearHover();
|
|
154
163
|
}
|
|
@@ -211,9 +220,6 @@ function OpenInEditorListener({ basePath, pageId }) {
|
|
|
211
220
|
if (!isOpenModifier(event)) {
|
|
212
221
|
return;
|
|
213
222
|
}
|
|
214
|
-
if (feedbackOverlayOpen()) {
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
223
|
const candidates = blockAncestorChain(event.target);
|
|
218
224
|
if (candidates.length === 0) {
|
|
219
225
|
return;
|
|
@@ -235,6 +241,7 @@ function OpenInEditorListener({ basePath, pageId }) {
|
|
|
235
241
|
window.addEventListener('scroll', onScroll, true);
|
|
236
242
|
window.addEventListener('click', onClickCapture, { capture: true });
|
|
237
243
|
return () => {
|
|
244
|
+
cancelScheduledHover();
|
|
238
245
|
window.removeEventListener('pointermove', onPointerMove);
|
|
239
246
|
window.removeEventListener('keydown', onKeyDown);
|
|
240
247
|
window.removeEventListener('keyup', onKeyUp);
|
|
@@ -247,10 +254,10 @@ function OpenInEditorListener({ basePath, pageId }) {
|
|
|
247
254
|
if (!hoverBlock || typeof document === 'undefined' || !document.body) {
|
|
248
255
|
return null;
|
|
249
256
|
}
|
|
250
|
-
// data-lowdefy-
|
|
251
|
-
//
|
|
257
|
+
// data-lowdefy-dev-tools keeps the highlight out of block resolution and
|
|
258
|
+
// out of the journey recorder (both skip that root).
|
|
252
259
|
return createPortal(
|
|
253
|
-
<div data-lowdefy-
|
|
260
|
+
<div data-lowdefy-dev-tools style={overlayContainer}>
|
|
254
261
|
<div
|
|
255
262
|
style={{
|
|
256
263
|
...highlightBox,
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import { act } from 'react-dom/test-utils';
|
|
20
|
+
import { createRoot } from 'react-dom/client';
|
|
21
|
+
import { afterEach, beforeEach, expect, test, vi } from 'vitest';
|
|
22
|
+
|
|
23
|
+
import OpenInEditorListener from './OpenInEditorListener.jsx';
|
|
24
|
+
|
|
25
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
26
|
+
|
|
27
|
+
let container;
|
|
28
|
+
let root;
|
|
29
|
+
let frames;
|
|
30
|
+
let elementFromPoint;
|
|
31
|
+
|
|
32
|
+
function flushFrames() {
|
|
33
|
+
const pending = [...frames];
|
|
34
|
+
frames.length = 0;
|
|
35
|
+
act(() => {
|
|
36
|
+
pending.forEach((callback) => callback?.());
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function move(x, y, init = {}) {
|
|
41
|
+
const event = new MouseEvent('pointermove', {
|
|
42
|
+
clientX: x,
|
|
43
|
+
clientY: y,
|
|
44
|
+
altKey: true,
|
|
45
|
+
bubbles: true,
|
|
46
|
+
...init,
|
|
47
|
+
});
|
|
48
|
+
act(() => {
|
|
49
|
+
window.dispatchEvent(event);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
frames = [];
|
|
55
|
+
vi.stubGlobal('requestAnimationFrame', (callback) => frames.push(callback));
|
|
56
|
+
vi.stubGlobal('cancelAnimationFrame', (id) => {
|
|
57
|
+
frames[id - 1] = null;
|
|
58
|
+
});
|
|
59
|
+
document.body.innerHTML = '<div id="bl-a"></div><div id="bl-b"></div>';
|
|
60
|
+
elementFromPoint = vi.fn((x) => document.getElementById(x < 100 ? 'bl-a' : 'bl-b'));
|
|
61
|
+
document.elementFromPoint = elementFromPoint;
|
|
62
|
+
container = document.createElement('div');
|
|
63
|
+
document.body.appendChild(container);
|
|
64
|
+
root = createRoot(container);
|
|
65
|
+
act(() => {
|
|
66
|
+
root.render(React.createElement(OpenInEditorListener, { basePath: '', pageId: 'page' }));
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
afterEach(() => {
|
|
71
|
+
act(() => root.unmount());
|
|
72
|
+
vi.unstubAllGlobals();
|
|
73
|
+
document.body.innerHTML = '';
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('many pointer moves with Alt held resolve the hover once, at the latest point', () => {
|
|
77
|
+
move(10, 10);
|
|
78
|
+
move(20, 20);
|
|
79
|
+
move(150, 30);
|
|
80
|
+
expect(frames.filter(Boolean)).toHaveLength(1);
|
|
81
|
+
expect(elementFromPoint).not.toHaveBeenCalled();
|
|
82
|
+
|
|
83
|
+
flushFrames();
|
|
84
|
+
expect(elementFromPoint).toHaveBeenCalledTimes(1);
|
|
85
|
+
expect(elementFromPoint).toHaveBeenCalledWith(150, 30);
|
|
86
|
+
expect(document.body.textContent).toContain('b');
|
|
87
|
+
expect(document.body.classList.contains('lowdefy-open-in-editor-target')).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('a move in a later frame schedules a new resolve', () => {
|
|
91
|
+
move(10, 10);
|
|
92
|
+
flushFrames();
|
|
93
|
+
move(150, 10);
|
|
94
|
+
flushFrames();
|
|
95
|
+
expect(elementFromPoint).toHaveBeenCalledTimes(2);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('a move without the modifier cancels the pending resolve and clears the highlight', () => {
|
|
99
|
+
move(10, 10);
|
|
100
|
+
flushFrames();
|
|
101
|
+
expect(document.body.classList.contains('lowdefy-open-in-editor-target')).toBe(true);
|
|
102
|
+
|
|
103
|
+
move(10, 10);
|
|
104
|
+
move(11, 11, { altKey: false });
|
|
105
|
+
flushFrames();
|
|
106
|
+
expect(elementFromPoint).toHaveBeenCalledTimes(1);
|
|
107
|
+
expect(document.body.classList.contains('lowdefy-open-in-editor-target')).toBe(false);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('unmount cancels a pending resolve', () => {
|
|
111
|
+
move(10, 10);
|
|
112
|
+
act(() => root.unmount());
|
|
113
|
+
flushFrames();
|
|
114
|
+
expect(elementFromPoint).not.toHaveBeenCalled();
|
|
115
|
+
root = createRoot(container);
|
|
116
|
+
});
|
|
@@ -14,33 +14,30 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
// Pure DOM-reading helpers for
|
|
17
|
+
// Pure DOM-reading helpers for open-in-editor's block resolution.
|
|
18
18
|
// Blocks render as id="bl-{blockId}" (skeletons use "s-bl-" and must NOT
|
|
19
19
|
// match — the "^=" prefix selector already excludes them since "s-bl-..."
|
|
20
20
|
// starts with "s-", not "bl-").
|
|
21
21
|
|
|
22
22
|
const BLOCK_ID_PREFIX = 'bl-';
|
|
23
23
|
const BLOCK_SELECTOR = `[id^="${BLOCK_ID_PREFIX}"]`;
|
|
24
|
-
const
|
|
25
|
-
const MAX_TEXT_LENGTH = 120;
|
|
26
|
-
const MAX_CLASS_LENGTH = 200;
|
|
24
|
+
const DEV_TOOLS_ROOT_SELECTOR = '[data-lowdefy-dev-tools]';
|
|
27
25
|
|
|
28
|
-
function
|
|
26
|
+
function isInsideDevTools(el) {
|
|
29
27
|
if (!(el instanceof Element)) {
|
|
30
28
|
return false;
|
|
31
29
|
}
|
|
32
|
-
return Boolean(el.closest(
|
|
30
|
+
return Boolean(el.closest(DEV_TOOLS_ROOT_SELECTOR));
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
function stripBlockId(blockEl) {
|
|
36
34
|
return blockEl.id.slice(BLOCK_ID_PREFIX.length);
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
// Nearest ancestor block element (or the element itself), ignoring the
|
|
40
|
-
//
|
|
41
|
-
// app block.
|
|
37
|
+
// Nearest ancestor block element (or the element itself), ignoring the dev
|
|
38
|
+
// tools' own DOM so pointing at the highlight never resolves to an app block.
|
|
42
39
|
function nearestBlock(el) {
|
|
43
|
-
if (!(el instanceof Element) ||
|
|
40
|
+
if (!(el instanceof Element) || isInsideDevTools(el)) {
|
|
44
41
|
return null;
|
|
45
42
|
}
|
|
46
43
|
const blockEl = el.closest(BLOCK_SELECTOR);
|
|
@@ -52,7 +49,7 @@ function nearestBlock(el) {
|
|
|
52
49
|
|
|
53
50
|
// All bl- ancestors, nearest to outermost, prefix stripped.
|
|
54
51
|
function blockAncestorChain(el) {
|
|
55
|
-
if (!(el instanceof Element) ||
|
|
52
|
+
if (!(el instanceof Element) || isInsideDevTools(el)) {
|
|
56
53
|
return [];
|
|
57
54
|
}
|
|
58
55
|
const chain = [];
|
|
@@ -64,36 +61,4 @@ function blockAncestorChain(el) {
|
|
|
64
61
|
return chain;
|
|
65
62
|
}
|
|
66
63
|
|
|
67
|
-
|
|
68
|
-
if (!(el instanceof Element)) {
|
|
69
|
-
return { tag: null, classes: null, text: null };
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let classes = null;
|
|
73
|
-
try {
|
|
74
|
-
classes = typeof el.className === 'string' ? el.className : null;
|
|
75
|
-
} catch {
|
|
76
|
-
classes = null;
|
|
77
|
-
}
|
|
78
|
-
if (classes && classes.length > MAX_CLASS_LENGTH) {
|
|
79
|
-
classes = `${classes.slice(0, MAX_CLASS_LENGTH)}…`;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
let text = '';
|
|
83
|
-
try {
|
|
84
|
-
text = el.textContent ? el.textContent.trim() : '';
|
|
85
|
-
} catch {
|
|
86
|
-
text = '';
|
|
87
|
-
}
|
|
88
|
-
if (text.length > MAX_TEXT_LENGTH) {
|
|
89
|
-
text = `${text.slice(0, MAX_TEXT_LENGTH)}…`;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return {
|
|
93
|
-
tag: el.tagName ?? null,
|
|
94
|
-
classes,
|
|
95
|
-
text: text || null,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export { nearestBlock, blockAncestorChain, describeElement };
|
|
64
|
+
export { nearestBlock, blockAncestorChain };
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
// Resolves a blockId to its YAML source via the dev server's existing
|
|
18
18
|
// GET /lowdefy-docs/find/{id}?pageId= route (which JIT-builds the page's
|
|
19
19
|
// keyMap on demand). Returns { file, line } with an absolute file path, or
|
|
20
|
-
// null when the id has no configured location. Best-effort
|
|
21
|
-
//
|
|
20
|
+
// null when the id has no configured location. Best-effort — a dev-only
|
|
21
|
+
// feature must never throw into the app.
|
|
22
22
|
async function findBlockLocation({ basePath, blockId, pageId }) {
|
|
23
23
|
try {
|
|
24
24
|
// Omit pageId when unknown — an empty ?pageId= reads as an unknown page
|