@agentuity/frontend 0.1.13 → 0.1.14
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/dist/beacon-script.js +1 -1
- package/dist/beacon.js +1 -1
- package/package.json +4 -4
- package/dist/analytics/beacon-standalone.d.ts +0 -106
- package/dist/analytics/beacon-standalone.d.ts.map +0 -1
- package/dist/analytics/beacon-standalone.js +0 -584
- package/dist/analytics/beacon-standalone.js.map +0 -1
- package/dist/analytics/index.d.ts +0 -22
- package/dist/analytics/index.d.ts.map +0 -1
- package/dist/analytics/index.js +0 -28
- package/dist/analytics/index.js.map +0 -1
- package/dist/analytics/types.d.ts +0 -141
- package/dist/analytics/types.d.ts.map +0 -1
- package/dist/analytics/types.js +0 -2
- package/dist/analytics/types.js.map +0 -1
- package/dist/analytics/utils/storage.d.ts +0 -13
- package/dist/analytics/utils/storage.d.ts.map +0 -1
- package/dist/analytics/utils/storage.js +0 -63
- package/dist/analytics/utils/storage.js.map +0 -1
- package/dist/analytics/utils/utm.d.ts +0 -12
- package/dist/analytics/utils/utm.d.ts.map +0 -1
- package/dist/analytics/utils/utm.js +0 -27
- package/dist/analytics/utils/utm.js.map +0 -1
- package/dist/beacon-script.d.ts +0 -16
- package/dist/beacon-script.d.ts.map +0 -1
- package/dist/beacon-script.js.map +0 -1
- package/dist/client/eventstream.d.ts +0 -12
- package/dist/client/eventstream.d.ts.map +0 -1
- package/dist/client/eventstream.js +0 -39
- package/dist/client/eventstream.js.map +0 -1
- package/dist/client/index.d.ts +0 -33
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -227
- package/dist/client/index.js.map +0 -1
- package/dist/client/stream.d.ts +0 -6
- package/dist/client/stream.d.ts.map +0 -1
- package/dist/client/stream.js +0 -49
- package/dist/client/stream.js.map +0 -1
- package/dist/client/types.d.ts +0 -168
- package/dist/client/types.d.ts.map +0 -1
- package/dist/client/types.js +0 -5
- package/dist/client/types.js.map +0 -1
- package/dist/client/websocket.d.ts +0 -6
- package/dist/client/websocket.d.ts.map +0 -1
- package/dist/client/websocket.js +0 -49
- package/dist/client/websocket.js.map +0 -1
- package/dist/env.d.ts +0 -2
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -10
- package/dist/env.js.map +0 -1
- package/dist/eventstream-manager.d.ts +0 -85
- package/dist/eventstream-manager.d.ts.map +0 -1
- package/dist/eventstream-manager.js +0 -137
- package/dist/eventstream-manager.js.map +0 -1
- package/dist/index.d.ts +0 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -15
- package/dist/index.js.map +0 -1
- package/dist/memo.d.ts +0 -6
- package/dist/memo.d.ts.map +0 -1
- package/dist/memo.js +0 -20
- package/dist/memo.js.map +0 -1
- package/dist/reconnect.d.ts +0 -22
- package/dist/reconnect.d.ts.map +0 -1
- package/dist/reconnect.js +0 -47
- package/dist/reconnect.js.map +0 -1
- package/dist/serialization.d.ts +0 -6
- package/dist/serialization.d.ts.map +0 -1
- package/dist/serialization.js +0 -16
- package/dist/serialization.js.map +0 -1
- package/dist/types.d.ts +0 -42
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/url.d.ts +0 -3
- package/dist/url.d.ts.map +0 -1
- package/dist/url.js +0 -24
- package/dist/url.js.map +0 -1
- package/dist/websocket-manager.d.ts +0 -90
- package/dist/websocket-manager.d.ts.map +0 -1
- package/dist/websocket-manager.js +0 -163
- package/dist/websocket-manager.js.map +0 -1
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Scroll milestone event - records when a scroll depth milestone was first crossed
|
|
3
|
-
*/
|
|
4
|
-
export interface ScrollEvent {
|
|
5
|
-
depth: number;
|
|
6
|
-
timestamp: number;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Custom event tracked during the page session
|
|
10
|
-
*/
|
|
11
|
-
export interface AnalyticsCustomEvent {
|
|
12
|
-
timestamp: number;
|
|
13
|
-
name: string;
|
|
14
|
-
data?: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Geo location data from agentuity.sh/location
|
|
18
|
-
*/
|
|
19
|
-
export interface GeoLocation {
|
|
20
|
-
country?: string;
|
|
21
|
-
country_latitude?: number;
|
|
22
|
-
country_longitude?: number;
|
|
23
|
-
region?: string;
|
|
24
|
-
region_latitude?: number;
|
|
25
|
-
region_longitude?: number;
|
|
26
|
-
city?: string;
|
|
27
|
-
city_latitude?: number;
|
|
28
|
-
city_longitude?: number;
|
|
29
|
-
timezone?: string;
|
|
30
|
-
latitude?: number;
|
|
31
|
-
longitude?: number;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Page view payload sent to the collection endpoint
|
|
35
|
-
* Represents a single page view with all aggregated data
|
|
36
|
-
*/
|
|
37
|
-
export interface PageViewPayload {
|
|
38
|
-
id: string;
|
|
39
|
-
timestamp: number;
|
|
40
|
-
timezone_offset: number;
|
|
41
|
-
url: string;
|
|
42
|
-
path: string;
|
|
43
|
-
referrer: string;
|
|
44
|
-
title: string;
|
|
45
|
-
screen_width: number;
|
|
46
|
-
screen_height: number;
|
|
47
|
-
viewport_width: number;
|
|
48
|
-
viewport_height: number;
|
|
49
|
-
device_pixel_ratio: number;
|
|
50
|
-
user_agent: string;
|
|
51
|
-
language: string;
|
|
52
|
-
country?: string;
|
|
53
|
-
country_latitude?: number;
|
|
54
|
-
country_longitude?: number;
|
|
55
|
-
region?: string;
|
|
56
|
-
region_latitude?: number;
|
|
57
|
-
region_longitude?: number;
|
|
58
|
-
city?: string;
|
|
59
|
-
city_latitude?: number;
|
|
60
|
-
city_longitude?: number;
|
|
61
|
-
timezone?: string;
|
|
62
|
-
latitude?: number;
|
|
63
|
-
longitude?: number;
|
|
64
|
-
load_time?: number;
|
|
65
|
-
dom_ready?: number;
|
|
66
|
-
ttfb?: number;
|
|
67
|
-
fcp?: number;
|
|
68
|
-
lcp?: number;
|
|
69
|
-
cls?: number;
|
|
70
|
-
inp?: number;
|
|
71
|
-
scroll_depth: number;
|
|
72
|
-
time_on_page: number;
|
|
73
|
-
scroll_events: ScrollEvent[];
|
|
74
|
-
custom_events: AnalyticsCustomEvent[];
|
|
75
|
-
utm_source?: string;
|
|
76
|
-
utm_medium?: string;
|
|
77
|
-
utm_campaign?: string;
|
|
78
|
-
utm_term?: string;
|
|
79
|
-
utm_content?: string;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Payload sent to /_agentuity/webanalytics/collect
|
|
83
|
-
*/
|
|
84
|
-
export interface AnalyticsPayload {
|
|
85
|
-
org_id: string;
|
|
86
|
-
project_id: string;
|
|
87
|
-
thread_id: string;
|
|
88
|
-
visitor_id: string;
|
|
89
|
-
user_id: string;
|
|
90
|
-
user_traits: Record<string, string>;
|
|
91
|
-
is_devmode: boolean;
|
|
92
|
-
pageview: PageViewPayload;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Configuration injected by SDK runtime into window.__AGENTUITY_ANALYTICS__
|
|
96
|
-
*/
|
|
97
|
-
export interface AnalyticsPageConfig {
|
|
98
|
-
enabled: boolean;
|
|
99
|
-
orgId: string;
|
|
100
|
-
projectId: string;
|
|
101
|
-
threadId: string;
|
|
102
|
-
isDevmode: boolean;
|
|
103
|
-
trackClicks?: boolean;
|
|
104
|
-
trackScroll?: boolean;
|
|
105
|
-
trackOutboundLinks?: boolean;
|
|
106
|
-
trackForms?: boolean;
|
|
107
|
-
trackWebVitals?: boolean;
|
|
108
|
-
trackErrors?: boolean;
|
|
109
|
-
trackSPANavigation?: boolean;
|
|
110
|
-
requireConsent?: boolean;
|
|
111
|
-
sampleRate?: number;
|
|
112
|
-
excludePatterns?: string[];
|
|
113
|
-
globalProperties?: Record<string, unknown>;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Public analytics client interface (exposed on window.agentuityAnalytics)
|
|
117
|
-
*/
|
|
118
|
-
export interface AnalyticsClient {
|
|
119
|
-
/**
|
|
120
|
-
* Track a custom event (aggregated and sent on page exit)
|
|
121
|
-
*/
|
|
122
|
-
track(eventName: string, properties?: Record<string, unknown>): void;
|
|
123
|
-
/**
|
|
124
|
-
* Identify the current user
|
|
125
|
-
*/
|
|
126
|
-
identify(userId: string, traits?: Record<string, unknown>): void;
|
|
127
|
-
/**
|
|
128
|
-
* Flush pending page view data immediately
|
|
129
|
-
*/
|
|
130
|
-
flush(): void;
|
|
131
|
-
}
|
|
132
|
-
declare global {
|
|
133
|
-
interface Window {
|
|
134
|
-
__AGENTUITY_ANALYTICS__?: AnalyticsPageConfig;
|
|
135
|
-
__AGENTUITY_SESSION__?: {
|
|
136
|
-
threadId?: string;
|
|
137
|
-
};
|
|
138
|
-
agentuityAnalytics?: AnalyticsClient;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/analytics/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;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AAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAErE;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAEjE;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;CACd;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,MAAM;QACf,uBAAuB,CAAC,EAAE,mBAAmB,CAAC;QAC9C,qBAAqB,CAAC,EAAE;YACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;QACF,kBAAkB,CAAC,EAAE,eAAe,CAAC;KACrC;CACD"}
|
package/dist/analytics/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/analytics/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get or create the visitor ID from localStorage
|
|
3
|
-
*/
|
|
4
|
-
export declare function getVisitorId(): string;
|
|
5
|
-
/**
|
|
6
|
-
* Check if user has opted out
|
|
7
|
-
*/
|
|
8
|
-
export declare function isOptedOut(): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Set opt-out status
|
|
11
|
-
*/
|
|
12
|
-
export declare function setOptOut(optOut: boolean): void;
|
|
13
|
-
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/analytics/utils/storage.ts"],"names":[],"mappings":"AAiBA;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAerC;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAKpC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAa/C"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const VISITOR_ID_KEY = 'agentuity_visitor_id';
|
|
2
|
-
const OPT_OUT_KEY = 'agentuity_analytics_optout';
|
|
3
|
-
/**
|
|
4
|
-
* Generate a random UUID v4
|
|
5
|
-
*/
|
|
6
|
-
function generateUUID() {
|
|
7
|
-
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
|
8
|
-
return crypto.randomUUID();
|
|
9
|
-
}
|
|
10
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
11
|
-
const r = (Math.random() * 16) | 0;
|
|
12
|
-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
13
|
-
return v.toString(16);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Get or create the visitor ID from localStorage
|
|
18
|
-
*/
|
|
19
|
-
export function getVisitorId() {
|
|
20
|
-
if (typeof localStorage === 'undefined') {
|
|
21
|
-
return generateUUID();
|
|
22
|
-
}
|
|
23
|
-
let visitorId = localStorage.getItem(VISITOR_ID_KEY);
|
|
24
|
-
if (!visitorId) {
|
|
25
|
-
visitorId = `vid_${generateUUID()}`;
|
|
26
|
-
try {
|
|
27
|
-
localStorage.setItem(VISITOR_ID_KEY, visitorId);
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
// localStorage might be full or disabled
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return visitorId;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Check if user has opted out
|
|
37
|
-
*/
|
|
38
|
-
export function isOptedOut() {
|
|
39
|
-
if (typeof localStorage === 'undefined') {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
return localStorage.getItem(OPT_OUT_KEY) === 'true';
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Set opt-out status
|
|
46
|
-
*/
|
|
47
|
-
export function setOptOut(optOut) {
|
|
48
|
-
if (typeof localStorage === 'undefined') {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
if (optOut) {
|
|
53
|
-
localStorage.setItem(OPT_OUT_KEY, 'true');
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
localStorage.removeItem(OPT_OUT_KEY);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
// localStorage might be full or disabled
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/analytics/utils/storage.ts"],"names":[],"mappings":"AAAA,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAC9C,MAAM,WAAW,GAAG,4BAA4B,CAAC;AAEjD;;GAEG;AACH,SAAS,YAAY;IACpB,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACxD,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;QACpE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QAC1C,OAAO,CAAC,CAAC,QAAQ,CAAC,E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6
|
-
utm_content?: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Extract UTM parameters from the current URL
|
|
10
|
-
*/
|
|
11
|
-
export declare function getUTMParams(): UTMParams;
|
|
12
|
-
//# sourceMappingURL=utm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utm.d.ts","sourceRoot":"","sources":["../../../src/analytics/utils/utm.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAwBxC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extract UTM parameters from the current URL
|
|
3
|
-
*/
|
|
4
|
-
export function getUTMParams() {
|
|
5
|
-
if (typeof window === 'undefined') {
|
|
6
|
-
return {};
|
|
7
|
-
}
|
|
8
|
-
const params = new URLSearchParams(window.location.search);
|
|
9
|
-
const utm = {};
|
|
10
|
-
const source = params.get('utm_source');
|
|
11
|
-
if (source)
|
|
12
|
-
utm.utm_source = source;
|
|
13
|
-
const medium = params.get('utm_medium');
|
|
14
|
-
if (medium)
|
|
15
|
-
utm.utm_medium = medium;
|
|
16
|
-
const campaign = params.get('utm_campaign');
|
|
17
|
-
if (campaign)
|
|
18
|
-
utm.utm_campaign = campaign;
|
|
19
|
-
const term = params.get('utm_term');
|
|
20
|
-
if (term)
|
|
21
|
-
utm.utm_term = term;
|
|
22
|
-
const content = params.get('utm_content');
|
|
23
|
-
if (content)
|
|
24
|
-
utm.utm_content = content;
|
|
25
|
-
return utm;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=utm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utm.js","sourceRoot":"","sources":["../../../src/analytics/utils/utm.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,UAAU,YAAY;IAC3B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QACnC,OAAO,EAAE,CAAC;IACX,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3D,MAAM,GAAG,GAAc,EAAE,CAAC;IAE1B,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACxC,IAAI,MAAM;QAAE,GAAG,CAAC,UAAU,GAAG,MAAM,CAAC;IAEpC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACxC,IAAI,MAAM;QAAE,GAAG,CAAC,UAAU,GAAG,MAAM,CAAC;IAEpC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC5C,IAAI,QAAQ;QAAE,GAAG,CAAC,YAAY,GAAG,QAAQ,CAAC;IAE1C,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACpC,IAAI,IAAI;QAAE,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC;IAE9B,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC1C,IAAI,OAAO;QAAE,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC;IAEvC,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
package/dist/beacon-script.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is a placeholder for TypeScript compilation.
|
|
3
|
-
* The actual BEACON_SCRIPT value is generated at build time by scripts/build-beacon.ts
|
|
4
|
-
* and written directly to dist/beacon-script.js, overwriting the compiled output.
|
|
5
|
-
*
|
|
6
|
-
* This allows TypeScript to generate proper .d.ts files during compilation,
|
|
7
|
-
* while the actual minified beacon code is injected during the build step.
|
|
8
|
-
*/
|
|
9
|
-
export declare const BEACON_SCRIPT: string;
|
|
10
|
-
/**
|
|
11
|
-
* Validates that the beacon script has been properly injected at build time.
|
|
12
|
-
* Call this early in the runtime to fail fast if the build step was missed.
|
|
13
|
-
* @throws Error if BEACON_SCRIPT is empty (build step not run)
|
|
14
|
-
*/
|
|
15
|
-
export declare function validateBeaconScript(): void;
|
|
16
|
-
//# sourceMappingURL=beacon-script.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"beacon-script.d.ts","sourceRoot":"","sources":["../src/beacon-script.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,aAAa,EAAE,MAAW,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAO3C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"beacon-script.js","sourceRoot":"","sources":["../src/beacon-script.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,aAAa,GAAW,EAAE,CAAC;AAExC;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IACnC,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CACd,wEAAwE;YACvE,2EAA2E,CAC5E,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { EventStreamClient } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Create an EventSource (SSE) client wrapper with event-based API.
|
|
4
|
-
*
|
|
5
|
-
* Note: Native EventSource has limited authentication support.
|
|
6
|
-
* - withCredentials: true will send cookies and HTTP auth headers
|
|
7
|
-
* - For custom Authorization headers, consider using @microsoft/fetch-event-source
|
|
8
|
-
*/
|
|
9
|
-
export declare function createEventStreamClient(url: string, options?: {
|
|
10
|
-
withCredentials?: boolean;
|
|
11
|
-
}): EventStreamClient;
|
|
12
|
-
//# sourceMappingURL=eventstream.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventstream.d.ts","sourceRoot":"","sources":["../../src/client/eventstream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,GACrC,iBAAiB,CAuCnB"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create an EventSource (SSE) client wrapper with event-based API.
|
|
3
|
-
*
|
|
4
|
-
* Note: Native EventSource has limited authentication support.
|
|
5
|
-
* - withCredentials: true will send cookies and HTTP auth headers
|
|
6
|
-
* - For custom Authorization headers, consider using @microsoft/fetch-event-source
|
|
7
|
-
*/
|
|
8
|
-
export function createEventStreamClient(url, options) {
|
|
9
|
-
const eventSource = new EventSource(url, {
|
|
10
|
-
withCredentials: options?.withCredentials ?? false,
|
|
11
|
-
});
|
|
12
|
-
const handlers = {
|
|
13
|
-
message: new Set(),
|
|
14
|
-
open: new Set(),
|
|
15
|
-
error: new Set(),
|
|
16
|
-
};
|
|
17
|
-
// Set up native EventSource event listeners
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
-
eventSource.onmessage = (event) => {
|
|
20
|
-
handlers.message.forEach((handler) => handler(event));
|
|
21
|
-
};
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
-
eventSource.onopen = (event) => {
|
|
24
|
-
handlers.open.forEach((handler) => handler(event));
|
|
25
|
-
};
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
-
eventSource.onerror = (event) => {
|
|
28
|
-
handlers.error.forEach((handler) => handler(event));
|
|
29
|
-
};
|
|
30
|
-
return {
|
|
31
|
-
on: ((event, handler) => {
|
|
32
|
-
handlers[event].add(handler);
|
|
33
|
-
}),
|
|
34
|
-
close() {
|
|
35
|
-
eventSource.close();
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=eventstream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventstream.js","sourceRoot":"","sources":["../../src/client/eventstream.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACtC,GAAW,EACX,OAAuC;IAEvC,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,GAAG,EAAE;QACxC,eAAe,EAAE,OAAO,EAAE,eAAe,IAAI,KAAK;KAClD,CAAC,CAAC;IACH,MAAM,QAAQ,GAIV;QACH,OAAO,EAAE,IAAI,GAAG,EAAE;QAClB,IAAI,EAAE,IAAI,GAAG,EAAE;QACf,KAAK,EAAE,IAAI,GAAG,EAAE;KAChB,CAAC;IAEF,4CAA4C;IAC5C,8DAA8D;IAC9D,WAAW,CAAC,SAAS,GAAG,CAAC,KAAU,EAAE,EAAE;QACtC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC;IAEF,8DAA8D;IAC9D,WAAW,CAAC,MAAM,GAAG,CAAC,KAAU,EAAE,EAAE;QACnC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC;IAEF,8DAA8D;IAC9D,WAAW,CAAC,OAAO,GAAG,CAAC,KAAU,EAAE,EAAE;QACpC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC;IAEF,OAAO;QACN,EAAE,EAAE,CAAC,CAAC,KAAmC,EAAE,OAAqB,EAAE,EAAE;YACnE,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC,CAA4B;QAE7B,KAAK;YACJ,WAAW,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/dist/client/index.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Client, ClientOptions } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Create a type-safe API client from a RouteRegistry.
|
|
4
|
-
*
|
|
5
|
-
* Uses a Proxy to build up the path as you navigate the object,
|
|
6
|
-
* then executes the request when you call a terminal method (.post(), .get(), .websocket(), etc.).
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { createClient } from '@agentuity/frontend';
|
|
11
|
-
* import type { RPCRouteRegistry } from './generated/routes';
|
|
12
|
-
*
|
|
13
|
-
* const client = createClient<RPCRouteRegistry>();
|
|
14
|
-
*
|
|
15
|
-
* // Type-safe API call
|
|
16
|
-
* const result = await client.hello.post({ name: 'World' });
|
|
17
|
-
*
|
|
18
|
-
* // WebSocket
|
|
19
|
-
* const ws = client.chat.websocket();
|
|
20
|
-
* ws.on('message', (msg) => console.log(msg));
|
|
21
|
-
*
|
|
22
|
-
* // Server-Sent Events
|
|
23
|
-
* const es = client.events.eventstream();
|
|
24
|
-
* es.on('message', (event) => console.log(event.data));
|
|
25
|
-
*
|
|
26
|
-
* // Streaming response
|
|
27
|
-
* const stream = await client.data.stream({ query: 'foo' });
|
|
28
|
-
* stream.on('chunk', (chunk) => console.log(chunk));
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export declare function createClient<R>(options?: ClientOptions, metadata?: unknown): Client<R>;
|
|
32
|
-
export type { ClientOptions, Client, RouteEndpoint, WebSocketClient, EventStreamClient, StreamClient, EventHandler, } from './types';
|
|
33
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA4DrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAE,aAAkB,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAoK1F;AAGD,YAAY,EACX,aAAa,EACb,MAAM,EACN,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,YAAY,GACZ,MAAM,SAAS,CAAC"}
|
package/dist/client/index.js
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { createWebSocketClient } from './websocket';
|
|
2
|
-
import { createEventStreamClient } from './eventstream';
|
|
3
|
-
import { createStreamClient } from './stream';
|
|
4
|
-
/**
|
|
5
|
-
* Default base URL (empty = relative URLs).
|
|
6
|
-
*/
|
|
7
|
-
const defaultBaseUrl = '';
|
|
8
|
-
/**
|
|
9
|
-
* Resolve baseUrl - if it's a function, call it; otherwise return the string.
|
|
10
|
-
*/
|
|
11
|
-
function resolveBaseUrl(baseUrl) {
|
|
12
|
-
return typeof baseUrl === 'function' ? baseUrl() : baseUrl;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Resolve headers - if it's a function, call it; otherwise return the object.
|
|
16
|
-
*/
|
|
17
|
-
function resolveHeaders(headers) {
|
|
18
|
-
return typeof headers === 'function' ? headers() : headers;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Escape special regex characters in a string.
|
|
22
|
-
*/
|
|
23
|
-
function escapeRegExp(str) {
|
|
24
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Substitute path parameters in a URL path template.
|
|
28
|
-
* E.g., '/api/users/:id' with { id: '123' } becomes '/api/users/123'
|
|
29
|
-
*/
|
|
30
|
-
function substitutePathParams(pathTemplate, pathParams) {
|
|
31
|
-
if (!pathParams)
|
|
32
|
-
return pathTemplate;
|
|
33
|
-
let result = pathTemplate;
|
|
34
|
-
for (const [key, value] of Object.entries(pathParams)) {
|
|
35
|
-
const escapedKey = escapeRegExp(key);
|
|
36
|
-
result = result.replace(new RegExp(`:${escapedKey}\\??`, 'g'), encodeURIComponent(value));
|
|
37
|
-
result = result.replace(new RegExp(`\\*${escapedKey}`, 'g'), encodeURIComponent(value));
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Build URL with query params.
|
|
43
|
-
*/
|
|
44
|
-
function buildUrlWithQuery(baseUrl, path, query) {
|
|
45
|
-
const url = `${baseUrl}${path}`;
|
|
46
|
-
if (!query || Object.keys(query).length === 0)
|
|
47
|
-
return url;
|
|
48
|
-
const params = new URLSearchParams(query);
|
|
49
|
-
return `${url}?${params.toString()}`;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Create a type-safe API client from a RouteRegistry.
|
|
53
|
-
*
|
|
54
|
-
* Uses a Proxy to build up the path as you navigate the object,
|
|
55
|
-
* then executes the request when you call a terminal method (.post(), .get(), .websocket(), etc.).
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```typescript
|
|
59
|
-
* import { createClient } from '@agentuity/frontend';
|
|
60
|
-
* import type { RPCRouteRegistry } from './generated/routes';
|
|
61
|
-
*
|
|
62
|
-
* const client = createClient<RPCRouteRegistry>();
|
|
63
|
-
*
|
|
64
|
-
* // Type-safe API call
|
|
65
|
-
* const result = await client.hello.post({ name: 'World' });
|
|
66
|
-
*
|
|
67
|
-
* // WebSocket
|
|
68
|
-
* const ws = client.chat.websocket();
|
|
69
|
-
* ws.on('message', (msg) => console.log(msg));
|
|
70
|
-
*
|
|
71
|
-
* // Server-Sent Events
|
|
72
|
-
* const es = client.events.eventstream();
|
|
73
|
-
* es.on('message', (event) => console.log(event.data));
|
|
74
|
-
*
|
|
75
|
-
* // Streaming response
|
|
76
|
-
* const stream = await client.data.stream({ query: 'foo' });
|
|
77
|
-
* stream.on('chunk', (chunk) => console.log(chunk));
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
export function createClient(options = {}, metadata) {
|
|
81
|
-
const { baseUrl = defaultBaseUrl, headers, contentType = 'application/json', signal } = options;
|
|
82
|
-
// Default headers to empty object if not provided
|
|
83
|
-
const defaultHeaders = headers || {};
|
|
84
|
-
const handler = {
|
|
85
|
-
get(target, prop) {
|
|
86
|
-
const currentPath = target.__path;
|
|
87
|
-
const newPath = [...currentPath, prop];
|
|
88
|
-
// Check if this is a terminal method
|
|
89
|
-
const httpMethods = ['get', 'post', 'put', 'delete', 'patch', 'head', 'options'];
|
|
90
|
-
const streamMethods = ['websocket', 'eventstream', 'stream'];
|
|
91
|
-
const isHttpMethod = httpMethods.includes(prop);
|
|
92
|
-
const isStreamMethod = streamMethods.includes(prop);
|
|
93
|
-
const isTerminalMethod = isHttpMethod || isStreamMethod;
|
|
94
|
-
// Terminal: method at the end (minimum 1 path segment required)
|
|
95
|
-
// Examples: client.hello.post(), client.echo.websocket(), client.events.eventstream()
|
|
96
|
-
if (isTerminalMethod && currentPath.length >= 1) {
|
|
97
|
-
const method = prop;
|
|
98
|
-
const pathSegments = currentPath;
|
|
99
|
-
// Look up route metadata
|
|
100
|
-
let routeType = 'api';
|
|
101
|
-
let routePath;
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
-
let metaNode = metadata;
|
|
104
|
-
if (isStreamMethod) {
|
|
105
|
-
// Stream methods directly specify the route type
|
|
106
|
-
if (method === 'websocket')
|
|
107
|
-
routeType = 'websocket';
|
|
108
|
-
else if (method === 'eventstream')
|
|
109
|
-
routeType = 'sse';
|
|
110
|
-
else if (method === 'stream')
|
|
111
|
-
routeType = 'stream';
|
|
112
|
-
}
|
|
113
|
-
if (metadata) {
|
|
114
|
-
for (const segment of pathSegments) {
|
|
115
|
-
if (metaNode && typeof metaNode === 'object') {
|
|
116
|
-
metaNode = metaNode[segment];
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (metaNode && typeof metaNode === 'object' && metaNode[method]) {
|
|
120
|
-
if (metaNode[method].type) {
|
|
121
|
-
routeType = metaNode[method].type;
|
|
122
|
-
}
|
|
123
|
-
if (metaNode[method].path) {
|
|
124
|
-
routePath = metaNode[method].path;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
// Fallback URL path if no metadata
|
|
129
|
-
const fallbackPath = '/api/' + pathSegments.join('/');
|
|
130
|
-
return (...args) => {
|
|
131
|
-
const resolvedBaseUrl = resolveBaseUrl(baseUrl);
|
|
132
|
-
const resolvedHeaders = resolveHeaders(defaultHeaders);
|
|
133
|
-
// Get path param names from metadata if available
|
|
134
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
|
-
const pathParamNames = metaNode?.[method]?.pathParams;
|
|
136
|
-
const hasPathParams = pathParamNames && pathParamNames.length > 0;
|
|
137
|
-
let pathParams;
|
|
138
|
-
let input;
|
|
139
|
-
let query;
|
|
140
|
-
if (hasPathParams) {
|
|
141
|
-
// Route has path params - positional arguments API
|
|
142
|
-
// Args are: param1, param2, ..., [options?]
|
|
143
|
-
// Example: client.user.get('123', 12) or client.user.get('123', 12, { query: {...} })
|
|
144
|
-
pathParams = {};
|
|
145
|
-
for (let i = 0; i < pathParamNames.length; i++) {
|
|
146
|
-
const arg = args[i];
|
|
147
|
-
if (arg === undefined || arg === null) {
|
|
148
|
-
throw new Error(`Missing required path parameter '${pathParamNames[i]}' at position ${i + 1}. ` +
|
|
149
|
-
`Expected ${pathParamNames.length} path parameter(s): ${pathParamNames.join(', ')}`);
|
|
150
|
-
}
|
|
151
|
-
pathParams[pathParamNames[i]] = String(arg);
|
|
152
|
-
}
|
|
153
|
-
// Check if there's an options object after the path params
|
|
154
|
-
const optionsArg = args[pathParamNames.length];
|
|
155
|
-
if (optionsArg && typeof optionsArg === 'object') {
|
|
156
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
|
-
const opts = optionsArg;
|
|
158
|
-
input = opts.input;
|
|
159
|
-
query = opts.query;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
// No path params - use existing behavior
|
|
164
|
-
const options = args[0];
|
|
165
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
166
|
-
const opts = options;
|
|
167
|
-
const isOptionsObject = opts && typeof opts === 'object' && ('input' in opts || 'query' in opts);
|
|
168
|
-
input = isOptionsObject ? opts.input : options;
|
|
169
|
-
query = isOptionsObject ? opts.query : undefined;
|
|
170
|
-
}
|
|
171
|
-
// Substitute path params in the route path
|
|
172
|
-
const basePath = routePath || fallbackPath;
|
|
173
|
-
const urlPath = substitutePathParams(basePath, pathParams);
|
|
174
|
-
// WebSocket endpoint
|
|
175
|
-
if (routeType === 'websocket') {
|
|
176
|
-
const wsBaseUrl = resolvedBaseUrl.replace(/^http/, 'ws');
|
|
177
|
-
const wsUrl = buildUrlWithQuery(wsBaseUrl, urlPath, query);
|
|
178
|
-
const ws = createWebSocketClient(wsUrl);
|
|
179
|
-
if (input) {
|
|
180
|
-
ws.on('open', () => ws.send(input));
|
|
181
|
-
}
|
|
182
|
-
return ws;
|
|
183
|
-
}
|
|
184
|
-
// SSE endpoint
|
|
185
|
-
if (routeType === 'sse') {
|
|
186
|
-
const sseUrl = buildUrlWithQuery(resolvedBaseUrl, urlPath, query);
|
|
187
|
-
return createEventStreamClient(sseUrl, {
|
|
188
|
-
withCredentials: Object.keys(resolvedHeaders).length > 0,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
// Stream endpoint
|
|
192
|
-
if (routeType === 'stream') {
|
|
193
|
-
const streamUrl = buildUrlWithQuery(resolvedBaseUrl, urlPath, query);
|
|
194
|
-
return fetch(streamUrl, {
|
|
195
|
-
method: method.toUpperCase(),
|
|
196
|
-
headers: { 'Content-Type': contentType, ...resolvedHeaders },
|
|
197
|
-
body: input ? JSON.stringify(input) : undefined,
|
|
198
|
-
signal,
|
|
199
|
-
}).then((res) => {
|
|
200
|
-
if (!res.ok)
|
|
201
|
-
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
202
|
-
return createStreamClient(res);
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
// Regular API endpoint
|
|
206
|
-
const apiUrl = buildUrlWithQuery(resolvedBaseUrl, urlPath, query);
|
|
207
|
-
return fetch(apiUrl, {
|
|
208
|
-
method: method.toUpperCase(),
|
|
209
|
-
headers: { 'Content-Type': contentType, ...resolvedHeaders },
|
|
210
|
-
body: method.toUpperCase() !== 'GET' && input ? JSON.stringify(input) : undefined,
|
|
211
|
-
signal,
|
|
212
|
-
}).then(async (res) => {
|
|
213
|
-
if (!res.ok)
|
|
214
|
-
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
215
|
-
if (res.status === 204)
|
|
216
|
-
return undefined;
|
|
217
|
-
return res.json();
|
|
218
|
-
});
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
// Otherwise, return a new proxy with extended path
|
|
222
|
-
return new Proxy({ __path: newPath }, handler);
|
|
223
|
-
},
|
|
224
|
-
};
|
|
225
|
-
return new Proxy({ __path: [] }, handler);
|
|
226
|
-
}
|
|
227
|
-
//# sourceMappingURL=index.js.map
|
package/dist/client/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB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