@hifilabs/pixel 0.7.1 → 0.8.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.
@@ -617,3 +617,259 @@ export interface ConsentBridgeProps {
617
617
  * props happens in your app code, not in the SDK.
618
618
  */
619
619
  export declare function ConsentBridge(props: ConsentBridgeProps): null;
620
+
621
+ // ============================================
622
+ // ArtistOS - Unified Component (Recommended)
623
+ // ============================================
624
+
625
+ /**
626
+ * Consent mode for ArtistOS
627
+ */
628
+ export type ConsentMode = 'built-in' | 'c15t' | 'external' | 'disabled';
629
+
630
+ /**
631
+ * Consent configuration for ArtistOS
632
+ */
633
+ export interface ConsentConfig {
634
+ /**
635
+ * How consent is managed
636
+ * - 'built-in': Use ArtistOS built-in consent manager (default)
637
+ * - 'c15t': Use c15t consent manager (requires @c15t/react)
638
+ * - 'external': Consent managed by external system (use ConsentBridge)
639
+ * - 'disabled': No consent management
640
+ */
641
+ mode?: ConsentMode;
642
+ /** Show consent banner */
643
+ showBanner?: boolean;
644
+ /** Delay before showing banner in ms */
645
+ bannerDelay?: number;
646
+ /** Show "Manage Preferences" button on banner */
647
+ showManageButton?: boolean;
648
+ }
649
+
650
+ /**
651
+ * Resolved config after merging props with env vars
652
+ */
653
+ export interface ResolvedConfig {
654
+ artistId: string | undefined;
655
+ gtmId: string | undefined;
656
+ endpoint: string | undefined;
657
+ consent: Required<ConsentConfig>;
658
+ debug: boolean;
659
+ disabled: boolean;
660
+ scriptUrl: string;
661
+ useEmulator: boolean;
662
+ projectId: string | undefined;
663
+ }
664
+
665
+ /**
666
+ * Consent state from built-in consent manager
667
+ */
668
+ export interface ConsentState {
669
+ /** Current consent preferences */
670
+ consent: ConsentPreferences | null;
671
+ /** Whether consent is still loading */
672
+ loading: boolean;
673
+ /** Whether user has made a consent choice */
674
+ hasConsented: boolean;
675
+ /** Whether to show the consent banner */
676
+ showBanner: boolean;
677
+ /** Set banner visibility */
678
+ setShowBanner: (show: boolean) => void;
679
+ /** Whether to show the consent dialog */
680
+ showDialog: boolean;
681
+ /** Set dialog visibility */
682
+ setShowDialog: (show: boolean) => void;
683
+ /** Accept all consent */
684
+ acceptAll: () => void;
685
+ /** Decline all consent */
686
+ declineAll: () => void;
687
+ /** Update specific consent preferences */
688
+ updateConsent: (prefs: ConsentPreferences) => void;
689
+ /** Check if specific consent type is granted */
690
+ hasConsent: (type: 'analytics' | 'marketing' | 'personalization') => boolean;
691
+ }
692
+
693
+ /**
694
+ * ArtistOS Context Value
695
+ */
696
+ export interface ArtistOSContextValue {
697
+ config: ResolvedConfig;
698
+ consentState: ConsentState;
699
+ }
700
+
701
+ /**
702
+ * ArtistOS Props - Zero-config unified component
703
+ */
704
+ export interface ArtistOSProps {
705
+ /** Artist ID (reads from NEXT_PUBLIC_ARTIST_ID if not provided) */
706
+ artistId?: string;
707
+ /** GTM container ID (reads from NEXT_PUBLIC_GTM_ID if not provided) */
708
+ gtmId?: string;
709
+ /** Pixel endpoint (reads from NEXT_PUBLIC_PIXEL_ENDPOINT if not provided) */
710
+ endpoint?: string;
711
+ /** Consent configuration */
712
+ consent?: ConsentConfig;
713
+ /** Enable debug logging */
714
+ debug?: boolean;
715
+ /** Disable tracking entirely */
716
+ disabled?: boolean;
717
+ /** Custom pixel script URL */
718
+ scriptUrl?: string;
719
+ /** Use Firebase emulator */
720
+ useEmulator?: boolean;
721
+ /** Project ID for multi-project tracking */
722
+ projectId?: string;
723
+ /** Optional children */
724
+ children?: React.ReactNode;
725
+ }
726
+
727
+ /**
728
+ * ArtistOS - Unified component for pixel loading, consent management, and GTM integration
729
+ *
730
+ * Zero-config usage:
731
+ * ```tsx
732
+ * <ArtistOS />
733
+ * ```
734
+ *
735
+ * With explicit artistId:
736
+ * ```tsx
737
+ * <ArtistOS artistId="artist_123" />
738
+ * ```
739
+ */
740
+ export declare function ArtistOS(props: ArtistOSProps): JSX.Element;
741
+
742
+ /**
743
+ * Hook to access ArtistOS context
744
+ * @throws Error if used outside ArtistOS
745
+ */
746
+ export declare function useArtistOS(): ArtistOSContextValue;
747
+
748
+ /**
749
+ * Hook to optionally access ArtistOS context
750
+ * Returns null if not inside ArtistOS
751
+ */
752
+ export declare function useArtistOSOptional(): ArtistOSContextValue | null;
753
+
754
+ /**
755
+ * Built-in consent hook for ArtistOS
756
+ */
757
+ export declare function useBuiltInConsent(config: Required<ConsentConfig>): ConsentState;
758
+
759
+ /**
760
+ * @deprecated Use ArtistOS with consent={{ mode: 'c15t' }} instead
761
+ */
762
+ export declare function useC15tConsent(config: Required<ConsentConfig>): ConsentState;
763
+
764
+ /**
765
+ * ArtistOS with Built-in Consent (used internally by ArtistOS)
766
+ */
767
+ export declare function ArtistOSWithBuiltIn(props: {
768
+ config: ResolvedConfig;
769
+ children?: React.ReactNode;
770
+ }): JSX.Element;
771
+
772
+ /**
773
+ * ArtistOS Core - No consent UI (used for external/disabled modes)
774
+ */
775
+ export declare function ArtistOSCore(props: {
776
+ config: ResolvedConfig;
777
+ children?: React.ReactNode;
778
+ }): JSX.Element;
779
+
780
+ /**
781
+ * ArtistOS with c15t Integration
782
+ * Requires @c15t/react to be installed
783
+ */
784
+ export declare function ArtistOSWithC15t(props: {
785
+ config: ResolvedConfig;
786
+ children?: React.ReactNode;
787
+ }): JSX.Element;
788
+
789
+ /**
790
+ * ArtistOS Context - for building custom integrations
791
+ */
792
+ export declare const ArtistOSContext: React.Context<ArtistOSContextValue | null>;
793
+
794
+ /**
795
+ * Pixel Script Loader component
796
+ */
797
+ export declare function PixelScriptLoader(props: { config: ResolvedConfig }): JSX.Element | null;
798
+
799
+ /**
800
+ * GTM Script Loader component
801
+ */
802
+ export declare function GTMScriptLoader(props: { config: ResolvedConfig }): JSX.Element | null;
803
+
804
+ /**
805
+ * Consent UI Manager component
806
+ */
807
+ export declare function ConsentUIManager(props: {
808
+ config: ResolvedConfig;
809
+ consentState: ConsentState;
810
+ }): JSX.Element | null;
811
+
812
+ /**
813
+ * Hook to sync GTM consent with Balance consent
814
+ */
815
+ export declare function useGTMConsentSync(
816
+ config: ResolvedConfig,
817
+ consentState: ConsentState
818
+ ): void;
819
+
820
+ // ============================================
821
+ // c15t Integration Types
822
+ // ============================================
823
+
824
+ /**
825
+ * c15t Consent Manager interface (from @c15t/react)
826
+ */
827
+ export interface C15tConsentManager {
828
+ consents: Record<string, boolean> | null;
829
+ hasConsented: () => boolean;
830
+ hasConsentFor: (category: string) => boolean;
831
+ setConsent: (category: string, value: boolean) => void;
832
+ saveConsents: (source?: string) => void;
833
+ acceptAll: () => void;
834
+ rejectAll: () => void;
835
+ }
836
+
837
+ /**
838
+ * Hook that bridges c15t consent to ArtistOS ConsentState
839
+ */
840
+ export declare function useC15tConsentState(
841
+ c15tManager: C15tConsentManager,
842
+ config: Required<ConsentConfig>
843
+ ): ConsentState;
844
+
845
+ // ============================================
846
+ // Consent Mapping Helpers
847
+ // ============================================
848
+
849
+ /**
850
+ * Mapping from c15t consent categories to Balance consent types
851
+ */
852
+ export declare const C15T_TO_BALANCE_MAP: {
853
+ measurement: 'analytics';
854
+ marketing: 'marketing';
855
+ experience: 'personalization';
856
+ };
857
+
858
+ /**
859
+ * Mapping from Balance consent types to c15t categories
860
+ */
861
+ export declare const BALANCE_TO_C15T_MAP: {
862
+ analytics: 'measurement';
863
+ marketing: 'marketing';
864
+ personalization: 'experience';
865
+ };
866
+
867
+ /**
868
+ * Convert c15t consent state to Balance format
869
+ */
870
+ export declare function toBalanceConsent(c15tConsents: Record<string, boolean>): ConsentPreferences;
871
+
872
+ /**
873
+ * Convert Balance consent to c15t format
874
+ */
875
+ export declare function fromBalanceConsent(balanceConsent: ConsentPreferences): Record<string, boolean>;