From bb1dbd3b0b09f867d8198bdf6dee55490363b307 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Fri, 18 Jul 2025 13:40:07 -0300 Subject: [PATCH] =?UTF-8?q?minifica=C3=A7=C3=A3o=20para=20front?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist-back/logger.js | 2 +- dist-front/index.mjs | 485 +------------------------------------- package.json | 2 +- tsup/tsup.config.front.ts | 2 +- 4 files changed, 4 insertions(+), 487 deletions(-) diff --git a/dist-back/logger.js b/dist-back/logger.js index 0283d3f..8f5983c 100644 --- a/dist-back/logger.js +++ b/dist-back/logger.js @@ -33,7 +33,7 @@ __export(logger_exports, { postLogger: () => postLogger }); module.exports = __toCommonJS(logger_exports); -var import_cross_fetch = __toESM(require("cross-fetch"), 1); +var import_cross_fetch = __toESM(require("cross-fetch")); var import_variaveisComuns = require("./variaveisComuns"); const LOKI_BASE_URL = "https://log.idz.one"; const LOKI_ENDPOINT = "/loki/api/v1/push"; diff --git a/dist-front/index.mjs b/dist-front/index.mjs index 347f76f..1587a58 100644 --- a/dist-front/index.mjs +++ b/dist-front/index.mjs @@ -1,484 +1 @@ -// src/aleatorio.ts -var alfabeto = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""); -var aleatorio = (tamanho) => `eli-${Array.from({ length: tamanho || 8 }).map(() => alfabeto[(999 * Math.random() | 0) % alfabeto.length]).join("")}`; - -// src/cacheMemoria.ts -var _cache = {}; -var cacheM = (chave, valor, validadeSeg) => { - const txChave = typeof chave == "string" ? chave : typeof chave == "number" ? String(chave) : encodeURIComponent(JSON.stringify(chave)); - const validade = validadeSeg && (/* @__PURE__ */ new Date()).getTime() + validadeSeg * 1e3; - if (valor !== void 0) { - _cache[txChave] = { - valor, - validade - }; - } - const busca = _cache[txChave]; - if (busca?.validade && busca.validade < (/* @__PURE__ */ new Date()).getTime()) { - return void 0; - } - return busca?.valor; -}; -var verCacheM = () => _cache; -var cacheMemoria = cacheM; - -// src/constantes.ts -var uuid_null = "00000000-0000-0000-0000-000000000000"; -var camposComuns = /* @__PURE__ */ ((camposComuns2) => { - camposComuns2["codigo"] = "codigo"; - camposComuns2["excluido"] = "excluido"; - camposComuns2["data_hora_criacao"] = "data_hora_criacao"; - camposComuns2["data_hora_atualizacao"] = "data_hora_atualizacao"; - camposComuns2["codigo_usuario_criacao"] = "codigo_usuario_criacao"; - camposComuns2["codigo_usuario_atualizacao"] = "codigo_usuario_atualizacao"; - camposComuns2["versao"] = "versao"; - return camposComuns2; -})(camposComuns || {}); -var tx = /* @__PURE__ */ ((tx2) => { - tx2["token"] = "token"; - return tx2; -})(tx || {}); -var tipoUsuarioResiduos = /* @__PURE__ */ ((tipoUsuarioResiduos2) => { - tipoUsuarioResiduos2["Usuario"] = "usuario"; - tipoUsuarioResiduos2["Fornecedor"] = "fornecedor"; - return tipoUsuarioResiduos2; -})(tipoUsuarioResiduos || {}); - -// src/consulta.ts -var operadores = /* @__PURE__ */ ((operadores2) => { - operadores2["="] = "="; - operadores2["!="] = "!="; - operadores2[">"] = ">"; - operadores2[">="] = ">="; - operadores2["<"] = "<"; - operadores2["<="] = "<="; - operadores2["like"] = "like"; - operadores2["in"] = "in"; - return operadores2; -})(operadores || {}); - -// src/ecosistema/urls.ts -var cdn_carro_de_boi = "https://carro-de-boi-idz-one.b-cdn.net"; - -// src/extensoes.ts -var extensoes = [ - { - ext: "gif", - tipo: "imagem", - mime: "image/gif" - }, - { - ext: "jpg", - tipo: "imagem", - mime: "image/jpeg" - }, - { - ext: "jpeg", - tipo: "imagem", - mime: "image/jpeg" - }, - { - ext: "png", - tipo: "imagem", - mime: "image/png" - }, - { - ext: "bmp", - tipo: "imagem", - mime: "image/bmp" - }, - { - ext: "webp", - tipo: "imagem", - mime: "image/webp" - }, - { - ext: "tiff", - tipo: "imagem", - mime: "image/tiff" - }, - { - ext: "svg", - tipo: "imagem", - mime: "image/svg+xml" - }, - { - ext: "ico", - tipo: "imagem", - mime: "image/x-icon" - }, - { - ext: "pdf", - tipo: "documento", - mime: "application/pdf" - }, - { - ext: "doc", - tipo: "documento", - mime: "application/msword" - }, - { - ext: "docx", - tipo: "documento", - mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" - }, - { - ext: "xls", - tipo: "documento", - mime: "application/vnd.ms-excel" - }, - { - ext: "xlsx", - tipo: "documento", - mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" - }, - { - ext: "ppt", - tipo: "documento", - mime: "application/vnd.ms-powerpoint" - }, - { - ext: "pptx", - tipo: "documento", - mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation" - }, - { - ext: "txt", - tipo: "documento", - mime: "text/plain" - }, - { - ext: "odt", - tipo: "documento", - mime: "application/vnd.oasis.opendocument.text" - }, - { - ext: "ods", - tipo: "documento", - mime: "application/vnd.oasis.opendocument.spreadsheet" - }, - { - ext: "rtf", - tipo: "documento", - mime: "application/rtf" - }, - { - ext: "csv", - tipo: "documento", - mime: "text/csv" - }, - { - ext: "mp4", - tipo: "v\xEDdeo", - mime: "video/mp4" - }, - { - ext: "avi", - tipo: "v\xEDdeo", - mime: "video/x-msvideo" - }, - { - ext: "mkv", - tipo: "v\xEDdeo", - mime: "video/x-matroska" - }, - { - ext: "mov", - tipo: "v\xEDdeo", - mime: "video/quicktime" - }, - { - ext: "wmv", - tipo: "v\xEDdeo", - mime: "video/x-ms-wmv" - }, - { - ext: "flv", - tipo: "v\xEDdeo", - mime: "video/x-flv" - }, - { - ext: "webm", - tipo: "v\xEDdeo", - mime: "video/webm" - }, - { - ext: "3gp", - tipo: "v\xEDdeo", - mime: "video/3gpp" - }, - { - ext: "mpeg", - tipo: "v\xEDdeo", - mime: "video/mpeg" - } -]; -var tipoArquivo = (nomeArquivo) => { - const extArquivo = String(nomeArquivo || "").toLocaleLowerCase().split(".").pop(); - const extensao = extensoes.find((extensao2) => extensao2.ext === extArquivo); - return extensao?.tipo || "outros"; -}; - -// src/logger.ts -import crossFetch from "cross-fetch"; - -// src/variaveisComuns.ts -var esperar = (ms) => new Promise( - (resolve) => setTimeout(() => resolve(true), ms) -); -var nomeVariavel = (v) => Object.keys(v).join("/"); - -// src/logger.ts -var LOKI_BASE_URL = "https://log.idz.one"; -var LOKI_ENDPOINT = "/loki/api/v1/push"; -var postLogger = async ({ - objeto -}) => { - const response = await crossFetch(`${LOKI_BASE_URL}${LOKI_ENDPOINT}`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(objeto) - }).catch((a) => a); - if (!response.ok) { - return [objeto, `Erro ${response.status}: ${await response?.text?.()}`]; - } - return [objeto]; -}; -var cwd = ""; -var defineCwd = (novoCwd) => { - cwd = novoCwd; -}; -var logger = ({ app: app_e, eProducao, parametros: parametrosAmbiente }) => ({ inquilino, usuario, parametros: parametrosSessao }) => async (level, mensagem, op_tipoLog) => { - let { - __filename, - detalhes, - local, - parametros: parametrosLog - } = op_tipoLog || {}; - const app = `${eProducao ? "" : "DEV-"}${app_e}`; - if (cwd && __filename) { - __filename = __filename.replace(cwd, ""); - } - if (local) { - detalhes = [`${nomeVariavel({ local })}="${local}"`, ...detalhes || []]; - } - if (__filename) { - detalhes = [ - `${nomeVariavel({ __filename })}="${__filename}"`, - ...detalhes || [] - ]; - } - const timestamp = `${Date.now()}000000`; - const mainLog = detalhes?.length ? `${mensagem} | ${detalhes.map((d) => JSON.stringify(d)).join(" | ")}` : mensagem; - const payload = { - stream: { - app, - inquilino, - usuario, - level, - ...parametrosAmbiente || {}, - ...parametrosSessao || {}, - ...parametrosLog || {} - }, - values: [ - [ - timestamp, - mainLog - // Linha de log direta - ] - ] - }; - const objeto = { streams: [payload] }; - const response = await postLogger({ objeto }); - return response; -}; - -// src/testes-de-variaveis/umaFuncao.ts -var umaFuncao = () => "Ol\xE1 Mundo! (fun\xE7\xE3o)"; - -// src/testes-de-variaveis/umaVariavel.ts -var umaVariavel = "Ol\xE1 Mundo! (vari\xE1vel)"; - -// src/texto_busca.ts -var texto_busca = (...texto) => texto.map( - (txt) => txt === null || txt === void 0 ? "" : String(txt).normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, " ").toLowerCase() -).join(" "); - -// src/tipagemRotas.ts -var TipagemRotas = class { - /** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial - ** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade") - */ - constructor({ - caminho, - acaoIr - }) { - this._partesCaminho = []; - this._acaoIr = acaoIr; - this._partesCaminho = (Array.isArray(caminho) ? caminho : [caminho]).flatMap((a) => a.split("/")).filter(Boolean); - } - /** Retorna o caminho completo da rota - ** console.log(mCaminho.caminho) - ** "/caminho" - */ - get caminho() { - const ret = `/${this._partesCaminho.join("/")}`; - return ret; - } - /** Define o caminho completo da rota - ** mCaminho.caminho = "/novoCaminho" - ** console.log(mCaminho.caminho) - ** "/novoCaminho" - ** */ - set caminho(caminhoParcial) { - this._partesCaminho = caminhoParcial.split("/").filter((parte) => parte); - } - /** Retorna o caminho completo da rota com a query - ** console.log(mCaminho.resolve({q:"query"})) - ** "http://localhost:3000/caminho?q=query" - */ - endereco(query, usarComoHash) { - const url = new URL( - typeof window !== "undefined" ? window.location.href : "http://localhost" - ); - url.pathname = this.caminho; - url.search = ""; - const queryKeys = Object.entries(query); - for (const [key, value] of queryKeys) { - url.searchParams.set( - String(key), - value === void 0 || value === null ? "" : value - ); - } - url.hash = ""; - if (usarComoHash) { - url.hash = `#${url.search}`; - url.search = ""; - } - return url.href; - } - /** Vai para a url - ** mCaminho.ir({q:"query"}) - ** window.location.href = "http://localhost:3000/caminho?q=query" - */ - ir(query) { - if (this._acaoIr) { - this._acaoIr(this.endereco(query)); - } else { - if (typeof window != "undefined") { - window.location.href = this.endereco(query); - } - } - } - /** Retorna os parametros da url - ** console.log(mCaminho.parametros()) - ** {q:"query"} - */ - get parametros() { - const url = new URL( - typeof window !== "undefined" ? window.location.href : "http://localhost" - ); - const query = url.searchParams; - const queryObj = Object.fromEntries(query.entries()); - const hash = url.hash; - if (hash) { - const hashObj = Object.fromEntries( - new URLSearchParams(hash.slice(1)).entries() - ); - return { ...queryObj, ...hashObj }; - } - return queryObj; - } -}; - -// src/unidades_medida.ts -var siglas_unidades_medida = /* @__PURE__ */ ((siglas_unidades_medida2) => { - siglas_unidades_medida2["UN"] = "UN"; - siglas_unidades_medida2["KG"] = "KG"; - siglas_unidades_medida2["TON"] = "TON"; - siglas_unidades_medida2["g"] = "g"; - siglas_unidades_medida2["M\xB3"] = "M\xB3"; - siglas_unidades_medida2["Lt"] = "Lt"; - return siglas_unidades_medida2; -})(siglas_unidades_medida || {}); -var unidades_medida = [ - { - sigla_unidade: "KG", - nome: "Quilograma", - sigla_normalizada: "KG", - normalizar: (valor) => valor, - tipo: "massa" - }, - { - sigla_unidade: "g", - nome: "Grama", - sigla_normalizada: "KG", - normalizar: (valor) => valor / 1e3, - tipo: "massa" - }, - { - sigla_unidade: "TON", - nome: "Tonelada", - sigla_normalizada: "KG", - normalizar: (valor) => valor * 1e3, - tipo: "massa" - }, - { - sigla_unidade: "Lt", - nome: "Litro", - sigla_normalizada: "Lt", - normalizar: (valor) => valor, - tipo: "volume" - }, - { - sigla_unidade: "M\xB3", - nome: "Metro C\xFAbico", - sigla_normalizada: "Lt", - normalizar: (valor) => valor * 1e3, - tipo: "volume" - }, - { - sigla_unidade: "UN", - nome: "Unidade", - sigla_normalizada: "UN", - normalizar: (valor) => valor, - tipo: "unidade" - } -]; - -// src/uuid.ts -var letras = "0123456789abcdef".split(""); -var uuid = () => { - letras.sort(() => Math.random() - 0.5); - const modelo = "xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx".split(""); - const retorno = modelo.map( - (letra) => letra === "x" ? letras[(1e3 * Math.random() | 0) % letras.length] : letra - ).join(""); - return retorno; -}; -export { - TipagemRotas, - aleatorio, - cacheM, - cacheMemoria, - camposComuns, - cdn_carro_de_boi, - defineCwd, - esperar, - extensoes, - logger, - nomeVariavel, - operadores, - postLogger, - siglas_unidades_medida, - texto_busca, - tipoArquivo, - tipoUsuarioResiduos, - tx, - umaFuncao, - umaVariavel, - unidades_medida, - uuid, - uuid_null, - verCacheM -}; +var u="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),K=e=>`eli-${Array.from({length:e||8}).map(()=>u[(999*Math.random()|0)%u.length]).join("")}`;var d={},k=(e,o,t)=>{let i=typeof e=="string"?e:typeof e=="number"?String(e):encodeURIComponent(JSON.stringify(e)),a=t&&new Date().getTime()+t*1e3;o!==void 0&&(d[i]={valor:o,validade:a});let r=d[i];if(!(r?.validade&&r.validaded,G=k;var E="00000000-0000-0000-0000-000000000000",O=(n=>(n.codigo="codigo",n.excluido="excluido",n.data_hora_criacao="data_hora_criacao",n.data_hora_atualizacao="data_hora_atualizacao",n.codigo_usuario_criacao="codigo_usuario_criacao",n.codigo_usuario_atualizacao="codigo_usuario_atualizacao",n.versao="versao",n))(O||{}),j=(o=>(o.token="token",o))(j||{}),z=(t=>(t.Usuario="usuario",t.Fornecedor="fornecedor",t))(z||{});var T=(t=>(t["="]="=",t["!="]="!=",t[">"]=">",t[">="]=">=",t["<"]="<",t["<="]="<=",t.like="like",t.in="in",t))(T||{});var J="https://carro-de-boi-idz-one.b-cdn.net";var $=[{ext:"gif",tipo:"imagem",mime:"image/gif"},{ext:"jpg",tipo:"imagem",mime:"image/jpeg"},{ext:"jpeg",tipo:"imagem",mime:"image/jpeg"},{ext:"png",tipo:"imagem",mime:"image/png"},{ext:"bmp",tipo:"imagem",mime:"image/bmp"},{ext:"webp",tipo:"imagem",mime:"image/webp"},{ext:"tiff",tipo:"imagem",mime:"image/tiff"},{ext:"svg",tipo:"imagem",mime:"image/svg+xml"},{ext:"ico",tipo:"imagem",mime:"image/x-icon"},{ext:"pdf",tipo:"documento",mime:"application/pdf"},{ext:"doc",tipo:"documento",mime:"application/msword"},{ext:"docx",tipo:"documento",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},{ext:"xls",tipo:"documento",mime:"application/vnd.ms-excel"},{ext:"xlsx",tipo:"documento",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},{ext:"ppt",tipo:"documento",mime:"application/vnd.ms-powerpoint"},{ext:"pptx",tipo:"documento",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"},{ext:"txt",tipo:"documento",mime:"text/plain"},{ext:"odt",tipo:"documento",mime:"application/vnd.oasis.opendocument.text"},{ext:"ods",tipo:"documento",mime:"application/vnd.oasis.opendocument.spreadsheet"},{ext:"rtf",tipo:"documento",mime:"application/rtf"},{ext:"csv",tipo:"documento",mime:"text/csv"},{ext:"mp4",tipo:"v\xEDdeo",mime:"video/mp4"},{ext:"avi",tipo:"v\xEDdeo",mime:"video/x-msvideo"},{ext:"mkv",tipo:"v\xEDdeo",mime:"video/x-matroska"},{ext:"mov",tipo:"v\xEDdeo",mime:"video/quicktime"},{ext:"wmv",tipo:"v\xEDdeo",mime:"video/x-ms-wmv"},{ext:"flv",tipo:"v\xEDdeo",mime:"video/x-flv"},{ext:"webm",tipo:"v\xEDdeo",mime:"video/webm"},{ext:"3gp",tipo:"v\xEDdeo",mime:"video/3gpp"},{ext:"mpeg",tipo:"v\xEDdeo",mime:"video/mpeg"}],H=e=>{let o=String(e||"").toLocaleLowerCase().split(".").pop();return $.find(i=>i.ext===o)?.tipo||"outros"};import M from"cross-fetch";var X=e=>new Promise(o=>setTimeout(()=>o(!0),e)),l=e=>Object.keys(e).join("/");var N="https://log.idz.one",S="/loki/api/v1/push",P=async({objeto:e})=>{let o=await M(`${N}${S}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(t=>t);return o.ok?[e]:[e,`Erro ${o.status}: ${await o?.text?.()}`]},x="",oe=e=>{x=e},te=({app:e,eProducao:o,parametros:t})=>({inquilino:i,usuario:a,parametros:r})=>async(p,n,v)=>{let{__filename:m,detalhes:s,local:c,parametros:h}=v||{},b=`${o?"":"DEV-"}${e}`;x&&m&&(m=m.replace(x,"")),c&&(s=[`${l({local:c})}="${c}"`,...s||[]]),m&&(s=[`${l({__filename:m})}="${m}"`,...s||[]]);let _=`${Date.now()}000000`,y=s?.length?`${n} | ${s.map(w=>JSON.stringify(w)).join(" | ")}`:n,L={streams:[{stream:{app:b,inquilino:i,usuario:a,level:p,...t||{},...r||{},...h||{}},values:[[_,y]]}]};return await P({objeto:L})};var re=()=>"Ol\xE1 Mundo! (fun\xE7\xE3o)";var ae="Ol\xE1 Mundo! (vari\xE1vel)";var de=(...e)=>e.map(o=>o==null?"":String(o).normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g," ").toLowerCase()).join(" ");var f=class{constructor({caminho:o,acaoIr:t}){this._partesCaminho=[];this._acaoIr=t,this._partesCaminho=(Array.isArray(o)?o:[o]).flatMap(i=>i.split("/")).filter(Boolean)}get caminho(){return`/${this._partesCaminho.join("/")}`}set caminho(o){this._partesCaminho=o.split("/").filter(t=>t)}endereco(o,t){let i=new URL(typeof window<"u"?window.location.href:"http://localhost");i.pathname=this.caminho,i.search="";let a=Object.entries(o);for(let[r,p]of a)i.searchParams.set(String(r),p??"");return i.hash="",t&&(i.hash=`#${i.search}`,i.search=""),i.href}ir(o){this._acaoIr?this._acaoIr(this.endereco(o)):typeof window<"u"&&(window.location.href=this.endereco(o))}get parametros(){let o=new URL(typeof window<"u"?window.location.href:"http://localhost"),t=o.searchParams,i=Object.fromEntries(t.entries()),a=o.hash;if(a){let r=Object.fromEntries(new URLSearchParams(a.slice(1)).entries());return{...i,...r}}return i}};var q=(r=>(r.UN="UN",r.KG="KG",r.TON="TON",r.g="g",r["M\xB3"]="M\xB3",r.Lt="Lt",r))(q||{}),ge=[{sigla_unidade:"KG",nome:"Quilograma",sigla_normalizada:"KG",normalizar:e=>e,tipo:"massa"},{sigla_unidade:"g",nome:"Grama",sigla_normalizada:"KG",normalizar:e=>e/1e3,tipo:"massa"},{sigla_unidade:"TON",nome:"Tonelada",sigla_normalizada:"KG",normalizar:e=>e*1e3,tipo:"massa"},{sigla_unidade:"Lt",nome:"Litro",sigla_normalizada:"Lt",normalizar:e=>e,tipo:"volume"},{sigla_unidade:"M\xB3",nome:"Metro C\xFAbico",sigla_normalizada:"Lt",normalizar:e=>e*1e3,tipo:"volume"},{sigla_unidade:"UN",nome:"Unidade",sigla_normalizada:"UN",normalizar:e=>e,tipo:"unidade"}];var g="0123456789abcdef".split(""),fe=()=>(g.sort(()=>Math.random()-.5),"xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx".split("").map(t=>t==="x"?g[(1e3*Math.random()|0)%g.length]:t).join(""));export{f as TipagemRotas,K as aleatorio,k as cacheM,G as cacheMemoria,O as camposComuns,J as cdn_carro_de_boi,oe as defineCwd,X as esperar,$ as extensoes,te as logger,l as nomeVariavel,T as operadores,P as postLogger,q as siglas_unidades_medida,de as texto_busca,H as tipoArquivo,z as tipoUsuarioResiduos,j as tx,re as umaFuncao,ae as umaVariavel,ge as unidades_medida,fe as uuid,E as uuid_null,C as verCacheM}; diff --git a/package.json b/package.json index 5194728..2204780 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-comuns", - "version": "0.202.0", + "version": "0.203.0", "description": "", "main": "./dist-back/index.js", "module": "./dist-front/index.mjs", diff --git a/tsup/tsup.config.front.ts b/tsup/tsup.config.front.ts index c015ab3..56ade55 100644 --- a/tsup/tsup.config.front.ts +++ b/tsup/tsup.config.front.ts @@ -14,7 +14,7 @@ export const tsup_config_front: Options = { dts: false, // Não gera arquivos de declaração TypeScript (.d.ts) para uso em front-end JS // legacyOutput e outExtension foram removidos por não serem necessários sourcemap: false, - minify: false, // Recomendado para builds de produção + minify: true, // Recomendado para builds de produção platform: "browser", outExtension: () => ({ js: ".mjs" }), }