Upgrade masto.js to V5

- Fix all breaking changes
- Have to manual remove null/undefined values before creating statuses
- Have to recreate iterator instance if start from scratch because can't pass args in next()
This commit is contained in:
Lim Chee Aun 2022-12-25 23:28:55 +08:00
parent cf4fbc8553
commit 318c2aeffc
9 changed files with 267 additions and 174 deletions

287
package-lock.json generated
View file

@ -14,7 +14,7 @@
"history": "~5.3.0", "history": "~5.3.0",
"iconify-icon": "~1.0.2", "iconify-icon": "~1.0.2",
"just-debounce-it": "~3.2.0", "just-debounce-it": "~3.2.0",
"masto": "~4.11.1", "masto": "~5.0.4",
"mem": "~9.0.2", "mem": "~9.0.2",
"preact": "~10.11.3", "preact": "~10.11.3",
"preact-router": "~4.1.0", "preact-router": "~4.1.0",
@ -2150,6 +2150,18 @@
"resolved": "https://registry.npmjs.org/@juggle/resize-observer/-/resize-observer-3.4.0.tgz", "resolved": "https://registry.npmjs.org/@juggle/resize-observer/-/resize-observer-3.4.0.tgz",
"integrity": "sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA==" "integrity": "sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA=="
}, },
"node_modules/@mastojs/ponyfills": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@mastojs/ponyfills/-/ponyfills-1.0.4.tgz",
"integrity": "sha512-1NaIGmcU7OmyNzx0fk+cYeGTkdXlOJOSdetaC4pStVWsrhht2cdlYSAfe5NDW3FcUmcEm2vVceB9lcClN1RCxw==",
"dependencies": {
"@types/node": "^18.11.17",
"@types/node-fetch": "^2.6.2",
"abort-controller": "^3.0.0",
"form-data": "^4.0.0",
"node-fetch": "^2.6.7"
}
},
"node_modules/@nodelib/fs.scandir": { "node_modules/@nodelib/fs.scandir": {
"version": "2.1.5", "version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@ -2450,8 +2462,29 @@
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "18.11.17", "version": "18.11.17",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.17.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.17.tgz",
"integrity": "sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng==", "integrity": "sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng=="
"dev": true },
"node_modules/@types/node-fetch": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.2.tgz",
"integrity": "sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==",
"dependencies": {
"@types/node": "*",
"form-data": "^3.0.0"
}
},
"node_modules/@types/node-fetch/node_modules/form-data": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz",
"integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
}, },
"node_modules/@types/resolve": { "node_modules/@types/resolve": {
"version": "1.17.1", "version": "1.17.1",
@ -2543,6 +2576,17 @@
"dev": true, "dev": true,
"peer": true "peer": true
}, },
"node_modules/abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
"dependencies": {
"event-target-shim": "^5.0.0"
},
"engines": {
"node": ">=6.5"
}
},
"node_modules/acorn": { "node_modules/acorn": {
"version": "8.8.1", "version": "8.8.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
@ -2647,16 +2691,6 @@
"postcss": "^8.1.0" "postcss": "^8.1.0"
} }
}, },
"node_modules/axios": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.1.3.tgz",
"integrity": "sha512-00tXVRwKx/FZr/IDVFt4C+f9FYairX517WoGCL6dpOntqLkZofjhu43F/Xl44UOpqa+9sLFDrG/XAnFsUYgkDA==",
"dependencies": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/babel-plugin-polyfill-corejs2": { "node_modules/babel-plugin-polyfill-corejs2": {
"version": "0.3.3", "version": "0.3.3",
"resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz", "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz",
@ -3167,6 +3201,14 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
"engines": {
"node": ">=6"
}
},
"node_modules/eventemitter3": { "node_modules/eventemitter3": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.0.tgz", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.0.tgz",
@ -3256,25 +3298,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/follow-redirects": {
"version": "1.15.2",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/form-data": { "node_modules/form-data": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
@ -3836,27 +3859,6 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/isomorphic-form-data": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isomorphic-form-data/-/isomorphic-form-data-2.0.0.tgz",
"integrity": "sha512-TYgVnXWeESVmQSg4GLVbalmQ+B4NPi/H4eWxqALKj63KsUrcu301YDjBqaOw3h+cbak7Na4Xyps3BiptHtxTfg==",
"dependencies": {
"form-data": "^2.3.2"
}
},
"node_modules/isomorphic-form-data/node_modules/form-data": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz",
"integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.6",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 0.12"
}
},
"node_modules/isomorphic-ws": { "node_modules/isomorphic-ws": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz", "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz",
@ -4146,14 +4148,13 @@
} }
}, },
"node_modules/masto": { "node_modules/masto": {
"version": "4.11.1", "version": "5.0.4",
"resolved": "https://registry.npmjs.org/masto/-/masto-4.11.1.tgz", "resolved": "https://registry.npmjs.org/masto/-/masto-5.0.4.tgz",
"integrity": "sha512-siTQNhfLV1JjOERCGgjagMvD6q0K0hLuhOXrbXNcYzHAwpbPeSeAM6CSpIRrZ8zFDepOR62Djs/GtJdTR21Rfw==", "integrity": "sha512-oMveJRoq/VdkgMXZNoZ6CvFyr5WdzH2zNIcK3QdHNlAOt1HkoqyHjPVicgjxq/lnwv6grqLB/XvlYA2N6ltVyA==",
"dependencies": { "dependencies": {
"axios": "1.1.3", "@mastojs/ponyfills": "^1.0.4",
"change-case": "^4.1.2", "change-case": "^4.1.2",
"eventemitter3": "^5.0.0", "eventemitter3": "^5.0.0",
"isomorphic-form-data": "^2.0.0",
"isomorphic-ws": "^5.0.0", "isomorphic-ws": "^5.0.0",
"semver": "^7.3.7", "semver": "^7.3.7",
"ws": "^8.8.0" "ws": "^8.8.0"
@ -4285,6 +4286,44 @@
"tslib": "^2.0.3" "tslib": "^2.0.3"
} }
}, },
"node_modules/node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/node-fetch/node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
"node_modules/node-fetch/node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
},
"node_modules/node-fetch/node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/node-releases": { "node_modules/node-releases": {
"version": "2.0.6", "version": "2.0.6",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz",
@ -4509,11 +4548,6 @@
"resolved": "https://registry.npmjs.org/proxy-compare/-/proxy-compare-2.3.0.tgz", "resolved": "https://registry.npmjs.org/proxy-compare/-/proxy-compare-2.3.0.tgz",
"integrity": "sha512-c3L2CcAi7f7pvlD0D7xsF+2CQIW8C3HaYx2Pfgq8eA4HAl3GAH6/dVYsyBbYF/0XJs2ziGLrzmz5fmzPm6A0pQ==" "integrity": "sha512-c3L2CcAi7f7pvlD0D7xsF+2CQIW8C3HaYx2Pfgq8eA4HAl3GAH6/dVYsyBbYF/0XJs2ziGLrzmz5fmzPm6A0pQ=="
}, },
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/punycode": { "node_modules/punycode": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
@ -7178,6 +7212,18 @@
"resolved": "https://registry.npmjs.org/@juggle/resize-observer/-/resize-observer-3.4.0.tgz", "resolved": "https://registry.npmjs.org/@juggle/resize-observer/-/resize-observer-3.4.0.tgz",
"integrity": "sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA==" "integrity": "sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA=="
}, },
"@mastojs/ponyfills": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@mastojs/ponyfills/-/ponyfills-1.0.4.tgz",
"integrity": "sha512-1NaIGmcU7OmyNzx0fk+cYeGTkdXlOJOSdetaC4pStVWsrhht2cdlYSAfe5NDW3FcUmcEm2vVceB9lcClN1RCxw==",
"requires": {
"@types/node": "^18.11.17",
"@types/node-fetch": "^2.6.2",
"abort-controller": "^3.0.0",
"form-data": "^4.0.0",
"node-fetch": "^2.6.7"
}
},
"@nodelib/fs.scandir": { "@nodelib/fs.scandir": {
"version": "2.1.5", "version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@ -7406,8 +7452,28 @@
"@types/node": { "@types/node": {
"version": "18.11.17", "version": "18.11.17",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.17.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.17.tgz",
"integrity": "sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng==", "integrity": "sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng=="
"dev": true },
"@types/node-fetch": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.2.tgz",
"integrity": "sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==",
"requires": {
"@types/node": "*",
"form-data": "^3.0.0"
},
"dependencies": {
"form-data": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz",
"integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
}
}
}, },
"@types/resolve": { "@types/resolve": {
"version": "1.17.1", "version": "1.17.1",
@ -7499,6 +7565,14 @@
"dev": true, "dev": true,
"peer": true "peer": true
}, },
"abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
"requires": {
"event-target-shim": "^5.0.0"
}
},
"acorn": { "acorn": {
"version": "8.8.1", "version": "8.8.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
@ -7562,16 +7636,6 @@
"postcss-value-parser": "^4.2.0" "postcss-value-parser": "^4.2.0"
} }
}, },
"axios": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.1.3.tgz",
"integrity": "sha512-00tXVRwKx/FZr/IDVFt4C+f9FYairX517WoGCL6dpOntqLkZofjhu43F/Xl44UOpqa+9sLFDrG/XAnFsUYgkDA==",
"requires": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"babel-plugin-polyfill-corejs2": { "babel-plugin-polyfill-corejs2": {
"version": "0.3.3", "version": "0.3.3",
"resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz", "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz",
@ -7958,6 +8022,11 @@
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
"dev": true "dev": true
}, },
"event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
},
"eventemitter3": { "eventemitter3": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.0.tgz", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.0.tgz",
@ -8040,11 +8109,6 @@
"to-regex-range": "^5.0.1" "to-regex-range": "^5.0.1"
} }
}, },
"follow-redirects": {
"version": "1.15.2",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz",
"integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA=="
},
"form-data": { "form-data": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
@ -8439,26 +8503,6 @@
"call-bind": "^1.0.2" "call-bind": "^1.0.2"
} }
}, },
"isomorphic-form-data": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isomorphic-form-data/-/isomorphic-form-data-2.0.0.tgz",
"integrity": "sha512-TYgVnXWeESVmQSg4GLVbalmQ+B4NPi/H4eWxqALKj63KsUrcu301YDjBqaOw3h+cbak7Na4Xyps3BiptHtxTfg==",
"requires": {
"form-data": "^2.3.2"
},
"dependencies": {
"form-data": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz",
"integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.6",
"mime-types": "^2.1.12"
}
}
}
},
"isomorphic-ws": { "isomorphic-ws": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz", "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz",
@ -8685,14 +8729,13 @@
} }
}, },
"masto": { "masto": {
"version": "4.11.1", "version": "5.0.4",
"resolved": "https://registry.npmjs.org/masto/-/masto-4.11.1.tgz", "resolved": "https://registry.npmjs.org/masto/-/masto-5.0.4.tgz",
"integrity": "sha512-siTQNhfLV1JjOERCGgjagMvD6q0K0hLuhOXrbXNcYzHAwpbPeSeAM6CSpIRrZ8zFDepOR62Djs/GtJdTR21Rfw==", "integrity": "sha512-oMveJRoq/VdkgMXZNoZ6CvFyr5WdzH2zNIcK3QdHNlAOt1HkoqyHjPVicgjxq/lnwv6grqLB/XvlYA2N6ltVyA==",
"requires": { "requires": {
"axios": "1.1.3", "@mastojs/ponyfills": "^1.0.4",
"change-case": "^4.1.2", "change-case": "^4.1.2",
"eventemitter3": "^5.0.0", "eventemitter3": "^5.0.0",
"isomorphic-form-data": "^2.0.0",
"isomorphic-ws": "^5.0.0", "isomorphic-ws": "^5.0.0",
"semver": "^7.3.7", "semver": "^7.3.7",
"ws": "^8.8.0" "ws": "^8.8.0"
@ -8787,6 +8830,35 @@
"tslib": "^2.0.3" "tslib": "^2.0.3"
} }
}, },
"node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"requires": {
"whatwg-url": "^5.0.0"
},
"dependencies": {
"tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
"webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
},
"whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"requires": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
}
}
},
"node-releases": { "node-releases": {
"version": "2.0.6", "version": "2.0.6",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz",
@ -8941,11 +9013,6 @@
"resolved": "https://registry.npmjs.org/proxy-compare/-/proxy-compare-2.3.0.tgz", "resolved": "https://registry.npmjs.org/proxy-compare/-/proxy-compare-2.3.0.tgz",
"integrity": "sha512-c3L2CcAi7f7pvlD0D7xsF+2CQIW8C3HaYx2Pfgq8eA4HAl3GAH6/dVYsyBbYF/0XJs2ziGLrzmz5fmzPm6A0pQ==" "integrity": "sha512-c3L2CcAi7f7pvlD0D7xsF+2CQIW8C3HaYx2Pfgq8eA4HAl3GAH6/dVYsyBbYF/0XJs2ziGLrzmz5fmzPm6A0pQ=="
}, },
"proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"punycode": { "punycode": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",

