@danxbot/plugin-sdk 0.2.33 → 0.2.35
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 +2 -0
- package/dist/publish.d.ts +6 -0
- package/dist/vite.d.ts +5 -0
- package/dist/vite.js +8 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,8 @@ import { danxPlugin } from "@danxbot/plugin-sdk/vite";
|
|
|
25
25
|
export default defineConfig({ plugins: [danxPlugin()] });
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
A plugin whose `CardView` is made for particular card types names them: `danxPlugin({ cardTypes: ["Bug"] })`. Each becomes that type's default view once the plugin's revision is approved and active (a team admin's card-view board shows it as "Default" and reverts a type to it); where two plugins name one type, the one activated first wins. The names go into `danx-plugin.json` as `cardTypes`, and the upload refuses a key that is not a card type key or a plugin that exports no `CardView`.
|
|
29
|
+
|
|
28
30
|
`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
31
|
|
|
30
32
|
`src/index.tsx` exports `CardView` and/or `CardListView`:
|
package/dist/publish.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ interface PluginManifest {
|
|
|
27
27
|
readonly screenshot?: string;
|
|
28
28
|
/** Each shared library's major the plugin was built against (`PLUGIN_RUNTIME_LIBRARIES`), compared with what the app serves. */
|
|
29
29
|
readonly runtime: Readonly<Record<string, number>>;
|
|
30
|
+
/**
|
|
31
|
+
* DX-6178: the card types the plugin's `CardView` is made for (card type keys, e.g. `["Bug"]`); absent when it is made for none. Each is that type's DEFAULT view
|
|
32
|
+
* while the plugin's active revision is approved and exports `CardView`: the admin's card-view board shows it as the type's "Default" and reverts to it.
|
|
33
|
+
* Where two plugins declare one type, the one activated first wins (`plugins.activated_at`).
|
|
34
|
+
*/
|
|
35
|
+
readonly cardTypes?: readonly string[];
|
|
30
36
|
/** DX-5282: which view modules the entry exports (`PLUGIN_VIEW_EXPORTS`), recorded at build from the entry chunk's real exports; never empty. */
|
|
31
37
|
readonly exports: readonly PluginViewExport[];
|
|
32
38
|
readonly files: readonly PluginManifestFile[];
|
package/dist/vite.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ declare const PLUGIN_ENTRY_FILE = "index.js";
|
|
|
5
5
|
interface DanxPluginOptions {
|
|
6
6
|
/** The module exporting `CardView` and/or `CardListView`, relative to the project root. */
|
|
7
7
|
readonly entry?: string;
|
|
8
|
+
/**
|
|
9
|
+
* DX-6178: the card types the plugin's `CardView` is made for (card type keys, e.g. `["Bug"]`). Each becomes that type's DEFAULT view once the plugin's revision is approved
|
|
10
|
+
* and active, and the team can always set the type back to it. Leave it out for a plugin made for no particular type.
|
|
11
|
+
*/
|
|
12
|
+
readonly cardTypes?: readonly string[];
|
|
8
13
|
}
|
|
9
14
|
/**
|
|
10
15
|
* The Vite preset for a 50 Arms card-type plugin: an ES-module library build whose output the app loads with `import()`.
|
package/dist/vite.js
CHANGED
|
@@ -49,7 +49,7 @@ function describeFile(root, file) {
|
|
|
49
49
|
sha256: createHash("sha256").update(bytes).digest("hex")
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
function buildManifest(outDir, entry, exports) {
|
|
52
|
+
function buildManifest(outDir, entry, exports, cardTypes = []) {
|
|
53
53
|
const files = filesUnder(outDir).map((file) => describeFile(outDir, file)).filter((file) => file.path !== PLUGIN_MANIFEST_FILE);
|
|
54
54
|
if (!files.some((file) => file.path === entry)) throw new Error(`danx-plugin: the build produced no entry module ${entry} in ${outDir}`);
|
|
55
55
|
return {
|
|
@@ -57,11 +57,13 @@ function buildManifest(outDir, entry, exports) {
|
|
|
57
57
|
styles: files.filter((file) => file.path.endsWith(".css")).map((file) => file.path),
|
|
58
58
|
runtime: pluginRuntimeContract().majors,
|
|
59
59
|
exports: [...exports],
|
|
60
|
+
// DX-6178: the card types the plugin's card view is made for, written only when the author named some.
|
|
61
|
+
...cardTypes.length === 0 ? {} : { cardTypes: [...cardTypes] },
|
|
60
62
|
files
|
|
61
63
|
};
|
|
62
64
|
}
|
|
63
|
-
function writeManifest(outDir, entry, exports) {
|
|
64
|
-
const manifest = buildManifest(outDir, entry, exports);
|
|
65
|
+
function writeManifest(outDir, entry, exports, cardTypes = []) {
|
|
66
|
+
const manifest = buildManifest(outDir, entry, exports, cardTypes);
|
|
65
67
|
writeFileSync(join(outDir, PLUGIN_MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}
|
|
66
68
|
`);
|
|
67
69
|
return manifest;
|
|
@@ -120,9 +122,9 @@ function danxPlugin(options = {}) {
|
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
},
|
|
123
|
-
writeBundle(
|
|
124
|
-
if (
|
|
125
|
-
writeManifest(
|
|
125
|
+
writeBundle(output) {
|
|
126
|
+
if (output.dir === void 0) throw new Error("danx-plugin: the build has no output directory to write the manifest into");
|
|
127
|
+
writeManifest(output.dir, PLUGIN_ENTRY_FILE, viewExports, options.cardTypes ?? []);
|
|
126
128
|
}
|
|
127
129
|
};
|
|
128
130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danxbot/plugin-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.35",
|
|
4
4
|
"description": "SDK for building 50 Arms card-type plugins (DX-5170): the card kit's type declarations, a Vite preset that builds a plugin against the app's shared runtime and writes its manifest, and the danx-plugin CLI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|