@touchcastllc/napster-companion-api-dev 1.0.0-alpha.61 → 1.0.0-alpha.63

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 CHANGED
@@ -545,7 +545,82 @@ instance.updateFeatureConfig("controls", { enabled: false });
545
545
  instance.enableFeature("controls");
546
546
  ```
547
547
 
548
- ### 3.2 Position & Layout
548
+ ### 3.2 Picture-in-Picture (PiP)
549
+
550
+ Automatically pop the avatar into a Document Picture-in-Picture window when the user switches browser tabs, so the conversation stays visible while they work in another tab. The PiP window mirrors the live avatar video and renders the built-in controls (mute / volume / screen-share / end). Closing the PiP window or returning to the original tab restores the in-page avatar. Chrome / Edge 116+ on HTTPS.
551
+
552
+ ```typescript
553
+ const instance = await NapsterCompanionApiSdk.init(token, {
554
+ features: {
555
+ pictureInPicture: {
556
+ enabled: true,
557
+ width: 400, // optional, default 400
558
+ height: 300, // optional, default 300
559
+ },
560
+ },
561
+ });
562
+ ```
563
+
564
+ **Browser requirements for the auto-PiP trigger to fire:**
565
+
566
+ - Secure context (HTTPS)
567
+ - Active media playback with audio
568
+ - The site has met the browser's Media Engagement Index threshold (user frequently consumes media on the site)
569
+
570
+ If the requirements aren't met, the avatar simply stays in-page when the tab loses focus — no errors are thrown.
571
+
572
+ ### 3.3 Screen Sharing
573
+
574
+ Share the user's screen with the avatar in real time. The SDK captures the display at 1 FPS, renders each frame onto an internal canvas, and streams the canvas track over WebRTC so the avatar can "see" what the user sees. Fully browser-based — no plugins or extensions required.
575
+
576
+ #### Enable & Configure
577
+
578
+ ```typescript
579
+ const instance = await NapsterCompanionApiSdk.init(token, {
580
+ features: {
581
+ screenShare: {
582
+ enabled: true,
583
+ },
584
+ },
585
+ });
586
+ ```
587
+
588
+ > **Note:** `features.screenShare.enabled` must be `true` for the screen share controls to appear and for `isScreenShareSupported` to return `true`.
589
+
590
+ #### Start & Stop
591
+
592
+ ```typescript
593
+ // Start sharing (opens browser's screen picker)
594
+ await instance.startScreenShare();
595
+
596
+ // Stop sharing
597
+ instance.stopScreenShare();
598
+
599
+ // Or toggle on/off
600
+ await instance.toggleScreenShare();
601
+ ```
602
+
603
+ The SDK sends `start_video` / `stop_video` commands to the avatar server automatically. If the user stops sharing via the browser's native "Stop sharing" button, the SDK detects this and cleans up.
604
+
605
+ #### Checking State
606
+
607
+ ```typescript
608
+ // Whether screen sharing is currently active
609
+ instance.isScreenSharing; // boolean
610
+
611
+ // Whether the browser supports screen sharing AND the feature is enabled
612
+ instance.isScreenShareSupported; // boolean
613
+ ```
614
+
615
+ #### Cleanup
616
+
617
+ Screen sharing is automatically stopped when:
618
+
619
+ - The user calls `instance.destroy()`
620
+ - The WebRTC connection closes (network failure, session end)
621
+ - The user clicks the browser's native "Stop sharing" button
622
+
623
+ ### 3.4 Position & Layout
549
624
 
550
625
  Customize the avatar's position on the screen using predefined positions or custom styles. Also you can override the position using style properties.
551
626
 
@@ -707,7 +782,55 @@ if (instance.isFeatureEnabled("disclaimer")) {
707
782
  }
708
783
  ```
709
784
 
