@danxbot/plugin-sdk 0.0.0-stage → 0.1.2
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/README.md +53 -2
- package/dist/card-kit.d.ts +1255 -0
- package/dist/cli.js +12 -0
- package/dist/vite.d.ts +22 -0
- package/dist/vite.js +119 -0
- package/package.json +55 -4
package/README.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @danxbot/plugin-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Build a 50 Arms **card-type plugin**: a small React bundle that gives a card type its own card view (`CardView`) and/or card-list view (`CardListView`), loaded into 50 Arms' own page with `import()`.
|
|
4
|
+
|
|
5
|
+
A plugin does not bundle React, `@danxbot/ui` or the card features. The app serves them under fixed import specifiers through an import map, so a plugin shares the app's single React and renders the app's own components:
|
|
6
|
+
|
|
7
|
+
| Specifier | What it is |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `react`, `react/jsx-runtime`, `react-dom` | The app's React |
|
|
10
|
+
| `@danxbot/ui` | The app's design system |
|
|
11
|
+
| `@danxbot/card-kit@1` | The card features: data hooks, card regions (`StandardCardPage`, `EditableTitle`, `ChecklistsSection`, ...), `CardFace`, `CardBoard` |
|
|
12
|
+
|
|
13
|
+
The live list and each library's major version is `GET /api/plugin-runtime`.
|
|
14
|
+
|
|
15
|
+
## Set up a plugin
|
|
16
|
+
|
|
17
|
+
`package.json`: depend on `@danxbot/plugin-sdk` and install its peers: `vite`, `react`, `@types/react`, `@danxbot/ui` and `react-router` (types only: the app serves the real ones; the kit's declarations import them).
|
|
18
|
+
|
|
19
|
+
`vite.config.ts`:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { defineConfig } from "vite";
|
|
23
|
+
import { danxPlugin } from "@danxbot/plugin-sdk/vite";
|
|
24
|
+
|
|
25
|
+
export default defineConfig({ plugins: [danxPlugin()] });
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`tsconfig.json`: add `"types": ["@danxbot/plugin-sdk/card-kit"]`: the kit's declarations. They are self-contained (they import only `react`, `@danxbot/ui` and `react-router`) and the specifier is not a package, so TypeScript reads them as ambient types.
|
|
29
|
+
|
|
30
|
+
`src/index.tsx` exports `CardView` and/or `CardListView`:
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { StandardCardPage, type CardViewProps } from "@danxbot/card-kit@1";
|
|
34
|
+
|
|
35
|
+
export function CardView({ card, mutation }: CardViewProps) {
|
|
36
|
+
return <StandardCardPage card={card} mutation={mutation} />;
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`vite build` writes the plugin to `dist/`: `index.js` (the entry), `chunks/` for code splitting, `index.css`, source maps, and `danx-plugin.json`, the manifest listing every file with its size and sha256 and the runtime majors the plugin was built against.
|
|
41
|
+
|
|
42
|
+
The build refuses to bundle a copy of React, React DOM, `@danxbot/ui` or `react-router`: import only the specifiers above. For routing, use the kit's `Link` and `useNavigate`; `StandardCardPage` reads the plan the page was opened from out of the URL, so a view that wraps it passes only `{card, mutation}`.
|
|
43
|
+
|
|
44
|
+
## The card kit is a contract
|
|
45
|
+
|
|
46
|
+
A runtime export of `@danxbot/card-kit@1`, and its parameters, is never removed or changed in place; the keys of the exported data types follow the Versioning section below. A breaking change is `@danxbot/card-kit@2`, served beside `@1` until no approved plugin revision needs it. A plugin's manifest records the majors it was built against, and the app refuses to run a revision built for a major it no longer serves.
|
|
47
|
+
|
|
48
|
+
## `danx-plugin publish`
|
|
49
|
+
|
|
50
|
+
Not available yet: it refuses with an error until the plugin upload route ships in the next release of this SDK.
|
|
51
|
+
|
|
52
|
+
## Versioning
|
|
53
|
+
|
|
54
|
+
The SDK stays 0.x until the shapes behind the card kit's data types settle: phase 1 of DX-4679 (card types as rows) changes `IssueViewV2.type`, and DX-5164 (designs on any card) changes the design fields. Until then the declarations may change between 0.x releases; the kit's runtime exports follow the `@danxbot/card-kit@1` rule above.
|