@yannosay/sinth 4.1.0 → 5.1.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 (78) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/DOCS.md +1359 -0
  3. package/README.md +83 -74
  4. package/bin/sinth.js +2 -1
  5. package/dist/cli/args.d.ts +11 -0
  6. package/dist/cli/args.js +74 -0
  7. package/dist/cli/index.d.ts +1 -0
  8. package/dist/cli/index.js +437 -0
  9. package/dist/cli/templates.d.ts +10 -0
  10. package/dist/cli/templates.js +193 -0
  11. package/dist/cli/ui.d.ts +28 -0
  12. package/dist/cli/ui.js +61 -0
  13. package/dist/cli/update-check.d.ts +2 -0
  14. package/dist/cli/update-check.js +124 -0
  15. package/dist/compiler/ast.d.ts +315 -0
  16. package/dist/compiler/ast.js +4 -0
  17. package/dist/compiler/codegen.d.ts +143 -0
  18. package/dist/compiler/codegen.js +1326 -0
  19. package/dist/compiler/diagnostics.d.ts +36 -0
  20. package/dist/compiler/diagnostics.js +142 -0
  21. package/dist/compiler/elements.d.ts +14 -0
  22. package/dist/compiler/elements.js +78 -0
  23. package/dist/compiler/globals.d.ts +2 -0
  24. package/dist/compiler/globals.js +27 -0
  25. package/dist/compiler/html.d.ts +37 -0
  26. package/dist/compiler/html.js +152 -0
  27. package/dist/compiler/lexer.d.ts +42 -0
  28. package/dist/compiler/lexer.js +404 -0
  29. package/dist/compiler/parser.d.ts +95 -0
  30. package/dist/compiler/parser.js +1374 -0
  31. package/dist/compiler/prerender.d.ts +72 -0
  32. package/dist/compiler/prerender.js +910 -0
  33. package/dist/compiler/script-analysis.d.ts +6 -0
  34. package/dist/compiler/script-analysis.js +106 -0
  35. package/dist/compiler/style.d.ts +39 -0
  36. package/dist/compiler/style.js +463 -0
  37. package/dist/deploy/cloudflare.d.ts +9 -0
  38. package/dist/deploy/cloudflare.js +111 -0
  39. package/dist/index.d.ts +13 -0
  40. package/dist/index.js +23 -0
  41. package/dist/project/build.d.ts +31 -0
  42. package/dist/project/build.js +425 -0
  43. package/dist/project/config.d.ts +33 -0
  44. package/dist/project/config.js +142 -0
  45. package/dist/project/project.d.ts +74 -0
  46. package/dist/project/project.js +535 -0
  47. package/dist/runtime/index.d.ts +68 -0
  48. package/dist/runtime/index.js +912 -0
  49. package/dist/server/client.d.ts +1 -0
  50. package/dist/server/client.js +112 -0
  51. package/dist/server/dev.d.ts +8 -0
  52. package/dist/server/dev.js +244 -0
  53. package/dist/server/preview.d.ts +6 -0
  54. package/dist/server/preview.js +106 -0
  55. package/dist/server/static.d.ts +10 -0
  56. package/dist/server/static.js +136 -0
  57. package/lib/ui/index.sinth +436 -0
  58. package/package.json +33 -15
  59. package/schema/sinth.config.schema.json +54 -0
  60. package/dist/browser/compile.js +0 -63
  61. package/dist/cli.js +0 -509
  62. package/dist/core/builtins.js +0 -117
  63. package/dist/core/cli-compiler.js +0 -705
  64. package/dist/core/compiler.js +0 -1489
  65. package/dist/core/expr.js +0 -129
  66. package/dist/core/head-builder.js +0 -130
  67. package/dist/core/lexer.js +0 -410
  68. package/dist/core/parser.js +0 -1646
  69. package/dist/core/runtime/custom-element.js +0 -81
  70. package/dist/core/runtime/functions.js +0 -99
  71. package/dist/core/runtime/helpers.js +0 -347
  72. package/dist/core/runtime/render.js +0 -136
  73. package/dist/core/style-processor.js +0 -317
  74. package/dist/core/types.js +0 -93
  75. package/dist/resolver.js +0 -175
  76. package/dist/server.js +0 -174
  77. package/dist/update-check.js +0 -109
  78. package/dist/utils.js +0 -80
