@pyreon/compiler 0.4.0 → 0.5.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.
@@ -53,5 +53,62 @@ interface TransformResult {
53
53
  }
54
54
  declare function transformJSX(code: string, filename?: string): TransformResult;
55
55
  //#endregion
56
- export { type CompilerWarning, type TransformResult, transformJSX };
56
+ //#region src/react-intercept.d.ts
57
+ /**
58
+ * React Pattern Interceptor — detects React/Vue patterns in code and provides
59
+ * structured diagnostics with exact fix suggestions for AI-assisted migration.
60
+ *
61
+ * Two modes:
62
+ * - `detectReactPatterns(code)` — returns diagnostics only (non-destructive)
63
+ * - `migrateReactCode(code)` — applies auto-fixes and returns transformed code
64
+ *
65
+ * Designed for three consumers:
66
+ * 1. Compiler pre-pass (warnings during build)
67
+ * 2. CLI `pyreon doctor` (project-wide scanning)
68
+ * 3. MCP server `migrate_react` / `validate` tools (AI agent integration)
69
+ */
70
+ type ReactDiagnosticCode = "react-import" | "react-dom-import" | "react-router-import" | "use-state" | "use-effect-mount" | "use-effect-deps" | "use-effect-no-deps" | "use-memo" | "use-callback" | "use-ref-dom" | "use-ref-box" | "use-reducer" | "use-layout-effect" | "memo-wrapper" | "forward-ref" | "class-name-prop" | "html-for-prop" | "on-change-input" | "dangerously-set-inner-html" | "dot-value-signal" | "array-map-jsx" | "key-on-for-child" | "create-context-import" | "use-context-import";
71
+ interface ReactDiagnostic {
72
+ /** Machine-readable code for filtering and programmatic handling */
73
+ code: ReactDiagnosticCode;
74
+ /** Human-readable message explaining the issue */
75
+ message: string;
76
+ /** 1-based line number */
77
+ line: number;
78
+ /** 0-based column */
79
+ column: number;
80
+ /** The code as written */
81
+ current: string;
82
+ /** The suggested Pyreon equivalent */
83
+ suggested: string;
84
+ /** Whether migrateReactCode can auto-fix this */
85
+ fixable: boolean;
86
+ }
87
+ interface MigrationChange {
88
+ type: "replace" | "remove" | "add";
89
+ line: number;
90
+ description: string;
91
+ }
92
+ interface MigrationResult {
93
+ /** Transformed source code */
94
+ code: string;
95
+ /** All detected patterns (including unfixable ones) */
96
+ diagnostics: ReactDiagnostic[];
97
+ /** Description of changes applied */
98
+ changes: MigrationChange[];
99
+ }
100
+ declare function detectReactPatterns(code: string, filename?: string): ReactDiagnostic[];
101
+ declare function migrateReactCode(code: string, filename?: string): MigrationResult;
102
+ /** Fast regex check — returns true if code likely contains React patterns worth analyzing */
103
+ declare function hasReactPatterns(code: string): boolean;
104
+ interface ErrorDiagnosis {
105
+ cause: string;
106
+ fix: string;
107
+ fixCode?: string | undefined;
108
+ related?: string | undefined;
109
+ }
110
+ /** Diagnose an error message and return structured fix information */
111
+ declare function diagnoseError(error: string): ErrorDiagnosis | null;
112
+ //#endregion
113
+ export { type CompilerWarning, type ErrorDiagnosis, type MigrationChange, type MigrationResult, type ReactDiagnostic, type ReactDiagnosticCode, type TransformResult, detectReactPatterns, diagnoseError, hasReactPatterns, migrateReactCode, transformJSX };
57
114
  //# sourceMappingURL=index2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/jsx.ts"],"mappings":";;AAqCA;;;;;;;;;;AAWA;;;;;;;;;;AAwCA;;;;;;;;;;;;;UAnDiB,eAAA;;EAEf,OAAA;;EAEA,IAAA;;EAEA,MAAA;;EAEA,IAAA;AAAA;AAAA,UAGe,eAAA;;EAEf,IAAA;;EAEA,aAAA;;EAEA,QAAA,EAAU,eAAA;AAAA;AAAA,iBAkCI,YAAA,CAAa,IAAA,UAAc,QAAA,YAAyB,eAAA"}
1
+ {"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/jsx.ts","../../src/react-intercept.ts"],"mappings":";;AAqCA;;;;;;;;;;AAWA;;;;;;;;;;AAwCA;;;;;;;;;;;;ACpEA;UDiBiB,eAAA;;EAEf,OAAA;ECnB6B;EDqB7B,IAAA;ECK8B;EDH9B,MAAA;ECKyB;EDHzB,IAAA;AAAA;AAAA,UAGe,eAAA;ECIf;EDFA,IAAA;ECMA;EDJA,aAAA;ECQA;EDNA,QAAA,EAAU,eAAA;AAAA;AAAA,iBAkCI,YAAA,CAAa,IAAA,UAAc,QAAA,YAAyB,eAAA;;;;AAnDpE;;;;;;;;;;AAWA;;KC5BY,mBAAA;AAAA,UA0BK,eAAA;EDIf;ECFA,IAAA,EAAM,mBAAA;EDMN;ECJA,OAAA;EDIyB;ECFzB,IAAA;EDoCc;EClCd,MAAA;;EAEA,OAAA;EDgC2B;EC9B3B,SAAA;ED8BkE;EC5BlE,OAAA;AAAA;AAAA,UAGe,eAAA;EACf,IAAA;EACA,IAAA;EACA,WAAA;AAAA;AAAA,UAGe,eAAA;EAjDc;EAmD7B,IAAA;EAzBe;EA2Bf,WAAA,EAAa,eAAA;;EAEb,OAAA,EAAS,eAAA;AAAA;AAAA,iBAsgBK,mBAAA,CAAoB,IAAA,UAAc,QAAA,YAAyB,eAAA;AAAA,iBA+V3D,gBAAA,CAAiB,IAAA,UAAc,QAAA,YAAyB,eAAA;;iBA0ExD,gBAAA,CAAiB,IAAA;AAAA,UAuBhB,cAAA;EACf,KAAA;EACA,GAAA;EACA,OAAA;EACA,OAAA;AAAA;;iBAkGc,aAAA,CAAc,KAAA,WAAgB,cAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyreon/compiler",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Template and JSX compiler for Pyreon",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/index.ts CHANGED
@@ -2,3 +2,17 @@
2
2
 
3
3
  export type { CompilerWarning, TransformResult } from "./jsx"
4
4
  export { transformJSX } from "./jsx"
5
+
6
+ export type {
7
+ ErrorDiagnosis,
8
+ MigrationChange,
9
+ MigrationResult,
10
+ ReactDiagnostic,
11
+ ReactDiagnosticCode,
12
+ } from "./react-intercept"
13
+ export {
14
+ detectReactPatterns,
15
+ diagnoseError,
16
+ hasReactPatterns,
17
+ migrateReactCode,
18
+ } from "./react-intercept"