@sola-air-ui/compiler 1.0.4 → 1.0.6

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/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@sola-air-ui/compiler",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Compiler for Sola single-file components (.sola) — transforms template + script + style to ES modules",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "bin": {
8
- "sola": "./src/cli.js"
8
+ "sola": "src/cli.js"
9
9
  },
10
10
  "exports": {
11
11
  ".": "./src/index.js"
@@ -25,7 +25,7 @@
25
25
  "homepage": "https://sola-air.dev",
26
26
  "repository": {
27
27
  "type": "git",
28
- "url": "https://github.com/rbm3267/sola-air"
28
+ "url": "git+https://github.com/rbm3267/sola-air.git"
29
29
  },
30
30
  "dependencies": {
31
31
  "acorn": "^8.10.0",
package/src/cli.js CHANGED
@@ -4,6 +4,8 @@ import fs from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import { compile } from './index.js';
6
6
 
7
+ const { version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
8
+
7
9
  const args = process.argv.slice(2);
8
10
 
9
11
  if (args.length === 0 || args.includes('-h') || args.includes('--help')) {
@@ -30,7 +32,7 @@ if (args.length === 0 || args.includes('-h') || args.includes('--help')) {
30
32
  }
31
33
 
32
34
  if (args.includes('-v') || args.includes('--version')) {
33
- console.log('Sola Compiler v1.0.3');
35
+ console.log(`Sola Compiler v${version}`);
34
36
  process.exit(0);
35
37
  }
36
38
 
package/src/index.js CHANGED
@@ -1,5 +1,10 @@
1
1
  import * as acorn from 'acorn';
2
2
  import * as htmlparser2 from 'htmlparser2';
3
+ import { readFileSync } from 'node:fs';
4
+
5
+ const { version: COMPILER_VERSION } = JSON.parse(
6
+ readFileSync(new URL('../package.json', import.meta.url), 'utf8')
7
+ );
3
8
 
4
9
  const VOID_ELEMENTS = new Set([
5
10
  'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
@@ -435,7 +440,11 @@ export function compile(source, options = {}) {
435
440
  const id = `e${uid++}`;
436
441
  domCode += ` const ${id} = document.createTextNode('');\n`;
437
442
  domCode += ` ${parentVar}.appendChild(${id});\n`;
438
- domCode += ` createEffect(() => { ${id}.textContent = String(${expr} ?? ''); });\n`;
443
+ // Parenthesize expr before `?? ''`: JS forbids mixing ?? with || or && at the
444
+ // same level without explicit grouping (e.g. `col.label || col ?? ''` is a
445
+ // SyntaxError), and any {a || b}-style fallback expression — an extremely
446
+ // common pattern — would otherwise produce invalid generated code.
447
+ domCode += ` createEffect(() => { ${id}.textContent = String((${expr}) ?? ''); });\n`;
439
448
  return;
440
449
  }
441
450
 
@@ -617,7 +626,7 @@ export function compile(source, options = {}) {
617
626
  // Assemble final output module
618
627
  const CORE_EXPORTS = 'createSignal, createDerived, createEffect, createIntent, createData, onMount, onDestroy, pushContext, popContext, __flush_mounts, __flush_destroys';
619
628
  let output = '';
620
- output += `// Compiled by @sola-air-ui/compiler v1.0.3\n`;
629
+ output += `// Compiled by @sola-air-ui/compiler v${COMPILER_VERSION}\n`;
621
630
 
622
631
  if (target === 'iife') {
623
632
  // ServiceNow / no-bundler mode: pull from window.SolaCore global