@jchat/addon-sdk 1.0.0-alpha.3 → 1.0.0-alpha.6

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/dist/ui.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { $ as DialogHeader, $n as SidebarRail, $t as PopoverDescription, A as Button, An as SheetHeader, At as Field, B as CardHeader, Bn as SidebarHeader, Bt as Label, C as AvatarFallback, Cn as SelectValue, Ct as DropdownMenuSeparator, D as AvatarWithStatusRing, Dn as SheetContent, Dt as DropdownMenuSubTrigger, E as AvatarImage, En as SheetClose, Et as DropdownMenuSubContent, F as Card, Fn as SidebarFooter, Ft as Icon, G as CollapsibleTrigger, Gn as SidebarMenuBadge, Gt as Message, H as Checkbox, Hn as SidebarInset, Ht as Marker, I as CardAction, In as SidebarGroup, It as IconProps, J as Dialog, Jn as SidebarMenuSkeleton, Jt as MessageFooter, K as ColorPicker, Kn as SidebarMenuButton, Kt as MessageAvatar, L as CardContent, Ln as SidebarGroupAction, Lt as Image, M as CalendarDayButton, Mn as SheetTrigger, Mt as FieldErrorProps, N as Captcha, Nn as Sidebar, Nt as FieldProps, O as Badge, On as SheetDescription, Ot as DropdownMenuTrigger, P as CaptchaProps, Pn as SidebarContent, Pt as GalleryItem, Q as DialogFooter, Qn as SidebarProvider, Qt as PopoverContent, R as CardDescription, Rn as SidebarGroupContent, Rt as ImageZoom, S as AvatarBadge, Sn as SelectTrigger, St as DropdownMenuRadioItem, T as AvatarGroupCount, Tn as Sheet, Tt as DropdownMenuSub, U as Collapsible, Un as SidebarMenu, Ut as MarkerContent, V as CardTitle, Vn as SidebarInput, Vt as Loader, W as CollapsibleContent, Wn as SidebarMenuAction, Wt as MarkerIcon, X as DialogContent, Xn as SidebarMenuSubButton, Xt as MessageHeader, Y as DialogClose, Yn as SidebarMenuSub, Yt as MessageGroup, Z as DialogDescription, Zn as SidebarMenuSubItem, Zt as Popover, _ as AnimatedBackground, _n as SelectItem, _r as cn, _t as DropdownMenuGroup, a as AlertDialog, an as ResponsiveDialogClose, ar as Switch, at as DrawerClose, b as AppearancePicker, bn as SelectScrollUpButton, br as useSidebar, bt as DropdownMenuPortal, c as AlertDialogContent, cn as ResponsiveDialogFooter, cr as TabsList, ct as DrawerFooter, d as AlertDialogHeader, dn as ResponsiveDialogTrigger, dr as Tooltip, dt as DrawerPortal, en as PopoverHeader, er as SidebarSeparator, et as DialogOverlay, f as AlertDialogMedia, fn as ScrollArea, fr as TooltipContent, ft as DrawerTitle, g as AlertDialogTrigger, gn as SelectGroup, gr as buttonVariants, gt as DropdownMenuContent, h as AlertDialogTitle, hn as SelectContent, hr as badgeVariants, ht as DropdownMenuCheckboxItem, i as AccordionTrigger, in as ResponsiveDialogBody, ir as StarRating, it as Drawer, j as Calendar, jn as SheetTitle, jt as FieldError, k as BadgeIcon, kn as SheetFooter, kt as DynamicFontLoader, l as AlertDialogDescription, ln as ResponsiveDialogHeader, lr as TabsTrigger, lt as DrawerHeader, m as AlertDialogPortal, mn as Select, mr as TooltipTrigger, mt as DropdownMenu, n as AccordionContent, nn as PopoverTrigger, nr as Skeleton, nt as DialogTitle, o as AlertDialogAction, on as ResponsiveDialogContent, or as Tabs, ot as DrawerContent, p as AlertDialogOverlay, pn as ScrollBar, pr as TooltipProvider, pt as DrawerTrigger, q as ConfirmDialog, qn as SidebarMenuItem, qt as MessageContent, r as AccordionItem, rn as ResponsiveDialog, rr as Slider, rt as DialogTrigger, s as AlertDialogCancel, sn as ResponsiveDialogDescription, sr as TabsContent, st as DrawerDescription, t as Accordion, tn as PopoverTitle, tr as SidebarTrigger, tt as DialogPortal, u as AlertDialogFooter, un as ResponsiveDialogTitle, ur as Textarea, ut as DrawerOverlay, v as AnimatedBackgroundProps, vn as SelectLabel, vr as markerVariants, vt as DropdownMenuItem, w as AvatarGroup, wn as Separator, wt as DropdownMenuShortcut, x as Avatar, xn as SelectSeparator, xt as DropdownMenuRadioGroup, y as Appearance, yn as SelectScrollDownButton, yr as tabsListVariants, yt as DropdownMenuLabel, z as CardFooter, zn as SidebarGroupLabel, zt as Input } from "./ui.d.mts";
2
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AnimatedBackground, AnimatedBackgroundProps, Appearance, AppearancePicker, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, AvatarWithStatusRing, Badge, BadgeIcon, Button, Calendar, CalendarDayButton, Captcha, CaptchaProps, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, ColorPicker, ConfirmDialog, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DynamicFontLoader, Field, FieldError, FieldErrorProps, FieldProps, GalleryItem, Icon, IconProps, Image, ImageZoom, Input, Label, Loader, Marker, MarkerContent, MarkerIcon, Message, MessageAvatar, MessageContent, MessageFooter, MessageGroup, MessageHeader, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, ResponsiveDialog, ResponsiveDialogBody, ResponsiveDialogClose, ResponsiveDialogContent, ResponsiveDialogDescription, ResponsiveDialogFooter, ResponsiveDialogHeader, ResponsiveDialogTitle, ResponsiveDialogTrigger, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, StarRating, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, markerVariants, tabsListVariants, useSidebar };
package/dist/ui2.d.mts ADDED
@@ -0,0 +1,2 @@
1
+ import { $ as DialogHeader, $n as SidebarRail, $t as PopoverDescription, A as Button, An as SheetHeader, At as Field, B as CardHeader, Bn as SidebarHeader, Bt as Label, C as AvatarFallback, Cn as SelectValue, Ct as DropdownMenuSeparator, D as AvatarWithStatusRing, Dn as SheetContent, Dt as DropdownMenuSubTrigger, E as AvatarImage, En as SheetClose, Et as DropdownMenuSubContent, F as Card, Fn as SidebarFooter, Ft as Icon, G as CollapsibleTrigger, Gn as SidebarMenuBadge, Gt as Message, H as Checkbox, Hn as SidebarInset, Ht as Marker, I as CardAction, In as SidebarGroup, It as IconProps, J as Dialog, Jn as SidebarMenuSkeleton, Jt as MessageFooter, K as ColorPicker, Kn as SidebarMenuButton, Kt as MessageAvatar, L as CardContent, Ln as SidebarGroupAction, Lt as Image, M as CalendarDayButton, Mn as SheetTrigger, Mt as FieldErrorProps, N as Captcha, Nn as Sidebar, Nt as FieldProps, O as Badge, On as SheetDescription, Ot as DropdownMenuTrigger, P as CaptchaProps, Pn as SidebarContent, Pt as GalleryItem, Q as DialogFooter, Qn as SidebarProvider, Qt as PopoverContent, R as CardDescription, Rn as SidebarGroupContent, Rt as ImageZoom, S as AvatarBadge, Sn as SelectTrigger, St as DropdownMenuRadioItem, T as AvatarGroupCount, Tn as Sheet, Tt as DropdownMenuSub, U as Collapsible, Un as SidebarMenu, Ut as MarkerContent, V as CardTitle, Vn as SidebarInput, Vt as Loader, W as CollapsibleContent, Wn as SidebarMenuAction, Wt as MarkerIcon, X as DialogContent, Xn as SidebarMenuSubButton, Xt as MessageHeader, Y as DialogClose, Yn as SidebarMenuSub, Yt as MessageGroup, Z as DialogDescription, Zn as SidebarMenuSubItem, Zt as Popover, _ as AnimatedBackground, _n as SelectItem, _r as cn, _t as DropdownMenuGroup, a as AlertDialog, an as ResponsiveDialogClose, ar as Switch, at as DrawerClose, b as AppearancePicker, bn as SelectScrollUpButton, br as useSidebar, bt as DropdownMenuPortal, c as AlertDialogContent, cn as ResponsiveDialogFooter, cr as TabsList, ct as DrawerFooter, d as AlertDialogHeader, dn as ResponsiveDialogTrigger, dr as Tooltip, dt as DrawerPortal, en as PopoverHeader, er as SidebarSeparator, et as DialogOverlay, f as AlertDialogMedia, fn as ScrollArea, fr as TooltipContent, ft as DrawerTitle, g as AlertDialogTrigger, gn as SelectGroup, gr as buttonVariants, gt as DropdownMenuContent, h as AlertDialogTitle, hn as SelectContent, hr as badgeVariants, ht as DropdownMenuCheckboxItem, i as AccordionTrigger, in as ResponsiveDialogBody, ir as StarRating, it as Drawer, j as Calendar, jn as SheetTitle, jt as FieldError, k as BadgeIcon, kn as SheetFooter, kt as DynamicFontLoader, l as AlertDialogDescription, ln as ResponsiveDialogHeader, lr as TabsTrigger, lt as DrawerHeader, m as AlertDialogPortal, mn as Select, mr as TooltipTrigger, mt as DropdownMenu, n as AccordionContent, nn as PopoverTrigger, nr as Skeleton, nt as DialogTitle, o as AlertDialogAction, on as ResponsiveDialogContent, or as Tabs, ot as DrawerContent, p as AlertDialogOverlay, pn as ScrollBar, pr as TooltipProvider, pt as DrawerTrigger, q as ConfirmDialog, qn as SidebarMenuItem, qt as MessageContent, r as AccordionItem, rn as ResponsiveDialog, rr as Slider, rt as DialogTrigger, s as AlertDialogCancel, sn as ResponsiveDialogDescription, sr as TabsContent, st as DrawerDescription, t as Accordion, tn as PopoverTitle, tr as SidebarTrigger, tt as DialogPortal, u as AlertDialogFooter, un as ResponsiveDialogTitle, ur as Textarea, ut as DrawerOverlay, v as AnimatedBackgroundProps, vn as SelectLabel, vr as markerVariants, vt as DropdownMenuItem, w as AvatarGroup, wn as Separator, wt as DropdownMenuShortcut, x as Avatar, xn as SelectSeparator, xt as DropdownMenuRadioGroup, y as Appearance, yn as SelectScrollDownButton, yr as tabsListVariants, yt as DropdownMenuLabel, z as CardFooter, zn as SidebarGroupLabel, zt as Input } from "./ui.mjs";
2
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AnimatedBackground, AnimatedBackgroundProps, Appearance, AppearancePicker, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, AvatarWithStatusRing, Badge, BadgeIcon, Button, Calendar, CalendarDayButton, Captcha, CaptchaProps, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, ColorPicker, ConfirmDialog, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DynamicFontLoader, Field, FieldError, FieldErrorProps, FieldProps, GalleryItem, Icon, IconProps, Image, ImageZoom, Input, Label, Loader, Marker, MarkerContent, MarkerIcon, Message, MessageAvatar, MessageContent, MessageFooter, MessageGroup, MessageHeader, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, ResponsiveDialog, ResponsiveDialogBody, ResponsiveDialogClose, ResponsiveDialogContent, ResponsiveDialogDescription, ResponsiveDialogFooter, ResponsiveDialogHeader, ResponsiveDialogTitle, ResponsiveDialogTrigger, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, StarRating, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, markerVariants, tabsListVariants, useSidebar };
package/dist/vite.d.mts CHANGED
@@ -2,13 +2,43 @@ import { t as AddonManifest } from "./contracts.mjs";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/vite.d.ts
4
4
  /**
5
- * Vite plugin to configure Jchat addon manifest generation, bundle backend scripts, copy
6
- * migrations, declarative seed data, and zip production build artifacts.
5
+ * Vite plugin for building JChat sandboxed addon extensions.
6
+ *
7
+ * Configures automatic manifest generation (`manifest.json`), bundles server-side API scripts
8
+ * (`src/api.ts`), embeds scoped Tailwind CSS into the frontend bundle, packages database migrations
9
+ * and seed files, copies documentation (`README.md`), signs database-bearing addon manifests, and
10
+ * zips production build artifacts.
11
+ *
12
+ * @example
13
+ * ;```ts
14
+ * import { jchatAddon } from "@jchat/addon-sdk/vite"
15
+ * import manifest from "./src/manifest"
16
+ * import { defineConfig } from "vite"
17
+ *
18
+ * export default defineConfig({
19
+ * plugins: [jchatAddon({ manifest })]
20
+ * })
21
+ * ```
22
+ *
23
+ * @param options - Configuration options for the JChat addon Vite plugin.
24
+ * @returns A Vite {@link Plugin} instance configured for addon compilation.
7
25
  */