View file

@ -16,7 +16,7 @@
"history": "~5.3.0", "history": "~5.3.0",
"iconify-icon": "~1.0.2", "iconify-icon": "~1.0.2",
"just-debounce-it": "~3.2.0", "just-debounce-it": "~3.2.0",
"masto": "~4.11.1", "masto": "~5.0.4",
"mem": "~9.0.2", "mem": "~9.0.2",
"preact": "~10.11.3", "preact": "~10.11.3",
"preact-router": "~4.1.0", "preact-router": "~4.1.0",

View file

@ -27,7 +27,7 @@ const { VITE_CLIENT_NAME: CLIENT_NAME } = import.meta.env;
window.__STATES__ = states; window.__STATES__ = states;
async function startStream() { async function startStream() {
const stream = await masto.stream.streamUser(); const stream = await masto.v1.stream.streamUser();
console.log('STREAM START', { stream }); console.log('STREAM START', { stream });
stream.on('update', (status) => { stream.on('update', (status) => {
console.log('UPDATE', status); console.log('UPDATE', status);
@ -119,22 +119,20 @@ function startVisibility() {
// Buffer for WS reconnect // Buffer for WS reconnect
(async () => { (async () => {
try { try {
const fetchHome = masto.timelines.fetchHome({ const fetchHome = masto.v1.timelines.listHome({
limit: 2, limit: 2,
// Need 2 because "new posts" only appear when there are 2 or more // Need 2 because "new posts" only appear when there are 2 or more
}); });
const fetchNotifications = masto.notifications const fetchNotifications = masto.v1.notifications.list({
.iterate({
limit: 1, limit: 1,
}) });
.next();
const newStatuses = await fetchHome; const newStatuses = await fetchHome;
if ( if (
newStatuses.value.length && newStatuses.length &&
newStatuses.value[0].id !== states.home[0].id newStatuses[0].id !== states.home[0].id
) { ) {
states.homeNew = newStatuses.value.map((status) => { states.homeNew = newStatuses.map((status) => {
states.statuses.set(status.id, status); states.statuses.set(status.id, status);
if (status.reblog) { if (status.reblog) {
states.statuses.set(status.reblog.id, status.reblog); states.statuses.set(status.reblog.id, status.reblog);
@ -148,8 +146,8 @@ function startVisibility() {
} }
const newNotifications = await fetchNotifications; const newNotifications = await fetchNotifications;
if (newNotifications.value.length) { if (newNotifications.length) {
const notification = newNotifications.value[0]; const notification = newNotifications[0];
const inNotificationsNew = states.notificationsNew.find( const inNotificationsNew = states.notificationsNew.find(
(n) => n.id === notification.id, (n) => n.id === notification.id,
); );
@ -242,7 +240,7 @@ export function App() {
timeout: 30_000, timeout: 30_000,
}); });
const mastoAccount = await masto.accounts.verifyCredentials(); const mastoAccount = await masto.v1.accounts.verifyCredentials();
console.log({ tokenJSON, mastoAccount }); console.log({ tokenJSON, mastoAccount });
@ -307,7 +305,7 @@ export function App() {
// Collect instance info // Collect instance info
(async () => { (async () => {
const info = await masto.instances.fetch(); const info = await masto.v2.instance.fetch();
console.log(info); console.log(info);
const { uri } = info; const { uri } = info;
const instances = store.local.getJSON('instances') || {}; const instances = store.local.getJSON('instances') || {};

View file

@ -20,7 +20,7 @@ function Account({ account }) {
setUIState('loading'); setUIState('loading');
(async () => { (async () => {
try { try {
const info = await masto.accounts.lookup({ const info = await masto.v1.accounts.lookup({
acct: account, acct: account,
skip_webfinger: false, skip_webfinger: false,
}); });
@ -69,7 +69,9 @@ function Account({ account }) {
setRelationshipUIState('loading'); setRelationshipUIState('loading');
(async () => { (async () => {
try { try {
const relationships = await masto.accounts.fetchRelationships([id]); const relationships = await masto.v1.accounts.fetchRelationships([
id,
]);
console.log('fetched relationship', relationships); console.log('fetched relationship', relationships);
if (relationships.length) { if (relationships.length) {
setRelationship(relationships[0]); setRelationship(relationships[0]);
@ -200,10 +202,12 @@ function Account({ account }) {
'Are you sure that you want to unfollow this account?', 'Are you sure that you want to unfollow this account?',
); );
if (yes) { if (yes) {
newRelationship = await masto.accounts.unfollow(id); newRelationship = await masto.v1.accounts.unfollow(
id,
);
} }
} else { } else {
newRelationship = await masto.accounts.follow(id); newRelationship = await masto.v1.accounts.follow(id);
} }
if (newRelationship) setRelationship(newRelationship); if (newRelationship) setRelationship(newRelationship);
setRelationshipUIState('default'); setRelationshipUIState('default');

View file

@ -90,7 +90,7 @@ function Compose({
const customEmojis = useRef(); const customEmojis = useRef();
useEffect(() => { useEffect(() => {
(async () => { (async () => {
const emojis = await masto.customEmojis.fetchAll(); const emojis = await masto.v1.customEmojis.list();
console.log({ emojis }); console.log({ emojis });
customEmojis.current = emojis; customEmojis.current = emojis;
})(); })();
@ -161,7 +161,9 @@ function Compose({
setUIState('loading'); setUIState('loading');
(async () => { (async () => {
try { try {
const statusSource = await masto.statuses.fetchSource(editStatus.id); const statusSource = await masto.v1.statuses.fetchSource(
editStatus.id,
);
console.log({ statusSource }); console.log({ statusSource });
const { text, spoilerText } = statusSource; const { text, spoilerText } = statusSource;
textareaRef.current.value = text; textareaRef.current.value = text;
@ -236,15 +238,16 @@ function Compose({
}[key]; }[key];
provide( provide(
new Promise((resolve) => { new Promise((resolve) => {
const resultsIterator = masto.search({ const searchResults = masto.v2.search({
type, type,
q: text, q: text,
limit: 5, limit: 5,
}); });
resultsIterator.next().then(({ value }) => { searchResults.then((value) => {
if (text !== textExpanderTextRef.current) { if (text !== textExpanderTextRef.current) {
return; return;
} }
console.log({ value, type, v: value[type] });
const results = value[type]; const results = value[type];
console.log('RESULTS', value, results); console.log('RESULTS', value, results);
let html = ''; let html = '';
@ -614,11 +617,13 @@ function Compose({
// If already uploaded // If already uploaded
return attachment; return attachment;
} else { } else {
const params = { const params = removeNullUndefined({
file, file,
description, description,
}; });
return masto.mediaAttachments.create(params).then((res) => { return masto.v2.mediaAttachments
.create(params)
.then((res) => {
if (res.id) { if (res.id) {
attachment.id = res.id; attachment.id = res.id;
} }
@ -648,7 +653,7 @@ function Compose({
console.log({ results, mediaAttachments }); console.log({ results, mediaAttachments });
} }
const params = { let params = {
status, status,
spoilerText, spoilerText,
sensitive, sensitive,
@ -659,13 +664,17 @@ function Compose({
params.visibility = visibility; params.visibility = visibility;
params.inReplyToId = replyToStatus?.id || undefined; params.inReplyToId = replyToStatus?.id || undefined;
} }
params = removeNullUndefined(params);
console.log('POST', params); console.log('POST', params);
let newStatus; let newStatus;
if (editStatus) { if (editStatus) {
newStatus = await masto.statuses.update(editStatus.id, params); newStatus = await masto.v1.statuses.update(
editStatus.id,
params,
);
} else { } else {
newStatus = await masto.statuses.create(params); newStatus = await masto.v1.statuses.create(params);
} }
setUIState('default'); setUIState('default');
@ -1129,4 +1138,13 @@ function countableText(inputText) {
.replace(usernameRegex, '$1@$3'); .replace(usernameRegex, '$1@$3');
} }
function removeNullUndefined(obj) {
for (let key in obj) {
if (obj[key] === null || obj[key] === undefined) {
delete obj[key];
}
}
return obj;
}
export default Compose; export default Compose;

View file

@ -28,7 +28,7 @@ import Avatar from './avatar';
import Icon from './icon'; import Icon from './icon';
function fetchAccount(id) { function fetchAccount(id) {
return masto.accounts.fetch(id); return masto.v1.accounts.fetch(id);
} }
const memFetchAccount = mem(fetchAccount); const memFetchAccount = mem(fetchAccount);
@ -521,10 +521,12 @@ function Status({
reblogsCount: reblogsCount + (reblogged ? -1 : 1), reblogsCount: reblogsCount + (reblogged ? -1 : 1),
}); });
if (reblogged) { if (reblogged) {
const newStatus = await masto.statuses.unreblog(id); const newStatus = await masto.v1.statuses.unreblog(
id,
);
states.statuses.set(newStatus.id, newStatus); states.statuses.set(newStatus.id, newStatus);
} else { } else {
const newStatus = await masto.statuses.reblog(id); const newStatus = await masto.v1.statuses.reblog(id);
states.statuses.set(newStatus.id, newStatus); states.statuses.set(newStatus.id, newStatus);
states.statuses.set( states.statuses.set(
newStatus.reblog.id, newStatus.reblog.id,
@ -558,10 +560,12 @@ function Status({
favouritesCount + (favourited ? -1 : 1), favouritesCount + (favourited ? -1 : 1),
}); });
if (favourited) { if (favourited) {
const newStatus = await masto.statuses.unfavourite(id); const newStatus = await masto.v1.statuses.unfavourite(
id,
);
states.statuses.set(newStatus.id, newStatus); states.statuses.set(newStatus.id, newStatus);
} else { } else {
const newStatus = await masto.statuses.favourite(id); const newStatus = await masto.v1.statuses.favourite(id);
states.statuses.set(newStatus.id, newStatus); states.statuses.set(newStatus.id, newStatus);
} }
} catch (e) { } catch (e) {
@ -587,10 +591,12 @@ function Status({
bookmarked: !bookmarked, bookmarked: !bookmarked,
}); });
if (bookmarked) { if (bookmarked) {
const newStatus = await masto.statuses.unbookmark(id); const newStatus = await masto.v1.statuses.unbookmark(
id,
);
states.statuses.set(newStatus.id, newStatus); states.statuses.set(newStatus.id, newStatus);
} else { } else {
const newStatus = await masto.statuses.bookmark(id); const newStatus = await masto.v1.statuses.bookmark(id);
states.statuses.set(newStatus.id, newStatus); states.statuses.set(newStatus.id, newStatus);
} }
} catch (e) { } catch (e) {
@ -942,7 +948,7 @@ function Poll({ poll, readOnly, onUpdate = () => {} }) {
setUIState('loading'); setUIState('loading');
(async () => { (async () => {
try { try {
const pollResponse = await masto.poll.fetch(id); const pollResponse = await masto.v1.poll.fetch(id);
onUpdate(pollResponse); onUpdate(pollResponse);
} catch (e) { } catch (e) {
// Silent fail // Silent fail
@ -1026,7 +1032,7 @@ function Poll({ poll, readOnly, onUpdate = () => {} }) {
}); });
console.log(votes); console.log(votes);
setUIState('loading'); setUIState('loading');
const pollResponse = await masto.poll.vote(id, { const pollResponse = await masto.v1.poll.vote(id, {
choices: votes, choices: votes,
}); });
console.log(pollResponse); console.log(pollResponse);
@ -1075,7 +1081,7 @@ function Poll({ poll, readOnly, onUpdate = () => {} }) {
setUIState('loading'); setUIState('loading');
(async () => { (async () => {
try { try {
const pollResponse = await masto.poll.fetch(id); const pollResponse = await masto.v1.poll.fetch(id);
onUpdate(pollResponse); onUpdate(pollResponse);
} catch (e) { } catch (e) {
// Silent fail // Silent fail
@ -1119,7 +1125,7 @@ function EditedAtModal({ statusID, onClose = () => {} }) {
setUIState('loading'); setUIState('loading');
(async () => { (async () => {
try { try {
const editHistory = await masto.statuses.fetchHistory(statusID); const editHistory = await masto.v1.statuses.listHistory(statusID);
console.log(editHistory); console.log(editHistory);
setEditHistory(editHistory); setEditHistory(editHistory);
setUIState('default'); setUIState('default');

View file

@ -16,18 +16,18 @@ function Home({ hidden }) {
const [showMore, setShowMore] = useState(false); const [showMore, setShowMore] = useState(false);
const homeIterator = useRef( const homeIterator = useRef(
masto.timelines.iterateHome({ masto.v1.timelines.listHome({
limit: LIMIT, limit: LIMIT,
}), }),
).current;
async function fetchStatuses(firstLoad) {
const allStatuses = await homeIterator.next(
firstLoad
? {
limit: LIMIT,
}
: undefined,
); );
async function fetchStatuses(firstLoad) {
if (firstLoad) {
// Reset iterator
homeIterator.current = masto.v1.timelines.listHome({
limit: LIMIT,
});
}
const allStatuses = await homeIterator.current.next();
if (allStatuses.value <= 0) { if (allStatuses.value <= 0) {
return { done: true }; return { done: true };
} }

View file

@ -212,18 +212,18 @@ function Notifications() {
const [onlyMentions, setOnlyMentions] = useState(false); const [onlyMentions, setOnlyMentions] = useState(false);
const notificationsIterator = useRef( const notificationsIterator = useRef(
masto.notifications.iterate({ masto.v1.notifications.list({
limit: LIMIT, limit: LIMIT,
}), }),
).current;
async function fetchNotifications(firstLoad) {
const allNotifications = await notificationsIterator.next(
firstLoad
? {
limit: LIMIT,
}
: undefined,
); );
async function fetchNotifications(firstLoad) {
if (firstLoad) {
// Reset iterator
notificationsIterator.current = masto.v1.notifications.list({
limit: LIMIT,
});
}
const allNotifications = await notificationsIterator.current.next();
if (allNotifications.value <= 0) { if (allNotifications.value <= 0) {
return { done: true }; return { done: true };
} }

View file

@ -72,8 +72,8 @@ function StatusPage({ id }) {
} }
(async () => { (async () => {
const heroFetch = masto.statuses.fetch(id); const heroFetch = masto.v1.statuses.fetch(id);
const contextFetch = masto.statuses.fetchContext(id); const contextFetch = masto.v1.statuses.fetchContext(id);
const hasStatus = snapStates.statuses.has(id); const hasStatus = snapStates.statuses.has(id);
let heroStatus = snapStates.statuses.get(id); let heroStatus = snapStates.statuses.get(id);