@namiml/web-sdk 3.4.0-dev.202605201800 → 3.4.0-dev.202605261547

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.
@@ -1,83 +1,66 @@
1
1
  /**
2
- * Cross-platform text-to-speech for the Nami Web SDK.
2
+ * Text-to-speech for the Nami Web SDK.
3
3
  *
4
- * Targets:
5
- * - VIZIO → window.VIZIO.Chromevox.play(text)
6
- * - Other CTV (Samsung Tizen, LG webOS, Xbox) + desktop browsers
7
- * → window.speechSynthesis.speak(SpeechSynthesisUtterance)
8
- * - Headless / no API available → no-op; callers should also set `aria-label`
9
- * on the focused element so the platform screenreader picks it up via the
10
- * ARIA path as a last resort.
4
+ * Speech requests are SDK-controlled and must never break paywall rendering.
11
5
  *
12
- * Selection precedence on `speak()`:
13
- * 1. VIZIO Chromevox (when present and enabled by the user).
14
- * 2. `window.speechSynthesis` (most other modern browsers including the
15
- * Chromium-based CTV runtimes).
16
- * 3. No-op; the caller's ARIA label remains the final fallback.
17
- *
18
- * Replaces the original `vizio-tts.ts` which only covered VIZIO and silently
19
- * dropped speech requests on every other platform.
20
- */
21
- /**
22
- * Attach platform-specific TTS event listeners. Idempotent. Currently only
23
- * VIZIO surfaces enable/disable events at runtime; other engines are queried
24
- * on demand inside `speak()`.
6
+ * The feature layer below is platform neutral: it builds initial paywall
7
+ * composites, speaks focused labels, gates speech during media playback, and
8
+ * cleans up on navigation. Actual speech is owned by explicit engine adapters
9
+ * where a programmable engine is reliable. Some TV runtimes also speak focused
10
+ * controls through system accessibility; for those runtimes the SDK aligns
11
+ * labels and lets the platform own focus speech instead of starting a second
12
+ * programmable utterance for the same focus event.
25
13
  */
14
+ import { type TComponent, type TPages } from '@namiml/sdk-core';
15
+ type TtsRequestPriority = 'low' | 'normal' | 'high';
16
+ type SpeakOptions = {
17
+ interrupt?: boolean;
18
+ reason?: 'composite' | 'focus' | 'manual';
19
+ transactionId?: number;
20
+ element?: Element | null;
21
+ focusPath?: Element[];
22
+ focusedLabel?: string;
23
+ priority?: TtsRequestPriority;
24
+ };
25
+ export type FocusContext = {
26
+ composedPath?: EventTarget[];
27
+ target?: EventTarget | null;
28
+ currentTarget?: EventTarget | null;
29
+ relatedTarget?: EventTarget | null;
30
+ };
31
+ export type TtsEngineName = 'webos-luna-tts' | 'web-speech' | 'vizio-chromevox';
32
+ export declare function setTtsDebugEnabled(enabled: boolean): void;
33
+ export declare function hasActiveCompositeAccessibilityAlignment(element: Element): boolean;
34
+ export declare const hasActiveWebOsLunaCompositeLabelAlignment: typeof hasActiveCompositeAccessibilityAlignment;
35
+ export declare function getEstimatedSpeechRestoreDelayMs(text: string): number;
36
+ export declare function restoreCompositeAccessibilityAlignment(element?: Element, transactionId?: number, reason?: string, force?: boolean): void;
37
+ export declare const restoreWebOsLunaCompositeLabelAlignment: typeof restoreCompositeAccessibilityAlignment;
38
+ export declare function scheduleCompositeAccessibilityAlignmentRestoreAfterBlur(element: Element, relatedTarget?: EventTarget | null): void;
39
+ export declare const scheduleWebOsLunaCompositeLabelAlignmentRestoreAfterBlur: typeof scheduleCompositeAccessibilityAlignmentRestoreAfterBlur;
40
+ export declare function isTtsSupported(): boolean;
41
+ export declare function setTtsEnabled(enabled: boolean): void;
26
42
  export declare function attachTtsEventListeners(): void;
