From a552f4074b90c9144319a828d4008edb73e75fa6 Mon Sep 17 00:00:00 2001 From: Wenderson Pires Date: Sat, 23 Mar 2024 04:09:53 -0300 Subject: [PATCH 1/4] fix useContext, fix createContext, new types, bug fixes --- .../{use-location.md => get-location.md} | 8 +- docs/router/routes.md | 6 +- lib/alem-vm/alem-vm.d.ts | 33 ++-- lib/alem-vm/importable/RouterProvider.ts | 160 ++++++++---------- lib/alem-vm/importable/createContext.ts | 127 ++++++++++---- lib/alem-vm/importable/useContext.ts | 4 +- lib/alem-vm/importable/useRoutes.ts | 18 +- lib/compiler.js | 7 +- lib/config/parseAlemFeatures.js | 1 + lib/dev.js | 3 +- 10 files changed, 213 insertions(+), 154 deletions(-) rename docs/router/{use-location.md => get-location.md} (83%) diff --git a/docs/router/use-location.md b/docs/router/get-location.md similarity index 83% rename from docs/router/use-location.md rename to docs/router/get-location.md index acc8832..d68b357 100644 --- a/docs/router/use-location.md +++ b/docs/router/get-location.md @@ -5,18 +5,18 @@ -## Use Location +## Get Location This hook returns the current location object. It can be useful if you'd like to perform some side effect whenever the current location changes. -Use `useLocation().isRoutesReady` to get to know when the routes are ready to be accessed. +Use `getLocation().isRoutesReady` to get to know when the routes are ready to be accessed. ```ts // http://127.0.0.1:8080/alem-lib.near/widget/Index?path=profile -import { useLocation } from "alem"; +import { getLocation } from "alem"; export const SomeComponent = () => { - const location = useLocation(); + const location = getLocation(); console.log(location); // { isRoutesReady: true, pathname: "profile", routes: ["home", "profile"] } diff --git a/docs/router/routes.md b/docs/router/routes.md index 59fceff..0461878 100644 --- a/docs/router/routes.md +++ b/docs/router/routes.md @@ -37,7 +37,7 @@ export default AppRoutes; ## Types of Behavior -`Routes` can handle links in two ways: +`Router` can handle links in two ways: - **URLBased:** This is the default behavior. Every link will reload the page by changing the URL structure in the browser; - **ContentBased:** This behavior does not change the URL in the browser and does not reload the page. Therefore, it is faster to display content on the screen. @@ -46,13 +46,13 @@ You can pass the type of behavior using the `type` property of Routes. ```tsx /* URL Based */ - /* Content Based */ - diff --git a/lib/alem-vm/alem-vm.d.ts b/lib/alem-vm/alem-vm.d.ts index bac20be..3a7b806 100644 --- a/lib/alem-vm/alem-vm.d.ts +++ b/lib/alem-vm/alem-vm.d.ts @@ -140,11 +140,12 @@ export declare const useRoutes: () => { * @param defaultStateValue Default values to be inserted to the Component's State * @param defaultPropsValue Default values to be inserted to the Component's props */ -export declare const createContext: ( +export declare const createContext: ( contextKey: string, - defaultStateValue: S, - defaultPropsValue: void | P, -) => void; +) => { + setDefaultData: (defaultStateValue: S) => void; + updateData: (updates: Partial) => void; +}; /** * Use context. This is helpful to get a previous created context's props. @@ -152,7 +153,7 @@ export declare const createContext: ( * @param contextKey Context key name * @returns */ -export declare const useContext: (contextKey: string) => D | undefined; +export declare const useContext: (contextKey: string) => D; // ======= APIs ======= @@ -217,8 +218,10 @@ export declare var props: any; export declare var context: BosContext; export declare const Widget: (params: { - src: string; - props: object; + loading?: JSX.Element | JSX.Element[] | string | number; + code?: string; + src?: string; + props?: object; }) => React.ReactNode; export declare const Markdown: (params: { @@ -240,6 +243,8 @@ export declare function useEffect( deps?: DependencyList, ): void; +export declare function useMemo(factory: () => T, deps: DependencyList): T; + /** * `fetch` allows to fetch data from the URL. It acts like a hook. It's a wrapper around the fetch function from the browser behind the caching layer. * @@ -340,7 +345,7 @@ export declare const Near: { args?: {}, blockId?: string, subscribe?: boolean, - ) => Promise; + ) => R; /** * Call @@ -359,7 +364,7 @@ export declare const Near: { args?: {}, gas?: string | number, deposit?: string | number, - ) => Promise; + ) => R; /** * Queries a block from the blockchain. @@ -402,7 +407,7 @@ export declare const Social: { */ return_deleted?: boolean; }, - ) => Promise; + ) => R; /** * `Social.getr` is just a wrapper helper for Social.get, it appends ** to each of the path pattern. @@ -427,7 +432,7 @@ export declare const Social: { */ return_deleted?: boolean; }, - ) => Promise; + ) => R; /** * It calls the SocialDB's `keys` API and returns the data. While the data is fetching the returned value equals to `null`. @@ -463,7 +468,7 @@ export declare const Social: { cacheOptions?: { ignoreCache: boolean; }, - ) => Promise; + ) => R; /** * Takes a `data` object and commits it to SocialDB. It works similarly to the `CommitButton` by spawning the modal window prompt @@ -493,7 +498,7 @@ export declare const Social: { */ onCancel?: () => void; }, - ) => Promise; + ) => R; /** * Returns the array of matched indexed values. Ordered by `blockHeight`. @@ -530,7 +535,7 @@ export declare const Social: { */ from?: 0 | "Max"; }, - ) => Promise; + ) => R; }; /** diff --git a/lib/alem-vm/importable/RouterProvider.ts b/lib/alem-vm/importable/RouterProvider.ts index 138c9c0..a989648 100644 --- a/lib/alem-vm/importable/RouterProvider.ts +++ b/lib/alem-vm/importable/RouterProvider.ts @@ -1,29 +1,17 @@ -import { State, state, RouteType, createContext } from "../alem-vm"; +import { RouteType, createContext, useContext } from "../alem-vm"; + +const ALEM_ROUTES_CONTEXT_KEY = "alemRoutes"; const RouterProvider = () => { - // Controle de rotas - const AlemRoutesStateInitialBody = { - alemRoutes: { - // ==================================== Routes ==================================== - routesInitialized: false, - activeRoute: "", - routeParameterName: "path", - routes: [] as string[], - routeType: "URLBased", // URLBased | ContentBased - routeBlocked: true, // Used to force navigate to other paths even when the "path=" parameter is present into the URL - }, - }; + const { setDefaultData, updateData } = createContext(ALEM_ROUTES_CONTEXT_KEY); /** * Update the alem state * @param updatedState */ const updateAlemRoutesState = (updatedState: Record) => { - State.update({ - alemRoutes: { - ...state.alemRoutes, - ...updatedState, - }, + updateData({ + ...updatedState, }); }; @@ -32,84 +20,80 @@ const RouterProvider = () => { * @returns */ const alemRoutesState = () => - state.alemRoutes as typeof AlemRoutesStateInitialBody.alemRoutes; - - const alemRoutesProps = { - // ...props, - - alemRoutes: { - ...state.alemRoutes, + useContext(ALEM_ROUTES_CONTEXT_KEY).alemRoutes; - // ==================================== Routes ==================================== + setDefaultData({ + // ==================================== Routes ==================================== + routesInitialized: false, + activeRoute: "", + routeParameterName: "path", + routes: [] as string[], + routeType: "URLBased", // URLBased | ContentBased + routeBlocked: true, // Used to force navigate to other paths even when the "path=" parameter is present into the URL - /** - * Update Route Parameter Name - * @param parameterName - */ - updateRouteParameterName: (parameterName: string) => { - updateAlemRoutesState({ - routeParameterName: parameterName, - }); - }, + // ==================================== Routes - Methods ==================================== - /** - * Update route parameters - */ - updateRouteParameters: (props: { - routes?: string[]; - routeType?: RouteType; - activeRoute?: string; - routeBlocked?: boolean; - }) => { - updateAlemRoutesState({ - routes: props.routes || alemRoutesState().routes, - routeType: props.routeType || alemRoutesState().routeType, - activeRoute: props.activeRoute || alemRoutesState().activeRoute, - routeBlocked: props.routeBlocked || alemRoutesState().routeBlocked, - routesInitialized: true, - }); - }, + /** + * Update Route Parameter Name + * @param parameterName + */ + updateRouteParameterName: (parameterName: string) => { + updateAlemRoutesState({ + routeParameterName: parameterName, + }); + }, - /** - * Update route type - * @param route - */ - // updateRouteType: (type: RouteType) => { - // updateAlemRoutesState({ - // routeType: type, - // }) - // }, + /** + * Update route parameters + */ + updateRouteParameters: (props: { + routes?: string[]; + routeType?: RouteType; + activeRoute?: string; + routeBlocked?: boolean; + }) => { + updateAlemRoutesState({ + routes: props.routes || alemRoutesState().routes, + routeType: props.routeType || alemRoutesState().routeType, + activeRoute: props.activeRoute || alemRoutesState().activeRoute, + routeBlocked: props.routeBlocked || alemRoutesState().routeBlocked, + routesInitialized: true, + }); + }, - /** - * Programmatically navigate to available routes. The URL will not be affected! - */ - navigate: (route: string) => { - // console.log("RoutesProvider -> navigate to:", route, alemRoutesState()); - if (alemRoutesState().routes.includes(route)) { - updateAlemRoutesState({ activeRoute: route }); - } - }, + /** + * Update route type + * @param route + */ + // updateRouteType: (type: RouteType) => { + // updateAlemRoutesState({ + // routeType: type, + // }) + // }, - /** - * This hook returns the current location object. - * @returns - */ - getLocation: () => { - return { - pathname: alemRoutesState().activeRoute, - routes: alemRoutesState().routes, - isRoutesReady: - alemRoutesState().routes && alemRoutesState().routes.length > 0, - }; - }, + /** + * Programmatically navigate to available routes. The URL will not be affected! + */ + navigate: (route: string) => { + // console.log("RoutesProvider -> navigate to:", route, alemRoutesState()); + if (alemRoutesState().routes.includes(route)) { + updateAlemRoutesState({ activeRoute: route }); + } }, - }; - createContext( - "alemRouterProvider", - AlemRoutesStateInitialBody, - alemRoutesProps, - ); + /** + * This hook returns the current location object. + * @returns + */ + getLocation: () => { + return { + pathname: alemRoutesState().activeRoute, + routes: alemRoutesState().routes, + isRoutesReady: + alemRoutesState().routes && alemRoutesState().routes.length > 0, + }; + }, + }); }; export default RouterProvider; diff --git a/lib/alem-vm/importable/createContext.ts b/lib/alem-vm/importable/createContext.ts index 8676ddc..63c6c8a 100644 --- a/lib/alem-vm/importable/createContext.ts +++ b/lib/alem-vm/importable/createContext.ts @@ -1,40 +1,109 @@ import { State, props, state } from "../alem-vm"; +const createContext = (contextKey: string) => { + const setDefaultData = (defaultStateValue: S) => { + if ( + !state[contextKey] || + (state[contextKey] && !state[contextKey].initialized) + ) { + const stateKeys = Object.keys(defaultStateValue); + // const propsKeys = Object.keys(defaultPropsValue || {}); + // let mainKeys = [...stateKeys, ...propsKeys]; + let mainKeys = [...stateKeys]; + + // Remove duplicate + mainKeys = mainKeys.filter( + (item, index) => mainKeys.indexOf(item) === index, + ); + + State.update({ + ...state, + // ...defaultStateValue, + [contextKey]: { + initialized: true, + keys: mainKeys, + ...defaultStateValue, + }, + }); + + // props = { + // ...props, + // ...state, + // [contextKey]: { ...state[contextKey], ...defaultPropsValue }, + // }; + } + + props = { + ...props, + ...state, + // [contextKey]: { ...state[contextKey], ...defaultPropsValue }, + [contextKey]: { ...state[contextKey] }, + }; + }; + + const updateData = (updates: Partial) => { + State.update({ [contextKey]: { ...state[contextKey], ...updates } }); + props = { + ...props, + ...state, + }; + }; + + return { + setDefaultData, + updateData, + }; +}; + /** * Create context for stateful component and send context props to its children. * This can be useful if you'd like to perform some side effect whenever some context data changes. * * @param contextKey Context key name (must be unique) * @param defaultStateValue Default values to be inserted to the Component's State - * @param defaultPropsValue Default values to be inserted to the Component's props */ -const createContext = ( - contextKey: string, - defaultStateValue: S, - defaultPropsValue: P | void, -) => { - if (!state || (state[contextKey] && !state[contextKey].initialized)) { - const stateKeys = Object.keys(defaultStateValue); - const propsKeys = Object.keys(defaultPropsValue || {}); - let mainKeys = [...stateKeys, ...propsKeys]; - - // Remove duplicate - mainKeys = mainKeys.filter( - (item, index) => mainKeys.indexOf(item) === index, - ); - - State.update({ - ...state, - ...defaultStateValue, - [contextKey]: { initialized: true, keys: mainKeys }, - }); - } - - props = { - ...props, - ...state, - ...defaultPropsValue, - }; -}; +// const createContext = ( +// contextKey: string, +// defaultStateValue: S, +// // defaultPropsValue: P | void, +// ) => { +// // console.log("Context Key:", contextKey); +// // console.log("State Context Key:", state[contextKey]); +// // console.log(""); + +// if ( +// !state[contextKey] || +// (state[contextKey] && !state[contextKey].initialized) +// ) { +// const stateKeys = Object.keys(defaultStateValue); +// // const propsKeys = Object.keys(defaultPropsValue || {}); +// // let mainKeys = [...stateKeys, ...propsKeys]; +// let mainKeys = [...stateKeys]; + +// // Remove duplicate +// mainKeys = mainKeys.filter( +// (item, index) => mainKeys.indexOf(item) === index, +// ); + +// State.update({ +// ...state, +// // ...defaultStateValue, +// [contextKey]: { initialized: true, keys: mainKeys, ...defaultStateValue }, +// }); + +// // props = { +// // ...props, +// // ...state, +// // [contextKey]: { ...state[contextKey], ...defaultPropsValue }, +// // }; +// } + +// props = { +// ...props, +// ...state, +// // [contextKey]: { ...state[contextKey], ...defaultPropsValue }, +// [contextKey]: { ...state[contextKey] }, +// }; +// }; export default createContext; diff --git a/lib/alem-vm/importable/useContext.ts b/lib/alem-vm/importable/useContext.ts index b825909..af1d98f 100644 --- a/lib/alem-vm/importable/useContext.ts +++ b/lib/alem-vm/importable/useContext.ts @@ -12,13 +12,13 @@ const useContext = (contextKey: string) => { const wasContextInitialized = props[contextKey].initialized; if (!wasContextInitialized) { console.error(`Context "${contextKey}" not found.`); - return; + return {}; } const contextKeys: string[] = props[contextKey].keys; const contextItems: Record = {}; contextKeys.forEach((key: string) => { - contextItems[key] = props[key]; + contextItems[key] = props[contextKey][key]; }); return contextItems as D; diff --git a/lib/alem-vm/importable/useRoutes.ts b/lib/alem-vm/importable/useRoutes.ts index 98b77c4..35b5e5e 100644 --- a/lib/alem-vm/importable/useRoutes.ts +++ b/lib/alem-vm/importable/useRoutes.ts @@ -1,14 +1,12 @@ import { useContext } from "../alem-vm"; type UseRoutesProps = { - alemRoutes: { - routesInitialized: boolean; - activeRoute: string; - routeParameterName: string; - routes: string[]; - routeType: string; - routeBlocked: boolean; - }; + routesInitialized: boolean; + activeRoute: string; + routeParameterName: string; + routes: string[]; + routeType: string; + routeBlocked: boolean; }; /** @@ -16,11 +14,11 @@ type UseRoutesProps = { * @returns */ const useRoutes = () => { - const contextData = useContext("alemRouterProvider"); + const contextData = useContext("alemRoutes"); if (!contextData) { console.error("useRoutes: You need to call `RouterProvider()` first."); } - return contextData!.alemRoutes; + return contextData!; }; export default useRoutes; diff --git a/lib/compiler.js b/lib/compiler.js index 67333ed..80bbe2a 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -14,6 +14,7 @@ const { const saveFinalBundleFile = require("./actions/saveFinalBundleFile"); const addSignatures = require("./actions/addSignatures"); const parseAlemFeatures = require("./config/parseAlemFeatures"); +const saveFileSchemas = require("./actions/saveFileSchemas"); const distFolder = process.env.DIST_FOLDER || "build"; @@ -82,16 +83,16 @@ function compile_files() { bundleContent = parseOptions(bundleContent); // Mimify - bundleContent = minify(bundleContent); + // bundleContent = minify(bundleContent); // Add sinatures - bundleContent = addSignatures(bundleContent); + // bundleContent = addSignatures(bundleContent); // Save final bundle file saveFinalBundleFile(bundleContent); // Save final file schemas - // saveFileSchemas(finishedSchemaProcessForWidgets.completeFileSchemas); + saveFileSchemas(finishedSchemaProcessForWidgets.completeFileSchemas); } module.exports = { diff --git a/lib/config/parseAlemFeatures.js b/lib/config/parseAlemFeatures.js index 83a8175..2973494 100644 --- a/lib/config/parseAlemFeatures.js +++ b/lib/config/parseAlemFeatures.js @@ -8,6 +8,7 @@ const parseAlemFeatures = (bundleContent) => { .replaceAll("loadExternalStyles(", "props.alem.loadExternalStyles(") .replaceAll("useParams(", "props.alem.useParams(") .replaceAll("createRoute(", "props.alem.createRoute(") + .replaceAll("promisify(", "props.alem.promisify(") // Routes .replaceAll("getLocation(", "props.alemRoutes.getLocation(") diff --git a/lib/dev.js b/lib/dev.js index c88351e..55fc1f2 100644 --- a/lib/dev.js +++ b/lib/dev.js @@ -51,11 +51,12 @@ async function dev(opts) { log.error(err); process.exit(1); }); + loading.finish(); if (io) { const devJson = generateAllDevJson(NETWORK); io.emit("fileChange", devJson); } - loading.finish(); + // loading.finish(); }); setTimeout(() => { From 3965cfd3f0fbbf7347fe9880545142f37bf1fd19 Mon Sep 17 00:00:00 2001 From: Wenderson Pires Date: Mon, 25 Mar 2024 03:02:58 -0300 Subject: [PATCH 2/4] SimpleRouter; createDebounce; new types. --- lib/alem-vm/alem-vm.d.ts | 26 ++++++++++++-- lib/alem-vm/importable/Router.tsx | 24 +++++-------- lib/alem-vm/importable/RouterProvider.ts | 16 +-------- lib/alem-vm/importable/SimpleRouter.tsx | 43 ++++++++++++++++++++++++ lib/alem-vm/importable/createDebounce.ts | 18 ++++++++++ lib/alem-vm/importable/getLocation.ts | 17 ++++++++++ lib/alem-vm/importable/useRoutes.ts | 3 ++ lib/config/importableAlemFileSchemas.js | 28 ++++++++++++++- lib/config/importableFiles.js | 27 +++++++++++++++ lib/config/parseAlemFeatures.js | 2 +- lib/regexp.js | 2 +- 11 files changed, 171 insertions(+), 35 deletions(-) create mode 100644 lib/alem-vm/importable/SimpleRouter.tsx create mode 100644 lib/alem-vm/importable/createDebounce.ts create mode 100644 lib/alem-vm/importable/getLocation.ts diff --git a/lib/alem-vm/alem-vm.d.ts b/lib/alem-vm/alem-vm.d.ts index 3a7b806..099f2ee 100644 --- a/lib/alem-vm/alem-vm.d.ts +++ b/lib/alem-vm/alem-vm.d.ts @@ -36,11 +36,11 @@ type RouterProps = { }; /** - * Init routes + * Init routes usint complex and statefull Router system. * @param props * @returns */ -export declare const Router: (props: RouterProps) => React.JSX.Element; +export declare const Router: (props: RouterProps) => JSX.Element; type LinkProps = { to: string; @@ -51,6 +51,17 @@ type LinkProps = { children?: JSX.Element | JSX.Element[] | string | number; }; +type URLRouterProps = { + routes: Route[]; + /** + * Parameter name to store current route name. Default is "path". + */ + parameterName?: string; + alem?: any; +}; + +export declare const SimpleRouter: (props: URLRouterProps) => JSX.Element; + /** * Link to access routes. */ @@ -205,6 +216,17 @@ export declare const promisify: ( */ export declare const isDevelopment: boolean; +/** + * Create a debounced method to obtain the data after the desired interval. + * @param cb Callback + * @param timeout Timeout. Default is 1 sec. + * @returns + */ +export declare const createDebounce: ( + cb: (data: D) => void, + timeout?: number, +) => (args: any) => void; + // BOS Below: // Bos diff --git a/lib/alem-vm/importable/Router.tsx b/lib/alem-vm/importable/Router.tsx index 04c48bf..6938e2c 100644 --- a/lib/alem-vm/importable/Router.tsx +++ b/lib/alem-vm/importable/Router.tsx @@ -37,6 +37,10 @@ const Router = (props: RouterProps) => { if (!route.component) { console.error(`Routes: Invalid component for route "${route.path}"`); } + + if (!route.path) { + console.error("Routes: Invalid path:", route.path); + } }); }, [routes]); @@ -111,22 +115,12 @@ const Router = (props: RouterProps) => { } }, [routeType]); - // Default route - if (activeRoute === "") { - const Component = routes[0].component; - return ; - } - // Route by route path - const Component = routes.find( - (route: Route) => route.path === activeRoute, - )?.component; - if (Component) { - return ; - } - - // Empty - return <>; + const Component = routes.find((route: Route) => route.path === activeRoute) + ?.component || + routes[0].component || <>; + + return ; }; export default Router; diff --git a/lib/alem-vm/importable/RouterProvider.ts b/lib/alem-vm/importable/RouterProvider.ts index a989648..d52778c 100644 --- a/lib/alem-vm/importable/RouterProvider.ts +++ b/lib/alem-vm/importable/RouterProvider.ts @@ -19,8 +19,7 @@ const RouterProvider = () => { * Get alem state * @returns */ - const alemRoutesState = () => - useContext(ALEM_ROUTES_CONTEXT_KEY).alemRoutes; + const alemRoutesState = () => useContext(ALEM_ROUTES_CONTEXT_KEY); setDefaultData({ // ==================================== Routes ==================================== @@ -80,19 +79,6 @@ const RouterProvider = () => { updateAlemRoutesState({ activeRoute: route }); } }, - - /** - * This hook returns the current location object. - * @returns - */ - getLocation: () => { - return { - pathname: alemRoutesState().activeRoute, - routes: alemRoutesState().routes, - isRoutesReady: - alemRoutesState().routes && alemRoutesState().routes.length > 0, - }; - }, }); }; diff --git a/lib/alem-vm/importable/SimpleRouter.tsx b/lib/alem-vm/importable/SimpleRouter.tsx new file mode 100644 index 0000000..2e58dd2 --- /dev/null +++ b/lib/alem-vm/importable/SimpleRouter.tsx @@ -0,0 +1,43 @@ +import { Route } from "../alem-vm"; + +type URLRouterProps = { + routes: Route[]; + /** + * Parameter name to store current route name. Default is "path". + */ + parameterName?: string; + alem?: any; +}; + +/** + * Init routes using simple Router system where it will render content + * based on the router path. + * @param props + * @returns + */ +const SimpleRouter = (props: URLRouterProps) => { + const { routes, parameterName, alem } = props; + + // Checa se sao rotas validas + routes.forEach((route) => { + if (!route.component) { + console.error(`Routes: Invalid component for route "${route.path}"`); + } + + if (!route.path) { + console.error("Routes: Invalid path:", route.path); + } + }); + + // BOS.props + const bosProps: Record = alem.rootProps || {}; + const activeRoute = bosProps[parameterName || "path"] || routes[0].path; + + const Component = routes.find((route: Route) => route.path === activeRoute) + ?.component || + routes[0].component || <>; + + return ; +}; + +export default SimpleRouter; diff --git a/lib/alem-vm/importable/createDebounce.ts b/lib/alem-vm/importable/createDebounce.ts new file mode 100644 index 0000000..197b5a4 --- /dev/null +++ b/lib/alem-vm/importable/createDebounce.ts @@ -0,0 +1,18 @@ +/** + * Create a debounced method to obtain the data after the desired interval. + * @param cb Callback + * @param timeout Timeout. Default is 1 sec. + * @returns + */ +const createDebounce = (cb: (data: D) => void, timeout?: number) => { + let timer; + const _timeout = timeout || 1000; + return (args) => { + clearTimeout(timer); + timer = setTimeout(() => { + cb(args as D); + }, _timeout); + }; +}; + +export default createDebounce; diff --git a/lib/alem-vm/importable/getLocation.ts b/lib/alem-vm/importable/getLocation.ts new file mode 100644 index 0000000..b6935c2 --- /dev/null +++ b/lib/alem-vm/importable/getLocation.ts @@ -0,0 +1,17 @@ +import { useRoutes } from "../alem-vm"; + +/** + * This returns the current location object. + * + * Works with Router only. + */ +const getLocation = () => { + const routes = useRoutes(); + return { + pathname: routes.activeRoute, + routes: routes.routes, + isRoutesReady: routes.routes && routes.routes.length > 0, + }; +}; + +export default getLocation; diff --git a/lib/alem-vm/importable/useRoutes.ts b/lib/alem-vm/importable/useRoutes.ts index 35b5e5e..0bc568d 100644 --- a/lib/alem-vm/importable/useRoutes.ts +++ b/lib/alem-vm/importable/useRoutes.ts @@ -11,6 +11,9 @@ type UseRoutesProps = { /** * Use Routes Context props. This can be useful if you'd like to perform some side effect whenever some context data changes. + * + * Works with Router only. + * * @returns */ const useRoutes = () => { diff --git a/lib/config/importableAlemFileSchemas.js b/lib/config/importableAlemFileSchemas.js index b3fd8ca..09beb65 100644 --- a/lib/config/importableAlemFileSchemas.js +++ b/lib/config/importableAlemFileSchemas.js @@ -34,7 +34,6 @@ const importableAlemFileSchemas = () => { path.join(__dirname, "../", ALEM_VM_FOLDER, "importable", "useContext.ts"), ); - // Components const routerSchema = transformFileToFileSchema( path.join(__dirname, "../", ALEM_VM_FOLDER, "importable", "Router.tsx"), ); @@ -47,6 +46,30 @@ const importableAlemFileSchemas = () => { path.join(__dirname, "../", ALEM_VM_FOLDER, "importable", "useRoutes.ts"), ); + const getLocationSchema = transformFileToFileSchema( + path.join(__dirname, "../", ALEM_VM_FOLDER, "importable", "getLocation.ts"), + ); + + const simpleRouterSchema = transformFileToFileSchema( + path.join( + __dirname, + "../", + ALEM_VM_FOLDER, + "importable", + "SimpleRouter.tsx", + ), + ); + + const createDebounceSchema = transformFileToFileSchema( + path.join( + __dirname, + "../", + ALEM_VM_FOLDER, + "importable", + "createDebounce.ts", + ), + ); + return loadFilesContent.loadComponentCodesObjectByFileSchemas([ createContextSchema, routerProviderSchema, @@ -54,6 +77,9 @@ const importableAlemFileSchemas = () => { routerSchema, routeLinkSchema, useRoutesSchema, + getLocationSchema, + simpleRouterSchema, + createDebounceSchema, ]); }; diff --git a/lib/config/importableFiles.js b/lib/config/importableFiles.js index b3bc46d..160b700 100644 --- a/lib/config/importableFiles.js +++ b/lib/config/importableFiles.js @@ -57,6 +57,30 @@ const useRoutes = path.join( "useRoutes.ts", ); +const getLocation = path.join( + __dirname, + "../", + ALEM_VM_FOLDER, + "importable", + "getLocation.ts", +); + +const SimpleRouter = path.join( + __dirname, + "../", + ALEM_VM_FOLDER, + "importable", + "SimpleRouter.tsx", +); + +const createDebounce = path.join( + __dirname, + "../", + ALEM_VM_FOLDER, + "importable", + "createDebounce.ts", +); + // TODO: Trazer outros recursos que não alteram o estado global pra ca, exemplo: promisify, etc module.exports = { @@ -66,4 +90,7 @@ module.exports = { Router, RouteLink, useRoutes, + getLocation, + SimpleRouter, + createDebounce, }; diff --git a/lib/config/parseAlemFeatures.js b/lib/config/parseAlemFeatures.js index 2973494..1443dd6 100644 --- a/lib/config/parseAlemFeatures.js +++ b/lib/config/parseAlemFeatures.js @@ -11,7 +11,7 @@ const parseAlemFeatures = (bundleContent) => { .replaceAll("promisify(", "props.alem.promisify(") // Routes - .replaceAll("getLocation(", "props.alemRoutes.getLocation(") + // .replaceAll("getLocation(", "props.alemRoutes.getLocation(") .replaceAll("navigate(", "props.alemRoutes.navigate(") ); }; diff --git a/lib/regexp.js b/lib/regexp.js index f3a19b2..d43a2ac 100644 --- a/lib/regexp.js +++ b/lib/regexp.js @@ -49,7 +49,7 @@ const MORE_THAN_ONE_SPACE = /\s{2,}/g; const CONTENT_OUTSIDE_OF_BRACES = /{[^{}]+}/g; -const WIDGET_PROPERTIES = /\b(useEffect|useState|State\.init)\b/g; +const WIDGET_PROPERTIES = /\b(useEffect|useState|useMemo|State\.init)\b/g; // given: blabla algo, get: [, , , ] // esse retorna so os nomes também: span, a, From 6d0370160c4bce4aae68e07e5d3a1ecb54142d42 Mon Sep 17 00:00:00 2001 From: Wenderson Pires Date: Mon, 25 Mar 2024 05:39:39 -0300 Subject: [PATCH 3/4] added Big types --- index.d.ts | 1 + lib/alem-vm/alem-vm.d.ts | 51 +++- lib/alem-vm/importable/SimpleRouter.tsx | 9 +- lib/external-declarations/big.d.ts | 353 ++++++++++++++++++++++++ 4 files changed, 398 insertions(+), 16 deletions(-) create mode 100644 lib/external-declarations/big.d.ts diff --git a/index.d.ts b/index.d.ts index 75807a1..2b615c3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1 +1,2 @@ export * from "./lib/alem-vm/alem-vm"; +export * from "./lib/external-declarations/big"; diff --git a/lib/alem-vm/alem-vm.d.ts b/lib/alem-vm/alem-vm.d.ts index 099f2ee..167372d 100644 --- a/lib/alem-vm/alem-vm.d.ts +++ b/lib/alem-vm/alem-vm.d.ts @@ -57,7 +57,6 @@ type URLRouterProps = { * Parameter name to store current route name. Default is "path". */ parameterName?: string; - alem?: any; }; export declare const SimpleRouter: (props: URLRouterProps) => JSX.Element; @@ -294,7 +293,10 @@ export declare const asyncFetch: (url: string) => Promise; * * Know more: https://docs.near.org/bos/api/web-methods#cache */ -export declare const useCache: (promise: () => Promise) => any; +export declare const useCache: ( + promise: () => Promise, + key?: string, +) => any; /** * Storage object to store data for widgets that is persistent across refreshes. Simulates localStorage access. @@ -345,6 +347,24 @@ export declare const clipboard: { writeText: (text: string) => void; }; +type Call = ( + contractName: string, + methodName: string, + args?: {}, + gas?: string | number, + deposit?: string | number, +) => void; + +type CallList = ( + callList: { + contractName: string; + methodName: string; + args?: {}; + gas?: string | number; + deposit?: string | number; + }[], +) => void; + /** * Use Near object to interact with smart contracts in the NEAR blockchain. */ @@ -380,13 +400,22 @@ export declare const Near: { * @param gas Maximum amount of gas to be used for the transaction (default 300Tg) * @param deposit Amount of NEAR tokens to attach to the call as deposit (in yoctoNEAR units) */ - call: ( - contractName: string, - methodName: string, - args?: {}, - gas?: string | number, - deposit?: string | number, - ) => R; + call: Call | CallList | any; + + /** + * A list of calls + * @param callList + * @returns + */ + // call: ( + // callList: { + // contractName: string; + // methodName: string; + // args?: {}; + // gas?: string | number; + // deposit?: string | number; + // }[], + // ) => R[]; /** * Queries a block from the blockchain. @@ -575,11 +604,13 @@ export declare const IpfsImageUpload: (params: { * Know more: https://docs.near.org/bos/api/builtin-components#files */ export declare const Files: (params: { - children: JSX.Element; + children?: JSX.Element; multiple?: boolean; accepts: string[]; clickable?: boolean; className?: string; + minFileSize?: number; + style?: React.CSSProperties; onChange: (files: File[]) => void; }) => React.ReactNode; diff --git a/lib/alem-vm/importable/SimpleRouter.tsx b/lib/alem-vm/importable/SimpleRouter.tsx index 2e58dd2..c558d14 100644 --- a/lib/alem-vm/importable/SimpleRouter.tsx +++ b/lib/alem-vm/importable/SimpleRouter.tsx @@ -1,4 +1,4 @@ -import { Route } from "../alem-vm"; +import { Route, props } from "../alem-vm"; type URLRouterProps = { routes: Route[]; @@ -6,7 +6,6 @@ type URLRouterProps = { * Parameter name to store current route name. Default is "path". */ parameterName?: string; - alem?: any; }; /** @@ -15,9 +14,7 @@ type URLRouterProps = { * @param props * @returns */ -const SimpleRouter = (props: URLRouterProps) => { - const { routes, parameterName, alem } = props; - +const SimpleRouter = ({ routes, parameterName }: URLRouterProps) => { // Checa se sao rotas validas routes.forEach((route) => { if (!route.component) { @@ -30,7 +27,7 @@ const SimpleRouter = (props: URLRouterProps) => { }); // BOS.props - const bosProps: Record = alem.rootProps || {}; + const bosProps: Record = props.alem.rootProps || {}; const activeRoute = bosProps[parameterName || "path"] || routes[0].path; const Component = routes.find((route: Route) => route.path === activeRoute) diff --git a/lib/external-declarations/big.d.ts b/lib/external-declarations/big.d.ts new file mode 100644 index 0000000..118ce07 --- /dev/null +++ b/lib/external-declarations/big.d.ts @@ -0,0 +1,353 @@ +export declare namespace Big { + type BigSource = number | string | Big; + + /** + * GT = 1, EQ = 0, LT = -1 + */ + type Comparison = -1 | 0 | 1; + + /** + * RoundDown = 0, RoundHalfUp = 1, RoundHalfEven = 2, RoundUp = 3 + */ + type RoundingMode = 0 | 1 | 2 | 3; + + interface BigConstructor { + /** + * Returns a new instance of a Big number object + * + * String values may be in exponential, as well as normal (non-exponential) notation. + * There is no limit to the number of digits of a string value (other than that of Javascript's maximum array size), but the largest recommended exponent magnitude is 1e+6. + * Infinity, NaN and hexadecimal literal strings, e.g. '0xff', are not valid. + * String values in octal literal form will be interpreted as decimals, e.g. '011' is 11, not 9. + * + * @throws `NaN` on an invalid value. + */ + new (value: BigSource): Big; + + /** + * Returns a new instance of a Big number object + * + * String values may be in exponential, as well as normal (non-exponential) notation. + * There is no limit to the number of digits of a string value (other than that of Javascript's maximum array size), but the largest recommended exponent magnitude is 1e+6. + * Infinity, NaN and hexadecimal literal strings, e.g. '0xff', are not valid. + * String values in octal literal form will be interpreted as decimals, e.g. '011' is 11, not 9. + * + * @throws `NaN` on an invalid value. + */ + (value: BigSource): Big; + + /** + * Create an additional Big number constructor + * + * Values created with the returned constructor will have a separate set of configuration values. + * This can be used to create Big objects with different DP and RM values. + * Big numbers created by different constructors can be used together in operations, and it is the DP and RM setting of the Big number that an operation is called upon that will apply. + * In the interest of memory efficiency, all Big number constructors share the same prototype object, + * so while the DP and RM (and any other own properties) of a constructor are isolated and untouchable by another, its prototype methods are not. + */ + (): BigConstructor; + + /** + * The maximum number of decimal places of the results of operations involving division. + * It is relevant only to the div and sqrt methods, and the pow method when the exponent is negative. + * + * 0 to 1e+6 inclusive + * Default value: 20 + */ + DP: number; + /** + * The rounding mode used in the above operations and by round, toExponential, toFixed and toPrecision. + * Default value: 1 + */ + RM: number; + /** + * The negative exponent value at and below which toString returns exponential notation. + * + * -1e+6 to 0 inclusive + * Default value: -7 + */ + NE: number; + /** + * The positive exponent value at and above which toString returns exponential notation. + * + * 0 to 1e+6 inclusive + * Default value: 21 + */ + PE: number; + /** + * When set to true, an error will be thrown if a primitive number is passed to the Big constructor, + * or if valueOf is called, or if toNumber is called on a Big which cannot be converted to a primitive number without a loss of precision. + * + * true|false + * Default value: false + */ + strict: boolean; + + /** Readonly rounding modes */ + + /** + * Rounds towards zero. + * I.e. truncate, no rounding. + */ + readonly roundDown: 0; + /** + * Rounds towards nearest neighbour. + * If equidistant, rounds away from zero. + */ + readonly roundHalfUp: 1; + /** + * Rounds towards nearest neighbour. + * If equidistant, rounds towards even neighbour. + */ + readonly roundHalfEven: 2; + /** + * Rounds away from zero. + */ + readonly roundUp: 3; + + readonly Big: BigConstructor; + } + + interface Big { + /** Returns a Big number whose value is the absolute value, i.e. the magnitude, of this Big number. */ + abs(): Big; + /** + * Returns a Big number whose value is the value of this Big number plus n - alias for .plus(). + * + * @throws `NaN` if n is invalid. + */ + add(n: BigSource): Big; + /** + * Compare the values. + * + * @throws `NaN` if n is invalid. + */ + cmp(n: BigSource): Comparison; + /** + * Returns a Big number whose value is the value of this Big number divided by n. + * + * If the result has more fraction digits than is specified by Big.DP, it will be rounded to Big.DP decimal places using rounding mode Big.RM. + * + * @throws `NaN` if n is invalid. + * @throws `±Infinity` on division by zero. + * @throws `NaN` on division of zero by zero. + */ + div(n: BigSource): Big; + /** + * Returns true if the value of this Big equals the value of n, otherwise returns false. + * + * @throws `NaN` if n is invalid. + */ + eq(n: BigSource): boolean; + /** + * Returns true if the value of this Big is greater than the value of n, otherwise returns false. + * + * @throws `NaN` if n is invalid. + */ + gt(n: BigSource): boolean; + /** + * Returns true if the value of this Big is greater than or equal to the value of n, otherwise returns false. + * + * @throws `NaN` if n is invalid. + */ + gte(n: BigSource): boolean; + /** + * Returns true if the value of this Big is less than the value of n, otherwise returns false. + * + * @throws `NaN` if n is invalid. + */ + lt(n: BigSource): boolean; + /** + * Returns true if the value of this Big is less than or equal to the value of n, otherwise returns false. + * + * @throws `NaN` if n is invalid. + */ + lte(n: BigSource): boolean; + /** + * Returns a Big number whose value is the value of this Big number minus n. + * + * @throws `NaN` if n is invalid. + */ + minus(n: BigSource): Big; + /** + * Returns a Big number whose value is the value of this Big number modulo n, i.e. the integer remainder of dividing this Big number by n. + * + * The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. + * + * @throws `NaN` if n is negative or otherwise invalid. + */ + mod(n: BigSource): Big; + /** + * Returns a Big number whose value is the value of this Big number times n - alias for .times(). + * + * @throws `NaN` if n is invalid. + */ + mul(n: BigSource): Big; + /** + * Return a new Big whose value is the value of this Big negated. + */ + neg(): Big; + /** + * Returns a Big number whose value is the value of this Big number plus n. + * + * @throws `NaN` if n is invalid. + */ + plus(n: BigSource): Big; + /** + * Returns a Big number whose value is the value of this Big number raised to the power exp. + * + * If exp is negative and the result has more fraction digits than is specified by Big.DP, it will be rounded to Big.DP decimal places using rounding mode Big.RM. + * + * @param exp The power to raise the number to, -1e+6 to 1e+6 inclusive + * @throws `!pow!` if exp is invalid. + * + * Note: High value exponents may cause this method to be slow to return. + */ + pow(exp: number): Big; + /** + * Return a new Big whose value is the value of this Big rounded to a maximum precision of sd + * significant digits using rounding mode rm, or Big.RM if rm is not specified. + * + * @param sd Significant digits: integer, 1 to MAX_DP inclusive. + * @param rm Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up). + * @throws `!prec!` if sd is invalid. + * @throws `!Big.RM!` if rm is invalid. + */ + prec(sd: number, rm?: RoundingMode): Big; + /** + * Returns a Big number whose value is the value of this Big number rounded using rounding mode rm to a maximum of dp decimal places. + * + * @param dp Decimal places, 0 to 1e+6 inclusive + * @param rm Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up). + * @throws `!round!` if dp is invalid. + * @throws `!Big.RM!` if rm is invalid. + */ + round(dp?: number, rm?: RoundingMode): Big; + /** + * Returns a Big number whose value is the square root of this Big number. + * + * If the result has more fraction digits than is specified by Big.DP, it will be rounded to Big.DP decimal places using rounding mode Big.RM. + * + * @throws `NaN` if this Big number is negative. + */ + sqrt(): Big; + /** + * Returns a Big number whose value is the value of this Big number minus n - alias for .minus(). + * + * @throws `NaN` if n is invalid. + */ + sub(n: BigSource): Big; + /** + * Returns a Big number whose value is the value of this Big number times n. + * + * @throws `NaN` if n is invalid. + */ + times(n: BigSource): Big; + /** + * Returns a string representing the value of this Big number in exponential notation to a fixed number of decimal places dp. + * + * If the value of this Big number in exponential notation has more digits to the right of the decimal point than is specified by dp, + * the return value will be rounded to dp decimal places using rounding mode Big.RM. + * + * If the value of this Big number in exponential notation has fewer digits to the right of the decimal point than is specified by dp, the return value will be appended with zeros accordingly. + * + * If dp is omitted, or is null or undefined, the number of digits after the decimal point defaults to the minimum number of digits necessary to represent the value exactly. + * + * @param dp Decimal places, 0 to 1e+6 inclusive + * @param rm Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up). + * @throws `!toFix!` if dp is invalid. + */ + toExponential(dp?: number, rm?: RoundingMode): string; + /** + * Returns a string representing the value of this Big number in normal notation to a fixed number of decimal places dp. + * + * If the value of this Big number in normal notation has more digits to the right of the decimal point than is specified by dp, + * the return value will be rounded to dp decimal places using rounding mode Big.RM. + * + * If the value of this Big number in normal notation has fewer fraction digits then is specified by dp, the return value will be appended with zeros accordingly. + * + * Unlike Number.prototype.toFixed, which returns exponential notation if a number is greater or equal to 1021, this method will always return normal notation. + * + * If dp is omitted, or is null or undefined, then the return value is simply the value in normal notation. + * This is also unlike Number.prototype.toFixed, which returns the value to zero decimal places. + * + * @param dp Decimal places, 0 to 1e+6 inclusive + * @param rm Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up). + * @throws `!toFix!` if dp is invalid. + */ + toFixed(dp?: number, rm?: RoundingMode): string; + /** + * Returns a string representing the value of this Big number to the specified number of significant digits sd. + * + * If the value of this Big number has more digits than is specified by sd, the return value will be rounded to sd significant digits using rounding mode Big.RM. + * + * If the value of this Big number has fewer digits than is specified by sd, the return value will be appended with zeros accordingly. + * + * If sd is less than the number of digits necessary to represent the integer part of the value in normal notation, then exponential notation is used. + * + * If sd is omitted, or is null or undefined, then the return value is the same as .toString(). + * + * @param sd Significant digits, 1 to 1e+6 inclusive + * @param rm Rounding mode: 0 (down), 1 (half-up), 2 (half-even) or 3 (up). + * @throws `!toPre!` if sd is invalid. + */ + toPrecision(sd?: number, rm?: RoundingMode): string; + /** + * Returns a string representing the value of this Big number. + * + * If this Big number has a positive exponent that is equal to or greater than 21, or a negative exponent equal to or less than -7, then exponential notation is returned. + * + * The point at which toString returns exponential rather than normal notation can be adjusted by changing + * the value of Big.E_POS and Big.E_NEG. By default, Big numbers correspond to Javascript's number type in this regard. + */ + toString(): string; + /** + * Returns a primitive number representing the value of this Big number. + * + * If Big.strict is true an error will be thrown if toNumber is called on a Big number which cannot be converted to a primitive number without a loss of precision. + * + * @since 6.0 + */ + toNumber(): number; + /** + * Returns a string representing the value of this Big number. + * + * If this Big number has a positive exponent that is equal to or greater than 21, or a negative exponent equal to or less than -7, then exponential notation is returned. + * + * The point at which toString returns exponential rather than normal notation can be adjusted by changing + * the value of Big.E_POS and Big.E_NEG. By default, Big numbers correspond to Javascript's number type in this regard. + */ + valueOf(): string; + /** + * Returns a string representing the value of this Big number. + * + * If this Big number has a positive exponent that is equal to or greater than 21, or a negative exponent equal to or less than -7, then exponential notation is returned. + * + * The point at which toString returns exponential rather than normal notation can be adjusted by changing + * the value of Big.E_POS and Big.E_NEG. By default, Big numbers correspond to Javascript's number type in this regard. + */ + toJSON(): string; + /** + * Returns an array of single digits + */ + c: number[]; + /** + * Returns the exponent, Integer, -1e+6 to 1e+6 inclusive + */ + e: number; + /** + * Returns the sign, -1 or 1 + */ + s: number; + } +} + +// We want the exported symbol 'Big' to represent two things: +// - The Big interface, when used in a type context. +// - The BigConstructor instance, when used in a value context. +declare const Big: Big.BigConstructor; +type Big = Big.Big; + +// The export is the same as type/value combo symbol 'Big'. +// export Big; +// export as namespace Big; From 9149436947a1a6eedcdeb24dc6110381204d882d Mon Sep 17 00:00:00 2001 From: Wenderson Pires Date: Tue, 26 Mar 2024 11:40:55 -0300 Subject: [PATCH 4/4] fix global state; new types. fix for complex objects will be made using a diff branch --- .gitignore | 3 ++- lib/alem-vm/alem-vm.d.ts | 17 +++++++++++++++++ lib/alem-vm/state.ts | 2 ++ lib/compiler.js | 4 ++-- package.json | 2 +- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 0367a5d..16cb767 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ OLD_README.md # misc .DS_Store -test.js \ No newline at end of file +test.js +errors \ No newline at end of file diff --git a/lib/alem-vm/alem-vm.d.ts b/lib/alem-vm/alem-vm.d.ts index 167372d..51a8bbf 100644 --- a/lib/alem-vm/alem-vm.d.ts +++ b/lib/alem-vm/alem-vm.d.ts @@ -586,6 +586,7 @@ export declare const Social: { */ from?: 0 | "Max"; }, + cacheOptions?: {}, ) => R; }; @@ -598,6 +599,18 @@ export declare const IpfsImageUpload: (params: { image: string; }) => React.ReactNode; +/** + * CommitButton + */ +export declare const CommitButton: (params: { + disabled?: boolean; + force?: boolean; + className?: string; + data?: {}; + onCommit?: () => void; + children?: JSX.Element | JSX.Element[] | string | number; +}) => React.ReactNode; + /** * A built-in component that enables to input files with drag and drop support. Read more about the `Files` component [here](https://www.npmjs.com/package/react-files). * @@ -653,6 +666,10 @@ export declare const InfiniteScroll: (params: { loadMore: (page: number) => void; hasMore: boolean; useWindow?: boolean; + pageStart?: number; + threshold?: number; + loader?: JSX.Element | JSX.Element[] | string | number; + children?: JSX.Element | JSX.Element[] | string | number; }) => React.ReactNode; /** diff --git a/lib/alem-vm/state.ts b/lib/alem-vm/state.ts index 14c4292..467b253 100644 --- a/lib/alem-vm/state.ts +++ b/lib/alem-vm/state.ts @@ -48,6 +48,8 @@ const AlemStateInitialBody = { }; State.init(AlemStateInitialBody); +// Note: força atualização do rootProps +State.update({ alem: { ...state.alem, rootProps: props } }); // Props para ser compartilhada com todos os Widgets export const props = { diff --git a/lib/compiler.js b/lib/compiler.js index 80bbe2a..c865f32 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -83,10 +83,10 @@ function compile_files() { bundleContent = parseOptions(bundleContent); // Mimify - // bundleContent = minify(bundleContent); + bundleContent = minify(bundleContent); // Add sinatures - // bundleContent = addSignatures(bundleContent); + bundleContent = addSignatures(bundleContent); // Save final bundle file saveFinalBundleFile(bundleContent); diff --git a/package.json b/package.json index 6425d6e..3fdd8dc 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.0.0-alpha.0", + "version": "1.0.0-alpha.1", "main": "main.js", "types": "index.d.ts", "author": "Wenderson Pires - wendersonpires.near",