juxscript 1.1.3 → 1.1.5

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.
Files changed (63) hide show
  1. package/machinery/build3.js +7 -91
  2. package/machinery/compiler3.js +3 -131
  3. package/package.json +19 -5
  4. package/lib/components/alert.ts +0 -200
  5. package/lib/components/app.ts +0 -247
  6. package/lib/components/badge.ts +0 -101
  7. package/lib/components/base/BaseComponent.ts +0 -421
  8. package/lib/components/base/FormInput.ts +0 -227
  9. package/lib/components/button.ts +0 -178
  10. package/lib/components/card.ts +0 -173
  11. package/lib/components/chart.ts +0 -231
  12. package/lib/components/checkbox.ts +0 -242
  13. package/lib/components/code.ts +0 -123
  14. package/lib/components/container.ts +0 -140
  15. package/lib/components/data.ts +0 -135
  16. package/lib/components/datepicker.ts +0 -234
  17. package/lib/components/dialog.ts +0 -172
  18. package/lib/components/divider.ts +0 -100
  19. package/lib/components/dropdown.ts +0 -186
  20. package/lib/components/element.ts +0 -267
  21. package/lib/components/fileupload.ts +0 -309
  22. package/lib/components/grid.ts +0 -291
  23. package/lib/components/guard.ts +0 -92
  24. package/lib/components/heading.ts +0 -96
  25. package/lib/components/helpers.ts +0 -41
  26. package/lib/components/hero.ts +0 -224
  27. package/lib/components/icon.ts +0 -178
  28. package/lib/components/icons.ts +0 -464
  29. package/lib/components/include.ts +0 -410
  30. package/lib/components/input.ts +0 -457
  31. package/lib/components/list.ts +0 -419
  32. package/lib/components/loading.ts +0 -100
  33. package/lib/components/menu.ts +0 -275
  34. package/lib/components/modal.ts +0 -284
  35. package/lib/components/nav.ts +0 -257
  36. package/lib/components/paragraph.ts +0 -97
  37. package/lib/components/progress.ts +0 -159
  38. package/lib/components/radio.ts +0 -278
  39. package/lib/components/req.ts +0 -303
  40. package/lib/components/script.ts +0 -41
  41. package/lib/components/select.ts +0 -252
  42. package/lib/components/sidebar.ts +0 -275
  43. package/lib/components/style.ts +0 -41
  44. package/lib/components/switch.ts +0 -246
  45. package/lib/components/table.ts +0 -1249
  46. package/lib/components/tabs.ts +0 -250
  47. package/lib/components/theme-toggle.ts +0 -293
  48. package/lib/components/tooltip.ts +0 -144
  49. package/lib/components/view.ts +0 -190
  50. package/lib/components/write.ts +0 -272
  51. package/lib/layouts/default.css +0 -260
  52. package/lib/layouts/figma.css +0 -334
  53. package/lib/reactivity/state.ts +0 -78
  54. package/lib/utils/fetch.ts +0 -553
  55. package/machinery/ast.js +0 -347
  56. package/machinery/build.js +0 -466
  57. package/machinery/bundleAssets.js +0 -0
  58. package/machinery/bundleJux.js +0 -0
  59. package/machinery/bundleVendors.js +0 -0
  60. package/machinery/doc-generator.js +0 -136
  61. package/machinery/imports.js +0 -155
  62. package/machinery/ts-shim.js +0 -46
  63. package/machinery/validators/file-validator.js +0 -123
