@progalaxyelabs/htms-cli 0.4.3 → 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.
package/bin/htms.js CHANGED
@@ -23,9 +23,12 @@ program
23
23
  // Compile command
24
24
  program
25
25
  .command('compile')
26
- .description('Compile .htms file to TypeScript')
26
+ .description('Compile .htms file to TypeScript or HTML')
27
27
  .argument('<input>', 'Input .htms file')
28
28
  .option('-o, --output <dir>', 'Output directory', 'dist')
29
+ .option('-f, --format <format>', 'Output format: typescript or html', 'typescript')
30
+ .option('-t, --template <file>', 'HTML template file to inject into (only for html format)')
31
+ .option('-s, --split-templates', 'Split templates into separate files for lazy loading (only for html format)')
29
32
  .option('-w, --watch', 'Watch for changes')
30
33
  .option('-q, --quiet', 'Suppress output')
31
34
  .action(async (input, options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progalaxyelabs/htms-cli",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "CLI for HTMS compiler",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,7 +22,7 @@
22
22
  "author": "ProGalaxy eLabs <info@progalaxyelabs.com>",
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@progalaxyelabs/htms-compiler": "^0.4.2",
25
+ "@progalaxyelabs/htms-compiler": "^0.5.0",
26
26
  "chokidar": "^3.5.0",
27
27
  "commander": "^11.0.0",
28
28
  "picocolors": "^1.0.0"
package/src/compiler.js CHANGED
@@ -1,4 +1,4 @@
1
- import { compile_wasm, init } from '@progalaxyelabs/htms-compiler';
1
+ import { compile_wasm, compile_with_options_wasm, init } from '@progalaxyelabs/htms-compiler';
2
2
  import { readFile, writeFile, mkdir } from 'fs/promises';
3
3
  import { dirname, join, basename } from 'path';
4
4
  import { printDiagnostics } from './format-errors.js';
@@ -14,7 +14,7 @@ async function ensureWasmInit() {
14
14
  }
15
15
 
16
16
  /**
17
- * Compile HTMS file to TypeScript
17
+ * Compile HTMS file to TypeScript or HTML
18
18
  * @param {string} inputPath - Path to .htms file
19
19
  * @param {string} outputDir - Output directory for generated files
20
20
  * @param {object} options - Compilation options
@@ -26,8 +26,27 @@ export async function compileFile(inputPath, outputDir, options = {}) {
26
26
  // Read source file
27
27
  const source = await readFile(inputPath, 'utf-8');
28
28
 
29
+ // Read template file if provided
30
+ let templateHtml = undefined;
31
+ if (options.template) {
32
+ templateHtml = await readFile(options.template, 'utf-8');
33
+ }
34
+
35
+ // Get source filename for HTML output (e.g., "app.htms" -> "app.html")
36
+ const sourceFilename = basename(inputPath, '.htms') + '.html';
37
+
38
+ // Prepare compile options
39
+ const compileOptions = {
40
+ output_format: options.format || 'typescript',
41
+ generate_router: true,
42
+ generate_events: true,
43
+ template_html: templateHtml,
44
+ source_filename: sourceFilename,
45
+ split_templates: options.splitTemplates || false,
46
+ };
47
+
29
48
  // Compile using WASM
30
- const result = compile_wasm(source);
49
+ const result = compile_with_options_wasm(source, compileOptions);
31
50
 
32
51
  // Print diagnostics
33
52
  if (result.diagnostics && result.diagnostics.length > 0) {
Binary file