8
26
  declare function jchatAddon(options: JchatAddonPluginOptions): Plugin;
27
+ /** Configuration options for the {@link jchatAddon} Vite plugin. */
9
28
  interface JchatAddonPluginOptions {
29
+ /** The base manifest specification for the addon. */
10
30
  manifest: AddonManifest;
31
+ /** Explicitly declare development mode to permit unsigned database-bearing builds. */
32
+ development?: boolean;
33
+ /**
34
+ * Whether to package the build output into a `.zip` archive upon build completion. Defaults to
35
+ * `true` during production builds and `false` during development builds.
36
+ */
11
37
  zip?: boolean;
38
+ /**
39
+ * Optional RSA private key string used to cryptographically sign database-bearing addons. If
40
+ * omitted, falls back to the `JCHAT_ADDON_SIGNING_PRIVATE_KEY` environment variable.
41
+ */
12
42
  signingPrivateKey?: string;
13
43
  /**
14
44
  * Embed Tailwind CSS output into the JS bundle and scope it to the addon's DOM container.
@@ -16,11 +46,36 @@ interface JchatAddonPluginOptions {
16
46
  */
17
47
  css?: boolean;
18
48
  }
49
+ /**
50
+ * Generates CLI argument parameters for bundling server-side Elysia API scripts (`src/api.ts`) via
51
+ * Bun.
52
+ *
53
+ * @param entryPath - Absolute file path to the server entry script (`src/api.ts`).
54
+ * @param outputPath - Absolute destination file path for the bundled output (`build/api.js`).
55
+ * @param developmentBuild - Indicates whether to enable external sourcemaps or minification.
56
+ * @returns Array of command line arguments for running `bun build`.
57
+ */
19
58
  declare function createAddonServerBuildArguments(entryPath: string, outputPath: string, developmentBuild: boolean): string[];
