Clean Code include src folder
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 4s
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 4s
This commit is contained in:
8
dist/sigpro.esm.js
vendored
8
dist/sigpro.esm.js
vendored
@@ -1,4 +1,4 @@
|
||||
// sigpro.js
|
||||
// src/sigpro.js
|
||||
var isFunc = (f) => typeof f === "function";
|
||||
var isObj = (o) => o && typeof o === "object";
|
||||
var isArr = Array.isArray;
|
||||
@@ -224,7 +224,7 @@ var watch = (sources, cb) => {
|
||||
return () => dispose(effect2);
|
||||
}
|
||||
const effect = createEffect(() => {
|
||||
const vals = Array.isArray(sources) ? sources.map((s) => s()) : sources();
|
||||
const vals = isArr(sources) ? sources.map((s) => s()) : sources();
|
||||
untrack(() => cb(vals));
|
||||
});
|
||||
effect();
|
||||
@@ -250,10 +250,8 @@ var validateAttr = (key, val) => {
|
||||
return null;
|
||||
if (isDangerousAttr(key)) {
|
||||
const sVal = String(val);
|
||||
if (DANGEROUS_PROTOCOL.test(sVal)) {
|
||||
console.warn(`[SigPro] Bloqueado protocolo peligroso en ${key}`);
|
||||
if (DANGEROUS_PROTOCOL.test(sVal))
|
||||
return "#";
|
||||
}
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
2
dist/sigpro.esm.min.js
vendored
2
dist/sigpro.esm.min.js
vendored
File diff suppressed because one or more lines are too long
10
dist/sigpro.js
vendored
10
dist/sigpro.js
vendored
@@ -1,5 +1,5 @@
|
||||
(() => {
|
||||
// sigpro.js
|
||||
// src/sigpro.js
|
||||
var isFunc = (f) => typeof f === "function";
|
||||
var isObj = (o) => o && typeof o === "object";
|
||||
var isArr = Array.isArray;
|
||||
@@ -225,7 +225,7 @@
|
||||
return () => dispose(effect2);
|
||||
}
|
||||
const effect = createEffect(() => {
|
||||
const vals = Array.isArray(sources) ? sources.map((s) => s()) : sources();
|
||||
const vals = isArr(sources) ? sources.map((s) => s()) : sources();
|
||||
untrack(() => cb(vals));
|
||||
});
|
||||
effect();
|
||||
@@ -251,10 +251,8 @@
|
||||
return null;
|
||||
if (isDangerousAttr(key)) {
|
||||
const sVal = String(val);
|
||||
if (DANGEROUS_PROTOCOL.test(sVal)) {
|
||||
console.warn(`[SigPro] Bloqueado protocolo peligroso en ${key}`);
|
||||
if (DANGEROUS_PROTOCOL.test(sVal))
|
||||
return "#";
|
||||
}
|
||||
}
|
||||
return val;
|
||||
};
|
||||
@@ -520,7 +518,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
// sigpro_umd.js
|
||||
// src/build_umd.js
|
||||
if (typeof window !== "undefined") {
|
||||
Object.assign(window, { $, $$, watch, h, Fragment, when, each, router, mount, batch, onUnmount, isArr, isFunc, isObj });
|
||||
}
|
||||
|
||||
2
dist/sigpro.min.js
vendored
2
dist/sigpro.min.js
vendored
File diff suppressed because one or more lines are too long
0
vite/index.js → dist/vite.js
vendored
0
vite/index.js → dist/vite.js
vendored
@@ -1,5 +1,5 @@
|
||||
(() => {
|
||||
// sigpro.js
|
||||
// src/sigpro.js
|
||||
var isFunc = (f) => typeof f === "function";
|
||||
var isObj = (o) => o && typeof o === "object";
|
||||
var isArr = Array.isArray;
|
||||
@@ -225,7 +225,7 @@
|
||||
return () => dispose(effect2);
|
||||
}
|
||||
const effect = createEffect(() => {
|
||||
const vals = Array.isArray(sources) ? sources.map((s) => s()) : sources();
|
||||
const vals = isArr(sources) ? sources.map((s) => s()) : sources();
|
||||
untrack(() => cb(vals));
|
||||
});
|
||||
effect();
|
||||
@@ -251,10 +251,8 @@
|
||||
return null;
|
||||
if (isDangerousAttr(key)) {
|
||||
const sVal = String(val);
|
||||
if (DANGEROUS_PROTOCOL.test(sVal)) {
|
||||
console.warn(`[SigPro] Bloqueado protocolo peligroso en ${key}`);
|
||||
if (DANGEROUS_PROTOCOL.test(sVal))
|
||||
return "#";
|
||||
}
|
||||
}
|
||||
return val;
|
||||
};
|
||||
@@ -520,7 +518,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
// sigpro_umd.js
|
||||
// src/build_umd.js
|
||||
if (typeof window !== "undefined") {
|
||||
Object.assign(window, { $, $$, watch, h, Fragment, when, each, router, mount, batch, onUnmount, isArr, isFunc, isObj });
|
||||
}
|
||||
|
||||
26
package.json
26
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sigpro",
|
||||
"version": "1.2.32",
|
||||
"version": "1.2.35",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
@@ -19,12 +19,12 @@
|
||||
"script": "./dist/sigpro.min.js",
|
||||
"types": "./sigpro.d.ts"
|
||||
},
|
||||
"./vite": "./vite/index.js",
|
||||
"./vite/*": "./vite/*.js"
|
||||
"./vite": {
|
||||
"import": "./dist/vite.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist/",
|
||||
"vite/",
|
||||
"README.md",
|
||||
"LICENSE",
|
||||
"sigpro.d.ts"
|
||||
@@ -39,21 +39,22 @@
|
||||
"email": "sigpro@natxocc.com"
|
||||
},
|
||||
"scripts": {
|
||||
"del": "bun pm cache rm && rm -f bun.lockb && rm -f bun.lock",
|
||||
"clean": "rm -rf dist",
|
||||
"prebuild": "npm run clean",
|
||||
"build:iife": "bun build ./sigpro_umd.js --bundle --outfile=./dist/sigpro.js --format=iife --global-name=sp",
|
||||
"build:iife:min": "bun build ./sigpro_umd.js --bundle --outfile=./dist/sigpro.min.js --format=iife --global-name=sp --minify",
|
||||
"build:esm": "bun build ./sigpro.js --bundle --outfile=./dist/sigpro.esm.js --format=esm",
|
||||
"build:esm:min": "bun build ./sigpro.js --bundle --outfile=./dist/sigpro.esm.min.js --format=esm --minify",
|
||||
"build:docs": "bun build ./sigpro_umd.js --bundle --outfile=./docs/sigpro.js --format=iife --global-name=sp",
|
||||
"build": "bun run build:iife && bun run build:iife:min && bun run build:esm && bun run build:esm:min && bun run build:docs",
|
||||
"docs": "bun x serve docs",
|
||||
"prepublishOnly": "npm run build"
|
||||
"build:iife": "bun build ./src/build_umd.js --bundle --outfile=./dist/sigpro.js --format=iife --global-name=sp",
|
||||
"build:iife:min": "bun build ./src/build_umd.js --bundle --outfile=./dist/sigpro.min.js --format=iife --global-name=sp --minify",
|
||||
"build:esm": "bun build ./src/sigpro.js --bundle --outfile=./dist/sigpro.esm.js --format=esm",
|
||||
"build:esm:min": "bun build ./src/sigpro.js --bundle --outfile=./dist/sigpro.esm.min.js --format=esm --minify",
|
||||
"build:copy": "cp ./src/vite.js ./dist/vite.js && cp ./dist/sigpro.js ./docs/sigpro.js",
|
||||
"build": "bun run build:iife && bun run build:iife:min && bun run build:esm && bun run build:esm:min && bun run build:copy",
|
||||
"docs": "bun x serve docs"
|
||||
},
|
||||
"keywords": [
|
||||
"signals",
|
||||
"reactivity",
|
||||
"reactive",
|
||||
"pure",
|
||||
"vanilla",
|
||||
"js",
|
||||
"ui",
|
||||
@@ -62,7 +63,6 @@
|
||||
"frontend",
|
||||
"spa",
|
||||
"lightweight",
|
||||
"no-vdom",
|
||||
"sigpro"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { h } from '../sigpro.js';
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
'a abbr article aside audio b blockquote br button canvas caption cite code col colgroup datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hr i iframe img input ins kbd label legend li main mark meter nav object ol optgroup option output p picture pre progress section select slot small source span strong sub summary sup svg table tbody td template textarea tfoot th thead time tr u ul video'
|
||||
.split(' ').forEach(tag => {
|
||||
window[tag] = (props, children) => h(tag, props, children);
|
||||
// window[tag] = (...args) => h(tag, ...args);
|
||||
});
|
||||
console.log('SigPro tags ready');
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { filterXSS } from '../sigpro.js';
|
||||
|
||||
const DANGEROUS_PROTOCOL = /^\s*(javascript|data|vbscript):/i;
|
||||
const DANGEROUS_URI_ATTRS = new Set(["src", "href", "formaction", "action", "background", "code", "archive"]);
|
||||
const isDangerousAttr = key => DANGEROUS_URI_ATTRS.has(key) || key.startsWith("on");
|
||||
|
||||
const validateAttr = (key, val) => {
|
||||
if (val == null || val === false) return null;
|
||||
if (isDangerousAttr(key)) {
|
||||
const sVal = String(val);
|
||||
if (DANGEROUS_PROTOCOL.test(sVal)) {
|
||||
console.warn(`[SigPro XSS] Locked ${key}`);
|
||||
return '#';
|
||||
}
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
filterXSS(validateAttr);
|
||||
@@ -213,7 +213,7 @@ const watch = (sources, cb) => {
|
||||
return () => dispose(effect)
|
||||
}
|
||||
const effect = createEffect(() => {
|
||||
const vals = Array.isArray(sources) ? sources.map(s => s()) : sources()
|
||||
const vals = isArr(sources) ? sources.map(s => s()) : sources()
|
||||
untrack(() => cb(vals))
|
||||
})
|
||||
effect()
|
||||
@@ -238,10 +238,7 @@ const validateAttr = (key, val) => {
|
||||
if (val == null || val === false) return null
|
||||
if (isDangerousAttr(key)) {
|
||||
const sVal = String(val)
|
||||
if (DANGEROUS_PROTOCOL.test(sVal)) {
|
||||
console.warn(`[SigPro] Bloqueado protocolo peligroso en ${key}`)
|
||||
return '#'
|
||||
}
|
||||
if (DANGEROUS_PROTOCOL.test(sVal)) return '#'
|
||||
}
|
||||
return val
|
||||
}
|
||||
77
src/vite.js
Normal file
77
src/vite.js
Normal file
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* SigPro Vite Plugin - File-based Routing
|
||||
* @module sigpro/vite
|
||||
*/
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
export default function sigproRouter() {
|
||||
const virtualModuleId = 'virtual:sigpro-routes';
|
||||
const resolvedVirtualModuleId = '\0' + virtualModuleId;
|
||||
|
||||
// Helper para escanear archivos
|
||||
const getFiles = (dir) => {
|
||||
if (!fs.existsSync(dir)) return [];
|
||||
return fs.readdirSync(dir, { recursive: true })
|
||||
.filter(file => /\.(js|jsx)$/.test(file) && !path.basename(file).startsWith('_'))
|
||||
.map(file => path.resolve(dir, file));
|
||||
};
|
||||
|
||||
// Transformador de ruta de archivo a URL de router
|
||||
const pathToUrl = (pagesDir, filePath) => {
|
||||
let relative = path.relative(pagesDir, filePath)
|
||||
.replace(/\\/g, '/')
|
||||
.replace(/\.(js|jsx)$/, '')
|
||||
.replace(/\/index$/, '')
|
||||
.replace(/^index$/, '');
|
||||
|
||||
return ('/' + relative)
|
||||
.replace(/\/+/g, '/')
|
||||
.replace(/\[\.\.\.([^\]]+)\]/g, '*')
|
||||
.replace(/\[([^\]]+)\]/g, ':$1')
|
||||
.replace(/\/$/, '') || '/';
|
||||
};
|
||||
|
||||
return {
|
||||
name: 'sigpro-router',
|
||||
|
||||
resolveId(id) {
|
||||
if (id === virtualModuleId) return resolvedVirtualModuleId;
|
||||
},
|
||||
|
||||
load(id) {
|
||||
if (id !== resolvedVirtualModuleId) return;
|
||||
|
||||
const root = process.cwd();
|
||||
const pagesDir = path.resolve(root, 'src/pages');
|
||||
|
||||
// Obtenemos y ordenamos archivos (rutas estáticas primero, luego dinámicas)
|
||||
const files = getFiles(pagesDir).sort((a, b) => {
|
||||
const urlA = pathToUrl(pagesDir, a);
|
||||
const urlB = pathToUrl(pagesDir, b);
|
||||
if (urlA.includes(':') && !urlB.includes(':')) return 1;
|
||||
if (!urlA.includes(':') && urlB.includes(':')) return -1;
|
||||
return urlB.length - urlA.length;
|
||||
});
|
||||
|
||||
let routeEntries = '';
|
||||
|
||||
files.forEach((fullPath) => {
|
||||
const urlPath = pathToUrl(pagesDir, fullPath);
|
||||
// Hacemos la ruta relativa al proyecto para que el import de Vite sea limpio
|
||||
const relativeImport = './' + path.relative(root, fullPath).replace(/\\/g, '/');
|
||||
|
||||
routeEntries += ` { path: '${urlPath}', component: async () => (await import('/${relativeImport}')).default },\n`;
|
||||
});
|
||||
|
||||
// Fallback 404 si no existe una ruta comodín
|
||||
if (!routeEntries.includes("path: '*'")) {
|
||||
routeEntries += ` { path: '*', component: () => document.createTextNode('404 - Not Found') },\n`;
|
||||
}
|
||||
|
||||
return `export const routes = [\n${routeEntries}];`;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export { sigproRouter };
|
||||
Reference in New Issue
Block a user