@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.
Files changed (2) hide show
  1. package/lib/templates.mjs +11 -10
  2. 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 type { SandboxModuleDef } from "@mutka-explorer/module";
18
-
19
- // A Mutka module is a single self-contained ESM file. It imports NOTHING at
20
- // runtime — it reaches the system only through \`host\`, and every host call is
21
- // checked against the permissions declared below. \`import type\` above is erased
22
- // at compile time, so the built file stays self-contained.
23
- const mod: SandboxModuleDef = {
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.1",
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",