diff --git a/.editorconfig b/.editorconfig index f40d3d29..f4da4406 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,5 +8,5 @@ trim_trailing_whitespace = true indent_size = 4 indent_style = space -[*.nix] +[*.{nix,yaml,yml}] indent_size = 2 diff --git a/.eslintignore b/.eslintignore index 19f051eb..a250337d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -94,3 +94,5 @@ typings/ config .eslintrc.js !.storybook + +src/lib/chrome-extension-toolkit diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 2261f56e..451d6b6f 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -205,7 +205,7 @@ module.exports = { { target: './src/shared', from: './', - except: ['./src/shared', './node_modules'], + except: ['./src/shared', './node_modules', './src/lib/chrome-extension-toolkit'], message: 'You cannot import into `shared` from an external directory.', }, ], @@ -227,6 +227,6 @@ module.exports = { 'simple-import-sort/imports': 'error', 'simple-import-sort/exports': 'error', 'import-essentials/restrict-import-depth': 'error', - 'import-essentials/check-path-alias': 'error', + // 'import-essentials/check-path-alias': 'error', }, }; diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f80cf5f4..f11d0a2c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,18 +1,20 @@ --- name: Bug report about: Create a report to help us improve -title: "[BUG] " +title: '[BUG] ' labels: '' assignees: '' - --- **Pre-submission Checklist** -- [ ] I confirmed this feature isn’t already requested, implemented, or planned (search open issues, pull requests etc) -- [ ] I have completed all sections below with detailed information +- [ ] I have searched existing issues to make sure this is not a duplicate +- [ ] I have cleared my browser cache and confirmed the issue persists +- [ ] I have checked this issue affects the latest version of the extension +- [ ] I have disabled other extensions to ensure this isn't a conflict issue +- [ ] I have included all the information requested below **Bug Description** @@ -39,9 +41,9 @@ assignees: '' **Debug Information** -- UTRP Extension Version: [e.g. 1.2.0] -- Browser Info: [e.g. Chrome 120.0.0] -- OS: [e.g. Windows 11, macOS Sonoma] +- UTRP Extension Version: [e.g. 1.2.0] +- Browser Info: [e.g. Chrome 120.0.0] +- OS: [e.g. Windows 11, macOS Sonoma] **Console Logs** diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index d21504b5..d87cca8e 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,18 +1,20 @@ --- name: Feature Request about: Suggest an idea for this project -title: "[FEATURE] " +title: '[FEATURE] ' labels: feature assignees: '' - --- **Pre-submission Checklist** -- [ ] I confirmed this feature isn’t already requested, implemented, or planned (search open issues, pull requests etc) -- [ ] I have completed all sections below with detailed information +- [ ] I have searched existing issues to ensure this feature hasn't been requested +- [ ] I have searched closed issues to check if this was previously rejected/implemented +- [ ] I have checked the project roadmap (if available) for planned similar features +- [ ] I have reviewed the documentation to confirm this feature doesn't exist +- [ ] I have completed all sections below with detailed information **Your Idea** diff --git a/.github/ISSUE_TEMPLATE/updating-build-dependencies.md b/.github/ISSUE_TEMPLATE/updating-build-dependencies.md index 9aedf541..7603a7f9 100644 --- a/.github/ISSUE_TEMPLATE/updating-build-dependencies.md +++ b/.github/ISSUE_TEMPLATE/updating-build-dependencies.md @@ -4,7 +4,6 @@ about: Updating Build Dependencies title: '' labels: build, dependencies assignees: doprz, Razboy20 - --- - [ ] Updated Nix Flake diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d93fb431..ad62cbda 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,21 +1,20 @@ version: 2 updates: - - package-ecosystem: 'npm' - directory: '/' - schedule: - interval: 'weekly' - day: 'monday' - time: '09:00' - timezone: 'America/Chicago' - groups: - minor-and-patch-updates: - update-types: - - 'minor' - - 'patch' - major-updates: - update-types: - - 'major' - - ignore: - - dependency-name: '@crxjs/vite-plugin' - - dependency-name: '@unocss/vite' + - package-ecosystem: 'npm' + directory: '/' + schedule: + interval: 'weekly' + day: 'monday' + time: '09:00' + timezone: 'America/Chicago' + groups: + minor-and-patch-updates: + update-types: + - 'minor' + - 'patch' + major-updates: + update-types: + - 'major' + ignore: + - dependency-name: '@crxjs/vite-plugin' + - dependency-name: '@unocss/vite' diff --git a/.github/workflows/best-practices.yml b/.github/workflows/best-practices.yml index 1f8fd579..9094f284 100644 --- a/.github/workflows/best-practices.yml +++ b/.github/workflows/best-practices.yml @@ -1,43 +1,33 @@ name: Best Practices - on: [push, pull_request] - jobs: - lint: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 10 - - - name: Install dependencies - run: pnpm install - - - name: Run ESLint - run: pnpm run lint - format: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 10 - - - name: Install dependencies - run: pnpm install - - - name: Run Prettier - run: pnpm run prettier + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + - name: Install dependencies + run: pnpm install + - name: Run ESLint + run: pnpm run lint + format: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + - name: Install dependencies + run: pnpm install + - name: Run Prettier + run: pnpm run prettier diff --git a/.github/workflows/check-types.yml b/.github/workflows/check-types.yml index 0ffd77da..b5fe537f 100644 --- a/.github/workflows/check-types.yml +++ b/.github/workflows/check-types.yml @@ -1,24 +1,18 @@ name: Type Check - on: [push, pull_request] - jobs: - type-check: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 10 - - - name: Install dependencies - run: pnpm install - - - name: Run tests - run: pnpm run check-types + type-check: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + - name: Install dependencies + run: pnpm install + - name: Run tests + run: pnpm run check-types diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index a0fb4dfe..3f7dba63 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -1,26 +1,22 @@ name: 'Chromatic' - on: [push, pull_request] - jobs: - chromatic: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 10 - - - name: Install dependencies - run: pnpm install - - - name: Publish to Chromatic - uses: chromaui/action@latest - with: - projectToken: chpt_e8bd07b0b27d8eb - exitZeroOnChanges: true - autoAcceptChanges: 'main' + chromatic: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + - name: Install dependencies + run: pnpm install + - name: Publish to Chromatic + uses: chromaui/action@latest + with: + projectToken: chpt_e8bd07b0b27d8eb + exitZeroOnChanges: true + autoAcceptChanges: 'main' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 71535534..db8ba73f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,25 +1,24 @@ name: Create Release on: - push: - branches: - - production - - preview + push: + branches: + - production + - preview jobs: - build: - name: build extension & create release - runs-on: ubuntu-latest - concurrency: - group: ${{ github.ref }} - cancel-in-progress: true - steps: - - uses: actions/checkout@master - - name: Get file permission - run: chmod -R 777 . - - - name: Install dependencies - run: npm ci - - name: Release with semantic-release - id: semantic-release - run: npx --no-install semantic-release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + build: + name: build extension & create release + runs-on: ubuntu-latest + concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + steps: + - uses: actions/checkout@master + - name: Get file permission + run: chmod -R 777 . + - name: Install dependencies + run: npm ci + - name: Release with semantic-release + id: semantic-release + run: npx --no-install semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1e6227dc..4ddde8a5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,24 +1,18 @@ name: Tests - on: [push, pull_request] - jobs: - test: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 10 - - - name: Install dependencies - run: pnpm install - - - name: Run tests - run: pnpm test + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + - name: Install dependencies + run: pnpm install + - name: Run tests + run: pnpm test diff --git a/.github/workflows/validate-pr.yml b/.github/workflows/validate-pr.yml index 8e612c71..95db3d3b 100644 --- a/.github/workflows/validate-pr.yml +++ b/.github/workflows/validate-pr.yml @@ -1,43 +1,40 @@ name: Validate PR Title - # thank you ben limmer for this workflow: # https://github.com/blimmer/semantic-release-demo-2/blob/main/.github/workflows/lint-pr.yml - on: - pull_request_target: - types: - - opened - - reopened - - edited - - synchronize - + pull_request_target: + types: + - opened + - reopened + - edited + - synchronize jobs: - main: - runs-on: ubuntu-latest - steps: - - uses: amannn/action-semantic-pull-request@v3.2.6 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Post Conventional Commit Comment (on failure) - uses: jungwinter/comment@v1 - id: conventional-commit-help - with: - type: create - issue_number: ${{ github.event.pull_request.number }} - token: ${{ secrets.GITHUB_TOKEN }} - body: | - Your pull request title did not conform to [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) standards. Our upcoming automated release pipeline will automatically determine - the proper release version based on your pull request title. - **Cheat Sheet** - - feat: A new feature - - fix: A bug fix - - docs: Documentation only changes - - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) - - refactor: A code change that neither fixes a bug nor adds a feature - - perf: A code change that improves performance - - test: Adding missing tests or correcting existing tests - - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) - - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) - - chore: Other changes that don't modify src or test files - - revert: Reverts a previous commit - if: ${{ failure() }} + main: + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v3.2.6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Post Conventional Commit Comment (on failure) + uses: jungwinter/comment@v1 + id: conventional-commit-help + with: + type: create + issue_number: ${{ github.event.pull_request.number }} + token: ${{ secrets.GITHUB_TOKEN }} + body: | + Your pull request title did not conform to [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) standards. Our upcoming automated release pipeline will automatically determine + the proper release version based on your pull request title. + **Cheat Sheet** + - feat: A new feature + - fix: A bug fix + - docs: Documentation only changes + - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) + - refactor: A code change that neither fixes a bug nor adds a feature + - perf: A code change that improves performance + - test: Adding missing tests or correcting existing tests + - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) + - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) + - chore: Other changes that don't modify src or test files + - revert: Reverts a previous commit + if: ${{ failure() }} diff --git a/.gitignore b/.gitignore index 770da4e8..8a86a447 100644 --- a/.gitignore +++ b/.gitignore @@ -212,4 +212,9 @@ package-lock.json storybook-static/ package/ -.direnv/ +# Nix +result +result-* + +# direnv +.direnv diff --git a/.storybook/vite-storybook.config.ts b/.storybook/vite-storybook.config.ts index 047953c6..344e514e 100644 --- a/.storybook/vite-storybook.config.ts +++ b/.storybook/vite-storybook.config.ts @@ -23,6 +23,7 @@ export default defineConfig({ '@shared': resolve(root, 'shared'), '@background': resolve(pagesDir, 'background'), '@views': resolve(root, 'views'), + '@chrome-extension-toolkit': resolve(root, 'lib/chrome-extension-toolkit'), }, }, }); diff --git a/.vscode/launch.json b/.vscode/launch.json index 3a274ea0..fe650bc6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,13 +6,9 @@ "request": "launch", "name": "Run current script", "runtimeExecutable": "npx", - "runtimeArgs": [ - "tsx" - ], + "runtimeArgs": ["tsx"], "program": "${file}", - "skipFiles": [ - "/**" - ], + "skipFiles": ["/**"] } ] -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json index a89cbd32..9685063e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -26,7 +26,7 @@ "navigation": "Routes", "logging": "log", "popup": "Layout", - "storage": "Database", + "storage": "Database" }, "material-icon-theme.files.associations": { "tsconfig.extension.json": "tsconfig", @@ -36,5 +36,5 @@ "[html]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "typescript.tsdk": "node_modules/typescript/lib", + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/CHANGELOG.md b/CHANGELOG.md index a12cb885..a7d7b5ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +## [2.3.0](https://github.com/Longhorn-Developers/UT-Registration-Plus/compare/v2.2.2...v2.3.0) (2026-01-07) + +### Features + +* add drag-and-drop import for schedules ([#661](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/661)) ([549c52a](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/549c52a39fee718f2bb07cfce33a294835a2246b)), closes [#446](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/446) +* allow bypassing the 10-schedule limit ([#675](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/675)) ([6a67a32](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/6a67a32e4f50a5bdd20aa43789f199b822483e2d)) +* condense resourceLinks course schedule ([#676](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/676)) ([cee5f02](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/cee5f0284f09f39ca5ae64559d0b697646c77e74)) +* LHD birthday ([#717](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/717)) ([2d18553](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/2d18553f98c5146fa18699ae20462e7dcbc9d35c)) +* **nix:** add prettier-version-match check ([#713](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/713)) ([8ccf7fb](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/8ccf7fb37e769ba445f39c140ca9c1c4245cc1c1)) +* **nix:** build UTRP ([#714](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/714)) ([38bb29b](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/38bb29b20b97ed3cf8fd6511df16553fed1d58bb)) + +### Bug Fixes + +* .editorconfig syntax for nix files ([b406d4d](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/b406d4dd244a25688c2b9621cf5d441228bd8913)) +* toSorted outdated chrome bug ([#694](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/694)) ([4f5d8c6](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/4f5d8c6d20e3cfeb7b62520ba1819e297d2cc60f)) ## [2.2.2](https://github.com/Longhorn-Developers/UT-Registration-Plus/compare/v2.2.1...v2.2.2) (2025-10-13) ### Features @@ -6,6 +21,7 @@ * automatically select new or duplicated schedules ([#583](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/583)) ([#589](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/589)) ([2a50f55](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/2a50f5580d3dbeb0d66546c23cf29bbb37d80da2)) * **env:** add SENTRY env vars ([8f7e1bc](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/8f7e1bc0af6336549068e02b80df21d4e8f4ef9c)) * export schedule button add to calendar ([#594](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/594)) ([5994ded](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/5994ded8be876cb55174d27d3fdb0832b21a0ff9)) +* **release:** v2.2.2 ([c21cbd7](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/c21cbd77f0764c03a711589ff4f957cb8c936eec)) * search result shading ([#617](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/617)) ([be861b8](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/be861b823cb2cb7f6f4a1f266351eec3fc1c2f99)) * show warning for courses of different semesters ([#570](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/570)) ([2e7dac1](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/2e7dac1e3eba757231ac07ac966231c08c703a16)) * support summer grades, fix summer course parser ([#596](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues/596)) ([2d92dd4](https://github.com/Longhorn-Developers/UT-Registration-Plus/commit/2d92dd47f00a44b7d48e92a8ffba94480e4e73f9)) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 38a5e364..5fd56688 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -8,21 +8,21 @@ This isn’t an exhaustive list of things that you can’t do. Rather, take it i This code of conduct applies to all spaces managed by the UT Registration Plus project or Longhorn Developers. This includes IRC, the mailing lists, the issue tracker, DSF events, and any other forums created by the project team which the community uses for communication. In addition, violations of this code outside these spaces may affect a person's ability to participate within them. -If you believe someone is violating the code of conduct, we ask that you report it by emailing [contact@longhorns.dev](mailto:contact@longhorns.dev). For more details please see our +If you believe someone is violating the code of conduct, we ask that you report it by emailing [contact@longhorns.dev](mailto:contact@longhorns.dev). For more details please see our - **Be friendly and patient.** - **Be welcoming.** We strive to be a community that welcomes and supports people of all backgrounds and identities. This includes, but is not limited to members of any race, ethnicity, culture, national origin, colour, immigration status, social and economic class, educational level, sex, sexual orientation, gender identity and expression, age, size, family status, political belief, religion, and mental and physical ability. - **Be considerate.** Your work will be used by other people, and you in turn will depend on the work of others. Any decision you take will affect users and colleagues, and you should take those consequences into account when making decisions. Remember that we're a world-wide community, so you might not be communicating in someone else's primary language. - **Be respectful.** Not all of us will agree all the time, but disagreement is no excuse for poor behavior and poor manners. We might all experience some frustration now and then, but we cannot allow that frustration to turn into a personal attack. It’s important to remember that a community where people feel uncomfortable or threatened is not a productive one. Members of the UT Registration Plus community should be respectful when dealing with other members as well as with people outside the UT Registration Plus community. -- **Be careful in the words that you choose.** We are a community of professionals, and we conduct ourselves professionally. Be kind to others. Do not insult or put down other participants. Harassment and other exclusionary behavior aren't acceptable. This includes, but is not limited to: - - Violent threats or language directed against another person. - - Discriminatory jokes and language. - - Posting sexually explicit or violent material. - - Posting (or threatening to post) other people's personally identifying information ("doxing"). - - Personal insults, especially those using racist or sexist terms. - - Unwelcome sexual attention. - - Advocating for, or encouraging, any of the above behavior. - - Repeated harassment of others. In general, if someone asks you to stop, then stop. +- **Be careful in the words that you choose.** We are a community of professionals, and we conduct ourselves professionally. Be kind to others. Do not insult or put down other participants. Harassment and other exclusionary behavior aren't acceptable. This includes, but is not limited to: +- Violent threats or language directed against another person. +- Discriminatory jokes and language. +- Posting sexually explicit or violent material. +- Posting (or threatening to post) other people's personally identifying information ("doxing"). +- Personal insults, especially those using racist or sexist terms. +- Unwelcome sexual attention. +- Advocating for, or encouraging, any of the above behavior. +- Repeated harassment of others. In general, if someone asks you to stop, then stop. - **When we disagree, try to understand why.** Disagreements, both social and technical, happen all the time and UT Registration Plus is no exception. It is important that we resolve disagreements and differing views constructively. Remember that we’re different. The strength of UT Registration Plus comes from its varied community, people from a wide range of backgrounds. Different people have different perspectives on issues. Being unable to understand why someone holds a viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to err and blaming each other doesn’t get us anywhere. Instead, focus on helping to resolve issues and learning from mistakes. Original text courtesy of the [Speak Up! project](http://web.archive.org/web/20141109123859/http://speakup.io/coc.html). diff --git a/DOCKER_DEV_SETUP.md b/DOCKER_DEV_SETUP.md index c879b938..c80858b2 100644 --- a/DOCKER_DEV_SETUP.md +++ b/DOCKER_DEV_SETUP.md @@ -2,8 +2,8 @@ ## Prerequisites -- Docker installed on your machine -- Git (to clone the repository) +- Docker installed on your machine +- Git (to clone the repository) ## Getting Started @@ -70,9 +70,9 @@ docker run -it --rm -v $(pwd)/dist:/extension/dist -p 5173:5173 -e BUILD_MODE=de ## Accessing the Built Extension -- For build mode, the extension files will be in the `dist` directory on your host machine. -- For zip mode, the zipped extension will be in the `package` directory on your host machine. -- For dev mode, the extension will be continuously built in the `dist` directory, and you can load it as an unpacked extension in Chrome. +- For build mode, the extension files will be in the `dist` directory on your host machine. +- For zip mode, the zipped extension will be in the `package` directory on your host machine. +- For dev mode, the extension will be continuously built in the `dist` directory, and you can load it as an unpacked extension in Chrome. ## Docker Development Workflow @@ -85,5 +85,5 @@ When working on the extension: ## Troubleshooting -- If you encounter permission issues with the output directories, ensure that the directories exist on your host machine and have the correct permissions. -- For any other issues, please check the Docker logs or open an issue in the GitHub repository. +- If you encounter permission issues with the output directories, ensure that the directories exist on your host machine and have the correct permissions. +- For any other issues, please check the Docker logs or open an issue in the GitHub repository. diff --git a/LICENSE.md b/LICENSE.md index e6a57fae..e1cff0a2 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/README.md b/README.md index 792e1cca..8949de8d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ![Downloads](https://img.shields.io/chrome-web-store/d/hboadpjkoaieogjimneceaahlppnipaa) ![License](https://img.shields.io/github/license/Longhorn-Developers/UT-Registration-Plus) -**UT Registration Plus (UTRP)** streamlines the process of registering for classes at UT Austin by reducing the chaos of juggling multiple tabs like Rate My Professor, Google Sheets, and the UT Course Schedule. With UTRP, you can simplify class selection and schedule management. We've all been there. 20 tabs of Rate My Professor, Google Spreadsheet, and the UT Course Schedule open and you still don't know what classes to take. +**UT Registration Plus (UTRP)** streamlines the process of registering for classes at UT Austin by reducing the chaos of juggling multiple tabs like Rate My Professor, Google Sheets, and the UT Course Schedule. With UTRP, you can simplify class selection and schedule management. We've all been there. 20 tabs of Rate My Professor, Google Spreadsheet, and the UT Course Schedule open and you still don't know what classes to take. ## Demo @@ -14,37 +14,37 @@ ## Features -- **Quick Access to Class Info**: For each class in the UT Course Schedule, UTRP provides a "breakdown" popup with direct links to RateMyProfessor, Course Evaluation Surveys (CES), and past syllabi. -- **Prerequisite & Restriction Highlights**: Displays course descriptions with highlighted details on prerequisites, restrictions, and other important info. -- **Grade Distribution Graphs**: View an aggregate and semester-specific graph of grade distributions for each course. -- **Saved Courses List**: Easily add courses to a list and view them in the extension popup. Copy unique numbers with a single click. -- **Conflict Detection**: Automatically highlights and strikes out courses that conflict with your saved courses in the UT Course Catalog. -- **Weekly Schedule View**: Displays your saved courses in a weekly schedule format for easier planning. -- **Multiple Schedule Support**: Create multiple schedules to plan for different registration scenarios. -- **And much more!** +- **Quick Access to Class Info**: For each class in the UT Course Schedule, UTRP provides a "breakdown" popup with direct links to RateMyProfessor, Course Evaluation Surveys (CES), and past syllabi. +- **Prerequisite & Restriction Highlights**: Displays course descriptions with highlighted details on prerequisites, restrictions, and other important info. +- **Grade Distribution Graphs**: View an aggregate and semester-specific graph of grade distributions for each course. +- **Saved Courses List**: Easily add courses to a list and view them in the extension popup. Copy unique numbers with a single click. +- **Conflict Detection**: Automatically highlights and strikes out courses that conflict with your saved courses in the UT Course Catalog. +- **Weekly Schedule View**: Displays your saved courses in a weekly schedule format for easier planning. +- **Multiple Schedule Support**: Create multiple schedules to plan for different registration scenarios. +- **And much more!** ## Toolchain -- React v20.9.0 (LTS) -- TypeScript v5.x -- Vite v5.x -- pnpm v10.x -- UnoCSS -- ESLint -- Prettier -- Storybook -- Figma -- Semantic-Release -- Custom Messaging & Storage Wrappers +- React v20.9.0 (LTS) +- TypeScript v5.x +- Vite v5.x +- pnpm v10.x +- UnoCSS +- ESLint +- Prettier +- Storybook +- Figma +- Semantic-Release +- Custom Messaging & Storage Wrappers ## VSCode Extensions We recommend using the following VSCode extensions to improve your development experience: -- **[ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)**: For identifying and fixing linting issues. -- **[Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)**: For automatic code formatting. -- **[Tailwind CSS IntelliSense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss)**: For Tailwind CSS class autocomplete and IntelliSense. -- **[UnoCSS](https://marketplace.visualstudio.com/items?itemName=antfu.unocss)**: For better support with UnoCSS utilities. +- **[ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)**: For identifying and fixing linting issues. +- **[Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)**: For automatic code formatting. +- **[Tailwind CSS IntelliSense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss)**: For Tailwind CSS class autocomplete and IntelliSense. +- **[UnoCSS](https://marketplace.visualstudio.com/items?itemName=antfu.unocss)**: For better support with UnoCSS utilities. ## Contributing @@ -79,7 +79,7 @@ Once set up, the extension can be built to the `dist/` directory using the follo ### Development Builds -- Run the development server: +- Run the development server: ```bash pnpm dev ``` @@ -92,7 +92,7 @@ Once set up, the extension can be built to the `dist/` directory using the follo ### Production Builds -- To generate production builds: +- To generate production builds: ```bash pnpm build ``` @@ -121,10 +121,10 @@ To load the extension manually in Chrome: If you encounter bugs or issues, please report them in the [Issues](https://github.com/Longhorn-Developers/UT-Registration-Plus/issues) section, including: -- A clear, descriptive title -- Steps to reproduce the issue -- Expected behavior -- Screenshots or logs (if applicable) +- A clear, descriptive title +- Steps to reproduce the issue +- Expected behavior +- Screenshots or logs (if applicable) We aim to address issues promptly. @@ -142,14 +142,14 @@ Follow this structure for commit messages: Where: -- **type**: One of the following: - - `feat`: A new feature - - `fix`: A bug fix - - `docs`: Documentation updates - - `style`: Code formatting changes (whitespace, semicolons, etc.) - - `refactor`: Code restructuring (without adding features or fixing bugs) - - `test`: Adding or modifying tests - - `chore`: Maintenance tasks or build process changes +- **type**: One of the following: + - `feat`: A new feature + - `fix`: A bug fix + - `docs`: Documentation updates + - `style`: Code formatting changes (whitespace, semicolons, etc.) + - `refactor`: Code restructuring (without adding features or fixing bugs) + - `test`: Adding or modifying tests + - `chore`: Maintenance tasks or build process changes Example: @@ -168,9 +168,9 @@ Branch names should follow the format: Examples: -- `feat/user-login` -- `fix/navbar-layout` -- `docs/update-readme` +- `feat/user-login` +- `fix/navbar-layout` +- `docs/update-readme` ## License @@ -184,28 +184,28 @@ We maintain a strict code of conduct. By contributing, you agree to adhere to th Special thanks to the developers and contributors behind these amazing tools and libraries: -- React v20.9.0 (LTS) -- TypeScript v5.x -- Vite v5.x -- pnpm v10.x -- UnoCSS -- ESLint -- Prettier -- Storybook -- Figma -- Semantic-Release -- [chrome-extension-toolkit](https://github.com/sghsri/chrome-extension-toolkit) -- [UT_Grade_Parser](https://github.com/doprz/UT_Grade_Parser) -- [eslint-plugin-import-essentials](https://github.com/doprz/eslint-plugin-import-essentials) -- [UT Registration Plus v1.2.2.7](https://github.com/Longhorn-Developers/UT-Registration-Plus/tree/legacy) by @sghsri -- [UT Registration Planner](https://github.com/doprz/UT-Registration-Planner) by @doprz -- [Figma Designs](https://www.figma.com/design/8tsCay2FRqctrdcZ3r9Ahw/UTRP) by @IsaDavRod -- [Longhorn Developers](https://github.com/Longhorn-Developers) - established in 2024 -- The UTRP devs, beta testers, and all supporters of the project! +- React v20.9.0 (LTS) +- TypeScript v5.x +- Vite v5.x +- pnpm v10.x +- UnoCSS +- ESLint +- Prettier +- Storybook +- Figma +- Semantic-Release +- [chrome-extension-toolkit](https://github.com/sghsri/chrome-extension-toolkit) +- [UT_Grade_Parser](https://github.com/doprz/UT_Grade_Parser) +- [eslint-plugin-import-essentials](https://github.com/doprz/eslint-plugin-import-essentials) +- [UT Registration Plus v1.2.2.7](https://github.com/Longhorn-Developers/UT-Registration-Plus/tree/legacy) by @sghsri +- [UT Registration Planner](https://github.com/doprz/UT-Registration-Planner) by @doprz +- [Figma Designs](https://www.figma.com/design/8tsCay2FRqctrdcZ3r9Ahw/UTRP) by @IsaDavRod +- [Longhorn Developers](https://github.com/Longhorn-Developers) - established in 2024 +- The UTRP devs, beta testers, and all supporters of the project! ## Activity -![UT-Registration-Plus Activity](https://repobeats.axiom.co/api/embed/47930fa3916ac1b475cd63a05948c449eb5ad502.svg "UT-Registration-Plus Repobeats analytics image") +![UT-Registration-Plus Activity](https://repobeats.axiom.co/api/embed/47930fa3916ac1b475cd63a05948c449eb5ad502.svg 'UT-Registration-Plus Repobeats analytics image') ## Star History diff --git a/chromatic.config.json b/chromatic.config.json index aeb5a24c..4b32d86e 100644 --- a/chromatic.config.json +++ b/chromatic.config.json @@ -1,5 +1,5 @@ { - "onlyChanged": true, - "projectId": "Project:65c5172964f36dcf207985bf", - "zip": true + "onlyChanged": true, + "projectId": "Project:65c5172964f36dcf207985bf", + "zip": true } diff --git a/default.nix b/default.nix new file mode 100644 index 00000000..b1565619 --- /dev/null +++ b/default.nix @@ -0,0 +1,10 @@ +(import ( + let + rev = "v1.1.0"; + sha256 = "sha256:19d2z6xsvpxm184m41qrpi1bplilwipgnzv9jy17fgw421785q1m"; + in + fetchTarball { + inherit sha256; + url = "https://github.com/NixOS/flake-compat/archive/${rev}.tar.gz"; + } +) { src = ./.; }).defaultNix diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 5d937781..42ffb086 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -24,7 +24,7 @@ else fi # Validate the mode -if [[ ! " ${SUPPORTED_MODES[*]} " =~ " ${mode} " ]]; then +if [[ ! " ${SUPPORTED_MODES[*]} " =~ ${mode} ]]; then echo "Error: Invalid mode '${mode}'" >&2 usage fi diff --git a/docs/WebSocket-Implementation-Tutorial.md b/docs/WebSocket-Implementation-Tutorial.md deleted file mode 100644 index e69de29b..00000000 diff --git a/flake.lock b/flake.lock index 31fe6379..af19e613 100644 --- a/flake.lock +++ b/flake.lock @@ -1,30 +1,30 @@ { "nodes": { - "flake-utils": { + "flake-parts": { "inputs": { - "systems": "systems" + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "lastModified": 1767609335, + "narHash": "sha256-feveD98mQpptwrAEggBQKJTYbvwwglSbOv53uCfH9PY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "250481aafeb741edfe23d29195671c19b36b6dca", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1759831965, - "narHash": "sha256-vgPm2xjOmKdZ0xKA6yLXPJpjOtQPHfaZDRtH+47XEBo=", + "lastModified": 1767640445, + "narHash": "sha256-UWYqmD7JFBEDBHWYcqE6s6c77pWdcU/i+bwD6XxMb8A=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c9b6fb798541223bbb396d287d16f43520250518", + "rev": "9f0c42f8bc7151b8e7e5840fb3bd454ad850d8c5", "type": "github" }, "original": { @@ -34,24 +34,59 @@ "type": "github" } }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - }, - "systems": { + "nixpkgs-lib": { "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "lastModified": 1765674936, + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", "type": "github" }, "original": { - "owner": "nix-systems", - "repo": "default", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1761236834, + "narHash": "sha256-+pthv6hrL5VLW2UqPdISGuLiUZ6SnAXdd2DdUE+fV2Q=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d5faa84122bc0a1fd5d378492efce4e289f8eac1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1767468822, + "narHash": "sha256-MpffQxHxmjVKMiQd0Tg2IM/bSjjdQAM+NDcX6yxj7rE=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "d56486eb9493ad9c4777c65932618e9c2d0468fc", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", "type": "github" } } diff --git a/flake.nix b/flake.nix index 6dbdba38..3b8a6360 100644 --- a/flake.nix +++ b/flake.nix @@ -1,43 +1,33 @@ { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; + flake-parts.url = "github:hercules-ci/flake-parts"; + treefmt-nix.url = "github:numtide/treefmt-nix"; }; outputs = - { - self, - nixpkgs, - flake-utils, - }: - flake-utils.lib.eachDefaultSystem ( - system: - let - pkgs = (import nixpkgs { inherit system; }); + inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = inputs.nixpkgs.lib.systems.flakeExposed; - commonPackages = with pkgs; [ - nodejs_20 # v20.19.5 - pnpm_10 # v10.18.0 - ]; + imports = [ + ./nix/packages.nix + ./nix/devShells.nix + ./nix/treefmt.nix + ]; - additionalPackages = with pkgs; [ - bun - nodePackages.conventional-changelog-cli - sentry-cli - ]; - in - { - formatter = pkgs.nixfmt-rfc-style; - - devShells.default = pkgs.mkShell { - name = "utrp-dev"; - buildInputs = commonPackages; + perSystem = + { system, ... }: + { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ + (final: prev: { + nodejs = prev.nodejs_20; # v20.19.5 + }) + ]; + config = { }; + }; }; - - devShells.full = pkgs.mkShell { - name = "utrp-dev-full"; - buildInputs = commonPackages ++ additionalPackages; - }; - } - ); + }; } diff --git a/nix/devShells.nix b/nix/devShells.nix new file mode 100644 index 00000000..e24b0475 --- /dev/null +++ b/nix/devShells.nix @@ -0,0 +1,30 @@ +{ + perSystem = + { + pkgs, + ... + }: + let + commonPackages = with pkgs; [ + nodejs # Defined in overlay + pnpm_10 # v10.18.2 + ]; + + additionalPackages = with pkgs; [ + bun + nodePackages.conventional-changelog-cli + sentry-cli + ]; + in + { + devShells.default = pkgs.mkShell { + name = "utrp-dev"; + packages = commonPackages; + }; + + devShells.full = pkgs.mkShell { + name = "utrp-dev-full"; + packages = commonPackages ++ additionalPackages; + }; + }; +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 00000000..9e896d46 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,51 @@ +{ + stdenv, + lib, + nodejs, + pnpm_10, + git, + version ? "dev", + gitRev ? "unknown", + gitBranch ? "unknown", + buildScript ? "build", +}: + +stdenv.mkDerivation (finalAttrs: { + inherit version; + pname = "ut-registration-plus"; + + src = ../.; + + nativeBuildInputs = [ + nodejs + pnpm_10.configHook + git + ]; + + pnpmDeps = pnpm_10.fetchDeps { + inherit (finalAttrs) pname version src; + fetcherVersion = 2; + hash = "sha256-UqHymJWvlTV4glra/6DkxuCxbG5dpPkFcnvq3vuxsJ8="; + }; + + # Pass git info to the build + VITE_GIT_COMMIT = gitRev; + VITE_GIT_BRANCH = gitBranch; + + buildPhase = '' + pnpm run ${buildScript} + ''; + + installPhase = '' + mkdir -p $out + cp -r dist/* $out/ + ''; + + meta = { + description = "UT Registration Plus"; + homepage = "https://github.com/Longhorn-Developers/UT-Registration-Plus"; + license = lib.licenses.mit; + maintainers = lib.maintainers.doprz; + platforms = lib.platforms.unix; + }; +}) diff --git a/nix/packages.nix b/nix/packages.nix new file mode 100644 index 00000000..bc68bb65 --- /dev/null +++ b/nix/packages.nix @@ -0,0 +1,40 @@ +{ inputs, ... }: +{ + perSystem = + { pkgs, ... }: + let + packageJson = builtins.fromJSON (builtins.readFile ../package.json); + gitRev = inputs.self.shortRev or inputs.self.dirtyShortRev or "dev"; + gitBranch = if inputs.self ? ref then inputs.self.ref else "unknown"; + baseVersion = packageJson.version; + + commonArgs = { + inherit gitRev gitBranch; + }; + + # Prod variant + ut-registration-plus = pkgs.callPackage ./package.nix ( + commonArgs + // { + version = "${baseVersion}+git.${gitRev}"; + buildScript = "build"; + } + ); + + # Dev variant + ut-registration-plus-dev = pkgs.callPackage ./package.nix ( + commonArgs + // { + version = "${baseVersion}-dev+git.${gitRev}"; + buildScript = "build:dev"; + } + ); + in + { + packages = { + inherit ut-registration-plus ut-registration-plus-dev; + default = ut-registration-plus; + dev = ut-registration-plus-dev; + }; + }; +} diff --git a/nix/treefmt.nix b/nix/treefmt.nix new file mode 100644 index 00000000..7c5cbb89 --- /dev/null +++ b/nix/treefmt.nix @@ -0,0 +1,63 @@ +{ inputs, ... }: +{ + imports = [ + inputs.treefmt-nix.flakeModule + ]; + + perSystem = + { pkgs, ... }: + { + treefmt = { + projectRootFile = "flake.nix"; + programs.nixfmt.enable = pkgs.lib.meta.availableOn pkgs.stdenv.buildPlatform pkgs.nixfmt-rfc-style.compiler; + programs.nixfmt.package = pkgs.nixfmt-rfc-style; + + # NOTE: Make sure the prettier version in package.json and the one used by treefmt are the same for consistent results + programs.prettier.enable = true; + programs.shellcheck.enable = true; + programs.yamlfmt.enable = true; + programs.dockerfmt.enable = true; + + settings.formatter.prettier.excludes = [ "pnpm-lock.yaml" ]; + settings.formatter.shellcheck.excludes = [ ".envrc" ]; + settings.formatter.yamlfmt.excludes = [ "pnpm-lock.yaml" ]; + }; + + checks = { + prettier-version-match = + pkgs.runCommand "check-prettier-version" + { + buildInputs = [ pkgs.jq ]; + } + '' + # Extract prettier version from package.json + packageJsonVersion=$(jq -r '.devDependencies.prettier // empty' ${../package.json}) + + if [ -z "$packageJsonVersion" ]; then + echo "Error: prettier not found in package.json devDependencies" + exit 1 + fi + + # Remove any semver prefix characters (^, ~, etc...) + packageJsonVersion=$(echo "$packageJsonVersion" | sed 's/^[\^~>=<]*//') + + # Get prettier version from nixpkgs + nixVersion="${pkgs.nodePackages.prettier.version}" + + if [ "$packageJsonVersion" != "$nixVersion" ]; then + echo "" + echo "ERROR: Prettier version mismatch!" + echo " package.json: $packageJsonVersion" + echo " nixpkgs: $nixVersion" + echo "" + echo "Please update one of the following:" + echo " - Update prettier in package.json to match nixpkgs: $nixVersion" + echo " - Override prettier in your flake to match package.json" + exit 1 + fi + + touch $out + ''; + }; + }; +} diff --git a/package.json b/package.json index 4b993997..c8cce387 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ut-registration-plus", "displayName": "UT Registration Plus", - "version": "2.2.2", + "version": "2.3.0", "description": "UT Registration Plus is a Chrome extension that allows students to easily register for classes.", "private": true, "homepage": "https://github.com/Longhorn-Developers/UT-Registration-Plus", @@ -39,9 +39,11 @@ "@phosphor-icons/react": "^2.1.7", "@sentry/react": "^8.55.0", "@tanstack/react-query": "^5.69.0", + "@tsparticles/engine": "^3.9.1", + "@tsparticles/react": "^3.0.0", + "@tsparticles/slim": "^3.9.1", "@unocss/vite": "^0.63.6", "@vitejs/plugin-react": "^4.3.4", - "chrome-extension-toolkit": "^0.0.54", "clsx": "^2.1.1", "conventional-changelog": "^6.0.0", "date-fns": "^4.1.0", @@ -134,9 +136,10 @@ "gulp": "^5.0.0", "gulp-execa": "^7.0.1", "gulp-zip": "^6.1.0", + "jsdom": "^28.0.0", "path": "^0.12.7", "postcss": "^8.5.3", - "prettier": "^3.5.2", + "prettier": "3.6.2", "react-dev-utils": "^12.0.1", "semantic-release": "^24.2.3", "storybook": "^8.6.0", @@ -159,7 +162,10 @@ }, "overrides": { "es-module-lexer": "^1.5.4" - } + }, + "onlyBuiltDependencies": [ + "@tsparticles/engine" + ] }, "volta": { "node": "20.19.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fd5613c8..f5afc312 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -49,15 +49,21 @@ importers: '@tanstack/react-query': specifier: ^5.69.0 version: 5.69.0(react@18.3.1) + '@tsparticles/engine': + specifier: ^3.9.1 + version: 3.9.1 + '@tsparticles/react': + specifier: ^3.0.0 + version: 3.0.0(@tsparticles/engine@3.9.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@tsparticles/slim': + specifier: ^3.9.1 + version: 3.9.1 '@unocss/vite': specifier: ^0.63.6 version: 0.63.6(patch_hash=9e2d2732a6e057a2ca90fba199730f252d8b4db8631b2c6ee0854fce7771bc95)(rollup@4.52.4)(typescript@5.7.3)(vite@5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0)) '@vitejs/plugin-react': specifier: ^4.3.4 version: 4.3.4(vite@5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0)) - chrome-extension-toolkit: - specifier: ^0.0.54 - version: 0.0.54 clsx: specifier: ^2.1.1 version: 2.1.1 @@ -154,25 +160,25 @@ importers: version: 8.55.0 '@storybook/addon-designs': specifier: ^8.2.0 - version: 8.2.0(@storybook/blocks@8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.5.2)))(@storybook/components@8.6.0(storybook@8.6.0(prettier@3.5.2)))(@storybook/theming@8.6.0(storybook@8.6.0(prettier@3.5.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + version: 8.2.0(@storybook/blocks@8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.6.2)))(@storybook/components@8.6.0(storybook@8.6.0(prettier@3.6.2)))(@storybook/theming@8.6.0(storybook@8.6.0(prettier@3.6.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@storybook/addon-essentials': specifier: ^8.6.0 - version: 8.6.0(@types/react@18.3.18)(storybook@8.6.0(prettier@3.5.2)) + version: 8.6.0(@types/react@18.3.18)(storybook@8.6.0(prettier@3.6.2)) '@storybook/addon-links': specifier: ^8.6.0 - version: 8.6.0(react@18.3.1)(storybook@8.6.0(prettier@3.5.2)) + version: 8.6.0(react@18.3.1)(storybook@8.6.0(prettier@3.6.2)) '@storybook/blocks': specifier: ^8.6.0 - version: 8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.5.2)) + version: 8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.6.2)) '@storybook/react': specifier: ^8.6.0 - version: 8.6.0(@storybook/test@8.6.0(storybook@8.6.0(prettier@3.5.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.5.2))(typescript@5.7.3) + version: 8.6.0(@storybook/test@8.6.0(storybook@8.6.0(prettier@3.6.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.6.2))(typescript@5.7.3) '@storybook/react-vite': specifier: ^8.6.0 - version: 8.6.0(@storybook/test@8.6.0(storybook@8.6.0(prettier@3.5.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(rollup@4.52.4)(storybook@8.6.0(prettier@3.5.2))(typescript@5.7.3)(vite@5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0)) + version: 8.6.0(@storybook/test@8.6.0(storybook@8.6.0(prettier@3.6.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(rollup@4.52.4)(storybook@8.6.0(prettier@3.6.2))(typescript@5.7.3)(vite@5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0)) '@storybook/test': specifier: ^8.6.0 - version: 8.6.0(storybook@8.6.0(prettier@3.5.2)) + version: 8.6.0(storybook@8.6.0(prettier@3.6.2)) '@svgr/core': specifier: ^8.1.0 version: 8.1.0(typescript@5.7.3) @@ -298,7 +304,7 @@ importers: version: 50.6.3(eslint@8.57.1) eslint-plugin-prettier: specifier: ^5.2.3 - version: 5.2.3(@types/eslint@9.6.1)(eslint-config-prettier@9.1.0(eslint@8.57.1))(eslint@8.57.1)(prettier@3.5.2) + version: 5.2.3(@types/eslint@9.6.1)(eslint-config-prettier@9.1.0(eslint@8.57.1))(eslint@8.57.1)(prettier@3.6.2) eslint-plugin-react: specifier: ^7.37.4 version: 7.37.4(eslint@8.57.1) @@ -329,6 +335,9 @@ importers: gulp-zip: specifier: ^6.1.0 version: 6.1.0(gulp@5.0.0) + jsdom: + specifier: ^28.0.0 + version: 28.0.0 path: specifier: ^0.12.7 version: 0.12.7 @@ -336,8 +345,8 @@ importers: specifier: ^8.5.3 version: 8.5.3 prettier: - specifier: ^3.5.2 - version: 3.5.2 + specifier: 3.6.2 + version: 3.6.2 react-dev-utils: specifier: ^12.0.1 version: 12.0.1(eslint@8.57.1)(typescript@5.7.3)(webpack@5.97.1(esbuild@0.25.10)) @@ -346,7 +355,7 @@ importers: version: 24.2.3(typescript@5.7.3) storybook: specifier: ^8.6.0 - version: 8.6.0(prettier@3.5.2) + version: 8.6.0(prettier@3.6.2) typescript: specifier: ^5.7.3 version: 5.7.3 @@ -367,10 +376,13 @@ importers: version: 0.8.9(rollup@4.52.4)(vite@5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0)) vitest: specifier: ^2.1.9 - version: 2.1.9(@types/node@22.13.5)(@vitest/ui@2.1.9)(sass@1.85.1)(terser@5.44.0) + version: 2.1.9(@types/node@22.13.5)(@vitest/ui@2.1.9)(happy-dom@20.5.0)(jsdom@28.0.0)(sass@1.85.1)(terser@5.44.0) packages: + '@acemir/cssom@0.9.31': + resolution: {integrity: sha512-ZnR3GSaH+/vJ0YlHau21FjfLYjMpYVIzTD8M8vIEQvIGxeOXyXdzCI140rrCY862p/C/BbzWsjc1dgnM9mkoTA==} + '@adobe/css-tools@4.4.2': resolution: {integrity: sha512-baYZExFpsdkBNuvGKTKWCwKH57HRZLVtycZS05WTQNVOiXVSeAki3nU35zlRbToeMW8aHlJfyS+1C4BOv27q0A==} @@ -390,6 +402,15 @@ packages: '@antfu/utils@8.1.1': resolution: {integrity: sha512-Mex9nXf9vR6AhcXmMrlz/HVgYYZpVGJ6YlPgwl7UnaFpnshXs6EK/oa5Gpf3CzENMjkvEx2tQtntGnb7UtSTOQ==} + '@asamuzakjp/css-color@4.1.2': + resolution: {integrity: sha512-NfBUvBaYgKIuq6E/RBLY1m0IohzNHAYyaJGuTK79Z23uNwmz2jl1mPsC5ZxCCxylinKhT1Amn5oNTlx1wN8cQg==} + + '@asamuzakjp/dom-selector@6.7.8': + resolution: {integrity: sha512-stisC1nULNc9oH5lakAj8MH88ZxeGxzyWNDfbdCxvJSJIvDsHNZqYvscGTgy/ysgXWLJPt6K/4t0/GjvtKcFJQ==} + + '@asamuzakjp/nwsapi@2.3.9': + resolution: {integrity: sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==} + '@babel/code-frame@7.26.2': resolution: {integrity: sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==} engines: {node: '>=6.9.0'} @@ -606,6 +627,37 @@ packages: resolution: {integrity: sha512-kSXgHHqCXASqJ8NmY94+KLGVwdtkJ0E7KsRQ+vbMpRliJ5ze0xnSk0l41p4txlUysmEoqaeo4Xb7rEFdcU2zjQ==} deprecated: Beta versions are no longer maintained. Please upgrade to the stable 2.0.0 release + '@csstools/color-helpers@6.0.1': + resolution: {integrity: sha512-NmXRccUJMk2AWA5A7e5a//3bCIMyOu2hAtdRYrhPPHjDxINuCwX1w6rnIZ4xjLcp0ayv6h8Pc3X0eJUGiAAXHQ==} + engines: {node: '>=20.19.0'} + + '@csstools/css-calc@3.0.0': + resolution: {integrity: sha512-q4d82GTl8BIlh/dTnVsWmxnbWJeb3kiU8eUH71UxlxnS+WIaALmtzTL8gR15PkYOexMQYVk0CO4qIG93C1IvPA==} + engines: {node: '>=20.19.0'} + peerDependencies: + '@csstools/css-parser-algorithms': ^4.0.0 + '@csstools/css-tokenizer': ^4.0.0 + + '@csstools/css-color-parser@4.0.1': + resolution: {integrity: sha512-vYwO15eRBEkeF6xjAno/KQ61HacNhfQuuU/eGwH67DplL0zD5ZixUa563phQvUelA07yDczIXdtmYojCphKJcw==} + engines: {node: '>=20.19.0'} + peerDependencies: + '@csstools/css-parser-algorithms': ^4.0.0 + '@csstools/css-tokenizer': ^4.0.0 + + '@csstools/css-parser-algorithms@4.0.0': + resolution: {integrity: sha512-+B87qS7fIG3L5h3qwJ/IFbjoVoOe/bpOdh9hAjXbvx0o8ImEmUsGXN0inFOnk2ChCFgqkkGFQ+TpM5rbhkKe4w==} + engines: {node: '>=20.19.0'} + peerDependencies: + '@csstools/css-tokenizer': ^4.0.0 + + '@csstools/css-syntax-patches-for-csstree@1.0.26': + resolution: {integrity: sha512-6boXK0KkzT5u5xOgF6TKB+CLq9SOpEGmkZw0g5n9/7yg85wab3UzSxB8TxhLJ31L4SGJ6BCFRw/iftTha1CJXA==} + + '@csstools/css-tokenizer@4.0.0': + resolution: {integrity: sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA==} + engines: {node: '>=20.19.0'} + '@date-fns/tz@1.2.0': resolution: {integrity: sha512-LBrd7MiJZ9McsOgxqWX7AaxrDjcFVjWH/tIKJd7pnR7McaslGYOP1QmmiBXdJH/H/yLCT+rcQ7FaPBUxRGUtrg==} @@ -1097,6 +1149,15 @@ packages: resolution: {integrity: sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + '@exodus/bytes@1.11.0': + resolution: {integrity: sha512-wO3vd8nsEHdumsXrjGO/v4p6irbg7hy9kvIeR6i2AwylZSk4HJdWgL0FNaVquW1+AweJcdvU1IEpuIWk/WaPnA==} + engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0} + peerDependencies: + '@noble/hashes': ^1.8.0 || ^2.0.0 + peerDependenciesMeta: + '@noble/hashes': + optional: true + '@figspec/components@1.0.3': resolution: {integrity: sha512-fBwHzJ4ouuOUJEi+yBZIrOy+0/fAjB3AeTcIHTT1PRxLz8P63xwC7R0EsIJXhScIcc+PljGmqbbVJCjLsnaGYA==} @@ -2075,6 +2136,121 @@ packages: resolution: {integrity: sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==} engines: {node: '>=10.13.0'} + '@tsparticles/basic@3.9.1': + resolution: {integrity: sha512-ijr2dHMx0IQHqhKW3qA8tfwrR2XYbbWYdaJMQuBo2CkwBVIhZ76U+H20Y492j/NXpd1FUnt2aC0l4CEVGVGdeQ==} + + '@tsparticles/engine@3.9.1': + resolution: {integrity: sha512-DpdgAhWMZ3Eh2gyxik8FXS6BKZ8vyea+Eu5BC4epsahqTGY9V3JGGJcXC6lRJx6cPMAx1A0FaQAojPF3v6rkmQ==} + + '@tsparticles/interaction-external-attract@3.9.1': + resolution: {integrity: sha512-5AJGmhzM9o4AVFV24WH5vSqMBzOXEOzIdGLIr+QJf4fRh9ZK62snsusv/ozKgs2KteRYQx+L7c5V3TqcDy2upg==} + + '@tsparticles/interaction-external-bounce@3.9.1': + resolution: {integrity: sha512-bv05+h70UIHOTWeTsTI1AeAmX6R3s8nnY74Ea6p6AbQjERzPYIa0XY19nq/hA7+Nrg+EissP5zgoYYeSphr85A==} + + '@tsparticles/interaction-external-bubble@3.9.1': + resolution: {integrity: sha512-tbd8ox/1GPl+zr+KyHQVV1bW88GE7OM6i4zql801YIlCDrl9wgTDdDFGIy9X7/cwTvTrCePhrfvdkUamXIribQ==} + + '@tsparticles/interaction-external-connect@3.9.1': + resolution: {integrity: sha512-sq8YfUNsIORjXHzzW7/AJQtfi/qDqLnYG2qOSE1WOsog39MD30RzmiOloejOkfNeUdcGUcfsDgpUuL3UhzFUOA==} + + '@tsparticles/interaction-external-grab@3.9.1': + resolution: {integrity: sha512-QwXza+sMMWDaMiFxd8y2tJwUK6c+nNw554+/9+tEZeTTk2fCbB0IJ7p/TH6ZGWDL0vo2muK54Njv2fEey191ow==} + + '@tsparticles/interaction-external-pause@3.9.1': + resolution: {integrity: sha512-Gzv4/FeNir0U/tVM9zQCqV1k+IAgaFjDU3T30M1AeAsNGh/rCITV2wnT7TOGFkbcla27m4Yxa+Fuab8+8pzm+g==} + + '@tsparticles/interaction-external-push@3.9.1': + resolution: {integrity: sha512-GvnWF9Qy4YkZdx+WJL2iy9IcgLvzOIu3K7aLYJFsQPaxT8d9TF8WlpoMlWKnJID6H5q4JqQuMRKRyWH8aAKyQw==} + + '@tsparticles/interaction-external-remove@3.9.1': + resolution: {integrity: sha512-yPThm4UDWejDOWW5Qc8KnnS2EfSo5VFcJUQDWc1+Wcj17xe7vdSoiwwOORM0PmNBzdDpSKQrte/gUnoqaUMwOA==} + + '@tsparticles/interaction-external-repulse@3.9.1': + resolution: {integrity: sha512-/LBppXkrMdvLHlEKWC7IykFhzrz+9nebT2fwSSFXK4plEBxDlIwnkDxd3FbVOAbnBvx4+L8+fbrEx+RvC8diAw==} + + '@tsparticles/interaction-external-slow@3.9.1': + resolution: {integrity: sha512-1ZYIR/udBwA9MdSCfgADsbDXKSFS0FMWuPWz7bm79g3sUxcYkihn+/hDhc6GXvNNR46V1ocJjrj0u6pAynS1KQ==} + + '@tsparticles/interaction-particles-attract@3.9.1': + resolution: {integrity: sha512-CYYYowJuGwRLUixQcSU/48PTKM8fCUYThe0hXwQ+yRMLAn053VHzL7NNZzKqEIeEyt5oJoy9KcvubjKWbzMBLQ==} + + '@tsparticles/interaction-particles-collisions@3.9.1': + resolution: {integrity: sha512-ggGyjW/3v1yxvYW1IF1EMT15M6w31y5zfNNUPkqd/IXRNPYvm0Z0ayhp+FKmz70M5p0UxxPIQHTvAv9Jqnuj8w==} + + '@tsparticles/interaction-particles-links@3.9.1': + resolution: {integrity: sha512-MsLbMjy1vY5M5/hu/oa5OSRZAUz49H3+9EBMTIOThiX+a+vpl3sxc9AqNd9gMsPbM4WJlub8T6VBZdyvzez1Vg==} + + '@tsparticles/move-base@3.9.1': + resolution: {integrity: sha512-X4huBS27d8srpxwOxliWPUt+NtCwY+8q/cx1DvQxyqmTA8VFCGpcHNwtqiN+9JicgzOvSuaORVqUgwlsc7h4pQ==} + + '@tsparticles/move-parallax@3.9.1': + resolution: {integrity: sha512-whlOR0bVeyh6J/hvxf/QM3DqvNnITMiAQ0kro6saqSDItAVqg4pYxBfEsSOKq7EhjxNvfhhqR+pFMhp06zoCVA==} + + '@tsparticles/plugin-easing-quad@3.9.1': + resolution: {integrity: sha512-C2UJOca5MTDXKUTBXj30Kiqr5UyID+xrY/LxicVWWZPczQW2bBxbIbfq9ULvzGDwBTxE2rdvIB8YFKmDYO45qw==} + + '@tsparticles/plugin-hex-color@3.9.1': + resolution: {integrity: sha512-vZgZ12AjUicJvk7AX4K2eAmKEQX/D1VEjEPFhyjbgI7A65eX72M465vVKIgNA6QArLZ1DLs7Z787LOE6GOBWsg==} + + '@tsparticles/plugin-hsl-color@3.9.1': + resolution: {integrity: sha512-jJd1iGgRwX6eeNjc1zUXiJivaqC5UE+SC2A3/NtHwwoQrkfxGWmRHOsVyLnOBRcCPgBp/FpdDe6DIDjCMO715w==} + + '@tsparticles/plugin-rgb-color@3.9.1': + resolution: {integrity: sha512-SBxk7f1KBfXeTnnklbE2Hx4jBgh6I6HOtxb+Os1gTp0oaghZOkWcCD2dP4QbUu7fVNCMOcApPoMNC8RTFcy9wQ==} + + '@tsparticles/react@3.0.0': + resolution: {integrity: sha512-hjGEtTT1cwv6BcjL+GcVgH++KYs52bIuQGW3PWv7z3tMa8g0bd6RI/vWSLj7p//NZ3uTjEIeilYIUPBh7Jfq/Q==} + peerDependencies: + '@tsparticles/engine': ^3.0.2 + react: '>=16.8.0' + react-dom: '>=16.8.0' + + '@tsparticles/shape-circle@3.9.1': + resolution: {integrity: sha512-DqZFLjbuhVn99WJ+A9ajz9YON72RtCcvubzq6qfjFmtwAK7frvQeb6iDTp6Ze9FUipluxVZWVRG4vWTxi2B+/g==} + + '@tsparticles/shape-emoji@3.9.1': + resolution: {integrity: sha512-ifvY63usuT+hipgVHb8gelBHSeF6ryPnMxAAEC1RGHhhXfpSRWMtE6ybr+pSsYU52M3G9+TF84v91pSwNrb9ZQ==} + + '@tsparticles/shape-image@3.9.1': + resolution: {integrity: sha512-fCA5eme8VF3oX8yNVUA0l2SLDKuiZObkijb0z3Ky0qj1HUEVlAuEMhhNDNB9E2iELTrWEix9z7BFMePp2CC7AA==} + + '@tsparticles/shape-line@3.9.1': + resolution: {integrity: sha512-wT8NSp0N9HURyV05f371cHKcNTNqr0/cwUu6WhBzbshkYGy1KZUP9CpRIh5FCrBpTev34mEQfOXDycgfG0KiLQ==} + + '@tsparticles/shape-polygon@3.9.1': + resolution: {integrity: sha512-dA77PgZdoLwxnliH6XQM/zF0r4jhT01pw5y7XTeTqws++hg4rTLV9255k6R6eUqKq0FPSW1/WBsBIl7q/MmrqQ==} + + '@tsparticles/shape-square@3.9.1': + resolution: {integrity: sha512-DKGkDnRyZrAm7T2ipqNezJahSWs6xd9O5LQLe5vjrYm1qGwrFxJiQaAdlb00UNrexz1/SA7bEoIg4XKaFa7qhQ==} + + '@tsparticles/shape-star@3.9.1': + resolution: {integrity: sha512-kdMJpi8cdeb6vGrZVSxTG0JIjCwIenggqk0EYeKAwtOGZFBgL7eHhF2F6uu1oq8cJAbXPujEoabnLsz6mW8XaA==} + + '@tsparticles/slim@3.9.1': + resolution: {integrity: sha512-CL5cDmADU7sDjRli0So+hY61VMbdroqbArmR9Av+c1Fisa5ytr6QD7Jv62iwU2S6rvgicEe9OyRmSy5GIefwZw==} + + '@tsparticles/updater-color@3.9.1': + resolution: {integrity: sha512-XGWdscrgEMA8L5E7exsE0f8/2zHKIqnTrZymcyuFBw2DCB6BIV+5z6qaNStpxrhq3DbIxxhqqcybqeOo7+Alpg==} + + '@tsparticles/updater-life@3.9.1': + resolution: {integrity: sha512-Oi8aF2RIwMMsjssUkCB6t3PRpENHjdZf6cX92WNfAuqXtQphr3OMAkYFJFWkvyPFK22AVy3p/cFt6KE5zXxwAA==} + + '@tsparticles/updater-opacity@3.9.1': + resolution: {integrity: sha512-w778LQuRZJ+IoWzeRdrGykPYSSaTeWfBvLZ2XwYEkh/Ss961InOxZKIpcS6i5Kp/Zfw0fS1ZAuqeHwuj///Osw==} + + '@tsparticles/updater-out-modes@3.9.1': + resolution: {integrity: sha512-cKQEkAwbru+hhKF+GTsfbOvuBbx2DSB25CxOdhtW2wRvDBoCnngNdLw91rs+0Cex4tgEeibkebrIKFDDE6kELg==} + + '@tsparticles/updater-rotate@3.9.1': + resolution: {integrity: sha512-9BfKaGfp28JN82MF2qs6Ae/lJr9EColMfMTHqSKljblwbpVDHte4umuwKl3VjbRt87WD9MGtla66NTUYl+WxuQ==} + + '@tsparticles/updater-size@3.9.1': + resolution: {integrity: sha512-3NSVs0O2ApNKZXfd+y/zNhTXSFeG1Pw4peI8e6z/q5+XLbmue9oiEwoPy/tQLaark3oNj3JU7Q903ZijPyXSzw==} + + '@tsparticles/updater-stroke-color@3.9.1': + resolution: {integrity: sha512-3x14+C2is9pZYTg9T2TiA/aM1YMq4wLdYaZDcHm3qO30DZu5oeQq0rm/6w+QOGKYY1Z3Htg9rlSUZkhTHn7eDA==} + '@types/aria-query@5.0.4': resolution: {integrity: sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==} @@ -2258,6 +2434,12 @@ packages: '@types/vinyl@2.0.12': resolution: {integrity: sha512-Sr2fYMBUVGYq8kj3UthXFAu5UN6ZW+rYr4NACjZQJvHvj+c8lYv0CahmZ2P/r7iUkN44gGUBwqxZkrKXYPb7cw==} + '@types/whatwg-mimetype@3.0.2': + resolution: {integrity: sha512-c2AKvDT8ToxLIOUlN51gTiHXflsfIFisS4pO7pDPoKouJCESkhZnEy623gwP9laCy5lnLDAw1vAzu2vM2YLOrA==} + + '@types/ws@8.18.1': + resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==} + '@types/yargs-parser@21.0.3': resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} @@ -2873,6 +3055,9 @@ packages: resolution: {integrity: sha512-aVNobHnJqLiUelTaHat9DZ1qM2w0C0Eym4LPI/3JxOnSokGVdsl1T1kN7TFvsEAD8G47A6VKQ0TVHqbBnYMJlQ==} engines: {node: '>=12.0.0'} + bidi-js@1.0.3: + resolution: {integrity: sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==} + binary-extensions@2.3.0: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} @@ -3037,9 +3222,6 @@ packages: '@chromatic-com/playwright': optional: true - chrome-extension-toolkit@0.0.54: - resolution: {integrity: sha512-ux8v/PfWQIvO+EBbF+kDYq2z8Rnp5YZ7GwJxYX7R2a9owIEHJxiCUSJ82tOsiMQINF/31+t6QLG9equKNZUOlA==} - chrome-trace-event@1.0.4: resolution: {integrity: sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==} engines: {node: '>=6.0'} @@ -3342,6 +3524,10 @@ packages: resolution: {integrity: sha512-0LrrStPOdJj+SPCCrGhzryycLjwcgUSHBtxNA8aIDxf0GLsRh1cKYhB00Gd1lDOS4yGH69+SNn13+TWbVHETFQ==} engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0, npm: '>=7.0.0'} + cssstyle@5.3.7: + resolution: {integrity: sha512-7D2EPVltRrsTkhpQmksIu+LxeWAIEk6wRDMJ1qljlv+CKHJM+cJLlfhWIzNA44eAsHXSNe3+vO6DW1yCYx8SuQ==} + engines: {node: '>=20'} + csstype@3.1.3: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} @@ -3352,6 +3538,10 @@ packages: resolution: {integrity: sha512-wAV9QHOsNbwnWdNW2FYvE1P56wtgSbM+3SZcdGiWQILwVjACCXDCI3Ai8QlCjMDB8YK5zySiXZYBiwGmNY3lnw==} engines: {node: '>=12'} + data-urls@7.0.0: + resolution: {integrity: sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA==} + engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0} + data-view-buffer@1.0.2: resolution: {integrity: sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ==} engines: {node: '>= 0.4'} @@ -3392,6 +3582,9 @@ packages: supports-color: optional: true + decimal.js@10.6.0: + resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==} + decode-named-character-reference@1.0.2: resolution: {integrity: sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==} @@ -3554,6 +3747,10 @@ packages: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} + entities@6.0.1: + resolution: {integrity: sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==} + engines: {node: '>=0.12'} + env-ci@11.1.0: resolution: {integrity: sha512-Z8dnwSDbV1XYM9SBF2J0GcNVvmfmfh3a49qddGIROhBoVro6MZVTji15z/sJbQ2ko2ei8n988EU1wzoLU/tF+g==} engines: {node: ^18.17 || >=20.6.1} @@ -4270,6 +4467,10 @@ packages: engines: {node: '>=0.4.7'} hasBin: true + happy-dom@20.5.0: + resolution: {integrity: sha512-VQe+Q5CYiGOgcCERXhcfNsbnrN92FDEKciMH/x6LppU9dd0j4aTjCTlqONFOIMcAm/5JxS3+utowbXV1OoFr+g==} + engines: {node: '>=20.0.0'} + has-bigints@1.1.0: resolution: {integrity: sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==} engines: {node: '>= 0.4'} @@ -4347,6 +4548,10 @@ packages: resolution: {integrity: sha512-sYKnA7eGln5ov8T8gnYlkSOxFJvywzEx9BueN6xo/GKO8PGiI6uK6xx+DIGe45T3bdVjLAQDQW1aicT8z8JwQg==} engines: {node: ^18.17.0 || >=20.5.0} + html-encoding-sniffer@6.0.0: + resolution: {integrity: sha512-CV9TW3Y3f8/wT0BRFc1/KAVQ3TUHiXmaAb6VW9vtiMFf7SLoMd1PdAc4W3KFOFETBJUb90KatHqlsZMWV+R9Gg==} + engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0} + html-escaper@2.0.2: resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} @@ -4612,6 +4817,9 @@ packages: resolution: {integrity: sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==} engines: {node: '>=0.10.0'} + is-potential-custom-element-name@1.0.1: + resolution: {integrity: sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==} + is-regex@1.2.1: resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==} engines: {node: '>= 0.4'} @@ -4778,6 +4986,15 @@ packages: resolution: {integrity: sha512-Hicd6JK5Njt2QB6XYFS7ok9e37O8AYk3jTcppG4YVQnYjOemymvTcmc7OWsmq/Qqj5TdRFO5/x/tIPmBeRtGHg==} engines: {node: '>=12.0.0'} + jsdom@28.0.0: + resolution: {integrity: sha512-KDYJgZ6T2TKdU8yBfYueq5EPG/EylMsBvCaenWMJb2OXmjgczzwveRCoJ+Hgj1lXPDyasvrgneSn4GBuR1hYyA==} + engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0} + peerDependencies: + canvas: ^3.0.0 + peerDependenciesMeta: + canvas: + optional: true + jsesc@3.1.0: resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==} engines: {node: '>=6'} @@ -4988,6 +5205,10 @@ packages: lru-cache@10.4.3: resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} + lru-cache@11.2.5: + resolution: {integrity: sha512-vFrFJkWtJvJnD5hg+hJvVE8Lh/TcMzKnTgCWmtBipwI5yLX/iX+5UB2tfuyODF5E7k9xEzMdYgGqaSb1c0c5Yw==} + engines: {node: 20 || >=22} + lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} @@ -5597,6 +5818,9 @@ packages: parse5@7.2.1: resolution: {integrity: sha512-BuBYQYlv1ckiPdQi/ohiivi9Sagc9JG+Ozs0r7b/0iK3sKmrb0b9FdWdBbOdx6hBCM/F9Ir82ofnBhtZOjCRPQ==} + parse5@8.0.0: + resolution: {integrity: sha512-9m4m5GSgXjL4AjumKzq1Fgfp3Z8rsvjRNbnkVwfu2ImRqE5D0LnY2QfDen18FSY9C573YU5XxSapdHZTZ2WolA==} + path-exists@3.0.0: resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==} engines: {node: '>=4'} @@ -5907,8 +6131,8 @@ packages: resolution: {integrity: sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==} engines: {node: '>=6.0.0'} - prettier@3.5.2: - resolution: {integrity: sha512-lc6npv5PH7hVqozBR7lkBNOGXV9vMwROAPlumdBkX0wTbbzPu/U1hk5yL8p2pt4Xoc+2mkT8t/sow2YrV/M5qg==} + prettier@3.6.2: + resolution: {integrity: sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==} engines: {node: '>=14'} hasBin: true @@ -6223,6 +6447,10 @@ packages: engines: {node: '>=14.0.0'} hasBin: true + saxes@6.0.0: + resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==} + engines: {node: '>=v12.22.7'} + scheduler@0.23.2: resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==} @@ -6568,6 +6796,9 @@ packages: engines: {node: '>=14.0.0'} hasBin: true + symbol-tree@3.2.4: + resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==} + synckit@0.9.2: resolution: {integrity: sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==} engines: {node: ^14.18.0 || >=16.0.0} @@ -6678,6 +6909,13 @@ packages: resolution: {integrity: sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==} engines: {node: '>=14.0.0'} + tldts-core@7.0.22: + resolution: {integrity: sha512-KgbTDC5wzlL6j/x6np6wCnDSMUq4kucHNm00KXPbfNzmllCmtmvtykJHfmgdHntwIeupW04y8s1N/43S1PkQDw==} + + tldts@7.0.22: + resolution: {integrity: sha512-nqpKFC53CgopKPjT6Wfb6tpIcZXHcI6G37hesvikhx0EmUGPkZrujRyAjgnmp1SHNgpQfKVanZ+KfpANFt2Hxw==} + hasBin: true + to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -6690,6 +6928,14 @@ packages: resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==} engines: {node: '>=6'} + tough-cookie@6.0.0: + resolution: {integrity: sha512-kXuRi1mtaKMrsLUxz3sQYvVl37B0Ns6MzfrtV5DvJceE9bPyspOqk9xxv7XbZWcfLWbFmm997vl83qUWVJA64w==} + engines: {node: '>=16'} + + tr46@6.0.0: + resolution: {integrity: sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==} + engines: {node: '>=20'} + traverse@0.6.8: resolution: {integrity: sha512-aXJDbk6SnumuaZSANd21XAo15ucCDE38H4fkqiGsc3MhCK+wOlZvLP9cB/TvpHT0mOyWgC4Z8EwRlzqYSUzdsA==} engines: {node: '>= 0.4'} @@ -6824,6 +7070,10 @@ packages: resolution: {integrity: sha512-hU/10obOIu62MGYjdskASR3CUAiYaFTtC9Pa6vHyf//mAipSvSQg6od2CnJswq7fvzNS3zJhxoRkgNVaHurWKw==} engines: {node: '>=18.17'} + undici@7.21.0: + resolution: {integrity: sha512-Hn2tCQpoDt1wv23a68Ctc8Cr/BHpUSfaPYrkajTXOS9IKpxVRx/X5m1K2YkbK2ipgZgxXSgsUinl3x+2YdSSfg==} + engines: {node: '>=20.18.1'} + unicode-emoji-modifier-base@1.0.0: resolution: {integrity: sha512-yLSH4py7oFH3oG/9K+XWrz1pSi3dfUrWEnInbxMfArOfc1+33BlGPQtLsOYwvdMy11AwUBetYuaRxSPqgkq+8g==} engines: {node: '>=4'} @@ -7045,10 +7295,18 @@ packages: typescript: optional: true + w3c-xmlserializer@5.0.0: + resolution: {integrity: sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==} + engines: {node: '>=18'} + watchpack@2.4.4: resolution: {integrity: sha512-c5EGNOiyxxV5qmTtAB7rbiXxi1ooX1pQKMLX/MIabJjRA0SJBQOjKF+KSVfHkr9U1cADPon0mRiVe/riyaiDUA==} engines: {node: '>=10.13.0'} + webidl-conversions@8.0.1: + resolution: {integrity: sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==} + engines: {node: '>=20'} + webpack-sources@3.3.3: resolution: {integrity: sha512-yd1RBzSGanHkitROoPFd6qsrxt+oFhg/129YzheDGqeustzX0vTZJZsSsQjVQC4yzBQ56K55XU8gaNCtIzOnTg==} engines: {node: '>=10.13.0'} @@ -7070,10 +7328,22 @@ packages: resolution: {integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==} engines: {node: '>=18'} + whatwg-mimetype@3.0.0: + resolution: {integrity: sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==} + engines: {node: '>=12'} + whatwg-mimetype@4.0.0: resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==} engines: {node: '>=18'} + whatwg-mimetype@5.0.0: + resolution: {integrity: sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==} + engines: {node: '>=20'} + + whatwg-url@16.0.0: + resolution: {integrity: sha512-9CcxtEKsf53UFwkSUZjG+9vydAsFO4lFHBpJUtjBcoJOCJpKnSJNwCw813zrYJHpCJ7sgfbtOe0V5Ku7Pa1XMQ==} + engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0} + which-boxed-primitive@1.1.1: resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==} engines: {node: '>= 0.4'} @@ -7138,6 +7408,25 @@ packages: utf-8-validate: optional: true + ws@8.19.0: + resolution: {integrity: sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + + xml-name-validator@5.0.0: + resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==} + engines: {node: '>=18'} + + xmlchars@2.2.0: + resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==} + xtend@4.0.2: resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} engines: {node: '>=0.4'} @@ -7189,6 +7478,8 @@ packages: snapshots: + '@acemir/cssom@0.9.31': {} + '@adobe/css-tools@4.4.2': {} '@ampproject/remapping@2.3.0': @@ -7210,6 +7501,24 @@ snapshots: '@antfu/utils@8.1.1': {} + '@asamuzakjp/css-color@4.1.2': + dependencies: + '@csstools/css-calc': 3.0.0(@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0))(@csstools/css-tokenizer@4.0.0) + '@csstools/css-color-parser': 4.0.1(@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0))(@csstools/css-tokenizer@4.0.0) + '@csstools/css-parser-algorithms': 4.0.0(@csstools/css-tokenizer@4.0.0) + '@csstools/css-tokenizer': 4.0.0 + lru-cache: 11.2.5 + + '@asamuzakjp/dom-selector@6.7.8': + dependencies: + '@asamuzakjp/nwsapi': 2.3.9 + bidi-js: 1.0.3 + css-tree: 3.1.0 + is-potential-custom-element-name: 1.0.1 + lru-cache: 11.2.5 + + '@asamuzakjp/nwsapi@2.3.9': {} + '@babel/code-frame@7.26.2': dependencies: '@babel/helper-validator-identifier': 7.25.9 @@ -7510,6 +7819,28 @@ snapshots: transitivePeerDependencies: - supports-color + '@csstools/color-helpers@6.0.1': {} + + '@csstools/css-calc@3.0.0(@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0))(@csstools/css-tokenizer@4.0.0)': + dependencies: + '@csstools/css-parser-algorithms': 4.0.0(@csstools/css-tokenizer@4.0.0) + '@csstools/css-tokenizer': 4.0.0 + + '@csstools/css-color-parser@4.0.1(@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0))(@csstools/css-tokenizer@4.0.0)': + dependencies: + '@csstools/color-helpers': 6.0.1 + '@csstools/css-calc': 3.0.0(@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0))(@csstools/css-tokenizer@4.0.0) + '@csstools/css-parser-algorithms': 4.0.0(@csstools/css-tokenizer@4.0.0) + '@csstools/css-tokenizer': 4.0.0 + + '@csstools/css-parser-algorithms@4.0.0(@csstools/css-tokenizer@4.0.0)': + dependencies: + '@csstools/css-tokenizer': 4.0.0 + + '@csstools/css-syntax-patches-for-csstree@1.0.26': {} + + '@csstools/css-tokenizer@4.0.0': {} + '@date-fns/tz@1.2.0': {} '@dnd-kit/accessibility@3.1.1(react@18.3.1)': @@ -7792,6 +8123,8 @@ snapshots: '@eslint/js@8.57.1': {} + '@exodus/bytes@1.11.0': {} + '@figspec/components@1.0.3': dependencies: lit: 2.8.0 @@ -8425,126 +8758,126 @@ snapshots: '@sindresorhus/merge-streams@4.0.0': {} - '@storybook/addon-actions@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/addon-actions@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: '@storybook/global': 5.0.0 '@types/uuid': 9.0.8 dequal: 2.0.3 polished: 4.3.1 - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) uuid: 9.0.1 - '@storybook/addon-backgrounds@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/addon-backgrounds@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: '@storybook/global': 5.0.0 memoizerific: 1.11.3 - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) ts-dedent: 2.2.0 - '@storybook/addon-controls@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/addon-controls@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: '@storybook/global': 5.0.0 dequal: 2.0.3 - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) ts-dedent: 2.2.0 - '@storybook/addon-designs@8.2.0(@storybook/blocks@8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.5.2)))(@storybook/components@8.6.0(storybook@8.6.0(prettier@3.5.2)))(@storybook/theming@8.6.0(storybook@8.6.0(prettier@3.5.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + '@storybook/addon-designs@8.2.0(@storybook/blocks@8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.6.2)))(@storybook/components@8.6.0(storybook@8.6.0(prettier@3.6.2)))(@storybook/theming@8.6.0(storybook@8.6.0(prettier@3.6.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@figspec/react': 1.0.3(react@18.3.1) optionalDependencies: - '@storybook/blocks': 8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.5.2)) - '@storybook/components': 8.6.0(storybook@8.6.0(prettier@3.5.2)) - '@storybook/theming': 8.6.0(storybook@8.6.0(prettier@3.5.2)) + '@storybook/blocks': 8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.6.2)) + '@storybook/components': 8.6.0(storybook@8.6.0(prettier@3.6.2)) + '@storybook/theming': 8.6.0(storybook@8.6.0(prettier@3.6.2)) react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - '@storybook/addon-docs@8.6.0(@types/react@18.3.18)(storybook@8.6.0(prettier@3.5.2))': + '@storybook/addon-docs@8.6.0(@types/react@18.3.18)(storybook@8.6.0(prettier@3.6.2))': dependencies: '@mdx-js/react': 3.1.0(@types/react@18.3.18)(react@18.3.1) - '@storybook/blocks': 8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.5.2)) - '@storybook/csf-plugin': 8.6.0(storybook@8.6.0(prettier@3.5.2)) - '@storybook/react-dom-shim': 8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.5.2)) + '@storybook/blocks': 8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.6.2)) + '@storybook/csf-plugin': 8.6.0(storybook@8.6.0(prettier@3.6.2)) + '@storybook/react-dom-shim': 8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.6.2)) react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) ts-dedent: 2.2.0 transitivePeerDependencies: - '@types/react' - '@storybook/addon-essentials@8.6.0(@types/react@18.3.18)(storybook@8.6.0(prettier@3.5.2))': + '@storybook/addon-essentials@8.6.0(@types/react@18.3.18)(storybook@8.6.0(prettier@3.6.2))': dependencies: - '@storybook/addon-actions': 8.6.0(storybook@8.6.0(prettier@3.5.2)) - '@storybook/addon-backgrounds': 8.6.0(storybook@8.6.0(prettier@3.5.2)) - '@storybook/addon-controls': 8.6.0(storybook@8.6.0(prettier@3.5.2)) - '@storybook/addon-docs': 8.6.0(@types/react@18.3.18)(storybook@8.6.0(prettier@3.5.2)) - '@storybook/addon-highlight': 8.6.0(storybook@8.6.0(prettier@3.5.2)) - '@storybook/addon-measure': 8.6.0(storybook@8.6.0(prettier@3.5.2)) - '@storybook/addon-outline': 8.6.0(storybook@8.6.0(prettier@3.5.2)) - '@storybook/addon-toolbars': 8.6.0(storybook@8.6.0(prettier@3.5.2)) - '@storybook/addon-viewport': 8.6.0(storybook@8.6.0(prettier@3.5.2)) - storybook: 8.6.0(prettier@3.5.2) + '@storybook/addon-actions': 8.6.0(storybook@8.6.0(prettier@3.6.2)) + '@storybook/addon-backgrounds': 8.6.0(storybook@8.6.0(prettier@3.6.2)) + '@storybook/addon-controls': 8.6.0(storybook@8.6.0(prettier@3.6.2)) + '@storybook/addon-docs': 8.6.0(@types/react@18.3.18)(storybook@8.6.0(prettier@3.6.2)) + '@storybook/addon-highlight': 8.6.0(storybook@8.6.0(prettier@3.6.2)) + '@storybook/addon-measure': 8.6.0(storybook@8.6.0(prettier@3.6.2)) + '@storybook/addon-outline': 8.6.0(storybook@8.6.0(prettier@3.6.2)) + '@storybook/addon-toolbars': 8.6.0(storybook@8.6.0(prettier@3.6.2)) + '@storybook/addon-viewport': 8.6.0(storybook@8.6.0(prettier@3.6.2)) + storybook: 8.6.0(prettier@3.6.2) ts-dedent: 2.2.0 transitivePeerDependencies: - '@types/react' - '@storybook/addon-highlight@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/addon-highlight@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: '@storybook/global': 5.0.0 - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) - '@storybook/addon-links@8.6.0(react@18.3.1)(storybook@8.6.0(prettier@3.5.2))': + '@storybook/addon-links@8.6.0(react@18.3.1)(storybook@8.6.0(prettier@3.6.2))': dependencies: '@storybook/global': 5.0.0 - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) ts-dedent: 2.2.0 optionalDependencies: react: 18.3.1 - '@storybook/addon-measure@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/addon-measure@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: '@storybook/global': 5.0.0 - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) tiny-invariant: 1.3.3 - '@storybook/addon-outline@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/addon-outline@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: '@storybook/global': 5.0.0 - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) ts-dedent: 2.2.0 - '@storybook/addon-toolbars@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/addon-toolbars@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) - '@storybook/addon-viewport@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/addon-viewport@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: memoizerific: 1.11.3 - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) - '@storybook/blocks@8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.5.2))': + '@storybook/blocks@8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.6.2))': dependencies: '@storybook/icons': 1.3.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) ts-dedent: 2.2.0 optionalDependencies: react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - '@storybook/builder-vite@8.6.0(storybook@8.6.0(prettier@3.5.2))(vite@5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0))': + '@storybook/builder-vite@8.6.0(storybook@8.6.0(prettier@3.6.2))(vite@5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0))': dependencies: - '@storybook/csf-plugin': 8.6.0(storybook@8.6.0(prettier@3.5.2)) + '@storybook/csf-plugin': 8.6.0(storybook@8.6.0(prettier@3.6.2)) browser-assert: 1.2.1 - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) ts-dedent: 2.2.0 vite: 5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0) - '@storybook/components@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/components@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) - '@storybook/core@8.6.0(prettier@3.5.2)(storybook@8.6.0(prettier@3.5.2))': + '@storybook/core@8.6.0(prettier@3.6.2)(storybook@8.6.0(prettier@3.6.2))': dependencies: - '@storybook/theming': 8.6.0(storybook@8.6.0(prettier@3.5.2)) + '@storybook/theming': 8.6.0(storybook@8.6.0(prettier@3.6.2)) better-opn: 3.0.2 browser-assert: 1.2.1 esbuild: 0.25.10 @@ -8556,16 +8889,16 @@ snapshots: util: 0.12.5 ws: 8.18.1 optionalDependencies: - prettier: 3.5.2 + prettier: 3.6.2 transitivePeerDependencies: - bufferutil - storybook - supports-color - utf-8-validate - '@storybook/csf-plugin@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/csf-plugin@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) unplugin: 1.16.1 '@storybook/csf@0.0.1': @@ -8579,77 +8912,77 @@ snapshots: react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - '@storybook/instrumenter@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/instrumenter@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: '@storybook/global': 5.0.0 '@vitest/utils': 2.1.9 - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) - '@storybook/manager-api@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/manager-api@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) - '@storybook/preview-api@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/preview-api@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) - '@storybook/react-dom-shim@8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.5.2))': + '@storybook/react-dom-shim@8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.6.2))': dependencies: react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) - '@storybook/react-vite@8.6.0(@storybook/test@8.6.0(storybook@8.6.0(prettier@3.5.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(rollup@4.52.4)(storybook@8.6.0(prettier@3.5.2))(typescript@5.7.3)(vite@5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0))': + '@storybook/react-vite@8.6.0(@storybook/test@8.6.0(storybook@8.6.0(prettier@3.6.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(rollup@4.52.4)(storybook@8.6.0(prettier@3.6.2))(typescript@5.7.3)(vite@5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0))': dependencies: '@joshwooding/vite-plugin-react-docgen-typescript': 0.5.0(typescript@5.7.3)(vite@5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0)) '@rollup/pluginutils': 5.1.4(rollup@4.52.4) - '@storybook/builder-vite': 8.6.0(storybook@8.6.0(prettier@3.5.2))(vite@5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0)) - '@storybook/react': 8.6.0(@storybook/test@8.6.0(storybook@8.6.0(prettier@3.5.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.5.2))(typescript@5.7.3) + '@storybook/builder-vite': 8.6.0(storybook@8.6.0(prettier@3.6.2))(vite@5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0)) + '@storybook/react': 8.6.0(@storybook/test@8.6.0(storybook@8.6.0(prettier@3.6.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.6.2))(typescript@5.7.3) find-up: 5.0.0 magic-string: 0.30.17 react: 18.3.1 react-docgen: 7.1.1 react-dom: 18.3.1(react@18.3.1) resolve: 1.22.10 - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) tsconfig-paths: 4.2.0 vite: 5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0) optionalDependencies: - '@storybook/test': 8.6.0(storybook@8.6.0(prettier@3.5.2)) + '@storybook/test': 8.6.0(storybook@8.6.0(prettier@3.6.2)) transitivePeerDependencies: - rollup - supports-color - typescript - '@storybook/react@8.6.0(@storybook/test@8.6.0(storybook@8.6.0(prettier@3.5.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.5.2))(typescript@5.7.3)': + '@storybook/react@8.6.0(@storybook/test@8.6.0(storybook@8.6.0(prettier@3.6.2)))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.6.2))(typescript@5.7.3)': dependencies: - '@storybook/components': 8.6.0(storybook@8.6.0(prettier@3.5.2)) + '@storybook/components': 8.6.0(storybook@8.6.0(prettier@3.6.2)) '@storybook/global': 5.0.0 - '@storybook/manager-api': 8.6.0(storybook@8.6.0(prettier@3.5.2)) - '@storybook/preview-api': 8.6.0(storybook@8.6.0(prettier@3.5.2)) - '@storybook/react-dom-shim': 8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.5.2)) - '@storybook/theming': 8.6.0(storybook@8.6.0(prettier@3.5.2)) + '@storybook/manager-api': 8.6.0(storybook@8.6.0(prettier@3.6.2)) + '@storybook/preview-api': 8.6.0(storybook@8.6.0(prettier@3.6.2)) + '@storybook/react-dom-shim': 8.6.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(storybook@8.6.0(prettier@3.6.2)) + '@storybook/theming': 8.6.0(storybook@8.6.0(prettier@3.6.2)) react: 18.3.1 react-dom: 18.3.1(react@18.3.1) - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) optionalDependencies: - '@storybook/test': 8.6.0(storybook@8.6.0(prettier@3.5.2)) + '@storybook/test': 8.6.0(storybook@8.6.0(prettier@3.6.2)) typescript: 5.7.3 - '@storybook/test@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/test@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: '@storybook/global': 5.0.0 - '@storybook/instrumenter': 8.6.0(storybook@8.6.0(prettier@3.5.2)) + '@storybook/instrumenter': 8.6.0(storybook@8.6.0(prettier@3.6.2)) '@testing-library/dom': 10.4.0 '@testing-library/jest-dom': 6.5.0 '@testing-library/user-event': 14.5.2(@testing-library/dom@10.4.0) '@vitest/expect': 2.0.5 '@vitest/spy': 2.0.5 - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) - '@storybook/theming@8.6.0(storybook@8.6.0(prettier@3.5.2))': + '@storybook/theming@8.6.0(storybook@8.6.0(prettier@3.6.2))': dependencies: - storybook: 8.6.0(prettier@3.5.2) + storybook: 8.6.0(prettier@3.6.2) '@svgr/babel-plugin-add-jsx-attribute@8.0.0(@babel/core@7.26.9)': dependencies: @@ -8820,6 +9153,188 @@ snapshots: '@trysound/sax@0.2.0': {} + '@tsparticles/basic@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + '@tsparticles/move-base': 3.9.1 + '@tsparticles/plugin-hex-color': 3.9.1 + '@tsparticles/plugin-hsl-color': 3.9.1 + '@tsparticles/plugin-rgb-color': 3.9.1 + '@tsparticles/shape-circle': 3.9.1 + '@tsparticles/updater-color': 3.9.1 + '@tsparticles/updater-opacity': 3.9.1 + '@tsparticles/updater-out-modes': 3.9.1 + '@tsparticles/updater-size': 3.9.1 + + '@tsparticles/engine@3.9.1': {} + + '@tsparticles/interaction-external-attract@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/interaction-external-bounce@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/interaction-external-bubble@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/interaction-external-connect@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/interaction-external-grab@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/interaction-external-pause@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/interaction-external-push@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/interaction-external-remove@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/interaction-external-repulse@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/interaction-external-slow@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/interaction-particles-attract@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/interaction-particles-collisions@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/interaction-particles-links@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/move-base@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/move-parallax@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/plugin-easing-quad@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/plugin-hex-color@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/plugin-hsl-color@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/plugin-rgb-color@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/react@3.0.0(@tsparticles/engine@3.9.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + dependencies: + '@tsparticles/engine': 3.9.1 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + + '@tsparticles/shape-circle@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/shape-emoji@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/shape-image@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/shape-line@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/shape-polygon@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/shape-square@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/shape-star@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/slim@3.9.1': + dependencies: + '@tsparticles/basic': 3.9.1 + '@tsparticles/engine': 3.9.1 + '@tsparticles/interaction-external-attract': 3.9.1 + '@tsparticles/interaction-external-bounce': 3.9.1 + '@tsparticles/interaction-external-bubble': 3.9.1 + '@tsparticles/interaction-external-connect': 3.9.1 + '@tsparticles/interaction-external-grab': 3.9.1 + '@tsparticles/interaction-external-pause': 3.9.1 + '@tsparticles/interaction-external-push': 3.9.1 + '@tsparticles/interaction-external-remove': 3.9.1 + '@tsparticles/interaction-external-repulse': 3.9.1 + '@tsparticles/interaction-external-slow': 3.9.1 + '@tsparticles/interaction-particles-attract': 3.9.1 + '@tsparticles/interaction-particles-collisions': 3.9.1 + '@tsparticles/interaction-particles-links': 3.9.1 + '@tsparticles/move-parallax': 3.9.1 + '@tsparticles/plugin-easing-quad': 3.9.1 + '@tsparticles/shape-emoji': 3.9.1 + '@tsparticles/shape-image': 3.9.1 + '@tsparticles/shape-line': 3.9.1 + '@tsparticles/shape-polygon': 3.9.1 + '@tsparticles/shape-square': 3.9.1 + '@tsparticles/shape-star': 3.9.1 + '@tsparticles/updater-life': 3.9.1 + '@tsparticles/updater-rotate': 3.9.1 + '@tsparticles/updater-stroke-color': 3.9.1 + + '@tsparticles/updater-color@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/updater-life@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/updater-opacity@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/updater-out-modes@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/updater-rotate@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/updater-size@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + + '@tsparticles/updater-stroke-color@3.9.1': + dependencies: + '@tsparticles/engine': 3.9.1 + '@types/aria-query@5.0.4': {} '@types/babel__core@7.20.5': @@ -9042,6 +9557,14 @@ snapshots: '@types/expect': 1.20.4 '@types/node': 22.13.5 + '@types/whatwg-mimetype@3.0.2': + optional: true + + '@types/ws@8.18.1': + dependencies: + '@types/node': 22.18.10 + optional: true + '@types/yargs-parser@21.0.3': {} '@types/yargs@17.0.33': @@ -9414,7 +9937,7 @@ snapshots: std-env: 3.8.0 test-exclude: 7.0.1 tinyrainbow: 1.2.0 - vitest: 2.1.9(@types/node@22.13.5)(@vitest/ui@2.1.9)(sass@1.85.1)(terser@5.44.0) + vitest: 2.1.9(@types/node@22.13.5)(@vitest/ui@2.1.9)(happy-dom@20.5.0)(jsdom@28.0.0)(sass@1.85.1)(terser@5.44.0) transitivePeerDependencies: - supports-color @@ -9476,7 +9999,7 @@ snapshots: sirv: 3.0.1 tinyglobby: 0.2.12 tinyrainbow: 1.2.0 - vitest: 2.1.9(@types/node@22.13.5)(@vitest/ui@2.1.9)(sass@1.85.1)(terser@5.44.0) + vitest: 2.1.9(@types/node@22.13.5)(@vitest/ui@2.1.9)(happy-dom@20.5.0)(jsdom@28.0.0)(sass@1.85.1)(terser@5.44.0) '@vitest/utils@2.0.5': dependencies: @@ -9892,6 +10415,10 @@ snapshots: dependencies: open: 8.4.2 + bidi-js@1.0.3: + dependencies: + require-from-string: 2.0.2 + binary-extensions@2.3.0: {} bl@5.1.0: @@ -10068,11 +10595,6 @@ snapshots: chromatic@11.26.0: {} - chrome-extension-toolkit@0.0.54: - dependencies: - react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) - chrome-trace-event@1.0.4: {} clean-stack@2.2.0: {} @@ -10415,12 +10937,26 @@ snapshots: dependencies: css-tree: 2.2.1 + cssstyle@5.3.7: + dependencies: + '@asamuzakjp/css-color': 4.1.2 + '@csstools/css-syntax-patches-for-csstree': 1.0.26 + css-tree: 3.1.0 + lru-cache: 11.2.5 + csstype@3.1.3: {} damerau-levenshtein@1.0.8: {} dargs@8.1.0: {} + data-urls@7.0.0: + dependencies: + whatwg-mimetype: 5.0.0 + whatwg-url: 16.0.0 + transitivePeerDependencies: + - '@noble/hashes' + data-view-buffer@1.0.2: dependencies: call-bound: 1.0.3 @@ -10453,6 +10989,8 @@ snapshots: dependencies: ms: 2.1.3 + decimal.js@10.6.0: {} + decode-named-character-reference@1.0.2: dependencies: character-entities: 2.0.2 @@ -10605,6 +11143,8 @@ snapshots: entities@4.5.0: {} + entities@6.0.1: {} + env-ci@11.1.0: dependencies: execa: 8.0.1 @@ -11010,10 +11550,10 @@ snapshots: safe-regex-test: 1.1.0 string.prototype.includes: 2.0.1 - eslint-plugin-prettier@5.2.3(@types/eslint@9.6.1)(eslint-config-prettier@9.1.0(eslint@8.57.1))(eslint@8.57.1)(prettier@3.5.2): + eslint-plugin-prettier@5.2.3(@types/eslint@9.6.1)(eslint-config-prettier@9.1.0(eslint@8.57.1))(eslint@8.57.1)(prettier@3.6.2): dependencies: eslint: 8.57.1 - prettier: 3.5.2 + prettier: 3.6.2 prettier-linter-helpers: 1.0.0 synckit: 0.9.2 optionalDependencies: @@ -11679,6 +12219,19 @@ snapshots: optionalDependencies: uglify-js: 3.19.3 + happy-dom@20.5.0: + dependencies: + '@types/node': 22.18.10 + '@types/whatwg-mimetype': 3.0.2 + '@types/ws': 8.18.1 + entities: 4.5.0 + whatwg-mimetype: 3.0.0 + ws: 8.19.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + optional: true + has-bigints@1.1.0: {} has-flag@3.0.0: {} @@ -11766,6 +12319,12 @@ snapshots: dependencies: lru-cache: 10.4.3 + html-encoding-sniffer@6.0.0: + dependencies: + '@exodus/bytes': 1.11.0 + transitivePeerDependencies: + - '@noble/hashes' + html-escaper@2.0.2: {} html-to-image@1.11.13: {} @@ -12007,6 +12566,8 @@ snapshots: is-plain-object@5.0.0: {} + is-potential-custom-element-name@1.0.1: {} + is-regex@1.2.1: dependencies: call-bound: 1.0.3 @@ -12167,6 +12728,32 @@ snapshots: jsdoc-type-pratt-parser@4.1.0: {} + jsdom@28.0.0: + dependencies: + '@acemir/cssom': 0.9.31 + '@asamuzakjp/dom-selector': 6.7.8 + '@exodus/bytes': 1.11.0 + cssstyle: 5.3.7 + data-urls: 7.0.0 + decimal.js: 10.6.0 + html-encoding-sniffer: 6.0.0 + http-proxy-agent: 7.0.2 + https-proxy-agent: 7.0.6 + is-potential-custom-element-name: 1.0.1 + parse5: 8.0.0 + saxes: 6.0.0 + symbol-tree: 3.2.4 + tough-cookie: 6.0.0 + undici: 7.21.0 + w3c-xmlserializer: 5.0.0 + webidl-conversions: 8.0.1 + whatwg-mimetype: 5.0.0 + whatwg-url: 16.0.0 + xml-name-validator: 5.0.0 + transitivePeerDependencies: + - '@noble/hashes' + - supports-color + jsesc@3.1.0: {} json-buffer@3.0.1: {} @@ -12355,6 +12942,8 @@ snapshots: lru-cache@10.4.3: {} + lru-cache@11.2.5: {} + lru-cache@5.1.1: dependencies: yallist: 3.1.1 @@ -13113,6 +13702,10 @@ snapshots: dependencies: entities: 4.5.0 + parse5@8.0.0: + dependencies: + entities: 6.0.1 + path-exists@3.0.0: {} path-exists@4.0.0: {} @@ -13381,7 +13974,7 @@ snapshots: dependencies: fast-diff: 1.3.0 - prettier@3.5.2: {} + prettier@3.6.2: {} pretty-format@27.5.1: dependencies: @@ -13798,6 +14391,10 @@ snapshots: optionalDependencies: '@parcel/watcher': 2.5.1 + saxes@6.0.0: + dependencies: + xmlchars: 2.2.0 + scheduler@0.23.2: dependencies: loose-envify: 1.4.0 @@ -14038,11 +14635,11 @@ snapshots: es-errors: 1.3.0 internal-slot: 1.1.0 - storybook@8.6.0(prettier@3.5.2): + storybook@8.6.0(prettier@3.6.2): dependencies: - '@storybook/core': 8.6.0(prettier@3.5.2)(storybook@8.6.0(prettier@3.5.2)) + '@storybook/core': 8.6.0(prettier@3.6.2)(storybook@8.6.0(prettier@3.6.2)) optionalDependencies: - prettier: 3.5.2 + prettier: 3.6.2 transitivePeerDependencies: - bufferutil - supports-color @@ -14221,6 +14818,8 @@ snapshots: csso: 5.0.5 picocolors: 1.1.1 + symbol-tree@3.2.4: {} + synckit@0.9.2: dependencies: '@pkgr/core': 0.1.1 @@ -14319,6 +14918,12 @@ snapshots: tinyspy@3.0.2: {} + tldts-core@7.0.22: {} + + tldts@7.0.22: + dependencies: + tldts-core: 7.0.22 + to-regex-range@5.0.1: dependencies: is-number: 7.0.0 @@ -14329,6 +14934,14 @@ snapshots: totalist@3.0.1: {} + tough-cookie@6.0.0: + dependencies: + tldts: 7.0.22 + + tr46@6.0.0: + dependencies: + punycode: 2.3.1 + traverse@0.6.8: {} trim-lines@3.0.1: {} @@ -14462,6 +15075,8 @@ snapshots: undici@6.22.0: {} + undici@7.21.0: {} + unicode-emoji-modifier-base@1.0.0: {} unicorn-magic@0.1.0: {} @@ -14691,7 +15306,7 @@ snapshots: sass: 1.85.1 terser: 5.44.0 - vitest@2.1.9(@types/node@22.13.5)(@vitest/ui@2.1.9)(sass@1.85.1)(terser@5.44.0): + vitest@2.1.9(@types/node@22.13.5)(@vitest/ui@2.1.9)(happy-dom@20.5.0)(jsdom@28.0.0)(sass@1.85.1)(terser@5.44.0): dependencies: '@vitest/expect': 2.1.9 '@vitest/mocker': 2.1.9(vite@5.4.20(@types/node@22.13.5)(sass@1.85.1)(terser@5.44.0)) @@ -14716,6 +15331,8 @@ snapshots: optionalDependencies: '@types/node': 22.13.5 '@vitest/ui': 2.1.9(vitest@2.1.9) + happy-dom: 20.5.0 + jsdom: 28.0.0 transitivePeerDependencies: - less - lightningcss @@ -14743,11 +15360,17 @@ snapshots: optionalDependencies: typescript: 5.7.3 + w3c-xmlserializer@5.0.0: + dependencies: + xml-name-validator: 5.0.0 + watchpack@2.4.4: dependencies: glob-to-regexp: 0.4.1 graceful-fs: 4.2.11 + webidl-conversions@8.0.1: {} + webpack-sources@3.3.3: {} webpack-virtual-modules@0.6.2: {} @@ -14786,8 +15409,21 @@ snapshots: dependencies: iconv-lite: 0.6.3 + whatwg-mimetype@3.0.0: + optional: true + whatwg-mimetype@4.0.0: {} + whatwg-mimetype@5.0.0: {} + + whatwg-url@16.0.0: + dependencies: + '@exodus/bytes': 1.11.0 + tr46: 6.0.0 + webidl-conversions: 8.0.1 + transitivePeerDependencies: + - '@noble/hashes' + which-boxed-primitive@1.1.1: dependencies: is-bigint: 1.1.0 @@ -14871,6 +15507,13 @@ snapshots: ws@8.18.1: {} + ws@8.19.0: + optional: true + + xml-name-validator@5.0.0: {} + + xmlchars@2.2.0: {} + xtend@4.0.2: {} y18n@5.0.8: {} diff --git a/public/json/departments.json b/public/json/departments.json index 49188ee2..f51249de 100644 --- a/public/json/departments.json +++ b/public/json/departments.json @@ -218,4 +218,4 @@ "WRT", "YID", "YOR" -] \ No newline at end of file +] diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..5dab565e --- /dev/null +++ b/shell.nix @@ -0,0 +1,10 @@ +(import ( + let + rev = "v1.1.0"; + sha256 = "sha256:19d2z6xsvpxm184m41qrpi1bplilwipgnzv9jy17fgw421785q1m"; + in + fetchTarball { + inherit sha256; + url = "https://github.com/NixOS/flake-compat/archive/${rev}.tar.gz"; + } +) { src = ./.; }).shellNix diff --git a/src/lib/chrome-extension-toolkit/README.md b/src/lib/chrome-extension-toolkit/README.md new file mode 100644 index 00000000..613c8910 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/README.md @@ -0,0 +1,8 @@ +# chrome-extension-toolkit + +Repo: https://github.com/sghsri/chrome-extension-toolkit +Author: sghsri +License: MIT +Version: 0.0.96 + +This library has been inlined into UTRP due to the package being removed from npm. diff --git a/src/lib/chrome-extension-toolkit/context/ContextInvalidated.tsx b/src/lib/chrome-extension-toolkit/context/ContextInvalidated.tsx new file mode 100644 index 00000000..b80215a9 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/context/ContextInvalidated.tsx @@ -0,0 +1,62 @@ +import React, { useState } from 'react'; + +const containerStyle: React.CSSProperties = { + position: 'fixed', + bottom: 0, + left: 0, + right: 0, + padding: '8px', + fontSize: '20px', + textAlign: 'center', + borderTopLeftRadius: '20px', + borderTopRightRadius: '20px', + zIndex: 999999999999, + cursor: 'pointer', +}; + +const closeButtonStyle: React.CSSProperties = { + position: 'absolute', + top: 0, + right: 0, + padding: '8px', + paddingRight: '20px', + fontSize: '20px', + cursor: 'pointer', +}; + +interface Props { + className?: string; + onClick?: () => void; +} + +/** + * A component that displays a message onto a content script when the context extension is invalidated. + */ +export function ContextInvalidated(props: Props): JSX.Element | null { + const [isShowing, setIsShowing] = useState(true); + + const hide = (e: React.MouseEvent) => { + e.stopPropagation(); + setIsShowing(false); + }; + + const reload = () => { + window.location.reload(); + }; + + return isShowing ? ( +
+ Context Extension Context invalidated. Click to reload +
+ ✕ +
+
+ ) : null; +} diff --git a/src/lib/chrome-extension-toolkit/context/index.ts b/src/lib/chrome-extension-toolkit/context/index.ts new file mode 100644 index 00000000..70b303cf --- /dev/null +++ b/src/lib/chrome-extension-toolkit/context/index.ts @@ -0,0 +1,2 @@ +export * from './ContextInvalidated'; +export * from './onContextInvalidated'; diff --git a/src/lib/chrome-extension-toolkit/context/onContextInvalidated.ts b/src/lib/chrome-extension-toolkit/context/onContextInvalidated.ts new file mode 100644 index 00000000..1cc466bb --- /dev/null +++ b/src/lib/chrome-extension-toolkit/context/onContextInvalidated.ts @@ -0,0 +1,14 @@ +/** + * A content script can be invalidated if a chrome extension is reloaded / updated. + * This function is used to detect when the extension's context has been invalidated, and to call a callback. + * @param callback A callback to be called when the extension's context has been invalidated + */ +export function onContextInvalidated(callback: () => void) { + const interval = setInterval(() => { + // this means the current tab's context has been invalidated + if (!chrome.runtime.id) { + clearInterval(interval); + callback(); + } + }, 1 * 1000); +} diff --git a/src/lib/chrome-extension-toolkit/dom/createShadowRoot.ts b/src/lib/chrome-extension-toolkit/dom/createShadowRoot.ts new file mode 100644 index 00000000..f2cd9d64 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/dom/createShadowRoot.ts @@ -0,0 +1,55 @@ +/** + * An extension of HTMLDivElement that represents a shadow root for use within an Extension Content Script. + */ +interface HTMLShadowDOMElement extends HTMLDivElement { + shadowRoot: ShadowRoot & { + INJECTION_POINT: HTMLDivElement; + }; + /** + * Adds a style sheet to the shadow root. + * @param path the path to the style sheet relative to the extension's root directory. uses chrome.runtime.getURL to get the absolute path. + */ + addStyle(path: string): Promise; +} + +/** + * In extension content scripts, often times the parent site's styles will override the styles of the extension. + * To get around this, we create a shadow DOM and isolate the extension's html and styles in the shadow DOM. + * from the parent site's styles to prevent conflicts. + * @param id the id of the shadow root. + * @param options the optional options for the shadow root. + * @param isolate whether or not to isolate the extension's document flow from the parent site's document flow. + * @returns A Div that represents the shadow root with some additional methods added to it. + */ +export function createShadowDOM(id: string, options?: ShadowRootInit, isolate = false): HTMLShadowDOMElement { + const html = document.querySelector('html'); + if (!html) { + throw new Error('Could not find html element'); + } + const div = document.createElement('div') as HTMLShadowDOMElement; + div.id = id; + div.style.all = 'initial'; + div.attachShadow({ + mode: 'open', + ...(options || {}), + }); + + const INJECTION_POINT = document.createElement('div'); + INJECTION_POINT.id = 'INJECTION_POINT'; + div.shadowRoot.appendChild(INJECTION_POINT); + div.shadowRoot.INJECTION_POINT = INJECTION_POINT; + + div.addStyle = async (path: string) => { + const style = await fetch(chrome.runtime.getURL(path)); + const styleNode = document.createElement('style'); + const parsedStyle = await style.text(); + styleNode.textContent = parsedStyle; + div.shadowRoot.appendChild(styleNode); + }; + + html.appendChild(div); + + if (isolate) document.body.style.isolation = 'isolate'; + + return div as HTMLShadowDOMElement; +} diff --git a/src/lib/chrome-extension-toolkit/dom/index.ts b/src/lib/chrome-extension-toolkit/dom/index.ts new file mode 100644 index 00000000..211e3742 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/dom/index.ts @@ -0,0 +1 @@ +export * from './createShadowRoot'; diff --git a/src/lib/chrome-extension-toolkit/getScriptType.ts b/src/lib/chrome-extension-toolkit/getScriptType.ts new file mode 100644 index 00000000..d277280d --- /dev/null +++ b/src/lib/chrome-extension-toolkit/getScriptType.ts @@ -0,0 +1,70 @@ +/** + * Possible contexts in which a chrome extension can run. + */ +export enum ScriptType { + CONTENT_SCRIPT = 'content_script', + BACKGROUND_SCRIPT = 'background_script', + EXTENSION_POPUP = 'extension_popup', + EXTENSION_PAGE = 'extension_page', +} + +/** + * Chrome extension code can run in different contexts. + * These different contexts have different capabilities and access to certain parts of the chrome extensions API. + * For example, the chrome.tabs api is not readily available in the content scripts. + * This function is used to identify the context in which the code is running. + * @returns The context in which the code is running, or null if the code is not running in a chrome extension. + */ +export default function getScriptType(): ScriptType | null { + if (!chrome?.runtime?.id) { + // we are not in a chrome extension + return null; + } + const manifest = chrome.runtime.getManifest(); + if (globalThis.window === undefined) { + return ScriptType.BACKGROUND_SCRIPT; + } + + if (window.location.href.startsWith(`chrome-extension://${chrome.runtime.id}`)) { + if (manifest.action?.default_popup && window.location.href.includes(manifest.action.default_popup)) { + return ScriptType.EXTENSION_POPUP; + } + return ScriptType.EXTENSION_PAGE; + } + + return ScriptType.CONTENT_SCRIPT; +} + +/** + * A helper function to check if the code is running in a content script. + * @returns true if the code is running in a content script, false otherwise. + */ +export function isContentScript(): boolean { + return getScriptType() === ScriptType.CONTENT_SCRIPT; +} + +/** + * A helper function to check if the code is running in the background script. + * @returns true if the code is running in the background script, false otherwise. + */ +export function isBackgroundScript(): boolean { + return getScriptType() === ScriptType.BACKGROUND_SCRIPT; +} + +/** + * A helper function to check if the code is running in the extension popup. + * @returns true if the code is running in the extension popup, false otherwise. + */ +export function isExtensionPopup(): boolean { + return getScriptType() === ScriptType.EXTENSION_POPUP; +} + +/** + * A helper function to check if the code is running in an extension page (popup, options, etc.). + * @returns true if the code is running in an extension page (popup, options, etc.), false otherwise. + * @param pageName The name of the page to check for. ex: 'options.html' + */ +export function isExtensionPage(pageName?: string): boolean { + const isPage = getScriptType() === ScriptType.EXTENSION_PAGE; + return isPage && pageName ? window.location.href.includes(pageName) : isPage; +} diff --git a/src/lib/chrome-extension-toolkit/index.ts b/src/lib/chrome-extension-toolkit/index.ts new file mode 100644 index 00000000..d29fbe01 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/index.ts @@ -0,0 +1,6 @@ +export * from './context'; +export * from './dom'; +export * from './getScriptType'; +export * from './messaging'; +export * from './storage'; +export * from './types'; diff --git a/src/lib/chrome-extension-toolkit/messaging/MessageListener.ts b/src/lib/chrome-extension-toolkit/messaging/MessageListener.ts new file mode 100644 index 00000000..38417625 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/messaging/MessageListener.ts @@ -0,0 +1,127 @@ +import getScriptType, { ScriptType } from '../getScriptType'; +import type { IMessageListener, Message, MessageHandler, Serializable } from '../types'; +import { MessageEndpoint } from '../types'; + +/** + * Options for configuring a message listener. + */ +export interface MessageListenerOptions { + /** + * A callback function that will be called when an error occurs. + * Useful if you want to log errors to a service like Sentry or Bugsnag. + * @param error The error that occurred. + */ + onError?: (error: Error) => void; + + /** + * A flag indicating whether verbose logging should be enabled. + */ + verbose?: boolean; +} + +/** + * An object that can be used to listen for and handle messages coming from another extension context. + */ +export class MessageListener implements IMessageListener { + private handlers: MessageHandler; + private scriptType: ScriptType; + private myEndpoint: MessageEndpoint; + private listeningFor: MessageEndpoint; + + private onError?: (error: Error) => void; + + private isVerbose: boolean = false; + + /** + * An object that can be used to listen for and handle messages coming from another extension context. + * @param handlers the message handlers for the messages that this listener will handle. When a message is received, the corresponding message handler is called. + */ + constructor(handlers: MessageHandler) { + this.handlers = handlers; + + // we want to know what type of script we are running in so we can determine what endpoint we are (background or foreground) + const scriptType = getScriptType(); + if (!scriptType) { + throw new Error('[crx-kit]: Unable to determine extension script type.'); + } + this.scriptType = scriptType; + + if (this.scriptType === ScriptType.BACKGROUND_SCRIPT) { + this.myEndpoint = MessageEndpoint.BACKGROUND; + this.listeningFor = MessageEndpoint.FOREGROUND; + } else { + this.myEndpoint = MessageEndpoint.FOREGROUND; + this.listeningFor = MessageEndpoint.BACKGROUND; + } + } + + private handleMessage = ( + message: Message, + sender: chrome.runtime.MessageSender, + sendResponse: (response: any) => void + ): boolean => { + if (message.to !== this.myEndpoint && message.from !== this.listeningFor) { + // this message is not for my current context, so ignore it + return true; + } + const messageName = message.name as string; + + // @ts-expect-error + const handler = this.handlers[messageName]; + if (!handler) { + // this message is for my current context, but I don't have a handler for it, so ignore it + return true; + } + try { + if (this.isVerbose) { + console.log(`[crx-kit]: message received: ${messageName}`, { + name: messageName, + data: message.data, + sender, + }); + } + // this message is for my current context, and I have a handler for it, so handle it + handler({ + data: message.data as Serializable, + sendResponse, + sender, + }); + } catch (error) { + console.error(`[crx-kit]: Error handling message ${messageName}`, { + name: messageName, + error, + message, + sender, + }); + if (this.onError) { + // @ts-expect-error + this.onError(error); + } + } + + return true; + }; + + /** + * Listens for messages from the specified source. + * @param options - The options for the message listener. + */ + public listen(options: MessageListenerOptions = { verbose: false }) { + this.isVerbose = options.verbose ?? false; + this.onError = options.onError; + console.log(`[crx-kit]: ${this.toString()} listening for messages from ${this.listeningFor}`); + chrome.runtime.onMessage.addListener(this.handleMessage); + } + + /** + * Stops listening for messages + */ + public unlisten() { + console.log(`[crx-kit]: ${this.toString()} no longer listening for messages from ${this.listeningFor}`); + chrome.runtime.onMessage.removeListener(this.handleMessage); + } + + private toString() { + return `MessageListener(${this.myEndpoint})`; + } +} diff --git a/src/lib/chrome-extension-toolkit/messaging/createMessenger.ts b/src/lib/chrome-extension-toolkit/messaging/createMessenger.ts new file mode 100644 index 00000000..befe60da --- /dev/null +++ b/src/lib/chrome-extension-toolkit/messaging/createMessenger.ts @@ -0,0 +1,94 @@ +import type { Message, MessageData, MessageResponse } from '../types'; +import { MessageEndpoint } from '../types'; +/** + * An object that can be used to send messages to the background script. + */ export type BackgroundMessenger = { + [K in keyof M]: MessageData extends undefined + ? () => Promise> + : (data: MessageData) => Promise>; +}; + +/** + * Where the foreground message is being sent to specifically (which tab or frame) + */ +type ForegroundMessageOptions = + | { + tabId: number; + frameId?: number; + } + | { + tabId: 'ALL' | 'ACTIVE_TAB'; + }; + +/** + * an object that can be used to send messages to the foreground (tabs OR extension pages (popup, options, etc.)) + */ +export type ForegroundMessenger = { + [K in keyof M]: MessageData extends undefined + ? (options: ForegroundMessageOptions) => Promise> + : (data: MessageData, options: ForegroundMessageOptions) => Promise>; +}; + +/** + * A wrapper for chrome extension messaging with a type-safe API. + * @type To which context the messages are sent. + * @returns A proxy object that can be used to send messages to the foreground (tabs or extension pages (popup, options, etc.)) + */ +export function createMessenger(destination: 'foreground'): ForegroundMessenger; +/** + * A wrapper for chrome extension messaging with a type-safe API. + * @param type To which context the messages are sent. + * @returns A proxy object that can be used to send messages to the background script. + */ +export function createMessenger(destination: 'background'): BackgroundMessenger; +/** + * A wrapper for chrome extension messaging with a type-safe API. + * @param destination To which context the messages are sent. + * @returns A proxy object that can be used to send messages to the background script. + */ +export function createMessenger(destination: 'background' | 'foreground') { + let to: MessageEndpoint = MessageEndpoint.BACKGROUND; + let from: MessageEndpoint = MessageEndpoint.FOREGROUND; + + if (destination === 'foreground') { + to = MessageEndpoint.FOREGROUND; + from = MessageEndpoint.BACKGROUND; + } + + const sender = new Proxy({} as any, { + get(target, prop) { + const name = prop as keyof M; + return async (data: MessageData, options?: ForegroundMessageOptions) => { + const message: Message = { + name, + data, + from, + to, + }; + + if (to === MessageEndpoint.FOREGROUND && options) { + // for messages sent to the tabs, we want to send to the tabs using chrome.tabs.sendMessage, + const { tabId } = options; + if (typeof tabId === 'number') { + return chrome.tabs.sendMessage(tabId, message, { frameId: options.frameId }); + } + if (tabId === 'ACTIVE_TAB') { + const tab = (await chrome.tabs.query({ active: true, currentWindow: true }))[0]; + if (tab && tab.id) { + return chrome.tabs.sendMessage(tab.id, message); + } + } + if (tabId === 'ALL') { + const tabs = (await chrome.tabs.query({})).filter(tab => tab.id !== undefined && tab.url); + return Promise.any([ + ...tabs.map(tab => chrome.tabs.sendMessage(tab.id!, message)), + chrome.runtime.sendMessage(message), + ]); + } + } + return chrome.runtime.sendMessage(message); + }; + }, + }); + return sender; +} diff --git a/src/lib/chrome-extension-toolkit/messaging/createUseMessage.ts b/src/lib/chrome-extension-toolkit/messaging/createUseMessage.ts new file mode 100644 index 00000000..21a0e919 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/messaging/createUseMessage.ts @@ -0,0 +1,30 @@ +import { useEffect } from 'react'; + +import type { Message, MessageData } from '../types'; + +/** + * A helper function to create a hook that can listen for messages coming through chrome.runtime.onMessage + * with e2e type safety + * @returns a hook that can be used to listen for messages from the background script. + */ +export function createUseMessage() { + return function useMessage>( + name: N, + callback: (data: D) => void + ): void { + useEffect(() => { + const onMessage = (message: Message) => { + if (message.name === name) { + callback(message.data); + } + return true; + }; + + chrome.runtime.onMessage.addListener(onMessage); + + return () => { + chrome.runtime.onMessage.removeListener(onMessage); + }; + }, [name, callback]); + }; +} diff --git a/src/lib/chrome-extension-toolkit/messaging/index.ts b/src/lib/chrome-extension-toolkit/messaging/index.ts new file mode 100644 index 00000000..24919a77 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/messaging/index.ts @@ -0,0 +1,3 @@ +export * from './createMessenger'; +export * from './createUseMessage'; +export * from './MessageListener'; diff --git a/src/lib/chrome-extension-toolkit/modules.d.ts b/src/lib/chrome-extension-toolkit/modules.d.ts new file mode 100644 index 00000000..68859399 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/modules.d.ts @@ -0,0 +1,15 @@ +declare global { + namespace NodeJS { + interface ProcessEnv { + NODE_ENV: 'development' | 'production' | 'test'; + CI?: string; + EXTENSION_STORAGE_PASSWORD?: string; + } + } + + type Environment = typeof process.env.NODE_ENV; +} + +// If this file has no import/export statements (i.e. is a script) +// convert it into a module by adding an empty export statement. +export {}; diff --git a/src/lib/chrome-extension-toolkit/storage/Security.ts b/src/lib/chrome-extension-toolkit/storage/Security.ts new file mode 100644 index 00000000..8a21247d --- /dev/null +++ b/src/lib/chrome-extension-toolkit/storage/Security.ts @@ -0,0 +1,214 @@ +/* eslint-disable max-classes-per-file */ +const { crypto } = globalThis; + +/** the number of times the key_algo will be run on the password */ +const ITERATIONS = 470_000; +/** the algorithm used to derive the password key from the password */ +const KEY_ALGO = 'PBKDF2'; +/** the algorithm used to derive the cipher key from the password key */ +const HASH_ALGO = 'SHA-256'; +/** the algorithm used to encrypt the data */ +const CIPHER_MODE = 'AES-GCM'; + +/** the size of the cipher key */ +const CIPHER_SIZE = 256; + +/** + * A class that provides encryption and decryption methods for use when storing data in the Stores provided by this library. + */ +export class Security { + private encoder = new TextEncoder(); + private decoder = new TextDecoder(); + + private cachedPasswordKey?: CryptoKey; + + public static MISSING_PASSWORD_ERROR_MESSAGE = + 'You must set the EXTENSION_STORAGE_PASSWORD environment variable to use encrypted storage.'; + + /** + * @returns the password key, either from the cache or by generating a new one from the password environment variable + */ + private async getPasswordKey(): Promise { + if (this.cachedPasswordKey) return this.cachedPasswordKey; + + if (!process.env.EXTENSION_STORAGE_PASSWORD) { + throw new Error(Security.MISSING_PASSWORD_ERROR_MESSAGE); + } + + const passwordBuffer = this.encoder.encode(process.env.EXTENSION_STORAGE_PASSWORD); + this.cachedPasswordKey = await crypto.subtle.importKey( + 'raw', + passwordBuffer, + { name: KEY_ALGO }, + false, // Not exportable + ['deriveKey'] + ); + return this.cachedPasswordKey; + } + + /** + * Derives a cipher key from the password key and salt + * @param salt the salt to use when deriving the cipher key + * @param passKey the password key to use when deriving the cipher key + * @param KeyUsage the key usage for the cipher key (encrypt or decrypt) + * @returns the cipher key which can be used to encrypt or decrypt data + */ + private async deriveCipherKey(salt: Uint8Array, passKey: CryptoKey, KeyUsage: KeyUsage[]): Promise { + return crypto.subtle.deriveKey( + { + name: KEY_ALGO, + hash: HASH_ALGO, + salt, + iterations: ITERATIONS, + }, + passKey, + { + name: CIPHER_MODE, + length: CIPHER_SIZE, + }, + false, + KeyUsage + ); + } + + /** + * @returns a random salt buffer for use in encryption + */ + private deriveSalt(): Uint8Array { + return crypto.getRandomValues(new Uint8Array(BoxBuffer.SALT_SIZE)); + } + + /** + * @returns a random IV buffer for use in encryption + */ + private deriveIv(): Uint8Array { + return crypto.getRandomValues(new Uint8Array(BoxBuffer.IV_SIZE)); + } + + /** + * Decrypts a value that has been encrypted using the encrypt method + * @param value the encrypted value to decrypt + * @returns the decrypted value + */ + async decrypt(value: any) { + if (!value) return value; + if (!isString(value)) return value; + + const passKey = await this.getPasswordKey(); + + // read in the string into a boxBuffer, and separate the salt, iv and encrypted data from it + const boxBuffer = BoxBuffer.fromBase64String(value); + const salt = boxBuffer.getSalt(); + const iv = boxBuffer.getIv(); + const encryptedData = boxBuffer.getEncryptedData(); + + // generate the decryption key + const decryptionKey = await this.deriveCipherKey(salt, passKey, ['decrypt']); + + // decrypt the data using the decryption key + const decryptedDataBuffer = await crypto.subtle.decrypt( + { + name: CIPHER_MODE, + iv, + }, + decryptionKey, + encryptedData + ); + + // parse the decrypted data into a JSON object and return it + return decryptedDataBuffer.byteLength === 0 ? undefined : JSON.parse(this.decoder.decode(decryptedDataBuffer)); + } + + /** + * Encrypts a value using the password key derived from the EXTENSION_STORAGE_PASSWORD environment variable + * @param value the value to encrypt + * @returns the encrypted value as a base64 string + */ + async encrypt(value: any): Promise { + let valueString = JSON.stringify(value); + + const passKey = await this.getPasswordKey(); + + const salt = this.deriveSalt(); + const iv = this.deriveIv(); + + const encryptionKey = await this.deriveCipherKey(salt, passKey, ['encrypt']); + + const encryptedData = new Uint8Array( + await crypto.subtle.encrypt( + { + name: CIPHER_MODE, + iv, + }, + encryptionKey, + this.encoder.encode(valueString) + ) + ); + + // create a boxBuffer to store the salt, iv and encrypted data together in a single buffer + const bufferSize = BoxBuffer.PREFIX_SIZE + encryptedData.byteLength; + + const boxBuffer = new BoxBuffer(new Uint8Array(bufferSize)); + boxBuffer.setSalt(salt); + boxBuffer.setIv(iv); + boxBuffer.setEncryptedData(encryptedData); + + // return the boxBuffer as a base64 string (to make it easier to store) + return boxBuffer.toBase64String(); + } +} + +/** + * A class representation of a buffer box in memory of the form: + * [salt][iv][encrypted data] + */ +class BoxBuffer { + private buffer: Uint8Array; + static SALT_SIZE = 16; + static IV_SIZE = 32; + + static get PREFIX_SIZE() { + return BoxBuffer.SALT_SIZE + BoxBuffer.IV_SIZE; + } + + constructor(buffer: Uint8Array) { + this.buffer = buffer; + } + + setSalt(salt: Uint8Array) { + this.buffer.set(salt, 0); + } + + setIv(iv: Uint8Array) { + this.buffer.set(iv, BoxBuffer.SALT_SIZE); + } + + setEncryptedData(encryptedData: Uint8Array) { + this.buffer.set(encryptedData, BoxBuffer.PREFIX_SIZE); + } + + getSalt(): Uint8Array { + return this.buffer.slice(0, BoxBuffer.SALT_SIZE); + } + + getIv(): Uint8Array { + return this.buffer.slice(BoxBuffer.SALT_SIZE, BoxBuffer.PREFIX_SIZE); + } + + getEncryptedData(): Uint8Array { + return this.buffer.slice(BoxBuffer.PREFIX_SIZE); + } + + toBase64String() { + return globalThis.btoa(String.fromCharCode.apply(null, this.buffer as any)); + } + + static fromBase64String(base64String: string): BoxBuffer { + const rawBuffer = Uint8Array.from(globalThis.atob(base64String), c => c.charCodeAt(0)); + return new BoxBuffer(rawBuffer); + } +} + +function isString(value: any): value is string { + return typeof value === 'string' || value instanceof String; +} diff --git a/src/lib/chrome-extension-toolkit/storage/createStore.ts b/src/lib/chrome-extension-toolkit/storage/createStore.ts new file mode 100644 index 00000000..38578292 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/storage/createStore.ts @@ -0,0 +1,447 @@ +/* eslint-disable no-await-in-loop */ +import { useEffect, useState } from 'react'; + +import type { Serializable } from '../types'; +import { Security } from './Security'; + +/** A utility type that forces you to declare all the values specified in the type interface for a module. */ +export type StoreDefaults = { + [P in keyof Required]: Pick extends Required> ? T[P] : T[P] | undefined; +}; + +/** + * Represents a change in data within the store. + */ +export type DataChange = { + key: string; + /** + * The old value of the data. This will be undefined if the data was just initialized. + */ + oldValue?: Serializable; + /** + * The new value of the data. + */ + newValue: Serializable; +}; + +/** + * A function that is called when the data in the store changes. + */ +export type OnChangedFunction = (changes: DataChange) => void; + +/** + * A virtual wrapper around the chrome.storage API that allows you to segment and compartmentalize your data. + * The data is all stored at the top level of the storage area, so you should namespace your keys to avoid collisions. + */ +export type Store = { + /** + * A unique identifier for the store. This will be prepended to all keys in the store to avoid collisions. + */ + readonly storeId: string; + /** + * The options that were passed to the createStore function + */ + readonly options: StoreOptions; + + /** + * The default values for the store. These were passed to the createStore function and will be used to initialize the store if the key is not already set. + */ + readonly defaults: StoreDefaults; + /** + * Initializes the store by setting any keys that are not already set to their default values. This will be called automatically when you first access a getter or setter. + */ + initialize(): Promise; + + /** + * Gets the value of the specified key from the store. + * @param key the key to get the value of + * @returns a promise that resolves to the value of the specified key (wrapped in a Serialized type) + */ + get(key: K): Promise>; + + /** + * Sets the value of the specified key in the store. + * @param key the key to set the value of + * @param value the value to set the key to + */ + set(key: K, value: Serializable): Promise; + + /** + * Sets the store with the values in the object passed in. + * @param values an object containing the keys and values to set in the store + */ + set(values: Partial>): Promise; + + /** + * Removes a specific key from the store. + * @param key the key to remove from the store + */ + remove(key: K): Promise; + + /** + * Returns a promise that resolves to the entire contents of the store. + */ + all(): Promise>; + + /** + * Returns an array of all the keys in the store. + */ + keys(): (keyof T & string)[]; + + /** + * A react hook that allows you to get and set the value of the specified key in the store from a functional component. + * @param key the key to get the value of or null to get the entire store + * @returns a tuple containing the value of the specified key, and a function to set the value + */ + use( + key: K + ): [ + K extends keyof T ? Serializable : Serializable, + (value: K extends keyof T ? Serializable : Partial>) => Promise, + ]; + + /** + * A react hook that allows you to get and set the value of the specified key in the store from a functional component. + * @param key the key to get the value of or null to get the entire store + * @param defaultValue the default value to use if the key is not already set + */ + use( + key: K, + defaultValue: K extends keyof T ? Serializable : Serializable + ): [ + K extends keyof T ? Serializable : Serializable, + (value: K extends keyof T ? Serializable : Partial>) => Promise, + ]; + + /** + * Subscribes to changes in the specified key in the store, and calls the specified function when the key changes. + * @param key the key to subscribe to + * @param callback the function to call when the key changes + */ + // @ts-expect-error + subscribe(key: K, callback: OnChangedFunction): (changes, area) => void; + // @ts-expect-error + subscribe(key: K[], callback: OnChangedFunction): (changes, area) => void; + + /** + * Removes a subscription that was added with the subscribe function. + * @param sub the subscription function that was added + */ + // @ts-expect-error + unsubscribe(sub: (changes, area) => void): void; +}; + +/** + * Options that modify the behavior of the store + */ +type StoreOptions = { + /** + * Whether or not to encrypt the data before storing it, and decrypt it when retrieving it. Defaults to false. + */ + isEncrypted?: boolean; +}; + +const security = new Security(); + +/** + * A function that creates a virtual storage bucket within the chrome.storage API. + * + * @param defaults the default values for the store (these will be used to initialize the store if the key is not already set, and will be used as the type for the getters and setters) + * @param area the storage area to use. Defaults to 'local' + * @returns an object which contains getters/setters for the keys in the defaults object, as well as an initialize function and an onChanged functions + */ +function createStore( + storeId: string, + defaults: StoreDefaults, + area: 'sync' | 'local' | 'session' | 'managed', + options?: StoreOptions +): Store { + const keys = Object.keys(defaults) as string[]; + const actualKeys = keys.map(key => `${storeId}:${key}`); + + let isEncrypted = options?.isEncrypted || false; + + if (isEncrypted && !process.env.EXTENSION_STORAGE_PASSWORD) { + throw new Error(Security.MISSING_PASSWORD_ERROR_MESSAGE); + } + + const store = { + defaults, + storeId, + options, + } as Store; + + let hasInitialized = false; + store.initialize = async () => { + const data = await chrome.storage[area].get(actualKeys); + const missingKeys = actualKeys.filter(key => data[key] === undefined); + + if (missingKeys.length) { + const defaultsToSet = {}; + + for (const key of missingKeys) { + // @ts-expect-error + const value = defaults[key.replace(`${storeId}:`, '')]; + // @ts-expect-error + defaultsToSet[key] = isEncrypted ? await security.encrypt(value) : value; + } + + await chrome.storage[area].set(defaultsToSet); + } + hasInitialized = true; + }; + + store.get = async (key: any) => { + if (!hasInitialized) { + await store.initialize(); + } + + const actualKey = `${storeId}:${key}`; + + const value = (await chrome.storage[area].get(actualKey))[actualKey]; + return isEncrypted ? await security.decrypt(value) : value; + }; + + store.set = async (key: any, value?: any) => { + if (!hasInitialized) { + await store.initialize(); + } + + // Handle the case where key is an object + if (typeof key === 'object' && value === undefined) { + const entriesToRemove: string[] = []; + const entriesToSet = {}; + + for (const [k, v] of Object.entries(key)) { + const actualKey = `${storeId}:${k}`; + if (v === undefined) { + // Prepare to remove this key + entriesToRemove.push(actualKey); + } else { + // @ts-expect-error + entriesToSet[actualKey] = isEncrypted ? await security.encrypt(v) : v; + } + } + + // Remove keys with undefined values + if (entriesToRemove.length > 0) { + await chrome.storage[area].remove(entriesToRemove); + } + + // Set keys with defined values + if (Object.keys(entriesToSet).length > 0) { + await chrome.storage[area].set(entriesToSet); + } + + return; + } + // now we know key is a string, so lets either set or remove it directly + + const actualKey = `${storeId}:${key}`; + if (value === undefined) { + // Remove if value is explicitly undefined + return await chrome.storage[area].remove(actualKey); + } + + // Set the value, applying encryption if necessary + await chrome.storage[area].set({ + [actualKey]: isEncrypted ? await security.encrypt(value) : value, + }); + }; + + store.remove = async (key: any) => { + if (!hasInitialized) { + await store.initialize(); + } + + const actualKey = `${storeId}:${key}`; + await chrome.storage[area].remove(actualKey); + }; + + store.all = async () => { + if (!hasInitialized) { + await store.initialize(); + } + const fullStore = await chrome.storage[area].get(actualKeys); + if (isEncrypted) { + await Promise.all( + keys.map(async key => { + const actualKey = `${storeId}:${key}`; + fullStore[key] = await security.decrypt(fullStore[actualKey]); + }) + ); + } + // now we need to remove the storeId from the keys + Object.keys(fullStore).forEach(actualKey => { + const newKey = actualKey.replace(`${storeId}:`, ''); + fullStore[newKey] = fullStore[actualKey]; + delete fullStore[actualKey]; + }); + return fullStore as Serializable; + }; + + store.keys = () => keys as (keyof T & string)[]; + + store.subscribe = (key: string | string[], callback) => { + // @ts-expect-error + const sub = async (changes, areaName) => { + const keys = Array.isArray(key) ? key : [key]; + const actualKeys = keys.map(k => `${storeId}:${k}`); + + if (areaName !== area) return; + + // make sure that there are keys is in the changes object + const subKeys = Object.keys(changes).filter(k => actualKeys.includes(k)); + if (!subKeys.length) return; + + subKeys.forEach(async actualKey => { + const key = actualKey.replace(`${storeId}:`, ''); + const [oldValue, newValue] = await Promise.all([ + isEncrypted ? security.decrypt(changes[actualKey].oldValue) : changes[actualKey].oldValue, + isEncrypted ? security.decrypt(changes[actualKey].newValue) : changes[actualKey].newValue, + ]); + + callback({ + key, + oldValue, + newValue, + }); + }); + }; + + chrome.storage.onChanged.addListener(sub); + return sub; + }; + + store.unsubscribe = sub => { + chrome.storage.onChanged.removeListener(sub); + }; + + // @ts-ignore + store.use = (key: keyof T | null, defaultValue?: key extends null ? T : T[typeof key]) => { + const initialValue: any = (() => { + // an explicit default value was passed, use it + if (arguments.length === 2) { + return defaultValue; + } + // a key was passed, but no default value was passed, use the default value from the defaults object + if (key === null) { + return defaults; + } + // no key was passed, use the default value from the defaults object + return defaults[key]; + })(); + + const [value, setValue] = useState(initialValue); + + const onChange = ({ key: k, newValue }: DataChange) => { + if (key === null) { + // @ts-expect-error + setValue(prev => ({ ...prev, [k]: newValue }) as any); + } else { + setValue(newValue as any); + } + }; + + useEffect(() => { + if (key === null) { + store + .all() + .then(setValue) + .then(() => { + store.subscribe(store.keys(), onChange as any); + }); + } else { + store + .get(key) + .then(setValue) + .then(() => { + store.subscribe(key, onChange as any); + }); + } + return () => { + store.unsubscribe(onChange as any); + }; + }, []); + + // @ts-expect-error + const set = async newValue => { + if (key === null) { + await store.set(newValue as any); + } else { + await store.set(key, newValue as any); + } + }; + + return [value, set] as any; + }; + + return store; +} + +/** + * A function that creates a virtual storage bucket within the chrome.storage.local API. + * This store will persist across browser sessions and be stored on the user's computer. + * + * @param storeId A unique key to use for this store. This will be prepended to all keys in the store to avoid collisions. ex: 'my-store' -> 'my-store:myKey' + * @param defaults the default values for the store (these will be used to initialize the store if the key is not already set, and will be used as the type for the getters and setters) + * @param computed an optional function that allows you to override the generated getters and setters with your own. Provides a reference to the store itself so you can access this store's getters and setters. + * @param area the storage area to use. Defaults to 'local' + * @returns an object which contains getters/setters for the keys in the defaults object, as well as an initialize function and an onChanged functions + */ +export function createLocalStore(storeId: string, defaults: StoreDefaults, options?: StoreOptions): Store { + return createStore(storeId, defaults, 'local', options); +} + +/** + * A function that creates a virtual storage bucket within the chrome.storage.sync API. + * This store will persist across browser sessions and be stored on the user's Google account (if they are logged in). + * This means that the data will be synced across all of the user's devices. + * + * @param storeId A unique key to use for this store. This will be prepended to all keys in the store to avoid collisions. ex: 'my-store' -> 'my-store:myKey' + * @param defaults the default values for the store (these will be used to initialize the store if the key is not already set, and will be used as the type for the getters and setters) + * @param options options that modify the behavior of the store + * @returns an object which contains getters/setters for the keys in the defaults object, as well as an initialize function and an onChanged functions + */ +export function createSyncStore(storeId: string, defaults: StoreDefaults, options?: StoreOptions): Store { + return createStore(storeId, defaults, 'sync', options); +} + +/** + * A function that creates a virtual storage bucket within the chrome.storage.managed API. + * This store will persist across browser sessions and managed by the administrator of the user's computer. + * + * @param storeId A unique key to use for this store. This will be prepended to all keys in the store to avoid collisions. ex: 'my-store' -> 'my-store:myKey' + * @param defaults the default values for the store (these will be used to initialize the store if the key is not already set, and will be used as the type for the getters and setters) + * @param options options that modify the behavior of the store + * @returns an object which contains getters/setters for the keys in the defaults object, as well as an initialize function and an onChanged functions + * @see https://developer.chrome.com/docs/extensions/reference/storage/#type-ManagedStorageArea + * + */ +export function createManagedStore(storeId: string, defaults: StoreDefaults, options?: StoreOptions): Store { + return createStore(storeId, defaults, 'managed', options); +} + +/** + * A function that creates a virtual storage bucket within the chrome.storage.session API. + * This store will NOT persist across browser sessions and will be stored in memory. This will reset when the browser is closed. + * + * @param storeId A unique key to use for this store. This will be prepended to all keys in the store to avoid collisions. ex: 'my-store' -> 'my-store:myKey' + * @param defaults the default values for the store (these will be used to initialize the store if the key is not already set, and will be used as the type for the getters and setters) + * @param options options that modify the behavior of the store + * @returns an object which contains getters/setters for the keys in the defaults object, as well as an initialize function and an onChanged functions + */ +export function createSessionStore(storeId: string, defaults: StoreDefaults, options?: StoreOptions): Store { + return createStore(storeId, defaults, 'session', options); +} + +// interface MyStore { +// name: string; +// age: number; +// isCool?: boolean; +// } +// const store = createLocalStore('my-store', { +// age: 0, +// isCool: false, +// name: 'John Doe', +// }); diff --git a/src/lib/chrome-extension-toolkit/storage/index.ts b/src/lib/chrome-extension-toolkit/storage/index.ts new file mode 100644 index 00000000..f02eb6e4 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/storage/index.ts @@ -0,0 +1,2 @@ +export * from './createStore'; +export * from './Security'; diff --git a/src/lib/chrome-extension-toolkit/types/Messaging.ts b/src/lib/chrome-extension-toolkit/types/Messaging.ts new file mode 100644 index 00000000..c7eb4616 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/types/Messaging.ts @@ -0,0 +1,70 @@ +import type { Serializable } from './Serialization'; + +/** + * MessageDefinition is a record of message names and their data types. + * The data type is the type of the first argument of the message handler. + * The return type of the message handler is the resolved type of the promise returned by the message sender. + */ +export type MessageDefinition | undefined) => any>> = T; + +/** + * A helper type to extract the data type of a message handler. + */ +export type MessageData = Serializable< + Parameters any ? M[K] : never>[0] +>; + +/** + * A helper type to extract the resolved type of a message handler. + */ +export type MessageResponse = Serializable< + ReturnType any ? M[K] : never> +>; +/** + * The internal object representing a message sent between chrome extension contexts. + */ +export type Message = { + name: keyof M; + data: MessageData; + from: MessageEndpoint; + to: MessageEndpoint; +}; + +/** + * Represents the extension context in which a message is either sent or received. + * The context is either the background script/service worker or a tab. + */ +export enum MessageEndpoint { + /** The background script or service worker. */ + BACKGROUND = 'BACKGROUND', + /** A foreground or extension page (popup, options, etc) */ + FOREGROUND = 'FOREGROUND', +} + +/** + * An object that implements the message handlers for each of the messages in the message definition. + */ +export type MessageHandler = { + [K in keyof M]: (context: { + /** The data sent with the message. */ + data: MessageData; + /** The tab or page or background service worker that sent the message. */ + sender: chrome.runtime.MessageSender; + /** A function that can be used to send a response asynchronously to the sender. */ + sendResponse: (response: MessageResponse) => void; + }) => Promise | void; +}; + +/** + * An object that can be used to handle messages coming from another extension context. + */ +export interface IMessageListener { + /** + * Starts listening for messages. When a message is received, the corresponding message handler is called. + */ + listen: (handler: MessageHandler) => void; + /** + * Stops listening for messages. + */ + unlisten: () => void; +} diff --git a/src/lib/chrome-extension-toolkit/types/Serialization.ts b/src/lib/chrome-extension-toolkit/types/Serialization.ts new file mode 100644 index 00000000..24a00124 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/types/Serialization.ts @@ -0,0 +1,69 @@ +type Primitive = string | number | boolean | null | undefined; + +/** + * A type that represents a serialized object. This is a recursive type that will serialize all properties of an object, except for functions which are ignored (and thus not serialized) + */ +export type Serialized = { + [K in keyof T as T[K] extends Function ? never : K]: Serializable; +}; + +/** + * Represents a type that can be serialized to JSON. This could either be a primitive type, an array of serializable types, or a complex object + * Recursively serializes an object to a JSON-compatible object. + */ +export type Serializable = T extends Primitive + ? T + : T extends Array + ? Array> + : T extends object + ? Serialized + : T; + +/** + * Serializes a value to a JSON-compatible object (i.e. a Serializable) + * @returns A JSON-compatible object that represents the value passed in with all functions removed and all objects recursively serialized + */ +export function serialize(value: T): Serializable { + return JSON.parse(JSON.stringify(value)) as Serializable; +} + +// THIS IS FOR TESTINWG THE TYPING + +// type Test2 = { +// test: string; +// openNewTab: (url: string) => void; +// url?: URL; +// }; + +// type Test1 = { +// openNewTab: (url: string) => void; +// count: number; +// url: URL; +// urls?: URL[]; +// foo: Test2; +// bar?: Test2; +// }; + +// let x: Serialized; +// // ^? + +// type SerializedData = Serializable; + +// let data: SerializedData = {} as any; + +// data.url = undefined; + +// data = { +// a: 'test', +// b: 1, +// c: true, +// d: { +// e: 'test', +// t: undefined, +// }, +// urls: [], +// }; + +// data.d = { +// e: 'test', +// }; diff --git a/src/lib/chrome-extension-toolkit/types/Test.ts b/src/lib/chrome-extension-toolkit/types/Test.ts new file mode 100644 index 00000000..fafe53f7 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/types/Test.ts @@ -0,0 +1,47 @@ +type Primitive = string | number | boolean | null | undefined; + +type Serialized = { + [K in keyof T as T[K] extends Function ? never : K]: Serializable; +}; + +type Serializable = T extends Primitive + ? T + : T extends Array + ? Array> + : T extends object + ? Serialized + : T; + +type Data = { + a: string; + b: number; + c: boolean; + url?: URL; + d: { + e: string; + t?: URL; + }; + get: () => void; + urls: URL[]; +}; + +type SerializedData = Serializable; + +let x: SerializedData = {} as any; + +x.url = undefined; + +x = { + a: 'test', + b: 1, + c: true, + d: { + e: 'test', + t: undefined, + }, + urls: [], +}; + +x.d = { + e: 'test', +}; diff --git a/src/lib/chrome-extension-toolkit/types/index.ts b/src/lib/chrome-extension-toolkit/types/index.ts new file mode 100644 index 00000000..8c264a38 --- /dev/null +++ b/src/lib/chrome-extension-toolkit/types/index.ts @@ -0,0 +1,6 @@ +export * from './Messaging'; +export * from './Serialization'; + +export type AddParameters any, TParameters extends [...args: any]> = ( + ...args: [...Parameters, ...TParameters] +) => ReturnType; diff --git a/src/lib/chrome-extension-toolkit/utils/Console.ts b/src/lib/chrome-extension-toolkit/utils/Console.ts new file mode 100644 index 00000000..2d283a5c --- /dev/null +++ b/src/lib/chrome-extension-toolkit/utils/Console.ts @@ -0,0 +1,48 @@ +const LOG_BACKGROUND_COLOR = '#2196F3'; +const LOG_TEXT_COLOR = '#fff'; + +const SUCCESS_BACKGROUND_COLOR = '#4CAF50'; +const SUCCESS_TEXT_COLOR = '#fff'; + +const ERROR_BACKGROUND_COLOR = '#F44336'; +const ERROR_TEXT_COLOR = '#fff'; + +const WARNING_BACKGROUND_COLOR = '#FFC107'; +const WARNING_TEXT_COLOR = '#fff'; + +/** + * Utility class for logging messages with different styles. + */ +export class Console { + static log(...args: any[]) { + console.log( + `%c ${args[0]} `, + `background: ${LOG_BACKGROUND_COLOR}; color: ${LOG_TEXT_COLOR}`, + ...args.slice(1) + ); + } + + static success(...args: any[]) { + console.log( + `%c ${args[0]} `, + `background: ${SUCCESS_BACKGROUND_COLOR}; color: ${SUCCESS_TEXT_COLOR}`, + ...args.slice(1) + ); + } + + static error(...args: any[]) { + console.error( + `%c ${args[0]} `, + `background: ${ERROR_BACKGROUND_COLOR}; color: ${ERROR_TEXT_COLOR}`, + ...args.slice(1) + ); + } + + static warn(...args: any[]) { + console.warn( + `%c ${args[0]} `, + `background: ${WARNING_BACKGROUND_COLOR}; color: ${WARNING_TEXT_COLOR}`, + ...args.slice(1) + ); + } +} diff --git a/src/lib/chrome-extension-toolkit/utils/string.ts b/src/lib/chrome-extension-toolkit/utils/string.ts new file mode 100644 index 00000000..215827ed --- /dev/null +++ b/src/lib/chrome-extension-toolkit/utils/string.ts @@ -0,0 +1,8 @@ +/** + * Capitalizes the first letter of a string + * @param str the string to capitalize + * @returns the capitalized string + */ +export function capitalize(str: string): string { + return str.charAt(0).toUpperCase() + str.slice(1); +} diff --git a/src/pages/404/Page404.tsx b/src/pages/404/Page404.tsx index f5e94389..87031b46 100644 --- a/src/pages/404/Page404.tsx +++ b/src/pages/404/Page404.tsx @@ -271,12 +271,12 @@ export default function Page404(): JSX.Element { } function _0x5629d1() { let _0x13c635 = _0xdd3699; - _0x5b7f43(), + (_0x5b7f43(), _0x16f39e[_0x13c635(0x81)]( _0x228047, 0x9c + -0x1 * 0x23ab + 0x230f * 0x1, -0x1c26 + 0x7bf + -0x6cd * -0x3 - ); + )); } let _0x93f360 = 0x64 * 0x49 + 0x1e1e + -0x3aa2; function _0x5b7f43() { @@ -373,12 +373,12 @@ export default function Page404(): JSX.Element { (-0x2469 + 0x156a * -0x1 + 0x39e2)) + (-0x1 * 0x13f8 + 0x6df + -0x1 * -0xd29); if (_0x3e178a == 0x1 * -0x1a87 + 0x1fdd + -0x555 * 0x1) { - (_0x546fb5 = + ((_0x546fb5 = (_0x227002 * (-0x10d7 + 0x1 * 0x15ad + -0x2 * 0x263)) & (-0x25ca * 0x1 + 0x8 * 0x278 + -0x1 * -0x1219)), (_0x1667c5 = (_0x32116b * (0x4d3 + 0x1c09 * -0x1 + 0x3 * 0x7c2)) & - (-0xf06 * 0x2 + -0x144f * -0x1 + -0x344 * -0x3)); + (-0xf06 * 0x2 + -0x144f * -0x1 + -0x344 * -0x3))); if (_0x5b3085 < -0xa * 0xed + -0xd19 + 0x1 * 0x165b) _0x1667c5 += -0xd48 + 0xf6c + 0xc * -0x2b; } @@ -410,10 +410,10 @@ export default function Page404(): JSX.Element { (-0x2709 + -0x6 * -0x312 + -0x39a * -0x6)), (_0x267dd3 = _0x38c463)); } - (_0x227002 += _0x4b089b), + ((_0x227002 += _0x4b089b), (_0x2aec99 += _0x5b3085), (_0x32116b += _0x1eaaad), - (_0x38c463 += _0x57383c); + (_0x38c463 += _0x57383c)); } } let _0x5cba48 = @@ -430,7 +430,7 @@ export default function Page404(): JSX.Element { let _0xdf8389 = ((_0x13f1b0 & (-0x247a + -0x4 * -0x9c2 + -0x39 * 0x7)) * _0x2062a9 * _0x5c387a) / ((0x1d5 * 0xa + -0x250a + -0x31 * -0x67) * (-0x7 * 0x25f + -0xae7 + 0x1c7f * 0x1)); - (_0x228047[_0x4626de(0x8e)][ + ((_0x228047[_0x4626de(0x8e)][ (_0x132623 + _0x1a573d * _0x124180) * (0x29 * -0xa9 + -0x94 * -0x2b + -0x239 * -0x1) + (0x55d * 0x2 + 0xeed * 0x1 + -0xc7 * 0x21) ] = _0x5cba48), @@ -441,7 +441,7 @@ export default function Page404(): JSX.Element { (_0x228047[_0x4626de(0x8e)][ (_0x132623 + _0x1a573d * _0x124180) * (0x1e2a + -0x21df + -0x1 * -0x3b9) + (0x1e79 + 0x860 * -0x2 + 0x1 * -0xdb7) - ] = _0xdf8389); + ] = _0xdf8389)); } } } diff --git a/src/pages/background/background.ts b/src/pages/background/background.ts index e64d3913..a0615584 100644 --- a/src/pages/background/background.ts +++ b/src/pages/background/background.ts @@ -1,7 +1,7 @@ +import { MessageListener } from '@chrome-extension-toolkit'; import type { BACKGROUND_MESSAGES } from '@shared/messages'; import { UserScheduleStore } from '@shared/storage/UserScheduleStore'; import updateBadgeText from '@shared/util/updateBadgeText'; -import { MessageListener } from 'chrome-extension-toolkit'; import onInstall from './events/onInstall'; import onServiceWorkerAlive from './events/onServiceWorkerAlive'; @@ -9,6 +9,7 @@ import onUpdate from './events/onUpdate'; import browserActionHandler from './handler/browserActionHandler'; import calendarBackgroundHandler from './handler/calendarBackgroundHandler'; import CESHandler from './handler/CESHandler'; +import gitHubStatsHandler from './handler/gitHubStatsHandler'; import tabManagementHandler from './handler/tabManagementHandler'; import userScheduleHandler from './handler/userScheduleHandler'; @@ -52,17 +53,18 @@ const messageListener = new MessageListener({ ...userScheduleHandler, ...CESHandler, ...calendarBackgroundHandler, + ...gitHubStatsHandler, }); messageListener.listen(); -UserScheduleStore.listen('schedules', async schedules => { +UserScheduleStore.subscribe('schedules', async schedules => { const index = await UserScheduleStore.get('activeIndex'); const numCourses = schedules.newValue[index]?.courses?.length; updateBadgeText(numCourses || 0); }); -UserScheduleStore.listen('activeIndex', async ({ newValue }) => { +UserScheduleStore.subscribe('activeIndex', async ({ newValue }) => { const schedules = await UserScheduleStore.get('schedules'); const numCourses = schedules[newValue]?.courses?.length; updateBadgeText(numCourses || 0); diff --git a/src/pages/background/handler/CESHandler.ts b/src/pages/background/handler/CESHandler.ts index 3de383ee..a372ade5 100644 --- a/src/pages/background/handler/CESHandler.ts +++ b/src/pages/background/handler/CESHandler.ts @@ -1,6 +1,6 @@ import openNewTab from '@background/util/openNewTab'; +import type { MessageHandler } from '@chrome-extension-toolkit'; import type CESMessage from '@shared/messages/CESMessage'; -import type { MessageHandler } from 'chrome-extension-toolkit'; const CESFall2023Url = 'https://utexas.bluera.com/utexas/rpvl.aspx?rid=d3db767b-049f-46c5-9a67-29c21c29c580®l=en-US'; diff --git a/src/pages/background/handler/browserActionHandler.ts b/src/pages/background/handler/browserActionHandler.ts index 9572cf1c..dc6fb68f 100644 --- a/src/pages/background/handler/browserActionHandler.ts +++ b/src/pages/background/handler/browserActionHandler.ts @@ -1,5 +1,5 @@ +import type { MessageHandler } from '@chrome-extension-toolkit'; import type BrowserActionMessages from '@shared/messages/BrowserActionMessages'; -import type { MessageHandler } from 'chrome-extension-toolkit'; const browserActionHandler: MessageHandler = { disableBrowserAction({ sender, sendResponse }) { diff --git a/src/pages/background/handler/calendarBackgroundHandler.ts b/src/pages/background/handler/calendarBackgroundHandler.ts index 8e19ccd3..c05315a8 100644 --- a/src/pages/background/handler/calendarBackgroundHandler.ts +++ b/src/pages/background/handler/calendarBackgroundHandler.ts @@ -1,14 +1,14 @@ import type { TabWithId } from '@background/util/openNewTab'; import openNewTab from '@background/util/openNewTab'; +import type { MessageHandler } from '@chrome-extension-toolkit'; import { tabs } from '@shared/messages'; import type { CalendarBackgroundMessages } from '@shared/messages/CalendarMessages'; import { OptionsStore } from '@shared/storage/OptionsStore'; import { CRX_PAGES } from '@shared/types/CRXPages'; -import type { MessageHandler } from 'chrome-extension-toolkit'; const getAllTabInfos = async () => { const openTabs = (await chrome.tabs.query({})).filter((tab): tab is TabWithId => tab.id !== undefined); - const results = await Promise.allSettled(openTabs.map(tab => tabs.getTabInfo(undefined, tab.id))); + const results = await Promise.allSettled(openTabs.map(tab => tabs.getTabInfo({ tabId: tab.id }))); type TabInfo = PromiseFulfilledResult>>; return results @@ -34,7 +34,7 @@ const calendarBackgroundHandler: MessageHandler = { await chrome.tabs.update(tabid, { active: true }); await chrome.windows.update(openCalendarTabInfo.tab.windowId, { focused: true, drawAttention: true }); - if (uniqueId !== undefined) await tabs.openCoursePopup({ uniqueId }, tabid); + if (uniqueId !== undefined) await tabs.openCoursePopup({ uniqueId }, { tabId: tabid }); sendResponse(openCalendarTabInfo.tab); } else { diff --git a/src/pages/background/handler/gitHubStatsHandler.ts b/src/pages/background/handler/gitHubStatsHandler.ts new file mode 100644 index 00000000..42f05844 --- /dev/null +++ b/src/pages/background/handler/gitHubStatsHandler.ts @@ -0,0 +1,31 @@ +import type { MessageHandler } from '@chrome-extension-toolkit'; +import type GitHubStatsMessages from '@shared/messages/GitHubStatsMessages'; +import { GitHubStatsService } from '@views/lib/getGitHubStats'; + +const gitHubStatsService = new GitHubStatsService(); + +/** + * Handler for GitHub stats related messages + */ +const gitHubStatsHandler: MessageHandler = { + async fetchGitHubStats({ data, sendResponse }) { + try { + const includeMergedPRs = data ?? false; + const stats = await gitHubStatsService.fetchGitHubStats({ includeMergedPRs }); + sendResponse(stats); + } catch (error) { + console.error('Error fetching GitHub stats in background:', error); + sendResponse({ + adminGitHubStats: {}, + userGitHubStats: {}, + contributors: [], + names: {}, + dataFetched: new Date(), + lastUpdated: new Date(), + isCached: false, + }); + } + }, +}; + +export default gitHubStatsHandler; diff --git a/src/pages/background/handler/tabManagementHandler.ts b/src/pages/background/handler/tabManagementHandler.ts index fa0d62e4..ba67be91 100644 --- a/src/pages/background/handler/tabManagementHandler.ts +++ b/src/pages/background/handler/tabManagementHandler.ts @@ -1,6 +1,6 @@ +import type { MessageHandler } from '@chrome-extension-toolkit'; import openNewTab from '@pages/background/util/openNewTab'; import type TabManagementMessages from '@shared/messages/TabManagementMessages'; -import type { MessageHandler } from 'chrome-extension-toolkit'; const tabManagementHandler: MessageHandler = { getTabId({ sendResponse, sender }) { diff --git a/src/pages/background/handler/userScheduleHandler.ts b/src/pages/background/handler/userScheduleHandler.ts index 33bcb52a..ec989f5d 100644 --- a/src/pages/background/handler/userScheduleHandler.ts +++ b/src/pages/background/handler/userScheduleHandler.ts @@ -1,3 +1,4 @@ +import type { MessageHandler } from '@chrome-extension-toolkit'; import addCourse from '@pages/background/lib/addCourse'; import clearCourses from '@pages/background/lib/clearCourses'; import createSchedule from '@pages/background/lib/createSchedule'; @@ -9,7 +10,6 @@ import switchSchedule from '@pages/background/lib/switchSchedule'; import type { UserScheduleMessages } from '@shared/messages/UserScheduleMessages'; import { Course } from '@shared/types/Course'; import { validateLoginStatus } from '@shared/util/checkLoginStatus'; -import type { MessageHandler } from 'chrome-extension-toolkit'; const userScheduleHandler: MessageHandler = { addCourse({ data, sendResponse }) { diff --git a/src/pages/background/lib/createSchedule.ts b/src/pages/background/lib/createSchedule.ts index 167e7d60..e6f1fd7b 100644 --- a/src/pages/background/lib/createSchedule.ts +++ b/src/pages/background/lib/createSchedule.ts @@ -1,7 +1,7 @@ +import type { Serialized } from '@chrome-extension-toolkit'; import { UserScheduleStore } from '@shared/storage/UserScheduleStore'; import type { UserSchedule } from '@shared/types/UserSchedule'; import { generateRandomId } from '@shared/util/random'; -import type { Serialized } from 'chrome-extension-toolkit'; /** * Creates a new schedule with the given name diff --git a/src/pages/background/lib/importSchedule.ts b/src/pages/background/lib/importSchedule.ts index a17526dd..0a20c565 100644 --- a/src/pages/background/lib/importSchedule.ts +++ b/src/pages/background/lib/importSchedule.ts @@ -1,6 +1,6 @@ +import type { Serialized } from '@chrome-extension-toolkit'; import { Course } from '@shared/types/Course'; import type { UserSchedule } from '@shared/types/UserSchedule'; -import type { Serialized } from 'chrome-extension-toolkit'; import addCourse from './addCourse'; import createSchedule from './createSchedule'; diff --git a/src/pages/calendar/CalendarMain.tsx b/src/pages/calendar/CalendarMain.tsx index 4fcce1bb..d72eacee 100644 --- a/src/pages/calendar/CalendarMain.tsx +++ b/src/pages/calendar/CalendarMain.tsx @@ -1,3 +1,4 @@ +import { MessageListener } from '@chrome-extension-toolkit'; import type TabInfoMessages from '@shared/messages/TabInfoMessages'; import Calendar from '@views/components/calendar/Calendar'; import DialogProvider from '@views/components/common/DialogProvider/DialogProvider'; @@ -5,7 +6,6 @@ import ExtensionRoot from '@views/components/common/ExtensionRoot/ExtensionRoot' import { MigrationDialog } from '@views/components/common/MigrationDialog'; import { WhatsNewDialog } from '@views/components/common/WhatsNewPopup'; import SentryProvider from '@views/contexts/SentryContext'; -import { MessageListener } from 'chrome-extension-toolkit'; import useKC_DABR_WASM from 'kc-dabr-wasm'; import React, { useEffect } from 'react'; diff --git a/src/shared/messages/GitHubStatsMessages.ts b/src/shared/messages/GitHubStatsMessages.ts new file mode 100644 index 00000000..d3971ade --- /dev/null +++ b/src/shared/messages/GitHubStatsMessages.ts @@ -0,0 +1,12 @@ +import type { GitHubStatsResult } from '@shared/types/GitHubStats'; + +/* eslint-disable jsdoc/require-jsdoc */ + +export default interface GitHubStatsMessages { + /** + * Fetch GitHub statistics for all contributors + * @param includeMergedPRs - Whether to include merged PR counts (optional, default: false) + * @returns GitHub stats including commits, lines added/deleted, and optionally merged PRs + */ + fetchGitHubStats: (includeMergedPRs?: boolean) => GitHubStatsResult; +} diff --git a/src/shared/messages/index.ts b/src/shared/messages/index.ts index 30a3a54e..88714273 100644 --- a/src/shared/messages/index.ts +++ b/src/shared/messages/index.ts @@ -1,8 +1,9 @@ -import { createMessenger } from 'chrome-extension-toolkit'; +import { createMessenger } from '@chrome-extension-toolkit'; import type BrowserActionMessages from './BrowserActionMessages'; import type { CalendarBackgroundMessages, CalendarTabMessages } from './CalendarMessages'; import type CESMessage from './CESMessage'; +import type GitHubStatsMessages from './GitHubStatsMessages'; import type TabInfoMessages from './TabInfoMessages'; import type TabManagementMessages from './TabManagementMessages'; import type { UserScheduleMessages } from './UserScheduleMessages'; @@ -14,7 +15,8 @@ export type BACKGROUND_MESSAGES = BrowserActionMessages & TabManagementMessages & UserScheduleMessages & CESMessage & - CalendarBackgroundMessages; + CalendarBackgroundMessages & + GitHubStatsMessages; /** * This is a type with all the message definitions that can be sent TO specific tabs diff --git a/src/shared/storage/CacheStore.ts b/src/shared/storage/CacheStore.ts index 455dd7c5..f5c127be 100644 --- a/src/shared/storage/CacheStore.ts +++ b/src/shared/storage/CacheStore.ts @@ -1,5 +1,5 @@ +import { createLocalStore } from '@chrome-extension-toolkit'; import type { CachedData } from '@shared/types/CachedData'; -import { createLocalStore, debugStore } from 'chrome-extension-toolkit'; interface ICacheStore { github: Record>; @@ -8,8 +8,8 @@ interface ICacheStore { /** * A store that is used for storing cached data such as GitHub contributors */ -export const CacheStore = createLocalStore({ +export const CacheStore = createLocalStore('CacheStore', { github: {}, }); -debugStore({ cacheStore: CacheStore }); +// debugStore({ cacheStore: CacheStore }); diff --git a/src/shared/storage/DevStore.ts b/src/shared/storage/DevStore.ts index 95a2fb99..575142f9 100644 --- a/src/shared/storage/DevStore.ts +++ b/src/shared/storage/DevStore.ts @@ -1,4 +1,4 @@ -import { createLocalStore, debugStore } from 'chrome-extension-toolkit'; +import { createLocalStore } from '@chrome-extension-toolkit'; /** * A store that is used to store data that is only relevant during development @@ -18,7 +18,7 @@ interface IDevStore { reloadTabId?: number; } -export const DevStore = createLocalStore({ +export const DevStore = createLocalStore('DevStore', { isDeveloper: false, debugTabId: undefined, isTabReloading: true, @@ -27,4 +27,4 @@ export const DevStore = createLocalStore({ reloadTabId: undefined, }); -debugStore({ devStore: DevStore }); +// debugStore({ devStore: DevStore }); diff --git a/src/shared/storage/ExtensionStore.ts b/src/shared/storage/ExtensionStore.ts index 197b52e4..d0d6443b 100644 --- a/src/shared/storage/ExtensionStore.ts +++ b/src/shared/storage/ExtensionStore.ts @@ -1,4 +1,4 @@ -import { createLocalStore, debugStore } from 'chrome-extension-toolkit'; +import { createLocalStore } from '@chrome-extension-toolkit'; /** * A store that is used for storing user options @@ -12,10 +12,10 @@ interface IExtensionStore { lastWhatsNewPopupVersion: number; } -export const ExtensionStore = createLocalStore({ +export const ExtensionStore = createLocalStore('ExtensionStore', { version: chrome.runtime.getManifest().version, lastUpdate: Date.now(), lastWhatsNewPopupVersion: 0, }); -debugStore({ ExtensionStore }); +// debugStore({ ExtensionStore }); diff --git a/src/shared/storage/OptionsStore.ts b/src/shared/storage/OptionsStore.ts index d0a66634..84e1432e 100644 --- a/src/shared/storage/OptionsStore.ts +++ b/src/shared/storage/OptionsStore.ts @@ -1,4 +1,4 @@ -import { createSyncStore, debugStore } from 'chrome-extension-toolkit'; +import { createSyncStore } from '@chrome-extension-toolkit'; /** * A store that is used for storing user options @@ -28,7 +28,7 @@ export interface IOptionsStore { allowMoreSchedules: boolean; } -export const OptionsStore = createSyncStore({ +export const OptionsStore = createSyncStore('OptionsStore', { enableCourseStatusChips: false, enableHighlightConflicts: true, enableScrollToLoad: true, @@ -58,4 +58,4 @@ export const initSettings = async () => // Clothing retailer right -debugStore({ OptionsStore }); +// debugStore({ OptionsStore }); diff --git a/src/shared/storage/UserScheduleStore.ts b/src/shared/storage/UserScheduleStore.ts index 4197f602..9989ecaa 100644 --- a/src/shared/storage/UserScheduleStore.ts +++ b/src/shared/storage/UserScheduleStore.ts @@ -1,5 +1,5 @@ +import { createLocalStore } from '@chrome-extension-toolkit'; import { UserSchedule } from '@shared/types/UserSchedule'; -import { createLocalStore, debugStore } from 'chrome-extension-toolkit'; import { generateRandomId } from '../util/random'; @@ -11,7 +11,7 @@ interface IUserScheduleStore { /** * A store that is used for storing user schedules (and the active schedule) */ -export const UserScheduleStore = createLocalStore({ +export const UserScheduleStore = createLocalStore('UserScheduleStore', { schedules: [ new UserSchedule({ courses: [], @@ -24,4 +24,4 @@ export const UserScheduleStore = createLocalStore({ activeIndex: 0, }); -debugStore({ userScheduleStore: UserScheduleStore }); +// debugStore({ userScheduleStore: UserScheduleStore }); diff --git a/src/shared/types/Course.ts b/src/shared/types/Course.ts index 86d4806c..695e18a4 100644 --- a/src/shared/types/Course.ts +++ b/src/shared/types/Course.ts @@ -1,5 +1,5 @@ +import type { Serialized } from '@chrome-extension-toolkit'; import { getCourseColors } from '@shared/util/colors'; -import type { Serialized } from 'chrome-extension-toolkit'; import type { CourseMeeting } from './CourseMeeting'; import { CourseSchedule } from './CourseSchedule'; diff --git a/src/shared/types/CourseMeeting.ts b/src/shared/types/CourseMeeting.ts index b14c0a22..3d337f08 100644 --- a/src/shared/types/CourseMeeting.ts +++ b/src/shared/types/CourseMeeting.ts @@ -1,4 +1,4 @@ -import type { Serialized } from 'chrome-extension-toolkit'; +import type { Serialized } from '@chrome-extension-toolkit'; /** * a map of the days of the week that a class is taught, and the corresponding abbreviation diff --git a/src/shared/types/CourseSchedule.ts b/src/shared/types/CourseSchedule.ts index 2d713e6d..621b4429 100644 --- a/src/shared/types/CourseSchedule.ts +++ b/src/shared/types/CourseSchedule.ts @@ -1,4 +1,4 @@ -import type { Serialized } from 'chrome-extension-toolkit'; +import type { Serialized } from '@chrome-extension-toolkit'; import type { Day } from './CourseMeeting'; import { CourseMeeting, DAY_MAP } from './CourseMeeting'; diff --git a/src/shared/types/GitHubStats.ts b/src/shared/types/GitHubStats.ts new file mode 100644 index 00000000..bc26463a --- /dev/null +++ b/src/shared/types/GitHubStats.ts @@ -0,0 +1,40 @@ +/* eslint-disable jsdoc/require-jsdoc */ +export type TeamMember = { + name: string; + role: string[]; + githubUsername: string; +}; + +export type GitHubStats = { + commits: number; + linesAdded: number; + linesDeleted: number; + mergedPRs?: number; +}; + +export type GitHubStatsResult = { + adminGitHubStats: Record; + userGitHubStats: Record; + contributors: string[]; + names: Record; + dataFetched: Date; + lastUpdated: Date; + isCached: boolean; +}; + +export type ContributorStats = { + total: number; + weeks: { w: number; a: number; d: number; c: number }[]; + author: { login: string }; +}; + +export type ContributorUser = { + name: string | undefined; +}; + +export type FetchResult = { + data: T; + dataFetched: Date; + lastUpdated: Date; + isCached: boolean; +}; diff --git a/src/shared/types/Instructor.ts b/src/shared/types/Instructor.ts index d9a00dca..cf9c294c 100644 --- a/src/shared/types/Instructor.ts +++ b/src/shared/types/Instructor.ts @@ -1,5 +1,5 @@ +import type { Serialized } from '@chrome-extension-toolkit'; import { capitalize } from '@shared/util/string'; -import type { Serialized } from 'chrome-extension-toolkit'; /** * A type representing an instructor for a course (who teaches it) diff --git a/src/shared/types/UserSchedule.ts b/src/shared/types/UserSchedule.ts index 2fe6534d..0e3ce73c 100644 --- a/src/shared/types/UserSchedule.ts +++ b/src/shared/types/UserSchedule.ts @@ -1,4 +1,4 @@ -import type { Serialized } from 'chrome-extension-toolkit'; +import type { Serialized } from '@chrome-extension-toolkit'; import { generateRandomId } from '../util/random'; import { Course } from './Course'; diff --git a/src/shared/util/colors.ts b/src/shared/util/colors.ts index 9f6279dd..5a2b4823 100644 --- a/src/shared/util/colors.ts +++ b/src/shared/util/colors.ts @@ -1,4 +1,4 @@ -import type { Serialized } from 'chrome-extension-toolkit'; +import type { Serialized } from '@chrome-extension-toolkit'; import { theme } from 'unocss/preset-mini'; import type { HexColor, HSL, Lab, RGB, sRGB } from '../types/Color'; diff --git a/src/stories/components/Dropdown.stories.tsx b/src/stories/components/Dropdown.stories.tsx index e3748f54..b1e317db 100644 --- a/src/stories/components/Dropdown.stories.tsx +++ b/src/stories/components/Dropdown.stories.tsx @@ -1,3 +1,4 @@ +import type { Serialized } from '@chrome-extension-toolkit'; import { UserScheduleStore } from '@shared/storage/UserScheduleStore'; import { UserSchedule } from '@shared/types/UserSchedule'; import { generateRandomId } from '@shared/util/random'; @@ -7,7 +8,6 @@ import ScheduleDropdown from '@views/components/common/ScheduleDropdown'; import ScheduleListItem from '@views/components/common/ScheduleListItem'; import { SortableList } from '@views/components/common/SortableList'; import useSchedules, { getActiveSchedule, switchSchedule } from '@views/hooks/useSchedules'; -import type { Serialized } from 'chrome-extension-toolkit'; import React, { useEffect } from 'react'; import { exampleSchedule } from '../injected/mocked'; diff --git a/src/views/components/PopupMain.tsx b/src/views/components/PopupMain.tsx index 53d8b24f..48a2221b 100644 --- a/src/views/components/PopupMain.tsx +++ b/src/views/components/PopupMain.tsx @@ -37,7 +37,7 @@ export default function PopupMain(): JSX.Element { initAllSettings(); - const l1 = OptionsStore.listen('enableCourseStatusChips', async ({ newValue }) => { + const l1 = OptionsStore.subscribe('enableCourseStatusChips', async ({ newValue }) => { setEnableCourseStatusChips(newValue); // console.log('enableCourseStatusChips', newValue); }); @@ -48,7 +48,7 @@ export default function PopupMain(): JSX.Element { // }); return () => { - OptionsStore.removeListener(l1); + OptionsStore.unsubscribe(l1); // OptionsStore.removeListener(l2); }; }, []); diff --git a/src/views/components/calendar/Calendar.tsx b/src/views/components/calendar/Calendar.tsx index 617eed42..a14b935c 100644 --- a/src/views/components/calendar/Calendar.tsx +++ b/src/views/components/calendar/Calendar.tsx @@ -1,3 +1,4 @@ +import { MessageListener } from '@chrome-extension-toolkit'; import { Sidebar } from '@phosphor-icons/react'; import type { CalendarTabMessages } from '@shared/messages/CalendarMessages'; import { OptionsStore } from '@shared/storage/OptionsStore'; @@ -16,7 +17,6 @@ import { CalendarContext } from '@views/contexts/CalendarContext'; import useCourseFromUrl from '@views/hooks/useCourseFromUrl'; import { useFlattenedCourseSchedule } from '@views/hooks/useFlattenedCourseSchedule'; import useWhatsNewPopUp from '@views/hooks/useWhatsNew'; -import { MessageListener } from 'chrome-extension-toolkit'; import clsx from 'clsx'; import type { ReactNode } from 'react'; import React, { useEffect, useState } from 'react'; diff --git a/src/views/components/calendar/CalendarCourseCell.tsx b/src/views/components/calendar/CalendarCourseCell.tsx index 00654eaa..d84a246b 100644 --- a/src/views/components/calendar/CalendarCourseCell.tsx +++ b/src/views/components/calendar/CalendarCourseCell.tsx @@ -61,13 +61,13 @@ export default function CalendarCourseCell({ useEffect(() => { initSettings().then(({ enableCourseStatusChips }) => setEnableCourseStatusChips(enableCourseStatusChips)); - const l1 = OptionsStore.listen('enableCourseStatusChips', async ({ newValue }) => { + const l1 = OptionsStore.subscribe('enableCourseStatusChips', async ({ newValue }) => { setEnableCourseStatusChips(newValue); // console.log('enableCourseStatusChips', newValue); }); return () => { - OptionsStore.removeListener(l1); + OptionsStore.unsubscribe(l1); }; }, []); diff --git a/src/views/components/calendar/CalendarCourseCellColorPicker/CourseCellColorPicker.tsx b/src/views/components/calendar/CalendarCourseCellColorPicker/CourseCellColorPicker.tsx index 76d77cdd..31544ad4 100644 --- a/src/views/components/calendar/CalendarCourseCellColorPicker/CourseCellColorPicker.tsx +++ b/src/views/components/calendar/CalendarCourseCellColorPicker/CourseCellColorPicker.tsx @@ -124,17 +124,15 @@ export default function CourseCellColorPicker({ defaultColor }: CourseCellColorP <>
- {colorPatchColors - .get(selectedBaseColor) - ?.map(shadeColor => ( - - ))} + {colorPatchColors.get(selectedBaseColor)?.map(shadeColor => ( + + ))}
)} diff --git a/src/views/components/calendar/CalendarHeader/CalendarHeader.tsx b/src/views/components/calendar/CalendarHeader/CalendarHeader.tsx index 78ed0a2f..14d3fd42 100644 --- a/src/views/components/calendar/CalendarHeader/CalendarHeader.tsx +++ b/src/views/components/calendar/CalendarHeader/CalendarHeader.tsx @@ -1,5 +1,5 @@ import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/react'; -import { CalendarDots, Export, FileCode, FilePng, Sidebar } from '@phosphor-icons/react'; +import { CalendarDots, Export, FileCode, FilePng, FileText, Sidebar } from '@phosphor-icons/react'; import styles from '@views/components/calendar/CalendarHeader/CalendarHeader.module.scss'; import { Button } from '@views/components/common/Button'; import DialogProvider from '@views/components/common/DialogProvider/DialogProvider'; @@ -11,7 +11,7 @@ import useSchedules from '@views/hooks/useSchedules'; import clsx from 'clsx'; import React from 'react'; -import { handleExportJson, saveAsCal, saveCalAsPng } from '../utils'; +import { handleExportJson, saveAsCal, saveAsText, saveCalAsPng } from '../utils'; interface CalendarHeaderProps { sidebarOpen?: boolean; @@ -111,6 +111,18 @@ export default function CalendarHeader({ sidebarOpen, onSidebarToggle }: Calenda Save as .json + + + {/* + + + + +
+
+ + Import Schedule + +

Import from a schedule file

+
+ + Import Schedule + +
+ + + +
+
+ + Course Conflict Highlight + +

+ Adds a red strikethrough to courses that have conflicting times. +

+
+ { + setHighlightConflicts(!highlightConflicts); + OptionsStore.set('enableHighlightConflicts', !highlightConflicts); + }} + /> +
+ + + +
+
+ + Load All Courses in Course Schedule + +