27
- /**
28
- * Set whether a page's media is currently producing audio. Toggled by
29
- * `VideoService` (`onplay`/`onpause`/`onended`). When set to `false`, any
30
- * deferred speech is flushed in this call.
31
- */
32
43
  export declare function setMediaPlaying(playing: boolean): void;
33
- /** Whether media is currently flagged as playing (test/debug helper). */
34
44
  export declare function isMediaPlaying(): boolean;
35
- /**
36
- * Cancel any in-flight or queued speech across every available engine.
37
- * Used implicitly by {@link speak} before starting a new utterance so that
38
- * a focus change mid-announcement interrupts the previous announcement
39
- * instead of letting it run concurrently. Also called when a page changes
40
- * and the previous announcement is no longer relevant.
41
- *
42
- * VIZIO Chromevox does not document a single cancel method across firmware
43
- * revisions, so we try the names that have appeared in the wild (`cancel`,
44
- * `stop`) and ignore any errors — silence on cancel is a strict improvement
45
- * over the overlap the user otherwise hears.
46
- */
45
+ export declare function stopSpeech(preserveTransactionId?: number): void;
47
46
  export declare function cancelSpeech(): void;
48
- /**
49
- * Speak `text` via the highest-priority TTS engine available. Empty / falsy
50
- * input is a no-op. While media is playing the latest request is buffered
51
- * and flushed on `setMediaPlaying(false)`. Errors are swallowed — TTS should
52
- * never break the paywall.
53
- *
54
- * NOTE: This function does NOT cancel any in-flight speech on its own.
55
- * Cancellation is the caller's responsibility — call {@link cancelSpeech}
56
- * at semantic interaction boundaries (e.g. inside a focus-change handler)
57
- * rather than on every utterance. Cancelling unconditionally inside
58
- * `speak()` is destructive on some VIZIO Chromevox firmware revisions
59
- * where the cancel + play sequence aborts the very utterance we just
60
- * tried to start.
61
- */
47
+ export declare function markTtsEngineUnavailable(engine?: TtsEngineName): void;
48
+ export declare function speakText(text: string, options?: SpeakOptions): boolean;
62
49
  export declare function speak(text: string): void;
63
- import type { TPages } from '@namiml/sdk-core';
64
- /** Inform the screenreader subsystem which page is currently rendered.
65
- * Resets the announced flag when the page actually changes. Safe to call
66
- * on every render.
67
- *
68
- * Comparison is by object identity, NOT by `page.name`. Every paywall in
69
- * the `a_onboarding_flow` staging payload contains a single page named
70
- * literally `'page1'` comparing by name would let Page 2's first focus
71
- * inherit Page 1's `pageAnnounced=true` state and silently drop the
72
- * composite. Page objects are sourced from each paywall's own
73
- * `template.pages` array, so reference equality cleanly distinguishes
74
- * pages across paywalls. */
50
+ export declare function diagnoseTtsEngine(text?: string): boolean;
51
+ export declare function focusEventReadsLabel(): boolean;
52
+ export declare function getSpeechLabelFromElement(element: Element | null | undefined): string;
53
+ export declare function getSpeechLabelFromComponent(component: TComponent | null | undefined): string;
54
+ export declare function applySpeechAttributes(element: Element, label: string): void;
55
+ export declare function buildInitialScreenSpeech(page: TPages | null | undefined, renderedRoot?: ParentNode | null, includeControls?: boolean): string;
56
+ export declare function speakInitialScreen(page: TPages | null | undefined, renderedRoot?: ParentNode | null): void;
57
+ export declare function preparePrimaryCtaCompositeFocus(element: Element, context?: FocusEvent | FocusContext): boolean;
58
+ export declare function attachFocusSpeechListeners(root?: Element | Document | DocumentFragment): () => void;
59
+ export declare function detachFocusSpeechListeners(): void;
75
60
  export declare function setActivePage(page: TPages | null | undefined): void;
76
- /** Get the currently active page (or null if none). */
61
+ export declare function setActivePageRenderRoot(root: ParentNode | null | undefined): void;
77
62
  export declare function getActivePage(): TPages | null;
