@admin-highlit/web-sdk 0.0.0-stage → 0.1.0-beta.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 (55) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE +8 -0
  3. package/NOTICE +17 -0
  4. package/README.md +117 -2
  5. package/dist/chunks/activate-banner.facade-BxuEF7R4.js +1 -0
  6. package/dist/chunks/astonished-DWjAE_Ui.js +1 -0
  7. package/dist/chunks/banner.view-Bi95J_KM.js +95 -0
  8. package/dist/chunks/blush-BLongC-7.js +1 -0
  9. package/dist/chunks/clap-CbaE59gk.js +1 -0
  10. package/dist/chunks/confetti-DtRbyKIF.js +1 -0
  11. package/dist/chunks/cover-loader.view-DrbnwnL2.js +1 -0
  12. package/dist/chunks/cover-scene.view-Dvb1B30Q.js +7 -0
  13. package/dist/chunks/cry-C0PCH3iy.js +1 -0
  14. package/dist/chunks/exploding-head-Brtj2e9w.js +1 -0
  15. package/dist/chunks/extras.facade-CxAEdzIq.js +1 -0
  16. package/dist/chunks/fire-ClpzuxLG.js +1 -0
  17. package/dist/chunks/grimacing-tlnKCEK5.js +1 -0
  18. package/dist/chunks/heart-C40aXMPt.js +1 -0
  19. package/dist/chunks/heart-eyes-DclZxFsJ.js +1 -0
  20. package/dist/chunks/heart-hands-CuquXiSP.js +1 -0
  21. package/dist/chunks/hundred-__POba_3.js +1 -0
  22. package/dist/chunks/index-CgpZJ9F1.js +20 -0
  23. package/dist/chunks/interactions-CuKVTm2-.js +1 -0
  24. package/dist/chunks/joy-CxXSvmb4.js +1 -0
  25. package/dist/chunks/live-runtime.facade-BcNbq_AT.js +1 -0
  26. package/dist/chunks/muscle-CVxbTlKP.js +1 -0
  27. package/dist/chunks/party-BKRjljRG.js +1 -0
  28. package/dist/chunks/partying-CDN5dHQ_.js +1 -0
  29. package/dist/chunks/playback-LHHueU9L.js +1 -0
  30. package/dist/chunks/playback.model-B3GGnQl1.js +1 -0
  31. package/dist/chunks/player-intent.model-DYNpcx0-.js +1 -0
  32. package/dist/chunks/player-runtime.facade-DSr_xgud.js +1 -0
  33. package/dist/chunks/player.view-CcU9MlBb.js +202 -0
  34. package/dist/chunks/pleading-BXYTcBme.js +1 -0
  35. package/dist/chunks/rage-B_bPm3xU.js +1 -0
  36. package/dist/chunks/raised-hands-cjht_WgS.js +1 -0
  37. package/dist/chunks/rofl-DhFudVS8.js +1 -0
  38. package/dist/chunks/scene.model-D4YsQd4q.js +1 -0
  39. package/dist/chunks/scene.view-CNMs6pLN.js +598 -0
  40. package/dist/chunks/sleeping-B-fw70UQ.js +1 -0
  41. package/dist/chunks/smiling-hearts-Cag9nkNL.js +1 -0
  42. package/dist/chunks/smirk-B_vPoQtF.js +1 -0
  43. package/dist/chunks/sparkles-CPawB-gv.js +1 -0
  44. package/dist/chunks/star-struck-CkXEUyJ8.js +1 -0
  45. package/dist/chunks/story-rail.view-A9dFtvyv.js +87 -0
  46. package/dist/chunks/sunglasses-CrEQeWEm.js +1 -0
  47. package/dist/chunks/sweat-smile-CEvqKKSO.js +1 -0
  48. package/dist/chunks/thinking-CChn6QQp.js +1 -0
  49. package/dist/chunks/thumbs-down-gYSCnsk2.js +1 -0
  50. package/dist/chunks/thumbs-up-DDWDsBzf.js +1 -0
  51. package/dist/chunks/tracking-runtime.facade-BYxLLTv0.js +1 -0
  52. package/dist/chunks/updatable-view.model-4968zd29.js +1 -0
  53. package/dist/index.d.ts +189 -0
  54. package/dist/index.js +1 -0
  55. package/package.json +68 -4