59
+ /**
60
+ * Cryptographically signs an addon manifest using RSA-SHA256 over all archive file contents.
61
+ *
62
+ * @param manifest - Unsigned or base addon manifest.
63
+ * @param files - List of archive file paths and raw contents to digest.
64
+ * @param privateKey - RSA private key in PEM format.
65
+ * @returns Updated {@link AddonManifest} containing an RSA signature block.
66
+ */
20
67
  declare function signAddonManifest(manifest: AddonManifest, files: readonly {
21
68
  path: string;
22
69
  contents: Buffer;
23
70
  }[], privateKey: string): AddonManifest;
71
+ /**
72
+ * Resolves the required RSA signing key for database-bearing addons.
73
+ *
74
+ * @param signingPrivateKey - Provided signing key or undefined.
75
+ * @param developmentBuild - Whether the current build is targeting development mode.
76
+ * @returns Resolved signing key string or undefined (in dev builds).
77
+ * @throws {@link Error} If building a database-bearing addon in production without a signing key.
78
+ */
24
79
  declare function requireAddonSigningKey(signingPrivateKey: string | undefined, developmentBuild: boolean): string | undefined;
25
80
  //#endregion
26
81
  export { JchatAddonPluginOptions, createAddonServerBuildArguments, jchatAddon, requireAddonSigningKey, signAddonManifest };
