From 3c8822cbbd9d6c7f56f0120201f1e49bdad61395 Mon Sep 17 00:00:00 2001 From: shoonia Date: Thu, 22 Feb 2024 22:26:49 +0200 Subject: [PATCH 1/3] Remove build step --- .size-limit.json | 7 +- dev | 1 - lib/index.cjs | 85 ------------- lib/index.js | 83 ------------ package-lock.json | 238 +++-------------------------------- package.json | 19 +-- rollup.config.js | 22 ---- index.d.ts => src/index.d.ts | 0 tests/setState.spec.js | 2 +- 9 files changed, 21 insertions(+), 436 deletions(-) delete mode 100644 lib/index.cjs delete mode 100644 lib/index.js delete mode 100644 rollup.config.js rename index.d.ts => src/index.d.ts (100%) diff --git a/.size-limit.json b/.size-limit.json index df70f51..73f3ae0 100644 --- a/.size-limit.json +++ b/.size-limit.json @@ -1,11 +1,6 @@ [ { - "path": "lib/index.cjs", - "import": "{ createStoreon }", - "limit": "597 B" - }, - { - "path": "lib/index.js", + "path": "./src/index.js", "import": "{ createStoreon }", "limit": "328 B" } diff --git a/dev b/dev index 844be89..da951ab 100644 --- a/dev +++ b/dev @@ -1,4 +1,3 @@ npm run lint -npm run build npm run test npm run size diff --git a/lib/index.cjs b/lib/index.cjs deleted file mode 100644 index bb63f5b..0000000 --- a/lib/index.cjs +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; - -let createStoreon = (modules) => { - let events = {}; - let state = {}; - let subs = []; - - let dispatch = (event, data) => { - if (event !== '@dispatch') { - dispatch('@dispatch', [event, data]); - } - - if (events[event]) { - let changes; - - events[event].forEach((cb) => { - let diff = cb(state, data); - - if (diff && typeof diff.then !== 'function') { - state = { ...state, ...diff }; - changes = { ...changes, ...diff }; - } - }); - - if (changes) { - dispatch('@changed', changes); - } - } - }; - - let on = (event, cb) => { - (events[event] ??= []).push(cb); - - return () => { - events[event] = events[event].filter((i) => i !== cb); - }; - }; - - let get = () => state; - let set = (changes) => dispatch('@set', changes); - - on('@set', (_, changes) => changes); - - modules.forEach((mod) => { - if (mod) { - mod({ dispatch, on, get, set }); - } - }); - - dispatch('@init'); - - return { - dispatch, - getState: get, - setState: set, - - connect(...k) { - let c = k.pop(); - - subs.push({ k, c }); - - return () => { - subs = subs.filter((i) => i.c !== c); - }; - }, - - readyStore() { - dispatch('@ready'); - - on('@changed', (_, changes) => { - subs.forEach((i) => { - let hasChanges = i.k.some((key) => key in changes); - - if (hasChanges) { - i.c(state); - } - }); - }); - - return Promise.all(subs.map((i) => i.c(state))); - }, - }; -}; - -exports.createStoreon = createStoreon; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index cde7363..0000000 --- a/lib/index.js +++ /dev/null @@ -1,83 +0,0 @@ -let createStoreon = (modules) => { - let events = {}; - let state = {}; - let subs = []; - - let dispatch = (event, data) => { - if (event !== '@dispatch') { - dispatch('@dispatch', [event, data]); - } - - if (events[event]) { - let changes; - - events[event].forEach((cb) => { - let diff = cb(state, data); - - if (diff && typeof diff.then !== 'function') { - state = { ...state, ...diff }; - changes = { ...changes, ...diff }; - } - }); - - if (changes) { - dispatch('@changed', changes); - } - } - }; - - let on = (event, cb) => { - (events[event] ??= []).push(cb); - - return () => { - events[event] = events[event].filter((i) => i !== cb); - }; - }; - - let get = () => state; - let set = (changes) => dispatch('@set', changes); - - on('@set', (_, changes) => changes); - - modules.forEach((mod) => { - if (mod) { - mod({ dispatch, on, get, set }); - } - }); - - dispatch('@init'); - - return { - dispatch, - getState: get, - setState: set, - - connect(...k) { - let c = k.pop(); - - subs.push({ k, c }); - - return () => { - subs = subs.filter((i) => i.c !== c); - }; - }, - - readyStore() { - dispatch('@ready'); - - on('@changed', (_, changes) => { - subs.forEach((i) => { - let hasChanges = i.k.some((key) => key in changes); - - if (hasChanges) { - i.c(state); - } - }); - }); - - return Promise.all(subs.map((i) => i.c(state))); - }, - }; -}; - -export { createStoreon }; diff --git a/package-lock.json b/package-lock.json index 59ad308..d49184a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,6 @@ "eslint": "^8.56.0", "eslint-plugin-jest": "^27.9.0", "jest": "^29.7.0", - "rollup": "^4.12.0", "size-limit": "^11.0.2" } }, @@ -1636,175 +1635,6 @@ "node": ">= 8" } }, - "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.12.0.tgz", - "integrity": "sha512-+ac02NL/2TCKRrJu2wffk1kZ+RyqxVUlbjSagNgPm94frxtr+XDL12E5Ll1enWskLrtrZ2r8L3wED1orIibV/w==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ] - }, - "node_modules/@rollup/rollup-android-arm64": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.12.0.tgz", - "integrity": "sha512-OBqcX2BMe6nvjQ0Nyp7cC90cnumt8PXmO7Dp3gfAju/6YwG0Tj74z1vKrfRz7qAv23nBcYM8BCbhrsWqO7PzQQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ] - }, - "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.12.0.tgz", - "integrity": "sha512-X64tZd8dRE/QTrBIEs63kaOBG0b5GVEd3ccoLtyf6IdXtHdh8h+I56C2yC3PtC9Ucnv0CpNFJLqKFVgCYe0lOQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.12.0.tgz", - "integrity": "sha512-cc71KUZoVbUJmGP2cOuiZ9HSOP14AzBAThn3OU+9LcA1+IUqswJyR1cAJj3Mg55HbjZP6OLAIscbQsQLrpgTOg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.12.0.tgz", - "integrity": "sha512-a6w/Y3hyyO6GlpKL2xJ4IOh/7d+APaqLYdMf86xnczU3nurFTaVN9s9jOXQg97BE4nYm/7Ga51rjec5nfRdrvA==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.12.0.tgz", - "integrity": "sha512-0fZBq27b+D7Ar5CQMofVN8sggOVhEtzFUwOwPppQt0k+VR+7UHMZZY4y+64WJ06XOhBTKXtQB/Sv0NwQMXyNAA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.12.0.tgz", - "integrity": "sha512-eTvzUS3hhhlgeAv6bfigekzWZjaEX9xP9HhxB0Dvrdbkk5w/b+1Sxct2ZuDxNJKzsRStSq1EaEkVSEe7A7ipgQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.12.0.tgz", - "integrity": "sha512-ix+qAB9qmrCRiaO71VFfY8rkiAZJL8zQRXveS27HS+pKdjwUfEhqo2+YF2oI+H/22Xsiski+qqwIBxVewLK7sw==", - "cpu": [ - "riscv64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.12.0.tgz", - "integrity": "sha512-TenQhZVOtw/3qKOPa7d+QgkeM6xY0LtwzR8OplmyL5LrgTWIXpTQg2Q2ycBf8jm+SFW2Wt/DTn1gf7nFp3ssVA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.12.0.tgz", - "integrity": "sha512-LfFdRhNnW0zdMvdCb5FNuWlls2WbbSridJvxOvYWgSBOYZtgBfW9UGNJG//rwMqTX1xQE9BAodvMH9tAusKDUw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.12.0.tgz", - "integrity": "sha512-JPDxovheWNp6d7AHCgsUlkuCKvtu3RB55iNEkaQcf0ttsDU/JZF+iQnYcQJSk/7PtT4mjjVG8N1kpwnI9SLYaw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.12.0.tgz", - "integrity": "sha512-fjtuvMWRGJn1oZacG8IPnzIV6GF2/XG+h71FKn76OYFqySXInJtseAqdprVTDTyqPxQOG9Exak5/E9Z3+EJ8ZA==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.12.0.tgz", - "integrity": "sha512-ZYmr5mS2wd4Dew/JjT0Fqi2NPB/ZhZ2VvPp7SmvPZb4Y1CG/LRcS6tcRo2cYU7zLK5A7cdbhWnnWmUjoI4qapg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ] - }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -1924,12 +1754,6 @@ "@babel/types": "^7.20.7" } }, - "node_modules/@types/estree": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", - "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", - "dev": true - }, "node_modules/@types/graceful-fs": { "version": "4.1.9", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", @@ -1980,9 +1804,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.11.19", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.19.tgz", - "integrity": "sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==", + "version": "20.11.20", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.20.tgz", + "integrity": "sha512-7/rR21OS+fq8IyHTgtLkDK949uzsa6n8BkziAKtPVpugIkO6D+/ooXMvzXxDnZrmtXVfjb1bKQafYpb8s89LOg==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -2487,9 +2311,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001588", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001588.tgz", - "integrity": "sha512-+hVY9jE44uKLkH0SrUTqxjxqNTOWHsbnQDIKjwkZ3lNTzUUVdBLBGXtj/q5Mp5u98r3droaZAewQuEDzjQdZlQ==", + "version": "1.0.30001589", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001589.tgz", + "integrity": "sha512-vNQWS6kI+q6sBlHbh71IIeC+sRwK2N3EDySc/updIGhIee2x5z00J4c1242/5/d6EpEMdOnk/m+6tuk4/tcsqg==", "dev": true, "funding": [ { @@ -2772,9 +2596,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.675", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.675.tgz", - "integrity": "sha512-+1u3F/XPNIdUwv8i1lDxHAxCvNNU0QIqgb1Ycn+Jnng8ITzWSvUqixRSM7NOazJuwhf65IV17f/VbKj8DmL26A==", + "version": "1.4.680", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.680.tgz", + "integrity": "sha512-4nToZ5jlPO14W82NkF32wyjhYqQByVaDmLy4J2/tYcAbJfgO2TKJC780Az1V13gzq4l73CJ0yuyalpXvxXXD9A==", "dev": true }, "node_modules/emittery": { @@ -3210,9 +3034,9 @@ } }, "node_modules/flatted": { - "version": "3.2.9", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.9.tgz", - "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", + "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "dev": true }, "node_modules/fs.realpath": { @@ -4427,9 +4251,9 @@ "dev": true }, "node_modules/nanoid": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.5.tgz", - "integrity": "sha512-/Veqm+QKsyMY3kqi4faWplnY1u+VuKO3dD2binyPIybP31DRO29bPF+1mszgLnrR2KqSLceFLBNw0zmvDzN1QQ==", + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.6.tgz", + "integrity": "sha512-rRq0eMHoGZxlvaFOUdK1Ev83Bd1IgzzR+WJ3IbDJ7QOSdAxYjlurSPqFs9s4lJg29RT6nPwizFtJhQS6V5xgiA==", "dev": true, "funding": [ { @@ -4936,38 +4760,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/rollup": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.12.0.tgz", - "integrity": "sha512-wz66wn4t1OHIJw3+XU7mJJQV/2NAfw5OAk6G6Hoo3zcvz/XOfQ52Vgi+AN4Uxoxi0KBBwk2g8zPrTDA4btSB/Q==", - "dev": true, - "dependencies": { - "@types/estree": "1.0.5" - }, - "bin": { - "rollup": "dist/bin/rollup" - }, - "engines": { - "node": ">=18.0.0", - "npm": ">=8.0.0" - }, - "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.12.0", - "@rollup/rollup-android-arm64": "4.12.0", - "@rollup/rollup-darwin-arm64": "4.12.0", - "@rollup/rollup-darwin-x64": "4.12.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.12.0", - "@rollup/rollup-linux-arm64-gnu": "4.12.0", - "@rollup/rollup-linux-arm64-musl": "4.12.0", - "@rollup/rollup-linux-riscv64-gnu": "4.12.0", - "@rollup/rollup-linux-x64-gnu": "4.12.0", - "@rollup/rollup-linux-x64-musl": "4.12.0", - "@rollup/rollup-win32-arm64-msvc": "4.12.0", - "@rollup/rollup-win32-ia32-msvc": "4.12.0", - "@rollup/rollup-win32-x64-msvc": "4.12.0", - "fsevents": "~2.3.2" - } - }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", diff --git a/package.json b/package.json index b364795..95be194 100644 --- a/package.json +++ b/package.json @@ -3,21 +3,12 @@ "version": "5.0.0-rc.3", "description": "A tiny event-based state manager Storeon for Velo by Wix", "type": "module", - "main": "lib/index.cjs", - "module": "lib/index.js", - "types": "./index.d.ts", - "exports": { - ".": { - "types": "./index.d.ts", - "require": "./lib/index.cjs", - "import": "./lib/index.js", - "default": "./lib/index.js" - } - }, + "main": "src/index.js", + "types": "./src/index.d.ts", + "exports": "./src/index.js", "sideEffects": false, "scripts": { "lint": "eslint src/**/*.js tests/**/*.js", - "build": "rollup -c", "size": "size-limit", "test": "node --experimental-vm-modules node_modules/.bin/jest" }, @@ -28,7 +19,6 @@ "eslint": "^8.56.0", "eslint-plugin-jest": "^27.9.0", "jest": "^29.7.0", - "rollup": "^4.12.0", "size-limit": "^11.0.2" }, "repository": { @@ -49,8 +39,7 @@ "redux" ], "files": [ - "lib", - "index.d.ts" + "src" ], "author": { "name": "Alexander Zaytsev", diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index c61968f..0000000 --- a/rollup.config.js +++ /dev/null @@ -1,22 +0,0 @@ -import { existsSync } from 'node:fs'; -import { rm } from 'node:fs/promises'; - -if (existsSync('./lib')) { - await rm('./lib', { recursive: true }); -} - -export default { - input: './src/index.js', - output: [ - { - file: './lib/index.js', - format: 'es', - }, - { - file: './lib/index.cjs', - format: 'cjs', - interop: false, - esModule: false, - }, - ], -}; diff --git a/index.d.ts b/src/index.d.ts similarity index 100% rename from index.d.ts rename to src/index.d.ts diff --git a/tests/setState.spec.js b/tests/setState.spec.js index 5d479b1..284d796 100644 --- a/tests/setState.spec.js +++ b/tests/setState.spec.js @@ -1,4 +1,4 @@ -import { createStoreon } from '../lib'; +import { createStoreon } from '..'; describe('getState method', () => { it('should update state', () => { From 5b49a2ced762cf91e7b56b2126752ac0c91daf0c Mon Sep 17 00:00:00 2001 From: shoonia Date: Thu, 22 Feb 2024 22:32:35 +0200 Subject: [PATCH 2/3] Remove build script --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f979d9c..48a4eac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,5 @@ jobs: - run: npm ci - run: npm run lint - - run: npm run build - run: npm test - run: npm run size From 3655100ea79b54bba1ffd5d1f5e05e91e81b9371 Mon Sep 17 00:00:00 2001 From: shoonia Date: Thu, 22 Feb 2024 22:34:11 +0200 Subject: [PATCH 3/3] Release v5.0.0-rc.4 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index d49184a..41055d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "storeon-velo", - "version": "5.0.0-rc.3", + "version": "5.0.0-rc.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "storeon-velo", - "version": "5.0.0-rc.3", + "version": "5.0.0-rc.4", "license": "MIT", "devDependencies": { "@evilmartians/lefthook": "^1.6.1", diff --git a/package.json b/package.json index 95be194..0866176 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "storeon-velo", - "version": "5.0.0-rc.3", + "version": "5.0.0-rc.4", "description": "A tiny event-based state manager Storeon for Velo by Wix", "type": "module", "main": "src/index.js",