@canvakit/plugin-slides 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,105 @@
1
+ # Functional Source License, Version 1.1, ALv2 Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-ALv2
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 AGENTIK SAS
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,64 @@
1
- # Temporary Holding Version
1
+ # @canvakit/plugin-slides
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The `slides` output-type plugin for `@canvakit/agent`.
4
+
5
+ A **declarative** plugin (Mustache template + data → multi-page PDF/HTML deck)
6
+ that defines its own I/O (template path + data overrides + designkit ref) and
7
+ its quality rubric, and taps the shared `@canvakit/agent` refine engine.
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ import { register } from "@canvakit/plugin-slides"
13
+ import { generate } from "@canvakit/agent"
14
+
15
+ // Register into the shared default registry (call once at startup).
16
+ register()
17
+
18
+ // Generate a slide deck.
19
+ const artifact = await generate(
20
+ "slides",
21
+ {
22
+ templatePath: "slides.canvakit.html",
23
+ dataPath: "deck.data.json",
24
+ design: "dk:agentik",
25
+ fonts: "embed",
26
+ },
27
+ { ctx: { cwd: "./fixtures" } }
28
+ )
29
+ ```
30
+
31
+ ## Input
32
+
33
+ | Field | Type | Description |
34
+ | -------------- | ----------------------------- | --------------------------------------------------- |
35
+ | `templatePath` | `string` | Path to the canvakit slides template |
36
+ | `dataPath` | `string` (optional) | Override the template's first file source |
37
+ | `design` | `string` (optional) | Designkit ref (`dk:`, or a local `.design.md` path) |
38
+ | `fonts` | `"link" \| "embed" \| "none"` | Font emission strategy |
39
+ | `variables` | `Record<string, unknown>` | Presentational `--var` overrides |
40
+
41
+ ## Refine
42
+
43
+ The plugin exposes a **presentation-only** refine boundary: edits may only
44
+ change the design, font mode, or presentational variables — never the slide
45
+ content.
46
+
47
+ ## Data format
48
+
49
+ The template expects a `slides` array source with objects like:
50
+
51
+ ```json
52
+ {
53
+ "slides": [
54
+ { "title": "Slide 1", "subtitle": "Optional subtitle" },
55
+ { "type": "content", "title": "Slide 2", "body": "Body text" }
56
+ ]
57
+ }
58
+ ```
59
+
60
+ ## License
61
+
62
+ [FSL-1.1-ALv2](./LICENSE), the Functional Source License with an Apache 2.0 future
63
+ license: free for any use except offering a competing product or service, and
64
+ each version becomes Apache-2.0 two years after its release. Copyright AGENTIK SAS.
@@ -0,0 +1,21 @@
1
+ import { CanvakitPlugin, PluginSourceRegistry } from '@canvakit/agent';
2
+ import { z } from 'zod';
3
+
4
+ declare const FETCH_FONT_FACES_EXTRA_KEY = "slides.fetchFontFaces";
5
+ declare const slidesInputSchema: z.ZodObject<{
6
+ templatePath: z.ZodString;
7
+ dataPath: z.ZodOptional<z.ZodString>;
8
+ design: z.ZodOptional<z.ZodString>;
9
+ fonts: z.ZodOptional<z.ZodEnum<{
10
+ link: "link";
11
+ embed: "embed";
12
+ none: "none";
13
+ }>>;
14
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
15
+ }, z.core.$strip>;
16
+ type SlidesInput = z.infer<typeof slidesInputSchema>;
17
+ declare const slidesPlugin: CanvakitPlugin<SlidesInput>;
18
+
19
+ declare function register(registry?: PluginSourceRegistry): void;
20
+
21
+ export { FETCH_FONT_FACES_EXTRA_KEY, type SlidesInput, register, slidesInputSchema, slidesPlugin };
package/dist/index.mjs ADDED
@@ -0,0 +1,211 @@
1
+ import { defaultRegistry } from '@canvakit/agent';
2
+ import * as path from 'path';
3
+ import { basename, extname } from 'path';
4
+ import { z } from 'zod';
5
+ import { exportCanvas } from '@canvakit/export';
6
+ import { designkitExtension } from '@canvakit/designkit';
7
+ import { readText } from '@canvakit/core';
8
+ import { promises } from 'fs';
9
+
10
+ /**
11
+ * @canvakit/plugin-slides v0.1.0
12
+ * The declarative `slides` output-type plugin for @canvakit/agent.
13
+ */
14
+
15
+ function createNodeFs(baseDir) {
16
+ const abs = path.resolve(baseDir);
17
+ const resolve2 = (p) => path.resolve(abs, p.replace(/^\/+/, ""));
18
+ return {
19
+ async readFile(p) {
20
+ return promises.readFile(resolve2(p));
21
+ },
22
+ async writeFile(p, contents) {
23
+ const full = resolve2(p);
24
+ await promises.mkdir(path.dirname(full), { recursive: true });
25
+ await promises.writeFile(full, contents);
26
+ },
27
+ async exists(p) {
28
+ try {
29
+ await promises.access(resolve2(p));
30
+ return true;
31
+ } catch {
32
+ return false;
33
+ }
34
+ },
35
+ async readdir(p, opts) {
36
+ const root = resolve2(p);
37
+ if (opts?.recursive === true) {
38
+ const found2 = await promises.readdir(root, {
39
+ recursive: true,
40
+ withFileTypes: true
41
+ });
42
+ return found2.map((e) => ({
43
+ name: path.relative(root, path.join(e.parentPath ?? root, e.name)),
44
+ type: e.isDirectory() ? "directory" : "file"
45
+ }));
46
+ }
47
+ const found = await promises.readdir(root, { withFileTypes: true });
48
+ return found.map((e) => ({
49
+ name: e.name,
50
+ type: e.isDirectory() ? "directory" : "file"
51
+ }));
52
+ }
53
+ };
54
+ }
55
+
56
+ // src/slides-plugin.ts
57
+ async function resolveDataPath(fs2, templatePath, dataPath) {
58
+ const stripped = dataPath.replace(/^\/+/, "");
59
+ if (await fs2.exists(stripped)) return `/${stripped}`;
60
+ const slash = templatePath.lastIndexOf("/");
61
+ const templateDir = slash >= 0 ? templatePath.slice(0, slash) : "";
62
+ const templateRel = templateDir ? `${templateDir}/${stripped}` : stripped;
63
+ if (await fs2.exists(templateRel)) return stripped;
64
+ throw new Error(
65
+ `slides dataPath not found: "${dataPath}" \u2014 looked cwd-relative ("${stripped}") and template-relative ("${templateRel}"). Pass a cwd-relative or template-relative path to the data JSON.`
66
+ );
67
+ }
68
+ var FETCH_FONT_FACES_EXTRA_KEY = "slides.fetchFontFaces";
69
+ function isFetchFontFaces(value) {
70
+ return typeof value === "function";
71
+ }
72
+ function extractFontFetcher(ctx) {
73
+ const raw = ctx.extra?.[FETCH_FONT_FACES_EXTRA_KEY];
74
+ return isFetchFontFaces(raw) ? raw : void 0;
75
+ }
76
+ var slidesInputSchema = z.object({
77
+ templatePath: z.string().min(1),
78
+ dataPath: z.string().min(1).optional(),
79
+ design: z.string().min(1).optional(),
80
+ fonts: z.enum(["link", "embed", "none"]).optional(),
81
+ variables: z.record(z.string(), z.unknown()).optional()
82
+ });
83
+ async function buildExportInput(input, ctx) {
84
+ const cwd = ctx.cwd ?? process.cwd();
85
+ const filesystem = createNodeFs(cwd);
86
+ let template = await readText(filesystem, input.templatePath);
87
+ if (input.dataPath) {
88
+ const resolved = await resolveDataPath(
89
+ filesystem,
90
+ input.templatePath,
91
+ input.dataPath
92
+ );
93
+ const pathRe = /(\n[ \t]*path:[ \t]*)(["']?)[^"'\n]+\2/;
94
+ if (!pathRe.test(template)) {
95
+ throw new Error(
96
+ `dataPath set but no "path:" frontmatter line to rewrite in ${input.templatePath}`
97
+ );
98
+ }
99
+ template = template.replace(pathRe, `$1"${resolved}"`);
100
+ }
101
+ const variables = { ...input.variables ?? {} };
102
+ const fetchFontFaces = extractFontFetcher(ctx);
103
+ const extensions = [
104
+ designkitExtension({
105
+ fonts: input.fonts ?? "embed",
106
+ ...input.design ? { overrideDesign: input.design } : {},
107
+ ...fetchFontFaces ? { fetchFontFaces } : {}
108
+ })
109
+ ];
110
+ return {
111
+ template,
112
+ templatePath: input.templatePath,
113
+ filesystem,
114
+ variables,
115
+ extensions
116
+ };
117
+ }
118
+ var PLAIN = { medium: "web" };
119
+ function outputFilename(templatePath) {
120
+ const base = basename(templatePath, extname(templatePath));
121
+ return `${base.replace(/\.canvakit$/, "")}.pdf`;
122
+ }
123
+ var refine = {
124
+ rubric: [
125
+ {
126
+ id: "legible",
127
+ criterion: "Body text is legible at the rendered size (no smaller than ~10px at 100% scale); nothing is clipped or overlapping.",
128
+ weight: 3
129
+ },
130
+ {
131
+ id: "hierarchy",
132
+ criterion: "Each slide has a clear visual hierarchy: the title stands out from the body text; subtitle/body are distinct.",
133
+ weight: 2
134
+ },
135
+ {
136
+ id: "density",
137
+ criterion: "Slides are not overcrowded \u2014 each slide communicates one idea with concise text that fits comfortably on the page.",
138
+ weight: 2
139
+ },
140
+ {
141
+ id: "theme-consistent",
142
+ criterion: "Every colour, background, border, and font-family comes from the active designkit \u2014 no off-theme hardcoded values leaking through.",
143
+ weight: 1
144
+ }
145
+ ],
146
+ editableScope: {
147
+ fields: ["design", "fonts", "variables"],
148
+ notes: "Presentation only \u2014 the designkit ref, font mode, and presentational --var overrides. NEVER the slide content (dataPath / the deck's prose): slide text is fixed input, not something to invent while tuning layout."
149
+ },
150
+ apply(input, edit) {
151
+ switch (edit.path) {
152
+ case "design":
153
+ return { ...input, design: z.string().min(1).parse(edit.value) };
154
+ case "fonts":
155
+ return {
156
+ ...input,
157
+ fonts: z.enum(["link", "embed", "none"]).parse(edit.value)
158
+ };
159
+ default: {
160
+ if (edit.path.startsWith("variables.")) {
161
+ const key = edit.path.slice("variables.".length);
162
+ if (key.length === 0) {
163
+ throw new Error(
164
+ `[plugin-slides] edit path "${edit.path}" has an empty variable key`
165
+ );
166
+ }
167
+ return {
168
+ ...input,
169
+ variables: { ...input.variables ?? {}, [key]: edit.value }
170
+ };
171
+ }
172
+ throw new Error(
173
+ `[plugin-slides] edit path "${edit.path}" is outside editableScope {design, fonts, variables.*}`
174
+ );
175
+ }
176
+ }
177
+ }
178
+ };
179
+ var slidesPlugin = {
180
+ type: "slides",
181
+ input: slidesInputSchema,
182
+ output: "pdf",
183
+ async render(input, ctx) {
184
+ const res = await exportCanvas(await buildExportInput(input, ctx), {
185
+ ...PLAIN,
186
+ format: "pdf"
187
+ });
188
+ return {
189
+ bytes: Buffer.from(res.bytes),
190
+ format: "pdf",
191
+ filename: outputFilename(input.templatePath)
192
+ };
193
+ },
194
+ async preview(input, ctx) {
195
+ const res = await exportCanvas(await buildExportInput(input, ctx), {
196
+ ...PLAIN,
197
+ format: "png"
198
+ });
199
+ return Buffer.from(res.bytes);
200
+ },
201
+ refine
202
+ };
203
+
204
+ // src/index.ts
205
+ function register(registry = defaultRegistry) {
206
+ registry.registerPlugin(slidesPlugin);
207
+ }
208
+
209
+ export { FETCH_FONT_FACES_EXTRA_KEY, register, slidesInputSchema, slidesPlugin };
210
+ //# sourceMappingURL=index.mjs.map
211
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/node-fs.ts","../src/slides-plugin.ts","../src/index.ts"],"names":["resolve","fs","found"],"mappings":";;;;;;;;;;;;;;AAIO,SAAS,aAAa,OAAA,EAAiC;AAC5D,EAAA,MAAM,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A,EAC3B;AACN,EAAA,QAAA,CAAS,eAAe,YAAY,CAAA;AACtC","file":"index.mjs","sourcesContent":["import { promises as fs } from \"node:fs\"\nimport * as path from \"node:path\"\nimport type { FilesystemEntry, FilesystemLike } from \"@canvakit/core\"\n\nexport function createNodeFs(baseDir: string): FilesystemLike {\n const abs = path.resolve(baseDir)\n const resolve = (p: string) => path.resolve(abs, p.replace(/^\\/+/, \"\"))\n\n return {\n async readFile(p) {\n return fs.readFile(resolve(p))\n },\n async writeFile(p, contents) {\n const full = resolve(p)\n await fs.mkdir(path.dirname(full), { recursive: true })\n await fs.writeFile(full, contents)\n },\n async exists(p) {\n try {\n await fs.access(resolve(p))\n return true\n } catch {\n return false\n }\n },\n async readdir(p, opts): Promise<FilesystemEntry[]> {\n const root = resolve(p)\n if (opts?.recursive === true) {\n const found = await fs.readdir(root, {\n recursive: true,\n withFileTypes: true,\n })\n return found.map(e => ({\n name: path.relative(root, path.join(e.parentPath ?? root, e.name)),\n type: e.isDirectory() ? \"directory\" : \"file\",\n }))\n }\n const found = await fs.readdir(root, { withFileTypes: true })\n return found.map(e => ({\n name: e.name,\n type: e.isDirectory() ? \"directory\" : \"file\",\n }))\n },\n }\n}\n","import { promises as fsPromises } from \"node:fs\"\nimport { basename, extname, resolve as resolvePath } from \"node:path\"\nimport { z } from \"zod\"\nimport type {\n Artifact,\n CanvakitPlugin,\n Edit,\n PluginContext,\n RefineCapability,\n} from \"@canvakit/agent\"\nimport {\n exportCanvas,\n type ExportCanvasInput,\n type ExportOptions,\n} from \"@canvakit/export\"\nimport {\n designkitExtension,\n type FetchFontFaces,\n type FontMode,\n} from \"@canvakit/designkit\"\nimport { readText, type FilesystemLike } from \"@canvakit/core\"\nimport { createNodeFs } from \"./node-fs.js\"\n\nasync function resolveDataPath(\n fs: FilesystemLike,\n templatePath: string,\n dataPath: string\n): Promise<string> {\n const stripped = dataPath.replace(/^\\/+/, \"\")\n if (await fs.exists(stripped)) return `/${stripped}`\n const slash = templatePath.lastIndexOf(\"/\")\n const templateDir = slash >= 0 ? templatePath.slice(0, slash) : \"\"\n const templateRel = templateDir ? `${templateDir}/${stripped}` : stripped\n if (await fs.exists(templateRel)) return stripped\n throw new Error(\n `slides dataPath not found: \"${dataPath}\" — looked cwd-relative ` +\n `(\"${stripped}\") and template-relative (\"${templateRel}\"). Pass a ` +\n `cwd-relative or template-relative path to the data JSON.`\n )\n}\n\nexport const FETCH_FONT_FACES_EXTRA_KEY = \"slides.fetchFontFaces\"\n\nfunction isFetchFontFaces(value: unknown): value is FetchFontFaces {\n return typeof value === \"function\"\n}\n\nfunction extractFontFetcher(ctx: PluginContext): FetchFontFaces | undefined {\n const raw = ctx.extra?.[FETCH_FONT_FACES_EXTRA_KEY]\n return isFetchFontFaces(raw) ? raw : undefined\n}\n\nexport const slidesInputSchema = z.object({\n templatePath: z.string().min(1),\n dataPath: z.string().min(1).optional(),\n design: z.string().min(1).optional(),\n fonts: z.enum([\"link\", \"embed\", \"none\"]).optional(),\n variables: z.record(z.string(), z.unknown()).optional(),\n})\n\nexport type SlidesInput = z.infer<typeof slidesInputSchema>\n\nexport async function buildExportInput(\n input: SlidesInput,\n ctx: PluginContext\n): Promise<ExportCanvasInput> {\n const cwd = ctx.cwd ?? process.cwd()\n const filesystem = createNodeFs(cwd)\n\n let template = await readText(filesystem, input.templatePath)\n\n if (input.dataPath) {\n const resolved = await resolveDataPath(\n filesystem,\n input.templatePath,\n input.dataPath\n )\n const pathRe = /(\\n[ \\t]*path:[ \\t]*)([\"']?)[^\"'\\n]+\\2/\n if (!pathRe.test(template)) {\n throw new Error(\n `dataPath set but no \"path:\" frontmatter line to rewrite in ${input.templatePath}`\n )\n }\n template = template.replace(pathRe, `$1\"${resolved}\"`)\n }\n\n const variables: Record<string, unknown> = { ...(input.variables ?? {}) }\n\n const fetchFontFaces = extractFontFetcher(ctx)\n const extensions = [\n designkitExtension({\n fonts: (input.fonts ?? \"embed\") as FontMode,\n ...(input.design ? { overrideDesign: input.design } : {}),\n ...(fetchFontFaces ? { fetchFontFaces } : {}),\n }),\n ]\n\n return {\n template,\n templatePath: input.templatePath,\n filesystem,\n variables,\n extensions,\n }\n}\n\nconst PLAIN: Pick<ExportOptions, \"medium\"> = { medium: \"web\" }\n\nfunction outputFilename(templatePath: string): string {\n const base = basename(templatePath, extname(templatePath))\n return `${base.replace(/\\.canvakit$/, \"\")}.pdf`\n}\n\nconst refine: RefineCapability<SlidesInput> = {\n rubric: [\n {\n id: \"legible\",\n criterion:\n \"Body text is legible at the rendered size (no smaller than ~10px at 100% scale); nothing is clipped or overlapping.\",\n weight: 3,\n },\n {\n id: \"hierarchy\",\n criterion:\n \"Each slide has a clear visual hierarchy: the title stands out from the body text; subtitle/body are distinct.\",\n weight: 2,\n },\n {\n id: \"density\",\n criterion:\n \"Slides are not overcrowded — each slide communicates one idea with concise text that fits comfortably on the page.\",\n weight: 2,\n },\n {\n id: \"theme-consistent\",\n criterion:\n \"Every colour, background, border, and font-family comes from the active designkit — no off-theme hardcoded values leaking through.\",\n weight: 1,\n },\n ],\n editableScope: {\n fields: [\"design\", \"fonts\", \"variables\"],\n notes:\n \"Presentation only — the designkit ref, font mode, and presentational --var overrides. NEVER the slide content (dataPath / the deck's prose): slide text is fixed input, not something to invent while tuning layout.\",\n },\n apply(input: SlidesInput, edit: Edit): SlidesInput {\n switch (edit.path) {\n case \"design\":\n return { ...input, design: z.string().min(1).parse(edit.value) }\n case \"fonts\":\n return {\n ...input,\n fonts: z.enum([\"link\", \"embed\", \"none\"]).parse(edit.value),\n }\n default: {\n if (edit.path.startsWith(\"variables.\")) {\n const key = edit.path.slice(\"variables.\".length)\n if (key.length === 0) {\n throw new Error(\n `[plugin-slides] edit path \"${edit.path}\" has an empty variable key`\n )\n }\n return {\n ...input,\n variables: { ...(input.variables ?? {}), [key]: edit.value },\n }\n }\n throw new Error(\n `[plugin-slides] edit path \"${edit.path}\" is outside editableScope ` +\n `{design, fonts, variables.*}`\n )\n }\n }\n },\n}\n\nexport const slidesPlugin: CanvakitPlugin<SlidesInput> = {\n type: \"slides\",\n input: slidesInputSchema,\n output: \"pdf\",\n async render(input: SlidesInput, ctx: PluginContext): Promise<Artifact> {\n const res = await exportCanvas(await buildExportInput(input, ctx), {\n ...PLAIN,\n format: \"pdf\",\n })\n return {\n bytes: Buffer.from(res.bytes),\n format: \"pdf\",\n filename: outputFilename(input.templatePath),\n }\n },\n async preview(input: SlidesInput, ctx: PluginContext): Promise<Buffer> {\n const res = await exportCanvas(await buildExportInput(input, ctx), {\n ...PLAIN,\n format: \"png\",\n })\n return Buffer.from(res.bytes)\n },\n refine,\n}\n","import { defaultRegistry, type PluginSourceRegistry } from \"@canvakit/agent\"\nimport { slidesPlugin } from \"./slides-plugin.js\"\n\nexport {\n slidesPlugin,\n slidesInputSchema,\n FETCH_FONT_FACES_EXTRA_KEY,\n type SlidesInput,\n} from \"./slides-plugin.js\"\n\nexport function register(\n registry: PluginSourceRegistry = defaultRegistry\n): void {\n registry.registerPlugin(slidesPlugin)\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@canvakit/plugin-slides",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "description": "The `slides` output-type plugin for @canvakit/agent — a declarative slide-deck plugin (Mustache template + data → multi-page PDF/HTML deck) that defines its own I/O + quality rubric and taps the shared refine engine. Registers the \"slides\" type into a PluginSourceRegistry.",
5
+ "keywords": [
6
+ "canvakit",
7
+ "agent",
8
+ "plugin",
9
+ "slides",
10
+ "deck",
11
+ "declarative"
12
+ ],
13
+ "homepage": "https://canvakit.sh",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/openagentik/canvakit",
17
+ "directory": "packages/plugin-slides"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/openagentik/canvakit/issues"
21
+ },
22
+ "license": "FSL-1.1-ALv2",
23
+ "type": "module",
24
+ "main": "dist/index.mjs",
25
+ "module": "dist/index.mjs",
26
+ "types": "dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.mjs",
31
+ "default": "./dist/index.mjs"
32
+ },
33
+ "./package.json": "./package.json"
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "README.md",
38
+ "LICENSE"
39
+ ],
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "dependencies": {
44
+ "@canvakit/agent": "^0.2.0",
45
+ "@canvakit/core": "^0.2.0",
46
+ "@canvakit/designkit": "^0.2.0",
47
+ "@canvakit/export": "^0.2.0",
48
+ "zod": "^4.4.3"
49
+ },
50
+ "devDependencies": {
51
+ "@types/node": "^25.6.2",
52
+ "tsup": "^8.5.1",
53
+ "typescript": "^5.9.3",
54
+ "vitest": "^3.2.4",
55
+ "@canvakit/tooling": "0.0.0"
56
+ },
57
+ "scripts": {
58
+ "dev": "tsup --watch",
59
+ "build": "tsup",
60
+ "clean": "rm -rf dist",
61
+ "check-types": "tsc --noEmit",
62
+ "test": "vitest run",
63
+ "test:watch": "vitest"
64
+ }
6
65
  }