@jchat/addon-sdk 1.0.0-alpha.11 → 1.0.0-alpha.12
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 +17 -0
- package/README.md +339 -61
- package/dist/cli.d.mts +6 -7
- package/dist/cli.mjs +3 -2
- package/dist/contracts.d.mts +5 -6
- package/dist/contracts.mjs +38 -0
- package/dist/diagnostics.d.mts +8 -9
- package/dist/diagnostics.mjs +1 -1
- package/dist/i18n-validator.d.mts +17 -0
- package/dist/i18n-validator.mjs +90 -0
- package/dist/i18n.mjs +191 -0
- package/dist/icon.d.mts +4 -0
- package/dist/icon.mjs +4 -0
- package/dist/index.d.mts +16 -510
- package/dist/index.mjs +6 -338
- package/dist/index2.d.mts +478 -0
- package/dist/state.d.mts +1 -0
- package/dist/state.mjs +2 -0
- package/dist/types.d.mts +12 -0
- package/dist/vite.d.mts +7 -8
- package/dist/vite.mjs +51 -11
- package/package.json +93 -16
- package/skills/create-jchat-addon/SKILL.md +140 -0
- package/skills/jchat-addon-development/SKILL.md +260 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @jchat/addon-sdk
|
|
2
2
|
|
|
3
|
+
## 1.0.0-alpha.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3d4d0ad: - Add interactive terminal UI powered by `@clack/prompts` with automatic TTY detection and positional argument support
|
|
8
|
+
- Add full-stack addon template scaffolding with Elysia API router, Kysely database schema, SQL migrations, and custom permission definitions
|
|
9
|
+
- Add multi-mountpoint support with dynamic UI rendering and directional RTL/LTR styles
|
|
10
|
+
- Expand locale scaffolding to all 20 host languages with 100% key parity and automated synchronization testing
|
|
11
|
+
- Strongly type `MountPoint` and `MOUNT_POINTS` contracts across generator and CLI interfaces
|
|
12
|
+
- Bundle contracts inline in `@jchat/create-addon` for standalone, zero-dependency CLI execution
|
|
13
|
+
- Export `./contracts` subpath from `@jchat/addon-sdk` for lightweight, framework-agnostic contract imports
|
|
14
|
+
- 7b86222: Add official customer-facing Agent Skills for JChat addon development and creation. Bundles `@jchat/addon-sdk` skills (`jchat-addon-development` and `create-jchat-addon`) for AI coding assistants and automatically scaffolds in-workspace skills when creating new addon projects.
|
|
15
|
+
- c5fa55f: Support direct icon imports via `@jchat/addon-sdk/icon` and align icon packs with canonical Lucide icon definitions. Addons can now import `Icons` directly without requiring hook invocation (`useIcons`), while maintaining backward compatibility for existing addons.
|
|
16
|
+
- 27efa80: - Update third-party developer guide in README with complete quick start, architecture specifications, hook references, and mount points
|
|
17
|
+
- Include `LICENSE` file in published npm package distribution
|
|
18
|
+
- Update license badge and terms references to link to official public web address (`https://jchatlive.com/terms`)
|
|
19
|
+
|
|
3
20
|
## 1.0.0-alpha.11
|
|
4
21
|
|
|
5
22
|
## 1.0.0-alpha.10
|
package/README.md
CHANGED
|
@@ -1,63 +1,256 @@
|
|
|
1
1
|
# @jchat/addon-sdk
|
|
2
2
|
|
|
3
|
-
Official TypeScript SDK for developing extensions, UI widgets, and server plugins for the [JChat](https://
|
|
3
|
+
Official TypeScript SDK for developing extensions, UI widgets, and server plugins for the [JChat](https://jchatlive.com) communication platform.
|
|
4
4
|
|
|
5
5
|
Provides typed interfaces, manifest contracts, Vite bundler plugins, and CLI development tooling for building sandboxed JChat addons.
|
|
6
6
|
|
|
7
|
+
[](https://www.npmjs.com/package/@jchat/addon-sdk)
|
|
8
|
+
[](https://jchatlive.com/terms)
|
|
9
|
+
|
|
7
10
|
---
|
|
8
11
|
|
|
9
|
-
##
|
|
12
|
+
## Architecture Overview
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
bun add -d @jchat/addon-sdk
|
|
13
|
-
```
|
|
14
|
+
JChat addons are **sandboxed, modular extensions** designed to enhance real-time chats without modifying core database schemas or server code.
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
- **Ultra-Lightweight Server Bundles**: Elysia and TypeBox are externalized and provided directly by the host server runtime via `ctx.t` and `app`. Server bundles (`build/api.js`) compile down to just **2–7 KB**.
|
|
17
|
+
- **Zero Frontend Bundle Bloat**: Host externals (`react`, `react-dom`, `@jchat/ui`, `@jchat/icon`, `@tanstack/react-query`, `jotai`) are injected at runtime by the JChat host application.
|
|
18
|
+
- **Isolated Database Schema**: Addon tables reside exclusively in the isolated `addons` PostgreSQL schema (e.g. `addons.GlimpseStories`), preventing collisions with core chat tables.
|
|
19
|
+
- **Scoped Cache & Real-Time Events**: Addons receive namespaced Redis cache (`addon:<id>:<key>`) and real-time WebSocket event broadcasting scoped to sites, rooms, or users.
|
|
20
|
+
- **20-Language i18n Standard**: First-class internationalization with 100% parity across all 20 supported host languages, including full RTL direction support.
|
|
16
21
|
|
|
17
22
|
---
|
|
18
23
|
|
|
19
24
|
## Requirements
|
|
20
25
|
|
|
21
|
-
- **Bun**: 1.4.0
|
|
22
|
-
- **React**:
|
|
23
|
-
- **Vite**:
|
|
26
|
+
- **Bun**: `1.4.0+`
|
|
27
|
+
- **React**: `19+`
|
|
28
|
+
- **Vite**: `8+`
|
|
24
29
|
|
|
25
30
|
---
|
|
26
31
|
|
|
27
|
-
##
|
|
32
|
+
## Installation
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
Install as a development dependency:
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
```bash
|
|
37
|
+
bun add -d @jchat/addon-sdk
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Or scaffold a new addon instantly with the official CLI:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
bun create @jchat/addon my-new-addon
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Quick Start Guide
|
|
49
|
+
|
|
50
|
+
### 1. Define the Addon Manifest (`src/manifest.ts`)
|
|
51
|
+
|
|
52
|
+
Use `defineAddonManifest` (or type with `AddonManifest`) to declare metadata, permissions, mount points, and supported languages:
|
|
32
53
|
|
|
33
54
|
```ts
|
|
34
|
-
import
|
|
55
|
+
import { defineAddonManifest } from "@jchat/addon-sdk"
|
|
35
56
|
|
|
36
|
-
|
|
37
|
-
id: "
|
|
38
|
-
name: "
|
|
57
|
+
export default defineAddonManifest({
|
|
58
|
+
id: "gifyard",
|
|
59
|
+
name: "Gifyard GIF Picker",
|
|
39
60
|
version: "1.0.0",
|
|
40
|
-
description: "
|
|
41
|
-
author: "
|
|
61
|
+
description: "Search and insert animated GIFs directly into chat messages.",
|
|
62
|
+
author: "JChat Ecosystem Team",
|
|
63
|
+
publisher: { id: "jchat" },
|
|
42
64
|
compatibility: {
|
|
43
65
|
jchat: ">=1.0.0-alpha.0 <2.0.0",
|
|
44
|
-
addonSdk: "
|
|
66
|
+
addonSdk: "^1.0.0"
|
|
45
67
|
},
|
|
46
|
-
locales: [
|
|
68
|
+
locales: [
|
|
69
|
+
"ar",
|
|
70
|
+
"bg",
|
|
71
|
+
"de",
|
|
72
|
+
"el",
|
|
73
|
+
"en",
|
|
74
|
+
"es",
|
|
75
|
+
"fr",
|
|
76
|
+
"he",
|
|
77
|
+
"hi",
|
|
78
|
+
"hr",
|
|
79
|
+
"kn",
|
|
80
|
+
"ml",
|
|
81
|
+
"nl",
|
|
82
|
+
"pt",
|
|
83
|
+
"ro",
|
|
84
|
+
"ru",
|
|
85
|
+
"ta",
|
|
86
|
+
"te",
|
|
87
|
+
"tr",
|
|
88
|
+
"ur"
|
|
89
|
+
],
|
|
47
90
|
defaultLocale: "en",
|
|
48
91
|
frontend: {
|
|
49
92
|
bundle: "./ui.js",
|
|
50
|
-
mountPoints: ["chat-toolbar", "
|
|
93
|
+
mountPoints: ["chat-toolbar", "emoji-picker-gif-tab", "addon-settings"]
|
|
94
|
+
},
|
|
95
|
+
server: {
|
|
96
|
+
bundle: "./api.ts",
|
|
97
|
+
migrations: ["./migrations/0001_init.sql"]
|
|
51
98
|
},
|
|
52
|
-
|
|
99
|
+
accessPermission: "addon.gifyard.view",
|
|
100
|
+
permissions: ["addon.gifyard.view", "addon.gifyard.manage"],
|
|
101
|
+
permissionDefinitions: [
|
|
102
|
+
{
|
|
103
|
+
name: "addon.gifyard.view",
|
|
104
|
+
label: "View GIFs",
|
|
105
|
+
description: "Search and preview animated GIFs in chat"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "addon.gifyard.manage",
|
|
109
|
+
label: "Manage Gifyard",
|
|
110
|
+
description: "Configure Giphy API keys and content rating settings"
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### 2. Build the Frontend UI (`src/ui.tsx`)
|
|
119
|
+
|
|
120
|
+
Addon UI components receive typed `AddonProps` and access host services via the `useAddonSDK()` hook:
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
import { useAddonSDK, useAddonQuery, useTranslation, type AddonProps } from "@jchat/addon-sdk"
|
|
124
|
+
import Icons from "@jchat/addon-sdk/icon"
|
|
125
|
+
import locales from "./locales"
|
|
126
|
+
|
|
127
|
+
export default function MyAddon({ mountPoint, roomId }: AddonProps) {
|
|
128
|
+
const sdk = useAddonSDK()
|
|
129
|
+
const { t, dir } = useTranslation(locales)
|
|
130
|
+
|
|
131
|
+
// Type-safe data fetching via TanStack Query bridge
|
|
132
|
+
const { data, isLoading } = useAddonQuery<{ items: string[] }>({
|
|
133
|
+
path: "/items",
|
|
134
|
+
queryKey: [roomId]
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
const handleInsert = (text: string) => {
|
|
138
|
+
// Insert rich content directly into the active Slate message editor
|
|
139
|
+
sdk.editor.dispatchCommand("INSERT_TEXT", text)
|
|
140
|
+
sdk.toast(t("item_inserted"), "success")
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<div dir={dir} className="rounded-2xl border border-border bg-card p-4 shadow-sm">
|
|
145
|
+
<div className="flex items-center gap-2 font-bold">
|
|
146
|
+
<Icons.Sparkles className="size-4 text-primary" />
|
|
147
|
+
<span>{t("addon_title")}</span>
|
|
148
|
+
</div>
|
|
149
|
+
{isLoading ? (
|
|
150
|
+
<p className="text-xs text-muted-foreground">{t("loading")}</p>
|
|
151
|
+
) : (
|
|
152
|
+
<button
|
|
153
|
+
onClick={() => handleInsert("Hello from Addon!")}
|
|
154
|
+
className="mt-3 rounded-lg bg-primary px-3 py-1.5 text-xs font-semibold text-primary-foreground"
|
|
155
|
+
>
|
|
156
|
+
{t("insert_action")}
|
|
157
|
+
</button>
|
|
158
|
+
)}
|
|
159
|
+
</div>
|
|
160
|
+
)
|
|
53
161
|
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
> **Directional Styling Rule**: Always use Tailwind logical directional properties (`ps-*`, `pe-*`, `ms-*`, `me-*`, `text-start`, `text-end`, `start-*`, `end-*`) to automatically adapt to RTL languages (`ar`, `he`, `ur`).
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
### 3. Build the Backend API (`src/api.ts`)
|
|
169
|
+
|
|
170
|
+
Define type-safe Elysia API endpoints. The schema validator `t` is injected directly via `ctx.t`, so your production bundle never imports or bundles Elysia:
|
|
54
171
|
|
|
55
|
-
|
|
172
|
+
```ts
|
|
173
|
+
import type { AddonApp, AddonServerContext } from "@jchat/addon-sdk"
|
|
174
|
+
|
|
175
|
+
export interface MyAddonDatabase {
|
|
176
|
+
addon_items: {
|
|
177
|
+
id: string
|
|
178
|
+
siteId: string
|
|
179
|
+
roomId: string
|
|
180
|
+
userId: string
|
|
181
|
+
title: string
|
|
182
|
+
createdAt: Date
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export default (
|
|
187
|
+
{ db, t, emit, cache, getConfig, getUser, hasPermission }: AddonServerContext<MyAddonDatabase>,
|
|
188
|
+
app: AddonApp
|
|
189
|
+
) => {
|
|
190
|
+
return app
|
|
191
|
+
.get(
|
|
192
|
+
"/items",
|
|
193
|
+
async ({ query, user }) => {
|
|
194
|
+
const siteId = user?.siteId ?? ""
|
|
195
|
+
const items = await db
|
|
196
|
+
.selectFrom("addon_items")
|
|
197
|
+
.where("siteId", "=", siteId)
|
|
198
|
+
.where("roomId", "=", query.roomId ?? "")
|
|
199
|
+
.orderBy("createdAt", "desc")
|
|
200
|
+
.limit(20)
|
|
201
|
+
.selectAll()
|
|
202
|
+
.execute()
|
|
203
|
+
|
|
204
|
+
return { items }
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
requirePermission: "addon.myaddon.view",
|
|
208
|
+
query: t.Object({
|
|
209
|
+
roomId: t.Optional(t.String())
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
.post(
|
|
214
|
+
"/items",
|
|
215
|
+
async ({ body, user, status }) => {
|
|
216
|
+
if (!user) {
|
|
217
|
+
return status(401, { error: "Authentication required" })
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const id = Bun.randomUUIDv7()
|
|
221
|
+
await db
|
|
222
|
+
.insertInto("addon_items")
|
|
223
|
+
.values({
|
|
224
|
+
id,
|
|
225
|
+
siteId: user.siteId!,
|
|
226
|
+
roomId: body.roomId,
|
|
227
|
+
userId: user.id,
|
|
228
|
+
title: body.title,
|
|
229
|
+
createdAt: new Date()
|
|
230
|
+
})
|
|
231
|
+
.execute()
|
|
232
|
+
|
|
233
|
+
// Broadcast real-time WebSocket event
|
|
234
|
+
await emit("addon:myaddon:item-created", { id, title: body.title }, { roomId: body.roomId })
|
|
235
|
+
|
|
236
|
+
return { id, title: body.title }
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
requirePermission: "addon.myaddon.manage",
|
|
240
|
+
body: t.Object({
|
|
241
|
+
roomId: t.String(),
|
|
242
|
+
title: t.String({ minLength: 1 })
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
)
|
|
246
|
+
}
|
|
56
247
|
```
|
|
57
248
|
|
|
58
|
-
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
### 4. Configure Vite Bundling (`vite.config.ts`)
|
|
59
252
|
|
|
60
|
-
|
|
253
|
+
Include the official Vite plugin for automatic manifest bundling, externalization, and live development:
|
|
61
254
|
|
|
62
255
|
```ts
|
|
63
256
|
import { defineConfig } from "vite"
|
|
@@ -68,65 +261,150 @@ export default defineConfig({
|
|
|
68
261
|
})
|
|
69
262
|
```
|
|
70
263
|
|
|
71
|
-
|
|
264
|
+
---
|
|
72
265
|
|
|
73
|
-
|
|
266
|
+
## SDK Modules & API Reference
|
|
74
267
|
|
|
75
|
-
|
|
76
|
-
# Build addon bundle and generate distribution zip
|
|
77
|
-
bun run jchat-addon build --zip
|
|
268
|
+
### 1. Host Bridge: `useAddonSDK()`
|
|
78
269
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
270
|
+
Provides access to the active JChat host application bridge:
|
|
271
|
+
|
|
272
|
+
| Property | Type | Description |
|
|
273
|
+
| :--------------- | :----------------- | :------------------------------------------------------------------------------------------------------------- |
|
|
274
|
+
| `api` | `AddonApi` | Authenticated HTTP client (`get`, `post`, `put`, `delete`) automatically scoped to `/api/v1/addons/<addonId>`. |
|
|
275
|
+
| `settings` | `AddonSettingsApi` | First-class configuration helper to load and save addon settings (`get()`, `save()`). |
|
|
276
|
+
| `editor` | `AddonEditorApi` | Active Slate editor controls (`dispatchCommand`, `insertNode`, `addAttachment`, `focus`). |
|
|
277
|
+
| `events` | `AddonEventBus` | Real-time WebSocket event listeners (`on`, `off`). |
|
|
278
|
+
| `toast` | `function` | Display host toast notifications (`default`, `success`, `error`). |
|
|
279
|
+
| `navigate` | `function` | Navigate to internal host routes without triggering a full page reload. |
|
|
280
|
+
| `supportedFonts` | `AddonFont[]` | List of fonts configured by the site administrator with scale multipliers. |
|
|
281
|
+
| `locale` | `string` | Active user locale code (e.g. `'en'`, `'ta'`, `'ar'`). |
|
|
282
|
+
| `dir` | `'ltr' \| 'rtl'` | Current layout text direction. |
|
|
82
283
|
|
|
83
284
|
---
|
|
84
285
|
|
|
85
|
-
|
|
286
|
+
### 2. Data Fetching: `@jchat/addon-sdk/query`
|
|
86
287
|
|
|
87
|
-
|
|
288
|
+
Integrated TanStack Query wrappers pre-configured with host caching, auto-invalidation, and credentials:
|
|
88
289
|
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
290
|
+
- **`useAddonQuery({ path, queryKey, ...options })`**: Cached GET requests automatically prefixed with `/api/v1/addons/<addonId>`.
|
|
291
|
+
- **`useAddonMutation({ path, method, invalidateQueries, ...options })`**: Declarative mutations with automatic query invalidation.
|
|
292
|
+
- **`useAddonInfiniteQuery({ path, queryKey, initialPageParam, getNextPageParam })`**: Paginated and infinite-scroll queries.
|
|
293
|
+
- **`useQueryClient()`**: Access the underlying TanStack Query client.
|
|
93
294
|
|
|
94
|
-
|
|
95
|
-
import type { AddonServerContext } from "@jchat/addon-sdk"
|
|
295
|
+
---
|
|
96
296
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
siteId: string
|
|
101
|
-
enabled: boolean
|
|
102
|
-
createdAt: Date
|
|
103
|
-
}
|
|
104
|
-
}
|
|
297
|
+
### 3. Atomic State: `@jchat/addon-sdk/state`
|
|
298
|
+
|
|
299
|
+
Re-exports Jotai state management primitives for maintaining synchronized, reactive UI state across multiple mount points:
|
|
105
300
|
|
|
106
|
-
|
|
301
|
+
```tsx
|
|
302
|
+
import { atom, useAtom, useAtomValue, useSetAtom } from "@jchat/addon-sdk/state"
|
|
303
|
+
|
|
304
|
+
export const activeTabAtom = atom<"trending" | "search">("trending")
|
|
107
305
|
```
|
|
108
306
|
|
|
109
307
|
---
|
|
110
308
|
|
|
111
|
-
|
|
309
|
+
### 4. Localization: `useTranslation()` & `useLocale()`
|
|
112
310
|
|
|
113
|
-
|
|
311
|
+
Addons must support all **20 host languages**:
|
|
312
|
+
`ar`, `bg`, `de`, `el`, `en`, `es`, `fr`, `he`, `hi`, `hr`, `kn`, `ml`, `nl`, `pt`, `ro`, `ru`, `ta`, `te`, `tr`, `ur`.
|
|
114
313
|
|
|
115
314
|
```tsx
|
|
116
|
-
import
|
|
315
|
+
import { useTranslation, useLocale } from "@jchat/addon-sdk"
|
|
316
|
+
import locales from "./locales"
|
|
117
317
|
|
|
118
|
-
export default function
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
<h3 className="font-semibold">{t("my_addon_title")}</h3>
|
|
122
|
-
<p className="text-sm text-muted-foreground">{context.siteId}</p>
|
|
123
|
-
</div>
|
|
124
|
-
)
|
|
318
|
+
export default function MyComponent() {
|
|
319
|
+
const { t, dir, isRtl, locale } = useTranslation(locales)
|
|
320
|
+
return <div dir={dir}>{t("welcome", { name: "User" })}</div>
|
|
125
321
|
}
|
|
126
322
|
```
|
|
127
323
|
|
|
324
|
+
For backend server routes (`src/api.ts`), use `createTranslator(locales, defaultLocale)` to translate server-sent notifications or messages.
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
### 5. Icons: `@jchat/addon-sdk/icon`
|
|
329
|
+
|
|
330
|
+
Imports the site's active icon pack directly, ensuring visual consistency with the host theme:
|
|
331
|
+
|
|
332
|
+
```tsx
|
|
333
|
+
import Icons from "@jchat/addon-sdk/icon"
|
|
334
|
+
|
|
335
|
+
;<Icons.Heart className="size-4 text-red-500" />
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
### 6. Server Context: `AddonServerContext`
|
|
341
|
+
|
|
342
|
+
The context passed to your server plugin (`src/api.ts`):
|
|
343
|
+
|
|
344
|
+
| Property | Type | Description |
|
|
345
|
+
| :-------------- | :--------------------- | :---------------------------------------------------------------------------------------- |
|
|
346
|
+
| `t` | `typeof t` | Elysia / TypeBox schema validator for defining `body`, `query`, `params`, and `headers`. |
|
|
347
|
+
| `db` | `AddonDatabase<T>` | Schema-scoped Kysely query builder (`selectFrom`, `insertInto`, `updateTable`, etc.). |
|
|
348
|
+
| `cache` | `AddonCacheClient` | Namespaced Redis client (`get`, `set`, `del`, `incr`, `expire`, `ttl`). |
|
|
349
|
+
| `emit` | `function` | Real-time WebSocket event broadcaster with target options (`siteId`, `roomId`, `userId`). |
|
|
350
|
+
| `getConfig` | `(siteId) => Promise` | Retrieve encrypted site configuration with automatic decryption. |
|
|
351
|
+
| `getUser` | `(userId) => Promise` | Fetch a single user's public profile (`id`, `name`, `displayName`, `avatar`, `gender`). |
|
|
352
|
+
| `getUsers` | `(userIds) => Promise` | Batch-fetch multiple user profiles in a single query. |
|
|
353
|
+
| `hasPermission` | `(user, perm) => bool` | Check whether a request user holds a given permission scope. |
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## Supported UI Mount Points
|
|
358
|
+
|
|
359
|
+
Addons can mount into any combination of locations defined in `MOUNT_POINTS`:
|
|
360
|
+
|
|
361
|
+
| Mount Point | Identifier | Description |
|
|
362
|
+
| :----------------------- | :------------------------- | :------------------------------------------------------------------------------ |
|
|
363
|
+
| **Chat Toolbar** | `chat-toolbar` | Action button rendered in the message composer toolbar. |
|
|
364
|
+
| **Chat Plus Menu** | `chat-plus-menu` | Action item inside the message composer (+) expandable menu. |
|
|
365
|
+
| **Chat Sidebar** | `chat-sidebar` | Dedicated right-hand collapsible panel in active chat rooms. |
|
|
366
|
+
| **Chat Header** | `chat-header` | Action button or widget rendered in the chat room top header. |
|
|
367
|
+
| **Sidebar Top** | `sidebar-top` | Placed at the top of the left-hand navigation sidebar. |
|
|
368
|
+
| **Sidebar Bottom** | `sidebar-bottom` | Placed at the bottom of the left-hand navigation sidebar (e.g. AdSense banner). |
|
|
369
|
+
| **User Popover Actions** | `user-popover-actions` | Custom action buttons in the user profile card popup. |
|
|
370
|
+
| **Message Context Menu** | `message-context-menu` | Custom actions on right-clicking or long-pressing a message. |
|
|
371
|
+
| **Message Feed Overlay** | `message-feed-overlay` | Floating banner or widget overlaid across the message stream. |
|
|
372
|
+
| **GIF Picker Tab** | `emoji-picker-gif-tab` | Custom GIF provider tab in the emoji/media drawer. |
|
|
373
|
+
| **Sticker Picker Tab** | `emoji-picker-sticker-tab` | Custom sticker provider tab in the emoji/media drawer. |
|
|
374
|
+
| **Addon Settings** | `addon-settings` | Configuration panel inside the Site Admin Dashboard. |
|
|
375
|
+
| **Owner Settings** | `owner-settings` | Global configuration panel inside the System Owner Dashboard. |
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## CLI Development Workflow
|
|
380
|
+
|
|
381
|
+
The SDK provides the `jchat-addon` CLI for local development, building, and validation:
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
# Start live development watcher with hot module reloading
|
|
385
|
+
bun run dev
|
|
386
|
+
|
|
387
|
+
# Run TypeScript typechecks
|
|
388
|
+
bun run typecheck
|
|
389
|
+
|
|
390
|
+
# Execute local unit and contract tests
|
|
391
|
+
bun test
|
|
392
|
+
|
|
393
|
+
# Build production bundles (build/ui.js and build/api.js)
|
|
394
|
+
bun run build
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## Publishing to JChat Marketplace
|
|
400
|
+
|
|
401
|
+
1. Build your addon package: `bun run build`.
|
|
402
|
+
2. Ensure all 20 translation files pass validation: `bun test`.
|
|
403
|
+
3. Package your addon distribution archive.
|
|
404
|
+
4. Sign in to the **[JChat Store Developer Portal](https://jchatlive.com/addons)** and submit your addon package for certified distribution.
|
|
405
|
+
|
|
128
406
|
---
|
|
129
407
|
|
|
130
408
|
## License
|
|
131
409
|
|
|
132
|
-
Proprietary — All rights reserved. See the [
|
|
410
|
+
Proprietary — All rights reserved. See the [Commercial EULA & Licensing Terms](https://jchatlive.com/terms) for full details.
|
package/dist/cli.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AddonManifest } from "./contracts.mjs";
|
|
2
2
|
import { InlineConfig } from "vite";
|
|
3
3
|
//#region src/cli.d.ts
|
|
4
4
|
/** Options for resolving addon build configuration. */
|
|
5
|
-
interface AddonCliOptions {
|
|
5
|
+
export interface AddonCliOptions {
|
|
6
6
|
rootDir?: string;
|
|
7
7
|
command?: "build" | "dev" | "help";
|
|
8
8
|
mode?: "production" | "development";
|
|
@@ -17,7 +17,7 @@ interface AddonCliOptions {
|
|
|
17
17
|
* @param rootDir - Root directory of the addon workspace.
|
|
18
18
|
* @returns Parsed {@link AddonManifest}.
|
|
19
19
|
*/
|
|
20
|
-
declare function loadAddonManifest(rootDir: string): Promise<AddonManifest>;
|
|
20
|
+
export declare function loadAddonManifest(rootDir: string): Promise<AddonManifest>;
|
|
21
21
|
/**
|
|
22
22
|
* Resolves the full Vite configuration for building a JChat addon, merging user custom configs if
|
|
23
23
|
* present.
|
|
@@ -25,12 +25,11 @@ declare function loadAddonManifest(rootDir: string): Promise<AddonManifest>;
|
|
|
25
25
|
* @param options - CLI build options.
|
|
26
26
|
* @returns Fully merged {@link InlineConfig} for Vite.
|
|
27
27
|
*/
|
|
28
|
-
declare function resolveAddonBuildConfig(options?: AddonCliOptions): Promise<InlineConfig>;
|
|
28
|
+
export declare function resolveAddonBuildConfig(options?: AddonCliOptions): Promise<InlineConfig>;
|
|
29
29
|
/**
|
|
30
30
|
* Main CLI handler for `jchat-addon`.
|
|
31
31
|
*
|
|
32
32
|
* @param args - CLI arguments (defaults to `process.argv.slice(2)`).
|
|
33
33
|
*/
|
|
34
|
-
declare function runAddonCli(args?: string[]): Promise<void>;
|
|
35
|
-
//#endregion
|
|
36
|
-
export { AddonCliOptions, loadAddonManifest, resolveAddonBuildConfig, runAddonCli };
|
|
34
|
+
export declare function runAddonCli(args?: string[]): Promise<void>;
|
|
35
|
+
//#endregion
|
package/dist/cli.mjs
CHANGED
|
@@ -120,12 +120,13 @@ Options:
|
|
|
120
120
|
`);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
const config = await resolveAddonBuildConfig({
|
|
124
124
|
command,
|
|
125
125
|
mode,
|
|
126
126
|
watch,
|
|
127
127
|
zip
|
|
128
|
-
})
|
|
128
|
+
});
|
|
129
|
+
await build(config);
|
|
129
130
|
}
|
|
130
131
|
if (import.meta.main) runAddonCli().catch((error) => {
|
|
131
132
|
console.error("❌ Addon build failed:", error);
|
package/dist/contracts.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/contracts.d.ts
|
|
2
2
|
/** Definition of a custom permission introduced by an addon. */
|
|
3
|
-
interface AddonPermissionDefinition {
|
|
3
|
+
export interface AddonPermissionDefinition {
|
|
4
4
|
/** Permission identifier (recommended: `addon.<id>.<action>`) */
|
|
5
5
|
name: string;
|
|
6
6
|
/** Short, human-readable name for the permission */
|
|
@@ -9,7 +9,7 @@ interface AddonPermissionDefinition {
|
|
|
9
9
|
description: string;
|
|
10
10
|
}
|
|
11
11
|
/** Valid locations where an addon can be rendered within the Jchat layout. */
|
|
12
|
-
declare const MOUNT_POINTS: {
|
|
12
|
+
export declare const MOUNT_POINTS: {
|
|
13
13
|
/** Top of the main chat column */
|
|
14
14
|
readonly CHAT_HEADER: "chat-header";
|
|
15
15
|
/** Below the main chat header, above messages */
|
|
@@ -44,12 +44,12 @@ declare const MOUNT_POINTS: {
|
|
|
44
44
|
readonly ADDON_SETTINGS: "addon-settings";
|
|
45
45
|
};
|
|
46
46
|
/** Union type of all valid addon mount points. */
|
|
47
|
-
type MountPoint = (typeof MOUNT_POINTS)[keyof typeof MOUNT_POINTS];
|
|
47
|
+
export type MountPoint = (typeof MOUNT_POINTS)[keyof typeof MOUNT_POINTS];
|
|
48
48
|
/**
|
|
49
49
|
* The `manifest.json` schema required for every Jchat addon. This file describes how the addon is
|
|
50
50
|
* identified and mounted.
|
|
51
51
|
*/
|
|
52
|
-
interface AddonManifest {
|
|
52
|
+
export interface AddonManifest {
|
|
53
53
|
/** Unique kebab-case addon identifier (must match the folder name) */
|
|
54
54
|
id: string;
|
|
55
55
|
/** Human-readable addon name */
|
|
@@ -118,5 +118,4 @@ interface AddonManifest {
|
|
|
118
118
|
/** Custom permissions that should be registered with the host application on installation */
|
|
119
119
|
permissionDefinitions?: AddonPermissionDefinition[];
|
|
120
120
|
}
|
|
121
|
-
//#endregion
|
|
122
|
-
export { MountPoint as i, AddonPermissionDefinition as n, MOUNT_POINTS as r, AddonManifest as t };
|
|
121
|
+
//#endregion
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/contracts.ts
|
|
2
|
+
/** Valid locations where an addon can be rendered within the Jchat layout. */
|
|
3
|
+
const MOUNT_POINTS = {
|
|
4
|
+
/** Top of the main chat column */
|
|
5
|
+
CHAT_HEADER: "chat-header",
|
|
6
|
+
/** Below the main chat header, above messages */
|
|
7
|
+
CHAT_TOOLBAR: "chat-toolbar",
|
|
8
|
+
/** The persistent right-side sidebar */
|
|
9
|
+
CHAT_SIDEBAR: "chat-sidebar",
|
|
10
|
+
/** Top of the left sidebar (room list) */
|
|
11
|
+
SIDEBAR_TOP: "sidebar-top",
|
|
12
|
+
/** Bottom of the left sidebar */
|
|
13
|
+
SIDEBAR_BOTTOM: "sidebar-bottom",
|
|
14
|
+
/** Action list shown when clicking a user's avatar */
|
|
15
|
+
USER_POPOVER_ACTIONS: "user-popover-actions",
|
|
16
|
+
/** Menu shown when right-clicking a message */
|
|
17
|
+
MESSAGE_CONTEXT_MENU: "message-context-menu",
|
|
18
|
+
/** Floating overlay rendered on top of the message stream */
|
|
19
|
+
MESSAGE_FEED_OVERLAY: "message-feed-overlay",
|
|
20
|
+
/** Main admin dashboard area */
|
|
21
|
+
ADMIN_PANEL: "admin-panel",
|
|
22
|
+
/** User or site settings dashboard area */
|
|
23
|
+
SETTINGS_PANEL: "settings-panel",
|
|
24
|
+
/** The 'plus' (+) menu in the message composer */
|
|
25
|
+
CHAT_PLUS_MENU: "chat-plus-menu",
|
|
26
|
+
/** Custom tab in the emoji/gif selection panel */
|
|
27
|
+
EMOJI_PICKER_GIF_TAB: "emoji-picker-gif-tab",
|
|
28
|
+
/** Custom tab in the emoji/sticker selection panel */
|
|
29
|
+
EMOJI_PICKER_STICKER_TAB: "emoji-picker-sticker-tab",
|
|
30
|
+
/** Full-screen or modal dialog specifically for TubeScan */
|
|
31
|
+
TUBESCAN_DIALOG: "tubescan-dialog",
|
|
32
|
+
/** Dedicated settings panel rendered in the Owner Dashboard */
|
|
33
|
+
OWNER_SETTINGS: "owner-settings",
|
|
34
|
+
/** Dedicated settings panel rendered in the Site Admin Dashboard */
|
|
35
|
+
ADDON_SETTINGS: "addon-settings"
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { MOUNT_POINTS };
|