710
- ### 5.4 Communication Methods
785
+ ### 5.4 Screen Sharing Methods
786
+
787
+ #### `startScreenShare(): Promise<void>`
788
+
789
+ Start screen sharing. Opens the browser's screen picker and begins streaming frames to the avatar.
790
+
791
+ ```typescript
792
+ await instance.startScreenShare();
793
+ ```
794
+
795
+ > **Note:** Requires `features.screenShare.enabled = true` in the init config. Does nothing if already sharing.
796
+
797
+ #### `stopScreenShare(): void`
798
+
799
+ Stop screen sharing. Releases the display stream and notifies the server.
800
+
801
+ ```typescript
802
+ instance.stopScreenShare();
803
+ ```
804
+
805
+ #### `toggleScreenShare(): Promise<void>`
806
+
807
+ Toggle screen sharing on or off.
808
+
809
+ ```typescript
810
+ await instance.toggleScreenShare();
811
+ ```
812
+
813
+ #### `isScreenSharing: boolean` _(read-only)_
814
+
815
+ Whether screen sharing is currently active.
816
+
817
+ ```typescript
818
+ if (instance.isScreenSharing) {
819
+ console.log("User is sharing their screen");
820
+ }
821
+ ```
822
+
823
+ #### `isScreenShareSupported: boolean` _(read-only)_
824
+
825
+ Whether screen sharing is supported by the browser **and** enabled in the feature config.
826
+
827
+ ```typescript
828
+ if (instance.isScreenShareSupported) {
829
+ showScreenShareButton();
830
+ }
831
+ ```
832
+
833
+ ### 5.5 Communication Methods
711
834
 
712
835
  #### `sendCommand(command: { type: string; data?: object }): void`
713
836
 
@@ -721,7 +844,7 @@ instance.sendCommand({ type: "send_message", data: { text: "Hello, how are you?"
721
844
  instance.sendCommand({ type: "cancel" });
722
845
  ```
723
846
 
724
- ### 5.5 Audio Control Methods
847
+ ### 5.6 Audio Control Methods
725
848
 
726
849
  Control the avatar's incoming WebRTC audio output (the avatar's voice the user hears). These methods operate on the underlying `<audio>` element and do not affect the user's microphone.
727
850
 
@@ -767,7 +890,7 @@ Get the current avatar audio output volume in the range `0..1`.
767
890
  const volume = instance.getAudioVolume();
768
891
  ```
769
892
 
770
- ### 5.6 Microphone Control Methods
893
+ ### 5.7 Microphone Control Methods
771
894
 
772
895
  Control the user's microphone input that is sent to the avatar.
773
896
 
@@ -797,7 +920,7 @@ if (instance.isMicMuted) {
797
920
  }
798
921
  ```
799
922
 
800
- ### 5.7 Avatar Speech Control Methods
923
+ ### 5.8 Avatar Speech Control Methods
801
924
 
802
925
  Interrupt the avatar's response and inspect speaking state for both sides of the conversation.
803
926
 
@@ -866,6 +989,13 @@ interface NapsterCompanionApiConfig {
866
989
  };
867
990
  disclaimer?: { enabled: boolean; text?: string };
868
991
  showSDKLoader?: { enabled: boolean; bgColor?: string };
992
+ pictureInPicture?: {
993
+ enabled: boolean;
994
+ width?: number; // default 400
995
+ height?: number; // default 300
996
+ };
997
+ screenShare?: { enabled: boolean };
998
+ controls?: { enabled: boolean };
869
999
  };
870
1000
 
871
1001
  // Configuration
package/lib/index.d.ts CHANGED
@@ -18,6 +18,9 @@ declare class NapsterCompanionApiSdkVanilla implements NapsterCompanionApiSDK {
18
18
  private unloadHandler;
19
19
  private pipController;
20
20
  private lastFaceDetected;
21
+ private userMutedDuringFaceTracking;
22
+ private faceTrackingLastDispatchedMute;
23
+ private muteStoreUnsubscribe;
21
24
  static getInstance(): NapsterCompanionApiSdkVanilla;
22
25
  constructor();
23
26
  private renderApp;