78
- /** Whether the page-level composite has not yet been announced for the active page. */
79
63
  export declare function shouldAnnounceComposite(): boolean;
80
- /** Mark the active page as having had its composite announced. */
81
64
  export declare function markPageAnnounced(): void;
82
- /** Clear all screenreader state — called when the paywall closes. */
83
65
  export declare function resetScreenreaderState(): void;
66
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@namiml/web-sdk",
3
3
  "type": "module",
4
- "version": "3.4.0-dev.202605201800",
4
+ "version": "3.4.0-dev.202605261547",
5
5
  "source": "src/nami-web.ts",
6
6
  "description": "Subscription monetization infrastructure — drop-in SDK with no-code paywalls, onboarding flows, A/B testing for web",
7
7
  "scripts": {
@@ -38,8 +38,7 @@
38
38
  },
39
39
  "files": [
40
40
  "dist",
41
- "!dist/**/*.map",
42
- "CHANGELOG.md"
41
+ "!dist/**/*.map"
43
42
  ],
44
43
  "keywords": [
45
44
  "in-app-purchase",
@@ -101,7 +100,7 @@
101
100
  "dependencies": {
102
101
  "@lit-labs/ssr-dom-shim": "^1.2.1",
103
102
  "@lit/context": "^1.1.3",
104
- "@namiml/sdk-core": "3.4.0-dev.202605201800",
103
+ "@namiml/sdk-core": "3.4.0-dev.202605261547",
105
104
  "bowser": "^2.11.0",
106
105
  "hls.js": "^1.5.18",
107
106
  "lit": "^3.3.1",
package/CHANGELOG.md DELETED
@@ -1,400 +0,0 @@
1
- # Changelog - Web SDK
2
-
3
- ## Unreleased
4
-
5
- ### Bug Fixes
6
- - Recognize Xbox controller B button (`BrowserBack`, `XF86Back`, keyCode 166) as the paywall Back key, so onboarding flows no longer reload the host SPA on Xbox UWP / Edge WebView. Back is still routed through the campaign's `__remoteback__` action — if no action is configured on the current flow step, the event is swallowed (no-op) the same as before, just without the browser falling through to `history.back`. (NAM-79)
7
-
8
- ### New Features
9
- - Support `modal` page presentation style: centered overlay with dim backdrop, internal scrolling capped at 85vh, 90vw on phone and 50vw on tablet/desktop/TV. Backdrop click and Escape dismiss the modal. (NAM-62)
10
-
11
- ## 1.7.8
12
- **Release Date:** February 17, 2026
13
-
14
- ### Bug Fixes
15
- - Fix rendering of components with 0 height or width
16
- - Fix CTV button focus display
17
- - Clear uninterpolated Smart Text variables
18
- - Make sure background image is fullscreen when scrolling
19
-
20
- ### New Features
21
- - Support Segment Picker form component
22
- - Support Countdown Timer component
23
- - Support Progress Bar component
24
- - Support new flow function setTags
25
- - Support listening for user tag updates in Flow
26
-
27
- ### Enhancements
28
- - Allow branching in flows based on set/notSet operators
29
- - Support TTS on Vizio devices
30
- - Support active and inactive drop shadow styling on segment picker
31
- - Support paywall conditions based on product subscription duration
32
-
33
- ## 1.7.7
34
- **Release Date:** December 17, 2025
35
-
36
- ### Bug Fixes
37
- - Ensure page-changed event escapes shadow DOM when CustomEvent polyfill is present
38
-
39
- ## 1.7.6
40
-
41
- **Release Date:** December 16, 2025
42
-
43
- ### Bug Fixes
44
- - Fix padding issues in toggle and list components
45
- - Fix gradient background issue
46
-
47
- ### New Features
48
- - Add radio and standard toggle button components
49
-
50
- ### Enhancements
51
- - Support disabled button properties
52
-
53
- ## 1.7.5
54
- **Release Date:** November 19, 2025
55
-
56
- ### Enhancements
57
- - Support using launch context custom attributes in flow analytics
58
- - Initial support for a progress indicator component
59
-
60
- ### Bug Fixes
61
- - Resolve an issue where a user's signed in state wasn't reflected on the paywall properly
62
- - Resolve an issue with content padding on certain components
63
- - Resolve an ssue where CMS settings for video player audio playback was not honored
64
-
65
- ## 1.7.4
66
- **Release Date:** October 30, 2025
67
-
68
- ### Bug Fixes
69
- - Fix an issue where if device registration failed, user was stuck in anonymous mode
70
-
71
- ### Enhancements
72
- - Support for legacy browsers
73
-
74
- ## 1.7.3
75
- **Release Date:** October 13, 2025
76
-
77
- ### Bug Fixes
78
- - Fix issue with hidden components not being hidden
79
- - Fix issue with deeplink handler
80
- - Fix issue preventing black bar and double scrolling in certain situations
81
-
82
- ### Enhancements
83
- - Swipe and animation improements
84
- - Support for custom carousel indicators
85
- - Add support for launch id to group flow transitions
86
- - Add support for disabled field on toggle switch
87
- - Add `NamiCampaignManager.isFlow` for checking if a placement is a flow or not
88
-
89
- ## 1.7.2
90
- **Release Date:** September 17, 2025
91
-
92
- ### Enhancements
93
- - Improve handling of device creation failures and latency
94
- - Add `disableCampaignUpdates` namiCommand
95
- - Add forced A/B testing via `splitPosition` namiCommand
96
- - Standardize `NamiPaywallManager.emitter`
97
- - Support smart variables derived from URL query parameters and related analytics
98
-
99
- ### Bug Fixes
100
- - Fix CTV scaling and spacing issues
101
- - Styling improvements
102
-
103
- ## 1.7.1
104
- **Release Date:** September 3, 2025
105
-
106
- ### Enhancements
107
- - Add `NamiFlowManager.pause` method
108
- - Add component animations (pulse/wave)
109
-
110
- ### Bug Fixes
111
- - Completed Flows will no longer call registered paywall close handlers
112
-
113
- ## 1.7.0
114
- **Release Date:** August 27, 2025
115
-
116
- ### Enhancements
117
- - Add new components (Form container, Toggle switch, Radio button)
118
- - Support Flow Smart Text Variables
119
- - Support Flow animations / transitions
120
- - Smart TV Back button support
121
- - Support for buy / select sku Flow handoffs
122
-
123
- ### Bug Fixes
124
- - QR Code component (scaling and non-hex colors)
125
-
126
- ## 1.6.4
127
- **Release Date:** August 6, 2025
128
-
129
- ### Enhancements
130
- - Improved directional navigation support for TV and custom Nami components
131
- - Pass launch context in flows for better paywall context handling
132
-
133
- ### Bug Fixes
134
- - Prevent scrolling on TV form factor (Content and Background containers)
135
- - Fix for handling unexpected SKU smart text variables
136
-
137
- ## 1.6.3
138
- **Release Date:** July 29, 2025
139
-
140
- ### Enhancements
141
- - Improved television layout scaling for various viewport sizes
142
-
143
- ## 1.6.2
144
- **Release Date:** July 28, 2025
145
-
146
- ### New Features
147
- - `Nami.sdkVersion` method to get the internal SDK version
148
- - Support for QR Code components
149
- - On Device Segment Selection for A/B testing
150
- - Support Base64, Gzipped Initial Configurations
151
- - Support Fully Uppercase Text Components
152
-
153
- ### Enhancements
154
- - Paywall actions will now trigger if no flow action for a button is defined
155
-
156
- ### Bug Fixes
157
- - Dynamic widths on Responsive Grid components
158
-
159
- ## 1.6.1
160
- **Release Date:** July 13, 2025
161
-
162
- ### Improvements
163
- - Fix type exports in declaration files
164
-
165
- ## 1.6.0
166
- **Release Date:** July 10, 2025
167
-
168
- ### New Features
169
- - Introduced `NamiFlowManager` for orchestrating multi-page flows
170
- - `NamiFlowManager.registerStepHandoff`: callback when a flow is handed off
171
- - `NamiFlowManager.registerEventHandler`: callback for flow analytics
172
- - `NamiFlowManager.resume`: resume a handed-off flow
173
-
174
- ### UI Enhancements
175
- - Default Focused Buttons
176
- - Blur Properties
177
-
178
- ### Accessibility
179
- - Screenreader support for videos
180
- - Screenreader hints added
181
-
182
- ### Performance
183
- - Better support handling multiple `Nami.configure` calls
184
- - General stability fixes
185
-
186
- ## 1.5.12
187
- **Release Date:** July 30, 2025
188
-
189
- ### Bug Fixes
190
- - Fix race condition when local storage fails
191
-
192
- ## 1.5.11
193
- **Release Date:** June 18, 2025
194
-
195
- ### Enhancements
196
- - Performance improvements for form factor lookups
197
-
198
- ### Bug Fixes
199
- - Fix uninterpolated smart text
200
- - Fix fallback to in-memory storage on localStorage write failures
201
-
202
- ## 1.5.10
203
- **Release Date:** May 22, 2025
204
-
205
- ### Enhancements
206
- - Support focused styling on buttons and toggle
207
- - Support tab key focus for collapsible component
208
- - Support alt tags on images
209
-
210
- ### Bug Fixes
211
- - Fix toggle switch not preserving state on re-render
212
- - Fix additional spacing in text list items
213
- - Fix issue with screenreader and collapsed content
214
-
215
- ## 1.5.9
216
- **Release Date:** April 2, 2025
217
-
218
- ### Bug Fixes
219
- - Resolve incorrect downscaling on 720p TV devices
220
-
221
- ## 1.5.8
222
- **Release Date:** April 1, 2025
223
-
224
- ### Bug Fixes
225
- - Resolve issue where toggle component event was firing twice
226
- - Fix toggle switch state re-rendering due to parent page
227
- - Remove additional unintended spacing
228
-
229
- ## 1.5.7
230
- **Release Date:** February 20, 2025
231
-
232
- ### Bug Fixes
233
- - Resolve additional type issue encountered with certain initial config files
234
-
235
- ## 1.5.6
236
- **Release Date:** February 19, 2025
237
-
238
- ### Bug Fixes
239
- - Resolve type issue encountered with certain initial config files
240
-
241
- ## 1.5.5
242
- **Release Date:** January 16, 2025
243
-
244
- ### Enhancements
245
- - Add optional `purchaseChannel` to `NamiConfiguration` to pass through to `NamiPaywallEvent` analytics
246
-
247
- ## 1.5.4
248
- **Release Date:** November 29, 2024
249
-
250
- ### Bug Fixes
251
- - Resolve issue with TV focus on containers and product buttons on first load
252
-
253
- ## 1.5.3
254
- **Release Date:** November 21, 2024
255
-
256
- ### Bug Fixes
257
- - Fix collapse component caret icon not updating when expanded
258
-
259
- ### Enhancements
260
- - Support scaling on TV devices (720p, 1080p, 4K, and 8K)
261
-
262
- ## 1.5.2
263
- **Release Date:** October 24, 2024
264
-
265
- ### Bug Fixes
266
- - Fix wrong campaign rule used for placement labels
267
- - Fix initial config campaign rule mapping
268
- - Fix background video fullscreen on mobile
269
- - Fix focus events on connected TV
270
- - Fix login/logout state handling
271
- - Fix display of free trials and promotional offers
272
- - Fix multiple UI issues in carousel and stack components
273
-
274
- ## 1.5.1
275
- **Release Date:** October 2, 2024
276
-
277
- ### Enhancements
278
- - Add `TOGGLE_CHANGE` and `PAGE_CHANGE` paywall events
279
-
280
- ### Bug Fixes
281
- - Fix carousel component swiper
282
- - Fix flex alignment issues
283
- - Fix Safari rendering for hero video
284
-
285
- ## 1.5.0
286
- **Release Date:** September 26, 2024
287
-
288
- ### New Features
289
- - Advanced video feature support
290
- - Carousel component support
291
-
292
- ### Enhancements
293
- - Improve fallback data handling
294
- - Support repeatable lists inside collapse components
295
- - Support vertical alignment in product container
296
- - Align `removeAllListeners` behavior with RN SDK
297
-
298
- ### Bug Fixes
299
- - Fix segment picker cursor behavior
300
- - Fix hidden component visibility
301
- - Fix responsive grid spacing and scrolling
302
- - Fix background video gradient and position
303
-
304
- ## 1.4.0
305
- **Release Date:** September 5, 2024
306
-
307
- ### New Features
308
- - HLS support in Video component
309
- - Responsive Grid component support
310
- - `NamiCustomerManager.deviceId` added
311
- - `NamiCustomerManager.registerJourneyStateHandler` and `journeyState` (subscription management)
312
- - `NamiEntitlementManager.clearProvisionalEntitlementGrants` (subscription management)
313
-
314
- ### Enhancements
315
- - Pass product groups to paywall via campaign launch
316
-
317
- ### Bug Fixes
318
- - Find product by ID instead of name
319
- - Fix spacing in text component
320
-
321
- ### Improvements
322
- - Update type definitions across paywall manager and customer manager APIs
323
-
324
- ## 1.3.2
325
- **Release Date:** August 14, 2024
326
-
327
- ### Bug Fixes
328
- - Conditional component rendering based on product entitlement and product groups
329
-
330
- ## 1.3.1
331
- **Release Date:** August 12, 2024
332
-
333
- ### Bug Fixes
334
- - Fix `SHOW_PAYWALL` event being triggered as `UNKNOWN`
335
-
336
- ## 1.3.0
337
- **Release Date:** August 12, 2024
338
-
339
- ### New Features
340
- - `NamiEntitlementManager` to manage entitlements
341
- - `active`, `isEntitlementActive`, `refresh`, `registerActiveEntitlementsHandler`
342
- - `NamiEntitlement` object model
343
- - Hidden component support
344
- - New components: Video and collapsible
345
- - Timeout and error handling improvements
346
-
347
- ### Bug Fixes
348
- - Typing improvements across SDKs
349
- - ECMAScript 2021 support
350
-
351
- ### Breaking Changes
352
- - `appPlatformId` renamed to `appPlatformID` in `NamiConfiguration`
353
- - `NamiPaywallManager.buySkuComplete` interface simplified
354
-
355
- ## 1.2.0
356
- **Release Date:** July 26, 2024
357
-
358
- ### New Features
359
- - `NamiCampaignManager.launch`: supports `paywallLaunchContext`
360
- - `NamiPaywallManager.buySKUCancel` and `buySKUComplete`
361
- - Paywall impression and conversion reporting
362
- - Faster paywall render time
363
-
364
- ### Bug Fixes
365
- - Consistent typing and API alignment across SDKs
366
-
367
- ## 1.1.0
368
- **Release Date:** June 24, 2024
369
-
370
- ### New Features
371
- - `NamiCustomerManager.setAnonymousMode`
372
- - `NamiCampaignManager.launch` with `paywallActionHandler`
373
- - `NamiPaywallManager.registerBuySkuHandler`
374
-
375
- ### Bug Fixes
376
- - Lit component compatibility and SSR fixes
377
- - Subscription pricing rendering fixes
378
- - Custom API host connectivity fixes
379
- - Icon display improvements
380
-
381
- ### Known Issues
382
- - `buySkuComplete`, `buySkuCancel` not fully implemented
383
- - Impression/conversion reporting and launch context not implemented
384
-
385
- ## 1.0.0
386
- **Release Date:** June 13, 2024
387
-
388
- ### New Features
389
- - Core SDK: `Nami`, `Nami.configure`, `NamiConfiguration`, `NamiLanguageCodes`
390
- - `NamiCampaignManager` for campaign management
391
- - `NamiCustomerManager` for customer state and attributes
392
- - `NamiPaywallManager` for paywall and event handler management
393
-
394
- ### Known Issues
395
- - Paywall event callbacks not firing
396
- - `buySkuComplete`, `buySkuCancel`, and `setAnonymousMode` partially implemented
397
- - Impression/conversion reporting and launch context not yet available
398
-
399
- ### Additional Notes
400
- Refer to the documentation for detailed usage instructions and integration examples.