deck-plugin-sdk 1.11.0 → 1.12.0
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 +97 -97
- package/bin/deck-plugin.mjs +158 -158
- package/build-plugin.mjs +172 -172
- package/package.json +60 -60
- package/packages.mjs +107 -107
- package/permissions.json +252 -248
- package/publish.mjs +116 -116
- package/shim/bridge.js +253 -249
- package/shim/p2p.d.ts +1 -1
- package/shim/settings.d.ts +1 -1
- package/shim/terminals.d.ts +1 -1
- package/shim/ui.d.ts +10 -10
- package/template/AGENTS.md +81 -81
- package/template/CLAUDE.md +1 -1
- package/template/LICENSE +21 -21
- package/template/README.md +20 -20
- package/template/gitignore +4 -4
- package/template/plugin.json +10 -10
- package/template/src/assets.d.ts +16 -16
- package/template/src/plugin.tsx +65 -65
- package/types/components/FileIcon.d.ts +1 -1
- package/types/components/TabStrip.d.ts +5 -2
- package/types/core/{settingsstore.d.ts → app/settingsstore.d.ts} +1 -1
- package/types/core/bridge.d.ts +1190 -1167
- package/types/core/{bookmarks.d.ts → browser/bookmarks.d.ts} +4 -2
- package/types/core/{browser.d.ts → browser/browser.d.ts} +1 -1
- package/types/core/{editorsettings.d.ts → editor/editorsettings.d.ts} +1 -1
- package/types/core/{icontheme.d.ts → editor/icontheme.d.ts} +1 -1
- package/types/core/workspaces/layout.d.ts +168 -0
- package/types/core/workspaces/terminals.d.ts +252 -0
- package/types/core/workspaces/zones.d.ts +215 -0
- package/types/modules/editor/MonacoHosts.d.ts +3 -3
- package/types/modules/editor/{DiffPeek.d.ts → git/DiffPeek.d.ts} +1 -1
- package/types/modules/editor/models.d.ts +1 -1
- package/types/modules/editor/{tree.d.ts → tree/tree.d.ts} +1 -1
- package/validate.mjs +112 -112
- package/types/core/terminals.d.ts +0 -573
- /package/types/core/{p2p.d.ts → app/p2p.d.ts} +0 -0
- /package/types/core/{theme.d.ts → app/theme.d.ts} +0 -0
- /package/types/core/{timeFormat.d.ts → app/timeFormat.d.ts} +0 -0
- /package/types/core/{browserurl.d.ts → browser/browserurl.d.ts} +0 -0
- /package/types/core/{dap.d.ts → editor/dap.d.ts} +0 -0
- /package/types/core/{debugtargets.d.ts → editor/debugtargets.d.ts} +0 -0
- /package/types/core/{decode.d.ts → editor/decode.d.ts} +0 -0
- /package/types/core/{editorsession.d.ts → editor/editorsession.d.ts} +0 -0
- /package/types/core/{inlay.d.ts → editor/inlay.d.ts} +0 -0
- /package/types/core/{langmap.d.ts → editor/langmap.d.ts} +0 -0
- /package/types/core/{lsp.d.ts → editor/lsp.d.ts} +0 -0
- /package/types/core/{monaco.d.ts → editor/monaco.d.ts} +0 -0
- /package/types/core/{patterntokens.d.ts → editor/patterntokens.d.ts} +0 -0
- /package/types/core/{snippets.d.ts → editor/snippets.d.ts} +0 -0
- /package/types/core/{treehide.d.ts → editor/treehide.d.ts} +0 -0
- /package/types/core/{keys.d.ts → keys/keys.d.ts} +0 -0
- /package/types/core/{keystore.d.ts → keys/keystore.d.ts} +0 -0
- /package/types/core/{notifications.d.ts → notifications/notifications.d.ts} +0 -0
- /package/types/core/{notifyapi.d.ts → notifications/notifyapi.d.ts} +0 -0
- /package/types/core/{fileview.d.ts → plugins/fileview.d.ts} +0 -0
- /package/types/core/{portal.d.ts → workspaces/portal.d.ts} +0 -0
- /package/types/core/{remotepath.d.ts → workspaces/remotepath.d.ts} +0 -0
- /package/types/core/{shellpath.d.ts → workspaces/shellpath.d.ts} +0 -0
- /package/types/core/{windows.d.ts → workspaces/windows.d.ts} +0 -0
- /package/types/modules/editor/{diffline.d.ts → git/diffline.d.ts} +0 -0
- /package/types/modules/editor/{hunks.d.ts → git/hunks.d.ts} +0 -0
- /package/types/modules/editor/{MarkdownLive.d.ts → viewers/MarkdownLive.d.ts} +0 -0
- /package/types/modules/editor/{viewers.d.ts → viewers/viewers.d.ts} +0 -0
package/build-plugin.mjs
CHANGED
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
// Build a Deck plugin: TSX sources -> one plugin.js Deck can import.
|
|
2
|
-
//
|
|
3
|
-
// The same build Deck's own plugins get, with one difference: the shim is shipped with this
|
|
4
|
-
// package rather than generated, because generating it needs Deck's TypeScript sources and the
|
|
5
|
-
// point of this package is that you do not have them.
|
|
6
|
-
//
|
|
7
|
-
// Why a plugin wants a build step at all: JSX, and ordinary imports across as many files as you
|
|
8
|
-
// like. It is not rebuilding Deck — it is what a VS Code extension does.
|
|
9
|
-
//
|
|
10
|
-
// The shim is the whole trick. Deck hands React, its bridge, `listen`, its icons and its
|
|
11
|
-
// animation library over on `window.__deck`, and esbuild resolves those module names to files
|
|
12
|
-
// that read from there. So your sources import "react" as normal code does, and at run time get
|
|
13
|
-
// DECK'S React — which is not an optimisation but a requirement, since two Reacts in one tree
|
|
14
|
-
// break hooks.
|
|
15
|
-
import { build } from "esbuild";
|
|
16
|
-
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
17
|
-
import { createRequire } from "node:module";
|
|
18
|
-
import { dirname, join } from "node:path";
|
|
19
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
20
|
-
import { assetLoaders, fromPackage, packageCss, rawImports } from "./packages.mjs";
|
|
21
|
-
|
|
22
|
-
const sdk = dirname(fileURLToPath(import.meta.url));
|
|
23
|
-
const require = createRequire(import.meta.url);
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The module names a plugin may import, and the file each resolves to: shipped ones in `shimDir`,
|
|
27
|
-
* the two generated per plugin in `genDir`.
|
|
28
|
-
*/
|
|
29
|
-
function shimMap(shimDir, genDir) {
|
|
30
|
-
return {
|
|
31
|
-
react: join(shimDir, "react.js"),
|
|
32
|
-
"deckreact/jsx-runtime": join(shimDir, "jsx-runtime.js"),
|
|
33
|
-
// A library compiled with the automatic runtime imports it under its real name.
|
|
34
|
-
"react/jsx-runtime": join(shimDir, "jsx-runtime.js"),
|
|
35
|
-
// Deck's react-dom (needs Deck 1.1); only bundled when a plugin or its library imports it.
|
|
36
|
-
"react-dom": join(shimDir, "react-dom.js"),
|
|
37
|
-
"@tauri-apps/api/event": join(shimDir, "event.js"),
|
|
38
|
-
"lucide-react": join(genDir, "icons.js"),
|
|
39
|
-
"framer-motion": join(genDir, "motion.js"),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Build the plugin in `dir`.
|
|
45
|
-
*
|
|
46
|
-
* A plugin imports the shim from this package (`deck-plugin-sdk/bridge`), so its project holds
|
|
47
|
-
* only its own code: the editor and esbuild both find the shim and its types in node_modules.
|
|
48
|
-
* The two files generated per plugin go to node_modules/.cache, for the length of a build.
|
|
49
|
-
*
|
|
50
|
-
* A project made before that imports `../shim/bridge.js`, a path that has to exist on disk, so
|
|
51
|
-
* for one of those the shim and its types are still copied in beside `src/`, on every build so
|
|
52
|
-
* updating the SDK updates them.
|
|
53
|
-
*/
|
|
54
|
-
export async function buildPlugin(dir, { entry = "plugin.tsx" } = {}) {
|
|
55
|
-
const manifestPath = join(dir, "plugin.json");
|
|
56
|
-
if (!existsSync(manifestPath)) {
|
|
57
|
-
throw new Error(`no plugin.json in ${dir}`);
|
|
58
|
-
}
|
|
59
|
-
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
60
|
-
|
|
61
|
-
// A plugin that needs more from esbuild than this build gives (a worker bundled into it, a
|
|
62
|
-
// dependency's locales left out) exports `esbuildPlugins` from deck-plugin.config.mjs beside
|
|
63
|
-
// plugin.json. They run after Deck's own, so they never take over react or the shim.
|
|
64
|
-
const configPath = join(dir, "deck-plugin.config.mjs");
|
|
65
|
-
const config = existsSync(configPath) ? await import(pathToFileURL(configPath).href) : {};
|
|
66
|
-
|
|
67
|
-
const sources = readdirSync(join(dir, "src"), { recursive: true })
|
|
68
|
-
.filter((f) => typeof f === "string" && /\.tsx?$/.test(f))
|
|
69
|
-
.map((f) => readFileSync(join(dir, "src", f), "utf8"));
|
|
70
|
-
|
|
71
|
-
const legacy = sources.some((src) => /from\s*["'](\.\.\/)+shim\//.test(src));
|
|
72
|
-
let shimDir = join(sdk, "shim");
|
|
73
|
-
let genDir = join(dir, "node_modules", ".cache", "deck-plugin");
|
|
74
|
-
if (legacy) {
|
|
75
|
-
shimDir = genDir = join(dir, "shim");
|
|
76
|
-
rmSync(shimDir, { recursive: true, force: true });
|
|
77
|
-
cpSync(join(sdk, "shim"), shimDir, { recursive: true });
|
|
78
|
-
// The declarations the shim's .d.ts files point at, as ../types/. Copied beside it for the
|
|
79
|
-
// same reason: a relative reference has to find something.
|
|
80
|
-
const typesDir = join(dir, "types");
|
|
81
|
-
rmSync(typesDir, { recursive: true, force: true });
|
|
82
|
-
cpSync(join(sdk, "types"), typesDir, { recursive: true });
|
|
83
|
-
} else {
|
|
84
|
-
mkdirSync(genDir, { recursive: true });
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// ---- icons and animation, generated per plugin ----
|
|
88
|
-
//
|
|
89
|
-
// These two cannot be shipped pre-generated like the rest of the shim. They name only the
|
|
90
|
-
// exports THIS plugin imports, on purpose: re-exporting the whole package goes through a
|
|
91
|
-
// module esbuild cannot see into, which defeats tree-shaking — doing that with lucide took a
|
|
92
|
-
// bundle from 403kb to 640kb, larger than just bundling it.
|
|
93
|
-
//
|
|
94
|
-
// Nothing about this needs Deck's source, only the plugin's own and the real package, so it
|
|
95
|
-
// runs here the same way it runs inside the Deck repository.
|
|
96
|
-
for (const [pkg, file, global] of [
|
|
97
|
-
["lucide-react", "icons.js", "icons"],
|
|
98
|
-
["framer-motion", "motion.js", "motion"],
|
|
99
|
-
]) {
|
|
100
|
-
const re = new RegExp(String.raw`import\s*\{([^}]*)\}\s*from\s*"${pkg}"`, "g");
|
|
101
|
-
const names = [...new Set(sources.flatMap((src) => [...src.matchAll(re)]
|
|
102
|
-
.flatMap((m) => m[1].split(",").map((n) => n.trim().split(/\s+as\s+/)[0]).filter(Boolean))))].sort();
|
|
103
|
-
|
|
104
|
-
// Checked against the real package, so a typo fails here rather than as a blank icon at run
|
|
105
|
-
// time. Only loaded when something is actually imported from it, since framer-motion is an
|
|
106
|
-
// optional peer dependency.
|
|
107
|
-
if (names.length) {
|
|
108
|
-
let real;
|
|
109
|
-
try { real = require(pkg); }
|
|
110
|
-
catch { throw new Error(`this plugin imports from "${pkg}" — run: npm i ${pkg}`); }
|
|
111
|
-
for (const n of names) if (!(n in real)) throw new Error(`${pkg} has no export "${n}"`);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
writeFileSync(join(genDir, file), `// GENERATED by the Deck plugin build — do not edit.
|
|
115
|
-
//
|
|
116
|
-
// Deck's ${pkg}, so this plugin does not bundle its own copy. Only the names this plugin
|
|
117
|
-
// imports: naming every export would defeat tree-shaking and make the bundle larger.
|
|
118
|
-
const __src = window.__deck.${global};
|
|
119
|
-
${names.map((n) => `export const ${n} = __src.${n};`).join("\n")}
|
|
120
|
-
`);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const shims = shimMap(shimDir, genDir);
|
|
124
|
-
|
|
125
|
-
await build({
|
|
126
|
-
entryPoints: [join(dir, "src", entry)],
|
|
127
|
-
outfile: join(dir, "plugin.js"),
|
|
128
|
-
bundle: true,
|
|
129
|
-
format: "esm",
|
|
130
|
-
target: "es2022",
|
|
131
|
-
// Nobody reads a plugin bundle; it is loaded by one import() at startup.
|
|
132
|
-
minify: true,
|
|
133
|
-
// A package that ships separate builds picks the production one.
|
|
134
|
-
conditions: ["production"],
|
|
135
|
-
jsx: "automatic",
|
|
136
|
-
// React comes from Deck, so the automatic runtime must import from the shim rather than a
|
|
137
|
-
// "react/jsx-runtime" that does not exist here.
|
|
138
|
-
jsxImportSource: "deckreact",
|
|
139
|
-
// A .wasm import becomes a Uint8Array inlined in the bundle rather than a sidecar file. A
|
|
140
|
-
// plugin is installed as plugin.json + plugin.js, so a file beside them would never arrive.
|
|
141
|
-
// A .css import becomes its text, for the plugin to inject as a <style>, for the same reason.
|
|
142
|
-
// Images and fonts become data: URLs, for the same reason (packages.mjs).
|
|
143
|
-
loader: { ".wasm": "binary", ".css": "text", ...assetLoaders },
|
|
144
|
-
// A resolve plugin rather than esbuild's `alias`, which maps package to package while these
|
|
145
|
-
// point at single files.
|
|
146
|
-
plugins: [{
|
|
147
|
-
name: "deck-runtime",
|
|
148
|
-
setup(b) {
|
|
149
|
-
const filter = new RegExp(`^(${Object.keys(shims)
|
|
150
|
-
.map((k) => k.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&")).join("|")})$`);
|
|
151
|
-
b.onResolve({ filter }, (a) => (fromPackage(a, dir) ? undefined : { path: shims[a.path] }));
|
|
152
|
-
},
|
|
153
|
-
}, rawImports, packageCss(manifest.id, dir), ...(config.esbuildPlugins ?? [])],
|
|
154
|
-
logLevel: "info",
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
// Optional: only a plugin that brings agent-facing tools has one. Built for node, because the
|
|
158
|
-
// MCP server runs outside the webview.
|
|
159
|
-
if (existsSync(join(dir, "src", "mcp.ts"))) {
|
|
160
|
-
await build({
|
|
161
|
-
entryPoints: [join(dir, "src", "mcp.ts")],
|
|
162
|
-
outfile: join(dir, "mcp.js"),
|
|
163
|
-
platform: "node",
|
|
164
|
-
format: "esm",
|
|
165
|
-
target: "node18",
|
|
166
|
-
bundle: true,
|
|
167
|
-
logLevel: "info",
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return manifest;
|
|
172
|
-
}
|
|
1
|
+
// Build a Deck plugin: TSX sources -> one plugin.js Deck can import.
|
|
2
|
+
//
|
|
3
|
+
// The same build Deck's own plugins get, with one difference: the shim is shipped with this
|
|
4
|
+
// package rather than generated, because generating it needs Deck's TypeScript sources and the
|
|
5
|
+
// point of this package is that you do not have them.
|
|
6
|
+
//
|
|
7
|
+
// Why a plugin wants a build step at all: JSX, and ordinary imports across as many files as you
|
|
8
|
+
// like. It is not rebuilding Deck — it is what a VS Code extension does.
|
|
9
|
+
//
|
|
10
|
+
// The shim is the whole trick. Deck hands React, its bridge, `listen`, its icons and its
|
|
11
|
+
// animation library over on `window.__deck`, and esbuild resolves those module names to files
|
|
12
|
+
// that read from there. So your sources import "react" as normal code does, and at run time get
|
|
13
|
+
// DECK'S React — which is not an optimisation but a requirement, since two Reacts in one tree
|
|
14
|
+
// break hooks.
|
|
15
|
+
import { build } from "esbuild";
|
|
16
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { createRequire } from "node:module";
|
|
18
|
+
import { dirname, join } from "node:path";
|
|
19
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
20
|
+
import { assetLoaders, fromPackage, packageCss, rawImports } from "./packages.mjs";
|
|
21
|
+
|
|
22
|
+
const sdk = dirname(fileURLToPath(import.meta.url));
|
|
23
|
+
const require = createRequire(import.meta.url);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The module names a plugin may import, and the file each resolves to: shipped ones in `shimDir`,
|
|
27
|
+
* the two generated per plugin in `genDir`.
|
|
28
|
+
*/
|
|
29
|
+
function shimMap(shimDir, genDir) {
|
|
30
|
+
return {
|
|
31
|
+
react: join(shimDir, "react.js"),
|
|
32
|
+
"deckreact/jsx-runtime": join(shimDir, "jsx-runtime.js"),
|
|
33
|
+
// A library compiled with the automatic runtime imports it under its real name.
|
|
34
|
+
"react/jsx-runtime": join(shimDir, "jsx-runtime.js"),
|
|
35
|
+
// Deck's react-dom (needs Deck 1.1); only bundled when a plugin or its library imports it.
|
|
36
|
+
"react-dom": join(shimDir, "react-dom.js"),
|
|
37
|
+
"@tauri-apps/api/event": join(shimDir, "event.js"),
|
|
38
|
+
"lucide-react": join(genDir, "icons.js"),
|
|
39
|
+
"framer-motion": join(genDir, "motion.js"),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Build the plugin in `dir`.
|
|
45
|
+
*
|
|
46
|
+
* A plugin imports the shim from this package (`deck-plugin-sdk/bridge`), so its project holds
|
|
47
|
+
* only its own code: the editor and esbuild both find the shim and its types in node_modules.
|
|
48
|
+
* The two files generated per plugin go to node_modules/.cache, for the length of a build.
|
|
49
|
+
*
|
|
50
|
+
* A project made before that imports `../shim/bridge.js`, a path that has to exist on disk, so
|
|
51
|
+
* for one of those the shim and its types are still copied in beside `src/`, on every build so
|
|
52
|
+
* updating the SDK updates them.
|
|
53
|
+
*/
|
|
54
|
+
export async function buildPlugin(dir, { entry = "plugin.tsx" } = {}) {
|
|
55
|
+
const manifestPath = join(dir, "plugin.json");
|
|
56
|
+
if (!existsSync(manifestPath)) {
|
|
57
|
+
throw new Error(`no plugin.json in ${dir}`);
|
|
58
|
+
}
|
|
59
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
60
|
+
|
|
61
|
+
// A plugin that needs more from esbuild than this build gives (a worker bundled into it, a
|
|
62
|
+
// dependency's locales left out) exports `esbuildPlugins` from deck-plugin.config.mjs beside
|
|
63
|
+
// plugin.json. They run after Deck's own, so they never take over react or the shim.
|
|
64
|
+
const configPath = join(dir, "deck-plugin.config.mjs");
|
|
65
|
+
const config = existsSync(configPath) ? await import(pathToFileURL(configPath).href) : {};
|
|
66
|
+
|
|
67
|
+
const sources = readdirSync(join(dir, "src"), { recursive: true })
|
|
68
|
+
.filter((f) => typeof f === "string" && /\.tsx?$/.test(f))
|
|
69
|
+
.map((f) => readFileSync(join(dir, "src", f), "utf8"));
|
|
70
|
+
|
|
71
|
+
const legacy = sources.some((src) => /from\s*["'](\.\.\/)+shim\//.test(src));
|
|
72
|
+
let shimDir = join(sdk, "shim");
|
|
73
|
+
let genDir = join(dir, "node_modules", ".cache", "deck-plugin");
|
|
74
|
+
if (legacy) {
|
|
75
|
+
shimDir = genDir = join(dir, "shim");
|
|
76
|
+
rmSync(shimDir, { recursive: true, force: true });
|
|
77
|
+
cpSync(join(sdk, "shim"), shimDir, { recursive: true });
|
|
78
|
+
// The declarations the shim's .d.ts files point at, as ../types/. Copied beside it for the
|
|
79
|
+
// same reason: a relative reference has to find something.
|
|
80
|
+
const typesDir = join(dir, "types");
|
|
81
|
+
rmSync(typesDir, { recursive: true, force: true });
|
|
82
|
+
cpSync(join(sdk, "types"), typesDir, { recursive: true });
|
|
83
|
+
} else {
|
|
84
|
+
mkdirSync(genDir, { recursive: true });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ---- icons and animation, generated per plugin ----
|
|
88
|
+
//
|
|
89
|
+
// These two cannot be shipped pre-generated like the rest of the shim. They name only the
|
|
90
|
+
// exports THIS plugin imports, on purpose: re-exporting the whole package goes through a
|
|
91
|
+
// module esbuild cannot see into, which defeats tree-shaking — doing that with lucide took a
|
|
92
|
+
// bundle from 403kb to 640kb, larger than just bundling it.
|
|
93
|
+
//
|
|
94
|
+
// Nothing about this needs Deck's source, only the plugin's own and the real package, so it
|
|
95
|
+
// runs here the same way it runs inside the Deck repository.
|
|
96
|
+
for (const [pkg, file, global] of [
|
|
97
|
+
["lucide-react", "icons.js", "icons"],
|
|
98
|
+
["framer-motion", "motion.js", "motion"],
|
|
99
|
+
]) {
|
|
100
|
+
const re = new RegExp(String.raw`import\s*\{([^}]*)\}\s*from\s*"${pkg}"`, "g");
|
|
101
|
+
const names = [...new Set(sources.flatMap((src) => [...src.matchAll(re)]
|
|
102
|
+
.flatMap((m) => m[1].split(",").map((n) => n.trim().split(/\s+as\s+/)[0]).filter(Boolean))))].sort();
|
|
103
|
+
|
|
104
|
+
// Checked against the real package, so a typo fails here rather than as a blank icon at run
|
|
105
|
+
// time. Only loaded when something is actually imported from it, since framer-motion is an
|
|
106
|
+
// optional peer dependency.
|
|
107
|
+
if (names.length) {
|
|
108
|
+
let real;
|
|
109
|
+
try { real = require(pkg); }
|
|
110
|
+
catch { throw new Error(`this plugin imports from "${pkg}" — run: npm i ${pkg}`); }
|
|
111
|
+
for (const n of names) if (!(n in real)) throw new Error(`${pkg} has no export "${n}"`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
writeFileSync(join(genDir, file), `// GENERATED by the Deck plugin build — do not edit.
|
|
115
|
+
//
|
|
116
|
+
// Deck's ${pkg}, so this plugin does not bundle its own copy. Only the names this plugin
|
|
117
|
+
// imports: naming every export would defeat tree-shaking and make the bundle larger.
|
|
118
|
+
const __src = window.__deck.${global};
|
|
119
|
+
${names.map((n) => `export const ${n} = __src.${n};`).join("\n")}
|
|
120
|
+
`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const shims = shimMap(shimDir, genDir);
|
|
124
|
+
|
|
125
|
+
await build({
|
|
126
|
+
entryPoints: [join(dir, "src", entry)],
|
|
127
|
+
outfile: join(dir, "plugin.js"),
|
|
128
|
+
bundle: true,
|
|
129
|
+
format: "esm",
|
|
130
|
+
target: "es2022",
|
|
131
|
+
// Nobody reads a plugin bundle; it is loaded by one import() at startup.
|
|
132
|
+
minify: true,
|
|
133
|
+
// A package that ships separate builds picks the production one.
|
|
134
|
+
conditions: ["production"],
|
|
135
|
+
jsx: "automatic",
|
|
136
|
+
// React comes from Deck, so the automatic runtime must import from the shim rather than a
|
|
137
|
+
// "react/jsx-runtime" that does not exist here.
|
|
138
|
+
jsxImportSource: "deckreact",
|
|
139
|
+
// A .wasm import becomes a Uint8Array inlined in the bundle rather than a sidecar file. A
|
|
140
|
+
// plugin is installed as plugin.json + plugin.js, so a file beside them would never arrive.
|
|
141
|
+
// A .css import becomes its text, for the plugin to inject as a <style>, for the same reason.
|
|
142
|
+
// Images and fonts become data: URLs, for the same reason (packages.mjs).
|
|
143
|
+
loader: { ".wasm": "binary", ".css": "text", ...assetLoaders },
|
|
144
|
+
// A resolve plugin rather than esbuild's `alias`, which maps package to package while these
|
|
145
|
+
// point at single files.
|
|
146
|
+
plugins: [{
|
|
147
|
+
name: "deck-runtime",
|
|
148
|
+
setup(b) {
|
|
149
|
+
const filter = new RegExp(`^(${Object.keys(shims)
|
|
150
|
+
.map((k) => k.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&")).join("|")})$`);
|
|
151
|
+
b.onResolve({ filter }, (a) => (fromPackage(a, dir) ? undefined : { path: shims[a.path] }));
|
|
152
|
+
},
|
|
153
|
+
}, rawImports, packageCss(manifest.id, dir), ...(config.esbuildPlugins ?? [])],
|
|
154
|
+
logLevel: "info",
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Optional: only a plugin that brings agent-facing tools has one. Built for node, because the
|
|
158
|
+
// MCP server runs outside the webview.
|
|
159
|
+
if (existsSync(join(dir, "src", "mcp.ts"))) {
|
|
160
|
+
await build({
|
|
161
|
+
entryPoints: [join(dir, "src", "mcp.ts")],
|
|
162
|
+
outfile: join(dir, "mcp.js"),
|
|
163
|
+
platform: "node",
|
|
164
|
+
format: "esm",
|
|
165
|
+
target: "node18",
|
|
166
|
+
bundle: true,
|
|
167
|
+
logLevel: "info",
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return manifest;
|
|
172
|
+
}
|
package/package.json
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "deck-plugin-sdk",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Build a plugin for Deck, outside the Deck repository.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"bin": {
|
|
8
|
-
"deck-plugin": "bin/deck-plugin.mjs"
|
|
9
|
-
},
|
|
10
|
-
"exports": {
|
|
11
|
-
"./build": "./build-plugin.mjs",
|
|
12
|
-
"./*": {
|
|
13
|
-
"types": "./shim/*.d.ts",
|
|
14
|
-
"default": "./shim/*.js"
|
|
15
|
-
},
|
|
16
|
-
"./package.json": "./package.json"
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"bin",
|
|
20
|
-
"shim",
|
|
21
|
-
"types",
|
|
22
|
-
"template",
|
|
23
|
-
"build-plugin.mjs",
|
|
24
|
-
"packages.mjs",
|
|
25
|
-
"README.md",
|
|
26
|
-
"permissions.json",
|
|
27
|
-
"publish.mjs",
|
|
28
|
-
"validate.mjs"
|
|
29
|
-
],
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"esbuild": "^0.28.0"
|
|
32
|
-
},
|
|
33
|
-
"peerDependencies": {
|
|
34
|
-
"@types/react": "^19.0.0",
|
|
35
|
-
"framer-motion": "^13.0.0",
|
|
36
|
-
"lucide-react": "^1.0.0",
|
|
37
|
-
"monaco-editor": "^0.56.0",
|
|
38
|
-
"react": "^19.0.0",
|
|
39
|
-
"typescript": "^5.0.0"
|
|
40
|
-
},
|
|
41
|
-
"peerDependenciesMeta": {
|
|
42
|
-
"framer-motion": {
|
|
43
|
-
"optional": true
|
|
44
|
-
},
|
|
45
|
-
"monaco-editor": {
|
|
46
|
-
"optional": true
|
|
47
|
-
},
|
|
48
|
-
"typescript": {
|
|
49
|
-
"optional": true
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"engines": {
|
|
53
|
-
"node": ">=20"
|
|
54
|
-
},
|
|
55
|
-
"keywords": [
|
|
56
|
-
"deck",
|
|
57
|
-
"plugin",
|
|
58
|
-
"sdk"
|
|
59
|
-
]
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "deck-plugin-sdk",
|
|
3
|
+
"version": "1.12.0",
|
|
4
|
+
"description": "Build a plugin for Deck, outside the Deck repository.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bin": {
|
|
8
|
+
"deck-plugin": "bin/deck-plugin.mjs"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
"./build": "./build-plugin.mjs",
|
|
12
|
+
"./*": {
|
|
13
|
+
"types": "./shim/*.d.ts",
|
|
14
|
+
"default": "./shim/*.js"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"bin",
|
|
20
|
+
"shim",
|
|
21
|
+
"types",
|
|
22
|
+
"template",
|
|
23
|
+
"build-plugin.mjs",
|
|
24
|
+
"packages.mjs",
|
|
25
|
+
"README.md",
|
|
26
|
+
"permissions.json",
|
|
27
|
+
"publish.mjs",
|
|
28
|
+
"validate.mjs"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"esbuild": "^0.28.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@types/react": "^19.0.0",
|
|
35
|
+
"framer-motion": "^13.0.0",
|
|
36
|
+
"lucide-react": "^1.0.0",
|
|
37
|
+
"monaco-editor": "^0.56.0",
|
|
38
|
+
"react": "^19.0.0",
|
|
39
|
+
"typescript": "^5.0.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependenciesMeta": {
|
|
42
|
+
"framer-motion": {
|
|
43
|
+
"optional": true
|
|
44
|
+
},
|
|
45
|
+
"monaco-editor": {
|
|
46
|
+
"optional": true
|
|
47
|
+
},
|
|
48
|
+
"typescript": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=20"
|
|
54
|
+
},
|
|
55
|
+
"keywords": [
|
|
56
|
+
"deck",
|
|
57
|
+
"plugin",
|
|
58
|
+
"sdk"
|
|
59
|
+
]
|
|
60
|
+
}
|