@namiml/web-sdk 3.4.0-dev.202605141714 → 3.4.0-dev.202605182046
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/CHANGELOG.md +8 -0
- package/dist/components/Paywall.d.ts +5 -0
- package/dist/components/elements/Button.d.ts +5 -0
- package/dist/components/styles/modal.d.ts +2 -0
- package/dist/nami-web.cjs +144 -30
- package/dist/nami-web.d.ts +5 -0
- package/dist/nami-web.mjs +144 -30
- package/dist/nami-web.umd.js +144 -30
- package/dist/utils/tts.d.ts +83 -0
- package/package.json +2 -2
- package/dist/utils/vizio-tts.d.ts +0 -2
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-platform text-to-speech for the Nami Web SDK.
|
|
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.
|
|
11
|
+
*
|
|
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()`.
|
|
25
|
+
*/
|
|
26
|
+
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
|
+
export declare function setMediaPlaying(playing: boolean): void;
|
|
33
|
+
/** Whether media is currently flagged as playing (test/debug helper). */
|
|
34
|
+
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
|
+
*/
|
|
47
|
+
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
|
+
*/
|
|
62
|
+
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. */
|
|
75
|
+
export declare function setActivePage(page: TPages | null | undefined): void;
|
|
76
|
+
/** Get the currently active page (or null if none). */
|
|
77
|
+
export declare function getActivePage(): TPages | null;
|
|
78
|
+
/** Whether the page-level composite has not yet been announced for the active page. */
|
|
79
|
+
export declare function shouldAnnounceComposite(): boolean;
|
|
80
|
+
/** Mark the active page as having had its composite announced. */
|
|
81
|
+
export declare function markPageAnnounced(): void;
|
|
82
|
+
/** Clear all screenreader state — called when the paywall closes. */
|
|
83
|
+
export declare function resetScreenreaderState(): void;
|
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.
|
|
4
|
+
"version": "3.4.0-dev.202605182046",
|
|
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": {
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"dependencies": {
|
|
102
102
|
"@lit-labs/ssr-dom-shim": "^1.2.1",
|
|
103
103
|
"@lit/context": "^1.1.3",
|
|
104
|
-
"@namiml/sdk-core": "3.4.0-dev.
|
|
104
|
+
"@namiml/sdk-core": "3.4.0-dev.202605182046",
|
|
105
105
|
"bowser": "^2.11.0",
|
|
106
106
|
"hls.js": "^1.5.18",
|
|
107
107
|
"lit": "^3.3.1",
|