@minicode-dev/chat 0.1.2 → 0.1.4

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/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to `@minicode-dev/chat` (owner: Minicode, project: LIRA).
4
4
 
5
+ ## Unreleased
6
+
7
+ ### Added
8
+
9
+ - Custom image emoji catalogs per provider, with picker, autocomplete and reaction support.
10
+ - Compact, one-click effects picker with sending feedback and sound/autoplay preferences.
11
+ - Nudge, dancing pig and confetti effects with the approved MP3 recordings in `assets/sounds/effects/`.
12
+ - Inline YouTube players for supported links, with a link to open YouTube.
13
+ - Source-based local demo, simulated conversations and an audio audition laboratory.
14
+
15
+ ### Changed
16
+
17
+ - Incoming effects autoplay by default in visible conversations, with a 5-second cooldown and no window-focus requirement.
18
+ - New incoming effects can replace an active animation; confetti now fills the panel with 220 responsive particles.
19
+
20
+ - Effects respect mute, reduced motion, cooldowns and manual replay; old messages and duplicates do not autoplay.
21
+ - Standalone development and release documentation. Host applications must update their served sound assets.
22
+
5
23
  ## 0.1.0 (unreleased)
6
24
 
7
25
  First release extracted from LIRA.
package/README.md CHANGED
@@ -99,7 +99,8 @@ from `/sounds/...`. Either:
99
99
  1. Copy them into the host's public folder, e.g. in a `postinstall`/build step:
100
100
 
101
101
  ```bash
102
- cp -R node_modules/@minicode-dev/chat/assets/sounds public/sounds
102
+ mkdir -p public/sounds
103
+ cp -R node_modules/@minicode-dev/chat/assets/sounds/. public/sounds/
103
104
  ```
104
105
 
105
106
  2. Or serve them from another path/CDN and point the chat at it, before any sound plays:
@@ -115,7 +116,21 @@ The files are also exposed as `@minicode-dev/chat/assets/*` for bundlers that ca
115
116
 
116
117
  ## Local development
117
118
 
118
- This repository builds a library; it does not include a standalone demo or a `dev` script.
119
+ This repository includes a local React demo that consumes the library source directly:
120
+
121
+ ```bash
122
+ npm install
123
+ npm run dev
124
+ ```
125
+
126
+ Vite opens the chat in your browser. The demo provides simulated users, automatic replies,
127
+ groups, emoji, reactions, message editing, attachments and a light/dark theme switch.
128
+ Messages and uploaded files stay in memory and reset on reload. No login or WebSocket
129
+ service is required. GIF/sticker search requires separately configured KLIPY credentials;
130
+ multiplayer games are not simulated. Voice recording requires browser microphone permission.
131
+ The `demo/` directory is excluded from the npm package by the `files` allowlist.
132
+
133
+ To build or pack the library:
119
134
 