+ Loads all courses in the Course Schedule site by scrolling, instead of using next/prev page + buttons. +

+
+ { + setLoadAllCourses(!loadAllCourses); + OptionsStore.set('enableScrollToLoad', !loadAllCourses); + }} + /> +
+ + + +
+
+ + Allow more than 10 schedules + +

+ Allow bypassing the 10-schedule limit. Intended for advisors or staff who need to create + many schedules on behalf of students. +

+
+ { + setIncreaseScheduleLimit(!increaseScheduleLimit); + OptionsStore.set('allowMoreSchedules', !increaseScheduleLimit); + }} + /> +
+ + + +
+
+ + Always Open Calendar in New Tab + +

+ Always opens the calendar view in a new tab when navigating to the calendar page. May + prevent issues where the calendar refuses to open. +

+
+ { + setCalendarNewTab(!calendarNewTab); + OptionsStore.set('alwaysOpenCalendarInNewTab', !calendarNewTab); + }} + /> +
+ + + +
+
+ + Reset All Data + +

Erases all schedules and courses you have.

+
+ +
+ + {DISPLAY_PREVIEWS && ( + + + 01234 MWF 10:00 AM - 11:00 AM UTC 1.234 + + + )} + + +); diff --git a/src/views/components/settings/ContributorCard.tsx b/src/views/components/settings/ContributorCard.tsx new file mode 100644 index 00000000..af7efb61 --- /dev/null +++ b/src/views/components/settings/ContributorCard.tsx @@ -0,0 +1,54 @@ +import Text from '@views/components/common/Text/Text'; +import React from 'react'; + +interface ContributorCardProps { + name: string; + githubUsername: string; + roles: string[]; + stats?: { + commits: number; + linesAdded: number; + linesDeleted: number; + mergedPRs?: number; + }; + showStats: boolean; + includeMergedPRs: boolean; +} + +/** + * GitHub contributor card component + */ +export const ContributorCard: React.FC = ({ + name, + githubUsername, + roles, + stats, + showStats, + includeMergedPRs, +}) => ( +
+ window.open(`https://github.com/${githubUsername}`, '_blank')} + > + {name} + + {roles.map(role => ( +

+ {role} +

+ ))} + {showStats && stats && ( +
+

GitHub Stats (UTRP repo):

+ {includeMergedPRs && stats.mergedPRs !== undefined && ( +

Merged PRs: {stats.mergedPRs}

+ )} +

Commits: {stats.commits}

+

{stats.linesAdded}++

+

{stats.linesDeleted}--

+
+ )} +
+); diff --git a/src/views/components/settings/ContributorCardSkeleton.tsx b/src/views/components/settings/ContributorCardSkeleton.tsx new file mode 100644 index 00000000..a1f79c80 --- /dev/null +++ b/src/views/components/settings/ContributorCardSkeleton.tsx @@ -0,0 +1,14 @@ +import React from 'react'; + +/** + * Lightweight skeleton placeholder for contributor cards while data loads + */ +export const ContributorCardSkeleton: React.FC = () => ( +
+
+
+
+
+); + +export default ContributorCardSkeleton; diff --git a/src/views/components/settings/Settings.tsx b/src/views/components/settings/Settings.tsx index f6218d3b..7fad389a 100644 --- a/src/views/components/settings/Settings.tsx +++ b/src/views/components/settings/Settings.tsx @@ -1,115 +1,72 @@ -// import addCourse from '@pages/background/lib/addCourse'; +// Pages import { addCourseByURL } from '@pages/background/lib/addCourseByURL'; import { deleteAllSchedules } from '@pages/background/lib/deleteSchedule'; import importSchedule from '@pages/background/lib/importSchedule'; -import { CalendarDots, Trash } from '@phosphor-icons/react'; +import { CalendarDots } from '@phosphor-icons/react'; +// Shared import { background } from '@shared/messages'; import { DevStore } from '@shared/storage/DevStore'; import { initSettings, OptionsStore } from '@shared/storage/OptionsStore'; import { CRX_PAGES } from '@shared/types/CRXPages'; -import MIMEType from '@shared/types/MIMEType'; -// import { addCourseByUrl } from '@shared/util/courseUtils'; -// import { getCourseColors } from '@shared/util/colors'; -// import CalendarCourseCell from '@views/components/calendar/CalendarCourseCell'; +import Particles from '@tsparticles/react'; import { Button } from '@views/components/common/Button'; import { usePrompt } from '@views/components/common/DialogProvider/DialogProvider'; +// Views import Divider from '@views/components/common/Divider'; import { LargeLogo } from '@views/components/common/LogoIcon'; -// import PopupCourseBlock from '@views/components/common/PopupCourseBlock'; -import SwitchButton from '@views/components/common/SwitchButton'; import Text from '@views/components/common/Text/Text'; +// Hooks import useChangelog from '@views/hooks/useChangelog'; import useSchedules from '@views/hooks/useSchedules'; -// import { CourseCatalogScraper } from '@views/lib/CourseCatalogScraper'; -// import getCourseTableRows from '@views/lib/getCourseTableRows'; import { GitHubStatsService, LONGHORN_DEVELOPERS_ADMINS, LONGHORN_DEVELOPERS_SWE } from '@views/lib/getGitHubStats'; -// import { SiteSupport } from '@views/lib/getSiteSupport'; -import clsx from 'clsx'; -import React, { useCallback, useEffect, useState } from 'react'; +// Misc +import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; +// Icons import IconoirGitFork from '~icons/iconoir/git-fork'; -import { handleExportJson } from '../calendar/utils'; -// import { ExampleCourse } from 'src/stories/components/ConflictsWithWarning.stories';; -import FileUpload from '../common/FileUpload'; import { useMigrationDialog } from '../common/MigrationDialog'; -// import RefreshIcon from '~icons/material-symbols/refresh'; +import { AdvancedSettings } from './AdvancedSettings'; +import { DEV_MODE_CLICK_TARGET, INCLUDE_MERGED_PRS, STATS_TOGGLE_KEY } from './constants'; +import { ContributorCard } from './ContributorCard'; +import { ContributorCardSkeleton } from './ContributorCardSkeleton'; import DevMode from './DevMode'; -import Preview from './Preview'; +import { useBirthdayCelebration } from './useBirthdayCelebration'; +import { useDevMode } from './useDevMode'; const manifest = chrome.runtime.getManifest(); -const gitHubStatsService = new GitHubStatsService(); -const includeMergedPRs = false; - -const DISPLAY_PREVIEWS = false; -const PREVIEW_SECTION_DIV_CLASSNAME = DISPLAY_PREVIEWS ? 'w-1/2 space-y-4' : 'flex-grow space-y-4'; - /** - * Custom hook for enabling developer mode. - * - * @param targetCount - The target count to activate developer mode. - * @returns A tuple containing a boolean indicating if developer mode is active and a function to increment the count. - */ -const useDevMode = (targetCount: number): [boolean, () => void] => { - const [count, setCount] = useState(0); - const [active, setActive] = useState(false); - const [lastClick, setLastClick] = useState(0); - - const incrementCount = useCallback(() => { - const now = Date.now(); - if (now - lastClick < 500) { - setCount(prevCount => { - const newCount = prevCount + 1; - if (newCount === targetCount) { - setActive(true); - } - return newCount; - }); - } else { - setCount(1); - } - setLastClick(now); - }, [lastClick, targetCount]); - - useEffect(() => { - const timer = setTimeout(() => setCount(0), 3000); - return () => clearTimeout(timer); - }, [count]); - - return [active, incrementCount]; -}; - -/** - * Component for managing user settings and preferences. + * Main Settings Component for managing user settings and preferences. * * @returns The Settings component. */ export default function Settings(): JSX.Element { - const [_enableCourseStatusChips, setEnableCourseStatusChips] = useState(false); - // const [_showTimeLocation, setShowTimeLocation] = useState(false); - const [highlightConflicts, setHighlightConflicts] = useState(false); - const [loadAllCourses, setLoadAllCourses] = useState(false); - const [_enableDataRefreshing, setEnableDataRefreshing] = useState(false); - const [calendarNewTab, setCalendarNewTab] = useState(false); - const [increaseScheduleLimit, setIncreaseScheduleLimit] = useState(false); + const gitHubStatsService = useMemo(() => new GitHubStatsService(), []); - const showMigrationDialog = useMigrationDialog(); - - // Toggle GitHub stats when the user presses the 'S' key - const [showGitHubStats, setShowGitHubStats] = useState(false); + // State + const [highlightConflicts, setHighlightConflicts] = useState(false); + const [loadAllCourses, setLoadAllCourses] = useState(false); + const [calendarNewTab, setCalendarNewTab] = useState(false); + const [increaseScheduleLimit, setIncreaseScheduleLimit] = useState(false); + const [showGitHubStats, setShowGitHubStats] = useState(false); const [githubStats, setGitHubStats] = useState > | null>(null); + const [isDeveloper, setIsDeveloper] = useState(false); const [activeSchedule] = useSchedules(); - // const [isRefreshing, setIsRefreshing] = useState(false); - - const [isDeveloper, setIsDeveloper] = useState(false); - const showDialog = usePrompt(); const handleChangelogOnClick = useChangelog(); + const showMigrationDialog = useMigrationDialog(); + const [devMode, toggleDevMode] = useDevMode(DEV_MODE_CLICK_TARGET); + const { showParticles, particlesInit, particlesOptions, triggerCelebration, isBirthday } = useBirthdayCelebration(); + + // Stable skeleton ids to avoid using array index as keys + const skeletonIdsRef = useRef(Array.from({ length: 8 }, (_, i) => `skeleton-${i}`)); + + // Initialize settings and listeners useEffect(() => { const fetchGitHubStats = async () => { try { @@ -121,19 +78,10 @@ export default function Settings(): JSX.Element { }; const initAndSetSettings = async () => { - const { - enableCourseStatusChips, - enableHighlightConflicts, - enableScrollToLoad, - enableDataRefreshing, - alwaysOpenCalendarInNewTab, - allowMoreSchedules, - } = await initSettings(); - setEnableCourseStatusChips(enableCourseStatusChips); - // setShowTimeLocation(enableTimeAndLocationInPopup); + const { enableHighlightConflicts, enableScrollToLoad, alwaysOpenCalendarInNewTab, allowMoreSchedules } = + await initSettings(); setHighlightConflicts(enableHighlightConflicts); setLoadAllCourses(enableScrollToLoad); - setEnableDataRefreshing(enableDataRefreshing); setCalendarNewTab(alwaysOpenCalendarInNewTab); setIncreaseScheduleLimit(allowMoreSchedules); }; @@ -143,79 +91,50 @@ export default function Settings(): JSX.Element { setIsDeveloper(isDev); }; - const ds_l1 = DevStore.listen('isDeveloper', async ({ newValue }) => { + const handleKeyPress = (event: KeyboardEvent) => { + if (event.key === STATS_TOGGLE_KEY || event.key === STATS_TOGGLE_KEY.toUpperCase()) { + setShowGitHubStats(prev => !prev); + } + }; + + // Listeners + const ds_l1 = DevStore.subscribe('isDeveloper', async ({ newValue }) => { setIsDeveloper(newValue); }); + const l1 = OptionsStore.subscribe('enableHighlightConflicts', async ({ newValue }) => { + setHighlightConflicts(newValue); + }); + + const l2 = OptionsStore.subscribe('enableScrollToLoad', async ({ newValue }) => { + setLoadAllCourses(newValue); + }); + + const l3 = OptionsStore.subscribe('alwaysOpenCalendarInNewTab', async ({ newValue }) => { + setCalendarNewTab(newValue); + }); + + const l4 = OptionsStore.subscribe('allowMoreSchedules', async ({ newValue }) => { + setIncreaseScheduleLimit(newValue); + }); + + window.addEventListener('keydown', handleKeyPress); + initDS(); fetchGitHubStats(); initAndSetSettings(); - const handleKeyPress = (event: KeyboardEvent) => { - if (event.key === 'S' || event.key === 's') { - setShowGitHubStats(prev => !prev); - } - }; - - window.addEventListener('keydown', handleKeyPress); - - // Listen for changes in the settings - const l1 = OptionsStore.listen('enableCourseStatusChips', async ({ newValue }) => { - setEnableCourseStatusChips(newValue); - // console.log('enableCourseStatusChips', newValue); - }); - - // const l2 = OptionsStore.listen('enableTimeAndLocationInPopup', async ({ newValue }) => { - // setShowTimeLocation(newValue); - // // console.log('enableTimeAndLocationInPopup', newValue); - // }); - - const l2 = OptionsStore.listen('enableHighlightConflicts', async ({ newValue }) => { - setHighlightConflicts(newValue); - // console.log('enableHighlightConflicts', newValue); - }); - - const l3 = OptionsStore.listen('enableScrollToLoad', async ({ newValue }) => { - setLoadAllCourses(newValue); - // console.log('enableScrollToLoad', newValue); - }); - - const l4 = OptionsStore.listen('enableDataRefreshing', async ({ newValue }) => { - setEnableDataRefreshing(newValue); - // console.log('enableDataRefreshing', newValue); - }); - - const l5 = OptionsStore.listen('alwaysOpenCalendarInNewTab', async ({ newValue }) => { - setCalendarNewTab(newValue); - // console.log('alwaysOpenCalendarInNewTab', newValue); - }); - - const l6 = OptionsStore.listen('alwaysOpenCalendarInNewTab', async ({ newValue }) => { - setCalendarNewTab(newValue); - // console.log('alwaysOpenCalendarInNewTab', newValue); - }); - - const l7 = OptionsStore.listen('allowMoreSchedules', async ({ newValue }) => { - setIncreaseScheduleLimit(newValue); - }); - - // Remove listeners when the component is unmounted return () => { - OptionsStore.removeListener(l1); - OptionsStore.removeListener(l2); - OptionsStore.removeListener(l3); - OptionsStore.removeListener(l4); - OptionsStore.removeListener(l5); - OptionsStore.removeListener(l6); - OptionsStore.removeListener(l7); - - DevStore.removeListener(ds_l1); - + OptionsStore.unsubscribe(l1); + OptionsStore.unsubscribe(l2); + OptionsStore.unsubscribe(l3); + OptionsStore.unsubscribe(l4); + DevStore.unsubscribe(ds_l1); window.removeEventListener('keydown', handleKeyPress); }; - }, []); + }, [gitHubStatsService]); - const handleEraseAll = () => { + const handleEraseAll = useCallback(() => { showDialog({ title: 'Erase All Course/Schedule Data', description: ( @@ -242,9 +161,9 @@ export default function Settings(): JSX.Element { ), }); - }; + }, [showDialog]); - const handleImportClick = async (event: React.ChangeEvent) => { + const handleImportClick = useCallback(async (event: React.ChangeEvent) => { const file = event.target.files?.[0]; if (!file) return; @@ -257,16 +176,30 @@ export default function Settings(): JSX.Element { console.error('Error importing schedule:', error); alert('Failed to import schedule. Make sure the file is a valid .json format.'); } - }; - // const handleAddCourseByLink = async () => { - // // todo: Use a proper modal instead of a prompt - // const link: string | null = prompt('Enter course link'); - // // Exit if the user cancels the prompt - // if (link === null) return; - // await addCourseByUrl(link, activeSchedule); - // }; + }, []); - const [devMode, toggleDevMode] = useDevMode(10); + const sortedContributors = useMemo(() => { + if (!githubStats) return LONGHORN_DEVELOPERS_SWE; + return [...LONGHORN_DEVELOPERS_SWE].sort( + (a, b) => + (githubStats.userGitHubStats[b.githubUsername]?.commits ?? 0) - + (githubStats.userGitHubStats[a.githubUsername]?.commits ?? 0) + ); + }, [githubStats]); + + const additionalContributors = useMemo(() => { + if (!githubStats) return []; + return Object.keys(githubStats.userGitHubStats) + .filter( + username => + !LONGHORN_DEVELOPERS_ADMINS.some(admin => admin.githubUsername === username) && + !LONGHORN_DEVELOPERS_SWE.some(swe => swe.githubUsername === username) + ) + .sort( + (a, b) => + (githubStats.userGitHubStats[b]?.commits ?? 0) - (githubStats.userGitHubStats[a]?.commits ?? 0) + ); + }, [githubStats]); if (devMode) { DevStore.set('isDeveloper', true); @@ -274,13 +207,32 @@ export default function Settings(): JSX.Element { } return ( -
+
+ {particlesInit && showParticles && ( + + )} +
- - Settings and Credits - +
+ + Settings and Credits + + {isBirthday && ( + + 🎉 Happy Birthday LHD! 🎉 + + )} +
-
- - */} - -
-
- - Export Current Schedule - -

