@llui/compiler-devtools 0.3.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Franco Ponticelli
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ import type { CompilerModule } from '@llui/compiler';
2
+ export declare const componentMetaModule: CompilerModule;
3
+ //# sourceMappingURL=component-meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-meta.d.ts","sourceRoot":"","sources":["../src/component-meta.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,gBAAgB,CAAA;AAG1E,eAAO,MAAM,mBAAmB,EAAE,cAoCjC,CAAA"}
@@ -0,0 +1,44 @@
1
+ // `component-meta` — emits `__componentMeta: { file, line }` per
2
+ // `component()` call. Today's `injectComponentMeta` in transform.ts
3
+ // is gated on devMode; this module keeps the gating semantics by
4
+ // accepting an option (the umbrella passes `devMode` through).
5
+ //
6
+ // This is the first per-component-targeted emission in the registry.
7
+ // It validates the `EmissionContribution.target` shape (v2c §7.9
8
+ // finding from the schema-hash POC): when multiple `component()`
9
+ // calls live in one file, each gets its own `__componentMeta` with
10
+ // its own line number, and the conflict-detector lets each emission
11
+ // through because the `(field, target)` tuples are distinct.
12
+ import { findComponentCalls } from '@llui/compiler';
13
+ export const componentMetaModule = {
14
+ name: 'component-meta',
15
+ compilerVersion: '^0.3.0',
16
+ diagnostics: [],
17
+ // Targets captured in `emit` (not `visit`) — see `_shared.ts`
18
+ // `findComponentCalls` for the rationale (Phase 2b rebuilds
19
+ // ancestor nodes, invalidating visit-captured refs).
20
+ visitors: {},
21
+ emit(ctx, analysis) {
22
+ const sf = analysis.sourceFile;
23
+ const calls = findComponentCalls(sf);
24
+ if (calls.length === 0)
25
+ return [];
26
+ const out = [];
27
+ for (const n of calls) {
28
+ const pos = n.pos >= 0 ? n.getStart(sf) : 0;
29
+ const { line } = sf.getLineAndCharacterOfPosition(pos);
30
+ const meta = ctx.factory.createObjectLiteralExpression([
31
+ ctx.factory.createPropertyAssignment('file', ctx.factory.createStringLiteral(sf.fileName)),
32
+ ctx.factory.createPropertyAssignment('line', ctx.factory.createNumericLiteral(line + 1)),
33
+ ], false);
34
+ out.push({
35
+ module: 'component-meta',
36
+ field: '__componentMeta',
37
+ value: meta,
38
+ target: n,
39
+ });
40
+ }
41
+ return out;
42
+ },
43
+ };
44
+ //# sourceMappingURL=component-meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-meta.js","sourceRoot":"","sources":["../src/component-meta.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,oEAAoE;AACpE,iEAAiE;AACjE,+DAA+D;AAC/D,EAAE;AACF,qEAAqE;AACrE,iEAAiE;AACjE,iEAAiE;AACjE,mEAAmE;AACnE,oEAAoE;AACp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EAAE,CAAC;aACV,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;CACF,CAAA","sourcesContent":["// `component-meta` — emits `__componentMeta: { file, line }` per\n// `component()` call. Today's `injectComponentMeta` in transform.ts\n// is gated on devMode; this module keeps the gating semantics by\n// accepting an option (the umbrella passes `devMode` through).\n//\n// This is the first per-component-targeted emission in the registry.\n// It validates the `EmissionContribution.target` shape (v2c §7.9\n// finding from the schema-hash POC): when multiple `component()`\n// calls live in one file, each gets its own `__componentMeta` with\n// its own line number, and the conflict-detector lets each emission\n// through because the `(field, target)` tuples are distinct.\n\nimport type { CompilerModule, EmissionContribution } from '@llui/compiler'\nimport { findComponentCalls } from '@llui/compiler'\n\nexport const componentMetaModule: CompilerModule = {\n name: 'component-meta',\n compilerVersion: '^0.3.0',\n diagnostics: [],\n // Targets captured in `emit` (not `visit`) — see `_shared.ts`\n // `findComponentCalls` for the rationale (Phase 2b rebuilds\n // ancestor nodes, invalidating visit-captured refs).\n visitors: {},\n\n emit(ctx, analysis): EmissionContribution[] {\n const sf = analysis.sourceFile\n const calls = findComponentCalls(sf)\n if (calls.length === 0) return []\n const out: EmissionContribution[] = []\n for (const n of calls) {\n const pos = n.pos >= 0 ? n.getStart(sf) : 0\n const { line } = sf.getLineAndCharacterOfPosition(pos)\n const meta = ctx.factory.createObjectLiteralExpression(\n [\n ctx.factory.createPropertyAssignment(\n 'file',\n ctx.factory.createStringLiteral(sf.fileName),\n ),\n ctx.factory.createPropertyAssignment('line', ctx.factory.createNumericLiteral(line + 1)),\n ],\n false,\n )\n out.push({\n module: 'component-meta',\n field: '__componentMeta',\n value: meta,\n target: n,\n })\n }\n return out\n },\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { type DevtoolsFactory } from '@llui/compiler';
2
+ import { componentMetaModule } from './component-meta.js';
3
+ export { componentMetaModule };
4
+ /**
5
+ * Builds the devtools module set for a single source file.
6
+ * Activation gates mirror what `transformLlui` did inline before
7
+ * decomp-27:
8
+ * - `componentMetaModule` when `devMode` is true
9
+ *
10
+ * Future devtools modules (trace instrumentation) would gate on a
11
+ * separate `enableTraceInstrumentation` flag the host passes via
12
+ * the factory input.
13
+ */
14
+ export declare const devtoolsFactory: DevtoolsFactory;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,KAAK,eAAe,EAAuB,MAAM,gBAAgB,CAAA;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAEzD,OAAO,EAAE,mBAAmB,EAAE,CAAA;AAE9B;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,eAM7B,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ // @llui/compiler-devtools — dev-MCP / LLM tooling support (opt-in).
2
+ //
3
+ // Emits compile-time metadata the dev MCP (`@llui/mcp`) and future
4
+ // devtools UI consume. Distinct from `@llui/compiler-introspection`
5
+ // which emits shared metadata (schemas, hashes, legend) that BOTH
6
+ // the end-user agent AND dev tooling consume; this package emits
7
+ // dev-only debug aids that don't need to ship in end-user builds.
8
+ //
9
+ // Modules:
10
+ // - component-meta __componentMeta: { file, line }
11
+ // - (future) trace instrumentation: _eachDiffLog, _disposerLog,
12
+ // _effectTimeline, _coverage when the runtime devtools spec lands
13
+ //
14
+ // Activation: opt-in. Hosts (Vite plugin, MCP, test setup) import
15
+ // this package and call `registerDevtoolsFactory(devtoolsFactory)`.
16
+ // transformLlui then activates modules per the factory's gating
17
+ // rules (today: componentMeta runs when devMode is true).
18
+ import {} from '@llui/compiler';
19
+ import { componentMetaModule } from './component-meta.js';
20
+ export { componentMetaModule };
21
+ /**
22
+ * Builds the devtools module set for a single source file.
23
+ * Activation gates mirror what `transformLlui` did inline before
24
+ * decomp-27:
25
+ * - `componentMetaModule` when `devMode` is true
26
+ *
27
+ * Future devtools modules (trace instrumentation) would gate on a
28
+ * separate `enableTraceInstrumentation` flag the host passes via
29
+ * the factory input.
30
+ */
31
+ export const devtoolsFactory = (input) => {
32
+ const modules = [];
33
+ if (input.devMode) {
34
+ modules.push(componentMetaModule);
35
+ }
36
+ return modules;
37
+ };
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,EAAE;AACF,mEAAmE;AACnE,oEAAoE;AACpE,kEAAkE;AAClE,iEAAiE;AACjE,kEAAkE;AAClE,EAAE;AACF,WAAW;AACX,+DAA+D;AAC/D,kEAAkE;AAClE,sEAAsE;AACtE,EAAE;AACF,kEAAkE;AAClE,oEAAoE;AACpE,gEAAgE;AAChE,0DAA0D;AAE1D,OAAO,EAA6C,MAAM,gBAAgB,CAAA;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAEzD,OAAO,EAAE,mBAAmB,EAAE,CAAA;AAE9B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAoB,CAAC,KAAK,EAAE,EAAE;IACxD,MAAM,OAAO,GAAqB,EAAE,CAAA;IACpC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IACnC,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["// @llui/compiler-devtools — dev-MCP / LLM tooling support (opt-in).\n//\n// Emits compile-time metadata the dev MCP (`@llui/mcp`) and future\n// devtools UI consume. Distinct from `@llui/compiler-introspection`\n// which emits shared metadata (schemas, hashes, legend) that BOTH\n// the end-user agent AND dev tooling consume; this package emits\n// dev-only debug aids that don't need to ship in end-user builds.\n//\n// Modules:\n// - component-meta __componentMeta: { file, line }\n// - (future) trace instrumentation: _eachDiffLog, _disposerLog,\n// _effectTimeline, _coverage when the runtime devtools spec lands\n//\n// Activation: opt-in. Hosts (Vite plugin, MCP, test setup) import\n// this package and call `registerDevtoolsFactory(devtoolsFactory)`.\n// transformLlui then activates modules per the factory's gating\n// rules (today: componentMeta runs when devMode is true).\n\nimport { type DevtoolsFactory, type CompilerModule } from '@llui/compiler'\nimport { componentMetaModule } from './component-meta.js'\n\nexport { componentMetaModule }\n\n/**\n * Builds the devtools module set for a single source file.\n * Activation gates mirror what `transformLlui` did inline before\n * decomp-27:\n * - `componentMetaModule` when `devMode` is true\n *\n * Future devtools modules (trace instrumentation) would gate on a\n * separate `enableTraceInstrumentation` flag the host passes via\n * the factory input.\n */\nexport const devtoolsFactory: DevtoolsFactory = (input) => {\n const modules: CompilerModule[] = []\n if (input.devMode) {\n modules.push(componentMetaModule)\n }\n return modules\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@llui/compiler-devtools",
3
+ "version": "0.3.0",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js"
10
+ }
11
+ },
12
+ "main": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "dependencies": {
18
+ "typescript": "^6.0.2",
19
+ "@llui/compiler": "0.3.0",
20
+ "@llui/compiler-introspection": "0.3.0"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^22.0.0"
24
+ },
25
+ "description": "LLui compiler — dev-MCP / LLM tooling support (opt-in, dev-mode only). Emits `__componentMeta` (file/line for source navigation) and future trace instrumentation (`_eachDiffLog`, `_disposerLog`, `_effectTimeline`, `_coverage`). Depends on @llui/compiler-introspection.",
26
+ "keywords": [
27
+ "llui",
28
+ "compiler",
29
+ "devtools",
30
+ "mcp"
31
+ ],
32
+ "author": "Franco Ponticelli <franco.ponticelli@gmail.com>",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/fponticelli/llui.git",
37
+ "directory": "packages/compiler-devtools"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/fponticelli/llui/issues"
41
+ },
42
+ "homepage": "https://github.com/fponticelli/llui/tree/main/packages/compiler-devtools#readme",
43
+ "scripts": {
44
+ "build": "tsc -p tsconfig.build.json",
45
+ "check": "tsc --noEmit",
46
+ "lint": "eslint src",
47
+ "test": "vitest run"
48
+ }
49
+ }