@rollrook-ai/plugin-cli 0.0.0-stage → 0.1.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.
Files changed (50) hide show
  1. package/bin/rollrook-plugin.js +2 -0
  2. package/dist/cli.d.ts +25 -0
  3. package/dist/cli.js +194 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/errors.d.ts +10 -0
  6. package/dist/errors.js +12 -0
  7. package/dist/errors.js.map +1 -0
  8. package/dist/index.d.ts +12 -0
  9. package/dist/index.js +8 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/main.d.ts +1 -0
  12. package/dist/main.js +3 -0
  13. package/dist/main.js.map +1 -0
  14. package/dist/manifest.d.ts +200 -0
  15. package/dist/manifest.js +723 -0
  16. package/dist/manifest.js.map +1 -0
  17. package/dist/packer.d.ts +44 -0
  18. package/dist/packer.js +78 -0
  19. package/dist/packer.js.map +1 -0
  20. package/dist/project.d.ts +59 -0
  21. package/dist/project.js +149 -0
  22. package/dist/project.js.map +1 -0
  23. package/dist/scaffold.d.ts +49 -0
  24. package/dist/scaffold.js +127 -0
  25. package/dist/scaffold.js.map +1 -0
  26. package/dist/vite.d.ts +40 -0
  27. package/dist/vite.js +124 -0
  28. package/dist/vite.js.map +1 -0
  29. package/package.json +49 -4
  30. package/src/cli.ts +206 -0
  31. package/src/errors.ts +11 -0
  32. package/src/index.ts +24 -0
  33. package/src/main.ts +3 -0
  34. package/src/manifest.ts +882 -0
  35. package/src/packer.ts +104 -0
  36. package/src/project.ts +168 -0
  37. package/src/scaffold.ts +156 -0
  38. package/src/vite.ts +136 -0
  39. package/template/README.md +12 -0
  40. package/template/_gitignore +4 -0
  41. package/template/icon.svg +14 -0
  42. package/template/index.html +33 -0
  43. package/template/package.json +22 -0
  44. package/template/rollrook-plugin.json +18 -0
  45. package/template/src/main.ts +78 -0
  46. package/template/src/style.css +35 -0
  47. package/template/src/vite-env.d.ts +1 -0
  48. package/template/tsconfig.json +18 -0
  49. package/template/vite.config.ts +10 -0
  50. package/README.md +0 -3
@@ -0,0 +1,78 @@
1
+ import "@rollrook-ai/sdk/theme.css";
2
+ import "./style.css";
3
+ import { RollRookError, context, events, storage, theme, ui } from "@rollrook-ai/sdk";
4
+ import manifest from "../rollrook-plugin.json";
5
+
6
+ if (import.meta.env.DEV) {
7
+ const { MockHost } = await import("@rollrook-ai/sdk/mock");
8
+ MockHost.install({ manifest });
9
+ }
10
+
11
+ /** The plugin's page: a counter kept in storage and a toast sender. */
12
+ class BasicPlugin {
13
+ static readonly COUNT_KEY = "count";
14
+
15
+ private count = 0;
16
+ private readonly count_element = BasicPlugin.element("count");
17
+
18
+ async start(): Promise<void> {
19
+ theme.follow();
20
+ const current = await context.get();
21
+ const title = BasicPlugin.element("title");
22
+ title.textContent = manifest.name;
23
+ title.title = `Version ${current.plugin_version} in RollRook ${current.app_version}`;
24
+ const stored = await storage.get(BasicPlugin.COUNT_KEY);
25
+ this.count = typeof stored === "number" ? stored : 0;
26
+ this.render(false);
27
+ BasicPlugin.element("increment").addEventListener("click", () => this.add(1));
28
+ BasicPlugin.element("reset").addEventListener("click", () => this.add(-this.count));
29
+ BasicPlugin.element("toast-form").addEventListener("submit", (event: Event) => this.send_toast(event));
30
+ events.on("visibility", (change) => {
31
+ document.body.dataset["shown"] = String(change.is_shown);
32
+ });
33
+ }
34
+
35
+ private async add(delta: number): Promise<void> {
36
+ this.count += delta;
37
+ this.render(true);
38
+ await storage.set(BasicPlugin.COUNT_KEY, this.count);
39
+ await ui.badge(this.count === 0 ? undefined : String(this.count));
40
+ }
41
+
42
+ private async send_toast(event: Event): Promise<void> {
43
+ event.preventDefault();
44
+ const input = BasicPlugin.element("message");
45
+ const text = input instanceof HTMLInputElement ? input.value.trim() : "";
46
+ if (text === "") {
47
+ return;
48
+ }
49
+ try {
50
+ await ui.toast(text);
51
+ } catch (err: unknown) {
52
+ if (err instanceof RollRookError) {
53
+ console.error(`toast failed (${err.code}): ${err.message}`);
54
+ return;
55
+ }
56
+ throw err;
57
+ }
58
+ }
59
+
60
+ private render(should_animate: boolean): void {
61
+ this.count_element.textContent = String(this.count);
62
+ if (should_animate) {
63
+ this.count_element.classList.remove("bump");
64
+ void this.count_element.offsetWidth;
65
+ this.count_element.classList.add("bump");
66
+ }
67
+ }
68
+
69
+ private static element(id: string): HTMLElement {
70
+ const found = document.getElementById(id);
71
+ if (found === null) {
72
+ throw new Error(`the page has no #${id}`);
73
+ }
74
+ return found;
75
+ }
76
+ }
77
+
78
+ await new BasicPlugin().start();
@@ -0,0 +1,35 @@
1
+ .header {
2
+ padding: 2px 2px 4px;
3
+ }
4
+
5
+ .header h1 {
6
+ margin: 0;
7
+ font-size: 15px;
8
+ }
9
+
10
+ .header-icon {
11
+ flex: none;
12
+ border-radius: 7px;
13
+ }
14
+
15
+ .count {
16
+ display: inline-block;
17
+ min-width: 2ch;
18
+ font-size: 28px;
19
+ font-weight: 600;
20
+ font-variant-numeric: tabular-nums;
21
+ letter-spacing: -0.02em;
22
+ }
23
+
24
+ .count.bump {
25
+ animation: bump 260ms cubic-bezier(0.3, 1.6, 0.5, 1);
26
+ }
27
+
28
+ @keyframes bump {
29
+ from {
30
+ transform: scale(1.18);
31
+ }
32
+ to {
33
+ transform: none;
34
+ }
35
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "types": ["vite/client"],
8
+ "strict": true,
9
+ "noUncheckedIndexedAccess": true,
10
+ "noImplicitOverride": true,
11
+ "resolveJsonModule": true,
12
+ "isolatedModules": true,
13
+ "verbatimModuleSyntax": true,
14
+ "skipLibCheck": true,
15
+ "noEmit": true
16
+ },
17
+ "include": ["src", "vite.config.ts"]
18
+ }
@@ -0,0 +1,10 @@
1
+ import { RollRookVite } from "@rollrook-ai/plugin-cli/vite";
2
+ import { defineConfig } from "vite";
3
+
4
+ export default defineConfig({
5
+ base: "./",
6
+ build: {
7
+ target: "es2022",
8
+ },
9
+ plugins: [RollRookVite.plugin()],
10
+ });
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
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.