@jchat/addon-sdk 1.0.0-alpha.10 → 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 CHANGED
@@ -1,5 +1,24 @@
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
+
20
+ ## 1.0.0-alpha.11
21
+
3
22
  ## 1.0.0-alpha.10
4
23
 
5
24
  ## 1.0.0-alpha.9
package/README.md CHANGED
@@ -1,69 +1,410 @@
1
1
  # @jchat/addon-sdk
2
2
 
3
- TypeScript SDK for building [JChat](https://jchat.app) addons.
3
+ Official TypeScript SDK for developing extensions, UI widgets, and server plugins for the [JChat](https://jchatlive.com) communication platform.
4
4
 
5
- Provides types, interfaces, and Vite build helpers for addon developers. This package is always
6
- **externalised** from addon bundles — the JChat host app provides the runtime implementation at
7
- load time.
5
+ Provides typed interfaces, manifest contracts, Vite bundler plugins, and CLI development tooling for building sandboxed JChat addons.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@jchat/addon-sdk.svg)](https://www.npmjs.com/package/@jchat/addon-sdk)
8
+ [![License](https://img.shields.io/badge/license-Proprietary-blue.svg)](https://jchatlive.com/terms)
9
+
10
+ ---
11
+
12
+ ## Architecture Overview
13
+
14
+ JChat addons are **sandboxed, modular extensions** designed to enhance real-time chats without modifying core database schemas or server code.
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.
21
+
22
+ ---
23
+
24
+ ## Requirements
25
+
26
+ - **Bun**: `1.4.0+`
27
+ - **React**: `19+`
28
+ - **Vite**: `8+`
29
+
30
+ ---
8
31
 
9
32
  ## Installation
10
33
 
34
+ Install as a development dependency:
35
+
11
36
  ```bash
12
- npm install @jchat/addon-sdk
13
- # or
14
- bun add @jchat/addon-sdk
37
+ bun add -d @jchat/addon-sdk
15
38
  ```
16
39
 
17
- ## Requirements
40
+ Or scaffold a new addon instantly with the official CLI:
18
41
 
19
- - Node.js 20+ or Bun 1.3+
20
- - React 18+, Elysia, Kysely, and Vite as peer dependencies
42
+ ```bash
43
+ bun create @jchat/addon my-new-addon
44
+ ```
45
+
46
+ ---
21
47
 
22
- ## Usage
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:
23
53
 
24
54
  ```ts
25
- import type {
26
- AddonManifest,
27
- AddonServerContext,
28
- AddonClientContext,
29
- AddonProps
30
- } from "@jchat/addon-sdk"
55
+ import { defineAddonManifest } from "@jchat/addon-sdk"
56
+
57
+ export default defineAddonManifest({
58
+ id: "gifyard",
59
+ name: "Gifyard GIF Picker",
60
+ version: "1.0.0",
61
+ description: "Search and insert animated GIFs directly into chat messages.",
62
+ author: "JChat Ecosystem Team",
63
+ publisher: { id: "jchat" },
64
+ compatibility: {
65
+ jchat: ">=1.0.0-alpha.0 <2.0.0",
66
+ addonSdk: "^1.0.0"
67
+ },
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
+ ],
90
+ defaultLocale: "en",
91
+ frontend: {
92
+ bundle: "./ui.js",
93
+ mountPoints: ["chat-toolbar", "emoji-picker-gif-tab", "addon-settings"]
94
+ },
95
+ server: {
96
+ bundle: "./api.ts",
97
+ migrations: ["./migrations/0001_init.sql"]
98
+ },
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
+ })
31
114
  ```
32
115
 
33
- For the Vite build plugin:
116
+ ---
34
117
 
35
- ```ts
36
- import { jchatAddon } from "@jchat/addon-sdk/vite"
118
+ ### 2. Build the Frontend UI (`src/ui.tsx`)
37
119
 
38
- export default {
39
- plugins: [jchatAddon()]
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
+ )
40
161
  }
41
162
  ```
42
163
 
43
- ## Database Architecture & Schema Isolation
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
+ ---
44
167
 
45
- JChat database-bearing addons use **Kysely** for server-side database access:
168
+ ### 3. Build the Backend API (`src/api.ts`)
46
169
 
47
- - **0 Bundle Overhead**: Table definitions are pure TypeScript interfaces (`src/db.ts`), resulting in 0 runtime JavaScript bundle footprint.
48
- - **Shared `addons` Schema**: All addon tables are placed inside the dedicated `"addons"` schema (e.g. `addons.DjDropTracks`, `addons.PollwisePolls`, `addons.GlimpseStories`), keeping them cleanly isolated from core `public` application tables without requiring dynamic PostgreSQL role creation (`CREATE ROLE`).
49
- - **Mandatory Table Naming**: Table names **must start with a Capital letter** and **must be prefixed with your capitalized `addonId`** (e.g. `addons.MyAddonSettings`). Unprefixed tables are rejected by the host migration validator.
50
- - **SQL Migrations**: Addon migrations are stored as plain SQL files (`migrations/001_*.sql`) listed in `manifest.ts` under `server.migrations`.
51
- - **ID Column Convention**: Use `text` / `varchar(36)` for host-referencing IDs (`siteId`, `roomId`, `userId`) to ensure driver-agnostic, cast-free query execution with UUID v7 strings.
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:
52
171
 
53
172
  ```ts
54
- import type { AddonDatabase } from "@jchat/addon-sdk"
173
+ import type { AddonApp, AddonServerContext } from "@jchat/addon-sdk"
55
174
 
56
175
  export interface MyAddonDatabase {
57
- MyAddonSettings: {
176
+ addon_items: {
58
177
  id: string
59
178
  siteId: string
179
+ roomId: string
180
+ userId: string
181
+ title: string
60
182
  createdAt: Date
61
183
  }
62
184
  }
63
185
 
64
- export type MyAddonContext = AddonServerContext<MyAddonDatabase>
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
+ }
247
+ ```
248
+
249
+ ---
250
+
251
+ ### 4. Configure Vite Bundling (`vite.config.ts`)
252
+
253
+ Include the official Vite plugin for automatic manifest bundling, externalization, and live development:
254
+
255
+ ```ts
256
+ import { defineConfig } from "vite"
257
+ import { jchatAddon } from "@jchat/addon-sdk/vite"
258
+
259
+ export default defineConfig({
260
+ plugins: [jchatAddon()]
261
+ })
262
+ ```
263
+
264
+ ---
265
+
266
+ ## SDK Modules & API Reference
267
+
268
+ ### 1. Host Bridge: `useAddonSDK()`
269
+
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. |
283
+
284
+ ---
285
+
286
+ ### 2. Data Fetching: `@jchat/addon-sdk/query`
287
+
288
+ Integrated TanStack Query wrappers pre-configured with host caching, auto-invalidation, and credentials:
289
+
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.
294
+
295
+ ---
296
+
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:
300
+
301
+ ```tsx
302
+ import { atom, useAtom, useAtomValue, useSetAtom } from "@jchat/addon-sdk/state"
303
+
304
+ export const activeTabAtom = atom<"trending" | "search">("trending")
305
+ ```
306
+
307
+ ---
308
+
309
+ ### 4. Localization: `useTranslation()` & `useLocale()`
310
+
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`.
313
+
314
+ ```tsx
315
+ import { useTranslation, useLocale } from "@jchat/addon-sdk"
316
+ import locales from "./locales"
317
+
318
+ export default function MyComponent() {
319
+ const { t, dir, isRtl, locale } = useTranslation(locales)
320
+ return <div dir={dir}>{t("welcome", { name: "User" })}</div>
321
+ }
322
+ ```
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" />
65
336
  ```
66
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
+
406
+ ---
407
+
67
408
  ## License
68
409
 
69
- Apache-2.0
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 { t as AddonManifest } from "./contracts.mjs";
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
- await build(await resolveAddonBuildConfig({
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);
@@ -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 };
@@ -1,13 +1,13 @@
1
- import { t as AddonManifest } from "./contracts.mjs";
1
+ import { AddonManifest } from "./contracts.mjs";
2
2
  //#region src/diagnostics.d.ts
3
3
  /**
4
4
  * Diagnostic result status indicator for addon validation checks. - `"pass"`: The diagnostic check
5
5
  * passed successfully. - `"warning"`: Non-critical warning (e.g. source maps present in
6
6
  * production). - `"error"`: Critical failure blocking addon installation or distribution.
7
7
  */
8
- type AddonDiagnosticStatus = "pass" | "warning" | "error";
8
+ export type AddonDiagnosticStatus = "pass" | "warning" | "error";
9
9
  /** Represents an individual diagnostic check result for an addon package. */
10
- interface AddonPackageDiagnostic {
10
+ export interface AddonPackageDiagnostic {
11
11
  /** Unique identifier for the diagnostic check (e.g. `"jchat"`, `"package-size"`). */
12
12
  id: string;
13
13
  /** Human-readable title for the diagnostic check. */
@@ -18,7 +18,7 @@ interface AddonPackageDiagnostic {
18
18
  message: string;
19
19
  }
20
20
  /** Options required to run diagnostic validation on an addon build package. */
21
- interface AddonPackageDiagnosticOptions {
21
+ export interface AddonPackageDiagnosticOptions {
22
22
  /** Absolute path to the compiled addon build output directory (`build/`). */
23
23
  buildDir: string;
24
24
  /** Parsed addon manifest object (`manifest.json`). */
@@ -45,7 +45,7 @@ interface AddonPackageDiagnosticOptions {
45
45
  * @returns Semver range string matching the current major series (e.g. `">=1.2.0 <2.0.0"`).
46
46
  * @throws {@link Error} If the input is not a valid semantic version string.
47
47
  */
48
- declare function createCompatibleMajorRange(version: string): string;
48
+ export declare function createCompatibleMajorRange(version: string): string;
49
49
  /**
50
50
  * Performs comprehensive diagnostic validation checks on an addon package build directory.
51
51
  *
@@ -57,13 +57,12 @@ declare function createCompatibleMajorRange(version: string): string;
57
57
  * versions.
58
58
  * @returns Array of {@link AddonPackageDiagnostic} results.
59
59
  */
60
- declare function diagnoseAddonPackage(options: AddonPackageDiagnosticOptions): AddonPackageDiagnostic[];
60
+ export declare function diagnoseAddonPackage(options: AddonPackageDiagnosticOptions): AddonPackageDiagnostic[];
61
61
  /**
62
62
  * Checks whether any diagnostic check in a diagnostic list returned a critical error.
63
63
  *
64
64
  * @param diagnostics - Array of diagnostic check results to evaluate.
65
65
  * @returns `true` if at least one check has `status === "error"`, otherwise `false`.
66
66
  */
67
- declare function hasAddonDiagnosticErrors(diagnostics: readonly AddonPackageDiagnostic[]): boolean;
68
- //#endregion
69
- export { AddonDiagnosticStatus, AddonPackageDiagnostic, AddonPackageDiagnosticOptions, createCompatibleMajorRange, diagnoseAddonPackage, hasAddonDiagnosticErrors };
67
+ export declare function hasAddonDiagnosticErrors(diagnostics: readonly AddonPackageDiagnostic[]): boolean;
68
+ //#endregion
@@ -76,7 +76,7 @@ function diagnoseAddonPackage(options) {
76
76
  const productionArchive = path$1.join(buildDir, `${manifest.id}-${manifest.version}.zip`);
77
77
  const hasProductionArchive = fs$1.existsSync(productionArchive) && fs$1.statSync(productionArchive).isFile();
78
78
  const totalBytes = options.productionPackage && hasProductionArchive ? fs$1.statSync(productionArchive).size : files.filter((file) => file !== productionArchive).reduce((total, file) => total + fs$1.statSync(file).size, 0);
79
- const maxBytes = options.maxBytes ?? 25 * 1024 * 1024;
79
+ const maxBytes = options.maxBytes ?? 26214400;
80
80
  diagnostics.push({
81
81
  id: "package-size",
82
82
  label: "Package size",