@fcannizzaro/streamdeck-react 0.1.12 → 0.1.14
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 +11 -8
- package/dist/action.d.ts +2 -2
- package/dist/action.js +2 -1
- package/dist/bundler-shared.d.ts +31 -0
- package/dist/bundler-shared.js +64 -2
- package/dist/font-inline.js +1 -1
- package/dist/google-font.d.ts +61 -0
- package/dist/google-font.js +124 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -1
- package/dist/manifest-extract.d.ts +32 -0
- package/dist/manifest-extract.js +141 -0
- package/dist/manifest-gen.d.ts +52 -0
- package/dist/manifest-gen.js +229 -0
- package/dist/manifest-types.d.ts +238 -0
- package/dist/plugin.js +44 -35
- package/dist/render/render-pool.js +1 -1
- package/dist/rollup.d.ts +37 -10
- package/dist/rollup.js +43 -14
- package/dist/roots/registry.js +20 -20
- package/dist/types.d.ts +35 -35
- package/dist/vite.d.ts +24 -8
- package/dist/vite.js +48 -13
- package/package.json +10 -5
- package/dist/manifest-codegen.d.ts +0 -38
- package/dist/manifest-codegen.js +0 -110
package/dist/manifest-codegen.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { dirname, join, resolve } from "node:path";
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
3
|
-
//#region src/manifest-codegen.ts
|
|
4
|
-
/**
|
|
5
|
-
* Find the manifest.json inside a `*.sdPlugin` directory.
|
|
6
|
-
*
|
|
7
|
-
* - If `explicit` is a string, it is resolved against `root`.
|
|
8
|
-
* - If `explicit` is `false`, codegen is disabled (returns `null`).
|
|
9
|
-
* - Otherwise, auto-detects by scanning `root` for `*.sdPlugin/manifest.json`.
|
|
10
|
-
*/
|
|
11
|
-
function findManifestPath(root, explicit, warn) {
|
|
12
|
-
if (explicit === false) return null;
|
|
13
|
-
if (typeof explicit === "string") {
|
|
14
|
-
const resolved = resolve(root, explicit);
|
|
15
|
-
if (!existsSync(resolved)) {
|
|
16
|
-
warn?.(`[@fcannizzaro/streamdeck-react] Manifest not found at ${resolved}`);
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return resolved;
|
|
20
|
-
}
|
|
21
|
-
const sdPluginDirs = readdirSync(root, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".sdPlugin"));
|
|
22
|
-
if (sdPluginDirs.length === 0) return null;
|
|
23
|
-
if (sdPluginDirs.length > 1) warn?.(`[@fcannizzaro/streamdeck-react] Multiple .sdPlugin directories found. Using "${sdPluginDirs[0].name}". Set the \`manifest\` option to specify one explicitly.`);
|
|
24
|
-
const manifestPath = join(root, sdPluginDirs[0].name, "manifest.json");
|
|
25
|
-
return existsSync(manifestPath) ? manifestPath : null;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Parse a Stream Deck plugin manifest and extract action metadata.
|
|
29
|
-
* Returns an empty array on failure (with a warning).
|
|
30
|
-
*/
|
|
31
|
-
function parseManifest(path, warn) {
|
|
32
|
-
try {
|
|
33
|
-
const content = readFileSync(path, "utf-8");
|
|
34
|
-
const manifest = JSON.parse(content);
|
|
35
|
-
if (!Array.isArray(manifest.Actions)) {
|
|
36
|
-
warn?.(`[@fcannizzaro/streamdeck-react] manifest.json has no Actions array`);
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
const actions = [];
|
|
40
|
-
for (const action of manifest.Actions) {
|
|
41
|
-
if (!action.UUID) {
|
|
42
|
-
warn?.(`[@fcannizzaro/streamdeck-react] Skipping manifest action with missing UUID`);
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
actions.push({
|
|
46
|
-
uuid: action.UUID,
|
|
47
|
-
controllers: action.Controllers ?? ["Keypad"]
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return actions;
|
|
51
|
-
} catch (err) {
|
|
52
|
-
warn?.(`[@fcannizzaro/streamdeck-react] Failed to parse manifest: ${err instanceof Error ? err.message : String(err)}`);
|
|
53
|
-
return [];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
var HEADER = ["// This file is auto-generated by @fcannizzaro/streamdeck-react", "// Do not edit this file manually. It is regenerated from the plugin manifest."].join("\n");
|
|
57
|
-
/**
|
|
58
|
-
* Generate the `declare module` augmentation string from parsed actions.
|
|
59
|
-
* Returns an empty string when there are no actions.
|
|
60
|
-
*/
|
|
61
|
-
function generateManifestDts(actions) {
|
|
62
|
-
if (actions.length === 0) return "";
|
|
63
|
-
return [
|
|
64
|
-
HEADER,
|
|
65
|
-
"",
|
|
66
|
-
"import \"@fcannizzaro/streamdeck-react\";",
|
|
67
|
-
"",
|
|
68
|
-
"declare module \"@fcannizzaro/streamdeck-react\" {",
|
|
69
|
-
" interface ManifestActions {",
|
|
70
|
-
...actions.map((action) => {
|
|
71
|
-
const controllers = action.controllers.map((c) => `"${c}"`).join(", ");
|
|
72
|
-
return ` "${action.uuid}": {\n controllers: readonly [${controllers}];\n };`;
|
|
73
|
-
}),
|
|
74
|
-
" }",
|
|
75
|
-
"}",
|
|
76
|
-
""
|
|
77
|
-
].join("\n");
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Write the generated `.d.ts` file only when the content has changed.
|
|
81
|
-
* Creates the parent directory if it does not exist.
|
|
82
|
-
*
|
|
83
|
-
* @returns `true` if the file was written, `false` if content was unchanged.
|
|
84
|
-
*/
|
|
85
|
-
function writeManifestDtsIfChanged(outPath, content) {
|
|
86
|
-
if (content === "") return false;
|
|
87
|
-
if (existsSync(outPath)) {
|
|
88
|
-
if (readFileSync(outPath, "utf-8") === content) return false;
|
|
89
|
-
}
|
|
90
|
-
const dir = dirname(outPath);
|
|
91
|
-
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
92
|
-
writeFileSync(outPath, content);
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* High-level helper: find, parse, generate, and write manifest types.
|
|
97
|
-
*
|
|
98
|
-
* @returns The resolved manifest path (for watch registration), or `null`.
|
|
99
|
-
*/
|
|
100
|
-
function generateManifestTypes(root, manifestOption, warn) {
|
|
101
|
-
const manifestPath = findManifestPath(root, manifestOption, warn);
|
|
102
|
-
if (!manifestPath) return null;
|
|
103
|
-
const content = generateManifestDts(parseManifest(manifestPath, warn));
|
|
104
|
-
return {
|
|
105
|
-
manifestPath,
|
|
106
|
-
written: writeManifestDtsIfChanged(resolve(root, "src/streamdeck-env.d.ts"), content)
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
//#endregion
|
|
110
|
-
export { generateManifestTypes };
|