@osdk/react-devtools 0.5.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/CHANGELOG.md +79 -0
- package/build/esm/DevToolsContext.js +19 -0
- package/build/esm/DevToolsContext.js.map +1 -0
- package/build/esm/components/ActionMetrics.js +89 -0
- package/build/esm/components/ActionMetrics.js.map +1 -0
- package/build/esm/components/BubbleChart.js +175 -0
- package/build/esm/components/BubbleChart.js.map +1 -0
- package/build/esm/components/BubbleChart.module.scss.js +6 -0
- package/build/esm/components/CacheInspectorTab.js +291 -0
- package/build/esm/components/CacheInspectorTab.js.map +1 -0
- package/build/esm/components/CacheInspectorTab.module.scss.js +39 -0
- package/build/esm/components/CacheMetrics.js +55 -0
- package/build/esm/components/CacheMetrics.js.map +1 -0
- package/build/esm/components/ComponentCard.js +124 -0
- package/build/esm/components/ComponentCard.js.map +1 -0
- package/build/esm/components/ComponentCard.module.scss.js +31 -0
- package/build/esm/components/ComputeTab.js +175 -0
- package/build/esm/components/ComputeTab.js.map +1 -0
- package/build/esm/components/CopyableCodeBlock.js +49 -0
- package/build/esm/components/CopyableCodeBlock.js.map +1 -0
- package/build/esm/components/CopyableCodeBlock.module.scss.js +10 -0
- package/build/esm/components/DebuggingTab.js +342 -0
- package/build/esm/components/DebuggingTab.js.map +1 -0
- package/build/esm/components/DebuggingTab.module.scss.js +18 -0
- package/build/esm/components/HookRow.js +180 -0
- package/build/esm/components/HookRow.js.map +1 -0
- package/build/esm/components/HookRow.module.scss.js +16 -0
- package/build/esm/components/ImprovementsTab.js +138 -0
- package/build/esm/components/ImprovementsTab.js.map +1 -0
- package/build/esm/components/ImprovementsTab.module.scss.js +30 -0
- package/build/esm/components/InspectorSelectionHeader.js +65 -0
- package/build/esm/components/InspectorSelectionHeader.js.map +1 -0
- package/build/esm/components/InterceptTab.js +862 -0
- package/build/esm/components/InterceptTab.js.map +1 -0
- package/build/esm/components/InterceptTab.module.scss.js +49 -0
- package/build/esm/components/IssueCard.js +115 -0
- package/build/esm/components/IssueCard.js.map +1 -0
- package/build/esm/components/IssueCard.module.scss.js +24 -0
- package/build/esm/components/LogEntryCard.js +94 -0
- package/build/esm/components/LogEntryCard.js.map +1 -0
- package/build/esm/components/LogEntryCard.module.scss.js +19 -0
- package/build/esm/components/MockEditor.js +316 -0
- package/build/esm/components/MockEditor.js.map +1 -0
- package/build/esm/components/MonitorErrorBoundary.js +64 -0
- package/build/esm/components/MonitorErrorBoundary.js.map +1 -0
- package/build/esm/components/MonitorErrorBoundary.module.scss.js +9 -0
- package/build/esm/components/MonitoringPanel.js +434 -0
- package/build/esm/components/MonitoringPanel.js.map +1 -0
- package/build/esm/components/MonitoringPanel.module.scss.js +81 -0
- package/build/esm/components/ObjectLoadingMetrics.js +60 -0
- package/build/esm/components/ObjectLoadingMetrics.js.map +1 -0
- package/build/esm/components/OsdkAppErrorBoundary.js +68 -0
- package/build/esm/components/OsdkAppErrorBoundary.js.map +1 -0
- package/build/esm/components/OsdkDevTools.js +40 -0
- package/build/esm/components/OsdkDevTools.js.map +1 -0
- package/build/esm/components/OverrideEditor.js +197 -0
- package/build/esm/components/OverrideEditor.js.map +1 -0
- package/build/esm/components/PerformanceTab.js +297 -0
- package/build/esm/components/PerformanceTab.js.map +1 -0
- package/build/esm/components/PrimitiveSelectionPanel.js +220 -0
- package/build/esm/components/PrimitiveSelectionPanel.js.map +1 -0
- package/build/esm/components/PrimitiveSelectionPanel.module.scss.js +26 -0
- package/build/esm/components/issueTypes.js +2 -0
- package/build/esm/components/issueTypes.js.map +1 -0
- package/build/esm/components/resolveComponentName.js +57 -0
- package/build/esm/components/resolveComponentName.js.map +1 -0
- package/build/esm/components/testHelpers.js +312 -0
- package/build/esm/components/testHelpers.js.map +1 -0
- package/build/esm/css.d.ts +20 -0
- package/build/esm/fiber/DegradationNotice.js +193 -0
- package/build/esm/fiber/DegradationNotice.js.map +1 -0
- package/build/esm/fiber/DevtoolsHook.js +252 -0
- package/build/esm/fiber/DevtoolsHook.js.map +1 -0
- package/build/esm/fiber/FiberAccess.js +65 -0
- package/build/esm/fiber/FiberAccess.js.map +1 -0
- package/build/esm/fiber/FiberInspection.js +140 -0
- package/build/esm/fiber/FiberInspection.js.map +1 -0
- package/build/esm/fiber/FiberTags.js +52 -0
- package/build/esm/fiber/FiberTags.js.map +1 -0
- package/build/esm/fiber/HookStateInspector.js +254 -0
- package/build/esm/fiber/HookStateInspector.js.map +1 -0
- package/build/esm/fiber/SafeFiberOperation.js +35 -0
- package/build/esm/fiber/SafeFiberOperation.js.map +1 -0
- package/build/esm/fiber/capabilities.js +180 -0
- package/build/esm/fiber/capabilities.js.map +1 -0
- package/build/esm/fiber/traverseFiber.js +129 -0
- package/build/esm/fiber/traverseFiber.js.map +1 -0
- package/build/esm/fiber/types.js +2 -0
- package/build/esm/fiber/types.js.map +1 -0
- package/build/esm/fiber/validation.js +155 -0
- package/build/esm/fiber/validation.js.map +1 -0
- package/build/esm/hooks/createPollingStore.js +81 -0
- package/build/esm/hooks/createPollingStore.js.map +1 -0
- package/build/esm/hooks/useActiveComponents.js +27 -0
- package/build/esm/hooks/useActiveComponents.js.map +1 -0
- package/build/esm/hooks/useComponentRegistry.js +25 -0
- package/build/esm/hooks/useComponentRegistry.js.map +1 -0
- package/build/esm/hooks/useComputeSelectors.js +43 -0
- package/build/esm/hooks/useComputeSelectors.js.map +1 -0
- package/build/esm/hooks/useConsoleLogs.js +46 -0
- package/build/esm/hooks/useConsoleLogs.js.map +1 -0
- package/build/esm/hooks/useInspectorSelection.js +93 -0
- package/build/esm/hooks/useInspectorSelection.js.map +1 -0
- package/build/esm/hooks/useMetrics.js +23 -0
- package/build/esm/hooks/useMetrics.js.map +1 -0
- package/build/esm/hooks/usePersistedState.js +89 -0
- package/build/esm/hooks/usePersistedState.js.map +1 -0
- package/build/esm/hooks/useRecommendations.js +123 -0
- package/build/esm/hooks/useRecommendations.js.map +1 -0
- package/build/esm/hooks/useSharedTick.js +49 -0
- package/build/esm/hooks/useSharedTick.js.map +1 -0
- package/build/esm/hooks/useTimeElapsed.js +51 -0
- package/build/esm/hooks/useTimeElapsed.js.map +1 -0
- package/build/esm/hooks/useTrackerSubscription.js +97 -0
- package/build/esm/hooks/useTrackerSubscription.js.map +1 -0
- package/build/esm/hooks/useUnusedFieldAnalysis.js +99 -0
- package/build/esm/hooks/useUnusedFieldAnalysis.js.map +1 -0
- package/build/esm/index.js +31 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/inspector/ClickToInspectSystem.js +228 -0
- package/build/esm/inspector/ClickToInspectSystem.js.map +1 -0
- package/build/esm/inspector/components/ComponentLabel.js +175 -0
- package/build/esm/inspector/components/ComponentLabel.js.map +1 -0
- package/build/esm/inspector/components/ComponentLabel.module.scss.js +12 -0
- package/build/esm/inspector/components/InspectorBanner.js +79 -0
- package/build/esm/inspector/components/InspectorBanner.js.map +1 -0
- package/build/esm/inspector/components/InspectorOverlay.js +149 -0
- package/build/esm/inspector/components/InspectorOverlay.js.map +1 -0
- package/build/esm/inspector/components/SelectionHighlight.js +74 -0
- package/build/esm/inspector/components/SelectionHighlight.js.map +1 -0
- package/build/esm/inspector/createClickToInspect.js +21 -0
- package/build/esm/inspector/createClickToInspect.js.map +1 -0
- package/build/esm/inspector/hooks/useAnimatedBounds.js +167 -0
- package/build/esm/inspector/hooks/useAnimatedBounds.js.map +1 -0
- package/build/esm/inspector/index.js +40 -0
- package/build/esm/inspector/index.js.map +1 -0
- package/build/esm/inspector/inspectorController.js +328 -0
- package/build/esm/inspector/inspectorController.js.map +1 -0
- package/build/esm/inspector/types.js +2 -0
- package/build/esm/inspector/types.js.map +1 -0
- package/build/esm/inspector/utils/elementBounds.js +72 -0
- package/build/esm/inspector/utils/elementBounds.js.map +1 -0
- package/build/esm/inspector/utils/interpolation.js +26 -0
- package/build/esm/inspector/utils/interpolation.js.map +1 -0
- package/build/esm/inspector/utils/labelPositioning.js +62 -0
- package/build/esm/inspector/utils/labelPositioning.js.map +1 -0
- package/build/esm/mocking/MockCacheKeyGenerator.js +109 -0
- package/build/esm/mocking/MockCacheKeyGenerator.js.map +1 -0
- package/build/esm/mocking/MockManager.js +281 -0
- package/build/esm/mocking/MockManager.js.map +1 -0
- package/build/esm/prototyping/PrototypeOverrideStore.js +66 -0
- package/build/esm/prototyping/PrototypeOverrideStore.js.map +1 -0
- package/build/esm/prototyping/index.js +18 -0
- package/build/esm/prototyping/index.js.map +1 -0
- package/build/esm/public/vite.js +19 -0
- package/build/esm/public/vite.js.map +1 -0
- package/build/esm/register.js +41 -0
- package/build/esm/register.js.map +1 -0
- package/build/esm/scss.d.ts +20 -0
- package/build/esm/store/ComputeStore.js +269 -0
- package/build/esm/store/ComputeStore.js.map +1 -0
- package/build/esm/store/ConsoleLogStore.js +289 -0
- package/build/esm/store/ConsoleLogStore.js.map +1 -0
- package/build/esm/store/MetricsStore.js +428 -0
- package/build/esm/store/MetricsStore.js.map +1 -0
- package/build/esm/store/MonitorStore.js +288 -0
- package/build/esm/store/MonitorStore.js.map +1 -0
- package/build/esm/store/SubscribableStore.js +38 -0
- package/build/esm/store/SubscribableStore.js.map +1 -0
- package/build/esm/store/WindowErrorStore.js +195 -0
- package/build/esm/store/WindowErrorStore.js.map +1 -0
- package/build/esm/styles.css +19441 -0
- package/build/esm/styles.js +31 -0
- package/build/esm/styles.js.map +1 -0
- package/build/esm/types/compute.js +2 -0
- package/build/esm/types/compute.js.map +1 -0
- package/build/esm/types/emissions.js +2 -0
- package/build/esm/types/emissions.js.map +1 -0
- package/build/esm/types/index.js +23 -0
- package/build/esm/types/index.js.map +1 -0
- package/build/esm/utils/ActionLifecycleTracker.js +178 -0
- package/build/esm/utils/ActionLifecycleTracker.js.map +1 -0
- package/build/esm/utils/CacheEfficiencyAnalyzer.js +198 -0
- package/build/esm/utils/CacheEfficiencyAnalyzer.js.map +1 -0
- package/build/esm/utils/CircularBuffer.js +96 -0
- package/build/esm/utils/CircularBuffer.js.map +1 -0
- package/build/esm/utils/ComponentContextCapture.js +215 -0
- package/build/esm/utils/ComponentContextCapture.js.map +1 -0
- package/build/esm/utils/ComponentPrimitiveDiscovery.js +173 -0
- package/build/esm/utils/ComponentPrimitiveDiscovery.js.map +1 -0
- package/build/esm/utils/ComponentQueryRegistry.js +340 -0
- package/build/esm/utils/ComponentQueryRegistry.js.map +1 -0
- package/build/esm/utils/ComputeMonitor.js +199 -0
- package/build/esm/utils/ComputeMonitor.js.map +1 -0
- package/build/esm/utils/EventTimeline.js +130 -0
- package/build/esm/utils/EventTimeline.js.map +1 -0
- package/build/esm/utils/LinkTraversalTracker.js +116 -0
- package/build/esm/utils/LinkTraversalTracker.js.map +1 -0
- package/build/esm/utils/MockDataGenerator.js +473 -0
- package/build/esm/utils/MockDataGenerator.js.map +1 -0
- package/build/esm/utils/ObservableClientMonitor.js +768 -0
- package/build/esm/utils/ObservableClientMonitor.js.map +1 -0
- package/build/esm/utils/PerformanceRecommendationEngine.js +185 -0
- package/build/esm/utils/PerformanceRecommendationEngine.js.map +1 -0
- package/build/esm/utils/PropertyAccessTracker.js +238 -0
- package/build/esm/utils/PropertyAccessTracker.js.map +1 -0
- package/build/esm/utils/RecommendationMatcher.js +53 -0
- package/build/esm/utils/RecommendationMatcher.js.map +1 -0
- package/build/esm/utils/SubscriptionTracker.js +132 -0
- package/build/esm/utils/SubscriptionTracker.js.map +1 -0
- package/build/esm/utils/UnusedFieldAnalyzer.js +186 -0
- package/build/esm/utils/UnusedFieldAnalyzer.js.map +1 -0
- package/build/esm/utils/WaterfallDetector.js +200 -0
- package/build/esm/utils/WaterfallDetector.js.map +1 -0
- package/build/esm/utils/computePayload.js +37 -0
- package/build/esm/utils/computePayload.js.map +1 -0
- package/build/esm/utils/computeRequest.js +29 -0
- package/build/esm/utils/computeRequest.js.map +1 -0
- package/build/esm/utils/format.js +69 -0
- package/build/esm/utils/format.js.map +1 -0
- package/build/esm/utils/logger.js +31 -0
- package/build/esm/utils/logger.js.map +1 -0
- package/build/esm/vite/constants.js +18 -0
- package/build/esm/vite/constants.js.map +1 -0
- package/build/esm/vite/hookInstaller.js +99 -0
- package/build/esm/vite/hookInstaller.js.map +1 -0
- package/build/esm/vite/index.js +77 -0
- package/build/esm/vite/index.js.map +1 -0
- package/build/types/DevToolsContext.d.ts +3 -0
- package/build/types/DevToolsContext.d.ts.map +1 -0
- package/build/types/components/ActionMetrics.d.ts +6 -0
- package/build/types/components/ActionMetrics.d.ts.map +1 -0
- package/build/types/components/BubbleChart.d.ts +10 -0
- package/build/types/components/BubbleChart.d.ts.map +1 -0
- package/build/types/components/CacheInspectorTab.d.ts +6 -0
- package/build/types/components/CacheInspectorTab.d.ts.map +1 -0
- package/build/types/components/CacheMetrics.d.ts +6 -0
- package/build/types/components/CacheMetrics.d.ts.map +1 -0
- package/build/types/components/ComponentCard.d.ts +13 -0
- package/build/types/components/ComponentCard.d.ts.map +1 -0
- package/build/types/components/ComputeTab.d.ts +6 -0
- package/build/types/components/ComputeTab.d.ts.map +1 -0
- package/build/types/components/CopyableCodeBlock.d.ts +7 -0
- package/build/types/components/CopyableCodeBlock.d.ts.map +1 -0
- package/build/types/components/DebuggingTab.d.ts +6 -0
- package/build/types/components/DebuggingTab.d.ts.map +1 -0
- package/build/types/components/HookRow.d.ts +9 -0
- package/build/types/components/HookRow.d.ts.map +1 -0
- package/build/types/components/ImprovementsTab.d.ts +7 -0
- package/build/types/components/ImprovementsTab.d.ts.map +1 -0
- package/build/types/components/InspectorSelectionHeader.d.ts +12 -0
- package/build/types/components/InspectorSelectionHeader.d.ts.map +1 -0
- package/build/types/components/InterceptTab.d.ts +126 -0
- package/build/types/components/InterceptTab.d.ts.map +1 -0
- package/build/types/components/IssueCard.d.ts +8 -0
- package/build/types/components/IssueCard.d.ts.map +1 -0
- package/build/types/components/LogEntryCard.d.ts +7 -0
- package/build/types/components/LogEntryCard.d.ts.map +1 -0
- package/build/types/components/MockEditor.d.ts +58 -0
- package/build/types/components/MockEditor.d.ts.map +1 -0
- package/build/types/components/MonitorErrorBoundary.d.ts +16 -0
- package/build/types/components/MonitorErrorBoundary.d.ts.map +1 -0
- package/build/types/components/MonitoringPanel.d.ts +8 -0
- package/build/types/components/MonitoringPanel.d.ts.map +1 -0
- package/build/types/components/ObjectLoadingMetrics.d.ts +7 -0
- package/build/types/components/ObjectLoadingMetrics.d.ts.map +1 -0
- package/build/types/components/OsdkAppErrorBoundary.d.ts +18 -0
- package/build/types/components/OsdkAppErrorBoundary.d.ts.map +1 -0
- package/build/types/components/OsdkDevTools.d.ts +2 -0
- package/build/types/components/OsdkDevTools.d.ts.map +1 -0
- package/build/types/components/OverrideEditor.d.ts +26 -0
- package/build/types/components/OverrideEditor.d.ts.map +1 -0
- package/build/types/components/PerformanceTab.d.ts +8 -0
- package/build/types/components/PerformanceTab.d.ts.map +1 -0
- package/build/types/components/PrimitiveSelectionPanel.d.ts +28 -0
- package/build/types/components/PrimitiveSelectionPanel.d.ts.map +1 -0
- package/build/types/components/issueTypes.d.ts +16 -0
- package/build/types/components/issueTypes.d.ts.map +1 -0
- package/build/types/components/resolveComponentName.d.ts +3 -0
- package/build/types/components/resolveComponentName.d.ts.map +1 -0
- package/build/types/components/testHelpers.d.ts +2 -0
- package/build/types/components/testHelpers.d.ts.map +1 -0
- package/build/types/css.d.d.ts +4 -0
- package/build/types/css.d.d.ts.map +1 -0
- package/build/types/fiber/DegradationNotice.d.ts +8 -0
- package/build/types/fiber/DegradationNotice.d.ts.map +1 -0
- package/build/types/fiber/DevtoolsHook.d.ts +7 -0
- package/build/types/fiber/DevtoolsHook.d.ts.map +1 -0
- package/build/types/fiber/FiberAccess.d.ts +2 -0
- package/build/types/fiber/FiberAccess.d.ts.map +1 -0
- package/build/types/fiber/FiberInspection.d.ts +6 -0
- package/build/types/fiber/FiberInspection.d.ts.map +1 -0
- package/build/types/fiber/FiberTags.d.ts +33 -0
- package/build/types/fiber/FiberTags.d.ts.map +1 -0
- package/build/types/fiber/HookStateInspector.d.ts +45 -0
- package/build/types/fiber/HookStateInspector.d.ts.map +1 -0
- package/build/types/fiber/SafeFiberOperation.d.ts +7 -0
- package/build/types/fiber/SafeFiberOperation.d.ts.map +1 -0
- package/build/types/fiber/capabilities.d.ts +38 -0
- package/build/types/fiber/capabilities.d.ts.map +1 -0
- package/build/types/fiber/traverseFiber.d.ts +5 -0
- package/build/types/fiber/traverseFiber.d.ts.map +1 -0
- package/build/types/fiber/types.d.ts +87 -0
- package/build/types/fiber/types.d.ts.map +1 -0
- package/build/types/fiber/validation.d.ts +10 -0
- package/build/types/fiber/validation.d.ts.map +1 -0
- package/build/types/hooks/createPollingStore.d.ts +5 -0
- package/build/types/hooks/createPollingStore.d.ts.map +1 -0
- package/build/types/hooks/useActiveComponents.d.ts +3 -0
- package/build/types/hooks/useActiveComponents.d.ts.map +1 -0
- package/build/types/hooks/useComponentRegistry.d.ts +3 -0
- package/build/types/hooks/useComponentRegistry.d.ts.map +1 -0
- package/build/types/hooks/useComputeSelectors.d.ts +7 -0
- package/build/types/hooks/useComputeSelectors.d.ts.map +1 -0
- package/build/types/hooks/useConsoleLogs.d.ts +7 -0
- package/build/types/hooks/useConsoleLogs.d.ts.map +1 -0
- package/build/types/hooks/useInspectorSelection.d.ts +9 -0
- package/build/types/hooks/useInspectorSelection.d.ts.map +1 -0
- package/build/types/hooks/useMetrics.d.ts +3 -0
- package/build/types/hooks/useMetrics.d.ts.map +1 -0
- package/build/types/hooks/usePersistedState.d.ts +1 -0
- package/build/types/hooks/usePersistedState.d.ts.map +1 -0
- package/build/types/hooks/useRecommendations.d.ts +10 -0
- package/build/types/hooks/useRecommendations.d.ts.map +1 -0
- package/build/types/hooks/useSharedTick.d.ts +1 -0
- package/build/types/hooks/useSharedTick.d.ts.map +1 -0
- package/build/types/hooks/useTimeElapsed.d.ts +1 -0
- package/build/types/hooks/useTimeElapsed.d.ts.map +1 -0
- package/build/types/hooks/useTrackerSubscription.d.ts +16 -0
- package/build/types/hooks/useTrackerSubscription.d.ts.map +1 -0
- package/build/types/hooks/useUnusedFieldAnalysis.d.ts +8 -0
- package/build/types/hooks/useUnusedFieldAnalysis.d.ts.map +1 -0
- package/build/types/index.d.ts +21 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/inspector/ClickToInspectSystem.d.ts +40 -0
- package/build/types/inspector/ClickToInspectSystem.d.ts.map +1 -0
- package/build/types/inspector/components/ComponentLabel.d.ts +3 -0
- package/build/types/inspector/components/ComponentLabel.d.ts.map +1 -0
- package/build/types/inspector/components/InspectorBanner.d.ts +5 -0
- package/build/types/inspector/components/InspectorBanner.d.ts.map +1 -0
- package/build/types/inspector/components/InspectorOverlay.d.ts +3 -0
- package/build/types/inspector/components/InspectorOverlay.d.ts.map +1 -0
- package/build/types/inspector/components/SelectionHighlight.d.ts +3 -0
- package/build/types/inspector/components/SelectionHighlight.d.ts.map +1 -0
- package/build/types/inspector/createClickToInspect.d.ts +3 -0
- package/build/types/inspector/createClickToInspect.d.ts.map +1 -0
- package/build/types/inspector/hooks/useAnimatedBounds.d.ts +2 -0
- package/build/types/inspector/hooks/useAnimatedBounds.d.ts.map +1 -0
- package/build/types/inspector/index.d.ts +13 -0
- package/build/types/inspector/index.d.ts.map +1 -0
- package/build/types/inspector/inspectorController.d.ts +2 -0
- package/build/types/inspector/inspectorController.d.ts.map +1 -0
- package/build/types/inspector/types.d.ts +94 -0
- package/build/types/inspector/types.d.ts.map +1 -0
- package/build/types/inspector/utils/elementBounds.d.ts +3 -0
- package/build/types/inspector/utils/elementBounds.d.ts.map +1 -0
- package/build/types/inspector/utils/interpolation.d.ts +7 -0
- package/build/types/inspector/utils/interpolation.d.ts.map +1 -0
- package/build/types/inspector/utils/labelPositioning.d.ts +3 -0
- package/build/types/inspector/utils/labelPositioning.d.ts.map +1 -0
- package/build/types/mocking/MockCacheKeyGenerator.d.ts +41 -0
- package/build/types/mocking/MockCacheKeyGenerator.d.ts.map +1 -0
- package/build/types/mocking/MockManager.d.ts +103 -0
- package/build/types/mocking/MockManager.d.ts.map +1 -0
- package/build/types/prototyping/PrototypeOverrideStore.d.ts +33 -0
- package/build/types/prototyping/PrototypeOverrideStore.d.ts.map +1 -0
- package/build/types/prototyping/index.d.ts +1 -0
- package/build/types/prototyping/index.d.ts.map +1 -0
- package/build/types/public/vite.d.ts +2 -0
- package/build/types/public/vite.d.ts.map +1 -0
- package/build/types/register.d.ts +1 -0
- package/build/types/register.d.ts.map +1 -0
- package/build/types/scss.d.d.ts +6 -0
- package/build/types/scss.d.d.ts.map +1 -0
- package/build/types/store/ComputeStore.d.ts +47 -0
- package/build/types/store/ComputeStore.d.ts.map +1 -0
- package/build/types/store/ConsoleLogStore.d.ts +29 -0
- package/build/types/store/ConsoleLogStore.d.ts.map +1 -0
- package/build/types/store/MetricsStore.d.ts +42 -0
- package/build/types/store/MetricsStore.d.ts.map +1 -0
- package/build/types/store/MonitorStore.d.ts +86 -0
- package/build/types/store/MonitorStore.d.ts.map +1 -0
- package/build/types/store/SubscribableStore.d.ts +6 -0
- package/build/types/store/SubscribableStore.d.ts.map +1 -0
- package/build/types/store/WindowErrorStore.d.ts +32 -0
- package/build/types/store/WindowErrorStore.d.ts.map +1 -0
- package/build/types/styles.d.ts +1 -0
- package/build/types/styles.d.ts.map +1 -0
- package/build/types/types/compute.d.ts +73 -0
- package/build/types/types/compute.d.ts.map +1 -0
- package/build/types/types/emissions.d.ts +24 -0
- package/build/types/types/emissions.d.ts.map +1 -0
- package/build/types/types/index.d.ts +143 -0
- package/build/types/types/index.d.ts.map +1 -0
- package/build/types/utils/ActionLifecycleTracker.d.ts +39 -0
- package/build/types/utils/ActionLifecycleTracker.d.ts.map +1 -0
- package/build/types/utils/CacheEfficiencyAnalyzer.d.ts +45 -0
- package/build/types/utils/CacheEfficiencyAnalyzer.d.ts.map +1 -0
- package/build/types/utils/CircularBuffer.d.ts +18 -0
- package/build/types/utils/CircularBuffer.d.ts.map +1 -0
- package/build/types/utils/ComponentContextCapture.d.ts +29 -0
- package/build/types/utils/ComponentContextCapture.d.ts.map +1 -0
- package/build/types/utils/ComponentPrimitiveDiscovery.d.ts +62 -0
- package/build/types/utils/ComponentPrimitiveDiscovery.d.ts.map +1 -0
- package/build/types/utils/ComponentQueryRegistry.d.ts +91 -0
- package/build/types/utils/ComponentQueryRegistry.d.ts.map +1 -0
- package/build/types/utils/ComputeMonitor.d.ts +14 -0
- package/build/types/utils/ComputeMonitor.d.ts.map +1 -0
- package/build/types/utils/EventTimeline.d.ts +102 -0
- package/build/types/utils/EventTimeline.d.ts.map +1 -0
- package/build/types/utils/LinkTraversalTracker.d.ts +43 -0
- package/build/types/utils/LinkTraversalTracker.d.ts.map +1 -0
- package/build/types/utils/MockDataGenerator.d.ts +23 -0
- package/build/types/utils/MockDataGenerator.d.ts.map +1 -0
- package/build/types/utils/ObservableClientMonitor.d.ts +62 -0
- package/build/types/utils/ObservableClientMonitor.d.ts.map +1 -0
- package/build/types/utils/PerformanceRecommendationEngine.d.ts +67 -0
- package/build/types/utils/PerformanceRecommendationEngine.d.ts.map +1 -0
- package/build/types/utils/PropertyAccessTracker.d.ts +50 -0
- package/build/types/utils/PropertyAccessTracker.d.ts.map +1 -0
- package/build/types/utils/RecommendationMatcher.d.ts +5 -0
- package/build/types/utils/RecommendationMatcher.d.ts.map +1 -0
- package/build/types/utils/SubscriptionTracker.d.ts +17 -0
- package/build/types/utils/SubscriptionTracker.d.ts.map +1 -0
- package/build/types/utils/UnusedFieldAnalyzer.d.ts +46 -0
- package/build/types/utils/UnusedFieldAnalyzer.d.ts.map +1 -0
- package/build/types/utils/WaterfallDetector.d.ts +28 -0
- package/build/types/utils/WaterfallDetector.d.ts.map +1 -0
- package/build/types/utils/computePayload.d.ts +3 -0
- package/build/types/utils/computePayload.d.ts.map +1 -0
- package/build/types/utils/computeRequest.d.ts +20 -0
- package/build/types/utils/computeRequest.d.ts.map +1 -0
- package/build/types/utils/format.d.ts +5 -0
- package/build/types/utils/format.d.ts.map +1 -0
- package/build/types/utils/logger.d.ts +2 -0
- package/build/types/utils/logger.d.ts.map +1 -0
- package/build/types/vite/constants.d.ts +1 -0
- package/build/types/vite/constants.d.ts.map +1 -0
- package/build/types/vite/hookInstaller.d.ts +1 -0
- package/build/types/vite/hookInstaller.d.ts.map +1 -0
- package/build/types/vite/index.d.ts +20 -0
- package/build/types/vite/index.d.ts.map +1 -0
- package/package.json +114 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
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
|
+
const DEFAULT_DEGRADATION_CONFIG = {
|
|
18
|
+
errorThreshold: 3,
|
|
19
|
+
recoveryTimeout: 30000
|
|
20
|
+
};
|
|
21
|
+
export class FiberCapabilitiesManager {
|
|
22
|
+
cachedSnapshot = null;
|
|
23
|
+
listeners = new Set();
|
|
24
|
+
featureErrorCounts = new Map();
|
|
25
|
+
featureLastError = new Map();
|
|
26
|
+
recoveryTimers = new Map();
|
|
27
|
+
constructor(config = {}) {
|
|
28
|
+
this.config = {
|
|
29
|
+
...DEFAULT_DEGRADATION_CONFIG,
|
|
30
|
+
...config
|
|
31
|
+
};
|
|
32
|
+
this.capabilities = {
|
|
33
|
+
hookInstalled: false,
|
|
34
|
+
rendererDetected: false,
|
|
35
|
+
fiberAccessWorking: false,
|
|
36
|
+
detectedReactVersion: null,
|
|
37
|
+
lastValidationTime: 0,
|
|
38
|
+
errorCount: 0,
|
|
39
|
+
disabledFeatures: new Set()
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
getCapabilities() {
|
|
43
|
+
if (this.cachedSnapshot != null) {
|
|
44
|
+
return this.cachedSnapshot;
|
|
45
|
+
}
|
|
46
|
+
this.cachedSnapshot = {
|
|
47
|
+
...this.capabilities,
|
|
48
|
+
disabledFeatures: new Set(this.capabilities.disabledFeatures)
|
|
49
|
+
};
|
|
50
|
+
return this.cachedSnapshot;
|
|
51
|
+
}
|
|
52
|
+
isFeatureAvailable(feature) {
|
|
53
|
+
if (this.capabilities.disabledFeatures.has(feature)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return this.capabilities.fiberAccessWorking;
|
|
57
|
+
}
|
|
58
|
+
setCapability(key, value) {
|
|
59
|
+
const oldValue = this.capabilities[key];
|
|
60
|
+
if (oldValue === value) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.capabilities = {
|
|
64
|
+
...this.capabilities,
|
|
65
|
+
[key]: value
|
|
66
|
+
};
|
|
67
|
+
this.cachedSnapshot = null;
|
|
68
|
+
this.notifyListeners();
|
|
69
|
+
}
|
|
70
|
+
recordError(feature, error) {
|
|
71
|
+
const currentCount = this.featureErrorCounts.get(feature) ?? 0;
|
|
72
|
+
const newCount = currentCount + 1;
|
|
73
|
+
this.featureErrorCounts.set(feature, newCount);
|
|
74
|
+
this.featureLastError.set(feature, Date.now());
|
|
75
|
+
this.capabilities = {
|
|
76
|
+
...this.capabilities,
|
|
77
|
+
errorCount: this.capabilities.errorCount + 1
|
|
78
|
+
};
|
|
79
|
+
this.cachedSnapshot = null;
|
|
80
|
+
if (newCount >= this.config.errorThreshold) {
|
|
81
|
+
this.disableFeature(feature);
|
|
82
|
+
}
|
|
83
|
+
this.scheduleRecoveryCheck(feature);
|
|
84
|
+
this.notifyListeners();
|
|
85
|
+
if (process.env.NODE_ENV !== "production") {
|
|
86
|
+
// eslint-disable-next-line no-console
|
|
87
|
+
console.warn(`[OSDK DevTools] Fiber feature "${feature}" error (${newCount}/${this.config.errorThreshold}):`, error);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
clearErrors(feature) {
|
|
91
|
+
this.featureErrorCounts.delete(feature);
|
|
92
|
+
this.featureLastError.delete(feature);
|
|
93
|
+
if (this.capabilities.disabledFeatures.has(feature)) {
|
|
94
|
+
const newDisabled = new Set(this.capabilities.disabledFeatures);
|
|
95
|
+
newDisabled.delete(feature);
|
|
96
|
+
this.capabilities = {
|
|
97
|
+
...this.capabilities,
|
|
98
|
+
disabledFeatures: newDisabled
|
|
99
|
+
};
|
|
100
|
+
this.cachedSnapshot = null;
|
|
101
|
+
this.notifyListeners();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
resetAll() {
|
|
105
|
+
this.featureErrorCounts.clear();
|
|
106
|
+
this.featureLastError.clear();
|
|
107
|
+
this.capabilities = {
|
|
108
|
+
...this.capabilities,
|
|
109
|
+
errorCount: 0,
|
|
110
|
+
disabledFeatures: new Set()
|
|
111
|
+
};
|
|
112
|
+
this.cachedSnapshot = null;
|
|
113
|
+
this.notifyListeners();
|
|
114
|
+
}
|
|
115
|
+
onCapabilitiesChange(listener) {
|
|
116
|
+
this.listeners.add(listener);
|
|
117
|
+
return () => {
|
|
118
|
+
this.listeners.delete(listener);
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
dispose() {
|
|
122
|
+
for (const timer of this.recoveryTimers.values()) {
|
|
123
|
+
clearTimeout(timer);
|
|
124
|
+
}
|
|
125
|
+
this.recoveryTimers.clear();
|
|
126
|
+
this.listeners.clear();
|
|
127
|
+
}
|
|
128
|
+
disableFeature(feature) {
|
|
129
|
+
if (this.capabilities.disabledFeatures.has(feature)) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const newDisabled = new Set(this.capabilities.disabledFeatures);
|
|
133
|
+
newDisabled.add(feature);
|
|
134
|
+
this.capabilities = {
|
|
135
|
+
...this.capabilities,
|
|
136
|
+
disabledFeatures: newDisabled
|
|
137
|
+
};
|
|
138
|
+
this.cachedSnapshot = null;
|
|
139
|
+
if (process.env.NODE_ENV !== "production") {
|
|
140
|
+
// eslint-disable-next-line no-console
|
|
141
|
+
console.warn(`[OSDK DevTools] Fiber feature "${feature}" has been disabled due to repeated errors`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
scheduleRecoveryCheck(feature) {
|
|
145
|
+
const existingTimer = this.recoveryTimers.get(feature);
|
|
146
|
+
if (existingTimer !== undefined) {
|
|
147
|
+
clearTimeout(existingTimer);
|
|
148
|
+
}
|
|
149
|
+
const timer = setTimeout(() => {
|
|
150
|
+
this.recoveryTimers.delete(feature);
|
|
151
|
+
const lastError = this.featureLastError.get(feature);
|
|
152
|
+
if (lastError && Date.now() - lastError >= this.config.recoveryTimeout) {
|
|
153
|
+
this.clearErrors(feature);
|
|
154
|
+
if (process.env.NODE_ENV !== "production") {
|
|
155
|
+
// eslint-disable-next-line no-console
|
|
156
|
+
console.info(`[OSDK DevTools] Fiber feature "${feature}" re-enabled after recovery timeout`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}, this.config.recoveryTimeout);
|
|
160
|
+
this.recoveryTimers.set(feature, timer);
|
|
161
|
+
}
|
|
162
|
+
notifyListeners() {
|
|
163
|
+
const snapshot = this.getCapabilities();
|
|
164
|
+
for (const listener of this.listeners) {
|
|
165
|
+
try {
|
|
166
|
+
listener(snapshot);
|
|
167
|
+
} catch {
|
|
168
|
+
// Ignore listener errors
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
let instance = null;
|
|
174
|
+
export function getCapabilitiesManager() {
|
|
175
|
+
if (instance == null) {
|
|
176
|
+
instance = new FiberCapabilitiesManager();
|
|
177
|
+
}
|
|
178
|
+
return instance;
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.js","names":["DEFAULT_DEGRADATION_CONFIG","errorThreshold","recoveryTimeout","FiberCapabilitiesManager","cachedSnapshot","listeners","Set","featureErrorCounts","Map","featureLastError","recoveryTimers","constructor","config","capabilities","hookInstalled","rendererDetected","fiberAccessWorking","detectedReactVersion","lastValidationTime","errorCount","disabledFeatures","getCapabilities","isFeatureAvailable","feature","has","setCapability","key","value","oldValue","notifyListeners","recordError","error","currentCount","get","newCount","set","Date","now","disableFeature","scheduleRecoveryCheck","process","env","NODE_ENV","console","warn","clearErrors","delete","newDisabled","resetAll","clear","onCapabilitiesChange","listener","add","dispose","timer","values","clearTimeout","existingTimer","undefined","setTimeout","lastError","info","snapshot","instance","getCapabilitiesManager"],"sources":["capabilities.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type FiberFeature =\n | \"component-inspection\"\n | \"hook-discovery\"\n | \"render-tracking\"\n | \"state-inspection\"\n | \"metadata-extraction\"\n | \"fiber-discovery\";\n\nexport interface FiberCapabilities {\n hookInstalled: boolean;\n rendererDetected: boolean;\n fiberAccessWorking: boolean;\n detectedReactVersion: string | null;\n lastValidationTime: number;\n errorCount: number;\n disabledFeatures: Set<FiberFeature>;\n}\n\ninterface DegradationConfig {\n errorThreshold: number;\n recoveryTimeout: number;\n}\n\nconst DEFAULT_DEGRADATION_CONFIG: DegradationConfig = {\n errorThreshold: 3,\n recoveryTimeout: 30000,\n};\n\ntype CapabilitiesListener = (capabilities: FiberCapabilities) => void;\n\nexport class FiberCapabilitiesManager {\n private capabilities: FiberCapabilities;\n private cachedSnapshot: Readonly<FiberCapabilities> | null = null;\n private listeners: Set<CapabilitiesListener> = new Set();\n private featureErrorCounts: Map<FiberFeature, number> = new Map();\n private featureLastError: Map<FiberFeature, number> = new Map();\n private recoveryTimers: Map<FiberFeature, ReturnType<typeof setTimeout>> =\n new Map();\n private config: DegradationConfig;\n\n constructor(config: Partial<DegradationConfig> = {}) {\n this.config = { ...DEFAULT_DEGRADATION_CONFIG, ...config };\n this.capabilities = {\n hookInstalled: false,\n rendererDetected: false,\n fiberAccessWorking: false,\n detectedReactVersion: null,\n lastValidationTime: 0,\n errorCount: 0,\n disabledFeatures: new Set(),\n };\n }\n\n getCapabilities(): Readonly<FiberCapabilities> {\n if (this.cachedSnapshot != null) {\n return this.cachedSnapshot;\n }\n this.cachedSnapshot = {\n ...this.capabilities,\n disabledFeatures: new Set(this.capabilities.disabledFeatures),\n };\n return this.cachedSnapshot;\n }\n\n isFeatureAvailable(feature: FiberFeature): boolean {\n if (this.capabilities.disabledFeatures.has(feature)) {\n return false;\n }\n return this.capabilities.fiberAccessWorking;\n }\n\n setCapability<K extends keyof FiberCapabilities>(\n key: K,\n value: FiberCapabilities[K],\n ): void {\n const oldValue = this.capabilities[key];\n if (oldValue === value) {\n return;\n }\n\n this.capabilities = {\n ...this.capabilities,\n [key]: value,\n };\n this.cachedSnapshot = null;\n this.notifyListeners();\n }\n\n recordError(feature: FiberFeature, error: unknown): void {\n const currentCount = this.featureErrorCounts.get(feature) ?? 0;\n const newCount = currentCount + 1;\n this.featureErrorCounts.set(feature, newCount);\n this.featureLastError.set(feature, Date.now());\n\n this.capabilities = {\n ...this.capabilities,\n errorCount: this.capabilities.errorCount + 1,\n };\n this.cachedSnapshot = null;\n\n if (newCount >= this.config.errorThreshold) {\n this.disableFeature(feature);\n }\n\n this.scheduleRecoveryCheck(feature);\n this.notifyListeners();\n\n if (process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.warn(\n `[OSDK DevTools] Fiber feature \"${feature}\" error (${newCount}/${this.config.errorThreshold}):`,\n error,\n );\n }\n }\n\n clearErrors(feature: FiberFeature): void {\n this.featureErrorCounts.delete(feature);\n this.featureLastError.delete(feature);\n\n if (this.capabilities.disabledFeatures.has(feature)) {\n const newDisabled = new Set(this.capabilities.disabledFeatures);\n newDisabled.delete(feature);\n this.capabilities = {\n ...this.capabilities,\n disabledFeatures: newDisabled,\n };\n this.cachedSnapshot = null;\n this.notifyListeners();\n }\n }\n\n resetAll(): void {\n this.featureErrorCounts.clear();\n this.featureLastError.clear();\n this.capabilities = {\n ...this.capabilities,\n errorCount: 0,\n disabledFeatures: new Set(),\n };\n this.cachedSnapshot = null;\n this.notifyListeners();\n }\n\n onCapabilitiesChange(listener: CapabilitiesListener): () => void {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n dispose(): void {\n for (const timer of this.recoveryTimers.values()) {\n clearTimeout(timer);\n }\n this.recoveryTimers.clear();\n this.listeners.clear();\n }\n\n private disableFeature(feature: FiberFeature): void {\n if (this.capabilities.disabledFeatures.has(feature)) {\n return;\n }\n\n const newDisabled = new Set(this.capabilities.disabledFeatures);\n newDisabled.add(feature);\n this.capabilities = {\n ...this.capabilities,\n disabledFeatures: newDisabled,\n };\n this.cachedSnapshot = null;\n\n if (process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.warn(\n `[OSDK DevTools] Fiber feature \"${feature}\" has been disabled due to repeated errors`,\n );\n }\n }\n\n private scheduleRecoveryCheck(feature: FiberFeature): void {\n const existingTimer = this.recoveryTimers.get(feature);\n if (existingTimer !== undefined) {\n clearTimeout(existingTimer);\n }\n\n const timer = setTimeout(() => {\n this.recoveryTimers.delete(feature);\n const lastError = this.featureLastError.get(feature);\n if (lastError && Date.now() - lastError >= this.config.recoveryTimeout) {\n this.clearErrors(feature);\n if (process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.info(\n `[OSDK DevTools] Fiber feature \"${feature}\" re-enabled after recovery timeout`,\n );\n }\n }\n }, this.config.recoveryTimeout);\n\n this.recoveryTimers.set(feature, timer);\n }\n\n private notifyListeners(): void {\n const snapshot = this.getCapabilities();\n for (const listener of this.listeners) {\n try {\n listener(snapshot);\n } catch {\n // Ignore listener errors\n }\n }\n }\n}\n\nlet instance: FiberCapabilitiesManager | null = null;\n\nexport function getCapabilitiesManager(): FiberCapabilitiesManager {\n if (instance == null) {\n instance = new FiberCapabilitiesManager();\n }\n return instance;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA,MAAMA,0BAA6C,GAAG;EACpDC,cAAc,EAAE,CAAC;EACjBC,eAAe,EAAE;AACnB,CAAC;AAID,OAAO,MAAMC,wBAAwB,CAAC;EAE5BC,cAAc,GAAuC,IAAI;EACzDC,SAAS,GAA8B,IAAIC,GAAG,CAAC,CAAC;EAChDC,kBAAkB,GAA8B,IAAIC,GAAG,CAAC,CAAC;EACzDC,gBAAgB,GAA8B,IAAID,GAAG,CAAC,CAAC;EACvDE,cAAc,GACpB,IAAIF,GAAG,CAAC,CAAC;EAGXG,WAAWA,CAACC,MAAkC,GAAG,CAAC,CAAC,EAAE;IACnD,IAAI,CAACA,MAAM,GAAG;MAAE,GAAGZ,0BAA0B;MAAE,GAAGY;IAAO,CAAC;IAC1D,IAAI,CAACC,YAAY,GAAG;MAClBC,aAAa,EAAE,KAAK;MACpBC,gBAAgB,EAAE,KAAK;MACvBC,kBAAkB,EAAE,KAAK;MACzBC,oBAAoB,EAAE,IAAI;MAC1BC,kBAAkB,EAAE,CAAC;MACrBC,UAAU,EAAE,CAAC;MACbC,gBAAgB,EAAE,IAAId,GAAG,CAAC;IAC5B,CAAC;EACH;EAEAe,eAAeA,CAAA,EAAgC;IAC7C,IAAI,IAAI,CAACjB,cAAc,IAAI,IAAI,EAAE;MAC/B,O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
+
*
|
|
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 { isUserComponent } from "./FiberTags.js";
|
|
18
|
+
import { safeFiberOperation } from "./SafeFiberOperation.js";
|
|
19
|
+
const DEFAULT_MAX_DEPTH = 500;
|
|
20
|
+
export function traverseFiber(fiber, selector, ascending, maxDepth = DEFAULT_MAX_DEPTH) {
|
|
21
|
+
if (!fiber) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
if (selector(fiber) === true) {
|
|
25
|
+
return fiber;
|
|
26
|
+
}
|
|
27
|
+
if (maxDepth <= 0) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (ascending) {
|
|
31
|
+
return fiber.return ? traverseFiber(fiber.return, selector, true, maxDepth - 1) : null;
|
|
32
|
+
}
|
|
33
|
+
let child = fiber.child;
|
|
34
|
+
while (child) {
|
|
35
|
+
const match = traverseFiber(child, selector, false, maxDepth - 1);
|
|
36
|
+
if (match) {
|
|
37
|
+
return match;
|
|
38
|
+
}
|
|
39
|
+
child = child.sibling;
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
export function traverseAllFibers(fiber, selector, ascending, maxResults, maxDepth = DEFAULT_MAX_DEPTH) {
|
|
44
|
+
const results = [];
|
|
45
|
+
function walk(node, depth) {
|
|
46
|
+
if (!node) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (maxResults != null && results.length >= maxResults) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (selector(node) === true) {
|
|
53
|
+
results.push(node);
|
|
54
|
+
if (maxResults != null && results.length >= maxResults) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (depth >= maxDepth) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (ascending) {
|
|
62
|
+
if (node.return) {
|
|
63
|
+
walk(node.return, depth + 1);
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
let child = node.child;
|
|
67
|
+
while (child) {
|
|
68
|
+
walk(child, depth + 1);
|
|
69
|
+
if (maxResults != null && results.length >= maxResults) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
child = child.sibling;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
walk(fiber, 0);
|
|
77
|
+
return results;
|
|
78
|
+
}
|
|
79
|
+
export function walkFiberTree(fiber, visitor, maxDepth = DEFAULT_MAX_DEPTH) {
|
|
80
|
+
const stack = [{
|
|
81
|
+
fiber,
|
|
82
|
+
depth: 0
|
|
83
|
+
}];
|
|
84
|
+
while (stack.length > 0) {
|
|
85
|
+
const entry = stack.pop();
|
|
86
|
+
if (!entry) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const {
|
|
90
|
+
fiber: current,
|
|
91
|
+
depth
|
|
92
|
+
} = entry;
|
|
93
|
+
if (depth > maxDepth) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
visitor(current);
|
|
97
|
+
const children = [];
|
|
98
|
+
let child = current.child;
|
|
99
|
+
while (child) {
|
|
100
|
+
children.push(child);
|
|
101
|
+
child = child.sibling;
|
|
102
|
+
}
|
|
103
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
104
|
+
stack.push({
|
|
105
|
+
fiber: children[i],
|
|
106
|
+
depth: depth + 1
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const FIND_PARENT_MAX_DEPTH = 100;
|
|
112
|
+
export function findParentComponent(fiber) {
|
|
113
|
+
return safeFiberOperation(() => {
|
|
114
|
+
let current = fiber.return;
|
|
115
|
+
let depth = 0;
|
|
116
|
+
while (current && depth < FIND_PARENT_MAX_DEPTH) {
|
|
117
|
+
if (isUserComponent(current)) {
|
|
118
|
+
return current;
|
|
119
|
+
}
|
|
120
|
+
current = current.return;
|
|
121
|
+
depth++;
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}, {
|
|
125
|
+
fallback: null,
|
|
126
|
+
feature: "component-inspection"
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=traverseFiber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traverseFiber.js","names":["isUserComponent","safeFiberOperation","DEFAULT_MAX_DEPTH","traverseFiber","fiber","selector","ascending","maxDepth","return","child","match","sibling","traverseAllFibers","maxResults","results","walk","node","depth","length","push","walkFiberTree","visitor","stack","entry","pop","current","children","i","FIND_PARENT_MAX_DEPTH","findParentComponent","fallback","feature"],"sources":["traverseFiber.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isUserComponent } from \"./FiberTags.js\";\nimport { safeFiberOperation } from \"./SafeFiberOperation.js\";\nimport type { Fiber } from \"./types.js\";\n\nconst DEFAULT_MAX_DEPTH = 500;\n\nexport function traverseFiber(\n fiber: Fiber | null,\n selector: (node: Fiber) => boolean | void,\n ascending?: boolean,\n maxDepth: number = DEFAULT_MAX_DEPTH,\n): Fiber | null {\n if (!fiber) {\n return null;\n }\n\n if (selector(fiber) === true) {\n return fiber;\n }\n\n if (maxDepth <= 0) {\n return null;\n }\n\n if (ascending) {\n return fiber.return\n ? traverseFiber(fiber.return, selector, true, maxDepth - 1)\n : null;\n }\n\n let child: Fiber | null = fiber.child;\n while (child) {\n const match = traverseFiber(child, selector, false, maxDepth - 1);\n if (match) {\n return match;\n }\n child = child.sibling;\n }\n\n return null;\n}\n\nexport function traverseAllFibers(\n fiber: Fiber | null,\n selector: (node: Fiber) => boolean | void,\n ascending?: boolean,\n maxResults?: number,\n maxDepth: number = DEFAULT_MAX_DEPTH,\n): Fiber[] {\n const results: Fiber[] = [];\n\n function walk(node: Fiber | null, depth: number): void {\n if (!node) {\n return;\n }\n if (maxResults != null && results.length >= maxResults) {\n return;\n }\n\n if (selector(node) === true) {\n results.push(node);\n if (maxResults != null && results.length >= maxResults) {\n return;\n }\n }\n\n if (depth >= maxDepth) {\n return;\n }\n\n if (ascending) {\n if (node.return) {\n walk(node.return, depth + 1);\n }\n } else {\n let child: Fiber | null = node.child;\n while (child) {\n walk(child, depth + 1);\n if (maxResults != null && results.length >= maxResults) {\n return;\n }\n child = child.sibling;\n }\n }\n }\n\n walk(fiber, 0);\n return results;\n}\n\nexport function walkFiberTree(\n fiber: Fiber,\n visitor: (fiber: Fiber) => void,\n maxDepth: number = DEFAULT_MAX_DEPTH,\n): void {\n const stack: Array<{ fiber: Fiber; depth: number }> = [\n { fiber, depth: 0 },\n ];\n\n while (stack.length > 0) {\n const entry = stack.pop();\n if (!entry) {\n continue;\n }\n const { fiber: current, depth } = entry;\n\n if (depth > maxDepth) {\n continue;\n }\n\n visitor(current);\n\n const children: Fiber[] = [];\n let child: Fiber | null = current.child;\n while (child) {\n children.push(child);\n child = child.sibling;\n }\n\n for (let i = children.length - 1; i >= 0; i--) {\n stack.push({ fiber: children[i], depth: depth + 1 });\n }\n }\n}\n\nconst FIND_PARENT_MAX_DEPTH = 100;\n\nexport function findParentComponent(fiber: Fiber): Fiber | null {\n return safeFiberOperation(\n () => {\n let current: Fiber | null = fiber.return;\n let depth = 0;\n\n while (current && depth < FIND_PARENT_MAX_DEPTH) {\n if (isUserComponent(current)) {\n return current;\n }\n current = current.return;\n depth++;\n }\n\n return null;\n },\n { fallback: null, feature: \"component-inspection\" },\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,QAAQ,gBAAgB;AAChD,SAASC,kBAAkB,QAAQ,yBAAyB;AAG5D,MAAMC,iBAAiB,GAAG,GAAG;AAE7B,OAAO,SAASC,aAAaA,CAC3BC,KAAmB,EACnBC,QAAyC,EACzCC,SAAmB,EACnBC,QAAgB,GAAGL,iBAAiB,EACtB;EACd,IAAI,CAACE,KAAK,EAAE;IACV,OAAO,IAAI;EACb;EAEA,IAAIC,QAAQ,CAACD,KAAK,CAAC,KAAK,IAAI,EAAE;IAC5B,OAAOA,KAAK;EACd;EAEA,IAAIG,QAAQ,IAAI,CAAC,EAAE;IACjB,OAAO,IAAI;EACb;EAEA,IAAID,SAAS,EAAE;IACb,OAAOF,KAAK,CAACI,MAAM,GACfL,aAAa,CAACC,KAAK,CAACI,MAAM,EAAEH,QAAQ,EAAE,IAAI,EAAEE,QAAQ,GAAG,CAAC,CAAC,GACzD,IAAI;EACV;EAEA,IAAIE,KAAmB,GAAGL,KAAK,CAACK,KAAK;EACrC,OAAOA,KAAK,EAAE;IACZ,MAAMC,KAAK,GAAGP,aAAa,CAACM,KAAK,EAAEJ,QAAQ,EAAE,KAAK,EAAEE,QAAQ,GAAG,CAAC,CAAC;IACjE,IAAIG,KAAK,EAAE;MACT,OAAOA,KAAK;IACd;IACAD,KAAK,GAAGA,KAAK,CAACE,OAAO;EACvB;EAEA,OAAO,I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OAAO,EAAE;EAAuB,CACpD,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["types.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n Fiber as ReactFiber,\n FiberRoot,\n Flags,\n Lanes,\n ReactContext,\n WorkTag,\n} from \"react-reconciler\";\n\nexport type { FiberRoot, Flags, Lanes, ReactContext, WorkTag };\n\nexport interface ContextDependency<T = unknown> {\n context: ReactContext<T>;\n memoizedValue: T;\n next: ContextDependency | null;\n observedBits: number;\n}\n\nexport interface Dependencies {\n firstContext: ContextDependency | null;\n lanes: Lanes;\n}\n\nexport interface Effect {\n create: (...args: unknown[]) => unknown;\n deps: unknown[] | null;\n destroy: ((...args: unknown[]) => unknown) | null;\n next: Effect | null;\n tag: number;\n}\n\nexport interface MemoizedState {\n memoizedState: unknown;\n next: MemoizedState | null;\n}\n\nexport interface FiberProps {\n [key: string]: unknown;\n}\n\nexport interface UpdateQueue {\n lastEffect: Effect | null;\n}\n\nexport type Fiber<TStateNode = unknown> =\n & Omit<\n ReactFiber,\n | \"alternate\"\n | \"child\"\n | \"dependencies\"\n | \"memoizedProps\"\n | \"memoizedState\"\n | \"pendingProps\"\n | \"return\"\n | \"sibling\"\n | \"stateNode\"\n | \"updateQueue\"\n >\n & {\n _debugInfo?: Array<{\n debugLocation?: unknown;\n env?: string;\n name?: string;\n }>;\n\n _debugOwner?: Fiber;\n _debugSource?: {\n columnNumber?: number;\n fileName: string;\n lineNumber: number;\n };\n\n _debugStack?: Error & { stack: string };\n alternate: Fiber | null;\n child: Fiber | null;\n return: Fiber | null;\n sibling: Fiber | null;\n\n dependencies: Dependencies | null;\n memoizedProps: FiberProps;\n memoizedState: MemoizedState | null;\n pendingProps: FiberProps;\n stateNode: TStateNode;\n updateQueue: UpdateQueue | null;\n };\n\nexport interface ReactRenderer {\n bundleType: 0 | 1;\n findFiberByHostInstance?: (hostInstance: unknown) => Fiber | null;\n getCurrentFiber?: (fiber: Fiber) => Fiber | null;\n overrideHookState?: (\n fiber: Fiber,\n id: string,\n path: string[],\n value: unknown,\n ) => void;\n overrideProps?: (fiber: Fiber, path: string[], value: unknown) => void;\n reconcilerVersion: string;\n rendererPackageName: string;\n version: string;\n}\n\nexport interface ReactDevToolsGlobalHook {\n _instrumentationIsActive?: boolean;\n _instrumentationSource?: string;\n checkDCE: (fn: unknown) => void;\n hasUnsupportedRendererAttached: boolean;\n inject: (renderer: ReactRenderer) => number;\n on: () => void;\n onCommitFiberRoot: (\n rendererID: number,\n root: FiberRoot,\n priority: number | void,\n ) => void;\n onCommitFiberUnmount: (rendererID: number, fiber: Fiber) => void;\n onPostCommitFiberRoot: (rendererID: number, root: FiberRoot) => void;\n renderers: Map<number, ReactRenderer>;\n supportsFiber: boolean;\n supportsFlight: boolean;\n}\n\nexport interface SourceLocation {\n fileName: string;\n lineNumber: number;\n columnNumber?: number;\n}\n\ndeclare global {\n var __REACT_DEVTOOLS_GLOBAL_HOOK__: ReactDevToolsGlobalHook | undefined;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
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 { getCapabilitiesManager } from "./capabilities.js";
|
|
18
|
+
import { getAllFiberRoots, getRenderers } from "./DevtoolsHook.js";
|
|
19
|
+
export function validateFiberAccess() {
|
|
20
|
+
const manager = getCapabilitiesManager();
|
|
21
|
+
const errors = [];
|
|
22
|
+
let reactVersion = null;
|
|
23
|
+
const hookInstalled = typeof globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined";
|
|
24
|
+
manager.setCapability("hookInstalled", hookInstalled);
|
|
25
|
+
if (!hookInstalled) {
|
|
26
|
+
errors.push({
|
|
27
|
+
field: "hookInstalled",
|
|
28
|
+
message: "React DevTools global hook is not installed",
|
|
29
|
+
value: false
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
let rendererDetected = false;
|
|
33
|
+
if (hookInstalled) {
|
|
34
|
+
const hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
35
|
+
if (hook?.renderers && hook.renderers.size > 0) {
|
|
36
|
+
rendererDetected = true;
|
|
37
|
+
const firstRenderer = hook.renderers.values().next().value;
|
|
38
|
+
if (firstRenderer?.version) {
|
|
39
|
+
reactVersion = firstRenderer.version;
|
|
40
|
+
} else if (firstRenderer?.reconcilerVersion) {
|
|
41
|
+
reactVersion = firstRenderer.reconcilerVersion;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
manager.setCapability("rendererDetected", rendererDetected);
|
|
46
|
+
manager.setCapability("detectedReactVersion", reactVersion);
|
|
47
|
+
if (!rendererDetected) {
|
|
48
|
+
errors.push({
|
|
49
|
+
field: "rendererDetected",
|
|
50
|
+
message: "No React renderer detected. React may not have loaded yet.",
|
|
51
|
+
value: false
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
let fiberAccessWorking = false;
|
|
55
|
+
if (rendererDetected) {
|
|
56
|
+
fiberAccessWorking = testFiberAccess();
|
|
57
|
+
}
|
|
58
|
+
manager.setCapability("fiberAccessWorking", fiberAccessWorking);
|
|
59
|
+
if (rendererDetected && !fiberAccessWorking) {
|
|
60
|
+
errors.push({
|
|
61
|
+
field: "fiberAccessWorking",
|
|
62
|
+
message: "Unable to access React fiber tree",
|
|
63
|
+
value: false
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
manager.setCapability("lastValidationTime", Date.now());
|
|
67
|
+
const success = hookInstalled && rendererDetected && fiberAccessWorking;
|
|
68
|
+
return {
|
|
69
|
+
success,
|
|
70
|
+
reactVersion,
|
|
71
|
+
capabilities: {
|
|
72
|
+
hookInstalled,
|
|
73
|
+
rendererDetected,
|
|
74
|
+
fiberAccessWorking,
|
|
75
|
+
detectedReactVersion: reactVersion
|
|
76
|
+
},
|
|
77
|
+
errors
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function testFiberAccess() {
|
|
81
|
+
const renderers = getRenderers();
|
|
82
|
+
if (renderers.size > 0) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
const trackedRoots = getAllFiberRoots();
|
|
87
|
+
for (const fiberRoot of trackedRoots) {
|
|
88
|
+
if (fiberRoot.current && typeof fiberRoot.current === "object" && "tag" in fiberRoot.current && typeof fiberRoot.current.tag === "number") {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const domRoots = findReactRoots();
|
|
93
|
+
for (const root of domRoots) {
|
|
94
|
+
const fiber = getFiberFromRoot(root);
|
|
95
|
+
if (fiber && typeof fiber === "object" && "tag" in fiber && typeof fiber.tag === "number") {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
} catch {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const COMMON_ROOT_SELECTORS = ["#root", "#app", "#__next", "[data-reactroot]", "#___gatsby", "#react-root", "#application"];
|
|
105
|
+
function hasReactInternals(element) {
|
|
106
|
+
for (const key in element) {
|
|
107
|
+
if (key.startsWith("__reactContainer$") || key.startsWith("_reactRootContainer")) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
function findReactRoots() {
|
|
114
|
+
const roots = [];
|
|
115
|
+
for (const selector of COMMON_ROOT_SELECTORS) {
|
|
116
|
+
const el = document.querySelector(selector);
|
|
117
|
+
if (el && hasReactInternals(el)) {
|
|
118
|
+
roots.push(el);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (roots.length > 0) {
|
|
122
|
+
return roots;
|
|
123
|
+
}
|
|
124
|
+
const topLevelChildren = document.body?.children;
|
|
125
|
+
if (topLevelChildren) {
|
|
126
|
+
for (const child of topLevelChildren) {
|
|
127
|
+
if (hasReactInternals(child)) {
|
|
128
|
+
roots.push(child);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return roots;
|
|
133
|
+
}
|
|
134
|
+
function getFiberFromRoot(element) {
|
|
135
|
+
const elementWithInternals = element;
|
|
136
|
+
for (const key in element) {
|
|
137
|
+
if (key.startsWith("__reactContainer$")) {
|
|
138
|
+
const container = elementWithInternals[key];
|
|
139
|
+
if (container && typeof container === "object" && "current" in container) {
|
|
140
|
+
return container.current;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if ("_reactRootContainer" in element) {
|
|
145
|
+
const legacyRoot = elementWithInternals._reactRootContainer;
|
|
146
|
+
if (legacyRoot && typeof legacyRoot === "object") {
|
|
147
|
+
const internalRoot = legacyRoot._internalRoot;
|
|
148
|
+
if (internalRoot && typeof internalRoot === "object") {
|
|
149
|
+
return internalRoot.current;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","names":["getCapabilitiesManager","getAllFiberRoots","getRenderers","validateFiberAccess","manager","errors","reactVersion","hookInstalled","globalThis","__REACT_DEVTOOLS_GLOBAL_HOOK__","setCapability","push","field","message","value","rendererDetected","hook","renderers","size","firstRenderer","values","next","version","reconcilerVersion","fiberAccessWorking","testFiberAccess","Date","now","success","capabilities","detectedReactVersion","trackedRoots","fiberRoot","current","tag","domRoots","findReactRoots","root","fiber","getFiberFromRoot","COMMON_ROOT_SELECTORS","hasReactInternals","element","key","startsWith","roots","selector","el","document","querySelector","length","topLevelChildren","body","children","child","elementWithInternals","container","legacyRoot","_reactRootContainer","internalRoot","_internalRoot"],"sources":["validation.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ValidationError } from \"../types/index.js\";\nimport {\n type FiberCapabilities,\n getCapabilitiesManager,\n} from \"./capabilities.js\";\nimport { getAllFiberRoots, getRenderers } from \"./DevtoolsHook.js\";\n\ninterface ValidationResult {\n success: boolean;\n reactVersion: string | null;\n capabilities: Partial<FiberCapabilities>;\n errors: ValidationError[];\n}\n\nexport function validateFiberAccess(): ValidationResult {\n const manager = getCapabilitiesManager();\n const errors: ValidationError[] = [];\n let reactVersion: string | null = null;\n\n const hookInstalled =\n typeof globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__ !== \"undefined\";\n manager.setCapability(\"hookInstalled\", hookInstalled);\n\n if (!hookInstalled) {\n errors.push({\n field: \"hookInstalled\",\n message: \"React DevTools global hook is not installed\",\n value: false,\n });\n }\n\n let rendererDetected = false;\n if (hookInstalled) {\n const hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;\n if (hook?.renderers && hook.renderers.size > 0) {\n rendererDetected = true;\n\n const firstRenderer = hook.renderers.values().next().value;\n if (firstRenderer?.version) {\n reactVersion = firstRenderer.version;\n } else if (firstRenderer?.reconcilerVersion) {\n reactVersion = firstRenderer.reconcilerVersion;\n }\n }\n }\n manager.setCapability(\"rendererDetected\", rendererDetected);\n manager.setCapability(\"detectedReactVersion\", reactVersion);\n\n if (!rendererDetected) {\n errors.push({\n field: \"rendererDetected\",\n message: \"No React renderer detected. React may not have loaded yet.\",\n value: false,\n });\n }\n\n let fiberAccessWorking = false;\n if (rendererDetected) {\n fiberAccessWorking = testFiberAccess();\n }\n manager.setCapability(\"fiberAccessWorking\", fiberAccessWorking);\n\n if (rendererDetected && !fiberAccessWorking) {\n errors.push({\n field: \"fiberAccessWorking\",\n message: \"Unable to access React fiber tree\",\n value: false,\n });\n }\n\n manager.setCapability(\"lastValidationTime\", Date.now());\n\n const success = hookInstalled && rendererDetected && fiberAccessWorking;\n\n return {\n success,\n reactVersion,\n capabilities: {\n hookInstalled,\n rendererDetected,\n fiberAccessWorking,\n detectedReactVersion: reactVersion,\n },\n errors,\n };\n}\n\nfunction testFiberAccess(): boolean {\n const renderers = getRenderers();\n if (renderers.size > 0) {\n return true;\n }\n\n try {\n const trackedRoots = getAllFiberRoots();\n for (const fiberRoot of trackedRoots) {\n if (\n fiberRoot.current\n && typeof fiberRoot.current === \"object\"\n && \"tag\" in fiberRoot.current\n && typeof fiberRoot.current.tag === \"number\"\n ) {\n return true;\n }\n }\n\n const domRoots = findReactRoots();\n for (const root of domRoots) {\n const fiber = getFiberFromRoot(root);\n if (\n fiber\n && typeof fiber === \"object\"\n && \"tag\" in fiber\n && typeof fiber.tag === \"number\"\n ) {\n return true;\n }\n }\n\n return false;\n } catch {\n return false;\n }\n}\n\nconst COMMON_ROOT_SELECTORS = [\n \"#root\",\n \"#app\",\n \"#__next\",\n \"[data-reactroot]\",\n \"#___gatsby\",\n \"#react-root\",\n \"#application\",\n];\n\nfunction hasReactInternals(element: Element): boolean {\n for (const key in element) {\n if (\n key.startsWith(\"__reactContainer$\")\n || key.startsWith(\"_reactRootContainer\")\n ) {\n return true;\n }\n }\n return false;\n}\n\nfunction findReactRoots(): Element[] {\n const roots: Element[] = [];\n\n for (const selector of COMMON_ROOT_SELECTORS) {\n const el = document.querySelector(selector);\n if (el && hasReactInternals(el)) {\n roots.push(el);\n }\n }\n\n if (roots.length > 0) {\n return roots;\n }\n\n const topLevelChildren = document.body?.children;\n if (topLevelChildren) {\n for (const child of topLevelChildren) {\n if (hasReactInternals(child)) {\n roots.push(child);\n }\n }\n }\n\n return roots;\n}\n\nfunction getFiberFromRoot(element: Element): unknown {\n const elementWithInternals = element as unknown as Record<string, unknown>;\n\n for (const key in element) {\n if (key.startsWith(\"__reactContainer$\")) {\n const container = elementWithInternals[key];\n if (\n container && typeof container === \"object\" && \"current\" in container\n ) {\n return (container as { current: unknown }).current;\n }\n }\n }\n\n if (\"_reactRootContainer\" in element) {\n const legacyRoot = elementWithInternals._reactRootContainer;\n if (legacyRoot && typeof legacyRoot === \"object\") {\n const internalRoot =\n (legacyRoot as Record<string, unknown>)._internalRoot;\n if (internalRoot && typeof internalRoot === \"object\") {\n return (internalRoot as { current: unknown }).current;\n }\n }\n }\n\n return null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAEEA,sBAAsB,QACjB,mBAAmB;AAC1B,SAASC,gBAAgB,EAAEC,YA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;EACF;EAEA,OAAOT,KAAK;AACd;AAEA,SAASN,gBAAgBA,CAACG,OAAgB,EAAW;EACnD,MAAMa,oBAAoB,GAAGb,OAA6C;EAE1E,KAAK,MAAMC,GAAG,IAAID,OAAO,EAAE;IACzB,IAAIC,GAAG,CAACC,UAAU,CAAC,mBAAmB,CAAC,EAAE;MACvC,MAAMY,SAAS,GAAGD,oBAAoB,CAACZ,GAAG,CAAC;MAC3C,IACEa,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,SAAS,IAAIA,SAAS,EACpE;QACA,OAAQA,SAAS,CAA0BvB,OAAO;MACpD;IACF;EACF;EAEA,IAAI,qBAAqB,IAAIS,OAAO,EAAE;IACpC,MAAMe,UAAU,GAAGF,oBAAoB,CAACG,mBAAmB;IAC3D,IAAID,UAAU,IAAI,OAAOA,UAAU,KAAK,QAAQ,EAAE;MAChD,MAAME,YAAY,GACfF,UAAU,CAA6BG,aAAa;MACvD,IAAID,YAAY,IAAI,OAAOA,YAAY,KAAK,QAAQ,EAAE;QACpD,OAAQA,YAAY,CAA0B1B,OAAO;MACvD;IACF;EACF;EAEA,OAAO,IAAI;AACb","ignoreList":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
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
|
+
export function createPollingStore(fetchFn, intervalMs) {
|
|
18
|
+
let currentValue;
|
|
19
|
+
const listeners = new Set();
|
|
20
|
+
let intervalId = null;
|
|
21
|
+
function notify() {
|
|
22
|
+
for (const listener of listeners) {
|
|
23
|
+
listener();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function poll() {
|
|
27
|
+
try {
|
|
28
|
+
const result = fetchFn();
|
|
29
|
+
if (result instanceof Promise) {
|
|
30
|
+
result.then(value => {
|
|
31
|
+
currentValue = value;
|
|
32
|
+
notify();
|
|
33
|
+
}).catch(() => {});
|
|
34
|
+
} else {
|
|
35
|
+
currentValue = result;
|
|
36
|
+
notify();
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
// ignore polling errors
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Eagerly fetch initial value at creation time (not during subscribe)
|
|
44
|
+
// so getSnapshot() returns data before the first subscription.
|
|
45
|
+
try {
|
|
46
|
+
const result = fetchFn();
|
|
47
|
+
if (result instanceof Promise) {
|
|
48
|
+
result.then(value => {
|
|
49
|
+
currentValue = value;
|
|
50
|
+
notify();
|
|
51
|
+
}).catch(() => {});
|
|
52
|
+
} else {
|
|
53
|
+
currentValue = result;
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
// ignore initial fetch errors
|
|
57
|
+
}
|
|
58
|
+
function getSnapshot() {
|
|
59
|
+
return currentValue;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
subscribe: function subscribe(callback) {
|
|
63
|
+
listeners.add(callback);
|
|
64
|
+
if (listeners.size === 1) {
|
|
65
|
+
intervalId = setInterval(poll, intervalMs);
|
|
66
|
+
}
|
|
67
|
+
return () => {
|
|
68
|
+
listeners.delete(callback);
|
|
69
|
+
if (listeners.size === 0 && intervalId != null) {
|
|
70
|
+
clearInterval(intervalId);
|
|
71
|
+
intervalId = null;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
getSnapshot,
|
|
76
|
+
forceRefresh: function forceRefresh() {
|
|
77
|
+
poll();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=createPollingStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPollingStore.js","names":["createPollingStore","fetchFn","intervalMs","currentValue","listeners","Set","intervalId","notify","listener","poll","result","Promise","then","value","catch","getSnapshot","subscribe","callback","add","size","setInterval","delete","clearInterval","forceRefresh"],"sources":["createPollingStore.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function createPollingStore<T>(\n fetchFn: () => T | Promise<T>,\n intervalMs: number,\n): {\n subscribe: (callback: () => void) => () => void;\n getSnapshot: () => T | undefined;\n forceRefresh: () => void;\n} {\n let currentValue: T | undefined;\n const listeners = new Set<() => void>();\n let intervalId: ReturnType<typeof setInterval> | null = null;\n\n function notify(): void {\n for (const listener of listeners) {\n listener();\n }\n }\n\n function poll(): void {\n try {\n const result = fetchFn();\n if (result instanceof Promise) {\n result.then((value) => {\n currentValue = value;\n notify();\n }).catch(() => {});\n } else {\n currentValue = result;\n notify();\n }\n } catch {\n // ignore polling errors\n }\n }\n\n // Eagerly fetch initial value at creation time (not during subscribe)\n // so getSnapshot() returns data before the first subscription.\n try {\n const result = fetchFn();\n if (result instanceof Promise) {\n result.then((value) => {\n currentValue = value;\n notify();\n }).catch(() => {});\n } else {\n currentValue = result;\n }\n } catch {\n // ignore initial fetch errors\n }\n\n function subscribe(callback: () => void): () => void {\n listeners.add(callback);\n if (listeners.size === 1) {\n intervalId = setInterval(poll, intervalMs);\n }\n return () => {\n listeners.delete(callback);\n if (listeners.size === 0 && intervalId != null) {\n clearInterval(intervalId);\n intervalId = null;\n }\n };\n }\n\n function getSnapshot(): T | undefined {\n return currentValue;\n }\n\n function forceRefresh(): void {\n poll();\n }\n\n return { subscribe, getSnapshot, forceRefresh };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASA,kBAAkBA,CAChCC,OAA6B,EAC7BC,UAAkB,EAKlB;EACA,IAAIC,YAA2B;EAC/B,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAa,CAAC;EACvC,IAAIC,UAAiD,GAAG,IAAI;EAE5D,SAASC,MAAMA,CAAA,EAAS;IACtB,KAAK,MAAMC,QAAQ,IAAIJ,SAAS,EAAE;MAChCI,QAAQ,CAAC,CAAC;IACZ;EACF;EAEA,SAASC,IAAIA,CAAA,EAAS;IACpB,IAAI;MACF,MAAMC,MAAM,GAAGT,OAAO,CAAC,CAAC;MACxB,IAAIS,MAAM,YAAYC,OAAO,EAAE;QAC7BD,MAAM,CAACE,IAAI,CAAEC,KAAK,IAAK;UACrBV,YAAY,GAAGU,KAAK;UACpBN,MAAM,CAAC,CAAC;QACV,CAAC,CAAC,CAACO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;MACpB,CAAC,MAAM;QACLX,YAAY,GAAGO,MAAM;QACrBH,MAAM,CAAC,CAAC;MACV;IACF,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;;EAEA;EACA;EACA,IAAI;IACF,MAAMG,MAAM,GAAGT,OAAO,CAAC,CAAC;IACxB,IAAIS,MAAM,YAAYC,OAAO,EAAE;MAC7BD,MAAM,CAACE,IAAI,CAAEC,KAAK,IAAK;QACrBV,YAAY,GAAGU,KAAK;QACpBN,MAAM,CAAC,CA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