@delmaredigital/payload-experiments 0.3.0-rc.4 → 0.4.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +293 -688
- package/dist/admin/LayerUsage.js +1 -1
- package/dist/admin/MetricSourceSelect.js +4 -4
- package/dist/admin/PlacementStatus.d.ts +3 -0
- package/dist/admin/PlacementStatus.js +54 -0
- package/dist/admin/TestsDashboardCards.d.ts +1 -0
- package/dist/admin/TestsDashboardCards.js +5 -9
- package/dist/admin/TestsNavLink.d.ts +1 -0
- package/dist/admin/TestsNavLink.js +5 -11
- package/dist/admin/blocks/BlockPanel.d.ts +5 -0
- package/dist/admin/blocks/BlockPanel.js +245 -0
- package/dist/admin/blocks/TestBlockField.d.ts +5 -0
- package/dist/admin/blocks/TestBlockField.js +163 -0
- package/dist/admin/blocks/formApi.d.ts +46 -0
- package/dist/admin/blocks/formApi.js +159 -0
- package/dist/admin/blocks/inject.d.ts +7 -0
- package/dist/admin/blocks/inject.js +42 -0
- package/dist/admin/blocks/model.d.ts +18 -0
- package/dist/admin/blocks/model.js +49 -0
- package/dist/admin/blocks/statusCache.d.ts +9 -0
- package/dist/admin/blocks/statusCache.js +92 -0
- package/dist/admin/blocks/useBlockForm.d.ts +17 -0
- package/dist/admin/blocks/useBlockForm.js +46 -0
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +47 -0
- package/dist/admin/copy/blocks.js +72 -0
- package/dist/admin/copy/goals.d.ts +8 -1
- package/dist/admin/copy/goals.js +14 -4
- package/dist/admin/copy/newTest.d.ts +13 -4
- package/dist/admin/copy/newTest.js +16 -4
- package/dist/admin/goals/XpGoalField.d.ts +4 -0
- package/dist/admin/goals/XpGoalField.js +194 -0
- package/dist/admin/goals/xpGoalField.css +47 -0
- package/dist/admin/pageCollections.d.ts +11 -0
- package/dist/admin/pageCollections.js +23 -0
- package/dist/admin/paths.d.ts +9 -0
- package/dist/admin/paths.js +9 -0
- package/dist/admin/placementStatus.model.d.ts +2 -0
- package/dist/admin/placementStatus.model.js +19 -0
- package/dist/admin/status.model.js +1 -1
- package/dist/admin/surface/ResultsRoute.d.ts +2 -1
- package/dist/admin/surface/ResultsRoute.js +20 -24
- package/dist/admin/surface/SurfaceShell.js +5 -2
- package/dist/admin/surface/TestRowMenu.d.ts +6 -0
- package/dist/admin/surface/TestRowMenu.js +156 -0
- package/dist/admin/surface/TestsHome.d.ts +5 -3
- package/dist/admin/surface/TestsHome.js +298 -59
- package/dist/admin/surface/TestsSurface.js +13 -8
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -1
- package/dist/admin/surface/goals/GoalForm.js +159 -85
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +7 -6
- package/dist/admin/surface/goals/data.js +6 -3
- package/dist/admin/surface/goals/goals.css +7 -0
- package/dist/admin/surface/goals/goals.model.d.ts +12 -3
- package/dist/admin/surface/goals/goals.model.js +43 -2
- package/dist/admin/surface/home.model.d.ts +9 -8
- package/dist/admin/surface/home.model.js +28 -23
- package/dist/admin/surface/newTest/NewTest.d.ts +4 -4
- package/dist/admin/surface/newTest/NewTest.js +146 -101
- package/dist/admin/surface/newTest/PageWizard.d.ts +8 -0
- package/dist/admin/surface/newTest/PageWizard.js +244 -0
- package/dist/admin/surface/newTest/newTest.css +28 -9
- package/dist/admin/surface/results/ResultsHeader.d.ts +2 -2
- package/dist/admin/surface/results/ResultsHeader.js +58 -57
- package/dist/admin/surface/surface.css +10 -0
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +42 -161
- package/dist/admin/theme.css +2 -0
- package/dist/admin/views/CollectionListRedirect.d.ts +1 -0
- package/dist/admin/views/CollectionListRedirect.js +1 -1
- package/dist/admin/views/ExperimentsRootView.js +28 -133
- package/dist/admin/views/GoalEditRedirect.d.ts +4 -0
- package/dist/admin/views/GoalEditRedirect.js +14 -0
- package/dist/admin/views/GoalsCollectionListView.d.ts +2 -0
- package/dist/admin/views/GoalsCollectionListView.js +4 -0
- package/dist/admin/views/TestsCollectionListView.d.ts +2 -0
- package/dist/admin/views/TestsCollectionListView.js +4 -0
- package/dist/admin/views/TestsNavLinkServer.d.ts +1 -0
- package/dist/admin/views/TestsNavLinkServer.js +2 -2
- package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
- package/dist/admin/views/TestsSurfaceClient.js +11 -0
- package/dist/admin/views/buildSurfaceProps.d.ts +8 -0
- package/dist/admin/views/buildSurfaceProps.js +102 -0
- package/dist/admin/views/renderCollectionList.d.ts +2 -0
- package/dist/admin/views/renderCollectionList.js +34 -0
- package/dist/admin/views/renderTestsSurface.d.ts +3 -0
- package/dist/admin/views/renderTestsSurface.js +34 -0
- package/dist/blocks/bindings.d.ts +3 -0
- package/dist/blocks/bindings.js +28 -0
- package/dist/blocks/createExperimentBlock.d.ts +6 -0
- package/dist/blocks/createExperimentBlock.js +77 -0
- package/dist/blocks/formState.d.ts +31 -0
- package/dist/blocks/formState.js +146 -0
- package/dist/blocks/model.d.ts +41 -0
- package/dist/blocks/model.js +34 -0
- package/dist/blocks/placementLanguages.d.ts +7 -0
- package/dist/blocks/placementLanguages.js +27 -0
- package/dist/blocks/placementLocale.d.ts +37 -0
- package/dist/blocks/placementLocale.js +270 -0
- package/dist/client/ExperimentGroup.d.ts +6 -0
- package/dist/client/ExperimentGroup.js +9 -0
- package/dist/client/ExperimentsProvider.js +20 -4
- package/dist/client/clickGoals.d.ts +4 -0
- package/dist/client/clickGoals.js +43 -0
- package/dist/collections/experiments/config.js +29 -10
- package/dist/collections/experiments/deleteGuard.d.ts +2 -1
- package/dist/collections/experiments/deleteGuard.js +14 -3
- package/dist/collections/experiments/editability.js +4 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.d.ts +2 -0
- package/dist/collections/experiments/pickSlug.js +10 -0
- package/dist/collections/labels.d.ts +3 -0
- package/dist/collections/labels.js +20 -0
- package/dist/collections/metrics.js +28 -6
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/phases.js +1 -0
- package/dist/collections/serialize.js +12 -4
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/db/adapter.d.ts +9 -1
- package/dist/db/adapter.js +77 -1
- package/dist/db/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.d.ts +30 -0
- package/dist/db/bulkPlacementRemoval.js +111 -0
- package/dist/db/clickGoals.d.ts +9 -0
- package/dist/db/clickGoals.js +22 -0
- package/dist/db/delete.d.ts +2 -1
- package/dist/db/delete.js +3 -4
- package/dist/db/events.d.ts +9 -0
- package/dist/db/events.js +42 -8
- package/dist/db/executor.d.ts +7 -1
- package/dist/db/executor.js +7 -3
- package/dist/db/locks.d.ts +8 -0
- package/dist/db/locks.js +27 -4
- package/dist/db/names.d.ts +4 -0
- package/dist/db/names.js +4 -0
- package/dist/db/pageBindings.d.ts +4 -0
- package/dist/db/pageBindings.js +17 -0
- package/dist/db/pageBusy.d.ts +2 -0
- package/dist/db/pageBusy.js +10 -0
- package/dist/db/pageContent.d.ts +10 -0
- package/dist/db/pageContent.js +79 -0
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/placements.d.ts +35 -0
- package/dist/db/placements.js +62 -0
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/slugs.d.ts +8 -0
- package/dist/db/slugs.js +40 -0
- package/dist/db/snapshots.d.ts +7 -0
- package/dist/db/snapshots.js +8 -5
- package/dist/endpoints/clickKeys.d.ts +5 -0
- package/dist/endpoints/clickKeys.js +17 -0
- package/dist/endpoints/contentLocale.d.ts +6 -0
- package/dist/endpoints/contentLocale.js +15 -0
- package/dist/endpoints/deleteImpact.d.ts +6 -0
- package/dist/endpoints/deleteImpact.js +207 -0
- package/dist/endpoints/duplicateOriginal.d.ts +38 -0
- package/dist/endpoints/duplicateOriginal.js +407 -0
- package/dist/endpoints/editorSurface.d.ts +3 -0
- package/dist/endpoints/editorSurface.js +31 -0
- package/dist/endpoints/events.js +106 -39
- package/dist/endpoints/index.js +85 -9
- package/dist/endpoints/pages.d.ts +5 -0
- package/dist/endpoints/pages.js +303 -0
- package/dist/endpoints/placementStatus.d.ts +6 -0
- package/dist/endpoints/placementStatus.js +246 -0
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/endpoints/readBody.d.ts +2 -0
- package/dist/endpoints/readBody.js +24 -0
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +10 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -5
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +41 -29
- package/dist/endpoints/wrapBlock.d.ts +6 -0
- package/dist/endpoints/wrapBlock.js +76 -0
- package/dist/errors.d.ts +7 -2
- package/dist/errors.js +11 -3
- package/dist/events/request.d.ts +6 -2
- package/dist/events/request.js +35 -8
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +25 -7
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- package/dist/exports/adminClient.d.ts +6 -1
- package/dist/exports/adminClient.js +6 -1
- package/dist/exports/adminRsc.d.ts +3 -0
- package/dist/exports/adminRsc.js +3 -0
- package/dist/exports/blocks.d.ts +2 -0
- package/dist/exports/blocks.js +1 -0
- package/dist/exports/client.d.ts +1 -0
- package/dist/exports/client.js +1 -0
- package/dist/exports/index.d.ts +6 -1
- package/dist/exports/index.js +3 -0
- package/dist/exports/puck.d.ts +3 -1
- package/dist/exports/puck.js +2 -0
- package/dist/exports/puckEditor.d.ts +3 -0
- package/dist/exports/puckEditor.js +2 -0
- package/dist/exports/rsc.d.ts +4 -0
- package/dist/exports/rsc.js +3 -0
- package/dist/fields/xpGoal.d.ts +3 -0
- package/dist/fields/xpGoal.js +16 -0
- package/dist/globals/state.js +10 -0
- package/dist/goals/cache.d.ts +3 -0
- package/dist/goals/cache.js +35 -0
- package/dist/goals/fairness.d.ts +40 -0
- package/dist/goals/fairness.js +209 -0
- package/dist/goals/key.d.ts +4 -0
- package/dist/goals/key.js +3 -0
- package/dist/goals/picker/clickGoalPicker.model.d.ts +36 -0
- package/dist/goals/picker/clickGoalPicker.model.js +63 -0
- package/dist/goals/picker/copy.d.ts +20 -0
- package/dist/goals/picker/copy.js +24 -0
- package/dist/goals/picker/useClickGoalPicker.d.ts +30 -0
- package/dist/goals/picker/useClickGoalPicker.js +222 -0
- package/dist/goals/validate.d.ts +3 -0
- package/dist/goals/validate.js +15 -0
- package/dist/hooks/blockRemovalRule.d.ts +30 -0
- package/dist/hooks/blockRemovalRule.js +165 -0
- package/dist/hooks/hostHook.js +6 -2
- package/dist/hooks/pageGuard.d.ts +30 -1
- package/dist/hooks/pageGuard.js +337 -107
- package/dist/hooks/puckGoals.d.ts +5 -0
- package/dist/hooks/puckGoals.js +62 -0
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- package/dist/hooks/trackPageCopies.d.ts +11 -0
- package/dist/hooks/trackPageCopies.js +7 -0
- package/dist/lib/fetchAllDocs.d.ts +1 -1
- package/dist/lib/placementPages.d.ts +10 -0
- package/dist/{admin/previewLinks.model.js → lib/placementPages.js} +10 -5
- package/dist/manifest/compile.d.ts +2 -1
- package/dist/manifest/compile.js +13 -6
- package/dist/onInit.js +65 -0
- package/dist/options.d.ts +4 -0
- package/dist/options.js +62 -1
- package/dist/plugin.js +56 -44
- package/dist/proxy/pageNavigation.d.ts +4 -0
- package/dist/proxy/pageNavigation.js +28 -0
- package/dist/proxy/resolve.js +52 -25
- package/dist/puck/ExperimentPicker.d.ts +2 -1
- package/dist/puck/ExperimentPicker.js +62 -40
- package/dist/puck/ExperimentSlot.js +3 -1
- package/dist/puck/copy.d.ts +6 -1
- package/dist/puck/copy.js +6 -1
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +25 -0
- package/dist/puck/editor/ConfigureTestDrawer.js +150 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +12 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +89 -21
- package/dist/puck/editor/EditorControls.d.ts +14 -0
- package/dist/puck/editor/EditorControls.js +99 -0
- package/dist/puck/editor/ExperimentSlotEditor.js +951 -179
- package/dist/puck/editor/LeftoverVersions.d.ts +15 -0
- package/dist/puck/editor/LeftoverVersions.js +79 -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 +6 -0
- package/dist/puck/editor/QuickTestActions.js +57 -0
- package/dist/puck/editor/ResultsReadout.d.ts +2 -1
- package/dist/puck/editor/ResultsReadout.js +10 -6
- package/dist/puck/editor/VersionBuilder.d.ts +66 -12
- package/dist/puck/editor/VersionBuilder.js +554 -231
- package/dist/puck/editor/armWrites.d.ts +11 -2
- package/dist/puck/editor/armWrites.js +43 -4
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -4
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +64 -19
- package/dist/puck/editor/copy.js +72 -20
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +192 -19
- package/dist/puck/editor/editor.css +329 -24
- package/dist/puck/editor/editor.model.d.ts +21 -3
- package/dist/puck/editor/editor.model.js +67 -7
- 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/integration.d.ts +10 -0
- package/dist/puck/editor/integration.js +30 -0
- package/dist/puck/editor/localPlacements.d.ts +5 -0
- package/dist/puck/editor/localPlacements.js +43 -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 +60 -0
- package/dist/puck/editor/placementsCache.js +263 -0
- package/dist/puck/editor/sidebar.d.ts +8 -0
- package/dist/puck/editor/sidebar.js +74 -0
- package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
- package/dist/puck/editor/usePageSaveReadiness.js +31 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +15 -0
- package/dist/puck/editor/xpGoalPuckEditorField.d.ts +7 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +153 -0
- package/dist/puck/experimentSlotField.d.ts +3 -0
- package/dist/puck/experimentSlotField.js +15 -4
- package/dist/puck/experimentSlug.d.ts +2 -0
- package/dist/puck/experimentSlug.js +3 -0
- package/dist/puck/integration.d.ts +6 -0
- package/dist/puck/integration.js +21 -0
- package/dist/puck/nestedTestCopy.d.ts +8 -0
- package/dist/puck/nestedTestCopy.js +22 -0
- package/dist/puck/nestedTests.d.ts +17 -0
- package/dist/puck/nestedTests.js +30 -0
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +17 -4
- package/dist/puck/visibility.d.ts +20 -0
- package/dist/puck/visibility.js +81 -0
- package/dist/puck/xpGoalField.d.ts +3 -0
- package/dist/puck/xpGoalField.js +6 -0
- package/dist/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/health.d.ts +12 -0
- package/dist/results/health.js +55 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/snapshot.js +15 -2
- package/dist/results/verdict.js +2 -1
- package/dist/runtime/cookie.d.ts +10 -2
- package/dist/runtime/cookie.js +38 -6
- package/dist/runtime/cookieOptions.d.ts +6 -0
- package/dist/runtime/cookieOptions.js +14 -0
- package/dist/runtime/proxyRuntime.d.ts +1 -0
- package/dist/runtime/proxyRuntime.js +18 -8
- package/dist/runtime/signing.d.ts +1 -0
- package/dist/runtime/signing.js +5 -0
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +63 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/pageKindSeoContract.d.ts +27 -0
- package/dist/server/pageKindSeoContract.js +80 -0
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +88 -12
- package/dist/server/resolveExperimentBlocks.d.ts +5 -0
- package/dist/server/resolveExperimentBlocks.js +52 -0
- package/dist/server/resolveExperimentData.js +8 -8
- package/dist/server/runResults.js +104 -25
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/toClientAssignments.js +2 -1
- package/dist/server/trackConversion.js +10 -13
- package/dist/{admin → testSurface}/PreviewLinks.d.ts +2 -1
- package/dist/{admin → testSurface}/PreviewLinks.js +8 -4
- package/dist/testSurface/actions/DecideDialog.d.ts +16 -0
- package/dist/{admin → testSurface}/actions/DecideDialog.js +79 -56
- package/dist/testSurface/actions/LifecycleAction.d.ts +16 -0
- package/dist/testSurface/actions/LifecycleAction.js +105 -0
- package/dist/{admin → testSurface}/actions/MakeContentResult.d.ts +4 -3
- package/dist/{admin → testSurface}/actions/MakeContentResult.js +10 -2
- package/dist/{admin → testSurface}/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +122 -0
- package/dist/testSurface/api.d.ts +60 -0
- package/dist/testSurface/api.js +167 -0
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/{admin → testSurface}/copy/actions.d.ts +30 -8
- package/dist/{admin → testSurface}/copy/actions.js +40 -11
- package/dist/{admin → testSurface}/copy/common.d.ts +13 -4
- package/dist/{admin → testSurface}/copy/common.js +18 -8
- package/dist/testSurface/copy/languages.d.ts +12 -0
- package/dist/testSurface/copy/languages.js +8 -0
- package/dist/{admin → testSurface}/copy/metrics.d.ts +1 -0
- package/dist/{admin → testSurface}/copy/metrics.js +1 -0
- package/dist/testSurface/copy/pages.d.ts +84 -0
- package/dist/testSurface/copy/pages.js +90 -0
- package/dist/{admin → testSurface}/copy/readiness.d.ts +59 -6
- package/dist/testSurface/copy/readiness.js +136 -0
- package/dist/{admin → testSurface}/copy/results.d.ts +7 -3
- package/dist/{admin → testSurface}/copy/results.js +7 -3
- package/dist/{admin → testSurface}/copy/review.d.ts +1 -1
- package/dist/{admin → testSurface}/copy/review.js +1 -1
- package/dist/{admin → testSurface}/copy/surface.d.ts +11 -2
- package/dist/{admin → testSurface}/copy/surface.js +13 -10
- package/dist/{admin → testSurface}/copy/testPage.d.ts +56 -7
- package/dist/testSurface/copy/testPage.js +165 -0
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/{admin → testSurface}/metricSource.model.d.ts +2 -0
- package/dist/{admin → testSurface}/metricSource.model.js +4 -0
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/testSurface/placements/placementLabels.d.ts +13 -0
- package/dist/testSurface/placements/placementLabels.js +22 -0
- package/dist/testSurface/placements/placementLabels.model.d.ts +13 -0
- package/dist/testSurface/placements/placementLabels.model.js +12 -0
- package/dist/testSurface/placements/usePlacementLabels.d.ts +12 -0
- package/dist/testSurface/placements/usePlacementLabels.js +102 -0
- package/dist/{admin → testSurface}/previewLinks.model.d.ts +1 -6
- package/dist/testSurface/previewLinks.model.js +4 -0
- package/dist/testSurface/readPreflight.d.ts +13 -0
- package/dist/testSurface/readPreflight.js +44 -0
- package/dist/testSurface/readinessRead.d.ts +53 -0
- package/dist/testSurface/readinessRead.js +50 -0
- package/dist/{admin → testSurface}/results/DataQualityPanel.js +4 -1
- package/dist/{admin → testSurface}/results/VerdictHero.d.ts +2 -1
- package/dist/{admin → testSurface}/results/VerdictHero.js +5 -1
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/results/results.model.d.ts +3 -0
- package/dist/{admin → testSurface}/results/results.model.js +14 -6
- package/dist/{admin → testSurface}/surface/contracts.d.ts +23 -8
- package/dist/testSurface/surface/editorPlacement.d.ts +26 -0
- package/dist/testSurface/surface/editorPlacement.js +78 -0
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +9 -0
- package/dist/{admin → testSurface}/surface/pageBlock/parts.js +39 -11
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +13 -0
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +273 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +21 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +503 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +29 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.model.js +40 -0
- package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.d.ts +8 -4
- package/dist/testSurface/surface/readiness/ActionDialogs.js +351 -0
- package/dist/{admin → testSurface}/surface/readiness/Banner.d.ts +2 -3
- package/dist/testSurface/surface/readiness/Banner.js +187 -0
- 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 +10 -0
- package/dist/testSurface/surface/readiness/SaveStatus.js +66 -0
- package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -2
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +57 -0
- package/dist/testSurface/surface/readiness/readiness.model.js +377 -0
- package/dist/testSurface/surface/readiness/useTransition.d.ts +16 -0
- package/dist/testSurface/surface/readiness/useTransition.js +141 -0
- package/dist/testSurface/surface/results/ReleasePages.d.ts +19 -0
- package/dist/{admin → testSurface}/surface/results/ReleasePages.js +43 -47
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +7 -3
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +129 -46
- package/dist/{admin → testSurface}/surface/results/useResults.d.ts +36 -9
- package/dist/{admin → testSurface}/surface/results/useResults.js +3 -2
- package/dist/{admin → testSurface}/surface/setting/parts.js +58 -18
- package/dist/testSurface/surface/setting/setting.css +17 -0
- package/dist/testSurface/surface/test/AdvancedSection.js +169 -0
- package/dist/testSurface/surface/test/DeleteTest.d.ts +23 -0
- package/dist/testSurface/surface/test/DeleteTest.js +270 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/testSurface/surface/test/GoalSection.js +341 -0
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +6 -2
- package/dist/testSurface/surface/test/PageHoldout.d.ts +3 -0
- package/dist/testSurface/surface/test/PageHoldout.js +70 -0
- package/dist/{admin → testSurface}/surface/test/Rail.js +7 -4
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +2 -3
- 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 +82 -12
- package/dist/testSurface/surface/test/TestSurface.d.ts +19 -0
- package/dist/testSurface/surface/test/TestSurface.js +265 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/{admin → testSurface}/surface/test/VersionsSection.js +81 -40
- package/dist/{admin → testSurface}/surface/test/fields.d.ts +40 -8
- package/dist/testSurface/surface/test/fields.js +306 -0
- package/dist/{admin → testSurface}/surface/test/jumpToSection.d.ts +1 -1
- package/dist/{admin → testSurface}/surface/test/jumpToSection.js +4 -3
- package/dist/testSurface/surface/test/pageParts.d.ts +5 -0
- package/dist/testSurface/surface/test/pageParts.js +106 -0
- package/dist/testSurface/surface/test/testPage.css +103 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.js +6 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.js +6 -2
- package/dist/testSurface/surface/useTestDocument.d.ts +60 -0
- package/dist/testSurface/surface/useTestDocument.js +782 -0
- package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
- package/dist/testSurface/surface/watchTestDocument.js +181 -0
- package/dist/testSurface/surfaceUrls.d.ts +7 -0
- package/dist/testSurface/surfaceUrls.js +19 -0
- package/dist/testSurface/useApi.d.ts +60 -0
- package/dist/testSurface/useApi.js +8 -0
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.d.ts +3 -0
- package/dist/testSurface/useReadinessPolling.js +26 -0
- package/dist/transitions/addMetric.d.ts +4 -6
- package/dist/transitions/addMetric.js +33 -2
- package/dist/transitions/allocate.d.ts +2 -2
- package/dist/transitions/allocate.js +3 -1
- package/dist/transitions/archive.d.ts +1 -1
- package/dist/transitions/archive.js +3 -2
- package/dist/transitions/checkStart.d.ts +18 -1
- package/dist/transitions/checkStart.js +207 -9
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +30 -3
- package/dist/transitions/deleteExperiment.d.ts +5 -3
- package/dist/transitions/deleteExperiment.js +43 -7
- package/dist/transitions/kernel.d.ts +4 -0
- package/dist/transitions/kernel.js +13 -4
- package/dist/transitions/makeContent.d.ts +7 -1
- package/dist/transitions/makeContent.js +74 -22
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +32 -0
- package/dist/transitions/pageAddress.d.ts +6 -0
- package/dist/transitions/pageAddress.js +71 -0
- package/dist/transitions/pageCollection.d.ts +10 -0
- package/dist/transitions/pageCollection.js +20 -0
- package/dist/transitions/pageVersions.d.ts +10 -0
- package/dist/transitions/pageVersions.js +46 -0
- package/dist/transitions/phaseRecord.d.ts +3 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +40 -0
- package/dist/transitions/placementInteractions.js +98 -0
- package/dist/transitions/placements.d.ts +58 -4
- package/dist/transitions/placements.js +391 -21
- package/dist/transitions/preflightData.d.ts +7 -5
- package/dist/transitions/preflightData.js +269 -40
- package/dist/transitions/releaseHoldout.d.ts +2 -1
- package/dist/transitions/releaseHoldout.js +3 -1
- package/dist/transitions/releasePages.d.ts +2 -1
- package/dist/transitions/releasePages.js +3 -1
- package/dist/transitions/resolveCaps.d.ts +3 -4
- package/dist/transitions/resolveCaps.js +6 -2
- package/dist/transitions/start.d.ts +6 -8
- package/dist/transitions/start.js +112 -31
- package/dist/transitions/startReads.d.ts +7 -0
- package/dist/transitions/startReads.js +28 -0
- package/dist/transitions/stop.d.ts +2 -1
- package/dist/transitions/stop.js +3 -2
- package/dist/types/admin.d.ts +1 -1
- package/dist/types/assignments.d.ts +1 -0
- package/dist/types/contracts.d.ts +30 -3
- package/dist/types/endpoints.d.ts +204 -13
- package/dist/types/index.d.ts +3 -0
- package/dist/types/puck.d.ts +8 -1
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +19 -4
- package/dist/types/surface.d.ts +20 -7
- package/dist/ui/Button.js +2 -2
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- package/dist/ui/Dialog.d.ts +24 -2
- package/dist/ui/Dialog.js +116 -6
- package/dist/ui/Drawer.d.ts +10 -0
- package/dist/ui/Drawer.js +29 -0
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +7 -4
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/Tabs.d.ts +4 -4
- package/dist/ui/Tabs.js +35 -32
- package/dist/ui/ui.css +49 -5
- package/package.json +9 -1
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -18
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- package/dist/admin/actions/DecideDialog.d.ts +0 -9
- package/dist/admin/actions/actions.model.js +0 -70
- package/dist/admin/api.d.ts +0 -38
- package/dist/admin/api.js +0 -99
- package/dist/admin/copy/readiness.js +0 -71
- package/dist/admin/copy/testPage.js +0 -100
- 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/pageBlock/pageBlock.model.js +0 -8
- package/dist/admin/surface/readiness/ActionDialogs.js +0 -302
- package/dist/admin/surface/readiness/Banner.js +0 -166
- package/dist/admin/surface/readiness/SaveStatus.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.js +0 -53
- package/dist/admin/surface/readiness/readiness.model.d.ts +0 -24
- package/dist/admin/surface/readiness/readiness.model.js +0 -123
- package/dist/admin/surface/readiness/useTransition.d.ts +0 -11
- package/dist/admin/surface/readiness/useTransition.js +0 -35
- package/dist/admin/surface/results/ReleasePages.d.ts +0 -14
- package/dist/admin/surface/setting/setting.css +0 -17
- package/dist/admin/surface/test/AdvancedSection.js +0 -160
- package/dist/admin/surface/test/GoalSection.d.ts +0 -2
- package/dist/admin/surface/test/GoalSection.js +0 -228
- package/dist/admin/surface/test/LengthSection.d.ts +0 -2
- package/dist/admin/surface/test/Section.js +0 -47
- package/dist/admin/surface/test/VersionsSection.d.ts +0 -4
- package/dist/admin/surface/test/fields.js +0 -184
- package/dist/admin/surface/test/pageParts.d.ts +0 -2
- package/dist/admin/surface/test/pageParts.js +0 -45
- package/dist/admin/surface/test/testPage.css +0 -90
- package/dist/admin/surface/useTestDocument.d.ts +0 -23
- package/dist/admin/surface/useTestDocument.js +0 -377
- package/dist/admin/useApi.d.ts +0 -35
- package/dist/admin/useApi.js +0 -10
- /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}/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/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/recommendation.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.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}/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}/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/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/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/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/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +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/setting/parts.d.ts +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/Rail.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.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
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { contentLocaleURL } from '../../testSurface/contentLocaleURL.js';
|
|
2
|
+
import { isPreflightResult, readPreflight } from '../../testSurface/readPreflight.js';
|
|
3
|
+
import { classifyReadinessRead } from '../../testSurface/readinessRead.js';
|
|
4
|
+
const cache = new Map();
|
|
5
|
+
const latest = new Map();
|
|
6
|
+
const consumers = new Map();
|
|
7
|
+
const keyFor = (api, id, contentLocale)=>JSON.stringify([
|
|
8
|
+
api,
|
|
9
|
+
String(id),
|
|
10
|
+
...contentLocale ? [
|
|
11
|
+
contentLocale
|
|
12
|
+
] : []
|
|
13
|
+
]);
|
|
14
|
+
function read(api, id, fresh, blocking = false, contentLocale) {
|
|
15
|
+
const key = keyFor(api, id, contentLocale);
|
|
16
|
+
const cached = cache.get(key);
|
|
17
|
+
if (cached && (!fresh || cached.pending)) return cached;
|
|
18
|
+
const controller = new AbortController();
|
|
19
|
+
const previous = latest.get(key);
|
|
20
|
+
const entry = {
|
|
21
|
+
controller,
|
|
22
|
+
pending: true,
|
|
23
|
+
blocking,
|
|
24
|
+
startedAt: Date.now(),
|
|
25
|
+
failures: previous?.failures ?? 0,
|
|
26
|
+
value: previous?.value,
|
|
27
|
+
previousPreflight: previous?.preflight ?? (previous?.pending ? previous.previousPreflight : undefined),
|
|
28
|
+
previousRead: previous?.read ?? previous?.previousRead,
|
|
29
|
+
promise: undefined
|
|
30
|
+
};
|
|
31
|
+
cache.set(key, entry);
|
|
32
|
+
latest.set(key, entry);
|
|
33
|
+
for (const notify of consumers.get(key)?.listeners ?? [])notify(entry.value);
|
|
34
|
+
entry.promise = (async ()=>{
|
|
35
|
+
try {
|
|
36
|
+
const { response, body: data } = await readPreflight((signal)=>fetch(contentLocaleURL(`${api}/xp/experiments/${encodeURIComponent(id)}/preflight`, contentLocale), {
|
|
37
|
+
credentials: 'include',
|
|
38
|
+
cache: 'no-store',
|
|
39
|
+
signal
|
|
40
|
+
}), controller.signal);
|
|
41
|
+
entry.read = classifyReadinessRead(response.status, data, entry.failures + 1, {
|
|
42
|
+
kind: 'where-used'
|
|
43
|
+
});
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
entry.response = new Response(JSON.stringify(data), {
|
|
46
|
+
status: response.status,
|
|
47
|
+
headers: response.headers
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!isPreflightResult(data)) return;
|
|
52
|
+
entry.preflight = data;
|
|
53
|
+
if (data.checks?.some((check)=>!check.ok && check.code === 'no-placements' && check.detail !== undefined)) return;
|
|
54
|
+
return Array.isArray(data.placements) ? data.placements : undefined;
|
|
55
|
+
} catch {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
})().then((placements)=>{
|
|
59
|
+
entry.pending = false;
|
|
60
|
+
entry.read ??= classifyReadinessRead(0, undefined, entry.failures + 1, {
|
|
61
|
+
kind: 'where-used'
|
|
62
|
+
});
|
|
63
|
+
entry.failures = entry.read.failed ? entry.failures + 1 : 0;
|
|
64
|
+
entry.value = placements;
|
|
65
|
+
if (cache.get(key) === entry) {
|
|
66
|
+
if (!entry.preflight) cache.delete(key);
|
|
67
|
+
for (const notify of consumers.get(key)?.listeners ?? [])notify(placements);
|
|
68
|
+
}
|
|
69
|
+
return placements;
|
|
70
|
+
});
|
|
71
|
+
return entry;
|
|
72
|
+
}
|
|
73
|
+
/** Share mounted reads, but destructive actions always bypass settled cached knowledge. */ export function refreshPlacements(api, id, contentLocale) {
|
|
74
|
+
return read(api, id, true, false, contentLocale).promise;
|
|
75
|
+
}
|
|
76
|
+
/** Focus storms share the last attempt (including polling), at most once per ten seconds. */ export function focusPlacements(api, id, contentLocale) {
|
|
77
|
+
const previous = latest.get(keyFor(api, id, contentLocale));
|
|
78
|
+
if (previous && Date.now() - previous.startedAt < 10_000) return previous.promise;
|
|
79
|
+
return read(api, id, true, false, contentLocale).promise;
|
|
80
|
+
}
|
|
81
|
+
export function invalidatePlacements(api, id, contentLocale) {
|
|
82
|
+
const key = keyFor(api, id, contentLocale);
|
|
83
|
+
cache.get(key)?.controller.abort();
|
|
84
|
+
cache.delete(key);
|
|
85
|
+
if (consumers.get(key)?.listeners.size) void read(api, id, true, true, contentLocale).promise;
|
|
86
|
+
else latest.delete(key);
|
|
87
|
+
}
|
|
88
|
+
/** Listen without starting a request; the drawer already owns its initial preflight. */ export function subscribePlacements(api, id, notify, contentLocale) {
|
|
89
|
+
const key = keyFor(api, id, contentLocale);
|
|
90
|
+
let group = consumers.get(key);
|
|
91
|
+
if (!group) {
|
|
92
|
+
const listeners = new Set();
|
|
93
|
+
group = {
|
|
94
|
+
listeners,
|
|
95
|
+
removeListener: (notify)=>{
|
|
96
|
+
listeners.delete(notify);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
consumers.set(key, group);
|
|
100
|
+
}
|
|
101
|
+
const current = group;
|
|
102
|
+
current.listeners.add(notify);
|
|
103
|
+
let listening = true;
|
|
104
|
+
return ()=>{
|
|
105
|
+
if (!listening) return;
|
|
106
|
+
listening = false;
|
|
107
|
+
current.removeListener(notify);
|
|
108
|
+
if (!current.listeners.size && consumers.get(key) === current) {
|
|
109
|
+
consumers.delete(key);
|
|
110
|
+
latest.delete(key);
|
|
111
|
+
cache.get(key)?.controller.abort();
|
|
112
|
+
cache.delete(key);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export function acquirePlacements(api, id, notify, fresh = false, contentLocale) {
|
|
117
|
+
const release = subscribePlacements(api, id, notify, contentLocale);
|
|
118
|
+
const key = keyFor(api, id, contentLocale);
|
|
119
|
+
const entry = read(api, id, fresh, false, contentLocale);
|
|
120
|
+
if (entry.value !== undefined) notify(entry.value);
|
|
121
|
+
let active = true;
|
|
122
|
+
void entry.promise.then(()=>{
|
|
123
|
+
if (active && cache.get(key) === entry) notify(entry.value);
|
|
124
|
+
});
|
|
125
|
+
return ()=>{
|
|
126
|
+
active = false;
|
|
127
|
+
release();
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** Drawer preflight uses this same producer and follows a superseding post-write read. */ export async function readEditorPreflight(api, id, signal, supersede = false, contentLocale) {
|
|
131
|
+
if (signal.aborted) return new Response(null, {
|
|
132
|
+
status: 503
|
|
133
|
+
});
|
|
134
|
+
const release = subscribePlacements(api, id, ()=>{}, contentLocale);
|
|
135
|
+
signal.addEventListener('abort', release, {
|
|
136
|
+
once: true
|
|
137
|
+
});
|
|
138
|
+
try {
|
|
139
|
+
if (supersede) invalidatePlacements(api, id, contentLocale);
|
|
140
|
+
const previous = latest.get(keyFor(api, id, contentLocale));
|
|
141
|
+
let entry = previous && Date.now() - previous.startedAt < 10_000 ? previous : read(api, id, true, false, contentLocale);
|
|
142
|
+
while(!signal.aborted){
|
|
143
|
+
await entry.promise;
|
|
144
|
+
if (signal.aborted) return new Response(null, {
|
|
145
|
+
status: 503
|
|
146
|
+
});
|
|
147
|
+
const current = latest.get(keyFor(api, id, contentLocale));
|
|
148
|
+
if (current && current !== entry) {
|
|
149
|
+
entry = current;
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
return entry.preflight ? Response.json(entry.preflight) : entry.response?.clone() ?? new Response(null, {
|
|
153
|
+
status: 503
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return new Response(null, {
|
|
157
|
+
status: 503
|
|
158
|
+
});
|
|
159
|
+
} finally{
|
|
160
|
+
signal.removeEventListener('abort', release);
|
|
161
|
+
release();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/** Current readiness shares the same request and lifetime as placements. */ export function cachedPreflight(api, id, contentLocale) {
|
|
165
|
+
const entry = latest.get(keyFor(api, id, contentLocale));
|
|
166
|
+
return entry?.preflight ?? (entry?.pending ? entry.previousPreflight : undefined);
|
|
167
|
+
}
|
|
168
|
+
/** Mandatory post-write/refusal reads guard Start in every shared consumer. */ export function placementsBlocking(api, id, contentLocale) {
|
|
169
|
+
const entry = cache.get(keyFor(api, id, contentLocale));
|
|
170
|
+
return entry?.pending === true && entry.blocking;
|
|
171
|
+
}
|
|
172
|
+
export function placementsPending(api, id, contentLocale) {
|
|
173
|
+
return cache.get(keyFor(api, id, contentLocale))?.pending === true;
|
|
174
|
+
}
|
|
175
|
+
/** Pending reads retain the complete settled classification, including terminal outcomes. */ export function cachedReadinessRead(api, id, contentLocale) {
|
|
176
|
+
const entry = latest.get(keyFor(api, id, contentLocale));
|
|
177
|
+
return entry?.pending ? entry.previousRead : entry?.read;
|
|
178
|
+
}
|
|
179
|
+
export function placementReadError(api, id, contentLocale) {
|
|
180
|
+
return cachedReadinessRead(api, id, contentLocale)?.message;
|
|
181
|
+
}
|
|
182
|
+
const notices = new WeakMap();
|
|
183
|
+
const noticeDelay = (api, id, contentLocale)=>cachedReadinessRead(api, id, contentLocale)?.pollDelay ?? null;
|
|
184
|
+
export function watchPlacementNotice(api, id, doc, contentLocale) {
|
|
185
|
+
let session = notices.get(doc);
|
|
186
|
+
if (!session) {
|
|
187
|
+
const requests = new Map();
|
|
188
|
+
const created = {
|
|
189
|
+
requests,
|
|
190
|
+
removeRequest: (key)=>{
|
|
191
|
+
requests.delete(key);
|
|
192
|
+
},
|
|
193
|
+
visibility: ()=>{},
|
|
194
|
+
schedule: ()=>{}
|
|
195
|
+
};
|
|
196
|
+
created.schedule = ()=>{
|
|
197
|
+
if (created.timer !== undefined) {
|
|
198
|
+
clearTimeout(created.timer);
|
|
199
|
+
created.timer = undefined;
|
|
200
|
+
}
|
|
201
|
+
const eligible = [
|
|
202
|
+
...created.requests.values()
|
|
203
|
+
].filter((request)=>!request.pending && noticeDelay(request.api, request.id, request.contentLocale) !== null);
|
|
204
|
+
if (doc.visibilityState !== 'visible' || !eligible.length) return;
|
|
205
|
+
created.timer = setTimeout(()=>{
|
|
206
|
+
created.timer = undefined;
|
|
207
|
+
if (doc.visibilityState !== 'visible') return;
|
|
208
|
+
const due = eligible.filter((request)=>created.requests.get(keyFor(request.api, request.id, request.contentLocale)) === request && request.nextAt <= Date.now());
|
|
209
|
+
for (const request of due){
|
|
210
|
+
request.pending = true;
|
|
211
|
+
void refreshPlacements(request.api, request.id, request.contentLocale).then(()=>{
|
|
212
|
+
request.pending = false;
|
|
213
|
+
request.nextAt = Date.now() + (noticeDelay(request.api, request.id, request.contentLocale) ?? 0);
|
|
214
|
+
if (notices.get(doc) === created) created.schedule();
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
created.schedule();
|
|
218
|
+
}, Math.max(0, Math.min(...eligible.map((request)=>request.nextAt)) - Date.now()));
|
|
219
|
+
};
|
|
220
|
+
created.visibility = ()=>{
|
|
221
|
+
for (const request of created.requests.values())request.nextAt = Date.now() + (noticeDelay(request.api, request.id, request.contentLocale) ?? 0);
|
|
222
|
+
created.schedule();
|
|
223
|
+
};
|
|
224
|
+
session = created;
|
|
225
|
+
notices.set(doc, session);
|
|
226
|
+
doc.addEventListener('visibilitychange', created.visibility);
|
|
227
|
+
}
|
|
228
|
+
const current = session;
|
|
229
|
+
const key = keyFor(api, id, contentLocale);
|
|
230
|
+
const existing = current.requests.get(key);
|
|
231
|
+
const request = existing ?? {
|
|
232
|
+
api,
|
|
233
|
+
id,
|
|
234
|
+
contentLocale,
|
|
235
|
+
subscribers: 0,
|
|
236
|
+
nextAt: Date.now() + (noticeDelay(api, id, contentLocale) ?? 0),
|
|
237
|
+
pending: false,
|
|
238
|
+
release: ()=>{}
|
|
239
|
+
};
|
|
240
|
+
request.subscribers++;
|
|
241
|
+
current.requests.set(key, request);
|
|
242
|
+
if (!existing) request.release = subscribePlacements(api, id, ()=>{
|
|
243
|
+
if (placementsPending(api, id, contentLocale)) return;
|
|
244
|
+
// Manual/focus retries also reset the backoff after recovery.
|
|
245
|
+
request.nextAt = Date.now() + (noticeDelay(api, id, contentLocale) ?? 0);
|
|
246
|
+
current.schedule();
|
|
247
|
+
}, contentLocale);
|
|
248
|
+
if (!existing || current.timer === undefined) current.schedule();
|
|
249
|
+
let active = true;
|
|
250
|
+
return ()=>{
|
|
251
|
+
if (!active) return;
|
|
252
|
+
active = false;
|
|
253
|
+
if (--request.subscribers === 0) {
|
|
254
|
+
current.removeRequest(key);
|
|
255
|
+
request.release();
|
|
256
|
+
}
|
|
257
|
+
if (!current.requests.size) {
|
|
258
|
+
if (current.timer !== undefined) clearTimeout(current.timer);
|
|
259
|
+
doc.removeEventListener('visibilitychange', current.visibility);
|
|
260
|
+
notices.delete(doc);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type Targets = {
|
|
2
|
+
test: HTMLElement;
|
|
3
|
+
controls: HTMLElement;
|
|
4
|
+
};
|
|
5
|
+
export declare function useSidebarTargets(id: string): Targets | undefined;
|
|
6
|
+
/** The custom field owns only its portal destinations never another data reader. */
|
|
7
|
+
export declare function TestSidebarField(): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
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 } 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 never another data reader. */ export function TestSidebarField() {
|
|
38
|
+
const getPuck = useGetPuck();
|
|
39
|
+
const id = usePuckSelector((state)=>state.selectedItem?.props.id);
|
|
40
|
+
const [test, setTest] = useState(null);
|
|
41
|
+
const [controls, setControls] = useState(null);
|
|
42
|
+
useEffect(()=>{
|
|
43
|
+
if (!id || !test || !controls) return;
|
|
44
|
+
const entry = bridge(getPuck);
|
|
45
|
+
const targets = {
|
|
46
|
+
test,
|
|
47
|
+
controls
|
|
48
|
+
};
|
|
49
|
+
entry.targets.set(id, targets);
|
|
50
|
+
for (const notify of entry.listeners)notify();
|
|
51
|
+
return ()=>{
|
|
52
|
+
if (entry.targets.get(id) === targets) entry.removeTarget(id);
|
|
53
|
+
for (const notify of entry.listeners)notify();
|
|
54
|
+
};
|
|
55
|
+
}, [
|
|
56
|
+
id,
|
|
57
|
+
test,
|
|
58
|
+
controls,
|
|
59
|
+
getPuck
|
|
60
|
+
]);
|
|
61
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
62
|
+
className: "xp-slot-root xp-slot-editor xp-puck-field xp-slot-sidebar",
|
|
63
|
+
onClick: (event)=>event.stopPropagation(),
|
|
64
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
65
|
+
children: [
|
|
66
|
+
/*#__PURE__*/ _jsx("div", {
|
|
67
|
+
ref: setTest
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ _jsx("div", {
|
|
70
|
+
ref: setControls
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DocId } from '../../types/contracts.js';
|
|
2
|
+
/** Listen for payload-puck 0.12.5+ save results through the DOM event. */
|
|
3
|
+
export declare function usePageSaveReadiness(api: string, id: DocId | undefined, page: {
|
|
4
|
+
collection: string;
|
|
5
|
+
id: string;
|
|
6
|
+
} | undefined, contentLocale?: string): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { invalidatePlacements } from './placementsCache.js';
|
|
4
|
+
const PUCK_SAVE_EVENT = 'payload-puck:save';
|
|
5
|
+
/** Listen for payload-puck 0.12.5+ save results through the DOM event. */ export function usePageSaveReadiness(api, id, page, contentLocale) {
|
|
6
|
+
const collection = page?.collection;
|
|
7
|
+
const pageId = page && String(page.id);
|
|
8
|
+
useEffect(()=>{
|
|
9
|
+
if (id === undefined || !collection || !pageId) return;
|
|
10
|
+
const onSave = (event)=>{
|
|
11
|
+
if (!(event instanceof CustomEvent)) return;
|
|
12
|
+
const detail = event.detail;
|
|
13
|
+
if (!detail || typeof detail !== 'object') return;
|
|
14
|
+
const save = detail;
|
|
15
|
+
if (save.ok !== true || save.id !== pageId || save.collection !== undefined && save.collection !== collection) return;
|
|
16
|
+
if (save.operation !== 'save' && save.operation !== 'publish' && save.operation !== 'unpublish') return;
|
|
17
|
+
if (typeof save.apiEndpoint !== 'string' || save.locale !== undefined && typeof save.locale !== 'string') return;
|
|
18
|
+
if (save.status !== undefined && save.status !== 'draft' && save.status !== 'published') return;
|
|
19
|
+
if (save.error !== undefined) return;
|
|
20
|
+
invalidatePlacements(api, id, contentLocale);
|
|
21
|
+
};
|
|
22
|
+
window.addEventListener(PUCK_SAVE_EVENT, onSave);
|
|
23
|
+
return ()=>window.removeEventListener(PUCK_SAVE_EVENT, onSave);
|
|
24
|
+
}, [
|
|
25
|
+
api,
|
|
26
|
+
id,
|
|
27
|
+
collection,
|
|
28
|
+
pageId,
|
|
29
|
+
contentLocale
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DocId } from '../../types/contracts.js';
|
|
2
|
+
/** Subscribe only while save/publish guidance or a retryable placement failure is visible. */
|
|
3
|
+
export declare function usePlacementNotice(api: string, id: DocId | undefined, message: string | undefined, contentLocale?: string): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
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, contentLocale) {
|
|
5
|
+
const showing = message !== undefined && id !== undefined;
|
|
6
|
+
useEffect(()=>{
|
|
7
|
+
if (id === undefined || !showing) return;
|
|
8
|
+
return watchPlacementNotice(api, id, document, contentLocale);
|
|
9
|
+
}, [
|
|
10
|
+
api,
|
|
11
|
+
id,
|
|
12
|
+
showing,
|
|
13
|
+
contentLocale
|
|
14
|
+
]);
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CustomField } from '@puckeditor/core';
|
|
2
|
+
import { type PuckRoutes } from '../routes.js';
|
|
3
|
+
import './editor.css';
|
|
4
|
+
/** Editor config only. The render config keeps xpGoalPuckField() from /puck. */
|
|
5
|
+
export declare function xpGoalPuckEditorField(options?: {
|
|
6
|
+
routes?: PuckRoutes;
|
|
7
|
+
}): CustomField<string>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
import { useClickGoalPicker } from '../../goals/picker/useClickGoalPicker.js';
|
|
5
|
+
import { clickGoalOptions } from '../../goals/picker/clickGoalPicker.model.js';
|
|
6
|
+
import { CLICK_GOAL_COPY as C } from '../../goals/picker/copy.js';
|
|
7
|
+
import { TextInput, Select } from '../../ui/Inputs.js';
|
|
8
|
+
import { Button } from '../../ui/Button.js';
|
|
9
|
+
import { resolvePuckRoutes } from '../routes.js';
|
|
10
|
+
import './editor.css';
|
|
11
|
+
function XpGoalPuckEditor({ value, onChange, api, readOnly }) {
|
|
12
|
+
const picker = useClickGoalPicker(api, {
|
|
13
|
+
enabled: !readOnly,
|
|
14
|
+
onSelect: onChange
|
|
15
|
+
});
|
|
16
|
+
const { options, missing } = clickGoalOptions(picker.status, picker.goals, value ?? '');
|
|
17
|
+
const readonly = readOnly || picker.status === 'not-manager';
|
|
18
|
+
const id = useId();
|
|
19
|
+
const stopEnter = (event)=>{
|
|
20
|
+
if (event.key === 'Enter') {
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
event.stopPropagation();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
26
|
+
className: "xp-slot-root xp-puck-field",
|
|
27
|
+
children: [
|
|
28
|
+
readonly ? /*#__PURE__*/ _jsxs("div", {
|
|
29
|
+
className: "xp-ui-field",
|
|
30
|
+
children: [
|
|
31
|
+
/*#__PURE__*/ _jsx("span", {
|
|
32
|
+
children: C.label
|
|
33
|
+
}),
|
|
34
|
+
/*#__PURE__*/ _jsx("p", {
|
|
35
|
+
children: value || C.none
|
|
36
|
+
})
|
|
37
|
+
]
|
|
38
|
+
}) : /*#__PURE__*/ _jsxs("div", {
|
|
39
|
+
className: "xp-ui-inline-row",
|
|
40
|
+
children: [
|
|
41
|
+
/*#__PURE__*/ _jsx(Select, {
|
|
42
|
+
id: `${id}-picker`,
|
|
43
|
+
label: C.label,
|
|
44
|
+
value: value ?? '',
|
|
45
|
+
disabled: picker.status !== 'ready',
|
|
46
|
+
onChange: (event)=>onChange(event.currentTarget.value),
|
|
47
|
+
children: options.map((option)=>/*#__PURE__*/ _jsx("option", {
|
|
48
|
+
value: option.value,
|
|
49
|
+
children: option.label
|
|
50
|
+
}, option.value))
|
|
51
|
+
}),
|
|
52
|
+
picker.canManage && !picker.panel.open ? /*#__PURE__*/ _jsx(Button, {
|
|
53
|
+
type: "button",
|
|
54
|
+
onClick: picker.open,
|
|
55
|
+
children: C.newGoal
|
|
56
|
+
}) : null
|
|
57
|
+
]
|
|
58
|
+
}),
|
|
59
|
+
!readonly && picker.status === 'error' ? /*#__PURE__*/ _jsxs("div", {
|
|
60
|
+
children: [
|
|
61
|
+
/*#__PURE__*/ _jsx("p", {
|
|
62
|
+
className: "xp-ui-help",
|
|
63
|
+
children: C.loadError
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
66
|
+
type: "button",
|
|
67
|
+
onClick: picker.retry,
|
|
68
|
+
children: C.retry
|
|
69
|
+
})
|
|
70
|
+
]
|
|
71
|
+
}) : null,
|
|
72
|
+
missing && !readonly ? /*#__PURE__*/ _jsx("p", {
|
|
73
|
+
className: "xp-ui-help",
|
|
74
|
+
role: "status",
|
|
75
|
+
children: C.undefinedKey
|
|
76
|
+
}) : null,
|
|
77
|
+
picker.canManage && !readOnly ? /*#__PURE__*/ _jsx(_Fragment, {
|
|
78
|
+
children: picker.panel.open ? /*#__PURE__*/ _jsxs("section", {
|
|
79
|
+
className: "xp-ui-subpanel",
|
|
80
|
+
"aria-labelledby": `${id}-title`,
|
|
81
|
+
children: [
|
|
82
|
+
/*#__PURE__*/ _jsx("h3", {
|
|
83
|
+
id: `${id}-title`,
|
|
84
|
+
children: C.title
|
|
85
|
+
}),
|
|
86
|
+
/*#__PURE__*/ _jsx(TextInput, {
|
|
87
|
+
id: `${id}-name`,
|
|
88
|
+
label: C.name,
|
|
89
|
+
value: picker.panel.name,
|
|
90
|
+
disabled: picker.panel.pending,
|
|
91
|
+
onKeyDown: stopEnter,
|
|
92
|
+
onChange: (event)=>picker.setName(event.currentTarget.value)
|
|
93
|
+
}),
|
|
94
|
+
/*#__PURE__*/ _jsxs("details", {
|
|
95
|
+
open: picker.panel.advanced,
|
|
96
|
+
onToggle: (event)=>picker.setAdvanced(event.currentTarget.open),
|
|
97
|
+
children: [
|
|
98
|
+
/*#__PURE__*/ _jsx("summary", {
|
|
99
|
+
children: C.advanced
|
|
100
|
+
}),
|
|
101
|
+
/*#__PURE__*/ _jsx(TextInput, {
|
|
102
|
+
id: `${id}-slug`,
|
|
103
|
+
label: C.slug,
|
|
104
|
+
value: picker.panel.slug,
|
|
105
|
+
disabled: picker.panel.pending,
|
|
106
|
+
onKeyDown: stopEnter,
|
|
107
|
+
error: picker.panel.errors.slug,
|
|
108
|
+
onChange: (event)=>picker.setSlug(event.currentTarget.value)
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
}),
|
|
112
|
+
picker.panel.errors.general ? /*#__PURE__*/ _jsx("p", {
|
|
113
|
+
className: "xp-ui-error",
|
|
114
|
+
role: "alert",
|
|
115
|
+
children: picker.panel.errors.general
|
|
116
|
+
}) : null,
|
|
117
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
118
|
+
className: "xp-ui-button-group",
|
|
119
|
+
children: [
|
|
120
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
121
|
+
type: "button",
|
|
122
|
+
variant: "primary",
|
|
123
|
+
disabled: picker.panel.pending || !picker.panel.name.trim(),
|
|
124
|
+
onClick: ()=>void picker.create(),
|
|
125
|
+
children: C.createGoal
|
|
126
|
+
}),
|
|
127
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
128
|
+
type: "button",
|
|
129
|
+
disabled: picker.panel.pending,
|
|
130
|
+
onClick: picker.cancel,
|
|
131
|
+
children: C.cancel
|
|
132
|
+
})
|
|
133
|
+
]
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
}) : null
|
|
137
|
+
}) : null
|
|
138
|
+
]
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/** Editor config only. The render config keeps xpGoalPuckField() from /puck. */ export function xpGoalPuckEditorField(options) {
|
|
142
|
+
const routes = resolvePuckRoutes(options?.routes);
|
|
143
|
+
return {
|
|
144
|
+
type: 'custom',
|
|
145
|
+
label: C.label,
|
|
146
|
+
render: ({ value, onChange, readOnly })=>/*#__PURE__*/ _jsx(XpGoalPuckEditor, {
|
|
147
|
+
value: value,
|
|
148
|
+
onChange: onChange,
|
|
149
|
+
api: routes.api,
|
|
150
|
+
readOnly: readOnly
|
|
151
|
+
})
|
|
152
|
+
};
|
|
153
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
1
2
|
import type { CustomField } from '@puckeditor/core';
|
|
2
3
|
import type { ExperimentRef } from '../types/puck.js';
|
|
3
4
|
import { type PuckRoutes } from './routes.js';
|
|
4
5
|
export declare function createExperimentSlotField(opts?: {
|
|
5
6
|
label?: string;
|
|
6
7
|
routes?: PuckRoutes;
|
|
8
|
+
renderActions?: (experiment: ExperimentRef) => ReactNode;
|
|
9
|
+
onBind?: (previous: ExperimentRef | null, next: ExperimentRef | null) => void;
|
|
7
10
|
}): CustomField<ExperimentRef | null>;
|
|
@@ -12,10 +12,21 @@ export function createExperimentSlotField(opts) {
|
|
|
12
12
|
routes,
|
|
13
13
|
children: createElement('div', {
|
|
14
14
|
className: 'xp-puck-field'
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
}, ...opts?.renderActions ? [
|
|
16
|
+
createElement(ExperimentPicker, {
|
|
17
|
+
value,
|
|
18
|
+
onChange: (next)=>{
|
|
19
|
+
opts?.onBind?.(value, next);
|
|
20
|
+
onChange(next);
|
|
21
|
+
}
|
|
22
|
+
}),
|
|
23
|
+
value ? opts.renderActions(value) : null
|
|
24
|
+
] : [
|
|
25
|
+
createElement(ExperimentPicker, {
|
|
26
|
+
value,
|
|
27
|
+
onChange
|
|
28
|
+
})
|
|
29
|
+
])
|
|
19
30
|
})
|
|
20
31
|
};
|
|
21
32
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ExperimentsPuckIntegration } from '../types/puck.js';
|
|
2
|
+
import type { PuckRoutes } from './routes.js';
|
|
3
|
+
/** Bundle the test block and its sidebar category for a host render config. */
|
|
4
|
+
export declare function experimentsPuck({ routes }?: {
|
|
5
|
+
routes?: PuckRoutes;
|
|
6
|
+
}): ExperimentsPuckIntegration;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EXPERIMENT_SLOT_TYPE } from '../types/puck.js';
|
|
2
|
+
import { createExperimentSlot } from './ExperimentSlot.js';
|
|
3
|
+
import { categoryTitle } from './copy.js';
|
|
4
|
+
/** Bundle the test block and its sidebar category for a host render config. */ export function experimentsPuck({ routes } = {}) {
|
|
5
|
+
return {
|
|
6
|
+
name: 'experiments',
|
|
7
|
+
components: {
|
|
8
|
+
[EXPERIMENT_SLOT_TYPE]: createExperimentSlot({
|
|
9
|
+
routes
|
|
10
|
+
})
|
|
11
|
+
},
|
|
12
|
+
categories: {
|
|
13
|
+
experiments: {
|
|
14
|
+
title: categoryTitle,
|
|
15
|
+
components: [
|
|
16
|
+
EXPERIMENT_SLOT_TYPE
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const nestedTestCopy: {
|
|
2
|
+
start: (outer?: string, inner?: string) => string;
|
|
3
|
+
readinessFallback: string;
|
|
4
|
+
editor: (outer?: string, inner?: string) => string;
|
|
5
|
+
publish: (outer?: string, inner?: string) => string;
|
|
6
|
+
hidden: (outer?: string) => string;
|
|
7
|
+
readiness: (detail: unknown) => string;
|
|
8
|
+
};
|