@admin-layout/tailwind-ui 12.2.4-alpha.62 → 12.2.4-alpha.66
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/AIToolbar/components/completion/Files.d.ts +3 -3
- package/lib/components/AIToolbar/components/completion/Files.d.ts.map +1 -1
- package/lib/components/AIToolbar/components/completion/Files.js +66 -36
- package/lib/components/AIToolbar/components/completion/Files.js.map +1 -1
- package/lib/components/AIToolbar/components/completion/Input.js +1 -1
- package/lib/components/AIToolbar/components/speech/Warning.d.ts.map +1 -1
- package/lib/components/AIToolbar/components/speech/Warning.js +101 -29
- package/lib/components/AIToolbar/components/speech/Warning.js.map +1 -1
- package/lib/components/AIToolbar/index.d.ts +2 -1
- package/lib/components/AIToolbar/index.d.ts.map +1 -1
- package/lib/components/CharacterSlotPicker/CharacterSlotPicker.d.ts +20 -0
- package/lib/components/CharacterSlotPicker/CharacterSlotPicker.d.ts.map +1 -0
- package/lib/components/CharacterSlotPicker/CharacterSlotPicker.js +249 -0
- package/lib/components/CharacterSlotPicker/CharacterSlotPicker.js.map +1 -0
- package/lib/components/CharacterSlotPicker/index.d.ts +3 -0
- package/lib/components/CharacterSlotPicker/index.d.ts.map +1 -0
- package/lib/components/Inbox/Channels/ChannelBar.d.ts +33 -0
- package/lib/components/Inbox/Channels/ChannelBar.d.ts.map +1 -0
- package/lib/components/Inbox/Channels/ChannelBar.js +79 -0
- package/lib/components/Inbox/Channels/ChannelBar.js.map +1 -0
- package/lib/components/Inbox/Channels/ChannelConnectModal.d.ts +24 -0
- package/lib/components/Inbox/Channels/ChannelConnectModal.d.ts.map +1 -0
- package/lib/components/Inbox/Channels/ChannelConnectModal.js +177 -0
- package/lib/components/Inbox/Channels/ChannelConnectModal.js.map +1 -0
- package/lib/components/Inbox/Channels/channelsMeta.d.ts +16 -0
- package/lib/components/Inbox/Channels/channelsMeta.d.ts.map +1 -0
- package/lib/components/Inbox/Channels/channelsMeta.js +127 -0
- package/lib/components/Inbox/Channels/channelsMeta.js.map +1 -0
- package/lib/components/Inbox/Channels/index.d.ts +7 -0
- package/lib/components/Inbox/Channels/index.d.ts.map +1 -0
- package/lib/components/Inbox/index.d.ts +2 -0
- package/lib/components/Inbox/index.d.ts.map +1 -0
- package/lib/components/index.d.ts +2 -0
- package/lib/components/index.d.ts.map +1 -1
- package/lib/hooks/activeCharacterPreference.d.ts +2 -1
- package/lib/hooks/activeCharacterPreference.d.ts.map +1 -1
- package/lib/hooks/activeCharacterPreference.js +9 -2
- package/lib/hooks/activeCharacterPreference.js.map +1 -1
- package/lib/hooks/characterOverrides.d.ts +29 -0
- package/lib/hooks/characterOverrides.d.ts.map +1 -0
- package/lib/hooks/characterOverrides.js +130 -0
- package/lib/hooks/characterOverrides.js.map +1 -0
- package/lib/hooks/characterSlotsPreference.d.ts +33 -0
- package/lib/hooks/characterSlotsPreference.d.ts.map +1 -0
- package/lib/hooks/characterSlotsPreference.js +141 -0
- package/lib/hooks/characterSlotsPreference.js.map +1 -0
- package/lib/hooks/index.d.ts +3 -0
- package/lib/hooks/index.d.ts.map +1 -1
- package/lib/hooks/useGlobalShortcutBridge.d.ts +21 -0
- package/lib/hooks/useGlobalShortcutBridge.d.ts.map +1 -0
- package/lib/hooks/useGlobalShortcutBridge.js +68 -0
- package/lib/hooks/useGlobalShortcutBridge.js.map +1 -0
- package/lib/index.js +1 -1
- package/lib/shardui/command.d.ts +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {jsx,jsxs}from'react/jsx-runtime';// helper functions
|
|
2
|
+
function TelegramIcon() {
|
|
3
|
+
return jsx("svg", {
|
|
4
|
+
width: 20,
|
|
5
|
+
height: 20,
|
|
6
|
+
viewBox: "0 0 24 24",
|
|
7
|
+
fill: "currentColor",
|
|
8
|
+
"aria-hidden": "true",
|
|
9
|
+
children: jsx("path", {
|
|
10
|
+
d: "M12 0C5.37 0 0 5.37 0 12c0 6.627 5.37 12 12 12 6.627 0 12-5.373 12-12C24 5.37 18.627 0 12 0zm5.894 8.221-1.97 9.28c-.145.658-.537.818-1.084.508l-3-2.21-1.446 1.394c-.14.18-.357.295-.548.295l.189-2.91 5.305-4.789c.23-.205-.05-.318-.357-.113l-6.554 4.124-2.827-.88c-.614-.192-.627-.614.128-.91l11.05-4.264c.512-.191 1.01.127.814 1.144z"
|
|
11
|
+
})
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function SlackIcon() {
|
|
15
|
+
return jsxs("svg", {
|
|
16
|
+
width: 20,
|
|
17
|
+
height: 20,
|
|
18
|
+
viewBox: "0 0 128 128",
|
|
19
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
20
|
+
"aria-hidden": "true",
|
|
21
|
+
children: [jsx("path", {
|
|
22
|
+
d: "M27.255 80.719c0 7.33-5.978 13.317-13.309 13.317C6.616 94.036.63 88.049.63 80.719s5.987-13.317 13.317-13.317h13.309zm6.709 0c0-7.33 5.987-13.317 13.317-13.317s13.317 5.986 13.317 13.317v33.335c0 7.33-5.986 13.317-13.317 13.317-7.33 0-13.317-5.987-13.317-13.317zm0 0",
|
|
23
|
+
fill: "#de1c59"
|
|
24
|
+
}), jsx("path", {
|
|
25
|
+
d: "M47.281 27.255c-7.33 0-13.317-5.978-13.317-13.309C33.964 6.616 39.951.63 47.281.63s13.317 5.987 13.317 13.317v13.309zm0 6.709c7.33 0 13.317 5.987 13.317 13.317s-5.986 13.317-13.317 13.317H13.946C6.616 60.598.63 54.612.63 47.281c0-7.33 5.987-13.317 13.317-13.317zm0 0",
|
|
26
|
+
fill: "#35c5f0"
|
|
27
|
+
}), jsx("path", {
|
|
28
|
+
d: "M100.745 47.281c0-7.33 5.978-13.317 13.309-13.317 7.33 0 13.317 5.987 13.317 13.317s-5.987 13.317-13.317 13.317h-13.309zm-6.709 0c0 7.33-5.987 13.317-13.317 13.317s-13.317-5.986-13.317-13.317V13.946C67.402 6.616 73.388.63 80.719.63c7.33 0 13.317 5.987 13.317 13.317zm0 0",
|
|
29
|
+
fill: "#2eb57d"
|
|
30
|
+
}), jsx("path", {
|
|
31
|
+
d: "M80.719 100.745c7.33 0 13.317 5.978 13.317 13.309 0 7.33-5.987 13.317-13.317 13.317s-13.317-5.987-13.317-13.317v-13.309zm0-6.709c-7.33 0-13.317-5.987-13.317-13.317s5.986-13.317 13.317-13.317h33.335c7.33 0 13.317 5.986 13.317 13.317 0 7.33-5.987 13.317-13.317 13.317zm0 0",
|
|
32
|
+
fill: "#ebb02e"
|
|
33
|
+
})]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function DiscordIcon() {
|
|
37
|
+
return jsx("svg", {
|
|
38
|
+
width: 20,
|
|
39
|
+
height: 20,
|
|
40
|
+
viewBox: "0 0 24 24",
|
|
41
|
+
fill: "currentColor",
|
|
42
|
+
"aria-hidden": "true",
|
|
43
|
+
children: jsx("path", {
|
|
44
|
+
d: "M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3333-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3333-.946 2.4189-2.1568 2.4189Z"
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function WhatsAppIcon() {
|
|
49
|
+
return jsx("svg", {
|
|
50
|
+
width: 20,
|
|
51
|
+
height: 20,
|
|
52
|
+
viewBox: "0 0 24 24",
|
|
53
|
+
fill: "currentColor",
|
|
54
|
+
"aria-hidden": "true",
|
|
55
|
+
children: jsx("path", {
|
|
56
|
+
d: "M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function TeamsIcon() {
|
|
61
|
+
return jsxs("svg", {
|
|
62
|
+
width: 20,
|
|
63
|
+
height: 20,
|
|
64
|
+
viewBox: "0 0 48 48",
|
|
65
|
+
"aria-hidden": "true",
|
|
66
|
+
children: [jsx("path", {
|
|
67
|
+
fill: "#5c6bc0",
|
|
68
|
+
d: "M41.5 13A3.5 3.5 0 1 0 41.5 20 3.5 3.5 0 1 0 41.5 13zM4 40l23 4V4L4 8V40z"
|
|
69
|
+
}), jsx("path", {
|
|
70
|
+
fill: "#fff",
|
|
71
|
+
d: "M21 16.27L21 19 17.01 19.18 16.99 31.04 14.01 30.95 14.01 19.29 10 19.45 10 16.94z"
|
|
72
|
+
}), jsx("path", {
|
|
73
|
+
fill: "#5c6bc0",
|
|
74
|
+
d: "M36 14c0 2.21-1.79 4-4 4-1.2 0-2.27-.53-3-1.36v-5.28c.73-.83 1.8-1.36 3-1.36C34.21 10 36 11.79 36 14zM38 23v11c0 0 1.567 0 3.5 0 1.762 0 3.205-1.306 3.45-3H45v-8H38zM29 20v17c0 0 1.567 0 3.5 0 1.762 0 3.205-1.306 3.45-3H36V20H29z"
|
|
75
|
+
})]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// constants
|
|
79
|
+
const CHANNELS = [{
|
|
80
|
+
id: 'telegram',
|
|
81
|
+
name: 'Telegram',
|
|
82
|
+
description: 'Bridge this chat to a Telegram bot',
|
|
83
|
+
icon: jsx(TelegramIcon, {}),
|
|
84
|
+
channelType: 'telegram-webhook',
|
|
85
|
+
tokenLabel: '',
|
|
86
|
+
tokenPlaceholder: '',
|
|
87
|
+
tokenHelp: '1. Open Telegram and find the configured bot\n2. Tap the deep link below (or scan the QR)\n3. Tap Start to complete pairing',
|
|
88
|
+
docsLink: 'https://core.telegram.org/bots#how-do-i-create-a-bot'
|
|
89
|
+
}, {
|
|
90
|
+
id: 'discord',
|
|
91
|
+
name: 'Discord',
|
|
92
|
+
description: 'Bridge this chat to a Discord channel',
|
|
93
|
+
icon: jsx(DiscordIcon, {}),
|
|
94
|
+
channelType: 'discord-webhook',
|
|
95
|
+
tokenLabel: '',
|
|
96
|
+
tokenPlaceholder: '',
|
|
97
|
+
tokenHelp: '1. Open Discord and DM the configured bot\n2. Send the deep-link command (or paste the token)\n3. The bot confirms pairing',
|
|
98
|
+
docsLink: 'https://discord.com/developers/applications'
|
|
99
|
+
}, {
|
|
100
|
+
id: 'slack',
|
|
101
|
+
name: 'Slack',
|
|
102
|
+
description: 'Bridge this chat to a Slack workspace',
|
|
103
|
+
icon: jsx(SlackIcon, {}),
|
|
104
|
+
channelType: 'slack-webhook',
|
|
105
|
+
tokenLabel: '',
|
|
106
|
+
tokenPlaceholder: '',
|
|
107
|
+
tokenHelp: '1. Open Slack and DM the configured bot\n2. Send the pairing command from the deep link\n3. The bot confirms pairing',
|
|
108
|
+
docsLink: 'https://api.slack.com/start'
|
|
109
|
+
}, {
|
|
110
|
+
id: 'whatsapp',
|
|
111
|
+
name: 'WhatsApp',
|
|
112
|
+
description: 'Pair WhatsApp via QR code',
|
|
113
|
+
icon: jsx(WhatsAppIcon, {}),
|
|
114
|
+
channelType: 'whatsapp-webhook',
|
|
115
|
+
tokenLabel: '',
|
|
116
|
+
tokenPlaceholder: '',
|
|
117
|
+
tokenHelp: 'Scan the QR code shown in the connect dialog with WhatsApp on your phone.'
|
|
118
|
+
}, {
|
|
119
|
+
id: 'teams',
|
|
120
|
+
name: 'Microsoft Teams',
|
|
121
|
+
description: 'Bridge this chat to Microsoft Teams',
|
|
122
|
+
icon: jsx(TeamsIcon, {}),
|
|
123
|
+
channelType: 'teams-webhook',
|
|
124
|
+
tokenLabel: '',
|
|
125
|
+
tokenPlaceholder: '',
|
|
126
|
+
tokenHelp: '1. Open Teams and DM the configured bot\n2. Send the pairing command from the deep link\n3. The bot confirms pairing'
|
|
127
|
+
}];export{CHANNELS};//# sourceMappingURL=channelsMeta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channelsMeta.js","sources":["../../../../src/components/Inbox/Channels/channelsMeta.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":"yCAIA;qBACe,GAAA;SACPA,SAAS,EAAA;IACb,KAAA,EAAA,EAAA;IACA,MAAM;IACN,OAAA,EAAA,WAAA;IACA,IAAA,EAAA,cAAoB;IACpB,aAAA,EAAA,MAAA;IACA,QAAA,EAAUA,UAAS,EAAA;MACnB,CAAA,EAAA;KACA;IACA;AACH;AAkED,SAAA,SAAO,GAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as ChannelBar } from './ChannelBar';
|
|
2
|
+
export type { ChannelBarProps } from './ChannelBar';
|
|
3
|
+
export { default as ChannelConnectModal } from './ChannelConnectModal';
|
|
4
|
+
export type { ChannelConnectModalProps, PairingTokenResult } from './ChannelConnectModal';
|
|
5
|
+
export { CHANNELS } from './channelsMeta';
|
|
6
|
+
export type { ChannelMeta } from './channelsMeta';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Inbox/Channels/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,YAAY,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Inbox/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -14,6 +14,8 @@ export * from './ThemeProvider';
|
|
|
14
14
|
export * from './LanguageMenuDropdown';
|
|
15
15
|
export * from './InputToolBar';
|
|
16
16
|
export * from './AIToolbar';
|
|
17
|
+
export * from './CharacterSlotPicker';
|
|
18
|
+
export * from './Inbox';
|
|
17
19
|
export * from './YantraIcon';
|
|
18
20
|
export { Markdown as AIToolbarMarkdown } from './AIToolbar/components/Markdown';
|
|
19
21
|
export * from './Markdown';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAChF,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAChF,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -17,7 +17,8 @@ export declare function readPreferredActiveCharacterFileName(): string | null;
|
|
|
17
17
|
* active character (toolbar + `/chat`).
|
|
18
18
|
*/
|
|
19
19
|
export declare function setPreferredActiveCharacterFileName(fileName: string | null): Promise<void>;
|
|
20
|
-
/** Pick the character row that matches the stored preference; otherwise
|
|
20
|
+
/** Pick the character row that matches the stored preference; otherwise the
|
|
21
|
+
* default-slot character (see `characterSlotsPreference`); otherwise list[0]. */
|
|
21
22
|
export declare function resolveActiveCharacterFromList<T extends {
|
|
22
23
|
file_name?: string | null;
|
|
23
24
|
}>(list: T[] | null | undefined): T | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activeCharacterPreference.d.ts","sourceRoot":"","sources":["../../src/hooks/activeCharacterPreference.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"activeCharacterPreference.d.ts","sourceRoot":"","sources":["../../src/hooks/activeCharacterPreference.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,0EAA0E;AAC1E,eAAO,MAAM,sCAAsC,sCAAsC,CAAC;AAE1F,0GAA0G;AAC1G,eAAO,MAAM,6BAA6B,mCAAmC,CAAC;AAE9E,wBAAgB,oCAAoC,IAAI,MAAM,GAAG,IAAI,CAOpE;AAYD;;;GAGG;AACH,wBAAsB,mCAAmC,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBhG;AAED;kFACkF;AAClF,wBAAgB,8BAA8B,CAAC,CAAC,SAAS;IAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAClF,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,GAC7B,CAAC,GAAG,IAAI,CAcV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import {readDefaultCharacterFileName}from'./characterSlotsPreference.js';/**
|
|
2
2
|
* Persisted preference for which installed character card is **active**
|
|
3
3
|
* across the toolbar + dashboard webviews (`character_list[].file_name` stem —
|
|
4
4
|
* e.g. `"Aria"`, `"Seraphina"`).
|
|
@@ -52,7 +52,8 @@ async function setPreferredActiveCharacterFileName(fileName) {
|
|
|
52
52
|
fileName: fileName?.trim() || null
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
/** Pick the character row that matches the stored preference; otherwise
|
|
55
|
+
/** Pick the character row that matches the stored preference; otherwise the
|
|
56
|
+
* default-slot character (see `characterSlotsPreference`); otherwise list[0]. */
|
|
56
57
|
function resolveActiveCharacterFromList(list) {
|
|
57
58
|
if (!list?.length) return null;
|
|
58
59
|
const pref = readPreferredActiveCharacterFileName();
|
|
@@ -60,5 +61,11 @@ function resolveActiveCharacterFromList(list) {
|
|
|
60
61
|
const match = list.find(c => c.file_name === pref);
|
|
61
62
|
if (match) return match;
|
|
62
63
|
}
|
|
64
|
+
// Fallback: the file_name assigned to the user's default slot (1–9).
|
|
65
|
+
const slotFile = readDefaultCharacterFileName();
|
|
66
|
+
if (slotFile) {
|
|
67
|
+
const match = list.find(c => c.file_name === slotFile);
|
|
68
|
+
if (match) return match;
|
|
69
|
+
}
|
|
63
70
|
return list[0] ?? null;
|
|
64
71
|
}export{ACTIVE_CHARACTER_CHANGE_EVENT,ACTIVE_CHARACTER_FILE_NAME_STORAGE_KEY,readPreferredActiveCharacterFileName,resolveActiveCharacterFromList,setPreferredActiveCharacterFileName};//# sourceMappingURL=activeCharacterPreference.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activeCharacterPreference.js","sources":["../../src/hooks/activeCharacterPreference.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"activeCharacterPreference.js","sources":["../../src/hooks/activeCharacterPreference.ts"],"sourcesContent":[null],"names":[],"mappings":"yEAAA;;;;;;;;AAQG;AAKH;AAEA,MAAA,sCAAA,GAAA;AACA;AAEA,MAAA,6BAAgB,GAAA;AAmBhB,SAAA,oCAAA,GAAA;;;AAGG,IAAA,OAAA,MAAA,CAAA,YAAA,CAAA,OAAA,CAAA,sCAAA,CAAA;AACH,EAAA,CAAA,CAAA,MAAA;AAqBA,IAAA,OAAA,IAAA;AACkF,EAAA;AAClF;AAA2D,eAAU,QAAQ,CAAA,KAAO,EAAA,OAAA,EAAA;AAAE,EAAA,IAClF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-character overrides (Phase C):
|
|
3
|
+
* - `voiceId` → preferred cloud-TTS voice id (e.g. ElevenLabs voice id)
|
|
4
|
+
* - `addendum` → extra system-prompt text appended to the persona
|
|
5
|
+
*
|
|
6
|
+
* Storage keys (per character `file_name`):
|
|
7
|
+
* `yantra:character-voice-id:<file_name>`
|
|
8
|
+
* `yantra:character-addendum:<file_name>`
|
|
9
|
+
*
|
|
10
|
+
* Mirrors `characterSlotsPreference.ts`: localStorage + same-tab DOM event +
|
|
11
|
+
* cross-webview Tauri event so any panel reflects edits immediately.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CHARACTER_OVERRIDES_CHANGE_EVENT = "yantra:character-overrides-change";
|
|
14
|
+
export interface CharacterOverrides {
|
|
15
|
+
voiceId: string;
|
|
16
|
+
addendum: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function readCharacterVoiceId(fileName: string): string;
|
|
19
|
+
export declare function readCharacterAddendum(fileName: string): string;
|
|
20
|
+
export declare function readCharacterOverrides(fileName: string): CharacterOverrides;
|
|
21
|
+
export declare function setCharacterVoiceId(fileName: string, voiceId: string): void;
|
|
22
|
+
export declare function setCharacterAddendum(fileName: string, addendum: string): void;
|
|
23
|
+
export declare function setCharacterOverrides(fileName: string, next: Partial<CharacterOverrides>): void;
|
|
24
|
+
/**
|
|
25
|
+
* Subscribe to overrides for a single character `file_name`. Updates on
|
|
26
|
+
* same-tab events, cross-tab `storage` events, and Tauri cross-webview emits.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useCharacterOverrides(fileName: string | null | undefined): CharacterOverrides;
|
|
29
|
+
//# sourceMappingURL=characterOverrides.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"characterOverrides.d.ts","sourceRoot":"","sources":["../../src/hooks/characterOverrides.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,eAAO,MAAM,gCAAgC,sCAAsC,CAAC;AAKpF,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CACpB;AA2CD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG9D;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,CAM3E;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI3E;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAI7E;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAK/F;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,kBAAkB,CA8C7F"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import*as React from'react';/**
|
|
2
|
+
* Per-character overrides (Phase C):
|
|
3
|
+
* - `voiceId` → preferred cloud-TTS voice id (e.g. ElevenLabs voice id)
|
|
4
|
+
* - `addendum` → extra system-prompt text appended to the persona
|
|
5
|
+
*
|
|
6
|
+
* Storage keys (per character `file_name`):
|
|
7
|
+
* `yantra:character-voice-id:<file_name>`
|
|
8
|
+
* `yantra:character-addendum:<file_name>`
|
|
9
|
+
*
|
|
10
|
+
* Mirrors `characterSlotsPreference.ts`: localStorage + same-tab DOM event +
|
|
11
|
+
* cross-webview Tauri event so any panel reflects edits immediately.
|
|
12
|
+
*/
|
|
13
|
+
const CHARACTER_OVERRIDES_CHANGE_EVENT = 'yantra:character-overrides-change';
|
|
14
|
+
const VOICE_ID_PREFIX = 'yantra:character-voice-id:';
|
|
15
|
+
const ADDENDUM_PREFIX = 'yantra:character-addendum:';
|
|
16
|
+
const EMPTY = {
|
|
17
|
+
voiceId: '',
|
|
18
|
+
addendum: ''
|
|
19
|
+
};
|
|
20
|
+
function safeGet(key) {
|
|
21
|
+
if (typeof window === 'undefined') return '';
|
|
22
|
+
try {
|
|
23
|
+
return window.localStorage.getItem(key) ?? '';
|
|
24
|
+
} catch {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function safeSet(key, value) {
|
|
29
|
+
if (typeof window === 'undefined') return;
|
|
30
|
+
try {
|
|
31
|
+
if (value) window.localStorage.setItem(key, value);else window.localStorage.removeItem(key);
|
|
32
|
+
} catch {
|
|
33
|
+
/* quota */
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function safeEmit(event, payload) {
|
|
37
|
+
try {
|
|
38
|
+
// @ts-ignore optional peer
|
|
39
|
+
const mod = await import('@tauri-apps/api/event');
|
|
40
|
+
await mod.emit(event, payload);
|
|
41
|
+
} catch {
|
|
42
|
+
/* non-Tauri */
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function broadcast(fileName) {
|
|
46
|
+
if (typeof window === 'undefined') return;
|
|
47
|
+
window.dispatchEvent(new CustomEvent(CHARACTER_OVERRIDES_CHANGE_EVENT, {
|
|
48
|
+
detail: {
|
|
49
|
+
fileName
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
void safeEmit(CHARACTER_OVERRIDES_CHANGE_EVENT, {
|
|
53
|
+
fileName
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function readCharacterVoiceId(fileName) {
|
|
57
|
+
if (!fileName) return '';
|
|
58
|
+
return safeGet(VOICE_ID_PREFIX + fileName).trim();
|
|
59
|
+
}
|
|
60
|
+
function readCharacterAddendum(fileName) {
|
|
61
|
+
if (!fileName) return '';
|
|
62
|
+
return safeGet(ADDENDUM_PREFIX + fileName);
|
|
63
|
+
}
|
|
64
|
+
function readCharacterOverrides(fileName) {
|
|
65
|
+
if (!fileName) return EMPTY;
|
|
66
|
+
return {
|
|
67
|
+
voiceId: readCharacterVoiceId(fileName),
|
|
68
|
+
addendum: readCharacterAddendum(fileName)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function setCharacterVoiceId(fileName, voiceId) {
|
|
72
|
+
if (!fileName) return;
|
|
73
|
+
safeSet(VOICE_ID_PREFIX + fileName, voiceId.trim());
|
|
74
|
+
broadcast(fileName);
|
|
75
|
+
}
|
|
76
|
+
function setCharacterAddendum(fileName, addendum) {
|
|
77
|
+
if (!fileName) return;
|
|
78
|
+
safeSet(ADDENDUM_PREFIX + fileName, addendum);
|
|
79
|
+
broadcast(fileName);
|
|
80
|
+
}
|
|
81
|
+
function setCharacterOverrides(fileName, next) {
|
|
82
|
+
if (!fileName) return;
|
|
83
|
+
if (typeof next.voiceId === 'string') safeSet(VOICE_ID_PREFIX + fileName, next.voiceId.trim());
|
|
84
|
+
if (typeof next.addendum === 'string') safeSet(ADDENDUM_PREFIX + fileName, next.addendum);
|
|
85
|
+
broadcast(fileName);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Subscribe to overrides for a single character `file_name`. Updates on
|
|
89
|
+
* same-tab events, cross-tab `storage` events, and Tauri cross-webview emits.
|
|
90
|
+
*/
|
|
91
|
+
function useCharacterOverrides(fileName) {
|
|
92
|
+
const key = fileName ?? '';
|
|
93
|
+
const [snap, setSnap] = React.useState(() => readCharacterOverrides(key));
|
|
94
|
+
React.useEffect(() => {
|
|
95
|
+
if (typeof window === 'undefined') return;
|
|
96
|
+
setSnap(readCharacterOverrides(key));
|
|
97
|
+
if (!key) return;
|
|
98
|
+
const refresh = e => {
|
|
99
|
+
// Only re-read when our character (or any character) changed.
|
|
100
|
+
const detail = e?.detail;
|
|
101
|
+
if (detail?.fileName && detail.fileName !== key) return;
|
|
102
|
+
setSnap(readCharacterOverrides(key));
|
|
103
|
+
};
|
|
104
|
+
window.addEventListener(CHARACTER_OVERRIDES_CHANGE_EVENT, refresh);
|
|
105
|
+
window.addEventListener('storage', refresh);
|
|
106
|
+
let unlistenTauri = null;
|
|
107
|
+
let cancelled = false;
|
|
108
|
+
(async () => {
|
|
109
|
+
try {
|
|
110
|
+
// @ts-ignore optional peer
|
|
111
|
+
const mod = await import('@tauri-apps/api/event');
|
|
112
|
+
const off = await mod.listen(CHARACTER_OVERRIDES_CHANGE_EVENT, e => {
|
|
113
|
+
const fn = e.payload?.fileName;
|
|
114
|
+
if (fn && fn !== key) return;
|
|
115
|
+
setSnap(readCharacterOverrides(key));
|
|
116
|
+
});
|
|
117
|
+
if (cancelled) off();else unlistenTauri = off;
|
|
118
|
+
} catch {
|
|
119
|
+
/* non-Tauri */
|
|
120
|
+
}
|
|
121
|
+
})();
|
|
122
|
+
return () => {
|
|
123
|
+
cancelled = true;
|
|
124
|
+
window.removeEventListener(CHARACTER_OVERRIDES_CHANGE_EVENT, refresh);
|
|
125
|
+
window.removeEventListener('storage', refresh);
|
|
126
|
+
if (unlistenTauri) unlistenTauri();
|
|
127
|
+
};
|
|
128
|
+
}, [key]);
|
|
129
|
+
return snap;
|
|
130
|
+
}export{CHARACTER_OVERRIDES_CHANGE_EVENT,readCharacterAddendum,readCharacterOverrides,readCharacterVoiceId,setCharacterAddendum,setCharacterOverrides,setCharacterVoiceId,useCharacterOverrides};//# sourceMappingURL=characterOverrides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"characterOverrides.js","sources":["../../src/hooks/characterOverrides.ts"],"sourcesContent":[null],"names":[],"mappings":"4BAAA;;;;;;;;;;;AAWG;sCASgC,GAAA;MAC/B,eAAgB,GAAA,4BAAA;MAChB,eAAiB,GAAA,4BAAA;AACpB,MAAA,KAAA,GAAA;AA2CD,EAAA,OAAA,EAAA,EAAA;AAKA,EAAA,QAAA,EAAA;AAKA,CAAA;AAQA,SAAA,OAAA,CAAA,GAAA,EAAA;AAMA,EAAA,IAAA,OAAA,MAAA,KAAgB,WAAA,EAAA,OAAoB,EAAC;AAMrC,EAAA,IAAA;AAOA,IAAA,OAAA,MAAA,CAAA,YAAA,CAAA,OAAA,CAAA,GAAA,CAAA,IAAA,EAAA;;;AAGG,EAAA;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persisted character slots 1–9 — user-managed bookmarks of installed
|
|
3
|
+
* characters. Each slot points to a character `file_name` (e.g. `"Aria"`).
|
|
4
|
+
*
|
|
5
|
+
* One slot is marked **default** and is used at startup when no other active
|
|
6
|
+
* character preference is set (see `resolveActiveCharacterFromList`).
|
|
7
|
+
*
|
|
8
|
+
* Mirrors `activeCharacterPreference.ts`: localStorage + custom DOM event +
|
|
9
|
+
* Tauri broadcast so every webview reacts to changes.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CHARACTER_SLOTS_STORAGE_KEY = "yantra:character-slots";
|
|
12
|
+
export declare const CHARACTER_SLOTS_DEFAULT_KEY = "yantra:character-slots:default";
|
|
13
|
+
export declare const CHARACTER_SLOTS_CHANGE_EVENT = "yantra:character-slots-change";
|
|
14
|
+
export type SlotNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
15
|
+
export type CharacterSlots = Partial<Record<SlotNumber, string>>;
|
|
16
|
+
export declare const SLOT_NUMBERS: readonly SlotNumber[];
|
|
17
|
+
export declare function readCharacterSlots(): CharacterSlots;
|
|
18
|
+
export declare function readDefaultSlot(): SlotNumber;
|
|
19
|
+
export declare function writeCharacterSlots(next: CharacterSlots): Promise<void>;
|
|
20
|
+
export declare function setSlot(slot: SlotNumber, fileName: string | null): Promise<void>;
|
|
21
|
+
export declare function setDefaultSlot(slot: SlotNumber): Promise<void>;
|
|
22
|
+
/** Returns the file_name assigned to the default slot, if any. */
|
|
23
|
+
export declare function readDefaultCharacterFileName(): string | null;
|
|
24
|
+
export interface UseCharacterSlotsResult {
|
|
25
|
+
slots: CharacterSlots;
|
|
26
|
+
defaultSlot: SlotNumber;
|
|
27
|
+
setSlot: (slot: SlotNumber, fileName: string | null) => Promise<void>;
|
|
28
|
+
setDefaultSlot: (slot: SlotNumber) => Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
/** Subscribe to the persisted slot map + default slot. Updates on
|
|
31
|
+
* same-tab events, cross-tab `storage` events, and Tauri cross-webview emits. */
|
|
32
|
+
export declare function useCharacterSlots(): UseCharacterSlotsResult;
|
|
33
|
+
//# sourceMappingURL=characterSlotsPreference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"characterSlotsPreference.d.ts","sourceRoot":"","sources":["../../src/hooks/characterSlotsPreference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,eAAO,MAAM,2BAA2B,2BAA2B,CAAC;AACpE,eAAO,MAAM,2BAA2B,mCAAmC,CAAC;AAC5E,eAAO,MAAM,4BAA4B,kCAAkC,CAAC;AAE5E,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3D,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;AAEjE,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAAyC,CAAC;AAMxF,wBAAgB,kBAAkB,IAAI,cAAc,CAiBnD;AAED,wBAAgB,eAAe,IAAI,UAAU,CAS5C;AAsBD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ7E;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAQtF;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAQpE;AAED,kEAAkE;AAClE,wBAAgB,4BAA4B,IAAI,MAAM,GAAG,IAAI,CAI5D;AAMD,MAAM,WAAW,uBAAuB;IACpC,KAAK,EAAE,cAAc,CAAC;IACtB,WAAW,EAAE,UAAU,CAAC;IACxB,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,cAAc,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD;AAED;kFACkF;AAClF,wBAAgB,iBAAiB,IAAI,uBAAuB,CAyC3D"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import*as React from'react';/**
|
|
2
|
+
* Persisted character slots 1–9 — user-managed bookmarks of installed
|
|
3
|
+
* characters. Each slot points to a character `file_name` (e.g. `"Aria"`).
|
|
4
|
+
*
|
|
5
|
+
* One slot is marked **default** and is used at startup when no other active
|
|
6
|
+
* character preference is set (see `resolveActiveCharacterFromList`).
|
|
7
|
+
*
|
|
8
|
+
* Mirrors `activeCharacterPreference.ts`: localStorage + custom DOM event +
|
|
9
|
+
* Tauri broadcast so every webview reacts to changes.
|
|
10
|
+
*/
|
|
11
|
+
const CHARACTER_SLOTS_STORAGE_KEY = 'yantra:character-slots';
|
|
12
|
+
const CHARACTER_SLOTS_DEFAULT_KEY = 'yantra:character-slots:default';
|
|
13
|
+
const CHARACTER_SLOTS_CHANGE_EVENT = 'yantra:character-slots-change';
|
|
14
|
+
const SLOT_NUMBERS = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
15
|
+
function isSlotNumber(n) {
|
|
16
|
+
return Number.isInteger(n) && n >= 1 && n <= 9;
|
|
17
|
+
}
|
|
18
|
+
function readCharacterSlots() {
|
|
19
|
+
if (typeof window === 'undefined') return {};
|
|
20
|
+
try {
|
|
21
|
+
const raw = window.localStorage.getItem(CHARACTER_SLOTS_STORAGE_KEY);
|
|
22
|
+
if (!raw) return {};
|
|
23
|
+
const parsed = JSON.parse(raw);
|
|
24
|
+
const out = {};
|
|
25
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
26
|
+
const n = Number(key);
|
|
27
|
+
if (isSlotNumber(n) && typeof value === 'string' && value.trim()) {
|
|
28
|
+
out[n] = value.trim();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
} catch {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function readDefaultSlot() {
|
|
37
|
+
if (typeof window === 'undefined') return 1;
|
|
38
|
+
try {
|
|
39
|
+
const raw = window.localStorage.getItem(CHARACTER_SLOTS_DEFAULT_KEY);
|
|
40
|
+
const n = raw ? Number(raw) : 1;
|
|
41
|
+
return isSlotNumber(n) ? n : 1;
|
|
42
|
+
} catch {
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function safeEmit(event, payload) {
|
|
47
|
+
try {
|
|
48
|
+
// @ts-ignore optional dynamic import
|
|
49
|
+
const mod = await import('@tauri-apps/api/event');
|
|
50
|
+
await mod.emit(event, payload);
|
|
51
|
+
} catch {
|
|
52
|
+
/* non-Tauri */
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function broadcast(slots, defaultSlot) {
|
|
56
|
+
if (typeof window === 'undefined') return;
|
|
57
|
+
window.dispatchEvent(new CustomEvent(CHARACTER_SLOTS_CHANGE_EVENT, {
|
|
58
|
+
detail: {
|
|
59
|
+
slots,
|
|
60
|
+
defaultSlot
|
|
61
|
+
}
|
|
62
|
+
}));
|
|
63
|
+
void safeEmit(CHARACTER_SLOTS_CHANGE_EVENT, {
|
|
64
|
+
slots,
|
|
65
|
+
defaultSlot
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async function writeCharacterSlots(next) {
|
|
69
|
+
if (typeof window === 'undefined') return;
|
|
70
|
+
try {
|
|
71
|
+
window.localStorage.setItem(CHARACTER_SLOTS_STORAGE_KEY, JSON.stringify(next));
|
|
72
|
+
} catch {
|
|
73
|
+
/* quota */
|
|
74
|
+
}
|
|
75
|
+
broadcast(next, readDefaultSlot());
|
|
76
|
+
}
|
|
77
|
+
async function setSlot(slot, fileName) {
|
|
78
|
+
const current = readCharacterSlots();
|
|
79
|
+
if (fileName && fileName.trim()) {
|
|
80
|
+
current[slot] = fileName.trim();
|
|
81
|
+
} else {
|
|
82
|
+
delete current[slot];
|
|
83
|
+
}
|
|
84
|
+
await writeCharacterSlots(current);
|
|
85
|
+
}
|
|
86
|
+
async function setDefaultSlot(slot) {
|
|
87
|
+
if (typeof window === 'undefined') return;
|
|
88
|
+
try {
|
|
89
|
+
window.localStorage.setItem(CHARACTER_SLOTS_DEFAULT_KEY, String(slot));
|
|
90
|
+
} catch {
|
|
91
|
+
/* quota */
|
|
92
|
+
}
|
|
93
|
+
broadcast(readCharacterSlots(), slot);
|
|
94
|
+
}
|
|
95
|
+
/** Returns the file_name assigned to the default slot, if any. */
|
|
96
|
+
function readDefaultCharacterFileName() {
|
|
97
|
+
const slots = readCharacterSlots();
|
|
98
|
+
const defSlot = readDefaultSlot();
|
|
99
|
+
return slots[defSlot] ?? null;
|
|
100
|
+
}
|
|
101
|
+
/** Subscribe to the persisted slot map + default slot. Updates on
|
|
102
|
+
* same-tab events, cross-tab `storage` events, and Tauri cross-webview emits. */
|
|
103
|
+
function useCharacterSlots() {
|
|
104
|
+
const [snapshot, setSnapshot] = React.useState(() => ({
|
|
105
|
+
slots: readCharacterSlots(),
|
|
106
|
+
defaultSlot: readDefaultSlot()
|
|
107
|
+
}));
|
|
108
|
+
React.useEffect(() => {
|
|
109
|
+
if (typeof window === 'undefined') return;
|
|
110
|
+
const refresh = () => setSnapshot({
|
|
111
|
+
slots: readCharacterSlots(),
|
|
112
|
+
defaultSlot: readDefaultSlot()
|
|
113
|
+
});
|
|
114
|
+
window.addEventListener(CHARACTER_SLOTS_CHANGE_EVENT, refresh);
|
|
115
|
+
window.addEventListener('storage', refresh);
|
|
116
|
+
let unlistenTauri = null;
|
|
117
|
+
let cancelled = false;
|
|
118
|
+
(async () => {
|
|
119
|
+
try {
|
|
120
|
+
// @ts-ignore optional peer
|
|
121
|
+
const mod = await import('@tauri-apps/api/event');
|
|
122
|
+
const off = await mod.listen(CHARACTER_SLOTS_CHANGE_EVENT, refresh);
|
|
123
|
+
if (cancelled) off();else unlistenTauri = off;
|
|
124
|
+
} catch {
|
|
125
|
+
/* non-Tauri */
|
|
126
|
+
}
|
|
127
|
+
})();
|
|
128
|
+
return () => {
|
|
129
|
+
cancelled = true;
|
|
130
|
+
window.removeEventListener(CHARACTER_SLOTS_CHANGE_EVENT, refresh);
|
|
131
|
+
window.removeEventListener('storage', refresh);
|
|
132
|
+
if (unlistenTauri) unlistenTauri();
|
|
133
|
+
};
|
|
134
|
+
}, []);
|
|
135
|
+
return {
|
|
136
|
+
slots: snapshot.slots,
|
|
137
|
+
defaultSlot: snapshot.defaultSlot,
|
|
138
|
+
setSlot,
|
|
139
|
+
setDefaultSlot
|
|
140
|
+
};
|
|
141
|
+
}export{CHARACTER_SLOTS_CHANGE_EVENT,CHARACTER_SLOTS_DEFAULT_KEY,CHARACTER_SLOTS_STORAGE_KEY,SLOT_NUMBERS,readCharacterSlots,readDefaultCharacterFileName,readDefaultSlot,setDefaultSlot,setSlot,useCharacterSlots,writeCharacterSlots};//# sourceMappingURL=characterSlotsPreference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"characterSlotsPreference.js","sources":["../../src/hooks/characterSlotsPreference.ts"],"sourcesContent":[null],"names":[],"mappings":"4BAAA;;;;;;;;;AASG;AAEH,MAAA,2BAAa,GAAA;AACb,MAAA,2BAAa,GAAA;AACb,MAAA,4BAAa,GAAA;AAED,kBAAa,IAAI,CAAC,EAAA,CAAG,EAAC,CAAA,EAAI,GAAG,CAAC,EAAA,CAAG,EAAC,CAAA,EAAI,GAAG,CAAC;AACtD,SAAM,YAAM,CAAA,CAAA,EAAA;AAEZ,EAAA,OAAA,MAAO,UAAM,CAAA,CAAA,CAAA,IAAA,CAAY,IAAE,CAAA,IAAA,CAAA,IAAS,CAAA;AAMpC;AAmBA,SAAA,kBAAgB,GAAA;AA+BhB,EAAA,IAAA,OAAA,MAAA,KAAsB,WAAA,EAAA,OAAoB,EAAA;AAU1C,EAAA,IAAA;AAUA,IAAA,MAAA,GAAA,GAAA,MAAA,CAAA,YAAsB,CAAA,OAAmB,CAAA,2BAA4B,CAQpE;AAED,IAAA,IAAA,CAAA,GAAA,EAAA,OAAA,EAAA;AACA,IAAA,MAAA,MAAA,GAAA,IAAA,CAAgB,KAAA,CAAA,GAAA,CAAA;AAUhB,IAAA,cAAiB;IACb,KAAK,iBAAiB,CAAA,IAAA,MAAA,CAAA,OAAA,CAAA,MAAA,CAAA,EAAA;MACtB,MAAA,CAAA,GAAW,WAAY;AACvB,MAAA,IAAA,YAAgB,CAAA,CAAA,CAAA,IAAA,OAAY,KAAQ,KAAE,YAAa,KAAK,CAAA,IAAQ,EAAA,EAAI;QACpE,GAAA,CAAA,CAAA,CAAA,GAAA,KAAiB,CAAA,IAAM,EAAA;AAC1B,MAAA;AAED,IAAA;AACkF,IAAA,OAAA,GAAA;AAClF,EAAA,CAAA,CAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/lib/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * from './activeCharacterPreference';
|
|
2
|
+
export * from './characterSlotsPreference';
|
|
3
|
+
export * from './characterOverrides';
|
|
4
|
+
export * from './useGlobalShortcutBridge';
|
|
2
5
|
export * from './useTheme';
|
|
3
6
|
export * from './useWindowSize';
|
|
4
7
|
export * from './useToast';
|
package/lib/hooks/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subscribes to native global-shortcut events emitted by the Tauri shell and
|
|
3
|
+
* dispatches them to the local React app state.
|
|
4
|
+
*
|
|
5
|
+
* Currently handles:
|
|
6
|
+
* - `bar:switch-slot` `{ slot: 0..9 }` — activates the character assigned to
|
|
7
|
+
* the given slot. `slot === 0` resolves to the user-chosen default slot.
|
|
8
|
+
*
|
|
9
|
+
* No-op in non-Tauri environments. Mount this hook once near the desktop bar
|
|
10
|
+
* root so the listener lives for the lifetime of the bar webview.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Browser CustomEvent names dispatched by this bridge when the corresponding
|
|
14
|
+
* Tauri global shortcut fires. Consumers (e.g. voice hook, activity-tracker
|
|
15
|
+
* UI) listen on `window` to react to the shortcut.
|
|
16
|
+
*/
|
|
17
|
+
export declare const BAR_TOGGLE_MIC_EVENT = "yantra:toggle-mic";
|
|
18
|
+
export declare const BAR_TOGGLE_AUDIO_EVENT = "yantra:toggle-audio";
|
|
19
|
+
export declare const BAR_TOGGLE_EYE_EVENT = "yantra:toggle-eye";
|
|
20
|
+
export declare function useGlobalShortcutBridge(): void;
|
|
21
|
+
//# sourceMappingURL=useGlobalShortcutBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGlobalShortcutBridge.d.ts","sourceRoot":"","sources":["../../src/hooks/useGlobalShortcutBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAsBH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AACxD,eAAO,MAAM,sBAAsB,wBAAwB,CAAC;AAC5D,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AAExD,wBAAgB,uBAAuB,IAAI,IAAI,CA6C9C"}
|