@getuserfeedback/sdk 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.
package/README.md ADDED
@@ -0,0 +1,319 @@
1
+ # @getuserfeedback/sdk
2
+
3
+ Secure, performant, and tiny SDK for [getuserfeedback.com](https://getuserfeedback.com).
4
+
5
+ `@getuserfeedback/sdk` lets you easily add in-app messaging and micro-surveys optimized to help you connect with users, build trust, guide development, and avoid building in a vacuum.
6
+
7
+ > Using React? Check out [@getuserfeedback/react](https://www.npmjs.com/package/@getuserfeedback/react).
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @getuserfeedback/sdk
13
+ ```
14
+
15
+ ## Get Started
16
+
17
+ ### 1. Get an API key
18
+ Sign up on [getuserfeedback.com](https://getuserfeedback.com) and grab your key in Settings.
19
+
20
+ ### 2. Wire the client
21
+
22
+ ```ts
23
+ // client.ts
24
+ import { createClient } from "@getuserfeedback/sdk";
25
+
26
+ export const client = createClient({
27
+ apiKey: "YOUR_API_KEY",
28
+ });
29
+
30
+ // identify user (e.g., on login)
31
+ client.identify(user.id, {
32
+ email: user.email,
33
+ firstName: user.firstName,
34
+ lastName: user.lastName,
35
+ });
36
+ ```
37
+
38
+ ### 3. Start collecting responses
39
+
40
+ Pick one of our curated templates on [getuserfeedback.com/templates](https://getuserfeedback.com/templates) — from a post-signup welcome message to customer satisfaction surveys, feedback forms, and more. You can also customize everything or start from scratch.
41
+
42
+ ### 4. Get feedback — improve product — repeat
43
+ Our widgets are optimized to get you *more* responses. Polished UI, crafted copy, templates, and a million subtle tricks. Result — you get more responses, make better roadmap calls, and find product-market fit faster.
44
+
45
+ ### Bonus
46
+ Our AI-powered theme editor allows a complete overhaul of the widget look and feel with a single prompt. Demo: [getuserfeedback.com/themes](https://getuserfeedback.com/themes).
47
+
48
+ ## Advanced use cases
49
+ ### Feedback form
50
+ You can call flows imperatively, e.g., open a feedback form when the user clicks a dedicated button in your UI.
51
+
52
+ ```ts
53
+ // feedback form you created on getuserfeedback.com
54
+ const FEEDBACK_FLOW_ID = "YOUR_FLOW_ID";
55
+
56
+ const button = document.querySelector<HTMLButtonElement>("#feedback-button");
57
+
58
+ button?.addEventListener("click", () => {
59
+ client.open(FEEDBACK_FLOW_ID);
60
+ });
61
+ ```
62
+
63
+ ### Bring your own UI
64
+ By default, flows are displayed in a floating container and [themed](https://getuserfeedback.com/themes) accordingly. Beyond that, you can replace the default floating container with your own. This gives you unprecedented customization options for a seamless user experience.
65
+
66
+ For example, if you're using custom dialogs throughout your product, our widgets can be seamlessly rendered into your dialogs and appear just like any other part of your app.
67
+
68
+ ```ts
69
+ const flow = await client.flow("YOUR_FLOW_ID");
70
+
71
+ // your custom container, e.g. a dialog
72
+ const container = document.querySelector<HTMLDivElement>("#feedback-dialog-body");
73
+
74
+ if (container) {
75
+ flow.setContainer(container);
76
+ }
77
+
78
+ flow.open({ containerRequirement: "hostOnly" });
79
+ ```
80
+
81
+ ## API Overview
82
+
83
+ - `createClient(options)`
84
+ - `client.identify(userId, traits?)` or `client.identify(traits)`
85
+ - `client.reset()`
86
+ - `client.open(flowId, options?)`
87
+ - `client.prefetch(flowId)`
88
+ - `client.prerender(flowId)`
89
+ - `client.flow(flowId)`
90
+ - `client.configure(updates)`
91
+ - `client.close()`
92
+ - `client.setContainer(element | null)`
93
+ - `client.setDefaultContainerPolicy(policy)`
94
+ - `client.subscribeFlowState(callback, options?)`
95
+
96
+ ## `createClient(options)`
97
+
98
+ Create a single SDK client and reuse it across your app.
99
+
100
+ ```ts
101
+ import { createClient } from "@getuserfeedback/sdk";
102
+
103
+ export const client = createClient({
104
+ apiKey: "YOUR_API_KEY",
105
+ });
106
+ ```
107
+
108
+ ### Options
109
+
110
+ - `apiKey` (`string`, required): your project API key.
111
+ - `colorScheme` (`"light" | "dark" | "system" | { autoDetectColorScheme: string[] }`, optional):
112
+ controls widget theme mode. See [Dark mode](#dark-mode).
113
+ - `disableAutoLoad` (`boolean`, optional): if `true`, call `client.load()` manually.
114
+ - `disableTelemetry` (`boolean`, optional): disables anonymous telemetry used for performance and error monitoring.
115
+
116
+ ### Notes
117
+
118
+ - If you call `createClient` again with the same `apiKey`, the SDK will return the same (stable) reference.
119
+
120
+ ### Delay widget load
121
+
122
+ If you want to manually control when the widget starts loading:
123
+
124
+ ```ts
125
+ import { createClient } from "@getuserfeedback/sdk";
126
+
127
+ export const client = createClient({
128
+ apiKey: "YOUR_API_KEY",
129
+ disableAutoLoad: true,
130
+ });
131
+
132
+ // later, when ready:
133
+ client.load();
134
+ ```
135
+
136
+ ## Identify users
137
+
138
+ Use identity to unlock cohort targeting and attach responses to user profiles.
139
+
140
+ ### `client.identify(userId, traits?)` or `client.identify(traits)`
141
+
142
+ ```ts
143
+ import { client } from "./client";
144
+
145
+ client.identify(user.id, {
146
+ email: user.email,
147
+ firstName: user.firstName,
148
+ lastName: user.lastName,
149
+ });
150
+ ```
151
+
152
+ Pass a stable `userId` when you have one. If you don't, use traits-only mode:
153
+
154
+ ```ts
155
+ import { client } from "./client";
156
+
157
+ client.identify({
158
+ email: user.email,
159
+ plan: user.plan,
160
+ });
161
+ ```
162
+
163
+ ### `client.reset()`
164
+
165
+ Call this on logout to clear active identity state and auth (if you use auth):
166
+
167
+ ```ts
168
+ import { client } from "./client";
169
+
170
+ client.reset();
171
+ ```
172
+
173
+ ## Dark mode
174
+
175
+ If you're using industry-standard ways to indicate when dark mode is *on*, the widget will pick it up and automatically keep itself in sync. If you only have light mode, the widget will stay in light mode.
176
+
177
+ Default behavior:
178
+ - The widget observes `class` and `data-theme` attributes on both `html` and `body`.
179
+ - `class="dark"` / `data-theme="dark"` enables dark mode.
180
+ - `class="light"` / `data-theme="light"` enables light mode.
181
+ - `class="system"` / `data-theme="system"` follows the user's system preference (`prefers-color-scheme`).
182
+ - If nothing is detected, it falls back to `"light"`.
183
+
184
+ You can control the behavior using the `colorScheme` option when creating a client, and you can also update it later.
185
+
186
+ ### Set a static color scheme at startup
187
+
188
+ ```ts
189
+ import { createClient } from "@getuserfeedback/sdk";
190
+
191
+ export const client = createClient({
192
+ apiKey: "YOUR_API_KEY",
193
+ colorScheme: "dark", // set to a static value
194
+ });
195
+ ```
196
+
197
+ `colorScheme` supports:
198
+ - `{ autoDetectColorScheme: string[] }`
199
+ - `"light" | "dark" | "system"`
200
+ ### Update color scheme at runtime
201
+
202
+ ```ts
203
+ client.configure({
204
+ colorScheme: "system", // follows user's system preference
205
+ });
206
+ ```
207
+
208
+ You can also switch runtime behavior back to host-driven auto-detection:
209
+
210
+ ```ts
211
+ client.configure({
212
+ colorScheme: {
213
+ autoDetectColorScheme: ["class", "data-theme"] // default
214
+ }
215
+ });
216
+ ```
217
+
218
+ ## Auth (optional)
219
+
220
+ You can run the SDK without auth. This is standard industry practice for client-side widgets like ours, so it is not enforced by default. However, we encourage you to implement auth for stricter controls.
221
+
222
+ Enable JWT validation in your workspace settings and pass a signed token from your app.
223
+
224
+ ### Set auth token
225
+
226
+ ```ts
227
+ client.configure({
228
+ auth: { jwt: { token: "YOUR_JWT" } },
229
+ });
230
+ ```
231
+
232
+ ### Refresh auth token
233
+
234
+ ```ts
235
+ client.configure({
236
+ auth: { jwt: { token: "YOUR_NEXT_JWT" } },
237
+ });
238
+ ```
239
+
240
+ ### Clear auth token
241
+
242
+ ```ts
243
+ client.configure({
244
+ auth: { jwt: null },
245
+ });
246
+
247
+ // also cleared on client.reset()
248
+ ```
249
+
250
+ ## Privacy and consent (GDPR, CCPA, etc)
251
+
252
+ Consent settings control non-essential data scopes: analytics, storage, personalization, ads.
253
+
254
+ By default, the widget starts with `granted` consent. For compliance with privacy regulations like GDPR and CCPA, you may want to choose a different default.
255
+
256
+ ### Set default consent to `pending`
257
+ ```ts
258
+ import { createClient } from "@getuserfeedback/sdk";
259
+
260
+ export const client = createClient({
261
+ apiKey: "YOUR_API_KEY",
262
+ defaultConsent: "pending", // set to `pending`
263
+ });
264
+ ```
265
+ With `pending` consent set by default, all non-essential data scopes are considered effectively denied.
266
+
267
+ ### Update consent at runtime
268
+
269
+ ```ts
270
+ client.configure({
271
+ consent: "granted",
272
+ });
273
+ ```
274
+
275
+ You can also pass explicit granted scopes instead:
276
+
277
+ ```ts
278
+ client.configure({
279
+ consent: ["analytics.measurement", "analytics.storage"],
280
+ });
281
+
282
+ ```
283
+ `defaultConsent` supports:
284
+ - `"pending" | "granted" (default) | "denied" | "revoked"`
285
+ - or a granted-scope list like `["analytics.measurement", "analytics.storage"]`
286
+
287
+ ### Impact of different consent settings
288
+
289
+ - Response collection: never affected.
290
+ - Imperative flow display: never affected.
291
+ - Cohort targeting: rules that depend on persisted activity, identity continuity, or storage-backed signals require both `analytics.measurement` and `analytics.storage`.
292
+ - Context targeting: rules based on current-page context (URL, referrer, timing, host signals) require `analytics.measurement` only.
293
+
294
+ ## Advanced — control flows imperatively
295
+
296
+ ### Open a flow
297
+
298
+ ```ts
299
+ client.open("YOUR_FLOW_ID");
300
+ ```
301
+
302
+ ### Prefetch and prerender
303
+
304
+ Prefetching loads flow resources over the network, prerendering warms up the UI.
305
+
306
+ ```ts
307
+ const flowId = "YOUR_FLOW_ID";
308
+ const button = document.querySelector<HTMLButtonElement>("#feedback-button");
309
+
310
+ button?.addEventListener("mouseenter", () => {
311
+ client.prerender(flowId);
312
+ });
313
+ ```
314
+
315
+ ## Links
316
+
317
+ - Docs: [getuserfeedback.com/docs](https://getuserfeedback.com/docs)
318
+ - Package versions (release history): [npm versions for `@getuserfeedback/sdk`](https://www.npmjs.com/package/@getuserfeedback/sdk?activeTab=versions)
319
+ - Report issues / support: [hello@getuserfeedback.com](mailto:hello@getuserfeedback.com)
@@ -0,0 +1,195 @@
1
+ /**
2
+ * Types and type guards for flow state and lifecycle events.
3
+ */
4
+ /** Current state of the flow: whether it is open, loading, and its dimensions (if known). */
5
+ interface FlowState$1 {
6
+ /** True when the flow is visible. */
7
+ isOpen: boolean;
8
+ /** True when the flow is loading (e.g. fetching or rendering). */
9
+ isLoading: boolean;
10
+ /** Flow width in pixels when known. */
11
+ width?: number;
12
+ /** Flow height in pixels when known. */
13
+ height?: number;
14
+ }
15
+
16
+ /**
17
+ * getuserfeedback widget SDK public API.
18
+ */
19
+
20
+ /**
21
+ * Use host attributes to auto-detect the color scheme ("light" by default). The widget observes these attributes on body and html elements,
22
+ *
23
+ * class="dark" or data-theme="dark" on html or body elements will set the widget to dark mode.
24
+ *
25
+ * class="light" or data-theme="light" will set the widget to light mode.
26
+ *
27
+ * class="system" or data-theme="system" will set the widget to follow the user's OS/browser preference (prefers-color-scheme).
28
+ */
29
+ type ColorSchemeAutoDetect = {
30
+ /** List of host attribute names (html or body) to observe for color scheme.
31
+ *
32
+ * Default: ["class", "data-theme"]
33
+ */
34
+ autoDetectColorScheme: string[];
35
+ };
36
+ /**
37
+ * Color scheme: either auto-detect from host html and body attributes (default) or provide an explicit value.
38
+ * - { autoDetectColorScheme: ["class", "data-theme"] }
39
+ * - "light" | "dark" | "system"
40
+ */
41
+ type ColorSchemeConfig = ColorSchemeAutoDetect | "light" | "dark" | "system";
42
+ /** When true, prints debug logs to console. Narrow down with a namespace string/array eg. `["loader", "handshake"]`. Default `false`. */
43
+ type DebugConfig = boolean | string | string[];
44
+ /** Status of a consent decision (pending, granted, denied, revoked). */
45
+ type ConsentStatus = "pending" | "granted" | "denied" | "revoked";
46
+ /** Supported consent scope identifiers for explicit allow-list grants. */
47
+ type GrantScope = "analytics.storage" | "analytics.measurement" | "personalization.storage" | "ads.storage" | "ads.user_data" | "ads.personalization";
48
+ /** Consent configuration. Use a single decision for all scopes, or provide an explicit allow-list of granted scopes. */
49
+ type ConsentConfig = ConsentStatus | GrantScope[];
50
+ /** Auth configuration (e.g. JWT for authenticated flows). */
51
+ type AuthConfig = {
52
+ jwt?: {
53
+ token: string;
54
+ } | null | undefined;
55
+ };
56
+ /** Options for {@link Client.configure}: color scheme, consent, and auth. */
57
+ type ConfigureOptions = {
58
+ colorScheme?: ColorSchemeConfig | undefined;
59
+ consent?: ConsentConfig | undefined;
60
+ auth?: AuthConfig | undefined;
61
+ };
62
+ type ClientOptions = {
63
+ /** Your project API key. */
64
+ apiKey: string;
65
+ /** Color scheme config: host-driven (loader observes attributes) or explicit. */
66
+ colorScheme?: ColorSchemeConfig | undefined;
67
+ /** Consent settings compatible with common privacy frameworks (GDPR, CCPA, LGPD) and CMP flows.
68
+ *
69
+ * Default: `granted` (all scopes).
70
+ *
71
+ * Accepts either a single decision (`granted` | `denied` | `pending` | `revoked`)
72
+ * or an explicit allow-list of additional granted scopes (`GrantScope[]`).
73
+ *
74
+ * For strict privacy guarantees, use `pending` at init time and later call `client.configure({ consent })` after
75
+ * the user makes a consent choice via your CMP or UI.
76
+ *
77
+ * In array form, listed scopes are granted and all other non-essential scopes are denied.
78
+ *
79
+ * Essential baseline scopes are always granted for core widget operation and cannot be denied:
80
+ * - `functionality.storage`
81
+ * - `security.storage`
82
+ */
83
+ defaultConsent?: ConsentConfig | undefined;
84
+ /** When true, prints debug logs to console. Narrow down with a namespace string/array eg. ```["loader", "handshake"]```. Default `false`.
85
+ */
86
+ enableDebug?: DebugConfig | undefined;
87
+ /** When true, the widget does not load automatically; call `client.load()` when ready. Default `false` */
88
+ disableAutoLoad?: boolean;
89
+ /** Disable anonymous widget telemetry.
90
+ *
91
+ * When `true`, telemetry is not sent.
92
+ *
93
+ * This flag does not disable user targeting and reporting analytics. It's used (by us) for performance monitoring and error tracking.
94
+ *
95
+ * Included telemetry data when enabled: apiKey, ephemeral one-time session id,
96
+ * execution flow, event timestamps, and page origin (domain name).
97
+ *
98
+ * Excluded by default: user identity and detailed page fields (path/referrer/search).
99
+ */
100
+ disableTelemetry?: boolean | undefined;
101
+ _cdn?: string;
102
+ };
103
+ /** Default container behavior for flows in an instance. */
104
+ type ContainerPolicy = {
105
+ kind: "floating";
106
+ } | {
107
+ kind: "hostContainer";
108
+ host: HTMLElement | null;
109
+ sharing: "shared" | "perFlowRun";
110
+ };
111
+
112
+ /** Current state of a flow run (open/loading + dimensions when known). */
113
+ type FlowState = FlowState$1;
114
+ /** Callback invoked when flow state changes. */
115
+ type FlowStateCallback = (state: FlowState) => void;
116
+ type IdentifyTraits = Record<string, unknown>;
117
+ /** Options for opening a flow run. */
118
+ type OpenFlowOptions = {
119
+ /**
120
+ * Controls where the flow may mount.
121
+ * - `any` (default): loader may use default mounting policy.
122
+ * - `hostOnly`: wait until a custom per-flow container is registered.
123
+ */
124
+ containerRequirement?: "any" | "hostOnly";
125
+ };
126
+ /** Options for subscribing to flow state updates. */
127
+ type SubscribeFlowStateOptions = {
128
+ /** Emit the current snapshot immediately. Default `true`. */
129
+ emitInitial?: boolean;
130
+ /** Auto-unsubscribe when the signal is aborted. */
131
+ signal?: AbortSignal;
132
+ };
133
+ /** Instance for a specific flow: open, prefetch, prerender, close, set container, and subscribe to flow state. */
134
+ type FlowRun = {
135
+ /** The flow/survey ID this instance refers to. */
136
+ flowId: string;
137
+ /** Open the flow (show the survey). */
138
+ open: (options?: OpenFlowOptions) => Promise<void>;
139
+ /** Prefetch the flow so it opens faster when you call `open()`. */
140
+ prefetch: () => Promise<void>;
141
+ /** Prerender the flow into a container (e.g. for a custom dialog). */
142
+ prerender: () => Promise<void>;
143
+ /** Close this flow. */
144
+ close: () => Promise<void>;
145
+ /** Attach the flow UI to a DOM element, or `null` to detach. */
146
+ setContainer: (element: HTMLElement | null) => void;
147
+ /** Return the latest known flow state snapshot. */
148
+ getFlowState: () => FlowState;
149
+ /** Subscribe to open/loading/dimensions; returns an unsubscribe function. */
150
+ subscribeFlowState: (callback: FlowStateCallback, options?: SubscribeFlowStateOptions) => () => void;
151
+ };
152
+ /** getuserfeedback client: load the widget, open flows, configure colorScheme/consent/auth, and identify users. */
153
+ type Client = {
154
+ /** Load the widget script. Call when you created the client with `disableAutoLoad: true`. */
155
+ load: () => void;
156
+ /** Set how this instance should choose default containers for flows. */
157
+ setDefaultContainerPolicy: (policy: ContainerPolicy) => void;
158
+ /** Attach all instance flows to a DOM element, or `null` to restore default host mounting. */
159
+ setContainer: (element: HTMLElement | null) => void;
160
+ /** Return the latest known instance-level flow state snapshot. */
161
+ getFlowState: () => FlowState;
162
+ /** Subscribe to instance-level flow state updates (eg targeting-triggered opens). */
163
+ subscribeFlowState: (callback: FlowStateCallback, options?: SubscribeFlowStateOptions) => () => void;
164
+ /** Return an instance for the given flow (use its `open`, `prefetch`, `close`, `setContainer`, `getFlowState`, `subscribeFlowState`). */
165
+ flow: (flowId: string) => FlowRun;
166
+ /** Open the flow and return its instance. */
167
+ open: (flowId: string, options?: OpenFlowOptions) => Promise<FlowRun>;
168
+ /** Prefetch the flow and return its instance. */
169
+ prefetch: (flowId: string) => Promise<FlowRun>;
170
+ /** Prerender the flow (e.g. on button hover).
171
+ * Prerendering warms up the flow for instant display later.
172
+ */
173
+ prerender: (flowId: string) => Promise<FlowRun>;
174
+ /** Close all open flows. */
175
+ close: () => Promise<void>;
176
+ /** Reset widget state and user identity. */
177
+ reset: () => Promise<void>;
178
+ /** Update color scheme, consent, or auth. */
179
+ configure: (updates: ConfigureOptions) => Promise<void>;
180
+ /** Associate the current user via either (userId, optionalTraits) or (traits). */
181
+ identify: {
182
+ (userId: string, traits?: IdentifyTraits): Promise<void>;
183
+ (traits: IdentifyTraits): Promise<void>;
184
+ };
185
+ };
186
+ /**
187
+ * Create a getuserfeedback client. Reuses an existing client when called with the same
188
+ * `apiKey` and equivalent options; otherwise creates a new one.
189
+ */
190
+ declare const createClient: ({ apiKey, _cdn, disableAutoLoad, colorScheme, disableTelemetry, enableDebug, defaultConsent, }: ClientOptions) => Client;
191
+
192
+ declare const SDK_VERSION: string;
193
+
194
+ export { SDK_VERSION, createClient };
195
+ export type { Client, ClientOptions, ConfigureOptions, ContainerPolicy, FlowRun, FlowState, FlowStateCallback, SubscribeFlowStateOptions };
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ var L={INSTANCE_FLOW_STATE_CHANGED:"instance:flow:state-changed",INSTANCE_FLOW_STATE_CHANGED_INSTANCE:"instance:flow:state-changed:instance",INSTANCE_COMMAND_SETTLED:"instance:command:settled",INSTANCE_COMMAND_UNSUPPORTED:"instance:command:unsupported",INSTANCE_READY:"instance:ready",INSTANCE_BRIDGE_MOUNTED:"instance:bridge:mounted",INSTANCE_BRIDGE_UNMOUNTED:"instance:bridge:unmounted",INSTANCE_IFRAME_READY:"instance:iframe:ready",INSTANCE_ERROR:"instance:error",INSTANCE_APP_EVENT:"instance:app-event"},C={configure:"gx.command.configure.v1",open:"gx.command.open.v1",prefetch:"gx.command.prefetch.v1",prerender:"gx.command.prerender.v1",identify:"gx.command.identify.v1",close:"gx.command.close.v1",reset:"gx.command.reset.v1",setContainer:"gx.command.setContainer.v1",setDefaultContainerPolicy:"gx.command.setDefaultContainerPolicy.v1"},Hm=[C.configure,C.open,C.prefetch,C.prerender,C.identify,C.close,C.reset,C.setContainer,C.setDefaultContainerPolicy],$m=["gx.protocol.public.v1",...Hm],jm="__getuserfeedback_runtime",s="v1",H=(T)=>`getuserfeedback:${T}`;var v=()=>{if(typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID==="function")return globalThis.crypto.randomUUID();return`req_${Date.now()}_${Math.random().toString(36).slice(2)}`};var r=(T)=>typeof T==="string"&&T.trim().length>0;function t(T){if(typeof T!=="object"||T===null)return!1;let O=T;return r(O.instanceId)&&typeof O.isOpen==="boolean"&&typeof O.isLoading==="boolean"&&(typeof O.width>"u"||typeof O.width==="number")&&(typeof O.height>"u"||typeof O.height==="number")&&r(O.flowHandleId)}function n(T){if(typeof T!=="object"||T===null)return!1;let O=T;return r(O.instanceId)&&typeof O.isOpen==="boolean"&&typeof O.isLoading==="boolean"&&(typeof O.width>"u"||typeof O.width==="number")&&(typeof O.height>"u"||typeof O.height==="number")}function zm(T){if(typeof T!=="object"||T===null)return!1;let O=T;if(!r(O.requestId)||typeof O.instanceId!=="string"&&O.instanceId!==null||typeof O.kind!=="string"||typeof O.ok!=="boolean")return!1;if(O.ok===!0)return!0;if(O.ok===!1&&typeof O.error==="object"&&O.error!==null)return typeof O.error.message==="string";return!1}var qm=30000,Um="COMMAND_SETTLEMENT_TIMEOUT";class q extends Error{code=Um;requestId;constructor(T){super(`Timed out waiting for command settlement: ${T}`);this.name="CommandSettlementTimeoutError",this.requestId=T}}var gm=(T)=>{if(typeof CustomEvent<"u")return T instanceof CustomEvent;return typeof T==="object"&&T!==null&&"detail"in T},h=(T)=>{let O=T.requestId.trim();if(!O)return Promise.reject(Error("requestId must be a non-empty string"));let G=T.windowRef??(typeof window>"u"?void 0:window);if(!G)return Promise.reject(Error("Cannot await command settlement without window"));let X=H(L.INSTANCE_COMMAND_SETTLED),M=Math.max(0,T.timeoutMs??qm);return new Promise((Y,x)=>{let K=()=>{if(typeof G.removeEventListener==="function")G.removeEventListener(X,F)},g=setTimeout(()=>{K(),x(new q(O))},M),F=(V)=>{if(!gm(V))return;let y=V.detail;if(!zm(y)||y.requestId!==O)return;let B=y;if(K(),clearTimeout(g),B.ok){Y(B);return}x(Error(B.error.message??`Command ${B.kind} failed without an error payload`))};G.addEventListener(X,F)})};var a=(T)=>{return async(O,G)=>{let X=v(),M=Am(G?.idempotencyKey);T({version:"1",requestId:X,idempotencyKey:M??X,command:O}),await h({requestId:X})}},Am=(T)=>{if(T===void 0)return null;let O=T.trim();if(!O)throw Error("idempotencyKey must be a non-empty string");return O};var Gm="0.1.0".trim(),l=Gm.length>0?Gm:"0.0.0-local";var d={isOpen:!1,isLoading:!1,width:void 0,height:void 0},Jm=new Map,Qm=(T)=>T,wm=()=>{if(typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID==="function")return Qm(globalThis.crypto.randomUUID());return Qm(`handle_${Date.now()}_${Math.random().toString(36).slice(2)}`)},bm=()=>{if(typeof globalThis.crypto<"u"&&typeof globalThis.crypto.randomUUID==="function")return globalThis.crypto.randomUUID();return`sdk-${Date.now()}-${Math.random().toString(16).slice(2)}`},rm=(T,O)=>{if(typeof T==="string")return{kind:"identify",userId:T,traits:O};return{kind:"identify",traits:T}},pm=120,Xm=120,cm=(T)=>T.apiKey,um=()=>typeof window>"u"?globalThis:window,Im=()=>{let T=um(),O=Jm.get(T);if(O)return O;let G=new Map;return Jm.set(T,G),G},om=({apiKey:T,_cdn:O="https://cdn.getuserfeedback.com",disableAutoLoad:G=!1,colorScheme:X,disableTelemetry:M=!1,enableDebug:Y=!1,defaultConsent:x})=>{let K=cm({apiKey:T,_cdn:O,disableAutoLoad:G,colorScheme:X,disableTelemetry:M,enableDebug:Y,defaultConsent:x}),g=Im(),F=g.get(K);if(F){if(F.updateOptions({apiKey:T,_cdn:O,disableAutoLoad:G,colorScheme:X,disableTelemetry:M,enableDebug:Y,defaultConsent:x}),!G)F.client.load();return F.client}let V=O,y=(m)=>{},B=l,Zm="v1",p=bm(),e={loader:"sdk",clientName:"@getuserfeedback/sdk",clientVersion:B,transport:"snippet"},Cm=[...$m],A=x,Mm=()=>({apiKey:T,clientMeta:e,capabilities:[...Cm],...X!==void 0&&{colorScheme:X},...M!==void 0&&{disableTelemetry:M},...Y!==void 0&&{enableDebug:Y},...A!==void 0&&{defaultConsent:A}}),w=!1,D=null,k=G,c=new Map,mm=d,R=(m)=>({isOpen:m.isOpen,isLoading:m.isLoading,width:m.width,height:m.height}),Em=(m)=>{let E=c.get(m);if(!E)return R(d);return R(E)},Tm=(m,E)=>{c.set(m,R(E))},Om=()=>R(mm),Vm=(m)=>{mm=R(m)},ym=(m)=>{if(!c.has(m))Tm(m,d)},_=()=>w,f=(m)=>{if(typeof window>"u")return;if(!window.__getuserfeedback_queue)window.__getuserfeedback_queue=[];let E={...m,instanceId:m.instanceId??p,clientMeta:m.clientMeta??e};window.__getuserfeedback_queue.push(E)},u=(m)=>{let E=m??v();return f({version:"1",instanceId:p,requestId:E,idempotencyKey:E,command:{kind:"init",opts:Mm()}}),E},Dm=(m,E)=>{let $=v();f({version:"1",requestId:$,idempotencyKey:$,command:{kind:"setContainer",flowHandleId:m,container:E}})},I=(m)=>{let E=v();f({version:"1",requestId:E,idempotencyKey:E,command:{kind:"setDefaultContainerPolicy",policy:m}})},P=(m)=>{return m.catch((E)=>{throw y(E),E})},Pm=()=>{if(typeof window>"u")return;if(!_()){if(k)throw Error("Widget not loaded. Call client.load() first.");o()}},Nm=a((m)=>f(m)),N=async(m)=>{return Pm(),Nm(m)},Sm=(m)=>{if(!_())return;let E=v();f({version:"1",requestId:E,idempotencyKey:E,command:{kind:"configure",opts:m}})},vm=(m)=>{if(k=m.disableAutoLoad??k,A=m.defaultConsent??A,m._cdn!==void 0&&m._cdn!==V)if(_()||D!==null){let E=Error("_cdn cannot be changed after widget init; keeping original");y(E)}else V=m._cdn;if(Ym(m),!k&&!_())o()},Ym=(m)=>{if(!_())return;let E={};if(m.colorScheme!==void 0)E.colorScheme=m.colorScheme;Sm(E)},o=()=>{if(typeof window>"u")return;if(_()||D)return;let m=()=>{let W=V.endsWith("/")?V:`${V}/`,j=`loader/${Zm}/${encodeURIComponent(T)}/loader.js`,J=new URL(j,W).toString();if(!document.querySelector(`link[href="${J}"][rel="preload"]`)){let Q=document.createElement("link");Q.rel="preload",Q.as="script",Q.href=J,document.head.appendChild(Q)}let U=document.createElement("script");if(U.src=J,U.async=!0,U.dataset)U.dataset.disableAutoRegister="true";else if(typeof U.setAttribute==="function")U.setAttribute("data-disable-auto-register","true");document.head.appendChild(U)},E=window[jm];if(E?.alive){let W=E.protocolVersion;if(W!==s)throw Error(`Incompatible loader runtime protocol: expected ${s}, received ${W??"unknown"}`);u(),w=!0;return}if(!Array.isArray(window.__getuserfeedback_queue)){let W=u();m(),w=!0;let j;j=h({requestId:W,timeoutMs:Xm}).then(()=>{}).catch((U)=>{y(U)}).finally(()=>{if(D===j)D=null}),D=j;return}w=!0;let z;z=(async()=>{let W=v();u(W);try{await h({requestId:W,timeoutMs:pm});return}catch(j){if(j instanceof q){m(),await h({requestId:W,timeoutMs:Xm});return}throw j}})().catch((W)=>{y(W)}).finally(()=>{if(D===z)D=null}),D=z},Fm=(m,E)=>{Dm(m,E)},Rm=(m)=>{if(m===null){I({kind:"floating"});return}I({kind:"hostContainer",host:m,sharing:"shared"})},_m=(m,E,$)=>{if($?.emitInitial??!0)E(Em(m));if(typeof window>"u")return()=>{};let z=H(L.INSTANCE_FLOW_STATE_CHANGED),S=(Q)=>{let Z=Q.detail;if(!t(Z)||Z.flowHandleId!==m)return;let Wm={isOpen:Z.isOpen,isLoading:Z.isLoading,width:Z.width,height:Z.height};Tm(m,Wm),E(R(Wm))},W=!1,j=$?.signal,J=null,U=()=>{if(W)return;if(W=!0,window.removeEventListener(z,S),j&&J)j.removeEventListener("abort",J)};if(window.addEventListener(z,S),j){if(J=()=>{U()},j.aborted)return U(),U;j.addEventListener("abort",J,{once:!0})}return U},hm=(m,E)=>{if(E?.emitInitial??!0)m(Om());if(typeof window>"u")return()=>{};let $=H(L.INSTANCE_FLOW_STATE_CHANGED_INSTANCE),z=(U)=>{let Q=U.detail;if(!n(Q)||Q.instanceId!==p)return;let Z={isOpen:Q.isOpen,isLoading:Q.isLoading,width:Q.width,height:Q.height};Vm(Z),m(R(Z))},S=!1,W=E?.signal,j=null,J=()=>{if(S)return;if(S=!0,window.removeEventListener($,z),W&&j)W.removeEventListener("abort",j)};if(window.addEventListener($,z),W){if(j=()=>{J()},W.aborted)return J(),J;W.addEventListener("abort",j,{once:!0})}return J},b=(m)=>{let E=m;if(!E.trim())throw Error("flowId must be a non-empty string");let $=wm();return ym($),{flowId:E,open:(z)=>P(N({kind:"open",flowId:E,flowHandleId:$,...z?.containerRequirement?{containerRequirement:z.containerRequirement}:{}})),prefetch:()=>P(N({kind:"prefetch",flowId:E})),prerender:()=>P(N({kind:"prerender",flowId:E,flowHandleId:$})),close:()=>P(N({kind:"close",flowHandleId:$})),setContainer:(z)=>{Fm($,z)},getFlowState:()=>Em($),subscribeFlowState:(z,S)=>_m($,z,S)}},xm=(m)=>b(m),Bm=async(m,E)=>{let $=b(m);return await $.open(E),$},Km=async(m)=>{let E=b(m);return await E.prefetch(),E},km=()=>{if(typeof window>"u")return Promise.resolve();return P(N({kind:"close"}))},fm=()=>{if(typeof window>"u")return Promise.resolve();return P(N({kind:"reset"}))};function Lm(m,E){if(typeof window>"u")return Promise.resolve();return P(N(rm(m,E)))}let i={load:o,setDefaultContainerPolicy:(m)=>{I(m)},setContainer:(m)=>{Rm(m)},getFlowState:()=>Om(),subscribeFlowState:(m,E)=>hm(m,E),flow:xm,open:Bm,prefetch:Km,prerender:async(m)=>{let E=b(m);return await E.prerender(),E},close:km,reset:fm,configure:(m)=>{if(typeof window>"u")return Promise.resolve();if(!_())return Promise.resolve();return P(N({kind:"configure",opts:m}))},identify:Lm};if(g.set(K,{client:i,updateOptions:vm}),!k)i.load();return i};export{om as createClient,l as SDK_VERSION};
2
+
3
+ //# debugId=5F212816B6682BA864756E2164756E21
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,16 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../shared/src/constants.ts", "../../shared/src/request-id.ts", "../../shared/src/protocol/host-event-contract.ts", "../../shared/src/protocol/command-settlement.ts", "../../shared/src/protocol/command-dispatch.ts", "../src/version.ts", "../src/client.ts"],
4
+ "sourcesContent": [
5
+ "import type { PublicCommandPayload } from \"./protocol/sdk-types\";\n\n// TODO: review this file and remove unused events\n\nexport const TELEMETRY_EVENTS = {\n\tINSTANCE_READY: \"instance_ready\",\n\tVIEW_DISPLAYED: \"view_displayed\",\n\tVIEW_CLOSED: \"view_closed\",\n\tFLOW_DISPLAYED: \"flow_displayed\",\n\tFLOW_CLOSED: \"flow_closed\",\n} as const;\n\nexport type TelemetryEventName =\n\t(typeof TELEMETRY_EVENTS)[keyof typeof TELEMETRY_EVENTS];\n\n// Data attribute used to anchor widget styles & root element. Shared so build\n// scripts, runtime code and tests stay in sync.\nexport const WIDGET_SELECTOR = \"[data-gx-widget]\" as const;\n\nexport const PARENT_ORIGIN_PARAM = \"gx_parent_origin\" as const;\n\nexport const WIDGET_EVENTS = {\n\tREADY: \"gx:ready\",\n\tBRIDGE_MOUNTED: \"gx:bridge-mounted\",\n\tBRIDGE_UNMOUNTED: \"gx:bridge-unmounted\",\n\tIFRAME_READY: \"gx:iframe-ready\",\n} as const;\n\nexport type WidgetEventName =\n\t(typeof WIDGET_EVENTS)[keyof typeof WIDGET_EVENTS];\n\n// Host event names (DOM events emitted by widget for external consumption)\n// Uses prefix \"getuserfeedback:\" for namespacing\nexport const HOST_EVENT_PREFIX = \"getuserfeedback:\" as const;\n\nexport const HOST_EVENT_KEYS = {\n\tINSTANCE_FLOW_STATE_CHANGED: \"instance:flow:state-changed\",\n\tINSTANCE_FLOW_STATE_CHANGED_INSTANCE: \"instance:flow:state-changed:instance\",\n\tINSTANCE_COMMAND_SETTLED: \"instance:command:settled\",\n\tINSTANCE_COMMAND_UNSUPPORTED: \"instance:command:unsupported\",\n\tINSTANCE_READY: \"instance:ready\",\n\tINSTANCE_BRIDGE_MOUNTED: \"instance:bridge:mounted\",\n\tINSTANCE_BRIDGE_UNMOUNTED: \"instance:bridge:unmounted\",\n\tINSTANCE_IFRAME_READY: \"instance:iframe:ready\",\n\tINSTANCE_ERROR: \"instance:error\",\n\tINSTANCE_APP_EVENT: \"instance:app-event\",\n} as const;\n\ntype SdkCapabilityCommandKind = Exclude<PublicCommandPayload[\"kind\"], \"init\">;\n\nconst SDK_COMMAND_CAPABILITY_BY_KIND = {\n\tconfigure: \"gx.command.configure.v1\",\n\topen: \"gx.command.open.v1\",\n\tprefetch: \"gx.command.prefetch.v1\",\n\tprerender: \"gx.command.prerender.v1\",\n\tidentify: \"gx.command.identify.v1\",\n\tclose: \"gx.command.close.v1\",\n\treset: \"gx.command.reset.v1\",\n\tsetContainer: \"gx.command.setContainer.v1\",\n\tsetDefaultContainerPolicy: \"gx.command.setDefaultContainerPolicy.v1\",\n} as const satisfies Record<\n\tSdkCapabilityCommandKind,\n\t`gx.command.${string}.v${number}`\n>;\n\nconst SDK_COMMAND_CAPABILITIES = [\n\tSDK_COMMAND_CAPABILITY_BY_KIND.configure,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.open,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.prefetch,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.prerender,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.identify,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.close,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.reset,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.setContainer,\n\tSDK_COMMAND_CAPABILITY_BY_KIND.setDefaultContainerPolicy,\n] as const;\n\ntype SdkCommandCapability =\n\t(typeof SDK_COMMAND_CAPABILITY_BY_KIND)[keyof typeof SDK_COMMAND_CAPABILITY_BY_KIND];\ntype _AssertAllCommandCapabilitiesAreAnnounced =\n\tExclude<\n\t\tSdkCommandCapability,\n\t\t(typeof SDK_COMMAND_CAPABILITIES)[number]\n\t> extends never\n\t\t? true\n\t\t: never;\ntype _AssertNoUnknownCommandCapabilities =\n\tExclude<\n\t\t(typeof SDK_COMMAND_CAPABILITIES)[number],\n\t\tSdkCommandCapability\n\t> extends never\n\t\t? true\n\t\t: never;\n\n/**\n * Stable capability tokens announced by the browser SDK during init.\n * These are versioned and namespaced to support forward-compatible negotiation.\n */\nexport const SDK_PROTOCOL_CAPABILITIES = [\n\t\"gx.protocol.public.v1\",\n\t...SDK_COMMAND_CAPABILITIES,\n] as const;\n\nexport type SdkProtocolCapability = (typeof SDK_PROTOCOL_CAPABILITIES)[number];\n\nexport const LOADER_RUNTIME_GLOBAL_KEY = \"__getuserfeedback_runtime\" as const;\nexport const LOADER_RUNTIME_PROTOCOL_VERSION = \"v1\" as const;\n\n// Helper to construct full event name with prefix\nexport const toHostEventName = (key: string): string =>\n\t`${HOST_EVENT_PREFIX}${key}`;\n",
6
+ "export const createCommandRequestId = (): string => {\n\tif (\n\t\ttypeof globalThis.crypto !== \"undefined\" &&\n\t\ttypeof globalThis.crypto.randomUUID === \"function\"\n\t) {\n\t\treturn globalThis.crypto.randomUUID();\n\t}\n\treturn `req_${Date.now()}_${Math.random().toString(36).slice(2)}`;\n};\n",
7
+ "/**\n * Types and type guards for flow state and lifecycle events.\n */\n\n/** Current state of the flow: whether it is open, loading, and its dimensions (if known). */\nexport interface FlowState {\n\t/** True when the flow is visible. */\n\tisOpen: boolean;\n\t/** True when the flow is loading (e.g. fetching or rendering). */\n\tisLoading: boolean;\n\t/** Flow width in pixels when known. */\n\twidth?: number;\n\t/** Flow height in pixels when known. */\n\theight?: number;\n}\n\nexport interface FlowStateChangedDetail extends FlowState {\n\tinstanceId: string;\n\tflowHandleId: string;\n}\n\nexport interface InstanceFlowStateChangedDetail extends FlowState {\n\tinstanceId: string;\n}\n\nconst isNonEmptyString = (v: unknown): v is string =>\n\ttypeof v === \"string\" && v.trim().length > 0;\n\nexport function isFlowStateChangedDetail(\n\tdetail: unknown,\n): detail is FlowStateChangedDetail {\n\tif (typeof detail !== \"object\" || detail === null) return false;\n\tconst d = detail as Record<string, unknown>;\n\treturn (\n\t\tisNonEmptyString(d.instanceId) &&\n\t\ttypeof d.isOpen === \"boolean\" &&\n\t\ttypeof d.isLoading === \"boolean\" &&\n\t\t(typeof d.width === \"undefined\" || typeof d.width === \"number\") &&\n\t\t(typeof d.height === \"undefined\" || typeof d.height === \"number\") &&\n\t\tisNonEmptyString(d.flowHandleId)\n\t);\n}\n\nexport function isInstanceFlowStateChangedDetail(\n\tdetail: unknown,\n): detail is InstanceFlowStateChangedDetail {\n\tif (typeof detail !== \"object\" || detail === null) return false;\n\tconst d = detail as Record<string, unknown>;\n\treturn (\n\t\tisNonEmptyString(d.instanceId) &&\n\t\ttypeof d.isOpen === \"boolean\" &&\n\t\ttypeof d.isLoading === \"boolean\" &&\n\t\t(typeof d.width === \"undefined\" || typeof d.width === \"number\") &&\n\t\t(typeof d.height === \"undefined\" || typeof d.height === \"number\")\n\t);\n}\n\nexport interface CommandSettledSuccessDetail {\n\trequestId: string;\n\tinstanceId: string | null;\n\tkind: string;\n\tok: true;\n\tresult?: unknown;\n}\n\nexport interface CommandSettledFailureDetail {\n\trequestId: string;\n\tinstanceId: string | null;\n\tkind: string;\n\tok: false;\n\terror: { message: string; code?: string };\n}\n\nexport type CommandSettledDetail =\n\t| CommandSettledSuccessDetail\n\t| CommandSettledFailureDetail;\n\nexport function isCommandSettledDetail(\n\tdetail: unknown,\n): detail is CommandSettledDetail {\n\tif (typeof detail !== \"object\" || detail === null) return false;\n\tconst d = detail as Record<string, unknown>;\n\tif (\n\t\t!isNonEmptyString(d.requestId) ||\n\t\t(typeof d.instanceId !== \"string\" && d.instanceId !== null) ||\n\t\ttypeof d.kind !== \"string\" ||\n\t\ttypeof d.ok !== \"boolean\"\n\t) {\n\t\treturn false;\n\t}\n\tif (d.ok === true) {\n\t\treturn true;\n\t}\n\tif (d.ok === false && typeof d.error === \"object\" && d.error !== null) {\n\t\tconst err = d.error as Record<string, unknown>;\n\t\treturn typeof err.message === \"string\";\n\t}\n\treturn false;\n}\n",
8
+ "import { HOST_EVENT_KEYS, toHostEventName } from \"../constants\";\nimport {\n\ttype CommandSettledDetail,\n\tisCommandSettledDetail,\n} from \"./host-event-contract\";\n\ntype WaitForCommandSettlementInput = {\n\trequestId: string;\n\twindowRef?: Window;\n\ttimeoutMs?: number;\n};\n\nconst DEFAULT_SETTLEMENT_TIMEOUT_MS = 30_000;\nexport const COMMAND_SETTLEMENT_TIMEOUT_CODE =\n\t\"COMMAND_SETTLEMENT_TIMEOUT\" as const;\n\nexport class CommandSettlementTimeoutError extends Error {\n\treadonly code = COMMAND_SETTLEMENT_TIMEOUT_CODE;\n\treadonly requestId: string;\n\n\tconstructor(requestId: string) {\n\t\tsuper(`Timed out waiting for command settlement: ${requestId}`);\n\t\tthis.name = \"CommandSettlementTimeoutError\";\n\t\tthis.requestId = requestId;\n\t}\n}\n\nconst eventHasDetail = (event: Event): event is Event & { detail: unknown } => {\n\tif (typeof CustomEvent !== \"undefined\") {\n\t\treturn event instanceof CustomEvent;\n\t}\n\treturn typeof event === \"object\" && event !== null && \"detail\" in event;\n};\n\nexport const waitForCommandSettlement = (\n\tinput: WaitForCommandSettlementInput,\n): Promise<CommandSettledDetail> => {\n\tconst requestId = input.requestId.trim();\n\tif (!requestId) {\n\t\treturn Promise.reject(new Error(\"requestId must be a non-empty string\"));\n\t}\n\tconst targetWindow =\n\t\tinput.windowRef ?? (typeof window === \"undefined\" ? undefined : window);\n\tif (!targetWindow) {\n\t\treturn Promise.reject(\n\t\t\tnew Error(\"Cannot await command settlement without window\"),\n\t\t);\n\t}\n\tconst eventName = toHostEventName(HOST_EVENT_KEYS.INSTANCE_COMMAND_SETTLED);\n\tconst timeoutMs = Math.max(\n\t\t0,\n\t\tinput.timeoutMs ?? DEFAULT_SETTLEMENT_TIMEOUT_MS,\n\t);\n\treturn new Promise<CommandSettledDetail>((resolve, reject) => {\n\t\tconst cleanup = (): void => {\n\t\t\tif (typeof targetWindow.removeEventListener === \"function\") {\n\t\t\t\ttargetWindow.removeEventListener(eventName, handleEvent);\n\t\t\t}\n\t\t};\n\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\tcleanup();\n\t\t\treject(new CommandSettlementTimeoutError(requestId));\n\t\t}, timeoutMs);\n\n\t\tconst handleEvent = (event: Event): void => {\n\t\t\tif (!eventHasDetail(event)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst raw = event.detail;\n\t\t\tif (!isCommandSettledDetail(raw) || raw.requestId !== requestId) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst detail = raw;\n\t\t\tcleanup();\n\t\t\tclearTimeout(timeoutId);\n\t\t\tif (detail.ok) {\n\t\t\t\tresolve(detail);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treject(\n\t\t\t\tnew Error(\n\t\t\t\t\tdetail.error.message ??\n\t\t\t\t\t\t`Command ${detail.kind} failed without an error payload`,\n\t\t\t\t),\n\t\t\t);\n\t\t};\n\t\ttargetWindow.addEventListener(eventName, handleEvent);\n\t});\n};\n",
9
+ "import { createCommandRequestId } from \"../request-id\";\nimport { waitForCommandSettlement } from \"./command-settlement\";\nimport type { CommandEnvelope, PublicCommandPayload } from \"./sdk-types\";\n\n/**\n * A command input: the pure payload with `kind` and command-specific fields.\n * Distributes over the PublicCommandPayload union so discriminant\n * narrowing is preserved (e.g. `{ kind: \"open\", flowId }` type-checks).\n */\nexport type CommandInput = PublicCommandPayload extends infer C\n\t? C extends PublicCommandPayload\n\t\t? C\n\t\t: never\n\t: never;\n\ntype DispatchOptions = {\n\tidempotencyKey?: string;\n};\n\n/**\n * Creates a dispatch function that wraps a command payload in an envelope,\n * pushes it into the queue, and returns a promise that settles when the\n * runtime acknowledges it.\n *\n * Request IDs are generated automatically.\n *\n * @example\n * ```ts\n * const dispatch = createCommandDispatch((env) => queue.push(env));\n * await dispatch({ kind: \"open\", flowId: \"f1\", flowHandleId: \"h1\" });\n * ```\n */\nexport const createCommandDispatch = (\n\tpush: (envelope: CommandEnvelope) => void,\n): ((input: CommandInput, options?: DispatchOptions) => Promise<void>) => {\n\treturn async (\n\t\tinput: CommandInput,\n\t\toptions?: DispatchOptions,\n\t): Promise<void> => {\n\t\tconst requestId = createCommandRequestId();\n\t\tconst idempotencyKey = resolveIdempotencyKey(options?.idempotencyKey);\n\t\tconst envelope: CommandEnvelope = {\n\t\t\tversion: \"1\",\n\t\t\trequestId,\n\t\t\tidempotencyKey: idempotencyKey ?? requestId,\n\t\t\tcommand: input,\n\t\t};\n\t\tpush(envelope);\n\t\tawait waitForCommandSettlement({ requestId });\n\t};\n};\n\nconst resolveIdempotencyKey = (value?: string): string | null => {\n\tif (value === undefined) {\n\t\treturn null;\n\t}\n\tconst idempotencyKey = value.trim();\n\tif (!idempotencyKey) {\n\t\tthrow new Error(\"idempotencyKey must be a non-empty string\");\n\t}\n\treturn idempotencyKey;\n};\n",
10
+ "declare const __GX_SDK_VERSION__: string | undefined;\n\nconst sdkVersion =\n\ttypeof __GX_SDK_VERSION__ === \"string\" ? __GX_SDK_VERSION__.trim() : \"\";\n\n// Build scripts inject __GX_SDK_VERSION__ for published artifacts.\n// Source-linked workspace usage may not inject defines, so keep a safe fallback.\nexport const SDK_VERSION = sdkVersion.length > 0 ? sdkVersion : \"0.0.0-local\";\n",
11
+ "import {\n\tHOST_EVENT_KEYS,\n\tLOADER_RUNTIME_GLOBAL_KEY,\n\tLOADER_RUNTIME_PROTOCOL_VERSION,\n\tSDK_PROTOCOL_CAPABILITIES,\n\ttoHostEventName,\n} from \"shared/constants\";\nimport {\n\ttype ClientMeta,\n\ttype ClientOptions,\n\ttype Command,\n\ttype CommandEnvelope,\n\tCommandSettlementTimeoutError,\n\ttype ConfigureOptions,\n\ttype ContainerPolicy,\n\tcreateCommandDispatch,\n\ttype FlowState as HostFlowState,\n\ttype InitOptions,\n\tisFlowStateChangedDetail,\n\tisInstanceFlowStateChangedDetail,\n\twaitForCommandSettlement,\n} from \"shared/protocol/sdk\";\nimport { SDK_VERSION } from \"./version\";\n\nexport type { ClientOptions };\n\nimport { createCommandRequestId } from \"shared/request-id\";\n\n/** @internal */\ndeclare global {\n\tinterface Window {\n\t\t__getuserfeedback_queue?: CommandEnvelope[];\n\t\t[LOADER_RUNTIME_GLOBAL_KEY]?: {\n\t\t\talive?: boolean;\n\t\t\tprotocolVersion?: string;\n\t\t};\n\t}\n}\n\ntype FlowHandleId = string;\n\n/** Current state of a flow run (open/loading + dimensions when known). */\nexport type FlowState = HostFlowState;\n\n/** Callback invoked when flow state changes. */\nexport type FlowStateCallback = (state: FlowState) => void;\ntype IdentifyTraits = Record<string, unknown>;\n\n/** Options for opening a flow run. */\nexport type OpenFlowOptions = {\n\t/**\n\t * Controls where the flow may mount.\n\t * - `any` (default): loader may use default mounting policy.\n\t * - `hostOnly`: wait until a custom per-flow container is registered.\n\t */\n\tcontainerRequirement?: \"any\" | \"hostOnly\";\n};\n\n/** Options for subscribing to flow state updates. */\nexport type SubscribeFlowStateOptions = {\n\t/** Emit the current snapshot immediately. Default `true`. */\n\temitInitial?: boolean;\n\t/** Auto-unsubscribe when the signal is aborted. */\n\tsignal?: AbortSignal;\n};\n\nconst DEFAULT_FLOW_STATE: FlowState = {\n\tisOpen: false,\n\tisLoading: false,\n\twidth: undefined,\n\theight: undefined,\n};\n\n/** Instance for a specific flow: open, prefetch, prerender, close, set container, and subscribe to flow state. */\nexport type FlowRun = {\n\t/** The flow/survey ID this instance refers to. */\n\tflowId: string;\n\t/** Open the flow (show the survey). */\n\topen: (options?: OpenFlowOptions) => Promise<void>;\n\t/** Prefetch the flow so it opens faster when you call `open()`. */\n\tprefetch: () => Promise<void>;\n\t/** Prerender the flow into a container (e.g. for a custom dialog). */\n\tprerender: () => Promise<void>;\n\t/** Close this flow. */\n\tclose: () => Promise<void>;\n\t/** Attach the flow UI to a DOM element, or `null` to detach. */\n\tsetContainer: (element: HTMLElement | null) => void;\n\t/** Return the latest known flow state snapshot. */\n\tgetFlowState: () => FlowState;\n\t/** Subscribe to open/loading/dimensions; returns an unsubscribe function. */\n\tsubscribeFlowState: (\n\t\tcallback: FlowStateCallback,\n\t\toptions?: SubscribeFlowStateOptions,\n\t) => () => void;\n};\n\n/** getuserfeedback client: load the widget, open flows, configure colorScheme/consent/auth, and identify users. */\nexport type Client = {\n\t/** Load the widget script. Call when you created the client with `disableAutoLoad: true`. */\n\tload: () => void;\n\t/** Set how this instance should choose default containers for flows. */\n\tsetDefaultContainerPolicy: (policy: ContainerPolicy) => void;\n\t/** Attach all instance flows to a DOM element, or `null` to restore default host mounting. */\n\tsetContainer: (element: HTMLElement | null) => void;\n\t/** Return the latest known instance-level flow state snapshot. */\n\tgetFlowState: () => FlowState;\n\t/** Subscribe to instance-level flow state updates (eg targeting-triggered opens). */\n\tsubscribeFlowState: (\n\t\tcallback: FlowStateCallback,\n\t\toptions?: SubscribeFlowStateOptions,\n\t) => () => void;\n\t/** Return an instance for the given flow (use its `open`, `prefetch`, `close`, `setContainer`, `getFlowState`, `subscribeFlowState`). */\n\tflow: (flowId: string) => FlowRun;\n\t/** Open the flow and return its instance. */\n\topen: (flowId: string, options?: OpenFlowOptions) => Promise<FlowRun>;\n\t/** Prefetch the flow and return its instance. */\n\tprefetch: (flowId: string) => Promise<FlowRun>;\n\t/** Prerender the flow (e.g. on button hover).\n\t * Prerendering warms up the flow for instant display later.\n\t */\n\tprerender: (flowId: string) => Promise<FlowRun>;\n\t/** Close all open flows. */\n\tclose: () => Promise<void>;\n\t/** Reset widget state and user identity. */\n\treset: () => Promise<void>;\n\t/** Update color scheme, consent, or auth. */\n\tconfigure: (updates: ConfigureOptions) => Promise<void>;\n\t/** Associate the current user via either (userId, optionalTraits) or (traits). */\n\tidentify: {\n\t\t(userId: string, traits?: IdentifyTraits): Promise<void>;\n\t\t(traits: IdentifyTraits): Promise<void>;\n\t};\n};\n\ntype ClientRegistryEntry = {\n\tclient: Client;\n\tupdateOptions: (options: ClientOptions) => void;\n};\n\nconst clientRegistry = new Map<object, Map<string, ClientRegistryEntry>>();\n\nconst asFlowHandleId = (value: string): FlowHandleId => value;\n\nconst createFlowHandleId = (): FlowHandleId => {\n\tif (\n\t\ttypeof globalThis.crypto !== \"undefined\" &&\n\t\ttypeof globalThis.crypto.randomUUID === \"function\"\n\t) {\n\t\treturn asFlowHandleId(globalThis.crypto.randomUUID());\n\t}\n\treturn asFlowHandleId(\n\t\t`handle_${Date.now()}_${Math.random().toString(36).slice(2)}`,\n\t);\n};\n\nconst createClientInstanceId = (): string => {\n\tif (\n\t\ttypeof globalThis.crypto !== \"undefined\" &&\n\t\ttypeof globalThis.crypto.randomUUID === \"function\"\n\t) {\n\t\treturn globalThis.crypto.randomUUID();\n\t}\n\treturn `sdk-${Date.now()}-${Math.random().toString(16).slice(2)}`;\n};\n\nconst toIdentifyCommandPayload = (\n\tidentifyInput: string | IdentifyTraits,\n\ttraits?: IdentifyTraits,\n): Extract<Command, { kind: \"identify\" }> => {\n\tif (typeof identifyInput === \"string\") {\n\t\treturn {\n\t\t\tkind: \"identify\",\n\t\t\tuserId: identifyInput,\n\t\t\ttraits,\n\t\t};\n\t}\n\treturn {\n\t\tkind: \"identify\",\n\t\ttraits: identifyInput,\n\t};\n};\n\nconst LOADER_RUNTIME_PROBE_TIMEOUT_MS = 120;\nconst LOADER_RUNTIME_POST_LOAD_TIMEOUT_MS = 120;\n\nconst resolveRegistryKey = (options: ClientOptions): string => options.apiKey;\n\nconst resolveRegistryScope = (): object =>\n\ttypeof window === \"undefined\" ? globalThis : window;\n\nconst getRegistryForScope = (): Map<string, ClientRegistryEntry> => {\n\tconst scope = resolveRegistryScope();\n\tconst existing = clientRegistry.get(scope);\n\tif (existing) {\n\t\treturn existing;\n\t}\n\tconst created = new Map<string, ClientRegistryEntry>();\n\tclientRegistry.set(scope, created);\n\treturn created;\n};\n\n/**\n * Create a getuserfeedback client. Reuses an existing client when called with the same\n * `apiKey` and equivalent options; otherwise creates a new one.\n */\nexport const createClient = ({\n\tapiKey,\n\t_cdn = \"https://cdn.getuserfeedback.com\",\n\tdisableAutoLoad = false,\n\tcolorScheme,\n\tdisableTelemetry = false,\n\tenableDebug = false,\n\tdefaultConsent,\n}: ClientOptions): Client => {\n\tconst registryKey = resolveRegistryKey({\n\t\tapiKey,\n\t\t_cdn,\n\t\tdisableAutoLoad,\n\t\tcolorScheme,\n\t\tdisableTelemetry,\n\t\tenableDebug,\n\t\tdefaultConsent,\n\t});\n\tconst registry = getRegistryForScope();\n\tconst existing = registry.get(registryKey);\n\tif (existing) {\n\t\texisting.updateOptions({\n\t\t\tapiKey,\n\t\t\t_cdn,\n\t\t\tdisableAutoLoad,\n\t\t\tcolorScheme,\n\t\t\tdisableTelemetry,\n\t\t\tenableDebug,\n\t\t\tdefaultConsent,\n\t\t});\n\t\tif (!disableAutoLoad) {\n\t\t\texisting.client.load();\n\t\t}\n\t\treturn existing.client;\n\t}\n\n\tlet _cdnConfig = _cdn;\n\n\tconst notifyError = (_error: unknown): void => {\n\t\t// No-op: track/use hooks removed from public API.\n\t};\n\n\tconst sdkVersion = SDK_VERSION;\n\tconst loaderVersion = \"v1\";\n\tconst clientInstanceId = createClientInstanceId();\n\tconst clientMeta: ClientMeta = {\n\t\tloader: \"sdk\",\n\t\tclientName: \"@getuserfeedback/sdk\",\n\t\tclientVersion: sdkVersion,\n\t\ttransport: \"snippet\",\n\t};\n\n\tconst capabilities = [...SDK_PROTOCOL_CAPABILITIES];\n\n\tlet defaultConsentConfig = defaultConsent;\n\n\tconst buildInitOpts = (): InitOptions => ({\n\t\tapiKey,\n\t\tclientMeta,\n\t\tcapabilities: [...capabilities],\n\t\t...(colorScheme !== undefined && { colorScheme }),\n\t\t...(disableTelemetry !== undefined && { disableTelemetry }),\n\t\t...(enableDebug !== undefined && { enableDebug }),\n\t\t...(defaultConsentConfig !== undefined && {\n\t\t\tdefaultConsent: defaultConsentConfig,\n\t\t}),\n\t});\n\n\tlet loaderRequested = false;\n\tlet pendingLoad: Promise<void> | null = null;\n\tlet disableAutoLoadConfig = disableAutoLoad;\n\tconst flowStateByHandle = new Map<FlowHandleId, FlowState>();\n\tlet instanceFlowState: FlowState = DEFAULT_FLOW_STATE;\n\n\tconst cloneFlowState = (state: FlowState): FlowState => ({\n\t\tisOpen: state.isOpen,\n\t\tisLoading: state.isLoading,\n\t\twidth: state.width,\n\t\theight: state.height,\n\t});\n\n\tconst getFlowStateForHandle = (flowHandleId: FlowHandleId): FlowState => {\n\t\tconst existing = flowStateByHandle.get(flowHandleId);\n\t\tif (!existing) {\n\t\t\treturn cloneFlowState(DEFAULT_FLOW_STATE);\n\t\t}\n\t\treturn cloneFlowState(existing);\n\t};\n\n\tconst setFlowStateForHandle = (\n\t\tflowHandleId: FlowHandleId,\n\t\tstate: FlowState,\n\t): void => {\n\t\tflowStateByHandle.set(flowHandleId, cloneFlowState(state));\n\t};\n\n\tconst getInstanceFlowState = (): FlowState =>\n\t\tcloneFlowState(instanceFlowState);\n\n\tconst setInstanceFlowState = (state: FlowState): void => {\n\t\tinstanceFlowState = cloneFlowState(state);\n\t};\n\n\tconst ensureFlowStateForHandle = (flowHandleId: FlowHandleId): void => {\n\t\tif (!flowStateByHandle.has(flowHandleId)) {\n\t\t\tsetFlowStateForHandle(flowHandleId, DEFAULT_FLOW_STATE);\n\t\t}\n\t};\n\n\tconst isLoaderRequested = (): boolean => loaderRequested;\n\n\tconst enqueue = (envelope: CommandEnvelope): void => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tif (!window.__getuserfeedback_queue) {\n\t\t\twindow.__getuserfeedback_queue = [];\n\t\t}\n\t\t// Stamp instanceId and clientMeta so the loader can route commands.\n\t\tconst stamped: CommandEnvelope = {\n\t\t\t...envelope,\n\t\t\tinstanceId: envelope.instanceId ?? clientInstanceId,\n\t\t\tclientMeta: envelope.clientMeta ?? clientMeta,\n\t\t};\n\t\twindow.__getuserfeedback_queue.push(stamped);\n\t};\n\n\tconst enqueueInstanceRegistration = (requestId?: string): string => {\n\t\tconst registrationRequestId = requestId ?? createCommandRequestId();\n\t\tenqueue({\n\t\t\tversion: \"1\",\n\t\t\tinstanceId: clientInstanceId,\n\t\t\trequestId: registrationRequestId,\n\t\t\tidempotencyKey: registrationRequestId,\n\t\t\tcommand: { kind: \"init\", opts: buildInitOpts() },\n\t\t});\n\t\treturn registrationRequestId;\n\t};\n\n\tconst enqueueSetContainer = (\n\t\tflowHandleId: FlowHandleId,\n\t\telement: HTMLElement | null,\n\t): void => {\n\t\tconst requestId = createCommandRequestId();\n\t\tenqueue({\n\t\t\tversion: \"1\",\n\t\t\trequestId,\n\t\t\tidempotencyKey: requestId,\n\t\t\tcommand: { kind: \"setContainer\", flowHandleId, container: element },\n\t\t});\n\t};\n\n\tconst enqueueSetDefaultContainerPolicy = (policy: ContainerPolicy): void => {\n\t\tconst requestId = createCommandRequestId();\n\t\tenqueue({\n\t\t\tversion: \"1\",\n\t\t\trequestId,\n\t\t\tidempotencyKey: requestId,\n\t\t\tcommand: { kind: \"setDefaultContainerPolicy\", policy },\n\t\t});\n\t};\n\n\tconst reportAsyncError = <T>(promise: Promise<T>): Promise<T> => {\n\t\treturn promise.catch((error) => {\n\t\t\tnotifyError(error);\n\t\t\tthrow error;\n\t\t});\n\t};\n\n\tconst ensureCommandsCanRun = (): void => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tif (!isLoaderRequested()) {\n\t\t\tif (disableAutoLoadConfig) {\n\t\t\t\tthrow new Error(\"Widget not loaded. Call client.load() first.\");\n\t\t\t}\n\t\t\tload();\n\t\t}\n\t};\n\n\t/** Enqueue a command and await its settlement.\n\t * The loader resolves instanceId from the instance registry. */\n\tconst rawDispatch = createCommandDispatch((cmd) => enqueue(cmd));\n\tconst dispatch = async (input: Command): Promise<void> => {\n\t\tensureCommandsCanRun();\n\t\treturn rawDispatch(input);\n\t};\n\n\tconst enqueueConfigUpdate = (opts: ConfigureOptions): void => {\n\t\tif (!isLoaderRequested()) {\n\t\t\treturn;\n\t\t}\n\t\tconst requestId = createCommandRequestId();\n\t\tenqueue({\n\t\t\tversion: \"1\",\n\t\t\trequestId,\n\t\t\tidempotencyKey: requestId,\n\t\t\tcommand: { kind: \"configure\", opts },\n\t\t});\n\t};\n\n\tconst updateOptions = (next: ClientOptions): void => {\n\t\tdisableAutoLoadConfig = next.disableAutoLoad ?? disableAutoLoadConfig;\n\t\tdefaultConsentConfig = next.defaultConsent ?? defaultConsentConfig;\n\n\t\tif (next._cdn !== undefined && next._cdn !== _cdnConfig) {\n\t\t\tif (isLoaderRequested() || pendingLoad !== null) {\n\t\t\t\tconst error = new Error(\n\t\t\t\t\t\"_cdn cannot be changed after widget init; keeping original\",\n\t\t\t\t);\n\t\t\t\tnotifyError(error);\n\t\t\t} else {\n\t\t\t\t_cdnConfig = next._cdn;\n\t\t\t}\n\t\t}\n\n\t\tapplyStartupConfig(next);\n\n\t\tif (!disableAutoLoadConfig && !isLoaderRequested()) {\n\t\t\tload();\n\t\t}\n\t};\n\n\tconst applyStartupConfig = (next: ClientOptions): void => {\n\t\t// Send configure payload from next (colorScheme only from ClientOptions).\n\t\tif (!isLoaderRequested()) return;\n\t\tconst opts: ConfigureOptions = {};\n\t\tif (next.colorScheme !== undefined) opts.colorScheme = next.colorScheme;\n\t\tenqueueConfigUpdate(opts);\n\t};\n\n\tconst load = (): void => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tif (isLoaderRequested() || pendingLoad) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst appendLoaderScript = (): void => {\n\t\t\tconst cdnBase = _cdnConfig.endsWith(\"/\") ? _cdnConfig : `${_cdnConfig}/`;\n\t\t\tconst loaderScriptPath = `loader/${loaderVersion}/${encodeURIComponent(\n\t\t\t\tapiKey,\n\t\t\t)}/loader.js`;\n\t\t\tconst scriptUrl = new URL(loaderScriptPath, cdnBase).toString();\n\t\t\tif (!document.querySelector(`link[href=\"${scriptUrl}\"][rel=\"preload\"]`)) {\n\t\t\t\tconst preload = document.createElement(\"link\");\n\t\t\t\tpreload.rel = \"preload\";\n\t\t\t\tpreload.as = \"script\";\n\t\t\t\tpreload.href = scriptUrl;\n\t\t\t\tdocument.head.appendChild(preload);\n\t\t\t}\n\n\t\t\tconst script = document.createElement(\"script\");\n\t\t\tscript.src = scriptUrl;\n\t\t\tscript.async = true;\n\t\t\tif (script.dataset) {\n\t\t\t\tscript.dataset.disableAutoRegister = \"true\";\n\t\t\t} else if (typeof script.setAttribute === \"function\") {\n\t\t\t\tscript.setAttribute(\"data-disable-auto-register\", \"true\");\n\t\t\t}\n\t\t\tdocument.head.appendChild(script);\n\t\t};\n\n\t\tconst runtimeMarker = window[LOADER_RUNTIME_GLOBAL_KEY];\n\t\tif (runtimeMarker?.alive) {\n\t\t\tconst protocolVersion = runtimeMarker.protocolVersion;\n\t\t\tif (protocolVersion !== LOADER_RUNTIME_PROTOCOL_VERSION) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Incompatible loader runtime protocol: expected ${LOADER_RUNTIME_PROTOCOL_VERSION}, received ${protocolVersion ?? \"unknown\"}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tenqueueInstanceRegistration();\n\t\t\tloaderRequested = true;\n\t\t\treturn;\n\t\t}\n\n\t\tconst hasCommandQueue = Array.isArray(window.__getuserfeedback_queue);\n\t\tif (!hasCommandQueue) {\n\t\t\tconst requestId = enqueueInstanceRegistration();\n\t\t\tappendLoaderScript();\n\t\t\tloaderRequested = true;\n\t\t\tlet trackedPending: Promise<void>;\n\t\t\tconst pending = waitForCommandSettlement({\n\t\t\t\trequestId,\n\t\t\t\ttimeoutMs: LOADER_RUNTIME_POST_LOAD_TIMEOUT_MS,\n\t\t\t})\n\t\t\t\t.then(() => {})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tnotifyError(error);\n\t\t\t\t});\n\t\t\ttrackedPending = pending.finally(() => {\n\t\t\t\tif (pendingLoad === trackedPending) {\n\t\t\t\t\tpendingLoad = null;\n\t\t\t\t}\n\t\t\t});\n\t\t\tpendingLoad = trackedPending;\n\t\t\treturn;\n\t\t}\n\n\t\tloaderRequested = true;\n\n\t\tlet trackedPending: Promise<void>;\n\t\tconst pending = (async () => {\n\t\t\tconst requestId = createCommandRequestId();\n\t\t\tenqueueInstanceRegistration(requestId);\n\t\t\ttry {\n\t\t\t\tawait waitForCommandSettlement({\n\t\t\t\t\trequestId,\n\t\t\t\t\ttimeoutMs: LOADER_RUNTIME_PROBE_TIMEOUT_MS,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof CommandSettlementTimeoutError) {\n\t\t\t\t\tappendLoaderScript();\n\t\t\t\t\tawait waitForCommandSettlement({\n\t\t\t\t\t\trequestId,\n\t\t\t\t\t\ttimeoutMs: LOADER_RUNTIME_POST_LOAD_TIMEOUT_MS,\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})().catch((error) => {\n\t\t\tnotifyError(error);\n\t\t});\n\t\ttrackedPending = pending.finally(() => {\n\t\t\tif (pendingLoad === trackedPending) {\n\t\t\t\tpendingLoad = null;\n\t\t\t}\n\t\t});\n\t\tpendingLoad = trackedPending;\n\t};\n\n\tconst setContainerForHandle = (\n\t\tflowHandleId: FlowHandleId,\n\t\telement: HTMLElement | null,\n\t): void => {\n\t\t// Always enqueue — commands sit in the global queue until the\n\t\t// loader processes them. The command-router stores containers in\n\t\t// pendingContainer and applies them when a flow run is allocated.\n\t\tenqueueSetContainer(flowHandleId, element);\n\t};\n\n\tconst setDefaultContainer = (element: HTMLElement | null): void => {\n\t\tif (element === null) {\n\t\t\tenqueueSetDefaultContainerPolicy({ kind: \"floating\" });\n\t\t\treturn;\n\t\t}\n\t\tenqueueSetDefaultContainerPolicy({\n\t\t\tkind: \"hostContainer\",\n\t\t\thost: element,\n\t\t\tsharing: \"shared\",\n\t\t});\n\t};\n\n\tconst subscribeFlowStateForHandle = (\n\t\tflowHandleId: FlowHandleId,\n\t\tcallback: FlowStateCallback,\n\t\toptions?: SubscribeFlowStateOptions,\n\t): (() => void) => {\n\t\tif (options?.emitInitial ?? true) {\n\t\t\tcallback(getFlowStateForHandle(flowHandleId));\n\t\t}\n\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst eventName = toHostEventName(\n\t\t\tHOST_EVENT_KEYS.INSTANCE_FLOW_STATE_CHANGED,\n\t\t);\n\n\t\tconst handleFlowStateEvent = (event: Event): void => {\n\t\t\tconst detail = (event as CustomEvent<unknown>).detail;\n\t\t\tif (\n\t\t\t\t!isFlowStateChangedDetail(detail) ||\n\t\t\t\tdetail.flowHandleId !== flowHandleId\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextState: FlowState = {\n\t\t\t\tisOpen: detail.isOpen,\n\t\t\t\tisLoading: detail.isLoading,\n\t\t\t\twidth: detail.width,\n\t\t\t\theight: detail.height,\n\t\t\t};\n\t\t\tsetFlowStateForHandle(flowHandleId, nextState);\n\t\t\tcallback(cloneFlowState(nextState));\n\t\t};\n\n\t\tlet isUnsubscribed = false;\n\t\tconst signal = options?.signal;\n\t\tlet handleAbort: (() => void) | null = null;\n\n\t\tconst unsubscribe = (): void => {\n\t\t\tif (isUnsubscribed) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tisUnsubscribed = true;\n\t\t\twindow.removeEventListener(eventName, handleFlowStateEvent);\n\t\t\tif (signal && handleAbort) {\n\t\t\t\tsignal.removeEventListener(\"abort\", handleAbort);\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(eventName, handleFlowStateEvent);\n\n\t\tif (signal) {\n\t\t\thandleAbort = () => {\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t\tif (signal.aborted) {\n\t\t\t\tunsubscribe();\n\t\t\t\treturn unsubscribe;\n\t\t\t}\n\t\t\tsignal.addEventListener(\"abort\", handleAbort, { once: true });\n\t\t}\n\n\t\treturn unsubscribe;\n\t};\n\n\tconst subscribeFlowStateForInstance = (\n\t\tcallback: FlowStateCallback,\n\t\toptions?: SubscribeFlowStateOptions,\n\t): (() => void) => {\n\t\tif (options?.emitInitial ?? true) {\n\t\t\tcallback(getInstanceFlowState());\n\t\t}\n\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst eventName = toHostEventName(\n\t\t\tHOST_EVENT_KEYS.INSTANCE_FLOW_STATE_CHANGED_INSTANCE,\n\t\t);\n\n\t\tconst handleFlowStateEvent = (event: Event): void => {\n\t\t\tconst detail = (event as CustomEvent<unknown>).detail;\n\t\t\tif (\n\t\t\t\t!isInstanceFlowStateChangedDetail(detail) ||\n\t\t\t\tdetail.instanceId !== clientInstanceId\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst nextState: FlowState = {\n\t\t\t\tisOpen: detail.isOpen,\n\t\t\t\tisLoading: detail.isLoading,\n\t\t\t\twidth: detail.width,\n\t\t\t\theight: detail.height,\n\t\t\t};\n\t\t\tsetInstanceFlowState(nextState);\n\t\t\tcallback(cloneFlowState(nextState));\n\t\t};\n\n\t\tlet isUnsubscribed = false;\n\t\tconst signal = options?.signal;\n\t\tlet handleAbort: (() => void) | null = null;\n\n\t\tconst unsubscribe = (): void => {\n\t\t\tif (isUnsubscribed) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tisUnsubscribed = true;\n\t\t\twindow.removeEventListener(eventName, handleFlowStateEvent);\n\t\t\tif (signal && handleAbort) {\n\t\t\t\tsignal.removeEventListener(\"abort\", handleAbort);\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(eventName, handleFlowStateEvent);\n\n\t\tif (signal) {\n\t\t\thandleAbort = () => {\n\t\t\t\tunsubscribe();\n\t\t\t};\n\t\t\tif (signal.aborted) {\n\t\t\t\tunsubscribe();\n\t\t\t\treturn unsubscribe;\n\t\t\t}\n\t\t\tsignal.addEventListener(\"abort\", handleAbort, { once: true });\n\t\t}\n\n\t\treturn unsubscribe;\n\t};\n\n\tconst createFlowRun = (flowIdInput: string): FlowRun => {\n\t\tconst flowId = flowIdInput;\n\t\tif (!flowId.trim()) {\n\t\t\tthrow new Error(\"flowId must be a non-empty string\");\n\t\t}\n\t\tconst flowHandleId = createFlowHandleId();\n\t\tensureFlowStateForHandle(flowHandleId);\n\n\t\treturn {\n\t\t\tflowId,\n\t\t\topen: (options?: OpenFlowOptions) =>\n\t\t\t\treportAsyncError(\n\t\t\t\t\tdispatch({\n\t\t\t\t\t\tkind: \"open\",\n\t\t\t\t\t\tflowId,\n\t\t\t\t\t\tflowHandleId,\n\t\t\t\t\t\t...(options?.containerRequirement\n\t\t\t\t\t\t\t? { containerRequirement: options.containerRequirement }\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\tprefetch: () => reportAsyncError(dispatch({ kind: \"prefetch\", flowId })),\n\t\t\tprerender: () =>\n\t\t\t\treportAsyncError(dispatch({ kind: \"prerender\", flowId, flowHandleId })),\n\t\t\tclose: () => reportAsyncError(dispatch({ kind: \"close\", flowHandleId })),\n\t\t\tsetContainer: (element: HTMLElement | null) => {\n\t\t\t\tsetContainerForHandle(flowHandleId, element);\n\t\t\t},\n\t\t\tgetFlowState: () => getFlowStateForHandle(flowHandleId),\n\t\t\tsubscribeFlowState: (\n\t\t\t\tcallback: FlowStateCallback,\n\t\t\t\toptions?: SubscribeFlowStateOptions,\n\t\t\t) => subscribeFlowStateForHandle(flowHandleId, callback, options),\n\t\t};\n\t};\n\n\tconst flow = (flowIdInput: string): FlowRun => createFlowRun(flowIdInput);\n\n\tconst open = async (\n\t\tflowIdInput: string,\n\t\toptions?: OpenFlowOptions,\n\t): Promise<FlowRun> => {\n\t\tconst nextFlowRun = createFlowRun(flowIdInput);\n\t\tawait nextFlowRun.open(options);\n\t\treturn nextFlowRun;\n\t};\n\n\tconst prefetch = async (flowIdInput: string): Promise<FlowRun> => {\n\t\tconst nextFlowRun = createFlowRun(flowIdInput);\n\t\tawait nextFlowRun.prefetch();\n\t\treturn nextFlowRun;\n\t};\n\n\tconst close = (): Promise<void> => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn reportAsyncError(dispatch({ kind: \"close\" }));\n\t};\n\n\tconst reset = (): Promise<void> => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn reportAsyncError(dispatch({ kind: \"reset\" }));\n\t};\n\n\tfunction identify(userId: string, traits?: IdentifyTraits): Promise<void>;\n\tfunction identify(traits: IdentifyTraits): Promise<void>;\n\tfunction identify(\n\t\tidentifyInput: string | IdentifyTraits,\n\t\ttraits?: IdentifyTraits,\n\t): Promise<void> {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\treturn reportAsyncError(\n\t\t\tdispatch(toIdentifyCommandPayload(identifyInput, traits)),\n\t\t);\n\t}\n\n\tconst configure = (updates: ConfigureOptions): Promise<void> => {\n\t\tif (typeof window === \"undefined\") {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tif (!isLoaderRequested()) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\t// Send updates as-is; loader merges and forwards deltas to core.\n\t\treturn reportAsyncError(dispatch({ kind: \"configure\", opts: updates }));\n\t};\n\n\tconst prerender = async (flowIdInput: string): Promise<FlowRun> => {\n\t\tconst nextFlowRun = createFlowRun(flowIdInput);\n\t\tawait nextFlowRun.prerender();\n\t\treturn nextFlowRun;\n\t};\n\n\tconst client: Client = {\n\t\tload,\n\t\tsetDefaultContainerPolicy: (policy: ContainerPolicy) => {\n\t\t\tenqueueSetDefaultContainerPolicy(policy);\n\t\t},\n\t\tsetContainer: (element: HTMLElement | null) => {\n\t\t\tsetDefaultContainer(element);\n\t\t},\n\t\tgetFlowState: () => getInstanceFlowState(),\n\t\tsubscribeFlowState: (\n\t\t\tcallback: FlowStateCallback,\n\t\t\toptions?: SubscribeFlowStateOptions,\n\t\t) => subscribeFlowStateForInstance(callback, options),\n\t\tflow,\n\t\topen,\n\t\tprefetch,\n\t\tprerender,\n\t\tclose,\n\t\treset,\n\t\tconfigure,\n\t\tidentify,\n\t};\n\n\tregistry.set(registryKey, {\n\t\tclient,\n\t\tupdateOptions,\n\t});\n\n\tif (!disableAutoLoadConfig) {\n\t\tclient.load();\n\t}\n\n\treturn client;\n};\n\nexport default createClient;\n"
12
+ ],
13
+ "mappings": "AAmCO,IAAM,EAAkB,CAC9B,4BAA6B,8BAC7B,qCAAsC,uCACtC,yBAA0B,2BAC1B,6BAA8B,+BAC9B,eAAgB,iBAChB,wBAAyB,0BACzB,0BAA2B,4BAC3B,sBAAuB,wBACvB,eAAgB,iBAChB,mBAAoB,oBACrB,EAIM,EAAiC,CACtC,UAAW,0BACX,KAAM,qBACN,SAAU,yBACV,UAAW,0BACX,SAAU,yBACV,MAAO,sBACP,MAAO,sBACP,aAAc,6BACd,0BAA2B,yCAC5B,EAKM,GAA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816B6682BA864756E2164756E21",
15
+ "names": []
16
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@getuserfeedback/sdk",
3
+ "version": "0.1.0",
4
+ "description": "GetUserFeedback widget SDK for the browser",
5
+ "keywords": [
6
+ "getuserfeedback",
7
+ "feedback",
8
+ "widget",
9
+ "sdk"
10
+ ],
11
+ "license": "MIT",
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "type": "module",
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "import": "./dist/index.js",
21
+ "types": "./dist/index.d.ts"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "dependencies": {},
28
+ "devDependencies": {
29
+ "rollup": "^4.57.1",
30
+ "rollup-plugin-dts": "^6.3.0"
31
+ },
32
+ "scripts": {
33
+ "prepack": "node scripts/prepack.cjs",
34
+ "postpack": "node scripts/postpack.cjs",
35
+ "build": "bun x rimraf dist tsconfig.tsbuildinfo && bun run scripts/build.ts && bun x rollup -c rollup.dts.config.mjs",
36
+ "typecheck": "tsc -b tsconfig.json",
37
+ "test": "bun test"
38
+ }
39
+ }