diff --git a/.nvmrc b/.nvmrc index 03191c9..39d00c0 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -18.0.0 \ No newline at end of file +18.17.0 \ No newline at end of file diff --git a/gateway/config/flags.js b/gateway/config/flags.js index 4d62690..00f45a7 100644 --- a/gateway/config/flags.js +++ b/gateway/config/flags.js @@ -2,6 +2,8 @@ const envConfig = document.getElementById("env-config").textContent; const config = JSON.parse(envConfig); export const flags = { + mainWidgetSrc: config.mainWidgetSrc, + mainWidgetLink: config.mainWidgetLink, network: process.env.NETWORK || config.network || "mainnet", bosLoaderUrl: process.env.BOS_LOADER_URL || diff --git a/gateway/src/index.js b/gateway/src/index.js index 83cdeb9..2d6e16a 100644 --- a/gateway/src/index.js +++ b/gateway/src/index.js @@ -75,6 +75,12 @@ function Home() { const { components: redirectMap } = useRedirectMap(); const widgets = {}; + // Force going to the main widget src (indexer) + if (location.pathname === "/" && flags.mainWidgetSrc) { + navigate(flags.mainWidgetSrc); + return ""; + } + Object.keys(redirectMap).forEach((key) => { const parts = key.split("/widget/"); if (!widgets[parts[0]]) { diff --git a/gateway/src/navigation/NavigationWrapper.js b/gateway/src/navigation/NavigationWrapper.js index 467c7aa..543263b 100644 --- a/gateway/src/navigation/NavigationWrapper.js +++ b/gateway/src/navigation/NavigationWrapper.js @@ -2,6 +2,7 @@ import React from "react"; import styled from "styled-components"; import { Link } from "react-router-dom"; import logo from "../assets/near-script-logo-white.png"; +import { flags } from "../../config/flags"; const StyledNavigation = styled.div` position: sticky; @@ -59,7 +60,7 @@ export function NavigationWrapper(props) {
{ + // NOTE: Checa se tem "as stateful", se tiver, deve ser tratado como um Widget/Stateful + const hasAsStatefulType = + content.includes('"as stateful"') || content.includes("'as stateful'"); + + if (hasAsStatefulType) { + content = content.replace('"as stateful";', ""); + content = content.replace("'as stateful';", ""); + content = content.replace('"as stateful"', ""); + content = content.replace("'as stateful'", ""); + + return { + updatedContent: removeBlankLines(content), + asStatefulSignalFound: true, + }; + } + + return { + updatedContent: content, + asStatefulSignalFound: false, + }; +}; + +module.exports = asStatefulCheck; diff --git a/lib/actions/getProjectName.js b/lib/actions/getProjectName.js new file mode 100644 index 0000000..134dc89 --- /dev/null +++ b/lib/actions/getProjectName.js @@ -0,0 +1,22 @@ +const { read_alem_config } = require("../config"); + +/** + * Get the project name based on configuration + * @returns + */ +const getProjectName = (skipCheckers = false) => { + const appConfig = read_alem_config(); + let projectName = appConfig.name.replaceAll(" ", "-").toLowerCase(); + + // Se ignorar a checagem do nome final do projeto + if (skipCheckers) { + return projectName; + } + + projectName = appConfig.isIndex ? "Index" : projectName; + return appConfig.options?.createLoaderWidget + ? `${projectName}Loader` + : projectName; +}; + +module.exports = getProjectName; diff --git a/lib/actions/loadFilesContent.js b/lib/actions/loadFilesContent.js index 0445176..ff66e1f 100644 --- a/lib/actions/loadFilesContent.js +++ b/lib/actions/loadFilesContent.js @@ -1,5 +1,6 @@ const parseAlemFeatures = require("../config/parseAlemFeatures"); const { scapeBacktick } = require("../helpers"); +const getProjectName = require("./getProjectName"); const transformSchemaToWidget = require("./transformSchemaToWidget"); /** @@ -7,7 +8,7 @@ const transformSchemaToWidget = require("./transformSchemaToWidget"); * @param {{filePath: string, toImport: string[], content: string}[]} fileSchemas * the process starts. This is util to inject previous schema files like Além importable items. */ -const loadComponentCodesObjectByFileSchemas = (fileSchemas) => { +const loadComponentCodesObjectByFileSchemas = (fileSchemas, network) => { let componentsCodes = ""; /** @@ -19,21 +20,40 @@ const loadComponentCodesObjectByFileSchemas = (fileSchemas) => { fileSchemas = fileSchemas.reverse(); // Get Normal js files & Widget files (components transformed to BOS Widgets) - const completeFileSchemas = transformSchemaToWidget(fileSchemas); + const completeFileSchemas = transformSchemaToWidget(fileSchemas, network); // Processa também os módulos let modulesCodes = ""; + // Ejected Files Codes + let ejectedFiles = []; + completeFileSchemas.fileSchemas.forEach((fileSchema) => { // Prepare Widgets (stateful components) - if (fileSchema.widgetName && !fileSchema.isStateless) { + if ( + fileSchema.widgetName && + !fileSchema.isStateless && + !fileSchema.toBeEjected + ) { componentsCodes += ` ${fileSchema.widgetName}: \`${scapeBacktick(fileSchema.finalFileBundle)}\`, `; } + // Ejectables - Arquivos a serem criado fora do indexador principal + if (fileSchema.toBeEjected) { + // O nome do projeto deve vir na frente para evitar conflitos com outros + // aplicativos publicados na mesma conta + const newWidgetName = `${getProjectName(true)}.${fileSchema.widgetName}`; + + ejectedFiles.push({ + name: newWidgetName, + content: fileSchema.finalFileBundle, + }); + } + // Prepare modules - if (fileSchema.isModule) { + if (fileSchema.isModule && !fileSchema.toBeEjected) { // let modulesValues = "{"; // const valuesEntries = Object.entries(fileSchema.moduleProps.values); // valuesEntries.forEach((entrie) => { @@ -62,6 +82,8 @@ const loadComponentCodesObjectByFileSchemas = (fileSchemas) => { componentsCodes, /** Código final de todos os módulos. Eles serão inseridos no escopo global e disponível para todos os subcomponents */ modulesCodes, + /** Lista de objetos (de arquivos ejetados e serem salvos separadamente) contento {name: nome da pagina/arquivo/widget, content: conteúdo do arquivo processado} */ + ejectedFiles, /** Código final do componente App de entrada do projet apenas. (src/index.tsx | .jsx) */ appComponentFinalBundle, /** Esquema final de todos os arquivos processados */ diff --git a/lib/actions/loadFilesInfo.js b/lib/actions/loadFilesInfo.js index ecfa12c..df81320 100644 --- a/lib/actions/loadFilesInfo.js +++ b/lib/actions/loadFilesInfo.js @@ -15,6 +15,7 @@ const filesContentCache = require("../config/filesContentCache"); const replaceRegexWithReferences = require("../parsers/regex-parser/convertRegexToStringLiteral"); const regexObjects = require("../parsers/regex-parser/regexObjects"); const prepareAlemDependencies = require("./prepareAlemDependencies"); +const processImportsToBase64 = require("../parsers/processImportsToBase64"); // const extractTopLevelDeclarations = require("../parsers/extractTopLevelDeclarations"); /** * Transform statefull components references to JSX (this applies for stateful and stateless components) @@ -150,6 +151,7 @@ const processFileSchema = (filePath, processOnlyThisFile) => { content: fileContent, isModule: false, moduleProps: {}, + base64Images: [], }; fileImportsPath.forEach((importPath) => { @@ -198,21 +200,58 @@ const processFileSchema = (filePath, processOnlyThisFile) => { } }); - // Transform statefull components references to JSX - currentFileSchema = replaceStatefulReferencesToJSX(currentFileSchema); - - // Push current schema result - contentOrderer.push(currentFileSchema); + const finalize = () => { + // Transform statefull components references to JSX + currentFileSchema = replaceStatefulReferencesToJSX(currentFileSchema); + + // Push current schema result + contentOrderer.push(currentFileSchema); + + if (!processOnlyThisFile) { + // Recursividade + currentFileSchema.nextFilesToLoad.forEach((fileToImport) => { + // Nao pode ser um recurso do alem-vm + // if (!fileToImport.includes(ALEM_VM_FOLDER)) { + processFileSchema(fileToImport); + // } + }); + } + }; - if (!processOnlyThisFile) { - // Recursividade - currentFileSchema.nextFilesToLoad.forEach((fileToImport) => { - // Nao pode ser um recurso do alem-vm - // if (!fileToImport.includes(ALEM_VM_FOLDER)) { - processFileSchema(fileToImport); - // } - }); - } + // Note: Chamando diretamente pois o processo de transformar imagem para base64 + // ainda nao esta completo + finalize(); + + /** + * TODO: Terminar a implantação. No momento, está usando async e como o metodo "processFileSchema" + * é sync, ele continua antes de acabar o processo abaixo async. Deve-se transformar o processFilesSchema + * em async e espelhar isso em todos os recursos que o usa. + * + * "processImportsToBase64" abaixo retorna uma lista de + * {imageKey: "nome do import da imagem", imageBase64Content: "conteúdo base64 da imagem"} + * + * Esses dados devem ser usados posteriormente: + * 1 - Inserir um const no topo do arquivo (para stateful) ou + * 1.1 - Inserir um const na primeira linha após o início da função (para stateless) + * 2 - esse const inserido tem o nome da "imageKey" e seu valor é o "imageBase64Content" + * + * Configuraçao (alem.config.json): + * options: { + * base64Images: { + * enabled: false, + * quality: 80, // aqui é fator de no máximo 100 + * } + * } + */ + + // processImportsToBase64(fileContent, filePath, 80) + // .then((data) => { + // if (data.length > 0) { + // currentFileSchema.base64Images = data; + // } + // finalize(); + // }) + // .catch(finalize); }; /** diff --git a/lib/actions/processChildrenWidget.js b/lib/actions/processChildrenWidget.js index e1a1590..3b12182 100644 --- a/lib/actions/processChildrenWidget.js +++ b/lib/actions/processChildrenWidget.js @@ -7,6 +7,7 @@ const extractJSXChildren = require("../parsers/extractJSXChildren"); const extractPropsFromJSX = require("../parsers/extractPropsFromJSX"); const extractTopLevelJSXElements = require("../parsers/extractTopLevelJSXElements"); const replaceJSXElement = require("../parsers/replaceJSXElement"); +const getProjectName = require("./getProjectName"); /** * Usado para remover o endChar do texto se o endChar for a última caractere no texto @@ -33,7 +34,7 @@ function removeEndCharacter(text, endChar) { * * @param {string} htmlContent */ -const processChildrenWidget = (htmlContent, fileSchemas) => { +const processChildrenWidget = (htmlContent, fileSchemas, account) => { const componentElements = extractTopLevelJSXElements(htmlContent); const finalElements = []; @@ -71,12 +72,33 @@ const processChildrenWidget = (htmlContent, fileSchemas) => { htmlElement = `const TempMethod = () => { return ${htmlElement} \n}`; - htmlElement = replaceJSXElement( - htmlElement, - componentElementName, - 0, - ``, - ); + if (componentSchema.toBeEjected) { + // O nome do projeto deve vir na frente para evitar conflitos com outros + // aplicativos publicados na mesma conta + const newWidgetName = `${getProjectName(true)}.${componentElementName}`; + const src = `"${account}/widget/${newWidgetName}"`; + + htmlElement = replaceJSXElement( + htmlElement, + componentElementName, + 0, + ``, + ); + } else { + htmlElement = replaceJSXElement( + htmlElement, + componentElementName, + 0, + ``, + ); + } + + // htmlElement = replaceJSXElement( + // htmlElement, + // componentElementName, + // 0, + // ``, + // ); // Remove method and last line htmlElement = htmlElement.replace( diff --git a/lib/actions/saveFinalBundleFile.js b/lib/actions/saveFinalBundleFile.js index f89602e..b31668e 100644 --- a/lib/actions/saveFinalBundleFile.js +++ b/lib/actions/saveFinalBundleFile.js @@ -4,8 +4,8 @@ const getMainWidgetName = require("./getMainWidgetName"); // Save final bundle file // Note: must save inside a ./src folder. This is the only folder bos-clir-rs recognizes -const saveFinalBundleFile = (bundleContent) => { - const finalFileName = getMainWidgetName(); +const saveFinalBundleFile = (bundleContent, fileName) => { + const finalFileName = fileName || getMainWidgetName(); fs.writeFileSync( path.join(`./build/src/${finalFileName}.jsx`), diff --git a/lib/actions/transformSchemaToWidget.js b/lib/actions/transformSchemaToWidget.js index 1f77008..a63d53f 100644 --- a/lib/actions/transformSchemaToWidget.js +++ b/lib/actions/transformSchemaToWidget.js @@ -34,10 +34,13 @@ const wrapCodeInGetFunction = require("../parsers/wrapCodeInGetFunction"); const getFunctionExportDeclarationKeys = require("../parsers/getFunctionExportDeclarationKeys"); const { read_alem_config } = require("../config"); const filterReturn = require("../parsers/filterReturn"); +const getProjectName = require("./getProjectName"); +const asStatefulCheck = require("./asStatefulCheck"); const config = read_alem_config(); let processError = null; +let account = null; /** * @param {string} content @@ -105,6 +108,16 @@ const processSchema = (fileSchema) => { // isStateless = Arquivo sem controle de estado let isStateless = !hasWidgetPropsCheck(fileSchema.content) && !isIndex; + + // Checa se tem a assinatura "as stateful" no conteúdo original do arquivo + if (isStateless) { + const checkResult = asStatefulCheck(fileSchema.content); + if (checkResult.asStatefulSignalFound) { + fileSchema.content = checkResult.updatedContent; + isStateless = false; + } + } + fileSchema.isStateless = isStateless; // ITEM 2 @@ -123,6 +136,18 @@ const processSchema = (fileSchema) => { transpileTypescript, ); + /** + * Deve ser ejetado os arquivos stateful? (cria um arquivo separado do arquivo principal Indexador) + * + * Configuraçao (alem.config.json): + * options: { + * ejectStatefulComponents: true + * } + */ + const toBeEjected = config.options?.ejectStatefulComponents && !isStateless; + + fileSchema.toBeEjected = toBeEjected; + // isModule = Arquivos que estão na pasta "src/modules". Estes são inseridos no state global para serem acessados por todos // os componentes, salvando assim bastante espaço do bundle final. // let isModule = fileSchema.filePath.includes("src/modules/") || isStateless; @@ -362,7 +387,11 @@ const transformWidgetInChildProps = (childProps, fileSchemas) => { const foundJSXs = extractJSX(entryValue); if (foundJSXs?.length > 0) { foundJSXs.forEach((jsx) => { - const widgetContent = processChildrenWidget(`<>${jsx}`, fileSchemas); + const widgetContent = processChildrenWidget( + `<>${jsx}`, + fileSchemas, + account, + ); entryValue = entryValue.replace(jsx, widgetContent); }); } @@ -495,7 +524,11 @@ const swapComponentsForStatelessFiles = (fileSchemas, fileSchema) => { let childChildren = extractJSXChildren(htmlElementString); if (childChildren) { - childChildren = processChildrenWidget(childChildren, fileSchemas); + childChildren = processChildrenWidget( + childChildren, + fileSchemas, + account, + ); childProps = { ...childProps, children: childChildren }; } @@ -522,12 +555,25 @@ const swapComponentsForStatelessFiles = (fileSchemas, fileSchema) => { // Caso quebre, ver isso. [Provavelmente o escape acima esta adicionando o } no final] // Transform components generated by .jsx / .tsx into - fileBundle = replaceJSXElement( - fileBundle, - importItemWidgetComponentName, - 0, - ``, - ); + if (importItemWidget.toBeEjected) { + // O nome do projeto deve vir na frente para evitar conflitos com outros + // aplicativos publicados na mesma conta + const newWidgetName = `${getProjectName(true)}.${importItemWidgetComponentName}`; + const src = `"${account}/widget/${newWidgetName}"`; + fileBundle = replaceJSXElement( + fileBundle, + importItemWidgetComponentName, + 0, + ``, + ); + } else { + fileBundle = replaceJSXElement( + fileBundle, + importItemWidgetComponentName, + 0, + ``, + ); + } // Remove funcao no topo e ultima linha fechando a funcao fileBundle = fileBundle.replace("const TempMethod = () => {", ""); @@ -842,7 +888,11 @@ const injectModulesDependencies = (fileSchemas, fileSchema) => { * @param {{filePath: string, toImport: string[], content: string}[]} fileSchemas * the process starts. This is util to inject previous schema files like Além importable items. */ -const transformSchemaToWidget = (fileSchemas) => { +const transformSchemaToWidget = (fileSchemas, network) => { + // Set current account + account = + network === "mainnet" ? config.mainnetAccount : config.testnetAccount; + const showLogs = process.env.SHOW_EXECUTION_TIME === "true"; // TODO: trocar esse nome, transformSchemaToWidget -> transformSchemaToWidgetSchema // Reset error state @@ -866,11 +916,6 @@ const transformSchemaToWidget = (fileSchemas) => { fileSchemas, fileSchema, ); - - // if (fileSchema.filePath.includes("src/Main.tsx")) { - // console.log("========== AAAA"); - // console.log("fileSchemas[fileSchemaIndex]", fileSchemas[fileSchemaIndex]); - // } }); end = Date.now(); if (showLogs) { @@ -881,10 +926,6 @@ const transformSchemaToWidget = (fileSchemas) => { start = Date.now(); fileSchemas.forEach((fileSchema, fileSchemaIndex) => { - // if (fileSchema.filePath.includes("src/Main.tsx")) { - // console.log("========== BBBB"); - // console.log("fileSchemas[fileSchemaIndex]", fileSchemas[fileSchemaIndex]); - // } // Processa arquivos que contenham elementos html mas são stateless // console.log("Current file:", fileSchema.filePath); // ATENCAO: essa funcao esta usando "fileSchema.jsContent" ao invéz de "fileSchema.finalFileBundle" @@ -893,10 +934,6 @@ const transformSchemaToWidget = (fileSchemas) => { fileSchemas, fileSchema, ); - // if (fileSchema.filePath.includes("src/Main.tsx")) { - // console.log("========== AAAA"); - // console.log("fileSchemas[fileSchemaIndex]", fileSchemas[fileSchemaIndex]); - // } }); end = Date.now(); if (showLogs) { @@ -912,11 +949,6 @@ const transformSchemaToWidget = (fileSchemas) => { fileSchemas, fileSchema, ); - - // if (fileSchema.filePath.includes("src/Main.tsx")) { - // console.log("========== AAAA"); - // console.log("fileSchemas[fileSchemaIndex]", fileSchemas[fileSchemaIndex]); - // } }); end = Date.now(); if (showLogs) { @@ -925,11 +957,6 @@ const transformSchemaToWidget = (fileSchemas) => { ); } - // FOO - // fileSchemas.forEach((fileSchema, fileSchemaIndex) => { - // fileSchemas[fileSchemaIndex] = foo(fileSchemas, fileSchema); - // }); - // Injeta as dependencias de arquivos (excluindo módulos). Tem que ser separado mesmo para evitar // conflitos na carga de modulos, se liberar módulos, o corpo deles vao ser injetados como arquivos // stateless causando assim duplicidade já que eles sao inseridos como módulos também. diff --git a/lib/alem-vm/alem-vm.d.ts b/lib/alem-vm/alem-vm.d.ts index 5321448..e0070f5 100644 --- a/lib/alem-vm/alem-vm.d.ts +++ b/lib/alem-vm/alem-vm.d.ts @@ -1,7 +1,20 @@ // ALEM Items: +type Children = JSX.Element | ReactElement | JSX.Element[] | string | number; + +type ReturnChildren = ( + params, +) => JSX.Element | ReactElement | JSX.Element[] | string | number; + +/** + * As a Stateful Widget. Tells the compiler to generate this component as a stateful widget (even though it is stateless). When using this type, the file must have only one component present. + * + * This is useful for when you want to avoid unnecessary re-renders caused by stateless components manipulating the state of the main component. + */ +export type AsStateful = ReturnChildren | Children; + export type ChildrenProps = { - children: JSX.Element | ReactElement | JSX.Element[] | string | number; + children: Children; }; export type ModuleResponseData = { response: any; forCallId: number }; diff --git a/lib/alem-vm/components/AppIndexer.jsx b/lib/alem-vm/components/AppIndexer.jsx index 4e19db8..3faa42c 100644 --- a/lib/alem-vm/components/AppIndexer.jsx +++ b/lib/alem-vm/components/AppIndexer.jsx @@ -1,3 +1,6 @@ +/** + * This file uses the App's code to render the App widget + */ const AlemApp = useMemo(() => { if (!props.alem.ready) { return ""; diff --git a/lib/alem-vm/components/AppSrcIndexer.jsx b/lib/alem-vm/components/AppSrcIndexer.jsx new file mode 100644 index 0000000..1c5987f --- /dev/null +++ b/lib/alem-vm/components/AppSrcIndexer.jsx @@ -0,0 +1,42 @@ +/** + * This file uses Widget's src to get the App Widget. + * + * It's used when the alem config "ejectStatefulComponents" is true + */ +const AlemApp = useMemo(() => { + if (!props.alem.ready) { + return ""; + } + + const widgetLayer2code = ` + const props = { + ...props, + // ==================================== Modules Code ==================================== + alem: { + ...props.alem, + // m = modulesCode, está sendo usado "m" para reduzir o bundle final + m: { + MODULES_CODE: {}, + }, + } + }; + + return ( + + ) + `; + + // staging.potlock.near/widget/potlock.ConfigForm + + return ( + + + + ); +}, [props.alem.ready, props.alem.alemExternalStylesBody, props.alem.rootProps]); + +return AlemApp; diff --git a/lib/compiler.js b/lib/compiler.js index 793c069..c4d980c 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -33,6 +33,8 @@ async function run_final_process(filesInfo, opts) { return; } + const NETWORK = opts.network || "mainnet"; + /** * Recebe um texto no formato: * NomeComponente: `codigo do componente`, @@ -41,6 +43,7 @@ async function run_final_process(filesInfo, opts) { const finishedSchemaProcessForWidgets = loadFilesContent.loadComponentCodesObjectByFileSchemas( filesInfo.fileSchemas, + NETWORK, ); if (finishedSchemaProcessForWidgets.error) { @@ -55,6 +58,24 @@ async function run_final_process(filesInfo, opts) { let widgetsCodes = finishedSchemaProcessForWidgets.componentsCodes; const modulesCodes = finishedSchemaProcessForWidgets.modulesCodes; + // Generate and Save each ejected component/file + finishedSchemaProcessForWidgets.ejectedFiles.forEach((componentData) => { + componentData.content = parseAlemFeatures(componentData.content); + componentData.content = removeBlankLines(componentData.content); + + if (process.env.MINIFY !== "false") { + componentData.content = minify(componentData.content); + } + + // Add sinatures + componentData.content = addSignatures(componentData.content); + + componentData.content = injectFoundRegExps(componentData.content); + + // Save final Page bundle file + saveFinalBundleFile(componentData.content, componentData.name); + }); + // Alem VM -> Header contents let bundleContent = await alemFiles.loadHeaderFilesContent(); @@ -69,7 +90,7 @@ async function run_final_process(filesInfo, opts) { // Tools -> Indexer // Adiciona o bundle do componente App dentro do Indexador: - bundleContent += alemFiles.loadIndexerContent(); + bundleContent += alemFiles.loadIndexerContent(NETWORK); // Insere os códigos dos Módulos nas props globais bundleContent = bundleContent.replace("MODULES_CODE: {},", modulesCodes); diff --git a/lib/config/alemFiles.js b/lib/config/alemFiles.js index 1dc464b..1877820 100644 --- a/lib/config/alemFiles.js +++ b/lib/config/alemFiles.js @@ -4,6 +4,8 @@ const { for_rfile } = require("../utils"); const { ALEM_VM_FOLDER } = require("../constants"); const importableAlemFileSchemas = require("./importableAlemFileSchemas"); const plugins = require("../../plugins"); +const { read_alem_config } = require("../config"); +const getProjectName = require("../actions/getProjectName"); const loadHeaderFilesContent = async () => { // State @@ -45,11 +47,31 @@ const loadHeaderFilesContent = async () => { * Criar o indexador do projeto * @returns */ -const loadIndexerContent = () => { - const appIndexer = process_file( - path.join(__dirname, "../", ALEM_VM_FOLDER, "components", "AppIndexer.jsx"), +const loadIndexerContent = (network) => { + const config = read_alem_config(); + const account = + network === "mainnet" ? config.mainnetAccount : config.testnetAccount; + const ejectStatefulComponents = config.options?.ejectStatefulComponents; + + let appIndexer = process_file( + path.join( + __dirname, + "../", + ALEM_VM_FOLDER, + "components", + ejectStatefulComponents ? "AppSrcIndexer.jsx" : "AppIndexer.jsx", + ), ); + // Insere o src do App + if (ejectStatefulComponents) { + const widgetName = `${getProjectName(true)}.App`; + appIndexer = appIndexer.replace( + "APP_INDEXER_WIDGET_SRC", + `${account}/widget/${widgetName}`, + ); + } + return removeComments(appIndexer); }; diff --git a/lib/dev.js b/lib/dev.js index 23c78cb..d0815de 100644 --- a/lib/dev.js +++ b/lib/dev.js @@ -12,6 +12,7 @@ const { build } = require("./build"); const { log } = require("./utils"); const { injectHTML } = require("./parse"); const filesContentCache = require("./config/filesContentCache"); +const getProjectName = require("./actions/getProjectName"); // dist folder name when building an app const distFolder = process.env.DIST_FOLDER || "build"; @@ -146,10 +147,18 @@ function generateAllDevJson(network) { // serves the development json async function serveDevJson({ useSocket, useGateway, useOpen, port, network }) { log.info(`Starting workspace...`); + const appConfig = read_alem_config(); const app = express(); let server = http.createServer(app); let io = null; + // Project account + const account = + network === "mainnet" ? appConfig.mainnetAccount : appConfig.testnetAccount; + + // Get the project name + const projectName = getProjectName(); + if (useSocket) { log.sucess("Socket server setup successfully."); io = socketIo(server, { @@ -203,6 +212,8 @@ async function serveDevJson({ useSocket, useGateway, useOpen, port, network }) { return res.status(404).send("Something went wrong."); } const envConfig = JSON.stringify({ + mainWidgetSrc: `${account}/widget/${projectName}`, + mainWidgetLink: `http://127.0.0.1:${port}/${account}/widget/${projectName}`, bosLoaderWs: `ws://127.0.0.1:${port}`, bosLoaderUrl: `http://127.0.0.1:${port}/api/loader`, enableHotReload: useSocket, @@ -229,7 +240,9 @@ async function serveDevJson({ useSocket, useGateway, useOpen, port, network }) { ? "start" : "xdg-open"; start = process.env.WSL_DISTRO_NAME ? "explorer.exe" : start; - exec(`${start} http://127.0.0.1:${port}`); + exec( + `${start} http://127.0.0.1:${port}/${account}/widget/${projectName}`, + ); } // log.log(` // ┌─────────────────────────────────────────────────────────────┐ diff --git a/lib/parsers/hasSignatureType.js b/lib/parsers/hasSignatureType.js new file mode 100644 index 0000000..c3b72e3 --- /dev/null +++ b/lib/parsers/hasSignatureType.js @@ -0,0 +1,58 @@ +const parser = require("@babel/parser"); +const traverse = require("@babel/traverse").default; +const t = require("@babel/types"); + +/** + * Verifica se o componente é de um tipo específico, se for, retorna true, senão, false. + * + * ex: + * + * ``` + * const code = `const Foo: AsStateful = () => {...}` + * const code2 = `const Foo: Other = () => {...}` + * const signatureType = "AsStateful"; + * + * hasSignatureType(code, signatureType); // true; + * hasSignatureType(code2, signatureType); // false; + * ``` + * + * @param {*} code + * @param {*} signatureType + * @returns + */ +function hasSignatureType(code, signatureType) { + const ast = parser.parse(code, { + sourceType: "module", + plugins: ["jsx", "typescript"], + }); + + let found = false; + + traverse(ast, { + VariableDeclarator(path) { + if ( + path.node.id.typeAnnotation && + t.isTSTypeReference(path.node.id.typeAnnotation.typeAnnotation) && + path.node.id.typeAnnotation.typeAnnotation.typeName.name === + signatureType + ) { + found = true; + path.stop(); + } + }, + FunctionDeclaration(path) { + if ( + path.node.returnType && + t.isTSTypeReference(path.node.returnType.typeAnnotation) && + path.node.returnType.typeAnnotation.typeName.name === signatureType + ) { + found = true; + path.stop(); + } + }, + }); + + return found; +} + +module.exports = hasSignatureType; diff --git a/lib/parsers/processImportsToBase64.js b/lib/parsers/processImportsToBase64.js new file mode 100644 index 0000000..2f74f33 --- /dev/null +++ b/lib/parsers/processImportsToBase64.js @@ -0,0 +1,66 @@ +const parser = require("@babel/parser"); +const traverse = require("@babel/traverse").default; +const nodePath = require("path"); +const sharp = require("sharp"); + +function isImageFile(filePath) { + const imageExtensions = [".png", ".jpg", ".jpeg", ".gif", ".svg"]; + return imageExtensions.includes(nodePath.extname(filePath).toLowerCase()); +} + +async function getBase64(filePath, quality = 80) { + const fileBuffer = await sharp(filePath) + .resize({ width: 800 }) // Adjust the size as needed + .jpeg({ quality }) // Adjust the quality as needed + .toBuffer(); + + return `data:image/${nodePath + .extname(filePath) + .slice(1)};base64,${fileBuffer.toString("base64")}`; +} + +/** + * Processo que captura os imports de imagens e guarda seu conteúdo em base64 para + * ser usado posteriormente no processo do compilador. + * @param {*} code + * @param {*} fileDir + * @param {*} quality + * @returns + */ +async function processImportsToBase64(code, fileDir, quality) { + const ast = parser.parse(code, { + sourceType: "module", + plugins: ["jsx", "typescript"], + }); + + const imageImports = []; + + const promises = []; + + traverse(ast, { + ImportDeclaration(path) { + const importPath = path.node.source.value; + const importName = path.node.specifiers[0].local.name; + const fullImportPath = nodePath.resolve( + nodePath.dirname(fileDir), + importPath, + ); + + if (isImageFile(fullImportPath)) { + promises.push( + getBase64(fullImportPath, quality).then((base64Content) => { + imageImports.push({ + imageKey: importName, + imageBase64Content: base64Content, + }); + }), + ); + } + }, + }); + + await Promise.all(promises); + return imageImports; +} + +module.exports = processImportsToBase64; diff --git a/package-lock.json b/package-lock.json index bd0950f..5178833 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "alem", - "version": "1.2.0", + "version": "1.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "alem", - "version": "1.2.0", + "version": "1.3.0", "license": "MIT", "dependencies": { "@babel/core": "^7.24.3", @@ -31,6 +31,7 @@ "postcss": "^8.4.38", "postcss-nested": "^6.0.1", "prettier": "^3.1.0", + "sharp": "^0.33.4", "socket.io": "^4.7.2", "sucrase": "^3.34.0", "tailwindcss": "^3.4.3" @@ -1863,6 +1864,15 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, + "node_modules/@emnapi/runtime": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.2.0.tgz", + "integrity": "sha512-bV21/9LQmcQeCPEg3BDFtvwL6cwiTMksYNWQQ4KOxCZikEGalWtenoZ0wCiukJINlGCIi2KXx01g4FoH/LxpzQ==", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -1952,6 +1962,437 @@ "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", "dev": true }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.4.tgz", + "integrity": "sha512-p0suNqXufJs9t3RqLBO6vvrgr5OhgbWp76s5gTRvdmxmuv9E1rcaqGUsl3l4mKVmXPkTkTErXediAui4x+8PSA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.0.2" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.4.tgz", + "integrity": "sha512-0l7yRObwtTi82Z6ebVI2PnHT8EB2NxBgpK2MiKJZJ7cz32R4lxd001ecMhzzsZig3Yv9oclvqqdV93jo9hy+Dw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.0.2" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.2.tgz", + "integrity": "sha512-tcK/41Rq8IKlSaKRCCAuuY3lDJjQnYIW1UXU1kxcEKrfL8WR7N6+rzNoOxoQRJWTAECuKwgAHnPvqXGN8XfkHA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "macos": ">=11", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.2.tgz", + "integrity": "sha512-Ofw+7oaWa0HiiMiKWqqaZbaYV3/UGL2wAPeLuJTx+9cXpCRdvQhCLG0IH8YGwM0yGWGLpsF4Su9vM1o6aer+Fw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "macos": ">=10.13", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.2.tgz", + "integrity": "sha512-iLWCvrKgeFoglQxdEwzu1eQV04o8YeYGFXtfWU26Zr2wWT3q3MTzC+QTCO3ZQfWd3doKHT4Pm2kRmLbupT+sZw==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.28", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.2.tgz", + "integrity": "sha512-x7kCt3N00ofFmmkkdshwj3vGPCnmiDh7Gwnd4nUwZln2YjqPxV1NlTyZOvoDWdKQVDL911487HOueBvrpflagw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.2.tgz", + "integrity": "sha512-cmhQ1J4qVhfmS6szYW7RT+gLJq9dH2i4maq+qyXayUSn9/3iY2ZeWpbAgSpSVbV2E1JUL2Gg7pwnYQ1h8rQIog==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.28", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.2.tgz", + "integrity": "sha512-E441q4Qdb+7yuyiADVi5J+44x8ctlrqn8XgkDTwr4qPJzWkaHwD489iZ4nGDgcuya4iMN3ULV6NwbhRZJ9Z7SQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.2.tgz", + "integrity": "sha512-3CAkndNpYUrlDqkCM5qhksfE+qSIREVpyoeHIU6jd48SJZViAmznoQQLAv4hVXF7xyUB9zf+G++e2v1ABjCbEQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.2.tgz", + "integrity": "sha512-VI94Q6khIHqHWNOh6LLdm9s2Ry4zdjWJwH56WoiJU7NTeDwyApdZZ8c+SADC8OH98KWNQXnE01UdJ9CSfZvwZw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.4.tgz", + "integrity": "sha512-RUgBD1c0+gCYZGCCe6mMdTiOFS0Zc/XrN0fYd6hISIKcDUbAW5NtSQW9g/powkrXYm6Vzwd6y+fqmExDuCdHNQ==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.28", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.0.2" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.4.tgz", + "integrity": "sha512-2800clwVg1ZQtxwSoTlHvtm9ObgAax7V6MTAB/hDT945Tfyy3hVkmiHpeLPCKYqYR1Gcmv1uDZ3a4OFwkdBL7Q==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.0.2" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.4.tgz", + "integrity": "sha512-h3RAL3siQoyzSoH36tUeS0PDmb5wINKGYzcLB5C6DIiAn2F3udeFAum+gj8IbA/82+8RGCTn7XW8WTFnqag4tQ==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.31", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.0.2" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.4.tgz", + "integrity": "sha512-GoR++s0XW9DGVi8SUGQ/U4AeIzLdNjHka6jidVwapQ/JebGVQIpi52OdyxCNVRE++n1FCLzjDovJNozif7w/Aw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "glibc": ">=2.26", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.0.2" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.4.tgz", + "integrity": "sha512-nhr1yC3BlVrKDTl6cO12gTpXMl4ITBUZieehFvMntlCXFzH2bvKG76tBL2Y/OqhupZt81pR7R+Q5YhJxW0rGgQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.0.2" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.4.tgz", + "integrity": "sha512-uCPTku0zwqDmZEOi4ILyGdmW76tH7dm8kKlOIV1XC5cLyJ71ENAAqarOHQh0RLfpIpbV5KOpXzdU6XkJtS0daw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "musl": ">=1.2.2", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.0.2" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.33.4.tgz", + "integrity": "sha512-Bmmauh4sXUsUqkleQahpdNXKvo+wa1V9KhT2pDA4VJGKwnKMJXiSTGphn0gnJrlooda0QxCtXc6RX1XAU6hMnQ==", + "cpu": [ + "wasm32" + ], + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.1.1" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.4.tgz", + "integrity": "sha512-99SJ91XzUhYHbx7uhK3+9Lf7+LjwMGQZMDlO/E/YVJ7Nc3lyDFZPGhjwiYdctoH2BOzW9+TnfqcaMKt0jHLdqw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.4.tgz", + "integrity": "sha512-3QLocdTRVIrFNye5YocZl+KKpYKP+fksi1QhmOArgx7GyhIbQp/WrJRu176jm8IxromS7RIkzMiMINVdBtC8Aw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0", + "npm": ">=9.6.5", + "pnpm": ">=7.1.0", + "yarn": ">=3.2.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -3642,6 +4083,18 @@ "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", "dev": true }, + "node_modules/color": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", + "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", + "dependencies": { + "color-convert": "^2.0.1", + "color-string": "^1.9.0" + }, + "engines": { + "node": ">=12.5.0" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -3658,6 +4111,15 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "node_modules/color-string": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", + "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", + "dependencies": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } + }, "node_modules/colord": { "version": "2.9.3", "resolved": "https://registry.npmjs.org/colord/-/colord-2.9.3.tgz", @@ -4016,6 +4478,14 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/detect-libc": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", + "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", + "engines": { + "node": ">=8" + } + }, "node_modules/detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -8006,6 +8476,56 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, + "node_modules/sharp": { + "version": "0.33.4", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.4.tgz", + "integrity": "sha512-7i/dt5kGl7qR4gwPRD2biwD2/SvBn3O04J77XKFgL2OnZtQw+AG9wnuS/csmu80nPRHLYE9E41fyEiG8nhH6/Q==", + "hasInstallScript": true, + "dependencies": { + "color": "^4.2.3", + "detect-libc": "^2.0.3", + "semver": "^7.6.0" + }, + "engines": { + "libvips": ">=8.15.2", + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.33.4", + "@img/sharp-darwin-x64": "0.33.4", + "@img/sharp-libvips-darwin-arm64": "1.0.2", + "@img/sharp-libvips-darwin-x64": "1.0.2", + "@img/sharp-libvips-linux-arm": "1.0.2", + "@img/sharp-libvips-linux-arm64": "1.0.2", + "@img/sharp-libvips-linux-s390x": "1.0.2", + "@img/sharp-libvips-linux-x64": "1.0.2", + "@img/sharp-libvips-linuxmusl-arm64": "1.0.2", + "@img/sharp-libvips-linuxmusl-x64": "1.0.2", + "@img/sharp-linux-arm": "0.33.4", + "@img/sharp-linux-arm64": "0.33.4", + "@img/sharp-linux-s390x": "0.33.4", + "@img/sharp-linux-x64": "0.33.4", + "@img/sharp-linuxmusl-arm64": "0.33.4", + "@img/sharp-linuxmusl-x64": "0.33.4", + "@img/sharp-wasm32": "0.33.4", + "@img/sharp-win32-ia32": "0.33.4", + "@img/sharp-win32-x64": "0.33.4" + } + }, + "node_modules/sharp/node_modules/semver": { + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -8053,6 +8573,19 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", + "dependencies": { + "is-arrayish": "^0.3.1" + } + }, + "node_modules/simple-swizzle/node_modules/is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" + }, "node_modules/sisteransi": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", @@ -8544,6 +9077,12 @@ "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==" }, + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", + "optional": true + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", diff --git a/package.json b/package.json index 72fc235..c6d2674 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "alem", "description": "Create web3 applications for NEAR BOS with a focus on performance and friendly development.", - "version": "1.2.1", + "version": "1.3.0", "main": "main.js", "types": "index.d.ts", "author": "Wenderson Pires - wendersonpires.near", @@ -57,6 +57,7 @@ "postcss": "^8.4.38", "postcss-nested": "^6.0.1", "prettier": "^3.1.0", + "sharp": "^0.33.4", "socket.io": "^4.7.2", "sucrase": "^3.34.0", "tailwindcss": "^3.4.3"