Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# production
/build
/dist

# misc
.DS_Store
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.6.1

- FIX: Addresses a scoping error on the optional `config.errorCallback` function triggerd during Compliation errors and 'VM is dead' errors.

## 2.6.0

- Support multiple Limited Access Keys on BOS gateway to enable "Don't ask me again" when interacting with third-party contracts on BOS. See https://github.com/NearSocial/VM/issues/148
Expand Down
2 changes: 0 additions & 2 deletions dist/index.js

This file was deleted.

8 changes: 0 additions & 8 deletions dist/index.js.LICENSE.txt

This file was deleted.

22 changes: 17 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dist"
],
"dependencies": {
"@module-federation/enhanced": "^0.1.7",
"@radix-ui/react-accordion": "^1.1.1",
"@radix-ui/react-alert-dialog": "^1.0.3",
"@radix-ui/react-aspect-ratio": "^1.0.2",
Expand Down Expand Up @@ -52,8 +53,10 @@
"mdast-util-find-and-replace": "^2.0.0",
"nanoid": "^4.0.1",
"prettier": "^2.7.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-bootstrap": "^2.5.0",
"react-bootstrap-typeahead": "^6.0.0",
"react-bootstrap-typeahead": "^6.1.2",
"react-error-boundary": "^3.1.4",
"react-files": "^3.0.0-alpha.3",
"react-infinite-scroller": "^1.2.6",
Expand All @@ -62,33 +65,39 @@
"react-syntax-highlighter": "^15.5.0",
"react-uuid": "^1.0.2",
"remark-gfm": "^3.0.1",
"sass": "^1.75.0",
"styled-components": "^5.3.6",
"tweetnacl": "^1.0.3"
},
"devDependencies": {
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@rsbuild/core": "^0.6.3",
"@rsbuild/plugin-node-polyfill": "^0.6.3",
"@rsbuild/plugin-react": "^0.6.3",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"babel-loader": "^9.1.2",
"buffer": "^6.0.3",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^9.0.1",
"cross-env": "^7.0.3",
"crypto-browserify": "^3.12.0",
"css-loader": "^6.2.0",
"css-loader": "^7.1.1",
"css-minimizer-webpack-plugin": "^3.0.2",
"html-webpack-plugin": "^5.3.2",
"https-browserify": "^1.0.0",
"mini-css-extract-plugin": "^2.2.2",
"near-api-js": "^2.1.3",
"node-sass": "^7.0.3",
"os-browserify": "^0.3.0",
"postcss-loader": "^7.0.1",
"process": "^0.11.10",
"sass-loader": "^13.1.0",
"sass-loader": "^14.2.1",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"style-loader": "^3.2.1",
"style-loader": "^4.0.0",
"typescript": "^5.4.2",
"url": "^0.11.0",
"webpack": "^5.52.0",
"webpack-bundle-analyzer": "^4.4.2",
Expand All @@ -104,6 +113,9 @@
"react-dom": "^18.2.0"
},
"scripts": {
"rs:dev": "DEBUG=rsbuild rsbuild dev --open",
"rs:build": "rsbuild build",
"rs:preview": "rsbuild preview",
"webpack": "webpack",
"prod": "npm run webpack -- --env mode=production",
"build": "npm run prod"
Expand Down
55 changes: 55 additions & 0 deletions rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { defineConfig } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
import { pluginNodePolyfill } from "@rsbuild/plugin-node-polyfill";

export default defineConfig({
server: {
port: 2000,
},
dev: {
// It is necessary to configure assetPrefix, and in the production environment, you need to configure output.assetPrefix
assetPrefix: 'http://localhost:2000',
startUrl: 'http://localhost:2000/mf-manifest.json',
writeToDisk: true,
},
output: {
assetPrefix: 'https://gateway.ipfs.io/ipns/klngrs.cloud/', // near-vm ipfs folder CID
// externals: {
// react: {
// commonjs: "react",
// commonjs2: "react",
// amd: "react",
// root: "React",
// },
// "react-dom": {
// commonjs: "react-dom",
// commonjs2: "react-dom",
// amd: "react-dom",
// root: "ReactDOM",
// },
// }
}, //
tools: {
rspack: (config, { appendPlugins }) => {
appendPlugins([
new ModuleFederationPlugin({
name: 'near_vm',
exposes: {
'./index': './src/index.tsx',
},
shared: {
react: {
singleton: true,
},
'react-dom': {
singleton: true,
},
},
// shared: ['react', 'react-dom'], // externals
}),
]);
},
},
plugins: [pluginNodePolyfill(), pluginReact()],
});
1 change: 1 addition & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@rsbuild/core/types" />
File renamed without changes.
2 changes: 1 addition & 1 deletion src/lib/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const OneNear = Big(10).pow(24);
const AccountSafetyMargin = OneNear.div(2);
export const ErrorScopes = {
"Boundary": "Component triggered an Error Boundary",
"Compliation": "Compilation error",
"Compilation": "Compilation error",
"Execution": "Execution error",
"Render": "Render error",
"Source": "Source code not found"
Expand Down
4 changes: 2 additions & 2 deletions src/lib/vm/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2287,7 +2287,7 @@ export default class VM {
renderCode(args) {
if (this.compileError) {
const { message, stack } = this.compileError;
this.vm.near.config.errorCallback({scope: ErrorScopes.Compilation, message});
this.near.config.errorCallback({scope: ErrorScopes.Compilation, message});
return (
<div className="alert alert-danger">
Compilation error:
Expand All @@ -2298,7 +2298,7 @@ export default class VM {
}
if (!this.alive) {
const message = "VM is dead";
this.vm.near.config.errorCallback({scope: ErrorScopes.Render, message});
this.near.config.errorCallback({scope: ErrorScopes.Render, message});
return <div className="alert alert-danger">{message}</div>;
}

Expand Down
20 changes: 20 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"allowJs": true,
"target": "ES2020",
"lib": ["DOM", "ES2020"],
"module": "ESNext",
"jsx": "react-jsx",
"strict": true,
"skipLibCheck": true,
"isolatedModules": true,
"resolveJsonModule": true,
"moduleResolution": "bundler",
"useDefineForClassFields": true,
"paths":{
"*": ["./@mf-types/*"]
},
"allowSyntheticDefaultImports": true
},
"include": ["src"],
}
83 changes: 0 additions & 83 deletions webpack.config.js

This file was deleted.

Loading