Clean and minify

This commit is contained in:
2026-03-26 22:59:21 +01:00
parent 9e59377055
commit 6350509abd
8 changed files with 27 additions and 295 deletions

View File

@@ -32,7 +32,7 @@
"dev:docs": "vitepress dev src/docs", "dev:docs": "vitepress dev src/docs",
"build:docs": "vitepress build src/docs", "build:docs": "vitepress build src/docs",
"preview:docs": "vitepress preview src/docs", "preview:docs": "vitepress preview src/docs",
"build:aggrid": "vite build --config UI/aggrid/vite.config.js" "build:aggrid": "vite build --config ui/grid/vite.config.js"
}, },
"devDependencies": { "devDependencies": {
"vitepress": "^1.6.4", "vitepress": "^1.6.4",

File diff suppressed because one or more lines are too long

View File

@@ -8,8 +8,8 @@ import {
RowSelectionModule, RowSelectionModule,
TextEditorModule, TextEditorModule,
ClientSideRowModelModule, ClientSideRowModelModule,
themeQuartz, // themeQuartz,
iconSetQuartzLight, // iconSetQuartzLight,
} from "ag-grid-community"; } from "ag-grid-community";
import { import {
@@ -25,7 +25,6 @@ import {
ClipboardModule, ClipboardModule,
} from "ag-grid-enterprise"; } from "ag-grid-enterprise";
// Registro único de módulos
ModuleRegistry.registerModules([ ModuleRegistry.registerModules([
ValidationModule, ValidationModule,
ColumnAutoSizeModule, ColumnAutoSizeModule,
@@ -46,23 +45,22 @@ ModuleRegistry.registerModules([
ClipboardModule, ClipboardModule,
]); ]);
// Helper de tema exportado // export const getAgTheme = (isDark) =>
export const getAgTheme = (isDark) => // themeQuartz.withPart(iconSetQuartzLight).withParams({
themeQuartz.withPart(iconSetQuartzLight).withParams({ // browserColorScheme: isDark ? "dark" : "light",
browserColorScheme: isDark ? "dark" : "light", // backgroundColor: isDark ? "#121212" : "#FDFDFD",
backgroundColor: isDark ? "#121212" : "#FDFDFD", // foregroundColor: isDark ? "#E0E0E0" : "#181D1F",
foregroundColor: isDark ? "#E0E0E0" : "#181D1F", // accentColor: isDark ? "#4FAAFF" : "#004B9C",
accentColor: isDark ? "#4FAAFF" : "#004B9C", // headerBackgroundColor: isDark ? "#2A2A2A" : "#EEB111",
headerBackgroundColor: isDark ? "#2A2A2A" : "#EEB111", // headerTextColor: isDark ? "#4FAAFF" : "#004B9C",
headerTextColor: isDark ? "#4FAAFF" : "#004B9C", // borderRadius: 4,
borderRadius: 4, // columnBorder: false,
columnBorder: false, // headerFontSize: 14,
headerFontSize: 14, // headerFontWeight: 600,
headerFontWeight: 600, // listItemHeight: 20,
listItemHeight: 20, // iconSize: 14,
iconSize: 14, // spacing: 3,
spacing: 3, // wrapperBorderRadius: 4,
wrapperBorderRadius: 4, // });
});
export { createGrid }; export { createGrid };

View File

@@ -8,18 +8,15 @@ const __dirname = path.resolve();
export default defineConfig({ export default defineConfig({
plugins: [tailwindcss()], plugins: [tailwindcss()],
build: { build: {
// Usamos la configuración de librería para generar el bundle limpio
lib: { lib: {
entry: resolve(__dirname, "./UI/aggrid/aggrid-lib.js"), entry: resolve(__dirname, "./UI/aggrid/grid-lib.js"),
name: "AgGridBundle", name: "GridBundle",
fileName: "aggrid", fileName: "grid",
formats: ["es"], formats: ["es"],
}, },
outDir: "./UI/aggrid/dist", outDir: "./ui/grid/dist",
minify: "terser", // Máxima compresión minify: "terser",
rollupOptions: { rollupOptions: {
// Si quieres que ag-grid NO se incluya y sea externo, añádelo aquí.
// Pero como quieres un "Bundle", lo dejamos vacío para que empaquete todo.
external: ["sigpro"], external: ["sigpro"],
output: { output: {
globals: { globals: {

2
ui/sigpro-ui.min.js vendored

File diff suppressed because one or more lines are too long

261
vite/index.d.ts vendored
View File

@@ -1,261 +0,0 @@
/**
* SigPro Vite Plugin
* Provides file-based routing and development tools for Vite
*
* @example
* ```javascript
* // vite.config.js
* import { defineConfig } from 'vite';
* import sigproRouter from 'sigpro/vite';
*
* export default defineConfig({
* plugins: [sigproRouter()]
* });
* ```
*/
import type { Plugin } from 'vite';
/**
* File-based routing configuration options
*/
export interface SigProRouterOptions {
/**
* Directory where page components are stored
* @default 'src/pages'
* @example
* ```javascript
* sigproRouter({ pagesDir: 'src/views' })
* ```
*/
pagesDir?: string;
/**
* File extensions to consider as pages
* @default ['.js', '.jsx', '.ts', '.tsx']
* @example
* ```javascript
* sigproRouter({ extensions: ['.js', '.jsx'] })
* ```
*/
extensions?: string[];
/**
* Custom route transformation function
* @param filePath - Absolute path to the file
* @returns Custom route path or null to skip
* @example
* ```javascript
* sigproRouter({
* transformRoute: (path) => {
* // Convert 'src/pages/blog/post.js' to '/blog/post'
* return path.replace(/^src\/pages/, '').replace(/\.js$/, '');
* }
* })
* ```
*/
transformRoute?: (filePath: string) => string | null;
/**
* Base path prefix for all routes
* @default ''
* @example
* ```javascript
* sigproRouter({ basePath: '/app' }) // Routes become /app/about, /app/users, etc.
* ```
*/
basePath?: string;
/**
* Custom 404 component path
* @default null (uses default "404 - Not Found")
* @example
* ```javascript
* sigproRouter({ notFoundComponent: 'src/pages/NotFound.js' })
* ```
*/
notFoundComponent?: string;
}
/**
* Route configuration generated by the plugin
*/
export interface GeneratedRoute {
/** URL path pattern (supports :params and * wildcard) */
path: string;
/** Lazy-loaded component */
component: () => Promise<any>;
}
/**
* Virtual module ID for generated routes
* @example
* ```javascript
* import { routes } from 'virtual:sigpro-routes';
* ```
*/
export const virtualModuleId = 'virtual:sigpro-routes';
/**
* Vite plugin for SigPro file-based routing
*
* Features:
* - 📁 File-based routing from `src/pages` directory
* - 🔄 Automatic route generation
* - 🚀 Lazy-loading support with code splitting
* - 📦 Dynamic routes with `[param]` syntax → `/:param`
* - ⭐ Catch-all routes with `[...param]` syntax → `/*`
* - 🎯 Index routes (`index.js` becomes `/`)
* - 🧹 Automatic sorting (static routes first, then dynamic)
* - 🎨 404 fallback generation
*
* @example
* **File Structure:**
* ```
* src/pages/
* ├── index.js → '/'
* ├── about.js → '/about'
* ├── blog/
* │ ├── index.js → '/blog'
* │ ├── [slug].js → '/blog/:slug'
* │ └── [...catch].js → '/blog/*'
* └── user/
* ├── index.js → '/user'
* └── [id].js → '/user/:id'
* ```
*
* @example
* **Generated Routes:**
* ```javascript
* // virtual:sigpro-routes
* export const routes = [
* { path: '/', component: () => import('src/pages/index.js') },
* { path: '/about', component: () => import('src/pages/about.js') },
* { path: '/blog', component: () => import('src/pages/blog/index.js') },
* { path: '/blog/:slug', component: () => import('src/pages/blog/[slug].js') },
* { path: '/blog/*', component: () => import('src/pages/blog/[...catch].js') },
* { path: '/user', component: () => import('src/pages/user/index.js') },
* { path: '/user/:id', component: () => import('src/pages/user/[id].js') },
* { path: '*', component: () => import('src/pages/NotFound.js') } // If exists
* ];
* ```
*
* @example
* **Usage with SigPro:**
* ```javascript
* // main.js
* import { routes } from 'virtual:sigpro-routes';
* import { $ } from 'sigpro';
*
* const router = $.router(routes);
* $.mount(router, '#app');
* ```
*
* @param options - Plugin configuration options
* @returns Vite plugin object
*/
export default function sigproRouter(options?: SigProRouterOptions): Plugin;
/**
* Page component props for route components
* @template Params - Type of route parameters
*/
export interface PageProps<Params = Record<string, string>> {
/** URL parameters from dynamic routes (e.g., :id, :slug) */
params: Params;
/** URL search parameters (query string) */
query: URLSearchParams;
/** Current pathname without query string */
pathname: string;
/** Children components (for nested routes) */
children?: any;
}
/**
* Route component type
* @template Params - Type of route parameters
*/
export type PageComponent<Params = Record<string, string>> = (
props: PageProps<Params>
) => HTMLElement | Promise<HTMLElement>;
/**
* Helper function to create typed route components
* Provides better TypeScript support and autocompletion
*
* @example
* ```javascript
* // pages/user/[id].js
* import { createPage } from 'sigpro/vite';
*
* export default createPage(({ params, query }) => {
* const { id } = params; // TypeScript knows this is a string
* const page = query.get('page') || 1;
*
* return div({ class: 'user-profile' }, [
* h1(`User ${id}`),
* p(`Page: ${page}`),
* button({
* onclick: () => console.log('Viewing user', id)
* }, 'View Profile')
* ]);
* });
* ```
*
* @example
* **With TypeScript:**
* ```typescript
* // pages/user/[id].tsx
* interface UserParams {
* id: string;
* }
*
* export default createPage<UserParams>(({ params, query }) => {
* const userId = params.id; // TypeScript knows this is string
* // ... rest of component
* });
* ```
*/
export function createPage<Params = Record<string, string>>(
component: (props: PageProps<Params>) => HTMLElement | Promise<HTMLElement>
): PageComponent<Params>;
/**
* Type guard to check if a component is lazy-loaded
* @param component - Component to check
* @returns True if component is a lazy-loaded module
*/
export function isLazyComponent(component: any): component is () => Promise<any>;
/**
* Utility to preload routes for better performance
* @example
* ```javascript
* import { preloadRoutes } from 'sigpro/vite';
*
* // Preload routes after initial load
* preloadRoutes(['/about', '/blog']);
* ```
*/
export function preloadRoutes(paths: string[]): Promise<void>;
/**
* Debug helper to inspect generated routes
* @example
* ```javascript
* // Only in development
* if (import.meta.env.DEV) {
* const routes = await import('virtual:sigpro-routes');
* console.table(routes);
* }
* ```
*/
export function inspectRoutes(): void;
/**
* Virtual module declarations for client-side code
* This allows TypeScript to understand the virtual module
*/
declare module 'virtual:sigpro-routes' {
export const routes: GeneratedRoute[];
}

View File

@@ -3,7 +3,6 @@
* @module sigpro/vite * @module sigpro/vite
*/ */
// ✅ Correcto: importas la función y la llamas como quieras
import sigproRouter from './router.js'; import sigproRouter from './router.js';
/** /**
@@ -24,5 +23,4 @@ import sigproRouter from './router.js';
*/ */
export default sigproRouter; export default sigproRouter;
// Opcional: también exportar como named export
export { sigproRouter }; export { sigproRouter };

1
vite/router.min.js vendored Normal file
View File

@@ -0,0 +1 @@
import fs from"fs";import path from"path";export default function sigproRouter(){const e="virtual:sigpro-routes",r="\0"+e,t=(e,r)=>("/"+path.relative(e,r).replace(/\\/g,"/").replace(/\.(js|jsx)$/,"").replace(/\/index$/,"").replace(/^index$/,"")).replace(/\/+/g,"/").replace(/\[\.\.\.([^\]]+)\]/g,"*").replace(/\[([^\]]+)\]/g,":$1").replace(/\/$/,"")||"/";return{name:"sigpro-router",resolveId(t){if(t===e)return r},load(e){if(e!==r)return;const s=path.resolve(process.cwd(),"src/pages"),n=(o=s,fs.existsSync(o)?fs.readdirSync(o,{recursive:!0}).filter((e=>/\.(js|jsx)$/.test(e)&&!path.basename(e).startsWith("_"))).map((e=>path.resolve(o,e))):[]).sort(((e,r)=>{const n=t(s,e),o=t(s,r);return n.includes(":")&&!o.includes(":")?1:!n.includes(":")&&o.includes(":")?-1:o.length-n.length}));var o;let a="";return n.forEach((e=>{const r=t(s,e),n=e.replace(/\\/g,"/");a+=` { path: '${r}', component: () => import('${n}') },\n`})),a.includes("path: '*'")||(a+=" { path: '*', component: () => span('404 - Not Found') },\n"),`export const routes = [\n${a}];`}}}