@delmaredigital/payload-experiments 0.4.0-rc.3 → 0.4.0-rc.5
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/dist/admin/LayerUsage.js +1 -1
- package/dist/admin/MetricSourceSelect.js +2 -2
- package/dist/admin/PlacementStatus.js +1 -1
- package/dist/admin/TestsDashboardCards.js +2 -2
- package/dist/admin/TestsNavLink.js +2 -2
- package/dist/admin/blocks/BlockPanel.js +3 -3
- package/dist/admin/blocks/TestBlockField.js +3 -3
- package/dist/admin/blocks/formApi.js +1 -1
- package/dist/admin/blocks/model.js +1 -1
- package/dist/admin/blocks/statusCache.js +1 -1
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +2 -2
- package/dist/admin/copy/blocks.js +3 -2
- package/dist/admin/copy/goals.d.ts +5 -1
- package/dist/admin/copy/goals.js +9 -3
- package/dist/admin/goals/XpGoalField.js +155 -129
- package/dist/admin/goals/xpGoalField.css +2 -3
- package/dist/admin/status.model.js +1 -1
- package/dist/admin/surface/ResultsRoute.d.ts +2 -1
- package/dist/admin/surface/ResultsRoute.js +6 -13
- package/dist/admin/surface/SurfaceShell.js +2 -2
- package/dist/admin/surface/TestsHome.d.ts +1 -1
- package/dist/admin/surface/TestsHome.js +3 -3
- package/dist/admin/surface/TestsSurface.js +2 -2
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -1
- package/dist/admin/surface/goals/GoalForm.js +55 -7
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +4 -4
- package/dist/admin/surface/goals/data.js +2 -2
- package/dist/admin/surface/goals/goals.css +7 -0
- package/dist/admin/surface/goals/goals.model.d.ts +11 -1
- package/dist/admin/surface/goals/goals.model.js +43 -0
- package/dist/admin/surface/home.model.d.ts +1 -1
- package/dist/admin/surface/home.model.js +5 -5
- package/dist/admin/surface/newTest/NewTest.d.ts +1 -1
- package/dist/admin/surface/newTest/NewTest.js +1 -1
- package/dist/admin/surface/newTest/PageWizard.d.ts +1 -1
- package/dist/admin/surface/newTest/PageWizard.js +23 -25
- package/dist/admin/surface/results/ResultsHeader.d.ts +2 -2
- package/dist/admin/surface/results/ResultsHeader.js +22 -15
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +45 -156
- package/dist/admin/views/ExperimentsRootView.js +1 -1
- package/dist/admin/views/TestsNavLinkServer.js +1 -1
- package/dist/admin/views/renderCollectionList.js +1 -1
- package/dist/admin/views/renderTestsSurface.js +1 -1
- package/dist/blocks/placementLocale.d.ts +21 -0
- package/dist/blocks/placementLocale.js +115 -0
- package/dist/collections/experiments/config.js +1 -1
- package/dist/collections/metrics.js +1 -1
- package/dist/db/bulkPlacementRemoval.d.ts +30 -0
- package/dist/db/bulkPlacementRemoval.js +107 -0
- package/dist/db/placements.d.ts +2 -0
- package/dist/db/placements.js +8 -0
- package/dist/endpoints/editorSurface.d.ts +3 -0
- package/dist/endpoints/editorSurface.js +31 -0
- package/dist/endpoints/index.js +28 -1
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fields/xpGoal.js +1 -1
- package/dist/goals/fairness.d.ts +1 -1
- package/dist/goals/fairness.js +1 -1
- package/dist/goals/picker/clickGoalPicker.model.d.ts +8 -1
- package/dist/goals/picker/clickGoalPicker.model.js +20 -2
- package/dist/goals/picker/copy.d.ts +4 -2
- package/dist/goals/picker/copy.js +4 -2
- package/dist/goals/picker/useClickGoalPicker.d.ts +1 -1
- package/dist/goals/picker/useClickGoalPicker.js +4 -2
- package/dist/hooks/blockRemovalRule.d.ts +29 -0
- package/dist/hooks/blockRemovalRule.js +141 -0
- package/dist/hooks/pageGuard.d.ts +24 -2
- package/dist/hooks/pageGuard.js +178 -24
- package/dist/lib/placementPages.d.ts +9 -0
- package/dist/{admin/previewLinks.model.js → lib/placementPages.js} +1 -4
- package/dist/onInit.js +22 -0
- package/dist/plugin.js +2 -1
- package/dist/puck/ExperimentPicker.js +25 -10
- package/dist/puck/copy.d.ts +4 -1
- package/dist/puck/copy.js +4 -1
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +21 -0
- package/dist/puck/editor/ConfigureTestDrawer.js +147 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +11 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +73 -9
- package/dist/puck/editor/EditorControls.d.ts +14 -0
- package/dist/puck/editor/EditorControls.js +99 -0
- package/dist/puck/editor/ExperimentSlotEditor.js +690 -79
- package/dist/puck/editor/LeftoverVersions.d.ts +13 -0
- package/dist/puck/editor/LeftoverVersions.js +115 -0
- package/dist/puck/editor/PlacementNotice.d.ts +8 -0
- package/dist/puck/editor/PlacementNotice.js +22 -0
- package/dist/puck/editor/QuickTestActions.d.ts +3 -0
- package/dist/puck/editor/QuickTestActions.js +50 -0
- package/dist/puck/editor/ResultsReadout.js +8 -5
- package/dist/puck/editor/VersionBuilder.d.ts +20 -6
- package/dist/puck/editor/VersionBuilder.js +80 -50
- package/dist/puck/editor/armWrites.d.ts +3 -1
- package/dist/puck/editor/armWrites.js +2 -1
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -3
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +42 -5
- package/dist/puck/editor/copy.js +43 -6
- package/dist/puck/editor/editor.chrome.css +44 -0
- package/dist/puck/editor/editor.css +68 -0
- package/dist/puck/editor/editor.model.d.ts +14 -0
- package/dist/puck/editor/editor.model.js +58 -1
- package/dist/puck/editor/editorSurface.d.ts +10 -0
- package/dist/puck/editor/editorSurface.js +65 -0
- package/dist/puck/editor/experimentOutlinePlugin.js +96 -28
- package/dist/puck/editor/localPlacements.d.ts +2 -0
- package/dist/puck/editor/localPlacements.js +29 -0
- package/dist/puck/editor/outlineVersion.d.ts +5 -0
- package/dist/puck/editor/outlineVersion.js +36 -0
- package/dist/puck/editor/placementsCache.d.ts +50 -0
- package/dist/puck/editor/placementsCache.js +258 -0
- package/dist/puck/editor/sidebar.d.ts +12 -0
- package/dist/puck/editor/sidebar.js +77 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +14 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +109 -98
- package/dist/puck/experimentSlotField.d.ts +3 -0
- package/dist/puck/experimentSlotField.js +15 -4
- package/dist/{admin → testSurface}/actions/DecideDialog.d.ts +2 -1
- package/dist/{admin → testSurface}/actions/DecideDialog.js +6 -4
- package/dist/{admin → testSurface}/api.js +5 -6
- package/dist/{admin → testSurface}/copy/common.d.ts +3 -1
- package/dist/{admin → testSurface}/copy/common.js +5 -1
- package/dist/{admin → testSurface}/copy/readiness.d.ts +20 -1
- package/dist/{admin → testSurface}/copy/readiness.js +25 -1
- package/dist/{admin → testSurface}/copy/testPage.d.ts +4 -0
- package/dist/{admin → testSurface}/copy/testPage.js +8 -2
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/{admin → testSurface}/placements/placementLabels.js +1 -1
- package/dist/{admin → testSurface}/previewLinks.model.d.ts +1 -6
- package/dist/testSurface/previewLinks.model.js +4 -0
- package/dist/testSurface/readPreflight.d.ts +9 -0
- package/dist/testSurface/readPreflight.js +38 -0
- package/dist/testSurface/readinessRead.d.ts +50 -0
- package/dist/testSurface/readinessRead.js +46 -0
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/surface/contracts.d.ts +7 -2
- package/dist/testSurface/surface/editorPlacement.d.ts +21 -0
- package/dist/testSurface/surface/editorPlacement.js +60 -0
- package/dist/{admin → testSurface}/surface/pageBlock/parts.js +19 -9
- package/dist/testSurface/surface/pagePicker/pagePicker.css +10 -0
- package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.js +37 -7
- package/dist/testSurface/surface/readiness/Banner.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/readiness/Banner.js +106 -68
- package/dist/testSurface/surface/readiness/BlockerList.d.ts +11 -0
- package/dist/testSurface/surface/readiness/BlockerList.js +31 -0
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +9 -0
- package/dist/testSurface/surface/readiness/SaveStatus.js +66 -0
- package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -2
- package/dist/{admin → testSurface}/surface/readiness/readiness.model.d.ts +13 -0
- package/dist/{admin → testSurface}/surface/readiness/readiness.model.js +51 -36
- package/dist/{admin → testSurface}/surface/readiness/useTransition.d.ts +5 -2
- package/dist/testSurface/surface/readiness/useTransition.js +98 -0
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +2 -2
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +18 -11
- package/dist/testSurface/surface/setting/setting.css +17 -0
- package/dist/{admin → testSurface}/surface/test/AdvancedSection.js +1 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/test/GoalSection.js +4 -2
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +2 -1
- package/dist/{admin → testSurface}/surface/test/Rail.js +7 -4
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +1 -2
- package/dist/{admin → testSurface}/surface/test/Section.d.ts +3 -1
- package/dist/testSurface/surface/test/Section.js +80 -0
- package/dist/{admin → testSurface}/surface/test/TargetingSection.js +5 -0
- package/dist/testSurface/surface/test/TestSurface.d.ts +19 -0
- package/dist/testSurface/surface/test/TestSurface.js +213 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/{admin → testSurface}/surface/test/VersionsSection.js +13 -6
- package/dist/testSurface/surface/test/testPage.css +104 -0
- package/dist/{admin → testSurface}/surface/useTestDocument.d.ts +9 -2
- package/dist/{admin → testSurface}/surface/useTestDocument.js +92 -46
- package/dist/{admin → testSurface}/surfaceUrls.js +1 -1
- package/dist/testSurface/useReadinessPolling.d.ts +3 -0
- package/dist/testSurface/useReadinessPolling.js +24 -0
- package/dist/transitions/placementInteractions.js +1 -1
- package/dist/transitions/placements.d.ts +27 -8
- package/dist/transitions/placements.js +77 -6
- package/dist/transitions/preflightData.js +1 -1
- package/dist/transitions/start.js +2 -2
- package/dist/types/endpoints.d.ts +1 -1
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- package/dist/ui/Dialog.d.ts +4 -1
- package/dist/ui/Dialog.js +41 -3
- package/dist/ui/Drawer.d.ts +10 -0
- package/dist/ui/Drawer.js +29 -0
- package/dist/ui/Tabs.d.ts +4 -3
- package/dist/ui/Tabs.js +47 -32
- package/dist/ui/ui.css +24 -0
- package/package.json +1 -1
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -19
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- package/dist/admin/results/results.css +0 -64
- package/dist/admin/styles.css +0 -10
- package/dist/admin/styles.d.ts +0 -2
- package/dist/admin/styles.js +0 -3
- package/dist/admin/surface/pagePicker/pagePicker.css +0 -10
- package/dist/admin/surface/readiness/Banner.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.js +0 -53
- package/dist/admin/surface/readiness/useTransition.js +0 -35
- package/dist/admin/surface/setting/setting.css +0 -17
- package/dist/admin/surface/test/GoalSection.d.ts +0 -2
- package/dist/admin/surface/test/LengthSection.d.ts +0 -2
- package/dist/admin/surface/test/Section.js +0 -48
- package/dist/admin/surface/test/VersionsSection.d.ts +0 -4
- package/dist/admin/surface/test/testPage.css +0 -92
- /package/dist/{admin → testSurface}/PreviewLinks.d.ts +0 -0
- /package/dist/{admin → testSurface}/PreviewLinks.js +0 -0
- /package/dist/{admin → testSurface}/actions/MakeContentResult.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/MakeContentResult.js +0 -0
- /package/dist/{admin → testSurface}/actions/actions.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/actions.model.js +0 -0
- /package/dist/{admin → testSurface}/actions/decide.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/decide.model.js +0 -0
- /package/dist/{admin → testSurface}/allocation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/allocation.model.js +0 -0
- /package/dist/{admin → testSurface}/api.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.js +0 -0
- /package/dist/{admin → testSurface}/copy/actions.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/actions.js +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.js +0 -0
- /package/dist/{admin → testSurface}/copy/arms.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/arms.js +0 -0
- /package/dist/{admin → testSurface}/copy/audience.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/audience.js +0 -0
- /package/dist/{admin → testSurface}/copy/metrics.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/metrics.js +0 -0
- /package/dist/{admin → testSurface}/copy/pages.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/pages.js +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.js +0 -0
- /package/dist/{admin → testSurface}/copy/results.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/results.js +0 -0
- /package/dist/{admin → testSurface}/copy/review.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/review.js +0 -0
- /package/dist/{admin → testSurface}/copy/setting.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/setting.js +0 -0
- /package/dist/{admin → testSurface}/copy/surface.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/surface.js +0 -0
- /package/dist/{admin → testSurface}/format/date.d.ts +0 -0
- /package/dist/{admin → testSurface}/format/date.js +0 -0
- /package/dist/{admin → testSurface}/labels.d.ts +0 -0
- /package/dist/{admin → testSurface}/labels.js +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.js +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.js +0 -0
- /package/dist/{admin → testSurface}/reload.d.ts +0 -0
- /package/dist/{admin → testSurface}/reload.js +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.js +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.js +0 -0
- /package/dist/{admin → testSurface}/results/DataQualityPanel.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataQualityPanel.js +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.js +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.js +0 -0
- /package/dist/{admin → testSurface}/results/VerdictHero.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/VerdictHero.js +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.js +0 -0
- /package/dist/{admin → testSurface}/results/format.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/format.js +0 -0
- /package/dist/{admin → testSurface}/results/legacy.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/legacy.js +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.js +0 -0
- /package/dist/{admin → testSurface}/results/results.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/results.model.js +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.js +0 -0
- /package/dist/{admin → testSurface}/review/review.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/review/review.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/contracts.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/CopyRoute.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/CopyRoute.js +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/PageCombobox.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/PageCombobox.js +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/ReleasePages.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/ReleasePages.js +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/results/useResults.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/useResults.js +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.js +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/AdvancedSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/PageHoldout.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/PageHoldout.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/Rail.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/fields.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/fields.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/jumpToSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/jumpToSection.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/pageParts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/pageParts.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/testPage.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/testPage.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/testDocument.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/testDocument.model.js +0 -0
- /package/dist/{admin → testSurface}/surfaceUrls.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.js +0 -0
- /package/dist/{admin → testSurface}/theme.d.ts +0 -0
- /package/dist/{admin → testSurface}/theme.js +0 -0
- /package/dist/{admin → testSurface}/useApi.d.ts +0 -0
- /package/dist/{admin → testSurface}/useApi.js +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
3
|
-
import { createUsePuck, walkTree } from '@puckeditor/core';
|
|
4
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createUsePuck, useGetPuck, walkTree } from '@puckeditor/core';
|
|
4
|
+
import { useId, useLayoutEffect, useMemo, useRef } from 'react';
|
|
5
5
|
import { EXPERIMENT_SLOT_TYPE } from '../../types/puck.js';
|
|
6
|
+
import { slotLabels } from '../copy.js';
|
|
7
|
+
import { useOutlineVersion } from './outlineVersion.js';
|
|
6
8
|
import { useArms } from './armsCache.js';
|
|
7
9
|
const usePuckSelector = createUsePuck();
|
|
8
10
|
const slots = [
|
|
@@ -11,35 +13,93 @@ const slots = [
|
|
|
11
13
|
'variantB',
|
|
12
14
|
'variantC'
|
|
13
15
|
];
|
|
14
|
-
// Puck 0.24.0
|
|
15
|
-
//
|
|
16
|
+
// Puck 0.24.0: defaultSlots prepends in field order (chunk-H65MT2JK:15–18),
|
|
17
|
+
// getZonesByParent/buildLayerNode preserve zone order (chunk-DQXMVPVM:8577–8622),
|
|
18
|
+
// and Layer maps it to direct wrappers (8126–8135). Never rely on a module hash.
|
|
16
19
|
const zone = 'div[class*="Layer-zones"]';
|
|
17
20
|
const chain = (count)=>Array(count).fill(zone).join(' ~ ');
|
|
18
|
-
function SlotRules({ item: [id, testId, emptySlots] }) {
|
|
21
|
+
/** Read Puck's DOM only; the plugin owns the wrapper and the emitted style. */ function SlotRules({ item: [id, testId, emptySlots], root, scope }) {
|
|
19
22
|
const known = useArms(testId ?? undefined);
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
const active = useOutlineVersion(useGetPuck(), id);
|
|
24
|
+
const dragging = usePuckSelector((state)=>state.appState.ui?.isDragging ?? false);
|
|
25
|
+
const fixedHidden = useRef([]);
|
|
26
|
+
const style = useRef(null);
|
|
27
|
+
useLayoutEffect(()=>{
|
|
28
|
+
const ownedStyle = style.current;
|
|
29
|
+
const host = root.current ?? ownedStyle?.parentElement;
|
|
30
|
+
if (!host || !ownedStyle || typeof CSS === 'undefined' || typeof CSS.escape !== 'function') return;
|
|
31
|
+
const rowSelector = `[data-xp-outline-scope="${CSS.escape(scope)}"] li[data-puck-layer-tree-id="${CSS.escape(id)}"]`;
|
|
32
|
+
const update = ()=>{
|
|
33
|
+
const rows = [
|
|
34
|
+
...host.querySelectorAll(`li[data-puck-layer-tree-id="${CSS.escape(id)}"]`)
|
|
35
|
+
];
|
|
36
|
+
const row = rows.length === 1 ? rows[0] : undefined;
|
|
37
|
+
const zones = row ? [
|
|
38
|
+
...row.children
|
|
39
|
+
].filter((child)=>child.matches(zone)) : [];
|
|
40
|
+
// Exact count and static field labels guard sibling position, including after
|
|
41
|
+
// a Puck upgrade, a host override, collapse/expand, reorder or virtualization.
|
|
42
|
+
const valid = !!row && zones.length === slots.length && [
|
|
43
|
+
...row.children
|
|
44
|
+
].filter((child)=>child.matches('div[class*="Layer-inner"]')).length === 1 && [
|
|
45
|
+
...row.children
|
|
46
|
+
].every((child)=>child.matches(`${zone}, div[class*="Layer-inner"], div[class*="DropLine"]`)) && zones.every((child, index)=>{
|
|
47
|
+
const label = child.firstElementChild;
|
|
48
|
+
const list = label?.nextElementSibling;
|
|
49
|
+
return label?.matches('div[class*="LayerTree-zoneTitle"]') && label.textContent?.trim() === slotLabels[slots[index]] && list?.matches('ul[class*="LayerTree"]') && !list.nextElementSibling;
|
|
50
|
+
});
|
|
51
|
+
const unknown = testId !== null && !known;
|
|
52
|
+
// A drag's collision shapes were measured before it began. Never hide a
|
|
53
|
+
// previously visible target mid-drag; apply the new tab after it finishes.
|
|
54
|
+
if (!valid || unknown) fixedHidden.current = [];
|
|
55
|
+
else if (!dragging) fixedHidden.current = slots.filter((slot, index)=>testId !== null && active ? slot !== active : slot !== active && slot !== 'control' && !known?.arms.includes(slot) && emptySlots[index]);
|
|
56
|
+
const rules = !valid || unknown ? '' : slots.flatMap((slot, index)=>{
|
|
57
|
+
// No canvas tab is mounted: retain the existing empty-unused-slot behavior.
|
|
58
|
+
if (!fixedHidden.current.includes(slot)) return [];
|
|
59
|
+
// The count guard also disables the rule synchronously if wrappers change.
|
|
60
|
+
const guard = `:has(> ${chain(slots.length)}):not(:has(> ${chain(slots.length + 1)}))`;
|
|
61
|
+
const selector = `${rowSelector}${guard} > ${chain(index + 1)}:not(${chain(index + 2)})`;
|
|
62
|
+
// Hidden descendants have no pointer hit area, including zone drop targets.
|
|
63
|
+
return [
|
|
64
|
+
`${selector} { display: none; pointer-events: none; }`
|
|
65
|
+
];
|
|
66
|
+
}).join('\n');
|
|
67
|
+
if (ownedStyle.textContent !== rules) ownedStyle.textContent = rules;
|
|
68
|
+
};
|
|
69
|
+
update();
|
|
70
|
+
const observer = new MutationObserver(update);
|
|
71
|
+
observer.observe(host, {
|
|
72
|
+
childList: true,
|
|
73
|
+
subtree: true,
|
|
74
|
+
characterData: true,
|
|
75
|
+
attributes: true,
|
|
76
|
+
attributeFilter: [
|
|
77
|
+
'class',
|
|
78
|
+
'data-puck-layer-tree-id'
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
return ()=>{
|
|
82
|
+
observer.disconnect();
|
|
83
|
+
ownedStyle.textContent = '';
|
|
84
|
+
};
|
|
85
|
+
}, [
|
|
86
|
+
id,
|
|
87
|
+
testId,
|
|
88
|
+
emptySlots,
|
|
89
|
+
known,
|
|
90
|
+
active,
|
|
91
|
+
dragging,
|
|
92
|
+
root,
|
|
93
|
+
scope
|
|
94
|
+
]);
|
|
37
95
|
return /*#__PURE__*/ _jsx("style", {
|
|
38
|
-
|
|
39
|
-
|
|
96
|
+
ref: style,
|
|
97
|
+
"data-xp-outline": id
|
|
40
98
|
});
|
|
41
99
|
}
|
|
42
100
|
function ExperimentOutline({ children }) {
|
|
101
|
+
const root = useRef(null);
|
|
102
|
+
const scope = useId();
|
|
43
103
|
// Public selector API in Puck 0.24, rather than the deprecated usePuck hook.
|
|
44
104
|
const key = usePuckSelector((state)=>{
|
|
45
105
|
const { data } = state.appState;
|
|
@@ -68,11 +128,19 @@ function ExperimentOutline({ children }) {
|
|
|
68
128
|
});
|
|
69
129
|
// Only binding/emptiness changes rebuild the rules, not edits to other page fields.
|
|
70
130
|
const rules = useMemo(()=>JSON.parse(key).map((item)=>/*#__PURE__*/ _jsx(SlotRules, {
|
|
71
|
-
item: item
|
|
131
|
+
item: item,
|
|
132
|
+
root: root,
|
|
133
|
+
scope: scope
|
|
72
134
|
}, item[0])), [
|
|
73
|
-
key
|
|
135
|
+
key,
|
|
136
|
+
scope
|
|
74
137
|
]);
|
|
75
|
-
return /*#__PURE__*/ _jsxs(
|
|
138
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
139
|
+
ref: root,
|
|
140
|
+
"data-xp-outline-scope": scope,
|
|
141
|
+
style: {
|
|
142
|
+
display: 'contents'
|
|
143
|
+
},
|
|
76
144
|
children: [
|
|
77
145
|
children,
|
|
78
146
|
rules
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { walkTree } from '@puckeditor/core';
|
|
2
|
+
// Puck data/config are immutable. Selection, hover and drag state reuse this
|
|
3
|
+
// result, and every block on the page shares a single traversal per data change.
|
|
4
|
+
const pages = new WeakMap();
|
|
5
|
+
export function localPlacements(data, config) {
|
|
6
|
+
let configs = pages.get(data);
|
|
7
|
+
if (!configs) {
|
|
8
|
+
configs = new WeakMap();
|
|
9
|
+
pages.set(data, configs);
|
|
10
|
+
}
|
|
11
|
+
let placements = configs.get(config);
|
|
12
|
+
if (!placements) {
|
|
13
|
+
placements = new Map();
|
|
14
|
+
const collect = (content)=>{
|
|
15
|
+
for (const item of content)if (item.type === 'ExperimentSlot' && item.props.experiment?.id !== undefined) {
|
|
16
|
+
const key = String(item.props.experiment.id);
|
|
17
|
+
const ids = placements.get(key) ?? new Set();
|
|
18
|
+
ids.add(item.props.id);
|
|
19
|
+
placements.set(key, ids);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
walkTree(data, config, (content)=>{
|
|
23
|
+
collect(content);
|
|
24
|
+
});
|
|
25
|
+
for (const content of Object.values(data.zones ?? {}))collect(content);
|
|
26
|
+
configs.set(config, placements);
|
|
27
|
+
}
|
|
28
|
+
return placements;
|
|
29
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ArmSlot } from '../../types/puck.js';
|
|
2
|
+
type Editor = object;
|
|
3
|
+
export declare function publishOutlineVersion(editor: Editor, id: string, slot?: ArmSlot): void;
|
|
4
|
+
export declare function useOutlineVersion(editor: Editor, id: string): ArmSlot | undefined;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react';
|
|
2
|
+
const editors = new WeakMap();
|
|
3
|
+
function entryFor(editor, id) {
|
|
4
|
+
let entries = editors.get(editor);
|
|
5
|
+
if (!entries) {
|
|
6
|
+
entries = new Map();
|
|
7
|
+
editors.set(editor, entries);
|
|
8
|
+
}
|
|
9
|
+
let entry = entries.get(id);
|
|
10
|
+
if (!entry) {
|
|
11
|
+
const listeners = new Set();
|
|
12
|
+
entry = {
|
|
13
|
+
listeners,
|
|
14
|
+
removeListener: (notify)=>{
|
|
15
|
+
listeners.delete(notify);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
entries.set(id, entry);
|
|
19
|
+
}
|
|
20
|
+
return entry;
|
|
21
|
+
}
|
|
22
|
+
export function publishOutlineVersion(editor, id, slot) {
|
|
23
|
+
const entry = entryFor(editor, id);
|
|
24
|
+
if (entry.slot === slot) return;
|
|
25
|
+
entry.slot = slot;
|
|
26
|
+
for (const notify of entry.listeners)notify();
|
|
27
|
+
}
|
|
28
|
+
export function useOutlineVersion(editor, id) {
|
|
29
|
+
const entry = entryFor(editor, id);
|
|
30
|
+
return useSyncExternalStore((notify)=>{
|
|
31
|
+
entry.listeners.add(notify);
|
|
32
|
+
return ()=>{
|
|
33
|
+
entry.removeListener(notify);
|
|
34
|
+
};
|
|
35
|
+
}, ()=>entry.slot, ()=>undefined);
|
|
36
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { DocId } from '../../types/contracts.js';
|
|
2
|
+
import type { PreflightResult } from '../../types/endpoints.js';
|
|
3
|
+
type Placements = PreflightResult['placements'];
|
|
4
|
+
/** Share mounted reads, but destructive actions always bypass settled cached knowledge. */
|
|
5
|
+
export declare function refreshPlacements(api: string, id: DocId): Promise<{
|
|
6
|
+
collection: string;
|
|
7
|
+
id: DocId;
|
|
8
|
+
title: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
editorUrl?: string;
|
|
11
|
+
slots?: Record<import("../../types/puck.js").ArmSlot, number>;
|
|
12
|
+
ok: boolean;
|
|
13
|
+
detail?: string;
|
|
14
|
+
}[] | undefined>;
|
|
15
|
+
/** Focus storms share the last attempt (including polling), at most once per ten seconds. */
|
|
16
|
+
export declare function focusPlacements(api: string, id: DocId): Promise<{
|
|
17
|
+
collection: string;
|
|
18
|
+
id: DocId;
|
|
19
|
+
title: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
editorUrl?: string;
|
|
22
|
+
slots?: Record<import("../../types/puck.js").ArmSlot, number>;
|
|
23
|
+
ok: boolean;
|
|
24
|
+
detail?: string;
|
|
25
|
+
}[] | undefined>;
|
|
26
|
+
export declare function invalidatePlacements(api: string, id: DocId): void;
|
|
27
|
+
/** Listen without starting a request; the drawer already owns its initial preflight. */
|
|
28
|
+
export declare function subscribePlacements(api: string, id: DocId, notify: (placements: Placements | undefined) => void): () => void;
|
|
29
|
+
export declare function acquirePlacements(api: string, id: DocId, notify: (placements: Placements | undefined) => void, fresh?: boolean): () => void;
|
|
30
|
+
/** Drawer preflight uses this same producer and follows a superseding post-write read. */
|
|
31
|
+
export declare function readEditorPreflight(api: string, id: DocId, signal: AbortSignal, supersede?: boolean): Promise<Response>;
|
|
32
|
+
/** Current readiness shares the same request and lifetime as placements. */
|
|
33
|
+
export declare function cachedPreflight(api: string, id: DocId): PreflightResult | undefined;
|
|
34
|
+
/** Mandatory post-write/refusal reads guard Start in every shared consumer. */
|
|
35
|
+
export declare function placementsBlocking(api: string, id: DocId): boolean;
|
|
36
|
+
export declare function placementsPending(api: string, id: DocId): boolean;
|
|
37
|
+
/** Pending reads retain the complete settled classification, including terminal outcomes. */
|
|
38
|
+
export declare function cachedReadinessRead(api: string, id: DocId): {
|
|
39
|
+
status: number;
|
|
40
|
+
loadState: "forbidden" | "error" | "missing" | "ready";
|
|
41
|
+
kind: string;
|
|
42
|
+
answer: PreflightResult | undefined;
|
|
43
|
+
message: "Couldn't check where this test is used. Try again." | "You don't have permission to check where this test is used." | "A page used by this test no longer exists. Choose another page." | "This test's setup couldn't be checked." | "Couldn't check readiness. Try again." | "This test no longer exists." | "This isn't available yet." | "Your session has expired. Sign in again." | "Couldn't load this test. Try selecting it again." | "You don't have access to this test." | "Couldn't load this test." | "You don't have access to this test. You can still edit its content." | "This test isn't available to you. You can still edit its content." | "You can view this test's results." | undefined;
|
|
44
|
+
failed: boolean;
|
|
45
|
+
retry: boolean;
|
|
46
|
+
pollDelay: number | null;
|
|
47
|
+
} | undefined;
|
|
48
|
+
export declare function placementReadError(api: string, id: DocId): string | undefined;
|
|
49
|
+
export declare function watchPlacementNotice(api: string, id: DocId, doc: Document): () => void;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { isPreflightResult, readPreflight } from '../../testSurface/readPreflight.js';
|
|
2
|
+
import { classifyReadinessRead } from '../../testSurface/readinessRead.js';
|
|
3
|
+
const cache = new Map();
|
|
4
|
+
const latest = new Map();
|
|
5
|
+
const consumers = new Map();
|
|
6
|
+
const keyFor = (api, id)=>JSON.stringify([
|
|
7
|
+
api,
|
|
8
|
+
String(id)
|
|
9
|
+
]);
|
|
10
|
+
function read(api, id, fresh, blocking = false) {
|
|
11
|
+
const key = keyFor(api, id);
|
|
12
|
+
const cached = cache.get(key);
|
|
13
|
+
if (cached && (!fresh || cached.pending)) return cached;
|
|
14
|
+
const controller = new AbortController();
|
|
15
|
+
const previous = latest.get(key);
|
|
16
|
+
const entry = {
|
|
17
|
+
controller,
|
|
18
|
+
pending: true,
|
|
19
|
+
blocking,
|
|
20
|
+
startedAt: Date.now(),
|
|
21
|
+
failures: previous?.failures ?? 0,
|
|
22
|
+
value: previous?.value,
|
|
23
|
+
previousPreflight: previous?.preflight ?? (previous?.pending ? previous.previousPreflight : undefined),
|
|
24
|
+
previousRead: previous?.read ?? previous?.previousRead,
|
|
25
|
+
promise: undefined
|
|
26
|
+
};
|
|
27
|
+
cache.set(key, entry);
|
|
28
|
+
latest.set(key, entry);
|
|
29
|
+
for (const notify of consumers.get(key)?.listeners ?? [])notify(entry.value);
|
|
30
|
+
entry.promise = (async ()=>{
|
|
31
|
+
try {
|
|
32
|
+
const { response, body: data } = await readPreflight((signal)=>fetch(`${api}/xp/experiments/${encodeURIComponent(id)}/preflight`, {
|
|
33
|
+
credentials: 'include',
|
|
34
|
+
cache: 'no-store',
|
|
35
|
+
signal
|
|
36
|
+
}), controller.signal);
|
|
37
|
+
entry.read = classifyReadinessRead(response.status, data, entry.failures + 1, {
|
|
38
|
+
kind: 'where-used'
|
|
39
|
+
});
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
entry.response = new Response(JSON.stringify(data), {
|
|
42
|
+
status: response.status,
|
|
43
|
+
headers: response.headers
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!isPreflightResult(data)) return;
|
|
48
|
+
entry.preflight = data;
|
|
49
|
+
if (data.checks?.some((check)=>!check.ok && check.code === 'no-placements' && check.detail !== undefined)) return;
|
|
50
|
+
return Array.isArray(data.placements) ? data.placements : undefined;
|
|
51
|
+
} catch {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
})().then((placements)=>{
|
|
55
|
+
entry.pending = false;
|
|
56
|
+
entry.read ??= classifyReadinessRead(0, undefined, entry.failures + 1, {
|
|
57
|
+
kind: 'where-used'
|
|
58
|
+
});
|
|
59
|
+
entry.failures = entry.read.failed ? entry.failures + 1 : 0;
|
|
60
|
+
entry.value = placements;
|
|
61
|
+
if (cache.get(key) === entry) {
|
|
62
|
+
if (!entry.preflight) cache.delete(key);
|
|
63
|
+
for (const notify of consumers.get(key)?.listeners ?? [])notify(placements);
|
|
64
|
+
}
|
|
65
|
+
return placements;
|
|
66
|
+
});
|
|
67
|
+
return entry;
|
|
68
|
+
}
|
|
69
|
+
/** Share mounted reads, but destructive actions always bypass settled cached knowledge. */ export function refreshPlacements(api, id) {
|
|
70
|
+
return read(api, id, true).promise;
|
|
71
|
+
}
|
|
72
|
+
/** Focus storms share the last attempt (including polling), at most once per ten seconds. */ export function focusPlacements(api, id) {
|
|
73
|
+
const previous = latest.get(keyFor(api, id));
|
|
74
|
+
if (previous && Date.now() - previous.startedAt < 10_000) return previous.promise;
|
|
75
|
+
return read(api, id, true).promise;
|
|
76
|
+
}
|
|
77
|
+
export function invalidatePlacements(api, id) {
|
|
78
|
+
const key = keyFor(api, id);
|
|
79
|
+
cache.get(key)?.controller.abort();
|
|
80
|
+
cache.delete(key);
|
|
81
|
+
if (consumers.get(key)?.listeners.size) void read(api, id, true, true).promise;
|
|
82
|
+
else latest.delete(key);
|
|
83
|
+
}
|
|
84
|
+
/** Listen without starting a request; the drawer already owns its initial preflight. */ export function subscribePlacements(api, id, notify) {
|
|
85
|
+
const key = keyFor(api, id);
|
|
86
|
+
let group = consumers.get(key);
|
|
87
|
+
if (!group) {
|
|
88
|
+
const listeners = new Set();
|
|
89
|
+
group = {
|
|
90
|
+
listeners,
|
|
91
|
+
removeListener: (notify)=>{
|
|
92
|
+
listeners.delete(notify);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
consumers.set(key, group);
|
|
96
|
+
}
|
|
97
|
+
const current = group;
|
|
98
|
+
current.listeners.add(notify);
|
|
99
|
+
let listening = true;
|
|
100
|
+
return ()=>{
|
|
101
|
+
if (!listening) return;
|
|
102
|
+
listening = false;
|
|
103
|
+
current.removeListener(notify);
|
|
104
|
+
if (!current.listeners.size && consumers.get(key) === current) {
|
|
105
|
+
consumers.delete(key);
|
|
106
|
+
latest.delete(key);
|
|
107
|
+
cache.get(key)?.controller.abort();
|
|
108
|
+
cache.delete(key);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export function acquirePlacements(api, id, notify, fresh = false) {
|
|
113
|
+
const release = subscribePlacements(api, id, notify);
|
|
114
|
+
const key = keyFor(api, id);
|
|
115
|
+
const entry = read(api, id, fresh);
|
|
116
|
+
if (entry.value !== undefined) notify(entry.value);
|
|
117
|
+
let active = true;
|
|
118
|
+
void entry.promise.then(()=>{
|
|
119
|
+
if (active && cache.get(key) === entry) notify(entry.value);
|
|
120
|
+
});
|
|
121
|
+
return ()=>{
|
|
122
|
+
active = false;
|
|
123
|
+
release();
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/** Drawer preflight uses this same producer and follows a superseding post-write read. */ export async function readEditorPreflight(api, id, signal, supersede = false) {
|
|
127
|
+
if (signal.aborted) return new Response(null, {
|
|
128
|
+
status: 503
|
|
129
|
+
});
|
|
130
|
+
const release = subscribePlacements(api, id, ()=>{});
|
|
131
|
+
signal.addEventListener('abort', release, {
|
|
132
|
+
once: true
|
|
133
|
+
});
|
|
134
|
+
try {
|
|
135
|
+
if (supersede) invalidatePlacements(api, id);
|
|
136
|
+
const previous = latest.get(keyFor(api, id));
|
|
137
|
+
let entry = previous && Date.now() - previous.startedAt < 10_000 ? previous : read(api, id, true);
|
|
138
|
+
while(!signal.aborted){
|
|
139
|
+
await entry.promise;
|
|
140
|
+
if (signal.aborted) return new Response(null, {
|
|
141
|
+
status: 503
|
|
142
|
+
});
|
|
143
|
+
const current = latest.get(keyFor(api, id));
|
|
144
|
+
if (current && current !== entry) {
|
|
145
|
+
entry = current;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
return entry.preflight ? Response.json(entry.preflight) : entry.response?.clone() ?? new Response(null, {
|
|
149
|
+
status: 503
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return new Response(null, {
|
|
153
|
+
status: 503
|
|
154
|
+
});
|
|
155
|
+
} finally{
|
|
156
|
+
signal.removeEventListener('abort', release);
|
|
157
|
+
release();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** Current readiness shares the same request and lifetime as placements. */ export function cachedPreflight(api, id) {
|
|
161
|
+
const entry = latest.get(keyFor(api, id));
|
|
162
|
+
return entry?.preflight ?? (entry?.pending ? entry.previousPreflight : undefined);
|
|
163
|
+
}
|
|
164
|
+
/** Mandatory post-write/refusal reads guard Start in every shared consumer. */ export function placementsBlocking(api, id) {
|
|
165
|
+
const entry = cache.get(keyFor(api, id));
|
|
166
|
+
return entry?.pending === true && entry.blocking;
|
|
167
|
+
}
|
|
168
|
+
export function placementsPending(api, id) {
|
|
169
|
+
return cache.get(keyFor(api, id))?.pending === true;
|
|
170
|
+
}
|
|
171
|
+
/** Pending reads retain the complete settled classification, including terminal outcomes. */ export function cachedReadinessRead(api, id) {
|
|
172
|
+
const entry = latest.get(keyFor(api, id));
|
|
173
|
+
return entry?.pending ? entry.previousRead : entry?.read;
|
|
174
|
+
}
|
|
175
|
+
export function placementReadError(api, id) {
|
|
176
|
+
return cachedReadinessRead(api, id)?.message;
|
|
177
|
+
}
|
|
178
|
+
const notices = new WeakMap();
|
|
179
|
+
const noticeDelay = (api, id)=>cachedReadinessRead(api, id)?.pollDelay ?? null;
|
|
180
|
+
export function watchPlacementNotice(api, id, doc) {
|
|
181
|
+
let session = notices.get(doc);
|
|
182
|
+
if (!session) {
|
|
183
|
+
const requests = new Map();
|
|
184
|
+
const created = {
|
|
185
|
+
requests,
|
|
186
|
+
removeRequest: (key)=>{
|
|
187
|
+
requests.delete(key);
|
|
188
|
+
},
|
|
189
|
+
visibility: ()=>{},
|
|
190
|
+
schedule: ()=>{}
|
|
191
|
+
};
|
|
192
|
+
created.schedule = ()=>{
|
|
193
|
+
if (created.timer !== undefined) {
|
|
194
|
+
clearTimeout(created.timer);
|
|
195
|
+
created.timer = undefined;
|
|
196
|
+
}
|
|
197
|
+
const eligible = [
|
|
198
|
+
...created.requests.values()
|
|
199
|
+
].filter((request)=>!request.pending && noticeDelay(request.api, request.id) !== null);
|
|
200
|
+
if (doc.visibilityState !== 'visible' || !eligible.length) return;
|
|
201
|
+
created.timer = setTimeout(()=>{
|
|
202
|
+
created.timer = undefined;
|
|
203
|
+
if (doc.visibilityState !== 'visible') return;
|
|
204
|
+
const due = eligible.filter((request)=>created.requests.get(keyFor(request.api, request.id)) === request && request.nextAt <= Date.now());
|
|
205
|
+
for (const request of due){
|
|
206
|
+
request.pending = true;
|
|
207
|
+
void refreshPlacements(request.api, request.id).then(()=>{
|
|
208
|
+
request.pending = false;
|
|
209
|
+
request.nextAt = Date.now() + (noticeDelay(request.api, request.id) ?? 0);
|
|
210
|
+
if (notices.get(doc) === created) created.schedule();
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
created.schedule();
|
|
214
|
+
}, Math.max(0, Math.min(...eligible.map((request)=>request.nextAt)) - Date.now()));
|
|
215
|
+
};
|
|
216
|
+
created.visibility = ()=>{
|
|
217
|
+
for (const request of created.requests.values())request.nextAt = Date.now() + (noticeDelay(request.api, request.id) ?? 0);
|
|
218
|
+
created.schedule();
|
|
219
|
+
};
|
|
220
|
+
session = created;
|
|
221
|
+
notices.set(doc, session);
|
|
222
|
+
doc.addEventListener('visibilitychange', created.visibility);
|
|
223
|
+
}
|
|
224
|
+
const current = session;
|
|
225
|
+
const key = keyFor(api, id);
|
|
226
|
+
const existing = current.requests.get(key);
|
|
227
|
+
const request = existing ?? {
|
|
228
|
+
api,
|
|
229
|
+
id,
|
|
230
|
+
subscribers: 0,
|
|
231
|
+
nextAt: Date.now() + (noticeDelay(api, id) ?? 0),
|
|
232
|
+
pending: false,
|
|
233
|
+
release: ()=>{}
|
|
234
|
+
};
|
|
235
|
+
request.subscribers++;
|
|
236
|
+
current.requests.set(key, request);
|
|
237
|
+
if (!existing) request.release = subscribePlacements(api, id, ()=>{
|
|
238
|
+
if (placementsPending(api, id)) return;
|
|
239
|
+
// Manual/focus retries also reset the backoff after recovery.
|
|
240
|
+
request.nextAt = Date.now() + (noticeDelay(api, id) ?? 0);
|
|
241
|
+
current.schedule();
|
|
242
|
+
});
|
|
243
|
+
if (!existing || current.timer === undefined) current.schedule();
|
|
244
|
+
let active = true;
|
|
245
|
+
return ()=>{
|
|
246
|
+
if (!active) return;
|
|
247
|
+
active = false;
|
|
248
|
+
if (--request.subscribers === 0) {
|
|
249
|
+
current.removeRequest(key);
|
|
250
|
+
request.release();
|
|
251
|
+
}
|
|
252
|
+
if (!current.requests.size) {
|
|
253
|
+
if (current.timer !== undefined) clearTimeout(current.timer);
|
|
254
|
+
doc.removeEventListener('visibilitychange', current.visibility);
|
|
255
|
+
notices.delete(doc);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ExperimentRef } from '../../types/puck.js';
|
|
2
|
+
type Targets = {
|
|
3
|
+
test: HTMLElement;
|
|
4
|
+
controls: HTMLElement;
|
|
5
|
+
onChange: (value: ExperimentRef | null) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare function useSidebarTargets(id: string): Targets | undefined;
|
|
8
|
+
/** The custom field owns only its portal destinations and binding callback, never another data reader. */
|
|
9
|
+
export declare function TestSidebarField({ onChange }: {
|
|
10
|
+
onChange: (value: ExperimentRef | null) => void;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createUsePuck, useGetPuck } from '@puckeditor/core';
|
|
4
|
+
import { useEffect, useState, useSyncExternalStore, useRef } from 'react';
|
|
5
|
+
const usePuckSelector = createUsePuck();
|
|
6
|
+
// useGetPuck returns the store's stable getState function (Puck 0.24:7223–7228).
|
|
7
|
+
// A WeakMap keeps separate editors (including their iframes) isolated.
|
|
8
|
+
const bridges = new WeakMap();
|
|
9
|
+
function bridge(session) {
|
|
10
|
+
let entry = bridges.get(session);
|
|
11
|
+
if (!entry) {
|
|
12
|
+
const targets = new Map();
|
|
13
|
+
const listeners = new Set();
|
|
14
|
+
entry = {
|
|
15
|
+
targets,
|
|
16
|
+
listeners,
|
|
17
|
+
removeListener: (notify)=>{
|
|
18
|
+
listeners.delete(notify);
|
|
19
|
+
},
|
|
20
|
+
removeTarget: (id)=>{
|
|
21
|
+
targets.delete(id);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
bridges.set(session, entry);
|
|
25
|
+
}
|
|
26
|
+
return entry;
|
|
27
|
+
}
|
|
28
|
+
export function useSidebarTargets(id) {
|
|
29
|
+
const entry = bridge(useGetPuck());
|
|
30
|
+
return useSyncExternalStore((notify)=>{
|
|
31
|
+
entry.listeners.add(notify);
|
|
32
|
+
return ()=>{
|
|
33
|
+
entry.removeListener(notify);
|
|
34
|
+
};
|
|
35
|
+
}, ()=>entry.targets.get(id), ()=>undefined);
|
|
36
|
+
}
|
|
37
|
+
/** The custom field owns only its portal destinations and binding callback, never another data reader. */ export function TestSidebarField({ onChange }) {
|
|
38
|
+
const getPuck = useGetPuck();
|
|
39
|
+
const change = useRef(onChange);
|
|
40
|
+
change.current = onChange;
|
|
41
|
+
const id = usePuckSelector((state)=>state.selectedItem?.props.id);
|
|
42
|
+
const [test, setTest] = useState(null);
|
|
43
|
+
const [controls, setControls] = useState(null);
|
|
44
|
+
useEffect(()=>{
|
|
45
|
+
if (!id || !test || !controls) return;
|
|
46
|
+
const entry = bridge(getPuck);
|
|
47
|
+
const targets = {
|
|
48
|
+
test,
|
|
49
|
+
controls,
|
|
50
|
+
onChange: (value)=>change.current(value)
|
|
51
|
+
};
|
|
52
|
+
entry.targets.set(id, targets);
|
|
53
|
+
for (const notify of entry.listeners)notify();
|
|
54
|
+
return ()=>{
|
|
55
|
+
if (entry.targets.get(id) === targets) entry.removeTarget(id);
|
|
56
|
+
for (const notify of entry.listeners)notify();
|
|
57
|
+
};
|
|
58
|
+
}, [
|
|
59
|
+
id,
|
|
60
|
+
test,
|
|
61
|
+
controls,
|
|
62
|
+
getPuck
|
|
63
|
+
]);
|
|
64
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
65
|
+
className: "xp-slot-root xp-slot-editor xp-puck-field xp-slot-sidebar",
|
|
66
|
+
onClick: (event)=>event.stopPropagation(),
|
|
67
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
68
|
+
children: [
|
|
69
|
+
/*#__PURE__*/ _jsx("div", {
|
|
70
|
+
ref: setTest
|
|
71
|
+
}),
|
|
72
|
+
/*#__PURE__*/ _jsx("div", {
|
|
73
|
+
ref: setControls
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { watchPlacementNotice } from './placementsCache.js';
|
|
4
|
+
/** Subscribe only while save/publish guidance or a retryable placement failure is visible. */ export function usePlacementNotice(api, id, message) {
|
|
5
|
+
const showing = message !== undefined && id !== undefined;
|
|
6
|
+
useEffect(()=>{
|
|
7
|
+
if (id === undefined || !showing) return;
|
|
8
|
+
return watchPlacementNotice(api, id, document);
|
|
9
|
+
}, [
|
|
10
|
+
api,
|
|
11
|
+
id,
|
|
12
|
+
showing
|
|
13
|
+
]);
|
|
14
|
+
}
|