@midas-aem/client 0.0.0-stage → 1.0.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.
- package/README.md +55 -3
- package/dist/index.cjs +1 -0
- package/dist/index.d.mts +43 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.mjs +1 -0
- package/dist/react.cjs +2 -0
- package/dist/react.d.mts +68 -0
- package/dist/react.d.ts +68 -0
- package/dist/react.mjs +2 -0
- package/package.json +42 -5
package/README.md
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @midas/client
|
|
2
|
+
|
|
3
|
+
Universal developer SDK and first-party React components for **MIDAS Autonomous Outbound & Town Crier Newsletters**.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @midas/client
|
|
11
|
+
# or
|
|
12
|
+
yarn add @midas/client
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @midas/client
|
|
15
|
+
2. React / Next.js 1-Line Drop-In Modal
|
|
16
|
+
Tsx
|
|
17
|
+
import { MidasModal } from '@midas/client/react';
|
|
18
|
+
|
|
19
|
+
export default function HeroSection() {
|
|
20
|
+
return (
|
|
21
|
+
<MidasModal
|
|
22
|
+
gongId="weekly-alpha"
|
|
23
|
+
developerToggle
|
|
24
|
+
accent="#7C3AED"
|
|
25
|
+
className="px-6 py-3 bg-purple-600 text-white font-bold rounded-xl"
|
|
26
|
+
>
|
|
27
|
+
Join 15,000+ Founders
|
|
28
|
+
</MidasModal>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
3. Isomorphic Backend / Node.js Usage
|
|
32
|
+
Automatically reads process.env.MIDAS_API_KEY:
|
|
33
|
+
TypeScript
|
|
34
|
+
import { MidasClient } from '@midas/client';
|
|
35
|
+
|
|
36
|
+
// Zero arguments needed in environments with MIDAS_API_KEY defined
|
|
37
|
+
const midas = new MidasClient();
|
|
38
|
+
|
|
39
|
+
await midas.subscribe({
|
|
40
|
+
email: 'subscriber@acme.com',
|
|
41
|
+
name: 'Alex Mercer',
|
|
42
|
+
gongId: 'weekly-alpha',
|
|
43
|
+
cadence: 'weekly',
|
|
44
|
+
metadata: { isTechnicalFounder: true }
|
|
45
|
+
});
|
|
46
|
+
4. Props Reference (<MidasModal />)
|
|
47
|
+
Prop Type Default Description
|
|
48
|
+
gongId string undefined Target Gong publication channel ID or slug.
|
|
49
|
+
developerToggle boolean false Enables progressive profiling toggle that reveals GitHub URL input.
|
|
50
|
+
cadenceToggle boolean true Enables interactive frequency pills (Daily, Weekly, Monthly).
|
|
51
|
+
accent string #2563EB Hex color code for submit button & active focus rings.
|
|
52
|
+
fields string[] ['name', 'email'] Array of field tokens to collect dynamically.
|
|
53
|
+
headline string 'Join our Newsletter' Main heading in modal dialog.
|
|
54
|
+
subheadline string 'Get updates...' Supporting lead magnet or discount copy.
|
|
55
|
+
buttonText string 'Subscribe' Label on submit button.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var l=(n,e)=>{for(var t in e)s(n,t,{get:e[t],enumerable:!0})},g=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of d(e))!p.call(n,r)&&r!==t&&s(n,r,{get:()=>e[r],enumerable:!(i=c(e,r))||i.enumerable});return n};var h=n=>g(s({},"__esModule",{value:!0}),n);var w={};l(w,{MidasClient:()=>a,TownCrierClient:()=>u});module.exports=h(w);var a=class{apiKey;baseUrl;constructor(e){let t=e?.apiKey?.trim();if(!t&&typeof process<"u"&&process.env&&(t=(process.env.MIDAS_API_KEY||process.env.TOWN_CRIER_API_KEY||process.env.NEXT_PUBLIC_MIDAS_API_KEY||process.env.VITE_MIDAS_API_KEY)?.trim()),!t&&typeof window<"u")try{let r=new Function("try { return import.meta.env; } catch (e) { return null; }")();r&&r.VITE_MIDAS_API_KEY&&(t=String(r.VITE_MIDAS_API_KEY).trim())}catch{}if(!t||!t.startsWith("midas_live_")&&!t.startsWith("tc_live_"))throw new Error('MidasClient: A valid API key starting with "midas_live_" or "tc_live_" is required. Pass apiKey to the constructor or define MIDAS_API_KEY in your environment variables.');this.apiKey=t,this.baseUrl=(e?.baseUrl||typeof process<"u"&&process.env?.MIDAS_BASE_URL||(typeof window<"u"?window.location.origin:"https://midas-aem.vercel.app")).replace(/\/$/,"")}async subscribe(e){if(!e.email||!e.email.includes("@"))throw new Error("MidasClient: A valid email address is required.");let t=`${this.baseUrl}/api/public/town-crier/subscribe`,i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({email:e.email.trim().toLowerCase(),name:e.name?.trim()||void 0,cadence:e.cadence||"weekly",tags:e.tags||["sdk_signup"],gongId:e.gongId?.trim()||void 0,campaignId:e.campaignId?.trim()||void 0,metadata:e.metadata||void 0})}),r=await i.json().catch(()=>({}));if(!i.ok)throw new Error(r.error||`Subscription failed (HTTP ${i.status})`);return r}async listGongs(){let e=`${this.baseUrl}/api/public/town-crier/gongs`,t=await fetch(e,{headers:{Authorization:`Bearer ${this.apiKey}`}}),i=await t.json().catch(()=>({}));if(!t.ok)throw new Error(i.error||"Failed to list Gongs");return i.gongs||[]}async publishBroadcast(e,t){let i=`${this.baseUrl}/api/public/town-crier/gongs/${e}/broadcast`,r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify(t)}),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o.error||"Failed to publish broadcast");return o}async getStats(){let e=`${this.baseUrl}/api/public/town-crier/stats`,t=await fetch(e,{headers:{Authorization:`Bearer ${this.apiKey}`}}),i=await t.json().catch(()=>({}));if(!t.ok)throw new Error(i.error||"Failed to fetch telemetry");return i}},u=a;0&&(module.exports={MidasClient,TownCrierClient});
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
interface MidasSubscribeOptions {
|
|
2
|
+
email: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
cadence?: 'daily' | 'weekly' | 'biweekly' | 'monthly' | string;
|
|
5
|
+
tags?: string[];
|
|
6
|
+
gongId?: string;
|
|
7
|
+
campaignId?: string;
|
|
8
|
+
metadata?: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
interface MidasClientConfig {
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
declare class MidasClient {
|
|
15
|
+
private apiKey;
|
|
16
|
+
private baseUrl;
|
|
17
|
+
constructor(config?: MidasClientConfig);
|
|
18
|
+
/**
|
|
19
|
+
* Ingest a subscriber.
|
|
20
|
+
* If gongId is specified and the channel has welcome autoresponders enabled,
|
|
21
|
+
* Midas dispatches the welcome lead-magnet email automatically in <60 seconds.
|
|
22
|
+
*/
|
|
23
|
+
subscribe(options: MidasSubscribeOptions): Promise<any>;
|
|
24
|
+
/**
|
|
25
|
+
* Programmatically query all active Gong publication channels
|
|
26
|
+
*/
|
|
27
|
+
listGongs(): Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Headlessly publish a broadcast newsletter issue to a Gong channel
|
|
30
|
+
*/
|
|
31
|
+
publishBroadcast(gongId: string, issue: {
|
|
32
|
+
subject: string;
|
|
33
|
+
body: string;
|
|
34
|
+
templateStyle?: string;
|
|
35
|
+
}): Promise<any>;
|
|
36
|
+
/**
|
|
37
|
+
* Probe real-time audience and delivery telemetry
|
|
38
|
+
*/
|
|
39
|
+
getStats(): Promise<any>;
|
|
40
|
+
}
|
|
41
|
+
declare const TownCrierClient: typeof MidasClient;
|
|
42
|
+
|
|
43
|
+
export { MidasClient, type MidasClientConfig, type MidasSubscribeOptions, TownCrierClient };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
interface MidasSubscribeOptions {
|
|
2
|
+
email: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
cadence?: 'daily' | 'weekly' | 'biweekly' | 'monthly' | string;
|
|
5
|
+
tags?: string[];
|
|
6
|
+
gongId?: string;
|
|
7
|
+
campaignId?: string;
|
|
8
|
+
metadata?: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
interface MidasClientConfig {
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
declare class MidasClient {
|
|
15
|
+
private apiKey;
|
|
16
|
+
private baseUrl;
|
|
17
|
+
constructor(config?: MidasClientConfig);
|
|
18
|
+
/**
|
|
19
|
+
* Ingest a subscriber.
|
|
20
|
+
* If gongId is specified and the channel has welcome autoresponders enabled,
|
|
21
|
+
* Midas dispatches the welcome lead-magnet email automatically in <60 seconds.
|
|
22
|
+
*/
|
|
23
|
+
subscribe(options: MidasSubscribeOptions): Promise<any>;
|
|
24
|
+
/**
|
|
25
|
+
* Programmatically query all active Gong publication channels
|
|
26
|
+
*/
|
|
27
|
+
listGongs(): Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Headlessly publish a broadcast newsletter issue to a Gong channel
|
|
30
|
+
*/
|
|
31
|
+
publishBroadcast(gongId: string, issue: {
|
|
32
|
+
subject: string;
|
|
33
|
+
body: string;
|
|
34
|
+
templateStyle?: string;
|
|
35
|
+
}): Promise<any>;
|
|
36
|
+
/**
|
|
37
|
+
* Probe real-time audience and delivery telemetry
|
|
38
|
+
*/
|
|
39
|
+
getStats(): Promise<any>;
|
|
40
|
+
}
|
|
41
|
+
declare const TownCrierClient: typeof MidasClient;
|
|
42
|
+
|
|
43
|
+
export { MidasClient, type MidasClientConfig, type MidasSubscribeOptions, TownCrierClient };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=class{apiKey;baseUrl;constructor(e){let t=e?.apiKey?.trim();if(!t&&typeof process<"u"&&process.env&&(t=(process.env.MIDAS_API_KEY||process.env.TOWN_CRIER_API_KEY||process.env.NEXT_PUBLIC_MIDAS_API_KEY||process.env.VITE_MIDAS_API_KEY)?.trim()),!t&&typeof window<"u")try{let r=new Function("try { return import.meta.env; } catch (e) { return null; }")();r&&r.VITE_MIDAS_API_KEY&&(t=String(r.VITE_MIDAS_API_KEY).trim())}catch{}if(!t||!t.startsWith("midas_live_")&&!t.startsWith("tc_live_"))throw new Error('MidasClient: A valid API key starting with "midas_live_" or "tc_live_" is required. Pass apiKey to the constructor or define MIDAS_API_KEY in your environment variables.');this.apiKey=t,this.baseUrl=(e?.baseUrl||typeof process<"u"&&process.env?.MIDAS_BASE_URL||(typeof window<"u"?window.location.origin:"https://midas-aem.vercel.app")).replace(/\/$/,"")}async subscribe(e){if(!e.email||!e.email.includes("@"))throw new Error("MidasClient: A valid email address is required.");let t=`${this.baseUrl}/api/public/town-crier/subscribe`,i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({email:e.email.trim().toLowerCase(),name:e.name?.trim()||void 0,cadence:e.cadence||"weekly",tags:e.tags||["sdk_signup"],gongId:e.gongId?.trim()||void 0,campaignId:e.campaignId?.trim()||void 0,metadata:e.metadata||void 0})}),r=await i.json().catch(()=>({}));if(!i.ok)throw new Error(r.error||`Subscription failed (HTTP ${i.status})`);return r}async listGongs(){let e=`${this.baseUrl}/api/public/town-crier/gongs`,t=await fetch(e,{headers:{Authorization:`Bearer ${this.apiKey}`}}),i=await t.json().catch(()=>({}));if(!t.ok)throw new Error(i.error||"Failed to list Gongs");return i.gongs||[]}async publishBroadcast(e,t){let i=`${this.baseUrl}/api/public/town-crier/gongs/${e}/broadcast`,r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify(t)}),a=await r.json().catch(()=>({}));if(!r.ok)throw new Error(a.error||"Failed to publish broadcast");return a}async getStats(){let e=`${this.baseUrl}/api/public/town-crier/stats`,t=await fetch(e,{headers:{Authorization:`Bearer ${this.apiKey}`}}),i=await t.json().catch(()=>({}));if(!t.ok)throw new Error(i.error||"Failed to fetch telemetry");return i}},o=n;export{n as MidasClient,o as TownCrierClient};
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var u=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var T=(n,t)=>{for(var a in t)u(n,a,{get:t[a],enumerable:!0})},I=(n,t,a,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of F(t))!C.call(n,i)&&i!==a&&u(n,i,{get:()=>t[i],enumerable:!(s=x(t,i))||s.enumerable});return n};var E=n=>I(u({},"__esModule",{value:!0}),n);var k={};T(k,{MidasEmbed:()=>S,MidasModal:()=>f,TownCrierModal:()=>N,useMidasModal:()=>w,useTownCrierModal:()=>K});module.exports=E(k);var d=require("react"),b=require("react/jsx-runtime");function w(n){let[t,a]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{if(typeof window<"u"&&!window.TownCrier&&!document.querySelector('script[src*="widget.js"]')){let e=document.createElement("script");e.src="https://midas-aem.vercel.app/api/public/town-crier/widget.js",e.async=!0,document.head.appendChild(e)}},[]),{open:(0,d.useCallback)(i=>{let e={...n,...i},o=[...e.fields||["name","email","cadence"]];if(e.developerToggle&&!o.includes("developer")&&o.push("developer"),typeof window<"u"&&window.TownCrier?.openModal)window.TownCrier.openModal({apiKey:e.apiKey,gongId:e.gongId,headline:e.headline,accent:e.accent,fields:o}),a(!0);else{let r=0,c=setInterval(()=>{r++,window.TownCrier?.openModal?(clearInterval(c),window.TownCrier.openModal({apiKey:e.apiKey,gongId:e.gongId,headline:e.headline,accent:e.accent,fields:o}),a(!0)):r>10&&(clearInterval(c),console.error("Midas: widget.js failed to load. Check network connection."))},150)}},[n]),isOpen:t}}var K=w,f=({apiKey:n,gongId:t,fields:a,developerToggle:s=!1,cadenceToggle:i=!0,accent:e="#2563EB",bg:o="#FFFFFF",text:r="#18181B",radius:c="20px",headline:p="Join our Newsletter",subheadline:g="Get high-signal insights delivered to your inbox.",buttonText:y="Subscribe",className:m="",style:h,children:v="Subscribe to Newsletter"})=>{let l=a?[...a]:["name","email"];i&&!l.includes("cadence")&&l.push("cadence"),s&&!l.includes("developer")&&l.push("developer");let{open:M}=w({apiKey:n,gongId:t,headline:p,accent:e,fields:l});return(0,b.jsx)("button",{type:"button",onClick:()=>M(),"data-town-crier-modal":!0,"data-key":n,"data-gong":t,"data-fields":l.join(","),"data-headline":p,"data-subheadline":g,"data-accent":e,"data-bg":o,"data-text":r,"data-radius":c,"data-button":y,className:m,style:h,children:v})},N=f,S=({apiKey:n,gongId:t,layout:a="card",accent:s="#2563EB",bg:i="#FFFFFF",radius:e="16px",headline:o="Join our newsletter",subheadline:r="Get updates in your inbox.",buttonText:c="Subscribe",className:p=""})=>((0,d.useEffect)(()=>{if(typeof window<"u"&&!window.TownCrier){let g=document.createElement("script");g.src="https://midas-aem.vercel.app/api/public/town-crier/widget.js",g.async=!0,document.head.appendChild(g)}},[]),(0,b.jsx)("div",{"data-town-crier-embed":!0,"data-key":n,"data-gong":t,"data-layout":a,"data-accent":s,"data-bg":i,"data-radius":e,"data-headline":o,"data-subheadline":r,"data-button":c,className:p}));0&&(module.exports={MidasEmbed,MidasModal,TownCrierModal,useMidasModal,useTownCrierModal});
|
package/dist/react.d.mts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface MidasModalProps {
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
gongId?: string;
|
|
6
|
+
fields?: Array<'email' | 'name' | 'company' | 'cadence' | 'developer' | string>;
|
|
7
|
+
developerToggle?: boolean;
|
|
8
|
+
cadenceToggle?: boolean;
|
|
9
|
+
accent?: string;
|
|
10
|
+
bg?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
radius?: string;
|
|
13
|
+
headline?: string;
|
|
14
|
+
subheadline?: string;
|
|
15
|
+
buttonText?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
style?: React.CSSProperties;
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
interface MidasEmbedProps {
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
gongId?: string;
|
|
23
|
+
layout?: 'card' | 'horizontal';
|
|
24
|
+
accent?: string;
|
|
25
|
+
bg?: string;
|
|
26
|
+
radius?: string;
|
|
27
|
+
headline?: string;
|
|
28
|
+
subheadline?: string;
|
|
29
|
+
buttonText?: string;
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Native React Hook for triggering the Midas modal imperatively
|
|
34
|
+
*/
|
|
35
|
+
declare function useMidasModal(defaultConfig?: {
|
|
36
|
+
apiKey?: string;
|
|
37
|
+
gongId?: string;
|
|
38
|
+
headline?: string;
|
|
39
|
+
accent?: string;
|
|
40
|
+
fields?: string[];
|
|
41
|
+
developerToggle?: boolean;
|
|
42
|
+
}): {
|
|
43
|
+
open: (overrideConfig?: {
|
|
44
|
+
apiKey?: string;
|
|
45
|
+
gongId?: string;
|
|
46
|
+
headline?: string;
|
|
47
|
+
accent?: string;
|
|
48
|
+
fields?: string[];
|
|
49
|
+
developerToggle?: boolean;
|
|
50
|
+
}) => void;
|
|
51
|
+
isOpen: boolean;
|
|
52
|
+
};
|
|
53
|
+
declare const useTownCrierModal: typeof useMidasModal;
|
|
54
|
+
/**
|
|
55
|
+
* 1-Line Clerk-Parity React Component Wrapper
|
|
56
|
+
* Usage:
|
|
57
|
+
* <MidasModal gongId="saas-weekly" developerToggle accent="#7C3AED">
|
|
58
|
+
* Join the Newsletter
|
|
59
|
+
* </MidasModal>
|
|
60
|
+
*/
|
|
61
|
+
declare const MidasModal: React.FC<MidasModalProps>;
|
|
62
|
+
declare const TownCrierModal: React.FC<MidasModalProps>;
|
|
63
|
+
/**
|
|
64
|
+
* In-Page Responsive Inline Card Component
|
|
65
|
+
*/
|
|
66
|
+
declare const MidasEmbed: React.FC<MidasEmbedProps>;
|
|
67
|
+
|
|
68
|
+
export { MidasEmbed, type MidasEmbedProps, MidasModal, type MidasModalProps, TownCrierModal, useMidasModal, useTownCrierModal };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface MidasModalProps {
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
gongId?: string;
|
|
6
|
+
fields?: Array<'email' | 'name' | 'company' | 'cadence' | 'developer' | string>;
|
|
7
|
+
developerToggle?: boolean;
|
|
8
|
+
cadenceToggle?: boolean;
|
|
9
|
+
accent?: string;
|
|
10
|
+
bg?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
radius?: string;
|
|
13
|
+
headline?: string;
|
|
14
|
+
subheadline?: string;
|
|
15
|
+
buttonText?: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
style?: React.CSSProperties;
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
interface MidasEmbedProps {
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
gongId?: string;
|
|
23
|
+
layout?: 'card' | 'horizontal';
|
|
24
|
+
accent?: string;
|
|
25
|
+
bg?: string;
|
|
26
|
+
radius?: string;
|
|
27
|
+
headline?: string;
|
|
28
|
+
subheadline?: string;
|
|
29
|
+
buttonText?: string;
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Native React Hook for triggering the Midas modal imperatively
|
|
34
|
+
*/
|
|
35
|
+
declare function useMidasModal(defaultConfig?: {
|
|
36
|
+
apiKey?: string;
|
|
37
|
+
gongId?: string;
|
|
38
|
+
headline?: string;
|
|
39
|
+
accent?: string;
|
|
40
|
+
fields?: string[];
|
|
41
|
+
developerToggle?: boolean;
|
|
42
|
+
}): {
|
|
43
|
+
open: (overrideConfig?: {
|
|
44
|
+
apiKey?: string;
|
|
45
|
+
gongId?: string;
|
|
46
|
+
headline?: string;
|
|
47
|
+
accent?: string;
|
|
48
|
+
fields?: string[];
|
|
49
|
+
developerToggle?: boolean;
|
|
50
|
+
}) => void;
|
|
51
|
+
isOpen: boolean;
|
|
52
|
+
};
|
|
53
|
+
declare const useTownCrierModal: typeof useMidasModal;
|
|
54
|
+
/**
|
|
55
|
+
* 1-Line Clerk-Parity React Component Wrapper
|
|
56
|
+
* Usage:
|
|
57
|
+
* <MidasModal gongId="saas-weekly" developerToggle accent="#7C3AED">
|
|
58
|
+
* Join the Newsletter
|
|
59
|
+
* </MidasModal>
|
|
60
|
+
*/
|
|
61
|
+
declare const MidasModal: React.FC<MidasModalProps>;
|
|
62
|
+
declare const TownCrierModal: React.FC<MidasModalProps>;
|
|
63
|
+
/**
|
|
64
|
+
* In-Page Responsive Inline Card Component
|
|
65
|
+
*/
|
|
66
|
+
declare const MidasEmbed: React.FC<MidasEmbedProps>;
|
|
67
|
+
|
|
68
|
+
export { MidasEmbed, type MidasEmbedProps, MidasModal, type MidasModalProps, TownCrierModal, useMidasModal, useTownCrierModal };
|
package/dist/react.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import{useCallback as v,useState as M,useEffect as p}from"react";import{jsx as w}from"react/jsx-runtime";function u(n){let[i,a]=M(!1);return p(()=>{if(typeof window<"u"&&!window.TownCrier&&!document.querySelector('script[src*="widget.js"]')){let e=document.createElement("script");e.src="https://midas-aem.vercel.app/api/public/town-crier/widget.js",e.async=!0,document.head.appendChild(e)}},[]),{open:v(o=>{let e={...n,...o},t=[...e.fields||["name","email","cadence"]];if(e.developerToggle&&!t.includes("developer")&&t.push("developer"),typeof window<"u"&&window.TownCrier?.openModal)window.TownCrier.openModal({apiKey:e.apiKey,gongId:e.gongId,headline:e.headline,accent:e.accent,fields:t}),a(!0);else{let s=0,d=setInterval(()=>{s++,window.TownCrier?.openModal?(clearInterval(d),window.TownCrier.openModal({apiKey:e.apiKey,gongId:e.gongId,headline:e.headline,accent:e.accent,fields:t}),a(!0)):s>10&&(clearInterval(d),console.error("Midas: widget.js failed to load. Check network connection."))},150)}},[n]),isOpen:i}}var T=u,x=({apiKey:n,gongId:i,fields:a,developerToggle:l=!1,cadenceToggle:o=!0,accent:e="#2563EB",bg:t="#FFFFFF",text:s="#18181B",radius:d="20px",headline:g="Join our Newsletter",subheadline:c="Get high-signal insights delivered to your inbox.",buttonText:b="Subscribe",className:f="",style:y,children:m="Subscribe to Newsletter"})=>{let r=a?[...a]:["name","email"];o&&!r.includes("cadence")&&r.push("cadence"),l&&!r.includes("developer")&&r.push("developer");let{open:h}=u({apiKey:n,gongId:i,headline:g,accent:e,fields:r});return w("button",{type:"button",onClick:()=>h(),"data-town-crier-modal":!0,"data-key":n,"data-gong":i,"data-fields":r.join(","),"data-headline":g,"data-subheadline":c,"data-accent":e,"data-bg":t,"data-text":s,"data-radius":d,"data-button":b,className:f,style:y,children:m})},I=x,E=({apiKey:n,gongId:i,layout:a="card",accent:l="#2563EB",bg:o="#FFFFFF",radius:e="16px",headline:t="Join our newsletter",subheadline:s="Get updates in your inbox.",buttonText:d="Subscribe",className:g=""})=>(p(()=>{if(typeof window<"u"&&!window.TownCrier){let c=document.createElement("script");c.src="https://midas-aem.vercel.app/api/public/town-crier/widget.js",c.async=!0,document.head.appendChild(c)}},[]),w("div",{"data-town-crier-embed":!0,"data-key":n,"data-gong":i,"data-layout":a,"data-accent":l,"data-bg":o,"data-radius":e,"data-headline":t,"data-subheadline":s,"data-button":d,className:g}));export{E as MidasEmbed,x as MidasModal,I as TownCrierModal,u as useMidasModal,T as useTownCrierModal};
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@midas-aem/client",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
1
|
+
{
|
|
2
|
+
"name": "@midas-aem/client",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Universal SDK and first-party React/Next.js components for Midas Autonomous Outbound & Town Crier Newsletters",
|
|
5
|
+
"author": "Pyrexx AI",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./react": {
|
|
17
|
+
"types": "./dist/react.d.ts",
|
|
18
|
+
"import": "./dist/react.mjs",
|
|
19
|
+
"require": "./dist/react.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"prepublishOnly": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": ">=18.0.0"
|
|
31
|
+
},
|
|
32
|
+
"peerDependenciesMeta": {
|
|
33
|
+
"react": {
|
|
34
|
+
"optional": true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/react": "^18.2.45",
|
|
39
|
+
"react": "^18.2.0",
|
|
40
|
+
"tsup": "^8.5.1",
|
|
41
|
+
"typescript": "^5.3.3"
|
|
42
|
+
}
|
|
6
43
|
}
|