@delmaredigital/payload-experiments 0.4.0-rc.7 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/README.md +9 -15
  2. package/dist/admin/MetricSourceSelect.js +10 -3
  3. package/dist/admin/armSelect/armSelect.model.d.ts +1 -1
  4. package/dist/admin/blocks/BlockPanel.d.ts +1 -0
  5. package/dist/admin/blocks/BlockPanel.js +75 -29
  6. package/dist/admin/blocks/model.js +7 -6
  7. package/dist/admin/copy/blocks.d.ts +14 -11
  8. package/dist/admin/copy/blocks.js +33 -22
  9. package/dist/admin/copy/goals.d.ts +15 -8
  10. package/dist/admin/copy/goals.js +18 -8
  11. package/dist/admin/copy/newTest.d.ts +10 -7
  12. package/dist/admin/copy/newTest.js +14 -7
  13. package/dist/admin/copy/status.d.ts +1 -1
  14. package/dist/admin/copy/status.js +2 -1
  15. package/dist/admin/pageCollections.d.ts +1 -0
  16. package/dist/admin/pageCollections.js +3 -0
  17. package/dist/admin/placementStatus.model.js +5 -3
  18. package/dist/admin/status.model.d.ts +1 -0
  19. package/dist/admin/status.model.js +2 -1
  20. package/dist/admin/surface/ResultsRoute.js +12 -10
  21. package/dist/admin/surface/SurfaceShell.d.ts +4 -2
  22. package/dist/admin/surface/SurfaceShell.js +28 -3
  23. package/dist/admin/surface/TestRowMenu.d.ts +13 -0
  24. package/dist/admin/surface/TestRowMenu.js +163 -0
  25. package/dist/admin/surface/TestsHome.d.ts +4 -3
  26. package/dist/admin/surface/TestsHome.js +224 -52
  27. package/dist/admin/surface/TestsSurface.js +2 -1
  28. package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
  29. package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
  30. package/dist/admin/surface/goals/GoalForm.d.ts +1 -0
  31. package/dist/admin/surface/goals/GoalForm.js +280 -198
  32. package/dist/admin/surface/goals/GoalsList.js +102 -33
  33. package/dist/admin/surface/goals/data.d.ts +2 -0
  34. package/dist/admin/surface/goals/data.js +9 -0
  35. package/dist/admin/surface/goals/goals.css +3 -2
  36. package/dist/admin/surface/goals/goals.model.d.ts +2 -2
  37. package/dist/admin/surface/goals/goals.model.js +7 -12
  38. package/dist/admin/surface/home.model.d.ts +15 -8
  39. package/dist/admin/surface/home.model.js +22 -18
  40. package/dist/admin/surface/newTest/NewTest.d.ts +3 -3
  41. package/dist/admin/surface/newTest/NewTest.js +156 -96
  42. package/dist/admin/surface/newTest/PageWizard.d.ts +4 -1
  43. package/dist/admin/surface/newTest/PageWizard.js +99 -68
  44. package/dist/admin/surface/newTest/newTest.css +28 -11
  45. package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
  46. package/dist/admin/surface/results/ResultsHeader.js +98 -66
  47. package/dist/admin/surface/surface.css +29 -0
  48. package/dist/admin/surface/test/TestPage.js +46 -38
  49. package/dist/admin/surface/useXpStepNav.d.ts +11 -0
  50. package/dist/admin/surface/useXpStepNav.js +14 -0
  51. package/dist/admin/views/TestsSurfaceClient.js +27 -3
  52. package/dist/admin/views/buildSurfaceProps.js +18 -66
  53. package/dist/arms/copy.d.ts +13 -3
  54. package/dist/arms/copy.js +5 -4
  55. package/dist/blocks/createExperimentBlock.js +1 -1
  56. package/dist/blocks/formState.js +2 -2
  57. package/dist/collections/experiments/armInvariants.js +8 -5
  58. package/dist/collections/experiments/config.js +8 -3
  59. package/dist/collections/experiments/deleteGuard.js +2 -2
  60. package/dist/collections/experiments/lockHook.js +21 -2
  61. package/dist/collections/experiments/pickSlug.js +2 -0
  62. package/dist/collections/metrics.js +12 -5
  63. package/dist/collections/metricsGuards.js +2 -0
  64. package/dist/collections/serialize.js +8 -6
  65. package/dist/constants.d.ts +1 -0
  66. package/dist/constants.js +1 -0
  67. package/dist/db/adapter.d.ts +9 -1
  68. package/dist/db/adapter.js +77 -1
  69. package/dist/db/delete.d.ts +1 -1
  70. package/dist/db/delete.js +2 -4
  71. package/dist/db/events.d.ts +9 -0
  72. package/dist/db/events.js +42 -8
  73. package/dist/db/executor.d.ts +7 -1
  74. package/dist/db/executor.js +7 -3
  75. package/dist/db/pageCopies.d.ts +5 -0
  76. package/dist/db/pageCopies.js +31 -0
  77. package/dist/db/results.d.ts +5 -1
  78. package/dist/db/results.js +21 -5
  79. package/dist/db/snapshots.d.ts +2 -0
  80. package/dist/endpoints/deleteImpact.js +2 -1
  81. package/dist/endpoints/duplicateOriginal.d.ts +38 -0
  82. package/dist/endpoints/duplicateOriginal.js +414 -0
  83. package/dist/endpoints/editorSurface.js +1 -1
  84. package/dist/endpoints/events.js +103 -39
  85. package/dist/endpoints/index.js +22 -8
  86. package/dist/endpoints/pages.js +245 -66
  87. package/dist/endpoints/placementStatus.js +8 -4
  88. package/dist/endpoints/results.d.ts +1 -1
  89. package/dist/endpoints/results.js +9 -2
  90. package/dist/endpoints/routeId.d.ts +2 -2
  91. package/dist/endpoints/routeId.js +11 -5
  92. package/dist/endpoints/summary.js +46 -12
  93. package/dist/endpoints/testVersion.d.ts +2 -0
  94. package/dist/endpoints/testVersion.js +38 -0
  95. package/dist/endpoints/transitions.js +41 -29
  96. package/dist/errors.d.ts +4 -0
  97. package/dist/errors.js +6 -0
  98. package/dist/events/request.d.ts +6 -2
  99. package/dist/events/request.js +35 -8
  100. package/dist/events/rows.d.ts +1 -1
  101. package/dist/events/rows.js +24 -8
  102. package/dist/events/writable.d.ts +9 -0
  103. package/dist/events/writable.js +13 -0
  104. package/dist/exports/index.d.ts +1 -1
  105. package/dist/exports/rsc.d.ts +1 -0
  106. package/dist/exports/rsc.js +1 -0
  107. package/dist/goals/fairness.js +2 -2
  108. package/dist/goals/picker/copy.js +1 -1
  109. package/dist/goals/sourceLabel.d.ts +2 -0
  110. package/dist/goals/sourceLabel.js +4 -0
  111. package/dist/hooks/hostHook.js +6 -2
  112. package/dist/hooks/pageGuard.js +4 -0
  113. package/dist/hooks/trackPageCopies.d.ts +11 -0
  114. package/dist/hooks/trackPageCopies.js +7 -0
  115. package/dist/labels/arms.d.ts +3 -0
  116. package/dist/labels/arms.js +8 -0
  117. package/dist/lib/fetchAllDocs.d.ts +1 -1
  118. package/dist/manifest/compile.js +8 -5
  119. package/dist/onInit.js +14 -0
  120. package/dist/options.d.ts +2 -0
  121. package/dist/options.js +23 -2
  122. package/dist/plugin.js +56 -2
  123. package/dist/proxy/pageNavigation.d.ts +4 -0
  124. package/dist/proxy/pageNavigation.js +28 -0
  125. package/dist/proxy/resolve.js +52 -25
  126. package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
  127. package/dist/puck/editor/ConfigureTestDrawer.js +40 -29
  128. package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
  129. package/dist/puck/editor/ExperimentSlotEditor.js +376 -139
  130. package/dist/puck/editor/LeftoverVersions.js +17 -32
  131. package/dist/puck/editor/QuickTestActions.d.ts +6 -3
  132. package/dist/puck/editor/QuickTestActions.js +55 -33
  133. package/dist/puck/editor/ResultsReadout.d.ts +4 -1
  134. package/dist/puck/editor/ResultsReadout.js +28 -15
  135. package/dist/puck/editor/VersionBuilder.d.ts +17 -4
  136. package/dist/puck/editor/VersionBuilder.js +175 -112
  137. package/dist/puck/editor/armWrites.js +2 -2
  138. package/dist/puck/editor/armsCache.js +1 -3
  139. package/dist/puck/editor/copy.d.ts +14 -7
  140. package/dist/puck/editor/copy.js +26 -13
  141. package/dist/puck/editor/editor.chrome.css +10 -8
  142. package/dist/puck/editor/editor.css +15 -9
  143. package/dist/puck/editor/editor.model.d.ts +1 -0
  144. package/dist/puck/editor/placementsCache.d.ts +4 -0
  145. package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
  146. package/dist/puck/editor/usePageSaveReadiness.js +31 -0
  147. package/dist/puck/nestedTestCopy.js +2 -2
  148. package/dist/puck/slotConfig.d.ts +1 -1
  149. package/dist/puck/slotConfig.js +1 -1
  150. package/dist/results/aggregate.d.ts +6 -3
  151. package/dist/results/aggregate.js +9 -9
  152. package/dist/results/analyse.d.ts +2 -0
  153. package/dist/results/analyse.js +2 -2
  154. package/dist/results/health.d.ts +8 -0
  155. package/dist/results/health.js +28 -0
  156. package/dist/results/identityCredit.d.ts +1 -0
  157. package/dist/results/identityCredit.js +4 -1
  158. package/dist/results/verdict.d.ts +4 -4
  159. package/dist/results/verdict.js +15 -11
  160. package/dist/runtime/cookie.d.ts +10 -2
  161. package/dist/runtime/cookie.js +38 -6
  162. package/dist/runtime/cookieOptions.d.ts +6 -0
  163. package/dist/runtime/cookieOptions.js +14 -0
  164. package/dist/runtime/proxyRuntime.d.ts +1 -0
  165. package/dist/runtime/proxyRuntime.js +18 -8
  166. package/dist/runtime/signing.d.ts +1 -0
  167. package/dist/runtime/signing.js +5 -0
  168. package/dist/sanitizeReadinessDetail.d.ts +2 -2
  169. package/dist/sanitizeReadinessDetail.js +20 -2
  170. package/dist/server/getAssignments.js +11 -10
  171. package/dist/server/recordContentChange.d.ts +1 -1
  172. package/dist/server/recordContentChange.js +11 -2
  173. package/dist/server/resolveExperimentBlocks.js +2 -4
  174. package/dist/server/resolveExperimentData.js +2 -5
  175. package/dist/server/runResults.js +54 -15
  176. package/dist/server/startExperiment.d.ts +20 -0
  177. package/dist/server/startExperiment.js +70 -0
  178. package/dist/server/trackConversion.js +10 -13
  179. package/dist/testSurface/PreviewLinks.d.ts +2 -1
  180. package/dist/testSurface/PreviewLinks.js +3 -3
  181. package/dist/testSurface/actions/DecideDialog.d.ts +10 -4
  182. package/dist/testSurface/actions/DecideDialog.js +93 -63
  183. package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
  184. package/dist/testSurface/actions/LifecycleAction.js +107 -0
  185. package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
  186. package/dist/testSurface/actions/MakeContentResult.js +10 -2
  187. package/dist/testSurface/actions/actions.model.d.ts +13 -5
  188. package/dist/testSurface/actions/actions.model.js +75 -22
  189. package/dist/testSurface/actions/decide.model.d.ts +1 -0
  190. package/dist/testSurface/actions/decide.model.js +1 -0
  191. package/dist/testSurface/allocation.model.js +6 -3
  192. package/dist/testSurface/api.d.ts +9 -6
  193. package/dist/testSurface/api.js +43 -23
  194. package/dist/testSurface/copy/actions.d.ts +37 -14
  195. package/dist/testSurface/copy/actions.js +40 -17
  196. package/dist/testSurface/copy/advanced.d.ts +10 -0
  197. package/dist/testSurface/copy/advanced.js +10 -0
  198. package/dist/testSurface/copy/arms.d.ts +1 -1
  199. package/dist/testSurface/copy/arms.js +1 -1
  200. package/dist/testSurface/copy/audience.d.ts +4 -3
  201. package/dist/testSurface/copy/audience.js +5 -4
  202. package/dist/testSurface/copy/common.d.ts +8 -6
  203. package/dist/testSurface/copy/common.js +8 -6
  204. package/dist/testSurface/copy/languages.d.ts +1 -0
  205. package/dist/testSurface/copy/languages.js +1 -0
  206. package/dist/testSurface/copy/metrics.d.ts +7 -0
  207. package/dist/testSurface/copy/metrics.js +9 -0
  208. package/dist/testSurface/copy/pages.d.ts +67 -7
  209. package/dist/testSurface/copy/pages.js +74 -7
  210. package/dist/testSurface/copy/readiness.d.ts +20 -7
  211. package/dist/testSurface/copy/readiness.js +36 -10
  212. package/dist/testSurface/copy/recommendation.d.ts +1 -22
  213. package/dist/testSurface/copy/recommendation.js +2 -22
  214. package/dist/testSurface/copy/results.d.ts +21 -12
  215. package/dist/testSurface/copy/results.js +24 -13
  216. package/dist/testSurface/copy/review.d.ts +13 -10
  217. package/dist/testSurface/copy/review.js +14 -10
  218. package/dist/testSurface/copy/setting.d.ts +1 -2
  219. package/dist/testSurface/copy/setting.js +1 -2
  220. package/dist/testSurface/copy/surface.d.ts +11 -2
  221. package/dist/testSurface/copy/surface.js +14 -11
  222. package/dist/testSurface/copy/testPage.d.ts +36 -12
  223. package/dist/testSurface/copy/testPage.js +53 -16
  224. package/dist/testSurface/format/date.d.ts +5 -2
  225. package/dist/testSurface/format/date.js +24 -8
  226. package/dist/testSurface/format/roundProgress.d.ts +6 -0
  227. package/dist/testSurface/format/roundProgress.js +15 -0
  228. package/dist/testSurface/format/useDateFormatter.d.ts +3 -0
  229. package/dist/testSurface/format/useDateFormatter.js +8 -0
  230. package/dist/testSurface/labels.d.ts +1 -2
  231. package/dist/testSurface/labels.js +2 -3
  232. package/dist/testSurface/lockedNotice.model.d.ts +2 -0
  233. package/dist/testSurface/lockedNotice.model.js +31 -0
  234. package/dist/testSurface/readPreflight.d.ts +4 -0
  235. package/dist/testSurface/readPreflight.js +6 -0
  236. package/dist/testSurface/readinessRead.d.ts +3 -0
  237. package/dist/testSurface/readinessRead.js +4 -0
  238. package/dist/testSurface/results/CiChart.js +2 -1
  239. package/dist/testSurface/results/DataTable.d.ts +1 -1
  240. package/dist/testSurface/results/DataTable.js +4 -3
  241. package/dist/testSurface/results/VerdictHero.d.ts +3 -2
  242. package/dist/testSurface/results/VerdictHero.js +5 -1
  243. package/dist/testSurface/results/legacy.d.ts +0 -5
  244. package/dist/testSurface/results/legacy.js +0 -14
  245. package/dist/testSurface/results/results.css +2 -2
  246. package/dist/testSurface/results/results.model.d.ts +9 -4
  247. package/dist/testSurface/results/results.model.js +31 -23
  248. package/dist/testSurface/results/snapshot.d.ts +2 -0
  249. package/dist/testSurface/results/snapshot.js +3 -0
  250. package/dist/testSurface/surface/contracts.d.ts +13 -1
  251. package/dist/testSurface/surface/editorPlacement.d.ts +3 -3
  252. package/dist/testSurface/surface/editorPlacement.js +2 -2
  253. package/dist/testSurface/surface/pageBlock/pageBlock.model.js +3 -3
  254. package/dist/testSurface/surface/pageBlock/parts.js +25 -12
  255. package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +8 -1
  256. package/dist/testSurface/surface/pagePicker/CopyRoute.js +243 -22
  257. package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +15 -4
  258. package/dist/testSurface/surface/pagePicker/PageCombobox.js +300 -197
  259. package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -10
  260. package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +5 -3
  261. package/dist/testSurface/surface/pagePicker/pagePicker.model.js +17 -2
  262. package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +9 -5
  263. package/dist/testSurface/surface/readiness/ActionDialogs.js +241 -230
  264. package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
  265. package/dist/testSurface/surface/readiness/Banner.js +113 -141
  266. package/dist/testSurface/surface/readiness/SaveStatus.d.ts +8 -4
  267. package/dist/testSurface/surface/readiness/SaveStatus.js +23 -22
  268. package/dist/testSurface/surface/readiness/readiness.model.d.ts +20 -6
  269. package/dist/testSurface/surface/readiness/readiness.model.js +168 -21
  270. package/dist/testSurface/surface/readiness/useTransition.d.ts +6 -4
  271. package/dist/testSurface/surface/readiness/useTransition.js +57 -14
  272. package/dist/testSurface/surface/results/ReleasePages.d.ts +6 -3
  273. package/dist/testSurface/surface/results/ReleasePages.js +42 -41
  274. package/dist/testSurface/surface/results/ResultsBody.d.ts +11 -4
  275. package/dist/testSurface/surface/results/ResultsBody.js +221 -118
  276. package/dist/testSurface/surface/results/recommendation.model.d.ts +6 -9
  277. package/dist/testSurface/surface/results/recommendation.model.js +15 -59
  278. package/dist/testSurface/surface/results/useResults.d.ts +13 -8
  279. package/dist/testSurface/surface/results/useResults.js +3 -2
  280. package/dist/testSurface/surface/setting/parts.js +89 -46
  281. package/dist/testSurface/surface/setting/setting.css +2 -1
  282. package/dist/testSurface/surface/test/AdvancedSection.js +11 -4
  283. package/dist/testSurface/surface/test/DeleteTest.d.ts +10 -2
  284. package/dist/testSurface/surface/test/DeleteTest.js +173 -74
  285. package/dist/testSurface/surface/test/GoalSection.js +18 -14
  286. package/dist/testSurface/surface/test/LengthSection.js +24 -13
  287. package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
  288. package/dist/testSurface/surface/test/PageHoldout.js +11 -8
  289. package/dist/testSurface/surface/test/ReadinessBar.d.ts +2 -1
  290. package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
  291. package/dist/testSurface/surface/test/Section.js +8 -0
  292. package/dist/testSurface/surface/test/TargetingSection.js +82 -12
  293. package/dist/testSurface/surface/test/TestSurface.js +73 -37
  294. package/dist/testSurface/surface/test/VersionsSection.js +141 -91
  295. package/dist/testSurface/surface/test/fields.d.ts +32 -6
  296. package/dist/testSurface/surface/test/fields.js +166 -52
  297. package/dist/testSurface/surface/test/pageParts.js +27 -12
  298. package/dist/testSurface/surface/test/testPage.css +9 -2
  299. package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
  300. package/dist/testSurface/surface/test/testPage.model.js +6 -0
  301. package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
  302. package/dist/testSurface/surface/testDocument.model.js +4 -1
  303. package/dist/testSurface/surface/useTestDocument.d.ts +21 -5
  304. package/dist/testSurface/surface/useTestDocument.js +472 -167
  305. package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
  306. package/dist/testSurface/surface/watchTestDocument.js +181 -0
  307. package/dist/testSurface/surfaceUrls.d.ts +1 -0
  308. package/dist/testSurface/surfaceUrls.js +4 -0
  309. package/dist/testSurface/useApi.d.ts +8 -5
  310. package/dist/testSurface/useOnTestReturn.d.ts +2 -0
  311. package/dist/testSurface/useOnTestReturn.js +27 -0
  312. package/dist/testSurface/useReadinessPolling.js +3 -1
  313. package/dist/transitions/addMetric.d.ts +2 -5
  314. package/dist/transitions/addMetric.js +5 -1
  315. package/dist/transitions/allocate.d.ts +2 -2
  316. package/dist/transitions/allocate.js +3 -1
  317. package/dist/transitions/archive.d.ts +1 -1
  318. package/dist/transitions/archive.js +3 -2
  319. package/dist/transitions/checkStart.d.ts +1 -0
  320. package/dist/transitions/checkStart.js +17 -6
  321. package/dist/transitions/decide.d.ts +1 -1
  322. package/dist/transitions/decide.js +5 -3
  323. package/dist/transitions/deleteExperiment.d.ts +2 -2
  324. package/dist/transitions/deleteExperiment.js +17 -7
  325. package/dist/transitions/kernel.d.ts +4 -0
  326. package/dist/transitions/kernel.js +9 -4
  327. package/dist/transitions/makeContent.d.ts +2 -1
  328. package/dist/transitions/makeContent.js +12 -8
  329. package/dist/transitions/nestedPlacementNames.d.ts +2 -2
  330. package/dist/transitions/nestedPlacementNames.js +4 -5
  331. package/dist/transitions/pageAddress.d.ts +6 -0
  332. package/dist/transitions/pageAddress.js +71 -0
  333. package/dist/transitions/pageVersions.d.ts +1 -1
  334. package/dist/transitions/phaseRecord.d.ts +2 -0
  335. package/dist/transitions/phaseRecord.js +5 -0
  336. package/dist/transitions/placementInteractions.d.ts +3 -3
  337. package/dist/transitions/placementInteractions.js +8 -7
  338. package/dist/transitions/placements.d.ts +2 -0
  339. package/dist/transitions/placements.js +5 -5
  340. package/dist/transitions/preflightData.d.ts +3 -2
  341. package/dist/transitions/preflightData.js +77 -43
  342. package/dist/transitions/releaseHoldout.d.ts +2 -1
  343. package/dist/transitions/releaseHoldout.js +3 -1
  344. package/dist/transitions/releasePages.d.ts +2 -1
  345. package/dist/transitions/releasePages.js +3 -1
  346. package/dist/transitions/resolveCaps.d.ts +2 -4
  347. package/dist/transitions/start.d.ts +7 -9
  348. package/dist/transitions/start.js +75 -39
  349. package/dist/transitions/startReads.d.ts +7 -0
  350. package/dist/transitions/startReads.js +28 -0
  351. package/dist/transitions/stop.d.ts +2 -1
  352. package/dist/transitions/stop.js +3 -2
  353. package/dist/types/armKey.d.ts +2 -0
  354. package/dist/types/armKey.js +1 -0
  355. package/dist/types/contracts.d.ts +17 -4
  356. package/dist/types/endpoints.d.ts +89 -17
  357. package/dist/types/endpoints.js +1 -1
  358. package/dist/types/runtime.d.ts +15 -9
  359. package/dist/types/snapshot.d.ts +2 -0
  360. package/dist/types/surface.d.ts +7 -9
  361. package/dist/ui/ChipsInput.d.ts +8 -1
  362. package/dist/ui/ChipsInput.js +17 -4
  363. package/dist/ui/Dialog.d.ts +21 -2
  364. package/dist/ui/Dialog.js +101 -4
  365. package/dist/ui/Inputs.js +0 -1
  366. package/dist/ui/ui.css +5 -1
  367. package/package.json +2 -2