@@ -0,0 +1,189 @@
1
+ /** A viewer tapped a banner. `url` is the call to action's destination, or null when it has none. */
2
+ declare interface BannerClickPayload {
3
+ readonly bannerId: string;
4
+ readonly url: string | null;
5
+ }
6
+
7
+ /** Public entry point. */
8
+ export declare const createHighlit: (config: HighlitConfig) => HighlitClient;
9
+
10
+ /** A viewer activated a call to action. `url` is the author's destination, or null when none is set. */
11
+ declare interface CtaClickPayload {
12
+ readonly groupId: string;
13
+ readonly storyId: string;
14
+ readonly elementId: string;
15
+ readonly trackingId: string;
16
+ readonly url: string | null;
17
+ readonly productId: string | null;
18
+ }
19
+
20
+ export declare interface HighlitClient {
21
+ readonly policy: ModePolicy;
22
+ mount(container: HTMLElement, options: MountOptions): PlacementHandle;
23
+ /**
24
+ * The signed-in user changed (login or account switch). The SDK asks `getViewerAssertion` again
25
+ * and reloads personalized content. Resolves when the new viewer is settled.
26
+ */
27
+ identityChanged(): Promise<void>;
28
+ /** Revoke this browser's viewer, start a fresh anonymous one and reload content. */
29
+ logout(): Promise<void>;
30
+ on<K extends keyof HighlitEvents>(event: K, handler: (payload: HighlitEvents[K]) => void): Unsubscribe;
31
+ destroy(): void;
32
+ }
33
+
34
+ export declare interface HighlitConfig {
35
+ readonly appToken: string;
36
+ readonly mode: OperatingMode;
37
+ /** Pull-based identity: resolve a host-signed assertion, or null for anonymous. */
38
+ readonly getViewerAssertion?: () => Promise<string | null>;
39
+ readonly apiBaseUrl?: string;
40
+ readonly locale?: string;
41
+ /**
42
+ * What an activated call to action does. `open` (default) opens its destination in a new tab and
43
+ * emits `cta:click`; `host` only emits the event so the host app navigates itself.
44
+ */
45
+ readonly ctaNavigation?: 'open' | 'host';
46
+ /**
47
+ * Hear about published changes as they happen, over a WebSocket opened after the first paint.
48
+ * On by default; `false` leaves content to its regular polling.
49
+ */
50
+ readonly liveUpdates?: boolean;
51
+ }
52
+
53
+ /** The only error type that crosses a module or public boundary. */
54
+ export declare class HighlitError extends Error {
55
+ readonly code: SdkErrorCode;
56
+ readonly recoverable: boolean;
57
+ readonly action: RecoveryAction;
58
+ readonly status: number | undefined;
59
+ readonly backendCode: string | undefined;
60
+ readonly retryAfterSeconds: number | undefined;
61
+ constructor(code: SdkErrorCode, message: string, init: SdkErrorInit);
62
+ }
63
+
64
+ export declare interface HighlitEvents {
65
+ 'live:status': LiveStatusPayload;
66
+ 'banner:click': BannerClickPayload;
67
+ 'interactive:response': InteractiveResponsePayload;
68
+ 'viewer:ready': ViewerReadyPayload;
69
+ 'viewer:reset': ViewerResetPayload;
70
+ 'promocode:copy': PromocodeCopyPayload;
71
+ 'cta:click': CtaClickPayload;
72
+ 'media:failed': MediaFailedPayload;
73
+ 'story:open': StoryOpenPayload;
74
+ 'story:close': StoryClosePayload;
75
+ 'story:complete': StoryEventPayload;
76
+ 'placement:ready': PlacementSignalPayload;
77
+ 'placement:empty': PlacementSignalPayload;
78
+ error: HighlitError;
79
+ }
80
+
81
+ /** A viewer's answer was saved. Ids and kind only: never the option, value or text. */
82
+ declare interface InteractiveResponsePayload {
83
+ readonly groupId: string;
84
+ readonly storyId: string;
85
+ readonly elementId: string;
86
+ readonly kind: 'poll_vote' | 'quiz_answer' | 'emoji_slider' | 'emoji_reactions' | 'question_submit';
87
+ }
88
+
89
+ /** Whether a placement hears about changes live, or only through its regular polling. */
90
+ declare interface LiveStatusPayload {
91
+ readonly placementId: string | null;
92
+ readonly status: 'connected' | 'polling';
93
+ }
94
+
95
+ /** A story's media could not play. Category only: no URL, no text. */
96
+ declare interface MediaFailedPayload {
97
+ readonly groupId: string;
98
+ readonly storyId: string;
99
+ readonly elementId: string;
100
+ readonly category: string;
101
+ }
102
+
103
+ /** What a mode allows. Modules ask the policy; they never compare mode names. */
104
+ declare interface ModePolicy {
105
+ readonly mode: OperatingMode;
106
+ /** A viewer credential is resolved and stored. */
107
+ readonly resolvesViewer: boolean;
108
+ /** Answers to interactive elements are saved and results shown. */
109
+ readonly savesResponses: boolean;
110
+ /** Impressions, story views and behavior events are sent. */
111
+ readonly tracksBehavior: boolean;
112
+ }
113
+
114
+ export declare interface MountOptions {
115
+ readonly placementToken: string;
116
+ }
117
+
118
+ declare const OPERATING_MODES: readonly ["viewOnly", "interactive", "measured"];
119
+
120
+ export declare type OperatingMode = (typeof OPERATING_MODES)[number];
121
+
122
+ export declare interface PlacementHandle {
123
+ /** Revalidate content now. */
124
+ refresh(): void;
125
+ /** Idempotent. */
126
+ destroy(): void;
127
+ }
128
+
129
+ declare interface PlacementSignalPayload {
130
+ readonly placementId: string;
131
+ }
132
+
133
+ /** A viewer copied a promo code. The code itself is not included. */
134
+ declare interface PromocodeCopyPayload {
135
+ readonly groupId: string;
136
+ readonly storyId: string;
137
+ readonly elementId: string;
138
+ readonly trackingId: string;
139
+ }
140
+
141
+ /** What the caller should do next, from the backend's client recovery matrix. */
142
+ declare type RecoveryAction = 'retry' | 'refreshContent' | 'refreshIdentity' | 'refreshAssertion' | 'newSession' | 'stop';
143
+
144
+ /** Closed catalog of SDK error codes (see docs/plans/sdk-public-api.md). */
145
+ declare const SDK_ERROR_CODES: readonly ["ssr_unsupported", "invalid_config", "unauthorized", "origin_not_allowed", "rate_limited", "content_revision_changed", "content_not_visible", "not_found", "bad_request", "conflict", "session_conflict", "interactive_locked", "interactive_conflict", "interactive_request_conflict", "network", "aborted", "unavailable", "viewer_unavailable", "viewer_credential_rejected", "viewer_assertion_rejected", "identity_key_rejected", "media_failed", "contract_mismatch", "destroyed"];
146
+
147
+ export declare type SdkErrorCode = (typeof SDK_ERROR_CODES)[number];
148
+
149
+ declare interface SdkErrorInit {
150
+ readonly recoverable: boolean;
151
+ readonly cause?: unknown;
152
+ readonly action?: RecoveryAction;
153
+ /** HTTP status when the error came from a response. */
154
+ readonly status?: number;
155
+ /** Backend error code, kept for diagnostics (never shown to end users). */
156
+ readonly backendCode?: string;
157
+ readonly retryAfterSeconds?: number;
158
+ }
159
+
160
+ declare interface StoryClosePayload {
161
+ readonly groupId: string;
162
+ /** `completed` when the viewer reached the end; otherwise who closed it. */
163
+ readonly reason: 'completed' | 'manual' | 'system';
164
+ }
165
+
166
+ declare interface StoryEventPayload {
167
+ readonly groupId: string;
168
+ readonly storyId: string;
169
+ }
170
+
171
+ declare interface StoryOpenPayload extends StoryEventPayload {
172
+ /** Zero-based position of the story inside its group. */
173
+ readonly position: number;
174
+ }
175
+
176
+ declare type Unsubscribe = () => void;
177
+
178
+ /** The viewer is resolved. `persistent: false` means the credential only lives for this page. */
179
+ declare interface ViewerReadyPayload {
180
+ readonly persistent: boolean;
181
+ readonly identified: boolean;
182
+ }
183
+
184
+ /** The previous viewer was dropped; personalized content is reloading. */
185
+ declare interface ViewerResetPayload {
186
+ readonly reason: 'logout' | 'identityChanged' | 'credentialRejected' | 'otherTab';
187
+ }
188
+
189
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{H as r,x as i}from"./chunks/index-CgpZJ9F1.js";export{r as HighlitError,i as createHighlit};
package/package.json CHANGED
@@ -1,6 +1,70 @@
1
1
  {
2
2
  "name": "@admin-highlit/web-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-beta.0",
4
+ "description": "Highlit web SDK: render Highlit stories and banners in your site.",
5
+ "private": false,
6
+ "type": "module",
7
+ "license": "SEE LICENSE IN LICENSE",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/Highlitt/web_sdk.git",
11
+ "directory": "packages/sdk"
12
+ },
13
+ "homepage": "https://github.com/Highlitt/web_sdk#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/Highlitt/web_sdk/issues"
16
+ },
17
+ "sideEffects": false,
18
+ "files": [
19
+ "dist",
20
+ "!dist/**/*.map",
21
+ "README.md",
22
+ "LICENSE",
23
+ "NOTICE",
24
+ "CHANGELOG.md"
25
+ ],
26
+ "main": "./dist/index.js",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
33
+ },
34
+ "./package.json": "./package.json"
35
+ },
36
+ "scripts": {
37
+ "typecheck": "tsc --noEmit",
38
+ "test": "vitest run",
39
+ "test:browser": "playwright test",
40
+ "build": "vite build",
41
+ "size": "size-limit"
42
+ },
43
+ "dependencies": {
44
+ "lit": "^3.3.0"
45
+ },
46
+ "devDependencies": {
47
+ "@axe-core/playwright": "^4.14.1",
48
+ "@playwright/test": "^1.56.0",
49
+ "@size-limit/file": "^11.2.0",
50
+ "happy-dom": "^21.0.4",
51
+ "size-limit": "^11.2.0",
52
+ "socket.io-client": "^4.8.4",
53
+ "terser": "^5.51.4",
54
+ "valibot": "^1.5.0",
55
+ "vite": "^7.1.0",
56
+ "vite-plugin-dts": "^4.5.0",
57
+ "vitest": "^5.1.2"
58
+ },
59
+ "publishConfig": {
60
+ "access": "public",
61
+ "tag": "next"
62
+ },
63
+ "keywords": [
64
+ "highlit",
65
+ "stories",
66
+ "banners",
67
+ "web-components",
68
+ "lit"
69
+ ]
70
+ }