@rangular-framework/compiler 0.0.0-stage → 1.0.1

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 (68) hide show
  1. package/dist/compiler/src/catalog.d.ts +63 -0
  2. package/dist/compiler/src/catalog.js +198 -0
  3. package/dist/compiler/src/class/formInit.d.ts +119 -0
  4. package/dist/compiler/src/class/formInit.js +370 -0
  5. package/dist/compiler/src/class/parseComponent.d.ts +232 -0
  6. package/dist/compiler/src/class/parseComponent.js +430 -0
  7. package/dist/compiler/src/class/parseDirective.d.ts +42 -0
  8. package/dist/compiler/src/class/parseDirective.js +227 -0
  9. package/dist/compiler/src/class/parseRoutes.d.ts +59 -0
  10. package/dist/compiler/src/class/parseRoutes.js +163 -0
  11. package/dist/compiler/src/codegen/generate.d.ts +166 -0
  12. package/dist/compiler/src/codegen/generate.js +3466 -0
  13. package/dist/compiler/src/codegen/methods.d.ts +148 -0
  14. package/dist/compiler/src/codegen/methods.js +975 -0
  15. package/dist/compiler/src/codegen/sourceMap.d.ts +42 -0
  16. package/dist/compiler/src/codegen/sourceMap.js +77 -0
  17. package/dist/compiler/src/compile.d.ts +101 -0
  18. package/dist/compiler/src/compile.js +775 -0
  19. package/dist/compiler/src/diagnostics.d.ts +37 -0
  20. package/dist/compiler/src/diagnostics.js +113 -0
  21. package/dist/compiler/src/doctor.d.ts +35 -0
  22. package/dist/compiler/src/doctor.js +144 -0
  23. package/dist/compiler/src/fix.d.ts +21 -0
  24. package/dist/compiler/src/fix.js +44 -0
  25. package/dist/compiler/src/index.d.ts +22 -0
  26. package/dist/compiler/src/index.js +38 -0
  27. package/dist/compiler/src/preview/renderPreview.d.ts +101 -0
  28. package/dist/compiler/src/preview/renderPreview.js +7158 -0
  29. package/dist/compiler/src/preview/styleSnapshot.d.ts +36 -0
  30. package/dist/compiler/src/preview/styleSnapshot.js +268 -0
  31. package/dist/compiler/src/propTable.d.ts +22 -0
  32. package/dist/compiler/src/propTable.js +107 -0
  33. package/dist/compiler/src/style/css.d.ts +23 -0
  34. package/dist/compiler/src/style/css.js +161 -0
  35. package/dist/compiler/src/template/ast.d.ts +66 -0
  36. package/dist/compiler/src/template/ast.js +19 -0
  37. package/dist/compiler/src/template/evaluate.d.ts +45 -0
  38. package/dist/compiler/src/template/evaluate.js +151 -0
  39. package/dist/compiler/src/template/expr.d.ts +94 -0
  40. package/dist/compiler/src/template/expr.js +360 -0
  41. package/dist/compiler/src/template/forms.d.ts +42 -0
  42. package/dist/compiler/src/template/forms.js +80 -0
  43. package/dist/compiler/src/template/literal.d.ts +38 -0
  44. package/dist/compiler/src/template/literal.js +248 -0
  45. package/dist/compiler/src/template/parser.d.ts +14 -0
  46. package/dist/compiler/src/template/parser.js +230 -0
  47. package/dist/compiler/src/template/pipes.d.ts +48 -0
  48. package/dist/compiler/src/template/pipes.js +225 -0
  49. package/dist/compiler/src/template/printAst.d.ts +3 -0
  50. package/dist/compiler/src/template/printAst.js +38 -0
  51. package/dist/compiler/src/template/structural.d.ts +27 -0
  52. package/dist/compiler/src/template/structural.js +51 -0
  53. package/dist/runtime/src/index.d.ts +486 -0
  54. package/dist/runtime/src/index.js +1197 -0
  55. package/dist/ui/src/chart.d.ts +81 -0
  56. package/dist/ui/src/chart.js +196 -0
  57. package/dist/ui/src/datetime.d.ts +92 -0
  58. package/dist/ui/src/datetime.js +240 -0
  59. package/dist/ui/src/icons.d.ts +63 -0
  60. package/dist/ui/src/icons.js +310 -0
  61. package/dist/ui/src/mask.d.ts +38 -0
  62. package/dist/ui/src/mask.js +103 -0
  63. package/dist/ui/src/palette.d.ts +66 -0
  64. package/dist/ui/src/palette.js +141 -0
  65. package/dist/ui/src/tokens.d.ts +129 -0
  66. package/dist/ui/src/tokens.js +173 -0
  67. package/package.json +24 -4
  68. package/README.md +0 -3
