@jchat/addon-sdk 1.0.0-alpha.10 → 1.0.0-alpha.11
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 +2 -0
- package/README.md +91 -28
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,62 +1,104 @@
|
|
|
1
1
|
# @jchat/addon-sdk
|
|
2
2
|
|
|
3
|
-
TypeScript SDK for
|
|
3
|
+
Official TypeScript SDK for developing extensions, UI widgets, and server plugins for the [JChat](https://jchat.im) platform.
|
|
4
4
|
|
|
5
|
-
Provides
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Provides typed interfaces, manifest contracts, Vite bundler plugins, and CLI development tooling for building sandboxed JChat addons.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
|
|
13
|
-
# or
|
|
14
|
-
bun add @jchat/addon-sdk
|
|
12
|
+
bun add -d @jchat/addon-sdk
|
|
15
13
|
```
|
|
16
14
|
|
|
15
|
+
> **Note**: `@jchat/addon-sdk` is an externalized build dependency. The JChat host runtime automatically provides shared externals (React, UI primitives, Kysely, and context objects) at load time.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
17
19
|
## Requirements
|
|
18
20
|
|
|
19
|
-
-
|
|
20
|
-
- React 18
|
|
21
|
+
- **Bun**: 1.4.0+
|
|
22
|
+
- **React**: 18+ / 19+
|
|
23
|
+
- **Vite**: 5+ / 6+
|
|
24
|
+
|
|
25
|
+
---
|
|
21
26
|
|
|
22
|
-
##
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
### 1. Define Addon Manifest
|
|
30
|
+
|
|
31
|
+
Create `src/manifest.ts` with metadata, permissions, mount points, and compatibility ranges:
|
|
23
32
|
|
|
24
33
|
```ts
|
|
25
|
-
import type {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
import type { AddonManifest } from "@jchat/addon-sdk"
|
|
35
|
+
|
|
36
|
+
const manifest: AddonManifest = {
|
|
37
|
+
id: "my-addon",
|
|
38
|
+
name: "My Addon",
|
|
39
|
+
version: "1.0.0",
|
|
40
|
+
description: "Custom feature extension for JChat",
|
|
41
|
+
author: "Developer",
|
|
42
|
+
compatibility: {
|
|
43
|
+
jchat: ">=1.0.0-alpha.0 <2.0.0",
|
|
44
|
+
addonSdk: ">=1.0.0-alpha.0 <2.0.0"
|
|
45
|
+
},
|
|
46
|
+
locales: ["en", "es", "fr", "de", "ar"],
|
|
47
|
+
defaultLocale: "en",
|
|
48
|
+
frontend: {
|
|
49
|
+
bundle: "./ui.js",
|
|
50
|
+
mountPoints: ["chat-toolbar", "room-settings"]
|
|
51
|
+
},
|
|
52
|
+
permissions: []
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default manifest
|
|
31
56
|
```
|
|
32
57
|
|
|
33
|
-
|
|
58
|
+
### 2. Configure Vite Plugin
|
|
59
|
+
|
|
60
|
+
In `vite.config.ts`, include the official JChat addon plugin:
|
|
34
61
|
|
|
35
62
|
```ts
|
|
63
|
+
import { defineConfig } from "vite"
|
|
36
64
|
import { jchatAddon } from "@jchat/addon-sdk/vite"
|
|
37
65
|
|
|
38
|
-
export default {
|
|
66
|
+
export default defineConfig({
|
|
39
67
|
plugins: [jchatAddon()]
|
|
40
|
-
}
|
|
68
|
+
})
|
|
41
69
|
```
|
|
42
70
|
|
|
43
|
-
|
|
71
|
+
### 3. Build & Package Addon
|
|
44
72
|
|
|
45
|
-
|
|
73
|
+
Use the built-in CLI to build, test, and bundle distribution packages:
|
|
46
74
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
75
|
+
```bash
|
|
76
|
+
# Build addon bundle and generate distribution zip
|
|
77
|
+
bun run jchat-addon build --zip
|
|
78
|
+
|
|
79
|
+
# Start live development watcher
|
|
80
|
+
bun run jchat-addon dev
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Database Architecture & Isolated Persistence
|
|
86
|
+
|
|
87
|
+
For addons requiring persistence, JChat provides zero-overhead, type-safe database queries via **Kysely**:
|
|
88
|
+
|
|
89
|
+
- **Zero Bundle Overhead**: Define tables as pure TypeScript interfaces (`src/db.ts`) with no ORM runtime footprint.
|
|
90
|
+
- **Isolated `addons` Schema**: All addon tables reside in the dedicated `"addons"` schema (e.g. `addons.MyAddonSettings`, `addons.GlimpseStories`), preventing collision with core application tables.
|
|
91
|
+
- **Table Naming Standard**: Table names must begin with a capital letter and start with your capitalized addon ID (e.g., `MyAddonItems`).
|
|
92
|
+
- **SQL Migrations**: Store migration scripts as standard SQL files under `migrations/` referenced in your manifest.
|
|
52
93
|
|
|
53
94
|
```ts
|
|
54
|
-
import type {
|
|
95
|
+
import type { AddonServerContext } from "@jchat/addon-sdk"
|
|
55
96
|
|
|
56
97
|
export interface MyAddonDatabase {
|
|
57
98
|
MyAddonSettings: {
|
|
58
99
|
id: string
|
|
59
100
|
siteId: string
|
|
101
|
+
enabled: boolean
|
|
60
102
|
createdAt: Date
|
|
61
103
|
}
|
|
62
104
|
}
|
|
@@ -64,6 +106,27 @@ export interface MyAddonDatabase {
|
|
|
64
106
|
export type MyAddonContext = AddonServerContext<MyAddonDatabase>
|
|
65
107
|
```
|
|
66
108
|
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## UI Mount Points & Lifecycle
|
|
112
|
+
|
|
113
|
+
Addon UI components receive a structured `AddonProps` object containing user, room, localization, and host bridge APIs:
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
import type { AddonProps } from "@jchat/addon-sdk"
|
|
117
|
+
|
|
118
|
+
export default function MyAddonComponent({ context, t }: AddonProps) {
|
|
119
|
+
return (
|
|
120
|
+
<div className="p-4 rounded-lg bg-card text-card-foreground border shadow-sm">
|
|
121
|
+
<h3 className="font-semibold">{t("my_addon_title")}</h3>
|
|
122
|
+
<p className="text-sm text-muted-foreground">{context.siteId}</p>
|
|
123
|
+
</div>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
67
130
|
## License
|
|
68
131
|
|
|
69
|
-
|
|
132
|
+
Proprietary — All rights reserved. See the [LICENSE](./LICENSE) file included in this package for full terms and conditions.
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import * as fs$1 from "node:fs";
|
|
|
3
3
|
import * as path$1 from "node:path";
|
|
4
4
|
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
5
|
//#region package.json
|
|
6
|
-
var version = "1.0.0-alpha.
|
|
6
|
+
var version = "1.0.0-alpha.11";
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region ../icon/dist/types.mjs
|
|
9
9
|
const e = `Activity.ArrowLeft.ArrowRight.Ban.Bell.BookOpen.Brush.Calendar.Camera.ChartBar.Check.CheckCheck.CheckCircle2.ChevronDown.ChevronLeft.ChevronRight.ChevronUp.CircleAlert.CircleCheck.CircleOff.CirclePlay.CirclePlus.Clock.Coffee.Contact.Cpu.Database.Dices.Ellipsis.Eraser.ExternalLink.Eye.EyeOff.Flag.Flame.FolderPlus.Footprints.Gamepad2.Gift.Globe.HardDrive.Headphones.Heart.Image.Info.Key.KeyRound.Layers.LayoutDashboard.LayoutList.LayoutTemplate.Link2.ListOrdered.Loader.LoaderCircle.Lock.LogOut.Mail.Maximize.Megaphone.MemoryStick.Menu.MessageCircle.MessageSquare.Mic.Minimize.Minus.Monitor.Moon.MoreHorizontal.Music.Music2.Newspaper.Palette.Paperclip.PartyPopper.Pause.PenLine.Play.Plus.Radio.Reply.RotateCcw.RotateCw.Search.Send.Server.Settings.Shield.ShieldAlert.ShieldCheck.SkipForward.SlidersHorizontal.Smartphone.Smile.Sparkles.Square.SquarePen.Star.Sun.ThumbsDown.ThumbsUp.Timer.Trash.Trash2.Trophy.Upload.User.UserCheck.UserCog.UserMinus.UserPen.UserPlus.UserRoundPlus.Users.UserX.Utensils.Video.VideoOff.Volume.Volume2.VolumeX.X.Youtube.Zap`.split(`.`);
|