package/dist/options.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { validateAccent } from './ui/accent.js';
2
2
  import { DEFAULT_MAX_BODY_BYTES } from './constants.js';
3
+ import { publicEventOrigin } from './events/request.js';
3
4
  const normalisedCollections = new WeakMap();
4
5
  /** Resolve once per registration list; every consumer shares the same field defaults. */ export function puckCollections(options) {
5
6
  const entries = options.puck?.collections;
@@ -17,8 +18,13 @@ const normalisedCollections = new WeakMap();
17
18
  normalisedCollections.set(resolved, resolved);
18
19
  return resolved;
19
20
  }
21
+ function enabledPuckCollections(options) {
22
+ return options.puck?.enabled === false ? [] : puckCollections(options);
23
+ }
20
24
  export function resolveOptions(input) {
21
25
  if (typeof input?.access?.manage !== 'function') throw new Error('Experiments access.manage must be a function');
26
+ const origin = publicEventOrigin(input.events?.origin);
27
+ if (input.events?.origin !== undefined && !origin) throw new Error('Experiments events.origin must be a public HTTP(S) origin with no path, query or credentials');
22
28
  const { manage, admin = manage, readResults = manage, readIdentities = admin } = input.access;
23
29
  for (const [name, access] of Object.entries({
24
30
  admin,
@@ -79,6 +85,9 @@ export function resolveOptions(input) {
79
85
  }
80
86
  if (entry.copyUrl !== undefined && !validCopyUrl(entry.copyUrl)) throw new Error('Experiments copyUrl must be a root-relative path');
81
87
  if (entry.copyLabel !== undefined && entry.copyUrl === undefined) throw new Error('Experiments copyLabel requires copyUrl');
88
+ if (entry.copy !== undefined && typeof entry.copy !== 'boolean' && (!entry.copy || typeof entry.copy !== 'object' || Array.isArray(entry.copy) || typeof entry.copy.overrides !== 'function')) {
89
+ throw new Error('Experiments pages.collections[].copy must be a boolean or an object with an overrides function');
90
+ }
82
91
  slugs.add(entry.slug);
83
92
  }
84
93
  }
@@ -163,6 +172,8 @@ export function resolveOptions(input) {
163
172
  ])),
