@twobirds/microcomponents 0.8.0 → 0.9.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.
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/cli/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;EAkBE;AAUF;;;;;;;;;;EAUE;AACF,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC7B,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;EAYE;AACF,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CA0BhE"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/cli/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;EAkBE;AAUF;;;;;;;;;;EAUE;AACF,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC7B,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;EAYE;AACF,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CA2BhE"}
@@ -63,6 +63,7 @@ export function scaffoldProject(namespace) {
63
63
  files['vite.config.ts'] = viteConfig(namespace);
64
64
  files['.gitignore'] = gitignore();
65
65
  files['opencode.jsonc'] = opencodeConfig();
66
+ files['.opencode/skills/components/SKILL.md'] = componentSkill(namespace, tag);
66
67
  files['README.md'] = readme(namespace, tag);
67
68
  files['src/index.html'] = prodShell(tag);
68
69
  files['src/index-dev.html'] = devShell(namespace, tag);
@@ -84,7 +85,7 @@ function packageJson(namespace) {
84
85
  typecheck: 'tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.vc.json',
85
86
  },
86
87
  dependencies: {
87
- '@twobirds/microcomponents': '^0.8.0',
88
+ '@twobirds/microcomponents': '^0.9.0',
88
89
  },
89
90
  devDependencies: {
90
91
  vite: '^8.1.5',
@@ -144,6 +145,86 @@ function opencodeConfig() {
144
145
  },
145
146
  }, null, '\t');
146
147
  }
148
+ function componentSkill(namespace, tag) {
149
+ return `---
150
+ name: components
151
+ description: Use when adding, editing, naming, or wiring a micro component in this project, registering a component in the bundle, choosing an event dispatch target, running dev or build, or touching build/ or public/.
152
+ ---
153
+
154
+ # Micro Components project
155
+
156
+ Namespace \`${namespace}\`. Every tag starts with \`${namespace}-\`. Components live in \`src/${namespace}/\` and the starter is \`<${tag}>\`.
157
+
158
+ ## The chain
159
+
160
+ \`src/\` → \`build/\` → \`public/\`
161
+
162
+ - \`src/\` is the only folder to edit.
163
+ - \`build/\` is the \`tsc\` output plus mirrored companion assets, served by the dev server. Generated.
164
+ - \`public/\` is the production site: \`bundle.js\` with companion assets inlined, \`bundle.css\`, \`index.html\`. Generated.
165
+
166
+ Never edit, rename, or delete anything under \`build/\` or \`public/\`. Change \`src/\` and rebuild.
167
+
168
+ ## Add a component
169
+
170
+ \`\`\`sh
171
+ npx mc new ${namespace}-name --target-html --target-css
172
+ \`\`\`
173
+
174
+ The tag must be kebab-case with at least one hyphen. \`ns-name\` becomes \`src/ns/name.ts\`: the first hyphen becomes the folder, which is the same rule the autoloader uses.
175
+
176
+ Register the component so the production bundle picks it up:
177
+
178
+ \`\`\`ts
179
+ // src/${namespace}/bundle.ts
180
+ import './name.js';
181
+ \`\`\`
182
+
183
+ A component missing from the barrel loads in dev through \`autoload()\` but is absent from \`public/bundle.js\`.
184
+
185
+ ## Companion assets
186
+
187
+ A camelCase descriptor maps to a dotted filename and is listed in \`static assets\`:
188
+
189
+ | descriptor | file | role |
190
+ | --- | --- | --- |
191
+ | \`css\` | \`name.css\` | document-level tokens under \`:root\` |
192
+ | \`targetCss\` | \`name.target.css\` | styles scoped to the host tag |
193
+ | \`shadowCss\` | \`name.shadow.css\` | styles inside the shadow root |
194
+ | \`html\` | \`name.html\` | light-DOM template |
195
+ | \`targetHtml\` | \`name.target.html\` | template for \`target.innerHTML\`, \`{key}\` tokens filled by \`parse()\` |
196
+ | \`shadowHtml\` | \`name.shadow.html\` | template for \`shadowRoot.innerHTML\` |
197
+
198
+ The loader fetches exactly the listed descriptors, so every entry in \`static assets\` needs its file.
199
+
200
+ ## Events
201
+
202
+ Prefer a direct target with the default local dispatch and a typed payload:
203
+
204
+ \`\`\`ts
205
+ target.dispatchEvent(
206
+ new CustomEvent('${namespace}:action', { detail: { data: { id: 'x' } } })
207
+ );
208
+ \`\`\`
209
+
210
+ Bubble up or down the tree only when the receiver cannot be named.
211
+
212
+ ## Verify
213
+
214
+ \`\`\`sh
215
+ pnpm typecheck
216
+ pnpm dev
217
+ pnpm build
218
+ pnpm preview
219
+ \`\`\`
220
+
221
+ \`mc clean\` removes \`build/\`, \`public/\` and \`coverage/\`.
222
+
223
+ ## API reference
224
+
225
+ The \`microcomponents\` MCP server registered in \`opencode.jsonc\` documents every export, the event system, and the concept essays. Query it instead of guessing an API.
226
+ `;
227
+ }
147
228
  function readme(namespace, tag) {
148
229
  return `# ${namespace} App
149
230
 
@@ -201,6 +282,10 @@ npx mc new ${namespace}-name --target-html --target-css
201
282
  \`\`\`
202
283
 
203
284
  Then add its import to \`src/${namespace}/bundle.ts\` so the production bundle picks it up.
285
+
286
+ \`.opencode/skills/components/SKILL.md\` carries the same rules for opencode: the
287
+ \`src/\` → \`build/\` → \`public/\` chain, the asset descriptors, the bundle registration,
288
+ and the event dispatch preference.
204
289
  `;
205
290
  }
206
291
  function viteConfig(namespace) {
package/dist/mcp/api.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "libraryVersion": "0.8.0",
2
+ "libraryVersion": "0.9.0",
3
3
  "exportedCount": 42,
4
4
  "entries": {
5
5
  "MC": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twobirds/microcomponents",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Micro Components",
5
5
  "keywords": [
6
6
  "PWA",