@meistrari/chat-nuxt 1.1.2 → 1.2.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.
Files changed (151) hide show
  1. package/README.md +95 -11
  2. package/dist/module.d.mts +5 -0
  3. package/dist/module.json +2 -2
  4. package/dist/module.mjs +96 -23
  5. package/dist/runtime/components/chat/conversation-list.d.vue.ts +1 -0
  6. package/dist/runtime/components/chat/conversation-list.vue +22 -2
  7. package/dist/runtime/components/chat/conversation-list.vue.d.ts +1 -0
  8. package/dist/runtime/components/chat/message-list.d.vue.ts +1 -0
  9. package/dist/runtime/components/chat/message-list.vue +23 -2
  10. package/dist/runtime/components/chat/message-list.vue.d.ts +1 -0
  11. package/dist/runtime/composables/useChat.d.ts +2 -1
  12. package/dist/runtime/composables/useChat.js +32 -3
  13. package/dist/runtime/composables/useChatApi.js +2 -1
  14. package/dist/runtime/composables/useConversations.d.ts +3 -2
  15. package/dist/runtime/composables/useConversations.js +99 -11
  16. package/dist/runtime/composables/useEmbedConfig.d.ts +11 -6
  17. package/dist/runtime/composables/useEmbedConfig.js +35 -7
  18. package/dist/runtime/composables/useIDB.js +4 -0
  19. package/dist/runtime/composables/usePdf.d.ts +840 -1
  20. package/dist/runtime/composables/usePdf.js +21 -3
  21. package/dist/runtime/composables/useWorkspaceContextFiles.d.ts +3 -3
  22. package/dist/runtime/composables/useWorkspaceContextFiles.js +19 -10
  23. package/dist/runtime/composables/useWorkspaceCredentials.d.ts +3 -3
  24. package/dist/runtime/composables/useWorkspaceExternalSkills.d.ts +1 -1
  25. package/dist/runtime/composables/useWorkspaceExternalSkills.js +5 -6
  26. package/dist/runtime/composables/useWorkspacePersonalization.d.ts +1 -1
  27. package/dist/runtime/composables/useWorkspacePersonalization.js +4 -5
  28. package/dist/runtime/composables/useWorkspaceSettings.js +12 -9
  29. package/dist/runtime/embed/components/ChatConfigurationModal.d.vue.ts +25 -0
  30. package/dist/runtime/embed/components/ChatConfigurationModal.vue +373 -0
  31. package/dist/runtime/embed/components/ChatConfigurationModal.vue.d.ts +25 -0
  32. package/dist/runtime/embed/components/ChatEmbed.vue +12 -1
  33. package/dist/runtime/embed/components/ChatEmbedInner.vue +31 -16
  34. package/dist/runtime/embed/components/configuration/ChatConfigurationContextFilesTab.d.vue.ts +22 -0
  35. package/dist/runtime/embed/components/configuration/ChatConfigurationContextFilesTab.vue +133 -0
  36. package/dist/runtime/embed/components/configuration/ChatConfigurationContextFilesTab.vue.d.ts +22 -0
  37. package/dist/runtime/embed/components/configuration/ChatConfigurationCredentialsTab.d.vue.ts +10 -0
  38. package/dist/runtime/embed/components/configuration/ChatConfigurationCredentialsTab.vue +220 -0
  39. package/dist/runtime/embed/components/configuration/ChatConfigurationCredentialsTab.vue.d.ts +10 -0
  40. package/dist/runtime/embed/components/configuration/ChatConfigurationExternalSkillsTab.d.vue.ts +32 -0
  41. package/dist/runtime/embed/components/configuration/ChatConfigurationExternalSkillsTab.vue +222 -0
  42. package/dist/runtime/embed/components/configuration/ChatConfigurationExternalSkillsTab.vue.d.ts +32 -0
  43. package/dist/runtime/embed/components/configuration/ChatConfigurationKnowledgeSourcesTab.d.vue.ts +18 -0
  44. package/dist/runtime/embed/components/configuration/ChatConfigurationKnowledgeSourcesTab.vue +142 -0
  45. package/dist/runtime/embed/components/configuration/ChatConfigurationKnowledgeSourcesTab.vue.d.ts +18 -0
  46. package/dist/runtime/embed/components/configuration/ChatConfigurationPersonalizationTab.d.vue.ts +10 -0
  47. package/dist/runtime/embed/components/configuration/ChatConfigurationPersonalizationTab.vue +37 -0
  48. package/dist/runtime/embed/components/configuration/ChatConfigurationPersonalizationTab.vue.d.ts +10 -0
  49. package/dist/runtime/embed/components/configuration/ChatConfigurationTelaToolsTab.d.vue.ts +20 -0
  50. package/dist/runtime/embed/components/configuration/ChatConfigurationTelaToolsTab.vue +146 -0
  51. package/dist/runtime/embed/components/configuration/ChatConfigurationTelaToolsTab.vue.d.ts +20 -0
  52. package/dist/runtime/server/api/admin/trigger-usage-report.post.d.ts +4 -1
  53. package/dist/runtime/server/api/admin/trigger-usage-report.post.js +2 -0
  54. package/dist/runtime/server/api/chat/workspace/settings.get.d.ts +1 -1
  55. package/dist/runtime/server/api/chat/workspace/settings.get.js +1 -0
  56. package/dist/runtime/server/api/conversations/[id]/cancel.post.d.ts +4 -1
  57. package/dist/runtime/server/api/conversations/[id]/cancel.post.js +1 -0
  58. package/dist/runtime/server/api/conversations/[id]/clear.post.d.ts +1 -1
  59. package/dist/runtime/server/api/conversations/[id]/clear.post.js +1 -0
  60. package/dist/runtime/server/api/conversations/[id]/duplicate.post.d.ts +1 -1
  61. package/dist/runtime/server/api/conversations/[id]/duplicate.post.js +46 -12
  62. package/dist/runtime/server/api/conversations/[id]/files.get.d.ts +1 -1
  63. package/dist/runtime/server/api/conversations/[id]/files.get.js +2 -0
  64. package/dist/runtime/server/api/conversations/[id]/index.delete.d.ts +3 -1
  65. package/dist/runtime/server/api/conversations/[id]/index.delete.js +1 -0
  66. package/dist/runtime/server/api/conversations/[id]/index.get.d.ts +1 -1
  67. package/dist/runtime/server/api/conversations/[id]/index.get.js +1 -0
  68. package/dist/runtime/server/api/conversations/[id]/index.patch.d.ts +1 -1
  69. package/dist/runtime/server/api/conversations/[id]/index.patch.js +1 -0
  70. package/dist/runtime/server/api/conversations/[id]/messages/[messageId]/retry.post.d.ts +1 -1
  71. package/dist/runtime/server/api/conversations/[id]/messages/[messageId]/retry.post.js +2 -0
  72. package/dist/runtime/server/api/conversations/[id]/messages/index.get.d.ts +14 -1
  73. package/dist/runtime/server/api/conversations/[id]/messages/index.get.js +2 -0
  74. package/dist/runtime/server/api/conversations/[id]/messages/index.post.d.ts +4 -1
  75. package/dist/runtime/server/api/conversations/[id]/messages/index.post.js +2 -0
  76. package/dist/runtime/server/api/conversations/[id]/usage.get.d.ts +1 -1
  77. package/dist/runtime/server/api/conversations/[id]/usage.get.js +1 -0
  78. package/dist/runtime/server/api/conversations/generate-title.post.d.ts +3 -1
  79. package/dist/runtime/server/api/conversations/generate-title.post.js +2 -0
  80. package/dist/runtime/server/api/conversations/index.get.d.ts +1 -1
  81. package/dist/runtime/server/api/conversations/index.get.js +1 -0
  82. package/dist/runtime/server/api/conversations/index.post.d.ts +1 -1
  83. package/dist/runtime/server/api/conversations/index.post.js +1 -0
  84. package/dist/runtime/server/api/external-skills/discover.post.d.ts +1 -1
  85. package/dist/runtime/server/api/external-skills/discover.post.js +2 -0
  86. package/dist/runtime/server/api/github/disconnect.post.d.ts +3 -1
  87. package/dist/runtime/server/api/github/disconnect.post.js +2 -0
  88. package/dist/runtime/server/api/github/status.get.d.ts +1 -1
  89. package/dist/runtime/server/api/github/status.get.js +2 -0
  90. package/dist/runtime/server/api/tela/canvas.get.d.ts +1 -1
  91. package/dist/runtime/server/api/tela/canvas.get.js +1 -0
  92. package/dist/runtime/server/api/tela/projects.get.d.ts +1 -1
  93. package/dist/runtime/server/api/tela/projects.get.js +1 -0
  94. package/dist/runtime/server/api/tela/workspaces.get.d.ts +1 -1
  95. package/dist/runtime/server/api/tela/workspaces.get.js +1 -0
  96. package/dist/runtime/server/api/tela/workstations.get.d.ts +1 -1
  97. package/dist/runtime/server/api/tela/workstations.get.js +1 -0
  98. package/dist/runtime/server/api/vault/permalink-metadata.post.d.ts +5 -1
  99. package/dist/runtime/server/api/vault/permalink-metadata.post.js +2 -0
  100. package/dist/runtime/server/api/vault/resolve.post.d.ts +9 -1
  101. package/dist/runtime/server/api/vault/resolve.post.js +2 -0
  102. package/dist/runtime/server/api/vault/upload.post.d.ts +6 -1
  103. package/dist/runtime/server/api/vault/upload.post.js +2 -0
  104. package/dist/runtime/server/api/workspace/credentials/[id].delete.d.ts +3 -1
  105. package/dist/runtime/server/api/workspace/credentials/[id].delete.js +1 -0
  106. package/dist/runtime/server/api/workspace/credentials/[id].put.d.ts +1 -1
  107. package/dist/runtime/server/api/workspace/credentials/[id].put.js +1 -0
  108. package/dist/runtime/server/api/workspace/credentials/index.get.d.ts +1 -1
  109. package/dist/runtime/server/api/workspace/credentials/index.get.js +1 -0
  110. package/dist/runtime/server/api/workspace/credentials/index.post.d.ts +1 -1
  111. package/dist/runtime/server/api/workspace/credentials/index.post.js +1 -0
  112. package/dist/runtime/server/api/workspace/settings.get.d.ts +1 -1
  113. package/dist/runtime/server/api/workspace/settings.get.js +1 -0
  114. package/dist/runtime/server/api/workspace/settings.patch.d.ts +1 -1
  115. package/dist/runtime/server/api/workspace/settings.patch.js +1 -0
  116. package/dist/runtime/server/api/workspace/usage.get.d.ts +1 -1
  117. package/dist/runtime/server/api/workspace/usage.get.js +1 -0
  118. package/dist/runtime/server/db/index.js +1 -0
  119. package/dist/runtime/server/middleware/domain-validation.d.ts +1 -1
  120. package/dist/runtime/server/middleware/domain-validation.js +2 -0
  121. package/dist/runtime/server/middleware/request-logger.d.ts +1 -1
  122. package/dist/runtime/server/middleware/request-logger.js +1 -0
  123. package/dist/runtime/server/tasks/send-daily-usage-report.d.ts +1 -1
  124. package/dist/runtime/server/tasks/send-daily-usage-report.js +1 -0
  125. package/dist/runtime/server/utils/agent-api.d.ts +1 -1
  126. package/dist/runtime/server/utils/agent-api.js +2 -0
  127. package/dist/runtime/server/utils/auth-api.js +2 -0
  128. package/dist/runtime/server/utils/auth.d.ts +1 -1
  129. package/dist/runtime/server/utils/auth.js +1 -0
  130. package/dist/runtime/server/utils/tela-api.d.ts +1 -1
  131. package/dist/runtime/server/utils/tela-api.js +2 -0
  132. package/dist/runtime/server/utils/workspace.js +1 -0
  133. package/dist/runtime/types/chat.d.ts +2 -1
  134. package/dist/runtime/types/workspace-settings.d.ts +3 -0
  135. package/dist/runtime/types/workspace-settings.js +0 -0
  136. package/dist/runtime/utils/conversation-list-skeleton.d.ts +31 -0
  137. package/dist/runtime/utils/conversation-list-skeleton.js +12 -0
  138. package/dist/runtime/utils/file.js +42 -42
  139. package/dist/types.d.mts +2 -0
  140. package/package.json +24 -12
  141. package/dist/runtime/composables/PageNavigation.d.ts +0 -13
  142. package/dist/runtime/composables/PageNavigation.js +0 -18
  143. /package/dist/runtime/components/{TelaChat.d.vue.ts → MeistrariChatEmbed.d.vue.ts} +0 -0
  144. /package/dist/runtime/components/{TelaChat.vue → MeistrariChatEmbed.vue} +0 -0
  145. /package/dist/runtime/components/{TelaChat.vue.d.ts → MeistrariChatEmbed.vue.d.ts} +0 -0
  146. /package/dist/runtime/components/{pdf-preview.d.vue.ts → pdf-preview.client.d.vue.ts} +0 -0
  147. /package/dist/runtime/components/{pdf-preview.vue → pdf-preview.client.vue} +0 -0
  148. /package/dist/runtime/components/{pdf-preview.vue.d.ts → pdf-preview.client.vue.d.ts} +0 -0
  149. /package/dist/runtime/components/{pdf-viewer.d.vue.ts → pdf-viewer.client.d.vue.ts} +0 -0
  150. /package/dist/runtime/components/{pdf-viewer.vue → pdf-viewer.client.vue} +0 -0
  151. /package/dist/runtime/components/{pdf-viewer.vue.d.ts → pdf-viewer.client.vue.d.ts} +0 -0
