diff --git a/.eslintrc.json b/.eslintrc.json index a278c2f..81dce9f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,4 +1,7 @@ { + "parserOptions": { + "ecmaVersion": "latest" + }, "env": { "browser": true, "es6": true, diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..df64aa5 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +ko_fi: surunzi +open_collective: eruda \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..d47b285 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,27 @@ +name: CI + +on: + workflow_dispatch: + push: + branches: + - 'master' + paths: + - 'src/**/*' + +jobs: + ci: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [16.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - run: npm i + - run: npm run ci diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..2ced8f0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,28 @@ +name: Publish to NPM + +on: + workflow_dispatch: + release: + types: [created] + +jobs: + publish: + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Node + uses: actions/setup-node@v2 + with: + node-version: '18.x' + registry-url: 'https://registry.npmjs.org' + - name: Build eruda-monitor + run: | + npm i + npm run build + - name: Publish package on NPM + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..1ddf8df --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "tabWidth": 2, + "semi": false +} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6a1d2a7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## v1.0.2 (20 Jul 2024) + +* fix: es5 check \ No newline at end of file diff --git a/README.md b/README.md index abf74d0..77c5534 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,15 @@ # eruda-monitor +[![NPM version][npm-image]][npm-url] +[![Build status][ci-image]][ci-url] +[![License][license-image]][npm-url] + +[npm-image]: https://img.shields.io/npm/v/eruda-monitor.svg +[npm-url]: https://npmjs.org/package/eruda-monitor +[ci-image]: https://img.shields.io/github/actions/workflow/status/liriliri/eruda-monitor/main.yml?branch=master&style=flat-square +[ci-url]: https://github.com/liriliri/eruda-monitor/actions/workflows/main.yml +[license-image]: https://img.shields.io/npm/l/eruda-monitor.svg + Eruda plugin for fps and memory. ## Demo diff --git a/package.json b/package.json index 778a16d..316f86b 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "eruda-monitor", - "version": "1.0.1", + "version": "1.0.2", "main": "eruda-monitor.js", + "description": "Eruda plugin for fps and memory", "browserslist": [ - "> 0.25%", + "since 2015", "not dead" ], "files": [ @@ -13,15 +14,17 @@ "scripts": { "dev": "webpack-dev-server --host 0.0.0.0 --mode development", "build": "webpack --mode production", - "ci": "npm run lint && npm run build", + "ci": "npm run lint && npm run build && npm run es5", "lint": "eslint src/**/*.js", + "format": "lsla prettier \"src/*.{js,scss}\" \"*.json\" --write", "es5": "es-check es5 eruda-monitor.js" }, "keywords": [ "eruda", "plugin" ], - "author": "", + "author": "surunzi", + "license": "MIT", "devDependencies": { "@babel/core": "^7.21.3", "@babel/plugin-transform-runtime": "^7.21.0", @@ -29,17 +32,15 @@ "autoprefixer": "^10.4.14", "babel-loader": "^9.1.2", "css-loader": "^3.4.2", - "eruda": "^3.1.0", - "es5": "^1.0.0", - "eslint": "^8.36.0", - "handlebars": "^4.7.7", - "handlebars-loader": "^1.7.3", + "eruda": "^3.2.0", + "es-check": "^7.2.1", + "eslint": "^8.57.0", "licia": "^1.38.0", "luna-performance-monitor": "^0.3.0", - "node-sass": "^8.0.0", "postcss": "^8.4.21", "postcss-class-prefix": "^0.3.0", "postcss-loader": "^7.0.2", + "sass": "^1.77.8", "sass-loader": "^13.2.0", "webpack": "^5.76.2", "webpack-cli": "^5.0.1", diff --git a/src/index.js b/src/index.js index 75b870f..06b630c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,21 +1,23 @@ -const LunaPerformanceMonitor = require('luna-performance-monitor') const raf = require('licia/raf') +const LunaPerformanceMonitor = require('luna-performance-monitor') const now = require('licia/now') -const contain = require('licia/contain') -module.exports = function(eruda) { +module.exports = function (eruda) { let { evalCss } = eruda.util class Monitor extends eruda.Tool { constructor() { super() this.name = 'monitor' - this._style = evalCss(require('./style.scss') + require('luna-performance-monitor/luna-performance-monitor.css')) + this._style = evalCss( + require('./style.scss') + + require('luna-performance-monitor/luna-performance-monitor.css') + ) } init($el, container) { super.init($el, container) $el.html('
') - + this._initFps($el.find('.eruda-fps').get(0)) if (performance.memory) { this._initMemory($el.find('.eruda-memory').get(0)) @@ -93,7 +95,7 @@ module.exports = function(eruda) { }) this._memoryMonitor = memoryMonitor } - _onThemeChange = (name, val) => { + _onThemeChange = (name) => { const fpsMonitor = this._fpsMonitor const memoryMonitor = this._memoryMonitor if (name === 'theme') { diff --git a/src/style.scss b/src/style.scss index 25c5eef..d42350e 100644 --- a/src/style.scss +++ b/src/style.scss @@ -3,4 +3,4 @@ .memory { margin: 10px 0; } -} \ No newline at end of file +}