Commit c5db75a
Every provider method is now safe to call before the CDN script
finishes booting. Calls buffered into a per-provider queue, drained
in order once the real global is exposed.
- new _queue.ts: generic in-memory op queue with ready/reset/drain
- new _identity.ts: state machine (anonymous/identified) with
onChange listeners and typed Verification discriminated union
(hmac for intercom/crisp/tawk/chatwoot, jwt for hubspot,
jwt+callback for zendesk messenger)
- intercom: install official queue stub before CDN boots so pre-load
calls are preserved; HMAC via user_hash
- crisp: keep queue-native \$crisp.push; HMAC for user:email
- tawk: Tawk_API.onLoad feeds our queue; HMAC for setAttributes
- zendesk: queue over zE; jwt or callback required for loginUser
- hubspot: _hsq queue-native for identify/track; hsConversationsOnReady
feeds our queue for widget ops; jwt verification sets identificationToken
- chatwoot: chatwoot:ready event feeds queue; identifier_hash for setUser
- every method is SSR-safe (returns resolved Promise when !isBrowser())
Tests: 39 green (queue drain order, reentrant enqueue, identity
transitions, pre-boot call buffering via jsdom).
Preempts competitor bugs cited in #1 (react-use-intercom#635/#747/#824,
crisp-sdk-web#11/#28, tawk-messenger-react#9/#26) and #4
(chatwoot#7065/#13448, crisp-sdk-web#19/#32/#49).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 664ab2e commit c5db75a
File tree
18 files changed
+3189
-126
lines changed- src
- providers
- test
18 files changed
+3189
-126
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | 8 | | |
16 | | - | |
17 | | - | |
| 9 | + | |
| 10 | + | |
18 | 11 | | |
| 12 | + | |
19 | 13 | | |
20 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
21 | 19 | | |
22 | | - | |
| 20 | + | |
23 | 21 | | |
| 22 | + | |
24 | 23 | | |
25 | 24 | | |
26 | | - | |
27 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
0 commit comments