- Backup your active schedule to a portable file -

-
- -
- - - -
-
- - Import Schedule - -

Import from a schedule file

-
- - Import Schedule - -
- - - -
-
- - Course Conflict Highlight - -

- Adds a red strikethrough to courses that have conflicting times. -

-
- { - setHighlightConflicts(!highlightConflicts); - OptionsStore.set('enableHighlightConflicts', !highlightConflicts); - }} - /> -
- - - -
-
- - Load All Courses in Course Schedule - -

- Loads all courses in the Course Schedule site by scrolling, instead of using - next/prev page buttons. -

-
- { - setLoadAllCourses(!loadAllCourses); - OptionsStore.set('enableScrollToLoad', !loadAllCourses); - }} - /> -
- -
-
- - Allow more than 10 schedules - -

- Allow bypassing the 10-schedule limit. Intended for advisors or staff who - need to create many schedules on behalf of students. -

-
- { - setIncreaseScheduleLimit(!increaseScheduleLimit); - OptionsStore.set('allowMoreSchedules', !increaseScheduleLimit); - }} - /> -
- - - -
-
- - Always Open Calendar in New Tab - -

- Always opens the calendar view in a new tab when navigating to the calendar - page. May prevent issues where the calendar refuses to open. -

-
- { - setCalendarNewTab(!calendarNewTab); - OptionsStore.set('alwaysOpenCalendarInNewTab', !calendarNewTab); - }} - /> -
- - - -
-
- - Reset All Data - -

