@encorekit/web-sdk 2.3.0 → 2.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 (265) hide show
  1. package/README.md +66 -1
  2. package/dist/cjs/index.cjs +1 -1
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/preview.cjs +2 -0
  5. package/dist/cjs/preview.cjs.map +1 -0
  6. package/dist/cjs/react.cjs +1 -1
  7. package/dist/cjs/react.cjs.map +1 -1
  8. package/dist/esm/chunks/ClaimReminder-DFyrm5bJ.js +2 -0
  9. package/dist/esm/chunks/ClaimReminder-DFyrm5bJ.js.map +1 -0
  10. package/dist/esm/chunks/GiftsButton-B0lVB463.js +2 -0
  11. package/dist/esm/chunks/GiftsButton-B0lVB463.js.map +1 -0
  12. package/dist/esm/chunks/TriggerHost-CNTiNrTH.js +2 -0
  13. package/dist/esm/chunks/TriggerHost-CNTiNrTH.js.map +1 -0
  14. package/dist/esm/chunks/autoPops-CngtK_R0.js +2 -0
  15. package/dist/esm/chunks/autoPops-CngtK_R0.js.map +1 -0
  16. package/dist/esm/chunks/customClaim-B4uj-aOc.js +2 -0
  17. package/dist/esm/chunks/customClaim-B4uj-aOc.js.map +1 -0
  18. package/dist/esm/chunks/eligibility-BY7fL8Ve.js +2 -0
  19. package/dist/esm/chunks/eligibility-BY7fL8Ve.js.map +1 -0
  20. package/dist/esm/chunks/index-CaBSqauy.js +2 -0
  21. package/dist/esm/chunks/index-CaBSqauy.js.map +1 -0
  22. package/dist/esm/chunks/lookValues-B9z2VWpH.js +2 -0
  23. package/dist/esm/chunks/lookValues-B9z2VWpH.js.map +1 -0
  24. package/dist/esm/chunks/sduiView-Ds7QtFId.js +2 -0
  25. package/dist/esm/chunks/sduiView-Ds7QtFId.js.map +1 -0
  26. package/dist/esm/chunks/spot-DkKMLpB-.js +2 -0
  27. package/dist/esm/chunks/spot-DkKMLpB-.js.map +1 -0
  28. package/dist/esm/chunks/template-B9p4CbPD.js +2 -0
  29. package/dist/esm/chunks/template-B9p4CbPD.js.map +1 -0
  30. package/dist/esm/chunks/textSlots-BnwxUg9V.js +2 -0
  31. package/dist/esm/chunks/textSlots-BnwxUg9V.js.map +1 -0
  32. package/dist/esm/chunks/timers-Bva4yoGM.js +2 -0
  33. package/dist/esm/chunks/timers-Bva4yoGM.js.map +1 -0
  34. package/dist/esm/index.js +1 -1
  35. package/dist/esm/index.js.map +1 -1
  36. package/dist/esm/preview.js +2 -0
  37. package/dist/esm/preview.js.map +1 -0
  38. package/dist/esm/react.js +1 -1
  39. package/dist/esm/react.js.map +1 -1
  40. package/dist/umd/encore.min.js +1 -1
  41. package/dist/umd/encore.min.js.map +1 -1
  42. package/package.json +9 -1
  43. package/types/analytics/DiagnosticsOutbox.d.ts +1 -0
  44. package/types/analytics/DiagnosticsOutbox.d.ts.map +1 -1
  45. package/types/analytics/events.d.ts +105 -5
  46. package/types/analytics/events.d.ts.map +1 -1
  47. package/types/analytics/models.d.ts +2 -0
  48. package/types/analytics/models.d.ts.map +1 -1
  49. package/types/analytics/transport.d.ts +6 -0
  50. package/types/analytics/transport.d.ts.map +1 -1
  51. package/types/api/APIClient.d.ts +58 -3
  52. package/types/api/APIClient.d.ts.map +1 -1
  53. package/types/api/contract.d.ts +4 -1
  54. package/types/api/contract.d.ts.map +1 -1
  55. package/types/api/generated/types.d.ts +420 -39
  56. package/types/api/generated/types.d.ts.map +1 -1
  57. package/types/api/models.d.ts +18 -2
  58. package/types/api/models.d.ts.map +1 -1
  59. package/types/api/offerBuilder.d.ts +10 -4
  60. package/types/api/offerBuilder.d.ts.map +1 -1
  61. package/types/core/Encore.d.ts +145 -3
  62. package/types/core/Encore.d.ts.map +1 -1
  63. package/types/core/OfferManager.d.ts +25 -3
  64. package/types/core/OfferManager.d.ts.map +1 -1
  65. package/types/core/PlacementBuilder.d.ts +6 -1
  66. package/types/core/PlacementBuilder.d.ts.map +1 -1
  67. package/types/core/SignalManager.d.ts.map +1 -1
  68. package/types/core/StorageManager.d.ts +3 -2
  69. package/types/core/StorageManager.d.ts.map +1 -1
  70. package/types/core/StrictUnlockReconciler.d.ts +1 -1
  71. package/types/core/StrictUnlockReconciler.d.ts.map +1 -1
  72. package/types/core/claimHandle.d.ts +44 -0
  73. package/types/core/claimHandle.d.ts.map +1 -0
  74. package/types/core/claimLog.d.ts +102 -0
  75. package/types/core/claimLog.d.ts.map +1 -0
  76. package/types/core/claimRefusal.d.ts +3 -0
  77. package/types/core/claimRefusal.d.ts.map +1 -0
  78. package/types/core/claimStatusCheck.d.ts +62 -0
  79. package/types/core/claimStatusCheck.d.ts.map +1 -0
  80. package/types/core/giftVariant.d.ts +5 -0
  81. package/types/core/giftVariant.d.ts.map +1 -1
  82. package/types/core/hostDisplay.d.ts +9 -2
  83. package/types/core/hostDisplay.d.ts.map +1 -1
  84. package/types/core/sduiVariables.d.ts +20 -0
  85. package/types/core/sduiVariables.d.ts.map +1 -0
  86. package/types/core/strings.d.ts +114 -0
  87. package/types/core/strings.d.ts.map +1 -0
  88. package/types/core/unlockCode.d.ts +8 -1
  89. package/types/core/unlockCode.d.ts.map +1 -1
  90. package/types/core/userKeys.d.ts +7 -0
  91. package/types/core/userKeys.d.ts.map +1 -0
  92. package/types/core/version.d.ts +1 -1
  93. package/types/experiments/ExposureOutbox.d.ts +1 -0
  94. package/types/experiments/ExposureOutbox.d.ts.map +1 -1
  95. package/types/preview.d.ts +51 -0
  96. package/types/preview.d.ts.map +1 -0
  97. package/types/react.d.ts +53 -1
  98. package/types/react.d.ts.map +1 -1
  99. package/types/sdui/actions.d.ts +93 -0
  100. package/types/sdui/actions.d.ts.map +1 -0
  101. package/types/sdui/bindings.d.ts +63 -0
  102. package/types/sdui/bindings.d.ts.map +1 -0
  103. package/types/sdui/compile.d.ts +88 -0
  104. package/types/sdui/compile.d.ts.map +1 -0
  105. package/types/sdui/conditions.d.ts +22 -0
  106. package/types/sdui/conditions.d.ts.map +1 -0
  107. package/types/sdui/context.d.ts +132 -0
  108. package/types/sdui/context.d.ts.map +1 -0
  109. package/types/sdui/countdown.d.ts +31 -0
  110. package/types/sdui/countdown.d.ts.map +1 -0
  111. package/types/sdui/decode.d.ts +35 -0
  112. package/types/sdui/decode.d.ts.map +1 -0
  113. package/types/sdui/deps.d.ts +43 -0
  114. package/types/sdui/deps.d.ts.map +1 -0
  115. package/types/sdui/dominantColor.d.ts +24 -0
  116. package/types/sdui/dominantColor.d.ts.map +1 -0
  117. package/types/sdui/elements/confetti.d.ts +38 -0
  118. package/types/sdui/elements/confetti.d.ts.map +1 -0
  119. package/types/sdui/elements/content.d.ts +27 -0
  120. package/types/sdui/elements/content.d.ts.map +1 -0
  121. package/types/sdui/elements/interactive.d.ts +48 -0
  122. package/types/sdui/elements/interactive.d.ts.map +1 -0
  123. package/types/sdui/elements/layout.d.ts +41 -0
  124. package/types/sdui/elements/layout.d.ts.map +1 -0
  125. package/types/sdui/elements/marquee.d.ts +17 -0
  126. package/types/sdui/elements/marquee.d.ts.map +1 -0
  127. package/types/sdui/elements/progress.d.ts +10 -0
  128. package/types/sdui/elements/progress.d.ts.map +1 -0
  129. package/types/sdui/elements/shared.d.ts +138 -0
  130. package/types/sdui/elements/shared.d.ts.map +1 -0
  131. package/types/sdui/elements/symbols.d.ts +22 -0
  132. package/types/sdui/elements/symbols.d.ts.map +1 -0
  133. package/types/sdui/elements/triggerText.d.ts +55 -0
  134. package/types/sdui/elements/triggerText.d.ts.map +1 -0
  135. package/types/sdui/host.d.ts +274 -0
  136. package/types/sdui/host.d.ts.map +1 -0
  137. package/types/sdui/inlineMarkup.d.ts +22 -0
  138. package/types/sdui/inlineMarkup.d.ts.map +1 -0
  139. package/types/sdui/lookValues.d.ts +50 -0
  140. package/types/sdui/lookValues.d.ts.map +1 -0
  141. package/types/sdui/model.d.ts +130 -0
  142. package/types/sdui/model.d.ts.map +1 -0
  143. package/types/sdui/motion.d.ts +37 -0
  144. package/types/sdui/motion.d.ts.map +1 -0
  145. package/types/sdui/precheck.d.ts +94 -0
  146. package/types/sdui/precheck.d.ts.map +1 -0
  147. package/types/sdui/scrollMath.d.ts +32 -0
  148. package/types/sdui/scrollMath.d.ts.map +1 -0
  149. package/types/sdui/style.d.ts +99 -0
  150. package/types/sdui/style.d.ts.map +1 -0
  151. package/types/sdui/triggerKit.d.ts +24 -0
  152. package/types/sdui/triggerKit.d.ts.map +1 -0
  153. package/types/sdui/unrunnable.d.ts +11 -0
  154. package/types/sdui/unrunnable.d.ts.map +1 -0
  155. package/types/sdui/vocabulary.d.ts +119 -0
  156. package/types/sdui/vocabulary.d.ts.map +1 -0
  157. package/types/triggers/claimReminder/ClaimReminder.d.ts +65 -0
  158. package/types/triggers/claimReminder/ClaimReminder.d.ts.map +1 -0
  159. package/types/triggers/claimReminder/bindings.d.ts +40 -0
  160. package/types/triggers/claimReminder/bindings.d.ts.map +1 -0
  161. package/types/triggers/claimReminder/config.d.ts +56 -0
  162. package/types/triggers/claimReminder/config.d.ts.map +1 -0
  163. package/types/triggers/claimReminder/eligibility.d.ts +37 -0
  164. package/types/triggers/claimReminder/eligibility.d.ts.map +1 -0
  165. package/types/triggers/claimReminder/servedWindow.d.ts +15 -0
  166. package/types/triggers/claimReminder/servedWindow.d.ts.map +1 -0
  167. package/types/triggers/claimReminder/source.d.ts +29 -0
  168. package/types/triggers/claimReminder/source.d.ts.map +1 -0
  169. package/types/triggers/giftsButton/GiftsButton.d.ts +60 -0
  170. package/types/triggers/giftsButton/GiftsButton.d.ts.map +1 -0
  171. package/types/triggers/giftsButton/config.d.ts +53 -0
  172. package/types/triggers/giftsButton/config.d.ts.map +1 -0
  173. package/types/triggers/giftsButton/spot.d.ts +54 -0
  174. package/types/triggers/giftsButton/spot.d.ts.map +1 -0
  175. package/types/triggers/host/TriggerHost.d.ts +127 -0
  176. package/types/triggers/host/TriggerHost.d.ts.map +1 -0
  177. package/types/triggers/host/autoPops.d.ts +16 -0
  178. package/types/triggers/host/autoPops.d.ts.map +1 -0
  179. package/types/triggers/host/configCache.d.ts +29 -0
  180. package/types/triggers/host/configCache.d.ts.map +1 -0
  181. package/types/triggers/host/customClaim.d.ts +85 -0
  182. package/types/triggers/host/customClaim.d.ts.map +1 -0
  183. package/types/triggers/host/dismissStore.d.ts +37 -0
  184. package/types/triggers/host/dismissStore.d.ts.map +1 -0
  185. package/types/triggers/host/readThrottle.d.ts +15 -0
  186. package/types/triggers/host/readThrottle.d.ts.map +1 -0
  187. package/types/triggers/host/registry.d.ts +17 -0
  188. package/types/triggers/host/registry.d.ts.map +1 -0
  189. package/types/triggers/host/sduiView.d.ts +31 -0
  190. package/types/triggers/host/sduiView.d.ts.map +1 -0
  191. package/types/triggers/host/template.d.ts +28 -0
  192. package/types/triggers/host/template.d.ts.map +1 -0
  193. package/types/triggers/host/textSlots.d.ts +35 -0
  194. package/types/triggers/host/textSlots.d.ts.map +1 -0
  195. package/types/triggers/host/theme.d.ts +87 -0
  196. package/types/triggers/host/theme.d.ts.map +1 -0
  197. package/types/triggers/host/timers.d.ts +11 -0
  198. package/types/triggers/host/timers.d.ts.map +1 -0
  199. package/types/triggers/host/types.d.ts +278 -0
  200. package/types/triggers/host/types.d.ts.map +1 -0
  201. package/types/triggers/host/wire.d.ts +55 -0
  202. package/types/triggers/host/wire.d.ts.map +1 -0
  203. package/types/triggers/preview.d.ts +78 -0
  204. package/types/triggers/preview.d.ts.map +1 -0
  205. package/types/triggers/request.d.ts +53 -0
  206. package/types/triggers/request.d.ts.map +1 -0
  207. package/types/types.d.ts +329 -1
  208. package/types/types.d.ts.map +1 -1
  209. package/types/ui/ClaimScreen.d.ts +1 -1
  210. package/types/ui/ClaimScreen.d.ts.map +1 -1
  211. package/types/ui/CodeUnlock.d.ts +12 -2
  212. package/types/ui/CodeUnlock.d.ts.map +1 -1
  213. package/types/ui/GiftHero.d.ts.map +1 -1
  214. package/types/ui/GiftList.d.ts.map +1 -1
  215. package/types/ui/GiftPicker.d.ts.map +1 -1
  216. package/types/ui/GiftPickerHero.d.ts.map +1 -1
  217. package/types/ui/GiftReveal.d.ts.map +1 -1
  218. package/types/ui/GiftSheet.d.ts +5 -5
  219. package/types/ui/GiftSheet.d.ts.map +1 -1
  220. package/types/ui/GiftUnwrap.d.ts.map +1 -1
  221. package/types/ui/OfferCard.d.ts.map +1 -1
  222. package/types/ui/OfferCarousel.d.ts.map +1 -1
  223. package/types/ui/OfferModal.d.ts +31 -0
  224. package/types/ui/OfferModal.d.ts.map +1 -1
  225. package/types/ui/PrimerScreen.d.ts +2 -0
  226. package/types/ui/PrimerScreen.d.ts.map +1 -1
  227. package/types/ui/RedemptionScreen.d.ts +5 -0
  228. package/types/ui/RedemptionScreen.d.ts.map +1 -1
  229. package/types/ui/RewardActions.d.ts.map +1 -1
  230. package/types/ui/RewardCard.d.ts.map +1 -1
  231. package/types/ui/SduiRewardSurface.d.ts +145 -0
  232. package/types/ui/SduiRewardSurface.d.ts.map +1 -0
  233. package/types/ui/Tooltip.d.ts.map +1 -1
  234. package/types/ui/brandComponents.d.ts.map +1 -1
  235. package/types/ui/brandTint.d.ts.map +1 -1
  236. package/types/ui/colorScheme.d.ts +15 -0
  237. package/types/ui/colorScheme.d.ts.map +1 -0
  238. package/types/ui/covered.d.ts +12 -0
  239. package/types/ui/covered.d.ts.map +1 -0
  240. package/types/ui/giftCategoryGroups.d.ts +13 -0
  241. package/types/ui/giftCategoryGroups.d.ts.map +1 -1
  242. package/types/ui/giftCopy.d.ts +14 -9
  243. package/types/ui/giftCopy.d.ts.map +1 -1
  244. package/types/ui/giftUnwrapCopy.d.ts.map +1 -1
  245. package/types/ui/imageURL.d.ts +44 -0
  246. package/types/ui/imageURL.d.ts.map +1 -0
  247. package/types/ui/impressionGate.d.ts +9 -0
  248. package/types/ui/impressionGate.d.ts.map +1 -1
  249. package/types/ui/offerBadge.d.ts.map +1 -1
  250. package/types/ui/rewardSurface.d.ts +11 -1
  251. package/types/ui/rewardSurface.d.ts.map +1 -1
  252. package/types/ui/sduiTheme.d.ts +48 -0
  253. package/types/ui/sduiTheme.d.ts.map +1 -0
  254. package/types/ui/sheetDetents.d.ts +28 -0
  255. package/types/ui/sheetDetents.d.ts.map +1 -0
  256. package/types/ui/styles.d.ts +11 -8
  257. package/types/ui/styles.d.ts.map +1 -1
  258. package/types/ui/termsLine.d.ts +3 -3
  259. package/types/ui/termsLine.d.ts.map +1 -1
  260. package/types/ui/toast.d.ts +11 -0
  261. package/types/ui/toast.d.ts.map +1 -0
  262. package/types/utils/logger.d.ts +10 -0
  263. package/types/utils/logger.d.ts.map +1 -1
  264. package/types/utils/text.d.ts +17 -0
  265. package/types/utils/text.d.ts.map +1 -1