package/dist/vite.mjs CHANGED
@@ -4,8 +4,26 @@ import { execFileSync } from "node:child_process";
4
4
  import crypto from "node:crypto";
5
5
  //#region src/vite.ts
6
6
  /**
7
- * Vite plugin to configure Jchat addon manifest generation, bundle backend scripts, copy
8
- * migrations, declarative seed data, and zip production build artifacts.
7
+ * Vite plugin for building JChat sandboxed addon extensions.
8
+ *
9
+ * Configures automatic manifest generation (`manifest.json`), bundles server-side API scripts
10
+ * (`src/api.ts`), embeds scoped Tailwind CSS into the frontend bundle, packages database migrations
11
+ * and seed files, copies documentation (`README.md`), signs database-bearing addon manifests, and
12
+ * zips production build artifacts.
13
+ *
14
+ * @example
15
+ * ;```ts
16
+ * import { jchatAddon } from "@jchat/addon-sdk/vite"
17
+ * import manifest from "./src/manifest"
18
+ * import { defineConfig } from "vite"
19
+ *
20
+ * export default defineConfig({
21
+ * plugins: [jchatAddon({ manifest })]
22
+ * })
23
+ * ```
24
+ *
25
+ * @param options - Configuration options for the JChat addon Vite plugin.
26
+ * @returns A Vite {@link Plugin} instance configured for addon compilation.
9
27
  */
