diff --git a/assets/workers/csv.worker.ts b/assets/workers/csv.worker.ts index d5bb53e6..0319420c 100644 --- a/assets/workers/csv.worker.ts +++ b/assets/workers/csv.worker.ts @@ -15,14 +15,6 @@ function snooze(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)); } -addEventListener('message', async (event: MessageEvent) => { - const { payload, sleep } = event.data.message; - await snooze(sleep); - const data = csvParse(payload); - const geojson = await transformGeoJSON(data); - postMessage(geojson); -}); - /** * Transforms a CSV to GeoJSON * @@ -60,3 +52,11 @@ async function transformGeoJSON( console.log('built geojson: ', geojson); return geojson; } + +self.addEventListener('message', async (e) => { + const message = e.data.message; + await snooze(message?.sleep || 0); + const data = csvParse(message?.payload); + const geojson = await transformGeoJSON(data); + self.postMessage(geojson); +}); diff --git a/config/index.ts b/config/index.ts index 57d0c79d..1cb9b7d7 100644 --- a/config/index.ts +++ b/config/index.ts @@ -19,7 +19,7 @@ const nitro: NuxtConfig['nitro'] = { const plugins: NuxtConfig['plugins'] = [ { src: '~/plugins/v-click-outside.ts', mode: 'client' }, { src: '~/plugins/v-mapbox.ts', mode: 'client' }, - { src: '~/plugins/v-web-workers.ts', mode: 'client' }, + { src: '~/plugins/v-web-workers.ts', mode: 'server' }, ]; const runtimeConfig: NuxtConfig['runtimeConfig'] = { diff --git a/package-lock.json b/package-lock.json index da6d1942..21e2a6cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,22 +38,22 @@ "@windicss/plugin-scrollbar": "^1.2.3", "eslint": "^8.37.0", "eslint-config-prettier": "^8.8.0", - "eslint-plugin-jsdoc": "^40.1.0", + "eslint-plugin-jsdoc": "^40.1.1", "eslint-plugin-nuxt": "^4.0.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-security": "^1.7.1", "eslint-plugin-vue": "^9.10.0", "husky": "^8.0.3", "lint-staged": "^13.2.0", - "nuxt": "3.3.2", + "nuxt": "^3.3.2", "nuxt-windicss": "^2.6.0", "prettier": "^2.8.7", "sass": "^1.60.0", "shipjs": "^0.26.1", - "stylelint": "^15.3.0", + "stylelint": "^15.4.0", "stylelint-config-recommended-vue": "^1.4.0", "stylelint-prettier": "^3.0.0", - "typescript": "^5.0.2" + "typescript": "^5.0.3" }, "engines": { "node": ">=18", @@ -216,9 +216,9 @@ "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" }, "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.21.0.tgz", - "integrity": "sha512-Q8wNiMIdwsv5la5SPxNYzzkPnjgC0Sy0i7jLkVOCdllu/xcVNkr3TeZzbHBJrj+XXRqzX5uCyCoV9eu6xUG7KQ==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.21.4.tgz", + "integrity": "sha512-46QrX2CQlaFRF4TkwfTt6nJD7IHq8539cCL7SDpqWSDeJKY1xylKKY5F/33mJhLZ3mFvKv2gGrVS6NkyF6qs+Q==", "dev": true, "dependencies": { "@babel/helper-annotate-as-pure": "^7.18.6", @@ -507,12 +507,12 @@ } }, "node_modules/@babel/plugin-syntax-jsx": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.18.6.tgz", - "integrity": "sha512-6mmljtAedFGTWu2p/8WIORGwy+61PLgOMPOdazc7YoJ9ZCWUyFy3A6CpPkRKLKD1ToAesxX8KGEViAiLo9N+7Q==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.21.4.tgz", + "integrity": "sha512-5hewiLct5OKyh6PLKEYaFclcqtIgCb6bmELouxjF6up5q3Sov7rOayW4RwhbaBL0dit8rA80GNfY+UuDp2mBbQ==", "dev": true, "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" + "@babel/helper-plugin-utils": "^7.20.2" }, "engines": { "node": ">=6.9.0" @@ -522,12 +522,12 @@ } }, "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.20.0.tgz", - "integrity": "sha512-rd9TkG+u1CExzS4SM1BlMEhMXwFLKVjOAFFCDx9PbX5ycJWDoWMcwdJH9RhkPu1dOgn5TrxLot/Gx6lWFuAUNQ==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.21.4.tgz", + "integrity": "sha512-xz0D39NvhQn4t4RNsHmDnnsaQizIlUkdtYvLs8La1BlfjQ6JEwxkJGeqJMW2tAXx+q6H+WFuUTXNdYVpEya0YA==", "dev": true, "dependencies": { - "@babel/helper-plugin-utils": "^7.19.0" + "@babel/helper-plugin-utils": "^7.20.2" }, "engines": { "node": ">=6.9.0" @@ -906,9 +906,9 @@ } }, "node_modules/@csstools/css-parser-algorithms": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-2.0.1.tgz", - "integrity": "sha512-B9/8PmOtU6nBiibJg0glnNktQDZ3rZnGn/7UmDfrm2vMtrdlXO3p7ErE95N0up80IRk9YEtB5jyj/TmQ1WH3dw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-2.1.0.tgz", + "integrity": "sha512-KP8TicdXpUyeB1NMlbHud/1l39xvLGvqNFWMpG4qC6H1zs9SadGUHe5SO92n/659sDW9aGDvm9AMru0DZkN1Bw==", "dev": true, "engines": { "node": "^14 || ^16 || >=18" @@ -6200,9 +6200,9 @@ } }, "node_modules/eslint-plugin-jsdoc": { - "version": "40.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-40.1.0.tgz", - "integrity": "sha512-ANvrhiu62VlSorARM0hup60VQsS3hNyp0Ca7cnJDj8tpJzM7tNhBVqMVYXSuLzEmqrpwx6aAh+NAN2DdAGG5fQ==", + "version": "40.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-40.1.1.tgz", + "integrity": "sha512-KxrQCq9pPt7LNeDBlLlnuJMpDFZnEQTs4e25NrT4u5cWmPw2P7F03F2qwPz0GMdlRZTyMOofuPAdiWytvPubvA==", "dev": true, "dependencies": { "@es-joy/jsdoccomment": "~0.37.0", @@ -13070,18 +13070,18 @@ } }, "node_modules/stylelint": { - "version": "15.3.0", - "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-15.3.0.tgz", - "integrity": "sha512-9UYBYk7K9rtlKcTUDZrtntE840sZM00qyYBQHHe7tjwMNUsPsGvR6Fd43IxHEAhRrDLzpy3TVaHb6CReBB3eFg==", + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-15.4.0.tgz", + "integrity": "sha512-TlOvpG3MbcFwHmK0q2ykhmpKo7Dq892beJit0NPdpyY9b1tFah/hGhqnAz/bRm2PDhDbJLKvjzkEYYBEz7Dxcg==", "dev": true, "dependencies": { - "@csstools/css-parser-algorithms": "^2.0.1", + "@csstools/css-parser-algorithms": "^2.1.0", "@csstools/css-tokenizer": "^2.1.0", "@csstools/media-query-list-parser": "^2.0.1", - "@csstools/selector-specificity": "^2.1.1", + "@csstools/selector-specificity": "^2.2.0", "balanced-match": "^2.0.0", "colord": "^2.9.3", - "cosmiconfig": "^8.1.0", + "cosmiconfig": "^8.1.3", "css-functions-list": "^3.1.0", "css-tree": "^2.3.1", "debug": "^4.3.4", @@ -13852,9 +13852,9 @@ } }, "node_modules/typescript": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.2.tgz", - "integrity": "sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.3.tgz", + "integrity": "sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==", "devOptional": true, "bin": { "tsc": "bin/tsc", @@ -14236,9 +14236,9 @@ } }, "node_modules/vite-node": { - "version": "0.29.7", - "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.29.7.tgz", - "integrity": "sha512-PakCZLvz37yFfUPWBnLa1OYHPCGm5v4pmRrTcFN4V/N/T3I6tyP3z07S//9w+DdeL7vVd0VSeyMZuAh+449ZWw==", + "version": "0.29.8", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-0.29.8.tgz", + "integrity": "sha512-b6OtCXfk65L6SElVM20q5G546yu10/kNrhg08afEoWlFRJXFq9/6glsvSVY+aI6YeC1tu2TtAqI2jHEQmOmsFw==", "dev": true, "dependencies": { "cac": "^6.7.14", diff --git a/package.json b/package.json index abf95f9d..bd9d9dc6 100644 --- a/package.json +++ b/package.json @@ -52,22 +52,22 @@ "@windicss/plugin-scrollbar": "^1.2.3", "eslint": "^8.37.0", "eslint-config-prettier": "^8.8.0", - "eslint-plugin-jsdoc": "^40.1.0", + "eslint-plugin-jsdoc": "^40.1.1", "eslint-plugin-nuxt": "^4.0.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-security": "^1.7.1", "eslint-plugin-vue": "^9.10.0", "husky": "^8.0.3", "lint-staged": "^13.2.0", - "nuxt": "3.3.2", + "nuxt": "^3.3.2", "nuxt-windicss": "^2.6.0", "prettier": "^2.8.7", "sass": "^1.60.0", "shipjs": "^0.26.1", - "stylelint": "^15.3.0", + "stylelint": "^15.4.0", "stylelint-config-recommended-vue": "^1.4.0", "stylelint-prettier": "^3.0.0", - "typescript": "^5.0.2" + "typescript": "^5.0.3" }, "repository": { "url": "git+https://github.com/geoql/expenses.git", diff --git a/pages/index.vue b/pages/index.vue index 720acc04..ef4907fa 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -112,7 +112,7 @@