@heroui/agent 0.2.0-beta.8 → 0.2.0-beta.9

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/chart-content-BBHQVMP4.js +1 -0
  3. package/dist/chunk-2XBFFSW2.js +1 -0
  4. package/dist/chunk-64RI74L5.js +1 -0
  5. package/dist/chunk-6ZJJN322.js +1 -0
  6. package/dist/chunk-7KCGPNEN.js +1 -0
  7. package/dist/chunk-BBB5EHDN.js +5 -0
  8. package/dist/chunk-CR3H7AVI.js +1 -0
  9. package/dist/chunk-HCLXS4HQ.js +1 -0
  10. package/dist/chunk-MXLGM4WV.js +1 -0
  11. package/dist/chunk-OA3TG5CS.js +1 -0
  12. package/dist/chunk-PZJ4NC3J.js +1 -0
  13. package/dist/chunk-RNNGE7KM.js +1 -0
  14. package/dist/chunk-S6OIAJSC.js +1 -0
  15. package/dist/chunk-SUDHJNTJ.js +2 -0
  16. package/dist/chunk-WUAFMD7Z.js +2 -0
  17. package/dist/component-renderer-GG6JVRUG.js +1 -0
  18. package/dist/composer-draft-NSKK65F3.js +1 -0
  19. package/dist/composer-image-draft-KAGTNQR7.js +1 -0
  20. package/dist/contracts.d.ts +1 -1
  21. package/dist/contracts.js +2 -2445
  22. package/dist/embed-runtime-GYXK7V6N.js +5 -0
  23. package/dist/index.js +1 -31
  24. package/dist/interactive-map-surface-WC2LPCR7.js +1 -0
  25. package/dist/internal/client-tools.js +1 -0
  26. package/dist/internal/models.js +1 -0
  27. package/dist/internal/runtime.js +1 -0
  28. package/dist/internal/theme.js +1 -0
  29. package/dist/next.js +1 -25
  30. package/dist/server.js +1 -136
  31. package/package.json +4 -4
  32. package/dist/chart-content-E4NPTUPR.js +0 -2696
  33. package/dist/chunk-3FG5NRTX.js +0 -9
  34. package/dist/chunk-CMZDZGUZ.js +0 -1132
  35. package/dist/chunk-DS4X5K2R.js +0 -56
  36. package/dist/chunk-FNGGMHVR.js +0 -625
  37. package/dist/chunk-G6GFNSG4.js +0 -284
  38. package/dist/chunk-Q7LGTVBL.js +0 -43
  39. package/dist/chunk-TOOT6SZ2.js +0 -74
  40. package/dist/chunk-UUPU3MYB.js +0 -42
  41. package/dist/chunk-VJA52U5P.js +0 -137
  42. package/dist/chunk-W7SCMB3O.js +0 -1285
  43. package/dist/component-renderer-MDDQMQTU.js +0 -10629
  44. package/dist/composer-draft-DTQAEO5K.js +0 -20
  45. package/dist/composer-image-draft-IVJ352E6.js +0 -174
  46. package/dist/embed-runtime-VVAGDPYY.js +0 -9422
  47. package/dist/interactive-map-surface-67KHT3VB.js +0 -362