10
28
  function jchatAddon(options) {
11
29
  const { manifest: manifestData } = options;
@@ -18,7 +36,7 @@ function jchatAddon(options) {
18
36
  return { define: { "process.env.NODE_ENV": JSON.stringify(env.mode || "production") } };
19
37
  },
20
38
  configResolved(config) {
21
- developmentBuild = config.mode === "development";
39
+ developmentBuild = options.development ?? (config.mode === "development" || process.env.JCHAT_ADDON_DEV === "true" || process.env.NODE_ENV === "development");
22
40
  if (shouldZip === void 0) shouldZip = config.mode === "production";
23
41
  },
24
42
  async writeBundle() {
@@ -81,12 +99,15 @@ function jchatAddon(options) {
81
99
  })), signingPrivateKey);
82
100
  }
83
101
  }
102
+ const readmeSource = path.resolve(rootDir, "README.md");
103
+ if (fs.existsSync(readmeSource)) fs.copyFileSync(readmeSource, path.resolve(buildDir, "README.md"));
84
104
  const manifestJson = JSON.stringify(manifest, null, 2);
85
105
  fs.writeFileSync(path.resolve(buildDir, "manifest.json"), manifestJson);
86
106
  if (shouldZip) {
87
107
  const zipName = `${manifest.id}-${pkg.version}.zip`;
88
108
  const filesToZip = ["manifest.json", bundleFile];
89
109
  if (fs.existsSync(path.resolve(buildDir, "api.js"))) filesToZip.push("api.js");
110
+ if (fs.existsSync(path.resolve(buildDir, "README.md"))) filesToZip.push("README.md");
90
111
  const migrationsDest = path.resolve(buildDir, "migrations");
91
112
  if (fs.existsSync(migrationsDest)) filesToZip.push("migrations");
92
113
  const seedsDest = path.resolve(buildDir, "seeds");
@@ -105,6 +126,15 @@ function jchatAddon(options) {
105
126
  }
106
127
  };
107
128
  }
