@jchat/addon-sdk 1.0.0-alpha.6 → 1.0.0-alpha.8
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/LICENSE +18 -196
- package/dist/cli.d.mts +36 -0
- package/dist/cli.mjs +135 -0
- package/dist/contracts.d.mts +12 -4
- package/dist/index.d.mts +250 -8
- package/dist/index.mjs +374 -2
- package/dist/ui.d.mts +1 -11977
- package/dist/ui.mjs +2 -2
- package/dist/vite.mjs +63 -16
- package/package.json +20 -3
- package/tsconfig.addon.json +20 -0
- package/dist/ui2.d.mts +0 -2
package/dist/ui.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
export * from "@jchat/ui";
|
|
2
|
+
export {};
|
package/dist/vite.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { execFileSync } from "node:child_process";
|
|
4
3
|
import crypto from "node:crypto";
|
|
5
4
|
//#region src/vite.ts
|
|
6
5
|
/**
|
|
@@ -33,7 +32,42 @@ function jchatAddon(options) {
|
|
|
33
32
|
name: "jchat-addon",
|
|
34
33
|
apply: "build",
|
|
35
34
|
config(_, env) {
|
|
36
|
-
|
|
35
|
+
const rootDir = process.cwd();
|
|
36
|
+
const uiEntry = path.resolve(rootDir, "src/ui.tsx");
|
|
37
|
+
const hasUi = fs.existsSync(uiEntry);
|
|
38
|
+
return {
|
|
39
|
+
define: {
|
|
40
|
+
global: "window",
|
|
41
|
+
"process.env.NODE_ENV": JSON.stringify(env.mode || "production")
|
|
42
|
+
},
|
|
43
|
+
build: {
|
|
44
|
+
outDir: "build",
|
|
45
|
+
emptyOutDir: true,
|
|
46
|
+
minify: env.mode === "production",
|
|
47
|
+
...hasUi ? {
|
|
48
|
+
lib: {
|
|
49
|
+
entry: uiEntry,
|
|
50
|
+
name: manifestData.id,
|
|
51
|
+
formats: ["es"],
|
|
52
|
+
fileName: () => "ui.[hash].js"
|
|
53
|
+
},
|
|
54
|
+
rolldownOptions: {
|
|
55
|
+
external: [
|
|
56
|
+
"react",
|
|
57
|
+
"react-dom",
|
|
58
|
+
"react/jsx-runtime",
|
|
59
|
+
"react/jsx-dev-runtime",
|
|
60
|
+
"jotai",
|
|
61
|
+
"react-hot-toast",
|
|
62
|
+
"@tanstack/react-query",
|
|
63
|
+
"@jchat/addon-sdk",
|
|
64
|
+
"@jchat/addon-sdk/ui"
|
|
65
|
+
],
|
|
66
|
+
output: { format: "esm" }
|
|
67
|
+
}
|
|
68
|
+
} : {}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
37
71
|
},
|
|
38
72
|
configResolved(config) {
|
|
39
73
|
developmentBuild = options.development ?? (config.mode === "development" || process.env.JCHAT_ADDON_DEV === "true" || process.env.NODE_ENV === "development");
|
|
@@ -59,9 +93,13 @@ function jchatAddon(options) {
|
|
|
59
93
|
}
|
|
60
94
|
};
|
|
61
95
|
const serverSrcPath = path.resolve(rootDir, "src/api.ts");
|
|
62
|
-
const hasServer =
|
|
96
|
+
const hasServer = await Bun.file(serverSrcPath).exists();
|
|
63
97
|
if (hasServer) {
|
|
64
|
-
|
|
98
|
+
Bun.spawnSync(["bun", ...createAddonServerBuildArguments(serverSrcPath, path.resolve(buildDir, "api.js"), developmentBuild)], { stdio: [
|
|
99
|
+
"inherit",
|
|
100
|
+
"inherit",
|
|
101
|
+
"inherit"
|
|
102
|
+
] });
|
|
65
103
|
manifest = {
|
|
66
104
|
...manifest,
|
|
67
105
|
server: {
|
|
@@ -77,12 +115,15 @@ function jchatAddon(options) {
|
|
|
77
115
|
});
|
|
78
116
|
for (const relativePath of databaseFiles) {
|
|
79
117
|
if (path.isAbsolute(relativePath) || relativePath.includes("\\") || relativePath.split("/").includes("..")) throw new Error(`Unsafe addon database file path: ${relativePath}`);
|
|
80
|
-
const source = path.resolve(rootDir, relativePath);
|
|
81
|
-
if (!fs.existsSync(source) || !fs.statSync(source).isFile()) throw new Error(`Missing addon database file: ${relativePath}`);
|
|
82
118
|
const destination = path.resolve(buildDir, relativePath);
|
|
83
119
|
fs.mkdirSync(path.dirname(destination), { recursive: true });
|
|
84
|
-
fs.copyFileSync(source, destination);
|
|
85
120
|
}
|
|
121
|
+
await Promise.all(databaseFiles.map(async (relativePath) => {
|
|
122
|
+
const source = path.resolve(rootDir, relativePath);
|
|
123
|
+
if (!await Bun.file(source).exists() || !fs.statSync(source).isFile()) throw new Error(`Missing addon database file: ${relativePath}`);
|
|
124
|
+
const destination = path.resolve(buildDir, relativePath);
|
|
125
|
+
return Bun.write(destination, Bun.file(source));
|
|
126
|
+
}));
|
|
86
127
|
if (manifest.server?.migrations?.length || manifest.server?.seeds?.length) {
|
|
87
128
|
const signingPrivateKey = requireAddonSigningKey(options.signingPrivateKey ?? process.env.JCHAT_ADDON_SIGNING_PRIVATE_KEY, developmentBuild);
|
|
88
129
|
if (signingPrivateKey) {
|
|
@@ -93,33 +134,39 @@ function jchatAddon(options) {
|
|
|
93
134
|
...manifest.server?.seeds ?? []
|
|
94
135
|
];
|
|
95
136
|
if (hasServer) archivePaths.push("api.js");
|
|
96
|
-
|
|
137
|
+
const resolvedFiles = await Promise.all(archivePaths.map(async (file) => ({
|
|
97
138
|
path: file,
|
|
98
|
-
contents: file === "manifest.json" ? Buffer.from("") :
|
|
99
|
-
}))
|
|
139
|
+
contents: file === "manifest.json" ? Buffer.from("") : Buffer.from(await Bun.file(path.resolve(buildDir, file)).arrayBuffer())
|
|
140
|
+
})));
|
|
141
|
+
manifest = signAddonManifest(manifest, resolvedFiles, signingPrivateKey);
|
|
100
142
|
}
|
|
101
143
|
}
|
|
102
144
|
const readmeSource = path.resolve(rootDir, "README.md");
|
|
103
|
-
if (
|
|
145
|
+
if (await Bun.file(readmeSource).exists()) await Bun.write(path.resolve(buildDir, "README.md"), Bun.file(readmeSource));
|
|
104
146
|
const manifestJson = JSON.stringify(manifest, null, 2);
|
|
105
|
-
|
|
147
|
+
await Bun.write(path.resolve(buildDir, "manifest.json"), manifestJson);
|
|
106
148
|
if (shouldZip) {
|
|
107
149
|
const zipName = `${manifest.id}-${pkg.version}.zip`;
|
|
108
150
|
const filesToZip = ["manifest.json", bundleFile];
|
|
109
|
-
if (
|
|
110
|
-
if (
|
|
151
|
+
if (await Bun.file(path.resolve(buildDir, "api.js")).exists()) filesToZip.push("api.js");
|
|
152
|
+
if (await Bun.file(path.resolve(buildDir, "README.md")).exists()) filesToZip.push("README.md");
|
|
111
153
|
const migrationsDest = path.resolve(buildDir, "migrations");
|
|
112
154
|
if (fs.existsSync(migrationsDest)) filesToZip.push("migrations");
|
|
113
155
|
const seedsDest = path.resolve(buildDir, "seeds");
|
|
114
156
|
if (fs.existsSync(seedsDest)) filesToZip.push("seeds");
|
|
115
|
-
|
|
157
|
+
Bun.spawnSync([
|
|
158
|
+
"tar",
|
|
116
159
|
"-a",
|
|
117
160
|
"-cf",
|
|
118
161
|
zipName,
|
|
119
162
|
...filesToZip
|
|
120
163
|
], {
|
|
121
164
|
cwd: buildDir,
|
|
122
|
-
stdio:
|
|
165
|
+
stdio: [
|
|
166
|
+
"inherit",
|
|
167
|
+
"inherit",
|
|
168
|
+
"inherit"
|
|
169
|
+
]
|
|
123
170
|
});
|
|
124
171
|
console.log(`Build Complete: ${manifest.id} v${pkg.version} → ${zipName}`);
|
|
125
172
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jchat/addon-sdk",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.8",
|
|
4
4
|
"private": false,
|
|
5
|
+
"description": "JChat Addon SDK for building JChat addons.",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"addon",
|
|
7
8
|
"chat",
|
|
@@ -11,14 +12,18 @@
|
|
|
11
12
|
"sdk",
|
|
12
13
|
"vite"
|
|
13
14
|
],
|
|
14
|
-
"license": "
|
|
15
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
15
16
|
"repository": {
|
|
16
17
|
"type": "git",
|
|
17
18
|
"url": "git+https://github.com/mjjabarullah/jchat.git",
|
|
18
19
|
"directory": "packages/addon-sdk"
|
|
19
20
|
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"jchat-addon": "./dist/cli.mjs"
|
|
23
|
+
},
|
|
20
24
|
"files": [
|
|
21
25
|
"dist",
|
|
26
|
+
"tsconfig.addon.json",
|
|
22
27
|
"README.md",
|
|
23
28
|
"CHANGELOG.md"
|
|
24
29
|
],
|
|
@@ -30,6 +35,10 @@
|
|
|
30
35
|
"types": "./dist/index.d.mts",
|
|
31
36
|
"import": "./dist/index.mjs"
|
|
32
37
|
},
|
|
38
|
+
"./cli": {
|
|
39
|
+
"types": "./dist/cli.d.mts",
|
|
40
|
+
"import": "./dist/cli.mjs"
|
|
41
|
+
},
|
|
33
42
|
"./diagnostics": {
|
|
34
43
|
"types": "./dist/diagnostics.d.mts",
|
|
35
44
|
"import": "./dist/diagnostics.mjs"
|
|
@@ -46,7 +55,8 @@
|
|
|
46
55
|
"style": "./src/tailwind.css",
|
|
47
56
|
"import": "./src/tailwind.css",
|
|
48
57
|
"default": "./src/tailwind.css"
|
|
49
|
-
}
|
|
58
|
+
},
|
|
59
|
+
"./tsconfig.json": "./tsconfig.addon.json"
|
|
50
60
|
},
|
|
51
61
|
"publishConfig": {
|
|
52
62
|
"access": "public"
|
|
@@ -55,12 +65,17 @@
|
|
|
55
65
|
"build": "tsdown",
|
|
56
66
|
"lint": "oxlint .",
|
|
57
67
|
"format": "oxfmt . --write",
|
|
68
|
+
"test": "bun test",
|
|
58
69
|
"typecheck": "tsc --noEmit",
|
|
59
70
|
"prepack": "bun run build"
|
|
60
71
|
},
|
|
72
|
+
"dependencies": {},
|
|
61
73
|
"devDependencies": {
|
|
62
74
|
"@jchat/icon": "workspace:*",
|
|
63
75
|
"@jchat/ui": "workspace:*",
|
|
76
|
+
"@tailwindcss/vite": "catalog:",
|
|
77
|
+
"@tanstack/react-query": "catalog:",
|
|
78
|
+
"@types/bun": "catalog:",
|
|
64
79
|
"@types/react": "catalog:",
|
|
65
80
|
"elysia": "catalog:",
|
|
66
81
|
"kysely": "^catalog:",
|
|
@@ -68,6 +83,8 @@
|
|
|
68
83
|
"vite": "catalog:"
|
|
69
84
|
},
|
|
70
85
|
"peerDependencies": {
|
|
86
|
+
"@tailwindcss/vite": "catalog:",
|
|
87
|
+
"@tanstack/react-query": "catalog:",
|
|
71
88
|
"elysia": "catalog:",
|
|
72
89
|
"kysely": "^catalog:",
|
|
73
90
|
"react": "catalog:",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"display": "JChat Addon Base",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
9
|
+
"jsx": "react-jsx",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"verbatimModuleSyntax": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
"types": ["bun", "vite/client"]
|
|
18
|
+
},
|
|
19
|
+
"exclude": ["build", "dist", "node_modules"]
|
|
20
|
+
}
|
package/dist/ui2.d.mts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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 };
|