package/dist/cli/ui.js ADDED
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.log = exports.colorEnabled = exports.c = void 0;
4
+ exports.brand = brand;
5
+ exports.printDiagnostic = printDiagnostic;
6
+ exports.formatBytes = formatBytes;
7
+ exports.formatMs = formatMs;
8
+ exports.table = table;
9
+ const diagnostics_1 = require("../compiler/diagnostics");
10
+ const enabled = process.stdout.isTTY && !process.env.NO_COLOR && process.env.TERM !== "dumb";
11
+ const wrap = (open, close) => (s) => (enabled ? `\u001b[${open}m${s}\u001b[${close}m` : s);
12
+ exports.c = {
13
+ bold: wrap("1", "22"),
14
+ dim: wrap("2", "22"),
15
+ red: wrap("31", "39"),
16
+ green: wrap("32", "39"),
17
+ yellow: wrap("33", "39"),
18
+ blue: wrap("34", "39"),
19
+ magenta: wrap("35", "39"),
20
+ cyan: wrap("36", "39"),
21
+ gray: wrap("90", "39"),
22
+ violet: (s) => (enabled ? `\u001b[38;2;192;132;252m${s}\u001b[39m` : s),
23
+ underline: wrap("4", "24"),
24
+ };
25
+ exports.colorEnabled = enabled;
26
+ function brand(label, version) {
27
+ return [exports.c.violet(exports.c.bold("Sinth")), label ? exports.c.bold(label) : "", exports.c.gray("v" + version)].filter(Boolean).join(" ");
28
+ }
29
+ exports.log = {
30
+ info: (msg) => console.log(`${exports.c.cyan("•")} ${msg}`),
31
+ success: (msg) => console.log(`${exports.c.green("✓")} ${msg}`),
32
+ warn: (msg) => console.log(`${exports.c.yellow("!")} ${msg}`),
33
+ error: (msg) => console.error(`${exports.c.red("✗")} ${msg}`),
34
+ step: (msg) => console.log(` ${exports.c.gray("›")} ${msg}`),
35
+ blank: () => console.log(),
36
+ };
37
+ function printDiagnostic(d) {
38
+ const text = (0, diagnostics_1.formatDiagnostic)(d, enabled);
39
+ if (d.severity === "error")
40
+ console.error("\n" + text + "\n");
41
+ else
42
+ console.log("\n" + text + "\n");
43
+ }
44
+ function formatBytes(bytes) {
45
+ if (bytes < 1024)
46
+ return `${bytes} B`;
47
+ if (bytes < 1024 * 1024)
48
+ return `${(bytes / 1024).toFixed(1)} kB`;
49
+ return `${(bytes / 1024 / 1024).toFixed(2)} MB`;
50
+ }
51
+ function formatMs(ms) {
52
+ return ms < 1000 ? `${ms}ms` : `${(ms / 1000).toFixed(2)}s`;
53
+ }
54
+ function table(rows, gap = 2) {
55
+ const ansi = new RegExp(String.fromCharCode(27) + "\\[[0-9;]*m", "g");
56
+ const strip = (s) => s.replace(ansi, "");
57
+ const widths = [];
58
+ for (const r of rows)
59
+ r.forEach((cell, i) => (widths[i] = Math.max(widths[i] ?? 0, strip(cell).length)));
60
+ return rows.map(r => r.map((cell, i) => (i === r.length - 1 ? cell : cell + " ".repeat(widths[i] - strip(cell).length + gap))).join("")).join("\n");
61
+ }
@@ -0,0 +1,2 @@
1
+ export declare function isNewer(latest: string, current: string): boolean;
2
+ export declare function startUpdateCheck(current: string): () => string | null;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.isNewer = isNewer;
37
+ exports.startUpdateCheck = startUpdateCheck;
38
+ const fs = __importStar(require("fs"));
39
+ const https = __importStar(require("https"));
40
+ const os = __importStar(require("os"));
41
+ const path = __importStar(require("path"));
42
+ const ui_1 = require("./ui");
43
+ const DAY = 24 * 60 * 60 * 1000;
44
+ function cacheFile() {
45
+ const base = process.env.XDG_CACHE_HOME || (process.platform === "win32" ? process.env.LOCALAPPDATA || os.homedir() : path.join(os.homedir(), ".cache"));
46
+ return path.join(base, "sinth", "update-check.json");
47
+ }
48
+ function parseVersion(v) {
49
+ const [main, pre = ""] = v.replace(/^v/, "").split("-", 2);
50
+ return { nums: main.split(".").map(n => Number(n) || 0), pre };
51
+ }
52
+ function isNewer(latest, current) {
53
+ const a = parseVersion(latest);
54
+ const b = parseVersion(current);
55
+ for (let i = 0; i < 3; i++) {
56
+ if ((a.nums[i] ?? 0) !== (b.nums[i] ?? 0))
57
+ return (a.nums[i] ?? 0) > (b.nums[i] ?? 0);
58
+ }
59
+ if (!a.pre && b.pre)
60
+ return true;
61
+ return false;
62
+ }
63
+ function fetchLatest(timeoutMs) {
64
+ return new Promise(resolve => {
65
+ const req = https.get("https://registry.npmjs.org/@yannosay/sinth/latest", { timeout: timeoutMs, headers: { Accept: "application/json" } }, res => {
66
+ if (res.statusCode !== 200) {
67
+ res.resume();
68
+ resolve(null);
69
+ return;
70
+ }
71
+ let body = "";
72
+ res.setEncoding("utf8");
73
+ res.on("data", (chunk) => {
74
+ body += chunk;
75
+ if (body.length > 1_000_000)
76
+ req.destroy();
77
+ });
78
+ res.on("end", () => {
79
+ try {
80
+ resolve(JSON.parse(body).version ?? null);
81
+ }
82
+ catch {
83
+ resolve(null);
84
+ }
85
+ });
86
+ });
87
+ req.on("socket", socket => socket.unref());
88
+ req.on("timeout", () => req.destroy());
89
+ req.on("error", () => resolve(null));
90
+ });
91
+ }
92
+ function startUpdateCheck(current) {
93
+ let message = null;
94
+ if (process.env.CI || process.env.SINTH_NO_UPDATE_CHECK || !process.stdout.isTTY)
95
+ return () => null;
96
+ const file = cacheFile();
97
+ let cached;
98
+ try {
99
+ cached = JSON.parse(fs.readFileSync(file, "utf-8"));
100
+ }
101
+ catch {
102
+ cached = null;
103
+ }
104
+ const announce = (latest) => {
105
+ if (latest && isNewer(latest, current)) {
106
+ message = `${ui_1.c.yellow("Update available")} ${ui_1.c.gray(current)} → ${ui_1.c.green(latest)} ${ui_1.c.gray("Run")} ${ui_1.c.cyan("npm i -g @yannosay/sinth@latest")}`;
107
+ }
108
+ };
109
+ if (cached && Date.now() - cached.checkedAt < DAY) {
110
+ announce(cached.latest);
111
+ return () => message;
112
+ }
113
+ fetchLatest(1500).then(latest => {
114
+ announce(latest);
115
+ try {
116
+ fs.mkdirSync(path.dirname(file), { recursive: true });
117
+ fs.writeFileSync(file, JSON.stringify({ checkedAt: Date.now(), latest }));
118
+ }
119
+ catch {
120
+ return;
121
+ }
122
+ }, () => undefined);
123
+ return () => message;
124
+ }
@@ -0,0 +1,315 @@
1
+ import { Loc } from "./diagnostics";
2
+ export type BaseType = "str" | "num" | "int" | "bool" | "obj" | "ui" | "any" | "void" | "fn";
3
+ export interface TypeRef {
4
+ base: BaseType;
5
+ array: number;
6
+ nullable: boolean;
7
+ }
8
+ export type LiteralValue = string | number | boolean | null;
9
+ export type Expr = {
10
+ k: "lit";
11
+ value: LiteralValue;
12
+ loc: Loc;
13
+ } | {
14
+ k: "tpl";
15
+ parts: (string | Expr)[];
16
+ loc: Loc;
17
+ } | {
18
+ k: "id";
19
+ name: string;
20
+ loc: Loc;
21
+ } | {
22
+ k: "member";
23
+ object: Expr;
24
+ prop: string;
25
+ optional: boolean;
26
+ loc: Loc;
27
+ } | {
28
+ k: "index";
29
+ object: Expr;
30
+ index: Expr;
31
+ optional: boolean;
32
+ loc: Loc;
33
+ } | {
34
+ k: "call";
35
+ callee: Expr;
36
+ args: Arg[];
37
+ optional: boolean;
38
+ memo: boolean;
39
+ loc: Loc;
40
+ } | {
41
+ k: "new";
42
+ callee: Expr;
43
+ args: Arg[];
44
+ loc: Loc;
45
+ } | {
46
+ k: "unary";
47
+ op: "!" | "-" | "+" | "~" | "typeof" | "await";
48
+ arg: Expr;
49
+ loc: Loc;
50
+ } | {
51
+ k: "binary";
52
+ op: BinaryOp;
53
+ left: Expr;
54
+ right: Expr;
55
+ loc: Loc;
56
+ } | {
57
+ k: "cond";
58
+ test: Expr;
59
+ then: Expr;
60
+ else: Expr;
61
+ loc: Loc;
62
+ } | {
63
+ k: "assign";
64
+ op: AssignOp;
65
+ target: Expr;
66
+ value: Expr;
67
+ loc: Loc;
68
+ } | {
69
+ k: "update";
70
+ op: "++";
71
+ prefix: boolean;
72
+ target: Expr;
73
+ loc: Loc;
74
+ } | {
75
+ k: "array";
76
+ items: ArrayItem[];
77
+ loc: Loc;
78
+ } | {
79
+ k: "object";
80
+ props: ObjectProp[];
81
+ loc: Loc;
82
+ } | {
83
+ k: "arrow";
84
+ params: Param[];
85
+ body: Expr | Stmt[];
86
+ async: boolean;
87
+ loc: Loc;
88
+ } | {
89
+ k: "range";
90
+ args: Expr[];
91
+ loc: Loc;
92
+ };
93
+ export type BinaryOp = "+" | "-" | "*" | "/" | "%" | "**" | "==" | "!=" | "<" | ">" | "<=" | ">=" | "&&" | "||" | "??";
94
+ export type AssignOp = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "??=" | "&&=" | "||=";
95
+ export interface Arg {
96
+ name?: string;
97
+ value: Expr;
98
+ spread: boolean;
99
+ loc: Loc;
100
+ }
101
+ export interface ArrayItem {
102
+ value: Expr;
103
+ spread: boolean;
104
+ }
105
+ export interface ObjectProp {
106
+ key: string;
107
+ computedKey?: Expr;
108
+ value: Expr;
109
+ spread: boolean;
110
+ loc: Loc;
111
+ }
112
+ export interface Param {
113
+ name: string;
114
+ type?: TypeRef;
115
+ defaultValue?: Expr;
116
+ optional: boolean;
117
+ rest: boolean;
118
+ bindable?: boolean;
119
+ loc: Loc;
120
+ }
121
+ export interface VarDecl {
122
+ kind: "var" | "const" | "computed";
123
+ name: string;
124
+ type?: TypeRef;
125
+ init?: Expr;
126
+ persist: boolean;
127
+ loc: Loc;
128
+ }
129
+ export type Stmt = {
130
+ k: "expr";
131
+ expr: Expr;
132
+ loc: Loc;
133
+ } | {
134
+ k: "var";
135
+ decl: VarDecl;
136
+ loc: Loc;
137
+ } | {
138
+ k: "if";
139
+ test: Expr;
140
+ then: Stmt[];
141
+ else?: Stmt[];
142
+ loc: Loc;
143
+ } | {
144
+ k: "for";
145
+ names: string[];
146
+ iter: Expr;
147
+ filter?: Expr;
148
+ body: Stmt[];
149
+ loc: Loc;
150
+ } | {
151
+ k: "while";
152
+ test: Expr;
153
+ body: Stmt[];
154
+ loc: Loc;
155
+ } | {
156
+ k: "return";
157
+ value?: Expr;
158
+ loc: Loc;
159
+ } | {
160
+ k: "break";
161
+ loc: Loc;
162
+ } | {
163
+ k: "continue";
164
+ loc: Loc;
165
+ };
166
+ export interface Attr {
167
+ name: string;
168
+ modifiers: string[];
169
+ value: Expr | null;
170
+ handler?: Stmt[];
171
+ loc: Loc;
172
+ }
173
+ export type Node = ElementNode | {
174
+ k: "text";
175
+ expr: Expr;
176
+ loc: Loc;
177
+ } | IfNode | ForNode | {
178
+ k: "slot";
179
+ name: string;
180
+ fallback: Node[];
181
+ loc: Loc;
182
+ } | {
183
+ k: "stmt";
184
+ stmt: Stmt;
185
+ loc: Loc;
186
+ } | {
187
+ k: "var";
188
+ decl: VarDecl;
189
+ loc: Loc;
190
+ };
191
+ export interface ElementNode {
192
+ k: "element";
193
+ name: string;
194
+ attrs: Attr[];
195
+ children: Node[];
196
+ slots: SlotFill[];
197
+ hasBody: boolean;
198
+ loc: Loc;
199
+ }
200
+ export interface SlotFill {
201
+ name: string;
202
+ children: Node[];
203
+ loc: Loc;
204
+ }
205
+ export interface IfBranch {
206
+ test?: Expr;
207
+ body: Node[];
208
+ loc: Loc;
209
+ }
210
+ export interface IfNode {
211
+ k: "if";
212
+ branches: IfBranch[];
213
+ persist: boolean;
214
+ delay?: Expr;
215
+ transition?: string;
216
+ loc: Loc;
217
+ }
218
+ export interface ForNode {
219
+ k: "for";
220
+ names: string[];
221
+ iter: Expr;
222
+ keyExpr?: Expr;
223
+ filter?: Expr;
224
+ body: Node[];
225
+ empty?: Node[];
226
+ loc: Loc;
227
+ }
228
+ export interface StyleBlock {
229
+ global: boolean;
230
+ lang: "sinth" | "css" | "scss";
231
+ raw: string;
232
+ loc: Loc;
233
+ }
234
+ export interface ScriptBlock {
235
+ raw: string;
236
+ attrs: Record<string, string>;
237
+ loc: Loc;
238
+ }
239
+ export interface FunctionDecl {
240
+ name: string;
241
+ params: Param[];
242
+ returnType?: TypeRef;
243
+ body: Stmt[];
244
+ view?: Node[];
245
+ async: boolean;
246
+ loc: Loc;
247
+ }
248
+ export interface Lifecycle {
249
+ kind: "mount" | "destroy";
250
+ body: Stmt[];
251
+ loc: Loc;
252
+ }
253
+ export interface Watcher {
254
+ expr: Expr;
255
+ body: Stmt[];
256
+ loc: Loc;
257
+ }
258
+ export interface ComponentDecl {
259
+ name: string;
260
+ params: Param[];
261
+ vars: VarDecl[];
262
+ functions: FunctionDecl[];
263
+ body: Node[];
264
+ styles: StyleBlock[];
265
+ scripts: ScriptBlock[];
266
+ lifecycle: Lifecycle[];
267
+ watchers: Watcher[];
268
+ customTag?: string;
269
+ exported: boolean;
270
+ file: string;
271
+ loc: Loc;
272
+ }
273
+ export type ImportKind = "sinth" | "style" | "module" | "script" | "font" | "json" | "library";
274
+ export interface ImportSpecifier {
275
+ name: string;
276
+ alias: string;
277
+ loc: Loc;
278
+ }
279
+ export interface ImportDecl {
280
+ kind: ImportKind;
281
+ source: string;
282
+ defaultName?: string;
283
+ namespace?: string;
284
+ named: ImportSpecifier[];
285
+ attrs: Record<string, string | boolean>;
286
+ sideEffect: boolean;
287
+ loc: Loc;
288
+ }
289
+ export interface MetaEntry {
290
+ key: string;
291
+ value: Expr;
292
+ loc: Loc;
293
+ }
294
+ export interface SinthFile {
295
+ path: string;
296
+ source: string;
297
+ isPage: boolean;
298
+ /** Route parameters from `[name]` segments in the page's path, e.g. `pages/blog/[slug].sinth`. */
299
+ params?: string[];
300
+ imports: ImportDecl[];
301
+ meta: MetaEntry[];
302
+ externs: {
303
+ name: string;
304
+ loc: Loc;
305
+ }[];
306
+ vars: VarDecl[];
307
+ functions: FunctionDecl[];
308
+ components: ComponentDecl[];
309
+ styles: StyleBlock[];
310
+ scripts: ScriptBlock[];
311
+ lifecycle: Lifecycle[];
312
+ watchers: Watcher[];
313
+ body: Node[];
314
+ }
315
+ export declare const TYPE_NAMES: ReadonlySet<string>;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TYPE_NAMES = void 0;
4
+ exports.TYPE_NAMES = new Set(["str", "num", "int", "bool", "obj", "ui", "any", "void", "fn"]);
@@ -0,0 +1,143 @@
1
+ import { Expr, ImportDecl, Param, SinthFile, Stmt, TypeRef, VarDecl } from "./ast";
2
+ import { DiagnosticBag, Loc } from "./diagnostics";
3
+ import { isStatementExpr } from "./parser";
4
+ import { ScssCompiler } from "./style";
5
+ export interface ComponentSig {
6
+ name: string;
7
+ params: Param[];
8
+ customTag?: string;
9
+ }
10
+ export interface FunctionSig {
11
+ name: string;
12
+ params: Param[];
13
+ returnType?: TypeRef;
14
+ ui: boolean;
15
+ }
16
+ export interface VarSig {
17
+ name: string;
18
+ kind: VarDecl["kind"];
19
+ type?: TypeRef;
20
+ }
21
+ export interface ModuleExports {
22
+ components: Map<string, ComponentSig>;
23
+ functions: Map<string, FunctionSig>;
24
+ vars: Map<string, VarSig>;
25
+ defaultComponent?: string;
26
+ }
27
+ export interface ResolvedImport {
28
+ decl: ImportDecl;
29
+ kind: "sinth" | "style" | "module" | "script" | "font" | "json";
30
+ specifier: string;
31
+ exports?: ModuleExports;
32
+ json?: unknown;
33
+ }
34
+ export interface CodegenOptions {
35
+ runtime: string;
36
+ dev: boolean;
37
+ scss?: ScssCompiler;
38
+ persistPrefix: string;
39
+ }
40
+ export interface InteractivityInfo {
41
+ interactive: boolean;
42
+ uses: string[];
43
+ }
44
+ export interface ModuleOutput {
45
+ js: string;
46
+ css: string;
47
+ exports: ModuleExports;
48
+ interactive: boolean;
49
+ base: boolean;
50
+ components: Record<string, InteractivityInfo>;
51
+ page?: InteractivityInfo;
52
+ usesState: boolean;
53
+ diagnostics: DiagnosticBag;
54
+ }
55
+ type BindingKind = "local" | "loop" | "param" | "state" | "computed" | "const" | "function" | "component" | "global" | "import";
56
+ interface Binding {
57
+ kind: BindingKind;
58
+ js: string;
59
+ type?: TypeRef;
60
+ fn?: FunctionSig;
61
+ comp?: ComponentSig;
62
+ defaultValue?: Expr;
63
+ bindable?: boolean;
64
+ ref?: string;
65
+ loc?: Loc;
66
+ }
67
+ declare class Scope {
68
+ readonly parent: Scope | null;
69
+ readonly kind: "module" | "component" | "function" | "block" | "loop";
70
+ private readonly names;
71
+ constructor(parent: Scope | null, kind?: "module" | "component" | "function" | "block" | "loop");
72
+ define(name: string, b: Binding): void;
73
+ has(name: string): boolean;
74
+ lookup(name: string): Binding | undefined;
75
+ all(): string[];
76
+ inComponent(): boolean;
77
+ }
78
+ export declare function collectExports(file: SinthFile): ModuleExports;
79
+ export declare class ModuleCompiler {
80
+ private readonly file;
81
+ private readonly imports;
82
+ private readonly opts;
83
+ private readonly out;
84
+ private readonly css;
85
+ private uid;
86
+ private interactive;
87
+ private uses;
88
+ private readonly componentInfo;
89
+ private usesState;
90
+ readonly diagnostics: DiagnosticBag;
91
+ private readonly moduleScope;
92
+ private readonly importLines;
93
+ private readonly exportsInfo;
94
+ private readonly fileHash;
95
+ private readonly pageCssVars;
96
+ constructor(file: SinthFile, imports: ResolvedImport[], opts: CodegenOptions);
97
+ private id;
98
+ private fail;
99
+ compile(): ModuleOutput;
100
+ private persistKey;
101
+ private checkDuplicate;
102
+ private defineComponent;
103
+ private declareImports;
104
+ private resolveNamespacedComponent;
105
+ private genVarDecl;
106
+ private genFunction;
107
+ private genParams;
108
+ private genComponent;
109
+ private genLifecycle;
110
+ private addStyle;
111
+ private genNodes;
112
+ private genNode;
113
+ private genText;
114
+ private genUiCall;
115
+ private isConstantExpr;
116
+ private isStaticNode;
117
+ private staticHtml;
118
+ private headingTag;
119
+ private elementShape;
120
+ private isStyleProp;
121
+ private genElement;
122
+ private genRawHtml;
123
+ private genDynamicAttrs;
124
+ private genHandler;
125
+ private genComponentUse;
126
+ private genIf;
127
+ private genFor;
128
+ private stmts;
129
+ private stmt;
130
+ private calleeBinding;
131
+ private unknownName;
132
+ private resolveId;
133
+ private bindingJs;
134
+ private assignTarget;
135
+ private genCallArgs;
136
+ expr(e: Expr, scope: Scope): string;
137
+ private checkBinary;
138
+ inferType(e: Expr, scope: Scope): TypeRef | undefined;
139
+ private checkAssignable;
140
+ }
141
+ export declare function containsAwait(stmts: Stmt[]): boolean;
142
+ export declare function compileModule(file: SinthFile, imports: ResolvedImport[], opts: CodegenOptions): ModuleOutput;
143
+ export { isStatementExpr };