juxscript 1.0.19 ā 1.0.21
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 +121 -72
- package/lib/components/alert.ts +212 -165
- package/lib/components/badge.ts +93 -103
- package/lib/components/base/BaseComponent.ts +397 -0
- package/lib/components/base/FormInput.ts +322 -0
- package/lib/components/button.ts +63 -122
- package/lib/components/card.ts +109 -155
- package/lib/components/charts/areachart.ts +315 -0
- package/lib/components/charts/barchart.ts +421 -0
- package/lib/components/charts/doughnutchart.ts +263 -0
- package/lib/components/charts/lib/BaseChart.ts +402 -0
- package/lib/components/charts/lib/chart-types.ts +159 -0
- package/lib/components/charts/lib/chart-utils.ts +160 -0
- package/lib/components/charts/lib/chart.ts +707 -0
- package/lib/components/checkbox.ts +264 -127
- package/lib/components/code.ts +75 -108
- package/lib/components/container.ts +113 -130
- package/lib/components/data.ts +37 -5
- package/lib/components/datepicker.ts +195 -147
- package/lib/components/dialog.ts +187 -157
- package/lib/components/divider.ts +85 -191
- package/lib/components/docs-data.json +544 -2027
- package/lib/components/dropdown.ts +178 -136
- package/lib/components/element.ts +227 -171
- package/lib/components/fileupload.ts +285 -228
- package/lib/components/guard.ts +92 -0
- package/lib/components/heading.ts +46 -69
- package/lib/components/helpers.ts +13 -6
- package/lib/components/hero.ts +107 -95
- package/lib/components/icon.ts +160 -0
- package/lib/components/icons.ts +175 -0
- package/lib/components/include.ts +153 -5
- package/lib/components/input.ts +174 -374
- package/lib/components/kpicard.ts +16 -16
- package/lib/components/list.ts +378 -240
- package/lib/components/loading.ts +142 -211
- package/lib/components/menu.ts +103 -97
- package/lib/components/modal.ts +138 -144
- package/lib/components/nav.ts +169 -90
- package/lib/components/paragraph.ts +49 -150
- package/lib/components/progress.ts +118 -200
- package/lib/components/radio.ts +297 -149
- package/lib/components/script.ts +19 -87
- package/lib/components/select.ts +184 -186
- package/lib/components/sidebar.ts +152 -140
- package/lib/components/style.ts +19 -82
- package/lib/components/switch.ts +258 -188
- package/lib/components/table.ts +1117 -170
- package/lib/components/tabs.ts +162 -145
- package/lib/components/theme-toggle.ts +108 -169
- package/lib/components/tooltip.ts +86 -157
- package/lib/components/write.ts +108 -127
- package/lib/jux.ts +86 -41
- package/machinery/build.js +466 -0
- package/machinery/compiler.js +354 -105
- package/machinery/server.js +23 -100
- package/machinery/watcher.js +153 -130
- package/package.json +1 -2
- package/presets/base.css +1166 -0
- package/presets/notion.css +2 -1975
- package/lib/adapters/base-adapter.js +0 -35
- package/lib/adapters/index.js +0 -33
- package/lib/adapters/mysql-adapter.js +0 -65
- package/lib/adapters/postgres-adapter.js +0 -70
- package/lib/adapters/sqlite-adapter.js +0 -56
- package/lib/components/areachart.ts +0 -1246
- package/lib/components/areachartsmooth.ts +0 -1380
- package/lib/components/barchart.ts +0 -1250
- package/lib/components/chart.ts +0 -127
- package/lib/components/doughnutchart.ts +0 -1191
- package/lib/components/footer.ts +0 -165
- package/lib/components/header.ts +0 -187
- package/lib/components/layout.ts +0 -239
- package/lib/components/main.ts +0 -137
- package/lib/layouts/default.jux +0 -8
- package/lib/layouts/figma.jux +0 -0
- /package/lib/{themes ā components/charts/lib}/charts.js +0 -0
package/machinery/watcher.js
CHANGED
|
@@ -1,148 +1,171 @@
|
|
|
1
|
-
import chokidar from 'chokidar';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { compileJuxFile, copyLibToOutput } from './compiler.js';
|
|
4
1
|
import fs from 'fs';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// Manually find all files to watch
|
|
13
|
-
console.log('\nš Finding files to watch...');
|
|
14
|
-
|
|
15
|
-
// Project .jux files
|
|
16
|
-
const juxFiles = glob.sync('**/*.jux', {
|
|
17
|
-
cwd: projectRoot,
|
|
18
|
-
ignore: ['node_modules/**', 'dist/**', '.git/**'],
|
|
19
|
-
absolute: true
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// Vendor layout .jux files
|
|
23
|
-
const libRoot = path.resolve(projectRoot, '../lib');
|
|
24
|
-
const vendorJuxFiles = glob.sync('layouts/**/*.jux', {
|
|
25
|
-
cwd: libRoot,
|
|
26
|
-
absolute: true
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const cssFiles = glob.sync('**/*.css', {
|
|
30
|
-
cwd: projectRoot,
|
|
31
|
-
ignore: ['node_modules/**', 'dist/**', '.git/**'],
|
|
32
|
-
absolute: true
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const libFiles = glob.sync('**/*.{ts,js,css}', {
|
|
36
|
-
cwd: libRoot,
|
|
37
|
-
absolute: true
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const machineryFiles = glob.sync('machinery/**/*.js', {
|
|
41
|
-
cwd: path.resolve(projectRoot, '..'),
|
|
42
|
-
absolute: true
|
|
43
|
-
});
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import {
|
|
4
|
+
copyLibToOutput,
|
|
5
|
+
bundleJuxFilesToRouter,
|
|
6
|
+
generateIndexHtml
|
|
7
|
+
} from './compiler.js';
|
|
44
8
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
console.error('ā No files found to watch!');
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
9
|
+
let isRebuilding = false;
|
|
10
|
+
let rebuildQueued = false;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Find all .jux files in a directory
|
|
14
|
+
*/
|
|
15
|
+
function findJuxFiles(dir, fileList = []) {
|
|
16
|
+
if (!fs.existsSync(dir)) return fileList;
|
|
17
|
+
|
|
18
|
+
const files = fs.readdirSync(dir);
|
|
58
19
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
20
|
+
files.forEach(file => {
|
|
21
|
+
const filePath = path.join(dir, file);
|
|
22
|
+
const stat = fs.statSync(filePath);
|
|
23
|
+
|
|
24
|
+
if (stat.isDirectory()) {
|
|
25
|
+
if (file !== 'node_modules' && file !== 'jux-dist' && file !== '.git' && file !== 'server') {
|
|
26
|
+
findJuxFiles(filePath, fileList);
|
|
27
|
+
}
|
|
28
|
+
} else if (file.endsWith('.jux')) {
|
|
29
|
+
fileList.push(filePath);
|
|
66
30
|
}
|
|
67
31
|
});
|
|
68
32
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
33
|
+
return fileList;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Full rebuild of the entire bundle
|
|
38
|
+
*/
|
|
39
|
+
async function fullRebuild(juxSource, distDir) {
|
|
40
|
+
const startTime = performance.now(); // ā
Start timing
|
|
41
|
+
console.log('\nš Rebuilding bundle...');
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
// Find all .jux files
|
|
45
|
+
const projectJuxFiles = findJuxFiles(juxSource);
|
|
46
|
+
console.log(` Found ${projectJuxFiles.length} .jux file(s)`);
|
|
47
|
+
|
|
48
|
+
// ā
Time the bundling step
|
|
49
|
+
const bundleStartTime = performance.now();
|
|
50
|
+
|
|
51
|
+
// Bundle all files
|
|
52
|
+
const mainJsFilename = await bundleJuxFilesToRouter(juxSource, distDir, {
|
|
53
|
+
routePrefix: ''
|
|
74
54
|
});
|
|
75
|
-
console.log('');
|
|
76
|
-
});
|
|
77
55
|
|
|
78
|
-
|
|
79
|
-
const relativePath = path.relative(path.resolve(projectRoot, '..'), filePath);
|
|
80
|
-
console.log(`\nš Changed: ${relativePath}`);
|
|
81
|
-
|
|
82
|
-
try {
|
|
83
|
-
if (filePath.endsWith('.jux')) {
|
|
84
|
-
console.log(' ā Compiling .jux file...');
|
|
85
|
-
|
|
86
|
-
// Determine if it's a vendor or project file
|
|
87
|
-
if (filePath.includes('/lib/layouts/')) {
|
|
88
|
-
// Vendor layout file
|
|
89
|
-
await compileJuxFile(filePath, {
|
|
90
|
-
distDir: path.join(distDir, 'lib'),
|
|
91
|
-
projectRoot: libRoot,
|
|
92
|
-
isServe: true
|
|
93
|
-
});
|
|
94
|
-
} else {
|
|
95
|
-
// Project file
|
|
96
|
-
await compileJuxFile(filePath, { distDir, projectRoot, isServe: true });
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
console.log(`ā
Recompiled: ${relativePath}`);
|
|
100
|
-
} else if (filePath.includes('/lib/')) {
|
|
101
|
-
console.log(' ā Rebuilding lib files...');
|
|
102
|
-
await copyLibToOutput(projectRoot, distDir);
|
|
103
|
-
console.log(`ā
Rebuilt lib files`);
|
|
104
|
-
} else if (filePath.endsWith('.css')) {
|
|
105
|
-
console.log(' ā CSS file changed');
|
|
106
|
-
console.log(`ā
CSS change detected`);
|
|
107
|
-
} else if (filePath.includes('/machinery/')) {
|
|
108
|
-
console.log(' ā Machinery file changed');
|
|
109
|
-
console.log(`ā ļø Restart server to apply changes`);
|
|
110
|
-
}
|
|
56
|
+
const bundleTime = performance.now() - bundleStartTime;
|
|
111
57
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
} catch (err) {
|
|
115
|
-
console.error(`ā Error processing ${relativePath}:`, err.message);
|
|
116
|
-
console.error(err.stack);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
58
|
+
// ā
Time the route generation step
|
|
59
|
+
const routeStartTime = performance.now();
|
|
119
60
|
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
61
|
+
// Generate routes for index.html
|
|
62
|
+
const routes = projectJuxFiles.map(juxFile => {
|
|
63
|
+
const relativePath = path.relative(juxSource, juxFile);
|
|
64
|
+
const parsedPath = path.parse(relativePath);
|
|
124
65
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
});
|
|
66
|
+
const rawFunctionName = parsedPath.dir
|
|
67
|
+
? `${parsedPath.dir.replace(/\//g, '_')}_${parsedPath.name}`
|
|
68
|
+
: parsedPath.name;
|
|
129
69
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
70
|
+
const functionName = rawFunctionName
|
|
71
|
+
.replace(/[-_]/g, ' ')
|
|
72
|
+
.split(' ')
|
|
73
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
74
|
+
.join('');
|
|
133
75
|
|
|
134
|
-
|
|
76
|
+
const routePath = '/' + (parsedPath.dir ? `${parsedPath.dir}/` : '') + parsedPath.name;
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
path: routePath.replace(/\/+/g, '/'),
|
|
80
|
+
functionName
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Generate index.html
|
|
85
|
+
generateIndexHtml(distDir, routes, mainJsFilename);
|
|
86
|
+
|
|
87
|
+
const routeTime = performance.now() - routeStartTime;
|
|
88
|
+
const totalTime = performance.now() - startTime;
|
|
89
|
+
|
|
90
|
+
// ā
Pretty-print timing breakdown
|
|
91
|
+
console.log(`\nā±ļø Rebuild Performance:`);
|
|
92
|
+
console.log(` Bundle generation: ${bundleTime.toFixed(0)}ms`);
|
|
93
|
+
console.log(` Route/index.html: ${routeTime.toFixed(0)}ms`);
|
|
94
|
+
console.log(` āāāāāāāāāāāāāāāāāāāāāāāāāāāā`);
|
|
95
|
+
console.log(` Total rebuild: ${totalTime.toFixed(0)}ms`);
|
|
96
|
+
|
|
97
|
+
// ā
Color-coded performance indicator
|
|
98
|
+
if (totalTime < 100) {
|
|
99
|
+
console.log(` ā
Lightning fast! ā”`);
|
|
100
|
+
} else if (totalTime < 500) {
|
|
101
|
+
console.log(` ā
Fast rebuild`);
|
|
102
|
+
} else if (totalTime < 1000) {
|
|
103
|
+
console.log(` ā ļø Moderate speed`);
|
|
104
|
+
} else {
|
|
105
|
+
console.log(` š Slow rebuild (consider optimizing)`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
console.log(`ā
Bundle rebuilt: ${mainJsFilename}\n`);
|
|
109
|
+
return true;
|
|
110
|
+
|
|
111
|
+
} catch (err) {
|
|
112
|
+
const failTime = performance.now() - startTime;
|
|
113
|
+
console.error(`ā Rebuild failed after ${failTime.toFixed(0)}ms:`, err.message);
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
135
116
|
}
|
|
136
117
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Start watching for file changes and rebuild on change
|
|
120
|
+
*/
|
|
121
|
+
export function startWatcher(juxSource, distDir, wsClients) {
|
|
122
|
+
console.log(`š Watching: ${juxSource}`);
|
|
123
|
+
|
|
124
|
+
const watcher = fs.watch(juxSource, { recursive: true }, async (eventType, filename) => {
|
|
125
|
+
// Ignore non-.jux files and certain patterns
|
|
126
|
+
if (!filename ||
|
|
127
|
+
!filename.endsWith('.jux') ||
|
|
128
|
+
filename.includes('node_modules') ||
|
|
129
|
+
filename.includes('jux-dist') ||
|
|
130
|
+
filename.startsWith('.')) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Debounce: If already rebuilding, queue another rebuild
|
|
135
|
+
if (isRebuilding) {
|
|
136
|
+
rebuildQueued = true;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
isRebuilding = true;
|
|
141
|
+
console.log(`\nš File changed: ${filename}`);
|
|
142
|
+
|
|
143
|
+
// Rebuild the entire bundle
|
|
144
|
+
const success = await fullRebuild(juxSource, distDir);
|
|
145
|
+
|
|
146
|
+
isRebuilding = false;
|
|
147
|
+
|
|
148
|
+
// Notify all WebSocket clients to reload
|
|
149
|
+
if (success && wsClients && wsClients.length > 0) {
|
|
150
|
+
console.log(`š Notifying ${wsClients.length} client(s) to reload`);
|
|
151
|
+
|
|
152
|
+
// ā
Add small delay to ensure file is fully written
|
|
153
|
+
setTimeout(() => {
|
|
154
|
+
wsClients.forEach(client => {
|
|
155
|
+
if (client.readyState === 1) { // OPEN
|
|
156
|
+
client.send(JSON.stringify({ type: 'reload' }));
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}, 100);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Process queued rebuild if needed
|
|
163
|
+
if (rebuildQueued) {
|
|
164
|
+
rebuildQueued = false;
|
|
165
|
+
console.log('š Processing queued rebuild...');
|
|
166
|
+
setTimeout(() => watcher.emit('change', 'change', filename), 500);
|
|
143
167
|
}
|
|
144
168
|
});
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
169
|
+
|
|
170
|
+
return watcher;
|
|
148
171
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "juxscript",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A JavaScript UX authorship platform",
|
|
6
6
|
"main": "lib/jux.js",
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
"esbuild": "^0.19.0",
|
|
56
56
|
"express": "^4.18.2",
|
|
57
57
|
"glob": "^13.0.0",
|
|
58
|
-
"sql.js": "^1.8.0",
|
|
59
58
|
"ws": "^8.13.0"
|
|
60
59
|
},
|
|
61
60
|
"devDependencies": {
|