@yannosay/sinth 4.0.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.
- package/CHANGELOG.md +83 -0
- package/DOCS.md +1359 -0
- package/README.md +83 -74
- package/bin/sinth.js +2 -1
- package/dist/cli/args.d.ts +11 -0
- package/dist/cli/args.js +74 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +437 -0
- package/dist/cli/templates.d.ts +10 -0
- package/dist/cli/templates.js +193 -0
- package/dist/cli/ui.d.ts +28 -0
- package/dist/cli/ui.js +61 -0
- package/dist/cli/update-check.d.ts +2 -0
- package/dist/cli/update-check.js +124 -0
- package/dist/compiler/ast.d.ts +315 -0
- package/dist/compiler/ast.js +4 -0
- package/dist/compiler/codegen.d.ts +143 -0
- package/dist/compiler/codegen.js +1326 -0
- package/dist/compiler/diagnostics.d.ts +36 -0
- package/dist/compiler/diagnostics.js +142 -0
- package/dist/compiler/elements.d.ts +14 -0
- package/dist/compiler/elements.js +78 -0
- package/dist/compiler/globals.d.ts +2 -0
- package/dist/compiler/globals.js +27 -0
- package/dist/compiler/html.d.ts +37 -0
- package/dist/compiler/html.js +152 -0
- package/dist/compiler/lexer.d.ts +42 -0
- package/dist/compiler/lexer.js +404 -0
- package/dist/compiler/parser.d.ts +95 -0
- package/dist/compiler/parser.js +1374 -0
- package/dist/compiler/prerender.d.ts +72 -0
- package/dist/compiler/prerender.js +910 -0
- package/dist/compiler/script-analysis.d.ts +6 -0
- package/dist/compiler/script-analysis.js +106 -0
- package/dist/compiler/style.d.ts +39 -0
- package/dist/compiler/style.js +463 -0
- package/dist/deploy/cloudflare.d.ts +9 -0
- package/dist/deploy/cloudflare.js +111 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +23 -0
- package/dist/project/build.d.ts +31 -0
- package/dist/project/build.js +425 -0
- package/dist/project/config.d.ts +33 -0
- package/dist/project/config.js +142 -0
- package/dist/project/project.d.ts +74 -0
- package/dist/project/project.js +535 -0
- package/dist/runtime/index.d.ts +68 -0
- package/dist/runtime/index.js +912 -0
- package/dist/server/client.d.ts +1 -0
- package/dist/server/client.js +112 -0
- package/dist/server/dev.d.ts +8 -0
- package/dist/server/dev.js +244 -0
- package/dist/server/preview.d.ts +6 -0
- package/dist/server/preview.js +106 -0
- package/dist/server/static.d.ts +10 -0
- package/dist/server/static.js +136 -0
- package/lib/ui/index.sinth +436 -0
- package/package.json +33 -15
- package/schema/sinth.config.schema.json +54 -0
- package/dist/browser/compile.js +0 -62
- package/dist/cli.js +0 -509
- package/dist/core/builtins.js +0 -117
- package/dist/core/cli-compiler.js +0 -683
- package/dist/core/compiler.js +0 -1428
- package/dist/core/expr.js +0 -125
- package/dist/core/head-builder.js +0 -130
- package/dist/core/lexer.js +0 -414
- package/dist/core/parser.js +0 -1665
- package/dist/core/runtime/custom-element.js +0 -81
- package/dist/core/runtime/functions.js +0 -99
- package/dist/core/runtime/helpers.js +0 -347
- package/dist/core/runtime/render.js +0 -136
- package/dist/core/style-processor.js +0 -317
- package/dist/core/types.js +0 -93
- package/dist/resolver.js +0 -175
- package/dist/server.js +0 -174
- package/dist/update-check.js +0 -109
- package/dist/utils.js +0 -80
package/dist/cli.js
DELETED
|
@@ -1,509 +0,0 @@
|
|
|
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
|
-
const fs = __importStar(require("fs"));
|
|
37
|
-
const path = __importStar(require("path"));
|
|
38
|
-
const https = __importStar(require("https"));
|
|
39
|
-
const child_process_1 = require("child_process");
|
|
40
|
-
const types_1 = require("./core/types");
|
|
41
|
-
const cli_compiler_1 = require("./core/cli-compiler");
|
|
42
|
-
const server_1 = require("./server");
|
|
43
|
-
const readline = __importStar(require("readline"));
|
|
44
|
-
const update_check_1 = require("./update-check");
|
|
45
|
-
function loadConfig(root) {
|
|
46
|
-
const cfgPath = path.join(root, "sinth.config.json");
|
|
47
|
-
if (fs.existsSync(cfgPath)) {
|
|
48
|
-
try {
|
|
49
|
-
return JSON.parse(fs.readFileSync(cfgPath, "utf-8"));
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
types_1.SinthWarning.emit("Could not parse sinth.config.json");
|
|
53
|
-
console.error(e);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return {};
|
|
57
|
-
}
|
|
58
|
-
async function main() {
|
|
59
|
-
const [, , command, ...args] = process.argv;
|
|
60
|
-
const cwd = process.cwd();
|
|
61
|
-
const cfg = loadConfig(cwd);
|
|
62
|
-
const outDirIdx = args.indexOf("--out");
|
|
63
|
-
const outDir = outDirIdx !== -1 ? args[outDirIdx + 1] : cfg.outDir ?? path.join(cwd, "dist");
|
|
64
|
-
const portIdx = args.indexOf("--port");
|
|
65
|
-
const port = portIdx !== -1 ? parseInt(args[portIdx + 1], 10) : cfg.port ?? 3000;
|
|
66
|
-
const minify = args.includes("--prod") || Boolean(cfg.minify);
|
|
67
|
-
const sharedRuntime = args.includes("--shared-runtime") || Boolean(cfg.sharedRuntime);
|
|
68
|
-
const libraryPaths = cfg.libraryPaths ?? [path.join(cwd, "libraries")];
|
|
69
|
-
const flagValues = new Set();
|
|
70
|
-
if (outDirIdx !== -1)
|
|
71
|
-
flagValues.add(args[outDirIdx + 1]);
|
|
72
|
-
if (portIdx !== -1)
|
|
73
|
-
flagValues.add(args[portIdx + 1]);
|
|
74
|
-
const cleanArgs = args.filter(a => !a.startsWith("--") && !flagValues.has(a));
|
|
75
|
-
const opts = { projectRoot: cwd, outDir, libraryPaths, minify, checkOnly: false, sharedRuntime };
|
|
76
|
-
switch (command) {
|
|
77
|
-
case "build": {
|
|
78
|
-
const nonSinth = cleanArgs.filter(a => !a.endsWith(".sinth"));
|
|
79
|
-
const buildStart = Date.now();
|
|
80
|
-
const pkgPath4 = path.join(__dirname, "..", "package.json");
|
|
81
|
-
if (fs.existsSync(pkgPath4)) {
|
|
82
|
-
const pkg4 = JSON.parse(fs.readFileSync(pkgPath4, "utf-8"));
|
|
83
|
-
(0, update_check_1.checkForUpdate)(pkg4.version);
|
|
84
|
-
}
|
|
85
|
-
if (nonSinth.length > 0)
|
|
86
|
-
process.stdout.write(`\u001b[33mSkipping non-.sinth files:\u001b[0m ${nonSinth.join(", ")}\n`);
|
|
87
|
-
const fileArgs = cleanArgs.filter(a => a.endsWith(".sinth"));
|
|
88
|
-
const pages = fileArgs.length > 0
|
|
89
|
-
? fileArgs.map(f => path.resolve(cwd, f)).filter(f => fs.existsSync(f))
|
|
90
|
-
: (0, cli_compiler_1.findSinthPages)(cwd, outDir);
|
|
91
|
-
if (pages.length === 0) {
|
|
92
|
-
process.stdout.write("No .sinth files found.\n");
|
|
93
|
-
process.exit(0);
|
|
94
|
-
}
|
|
95
|
-
let hadError = false, built = 0;
|
|
96
|
-
const sharedRuntimes = [];
|
|
97
|
-
for (const p of pages) {
|
|
98
|
-
try {
|
|
99
|
-
const result = (0, cli_compiler_1.compileFile)(p, opts);
|
|
100
|
-
if (!result)
|
|
101
|
-
continue;
|
|
102
|
-
const html = result.html;
|
|
103
|
-
if (result.shared) {
|
|
104
|
-
sharedRuntimes.push(result.shared);
|
|
105
|
-
}
|
|
106
|
-
const rel = path.relative(cwd, p).replace(/\.sinth$/, ".html");
|
|
107
|
-
const out = path.join(outDir, rel);
|
|
108
|
-
fs.mkdirSync(path.dirname(out), { recursive: true });
|
|
109
|
-
fs.writeFileSync(out, html);
|
|
110
|
-
process.stdout.write(` \u001b[32m✓\u001b[0m ${rel}\n`);
|
|
111
|
-
built++;
|
|
112
|
-
}
|
|
113
|
-
catch (e) {
|
|
114
|
-
process.stderr.write(` \u001b[31m✗\u001b[0m ${path.relative(cwd, p)}\n${e.message}\n`);
|
|
115
|
-
hadError = true;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (sharedRuntimes.length > 0) {
|
|
119
|
-
const combined = sharedRuntimes.join("\n");
|
|
120
|
-
fs.writeFileSync(path.join(outDir, "sinth-runtime.js"), combined);
|
|
121
|
-
process.stdout.write(` \u001b[32m✓\u001b[0m sinth-runtime.js (shared)\n`);
|
|
122
|
-
}
|
|
123
|
-
const assetsIn = path.join(cwd, "assets"), assetsOut = path.join(outDir, "assets");
|
|
124
|
-
if (fs.existsSync(assetsIn)) {
|
|
125
|
-
(0, cli_compiler_1.copyDir)(assetsIn, assetsOut);
|
|
126
|
-
process.stdout.write(` \u001b[32m✓\u001b[0m assets/ → ${path.relative(cwd, assetsOut)}/\n`);
|
|
127
|
-
}
|
|
128
|
-
const libIn = path.join(cwd, "libraries"), libOut = path.join(outDir, "libraries");
|
|
129
|
-
if (fs.existsSync(libIn)) {
|
|
130
|
-
(0, cli_compiler_1.copyDir)(libIn, libOut);
|
|
131
|
-
const libFiles = fs.readdirSync(libOut, { recursive: true });
|
|
132
|
-
for (const f of libFiles) {
|
|
133
|
-
if (f.endsWith(".sinth") || f.endsWith(".html")) {
|
|
134
|
-
try {
|
|
135
|
-
fs.unlinkSync(path.join(libOut, f));
|
|
136
|
-
}
|
|
137
|
-
catch (e) {
|
|
138
|
-
console.warn(`Failed to delete ${f}:`, e);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
process.stdout.write(` \u001b[32m✓\u001b[0m libraries/ → ${path.relative(cwd, libOut)}/\n`);
|
|
143
|
-
}
|
|
144
|
-
const buildTime = ((Date.now() - buildStart) / 1000).toFixed(2);
|
|
145
|
-
process.stdout.write(`\n\u001b[1mBuilt ${built} page(s)\u001b[0m${hadError ? " with errors" : ""} \u001b[2min ${buildTime}s\u001b[0m\n`);
|
|
146
|
-
return process.exit(hadError ? 1 : 0);
|
|
147
|
-
}
|
|
148
|
-
case "dev": {
|
|
149
|
-
const pkgPath3 = path.join(__dirname, "..", "package.json");
|
|
150
|
-
if (fs.existsSync(pkgPath3)) {
|
|
151
|
-
const pkg3 = JSON.parse(fs.readFileSync(pkgPath3, "utf-8"));
|
|
152
|
-
(0, update_check_1.checkForUpdate)(pkg3.version);
|
|
153
|
-
}
|
|
154
|
-
const fileArgs = cleanArgs.filter(a => a.endsWith(".sinth"));
|
|
155
|
-
const files = fileArgs.length > 0
|
|
156
|
-
? fileArgs.map(f => path.resolve(cwd, f)).filter(f => fs.existsSync(f))
|
|
157
|
-
: undefined;
|
|
158
|
-
await (0, server_1.startDevServer)({ ...opts, port, files });
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
case "check": {
|
|
162
|
-
opts.checkOnly = true;
|
|
163
|
-
const pages = (0, cli_compiler_1.findSinthPages)(cwd, outDir);
|
|
164
|
-
let hadError = false;
|
|
165
|
-
for (const p of pages) {
|
|
166
|
-
try {
|
|
167
|
-
(0, cli_compiler_1.compileFile)(p, opts);
|
|
168
|
-
process.stdout.write(` \u001b[32m✓\u001b[0m ${path.relative(cwd, p)}\n`);
|
|
169
|
-
}
|
|
170
|
-
catch (e) {
|
|
171
|
-
process.stderr.write(` \u001b[31m✗\u001b[0m ${path.relative(cwd, p)}\n${e.message}\n`);
|
|
172
|
-
hadError = true;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return process.exit(hadError ? 1 : 0);
|
|
176
|
-
}
|
|
177
|
-
case "update": {
|
|
178
|
-
const pkgPath2 = path.join(__dirname, "..", "package.json");
|
|
179
|
-
const current = fs.existsSync(pkgPath2) ? JSON.parse(fs.readFileSync(pkgPath2, "utf-8")).version : null;
|
|
180
|
-
https.get("https://registry.npmjs.org/@yannosay/sinth/latest", { timeout: 5000 }, (res) => {
|
|
181
|
-
let data = "";
|
|
182
|
-
res.on("data", (chunk) => data += chunk.toString());
|
|
183
|
-
res.on("end", () => {
|
|
184
|
-
try {
|
|
185
|
-
const latest = JSON.parse(data).version;
|
|
186
|
-
if (latest === current) {
|
|
187
|
-
process.stdout.write(`\u001b[32mAlready on latest version: ${current} ✓\u001b[0m\n`);
|
|
188
|
-
}
|
|
189
|
-
else if (latest) {
|
|
190
|
-
process.stdout.write(`\u001b[36mUpdating Sinth ${current} → ${latest}...\u001b[0m\n`);
|
|
191
|
-
(0, child_process_1.execSync)("npm install -g @yannosay/sinth@latest", { stdio: "inherit" });
|
|
192
|
-
process.stdout.write(`\u001b[32m✓ Sinth updated to ${latest}!\u001b[0m\n`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
catch {
|
|
196
|
-
process.stderr.write("\u001b[31mCould not check for updates.\u001b[0m\n");
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}).on("error", () => process.stderr.write("\u001b[31mCould not reach npm registry.\u001b[0m\n"));
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
case "version":
|
|
203
|
-
case "--version":
|
|
204
|
-
case "-v": {
|
|
205
|
-
const pkgPath = path.join(__dirname, "..", "package.json");
|
|
206
|
-
if (fs.existsSync(pkgPath)) {
|
|
207
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
208
|
-
process.stdout.write(`Sinth Compiler v${pkg.version}\n`);
|
|
209
|
-
(0, update_check_1.checkForUpdate)(pkg.version); // fire & forget
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
process.stdout.write("Sinth Compiler v1.0.0\n");
|
|
213
|
-
}
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
case "init": {
|
|
217
|
-
await interactiveInit(cwd);
|
|
218
|
-
process.stdin.destroy();
|
|
219
|
-
return process.exit(0);
|
|
220
|
-
}
|
|
221
|
-
default: {
|
|
222
|
-
let version = "1.0.0";
|
|
223
|
-
const paths = [
|
|
224
|
-
path.resolve(__dirname, "..", "package.json"),
|
|
225
|
-
path.resolve(__dirname, "package.json"),
|
|
226
|
-
path.resolve(process.cwd(), "package.json"),
|
|
227
|
-
path.resolve(process.cwd(), "..", "package.json"),
|
|
228
|
-
];
|
|
229
|
-
for (const p of paths) {
|
|
230
|
-
if (fs.existsSync(p)) {
|
|
231
|
-
try {
|
|
232
|
-
const pkg = JSON.parse(fs.readFileSync(p, "utf-8"));
|
|
233
|
-
version = pkg.version;
|
|
234
|
-
break;
|
|
235
|
-
}
|
|
236
|
-
catch {
|
|
237
|
-
// Ignore - use default version
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
process.stdout.write(`
|
|
242
|
-
\u001b[1mSinth Compiler v${version}\u001b[0m
|
|
243
|
-
|
|
244
|
-
\u001b[1mCommands:\u001b[0m
|
|
245
|
-
sinth build [files] [--out ./dist] [--prod] [--shared-runtime] Compile .sinth pages
|
|
246
|
-
sinth dev [files] [--port 3000] Live-reload dev server
|
|
247
|
-
sinth check Lint without emitting
|
|
248
|
-
sinth init [name] Scaffold a new project
|
|
249
|
-
sinth version Print version
|
|
250
|
-
`);
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
const PRESETS = [
|
|
256
|
-
{ value: "basic", label: "Basic", description: "Single page + component" },
|
|
257
|
-
{ value: "full", label: "Full", description: "Multi-page, components, SCSS demo" },
|
|
258
|
-
{ value: "blank", label: "Blank", description: "Folders + config only" },
|
|
259
|
-
];
|
|
260
|
-
async function interactiveInit(cwd) {
|
|
261
|
-
const rl = readline.createInterface({
|
|
262
|
-
input: process.stdin,
|
|
263
|
-
output: process.stdout,
|
|
264
|
-
terminal: true,
|
|
265
|
-
escapeCodeTimeout: 50,
|
|
266
|
-
});
|
|
267
|
-
process.stdout.write("\u001b[s\u001b[1m\n✨ Welcome to Sinth project setup!\n\n\u001b[0m");
|
|
268
|
-
const rawName = await question(rl, "\u001b[45m\u001b[30m Project name: \u001b[0m ", "my-sinth-project");
|
|
269
|
-
rl.close();
|
|
270
|
-
process.stdin.pause();
|
|
271
|
-
process.stdin.removeAllListeners();
|
|
272
|
-
process.stdin.read();
|
|
273
|
-
process.stdout.write("\n");
|
|
274
|
-
const projectName = rawName.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
|
|
275
|
-
const preset = await select();
|
|
276
|
-
process.stdout.write("\u001b[u\u001b[0J");
|
|
277
|
-
const root = path.resolve(cwd, projectName);
|
|
278
|
-
const start = Date.now();
|
|
279
|
-
scaffoldByPreset(root, projectName, preset);
|
|
280
|
-
const elapsed = ((Date.now() - start) / 1000).toFixed(2);
|
|
281
|
-
process.stdout.write(`
|
|
282
|
-
\u001b[1m✨ Success!\u001b[0m
|
|
283
|
-
|
|
284
|
-
\u001b[45m\u001b[30m Project name: \u001b[0m ${projectName}
|
|
285
|
-
\u001b[43m\u001b[30m Preset: \u001b[0m ${preset}
|
|
286
|
-
\u001b[32m✓ ${projectName} scaffolded at \u001b[4m${projectName}/\u001b[0m\u001b[32m in ${elapsed}s\u001b[0m
|
|
287
|
-
|
|
288
|
-
\u001b[47m\u001b[30m Get started: \u001b[0m
|
|
289
|
-
\u001b[100m\u001b[37m sinth dev \u001b[0m to start dev server.
|
|
290
|
-
`);
|
|
291
|
-
}
|
|
292
|
-
function question(rl, prompt, defaultVal) {
|
|
293
|
-
return new Promise((resolve) => {
|
|
294
|
-
rl.question(prompt, (answer) => {
|
|
295
|
-
resolve(answer.trim() || defaultVal);
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
function select() {
|
|
300
|
-
return new Promise((resolve) => {
|
|
301
|
-
const items = PRESETS;
|
|
302
|
-
let selected = 1;
|
|
303
|
-
const prefix = " ";
|
|
304
|
-
const cursor = "\u001b[36m❯\u001b[0m";
|
|
305
|
-
const empty = " ";
|
|
306
|
-
function render(first = false) {
|
|
307
|
-
if (!first) {
|
|
308
|
-
process.stdout.write(`\u001b[${items.length + 1}A`);
|
|
309
|
-
}
|
|
310
|
-
process.stdout.write(`\u001b[43m\u001b[30m Select preset: \u001b[0m\n`);
|
|
311
|
-
for (let i = 0; i < items.length; i++) {
|
|
312
|
-
const pointer = i === selected ? cursor : empty;
|
|
313
|
-
const isFull = items[i].value === "full";
|
|
314
|
-
let label;
|
|
315
|
-
if (i === selected) {
|
|
316
|
-
label = isFull ? `\u001b[1m\u001b[35m${items[i].label}\u001b[0m` : `\u001b[1m${items[i].label}\u001b[0m`;
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
label = items[i].label;
|
|
320
|
-
}
|
|
321
|
-
const desc = `\u001b[2m- ${items[i].description}\u001b[0m`;
|
|
322
|
-
process.stdout.write(`${prefix}${pointer} ${label} ${desc}\u001b[0K\n`);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
process.stdin.setRawMode(true);
|
|
326
|
-
process.stdin.resume();
|
|
327
|
-
process.stdin.setEncoding("utf8");
|
|
328
|
-
const onData = (key) => {
|
|
329
|
-
const str = key.toString();
|
|
330
|
-
if (str === "\u001b[A") {
|
|
331
|
-
selected = (selected - 1 + items.length) % items.length;
|
|
332
|
-
render();
|
|
333
|
-
}
|
|
334
|
-
else if (str === "\u001b[B") {
|
|
335
|
-
selected = (selected + 1) % items.length;
|
|
336
|
-
render();
|
|
337
|
-
}
|
|
338
|
-
else if (str === "\r" || str === "\n") {
|
|
339
|
-
process.stdin.setRawMode(false);
|
|
340
|
-
process.stdin.removeAllListeners("data");
|
|
341
|
-
process.stdin.resume();
|
|
342
|
-
process.stdout.write(`\u001b[${items.length + 1}A\u001b[0J`);
|
|
343
|
-
resolve(items[selected].value);
|
|
344
|
-
}
|
|
345
|
-
else if (str === "\u0003") {
|
|
346
|
-
process.stdin.setRawMode(false);
|
|
347
|
-
process.stdin.pause();
|
|
348
|
-
process.exit(0);
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
process.stdin.on("data", onData);
|
|
352
|
-
render(true);
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
function scaffoldByPreset(root, name, preset) {
|
|
356
|
-
const dirs = ["pages", "components", "styles", "libraries", "assets"];
|
|
357
|
-
for (const d of dirs)
|
|
358
|
-
fs.mkdirSync(path.join(root, d), { recursive: true });
|
|
359
|
-
fs.writeFileSync(path.join(root, "sinth.config.json"), JSON.stringify({ outDir: "./dist", libraryPaths: ["./libraries"], minify: false }, null, 2));
|
|
360
|
-
fs.writeFileSync(path.join(root, ".gitignore"), "dist/\nnode_modules/\n");
|
|
361
|
-
fs.writeFileSync(path.join(root, "package.json"), JSON.stringify({
|
|
362
|
-
name: name.toLowerCase().replace(/\s+/g, "-"),
|
|
363
|
-
version: "1.0.0",
|
|
364
|
-
scripts: { build: "sinth build", dev: "sinth dev" },
|
|
365
|
-
dependencies: { "sass": "^1.70.0" },
|
|
366
|
-
}, null, 2));
|
|
367
|
-
if (preset === "blank")
|
|
368
|
-
return;
|
|
369
|
-
fs.writeFileSync(path.join(root, "styles", "reset.css"), `*, *::before, *::after { box-sizing: border-box; }\nbody { margin: 0; font-family: system-ui, sans-serif; line-height: 1.6; }\nimg { max-width: 100%; display: block; }\n`);
|
|
370
|
-
fs.writeFileSync(path.join(root, "components", "Navbar.sinth"), `-- Navbar component
|
|
371
|
-
|
|
372
|
-
component Navbar {
|
|
373
|
-
Header {
|
|
374
|
-
Nav {
|
|
375
|
-
Link(href: "/", class: "logo") { "MySite" }
|
|
376
|
-
Div(class: "nav-links") {
|
|
377
|
-
NavLink(href: "/") { "Home" }
|
|
378
|
-
NavLink(href: "/about") { "About" }
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
style {
|
|
384
|
-
header {
|
|
385
|
-
display: "flex"
|
|
386
|
-
alignItems: "center"
|
|
387
|
-
padding: "1rem 2rem"
|
|
388
|
-
backgroundColor: "#1a1a2e"
|
|
389
|
-
color: "white"
|
|
390
|
-
}
|
|
391
|
-
.logo {
|
|
392
|
-
fontSize: "1.5rem"
|
|
393
|
-
fontWeight: "700"
|
|
394
|
-
color: "white"
|
|
395
|
-
textDecoration: "none"
|
|
396
|
-
}
|
|
397
|
-
.nav-links {
|
|
398
|
-
marginLeft: "auto"
|
|
399
|
-
display: "flex"
|
|
400
|
-
gap: "1.5rem"
|
|
401
|
-
}
|
|
402
|
-
.nav-links a {
|
|
403
|
-
color: "rgba(255,255,255,0.8)"
|
|
404
|
-
textDecoration: "none"
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
`);
|
|
409
|
-
if (preset === "basic") {
|
|
410
|
-
fs.writeFileSync(path.join(root, "pages", "index.sinth"), `-- My Sinth Site
|
|
411
|
-
page
|
|
412
|
-
|
|
413
|
-
import "../components/Navbar.sinth"
|
|
414
|
-
import css "../styles/reset.css"
|
|
415
|
-
|
|
416
|
-
title = "My Site"
|
|
417
|
-
fav = "assets/favicon.ico"
|
|
418
|
-
descr = "Built with Sinth."
|
|
419
|
-
|
|
420
|
-
Navbar
|
|
421
|
-
|
|
422
|
-
Main {
|
|
423
|
-
Heading(level: 1) { "Hello, Sinth!" }
|
|
424
|
-
Paragraph { "Edit pages/index.sinth to get started." }
|
|
425
|
-
}
|
|
426
|
-
`);
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
fs.writeFileSync(path.join(root, "pages", "index.sinth"), `-- My Sinth Site
|
|
430
|
-
page
|
|
431
|
-
|
|
432
|
-
import "../components/Navbar.sinth"
|
|
433
|
-
import css "../styles/reset.css"
|
|
434
|
-
|
|
435
|
-
title = "My Site"
|
|
436
|
-
fav = "assets/favicon.ico"
|
|
437
|
-
descr = "Built with Sinth v1.0.0."
|
|
438
|
-
|
|
439
|
-
var int score = 0
|
|
440
|
-
var str message = "Click to begin"
|
|
441
|
-
|
|
442
|
-
Navbar
|
|
443
|
-
|
|
444
|
-
Hero {
|
|
445
|
-
Heading(level: 1) { "Welcome to Sinth" }
|
|
446
|
-
Paragraph { "A declarative, component-based web UI language." }
|
|
447
|
-
Button(onClick: "handleClick") { "Get Started" }
|
|
448
|
-
Paragraph(id: "score-display") { message }
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
Main {
|
|
452
|
-
Section {
|
|
453
|
-
Heading(level: 2) { "Features" }
|
|
454
|
-
CardGrid {
|
|
455
|
-
-- Add Card components here
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
style {
|
|
461
|
-
section.hero {
|
|
462
|
-
padding: "4rem 2rem"
|
|
463
|
-
textAlign: "center"
|
|
464
|
-
backgroundColor: "#f0f4ff"
|
|
465
|
-
}
|
|
466
|
-
main {
|
|
467
|
-
maxWidth: "1100px"
|
|
468
|
-
margin: "0 auto"
|
|
469
|
-
padding: "2rem"
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
script {
|
|
474
|
-
function handleClick() {
|
|
475
|
-
score += 1
|
|
476
|
-
message = "Score: " + score
|
|
477
|
-
sinthRender()
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
`);
|
|
481
|
-
fs.writeFileSync(path.join(root, "components", "Card.sinth"), `-- Card component
|
|
482
|
-
|
|
483
|
-
component Card(title, color = "blue") {
|
|
484
|
-
Div(class: "card") {
|
|
485
|
-
Heading(level: 3) { "$title" }
|
|
486
|
-
Div(class: "card-body") { "$slot" }
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
style {
|
|
490
|
-
.card {
|
|
491
|
-
backgroundColor: "#f7f7f7"
|
|
492
|
-
borderRadius: "1rem"
|
|
493
|
-
padding: "1.5rem"
|
|
494
|
-
marginBottom: "1rem"
|
|
495
|
-
}
|
|
496
|
-
.card:hover {
|
|
497
|
-
boxShadow: "0 4px 16px rgba(0,0,0,0.1)"
|
|
498
|
-
}
|
|
499
|
-
.card-body {
|
|
500
|
-
marginTop: "0.75rem"
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
`);
|
|
505
|
-
}
|
|
506
|
-
main().catch(e => {
|
|
507
|
-
process.stderr.write(`\u001b[31m${e.message}\u001b[0m\n`);
|
|
508
|
-
process.exit(1);
|
|
509
|
-
});
|
package/dist/core/builtins.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VOID_TAGS = exports.BUILTIN_MAP = void 0;
|
|
4
|
-
exports.BUILTIN_MAP = {
|
|
5
|
-
// structural
|
|
6
|
-
Main: { tag: "main" },
|
|
7
|
-
Header: { tag: "header" },
|
|
8
|
-
Footer: { tag: "footer" },
|
|
9
|
-
Nav: { tag: "nav" },
|
|
10
|
-
Section: { tag: "section" },
|
|
11
|
-
Article: { tag: "article" },
|
|
12
|
-
Aside: { tag: "aside" },
|
|
13
|
-
Div: { tag: "div" },
|
|
14
|
-
Span: { tag: "span" },
|
|
15
|
-
Hero: { tag: "section", defaultClass: "hero" },
|
|
16
|
-
Container: { tag: "div", defaultClass: "container" },
|
|
17
|
-
Grid: { tag: "div", defaultClass: "grid" },
|
|
18
|
-
Flex: { tag: "div", defaultClass: "flex" },
|
|
19
|
-
Stack: { tag: "div", defaultClass: "stack" },
|
|
20
|
-
Row: { tag: "div", defaultClass: "row" },
|
|
21
|
-
Column: { tag: "div", defaultClass: "col" },
|
|
22
|
-
CardGrid: { tag: "div", defaultClass: "card-grid" },
|
|
23
|
-
// typography
|
|
24
|
-
Heading: { tag: "h1" },
|
|
25
|
-
SubHeading: { tag: "p", defaultClass: "subheading" },
|
|
26
|
-
Paragraph: { tag: "p" },
|
|
27
|
-
Lead: { tag: "p", defaultClass: "lead" },
|
|
28
|
-
Small: { tag: "small" },
|
|
29
|
-
Strong: { tag: "strong" },
|
|
30
|
-
Em: { tag: "em" },
|
|
31
|
-
Code: { tag: "code" },
|
|
32
|
-
Pre: { tag: "pre" },
|
|
33
|
-
Blockquote: { tag: "blockquote" },
|
|
34
|
-
Mark: { tag: "mark" },
|
|
35
|
-
Label: { tag: "label" },
|
|
36
|
-
Abbr: { tag: "abbr" },
|
|
37
|
-
Del: { tag: "del" },
|
|
38
|
-
Ins: { tag: "ins" },
|
|
39
|
-
Sub: { tag: "sub" },
|
|
40
|
-
Sup: { tag: "sup" },
|
|
41
|
-
Data: { tag: "data" },
|
|
42
|
-
Time: { tag: "time" },
|
|
43
|
-
Bdi: { tag: "bdi" },
|
|
44
|
-
Bdo: { tag: "bdo" },
|
|
45
|
-
Cite: { tag: "cite" },
|
|
46
|
-
Dfn: { tag: "dfn" },
|
|
47
|
-
Kbd: { tag: "kbd" },
|
|
48
|
-
Samp: { tag: "samp" },
|
|
49
|
-
Var: { tag: "var" },
|
|
50
|
-
Address: { tag: "address" },
|
|
51
|
-
Ruby: { tag: "ruby" },
|
|
52
|
-
Rt: { tag: "rt" },
|
|
53
|
-
Rp: { tag: "rp" },
|
|
54
|
-
// interactive
|
|
55
|
-
Button: { tag: "button" },
|
|
56
|
-
Link: { tag: "a" },
|
|
57
|
-
NavLink: { tag: "a" },
|
|
58
|
-
Select: { tag: "select" },
|
|
59
|
-
Form: { tag: "form" },
|
|
60
|
-
Fieldset: { tag: "fieldset" },
|
|
61
|
-
Legend: { tag: "legend" },
|
|
62
|
-
Details: { tag: "details" },
|
|
63
|
-
Summary: { tag: "summary" },
|
|
64
|
-
Dialog: { tag: "dialog" },
|
|
65
|
-
Textarea: { tag: "textarea" },
|
|
66
|
-
Datalist: { tag: "datalist" },
|
|
67
|
-
Optgroup: { tag: "optgroup" },
|
|
68
|
-
Option: { tag: "option" },
|
|
69
|
-
Progress: { tag: "progress" },
|
|
70
|
-
Meter: { tag: "meter" },
|
|
71
|
-
Output: { tag: "output" },
|
|
72
|
-
Map: { tag: "map" },
|
|
73
|
-
// media
|
|
74
|
-
Picture: { tag: "picture" },
|
|
75
|
-
Video: { tag: "video" },
|
|
76
|
-
Audio: { tag: "audio" },
|
|
77
|
-
Figure: { tag: "figure" },
|
|
78
|
-
Figcaption: { tag: "figcaption" },
|
|
79
|
-
Canvas: { tag: "canvas" },
|
|
80
|
-
Svg: { tag: "svg" },
|
|
81
|
-
IFrame: { tag: "iframe" },
|
|
82
|
-
Object: { tag: "object" },
|
|
83
|
-
// void elements
|
|
84
|
-
Img: { tag: "img", voidEl: true },
|
|
85
|
-
Logo: { tag: "img", voidEl: true },
|
|
86
|
-
Input: { tag: "input", voidEl: true },
|
|
87
|
-
Checkbox: { tag: "input", voidEl: true },
|
|
88
|
-
Hr: { tag: "hr", voidEl: true },
|
|
89
|
-
Br: { tag: "br", voidEl: true },
|
|
90
|
-
Wbr: { tag: "wbr", voidEl: true },
|
|
91
|
-
Source: { tag: "source", voidEl: true },
|
|
92
|
-
Embed: { tag: "embed", voidEl: true },
|
|
93
|
-
Col: { tag: "col", voidEl: true },
|
|
94
|
-
Area: { tag: "area", voidEl: true },
|
|
95
|
-
// lists
|
|
96
|
-
Ul: { tag: "ul" }, Ol: { tag: "ol" }, Li: { tag: "li" },
|
|
97
|
-
Dl: { tag: "dl" }, Dt: { tag: "dt" }, Dd: { tag: "dd" },
|
|
98
|
-
// tables
|
|
99
|
-
Table: { tag: "table" },
|
|
100
|
-
Caption: { tag: "caption" },
|
|
101
|
-
Thead: { tag: "thead" },
|
|
102
|
-
Tbody: { tag: "tbody" },
|
|
103
|
-
Tfoot: { tag: "tfoot" },
|
|
104
|
-
Tr: { tag: "tr" },
|
|
105
|
-
Th: { tag: "th" },
|
|
106
|
-
Td: { tag: "td" },
|
|
107
|
-
Colgroup: { tag: "colgroup" },
|
|
108
|
-
// utility
|
|
109
|
-
Template: { tag: "template" },
|
|
110
|
-
Slot: { tag: "slot" },
|
|
111
|
-
NoScript: { tag: "noscript" },
|
|
112
|
-
RawHTML: { tag: "__RAW__" },
|
|
113
|
-
};
|
|
114
|
-
exports.VOID_TAGS = new Set([
|
|
115
|
-
"area", "base", "br", "col", "embed", "hr", "img", "input",
|
|
116
|
-
"link", "meta", "param", "source", "track", "wbr",
|
|
117
|
-
]);
|