@geekmidas/ui 0.0.1

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/dist/index.cjs ADDED
File without changes
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.mjs ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@geekmidas/ui",
3
+ "version": "0.0.1",
4
+ "description": "Shared UI build utilities",
5
+ "type": "module",
6
+ "bin": {
7
+ "embed-ui": "./scripts/embed-ui.ts"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/geekmidas/toolbox"
12
+ },
13
+ "publishConfig": {
14
+ "registry": "https://registry.npmjs.org/",
15
+ "access": "public"
16
+ },
17
+ "devDependencies": {
18
+ "tsx": "~4.19.4"
19
+ }
20
+ }
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env tsx
2
+ /**
3
+ * Script to embed built UI assets into a TypeScript file.
4
+ * This allows packages to serve the UI without external files.
5
+ *
6
+ * Usage: embed-ui <input-dir> <output-file>
7
+ * Example: embed-ui dist/ui src/ui-assets.ts
8
+ */
9
+ import { readFileSync, readdirSync, writeFileSync } from 'fs';
10
+
11
+ interface Asset {
12
+ path: string;
13
+ content: string;
14
+ contentType: string;
15
+ }
16
+
17
+ function getContentType(filename: string): string {
18
+ if (filename.endsWith('.html')) return 'text/html';
19
+ if (filename.endsWith('.css')) return 'text/css';
20
+ if (filename.endsWith('.js')) return 'application/javascript';
21
+ if (filename.endsWith('.map')) return 'application/json';
22
+ return 'application/octet-stream';
23
+ }
24
+
25
+ function collectAssets(dir: string, basePath: string = ''): Asset[] {
26
+ const assets: Asset[] = [];
27
+ const entries = readdirSync(dir, { withFileTypes: true });
28
+
29
+ for (const entry of entries) {
30
+ const fullPath = `${dir}/${entry.name}`;
31
+ const assetPath = basePath ? `${basePath}/${entry.name}` : entry.name;
32
+
33
+ if (entry.isDirectory()) {
34
+ assets.push(...collectAssets(fullPath, assetPath));
35
+ } else if (!entry.name.endsWith('.map')) {
36
+ // Skip source maps
37
+ const content = readFileSync(fullPath, 'utf-8');
38
+ assets.push({
39
+ path: assetPath,
40
+ content,
41
+ contentType: getContentType(entry.name),
42
+ });
43
+ }
44
+ }
45
+
46
+ return assets;
47
+ }
48
+
49
+ const args = process.argv.slice(2);
50
+ if (args.length !== 2) {
51
+ console.error('Usage: embed-ui <input-dir> <output-file>');
52
+ console.error('Example: embed-ui dist/ui src/ui-assets.ts');
53
+ process.exit(1);
54
+ }
55
+
56
+ const [inputDir, outputFile] = args;
57
+
58
+ try {
59
+ const assets = collectAssets(inputDir);
60
+
61
+ // Find the index.html to extract references
62
+ const indexHtml = assets.find((a) => a.path === 'index.html');
63
+ if (!indexHtml) {
64
+ console.error('index.html not found in build output');
65
+ process.exit(1);
66
+ }
67
+
68
+ // Generate TypeScript file
69
+ const output = `// Auto-generated file - do not edit directly
70
+ // Generated by @geekmidas/ui/scripts/embed-ui.ts
71
+
72
+ export interface UIAsset {
73
+ path: string;
74
+ content: string;
75
+ contentType: string;
76
+ }
77
+
78
+ export const UI_ASSETS: UIAsset[] = ${JSON.stringify(assets, null, 2)};
79
+
80
+ export function getAsset(path: string): UIAsset | undefined {
81
+ // Normalize path
82
+ const normalized = path.replace(/^\\//, '');
83
+ return UI_ASSETS.find((a) => a.path === normalized);
84
+ }
85
+
86
+ export function getIndexHtml(): string {
87
+ const asset = UI_ASSETS.find((a) => a.path === 'index.html');
88
+ return asset?.content ?? '';
89
+ }
90
+ `;
91
+
92
+ writeFileSync(outputFile, output);
93
+ console.error(`Embedded ${assets.length} UI assets into ${outputFile}`);
94
+ } catch (error) {
95
+ console.error('Error embedding UI assets:', error);
96
+ process.exit(1);
97
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export {};