@@ -0,0 +1,148 @@
1
+ import * as ts from 'typescript';
2
+ import { ComponentField, ComponentMethod } from '../class/parseComponent';
3
+ import { Diagnostic } from '../diagnostics';
4
+ /**
5
+ * Method translation (Stage 2, M3).
6
+ *
7
+ * Component methods are translated statement-by-statement from the
8
+ * TypeScript AST. Two output modes share one walker:
9
+ * - 'react': `this.field` reads become the bare variable; assignments to
10
+ * state fields become setter calls (`this.count++` -> `setCount(count + 1)`).
11
+ * - 'state': `this.field` becomes `state.field` and `this.method()` becomes
12
+ * `methods.method()`, used by the interactive HTML preview runtime.
13
+ *
14
+ * Anything outside the supported subset yields a METHOD_UNSUPPORTED warning
15
+ * plus a TODO comment at that spot, code is never silently dropped and
16
+ * broken syntax is never emitted.
17
+ */
18
+ /**
19
+ * 'react' , component -> function component (this.field -> state/setter).
20
+ * 'state' , the interactive preview (this.field -> state.field).
21
+ * 'service', a service stays a real class, so `this.` survives verbatim;
22
+ * assignments to fields additionally emit `this.__notify()` so
23
+ * subscribed components re-render (Stage 3, M6).
24
+ * 'pipe', a @Pipe class also stays a real class (Stage 12): `this.`
25
+ * survives and assignments stay plain, but there is no
26
+ * __notify, a pipe has no subscribers; the generated class
27
+ * does not extend ReactiveService.
28
+ */
29
+ export type TranslateMode = 'react' | 'state' | 'service' | 'pipe';
30
+ export declare function setterName(field: string): string;
31
+ /**
32
+ * The method-local shadow for a state field that a method assigns and
33
+ * then reads again (react mode). Generated code holds fields in consts
34
+ * plus setters, so a read after `this.x = v` would see the stale render
35
+ * value, where the class reads the value it just wrote. A shadow local
36
+ * restores the class semantics: it starts as the render value, every
37
+ * assignment in the method updates it alongside the setter call, and
38
+ * reads of the field after its first assignment in the method go to it.
39
+ */
40
+ export declare function shadowName(field: string): string;
41
+ /**
42
+ * The array methods that mutate their receiver in place. A call of one
43
+ * of these on `this.<field>` changes the field's value, so the field
44
+ * counts as mutated (proof fix): without this, `this.items.push(x)`
45
+ * compiled silently against a plain const and the generated app never
46
+ * re-rendered, while the preview (whose state is a mutable object)
47
+ * did, a direct parity break.
48
+ */
49
+ export declare const MUTATING_ARRAY_METHODS: Set<string>;
50
+ /** The fix line that teaches the assignment form for array changes. */
51
+ export declare function arrayAssignmentFix(field: string): string;
52
+ /**
53
+ * First pass: which fields are assigned anywhere inside any method?
54
+ * Those fields become React state (useState) in codegen.
55
+ */
56
+ export declare function analyzeMutatedFields(component: MethodHost): Set<string>;
57
+ /**
58
+ * The stale-read trap (verification fortification, 2026-11-26): within
59
+ * one method, a field that is assigned, then read, then assigned again
60
+ * is read as the value from before the method ran, because generated
61
+ * state reads see the render snapshot, not the pending assignment.
62
+ * Flagged once per field per method as GEN_FIELD_REREAD. The scan
63
+ * walks statements in order (if branches in sequence) and never into
64
+ * arrow bodies, whose execution is deferred. A call to a method of
65
+ * the same component is expanded one level (runtime prevention
66
+ * round, 2026-11-29, point 9): the helper runs with the caller's
67
+ * render snapshot, so an assign in the caller, a read in the
68
+ * helper and an assign in the helper is the same trap split across
69
+ * the call. Deeper chains and recursion are not followed.
70
+ */
71
+ export declare function analyzeFieldRereads(component: MethodHost): Diagnostic[];
72
+ /**
73
+ * The stale timer trap (runtime prevention round, 2026-11-29,
74
+ * point 1 of the audit): a setInterval or setTimeout created in
75
+ * ngOnInit or the constructor runs its callback with the field
76
+ * values of the first render, because those bodies run exactly
77
+ * once and a component's methods are recreated per render, so the
78
+ * timer keeps the first copy. A callback that reads a component
79
+ * field therefore reads the first value forever: an interval
80
+ * counter freezes at its first tick. A write that reads no field
81
+ * is safe (the setter is stable and the value is the same from
82
+ * any render), and a timer created in an event handler runs with
83
+ * that event's own render, so neither is flagged. This analysis
84
+ * runs for components only (react mode), where fields are render
85
+ * state. A service's fields are plain instance fields, so its
86
+ * timers read live values and stay silent: the alarm heartbeat
87
+ * is the safe pattern this check points to. Flagged once per
88
+ * timer call as GEN_TIMER_STALE. A callback that calls a
89
+ * component method counts when that method reads a field itself
90
+ * (one level: setInterval(() => this.tick()) is the alarm shape,
91
+ * safe in a service and stale in a component).
92
+ */
93
+ export declare function analyzeTimers(component: MethodHost): Diagnostic[];
94
+ /**
95
+ * The deep mutation trap (runtime prevention round, 2026-11-29,
96
+ * point 2 of the audit): an assignment into a field's insides,
97
+ * this.items[0] = 'z' or this.cfg.loud = true, compiles clean and
98
+ * generates a raw mutation with no setter call, so the data
99
+ * changes and the view never re-renders. push and pop are
100
+ * rewritten through the setter and splice and sort are named by
101
+ * METHOD_UNSUPPORTED; this is the remaining silent shape. Flagged
102
+ * once per field per method as GEN_DEEP_MUTATION. Components only
103
+ * (react mode): a service's fields are plain instance fields and
104
+ * its subscribers re-render on the version bump of any assignment
105
+ * the service makes to the field itself; the trap is the component
106
+ * state slot, where only the setter call re-renders.
107
+ */
108
+ export declare function analyzeDeepMutations(component: MethodHost): Diagnostic[];
109
+ /**
110
+ * React mode: find the state fields a method assigns and then reads
111
+ * again later in the same method (in source order, blocks and if/else
112
+ * branches flattened in order). Those fields get a method-local shadow
113
+ * (see shadowName), because the generated setter call does not update
114
+ * the render-scope const the bare field name reads. Reads inside the
115
+ * assigning statement's own right-hand side are not "later": they see
116
+ * the value from before that assignment, which is the render value or
117
+ * the shadow left by an earlier assignment, both already correct.
118
+ */
119
+ export declare function findShadowedFields(statements: ts.Statement[], fieldNames: Set<string>, methodNames: Set<string>, stateFields: Set<string>): Map<string, string>;
120
+ export interface TranslatedMethod {
121
+ name: string;
122
+ /** Parameter source texts (react mode), e.g. `step: number = 1`. */
123
+ paramTexts: string[];
124
+ /** Parameter bare names (state/preview mode). */
125
+ paramNames: string[];
126
+ /** Body lines at zero indent (statements already end with ';'). */
127
+ lines: string[];
128
+ }
129
+ /** Anything with fields and methods to translate: a component or a service. */
130
+ export interface MethodHost {
131
+ fields: ComponentField[];
132
+ methods: string[];
133
+ methodDetails: ComponentMethod[];
134
+ }
135
+ export interface TranslateOptions {
136
+ /** @Output field name -> callback expression for `.emit(...)` calls. */
137
+ outputCallbacks?: Map<string, string>;
138
+ /** Reactive form fields held in refs in generated code (Stage 8). */
139
+ formFields?: Set<string>;
140
+ }
141
+ /**
142
+ * Translate all methods of a component (or service) in the given mode.
143
+ * Returns the translated methods plus accumulated diagnostics.
144
+ */
145
+ export declare function translateMethods(component: MethodHost, mode: TranslateMode, stateFields: Set<string>, options?: TranslateOptions): {
146
+ methods: TranslatedMethod[];
147
+ diagnostics: Diagnostic[];
148
+ };