arcy.js 0.0.2 → 0.1.1
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 +94 -3
- package/dist/arcy.chat.3968644db103.js +1271 -0
- package/dist/arcy.flow.fef131718e42.js +3 -0
- package/dist/arcy.legacy.b4005932a6cc.js +568 -0
- package/dist/arcy.loader.js +2 -0
- package/dist/arcy.modern.a51b9a32dd28.js +568 -0
- package/dist/arcy.picker.73f47221b73c.js +59 -0
- package/dist/chat-BK57WIAA.js +3867 -0
- package/dist/chunk-6HBSGVRN.js +219 -0
- package/dist/chunk-7VVKR3AO.js +122 -0
- package/dist/chunk-CQ2DESAJ.js +263 -0
- package/dist/chunk-DKYMIAYF.js +7 -0
- package/dist/chunk-FR6SJSDU.js +220 -0
- package/dist/chunk-LGWYJSYX.js +271 -0
- package/dist/chunk-NIHUDSWK.js +155 -0
- package/dist/chunk-NY3NXM2V.js +213 -0
- package/dist/design-mode.cjs +135 -0
- package/dist/design-mode.d.ts +197 -0
- package/dist/design-mode.js +2 -0
- package/dist/flow-M7W3H3C5.js +1422 -0
- package/dist/fonts/dm-sans-latin-ext.woff2 +0 -0
- package/dist/fonts/dm-sans-latin.woff2 +0 -0
- package/dist/fonts/ibm-plex-sans-latin-ext.woff2 +0 -0
- package/dist/fonts/ibm-plex-sans-latin.woff2 +0 -0
- package/dist/fonts/inter-latin-ext.woff2 +0 -0
- package/dist/fonts/inter-latin.woff2 +0 -0
- package/dist/fonts/lato-latin-ext.woff2 +0 -0
- package/dist/fonts/lato-latin.woff2 +0 -0
- package/dist/fonts/manrope-latin-ext.woff2 +0 -0
- package/dist/fonts/manrope-latin.woff2 +0 -0
- package/dist/fonts/montserrat-latin-ext.woff2 +0 -0
- package/dist/fonts/montserrat-latin.woff2 +0 -0
- package/dist/fonts/nunito-latin-ext.woff2 +0 -0
- package/dist/fonts/nunito-latin.woff2 +0 -0
- package/dist/fonts/open-sans-latin-ext.woff2 +0 -0
- package/dist/fonts/open-sans-latin.woff2 +0 -0
- package/dist/fonts/playfair-display-latin-ext.woff2 +0 -0
- package/dist/fonts/playfair-display-latin.woff2 +0 -0
- package/dist/fonts/poppins-latin-ext.woff2 +0 -0
- package/dist/fonts/poppins-latin.woff2 +0 -0
- package/dist/fonts/roboto-latin-ext.woff2 +0 -0
- package/dist/fonts/roboto-latin.woff2 +0 -0
- package/dist/fonts/source-sans-3-latin-ext.woff2 +0 -0
- package/dist/fonts/source-sans-3-latin.woff2 +0 -0
- package/dist/fonts/work-sans-latin-ext.woff2 +0 -0
- package/dist/fonts/work-sans-latin.woff2 +0 -0
- package/dist/index.cjs +13848 -0
- package/dist/index.d.ts +169 -0
- package/dist/index.js +4743 -0
- package/dist/picker-JPESE6JJ.js +2134 -0
- package/dist/snippet.cjs +46 -0
- package/dist/snippet.d.ts +39 -0
- package/dist/snippet.js +43 -0
- package/package.json +69 -5
- package/index.js +0 -5
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The three widget lifecycle events, and deliberately only three
|
|
3
|
+
* (PRODUCT_SCOPE §1.1, ADR 0050).
|
|
4
|
+
*
|
|
5
|
+
* `message` and the flow events are absent on purpose: they belong to
|
|
6
|
+
* subsystems that do not exist yet, and publishing an event name promises a
|
|
7
|
+
* contract before the thing that fires it is built. A host app that wires a
|
|
8
|
+
* handler and gets silence has been lied to. Adding an event later is additive.
|
|
9
|
+
*/
|
|
10
|
+
type ArcyEvent = "ready" | "open" | "close";
|
|
11
|
+
type ArcyEventHandler = () => void;
|
|
12
|
+
/** The function `on()` hands back. Calling it removes that one handler. */
|
|
13
|
+
type Unsubscribe = () => void;
|
|
14
|
+
/**
|
|
15
|
+
* What an attribute value may be. Mirrors the five trait data types the backend
|
|
16
|
+
* registry accepts (PRODUCT_SCOPE §9.1.5), plus `null`, which clears the key
|
|
17
|
+
* and is the only value that does.
|
|
18
|
+
*
|
|
19
|
+
* Typing is enforced server-side against the declared trait, not here: the
|
|
20
|
+
* widget cannot know what an app has declared, and validating twice with one
|
|
21
|
+
* side guessing produces disagreements that are worse than no check at all.
|
|
22
|
+
*/
|
|
23
|
+
type AttributeValue = string | number | boolean | null | string[];
|
|
24
|
+
type Attributes = Record<string, AttributeValue>;
|
|
25
|
+
/**
|
|
26
|
+
* What a caller may hand `identify()`, and it is deliberately wider than what
|
|
27
|
+
* goes on the wire (ADR 0194).
|
|
28
|
+
*
|
|
29
|
+
* `undefined` means "nothing to send for this key": the key is dropped from the
|
|
30
|
+
* payload before it leaves the browser, silently, and never reaches the server.
|
|
31
|
+
* It exists because every auth SDK returns optional fields, so the line an
|
|
32
|
+
* operator naturally writes is `user_email: user.primaryEmailAddress?.emailAddress`,
|
|
33
|
+
* and a type that refuses it refuses the install snippet we publish.
|
|
34
|
+
*
|
|
35
|
+
* This keeps the three spellings distinct. An absent key means "do not touch",
|
|
36
|
+
* `null` means "clear it", and a value means "set it". `undefined` is the first
|
|
37
|
+
* of those, spelled the way JavaScript spells it.
|
|
38
|
+
*/
|
|
39
|
+
type AttributesInput = Record<string, AttributeValue | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* The complete set of `init()` options, and it is complete by design
|
|
42
|
+
* (PRODUCT_SCOPE §11.5.1, resolved at G1 as Q41). **Reopened once, D733**
|
|
43
|
+
* (PRD 11, slice 11.8): `contentLocale` was added as the fourth and only
|
|
44
|
+
* other deliberate exception, for the same reason as the original three - it
|
|
45
|
+
* is a runtime escape hatch the dashboard cannot know about, not
|
|
46
|
+
* configuration moved to the wrong side of the boundary. See `contentLocale`
|
|
47
|
+
* below for why it is a separate option from `locale` rather than a second
|
|
48
|
+
* code shape on the same one.
|
|
49
|
+
*
|
|
50
|
+
* Configuration is authored in the dashboard. These four are runtime escape
|
|
51
|
+
* hatches for things the dashboard structurally cannot know, and the dashboard
|
|
52
|
+
* shows an "Overridden in code" badge when one is sent. Anything a
|
|
53
|
+
* non-developer would want to change belongs in the dashboard, where they can
|
|
54
|
+
* actually reach it. **Do not add a fifth without reopening Q41.**
|
|
55
|
+
*/
|
|
56
|
+
interface ArcyOptions {
|
|
57
|
+
/** Consent signal for behavioral telemetry. A cookie banner is code. */
|
|
58
|
+
telemetry?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Where the widget talks to ARCY, if not `https://api.arcyai.com`.
|
|
61
|
+
*
|
|
62
|
+
* The fifth escape hatch (D1396, ADR 0186), and it exists for one reason:
|
|
63
|
+
* a page under a Content Security Policy has to name every origin the
|
|
64
|
+
* widget reaches, and a customer who would rather name none can rewrite a
|
|
65
|
+
* path on their own domain to our API and pass it here. Session, chat,
|
|
66
|
+
* flows, telemetry, image uploads and the panel's web fonts all follow it,
|
|
67
|
+
* so proxying moves the whole widget rather than most of it.
|
|
68
|
+
*
|
|
69
|
+
* An origin or an origin with a path prefix, no trailing slash, for
|
|
70
|
+
* example `https://example.com/_arcy`. Anything that is not a string is
|
|
71
|
+
* ignored with a warning, like every other bad option.
|
|
72
|
+
*/
|
|
73
|
+
apiBase?: string;
|
|
74
|
+
/**
|
|
75
|
+
* The host app usually knows the user's language before ARCY loads.
|
|
76
|
+
*
|
|
77
|
+
* Two-letter codes only (`"en"`/`"tr"`). This feeds `SdkApp.uiLanguage`,
|
|
78
|
+
* the agent's default reply-language directive (D691) - it does **not**
|
|
79
|
+
* set the session's content locale. See `contentLocale` for that, a
|
|
80
|
+
* deliberately separate option (D732, D733): the two shapes (`"en"` vs.
|
|
81
|
+
* `"en-US"`) are ambiguous on one option, and a customer whose
|
|
82
|
+
* reply-language default and content locale genuinely differ (an
|
|
83
|
+
* English-replying agent serving a `tr-TR` audience, or vice versa) needs
|
|
84
|
+
* to be able to set them independently.
|
|
85
|
+
*/
|
|
86
|
+
locale?: string;
|
|
87
|
+
/** A support page wanting the panel open on arrival is a real, narrow case. */
|
|
88
|
+
defaultOpen?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* The end user's content locale (PRD 11, slice 11.8; ADR 0049, D733).
|
|
91
|
+
*
|
|
92
|
+
* Region-qualified (`"en-US"`/`"tr-TR"`, the `LocaleCode` catalogue from
|
|
93
|
+
* the backend's `locale-catalog.ts`), unlike `locale` above. Seeds
|
|
94
|
+
* `SdkSession.localeCode`'s explicit tier at bootstrap time - the same
|
|
95
|
+
* tier a `locale_code` identify()/updateUser() trait fills (§1.1's install
|
|
96
|
+
* snippet). **Not auto-derived from `locale`, deliberately (D733):** that
|
|
97
|
+
* would silently guess a customer's audience region from their reply
|
|
98
|
+
* language, which is wrong exactly when the two are set independently for
|
|
99
|
+
* a real reason. Pass both when both are known; pass neither and the
|
|
100
|
+
* chain falls through to the browser language, then the app default.
|
|
101
|
+
*/
|
|
102
|
+
contentLocale?: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The namespace object: `window.arcy` in the HTML build, the default export in
|
|
106
|
+
* the npm build. Both paths resolve to the same object so a call written
|
|
107
|
+
* against one behaves identically on the other.
|
|
108
|
+
*
|
|
109
|
+
* **No method throws and no promise rejects** (ADR 0050). Async methods resolve
|
|
110
|
+
* even on failure and report through a console warning. A rejected promise
|
|
111
|
+
* nobody awaited surfaces as an unhandled rejection inside the customer's error
|
|
112
|
+
* reporting, attributed to them, and the documented install snippet calls
|
|
113
|
+
* `identify()` with no `await`.
|
|
114
|
+
*/
|
|
115
|
+
/**
|
|
116
|
+
* The third argument to `identify()` (slice 6.3, D158).
|
|
117
|
+
*
|
|
118
|
+
* **An options object rather than a positional third parameter**, because
|
|
119
|
+
* ADR 0050 froze this API and a frozen API published on customer pages is
|
|
120
|
+
* exactly where positional arguments accumulate into
|
|
121
|
+
* `identify(id, traits, hash, null, true)` with no way to fix it. Four extra
|
|
122
|
+
* characters in the copy-paste recipe buys extensibility on the one surface
|
|
123
|
+
* that cannot be revised.
|
|
124
|
+
*/
|
|
125
|
+
interface IdentifyOptions {
|
|
126
|
+
/**
|
|
127
|
+
* `HMAC-SHA256(environment Secret, userId)`, computed on the customer's own
|
|
128
|
+
* server and never in the browser (PRD 6, D152).
|
|
129
|
+
*
|
|
130
|
+
* The name is Intercom's and Segment's, so the install recipe reads as
|
|
131
|
+
* familiar rather than novel. Optional, and strongly recommended: with
|
|
132
|
+
* identity verification off it is recorded and changes nothing, and with it
|
|
133
|
+
* on an unproven identity degrades to anonymous rather than being trusted.
|
|
134
|
+
*/
|
|
135
|
+
userHash?: string;
|
|
136
|
+
}
|
|
137
|
+
interface Arcy {
|
|
138
|
+
init(token: string, options?: ArcyOptions): Promise<void>;
|
|
139
|
+
identify(userId: string, attributes?: AttributesInput, options?: IdentifyOptions): Promise<void>;
|
|
140
|
+
identifyAnonymous(attributes?: AttributesInput): Promise<void>;
|
|
141
|
+
updateUser(attributes?: AttributesInput): Promise<void>;
|
|
142
|
+
reset(): void;
|
|
143
|
+
open(): void;
|
|
144
|
+
close(): void;
|
|
145
|
+
on(event: ArcyEvent, handler: ArcyEventHandler): Unsubscribe;
|
|
146
|
+
readonly VERSION: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Kept as a plain literal rather than injected from package.json at build time,
|
|
151
|
+
* so the ESM, CJS, and IIFE builds all carry the same value with no build-time
|
|
152
|
+
* indirection. Bumped with the package version.
|
|
153
|
+
*/
|
|
154
|
+
declare const VERSION = "0.1.1";
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The namespace object, and the npm build's default export. `src/browser.ts`
|
|
158
|
+
* builds the same object for `window.arcy` on the script path.
|
|
159
|
+
*
|
|
160
|
+
* The two entry points differ in exactly one argument (ADR 0185): this one
|
|
161
|
+
* loads the chat panel, the flow engine and the picker with `import()`, so
|
|
162
|
+
* they become chunks in the customer's own build on the customer's own
|
|
163
|
+
* origin. The script build injects them from the CDN, which is the origin
|
|
164
|
+
* its install snippet already comes from. Nothing else about the two paths
|
|
165
|
+
* differs, and a call written against one behaves identically on the other.
|
|
166
|
+
*/
|
|
167
|
+
declare const arcy: Arcy;
|
|
168
|
+
|
|
169
|
+
export { type Arcy, type ArcyEvent, type ArcyEventHandler, type ArcyOptions, type AttributeValue, type Attributes, type AttributesInput, type Unsubscribe, VERSION, arcy as default };
|