@@ -1,20 +0,0 @@
1
- import {
2
- agentComposerDraftStorageKey,
3
- clearAgentComposerDraft,
4
- clearAgentComposerDraftsForProject,
5
- readAgentComposerImageDraft,
6
- saveAgentComposerImageDraft
7
- } from "./chunk-DS4X5K2R.js";
8
- import {
9
- readAgentComposerPromptDraft,
10
- saveAgentComposerPromptDraft
11
- } from "./chunk-UUPU3MYB.js";
12
- export {
13
- agentComposerDraftStorageKey,
14
- clearAgentComposerDraft,
15
- clearAgentComposerDraftsForProject,
16
- readAgentComposerImageDraft,
17
- readAgentComposerPromptDraft,
18
- saveAgentComposerImageDraft,
19
- saveAgentComposerPromptDraft
20
- };
@@ -1,174 +0,0 @@
1
- import {
2
- AGENT_COMPOSER_DRAFT_MAX_AGE_MS
3
- } from "./chunk-UUPU3MYB.js";
4
-
5
- // src/embed/composer-image-draft.ts
6
- var AGENT_COMPOSER_DRAFT_DB_NAME = "heroui-agent-embed";
7
- var AGENT_COMPOSER_DRAFT_DB_VERSION = 1;
8
- var AGENT_COMPOSER_IMAGE_DRAFT_STORE = "composer-image-drafts";
9
- var pendingImageDraftMutations = /* @__PURE__ */ new Map();
10
- async function readAgentComposerImageDraft(key, now = Date.now()) {
11
- await pendingImageDraftMutations.get(key);
12
- const stored = await readImageDraftRecord(key);
13
- if (!stored) return [];
14
- const isFresh = now - stored.savedAt <= AGENT_COMPOSER_DRAFT_MAX_AGE_MS;
15
- const files = stored.files;
16
- if (!isFresh || files.length === 0) {
17
- await queueImageDraftMutation(key, () => deleteImageDraftRecord(key));
18
- return [];
19
- }
20
- return files;
21
- }
22
- function saveAgentComposerImageDraft(key, files, now = Date.now()) {
23
- const images = files.filter(isPersistableImageFile);
24
- return queueImageDraftMutation(key, async () => {
25
- if (images.length === 0) {
26
- await deleteImageDraftRecord(key);
27
- return;
28
- }
29
- const storedFiles = await Promise.all(images.map(serializeFile));
30
- await writeImageDraftRecord({ files: storedFiles, key, savedAt: now });
31
- });
32
- }
33
- function clearAgentComposerImageDraft(key) {
34
- return queueImageDraftMutation(key, () => deleteImageDraftRecord(key));
35
- }
36
- async function clearAgentComposerImageDraftsForProject(prefix) {
37
- const pending = [...pendingImageDraftMutations.entries()].filter(([key]) => key.startsWith(prefix)).map(([, mutation]) => mutation);
38
- await Promise.all(pending);
39
- await deleteImageDraftRecordsByPrefix(prefix);
40
- }
41
- function isPersistableImageFile(value) {
42
- return typeof File !== "undefined" && value instanceof File && typeof value.type === "string" && value.type.startsWith("image/");
43
- }
44
- async function serializeFile(file) {
45
- return {
46
- bytes: await file.arrayBuffer(),
47
- lastModified: file.lastModified,
48
- name: file.name,
49
- type: file.type
50
- };
51
- }
52
- function restoreImageFile(value) {
53
- if (isPersistableImageFile(value)) return value;
54
- if (typeof File === "undefined" || !value || typeof value !== "object") return null;
55
- const file = value;
56
- if (!isArrayBuffer(file.bytes) || typeof file.lastModified !== "number" || typeof file.name !== "string" || typeof file.type !== "string" || !file.type.startsWith("image/")) {
57
- return null;
58
- }
59
- return new File([file.bytes], file.name, {
60
- lastModified: file.lastModified,
61
- type: file.type
62
- });
63
- }
64
- function isArrayBuffer(value) {
65
- return Object.prototype.toString.call(value) === "[object ArrayBuffer]";
66
- }
67
- function queueImageDraftMutation(key, mutation) {
68
- const previous = pendingImageDraftMutations.get(key) ?? Promise.resolve();
69
- const next = previous.catch(() => void 0).then(mutation).catch(() => void 0);
70
- pendingImageDraftMutations.set(key, next);
71
- void next.finally(() => {
72
- if (pendingImageDraftMutations.get(key) === next) pendingImageDraftMutations.delete(key);
73
- });
74
- return next;
75
- }
76
- function openImageDraftDatabase() {
77
- if (typeof indexedDB === "undefined") return Promise.resolve(null);
78
- return new Promise((resolve) => {
79
- const request = indexedDB.open(AGENT_COMPOSER_DRAFT_DB_NAME, AGENT_COMPOSER_DRAFT_DB_VERSION);
80
- request.onerror = () => resolve(null);
81
- request.onupgradeneeded = () => {
82
- const database = request.result;
83
- if (!database.objectStoreNames.contains(AGENT_COMPOSER_IMAGE_DRAFT_STORE)) {
84
- database.createObjectStore(AGENT_COMPOSER_IMAGE_DRAFT_STORE, { keyPath: "key" });
85
- }
86
- };
87
- request.onsuccess = () => resolve(request.result);
88
- });
89
- }
90
- async function withImageDraftStore(mode, run) {
91
- let database;
92
- try {
93
- database = await openImageDraftDatabase();
94
- } catch {
95
- return null;
96
- }
97
- if (!database) return null;
98
- try {
99
- const transaction = database.transaction(AGENT_COMPOSER_IMAGE_DRAFT_STORE, mode);
100
- const completion = waitForTransaction(transaction);
101
- const [result] = await Promise.all([
102
- run(transaction.objectStore(AGENT_COMPOSER_IMAGE_DRAFT_STORE)),
103
- completion
104
- ]);
105
- return result;
106
- } catch {
107
- return null;
108
- } finally {
109
- database.close();
110
- }
111
- }
112
- async function readImageDraftRecord(key) {
113
- const result = await withImageDraftStore(
114
- "readonly",
115
- (store) => waitForRequest(store.get(key))
116
- );
117
- if (typeof result !== "object" || result === null) return null;
118
- const draft = result;
119
- if (draft.key !== key || typeof draft.savedAt !== "number" || !Array.isArray(draft.files)) {
120
- return null;
121
- }
122
- return {
123
- files: draft.files.map(restoreImageFile).filter((file) => file !== null),
124
- key,
125
- savedAt: draft.savedAt
126
- };
127
- }
128
- async function writeImageDraftRecord(draft) {
129
- await withImageDraftStore("readwrite", async (store) => {
130
- await waitForRequest(store.put(draft));
131
- });
132
- }
133
- async function deleteImageDraftRecord(key) {
134
- await withImageDraftStore("readwrite", async (store) => {
135
- await waitForRequest(store.delete(key));
136
- });
137
- }
138
- async function deleteImageDraftRecordsByPrefix(prefix) {
139
- await withImageDraftStore(
140
- "readwrite",
141
- (store) => new Promise((resolve, reject) => {
142
- const request = store.openCursor();
143
- request.onerror = () => reject(request.error ?? new Error("Unable to clear image drafts"));
144
- request.onsuccess = () => {
145
- const cursor = request.result;
146
- if (!cursor) {
147
- resolve();
148
- return;
149
- }
150
- if (typeof cursor.key === "string" && cursor.key.startsWith(prefix)) cursor.delete();
151
- cursor.continue();
152
- };
153
- })
154
- );
155
- }
156
- function waitForRequest(request) {
157
- return new Promise((resolve, reject) => {
158
- request.onerror = () => reject(request.error ?? new Error("IndexedDB request failed"));
159
- request.onsuccess = () => resolve(request.result);
160
- });
161
- }
162
- function waitForTransaction(transaction) {
163
- return new Promise((resolve, reject) => {
164
- transaction.onabort = () => reject(transaction.error ?? new Error("IndexedDB aborted"));
165
- transaction.onerror = () => reject(transaction.error ?? new Error("IndexedDB failed"));
166
- transaction.oncomplete = () => resolve();
167
- });
168
- }
169
- export {
170
- clearAgentComposerImageDraft,
171
- clearAgentComposerImageDraftsForProject,
172
- readAgentComposerImageDraft,
173
- saveAgentComposerImageDraft
174
- };