juxscript 1.1.71 → 1.1.73

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/cli.js CHANGED
@@ -42,7 +42,6 @@ async function createProject(projectName) {
42
42
  // Fallback: create minimal starter
43
43
  const juxDir = path.join(targetDir, 'jux');
44
44
  fs.mkdirSync(juxDir, { recursive: true });
45
- // Updated to use jux namespace and renderTo
46
45
  fs.writeFileSync(
47
46
  path.join(juxDir, 'index.jux'),
48
47
  `import { jux } from 'juxscript';\n\njux.element('h1', { id: 'welcome' })\n .text('Welcome to JUX!')\n .render('app');\n`
@@ -58,6 +57,15 @@ async function createProject(projectName) {
58
57
  console.log(' ✓ Created juxconfig.js');
59
58
  }
60
59
 
60
+ // ✅ 4. Read config to determine public folder location
61
+ let publicDirName = 'public'; // default
62
+ try {
63
+ const configModule = await import(`file://${configDest}`);
64
+ publicDirName = configModule.config?.directories?.public || 'public';
65
+ } catch (e) {
66
+ // Use default if config can't be read
67
+ }
68
+
61
69
  // 4. Create package.json
62
70
  const pkg = {
63
71
  name: projectName,
@@ -75,14 +83,32 @@ async function createProject(projectName) {
75
83
  fs.writeFileSync(path.join(targetDir, 'package.json'), JSON.stringify(pkg, null, 2));
76
84
  console.log(' ✓ Created package.json');
77
85
 
78
- // 5. Create .gitignore
86
+ // 5. Create public folder with examples
87
+ const publicDir = path.join(targetDir, publicDirName);
88
+ fs.mkdirSync(publicDir, { recursive: true });
89
+
90
+ // Create example favicon
91
+ fs.writeFileSync(
92
+ path.join(publicDir, 'favicon.ico'),
93
+ '' // Empty file placeholder
94
+ );
95
+
96
+ // Create example CSS
97
+ fs.writeFileSync(
98
+ path.join(publicDir, 'styles.css'),
99
+ `/* Custom styles for your JUX app */\nbody {\n margin: 0;\n font-family: system-ui, -apple-system, sans-serif;\n}\n`
100
+ );
101
+
102
+ console.log(` ✓ Created ${publicDirName}/ folder`);
103
+
104
+ // 6. Create .gitignore
79
105
  fs.writeFileSync(
80
106
  path.join(targetDir, '.gitignore'),
81
107
  `.jux-dist/\nnode_modules/\n.DS_Store\n.env\n*.log\n`
82
108
  );
83
109
  console.log(' ✓ Created .gitignore');
84
110
 
85
- // 6. Install dependencies
111
+ // 7. Install dependencies
86
112
  console.log('\n📥 Installing dependencies...\n');
87
113
  try {
88
114
  const { execSync } = await import('child_process');
@@ -104,7 +130,7 @@ async function createProject(projectName) {
104
130
  // COMMAND: init
105
131
  // Initializes JUX in an existing project
106
132
  // ═══════════════════════════════════════════════════════════════
107
- function initProject() {
133
+ async function initProject() {
108
134
  const targetDir = process.cwd();
109
135
 
110
136
  console.log('\n📦 Initializing JUX in current directory\n');
@@ -121,7 +147,6 @@ function initProject() {
121
147
  copyDirRecursive(templateDir, juxDir);
122
148
  console.log(' ✓ Copied template files to ./jux');
123
149
  } else {
124
- // Updated to use jux namespace and renderTo
125
150
  fs.writeFileSync(
126
151
  path.join(juxDir, 'index.jux'),
127
152
  `import { jux } from 'juxscript';\n\njux.element('h1', { id: 'welcome' })\n .text('Welcome to JUX!')\n .render('app');\n`
@@ -160,6 +185,30 @@ function initProject() {
160
185
  }
161
186
  }
162
187
 
188
+ // ✅ 4. Read config to determine public folder location
189
+ let publicDirName = 'public'; // default
190
+ if (fs.existsSync(configDest)) {
191
+ try {
192
+ const configModule = await import(`file://${configDest}`);
193
+ publicDirName = configModule.config?.directories?.public || 'public';
194
+ } catch (e) {
195
+ // Use default if config can't be read
196
+ }
197
+ }
198
+
199
+ // ✅ 5. Create configured public folder
200
+ const publicDir = path.join(targetDir, publicDirName);
201
+ if (!fs.existsSync(publicDir)) {
202
+ fs.mkdirSync(publicDir, { recursive: true });
203
+
204
+ fs.writeFileSync(
205
+ path.join(publicDir, 'styles.css'),
206
+ `/* Custom styles */\nbody { margin: 0; font-family: system-ui; }\n`
207
+ );
208
+
209
+ console.log(` ✓ Created ${publicDirName}/ folder`);
210
+ }
211
+
163
212
  console.log('\n✅ Initialized. Run: npm run dev\n');
164
213
  }
165
214
 
@@ -249,12 +298,12 @@ Options:
249
298
  // ═══════════════════════════════════════════════════════════════
250
299
  switch (command) {
251
300
  case 'create':
252
- createProject(args[0]);
301
+ createProject(args[0]); // ✅ Already async, no await needed at top level
253
302
  break;
254
303
 
255
304
  case 'init':
256
305
  case 'install':
257
- initProject();
306
+ initProject(); // ✅ Already async, no await needed at top level
258
307
  break;
259
308
 
260
309
  case 'build':
@@ -1,5 +1,5 @@
1
1
  {
2
- "totalFiles": 64,
2
+ "totalFiles": 63,
3
3
  "totalClasses": 194,
4
4
  "classList": [
5
5
  "?",
@@ -1023,561 +1023,6 @@
1023
1023
  }
1024
1024
  ]
1025
1025
  },
1026
- {
1027
- "file": "blueprint.ts",
1028
- "path": "blueprint.ts",
1029
- "methods": {
1030
- "_renderHierarchy": [
1031
- "jux-blueprint-class",
1032
- "jux-blueprint-classes",
1033
- "jux-blueprint-hierarchy",
1034
- "jux-blueprint-id",
1035
- "jux-blueprint-line",
1036
- "jux-blueprint-node",
1037
- "jux-blueprint-tag"
1038
- ],
1039
- "_renderComponentCard": [
1040
- "jux-blueprint-badge",
1041
- "jux-blueprint-card",
1042
- "jux-blueprint-card-body",
1043
- "jux-blueprint-card-expanded",
1044
- "jux-blueprint-card-header",
1045
- "jux-blueprint-card-title",
1046
- "jux-blueprint-class-list",
1047
- "jux-blueprint-class-tag",
1048
- "jux-blueprint-section",
1049
- "jux-blueprint-section-title",
1050
- "jux-blueprint-toggle-icon"
1051
- ],
1052
- "render": [
1053
- "jux-blueprint",
1054
- "jux-blueprint-button",
1055
- "jux-blueprint-content",
1056
- "jux-blueprint-controls",
1057
- "jux-blueprint-count",
1058
- "jux-blueprint-empty",
1059
- "jux-blueprint-filter",
1060
- "jux-blueprint-header",
1061
- "jux-blueprint-stats",
1062
- "jux-blueprint-title"
1063
- ],
1064
- "_rebuildContent": [
1065
- "jux-blueprint-empty"
1066
- ]
1067
- },
1068
- "allClasses": [
1069
- "jux-blueprint",
1070
- "jux-blueprint-badge",
1071
- "jux-blueprint-button",
1072
- "jux-blueprint-card",
1073
- "jux-blueprint-card-body",
1074
- "jux-blueprint-card-expanded",
1075
- "jux-blueprint-card-header",
1076
- "jux-blueprint-card-title",
1077
- "jux-blueprint-class",
1078
- "jux-blueprint-class-list",
1079
- "jux-blueprint-class-tag",
1080
- "jux-blueprint-classes",
1081
- "jux-blueprint-content",
1082
- "jux-blueprint-controls",
1083
- "jux-blueprint-count",
1084
- "jux-blueprint-empty",
1085
- "jux-blueprint-filter",
1086
- "jux-blueprint-header",
1087
- "jux-blueprint-hierarchy",
1088
- "jux-blueprint-id",
1089
- "jux-blueprint-line",
1090
- "jux-blueprint-node",
1091
- "jux-blueprint-section",
1092
- "jux-blueprint-section-title",
1093
- "jux-blueprint-stats",
1094
- "jux-blueprint-tag",
1095
- "jux-blueprint-title",
1096
- "jux-blueprint-toggle-icon"
1097
- ],
1098
- "classCount": 28,
1099
- "domStructures": [
1100
- {
1101
- "method": "_renderHierarchy",
1102
- "elements": [
1103
- {
1104
- "tag": "div",
1105
- "classes": [
1106
- "jux-blueprint-hierarchy"
1107
- ],
1108
- "id": null
1109
- },
1110
- {
1111
- "tag": "div",
1112
- "classes": [
1113
- "jux-blueprint-node"
1114
- ],
1115
- "id": null
1116
- },
1117
- {
1118
- "tag": "span",
1119
- "classes": [
1120
- "jux-blueprint-line"
1121
- ],
1122
- "id": null
1123
- },
1124
- {
1125
- "tag": "span",
1126
- "classes": [
1127
- "jux-blueprint-tag"
1128
- ],
1129
- "id": null
1130
- },
1131
- {
1132
- "tag": "span",
1133
- "classes": [
1134
- "jux-blueprint-id"
1135
- ],
1136
- "id": null
1137
- },
1138
- {
1139
- "tag": "span",
1140
- "classes": [
1141
- "jux-blueprint-classes"
1142
- ],
1143
- "id": null
1144
- },
1145
- {
1146
- "tag": "span",
1147
- "classes": [
1148
- "jux-blueprint-class"
1149
- ],
1150
- "id": null
1151
- }
1152
- ],
1153
- "hierarchy": [
1154
- {
1155
- "tag": "div",
1156
- "classes": [
1157
- "jux-blueprint-hierarchy"
1158
- ],
1159
- "id": null,
1160
- "children": [
1161
- {
1162
- "tag": "div",
1163
- "classes": [
1164
- "jux-blueprint-node"
1165
- ],
1166
- "id": null,
1167
- "children": [
1168
- {
1169
- "tag": "span",
1170
- "classes": [
1171
- "jux-blueprint-line"
1172
- ],
1173
- "id": null
1174
- },
1175
- {
1176
- "tag": "span",
1177
- "classes": [
1178
- "jux-blueprint-tag"
1179
- ],
1180
- "id": null
1181
- },
1182
- {
1183
- "tag": "span",
1184
- "classes": [
1185
- "jux-blueprint-id"
1186
- ],
1187
- "id": null
1188
- },
1189
- {
1190
- "tag": "span",
1191
- "classes": [
1192
- "jux-blueprint-classes"
1193
- ],
1194
- "id": null,
1195
- "children": [
1196
- {
1197
- "tag": "span",
1198
- "classes": [
1199
- "jux-blueprint-class"
1200
- ],
1201
- "id": null
1202
- }
1203
- ]
1204
- }
1205
- ]
1206
- }
1207
- ]
1208
- }
1209
- ]
1210
- },
1211
- {
1212
- "method": "_renderComponentCard",
1213
- "elements": [
1214
- {
1215
- "tag": "div",
1216
- "classes": [
1217
- "jux-blueprint-card",
1218
- "jux-blueprint-card-expanded"
1219
- ],
1220
- "id": null
1221
- },
1222
- {
1223
- "tag": "div",
1224
- "classes": [
1225
- "jux-blueprint-card-header"
1226
- ],
1227
- "id": null
1228
- },
1229
- {
1230
- "tag": "h4",
1231
- "classes": [
1232
- "jux-blueprint-card-title"
1233
- ],
1234
- "id": null
1235
- },
1236
- {
1237
- "tag": "span",
1238
- "classes": [
1239
- "jux-blueprint-badge"
1240
- ],
1241
- "id": null
1242
- },
1243
- {
1244
- "tag": "span",
1245
- "classes": [
1246
- "jux-blueprint-toggle-icon"
1247
- ],
1248
- "id": null
1249
- },
1250
- {
1251
- "tag": "div",
1252
- "classes": [
1253
- "jux-blueprint-card-body"
1254
- ],
1255
- "id": null
1256
- },
1257
- {
1258
- "tag": "div",
1259
- "classes": [
1260
- "jux-blueprint-section"
1261
- ],
1262
- "id": null
1263
- },
1264
- {
1265
- "tag": "h5",
1266
- "classes": [
1267
- "jux-blueprint-section-title"
1268
- ],
1269
- "id": null
1270
- },
1271
- {
1272
- "tag": "div",
1273
- "classes": [
1274
- "jux-blueprint-class-list"
1275
- ],
1276
- "id": null
1277
- },
1278
- {
1279
- "tag": "span",
1280
- "classes": [
1281
- "jux-blueprint-class-tag"
1282
- ],
1283
- "id": null
1284
- },
1285
- {
1286
- "tag": "div",
1287
- "classes": [
1288
- "jux-blueprint-section"
1289
- ],
1290
- "id": null
1291
- },
1292
- {
1293
- "tag": "h5",
1294
- "classes": [
1295
- "jux-blueprint-section-title"
1296
- ],
1297
- "id": null
1298
- }
1299
- ],
1300
- "hierarchy": [
1301
- {
1302
- "tag": "div",
1303
- "classes": [
1304
- "jux-blueprint-card",
1305
- "jux-blueprint-card-expanded"
1306
- ],
1307
- "id": null,
1308
- "children": [
1309
- {
1310
- "tag": "div",
1311
- "classes": [
1312
- "jux-blueprint-card-header"
1313
- ],
1314
- "id": null,
1315
- "children": [
1316
- {
1317
- "tag": "h4",
1318
- "classes": [
1319
- "jux-blueprint-card-title"
1320
- ],
1321
- "id": null
1322
- },
1323
- {
1324
- "tag": "span",
1325
- "classes": [
1326
- "jux-blueprint-badge"
1327
- ],
1328
- "id": null
1329
- },
1330
- {
1331
- "tag": "span",
1332
- "classes": [
1333
- "jux-blueprint-toggle-icon"
1334
- ],
1335
- "id": null
1336
- }
1337
- ]
1338
- },
1339
- {
1340
- "tag": "div",
1341
- "classes": [
1342
- "jux-blueprint-card-body"
1343
- ],
1344
- "id": null,
1345
- "children": [
1346
- {
1347
- "tag": "div",
1348
- "classes": [
1349
- "jux-blueprint-section"
1350
- ],
1351
- "id": null,
1352
- "children": [
1353
- {
1354
- "tag": "h5",
1355
- "classes": [
1356
- "jux-blueprint-section-title"
1357
- ],
1358
- "id": null
1359
- },
1360
- {
1361
- "tag": "div",
1362
- "classes": [
1363
- "jux-blueprint-class-list"
1364
- ],
1365
- "id": null,
1366
- "children": [
1367
- {
1368
- "tag": "span",
1369
- "classes": [
1370
- "jux-blueprint-class-tag"
1371
- ],
1372
- "id": null
1373
- }
1374
- ]
1375
- }
1376
- ]
1377
- },
1378
- {
1379
- "tag": "div",
1380
- "classes": [
1381
- "jux-blueprint-section"
1382
- ],
1383
- "id": null,
1384
- "children": [
1385
- {
1386
- "tag": "h5",
1387
- "classes": [
1388
- "jux-blueprint-section-title"
1389
- ],
1390
- "id": null
1391
- }
1392
- ]
1393
- }
1394
- ]
1395
- }
1396
- ]
1397
- }
1398
- ]
1399
- },
1400
- {
1401
- "method": "render",
1402
- "elements": [
1403
- {
1404
- "tag": "div",
1405
- "classes": [
1406
- "jux-blueprint"
1407
- ],
1408
- "id": null
1409
- },
1410
- {
1411
- "tag": "div",
1412
- "classes": [
1413
- "jux-blueprint-header"
1414
- ],
1415
- "id": null
1416
- },
1417
- {
1418
- "tag": "h2",
1419
- "classes": [
1420
- "jux-blueprint-title"
1421
- ],
1422
- "id": null
1423
- },
1424
- {
1425
- "tag": "div",
1426
- "classes": [
1427
- "jux-blueprint-stats"
1428
- ],
1429
- "id": null
1430
- },
1431
- {
1432
- "tag": "div",
1433
- "classes": [
1434
- "jux-blueprint-controls"
1435
- ],
1436
- "id": null
1437
- },
1438
- {
1439
- "tag": "input",
1440
- "classes": [
1441
- "jux-blueprint-filter"
1442
- ],
1443
- "id": null
1444
- },
1445
- {
1446
- "tag": "button",
1447
- "classes": [
1448
- "jux-blueprint-button"
1449
- ],
1450
- "id": null
1451
- },
1452
- {
1453
- "tag": "div",
1454
- "classes": [
1455
- "jux-blueprint-count"
1456
- ],
1457
- "id": null
1458
- },
1459
- {
1460
- "tag": "div",
1461
- "classes": [
1462
- "jux-blueprint-content"
1463
- ],
1464
- "id": null
1465
- },
1466
- {
1467
- "tag": "div",
1468
- "classes": [
1469
- "jux-blueprint-empty"
1470
- ],
1471
- "id": null
1472
- }
1473
- ],
1474
- "hierarchy": [
1475
- {
1476
- "tag": "div",
1477
- "classes": [
1478
- "jux-blueprint"
1479
- ],
1480
- "id": null,
1481
- "orphan": true
1482
- },
1483
- {
1484
- "tag": "div",
1485
- "classes": [
1486
- "jux-blueprint-header"
1487
- ],
1488
- "id": null,
1489
- "orphan": true
1490
- },
1491
- {
1492
- "tag": "h2",
1493
- "classes": [
1494
- "jux-blueprint-title"
1495
- ],
1496
- "id": null,
1497
- "orphan": true
1498
- },
1499
- {
1500
- "tag": "div",
1501
- "classes": [
1502
- "jux-blueprint-stats"
1503
- ],
1504
- "id": null,
1505
- "orphan": true
1506
- },
1507
- {
1508
- "tag": "div",
1509
- "classes": [
1510
- "jux-blueprint-controls"
1511
- ],
1512
- "id": null,
1513
- "orphan": true
1514
- },
1515
- {
1516
- "tag": "input",
1517
- "classes": [
1518
- "jux-blueprint-filter"
1519
- ],
1520
- "id": null,
1521
- "orphan": true
1522
- },
1523
- {
1524
- "tag": "button",
1525
- "classes": [
1526
- "jux-blueprint-button"
1527
- ],
1528
- "id": null,
1529
- "orphan": true
1530
- },
1531
- {
1532
- "tag": "div",
1533
- "classes": [
1534
- "jux-blueprint-count"
1535
- ],
1536
- "id": null,
1537
- "orphan": true
1538
- },
1539
- {
1540
- "tag": "div",
1541
- "classes": [
1542
- "jux-blueprint-content"
1543
- ],
1544
- "id": null,
1545
- "orphan": true
1546
- },
1547
- {
1548
- "tag": "div",
1549
- "classes": [
1550
- "jux-blueprint-empty"
1551
- ],
1552
- "id": null,
1553
- "orphan": true
1554
- }
1555
- ]
1556
- },
1557
- {
1558
- "method": "_rebuildContent",
1559
- "elements": [
1560
- {
1561
- "tag": "div",
1562
- "classes": [
1563
- "jux-blueprint-empty"
1564
- ],
1565
- "id": null
1566
- }
1567
- ],
1568
- "hierarchy": [
1569
- {
1570
- "tag": "div",
1571
- "classes": [
1572
- "jux-blueprint-empty"
1573
- ],
1574
- "id": null,
1575
- "orphan": true
1576
- }
1577
- ]
1578
- }
1579
- ]
1580
- },
1581
1026
  {
1582
1027
  "file": "button.js",
1583
1028
  "path": "button.js",