- Erases all schedules and courses you have. -

-
- -
-
- {DISPLAY_PREVIEWS && ( - - - 01234 MWF 10:00 AM - 11:00 AM UTC 1.234 - - - )} -
- + @@ -593,17 +326,21 @@ export default function Settings(): JSX.Element { Open Debug Page
+ + + + + )} - - - - -
@@ -616,144 +353,45 @@ export default function Settings(): JSX.Element {
{LONGHORN_DEVELOPERS_ADMINS.map(admin => ( -
- - window.open(`https://github.com/${admin.githubUsername}`, '_blank') - } - > - {admin.name} - - {admin.role.map(role => ( -

- {role} -

- ))} - {showGitHubStats && githubStats && ( -
-

GitHub Stats (UTRP repo):

- {includeMergedPRs && ( -

- Merged PRS:{' '} - {githubStats.adminGitHubStats[admin.githubUsername]?.mergedPRs} -

- )} -

- Commits: {githubStats.adminGitHubStats[admin.githubUsername]?.commits} -

-

- {githubStats.adminGitHubStats[admin.githubUsername]?.linesAdded} ++ -

-

- {githubStats.adminGitHubStats[admin.githubUsername]?.linesDeleted} -- -

-
- )} -
+ name={admin.name} + githubUsername={admin.githubUsername} + roles={admin.role} + stats={githubStats?.adminGitHubStats[admin.githubUsername]} + showStats={showGitHubStats} + includeMergedPRs={INCLUDE_MERGED_PRS} + /> ))}

