@widgetic/chat 0.1.38 → 0.1.40
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/README.md +71 -0
- package/dist/components/AttachmentDisplay.svelte +14 -4
- package/dist/components/Chat.svelte +131 -106
- package/dist/components/Chat.svelte.d.ts +29 -0
- package/dist/components/ChatComposer.svelte +5 -1
- package/dist/components/ChatMessages.svelte +595 -175
- package/dist/components/ChatMessages.svelte.d.ts +20 -0
- package/dist/components/CodeBlock.svelte +9 -1
- package/dist/components/ComposerAttachmentsTray.svelte +64 -0
- package/dist/components/ComposerAttachmentsTray.svelte.d.ts +11 -0
- package/dist/components/PanelChatHeader.svelte +26 -6
- package/dist/components/PanelChatHeader.svelte.d.ts +1 -0
- package/dist/components/PanelFollowUpSuggestions.svelte +2 -2
- package/dist/components/PanelSuggestionButtons.svelte +2 -1
- package/dist/components/agent/AgentAvatar.svelte +153 -0
- package/dist/components/agent/AgentAvatar.svelte.d.ts +27 -0
- package/dist/components/agent/AgentTurn.svelte +64 -0
- package/dist/components/agent/AgentTurn.svelte.d.ts +32 -0
- package/dist/components/agent/AvatarBoundary.svelte +29 -0
- package/dist/components/agent/AvatarBoundary.svelte.d.ts +20 -0
- package/dist/components/agent/CodeCard.svelte +288 -0
- package/dist/components/agent/CodeCard.svelte.d.ts +12 -0
- package/dist/components/agent/GenerationModule.svelte +99 -0
- package/dist/components/agent/GenerationModule.svelte.d.ts +16 -0
- package/dist/components/agent/MemberAvatar.svelte +87 -0
- package/dist/components/agent/MemberAvatar.svelte.d.ts +8 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +9 -0
- package/dist/i18n/messages.d.ts +32 -10
- package/dist/i18n/messages.js +32 -10
- package/dist/types/agent.d.ts +74 -0
- package/dist/types/agent.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/agentTurn.d.ts +219 -0
- package/dist/utils/agentTurn.js +301 -0
- package/dist/utils/attachmentPreviewUrl.d.ts +21 -0
- package/dist/utils/attachmentPreviewUrl.js +39 -0
- package/dist/utils/bubbleFit.d.ts +75 -0
- package/dist/utils/bubbleFit.js +116 -0
- package/dist/utils/bubbleShrinkWrap.d.ts +32 -0
- package/dist/utils/bubbleShrinkWrap.js +360 -0
- package/dist/utils/chatImageUploadPrep.d.ts +22 -0
- package/dist/utils/chatImageUploadPrep.js +90 -0
- package/dist/utils/codeHighlight.d.ts +13 -0
- package/dist/utils/codeHighlight.js +61 -0
- package/dist/utils/codePrettier.d.ts +6 -0
- package/dist/utils/codePrettier.js +34 -0
- package/dist/utils/codeStreamFormat.d.ts +90 -0
- package/dist/utils/codeStreamFormat.js +429 -0
- package/dist/utils/generationArchiveStore.d.ts +15 -0
- package/dist/utils/generationArchiveStore.js +89 -0
- package/dist/utils/imageTransform.d.ts +12 -0
- package/dist/utils/imageTransform.js +45 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/suggestionDraft.d.ts +5 -0
- package/dist/utils/suggestionDraft.js +15 -0
- package/package.json +5 -4
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Image Transformations for chat attachment previews (display only).
|
|
3
|
+
*/
|
|
4
|
+
/** Matches site `PUBLIC_IMAGE_TRANSFORM_HOSTS` defaults (library build cannot read Vite env). */
|
|
5
|
+
const TRANSFORM_HOSTS = 'static.widgetic.com,cdn.widgetic.com'
|
|
6
|
+
.split(',')
|
|
7
|
+
.map((host) => host.trim().toLowerCase())
|
|
8
|
+
.filter(Boolean);
|
|
9
|
+
const ENABLED = true;
|
|
10
|
+
function isTransformable(url) {
|
|
11
|
+
if (!ENABLED || !url)
|
|
12
|
+
return false;
|
|
13
|
+
if (url.startsWith('blob:') || url.startsWith('data:'))
|
|
14
|
+
return false;
|
|
15
|
+
try {
|
|
16
|
+
const parsed = new URL(url);
|
|
17
|
+
if (parsed.protocol !== 'https:')
|
|
18
|
+
return false;
|
|
19
|
+
return TRANSFORM_HOSTS.includes(parsed.hostname.toLowerCase());
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Path-style Cloudflare transform URL, or the original when not on an allowlisted host. */
|
|
26
|
+
export function buildTransformedUrl(url, options) {
|
|
27
|
+
const source = url ?? '';
|
|
28
|
+
if (!isTransformable(source))
|
|
29
|
+
return source;
|
|
30
|
+
const parts = [`width=${options.width}`];
|
|
31
|
+
if (options.height)
|
|
32
|
+
parts.push(`height=${options.height}`);
|
|
33
|
+
else if (options.fit === 'cover')
|
|
34
|
+
parts.push(`height=${options.width}`);
|
|
35
|
+
if (options.fit)
|
|
36
|
+
parts.push(`fit=${options.fit}`);
|
|
37
|
+
parts.push(`quality=${options.quality ?? 75}`);
|
|
38
|
+
parts.push('format=auto');
|
|
39
|
+
const parsed = new URL(source);
|
|
40
|
+
return `${parsed.origin}/cdn-cgi/image/${parts.join(',')}/${source}`;
|
|
41
|
+
}
|
|
42
|
+
export function buildImageThumbnailUrl(url, renderedCssPx) {
|
|
43
|
+
const width = Math.min(Math.round(renderedCssPx * 2), 640);
|
|
44
|
+
return buildTransformedUrl(url, { width, fit: 'cover', quality: 80 });
|
|
45
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -6,4 +6,6 @@ export { readThinkingTail, readCodegenStreamTail, generationActivityPhase, thoug
|
|
|
6
6
|
export type { GenerationActivityPhase } from './generationActivity.js';
|
|
7
7
|
export { readGenerationPlanFromMetadata, mapWidgetPlanToPlanCard, } from './generationPlan.js';
|
|
8
8
|
export type { GenerationPlanWire, MappedGenerationPlanCard, WidgetPlanTaskStatusWire, } from './generationPlan.js';
|
|
9
|
+
export { AGENT_AVATAR_PIXELS, CURRENT_USER_PLACEHOLDER_ID, LOCAL_SERVICE_USER_ID, MAX_KEPT_GENERATION_CHARS, agentAvatarLabelKey, agentAvatarPixels, agentLookSignature, avatarStartAfter, finishedGenerationBelongsTo, finishedModulesView, keepFinishedGeneration, keptWorkIsOutdated, liveAgentLook, liveModulesView, memberDisplayName, memberMailtoHref, memberTooltipEmail, normalizePromptText, pageNamesPeople, resolveChatMember, settledAgentLook, soundStateOf, turnOutcome } from './agentTurn.js';
|
|
10
|
+
export type { AgentAvatarSize, AgentLook, AvatarStart, FinishedGeneration, GenerationModulesView, SoundStateInput, TurnOutcome, TurnReplyFacts } from './agentTurn.js';
|
|
9
11
|
export type { AttachmentType, AttachmentValidation, PendingAttachment, UploadStatus } from '../types/index.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -6,3 +6,6 @@ export { VERSION_RATINGS, ratingAfterPress, ratingOfVersion, isRatableVersionRep
|
|
|
6
6
|
export { setLogsEnabled, chatLog, chatWarn, chatError } from './logger.js';
|
|
7
7
|
export { readThinkingTail, readCodegenStreamTail, generationActivityPhase, thoughtDurationSeconds, generationActivityAriaKey, } from './generationActivity.js';
|
|
8
8
|
export { readGenerationPlanFromMetadata, mapWidgetPlanToPlanCard, } from './generationPlan.js';
|
|
9
|
+
// The assistant's turn: its avatar's looks, the judgement of a finished turn, who wrote a message, what is kept of the work.
|
|
10
|
+
// A page that is not the chat (the workflows assistant) follows the same choreography through these.
|
|
11
|
+
export { AGENT_AVATAR_PIXELS, CURRENT_USER_PLACEHOLDER_ID, LOCAL_SERVICE_USER_ID, MAX_KEPT_GENERATION_CHARS, agentAvatarLabelKey, agentAvatarPixels, agentLookSignature, avatarStartAfter, finishedGenerationBelongsTo, finishedModulesView, keepFinishedGeneration, keptWorkIsOutdated, liveAgentLook, liveModulesView, memberDisplayName, memberMailtoHref, memberTooltipEmail, normalizePromptText, pageNamesPeople, resolveChatMember, settledAgentLook, soundStateOf, turnOutcome } from './agentTurn.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merges a suggestion label into the composer draft without sending.
|
|
3
|
+
* Empty draft: replace. Nonempty: append after a single space (one line, caret at end).
|
|
4
|
+
*/
|
|
5
|
+
export function mergeSuggestionIntoDraft(currentDraft, suggestion) {
|
|
6
|
+
const trimmed = suggestion.trim();
|
|
7
|
+
if (!trimmed)
|
|
8
|
+
return currentDraft;
|
|
9
|
+
const draft = currentDraft;
|
|
10
|
+
if (!draft.trim())
|
|
11
|
+
return trimmed;
|
|
12
|
+
if (draft.endsWith(' ') || draft.endsWith('\n'))
|
|
13
|
+
return `${draft}${trimmed}`;
|
|
14
|
+
return `${draft} ${trimmed}`;
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widgetic/chat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -57,11 +57,13 @@
|
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@widgetic/api-sdk": "*",
|
|
60
|
-
"@widgetic/design-system": ">=0.5.
|
|
60
|
+
"@widgetic/design-system": ">=0.5.36",
|
|
61
61
|
"svelte": "^5.25.6"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
+
"@chenglou/pretext": "^1.0.0",
|
|
64
65
|
"highlight.js": "^11.11.1",
|
|
66
|
+
"prettier": "^3.1.1",
|
|
65
67
|
"socket.io-client": "^4.7.5"
|
|
66
68
|
},
|
|
67
69
|
"devDependencies": {
|
|
@@ -73,14 +75,13 @@
|
|
|
73
75
|
"@tailwindcss/postcss": "^4.1.4",
|
|
74
76
|
"@types/node": "^26.4.1",
|
|
75
77
|
"@widgetic/api-sdk": "^1.0.10",
|
|
76
|
-
"@widgetic/design-system": "^0.5.
|
|
78
|
+
"@widgetic/design-system": "^0.5.39",
|
|
77
79
|
"@widgetic/dev-tools": "^0.2.0",
|
|
78
80
|
"autoprefixer": "^10.4.20",
|
|
79
81
|
"eslint": "^9.0.0",
|
|
80
82
|
"eslint-config-prettier": "^9.1.0",
|
|
81
83
|
"eslint-plugin-svelte": "^2.36.0",
|
|
82
84
|
"postcss": "^8.5.3",
|
|
83
|
-
"prettier": "^3.1.1",
|
|
84
85
|
"prettier-plugin-svelte": "^3.1.2",
|
|
85
86
|
"svelte": "^5.25.6",
|
|
86
87
|
"svelte-check": "^4.0.0",
|