@pmate/chat-sdk 0.1.6 → 0.1.8
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/lib/components/AttachmentPreview.js +20 -4
- package/lib/components/ChatInputDesktop.js +149 -43
- package/lib/components/ChatInputMobile.js +119 -44
- package/lib/components/HoldToTalkButton.js +10 -9
- package/lib/components/ImageTrigger.d.ts +1 -1
- package/lib/components/ImageTrigger.js +1 -1
- package/lib/components/icons.d.ts +3 -0
- package/lib/components/icons.js +13 -4
- package/lib/hooks/useAttachmentState.d.ts +3 -1
- package/lib/hooks/useVoiceInputController.js +21 -2
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/runtime/botAuth.d.ts +32 -0
- package/lib/runtime/botAuth.js +71 -0
- package/lib/runtime/botKey.d.ts +14 -0
- package/lib/runtime/botKey.js +25 -0
- package/lib/runtime/chatClient.d.ts +62 -0
- package/lib/runtime/chatClient.js +209 -0
- package/lib/runtime/index.d.ts +5 -0
- package/lib/runtime/index.js +5 -0
- package/lib/runtime/protocol.d.ts +83 -0
- package/lib/runtime/protocol.js +113 -0
- package/lib/runtime/thread.d.ts +3 -0
- package/lib/runtime/thread.js +18 -0
- package/lib/tokens/chatInputThemes.js +20 -20
- package/lib/tokens/defaultTokens.js +17 -17
- package/lib/types/attachment.d.ts +1 -1
- package/lib/types/voice.d.ts +1 -0
- package/package.json +7 -1
- package/dist/assets/ChatInput.stories-CSt4WoEv.js +0 -1702
- package/dist/assets/Color-AVL7NMMY-BspvszXC.js +0 -1
- package/dist/assets/DocsRenderer-PQXLIZUC-BM8CapQZ.js +0 -1243
- package/dist/assets/client-Bw6ZM57k.js +0 -9
- package/dist/assets/iframe-Dci6y3pc.js +0 -1071
- package/dist/assets/iframe-DnNTepBm.css +0 -1
- package/dist/assets/index-DQ_t8Ou6.js +0 -1
- package/dist/assets/preload-helper-PPVm8Dsz.js +0 -1
- package/dist/assets/react-18-3UzO1Bv7.js +0 -1
- package/dist/favicon-wrapper.svg +0 -46
- package/dist/favicon.svg +0 -1
- package/dist/iframe.html +0 -687
- package/dist/index.html +0 -148
- package/dist/index.json +0 -1
- package/dist/nunito-sans-bold-italic.woff2 +0 -0
- package/dist/nunito-sans-bold.woff2 +0 -0
- package/dist/nunito-sans-italic.woff2 +0 -0
- package/dist/nunito-sans-regular.woff2 +0 -0
- package/dist/project.json +0 -1
- package/dist/sb-addons/docs-1/manager-bundle.js +0 -151
- package/dist/sb-addons/docs-1/manager-bundle.js.LEGAL.txt +0 -0
- package/dist/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +0 -971
- package/dist/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js.LEGAL.txt +0 -0
- package/dist/sb-common-assets/favicon-wrapper.svg +0 -46
- package/dist/sb-common-assets/favicon.svg +0 -1
- package/dist/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/dist/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/dist/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/dist/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/dist/sb-manager/globals-module-info.js +0 -799
- package/dist/sb-manager/globals-runtime.js +0 -69791
- package/dist/sb-manager/globals.js +0 -34
- package/dist/sb-manager/runtime.js +0 -13198
- package/dist/vite-inject-mocker-entry.js +0 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function pairId(appId, userA, userB) {
|
|
2
|
+
const [left, right] = userA <= userB ? [userA, userB] : [userB, userA];
|
|
3
|
+
return stableHash(`social:v1:pair:${appId}:${left}:${right}`);
|
|
4
|
+
}
|
|
5
|
+
export function dmThreadId(appId, userA, userB) {
|
|
6
|
+
return stableHash(`social:v1:dm:${appId}:${pairId(appId, userA, userB)}`);
|
|
7
|
+
}
|
|
8
|
+
export function groupThreadId(appId, groupId) {
|
|
9
|
+
return stableHash(`social:v1:group:${appId}:${groupId}`);
|
|
10
|
+
}
|
|
11
|
+
function stableHash(value) {
|
|
12
|
+
let hash = 0x811c9dc5;
|
|
13
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
14
|
+
hash ^= value.charCodeAt(index);
|
|
15
|
+
hash = Math.imul(hash, 0x01000193);
|
|
16
|
+
}
|
|
17
|
+
return `h${(hash >>> 0).toString(16).padStart(8, "0")}`;
|
|
18
|
+
}
|
|
@@ -2,20 +2,20 @@ export const chatInputThemes = {
|
|
|
2
2
|
pmate: {},
|
|
3
3
|
cli: {
|
|
4
4
|
color: {
|
|
5
|
-
brandPrimary: "#
|
|
6
|
-
surfaceInputDefault: "#
|
|
7
|
-
surfaceInputFocus: "#
|
|
8
|
-
surfaceInputRecording: "#
|
|
5
|
+
brandPrimary: "#25D6A0",
|
|
6
|
+
surfaceInputDefault: "#0B1512",
|
|
7
|
+
surfaceInputFocus: "#10201A",
|
|
8
|
+
surfaceInputRecording: "#132A22",
|
|
9
9
|
surfaceInputError: "#251111",
|
|
10
|
-
textPrimary: "#
|
|
11
|
-
textSecondary: "#
|
|
12
|
-
iconDefault: "#
|
|
13
|
-
iconActive: "#
|
|
14
|
-
actionSendDefault: "#
|
|
10
|
+
textPrimary: "#ECFFF7",
|
|
11
|
+
textSecondary: "#8CB6A8",
|
|
12
|
+
iconDefault: "#A4C7BA",
|
|
13
|
+
iconActive: "#25D6A0",
|
|
14
|
+
actionSendDefault: "#25D6A0",
|
|
15
15
|
actionSendDisabled: "#23483B",
|
|
16
16
|
actionSendTextOnPrimary: "#06100D",
|
|
17
|
-
borderDefault: "#
|
|
18
|
-
borderFocus: "#
|
|
17
|
+
borderDefault: "#263F37",
|
|
18
|
+
borderFocus: "#3A715F",
|
|
19
19
|
borderError: "#D66B6B",
|
|
20
20
|
statusError: "#FF8A8A",
|
|
21
21
|
statusWarning: "#E0B256",
|
|
@@ -24,9 +24,9 @@ export const chatInputThemes = {
|
|
|
24
24
|
voiceWaveformBackground: "#214A3C",
|
|
25
25
|
},
|
|
26
26
|
spacing: {
|
|
27
|
-
inputOuter:
|
|
27
|
+
inputOuter: 8,
|
|
28
28
|
inputInner: 10,
|
|
29
|
-
actionGap:
|
|
29
|
+
actionGap: 10,
|
|
30
30
|
attachmentGap: 8,
|
|
31
31
|
voiceWaveformGap: 4,
|
|
32
32
|
mobileTouchInset: 10,
|
|
@@ -34,16 +34,16 @@ export const chatInputThemes = {
|
|
|
34
34
|
statusHintTop: 6,
|
|
35
35
|
},
|
|
36
36
|
radius: {
|
|
37
|
-
inputSurface:
|
|
38
|
-
actionButton:
|
|
39
|
-
attachmentPreview:
|
|
37
|
+
inputSurface: 14,
|
|
38
|
+
actionButton: 18,
|
|
39
|
+
attachmentPreview: 10,
|
|
40
40
|
waveformBar: 2,
|
|
41
|
-
mobileHoldToTalk:
|
|
42
|
-
desktopInputSurface:
|
|
41
|
+
mobileHoldToTalk: 14,
|
|
42
|
+
desktopInputSurface: 14,
|
|
43
43
|
},
|
|
44
44
|
shadow: {
|
|
45
|
-
inputElevated: "0 0 0
|
|
46
|
-
recordingActive: "0 0 0
|
|
45
|
+
inputElevated: "0 1px 0 rgba(255, 255, 255, 0.03), 0 8px 24px rgba(0, 0, 0, 0.18)",
|
|
46
|
+
recordingActive: "0 0 0 4px rgba(37, 214, 160, 0.16)",
|
|
47
47
|
},
|
|
48
48
|
typography: {
|
|
49
49
|
familyBase: '"SF Mono", "JetBrains Mono", monospace',
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
export const defaultChatInputTokens = {
|
|
2
2
|
color: {
|
|
3
|
-
brandPrimary: "#
|
|
3
|
+
brandPrimary: "#12B886",
|
|
4
4
|
surfaceInputDefault: "#FFFFFF",
|
|
5
|
-
surfaceInputFocus: "#
|
|
6
|
-
surfaceInputRecording: "#
|
|
5
|
+
surfaceInputFocus: "#F4F7F6",
|
|
6
|
+
surfaceInputRecording: "#E9F8F1",
|
|
7
7
|
surfaceInputError: "#FFF1F3",
|
|
8
|
-
textPrimary: "#
|
|
9
|
-
textSecondary: "#
|
|
10
|
-
iconDefault: "#
|
|
11
|
-
iconActive: "#
|
|
12
|
-
actionSendDefault: "#
|
|
13
|
-
actionSendDisabled: "#
|
|
8
|
+
textPrimary: "#18211E",
|
|
9
|
+
textSecondary: "#65736E",
|
|
10
|
+
iconDefault: "#3F4A46",
|
|
11
|
+
iconActive: "#12B886",
|
|
12
|
+
actionSendDefault: "#12B886",
|
|
13
|
+
actionSendDisabled: "#B9D9CF",
|
|
14
14
|
actionSendTextOnPrimary: "#FFFFFF",
|
|
15
|
-
borderDefault: "#
|
|
16
|
-
borderFocus: "#
|
|
15
|
+
borderDefault: "#DCE6E2",
|
|
16
|
+
borderFocus: "#8EDBC3",
|
|
17
17
|
borderError: "#F2A7B5",
|
|
18
18
|
statusError: "#D14363",
|
|
19
19
|
statusWarning: "#D98E04",
|
|
20
20
|
statusSuccess: "#2E9B62",
|
|
21
|
-
voiceWaveformActive: "#
|
|
22
|
-
voiceWaveformBackground: "#
|
|
21
|
+
voiceWaveformActive: "#12B886",
|
|
22
|
+
voiceWaveformBackground: "#CFEFE3",
|
|
23
23
|
},
|
|
24
24
|
spacing: {
|
|
25
25
|
inputOuter: 12,
|
|
@@ -32,8 +32,8 @@ export const defaultChatInputTokens = {
|
|
|
32
32
|
statusHintTop: 6,
|
|
33
33
|
},
|
|
34
34
|
radius: {
|
|
35
|
-
inputSurface:
|
|
36
|
-
actionButton:
|
|
35
|
+
inputSurface: 16,
|
|
36
|
+
actionButton: 18,
|
|
37
37
|
attachmentPreview: 14,
|
|
38
38
|
waveformBar: 999,
|
|
39
39
|
mobileHoldToTalk: 18,
|
|
@@ -46,8 +46,8 @@ export const defaultChatInputTokens = {
|
|
|
46
46
|
transcribingLoading: "900ms linear infinite",
|
|
47
47
|
},
|
|
48
48
|
shadow: {
|
|
49
|
-
inputElevated: "0
|
|
50
|
-
recordingActive: "0 0 0 4px rgba(
|
|
49
|
+
inputElevated: "0 1px 2px rgba(15, 23, 42, 0.04)",
|
|
50
|
+
recordingActive: "0 0 0 4px rgba(18, 184, 134, 0.14)",
|
|
51
51
|
},
|
|
52
52
|
typography: {
|
|
53
53
|
familyBase: '"SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif',
|
package/lib/types/voice.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type ChatVoiceConfig = {
|
|
|
11
11
|
asrClient?: ChatASRClient;
|
|
12
12
|
lang?: string;
|
|
13
13
|
minDurationMs?: number;
|
|
14
|
+
transcribeTimeoutMs?: number;
|
|
14
15
|
simulatedTranscript?: string;
|
|
15
16
|
shortRecordingMessage?: string;
|
|
16
17
|
onVoiceSend?: (blob: Blob) => Promise<void> | void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pmate/chat-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Cross-platform PMate chat input components, voice input primitives, and ASR helpers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
"types": "./lib/index.d.ts",
|
|
20
20
|
"import": "./lib/index.js",
|
|
21
21
|
"default": "./lib/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./runtime": {
|
|
24
|
+
"types": "./lib/runtime/index.d.ts",
|
|
25
|
+
"import": "./lib/runtime/index.js",
|
|
26
|
+
"default": "./lib/runtime/index.js"
|
|
22
27
|
}
|
|
23
28
|
},
|
|
24
29
|
"publishConfig": {
|
|
@@ -36,6 +41,7 @@
|
|
|
36
41
|
"@emoji-mart/data": "^1.2.1",
|
|
37
42
|
"@emoji-mart/react": "^1.1.1",
|
|
38
43
|
"@pmate/agent-sdk": "^1.1.2",
|
|
44
|
+
"@msgpack/msgpack": "^3.1.2",
|
|
39
45
|
"jotai": "^2.16.1"
|
|
40
46
|
},
|
|
41
47
|
"peerDependencies": {
|