@@ -1,11 +1,38 @@
1
1
  import * as Sentry from "@sentry/nuxt";
2
+ function sortConversationsByUpdatedAt(conversations) {
3
+ return [...conversations].sort(
4
+ (a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
5
+ );
6
+ }
7
+ export function mergeFetchedConversations(fetchedConversations, localConversations, deletedConversationIds = [], locallyMutatedConversationIds = []) {
8
+ const deletedIds = new Set(deletedConversationIds);
9
+ const locallyMutatedIds = new Set(locallyMutatedConversationIds);
10
+ const mergedById = /* @__PURE__ */ new Map();
11
+ for (const conversation of fetchedConversations) {
12
+ if (!deletedIds.has(conversation.id)) {
13
+ mergedById.set(conversation.id, conversation);
14
+ }
15
+ }
16
+ for (const conversation of localConversations) {
17
+ if (!deletedIds.has(conversation.id)) {
18
+ if (!mergedById.has(conversation.id) || locallyMutatedIds.has(conversation.id)) {
19
+ mergedById.set(conversation.id, conversation);
20
+ }
21
+ }
22
+ }
23
+ return sortConversationsByUpdatedAt([...mergedById.values()]);
24
+ }
2
25
  export function useConversations() {
3
26
  const chatApi = useChatApi();
4
27
  const embedConfig = useEmbedConfig();
28
+ const { activeOrganization } = useTelaApplicationAuth();
5
29
  const conversationBuckets = useState("conversations", () => ({}));
6
30
  const loadingBuckets = useState("conversations-loading", () => ({}));
7
31
  const errorBuckets = useState("conversations-error", () => ({}));
8
- const workspaceScope = computed(() => embedConfig?.workspaceId.value.trim() || "default");
32
+ const mutationVersionBuckets = useState("conversations-mutation-version", () => ({}));
33
+ const deletedIdBuckets = useState("conversations-deleted-ids", () => ({}));
34
+ const mutatedIdBuckets = useState("conversations-mutated-ids", () => ({}));
35
+ const workspaceScope = computed(() => embedConfig?.workspaceId.value.trim() || activeOrganization.value?.id?.trim() || "default");
9
36
  const conversations = computed({
10
37
  get: () => conversationBuckets.value[workspaceScope.value] ?? [],
11
38
  set: (value) => {
@@ -15,6 +42,33 @@ export function useConversations() {
15
42
  };
16
43
  }
17
44
  });
45
+ const mutationVersion = computed({
46
+ get: () => mutationVersionBuckets.value[workspaceScope.value] ?? 0,
47
+ set: (value) => {
48
+ mutationVersionBuckets.value = {
49
+ ...mutationVersionBuckets.value,
50
+ [workspaceScope.value]: value
51
+ };
52
+ }
53
+ });
54
+ const deletedConversationIds = computed({
55
+ get: () => deletedIdBuckets.value[workspaceScope.value] ?? [],
56
+ set: (value) => {
57
+ deletedIdBuckets.value = {
58
+ ...deletedIdBuckets.value,
59
+ [workspaceScope.value]: value
60
+ };
61
+ }
62
+ });
63
+ const mutatedConversationIds = computed({
64
+ get: () => mutatedIdBuckets.value[workspaceScope.value] ?? [],
65
+ set: (value) => {
66
+ mutatedIdBuckets.value = {
67
+ ...mutatedIdBuckets.value,
68
+ [workspaceScope.value]: value
69
+ };
70
+ }
71
+ });
18
72
  const loading = computed({
19
73
  get: () => loadingBuckets.value[workspaceScope.value] ?? false,
20
74
  set: (value) => {
@@ -33,6 +87,28 @@ export function useConversations() {
33
87
  };
34
88
  }
35
89
  });
90
+ function markMutated(id) {
91
+ mutationVersion.value = mutationVersion.value + 1;
92
+ if (id) {
93
+ mutatedConversationIds.value = [.../* @__PURE__ */ new Set([...mutatedConversationIds.value, id])];
94
+ }
95
+ }
96
+ function commitConversations(nextConversations, mutatedId) {
97
+ conversations.value = sortConversationsByUpdatedAt(nextConversations);
98
+ markMutated(mutatedId);
99
+ }
100
+ function addDeletedConversationId(id) {
101
+ deletedConversationIds.value = [.../* @__PURE__ */ new Set([...deletedConversationIds.value, id])];
102
+ markMutated();
103
+ }
104
+ function removeDeletedConversationId(id) {
105
+ deletedConversationIds.value = deletedConversationIds.value.filter((deletedId) => deletedId !== id);
106
+ markMutated();
107
+ }
108
+ function pruneDeletedConversationIds(serverConversations) {
109
+ const returnedIds = new Set(serverConversations.map((conversation) => conversation.id));
110
+ deletedConversationIds.value = deletedConversationIds.value.filter((id) => returnedIds.has(id));
111
+ }
36
112
  function cloneAppliedSettingsSnapshot(snapshot) {
37
113
  if (!snapshot)
38
114
  return null;
@@ -41,12 +117,26 @@ export function useConversations() {
41
117
  const fetchConversations = async () => {
42
118
  loading.value = true;
43
119
  error.value = null;
120
+ const mutationVersionAtStart = mutationVersion.value;
44
121
  try {
45
122
  const data = await $fetch(
46
123
  chatApi.path("/conversations"),
47
124
  chatApi.withChatHeaders()
48
125
  );
49
- conversations.value = data;
126
+ const visibleData = data.filter((conversation) => !deletedConversationIds.value.includes(conversation.id));
127
+ if (mutationVersion.value === mutationVersionAtStart) {
128
+ conversations.value = sortConversationsByUpdatedAt(visibleData);
129
+ mutatedConversationIds.value = [];
130
+ } else {
131
+ conversations.value = mergeFetchedConversations(
132
+ visibleData,
133
+ conversations.value,
134
+ deletedConversationIds.value,
135
+ mutatedConversationIds.value
136
+ );
137
+ mutatedConversationIds.value = [];
138
+ }
139
+ pruneDeletedConversationIds(data);
50
140
  } catch (err) {
51
141
  const message = err instanceof Error ? err.message : "Erro ao carregar conversas";
52
142
  error.value = message;
@@ -65,7 +155,7 @@ export function useConversations() {
65
155
  body: options?.model ? { model: options.model } : void 0
66
156
  })
67
157
  );
68
- conversations.value = [conversation, ...conversations.value];
158
+ commitConversations([conversation, ...conversations.value], conversation.id);
69
159
  return conversation;
70
160
  } catch (err) {
71
161
  const message = err instanceof Error ? err.message : "Erro ao criar conversa";
@@ -77,7 +167,8 @@ export function useConversations() {
77
167
  error.value = null;
78
168
  const statusToast = useStatusToast();
79
169
  const deletedConversation = conversations.value.find((c) => c.id === id);
80
- conversations.value = conversations.value.filter((c) => c.id !== id);
170
+ addDeletedConversationId(id);
171
+ commitConversations(conversations.value.filter((c) => c.id !== id), id);
81
172
  try {
82
173
  await $fetch(
83
174
  chatApi.path(`/conversations/${id}`),
@@ -91,10 +182,9 @@ export function useConversations() {
91
182
  });
92
183
  return true;
93
184
  } catch (err) {
185
+ removeDeletedConversationId(id);
94
186
  if (deletedConversation) {
95
- conversations.value = [...conversations.value, deletedConversation].sort(
96
- (a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
97
- );
187
+ commitConversations([...conversations.value, deletedConversation], deletedConversation.id);
98
188
  }
99
189
  const message = err instanceof Error ? err.message : "Erro ao deletar conversa";
100
190
  error.value = message;
@@ -122,9 +212,7 @@ export function useConversations() {
122
212
  createdAt: updated.createdAt,
123
213
  updatedAt: updated.updatedAt
124
214
  };
125
- conversations.value = nextConversations.sort(
126
- (a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
127
- );
215
+ commitConversations(nextConversations, updated.id);
128
216
  }
129
217
  };
130
218
  const renameConversation = async (id, title) => {
@@ -161,7 +249,7 @@ export function useConversations() {
161
249
  method: "POST"
162
250
  })
163
251
  );
164
- conversations.value = [duplicated, ...conversations.value];
252
+ commitConversations([duplicated, ...conversations.value], duplicated.id);
165
253
  statusToast.update({
166
254
  text: "Conversa duplicada",
167
255
  icon: "i-ph-check"
@@ -1,13 +1,18 @@
1
- import type { DeepReadonly, Ref } from 'vue';
1
+ import type { DeepReadonly, MaybeRefOrGetter, Ref } from 'vue';
2
2
  import type { WorkspaceSettings } from './useWorkspaceSettings.js';
3
3
  export type EmbedConfig = {
4
4
  workspaceId: Ref<string>;
5
5
  workspaceSettings: Ref<DeepReadonly<WorkspaceSettings> | WorkspaceSettings | null | undefined>;
6
6
  hideSidebar: Ref<boolean>;
7
7
  };
8
- export declare function provideEmbedConfig(props: {
9
- workspaceId: string;
10
- workspaceSettings?: DeepReadonly<WorkspaceSettings> | WorkspaceSettings | null;
11
- hideSidebar?: boolean;
12
- }): void;
8
+ type EmbedConfigInput = {
9
+ workspaceId: MaybeRefOrGetter<string>;
10
+ workspaceSettings?: MaybeRefOrGetter<DeepReadonly<WorkspaceSettings> | WorkspaceSettings | null | undefined>;
11
+ hideSidebar?: MaybeRefOrGetter<boolean | undefined>;
12
+ };
13
+ type ProvideEmbedConfigOptions = {
14
+ syncGlobal?: boolean;
15
+ };
16
+ export declare function provideEmbedConfig(input: EmbedConfigInput, options?: ProvideEmbedConfigOptions): void;
13
17
  export declare function useEmbedConfig(): EmbedConfig | null;
18
+ export {};
@@ -1,11 +1,39 @@
1
1
  const EMBED_CONFIG_KEY = "embed-config";
2
- export function provideEmbedConfig(props) {
3
- provide(EMBED_CONFIG_KEY, {
4
- workspaceId: computed(() => props.workspaceId),
5
- workspaceSettings: toRef(props, "workspaceSettings"),
6
- hideSidebar: computed(() => props.hideSidebar ?? true)
7
- });
2
+ function useGlobalEmbedConfigState() {
3
+ return {
4
+ provided: useState("chat-embed-config-provided", () => false),
5
+ workspaceId: useState("chat-embed-config-workspace-id", () => ""),
6
+ workspaceSettings: useState("chat-embed-config-workspace-settings", () => void 0),
7
+ hideSidebar: useState("chat-embed-config-hide-sidebar", () => void 0)
8
+ };
9
+ }
10
+ export function provideEmbedConfig(input, options = {}) {
11
+ const config = {
12
+ workspaceId: computed(() => toValue(input.workspaceId)),
13
+ workspaceSettings: computed(() => toValue(input.workspaceSettings)),
14
+ hideSidebar: computed(() => toValue(input.hideSidebar) ?? true)
15
+ };
16
+ const globalConfig = useGlobalEmbedConfigState();
17
+ if (options.syncGlobal ?? true) {
18
+ watchEffect(() => {
19
+ globalConfig.provided.value = true;
20
+ globalConfig.workspaceId.value = config.workspaceId.value;
21
+ globalConfig.workspaceSettings.value = config.workspaceSettings.value;
22
+ globalConfig.hideSidebar.value = config.hideSidebar.value;
23
+ });
24
+ }
25
+ provide(EMBED_CONFIG_KEY, config);
8
26
  }
9
27
  export function useEmbedConfig() {
10
- return inject(EMBED_CONFIG_KEY, null);
28
+ const injectedConfig = inject(EMBED_CONFIG_KEY, null);
29
+ if (injectedConfig)
30
+ return injectedConfig;
31
+ const globalConfig = useGlobalEmbedConfigState();
32
+ if (!globalConfig.provided.value)
33
+ return null;
34
+ return {
35
+ workspaceId: computed(() => globalConfig.workspaceId.value),
36
+ workspaceSettings: computed(() => globalConfig.workspaceSettings.value),
37
+ hideSidebar: computed(() => globalConfig.hideSidebar.value ?? true)
38
+ };
11
39
  }
@@ -2,6 +2,8 @@ export function useIDB(options) {
2
2
  const { dbName = "tela", storeName, version } = options;
3
3
  let dbInstance = null;
4
4
  async function setup() {
5
+ if (!import.meta.client)
6
+ return null;
5
7
  if (dbInstance)
6
8
  return dbInstance;
7
9
  return new Promise((resolve, reject) => {
@@ -36,6 +38,8 @@ export function useIDB(options) {
36
38
  }
37
39
  async function withStore(mode, callback) {
38
40
  const db = await setup();
41
+ if (!db)
42
+ return null;
39
43
  return new Promise((resolve, reject) => {
40
44
  const transaction = db.transaction(storeName, mode);
41
45
  const store = transaction.objectStore(storeName);