juxscript 1.1.3 → 1.1.4

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 -209
  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
@@ -1,155 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
- const REGISTRY_PATH = path.join(__dirname, '../lib/registry/packages.json');
8
-
9
- /**
10
- * Load package registry
11
- */
12
- function loadRegistry() {
13
- if (!fs.existsSync(REGISTRY_PATH)) {
14
- return {};
15
- }
16
- return JSON.parse(fs.readFileSync(REGISTRY_PATH, 'utf-8'));
17
- }
18
-
19
- /**
20
- * Parse @import directives from Jux code
21
- */
22
- export function parseImports(juxCode) {
23
- const imports = [];
24
- const lines = juxCode.split('\n');
25
-
26
- for (let i = 0; i < lines.length; i++) {
27
- const line = lines[i].trim();
28
-
29
- // Stop parsing when we hit actual code (non-directive, non-comment)
30
- if (line && !line.startsWith('@') && !line.startsWith('//') && !line.startsWith('/*')) {
31
- break;
32
- }
33
-
34
- // Match @import directive
35
- const importMatch = line.match(/^@import\s+(.+)$/);
36
- if (importMatch) {
37
- const importSpec = importMatch[1].trim();
38
- imports.push({
39
- line: i + 1,
40
- raw: importSpec,
41
- resolved: resolveImport(importSpec)
42
- });
43
-
44
- if (process.env.JUX_VERBOSE) {
45
- console.log(` [Line ${i + 1}] Found @import: ${importSpec}`);
46
- }
47
- }
48
- }
49
-
50
- return imports;
51
- }
52
-
53
- /**
54
- * Resolve import specification to URL/path
55
- */
56
- export function resolveImport(importSpec) {
57
- // Remove quotes if present
58
- const cleaned = importSpec.replace(/^['"]|['"]$/g, '');
59
-
60
- // Direct URL (starts with http:// or https://)
61
- if (cleaned.startsWith('http://') || cleaned.startsWith('https://')) {
62
- return {
63
- type: 'cdn',
64
- url: cleaned,
65
- source: 'direct'
66
- };
67
- }
68
-
69
- // Local file (starts with ./ or ../ or /)
70
- if (cleaned.startsWith('./') || cleaned.startsWith('../') || cleaned.startsWith('/')) {
71
- return {
72
- type: 'local',
73
- path: cleaned,
74
- source: 'file'
75
- };
76
- }
77
-
78
- // Unknown/unsupported
79
- return {
80
- type: 'unknown',
81
- name: cleaned,
82
- error: `Import "${cleaned}" must be a URL (https://...) or relative path (./...)`
83
- };
84
- }
85
-
86
- /**
87
- * Auto-detect component dependencies
88
- */
89
- function detectComponentDependencies(usedComponents) {
90
- const componentDeps = {
91
- 'chart': 'chart.js'
92
- // Add more mappings as needed
93
- };
94
-
95
- const deps = new Set();
96
-
97
- usedComponents.forEach(comp => {
98
- if (componentDeps[comp]) {
99
- deps.add(componentDeps[comp]);
100
- }
101
- });
102
-
103
- return Array.from(deps).map(pkg => ({
104
- auto: true,
105
- resolved: resolveImport(pkg)
106
- }));
107
- }
108
-
109
- /**
110
- * Generate HTML script tags from resolved imports
111
- */
112
- export function generateImportTags(imports) {
113
- const tags = [];
114
- const seen = new Set();
115
-
116
- for (const imp of imports) {
117
- const resolved = imp.resolved;
118
-
119
- if (resolved.type === 'unknown') {
120
- tags.push(`<!-- ERROR: ${resolved.error} -->`);
121
- continue;
122
- }
123
-
124
- const key = resolved.url || resolved.path;
125
- if (seen.has(key)) continue;
126
- seen.add(key);
127
-
128
- if (resolved.type === 'cdn') {
129
- tags.push(` <script src="${resolved.url}"></script>`);
130
- } else if (resolved.type === 'local') {
131
- tags.push(` <script type="module" src="${resolved.path}"></script>`);
132
- }
133
- }
134
-
135
- return tags.join('\n');
136
- }
137
-
138
- /**
139
- * Validate all imports are resolvable
140
- */
141
- export function validateImports(imports) {
142
- const errors = [];
143
-
144
- imports.forEach(imp => {
145
- if (imp.resolved.type === 'unknown') {
146
- errors.push({
147
- line: imp.line,
148
- message: imp.resolved.error,
149
- raw: imp.raw
150
- });
151
- }
152
- });
153
-
154
- return errors;
155
- }
@@ -1,46 +0,0 @@
1
- import esbuild from 'esbuild';
2
-
3
- /**
4
- * TypeScript Shim - Strips type annotations using esbuild
5
- * This is rock-solid and handles ALL TypeScript syntax correctly
6
- */
7
-
8
- /**
9
- * Strip TypeScript type annotations from code using esbuild
10
- *
11
- * @param {string} code - TypeScript source code
12
- * @returns {string} - JavaScript code with types removed
13
- */
14
- export function stripTypes(code) {
15
- try {
16
- // ✅ Use esbuild to transform TypeScript → JavaScript
17
- const result = esbuild.transformSync(code, {
18
- loader: 'ts',
19
- format: 'esm',
20
- target: 'es2020'
21
- });
22
-
23
- return result.code;
24
- } catch (err) {
25
- console.error('❌ Failed to strip TypeScript:', err.message);
26
- // Return original code if transformation fails
27
- return code;
28
- }
29
- }
30
-
31
- /**
32
- * Check if a file is TypeScript based on extension
33
- */
34
- export function isTypeScript(filePath) {
35
- return filePath.endsWith('.ts') || filePath.endsWith('.tsx');
36
- }
37
-
38
- /**
39
- * Load and parse a file, automatically stripping types if it's TypeScript
40
- */
41
- export function loadAndStripTypes(filePath, fileContent) {
42
- if (isTypeScript(filePath)) {
43
- return stripTypes(fileContent);
44
- }
45
- return fileContent;
46
- }
@@ -1,123 +0,0 @@
1
- /**
2
- * File validation utilities for Jux compiler
3
- * Validates file types and content security
4
- */
5
- export class FileValidator {
6
- constructor() {
7
- this.cssExtensions = /\.(css|scss|sass|less)$/i;
8
- this.jsExtensions = /\.(js|mjs|ts|tsx|jsx)$/i;
9
- this.imageExtensions = /\.(png|jpg|jpeg|gif|svg|webp|ico|bmp)$/i;
10
- }
11
-
12
- /**
13
- * Check if file is a CSS file
14
- */
15
- isCSSFile(filepath) {
16
- return this.cssExtensions.test(filepath);
17
- }
18
-
19
- /**
20
- * Check if file is a JavaScript file
21
- */
22
- isJavaScriptFile(filepath) {
23
- return this.jsExtensions.test(filepath);
24
- }
25
-
26
- /**
27
- * Check if file is an image file
28
- */
29
- isImageFile(filepath) {
30
- return this.imageExtensions.test(filepath);
31
- }
32
-
33
- /**
34
- * Validate CSS content for security issues
35
- * Detects <script> tags that could be injected
36
- */
37
- validateStyleContent(content, source = 'unknown') {
38
- if (/<script/i.test(content)) {
39
- throw new Error(
40
- `🚨 Security Error: <script> tag detected in ${source}\n` +
41
- `CSS content must not contain script tags.`
42
- );
43
- }
44
-
45
- if (/<\/script/i.test(content)) {
46
- throw new Error(
47
- `🚨 Security Error: </script> tag detected in ${source}\n` +
48
- `CSS content must not contain script tags.`
49
- );
50
- }
51
-
52
- return content;
53
- }
54
-
55
- /**
56
- * Determine import type based on file extension
57
- * Returns: 'css' | 'js' | 'image' | 'unknown'
58
- */
59
- validateImportPath(importPath) {
60
- // Handle URLs
61
- if (importPath.startsWith('http://') || importPath.startsWith('https://')) {
62
- // Try to infer from URL
63
- if (this.isCSSFile(importPath)) return { type: 'css', path: importPath };
64
- if (this.isJavaScriptFile(importPath)) return { type: 'js', path: importPath };
65
- if (this.isImageFile(importPath)) return { type: 'image', path: importPath };
66
-
67
- // Default to unknown for CDN URLs without clear extensions
68
- return { type: 'unknown', path: importPath };
69
- }
70
-
71
- // Local files
72
- if (this.isCSSFile(importPath)) {
73
- return { type: 'css', path: importPath };
74
- }
75
-
76
- if (this.isJavaScriptFile(importPath)) {
77
- return { type: 'js', path: importPath };
78
- }
79
-
80
- if (this.isImageFile(importPath)) {
81
- return { type: 'image', path: importPath };
82
- }
83
-
84
- return { type: 'unknown', path: importPath };
85
- }
86
-
87
- /**
88
- * Validate array of imports and categorize them
89
- * Returns categorized imports with warnings
90
- */
91
- categorizeImports(imports) {
92
- const categorized = {
93
- css: [],
94
- js: [],
95
- images: [],
96
- unknown: []
97
- };
98
-
99
- const warnings = [];
100
-
101
- for (const importPath of imports) {
102
- const result = this.validateImportPath(importPath);
103
-
104
- if (result.type === 'unknown') {
105
- warnings.push(
106
- `⚠️ Unknown import type: ${importPath}\n` +
107
- ` Supported: .css/.scss/.sass, .js/.ts, .png/.jpg/.svg`
108
- );
109
- }
110
-
111
- categorized[result.type === 'unknown' ? 'unknown' : result.type].push(result.path);
112
- }
113
-
114
- return { categorized, warnings };
115
- }
116
-
117
- /**
118
- * Check if inline style content is empty or whitespace-only
119
- */
120
- isEmptyStyle(styleContent) {
121
- return !styleContent || styleContent.trim().length === 0;
122
- }
123
- }