120
135
  ```bash
121
136
  npm install
@@ -162,3 +177,118 @@ npm authentication challenge are handled by you. No Git push is performed.
162
177
 
163
178
  The command is named `release` because npm reserves `publish` as a lifecycle hook;
164
179
  a script with that name that calls `npm publish` could invoke itself recursively.
180
+
181
+ ## Feature implementation notes
182
+
183
+ For AI handoff and troubleshooting context, see [CONTEXTO_PARA_IA.md](CONTEXTO_PARA_IA.md)
184
+ in the source repository (not included in the npm archive).
185
+
186
+ For the Spanish implementation record and demo walkthrough, see [NUEVAS_FUNCIONES.md](NUEVAS_FUNCIONES.md)
187
+ in the source repository. This companion document is not included in the npm archive;
188
+ the integration sections below are included.
189
+
190
+ ## Custom image emojis
191
+
192
+ Provide a catalog per chat provider. Custom shortcodes work in messages, the emoji picker,
193
+ autocomplete and reactions. Unicode emojis continue to work normally.
194
+
195
+ ```jsx
196
+ const config = {
197
+ media: {
198
+ emoji: {
199
+ custom: [
200
+ { shortcode: 'team_party', url: 'https://your-app.example/emojis/party.webp', label: 'Team party' },
201
+ ],
202
+ },
203
+ },
204
+ };
205
+ ```
206
+
207
+ Use lowercase names of 1–32 letters, numbers, `_`, `+` or `-`. The catalog accepts up to
208
+ 100 entries. Unknown shortcodes or failed images remain readable as `:team_party:`.
209
+ The consuming application supplies a shared catalog and image URLs for real users;
210
+ it is responsible for upload permissions, storage and preserving images used in history.
211
+ The local demo includes a session-only image uploader (PNG/JPG/WebP/GIF, up to 256 KB
212
+ and 2048 × 2048) and an example image. Open **Nuevas funciones** to try it.
213
+
214
+ ## Zumbidos and animated effects
215
+
216
+ The chat includes a nudge, a dancing pig and confetti with approved audio recordings.
217
+ The pig uses `cerdito_disco_original.mp3`; nudge and confetti use `nudge.mp3` and `confetti.mp3`
218
+ in the same `assets/sounds/effects/` directory. Serve
219
+ `assets/sounds/effects/cerdito_disco_original.mp3` at `/sounds/effects/cerdito_disco_original.mp3`,
220
+ or use the existing `setChatAssetsBaseUrl` sound asset configuration. Copying the complete
221
+ `assets/sounds/` directory as described above includes this recording.
222
+ Open the **Efectos y zumbidos** button in the composer and click an effect to send it
223
+ and play its animation. Each compact row shows sending/sent feedback; sound and automatic
224
+ playback are controlled by two switches. Received
225
+ effects appear as cards with manual replay; new received effects play automatically by default in the visible conversation.
226
+
227
+ ```jsx
228
+ const config = {
229
+ effects: {
230
+ enabled: true,
231
+ autoPlay: true,
232
+ sound: true,
233
+ volume: 0.35,
234
+ cooldownMs: 5000,
235
+ maxAgeMs: 10000,
236
+ allowGroups: false,
237
+ onPreferencesChange: (patch) => console.log('Save user preferences', patch),
238
+ },
239
+ };
240
+ ```
241
+
242
+ Effects use ordinary versioned text messages over the existing transport; servers must
243
+ preserve the message text. `encodeEffect`, `decodeEffect`, `EFFECT_PREFIX`, `EFFECT_CATALOG`
244
+ and `getChatEffect` are exported for integrations. Older clients show a readable fallback
245
+ alongside the versioned payload. Set `effects: false` to disable the feature.
246
+
247
+ Audio requires browser permission to play after a user gesture and respects the chat's
248
+ mute control. Effects stop when closed or when leaving the conversation; motion reduction
249
+ uses a static alternative. History, duplicates and reconnection baselines do not trigger
250
+ automatic playback. Automatic effects require a visible conversation in a visible tab. Same-origin
251
+ tab deduplication is best effort. Receiving clients use a cooldown and ignore stale events.
252
+ The server should enforce its own authorization and rate limits; browser controls alone
253
+ cannot prevent abusive clients.
254
+
255
+ In the demo, **Nuevas funciones** lets you simulate effects from Ana and configure playback.
256
+ The demo permits effects in groups and uses the same 5-second cooldown. None of these
257
+ features requires a paid audio API. Sharing full songs and managing a production emoji
258
+ upload service are outside this implementation.
259
+
260
+ ## YouTube videos in messages
261
+
262
+ Paste a YouTube video link into a message to display an inline player. Supported links
263
+ include `watch?v=`, `youtu.be`, Shorts, Live and embed URLs, including start timestamps.
264
+ The first supported video per message is embedded, with lazy loading and no autoplay.
265
+ The original message is preserved and an **Abrir en YouTube** link is always available
266
+ for videos that cannot play in an embedded player. No API key is required.
267
+
268
+ Set `config.features.youtube` to `false` to disable previews. Playback requires internet
269
+ access and a video that permits embedding. Applications with a Content Security Policy
270
+ must allow `https://www.youtube-nocookie.com` in `frame-src`.
271
+
272
+ ## Proposed audio samples (demo only)
273
+
274
+ Run `npm run dev`, open **Nuevas funciones**, and scroll to **Audios de los efectos**.
275
+ The demo offers WAV previews of a disco/funk pig beat (104 BPM, two bars), a new nudge,
276
+ and a festive confetti cue, alongside the current synthesized sounds for comparison.
277
+ All three approved effects now use MP3 recordings. The pig WAV remains an alternative
278
+ proposal; the nudge and confetti WAVs are the original sources of the approved recordings.
279
+
280
+ `predev` generates the WAV files automatically. Use `npm run audio:samples` to regenerate
281
+ them separately. Generated files live in `demo/audio-samples/`, are ignored by Git and
282
+ excluded from npm. Source generators are in `demo/audio-lab/`; see
283
+ [AUDIO_EFFECTS.md](AUDIO_EFFECTS.md) in the source repository for the arrangement and limitations.
284
+
285
+ ### Fun chat defaults
286
+
287
+ New incoming effects automatically animate in the visible conversation by default;
288
+ manual replay is still available. The default cooldown is 5 seconds. Window focus is
289
+ not required, but hidden tabs and old messages do not replay effects. A new permitted
290
+ effect can replace the animation currently playing. Confetti fills the panel with
291
+ 220 colored particles and scales to its height. Reduced-motion preferences remain respected.
292
+ Browsers can still block sound before the recipient interacts with the site; the visual
293
+ effect does not depend on successful audio playback. Both participants must use an updated
294
+ package, and explicitly saved `autoPlay: false` settings still disable automatic playback.
Binary file