@flonix/ig-embed 0.0.0-stage → 0.1.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.
@@ -0,0 +1,199 @@
1
+ /** shadcn-style design tokens. Every value is a raw CSS color string so a
2
+ * host can pass any format (hex, rgb(), hsl(), oklch(), var(), …). */
3
+ interface ThemeTokens {
4
+ background: string;
5
+ foreground: string;
6
+ card: string;
7
+ cardForeground: string;
8
+ popover: string;
9
+ popoverForeground: string;
10
+ primary: string;
11
+ primaryForeground: string;
12
+ secondary: string;
13
+ secondaryForeground: string;
14
+ muted: string;
15
+ mutedForeground: string;
16
+ accent: string;
17
+ accentForeground: string;
18
+ destructive: string;
19
+ destructiveForeground: string;
20
+ border: string;
21
+ input: string;
22
+ ring: string;
23
+ }
24
+ type ThemeMode = "light" | "dark" | "auto";
25
+ interface ThemeConfig {
26
+ /** `auto` follows the host's `prefers-color-scheme`. Default: `auto`. */
27
+ mode?: ThemeMode;
28
+ /** CSS font-family stack. Default: Flonix font. */
29
+ fontFamily?: string;
30
+ /** Base corner radius, any CSS length. Default: `12px`. */
31
+ radius?: string;
32
+ /** Per-mode token overrides. Anything omitted falls back to Flonix defaults. */
33
+ tokens?: {
34
+ light?: Partial<ThemeTokens>;
35
+ dark?: Partial<ThemeTokens>;
36
+ };
37
+ }
38
+ /** The end-user inside the host platform (e.g. a partner merchant). */
39
+ interface FlonixUser {
40
+ id: string;
41
+ email?: string;
42
+ name?: string;
43
+ }
44
+ /**
45
+ * Partner co-branding. The logo is shown next to the Flonix mark as
46
+ * "<partner logo> × flonix".
47
+ *
48
+ * `logo` / `logoDark` accept any image — an https URL or a data URI, in any
49
+ * format (SVG, PNG, WebP…). The logo is displayed at **18px height, width auto
50
+ * (max 120px)**, so supply a transparent-background asset ideally ~2× that
51
+ * (≈40px tall / SVG) for a crisp result.
52
+ */
53
+ interface PartnerBranding {
54
+ /** Partner/brand name — used as the logo's alt text. */
55
+ name: string;
56
+ /** Logo shown in light theme (and dark, if `logoDark` is omitted). */
57
+ logo: string;
58
+ /** Optional logo variant for dark theme. Falls back to `logo`. */
59
+ logoDark?: string;
60
+ }
61
+ interface InstagramAccount {
62
+ instagramId: string | null;
63
+ username: string | null;
64
+ }
65
+ type MediaType = "IMAGE" | "VIDEO" | "CAROUSEL" | "REELS";
66
+ interface InstagramPost {
67
+ id: string;
68
+ caption: string | null;
69
+ media: string | null;
70
+ mediaType: MediaType;
71
+ permalink?: string | null;
72
+ timestamp?: string | null;
73
+ }
74
+ type AutomationType = "COMMENT" | "DM";
75
+ /** A link button delivered in the DM (label + destination URL). Max 3. */
76
+ interface LinkButton {
77
+ label: string;
78
+ url: string;
79
+ }
80
+ declare const MAX_LINK_BUTTONS = 3;
81
+ interface FollowGateConfig {
82
+ enabled: boolean;
83
+ followProfileUrl: string;
84
+ followButtonLabel: string;
85
+ followConfirmButtonLabel: string;
86
+ followUpMessage: string;
87
+ }
88
+ interface CreateAutomationInput {
89
+ postId: string;
90
+ type: AutomationType;
91
+ name: string;
92
+ /** Trigger keywords (comment text / DM text). */
93
+ keywords: string[];
94
+ /** Public reply posted under the comment (COMMENT automations). */
95
+ commentReply: string | null;
96
+ /** Label on the opt-in button of the first DM. */
97
+ entryButtonLabel: string;
98
+ /** The DM delivered to the user. */
99
+ deliveryMessage: string;
100
+ /** Up to MAX_LINK_BUTTONS link buttons delivered with the DM. */
101
+ linkButtons: LinkButton[];
102
+ followGate: FollowGateConfig;
103
+ }
104
+ interface SessionResponse {
105
+ connected: boolean;
106
+ token: string;
107
+ account: InstagramAccount | null;
108
+ }
109
+ interface ConnectStartResponse {
110
+ authorizeUrl: string;
111
+ }
112
+ interface PostsResponse {
113
+ posts: InstagramPost[];
114
+ nextCursor: string | null;
115
+ }
116
+ interface CreateAutomationResponse {
117
+ id: string;
118
+ }
119
+ /** Transport abstraction. The real implementation hits `/api/embed/*`;
120
+ * the demo injects a mock. */
121
+ interface Transport {
122
+ session(input: {
123
+ apiKey: string;
124
+ user: FlonixUser;
125
+ }): Promise<SessionResponse>;
126
+ connectStart(input: {
127
+ token: string;
128
+ returnUrl: string;
129
+ }): Promise<ConnectStartResponse>;
130
+ posts(input: {
131
+ token: string;
132
+ cursor: string | null;
133
+ }): Promise<PostsResponse>;
134
+ createAutomation(input: {
135
+ token: string;
136
+ data: CreateAutomationInput;
137
+ }): Promise<CreateAutomationResponse>;
138
+ }
139
+ interface FlonixIGConfig {
140
+ /** Org API key issued from the Flonix admin dashboard. */
141
+ apiKey: string;
142
+ /** The host platform's end-user. `id` must be stable per merchant. */
143
+ user: FlonixUser;
144
+ /** Co-branding (required): renders "<partner logo> × flonix". */
145
+ partner: PartnerBranding;
146
+ /** Flonix base URL. Default: `https://flonix.pro`. */
147
+ baseUrl?: string;
148
+ /** Where Instagram OAuth returns to. Default: current page URL. */
149
+ returnUrl?: string;
150
+ /** Theme + branding customization. */
151
+ theme?: ThemeConfig;
152
+ onConnected?: (account: InstagramAccount) => void;
153
+ onAutomationCreated?: (automation: CreateAutomationResponse) => void;
154
+ onError?: (error: Error) => void;
155
+ /** Advanced/testing: inject a custom transport (the demo uses this). */
156
+ transport?: Transport;
157
+ }
158
+ interface FlonixIGInstance {
159
+ /** Re-fetch session + posts. */
160
+ refresh(): void;
161
+ /** Tear down the widget and detach from the DOM. */
162
+ unmount(): void;
163
+ }
164
+
165
+ interface MockOptions {
166
+ /** Pages of posts to serve before stopping. Default 3. */
167
+ totalPages?: number;
168
+ /** Posts per page. Default 8. */
169
+ perPage?: number;
170
+ /** localStorage key suffix so multiple demos don't collide. */
171
+ namespace?: string;
172
+ }
173
+ declare function createMockTransport(options?: MockOptions): Transport;
174
+
175
+ declare function createHttpTransport(baseUrl: string): Transport;
176
+
177
+ /** Flonix brand defaults for both color schemes. Hosts override any subset. */
178
+ declare const DEFAULT_TOKENS: {
179
+ light: ThemeTokens;
180
+ dark: ThemeTokens;
181
+ };
182
+
183
+ declare const version = "0.1.0";
184
+ /**
185
+ * Mount the Flonix Instagram automation widget into a container.
186
+ *
187
+ * @example
188
+ * FlonixIG.mount("#flonix", {
189
+ * apiKey: "flxig.…",
190
+ * user: { id: "merchant_42", email: "me@shop.com" },
191
+ * })
192
+ */
193
+ declare function mount(target: string | HTMLElement, config: FlonixIGConfig): FlonixIGInstance;
194
+ declare const FlonixIG: {
195
+ mount: typeof mount;
196
+ version: string;
197
+ };
198
+
199
+ export { type AutomationType, type ConnectStartResponse, type CreateAutomationInput, type CreateAutomationResponse, DEFAULT_TOKENS, FlonixIG, type FlonixIGConfig, type FlonixIGInstance, type FlonixUser, type FollowGateConfig, type InstagramAccount, type InstagramPost, type LinkButton, MAX_LINK_BUTTONS, type MediaType, type PartnerBranding, type PostsResponse, type SessionResponse, type ThemeConfig, type ThemeMode, type ThemeTokens, type Transport, createHttpTransport, createMockTransport, mount, version };