164
173
  events: {
165
174
  ...input.events,
175
+ origin,
176
+ rateLimit: input.events?.rateLimit,
166
177
  retentionDays,
167
178
  maxBodyBytes,
168
179
  dimensions: Array.isArray(dimensions) ? [
@@ -186,7 +197,17 @@ function validCopyUrl(value) {
186
197
  }
187
198
  /** One published-row rule shared by scans, bindings, writes and editor links. */ export function documentEditor(options, collection, doc) {
188
199
  const block = options.blocks?.collections.find((entry)=>entry.slug === collection);
189
- const puck = options.puck?.enabled !== false && puckCollections(options).some((entry)=>entry.slug === collection);
190
200
  if (block && (block.appliesTo ? block.appliesTo(doc) : true)) return 'blocks';
191
- return puck ? 'puck' : 'page';
201
+ return hasPuckEditor(options, collection) ? 'puck' : 'page';
202
+ }
203
+ export function hasPuckEditor(options, collection) {
204
+ return enabledPuckCollections(options).some((entry)=>entry.slug === collection);
205
+ }
206
+ export function blockPageSlugs(options) {
207
+ return [
208
+ ...new Set([
209
+ ...enabledPuckCollections(options),
210
+ ...options.blocks?.collections ?? []
211
+ ].map((entry)=>entry.slug))
212
+ ];
192
213
  }
package/dist/plugin.js CHANGED
@@ -2,6 +2,7 @@ import { buildCollections } from './collections/index.js';
2
2
  import { buildEndpoints } from './endpoints/index.js';
3
3
  import { contentChangesBeforeHook, contentChangesHook } from './hooks/contentChanges.js';
4
4
  import { puckGoalsBeforeChange } from './hooks/puckGoals.js';
5
+ import { trackPageCopies } from './hooks/trackPageCopies.js';
5
6
  import { pageGuardAfterChange, pageGuardAfterOperation, pageGuardEnterOperation, pageGuardBeforeChange, pageGuardBeforeDelete, pageGuardBeforeOperation } from './hooks/pageGuard.js';
6
7
  import { createOnInit } from './onInit.js';
7
8
  import { puckCollections, resolveOptions } from './options.js';
@@ -39,9 +40,59 @@ export function createExperimentsPlugin(input) {
39
40
  ...config.admin?.components,
40
41
  views: {
41
42
  ...config.admin?.components?.views,
43
+ xpNewTest: {
44
+ Component: paths.XP_TESTS_VIEW,
45
+ path: '/experiments/new',
46
+ exact: true,
47
+ meta: {
48
+ title: {
49
+ absolute: 'New test · Tests'
50
+ },
51
+ titleSuffix: ''
52
+ }
53
+ },
54
+ xpNewGoal: {
55
+ Component: paths.XP_TESTS_VIEW,
56
+ path: '/experiments/goals/new',
57
+ exact: true,
58
+ meta: {
59
+ title: {
60
+ absolute: 'New goal · Tests'
61
+ },
62
+ titleSuffix: ''
63
+ }
64
+ },
65
+ xpGoal: {
66
+ Component: paths.XP_TESTS_VIEW,
67
+ path: '/experiments/goals/:id',
68
+ exact: true,
69
+ meta: {
70
+ title: {
71
+ absolute: 'Goal · Tests'
72
+ },
73
+ titleSuffix: ''
74
+ }
75
+ },
76
+ xpResults: {
77
+ Component: paths.XP_TESTS_VIEW,
78
+ path: '/experiments/:id/results',
79
+ exact: true,
80
+ meta: {
81
+ title: {
82
+ absolute: 'Results · Tests'
83
+ },
84
+ titleSuffix: ''
85
+ }
86
+ },
42
87
  xpTests: {
43
88
  Component: paths.XP_TESTS_VIEW,
44
- path: '/experiments/:segments*'
89
+ path: '/experiments/:segments*',
90
+ meta: {
91
+ title: {
92
+ absolute: 'Test · Tests'
93
+ },
94
+ titleSuffix: ''
95
+ }
45
96
  }
46
97
  }
47
98
  }
@@ -53,7 +104,7 @@ export function createExperimentsPlugin(input) {
53
104
  ].map((slug)=>collections.find((collection)=>collection.slug === slug)),
54
105
  ...(config.collections ?? []).map((collection)=>{
55
106
  const puck = options.puck?.enabled && registrations.find((entry)=>entry.slug === collection.slug);
56
- const page = options.pages?.collections.some((entry)=>entry.slug === collection.slug);
107
+ const page = options.pages?.collections.find((entry)=>entry.slug === collection.slug);
57
108
  const blocks = options.blocks?.collections.find((entry)=>entry.slug === collection.slug);
58
109
  if (!puck && !page && !blocks) return collection;
59
110
  return {
@@ -97,6 +148,9 @@ export function createExperimentsPlugin(input) {
97
148
  ...collection.hooks?.afterOperation ?? []
98
149
  ],
99
150
  afterChange: [
151
+ ...page?.copy ? [
152
+ trackPageCopies
153
+ ] : [],
100
154
  ...collection.hooks?.afterChange ?? [],
101
155
  pageGuardAfterChange,
102
156
  contentChangesHook
@@ -0,0 +1,4 @@
1
+ import type { NextRequest } from 'next/server';
2
+ /** A document or an App Router navigation can mint the cookie for its own render. */
3
+ export declare function isPageNavigation({ method, headers }: NextRequest): boolean;
4
+ export declare function looksLikeNormalizedAppRouterRequest({ method, headers }: NextRequest): boolean;
@@ -0,0 +1,28 @@
1
+ /** A document or an App Router navigation can mint the cookie for its own render. */ export function isPageNavigation({ method, headers }) {
2
+ if (method !== 'GET') return false;
3
+ if (headers.has('x-nextjs-data') || headers.has('next-router-prefetch') || headers.has('next-router-segment-prefetch') || headers.has('x-middleware-prefetch') || headers.has('next-hmr-refresh') || headers.get('next-test-fetch-priority') === 'low' || [
4
+ 'purpose',
5
+ 'sec-purpose',
6
+ 'x-moz'
7
+ ].some((name)=>/\b(?:prefetch|prerender)\b/i.test(headers.get(name) ?? ''))) return false;
8
+ const mode = headers.get('sec-fetch-mode');
9
+ const destination = headers.get('sec-fetch-dest');
10
+ if (headers.has('rsc')) {
11
+ // Next sends the router state on navigation and refresh. Explicit full prefetch can
12
+ // share this shape, so hosts must avoid full prefetch on routes covered by the proxy.
13
+ const site = headers.get('sec-fetch-site');
14
+ return headers.get('rsc') === '1' && Boolean(headers.get('next-router-state-tree')) && (mode === null || mode === 'cors' || mode === 'same-origin') && (destination === null || destination === 'empty') && (site === null || site === 'same-origin');
15
+ }
16
+ if (mode !== null && mode !== 'navigate') return false;
17
+ if (destination !== null) return destination === 'document';
18
+ // Older browsers still advertise HTML for a document navigation.
19
+ return (headers.get('accept') ?? '').split(',').some((value)=>{
20
+ const [type, ...params] = value.trim().toLowerCase().split(';');
21
+ return (type === 'text/html' || type === 'application/xhtml+xml') && !params.some((param)=>/^\s*q\s*=\s*0(?:\.0*)?\s*$/.test(param));
22
+ });
23
+ }
24
+ export function looksLikeNormalizedAppRouterRequest({ method, headers }) {
25
+ // Next-Url survives normalization when the App Router sends it for interception.
26
+ // Fetch Metadata and Accept alone also match ordinary same-origin fetches.
27
+ return method === 'GET' && !headers.has('rsc') && headers.get('next-url')?.startsWith('/') === true && headers.get('accept') === '*/*' && headers.get('sec-fetch-mode') === 'cors' && headers.get('sec-fetch-dest') === 'empty' && headers.get('sec-fetch-site') === 'same-origin';
28
+ }
@@ -4,14 +4,17 @@ import { assign, fillFlagPoints } from '../runtime/assign.js';
4
4
  import { sign } from '../runtime/signing.js';
5
5
  import { requestAttributes } from '../runtime/normalisePath.js';
6
6
  import { isBot } from '../runtime/bot.js';
7
- import { cookieAttributes, encodeUnitCookie, mintUnitId, verifyUnitCookie } from '../runtime/cookie.js';
7
+ import { cookieAttributes, encodeUnitCookie, mintUnitId, readSignedUnit, unitCookieMaxAgeMs } from '../runtime/cookie.js';
8
8
  import { encodeAssignmentsHeader } from '../runtime/header.js';
9
9
  import { verifyPreviewToken } from '../runtime/previewToken.js';
10
10
  import { pageRewrite } from './pageRewrite.js';
11
11
  import { skipPath } from './skip.js';
12
12
  import { controlAssignments, emptyAssignments } from './control.js';
13
13
  import { consentFallback } from './consentFallback.js';
14
+ import { isPageNavigation, looksLikeNormalizedAppRouterRequest } from './pageNavigation.js';
15
+ import { assertCookieOptions } from '../runtime/cookieOptions.js';
14
16
  const caches = new WeakMap();
17
+ let warnedAboutUrlNormalization = false;
15
18
  export async function resolveExperiments(request, proxyRuntime) {
16
19
  const requestHeaders = new Headers(request.headers);
17
20
  const result = {
@@ -23,38 +26,62 @@ export async function resolveExperiments(request, proxyRuntime) {
23
26
  ...requestHeaders.keys()
24
27
  ])if (name.startsWith('x-xp-')) requestHeaders.delete(name);
25
28
  if (skipPath(request.nextUrl.pathname, proxyRuntime.apiRoute)) return result;
29
+ assertCookieOptions(proxyRuntime.cookie);
30
+ const name = proxyRuntime.cookie.name;
31
+ if (!warnedAboutUrlNormalization && !request.cookies.has(name) && looksLikeNormalizedAppRouterRequest(request)) {
32
+ warnedAboutUrlNormalization = true;
33
+ console.warn('[payload-experiments] Next.js may be stripping App Router headers. Set skipProxyUrlNormalize: true in your Next.js config. Without it, visitors who follow in-site links or continue after consent without a full page load wait until their next full page load to enroll in tests.');
34
+ }
35
+ const bot = isBot(request.headers.get('user-agent'));
26
36
  let consent = false;
27
37
  try {
28
38
  consent = proxyRuntime.cookie.consent?.(request) !== false;
29
39
  } catch {
30
40
  console.error('[payload-experiments] consent failed; treating consent as false');
31
41
  }
32
- const requestContext = `${request.method}|${request.nextUrl.pathname}${request.nextUrl.search}|${consent ? 'c1' : 'c0'}`;
42
+ const nowMs = Date.now();
43
+ const signedUnit = consent ? readSignedUnit(request, proxyRuntime, nowMs) : null;
44
+ let visitorId = signedUnit?.unitId;
45
+ let cookieValue;
46
+ if (consent && !signedUnit && !bot && isPageNavigation(request)) {
47
+ try {
48
+ const limit = proxyRuntime.rateLimitUnit;
49
+ if (limit === false || await limit?.(request) === true) {
50
+ const id = mintUnitId();
51
+ cookieValue = encodeUnitCookie(id, proxyRuntime.secrets);
52
+ visitorId = id;
53
+ }
54
+ } catch {
55
+ console.error('[payload-experiments] visitor ID issuance failed');
56
+ }
57
+ } else if (signedUnit && (signedUnit.renewedAtMs === null || nowMs - signedUnit.renewedAtMs >= unitCookieMaxAgeMs(proxyRuntime) / 2)) {
58
+ cookieValue = encodeUnitCookie(signedUnit.unitId, proxyRuntime.secrets, signedUnit.issuedAtMs, nowMs);
59
+ }
60
+ // Consent applies to both unit types. Issuance only controls the visitor ID.
61
+ // Keep Next's Flight cache key out of the signed context and preserve the app's raw query.
62
+ const query = request.nextUrl.search.slice(1).split('&').filter((part)=>part !== '_rsc' && !part.startsWith('_rsc=')).join('&');
63
+ const requestPath = query ? `${request.nextUrl.pathname}?${query}` : request.nextUrl.pathname;
64
+ const requestContext = `${request.method}|${requestPath}|${consent ? 'c1' : 'c0'}`;
33
65
  const signedContext = `${requestContext}|${sign(`xp:request:${requestContext}`, proxyRuntime.secrets)}`;
34
66
  if (Buffer.byteLength(signedContext) <= 2048) requestHeaders.set(XP_REQUEST_HEADER, signedContext);
35
- const name = proxyRuntime.cookie.name;
36
- let visitorId = consent ? verifyUnitCookie(request.cookies.get(name)?.value, proxyRuntime.secrets) ?? undefined : undefined;
37
- if (!consent) {
67
+ if (!visitorId || cookieValue) {
38
68
  const cookies = (requestHeaders.get('cookie') ?? '').split(';').map((cookie)=>cookie.trim()).filter((cookie)=>cookie && cookie.split('=', 1)[0]?.trim() !== name);
69
+ if (cookieValue) {
70
+ result.requestCookies.push({
71
+ name,
72
+ value: cookieValue
73
+ });
74
+ result.setCookies.push({
75
+ name,
76
+ value: cookieValue,
77
+ ...cookieAttributes(proxyRuntime, {
78
+ https: request.nextUrl.protocol === 'https:'
79
+ })
80
+ });
81
+ cookies.push(`${name}=${cookieValue}`);
82
+ }
39
83
  if (cookies.length) requestHeaders.set('cookie', cookies.join('; '));
40
84
  else requestHeaders.delete('cookie');
41
- } else if (!visitorId) {
42
- visitorId = mintUnitId();
43
- const value = encodeUnitCookie(visitorId, proxyRuntime.secrets);
44
- result.requestCookies.push({
45
- name,
46
- value
47
- });
48
- result.setCookies.push({
49
- name,
50
- value,
51
- ...cookieAttributes(proxyRuntime, {
52
- https: request.nextUrl.protocol === 'https:'
53
- })
54
- });
55
- const cookies = (request.headers.get('cookie') ?? '').split(';').map((cookie)=>cookie.trim()).filter((cookie)=>cookie && cookie.split('=', 1)[0] !== name);
56
- cookies.push(`${name}=${value}`);
57
- requestHeaders.set('cookie', cookies.join('; '));
58
85
  }
59
86
  let resolvedUnit = {
60
87
  attributes: {}
@@ -92,7 +119,7 @@ export async function resolveExperiments(request, proxyRuntime) {
92
119
  visitorId,
93
120
  userId,
94
121
  staff: attributes.staff === true,
95
- bot: isBot(request.headers.get('user-agent')),
122
+ bot,
96
123
  preview: Boolean(previewExperiment),
97
124
  sessionUnknown: sessionUnknown ?? false,
98
125
  method: request.method
@@ -103,7 +130,7 @@ export async function resolveExperiments(request, proxyRuntime) {
103
130
  try {
104
131
  assignments = consentFallback(currentManifest, attributes, context);
105
132
  } catch {
106
- console.error('[payload-experiments] consent fallback failed; serving non-exposable control');
133
+ console.error('[payload-experiments] identity-free fallback failed; serving non-exposable control');
107
134
  assignmentFailed = true;
108
135
  try {
109
136
  assignments = controlAssignments(currentManifest, context);
@@ -132,7 +159,7 @@ export async function resolveExperiments(request, proxyRuntime) {
132
159
  }
133
160
  }
134
161
  if (previewExperiment && token) {
135
- if (consent && !assignmentFailed) {
162
+ if (visitorId && !assignmentFailed) {
136
163
  assignments.deferred = assignments.deferred.filter((slug)=>slug !== previewExperiment.slug);
137
164
  assignments.bySlug[previewExperiment.slug] = {
138
165
  slug: previewExperiment.slug,
@@ -1,25 +1,25 @@
1
1
  import type { DocId } from '../../types/contracts.js';
2
+ import type { BlockVersionContent } from '../../testSurface/surface/contracts.js';
2
3
  import type { resolvePuckRoutes } from '../routes.js';
3
4
  import './editor.css';
4
5
  type ConfigureRoutes = ReturnType<typeof resolvePuckRoutes> & {
5
6
  contentLocale?: string;
6
7
  };
7
- export declare function ConfigureTestDrawer({ id, routes, onClose }: {
8
+ export declare function ConfigureTestDrawer({ id, routes, versionContent, onClose }: {
8
9
  id: DocId;
9
10
  routes: ConfigureRoutes;
11
+ versionContent?: BlockVersionContent;
10
12
  onClose: () => void;
11
13
  }): import("react").JSX.Element;
12
14
  /** Separate document root, like the creation dialog: Puck has no ancestor handlers here. */
13
- export declare function openConfigureTestDrawer(source: HTMLElement, routes: ConfigureRoutes, id: DocId): {
15
+ export declare function openConfigureTestDrawer(source: HTMLElement, routes: ConfigureRoutes, id: DocId, versionContent?: BlockVersionContent, onClose?: () => void): {
14
16
  close: () => void;
17
+ updateVersionContent: (content: BlockVersionContent | undefined) => void;
15
18
  };
16
19
  /** The canvas already has current permissions; use them without a second read. */
17
- export declare function ConfigureTestControl({ id, routes }: {
20
+ export declare function ConfigureTestControl({ id, routes, versionContent }: {
18
21
  id: DocId;
19
22
  routes: ConfigureRoutes;
23
+ versionContent?: BlockVersionContent;
20
24
  }): import("react").JSX.Element;
21
- export declare function ConfigureTestButton({ id, routes }: {
22
- id: DocId;
23
- routes: ConfigureRoutes;
24
- }): import("react").JSX.Element | null;
25
25
  export {};
@@ -7,12 +7,12 @@ import { TestSurface } from '../../testSurface/surface/test/TestSurface.js';
7
7
  import { Drawer } from '../../ui/Drawer.js';
8
8
  import { Button } from '../../ui/Button.js';
9
9
  import { TEST_PAGE } from '../../testSurface/copy/testPage.js';
10
- import { readSurface, useEditorSurface } from './editorSurface.js';
10
+ import { readSurface } from './editorSurface.js';
11
11
  import { editorCopy as C } from './copy.js';
12
12
  import { publishExperiment } from './armsCache.js';
13
13
  import { readEditorPreflight } from './placementsCache.js';
14
14
  import './editor.css';
15
- export function ConfigureTestDrawer({ id, routes, onClose }) {
15
+ export function ConfigureTestDrawer({ id, routes, versionContent, onClose }) {
16
16
  const [title, setTitle] = useState(C.configure);
17
17
  const [state, setState] = useState({});
18
18
  const [attempt, setAttempt] = useState(0);
@@ -24,8 +24,7 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
24
24
  surface: {
25
25
  ...result.surface,
26
26
  adminRoute: routes.admin,
27
- apiRoute: routes.api,
28
- contentLocale: routes.contentLocale
27
+ apiRoute: routes.api
29
28
  }
30
29
  } : result);
31
30
  });
@@ -35,12 +34,14 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
35
34
  }, [
36
35
  routes.api,
37
36
  routes.admin,
38
- routes.contentLocale,
39
37
  attempt
40
38
  ]);
41
39
  // Unknown permissions use the test page's authoritative admin access check.
42
40
  const testUrl = `${routes.admin}/experiments/${encodeURIComponent(id)}`;
43
41
  const openUrl = state.surface && !state.surface.canManage && state.surface.canReadResults ? `${testUrl}/results` : testUrl;
42
+ const editorPage = versionContent ? {
43
+ versionContent
44
+ } : undefined;
44
45
  return /*#__PURE__*/ _jsx(Drawer, {
45
46
  title: title,
46
47
  closeLabel: C.closeConfigure,
@@ -65,7 +66,11 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
65
66
  },
66
67
  children: state.surface ? /*#__PURE__*/ _jsx(TestSurface, {
67
68
  id: id,
68
- surface: state.surface,
69
+ surface: {
70
+ ...state.surface,
71
+ contentLocale: routes.contentLocale,
72
+ editorPage
73
+ },
69
74
  embedded: true,
70
75
  onTitleChange: setTitle,
71
76
  onDocument: (doc)=>publishExperiment(id, doc),
@@ -85,7 +90,7 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
85
90
  })
86
91
  });
87
92
  }
88
- /** Separate document root, like the creation dialog: Puck has no ancestor handlers here. */ export function openConfigureTestDrawer(source, routes, id) {
93
+ /** Separate document root, like the creation dialog: Puck has no ancestor handlers here. */ export function openConfigureTestDrawer(source, routes, id, versionContent, onClose) {
89
94
  // A canvas iframe's modal would cover only the canvas. Mount over the whole editor.
90
95
  const doc = source.ownerDocument.defaultView?.frameElement?.ownerDocument ?? source.ownerDocument;
91
96
  const container = doc.createElement('div');
@@ -108,42 +113,48 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
108
113
  container.remove();
109
114
  if (source.isConnected) source.focus();
110
115
  });
116
+ onClose?.();
111
117
  };
112
- root.render(/*#__PURE__*/ _jsx("div", {
113
- onClick: (event)=>event.stopPropagation(),
114
- onKeyDown: (event)=>event.stopPropagation(),
115
- onPointerMove: (event)=>event.stopPropagation(),
116
- onPointerUp: (event)=>event.stopPropagation(),
117
- children: /*#__PURE__*/ _jsx(ConfigureTestDrawer, {
118
- id: id,
119
- routes: routes,
120
- onClose: close
121
- })
122
- }));
118
+ const updateVersionContent = (content)=>{
119
+ if (closed) return;
120
+ root.render(/*#__PURE__*/ _jsx("div", {
121
+ onClick: (event)=>event.stopPropagation(),
122
+ onKeyDown: (event)=>event.stopPropagation(),
123
+ onPointerMove: (event)=>event.stopPropagation(),
124
+ onPointerUp: (event)=>event.stopPropagation(),
125
+ children: /*#__PURE__*/ _jsx(ConfigureTestDrawer, {
126
+ id: id,
127
+ routes: routes,
128
+ versionContent: content,
129
+ onClose: close
130
+ })
131
+ }));
132
+ };
133
+ updateVersionContent(versionContent);
123
134
  return {
124
- close
135
+ close,
136
+ updateVersionContent
125
137
  };
126
138
  }
127
- /** The canvas already has current permissions; use them without a second read. */ export function ConfigureTestControl({ id, routes }) {
139
+ /** The canvas already has current permissions; use them without a second read. */ export function ConfigureTestControl({ id, routes, versionContent }) {
128
140
  const drawer = useRef(undefined);
129
141
  useEffect(()=>()=>drawer.current?.close(), [
130
142
  id,
131
143
  routes.api
132
144
  ]);
145
+ useEffect(()=>{
146
+ drawer.current?.updateVersionContent(versionContent);
147
+ }, [
148
+ versionContent
149
+ ]);
133
150
  return /*#__PURE__*/ _jsx(Button, {
134
151
  variant: "primary",
135
152
  onClick: (event)=>{
136
153
  drawer.current?.close();
137
- drawer.current = openConfigureTestDrawer(event.currentTarget, routes, id);
154
+ drawer.current = openConfigureTestDrawer(event.currentTarget, routes, id, versionContent, ()=>{
155
+ drawer.current = undefined;
156
+ });
138
157
  },
139
158
  children: C.configure
140
159
  });
141
160
  }
142
- export function ConfigureTestButton({ id, routes }) {
143
- const access = useEditorSurface(routes.api);
144
- if (!access.surface || !access.surface.canManage && !access.surface.canReadResults) return null;
145
- return /*#__PURE__*/ _jsx(ConfigureTestControl, {
146
- id: id,
147
- routes: routes
148
- });
149
- }
@@ -1,4 +1,5 @@
1
1
  import { type ComponentConfig } from '@puckeditor/core';
2
+ import { type ReactNode } from 'react';
2
3
  import type { ExperimentSlotProps } from '../../types/puck.js';
3
4
  import { type PuckRoutes } from '../routes.js';
4
5
  import './editor.css';
@@ -12,7 +13,7 @@ export declare const ExperimentSlotEditor: {
12
13
  defaultProps?: ExperimentSlotProps | undefined;
13
14
  fields?: import("@puckeditor/core").Fields<ExperimentSlotProps, {}> | undefined;
14
15
  renderFields?: ((props: {
15
- fields: Partial<Record<keyof ExperimentSlotProps, import("react").ReactNode>>;
16
+ fields: Partial<Record<keyof ExperimentSlotProps, ReactNode>>;
16
17
  }) => import("react").ReactElement) | undefined;
17
18
  permissions?: Partial<import("@puckeditor/core").Permissions>;
18
19
  inline?: boolean;