@@ -0,0 +1,278 @@
1
+ /**
2
+ * The trigger plug-in interface. INTERNAL: triggers ship inside the SDK and are
3
+ * registered by id; a host app only names the id (`Encore.triggers.mount(id, ...)`).
4
+ *
5
+ * The host (TriggerHost.ts) owns everything every trigger shares: the unknown-id
6
+ * no-op, the pre-config gate, the `/config` request and envelope check, visibility and
7
+ * the `sdk_trigger_*` events, the dismiss store, identity and language re-runs, and
8
+ * never throwing into the page. A plug-in owns only what is its own: what it needs
9
+ * before asking for a variant, how it reads its template, what one render shows, what
10
+ * a tap does, and how it draws.
11
+ *
12
+ * Same shape as iOS and Android (generic-contract.md, "Plug-in interface"), with one
13
+ * web difference: `onTap` STARTS synchronously, because a browser only opens a tab
14
+ * from inside the click that asked for it, so a sheet is presented before its first
15
+ * await. It may return a promise (a sheet that must close first).
16
+ */
17
+ import type { AppearanceConfig, PublisherReward, ShowResult, UseCase } from '../../types';
18
+ import type { TriggerRequest, TriggerState } from '../request';
19
+ import type { NotShownReason } from './wire';
20
+ import type { TriggerPortalTheme } from './theme';
21
+ /** The mount's free-form options (`mount(id, el, { options })`), for future plug-ins. */
22
+ export type TriggerOptionValues = Readonly<Record<string, string>>;
23
+ /**
24
+ * What a plug-in remembers for one mount and one identity (a plug-in is shared by every
25
+ * mount). Empty again after an identity change; kept across a language change, so a
26
+ * decision (an automatic pop already made) survives it. Null prototype.
27
+ */
28
+ export type TriggerMountState = Record<string, unknown>;
29
+ /**
30
+ * Whether the sheet a trigger opens would open with offers for this user, by the SDK's
31
+ * own path (its config, then an offer search held for the tap): `offers` names the
32
+ * campaigns it holds; `sheet_unavailable` when the server says the sheet has nothing to
33
+ * serve; `none` for no offers or any failure.
34
+ */
35
+ export type SheetCheck = {
36
+ status: 'offers';
37
+ campaignIds: ReadonlySet<string>;
38
+ /** The held offers in sheet order, with what a trigger may show of each. */
39
+ offers?: readonly HeldOffer[];
40
+ } | {
41
+ status: 'none';
42
+ } | {
43
+ status: 'sheet_unavailable';
44
+ };
45
+ /** One offer the sheet holds, as a trigger may show it. */
46
+ export interface HeldOffer {
47
+ campaignId: string;
48
+ advertiserName?: string;
49
+ logoUrl?: string;
50
+ }
51
+ export interface TriggerPrepareContext {
52
+ now: number;
53
+ /** What this mount asks for: its use case, a pinned layout, its auto-open opt-out. */
54
+ request: TriggerRequest;
55
+ /** This trigger's dismissed content keys on this device. */
56
+ dismissed: ReadonlySet<string>;
57
+ options: TriggerOptionValues;
58
+ /** The mount's placement id, as the host app passed it. */
59
+ placement: string | undefined;
60
+ mountState: TriggerMountState;
61
+ /** Another trigger's dismissed content keys on this device (the reminder a GiftsButton spot may draw). */
62
+ dismissedOf(triggerId: string): ReadonlySet<string>;
63
+ }
64
+ export interface TriggerPrepareContextWithReport extends TriggerPrepareContext {
65
+ /**
66
+ * Search afresh rather than read a held set: a sheet a trigger opened just closed
67
+ * with a claim, so a held set may still list the claimed offer.
68
+ */
69
+ fresh: boolean;
70
+ /**
71
+ * The user reached this trigger and it would have shown, but `reason` stops it
72
+ * (e.g. the sheet it opens has nothing to serve). Return null after calling it. The host reports it
73
+ * once per (trigger, placement, reason) per local day on this device.
74
+ */
75
+ notShown(reason: NotShownReason): void;
76
+ /**
77
+ * Nothing to show until `at` (epoch ms), say the next local day: the host reads again
78
+ * then, while the page is visible (a hidden page reads on its return anyway). Only
79
+ * the newest read's request stands.
80
+ */
81
+ readAgainAt(at: number): void;
82
+ }
83
+ export interface TriggerPresentContext extends TriggerPrepareContext {
84
+ /** The publisher's colours. They beat the app's portal theme, the look's, and the default. */
85
+ appearance: AppearanceConfig | undefined;
86
+ /** The app's theme set in the portal, as `/config` serves it in `ui.values`. Empty when unset. */
87
+ portal: TriggerPortalTheme;
88
+ /** The mount's `icon` option, as passed (unchecked). */
89
+ icon: unknown;
90
+ /**
91
+ * The user can be at the placement now (page visible, mount attached) and this present
92
+ * follows a fresh read, not the clock. A plug-in acts on its own (an `autoTap`) only then.
93
+ */
94
+ canAutoTap: boolean;
95
+ /**
96
+ * The mount's own `values` for `${values.K}` (already checked: at most 16 keys, plain
97
+ * text). They go over the look's defaults, are filled on the device, and are never
98
+ * sent, logged or stored.
99
+ */
100
+ lookValues: Readonly<Record<string, string>>;
101
+ /**
102
+ * Read again (not only present) at `at`: what was read no longer fits the served look,
103
+ * so the device state should be worked out afresh. The earliest ask of a read stands.
104
+ */
105
+ readAgainAt(at: number): void;
106
+ }
107
+ /** What a plug-in adds to the host's common event fields. */
108
+ export interface TriggerEventFields {
109
+ transactionId?: string;
110
+ campaignId?: string;
111
+ /** The layout actually drawn. */
112
+ layout?: string;
113
+ /**
114
+ * Text slots the look declares that this presentation does not draw (a reminder's headline on a
115
+ * branch that draws another title): left out of `text_slots`, so it names only lines on screen.
116
+ */
117
+ undrawnSlots?: readonly string[];
118
+ }
119
+ /** One render: what to draw, and what the host needs to know about it. */
120
+ export interface TriggerPresentation<Model> {
121
+ model: Model;
122
+ /** Identifies what is shown: viewed once per key per mount, and the key a dismiss stores. */
123
+ contentKey: string;
124
+ eventFields: TriggerEventFields;
125
+ dismissible: boolean;
126
+ /** Epoch ms at which the host must present again (a countdown's end), if any. */
127
+ refreshAt?: number;
128
+ /**
129
+ * A target the host taps by itself once, right after drawing this presentation
130
+ * (a GiftsButton look whose behavior says `autoOpen: on` pops the sheet with `auto`). Not
131
+ * repeated on an in-place update.
132
+ */
133
+ autoTap?: string;
134
+ /**
135
+ * The user was eligible for something this presentation does not show (GiftsButton
136
+ * drawing the pill because another mount already popped today): the host reports the
137
+ * counterfactual with this reason once. What is drawn counts its impressions as usual.
138
+ */
139
+ notShownReason?: NotShownReason;
140
+ /** The counterfactual's own fields when they differ from what is drawn (default `eventFields`). */
141
+ notShownEventFields?: TriggerEventFields;
142
+ /**
143
+ * The trigger this presentation draws, when it is not the mounted one (the reminder look
144
+ * a GiftsButton request was answered with). Its events name it as `trigger`, with the
145
+ * mounted one as `host_trigger`.
146
+ */
147
+ drawnTrigger?: string;
148
+ /**
149
+ * What a dismiss hides: these content keys in `drawnTrigger`'s dismiss store (every claim
150
+ * a reminder in a GiftsButton spot shows). Default: `contentKey` in the mounted trigger's.
151
+ */
152
+ dismissKeys?: readonly string[];
153
+ }
154
+ /** What a tap leaves behind. `refresh` re-runs `prepare` (the content may have changed). */
155
+ export type TriggerTapOutcome = 'keep' | 'refresh';
156
+ /** Present the SDK's own sheet, exactly as the host app's `placement().useCase().show()` would. */
157
+ export interface TriggerSheetRequest {
158
+ /** A public use case name (`rewardUsers`, ...). An unknown one resolves without presenting. */
159
+ useCase: UseCase;
160
+ placement: string | undefined;
161
+ /** Called once if and when the sheet actually opens (never when it does not). */
162
+ onPresented?: () => void;
163
+ }
164
+ /** What the host adds to a plug-in's sheet request: the id, the mount's prize, and liveness. */
165
+ export interface HostSheetRequest extends TriggerSheetRequest {
166
+ presentationId: string;
167
+ /** The trigger opened this sheet by itself: if the mount goes before it shows, it never shows. */
168
+ automatic?: boolean;
169
+ publisherReward?: PublisherReward;
170
+ /** False once the mount is gone or restarted; a sheet still waiting to open then does not. */
171
+ isCurrent: () => boolean;
172
+ }
173
+ export interface TriggerTapContext {
174
+ options: TriggerOptionValues;
175
+ mountState: TriggerMountState;
176
+ /**
177
+ * The id the host minted for the sheet this tap opens (`opensSheet` said yes), already
178
+ * reported on `sdk_trigger_clicked` as `presentation_id`. Absent otherwise.
179
+ */
180
+ presentationId?: string;
181
+ /**
182
+ * Present the Encore sheet under `presentationId`. Resolves when it closes (never
183
+ * rejects). Returning the continuation from `onTap` keeps the tap in flight until then.
184
+ */
185
+ presentSheet(request: TriggerSheetRequest): Promise<ShowResult>;
186
+ }
187
+ /** Handed to `render`: how the drawn view reports user actions to the host. */
188
+ export interface TriggerRenderScope {
189
+ /** A tap on `target` (a trigger-defined name, e.g. `card` or `arrow`). */
190
+ tapped(target: string): void;
191
+ /** The user dismissed what is shown. */
192
+ dismissed(): void;
193
+ /** The clock the view draws its countdowns against. Absent: the device clock (the live host). */
194
+ now?(): number;
195
+ }
196
+ export interface TriggerView<Model> {
197
+ root: HTMLElement;
198
+ /**
199
+ * Show `model` in place (same content key, e.g. a countdown tick). Return false when
200
+ * it cannot be shown in place, and the host draws it afresh.
201
+ */
202
+ update(model: Model): boolean;
203
+ /** Whether any of the view is on screen (to pause motion offscreen). */
204
+ setOnScreen?(onScreen: boolean): void;
205
+ /** A tap is in flight (true) or settled (false): dim and ignore presses meanwhile (motion keeps running). */
206
+ setBusy?(busy: boolean): void;
207
+ }
208
+ export interface TriggerPlugin<Content, Config, Model> {
209
+ /** The trigger id, as variant files name it (`template.trigger`). */
210
+ readonly id: string;
211
+ /** The gate before `/config`: null means nothing to show, and no request is sent. */
212
+ prepare(context: TriggerPrepareContextWithReport): Promise<Content | null>;
213
+ /**
214
+ * The strict pre-check on the raw served template (trigger SDUI contract §5): the
215
+ * first thing this build must not render, or undefined. A failure draws nothing and
216
+ * reports `unrenderable`; `decode` is not called.
217
+ */
218
+ precheck?(template: Record<string, unknown>): {
219
+ reason: string;
220
+ path: string;
221
+ } | undefined;
222
+ /** `ui.template` as this trigger reads it. Null renders nothing. */
223
+ decode(template: Record<string, unknown>): Config | null;
224
+ /**
225
+ * Other triggers whose looks may answer this trigger's request (TRIGGER_ALLOW.renders):
226
+ * a GiftsButton spot may be answered with the reminder look. `precheck`, `decode` and
227
+ * `present` then see that trigger's template; anything else is unrenderable.
228
+ */
229
+ readonly alsoDraws?: readonly string[];
230
+ /**
231
+ * What happened on the device for this content (§2.8), sent as `state` on the one
232
+ * `/config` request: `claimOpen` (an eligible open claim) or `completed` (an offer
233
+ * finished today, none claimed since, its thanks not tapped). The host asks again when
234
+ * it changes. Null: none.
235
+ */
236
+ requestState?(content: Content): TriggerState | null;
237
+ /**
238
+ * The completion a `completed` state is about (its claim's id), so a behavior's hide is
239
+ * reported once per completion. Null otherwise.
240
+ */
241
+ completionOf?(content: Content): string | null;
242
+ /** What to draw now. Null renders nothing. */
243
+ present(content: Content, config: Config, context: TriggerPresentContext): TriggerPresentation<Model> | null;
244
+ /**
245
+ * Whether this tap opens the Encore sheet. Asked before the tap is reported: a yes
246
+ * makes the host mint the sheet's presentation id and put it on the tapped event.
247
+ */
248
+ opensSheet?(model: Model, target: string): boolean;
249
+ /**
250
+ * The tap's side effect, STARTED synchronously inside the click (a browser opens a
251
+ * tab only there). Return a promise to keep the tap in flight until it settles (a
252
+ * sheet that must close first); the host takes no other tap meanwhile.
253
+ */
254
+ onTap(model: Model, target: string, context: TriggerTapContext): TriggerTapOutcome | Promise<TriggerTapOutcome>;
255
+ render(model: Model, scope: TriggerRenderScope): TriggerView<Model>;
256
+ /**
257
+ * An automatic tap (`autoTap`) held behind another sheet never ran: the sheet stayed up
258
+ * for a minute, nothing was drawn when it closed, the identity changed, or the mount
259
+ * was unmounted. The plug-in gives back what it reserved for it (`model` is the one the
260
+ * tap was accepted on); the host presents again unless the mount is going away.
261
+ */
262
+ autoTapAbandoned?(model: Model, target: string, context: TriggerAbandonContext): void;
263
+ }
264
+ export interface TriggerAbandonContext {
265
+ mountState: TriggerMountState;
266
+ placement: string | undefined;
267
+ }
268
+ /** Erased form the registry stores. */
269
+ export type AnyTriggerPlugin = TriggerPlugin<any, any, any>;
270
+ /**
271
+ * A trigger as the registry holds it: its id, and how to load its plug-in. Plug-ins
272
+ * load on first mount, so an app that never mounts one never downloads it.
273
+ */
274
+ export interface TriggerEntry {
275
+ readonly id: string;
276
+ load(): Promise<AnyTriggerPlugin>;
277
+ }
278
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/triggers/host/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,yFAAyF;AACzF,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEnE;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAExD;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB;IACE,MAAM,EAAE,QAAQ,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,4EAA4E;IAC5E,MAAM,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;CAC/B,GACD;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,MAAM,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAEpC,2DAA2D;AAC3D,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,sFAAsF;IACtF,OAAO,EAAE,cAAc,CAAC;IACxB,4DAA4D;IAC5D,SAAS,EAAE,WAAW,CAAC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,EACd,OAAO,EAAE,qBAAqB,GAC7B,mBAAmB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACrC;;;OAGG;IACH,UAAU,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACnD;;;;OAIG;IACH,KAAK,CACH,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,kBAAkB,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IACpE;;;;;OAKG;IACH,gBAAgB,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACvF;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,uCAAuC;AAEvC,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,IAAI,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACnC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Trigger event names and the counterfactual's reasons: the only place they are
3
+ * spelled; changing them here changes every emitter.
4
+ */
5
+ export declare const TRIGGER_EVENT: Readonly<{
6
+ readonly impression: "sdk_trigger_impression";
7
+ readonly clicked: "sdk_trigger_clicked";
8
+ readonly autoOpened: "sdk_trigger_auto_opened";
9
+ readonly dismissed: "sdk_trigger_dismissed";
10
+ readonly eligibleNotShown: "sdk_trigger_eligible_not_shown";
11
+ }>;
12
+ /** Why a trigger the user reached was not shown. "Nothing to show" is not one of them. */
13
+ export declare const NOT_SHOWN_REASON: Readonly<{
14
+ /** The trigger's /config came back with no template AND an experiment: held out. */
15
+ readonly holdout: "holdout";
16
+ /**
17
+ * The sheet the trigger opens would not open for this user: the server's answer for
18
+ * that sheet has nothing this SDK can serve (no copy, or another use case's answer).
19
+ * A null template with servable copy still opens web's hand-written sheet, so it is
20
+ * not this. No offers or a 409 is "nothing to show", never this.
21
+ */
22
+ readonly sheetUnavailable: "sheet_unavailable";
23
+ /** GiftsButton opening by itself: eligible, but another mount popped at this placement today. */
24
+ readonly autoHeld: "auto_held";
25
+ /**
26
+ * The served tree uses something this build does not render (an element, field,
27
+ * style key, action or symbol outside `sdui/precheck.ts`'s allow-list), so the
28
+ * trigger draws nothing rather than drawing wrong and counting an impression.
29
+ */
30
+ readonly unrenderable: "unrenderable";
31
+ /**
32
+ * The look's behavior hid the spot after a completed offer (`ui.step` afterComplete with
33
+ * no template): the exposure for that step, once per completion, never `holdout`.
34
+ */
35
+ readonly afterCompleteHide: "after_complete_hide";
36
+ /**
37
+ * No template, with a `ui.step` this build does not know (a newer server's step): drawn
38
+ * as nothing, stamped with the raw step, never `holdout`.
39
+ */
40
+ readonly unknownStep: "unknown_step";
41
+ }>;
42
+ export type NotShownReason = (typeof NOT_SHOWN_REASON)[keyof typeof NOT_SHOWN_REASON];
43
+ /** The device-local record of reported reasons: `{ "<placement>|<reason>": "YYYY-MM-DD" }`. */
44
+ export declare function notShownStorageKey(triggerId: string): string;
45
+ /**
46
+ * The custom-UI handle's behavior-only trigger (`Encore.claim`): it asks for rules only
47
+ * (`layout: behavior`, never drawn) and reports its events with layout `custom`.
48
+ */
49
+ export declare const CUSTOM_CLAIM_ID = "customClaim";
50
+ /** Trigger ids this SDK ships (the registry's keys, as variant files name them). */
51
+ export declare const TRIGGER_ID: Readonly<{
52
+ readonly claimReminder: "claimReminder";
53
+ readonly giftsButton: "giftsButton";
54
+ }>;
55
+ //# sourceMappingURL=wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../../src/triggers/host/wire.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,aAAa;;;;;;EAMf,CAAC;AAEZ,0FAA0F;AAC1F,eAAO,MAAM,gBAAgB;IAC3B,oFAAoF;;IAEpF;;;;;OAKG;;IAEH,iGAAiG;;IAEjG;;;;OAIG;;IAEH;;;OAGG;;IAEH;;;OAGG;;EAEM,CAAC;AAEZ,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAEtF,+FAA+F;AAC/F,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAE7C,oFAAoF;AACpF,eAAO,MAAM,UAAU;;;EAGZ,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The trigger half of `@encorekit/web-sdk/preview` (🔴 INTERNAL, admin portal only).
3
+ *
4
+ * Draws one trigger look (a GiftsButton or ClaimReminder variant file, as `/config`
5
+ * serves it in `ui.template`) with sample offers and claims, through the live plug-ins:
6
+ * the GiftsButton spot decodes it, `present` binds its values, times and lists exactly as
7
+ * on a device, and `render` draws it with the SDUI engine. Only the I/O is replaced:
8
+ * there is no `/config` or offer search, no storage, no analytics, and a tap or × does
9
+ * nothing.
10
+ *
11
+ * `state` is what happened on the device (§2.8). A look draws in the states Encore
12
+ * serves it for: a gifts look in any state, a reminder look only with an open claim
13
+ * (`claimOpen`), a thanks look only after a completion (`completed`). In any other state
14
+ * the preview draws nothing and says so (`empty`), as a device would.
15
+ */
16
+ import type { TriggerAppearance, TriggerPortalTheme } from './host/theme';
17
+ /** What happened on the device, as the spot tells Encore (`state=`); `default` is neither. */
18
+ export type TriggerPreviewState = 'default' | 'claimOpen' | 'completed';
19
+ /** One offer the sheet would hold: its logo is what the gifts looks draw. */
20
+ export interface TriggerPreviewOffer {
21
+ advertiserName?: string;
22
+ logoUrl?: string;
23
+ }
24
+ /** One open claim, for the reminder looks. */
25
+ export interface TriggerPreviewClaim {
26
+ advertiserName: string;
27
+ advertiserLogoUrl?: string | null;
28
+ /** Spoken only, never drawn. */
29
+ perk?: string;
30
+ /** ISO-8601. Absent: two hours before `now`. */
31
+ claimedAt?: string;
32
+ }
33
+ export interface TriggerPreviewInput {
34
+ /** The look as served (`ui.template`): its `trigger`, `layout`, colours, strings and `root`. */
35
+ template: Record<string, unknown>;
36
+ /** Default `default`. */
37
+ state?: TriggerPreviewState;
38
+ /** Default `dark`, as on a device where nobody chose. */
39
+ colorScheme?: 'light' | 'dark';
40
+ /** The publisher's colours (`appearance`), over the app's and the look's. */
41
+ appearance?: Omit<TriggerAppearance, 'colorScheme'>;
42
+ /** The app's portal theme: its accent and store icon. */
43
+ portal?: Pick<TriggerPortalTheme, 'accentColor' | 'appIconUrl'>;
44
+ /** The mount's `icon` option. Default `gift`. */
45
+ icon?: 'gift' | 'appIcon' | 'none';
46
+ /** The mount's `values` for `${values.K}`, over the look's own defaults. */
47
+ values?: Readonly<Record<string, string>>;
48
+ offers?: readonly TriggerPreviewOffer[];
49
+ /** Newest first or not: the reminder sorts them as on a device. */
50
+ claims?: readonly TriggerPreviewClaim[];
51
+ /** Epoch ms the countdowns count from. Default: now. The preview does not tick. */
52
+ now?: number;
53
+ }
54
+ export type TriggerPreviewResult = {
55
+ status: 'rendered';
56
+ trigger: string;
57
+ layout: string;
58
+ }
59
+ /** The look draws nothing in this state (or with these samples). */
60
+ | {
61
+ status: 'empty';
62
+ }
63
+ /** Not a look this build draws: an unknown trigger, or a tree outside the vocabulary. */
64
+ | {
65
+ status: 'unrenderable';
66
+ reason: string;
67
+ };
68
+ export interface TriggerPreviewHandle {
69
+ /** What the last render drew. */
70
+ readonly result: TriggerPreviewResult;
71
+ /** Draw `input` afresh in the same container. After destroy(), draws nothing. */
72
+ update(input: TriggerPreviewInput): TriggerPreviewResult;
73
+ /** Remove everything the preview added. Safe to call more than once. */
74
+ destroy(): void;
75
+ }
76
+ /** Mount a preview of the trigger look `input` describes in `container`. */
77
+ export declare function renderTriggerPreview(container: HTMLElement | ShadowRoot, input: TriggerPreviewInput): TriggerPreviewHandle;
78
+ //# sourceMappingURL=preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/triggers/preview.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAI1E,8FAA8F;AAC9F,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC;AAExE,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,8CAA8C;AAC9C,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,gGAAgG;IAChG,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,yBAAyB;IACzB,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,yDAAyD;IACzD,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC/B,6EAA6E;IAC7E,UAAU,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;IACpD,yDAAyD;IACzD,MAAM,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,aAAa,GAAG,YAAY,CAAC,CAAC;IAChE,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IACnC,4EAA4E;IAC5E,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,MAAM,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACxC,mEAAmE;IACnE,MAAM,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACxC,mFAAmF;IACnF,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,oBAAoB,GAC5B;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACzD,oEAAoE;GAClE;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE;AACrB,yFAAyF;GACvF;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/C,MAAM,WAAW,oBAAoB;IACnC,iCAAiC;IACjC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,iFAAiF;IACjF,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,oBAAoB,CAAC;IACzD,wEAAwE;IACxE,OAAO,IAAI,IAAI,CAAC;CACjB;AA4GD,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,WAAW,GAAG,UAAU,EACnC,KAAK,EAAE,mBAAmB,GACzB,oBAAoB,CA8BtB"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * What a trigger mount asks the server for, read from its options once:
3
+ * the use case it serves, a pinned layout, and whether it forbids opening the sheet by itself.
4
+ *
5
+ * In the core bundle and free of the host, so `Encore.triggers.mount` can refuse a mount
6
+ * (churn, a layout that is not a name) before any chunk loads or request is sent.
7
+ */
8
+ import type { UseCase } from '../types';
9
+ /** A trigger's state look after a completed claim: never a publisher pin. */
10
+ export declare const THANKS_LAYOUT_NAME = "thanks";
11
+ /** What one mount asks for, resolved. */
12
+ export interface TriggerRequest {
13
+ useCase: UseCase;
14
+ /** The layout pin sent as `layout=<pin>`. Absent: managed. A pinned mount never opens by itself. */
15
+ layout?: string;
16
+ /**
17
+ * Sent as `autoOpen=off`, only when the mount forbids Encore from opening the sheet by
18
+ * itself. Absent: allowed, and the served look's `behavior.autoOpen` decides.
19
+ */
20
+ autoOpen?: 'off';
21
+ /**
22
+ * What happened on the device, sent as `state=` (§2.8): the served look's behavior picks
23
+ * the step's look for it. Set by the host from the plug-in's `requestState`.
24
+ */
25
+ state?: TriggerState;
26
+ }
27
+ /**
28
+ * Whether a look served to this mount may open the sheet by itself: a trigger that can,
29
+ * on a mount that neither said off nor pinned a layout. The device's own bounds (once per
30
+ * mount and per placement per local day, never over another sheet, foreground only) still
31
+ * apply on top.
32
+ */
33
+ export declare function mayOpenByItself(triggerId: string, request: TriggerRequest): boolean;
34
+ /** A trigger request's device state (§2.8). */
35
+ export type TriggerState = 'claimOpen' | 'completed';
36
+ /** Test hook: log every warning again. */
37
+ export declare function forgetRequestWarnings(): void;
38
+ /**
39
+ * The request for mounting `triggerId` with `options`, or null to render nothing and
40
+ * send nothing: churn (not supported yet), a use case this SDK does not name, or a
41
+ * pinned layout that is not a name. Any name is a pin; the server decides the look.
42
+ */
43
+ export declare function resolveTriggerRequest(triggerId: string, options: {
44
+ useCase?: unknown;
45
+ layout?: unknown;
46
+ autoOpen?: unknown;
47
+ } | null | undefined): TriggerRequest | null;
48
+ /**
49
+ * `Encore.claim` once took `afterClaim` and `afterComplete`; Encore decides both now (the
50
+ * customClaim rules). A caller still passing either is told once, and the value is ignored.
51
+ */
52
+ export declare function warnRetiredClaimSteps(options: object | null | undefined): void;
53
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/triggers/request.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAexC,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,oGAAoG;IACpG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAEnF;AAED,+CAA+C;AAC/C,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,WAAW,CAAC;AAgBrD,0CAA0C;AAC1C,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GACtF,cAAc,GAAG,IAAI,CAiEvB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAS9E"}