juxscript 1.1.5 → 1.1.7
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 +1 -1
- package/index.d.ts +10 -10
- package/index.d.ts.map +1 -0
- package/lib/components/alert.d.ts +32 -0
- package/lib/components/alert.d.ts.map +1 -0
- package/lib/components/alert.js +153 -0
- package/lib/components/alert.ts +200 -0
- package/lib/components/app.d.ts +89 -0
- package/lib/components/app.d.ts.map +1 -0
- package/lib/components/app.js +175 -0
- package/lib/components/app.ts +247 -0
- package/lib/components/badge.d.ts +27 -0
- package/lib/components/badge.d.ts.map +1 -0
- package/lib/components/badge.js +70 -0
- package/lib/components/badge.ts +101 -0
- package/lib/components/base/BaseComponent.d.ts +142 -0
- package/lib/components/base/BaseComponent.d.ts.map +1 -0
- package/lib/components/base/BaseComponent.js +363 -0
- package/lib/components/base/BaseComponent.ts +421 -0
- package/lib/components/base/FormInput.d.ts +73 -0
- package/lib/components/base/FormInput.d.ts.map +1 -0
- package/lib/components/base/FormInput.js +163 -0
- package/lib/components/base/FormInput.ts +227 -0
- package/lib/components/button.d.ts +48 -0
- package/lib/components/button.d.ts.map +1 -0
- package/lib/components/button.js +121 -0
- package/lib/components/button.ts +178 -0
- package/lib/components/card.d.ts +34 -0
- package/lib/components/card.d.ts.map +1 -0
- package/lib/components/card.js +127 -0
- package/lib/components/card.ts +173 -0
- package/lib/components/chart.d.ts +45 -0
- package/lib/components/chart.d.ts.map +1 -0
- package/lib/components/chart.js +186 -0
- package/lib/components/chart.ts +231 -0
- package/lib/components/checkbox.d.ts +31 -0
- package/lib/components/checkbox.d.ts.map +1 -0
- package/lib/components/checkbox.js +185 -0
- package/lib/components/checkbox.ts +242 -0
- package/lib/components/code.d.ts +24 -0
- package/lib/components/code.d.ts.map +1 -0
- package/lib/components/code.js +88 -0
- package/lib/components/code.ts +123 -0
- package/lib/components/container.d.ts +42 -0
- package/lib/components/container.d.ts.map +1 -0
- package/lib/components/container.js +93 -0
- package/lib/components/container.ts +140 -0
- package/lib/components/data.d.ts +36 -0
- package/lib/components/data.d.ts.map +1 -0
- package/lib/components/data.js +110 -0
- package/lib/components/data.ts +135 -0
- package/lib/components/datepicker.d.ts +38 -0
- package/lib/components/datepicker.d.ts.map +1 -0
- package/lib/components/datepicker.js +177 -0
- package/lib/components/datepicker.ts +234 -0
- package/lib/components/dialog.d.ts +38 -0
- package/lib/components/dialog.d.ts.map +1 -0
- package/lib/components/dialog.js +126 -0
- package/lib/components/dialog.ts +172 -0
- package/lib/components/divider.d.ts +30 -0
- package/lib/components/divider.d.ts.map +1 -0
- package/lib/components/divider.js +69 -0
- package/lib/components/divider.ts +100 -0
- package/lib/components/dropdown.d.ts +39 -0
- package/lib/components/dropdown.d.ts.map +1 -0
- package/lib/components/dropdown.js +133 -0
- package/lib/components/dropdown.ts +186 -0
- package/lib/components/element.d.ts +50 -0
- package/lib/components/element.d.ts.map +1 -0
- package/lib/components/element.js +206 -0
- package/lib/components/element.ts +267 -0
- package/lib/components/fileupload.d.ts +40 -0
- package/lib/components/fileupload.d.ts.map +1 -0
- package/lib/components/fileupload.js +241 -0
- package/lib/components/fileupload.ts +309 -0
- package/lib/components/grid.d.ts +87 -0
- package/lib/components/grid.d.ts.map +1 -0
- package/lib/components/grid.js +205 -0
- package/lib/components/grid.ts +291 -0
- package/lib/components/guard.d.ts +41 -0
- package/lib/components/guard.d.ts.map +1 -0
- package/lib/components/guard.js +56 -0
- package/lib/components/guard.ts +92 -0
- package/lib/components/heading.d.ts +24 -0
- package/lib/components/heading.d.ts.map +1 -0
- package/lib/components/heading.js +67 -0
- package/lib/components/heading.ts +96 -0
- package/lib/components/helpers.d.ts +9 -0
- package/lib/components/helpers.d.ts.map +1 -0
- package/lib/components/helpers.js +30 -0
- package/lib/components/helpers.ts +41 -0
- package/lib/components/hero.d.ts +45 -0
- package/lib/components/hero.d.ts.map +1 -0
- package/lib/components/hero.js +165 -0
- package/lib/components/hero.ts +224 -0
- package/lib/components/icon.d.ts +35 -0
- package/lib/components/icon.d.ts.map +1 -0
- package/lib/components/icon.js +132 -0
- package/lib/components/icon.ts +178 -0
- package/lib/components/icons.d.ts +25 -0
- package/lib/components/icons.d.ts.map +1 -0
- package/lib/components/icons.js +440 -0
- package/lib/components/icons.ts +464 -0
- package/lib/components/include.d.ts +120 -0
- package/lib/components/include.d.ts.map +1 -0
- package/lib/components/include.js +350 -0
- package/lib/components/include.ts +410 -0
- package/lib/components/input.d.ts +83 -0
- package/lib/components/input.d.ts.map +1 -0
- package/lib/components/input.js +348 -0
- package/lib/components/input.ts +457 -0
- package/lib/components/list.d.ts +82 -0
- package/lib/components/list.d.ts.map +1 -0
- package/lib/components/list.js +311 -0
- package/lib/components/list.ts +419 -0
- package/lib/components/loading.d.ts +24 -0
- package/lib/components/loading.d.ts.map +1 -0
- package/lib/components/loading.js +73 -0
- package/lib/components/loading.ts +100 -0
- package/lib/components/menu.d.ts +37 -0
- package/lib/components/menu.d.ts.map +1 -0
- package/lib/components/menu.js +202 -0
- package/lib/components/menu.ts +275 -0
- package/lib/components/modal.d.ts +51 -0
- package/lib/components/modal.d.ts.map +1 -0
- package/lib/components/modal.js +227 -0
- package/lib/components/modal.ts +284 -0
- package/lib/components/nav.d.ts +45 -0
- package/lib/components/nav.d.ts.map +1 -0
- package/lib/components/nav.js +190 -0
- package/lib/components/nav.ts +257 -0
- package/lib/components/paragraph.d.ts +21 -0
- package/lib/components/paragraph.d.ts.map +1 -0
- package/lib/components/paragraph.js +70 -0
- package/lib/components/paragraph.ts +97 -0
- package/lib/components/progress.d.ts +39 -0
- package/lib/components/progress.d.ts.map +1 -0
- package/lib/components/progress.js +113 -0
- package/lib/components/progress.ts +159 -0
- package/lib/components/radio.d.ts +41 -0
- package/lib/components/radio.d.ts.map +1 -0
- package/lib/components/radio.js +203 -0
- package/lib/components/radio.ts +278 -0
- package/lib/components/req.d.ts +155 -0
- package/lib/components/req.d.ts.map +1 -0
- package/lib/components/req.js +253 -0
- package/lib/components/req.ts +303 -0
- package/lib/components/script.d.ts +14 -0
- package/lib/components/script.d.ts.map +1 -0
- package/lib/components/script.js +33 -0
- package/lib/components/script.ts +41 -0
- package/lib/components/select.d.ts +40 -0
- package/lib/components/select.d.ts.map +1 -0
- package/lib/components/select.js +183 -0
- package/lib/components/select.ts +252 -0
- package/lib/components/sidebar.d.ts +48 -0
- package/lib/components/sidebar.d.ts.map +1 -0
- package/lib/components/sidebar.js +207 -0
- package/lib/components/sidebar.ts +275 -0
- package/lib/components/style.d.ts +14 -0
- package/lib/components/style.d.ts.map +1 -0
- package/lib/components/style.js +33 -0
- package/lib/components/style.ts +41 -0
- package/lib/components/switch.d.ts +32 -0
- package/lib/components/switch.d.ts.map +1 -0
- package/lib/components/switch.js +186 -0
- package/lib/components/switch.ts +246 -0
- package/lib/components/table.d.ts +137 -0
- package/lib/components/table.d.ts.map +1 -0
- package/lib/components/table.js +1045 -0
- package/lib/components/table.ts +1249 -0
- package/lib/components/tabs.d.ts +36 -0
- package/lib/components/tabs.d.ts.map +1 -0
- package/lib/components/tabs.js +198 -0
- package/lib/components/tabs.ts +250 -0
- package/lib/components/theme-toggle.d.ts +44 -0
- package/lib/components/theme-toggle.d.ts.map +1 -0
- package/lib/components/theme-toggle.js +215 -0
- package/lib/components/theme-toggle.ts +293 -0
- package/lib/components/tooltip.d.ts +30 -0
- package/lib/components/tooltip.d.ts.map +1 -0
- package/lib/components/tooltip.js +109 -0
- package/lib/components/tooltip.ts +144 -0
- package/lib/components/view.d.ts +48 -0
- package/lib/components/view.d.ts.map +1 -0
- package/lib/components/view.js +149 -0
- package/lib/components/view.ts +190 -0
- package/lib/components/write.d.ts +107 -0
- package/lib/components/write.d.ts.map +1 -0
- package/lib/components/write.js +222 -0
- package/lib/components/write.ts +272 -0
- package/lib/layouts/default.css +260 -0
- package/lib/layouts/figma.css +334 -0
- package/lib/reactivity/state.d.ts +36 -0
- package/lib/reactivity/state.d.ts.map +1 -0
- package/lib/reactivity/state.js +67 -0
- package/lib/reactivity/state.ts +78 -0
- package/lib/utils/fetch.d.ts +176 -0
- package/lib/utils/fetch.d.ts.map +1 -0
- package/lib/utils/fetch.js +427 -0
- package/lib/utils/fetch.ts +553 -0
- package/machinery/doc-generator.js +136 -0
- package/machinery/imports.js +155 -0
- package/machinery/ts-shim.js +46 -0
- package/package.json +9 -15
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "juxscript",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A JavaScript UX authorship platform",
|
|
6
6
|
"main": "index.js",
|
|
@@ -21,23 +21,16 @@
|
|
|
21
21
|
"files": [
|
|
22
22
|
"index.js",
|
|
23
23
|
"index.d.ts",
|
|
24
|
+
"index.d.ts.map",
|
|
24
25
|
"bin",
|
|
25
|
-
"create
|
|
26
|
-
"lib
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"machinery/compiler3.js",
|
|
30
|
-
"machinery/config.js",
|
|
31
|
-
"machinery/serve.js",
|
|
32
|
-
"machinery/watcher.js",
|
|
26
|
+
"create",
|
|
27
|
+
"lib",
|
|
28
|
+
"machinery",
|
|
29
|
+
"reactivity",
|
|
33
30
|
"types",
|
|
34
31
|
"juxconfig.example.js",
|
|
35
32
|
"README.md",
|
|
36
|
-
"LICENSE"
|
|
37
|
-
"!lib/**/*.test.js",
|
|
38
|
-
"!lib/**/*.spec.js",
|
|
39
|
-
"!lib/previews/**",
|
|
40
|
-
"!**/*.map"
|
|
33
|
+
"LICENSE"
|
|
41
34
|
],
|
|
42
35
|
"bin": {
|
|
43
36
|
"jux": "./bin/cli.js"
|
|
@@ -53,7 +46,8 @@
|
|
|
53
46
|
"scripts": {
|
|
54
47
|
"build": "tsc",
|
|
55
48
|
"dev": "tsc --watch",
|
|
56
|
-
"prepublishOnly": "npm run build"
|
|
49
|
+
"prepublishOnly": "npm run build",
|
|
50
|
+
"postpublish": "echo '✅ Published successfully. Verify with: npm info juxscript'"
|
|
57
51
|
},
|
|
58
52
|
"dependencies": {
|
|
59
53
|
"acorn": "^8.15.0",
|