@pagelines/sdk 1.0.207 → 1.0.209
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/{AgentProvider.vue_vue_type_script_setup_true_lang-3Bb9TMh9.js → AgentProvider.vue_vue_type_script_setup_true_lang-GgGjo40K.js} +2 -2
- package/dist/{AgentProvider.vue_vue_type_script_setup_true_lang-3Bb9TMh9.js.map → AgentProvider.vue_vue_type_script_setup_true_lang-GgGjo40K.js.map} +1 -1
- package/dist/{AgentWidgetInline-S_dLDyR4.js → AgentWidgetInline-BXeTufF0.js} +2 -2
- package/dist/{AgentWidgetInline-S_dLDyR4.js.map → AgentWidgetInline-BXeTufF0.js.map} +1 -1
- package/dist/{AgentWidgetModal-B-SpFsc0.js → AgentWidgetModal-DP7iwx2o.js} +2 -2
- package/dist/{AgentWidgetModal-B-SpFsc0.js.map → AgentWidgetModal-DP7iwx2o.js.map} +1 -1
- package/dist/{AgentWidgetPopup-DL5gm6Oe.js → AgentWidgetPopup-C5ZgN09k.js} +2 -2
- package/dist/{AgentWidgetPopup-DL5gm6Oe.js.map → AgentWidgetPopup-C5ZgN09k.js.map} +1 -1
- package/dist/{AgentWrap.vue_vue_type_script_setup_true_lang-TroCRBgC.js → AgentWrap.vue_vue_type_script_setup_true_lang-Bv2KuZP0.js} +615 -605
- package/dist/AgentWrap.vue_vue_type_script_setup_true_lang-Bv2KuZP0.js.map +1 -0
- package/dist/agent/schema.d.ts +1 -0
- package/dist/agent.js +3 -3
- package/dist/clients/ChatClient.d.ts +1 -0
- package/dist/clients/types.d.ts +2 -2
- package/dist/sdk.js +1 -1
- package/dist/{sdkClient-90qax7Jh.js → sdkClient-B3EKDRYb.js} +365 -190
- package/dist/sdkClient-B3EKDRYb.js.map +1 -0
- package/dist/sdkClient.d.ts +1 -1
- package/dist/widget.js +4 -4
- package/package.json +2 -2
- package/dist/AgentWrap.vue_vue_type_script_setup_true_lang-TroCRBgC.js.map +0 -1
- package/dist/sdkClient-90qax7Jh.js.map +0 -1
|
@@ -1,61 +1,63 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
import { watch as
|
|
6
|
-
import { APP_PORT as
|
|
7
|
-
import { hc as
|
|
8
|
-
function
|
|
9
|
-
const { prefix: e = "id_" } =
|
|
1
|
+
var ie = Object.defineProperty;
|
|
2
|
+
var he = (d, e, t) => e in d ? ie(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t;
|
|
3
|
+
var s = (d, e) => ie(d, "name", { value: e, configurable: !0 });
|
|
4
|
+
var a = (d, e, t) => he(d, typeof e != "symbol" ? e + "" : e, t);
|
|
5
|
+
import { watch as ne, ref as T, computed as se } from "vue";
|
|
6
|
+
import { APP_PORT as M, APP_PROD_URL as R } from "@pagelines/types";
|
|
7
|
+
import { hc as de } from "hono/client";
|
|
8
|
+
function ae(d = {}) {
|
|
9
|
+
const { prefix: e = "id_" } = d, t = e.length >= 3 ? e.substring(0, 3) : e.padEnd(3, "_"), o = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0");
|
|
10
10
|
let r = "";
|
|
11
11
|
for (let i = 0; i < 16; i++)
|
|
12
12
|
r += Math.floor(Math.random() * 16).toString(16);
|
|
13
13
|
return t + o + r;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
const
|
|
15
|
+
s(ae, "objectId$1");
|
|
16
|
+
const $ = globalThis.process, y = typeof window < "u", G = typeof $ < "u" && !y, E = y ? typeof window < "u" && window.location && !window.location.hostname.includes("localhost") : G && typeof $ < "u" && $.env?.NODE_ENV === "production", ge = !E, D = {
|
|
17
17
|
error: { priority: 50, color: "#FF0000", nodeColor: "\x1B[31m" },
|
|
18
18
|
warn: { priority: 40, color: "#FFA500", nodeColor: "\x1B[33m" },
|
|
19
19
|
info: { priority: 30, color: "#00ABFF", nodeColor: "\x1B[36m" },
|
|
20
20
|
debug: { priority: 20, color: "#00BD0C", nodeColor: "\x1B[32m" },
|
|
21
21
|
trace: { priority: 10, color: "#5233FF", nodeColor: "\x1B[35m" }
|
|
22
|
-
},
|
|
22
|
+
}, fe = ["password", "token", "secret", "apikey", "api_key", "authorization", "cookie"];
|
|
23
|
+
var m;
|
|
24
|
+
let ce = (m = class {
|
|
23
25
|
constructor(e = {}, t) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
a(this, "settings");
|
|
27
|
+
a(this, "enabledInBrowser", !1);
|
|
28
|
+
a(this, "context");
|
|
27
29
|
this.context = t, this.settings = {
|
|
28
30
|
enabled: e.enabled ?? !0,
|
|
29
31
|
minLevel: e.minLevel ?? this.getDefaultLevel(),
|
|
30
32
|
timestamps: e.timestamps ?? !0
|
|
31
|
-
},
|
|
33
|
+
}, y && this.initBrowserLogging();
|
|
32
34
|
}
|
|
33
35
|
getDefaultLevel() {
|
|
34
|
-
if (
|
|
35
|
-
return
|
|
36
|
-
if (
|
|
36
|
+
if (G && typeof $ < "u" && $.env?.LOG_LEVEL)
|
|
37
|
+
return $.env.LOG_LEVEL;
|
|
38
|
+
if (y && typeof localStorage < "u" && typeof localStorage.getItem == "function") {
|
|
37
39
|
const e = localStorage.getItem("PAGELINES_LOG_LEVEL");
|
|
38
40
|
if (e)
|
|
39
41
|
return e;
|
|
40
42
|
}
|
|
41
|
-
return
|
|
43
|
+
return "info";
|
|
42
44
|
}
|
|
43
45
|
initBrowserLogging() {
|
|
44
|
-
if (!
|
|
46
|
+
if (!y)
|
|
45
47
|
return;
|
|
46
48
|
const t = typeof localStorage?.getItem == "function" && localStorage.getItem("PAGELINES_LOG") === "true", o = window.location?.hostname || "";
|
|
47
|
-
this.enabledInBrowser =
|
|
49
|
+
this.enabledInBrowser = ge || t || o === "localhost" || o.includes("127.0.0.1"), E && !t && !m.hasShownHelp && (console.log(
|
|
48
50
|
"%cPageLines Logger (disabled in production)",
|
|
49
51
|
"color: #888; font-size: 12px"
|
|
50
52
|
), console.log(
|
|
51
53
|
'%cTo enable: localStorage.setItem("PAGELINES_LOG", "true")',
|
|
52
54
|
"color: #888; font-size: 11px"
|
|
53
|
-
),
|
|
55
|
+
), m.hasShownHelp = !0);
|
|
54
56
|
}
|
|
55
57
|
shouldLog(e) {
|
|
56
|
-
if (!this.settings.enabled ||
|
|
58
|
+
if (!this.settings.enabled || y && !this.enabledInBrowser)
|
|
57
59
|
return !1;
|
|
58
|
-
const t =
|
|
60
|
+
const t = D[e].priority, o = D[this.settings.minLevel].priority;
|
|
59
61
|
return t >= o;
|
|
60
62
|
}
|
|
61
63
|
formatTimestamp() {
|
|
@@ -77,7 +79,7 @@ const I = globalThis.process, m = typeof window < "u", B = typeof I < "u" && !m,
|
|
|
77
79
|
const t = {};
|
|
78
80
|
for (const [o, r] of Object.entries(e)) {
|
|
79
81
|
const i = o.toLowerCase();
|
|
80
|
-
|
|
82
|
+
fe.some((n) => i.includes(n)) ? t[o] = "[REDACTED]" : typeof r == "object" && r !== null ? t[o] = this.redactSensitive(r) : t[o] = r;
|
|
81
83
|
}
|
|
82
84
|
return t;
|
|
83
85
|
}
|
|
@@ -90,7 +92,7 @@ const I = globalThis.process, m = typeof window < "u", B = typeof I < "u" && !m,
|
|
|
90
92
|
return {
|
|
91
93
|
name: e.name,
|
|
92
94
|
message: e.message,
|
|
93
|
-
stack:
|
|
95
|
+
stack: E ? e.stack?.split(`
|
|
94
96
|
`).slice(0, 3).join(`
|
|
95
97
|
`) : e.stack,
|
|
96
98
|
...e
|
|
@@ -101,39 +103,39 @@ const I = globalThis.process, m = typeof window < "u", B = typeof I < "u" && !m,
|
|
|
101
103
|
if (typeof e != "object")
|
|
102
104
|
return e;
|
|
103
105
|
if (Array.isArray(e))
|
|
104
|
-
return e.length > 20 &&
|
|
106
|
+
return e.length > 20 && E ? `Array(${e.length}) [${e.slice(0, 3).map((r) => this.formatData(r, t, o + 1)).join(", ")}, ...]` : e.map((r) => this.formatData(r, t, o + 1));
|
|
105
107
|
try {
|
|
106
|
-
const r = {}, i = Object.entries(e),
|
|
107
|
-
for (const [
|
|
108
|
-
r[
|
|
109
|
-
return i.length >
|
|
108
|
+
const r = {}, i = Object.entries(e), n = E ? 50 : 200;
|
|
109
|
+
for (const [u, c] of i.slice(0, n))
|
|
110
|
+
r[u] = this.formatData(c, t, o + 1);
|
|
111
|
+
return i.length > n && (r["..."] = `${i.length - n} more properties`), this.redactSensitive(r);
|
|
110
112
|
} catch {
|
|
111
113
|
return "[Unserializable]";
|
|
112
114
|
}
|
|
113
115
|
}
|
|
114
116
|
logToBrowser(e) {
|
|
115
|
-
if (!
|
|
117
|
+
if (!y || !this.shouldLog(e.level))
|
|
116
118
|
return;
|
|
117
|
-
const { level: t, description: o, context: r, data: i, error:
|
|
118
|
-
i !== void 0 ? console[t](`%c${
|
|
119
|
+
const { level: t, description: o, context: r, data: i, error: n } = e, u = D[t], l = `[${r || this.context || "www"}] ${t.toUpperCase()}:`, h = `color: ${u.color}; font-weight: bold;`;
|
|
120
|
+
i !== void 0 ? console[t](`%c${l}`, h, o, this.formatData(i)) : console[t](`%c${l}`, h, o), n && (n instanceof Error ? console.error(n) : console.error("Error details:", n));
|
|
119
121
|
}
|
|
120
122
|
logToNode(e) {
|
|
121
|
-
if (!
|
|
123
|
+
if (!G || !this.shouldLog(e.level))
|
|
122
124
|
return;
|
|
123
|
-
const { level: t, description: o, context: r, data: i, error:
|
|
124
|
-
if (
|
|
125
|
-
const
|
|
125
|
+
const { level: t, description: o, context: r, data: i, error: n } = e, u = r || this.context || "www";
|
|
126
|
+
if (E) {
|
|
127
|
+
const c = {
|
|
126
128
|
timestamp: this.formatISOTimestamp(),
|
|
127
129
|
level: t.toUpperCase()
|
|
128
130
|
};
|
|
129
|
-
i && (
|
|
131
|
+
i && (c.data = this.formatData(i)), n && (c.error = this.formatData(n)), console[t](`${c.timestamp} ${c.level} [${u}] ${o}`, i || n ? JSON.stringify({ data: i, error: n }) : "");
|
|
130
132
|
} else {
|
|
131
|
-
const
|
|
132
|
-
console[t](k), i !== void 0 && console.log(JSON.stringify(this.formatData(i), null, 2)),
|
|
133
|
+
const c = D[t], l = this.formatTimestamp(), h = "\x1B[0m", S = "\x1B[2m", g = c.nodeColor || "", k = `${S}${l}${h} ${g}${t.toUpperCase()} (${u}):${h} ${o}`;
|
|
134
|
+
console[t](k), i !== void 0 && console.log(JSON.stringify(this.formatData(i), null, 2)), n && (n instanceof Error ? (console.error(`\x1B[31mError:${h}`, n.message), n.stack && console.error(`\x1B[90m${n.stack}${h}`)) : console.error("Error:", n));
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
137
|
log(e) {
|
|
136
|
-
|
|
138
|
+
y ? this.logToBrowser(e) : G && this.logToNode(e);
|
|
137
139
|
}
|
|
138
140
|
error(e, t) {
|
|
139
141
|
this.log({ level: "error", description: e, data: t, context: this.context });
|
|
@@ -151,55 +153,53 @@ const I = globalThis.process, m = typeof window < "u", B = typeof I < "u" && !m,
|
|
|
151
153
|
this.log({ level: "trace", description: e, data: t, context: this.context });
|
|
152
154
|
}
|
|
153
155
|
isEnabled() {
|
|
154
|
-
return
|
|
156
|
+
return y ? this.enabledInBrowser : !0;
|
|
155
157
|
}
|
|
156
158
|
setLevel(e) {
|
|
157
159
|
this.settings.minLevel = e;
|
|
158
160
|
}
|
|
159
161
|
createContextLogger(e) {
|
|
160
|
-
const t = new
|
|
162
|
+
const t = new m(this.settings, e);
|
|
161
163
|
return {
|
|
162
|
-
error: /* @__PURE__ */
|
|
163
|
-
warn: /* @__PURE__ */
|
|
164
|
-
info: /* @__PURE__ */
|
|
165
|
-
debug: /* @__PURE__ */
|
|
166
|
-
trace: /* @__PURE__ */
|
|
167
|
-
isEnabled: /* @__PURE__ */
|
|
168
|
-
setLevel: /* @__PURE__ */
|
|
164
|
+
error: /* @__PURE__ */ s((o, r) => t.error(o, r), "error"),
|
|
165
|
+
warn: /* @__PURE__ */ s((o, r) => t.warn(o, r), "warn"),
|
|
166
|
+
info: /* @__PURE__ */ s((o, r) => t.info(o, r), "info"),
|
|
167
|
+
debug: /* @__PURE__ */ s((o, r) => t.debug(o, r), "debug"),
|
|
168
|
+
trace: /* @__PURE__ */ s((o, r) => t.trace(o, r), "trace"),
|
|
169
|
+
isEnabled: /* @__PURE__ */ s(() => t.isEnabled(), "isEnabled"),
|
|
170
|
+
setLevel: /* @__PURE__ */ s((o) => t.setLevel(o), "setLevel")
|
|
169
171
|
};
|
|
170
172
|
}
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
function oe(h) {
|
|
175
|
-
return new F({}, h);
|
|
173
|
+
}, s(m, "Logger"), a(m, "hasShownHelp", !1), m);
|
|
174
|
+
function pe(d) {
|
|
175
|
+
return new ce({}, d);
|
|
176
176
|
}
|
|
177
|
-
|
|
178
|
-
const v = new
|
|
177
|
+
s(pe, "createLogger$1");
|
|
178
|
+
const v = new ce();
|
|
179
179
|
v.error.bind(v);
|
|
180
180
|
v.warn.bind(v);
|
|
181
181
|
v.info.bind(v);
|
|
182
182
|
v.debug.bind(v);
|
|
183
183
|
v.trace.bind(v);
|
|
184
|
-
const
|
|
184
|
+
const Y = class Y {
|
|
185
185
|
constructor(e, t) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
this.name = e, this.settings = t, this.logger =
|
|
186
|
+
a(this, "name");
|
|
187
|
+
a(this, "settings");
|
|
188
|
+
a(this, "logger");
|
|
189
|
+
this.name = e, this.settings = t, this.logger = pe(e);
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
|
-
|
|
193
|
-
let
|
|
194
|
-
const
|
|
192
|
+
s(Y, "SettingsObject");
|
|
193
|
+
let V = Y;
|
|
194
|
+
const X = class X {
|
|
195
195
|
constructor() {
|
|
196
196
|
// Configuration properties
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
a(this, "tokenName", "auth-token");
|
|
198
|
+
a(this, "tokenMaxAge", 3600 * 24 * 7);
|
|
199
199
|
// 7 days
|
|
200
|
-
|
|
200
|
+
a(this, "fallbackStorageKey", "token");
|
|
201
201
|
// For localStorage migration
|
|
202
|
-
|
|
202
|
+
a(this, "productionDomain", ".pagelines.com");
|
|
203
203
|
}
|
|
204
204
|
/**
|
|
205
205
|
* Get cookie value by name
|
|
@@ -224,13 +224,13 @@ const z = class z {
|
|
|
224
224
|
const {
|
|
225
225
|
secure: r = !0,
|
|
226
226
|
sameSite: i = "lax",
|
|
227
|
-
maxAge:
|
|
227
|
+
maxAge: n = 3600 * 24 * 7,
|
|
228
228
|
// 7 days default
|
|
229
|
-
domain:
|
|
230
|
-
path:
|
|
229
|
+
domain: u,
|
|
230
|
+
path: c = "/"
|
|
231
231
|
} = o;
|
|
232
|
-
let
|
|
233
|
-
|
|
232
|
+
let l = `${e}=${encodeURIComponent(t)}`;
|
|
233
|
+
l += `; Path=${c}`, l += `; Max-Age=${n}`, l += `; SameSite=${i}`, r && (l += "; Secure"), u && (l += `; Domain=${u}`), document.cookie = l;
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
* Remove cookie by setting expired date
|
|
@@ -282,38 +282,38 @@ const z = class z {
|
|
|
282
282
|
}), this.isLocalStorageFunctional() && window.localStorage.removeItem(this.fallbackStorageKey);
|
|
283
283
|
}
|
|
284
284
|
};
|
|
285
|
-
|
|
286
|
-
let
|
|
287
|
-
const
|
|
288
|
-
function
|
|
289
|
-
const t =
|
|
290
|
-
return
|
|
291
|
-
fetch: /* @__PURE__ */
|
|
292
|
-
const
|
|
285
|
+
s(X, "CookieUtil");
|
|
286
|
+
let z = X;
|
|
287
|
+
const C = new z();
|
|
288
|
+
function me(d, e) {
|
|
289
|
+
const t = d.apiBase || (d.isDev ? `http://localhost:${M}` : R);
|
|
290
|
+
return de(t, {
|
|
291
|
+
fetch: /* @__PURE__ */ s(async (r, i) => {
|
|
292
|
+
const n = C.getAuthToken(), u = await fetch(r, {
|
|
293
293
|
...i,
|
|
294
294
|
headers: {
|
|
295
295
|
...i?.headers,
|
|
296
296
|
"Content-Type": "application/json",
|
|
297
297
|
// Only include Authorization header if token exists
|
|
298
|
-
...
|
|
298
|
+
...n && { Authorization: `Bearer ${n}` }
|
|
299
299
|
},
|
|
300
300
|
// Use 'omit' for Bearer tokens (not cookies) to allow CORS wildcard origin
|
|
301
301
|
credentials: "omit"
|
|
302
302
|
});
|
|
303
303
|
if (e) {
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
return typeof
|
|
304
|
+
const c = u.json.bind(u);
|
|
305
|
+
u.json = async () => {
|
|
306
|
+
const l = await c();
|
|
307
|
+
return typeof l == "object" && l !== null && "ok" in l && ("user" in l || "token" in l) && e(l), l;
|
|
308
308
|
};
|
|
309
309
|
}
|
|
310
|
-
return
|
|
310
|
+
return u;
|
|
311
311
|
}, "fetch")
|
|
312
312
|
});
|
|
313
313
|
}
|
|
314
|
-
|
|
315
|
-
let
|
|
316
|
-
const
|
|
314
|
+
s(me, "createApiClient");
|
|
315
|
+
let ve = /* @__PURE__ */ Symbol("clean"), p = [], I = 0;
|
|
316
|
+
const U = 4, ue = /* @__PURE__ */ s(/* @__NO_SIDE_EFFECTS__ */ (d) => {
|
|
317
317
|
let e = [], t = {
|
|
318
318
|
get() {
|
|
319
319
|
return t.lc || t.listen(() => {
|
|
@@ -322,22 +322,22 @@ const $ = 4, re = /* @__PURE__ */ l(/* @__NO_SIDE_EFFECTS__ */ (h) => {
|
|
|
322
322
|
lc: 0,
|
|
323
323
|
listen(o) {
|
|
324
324
|
return t.lc = e.push(o), () => {
|
|
325
|
-
for (let i =
|
|
326
|
-
p[i] === o ? p.splice(i,
|
|
325
|
+
for (let i = I + U; i < p.length; )
|
|
326
|
+
p[i] === o ? p.splice(i, U) : i += U;
|
|
327
327
|
let r = e.indexOf(o);
|
|
328
328
|
~r && (e.splice(r, 1), --t.lc || t.off());
|
|
329
329
|
};
|
|
330
330
|
},
|
|
331
331
|
notify(o, r) {
|
|
332
332
|
let i = !p.length;
|
|
333
|
-
for (let
|
|
334
|
-
p.push(
|
|
333
|
+
for (let n of e)
|
|
334
|
+
p.push(n, t.value, o, r);
|
|
335
335
|
if (i) {
|
|
336
|
-
for (
|
|
337
|
-
p[
|
|
338
|
-
p[
|
|
339
|
-
p[
|
|
340
|
-
p[
|
|
336
|
+
for (I = 0; I < p.length; I += U)
|
|
337
|
+
p[I](
|
|
338
|
+
p[I + 1],
|
|
339
|
+
p[I + 2],
|
|
340
|
+
p[I + 3]
|
|
341
341
|
);
|
|
342
342
|
p.length = 0;
|
|
343
343
|
}
|
|
@@ -354,14 +354,182 @@ const $ = 4, re = /* @__PURE__ */ l(/* @__NO_SIDE_EFFECTS__ */ (h) => {
|
|
|
354
354
|
let r = t.listen(o);
|
|
355
355
|
return o(t.value), r;
|
|
356
356
|
},
|
|
357
|
-
value:
|
|
357
|
+
value: d
|
|
358
358
|
};
|
|
359
|
-
return process.env.NODE_ENV !== "production" && (t[
|
|
359
|
+
return process.env.NODE_ENV !== "production" && (t[ve] = () => {
|
|
360
360
|
e = [], t.lc = 0, t.off();
|
|
361
361
|
}), t;
|
|
362
|
-
}, "atom"),
|
|
362
|
+
}, "atom"), A = globalThis.process, x = typeof window < "u", j = typeof A < "u" && !x, b = x ? typeof window < "u" && window.location && !window.location.hostname.includes("localhost") : j && typeof A < "u" && A.env?.NODE_ENV === "production", we = !b, P = {
|
|
363
|
+
error: { priority: 50, color: "#FF0000", nodeColor: "\x1B[31m" },
|
|
364
|
+
warn: { priority: 40, color: "#FFA500", nodeColor: "\x1B[33m" },
|
|
365
|
+
info: { priority: 30, color: "#00ABFF", nodeColor: "\x1B[36m" },
|
|
366
|
+
debug: { priority: 20, color: "#00BD0C", nodeColor: "\x1B[32m" },
|
|
367
|
+
trace: { priority: 10, color: "#5233FF", nodeColor: "\x1B[35m" }
|
|
368
|
+
}, ye = ["password", "token", "secret", "apikey", "api_key", "authorization", "cookie"], L = class L {
|
|
369
|
+
constructor(e = {}, t) {
|
|
370
|
+
a(this, "settings");
|
|
371
|
+
a(this, "enabledInBrowser", !1);
|
|
372
|
+
a(this, "context");
|
|
373
|
+
this.context = t, this.settings = {
|
|
374
|
+
enabled: e.enabled ?? !0,
|
|
375
|
+
minLevel: e.minLevel ?? this.getDefaultLevel(),
|
|
376
|
+
timestamps: e.timestamps ?? !0
|
|
377
|
+
}, x && this.initBrowserLogging();
|
|
378
|
+
}
|
|
379
|
+
getDefaultLevel() {
|
|
380
|
+
if (j && typeof A < "u" && A.env?.LOG_LEVEL)
|
|
381
|
+
return A.env.LOG_LEVEL;
|
|
382
|
+
if (x && typeof localStorage < "u" && typeof localStorage.getItem == "function") {
|
|
383
|
+
const e = localStorage.getItem("PAGELINES_LOG_LEVEL");
|
|
384
|
+
if (e)
|
|
385
|
+
return e;
|
|
386
|
+
}
|
|
387
|
+
return b ? "info" : "debug";
|
|
388
|
+
}
|
|
389
|
+
initBrowserLogging() {
|
|
390
|
+
if (!x)
|
|
391
|
+
return;
|
|
392
|
+
const t = typeof localStorage?.getItem == "function" && localStorage.getItem("PAGELINES_LOG") === "true", o = window.location?.hostname || "";
|
|
393
|
+
this.enabledInBrowser = we || t || o === "localhost" || o.includes("127.0.0.1"), b && !t && !L.hasShownHelp && (console.log(
|
|
394
|
+
"%cPageLines Logger (disabled in production)",
|
|
395
|
+
"color: #888; font-size: 12px"
|
|
396
|
+
), console.log(
|
|
397
|
+
'%cTo enable: localStorage.setItem("PAGELINES_LOG", "true")',
|
|
398
|
+
"color: #888; font-size: 11px"
|
|
399
|
+
), L.hasShownHelp = !0);
|
|
400
|
+
}
|
|
401
|
+
shouldLog(e) {
|
|
402
|
+
if (!this.settings.enabled || x && !this.enabledInBrowser)
|
|
403
|
+
return !1;
|
|
404
|
+
const t = P[e].priority, o = P[this.settings.minLevel].priority;
|
|
405
|
+
return t >= o;
|
|
406
|
+
}
|
|
407
|
+
formatTimestamp() {
|
|
408
|
+
return (/* @__PURE__ */ new Date()).toLocaleTimeString("en-GB", {
|
|
409
|
+
hour12: !1,
|
|
410
|
+
hour: "2-digit",
|
|
411
|
+
minute: "2-digit",
|
|
412
|
+
second: "2-digit"
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
formatISOTimestamp() {
|
|
416
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
417
|
+
}
|
|
418
|
+
redactSensitive(e) {
|
|
419
|
+
if (typeof e != "object" || e === null)
|
|
420
|
+
return e;
|
|
421
|
+
if (Array.isArray(e))
|
|
422
|
+
return e.map((o) => this.redactSensitive(o));
|
|
423
|
+
const t = {};
|
|
424
|
+
for (const [o, r] of Object.entries(e)) {
|
|
425
|
+
const i = o.toLowerCase();
|
|
426
|
+
ye.some((n) => i.includes(n)) ? t[o] = "[REDACTED]" : typeof r == "object" && r !== null ? t[o] = this.redactSensitive(r) : t[o] = r;
|
|
427
|
+
}
|
|
428
|
+
return t;
|
|
429
|
+
}
|
|
430
|
+
formatData(e, t = 3, o = 0) {
|
|
431
|
+
if (o >= t)
|
|
432
|
+
return "[Max Depth]";
|
|
433
|
+
if (e == null)
|
|
434
|
+
return e;
|
|
435
|
+
if (e instanceof Error)
|
|
436
|
+
return {
|
|
437
|
+
name: e.name,
|
|
438
|
+
message: e.message,
|
|
439
|
+
stack: b ? e.stack?.split(`
|
|
440
|
+
`).slice(0, 3).join(`
|
|
441
|
+
`) : e.stack,
|
|
442
|
+
...e
|
|
443
|
+
// Include any additional error properties
|
|
444
|
+
};
|
|
445
|
+
if (e instanceof Date)
|
|
446
|
+
return e.toISOString();
|
|
447
|
+
if (typeof e != "object")
|
|
448
|
+
return e;
|
|
449
|
+
if (Array.isArray(e))
|
|
450
|
+
return e.length > 20 && b ? `Array(${e.length}) [${e.slice(0, 3).map((r) => this.formatData(r, t, o + 1)).join(", ")}, ...]` : e.map((r) => this.formatData(r, t, o + 1));
|
|
451
|
+
try {
|
|
452
|
+
const r = {}, i = Object.entries(e), n = b ? 50 : 200;
|
|
453
|
+
for (const [u, c] of i.slice(0, n))
|
|
454
|
+
r[u] = this.formatData(c, t, o + 1);
|
|
455
|
+
return i.length > n && (r["..."] = `${i.length - n} more properties`), this.redactSensitive(r);
|
|
456
|
+
} catch {
|
|
457
|
+
return "[Unserializable]";
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
logToBrowser(e) {
|
|
461
|
+
if (!x || !this.shouldLog(e.level))
|
|
462
|
+
return;
|
|
463
|
+
const { level: t, description: o, context: r, data: i, error: n } = e, u = P[t], l = `[${r || this.context || "www"}] ${t.toUpperCase()}:`, h = `color: ${u.color}; font-weight: bold;`;
|
|
464
|
+
i !== void 0 ? console[t](`%c${l}`, h, o, this.formatData(i)) : console[t](`%c${l}`, h, o), n && (n instanceof Error ? console.error(n) : console.error("Error details:", n));
|
|
465
|
+
}
|
|
466
|
+
logToNode(e) {
|
|
467
|
+
if (!j || !this.shouldLog(e.level))
|
|
468
|
+
return;
|
|
469
|
+
const { level: t, description: o, context: r, data: i, error: n } = e, u = r || this.context || "www";
|
|
470
|
+
if (b) {
|
|
471
|
+
const c = {
|
|
472
|
+
timestamp: this.formatISOTimestamp(),
|
|
473
|
+
level: t.toUpperCase()
|
|
474
|
+
};
|
|
475
|
+
i && (c.data = this.formatData(i)), n && (c.error = this.formatData(n)), console[t](`${c.timestamp} ${c.level} [${u}] ${o}`, i || n ? JSON.stringify({ data: i, error: n }) : "");
|
|
476
|
+
} else {
|
|
477
|
+
const c = P[t], l = this.formatTimestamp(), h = "\x1B[0m", S = "\x1B[2m", g = c.nodeColor || "", k = `${S}${l}${h} ${g}${t.toUpperCase()} (${u}):${h} ${o}`;
|
|
478
|
+
console[t](k), i !== void 0 && console.log(JSON.stringify(this.formatData(i), null, 2)), n && (n instanceof Error ? (console.error(`\x1B[31mError:${h}`, n.message), n.stack && console.error(`\x1B[90m${n.stack}${h}`)) : console.error("Error:", n));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
log(e) {
|
|
482
|
+
x ? this.logToBrowser(e) : j && this.logToNode(e);
|
|
483
|
+
}
|
|
484
|
+
error(e, t) {
|
|
485
|
+
this.log({ level: "error", description: e, data: t, context: this.context });
|
|
486
|
+
}
|
|
487
|
+
warn(e, t) {
|
|
488
|
+
this.log({ level: "warn", description: e, data: t, context: this.context });
|
|
489
|
+
}
|
|
490
|
+
info(e, t) {
|
|
491
|
+
this.log({ level: "info", description: e, data: t, context: this.context });
|
|
492
|
+
}
|
|
493
|
+
debug(e, t) {
|
|
494
|
+
this.log({ level: "debug", description: e, data: t, context: this.context });
|
|
495
|
+
}
|
|
496
|
+
trace(e, t) {
|
|
497
|
+
this.log({ level: "trace", description: e, data: t, context: this.context });
|
|
498
|
+
}
|
|
499
|
+
isEnabled() {
|
|
500
|
+
return x ? this.enabledInBrowser : !0;
|
|
501
|
+
}
|
|
502
|
+
setLevel(e) {
|
|
503
|
+
this.settings.minLevel = e;
|
|
504
|
+
}
|
|
505
|
+
createContextLogger(e) {
|
|
506
|
+
const t = new L(this.settings, e);
|
|
507
|
+
return {
|
|
508
|
+
error: /* @__PURE__ */ s((o, r) => t.error(o, r), "error"),
|
|
509
|
+
warn: /* @__PURE__ */ s((o, r) => t.warn(o, r), "warn"),
|
|
510
|
+
info: /* @__PURE__ */ s((o, r) => t.info(o, r), "info"),
|
|
511
|
+
debug: /* @__PURE__ */ s((o, r) => t.debug(o, r), "debug"),
|
|
512
|
+
trace: /* @__PURE__ */ s((o, r) => t.trace(o, r), "trace"),
|
|
513
|
+
isEnabled: /* @__PURE__ */ s(() => t.isEnabled(), "isEnabled"),
|
|
514
|
+
setLevel: /* @__PURE__ */ s((o) => t.setLevel(o), "setLevel")
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
s(L, "Logger"), a(L, "hasShownHelp", !1);
|
|
519
|
+
let _ = L;
|
|
520
|
+
function xe(d) {
|
|
521
|
+
return new _({}, d);
|
|
522
|
+
}
|
|
523
|
+
s(xe, "createLogger");
|
|
524
|
+
const w = new _();
|
|
525
|
+
w.error.bind(w);
|
|
526
|
+
w.warn.bind(w);
|
|
527
|
+
w.info.bind(w);
|
|
528
|
+
w.debug.bind(w);
|
|
529
|
+
w.trace.bind(w);
|
|
530
|
+
const F = /* @__PURE__ */ ue(void 0), O = /* @__PURE__ */ ue(null), Z = class Z {
|
|
363
531
|
constructor() {
|
|
364
|
-
|
|
532
|
+
a(this, "logger", xe("SDKStorage"));
|
|
365
533
|
}
|
|
366
534
|
/**
|
|
367
535
|
* Check if localStorage is fully functional (some test environments provide partial mocks)
|
|
@@ -373,14 +541,14 @@ const $ = 4, re = /* @__PURE__ */ l(/* @__NO_SIDE_EFFECTS__ */ (h) => {
|
|
|
373
541
|
* Sync Vue reactive refs with global nanostores for cross-page persistence
|
|
374
542
|
*/
|
|
375
543
|
syncWithGlobalStores(e, t) {
|
|
376
|
-
const o =
|
|
377
|
-
o && (e.value = o), r && (t.value = r),
|
|
378
|
-
|
|
379
|
-
}, { immediate: !0 }),
|
|
380
|
-
|
|
381
|
-
}, { immediate: !0 }),
|
|
544
|
+
const o = F.get(), r = O.get();
|
|
545
|
+
o && (e.value = o), r && (t.value = r), ne(e, (i) => {
|
|
546
|
+
F.set(i);
|
|
547
|
+
}, { immediate: !0 }), ne(t, (i) => {
|
|
548
|
+
O.set(i);
|
|
549
|
+
}, { immediate: !0 }), F.subscribe((i) => {
|
|
382
550
|
i !== e.value && (e.value = i);
|
|
383
|
-
}),
|
|
551
|
+
}), O.subscribe((i) => {
|
|
384
552
|
i !== t.value && (t.value = i);
|
|
385
553
|
});
|
|
386
554
|
}
|
|
@@ -390,7 +558,7 @@ const $ = 4, re = /* @__PURE__ */ l(/* @__NO_SIDE_EFFECTS__ */ (h) => {
|
|
|
390
558
|
loadFromStorage(e, t) {
|
|
391
559
|
if (typeof window > "u")
|
|
392
560
|
return;
|
|
393
|
-
const o =
|
|
561
|
+
const o = C.getAuthToken();
|
|
394
562
|
if (o && (t.value = o), this.isLocalStorageFunctional())
|
|
395
563
|
try {
|
|
396
564
|
const r = localStorage.getItem("pagelines-user");
|
|
@@ -403,7 +571,7 @@ const $ = 4, re = /* @__PURE__ */ l(/* @__NO_SIDE_EFFECTS__ */ (h) => {
|
|
|
403
571
|
* Save current user and token to browser storage
|
|
404
572
|
*/
|
|
405
573
|
saveToStorage(e, t) {
|
|
406
|
-
if (!(typeof window > "u") && (t.value ?
|
|
574
|
+
if (!(typeof window > "u") && (t.value ? C.setAuthToken(t.value) : C.removeAuthToken(), this.isLocalStorageFunctional()))
|
|
407
575
|
try {
|
|
408
576
|
e.value ? localStorage.setItem("pagelines-user", JSON.stringify(e.value)) : localStorage.removeItem("pagelines-user");
|
|
409
577
|
} catch (o) {
|
|
@@ -415,13 +583,13 @@ const $ = 4, re = /* @__PURE__ */ l(/* @__NO_SIDE_EFFECTS__ */ (h) => {
|
|
|
415
583
|
*/
|
|
416
584
|
clearStorage() {
|
|
417
585
|
if (!(typeof window > "u")) {
|
|
418
|
-
if (
|
|
586
|
+
if (C.removeAuthToken(), this.isLocalStorageFunctional())
|
|
419
587
|
try {
|
|
420
588
|
localStorage.removeItem("pagelines-user");
|
|
421
589
|
} catch (e) {
|
|
422
590
|
this.logger.error("Failed to clear user from localStorage", { data: e });
|
|
423
591
|
}
|
|
424
|
-
|
|
592
|
+
F.set(void 0), O.set(null);
|
|
425
593
|
}
|
|
426
594
|
}
|
|
427
595
|
/**
|
|
@@ -448,9 +616,9 @@ const $ = 4, re = /* @__PURE__ */ l(/* @__NO_SIDE_EFFECTS__ */ (h) => {
|
|
|
448
616
|
}
|
|
449
617
|
}
|
|
450
618
|
};
|
|
451
|
-
|
|
452
|
-
let
|
|
453
|
-
const
|
|
619
|
+
s(Z, "SDKStorage");
|
|
620
|
+
let W = Z;
|
|
621
|
+
const ee = class ee {
|
|
454
622
|
constructor(e) {
|
|
455
623
|
this.ctx = e;
|
|
456
624
|
}
|
|
@@ -561,44 +729,44 @@ const V = class V {
|
|
|
561
729
|
this.ctx.logger.error("loginWithGoogle: Only available in browser");
|
|
562
730
|
return;
|
|
563
731
|
}
|
|
564
|
-
const t = this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${
|
|
732
|
+
const t = this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${M}` : R), o = window.location.origin, r = `${t}/auth/google-popup?origin=${encodeURIComponent(o)}`, i = 500, n = 600, u = window.screenX + (window.outerWidth - i) / 2, c = window.screenY + (window.outerHeight - n) / 2, l = window.open(
|
|
565
733
|
r,
|
|
566
734
|
"google-auth",
|
|
567
|
-
`width=${i},height=${
|
|
735
|
+
`width=${i},height=${n},left=${u},top=${c},popup=yes`
|
|
568
736
|
);
|
|
569
|
-
if (!
|
|
737
|
+
if (!l) {
|
|
570
738
|
const g = "Popup was blocked. Please allow popups for this site.";
|
|
571
739
|
this.ctx.error.value = g, e?.onError?.(g);
|
|
572
740
|
return;
|
|
573
741
|
}
|
|
574
|
-
const
|
|
742
|
+
const h = /* @__PURE__ */ s((g) => {
|
|
575
743
|
const k = new URL(t).origin;
|
|
576
744
|
if (g.origin === k) {
|
|
577
745
|
if (g.data?.type === "auth-success") {
|
|
578
|
-
window.removeEventListener("message",
|
|
579
|
-
const { token: f, user:
|
|
580
|
-
this.ctx.processApiResponse({ ok: !0, data: {}, token: f, user:
|
|
746
|
+
window.removeEventListener("message", h);
|
|
747
|
+
const { token: f, user: B } = g.data;
|
|
748
|
+
this.ctx.processApiResponse({ ok: !0, data: {}, token: f, user: B }), this.ctx.logger.info("Google login successful"), e?.onSuccess?.(B);
|
|
581
749
|
} else if (g.data?.type === "auth-error") {
|
|
582
|
-
window.removeEventListener("message",
|
|
750
|
+
window.removeEventListener("message", h);
|
|
583
751
|
const f = g.data.error || "Google authentication failed";
|
|
584
752
|
this.ctx.error.value = f, this.ctx.logger.error("Google login failed", { error: f }), e?.onError?.(f);
|
|
585
753
|
}
|
|
586
754
|
}
|
|
587
755
|
}, "handler");
|
|
588
|
-
window.addEventListener("message",
|
|
756
|
+
window.addEventListener("message", h);
|
|
589
757
|
const S = setInterval(() => {
|
|
590
|
-
|
|
758
|
+
l.closed && (clearInterval(S), window.removeEventListener("message", h));
|
|
591
759
|
}, 500);
|
|
592
760
|
}
|
|
593
761
|
};
|
|
594
|
-
|
|
595
|
-
let
|
|
596
|
-
const
|
|
762
|
+
s(ee, "AuthClient");
|
|
763
|
+
let J = ee;
|
|
764
|
+
const te = class te {
|
|
597
765
|
constructor(e) {
|
|
598
766
|
this.ctx = e;
|
|
599
767
|
}
|
|
600
768
|
async chatStream(e) {
|
|
601
|
-
const o = `${this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${
|
|
769
|
+
const o = `${this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${M}` : R)}/api/agent/public/${encodeURIComponent(e.handle)}/chat/stream`;
|
|
602
770
|
try {
|
|
603
771
|
const r = await fetch(o, {
|
|
604
772
|
method: "POST",
|
|
@@ -613,8 +781,8 @@ const H = class H {
|
|
|
613
781
|
})
|
|
614
782
|
});
|
|
615
783
|
if (!r.ok) {
|
|
616
|
-
const
|
|
617
|
-
e.onError(
|
|
784
|
+
const l = await r.json().catch(() => ({ error: "Request failed" }));
|
|
785
|
+
e.onError(l.error || `HTTP ${r.status}`);
|
|
618
786
|
return;
|
|
619
787
|
}
|
|
620
788
|
const i = r.body?.getReader();
|
|
@@ -622,22 +790,22 @@ const H = class H {
|
|
|
622
790
|
e.onError("No response stream");
|
|
623
791
|
return;
|
|
624
792
|
}
|
|
625
|
-
const
|
|
626
|
-
let
|
|
793
|
+
const n = new TextDecoder();
|
|
794
|
+
let u = "", c = e.conversationId || "";
|
|
627
795
|
for (; ; ) {
|
|
628
|
-
const { done:
|
|
629
|
-
if (
|
|
796
|
+
const { done: l, value: h } = await i.read();
|
|
797
|
+
if (l)
|
|
630
798
|
break;
|
|
631
|
-
|
|
632
|
-
const S =
|
|
799
|
+
u += n.decode(h, { stream: !0 });
|
|
800
|
+
const S = u.split(`
|
|
633
801
|
`);
|
|
634
|
-
|
|
802
|
+
u = S.pop() || "";
|
|
635
803
|
for (const g of S) {
|
|
636
804
|
if (!g.startsWith("data: "))
|
|
637
805
|
continue;
|
|
638
806
|
const k = g.slice(6).trim();
|
|
639
807
|
if (k === "[DONE]") {
|
|
640
|
-
e.onDone(
|
|
808
|
+
e.onDone(c);
|
|
641
809
|
return;
|
|
642
810
|
}
|
|
643
811
|
try {
|
|
@@ -646,20 +814,20 @@ const H = class H {
|
|
|
646
814
|
e.onStatus?.(f.pl_status);
|
|
647
815
|
continue;
|
|
648
816
|
}
|
|
649
|
-
f.pl_metadata?.conversationId && (
|
|
650
|
-
const
|
|
651
|
-
|
|
817
|
+
f.pl_metadata?.conversationId && (c = f.pl_metadata.conversationId);
|
|
818
|
+
const B = f.choices?.[0]?.delta;
|
|
819
|
+
B?.content && e.onDelta(B.content);
|
|
652
820
|
} catch {
|
|
653
821
|
}
|
|
654
822
|
}
|
|
655
823
|
}
|
|
656
|
-
e.onDone(
|
|
824
|
+
e.onDone(c);
|
|
657
825
|
} catch (r) {
|
|
658
826
|
e.onError(r instanceof Error ? r.message : "Stream failed");
|
|
659
827
|
}
|
|
660
828
|
}
|
|
661
829
|
async chatMessage(e) {
|
|
662
|
-
const o = `${this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${
|
|
830
|
+
const o = `${this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${M}` : R)}/api/agent/public/${encodeURIComponent(e.handle)}/chat`;
|
|
663
831
|
try {
|
|
664
832
|
const i = await (await fetch(o, {
|
|
665
833
|
method: "POST",
|
|
@@ -685,9 +853,17 @@ const H = class H {
|
|
|
685
853
|
}
|
|
686
854
|
}
|
|
687
855
|
};
|
|
688
|
-
|
|
689
|
-
let
|
|
690
|
-
|
|
856
|
+
s(te, "ChatClient");
|
|
857
|
+
let q = te;
|
|
858
|
+
function Se(d = {}) {
|
|
859
|
+
const { prefix: e = "id_" } = d, t = e.length >= 3 ? e.substring(0, 3) : e.padEnd(3, "_"), o = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0");
|
|
860
|
+
let r = "";
|
|
861
|
+
for (let i = 0; i < 16; i++)
|
|
862
|
+
r += Math.floor(Math.random() * 16).toString(16);
|
|
863
|
+
return t + o + r;
|
|
864
|
+
}
|
|
865
|
+
s(Se, "objectId");
|
|
866
|
+
const oe = class oe {
|
|
691
867
|
constructor(e) {
|
|
692
868
|
this.ctx = e;
|
|
693
869
|
}
|
|
@@ -730,7 +906,7 @@ const Q = class Q {
|
|
|
730
906
|
generateAnonId() {
|
|
731
907
|
const e = "pagelinesAnonId";
|
|
732
908
|
let t = this.ctx.storage.getItem(e);
|
|
733
|
-
return t || (t =
|
|
909
|
+
return t || (t = Se({ prefix: "anon" }), this.ctx.storage.setItem(e, t)), t;
|
|
734
910
|
}
|
|
735
911
|
track(e) {
|
|
736
912
|
try {
|
|
@@ -745,11 +921,11 @@ const Q = class Q {
|
|
|
745
921
|
}
|
|
746
922
|
}
|
|
747
923
|
};
|
|
748
|
-
|
|
749
|
-
let
|
|
750
|
-
const
|
|
924
|
+
s(oe, "UserClient");
|
|
925
|
+
let H = oe;
|
|
926
|
+
const re = class re {
|
|
751
927
|
constructor() {
|
|
752
|
-
|
|
928
|
+
a(this, "key", "__PAGELINES_SDK__");
|
|
753
929
|
}
|
|
754
930
|
get() {
|
|
755
931
|
if (!(typeof window > "u"))
|
|
@@ -762,29 +938,29 @@ const Y = class Y {
|
|
|
762
938
|
typeof window < "u" && delete globalThis[this.key];
|
|
763
939
|
}
|
|
764
940
|
};
|
|
765
|
-
|
|
766
|
-
let
|
|
767
|
-
const
|
|
941
|
+
s(re, "SDKGlobal");
|
|
942
|
+
let Q = re;
|
|
943
|
+
const N = new Q(), K = class K extends V {
|
|
768
944
|
constructor(t = {}) {
|
|
769
|
-
const o =
|
|
945
|
+
const o = N.get();
|
|
770
946
|
if (o)
|
|
771
947
|
return console.debug("[PageLinesSDK] Returning existing singleton instance"), o;
|
|
772
948
|
super("PageLinesSDK", t);
|
|
773
949
|
// Vue reactive state
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
950
|
+
a(this, "activeUser", T());
|
|
951
|
+
a(this, "token", T(null));
|
|
952
|
+
a(this, "loading", T(!1));
|
|
953
|
+
a(this, "error", T(null));
|
|
954
|
+
a(this, "apiBase", this.settings.apiBase || void 0);
|
|
779
955
|
// Storage handler for persistence
|
|
780
|
-
|
|
956
|
+
a(this, "storage", new W());
|
|
781
957
|
// Auto-managed session ID for usage tracking
|
|
782
|
-
|
|
958
|
+
a(this, "sessionId", ae({ prefix: "ses" }));
|
|
783
959
|
// Typed Hono RPC client - uses SDKAppType (auth/self/usage routes only)
|
|
784
960
|
// Initialized in constructor (definite assignment via singleton pattern)
|
|
785
|
-
|
|
961
|
+
a(this, "apiClient");
|
|
786
962
|
// Computed properties derived from activeUser (matches UserClient pattern)
|
|
787
|
-
|
|
963
|
+
a(this, "currentAgent", se(() => {
|
|
788
964
|
const t = this.activeUser.value;
|
|
789
965
|
if (!t?.agents)
|
|
790
966
|
return;
|
|
@@ -792,7 +968,7 @@ const T = new K(), N = class N extends j {
|
|
|
792
968
|
if (o)
|
|
793
969
|
return t.agents.find((r) => r.agentId === o);
|
|
794
970
|
}));
|
|
795
|
-
|
|
971
|
+
a(this, "currentOrg", se(() => {
|
|
796
972
|
const t = this.currentAgent.value;
|
|
797
973
|
if (!t?.orgId)
|
|
798
974
|
return;
|
|
@@ -801,13 +977,13 @@ const T = new K(), N = class N extends j {
|
|
|
801
977
|
return o.orgs.find((r) => r.orgId === t.orgId);
|
|
802
978
|
}));
|
|
803
979
|
// Initialization state
|
|
804
|
-
|
|
805
|
-
|
|
980
|
+
a(this, "initialized");
|
|
981
|
+
a(this, "resolveUser");
|
|
806
982
|
// Sub-clients (new preferred API surface)
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
983
|
+
a(this, "auth");
|
|
984
|
+
a(this, "chat");
|
|
985
|
+
a(this, "user");
|
|
986
|
+
N.set(this), this.apiClient = me(
|
|
811
987
|
{ isDev: this.isDev, apiBase: this.apiBase },
|
|
812
988
|
this.processApiResponse.bind(this)
|
|
813
989
|
);
|
|
@@ -825,7 +1001,7 @@ const T = new K(), N = class N extends j {
|
|
|
825
1001
|
logger: this.logger,
|
|
826
1002
|
processApiResponse: this.processApiResponse.bind(this)
|
|
827
1003
|
};
|
|
828
|
-
this.auth = new
|
|
1004
|
+
this.auth = new J(r), this.chat = new q(r), this.user = new H(r), this.logger.info("PageLinesSDK initialized"), this.storage.loadFromStorage(this.activeUser, this.token), this.storage.syncWithGlobalStores(this.activeUser, this.token), this.initialized = new Promise((i) => {
|
|
829
1005
|
this.resolveUser = i;
|
|
830
1006
|
}), this.token.value && !this.activeUser.value ? this.getCurrentUser().then((i) => {
|
|
831
1007
|
this.resolveUser && (this.resolveUser(i), this.resolveUser = void 0);
|
|
@@ -839,7 +1015,7 @@ const T = new K(), N = class N extends j {
|
|
|
839
1015
|
* Recommended: Use this instead of constructor for shared state
|
|
840
1016
|
*/
|
|
841
1017
|
static getInstance(t = {}) {
|
|
842
|
-
return
|
|
1018
|
+
return N.get() || new K(t);
|
|
843
1019
|
}
|
|
844
1020
|
get isDev() {
|
|
845
1021
|
return this.settings.isDev ?? (typeof window < "u" ? window.location.hostname === "localhost" || window.location.hostname.includes("127.0.0.1") : !1);
|
|
@@ -859,9 +1035,9 @@ const T = new K(), N = class N extends j {
|
|
|
859
1035
|
}
|
|
860
1036
|
// Full reset - clears session + state + destroys singleton
|
|
861
1037
|
clear() {
|
|
862
|
-
this.logger.info("Clearing SDK completely"), this.clearSession(), this.loading.value = !1, this.sessionId =
|
|
1038
|
+
this.logger.info("Clearing SDK completely"), this.clearSession(), this.loading.value = !1, this.sessionId = ae({ prefix: "ses" }), N.delete();
|
|
863
1039
|
}
|
|
864
|
-
// Backward-compatible delegates
|
|
1040
|
+
// Backward-compatible delegates — these forward to sub-clients
|
|
865
1041
|
// Can be removed in a future breaking change
|
|
866
1042
|
async sendCode(t) {
|
|
867
1043
|
return this.auth.sendCode(t);
|
|
@@ -906,14 +1082,13 @@ const T = new K(), N = class N extends j {
|
|
|
906
1082
|
return this.user.track(t);
|
|
907
1083
|
}
|
|
908
1084
|
};
|
|
909
|
-
|
|
910
|
-
let
|
|
1085
|
+
s(K, "PageLinesSDK");
|
|
1086
|
+
let le = K;
|
|
911
1087
|
export {
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
oe as c
|
|
1088
|
+
J as A,
|
|
1089
|
+
q as C,
|
|
1090
|
+
le as P,
|
|
1091
|
+
H as U,
|
|
1092
|
+
xe as c
|
|
918
1093
|
};
|
|
919
|
-
//# sourceMappingURL=sdkClient-
|
|
1094
|
+
//# sourceMappingURL=sdkClient-B3EKDRYb.js.map
|