@mutka-explorer/create 1.0.0-rc.1 → 1.0.0-rc.3
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/lib/templates.mjs +11 -10
- package/package.json +1 -1
package/lib/templates.mjs
CHANGED
|
@@ -14,13 +14,15 @@ export const PERMISSIONS = [
|
|
|
14
14
|
const permsLiteral = (perms) => perms.map((p) => `"${p}"`).join(", ");
|
|
15
15
|
|
|
16
16
|
export function indexTs(cfg) {
|
|
17
|
-
return `import
|
|
18
|
-
|
|
19
|
-
// A Mutka module is a single self-contained ESM file. It
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
|
|
17
|
+
return `import { defineModule } from "@mutka-explorer/module";
|
|
18
|
+
|
|
19
|
+
// A Mutka module is a single self-contained ESM file. It reaches the system only
|
|
20
|
+
// through \`host\`, and every host call is checked against the permissions declared
|
|
21
|
+
// below. \`defineModule\` is an identity function: it adds no runtime weight (the
|
|
22
|
+
// bundler inlines it) but lets TypeScript infer your command ids — so
|
|
23
|
+
// \`host.onCommand\` only accepts an id you declared in \`commands\`, and a typo is a
|
|
24
|
+
// compile error.
|
|
25
|
+
export default defineModule({
|
|
24
26
|
id: "${cfg.id}",
|
|
25
27
|
name: "${cfg.name}",
|
|
26
28
|
version: "0.1.0",
|
|
@@ -38,6 +40,7 @@ const mod: SandboxModuleDef = {
|
|
|
38
40
|
},
|
|
39
41
|
],
|
|
40
42
|
setup(host) {
|
|
43
|
+
// "${cfg.id}.hello" is autocompleted + checked against commands[] above.
|
|
41
44
|
host.onCommand("${cfg.id}.hello", async (snap) => {
|
|
42
45
|
// host is fully typed — readDir resolves to FileItem[], no cast needed.
|
|
43
46
|
const items = await host.fs.readDir(snap.currentDirectory);
|
|
@@ -47,9 +50,7 @@ const mod: SandboxModuleDef = {
|
|
|
47
50
|
);
|
|
48
51
|
});
|
|
49
52
|
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default mod;
|
|
53
|
+
});
|
|
53
54
|
`;
|
|
54
55
|
}
|
|
55
56
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mutka-explorer/create",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.3",
|
|
4
4
|
"description": "Scaffold a new Mutka module — a typed TypeScript project wired to @mutka-explorer/module that builds to a single ESM file.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Mutka contributors",
|