package/machinery/ast.js DELETED
@@ -1,347 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import * as acorn from 'acorn';
4
- import { simple } from 'acorn-walk';
5
- import { glob } from 'glob';
6
- import { loadAndStripTypes, isTypeScript } from './ts-shim.js';
7
-
8
- const vendors = new Set();
9
- const processedFiles = new Set();
10
- const rels = new Map();
11
- const allFiles = new Set();
12
- const cssFiles = new Set();
13
- const assetFiles = new Set();
14
-
15
- // ✅ Define asset extensions to track
16
- const ASSET_EXTENSIONS = [
17
- '.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp', '.bmp', '.ico',
18
- '.mp4', '.mov', '.avi', '.webm', '.ogv',
19
- '.mp3', '.wav', '.ogg', '.m4a',
20
- '.woff', '.woff2', '.ttf', '.otf', '.eot',
21
- '.json', '.xml', '.csv', '.txt',
22
- '.pdf', '.doc', '.docx', '.zip'
23
- ];
24
-
25
- function countAllSourceFiles(directories) {
26
- const allFiles = new Set();
27
-
28
- for (const dir of directories) {
29
- const dirPath = path.resolve(dir);
30
- if (!fs.existsSync(dirPath)) {
31
- console.warn(`⚠️ Directory not found: ${dirPath}`);
32
- continue;
33
- }
34
-
35
- const files = findSourceFiles(dirPath);
36
- files.forEach(f => allFiles.add(f));
37
- }
38
-
39
- return allFiles;
40
- }
41
-
42
- function findSourceFiles(dir, fileList = []) {
43
- const entries = fs.readdirSync(dir, { withFileTypes: true });
44
-
45
- for (const entry of entries) {
46
- const fullPath = path.join(dir, entry.name);
47
-
48
- if (entry.isDirectory()) {
49
- if (!entry.name.startsWith('.') && entry.name !== 'node_modules') {
50
- findSourceFiles(fullPath, fileList);
51
- }
52
- } else if (entry.isFile() && (entry.name.endsWith('.jux') || entry.name.endsWith('.js') || entry.name.endsWith('.ts'))) {
53
- fileList.push(fullPath);
54
- }
55
- }
56
-
57
- return fileList;
58
- }
59
-
60
- const getAllCode = (srcDir) => {
61
- const pattern = path.join(srcDir, '**/*.{js,jux,ts}');
62
- const files = glob.sync(pattern);
63
- const codeMap = {};
64
-
65
- files.forEach(filePath => {
66
- const rawCode = fs.readFileSync(filePath, 'utf-8');
67
- const code = loadAndStripTypes(filePath, rawCode);
68
- codeMap[filePath] = code;
69
- });
70
-
71
- return codeMap;
72
- };
73
-
74
- const findAllRels = (code, sourceFile) => {
75
- try {
76
- const ast = acorn.parse(code, {
77
- ecmaVersion: 'latest',
78
- sourceType: 'module'
79
- });
80
-
81
- simple(ast, {
82
- ImportDeclaration(node) {
83
- const { value } = node.source;
84
- if (/^[./]/.test(value)) {
85
- if (!rels.has(sourceFile)) {
86
- rels.set(sourceFile, new Set());
87
- }
88
- rels.get(sourceFile).add(value);
89
- }
90
- },
91
- CallExpression(node) {
92
- if (node.callee.type === 'MemberExpression' &&
93
- node.callee.object.name === 'jux' &&
94
- node.callee.property.name === 'include' &&
95
- node.arguments.length > 0 &&
96
- node.arguments[0].type === 'Literal') {
97
-
98
- const includePath = node.arguments[0].value;
99
-
100
- if (!rels.has(sourceFile)) {
101
- rels.set(sourceFile, new Set());
102
- }
103
- rels.get(sourceFile).add(includePath);
104
- }
105
- },
106
- Literal(node) {
107
- if (typeof node.value === 'string') {
108
- const val = node.value;
109
-
110
- if (/^[./]/.test(val)) {
111
- const ext = path.extname(val).toLowerCase();
112
-
113
- if (ASSET_EXTENSIONS.includes(ext)) {
114
- if (!rels.has(sourceFile)) {
115
- rels.set(sourceFile, new Set());
116
- }
117
- rels.get(sourceFile).add(val);
118
- }
119
- }
120
- }
121
- }
122
- });
123
- } catch (err) {
124
- // Silent fail
125
- }
126
- };
127
-
128
- const findVendors = (code) => {
129
- try {
130
- const ast = acorn.parse(code, {
131
- ecmaVersion: 'latest',
132
- sourceType: 'module'
133
- });
134
-
135
- simple(ast, {
136
- ImportDeclaration(node) {
137
- const { value } = node.source;
138
- if (!/^[./]/.test(value)) {
139
- vendors.add(value);
140
- }
141
- }
142
- });
143
- } catch (err) {
144
- // Silent fail
145
- }
146
- };
147
-
148
- function processCodeDirs(directories) {
149
- const allCodeMaps = {};
150
- for (const dir of directories) {
151
- const codeMap = getAllCode(dir);
152
- Object.assign(allCodeMaps, codeMap);
153
- }
154
-
155
- Object.keys(allCodeMaps).forEach(filePath => {
156
- allFiles.add(path.resolve(filePath));
157
- });
158
-
159
- for (const filePath in allCodeMaps) {
160
- if (!processedFiles.has(filePath)) {
161
- const code = allCodeMaps[filePath];
162
- findVendors(code);
163
- findAllRels(code, filePath);
164
- processedFiles.add(filePath);
165
- }
166
- }
167
-
168
- resolveAllRelativeImports();
169
- }
170
-
171
- function resolveAllRelativeImports() {
172
- const visited = new Set();
173
- const toProcess = Array.from(rels.keys());
174
-
175
- while (toProcess.length > 0) {
176
- const currentFile = toProcess.shift();
177
-
178
- if (visited.has(currentFile)) continue;
179
- visited.add(currentFile);
180
-
181
- allFiles.add(currentFile);
182
-
183
- const imports = rels.get(currentFile);
184
- if (!imports) continue;
185
-
186
- const sourceDir = path.dirname(currentFile);
187
-
188
- imports.forEach(relImport => {
189
- const basePath = path.resolve(sourceDir, relImport);
190
-
191
- const ext = path.extname(relImport).toLowerCase();
192
-
193
- if (ext === '.css') {
194
- if (fs.existsSync(basePath)) {
195
- const absolutePath = path.resolve(basePath);
196
- allFiles.add(absolutePath);
197
- cssFiles.add(absolutePath);
198
- }
199
- return;
200
- }
201
-
202
- if (ASSET_EXTENSIONS.includes(ext)) {
203
- if (fs.existsSync(basePath)) {
204
- const absolutePath = path.resolve(basePath);
205
- allFiles.add(absolutePath);
206
- assetFiles.add(absolutePath);
207
- }
208
- return;
209
- }
210
-
211
- const extensions = ['', '.js', '.jux', '.ts'];
212
-
213
- for (const extSuffix of extensions) {
214
- const fullPath = basePath + extSuffix;
215
-
216
- if (fs.existsSync(fullPath)) {
217
- const absolutePath = path.resolve(fullPath);
218
- allFiles.add(absolutePath);
219
-
220
- if (!visited.has(fullPath) && !processedFiles.has(fullPath)) {
221
- try {
222
- const content = fs.readFileSync(fullPath, 'utf-8');
223
- const code = loadAndStripTypes(fullPath, content);
224
-
225
- findVendors(code);
226
- findAllRels(code, fullPath);
227
- processedFiles.add(fullPath);
228
-
229
- if (rels.has(fullPath)) {
230
- toProcess.push(fullPath);
231
- }
232
- } catch (err) {
233
- // Silent fail
234
- }
235
- }
236
-
237
- break;
238
- }
239
- }
240
- });
241
- }
242
- }
243
-
244
- // ✅ LEGACY EXPORTS (for backward compatibility)
245
- export const analyzeVendors = (files) => {
246
- vendors.clear();
247
- for (const filePath in files) {
248
- if (filePath.endsWith('.js') || filePath.endsWith('.jux') || filePath.endsWith('.ts')) {
249
- const rawCode = files[filePath];
250
- const code = loadAndStripTypes(filePath, rawCode);
251
- findVendors(code);
252
- }
253
- }
254
- return Array.from(vendors);
255
- }
256
-
257
- export const clearVendors = () => {
258
- vendors.clear();
259
- }
260
-
261
- export const getVendors = () => {
262
- return Array.from(vendors);
263
- }
264
-
265
- // ✅ NEW: Main analysis function that returns everything
266
- export function analyzeProject(directories = ['./jux', './lib']) {
267
- // Clear previous state
268
- vendors.clear();
269
- processedFiles.clear();
270
- rels.clear();
271
- allFiles.clear();
272
- cssFiles.clear();
273
- assetFiles.clear();
274
-
275
- // Run analysis
276
- processCodeDirs(directories);
277
-
278
- // Return comprehensive analysis results
279
- return {
280
- vendors: Array.from(vendors),
281
- allFiles: Array.from(allFiles),
282
- cssFiles: Array.from(cssFiles),
283
- assetFiles: Array.from(assetFiles),
284
- relativeImports: rels,
285
-
286
- // Categorized files
287
- juxFiles: Array.from(allFiles).filter(f => f.endsWith('.jux')),
288
- jsFiles: Array.from(allFiles).filter(f => f.endsWith('.js')),
289
- tsFiles: Array.from(allFiles).filter(f => f.endsWith('.ts')),
290
-
291
- // Asset breakdown
292
- assets: {
293
- images: Array.from(assetFiles).filter(f => {
294
- const ext = path.extname(f).toLowerCase();
295
- return ['.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp', '.bmp', '.ico'].includes(ext);
296
- }),
297
- videos: Array.from(assetFiles).filter(f => {
298
- const ext = path.extname(f).toLowerCase();
299
- return ['.mp4', '.mov', '.avi', '.webm', '.ogv'].includes(ext);
300
- }),
301
- audio: Array.from(assetFiles).filter(f => {
302
- const ext = path.extname(f).toLowerCase();
303
- return ['.mp3', '.wav', '.ogg', '.m4a'].includes(ext);
304
- }),
305
- fonts: Array.from(assetFiles).filter(f => {
306
- const ext = path.extname(f).toLowerCase();
307
- return ['.woff', '.woff2', '.ttf', '.otf', '.eot'].includes(ext);
308
- }),
309
- data: Array.from(assetFiles).filter(f => {
310
- const ext = path.extname(f).toLowerCase();
311
- return ['.json', '.xml', '.csv', '.txt'].includes(ext);
312
- })
313
- },
314
-
315
- // Summary stats
316
- stats: {
317
- totalFiles: allFiles.size,
318
- totalVendors: vendors.size,
319
- totalCSS: cssFiles.size,
320
- totalAssets: assetFiles.size,
321
- filesWithImports: rels.size
322
- }
323
- };
324
- }
325
-
326
- // ✅ Export constants
327
- export { ASSET_EXTENSIONS };
328
-
329
- export default {
330
- analyzeProject,
331
- analyzeVendors,
332
- clearVendors,
333
- getVendors,
334
- ASSET_EXTENSIONS
335
- };
336
-
337
- function main() {
338
- const analysis = analyzeProject(['./jux', './lib']);
339
-
340
- console.log('External vendors:', analysis.vendors);
341
- console.log('Total files:', analysis.stats.totalFiles);
342
- }
343
-
344
- // Only run main if executed directly
345
- if (import.meta.url === `file://${process.argv[1]}`) {
346
- main();
347
- }