@widgetic/chat 0.1.5 → 0.1.7

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.
@@ -45,7 +45,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
47
  };
48
- import { chatLog } from '../utils/logger.js';
49
48
  import { ContextType } from '../types/index.js';
50
49
  /**
51
50
  * Widgetic Canvas Platform Adapter
@@ -230,7 +229,7 @@ var WidgeticCanvasAdapter = /** @class */ (function () {
230
229
  return __awaiter(this, void 0, Promise, function () {
231
230
  return __generator(this, function (_a) {
232
231
  try {
233
- chatLog("Starting recording for frame: ".concat(frameId));
232
+ // chatLog(`Starting recording for frame: ${frameId}`);
234
233
  // Implementation would integrate with the canvas recording system
235
234
  // For now, just log the action
236
235
  }
@@ -269,7 +268,7 @@ var WidgeticCanvasAdapter = /** @class */ (function () {
269
268
  return __awaiter(this, void 0, Promise, function () {
270
269
  return __generator(this, function (_a) {
271
270
  // Implementation would stop the recording and return the video blob
272
- chatLog('Stopping recording...');
271
+ // chatLog('Stopping recording...');
273
272
  return [2 /*return*/, new Blob([], { type: 'video/webm' })];
274
273
  });
275
274
  });
@@ -552,7 +551,6 @@ var WidgeticCanvasAdapter = /** @class */ (function () {
552
551
  var _this = this;
553
552
  return __generator(this, function (_a) {
554
553
  try {
555
- chatLog("Enabling element selection for frame: ".concat(frameId));
556
554
  frameElement = document.querySelector("[data-frame-id=\"".concat(frameId, "\"]"));
557
555
  if (frameElement) {
558
556
  frameElement.classList.add('element-selection-mode');
@@ -612,7 +610,6 @@ var WidgeticCanvasAdapter = /** @class */ (function () {
612
610
  switch (_b.label) {
613
611
  case 0:
614
612
  _b.trys.push([0, 2, , 3]);
615
- chatLog("Selected element ".concat(elementId, " in frame ").concat(frameId));
616
613
  frameElement = document.querySelector("[data-frame-id=\"".concat(frameId, "\"]"));
617
614
  if (frameElement) {
618
615
  frameElement.querySelectorAll('.element-selected').forEach(function (el) {
@@ -35,7 +35,7 @@
35
35
  if (disabled || !conversationId) return;
36
36
 
37
37
  try {
38
- chatLog('Triggering screenshot for context:', context.id);
38
+ // chatLog('Triggering screenshot for context:', context.id);
39
39
  dispatch('screenshot', { contextId: context.id });
40
40
  } catch (error) {
41
41
  console.error('Screenshot failed:', error);
@@ -49,10 +49,10 @@
49
49
 
50
50
  try {
51
51
  if (isRecording) {
52
- chatLog('Stopping recording for context:', context.id);
52
+ // chatLog('Stopping recording for context:', context.id);
53
53
  dispatch('recordStop', { contextId: context.id });
54
54
  } else {
55
- chatLog('Starting recording for context:', context.id);
55
+ // chatLog('Starting recording for context:', context.id);
56
56
  dispatch('recordStart', { contextId: context.id });
57
57
  }
58
58
  } catch (error) {
@@ -65,7 +65,7 @@
65
65
  function handleUpload() {
66
66
  if (disabled || !conversationId) return;
67
67
 
68
- chatLog('Triggering file upload');
68
+ // chatLog('Triggering file upload');
69
69
  dispatch('upload');
70
70
  }
71
71
 
@@ -73,7 +73,7 @@
73
73
  function handleCompletionToggle() {
74
74
  if (disabled || !conversationId) return;
75
75
 
76
- chatLog('Toggling conversation completion:', !isCompleted);
76
+ // chatLog('Toggling conversation completion:', !isCompleted);
77
77
  dispatch('complete', { completed: !isCompleted });
78
78
  }
79
79
 
@@ -169,7 +169,7 @@
169
169
  class:completed={isCompleted}
170
170
  onclick={handleCompletionToggle}
171
171
  disabled={disabled || !conversationId}
172
- title={isCompleted ? 'Mark as Active' : 'Mark as Complete'}
172
+ title={isCompleted ? 'Mark as Active — you can keep iterating either way' : 'Mark this chat as done. You can still send messages and iterate on the widget.'}
173
173
  aria-label={isCompleted ? 'Mark conversation as active' : 'Mark conversation as complete'}
174
174
  >
175
175
  {#if isCompleted}
@@ -39,8 +39,12 @@
39
39
  return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
40
40
  }
41
41
 
42
- function isImageType(fileType: string): boolean {
43
- return fileType.startsWith('image/');
42
+ function isImageType(fileType: string, url?: string): boolean {
43
+ if (fileType?.startsWith('image/')) return true;
44
+ if (typeof url === 'string' && (/^data:image\//i.test(url) || /\.(png|jpe?g|gif|webp|svg)(\?|$)/i.test(url))) {
45
+ return true;
46
+ }
47
+ return false;
44
48
  }
45
49
 
46
50
  function isVideoType(fileType: string): boolean {
@@ -68,6 +72,13 @@
68
72
  }
69
73
 
70
74
  function handleRemove(attachment: ContentItemOutput) {
75
+ if (attachment.url && attachment.url.startsWith('blob:')) {
76
+ try {
77
+ URL.revokeObjectURL(attachment.url);
78
+ } catch {
79
+ /* ignore error */
80
+ }
81
+ }
71
82
  if (onRemove) {
72
83
  onRemove(attachment);
73
84
  }
@@ -94,7 +105,7 @@
94
105
  <div class="message-attachments">
95
106
  {#each displayedAttachments as attachment (attachment.id)}
96
107
  <div class="message-attachment-item">
97
- {#if isImageType(attachment.file_type) && showPreview}
108
+ {#if isImageType(attachment.file_type, attachment.url) && showPreview}
98
109
  <!-- svelte-ignore a11y_click_events_have_key_events -->
99
110
  <!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
100
111
  <img
@@ -144,7 +155,7 @@
144
155
  <div class="preview-attachments">
145
156
  {#each displayedAttachments as attachment (attachment.id)}
146
157
  <div class="preview-attachment-item">
147
- {#if isImageType(attachment.file_type) && showPreview}
158
+ {#if isImageType(attachment.file_type, attachment.url) && showPreview}
148
159
  <div class="preview-image-container">
149
160
  <img
150
161
  src={attachment.url}
@@ -240,7 +251,7 @@
240
251
  <!-- svelte-ignore a11y_click_events_have_key_events -->
241
252
  <!-- svelte-ignore a11y_no_static_element_interactions -->
242
253
  <div class="lightbox-content" onclick={(e) => e.stopPropagation()}>
243
- {#if isImageType(lightboxAttachment.file_type)}
254
+ {#if isImageType(lightboxAttachment.file_type, lightboxAttachment.url)}
244
255
  <img
245
256
  src={lightboxAttachment.url}
246
257
  alt={lightboxAttachment.file_name || 'Attachment'}