@runtypelabs/persona 4.17.0 → 4.18.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/dist/animations/glyph-cycle.d.cts +1 -1
- package/dist/animations/glyph-cycle.d.ts +1 -1
- package/dist/animations/{types-BpWGm7_6.d.cts → types-DsmTD8TO.d.cts} +12 -0
- package/dist/animations/{types-BpWGm7_6.d.ts → types-DsmTD8TO.d.ts} +12 -0
- package/dist/animations/wipe.d.cts +1 -1
- package/dist/animations/wipe.d.ts +1 -1
- package/dist/chunk-3I2S3I5P.js +1 -0
- package/dist/chunk-76IELU7F.js +1 -0
- package/dist/chunk-EFJBUH5F.js +1 -0
- package/dist/chunk-PDPVORUF.js +1 -0
- package/dist/chunk-Q735PSZL.js +1 -0
- package/dist/chunk-VK6JOIYJ.js +1 -0
- package/dist/codegen.cjs +4 -4
- package/dist/codegen.js +4 -4
- package/dist/{context-mentions-BTSTIBFC.js → context-mentions-MJL6S6P2.js} +1 -1
- package/dist/context-mentions.cjs +9 -8
- package/dist/context-mentions.d.cts +1224 -14
- package/dist/context-mentions.d.ts +1224 -14
- package/dist/context-mentions.js +9 -8
- package/dist/event-stream-view-4EZ7BGFK.js +1 -0
- package/dist/event-stream-view.cjs +129 -0
- package/dist/event-stream-view.d.cts +8384 -0
- package/dist/event-stream-view.d.ts +8384 -0
- package/dist/event-stream-view.js +129 -0
- package/dist/history-view-BD6OXLNA.js +898 -0
- package/dist/history-view.cjs +898 -0
- package/dist/history-view.d.cts +1461 -0
- package/dist/history-view.d.ts +1461 -0
- package/dist/history-view.js +898 -0
- package/dist/index.cjs +77 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2040 -21
- package/dist/index.d.ts +2040 -21
- package/dist/index.global.js +67 -66
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +77 -77
- package/dist/index.js.map +1 -1
- package/dist/launcher.global.js +5 -4
- package/dist/launcher.global.js.map +1 -1
- package/dist/plugin-kit.cjs +1 -1
- package/dist/plugin-kit.d.cts +0 -8
- package/dist/plugin-kit.d.ts +0 -8
- package/dist/plugin-kit.js +1 -1
- package/dist/smart-dom-reader.d.cts +1224 -14
- package/dist/smart-dom-reader.d.ts +1224 -14
- package/dist/theme-editor-preview.cjs +970 -73
- package/dist/theme-editor-preview.d.cts +1343 -15
- package/dist/theme-editor-preview.d.ts +1343 -15
- package/dist/theme-editor-preview.js +81 -81
- package/dist/theme-editor.cjs +7 -7
- package/dist/theme-editor.d.cts +1227 -15
- package/dist/theme-editor.d.ts +1227 -15
- package/dist/theme-editor.js +9 -9
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +226 -7
- package/dist/theme-reference.d.ts +226 -7
- package/dist/theme-reference.js +1 -1
- package/dist/webmcp-polyfill.js +2 -2
- package/dist/widget.css +1 -1
- package/package.json +18 -6
- package/src/client-history-rest.test.ts +1034 -0
- package/src/client-visitor-history.test.ts +596 -0
- package/src/client.ts +1040 -24
- package/src/components/artifact-inline.ts +8 -1
- package/src/components/artifact-pane.test.ts +278 -1
- package/src/components/artifact-pane.ts +135 -67
- package/src/components/artifact-preview.test.ts +14 -1
- package/src/components/artifact-preview.ts +9 -0
- package/src/components/header-builder.ts +3 -0
- package/src/components/header-layouts.test.ts +171 -7
- package/src/components/header-layouts.ts +83 -53
- package/src/components/header-parts.test.ts +154 -1
- package/src/components/header-parts.ts +266 -138
- package/src/components/history-confirm-dialog.ts +177 -0
- package/src/components/history-shell-copy.ts +99 -0
- package/src/components/history-view/announcer.ts +40 -0
- package/src/components/history-view/copy.ts +105 -0
- package/src/components/history-view/css.ts +1078 -0
- package/src/components/history-view/grouping.test.ts +142 -0
- package/src/components/history-view/grouping.ts +142 -0
- package/src/components/history-view/icons.ts +73 -0
- package/src/components/history-view/rows.ts +341 -0
- package/src/components/history-view/state.ts +309 -0
- package/src/components/history-view.test.ts +2660 -0
- package/src/components/history-view.ts +1891 -0
- package/src/components/launcher-surface.test.ts +133 -0
- package/src/components/launcher.test.ts +18 -0
- package/src/components/launcher.ts +7 -7
- package/src/components/panel.ts +17 -7
- package/src/components/welcome.ts +72 -2
- package/src/defaults.ts +36 -3
- package/src/event-stream-view-bundle.test.ts +69 -0
- package/src/event-stream-view-entry.ts +19 -0
- package/src/event-stream-view-loader.ts +31 -0
- package/src/event-stream-view.ts +19 -0
- package/src/generated/runtype-openapi-contract.ts +54 -4
- package/src/history-render.ts +325 -0
- package/src/history-view-bundle.test.ts +78 -0
- package/src/history-view-entry.ts +41 -0
- package/src/history-view-loader.test.ts +30 -0
- package/src/history-view-loader.ts +32 -0
- package/src/history-view.ts +28 -0
- package/src/index-core.ts +50 -2
- package/src/index-global.ts +55 -0
- package/src/internal/demo-history-provider.test.ts +402 -0
- package/src/internal/demo-history-provider.ts +689 -0
- package/src/internal/history-provider-registry.ts +25 -0
- package/src/internal/history-provider.ts +150 -0
- package/src/internal/runtype-history-provider.test.ts +313 -0
- package/src/internal/runtype-history-provider.ts +240 -0
- package/src/plugin-kit.test.ts +16 -0
- package/src/plugin-kit.ts +13 -5
- package/src/plugins/types.ts +177 -1
- package/src/session-history.test.ts +1397 -0
- package/src/session.ts +1200 -26
- package/src/styles/widget-styles.test.ts +133 -0
- package/src/styles/widget.css +227 -8
- package/src/theme-editor/preview-utils.test.ts +19 -0
- package/src/theme-editor/preview-utils.ts +15 -1
- package/src/theme-editor/preview.ts +7 -1
- package/src/theme-editor/role-mappings.ts +4 -1
- package/src/theme-editor/sections.test.ts +168 -1
- package/src/theme-editor/sections.ts +136 -7
- package/src/theme-editor/webmcp/summary.ts +16 -2
- package/src/theme-reference.ts +20 -6
- package/src/types/theme.ts +213 -7
- package/src/types.ts +927 -7
- package/src/ui.artifact-rail-resize.test.ts +235 -0
- package/src/ui.attachments-drop.test.ts +1 -0
- package/src/ui.header-update-stability.test.ts +2 -2
- package/src/ui.history-chunk.test.ts +72 -0
- package/src/ui.history-config-provider.test.ts +318 -0
- package/src/ui.history-controller.test.ts +711 -0
- package/src/ui.history-lifecycle.test.ts +456 -0
- package/src/ui.history-render-hooks.test.ts +904 -0
- package/src/ui.history-shell.test.ts +1887 -0
- package/src/ui.rail-overlay.test.ts +573 -0
- package/src/ui.rail-resize.test.ts +284 -0
- package/src/ui.rebuild-composer.test.ts +21 -0
- package/src/ui.render-welcome.test.ts +42 -0
- package/src/ui.shortcuts.test.ts +166 -0
- package/src/ui.ts +3071 -240
- package/src/utils/__fixtures__/client-conversation-history-wire.json +108 -0
- package/src/utils/artifact-file.ts +15 -0
- package/src/utils/artifact-gate.test.ts +4 -0
- package/src/utils/artifact-gate.ts +13 -17
- package/src/utils/artifact-resize.test.ts +28 -0
- package/src/utils/artifact-resize.ts +9 -2
- package/src/utils/buttons.ts +188 -1
- package/src/utils/config-merge.test.ts +91 -0
- package/src/utils/dropdown.ts +10 -1
- package/src/utils/history-messages.test.ts +284 -0
- package/src/utils/history-messages.ts +284 -0
- package/src/utils/icons.ts +3 -0
- package/src/utils/shortcuts.test.ts +288 -0
- package/src/utils/shortcuts.ts +221 -0
- package/src/utils/theme.test.ts +501 -4
- package/src/utils/theme.ts +42 -3
- package/src/utils/tokens.ts +153 -15
- package/src/utils/tooltip-timing.ts +4 -0
- package/src/utils/tooltip.test.ts +249 -7
- package/src/utils/tooltip.ts +146 -4
- package/src/utils/visitor-store.test.ts +425 -0
- package/src/utils/visitor-store.ts +337 -0
- package/dist/chunk-QJ4LV2KW.js +0 -1
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable visitor-credential store for per-visitor conversation history
|
|
3
|
+
* (client-token mode only). Holds the raw `cvt_…` secret under a localStorage
|
|
4
|
+
* key namespaced by a hash of the client token, degrades to memory after the
|
|
5
|
+
* first storage throw, and observes cross-tab changes through the `storage`
|
|
6
|
+
* event. One instance is owned by the controller and injected into every
|
|
7
|
+
* `AgentWidgetClient` it builds; reuse is keyed on the identity tuple
|
|
8
|
+
* `(clientToken, keyPrefix, persistDisabled)`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export interface VisitorStoreChange {
|
|
12
|
+
previousToken: string | null;
|
|
13
|
+
token: string | null;
|
|
14
|
+
/** "local" = this store's own set/clear; "external" = observed from outside. */
|
|
15
|
+
source: "local" | "external";
|
|
16
|
+
revision: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface VisitorStore {
|
|
20
|
+
/** Resolves once the hashed storage key exists; every op awaits it. */
|
|
21
|
+
readonly ready: Promise<void>;
|
|
22
|
+
get(): Promise<string | null>;
|
|
23
|
+
set(token: string): Promise<void>;
|
|
24
|
+
clear(): Promise<void>;
|
|
25
|
+
/** Monotonic per instance; advances on every observed value change. */
|
|
26
|
+
revision(): number;
|
|
27
|
+
subscribe(callback: (change: VisitorStoreChange) => void): () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Serialize the empty-store first init across same-origin tabs. Web Locks
|
|
30
|
+
* when available; otherwise a best-effort localStorage lease (collision
|
|
31
|
+
* reduction, not proof of exclusivity). Callers must re-read the store
|
|
32
|
+
* inside `fn` and hold the lock through mint + write + immediate claim.
|
|
33
|
+
*/
|
|
34
|
+
withFirstInitLock<T>(fn: () => Promise<T>): Promise<T>;
|
|
35
|
+
matches(
|
|
36
|
+
clientToken: string,
|
|
37
|
+
keyPrefix: string,
|
|
38
|
+
persistDisabled: boolean
|
|
39
|
+
): boolean;
|
|
40
|
+
destroy(): void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface LockManagerLike {
|
|
44
|
+
request<T>(name: string, callback: () => Promise<T> | T): Promise<T>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface LeaseRecord {
|
|
48
|
+
ownerNonce: string;
|
|
49
|
+
expiresAt: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Non-crypto fallback for non-secure contexts without `crypto.subtle`. */
|
|
53
|
+
const fnv1aHex = (input: string): string => {
|
|
54
|
+
let hash = 0x811c9dc5;
|
|
55
|
+
for (let i = 0; i < input.length; i++) {
|
|
56
|
+
hash ^= input.charCodeAt(i);
|
|
57
|
+
hash = Math.imul(hash, 0x01000193) >>> 0;
|
|
58
|
+
}
|
|
59
|
+
return hash.toString(16).padStart(8, "0");
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Namespacing hash only, not a security boundary: it keeps the raw `ct_`
|
|
64
|
+
* token out of storage keys and separates surfaces sharing an origin.
|
|
65
|
+
*/
|
|
66
|
+
export const hashClientToken = async (clientToken: string): Promise<string> => {
|
|
67
|
+
const subtle = globalThis.crypto?.subtle;
|
|
68
|
+
if (subtle) {
|
|
69
|
+
try {
|
|
70
|
+
const digest = await subtle.digest(
|
|
71
|
+
"SHA-256",
|
|
72
|
+
new TextEncoder().encode(clientToken)
|
|
73
|
+
);
|
|
74
|
+
return Array.from(new Uint8Array(digest))
|
|
75
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
76
|
+
.join("");
|
|
77
|
+
} catch {
|
|
78
|
+
// Non-secure context: fall through to the sync hash.
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return fnv1aHex(clientToken);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const visitorStoreKeys = async (
|
|
85
|
+
clientToken: string,
|
|
86
|
+
keyPrefix: string
|
|
87
|
+
): Promise<{ storageKey: string; leaseKey: string; lockName: string }> => {
|
|
88
|
+
const tokenHash = await hashClientToken(clientToken);
|
|
89
|
+
return {
|
|
90
|
+
storageKey: `${keyPrefix}visitor:${tokenHash}`,
|
|
91
|
+
leaseKey: `${keyPrefix}visitor-init-lock:${tokenHash}`,
|
|
92
|
+
lockName: `persona-visitor-init:${await hashClientToken(
|
|
93
|
+
`${clientToken}\0${keyPrefix}`
|
|
94
|
+
)}`,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const LEASE_MS = 10_000;
|
|
99
|
+
const LEASE_WAIT_CAP_MS = 15_000;
|
|
100
|
+
|
|
101
|
+
export const createVisitorStore = (
|
|
102
|
+
clientToken: string,
|
|
103
|
+
keyPrefix: string,
|
|
104
|
+
persistDisabled: boolean
|
|
105
|
+
): VisitorStore => {
|
|
106
|
+
let storageKey = "";
|
|
107
|
+
let leaseKey = "";
|
|
108
|
+
let lockName = "";
|
|
109
|
+
let blocked = false;
|
|
110
|
+
let destroyed = false;
|
|
111
|
+
let currentRevision = 0;
|
|
112
|
+
let lastKnown: string | null = null;
|
|
113
|
+
let heldLeaseNonce: string | null = null;
|
|
114
|
+
const subscribers = new Set<(change: VisitorStoreChange) => void>();
|
|
115
|
+
|
|
116
|
+
const localStore = (): Storage | null => {
|
|
117
|
+
if (persistDisabled || blocked) return null;
|
|
118
|
+
try {
|
|
119
|
+
if (typeof window === "undefined" || !window.localStorage) return null;
|
|
120
|
+
return window.localStorage;
|
|
121
|
+
} catch {
|
|
122
|
+
blocked = true;
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const readRaw = (): string | null => {
|
|
128
|
+
const store = localStore();
|
|
129
|
+
if (!store) return lastKnown;
|
|
130
|
+
try {
|
|
131
|
+
return store.getItem(storageKey);
|
|
132
|
+
} catch {
|
|
133
|
+
blocked = true;
|
|
134
|
+
return lastKnown;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const observe = (value: string | null, source: "local" | "external") => {
|
|
139
|
+
if (destroyed || value === lastKnown) return;
|
|
140
|
+
const previousToken = lastKnown;
|
|
141
|
+
lastKnown = value;
|
|
142
|
+
currentRevision += 1;
|
|
143
|
+
const change: VisitorStoreChange = {
|
|
144
|
+
previousToken,
|
|
145
|
+
token: value,
|
|
146
|
+
source,
|
|
147
|
+
revision: currentRevision,
|
|
148
|
+
};
|
|
149
|
+
for (const callback of subscribers) callback(change);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const onStorage = (event: StorageEvent) => {
|
|
153
|
+
if (destroyed) return;
|
|
154
|
+
// key === null is a whole-store clear(); our value is gone with it.
|
|
155
|
+
if (event.key !== null && event.key !== storageKey) return;
|
|
156
|
+
observe(event.key === null ? null : (event.newValue ?? null), "external");
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const ready = (async () => {
|
|
160
|
+
const keys = await visitorStoreKeys(clientToken, keyPrefix);
|
|
161
|
+
storageKey = keys.storageKey;
|
|
162
|
+
leaseKey = keys.leaseKey;
|
|
163
|
+
lockName = keys.lockName;
|
|
164
|
+
// Hydrate silently: an existing credential at boot is not a "change".
|
|
165
|
+
lastKnown = readRaw();
|
|
166
|
+
if (!persistDisabled && typeof window !== "undefined") {
|
|
167
|
+
window.addEventListener("storage", onStorage);
|
|
168
|
+
}
|
|
169
|
+
})();
|
|
170
|
+
|
|
171
|
+
const sleep = (ms: number) => new Promise<void>((r) => setTimeout(r, ms));
|
|
172
|
+
|
|
173
|
+
const readLease = (): LeaseRecord | null => {
|
|
174
|
+
const store = localStore();
|
|
175
|
+
if (!store) return null;
|
|
176
|
+
try {
|
|
177
|
+
const raw = store.getItem(leaseKey);
|
|
178
|
+
if (!raw) return null;
|
|
179
|
+
const parsed = JSON.parse(raw) as LeaseRecord;
|
|
180
|
+
return typeof parsed?.expiresAt === "number" &&
|
|
181
|
+
typeof parsed?.ownerNonce === "string"
|
|
182
|
+
? parsed
|
|
183
|
+
: null;
|
|
184
|
+
} catch {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const removeOwnLease = (nonce: string) => {
|
|
190
|
+
const store = localStore();
|
|
191
|
+
if (!store) return;
|
|
192
|
+
try {
|
|
193
|
+
if (readLease()?.ownerNonce === nonce) store.removeItem(leaseKey);
|
|
194
|
+
} catch {
|
|
195
|
+
// Expiry reclaims an unremovable lease.
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/** Storage-change wakeup with a timeout floor; same-tab writers fire no event. */
|
|
200
|
+
const waitForLeaseChange = (timeoutMs: number) =>
|
|
201
|
+
new Promise<void>((resolve) => {
|
|
202
|
+
const timer = setTimeout(done, timeoutMs);
|
|
203
|
+
function done() {
|
|
204
|
+
clearTimeout(timer);
|
|
205
|
+
window.removeEventListener("storage", wake);
|
|
206
|
+
resolve();
|
|
207
|
+
}
|
|
208
|
+
function wake(event: StorageEvent) {
|
|
209
|
+
if (event.key === null || event.key === leaseKey) done();
|
|
210
|
+
}
|
|
211
|
+
window.addEventListener("storage", wake);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
const leaseLock = async <T>(fn: () => Promise<T>): Promise<T> => {
|
|
215
|
+
const nonce = `${Date.now().toString(36)}-${Math.random()
|
|
216
|
+
.toString(36)
|
|
217
|
+
.slice(2)}`;
|
|
218
|
+
const deadline = Date.now() + LEASE_WAIT_CAP_MS;
|
|
219
|
+
while (Date.now() < deadline) {
|
|
220
|
+
const store = localStore();
|
|
221
|
+
if (!store) break;
|
|
222
|
+
const now = Date.now();
|
|
223
|
+
const lease = readLease();
|
|
224
|
+
if (lease && lease.expiresAt > now && lease.ownerNonce !== nonce) {
|
|
225
|
+
await waitForLeaseChange(Math.min(lease.expiresAt - now, 500));
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
store.setItem(
|
|
230
|
+
leaseKey,
|
|
231
|
+
JSON.stringify({
|
|
232
|
+
ownerNonce: nonce,
|
|
233
|
+
expiresAt: now + LEASE_MS,
|
|
234
|
+
} satisfies LeaseRecord)
|
|
235
|
+
);
|
|
236
|
+
} catch {
|
|
237
|
+
blocked = true;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
// localStorage has no compare-and-set: re-read after a randomized
|
|
241
|
+
// contention window and yield if another writer overwrote us.
|
|
242
|
+
await sleep(20 + Math.random() * 40);
|
|
243
|
+
if (readLease()?.ownerNonce !== nonce) {
|
|
244
|
+
await waitForLeaseChange(500);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
heldLeaseNonce = nonce;
|
|
248
|
+
try {
|
|
249
|
+
return await fn();
|
|
250
|
+
} finally {
|
|
251
|
+
heldLeaseNonce = null;
|
|
252
|
+
removeOwnLease(nonce);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// Cap or storage loss: proceed unlocked, the documented rare-race mode.
|
|
256
|
+
return fn();
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
return {
|
|
260
|
+
ready,
|
|
261
|
+
|
|
262
|
+
async get() {
|
|
263
|
+
await ready;
|
|
264
|
+
// Drift from a same-document sibling writer fires no storage event;
|
|
265
|
+
// reading is the only observation point, so count it as external.
|
|
266
|
+
observe(readRaw(), "external");
|
|
267
|
+
return lastKnown;
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
async set(token: string) {
|
|
271
|
+
await ready;
|
|
272
|
+
const store = localStore();
|
|
273
|
+
if (store) {
|
|
274
|
+
try {
|
|
275
|
+
store.setItem(storageKey, token);
|
|
276
|
+
} catch {
|
|
277
|
+
blocked = true;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
observe(token, "local");
|
|
281
|
+
},
|
|
282
|
+
|
|
283
|
+
async clear() {
|
|
284
|
+
await ready;
|
|
285
|
+
const store = localStore();
|
|
286
|
+
if (store) {
|
|
287
|
+
try {
|
|
288
|
+
store.removeItem(storageKey);
|
|
289
|
+
} catch {
|
|
290
|
+
blocked = true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
observe(null, "local");
|
|
294
|
+
},
|
|
295
|
+
|
|
296
|
+
revision() {
|
|
297
|
+
return currentRevision;
|
|
298
|
+
},
|
|
299
|
+
|
|
300
|
+
subscribe(callback) {
|
|
301
|
+
subscribers.add(callback);
|
|
302
|
+
return () => {
|
|
303
|
+
subscribers.delete(callback);
|
|
304
|
+
};
|
|
305
|
+
},
|
|
306
|
+
|
|
307
|
+
async withFirstInitLock(fn) {
|
|
308
|
+
await ready;
|
|
309
|
+
const locks = (
|
|
310
|
+
globalThis.navigator as Navigator & { locks?: LockManagerLike }
|
|
311
|
+
)?.locks;
|
|
312
|
+
if (locks?.request) {
|
|
313
|
+
return locks.request(lockName, () => fn());
|
|
314
|
+
}
|
|
315
|
+
// No-persistence and degraded-memory modes cannot coordinate tabs.
|
|
316
|
+
if (!localStore()) return fn();
|
|
317
|
+
return leaseLock(fn);
|
|
318
|
+
},
|
|
319
|
+
|
|
320
|
+
matches(otherToken, otherPrefix, otherPersistDisabled) {
|
|
321
|
+
return (
|
|
322
|
+
otherToken === clientToken &&
|
|
323
|
+
otherPrefix === keyPrefix &&
|
|
324
|
+
otherPersistDisabled === persistDisabled
|
|
325
|
+
);
|
|
326
|
+
},
|
|
327
|
+
|
|
328
|
+
destroy() {
|
|
329
|
+
destroyed = true;
|
|
330
|
+
subscribers.clear();
|
|
331
|
+
if (typeof window !== "undefined") {
|
|
332
|
+
window.removeEventListener("storage", onStorage);
|
|
333
|
+
}
|
|
334
|
+
if (heldLeaseNonce) removeOwnLease(heldLeaseNonce);
|
|
335
|
+
},
|
|
336
|
+
};
|
|
337
|
+
};
|
package/dist/chunk-QJ4LV2KW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var Kt=(e,t)=>{let n=document.createElement(e);return t&&(n.className=t),n};var Wt=()=>document.createDocumentFragment(),Ut=(e,t={},...n)=>{let o=document.createElement(e);if(t.className&&(o.className=t.className),t.text!==void 0&&(o.textContent=t.text),t.attrs)for(let[s,a]of Object.entries(t.attrs))o.setAttribute(s,a);if(t.style){let s=o.style,a=t.style;for(let c of Object.keys(a)){let l=a[c];l!=null&&(s[c]=l)}}let r=n.filter(s=>s!=null);return r.length>0&&o.append(...r),o},jt=(...e)=>e.filter(Boolean).join(" ");import{Activity as A,ArrowDown as k,ArrowUp as P,ArrowUpRight as L,Bot as I,ChevronDown as R,ChevronUp as D,ChevronRight as H,ChevronLeft as O,Check as z,Clipboard as B,ClipboardCopy as F,CodeXml as K,Copy as W,File as U,FileCode as j,FileSpreadsheet as $,FileText as q,ImagePlus as V,Loader as X,LoaderCircle as G,Mic as _,Paperclip as Y,RefreshCw as Z,Search as J,Send as Q,ShieldAlert as ee,ShieldCheck as te,ShieldX as ne,Square as oe,ThumbsDown as re,ThumbsUp as ie,Upload as se,Volume2 as ae,X as le,User as ce,Mail as de,Phone as ue,Calendar as me,Clock as pe,Building as ge,MapPin as he,Lock as fe,Key as we,CreditCard as ye,AtSign as be,Hash as ve,Globe as xe,Link as Ce,CircleCheck as Se,CircleX as Ee,TriangleAlert as Te,Info as Me,Ban as Ne,Shield as Ae,ArrowLeft as ke,ArrowRight as Pe,ExternalLink as Le,Ellipsis as Ie,EllipsisVertical as Re,Menu as De,House as He,Plus as Oe,Minus as ze,Pencil as Be,PenLine as Fe,Trash as Ke,Trash2 as We,Save as Ue,Download as je,Share as $e,Funnel as qe,Settings as Ve,RotateCw as Xe,Maximize as Ge,Minimize as _e,ShoppingCart as Ye,ShoppingBag as Ze,Package as Je,Truck as Qe,Tag as et,Gift as tt,Receipt as nt,Wallet as ot,Store as rt,DollarSign as it,Percent as st,Play as at,Pause as lt,VolumeX as ct,Camera as dt,Image as ut,Film as mt,Headphones as pt,MessageCircle as gt,MessageSquare as ht,Bell as ft,Heart as wt,Star as yt,Eye as bt,EyeOff as vt,Bookmark as xt,CalendarDays as Ct,History as St,Timer as Et,Folder as Tt,FolderOpen as Mt,Files as Nt,ChartColumn as At,Sparkles as kt,Zap as Pt,Sun as Lt,Moon as It,Flag as Rt,Lightbulb as Dt,Monitor as Ht,Smartphone as Ot}from"lucide";var zt={activity:A,"arrow-down":k,"arrow-up":P,"arrow-up-right":L,bot:I,"chevron-down":R,"chevron-up":D,"chevron-right":H,"chevron-left":O,check:z,clipboard:B,"clipboard-copy":F,"code-xml":K,copy:W,file:U,"file-code":j,"file-spreadsheet":$,"file-text":q,"image-plus":V,loader:X,"loader-circle":G,mic:_,paperclip:Y,"refresh-cw":Z,search:J,send:Q,"shield-alert":ee,"shield-check":te,"shield-x":ne,square:oe,"thumbs-down":re,"thumbs-up":ie,upload:se,"volume-2":ae,x:le,user:ce,mail:de,phone:ue,calendar:me,clock:pe,building:ge,"map-pin":he,lock:fe,key:we,"credit-card":ye,"at-sign":be,hash:ve,globe:xe,link:Ce,"circle-check":Se,"circle-x":Ee,"triangle-alert":Te,info:Me,ban:Ne,shield:Ae,"arrow-left":ke,"arrow-right":Pe,"external-link":Le,ellipsis:Ie,"ellipsis-vertical":Re,menu:De,house:He,plus:Oe,minus:ze,pencil:Be,"pen-line":Fe,trash:Ke,"trash-2":We,save:Ue,download:je,share:$e,funnel:qe,settings:Ve,"rotate-cw":Xe,maximize:Ge,minimize:_e,"shopping-cart":Ye,"shopping-bag":Ze,package:Je,truck:Qe,tag:et,gift:tt,receipt:nt,wallet:ot,store:rt,"dollar-sign":it,percent:st,play:at,pause:lt,"volume-x":ct,camera:dt,image:ut,film:mt,headphones:pt,"message-circle":gt,"message-square":ht,bell:ft,heart:wt,star:yt,eye:bt,"eye-off":vt,bookmark:xt,"calendar-days":Ct,history:St,timer:Et,folder:Tt,"folder-open":Mt,files:Nt,"chart-column":At,sparkles:kt,zap:Pt,sun:Lt,moon:It,flag:Rt,lightbulb:Dt,monitor:Ht,smartphone:Ot},Vt=(e,t=24,n="currentColor",o=2)=>{let r=zt[e];return r?Bt(r,t,n,o):(console.warn(`Lucide icon "${e}" is not in the Persona registry. Add it to packages/widget/src/utils/icons.ts (see docs/icon-registry-shortlist.md).`),null)};function Bt(e,t,n,o){if(!Array.isArray(e))return null;let r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("width",String(t)),r.setAttribute("height",String(t)),r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("fill","none"),r.setAttribute("stroke",n),r.setAttribute("stroke-width",String(o)),r.setAttribute("stroke-linecap","round"),r.setAttribute("stroke-linejoin","round"),r.setAttribute("aria-hidden","true"),e.forEach(s=>{if(!Array.isArray(s)||s.length<2)return;let a=s[0],c=s[1];if(!c)return;let l=document.createElementNS("http://www.w3.org/2000/svg",a);Object.entries(c).forEach(([h,f])=>{h!=="stroke"&&l.setAttribute(h,String(f))}),r.appendChild(l)}),r}function Gt(e){let t={trigger:e.trigger??"@",position:e.triggerPosition??"anywhere",allowSpaces:!1,sources:Array.isArray(e.sources)?e.sources:[],searchPlaceholder:e.searchPlaceholder,showButton:e.showButton!==!1,buttonIconName:e.buttonIconName,buttonTooltipText:e.buttonTooltipText},n=(e.triggers??[]).map(o=>({trigger:o.trigger,position:o.triggerPosition??"anywhere",allowSpaces:o.allowSpaces??!1,sources:Array.isArray(o.sources)?o.sources:[],searchPlaceholder:o.searchPlaceholder,showButton:o.showButton===!0,buttonIconName:o.buttonIconName,buttonTooltipText:o.buttonTooltipText}));return[t,...n]}function T(e){let t=e.getRootNode?.();return t instanceof ShadowRoot||t instanceof Document?t:e.ownerDocument??document}function b(e,t,n){let o=e instanceof Document?e.head:e,r=t.replace(/["\\]/g,"\\$&");if(o.querySelector(`style[data-persona-plugin-style="${r}"]`))return;let a=(e instanceof Document?e:e.ownerDocument??document).createElement("style");a.setAttribute("data-persona-plugin-style",t),a.textContent=n,o.appendChild(a)}function Yt(e,t,n){if(e instanceof Document||e instanceof ShadowRoot){b(e,t,n);return}let o=e;if(o.isConnected){b(T(o),t,n);return}let r=o.ownerDocument??document;b(r,t,n),queueMicrotask(()=>{let s=T(o);s!==r&&b(s,t,n)})}function Ft(e){let t=e.getRootNode?.();return t instanceof ShadowRoot?t:(e.ownerDocument??document).body}function Zt(e){let{anchor:t,content:n,placement:o="bottom-start",offset:r=6,matchAnchorWidth:s=!1,horizontalOffset:a,verticalOffset:c,zIndex:l=2147483e3,onOpen:h,onDismiss:f}=e,M=e.container??Ft(t),d=!1,w=null,v=()=>{if(!d)return;let i=t.getBoundingClientRect();n.style.position="fixed",s&&(n.style.minWidth=`${i.width}px`),a&&(n.style.maxWidth=`${i.width}px`);let m=n.getBoundingClientRect(),u=c?.()??null,y=u!=null?i.top+u:i.top,x=o==="top-start"||o==="top-end"?y-r-m.height:i.bottom+r,g=o==="bottom-end"||o==="top-end"?i.right-m.width:i.left,E=a?.()??null;if(E!=null){let N=Math.max(i.left,i.right-m.width);g=Math.min(Math.max(i.left+E,i.left),N)}n.style.top=`${x}px`,n.style.left=`${g}px`},p=()=>{d&&(d=!1,w&&(w(),w=null),n.remove())},S=()=>{if(d)return;d=!0,l!=null&&(n.style.zIndex=String(l)),M.appendChild(n),v();let i=(t.ownerDocument??document).defaultView??window,m=t.ownerDocument??document,u=()=>{if(!t.isConnected){p(),f?.("anchor-removed");return}v()},y=C=>{let g=typeof C.composedPath=="function"?C.composedPath():[];g.includes(n)||g.includes(t)||(p(),f?.("outside"))},x=i.setTimeout(()=>{m.addEventListener("pointerdown",y,!0)},0);i.addEventListener("scroll",u,!0),i.addEventListener("resize",u),w=()=>{i.clearTimeout(x),m.removeEventListener("pointerdown",y,!0),i.removeEventListener("scroll",u,!0),i.removeEventListener("resize",u)},h?.()};return{get isOpen(){return d},open:S,close:p,toggle:()=>d?p():S(),reposition:v,destroy:p}}function Jt(e){return(typeof e.composedPath=="function"?e.composedPath():[]).some(n=>n instanceof HTMLElement&&(n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.isContentEditable))}export{Kt as a,Wt as b,Ut as c,jt as d,Vt as e,Gt as f,Yt as g,Zt as h,Jt as i};
|