@encorekit/web-sdk 2.2.1 → 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.
- package/README.md +66 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/preview.cjs +2 -0
- package/dist/cjs/preview.cjs.map +1 -0
- package/dist/cjs/react.cjs +1 -1
- package/dist/cjs/react.cjs.map +1 -1
- package/dist/esm/chunks/ClaimReminder-DFyrm5bJ.js +2 -0
- package/dist/esm/chunks/ClaimReminder-DFyrm5bJ.js.map +1 -0
- package/dist/esm/chunks/GiftsButton-B0lVB463.js +2 -0
- package/dist/esm/chunks/GiftsButton-B0lVB463.js.map +1 -0
- package/dist/esm/chunks/TriggerHost-CNTiNrTH.js +2 -0
- package/dist/esm/chunks/TriggerHost-CNTiNrTH.js.map +1 -0
- package/dist/esm/chunks/autoPops-CngtK_R0.js +2 -0
- package/dist/esm/chunks/autoPops-CngtK_R0.js.map +1 -0
- package/dist/esm/chunks/customClaim-B4uj-aOc.js +2 -0
- package/dist/esm/chunks/customClaim-B4uj-aOc.js.map +1 -0
- package/dist/esm/chunks/eligibility-BY7fL8Ve.js +2 -0
- package/dist/esm/chunks/eligibility-BY7fL8Ve.js.map +1 -0
- package/dist/esm/chunks/index-CaBSqauy.js +2 -0
- package/dist/esm/chunks/index-CaBSqauy.js.map +1 -0
- package/dist/esm/chunks/lookValues-B9z2VWpH.js +2 -0
- package/dist/esm/chunks/lookValues-B9z2VWpH.js.map +1 -0
- package/dist/esm/chunks/sduiView-Ds7QtFId.js +2 -0
- package/dist/esm/chunks/sduiView-Ds7QtFId.js.map +1 -0
- package/dist/esm/chunks/spot-DkKMLpB-.js +2 -0
- package/dist/esm/chunks/spot-DkKMLpB-.js.map +1 -0
- package/dist/esm/chunks/template-B9p4CbPD.js +2 -0
- package/dist/esm/chunks/template-B9p4CbPD.js.map +1 -0
- package/dist/esm/chunks/textSlots-BnwxUg9V.js +2 -0
- package/dist/esm/chunks/textSlots-BnwxUg9V.js.map +1 -0
- package/dist/esm/chunks/timers-Bva4yoGM.js +2 -0
- package/dist/esm/chunks/timers-Bva4yoGM.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/preview.js +2 -0
- package/dist/esm/preview.js.map +1 -0
- package/dist/esm/react.js +1 -1
- package/dist/esm/react.js.map +1 -1
- package/dist/umd/encore.min.js +1 -1
- package/dist/umd/encore.min.js.map +1 -1
- package/package.json +9 -1
- package/types/analytics/DiagnosticsOutbox.d.ts +1 -0
- package/types/analytics/DiagnosticsOutbox.d.ts.map +1 -1
- package/types/analytics/events.d.ts +108 -8
- package/types/analytics/events.d.ts.map +1 -1
- package/types/analytics/models.d.ts +2 -0
- package/types/analytics/models.d.ts.map +1 -1
- package/types/analytics/transport.d.ts +6 -0
- package/types/analytics/transport.d.ts.map +1 -1
- package/types/api/APIClient.d.ts +70 -33
- package/types/api/APIClient.d.ts.map +1 -1
- package/types/api/contract.d.ts +4 -1
- package/types/api/contract.d.ts.map +1 -1
- package/types/api/generated/types.d.ts +994 -17
- package/types/api/generated/types.d.ts.map +1 -1
- package/types/api/models.d.ts +29 -8
- package/types/api/models.d.ts.map +1 -1
- package/types/api/offerBuilder.d.ts +51 -0
- package/types/api/offerBuilder.d.ts.map +1 -0
- package/types/core/Configuration.d.ts +9 -0
- package/types/core/Configuration.d.ts.map +1 -1
- package/types/core/Encore.d.ts +145 -3
- package/types/core/Encore.d.ts.map +1 -1
- package/types/core/OfferManager.d.ts +27 -5
- package/types/core/OfferManager.d.ts.map +1 -1
- package/types/core/PlacementBuilder.d.ts +6 -1
- package/types/core/PlacementBuilder.d.ts.map +1 -1
- package/types/core/SignalManager.d.ts.map +1 -1
- package/types/core/StorageManager.d.ts +3 -2
- package/types/core/StorageManager.d.ts.map +1 -1
- package/types/core/StrictUnlockReconciler.d.ts +1 -1
- package/types/core/StrictUnlockReconciler.d.ts.map +1 -1
- package/types/core/claimHandle.d.ts +44 -0
- package/types/core/claimHandle.d.ts.map +1 -0
- package/types/core/claimLog.d.ts +102 -0
- package/types/core/claimLog.d.ts.map +1 -0
- package/types/core/claimRefusal.d.ts +3 -0
- package/types/core/claimRefusal.d.ts.map +1 -0
- package/types/core/claimScreenVariant.d.ts +3 -0
- package/types/core/claimScreenVariant.d.ts.map +1 -0
- package/types/core/claimStatusCheck.d.ts +62 -0
- package/types/core/claimStatusCheck.d.ts.map +1 -0
- package/types/core/giftVariant.d.ts +5 -0
- package/types/core/giftVariant.d.ts.map +1 -1
- package/types/core/hostDisplay.d.ts +9 -2
- package/types/core/hostDisplay.d.ts.map +1 -1
- package/types/core/sduiVariables.d.ts +20 -0
- package/types/core/sduiVariables.d.ts.map +1 -0
- package/types/core/strings.d.ts +114 -0
- package/types/core/strings.d.ts.map +1 -0
- package/types/core/unlockCode.d.ts +12 -2
- package/types/core/unlockCode.d.ts.map +1 -1
- package/types/core/userKeys.d.ts +7 -0
- package/types/core/userKeys.d.ts.map +1 -0
- package/types/core/version.d.ts +1 -1
- package/types/experiments/ExposureOutbox.d.ts +1 -0
- package/types/experiments/ExposureOutbox.d.ts.map +1 -1
- package/types/preview.d.ts +51 -0
- package/types/preview.d.ts.map +1 -0
- package/types/react.d.ts +53 -1
- package/types/react.d.ts.map +1 -1
- package/types/sdui/actions.d.ts +93 -0
- package/types/sdui/actions.d.ts.map +1 -0
- package/types/sdui/bindings.d.ts +63 -0
- package/types/sdui/bindings.d.ts.map +1 -0
- package/types/sdui/compile.d.ts +88 -0
- package/types/sdui/compile.d.ts.map +1 -0
- package/types/sdui/conditions.d.ts +22 -0
- package/types/sdui/conditions.d.ts.map +1 -0
- package/types/sdui/context.d.ts +132 -0
- package/types/sdui/context.d.ts.map +1 -0
- package/types/sdui/countdown.d.ts +31 -0
- package/types/sdui/countdown.d.ts.map +1 -0
- package/types/sdui/decode.d.ts +35 -0
- package/types/sdui/decode.d.ts.map +1 -0
- package/types/sdui/deps.d.ts +43 -0
- package/types/sdui/deps.d.ts.map +1 -0
- package/types/sdui/dominantColor.d.ts +24 -0
- package/types/sdui/dominantColor.d.ts.map +1 -0
- package/types/sdui/elements/confetti.d.ts +38 -0
- package/types/sdui/elements/confetti.d.ts.map +1 -0
- package/types/sdui/elements/content.d.ts +27 -0
- package/types/sdui/elements/content.d.ts.map +1 -0
- package/types/sdui/elements/interactive.d.ts +48 -0
- package/types/sdui/elements/interactive.d.ts.map +1 -0
- package/types/sdui/elements/layout.d.ts +41 -0
- package/types/sdui/elements/layout.d.ts.map +1 -0
- package/types/sdui/elements/marquee.d.ts +17 -0
- package/types/sdui/elements/marquee.d.ts.map +1 -0
- package/types/sdui/elements/progress.d.ts +10 -0
- package/types/sdui/elements/progress.d.ts.map +1 -0
- package/types/sdui/elements/shared.d.ts +138 -0
- package/types/sdui/elements/shared.d.ts.map +1 -0
- package/types/sdui/elements/symbols.d.ts +22 -0
- package/types/sdui/elements/symbols.d.ts.map +1 -0
- package/types/sdui/elements/triggerText.d.ts +55 -0
- package/types/sdui/elements/triggerText.d.ts.map +1 -0
- package/types/sdui/host.d.ts +274 -0
- package/types/sdui/host.d.ts.map +1 -0
- package/types/sdui/inlineMarkup.d.ts +22 -0
- package/types/sdui/inlineMarkup.d.ts.map +1 -0
- package/types/sdui/lookValues.d.ts +50 -0
- package/types/sdui/lookValues.d.ts.map +1 -0
- package/types/sdui/model.d.ts +130 -0
- package/types/sdui/model.d.ts.map +1 -0
- package/types/sdui/motion.d.ts +37 -0
- package/types/sdui/motion.d.ts.map +1 -0
- package/types/sdui/precheck.d.ts +94 -0
- package/types/sdui/precheck.d.ts.map +1 -0
- package/types/sdui/scrollMath.d.ts +32 -0
- package/types/sdui/scrollMath.d.ts.map +1 -0
- package/types/sdui/style.d.ts +99 -0
- package/types/sdui/style.d.ts.map +1 -0
- package/types/sdui/triggerKit.d.ts +24 -0
- package/types/sdui/triggerKit.d.ts.map +1 -0
- package/types/sdui/unrunnable.d.ts +11 -0
- package/types/sdui/unrunnable.d.ts.map +1 -0
- package/types/sdui/vocabulary.d.ts +119 -0
- package/types/sdui/vocabulary.d.ts.map +1 -0
- package/types/triggers/claimReminder/ClaimReminder.d.ts +65 -0
- package/types/triggers/claimReminder/ClaimReminder.d.ts.map +1 -0
- package/types/triggers/claimReminder/bindings.d.ts +40 -0
- package/types/triggers/claimReminder/bindings.d.ts.map +1 -0
- package/types/triggers/claimReminder/config.d.ts +56 -0
- package/types/triggers/claimReminder/config.d.ts.map +1 -0
- package/types/triggers/claimReminder/eligibility.d.ts +37 -0
- package/types/triggers/claimReminder/eligibility.d.ts.map +1 -0
- package/types/triggers/claimReminder/servedWindow.d.ts +15 -0
- package/types/triggers/claimReminder/servedWindow.d.ts.map +1 -0
- package/types/triggers/claimReminder/source.d.ts +29 -0
- package/types/triggers/claimReminder/source.d.ts.map +1 -0
- package/types/triggers/giftsButton/GiftsButton.d.ts +60 -0
- package/types/triggers/giftsButton/GiftsButton.d.ts.map +1 -0
- package/types/triggers/giftsButton/config.d.ts +53 -0
- package/types/triggers/giftsButton/config.d.ts.map +1 -0
- package/types/triggers/giftsButton/spot.d.ts +54 -0
- package/types/triggers/giftsButton/spot.d.ts.map +1 -0
- package/types/triggers/host/TriggerHost.d.ts +127 -0
- package/types/triggers/host/TriggerHost.d.ts.map +1 -0
- package/types/triggers/host/autoPops.d.ts +16 -0
- package/types/triggers/host/autoPops.d.ts.map +1 -0
- package/types/triggers/host/configCache.d.ts +29 -0
- package/types/triggers/host/configCache.d.ts.map +1 -0
- package/types/triggers/host/customClaim.d.ts +85 -0
- package/types/triggers/host/customClaim.d.ts.map +1 -0
- package/types/triggers/host/dismissStore.d.ts +37 -0
- package/types/triggers/host/dismissStore.d.ts.map +1 -0
- package/types/triggers/host/readThrottle.d.ts +15 -0
- package/types/triggers/host/readThrottle.d.ts.map +1 -0
- package/types/triggers/host/registry.d.ts +17 -0
- package/types/triggers/host/registry.d.ts.map +1 -0
- package/types/triggers/host/sduiView.d.ts +31 -0
- package/types/triggers/host/sduiView.d.ts.map +1 -0
- package/types/triggers/host/template.d.ts +28 -0
- package/types/triggers/host/template.d.ts.map +1 -0
- package/types/triggers/host/textSlots.d.ts +35 -0
- package/types/triggers/host/textSlots.d.ts.map +1 -0
- package/types/triggers/host/theme.d.ts +87 -0
- package/types/triggers/host/theme.d.ts.map +1 -0
- package/types/triggers/host/timers.d.ts +11 -0
- package/types/triggers/host/timers.d.ts.map +1 -0
- package/types/triggers/host/types.d.ts +278 -0
- package/types/triggers/host/types.d.ts.map +1 -0
- package/types/triggers/host/wire.d.ts +55 -0
- package/types/triggers/host/wire.d.ts.map +1 -0
- package/types/triggers/preview.d.ts +78 -0
- package/types/triggers/preview.d.ts.map +1 -0
- package/types/triggers/request.d.ts +53 -0
- package/types/triggers/request.d.ts.map +1 -0
- package/types/types.d.ts +420 -4
- package/types/types.d.ts.map +1 -1
- package/types/ui/ClaimScreen.d.ts +62 -0
- package/types/ui/ClaimScreen.d.ts.map +1 -0
- package/types/ui/CodeUnlock.d.ts +26 -2
- package/types/ui/CodeUnlock.d.ts.map +1 -1
- package/types/ui/GiftHero.d.ts.map +1 -1
- package/types/ui/GiftList.d.ts.map +1 -1
- package/types/ui/GiftPicker.d.ts.map +1 -1
- package/types/ui/GiftPickerHero.d.ts.map +1 -1
- package/types/ui/GiftReveal.d.ts.map +1 -1
- package/types/ui/GiftSheet.d.ts +5 -5
- package/types/ui/GiftSheet.d.ts.map +1 -1
- package/types/ui/GiftUnwrap.d.ts.map +1 -1
- package/types/ui/OfferCard.d.ts.map +1 -1
- package/types/ui/OfferCarousel.d.ts.map +1 -1
- package/types/ui/OfferModal.d.ts +31 -6
- package/types/ui/OfferModal.d.ts.map +1 -1
- package/types/ui/PrimerScreen.d.ts +2 -0
- package/types/ui/PrimerScreen.d.ts.map +1 -1
- package/types/ui/RedemptionScreen.d.ts +5 -0
- package/types/ui/RedemptionScreen.d.ts.map +1 -1
- package/types/ui/RewardActions.d.ts.map +1 -1
- package/types/ui/RewardCard.d.ts.map +1 -1
- package/types/ui/SduiRewardSurface.d.ts +145 -0
- package/types/ui/SduiRewardSurface.d.ts.map +1 -0
- package/types/ui/Tooltip.d.ts.map +1 -1
- package/types/ui/brandComponents.d.ts.map +1 -1
- package/types/ui/brandTint.d.ts.map +1 -1
- package/types/ui/colorScheme.d.ts +15 -0
- package/types/ui/colorScheme.d.ts.map +1 -0
- package/types/ui/covered.d.ts +12 -0
- package/types/ui/covered.d.ts.map +1 -0
- package/types/ui/giftCategoryGroups.d.ts +13 -0
- package/types/ui/giftCategoryGroups.d.ts.map +1 -1
- package/types/ui/giftCopy.d.ts +14 -9
- package/types/ui/giftCopy.d.ts.map +1 -1
- package/types/ui/giftUnwrapCopy.d.ts.map +1 -1
- package/types/ui/imageURL.d.ts +44 -0
- package/types/ui/imageURL.d.ts.map +1 -0
- package/types/ui/impressionGate.d.ts +9 -0
- package/types/ui/impressionGate.d.ts.map +1 -1
- package/types/ui/offerBadge.d.ts.map +1 -1
- package/types/ui/rewardSurface.d.ts +11 -1
- package/types/ui/rewardSurface.d.ts.map +1 -1
- package/types/ui/sduiTheme.d.ts +48 -0
- package/types/ui/sduiTheme.d.ts.map +1 -0
- package/types/ui/sheetDetents.d.ts +28 -0
- package/types/ui/sheetDetents.d.ts.map +1 -0
- package/types/ui/styles.d.ts +11 -8
- package/types/ui/styles.d.ts.map +1 -1
- package/types/ui/termsLine.d.ts +3 -3
- package/types/ui/termsLine.d.ts.map +1 -1
- package/types/ui/toast.d.ts +11 -0
- package/types/ui/toast.d.ts.map +1 -0
- package/types/utils/logger.d.ts +10 -0
- package/types/utils/logger.d.ts.map +1 -1
- package/types/utils/text.d.ts +17 -0
- package/types/utils/text.d.ts.map +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's own words on a trigger (`headline`, `subheadline`, `cta`): a look names, in
|
|
3
|
+
* its root `textSlots`, which of its OWN strings each slot replaces, so that string is
|
|
4
|
+
* the slot's default (translated, per variant). App text is cleaned the same way on every
|
|
5
|
+
* platform, never translated, and never leaves the device.
|
|
6
|
+
*/
|
|
7
|
+
/** The text slots a mount can set, in wire order. */
|
|
8
|
+
export declare const TEXT_SLOTS: readonly ["headline", "subheadline", "cta"];
|
|
9
|
+
export type TextSlot = (typeof TEXT_SLOTS)[number];
|
|
10
|
+
/** The longest slot text kept, in UTF-16 code units (JavaScript `.length`). */
|
|
11
|
+
export declare const MAX_SLOT_TEXT_LENGTH = 120;
|
|
12
|
+
/**
|
|
13
|
+
* An app's slot text as it may be drawn, or null for the look's own default: not a
|
|
14
|
+
* string, nothing visible after cleaning, or text still holding `${` (the fill pass would
|
|
15
|
+
* expand it). The order is shared by every SDK.
|
|
16
|
+
*/
|
|
17
|
+
export declare function sanitizeSlotText(raw: unknown): string | null;
|
|
18
|
+
/** A mount's slot text, cleaned once: only the slots it set with text that survives. */
|
|
19
|
+
export declare function mountSlotText(options: Partial<Record<TextSlot, unknown>> | null | undefined): Partial<Record<TextSlot, string>>;
|
|
20
|
+
/**
|
|
21
|
+
* `template` with the app's text in place of the strings its `textSlots` name, and the
|
|
22
|
+
* slots drawn with app text (sorted; empty when none). Lenient, as a device is with a newer
|
|
23
|
+
* server: an unknown slot, a slot naming a string the look lacks, or a `textSlots` that is
|
|
24
|
+
* not an object is skipped. A state look keeps its own words. The template is never
|
|
25
|
+
* changed in place, so a shared cached answer stays as served.
|
|
26
|
+
*/
|
|
27
|
+
export declare function withSlotText(template: unknown, text: Partial<Record<TextSlot, string>>): {
|
|
28
|
+
template: unknown;
|
|
29
|
+
drawn: TextSlot[];
|
|
30
|
+
};
|
|
31
|
+
/** The string a look's headline slot names, for the reminder's spoken title; null when none. */
|
|
32
|
+
export declare function headlineKeyOf(template: unknown): string | null;
|
|
33
|
+
/** Each slot a look declares in the string form, with the string it replaces. */
|
|
34
|
+
export declare function slotKeysOf(template: unknown): Partial<Record<TextSlot, string>>;
|
|
35
|
+
//# sourceMappingURL=textSlots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textSlots.d.ts","sourceRoot":"","sources":["../../../src/triggers/host/textSlots.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qDAAqD;AACrD,eAAO,MAAM,UAAU,6CAA8C,CAAC;AACtE,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAkCxC;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAc5D;AAED,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAO/H;AAMD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,GACtC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,QAAQ,EAAE,CAAA;CAAE,CAe1C;AAED,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAI9D;AAED,iFAAiF;AACjF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAQ/E"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colour precedence, per token: the publisher's `appearance`, then the app's theme
|
|
3
|
+
* set in the portal (served as `ui.values.appearance`), then the look's colours,
|
|
4
|
+
* then the built-in default. A publisher colour is never overridden. Text follows the background: a
|
|
5
|
+
* background set without a text colour at the same level gets black or white
|
|
6
|
+
* ink for that background, never a text colour picked for another one.
|
|
7
|
+
*
|
|
8
|
+
* Only hex is accepted (`#RGB`, `#RRGGBB`, `#RRGGBBAA`): the formats every platform's
|
|
9
|
+
* AppearanceConfig parses, so one value is one colour everywhere. Anything else is
|
|
10
|
+
* skipped and the next source answers. Values reach the page through
|
|
11
|
+
* `style.setProperty`, never through markup.
|
|
12
|
+
*/
|
|
13
|
+
import type { AppearanceConfig } from '../../types';
|
|
14
|
+
/** A template's `colors` block, as every trigger variant serves it. */
|
|
15
|
+
export interface TriggerColors {
|
|
16
|
+
background?: string;
|
|
17
|
+
accent?: string;
|
|
18
|
+
text?: string;
|
|
19
|
+
}
|
|
20
|
+
/** What a trigger reads from `appearance`: its seven colours and `colorScheme`; the sheet's slots do not apply. */
|
|
21
|
+
export type TriggerAppearance = Pick<AppearanceConfig, 'accentColor' | 'backgroundColor' | 'textColor' | 'secondaryTextColor' | 'trackColor' | 'onAccentColor' | 'backgroundEndColor' | 'colorScheme'>;
|
|
22
|
+
/**
|
|
23
|
+
* The app's theme as the portal stores it and `/config` serves it in `ui.values`:
|
|
24
|
+
* hex as the server writes it (8 digits are alpha first, as the sheet reads them).
|
|
25
|
+
*/
|
|
26
|
+
export interface TriggerPortalTheme {
|
|
27
|
+
accentColor?: string;
|
|
28
|
+
/** The app's saved appearance mode (`light`, `dark` or `auto`). */
|
|
29
|
+
mode?: string;
|
|
30
|
+
/** The app's store icon (`media.appstoreIcon`). */
|
|
31
|
+
appIconUrl?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface TriggerTheme {
|
|
34
|
+
background: string;
|
|
35
|
+
accent: string;
|
|
36
|
+
text: string;
|
|
37
|
+
/** Set only by the publisher; unset falls back to the text colour at the look's opacity. */
|
|
38
|
+
secondary?: string;
|
|
39
|
+
/** Set only by the publisher; unset falls back to the text colour at the look's opacity. */
|
|
40
|
+
track?: string;
|
|
41
|
+
/** Set only by the publisher; unset is black or white for the accent. */
|
|
42
|
+
onAccent?: string;
|
|
43
|
+
/** Set only by the publisher: a gradient's second stop. Unset is `background` (a solid card). */
|
|
44
|
+
backgroundEnd?: string;
|
|
45
|
+
}
|
|
46
|
+
/** The Figma palette every trigger shares. */
|
|
47
|
+
export declare const DEFAULT_TRIGGER_THEME: Readonly<TriggerTheme>;
|
|
48
|
+
/** Encore's light palette, used in the light scheme when nothing above it sets a colour. */
|
|
49
|
+
export declare const DEFAULT_LIGHT_TRIGGER_THEME: Readonly<TriggerTheme>;
|
|
50
|
+
export type TriggerScheme = 'light' | 'dark';
|
|
51
|
+
/**
|
|
52
|
+
* Light or dark for a trigger: the publisher's `colorScheme`, then the app's saved
|
|
53
|
+
* mode from the portal (`auto` follows the device, as `system` does), then dark. A
|
|
54
|
+
* value it does not know is skipped. Dark stays the default unless someone opts in.
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolveTriggerScheme(appearance: Pick<AppearanceConfig, 'colorScheme'> | undefined, portal: TriggerPortalTheme, prefersDark?: () => boolean): TriggerScheme;
|
|
57
|
+
/**
|
|
58
|
+
* `variant` is the look's dark colours (`colors`); `lightVariant` its light ones
|
|
59
|
+
* (`lightColors`). In the light scheme the look's dark colours never apply: the order
|
|
60
|
+
* is publisher, portal, the look's light colours, then Encore's light default.
|
|
61
|
+
*/
|
|
62
|
+
export declare function resolveTriggerTheme(appearance: TriggerAppearance | undefined, darkVariant: TriggerColors, portal?: TriggerPortalTheme, scheme?: TriggerScheme, lightVariant?: TriggerColors): TriggerTheme;
|
|
63
|
+
/**
|
|
64
|
+
* The appearance tokens a trigger tree names (trigger SDUI contract §2.1), from the
|
|
65
|
+
* resolved palette. The accent is read as drawn: a translucent accent composited
|
|
66
|
+
* over the surface. `onAccent` is black or white, whichever reads on it;
|
|
67
|
+
* `inkOnAccent` is the surface itself when it is opaque and reaches 3:1 on the
|
|
68
|
+
* accent, as designed, else `onAccent`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function triggerTokens(theme: TriggerTheme): Readonly<Record<string, string>>;
|
|
71
|
+
/**
|
|
72
|
+
* The tokens that fell back to the text colour because the publisher left them
|
|
73
|
+
* unset. Only on these does a look's `opacity` apply: a colour the publisher chose is
|
|
74
|
+
* drawn exactly as chosen, never faded.
|
|
75
|
+
*/
|
|
76
|
+
export declare function triggerFallbackTokens(theme: TriggerTheme): ReadonlySet<string>;
|
|
77
|
+
export interface TriggerIconValues {
|
|
78
|
+
icon: 'gift' | 'appIcon' | 'none';
|
|
79
|
+
appIconUrl?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The icon a look draws, as host values: `icon` is `gift`, `appIcon` or `none`, and
|
|
83
|
+
* `appIconUrl` is the app's store icon when it is a safe image. `appIcon` without a
|
|
84
|
+
* usable icon draws the gift, and an icon this SDK does not know is the gift too.
|
|
85
|
+
*/
|
|
86
|
+
export declare function triggerIconValues(asked: unknown, portal: TriggerPortalTheme): TriggerIconValues;
|
|
87
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/triggers/host/theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,mHAAmH;AACnH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,gBAAgB,EACd,aAAa,GACb,iBAAiB,GACjB,WAAW,GACX,oBAAoB,GACpB,YAAY,GACZ,eAAe,GACf,oBAAoB,GACpB,aAAa,CAChB,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,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AqB,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW,CAAC,MAAM,CAAC,CAK9E;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,kBAAkB,GACzB,iBAAiB,CAInB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The longest any trigger waits before presenting or reading again: a deadline, a
|
|
3
|
+
* local midnight, a plug-in's `readAgainAt`. Further than this, it presents (or reads)
|
|
4
|
+
* at the cap, which works the time out afresh. The same cap on every platform.
|
|
5
|
+
*/
|
|
6
|
+
export declare const MAX_REPRESENT_MS: number;
|
|
7
|
+
/** How long to wait for `at` from `now`: never negative, never past the cap. */
|
|
8
|
+
export declare function representDelay(at: number, now: number): number;
|
|
9
|
+
/** Epoch ms of the local midnight after `now`. */
|
|
10
|
+
export declare function nextLocalMidnight(now?: number): number;
|
|
11
|
+
//# sourceMappingURL=timers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timers.d.ts","sourceRoot":"","sources":["../../../src/triggers/host/timers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAA0B,CAAC;AAExD,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,kDAAkD;AAClD,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAmB,GAAG,MAAM,CAIlE"}
|
|
@@ -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;AA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|
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"}
|