Skip to content

Commit

Permalink
fix platform checker, alem-vm types updated
Browse files Browse the repository at this point in the history
  • Loading branch information
wpdas committed Apr 17, 2024
1 parent 37a932e commit 8722991
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 13 deletions.
12 changes: 7 additions & 5 deletions lib/actions/transformSchemaToWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,13 @@ const processSchema = (fileSchema) => {
// do projeto

// 1 - Verifica se é um arquivo que vem da lib Além
const isAlemFile = importedItemFileSource.includes(
"lib/alem-vm/importable", // OSX, Linux
) || importedItemFileSource.includes(
"lib\\alem-vm\\importable", // Windows
)
const isAlemFile =
importedItemFileSource.includes(
"lib/alem-vm/importable", // OSX, Linux
) ||
importedItemFileSource.includes(
"lib\\alem-vm\\importable", // Windows
);

// 2 - Se não for, continua o processo normalmente, se for, ignora o tratamento abaixo
if (!isAlemFile) {
Expand Down
26 changes: 23 additions & 3 deletions lib/alem-vm/alem-vm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,39 @@ export declare function useEffect(

export declare function useMemo<T>(factory: () => T, deps: DependencyList): T;

type FetchOptions = {
responseType?:
| "arraybuffer"
| "blob"
| "formdata"
| "json"
| "text"
| "application/json";
method?: string;
headers?: Record<string, any>;
body?: string;
[key]?: any;
};

/**
* `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.
*
* Know more: https://docs.near.org/bos/api/web-methods#fetch
*/
export declare const fetch: (url: string) => { body: any };
export declare const fetch: (
url: string,
options?: FetchOptions,
) => { body: any };

/**
* `asyncFetch` is the async version of `fetch`, meaning that it returns a promise instead of a value.
*
* Know more: https://docs.near.org/bos/api/web-methods#async-version
* Know more: https://docs.near.org/build/near-components/anatomy/web-methods#async-version
*/
export declare const asyncFetch: (url: string) => Promise<any>;
export declare const asyncFetch: (
url: string,
options?: FetchOptions,
) => Promise<any>;

/**
* The `useCache` hook takes a promise through a generator function, fetches the data and caches it. It can be used to easily use and cache data from async data sources.
Expand Down
2 changes: 1 addition & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const os = require("os");

const ALEM_VM_FOLDER = "alem-vm";
const isWindows = os.platform().includes('win');
const isWindows = os.platform().includes("win32");

module.exports = {
ALEM_VM_FOLDER,
Expand Down
4 changes: 3 additions & 1 deletion lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,9 @@ function getImportedElementFileSource(fileContent, importedElementName) {
// Windows adjusment
appContainerImportPath = appContainerImportPath.replaceAll("\\\\", "\\");

return isWindows ? appContainerImportPath.replaceAll("/", "\\") : appContainerImportPath;
return isWindows
? appContainerImportPath.replaceAll("/", "\\")
: appContainerImportPath;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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-beta.19",
"version": "1.0.0-beta.20",
"main": "main.js",
"types": "index.d.ts",
"author": "Wenderson Pires - wendersonpires.near",
Expand Down

0 comments on commit 8722991

Please sign in to comment.