@minicode-dev/chat 0.0.0-stage → 0.1.1
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 +24 -0
- package/README.md +163 -2
- package/assets/sounds/battleship_audio_pack/assets/cannon_fire.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/cruiser_damage_alarm.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/defeat.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ocean_ambient_loop.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/projectile_flyby.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ship_heavy_hit.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ship_hit.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ship_place.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ship_rotate.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ship_sinking.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/sonar_ping.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ui_click.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/victory.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/water_splash.ogg +0 -0
- package/assets/sounds/connect4/close.ogg +0 -0
- package/assets/sounds/connect4/draw.ogg +0 -0
- package/assets/sounds/connect4/drop.ogg +0 -0
- package/assets/sounds/connect4/invite.ogg +0 -0
- package/assets/sounds/connect4/lose.ogg +0 -0
- package/assets/sounds/connect4/start.ogg +0 -0
- package/assets/sounds/connect4/turn.ogg +0 -0
- package/assets/sounds/connect4/win.ogg +0 -0
- package/assets/sounds/notification.mp3 +0 -0
- package/assets/sounds/notification.ogg +0 -0
- package/assets/sounds/ting.mp3 +0 -0
- package/assets/sounds/ting.ogg +0 -0
- package/dist/chunks/BattleshipGameCard-CW_A8Nim.js +958 -0
- package/dist/chunks/BattleshipGameCard-CW_A8Nim.js.map +1 -0
- package/dist/chunks/BattleshipPrototype-Duz-S1JE.js +373 -0
- package/dist/chunks/BattleshipPrototype-Duz-S1JE.js.map +1 -0
- package/dist/chunks/battleship-DXKuIZ1I.js +124 -0
- package/dist/chunks/battleship-DXKuIZ1I.js.map +1 -0
- package/dist/chunks/connect4Sounds-Do3nvVFx.js +1847 -0
- package/dist/chunks/connect4Sounds-Do3nvVFx.js.map +1 -0
- package/dist/chunks/createBattleScene-HIAvjixn.js +1621 -0
- package/dist/chunks/createBattleScene-HIAvjixn.js.map +1 -0
- package/dist/chunks/webglSupport-2WjPEPZ_.js +16 -0
- package/dist/chunks/webglSupport-2WjPEPZ_.js.map +1 -0
- package/dist/index.js +9519 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +2 -0
- package/index.d.ts +470 -0
- package/package.json +67 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@minicode-dev/chat` (owner: Minicode, project: LIRA).
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (unreleased)
|
|
6
|
+
|
|
7
|
+
First release extracted from LIRA.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Package inside the LIRA npm workspace (`packages/chat`), restricted publish under the `@minicode-dev` scope.
|
|
12
|
+
- `LiraChatProvider` with `config` / `transport` / `stores` / `chatStore`, `normalizeConfig` and `DEFAULT_CONFIG`.
|
|
13
|
+
- `ChatTransport` contract, `createStandaloneTransport` and the LIRA transport adapter.
|
|
14
|
+
- Connected placements `ChatWindow`, `ChatPage`, `ChatButton`, `ChatNotifications`, plus presentational primitives
|
|
15
|
+
(`ChatWindowShell`, `MessageList`, `MessageBubble`, `MessageComposer`, emoji/GIF/sticker pickers).
|
|
16
|
+
- Frozen protocol helpers (`LIRA_EDIT_V1:` / `LIRA_REACT_V1:` prefixes, stickers, reactions).
|
|
17
|
+
- Games (Connect 4, Battleship 3D with optional `three`), notifications and PWA helpers.
|
|
18
|
+
- Library build (Vite, ESM) to `dist/index.js` + `dist/styles.css`; hand-written `index.d.ts`.
|
|
19
|
+
- Sounds shipped in `assets/sounds/`, served by the host (`setChatAssetsBaseUrl`).
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- `emojibase-data` is loaded lazily with dynamic `import()` (cached); the emoji picker and autocomplete
|
|
24
|
+
re-render when the catalog arrives (`useEmojiDataReady`).
|
package/README.md
CHANGED
|
@@ -1,3 +1,164 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @minicode-dev/chat
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Real-time chat for React (WebSocket, reactions, editing, emoji, GIFs/stickers via KLIPY, file and voice
|
|
4
|
+
attachments, notifications, Connect 4 and 3D Battleship).
|
|
5
|
+
|
|
6
|
+
Standalone, reusable npm package for integration into React applications through configurable
|
|
7
|
+
providers and transport adapters.
|
|
8
|
+
|
|
9
|
+
- Owner: **Minicode** · License: `UNLICENSED`.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Install the package from npm. If your registry requires authentication, configure an `.npmrc` in
|
|
14
|
+
the host project (keep the token out of git, e.g. via an environment variable):
|
|
15
|
+
|
|
16
|
+
```ini
|
|
17
|
+
@minicode-dev:registry=https://registry.npmjs.org/
|
|
18
|
+
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @minicode-dev/chat react react-dom zustand lucide-react
|
|
23
|
+
# Only if Battleship 3D is enabled:
|
|
24
|
+
npm install three@">=0.134.0 <0.138.0"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Peer dependencies
|
|
28
|
+
|
|
29
|
+
| Package | Range | Notes |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| `react`, `react-dom` | `>=18` | |
|
|
32
|
+
| `zustand` | `^4.5.0 \|\| ^5.0.0` | |
|
|
33
|
+
| `lucide-react` | `>=0.400.0` | |
|
|
34
|
+
| `three` | `>=0.134.0 <0.138.0` | Optional, only for Battleship 3D (loaded lazily). |
|
|
35
|
+
|
|
36
|
+
`emojibase-data` and `dayjs` are regular dependencies. The emoji catalog (~1.4 MB of JSON) is loaded with
|
|
37
|
+
dynamic `import()` the first time the composer/emoji picker mounts, so the host bundler must support
|
|
38
|
+
JSON imports (Vite, webpack 5, Rollup with `@rollup/plugin-json`, esbuild do).
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
```jsx
|
|
43
|
+
import {
|
|
44
|
+
LiraChatProvider, ChatButton, ChatWindow, ChatPage, ChatNotifications,
|
|
45
|
+
} from '@minicode-dev/chat';
|
|
46
|
+
import '@minicode-dev/chat/styles.css';
|
|
47
|
+
|
|
48
|
+
const config = {
|
|
49
|
+
websocket: { url: 'wss://chat.example.com/ws' },
|
|
50
|
+
auth: { getToken: () => localStorage.getItem('token') },
|
|
51
|
+
callbacks: { onError: (error) => console.error(error) },
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export function App() {
|
|
55
|
+
return (
|
|
56
|
+
<LiraChatProvider config={config}>
|
|
57
|
+
<ChatButton label="Chat" />
|
|
58
|
+
<ChatWindow placement="floating" />
|
|
59
|
+
<ChatNotifications />
|
|
60
|
+
</LiraChatProvider>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Full-page route (e.g. /chat, also used by the "detach" window):
|
|
65
|
+
export function ChatRoute() {
|
|
66
|
+
return (
|
|
67
|
+
<LiraChatProvider config={config}>
|
|
68
|
+
<ChatPage />
|
|
69
|
+
</LiraChatProvider>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- `LiraChatProvider` props: `config`, `transport` (inject your own `ChatTransport` adapter;
|
|
75
|
+
the provider never closes an injected transport), `stores`, `chatStore` and `children`. Without a
|
|
76
|
+
`transport`, a standalone WebSocket transport is created from `config.websocket.url`.
|
|
77
|
+
- `ChatWindow` props: `placement` (`'floating' | 'modal' | 'embedded'`), `open` / `onOpenChange`
|
|
78
|
+
(controlled mode), `className`, `BattleshipPreviewComponent`.
|
|
79
|
+
- `ChatPage`: `className`. `ChatButton`: `className`, `label`. `ChatNotifications`: no props.
|
|
80
|
+
- Lower level: `createStandaloneTransport`, `createChatStore`, hooks (`useChatConfig`, `useChatTransport`,
|
|
81
|
+
`useChatConnection`, `useChatUnreadTotal`) and presentational primitives (`ChatWindowShell`,
|
|
82
|
+
`MessageList`, `MessageComposer`, pickers…). See `index.d.ts` for the full typed API; anything not
|
|
83
|
+
exported from the package root is internal.
|
|
84
|
+
|
|
85
|
+
## Styles
|
|
86
|
+
|
|
87
|
+
Import the stylesheet once, anywhere in the host app:
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
import '@minicode-dev/chat/styles.css';
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Assets (sounds)
|
|
94
|
+
|
|
95
|
+
Notification and game sounds ship in `assets/sounds/` (`ting.*`, `notification.*`, `connect4/*.ogg`,
|
|
96
|
+
`battleship_audio_pack/assets/*.ogg`) but **the host serves them**. By default the chat requests them
|
|
97
|
+
from `/sounds/...`. Either:
|
|
98
|
+
|
|
99
|
+
1. Copy them into the host's public folder, e.g. in a `postinstall`/build step:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
cp -R node_modules/@minicode-dev/chat/assets/sounds public/sounds
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
2. Or serve them from another path/CDN and point the chat at it, before any sound plays:
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
import { setChatAssetsBaseUrl } from '@minicode-dev/chat';
|
|
109
|
+
setChatAssetsBaseUrl('https://cdn.example.com/minicode-chat/sounds');
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
(`config.assets.baseUrl` exists in the config schema but is not wired yet; use the function.)
|
|
113
|
+
|
|
114
|
+
The files are also exposed as `@minicode-dev/chat/assets/*` for bundlers that can import asset URLs.
|
|
115
|
+
|
|
116
|
+
## Local development
|
|
117
|
+
|
|
118
|
+
This repository builds a library; it does not include a standalone demo or a `dev` script.
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm install
|
|
122
|
+
npm run build # ESM library and styles in dist/
|
|
123
|
+
npm pack # builds again via prepack and creates an installable .tgz
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
To test local changes, install the generated tarball in a React application:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Run inside your consuming application; adjust the path and package version.
|
|
130
|
+
npm install /path/to/minicode-chat/minicode-dev-chat-0.1.0.tgz
|
|
131
|
+
npm run dev # if your application provides this script
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Repeat packing and installation after changes. Installation updates the consuming application's
|
|
135
|
+
local dependency files. Real-time messaging requires a compatible WebSocket service and any
|
|
136
|
+
necessary authentication, supplied by the consuming application.
|
|
137
|
+
|
|
138
|
+
For source-based development, the custom `@minicode-dev/source` export condition points at `src/`.
|
|
139
|
+
Tooling must explicitly enable it (for example through Vite's `resolve.conditions`) and resolve
|
|
140
|
+
this local package. It is not enabled by default; React and other shared peers must resolve to
|
|
141
|
+
one copy in the consuming application.
|
|
142
|
+
|
|
143
|
+
## Publishing updates
|
|
144
|
+
|
|
145
|
+
Log in yourself with `npm login`, then run:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
npm run release # patch version, build, validate contents, publish
|
|
149
|
+
npm run release -- minor # minor version
|
|
150
|
+
npm run release -- major # major version
|
|
151
|
+
npm run release -- --dry-run # build and inspect; no version change or publication
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The release script checks your npm session, builds, increments the version without
|
|
155
|
+
creating a Git commit or tag, and validates the exact archive before publishing it.
|
|
156
|
+
Only `dist/`, `assets/`, public types, README, changelog and package metadata are allowed.
|
|
157
|
+
Temporary archives and this package's root `.tgz` files are removed even on failure.
|
|
158
|
+
Build output in `dist/` is retained for local use. If publication fails after the
|
|
159
|
+
version bump, the updated version remains in `package.json` and the lockfile.
|
|
160
|
+
Registry access follows `publishConfig` in `package.json`; login and any required
|
|
161
|
+
npm authentication challenge are handled by you. No Git push is performed.
|
|
162
|
+
|
|
163
|
+
The command is named `release` because npm reserves `publish` as a lifecycle hook;
|
|
164
|
+
a script with that name that calls `npm publish` could invoke itself recursively.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|