diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 727a75b1..23a8fde9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: # This workflow contains a single job called "build" base: # The type of runner that the job will run on - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -53,11 +53,11 @@ jobs: - name: check build size webpack run: npm run size:webpack - - name: check build size browserify - run: npm run size:browserify + # - name: check build size browserify + # run: npm run size:browserify - - name: check build size rollup - run: npm run size:rollup + # - name: check build size rollup + # run: npm run size:rollup - name: code format run: npm run lint @@ -82,7 +82,7 @@ jobs: # run the node test in an own task, so we can use a node-version matrix. - test-node: + test: runs-on: ubuntu-20.04 strategy: matrix: @@ -120,6 +120,12 @@ jobs: - name: test node run: npm run test:node + - name: Install playwright webkit + run: npx playwright install-deps webkit + + - name: test browser + run: npx playwright install && npm run test:browser + # TODO this does not work atm. fix this. # - name: test electron diff --git a/config/webpack.config.js b/config/webpack.config.js index d1bdafe6..b2a12a2e 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -1,10 +1,13 @@ +/* eslint-disable @typescript-eslint/no-require-imports */ +/* eslint-disable prettier/prettier */ + const path = require('path'); const TerserPlugin = require('terser-webpack-plugin'); module.exports = { mode: 'production', - entry: './dist/lib/browserify.index.js', + entry: './dist/lib/browser.js', optimization: { minimize: true, minimizer: [new TerserPlugin()] diff --git a/eslint.config.mjs b/eslint.config.mjs index 5944d188..49733919 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -292,7 +292,13 @@ export default [ // ignore files ignores: [ // ignore eslint for testcafe, since relative plugin is not working - "test/e2e.test.js" + "test/e2e.test.js", + + // disable eslint for config files + "config/**/*.js", + + // dist + "dist/**/*.js", ], }, ]; diff --git a/package.json b/package.json index 2c19289c..8ed5952c 100644 --- a/package.json +++ b/package.json @@ -44,14 +44,14 @@ "test:electron": "(cd ./test-electron && npm run test)", "size:prewebpack": "cross-env NODE_ENV=build webpack --config ./config/webpack.config.js", "size:webpack": "npm run size:prewebpack && echo \"Build-Size Webpack (minified+gzip):\" && gzip-size --raw ./test_tmp/webpack.bundle.js", - "size:browserify": "rimraf test_tmp/browserify.js && browserify --no-builtins dist/lib/browserify.index.js > test_tmp/browserify.js && uglifyjs --compress --mangle --output test_tmp/browserify.min.js -- test_tmp/browserify.js && echo \"Build-Size browserify (minified+gzip):\" && gzip-size --raw test_tmp/browserify.min.js", + "size:browserify": "rimraf test_tmp/browserify.js && browserify --no-builtins dist/lib/browser.js > test_tmp/browserify.js && uglifyjs --compress --mangle --output test_tmp/browserify.min.js -- test_tmp/browserify.js && echo \"Build-Size browserify (minified+gzip):\" && gzip-size --raw test_tmp/browserify.min.js", "size:rollup": "rollup --config ./config/rollup.config.js && echo \"Build-Size Rollup (minified+gzip):\" && gzip-size --raw ./test_tmp/rollup.bundle.js", "lint": "eslint src test --cache", "clear": "rimraf -rf ./dist && rimraf -rf ./gen", "build:es6node": "rimraf -rf dist/esnode && cross-env NODE_ENV=es6 babel src --out-dir dist/esnode", - "build:es6browser": "rimraf -rf dist/esbrowser && cross-env NODE_ENV=es6 babel src --out-dir dist/esbrowser && grep -rl NodeMethod dist/esbrowser/ | xargs sed -i '' 's/.*NodeMethod.*//'", + "build:es6browser": "rimraf -rf dist/esbrowser && cross-env NODE_ENV=es6 babel src --out-dir dist/esbrowser", "build:es5node": "cross-env NODE_ENV=es5 babel src --out-dir dist/es5node", - "build:es5browser": "cross-env NODE_ENV=es5 babel src --out-dir dist/lib && grep -rl NodeMethod dist/lib/ | xargs sed -i '' 's/.*NodeMethod.*//'", + "build:es5browser": "cross-env NODE_ENV=es5 babel src --out-dir dist/lib", "build:test": "cross-env NODE_ENV=es5 babel test --out-dir test_tmp", "build:index": "browserify test_tmp/scripts/index.js > docs/index.js", "build:browser": "browserify test_tmp/scripts/e2e.js > docs/e2e.js", @@ -60,7 +60,7 @@ "build:lib-browser": "browserify dist/lib/index.js -p esmify > dist/lib/browser.js", "build:lib-browser:min": "uglifyjs --compress --mangle --output dist/lib/browser.min.js -- dist/lib/browser.js", "build": "npm run clear && npm run build:publish && concurrently \"npm run build:es6node\" \"npm run build:es6browser\" \"npm run build:es5browser\" \"npm run build:test\" && concurrently \"npm run build:index\" \"npm run build:browser\" \"npm run build:worker\" \"npm run build:iframe\" && npm run build:lib-browser && npm run build:lib-browser:min", - "build:min": "uglifyjs --compress --mangle --output dist/lib/browserify.min.js -- dist/lib/browserify.index.js", + "build:min": "uglifyjs --compress --mangle --output dist/lib/browserify.min.js -- dist/lib/browser.js", "docs:only": "http-server ./docs --silent", "docs:serve": "npm run build && echo \"Open http://localhost:8080/\" && npm run docs:only", "build:publish": "torus-scripts build" diff --git a/src/methods/indexed-db.js b/src/methods/indexed-db.js index d486e19e..c4a59398 100644 --- a/src/methods/indexed-db.js +++ b/src/methods/indexed-db.js @@ -175,17 +175,21 @@ export function getMessagesHigherThan(db, lastCursorId) { } export function removeMessagesById(db, ids) { - const tx = db.transaction([OBJECT_STORE_ID], "readwrite", TRANSACTION_SETTINGS); - const objectStore = tx.objectStore(OBJECT_STORE_ID); + try { + const tx = db.transaction([OBJECT_STORE_ID], "readwrite", TRANSACTION_SETTINGS); + const objectStore = tx.objectStore(OBJECT_STORE_ID); - return Promise.all( - ids.map((id) => { - const deleteRequest = objectStore.delete(id); - return new Promise((resolve) => { - deleteRequest.onsuccess = () => resolve(); - }); - }) - ); + return Promise.all( + ids.map((id) => { + const deleteRequest = objectStore.delete(id); + return new Promise((resolve) => { + deleteRequest.onsuccess = () => resolve(); + }); + }) + ); + } catch (e) { + console.error(e); + } } export function getOldMessages(db, ttl) { diff --git a/test/scripts/e2e.js b/test/scripts/e2e.js index 150fed6b..ff36e3c8 100644 --- a/test/scripts/e2e.js +++ b/test/scripts/e2e.js @@ -226,7 +226,11 @@ function run() { }; if (autoStart && autoStart !== '') { - window[autoStart](); + if (window !== undefined && window.hasOwnProperty(autoStart)) { + window[autoStart](); + } else { + console.log('window is undefined'); + } } } diff --git a/test/scripts/util.js b/test/scripts/util.js index 2749d066..71b0bb74 100644 --- a/test/scripts/util.js +++ b/test/scripts/util.js @@ -3,7 +3,7 @@ // https://stackoverflow.com/a/901144/3443137 function getParameterByName(name, url) { if (!url) url = window.location.href; - name = name.replace(/[\[\]]/g, "\\$&"); + name = name.replace(/[\\[\]]/g, "\\$&"); const regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"); const results = regex.exec(url); if (!results) return null;