UTRP CONTRIBUTORS

- {LONGHORN_DEVELOPERS_SWE.sort( - (a, b) => - (githubStats?.userGitHubStats[b.githubUsername]?.commits ?? 0) - - (githubStats?.userGitHubStats[a.githubUsername]?.commits ?? 0) - ).map(swe => ( -
( + - - window.open(`https://github.com/${swe.githubUsername}`, '_blank') - } - > - {swe.name} - - {swe.role.map(role => ( -

- {role} -

- ))} - {showGitHubStats && githubStats && ( -
-

GitHub Stats (UTRP repo):

- {includeMergedPRs && ( -

- Merged PRS:{' '} - {githubStats.userGitHubStats[swe.githubUsername]?.mergedPRs} -

- )} -

- Commits: {githubStats.userGitHubStats[swe.githubUsername]?.commits} -

-

- {githubStats.userGitHubStats[swe.githubUsername]?.linesAdded} ++ -

-

- {githubStats.userGitHubStats[swe.githubUsername]?.linesDeleted} -- -

-
- )} -
+ name={swe.name} + githubUsername={swe.githubUsername} + roles={swe.role} + stats={githubStats?.userGitHubStats[swe.githubUsername]} + showStats={showGitHubStats} + includeMergedPRs={INCLUDE_MERGED_PRS} + /> ))} - {githubStats && - Object.keys(githubStats.userGitHubStats) - .filter( - username => - !LONGHORN_DEVELOPERS_ADMINS.some( - admin => admin.githubUsername === username - ) && !LONGHORN_DEVELOPERS_SWE.some(swe => swe.githubUsername === username) - ) - .sort( - (a, b) => - (githubStats.userGitHubStats[b]?.commits ?? 0) - - (githubStats.userGitHubStats[a]?.commits ?? 0) - ) - .map(username => ( -
- window.open(`https://github.com/${username}`, '_blank')} - > - {githubStats.names[username]} - -

Contributor

- {showGitHubStats && ( -
-

GitHub Stats (UTRP repo):

- {includeMergedPRs && ( -

- Merged PRs:{' '} - {githubStats.userGitHubStats[username]?.mergedPRs} -

- )} -

- Commits: {githubStats.userGitHubStats[username]?.commits} -

-

- {githubStats.userGitHubStats[username]?.linesAdded} ++ -

-

- {githubStats.userGitHubStats[username]?.linesDeleted} -- -

-
- )} -
- ))} + {githubStats === null + ? skeletonIdsRef.current.slice(0, 8).map(id => ) + : additionalContributors.map(username => ( + + ))}
diff --git a/src/views/components/settings/constants.ts b/src/views/components/settings/constants.ts new file mode 100644 index 00000000..1679009d --- /dev/null +++ b/src/views/components/settings/constants.ts @@ -0,0 +1,13 @@ +export const DISPLAY_PREVIEWS = false; +export const PREVIEW_SECTION_DIV_CLASSNAME = DISPLAY_PREVIEWS ? 'w-1/2 space-y-4' : 'flex-grow space-y-4'; + +export const STATS_TOGGLE_KEY = 's'; +export const INCLUDE_MERGED_PRS = false; +export const DEV_MODE_CLICK_TARGET = 5; +export const DEV_MODE_CLICK_TIMEOUT = 5000; +export const DEV_MODE_CLICK_INTERVAL = 500; + +// LHD Birthday: January 9th, 2024 +export const LHD_BIRTHDAY = { month: 0, day: 9 }; +export const BIRTHDAY_CELEBRATION_DURATION = 5000; +export const BIRTHDAY_CELEBRATION_DEBOUNCE = 2000; diff --git a/src/views/components/settings/useBirthdayCelebration.ts b/src/views/components/settings/useBirthdayCelebration.ts new file mode 100644 index 00000000..01cbf7f5 --- /dev/null +++ b/src/views/components/settings/useBirthdayCelebration.ts @@ -0,0 +1,140 @@ +import type { Engine, ISourceOptions } from '@tsparticles/engine'; +import { initParticlesEngine } from '@tsparticles/react'; +import { loadSlim } from '@tsparticles/slim'; +import { useCallback, useEffect, useMemo, useState } from 'react'; + +import { BIRTHDAY_CELEBRATION_DEBOUNCE, BIRTHDAY_CELEBRATION_DURATION, LHD_BIRTHDAY } from './constants'; + +/** + * Custom hook for birthday celebration particles + */ +export const useBirthdayCelebration = () => { + const [showParticles, setShowParticles] = useState(false); + const [particlesInit, setParticlesInit] = useState(false); + const [lastCelebration, setLastCelebration] = useState(0); + + const isBirthday = useMemo(() => { + const today = new Date(); + return today.getMonth() === LHD_BIRTHDAY.month && today.getDate() === LHD_BIRTHDAY.day; + }, []); + + useEffect(() => { + initParticlesEngine(async (engine: Engine) => { + await loadSlim(engine); + }).then(() => { + setParticlesInit(true); + }); + }, []); + + const triggerCelebration = useCallback(() => { + if (!isBirthday) return; + + const now = Date.now(); + // Debounce: prevent triggering again within BIRTHDAY_CELEBRATION_DEBOUNCE ms + if (now - lastCelebration < BIRTHDAY_CELEBRATION_DEBOUNCE) return; + + setLastCelebration(now); + setShowParticles(true); + setTimeout(() => setShowParticles(false), BIRTHDAY_CELEBRATION_DURATION); + }, [isBirthday, lastCelebration]); + + const particlesOptions: ISourceOptions = useMemo( + () => ({ + fullScreen: { enable: true, zIndex: 1 }, + particles: { + color: { value: ['#BF5700', '#333F48', '#FFFFFF'] }, // UT colors + move: { + direction: 'bottom', + enable: true, + outModes: { + default: 'out', + }, + size: true, + speed: { + min: 1, + max: 3, + }, + }, + number: { + value: 500, + density: { + enable: true, + area: 800, + }, + }, + opacity: { + value: 1, + animation: { + enable: false, + startValue: 'max', + destroy: 'min', + speed: 0.3, + sync: true, + }, + }, + rotate: { + value: { + min: 0, + max: 360, + }, + direction: 'random', + move: true, + animation: { + enable: true, + speed: 60, + }, + }, + tilt: { + direction: 'random', + enable: true, + move: true, + value: { + min: 0, + max: 360, + }, + animation: { + enable: true, + speed: 60, + }, + }, + shape: { + type: ['circle', 'square'], + options: {}, + }, + size: { + value: { + min: 2, + max: 4, + }, + }, + roll: { + darken: { + enable: true, + value: 30, + }, + enlighten: { + enable: true, + value: 30, + }, + enable: true, + speed: { + min: 15, + max: 25, + }, + }, + wobble: { + distance: 30, + enable: true, + move: true, + speed: { + min: -15, + max: 15, + }, + }, + }, + }), + [] + ); + + return { showParticles, particlesInit, particlesOptions, triggerCelebration, isBirthday }; +}; diff --git a/src/views/components/settings/useDevMode.ts b/src/views/components/settings/useDevMode.ts new file mode 100644 index 00000000..a4a0873b --- /dev/null +++ b/src/views/components/settings/useDevMode.ts @@ -0,0 +1,35 @@ +import { useCallback, useEffect, useState } from 'react'; + +import { DEV_MODE_CLICK_INTERVAL, DEV_MODE_CLICK_TIMEOUT } from './constants'; + +/** + * Custom hook for enabling developer mode via rapid clicking + */ +export const useDevMode = (targetCount: number): [boolean, () => void] => { + const [count, setCount] = useState(0); + const [active, setActive] = useState(false); + const [lastClick, setLastClick] = useState(0); + + const incrementCount = useCallback(() => { + const now = Date.now(); + if (now - lastClick < DEV_MODE_CLICK_INTERVAL) { + setCount(prevCount => { + const newCount = prevCount + 1; + if (newCount === targetCount) { + setActive(true); + } + return newCount; + }); + } else { + setCount(1); + } + setLastClick(now); + }, [lastClick, targetCount]); + + useEffect(() => { + const timer = setTimeout(() => setCount(0), DEV_MODE_CLICK_TIMEOUT); + return () => clearTimeout(timer); + }, [count]); + + return [active, incrementCount]; +}; diff --git a/src/views/hooks/useEnforceScheduleLimit.tsx b/src/views/hooks/useEnforceScheduleLimit.tsx index 4409fec6..088e1c33 100644 --- a/src/views/hooks/useEnforceScheduleLimit.tsx +++ b/src/views/hooks/useEnforceScheduleLimit.tsx @@ -33,13 +33,13 @@ export function useEnforceScheduleLimit(): () => boolean { } })(); - const listener = OptionsStore.listen('allowMoreSchedules', async ({ newValue }) => { + const listener = OptionsStore.subscribe('allowMoreSchedules', async ({ newValue }) => { setAllowMoreSchedules(newValue); }); return () => { mounted = false; - OptionsStore.removeListener(listener); + OptionsStore.unsubscribe(listener); }; }, []); diff --git a/src/views/hooks/useSchedules.ts b/src/views/hooks/useSchedules.ts index 08293dcd..39523f35 100644 --- a/src/views/hooks/useSchedules.ts +++ b/src/views/hooks/useSchedules.ts @@ -48,19 +48,19 @@ export default function useSchedules(): [active: UserSchedule, schedules: UserSc } useEffect(() => { - const l1 = UserScheduleStore.listen('schedules', ({ newValue }) => { + const l1 = UserScheduleStore.subscribe('schedules', ({ newValue }) => { schedulesCache = newValue.map(s => new UserSchedule(s)); setSchedules(schedulesCache); }); - const l2 = UserScheduleStore.listen('activeIndex', ({ newValue }) => { + const l2 = UserScheduleStore.subscribe('activeIndex', ({ newValue }) => { activeIndexCache = newValue; setActiveIndex(newValue); }); return () => { - UserScheduleStore.removeListener(l1); - UserScheduleStore.removeListener(l2); + UserScheduleStore.unsubscribe(l1); + UserScheduleStore.unsubscribe(l2); }; }, []); diff --git a/src/views/hooks/useTabMessage.ts b/src/views/hooks/useTabMessage.ts index 035d98c0..58be2cd9 100644 --- a/src/views/hooks/useTabMessage.ts +++ b/src/views/hooks/useTabMessage.ts @@ -1,4 +1,4 @@ +import { createUseMessage } from '@chrome-extension-toolkit'; import type { TAB_MESSAGES } from '@shared/messages'; -import { createUseMessage } from 'chrome-extension-toolkit'; export const useTabMessage = createUseMessage(); diff --git a/src/views/hooks/useVersion.ts b/src/views/hooks/useVersion.ts index c934ef79..f420bc68 100644 --- a/src/views/hooks/useVersion.ts +++ b/src/views/hooks/useVersion.ts @@ -9,12 +9,12 @@ export default function useVersion(): string { const [version, setVersion] = useState(''); useEffect(() => { - const listener = ExtensionStore.listen('version', ({ newValue }) => { + const listener = ExtensionStore.subscribe('version', ({ newValue }) => { setVersion(newValue); }); return () => { - ExtensionStore.removeListener(listener); + ExtensionStore.unsubscribe(listener); }; }, []); diff --git a/src/views/index.tsx b/src/views/index.tsx index 11600aaa..8c954be9 100644 --- a/src/views/index.tsx +++ b/src/views/index.tsx @@ -1,4 +1,4 @@ -import { ContextInvalidated, createShadowDOM, onContextInvalidated } from 'chrome-extension-toolkit'; +import { ContextInvalidated, createShadowDOM, onContextInvalidated } from '@chrome-extension-toolkit'; import React from 'react'; import CourseCatalogMain from './components/CourseCatalogMain'; diff --git a/src/views/lib/getGitHubStats.ts b/src/views/lib/getGitHubStats.ts index 8934a645..0ea9cc1b 100644 --- a/src/views/lib/getGitHubStats.ts +++ b/src/views/lib/getGitHubStats.ts @@ -1,37 +1,13 @@ import { Octokit } from '@octokit/rest'; import { CacheStore } from '@shared/storage/CacheStore'; import type { CachedData } from '@shared/types/CachedData'; - -// Types -type TeamMember = { - name: string; - role: string[]; - githubUsername: string; -}; - -type GitHubStats = { - commits: number; - linesAdded: number; - linesDeleted: number; - mergedPRs?: number; -}; - -type ContributorStats = { - total: number; - weeks: { w: number; a: number; d: number; c: number }[]; - author: { login: string }; -}; - -type ContributorUser = { - name: string | undefined; -}; - -type FetchResult = { - data: T; - dataFetched: Date; - lastUpdated: Date; - isCached: boolean; -}; +import type { + ContributorStats, + ContributorUser, + FetchResult, + GitHubStats, + TeamMember, +} from '@shared/types/GitHubStats'; // Constants const CACHE_TTL = 1 * 60 * 60 * 1000; // 1 hour in milliseconds @@ -91,6 +67,8 @@ export class GitHubStatsService { private octokit: Octokit; private cache: Record>; + private storageLock: Promise = Promise.resolve(); + constructor(githubToken?: string) { this.octokit = githubToken ? new Octokit({ auth: githubToken }) : new Octokit(); this.cache = {} as Record>; @@ -114,16 +92,33 @@ export class GitHubStatsService { return null; } - private async setCachedData(key: string, data: T): Promise { - if (Object.keys(this.cache).length === 0) { - const githubCache = await CacheStore.get('github'); - if (githubCache && typeof githubCache === 'object') { - this.cache = githubCache as Record>; - } - } + private async setCachedData(key: string, data: T, persist = true): Promise { + // get the current lock + const existingLock = this.storageLock; - this.cache[key] = { data, dataFetched: Date.now() }; - await CacheStore.set('github', this.cache); + // update the lock with a new promise + this.storageLock = (async () => { + // wait for current lock to finish + await existingLock; + + // ensure cache is loaded before modifying + if (Object.keys(this.cache).length === 0) { + const githubCache = await CacheStore.get('github'); + if (githubCache && typeof githubCache === 'object') { + this.cache = githubCache as Record>; + } + } + + // update local memory + this.cache[key] = { data, dataFetched: Date.now() }; + + // only write to the physical storage API if persist is true + if (persist) { + await CacheStore.set('github', this.cache); + } + })(); + + return this.storageLock; } private async fetchWithRetry(fetchFn: () => Promise, retries: number = 3, delay: number = 5000): Promise { @@ -182,6 +177,7 @@ export class GitHubStatsService { private async fetchContributorNames(contributors: string[]): Promise> { const names: Record = {}; + await Promise.all( contributors.map(async contributor => { const cacheKey = `contributor_name_${contributor}`; @@ -198,18 +194,17 @@ export class GitHubStatsService { if (data.name) { name = data.name; } - await this.setCachedData(cacheKey, name); + // Pass 'false' to avoid writing to disk for every single name + await this.setCachedData(cacheKey, name, false); } catch (e) { console.error(e); } } - names[contributor] = name; }) ); return names; } - private async fetchMergedPRsCount(username: string): Promise> { const cacheKey = `merged_prs_${username}`; const cachedCount = await this.getCachedData(cacheKey); @@ -233,7 +228,7 @@ export class GitHubStatsService { lastUpdated: new Date(), isCached: false, }; - await this.setCachedData(cacheKey, fetchResult.data); + await this.setCachedData(cacheKey, fetchResult.data, false); return fetchResult; } @@ -300,6 +295,8 @@ export class GitHubStatsService { const names = await this.fetchContributorNames(contributors); + await CacheStore.set('github', this.cache); + return { adminGitHubStats, userGitHubStats, diff --git a/src/views/lib/getSiteSupport.ts b/src/views/lib/getSiteSupport.ts index e5dee841..17e3da9e 100644 --- a/src/views/lib/getSiteSupport.ts +++ b/src/views/lib/getSiteSupport.ts @@ -1,4 +1,4 @@ -import { isExtensionPage, isExtensionPopup } from 'chrome-extension-toolkit'; +import { isExtensionPage, isExtensionPopup } from '@chrome-extension-toolkit'; /** * An enum that represents the different types of pages that we support diff --git a/src/views/lib/openNewTabFromContentScript.ts b/src/views/lib/openNewTabFromContentScript.ts index 782d0ec7..fe4d5760 100644 --- a/src/views/lib/openNewTabFromContentScript.ts +++ b/src/views/lib/openNewTabFromContentScript.ts @@ -1,4 +1,4 @@ -import { createMessenger } from 'chrome-extension-toolkit'; +import { createMessenger } from '@chrome-extension-toolkit'; type MyMessages = { openNewTab: (data: { url: string }) => void; diff --git a/tsconfig.json b/tsconfig.json index d1cdad8c..46be220b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,8 +25,9 @@ "@public/*": ["public/*"], "@shared/*": ["src/shared/*"], "@background/*": ["src/pages/background/*"], - "@views/*": ["src/views/*"] - } + "@views/*": ["src/views/*"], + "@chrome-extension-toolkit": ["src/lib/chrome-extension-toolkit"], + }, }, "include": [ "src", @@ -42,6 +43,6 @@ ".storybook", "unocss.config.ts", "gulpfile.js", - "@types" - ] + "@types", + ], } diff --git a/vite.config.ts b/vite.config.ts index 77e83991..0531285f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -88,6 +88,31 @@ const fixManifestOptionsPage = (): Plugin => ({ }, }); +function getGitInfo() { + // Try environment variables first (for Nix builds) + if (process.env.VITE_GIT_BRANCH && process.env.VITE_GIT_COMMIT) { + return { + gitBranch: process.env.VITE_GIT_BRANCH, + gitCommit: process.env.VITE_GIT_COMMIT, + }; + } + + // Fall back to git commands (for local development) + try { + return { + gitBranch: execSync('git rev-parse --abbrev-ref HEAD').toString().trim(), + gitCommit: execSync('git rev-parse --short HEAD').toString().trim(), + }; + } catch { + return { + gitBranch: 'unknown', + gitCommit: 'unknown', + }; + } +} + +const gitInfo = getGitInfo(); + let config: ResolvedConfig; let server: ViteDevServer; @@ -180,12 +205,14 @@ export default defineConfig({ 'PROD', 'VITE_SENTRY_ENVIRONMENT', 'VITE_BETA_BUILD', + 'VITE_GIT_BRANCH', + 'VITE_GIT_COMMIT', ], includeTimestamp: true, includeBuildTime: true, customMetadata: { - gitBranch: () => execSync('git rev-parse --abbrev-ref HEAD').toString().trim(), - gitCommit: () => execSync('git rev-parse --short HEAD').toString().trim(), + gitBranch: () => gitInfo.gitBranch, + gitCommit: () => gitInfo.gitCommit, nodeVersion: () => process.version, }, }), @@ -199,6 +226,7 @@ export default defineConfig({ '@shared': resolve(root, 'shared'), '@background': resolve(pagesDir, 'background'), '@views': resolve(root, 'views'), + '@chrome-extension-toolkit': resolve(root, 'lib/chrome-extension-toolkit'), }, }, server: { @@ -257,6 +285,7 @@ export default defineConfig({ }, }, test: { + environment: 'jsdom', coverage: { provider: 'v8', },