@rangular-framework/compiler 0.0.0-stage → 1.0.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.
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,42 @@
1
+ /**
2
+ * Source maps (Stage 5, M7): a small hand-written base64 VLQ encoder and
3
+ * a mappings builder, no dependencies. Granularity is deliberately block
4
+ * level in v1: the generated component function start maps back to the
5
+ * class declaration in the .ts file, and each top level template
6
+ * element's generated JSX start maps back to that element's position in
7
+ * the template file. Per-expression mappings are post-v1.
8
+ */
9
+ export interface SourceSegment {
10
+ /** 0-based line in the generated file. */
11
+ generatedLine: number;
12
+ /** 0-based column in the generated file. */
13
+ generatedColumn: number;
14
+ /** Index into the sources array. */
15
+ sourceIndex: number;
16
+ /** 0-based line in the source file. */
17
+ sourceLine: number;
18
+ /** 0-based column in the source file. */
19
+ sourceColumn: number;
20
+ }
21
+ export interface SourceMapV3 {
22
+ version: 3;
23
+ file?: string;
24
+ sources: string[];
25
+ sourcesContent?: (string | null)[];
26
+ names: string[];
27
+ mappings: string;
28
+ }
29
+ /** Encode one signed integer as base64 VLQ. */
30
+ export declare function encodeVlq(value: number): string;
31
+ /**
32
+ * Build the mappings string from raw segments. Segments are sorted by
33
+ * generated position, duplicates at the same generated position are
34
+ * dropped (first wins), and every field is encoded relative to the
35
+ * previous segment, with the generated column resetting per line.
36
+ */
37
+ export declare function buildMappings(segments: SourceSegment[]): string;
38
+ /** Assemble a complete source map v3 object. */
39
+ export declare function makeSourceMap(sources: string[], segments: SourceSegment[], opts?: {
40
+ file?: string;
41
+ sourcesContent?: (string | null)[];
42
+ }): SourceMapV3;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ /**
3
+ * Source maps (Stage 5, M7): a small hand-written base64 VLQ encoder and
4
+ * a mappings builder, no dependencies. Granularity is deliberately block
5
+ * level in v1: the generated component function start maps back to the
6
+ * class declaration in the .ts file, and each top level template
7
+ * element's generated JSX start maps back to that element's position in
8
+ * the template file. Per-expression mappings are post-v1.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.encodeVlq = encodeVlq;
12
+ exports.buildMappings = buildMappings;
13
+ exports.makeSourceMap = makeSourceMap;
14
+ const B64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
15
+ /** Encode one signed integer as base64 VLQ. */
16
+ function encodeVlq(value) {
17
+ let v = value < 0 ? ((-value) << 1) | 1 : value << 1;
18
+ let out = '';
19
+ do {
20
+ let digit = v & 31;
21
+ v >>>= 5;
22
+ if (v > 0)
23
+ digit |= 32; // continuation bit
24
+ out += B64[digit];
25
+ } while (v > 0);
26
+ return out;
27
+ }
28
+ /**
29
+ * Build the mappings string from raw segments. Segments are sorted by
30
+ * generated position, duplicates at the same generated position are
31
+ * dropped (first wins), and every field is encoded relative to the
32
+ * previous segment, with the generated column resetting per line.
33
+ */
34
+ function buildMappings(segments) {
35
+ const sorted = [...segments].sort((a, b) => a.generatedLine - b.generatedLine || a.generatedColumn - b.generatedColumn);
36
+ const lines = [];
37
+ let prevSource = 0;
38
+ let prevSourceLine = 0;
39
+ let prevSourceColumn = 0;
40
+ let currentLine = 0;
41
+ let prevGenColumn = 0;
42
+ let lineBuf = '';
43
+ const flush = () => { lines.push(lineBuf); lineBuf = ''; };
44
+ for (const seg of sorted) {
45
+ while (currentLine < seg.generatedLine) {
46
+ flush();
47
+ currentLine++;
48
+ prevGenColumn = 0;
49
+ }
50
+ if (lineBuf)
51
+ lineBuf += ',';
52
+ lineBuf += encodeVlq(seg.generatedColumn - prevGenColumn)
53
+ + encodeVlq(seg.sourceIndex - prevSource)
54
+ + encodeVlq(seg.sourceLine - prevSourceLine)
55
+ + encodeVlq(seg.sourceColumn - prevSourceColumn);
56
+ prevGenColumn = seg.generatedColumn;
57
+ prevSource = seg.sourceIndex;
58
+ prevSourceLine = seg.sourceLine;
59
+ prevSourceColumn = seg.sourceColumn;
60
+ }
61
+ flush();
62
+ return lines.join(';');
63
+ }
64
+ /** Assemble a complete source map v3 object. */
65
+ function makeSourceMap(sources, segments, opts = {}) {
66
+ const map = {
67
+ version: 3,
68
+ sources,
69
+ names: [],
70
+ mappings: buildMappings(segments),
71
+ };
72
+ if (opts.file)
73
+ map.file = opts.file;
74
+ if (opts.sourcesContent)
75
+ map.sourcesContent = opts.sourcesContent;
76
+ return map;
77
+ }
@@ -0,0 +1,101 @@
1
+ import { ComponentInfo, DirectiveInfo, PipeInfo, ServiceInfo } from './class/parseComponent';
2
+ import { ResolvedRoute } from './class/parseRoutes';
3
+ import { ChildUnitInput } from './codegen/generate';
4
+ import { SourceMapV3 } from './codegen/sourceMap';
5
+ import { Diagnostic } from './diagnostics';
6
+ import { ParsedCss } from './style/css';
7
+ import { TemplateRoot } from './template/ast';
8
+ export interface ResolvedSource {
9
+ source: string;
10
+ /** Canonical key for the resolved file (used for cycle detection). */
11
+ fileName: string;
12
+ }
13
+ export interface CompileOptions {
14
+ tsSource: string;
15
+ fileName?: string;
16
+ /** Inline template content, when the caller already read templateUrl. */
17
+ templateSource?: string;
18
+ /** Resolver for templateUrl / styleUrls, e.g. reading from disk in the CLI. */
19
+ resolveFile?: (relativePath: string) => string | undefined;
20
+ /**
21
+ * Resolver for relative imports (Stage 3): given a specifier like
22
+ * './mail.service' and the importing file's key, return its source.
23
+ * When absent, resolveFile is tried with the specifier and with '.ts'
24
+ * appended, using the specifier itself as the file key.
25
+ */
26
+ resolveImport?: (specifier: string, importerFileName: string) => ResolvedSource | undefined;
27
+ /** Ask codegen for a block level source map (Stage 5). */
28
+ sourceMap?: boolean;
29
+ /**
30
+ * Routes file specifier (Stage 9), resolved like a relative import
31
+ * from the entry file, e.g. './app.routes.ts'. When omitted, the
32
+ * compiler auto-discovers a sibling 'app.routes.ts' next to the entry
33
+ * component: the routes file is read whenever it exists, and required
34
+ * (GEN_ROUTES_MISSING) whenever a template uses <router-outlet> or
35
+ * routerLink, or a component injects Router / ActivatedRoute.
36
+ */
37
+ routesSpecifier?: string;
38
+ /**
39
+ * Project root boundary (security audit, 2026-11-12): when set, every
40
+ * file a compilation resolves (templateUrl, styleUrls, relative
41
+ * imports) must stay inside this directory tree. A path that escapes
42
+ * is refused with a CMP_PATH_ESCAPE error and the file is never used.
43
+ * The CLI sets this to the nearest ancestor of the entry file that
44
+ * holds a package.json, falling back to the entry file's directory.
45
+ * Library callers who omit it keep the previous trusting behaviour.
46
+ * The check applies to absolute file keys; bare in-memory keys are
47
+ * not filesystem paths and are left alone.
48
+ */
49
+ rootDir?: string;
50
+ }
51
+ export interface CompileResult {
52
+ code: string;
53
+ diagnostics: Diagnostic[];
54
+ ast?: TemplateRoot;
55
+ component?: ComponentInfo;
56
+ css?: ParsedCss;
57
+ /** Child components resolved through imports, with parsed templates (M5). */
58
+ children: ChildUnitInput[];
59
+ /** Every @Injectable class resolved through imports (M6). */
60
+ services: ServiceInfo[];
61
+ /** Every custom @Pipe class resolved through imports (Stage 12). */
62
+ pipes: PipeInfo[];
63
+ /** Every attribute @Directive class resolved through imports (Stage 12). */
64
+ directives: DirectiveInfo[];
65
+ /**
66
+ * The resolved route table (Stage 9): the routes file's entries with
67
+ * their component classes resolved against the registry. Empty when
68
+ * the compilation has no routes file.
69
+ */
70
+ routes: ResolvedRoute[];
71
+ /**
72
+ * Every source file this compilation read (Stage 5): the entry .ts, the
73
+ * templates, and every resolved relative import. `rg watch` watches
74
+ * exactly this set and re-resolves it after each compile.
75
+ */
76
+ files: string[];
77
+ /** Block level source map, present only when requested (Stage 5). */
78
+ sourceMap?: SourceMapV3;
79
+ }
80
+ /**
81
+ * Join a templateUrl or styleUrl onto the directory of the file that
82
+ * declares it, with '.' and '..' segments normalised. File keys here are
83
+ * plain strings (absolute paths from the CLI, bare names in tests), so
84
+ * this stays string based and platform neutral.
85
+ */
86
+ export declare function resolveSiblingPath(fromFile: string, rel: string): string;
87
+ /**
88
+ * True when `candidate` is `root` or lives under it. Only absolute keys
89
+ * are judged: a relative or bare key is an in-memory name from a test
90
+ * resolver, not a filesystem path, and is always allowed through (the
91
+ * CLI passes absolute keys, so the boundary is enforced there).
92
+ */
93
+ export declare function isWithinRoot(candidate: string, root: string): boolean;
94
+ /**
95
+ * The full pipeline: class parse -> import registry (Stage 3: child
96
+ * components and services are followed through relative imports) ->
97
+ * template parse -> CSS parse -> code generation. Never throws for bad
98
+ * user input; it reports diagnostics.
99
+ */
100
+ export declare function compileComponent(options: CompileOptions): CompileResult;
101
+ export declare function hasErrors(diagnostics: Diagnostic[]): boolean;