129
+ /**
130
+ * Generates CLI argument parameters for bundling server-side Elysia API scripts (`src/api.ts`) via
131
+ * Bun.
132
+ *
133
+ * @param entryPath - Absolute file path to the server entry script (`src/api.ts`).
134
+ * @param outputPath - Absolute destination file path for the bundled output (`build/api.js`).
135
+ * @param developmentBuild - Indicates whether to enable external sourcemaps or minification.
136
+ * @returns Array of command line arguments for running `bun build`.
137
+ */
108
138
  function createAddonServerBuildArguments(entryPath, outputPath, developmentBuild) {
109
139
  return [
110
140
  "build",
@@ -112,9 +142,17 @@ function createAddonServerBuildArguments(entryPath, outputPath, developmentBuild
112
142
  "--target=bun",
113
143
  "--format=esm",
114
144
  `--outfile=${outputPath}`,
115
- developmentBuild ? "--sourcemap=external" : "--minify"
145
+ developmentBuild ? "--sourcemap=inline" : "--minify"
116
146
  ];
117
147
  }
148
+ /**
149
+ * Cryptographically signs an addon manifest using RSA-SHA256 over all archive file contents.
150
+ *
151
+ * @param manifest - Unsigned or base addon manifest.
152
+ * @param files - List of archive file paths and raw contents to digest.
153
+ * @param privateKey - RSA private key in PEM format.
154
+ * @returns Updated {@link AddonManifest} containing an RSA signature block.
155
+ */
118
156
  function signAddonManifest(manifest, files, privateKey) {
119
157
  if (!manifest.publisher?.id) throw new Error("Signed addons require manifest.publisher.id");
120
158
  const unsigned = {
@@ -126,7 +164,7 @@ function signAddonManifest(manifest, files, privateKey) {
126
164
  }
127
165
  };
128
166
  const hash = crypto.createHash("sha256");
129
- for (const file of [...files].sort((a, b) => a.path.localeCompare(b.path))) {
167
+ for (const file of [...files].toSorted((a, b) => a.path.localeCompare(b.path))) {
130
168
  hash.update(file.path);
131
169
  hash.update("\0");
132
170
  hash.update(file.path === "manifest.json" ? stableStringify(unsigned) : file.contents);
@@ -142,6 +180,14 @@ function signAddonManifest(manifest, files, privateKey) {
142
180
  }
143
181
  };
144
182
  }
183
+ /**
184
+ * Resolves the required RSA signing key for database-bearing addons.
185
+ *
186
+ * @param signingPrivateKey - Provided signing key or undefined.
187
+ * @param developmentBuild - Whether the current build is targeting development mode.
188
+ * @returns Resolved signing key string or undefined (in dev builds).
189
+ * @throws {@link Error} If building a database-bearing addon in production without a signing key.
190
+ */
145
191
  function requireAddonSigningKey(signingPrivateKey, developmentBuild) {
146
192
  if (signingPrivateKey) return signingPrivateKey;
147
193
  if (developmentBuild) return void 0;
@@ -179,12 +225,12 @@ function embedCssIntoBundle(buildDir, addonId) {
179
225
  fs.unlinkSync(cssPath);
180
226
  } catch {}
181
227
  }
228
+ function sortValue(child) {
229
+ if (Array.isArray(child)) return child.map(sortValue);
230
+ if (child && typeof child === "object") return Object.fromEntries(Object.entries(child).toSorted(([left], [right]) => left.localeCompare(right)).map(([key, nested]) => [key, sortValue(nested)]));
231
+ return child;
232
+ }
182
233
  function stableStringify(value) {
183
- const sortValue = (child) => {
184
- if (Array.isArray(child)) return child.map(sortValue);
185
- if (child && typeof child === "object") return Object.fromEntries(Object.entries(child).sort(([left], [right]) => left.localeCompare(right)).map(([key, nested]) => [key, sortValue(nested)]));
186
- return child;
187
- };
188
234
  return JSON.stringify(sortValue(value));
189
235
  }
190
236
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jchat/addon-sdk",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.6",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "addon",
@@ -37,6 +37,15 @@
37
37
  "./vite": {
38
38
  "types": "./dist/vite.d.mts",
39
39
  "import": "./dist/vite.mjs"
40
+ },
41
+ "./ui": {
42
+ "types": "./dist/ui.d.mts",
43
+ "import": "./dist/ui.mjs"
44
+ },
45
+ "./ui/tailwind.css": {
46
+ "style": "./src/tailwind.css",
47
+ "import": "./src/tailwind.css",
48
+ "default": "./src/tailwind.css"
40
49
  }
41
50
  },
42
51
  "publishConfig": {
@@ -44,13 +53,14 @@
44
53
  },
45
54
  "scripts": {
46
55
  "build": "tsdown",
47
- "lint": "oxlint . --config=../../oxlint.json",
56
+ "lint": "oxlint .",
48
57
  "format": "oxfmt . --write",
49
58
  "typecheck": "tsc --noEmit",
50
59
  "prepack": "bun run build"
51
60
  },
52
61
  "devDependencies": {
53
62
  "@jchat/icon": "workspace:*",
63
+ "@jchat/ui": "workspace:*",
54
64
  "@types/react": "catalog:",
55
65
  "elysia": "catalog:",
56
66
  "kysely": "^catalog:",