diff --git a/.changeset/config.json b/.changeset/config.json index 8856c6591c..451f00b003 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -1,5 +1,5 @@ { - "$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json", + "$schema": "https://unpkg.com/@changesets/config@4.0.0/schema.json", "changelog": [ "@changesets/changelog-github", { "repo": "TanStack/table", "disableThanks": true } @@ -11,6 +11,7 @@ "fixed": [], "linked": [["@tanstack/*"]], "ignore": [], + "privatePackages": { "version": false, "tag": false }, "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": { "onlyUpdatePeerDependentsWhenOutOfRange": true } diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 0000000000..21d884dbeb --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,12 @@ +# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json + +reviews: + request_changes_workflow: false + slop_detection: + enabled: true + +knowledge_base: + code_guidelines: + enabled: true + filePatterns: + - 'CONTRIBUTING.md' diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 67bf29eb62..208a1960c3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -6,9 +6,9 @@ body: value: | Thank you for reporting an issue :pray:. - This issue tracker is for reporting reproducible bugs or regression's found in [react-table](https://github.com/tanstack/table) + This issue tracker is for reporting reproducible bugs or regression's found in [TanStack Table](https://github.com/tanstack/table) If you have a question about how to achieve or implement something and are struggling, please post a question - inside of react-table's [Discussions tab](https://github.com/tanstack/table/discussions) instead of filing an issue. + inside of TanStack Table's [Discussions tab](https://github.com/tanstack/table/discussions) instead of filing an issue. Before submitting a new bug/issue, please check the links below to see if there is a solution or question posted there already: - TanStack Table's [Discussions tab](https://github.com/tanstack/table/discussions) diff --git a/.github/pull_request_template b/.github/pull_request_template deleted file mode 100644 index 2c10bc7d7d..0000000000 --- a/.github/pull_request_template +++ /dev/null @@ -1,8 +0,0 @@ -## 🎯 Changes - - - -## ✅ Checklist - -- [ ] I have followed the steps in the [Contributing guide](https://github.com/TanStack/table/blob/main/CONTRIBUTING.md). -- [ ] I have tested this code locally with `pnpm test:pr`. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 3cda47f4f1..cdc242820d 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -5,7 +5,8 @@ ## ✅ Checklist - [ ] I have followed the steps in the [Contributing guide](https://github.com/TanStack/table/blob/main/CONTRIBUTING.md). -- [ ] I have tested this code locally with `pnpm run test:pr`. +- [ ] I have tested code changes locally with `pnpm test` and `pnpm test:e2e`, or these tests do not apply to this pull request. +- [ ] I fully understand the code in this pull request, including any code generated with AI assistance. ## 🚀 Release Impact diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index 4b056ba1d6..8385740eef 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -21,7 +21,7 @@ jobs: fetch-depth: 0 persist-credentials: false - name: Setup Tools - uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 # main + uses: tanstack/config/.github/setup@466151b2d479656b38942cd84a0a3dce29d48de3 # main - name: Fix formatting run: pnpm format - name: Apply fixes diff --git a/.github/workflows/check-skills.yml b/.github/workflows/check-skills.yml index 4adbae05f2..1ef0040369 100644 --- a/.github/workflows/check-skills.yml +++ b/.github/workflows/check-skills.yml @@ -18,7 +18,11 @@ on: - '**/_artifacts/**' - 'scripts/sync-skill-versions.mjs' - 'scripts/typecheck-skill-snippets.mjs' + - 'scripts/skill-snippets-*.tsconfig.json' - 'scripts/validate-skill-content.mjs' + - 'scripts/validate-skill-tree.mjs' + - 'scripts/skill-tree.mjs' + - 'scripts/tests/skill-tree.test.mjs' - 'package.json' - 'pnpm-lock.yaml' - '.github/workflows/check-skills.yml' diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d646d3ce88..d51a741c14 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -32,7 +32,7 @@ jobs: - name: Start Nx Agents run: npx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yaml" - name: Setup Tools - uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 # main + uses: tanstack/config/.github/setup@466151b2d479656b38942cd84a0a3dce29d48de3 # main - name: Get base and head commits for `nx affected` uses: nrwl/nx-set-shas@3e9ad7370203c1e93d109be57f3b72eb0eb511b1 # v4.4.0 with: @@ -51,7 +51,7 @@ jobs: with: persist-credentials: false - name: Setup Tools - uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 # main + uses: tanstack/config/.github/setup@466151b2d479656b38942cd84a0a3dce29d48de3 # main - name: Collect Coverage run: pnpm --filter "@tanstack/table-core" test:coverage - name: Write Coverage Summary @@ -66,7 +66,7 @@ jobs: fetch-depth: 0 persist-credentials: false - name: Setup Tools - uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 # main + uses: tanstack/config/.github/setup@466151b2d479656b38942cd84a0a3dce29d48de3 # main - name: Build Packages run: pnpm run build:all - name: Publish Previews @@ -83,6 +83,6 @@ jobs: with: persist-credentials: false - name: Setup Tools - uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 # main + uses: tanstack/config/.github/setup@466151b2d479656b38942cd84a0a3dce29d48de3 # main - name: Changeset Preview - uses: TanStack/config/.github/changeset-preview@e4b48f16568324f76f467aa4c2aac2f05db632c3 # main + uses: TanStack/config/.github/changeset-preview@466151b2d479656b38942cd84a0a3dce29d48de3 # main diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ba730a7313..11eae5a880 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,7 @@ jobs: - name: Start Nx Agents run: npx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yaml" - name: Setup Tools - uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 # main + uses: tanstack/config/.github/setup@466151b2d479656b38942cd84a0a3dce29d48de3 # main - name: Run Tests run: pnpm run test:ci --parallel=4 - name: Stop Nx Agents @@ -40,19 +40,18 @@ jobs: run: npx nx-cloud stop-all-agents - name: Run Changesets (version or publish) id: changesets - uses: changesets/action@63a615b9cd06ba9a3e6d13796c7fbcb080a60a0b # v1.8.0 + uses: changesets/action@8488615a623b1b9c987934bb89eae8af6a946ac1 # v2.1.1 with: - version: pnpm run changeset:version - publish: pnpm run changeset:publish - commit: 'ci: Version Packages' - title: 'ci: Version Packages' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + version-script: pnpm run changeset:version + publish-script: pnpm run changeset:publish + commit-message: 'ci: Version Packages' + pr-title: 'ci: Version Packages' + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Comment on PRs about release if: steps.changesets.outputs.published == 'true' - uses: TanStack/config/.github/comment-on-release@e4b48f16568324f76f467aa4c2aac2f05db632c3 # main + uses: TanStack/config/.github/comment-on-release@466151b2d479656b38942cd84a0a3dce29d48de3 # main with: - published-packages: ${{ steps.changesets.outputs.publishedPackages }} + published-packages: ${{ steps.changesets.outputs.published-packages }} audit: name: Audit @@ -67,10 +66,18 @@ jobs: fetch-depth: 0 persist-credentials: false - name: Setup Tools - uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 # main + uses: tanstack/config/.github/setup@466151b2d479656b38942cd84a0a3dce29d48de3 # main - name: Build Packages run: pnpm run build:all - name: Install Playwright Browsers run: pnpm run test:e2e:install - name: Run E2E Tests run: pnpm run test:e2e + - name: Upload E2E failure artifacts + if: ${{ failure() }} + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: e2e-failures + path: test-results/ + if-no-files-found: ignore + retention-days: 7 diff --git a/.gitignore b/.gitignore index eee942d0cf..3ac08645da 100644 --- a/.gitignore +++ b/.gitignore @@ -62,6 +62,5 @@ vite.config.ts.timestamp-* .claude/* .cursor/* -Agents.md .agents/* terminalOutput diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000000..abd59989c1 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,42 @@ +# Agent Instructions + +Before analyzing or changing this repository, read and follow +[`CONTRIBUTING.md`](./CONTRIBUTING.md). Its contribution, development, testing, +pull request, and changeset requirements apply to AI-assisted work as well as +human-authored work. + +Keep every change focused on one topic. Understand and verify all generated +code, run the required checks, and provide a concise pull request description +that follows the repository template. + +## Packages that cannot be upgraded yet + +Leave these pins alone during routine dependency bumps. They are either +intentionally deferred or need a manual version choice that `ncu` gets wrong. + +- **TypeScript** — keep `6.0.3`. Do not bump it as part of a general upgrade. +- **Highest semver is not the real latest.** `ncu` can pick a version that + outranks the package's `latest` dist-tag. Check `npm view dist-tags` + and take the newest release on the `latest` line that meets + `minimumReleaseAge`: + - `octane`: `1.0.3` is an unrelated 2015 release. Use the 0.x line. Octane + peers on an exact `@tsrx/oxc` version, so set `@tsrx/oxc` to that exact + version even when `ncu` offers a newer one. + - `@tanstack/react-pacer-devtools` and `@tanstack/solid-pacer-devtools`: + `0.14.0` is an old release that lacks the `pacerDevtoolsPlugin` export the + Form and Router examples use. + - `@tanstack/preact-form`: `1.33.x` sits above `latest` and removes + `createFormHookContexts` and `withForm`, which the Preact Form example uses. +- **Babel 8 peer warnings** — `@rollup/plugin-babel` and some transitive Babel 7 + plugins still declare `@babel/core@^7` peers. The Ember toolchain + (`@nullvoxpopuli/ember-vite`) supports Babel 8, and Ember builds and tests + pass on it, so these `pnpm peers check` warnings are expected. Do not pin + Babel back to 7 because of them. +- **`@tanstack/intent`** — keep `0.4.0`. The 0.5 checker compiles TS and JS + fences without framework TypeScript configuration or surrounding context. It + rejects valid Preact and Lit examples, class-member excerpts, and deliberately + wrong examples. 0.5.6 still reports 64 such errors. 0.5 can skip a fence + with a `no-check` fence property or expect one with `expect-error`, but the + repository's snippet checker only accepts bare `ts`/`tsx` fences after a + `skill-snippet:check` marker. Keep the repository's content and + annotated-snippet checks enabled while this migration is deferred. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3e82ab7dd0..128297d5d5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,7 +11,7 @@ If you have questions about implementation details, help or support, then please ## Reporting Issues -If you have found what you think is a bug, please [file an issue](https://github.com/tanstack/table/issues/new). **PLEASE NOTE:** Issues that are identified as implementation questions or non-issues will be immediately closed and redirected to [Github Discussions](https://github.com/tanstack/table/discussions) +If you have found what you think is a bug, first search the [open and closed issues](https://github.com/TanStack/table/issues?q=is%3Aissue) to make sure it has not already been reported. If you cannot find an existing report, use the [bug report template](https://github.com/TanStack/table/issues/new?template=bug_report.yml). **PLEASE NOTE:** Issues that are identified as implementation questions or non-issues will be immediately closed and redirected to [Github Discussions](https://github.com/tanstack/table/discussions). ## Suggesting new features @@ -25,30 +25,23 @@ Before proceeding with development, ensure you match one of the following criter - Fixing a larger issue that has been previously discussed and agreed-upon by maintainers - Adding a new feature that has been previously discussed and agreed-upon by maintainers +## Pull Request Guidelines + +Every pull request must follow the [TanStack Table pull request template](.github/pull_request_template.md). Complete its description and checklist without removing or bypassing the required sections. + +- Search the [open and closed pull requests](https://github.com/TanStack/table/pulls?q=is%3Apr) before starting work to avoid duplicating an existing contribution. +- Keep each pull request focused on one change or topic. Pull requests that combine unrelated changes will be closed with a request to split them into separately reviewable contributions. +- Write a concise description that clearly explains what changed and why. Follow the sections in the pull request template; a long, unstructured description makes a contribution harder to review. +- You may use AI tools to help generate code, but you remain responsible for understanding, testing, and verifying every submitted change. Do not submit unreviewed, low-quality, or irrelevant generated code. +- Do not mass-submit unrelated or low-quality AI-generated pull requests. We treat that behavior as spam and may close the pull requests, block the contributor, and report the GitHub account. + ## Development Workflow -- Fork this repository, we prefer the `feat-*` branch name style -- Ensure you have `pnpm` installed -- Install the project's dependencies and linkages by running `pnpm install` -- Auto-build and auto-test files as you edit by running `pnpm dev` -- Implement your changes and tests -- To run examples, follow their individual directions. Usually this includes: - - cd into the example directory - - Do NOT install dependencies again or do any linking. Nx already handles this for you. Only run install from the project root. - - Starting the dev server with `pnpm dev` or `pnpm start` (from the example directory) -- To test in your own projects: - - Build/watch for changes with `pnpm build`/`pnpm dev` -- Document your changes in the appropriate documentation website markdown pages -- Create a changeset (changelog entry) for your changes by running `pnpm changeset` -- Commit your work and open a pull request -- Submit the PR for review - -## Adding a new example - -- Clone an existing example into the appropriate `examples` directory -- Name it the example name in kebab-case -- Update the new example's package.json to match the new example name and any other details -- Check dependencies for unused packages -- Install any additional packages to the example that you may need -- Update the docs/config.json file to include the new example in the navigation sidebar -- Commit the example eg. `docs: Add example-name` +- Fork the repository and create a branch for your contribution. We prefer the `feat-*` branch name style. +- Ensure you have `pnpm` installed, then install dependencies from the repository root with `pnpm i`. Do not install dependencies separately inside an example. +- Build the affected packages with `pnpm build`. Use `pnpm build:all` when you need to build every package. +- Implement your change, including relevant tests and documentation. +- To run an example, change into its directory and run `pnpm dev` or `pnpm start`. Examples run on [http://localhost:7777](http://localhost:7777) by default. +- Before opening a pull request with code changes, run both `pnpm test` and `pnpm test:e2e` from the repository root. On the first end-to-end test run, you may need to install the browser with `pnpm test:e2e:install`. Documentation, configuration, and other non-code changes do not require these test suites. +- Every change that affects a published package must include a changeset. Create the changelog entry with `pnpm changeset`; documentation, CI, and development-only changes do not require one. +- Commit your work, open a pull request, complete the required template, and submit it for review. diff --git a/README.md b/README.md index f9ec9e8e28..baedef9a21 100644 --- a/README.md +++ b/README.md @@ -91,18 +91,18 @@ to add skill-loading guidance for your agent (Claude Code, Cursor, Copilot, etc. - - - CodeRabbit + + + CodeRabbit - - - Cloudflare + + + Cloudflare diff --git a/_artifacts/domain_map.yaml b/_artifacts/domain_map.yaml index 213172c21f..88c55cb357 100644 --- a/_artifacts/domain_map.yaml +++ b/_artifacts/domain_map.yaml @@ -1,19 +1,23 @@ library: name: '@tanstack/table' - version: '9.1.2' + version: '9.3.1' repository: 'https://github.com/TanStack/table' homepage: 'https://tanstack.com/table' - description: 'Headless, framework-agnostic data-grid state and row-processing primitives with tree-shakeable v9 features and framework adapters.' + description: 'Headless, framework-agnostic data-grid state and row-processing + primitives with tree-shakeable v9 features and framework adapters.' primary_framework: 'framework-agnostic' monorepo: true package_version_overrides: - '@tanstack/angular-table': '9.2.1' - '@tanstack/angular-table-devtools': '9.2.0' - '@tanstack/preact-table-devtools': '9.2.0' - '@tanstack/react-table-devtools': '9.2.0' - '@tanstack/solid-table-devtools': '9.2.0' - '@tanstack/table-devtools': '9.2.0' - '@tanstack/vue-table-devtools': '9.2.0' + '@tanstack/angular-table': '9.3.2' + '@tanstack/angular-table-devtools': '9.3.2' + '@tanstack/ember-table': '9.3.2' + '@tanstack/match-sorter-utils': '9.2.6' + '@tanstack/preact-table-devtools': '9.3.2' + '@tanstack/react-table-devtools': '9.3.2' + '@tanstack/solid-table-devtools': '9.3.2' + '@tanstack/svelte-table': '9.3.2' + '@tanstack/table-devtools': '9.3.2' + '@tanstack/vue-table-devtools': '9.3.2' meta: generated_by: '@tanstack/intent scaffold domain discovery' @@ -21,75 +25,135 @@ meta: status: reviewed maintainer_review_pending: false phase_4_date: '2026-07-10' - release_voice: 'Treat v9 as stable guidance while recording the exact prerelease package version in skill metadata.' + release_voice: + 'Treat v9 as stable guidance while recording the exact prerelease + package version in skill metadata.' + structure_updated_at: 2026-10-04 + structure_workflow: Existing reviewed domain map and maintainer-approved + progressive-disclosure proposal -> revised skill spec -> skill tree -> + generate-skill Mode A. scope: goals: - - 'Route agents to the correct package and skill, then correct common foot-guns and misconceptions.' - - 'Use docs and examples for intended workflows, and direct exact API discovery to installed package declarations (dist/**/*.d.ts).' - - 'Teach headless rendering, feature registration, row-model ownership, framework state, and v8-to-v9 changes as foundations.' + - 'Route agents to the correct package and skill, then correct common + foot-guns and misconceptions.' + - 'Use docs and examples for intended workflows, and direct exact API + discovery to installed package declarations (dist/**/*.d.ts).' + - 'Teach headless rendering, feature registration, row-model ownership, + framework state, and v8-to-v9 changes as foundations.' included: - 'All 18 public workspace packages.' - - 'All 17 stock Table v9 features, custom features, TypeScript helpers, migrations, framework state, composable table hooks, Query, Virtual, Devtools, and fuzzy ranking.' - - 'Renderer-owned CSS edge cases for sticky positioning, column widths, resizing, layout, and virtualization.' + - 'All 17 stock Table v9 features, custom features, TypeScript helpers, + migrations, framework state, composable table hooks, Query, Virtual, + Devtools, and fuzzy ranking.' + - 'Renderer-owned CSS edge cases for sticky positioning, column widths, + resizing, layout, and virtualization.' excluded: - - 'Component-library-specific integrations such as shadcn, Material UI, Mantine, and equivalent design systems.' + - 'Component-library-specific integrations such as shadcn, Material UI, + Mantine, and equivalent design systems.' - 'Worker row models and experimental worker guidance.' - - 'A dedicated performance skill; performance guidance is placed where the relevant state, row model, or virtualization decision is made.' - - 'A promoted useLegacyTable workflow; it may only be identified as a deprecated temporary stopgap when encountered.' + - 'A dedicated performance skill; performance guidance is placed where the + relevant state, row model, or virtualization decision is made.' + - 'A promoted useLegacyTable workflow; it may only be identified as a + deprecated temporary stopgap when encountered.' validation_contract: - - 'Every generated skill must pass Intent validation and exact package-version synchronization.' - - 'Load-bearing TypeScript examples marked with skill-snippet:check must compile against workspace source and their package tsconfig.' - - 'Content checks reject malformed Markdown tables, invented package imports, feature-gated APIs without their feature, unstable empty-array data getters, and adapter-specific corrected foot-guns.' - - 'Wrong/Correct pairs are reserved for code where Wrong actually misbehaves; valid defaults and supported alternatives must use decision-oriented prose instead.' - - 'Virtual integration patterns must follow the maintained adapter guide/example rather than borrowing another framework adapter API.' - - 'Release automation updates skill and artifact version metadata after package versions are calculated and before packages publish.' + - 'Every generated skill must pass Intent validation and exact package-version + synchronization.' + - 'Load-bearing TypeScript examples marked with skill-snippet:check must + compile against workspace source and their package tsconfig.' + - 'Content checks reject malformed Markdown tables, invented package imports, + feature-gated APIs without their feature, unstable empty-array data getters, + and adapter-specific corrected foot-guns.' + - 'Wrong/Correct pairs are reserved for code where Wrong actually misbehaves; + valid defaults and supported alternatives must use decision-oriented prose + instead.' + - 'Virtual integration patterns must follow the maintained adapter + guide/example rather than borrowing another framework adapter API.' + - 'Release automation updates skill and artifact version metadata after + package versions are calculated and before packages publish.' migration_depth_contract: - exception: 'Migration skills are intentionally comprehensive rather than bare-bones. Each adapter migration skill must stand alone and list every breaking change in its maintained v8-to-v9 guide, even when the same change also appears in the table-core migration skill.' + exception: 'Keep the exhaustive shared audit checklist in the core migration + skill and detailed mappings in its references. Adapter migration skills + explicitly load that checklist and add adapter-only checks and references; + preserve every breaking change without repeating shared inventories.' required_coverage: - - 'Framework package and construction entrypoint changes, including framework-version prerequisites.' - - 'Logical start/end column-pinning rename and the full old-to-new API mapping.' - - 'Prototype-bound row, cell, column, and header methods; object-spread/Object.keys/JSON implications.' - - 'Required tableFeatures registration, stockFeatures audit guidance, all 16 feature imports, and feature-gated state/APIs.' - - 'Core row model removal plus every get*RowModel to create*RowModel feature-slot mapping.' - - 'filterFns, sortFns, aggregationFns, and filterMeta registry-slot migration.' - - 'Adapter state access, selectors/subscriptions, controlled slices, external atoms, precedence, and onStateChange removal.' + - 'Framework package and construction entrypoint changes, including + framework-version prerequisites.' + - 'Logical start/end column-pinning rename and the full old-to-new API + mapping.' + - 'Prototype-bound row, cell, column, and header methods; + object-spread/Object.keys/JSON implications.' + - 'Required tableFeatures registration, stockFeatures audit guidance, all 17 + feature imports, and feature-gated state/APIs.' + - 'Core row model removal plus every get*RowModel to create*RowModel + feature-slot mapping.' + - 'filterFns, sortFns, aggregationFns, and filterMeta registry-slot + migration.' + - 'Adapter state access, selectors/subscriptions, controlled slices, + external atoms, precedence, and onStateChange removal.' - 'createColumnHelper TFeatures and columns() inference changes.' - 'Framework rendering helper/component/directive changes.' - 'tableOptions and createTableHook composability.' - - 'enablePinning split, columnSizing/columnResizing split and state/API renames.' + - 'enablePinning split, columnSizing/columnResizing split and state/API + renames.' - 'Sorting option/API/type/built-in registry renames.' - - 'Removed underscore-prefixed internal APIs and public row API replacements.' - - 'Row-selection some-selected semantic changes and correct indeterminate checks.' - - 'TFeatures generic changes, StockFeatures typing, meta typing, function-registry augmentation replacement, and RowData restriction.' - - 'A final exhaustive migration checklist suitable for auditing an existing codebase.' + - 'Removed underscore-prefixed internal APIs and public row API + replacements.' + - 'Row-selection some-selected semantic changes and correct indeterminate + checks.' + - 'TFeatures generic changes, StockFeatures typing, meta typing, + function-registry augmentation replacement, and RowData restriction.' + - 'A final exhaustive migration checklist suitable for auditing an existing + codebase.' table_state_depth_contract: - exception: 'Framework table-state skills are foundational and intentionally richer than ordinary feature skills. Preserve the guide mental model and adapter-specific reactivity; do not reduce them to a few controlled-state snippets.' + exception: 'Shared ownership and reset rules belong to the core table-state + skill. Adapter table-state skills require it and retain essential reactive + reads and controlled wiring inline, with advanced patterns in references. + State repair does not require getting-started.' required_coverage: - - 'Table as a state coordinator and internal state as the default ownership choice.' - - 'Feature-gated state slices and the relationship between registered features, options, APIs, atoms, and inferred types.' - - 'The distinct baseAtoms, atoms, store, and adapter-selected state surfaces.' - - 'Current snapshot reads versus framework-reactive subscriptions or tracked reads.' - - 'Exactly one owner per slice: internal state, initialState, external atoms, or state plus on[State]Change.' - - 'External-atom precedence, controlled-state synchronization, updater-function handling, and global onStateChange removal.' - - 'Feature methods as the preferred write surface, baseAtoms as a low-level escape hatch, and external-atom writes when externally owned.' - - 'initialState timing, feature reset behavior, reset-to-default arguments, and core reset limitations with external atoms.' + - 'Table as a state coordinator and internal state as the default ownership + choice.' + - 'Feature-gated state slices and the relationship between registered + features, options, APIs, atoms, and inferred types.' + - 'The distinct baseAtoms, atoms, store, and adapter-selected state + surfaces.' + - 'Current snapshot reads versus framework-reactive subscriptions or tracked + reads.' + - 'Exactly one owner per slice: internal state, initialState, external + atoms, or state plus on[State]Change.' + - 'External-atom precedence, controlled-state synchronization, + updater-function handling, and global onStateChange removal.' + - 'Feature methods as the preferred write surface, baseAtoms as a low-level + escape hatch, and external-atom writes when externally owned.' + - 'initialState timing, feature reset behavior, reset-to-default arguments, + and core reset limitations with external atoms.' - 'Feature-specific state types and TableState inference.' - - 'Adapter-specific selectors, subscriptions, compiler/reactivity boundaries, and option synchronization.' + - 'Adapter-specific selectors, subscriptions, compiler/reactivity + boundaries, and option synchronization.' stable_model_input_contract: - rule: 'Every skill example must keep data and columns references stable between meaningful changes. Never recommend inline map/filter/slice chains, makeColumns calls, or fresh fallback arrays in repeatedly evaluated table options.' + rule: + 'Every skill example must keep data and columns references stable between + meaningful changes. Never recommend inline map/filter/slice chains, + makeColumns calls, or fresh fallback arrays in repeatedly evaluated table + options.' accepted_patterns: - 'Module or component-lifetime constants for static data and columns.' - - 'Framework memo/computed primitives for derived data, keyed to the actual derivation inputs.' - - 'Stable state, signal, ref, rune, resource, or Query result references for changing data.' - - 'A module-level stable empty fallback instead of data ?? [] in React-like render paths or reactive option initializers.' + - 'Framework memo/computed primitives for derived data, keyed to the actual + derivation inputs.' + - 'Stable state, signal, ref, rune, resource, or Query result references for + changing data.' + - 'A module-level stable empty fallback instead of data ?? [] in React-like + render paths or reactive option initializers.' custom_feature_depth_contract: - exception: 'The custom-features skill must enumerate the complete extension surface in one authoritative example. Do not pair a minimal density example with separate map/API examples or add a later misconception that merely explains their relationship.' + exception: + 'Keep the custom-feature workflow directly discoverable. Preserve the + complete extension surface and annotated authoritative example in + references/plugin-example.md, linked before implementation.' required_feature_maps: - 'TableState_FeatureMap' - 'TableOptions_FeatureMap' @@ -103,22 +167,32 @@ custom_feature_depth_contract: - 'CachedRowModels_FeatureMap' required_api_installation: - 'assignTableAPIs inside constructTableAPIs for the singleton table.' - - 'assignPrototypeAPIs inside assignColumnPrototype for shared column methods.' + - 'assignPrototypeAPIs inside assignColumnPrototype for shared column + methods.' - 'assignPrototypeAPIs inside assignRowPrototype for shared row methods.' - 'assignPrototypeAPIs inside assignCellPrototype for shared cell methods.' - - 'assignPrototypeAPIs inside assignHeaderPrototype for shared header methods.' - - 'initColumnInstanceData and initRowInstanceData for per-instance mutable data rather than shared methods.' - - 'The table_/column_/row_/cell_/header_ static-name prefixes, self argument difference, optional memoDeps, and absence of per-object assign*APIs utilities.' + - 'assignPrototypeAPIs inside assignHeaderPrototype for shared header + methods.' + - 'initColumnInstanceData and initRowInstanceData for per-instance mutable + data rather than shared methods.' + - 'The table_/column_/row_/cell_/header_ static-name prefixes, self argument + difference, optional memoDeps, and absence of per-object assign*APIs + utilities.' api_discovery_policy: - rule: 'For exact exports, option types, state shapes, and instance APIs, inspect dist declarations (.d.ts) in the installed package before inventing an API or relying on memory.' + rule: + 'For exact exports, option types, state shapes, and instance APIs, inspect + dist declarations (.d.ts) in the installed package before inventing an API + or relying on memory.' adapter_entrypoint: 'node_modules/@tanstack/-table/dist/index.d.ts' core_entrypoint: 'node_modules/@tanstack/table-core/dist/index.d.ts' feature_source: 'node_modules/@tanstack/table-core/dist/features//' ember_entrypoint: 'node_modules/@tanstack/ember-table/declarations/index.d.ts' angular_entrypoint: 'node_modules/@tanstack/angular-table/dist/types/' octane_entrypoint: 'node_modules/@tanstack/octane-table/src/index.d.ts' - fallback: 'If declarations are unavailable, resolve the installed package root and inspect published types; do not open package src/ or substitute v8 / another adapter API.' + fallback: 'If declarations are unavailable, resolve the installed package root + and inspect published types; do not open package src/ or substitute v8 / + another adapter API.' coverage: ignored_packages: @@ -158,1495 +232,2475 @@ coverage: domains: - slug: foundations name: 'Foundations and migration' - description: 'Headless philosophy, feature registration, client/server ownership, TypeScript inference, API discovery, custom features, and v8 migration.' + description: 'Headless philosophy, feature registration, client/server + ownership, TypeScript inference, API discovery, custom features, and v8 + migration.' - slug: feature-plugins name: 'Feature plugins' - description: 'The 17 stock optional features, their prerequisites, state, row-model participation, and UI responsibilities.' + description: 'The 17 stock optional features, their prerequisites, state, + row-model participation, and UI responsibilities.' - slug: framework-adapters name: 'Framework adapters' - description: 'Per-framework setup, reactive table state, v8 migration, reusable createTableHook patterns, and supported Query/Virtual composition.' + description: + 'Per-framework setup, reactive table state, v8 migration, reusable + createTableHook patterns, and supported Query/Virtual composition.' - slug: observability name: 'Devtools' - description: 'Framework-neutral and adapter-specific Devtools registration, keys, production exports, and connection failures.' + description: 'Framework-neutral and adapter-specific Devtools registration, + keys, production exports, and connection failures.' - slug: utilities name: 'Utilities' description: 'Fuzzy ranking and comparison behavior shipped by match-sorter-utils.' tensions: - - name: 'Explicit tree-shaking vs kitchen-sink convenience' - skills: ['core', 'table-features', 'getting-started', 'migrate-v8-to-v9'] - agent_risk: 'Agents reach for stockFeatures or a kitchen-sink example as the default and silently erase the main v9 bundle-size benefit.' - - name: 'Client-side processing vs server-owned processing' + - name: Explicit tree-shaking vs kitchen-sink convenience skills: - [ - 'client-vs-server', - 'column-filtering', - 'global-filtering', - 'grouping', - 'sorting', - 'pagination', - 'with-tanstack-query', - ] - agent_risk: 'Agents enable manual flags but still expect Table row models to transform the data, or mix server and client stages without defining the boundary.' - - name: 'Simple whole-table subscriptions vs fine-grained reactive state' - skills: ['table-state', 'create-table-hook', 'with-tanstack-virtual'] - agent_risk: 'Agents either over-optimize small tables or hide state reads behind stable objects so framework compilers and memoization miss updates.' - - name: 'Reactive options vs stable model inputs' + - core + - table-features + - getting-started + - migrate-v8-to-v9 + agent_risk: Agents reach for stockFeatures or a kitchen-sink example as the + default and silently erase the main v9 bundle-size benefit. + - name: Client-side processing vs server-owned processing skills: - [ - 'core', - 'client-vs-server', - 'getting-started', - 'table-state', - 'with-tanstack-query', - ] - agent_risk: 'Agents derive data with map/filter/slice or recreate columns inside render/options callbacks, invalidating row and column models on unrelated updates or causing adapter render loops.' - - name: 'Headless flexibility vs renderer-owned correctness' + - table-features/references/client-vs-server.md + - table-features/references/column-filtering.md + - table-features/references/global-filtering.md + - table-features/references/grouping.md + - table-features/references/sorting.md + - table-features/references/pagination.md + - getting-started/references/with-tanstack-query.md + agent_risk: Agents enable manual flags but still expect Table row models to + transform the data, or mix server and client stages without defining the + boundary. + - name: Simple whole-table subscriptions vs fine-grained reactive state skills: - [ - 'core', - 'column-pinning', - 'column-sizing', - 'column-resizing', - 'with-tanstack-virtual', - ] - agent_risk: 'Agents expect feature state to supply semantic markup or CSS and blame Table for sticky, width, accessibility, or layout behavior owned by their renderer.' + - table-state + - getting-started/references/create-table-hook.md + - getting-started/references/with-tanstack-virtual.md + agent_risk: + Agents either over-optimize small tables or hide state reads behind + stable objects so framework compilers and memoization miss updates. + - name: Reactive options vs stable model inputs + skills: + - core + - table-features/references/client-vs-server.md + - getting-started + - table-state + - getting-started/references/with-tanstack-query.md + agent_risk: + Agents derive data with map/filter/slice or recreate columns inside + render/options callbacks, invalidating row and column models on unrelated + updates or causing adapter render loops. + - name: Headless flexibility vs renderer-owned correctness + skills: + - core + - table-features/references/column-pinning.md + - table-features/references/column-sizing.md + - table-features/references/column-resizing.md + - getting-started/references/with-tanstack-virtual.md + agent_risk: Agents expect feature state to supply semantic markup or CSS and + blame Table for sticky, width, accessibility, or layout behavior owned by + their renderer. skills: - slug: core package: '@tanstack/table-core' domain: foundations type: core - purpose: 'Establish the headless mental model, core row model, markup ownership, stable inputs, and feature-driven table architecture.' - sources: - [ - 'TanStack/table:docs/overview.md', - 'TanStack/table:docs/guide/tables.md', - 'TanStack/table:docs/guide/data.md', - 'TanStack/table:packages/table-core/src/index.ts', - ] - failure_modes: - - 'Treating Table as a component or design system instead of rendering semantic markup, styles, and accessibility in userland.' - - 'Recreating data or columns on every reactive pass and causing repeated row-model work or render loops.' - - 'Destructuring v9 row, cell, header, or column prototype methods and losing their instance this binding.' - + purpose: + Establish the headless mental model, core row model, markup ownership, + stable inputs, and feature-driven table architecture. + sources: + - TanStack/table:docs/overview.md + - TanStack/table:docs/guide/tables.md + - TanStack/table:docs/guide/data.md + - TanStack/table:packages/table-core/src/index.ts + - TanStack/table:docs/guide/helpers.md + - TanStack/table:docs/guide/column-defs.md + - TanStack/table:docs/guide/table-and-column-meta.md + - TanStack/table:packages/table-core/src/helpers + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:docs/framework/react/guide/migrating.md + - TanStack/table:docs/guide/rows.md + - TanStack/table:packages/table-core/src/core/rows/coreRowsFeature.utils.ts + failure_modes: + - Treating Table as a component or design system instead of rendering + semantic markup, styles, and accessibility in userland. + - Recreating data or columns on every reactive pass and causing repeated + row-model work or render loops. + - Destructuring v9 row, cell, header, or column prototype methods and + losing their instance this binding. + references: + - slug: typescript + purpose: Preserve userland inference with columnHelper, meta helpers, + tableOptions, and feature-derived types instead of manually threading + generics. + sources: + - TanStack/table:docs/guide/helpers.md + - TanStack/table:docs/guide/column-defs.md + - TanStack/table:docs/guide/table-and-column-meta.md + - TanStack/table:packages/table-core/src/helpers + failure_modes: + - Annotating heterogeneous helper-built columns as ColumnDef[] and erasing each accessor value type. + - Manually supplying deep Table feature generics rather than deriving + them from typeof features or letting helpers infer them. + - Using v8 global declaration merging for per-table meta when v9 + tableMeta, columnMeta, filterMeta, and meta helpers can scope the + types. + path: references/typescript.md + replaces: '@tanstack/table-core#typescript' + - slug: api-not-found + purpose: + Diagnose missing exports, options, state, and instance methods before + inventing replacement code. + sources: + - TanStack/table:packages/table-core/src/index.ts + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:docs/framework/react/guide/migrating.md + failure_modes: + - Searching v8 docs or recalling v7 APIs instead of checking the + installed v9 package src and exact package version. + - Assuming an API was removed when its feature was simply omitted from + tableFeatures. + - Using object spread, Object.keys, or JSON serialization to discover + v9 prototype methods and concluding those methods do not exist. + path: references/api-not-found.md + replaces: '@tanstack/table-core#api-not-found' + - path: references/rows.md + purpose: Read for display-order row numbers, row identity, or row cache misuse. + sources: + - TanStack/table:docs/guide/rows.md + - TanStack/table:packages/table-core/src/core/rows/coreRowsFeature.utils.ts + failure_modes: + - Using row.index as the filtered, sorted display index. + - Reading _displayIndexCache directly instead of getDisplayIndex(). + description: + Use TanStack Table v9 core architecture, stable data and columns, + and inferred types. Route setup, missing APIs, row models, state, + features, and framework-specific work. + requires: [] - slug: table-features package: '@tanstack/table-core' domain: foundations type: core - purpose: 'Register only the features, row-model factories, and function registries a table actually uses.' - sources: - [ - 'TanStack/table:docs/guide/row-models.md', - 'TanStack/table:packages/table-core/src/types/TableFeatures.ts', - 'TanStack/table:packages/table-core/src/features/stockFeatures.ts', - 'TanStack/table:packages/table-core/src/core/table/constructTable.ts', - ] - failure_modes: - - 'Calling a feature API without registering its feature, so its state slice and runtime API do not exist.' - - 'Registering a row-model or function-registry slot without its prerequisite feature, or placing prerequisites after dependent slots.' - - 'Defaulting to stockFeatures for new tables and bundling every optional feature instead of preserving v9 tree-shaking.' - - - slug: client-vs-server - package: '@tanstack/table-core' - domain: foundations - type: core - purpose: 'Choose which filtering, grouping, sorting, expanding, and pagination stages Table owns and which a backend owns.' - sources: - [ - 'TanStack/table:docs/guide/row-models.md', - 'TanStack/table:packages/table-core/src/core/row-models/coreRowModelsFeature.utils.ts', - 'TanStack/table:examples/react/with-tanstack-query', - ] - failure_modes: - - 'Assuming manualPagination, manualSorting, manualFiltering, manualGrouping, or manualExpanding performs server work; each flag only bypasses that client row-model stage.' - - 'Passing a full dataset while manual pagination is enabled and expecting Table to slice it, or passing one page while a client row model expects the full dataset.' - - 'Mixing client and server stages without defining their order, producing sorting or filtering that only applies to the currently loaded page.' - - - slug: typescript - package: '@tanstack/table-core' - domain: foundations - type: core - purpose: 'Preserve userland inference with columnHelper, meta helpers, tableOptions, and feature-derived types instead of manually threading generics.' - sources: - [ - 'TanStack/table:docs/guide/helpers.md', - 'TanStack/table:docs/guide/column-defs.md', - 'TanStack/table:docs/guide/table-and-column-meta.md', - 'TanStack/table:packages/table-core/src/helpers', - ] - failure_modes: - - 'Annotating heterogeneous helper-built columns as ColumnDef[] and erasing each accessor value type.' - - 'Manually supplying deep Table feature generics rather than deriving them from typeof features or letting helpers infer them.' - - 'Using v8 global declaration merging for per-table meta when v9 tableMeta, columnMeta, filterMeta, and meta helpers can scope the types.' - - - slug: api-not-found + purpose: Register only the features, row-model factories, and function + registries a table actually uses. + sources: + - TanStack/table:docs/guide/row-models.md + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:packages/table-core/src/features/stockFeatures.ts + - TanStack/table:packages/table-core/src/core/table/constructTable.ts + - TanStack/table:packages/table-core/src/core/row-models/coreRowModelsFeature.utils.ts + - TanStack/table:examples/react/with-tanstack-query + - TanStack/table:docs/framework/react/guide/column-faceting.md + - TanStack/table:packages/table-core/src/features/column-faceting + - TanStack/table:examples/react/filters-faceted + - TanStack/table:docs/framework/react/guide/column-filtering.md + - TanStack/table:packages/table-core/src/features/column-filtering + - TanStack/table:examples/react/filters + - TanStack/table:docs/framework/react/guide/grouping.md + - TanStack/table:packages/table-core/src/features/column-grouping + - TanStack/table:examples/react/grouping + - TanStack/table:docs/framework/react/guide/column-ordering.md + - TanStack/table:packages/table-core/src/features/column-ordering + - TanStack/table:examples/react/column-dnd + - TanStack/table:docs/framework/react/guide/column-pinning.md + - TanStack/table:packages/table-core/src/features/column-pinning + - TanStack/table:examples/react/column-pinning-sticky + - TanStack/table:docs/framework/react/guide/column-resizing.md + - TanStack/table:packages/table-core/src/features/column-resizing + - TanStack/table:examples/react/column-resizing-performant + - TanStack/table:docs/framework/react/guide/column-sizing.md + - TanStack/table:packages/table-core/src/features/column-sizing + - TanStack/table:examples/react/column-sizing + - TanStack/table:docs/framework/react/guide/column-visibility.md + - TanStack/table:packages/table-core/src/features/column-visibility + - TanStack/table:examples/react/column-visibility + - TanStack/table:docs/framework/react/guide/global-filtering.md + - TanStack/table:packages/table-core/src/features/global-filtering + - TanStack/table:docs/framework/react/guide/expanding.md + - TanStack/table:packages/table-core/src/features/row-expanding + - TanStack/table:examples/react/expanding + - TanStack/table:docs/framework/react/guide/pagination.md + - TanStack/table:packages/table-core/src/features/row-pagination + - TanStack/table:examples/react/pagination + - TanStack/table:docs/framework/react/guide/row-pinning.md + - TanStack/table:packages/table-core/src/features/row-pinning + - TanStack/table:examples/react/row-pinning + - TanStack/table:docs/framework/react/guide/cell-selection.md + - TanStack/table:packages/table-core/src/features/cell-selection + - TanStack/table:examples/react/cell-selection + - TanStack/table:docs/framework/react/guide/cell-spanning.md + - TanStack/table:packages/table-core/src/features/cell-spanning + - TanStack/table:examples/react/cell-spanning + - TanStack/table:docs/framework/react/guide/row-selection.md + - TanStack/table:packages/table-core/src/features/row-selection + - TanStack/table:examples/react/row-selection + - TanStack/table:docs/framework/react/guide/sorting.md + - TanStack/table:packages/table-core/src/features/row-sorting + - TanStack/table:examples/react/sorting + - TanStack/table:docs/framework/react/guide/aggregation.md + - TanStack/table:packages/table-core/src/features/row-aggregation + - TanStack/table:examples/react/aggregation + - TanStack/table:examples/react/grouped-aggregation + failure_modes: + - Calling a feature API without registering its feature, so its state + slice and runtime API do not exist. + - Registering a row-model or function-registry slot without its + prerequisite feature, or placing prerequisites after dependent slots. + - Defaulting to stockFeatures for new tables and bundling every optional + feature instead of preserving v9 tree-shaking. + references: + - slug: client-vs-server + purpose: + Choose which filtering, grouping, sorting, expanding, and pagination + stages Table owns and which a backend owns. + sources: + - TanStack/table:docs/guide/row-models.md + - TanStack/table:packages/table-core/src/core/row-models/coreRowModelsFeature.utils.ts + - TanStack/table:examples/react/with-tanstack-query + failure_modes: + - Assuming manualPagination, manualSorting, manualFiltering, + manualGrouping, or manualExpanding performs server work; each flag + only bypasses that client row-model stage. + - Passing a full dataset while manual pagination is enabled and + expecting Table to slice it, or passing one page while a client row + model expects the full dataset. + - Mixing client and server stages without defining their order, + producing sorting or filtering that only applies to the currently + loaded page. + path: references/client-vs-server.md + replaces: '@tanstack/table-core#client-vs-server' + - slug: column-faceting + purpose: + Derive filter option counts and numeric ranges from the correct faceted + row model. + sources: + - TanStack/table:docs/framework/react/guide/column-faceting.md + - TanStack/table:packages/table-core/src/features/column-faceting + - TanStack/table:examples/react/filters-faceted + failure_modes: + - Registering columnFacetingFeature but omitting the facetedRowModel, + facetedUniqueValues, or facetedMinMaxValues slot needed by the API + being called. + - Expecting a column facet to include that column own active filter; + the faceted row model intentionally applies the other filters and + excludes its own. + - Computing large server-owned facet sets from the currently loaded + client page and presenting incomplete counts as global results. + path: references/column-faceting.md + replaces: '@tanstack/table-core#column-faceting' + - slug: column-filtering + purpose: + Configure column filters, filter functions, metadata, nested-row + direction, and client/manual ownership. + sources: + - TanStack/table:docs/framework/react/guide/column-filtering.md + - TanStack/table:packages/table-core/src/features/column-filtering + - TanStack/table:examples/react/filters + failure_modes: + - Setting manualFiltering and still expecting createFilteredRowModel + to transform data; manual mode returns the pre-filtered model. + - Using accessor values that are objects or renderer output with + built-in filter functions that expect comparable primitive values. + - Providing controlled columnFilters plus onColumnFiltersChange + without applying both value and updater-function forms to the + external source. + path: references/column-filtering.md + replaces: '@tanstack/table-core#column-filtering' + - slug: grouping + purpose: + Group rows, aggregate cells, and reason about grouped rows in expansion + and pagination. + sources: + - TanStack/table:docs/framework/react/guide/grouping.md + - TanStack/table:packages/table-core/src/features/column-grouping + - TanStack/table:examples/react/grouping + failure_modes: + - Registering groupedRowModel without columnGroupingFeature, + registering aggregationFns without rowAggregationFeature, or + expecting grouping state alone to process rows. + - Assuming pageSize counts only leaf data rows; group headers are rows + in the model and affect built-in pagination. + - Rendering every grouped cell as a normal value instead of handling + grouped, placeholder, and aggregated cell states. + path: references/grouping.md + replaces: '@tanstack/table-core#grouping' + - slug: column-ordering + purpose: + Control leaf-column order while respecting pinning, visibility, and + grouped-column precedence. + sources: + - TanStack/table:docs/framework/react/guide/column-ordering.md + - TanStack/table:packages/table-core/src/features/column-ordering + - TanStack/table:examples/react/column-dnd + failure_modes: + - Treating columnOrder as the final rendered order while pinning + regions and groupedColumnMode also reorder columns. + - Using headers, labels, or array indexes as drag identifiers instead + of stable leaf column IDs. + - Mutating the columnOrder array in place so the state owner does not + observe a new value. + path: references/column-ordering.md + replaces: '@tanstack/table-core#column-ordering' + - slug: column-pinning + purpose: + Partition columns into logical start, center, and end regions and + implement sticky layout correctly. + sources: + - TanStack/table:docs/framework/react/guide/column-pinning.md + - TanStack/table:packages/table-core/src/features/column-pinning + - TanStack/table:examples/react/column-pinning-sticky + failure_modes: + - Using v8 or early-beta left/right state and APIs instead of v9 + logical start/end names, especially in RTL layouts. + - 'Expecting pinning state to apply position: sticky, offsets, + z-index, backgrounds, or overflow CSS automatically.' + - Allowing rendered widths to diverge from column.getSize, producing + gaps or overlaps between adjacent pinned columns. + path: references/column-pinning.md + replaces: '@tanstack/table-core#column-pinning' + - slug: column-resizing + purpose: + Wire resize gestures and resize state onto the numeric sizing model + without avoidable render cost. + sources: + - TanStack/table:docs/framework/react/guide/column-resizing.md + - TanStack/table:packages/table-core/src/features/column-resizing + - TanStack/table:examples/react/column-resizing-performant + failure_modes: + - Registering columnResizingFeature without its columnSizingFeature + prerequisite. + - Displaying a resize handle without attaching header.getResizeHandler + to mouse and touch start events. + - Reading getSize repeatedly in every cell during onChange resizing + instead of caching sizes or using CSS variables for large tables. + path: references/column-resizing.md + replaces: '@tanstack/table-core#column-resizing' + - slug: column-sizing + purpose: Use numeric min, max, and current sizes as state inputs to a + renderer-owned CSS layout. + sources: + - TanStack/table:docs/framework/react/guide/column-sizing.md + - TanStack/table:packages/table-core/src/features/column-sizing + - TanStack/table:examples/react/column-sizing + failure_modes: + - Expecting the numeric sizing state to set DOM widths without + applying it to th/td descendants, grid tracks, or flex styles. + - Forcing auto or percentage strings through a number API instead of + choosing and implementing an appropriate CSS layout strategy. + - Forgetting the default size and rendered content can disagree, which + also corrupts pinning offsets and total-size calculations. + path: references/column-sizing.md + replaces: '@tanstack/table-core#column-sizing' + - slug: column-visibility + purpose: + Hide leaf columns while rendering only visibility-aware header, column, + and cell collections. + sources: + - TanStack/table:docs/framework/react/guide/column-visibility.md + - TanStack/table:packages/table-core/src/features/column-visibility + - TanStack/table:examples/react/column-visibility + failure_modes: + - Updating columnVisibility but rendering getAllLeafColumns or + row.getAllCells, so hidden columns remain in the DOM. + - Treating absent map entries as hidden; only an explicit false hides + a column. + - Expecting enableHiding to hide a column when it only controls + whether the user or API may hide it. + path: references/column-visibility.md + replaces: '@tanstack/table-core#column-visibility' + - slug: global-filtering + purpose: Apply one filter across eligible columns with explicit column + eligibility and client/manual ownership. + sources: + - TanStack/table:docs/framework/react/guide/global-filtering.md + - TanStack/table:packages/table-core/src/features/global-filtering + - TanStack/table:examples/react/filters + failure_modes: + - Registering globalFilteringFeature without columnFilteringFeature + and a filtered row-model stage when client processing is expected. + - Assuming every column participates; the default eligibility checks + the first core row value and only accepts strings or numbers. + - Using manualFiltering while updating globalFilter state but never + sending that value to the server query. + path: references/global-filtering.md + replaces: '@tanstack/table-core#global-filtering' + - slug: expanding + purpose: + Expand hierarchical subrows or custom detail panels and place expansion + correctly relative to pagination. + sources: + - TanStack/table:docs/framework/react/guide/expanding.md + - TanStack/table:packages/table-core/src/features/row-expanding + - TanStack/table:examples/react/expanding + failure_modes: + - Expecting nested data to expand without getSubRows, or expecting a + custom detail panel without getRowCanExpand and renderer markup. + - Updating expanded state but never rendering subrows or the custom + expanded UI because Table is headless. + - Assuming paginateExpandedRows changes grouping or flattens visual + descendants; it only controls the expanded-row pagination stage. + path: references/expanding.md + replaces: '@tanstack/table-core#expanding' + - slug: pagination + purpose: + Configure client slicing or manual pages, counts, navigation limits, + and automatic page-index resets. + sources: + - TanStack/table:docs/framework/react/guide/pagination.md + - TanStack/table:packages/table-core/src/features/row-pagination + - TanStack/table:examples/react/pagination + failure_modes: + - Enabling manualPagination and passing all rows while expecting Table + to slice them; manual data must already represent the intended page. + - Omitting rowCount or pageCount for server pagination and then + trusting next-page or last-page availability. + - Misdiagnosing pageIndex jumping to zero as failed controlled state + when autoResetPageIndex is reacting to client-side data or row-model + changes. + path: references/pagination.md + replaces: '@tanstack/table-core#pagination' + - slug: row-pinning + purpose: + Separate top, center, and bottom rows with stable IDs and explicit + rendering/sticky behavior. + sources: + - TanStack/table:docs/framework/react/guide/row-pinning.md + - TanStack/table:packages/table-core/src/features/row-pinning + - TanStack/table:examples/react/row-pinning + failure_modes: + - Using index-derived row IDs for persistent pinning while sorting, + filtering, pagination, or data insertion changes indexes. + - Expecting row pinning to add sticky CSS or render top/center/bottom + collections in the correct order automatically. + - Ignoring keepPinnedRows, so pinned rows remain visible outside the + center row model when the desired product behavior was to filter or + paginate them away. + path: references/row-pinning.md + replaces: '@tanstack/table-core#row-pinning' + - slug: cell-selection + purpose: Maintain spreadsheet-style rectangular selections as ordered + include/exclude operations anchored to row and column ids, resolving + them into disjoint positive regions across sorting, filtering, + pagination, and column layout changes. + sources: + - TanStack/table:docs/framework/react/guide/cell-selection.md + - TanStack/table:packages/table-core/src/features/cell-selection + - TanStack/table:examples/react/cell-selection + failure_modes: + - Expecting cellSelection to be a per-cell map or a list of final + positive regions; it is an ordered log of two-corner include/exclude + operations, and derived bounds may split one stored range into + several regions. + - Reordering, deduplicating, or serializing only the corners of + controlled cellSelection state and thereby changing or losing + subtraction semantics. + - Using additive when the intended operation is explicit subtraction; + selectCellRange mode is replace, include, or exclude, while additive + is only a deprecated include alias. + - Assuming Ctrl/Cmd always adds a range; a modified interaction + excludes when it starts on a selected cell and includes when it + starts on an unselected cell. + - Binding only the mousedown handler and expecting drag selection, or + reimplementing mouseup even though the start handler owns its own + document listener. + - Drawing the selection outline with borders on a border-collapse + table, which changes row heights as cells become selected. + - Re-rendering every cell on each drag update instead of subscribing + per row to table.atoms.cellSelection. + path: references/cell-selection.md + replaces: '@tanstack/table-core#cell-selection' + - slug: cell-spanning + purpose: + Merge adjacent body cells into row- and column-spanning cells derived + from the rendered row model, with covered cells reporting a span of 0 + that renderers must skip. + sources: + - TanStack/table:docs/framework/react/guide/cell-spanning.md + - TanStack/table:packages/table-core/src/features/cell-spanning + - TanStack/table:examples/react/cell-spanning + failure_modes: + - Rendering a covered cell with rowSpan={0} instead of skipping it; + HTML rowspan="0" means span to the end of the row group, so the cell + merges down the entire tbody. + - Expecting spanning to sort or group rows; it merges adjacent equal + values only, so unsorted data renders no merges at all. + - Precomputing spans from the source data array, which survives + sorting, filtering, and page changes and produces ragged rows. + - Assuming a run continues across a page or pinned-section boundary; + runs are clipped to the rendered rows of each section. + - Pre-expanding stored selection corners to cover merges; selection + bounds already expand at derivation time when both features are + registered, and pre-expanded corners go stale when sorting or paging + changes the merges. + path: references/cell-spanning.md + replaces: '@tanstack/table-core#cell-spanning' + - slug: row-selection + purpose: + Maintain selection IDs across current, filtered, grouped, and manually + paginated data. + sources: + - TanStack/table:docs/framework/react/guide/row-selection.md + - TanStack/table:packages/table-core/src/features/row-selection + - TanStack/table:examples/react/row-selection + failure_modes: + - Assuming selection mutates application data or is automatically + deleted when rows disappear; rowSelection is independent ID state. + - Using default index IDs for server pagination or mutable data + instead of a stable getRowId. + - Treating getSelectedRowModel as a database-wide selection lookup + under manual pagination even though only loaded rows can appear in a + row model. + path: references/row-selection.md + replaces: '@tanstack/table-core#row-selection' + - slug: sorting + purpose: Configure single/multi sorting, comparison functions, undefined + placement, removal cycles, and client/manual ownership. + sources: + - TanStack/table:docs/framework/react/guide/sorting.md + - TanStack/table:packages/table-core/src/features/row-sorting + - TanStack/table:examples/react/sorting + failure_modes: + - Setting manualSorting and expecting createSortedRowModel to reorder + rows; manual mode trusts incoming data. + - Writing a custom sortFn that applies ascending/descending direction + itself even though Table reverses the comparator result for + descending order. + - Assuming undefined values, multi-sort gestures, and sort-removal + cycles match product expectations without configuring sortUndefined + and multi-sort options. + path: references/sorting.md + replaces: '@tanstack/table-core#sorting' + - slug: aggregation + path: references/aggregation.md + replaces: '@tanstack/table-core#aggregation' + purpose: + Aggregate columns independently of grouping, with depth-selected row + scopes, multiple keyed aggregations, custom context definitions, and + manual values. + sources: + - TanStack/table:docs/framework/react/guide/aggregation.md + - TanStack/table:packages/table-core/src/features/row-aggregation + - TanStack/table:examples/react/aggregation + - TanStack/table:examples/react/grouped-aggregation + failure_modes: + - Adding grouping solely to compute a grand total instead of using + rowAggregationFeature. + - Passing a nonexistent scope option alongside rows; the public + options contain rows and maxDepth. + - Using the legacy callable aggregation signature instead of + constructAggregationFn and the aggregate context. + - Registering aggregationFns without rowAggregationFeature or assuming + grouping state alone computes aggregates. + description: 'Add or debug Table v9 features: registration, row-model slots, + prerequisites, sorting, filtering, pagination, selection, spanning, and + column layout. Read only task-relevant feature references.' + requires: + - core + - slug: table-state package: '@tanstack/table-core' domain: foundations type: core - purpose: 'Diagnose missing exports, options, state, and instance methods before inventing replacement code.' - sources: - [ - 'TanStack/table:packages/table-core/src/index.ts', - 'TanStack/table:packages/table-core/src/types/TableFeatures.ts', - 'TanStack/table:docs/framework/react/guide/migrating.md', - ] - failure_modes: - - 'Searching v8 docs or recalling v7 APIs instead of checking the installed v9 package src and exact package version.' - - 'Assuming an API was removed when its feature was simply omitted from tableFeatures.' - - 'Using object spread, Object.keys, or JSON serialization to discover v9 prototype methods and concluding those methods do not exist.' - + purpose: Choose shared Table v9 state ownership, initialization, update and + reset semantics; route reactive reads to the installed framework adapter. + sources: + - TanStack/table:docs/framework/react/guide/table-state.md + - TanStack/table:packages/table-core/src/core/table/coreTablesFeature.types.ts + - TanStack/table:packages/table-core/src/core/table/coreTablesFeature.utils.ts + - TanStack/table:packages/table-core/src/core/reactivity/coreReactivityFeature.utils.ts + failure_modes: + - Assuming an unregistered feature has a state slice. + - Confusing writable baseAtoms, readonly resolved atoms, the flat store, + and adapter-selected state. + - Supplying a controlled callback without the current controlled value, or + discarding updater functions. + - Assigning multiple owners to one slice and relying on atom/state + precedence. + - Treating snapshots as framework subscriptions. + - Expecting changed initialState or a core table.reset() to reset + externally owned atoms. + description: + Choose Table v9 state ownership, atoms, initialization, updates, + and resets. Load for controlled slices or state coordination; use the + adapter state skill for reactive reads. + requires: + - core - slug: custom-features package: '@tanstack/table-core' domain: foundations type: core - purpose: 'Extend Table through every v9 FeatureMap and table/column/row/cell/header API lifecycle surface only when built-in options, meta, and APIs are insufficient.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/custom-features.md', - 'TanStack/table:packages/table-core/src/types', - 'TanStack/table:packages/table-core/src/types/TableFeatures.ts', - 'TanStack/table:packages/table-core/src/utils.ts', - 'TanStack/table:packages/table-core/src/features', - 'TanStack/table:examples/react/custom-plugin', - ] - failure_modes: - - 'Building a custom feature for behavior already covered by column meta, table meta, or a built-in feature API.' - - 'Adding types without registering matching initial state, default options, state updaters, and prototype/table APIs in the feature lifecycle.' - - 'Mutating table instances ad hoc instead of registering a stable feature in tableFeatures, losing type inference and composition.' - - 'Assuming the density example exhausts the extension surface and overlooking column-def, column, row, cell, header, or advanced row-model FeatureMaps.' - - 'Looking for nonexistent assignColumnAPIs/assignRowAPIs helpers instead of using assignPrototypeAPIs inside the matching TableFeature prototype hook.' - + purpose: Extend Table through every v9 FeatureMap and + table/column/row/cell/header API lifecycle surface only when built-in + options, meta, and APIs are insufficient. + sources: + - TanStack/table:docs/framework/react/guide/custom-features.md + - TanStack/table:packages/table-core/src/types + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:packages/table-core/src/utils.ts + - TanStack/table:packages/table-core/src/features + - TanStack/table:examples/react/custom-plugin + failure_modes: + - Building a custom feature for behavior already covered by column meta, + table meta, or a built-in feature API. + - Adding types without registering matching initial state, default + options, state updaters, and prototype/table APIs in the feature + lifecycle. + - Mutating table instances ad hoc instead of registering a stable feature + in tableFeatures, losing type inference and composition. + - Assuming the density example exhausts the extension surface and + overlooking column-def, column, row, cell, header, or advanced row-model + FeatureMaps. + - Looking for nonexistent assignColumnAPIs/assignRowAPIs helpers instead + of using assignPrototypeAPIs inside the matching TableFeature prototype + hook. + references: + - path: references/plugin-example.md + purpose: Read when implementing a custom plugin for the complete checked + example, FeatureMaps, and lifecycle wiring. + sources: + - TanStack/table:docs/framework/react/guide/custom-features.md + - TanStack/table:packages/table-core/src/types + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:packages/table-core/src/utils.ts + - TanStack/table:packages/table-core/src/features + - TanStack/table:examples/react/custom-plugin + failure_modes: + - Building a custom feature for behavior already covered by column + meta, table meta, or a built-in feature API. + - Adding types without registering matching initial state, default + options, state updaters, and prototype/table APIs in the feature + lifecycle. + - Mutating table instances ad hoc instead of registering a stable + feature in tableFeatures, losing type inference and composition. + - Assuming the density example exhausts the extension surface and + overlooking column-def, column, row, cell, header, or advanced + row-model FeatureMaps. + - Looking for nonexistent assignColumnAPIs/assignRowAPIs helpers + instead of using assignPrototypeAPIs inside the matching + TableFeature prototype hook. + description: Implement a Table v9 plugin when built-ins and typed meta are + insufficient. Covers FeatureMaps, runtime lifecycle hooks, prototypes, and + a complete checked example. + requires: + - core + - table-features - slug: migrate-v8-to-v9 package: '@tanstack/table-core' domain: foundations type: migration - purpose: 'Route framework-specific migration while enforcing the shared v9 feature, row-model, instance-method, naming, and type changes.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/migrating.md', - 'TanStack/table:docs/framework/preact/guide/migrating.md', - 'TanStack/table:docs/framework/solid/guide/migrating.md', - 'TanStack/table:docs/framework/svelte/guide/migrating.md', - 'TanStack/table:docs/framework/vue/guide/migrating.md', - 'TanStack/table:docs/framework/angular/guide/migrating.md', - 'TanStack/table:docs/framework/lit/guide/migrating.md', - 'TanStack/table:packages/table-core/src/index.ts', - 'TanStack/table:packages/table-core/src/types/TableFeatures.ts', - 'TanStack/table:packages/table-core/src/features/column-pinning/columnPinningFeature.types.ts', - 'TanStack/table:packages/table-core/src/features/column-resizing/columnResizingFeature.types.ts', - 'TanStack/table:packages/react-table/src/legacy.ts', - ] - failure_modes: - - 'Promoting deprecated useLegacyTable as the migration target instead of a temporary stopgap for code already using it.' - - 'Leaving v8 getFilteredRowModel/getSortedRowModel/getPaginationRowModel table options in place instead of v9 create*RowModel slots on tableFeatures.' - - 'Missing shared breaking changes such as prototype-bound instance methods, sortFn naming, feature-gated APIs, or logical start/end pinning.' - - - slug: column-faceting - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Derive filter option counts and numeric ranges from the correct faceted row model.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/column-faceting.md', - 'TanStack/table:packages/table-core/src/features/column-faceting', - 'TanStack/table:examples/react/filters-faceted', - ] - failure_modes: - - 'Registering columnFacetingFeature but omitting the facetedRowModel, facetedUniqueValues, or facetedMinMaxValues slot needed by the API being called.' - - 'Expecting a column facet to include that column own active filter; the faceted row model intentionally applies the other filters and excludes its own.' - - 'Computing large server-owned facet sets from the currently loaded client page and presenting incomplete counts as global results.' - - - slug: column-filtering - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Configure column filters, filter functions, metadata, nested-row direction, and client/manual ownership.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/column-filtering.md', - 'TanStack/table:packages/table-core/src/features/column-filtering', - 'TanStack/table:examples/react/filters', - ] - failure_modes: - - 'Setting manualFiltering and still expecting createFilteredRowModel to transform data; manual mode returns the pre-filtered model.' - - 'Using accessor values that are objects or renderer output with built-in filter functions that expect comparable primitive values.' - - 'Providing controlled columnFilters plus onColumnFiltersChange without applying both value and updater-function forms to the external source.' - - - slug: grouping - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Group rows, aggregate cells, and reason about grouped rows in expansion and pagination.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/grouping.md', - 'TanStack/table:packages/table-core/src/features/column-grouping', - 'TanStack/table:examples/react/grouping', - ] - failure_modes: - - 'Registering groupedRowModel or aggregationFns without columnGroupingFeature, or expecting grouping state alone to process rows.' - - 'Assuming pageSize counts only leaf data rows; group headers are rows in the model and affect built-in pagination.' - - 'Rendering every grouped cell as a normal value instead of handling grouped, placeholder, and aggregated cell states.' - - - slug: column-ordering - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Control leaf-column order while respecting pinning, visibility, and grouped-column precedence.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/column-ordering.md', - 'TanStack/table:packages/table-core/src/features/column-ordering', - 'TanStack/table:examples/react/column-dnd', - ] - failure_modes: - - 'Treating columnOrder as the final rendered order while pinning regions and groupedColumnMode also reorder columns.' - - 'Using headers, labels, or array indexes as drag identifiers instead of stable leaf column IDs.' - - 'Mutating the columnOrder array in place so the state owner does not observe a new value.' - - - slug: column-pinning - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Partition columns into logical start, center, and end regions and implement sticky layout correctly.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/column-pinning.md', - 'TanStack/table:packages/table-core/src/features/column-pinning', - 'TanStack/table:examples/react/column-pinning-sticky', - ] - failure_modes: - - 'Using v8 or early-beta left/right state and APIs instead of v9 logical start/end names, especially in RTL layouts.' - - 'Expecting pinning state to apply position: sticky, offsets, z-index, backgrounds, or overflow CSS automatically.' - - 'Allowing rendered widths to diverge from column.getSize, producing gaps or overlaps between adjacent pinned columns.' - - - slug: column-resizing - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Wire resize gestures and resize state onto the numeric sizing model without avoidable render cost.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/column-resizing.md', - 'TanStack/table:packages/table-core/src/features/column-resizing', - 'TanStack/table:examples/react/column-resizing-performant', - ] - failure_modes: - - 'Registering columnResizingFeature without its columnSizingFeature prerequisite.' - - 'Displaying a resize handle without attaching header.getResizeHandler to the correct pointer or touch events.' - - 'Reading getSize repeatedly in every cell during onChange resizing instead of caching sizes or using CSS variables for large tables.' - - - slug: column-sizing - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Use numeric min, max, and current sizes as state inputs to a renderer-owned CSS layout.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/column-sizing.md', - 'TanStack/table:packages/table-core/src/features/column-sizing', - 'TanStack/table:examples/react/column-sizing', - ] - failure_modes: - - 'Expecting the numeric sizing state to set DOM widths without applying it to th/td descendants, grid tracks, or flex styles.' - - 'Forcing auto or percentage strings through a number API instead of choosing and implementing an appropriate CSS layout strategy.' - - 'Forgetting the default size and rendered content can disagree, which also corrupts pinning offsets and total-size calculations.' - - - slug: column-visibility - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Hide leaf columns while rendering only visibility-aware header, column, and cell collections.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/column-visibility.md', - 'TanStack/table:packages/table-core/src/features/column-visibility', - 'TanStack/table:examples/react/column-visibility', - ] - failure_modes: - - 'Updating columnVisibility but rendering getAllLeafColumns or row.getAllCells, so hidden columns remain in the DOM.' - - 'Treating absent map entries as hidden; only an explicit false hides a column.' - - 'Expecting enableHiding to hide a column when it only controls whether the user or API may hide it.' - - - slug: global-filtering - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Apply one filter across eligible columns with explicit column eligibility and client/manual ownership.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/global-filtering.md', - 'TanStack/table:packages/table-core/src/features/global-filtering', - 'TanStack/table:examples/react/filters', - ] - failure_modes: - - 'Registering globalFilteringFeature without columnFilteringFeature and a filtered row-model stage when client processing is expected.' - - 'Assuming every column participates; the default eligibility checks the first core row value and only accepts strings or numbers.' - - 'Using manualFiltering while updating globalFilter state but never sending that value to the server query.' - - - slug: expanding - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Expand hierarchical subrows or custom detail panels and place expansion correctly relative to pagination.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/expanding.md', - 'TanStack/table:packages/table-core/src/features/row-expanding', - 'TanStack/table:examples/react/expanding', - ] - failure_modes: - - 'Expecting nested data to expand without getSubRows, or expecting a custom detail panel without getRowCanExpand and renderer markup.' - - 'Updating expanded state but never rendering subrows or the custom expanded UI because Table is headless.' - - 'Assuming paginateExpandedRows changes grouping or flattens visual descendants; it only controls the expanded-row pagination stage.' - - - slug: pagination - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Configure client slicing or manual pages, counts, navigation limits, and automatic page-index resets.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/pagination.md', - 'TanStack/table:packages/table-core/src/features/row-pagination', - 'TanStack/table:examples/react/pagination', - ] - failure_modes: - - 'Enabling manualPagination and passing all rows while expecting Table to slice them; manual data must already represent the intended page.' - - 'Omitting rowCount or pageCount for server pagination and then trusting next-page or last-page availability.' - - 'Misdiagnosing pageIndex jumping to zero as failed controlled state when autoResetPageIndex is reacting to client-side data or row-model changes.' - - - slug: row-pinning - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Separate top, center, and bottom rows with stable IDs and explicit rendering/sticky behavior.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/row-pinning.md', - 'TanStack/table:packages/table-core/src/features/row-pinning', - 'TanStack/table:examples/react/row-pinning', - ] - failure_modes: - - 'Using index-derived row IDs for persistent pinning while sorting, filtering, pagination, or data insertion changes indexes.' - - 'Expecting row pinning to add sticky CSS or render top/center/bottom collections in the correct order automatically.' - - 'Ignoring keepPinnedRows, so pinned rows remain visible outside the center row model when the desired product behavior was to filter or paginate them away.' - - - slug: cell-selection - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Maintain spreadsheet-style rectangular selections as ordered include/exclude operations anchored to row and column ids, resolving them into disjoint positive regions across sorting, filtering, pagination, and column layout changes.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/cell-selection.md', - 'TanStack/table:packages/table-core/src/features/cell-selection', - 'TanStack/table:examples/react/cell-selection', - ] - failure_modes: - - 'Expecting cellSelection to be a per-cell map or a list of final positive regions; it is an ordered log of two-corner include/exclude operations, and derived bounds may split one stored range into several regions.' - - 'Reordering, deduplicating, or serializing only the corners of controlled cellSelection state and thereby changing or losing subtraction semantics.' - - 'Using additive when the intended operation is explicit subtraction; selectCellRange mode is replace, include, or exclude, while additive is only a deprecated include alias.' - - 'Assuming Ctrl/Cmd always adds a range; a modified interaction excludes when it starts on a selected cell and includes when it starts on an unselected cell.' - - 'Binding only the mousedown handler and expecting drag selection, or reimplementing mouseup even though the start handler owns its own document listener.' - - 'Drawing the selection outline with borders on a border-collapse table, which changes row heights as cells become selected.' - - 'Re-rendering every cell on each drag update instead of subscribing per row to table.atoms.cellSelection.' - - - slug: cell-spanning - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Merge adjacent body cells into row- and column-spanning cells derived from the rendered row model, with covered cells reporting a span of 0 that renderers must skip.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/cell-spanning.md', - 'TanStack/table:packages/table-core/src/features/cell-spanning', - 'TanStack/table:examples/react/cell-spanning', - ] - failure_modes: - - 'Rendering a covered cell with rowSpan={0} instead of skipping it; HTML rowspan="0" means span to the end of the row group, so the cell merges down the entire tbody.' - - 'Expecting spanning to sort or group rows; it merges adjacent equal values only, so unsorted data renders no merges at all.' - - 'Precomputing spans from the source data array, which survives sorting, filtering, and page changes and produces ragged rows.' - - 'Assuming a run continues across a page or pinned-section boundary; runs are clipped to the rendered rows of each section.' - - 'Pre-expanding stored selection corners to cover merges; selection bounds already expand at derivation time when both features are registered, and pre-expanded corners go stale when sorting or paging changes the merges.' - - - slug: row-selection - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Maintain selection IDs across current, filtered, grouped, and manually paginated data.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/row-selection.md', - 'TanStack/table:packages/table-core/src/features/row-selection', - 'TanStack/table:examples/react/row-selection', - ] - failure_modes: - - 'Assuming selection mutates application data or is automatically deleted when rows disappear; rowSelection is independent ID state.' - - 'Using default index IDs for server pagination or mutable data instead of a stable getRowId.' - - 'Treating getSelectedRowModel as a database-wide selection lookup under manual pagination even though only loaded rows can appear in a row model.' - - - slug: sorting - package: '@tanstack/table-core' - domain: feature-plugins - type: feature - purpose: 'Configure single/multi sorting, comparison functions, undefined placement, removal cycles, and client/manual ownership.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/sorting.md', - 'TanStack/table:packages/table-core/src/features/row-sorting', - 'TanStack/table:examples/react/sorting', - ] - failure_modes: - - 'Setting manualSorting and expecting createSortedRowModel to reorder rows; manual mode trusts incoming data.' - - 'Writing a custom sortFn that applies ascending/descending direction itself even though Table reverses the comparator result for descending order.' - - 'Assuming undefined values, multi-sort gestures, and sort-removal cycles match product expectations without configuring sortUndefined and multi-sort options.' - + purpose: Route framework-specific migration while enforcing the shared v9 + feature, row-model, instance-method, naming, and type changes. + sources: + - TanStack/table:docs/framework/react/guide/migrating.md + - TanStack/table:docs/framework/preact/guide/migrating.md + - TanStack/table:docs/framework/solid/guide/migrating.md + - TanStack/table:docs/framework/svelte/guide/migrating.md + - TanStack/table:docs/framework/vue/guide/migrating.md + - TanStack/table:docs/framework/angular/guide/migrating.md + - TanStack/table:docs/framework/lit/guide/migrating.md + - TanStack/table:packages/table-core/src/index.ts + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:packages/table-core/src/features/column-pinning/columnPinningFeature.types.ts + - TanStack/table:packages/table-core/src/features/column-resizing/columnResizingFeature.types.ts + - TanStack/table:packages/react-table/src/legacy.ts + failure_modes: + - Promoting deprecated useLegacyTable as the migration target instead of a + temporary stopgap for code already using it. + - Leaving v8 getFilteredRowModel/getSortedRowModel/getPaginationRowModel + table options in place instead of v9 create*RowModel slots on + tableFeatures. + - Missing shared breaking changes such as prototype-bound instance + methods, sortFn naming, feature-gated APIs, or logical start/end + pinning. + references: + - path: references/architecture.md + purpose: + Read for feature registration, row-model and function slots, bound + methods, and removed internal APIs. + sources: + - TanStack/table:docs/framework/react/guide/migrating.md + - TanStack/table:docs/framework/preact/guide/migrating.md + - TanStack/table:docs/framework/solid/guide/migrating.md + - TanStack/table:docs/framework/svelte/guide/migrating.md + - TanStack/table:docs/framework/vue/guide/migrating.md + - TanStack/table:docs/framework/angular/guide/migrating.md + - TanStack/table:docs/framework/lit/guide/migrating.md + - TanStack/table:packages/table-core/src/index.ts + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:packages/table-core/src/features/column-pinning/columnPinningFeature.types.ts + - TanStack/table:packages/table-core/src/features/column-resizing/columnResizingFeature.types.ts + - TanStack/table:packages/react-table/src/legacy.ts + failure_modes: [] + - path: references/state.md + purpose: Read for shared v8 state, ownership, observation, and reset changes. + sources: + - TanStack/table:docs/framework/react/guide/migrating.md + - TanStack/table:docs/framework/preact/guide/migrating.md + - TanStack/table:docs/framework/solid/guide/migrating.md + - TanStack/table:docs/framework/svelte/guide/migrating.md + - TanStack/table:docs/framework/vue/guide/migrating.md + - TanStack/table:docs/framework/angular/guide/migrating.md + - TanStack/table:docs/framework/lit/guide/migrating.md + - TanStack/table:packages/table-core/src/index.ts + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:packages/table-core/src/features/column-pinning/columnPinningFeature.types.ts + - TanStack/table:packages/table-core/src/features/column-resizing/columnResizingFeature.types.ts + - TanStack/table:packages/react-table/src/legacy.ts + failure_modes: [] + - path: references/feature-apis.md + purpose: + Read when auditing pinning, sizing, resizing, sorting, or row-selection + API changes. + sources: + - TanStack/table:docs/framework/react/guide/migrating.md + - TanStack/table:docs/framework/preact/guide/migrating.md + - TanStack/table:docs/framework/solid/guide/migrating.md + - TanStack/table:docs/framework/svelte/guide/migrating.md + - TanStack/table:docs/framework/vue/guide/migrating.md + - TanStack/table:docs/framework/angular/guide/migrating.md + - TanStack/table:docs/framework/lit/guide/migrating.md + - TanStack/table:packages/table-core/src/index.ts + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:packages/table-core/src/features/column-pinning/columnPinningFeature.types.ts + - TanStack/table:packages/table-core/src/features/column-resizing/columnResizingFeature.types.ts + - TanStack/table:packages/react-table/src/legacy.ts + failure_modes: [] + - path: references/typescript.md + purpose: + Read for feature generics, column helpers, meta, registries, and + RowData changes. + sources: + - TanStack/table:docs/framework/react/guide/migrating.md + - TanStack/table:docs/framework/preact/guide/migrating.md + - TanStack/table:docs/framework/solid/guide/migrating.md + - TanStack/table:docs/framework/svelte/guide/migrating.md + - TanStack/table:docs/framework/vue/guide/migrating.md + - TanStack/table:docs/framework/angular/guide/migrating.md + - TanStack/table:docs/framework/lit/guide/migrating.md + - TanStack/table:packages/table-core/src/index.ts + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:packages/table-core/src/features/column-pinning/columnPinningFeature.types.ts + - TanStack/table:packages/table-core/src/features/column-resizing/columnResizingFeature.types.ts + - TanStack/table:packages/react-table/src/legacy.ts + failure_modes: [] + description: + Audit and migrate Table v8 to v9. Inventory affected APIs, follow + the shared checklist, and read only the required architecture, state, + feature, and TypeScript mappings. + requires: + - core - slug: getting-started package: '@tanstack/react-table' domain: framework-adapters type: framework framework: react - purpose: 'Create and render a headless v9 React table with useTable and explicit features.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/migrating.md', - 'TanStack/table:examples/react/basic-use-table', - 'TanStack/table:packages/react-table/src/index.ts', - ] - failure_modes: - - 'Copying a v8 useReactTable/getCoreRowModel setup instead of the v9 useTable plus tableFeatures shape.' - - 'Expecting useTable to render markup or styles rather than mapping headers, rows, and cells with FlexRender or flexRender.' - - 'Creating features, columns, or fallback data inside render without stable references.' - + purpose: + Create and render a headless v9 React table with useTable and explicit + features. + sources: + - TanStack/table:docs/framework/react/guide/migrating.md + - TanStack/table:examples/react/basic-use-table + - TanStack/table:packages/react-table/src/index.ts + - TanStack/table:docs/framework/react/guide/composable-tables.md + - TanStack/table:docs/framework/react/guide/table-context.md + - TanStack/table:examples/react/composable-tables + - TanStack/table:packages/react-table/src/createTableHook.tsx + - TanStack/table:packages/react-table/src/createTableHookContexts.tsx + - TanStack/table:examples/react/with-tanstack-query + - TanStack/table:examples/react/virtualized-infinite-scrolling + - TanStack/table:docs/framework/react/guide/pagination.md + - TanStack/table:docs/framework/react/guide/virtualization.md + - TanStack/table:examples/react/virtualized-rows + - TanStack/table:examples/react/virtualized-columns + failure_modes: + - Copying a v8 useReactTable/getCoreRowModel setup instead of the v9 + useTable plus tableFeatures shape. + - Expecting useTable to render markup or styles rather than mapping + headers, rows, and cells with FlexRender or flexRender. + - Creating features, columns, or fallback data inside render without + stable references. + references: + - slug: create-table-hook + purpose: Create a typed app-level React table hook with shared features, + options, helpers, components, and contexts. + sources: + - TanStack/table:docs/framework/react/guide/composable-tables.md + - TanStack/table:docs/framework/react/guide/table-context.md + - TanStack/table:examples/react/composable-tables + - TanStack/table:packages/react-table/src/createTableHook.tsx + - TanStack/table:packages/react-table/src/createTableHookContexts.tsx + failure_modes: + - Using createTableHook for a one-off table or registering a full + component system when only shared features/defaults are needed. + - Prop-drilling table, cell, and header values through registered + components instead of using the typed context hooks returned by the + same factory. + - Creating contexts inside a render path or introducing circular + imports between the hook module and registered components, causing + HMR or remount failures. + path: references/create-table-hook.md + replaces: '@tanstack/react-table#create-table-hook' + - slug: with-tanstack-query + purpose: + Use Query as the server-data source while Table owns data-grid state + and explicit manual row-model boundaries. + sources: + - TanStack/table:examples/react/with-tanstack-query + - TanStack/table:examples/react/virtualized-infinite-scrolling + - TanStack/table:docs/framework/react/guide/pagination.md + failure_modes: + - Putting server response data into a second unsynchronized React + state layer instead of deriving Table data from the query result. + - Omitting pagination, sorting, or filter state from the query key and + showing cached data for the wrong table state. + - Enabling manual processing without passing server counts, resetting + invalid pages, or preserving previous data intentionally. + path: references/with-tanstack-query.md + replaces: '@tanstack/react-table#with-tanstack-query' + - slug: with-tanstack-virtual + purpose: + Virtualize React rows or columns as a rendering concern layered over + the final Table row model. + sources: + - TanStack/table:docs/framework/react/guide/virtualization.md + - TanStack/table:examples/react/virtualized-rows + - TanStack/table:examples/react/virtualized-columns + - TanStack/table:examples/react/virtualized-infinite-scrolling + failure_modes: + - Treating Virtual as a Table feature or row model instead of + virtualizing table.getRowModel().rows in the renderer. + - Measuring rows against the wrong scroll element or omitting stable + keys and data-index values for dynamic measurement. + - Combining semantic table layout, sticky headers/columns, transforms, + and dynamic heights without copying the example CSS positioning + contract. + path: references/with-tanstack-virtual.md + replaces: '@tanstack/react-table#with-tanstack-virtual' + description: + Create and render Table v9 with the react adapter. Route reusable + createTableHook components, Query and Virtual integration, and framework + setup; use table-state for reactive ownership. + requires: + - '@tanstack/table-core#core' - slug: table-state package: '@tanstack/react-table' domain: framework-adapters type: framework framework: react - purpose: 'Read, subscribe to, control, and optimize React table state with selectors, Subscribe, and external atoms.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/table-state.md', - 'TanStack/table:docs/framework/react/guide/react-compiler.md', - 'TanStack/table:examples/react/basic-subscribe', - 'TanStack/table:packages/react-table/src/Subscribe.ts', - 'TanStack/table:packages/react-table/src/useTable.ts', - ] - failure_modes: - - 'Reading table.atoms.x.get or table.store.state during render and assuming that snapshot read subscribes React to future changes.' - - 'Providing onSliceChange without state.slice, or failing to apply updater-function values when React owns the slice.' - - 'Hiding builder-method state reads in compiler-memoized children without a Subscribe boundary, or adding fine-grained Subscribe everywhere before measuring.' - + purpose: Read, subscribe to, control, and optimize React table state with + selectors, Subscribe, and external atoms. + sources: + - TanStack/table:docs/framework/react/guide/table-state.md + - TanStack/table:docs/framework/react/guide/react-compiler.md + - TanStack/table:examples/react/basic-subscribe + - TanStack/table:packages/react-table/src/Subscribe.ts + - TanStack/table:packages/react-table/src/useTable.ts + failure_modes: + - Reading table.atoms.x.get or table.store.state during render and + assuming that snapshot read subscribes React to future changes. + - Providing onSliceChange without state.slice, or failing to apply + updater-function values when React owns the slice. + - Hiding builder-method state reads in compiler-memoized children without + a Subscribe boundary, or adding fine-grained Subscribe everywhere before + measuring. + references: + - path: references/reactivity.md + purpose: + Read for advanced react reactive boundaries, subscription patterns, and + complete framework-specific state examples. + sources: + - TanStack/table:docs/framework/react/guide/table-state.md + - TanStack/table:docs/framework/react/guide/react-compiler.md + - TanStack/table:examples/react/basic-subscribe + - TanStack/table:packages/react-table/src/Subscribe.ts + - TanStack/table:packages/react-table/src/useTable.ts + failure_modes: + - Reading table.atoms.x.get or table.store.state during render and + assuming that snapshot read subscribes React to future changes. + - Providing onSliceChange without state.slice, or failing to apply + updater-function values when React owns the slice. + - Hiding builder-method state reads in compiler-memoized children + without a Subscribe boundary, or adding fine-grained Subscribe + everywhere before measuring. + description: + Read and control Table v9 state in react. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' - slug: migrate-v8-to-v9 package: '@tanstack/react-table' domain: framework-adapters type: migration framework: react - purpose: 'Migrate React from useReactTable to the native v9 feature, state, rendering, helper, and composable APIs.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/migrating.md', - 'TanStack/table:packages/react-table/src/index.ts', - 'TanStack/table:packages/react-table/src/legacy.ts', - 'TanStack/table:examples/react/basic-use-table', - ] - failure_modes: - - 'Using useLegacyTable as the finished migration rather than converting to useTable and explicit features.' - - 'Keeping the removed global onStateChange or v8 row-model options instead of per-slice control and tableFeatures slots.' - - 'Missing React-specific FlexRender/Subscribe changes while only applying the core feature renames.' - - - slug: create-table-hook - package: '@tanstack/react-table' - domain: framework-adapters - type: framework - framework: react - purpose: 'Create a typed app-level React table hook with shared features, options, helpers, components, and contexts.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/composable-tables.md', - 'TanStack/table:docs/framework/react/guide/table-context.md', - 'TanStack/table:examples/react/composable-tables', - 'TanStack/table:packages/react-table/src/createTableHook.tsx', - 'TanStack/table:packages/react-table/src/createTableHookContexts.tsx', - ] - failure_modes: - - 'Using createTableHook for a one-off table or registering a full component system when only shared features/defaults are needed.' - - 'Prop-drilling table, cell, and header values through registered components instead of using the typed context hooks returned by the same factory.' - - 'Creating contexts inside a render path or introducing circular imports between the hook module and registered components, causing HMR or remount failures.' - - - slug: with-tanstack-query - package: '@tanstack/react-table' - domain: framework-adapters - type: integration - framework: react - purpose: 'Use Query as the server-data source while Table owns data-grid state and explicit manual row-model boundaries.' - sources: - [ - 'TanStack/table:examples/react/with-tanstack-query', - 'TanStack/table:examples/react/virtualized-infinite-scrolling', - 'TanStack/table:docs/framework/react/guide/pagination.md', - ] - failure_modes: - - 'Putting server response data into a second unsynchronized React state layer instead of deriving Table data from the query result.' - - 'Omitting pagination, sorting, or filter state from the query key and showing cached data for the wrong table state.' - - 'Enabling manual processing without passing server counts, resetting invalid pages, or preserving previous data intentionally.' - - - slug: with-tanstack-virtual - package: '@tanstack/react-table' - domain: framework-adapters - type: integration - framework: react - purpose: 'Virtualize React rows or columns as a rendering concern layered over the final Table row model.' - sources: - [ - 'TanStack/table:docs/framework/react/guide/virtualization.md', - 'TanStack/table:examples/react/virtualized-rows', - 'TanStack/table:examples/react/virtualized-columns', - 'TanStack/table:examples/react/virtualized-infinite-scrolling', - ] - failure_modes: - - 'Treating Virtual as a Table feature or row model instead of virtualizing table.getRowModel().rows in the renderer.' - - 'Measuring rows against the wrong scroll element or omitting stable keys and data-index values for dynamic measurement.' - - 'Combining semantic table layout, sticky headers/columns, transforms, and dynamic heights without copying the example CSS positioning contract.' - + purpose: Migrate React from useReactTable to the native v9 feature, state, + rendering, helper, and composable APIs. + sources: + - TanStack/table:docs/framework/react/guide/migrating.md + - TanStack/table:packages/react-table/src/index.ts + - TanStack/table:packages/react-table/src/legacy.ts + - TanStack/table:examples/react/basic-use-table + failure_modes: + - Using useLegacyTable as the finished migration rather than converting to + useTable and explicit features. + - Keeping the removed global onStateChange or v8 row-model options instead + of per-slice control and tableFeatures slots. + - Missing React-specific FlexRender/Subscribe changes while only applying + the core feature renames. + references: + - path: references/adapter-migration.md + purpose: + Read for react construction, rendering, state, and app-hook migration + details. Shared feature and type mappings belong to the core migration + references. + sources: + - TanStack/table:docs/framework/react/guide/migrating.md + - TanStack/table:packages/react-table/src/index.ts + - TanStack/table:packages/react-table/src/legacy.ts + - TanStack/table:examples/react/basic-use-table + failure_modes: + - Using useLegacyTable as the finished migration rather than + converting to useTable and explicit features. + - Keeping the removed global onStateChange or v8 row-model options + instead of per-slice control and tableFeatures slots. + - Missing React-specific FlexRender/Subscribe changes while only + applying the core feature renames. + description: Migrate react Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. + requires: + - '@tanstack/table-core#migrate-v8-to-v9' - slug: getting-started package: '@tanstack/preact-table' domain: framework-adapters type: framework framework: preact - purpose: 'Create and render a native Preact v9 table without relying on the React adapter through preact/compat.' - sources: - [ - 'TanStack/table:docs/framework/preact/guide/migrating.md', - 'TanStack/table:examples/preact/basic-use-table', - 'TanStack/table:packages/preact-table/src/index.ts', - ] - failure_modes: - - 'Importing @tanstack/react-table through preact/compat instead of the native @tanstack/preact-table v9 adapter.' - - 'Copying useReactTable or React-only rendering assumptions instead of Preact useTable and its exported helpers.' - - 'Recreating stable features, columns, or data on each render and causing unnecessary option and row-model work.' - + purpose: + Create and render a native Preact v9 table without relying on the React + adapter through preact/compat. + sources: + - TanStack/table:docs/framework/preact/guide/migrating.md + - TanStack/table:examples/preact/basic-use-table + - TanStack/table:packages/preact-table/src/index.ts + - TanStack/table:docs/framework/preact/guide/composable-tables.md + - TanStack/table:docs/framework/preact/guide/table-context.md + - TanStack/table:examples/preact/composable-tables + - TanStack/table:packages/preact-table/src/createTableHook.tsx + - TanStack/table:packages/preact-table/src/createTableHookContexts.tsx + - TanStack/table:examples/preact/with-tanstack-query + - TanStack/table:docs/framework/preact/guide/pagination.md + - TanStack/table:docs/framework/preact/guide/virtualization.md + failure_modes: + - Importing @tanstack/react-table through preact/compat instead of the + native @tanstack/preact-table v9 adapter. + - Copying useReactTable or React-only rendering assumptions instead of + Preact useTable and its exported helpers. + - Recreating stable features, columns, or data on each render and causing + unnecessary option and row-model work. + references: + - slug: create-table-hook + purpose: + Build a typed reusable Preact table hook and optional component/context + registry. + sources: + - TanStack/table:docs/framework/preact/guide/composable-tables.md + - TanStack/table:docs/framework/preact/guide/table-context.md + - TanStack/table:examples/preact/composable-tables + - TanStack/table:packages/preact-table/src/createTableHook.tsx + - TanStack/table:packages/preact-table/src/createTableHookContexts.tsx + failure_modes: + - Using the app hook for one table when standalone useTable is clearer. + - Importing context hooks from a different factory or reading them + outside the matching AppTable/AppCell/AppHeader provider. + - Prop-drilling stable table instances through memoized components and + expecting context consumers to update without the factory + wrappers/subscriptions. + path: references/create-table-hook.md + replaces: '@tanstack/preact-table#create-table-hook' + - slug: with-tanstack-query + purpose: + Drive manually processed Preact table data from TanStack Query and + table state. + sources: + - TanStack/table:examples/preact/with-tanstack-query + - TanStack/table:docs/framework/preact/guide/pagination.md + failure_modes: + - Copying React Query hook names or React state glue instead of the + Preact Query example. + - Leaving table state out of the query key or query function request. + - Expecting manual pagination/filtering/sorting flags to fetch or + transform server data. + path: references/with-tanstack-query.md + replaces: '@tanstack/preact-table#with-tanstack-query' + - slug: with-tanstack-virtual + purpose: + Apply Preact Virtual rendering to Table rows or columns using the + adapter virtualization guide. + sources: + - TanStack/table:docs/framework/preact/guide/virtualization.md + - TanStack/table:packages/preact-table/src/index.ts + failure_modes: + - Copying React-only component/hook details instead of using the + Preact Virtual API exported for the installed versions. + - Virtualizing raw input data instead of the final filtered, sorted, + expanded, and paginated row model. + - Assuming Table supplies scroll containers, measurements, spacer + geometry, sticky CSS, or overscan defaults. + path: references/with-tanstack-virtual.md + replaces: '@tanstack/preact-table#with-tanstack-virtual' + description: + Create and render Table v9 with the preact adapter. Route reusable + createTableHook components, Query and Virtual integration, and framework + setup; use table-state for reactive ownership. + requires: + - '@tanstack/table-core#core' - slug: table-state package: '@tanstack/preact-table' domain: framework-adapters type: framework framework: preact - purpose: 'Use selected table.state, Preact subscriptions, controlled slices, and external atoms correctly.' - sources: - [ - 'TanStack/table:docs/framework/preact/guide/table-state.md', - 'TanStack/table:examples/preact/basic-subscribe', - 'TanStack/table:packages/preact-table/src/useTable.ts', - ] - failure_modes: - - 'Reading atom/store snapshots in render as though they create Preact subscriptions.' - - 'Pairing an onSliceChange callback with no controlled state.slice value or ignoring updater-function inputs.' - - 'Narrowing the useTable selector so far that rendered builder APIs depend on unselected state, or optimizing before a real render problem exists.' - + purpose: + Use selected table.state, Preact subscriptions, controlled slices, and + external atoms correctly. + sources: + - TanStack/table:docs/framework/preact/guide/table-state.md + - TanStack/table:examples/preact/basic-subscribe + - TanStack/table:packages/preact-table/src/useTable.ts + failure_modes: + - Reading atom/store snapshots in render as though they create Preact + subscriptions. + - Pairing an onSliceChange callback with no controlled state.slice value + or ignoring updater-function inputs. + - Narrowing the useTable selector so far that rendered builder APIs depend + on unselected state, or optimizing before a real render problem exists. + references: + - path: references/reactivity.md + purpose: + Read for advanced preact reactive boundaries, subscription patterns, + and complete framework-specific state examples. + sources: + - TanStack/table:docs/framework/preact/guide/table-state.md + - TanStack/table:examples/preact/basic-subscribe + - TanStack/table:packages/preact-table/src/useTable.ts + failure_modes: + - Reading atom/store snapshots in render as though they create Preact + subscriptions. + - Pairing an onSliceChange callback with no controlled state.slice + value or ignoring updater-function inputs. + - Narrowing the useTable selector so far that rendered builder APIs + depend on unselected state, or optimizing before a real render + problem exists. + description: + Read and control Table v9 state in preact. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' - slug: migrate-v8-to-v9 package: '@tanstack/preact-table' domain: framework-adapters type: migration framework: preact - purpose: 'Move a v8 React-adapter/preact-compat table onto the native v9 Preact adapter and architecture.' - sources: - [ - 'TanStack/table:docs/framework/preact/guide/migrating.md', - 'TanStack/table:packages/preact-table/src/index.ts', - 'TanStack/table:examples/preact/basic-use-table', - ] - failure_modes: - - 'Treating Preact as a simple hook rename while leaving the React package and compat aliases in place.' - - 'Keeping v8 get*RowModel options and globally included features instead of explicit tableFeatures slots.' - - 'Missing prototype-method, state, helper, pinning, and sorting renames shared by every v9 adapter.' - - - slug: create-table-hook - package: '@tanstack/preact-table' - domain: framework-adapters - type: framework - framework: preact - purpose: 'Build a typed reusable Preact table hook and optional component/context registry.' - sources: - [ - 'TanStack/table:docs/framework/preact/guide/composable-tables.md', - 'TanStack/table:docs/framework/preact/guide/table-context.md', - 'TanStack/table:examples/preact/composable-tables', - 'TanStack/table:packages/preact-table/src/createTableHook.tsx', - 'TanStack/table:packages/preact-table/src/createTableHookContexts.tsx', - ] - failure_modes: - - 'Using the app hook for one table when standalone useTable is clearer.' - - 'Importing context hooks from a different factory or reading them outside the matching AppTable/AppCell/AppHeader provider.' - - 'Prop-drilling stable table instances through memoized components and expecting context consumers to update without the factory wrappers/subscriptions.' - - - slug: with-tanstack-query - package: '@tanstack/preact-table' - domain: framework-adapters - type: integration - framework: preact - purpose: 'Drive manually processed Preact table data from TanStack Query and table state.' - sources: - [ - 'TanStack/table:examples/preact/with-tanstack-query', - 'TanStack/table:docs/framework/preact/guide/pagination.md', - ] - failure_modes: - - 'Copying React Query hook names or React state glue instead of the Preact Query example.' - - 'Leaving table state out of the query key or query function request.' - - 'Expecting manual pagination/filtering/sorting flags to fetch or transform server data.' - - - slug: with-tanstack-virtual - package: '@tanstack/preact-table' - domain: framework-adapters - type: integration - framework: preact - purpose: 'Apply Preact Virtual rendering to Table rows or columns using the adapter virtualization guide.' - sources: - [ - 'TanStack/table:docs/framework/preact/guide/virtualization.md', - 'TanStack/table:packages/preact-table/src/index.ts', - ] - failure_modes: - - 'Copying React-only component/hook details instead of using the Preact Virtual API exported for the installed versions.' - - 'Virtualizing raw input data instead of the final filtered, sorted, expanded, and paginated row model.' - - 'Assuming Table supplies scroll containers, measurements, spacer geometry, sticky CSS, or overscan defaults.' - + purpose: + Move a v8 React-adapter/preact-compat table onto the native v9 Preact + adapter and architecture. + sources: + - TanStack/table:docs/framework/preact/guide/migrating.md + - TanStack/table:packages/preact-table/src/index.ts + - TanStack/table:examples/preact/basic-use-table + failure_modes: + - Treating Preact as a simple hook rename while leaving the React package + and compat aliases in place. + - Keeping v8 get*RowModel options and globally included features instead + of explicit tableFeatures slots. + - Missing prototype-method, state, helper, pinning, and sorting renames + shared by every v9 adapter. + references: + - path: references/adapter-migration.md + purpose: + Read for preact construction, rendering, state, and app-hook migration + details. Shared feature and type mappings belong to the core migration + references. + sources: + - TanStack/table:docs/framework/preact/guide/migrating.md + - TanStack/table:packages/preact-table/src/index.ts + - TanStack/table:examples/preact/basic-use-table + failure_modes: + - Treating Preact as a simple hook rename while leaving the React + package and compat aliases in place. + - Keeping v8 get*RowModel options and globally included features + instead of explicit tableFeatures slots. + - Missing prototype-method, state, helper, pinning, and sorting + renames shared by every v9 adapter. + description: Migrate preact Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. + requires: + - '@tanstack/table-core#migrate-v8-to-v9' - slug: getting-started package: '@tanstack/solid-table' domain: framework-adapters type: framework framework: solid - purpose: 'Create a Solid v9 table with createTable, reactive getters, and JSX rendering.' - sources: - [ - 'TanStack/table:docs/framework/solid/guide/migrating.md', - 'TanStack/table:examples/solid/basic-use-table', - 'TanStack/table:packages/solid-table/src/index.tsx', - ] - failure_modes: - - 'Using the v8 createSolidTable entrypoint or a React hook instead of v9 createTable.' - - 'Reading a signal once and passing its snapshot as data instead of a getter/reactive option when updates are expected.' - - 'Expecting Table to render DOM or CSS rather than iterating row/header APIs in Solid JSX.' - + purpose: Create a Solid v9 table with createTable, reactive getters, and JSX + rendering. + sources: + - TanStack/table:docs/framework/solid/guide/migrating.md + - TanStack/table:examples/solid/basic-use-table + - TanStack/table:packages/solid-table/src/index.tsx + - TanStack/table:docs/framework/solid/guide/composable-tables.md + - TanStack/table:examples/solid/composable-tables + - TanStack/table:packages/solid-table/src/createTableHook.tsx + - TanStack/table:examples/solid/with-tanstack-query + - TanStack/table:docs/framework/solid/guide/pagination.md + - TanStack/table:docs/framework/solid/guide/virtualization.md + - TanStack/table:examples/solid/virtualized-rows + - TanStack/table:examples/solid/virtualized-columns + - TanStack/table:examples/solid/virtualized-infinite-scrolling + failure_modes: + - Using the v8 createSolidTable entrypoint or a React hook instead of v9 + createTable. + - Reading a signal once and passing its snapshot as data instead of a + getter/reactive option when updates are expected. + - Expecting Table to render DOM or CSS rather than iterating row/header + APIs in Solid JSX. + references: + - slug: create-table-hook + purpose: Create a shared Solid createAppTable and typed helper/component + registry without losing reactivity. + sources: + - TanStack/table:docs/framework/solid/guide/composable-tables.md + - TanStack/table:examples/solid/composable-tables + - TanStack/table:packages/solid-table/src/createTableHook.tsx + failure_modes: + - Using createTableHook for a one-off table instead of standalone + createTable. + - Passing snapshots where createAppTable needs reactive getters or + signals for per-table data and state. + - Reading context values outside registered App wrappers or + prop-drilling the table when returned context hooks express the + shared boundary. + path: references/create-table-hook.md + replaces: '@tanstack/solid-table#create-table-hook' + - slug: with-tanstack-query + purpose: + Compose Solid Query resources with manually processed Table state and + reactive query inputs. + sources: + - TanStack/table:examples/solid/with-tanstack-query + - TanStack/table:docs/framework/solid/guide/pagination.md + failure_modes: + - Passing signal snapshots into the query key so sorting, filtering, + or pagination changes are not tracked. + - Copying React Query hook/state patterns instead of Solid Query + reactive option getters. + - Using manual Table flags without returning already processed server + data and counts. + path: references/with-tanstack-query.md + replaces: '@tanstack/solid-table#with-tanstack-query' + - slug: with-tanstack-virtual + purpose: + Virtualize Solid Table rows/columns and infinite server data while + preserving reactive measurements. + sources: + - TanStack/table:docs/framework/solid/guide/virtualization.md + - TanStack/table:examples/solid/virtualized-rows + - TanStack/table:examples/solid/virtualized-columns + - TanStack/table:examples/solid/virtualized-infinite-scrolling + failure_modes: + - Creating the virtualizer from a non-reactive row count or wrong + scroll element. + - Virtualizing raw data rather than the current Table row model. + - Applying transforms, dynamic measurements, sticky regions, or + grid/flex widths inconsistently with the rendered layout. + path: references/with-tanstack-virtual.md + replaces: '@tanstack/solid-table#with-tanstack-virtual' + description: + Create and render Table v9 with the solid adapter. Route reusable + createTableHook components, Query and Virtual integration, and framework + setup; use table-state for reactive ownership. + requires: + - '@tanstack/table-core#core' - slug: table-state package: '@tanstack/solid-table' domain: framework-adapters type: framework framework: solid - purpose: 'Use Solid-backed table atoms inside tracked scopes and choose native signals or external atoms for ownership.' - sources: - [ - 'TanStack/table:docs/framework/solid/guide/table-state.md', - 'TanStack/table:examples/solid/basic-external-state', - 'TanStack/table:packages/solid-table/src/createTable.ts', - ] - failure_modes: - - 'Reading table atoms outside JSX, createMemo, createEffect, or another tracked scope and expecting later changes to rerun code.' - - 'Calling a state updater with a Solid setter assumption without resolving Table value-or-updater semantics.' - - 'Adding React-style broad rerender workarounds instead of relying on Solid narrow atom reads and computations.' - + purpose: + Use Solid-backed table atoms inside tracked scopes and choose native + signals or external atoms for ownership. + sources: + - TanStack/table:docs/framework/solid/guide/table-state.md + - TanStack/table:examples/solid/basic-external-state + - TanStack/table:packages/solid-table/src/createTable.ts + failure_modes: + - Reading table atoms outside JSX, createMemo, createEffect, or another + tracked scope and expecting later changes to rerun code. + - Calling a state updater with a Solid setter assumption without resolving + Table value-or-updater semantics. + - Adding React-style broad rerender workarounds instead of relying on + Solid narrow atom reads and computations. + references: + - path: references/reactivity.md + purpose: + Read for advanced solid reactive boundaries, subscription patterns, and + complete framework-specific state examples. + sources: + - TanStack/table:docs/framework/solid/guide/table-state.md + - TanStack/table:examples/solid/basic-external-state + - TanStack/table:packages/solid-table/src/createTable.ts + failure_modes: + - Reading table atoms outside JSX, createMemo, createEffect, or + another tracked scope and expecting later changes to rerun code. + - Calling a state updater with a Solid setter assumption without + resolving Table value-or-updater semantics. + - Adding React-style broad rerender workarounds instead of relying on + Solid narrow atom reads and computations. + description: + Read and control Table v9 state in solid. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' - slug: migrate-v8-to-v9 package: '@tanstack/solid-table' domain: framework-adapters type: migration framework: solid - purpose: 'Migrate createSolidTable code to v9 createTable, explicit features, atom-backed state, and new helpers.' - sources: - [ - 'TanStack/table:docs/framework/solid/guide/migrating.md', - 'TanStack/table:packages/solid-table/src/index.tsx', - 'TanStack/table:examples/solid/basic-use-table', - ] - failure_modes: - - 'Renaming the entrypoint but retaining v8 row-model options outside tableFeatures.' - - 'Forcing React selector patterns into Solid instead of using signal-tracked table atom reads.' - - 'Missing shared v9 changes to instance method binding, feature APIs, meta helpers, sorting, and pinning.' - - - slug: create-table-hook - package: '@tanstack/solid-table' - domain: framework-adapters - type: framework - framework: solid - purpose: 'Create a shared Solid createAppTable and typed helper/component registry without losing reactivity.' - sources: - [ - 'TanStack/table:docs/framework/solid/guide/composable-tables.md', - 'TanStack/table:examples/solid/composable-tables', - 'TanStack/table:packages/solid-table/src/createTableHook.tsx', - ] - failure_modes: - - 'Using createTableHook for a one-off table instead of standalone createTable.' - - 'Passing snapshots where createAppTable needs reactive getters or signals for per-table data and state.' - - 'Reading context values outside registered App wrappers or prop-drilling the table when returned context hooks express the shared boundary.' - - - slug: with-tanstack-query - package: '@tanstack/solid-table' - domain: framework-adapters - type: integration - framework: solid - purpose: 'Compose Solid Query resources with manually processed Table state and reactive query inputs.' - sources: - [ - 'TanStack/table:examples/solid/with-tanstack-query', - 'TanStack/table:docs/framework/solid/guide/pagination.md', - ] - failure_modes: - - 'Passing signal snapshots into the query key so sorting, filtering, or pagination changes are not tracked.' - - 'Copying React Query hook/state patterns instead of Solid Query reactive option getters.' - - 'Using manual Table flags without returning already processed server data and counts.' - - - slug: with-tanstack-virtual - package: '@tanstack/solid-table' - domain: framework-adapters - type: integration - framework: solid - purpose: 'Virtualize Solid Table rows/columns and infinite server data while preserving reactive measurements.' - sources: - [ - 'TanStack/table:docs/framework/solid/guide/virtualization.md', - 'TanStack/table:examples/solid/virtualized-rows', - 'TanStack/table:examples/solid/virtualized-columns', - 'TanStack/table:examples/solid/virtualized-infinite-scrolling', - ] - failure_modes: - - 'Creating the virtualizer from a non-reactive row count or wrong scroll element.' - - 'Virtualizing raw data rather than the current Table row model.' - - 'Applying transforms, dynamic measurements, sticky regions, or grid/flex widths inconsistently with the rendered layout.' - + purpose: Migrate createSolidTable code to v9 createTable, explicit features, + atom-backed state, and new helpers. + sources: + - TanStack/table:docs/framework/solid/guide/migrating.md + - TanStack/table:packages/solid-table/src/index.tsx + - TanStack/table:examples/solid/basic-use-table + failure_modes: + - Renaming the entrypoint but retaining v8 row-model options outside + tableFeatures. + - Forcing React selector patterns into Solid instead of using + signal-tracked table atom reads. + - Missing shared v9 changes to instance method binding, feature APIs, meta + helpers, sorting, and pinning. + references: + - path: references/adapter-migration.md + purpose: + Read for solid construction, rendering, state, and app-hook migration + details. Shared feature and type mappings belong to the core migration + references. + sources: + - TanStack/table:docs/framework/solid/guide/migrating.md + - TanStack/table:packages/solid-table/src/index.tsx + - TanStack/table:examples/solid/basic-use-table + failure_modes: + - Renaming the entrypoint but retaining v8 row-model options outside + tableFeatures. + - Forcing React selector patterns into Solid instead of using + signal-tracked table atom reads. + - Missing shared v9 changes to instance method binding, feature APIs, + meta helpers, sorting, and pinning. + description: Migrate solid Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. + requires: + - '@tanstack/table-core#migrate-v8-to-v9' - slug: getting-started package: '@tanstack/svelte-table' domain: framework-adapters type: framework framework: svelte - purpose: 'Create a Svelte 5 table with createTable, rune-backed option getters, FlexRender, and headless markup.' - sources: - [ - 'TanStack/table:docs/framework/svelte/guide/migrating.md', - 'TanStack/table:examples/svelte/basic-create-table', - 'TanStack/table:packages/svelte-table/src/index.ts', - ] - failure_modes: - - 'Using the v8 createSvelteTable/store API or pre-Svelte-5 syntax instead of v9 createTable and runes.' - - 'Passing a one-time data snapshot where a getter is needed for current rune state.' - - 'Expecting render helpers to initialize interactive markup or provide table CSS automatically.' - - - slug: table-state - package: '@tanstack/svelte-table' - domain: framework-adapters - type: framework - framework: svelte - purpose: 'Use rune-aware table atoms and stores, native $derived projections, controlled $state or createTableState slices, and external atoms without broad invalidation or snapshot mismatches.' - sources: - [ - 'TanStack/table:docs/framework/svelte/guide/table-state.md', - 'TanStack/table:docs/framework/svelte/guide/pagination.md', - 'TanStack/table:examples/svelte/basic-external-state', - 'TanStack/table:packages/svelte-table/src/createTable.svelte.ts', - 'TanStack/table:packages/svelte-table/src/createTableState.svelte.ts', - ] - failure_modes: - - 'Keeping the removed beta.58 createTable/createAppTable selector argument, selected table.state property, subscribeTable helper, or SubscribeSource type after beta.59.' - - 'Reading atom or store snapshots outside a tracked Svelte scope and expecting the read itself to keep a consumer reactive.' - - 'Reading table.store.get() in an effect that only needs one atom slice, causing unrelated state changes to rerun the effect.' - - 'Pairing onSliceChange with a controlled state slice that is not actually written back with value-or-updater semantics.' - - 'Blaming pagination reactivity when autoResetPageIndex immediately overwrites an externally requested page.' - - - slug: migrate-v8-to-v9 - package: '@tanstack/svelte-table' - domain: framework-adapters - type: migration - framework: svelte - purpose: 'Move Svelte 4/v8 store-oriented tables to the Svelte 5 v9 adapter, explicit features, and rune-backed state.' - sources: - [ - 'TanStack/table:docs/framework/svelte/guide/migrating.md', - 'TanStack/table:packages/svelte-table/src/index.ts', - 'TanStack/table:examples/svelte/basic-create-table', - ] - failure_modes: - - 'Attempting the v9 adapter migration without first adopting Svelte 5-compatible component and reactivity syntax.' - - 'Keeping readable-store assumptions or v8 row-model table options after switching to createTable.' - - 'Keeping beta.58 creation selectors, table.state, subscribeTable, or their removed selected-state generic parameters after beta.59.' - - 'Missing shared v9 prototype, feature, helper, sorting, and logical-pinning changes.' - - - slug: create-table-hook - package: '@tanstack/svelte-table' - domain: framework-adapters - type: framework - framework: svelte - purpose: 'Define a reusable Svelte createAppTable, typed column helper, and optional component/context registry.' - sources: - [ - 'TanStack/table:docs/framework/svelte/guide/composable-tables.md', - 'TanStack/table:examples/svelte/composable-tables', - 'TanStack/table:packages/svelte-table/src/createTableHook.svelte.ts', - ] - failure_modes: - - 'Reimplementing createAppTable around the framework-agnostic core instead of using the shipped rune-capable createTableHook implementation.' - - 'Passing $state snapshots instead of getters to createAppTable, freezing data or controlled state.' - - 'Prop-drilling contexts through registered components instead of consuming the typed hooks under matching App wrappers.' - - - slug: with-tanstack-query + purpose: + Create a Svelte 5 table with createTable, rune-backed option getters, + FlexRender, and headless markup. + sources: + - TanStack/table:docs/framework/svelte/guide/migrating.md + - TanStack/table:examples/svelte/basic-create-table + - TanStack/table:packages/svelte-table/src/index.ts + - TanStack/table:docs/framework/svelte/guide/composable-tables.md + - TanStack/table:examples/svelte/composable-tables + - TanStack/table:packages/svelte-table/src/createTableHook.svelte.ts + - TanStack/table:examples/svelte/with-tanstack-query + - TanStack/table:docs/framework/svelte/guide/pagination.md + - TanStack/table:docs/framework/svelte/guide/virtualization.md + - TanStack/table:examples/svelte/virtualized-rows + - TanStack/table:examples/svelte/virtualized-columns + - TanStack/table:examples/svelte/virtualized-infinite-scrolling + failure_modes: + - Using the v8 createSvelteTable/store API or pre-Svelte-5 syntax instead + of v9 createTable and runes. + - Passing a one-time data snapshot where a getter is needed for current + rune state. + - Expecting render helpers to initialize interactive markup or provide + table CSS automatically. + references: + - slug: create-table-hook + purpose: + Define a reusable Svelte createAppTable, typed column helper, and + optional component/context registry. + sources: + - TanStack/table:docs/framework/svelte/guide/composable-tables.md + - TanStack/table:examples/svelte/composable-tables + - TanStack/table:packages/svelte-table/src/createTableHook.svelte.ts + failure_modes: + - Reimplementing createAppTable around the framework-agnostic core + instead of using the shipped rune-capable createTableHook + implementation. + - Passing $state snapshots instead of getters to createAppTable, + freezing data or controlled state. + - Prop-drilling contexts through registered components instead of + consuming the typed hooks under matching App wrappers. + path: references/create-table-hook.md + replaces: '@tanstack/svelte-table#create-table-hook' + - slug: with-tanstack-query + purpose: + Connect Svelte Query data and query keys to manual Table processing + state. + sources: + - TanStack/table:examples/svelte/with-tanstack-query + - TanStack/table:docs/framework/svelte/guide/pagination.md + failure_modes: + - Building a query from non-reactive snapshots so page, sort, or + filter changes do not refetch. + - Duplicating query data into unsynchronized $state rather than + exposing the query result to Table through a getter. + - Expecting manual Table flags to execute network requests or server + transformations. + path: references/with-tanstack-query.md + replaces: '@tanstack/svelte-table#with-tanstack-query' + - slug: with-tanstack-virtual + purpose: + Render Svelte Table row/column models through Svelte Virtual with + stable measurement and layout. + sources: + - TanStack/table:docs/framework/svelte/guide/virtualization.md + - TanStack/table:examples/svelte/virtualized-rows + - TanStack/table:examples/svelte/virtualized-columns + - TanStack/table:examples/svelte/virtualized-infinite-scrolling + failure_modes: + - Using a stale row count or scroll element instead of reactive values + available to the virtualizer. + - Virtualizing source data rather than the final Table row model. + - Combining absolute positioning, transforms, sticky regions, and + semantic table layout without the required CSS geometry. + path: references/with-tanstack-virtual.md + replaces: '@tanstack/svelte-table#with-tanstack-virtual' + description: + Create and render Table v9 with the svelte adapter. Route reusable + createTableHook components, Query and Virtual integration, and framework + setup; use table-state for reactive ownership. + requires: + - '@tanstack/table-core#core' + - slug: table-state package: '@tanstack/svelte-table' domain: framework-adapters - type: integration + type: framework framework: svelte - purpose: 'Connect Svelte Query data and query keys to manual Table processing state.' - sources: - [ - 'TanStack/table:examples/svelte/with-tanstack-query', - 'TanStack/table:docs/framework/svelte/guide/pagination.md', - ] - failure_modes: - - 'Building a query from non-reactive snapshots so page, sort, or filter changes do not refetch.' - - 'Duplicating query data into unsynchronized $state rather than exposing the query result to Table through a getter.' - - 'Expecting manual Table flags to execute network requests or server transformations.' - - - slug: with-tanstack-virtual + purpose: Use rune-aware table atoms and stores, native $derived projections, + controlled $state or createTableState slices, and external atoms without + broad invalidation or snapshot mismatches. + sources: + - TanStack/table:docs/framework/svelte/guide/table-state.md + - TanStack/table:docs/framework/svelte/guide/pagination.md + - TanStack/table:examples/svelte/basic-external-state + - TanStack/table:packages/svelte-table/src/createTable.svelte.ts + - TanStack/table:packages/svelte-table/src/createTableState.svelte.ts + failure_modes: + - Keeping the removed beta.58 createTable/createAppTable selector + argument, selected table.state property, subscribeTable helper, or + SubscribeSource type after beta.59. + - Reading atom or store snapshots outside a tracked Svelte scope and + expecting the read itself to keep a consumer reactive. + - Reading table.store.get() in an effect that only needs one atom slice, + causing unrelated state changes to rerun the effect. + - Pairing onSliceChange with a controlled state slice that is not actually + written back with value-or-updater semantics. + - Blaming pagination reactivity when autoResetPageIndex immediately + overwrites an externally requested page. + references: + - path: references/reactivity.md + purpose: + Read for advanced svelte reactive boundaries, subscription patterns, + and complete framework-specific state examples. + sources: + - TanStack/table:docs/framework/svelte/guide/table-state.md + - TanStack/table:docs/framework/svelte/guide/pagination.md + - TanStack/table:examples/svelte/basic-external-state + - TanStack/table:packages/svelte-table/src/createTable.svelte.ts + - TanStack/table:packages/svelte-table/src/createTableState.svelte.ts + failure_modes: + - Keeping the removed beta.58 createTable/createAppTable selector + argument, selected table.state property, subscribeTable helper, or + SubscribeSource type after beta.59. + - Reading atom or store snapshots outside a tracked Svelte scope and + expecting the read itself to keep a consumer reactive. + - Reading table.store.get() in an effect that only needs one atom + slice, causing unrelated state changes to rerun the effect. + - Pairing onSliceChange with a controlled state slice that is not + actually written back with value-or-updater semantics. + - Blaming pagination reactivity when autoResetPageIndex immediately + overwrites an externally requested page. + description: + Read and control Table v9 state in svelte. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' + - slug: migrate-v8-to-v9 package: '@tanstack/svelte-table' domain: framework-adapters - type: integration + type: migration framework: svelte - purpose: 'Render Svelte Table row/column models through Svelte Virtual with stable measurement and layout.' - sources: - [ - 'TanStack/table:docs/framework/svelte/guide/virtualization.md', - 'TanStack/table:examples/svelte/virtualized-rows', - 'TanStack/table:examples/svelte/virtualized-columns', - 'TanStack/table:examples/svelte/virtualized-infinite-scrolling', - ] - failure_modes: - - 'Using a stale row count or scroll element instead of reactive values available to the virtualizer.' - - 'Virtualizing source data rather than the final Table row model.' - - 'Combining absolute positioning, transforms, sticky regions, and semantic table layout without the required CSS geometry.' - + purpose: Move Svelte 4/v8 store-oriented tables to the Svelte 5 v9 adapter, + explicit features, and rune-backed state. + sources: + - TanStack/table:docs/framework/svelte/guide/migrating.md + - TanStack/table:packages/svelte-table/src/index.ts + - TanStack/table:examples/svelte/basic-create-table + failure_modes: + - Attempting the v9 adapter migration without first adopting Svelte + 5-compatible component and reactivity syntax. + - Keeping readable-store assumptions or v8 row-model table options after + switching to createTable. + - Keeping beta.58 creation selectors, table.state, subscribeTable, or + their removed selected-state generic parameters after beta.59. + - Missing shared v9 prototype, feature, helper, sorting, and + logical-pinning changes. + references: + - path: references/adapter-migration.md + purpose: + Read for svelte construction, rendering, state, and app-hook migration + details. Shared feature and type mappings belong to the core migration + references. + sources: + - TanStack/table:docs/framework/svelte/guide/migrating.md + - TanStack/table:packages/svelte-table/src/index.ts + - TanStack/table:examples/svelte/basic-create-table + failure_modes: + - Attempting the v9 adapter migration without first adopting Svelte + 5-compatible component and reactivity syntax. + - Keeping readable-store assumptions or v8 row-model table options + after switching to createTable. + - Keeping beta.58 creation selectors, table.state, subscribeTable, or + their removed selected-state generic parameters after beta.59. + - Missing shared v9 prototype, feature, helper, sorting, and + logical-pinning changes. + description: Migrate svelte Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. + requires: + - '@tanstack/table-core#migrate-v8-to-v9' - slug: getting-started package: '@tanstack/vue-table' domain: framework-adapters type: framework framework: vue - purpose: 'Create a Vue v9 table with useTable, reactive options, and template/render helpers.' - sources: - [ - 'TanStack/table:docs/framework/vue/guide/migrating.md', - 'TanStack/table:examples/vue/basic-use-table', - 'TanStack/table:packages/vue-table/src/index.ts', - ] - failure_modes: - - 'Using v8 useVueTable or React hook names instead of the installed v9 Vue entrypoint.' - - 'Destructuring reactive refs/options into snapshots before passing them to useTable.' - - 'Expecting Table to provide a Vue table component or component-library styling.' - + purpose: Create a Vue v9 table with useTable, reactive options, and + template/render helpers. + sources: + - TanStack/table:docs/framework/vue/guide/migrating.md + - TanStack/table:examples/vue/basic-use-table + - TanStack/table:packages/vue-table/src/index.ts + - TanStack/table:docs/framework/vue/guide/composable-tables.md + - TanStack/table:examples/vue/composable-tables + - TanStack/table:packages/vue-table/src/createTableHook.ts + - TanStack/table:examples/vue/with-tanstack-query + - TanStack/table:docs/framework/vue/guide/pagination.md + - TanStack/table:docs/framework/vue/guide/virtualization.md + - TanStack/table:examples/vue/virtualized-rows + - TanStack/table:examples/vue/virtualized-columns + - TanStack/table:examples/vue/virtualized-infinite-scrolling + failure_modes: + - Using v8 useVueTable or React hook names instead of the installed v9 Vue + entrypoint. + - Destructuring reactive refs/options into snapshots before passing them + to useTable. + - Expecting Table to provide a Vue table component or component-library + styling. + references: + - slug: create-table-hook + purpose: + Create a reusable Vue useAppTable and typed component/context registry + while avoiding circular inference. + sources: + - TanStack/table:docs/framework/vue/guide/composable-tables.md + - TanStack/table:examples/vue/composable-tables + - TanStack/table:packages/vue-table/src/createTableHook.ts + failure_modes: + - Using createTableHook for one table or registering reusable UI + components before the app has shared conventions. + - Creating a circular inference/import chain between the hook module + and registered components instead of exporting explicit context-hook + types. + - Passing Vue JSX children as slots when table.Subscribe expects an + explicit children prop. + path: references/create-table-hook.md + replaces: '@tanstack/vue-table#create-table-hook' + - slug: with-tanstack-query + purpose: + Drive Vue Query keys and server requests from reactive Table state with + explicit manual stages. + sources: + - TanStack/table:examples/vue/with-tanstack-query + - TanStack/table:docs/framework/vue/guide/pagination.md + failure_modes: + - Unwrapping refs before constructing the query key so table-state + changes are not dependencies. + - Mirroring query data into an unnecessary second ref and allowing the + two sources to drift. + - Omitting server counts or expecting manual Table modes to process + the returned page. + path: references/with-tanstack-query.md + replaces: '@tanstack/vue-table#with-tanstack-query' + - slug: with-tanstack-virtual + purpose: + Layer Vue Virtual rendering over the current Table row/column model and + its CSS layout. + sources: + - TanStack/table:docs/framework/vue/guide/virtualization.md + - TanStack/table:examples/vue/virtualized-rows + - TanStack/table:examples/vue/virtualized-columns + - TanStack/table:examples/vue/virtualized-infinite-scrolling + failure_modes: + - Passing non-reactive counts or scroll targets to the virtualizer. + - Virtualizing raw query/data arrays rather than the current Table + model. + - Assuming virtualization supplies column sizes, sticky CSS, semantic + markup, or dynamic-row measurement automatically. + path: references/with-tanstack-virtual.md + replaces: '@tanstack/vue-table#with-tanstack-virtual' + description: Create and render Table v9 with the vue adapter. Route reusable + createTableHook components, Query and Virtual integration, and framework + setup; use table-state for reactive ownership. + requires: + - '@tanstack/table-core#core' - slug: table-state package: '@tanstack/vue-table' domain: framework-adapters type: framework framework: vue - purpose: 'Read Vue-backed table atoms in tracked contexts and control slices with refs, computed values, or external atoms.' - sources: - [ - 'TanStack/table:docs/framework/vue/guide/table-state.md', - 'TanStack/table:examples/vue/basic-external-state', - 'TanStack/table:packages/vue-table/src/useTable.ts', - ] - failure_modes: - - 'Reading an atom snapshot outside a template, computed, watch, or other tracked context and expecting it to update consumers.' - - 'Passing a ref value snapshot rather than the ref/computed/getter shape supported by reactive table options.' - - 'Ignoring value-or-updater callback semantics when synchronizing controlled refs.' - + purpose: + Read Vue-backed table atoms in tracked contexts and control slices with + refs, computed values, or external atoms. + sources: + - TanStack/table:docs/framework/vue/guide/table-state.md + - TanStack/table:examples/vue/basic-external-state + - TanStack/table:packages/vue-table/src/useTable.ts + failure_modes: + - Reading an atom snapshot outside a template, computed, watch, or other + tracked context and expecting it to update consumers. + - Passing a ref value snapshot rather than the ref/computed/getter shape + supported by reactive table options. + - Ignoring value-or-updater callback semantics when synchronizing + controlled refs. + references: + - path: references/reactivity.md + purpose: + Read for advanced vue reactive boundaries, subscription patterns, and + complete framework-specific state examples. + sources: + - TanStack/table:docs/framework/vue/guide/table-state.md + - TanStack/table:examples/vue/basic-external-state + - TanStack/table:packages/vue-table/src/useTable.ts + failure_modes: + - Reading an atom snapshot outside a template, computed, watch, or + other tracked context and expecting it to update consumers. + - Passing a ref value snapshot rather than the ref/computed/getter + shape supported by reactive table options. + - Ignoring value-or-updater callback semantics when synchronizing + controlled refs. + description: Read and control Table v9 state in vue. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' - slug: migrate-v8-to-v9 package: '@tanstack/vue-table' domain: framework-adapters type: migration framework: vue - purpose: 'Migrate Vue v8 table construction, row models, state, helpers, and rendering to v9.' - sources: - [ - 'TanStack/table:docs/framework/vue/guide/migrating.md', - 'TanStack/table:packages/vue-table/src/index.ts', - 'TanStack/table:examples/vue/basic-use-table', - ] - failure_modes: - - 'Changing the hook name while retaining v8 row-model options and implicit all-feature behavior.' - - 'Flattening refs/computed inputs during migration and losing Vue reactivity.' - - 'Missing shared v9 changes to prototype methods, per-table meta, sortFn names, and start/end pinning.' - - - slug: create-table-hook - package: '@tanstack/vue-table' - domain: framework-adapters - type: framework - framework: vue - purpose: 'Create a reusable Vue useAppTable and typed component/context registry while avoiding circular inference.' - sources: - [ - 'TanStack/table:docs/framework/vue/guide/composable-tables.md', - 'TanStack/table:examples/vue/composable-tables', - 'TanStack/table:packages/vue-table/src/createTableHook.ts', - ] - failure_modes: - - 'Using createTableHook for one table or registering reusable UI components before the app has shared conventions.' - - 'Creating a circular inference/import chain between the hook module and registered components instead of exporting explicit context-hook types.' - - 'Passing Vue JSX children as slots when table.Subscribe expects an explicit children prop.' - - - slug: with-tanstack-query - package: '@tanstack/vue-table' - domain: framework-adapters - type: integration - framework: vue - purpose: 'Drive Vue Query keys and server requests from reactive Table state with explicit manual stages.' - sources: - [ - 'TanStack/table:examples/vue/with-tanstack-query', - 'TanStack/table:docs/framework/vue/guide/pagination.md', - ] - failure_modes: - - 'Unwrapping refs before constructing the query key so table-state changes are not dependencies.' - - 'Mirroring query data into an unnecessary second ref and allowing the two sources to drift.' - - 'Omitting server counts or expecting manual Table modes to process the returned page.' - - - slug: with-tanstack-virtual - package: '@tanstack/vue-table' - domain: framework-adapters - type: integration - framework: vue - purpose: 'Layer Vue Virtual rendering over the current Table row/column model and its CSS layout.' - sources: - [ - 'TanStack/table:docs/framework/vue/guide/virtualization.md', - 'TanStack/table:examples/vue/virtualized-rows', - 'TanStack/table:examples/vue/virtualized-columns', - 'TanStack/table:examples/vue/virtualized-infinite-scrolling', - ] - failure_modes: - - 'Passing non-reactive counts or scroll targets to the virtualizer.' - - 'Virtualizing raw query/data arrays rather than the current Table model.' - - 'Assuming virtualization supplies column sizes, sticky CSS, semantic markup, or dynamic-row measurement automatically.' - + purpose: Migrate Vue v8 table construction, row models, state, helpers, and + rendering to v9. + sources: + - TanStack/table:docs/framework/vue/guide/migrating.md + - TanStack/table:packages/vue-table/src/index.ts + - TanStack/table:examples/vue/basic-use-table + failure_modes: + - Changing the hook name while retaining v8 row-model options and implicit + all-feature behavior. + - Flattening refs/computed inputs during migration and losing Vue + reactivity. + - Missing shared v9 changes to prototype methods, per-table meta, sortFn + names, and start/end pinning. + references: + - path: references/adapter-migration.md + purpose: + Read for vue construction, rendering, state, and app-hook migration + details. Shared feature and type mappings belong to the core migration + references. + sources: + - TanStack/table:docs/framework/vue/guide/migrating.md + - TanStack/table:packages/vue-table/src/index.ts + - TanStack/table:examples/vue/basic-use-table + failure_modes: + - Changing the hook name while retaining v8 row-model options and + implicit all-feature behavior. + - Flattening refs/computed inputs during migration and losing Vue + reactivity. + - Missing shared v9 changes to prototype methods, per-table meta, + sortFn names, and start/end pinning. + description: Migrate vue Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. + requires: + - '@tanstack/table-core#migrate-v8-to-v9' - slug: getting-started package: '@tanstack/angular-table' domain: framework-adapters type: framework framework: angular - purpose: 'Create an Angular v9 table with injectTable, stable options, signals, and FlexRender directives.' - sources: - [ - 'TanStack/table:docs/framework/angular/guide/migrating.md', - 'TanStack/table:docs/framework/angular/guide/rendering.md', - 'TanStack/table:examples/angular/basic-inject-table', - 'TanStack/table:packages/angular-table/src/index.ts', - ] - failure_modes: - - 'Calling injectTable outside a valid Angular injection context.' - - 'Allocating columns or features inside the signal-tracked options initializer so every signal change rebuilds static inputs.' - - 'Treating render functions as Angular components or bypassing the documented structural directives and context injection rules.' - + purpose: + Create an Angular v9 table with injectTable, stable options, signals, + and FlexRender directives. + sources: + - TanStack/table:docs/framework/angular/guide/migrating.md + - TanStack/table:docs/framework/angular/guide/flex-render.md + - TanStack/table:examples/angular/basic-inject-table + - TanStack/table:packages/angular-table/src/index.ts + - TanStack/table:docs/framework/angular/guide/composable-tables.md + - TanStack/table:examples/angular/composable-tables + - TanStack/table:packages/angular-table/src/helpers/createTableHook.ts + - TanStack/table:examples/angular/with-tanstack-query + - TanStack/table:docs/framework/angular/guide/table-state.md + - TanStack/table:docs/framework/angular/guide/pagination.md + - TanStack/table:docs/framework/angular/guide/virtualization.md + - TanStack/table:examples/angular/virtualized-rows + - TanStack/table:examples/angular/virtualized-columns + - TanStack/table:examples/angular/virtualized-infinite-scrolling + failure_modes: + - Calling injectTable outside a valid Angular injection context. + - Allocating columns or features inside the signal-tracked options + initializer so every signal change rebuilds static inputs. + - Treating render functions as Angular components or bypassing the + documented structural directives and context injection rules. + references: + - slug: create-table-hook + purpose: Create a typed injectAppTable abstraction with shared features, + defaults, components, and DI context. + sources: + - TanStack/table:docs/framework/angular/guide/composable-tables.md + - TanStack/table:examples/angular/composable-tables + - TanStack/table:packages/angular-table/src/helpers/createTableHook.ts + failure_modes: + - Calling injectAppTable or returned context injectors outside Angular + injection context. + - Prop-drilling table/cell/header values into registered components + instead of using the returned typed injection helpers. + - Treating arbitrary render values as Angular components and passing + them to flexRenderComponent. + path: references/create-table-hook.md + replaces: '@tanstack/angular-table#create-table-hook' + - slug: with-tanstack-query + purpose: + Connect Angular Query to signal-owned Table state and manual server + processing. + sources: + - TanStack/table:examples/angular/with-tanstack-query + - TanStack/table:docs/framework/angular/guide/table-state.md + - TanStack/table:docs/framework/angular/guide/pagination.md + failure_modes: + - Reading query-key signals outside a reactive query options function + and preventing refetches. + - Duplicating query data into another signal without a defined + editing/cache ownership model. + - Expecting manual Table flags to fetch data or omitting row/page + counts required for navigation. + path: references/with-tanstack-query.md + replaces: '@tanstack/angular-table#with-tanstack-query' + - slug: with-tanstack-virtual + purpose: + Render Angular Table models through Angular Virtual with correct + signals, measurements, and infinite fetching. + sources: + - TanStack/table:docs/framework/angular/guide/virtualization.md + - TanStack/table:examples/angular/virtualized-rows + - TanStack/table:examples/angular/virtualized-columns + - TanStack/table:examples/angular/virtualized-infinite-scrolling + failure_modes: + - Constructing the virtualizer outside required Angular + injection/reactive context or from stale counts. + - Virtualizing input data rather than the current Table row model. + - Combining measured rows, transforms, sticky regions, and grid/flex + sizing without the example layout contract. + path: references/with-tanstack-virtual.md + replaces: '@tanstack/angular-table#with-tanstack-virtual' + description: + Create and render Table v9 with the angular adapter. Route reusable + createTableHook components, Query and Virtual integration, and framework + setup; use table-state for reactive ownership. + requires: + - '@tanstack/table-core#core' - slug: table-state package: '@tanstack/angular-table' domain: framework-adapters type: framework framework: angular - purpose: 'Use Angular-signal-backed table atoms, computed selectors, controlled signals, and external Store atoms correctly.' - sources: - [ - 'TanStack/table:docs/framework/angular/guide/table-state.md', - 'TanStack/table:examples/angular/basic-external-state', - 'TanStack/table:packages/angular-table/src/injectTable.ts', - ] - failure_modes: - - 'Wrapping every atom read in computed just to make it reactive even though table atoms already read Angular signals.' - - 'Reading controlled signals in injectTable and overlooking that each write reruns the initializer and setOptions.' - - 'Assigning updater functions directly to signals instead of resolving Table value-or-updater callbacks.' - + purpose: + Use Angular-signal-backed table atoms, computed selectors, controlled + signals, and external Store atoms correctly. + sources: + - TanStack/table:docs/framework/angular/guide/table-state.md + - TanStack/table:examples/angular/basic-external-state + - TanStack/table:packages/angular-table/src/injectTable.ts + failure_modes: + - Wrapping every atom read in computed just to make it reactive even + though table atoms already read Angular signals. + - Reading controlled signals in injectTable and overlooking that each + write reruns the initializer and setOptions. + - Assigning updater functions directly to signals instead of resolving + Table value-or-updater callbacks. + references: + - path: references/reactivity.md + purpose: + Read for advanced angular reactive boundaries, subscription patterns, + and complete framework-specific state examples. + sources: + - TanStack/table:docs/framework/angular/guide/table-state.md + - TanStack/table:examples/angular/basic-external-state + - TanStack/table:packages/angular-table/src/injectTable.ts + failure_modes: + - Wrapping every atom read in computed just to make it reactive even + though table atoms already read Angular signals. + - Reading controlled signals in injectTable and overlooking that each + write reruns the initializer and setOptions. + - Assigning updater functions directly to signals instead of resolving + Table value-or-updater callbacks. + description: + Read and control Table v9 state in angular. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' - slug: migrate-v8-to-v9 package: '@tanstack/angular-table' domain: framework-adapters type: migration framework: angular - purpose: 'Migrate createAngularTable code to injectTable, v9 features, signal-backed state, and current rendering directives.' - sources: - [ - 'TanStack/table:docs/framework/angular/guide/migrating.md', - 'TanStack/table:packages/angular-table/src/index.ts', - 'TanStack/table:examples/angular/basic-inject-table', - ] - failure_modes: - - 'Renaming createAngularTable to injectTable without moving construction into an injection context.' - - 'Retaining v8 get*RowModel options or unstable values inside the reactive initializer.' - - 'Missing FlexRender directive, prototype-method, helper, sorting, and logical-pinning changes.' - - - slug: create-table-hook - package: '@tanstack/angular-table' - domain: framework-adapters - type: framework - framework: angular - purpose: 'Create a typed injectAppTable abstraction with shared features, defaults, components, and DI context.' - sources: - [ - 'TanStack/table:docs/framework/angular/guide/composable-tables.md', - 'TanStack/table:examples/angular/composable-tables', - 'TanStack/table:packages/angular-table/src/helpers/createTableHook.ts', - ] - failure_modes: - - 'Calling injectAppTable or returned context injectors outside Angular injection context.' - - 'Prop-drilling table/cell/header values into registered components instead of using the returned typed injection helpers.' - - 'Treating arbitrary render values as Angular components and passing them to flexRenderComponent.' - - - slug: with-tanstack-query - package: '@tanstack/angular-table' - domain: framework-adapters - type: integration - framework: angular - purpose: 'Connect Angular Query to signal-owned Table state and manual server processing.' - sources: - [ - 'TanStack/table:examples/angular/with-tanstack-query', - 'TanStack/table:docs/framework/angular/guide/table-state.md', - 'TanStack/table:docs/framework/angular/guide/pagination.md', - ] - failure_modes: - - 'Reading query-key signals outside a reactive query options function and preventing refetches.' - - 'Duplicating query data into another signal without a defined editing/cache ownership model.' - - 'Expecting manual Table flags to fetch data or omitting row/page counts required for navigation.' - - - slug: with-tanstack-virtual - package: '@tanstack/angular-table' - domain: framework-adapters - type: integration - framework: angular - purpose: 'Render Angular Table models through Angular Virtual with correct signals, measurements, and infinite fetching.' - sources: - [ - 'TanStack/table:docs/framework/angular/guide/virtualization.md', - 'TanStack/table:examples/angular/virtualized-rows', - 'TanStack/table:examples/angular/virtualized-columns', - 'TanStack/table:examples/angular/virtualized-infinite-scrolling', - ] - failure_modes: - - 'Constructing the virtualizer outside required Angular injection/reactive context or from stale counts.' - - 'Virtualizing input data rather than the current Table row model.' - - 'Combining measured rows, transforms, sticky regions, and grid/flex sizing without the example layout contract.' - + purpose: Migrate createAngularTable code to injectTable, v9 features, + signal-backed state, and current rendering directives. + sources: + - TanStack/table:docs/framework/angular/guide/migrating.md + - TanStack/table:packages/angular-table/src/index.ts + - TanStack/table:examples/angular/basic-inject-table + failure_modes: + - Renaming createAngularTable to injectTable without moving construction + into an injection context. + - Retaining v8 get*RowModel options or unstable values inside the reactive + initializer. + - Missing FlexRender directive, prototype-method, helper, sorting, and + logical-pinning changes. + references: + - path: references/adapter-migration.md + purpose: + Read for angular construction, rendering, state, and app-hook migration + details. Shared feature and type mappings belong to the core migration + references. + sources: + - TanStack/table:docs/framework/angular/guide/migrating.md + - TanStack/table:packages/angular-table/src/index.ts + - TanStack/table:examples/angular/basic-inject-table + failure_modes: + - Renaming createAngularTable to injectTable without moving + construction into an injection context. + - Retaining v8 get*RowModel options or unstable values inside the + reactive initializer. + - Missing FlexRender directive, prototype-method, helper, sorting, and + logical-pinning changes. + description: Migrate angular Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. + requires: + - '@tanstack/table-core#migrate-v8-to-v9' - slug: getting-started package: '@tanstack/lit-table' domain: framework-adapters type: framework framework: lit - purpose: 'Create and render a v9 Lit table through TableController and reactive host updates.' - sources: - [ - 'TanStack/table:docs/framework/lit/guide/migrating.md', - 'TanStack/table:examples/lit/basic-table-controller', - 'TanStack/table:packages/lit-table/src/index.ts', - ] - failure_modes: - - 'Using the v8 TableController constructor-with-options thunk instead of passing options to controller.table in render.' - - 'Constructing a new controller or selector on every render rather than keeping stable host fields.' - - 'Expecting TableController to supply semantic table markup, CSS, or a component library.' - + purpose: + Create and render a v9 Lit table through TableController and reactive + host updates. + sources: + - TanStack/table:docs/framework/lit/guide/migrating.md + - TanStack/table:examples/lit/basic-table-controller + - TanStack/table:packages/lit-table/src/index.ts + - TanStack/table:docs/framework/lit/guide/composable-tables.md + - TanStack/table:examples/lit/composable-tables + - TanStack/table:packages/lit-table/src/createTableHook.ts + - TanStack/table:docs/framework/lit/guide/virtualization.md + - TanStack/table:examples/lit/virtualized-rows + - TanStack/table:examples/lit/virtualized-columns + - TanStack/table:examples/lit/virtualized-infinite-scrolling + failure_modes: + - Using the v8 TableController constructor-with-options thunk instead of + passing options to controller.table in render. + - Constructing a new controller or selector on every render rather than + keeping stable host fields. + - Expecting TableController to supply semantic table markup, CSS, or a + component library. + references: + - slug: create-table-hook + purpose: + Create a reusable Lit app-table controller/helper layer and consume + table context from custom elements. + sources: + - TanStack/table:docs/framework/lit/guide/composable-tables.md + - TanStack/table:examples/lit/composable-tables + - TanStack/table:packages/lit-table/src/createTableHook.ts + failure_modes: + - Calling useAppTable without the Lit host or recreating the backing + controller every update. + - Assuming Lit tableComponents work exactly like JSX adapter + registries; table-level controls may be custom elements using + useTableContext. + - Prop-drilling a stable table through custom elements instead of + consuming the nearest typed app-table context. + path: references/create-table-hook.md + replaces: '@tanstack/lit-table#create-table-hook' + - slug: with-tanstack-virtual + purpose: + Layer Lit Virtual rendering and measurement over the current Table + model. + sources: + - TanStack/table:docs/framework/lit/guide/virtualization.md + - TanStack/table:examples/lit/virtualized-rows + - TanStack/table:examples/lit/virtualized-columns + - TanStack/table:examples/lit/virtualized-infinite-scrolling + failure_modes: + - Creating a virtualizer/controller with the wrong host lifecycle or a + stale item count. + - Virtualizing raw input data instead of table.getRowModel().rows. + - Assuming Virtual or Table owns absolute positioning, measurement + attributes, sticky CSS, or column widths. + path: references/with-tanstack-virtual.md + replaces: '@tanstack/lit-table#with-tanstack-virtual' + description: Create and render Table v9 with the lit adapter. Route reusable + createTableHook components, Virtual integration, and framework setup; use + table-state for reactive ownership. + requires: + - '@tanstack/table-core#core' - slug: table-state package: '@tanstack/lit-table' domain: framework-adapters type: framework framework: lit - purpose: 'Use TableController-selected table.state, stable subscriptions, controlled properties, and external atoms.' - sources: - [ - 'TanStack/table:docs/framework/lit/guide/table-state.md', - 'TanStack/table:examples/lit/basic-external-state', - 'TanStack/table:packages/lit-table/src/TableController.ts', - ] - failure_modes: - - 'Reading store snapshots imperatively and assuming the host is subscribed to a custom derived value not selected or subscribed.' - - 'Creating selector functions inside render and causing avoidable subscription/update churn.' - - 'Providing onSliceChange without reflecting the controlled state.slice back into the next controller.table options.' - + purpose: Use TableController-selected table.state, stable subscriptions, + controlled properties, and external atoms. + sources: + - TanStack/table:docs/framework/lit/guide/table-state.md + - TanStack/table:examples/lit/basic-external-state + - TanStack/table:packages/lit-table/src/TableController.ts + failure_modes: + - Reading store snapshots imperatively and assuming the host is subscribed + to a custom derived value not selected or subscribed. + - Creating selector functions inside render and causing avoidable + subscription/update churn. + - Providing onSliceChange without reflecting the controlled state.slice + back into the next controller.table options. + references: + - path: references/reactivity.md + purpose: + Read for advanced lit reactive boundaries, subscription patterns, and + complete framework-specific state examples. + sources: + - TanStack/table:docs/framework/lit/guide/table-state.md + - TanStack/table:examples/lit/basic-external-state + - TanStack/table:packages/lit-table/src/TableController.ts + failure_modes: + - Reading store snapshots imperatively and assuming the host is + subscribed to a custom derived value not selected or subscribed. + - Creating selector functions inside render and causing avoidable + subscription/update churn. + - Providing onSliceChange without reflecting the controlled + state.slice back into the next controller.table options. + description: Read and control Table v9 state in lit. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' - slug: migrate-v8-to-v9 package: '@tanstack/lit-table' domain: framework-adapters type: migration framework: lit - purpose: 'Migrate Lit v8 controller construction, row models, state, helpers, and rendering to v9.' - sources: - [ - 'TanStack/table:docs/framework/lit/guide/migrating.md', - 'TanStack/table:packages/lit-table/src/index.ts', - 'TanStack/table:examples/lit/basic-table-controller', - ] - failure_modes: - - 'Passing the options thunk to the v9 TableController constructor instead of controller.table during render.' - - 'Keeping v8 get*RowModel table options rather than v9 tableFeatures slots.' - - 'Missing shared v9 prototype-method, meta-helper, sorting, and start/end pinning changes.' - - - slug: create-table-hook - package: '@tanstack/lit-table' - domain: framework-adapters - type: framework - framework: lit - purpose: 'Create a reusable Lit app-table controller/helper layer and consume table context from custom elements.' - sources: - [ - 'TanStack/table:docs/framework/lit/guide/composable-tables.md', - 'TanStack/table:examples/lit/composable-tables', - 'TanStack/table:packages/lit-table/src/createTableHook.ts', - ] - failure_modes: - - 'Calling useAppTable without the Lit host or recreating the backing controller every update.' - - 'Assuming Lit tableComponents work exactly like JSX adapter registries; table-level controls may be custom elements using useTableContext.' - - 'Prop-drilling a stable table through custom elements instead of consuming the nearest typed app-table context.' - - - slug: with-tanstack-virtual - package: '@tanstack/lit-table' - domain: framework-adapters - type: integration - framework: lit - purpose: 'Layer Lit Virtual rendering and measurement over the current Table model.' - sources: - [ - 'TanStack/table:docs/framework/lit/guide/virtualization.md', - 'TanStack/table:examples/lit/virtualized-rows', - 'TanStack/table:examples/lit/virtualized-columns', - 'TanStack/table:examples/lit/virtualized-infinite-scrolling', - ] - failure_modes: - - 'Creating a virtualizer/controller with the wrong host lifecycle or a stale item count.' - - 'Virtualizing raw input data instead of table.getRowModel().rows.' - - 'Assuming Virtual or Table owns absolute positioning, measurement attributes, sticky CSS, or column widths.' - + purpose: + Migrate Lit v8 controller construction, row models, state, helpers, and + rendering to v9. + sources: + - TanStack/table:docs/framework/lit/guide/migrating.md + - TanStack/table:packages/lit-table/src/index.ts + - TanStack/table:examples/lit/basic-table-controller + failure_modes: + - Passing the options thunk to the v9 TableController constructor instead + of controller.table during render. + - Keeping v8 get*RowModel table options rather than v9 tableFeatures slots. + - Missing shared v9 prototype-method, meta-helper, sorting, and start/end + pinning changes. + references: + - path: references/adapter-migration.md + purpose: + Read for lit construction, rendering, state, and app-hook migration + details. Shared feature and type mappings belong to the core migration + references. + sources: + - TanStack/table:docs/framework/lit/guide/migrating.md + - TanStack/table:packages/lit-table/src/index.ts + - TanStack/table:examples/lit/basic-table-controller + failure_modes: + - Passing the options thunk to the v9 TableController constructor + instead of controller.table during render. + - Keeping v8 get*RowModel table options rather than v9 tableFeatures + slots. + - Missing shared v9 prototype-method, meta-helper, sorting, and + start/end pinning changes. + description: Migrate lit Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. + requires: + - '@tanstack/table-core#migrate-v8-to-v9' - slug: getting-started package: '@tanstack/octane-table' domain: framework-adapters type: framework framework: octane - purpose: 'Create and render an Octane v9 table with application-authored TSRX, stable inputs, keyed lists, and component-scoped render helpers.' - sources: - [ - 'TanStack/table:docs/framework/octane/quick-start.md', - 'TanStack/table:examples/octane/basic-use-table', - 'TanStack/table:packages/octane-table/src/index.ts', - 'TanStack/table:packages/octane-table/src/useTable.tsrx', - ] - failure_modes: - - 'Importing another framework adapter or translating React component-return semantics directly instead of using Octane TSRX component bodies.' - - 'Invoking FlexRender or other component-scoped helpers as plain functions instead of rendering them as components.' - - 'Recreating stable features, columns, or data on each render and causing unnecessary option and row-model work.' - + purpose: + Create and render an Octane v9 table with application-authored TSRX, + stable inputs, keyed lists, and component-scoped render helpers. + sources: + - TanStack/table:docs/framework/octane/quick-start.md + - TanStack/table:examples/octane/basic-use-table + - TanStack/table:packages/octane-table/src/index.ts + - TanStack/table:packages/octane-table/src/useTable.tsrx + - TanStack/table:docs/framework/octane/guide/composable-tables.md + - TanStack/table:docs/framework/octane/guide/table-context.md + - TanStack/table:examples/octane/composable-tables + - TanStack/table:packages/octane-table/src/createTableHook.tsrx + - TanStack/table:packages/octane-table/src/createTableHookContexts.ts + failure_modes: + - Importing another framework adapter or translating React + component-return semantics directly instead of using Octane TSRX + component bodies. + - Invoking FlexRender or other component-scoped helpers as plain functions + instead of rendering them as components. + - Recreating stable features, columns, or data on each render and causing + unnecessary option and row-model work. + references: + - slug: create-table-hook + purpose: + Build a typed reusable Octane table hook with stable App wrappers, + registered components, and default or isolated contexts. + sources: + - TanStack/table:docs/framework/octane/guide/composable-tables.md + - TanStack/table:docs/framework/octane/guide/table-context.md + - TanStack/table:examples/octane/composable-tables + - TanStack/table:packages/octane-table/src/createTableHook.tsrx + - TanStack/table:packages/octane-table/src/createTableHookContexts.ts + failure_modes: + - Using the app hook for one table when standalone useTable is clearer. + - Reading a factory context outside its matching + AppTable/AppCell/AppHeader provider or invoking a wrapper as a plain + function. + - Creating the factory in render and destabilizing wrapper, context, + and registered-component identities. + path: references/create-table-hook.md + replaces: '@tanstack/octane-table#create-table-hook' + description: + Create and render Table v9 with the octane adapter. Route reusable + createTableHook components, and framework setup; use table-state for + reactive ownership. + requires: + - '@tanstack/table-core#core' - slug: table-state package: '@tanstack/octane-table' domain: framework-adapters type: framework framework: octane - purpose: 'Use selected table.state, component-scoped Subscribe islands, controlled slices, and synchronous Octane Store atom ownership with commit-safe publication.' - sources: - [ - 'TanStack/table:docs/framework/octane/guide/table-state.md', - 'TanStack/table:examples/octane/basic-subscribe', - 'TanStack/table:examples/octane/basic-external-atoms', - 'TanStack/table:packages/octane-table/src/useTable.tsrx', - 'TanStack/table:packages/octane-table/src/Subscribe.tsrx', - ] - failure_modes: - - 'Reading atom/store snapshots in render as though they establish an Octane subscription.' - - 'Calling table.Subscribe as a normal function and sharing compiler slots instead of mounting an independent component scope.' - - 'Expecting controlled options.state to publish during render, or mixing it with an external atom that has ownership precedence.' - - - slug: create-table-hook - package: '@tanstack/octane-table' - domain: framework-adapters - type: framework - framework: octane - purpose: 'Build a typed reusable Octane table hook with stable App wrappers, registered components, and default or isolated contexts.' - sources: - [ - 'TanStack/table:docs/framework/octane/guide/composable-tables.md', - 'TanStack/table:docs/framework/octane/guide/table-context.md', - 'TanStack/table:examples/octane/composable-tables', - 'TanStack/table:packages/octane-table/src/createTableHook.tsrx', - 'TanStack/table:packages/octane-table/src/createTableHookContexts.ts', - ] - failure_modes: - - 'Using the app hook for one table when standalone useTable is clearer.' - - 'Reading a factory context outside its matching AppTable/AppCell/AppHeader provider or invoking a wrapper as a plain function.' - - 'Creating the factory in render and destabilizing wrapper, context, and registered-component identities.' - + purpose: Use selected table.state, component-scoped Subscribe islands, + controlled slices, and synchronous Octane Store atom ownership with + commit-safe publication. + sources: + - TanStack/table:docs/framework/octane/guide/table-state.md + - TanStack/table:examples/octane/basic-subscribe + - TanStack/table:examples/octane/basic-external-atoms + - TanStack/table:packages/octane-table/src/useTable.tsrx + - TanStack/table:packages/octane-table/src/Subscribe.tsrx + failure_modes: + - Reading atom/store snapshots in render as though they establish an + Octane subscription. + - Calling table.Subscribe as a normal function and sharing compiler slots + instead of mounting an independent component scope. + - Expecting controlled options.state to publish during render, or mixing + it with an external atom that has ownership precedence. + references: + - path: references/reactivity.md + purpose: + Read for advanced octane reactive boundaries, subscription patterns, + and complete framework-specific state examples. + sources: + - TanStack/table:docs/framework/octane/guide/table-state.md + - TanStack/table:examples/octane/basic-subscribe + - TanStack/table:examples/octane/basic-external-atoms + - TanStack/table:packages/octane-table/src/useTable.tsrx + - TanStack/table:packages/octane-table/src/Subscribe.tsrx + failure_modes: + - Reading atom/store snapshots in render as though they establish an + Octane subscription. + - Calling table.Subscribe as a normal function and sharing compiler + slots instead of mounting an independent component scope. + - Expecting controlled options.state to publish during render, or + mixing it with an external atom that has ownership precedence. + description: + Read and control Table v9 state in octane. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' - slug: getting-started package: '@tanstack/ember-table' domain: framework-adapters type: framework framework: ember - purpose: 'Create an Ember v9 table through the tracked useTable options thunk and render it with Glimmer-native FlexRender components.' - sources: - [ - 'TanStack/table:docs/framework/ember/quick-start.md', - 'TanStack/table:examples/ember/basic-table', - 'TanStack/table:packages/ember-table/src/index.ts', - 'TanStack/table:packages/ember-table/src/use-table.ts', - 'TanStack/table:packages/ember-table/src/FlexRender.gts', - ] - failure_modes: - - 'Passing an options object instead of a thunk, or failing to read tracked data inside that thunk.' - - 'Passing extracted v9 prototype methods through Ember templates without preserving their receiver.' - - 'Recreating features, columns, or derived data whenever tracked options rerun.' - + purpose: + Create an Ember v9 table through the tracked useTable options thunk and + render it with Glimmer-native FlexRender components. + sources: + - TanStack/table:docs/framework/ember/quick-start.md + - TanStack/table:examples/ember/basic-table + - TanStack/table:packages/ember-table/src/index.ts + - TanStack/table:packages/ember-table/src/use-table.ts + - TanStack/table:packages/ember-table/src/FlexRender.gts + - TanStack/table:docs/framework/ember/guide/composable-tables.md + - TanStack/table:examples/ember/basic-app-table + - TanStack/table:packages/ember-table/src/create-table-hook.ts + failure_modes: + - Passing an options object instead of a thunk, or failing to read tracked + data inside that thunk. + - Passing extracted v9 prototype methods through Ember templates without + preserving their receiver. + - Recreating features, columns, or derived data whenever tracked options + rerun. + references: + - slug: create-table-hook + purpose: + Share Ember table features, row-model slots, defaults, and inferred + column helpers without inventing a component registry. + sources: + - TanStack/table:docs/framework/ember/guide/composable-tables.md + - TanStack/table:examples/ember/basic-app-table + - TanStack/table:packages/ember-table/src/create-table-hook.ts + failure_modes: + - Expecting AppTable/AppCell/context registries that the Ember factory + does not implement. + - Passing features at each createAppTable call or recreating the app + hook in tracked scope. + - Putting shared mutable state in factory defaults instead of keeping + state ownership per table. + path: references/create-table-hook.md + replaces: '@tanstack/ember-table#create-table-hook' + description: + Create and render Table v9 with the ember adapter. Route reusable + createTableHook defaults, and framework setup; use table-state for + reactive ownership. + requires: + - '@tanstack/table-core#core' - slug: table-state package: '@tanstack/ember-table' domain: framework-adapters type: framework framework: ember - purpose: 'Use Glimmer-tracked table reads and own slices internally, through Ember atoms, or through tracked controlled state.' - sources: - [ - 'TanStack/table:docs/framework/ember/guide/table-state.md', - 'TanStack/table:examples/ember/basic-external-atoms', - 'TanStack/table:examples/ember/basic-external-state', - 'TanStack/table:packages/ember-table/src/use-table.ts', - 'TanStack/table:packages/ember-table/src/reactivity.ts', - 'TanStack/table:packages/ember-table/src/signal.ts', - ] - failure_modes: - - 'Inventing table.Subscribe or using the intentionally no-op table.store.subscribe instead of Glimmer-tracked reads.' - - 'Using removed table.getState() rather than table.store.state or a slice atom.' - - 'Mixing atoms and state ownership, omitting updater resolution, or trying to replace construct-time atoms after table creation.' - - - slug: create-table-hook - package: '@tanstack/ember-table' - domain: framework-adapters - type: framework - framework: ember - purpose: 'Share Ember table features, row-model slots, defaults, and inferred column helpers without inventing a component registry.' - sources: - [ - 'TanStack/table:docs/framework/ember/guide/composable-tables.md', - 'TanStack/table:examples/ember/basic-app-table', - 'TanStack/table:packages/ember-table/src/create-table-hook.ts', - ] - failure_modes: - - 'Expecting AppTable/AppCell/context registries that the Ember factory does not implement.' - - 'Passing features at each createAppTable call or recreating the app hook in tracked scope.' - - 'Putting shared mutable state in factory defaults instead of keeping state ownership per table.' - + purpose: Use Glimmer-tracked table reads and own slices internally, through + Ember atoms, or through tracked controlled state. + sources: + - TanStack/table:docs/framework/ember/guide/table-state.md + - TanStack/table:examples/ember/basic-external-atoms + - TanStack/table:examples/ember/basic-external-state + - TanStack/table:packages/ember-table/src/use-table.ts + - TanStack/table:packages/ember-table/src/reactivity.ts + - TanStack/table:packages/ember-table/src/signal.ts + failure_modes: + - Inventing table.Subscribe or using the intentionally no-op + table.store.subscribe instead of Glimmer-tracked reads. + - Using removed table.getState() rather than table.store.state or a slice + atom. + - Mixing atoms and state ownership, omitting updater resolution, or trying + to replace construct-time atoms after table creation. + references: + - path: references/reactivity.md + purpose: + Read for advanced ember reactive boundaries, subscription patterns, and + complete framework-specific state examples. + sources: + - TanStack/table:docs/framework/ember/guide/table-state.md + - TanStack/table:examples/ember/basic-external-atoms + - TanStack/table:examples/ember/basic-external-state + - TanStack/table:packages/ember-table/src/use-table.ts + - TanStack/table:packages/ember-table/src/reactivity.ts + - TanStack/table:packages/ember-table/src/signal.ts + failure_modes: + - Inventing table.Subscribe or using the intentionally no-op + table.store.subscribe instead of Glimmer-tracked reads. + - Using removed table.getState() rather than table.store.state or a + slice atom. + - Mixing atoms and state ownership, omitting updater resolution, or + trying to replace construct-time atoms after table creation. + - Creating component-owned external-atom subscriptions without passing + the Ember owner prevents owner-destruction cleanup. + description: + Read and control Table v9 state in ember. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' - slug: getting-started package: '@tanstack/alpine-table' domain: framework-adapters type: framework framework: alpine - purpose: 'Create an Alpine v9 table and render reactive headless markup through Alpine bindings.' - sources: - [ - 'TanStack/table:docs/framework/alpine/guide/table-state.md', - 'TanStack/table:examples/alpine/basic-create-table', - 'TanStack/table:packages/alpine-table/src/index.ts', - ] - failure_modes: - - 'Copying a React/Vue hook API instead of Alpine createTable and its reactive proxy.' - - 'Expecting x-html output to initialize nested Alpine directives; interactive controls must exist as real markup/bindings.' - - 'Expecting the adapter to provide semantic markup, styling, or component-library integration.' - + purpose: + Create an Alpine v9 table and render reactive headless markup through + Alpine bindings. + sources: + - TanStack/table:docs/framework/alpine/guide/table-state.md + - TanStack/table:examples/alpine/basic-create-table + - TanStack/table:packages/alpine-table/src/index.ts + - TanStack/table:docs/framework/alpine/guide/composable-tables.md + - TanStack/table:examples/alpine/basic-app-table + - TanStack/table:packages/alpine-table/src/createTableHook.ts + failure_modes: + - Copying a React/Vue hook API instead of Alpine createTable and its + reactive proxy. + - Expecting x-html output to initialize nested Alpine directives; + interactive controls must exist as real markup/bindings. + - Expecting the adapter to provide semantic markup, styling, or + component-library integration. + references: + - slug: create-table-hook + purpose: + Share Alpine table features, options, and typed column helpers without + inventing a component registry. + sources: + - TanStack/table:docs/framework/alpine/guide/composable-tables.md + - TanStack/table:examples/alpine/basic-app-table + - TanStack/table:packages/alpine-table/src/createTableHook.ts + failure_modes: + - Expecting React-style registered cell/header/table components from + an Alpine hook that intentionally only shares features and defaults. + - Using createTableHook for a single table where standalone + createTable is clearer. + - Embedding interactive Alpine directives in x-html strings instead of + using real markup or Alpine.bind bundles. + path: references/create-table-hook.md + replaces: '@tanstack/alpine-table#create-table-hook' + description: + Create and render Table v9 with the alpine adapter. Route reusable + createTableHook defaults, and framework setup; use table-state for + reactive ownership. + requires: + - '@tanstack/table-core#core' - slug: table-state package: '@tanstack/alpine-table' domain: framework-adapters type: framework framework: alpine - purpose: 'Use automatically reactive Alpine table reads and own controlled slices through Alpine.reactive or external atoms.' - sources: - [ - 'TanStack/table:docs/framework/alpine/guide/table-state.md', - 'TanStack/table:examples/alpine/basic-create-table', - 'TanStack/table:packages/alpine-table/src/createTable.ts', - ] - failure_modes: - - 'Adding a nonexistent table.Subscribe abstraction instead of reading APIs directly in Alpine bindings.' - - 'Passing controlled snapshots instead of getters over Alpine.reactive state.' - - 'Ignoring value-or-updater semantics in onSliceChange callbacks or combining state and atoms for the same slice without understanding atom precedence.' - - - slug: create-table-hook - package: '@tanstack/alpine-table' - domain: framework-adapters - type: framework - framework: alpine - purpose: 'Share Alpine table features, options, and typed column helpers without inventing a component registry.' - sources: - [ - 'TanStack/table:docs/framework/alpine/guide/composable-tables.md', - 'TanStack/table:examples/alpine/basic-app-table', - 'TanStack/table:packages/alpine-table/src/createTableHook.ts', - ] - failure_modes: - - 'Expecting React-style registered cell/header/table components from an Alpine hook that intentionally only shares features and defaults.' - - 'Using createTableHook for a single table where standalone createTable is clearer.' - - 'Embedding interactive Alpine directives in x-html strings instead of using real markup or Alpine.bind bundles.' - + purpose: + Use automatically reactive Alpine table reads and own controlled slices + through Alpine.reactive or external atoms. + sources: + - TanStack/table:docs/framework/alpine/guide/table-state.md + - TanStack/table:examples/alpine/basic-create-table + - TanStack/table:packages/alpine-table/src/createTable.ts + failure_modes: + - Adding a nonexistent table.Subscribe abstraction instead of reading APIs + directly in Alpine bindings. + - Passing controlled snapshots instead of getters over Alpine.reactive + state. + - Ignoring value-or-updater semantics in onSliceChange callbacks or + combining state and atoms for the same slice without understanding atom + precedence. + references: + - path: references/reactivity.md + purpose: + Read for advanced alpine reactive boundaries, subscription patterns, + and complete framework-specific state examples. + sources: + - TanStack/table:docs/framework/alpine/guide/table-state.md + - TanStack/table:examples/alpine/basic-create-table + - TanStack/table:packages/alpine-table/src/createTable.ts + failure_modes: + - Adding a nonexistent table.Subscribe abstraction instead of reading + APIs directly in Alpine bindings. + - Passing controlled snapshots instead of getters over Alpine.reactive + state. + - Ignoring value-or-updater semantics in onSliceChange callbacks or + combining state and atoms for the same slice without understanding + atom precedence. + description: + Read and control Table v9 state in alpine. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' - slug: devtools package: '@tanstack/table-devtools' domain: observability type: integration - purpose: 'Register core table targets and inspect state, options, rows, columns, and feature coverage.' - sources: - [ - 'TanStack/table:docs/devtools.md', - 'TanStack/table:packages/table-devtools/src/index.ts', - 'TanStack/table:packages/table-devtools/src/tableTarget.ts', - 'TanStack/table:packages/table-devtools/src/production.ts', - ] - failure_modes: - - 'Registering a table with no non-empty options.key; registration is skipped and Devtools reports no connected table.' - - 'Reusing one key for different live tables and replacing the target unexpectedly.' - - 'Importing the development-gated entrypoint while expecting full Devtools behavior in production.' - + purpose: + Register core table targets and inspect state, options, rows, columns, + and feature coverage. + sources: + - TanStack/table:docs/devtools.md + - TanStack/table:packages/table-devtools/src/index.ts + - TanStack/table:packages/table-devtools/src/tableTarget.ts + - TanStack/table:packages/table-devtools/src/production.ts + failure_modes: + - Registering a table with no non-empty options.key; registration is + skipped and Devtools reports no connected table. + - Reusing one key for different live tables and replacing the target + unexpectedly. + - Importing the development-gated entrypoint while expecting full Devtools + behavior in production. + description: Register TanStack Table targets and inspect options, state, + features, columns, rows, and row models with @tanstack/table-devtools. + Load for missing connections, required unique table options.key, target + replacement/cleanup, or explicit production entrypoints. + requires: + - '@tanstack/table-core#core' - slug: devtools package: '@tanstack/react-table-devtools' domain: observability type: integration framework: react - purpose: 'Connect and render React Table Devtools with stable table identity and development gating.' - sources: - [ - 'TanStack/table:docs/devtools.md', - 'TanStack/table:packages/react-table-devtools/src/index.ts', - 'TanStack/table:packages/react-table-devtools/src/useTanStackTableDevtools.ts', - ] - failure_modes: - - 'Omitting table options.key and seeing a rendered panel with no registered table.' - - 'Calling registration conditionally or with unstable table identity instead of using the adapter hook/component lifecycle.' - - 'Assuming the default entrypoint stays functional outside development rather than using or intentionally avoiding the production export.' - + purpose: + Connect and render React Table Devtools with stable table identity and + development gating. + sources: + - TanStack/table:docs/devtools.md + - TanStack/table:packages/react-table-devtools/src/index.ts + - TanStack/table:packages/react-table-devtools/src/useTanStackTableDevtools.ts + failure_modes: + - Omitting table options.key and seeing a rendered panel with no + registered table. + - Calling registration conditionally or with unstable table identity + instead of using the adapter hook/component lifecycle. + - Assuming the default entrypoint stays functional outside development + rather than using or intentionally avoiding the production export. + description: Connect React Table v9 instances to Devtools with + ReactTableDevtools, useTanStackTableDevtools, or the plugin lifecycle. + Covers stable table identity, required unique options.key, cleanup, + enabled state, and development-gated exports. + requires: + - '@tanstack/table-core#core' + - '@tanstack/table-devtools#devtools' - slug: devtools package: '@tanstack/preact-table-devtools' domain: observability type: integration framework: preact - purpose: 'Connect Preact tables to the Devtools target registry and render the native Preact panel.' - sources: - [ - 'TanStack/table:docs/devtools.md', - 'TanStack/table:packages/preact-table-devtools/src/index.ts', - 'TanStack/table:packages/preact-table-devtools/src/useTanStackTableDevtools.ts', - ] - failure_modes: - - 'Copying React Devtools imports instead of the Preact package API.' - - 'Omitting a stable options.key or failing to clean up/re-register when the table changes.' - - 'Expecting development-gated exports to inspect tables in a production build.' - + purpose: + Connect Preact tables to the Devtools target registry and render the + native Preact panel. + sources: + - TanStack/table:docs/devtools.md + - TanStack/table:packages/preact-table-devtools/src/index.ts + - TanStack/table:packages/preact-table-devtools/src/useTanStackTableDevtools.ts + failure_modes: + - Copying React Devtools imports instead of the Preact package API. + - Omitting a stable options.key or failing to clean up/re-register when + the table changes. + - Expecting development-gated exports to inspect tables in a production + build. + description: + Connect native Preact Table instances to Devtools with the Preact + component, hook, or plugin lifecycle. Covers correct package imports, + required unique options.key, target cleanup, enabled state, and + development gating. + requires: + - '@tanstack/table-core#core' + - '@tanstack/table-devtools#devtools' - slug: devtools package: '@tanstack/solid-table-devtools' domain: observability type: integration framework: solid - purpose: 'Connect Solid tables to Devtools with reactive registration and the correct development/production exports.' - sources: - [ - 'TanStack/table:docs/devtools.md', - 'TanStack/table:packages/solid-table-devtools/src/index.ts', - 'TanStack/table:packages/solid-table-devtools/src/useTanStackTableDevtools.ts', - ] - failure_modes: - - 'Passing a stale table snapshot to registration rather than evaluating it in the intended Solid reactive owner.' - - 'Omitting options.key and silently failing target registration after the logged warning.' - - 'Importing the no-op development-gated component/plugin in production and expecting a panel.' - + purpose: Connect Solid tables to Devtools with reactive registration and the + correct development/production exports. + sources: + - TanStack/table:docs/devtools.md + - TanStack/table:packages/solid-table-devtools/src/index.ts + - TanStack/table:packages/solid-table-devtools/src/useTanStackTableDevtools.ts + failure_modes: + - Passing a stale table snapshot to registration rather than evaluating it + in the intended Solid reactive owner. + - Omitting options.key and silently failing target registration after the + logged warning. + - Importing the no-op development-gated component/plugin in production and + expecting a panel. + description: + Connect Solid Table instances to Devtools in the proper reactive + owner using the Solid component, hook, or plugin. Covers required unique + options.key, target cleanup, enabled state, and development versus + explicit production exports. + requires: + - '@tanstack/table-core#core' + - '@tanstack/table-devtools#devtools' - slug: devtools package: '@tanstack/vue-table-devtools' domain: observability type: integration framework: vue - purpose: 'Connect Vue table refs to Devtools and preserve reactive target cleanup.' - sources: - [ - 'TanStack/table:docs/devtools.md', - 'TanStack/table:packages/vue-table-devtools/src/index.ts', - 'TanStack/table:packages/vue-table-devtools/src/useTanStackTableDevtools.ts', - ] - failure_modes: - - 'Unwrapping a table ref once and preventing registration from following later table changes.' - - 'Omitting the table key or reusing it across simultaneous tables.' - - 'Expecting the development-gated default entrypoint to remain active in production.' - + purpose: Connect Vue table refs to Devtools and preserve reactive target cleanup. + sources: + - TanStack/table:docs/devtools.md + - TanStack/table:packages/vue-table-devtools/src/index.ts + - TanStack/table:packages/vue-table-devtools/src/useTanStackTableDevtools.ts + failure_modes: + - Unwrapping a table ref once and preventing registration from following + later table changes. + - Omitting the table key or reusing it across simultaneous tables. + - Expecting the development-gated default entrypoint to remain active in + production. + description: + Connect Vue Table refs to Devtools with reactive target tracking, + required unique options.key, lifecycle cleanup, enabled state, and + development-gated component/plugin exports. + requires: + - '@tanstack/table-core#core' + - '@tanstack/table-devtools#devtools' - slug: devtools package: '@tanstack/angular-table-devtools' domain: observability type: integration framework: angular - purpose: 'Register Angular signal-provided tables with Devtools inside injection context.' - sources: - [ - 'TanStack/table:docs/devtools.md', - 'TanStack/table:packages/angular-table-devtools/src/index.ts', - 'TanStack/table:packages/angular-table-devtools/src/injectTanStackTableDevtools.ts', - ] - failure_modes: - - 'Calling injectTanStackTableDevtools outside Angular injection context.' - - 'Omitting options.key or returning an undefined table without understanding registration is intentionally disabled.' - - 'Expecting Angular isDevMode-gated exports to render full Devtools in production.' - + purpose: + Register Angular signal-provided tables with Devtools inside injection + context. + sources: + - TanStack/table:docs/devtools.md + - TanStack/table:packages/angular-table-devtools/src/index.ts + - TanStack/table:packages/angular-table-devtools/src/injectTanStackTableDevtools.ts + failure_modes: + - Calling injectTanStackTableDevtools outside Angular injection context. + - Omitting options.key or returning an undefined table without + understanding registration is intentionally disabled. + - Expecting Angular isDevMode-gated exports to render full Devtools in + production. + description: + Register Angular Table instances with injectTanStackTableDevtools + inside injection context. Covers reactive options, enabled/undefined + tables, required unique options.key, cleanup, Angular isDevMode gating, + and explicit production exports. + requires: + - '@tanstack/table-core#core' + - '@tanstack/table-devtools#devtools' - slug: fuzzy-ranking package: '@tanstack/match-sorter-utils' domain: utilities type: core - purpose: 'Rank items, filter on passed, and compare stored ranking metadata without conflating fuzzy matching with Table itself.' - sources: - [ - 'TanStack/table:packages/match-sorter-utils/src/index.ts', - 'TanStack/table:docs/framework/react/guide/fuzzy-filtering.md', - 'TanStack/table:examples/react/filters-fuzzy', - ] - failure_modes: - - 'Using the numeric rank as a boolean instead of checking RankingInfo.passed against the configured threshold.' - - 'Calling rankItem again during sorting instead of storing RankingInfo as filter metadata and comparing it with compareItems.' - - 'Assuming accessors return arbitrary values; matching prepares string values and accessor configuration controls thresholds and ranking bounds.' + purpose: Rank items, filter on passed, and compare stored ranking metadata + without conflating fuzzy matching with Table itself. + sources: + - TanStack/table:packages/match-sorter-utils/src/index.ts + - TanStack/table:docs/framework/react/guide/fuzzy-filtering.md + - TanStack/table:examples/react/filters-fuzzy + failure_modes: + - Using the numeric rank as a boolean instead of checking + RankingInfo.passed against the configured threshold. + - Calling rankItem again during sorting instead of storing RankingInfo as + filter metadata and comparing it with compareItems. + - Assuming accessors return arbitrary values; matching prepares string + values and accessor configuration controls thresholds and ranking + bounds. + description: + Rank fuzzy matches with rankItem, filter with RankingInfo.passed, + compare saved ranking metadata with compareItems, and configure rankings, + thresholds, accessors, bounds, and diacritic handling. Routes TanStack + Table filterMeta wiring to filtering skills. + requires: [] cross_references: - - from: 'core' - to: 'table-features' - reason: 'Every non-core API and state slice depends on feature registration.' - - from: 'table-features' - to: 'api-not-found' - reason: 'A missing feature is the first diagnostic for a missing v9 API.' - - from: 'client-vs-server' + - from: core + to: table-features + reason: Every non-core API and state slice depends on feature registration. + - from: table-features + to: core/references/api-not-found.md + reason: A missing feature is the first diagnostic for a missing v9 API. + - from: table-features/references/client-vs-server.md to: - [ - 'column-filtering', - 'global-filtering', - 'grouping', - 'sorting', - 'expanding', - 'pagination', - ] - reason: 'Manual flags bypass the matching client row-model stages.' - - from: 'typescript' - to: ['table-features', 'create-table-hook'] - reason: 'Feature and app-hook factories are the main sources of inferred v9 userland types.' - - from: 'column-faceting' - to: ['column-filtering', 'global-filtering'] - reason: 'Facet values depend on active filter context and eligible columns.' - - from: 'grouping' - to: ['expanding', 'pagination'] - reason: 'Grouped rows are expanded row trees and count as rows during pagination.' - - from: 'column-pinning' - to: ['column-sizing', 'column-resizing'] - reason: 'Sticky offsets are computed from the numeric column sizing model.' - - from: 'pagination' - to: ['row-selection', 'with-tanstack-query'] - reason: 'Manual pages change which selected IDs have loaded Row objects and usually drive a query key.' - - from: 'table-state' - to: ['create-table-hook', 'with-tanstack-query', 'with-tanstack-virtual'] - reason: 'Reusable components and integrations must read state through the adapter reactive model.' - - from: 'migrate-v8-to-v9' - to: ['table-features', 'table-state', 'typescript', 'api-not-found'] - reason: 'Migration problems span architecture, state, types, and renamed/gated APIs.' + - table-features/references/column-filtering.md + - table-features/references/global-filtering.md + - table-features/references/grouping.md + - table-features/references/sorting.md + - table-features/references/expanding.md + - table-features/references/pagination.md + reason: Manual flags bypass the matching client row-model stages. + - from: core/references/typescript.md + to: + - table-features + - getting-started/references/create-table-hook.md + reason: Feature and app-hook factories are the main sources of inferred v9 + userland types. + - from: table-features/references/column-faceting.md + to: + - table-features/references/column-filtering.md + - table-features/references/global-filtering.md + reason: Facet values depend on active filter context and eligible columns. + - from: table-features/references/grouping.md + to: + - table-features/references/expanding.md + - table-features/references/pagination.md + reason: Grouped rows are expanded row trees and count as rows during pagination. + - from: table-features/references/column-pinning.md + to: + - table-features/references/column-sizing.md + - table-features/references/column-resizing.md + reason: Sticky offsets are computed from the numeric column sizing model. + - from: table-features/references/pagination.md + to: + - table-features/references/row-selection.md + - getting-started/references/with-tanstack-query.md + reason: Manual pages change which selected IDs have loaded Row objects and + usually drive a query key. + - from: table-state + to: + - getting-started/references/create-table-hook.md + - getting-started/references/with-tanstack-query.md + - getting-started/references/with-tanstack-virtual.md + reason: + Reusable components and integrations must read state through the adapter + reactive model. + - from: migrate-v8-to-v9 + to: + - table-features + - table-state + - core/references/typescript.md + - core/references/api-not-found.md + reason: Migration problems span architecture, state, types, and renamed/gated APIs. issue_evidence: - cluster: 'Feature and API discovery' references: ['discussion/5834', 'issue/6212', 'issue/6311'] - finding: 'V9 modularity, renamed registries, and type-gated APIs make installed-source lookup and feature registration essential.' + finding: 'V9 modularity, renamed registries, and type-gated APIs make + installed-source lookup and feature registration essential.' - cluster: 'Composable tables and context' references: ['issue/6348', 'issue/6323', 'issue/6199', 'issue/2344'] - finding: 'Circular imports, context identity, and remount/stale-input failures justify dedicated createTableHook skills.' + finding: + 'Circular imports, context identity, and remount/stale-input failures + require dedicated createTableHook references linked from each adapter + entry point.' - cluster: 'Framework state and compiler reactivity' references: ['issue/6224', 'issue/6236', 'issue/6374', 'issue/6117', 'issue/5903'] - finding: 'Snapshot reads, controlled updater semantics, auto resets, and compiler-hidden method reads are recurring silent failures.' + finding: 'Snapshot reads, controlled updater semantics, auto resets, and + compiler-hidden method reads are recurring silent failures.' - cluster: 'Manual row models' references: [ @@ -1657,7 +2711,9 @@ issue_evidence: 'discussion/3552', 'discussion/5137', ] - finding: 'Users routinely expect manual flags to process rows or assume off-page rows remain available as Row objects.' + finding: + 'Users routinely expect manual flags to process rows or assume off-page + rows remain available as Row objects.' - cluster: 'TypeScript inference' references: [ @@ -1667,7 +2723,9 @@ issue_evidence: 'discussion/4195', 'discussion/4220', ] - finding: 'Manual ColumnDef annotations and deep generics erase TValue inference or overload TypeScript; v9 helpers should lead.' + finding: + 'Manual ColumnDef annotations and deep generics erase TValue inference + or overload TypeScript; v9 helpers should lead.' - cluster: 'Renderer-owned layout' references: [ @@ -1677,52 +2735,146 @@ issue_evidence: 'discussion/4439', 'discussion/3259', ] - finding: 'Pinning, width, alignment, RTL, and responsive behavior require explicit renderer CSS and stable sizing inputs.' + finding: 'Pinning, width, alignment, RTL, and responsive behavior require + explicit renderer CSS and stable sizing inputs.' documentation_read: - narrative_docs: 'All 187 narrative Markdown documents were inventoried by title, headings, and admonitions; foundational, feature, state, migration, composable, and virtualization guides were deep-read.' - generated_references: 'All 828 generated reference documents were inventoried for exports and API categories; exact API truth is delegated to installed dist declarations (.d.ts) in skills.' - examples: 'All 277 example directories were inventoried; basic, state, composable, Query, Virtual, feature, and Devtools-relevant examples were sampled or deep-read by skill.' - source: 'All public package entrypoints, tableFeatures prerequisites, core construction/state precedence, all 16 feature implementations/defaults, createTableHook implementations, Devtools registration, and match-sorter-utils source were inspected.' - community: 'Recent v9 issues plus recurring high-signal issues and GitHub discussions were reviewed for failure modes and misconceptions.' + narrative_docs: + 'All 187 narrative Markdown documents were inventoried by title, + headings, and admonitions; foundational, feature, state, migration, + composable, and virtualization guides were deep-read.' + generated_references: 'All 828 generated reference documents were inventoried + for exports and API categories; exact API truth is delegated to installed + dist declarations (.d.ts) in skills.' + examples: 'All 277 example directories were inventoried; basic, state, + composable, Query, Virtual, feature, and Devtools-relevant examples were + sampled or deep-read by skill.' + source: 'All public package entrypoints, tableFeatures prerequisites, core + construction/state precedence, all 16 feature implementations/defaults, + createTableHook implementations, Devtools registration, and + match-sorter-utils source were inspected.' + community: 'Recent v9 issues plus recurring high-signal issues and GitHub + discussions were reviewed for failure modes and misconceptions.' open_gaps: - skill: 'table-features' - question: 'Should stockFeatures be framed only as a migration/kitchen-sink convenience, or also as an acceptable default for small applications unconcerned with bundle size?' + question: 'Should stockFeatures be framed only as a migration/kitchen-sink + convenience, or also as an acceptable default for small applications + unconcerned with bundle size?' status: resolved - decision: 'Explicit features are the default; stockFeatures is migration and kitchen-sink convenience.' + decision: 'Explicit features are the default; stockFeatures is migration and + kitchen-sink convenience.' - skill: 'client-vs-server' - question: 'Should mixed pipelines such as server filtering/sorting plus client pagination be presented neutrally, or discouraged unless all required rows are loaded?' + question: + 'Should mixed pipelines such as server filtering/sorting plus client + pagination be presented neutrally, or discouraged unless all required rows + are loaded?' status: resolved - decision: 'Mixed pipelines are valid, but skills must name the owner and available dataset for every stage.' + decision: 'Mixed pipelines are valid, but skills must name the owner and + available dataset for every stage.' - skill: 'create-table-hook' - question: 'Should createTableHook be recommended as the standard app-level abstraction once an application has multiple tables, with standalone table creation reserved for one-offs?' + question: 'Should createTableHook be recommended as the standard app-level + abstraction once an application has multiple tables, with standalone table + creation reserved for one-offs?' status: resolved - decision: 'Recommend createTableHook for recurring app conventions and standalone creation for one-offs.' + decision: 'Recommend createTableHook for recurring app conventions and + standalone creation for one-offs.' - skill: 'create-table-hook' - question: 'How strongly should context/injection be preferred over prop drilling when registered components need the table, cell, or header?' + question: + 'How strongly should context/injection be preferred over prop drilling + when registered components need the table, cell, or header?' status: resolved - decision: 'Prefer the typed context or injection helpers returned by the same factory inside registered components.' + decision: + 'Prefer the typed context or injection helpers returned by the same + factory inside registered components.' - skill: 'migrate-v8-to-v9' - question: 'Should useLegacyTable be omitted unless it already appears in user code, or included as a clearly deprecated emergency bridge in a Common Mistakes note?' + question: + 'Should useLegacyTable be omitted unless it already appears in user + code, or included as a clearly deprecated emergency bridge in a Common + Mistakes note?' status: resolved - decision: 'Mention it only when encountered and identify it as a deprecated temporary bridge, never the migration target.' + decision: 'Mention it only when encountered and identify it as a deprecated + temporary bridge, never the migration target.' - skill: 'with-tanstack-virtual' - question: 'Should the skills cover only the maintained examples, or also mention unsupported combinations such as drag-and-drop plus virtualization as user-owned composition?' + question: + 'Should the skills cover only the maintained examples, or also mention + unsupported combinations such as drag-and-drop plus virtualization as + user-owned composition?' status: resolved - decision: 'Teach maintained examples; briefly label unsupported combinations as user-owned composition without prescribing an unmaintained recipe.' + decision: + 'Teach maintained examples; briefly label unsupported combinations as + user-owned composition without prescribing an unmaintained recipe.' - skill: 'devtools' - question: 'Should production entrypoints be taught as supported production inspection, or should normal guidance keep Devtools development-only?' + question: 'Should production entrypoints be taught as supported production + inspection, or should normal guidance keep Devtools development-only?' status: resolved - decision: 'Keep normal guidance development-only; explain production entrypoints only when explicitly requested.' + decision: + 'Keep normal guidance development-only; explain production entrypoints + only when explicitly requested.' maintainer_interview: phase_2_completed: true phase_2_summary: - - 'Primary journeys are first table setup, adding a feature, v8-to-v9 migration, server-data decisions, and performance debugging.' - - 'Table is headless and compatible with component libraries/design systems, but no library-specific skills are in scope.' - - 'Feature skills should be short, edge-case-first, and route exact API discovery to installed dist declarations (.d.ts).' - - 'Framework state guides, createTableHook, Query, and Virtual require dedicated adapter guidance where source exists.' + - 'Primary journeys are first table setup, adding a feature, v8-to-v9 + migration, server-data decisions, and performance debugging.' + - 'Table is headless and compatible with component libraries/design systems, + but no library-specific skills are in scope.' + - 'Feature skills should be short, edge-case-first, and route exact API + discovery to installed dist declarations (.d.ts).' + - 'Framework state guides, createTableHook, Query, and Virtual require + dedicated adapter guidance where source exists.' - 'Worker row models are excluded and useLegacyTable must not be promoted.' phase_4_completed: true phase_4_answers_accepted: true + progressive_disclosure_decision: + accepted_at: 2026-10-04 + decisions: + - Keep core state management and feature architecture directly + discoverable. + - Move individual optional features and adapter compositions to + conditional references. + - Use the official Intent artifacts-to-skills/references workflow for the + complete batch. +disclosure_contract: + entrypoints: 39 + feature_references: 17 + rules: + - Every skills entry produces SKILL.md; each nested references entry + produces the named supporting Markdown file relative to its owner. + - Read the reviewed domain map and skill spec before updating + skill_tree.yaml; generate files only from that tree. + - Choose references from the requested change and relevant registrations, + including features being added; installed or registered features alone do + not require loading their content. + - Use direct Markdown links with explicit read conditions; references have + no SKILL.md frontmatter or independent discovery entry. + - Keep source evidence and failure modes with their reference in this map, + and aggregate sources on the owner for Intent staleness tracking. + - Keep complete shared migration coverage in a checklist and load detailed + mappings only when that checklist finds affected code. + - Reference files inherit the owning skill/package version; version + synchronization stays on SKILL.md and artifacts. + validation: + - Validate every declared skill and reference exists, each reference is + directly linked from its owner, and no shipped document is absent from the + tree. + - Check reference Markdown and annotated snippets with the same rules as + entry points. + - Verify catalog size, single-file loading, reference-link resolution, + dependency reachability, and npm package contents in a consumer fixture. +progressive_disclosure_review: + date: 2026-10-04 + workflow: tree-generator and generate-skill Mode A from existing reviewed artifacts + community_scan: + - Reviewed issues 6601, 6577, 6524 and discussion 6535 for React reactive + boundaries and inferred feature types; retained source-backed adapter + guidance rather than unverified comment workarounds. + - Reviewed Angular issue 6530, closed as fixed in 9.1.3; obsolete + microtask/isMount workarounds do not belong in current skills. + - Existing domain issue evidence and technical failure modes remain attached + to their owning entry points or references. + artifact_corrections: + - Restore the aggregation inventory from its existing published skill, + guide, and source. + - Keep aggregationFns prerequisites tied to rowAggregationFeature. + - Keep resize handlers tied to mouse and touch start events. diff --git a/_artifacts/skill_spec.md b/_artifacts/skill_spec.md index 00de2f975d..bd6a9b0248 100644 --- a/_artifacts/skill_spec.md +++ b/_artifacts/skill_spec.md @@ -1,7 +1,7 @@ # TanStack Table v9 skill specification Status: reviewed
-Date: 2026-07-29
+Date: 2026-10-04
Library target: TanStack Table v9, authored in stable-release voice
Package metadata target: exact workspace package versions; release automation keeps every shipped skill synchronized @@ -9,7 +9,7 @@ This specification is the generation contract for a deliberately smaller, foot-g ## Outcome -Generate 80 short package-local skills across all 18 public packages. A loaded skill should quickly do three things: +Generate 39 package-local entry points across all 18 public packages, with the supporting references declared in skill_tree.yaml. A loaded skill should quickly do three things: 1. Correct the user or agent mental model. 2. Show the smallest reliable setup or decision pattern. @@ -23,12 +23,12 @@ The skills should not enumerate every option or method. That duplicates generate - V9 optional features are plugins. A feature API, state slice, row model, or function registry exists only when the matching feature is registered through tableFeatures. - The client/server row-model boundary is a first-order architecture decision. Manual modes bypass Table processing; they do not perform server work. - Most userland TypeScript should be inferred through helpers, features, options, and app-hook factories. Deep manual generics are a smell. -- createTableHook is important v9 guidance for reusable app-level table infrastructure. It deserves one dedicated skill in every framework package. +- createTableHook is important v9 guidance for reusable app-level table infrastructure. It deserves one dedicated reference linked from every framework getting-started skill. - Framework table-state guidance is fundamental and should retain substantially more depth than ordinary feature skills. - Data and columns are model inputs and must retain stable references between meaningful changes in every adapter and composition example. - V8-to-v9 migration is a primary route. Deprecated useLegacyTable is not the destination and must not be promoted. - TanStack Query usually owns data before it reaches Table. TanStack Virtual is intertwined with Table rendering after the final row/column model exists. -- CSS/layout failure modes belong in the relevant pinning, sizing, resizing, and virtualization skills. Component-library-specific skills do not. +- CSS/layout failure modes belong in the relevant pinning, sizing, resizing, and virtualization references. Component-library-specific skills do not. - Worker row models are excluded. ## Source-of-truth hierarchy @@ -68,54 +68,40 @@ Each generated SKILL.md must satisfy the current TanStack Intent validator: The metadata version must record the exact package version even though prose treats v9 as stable. Do not call ordinary v9 APIs experimental or advise waiting for stable. -### Body shape +### Artifacts before generated files -Prefer 60-180 lines. Table-state, migration, createTableHook, and Virtual skills may be longer when the adapter genuinely differs. +Use the installed Intent `tree-generator` and `generate-skill` Mode A workflows. The reviewed domain map contains the knowledge inventory and failure modes. This specification defines placement. Update `skill_tree.yaml` from both before generating any skill or reference. -Use this default structure: +Each item in `domain_map.yaml#skills` produces one `SKILL.md`. Its nested `references` entries retain their purpose, source evidence, and failure modes, and produce the paths listed in the corresponding tree entry. A moved topic remains covered through that reference. Do not restore its old discovery entry during regeneration. -1. One-paragraph mental model. -2. Setup: imports and the smallest valid configuration. -3. Two to four decision or implementation patterns. -4. Common mistakes: at least three concrete failures with correction. -5. API discovery: exact installed declaration route (`.d.ts`) and identifiers to inspect. -6. Cross-skill routing only when another skill owns the next decision. +The maintainer approved the progressive-disclosure proposal and batch implementation on 2026-10-04. Preserve prior reviewed technical decisions while changing their placement. This is generation from existing reviewed artifacts, not a new-library discovery interview. -Do not add a reference folder by default. Add one only when a large migration mapping or framework-specific content cannot stay concise in SKILL.md. Progressive disclosure is a size tool, not permission to recreate all docs as references. +### Body shape and disclosure -### Migration skill exception +Keep shared purpose, essential constraints, the minimum valid setup, and routing in `SKILL.md`. Prefer 60-120 lines for ordinary entry points; preserve correctness when a framework needs more. The 500-line ceiling is a guard, not a reason to delay references. -The table-core and seven adapter migrate-v8-to-v9 skills are intentionally comprehensive. They may approach the 500-line limit and must list every breaking change in the maintained migration guide, not merely three common mistakes or a short route to the docs. +- Use the core overview and routing format for `core`, the standard procedure format for setup and state, and Intent's checklist format for migration. +- Split conditional content by the task it serves. Optional features, Query, Virtual, reusable app hooks, advanced reactivity, and detailed migration maps belong in their declared references. +- Give each reference a direct relative Markdown link in the owning `SKILL.md` and an explicit condition for reading it. A list of filenames without read conditions is insufficient. +- Read references for the requested change and relevant existing registrations, including features being added. A feature being installed or registered alone does not require reading its reference. +- Each reference is ordinary Markdown with a descriptive title, purpose, source provenance, and maintained examples. It has no skill frontmatter and inherits its owning package version. +- Keep related feature references separate: row/cell selection, sizing/resizing, and each pinning feature have different behavior and prerequisites. +- Keep shared essential gotchas inline. Retain concrete feature-specific failure modes in the matching reference. Use wrong/correct examples only when they explain a real failure; a router does not need three artificial mistakes. +- Use `requires` only for unconditional skill prerequisites, and state those reads in prose. Intent load returns one entry point; it does not automatically load prerequisites or references. +- Use Markdown links within a package. Resolve cross-package skills with `intent load #`; do not assume a hoisted sibling package or a repository-only path exists in a consumer install. +- Keep exact API discovery rooted in installed package declarations. -Every adapter migration skill must be usable on its own and include: +### Migration coverage -- its framework-version prerequisite, package change, and construction entrypoint mapping; -- the complete shared architecture changes for tableFeatures, all stock feature imports, row-model slots, function registries, and stockFeatures audit guidance; -- the full logical start/end column-pinning mapping; -- prototype-method binding and enumeration/spread consequences; -- state access, selector/subscription, controlled-state, external-atom, precedence, and onStateChange changes for that adapter; -- createColumnHelper/columns(), rendering, tableOptions, and createTableHook changes; -- pinning-option, sizing/resizing, sorting, removed-internal, row, and row-selection API changes; -- all TypeScript generic, meta, function-registry augmentation, StockFeatures, and RowData changes; -- an exhaustive checkbox audit at the end. +Core `migrate-v8-to-v9` owns the complete shared audit checklist. Its architecture, state, feature-apis, and typescript references preserve every shared breaking change from the reviewed domain map. Audit the whole checklist and read detailed mappings for affected code. -Do not rely on the core migration skill to hide shared changes from an adapter migration. The requires relationship supplies context, but migration users commonly load only the adapter skill and need the full audit surface there. Keep detailed mappings in SKILL.md unless the file would exceed Intent's 500-line limit. +Each adapter migration entry point explicitly loads the core migration skill and adds its framework-version, construction, rendering, state, and app-hook checks. Its adapter-migration reference contains framework-specific detail. Shared rename tables and inventories have one authoritative home in core. Preserve complete migration coverage across the entry point and referenced files. -### Table-state skill exception +### State coverage -Every framework table-state skill must preserve substantially more of its guide than an ordinary feature skill because state coordination is the library's foundational behavior. Include: +Core `table-state` owns internal/default ownership, feature-gated slices, baseAtoms/atoms/store, controlled-value/updater pairing, external-atom precedence, initialization, resets, and state inference. It routes reactive consumption to the installed adapter. -- internal state as the default and the reasons to hoist only selected slices; -- feature-gated state and typing; -- `baseAtoms`, readonly derived `atoms`, the flat `store`, and any adapter-selected `table.state` surface; -- snapshot reads versus the adapter's tracked/subscribed reads; -- one owner per slice across internal state, `initialState`, external `atoms`, and `state` plus `on[State]Change`; -- precedence, value-or-updater handling, and removal of the v8 global `onStateChange` option; -- preferred feature-method writes, low-level base-atom writes, initial/reset semantics, and externally owned reset limitations; -- feature-specific types and `TableState` inference; -- framework-specific selector, subscription, compiler, signal, rune, ref, controller, or proxy behavior. - -Retain concrete wrong-versus-correct examples for the adapter's most likely subscription and controlled-state mistakes. Table-state skills may exceed the normal 180-line target while remaining below Intent's 500-line limit. +Each adapter `table-state` requires the core state skill. Keep its essential snapshot-versus-tracked-read distinction, supported subscription APIs, controlled wiring, and adapter-specific correctness warnings inline. Its reactivity reference holds advanced boundaries and extended examples. State repair in an existing table does not require getting-started. ### Stable model-input invariant @@ -123,11 +109,11 @@ Treat stable `data` and `columns` references as a correctness and performance in ### Custom-feature completeness exception -The custom-features skill must enumerate all 10 public declaration-merge FeatureMaps: table state, table options, table, column definition, column, row, cell, header, row-model functions, and cached row models. Explain that `Plugins` registers the feature key and that declarations add types only; each advertised runtime surface needs matching lifecycle wiring. +The custom-features plugin-example reference must enumerate all 10 public declaration-merge FeatureMaps: table state, table options, table, column definition, column, row, cell, header, row-model functions, and cached row models. Explain that `Plugins` registers the feature key and that declarations add types only; each advertised runtime surface needs matching lifecycle wiring. Enumerate both API utilities and every installation path: `assignTableAPIs` in `constructTableAPIs`, plus `assignPrototypeAPIs` in `assignColumnPrototype`, `assignRowPrototype`, `assignCellPrototype`, and `assignHeaderPrototype`. Include the static-name prefixes, prototype self argument, optional `memoDeps`, shared-prototype constraint, `initColumnInstanceData`/`initRowInstanceData`, and the fact that per-object `assignColumnAPIs`-style utilities do not exist. Clearly label row-model maps as advanced internal pipeline surfaces requiring explicit runtime/cache wiring. -Use one annotated, authoritative feature example for the complete shape. Do not stack a minimal density example, a second FeatureMap example, a third API-installation example, and then repeat their distinction under Common Mistakes. Keep selection guidance and foot-guns as compact prose around the single example. +Use one annotated, authoritative feature example for the complete shape. Do not stack a minimal density example, a second FeatureMap example, a third API-installation example, and then repeat their distinction under Common Mistakes. Keep the custom-features entry point focused on plugin selection and implementation steps, with a direct instruction to read the checked example before implementing lifecycle wiring. ### Code examples @@ -161,8 +147,9 @@ Use Wrong/Correct only when the Wrong form is demonstrably broken or misleading. - `intent validate` checks structure, frontmatter, sources, requires, and artifacts. - `skills:versions:check` compares each skill's `metadata.library_version` with its package and verifies artifact overrides. -- `test:skill-content` checks high-risk generated-content invariants, including Markdown table shape, package imports, feature gating, stable empty fallbacks, adapter subscription shapes, and resize input events. -- Add `` immediately before a self-contained TypeScript/TSX fence when its exact code is load-bearing. `test:skill-snippets` compiles each marked fence against workspace source. A marker may specify `prelude=path` or `tsconfig=path` when the snippet needs an explicit checked context. +- `test:skill-tree` checks artifact/file coverage, direct reference links, local link targets, skill dependencies, source provenance, Intent consumer discovery/loading, and packaged references. +- `test:skill-content` checks high-risk generated-content invariants in entry points and references, including Markdown table shape, package imports, feature gating, stable empty fallbacks, adapter subscription shapes, and resize input events. +- Add `` immediately before a self-contained TypeScript/TSX fence when its exact code is load-bearing. `test:skill-snippets` compiles each marked fence in entry points and references against workspace source. A marker may specify `prelude=path` or `tsconfig=path` when the snippet needs an explicit checked context. - Virtual composition guidance must be copied from or kept structurally faithful to the maintained adapter guide/example. When evidence is absent, route to the documented supported composition instead of inventing an adapter package or API. These checks run in `pnpm test:skills`. They supplement review; they do not justify expanding skills into API summaries. @@ -173,84 +160,29 @@ Skill versions ship with package versions. After release tooling calculates pack ## Routing taxonomy -### Foundations and migration — @tanstack/table-core (7) - -- core — headless philosophy, core model, stable inputs, renderer ownership. -- table-features — explicit registration, prerequisites, row-model/function slots, tree-shaking. -- client-vs-server — choose ownership for filtering/grouping/sorting/expanding/pagination. -- typescript — columnHelper, meta helpers, tableOptions, inference, avoid manual generics. -- api-not-found — inspect installed declarations, feature gating, version/adapter mismatch, prototypes. -- custom-features — plugin lifecycle after exhausting built-in APIs and meta. -- migrate-v8-to-v9 — shared breaking changes and adapter migration routing. - -### Stock feature plugins — @tanstack/table-core (16) - -- aggregation -- cell-selection -- column-faceting -- column-filtering -- grouping -- column-ordering -- column-pinning -- column-resizing -- column-sizing -- column-visibility -- global-filtering -- expanding -- pagination -- row-pinning -- row-selection -- sorting - -Each feature skill must: - -- name the feature import; -- name only row-model and registry slots relevant to that feature; -- state its tableFeatures prerequisites; -- distinguish state from row processing and renderer behavior; -- route exact API discovery to its shipped feature directory under `dist/features/`; -- include feature-specific edge cases from domain_map.yaml. - -Do not combine all column layout features into one summary. Their plugin prerequisites and CSS responsibilities differ enough to route independently. - -### Framework adapter set - -React, Preact, Solid, Svelte, Vue, and Angular each ship six skills: - -- getting-started -- table-state -- migrate-v8-to-v9 -- create-table-hook -- with-tanstack-query -- with-tanstack-virtual +### Foundations and migration: @tanstack/table-core -Lit ships five: +Five entry points remain directly discoverable: -- getting-started -- table-state -- migrate-v8-to-v9 -- create-table-hook -- with-tanstack-virtual +- `core`: headless model, stable inputs, minimal typed setup, and routing. References own TypeScript troubleshooting, missing API diagnosis, and row/display-index details. +- `table-features`: feature registration, prerequisites, row-model and function slots. References own client/server boundaries and each of the 17 optional features. +- `table-state`: shared ownership, initialization, updates, reset semantics, and adapter-state routing. +- `custom-features`: plugin authoring workflow and one complete checked plugin example in a reference. +- `migrate-v8-to-v9`: complete shared audit checklist and conditional architecture, state, feature API, and TypeScript mappings. -Alpine ships three: +### Optional feature references -- getting-started -- table-state -- create-table-hook +The `table-features` entry point directly links aggregation, cell-selection, cell-spanning, column-faceting, column-filtering, column-ordering, column-pinning, column-resizing, column-sizing, column-visibility, expanding, global-filtering, grouping, pagination, row-pinning, row-selection, and sorting. -Ember ships three: +Each feature reference names its feature import, relevant row-model/registry slots, prerequisites, state/processing/renderer responsibilities, installed declaration directory, and the feature-specific failure modes retained in the domain map. -- getting-started -- table-state -- create-table-hook +### Framework adapter set -Octane ships three: +All ten adapters have `getting-started` and `table-state` entry points. React, Preact, Solid, Svelte, Vue, Angular, and Lit also retain `migrate-v8-to-v9`. State and migration entry points have their own conditional detailed references. -- getting-started -- table-state -- create-table-hook +Every getting-started skill directly links a `references/create-table-hook.md`. React, Preact, Solid, Svelte, Vue, and Angular also link `references/with-tanstack-query.md` and `references/with-tanstack-virtual.md`. Lit also links Virtual. Broaden the getting-started description to route ongoing adapter work and these supported integrations. -Do not add Query where no maintained adapter example exists. Do not add Alpine, Ember, or Octane migration skills because none has a v8 adapter journey to teach. Do not add Ember or Octane Query or Virtual skills until maintained adapter examples exist. Do not invent Preact virtualization examples; its Virtual skill should rely on the maintained adapter guide and installed APIs. +Keep framework-specific examples in their package. Do not add Query or Virtual guidance where no maintained adapter guide/example exists. Alpine, Ember, and Octane have no v8 adapter migration journey. ### Devtools set (6) @@ -271,27 +203,29 @@ All Devtools skills must emphasize the required non-empty table options.key, lif ## Package coverage -| Package | Skills | -| -------------------------------- | -----: | -| @tanstack/table-core | 23 | -| @tanstack/react-table | 6 | -| @tanstack/preact-table | 6 | -| @tanstack/octane-table | 3 | -| @tanstack/solid-table | 6 | -| @tanstack/svelte-table | 6 | -| @tanstack/vue-table | 6 | -| @tanstack/angular-table | 6 | -| @tanstack/lit-table | 5 | -| @tanstack/alpine-table | 3 | -| @tanstack/ember-table | 3 | -| @tanstack/table-devtools | 1 | -| @tanstack/react-table-devtools | 1 | -| @tanstack/preact-table-devtools | 1 | -| @tanstack/solid-table-devtools | 1 | -| @tanstack/vue-table-devtools | 1 | -| @tanstack/angular-table-devtools | 1 | -| @tanstack/match-sorter-utils | 1 | -| Total | 80 | +| Package | Entry points | +| -------------------------------- | -----------: | +| @tanstack/table-core | 5 | +| @tanstack/react-table | 3 | +| @tanstack/preact-table | 3 | +| @tanstack/octane-table | 2 | +| @tanstack/solid-table | 3 | +| @tanstack/svelte-table | 3 | +| @tanstack/vue-table | 3 | +| @tanstack/angular-table | 3 | +| @tanstack/lit-table | 3 | +| @tanstack/alpine-table | 2 | +| @tanstack/ember-table | 2 | +| @tanstack/table-devtools | 1 | +| @tanstack/react-table-devtools | 1 | +| @tanstack/preact-table-devtools | 1 | +| @tanstack/solid-table-devtools | 1 | +| @tanstack/vue-table-devtools | 1 | +| @tanstack/angular-table-devtools | 1 | +| @tanstack/match-sorter-utils | 1 | +| Total | 39 | + +`pnpm test:skills` verifies the file inventory against the tree. A React consumer with core discovers eight Table entry points. Plain reference files never appear as independent Intent skills. ## Framework distinctions that must survive generation @@ -364,12 +298,12 @@ All Devtools skills must emphasize the required non-empty table options.key, lif ## Cross-cutting placement rules - Performance: stable inputs in getting-started/core; adapter-specific fine-grained state reads or selectors in table-state; CSS variables in resizing; measurement/overscan in Virtual; row ownership in client-vs-server. -- CSS: pinning, sizing, resizing, and Virtual skills only. Core may state that CSS is user-owned. +- CSS: pinning, sizing, resizing, and Virtual references only. Core may state that CSS is user-owned. - Accessibility: core/getting-started may remind that headless rendering leaves semantics and interaction accessibility with the renderer; do not create a component-library integration skill. - Query: data source and manual processing boundaries, not Table rendering. - Virtual: final Table models and renderer geometry, never tableFeatures. -- Context: createTableHook skills; mention context over prop drilling when a registered reusable component needs typed table/cell/header access. -- API lookup: api-not-found establishes the workflow; every other skill includes its direct installed declaration route. +- Context: createTableHook references; mention context over prop drilling when a registered reusable component needs typed table/cell/header access. +- API lookup: core/references/api-not-found.md establishes the workflow; every other skill includes its direct installed declaration route. ## Anti-patterns forbidden during generation @@ -393,7 +327,13 @@ The maintainer accepted these generation positions on 2026-07-10: 3. createTableHook is recommended for recurring app conventions; standalone construction remains appropriate for one-offs. 4. Typed context/injection helpers from createTableHook are preferred over prop drilling inside registered components. 5. useLegacyTable is mentioned only when encountered, as a deprecated temporary bridge rather than a migration target. -6. Virtual skills teach maintained examples and only identify unsupported combinations as user-owned composition. +6. Virtual references teach maintained examples and only identify unsupported combinations as user-owned composition. 7. Devtools guidance is development-only by default; production entrypoints are explained only when explicitly requested. Domain discovery is reviewed and tree generation may proceed. + +## Consumer compatibility and validation + +Moved topic IDs are intentionally removed from discovery. Document their owning entry points in docs/agent-skills.md. Consumers using explicit `install --map` mappings must regenerate them. Consumers allowing individual old IDs in `intent.skills` must select the replacement entry points. Preserve a small catalog by avoiding forwarding SKILL.md files. + +Verify the pinned Intent 0.4.0 behavior in an isolated consumer install: list/catalog counts, default and mapped guidance, single-file loading, conditional reference links, and prerequisites. Check that package tarballs contain the references. Measure discovery text and task-specific reads separately. Run the content and annotated-snippet checks after all moves, and include a changeset because these files ship inside published packages. diff --git a/_artifacts/skill_tree.yaml b/_artifacts/skill_tree.yaml index 1f2af9f60b..0588b272ee 100644 --- a/_artifacts/skill_tree.yaml +++ b/_artifacts/skill_tree.yaml @@ -1,1201 +1,927 @@ library: name: '@tanstack/table' - version: '9.1.2' + version: '9.3.1' repository: 'https://github.com/TanStack/table' - description: 'Headless data-grid state and row processing with tree-shakeable v9 features and framework adapters.' + description: + 'Headless data-grid state and row processing with tree-shakeable v9 + features and framework adapters.' package_version_overrides: - '@tanstack/angular-table': '9.2.1' - '@tanstack/angular-table-devtools': '9.2.0' - '@tanstack/preact-table-devtools': '9.2.0' - '@tanstack/react-table-devtools': '9.2.0' - '@tanstack/solid-table-devtools': '9.2.0' - '@tanstack/table-devtools': '9.2.0' - '@tanstack/vue-table-devtools': '9.2.0' + '@tanstack/angular-table': '9.3.2' + '@tanstack/angular-table-devtools': '9.3.2' + '@tanstack/ember-table': '9.3.2' + '@tanstack/match-sorter-utils': '9.2.6' + '@tanstack/preact-table-devtools': '9.3.2' + '@tanstack/react-table-devtools': '9.3.2' + '@tanstack/solid-table-devtools': '9.3.2' + '@tanstack/svelte-table': '9.3.2' + '@tanstack/table-devtools': '9.3.2' + '@tanstack/vue-table-devtools': '9.3.2' generated_from: domain_map: '_artifacts/domain_map.yaml' skill_spec: '_artifacts/skill_spec.md' -generated_at: '2026-08-01' +generated_at: '2026-10-04' status: reviewed -reviewed_at: '2026-07-29' +reviewed_at: '2026-10-04' batch_review: true -structure: 'flat-per-package' +structure: 'entrypoints-with-references' monorepo_layout: true tree_decisions: - - 'Every domain-map entry maps one-to-one to a package-local SKILL.md.' - - 'Flat task-focused paths keep each feature and adapter workflow independently discoverable.' - - 'The table-core core skill is the lightweight router and philosophy skill; no additional synthetic router skills are added.' - - 'No reference files are planned initially. Generation may add one only when content cannot remain concise under the reviewed specification.' - - 'Cross-package requires use the package#skill identifier form; same-package requires use the local slug.' - - 'All migrate-v8-to-v9 skills are comprehensive exceptions to the compact default: each must enumerate every shared and adapter-specific breaking change and end with a complete audit checklist.' - - 'Wrong/Correct examples are used only for genuinely broken behavior; supported alternatives are presented as explicit decisions.' - - 'Adapter composition skills stay anchored to maintained examples and guides, especially where Virtual adapter APIs differ.' - - 'Skill source, content, Markdown structure, checked snippets, and package-version metadata are validated in CI.' - - 'All framework table-state skills are foundational depth exceptions: each preserves state surfaces, feature gating, ownership, precedence, updates/resets, typing, and adapter-specific subscription behavior from its guide.' - - 'Every generated example keeps data and columns stable; repeated option evaluation must not contain inline derivation, column factories, or fresh empty-array fallbacks.' - - 'The custom-features skill is a completeness exception expressed through one authoritative example: it inventories all 10 FeatureMaps and every table/column/row/cell/header API installation path without layering redundant examples or misconceptions.' + - Each domain-map skills entry maps to one package-local SKILL.md; its + references entries map to supporting Markdown files. + - Core, feature architecture, and shared state remain directly discoverable + alongside custom-plugin and migration workflows. + - All 17 optional features live under table-features/references, selected by + the requested change and relevant feature registrations. + - Adapter entry points route createTableHook, Query, and Virtual to references + only where maintained guidance exists. + - Adapter state skills require shared state, retain essential reactivity + inline, and disclose advanced examples without requiring setup guidance. + - Shared migration checklists remain complete; core references own shared + mappings and adapter references own framework-specific changes. + - Every reference has a direct conditional Markdown link from its owner and + inherits that package version. + - Owner sources aggregate reference evidence for Intent stale; source content, + links, annotated examples, and published reference files are validated. + - Keep Intent 0.4.0 and the repository content/snippet checks. Batch + generation uses generate-skill Mode A from these reviewed artifacts. skills: - - name: 'Core' + - name: Core slug: core type: core domain: foundations - path: 'packages/table-core/skills/core/SKILL.md' - package: 'packages/table-core' - description: 'Use TanStack Table v9 as a headless data-grid state and row-processing engine. Routes first-table setup, stable data/columns, semantic rendering, feature plugins, framework adapters, and renderer-owned CSS or accessibility.' - sources: - - 'TanStack/table:docs/overview.md' - - 'TanStack/table:docs/guide/tables.md' - - 'TanStack/table:docs/guide/data.md' - - 'TanStack/table:packages/table-core/src/index.ts' - - - name: 'Table Features' + path: packages/table-core/skills/core/SKILL.md + package: packages/table-core + description: + Use TanStack Table v9 core architecture, stable data and columns, + and inferred types. Route setup, missing APIs, row models, state, + features, and framework-specific work. + sources: + - TanStack/table:docs/overview.md + - TanStack/table:docs/guide/tables.md + - TanStack/table:docs/guide/data.md + - TanStack/table:packages/table-core/src/index.ts + - TanStack/table:docs/guide/helpers.md + - TanStack/table:docs/guide/column-defs.md + - TanStack/table:docs/guide/table-and-column-meta.md + - TanStack/table:packages/table-core/src/helpers + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:docs/framework/react/guide/migrating.md + - TanStack/table:docs/guide/rows.md + - TanStack/table:packages/table-core/src/core/rows/coreRowsFeature.utils.ts + references: + - references/typescript.md + - references/api-not-found.md + - references/rows.md + - name: Table Features slug: table-features - type: sub-skill - domain: foundations - path: 'packages/table-core/skills/table-features/SKILL.md' - package: 'packages/table-core' - description: 'Register v9 tableFeatures, feature plugins, create*RowModel factories, and filterFns/sortFns/aggregationFns slots in prerequisite order while preserving tree-shaking. Load when an API or state slice is missing or when choosing explicit features versus stockFeatures.' - requires: ['core'] - sources: - - 'TanStack/table:docs/guide/row-models.md' - - 'TanStack/table:packages/table-core/src/types/TableFeatures.ts' - - 'TanStack/table:packages/table-core/src/features/stockFeatures.ts' - - 'TanStack/table:packages/table-core/src/core/table/constructTable.ts' - - - name: 'Client vs Server' - slug: client-vs-server - type: sub-skill - domain: foundations - path: 'packages/table-core/skills/client-vs-server/SKILL.md' - package: 'packages/table-core' - description: 'Choose client or server ownership for filtering, grouping, sorting, expanding, and pagination. Explains create*RowModel pipelines, manual* bypass flags, mixed pipelines, server counts, stable processed data, and the exact dataset available to every stage.' - requires: ['core', 'table-features'] - sources: - - 'TanStack/table:docs/guide/row-models.md' - - 'TanStack/table:packages/table-core/src/core/row-models/coreRowModelsFeature.utils.ts' - - 'TanStack/table:examples/react/with-tanstack-query' - - - name: 'TypeScript' - slug: typescript - type: sub-skill + type: core domain: foundations - path: 'packages/table-core/skills/typescript/SKILL.md' - package: 'packages/table-core' - description: 'Preserve TanStack Table v9 inference with createColumnHelper, columns(), tableOptions, tableMeta/columnMeta/filterMeta helpers, typeof features, and createTableHook. Load for ColumnDef errors, reusable generic tables, or unnecessary manual feature generics.' - requires: ['core', 'table-features'] - sources: - - 'TanStack/table:docs/guide/helpers.md' - - 'TanStack/table:docs/guide/column-defs.md' - - 'TanStack/table:docs/guide/table-and-column-meta.md' - - 'TanStack/table:packages/table-core/src/helpers' - - - name: 'API Not Found' - slug: api-not-found - type: sub-skill + path: packages/table-core/skills/table-features/SKILL.md + package: packages/table-core + description: 'Add or debug Table v9 features: registration, row-model slots, + prerequisites, sorting, filtering, pagination, selection, spanning, and + column layout. Read only task-relevant feature references.' + requires: + - core + sources: + - TanStack/table:docs/guide/row-models.md + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:packages/table-core/src/features/stockFeatures.ts + - TanStack/table:packages/table-core/src/core/table/constructTable.ts + - TanStack/table:packages/table-core/src/core/row-models/coreRowModelsFeature.utils.ts + - TanStack/table:examples/react/with-tanstack-query + - TanStack/table:docs/framework/react/guide/column-faceting.md + - TanStack/table:packages/table-core/src/features/column-faceting + - TanStack/table:examples/react/filters-faceted + - TanStack/table:docs/framework/react/guide/column-filtering.md + - TanStack/table:packages/table-core/src/features/column-filtering + - TanStack/table:examples/react/filters + - TanStack/table:docs/framework/react/guide/grouping.md + - TanStack/table:packages/table-core/src/features/column-grouping + - TanStack/table:examples/react/grouping + - TanStack/table:docs/framework/react/guide/column-ordering.md + - TanStack/table:packages/table-core/src/features/column-ordering + - TanStack/table:examples/react/column-dnd + - TanStack/table:docs/framework/react/guide/column-pinning.md + - TanStack/table:packages/table-core/src/features/column-pinning + - TanStack/table:examples/react/column-pinning-sticky + - TanStack/table:docs/framework/react/guide/column-resizing.md + - TanStack/table:packages/table-core/src/features/column-resizing + - TanStack/table:examples/react/column-resizing-performant + - TanStack/table:docs/framework/react/guide/column-sizing.md + - TanStack/table:packages/table-core/src/features/column-sizing + - TanStack/table:examples/react/column-sizing + - TanStack/table:docs/framework/react/guide/column-visibility.md + - TanStack/table:packages/table-core/src/features/column-visibility + - TanStack/table:examples/react/column-visibility + - TanStack/table:docs/framework/react/guide/global-filtering.md + - TanStack/table:packages/table-core/src/features/global-filtering + - TanStack/table:docs/framework/react/guide/expanding.md + - TanStack/table:packages/table-core/src/features/row-expanding + - TanStack/table:examples/react/expanding + - TanStack/table:docs/framework/react/guide/pagination.md + - TanStack/table:packages/table-core/src/features/row-pagination + - TanStack/table:examples/react/pagination + - TanStack/table:docs/framework/react/guide/row-pinning.md + - TanStack/table:packages/table-core/src/features/row-pinning + - TanStack/table:examples/react/row-pinning + - TanStack/table:docs/framework/react/guide/cell-selection.md + - TanStack/table:packages/table-core/src/features/cell-selection + - TanStack/table:examples/react/cell-selection + - TanStack/table:docs/framework/react/guide/cell-spanning.md + - TanStack/table:packages/table-core/src/features/cell-spanning + - TanStack/table:examples/react/cell-spanning + - TanStack/table:docs/framework/react/guide/row-selection.md + - TanStack/table:packages/table-core/src/features/row-selection + - TanStack/table:examples/react/row-selection + - TanStack/table:docs/framework/react/guide/sorting.md + - TanStack/table:packages/table-core/src/features/row-sorting + - TanStack/table:examples/react/sorting + - TanStack/table:docs/framework/react/guide/aggregation.md + - TanStack/table:packages/table-core/src/features/row-aggregation + - TanStack/table:examples/react/aggregation + - TanStack/table:examples/react/grouped-aggregation + references: + - references/client-vs-server.md + - references/column-faceting.md + - references/column-filtering.md + - references/grouping.md + - references/column-ordering.md + - references/column-pinning.md + - references/column-resizing.md + - references/column-sizing.md + - references/column-visibility.md + - references/global-filtering.md + - references/expanding.md + - references/pagination.md + - references/row-pinning.md + - references/cell-selection.md + - references/cell-spanning.md + - references/row-selection.md + - references/sorting.md + - references/aggregation.md + - name: Table State + slug: table-state + type: core domain: foundations - path: 'packages/table-core/skills/api-not-found/SKILL.md' - package: 'packages/table-core' - description: 'Diagnose missing TanStack Table exports, options, state slices, and instance methods by checking the installed package declarations (dist/**/*.d.ts), adapter/version mismatches, tableFeatures registration, and v9 prototype APIs before inventing replacements.' - requires: ['core', 'table-features'] + path: packages/table-core/skills/table-state/SKILL.md + package: packages/table-core + description: + Choose Table v9 state ownership, atoms, initialization, updates, + and resets. Load for controlled slices or state coordination; use the + adapter state skill for reactive reads. + requires: + - core sources: - - 'TanStack/table:packages/table-core/src/index.ts' - - 'TanStack/table:packages/table-core/src/types/TableFeatures.ts' - - 'TanStack/table:docs/framework/react/guide/migrating.md' - - - name: 'Custom Features' + - TanStack/table:docs/framework/react/guide/table-state.md + - TanStack/table:packages/table-core/src/core/table/coreTablesFeature.types.ts + - TanStack/table:packages/table-core/src/core/table/coreTablesFeature.utils.ts + - TanStack/table:packages/table-core/src/core/reactivity/coreReactivityFeature.utils.ts + - name: Custom Features slug: custom-features - type: sub-skill + type: core domain: foundations - path: 'packages/table-core/skills/custom-features/SKILL.md' - package: 'packages/table-core' - description: 'Author a TanStack Table v9 feature plugin across all 10 FeatureMaps and every table/column/row/cell/header API installation path, including prototypes, memoDeps, instance data, and advanced row-model maps, after checking built-ins and meta.' - requires: ['core', 'table-features', 'typescript'] - sources: - - 'TanStack/table:docs/framework/react/guide/custom-features.md' - - 'TanStack/table:packages/table-core/src/types' - - 'TanStack/table:packages/table-core/src/types/TableFeatures.ts' - - 'TanStack/table:packages/table-core/src/utils.ts' - - 'TanStack/table:packages/table-core/src/features' - - 'TanStack/table:examples/react/custom-plugin' - - - name: 'Migrate v8 to v9' + path: packages/table-core/skills/custom-features/SKILL.md + package: packages/table-core + description: Implement a Table v9 plugin when built-ins and typed meta are + insufficient. Covers FeatureMaps, runtime lifecycle hooks, prototypes, and + a complete checked example. + requires: + - core + - table-features + sources: + - TanStack/table:docs/framework/react/guide/custom-features.md + - TanStack/table:packages/table-core/src/types + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:packages/table-core/src/utils.ts + - TanStack/table:packages/table-core/src/features + - TanStack/table:examples/react/custom-plugin + references: + - references/plugin-example.md + - name: Migrate v8 to v9 slug: migrate-v8-to-v9 - type: lifecycle + type: migration domain: foundations - path: 'packages/table-core/skills/migrate-v8-to-v9/SKILL.md' - package: 'packages/table-core' - description: 'Perform a complete TanStack Table v8-to-v9 migration audit: all 16 feature registrations, every row-model and registry slot, state/store changes, prototype methods, full pinning and resizing mappings, sorting and selection semantics, removed internals, helpers, meta typing, and generic changes. useLegacyTable is only a deprecated temporary bridge when already encountered.' - requires: ['core', 'table-features', 'typescript'] - sources: - - 'TanStack/table:docs/framework/react/guide/migrating.md' - - 'TanStack/table:docs/framework/preact/guide/migrating.md' - - 'TanStack/table:docs/framework/solid/guide/migrating.md' - - 'TanStack/table:docs/framework/svelte/guide/migrating.md' - - 'TanStack/table:docs/framework/vue/guide/migrating.md' - - 'TanStack/table:docs/framework/angular/guide/migrating.md' - - 'TanStack/table:docs/framework/lit/guide/migrating.md' - - 'TanStack/table:packages/table-core/src/index.ts' - - 'TanStack/table:packages/table-core/src/types/TableFeatures.ts' - - 'TanStack/table:packages/table-core/src/features/column-pinning/columnPinningFeature.types.ts' - - 'TanStack/table:packages/table-core/src/features/column-resizing/columnResizingFeature.types.ts' - - 'TanStack/table:packages/react-table/src/legacy.ts' - - - name: 'Column Faceting' - slug: column-faceting - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/column-faceting/SKILL.md' - package: 'packages/table-core' - description: 'Build faceted filter UIs with columnFacetingFeature, facetedRowModel, facetedUniqueValues, and facetedMinMaxValues. Covers own-filter exclusion, other-filter context, incomplete server-page counts, and installed feature-source API lookup.' - requires: ['core', 'table-features', 'column-filtering'] - sources: - - 'TanStack/table:docs/framework/react/guide/column-faceting.md' - - 'TanStack/table:packages/table-core/src/features/column-faceting' - - 'TanStack/table:examples/react/filters-faceted' - - - name: 'Column Filtering' - slug: column-filtering - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/column-filtering/SKILL.md' - package: 'packages/table-core' - description: 'Filter columns with columnFilteringFeature, filteredRowModel, filterFns, filterMeta, nested-row direction, and manualFiltering. Load for accessor/filter compatibility, controlled filter updaters, or client/server filter ownership.' - requires: ['core', 'table-features', 'client-vs-server'] - sources: - - 'TanStack/table:docs/framework/react/guide/column-filtering.md' - - 'TanStack/table:packages/table-core/src/features/column-filtering' - - 'TanStack/table:examples/react/filters' - - - name: 'Grouping' - slug: grouping - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/grouping/SKILL.md' - package: 'packages/table-core' - description: 'Group and aggregate rows with columnGroupingFeature, groupedRowModel, aggregationFns, groupedColumnMode, and manualGrouping. Covers grouped/placeholder/aggregated cells plus expansion and pagination semantics.' - requires: ['core', 'table-features', 'client-vs-server'] - sources: - - 'TanStack/table:docs/framework/react/guide/grouping.md' - - 'TanStack/table:packages/table-core/src/features/column-grouping' - - 'TanStack/table:examples/react/grouping' - - - name: 'Aggregation' - slug: aggregation - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/aggregation/SKILL.md' - package: 'packages/table-core' - description: 'Aggregate columns independently of grouping with rowAggregationFeature, built-in or custom aggregation functions, caller-selected row scopes, keyed results, grouped merges, and manual values.' - requires: ['core', 'table-features'] - sources: - - 'TanStack/table:docs/guide/aggregation.md' - - 'TanStack/table:docs/framework/react/guide/aggregation.md' - - 'TanStack/table:packages/table-core/src/features/row-aggregation' - - 'TanStack/table:examples/react/aggregation' - - 'TanStack/table:examples/react/grouped-aggregation' - - - name: 'Column Ordering' - slug: column-ordering - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/column-ordering/SKILL.md' - package: 'packages/table-core' - description: 'Control leaf columnOrder with stable IDs while respecting pinning regions, visibility, and groupedColumnMode precedence. Load for column drag-and-drop or rendered order that differs from state.' - requires: ['core', 'table-features'] - sources: - - 'TanStack/table:docs/framework/react/guide/column-ordering.md' - - 'TanStack/table:packages/table-core/src/features/column-ordering' - - 'TanStack/table:examples/react/column-dnd' - - - name: 'Column Pinning' - slug: column-pinning - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/column-pinning/SKILL.md' - package: 'packages/table-core' - description: 'Pin columns into logical start/center/end regions with columnPinningFeature and implement sticky CSS, RTL logical offsets, z-index, backgrounds, overflow, and widths without gaps or overlaps.' - requires: ['core', 'table-features', 'column-sizing'] - sources: - - 'TanStack/table:docs/framework/react/guide/column-pinning.md' - - 'TanStack/table:packages/table-core/src/features/column-pinning' - - 'TanStack/table:examples/react/column-pinning-sticky' - - - name: 'Column Resizing' - slug: column-resizing - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/column-resizing/SKILL.md' - package: 'packages/table-core' - description: 'Wire columnResizingFeature, header.getResizeHandler, resize modes/direction, pointer or touch events, and performant CSS-variable updates. Requires columnSizingFeature and renderer-owned handles/styles.' - requires: ['core', 'table-features', 'column-sizing'] - sources: - - 'TanStack/table:docs/framework/react/guide/column-resizing.md' - - 'TanStack/table:packages/table-core/src/features/column-resizing' - - 'TanStack/table:examples/react/column-resizing-performant' - - - name: 'Column Sizing' - slug: column-sizing - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/column-sizing/SKILL.md' - package: 'packages/table-core' - description: 'Use columnSizingFeature numeric size/minSize/maxSize state, getSize/getStart/getAfter offsets, and total sizes in table, grid, or flex CSS. Load for auto/percentage misconceptions or sizing/pinning layout mismatch.' - requires: ['core', 'table-features'] - sources: - - 'TanStack/table:docs/framework/react/guide/column-sizing.md' - - 'TanStack/table:packages/table-core/src/features/column-sizing' - - 'TanStack/table:examples/react/column-sizing' - - - name: 'Column Visibility' - slug: column-visibility - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/column-visibility/SKILL.md' - package: 'packages/table-core' - description: 'Hide columns with columnVisibilityFeature while rendering visibility-aware header, column, and cell collections. Covers false-versus-absent state, enableHiding semantics, and hidden columns remaining in DOM through getAll APIs.' - requires: ['core', 'table-features'] - sources: - - 'TanStack/table:docs/framework/react/guide/column-visibility.md' - - 'TanStack/table:packages/table-core/src/features/column-visibility' - - 'TanStack/table:examples/react/column-visibility' - - - name: 'Global Filtering' - slug: global-filtering - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/global-filtering/SKILL.md' - package: 'packages/table-core' - description: 'Apply globalFilter across eligible columns with globalFilteringFeature, columnFilteringFeature, filteredRowModel, globalFilterFn, and manual server filtering. Covers default string/number eligibility and explicit exclusions.' - requires: ['core', 'table-features', 'client-vs-server', 'column-filtering'] - sources: - - 'TanStack/table:docs/framework/react/guide/global-filtering.md' - - 'TanStack/table:packages/table-core/src/features/global-filtering' - - 'TanStack/table:examples/react/filters' - - - name: 'Expanding' - slug: expanding - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/expanding/SKILL.md' - package: 'packages/table-core' - description: 'Expand hierarchical subrows or custom detail panels with rowExpandingFeature, expandedRowModel, getSubRows, getRowCanExpand, manualExpanding, and paginateExpandedRows. Separates expansion state from user-rendered detail UI.' - requires: ['core', 'table-features', 'client-vs-server'] - sources: - - 'TanStack/table:docs/framework/react/guide/expanding.md' - - 'TanStack/table:packages/table-core/src/features/row-expanding' - - 'TanStack/table:examples/react/expanding' - - - name: 'Pagination' - slug: pagination - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/pagination/SKILL.md' - package: 'packages/table-core' - description: 'Paginate with rowPaginationFeature and paginatedRowModel or manualPagination. Covers pageIndex/pageSize, rowCount/pageCount, next-page limits, already-paginated server data, and autoResetPageIndex surprises.' - requires: ['core', 'table-features', 'client-vs-server'] - sources: - - 'TanStack/table:docs/framework/react/guide/pagination.md' - - 'TanStack/table:packages/table-core/src/features/row-pagination' - - 'TanStack/table:examples/react/pagination' - - - name: 'Row Pinning' - slug: row-pinning - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/row-pinning/SKILL.md' - package: 'packages/table-core' - description: 'Pin stable row IDs into top/center/bottom collections with rowPinningFeature and keepPinnedRows. Covers getRowId, filtering/pagination visibility, explicit region rendering, and renderer-owned sticky CSS.' - requires: ['core', 'table-features'] - sources: - - 'TanStack/table:docs/framework/react/guide/row-pinning.md' - - 'TanStack/table:packages/table-core/src/features/row-pinning' - - 'TanStack/table:examples/react/row-pinning' - - - name: 'Cell Selection' - slug: cell-selection - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/cell-selection/SKILL.md' - package: 'packages/table-core' - description: 'Select, add, and subtract rectangular cell ranges with cellSelectionFeature: ordered include/exclude operations, modifier dragging, final positive bounds, selection edges, and render-order resolution under pinning. Load for spreadsheet-style or “select all except” behavior.' - requires: ['core', 'table-features'] - sources: - - 'TanStack/table:docs/framework/react/guide/cell-selection.md' - - 'TanStack/table:packages/table-core/src/features/cell-selection' - - 'TanStack/table:examples/react/cell-selection' - - - name: 'Cell Spanning' - slug: cell-spanning - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/cell-spanning/SKILL.md' - package: 'packages/table-core' - description: 'Merge adjacent body cells with cellSpanningFeature: value-based rowSpan via spanRows, per-row colSpan via spanColumns, and the covered-cell convention where a span of 0 means skip the cell. Load for merged grids, spans lost after sorting or paging, or ragged rows.' - requires: ['core', 'table-features'] - sources: - - 'TanStack/table:docs/framework/react/guide/cell-spanning.md' - - 'TanStack/table:packages/table-core/src/features/cell-spanning' - - 'TanStack/table:examples/react/cell-spanning' - - - name: 'Row Selection' - slug: row-selection - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/row-selection/SKILL.md' - package: 'packages/table-core' - description: 'Maintain rowSelection ID state with stable getRowId, single/multi/subrow rules, current/filtered/grouped selected models, and manual-pagination semantics. Load when selected IDs outlive loaded Row objects or data removal.' - requires: ['core', 'table-features'] - sources: - - 'TanStack/table:docs/framework/react/guide/row-selection.md' - - 'TanStack/table:packages/table-core/src/features/row-selection' - - 'TanStack/table:examples/react/row-selection' - - - name: 'Sorting' - slug: sorting - type: sub-skill - domain: feature-plugins - path: 'packages/table-core/skills/sorting/SKILL.md' - package: 'packages/table-core' - description: 'Sort with rowSortingFeature, sortedRowModel, sortFns, multi-sort/removal options, sortUndefined, and manualSorting. Covers comparator direction, incoming server order, and explicit product sorting cycles.' - requires: ['core', 'table-features', 'client-vs-server'] - sources: - - 'TanStack/table:docs/framework/react/guide/sorting.md' - - 'TanStack/table:packages/table-core/src/features/row-sorting' - - 'TanStack/table:examples/react/sorting' - - - name: 'React Getting Started' + path: packages/table-core/skills/migrate-v8-to-v9/SKILL.md + package: packages/table-core + description: + Audit and migrate Table v8 to v9. Inventory affected APIs, follow + the shared checklist, and read only the required architecture, state, + feature, and TypeScript mappings. + requires: + - core + sources: + - TanStack/table:docs/framework/react/guide/migrating.md + - TanStack/table:docs/framework/preact/guide/migrating.md + - TanStack/table:docs/framework/solid/guide/migrating.md + - TanStack/table:docs/framework/svelte/guide/migrating.md + - TanStack/table:docs/framework/vue/guide/migrating.md + - TanStack/table:docs/framework/angular/guide/migrating.md + - TanStack/table:docs/framework/lit/guide/migrating.md + - TanStack/table:packages/table-core/src/index.ts + - TanStack/table:packages/table-core/src/types/TableFeatures.ts + - TanStack/table:packages/table-core/src/features/column-pinning/columnPinningFeature.types.ts + - TanStack/table:packages/table-core/src/features/column-resizing/columnResizingFeature.types.ts + - TanStack/table:packages/react-table/src/legacy.ts + references: + - references/architecture.md + - references/state.md + - references/feature-apis.md + - references/typescript.md + - name: React Getting Started slug: getting-started type: framework domain: framework-adapters - path: 'packages/react-table/skills/getting-started/SKILL.md' - package: 'packages/react-table' - description: 'Create a TanStack React Table v9 table with useTable, tableFeatures, stable data/columns, header and row models, and FlexRender/flexRender. Load for a first React table or when adapting a kitchen-sink example without importing every feature.' + path: packages/react-table/skills/getting-started/SKILL.md + package: packages/react-table + description: + Create and render Table v9 with the react adapter. Route reusable + createTableHook components, Query and Virtual integration, and framework + setup; use table-state for reactive ownership. requires: - ['@tanstack/table-core#core', '@tanstack/table-core#table-features'] - sources: - - 'TanStack/table:docs/framework/react/guide/migrating.md' - - 'TanStack/table:examples/react/basic-use-table' - - 'TanStack/table:packages/react-table/src/index.ts' - - - name: 'React Table State' + - '@tanstack/table-core#core' + sources: + - TanStack/table:docs/framework/react/guide/migrating.md + - TanStack/table:examples/react/basic-use-table + - TanStack/table:packages/react-table/src/index.ts + - TanStack/table:docs/framework/react/guide/composable-tables.md + - TanStack/table:docs/framework/react/guide/table-context.md + - TanStack/table:examples/react/composable-tables + - TanStack/table:packages/react-table/src/createTableHook.tsx + - TanStack/table:packages/react-table/src/createTableHookContexts.tsx + - TanStack/table:examples/react/with-tanstack-query + - TanStack/table:examples/react/virtualized-infinite-scrolling + - TanStack/table:docs/framework/react/guide/pagination.md + - TanStack/table:docs/framework/react/guide/virtualization.md + - TanStack/table:examples/react/virtualized-rows + - TanStack/table:examples/react/virtualized-columns + references: + - references/create-table-hook.md + - references/with-tanstack-query.md + - references/with-tanstack-virtual.md + - name: React Table State slug: table-state type: framework domain: framework-adapters - path: 'packages/react-table/skills/table-state/SKILL.md' - package: 'packages/react-table' - description: 'Read and own React Table v9 state with selected table.state, useTable selectors, table.Subscribe/Subscribe, table.atoms, table.store, controlled state plus on*Change, and external TanStack Store atoms. Includes React Compiler builder-method subscription foot-guns.' - requires: ['@tanstack/table-core#core', 'getting-started'] - sources: - - 'TanStack/table:docs/framework/react/guide/table-state.md' - - 'TanStack/table:docs/framework/react/guide/react-compiler.md' - - 'TanStack/table:examples/react/basic-subscribe' - - 'TanStack/table:packages/react-table/src/Subscribe.ts' - - 'TanStack/table:packages/react-table/src/useTable.ts' - - - name: 'React Migrate v8 to v9' - slug: migrate-v8-to-v9 - type: lifecycle - domain: framework-adapters - path: 'packages/react-table/skills/migrate-v8-to-v9/SKILL.md' - package: 'packages/react-table' - description: 'Migrate @tanstack/react-table from v8 useReactTable to v9 useTable, explicit tableFeatures, create*RowModel slots, atomic state, FlexRender/Subscribe, helper changes, and composable tables. Treat useLegacyTable only as a deprecated bridge when already present.' + path: packages/react-table/skills/table-state/SKILL.md + package: packages/react-table + description: + Read and control Table v9 state in react. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. requires: - [ - '@tanstack/table-core#migrate-v8-to-v9', - 'getting-started', - 'table-state', - ] - sources: - - 'TanStack/table:docs/framework/react/guide/migrating.md' - - 'TanStack/table:packages/react-table/src/index.ts' - - 'TanStack/table:examples/react/basic-use-table' - - 'TanStack/table:packages/react-table/src/legacy.ts' - - - name: 'React createTableHook' - slug: create-table-hook - type: framework - domain: framework-adapters - path: 'packages/react-table/skills/create-table-hook/SKILL.md' - package: 'packages/react-table' - description: 'Create an app-level React table factory with createTableHook, useAppTable, createAppColumnHelper, shared features/defaults, optional component registries, AppTable/AppCell/AppHeader wrappers, and typed context hooks. Covers scoped contexts, HMR circular imports, and context over prop drilling.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/react/guide/composable-tables.md' - - 'TanStack/table:docs/framework/react/guide/table-context.md' - - 'TanStack/table:examples/react/composable-tables' - - 'TanStack/table:packages/react-table/src/createTableHook.tsx' - - 'TanStack/table:packages/react-table/src/createTableHookContexts.tsx' - - - name: 'React with TanStack Query' - slug: with-tanstack-query - type: composition + - '@tanstack/table-core#table-state' + sources: + - TanStack/table:docs/framework/react/guide/table-state.md + - TanStack/table:docs/framework/react/guide/react-compiler.md + - TanStack/table:examples/react/basic-subscribe + - TanStack/table:packages/react-table/src/Subscribe.ts + - TanStack/table:packages/react-table/src/useTable.ts + references: + - references/reactivity.md + - name: React Migrate v8 to v9 + slug: migrate-v8-to-v9 + type: migration domain: framework-adapters - path: 'packages/react-table/skills/with-tanstack-query/SKILL.md' - package: 'packages/react-table' - description: 'Compose React Table v9 with TanStack Query for server filtering, sorting, pagination, and infinite data. Covers table state in query keys, manual* boundaries, server counts, previous data, and using query results directly rather than duplicating state.' + path: packages/react-table/skills/migrate-v8-to-v9/SKILL.md + package: packages/react-table + description: Migrate react Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. requires: - [ - '@tanstack/table-core#client-vs-server', - 'getting-started', - 'table-state', - ] - sources: - - 'TanStack/table:examples/react/with-tanstack-query' - - 'TanStack/table:examples/react/virtualized-infinite-scrolling' - - 'TanStack/table:docs/framework/react/guide/pagination.md' - - - name: 'React with TanStack Virtual' - slug: with-tanstack-virtual - type: composition - domain: framework-adapters - path: 'packages/react-table/skills/with-tanstack-virtual/SKILL.md' - package: 'packages/react-table' - description: 'Virtualize final React Table row or column models with TanStack Virtual. Covers scroll elements, stable row keys, data-index measurement, dynamic heights, sticky headers/columns, grid/flex geometry, infinite fetching, and Virtual as renderer composition rather than a Table feature.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/react/guide/virtualization.md' - - 'TanStack/table:examples/react/virtualized-rows' - - 'TanStack/table:examples/react/virtualized-columns' - - 'TanStack/table:examples/react/virtualized-infinite-scrolling' - - - name: 'Preact Getting Started' + - '@tanstack/table-core#migrate-v8-to-v9' + sources: + - TanStack/table:docs/framework/react/guide/migrating.md + - TanStack/table:packages/react-table/src/index.ts + - TanStack/table:packages/react-table/src/legacy.ts + - TanStack/table:examples/react/basic-use-table + references: + - references/adapter-migration.md + - name: Preact Getting Started slug: getting-started type: framework domain: framework-adapters - path: 'packages/preact-table/skills/getting-started/SKILL.md' - package: 'packages/preact-table' - description: 'Create a native @tanstack/preact-table v9 table with useTable, tableFeatures, stable inputs, and Preact render helpers. Load when replacing @tanstack/react-table through preact/compat or starting a Preact table.' + path: packages/preact-table/skills/getting-started/SKILL.md + package: packages/preact-table + description: + Create and render Table v9 with the preact adapter. Route reusable + createTableHook components, Query and Virtual integration, and framework + setup; use table-state for reactive ownership. requires: - ['@tanstack/table-core#core', '@tanstack/table-core#table-features'] - sources: - - 'TanStack/table:docs/framework/preact/guide/migrating.md' - - 'TanStack/table:examples/preact/basic-use-table' - - 'TanStack/table:packages/preact-table/src/index.ts' - - - name: 'Preact Table State' + - '@tanstack/table-core#core' + sources: + - TanStack/table:docs/framework/preact/guide/migrating.md + - TanStack/table:examples/preact/basic-use-table + - TanStack/table:packages/preact-table/src/index.ts + - TanStack/table:docs/framework/preact/guide/composable-tables.md + - TanStack/table:docs/framework/preact/guide/table-context.md + - TanStack/table:examples/preact/composable-tables + - TanStack/table:packages/preact-table/src/createTableHook.tsx + - TanStack/table:packages/preact-table/src/createTableHookContexts.tsx + - TanStack/table:examples/preact/with-tanstack-query + - TanStack/table:docs/framework/preact/guide/pagination.md + - TanStack/table:docs/framework/preact/guide/virtualization.md + references: + - references/create-table-hook.md + - references/with-tanstack-query.md + - references/with-tanstack-virtual.md + - name: Preact Table State slug: table-state type: framework domain: framework-adapters - path: 'packages/preact-table/skills/table-state/SKILL.md' - package: 'packages/preact-table' - description: 'Read and own Preact Table state with selected table.state, useTable selectors, table.Subscribe, table.atoms/store, controlled slices, and external Preact Store atoms. Distinguishes current snapshots from reactive subscriptions and avoids React-package imports.' - requires: ['@tanstack/table-core#core', 'getting-started'] - sources: - - 'TanStack/table:docs/framework/preact/guide/table-state.md' - - 'TanStack/table:examples/preact/basic-subscribe' - - 'TanStack/table:packages/preact-table/src/useTable.ts' - - - name: 'Preact Migrate v8 to v9' - slug: migrate-v8-to-v9 - type: lifecycle - domain: framework-adapters - path: 'packages/preact-table/skills/migrate-v8-to-v9/SKILL.md' - package: 'packages/preact-table' - description: 'Move a Preact v8 app from the React adapter/preact/compat to native @tanstack/preact-table v9, useTable, tableFeatures row models, atom-backed state, and current render helpers while applying shared v9 breaking changes.' + path: packages/preact-table/skills/table-state/SKILL.md + package: packages/preact-table + description: + Read and control Table v9 state in preact. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. requires: - [ - '@tanstack/table-core#migrate-v8-to-v9', - 'getting-started', - 'table-state', - ] - sources: - - 'TanStack/table:docs/framework/preact/guide/migrating.md' - - 'TanStack/table:packages/preact-table/src/index.ts' - - 'TanStack/table:examples/preact/basic-use-table' - - - name: 'Preact createTableHook' - slug: create-table-hook - type: framework - domain: framework-adapters - path: 'packages/preact-table/skills/create-table-hook/SKILL.md' - package: 'packages/preact-table' - description: 'Create a reusable Preact useAppTable and createAppColumnHelper with shared features/options, optional App component registries, typed table/cell/header context hooks, scoped contexts, and correct provider subscription boundaries.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/preact/guide/composable-tables.md' - - 'TanStack/table:docs/framework/preact/guide/table-context.md' - - 'TanStack/table:examples/preact/composable-tables' - - 'TanStack/table:packages/preact-table/src/createTableHook.tsx' - - 'TanStack/table:packages/preact-table/src/createTableHookContexts.tsx' - - - name: 'Preact with TanStack Query' - slug: with-tanstack-query - type: composition + - '@tanstack/table-core#table-state' + sources: + - TanStack/table:docs/framework/preact/guide/table-state.md + - TanStack/table:examples/preact/basic-subscribe + - TanStack/table:packages/preact-table/src/useTable.ts + references: + - references/reactivity.md + - name: Preact Migrate v8 to v9 + slug: migrate-v8-to-v9 + type: migration domain: framework-adapters - path: 'packages/preact-table/skills/with-tanstack-query/SKILL.md' - package: 'packages/preact-table' - description: 'Compose native Preact Table with TanStack Query using table state in query keys, already-processed server pages, manual filtering/sorting/pagination, server counts, and Preact-specific query/state APIs.' + path: packages/preact-table/skills/migrate-v8-to-v9/SKILL.md + package: packages/preact-table + description: Migrate preact Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. requires: - [ - '@tanstack/table-core#client-vs-server', - 'getting-started', - 'table-state', - ] - sources: - - 'TanStack/table:examples/preact/with-tanstack-query' - - 'TanStack/table:docs/framework/preact/guide/pagination.md' - - - name: 'Preact with TanStack Virtual' - slug: with-tanstack-virtual - type: composition - domain: framework-adapters - path: 'packages/preact-table/skills/with-tanstack-virtual/SKILL.md' - package: 'packages/preact-table' - description: 'Apply Preact Virtual rendering to the final Preact Table row or column model. Uses the maintained adapter guide and installed source for exact APIs; covers counts, scroll targets, keys, measurements, spacer geometry, and renderer-owned sticky/sizing CSS.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/preact/guide/virtualization.md' - - 'TanStack/table:packages/preact-table/src/index.ts' - - - name: 'Solid Getting Started' + - '@tanstack/table-core#migrate-v8-to-v9' + sources: + - TanStack/table:docs/framework/preact/guide/migrating.md + - TanStack/table:packages/preact-table/src/index.ts + - TanStack/table:examples/preact/basic-use-table + references: + - references/adapter-migration.md + - name: Solid Getting Started slug: getting-started type: framework domain: framework-adapters - path: 'packages/solid-table/skills/getting-started/SKILL.md' - package: 'packages/solid-table' - description: 'Create a Solid Table v9 table with createTable, explicit tableFeatures, reactive data getters, stable static inputs, and Solid JSX rendering. Load when replacing createSolidTable or adapting React examples.' + path: packages/solid-table/skills/getting-started/SKILL.md + package: packages/solid-table + description: + Create and render Table v9 with the solid adapter. Route reusable + createTableHook components, Query and Virtual integration, and framework + setup; use table-state for reactive ownership. requires: - ['@tanstack/table-core#core', '@tanstack/table-core#table-features'] - sources: - - 'TanStack/table:docs/framework/solid/guide/migrating.md' - - 'TanStack/table:examples/solid/basic-use-table' - - 'TanStack/table:packages/solid-table/src/index.tsx' - - - name: 'Solid Table State' + - '@tanstack/table-core#core' + sources: + - TanStack/table:docs/framework/solid/guide/migrating.md + - TanStack/table:examples/solid/basic-use-table + - TanStack/table:packages/solid-table/src/index.tsx + - TanStack/table:docs/framework/solid/guide/composable-tables.md + - TanStack/table:examples/solid/composable-tables + - TanStack/table:packages/solid-table/src/createTableHook.tsx + - TanStack/table:examples/solid/with-tanstack-query + - TanStack/table:docs/framework/solid/guide/pagination.md + - TanStack/table:docs/framework/solid/guide/virtualization.md + - TanStack/table:examples/solid/virtualized-rows + - TanStack/table:examples/solid/virtualized-columns + - TanStack/table:examples/solid/virtualized-infinite-scrolling + references: + - references/create-table-hook.md + - references/with-tanstack-query.md + - references/with-tanstack-virtual.md + - name: Solid Table State slug: table-state type: framework domain: framework-adapters - path: 'packages/solid-table/skills/table-state/SKILL.md' - package: 'packages/solid-table' - description: 'Read Solid-backed table.atoms inside JSX, createMemo, createEffect, or table.Subscribe; own slices with native signals or external TanStack Store atoms; and apply value-or-updater callbacks without React-style rerender workarounds.' - requires: ['@tanstack/table-core#core', 'getting-started'] - sources: - - 'TanStack/table:docs/framework/solid/guide/table-state.md' - - 'TanStack/table:examples/solid/basic-external-state' - - 'TanStack/table:packages/solid-table/src/createTable.ts' - - - name: 'Solid Migrate v8 to v9' - slug: migrate-v8-to-v9 - type: lifecycle - domain: framework-adapters - path: 'packages/solid-table/skills/migrate-v8-to-v9/SKILL.md' - package: 'packages/solid-table' - description: 'Migrate Solid from v8 createSolidTable to v9 createTable, explicit features and row-model slots, signal-backed atoms, current helpers/rendering, prototype methods, sortFn names, and logical start/end pinning.' + path: packages/solid-table/skills/table-state/SKILL.md + package: packages/solid-table + description: + Read and control Table v9 state in solid. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. requires: - [ - '@tanstack/table-core#migrate-v8-to-v9', - 'getting-started', - 'table-state', - ] - sources: - - 'TanStack/table:docs/framework/solid/guide/migrating.md' - - 'TanStack/table:packages/solid-table/src/index.tsx' - - 'TanStack/table:examples/solid/basic-use-table' - - - name: 'Solid createTableHook' - slug: create-table-hook - type: framework - domain: framework-adapters - path: 'packages/solid-table/skills/create-table-hook/SKILL.md' - package: 'packages/solid-table' - description: 'Create a reusable Solid createAppTable/createAppColumnHelper with shared features/defaults, reactive per-table getters, optional App component registries, and typed context hooks for registered table/cell/header UI.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/solid/guide/composable-tables.md' - - 'TanStack/table:examples/solid/composable-tables' - - 'TanStack/table:packages/solid-table/src/createTableHook.tsx' - - - name: 'Solid with TanStack Query' - slug: with-tanstack-query - type: composition + - '@tanstack/table-core#table-state' + sources: + - TanStack/table:docs/framework/solid/guide/table-state.md + - TanStack/table:examples/solid/basic-external-state + - TanStack/table:packages/solid-table/src/createTable.ts + references: + - references/reactivity.md + - name: Solid Migrate v8 to v9 + slug: migrate-v8-to-v9 + type: migration domain: framework-adapters - path: 'packages/solid-table/skills/with-tanstack-query/SKILL.md' - package: 'packages/solid-table' - description: 'Compose Solid Query reactive options with Solid Table manual processing. Covers tracked query-key signals, query result getters, server counts, and avoiding React Query patterns or duplicated data state.' + path: packages/solid-table/skills/migrate-v8-to-v9/SKILL.md + package: packages/solid-table + description: Migrate solid Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. requires: - [ - '@tanstack/table-core#client-vs-server', - 'getting-started', - 'table-state', - ] - sources: - - 'TanStack/table:examples/solid/with-tanstack-query' - - 'TanStack/table:docs/framework/solid/guide/pagination.md' - - - name: 'Solid with TanStack Virtual' - slug: with-tanstack-virtual - type: composition - domain: framework-adapters - path: 'packages/solid-table/skills/with-tanstack-virtual/SKILL.md' - package: 'packages/solid-table' - description: 'Virtualize Solid Table row/column models and infinite Query data with reactive counts, scroll targets, stable keys, dynamic measurement, transforms, sticky regions, and grid/flex sizing.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/solid/guide/virtualization.md' - - 'TanStack/table:examples/solid/virtualized-rows' - - 'TanStack/table:examples/solid/virtualized-columns' - - 'TanStack/table:examples/solid/virtualized-infinite-scrolling' - - - name: 'Svelte Getting Started' + - '@tanstack/table-core#migrate-v8-to-v9' + sources: + - TanStack/table:docs/framework/solid/guide/migrating.md + - TanStack/table:packages/solid-table/src/index.tsx + - TanStack/table:examples/solid/basic-use-table + references: + - references/adapter-migration.md + - name: Svelte Getting Started slug: getting-started type: framework domain: framework-adapters - path: 'packages/svelte-table/skills/getting-started/SKILL.md' - package: 'packages/svelte-table' - description: 'Create a Svelte 5 TanStack Table v9 table with createTable, explicit tableFeatures, rune-backed data getters, stable static inputs, FlexRender, and headless markup. Load when replacing createSvelteTable or pre-rune patterns.' + path: packages/svelte-table/skills/getting-started/SKILL.md + package: packages/svelte-table + description: + Create and render Table v9 with the svelte adapter. Route reusable + createTableHook components, Query and Virtual integration, and framework + setup; use table-state for reactive ownership. requires: - ['@tanstack/table-core#core', '@tanstack/table-core#table-features'] - sources: - - 'TanStack/table:docs/framework/svelte/guide/migrating.md' - - 'TanStack/table:examples/svelte/basic-create-table' - - 'TanStack/table:packages/svelte-table/src/index.ts' - - - name: 'Svelte Table State' + - '@tanstack/table-core#core' + sources: + - TanStack/table:docs/framework/svelte/guide/migrating.md + - TanStack/table:examples/svelte/basic-create-table + - TanStack/table:packages/svelte-table/src/index.ts + - TanStack/table:docs/framework/svelte/guide/composable-tables.md + - TanStack/table:examples/svelte/composable-tables + - TanStack/table:packages/svelte-table/src/createTableHook.svelte.ts + - TanStack/table:examples/svelte/with-tanstack-query + - TanStack/table:docs/framework/svelte/guide/pagination.md + - TanStack/table:docs/framework/svelte/guide/virtualization.md + - TanStack/table:examples/svelte/virtualized-rows + - TanStack/table:examples/svelte/virtualized-columns + - TanStack/table:examples/svelte/virtualized-infinite-scrolling + references: + - references/create-table-hook.md + - references/with-tanstack-query.md + - references/with-tanstack-virtual.md + - name: Svelte Table State slug: table-state type: framework domain: framework-adapters - path: 'packages/svelte-table/skills/table-state/SKILL.md' - package: 'packages/svelte-table' - description: 'Use Svelte 5 rune-aware table atoms and stores, $derived projections, reactive option getters, controlled $state or createTableState slices, external atoms, and auto-reset behavior without broad invalidation or snapshot mismatches.' - requires: ['@tanstack/table-core#core', 'getting-started'] - sources: - - 'TanStack/table:docs/framework/svelte/guide/table-state.md' - - 'TanStack/table:docs/framework/svelte/guide/pagination.md' - - 'TanStack/table:examples/svelte/basic-external-state' - - 'TanStack/table:packages/svelte-table/src/createTable.svelte.ts' - - 'TanStack/table:packages/svelte-table/src/createTableState.svelte.ts' - - - name: 'Svelte Migrate v8 to v9' - slug: migrate-v8-to-v9 - type: lifecycle - domain: framework-adapters - path: 'packages/svelte-table/skills/migrate-v8-to-v9/SKILL.md' - package: 'packages/svelte-table' - description: 'Complete Svelte v8-to-v9 migration reference: Svelte 5, createTable, beta.59 selector removal, explicit features and row-model slots, atom/rune state, rendering helpers, prototype methods, type generics, sorting, sizing, selection, and logical pinning.' + path: packages/svelte-table/skills/table-state/SKILL.md + package: packages/svelte-table + description: + Read and control Table v9 state in svelte. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. requires: - [ - '@tanstack/table-core#migrate-v8-to-v9', - 'getting-started', - 'table-state', - ] - sources: - - 'TanStack/table:docs/framework/svelte/guide/migrating.md' - - 'TanStack/table:packages/svelte-table/src/index.ts' - - 'TanStack/table:examples/svelte/basic-create-table' - - - name: 'Svelte createTableHook' - slug: create-table-hook - type: framework - domain: framework-adapters - path: 'packages/svelte-table/skills/create-table-hook/SKILL.md' - package: 'packages/svelte-table' - description: "Define a Svelte createAppTable/createAppColumnHelper using the adapter's rune-capable createTableHook implementation, shared features/defaults, reactive per-table getters, optional App component registries, and typed table/cell/header context hooks." - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/svelte/guide/composable-tables.md' - - 'TanStack/table:examples/svelte/composable-tables' - - 'TanStack/table:packages/svelte-table/src/createTableHook.svelte.ts' - - - name: 'Svelte with TanStack Query' - slug: with-tanstack-query - type: composition + - '@tanstack/table-core#table-state' + sources: + - TanStack/table:docs/framework/svelte/guide/table-state.md + - TanStack/table:docs/framework/svelte/guide/pagination.md + - TanStack/table:examples/svelte/basic-external-state + - TanStack/table:packages/svelte-table/src/createTable.svelte.ts + - TanStack/table:packages/svelte-table/src/createTableState.svelte.ts + references: + - references/reactivity.md + - name: Svelte Migrate v8 to v9 + slug: migrate-v8-to-v9 + type: migration domain: framework-adapters - path: 'packages/svelte-table/skills/with-tanstack-query/SKILL.md' - package: 'packages/svelte-table' - description: 'Compose Svelte Query with Svelte Table manual filtering, sorting, and pagination using reactive query inputs, query-result data getters, server counts, and a single source of server-data truth.' + path: packages/svelte-table/skills/migrate-v8-to-v9/SKILL.md + package: packages/svelte-table + description: Migrate svelte Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. requires: - [ - '@tanstack/table-core#client-vs-server', - 'getting-started', - 'table-state', - ] - sources: - - 'TanStack/table:examples/svelte/with-tanstack-query' - - 'TanStack/table:docs/framework/svelte/guide/pagination.md' - - - name: 'Svelte with TanStack Virtual' - slug: with-tanstack-virtual - type: composition - domain: framework-adapters - path: 'packages/svelte-table/skills/with-tanstack-virtual/SKILL.md' - package: 'packages/svelte-table' - description: 'Virtualize Svelte Table final row or column models with reactive counts and scroll targets, stable keys, dynamic measurement, absolute transforms, sticky regions, grid/flex sizing, and infinite data.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/svelte/guide/virtualization.md' - - 'TanStack/table:examples/svelte/virtualized-rows' - - 'TanStack/table:examples/svelte/virtualized-columns' - - 'TanStack/table:examples/svelte/virtualized-infinite-scrolling' - - - name: 'Vue Getting Started' + - '@tanstack/table-core#migrate-v8-to-v9' + sources: + - TanStack/table:docs/framework/svelte/guide/migrating.md + - TanStack/table:packages/svelte-table/src/index.ts + - TanStack/table:examples/svelte/basic-create-table + references: + - references/adapter-migration.md + - name: Vue Getting Started slug: getting-started type: framework domain: framework-adapters - path: 'packages/vue-table/skills/getting-started/SKILL.md' - package: 'packages/vue-table' - description: 'Create a Vue TanStack Table v9 table with useTable, explicit tableFeatures, stable columns/features, reactive ref or computed data, and Vue template/render helpers without destructuring reactive snapshots.' + path: packages/vue-table/skills/getting-started/SKILL.md + package: packages/vue-table + description: Create and render Table v9 with the vue adapter. Route reusable + createTableHook components, Query and Virtual integration, and framework + setup; use table-state for reactive ownership. requires: - ['@tanstack/table-core#core', '@tanstack/table-core#table-features'] - sources: - - 'TanStack/table:docs/framework/vue/guide/migrating.md' - - 'TanStack/table:examples/vue/basic-use-table' - - 'TanStack/table:packages/vue-table/src/index.ts' - - - name: 'Vue Table State' + - '@tanstack/table-core#core' + sources: + - TanStack/table:docs/framework/vue/guide/migrating.md + - TanStack/table:examples/vue/basic-use-table + - TanStack/table:packages/vue-table/src/index.ts + - TanStack/table:docs/framework/vue/guide/composable-tables.md + - TanStack/table:examples/vue/composable-tables + - TanStack/table:packages/vue-table/src/createTableHook.ts + - TanStack/table:examples/vue/with-tanstack-query + - TanStack/table:docs/framework/vue/guide/pagination.md + - TanStack/table:docs/framework/vue/guide/virtualization.md + - TanStack/table:examples/vue/virtualized-rows + - TanStack/table:examples/vue/virtualized-columns + - TanStack/table:examples/vue/virtualized-infinite-scrolling + references: + - references/create-table-hook.md + - references/with-tanstack-query.md + - references/with-tanstack-virtual.md + - name: Vue Table State slug: table-state type: framework domain: framework-adapters - path: 'packages/vue-table/skills/table-state/SKILL.md' - package: 'packages/vue-table' - description: 'Read Vue-backed table.atoms/store in templates, computed, watch, or table.Subscribe; own slices with refs/computed or external Vue Store atoms; and apply updater callbacks while preserving reactive option shapes.' - requires: ['@tanstack/table-core#core', 'getting-started'] - sources: - - 'TanStack/table:docs/framework/vue/guide/table-state.md' - - 'TanStack/table:examples/vue/basic-external-state' - - 'TanStack/table:packages/vue-table/src/useTable.ts' - - - name: 'Vue Migrate v8 to v9' - slug: migrate-v8-to-v9 - type: lifecycle - domain: framework-adapters - path: 'packages/vue-table/skills/migrate-v8-to-v9/SKILL.md' - package: 'packages/vue-table' - description: 'Migrate Vue v8 construction, implicit features, row-model options, state, helpers, rendering, instance methods, sorting names, meta typing, and physical pinning to the Vue v9 useTable architecture.' + path: packages/vue-table/skills/table-state/SKILL.md + package: packages/vue-table + description: Read and control Table v9 state in vue. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. requires: - [ - '@tanstack/table-core#migrate-v8-to-v9', - 'getting-started', - 'table-state', - ] - sources: - - 'TanStack/table:docs/framework/vue/guide/migrating.md' - - 'TanStack/table:packages/vue-table/src/index.ts' - - 'TanStack/table:examples/vue/basic-use-table' - - - name: 'Vue createTableHook' - slug: create-table-hook - type: framework - domain: framework-adapters - path: 'packages/vue-table/skills/create-table-hook/SKILL.md' - package: 'packages/vue-table' - description: 'Create a reusable Vue useAppTable/createAppColumnHelper with shared features/defaults, reactive per-table options, optional component registries, dynamic App wrappers, typed context hooks, and explicit types that break circular inference.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/vue/guide/composable-tables.md' - - 'TanStack/table:examples/vue/composable-tables' - - 'TanStack/table:packages/vue-table/src/createTableHook.ts' - - - name: 'Vue with TanStack Query' - slug: with-tanstack-query - type: composition + - '@tanstack/table-core#table-state' + sources: + - TanStack/table:docs/framework/vue/guide/table-state.md + - TanStack/table:examples/vue/basic-external-state + - TanStack/table:packages/vue-table/src/useTable.ts + references: + - references/reactivity.md + - name: Vue Migrate v8 to v9 + slug: migrate-v8-to-v9 + type: migration domain: framework-adapters - path: 'packages/vue-table/skills/with-tanstack-query/SKILL.md' - package: 'packages/vue-table' - description: 'Compose reactive Vue Query keys and results with Vue Table manual row processing, refs/computed state, server counts, and already-processed pages without duplicating query data into a drifting local ref.' + path: packages/vue-table/skills/migrate-v8-to-v9/SKILL.md + package: packages/vue-table + description: Migrate vue Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. requires: - [ - '@tanstack/table-core#client-vs-server', - 'getting-started', - 'table-state', - ] - sources: - - 'TanStack/table:examples/vue/with-tanstack-query' - - 'TanStack/table:docs/framework/vue/guide/pagination.md' - - - name: 'Vue with TanStack Virtual' - slug: with-tanstack-virtual - type: composition - domain: framework-adapters - path: 'packages/vue-table/skills/with-tanstack-virtual/SKILL.md' - package: 'packages/vue-table' - description: 'Virtualize Vue Table final row or column models with reactive counts/scroll targets, stable keys, measurement, spacer geometry, sticky CSS, grid/flex widths, and infinite server data.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/vue/guide/virtualization.md' - - 'TanStack/table:examples/vue/virtualized-rows' - - 'TanStack/table:examples/vue/virtualized-columns' - - 'TanStack/table:examples/vue/virtualized-infinite-scrolling' - - - name: 'Angular Getting Started' + - '@tanstack/table-core#migrate-v8-to-v9' + sources: + - TanStack/table:docs/framework/vue/guide/migrating.md + - TanStack/table:packages/vue-table/src/index.ts + - TanStack/table:examples/vue/basic-use-table + references: + - references/adapter-migration.md + - name: Angular Getting Started slug: getting-started type: framework domain: framework-adapters - path: 'packages/angular-table/skills/getting-started/SKILL.md' - package: 'packages/angular-table' - description: 'Create an Angular TanStack Table v9 table with injectTable inside injection context, explicit stable tableFeatures/columns, signal-backed data, and FlexRender structural directives or helpers.' + path: packages/angular-table/skills/getting-started/SKILL.md + package: packages/angular-table + description: + Create and render Table v9 with the angular adapter. Route reusable + createTableHook components, Query and Virtual integration, and framework + setup; use table-state for reactive ownership. requires: - ['@tanstack/table-core#core', '@tanstack/table-core#table-features'] - sources: - - 'TanStack/table:docs/framework/angular/guide/migrating.md' - - 'TanStack/table:docs/framework/angular/guide/rendering.md' - - 'TanStack/table:examples/angular/basic-inject-table' - - 'TanStack/table:packages/angular-table/src/index.ts' - - - name: 'Angular Table State' + - '@tanstack/table-core#core' + sources: + - TanStack/table:docs/framework/angular/guide/migrating.md + - TanStack/table:docs/framework/angular/guide/flex-render.md + - TanStack/table:examples/angular/basic-inject-table + - TanStack/table:packages/angular-table/src/index.ts + - TanStack/table:docs/framework/angular/guide/composable-tables.md + - TanStack/table:examples/angular/composable-tables + - TanStack/table:packages/angular-table/src/helpers/createTableHook.ts + - TanStack/table:examples/angular/with-tanstack-query + - TanStack/table:docs/framework/angular/guide/table-state.md + - TanStack/table:docs/framework/angular/guide/pagination.md + - TanStack/table:docs/framework/angular/guide/virtualization.md + - TanStack/table:examples/angular/virtualized-rows + - TanStack/table:examples/angular/virtualized-columns + - TanStack/table:examples/angular/virtualized-infinite-scrolling + references: + - references/create-table-hook.md + - references/with-tanstack-query.md + - references/with-tanstack-virtual.md + - name: Angular Table State slug: table-state type: framework domain: framework-adapters - path: 'packages/angular-table/skills/table-state/SKILL.md' - package: 'packages/angular-table' - description: 'Use Angular-signal-backed table.atoms, direct template reads, computed selectors, controlled signals, value-or-updater callbacks, and external Angular Store atoms while accounting for injectTable initializer reruns.' - requires: ['@tanstack/table-core#core', 'getting-started'] - sources: - - 'TanStack/table:docs/framework/angular/guide/table-state.md' - - 'TanStack/table:examples/angular/basic-external-state' - - 'TanStack/table:packages/angular-table/src/injectTable.ts' - - - name: 'Angular Migrate v8 to v9' - slug: migrate-v8-to-v9 - type: lifecycle - domain: framework-adapters - path: 'packages/angular-table/skills/migrate-v8-to-v9/SKILL.md' - package: 'packages/angular-table' - description: 'Migrate createAngularTable v8 code to injectTable v9 in injection context, tableFeatures row models, signal-backed state, stable reactive initializers, current FlexRender directives, helpers, prototype methods, sorting, and logical pinning.' + path: packages/angular-table/skills/table-state/SKILL.md + package: packages/angular-table + description: + Read and control Table v9 state in angular. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. requires: - [ - '@tanstack/table-core#migrate-v8-to-v9', - 'getting-started', - 'table-state', - ] - sources: - - 'TanStack/table:docs/framework/angular/guide/migrating.md' - - 'TanStack/table:packages/angular-table/src/index.ts' - - 'TanStack/table:examples/angular/basic-inject-table' - - - name: 'Angular createTableHook' - slug: create-table-hook - type: framework - domain: framework-adapters - path: 'packages/angular-table/skills/create-table-hook/SKILL.md' - package: 'packages/angular-table' - description: 'Create an Angular injectAppTable/createAppColumnHelper abstraction with shared features/defaults, registered components, injectTableContext/injectTableCellContext/injectTableHeaderContext, and correct FlexRender component versus function handling.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/angular/guide/composable-tables.md' - - 'TanStack/table:examples/angular/composable-tables' - - 'TanStack/table:packages/angular-table/src/helpers/createTableHook.ts' - - - name: 'Angular with TanStack Query' - slug: with-tanstack-query - type: composition + - '@tanstack/table-core#table-state' + sources: + - TanStack/table:docs/framework/angular/guide/table-state.md + - TanStack/table:examples/angular/basic-external-state + - TanStack/table:packages/angular-table/src/injectTable.ts + references: + - references/reactivity.md + - name: Angular Migrate v8 to v9 + slug: migrate-v8-to-v9 + type: migration domain: framework-adapters - path: 'packages/angular-table/skills/with-tanstack-query/SKILL.md' - package: 'packages/angular-table' - description: 'Compose Angular Query with signal-owned Table filtering, sorting, and pagination state. Covers reactive query options/keys, manual row-model boundaries, direct query data, server row/page counts, and injection context.' + path: packages/angular-table/skills/migrate-v8-to-v9/SKILL.md + package: packages/angular-table + description: Migrate angular Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. requires: - [ - '@tanstack/table-core#client-vs-server', - 'getting-started', - 'table-state', - ] - sources: - - 'TanStack/table:examples/angular/with-tanstack-query' - - 'TanStack/table:docs/framework/angular/guide/table-state.md' - - 'TanStack/table:docs/framework/angular/guide/pagination.md' - - - name: 'Angular with TanStack Virtual' - slug: with-tanstack-virtual - type: composition - domain: framework-adapters - path: 'packages/angular-table/skills/with-tanstack-virtual/SKILL.md' - package: 'packages/angular-table' - description: 'Virtualize Angular Table final row or column models inside the correct injection/reactive lifecycle. Covers signal counts, scroll elements, keys, measurement, transforms, sticky regions, grid/flex sizing, and infinite data.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/angular/guide/virtualization.md' - - 'TanStack/table:examples/angular/virtualized-rows' - - 'TanStack/table:examples/angular/virtualized-columns' - - 'TanStack/table:examples/angular/virtualized-infinite-scrolling' - - - name: 'Lit Getting Started' + - '@tanstack/table-core#migrate-v8-to-v9' + sources: + - TanStack/table:docs/framework/angular/guide/migrating.md + - TanStack/table:packages/angular-table/src/index.ts + - TanStack/table:examples/angular/basic-inject-table + references: + - references/adapter-migration.md + - name: Lit Getting Started slug: getting-started type: framework domain: framework-adapters - path: 'packages/lit-table/skills/getting-started/SKILL.md' - package: 'packages/lit-table' - description: 'Create a Lit TanStack Table v9 table with a stable TableController host field, explicit tableFeatures, controller.table(options, selector) during render, and headless Lit templates.' + path: packages/lit-table/skills/getting-started/SKILL.md + package: packages/lit-table + description: Create and render Table v9 with the lit adapter. Route reusable + createTableHook components, Virtual integration, and framework setup; use + table-state for reactive ownership. requires: - ['@tanstack/table-core#core', '@tanstack/table-core#table-features'] - sources: - - 'TanStack/table:docs/framework/lit/guide/migrating.md' - - 'TanStack/table:examples/lit/basic-table-controller' - - 'TanStack/table:packages/lit-table/src/index.ts' - - - name: 'Lit Table State' + - '@tanstack/table-core#core' + sources: + - TanStack/table:docs/framework/lit/guide/migrating.md + - TanStack/table:examples/lit/basic-table-controller + - TanStack/table:packages/lit-table/src/index.ts + - TanStack/table:docs/framework/lit/guide/composable-tables.md + - TanStack/table:examples/lit/composable-tables + - TanStack/table:packages/lit-table/src/createTableHook.ts + - TanStack/table:docs/framework/lit/guide/virtualization.md + - TanStack/table:examples/lit/virtualized-rows + - TanStack/table:examples/lit/virtualized-columns + - TanStack/table:examples/lit/virtualized-infinite-scrolling + references: + - references/create-table-hook.md + - references/with-tanstack-virtual.md + - name: Lit Table State slug: table-state type: framework domain: framework-adapters - path: 'packages/lit-table/skills/table-state/SKILL.md' - package: 'packages/lit-table' - description: 'Use TableController-selected table.state, table.atoms/store, stable table.subscribe selectors, controlled reactive properties plus on*Change, and external TanStack Store atoms while preserving Lit host update behavior.' - requires: ['@tanstack/table-core#core', 'getting-started'] - sources: - - 'TanStack/table:docs/framework/lit/guide/table-state.md' - - 'TanStack/table:examples/lit/basic-external-state' - - 'TanStack/table:packages/lit-table/src/TableController.ts' - - - name: 'Lit Migrate v8 to v9' + path: packages/lit-table/skills/table-state/SKILL.md + package: packages/lit-table + description: Read and control Table v9 state in lit. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' + sources: + - TanStack/table:docs/framework/lit/guide/table-state.md + - TanStack/table:examples/lit/basic-external-state + - TanStack/table:packages/lit-table/src/TableController.ts + references: + - references/reactivity.md + - name: Lit Migrate v8 to v9 slug: migrate-v8-to-v9 - type: lifecycle + type: migration domain: framework-adapters - path: 'packages/lit-table/skills/migrate-v8-to-v9/SKILL.md' - package: 'packages/lit-table' - description: 'Migrate Lit v8 controller construction to a stable v9 TableController plus controller.table(options), explicit feature/row-model slots, selected state, helpers, prototype methods, sortFn names, and logical start/end pinning.' + path: packages/lit-table/skills/migrate-v8-to-v9/SKILL.md + package: packages/lit-table + description: Migrate lit Table v8 to v9. Audit framework construction, + rendering, state, and app hooks, with shared API changes in the core + migration skill. requires: - [ - '@tanstack/table-core#migrate-v8-to-v9', - 'getting-started', - 'table-state', - ] - sources: - - 'TanStack/table:docs/framework/lit/guide/migrating.md' - - 'TanStack/table:packages/lit-table/src/index.ts' - - 'TanStack/table:examples/lit/basic-table-controller' - - - name: 'Lit createTableHook' - slug: create-table-hook - type: framework - domain: framework-adapters - path: 'packages/lit-table/skills/create-table-hook/SKILL.md' - package: 'packages/lit-table' - description: 'Create a reusable Lit useAppTable/createAppColumnHelper layer with host-backed controllers, shared features/defaults, typed cell/header renderers, and useTableContext for custom-element controls instead of prop drilling.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/lit/guide/composable-tables.md' - - 'TanStack/table:examples/lit/composable-tables' - - 'TanStack/table:packages/lit-table/src/createTableHook.ts' - - - name: 'Lit with TanStack Virtual' - slug: with-tanstack-virtual - type: composition - domain: framework-adapters - path: 'packages/lit-table/skills/with-tanstack-virtual/SKILL.md' - package: 'packages/lit-table' - description: 'Virtualize Lit Table final row or column models with host lifecycle-aware virtualizers, stable counts/keys, dynamic measurement, scroll geometry, sticky CSS, grid/flex sizing, and infinite data.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/lit/guide/virtualization.md' - - 'TanStack/table:examples/lit/virtualized-rows' - - 'TanStack/table:examples/lit/virtualized-columns' - - 'TanStack/table:examples/lit/virtualized-infinite-scrolling' - - - name: 'Octane Getting Started' + - '@tanstack/table-core#migrate-v8-to-v9' + sources: + - TanStack/table:docs/framework/lit/guide/migrating.md + - TanStack/table:packages/lit-table/src/index.ts + - TanStack/table:examples/lit/basic-table-controller + references: + - references/adapter-migration.md + - name: Octane Getting Started slug: getting-started type: framework domain: framework-adapters - path: 'packages/octane-table/skills/getting-started/SKILL.md' - package: 'packages/octane-table' - description: 'Create an @tanstack/octane-table v9 table with useTable, tableFeatures, stable inputs, TSRX component bodies, keyed @for rendering, and FlexRender. Load when starting an Octane table or translating a React/Preact example without changing its behavior.' + path: packages/octane-table/skills/getting-started/SKILL.md + package: packages/octane-table + description: + Create and render Table v9 with the octane adapter. Route reusable + createTableHook components, and framework setup; use table-state for + reactive ownership. requires: - ['@tanstack/table-core#core', '@tanstack/table-core#table-features'] - sources: - - 'TanStack/table:docs/framework/octane/quick-start.md' - - 'TanStack/table:examples/octane/basic-use-table' - - 'TanStack/table:packages/octane-table/src/index.ts' - - 'TanStack/table:packages/octane-table/src/useTable.tsrx' - - - name: 'Octane Table State' + - '@tanstack/table-core#core' + sources: + - TanStack/table:docs/framework/octane/quick-start.md + - TanStack/table:examples/octane/basic-use-table + - TanStack/table:packages/octane-table/src/index.ts + - TanStack/table:packages/octane-table/src/useTable.tsrx + - TanStack/table:docs/framework/octane/guide/composable-tables.md + - TanStack/table:docs/framework/octane/guide/table-context.md + - TanStack/table:examples/octane/composable-tables + - TanStack/table:packages/octane-table/src/createTableHook.tsrx + - TanStack/table:packages/octane-table/src/createTableHookContexts.ts + references: + - references/create-table-hook.md + - name: Octane Table State slug: table-state type: framework domain: framework-adapters - path: 'packages/octane-table/skills/table-state/SKILL.md' - package: 'packages/octane-table' - description: 'Read and own Octane Table v9 state with useTable selectors, table.state, table.Subscribe, controlled slices, and @tanstack/octane-store atoms. Load for state ownership, render timing, snapshot-versus-subscription bugs, or fine-grained rendering.' - requires: ['@tanstack/table-core#core', 'getting-started'] - sources: - - 'TanStack/table:docs/framework/octane/guide/table-state.md' - - 'TanStack/table:examples/octane/basic-subscribe' - - 'TanStack/table:examples/octane/basic-external-atoms' - - 'TanStack/table:packages/octane-table/src/useTable.tsrx' - - 'TanStack/table:packages/octane-table/src/Subscribe.tsrx' - - - name: 'Octane createTableHook' - slug: create-table-hook - type: framework - domain: framework-adapters - path: 'packages/octane-table/skills/create-table-hook/SKILL.md' - package: 'packages/octane-table' - description: 'Create reusable Octane table infrastructure with createTableHook, useAppTable, createAppColumnHelper, registered components, stable App wrappers, and typed context hooks. Load for recurring conventions, scoped contexts, or prop drilling.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/octane/guide/composable-tables.md' - - 'TanStack/table:docs/framework/octane/guide/table-context.md' - - 'TanStack/table:examples/octane/composable-tables' - - 'TanStack/table:packages/octane-table/src/createTableHook.tsrx' - - 'TanStack/table:packages/octane-table/src/createTableHookContexts.ts' - - - name: 'Ember Getting Started' + path: packages/octane-table/skills/table-state/SKILL.md + package: packages/octane-table + description: + Read and control Table v9 state in octane. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' + sources: + - TanStack/table:docs/framework/octane/guide/table-state.md + - TanStack/table:examples/octane/basic-subscribe + - TanStack/table:examples/octane/basic-external-atoms + - TanStack/table:packages/octane-table/src/useTable.tsrx + - TanStack/table:packages/octane-table/src/Subscribe.tsrx + references: + - references/reactivity.md + - name: Ember Getting Started slug: getting-started type: framework domain: framework-adapters - path: 'packages/ember-table/skills/getting-started/SKILL.md' - package: 'packages/ember-table' - description: "Create a TanStack Ember Table v9 table with useTable, a tracked options thunk, stable tableFeatures and columns, .gts templates, FlexRenderCell/Header/Footer, and correctly bound template helpers. Load for first-table setup, Glimmer reactivity, component cell renderers, or adapting another framework's example to Ember." + path: packages/ember-table/skills/getting-started/SKILL.md + package: packages/ember-table + description: + Create and render Table v9 with the ember adapter. Route reusable + createTableHook defaults, and framework setup; use table-state for + reactive ownership. requires: - ['@tanstack/table-core#core', '@tanstack/table-core#table-features'] - sources: - - 'TanStack/table:docs/framework/ember/quick-start.md' - - 'TanStack/table:examples/ember/basic-table' - - 'TanStack/table:packages/ember-table/src/index.ts' - - 'TanStack/table:packages/ember-table/src/use-table.ts' - - 'TanStack/table:packages/ember-table/src/FlexRender.gts' - - - name: 'Ember Table State' + - '@tanstack/table-core#core' + sources: + - TanStack/table:docs/framework/ember/quick-start.md + - TanStack/table:examples/ember/basic-table + - TanStack/table:packages/ember-table/src/index.ts + - TanStack/table:packages/ember-table/src/use-table.ts + - TanStack/table:packages/ember-table/src/FlexRender.gts + - TanStack/table:docs/framework/ember/guide/composable-tables.md + - TanStack/table:examples/ember/basic-app-table + - TanStack/table:packages/ember-table/src/create-table-hook.ts + references: + - references/create-table-hook.md + - name: Ember Table State slug: table-state type: framework domain: framework-adapters - path: 'packages/ember-table/skills/table-state/SKILL.md' - package: 'packages/ember-table' - description: 'Read, track, initialize, control, and reset TanStack Ember Table v9 state through Glimmer-reactive table APIs, baseAtoms, atoms, store, Ember createAtom, or @tracked state plus on*Change. Load for ownership precedence, updater callbacks, stale template state, options-thunk reactivity, or incorrect table.Subscribe/store.subscribe usage.' - requires: ['@tanstack/table-core#core', 'getting-started'] - sources: - - 'TanStack/table:docs/framework/ember/guide/table-state.md' - - 'TanStack/table:examples/ember/basic-external-atoms' - - 'TanStack/table:examples/ember/basic-external-state' - - 'TanStack/table:packages/ember-table/src/use-table.ts' - - 'TanStack/table:packages/ember-table/src/reactivity.ts' - - 'TanStack/table:packages/ember-table/src/signal.ts' - - - name: 'Ember createTableHook' - slug: create-table-hook - type: framework - domain: framework-adapters - path: 'packages/ember-table/skills/create-table-hook/SKILL.md' - package: 'packages/ember-table' - description: 'Share TanStack Ember Table v9 features, row-model slots, defaults, and inferred column helpers with createTableHook, createAppTable, createAppColumnHelper, and appFeatures. Load for recurring Ember table conventions, per-table overrides, or confusion with component/context registries from other adapters.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/ember/guide/composable-tables.md' - - 'TanStack/table:examples/ember/basic-app-table' - - 'TanStack/table:packages/ember-table/src/create-table-hook.ts' - - - name: 'Alpine Getting Started' + path: packages/ember-table/skills/table-state/SKILL.md + package: packages/ember-table + description: + Read and control Table v9 state in ember. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' + sources: + - TanStack/table:docs/framework/ember/guide/table-state.md + - TanStack/table:examples/ember/basic-external-atoms + - TanStack/table:examples/ember/basic-external-state + - TanStack/table:packages/ember-table/src/use-table.ts + - TanStack/table:packages/ember-table/src/reactivity.ts + - TanStack/table:packages/ember-table/src/signal.ts + references: + - references/reactivity.md + - name: Alpine Getting Started slug: getting-started type: framework domain: framework-adapters - path: 'packages/alpine-table/skills/getting-started/SKILL.md' - package: 'packages/alpine-table' - description: 'Create an Alpine TanStack Table v9 table with createTable, explicit tableFeatures, Alpine.reactive data/getters, real x-for/x-text/x-html markup, and renderer-owned styles. Covers why x-html does not initialize nested Alpine directives.' + path: packages/alpine-table/skills/getting-started/SKILL.md + package: packages/alpine-table + description: + Create and render Table v9 with the alpine adapter. Route reusable + createTableHook defaults, and framework setup; use table-state for + reactive ownership. requires: - ['@tanstack/table-core#core', '@tanstack/table-core#table-features'] - sources: - - 'TanStack/table:docs/framework/alpine/guide/table-state.md' - - 'TanStack/table:examples/alpine/basic-create-table' - - 'TanStack/table:packages/alpine-table/src/index.ts' - - - name: 'Alpine Table State' + - '@tanstack/table-core#core' + sources: + - TanStack/table:docs/framework/alpine/guide/table-state.md + - TanStack/table:examples/alpine/basic-create-table + - TanStack/table:packages/alpine-table/src/index.ts + - TanStack/table:docs/framework/alpine/guide/composable-tables.md + - TanStack/table:examples/alpine/basic-app-table + - TanStack/table:packages/alpine-table/src/createTableHook.ts + references: + - references/create-table-hook.md + - name: Alpine Table State slug: table-state type: framework domain: framework-adapters - path: 'packages/alpine-table/skills/table-state/SKILL.md' - package: 'packages/alpine-table' - description: 'Read automatically reactive Alpine table APIs directly in bindings; own slices with Alpine.reactive getters plus on*Change or external TanStack Store atoms; and apply updater callbacks without inventing table.Subscribe.' - requires: ['@tanstack/table-core#core', 'getting-started'] - sources: - - 'TanStack/table:docs/framework/alpine/guide/table-state.md' - - 'TanStack/table:examples/alpine/basic-create-table' - - 'TanStack/table:packages/alpine-table/src/createTable.ts' - - - name: 'Alpine createTableHook' - slug: create-table-hook - type: framework - domain: framework-adapters - path: 'packages/alpine-table/skills/create-table-hook/SKILL.md' - package: 'packages/alpine-table' - description: 'Share Alpine tableFeatures, defaults, createAppTable, and createAppColumnHelper with createTableHook. Clarifies that Alpine has no registered component/context registry and interactive reuse belongs in real markup or Alpine.bind bundles.' - requires: ['@tanstack/table-core#core', 'getting-started', 'table-state'] - sources: - - 'TanStack/table:docs/framework/alpine/guide/composable-tables.md' - - 'TanStack/table:examples/alpine/basic-app-table' - - 'TanStack/table:packages/alpine-table/src/createTableHook.ts' - - - name: 'Table Devtools' + path: packages/alpine-table/skills/table-state/SKILL.md + package: packages/alpine-table + description: + Read and control Table v9 state in alpine. Use for tracked reads, + subscriptions, controlled slices, and framework-specific reactive + boundaries. + requires: + - '@tanstack/table-core#table-state' + sources: + - TanStack/table:docs/framework/alpine/guide/table-state.md + - TanStack/table:examples/alpine/basic-create-table + - TanStack/table:packages/alpine-table/src/createTable.ts + references: + - references/reactivity.md + - name: Table Devtools slug: devtools - type: core + type: integration domain: observability - path: 'packages/table-devtools/skills/devtools/SKILL.md' - package: 'packages/table-devtools' - description: 'Register TanStack Table targets and inspect options, state, features, columns, rows, and row models with @tanstack/table-devtools. Load for missing connections, required unique table options.key, target replacement/cleanup, or explicit production entrypoints.' - requires: ['@tanstack/table-core#core'] + path: packages/table-devtools/skills/devtools/SKILL.md + package: packages/table-devtools + description: Register TanStack Table targets and inspect options, state, + features, columns, rows, and row models with @tanstack/table-devtools. + Load for missing connections, required unique table options.key, target + replacement/cleanup, or explicit production entrypoints. + requires: + - '@tanstack/table-core#core' sources: - - 'TanStack/table:docs/devtools.md' - - 'TanStack/table:packages/table-devtools/src/index.ts' - - 'TanStack/table:packages/table-devtools/src/tableTarget.ts' - - 'TanStack/table:packages/table-devtools/src/production.ts' - - - name: 'React Table Devtools' + - TanStack/table:docs/devtools.md + - TanStack/table:packages/table-devtools/src/index.ts + - TanStack/table:packages/table-devtools/src/tableTarget.ts + - TanStack/table:packages/table-devtools/src/production.ts + - name: React Table Devtools slug: devtools - type: framework + type: integration domain: observability - path: 'packages/react-table-devtools/skills/devtools/SKILL.md' - package: 'packages/react-table-devtools' - description: 'Connect React Table v9 instances to Devtools with ReactTableDevtools, useTanStackTableDevtools, or the plugin lifecycle. Covers stable table identity, required unique options.key, cleanup, enabled state, and development-gated exports.' - requires: ['@tanstack/table-core#core', '@tanstack/table-devtools#devtools'] + path: packages/react-table-devtools/skills/devtools/SKILL.md + package: packages/react-table-devtools + description: Connect React Table v9 instances to Devtools with + ReactTableDevtools, useTanStackTableDevtools, or the plugin lifecycle. + Covers stable table identity, required unique options.key, cleanup, + enabled state, and development-gated exports. + requires: + - '@tanstack/table-core#core' + - '@tanstack/table-devtools#devtools' sources: - - 'TanStack/table:docs/devtools.md' - - 'TanStack/table:packages/react-table-devtools/src/index.ts' - - 'TanStack/table:packages/react-table-devtools/src/useTanStackTableDevtools.ts' - - - name: 'Preact Table Devtools' + - TanStack/table:docs/devtools.md + - TanStack/table:packages/react-table-devtools/src/index.ts + - TanStack/table:packages/react-table-devtools/src/useTanStackTableDevtools.ts + - name: Preact Table Devtools slug: devtools - type: framework + type: integration domain: observability - path: 'packages/preact-table-devtools/skills/devtools/SKILL.md' - package: 'packages/preact-table-devtools' - description: 'Connect native Preact Table instances to Devtools with the Preact component, hook, or plugin lifecycle. Covers correct package imports, required unique options.key, target cleanup, enabled state, and development gating.' - requires: ['@tanstack/table-core#core', '@tanstack/table-devtools#devtools'] + path: packages/preact-table-devtools/skills/devtools/SKILL.md + package: packages/preact-table-devtools + description: + Connect native Preact Table instances to Devtools with the Preact + component, hook, or plugin lifecycle. Covers correct package imports, + required unique options.key, target cleanup, enabled state, and + development gating. + requires: + - '@tanstack/table-core#core' + - '@tanstack/table-devtools#devtools' sources: - - 'TanStack/table:docs/devtools.md' - - 'TanStack/table:packages/preact-table-devtools/src/index.ts' - - 'TanStack/table:packages/preact-table-devtools/src/useTanStackTableDevtools.ts' - - - name: 'Solid Table Devtools' + - TanStack/table:docs/devtools.md + - TanStack/table:packages/preact-table-devtools/src/index.ts + - TanStack/table:packages/preact-table-devtools/src/useTanStackTableDevtools.ts + - name: Solid Table Devtools slug: devtools - type: framework + type: integration domain: observability - path: 'packages/solid-table-devtools/skills/devtools/SKILL.md' - package: 'packages/solid-table-devtools' - description: 'Connect Solid Table instances to Devtools in the proper reactive owner using the Solid component, hook, or plugin. Covers required unique options.key, target cleanup, enabled state, and development versus explicit production exports.' - requires: ['@tanstack/table-core#core', '@tanstack/table-devtools#devtools'] + path: packages/solid-table-devtools/skills/devtools/SKILL.md + package: packages/solid-table-devtools + description: + Connect Solid Table instances to Devtools in the proper reactive + owner using the Solid component, hook, or plugin. Covers required unique + options.key, target cleanup, enabled state, and development versus + explicit production exports. + requires: + - '@tanstack/table-core#core' + - '@tanstack/table-devtools#devtools' sources: - - 'TanStack/table:docs/devtools.md' - - 'TanStack/table:packages/solid-table-devtools/src/index.ts' - - 'TanStack/table:packages/solid-table-devtools/src/useTanStackTableDevtools.ts' - - - name: 'Vue Table Devtools' + - TanStack/table:docs/devtools.md + - TanStack/table:packages/solid-table-devtools/src/index.ts + - TanStack/table:packages/solid-table-devtools/src/useTanStackTableDevtools.ts + - name: Vue Table Devtools slug: devtools - type: framework + type: integration domain: observability - path: 'packages/vue-table-devtools/skills/devtools/SKILL.md' - package: 'packages/vue-table-devtools' - description: 'Connect Vue Table refs to Devtools with reactive target tracking, required unique options.key, lifecycle cleanup, enabled state, and development-gated component/plugin exports.' - requires: ['@tanstack/table-core#core', '@tanstack/table-devtools#devtools'] + path: packages/vue-table-devtools/skills/devtools/SKILL.md + package: packages/vue-table-devtools + description: + Connect Vue Table refs to Devtools with reactive target tracking, + required unique options.key, lifecycle cleanup, enabled state, and + development-gated component/plugin exports. + requires: + - '@tanstack/table-core#core' + - '@tanstack/table-devtools#devtools' sources: - - 'TanStack/table:docs/devtools.md' - - 'TanStack/table:packages/vue-table-devtools/src/index.ts' - - 'TanStack/table:packages/vue-table-devtools/src/useTanStackTableDevtools.ts' - - - name: 'Angular Table Devtools' + - TanStack/table:docs/devtools.md + - TanStack/table:packages/vue-table-devtools/src/index.ts + - TanStack/table:packages/vue-table-devtools/src/useTanStackTableDevtools.ts + - name: Angular Table Devtools slug: devtools - type: framework + type: integration domain: observability - path: 'packages/angular-table-devtools/skills/devtools/SKILL.md' - package: 'packages/angular-table-devtools' - description: 'Register Angular Table instances with injectTanStackTableDevtools inside injection context. Covers reactive options, enabled/undefined tables, required unique options.key, cleanup, Angular isDevMode gating, and explicit production exports.' - requires: ['@tanstack/table-core#core', '@tanstack/table-devtools#devtools'] + path: packages/angular-table-devtools/skills/devtools/SKILL.md + package: packages/angular-table-devtools + description: + Register Angular Table instances with injectTanStackTableDevtools + inside injection context. Covers reactive options, enabled/undefined + tables, required unique options.key, cleanup, Angular isDevMode gating, + and explicit production exports. + requires: + - '@tanstack/table-core#core' + - '@tanstack/table-devtools#devtools' sources: - - 'TanStack/table:docs/devtools.md' - - 'TanStack/table:packages/angular-table-devtools/src/index.ts' - - 'TanStack/table:packages/angular-table-devtools/src/injectTanStackTableDevtools.ts' - - - name: 'Fuzzy Ranking' + - TanStack/table:docs/devtools.md + - TanStack/table:packages/angular-table-devtools/src/index.ts + - TanStack/table:packages/angular-table-devtools/src/injectTanStackTableDevtools.ts + - name: Fuzzy Ranking slug: fuzzy-ranking type: core domain: utilities - path: 'packages/match-sorter-utils/skills/fuzzy-ranking/SKILL.md' - package: 'packages/match-sorter-utils' - description: 'Rank fuzzy matches with rankItem, filter with RankingInfo.passed, compare saved ranking metadata with compareItems, and configure rankings, thresholds, accessors, bounds, and diacritic handling. Routes TanStack Table filterMeta wiring to filtering skills.' - sources: - - 'TanStack/table:packages/match-sorter-utils/src/index.ts' - - 'TanStack/table:docs/framework/react/guide/fuzzy-filtering.md' - - 'TanStack/table:examples/react/filters-fuzzy' + path: packages/match-sorter-utils/skills/fuzzy-ranking/SKILL.md + package: packages/match-sorter-utils + description: + Rank fuzzy matches with rankItem, filter with RankingInfo.passed, + compare saved ranking metadata with compareItems, and configure rankings, + thresholds, accessors, bounds, and diacritic handling. Routes TanStack + Table filterMeta wiring to filtering skills. + sources: + - TanStack/table:packages/match-sorter-utils/src/index.ts + - TanStack/table:docs/framework/react/guide/fuzzy-filtering.md + - TanStack/table:examples/react/filters-fuzzy diff --git a/docs/agent-skills.md b/docs/agent-skills.md index 37da780155..b1ee3d983b 100644 --- a/docs/agent-skills.md +++ b/docs/agent-skills.md @@ -27,14 +27,18 @@ TanStack Table publishes skills inside its packages so the guidance travels with The skills available to your agent depend on which packages your project installs: -| Package | Skills | What they teach | -| ---------------------------------------------------------- | ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `@tanstack/table-core` | `core`, `table-features`, and focused feature skills | Headless table architecture, explicit feature registration, TypeScript, client/server boundaries, migration, and features such as sorting, filtering, grouping, pagination, pinning, sizing, selection, and aggregation | -| `@tanstack/-table` | Framework-specific setup and state skills | Creating, rendering, and controlling a table with your framework adapter; supported adapters also include migration and TanStack Query/Virtual composition skills | -| `@tanstack/table-devtools` and framework devtools adapters | `devtools` | Registering table instances and inspecting features, state, options, rows, and columns | -| `@tanstack/match-sorter-utils` | `fuzzy-ranking` | Fuzzy filtering, ranking metadata, and rank-aware sorting | +| Package | Skills | What they teach | +| ---------------------------------------------------------- | ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `@tanstack/table-core` | `core`, `table-features`, `table-state`, `custom-features`, `migrate-v8-to-v9` | Core architecture, feature registration, shared state ownership, plugin authoring, and migration. Each optional feature has an on-demand reference linked from `table-features`. | +| `@tanstack/-table` | `getting-started`, `table-state`, and migration where supported | Framework setup, rendering, and reactive state. References cover reusable app hooks, advanced reactivity, and maintained Query/Virtual integrations. | +| `@tanstack/table-devtools` and framework devtools adapters | `devtools` | Registering table instances and inspecting features, state, options, rows, and columns | +| `@tanstack/match-sorter-utils` | `fuzzy-ranking` | Fuzzy filtering, ranking metadata, and rank-aware sorting | -Each skill lives under `node_modules//skills//SKILL.md` once the package is installed. Skills can declare prerequisites, so your agent can load the core guidance before a framework or feature-specific skill. +Each skill lives under `node_modules//skills//SKILL.md` once the package is installed. Its `references/` directory contains guidance for specific tasks. For example, row selection lives in `@tanstack/table-core/skills/table-features/references/row-selection.md`. + +The entry point tells the agent when to read each reference. A sorting change loads the sorting guidance; selection, resizing, and other unrelated feature references stay unloaded. Framework state skills load the shared state model and then explain their own reactive reads and updates. + +Intent lists entry points and loads one requested `SKILL.md` at a time. The agent follows its prerequisite instructions and reads relevant references. A React project with core installed has eight Table entry points. Devtools and other installed libraries add their own entries. ## Step 1: Install TanStack Table @@ -89,9 +93,11 @@ You can inspect and load Table skills yourself with the same commands: ```bash npx @tanstack/intent@latest list npx @tanstack/intent@latest load @tanstack/react-table#getting-started -npx @tanstack/intent@latest load @tanstack/table-core#sorting +npx @tanstack/intent@latest load @tanstack/table-core#table-features ``` +For sorting, follow the loaded entry point's link to `references/sorting.md`. The load command resolves relative Markdown links to the installed package, including when your package manager uses nested dependency paths. + If you prefer explicit task-to-skill entries, run `npx @tanstack/intent@latest install --map`. Mapping mode scans your installed intent-enabled packages and writes compact `id`, `run`, and `for` entries into the managed block. ## Step 4: Confirm It's Wired Up @@ -112,6 +118,22 @@ If the agent still falls back to v8 patterns, reopen its config file and confirm Skills are versioned with each package. When you update your TanStack Table packages, the `SKILL.md` files under `node_modules` update with them. No CLI rerun is needed. If you use explicit mappings, rerun `npx @tanstack/intent@latest install --map` after adding another intent-enabled package, such as a Table devtools adapter, or when you want to refresh the mappings. +### Update older skill mappings + +The progressive-disclosure layout replaces individual feature and composition skill IDs with references. If your agent configuration contains the old IDs, update them as follows: + +| Old skill ID | Replacement entry point and reference | +| --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| `@tanstack/table-core#sorting`, `#row-selection`, and the other optional feature skills | `@tanstack/table-core#table-features`, then the matching feature reference | +| `@tanstack/table-core#client-vs-server` | `@tanstack/table-core#table-features`, then `references/client-vs-server.md` | +| `@tanstack/table-core#typescript` or `#api-not-found` | `@tanstack/table-core#core`, then the matching reference | +| `@tanstack/-table#create-table-hook` | The adapter's `getting-started`, then `references/create-table-hook.md` | +| `@tanstack/-table#with-tanstack-query` or `#with-tanstack-virtual` | The adapter's `getting-started`, then the matching integration reference | + +If `package.json#intent.skills` allows individual old skill IDs, run `npx @tanstack/intent@latest install --review` to select their replacements and the prerequisites they need. Package-level permissions include new entry points automatically. Regenerate explicit mappings with `npx @tanstack/intent@latest install --map` after updating permissions. Direct file pointers to moved skills also need their new paths. + +Core state guidance is available as `@tanstack/table-core#table-state`. Adapter state and migration skill IDs remain available. Migration skills retain a complete audit checklist and link to detailed mappings for the APIs your project uses. + ## Using Skills Without the CLI If you'd rather wire skills in yourself, reference them directly from `node_modules` in any agent config file. The minimum your agent needs is a pointer to the relevant file: diff --git a/docs/config.json b/docs/config.json index 97d77cf0ab..2625aaeae7 100644 --- a/docs/config.json +++ b/docs/config.json @@ -716,7 +716,7 @@ { "label": "DisplayColumnDef", "to": "reference/index/type-aliases/DisplayColumnDef" }, { "label": "GroupColumnDef", "to": "reference/index/type-aliases/GroupColumnDef" }, { "label": "ColumnDefTemplate", "to": "reference/index/type-aliases/ColumnDefTemplate" }, - { "label": "ColumnHelper", "to": "reference/index/type-aliases/ColumnHelper" }, + { "label": "ColumnHelper", "to": "reference/index/interfaces/ColumnHelper" }, { "label": "ColumnMeta", "to": "reference/index/interfaces/ColumnMeta" }, { "label": "createColumnHelper", "to": "reference/index/functions/createColumnHelper" }, { "label": "constructColumn", "to": "reference/index/functions/constructColumn" }, @@ -807,7 +807,6 @@ { "label": "createFacetedUniqueValues", "to": "reference/index/functions/createFacetedUniqueValues" }, { "label": "expandRows", "to": "reference/index/functions/expandRows" }, { "label": "RowModelFns", "to": "reference/index/type-aliases/RowModelFns" }, - { "label": "CreateRowModels", "to": "reference/index/type-aliases/CreateRowModels" }, { "label": "CachedRowModels", "to": "reference/index/type-aliases/CachedRowModels" } ] }, @@ -878,7 +877,7 @@ "label": "Header API Reference", "children": [ { "label": "Header", "to": "reference/index/type-aliases/Header" }, - { "label": "HeaderGroup", "to": "reference/index/type-aliases/HeaderGroup" }, + { "label": "HeaderGroup", "to": "reference/index/interfaces/HeaderGroup" }, { "label": "HeaderContext", "to": "reference/index/interfaces/HeaderContext" }, { "label": "constructHeader", "to": "reference/index/functions/constructHeader" }, { "label": "buildHeaderGroups", "to": "reference/index/functions/buildHeaderGroups" } diff --git a/docs/framework/alpine/guide/cell-selection.md b/docs/framework/alpine/guide/cell-selection.md index 2ada44ca5d..1a65e09c16 100644 --- a/docs/framework/alpine/guide/cell-selection.md +++ b/docs/framework/alpine/guide/cell-selection.md @@ -274,19 +274,43 @@ Cell selection ships no keyboard handling of its own. Instead it exposes imperat `direction` is `'up'`, `'down'`, `'left'`, or `'right'`. ```ts -import { createMultiHotkeyHandler } from '@tanstack/hotkeys' +import Alpine from 'alpinejs' +import { createHotkeysScope, hotkeysPlugin } from '@tanstack/alpine-hotkeys' + +Alpine.plugin(hotkeysPlugin) -// Alpine has no hotkeys adapter, so the framework-agnostic core handler is used -onGridKeyDown: createMultiHotkeyHandler({ - ArrowUp: () => table.moveCellSelection('up'), - ArrowDown: () => table.moveCellSelection('down'), - 'Shift+ArrowDown': () => table.extendCellSelection('down'), - 'Mod+A': () => table.selectAllCells(), - Escape: () => table.resetCellSelection(true), -}), +Alpine.data('table', () => { + // ...create the table + const hotkeys = createHotkeysScope() + + return { + init() { + hotkeys.createHotkeys( + [ + { hotkey: 'ArrowUp', callback: () => table.moveCellSelection('up') }, + { + hotkey: 'ArrowDown', + callback: () => table.moveCellSelection('down'), + }, + { + hotkey: 'Shift+ArrowDown', + callback: () => table.extendCellSelection('down'), + }, + { hotkey: 'Mod+A', callback: () => table.selectAllCells() }, + { hotkey: 'Escape', callback: () => table.resetCellSelection(true) }, + ], + // scope every binding to the grid element + () => ({ target: this.$refs.grid }), + ) + }, + destroy() { + hotkeys.destroy() + }, + } +}) // then, in the markup: -//
...
+//
...
``` Scope the hotkeys to the grid element rather than the document, or arrow keys and Escape will hijack inputs elsewhere on the page. diff --git a/docs/framework/alpine/reference/functions/FlexRender-1.md b/docs/framework/alpine/reference/functions/FlexRender-1.md index 1124ef2e62..0ba6ceb3cb 100644 --- a/docs/framework/alpine/reference/functions/FlexRender-1.md +++ b/docs/framework/alpine/reference/functions/FlexRender-1.md @@ -3,8 +3,6 @@ id: FlexRender title: FlexRender --- -# Function: FlexRender() - ```ts function FlexRender(props): any; ``` diff --git a/docs/framework/alpine/reference/functions/createTable.md b/docs/framework/alpine/reference/functions/createTable.md index 03e6b51bb3..993341cded 100644 --- a/docs/framework/alpine/reference/functions/createTable.md +++ b/docs/framework/alpine/reference/functions/createTable.md @@ -3,8 +3,6 @@ id: createTable title: createTable --- -# Function: createTable() - ```ts function createTable(tableOptions, selector?): AlpineTable; ``` diff --git a/docs/framework/alpine/reference/functions/createTableHook.md b/docs/framework/alpine/reference/functions/createTableHook.md index 409617cc11..9c4237c374 100644 --- a/docs/framework/alpine/reference/functions/createTableHook.md +++ b/docs/framework/alpine/reference/functions/createTableHook.md @@ -3,8 +3,6 @@ id: createTableHook title: createTableHook --- -# Function: createTableHook() - ```ts function createTableHook(__namedParameters): object; ``` @@ -33,7 +31,7 @@ Defined in: [createTableHook.ts:26](https://github.com/TanStack/table/blob/main/ appFeatures: TFeatures; ``` -### createAppColumnHelper() +### createAppColumnHelper ```ts createAppColumnHelper: () => ColumnHelper; @@ -49,7 +47,7 @@ createAppColumnHelper: () => ColumnHelper; `ColumnHelper`\<`TFeatures`, `TData`\> -### createAppTable() +### createAppTable ```ts createAppTable: (tableOptions, selector?) => AppAlpineTable; diff --git a/docs/framework/alpine/reference/functions/flexRender.md b/docs/framework/alpine/reference/functions/flexRender.md index 0c7178925b..4afa764969 100644 --- a/docs/framework/alpine/reference/functions/flexRender.md +++ b/docs/framework/alpine/reference/functions/flexRender.md @@ -3,8 +3,6 @@ id: flexRender title: flexRender --- -# Function: flexRender() - ```ts function flexRender(render, props): any; ``` diff --git a/docs/framework/alpine/reference/index.md b/docs/framework/alpine/reference/index.md index c5f4fea221..befcac3077 100644 --- a/docs/framework/alpine/reference/index.md +++ b/docs/framework/alpine/reference/index.md @@ -3,8 +3,6 @@ id: "@tanstack/alpine-table" title: "@tanstack/alpine-table" --- -# @tanstack/alpine-table - ## Type Aliases - [AlpineTable](type-aliases/AlpineTable.md) diff --git a/docs/framework/alpine/reference/type-aliases/AlpineTable.md b/docs/framework/alpine/reference/type-aliases/AlpineTable.md index 6f797022eb..77329c0979 100644 --- a/docs/framework/alpine/reference/type-aliases/AlpineTable.md +++ b/docs/framework/alpine/reference/type-aliases/AlpineTable.md @@ -3,8 +3,6 @@ id: AlpineTable title: AlpineTable --- -# Type Alias: AlpineTable\ - ```ts type AlpineTable = Table & object; ``` diff --git a/docs/framework/alpine/reference/type-aliases/AppAlpineTable.md b/docs/framework/alpine/reference/type-aliases/AppAlpineTable.md index cb8e891da0..c71fb82d3b 100644 --- a/docs/framework/alpine/reference/type-aliases/AppAlpineTable.md +++ b/docs/framework/alpine/reference/type-aliases/AppAlpineTable.md @@ -3,8 +3,6 @@ id: AppAlpineTable title: AppAlpineTable --- -# Type Alias: AppAlpineTable\ - ```ts type AppAlpineTable = AlpineTable; ``` diff --git a/docs/framework/alpine/reference/type-aliases/AppColumnHelper.md b/docs/framework/alpine/reference/type-aliases/AppColumnHelper.md index fbf273cbc5..917bc502f9 100644 --- a/docs/framework/alpine/reference/type-aliases/AppColumnHelper.md +++ b/docs/framework/alpine/reference/type-aliases/AppColumnHelper.md @@ -3,8 +3,6 @@ id: AppColumnHelper title: AppColumnHelper --- -# Type Alias: AppColumnHelper\ - ```ts type AppColumnHelper = ReturnType; ``` diff --git a/docs/framework/alpine/reference/type-aliases/CreateTableHookOptions.md b/docs/framework/alpine/reference/type-aliases/CreateTableHookOptions.md index 1c5dbdbcbf..eca038f19e 100644 --- a/docs/framework/alpine/reference/type-aliases/CreateTableHookOptions.md +++ b/docs/framework/alpine/reference/type-aliases/CreateTableHookOptions.md @@ -3,8 +3,6 @@ id: CreateTableHookOptions title: CreateTableHookOptions --- -# Type Alias: CreateTableHookOptions\ - ```ts type CreateTableHookOptions = Omit, "columns" | "data" | "state">; ``` diff --git a/docs/framework/alpine/reference/type-aliases/FlexRenderProps.md b/docs/framework/alpine/reference/type-aliases/FlexRenderProps.md index 68970001dd..8a946eea57 100644 --- a/docs/framework/alpine/reference/type-aliases/FlexRenderProps.md +++ b/docs/framework/alpine/reference/type-aliases/FlexRenderProps.md @@ -3,8 +3,6 @@ id: FlexRenderProps title: FlexRenderProps --- -# Type Alias: FlexRenderProps\ - ```ts type FlexRenderProps = | { diff --git a/docs/framework/angular/reference/classes/FlexRenderCell.md b/docs/framework/angular/reference/classes/FlexRenderCell.md index 7f5258f939..ffbdc4a803 100644 --- a/docs/framework/angular/reference/classes/FlexRenderCell.md +++ b/docs/framework/angular/reference/classes/FlexRenderCell.md @@ -3,8 +3,6 @@ id: FlexRenderCell title: FlexRenderCell --- -# Class: FlexRenderCell\ - Defined in: [packages/angular-table/src/helpers/flexRenderCell.ts:62](https://github.com/TanStack/table/blob/main/packages/angular-table/src/helpers/flexRenderCell.ts#L62) Simplified directive wrapper of `*flexRender`. diff --git a/docs/framework/angular/reference/classes/FlexRenderComponentInstance.md b/docs/framework/angular/reference/classes/FlexRenderComponentInstance.md index 52c97a24cb..082e4a67b5 100644 --- a/docs/framework/angular/reference/classes/FlexRenderComponentInstance.md +++ b/docs/framework/angular/reference/classes/FlexRenderComponentInstance.md @@ -3,13 +3,11 @@ id: FlexRenderComponentInstance title: FlexRenderComponentInstance --- -# Class: FlexRenderComponentInstance\ - -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:259](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L259) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:297](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L297) Wrapper class for a component that will be used as content for [FlexRenderDirective](FlexRenderDirective.md) -Prefer [flexRenderComponent](../functions/flexRenderComponent.md) helper for better type-safety +Prefer [flexRenderComponent](../functions/flexRenderComponent.md) for better type-safety. ## Type Parameters @@ -32,10 +30,11 @@ new FlexRenderComponentInstance( injector?, outputs?, directives?, -bindings?): FlexRenderComponentInstance; + bindings?, +key?): FlexRenderComponentInstance; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:266](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L266) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:303](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L303) #### Parameters @@ -63,51 +62,23 @@ Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:266]( `Binding`[] +##### key? + +`string` \| `number` + #### Returns `FlexRenderComponentInstance`\<`TComponent`\> ## Properties -### allowedInputNames - -```ts -readonly allowedInputNames: string[] = []; -``` - -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:263](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L263) - -List of allowed input names. - -#### Implementation of - -[`FlexRenderComponent`](../interfaces/FlexRenderComponent.md).[`allowedInputNames`](../interfaces/FlexRenderComponent.md#allowedinputnames) - -*** - -### allowedOutputNames - -```ts -readonly allowedOutputNames: string[] = []; -``` - -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:264](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L264) - -List of allowed output names. - -#### Implementation of - -[`FlexRenderComponent`](../interfaces/FlexRenderComponent.md).[`allowedOutputNames`](../interfaces/FlexRenderComponent.md#allowedoutputnames) - -*** - ### bindings? ```ts -readonly optional bindings: Binding[]; +readonly optional bindings?: Binding[]; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:272](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L272) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:309](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L309) Bindings to apply to the root component @@ -127,7 +98,7 @@ FlexRenderOptions#bindings readonly component: Type; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:267](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L267) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:304](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L304) The component type @@ -140,10 +111,10 @@ The component type ### directives? ```ts -readonly optional directives: (Type | DirectiveWithBindings)[]; +readonly optional directives?: (Type | DirectiveWithBindings)[]; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:271](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L271) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:308](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L308) Directives that should be applied to the component. @@ -158,10 +129,10 @@ Directives that should be applied to the component. ### injector? ```ts -readonly optional injector: Injector; +readonly optional injector?: Injector; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:269](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L269) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:306](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L306) Optional Injector that will be used when rendering the component. @@ -178,10 +149,10 @@ FlexRenderOptions#injector ### inputs? ```ts -readonly optional inputs: Inputs; +readonly optional inputs?: Inputs; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:268](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L268) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:305](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L305) Component instance inputs. Set via [componentRef.setInput API](https://angular.dev/api/core/ComponentRef#setInput)) @@ -195,13 +166,50 @@ FlexRenderOptions#inputs *** +### key? + +```ts +readonly optional key?: string | number; +``` + +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:310](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L310) + +Optional identity used together with the component type to decide whether +an existing component instance can be reused. + +#### See + +FlexRenderOptions#key + +#### Implementation of + +[`FlexRenderComponent`](../interfaces/FlexRenderComponent.md).[`key`](../interfaces/FlexRenderComponent.md#key) + +*** + +### metadata + +```ts +readonly metadata: ResolvedComponentMetadata; +``` + +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:301](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L301) + +Cached component metadata used by the flex renderer. + +#### Implementation of + +[`FlexRenderComponent`](../interfaces/FlexRenderComponent.md).[`metadata`](../interfaces/FlexRenderComponent.md#metadata) + +*** + ### mirror ```ts readonly mirror: ComponentMirror; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:262](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L262) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:300](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L300) Reflected metadata about the component. @@ -214,10 +222,10 @@ Reflected metadata about the component. ### outputs? ```ts -readonly optional outputs: Outputs; +readonly optional outputs?: Outputs; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:270](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L270) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:307](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L307) Component instance outputs. Subscribed via OutputEmitterRef#subscribe diff --git a/docs/framework/angular/reference/classes/FlexRenderDirective.md b/docs/framework/angular/reference/classes/FlexRenderDirective.md index 9a587f4b86..24f6b8fe69 100644 --- a/docs/framework/angular/reference/classes/FlexRenderDirective.md +++ b/docs/framework/angular/reference/classes/FlexRenderDirective.md @@ -3,8 +3,6 @@ id: FlexRenderDirective title: FlexRenderDirective --- -# Class: FlexRenderDirective\ - Defined in: [packages/angular-table/src/flexRender.ts:84](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flexRender.ts#L84) Use this utility directive to render headers, cells, or footers with custom markup. diff --git a/docs/framework/angular/reference/classes/TanStackTable.md b/docs/framework/angular/reference/classes/TanStackTable.md index 60c92e083d..e6c43fe9c1 100644 --- a/docs/framework/angular/reference/classes/TanStackTable.md +++ b/docs/framework/angular/reference/classes/TanStackTable.md @@ -3,8 +3,6 @@ id: TanStackTable title: TanStackTable --- -# Class: TanStackTable\ - Defined in: [packages/angular-table/src/helpers/table.ts:59](https://github.com/TanStack/table/blob/main/packages/angular-table/src/helpers/table.ts#L59) Provides a TanStack Table instance (`AngularTable`) in Angular DI. diff --git a/docs/framework/angular/reference/classes/TanStackTableCell.md b/docs/framework/angular/reference/classes/TanStackTableCell.md index 918dca2ff1..9bf49def0b 100644 --- a/docs/framework/angular/reference/classes/TanStackTableCell.md +++ b/docs/framework/angular/reference/classes/TanStackTableCell.md @@ -3,8 +3,6 @@ id: TanStackTableCell title: TanStackTableCell --- -# Class: TanStackTableCell\ - Defined in: [packages/angular-table/src/helpers/cell.ts:76](https://github.com/TanStack/table/blob/main/packages/angular-table/src/helpers/cell.ts#L76) Provides a TanStack Table `Cell` instance in Angular DI. diff --git a/docs/framework/angular/reference/classes/TanStackTableHeader.md b/docs/framework/angular/reference/classes/TanStackTableHeader.md index e3eb0eee33..00cb27e06a 100644 --- a/docs/framework/angular/reference/classes/TanStackTableHeader.md +++ b/docs/framework/angular/reference/classes/TanStackTableHeader.md @@ -3,8 +3,6 @@ id: TanStackTableHeader title: TanStackTableHeader --- -# Class: TanStackTableHeader\ - Defined in: [packages/angular-table/src/helpers/header.ts:71](https://github.com/TanStack/table/blob/main/packages/angular-table/src/helpers/header.ts#L71) Provides a TanStack Table `Header` instance in Angular DI. diff --git a/docs/framework/angular/reference/functions/createTableHook.md b/docs/framework/angular/reference/functions/createTableHook.md index 0d00861b5a..f81d4b2e7c 100644 --- a/docs/framework/angular/reference/functions/createTableHook.md +++ b/docs/framework/angular/reference/functions/createTableHook.md @@ -3,8 +3,6 @@ id: createTableHook title: createTableHook --- -# Function: createTableHook() - ```ts function createTableHook(__namedParameters): CreateTableHookResult; ``` diff --git a/docs/framework/angular/reference/functions/flexRenderComponent.md b/docs/framework/angular/reference/functions/flexRenderComponent.md index 3daa41c307..87fe6830e9 100644 --- a/docs/framework/angular/reference/functions/flexRenderComponent.md +++ b/docs/framework/angular/reference/functions/flexRenderComponent.md @@ -3,13 +3,11 @@ id: flexRenderComponent title: flexRenderComponent --- -# Function: flexRenderComponent() - ```ts function flexRenderComponent(component, options?): FlexRenderComponent; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:150](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L150) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:184](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L184) Helper function to create a [FlexRenderComponent](../interfaces/FlexRenderComponent.md) instance, with better type-safety. diff --git a/docs/framework/angular/reference/functions/injectFlexRenderContext.md b/docs/framework/angular/reference/functions/injectFlexRenderContext.md index 457600b7e7..5fc5afc966 100644 --- a/docs/framework/angular/reference/functions/injectFlexRenderContext.md +++ b/docs/framework/angular/reference/functions/injectFlexRenderContext.md @@ -3,8 +3,6 @@ id: injectFlexRenderContext title: injectFlexRenderContext --- -# Function: injectFlexRenderContext() - ```ts function injectFlexRenderContext(): T; ``` diff --git a/docs/framework/angular/reference/functions/injectTable.md b/docs/framework/angular/reference/functions/injectTable.md index 9ac0109b36..98c6f5e0d0 100644 --- a/docs/framework/angular/reference/functions/injectTable.md +++ b/docs/framework/angular/reference/functions/injectTable.md @@ -3,10 +3,8 @@ id: injectTable title: injectTable --- -# Function: injectTable() - ```ts -function injectTable(options): AngularTable; +function injectTable(optionsFactory): AngularTable; ``` Defined in: [packages/angular-table/src/injectTable.ts:90](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L90) @@ -34,7 +32,7 @@ The returned table is also signal-reactive: table state and table APIs are wired ## Parameters -### options +### optionsFactory () => `TableOptions`\<`TFeatures`, `TData`\> diff --git a/docs/framework/angular/reference/functions/injectTableCellContext.md b/docs/framework/angular/reference/functions/injectTableCellContext.md index cde9de15dc..cbca45dcd2 100644 --- a/docs/framework/angular/reference/functions/injectTableCellContext.md +++ b/docs/framework/angular/reference/functions/injectTableCellContext.md @@ -3,8 +3,6 @@ id: injectTableCellContext title: injectTableCellContext --- -# Function: injectTableCellContext() - ```ts function injectTableCellContext(): Signal>; ``` diff --git a/docs/framework/angular/reference/functions/injectTableContext.md b/docs/framework/angular/reference/functions/injectTableContext.md index d19bcaa1f2..2df4b4061a 100644 --- a/docs/framework/angular/reference/functions/injectTableContext.md +++ b/docs/framework/angular/reference/functions/injectTableContext.md @@ -3,8 +3,6 @@ id: injectTableContext title: injectTableContext --- -# Function: injectTableContext() - ```ts function injectTableContext(): Signal>; ``` diff --git a/docs/framework/angular/reference/functions/injectTableHeaderContext.md b/docs/framework/angular/reference/functions/injectTableHeaderContext.md index 2413752003..c6b79a4cbd 100644 --- a/docs/framework/angular/reference/functions/injectTableHeaderContext.md +++ b/docs/framework/angular/reference/functions/injectTableHeaderContext.md @@ -3,8 +3,6 @@ id: injectTableHeaderContext title: injectTableHeaderContext --- -# Function: injectTableHeaderContext() - ```ts function injectTableHeaderContext(): Signal>; ``` diff --git a/docs/framework/angular/reference/functions/shallow.md b/docs/framework/angular/reference/functions/shallow.md index 57231700ef..75446391a5 100644 --- a/docs/framework/angular/reference/functions/shallow.md +++ b/docs/framework/angular/reference/functions/shallow.md @@ -3,13 +3,11 @@ id: shallow title: shallow --- -# Function: shallow() - ```ts function shallow(objA, objB): boolean; ``` -Defined in: node\_modules/.pnpm/@tanstack+store@0.11.0/node\_modules/@tanstack/store/dist/shallow.d.ts:2 +Defined in: node\_modules/.pnpm/@tanstack+store@0.11.2/node\_modules/@tanstack/store/dist/shallow.d.ts:2 ## Type Parameters diff --git a/docs/framework/angular/reference/index.md b/docs/framework/angular/reference/index.md index 0166ae210a..f783cf1b7d 100644 --- a/docs/framework/angular/reference/index.md +++ b/docs/framework/angular/reference/index.md @@ -3,8 +3,6 @@ id: "@tanstack/angular-table" title: "@tanstack/angular-table" --- -# @tanstack/angular-table - ## Classes - [FlexRenderCell](classes/FlexRenderCell.md) diff --git a/docs/framework/angular/reference/interfaces/FlexRenderComponent.md b/docs/framework/angular/reference/interfaces/FlexRenderComponent.md index 640236f8e8..f19608ac40 100644 --- a/docs/framework/angular/reference/interfaces/FlexRenderComponent.md +++ b/docs/framework/angular/reference/interfaces/FlexRenderComponent.md @@ -3,9 +3,7 @@ id: FlexRenderComponent title: FlexRenderComponent --- -# Interface: FlexRenderComponent\ - -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:205](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L205) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:240](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L240) Wrapper interface for a component that will be used as content for [FlexRenderDirective](../classes/FlexRenderDirective.md). Can be created using [flexRenderComponent](../functions/flexRenderComponent.md) helper. @@ -54,37 +52,13 @@ class MyComponent { ## Properties -### allowedInputNames - -```ts -readonly allowedInputNames: string[]; -``` - -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:217](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L217) - -List of allowed input names. - -*** - -### allowedOutputNames - -```ts -readonly allowedOutputNames: string[]; -``` - -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:221](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L221) - -List of allowed output names. - -*** - ### bindings? ```ts -optional bindings: Binding[]; +optional bindings?: Binding[]; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:245](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L245) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:283](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L283) Bindings to apply to the root component @@ -100,7 +74,7 @@ FlexRenderOptions#bindings readonly component: Type; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:209](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L209) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:244](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L244) The component type @@ -109,10 +83,10 @@ The component type ### directives? ```ts -optional directives: (Type | DirectiveWithBindings)[]; +optional directives?: (Type | DirectiveWithBindings)[]; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:251](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L251) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:289](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L289) Directives that should be applied to the component. @@ -123,10 +97,10 @@ Directives that should be applied to the component. ### injector? ```ts -readonly optional injector: Injector; +readonly optional injector?: Injector; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:239](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L239) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:277](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L277) Optional Injector that will be used when rendering the component. @@ -139,10 +113,10 @@ FlexRenderOptions#injector ### inputs? ```ts -readonly optional inputs: Inputs; +readonly optional inputs?: Inputs; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:233](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L233) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:271](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L271) Component instance inputs. Set via [componentRef.setInput API](https://angular.dev/api/core/ComponentRef#setInput)) @@ -152,13 +126,42 @@ FlexRenderOptions#inputs *** +### key? + +```ts +readonly optional key?: string | number; +``` + +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:251](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L251) + +Optional identity used together with the component type to decide whether +an existing component instance can be reused. + +#### See + +FlexRenderOptions#key + +*** + +### metadata + +```ts +readonly metadata: ResolvedComponentMetadata; +``` + +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:259](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L259) + +Cached component metadata used by the flex renderer. + +*** + ### mirror ```ts readonly mirror: ComponentMirror; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:213](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L213) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:255](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L255) Reflected metadata about the component. @@ -167,10 +170,10 @@ Reflected metadata about the component. ### outputs? ```ts -readonly optional outputs: Outputs; +readonly optional outputs?: Outputs; ``` -Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:227](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L227) +Defined in: [packages/angular-table/src/flex-render/flexRenderComponent.ts:265](https://github.com/TanStack/table/blob/main/packages/angular-table/src/flex-render/flexRenderComponent.ts#L265) Component instance outputs. Subscribed via OutputEmitterRef#subscribe diff --git a/docs/framework/angular/reference/interfaces/TanStackTableCellContext.md b/docs/framework/angular/reference/interfaces/TanStackTableCellContext.md index 88971085c4..5c81449d7c 100644 --- a/docs/framework/angular/reference/interfaces/TanStackTableCellContext.md +++ b/docs/framework/angular/reference/interfaces/TanStackTableCellContext.md @@ -3,8 +3,6 @@ id: TanStackTableCellContext title: TanStackTableCellContext --- -# Interface: TanStackTableCellContext\ - Defined in: [packages/angular-table/src/helpers/cell.ts:11](https://github.com/TanStack/table/blob/main/packages/angular-table/src/helpers/cell.ts#L11) DI context shape for a TanStack Table cell. diff --git a/docs/framework/angular/reference/interfaces/TanStackTableHeaderContext.md b/docs/framework/angular/reference/interfaces/TanStackTableHeaderContext.md index 9a1a50effd..84ba045d01 100644 --- a/docs/framework/angular/reference/interfaces/TanStackTableHeaderContext.md +++ b/docs/framework/angular/reference/interfaces/TanStackTableHeaderContext.md @@ -3,8 +3,6 @@ id: TanStackTableHeaderContext title: TanStackTableHeaderContext --- -# Interface: TanStackTableHeaderContext\ - Defined in: [packages/angular-table/src/helpers/header.ts:11](https://github.com/TanStack/table/blob/main/packages/angular-table/src/helpers/header.ts#L11) DI context shape for a TanStack Table header. diff --git a/docs/framework/angular/reference/type-aliases/AngularTable.md b/docs/framework/angular/reference/type-aliases/AngularTable.md index 586dc38fcb..88f10afd0d 100644 --- a/docs/framework/angular/reference/type-aliases/AngularTable.md +++ b/docs/framework/angular/reference/type-aliases/AngularTable.md @@ -3,8 +3,6 @@ id: AngularTable title: AngularTable --- -# Type Alias: AngularTable\ - ```ts type AngularTable = Table; ``` diff --git a/docs/framework/angular/reference/type-aliases/AppAngularTable.md b/docs/framework/angular/reference/type-aliases/AppAngularTable.md index dd4655cfc0..88af9dbb0c 100644 --- a/docs/framework/angular/reference/type-aliases/AppAngularTable.md +++ b/docs/framework/angular/reference/type-aliases/AppAngularTable.md @@ -3,8 +3,6 @@ id: AppAngularTable title: AppAngularTable --- -# Type Alias: AppAngularTable\ - ```ts type AppAngularTable = AngularTable & NoInfer & object; ``` @@ -15,7 +13,7 @@ Extended table API returned by useAppTable with all App wrapper components ## Type Declaration -### appCell() +### appCell ```ts appCell: (cell) => Cell & NoInfer; @@ -37,7 +35,7 @@ appCell: (cell) => Cell & NoInfer & `NoInfer`\<`TCellComponents`\> -### appFooter() +### appFooter ```ts appFooter: (footer) => Header & NoInfer; @@ -59,7 +57,7 @@ appFooter: (footer) => Header & NoInfer & `NoInfer`\<`THeaderComponents`\> -### appHeader() +### appHeader ```ts appHeader: (header) => Header & NoInfer; diff --git a/docs/framework/angular/reference/type-aliases/AppCellContext.md b/docs/framework/angular/reference/type-aliases/AppCellContext.md index 7064edd43f..80660341e5 100644 --- a/docs/framework/angular/reference/type-aliases/AppCellContext.md +++ b/docs/framework/angular/reference/type-aliases/AppCellContext.md @@ -3,8 +3,6 @@ id: AppCellContext title: AppCellContext --- -# Type Alias: AppCellContext\ - ```ts type AppCellContext = object; ``` @@ -44,7 +42,7 @@ Defined in: [packages/angular-table/src/helpers/createTableHook.ts:52](https://g #### Type Declaration -##### FlexRender() +##### FlexRender ```ts FlexRender: () => unknown; diff --git a/docs/framework/angular/reference/type-aliases/AppColumnDefBase.md b/docs/framework/angular/reference/type-aliases/AppColumnDefBase.md index 5b3112c7d6..66eae37e7b 100644 --- a/docs/framework/angular/reference/type-aliases/AppColumnDefBase.md +++ b/docs/framework/angular/reference/type-aliases/AppColumnDefBase.md @@ -3,8 +3,6 @@ id: AppColumnDefBase title: AppColumnDefBase --- -# Type Alias: AppColumnDefBase\ - ```ts type AppColumnDefBase = Omit, "cell" | "header" | "footer"> & object; ``` @@ -18,19 +16,19 @@ Enhanced column definition base with pre-bound components in cell/header/footer ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/angular/reference/type-aliases/AppColumnDefTemplate.md b/docs/framework/angular/reference/type-aliases/AppColumnDefTemplate.md index 53e8892975..d930e20d36 100644 --- a/docs/framework/angular/reference/type-aliases/AppColumnDefTemplate.md +++ b/docs/framework/angular/reference/type-aliases/AppColumnDefTemplate.md @@ -3,10 +3,8 @@ id: AppColumnDefTemplate title: AppColumnDefTemplate --- -# Type Alias: AppColumnDefTemplate\ - ```ts -type AppColumnDefTemplate = string | (props) => any; +type AppColumnDefTemplate = string | ((props) => any); ``` Defined in: [packages/angular-table/src/helpers/createTableHook.ts:84](https://github.com/TanStack/table/blob/main/packages/angular-table/src/helpers/createTableHook.ts#L84) diff --git a/docs/framework/angular/reference/type-aliases/AppColumnHelper.md b/docs/framework/angular/reference/type-aliases/AppColumnHelper.md index 241e5d3f93..4584910b80 100644 --- a/docs/framework/angular/reference/type-aliases/AppColumnHelper.md +++ b/docs/framework/angular/reference/type-aliases/AppColumnHelper.md @@ -3,8 +3,6 @@ id: AppColumnHelper title: AppColumnHelper --- -# Type Alias: AppColumnHelper\ - ```ts type AppColumnHelper = object; ``` @@ -34,7 +32,7 @@ This enables TypeScript to know about the registered components when defining co ## Properties -### accessor() +### accessor ```ts accessor: (accessor, column) => TAccessor extends AccessorFn ? AccessorFnColumnDef : AccessorKeyColumnDef; @@ -71,7 +69,7 @@ The cell, header, and footer contexts include pre-bound components. *** -### columns() +### columns ```ts columns: (columns) => ColumnDef[] & [...TColumns]; @@ -99,7 +97,7 @@ Wraps an array of column definitions to preserve each column's individual TValue *** -### display() +### display ```ts display: (column) => DisplayColumnDef; @@ -122,7 +120,7 @@ The cell, header, and footer contexts include pre-bound components. *** -### group() +### group ```ts group: (column) => GroupColumnDef; diff --git a/docs/framework/angular/reference/type-aliases/AppDisplayColumnDef.md b/docs/framework/angular/reference/type-aliases/AppDisplayColumnDef.md index 640129bdcf..da7a8d2c91 100644 --- a/docs/framework/angular/reference/type-aliases/AppDisplayColumnDef.md +++ b/docs/framework/angular/reference/type-aliases/AppDisplayColumnDef.md @@ -3,8 +3,6 @@ id: AppDisplayColumnDef title: AppDisplayColumnDef --- -# Type Alias: AppDisplayColumnDef\ - ```ts type AppDisplayColumnDef = Omit, "cell" | "header" | "footer"> & object; ``` @@ -18,19 +16,19 @@ Enhanced display column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/angular/reference/type-aliases/AppGroupColumnDef.md b/docs/framework/angular/reference/type-aliases/AppGroupColumnDef.md index 75d5164e58..03cd879ec9 100644 --- a/docs/framework/angular/reference/type-aliases/AppGroupColumnDef.md +++ b/docs/framework/angular/reference/type-aliases/AppGroupColumnDef.md @@ -3,8 +3,6 @@ id: AppGroupColumnDef title: AppGroupColumnDef --- -# Type Alias: AppGroupColumnDef\ - ```ts type AppGroupColumnDef = Omit, "cell" | "header" | "footer" | "columns"> & object; ``` @@ -18,25 +16,25 @@ Enhanced group column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### columns? ```ts -optional columns: ReadonlyArray>; +optional columns?: ReadonlyArray>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/angular/reference/type-aliases/AppHeaderContext.md b/docs/framework/angular/reference/type-aliases/AppHeaderContext.md index d9171c35db..0e797ddee0 100644 --- a/docs/framework/angular/reference/type-aliases/AppHeaderContext.md +++ b/docs/framework/angular/reference/type-aliases/AppHeaderContext.md @@ -3,8 +3,6 @@ id: AppHeaderContext title: AppHeaderContext --- -# Type Alias: AppHeaderContext\ - ```ts type AppHeaderContext = object; ``` @@ -54,7 +52,7 @@ Defined in: [packages/angular-table/src/helpers/createTableHook.ts:72](https://g #### Type Declaration -##### FlexRender() +##### FlexRender ```ts FlexRender: () => unknown; diff --git a/docs/framework/angular/reference/type-aliases/CreateTableContextOptions.md b/docs/framework/angular/reference/type-aliases/CreateTableContextOptions.md index a8759da512..7010ed8103 100644 --- a/docs/framework/angular/reference/type-aliases/CreateTableContextOptions.md +++ b/docs/framework/angular/reference/type-aliases/CreateTableContextOptions.md @@ -3,8 +3,6 @@ id: CreateTableContextOptions title: CreateTableContextOptions --- -# Type Alias: CreateTableContextOptions\ - ```ts type CreateTableContextOptions = Omit, "columns" | "data" | "store" | "state" | "initialState"> & object; ``` @@ -19,7 +17,7 @@ Extends all TableOptions except 'columns' | 'data' | 'store' | 'state' | 'initia ### cellComponents? ```ts -optional cellComponents: TCellComponents; +optional cellComponents?: TCellComponents; ``` Cell-level components that need access to the cell instance. @@ -35,7 +33,7 @@ Use `useCellContext()` inside these components. ### headerComponents? ```ts -optional headerComponents: THeaderComponents; +optional headerComponents?: THeaderComponents; ``` Header-level components that need access to the header instance. @@ -51,7 +49,7 @@ Use `useHeaderContext()` inside these components. ### tableComponents? ```ts -optional tableComponents: TTableComponents; +optional tableComponents?: TTableComponents; ``` Table-level components that need access to the table instance. diff --git a/docs/framework/angular/reference/type-aliases/CreateTableHookResult.md b/docs/framework/angular/reference/type-aliases/CreateTableHookResult.md index b12d61c653..e02aa37edd 100644 --- a/docs/framework/angular/reference/type-aliases/CreateTableHookResult.md +++ b/docs/framework/angular/reference/type-aliases/CreateTableHookResult.md @@ -3,8 +3,6 @@ id: CreateTableHookResult title: CreateTableHookResult --- -# Type Alias: CreateTableHookResult\ - ```ts type CreateTableHookResult = object; ``` @@ -31,7 +29,7 @@ Defined in: [packages/angular-table/src/helpers/createTableHook.ts:302](https:// ## Properties -### createAppColumnHelper() +### createAppColumnHelper ```ts createAppColumnHelper: () => AppColumnHelper; @@ -51,7 +49,7 @@ Defined in: [packages/angular-table/src/helpers/createTableHook.ts:308](https:// *** -### injectAppTable() +### injectAppTable ```ts injectAppTable: (tableOptions) => AppAngularTable; @@ -77,7 +75,7 @@ Defined in: [packages/angular-table/src/helpers/createTableHook.ts:333](https:// *** -### injectFlexRenderCellContext() +### injectFlexRenderCellContext ```ts injectFlexRenderCellContext: () => CellContext; @@ -101,7 +99,7 @@ Defined in: [packages/angular-table/src/helpers/createTableHook.ts:329](https:// *** -### injectFlexRenderHeaderContext() +### injectFlexRenderHeaderContext ```ts injectFlexRenderHeaderContext: () => HeaderContext; @@ -125,7 +123,7 @@ Defined in: [packages/angular-table/src/helpers/createTableHook.ts:325](https:// *** -### injectTableCellContext() +### injectTableCellContext ```ts injectTableCellContext: () => Signal & TCellComponents>; @@ -149,7 +147,7 @@ Defined in: [packages/angular-table/src/helpers/createTableHook.ts:321](https:// *** -### injectTableContext() +### injectTableContext ```ts injectTableContext: () => Signal & TTableComponents>; @@ -169,7 +167,7 @@ Defined in: [packages/angular-table/src/helpers/createTableHook.ts:314](https:// *** -### injectTableHeaderContext() +### injectTableHeaderContext ```ts injectTableHeaderContext: () => Signal & THeaderComponents>; diff --git a/docs/framework/angular/reference/type-aliases/FlexRenderComponentProps.md b/docs/framework/angular/reference/type-aliases/FlexRenderComponentProps.md index 952c9e14f0..f5e683bd1b 100644 --- a/docs/framework/angular/reference/type-aliases/FlexRenderComponentProps.md +++ b/docs/framework/angular/reference/type-aliases/FlexRenderComponentProps.md @@ -3,8 +3,6 @@ id: FlexRenderComponentProps title: FlexRenderComponentProps --- -# Type Alias: FlexRenderComponentProps - ```ts type FlexRenderComponentProps = InjectionToken<{ }>; diff --git a/docs/framework/angular/reference/type-aliases/FlexRenderContent.md b/docs/framework/angular/reference/type-aliases/FlexRenderContent.md index 85cb24ace4..1f10ad8db0 100644 --- a/docs/framework/angular/reference/type-aliases/FlexRenderContent.md +++ b/docs/framework/angular/reference/type-aliases/FlexRenderContent.md @@ -3,8 +3,6 @@ id: FlexRenderContent title: FlexRenderContent --- -# Type Alias: FlexRenderContent\ - ```ts type FlexRenderContent = | string diff --git a/docs/framework/angular/reference/type-aliases/FlexRenderInputContent.md b/docs/framework/angular/reference/type-aliases/FlexRenderInputContent.md index a3d1862dcd..3487fdc48b 100644 --- a/docs/framework/angular/reference/type-aliases/FlexRenderInputContent.md +++ b/docs/framework/angular/reference/type-aliases/FlexRenderInputContent.md @@ -3,13 +3,11 @@ id: FlexRenderInputContent title: FlexRenderInputContent --- -# Type Alias: FlexRenderInputContent\ - ```ts type FlexRenderInputContent = | number | string - | (props) => FlexRenderContent + | ((props) => FlexRenderContent) | null | undefined; ``` diff --git a/docs/framework/angular/reference/type-aliases/RenderableComponent.md b/docs/framework/angular/reference/type-aliases/RenderableComponent.md index b194166761..96862d5b06 100644 --- a/docs/framework/angular/reference/type-aliases/RenderableComponent.md +++ b/docs/framework/angular/reference/type-aliases/RenderableComponent.md @@ -3,12 +3,10 @@ id: RenderableComponent title: RenderableComponent --- -# Type Alias: RenderableComponent - ```ts type RenderableComponent = | Type -| (props) => FlexRenderContent; + | ((props) => FlexRenderContent); ``` Defined in: [packages/angular-table/src/helpers/createTableHook.ts:34](https://github.com/TanStack/table/blob/main/packages/angular-table/src/helpers/createTableHook.ts#L34) diff --git a/docs/framework/angular/reference/type-aliases/SubscribeSource.md b/docs/framework/angular/reference/type-aliases/SubscribeSource.md index 531cddf8d5..e9228841d9 100644 --- a/docs/framework/angular/reference/type-aliases/SubscribeSource.md +++ b/docs/framework/angular/reference/type-aliases/SubscribeSource.md @@ -3,8 +3,6 @@ id: SubscribeSource title: SubscribeSource --- -# Type Alias: SubscribeSource\ - ```ts type SubscribeSource = | Atom diff --git a/docs/framework/angular/reference/variables/FlexRender.md b/docs/framework/angular/reference/variables/FlexRender.md index 0d628161c2..d53282cd68 100644 --- a/docs/framework/angular/reference/variables/FlexRender.md +++ b/docs/framework/angular/reference/variables/FlexRender.md @@ -3,8 +3,6 @@ id: FlexRender title: FlexRender --- -# Variable: FlexRender - ```ts const FlexRender: readonly [typeof FlexRenderDirective, typeof FlexRenderCell]; ``` diff --git a/docs/framework/angular/reference/variables/TanStackTableCellToken.md b/docs/framework/angular/reference/variables/TanStackTableCellToken.md index dd4895fc2d..434e935bdc 100644 --- a/docs/framework/angular/reference/variables/TanStackTableCellToken.md +++ b/docs/framework/angular/reference/variables/TanStackTableCellToken.md @@ -3,8 +3,6 @@ id: TanStackTableCellToken title: TanStackTableCellToken --- -# Variable: TanStackTableCellToken - ```ts const TanStackTableCellToken: InjectionToken>>; ``` diff --git a/docs/framework/angular/reference/variables/TanStackTableHeaderToken.md b/docs/framework/angular/reference/variables/TanStackTableHeaderToken.md index 4d607a3a2c..3552b427e6 100644 --- a/docs/framework/angular/reference/variables/TanStackTableHeaderToken.md +++ b/docs/framework/angular/reference/variables/TanStackTableHeaderToken.md @@ -3,8 +3,6 @@ id: TanStackTableHeaderToken title: TanStackTableHeaderToken --- -# Variable: TanStackTableHeaderToken - ```ts const TanStackTableHeaderToken: InjectionToken>>; ``` diff --git a/docs/framework/angular/reference/variables/TanStackTableToken.md b/docs/framework/angular/reference/variables/TanStackTableToken.md index 93a8358263..70d61bbbfd 100644 --- a/docs/framework/angular/reference/variables/TanStackTableToken.md +++ b/docs/framework/angular/reference/variables/TanStackTableToken.md @@ -3,8 +3,6 @@ id: TanStackTableToken title: TanStackTableToken --- -# Variable: TanStackTableToken - ```ts const TanStackTableToken: InjectionToken>>; ``` diff --git a/docs/framework/ember/guide/cell-selection.md b/docs/framework/ember/guide/cell-selection.md index 1115a7992f..c0567988ee 100644 --- a/docs/framework/ember/guide/cell-selection.md +++ b/docs/framework/ember/guide/cell-selection.md @@ -254,19 +254,23 @@ Cell selection ships no keyboard handling of its own. Instead it exposes imperat `direction` is `'up'`, `'down'`, `'left'`, or `'right'`. ```ts -import { createMultiHotkeyHandler } from '@tanstack/hotkeys' - -// Ember has no hotkeys adapter, so the framework-agnostic core handler is used -onGridKeyDown = createMultiHotkeyHandler({ - ArrowUp: () => this.table.moveCellSelection('up'), - ArrowDown: () => this.table.moveCellSelection('down'), - 'Shift+ArrowDown': () => this.table.extendCellSelection('down'), - 'Mod+A': () => this.table.selectAllCells(), - Escape: () => this.table.resetCellSelection(true), -}) +import { onHotkeys } from '@tanstack/ember-hotkeys' +import type { EmberHotkeyDefinition } from '@tanstack/ember-hotkeys' + +// the onHotkeys modifier scopes every binding to the element it is on +gridHotkeys: Array = [ + { hotkey: 'ArrowUp', callback: () => this.table.moveCellSelection('up') }, + { hotkey: 'ArrowDown', callback: () => this.table.moveCellSelection('down') }, + { + hotkey: 'Shift+ArrowDown', + callback: () => this.table.extendCellSelection('down'), + }, + { hotkey: 'Mod+A', callback: () => this.table.selectAllCells() }, + { hotkey: 'Escape', callback: () => this.table.resetCellSelection(true) }, +] // then, in the template: -//
...
+//
...
``` Scope the hotkeys to the grid element rather than the document, or arrow keys and Escape will hijack inputs elsewhere on the page. diff --git a/docs/framework/ember/reference/classes/ComputedSignal.md b/docs/framework/ember/reference/classes/ComputedSignal.md index 9178695adc..3d0e786a36 100644 --- a/docs/framework/ember/reference/classes/ComputedSignal.md +++ b/docs/framework/ember/reference/classes/ComputedSignal.md @@ -3,8 +3,6 @@ id: ComputedSignal title: ComputedSignal --- -# Class: ComputedSignal\ - Defined in: packages/ember-table/declarations/signal.d.ts:19 ## Type Parameters @@ -35,7 +33,7 @@ Defined in: packages/ember-table/declarations/signal.d.ts:21 ## Properties -### subscribe() +### subscribe ```ts subscribe: () => Subscription; diff --git a/docs/framework/ember/reference/classes/FlexRenderCell.md b/docs/framework/ember/reference/classes/FlexRenderCell.md index 1a08814c80..139627a1f4 100644 --- a/docs/framework/ember/reference/classes/FlexRenderCell.md +++ b/docs/framework/ember/reference/classes/FlexRenderCell.md @@ -3,8 +3,6 @@ id: FlexRenderCell title: FlexRenderCell --- -# Class: FlexRenderCell\ - Defined in: packages/ember-table/declarations/FlexRender.d.ts:26 ## Extends @@ -65,7 +63,7 @@ Component>.constructor [Context]: ComponentContext, FlexRenderCellSignature>; ``` -Defined in: node\_modules/.pnpm/@glint+ember-tsc@1.8.14\_ember-source@7.1.0\_@glimmer+component@2.1.1\_supports-color@8.1.\_8bece6e70d52a2dcadad1882db996878/node\_modules/@glint/ember-tsc/types/-private/dsl/integration-declarations.d.ts:33 +Defined in: node\_modules/.pnpm/@glint+ember-tsc@1.11.6\_ember-source@7.3.0\_@glimmer+component@2.1.1\_supports-color@8.1.\_d43e58650df066498b315aea8cf7f9bf/node\_modules/@glint/ember-tsc/types/-private/dsl/integration-declarations.d.ts:33 #### Inherited from @@ -75,14 +73,14 @@ Component.[Context] *** -### \[Invoke\]() +### \[Invoke\] ```ts [Invoke]: (...args) => ComponentReturn, unknown>; ``` -Defined in: node\_modules/.pnpm/@glint+template@1.7.10/node\_modules/@glint/template/-private/integration.d.ts:22 +Defined in: node\_modules/.pnpm/@glint+template@1.9.0/node\_modules/@glint/template/-private/integration.d.ts:22 #### Parameters diff --git a/docs/framework/ember/reference/classes/FlexRenderComponentConfig.md b/docs/framework/ember/reference/classes/FlexRenderComponentConfig.md index b99ac72a72..e4ca299242 100644 --- a/docs/framework/ember/reference/classes/FlexRenderComponentConfig.md +++ b/docs/framework/ember/reference/classes/FlexRenderComponentConfig.md @@ -3,8 +3,6 @@ id: FlexRenderComponentConfig title: FlexRenderComponentConfig --- -# Class: FlexRenderComponentConfig\ - Defined in: packages/ember-table/declarations/flex-render-helpers.d.ts:18 ## Type Parameters @@ -64,7 +62,7 @@ Defined in: packages/ember-table/declarations/flex-render-helpers.d.ts:19 ### options? ```ts -readonly optional options: TOptions; +readonly optional options?: TOptions; ``` Defined in: packages/ember-table/declarations/flex-render-helpers.d.ts:20 diff --git a/docs/framework/ember/reference/classes/FlexRenderFooter.md b/docs/framework/ember/reference/classes/FlexRenderFooter.md index a93322572e..a44d53cdc6 100644 --- a/docs/framework/ember/reference/classes/FlexRenderFooter.md +++ b/docs/framework/ember/reference/classes/FlexRenderFooter.md @@ -3,8 +3,6 @@ id: FlexRenderFooter title: FlexRenderFooter --- -# Class: FlexRenderFooter\ - Defined in: packages/ember-table/declarations/FlexRender.d.ts:54 ## Extends @@ -65,7 +63,7 @@ Component>.constructor [Context]: ComponentContext, FlexRenderFooterSignature>; ``` -Defined in: node\_modules/.pnpm/@glint+ember-tsc@1.8.14\_ember-source@7.1.0\_@glimmer+component@2.1.1\_supports-color@8.1.\_8bece6e70d52a2dcadad1882db996878/node\_modules/@glint/ember-tsc/types/-private/dsl/integration-declarations.d.ts:33 +Defined in: node\_modules/.pnpm/@glint+ember-tsc@1.11.6\_ember-source@7.3.0\_@glimmer+component@2.1.1\_supports-color@8.1.\_d43e58650df066498b315aea8cf7f9bf/node\_modules/@glint/ember-tsc/types/-private/dsl/integration-declarations.d.ts:33 #### Inherited from @@ -75,14 +73,14 @@ Component.[Context] *** -### \[Invoke\]() +### \[Invoke\] ```ts [Invoke]: (...args) => ComponentReturn, unknown>; ``` -Defined in: node\_modules/.pnpm/@glint+template@1.7.10/node\_modules/@glint/template/-private/integration.d.ts:22 +Defined in: node\_modules/.pnpm/@glint+template@1.9.0/node\_modules/@glint/template/-private/integration.d.ts:22 #### Parameters diff --git a/docs/framework/ember/reference/classes/FlexRenderHeader.md b/docs/framework/ember/reference/classes/FlexRenderHeader.md index d984df6d32..8970a95c9b 100644 --- a/docs/framework/ember/reference/classes/FlexRenderHeader.md +++ b/docs/framework/ember/reference/classes/FlexRenderHeader.md @@ -3,8 +3,6 @@ id: FlexRenderHeader title: FlexRenderHeader --- -# Class: FlexRenderHeader\ - Defined in: packages/ember-table/declarations/FlexRender.d.ts:40 ## Extends @@ -65,7 +63,7 @@ Component>.constructor [Context]: ComponentContext, FlexRenderHeaderSignature>; ``` -Defined in: node\_modules/.pnpm/@glint+ember-tsc@1.8.14\_ember-source@7.1.0\_@glimmer+component@2.1.1\_supports-color@8.1.\_8bece6e70d52a2dcadad1882db996878/node\_modules/@glint/ember-tsc/types/-private/dsl/integration-declarations.d.ts:33 +Defined in: node\_modules/.pnpm/@glint+ember-tsc@1.11.6\_ember-source@7.3.0\_@glimmer+component@2.1.1\_supports-color@8.1.\_d43e58650df066498b315aea8cf7f9bf/node\_modules/@glint/ember-tsc/types/-private/dsl/integration-declarations.d.ts:33 #### Inherited from @@ -75,14 +73,14 @@ Component.[Context] *** -### \[Invoke\]() +### \[Invoke\] ```ts [Invoke]: (...args) => ComponentReturn, unknown>; ``` -Defined in: node\_modules/.pnpm/@glint+template@1.7.10/node\_modules/@glint/template/-private/integration.d.ts:22 +Defined in: node\_modules/.pnpm/@glint+template@1.9.0/node\_modules/@glint/template/-private/integration.d.ts:22 #### Parameters diff --git a/docs/framework/ember/reference/classes/Signal.md b/docs/framework/ember/reference/classes/Signal.md index 0e6bae62a5..8c58af6c1a 100644 --- a/docs/framework/ember/reference/classes/Signal.md +++ b/docs/framework/ember/reference/classes/Signal.md @@ -3,8 +3,6 @@ id: Signal title: Signal --- -# Class: Signal\ - Defined in: packages/ember-table/declarations/signal.d.ts:8 Ember-native signal implementation. @@ -35,7 +33,7 @@ Defined in: packages/ember-table/declarations/signal.d.ts:11 ##### options -`AtomOptions`\<`T`\> | `undefined` +`AtomOptions`\<`T`\> \| `undefined` #### Returns @@ -113,7 +111,7 @@ Defined in: packages/ember-table/declarations/signal.d.ts:14 ##### value -`T` | (`prev`) => `T` +`T` \| ((`prev`) => `T`) #### Returns @@ -133,7 +131,7 @@ Defined in: packages/ember-table/declarations/signal.d.ts:12 ##### listenerOrObserver -`Observer`\<`T`\> | (`value`) => `void` +`Observer`\<`T`\> \| ((`value`) => `void`) #### Returns diff --git a/docs/framework/ember/reference/functions/computed.md b/docs/framework/ember/reference/functions/computed.md index 8856cbd841..cd2aa08505 100644 --- a/docs/framework/ember/reference/functions/computed.md +++ b/docs/framework/ember/reference/functions/computed.md @@ -3,8 +3,6 @@ id: computed title: computed --- -# Function: computed() - ```ts function computed(fn): ComputedSignal; ``` diff --git a/docs/framework/ember/reference/functions/createAtom.md b/docs/framework/ember/reference/functions/createAtom.md index dbe7d20aab..43732b101c 100644 --- a/docs/framework/ember/reference/functions/createAtom.md +++ b/docs/framework/ember/reference/functions/createAtom.md @@ -3,8 +3,6 @@ id: createAtom title: createAtom --- -# Function: createAtom() - ```ts function createAtom(initialValue, options?): Atom; ``` diff --git a/docs/framework/ember/reference/functions/createTableHook.md b/docs/framework/ember/reference/functions/createTableHook.md index 2340dacd14..caf2d75135 100644 --- a/docs/framework/ember/reference/functions/createTableHook.md +++ b/docs/framework/ember/reference/functions/createTableHook.md @@ -3,8 +3,6 @@ id: createTableHook title: createTableHook --- -# Function: createTableHook() - ```ts function createTableHook(__namedParameters): object; ``` @@ -41,7 +39,7 @@ components onto the table; render with the `FlexRenderCell`, appFeatures: TFeatures; ``` -### createAppColumnHelper() +### createAppColumnHelper ```ts createAppColumnHelper: () => ColumnHelper; @@ -57,7 +55,7 @@ createAppColumnHelper: () => ColumnHelper; `ColumnHelper`\<`TFeatures`, `TData`\> -### createAppTable() +### createAppTable ```ts createAppTable: { diff --git a/docs/framework/ember/reference/functions/emberReactivity.md b/docs/framework/ember/reference/functions/emberReactivity.md index 441d2c8774..e217a0ae9b 100644 --- a/docs/framework/ember/reference/functions/emberReactivity.md +++ b/docs/framework/ember/reference/functions/emberReactivity.md @@ -3,8 +3,6 @@ id: emberReactivity title: emberReactivity --- -# Function: emberReactivity() - ```ts function emberReactivity(): TableReactivityBindings; ``` diff --git a/docs/framework/ember/reference/functions/flexRenderComponent.md b/docs/framework/ember/reference/functions/flexRenderComponent.md index 15062eaf88..1fdb952bdd 100644 --- a/docs/framework/ember/reference/functions/flexRenderComponent.md +++ b/docs/framework/ember/reference/functions/flexRenderComponent.md @@ -3,8 +3,6 @@ id: flexRenderComponent title: flexRenderComponent --- -# Function: flexRenderComponent() - ## Call Signature ```ts diff --git a/docs/framework/ember/reference/functions/signal.md b/docs/framework/ember/reference/functions/signal.md index 57cee82fe7..04f88cd86b 100644 --- a/docs/framework/ember/reference/functions/signal.md +++ b/docs/framework/ember/reference/functions/signal.md @@ -3,8 +3,6 @@ id: signal title: signal --- -# Function: signal() - ```ts function signal(value, options): Signal; ``` @@ -25,7 +23,7 @@ Defined in: packages/ember-table/declarations/signal.d.ts:26 ### options -`AtomOptions`\<`T`\> | `undefined` +`AtomOptions`\<`T`\> \| `undefined` ## Returns diff --git a/docs/framework/ember/reference/functions/useTable.md b/docs/framework/ember/reference/functions/useTable.md index cba642ed31..dcbf7d752f 100644 --- a/docs/framework/ember/reference/functions/useTable.md +++ b/docs/framework/ember/reference/functions/useTable.md @@ -3,8 +3,6 @@ id: useTable title: useTable --- -# Function: useTable() - ## Call Signature ```ts diff --git a/docs/framework/ember/reference/index.md b/docs/framework/ember/reference/index.md index aa39703fc1..5c39c903c9 100644 --- a/docs/framework/ember/reference/index.md +++ b/docs/framework/ember/reference/index.md @@ -3,8 +3,6 @@ id: "@tanstack/ember-table" title: "@tanstack/ember-table" --- -# @tanstack/ember-table - ## Classes - [ComputedSignal](classes/ComputedSignal.md) diff --git a/docs/framework/ember/reference/interfaces/CellRenderableSignature.md b/docs/framework/ember/reference/interfaces/CellRenderableSignature.md index 048c86483c..7d70fc6ea7 100644 --- a/docs/framework/ember/reference/interfaces/CellRenderableSignature.md +++ b/docs/framework/ember/reference/interfaces/CellRenderableSignature.md @@ -3,8 +3,6 @@ id: CellRenderableSignature title: CellRenderableSignature --- -# Interface: CellRenderableSignature\ - Defined in: packages/ember-table/declarations/flex-render-helpers.d.ts:11 ## Type Parameters @@ -44,5 +42,5 @@ ctx: CellContext; #### options? ```ts -optional options: TOptions; +optional options?: TOptions; ``` diff --git a/docs/framework/ember/reference/interfaces/FlexRenderableSignature.md b/docs/framework/ember/reference/interfaces/FlexRenderableSignature.md index 21895cb3a6..01601c05cb 100644 --- a/docs/framework/ember/reference/interfaces/FlexRenderableSignature.md +++ b/docs/framework/ember/reference/interfaces/FlexRenderableSignature.md @@ -3,8 +3,6 @@ id: FlexRenderableSignature title: FlexRenderableSignature --- -# Interface: FlexRenderableSignature\ - Defined in: packages/ember-table/declarations/flex-render-helpers.d.ts:5 ## Type Parameters @@ -44,5 +42,5 @@ ctx: FlexRenderContext; #### options? ```ts -optional options: TOptions; +optional options?: TOptions; ``` diff --git a/docs/framework/ember/reference/type-aliases/AppColumnHelper.md b/docs/framework/ember/reference/type-aliases/AppColumnHelper.md index 2904c185fe..eddc95ee29 100644 --- a/docs/framework/ember/reference/type-aliases/AppColumnHelper.md +++ b/docs/framework/ember/reference/type-aliases/AppColumnHelper.md @@ -3,8 +3,6 @@ id: AppColumnHelper title: AppColumnHelper --- -# Type Alias: AppColumnHelper\ - ```ts type AppColumnHelper = ReturnType; ``` diff --git a/docs/framework/ember/reference/type-aliases/AppEmberTable.md b/docs/framework/ember/reference/type-aliases/AppEmberTable.md index 5b301967e4..0491b095e7 100644 --- a/docs/framework/ember/reference/type-aliases/AppEmberTable.md +++ b/docs/framework/ember/reference/type-aliases/AppEmberTable.md @@ -3,8 +3,6 @@ id: AppEmberTable title: AppEmberTable --- -# Type Alias: AppEmberTable\ - ```ts type AppEmberTable = Table; ``` diff --git a/docs/framework/ember/reference/type-aliases/CreateTableHookOptions.md b/docs/framework/ember/reference/type-aliases/CreateTableHookOptions.md index 9dfbdaa3ea..0477a9affa 100644 --- a/docs/framework/ember/reference/type-aliases/CreateTableHookOptions.md +++ b/docs/framework/ember/reference/type-aliases/CreateTableHookOptions.md @@ -3,8 +3,6 @@ id: CreateTableHookOptions title: CreateTableHookOptions --- -# Type Alias: CreateTableHookOptions\ - ```ts type CreateTableHookOptions = Omit, "columns" | "data" | "state">; ``` diff --git a/docs/framework/ember/reference/type-aliases/FlexRenderContext.md b/docs/framework/ember/reference/type-aliases/FlexRenderContext.md index 80ad6edf1c..c1486732a7 100644 --- a/docs/framework/ember/reference/type-aliases/FlexRenderContext.md +++ b/docs/framework/ember/reference/type-aliases/FlexRenderContext.md @@ -3,8 +3,6 @@ id: FlexRenderContext title: FlexRenderContext --- -# Type Alias: FlexRenderContext\ - ```ts type FlexRenderContext = | CellContext diff --git a/docs/framework/lit/guide/cell-selection.md b/docs/framework/lit/guide/cell-selection.md index ca69647422..9443f231eb 100644 --- a/docs/framework/lit/guide/cell-selection.md +++ b/docs/framework/lit/guide/cell-selection.md @@ -254,19 +254,31 @@ Cell selection ships no keyboard handling of its own. Instead it exposes imperat `direction` is `'up'`, `'down'`, `'left'`, or `'right'`. ```ts -import { createMultiHotkeyHandler } from '@tanstack/lit-hotkeys' - -// one stateless handler is simpler here than a HotkeyController per binding -const onGridKeyDown = createMultiHotkeyHandler({ - ArrowUp: () => table.moveCellSelection('up'), - ArrowDown: () => table.moveCellSelection('down'), - 'Shift+ArrowDown': () => table.extendCellSelection('down'), - 'Mod+A': () => table.selectAllCells(), - Escape: () => table.resetCellSelection(true), -}) - -// then, in the template: -// html`
...
` +import { createRef, ref } from 'lit/directives/ref.js' +import { HotkeyController } from '@tanstack/lit-hotkeys' +import type { HotkeyChord } from '@tanstack/lit-hotkeys' + +// inside the element class: one HotkeyController per binding, each scoped to +// the grid element +private _grid = createRef() + +private _gridHotkeys = ( + [ + ['ArrowUp', () => this._table?.moveCellSelection('up')], + ['ArrowDown', () => this._table?.moveCellSelection('down')], + ['Shift+ArrowDown', () => this._table?.extendCellSelection('down')], + ['Mod+A', () => this._table?.selectAllCells()], + ['Escape', () => this._table?.resetCellSelection(true)], + ] satisfies Array<[HotkeyChord, () => void]> +).map( + ([hotkey, callback]) => + new HotkeyController(this, hotkey, callback, () => ({ + target: this._grid.value, + })), +) + +// then, in render(): +// html`
...
` ``` Scope the hotkeys to the grid element rather than the document, or arrow keys and Escape will hijack inputs elsewhere on the page. diff --git a/docs/framework/lit/reference/classes/SubscribeDirective.md b/docs/framework/lit/reference/classes/SubscribeDirective.md index fd9387cf6e..58987aed89 100644 --- a/docs/framework/lit/reference/classes/SubscribeDirective.md +++ b/docs/framework/lit/reference/classes/SubscribeDirective.md @@ -3,8 +3,6 @@ id: SubscribeDirective title: SubscribeDirective --- -# Class: SubscribeDirective - Defined in: [packages/lit-table/src/subscribe-directive.ts:43](https://github.com/TanStack/table/blob/main/packages/lit-table/src/subscribe-directive.ts#L43) An asynchronous Lit directive that subscribes to a `@tanstack/lit-store` @@ -109,7 +107,7 @@ Initialize the part with internal fields ##### attributeIndex -`number` | `undefined` +`number` \| `undefined` #### Returns @@ -314,7 +312,8 @@ Defined in: [packages/lit-table/src/subscribe-directive.ts:87](https://github.co ##### args -\[[`SelectionSource`](../type-aliases/SelectionSource.md)\<`any`\>, `TemplateFunction`\<`any`\>\] | \[[`SelectionSource`](../type-aliases/SelectionSource.md)\<`any`\>, `Selector`\<`any`, `any`\>, `TemplateFunction`\<`any`\>\] + \| \[[`SelectionSource`](../type-aliases/SelectionSource.md)\<`any`\>, `TemplateFunction`\<`any`\>\] + \| \[[`SelectionSource`](../type-aliases/SelectionSource.md)\<`any`\>, `Selector`\<`any`, `any`\>, `TemplateFunction`\<`any`\>\] #### Returns diff --git a/docs/framework/lit/reference/classes/TableController.md b/docs/framework/lit/reference/classes/TableController.md index f44dedd2db..843219de9a 100644 --- a/docs/framework/lit/reference/classes/TableController.md +++ b/docs/framework/lit/reference/classes/TableController.md @@ -3,8 +3,6 @@ id: TableController title: TableController --- -# Class: TableController\ - Defined in: [packages/lit-table/src/TableController.ts:123](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L123) A Lit ReactiveController for TanStack Table integration. diff --git a/docs/framework/lit/reference/functions/FlexRender-1.md b/docs/framework/lit/reference/functions/FlexRender-1.md index c061ec9d2d..4af1c78ab5 100644 --- a/docs/framework/lit/reference/functions/FlexRender-1.md +++ b/docs/framework/lit/reference/functions/FlexRender-1.md @@ -3,8 +3,6 @@ id: FlexRender title: FlexRender --- -# Function: FlexRender() - ```ts function FlexRender(props): LitRenderable; ``` diff --git a/docs/framework/lit/reference/functions/createTableHook.md b/docs/framework/lit/reference/functions/createTableHook.md index 6167c70940..0c776cec0c 100644 --- a/docs/framework/lit/reference/functions/createTableHook.md +++ b/docs/framework/lit/reference/functions/createTableHook.md @@ -3,8 +3,6 @@ id: createTableHook title: createTableHook --- -# Function: createTableHook() - ```ts function createTableHook(__namedParameters): CreateTableHookResult; ``` diff --git a/docs/framework/lit/reference/functions/flexRender.md b/docs/framework/lit/reference/functions/flexRender.md index 883d93927f..8a75f0400d 100644 --- a/docs/framework/lit/reference/functions/flexRender.md +++ b/docs/framework/lit/reference/functions/flexRender.md @@ -3,8 +3,6 @@ id: flexRender title: flexRender --- -# Function: flexRender() - ```ts function flexRender(Comp, props): LitRenderable; ``` @@ -27,7 +25,8 @@ convenience wrapper for table cell/header/footer objects. ### Comp -[`LitRenderable`](../type-aliases/LitRenderable.md) | (`props`) => [`LitRenderable`](../type-aliases/LitRenderable.md) + \| [`LitRenderable`](../type-aliases/LitRenderable.md) + \| ((`props`) => [`LitRenderable`](../type-aliases/LitRenderable.md)) ### props diff --git a/docs/framework/lit/reference/index.md b/docs/framework/lit/reference/index.md index 5517c61193..dbaad72e1e 100644 --- a/docs/framework/lit/reference/index.md +++ b/docs/framework/lit/reference/index.md @@ -3,8 +3,6 @@ id: "@tanstack/lit-table" title: "@tanstack/lit-table" --- -# @tanstack/lit-table - ## Classes - [SubscribeDirective](classes/SubscribeDirective.md) diff --git a/docs/framework/lit/reference/interfaces/CreateTableHookResult.md b/docs/framework/lit/reference/interfaces/CreateTableHookResult.md index 2c6bc65772..367bff8db4 100644 --- a/docs/framework/lit/reference/interfaces/CreateTableHookResult.md +++ b/docs/framework/lit/reference/interfaces/CreateTableHookResult.md @@ -3,8 +3,6 @@ id: CreateTableHookResult title: CreateTableHookResult --- -# Interface: CreateTableHookResult\ - Defined in: [packages/lit-table/src/createTableHook.ts:358](https://github.com/TanStack/table/blob/main/packages/lit-table/src/createTableHook.ts#L358) ## Type Parameters @@ -39,7 +37,7 @@ The features object that was passed to `createTableHook`. *** -### createAppColumnHelper() +### createAppColumnHelper ```ts createAppColumnHelper: () => AppColumnHelper; @@ -62,7 +60,7 @@ the cell/header/footer render props expose the bound components. *** -### useAppTable() +### useAppTable ```ts useAppTable: (host, tableOptions, selector?) => object; @@ -102,7 +100,7 @@ the `App*` wrapper functions, a bound `FlexRender`, and the registered `object` -##### table() +##### table ```ts table: () => AppLitTable; @@ -114,7 +112,7 @@ table: () => AppLitTable(host) => ContextConsumer>, ReactiveControllerHost & HTMLElement>; @@ -143,7 +141,7 @@ provides an extended cell through context, so this is a BARE `Cell`. *** -### useHeaderContext() +### useHeaderContext ```ts useHeaderContext: (host) => ContextConsumer>, ReactiveControllerHost & HTMLElement>; @@ -172,7 +170,7 @@ provides an extended header through context, so this is a BARE `Header`. *** -### useTableContext() +### useTableContext ```ts useTableContext: (host) => ContextConsumer>, ReactiveControllerHost & HTMLElement>; diff --git a/docs/framework/lit/reference/type-aliases/AppCellContext.md b/docs/framework/lit/reference/type-aliases/AppCellContext.md index 05e996c13c..006b44392b 100644 --- a/docs/framework/lit/reference/type-aliases/AppCellContext.md +++ b/docs/framework/lit/reference/type-aliases/AppCellContext.md @@ -3,8 +3,6 @@ id: AppCellContext title: AppCellContext --- -# Type Alias: AppCellContext\ - ```ts type AppCellContext = object; ``` @@ -44,7 +42,7 @@ Defined in: [packages/lit-table/src/createTableHook.ts:55](https://github.com/Ta #### Type Declaration -##### FlexRender() +##### FlexRender ```ts FlexRender: () => LitRenderable; diff --git a/docs/framework/lit/reference/type-aliases/AppColumnDefBase.md b/docs/framework/lit/reference/type-aliases/AppColumnDefBase.md index bfc76c591c..6a3c527454 100644 --- a/docs/framework/lit/reference/type-aliases/AppColumnDefBase.md +++ b/docs/framework/lit/reference/type-aliases/AppColumnDefBase.md @@ -3,8 +3,6 @@ id: AppColumnDefBase title: AppColumnDefBase --- -# Type Alias: AppColumnDefBase\ - ```ts type AppColumnDefBase = Omit, "cell" | "header" | "footer"> & object; ``` @@ -18,19 +16,19 @@ Enhanced column definition base with pre-bound components in cell/header/footer ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/lit/reference/type-aliases/AppColumnDefTemplate.md b/docs/framework/lit/reference/type-aliases/AppColumnDefTemplate.md index 94ea5c6c65..3c3baad44a 100644 --- a/docs/framework/lit/reference/type-aliases/AppColumnDefTemplate.md +++ b/docs/framework/lit/reference/type-aliases/AppColumnDefTemplate.md @@ -3,10 +3,8 @@ id: AppColumnDefTemplate title: AppColumnDefTemplate --- -# Type Alias: AppColumnDefTemplate\ - ```ts -type AppColumnDefTemplate = string | (props) => any; +type AppColumnDefTemplate = string | ((props) => any); ``` Defined in: [packages/lit-table/src/createTableHook.ts:91](https://github.com/TanStack/table/blob/main/packages/lit-table/src/createTableHook.ts#L91) diff --git a/docs/framework/lit/reference/type-aliases/AppColumnHelper.md b/docs/framework/lit/reference/type-aliases/AppColumnHelper.md index 267fff63b1..e39b25d1fb 100644 --- a/docs/framework/lit/reference/type-aliases/AppColumnHelper.md +++ b/docs/framework/lit/reference/type-aliases/AppColumnHelper.md @@ -3,8 +3,6 @@ id: AppColumnHelper title: AppColumnHelper --- -# Type Alias: AppColumnHelper\ - ```ts type AppColumnHelper = object; ``` @@ -34,7 +32,7 @@ This enables TypeScript to know about the registered components when defining co ## Properties -### accessor() +### accessor ```ts accessor: (accessor, column) => TAccessor extends AccessorFn ? AccessorFnColumnDef : AccessorKeyColumnDef; @@ -71,7 +69,7 @@ The cell, header, and footer contexts include pre-bound components. *** -### columns() +### columns ```ts columns: (columns) => ColumnDef[] & [...TColumns]; @@ -99,7 +97,7 @@ Wraps an array of column definitions to preserve each column's individual TValue *** -### display() +### display ```ts display: (column) => DisplayColumnDef; @@ -122,7 +120,7 @@ The cell, header, and footer contexts include pre-bound components. *** -### group() +### group ```ts group: (column) => GroupColumnDef; diff --git a/docs/framework/lit/reference/type-aliases/AppDisplayColumnDef.md b/docs/framework/lit/reference/type-aliases/AppDisplayColumnDef.md index 7f80e00a3a..bd8dc99962 100644 --- a/docs/framework/lit/reference/type-aliases/AppDisplayColumnDef.md +++ b/docs/framework/lit/reference/type-aliases/AppDisplayColumnDef.md @@ -3,8 +3,6 @@ id: AppDisplayColumnDef title: AppDisplayColumnDef --- -# Type Alias: AppDisplayColumnDef\ - ```ts type AppDisplayColumnDef = Omit, "cell" | "header" | "footer"> & object; ``` @@ -18,19 +16,19 @@ Enhanced display column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/lit/reference/type-aliases/AppGroupColumnDef.md b/docs/framework/lit/reference/type-aliases/AppGroupColumnDef.md index 0841217102..5b206f5a6e 100644 --- a/docs/framework/lit/reference/type-aliases/AppGroupColumnDef.md +++ b/docs/framework/lit/reference/type-aliases/AppGroupColumnDef.md @@ -3,8 +3,6 @@ id: AppGroupColumnDef title: AppGroupColumnDef --- -# Type Alias: AppGroupColumnDef\ - ```ts type AppGroupColumnDef = Omit, "cell" | "header" | "footer" | "columns"> & object; ``` @@ -18,25 +16,25 @@ Enhanced group column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### columns? ```ts -optional columns: ReadonlyArray>; +optional columns?: ReadonlyArray>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/lit/reference/type-aliases/AppHeaderContext.md b/docs/framework/lit/reference/type-aliases/AppHeaderContext.md index 46e6eb056b..389dbfb8c8 100644 --- a/docs/framework/lit/reference/type-aliases/AppHeaderContext.md +++ b/docs/framework/lit/reference/type-aliases/AppHeaderContext.md @@ -3,8 +3,6 @@ id: AppHeaderContext title: AppHeaderContext --- -# Type Alias: AppHeaderContext\ - ```ts type AppHeaderContext = object; ``` @@ -54,7 +52,7 @@ Defined in: [packages/lit-table/src/createTableHook.ts:77](https://github.com/Ta #### Type Declaration -##### FlexRender() +##### FlexRender ```ts FlexRender: () => LitRenderable; diff --git a/docs/framework/lit/reference/type-aliases/AppLitTable.md b/docs/framework/lit/reference/type-aliases/AppLitTable.md index 91a3e8add0..2d84e23bc2 100644 --- a/docs/framework/lit/reference/type-aliases/AppLitTable.md +++ b/docs/framework/lit/reference/type-aliases/AppLitTable.md @@ -3,8 +3,6 @@ id: AppLitTable title: AppLitTable --- -# Type Alias: AppLitTable\ - ```ts type AppLitTable = LitTable & NoInfer & object; ``` @@ -15,7 +13,7 @@ Extended table API returned by useAppTable with all App wrapper functions ## Type Declaration -### AppCell() +### AppCell ```ts AppCell: (cell, renderFn) => LitRenderable; @@ -49,7 +47,7 @@ Wraps a cell and provides cell context with pre-bound cellComponents. ${table.AppCell(cell, (c) => html`${c.FlexRender()}`)} ``` -### AppFooter() +### AppFooter ```ts AppFooter: (header, renderFn) => LitRenderable; @@ -83,7 +81,7 @@ Wraps a footer and provides header context with pre-bound headerComponents. ${table.AppFooter(footer, (f) => html`${f.FlexRender()}`)} ``` -### AppHeader() +### AppHeader ```ts AppHeader: (header, renderFn) => LitRenderable; diff --git a/docs/framework/lit/reference/type-aliases/BoundComponents.md b/docs/framework/lit/reference/type-aliases/BoundComponents.md index 07e84c5124..8d91ee07cd 100644 --- a/docs/framework/lit/reference/type-aliases/BoundComponents.md +++ b/docs/framework/lit/reference/type-aliases/BoundComponents.md @@ -3,8 +3,6 @@ id: BoundComponents title: BoundComponents --- -# Type Alias: BoundComponents\ - ```ts type BoundComponents = { [TKey in keyof TComponents]: () => ReturnType }; ``` diff --git a/docs/framework/lit/reference/type-aliases/ComponentType.md b/docs/framework/lit/reference/type-aliases/ComponentType.md index 8bb2f9aa9f..ae66e1338d 100644 --- a/docs/framework/lit/reference/type-aliases/ComponentType.md +++ b/docs/framework/lit/reference/type-aliases/ComponentType.md @@ -3,8 +3,6 @@ id: ComponentType title: ComponentType --- -# Type Alias: ComponentType()\ - ```ts type ComponentType = (props) => any; ``` diff --git a/docs/framework/lit/reference/type-aliases/CreateTableHookOptions.md b/docs/framework/lit/reference/type-aliases/CreateTableHookOptions.md index cc8073add5..0d6805f24f 100644 --- a/docs/framework/lit/reference/type-aliases/CreateTableHookOptions.md +++ b/docs/framework/lit/reference/type-aliases/CreateTableHookOptions.md @@ -3,8 +3,6 @@ id: CreateTableHookOptions title: CreateTableHookOptions --- -# Type Alias: CreateTableHookOptions\ - ```ts type CreateTableHookOptions = Omit, "columns" | "data" | "store" | "state" | "initialState"> & object; ``` @@ -19,7 +17,7 @@ Extends all TableOptions except 'columns' | 'data' | 'store' | 'state' | 'initia ### cellComponents? ```ts -optional cellComponents: TCellComponents; +optional cellComponents?: TCellComponents; ``` Cell-level components that need access to the cell instance. @@ -35,7 +33,7 @@ Use `useCellContext()` inside these components. ### headerComponents? ```ts -optional headerComponents: THeaderComponents; +optional headerComponents?: THeaderComponents; ``` Header-level components that need access to the header instance. @@ -51,7 +49,7 @@ Use `useHeaderContext()` inside these components. ### tableComponents? ```ts -optional tableComponents: TTableComponents; +optional tableComponents?: TTableComponents; ``` Table-level components that need access to the table instance. diff --git a/docs/framework/lit/reference/type-aliases/FlexRenderProps.md b/docs/framework/lit/reference/type-aliases/FlexRenderProps.md index bdef5a7b3b..bb1c5cf963 100644 --- a/docs/framework/lit/reference/type-aliases/FlexRenderProps.md +++ b/docs/framework/lit/reference/type-aliases/FlexRenderProps.md @@ -3,8 +3,6 @@ id: FlexRenderProps title: FlexRenderProps --- -# Type Alias: FlexRenderProps\ - ```ts type FlexRenderProps = | { diff --git a/docs/framework/lit/reference/type-aliases/LitRenderable.md b/docs/framework/lit/reference/type-aliases/LitRenderable.md index 19fcbd1e2d..174f171180 100644 --- a/docs/framework/lit/reference/type-aliases/LitRenderable.md +++ b/docs/framework/lit/reference/type-aliases/LitRenderable.md @@ -3,8 +3,6 @@ id: LitRenderable title: LitRenderable --- -# Type Alias: LitRenderable - ```ts type LitRenderable = | TemplateResult diff --git a/docs/framework/lit/reference/type-aliases/LitTable.md b/docs/framework/lit/reference/type-aliases/LitTable.md index 64a961162f..879cd9d632 100644 --- a/docs/framework/lit/reference/type-aliases/LitTable.md +++ b/docs/framework/lit/reference/type-aliases/LitTable.md @@ -3,8 +3,6 @@ id: LitTable title: LitTable --- -# Type Alias: LitTable\ - ```ts type LitTable = Omit, "store"> & object; ``` diff --git a/docs/framework/lit/reference/type-aliases/SelectionSource.md b/docs/framework/lit/reference/type-aliases/SelectionSource.md index fe5da2cb69..1d0e636478 100644 --- a/docs/framework/lit/reference/type-aliases/SelectionSource.md +++ b/docs/framework/lit/reference/type-aliases/SelectionSource.md @@ -3,8 +3,6 @@ id: SelectionSource title: SelectionSource --- -# Type Alias: SelectionSource\ - ```ts type SelectionSource = | Atom diff --git a/docs/framework/lit/reference/variables/subscribe.md b/docs/framework/lit/reference/variables/subscribe.md index bd75169808..0275498968 100644 --- a/docs/framework/lit/reference/variables/subscribe.md +++ b/docs/framework/lit/reference/variables/subscribe.md @@ -3,8 +3,6 @@ id: subscribe title: subscribe --- -# Variable: subscribe() - ```ts const subscribe: { (source, template): DirectiveResult; diff --git a/docs/framework/octane/guide/cell-spanning.md b/docs/framework/octane/guide/cell-spanning.md index eeb2709536..431d718e94 100644 --- a/docs/framework/octane/guide/cell-spanning.md +++ b/docs/framework/octane/guide/cell-spanning.md @@ -68,12 +68,12 @@ A covered cell reports a span of `0`, and the renderer skips it. This is the sam const colSpan = cell.getColSpan() // A span of 0 means the cell is covered by a cell above or to its left. - // Skip it. Do not render `rowSpan={0}`: in HTML that means "span to the + // Skip it. Do not render `rowspan={0}`: in HTML that means "span to the // end of the row group", which merges the cell down the entire tbody. if (rowSpan === 0 || colSpan === 0) return null return ( - + ) diff --git a/docs/framework/octane/guide/column-resizing.md b/docs/framework/octane/guide/column-resizing.md index 62908238eb..d8a38487d8 100644 --- a/docs/framework/octane/guide/column-resizing.md +++ b/docs/framework/octane/guide/column-resizing.md @@ -119,7 +119,7 @@ How you apply these size styles to your markup is up to you, but it is pretty co ```tsx ``` diff --git a/docs/framework/octane/guide/expanding.md b/docs/framework/octane/guide/expanding.md index d280f45ddd..59ddd32624 100644 --- a/docs/framework/octane/guide/expanding.md +++ b/docs/framework/octane/guide/expanding.md @@ -146,7 +146,7 @@ const table = useTable({ {row.getIsExpanded() && ( {/* span however many columns the expanded data needs if it does not share the parent row's columns */} - + {/* Your custom UI goes here */} diff --git a/docs/framework/octane/guide/table-context.md b/docs/framework/octane/guide/table-context.md index ab842f08b6..9bef33a37f 100644 --- a/docs/framework/octane/guide/table-context.md +++ b/docs/framework/octane/guide/table-context.md @@ -65,14 +65,14 @@ Reach for `createTableHookContexts` instead of hand-rolling `createContext`. It ```tsx // cell-slot-context.ts -export const { cellContext, useCellContext } = +export const { cellContext: CellContext, useCellContext } = createTableHookContexts() // provide the (stable) cell once, near where you render it function CellSlot({ cell }: { cell: Cell }) @{ - + - + } // read it anywhere below, no prop drilling diff --git a/docs/framework/octane/reference/functions/FlexRender-1.md b/docs/framework/octane/reference/functions/FlexRender-1.md index e764abc47d..4fbdd6a9a3 100644 --- a/docs/framework/octane/reference/functions/FlexRender-1.md +++ b/docs/framework/octane/reference/functions/FlexRender-1.md @@ -3,8 +3,6 @@ id: FlexRender title: FlexRender --- -# Function: FlexRender() - ```ts function FlexRender(props): unknown; ``` diff --git a/docs/framework/octane/reference/functions/createTableHook.md b/docs/framework/octane/reference/functions/createTableHook.md index 93494318f7..4de203852c 100644 --- a/docs/framework/octane/reference/functions/createTableHook.md +++ b/docs/framework/octane/reference/functions/createTableHook.md @@ -3,8 +3,6 @@ id: createTableHook title: createTableHook --- -# Function: createTableHook() - ```ts function createTableHook(options): CreateTableHookResult; ``` diff --git a/docs/framework/octane/reference/functions/createTableHookContexts.md b/docs/framework/octane/reference/functions/createTableHookContexts.md index 3fd15cfad8..93952c241e 100644 --- a/docs/framework/octane/reference/functions/createTableHookContexts.md +++ b/docs/framework/octane/reference/functions/createTableHookContexts.md @@ -3,8 +3,6 @@ id: createTableHookContexts title: createTableHookContexts --- -# Function: createTableHookContexts() - ```ts function createTableHookContexts(): TableHookContexts; ``` diff --git a/docs/framework/octane/reference/functions/flexRender.md b/docs/framework/octane/reference/functions/flexRender.md index 2226e339d6..8d2d062ba4 100644 --- a/docs/framework/octane/reference/functions/flexRender.md +++ b/docs/framework/octane/reference/functions/flexRender.md @@ -3,8 +3,6 @@ id: flexRender title: flexRender --- -# Function: flexRender() - ```ts function flexRender(Comp, props): unknown; ``` diff --git a/docs/framework/octane/reference/functions/useTable.md b/docs/framework/octane/reference/functions/useTable.md index 6e78b68355..2429841a57 100644 --- a/docs/framework/octane/reference/functions/useTable.md +++ b/docs/framework/octane/reference/functions/useTable.md @@ -3,8 +3,6 @@ id: useTable title: useTable --- -# Function: useTable() - ```ts function useTable(tableOptions, selector?): OctaneTable; ``` diff --git a/docs/framework/octane/reference/index.md b/docs/framework/octane/reference/index.md index fa5fc5cfd1..1b60e61446 100644 --- a/docs/framework/octane/reference/index.md +++ b/docs/framework/octane/reference/index.md @@ -3,8 +3,6 @@ id: "@tanstack/octane-table" title: "@tanstack/octane-table" --- -# @tanstack/octane-table - ## Interfaces - [AppCellComponent](interfaces/AppCellComponent.md) diff --git a/docs/framework/octane/reference/interfaces/AppCellComponent.md b/docs/framework/octane/reference/interfaces/AppCellComponent.md index 2d7dff1d4a..3df36aa11b 100644 --- a/docs/framework/octane/reference/interfaces/AppCellComponent.md +++ b/docs/framework/octane/reference/interfaces/AppCellComponent.md @@ -3,8 +3,6 @@ id: AppCellComponent title: AppCellComponent --- -# Interface: AppCellComponent()\ - Defined in: [types.ts:670](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L670) Component type for AppCell — wraps a cell and provides cell context with diff --git a/docs/framework/octane/reference/interfaces/AppCellContext.md b/docs/framework/octane/reference/interfaces/AppCellContext.md index cb6ccfb32c..09feda93ba 100644 --- a/docs/framework/octane/reference/interfaces/AppCellContext.md +++ b/docs/framework/octane/reference/interfaces/AppCellContext.md @@ -3,8 +3,6 @@ id: AppCellContext title: AppCellContext --- -# Interface: AppCellContext\ - Defined in: [types.ts:341](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L341) Enhanced CellContext with pre-bound cell components. @@ -40,7 +38,7 @@ Defined in: [types.ts:347](https://github.com/TanStack/table/blob/main/packages/ #### Type Declaration -##### FlexRender() +##### FlexRender ```ts FlexRender: () => unknown; diff --git a/docs/framework/octane/reference/interfaces/AppCellPropsWithSelector.md b/docs/framework/octane/reference/interfaces/AppCellPropsWithSelector.md index 7b7fd10186..2e5cfb6640 100644 --- a/docs/framework/octane/reference/interfaces/AppCellPropsWithSelector.md +++ b/docs/framework/octane/reference/interfaces/AppCellPropsWithSelector.md @@ -3,8 +3,6 @@ id: AppCellPropsWithSelector title: AppCellPropsWithSelector --- -# Interface: AppCellPropsWithSelector\ - Defined in: [types.ts:618](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L618) Props for AppCell component — with selector. @@ -43,7 +41,7 @@ Defined in: [types.ts:625](https://github.com/TanStack/table/blob/main/packages/ *** -### children() +### children ```ts children: (cell, state) => unknown; @@ -67,7 +65,7 @@ Defined in: [types.ts:626](https://github.com/TanStack/table/blob/main/packages/ *** -### selector() +### selector ```ts selector: (state) => TSelected; diff --git a/docs/framework/octane/reference/interfaces/AppCellPropsWithoutSelector.md b/docs/framework/octane/reference/interfaces/AppCellPropsWithoutSelector.md index d8824d6bcf..322b28c04b 100644 --- a/docs/framework/octane/reference/interfaces/AppCellPropsWithoutSelector.md +++ b/docs/framework/octane/reference/interfaces/AppCellPropsWithoutSelector.md @@ -3,8 +3,6 @@ id: AppCellPropsWithoutSelector title: AppCellPropsWithoutSelector --- -# Interface: AppCellPropsWithoutSelector\ - Defined in: [types.ts:603](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L603) Props for AppCell component — without selector. @@ -39,7 +37,7 @@ Defined in: [types.ts:609](https://github.com/TanStack/table/blob/main/packages/ *** -### children() +### children ```ts children: (cell) => unknown; @@ -62,7 +60,7 @@ Defined in: [types.ts:610](https://github.com/TanStack/table/blob/main/packages/ ### selector? ```ts -optional selector: undefined; +optional selector?: undefined; ``` Defined in: [types.ts:614](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L614) diff --git a/docs/framework/octane/reference/interfaces/AppColumnHelper.md b/docs/framework/octane/reference/interfaces/AppColumnHelper.md index a4fe7ea54c..b436be73d7 100644 --- a/docs/framework/octane/reference/interfaces/AppColumnHelper.md +++ b/docs/framework/octane/reference/interfaces/AppColumnHelper.md @@ -3,8 +3,6 @@ id: AppColumnHelper title: AppColumnHelper --- -# Interface: AppColumnHelper\ - Defined in: [types.ts:455](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L455) Enhanced column helper with pre-bound components in cell/header/footer @@ -31,7 +29,7 @@ when defining columns. ## Properties -### accessor() +### accessor ```ts accessor: (accessor, column) => TAccessor extends AccessorFn ? AccessorFnColumnDef : AccessorKeyColumnDef; @@ -68,7 +66,7 @@ The cell, header, and footer contexts include pre-bound components. *** -### columns() +### columns ```ts columns: (columns) => ColumnDef[] & [...TColumns[]]; @@ -97,7 +95,7 @@ TValue type. *** -### display() +### display ```ts display: (column) => DisplayColumnDef; @@ -120,7 +118,7 @@ The cell, header, and footer contexts include pre-bound components. *** -### group() +### group ```ts group: (column) => GroupColumnDef; diff --git a/docs/framework/octane/reference/interfaces/AppHeaderComponent.md b/docs/framework/octane/reference/interfaces/AppHeaderComponent.md index 0dc5a8e92a..0135457ba9 100644 --- a/docs/framework/octane/reference/interfaces/AppHeaderComponent.md +++ b/docs/framework/octane/reference/interfaces/AppHeaderComponent.md @@ -3,8 +3,6 @@ id: AppHeaderComponent title: AppHeaderComponent --- -# Interface: AppHeaderComponent()\ - Defined in: [types.ts:698](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L698) Component type for AppHeader/AppFooter — wraps a header and provides header diff --git a/docs/framework/octane/reference/interfaces/AppHeaderContext.md b/docs/framework/octane/reference/interfaces/AppHeaderContext.md index 2c85aaf8f9..f9025bc30a 100644 --- a/docs/framework/octane/reference/interfaces/AppHeaderContext.md +++ b/docs/framework/octane/reference/interfaces/AppHeaderContext.md @@ -3,8 +3,6 @@ id: AppHeaderContext title: AppHeaderContext --- -# Interface: AppHeaderContext\ - Defined in: [types.ts:360](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L360) Enhanced HeaderContext with pre-bound header components. @@ -50,7 +48,7 @@ Defined in: [types.ts:367](https://github.com/TanStack/table/blob/main/packages/ #### Type Declaration -##### FlexRender() +##### FlexRender ```ts FlexRender: () => unknown; diff --git a/docs/framework/octane/reference/interfaces/AppHeaderPropsWithSelector.md b/docs/framework/octane/reference/interfaces/AppHeaderPropsWithSelector.md index 41904b5a2e..d533cd9a4c 100644 --- a/docs/framework/octane/reference/interfaces/AppHeaderPropsWithSelector.md +++ b/docs/framework/octane/reference/interfaces/AppHeaderPropsWithSelector.md @@ -3,8 +3,6 @@ id: AppHeaderPropsWithSelector title: AppHeaderPropsWithSelector --- -# Interface: AppHeaderPropsWithSelector\ - Defined in: [types.ts:650](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L650) Props for AppHeader/AppFooter component — with selector. @@ -33,7 +31,7 @@ Props for AppHeader/AppFooter component — with selector. ## Properties -### children() +### children ```ts children: (header, state) => unknown; @@ -67,7 +65,7 @@ Defined in: [types.ts:657](https://github.com/TanStack/table/blob/main/packages/ *** -### selector() +### selector ```ts selector: (state) => TSelected; diff --git a/docs/framework/octane/reference/interfaces/AppHeaderPropsWithoutSelector.md b/docs/framework/octane/reference/interfaces/AppHeaderPropsWithoutSelector.md index 9b5952d394..4b6449e418 100644 --- a/docs/framework/octane/reference/interfaces/AppHeaderPropsWithoutSelector.md +++ b/docs/framework/octane/reference/interfaces/AppHeaderPropsWithoutSelector.md @@ -3,8 +3,6 @@ id: AppHeaderPropsWithoutSelector title: AppHeaderPropsWithoutSelector --- -# Interface: AppHeaderPropsWithoutSelector\ - Defined in: [types.ts:635](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L635) Props for AppHeader/AppFooter component — without selector. @@ -29,7 +27,7 @@ Props for AppHeader/AppFooter component — without selector. ## Properties -### children() +### children ```ts children: (header) => unknown; @@ -62,7 +60,7 @@ Defined in: [types.ts:641](https://github.com/TanStack/table/blob/main/packages/ ### selector? ```ts -optional selector: undefined; +optional selector?: undefined; ``` Defined in: [types.ts:646](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L646) diff --git a/docs/framework/octane/reference/interfaces/AppTableComponent.md b/docs/framework/octane/reference/interfaces/AppTableComponent.md index 1e59cad4a7..bacf606284 100644 --- a/docs/framework/octane/reference/interfaces/AppTableComponent.md +++ b/docs/framework/octane/reference/interfaces/AppTableComponent.md @@ -3,8 +3,6 @@ id: AppTableComponent title: AppTableComponent --- -# Interface: AppTableComponent()\ - Defined in: [types.ts:723](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L723) Component type for AppTable — root wrapper with optional Subscribe. diff --git a/docs/framework/octane/reference/interfaces/AppTablePropsWithSelector.md b/docs/framework/octane/reference/interfaces/AppTablePropsWithSelector.md index 946d5d9c21..50f417840d 100644 --- a/docs/framework/octane/reference/interfaces/AppTablePropsWithSelector.md +++ b/docs/framework/octane/reference/interfaces/AppTablePropsWithSelector.md @@ -3,8 +3,6 @@ id: AppTablePropsWithSelector title: AppTablePropsWithSelector --- -# Interface: AppTablePropsWithSelector\ - Defined in: [types.ts:594](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L594) Props for AppTable component — with selector. @@ -21,7 +19,7 @@ Props for AppTable component — with selector. ## Properties -### children() +### children ```ts children: (state) => unknown; @@ -41,7 +39,7 @@ Defined in: [types.ts:598](https://github.com/TanStack/table/blob/main/packages/ *** -### selector() +### selector ```ts selector: (state) => TSelected; diff --git a/docs/framework/octane/reference/interfaces/AppTablePropsWithoutSelector.md b/docs/framework/octane/reference/interfaces/AppTablePropsWithoutSelector.md index d4faf227c2..5dd993f039 100644 --- a/docs/framework/octane/reference/interfaces/AppTablePropsWithoutSelector.md +++ b/docs/framework/octane/reference/interfaces/AppTablePropsWithoutSelector.md @@ -3,8 +3,6 @@ id: AppTablePropsWithoutSelector title: AppTablePropsWithoutSelector --- -# Interface: AppTablePropsWithoutSelector - Defined in: [types.ts:588](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L588) Props for AppTable component — without selector. @@ -24,7 +22,7 @@ Defined in: [types.ts:589](https://github.com/TanStack/table/blob/main/packages/ ### selector? ```ts -optional selector: undefined; +optional selector?: undefined; ``` Defined in: [types.ts:590](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L590) diff --git a/docs/framework/octane/reference/interfaces/CreateTableHookResult.md b/docs/framework/octane/reference/interfaces/CreateTableHookResult.md index 6f8e28200a..c0dda85c44 100644 --- a/docs/framework/octane/reference/interfaces/CreateTableHookResult.md +++ b/docs/framework/octane/reference/interfaces/CreateTableHookResult.md @@ -3,8 +3,6 @@ id: CreateTableHookResult title: CreateTableHookResult --- -# Interface: CreateTableHookResult\ - Defined in: [types.ts:807](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L807) ## Type Parameters @@ -39,7 +37,7 @@ The features object that was passed to `createTableHook`. *** -### createAppColumnHelper() +### createAppColumnHelper ```ts createAppColumnHelper: () => AppColumnHelper; @@ -62,7 +60,7 @@ the cell/header/footer render props expose the bound components. *** -### useAppTable() +### useAppTable ```ts useAppTable: (tableOptions, selector?) => AppOctaneTable; @@ -99,7 +97,7 @@ Creates a table with the `App*` wrapper components and registered *** -### useCellContext() +### useCellContext ```ts useCellContext: () => Cell_Core & ExtractFeatureMapTypes & TCellComponents & object; @@ -122,7 +120,7 @@ your `cellComponents` and a context-bound `FlexRender`. *** -### useHeaderContext() +### useHeaderContext ```ts useHeaderContext: () => Header_Core & ExtractFeatureMapTypes & THeaderComponents & object; @@ -146,7 +144,7 @@ context-bound `FlexRender`. *** -### useTableContext() +### useTableContext ```ts useTableContext: () => AppOctaneTable; diff --git a/docs/framework/octane/reference/interfaces/SubscribeComponent.md b/docs/framework/octane/reference/interfaces/SubscribeComponent.md index 2aade793d7..2bb0dda793 100644 --- a/docs/framework/octane/reference/interfaces/SubscribeComponent.md +++ b/docs/framework/octane/reference/interfaces/SubscribeComponent.md @@ -3,8 +3,6 @@ id: SubscribeComponent title: SubscribeComponent --- -# Interface: SubscribeComponent() - Defined in: [types.ts:181](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L181) The call signature of the standalone `Subscribe` component. diff --git a/docs/framework/octane/reference/interfaces/SubscribePropsWithSourceIdentity.md b/docs/framework/octane/reference/interfaces/SubscribePropsWithSourceIdentity.md index 3fd36ec591..0deaf924b2 100644 --- a/docs/framework/octane/reference/interfaces/SubscribePropsWithSourceIdentity.md +++ b/docs/framework/octane/reference/interfaces/SubscribePropsWithSourceIdentity.md @@ -3,8 +3,6 @@ id: SubscribePropsWithSourceIdentity title: SubscribePropsWithSourceIdentity --- -# Interface: SubscribePropsWithSourceIdentity\ - Defined in: [types.ts:134](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L134) Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or @@ -24,7 +22,7 @@ selector — children receive `TSourceValue`. ```ts children: | SubscribeStaticChild - | (state) => unknown; + | ((state) => unknown); ``` Defined in: [types.ts:137](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L137) @@ -34,7 +32,7 @@ Defined in: [types.ts:137](https://github.com/TanStack/table/blob/main/packages/ ### selector? ```ts -optional selector: undefined; +optional selector?: undefined; ``` Defined in: [types.ts:136](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L136) diff --git a/docs/framework/octane/reference/interfaces/SubscribePropsWithSourceWithSelector.md b/docs/framework/octane/reference/interfaces/SubscribePropsWithSourceWithSelector.md index b56bca608a..baca4fb788 100644 --- a/docs/framework/octane/reference/interfaces/SubscribePropsWithSourceWithSelector.md +++ b/docs/framework/octane/reference/interfaces/SubscribePropsWithSourceWithSelector.md @@ -3,8 +3,6 @@ id: SubscribePropsWithSourceWithSelector title: SubscribePropsWithSourceWithSelector --- -# Interface: SubscribePropsWithSourceWithSelector\ - Defined in: [types.ts:144](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L144) Subscribe to a projected value from a source (atom or store). The selector @@ -27,14 +25,14 @@ receives the source value; children receive the projected `TSelected`. ```ts children: | SubscribeStaticChild - | (state) => unknown; + | ((state) => unknown); ``` Defined in: [types.ts:147](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L147) *** -### selector() +### selector ```ts selector: (state) => TSelected; diff --git a/docs/framework/octane/reference/interfaces/SubscribePropsWithStore.md b/docs/framework/octane/reference/interfaces/SubscribePropsWithStore.md index d65c61356f..af13d4f9e4 100644 --- a/docs/framework/octane/reference/interfaces/SubscribePropsWithStore.md +++ b/docs/framework/octane/reference/interfaces/SubscribePropsWithStore.md @@ -3,8 +3,6 @@ id: SubscribePropsWithStore title: SubscribePropsWithStore --- -# Interface: SubscribePropsWithStore\ - Defined in: [types.ts:113](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L113) Subscribe to `table.store` (full table state). The selector receives the full @@ -27,14 +25,14 @@ TableState. ```ts children: | SubscribeStaticChild - | (state) => unknown; + | ((state) => unknown); ``` Defined in: [types.ts:126](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L126) *** -### selector() +### selector ```ts selector: (state) => TSelected; diff --git a/docs/framework/octane/reference/interfaces/TableHookContexts.md b/docs/framework/octane/reference/interfaces/TableHookContexts.md index 0b1f228d34..e6a9af8fec 100644 --- a/docs/framework/octane/reference/interfaces/TableHookContexts.md +++ b/docs/framework/octane/reference/interfaces/TableHookContexts.md @@ -3,8 +3,6 @@ id: TableHookContexts title: TableHookContexts --- -# Interface: TableHookContexts\ - Defined in: [types.ts:310](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L310) The object returned by `createTableHookContexts`: three scoped octane @@ -52,7 +50,7 @@ Defined in: [types.ts:314](https://github.com/TanStack/table/blob/main/packages/ *** -### useCellContext() +### useCellContext ```ts useCellContext: () => Cell; @@ -72,7 +70,7 @@ Defined in: [types.ts:321](https://github.com/TanStack/table/blob/main/packages/ *** -### useHeaderContext() +### useHeaderContext ```ts useHeaderContext: () => Header; @@ -92,7 +90,7 @@ Defined in: [types.ts:326](https://github.com/TanStack/table/blob/main/packages/ *** -### useTableContext() +### useTableContext ```ts useTableContext: () => OctaneTable; diff --git a/docs/framework/octane/reference/type-aliases/AppColumnDefBase.md b/docs/framework/octane/reference/type-aliases/AppColumnDefBase.md index de683b8cc9..f3a20a7ec2 100644 --- a/docs/framework/octane/reference/type-aliases/AppColumnDefBase.md +++ b/docs/framework/octane/reference/type-aliases/AppColumnDefBase.md @@ -3,8 +3,6 @@ id: AppColumnDefBase title: AppColumnDefBase --- -# Type Alias: AppColumnDefBase\ - ```ts type AppColumnDefBase = Omit, "cell" | "header" | "footer"> & object; ``` @@ -19,19 +17,19 @@ cell/header/footer contexts. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/octane/reference/type-aliases/AppColumnDefTemplate.md b/docs/framework/octane/reference/type-aliases/AppColumnDefTemplate.md index 8d0755f87c..36f1e886e2 100644 --- a/docs/framework/octane/reference/type-aliases/AppColumnDefTemplate.md +++ b/docs/framework/octane/reference/type-aliases/AppColumnDefTemplate.md @@ -3,10 +3,8 @@ id: AppColumnDefTemplate title: AppColumnDefTemplate --- -# Type Alias: AppColumnDefTemplate\ - ```ts -type AppColumnDefTemplate = string | (props) => any; +type AppColumnDefTemplate = string | ((props) => any); ``` Defined in: [types.ts:375](https://github.com/TanStack/table/blob/main/packages/octane-table/src/types.ts#L375) diff --git a/docs/framework/octane/reference/type-aliases/AppDisplayColumnDef.md b/docs/framework/octane/reference/type-aliases/AppDisplayColumnDef.md index cf1e2b6aef..22b0efe2c7 100644 --- a/docs/framework/octane/reference/type-aliases/AppDisplayColumnDef.md +++ b/docs/framework/octane/reference/type-aliases/AppDisplayColumnDef.md @@ -3,8 +3,6 @@ id: AppDisplayColumnDef title: AppDisplayColumnDef --- -# Type Alias: AppDisplayColumnDef\ - ```ts type AppDisplayColumnDef = Omit, "cell" | "header" | "footer"> & object; ``` @@ -18,19 +16,19 @@ Enhanced display column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/octane/reference/type-aliases/AppGroupColumnDef.md b/docs/framework/octane/reference/type-aliases/AppGroupColumnDef.md index 0a376bb563..33143abf09 100644 --- a/docs/framework/octane/reference/type-aliases/AppGroupColumnDef.md +++ b/docs/framework/octane/reference/type-aliases/AppGroupColumnDef.md @@ -3,8 +3,6 @@ id: AppGroupColumnDef title: AppGroupColumnDef --- -# Type Alias: AppGroupColumnDef\ - ```ts type AppGroupColumnDef = Omit, "cell" | "header" | "footer" | "columns"> & object; ``` @@ -18,25 +16,25 @@ Enhanced group column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### columns? ```ts -optional columns: ColumnDef[]; +optional columns?: ColumnDef[]; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/octane/reference/type-aliases/AppOctaneTable.md b/docs/framework/octane/reference/type-aliases/AppOctaneTable.md index 871b72c4cd..24d02151da 100644 --- a/docs/framework/octane/reference/type-aliases/AppOctaneTable.md +++ b/docs/framework/octane/reference/type-aliases/AppOctaneTable.md @@ -3,8 +3,6 @@ id: AppOctaneTable title: AppOctaneTable --- -# Type Alias: AppOctaneTable\ - ```ts type AppOctaneTable = OctaneTable & CoreNoInfer & object; ``` diff --git a/docs/framework/octane/reference/type-aliases/CreateTableHookOptions.md b/docs/framework/octane/reference/type-aliases/CreateTableHookOptions.md index 92a23c006e..f20b5f5815 100644 --- a/docs/framework/octane/reference/type-aliases/CreateTableHookOptions.md +++ b/docs/framework/octane/reference/type-aliases/CreateTableHookOptions.md @@ -3,8 +3,6 @@ id: CreateTableHookOptions title: CreateTableHookOptions --- -# Type Alias: CreateTableHookOptions\ - ```ts type CreateTableHookOptions = Omit, "columns" | "data" | "store" | "state" | "initialState"> & object; ``` @@ -20,7 +18,7 @@ options. Extends all TableOptions except ### cellComponents? ```ts -optional cellComponents: TCellComponents; +optional cellComponents?: TCellComponents; ``` Cell-level components that need access to the cell instance. @@ -36,7 +34,7 @@ Use `useCellContext()` inside these components. ### cellContext? ```ts -optional cellContext: Context>; +optional cellContext?: Context>; ``` A custom octane context for the cell instance, used inside your @@ -49,7 +47,7 @@ CreateTableHookOptions.tableContext ### headerComponents? ```ts -optional headerComponents: THeaderComponents; +optional headerComponents?: THeaderComponents; ``` Header-level components that need access to the header instance. @@ -65,7 +63,7 @@ children. Use `useHeaderContext()` inside these components. ### headerContext? ```ts -optional headerContext: Context>; +optional headerContext?: Context>; ``` A custom octane context for the header instance, used inside your @@ -78,7 +76,7 @@ CreateTableHookOptions.tableContext ### tableComponents? ```ts -optional tableComponents: TTableComponents; +optional tableComponents?: TTableComponents; ``` Table-level components that need access to the table instance. @@ -94,7 +92,7 @@ Use `useTableContext()` inside these components. ### tableContext? ```ts -optional tableContext: Context>; +optional tableContext?: Context>; ``` A custom octane context for the table instance (read with `useContext` diff --git a/docs/framework/octane/reference/type-aliases/FlexRenderProps.md b/docs/framework/octane/reference/type-aliases/FlexRenderProps.md index 2b803fe9b3..cb38742d92 100644 --- a/docs/framework/octane/reference/type-aliases/FlexRenderProps.md +++ b/docs/framework/octane/reference/type-aliases/FlexRenderProps.md @@ -3,8 +3,6 @@ id: FlexRenderProps title: FlexRenderProps --- -# Type Alias: FlexRenderProps\ - ```ts type FlexRenderProps = | { diff --git a/docs/framework/octane/reference/type-aliases/OctaneTable.md b/docs/framework/octane/reference/type-aliases/OctaneTable.md index 6bef62e73d..608f77bac0 100644 --- a/docs/framework/octane/reference/type-aliases/OctaneTable.md +++ b/docs/framework/octane/reference/type-aliases/OctaneTable.md @@ -3,8 +3,6 @@ id: OctaneTable title: OctaneTable --- -# Type Alias: OctaneTable\ - ```ts type OctaneTable = Omit, "store"> & object; ``` @@ -17,7 +15,7 @@ and the selected `state`. ## Type Declaration -### FlexRender() +### FlexRender ```ts FlexRender: (props) => OctaneNode; @@ -90,7 +88,7 @@ Prefer `table.state` for render reads, subscriptions. `table.store.state` is a current-value snapshot and is easy to misuse in render code. -### Subscribe() +### Subscribe ```ts Subscribe: { @@ -130,7 +128,7 @@ from `source`. ###### children - \| (`state`) => `OctaneNode` + \| ((`state`) => `OctaneNode`) \| [`SubscribeStaticChild`](SubscribeStaticChild.md) ###### selector? @@ -167,7 +165,7 @@ from `source`. ###### children - \| (`state`) => `OctaneNode` + \| ((`state`) => `OctaneNode`) \| [`SubscribeStaticChild`](SubscribeStaticChild.md) ###### selector diff --git a/docs/framework/octane/reference/type-aliases/Renderable.md b/docs/framework/octane/reference/type-aliases/Renderable.md index f8ea7c5a4a..c4b8722090 100644 --- a/docs/framework/octane/reference/type-aliases/Renderable.md +++ b/docs/framework/octane/reference/type-aliases/Renderable.md @@ -3,8 +3,6 @@ id: Renderable title: Renderable --- -# Type Alias: Renderable\ - ```ts type Renderable = | ComponentBody diff --git a/docs/framework/octane/reference/type-aliases/SubscribeProps.md b/docs/framework/octane/reference/type-aliases/SubscribeProps.md index 98a0eb5560..56b1d7a023 100644 --- a/docs/framework/octane/reference/type-aliases/SubscribeProps.md +++ b/docs/framework/octane/reference/type-aliases/SubscribeProps.md @@ -3,8 +3,6 @@ id: SubscribeProps title: SubscribeProps --- -# Type Alias: SubscribeProps\ - ```ts type SubscribeProps = | SubscribePropsWithStore diff --git a/docs/framework/octane/reference/type-aliases/SubscribePropsWithSource.md b/docs/framework/octane/reference/type-aliases/SubscribePropsWithSource.md index 32d3dd25c9..e60b1a438f 100644 --- a/docs/framework/octane/reference/type-aliases/SubscribePropsWithSource.md +++ b/docs/framework/octane/reference/type-aliases/SubscribePropsWithSource.md @@ -3,8 +3,6 @@ id: SubscribePropsWithSource title: SubscribePropsWithSource --- -# Type Alias: SubscribePropsWithSource\ - ```ts type SubscribePropsWithSource = | SubscribePropsWithSourceIdentity diff --git a/docs/framework/octane/reference/type-aliases/SubscribeSource.md b/docs/framework/octane/reference/type-aliases/SubscribeSource.md index 1e3ca4065b..3859a92e3b 100644 --- a/docs/framework/octane/reference/type-aliases/SubscribeSource.md +++ b/docs/framework/octane/reference/type-aliases/SubscribeSource.md @@ -3,8 +3,6 @@ id: SubscribeSource title: SubscribeSource --- -# Type Alias: SubscribeSource\ - ```ts type SubscribeSource = | Atom diff --git a/docs/framework/octane/reference/type-aliases/SubscribeStaticChild.md b/docs/framework/octane/reference/type-aliases/SubscribeStaticChild.md index 8a7ff52664..d9e87ec32a 100644 --- a/docs/framework/octane/reference/type-aliases/SubscribeStaticChild.md +++ b/docs/framework/octane/reference/type-aliases/SubscribeStaticChild.md @@ -3,8 +3,6 @@ id: SubscribeStaticChild title: SubscribeStaticChild --- -# Type Alias: SubscribeStaticChild - ```ts type SubscribeStaticChild = | ElementDescriptor diff --git a/docs/framework/octane/reference/type-aliases/TableComponentType.md b/docs/framework/octane/reference/type-aliases/TableComponentType.md index d9bbe0494d..039dc96740 100644 --- a/docs/framework/octane/reference/type-aliases/TableComponentType.md +++ b/docs/framework/octane/reference/type-aliases/TableComponentType.md @@ -3,8 +3,6 @@ id: TableComponentType title: TableComponentType --- -# Type Alias: TableComponentType()\ - ```ts type TableComponentType = (props) => OctaneNode; ``` diff --git a/docs/framework/octane/reference/variables/Subscribe.md b/docs/framework/octane/reference/variables/Subscribe.md index 69150fb07c..7723fd5dd8 100644 --- a/docs/framework/octane/reference/variables/Subscribe.md +++ b/docs/framework/octane/reference/variables/Subscribe.md @@ -3,8 +3,6 @@ id: Subscribe title: Subscribe --- -# Variable: Subscribe - ```ts const Subscribe: SubscribeComponent; ``` diff --git a/docs/framework/preact/reference/functions/FlexRender-1.md b/docs/framework/preact/reference/functions/FlexRender-1.md index 7f29a39faf..d058472e4a 100644 --- a/docs/framework/preact/reference/functions/FlexRender-1.md +++ b/docs/framework/preact/reference/functions/FlexRender-1.md @@ -3,8 +3,6 @@ id: FlexRender title: FlexRender --- -# Function: FlexRender() - ```ts function FlexRender(props): ComponentChild; ``` diff --git a/docs/framework/preact/reference/functions/Subscribe.md b/docs/framework/preact/reference/functions/Subscribe.md index 83b62e37ab..f7d4c3d732 100644 --- a/docs/framework/preact/reference/functions/Subscribe.md +++ b/docs/framework/preact/reference/functions/Subscribe.md @@ -3,8 +3,6 @@ id: Subscribe title: Subscribe --- -# Function: Subscribe() - ## Call Signature ```ts diff --git a/docs/framework/preact/reference/functions/createTableHook.md b/docs/framework/preact/reference/functions/createTableHook.md index 6ce7298d92..4592e9c5f6 100644 --- a/docs/framework/preact/reference/functions/createTableHook.md +++ b/docs/framework/preact/reference/functions/createTableHook.md @@ -3,8 +3,6 @@ id: createTableHook title: createTableHook --- -# Function: createTableHook() - ```ts function createTableHook(__namedParameters): CreateTableHookResult; ``` diff --git a/docs/framework/preact/reference/functions/createTableHookContexts.md b/docs/framework/preact/reference/functions/createTableHookContexts.md index 3e30a4f6d2..7c98fccb13 100644 --- a/docs/framework/preact/reference/functions/createTableHookContexts.md +++ b/docs/framework/preact/reference/functions/createTableHookContexts.md @@ -3,8 +3,6 @@ id: createTableHookContexts title: createTableHookContexts --- -# Function: createTableHookContexts() - ```ts function createTableHookContexts(): TableHookContexts; ``` diff --git a/docs/framework/preact/reference/functions/flexRender.md b/docs/framework/preact/reference/functions/flexRender.md index 3b1cabadbf..507754be82 100644 --- a/docs/framework/preact/reference/functions/flexRender.md +++ b/docs/framework/preact/reference/functions/flexRender.md @@ -3,8 +3,6 @@ id: flexRender title: flexRender --- -# Function: flexRender() - ```ts function flexRender(Comp, props): ComponentChild | Element; ``` diff --git a/docs/framework/preact/reference/functions/useTable.md b/docs/framework/preact/reference/functions/useTable.md index 0390c6ea64..1db4e6ea8d 100644 --- a/docs/framework/preact/reference/functions/useTable.md +++ b/docs/framework/preact/reference/functions/useTable.md @@ -3,8 +3,6 @@ id: useTable title: useTable --- -# Function: useTable() - ```ts function useTable(tableOptions, selector?): PreactTable; ``` diff --git a/docs/framework/preact/reference/index.md b/docs/framework/preact/reference/index.md index 20829a0a12..3a5eeefeb5 100644 --- a/docs/framework/preact/reference/index.md +++ b/docs/framework/preact/reference/index.md @@ -3,8 +3,6 @@ id: "@tanstack/preact-table" title: "@tanstack/preact-table" --- -# @tanstack/preact-table - ## Interfaces - [AppCellComponent](interfaces/AppCellComponent.md) diff --git a/docs/framework/preact/reference/interfaces/AppCellComponent.md b/docs/framework/preact/reference/interfaces/AppCellComponent.md index 8b586e4d06..a6168059bc 100644 --- a/docs/framework/preact/reference/interfaces/AppCellComponent.md +++ b/docs/framework/preact/reference/interfaces/AppCellComponent.md @@ -3,8 +3,6 @@ id: AppCellComponent title: AppCellComponent --- -# Interface: AppCellComponent()\ - Defined in: [createTableHook.tsx:467](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L467) Component type for AppCell - wraps a cell and provides cell context with optional Subscribe diff --git a/docs/framework/preact/reference/interfaces/AppCellPropsWithSelector.md b/docs/framework/preact/reference/interfaces/AppCellPropsWithSelector.md index 02fd4a1ce7..2a19e19dd2 100644 --- a/docs/framework/preact/reference/interfaces/AppCellPropsWithSelector.md +++ b/docs/framework/preact/reference/interfaces/AppCellPropsWithSelector.md @@ -3,8 +3,6 @@ id: AppCellPropsWithSelector title: AppCellPropsWithSelector --- -# Interface: AppCellPropsWithSelector\ - Defined in: [createTableHook.tsx:412](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L412) Props for AppCell component - with selector @@ -43,7 +41,7 @@ Defined in: [createTableHook.tsx:419](https://github.com/TanStack/table/blob/mai *** -### children() +### children ```ts children: (cell, state) => ComponentChildren; @@ -67,7 +65,7 @@ Defined in: [createTableHook.tsx:420](https://github.com/TanStack/table/blob/mai *** -### selector() +### selector ```ts selector: (state) => TSelected; diff --git a/docs/framework/preact/reference/interfaces/AppCellPropsWithoutSelector.md b/docs/framework/preact/reference/interfaces/AppCellPropsWithoutSelector.md index 7ec5ed2022..d42346787d 100644 --- a/docs/framework/preact/reference/interfaces/AppCellPropsWithoutSelector.md +++ b/docs/framework/preact/reference/interfaces/AppCellPropsWithoutSelector.md @@ -3,8 +3,6 @@ id: AppCellPropsWithoutSelector title: AppCellPropsWithoutSelector --- -# Interface: AppCellPropsWithoutSelector\ - Defined in: [createTableHook.tsx:395](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L395) Props for AppCell component - without selector @@ -39,7 +37,7 @@ Defined in: [createTableHook.tsx:401](https://github.com/TanStack/table/blob/mai *** -### children() +### children ```ts children: (cell) => ComponentChildren; @@ -62,7 +60,7 @@ Defined in: [createTableHook.tsx:402](https://github.com/TanStack/table/blob/mai ### selector? ```ts -optional selector: undefined; +optional selector?: undefined; ``` Defined in: [createTableHook.tsx:406](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L406) diff --git a/docs/framework/preact/reference/interfaces/AppHeaderComponent.md b/docs/framework/preact/reference/interfaces/AppHeaderComponent.md index 8ccca938f5..9a9e048ff1 100644 --- a/docs/framework/preact/reference/interfaces/AppHeaderComponent.md +++ b/docs/framework/preact/reference/interfaces/AppHeaderComponent.md @@ -3,8 +3,6 @@ id: AppHeaderComponent title: AppHeaderComponent --- -# Interface: AppHeaderComponent()\ - Defined in: [createTableHook.tsx:494](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L494) Component type for AppHeader/AppFooter - wraps a header and provides header context with optional Subscribe diff --git a/docs/framework/preact/reference/interfaces/AppHeaderPropsWithSelector.md b/docs/framework/preact/reference/interfaces/AppHeaderPropsWithSelector.md index a99e55e509..e09a491cfd 100644 --- a/docs/framework/preact/reference/interfaces/AppHeaderPropsWithSelector.md +++ b/docs/framework/preact/reference/interfaces/AppHeaderPropsWithSelector.md @@ -3,8 +3,6 @@ id: AppHeaderPropsWithSelector title: AppHeaderPropsWithSelector --- -# Interface: AppHeaderPropsWithSelector\ - Defined in: [createTableHook.tsx:448](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L448) Props for AppHeader/AppFooter component - with selector @@ -33,7 +31,7 @@ Props for AppHeader/AppFooter component - with selector ## Properties -### children() +### children ```ts children: (header, state) => ComponentChildren; @@ -67,7 +65,7 @@ Defined in: [createTableHook.tsx:455](https://github.com/TanStack/table/blob/mai *** -### selector() +### selector ```ts selector: (state) => TSelected; diff --git a/docs/framework/preact/reference/interfaces/AppHeaderPropsWithoutSelector.md b/docs/framework/preact/reference/interfaces/AppHeaderPropsWithoutSelector.md index 20db0cfc16..dc1c2f83d8 100644 --- a/docs/framework/preact/reference/interfaces/AppHeaderPropsWithoutSelector.md +++ b/docs/framework/preact/reference/interfaces/AppHeaderPropsWithoutSelector.md @@ -3,8 +3,6 @@ id: AppHeaderPropsWithoutSelector title: AppHeaderPropsWithoutSelector --- -# Interface: AppHeaderPropsWithoutSelector\ - Defined in: [createTableHook.tsx:431](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L431) Props for AppHeader/AppFooter component - without selector @@ -29,7 +27,7 @@ Props for AppHeader/AppFooter component - without selector ## Properties -### children() +### children ```ts children: (header) => ComponentChildren; @@ -62,7 +60,7 @@ Defined in: [createTableHook.tsx:437](https://github.com/TanStack/table/blob/mai ### selector? ```ts -optional selector: undefined; +optional selector?: undefined; ``` Defined in: [createTableHook.tsx:442](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L442) diff --git a/docs/framework/preact/reference/interfaces/AppTableComponent.md b/docs/framework/preact/reference/interfaces/AppTableComponent.md index affaa39761..d7db05085f 100644 --- a/docs/framework/preact/reference/interfaces/AppTableComponent.md +++ b/docs/framework/preact/reference/interfaces/AppTableComponent.md @@ -3,8 +3,6 @@ id: AppTableComponent title: AppTableComponent --- -# Interface: AppTableComponent()\ - Defined in: [createTableHook.tsx:521](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L521) Component type for AppTable - root wrapper with optional Subscribe diff --git a/docs/framework/preact/reference/interfaces/AppTablePropsWithSelector.md b/docs/framework/preact/reference/interfaces/AppTablePropsWithSelector.md index 81e8265a87..61fb03b3c5 100644 --- a/docs/framework/preact/reference/interfaces/AppTablePropsWithSelector.md +++ b/docs/framework/preact/reference/interfaces/AppTablePropsWithSelector.md @@ -3,8 +3,6 @@ id: AppTablePropsWithSelector title: AppTablePropsWithSelector --- -# Interface: AppTablePropsWithSelector\ - Defined in: [createTableHook.tsx:384](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L384) Props for AppTable component - with selector @@ -21,7 +19,7 @@ Props for AppTable component - with selector ## Properties -### children() +### children ```ts children: (state) => ComponentChildren; @@ -41,7 +39,7 @@ Defined in: [createTableHook.tsx:388](https://github.com/TanStack/table/blob/mai *** -### selector() +### selector ```ts selector: (state) => TSelected; diff --git a/docs/framework/preact/reference/interfaces/AppTablePropsWithoutSelector.md b/docs/framework/preact/reference/interfaces/AppTablePropsWithoutSelector.md index 07d487c315..e567b143fd 100644 --- a/docs/framework/preact/reference/interfaces/AppTablePropsWithoutSelector.md +++ b/docs/framework/preact/reference/interfaces/AppTablePropsWithoutSelector.md @@ -3,8 +3,6 @@ id: AppTablePropsWithoutSelector title: AppTablePropsWithoutSelector --- -# Interface: AppTablePropsWithoutSelector - Defined in: [createTableHook.tsx:376](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L376) Props for AppTable component - without selector @@ -24,7 +22,7 @@ Defined in: [createTableHook.tsx:377](https://github.com/TanStack/table/blob/mai ### selector? ```ts -optional selector: undefined; +optional selector?: undefined; ``` Defined in: [createTableHook.tsx:378](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L378) diff --git a/docs/framework/preact/reference/interfaces/CreateTableHookResult.md b/docs/framework/preact/reference/interfaces/CreateTableHookResult.md index 05c4695293..929b89b863 100644 --- a/docs/framework/preact/reference/interfaces/CreateTableHookResult.md +++ b/docs/framework/preact/reference/interfaces/CreateTableHookResult.md @@ -3,8 +3,6 @@ id: CreateTableHookResult title: CreateTableHookResult --- -# Interface: CreateTableHookResult\ - Defined in: [createTableHook.tsx:295](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L295) ## Type Parameters @@ -39,7 +37,7 @@ The features object that was passed to `createTableHook`. *** -### createAppColumnHelper() +### createAppColumnHelper ```ts createAppColumnHelper: () => AppColumnHelper; @@ -62,7 +60,7 @@ the cell/header/footer render props expose the bound components. *** -### useAppTable() +### useAppTable ```ts useAppTable: (tableOptions, selector?) => AppPreactTable; @@ -99,7 +97,7 @@ Creates a table with the `App*` wrapper components and registered *** -### useCellContext() +### useCellContext ```ts useCellContext: () => Cell_Core & ExtractFeatureMapTypes & TCellComponents & object; @@ -122,7 +120,7 @@ Reads the cell provided by the nearest ``, extended with your *** -### useHeaderContext() +### useHeaderContext ```ts useHeaderContext: () => Header_Core & ExtractFeatureMapTypes & THeaderComponents & object; @@ -146,7 +144,7 @@ context-bound `FlexRender`. *** -### useTableContext() +### useTableContext ```ts useTableContext: () => AppPreactTable; diff --git a/docs/framework/preact/reference/interfaces/TableHookContexts.md b/docs/framework/preact/reference/interfaces/TableHookContexts.md index 9032eb632c..3b35ba975f 100644 --- a/docs/framework/preact/reference/interfaces/TableHookContexts.md +++ b/docs/framework/preact/reference/interfaces/TableHookContexts.md @@ -3,8 +3,6 @@ id: TableHookContexts title: TableHookContexts --- -# Interface: TableHookContexts\ - Defined in: [createTableHookContexts.tsx:18](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHookContexts.tsx#L18) The object returned by [createTableHookContexts](../functions/createTableHookContexts.md): three scoped Preact @@ -52,7 +50,7 @@ Defined in: [createTableHookContexts.tsx:22](https://github.com/TanStack/table/b *** -### useCellContext() +### useCellContext ```ts useCellContext: () => Cell; @@ -72,7 +70,7 @@ Defined in: [createTableHookContexts.tsx:29](https://github.com/TanStack/table/b *** -### useHeaderContext() +### useHeaderContext ```ts useHeaderContext: () => Header; @@ -92,7 +90,7 @@ Defined in: [createTableHookContexts.tsx:34](https://github.com/TanStack/table/b *** -### useTableContext() +### useTableContext ```ts useTableContext: () => PreactTable; diff --git a/docs/framework/preact/reference/type-aliases/AppCellContext.md b/docs/framework/preact/reference/type-aliases/AppCellContext.md index 1223d8dbb7..963ca998e0 100644 --- a/docs/framework/preact/reference/type-aliases/AppCellContext.md +++ b/docs/framework/preact/reference/type-aliases/AppCellContext.md @@ -3,8 +3,6 @@ id: AppCellContext title: AppCellContext --- -# Type Alias: AppCellContext\ - ```ts type AppCellContext = object; ``` @@ -44,7 +42,7 @@ Defined in: [createTableHook.tsx:51](https://github.com/TanStack/table/blob/main #### Type Declaration -##### FlexRender() +##### FlexRender ```ts FlexRender: () => ComponentChildren; diff --git a/docs/framework/preact/reference/type-aliases/AppColumnDefBase.md b/docs/framework/preact/reference/type-aliases/AppColumnDefBase.md index ffc49ba135..40653d9d59 100644 --- a/docs/framework/preact/reference/type-aliases/AppColumnDefBase.md +++ b/docs/framework/preact/reference/type-aliases/AppColumnDefBase.md @@ -3,8 +3,6 @@ id: AppColumnDefBase title: AppColumnDefBase --- -# Type Alias: AppColumnDefBase\ - ```ts type AppColumnDefBase = Omit, "cell" | "header" | "footer"> & object; ``` @@ -18,19 +16,19 @@ Enhanced column definition base with pre-bound components in cell/header/footer ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/preact/reference/type-aliases/AppColumnDefTemplate.md b/docs/framework/preact/reference/type-aliases/AppColumnDefTemplate.md index b4609deb69..10adc10102 100644 --- a/docs/framework/preact/reference/type-aliases/AppColumnDefTemplate.md +++ b/docs/framework/preact/reference/type-aliases/AppColumnDefTemplate.md @@ -3,10 +3,8 @@ id: AppColumnDefTemplate title: AppColumnDefTemplate --- -# Type Alias: AppColumnDefTemplate\ - ```ts -type AppColumnDefTemplate = string | (props) => any; +type AppColumnDefTemplate = string | ((props) => any); ``` Defined in: [createTableHook.tsx:83](https://github.com/TanStack/table/blob/main/packages/preact-table/src/createTableHook.tsx#L83) diff --git a/docs/framework/preact/reference/type-aliases/AppColumnHelper.md b/docs/framework/preact/reference/type-aliases/AppColumnHelper.md index edd780a129..c58ac8fcb5 100644 --- a/docs/framework/preact/reference/type-aliases/AppColumnHelper.md +++ b/docs/framework/preact/reference/type-aliases/AppColumnHelper.md @@ -3,8 +3,6 @@ id: AppColumnHelper title: AppColumnHelper --- -# Type Alias: AppColumnHelper\ - ```ts type AppColumnHelper = object; ``` @@ -34,7 +32,7 @@ This enables TypeScript to know about the registered components when defining co ## Properties -### accessor() +### accessor ```ts accessor: (accessor, column) => TAccessor extends AccessorFn ? AccessorFnColumnDef : AccessorKeyColumnDef; @@ -71,7 +69,7 @@ The cell, header, and footer contexts include pre-bound components. *** -### columns() +### columns ```ts columns: (columns) => ColumnDef[] & [...TColumns]; @@ -99,7 +97,7 @@ Wraps an array of column definitions to preserve each column's individual TValue *** -### display() +### display ```ts display: (column) => DisplayColumnDef; @@ -122,7 +120,7 @@ The cell, header, and footer contexts include pre-bound components. *** -### group() +### group ```ts group: (column) => GroupColumnDef; diff --git a/docs/framework/preact/reference/type-aliases/AppDisplayColumnDef.md b/docs/framework/preact/reference/type-aliases/AppDisplayColumnDef.md index 21be92280e..1c8ba635c7 100644 --- a/docs/framework/preact/reference/type-aliases/AppDisplayColumnDef.md +++ b/docs/framework/preact/reference/type-aliases/AppDisplayColumnDef.md @@ -3,8 +3,6 @@ id: AppDisplayColumnDef title: AppDisplayColumnDef --- -# Type Alias: AppDisplayColumnDef\ - ```ts type AppDisplayColumnDef = Omit, "cell" | "header" | "footer"> & object; ``` @@ -18,19 +16,19 @@ Enhanced display column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/preact/reference/type-aliases/AppGroupColumnDef.md b/docs/framework/preact/reference/type-aliases/AppGroupColumnDef.md index fd14626563..17def598dd 100644 --- a/docs/framework/preact/reference/type-aliases/AppGroupColumnDef.md +++ b/docs/framework/preact/reference/type-aliases/AppGroupColumnDef.md @@ -3,8 +3,6 @@ id: AppGroupColumnDef title: AppGroupColumnDef --- -# Type Alias: AppGroupColumnDef\ - ```ts type AppGroupColumnDef = Omit, "cell" | "header" | "footer" | "columns"> & object; ``` @@ -18,25 +16,25 @@ Enhanced group column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### columns? ```ts -optional columns: ReadonlyArray>; +optional columns?: ReadonlyArray>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/preact/reference/type-aliases/AppHeaderContext.md b/docs/framework/preact/reference/type-aliases/AppHeaderContext.md index dffcc70242..767437236b 100644 --- a/docs/framework/preact/reference/type-aliases/AppHeaderContext.md +++ b/docs/framework/preact/reference/type-aliases/AppHeaderContext.md @@ -3,8 +3,6 @@ id: AppHeaderContext title: AppHeaderContext --- -# Type Alias: AppHeaderContext\ - ```ts type AppHeaderContext = object; ``` @@ -54,7 +52,7 @@ Defined in: [createTableHook.tsx:71](https://github.com/TanStack/table/blob/main #### Type Declaration -##### FlexRender() +##### FlexRender ```ts FlexRender: () => ComponentChildren; diff --git a/docs/framework/preact/reference/type-aliases/AppPreactTable.md b/docs/framework/preact/reference/type-aliases/AppPreactTable.md index a6ee0fd873..498e225cd1 100644 --- a/docs/framework/preact/reference/type-aliases/AppPreactTable.md +++ b/docs/framework/preact/reference/type-aliases/AppPreactTable.md @@ -3,8 +3,6 @@ id: AppPreactTable title: AppPreactTable --- -# Type Alias: AppPreactTable\ - ```ts type AppPreactTable = PreactTable & NoInfer & object; ``` diff --git a/docs/framework/preact/reference/type-aliases/CreateTableHookOptions.md b/docs/framework/preact/reference/type-aliases/CreateTableHookOptions.md index d7374f61b7..ef437d6a4b 100644 --- a/docs/framework/preact/reference/type-aliases/CreateTableHookOptions.md +++ b/docs/framework/preact/reference/type-aliases/CreateTableHookOptions.md @@ -3,8 +3,6 @@ id: CreateTableHookOptions title: CreateTableHookOptions --- -# Type Alias: CreateTableHookOptions\ - ```ts type CreateTableHookOptions = Omit, "columns" | "data" | "store" | "state" | "initialState"> & object; ``` @@ -19,7 +17,7 @@ Extends all TableOptions except 'columns' | 'data' | 'store' | 'state' | 'initia ### cellComponents? ```ts -optional cellComponents: TCellComponents; +optional cellComponents?: TCellComponents; ``` Cell-level components that need access to the cell instance. @@ -35,7 +33,7 @@ Use `useCellContext()` inside these components. ### cellContext? ```ts -optional cellContext: Context>; +optional cellContext?: Context>; ``` A custom Preact context for the cell instance, used inside your `cellComponents`. @@ -47,7 +45,7 @@ CreateTableHookOptions.tableContext ### headerComponents? ```ts -optional headerComponents: THeaderComponents; +optional headerComponents?: THeaderComponents; ``` Header-level components that need access to the header instance. @@ -63,7 +61,7 @@ Use `useHeaderContext()` inside these components. ### headerContext? ```ts -optional headerContext: Context>; +optional headerContext?: Context>; ``` A custom Preact context for the header instance, used inside your @@ -76,7 +74,7 @@ CreateTableHookOptions.tableContext ### tableComponents? ```ts -optional tableComponents: TTableComponents; +optional tableComponents?: TTableComponents; ``` Table-level components that need access to the table instance. @@ -92,7 +90,7 @@ Use `useTableContext()` inside these components. ### tableContext? ```ts -optional tableContext: Context>; +optional tableContext?: Context>; ``` A custom Preact context for the table instance (read with `useContext` inside diff --git a/docs/framework/preact/reference/type-aliases/FlexRenderProps.md b/docs/framework/preact/reference/type-aliases/FlexRenderProps.md index f3e113d684..4b54bd059c 100644 --- a/docs/framework/preact/reference/type-aliases/FlexRenderProps.md +++ b/docs/framework/preact/reference/type-aliases/FlexRenderProps.md @@ -3,8 +3,6 @@ id: FlexRenderProps title: FlexRenderProps --- -# Type Alias: FlexRenderProps\ - ```ts type FlexRenderProps = | { diff --git a/docs/framework/preact/reference/type-aliases/PreactTable.md b/docs/framework/preact/reference/type-aliases/PreactTable.md index af6038701b..4b34b255b2 100644 --- a/docs/framework/preact/reference/type-aliases/PreactTable.md +++ b/docs/framework/preact/reference/type-aliases/PreactTable.md @@ -3,8 +3,6 @@ id: PreactTable title: PreactTable --- -# Type Alias: PreactTable\ - ```ts type PreactTable = Omit, "store"> & object; ``` @@ -13,7 +11,7 @@ Defined in: [useTable.ts:27](https://github.com/TanStack/table/blob/main/package ## Type Declaration -### FlexRender() +### FlexRender ```ts FlexRender: (props) => ComponentChildren; @@ -62,7 +60,7 @@ Prefer `table.state` for render reads, subscriptions. `table.store.state` is a current-value snapshot and is easy to misuse in render code. -### Subscribe() +### Subscribe ```ts Subscribe: { @@ -93,7 +91,7 @@ Source without `selector` is separate so children infer `TSourceValue` (identity ###### children -(`state`) => `ComponentChildren` \| `ComponentChildren` +((`state`) => `ComponentChildren`) \| `ComponentChildren` ###### selector? @@ -129,7 +127,7 @@ Source without `selector` is separate so children infer `TSourceValue` (identity ###### children -(`state`) => `ComponentChildren` \| `ComponentChildren` +((`state`) => `ComponentChildren`) \| `ComponentChildren` ###### selector diff --git a/docs/framework/preact/reference/type-aliases/Renderable.md b/docs/framework/preact/reference/type-aliases/Renderable.md index e9f9ef4d66..6f5d89eae6 100644 --- a/docs/framework/preact/reference/type-aliases/Renderable.md +++ b/docs/framework/preact/reference/type-aliases/Renderable.md @@ -3,8 +3,6 @@ id: Renderable title: Renderable --- -# Type Alias: Renderable\ - ```ts type Renderable = ComponentChild | ComponentType; ``` diff --git a/docs/framework/preact/reference/type-aliases/SubscribeProps.md b/docs/framework/preact/reference/type-aliases/SubscribeProps.md index 791e1d233e..af37f7b36b 100644 --- a/docs/framework/preact/reference/type-aliases/SubscribeProps.md +++ b/docs/framework/preact/reference/type-aliases/SubscribeProps.md @@ -3,8 +3,6 @@ id: SubscribeProps title: SubscribeProps --- -# Type Alias: SubscribeProps\ - ```ts type SubscribeProps = | SubscribePropsWithStore diff --git a/docs/framework/preact/reference/type-aliases/SubscribePropsWithSource.md b/docs/framework/preact/reference/type-aliases/SubscribePropsWithSource.md index 0fcb05dc69..29e2e518f8 100644 --- a/docs/framework/preact/reference/type-aliases/SubscribePropsWithSource.md +++ b/docs/framework/preact/reference/type-aliases/SubscribePropsWithSource.md @@ -3,8 +3,6 @@ id: SubscribePropsWithSource title: SubscribePropsWithSource --- -# Type Alias: SubscribePropsWithSource\ - ```ts type SubscribePropsWithSource = | SubscribePropsWithSourceIdentity diff --git a/docs/framework/preact/reference/type-aliases/SubscribePropsWithSourceIdentity.md b/docs/framework/preact/reference/type-aliases/SubscribePropsWithSourceIdentity.md index 07bf8b0609..9ca75c3637 100644 --- a/docs/framework/preact/reference/type-aliases/SubscribePropsWithSourceIdentity.md +++ b/docs/framework/preact/reference/type-aliases/SubscribePropsWithSourceIdentity.md @@ -3,8 +3,6 @@ id: SubscribePropsWithSourceIdentity title: SubscribePropsWithSourceIdentity --- -# Type Alias: SubscribePropsWithSourceIdentity\ - ```ts type SubscribePropsWithSourceIdentity = object; ``` @@ -26,7 +24,7 @@ selector — children receive `TSourceValue`. ### children ```ts -children: (state) => ComponentChildren | ComponentChildren; +children: ((state) => ComponentChildren) | ComponentChildren; ``` Defined in: [Subscribe.ts:42](https://github.com/TanStack/table/blob/main/packages/preact-table/src/Subscribe.ts#L42) @@ -36,7 +34,7 @@ Defined in: [Subscribe.ts:42](https://github.com/TanStack/table/blob/main/packag ### selector? ```ts -optional selector: undefined; +optional selector?: undefined; ``` Defined in: [Subscribe.ts:41](https://github.com/TanStack/table/blob/main/packages/preact-table/src/Subscribe.ts#L41) diff --git a/docs/framework/preact/reference/type-aliases/SubscribePropsWithSourceWithSelector.md b/docs/framework/preact/reference/type-aliases/SubscribePropsWithSourceWithSelector.md index 3baec82ef1..3dc154d6ba 100644 --- a/docs/framework/preact/reference/type-aliases/SubscribePropsWithSourceWithSelector.md +++ b/docs/framework/preact/reference/type-aliases/SubscribePropsWithSourceWithSelector.md @@ -3,8 +3,6 @@ id: SubscribePropsWithSourceWithSelector title: SubscribePropsWithSourceWithSelector --- -# Type Alias: SubscribePropsWithSourceWithSelector\ - ```ts type SubscribePropsWithSourceWithSelector = object; ``` @@ -28,14 +26,14 @@ Subscribe to a projected value from a source (atom or store). ### children ```ts -children: (state) => ComponentChildren | ComponentChildren; +children: ((state) => ComponentChildren) | ComponentChildren; ``` Defined in: [Subscribe.ts:51](https://github.com/TanStack/table/blob/main/packages/preact-table/src/Subscribe.ts#L51) *** -### selector() +### selector ```ts selector: (state) => TSelected; diff --git a/docs/framework/preact/reference/type-aliases/SubscribePropsWithStore.md b/docs/framework/preact/reference/type-aliases/SubscribePropsWithStore.md index eb4d2e1d0d..b2ff980612 100644 --- a/docs/framework/preact/reference/type-aliases/SubscribePropsWithStore.md +++ b/docs/framework/preact/reference/type-aliases/SubscribePropsWithStore.md @@ -3,8 +3,6 @@ id: SubscribePropsWithStore title: SubscribePropsWithStore --- -# Type Alias: SubscribePropsWithStore\ - ```ts type SubscribePropsWithStore = object; ``` @@ -29,14 +27,14 @@ TableState. ### children ```ts -children: (state) => ComponentChildren | ComponentChildren; +children: ((state) => ComponentChildren) | ComponentChildren; ``` Defined in: [Subscribe.ts:31](https://github.com/TanStack/table/blob/main/packages/preact-table/src/Subscribe.ts#L31) *** -### selector() +### selector ```ts selector: (state) => TSelected; diff --git a/docs/framework/preact/reference/type-aliases/SubscribeSource.md b/docs/framework/preact/reference/type-aliases/SubscribeSource.md index 1d4fe04102..7afcd65a0c 100644 --- a/docs/framework/preact/reference/type-aliases/SubscribeSource.md +++ b/docs/framework/preact/reference/type-aliases/SubscribeSource.md @@ -3,8 +3,6 @@ id: SubscribeSource title: SubscribeSource --- -# Type Alias: SubscribeSource\ - ```ts type SubscribeSource = | Atom diff --git a/docs/framework/react/guide/react-compiler.md b/docs/framework/react/guide/react-compiler.md index 3542069609..41179e5aec 100644 --- a/docs/framework/react/guide/react-compiler.md +++ b/docs/framework/react/guide/react-compiler.md @@ -192,6 +192,8 @@ function TableBody({ table }) { The selector must include every state slice that can change the result of `table.getRowModel()` for this table. That may include filtering, sorting, grouping, expansion, or pagination, depending on the features in use. +State is not the only input to `table.getRowModel()`. Replacing `data` from outside the table, such as a `setState` call, a query refetch, or a WebSocket message, does not change any state slice, so a `Subscribe` selector cannot detect it. When the body reads the table from `useTableContext()` inside ``, `AppTable` provides a new table value whenever the owner of `useAppTable` renders with new options, so the body updates without extra wiring. When you pass `table` as a prop through components that the compiler may skip, also pass `data` (or the rows you render) as a prop so the body renders again when the data changes. + Use `table.Subscribe` when `table` is the React-facing value returned by `useTable`. In a cell or header render context, `table` is the core Table instead. Import the standalone `Subscribe` component and pass `table.store` or one of the values in `table.atoms` as its source. Do not add a subscription to every cell by default. Add one when a nested component reads state that is not represented by its props, or when profiling shows that moving an update lower in the tree would help. diff --git a/docs/framework/react/reference/index.md b/docs/framework/react/reference/index.md index 1902741d6c..952ac670dc 100644 --- a/docs/framework/react/reference/index.md +++ b/docs/framework/react/reference/index.md @@ -3,8 +3,6 @@ id: "@tanstack/react-table" title: "@tanstack/react-table" --- -# @tanstack/react-table - ## Modules - [index](index/index.md) diff --git a/docs/framework/react/reference/index/functions/FlexRender-1.md b/docs/framework/react/reference/index/functions/FlexRender-1.md index c6fe671fb8..f0d0f1409f 100644 --- a/docs/framework/react/reference/index/functions/FlexRender-1.md +++ b/docs/framework/react/reference/index/functions/FlexRender-1.md @@ -3,8 +3,6 @@ id: FlexRender title: FlexRender --- -# Function: FlexRender() - ```ts function FlexRender(props): | string @@ -18,7 +16,7 @@ function FlexRender(props): | undefined; ``` -Defined in: [react-table/src/FlexRender.tsx:97](https://github.com/TanStack/table/blob/main/packages/react-table/src/FlexRender.tsx#L97) +Defined in: [src/FlexRender.tsx:97](https://github.com/TanStack/table/blob/main/packages/react-table/src/FlexRender.tsx#L97) Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup. Only one prop (`cell`, `header`, or `footer`) may be passed. diff --git a/docs/framework/react/reference/index/functions/Subscribe.md b/docs/framework/react/reference/index/functions/Subscribe.md index ddb552fbae..281761bba7 100644 --- a/docs/framework/react/reference/index/functions/Subscribe.md +++ b/docs/framework/react/reference/index/functions/Subscribe.md @@ -3,15 +3,13 @@ id: Subscribe title: Subscribe --- -# Function: Subscribe() - ## Call Signature ```ts function Subscribe(props): ReactNode | Promise; ``` -Defined in: [react-table/src/Subscribe.ts:122](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L122) +Defined in: [src/Subscribe.ts:122](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L122) A React component that allows you to subscribe to the table state. @@ -79,7 +77,7 @@ contextual typing works. This standalone component uses a union `props` type. function Subscribe(props): ReactNode | Promise; ``` -Defined in: [react-table/src/Subscribe.ts:125](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L125) +Defined in: [src/Subscribe.ts:125](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L125) A React component that allows you to subscribe to the table state. @@ -151,7 +149,7 @@ contextual typing works. This standalone component uses a union `props` type. function Subscribe(props): ReactNode | Promise; ``` -Defined in: [react-table/src/Subscribe.ts:128](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L128) +Defined in: [src/Subscribe.ts:128](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L128) A React component that allows you to subscribe to the table state. diff --git a/docs/framework/react/reference/index/functions/createTableHook.md b/docs/framework/react/reference/index/functions/createTableHook.md index 41a8334536..73febc81e3 100644 --- a/docs/framework/react/reference/index/functions/createTableHook.md +++ b/docs/framework/react/reference/index/functions/createTableHook.md @@ -3,13 +3,11 @@ id: createTableHook title: createTableHook --- -# Function: createTableHook() - ```ts function createTableHook(__namedParameters): CreateTableHookResult; ``` -Defined in: [react-table/src/createTableHook.tsx:692](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L692) +Defined in: [src/createTableHook.tsx:692](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L692) Creates a custom table hook with pre-bound components for composition. diff --git a/docs/framework/react/reference/index/functions/createTableHookContexts.md b/docs/framework/react/reference/index/functions/createTableHookContexts.md index 5d3a9a5b76..a493a0830e 100644 --- a/docs/framework/react/reference/index/functions/createTableHookContexts.md +++ b/docs/framework/react/reference/index/functions/createTableHookContexts.md @@ -3,13 +3,11 @@ id: createTableHookContexts title: createTableHookContexts --- -# Function: createTableHookContexts() - ```ts function createTableHookContexts(): TableHookContexts; ``` -Defined in: [react-table/src/createTableHookContexts.tsx:83](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L83) +Defined in: [src/createTableHookContexts.tsx:83](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L83) Creates a fresh, scoped set of table/cell/header contexts (plus matching context hooks) that you can pass into [createTableHook](createTableHook.md). This mirrors diff --git a/docs/framework/react/reference/index/functions/flexRender.md b/docs/framework/react/reference/index/functions/flexRender.md index 0bed93edc2..45059aa595 100644 --- a/docs/framework/react/reference/index/functions/flexRender.md +++ b/docs/framework/react/reference/index/functions/flexRender.md @@ -3,13 +3,11 @@ id: flexRender title: flexRender --- -# Function: flexRender() - ```ts function flexRender(Comp, props): ReactNode | Element; ``` -Defined in: [react-table/src/FlexRender.tsx:45](https://github.com/TanStack/table/blob/main/packages/react-table/src/FlexRender.tsx#L45) +Defined in: [src/FlexRender.tsx:45](https://github.com/TanStack/table/blob/main/packages/react-table/src/FlexRender.tsx#L45) If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`. diff --git a/docs/framework/react/reference/index/functions/useTable.md b/docs/framework/react/reference/index/functions/useTable.md index f2aec581a6..9459f63cd9 100644 --- a/docs/framework/react/reference/index/functions/useTable.md +++ b/docs/framework/react/reference/index/functions/useTable.md @@ -3,13 +3,11 @@ id: useTable title: useTable --- -# Function: useTable() - ```ts function useTable(tableOptions, selector?): ReactTable; ``` -Defined in: [react-table/src/useTable.ts:149](https://github.com/TanStack/table/blob/main/packages/react-table/src/useTable.ts#L149) +Defined in: [src/useTable.ts:149](https://github.com/TanStack/table/blob/main/packages/react-table/src/useTable.ts#L149) Creates a React table instance backed by TanStack Store atoms. diff --git a/docs/framework/react/reference/index/index.md b/docs/framework/react/reference/index/index.md index f531ab0e79..0c66aed23d 100644 --- a/docs/framework/react/reference/index/index.md +++ b/docs/framework/react/reference/index/index.md @@ -3,8 +3,6 @@ id: index title: index --- -# index - ## Interfaces - [AppCellComponent](interfaces/AppCellComponent.md) diff --git a/docs/framework/react/reference/index/interfaces/AppCellComponent.md b/docs/framework/react/reference/index/interfaces/AppCellComponent.md index 5870eb6a32..5f58cce6ef 100644 --- a/docs/framework/react/reference/index/interfaces/AppCellComponent.md +++ b/docs/framework/react/reference/index/interfaces/AppCellComponent.md @@ -3,9 +3,7 @@ id: AppCellComponent title: AppCellComponent --- -# Interface: AppCellComponent()\ - -Defined in: [react-table/src/createTableHook.tsx:470](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L470) +Defined in: [src/createTableHook.tsx:470](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L470) Component type for AppCell - wraps a cell and provides cell context with optional Subscribe @@ -29,7 +27,7 @@ Component type for AppCell - wraps a cell and provides cell context with optiona AppCellComponent(props): ReactNode; ``` -Defined in: [react-table/src/createTableHook.tsx:475](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L475) +Defined in: [src/createTableHook.tsx:475](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L475) Component type for AppCell - wraps a cell and provides cell context with optional Subscribe @@ -55,7 +53,7 @@ Component type for AppCell - wraps a cell and provides cell context with optiona AppCellComponent(props): ReactNode; ``` -Defined in: [react-table/src/createTableHook.tsx:483](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L483) +Defined in: [src/createTableHook.tsx:483](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L483) Component type for AppCell - wraps a cell and provides cell context with optional Subscribe diff --git a/docs/framework/react/reference/index/interfaces/AppCellPropsWithSelector.md b/docs/framework/react/reference/index/interfaces/AppCellPropsWithSelector.md index 9bd0c5c833..c1ccaa2a3e 100644 --- a/docs/framework/react/reference/index/interfaces/AppCellPropsWithSelector.md +++ b/docs/framework/react/reference/index/interfaces/AppCellPropsWithSelector.md @@ -3,9 +3,7 @@ id: AppCellPropsWithSelector title: AppCellPropsWithSelector --- -# Interface: AppCellPropsWithSelector\ - -Defined in: [react-table/src/createTableHook.tsx:415](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L415) +Defined in: [src/createTableHook.tsx:415](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L415) Props for AppCell component - with selector @@ -39,17 +37,17 @@ Props for AppCell component - with selector cell: Cell; ``` -Defined in: [react-table/src/createTableHook.tsx:422](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L422) +Defined in: [src/createTableHook.tsx:422](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L422) *** -### children() +### children ```ts children: (cell, state) => ReactNode; ``` -Defined in: [react-table/src/createTableHook.tsx:423](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L423) +Defined in: [src/createTableHook.tsx:423](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L423) #### Parameters @@ -67,13 +65,13 @@ Defined in: [react-table/src/createTableHook.tsx:423](https://github.com/TanStac *** -### selector() +### selector ```ts selector: (state) => TSelected; ``` -Defined in: [react-table/src/createTableHook.tsx:428](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L428) +Defined in: [src/createTableHook.tsx:428](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L428) #### Parameters diff --git a/docs/framework/react/reference/index/interfaces/AppCellPropsWithoutSelector.md b/docs/framework/react/reference/index/interfaces/AppCellPropsWithoutSelector.md index 3035188c88..dc7825b3ec 100644 --- a/docs/framework/react/reference/index/interfaces/AppCellPropsWithoutSelector.md +++ b/docs/framework/react/reference/index/interfaces/AppCellPropsWithoutSelector.md @@ -3,9 +3,7 @@ id: AppCellPropsWithoutSelector title: AppCellPropsWithoutSelector --- -# Interface: AppCellPropsWithoutSelector\ - -Defined in: [react-table/src/createTableHook.tsx:398](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L398) +Defined in: [src/createTableHook.tsx:398](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L398) Props for AppCell component - without selector @@ -35,17 +33,17 @@ Props for AppCell component - without selector cell: Cell; ``` -Defined in: [react-table/src/createTableHook.tsx:404](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L404) +Defined in: [src/createTableHook.tsx:404](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L404) *** -### children() +### children ```ts children: (cell) => ReactNode; ``` -Defined in: [react-table/src/createTableHook.tsx:405](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L405) +Defined in: [src/createTableHook.tsx:405](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L405) #### Parameters @@ -62,7 +60,7 @@ Defined in: [react-table/src/createTableHook.tsx:405](https://github.com/TanStac ### selector? ```ts -optional selector: undefined; +optional selector?: undefined; ``` -Defined in: [react-table/src/createTableHook.tsx:409](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L409) +Defined in: [src/createTableHook.tsx:409](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L409) diff --git a/docs/framework/react/reference/index/interfaces/AppHeaderComponent.md b/docs/framework/react/reference/index/interfaces/AppHeaderComponent.md index ef57827ade..cd1d58f7fa 100644 --- a/docs/framework/react/reference/index/interfaces/AppHeaderComponent.md +++ b/docs/framework/react/reference/index/interfaces/AppHeaderComponent.md @@ -3,9 +3,7 @@ id: AppHeaderComponent title: AppHeaderComponent --- -# Interface: AppHeaderComponent()\ - -Defined in: [react-table/src/createTableHook.tsx:497](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L497) +Defined in: [src/createTableHook.tsx:497](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L497) Component type for AppHeader/AppFooter - wraps a header and provides header context with optional Subscribe @@ -29,7 +27,7 @@ Component type for AppHeader/AppFooter - wraps a header and provides header cont AppHeaderComponent(props): ReactNode; ``` -Defined in: [react-table/src/createTableHook.tsx:502](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L502) +Defined in: [src/createTableHook.tsx:502](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L502) Component type for AppHeader/AppFooter - wraps a header and provides header context with optional Subscribe @@ -55,7 +53,7 @@ Component type for AppHeader/AppFooter - wraps a header and provides header cont AppHeaderComponent(props): ReactNode; ``` -Defined in: [react-table/src/createTableHook.tsx:510](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L510) +Defined in: [src/createTableHook.tsx:510](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L510) Component type for AppHeader/AppFooter - wraps a header and provides header context with optional Subscribe diff --git a/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithSelector.md b/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithSelector.md index 9f3e6e29ed..f85fef5283 100644 --- a/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithSelector.md +++ b/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithSelector.md @@ -3,9 +3,7 @@ id: AppHeaderPropsWithSelector title: AppHeaderPropsWithSelector --- -# Interface: AppHeaderPropsWithSelector\ - -Defined in: [react-table/src/createTableHook.tsx:451](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L451) +Defined in: [src/createTableHook.tsx:451](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L451) Props for AppHeader/AppFooter component - with selector @@ -33,13 +31,13 @@ Props for AppHeader/AppFooter component - with selector ## Properties -### children() +### children ```ts children: (header, state) => ReactNode; ``` -Defined in: [react-table/src/createTableHook.tsx:459](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L459) +Defined in: [src/createTableHook.tsx:459](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L459) #### Parameters @@ -63,17 +61,17 @@ Defined in: [react-table/src/createTableHook.tsx:459](https://github.com/TanStac header: Header; ``` -Defined in: [react-table/src/createTableHook.tsx:458](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L458) +Defined in: [src/createTableHook.tsx:458](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L458) *** -### selector() +### selector ```ts selector: (state) => TSelected; ``` -Defined in: [react-table/src/createTableHook.tsx:464](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L464) +Defined in: [src/createTableHook.tsx:464](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L464) #### Parameters diff --git a/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithoutSelector.md b/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithoutSelector.md index 31ca0c7680..108efc25fe 100644 --- a/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithoutSelector.md +++ b/docs/framework/react/reference/index/interfaces/AppHeaderPropsWithoutSelector.md @@ -3,9 +3,7 @@ id: AppHeaderPropsWithoutSelector title: AppHeaderPropsWithoutSelector --- -# Interface: AppHeaderPropsWithoutSelector\ - -Defined in: [react-table/src/createTableHook.tsx:434](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L434) +Defined in: [src/createTableHook.tsx:434](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L434) Props for AppHeader/AppFooter component - without selector @@ -29,13 +27,13 @@ Props for AppHeader/AppFooter component - without selector ## Properties -### children() +### children ```ts children: (header) => ReactNode; ``` -Defined in: [react-table/src/createTableHook.tsx:441](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L441) +Defined in: [src/createTableHook.tsx:441](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L441) #### Parameters @@ -55,14 +53,14 @@ Defined in: [react-table/src/createTableHook.tsx:441](https://github.com/TanStac header: Header; ``` -Defined in: [react-table/src/createTableHook.tsx:440](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L440) +Defined in: [src/createTableHook.tsx:440](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L440) *** ### selector? ```ts -optional selector: undefined; +optional selector?: undefined; ``` -Defined in: [react-table/src/createTableHook.tsx:445](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L445) +Defined in: [src/createTableHook.tsx:445](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L445) diff --git a/docs/framework/react/reference/index/interfaces/AppTableComponent.md b/docs/framework/react/reference/index/interfaces/AppTableComponent.md index 4a6f7be020..4bbf66a02f 100644 --- a/docs/framework/react/reference/index/interfaces/AppTableComponent.md +++ b/docs/framework/react/reference/index/interfaces/AppTableComponent.md @@ -3,9 +3,7 @@ id: AppTableComponent title: AppTableComponent --- -# Interface: AppTableComponent()\ - -Defined in: [react-table/src/createTableHook.tsx:524](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L524) +Defined in: [src/createTableHook.tsx:524](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L524) Component type for AppTable - root wrapper with optional Subscribe @@ -21,7 +19,7 @@ Component type for AppTable - root wrapper with optional Subscribe AppTableComponent(props): ReactNode; ``` -Defined in: [react-table/src/createTableHook.tsx:525](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L525) +Defined in: [src/createTableHook.tsx:525](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L525) Component type for AppTable - root wrapper with optional Subscribe @@ -41,7 +39,7 @@ Component type for AppTable - root wrapper with optional Subscribe AppTableComponent(props): ReactNode; ``` -Defined in: [react-table/src/createTableHook.tsx:526](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L526) +Defined in: [src/createTableHook.tsx:526](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L526) Component type for AppTable - root wrapper with optional Subscribe diff --git a/docs/framework/react/reference/index/interfaces/AppTablePropsWithSelector.md b/docs/framework/react/reference/index/interfaces/AppTablePropsWithSelector.md index b2147e1979..64db7d46a7 100644 --- a/docs/framework/react/reference/index/interfaces/AppTablePropsWithSelector.md +++ b/docs/framework/react/reference/index/interfaces/AppTablePropsWithSelector.md @@ -3,9 +3,7 @@ id: AppTablePropsWithSelector title: AppTablePropsWithSelector --- -# Interface: AppTablePropsWithSelector\ - -Defined in: [react-table/src/createTableHook.tsx:387](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L387) +Defined in: [src/createTableHook.tsx:387](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L387) Props for AppTable component - with selector @@ -21,13 +19,13 @@ Props for AppTable component - with selector ## Properties -### children() +### children ```ts children: (state) => ReactNode; ``` -Defined in: [react-table/src/createTableHook.tsx:391](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L391) +Defined in: [src/createTableHook.tsx:391](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L391) #### Parameters @@ -41,13 +39,13 @@ Defined in: [react-table/src/createTableHook.tsx:391](https://github.com/TanStac *** -### selector() +### selector ```ts selector: (state) => TSelected; ``` -Defined in: [react-table/src/createTableHook.tsx:392](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L392) +Defined in: [src/createTableHook.tsx:392](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L392) #### Parameters diff --git a/docs/framework/react/reference/index/interfaces/AppTablePropsWithoutSelector.md b/docs/framework/react/reference/index/interfaces/AppTablePropsWithoutSelector.md index 550cf33098..de95cd76d4 100644 --- a/docs/framework/react/reference/index/interfaces/AppTablePropsWithoutSelector.md +++ b/docs/framework/react/reference/index/interfaces/AppTablePropsWithoutSelector.md @@ -3,9 +3,7 @@ id: AppTablePropsWithoutSelector title: AppTablePropsWithoutSelector --- -# Interface: AppTablePropsWithoutSelector - -Defined in: [react-table/src/createTableHook.tsx:379](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L379) +Defined in: [src/createTableHook.tsx:379](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L379) Props for AppTable component - without selector @@ -17,14 +15,14 @@ Props for AppTable component - without selector children: ReactNode; ``` -Defined in: [react-table/src/createTableHook.tsx:380](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L380) +Defined in: [src/createTableHook.tsx:380](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L380) *** ### selector? ```ts -optional selector: undefined; +optional selector?: undefined; ``` -Defined in: [react-table/src/createTableHook.tsx:381](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L381) +Defined in: [src/createTableHook.tsx:381](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L381) diff --git a/docs/framework/react/reference/index/interfaces/CreateTableHookResult.md b/docs/framework/react/reference/index/interfaces/CreateTableHookResult.md index 38ca4d702a..12092b17c6 100644 --- a/docs/framework/react/reference/index/interfaces/CreateTableHookResult.md +++ b/docs/framework/react/reference/index/interfaces/CreateTableHookResult.md @@ -3,9 +3,7 @@ id: CreateTableHookResult title: CreateTableHookResult --- -# Interface: CreateTableHookResult\ - -Defined in: [react-table/src/createTableHook.tsx:298](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L298) +Defined in: [src/createTableHook.tsx:298](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L298) ## Type Parameters @@ -33,19 +31,19 @@ Defined in: [react-table/src/createTableHook.tsx:298](https://github.com/TanStac appFeatures: TFeatures; ``` -Defined in: [react-table/src/createTableHook.tsx:305](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L305) +Defined in: [src/createTableHook.tsx:305](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L305) The features object that was passed to `createTableHook`. *** -### createAppColumnHelper() +### createAppColumnHelper ```ts createAppColumnHelper: () => AppColumnHelper; ``` -Defined in: [react-table/src/createTableHook.tsx:310](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L310) +Defined in: [src/createTableHook.tsx:310](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L310) A column helper pre-bound to `TFeatures` and the registered components, so the cell/header/footer render props expose the bound components. @@ -62,13 +60,13 @@ the cell/header/footer render props expose the bound components. *** -### useAppTable() +### useAppTable ```ts useAppTable: (tableOptions, selector?) => AppReactTable; ``` -Defined in: [react-table/src/createTableHook.tsx:320](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L320) +Defined in: [src/createTableHook.tsx:320](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L320) Creates a table with the `App*` wrapper components and registered `tableComponents` attached. `TData` is inferred from the `data` option. @@ -99,13 +97,13 @@ Creates a table with the `App*` wrapper components and registered *** -### useCellContext() +### useCellContext ```ts useCellContext: () => Cell_Core & ExtractFeatureMapTypes & TCellComponents & object; ``` -Defined in: [react-table/src/createTableHook.tsx:357](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L357) +Defined in: [src/createTableHook.tsx:357](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L357) Reads the cell provided by the nearest ``, extended with your `cellComponents` and a context-bound `FlexRender`. @@ -122,13 +120,13 @@ Reads the cell provided by the nearest ``, extended with your *** -### useHeaderContext() +### useHeaderContext ```ts useHeaderContext: () => Header_Core & ExtractFeatureMapTypes & THeaderComponents & object; ``` -Defined in: [react-table/src/createTableHook.tsx:368](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L368) +Defined in: [src/createTableHook.tsx:368](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L368) Reads the header provided by the nearest `` / ``, extended with your `headerComponents` and a @@ -146,13 +144,13 @@ context-bound `FlexRender`. *** -### useTableContext() +### useTableContext ```ts useTableContext: () => AppReactTable; ``` -Defined in: [react-table/src/createTableHook.tsx:342](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L342) +Defined in: [src/createTableHook.tsx:342](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L342) Reads the table provided by the nearest ``. This is the same extended instance `useAppTable` returns, so the `App*` components and your diff --git a/docs/framework/react/reference/index/interfaces/TableHookContexts.md b/docs/framework/react/reference/index/interfaces/TableHookContexts.md index bccd2b6cc4..7867020c54 100644 --- a/docs/framework/react/reference/index/interfaces/TableHookContexts.md +++ b/docs/framework/react/reference/index/interfaces/TableHookContexts.md @@ -3,9 +3,7 @@ id: TableHookContexts title: TableHookContexts --- -# Interface: TableHookContexts\ - -Defined in: [react-table/src/createTableHookContexts.tsx:17](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L17) +Defined in: [src/createTableHookContexts.tsx:17](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L17) The object returned by [createTableHookContexts](../functions/createTableHookContexts.md): three scoped React contexts plus matching context hooks. @@ -28,7 +26,7 @@ contexts plus matching context hooks. cellContext: Context>; ``` -Defined in: [react-table/src/createTableHookContexts.tsx:22](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L22) +Defined in: [src/createTableHookContexts.tsx:22](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L22) *** @@ -38,7 +36,7 @@ Defined in: [react-table/src/createTableHookContexts.tsx:22](https://github.com/ headerContext: Context>; ``` -Defined in: [react-table/src/createTableHookContexts.tsx:23](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L23) +Defined in: [src/createTableHookContexts.tsx:23](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L23) *** @@ -48,17 +46,17 @@ Defined in: [react-table/src/createTableHookContexts.tsx:23](https://github.com/ tableContext: Context>; ``` -Defined in: [react-table/src/createTableHookContexts.tsx:21](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L21) +Defined in: [src/createTableHookContexts.tsx:21](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L21) *** -### useCellContext() +### useCellContext ```ts useCellContext: () => Cell; ``` -Defined in: [react-table/src/createTableHookContexts.tsx:28](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L28) +Defined in: [src/createTableHookContexts.tsx:28](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L28) #### Type Parameters @@ -72,13 +70,13 @@ Defined in: [react-table/src/createTableHookContexts.tsx:28](https://github.com/ *** -### useHeaderContext() +### useHeaderContext ```ts useHeaderContext: () => Header; ``` -Defined in: [react-table/src/createTableHookContexts.tsx:33](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L33) +Defined in: [src/createTableHookContexts.tsx:33](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L33) #### Type Parameters @@ -92,13 +90,13 @@ Defined in: [react-table/src/createTableHookContexts.tsx:33](https://github.com/ *** -### useTableContext() +### useTableContext ```ts useTableContext: () => ReactTable; ``` -Defined in: [react-table/src/createTableHookContexts.tsx:24](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L24) +Defined in: [src/createTableHookContexts.tsx:24](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHookContexts.tsx#L24) #### Type Parameters diff --git a/docs/framework/react/reference/index/type-aliases/AppCellContext.md b/docs/framework/react/reference/index/type-aliases/AppCellContext.md index 6093395df7..7bb267a1a0 100644 --- a/docs/framework/react/reference/index/type-aliases/AppCellContext.md +++ b/docs/framework/react/reference/index/type-aliases/AppCellContext.md @@ -3,13 +3,11 @@ id: AppCellContext title: AppCellContext --- -# Type Alias: AppCellContext\ - ```ts type AppCellContext = object; ``` -Defined in: [react-table/src/createTableHook.tsx:48](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L48) +Defined in: [src/createTableHook.tsx:48](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L48) Enhanced CellContext with pre-bound cell components. The `cell` property includes the registered cellComponents. @@ -40,11 +38,11 @@ The `cell` property includes the registered cellComponents. cell: Cell & TCellComponents & object; ``` -Defined in: [react-table/src/createTableHook.tsx:54](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L54) +Defined in: [src/createTableHook.tsx:54](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L54) #### Type Declaration -##### FlexRender() +##### FlexRender ```ts FlexRender: () => ReactNode; @@ -62,7 +60,7 @@ FlexRender: () => ReactNode; column: Column; ``` -Defined in: [react-table/src/createTableHook.tsx:56](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L56) +Defined in: [src/createTableHook.tsx:56](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L56) *** @@ -72,7 +70,7 @@ Defined in: [react-table/src/createTableHook.tsx:56](https://github.com/TanStack getValue: CellContext["getValue"]; ``` -Defined in: [react-table/src/createTableHook.tsx:57](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L57) +Defined in: [src/createTableHook.tsx:57](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L57) *** @@ -82,7 +80,7 @@ Defined in: [react-table/src/createTableHook.tsx:57](https://github.com/TanStack renderValue: CellContext["renderValue"]; ``` -Defined in: [react-table/src/createTableHook.tsx:58](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L58) +Defined in: [src/createTableHook.tsx:58](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L58) *** @@ -92,7 +90,7 @@ Defined in: [react-table/src/createTableHook.tsx:58](https://github.com/TanStack row: Row; ``` -Defined in: [react-table/src/createTableHook.tsx:59](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L59) +Defined in: [src/createTableHook.tsx:59](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L59) *** @@ -102,4 +100,4 @@ Defined in: [react-table/src/createTableHook.tsx:59](https://github.com/TanStack table: Table; ``` -Defined in: [react-table/src/createTableHook.tsx:60](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L60) +Defined in: [src/createTableHook.tsx:60](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L60) diff --git a/docs/framework/react/reference/index/type-aliases/AppColumnDefBase.md b/docs/framework/react/reference/index/type-aliases/AppColumnDefBase.md index 6703ada186..3616a72024 100644 --- a/docs/framework/react/reference/index/type-aliases/AppColumnDefBase.md +++ b/docs/framework/react/reference/index/type-aliases/AppColumnDefBase.md @@ -3,13 +3,11 @@ id: AppColumnDefBase title: AppColumnDefBase --- -# Type Alias: AppColumnDefBase\ - ```ts type AppColumnDefBase = Omit, "cell" | "header" | "footer"> & object; ``` -Defined in: [react-table/src/createTableHook.tsx:92](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L92) +Defined in: [src/createTableHook.tsx:92](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L92) Enhanced column definition base with pre-bound components in cell/header/footer contexts. @@ -18,19 +16,19 @@ Enhanced column definition base with pre-bound components in cell/header/footer ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/react/reference/index/type-aliases/AppColumnDefTemplate.md b/docs/framework/react/reference/index/type-aliases/AppColumnDefTemplate.md index 098eb63bde..9f260c6765 100644 --- a/docs/framework/react/reference/index/type-aliases/AppColumnDefTemplate.md +++ b/docs/framework/react/reference/index/type-aliases/AppColumnDefTemplate.md @@ -3,13 +3,11 @@ id: AppColumnDefTemplate title: AppColumnDefTemplate --- -# Type Alias: AppColumnDefTemplate\ - ```ts -type AppColumnDefTemplate = string | (props) => any; +type AppColumnDefTemplate = string | ((props) => any); ``` -Defined in: [react-table/src/createTableHook.tsx:86](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L86) +Defined in: [src/createTableHook.tsx:86](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L86) Template type for column definitions that can be a string or a function. diff --git a/docs/framework/react/reference/index/type-aliases/AppColumnHelper.md b/docs/framework/react/reference/index/type-aliases/AppColumnHelper.md index 32328516f6..5b58d2a580 100644 --- a/docs/framework/react/reference/index/type-aliases/AppColumnHelper.md +++ b/docs/framework/react/reference/index/type-aliases/AppColumnHelper.md @@ -3,13 +3,11 @@ id: AppColumnHelper title: AppColumnHelper --- -# Type Alias: AppColumnHelper\ - ```ts type AppColumnHelper = object; ``` -Defined in: [react-table/src/createTableHook.tsx:168](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L168) +Defined in: [src/createTableHook.tsx:168](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L168) Enhanced column helper with pre-bound components in cell/header/footer contexts. This enables TypeScript to know about the registered components when defining columns. @@ -34,13 +32,13 @@ This enables TypeScript to know about the registered components when defining co ## Properties -### accessor() +### accessor ```ts accessor: (accessor, column) => TAccessor extends AccessorFn ? AccessorFnColumnDef : AccessorKeyColumnDef; ``` -Defined in: [react-table/src/createTableHook.tsx:178](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L178) +Defined in: [src/createTableHook.tsx:178](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L178) Creates a data column definition with an accessor key or function. The cell, header, and footer contexts include pre-bound components. @@ -71,13 +69,13 @@ The cell, header, and footer contexts include pre-bound components. *** -### columns() +### columns ```ts columns: (columns) => ColumnDef[] & [...TColumns]; ``` -Defined in: [react-table/src/createTableHook.tsx:209](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L209) +Defined in: [src/createTableHook.tsx:209](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L209) Wraps an array of column definitions to preserve each column's individual TValue type. @@ -99,13 +97,13 @@ Wraps an array of column definitions to preserve each column's individual TValue *** -### display() +### display ```ts display: (column) => DisplayColumnDef; ``` -Defined in: [react-table/src/createTableHook.tsx:217](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L217) +Defined in: [src/createTableHook.tsx:217](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L217) Creates a display column definition for non-data columns. The cell, header, and footer contexts include pre-bound components. @@ -122,13 +120,13 @@ The cell, header, and footer contexts include pre-bound components. *** -### group() +### group ```ts group: (column) => GroupColumnDef; ``` -Defined in: [react-table/src/createTableHook.tsx:230](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L230) +Defined in: [src/createTableHook.tsx:230](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L230) Creates a group column definition with nested child columns. The cell, header, and footer contexts include pre-bound components. diff --git a/docs/framework/react/reference/index/type-aliases/AppDisplayColumnDef.md b/docs/framework/react/reference/index/type-aliases/AppDisplayColumnDef.md index 95371dfcf7..6ae19e542e 100644 --- a/docs/framework/react/reference/index/type-aliases/AppDisplayColumnDef.md +++ b/docs/framework/react/reference/index/type-aliases/AppDisplayColumnDef.md @@ -3,13 +3,11 @@ id: AppDisplayColumnDef title: AppDisplayColumnDef --- -# Type Alias: AppDisplayColumnDef\ - ```ts type AppDisplayColumnDef = Omit, "cell" | "header" | "footer"> & object; ``` -Defined in: [react-table/src/createTableHook.tsx:116](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L116) +Defined in: [src/createTableHook.tsx:116](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L116) Enhanced display column definition with pre-bound components. @@ -18,19 +16,19 @@ Enhanced display column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/react/reference/index/type-aliases/AppGroupColumnDef.md b/docs/framework/react/reference/index/type-aliases/AppGroupColumnDef.md index f6caa31706..be5d9c8779 100644 --- a/docs/framework/react/reference/index/type-aliases/AppGroupColumnDef.md +++ b/docs/framework/react/reference/index/type-aliases/AppGroupColumnDef.md @@ -3,13 +3,11 @@ id: AppGroupColumnDef title: AppGroupColumnDef --- -# Type Alias: AppGroupColumnDef\ - ```ts type AppGroupColumnDef = Omit, "cell" | "header" | "footer" | "columns"> & object; ``` -Defined in: [react-table/src/createTableHook.tsx:139](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L139) +Defined in: [src/createTableHook.tsx:139](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L139) Enhanced group column definition with pre-bound components. @@ -18,25 +16,25 @@ Enhanced group column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### columns? ```ts -optional columns: ReadonlyArray>; +optional columns?: ReadonlyArray>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/react/reference/index/type-aliases/AppHeaderContext.md b/docs/framework/react/reference/index/type-aliases/AppHeaderContext.md index 1a23573998..311333c244 100644 --- a/docs/framework/react/reference/index/type-aliases/AppHeaderContext.md +++ b/docs/framework/react/reference/index/type-aliases/AppHeaderContext.md @@ -3,13 +3,11 @@ id: AppHeaderContext title: AppHeaderContext --- -# Type Alias: AppHeaderContext\ - ```ts type AppHeaderContext = object; ``` -Defined in: [react-table/src/createTableHook.tsx:67](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L67) +Defined in: [src/createTableHook.tsx:67](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L67) Enhanced HeaderContext with pre-bound header components. The `header` property includes the registered headerComponents. @@ -40,7 +38,7 @@ The `header` property includes the registered headerComponents. column: Column; ``` -Defined in: [react-table/src/createTableHook.tsx:73](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L73) +Defined in: [src/createTableHook.tsx:73](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L73) *** @@ -50,11 +48,11 @@ Defined in: [react-table/src/createTableHook.tsx:73](https://github.com/TanStack header: Header & THeaderComponents & object; ``` -Defined in: [react-table/src/createTableHook.tsx:74](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L74) +Defined in: [src/createTableHook.tsx:74](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L74) #### Type Declaration -##### FlexRender() +##### FlexRender ```ts FlexRender: () => ReactNode; @@ -72,4 +70,4 @@ FlexRender: () => ReactNode; table: Table; ``` -Defined in: [react-table/src/createTableHook.tsx:76](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L76) +Defined in: [src/createTableHook.tsx:76](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L76) diff --git a/docs/framework/react/reference/index/type-aliases/AppReactTable.md b/docs/framework/react/reference/index/type-aliases/AppReactTable.md index 64242d38b0..47220a461d 100644 --- a/docs/framework/react/reference/index/type-aliases/AppReactTable.md +++ b/docs/framework/react/reference/index/type-aliases/AppReactTable.md @@ -3,13 +3,11 @@ id: AppReactTable title: AppReactTable --- -# Type Alias: AppReactTable\ - ```ts type AppReactTable = ReactTable & NoInfer & object; ``` -Defined in: [react-table/src/createTableHook.tsx:532](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L532) +Defined in: [src/createTableHook.tsx:532](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L532) Extended table API returned by useAppTable with all App wrapper components diff --git a/docs/framework/react/reference/index/type-aliases/CreateTableHookOptions.md b/docs/framework/react/reference/index/type-aliases/CreateTableHookOptions.md index 97fe8f9d8c..da78dd9709 100644 --- a/docs/framework/react/reference/index/type-aliases/CreateTableHookOptions.md +++ b/docs/framework/react/reference/index/type-aliases/CreateTableHookOptions.md @@ -3,13 +3,11 @@ id: CreateTableHookOptions title: CreateTableHookOptions --- -# Type Alias: CreateTableHookOptions\ - ```ts type CreateTableHookOptions = Omit, "columns" | "data" | "store" | "state" | "initialState"> & object; ``` -Defined in: [react-table/src/createTableHook.tsx:248](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L248) +Defined in: [src/createTableHook.tsx:248](https://github.com/TanStack/table/blob/main/packages/react-table/src/createTableHook.tsx#L248) Options for creating a table hook with pre-bound components and default table options. Extends all TableOptions except 'columns' | 'data' | 'store' | 'state' | 'initialState'. @@ -19,7 +17,7 @@ Extends all TableOptions except 'columns' | 'data' | 'store' | 'state' | 'initia ### cellComponents? ```ts -optional cellComponents: TCellComponents; +optional cellComponents?: TCellComponents; ``` Cell-level components that need access to the cell instance. @@ -35,7 +33,7 @@ Use `useCellContext()` inside these components. ### cellContext? ```ts -optional cellContext: Context>; +optional cellContext?: Context>; ``` A custom React context for the cell instance, used inside your `cellComponents`. @@ -47,7 +45,7 @@ CreateTableHookOptions.tableContext ### headerComponents? ```ts -optional headerComponents: THeaderComponents; +optional headerComponents?: THeaderComponents; ``` Header-level components that need access to the header instance. @@ -63,7 +61,7 @@ Use `useHeaderContext()` inside these components. ### headerContext? ```ts -optional headerContext: Context>; +optional headerContext?: Context>; ``` A custom React context for the header instance, used inside your @@ -76,7 +74,7 @@ CreateTableHookOptions.tableContext ### tableComponents? ```ts -optional tableComponents: TTableComponents; +optional tableComponents?: TTableComponents; ``` Table-level components that need access to the table instance. @@ -92,7 +90,7 @@ Use `useTableContext()` inside these components. ### tableContext? ```ts -optional tableContext: Context>; +optional tableContext?: Context>; ``` A custom React context for the table instance (read with `useContext` inside diff --git a/docs/framework/react/reference/index/type-aliases/FlexRenderProps.md b/docs/framework/react/reference/index/type-aliases/FlexRenderProps.md index cf42d0fbe9..a63ded41a7 100644 --- a/docs/framework/react/reference/index/type-aliases/FlexRenderProps.md +++ b/docs/framework/react/reference/index/type-aliases/FlexRenderProps.md @@ -3,8 +3,6 @@ id: FlexRenderProps title: FlexRenderProps --- -# Type Alias: FlexRenderProps\ - ```ts type FlexRenderProps = | { @@ -24,7 +22,7 @@ type FlexRenderProps = }; ``` -Defined in: [react-table/src/FlexRender.tsx:63](https://github.com/TanStack/table/blob/main/packages/react-table/src/FlexRender.tsx#L63) +Defined in: [src/FlexRender.tsx:63](https://github.com/TanStack/table/blob/main/packages/react-table/src/FlexRender.tsx#L63) Simplified component wrapper of `flexRender`. Use this utility component to render headers, cells, or footers with custom markup. Only one prop (`cell`, `header`, or `footer`) may be passed. diff --git a/docs/framework/react/reference/index/type-aliases/ReactTable.md b/docs/framework/react/reference/index/type-aliases/ReactTable.md index 23ea5bc87f..10dc32f23e 100644 --- a/docs/framework/react/reference/index/type-aliases/ReactTable.md +++ b/docs/framework/react/reference/index/type-aliases/ReactTable.md @@ -3,17 +3,15 @@ id: ReactTable title: ReactTable --- -# Type Alias: ReactTable\ - ```ts type ReactTable = Omit, "store"> & object; ``` -Defined in: [react-table/src/useTable.ts:29](https://github.com/TanStack/table/blob/main/packages/react-table/src/useTable.ts#L29) +Defined in: [src/useTable.ts:29](https://github.com/TanStack/table/blob/main/packages/react-table/src/useTable.ts#L29) ## Type Declaration -### FlexRender() +### FlexRender ```ts FlexRender: (props) => ReactNode; @@ -85,7 +83,7 @@ Prefer `table.state` for render reads, subscriptions. `table.store.state` is a current-value snapshot and is easy to misuse in render code. -### Subscribe() +### Subscribe ```ts Subscribe: { @@ -122,7 +120,7 @@ The **source** overloads are listed first so `TSourceValue` is inferred from `so ###### children -(`state`) => `ReactNode` \| `ReactNode` +((`state`) => `ReactNode`) \| `ReactNode` ###### selector? @@ -158,7 +156,7 @@ The **source** overloads are listed first so `TSourceValue` is inferred from `so ###### children -(`state`) => `ReactNode` \| `ReactNode` +((`state`) => `ReactNode`) \| `ReactNode` ###### selector diff --git a/docs/framework/react/reference/index/type-aliases/Renderable.md b/docs/framework/react/reference/index/type-aliases/Renderable.md index 8fef899628..147024d185 100644 --- a/docs/framework/react/reference/index/type-aliases/Renderable.md +++ b/docs/framework/react/reference/index/type-aliases/Renderable.md @@ -3,13 +3,11 @@ id: Renderable title: Renderable --- -# Type Alias: Renderable\ - ```ts type Renderable = ReactNode | ComponentType; ``` -Defined in: [react-table/src/FlexRender.tsx:11](https://github.com/TanStack/table/blob/main/packages/react-table/src/FlexRender.tsx#L11) +Defined in: [src/FlexRender.tsx:11](https://github.com/TanStack/table/blob/main/packages/react-table/src/FlexRender.tsx#L11) ## Type Parameters diff --git a/docs/framework/react/reference/index/type-aliases/SubscribeProps.md b/docs/framework/react/reference/index/type-aliases/SubscribeProps.md index 0bf4728ed0..a557075c05 100644 --- a/docs/framework/react/reference/index/type-aliases/SubscribeProps.md +++ b/docs/framework/react/reference/index/type-aliases/SubscribeProps.md @@ -3,8 +3,6 @@ id: SubscribeProps title: SubscribeProps --- -# Type Alias: SubscribeProps\ - ```ts type SubscribeProps = | SubscribePropsWithStore @@ -12,7 +10,7 @@ type SubscribeProps = | SubscribePropsWithSourceWithSelector; ``` -Defined in: [react-table/src/Subscribe.ts:66](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L66) +Defined in: [src/Subscribe.ts:66](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L66) ## Type Parameters diff --git a/docs/framework/react/reference/index/type-aliases/SubscribePropsWithSource.md b/docs/framework/react/reference/index/type-aliases/SubscribePropsWithSource.md index b929f8a62a..8985bac975 100644 --- a/docs/framework/react/reference/index/type-aliases/SubscribePropsWithSource.md +++ b/docs/framework/react/reference/index/type-aliases/SubscribePropsWithSource.md @@ -3,15 +3,13 @@ id: SubscribePropsWithSource title: SubscribePropsWithSource --- -# Type Alias: SubscribePropsWithSource\ - ```ts type SubscribePropsWithSource = | SubscribePropsWithSourceIdentity | SubscribePropsWithSourceWithSelector; ``` -Defined in: [react-table/src/Subscribe.ts:62](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L62) +Defined in: [src/Subscribe.ts:62](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L62) Subscribe to a single source — atom or store (identity or projected). Prefer [SubscribePropsWithSourceIdentity](SubscribePropsWithSourceIdentity.md) or [SubscribePropsWithSourceWithSelector](SubscribePropsWithSourceWithSelector.md) diff --git a/docs/framework/react/reference/index/type-aliases/SubscribePropsWithSourceIdentity.md b/docs/framework/react/reference/index/type-aliases/SubscribePropsWithSourceIdentity.md index 3c2fd7f64b..f0192bcb63 100644 --- a/docs/framework/react/reference/index/type-aliases/SubscribePropsWithSourceIdentity.md +++ b/docs/framework/react/reference/index/type-aliases/SubscribePropsWithSourceIdentity.md @@ -3,13 +3,11 @@ id: SubscribePropsWithSourceIdentity title: SubscribePropsWithSourceIdentity --- -# Type Alias: SubscribePropsWithSourceIdentity\ - ```ts type SubscribePropsWithSourceIdentity = object; ``` -Defined in: [react-table/src/Subscribe.ts:41](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L41) +Defined in: [src/Subscribe.ts:41](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L41) Subscribe to the full value of a source (e.g. `table.atoms.rowSelection` or `table.optionsStore`). Omitting `selector` is equivalent to the identity @@ -26,20 +24,20 @@ selector — children receive `TSourceValue`. ### children ```ts -children: (state) => ReactNode | ReactNode; +children: ((state) => ReactNode) | ReactNode; ``` -Defined in: [react-table/src/Subscribe.ts:44](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L44) +Defined in: [src/Subscribe.ts:44](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L44) *** ### selector? ```ts -optional selector: undefined; +optional selector?: undefined; ``` -Defined in: [react-table/src/Subscribe.ts:43](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L43) +Defined in: [src/Subscribe.ts:43](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L43) *** @@ -49,4 +47,4 @@ Defined in: [react-table/src/Subscribe.ts:43](https://github.com/TanStack/table/ source: SubscribeSource; ``` -Defined in: [react-table/src/Subscribe.ts:42](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L42) +Defined in: [src/Subscribe.ts:42](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L42) diff --git a/docs/framework/react/reference/index/type-aliases/SubscribePropsWithSourceWithSelector.md b/docs/framework/react/reference/index/type-aliases/SubscribePropsWithSourceWithSelector.md index 9d5fcfb885..6e0277a45c 100644 --- a/docs/framework/react/reference/index/type-aliases/SubscribePropsWithSourceWithSelector.md +++ b/docs/framework/react/reference/index/type-aliases/SubscribePropsWithSourceWithSelector.md @@ -3,13 +3,11 @@ id: SubscribePropsWithSourceWithSelector title: SubscribePropsWithSourceWithSelector --- -# Type Alias: SubscribePropsWithSourceWithSelector\ - ```ts type SubscribePropsWithSourceWithSelector = object; ``` -Defined in: [react-table/src/Subscribe.ts:51](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L51) +Defined in: [src/Subscribe.ts:51](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L51) Subscribe to a projected value from a source (atom or store). The selector receives the source value; children receive the projected `TSelected`. @@ -29,20 +27,20 @@ receives the source value; children receive the projected `TSelected`. ### children ```ts -children: (state) => ReactNode | ReactNode; +children: ((state) => ReactNode) | ReactNode; ``` -Defined in: [react-table/src/Subscribe.ts:54](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L54) +Defined in: [src/Subscribe.ts:54](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L54) *** -### selector() +### selector ```ts selector: (state) => TSelected; ``` -Defined in: [react-table/src/Subscribe.ts:53](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L53) +Defined in: [src/Subscribe.ts:53](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L53) #### Parameters @@ -62,4 +60,4 @@ Defined in: [react-table/src/Subscribe.ts:53](https://github.com/TanStack/table/ source: SubscribeSource; ``` -Defined in: [react-table/src/Subscribe.ts:52](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L52) +Defined in: [src/Subscribe.ts:52](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L52) diff --git a/docs/framework/react/reference/index/type-aliases/SubscribePropsWithStore.md b/docs/framework/react/reference/index/type-aliases/SubscribePropsWithStore.md index 361e9bfd82..1db2ca8fbc 100644 --- a/docs/framework/react/reference/index/type-aliases/SubscribePropsWithStore.md +++ b/docs/framework/react/reference/index/type-aliases/SubscribePropsWithStore.md @@ -3,13 +3,11 @@ id: SubscribePropsWithStore title: SubscribePropsWithStore --- -# Type Alias: SubscribePropsWithStore\ - ```ts type SubscribePropsWithStore = object; ``` -Defined in: [react-table/src/Subscribe.ts:20](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L20) +Defined in: [src/Subscribe.ts:20](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L20) Subscribe to `table.store` (full table state). The selector receives the full TableState. @@ -29,20 +27,20 @@ TableState. ### children ```ts -children: (state) => ReactNode | ReactNode; +children: ((state) => ReactNode) | ReactNode; ``` -Defined in: [react-table/src/Subscribe.ts:33](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L33) +Defined in: [src/Subscribe.ts:33](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L33) *** -### selector() +### selector ```ts selector: (state) => TSelected; ``` -Defined in: [react-table/src/Subscribe.ts:32](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L32) +Defined in: [src/Subscribe.ts:32](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L32) Select from full table state. Re-renders when the selected value changes (shallow compare). @@ -68,4 +66,4 @@ store without an explicit projection. source: SubscribeSource>; ``` -Defined in: [react-table/src/Subscribe.ts:24](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L24) +Defined in: [src/Subscribe.ts:24](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L24) diff --git a/docs/framework/react/reference/index/type-aliases/SubscribeSource.md b/docs/framework/react/reference/index/type-aliases/SubscribeSource.md index 1bbbb59253..6135316d16 100644 --- a/docs/framework/react/reference/index/type-aliases/SubscribeSource.md +++ b/docs/framework/react/reference/index/type-aliases/SubscribeSource.md @@ -3,8 +3,6 @@ id: SubscribeSource title: SubscribeSource --- -# Type Alias: SubscribeSource\ - ```ts type SubscribeSource = | Atom @@ -13,7 +11,7 @@ type SubscribeSource = | ReadonlyStore; ``` -Defined in: [react-table/src/Subscribe.ts:13](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L13) +Defined in: [src/Subscribe.ts:13](https://github.com/TanStack/table/blob/main/packages/react-table/src/Subscribe.ts#L13) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/functions/getCoreRowModel.md b/docs/framework/react/reference/legacy/functions/getCoreRowModel.md index 651bd1d957..176203431a 100644 --- a/docs/framework/react/reference/legacy/functions/getCoreRowModel.md +++ b/docs/framework/react/reference/legacy/functions/getCoreRowModel.md @@ -3,13 +3,11 @@ id: getCoreRowModel title: getCoreRowModel --- -# ~~Function: getCoreRowModel()~~ - ```ts function getCoreRowModel(): RowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:151](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L151) +Defined in: [src/useLegacyTable.ts:151](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L151) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/functions/getExpandedRowModel.md b/docs/framework/react/reference/legacy/functions/getExpandedRowModel.md index 38e3af0df2..bd0bf03a19 100644 --- a/docs/framework/react/reference/legacy/functions/getExpandedRowModel.md +++ b/docs/framework/react/reference/legacy/functions/getExpandedRowModel.md @@ -3,13 +3,11 @@ id: getExpandedRowModel title: getExpandedRowModel --- -# ~~Function: getExpandedRowModel()~~ - ```ts function getExpandedRowModel(): RowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:91](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L91) +Defined in: [src/useLegacyTable.ts:91](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L91) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/functions/getFacetedMinMaxValues.md b/docs/framework/react/reference/legacy/functions/getFacetedMinMaxValues.md index fd28c1573e..8fd0a542a0 100644 --- a/docs/framework/react/reference/legacy/functions/getFacetedMinMaxValues.md +++ b/docs/framework/react/reference/legacy/functions/getFacetedMinMaxValues.md @@ -3,13 +3,11 @@ id: getFacetedMinMaxValues title: getFacetedMinMaxValues --- -# ~~Function: getFacetedMinMaxValues()~~ - ```ts function getFacetedMinMaxValues(): FacetedMinMaxValuesFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:127](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L127) +Defined in: [src/useLegacyTable.ts:127](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L127) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/functions/getFacetedRowModel.md b/docs/framework/react/reference/legacy/functions/getFacetedRowModel.md index 70d9700ba3..e5e69f4d82 100644 --- a/docs/framework/react/reference/legacy/functions/getFacetedRowModel.md +++ b/docs/framework/react/reference/legacy/functions/getFacetedRowModel.md @@ -3,13 +3,11 @@ id: getFacetedRowModel title: getFacetedRowModel --- -# ~~Function: getFacetedRowModel()~~ - ```ts function getFacetedRowModel(): FacetedRowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:115](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L115) +Defined in: [src/useLegacyTable.ts:115](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L115) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/functions/getFacetedUniqueValues.md b/docs/framework/react/reference/legacy/functions/getFacetedUniqueValues.md index fcf1ddbbe0..729c9fe05f 100644 --- a/docs/framework/react/reference/legacy/functions/getFacetedUniqueValues.md +++ b/docs/framework/react/reference/legacy/functions/getFacetedUniqueValues.md @@ -3,13 +3,11 @@ id: getFacetedUniqueValues title: getFacetedUniqueValues --- -# ~~Function: getFacetedUniqueValues()~~ - ```ts function getFacetedUniqueValues(): FacetedUniqueValuesFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:139](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L139) +Defined in: [src/useLegacyTable.ts:139](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L139) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/functions/getFilteredRowModel.md b/docs/framework/react/reference/legacy/functions/getFilteredRowModel.md index 1a4403cad4..49f5bf70f6 100644 --- a/docs/framework/react/reference/legacy/functions/getFilteredRowModel.md +++ b/docs/framework/react/reference/legacy/functions/getFilteredRowModel.md @@ -3,13 +3,11 @@ id: getFilteredRowModel title: getFilteredRowModel --- -# ~~Function: getFilteredRowModel()~~ - ```ts function getFilteredRowModel(): RowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:55](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L55) +Defined in: [src/useLegacyTable.ts:55](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L55) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/functions/getGroupedRowModel.md b/docs/framework/react/reference/legacy/functions/getGroupedRowModel.md index bf31553aa4..7fd083ee37 100644 --- a/docs/framework/react/reference/legacy/functions/getGroupedRowModel.md +++ b/docs/framework/react/reference/legacy/functions/getGroupedRowModel.md @@ -3,13 +3,11 @@ id: getGroupedRowModel title: getGroupedRowModel --- -# ~~Function: getGroupedRowModel()~~ - ```ts function getGroupedRowModel(): RowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:103](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L103) +Defined in: [src/useLegacyTable.ts:103](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L103) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/functions/getPaginationRowModel.md b/docs/framework/react/reference/legacy/functions/getPaginationRowModel.md index 7bca00960b..93752d4b82 100644 --- a/docs/framework/react/reference/legacy/functions/getPaginationRowModel.md +++ b/docs/framework/react/reference/legacy/functions/getPaginationRowModel.md @@ -3,13 +3,11 @@ id: getPaginationRowModel title: getPaginationRowModel --- -# ~~Function: getPaginationRowModel()~~ - ```ts function getPaginationRowModel(): RowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:79](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L79) +Defined in: [src/useLegacyTable.ts:79](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L79) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/functions/getSortedRowModel.md b/docs/framework/react/reference/legacy/functions/getSortedRowModel.md index 66ea0af8c3..b5aa2b40e6 100644 --- a/docs/framework/react/reference/legacy/functions/getSortedRowModel.md +++ b/docs/framework/react/reference/legacy/functions/getSortedRowModel.md @@ -3,13 +3,11 @@ id: getSortedRowModel title: getSortedRowModel --- -# ~~Function: getSortedRowModel()~~ - ```ts function getSortedRowModel(): RowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:67](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L67) +Defined in: [src/useLegacyTable.ts:67](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L67) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/functions/legacyCreateColumnHelper.md b/docs/framework/react/reference/legacy/functions/legacyCreateColumnHelper.md index 0f7cf7086d..02b9d698df 100644 --- a/docs/framework/react/reference/legacy/functions/legacyCreateColumnHelper.md +++ b/docs/framework/react/reference/legacy/functions/legacyCreateColumnHelper.md @@ -3,13 +3,11 @@ id: legacyCreateColumnHelper title: legacyCreateColumnHelper --- -# ~~Function: legacyCreateColumnHelper()~~ - ```ts function legacyCreateColumnHelper(): ColumnHelper; ``` -Defined in: [react-table/src/useLegacyTable.ts:360](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L360) +Defined in: [src/useLegacyTable.ts:360](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L360) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/functions/useLegacyTable.md b/docs/framework/react/reference/legacy/functions/useLegacyTable.md index 0ef48a8644..fe732ea460 100644 --- a/docs/framework/react/reference/legacy/functions/useLegacyTable.md +++ b/docs/framework/react/reference/legacy/functions/useLegacyTable.md @@ -3,13 +3,11 @@ id: useLegacyTable title: useLegacyTable --- -# ~~Function: useLegacyTable()~~ - ```ts function useLegacyTable(options): LegacyReactTable; ``` -Defined in: [react-table/src/useLegacyTable.ts:405](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L405) +Defined in: [src/useLegacyTable.ts:405](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L405) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/index.md b/docs/framework/react/reference/legacy/index.md index 92a8f9b1e7..634ff1960b 100644 --- a/docs/framework/react/reference/legacy/index.md +++ b/docs/framework/react/reference/legacy/index.md @@ -3,8 +3,6 @@ id: legacy title: legacy --- -# legacy - ## Interfaces - [LegacyFeatures](interfaces/LegacyFeatures.md) diff --git a/docs/framework/react/reference/legacy/interfaces/LegacyFeatures.md b/docs/framework/react/reference/legacy/interfaces/LegacyFeatures.md index e980d739e6..0c6ea1eb00 100644 --- a/docs/framework/react/reference/legacy/interfaces/LegacyFeatures.md +++ b/docs/framework/react/reference/legacy/interfaces/LegacyFeatures.md @@ -3,9 +3,7 @@ id: LegacyFeatures title: LegacyFeatures --- -# Interface: LegacyFeatures - -Defined in: [react-table/src/useLegacyTable.ts:168](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L168) +Defined in: [src/useLegacyTable.ts:168](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L168) Feature set registered by `useLegacyTable`. @@ -25,7 +23,7 @@ registries so column definitions accept the v8 string identifiers such as aggregationFns: object; ``` -Defined in: [react-table/src/useLegacyTable.ts:169](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L169) +Defined in: [src/useLegacyTable.ts:169](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L169) #### range @@ -41,7 +39,7 @@ range: AggregationFnDef; filterFns: object; ``` -Defined in: [react-table/src/useLegacyTable.ts:170](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L170) +Defined in: [src/useLegacyTable.ts:170](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L170) #### startsWithLetter @@ -57,7 +55,7 @@ startsWithLetter: FilterFn; sortFns: object; ``` -Defined in: [react-table/src/useLegacyTable.ts:171](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L171) +Defined in: [src/useLegacyTable.ts:171](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L171) #### byNameLength diff --git a/docs/framework/react/reference/legacy/interfaces/LegacyRowModelOptions.md b/docs/framework/react/reference/legacy/interfaces/LegacyRowModelOptions.md index 1ae87beee9..309c8677c2 100644 --- a/docs/framework/react/reference/legacy/interfaces/LegacyRowModelOptions.md +++ b/docs/framework/react/reference/legacy/interfaces/LegacyRowModelOptions.md @@ -3,9 +3,7 @@ id: LegacyRowModelOptions title: LegacyRowModelOptions --- -# Interface: LegacyRowModelOptions\ - -Defined in: [react-table/src/useLegacyTable.ts:208](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L208) +Defined in: [src/useLegacyTable.ts:208](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L208) Legacy v8-style row model options @@ -20,10 +18,10 @@ Legacy v8-style row model options ### ~~aggregationFns?~~ ```ts -optional aggregationFns: AggregationFns; +optional aggregationFns?: AggregationFns; ``` -Defined in: [react-table/src/useLegacyTable.ts:268](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L268) +Defined in: [src/useLegacyTable.ts:268](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L268) Additional aggregation functions to apply to the table. @@ -36,10 +34,10 @@ Use `rowAggregationFeature` with the `aggregationFns` slot instead. Add `columnG ### ~~filterFns?~~ ```ts -optional filterFns: FilterFns; +optional filterFns?: FilterFns; ``` -Defined in: [react-table/src/useLegacyTable.ts:258](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L258) +Defined in: [src/useLegacyTable.ts:258](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L258) Additional filter functions to apply to the table. @@ -52,10 +50,10 @@ Use the `filteredRowModel`/`filterFns` slots on the `features` option with `crea ### ~~getCoreRowModel?~~ ```ts -optional getCoreRowModel: RowModelFactory; +optional getCoreRowModel?: RowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:213](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L213) +Defined in: [src/useLegacyTable.ts:213](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L213) Returns the core row model for the table. @@ -68,10 +66,10 @@ This option is no longer needed in v9. The core row model is always created auto ### ~~getExpandedRowModel?~~ ```ts -optional getExpandedRowModel: RowModelFactory; +optional getExpandedRowModel?: RowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:233](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L233) +Defined in: [src/useLegacyTable.ts:233](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L233) Returns the expanded row model for the table. @@ -84,10 +82,10 @@ Use the `expandedRowModel` slot on the `features` option with `createExpandedRow ### ~~getFacetedMinMaxValues?~~ ```ts -optional getFacetedMinMaxValues: FacetedMinMaxValuesFactory; +optional getFacetedMinMaxValues?: FacetedMinMaxValuesFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:248](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L248) +Defined in: [src/useLegacyTable.ts:248](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L248) Returns the faceted min/max values for a column. @@ -100,10 +98,10 @@ Use the `facetedMinMaxValues` slot on the `features` option with `createFacetedM ### ~~getFacetedRowModel?~~ ```ts -optional getFacetedRowModel: FacetedRowModelFactory; +optional getFacetedRowModel?: FacetedRowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:243](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L243) +Defined in: [src/useLegacyTable.ts:243](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L243) Returns the faceted row model for a column. @@ -116,10 +114,10 @@ Use the `facetedRowModel` slot on the `features` option with `createFacetedRowMo ### ~~getFacetedUniqueValues?~~ ```ts -optional getFacetedUniqueValues: FacetedUniqueValuesFactory; +optional getFacetedUniqueValues?: FacetedUniqueValuesFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:253](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L253) +Defined in: [src/useLegacyTable.ts:253](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L253) Returns the faceted unique values for a column. @@ -132,10 +130,10 @@ Use the `facetedUniqueValues` slot on the `features` option with `createFacetedU ### ~~getFilteredRowModel?~~ ```ts -optional getFilteredRowModel: RowModelFactory; +optional getFilteredRowModel?: RowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:218](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L218) +Defined in: [src/useLegacyTable.ts:218](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L218) Returns the filtered row model for the table. @@ -148,10 +146,10 @@ Use the `filteredRowModel`/`filterFns` slots on the `features` option with `crea ### ~~getGroupedRowModel?~~ ```ts -optional getGroupedRowModel: RowModelFactory; +optional getGroupedRowModel?: RowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:238](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L238) +Defined in: [src/useLegacyTable.ts:238](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L238) Returns the grouped row model for the table. @@ -164,10 +162,10 @@ Use `columnGroupingFeature` with the `groupedRowModel` slot and `createGroupedRo ### ~~getPaginationRowModel?~~ ```ts -optional getPaginationRowModel: RowModelFactory; +optional getPaginationRowModel?: RowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:228](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L228) +Defined in: [src/useLegacyTable.ts:228](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L228) Returns the paginated row model for the table. @@ -180,10 +178,10 @@ Use the `paginatedRowModel` slot on the `features` option with `createPaginatedR ### ~~getSortedRowModel?~~ ```ts -optional getSortedRowModel: RowModelFactory; +optional getSortedRowModel?: RowModelFactory; ``` -Defined in: [react-table/src/useLegacyTable.ts:223](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L223) +Defined in: [src/useLegacyTable.ts:223](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L223) Returns the sorted row model for the table. @@ -196,10 +194,10 @@ Use the `sortedRowModel`/`sortFns` slots on the `features` option with `createSo ### ~~sortFns?~~ ```ts -optional sortFns: SortFns; +optional sortFns?: SortFns; ``` -Defined in: [react-table/src/useLegacyTable.ts:263](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L263) +Defined in: [src/useLegacyTable.ts:263](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L263) Additional sort functions to apply to the table. diff --git a/docs/framework/react/reference/legacy/type-aliases/FacetedMinMaxValuesFactory.md b/docs/framework/react/reference/legacy/type-aliases/FacetedMinMaxValuesFactory.md index 7dbc87037a..3da5229a43 100644 --- a/docs/framework/react/reference/legacy/type-aliases/FacetedMinMaxValuesFactory.md +++ b/docs/framework/react/reference/legacy/type-aliases/FacetedMinMaxValuesFactory.md @@ -3,13 +3,11 @@ id: FacetedMinMaxValuesFactory title: FacetedMinMaxValuesFactory --- -# Type Alias: FacetedMinMaxValuesFactory()\ - ```ts type FacetedMinMaxValuesFactory = (table, columnId) => () => undefined | [number, number]; ``` -Defined in: [react-table/src/useLegacyTable.ts:192](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L192) +Defined in: [src/useLegacyTable.ts:192](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L192) Faceted min/max values factory function type from v8 API @@ -31,10 +29,4 @@ Faceted min/max values factory function type from v8 API ## Returns -```ts -(): undefined | [number, number]; -``` - -### Returns - -`undefined` \| \[`number`, `number`\] +() => `undefined` \| \[`number`, `number`\] diff --git a/docs/framework/react/reference/legacy/type-aliases/FacetedRowModelFactory.md b/docs/framework/react/reference/legacy/type-aliases/FacetedRowModelFactory.md index 16b00ad79d..e12ec26c66 100644 --- a/docs/framework/react/reference/legacy/type-aliases/FacetedRowModelFactory.md +++ b/docs/framework/react/reference/legacy/type-aliases/FacetedRowModelFactory.md @@ -3,13 +3,11 @@ id: FacetedRowModelFactory title: FacetedRowModelFactory --- -# Type Alias: FacetedRowModelFactory()\ - ```ts type FacetedRowModelFactory = (table, columnId) => () => RowModel; ``` -Defined in: [react-table/src/useLegacyTable.ts:184](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L184) +Defined in: [src/useLegacyTable.ts:184](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L184) Faceted row model factory function type from v8 API @@ -31,10 +29,4 @@ Faceted row model factory function type from v8 API ## Returns -```ts -(): RowModel; -``` - -### Returns - -`RowModel`\<[`LegacyFeatures`](../interfaces/LegacyFeatures.md), `TData`\> +() => `RowModel`\<[`LegacyFeatures`](../interfaces/LegacyFeatures.md), `TData`\> diff --git a/docs/framework/react/reference/legacy/type-aliases/FacetedUniqueValuesFactory.md b/docs/framework/react/reference/legacy/type-aliases/FacetedUniqueValuesFactory.md index ead5795c42..3d31c6e743 100644 --- a/docs/framework/react/reference/legacy/type-aliases/FacetedUniqueValuesFactory.md +++ b/docs/framework/react/reference/legacy/type-aliases/FacetedUniqueValuesFactory.md @@ -3,13 +3,11 @@ id: FacetedUniqueValuesFactory title: FacetedUniqueValuesFactory --- -# Type Alias: FacetedUniqueValuesFactory()\ - ```ts type FacetedUniqueValuesFactory = (table, columnId) => () => Map; ``` -Defined in: [react-table/src/useLegacyTable.ts:200](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L200) +Defined in: [src/useLegacyTable.ts:200](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L200) Faceted unique values factory function type from v8 API @@ -31,10 +29,4 @@ Faceted unique values factory function type from v8 API ## Returns -```ts -(): Map; -``` - -### Returns - -`Map`\<`any`, `number`\> +() => `Map`\<`any`, `number`\> diff --git a/docs/framework/react/reference/legacy/type-aliases/LegacyCell.md b/docs/framework/react/reference/legacy/type-aliases/LegacyCell.md index ad754da8be..f3aa8ff344 100644 --- a/docs/framework/react/reference/legacy/type-aliases/LegacyCell.md +++ b/docs/framework/react/reference/legacy/type-aliases/LegacyCell.md @@ -3,13 +3,11 @@ id: LegacyCell title: LegacyCell --- -# ~~Type Alias: LegacyCell\~~ - ```ts type LegacyCell = Cell; ``` -Defined in: [react-table/src/useLegacyTable.ts:322](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L322) +Defined in: [src/useLegacyTable.ts:322](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L322) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/type-aliases/LegacyColumn.md b/docs/framework/react/reference/legacy/type-aliases/LegacyColumn.md index ef55881f9c..3341098a43 100644 --- a/docs/framework/react/reference/legacy/type-aliases/LegacyColumn.md +++ b/docs/framework/react/reference/legacy/type-aliases/LegacyColumn.md @@ -3,13 +3,11 @@ id: LegacyColumn title: LegacyColumn --- -# ~~Type Alias: LegacyColumn\~~ - ```ts type LegacyColumn = Column; ``` -Defined in: [react-table/src/useLegacyTable.ts:312](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L312) +Defined in: [src/useLegacyTable.ts:312](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L312) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/type-aliases/LegacyColumnDef.md b/docs/framework/react/reference/legacy/type-aliases/LegacyColumnDef.md index 3b77358239..318a3edf78 100644 --- a/docs/framework/react/reference/legacy/type-aliases/LegacyColumnDef.md +++ b/docs/framework/react/reference/legacy/type-aliases/LegacyColumnDef.md @@ -3,13 +3,11 @@ id: LegacyColumnDef title: LegacyColumnDef --- -# ~~Type Alias: LegacyColumnDef\~~ - ```ts type LegacyColumnDef = ColumnDef; ``` -Defined in: [react-table/src/useLegacyTable.ts:342](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L342) +Defined in: [src/useLegacyTable.ts:342](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L342) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/type-aliases/LegacyHeader.md b/docs/framework/react/reference/legacy/type-aliases/LegacyHeader.md index d43c6e3a0d..f1a383cddc 100644 --- a/docs/framework/react/reference/legacy/type-aliases/LegacyHeader.md +++ b/docs/framework/react/reference/legacy/type-aliases/LegacyHeader.md @@ -3,13 +3,11 @@ id: LegacyHeader title: LegacyHeader --- -# ~~Type Alias: LegacyHeader\~~ - ```ts type LegacyHeader = Header; ``` -Defined in: [react-table/src/useLegacyTable.ts:329](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L329) +Defined in: [src/useLegacyTable.ts:329](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L329) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/type-aliases/LegacyHeaderGroup.md b/docs/framework/react/reference/legacy/type-aliases/LegacyHeaderGroup.md index 5b745508b4..adf2eaf360 100644 --- a/docs/framework/react/reference/legacy/type-aliases/LegacyHeaderGroup.md +++ b/docs/framework/react/reference/legacy/type-aliases/LegacyHeaderGroup.md @@ -3,13 +3,11 @@ id: LegacyHeaderGroup title: LegacyHeaderGroup --- -# ~~Type Alias: LegacyHeaderGroup\~~ - ```ts type LegacyHeaderGroup = HeaderGroup; ``` -Defined in: [react-table/src/useLegacyTable.ts:336](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L336) +Defined in: [src/useLegacyTable.ts:336](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L336) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/type-aliases/LegacyReactTable.md b/docs/framework/react/reference/legacy/type-aliases/LegacyReactTable.md index 9c72c80527..91e2ff5449 100644 --- a/docs/framework/react/reference/legacy/type-aliases/LegacyReactTable.md +++ b/docs/framework/react/reference/legacy/type-aliases/LegacyReactTable.md @@ -3,19 +3,17 @@ id: LegacyReactTable title: LegacyReactTable --- -# ~~Type Alias: LegacyReactTable\~~ - ```ts type LegacyReactTable = ReactTable> & object; ``` -Defined in: [react-table/src/useLegacyTable.ts:290](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L290) +Defined in: [src/useLegacyTable.ts:290](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L290) Legacy table instance type that includes the v8-style `getState()` method. ## Type Declaration -### ~~getState()~~ +### ~~getState~~ ```ts getState: () => TableState; @@ -31,7 +29,7 @@ Returns the current table state. In v9, access state directly via `table.state` or use `table.state` for the full state. -### ~~setState()~~ +### ~~setState~~ ```ts setState: (state) => void; diff --git a/docs/framework/react/reference/legacy/type-aliases/LegacyRow.md b/docs/framework/react/reference/legacy/type-aliases/LegacyRow.md index f0b2c91346..e8d07d94cb 100644 --- a/docs/framework/react/reference/legacy/type-aliases/LegacyRow.md +++ b/docs/framework/react/reference/legacy/type-aliases/LegacyRow.md @@ -3,13 +3,11 @@ id: LegacyRow title: LegacyRow --- -# ~~Type Alias: LegacyRow\~~ - ```ts type LegacyRow = Row; ``` -Defined in: [react-table/src/useLegacyTable.ts:319](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L319) +Defined in: [src/useLegacyTable.ts:319](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L319) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/type-aliases/LegacyTable.md b/docs/framework/react/reference/legacy/type-aliases/LegacyTable.md index 97b4fa1ced..d9f372ec79 100644 --- a/docs/framework/react/reference/legacy/type-aliases/LegacyTable.md +++ b/docs/framework/react/reference/legacy/type-aliases/LegacyTable.md @@ -3,13 +3,11 @@ id: LegacyTable title: LegacyTable --- -# ~~Type Alias: LegacyTable\~~ - ```ts type LegacyTable = Table; ``` -Defined in: [react-table/src/useLegacyTable.ts:348](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L348) +Defined in: [src/useLegacyTable.ts:348](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L348) ## Type Parameters diff --git a/docs/framework/react/reference/legacy/type-aliases/LegacyTableOptions.md b/docs/framework/react/reference/legacy/type-aliases/LegacyTableOptions.md index 84a62daeb2..3dd493c589 100644 --- a/docs/framework/react/reference/legacy/type-aliases/LegacyTableOptions.md +++ b/docs/framework/react/reference/legacy/type-aliases/LegacyTableOptions.md @@ -3,13 +3,11 @@ id: LegacyTableOptions title: LegacyTableOptions --- -# ~~Type Alias: LegacyTableOptions\~~ - ```ts type LegacyTableOptions = Omit, "features"> & LegacyRowModelOptions; ``` -Defined in: [react-table/src/useLegacyTable.ts:279](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L279) +Defined in: [src/useLegacyTable.ts:279](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L279) Legacy v8-style table options that work with useLegacyTable. diff --git a/docs/framework/react/reference/legacy/type-aliases/RowModelFactory.md b/docs/framework/react/reference/legacy/type-aliases/RowModelFactory.md index 2a17377281..f5faad4a30 100644 --- a/docs/framework/react/reference/legacy/type-aliases/RowModelFactory.md +++ b/docs/framework/react/reference/legacy/type-aliases/RowModelFactory.md @@ -3,13 +3,11 @@ id: RowModelFactory title: RowModelFactory --- -# Type Alias: RowModelFactory()\ - ```ts type RowModelFactory = (table) => () => RowModel; ``` -Defined in: [react-table/src/useLegacyTable.ts:177](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L177) +Defined in: [src/useLegacyTable.ts:177](https://github.com/TanStack/table/blob/main/packages/react-table/src/useLegacyTable.ts#L177) Row model factory function type from v8 API @@ -27,10 +25,4 @@ Row model factory function type from v8 API ## Returns -```ts -(): RowModel; -``` - -### Returns - -`RowModel`\<[`LegacyFeatures`](../interfaces/LegacyFeatures.md), `TData`\> +() => `RowModel`\<[`LegacyFeatures`](../interfaces/LegacyFeatures.md), `TData`\> diff --git a/docs/framework/solid/guide/column-filtering.md b/docs/framework/solid/guide/column-filtering.md index 40362d45ee..c17cd32ac0 100644 --- a/docs/framework/solid/guide/column-filtering.md +++ b/docs/framework/solid/guide/column-filtering.md @@ -133,7 +133,7 @@ Since the column filter state is an array of objects, you can have multiple colu #### Accessing Column Filter State -In Solid, the table's state atoms are backed by Solid signals, so `table.atoms.columnFilters.get()` is a reactive read when called inside a tracked scope (JSX, `createMemo`, `createEffect`, or `table.Subscribe`). In event handlers or other untracked code, the same call simply returns the current value. +In Solid, the table's state atoms are backed by Solid signals, so `table.atoms.columnFilters.get()` is a reactive read when called inside a tracked scope (JSX, `createMemo`, or `createEffect`). In event handlers or other untracked code, the same call simply returns the current value. ```tsx const table = createTable({ diff --git a/docs/framework/solid/guide/global-filtering.md b/docs/framework/solid/guide/global-filtering.md index f96db6ebe5..83762cb88f 100644 --- a/docs/framework/solid/guide/global-filtering.md +++ b/docs/framework/solid/guide/global-filtering.md @@ -147,7 +147,7 @@ You can also define your own custom global filter function and pass it directly ### Global Filter State -The `globalFilter` state slice holds the current global filter value, usually a search string (the slice is typed as `any` so custom global filter functions can accept other value shapes). In Solid, the table's state atoms are backed by Solid signals, so `table.atoms.globalFilter.get()` is a reactive read when called inside a tracked scope (JSX, `createMemo`, `createEffect`, or `table.Subscribe`). In event handlers, the same call simply returns the current value. +The `globalFilter` state slice holds the current global filter value, usually a search string (the slice is typed as `any` so custom global filter functions can accept other value shapes). In Solid, the table's state atoms are backed by Solid signals, so `table.atoms.globalFilter.get()` is a reactive read when called inside a tracked scope (JSX, `createMemo`, or `createEffect`). In event handlers, the same call simply returns the current value. If you need access to the global filter state outside of the table, you can own the slice yourself. The recommended way in v9 is an external atom passed through the `atoms` table option. Atoms preserve fine-grained subscriptions, and the filter value can be used elsewhere (such as in a query key for server-side filtering) without making the table depend on component-local state. diff --git a/docs/framework/solid/guide/migrating.md b/docs/framework/solid/guide/migrating.md index 1d57ee11a1..6cbc086296 100644 --- a/docs/framework/solid/guide/migrating.md +++ b/docs/framework/solid/guide/migrating.md @@ -15,7 +15,7 @@ TanStack Table V9 delivers major performance improvements, hundreds of bug fixes ### 2. State Management Overhaul - **TanStack Store foundation**: State is backed by TanStack Store atoms with Solid-aware reactivity. -- **Solid-native reads**: Atom reads participate in Solid tracking when called inside JSX, `createMemo`, `createEffect`, or `table.Subscribe`. +- **Solid-native reads**: Atom reads participate in Solid tracking when called inside JSX, `createMemo`, or `createEffect`. - **External atoms**: Apps can own individual slices with atoms from `@tanstack/solid-store`. ### 3. Type-Safety Improvements @@ -295,12 +295,12 @@ Because these methods now live on the prototype, they also do not appear as own Solid v9 uses table atoms backed by Solid primitives. Prefer narrow atom reads or Solid memos over broad whole-state reads. -| Surface | Use | -| --------------------------- | --------------------------------------------------------------------------------------------- | -| `table.atoms..get()` | Narrow reactive reads inside Solid tracking scopes. | -| `table.store.get()` | Current full state snapshot. Use mostly for debug output or intentionally broad dependencies. | -| `table.Subscribe` | A Solid render boundary whose child reads the atoms it needs. | -| `table.baseAtoms.` | Internal writable atoms. Prefer feature APIs or external atoms. | +| Surface | Use | +| --------------------------- | ---------------------------------------------------------------------------------------------- | +| `table.atoms..get()` | Narrow reactive reads inside Solid tracking scopes. | +| `table.store.get()` | Current full state snapshot. Use mostly for debug output or intentionally broad dependencies. | +| `table.Subscribe` | Deprecated compatibility wrapper. Read table APIs or atoms directly in JSX, memos, or effects. | +| `table.baseAtoms.` | Internal writable atoms. Prefer feature APIs or external atoms. | ### Accessing State @@ -335,16 +335,16 @@ Atom reads can also be used directly in JSX: ``` -### Fine-grained Updates with `table.Subscribe` +### Replace `table.Subscribe` -`table.Subscribe` passes `table.atoms` to its child function. As with any Solid component, the child function body runs once and is untracked, so read atoms inside JSX expressions (or thunks called from JSX) for Solid to track them. +`table.Subscribe` is deprecated. It only passes `table.atoms` to its child function and creates no subscription or tracking scope. Remove the wrapper and read atoms directly inside JSX, `createMemo`, or `createEffect`: ```tsx - - {(atoms) => Page {atoms.pagination.get().pageIndex + 1}} - +Page {table.atoms.pagination.get().pageIndex + 1} ``` +Solid tracks these reads natively. Component bodies run once, so keep reactive reads inside a tracked scope. + ### Controlled State The v8-style `state` + `on[State]Change` controlled state patterns still work and remain convenient for simple integrations. For new v9 code, prefer owning state slices with external atoms (see [External Atoms](#external-atoms) below), which give you fine-grained subscriptions without mirroring state through signals. If you do control state with signals, use getters in `state` so Solid tracks the current signal values. diff --git a/docs/framework/solid/guide/pagination.md b/docs/framework/solid/guide/pagination.md index 0f74f04c50..73297fbd05 100644 --- a/docs/framework/solid/guide/pagination.md +++ b/docs/framework/solid/guide/pagination.md @@ -222,7 +222,7 @@ The `pagination` state is an object that contains the following properties: - `pageIndex`: The current page index (zero-based). - `pageSize`: The current page size. -In Solid, the table's state atoms are backed by Solid signals, so `table.atoms.pagination.get()` is a reactive read when called inside a tracked scope (JSX, `createMemo`, `createEffect`, or `table.Subscribe`). In event handlers, the same call simply returns the current value. +In Solid, the table's state atoms are backed by Solid signals, so `table.atoms.pagination.get()` is a reactive read when called inside a tracked scope (JSX, `createMemo`, or `createEffect`). In event handlers, the same call simply returns the current value. If you need access to the `pagination` state outside of the table (a server-side query key is the most common case), you can own the slice yourself. The recommended way in v9 is an external atom passed through the `atoms` table option. Atoms preserve fine-grained subscriptions, and the pagination value can be used in a query key without making the table depend on component-local state. diff --git a/docs/framework/solid/guide/row-selection.md b/docs/framework/solid/guide/row-selection.md index 9e9ef99294..b7588da736 100644 --- a/docs/framework/solid/guide/row-selection.md +++ b/docs/framework/solid/guide/row-selection.md @@ -52,7 +52,7 @@ console.log(table.getFilteredSelectedRowModel().rows) //get filtered client-side console.log(table.getGroupedSelectedRowModel().rows) //get grouped client-side selected rows ``` -In Solid, the table's state atoms are backed by Solid signals, so `table.atoms.rowSelection.get()` is a reactive read when called inside a tracked scope (JSX, `createMemo`, `createEffect`, or `table.Subscribe`). In event handlers or other untracked code, the same call simply returns the current value. +In Solid, the table's state atoms are backed by Solid signals, so `table.atoms.rowSelection.get()` is a reactive read when called inside a tracked scope (JSX, `createMemo`, or `createEffect`). In event handlers or other untracked code, the same call simply returns the current value. > [!NOTE] > If you are using `manualPagination`, be aware that the `getSelectedRowModel` API will only return selected rows on the current page because table row models can only generate rows based on the `data` that is passed in. Row selection state, however, can contain row ids that are not present in the `data` array just fine. diff --git a/docs/framework/solid/guide/sorting.md b/docs/framework/solid/guide/sorting.md index a837f7c356..b555f03aee 100644 --- a/docs/framework/solid/guide/sorting.md +++ b/docs/framework/solid/guide/sorting.md @@ -68,7 +68,7 @@ Since the sorting state is an array, it is possible to sort by multiple columns #### Accessing Sorting State -In Solid, the table's state atoms are backed by Solid signals, so `table.atoms.sorting.get()` is a reactive read when called inside a tracked scope (JSX, `createMemo`, `createEffect`, or `table.Subscribe`). In event handlers or other untracked code, the same call simply returns the current value. `table.store.get()` returns a current full-state snapshot, useful for debugging. +In Solid, the table's state atoms are backed by Solid signals, so `table.atoms.sorting.get()` is a reactive read when called inside a tracked scope (JSX, `createMemo`, or `createEffect`). In event handlers or other untracked code, the same call simply returns the current value. `table.store.get()` returns a current full-state snapshot, useful for debugging. ```tsx const table = createTable({ diff --git a/docs/framework/solid/guide/table-state.md b/docs/framework/solid/guide/table-state.md index 3273a99b15..adfd0ceae9 100644 --- a/docs/framework/solid/guide/table-state.md +++ b/docs/framework/solid/guide/table-state.md @@ -71,7 +71,7 @@ There are two different questions when reading table state: - Do you only need the current value? - Or should a Solid computation update when that value changes? -Use direct atom reads for slice values. Use `table.store.get()` for the current flat state snapshot. Because Solid table atoms are backed by Solid signals and memos, atom reads participate in Solid dependency tracking when they happen inside JSX, `createMemo(...)`, `createEffect(...)`, or `table.Subscribe`. +Use direct atom reads for slice values. Use `table.store.get()` for the current flat state snapshot. Because Solid table atoms are backed by Solid signals and memos, atom reads participate in Solid dependency tracking when they happen inside JSX, `createMemo(...)`, or `createEffect(...)`. #### Reading State @@ -120,56 +120,32 @@ You can use atom reads directly in JSX too: ``` -#### Fine-grained Updates with table.Subscribe +#### Fine-grained updates -Use `table.Subscribe` when you want a specific part of the Solid tree to create a reactive render boundary. Its child function receives `table.atoms`. As with any Solid component, the child function body runs once and is untracked, so perform atom reads inside JSX expressions or in thunks called from JSX; Solid tracks only those reads. +Read table APIs and atoms directly inside JSX. Solid tracks the reads and updates the expressions that depend on them. For derived values outside JSX, use `createMemo` or an accessor called from JSX. -```tsx - - {(atoms) => { - // a thunk: the reads run (and track) when JSX calls it, not in the body - const rows = () => { - atoms.columnFilters.get() - atoms.globalFilter.get() - atoms.pagination.get() - return table.getRowModel().rows - } - - return ( - - {(row) => {/* ... */}} - - ) - }} - -``` +`table.Subscribe` is deprecated. It only passes atoms to its child function and creates no subscription or tracking scope. Remove the wrapper and replace the child function's `atoms` parameter with `table.atoms`. ```tsx - - {(atoms) => ( - - - {(row) => { - const isSelected = () => atoms.rowSelection.get()[row.id] - - return ( - - - - - - ) - }} - - - )} - + + + {(row) => ( + + + + + + )} + + ``` +Keep reactive reads inside JSX, memos, or effects. Reading an atom into a plain variable in a component body captures its current value and does not track updates. + ### Setting Table State You should almost never need to set table state directly. TanStack Table features expose dedicated APIs for interacting with their state, and those APIs are the safest way to make changes. diff --git a/docs/framework/solid/reference/functions/FlexRender-1.md b/docs/framework/solid/reference/functions/FlexRender-1.md index acd8d73b31..dc45941010 100644 --- a/docs/framework/solid/reference/functions/FlexRender-1.md +++ b/docs/framework/solid/reference/functions/FlexRender-1.md @@ -3,8 +3,6 @@ id: FlexRender title: FlexRender --- -# Function: FlexRender() - ```ts function FlexRender(props): Element; ``` diff --git a/docs/framework/solid/reference/functions/createTable.md b/docs/framework/solid/reference/functions/createTable.md index a1c36de618..304aa24535 100644 --- a/docs/framework/solid/reference/functions/createTable.md +++ b/docs/framework/solid/reference/functions/createTable.md @@ -3,19 +3,18 @@ id: createTable title: createTable --- -# Function: createTable() - ```ts function createTable(tableOptions): SolidTable; ``` -Defined in: [createTable.ts:61](https://github.com/TanStack/table/blob/main/packages/solid-table/src/createTable.ts#L61) +Defined in: [createTable.ts:64](https://github.com/TanStack/table/blob/main/packages/solid-table/src/createTable.ts#L64) Creates a Solid table instance backed by Solid-aware TanStack Store atoms. Table APIs and atom reads participate in Solid dependency tracking, so computations that read a specific slice can update without invalidating -unrelated UI. Use `table.Subscribe` to create atom-tracked render boundaries. +unrelated UI. Read table APIs or atoms inside JSX, `createMemo`, or +`createEffect` to track updates. ## Type Parameters diff --git a/docs/framework/solid/reference/functions/createTableHook.md b/docs/framework/solid/reference/functions/createTableHook.md index f3e7faa9bc..c28c7d8f42 100644 --- a/docs/framework/solid/reference/functions/createTableHook.md +++ b/docs/framework/solid/reference/functions/createTableHook.md @@ -3,13 +3,11 @@ id: createTableHook title: createTableHook --- -# Function: createTableHook() - ```ts function createTableHook(__namedParameters): CreateTableHookResult; ``` -Defined in: [createTableHook.tsx:571](https://github.com/TanStack/table/blob/main/packages/solid-table/src/createTableHook.tsx#L571) +Defined in: [createTableHook.tsx:569](https://github.com/TanStack/table/blob/main/packages/solid-table/src/createTableHook.tsx#L569) Creates a custom table hook with pre-bound components for composition. @@ -81,9 +79,7 @@ const columnHelper = createAppColumnHelper() function PaginationControls() { const table = useTableContext() // TFeatures already known! return ( - - {(atoms) => Page {atoms.pagination.get().pageIndex + 1}} - + Page {table.atoms.pagination.get().pageIndex + 1} ) } diff --git a/docs/framework/solid/reference/functions/flexRender.md b/docs/framework/solid/reference/functions/flexRender.md index 76a35f74d1..5b9bf38f0d 100644 --- a/docs/framework/solid/reference/functions/flexRender.md +++ b/docs/framework/solid/reference/functions/flexRender.md @@ -3,8 +3,6 @@ id: flexRender title: flexRender --- -# Function: flexRender() - ```ts function flexRender(Comp, props): Element; ``` @@ -27,7 +25,7 @@ instead. ### Comp -`Element` | (`_props`) => `Element` +`Element` \| ((`_props`) => `Element`) ### props diff --git a/docs/framework/solid/reference/index.md b/docs/framework/solid/reference/index.md index 15e39b72d3..77e25d5f91 100644 --- a/docs/framework/solid/reference/index.md +++ b/docs/framework/solid/reference/index.md @@ -3,8 +3,6 @@ id: "@tanstack/solid-table" title: "@tanstack/solid-table" --- -# @tanstack/solid-table - ## Interfaces - [AppCellComponent](interfaces/AppCellComponent.md) diff --git a/docs/framework/solid/reference/interfaces/AppCellComponent.md b/docs/framework/solid/reference/interfaces/AppCellComponent.md index 5765b5ab9c..e13c5b8e8c 100644 --- a/docs/framework/solid/reference/interfaces/AppCellComponent.md +++ b/docs/framework/solid/reference/interfaces/AppCellComponent.md @@ -3,8 +3,6 @@ id: AppCellComponent title: AppCellComponent --- -# Interface: AppCellComponent()\ - Defined in: [createTableHook.tsx:311](https://github.com/TanStack/table/blob/main/packages/solid-table/src/createTableHook.tsx#L311) Component type for AppCell - wraps a cell and provides cell context. diff --git a/docs/framework/solid/reference/interfaces/AppCellProps.md b/docs/framework/solid/reference/interfaces/AppCellProps.md index 3bc47a007c..cff1ad6420 100644 --- a/docs/framework/solid/reference/interfaces/AppCellProps.md +++ b/docs/framework/solid/reference/interfaces/AppCellProps.md @@ -3,8 +3,6 @@ id: AppCellProps title: AppCellProps --- -# Interface: AppCellProps\ - Defined in: [createTableHook.tsx:279](https://github.com/TanStack/table/blob/main/packages/solid-table/src/createTableHook.tsx#L279) Props for AppCell component. @@ -39,7 +37,7 @@ Defined in: [createTableHook.tsx:285](https://github.com/TanStack/table/blob/mai *** -### children() +### children ```ts children: (cell) => Element; diff --git a/docs/framework/solid/reference/interfaces/AppHeaderComponent.md b/docs/framework/solid/reference/interfaces/AppHeaderComponent.md index 91cbd91d79..d6b0e6051c 100644 --- a/docs/framework/solid/reference/interfaces/AppHeaderComponent.md +++ b/docs/framework/solid/reference/interfaces/AppHeaderComponent.md @@ -3,8 +3,6 @@ id: AppHeaderComponent title: AppHeaderComponent --- -# Interface: AppHeaderComponent()\ - Defined in: [createTableHook.tsx:324](https://github.com/TanStack/table/blob/main/packages/solid-table/src/createTableHook.tsx#L324) Component type for AppHeader/AppFooter - wraps a header and provides header context. diff --git a/docs/framework/solid/reference/interfaces/AppHeaderProps.md b/docs/framework/solid/reference/interfaces/AppHeaderProps.md index e69cafae5b..bb04061954 100644 --- a/docs/framework/solid/reference/interfaces/AppHeaderProps.md +++ b/docs/framework/solid/reference/interfaces/AppHeaderProps.md @@ -3,8 +3,6 @@ id: AppHeaderProps title: AppHeaderProps --- -# Interface: AppHeaderProps\ - Defined in: [createTableHook.tsx:295](https://github.com/TanStack/table/blob/main/packages/solid-table/src/createTableHook.tsx#L295) Props for AppHeader/AppFooter component. @@ -29,7 +27,7 @@ Props for AppHeader/AppFooter component. ## Properties -### children() +### children ```ts children: (header) => Element; diff --git a/docs/framework/solid/reference/interfaces/AppTableComponent.md b/docs/framework/solid/reference/interfaces/AppTableComponent.md index f8989c0a19..46d32d4e9a 100644 --- a/docs/framework/solid/reference/interfaces/AppTableComponent.md +++ b/docs/framework/solid/reference/interfaces/AppTableComponent.md @@ -3,11 +3,9 @@ id: AppTableComponent title: AppTableComponent --- -# Interface: AppTableComponent()\<_TFeatures\> - Defined in: [createTableHook.tsx:337](https://github.com/TanStack/table/blob/main/packages/solid-table/src/createTableHook.tsx#L337) -Component type for AppTable - root wrapper with optional Subscribe +Component type for AppTable - root wrapper that provides table context ## Type Parameters @@ -21,7 +19,7 @@ AppTableComponent(props): Element; Defined in: [createTableHook.tsx:338](https://github.com/TanStack/table/blob/main/packages/solid-table/src/createTableHook.tsx#L338) -Component type for AppTable - root wrapper with optional Subscribe +Component type for AppTable - root wrapper that provides table context ## Parameters diff --git a/docs/framework/solid/reference/interfaces/AppTableProps.md b/docs/framework/solid/reference/interfaces/AppTableProps.md index 8189be0fee..5705fe8533 100644 --- a/docs/framework/solid/reference/interfaces/AppTableProps.md +++ b/docs/framework/solid/reference/interfaces/AppTableProps.md @@ -3,8 +3,6 @@ id: AppTableProps title: AppTableProps --- -# Interface: AppTableProps - Defined in: [createTableHook.tsx:272](https://github.com/TanStack/table/blob/main/packages/solid-table/src/createTableHook.tsx#L272) ## Properties diff --git a/docs/framework/solid/reference/interfaces/CreateTableHookResult.md b/docs/framework/solid/reference/interfaces/CreateTableHookResult.md index 4d5e644cae..075eaf3b2a 100644 --- a/docs/framework/solid/reference/interfaces/CreateTableHookResult.md +++ b/docs/framework/solid/reference/interfaces/CreateTableHookResult.md @@ -3,8 +3,6 @@ id: CreateTableHookResult title: CreateTableHookResult --- -# Interface: CreateTableHookResult\ - Defined in: [createTableHook.tsx:405](https://github.com/TanStack/table/blob/main/packages/solid-table/src/createTableHook.tsx#L405) ## Type Parameters @@ -39,7 +37,7 @@ The features object that was passed to `createTableHook`. *** -### createAppColumnHelper() +### createAppColumnHelper ```ts createAppColumnHelper: () => AppColumnHelper; @@ -62,7 +60,7 @@ the cell/header/footer render props expose the bound components. *** -### createAppTable() +### createAppTable ```ts createAppTable: (tableOptions) => AppSolidTable; @@ -91,7 +89,7 @@ Creates a table with the `App*` wrapper components and registered *** -### useCellContext() +### useCellContext ```ts useCellContext: () => Cell_Core & ExtractFeatureMapTypes & TCellComponents & object; @@ -114,7 +112,7 @@ Reads the cell provided by the nearest ``, extended with your *** -### useHeaderContext() +### useHeaderContext ```ts useHeaderContext: () => Header_Core & ExtractFeatureMapTypes & THeaderComponents & object; @@ -138,7 +136,7 @@ context-bound `FlexRender`. *** -### useTableContext() +### useTableContext ```ts useTableContext: () => AppSolidTable; diff --git a/docs/framework/solid/reference/type-aliases/AppCellContext.md b/docs/framework/solid/reference/type-aliases/AppCellContext.md index 6d75083acc..9ad2cc4a01 100644 --- a/docs/framework/solid/reference/type-aliases/AppCellContext.md +++ b/docs/framework/solid/reference/type-aliases/AppCellContext.md @@ -3,8 +3,6 @@ id: AppCellContext title: AppCellContext --- -# Type Alias: AppCellContext\ - ```ts type AppCellContext = object; ``` @@ -44,7 +42,7 @@ Defined in: [createTableHook.tsx:46](https://github.com/TanStack/table/blob/main #### Type Declaration -##### FlexRender() +##### FlexRender ```ts FlexRender: () => JSXElement; diff --git a/docs/framework/solid/reference/type-aliases/AppColumnDefBase.md b/docs/framework/solid/reference/type-aliases/AppColumnDefBase.md index f214002f04..e38d4c04ab 100644 --- a/docs/framework/solid/reference/type-aliases/AppColumnDefBase.md +++ b/docs/framework/solid/reference/type-aliases/AppColumnDefBase.md @@ -3,8 +3,6 @@ id: AppColumnDefBase title: AppColumnDefBase --- -# Type Alias: AppColumnDefBase\ - ```ts type AppColumnDefBase = Omit, "cell" | "header" | "footer"> & object; ``` @@ -18,19 +16,19 @@ Enhanced column definition base with pre-bound components in cell/header/footer ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/solid/reference/type-aliases/AppColumnDefTemplate.md b/docs/framework/solid/reference/type-aliases/AppColumnDefTemplate.md index 6cf56656da..f7cb5db96e 100644 --- a/docs/framework/solid/reference/type-aliases/AppColumnDefTemplate.md +++ b/docs/framework/solid/reference/type-aliases/AppColumnDefTemplate.md @@ -3,10 +3,8 @@ id: AppColumnDefTemplate title: AppColumnDefTemplate --- -# Type Alias: AppColumnDefTemplate\ - ```ts -type AppColumnDefTemplate = string | (props) => any; +type AppColumnDefTemplate = string | ((props) => any); ``` Defined in: [createTableHook.tsx:78](https://github.com/TanStack/table/blob/main/packages/solid-table/src/createTableHook.tsx#L78) diff --git a/docs/framework/solid/reference/type-aliases/AppColumnHelper.md b/docs/framework/solid/reference/type-aliases/AppColumnHelper.md index 4620cee8b2..5af9140668 100644 --- a/docs/framework/solid/reference/type-aliases/AppColumnHelper.md +++ b/docs/framework/solid/reference/type-aliases/AppColumnHelper.md @@ -3,8 +3,6 @@ id: AppColumnHelper title: AppColumnHelper --- -# Type Alias: AppColumnHelper\ - ```ts type AppColumnHelper = object; ``` @@ -34,7 +32,7 @@ This enables TypeScript to know about the registered components when defining co ## Properties -### accessor() +### accessor ```ts accessor: (accessor, column) => TAccessor extends AccessorFn ? AccessorFnColumnDef : AccessorKeyColumnDef; @@ -71,7 +69,7 @@ The cell, header, and footer contexts include pre-bound components. *** -### columns() +### columns ```ts columns: (columns) => ColumnDef[] & [...TColumns]; @@ -99,7 +97,7 @@ Wraps an array of column definitions to preserve each column's individual TValue *** -### display() +### display ```ts display: (column) => DisplayColumnDef; @@ -122,7 +120,7 @@ The cell, header, and footer contexts include pre-bound components. *** -### group() +### group ```ts group: (column) => GroupColumnDef; diff --git a/docs/framework/solid/reference/type-aliases/AppDisplayColumnDef.md b/docs/framework/solid/reference/type-aliases/AppDisplayColumnDef.md index 59704dc0f5..76e1b49697 100644 --- a/docs/framework/solid/reference/type-aliases/AppDisplayColumnDef.md +++ b/docs/framework/solid/reference/type-aliases/AppDisplayColumnDef.md @@ -3,8 +3,6 @@ id: AppDisplayColumnDef title: AppDisplayColumnDef --- -# Type Alias: AppDisplayColumnDef\ - ```ts type AppDisplayColumnDef = Omit, "cell" | "header" | "footer"> & object; ``` @@ -18,19 +16,19 @@ Enhanced display column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/solid/reference/type-aliases/AppGroupColumnDef.md b/docs/framework/solid/reference/type-aliases/AppGroupColumnDef.md index f3d6a50bad..9030995b54 100644 --- a/docs/framework/solid/reference/type-aliases/AppGroupColumnDef.md +++ b/docs/framework/solid/reference/type-aliases/AppGroupColumnDef.md @@ -3,8 +3,6 @@ id: AppGroupColumnDef title: AppGroupColumnDef --- -# Type Alias: AppGroupColumnDef\ - ```ts type AppGroupColumnDef = Omit, "cell" | "header" | "footer" | "columns"> & object; ``` @@ -18,25 +16,25 @@ Enhanced group column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### columns? ```ts -optional columns: ReadonlyArray>; +optional columns?: ReadonlyArray>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/solid/reference/type-aliases/AppHeaderContext.md b/docs/framework/solid/reference/type-aliases/AppHeaderContext.md index 78bfb65852..db23504e6d 100644 --- a/docs/framework/solid/reference/type-aliases/AppHeaderContext.md +++ b/docs/framework/solid/reference/type-aliases/AppHeaderContext.md @@ -3,8 +3,6 @@ id: AppHeaderContext title: AppHeaderContext --- -# Type Alias: AppHeaderContext\ - ```ts type AppHeaderContext = object; ``` @@ -54,7 +52,7 @@ Defined in: [createTableHook.tsx:66](https://github.com/TanStack/table/blob/main #### Type Declaration -##### FlexRender() +##### FlexRender ```ts FlexRender: () => JSXElement; diff --git a/docs/framework/solid/reference/type-aliases/AppSolidTable.md b/docs/framework/solid/reference/type-aliases/AppSolidTable.md index 0c5777d22a..b5119eccbe 100644 --- a/docs/framework/solid/reference/type-aliases/AppSolidTable.md +++ b/docs/framework/solid/reference/type-aliases/AppSolidTable.md @@ -3,8 +3,6 @@ id: AppSolidTable title: AppSolidTable --- -# Type Alias: AppSolidTable\ - ```ts type AppSolidTable = SolidTable & NoInfer & object; ``` diff --git a/docs/framework/solid/reference/type-aliases/ComponentType.md b/docs/framework/solid/reference/type-aliases/ComponentType.md index 21580b21f4..d9b80b3173 100644 --- a/docs/framework/solid/reference/type-aliases/ComponentType.md +++ b/docs/framework/solid/reference/type-aliases/ComponentType.md @@ -3,8 +3,6 @@ id: ComponentType title: ComponentType --- -# Type Alias: ComponentType\ - ```ts type ComponentType = Component; ``` diff --git a/docs/framework/solid/reference/type-aliases/CreateTableHookOptions.md b/docs/framework/solid/reference/type-aliases/CreateTableHookOptions.md index e858c66e39..c9bd1f51ec 100644 --- a/docs/framework/solid/reference/type-aliases/CreateTableHookOptions.md +++ b/docs/framework/solid/reference/type-aliases/CreateTableHookOptions.md @@ -3,8 +3,6 @@ id: CreateTableHookOptions title: CreateTableHookOptions --- -# Type Alias: CreateTableHookOptions\ - ```ts type CreateTableHookOptions = Omit, "columns" | "data" | "store" | "state" | "initialState"> & object; ``` @@ -19,7 +17,7 @@ Extends all TableOptions except 'columns' | 'data' | 'store' | 'state' | 'initia ### cellComponents? ```ts -optional cellComponents: TCellComponents; +optional cellComponents?: TCellComponents; ``` Cell-level components that need access to the cell instance. @@ -35,7 +33,7 @@ Use `useCellContext()` inside these components. ### headerComponents? ```ts -optional headerComponents: THeaderComponents; +optional headerComponents?: THeaderComponents; ``` Header-level components that need access to the header instance. @@ -51,7 +49,7 @@ Use `useHeaderContext()` inside these components. ### tableComponents? ```ts -optional tableComponents: TTableComponents; +optional tableComponents?: TTableComponents; ``` Table-level components that need access to the table instance. diff --git a/docs/framework/solid/reference/type-aliases/FlexRenderProps.md b/docs/framework/solid/reference/type-aliases/FlexRenderProps.md index baada4bad3..da1ef2fe4a 100644 --- a/docs/framework/solid/reference/type-aliases/FlexRenderProps.md +++ b/docs/framework/solid/reference/type-aliases/FlexRenderProps.md @@ -3,8 +3,6 @@ id: FlexRenderProps title: FlexRenderProps --- -# Type Alias: FlexRenderProps\ - ```ts type FlexRenderProps = | { diff --git a/docs/framework/solid/reference/type-aliases/SolidTable.md b/docs/framework/solid/reference/type-aliases/SolidTable.md index 981d6d6fcb..c37c0fc438 100644 --- a/docs/framework/solid/reference/type-aliases/SolidTable.md +++ b/docs/framework/solid/reference/type-aliases/SolidTable.md @@ -3,8 +3,6 @@ id: SolidTable title: SolidTable --- -# Type Alias: SolidTable\ - ```ts type SolidTable = Table & object; ``` @@ -31,15 +29,12 @@ rendering headers, cells, or footers with custom markup. Mirrors the ``` -### Subscribe() +### ~~Subscribe~~ ```ts Subscribe: (props) => JSX.Element; ``` -Creates a reactive render boundary. The child function reads the table -atoms it needs, so Solid only tracks those atom reads. - #### Parameters ##### props @@ -52,6 +47,13 @@ atoms it needs, so Solid only tracks those atom reads. `JSX.Element` +#### Deprecated + +Read table APIs or `table.atoms` directly inside JSX, +`createMemo`, or `createEffect`. Solid tracks those reads natively. +This compatibility wrapper only passes atoms to its child function; +it does not create a subscription or tracking scope. + ## Type Parameters ### TFeatures diff --git a/docs/framework/svelte/reference/functions/createTable.md b/docs/framework/svelte/reference/functions/createTable.md index 77306b22eb..bc31c38a94 100644 --- a/docs/framework/svelte/reference/functions/createTable.md +++ b/docs/framework/svelte/reference/functions/createTable.md @@ -3,8 +3,6 @@ id: createTable title: createTable --- -# Function: createTable() - ```ts function createTable(tableOptions): SvelteTable; ``` diff --git a/docs/framework/svelte/reference/functions/createTableHook.md b/docs/framework/svelte/reference/functions/createTableHook.md index ccdf62f84d..016dafdeaa 100644 --- a/docs/framework/svelte/reference/functions/createTableHook.md +++ b/docs/framework/svelte/reference/functions/createTableHook.md @@ -3,8 +3,6 @@ id: createTableHook title: createTableHook --- -# Function: createTableHook() - ```ts function createTableHook(__namedParameters): CreateTableHookResult; ``` diff --git a/docs/framework/svelte/reference/functions/createTableState.md b/docs/framework/svelte/reference/functions/createTableState.md index d4c22f79ff..9182449c01 100644 --- a/docs/framework/svelte/reference/functions/createTableState.md +++ b/docs/framework/svelte/reference/functions/createTableState.md @@ -3,8 +3,6 @@ id: createTableState title: createTableState --- -# Function: createTableState() - ```ts function createTableState(initialValue): [() => TState, (updater) => void]; ``` diff --git a/docs/framework/svelte/reference/functions/renderComponent.md b/docs/framework/svelte/reference/functions/renderComponent.md index 6a83088152..f037078eb7 100644 --- a/docs/framework/svelte/reference/functions/renderComponent.md +++ b/docs/framework/svelte/reference/functions/renderComponent.md @@ -3,8 +3,6 @@ id: renderComponent title: renderComponent --- -# Function: renderComponent() - ```ts function renderComponent(component, props?): RenderComponentConfig; ``` diff --git a/docs/framework/svelte/reference/functions/renderSnippet.md b/docs/framework/svelte/reference/functions/renderSnippet.md index 030a61b0a2..ff96e6cd64 100644 --- a/docs/framework/svelte/reference/functions/renderSnippet.md +++ b/docs/framework/svelte/reference/functions/renderSnippet.md @@ -3,8 +3,6 @@ id: renderSnippet title: renderSnippet --- -# Function: renderSnippet() - ```ts function renderSnippet(snippet, params?): RenderSnippetConfig; ``` diff --git a/docs/framework/svelte/reference/index.md b/docs/framework/svelte/reference/index.md index 7d73aa4813..8a7162e71d 100644 --- a/docs/framework/svelte/reference/index.md +++ b/docs/framework/svelte/reference/index.md @@ -3,8 +3,6 @@ id: "@tanstack/svelte-table" title: "@tanstack/svelte-table" --- -# @tanstack/svelte-table - ## Interfaces - [CreateTableHookResult](interfaces/CreateTableHookResult.md) diff --git a/docs/framework/svelte/reference/interfaces/CreateTableHookResult.md b/docs/framework/svelte/reference/interfaces/CreateTableHookResult.md index b08d01b762..6742a526c9 100644 --- a/docs/framework/svelte/reference/interfaces/CreateTableHookResult.md +++ b/docs/framework/svelte/reference/interfaces/CreateTableHookResult.md @@ -3,8 +3,6 @@ id: CreateTableHookResult title: CreateTableHookResult --- -# Interface: CreateTableHookResult\ - Defined in: [packages/svelte-table/src/createTableHook.svelte.ts:377](https://github.com/TanStack/table/blob/main/packages/svelte-table/src/createTableHook.svelte.ts#L377) ## Type Parameters @@ -39,7 +37,7 @@ The features object that was passed to `createTableHook`. *** -### createAppColumnHelper() +### createAppColumnHelper ```ts createAppColumnHelper: () => AppColumnHelper; @@ -62,7 +60,7 @@ the cell/header/footer render props expose the bound components. *** -### createAppTable() +### createAppTable ```ts createAppTable: (tableOptions) => AppSvelteTable; @@ -95,7 +93,7 @@ These reads participate in Svelte dependency tracking inside templates, *** -### useCellContext() +### useCellContext ```ts useCellContext: () => Cell_Core & ExtractFeatureMapTypes & TCellComponents & object; @@ -118,7 +116,7 @@ Reads the cell provided by the nearest ``, extended with your *** -### useHeaderContext() +### useHeaderContext ```ts useHeaderContext: () => Header_Core & ExtractFeatureMapTypes & THeaderComponents & object; @@ -142,7 +140,7 @@ context-bound `FlexRender`. *** -### useTableContext() +### useTableContext ```ts useTableContext: () => AppSvelteTable; diff --git a/docs/framework/svelte/reference/type-aliases/AppCellContext.md b/docs/framework/svelte/reference/type-aliases/AppCellContext.md index d08f34f33d..f6d4852b8e 100644 --- a/docs/framework/svelte/reference/type-aliases/AppCellContext.md +++ b/docs/framework/svelte/reference/type-aliases/AppCellContext.md @@ -3,8 +3,6 @@ id: AppCellContext title: AppCellContext --- -# Type Alias: AppCellContext\ - ```ts type AppCellContext = object; ``` diff --git a/docs/framework/svelte/reference/type-aliases/AppColumnDefBase.md b/docs/framework/svelte/reference/type-aliases/AppColumnDefBase.md index ea73180cce..c170a5412e 100644 --- a/docs/framework/svelte/reference/type-aliases/AppColumnDefBase.md +++ b/docs/framework/svelte/reference/type-aliases/AppColumnDefBase.md @@ -3,8 +3,6 @@ id: AppColumnDefBase title: AppColumnDefBase --- -# Type Alias: AppColumnDefBase\ - ```ts type AppColumnDefBase = Omit, "cell" | "header" | "footer"> & object; ``` @@ -18,19 +16,19 @@ Enhanced column definition base with pre-bound components in cell/header/footer ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/svelte/reference/type-aliases/AppColumnDefTemplate.md b/docs/framework/svelte/reference/type-aliases/AppColumnDefTemplate.md index 8ed9fb67de..7c9ef1910f 100644 --- a/docs/framework/svelte/reference/type-aliases/AppColumnDefTemplate.md +++ b/docs/framework/svelte/reference/type-aliases/AppColumnDefTemplate.md @@ -3,10 +3,8 @@ id: AppColumnDefTemplate title: AppColumnDefTemplate --- -# Type Alias: AppColumnDefTemplate\ - ```ts -type AppColumnDefTemplate = string | (props) => any; +type AppColumnDefTemplate = string | ((props) => any); ``` Defined in: [packages/svelte-table/src/createTableHook.svelte.ts:87](https://github.com/TanStack/table/blob/main/packages/svelte-table/src/createTableHook.svelte.ts#L87) diff --git a/docs/framework/svelte/reference/type-aliases/AppColumnHelper.md b/docs/framework/svelte/reference/type-aliases/AppColumnHelper.md index b915dbc383..e211d1b6c6 100644 --- a/docs/framework/svelte/reference/type-aliases/AppColumnHelper.md +++ b/docs/framework/svelte/reference/type-aliases/AppColumnHelper.md @@ -3,8 +3,6 @@ id: AppColumnHelper title: AppColumnHelper --- -# Type Alias: AppColumnHelper\ - ```ts type AppColumnHelper = object; ``` @@ -34,7 +32,7 @@ This enables TypeScript to know about the registered components when defining co ## Properties -### accessor() +### accessor ```ts accessor: (accessor, column) => TAccessor extends AccessorFn ? AccessorFnColumnDef : AccessorKeyColumnDef; @@ -71,7 +69,7 @@ The cell, header, and footer contexts include pre-bound components. *** -### columns() +### columns ```ts columns: (columns) => ColumnDef[] & [...TColumns]; @@ -99,7 +97,7 @@ Wraps an array of column definitions to preserve each column's individual TValue *** -### display() +### display ```ts display: (column) => DisplayColumnDef; @@ -122,7 +120,7 @@ The cell, header, and footer contexts include pre-bound components. *** -### group() +### group ```ts group: (column) => GroupColumnDef; diff --git a/docs/framework/svelte/reference/type-aliases/AppDisplayColumnDef.md b/docs/framework/svelte/reference/type-aliases/AppDisplayColumnDef.md index 7c07fa433b..2e48940d1a 100644 --- a/docs/framework/svelte/reference/type-aliases/AppDisplayColumnDef.md +++ b/docs/framework/svelte/reference/type-aliases/AppDisplayColumnDef.md @@ -3,8 +3,6 @@ id: AppDisplayColumnDef title: AppDisplayColumnDef --- -# Type Alias: AppDisplayColumnDef\ - ```ts type AppDisplayColumnDef = Omit, "cell" | "header" | "footer"> & object; ``` @@ -18,19 +16,19 @@ Enhanced display column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/svelte/reference/type-aliases/AppGroupColumnDef.md b/docs/framework/svelte/reference/type-aliases/AppGroupColumnDef.md index df893b56cb..212b9ed7fb 100644 --- a/docs/framework/svelte/reference/type-aliases/AppGroupColumnDef.md +++ b/docs/framework/svelte/reference/type-aliases/AppGroupColumnDef.md @@ -3,8 +3,6 @@ id: AppGroupColumnDef title: AppGroupColumnDef --- -# Type Alias: AppGroupColumnDef\ - ```ts type AppGroupColumnDef = Omit, "cell" | "header" | "footer" | "columns"> & object; ``` @@ -18,25 +16,25 @@ Enhanced group column definition with pre-bound components. ### cell? ```ts -optional cell: AppColumnDefTemplate>; +optional cell?: AppColumnDefTemplate>; ``` ### columns? ```ts -optional columns: ReadonlyArray>; +optional columns?: ReadonlyArray>; ``` ### footer? ```ts -optional footer: AppColumnDefTemplate>; +optional footer?: AppColumnDefTemplate>; ``` ### header? ```ts -optional header: AppColumnDefTemplate>; +optional header?: AppColumnDefTemplate>; ``` ## Type Parameters diff --git a/docs/framework/svelte/reference/type-aliases/AppHeaderContext.md b/docs/framework/svelte/reference/type-aliases/AppHeaderContext.md index bda4ac0467..ff1b388b5a 100644 --- a/docs/framework/svelte/reference/type-aliases/AppHeaderContext.md +++ b/docs/framework/svelte/reference/type-aliases/AppHeaderContext.md @@ -3,8 +3,6 @@ id: AppHeaderContext title: AppHeaderContext --- -# Type Alias: AppHeaderContext\ - ```ts type AppHeaderContext = object; ``` diff --git a/docs/framework/svelte/reference/type-aliases/AppSvelteTable.md b/docs/framework/svelte/reference/type-aliases/AppSvelteTable.md index 3468dfde27..4a33d6ceff 100644 --- a/docs/framework/svelte/reference/type-aliases/AppSvelteTable.md +++ b/docs/framework/svelte/reference/type-aliases/AppSvelteTable.md @@ -3,8 +3,6 @@ id: AppSvelteTable title: AppSvelteTable --- -# Type Alias: AppSvelteTable\ - ```ts type AppSvelteTable = SvelteTable & NoInfer & object; ``` diff --git a/docs/framework/svelte/reference/type-aliases/ComponentType.md b/docs/framework/svelte/reference/type-aliases/ComponentType.md index eb16ee6eda..af3164e50b 100644 --- a/docs/framework/svelte/reference/type-aliases/ComponentType.md +++ b/docs/framework/svelte/reference/type-aliases/ComponentType.md @@ -3,8 +3,6 @@ id: ComponentType title: ComponentType --- -# Type Alias: ComponentType\ - ```ts type ComponentType = Component; ``` diff --git a/docs/framework/svelte/reference/type-aliases/CreateTableHookOptions.md b/docs/framework/svelte/reference/type-aliases/CreateTableHookOptions.md index 8d21dfbe3c..c6eaf89b11 100644 --- a/docs/framework/svelte/reference/type-aliases/CreateTableHookOptions.md +++ b/docs/framework/svelte/reference/type-aliases/CreateTableHookOptions.md @@ -3,8 +3,6 @@ id: CreateTableHookOptions title: CreateTableHookOptions --- -# Type Alias: CreateTableHookOptions\ - ```ts type CreateTableHookOptions = Omit, "columns" | "data" | "store" | "state" | "initialState"> & object; ``` @@ -19,7 +17,7 @@ Extends all TableOptions except 'columns' | 'data' | 'store' | 'state' | 'initia ### cellComponents? ```ts -optional cellComponents: TCellComponents; +optional cellComponents?: TCellComponents; ``` Cell-level components that need access to the cell instance. @@ -35,7 +33,7 @@ Use `useCellContext()` inside these components. ### headerComponents? ```ts -optional headerComponents: THeaderComponents; +optional headerComponents?: THeaderComponents; ``` Header-level components that need access to the header instance. @@ -51,7 +49,7 @@ Use `useHeaderContext()` inside these components. ### tableComponents? ```ts -optional tableComponents: TTableComponents; +optional tableComponents?: TTableComponents; ``` Table-level components that need access to the table instance. diff --git a/docs/framework/svelte/reference/type-aliases/FlexRender.md b/docs/framework/svelte/reference/type-aliases/FlexRender.md index a254a400ca..efeda58e12 100644 --- a/docs/framework/svelte/reference/type-aliases/FlexRender.md +++ b/docs/framework/svelte/reference/type-aliases/FlexRender.md @@ -3,10 +3,8 @@ id: FlexRender title: FlexRender --- -# Type Alias: FlexRender - ```ts type FlexRender = SvelteComponent; ``` -Defined in: node\_modules/.pnpm/svelte@5.56.8\_@typescript-eslint+types@8.65.0/node\_modules/svelte/types/index.d.ts:3212 +Defined in: node\_modules/.pnpm/svelte@5.57.1\_@typescript-eslint+types@8.68.0/node\_modules/svelte/types/index.d.ts:3324 diff --git a/docs/framework/svelte/reference/type-aliases/SvelteTable.md b/docs/framework/svelte/reference/type-aliases/SvelteTable.md index 54798d7acd..f2a16492d5 100644 --- a/docs/framework/svelte/reference/type-aliases/SvelteTable.md +++ b/docs/framework/svelte/reference/type-aliases/SvelteTable.md @@ -3,8 +3,6 @@ id: SvelteTable title: SvelteTable --- -# Type Alias: SvelteTable\ - ```ts type SvelteTable = Table; ``` diff --git a/docs/framework/svelte/reference/variables/FlexRender.md b/docs/framework/svelte/reference/variables/FlexRender.md index b397a72915..a4db767b90 100644 --- a/docs/framework/svelte/reference/variables/FlexRender.md +++ b/docs/framework/svelte/reference/variables/FlexRender.md @@ -3,10 +3,8 @@ id: FlexRender title: FlexRender --- -# Variable: FlexRender - ```ts const FlexRender: LegacyComponentType; ``` -Defined in: node\_modules/.pnpm/svelte@5.56.8\_@typescript-eslint+types@8.65.0/node\_modules/svelte/types/index.d.ts:3212 +Defined in: node\_modules/.pnpm/svelte@5.57.1\_@typescript-eslint+types@8.68.0/node\_modules/svelte/types/index.d.ts:3324 diff --git a/docs/framework/vue/guide/cell-selection.md b/docs/framework/vue/guide/cell-selection.md index eb63b0a44f..f1c373508f 100644 --- a/docs/framework/vue/guide/cell-selection.md +++ b/docs/framework/vue/guide/cell-selection.md @@ -36,7 +36,7 @@ The cell selection feature keeps track of spreadsheet-style rectangular selectio The table instance already manages the cell selection state for you. You can access the selection or values derived from it through a few APIs. -- `table.atoms.cellSelection.get()` - returns the current cell selection (reactive inside templates, `computed(...)`, `watch(...)`, and `table.Subscribe`; a plain snapshot elsewhere) +- `table.atoms.cellSelection.get()` - returns the current cell selection (reactive inside templates, `computed(...)`, `watch(...)` sources, and render functions; a plain snapshot elsewhere) - `getSelectedCellCount()` - returns how many cells are selected - `getSelectedCellIds()` - returns the ids of every selected cell - `getCellSelectionRowIds()` / `getCellSelectionColumnIds()` - returns the rows and columns the selection touches diff --git a/docs/framework/vue/guide/column-faceting.md b/docs/framework/vue/guide/column-faceting.md index a8f82de322..029b84909e 100644 --- a/docs/framework/vue/guide/column-faceting.md +++ b/docs/framework/vue/guide/column-faceting.md @@ -153,7 +153,7 @@ If you want each count to represent rows, make sure `getUniqueValues` returns ea ### Reactive Facet Controls in Vue -Read facet APIs inside a Vue reactive context such as `computed`, a template, or `table.Subscribe`. A filter component can derive its options from a stable `column` prop with `computed`. +Read facet APIs inside a Vue reactive context such as `computed`, a template, or a render function. A filter component can derive its options from a stable `column` prop with `computed`. ```vue + + diff --git a/examples/alpine/realtime-trading/package.json b/examples/alpine/realtime-trading/package.json new file mode 100644 index 0000000000..c3e24b9b57 --- /dev/null +++ b/examples/alpine/realtime-trading/package.json @@ -0,0 +1,32 @@ +{ + "name": "tanstack-alpine-table-example-realtime-trading", + "private": true, + "type": "module", + "scripts": { + "start": "vite", + "dev": "vite", + "build": "vite build", + "serve": "vite preview", + "lint": "eslint ./src", + "test:types": "tsc --noEmit", + "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" + }, + "nx": { + "targets": { + "test:e2e": { + "parallelism": false + } + } + }, + "dependencies": { + "@tanstack/alpine-table": "^9.3.1", + "@tanstack/store": "^0.11.2", + "alpinejs": "^3.17.5" + }, + "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/alpinejs": "^3.17.0", + "typescript": "6.0.3", + "vite": "^8.3.8" + } +} diff --git a/examples/alpine/realtime-trading/src/benchmark/benchmark-monitor.ts b/examples/alpine/realtime-trading/src/benchmark/benchmark-monitor.ts new file mode 100644 index 0000000000..bdceb13a7c --- /dev/null +++ b/examples/alpine/realtime-trading/src/benchmark/benchmark-monitor.ts @@ -0,0 +1,449 @@ +import { + quoteCellLifecycle, + quoteRenderDiagnostics, +} from '../table/table-config/quote-cells' +import { rowModelDiagnostics } from '../table/trading-table' + +export interface NamedInvocationRate { + name: string + callsPerSecond: number +} + +interface TimedLatencySample { + recordedAt: number + duration: number +} + +const averageLatencyWindowMs = 3_000 +const percentileLatencyWindowMs = 10_000 +const frameRateWindowMs = 1_000 + +export interface FeedMetrics { + actualTicksPerSecond: number + rowUpdatesPerSecond: number + workerMessagesPerSecond: number + stateApplicationsPerSecond: number + supersededUpdatesPerSecond: number + totalTicks: number + rafCallbacksPerSecond: number + tableCommitsPerSecond: number + lastBatchSize: number + averageCommitLatencyMs: number + p95CommitLatencyMs: number + maxCommitLatencyMs: number + slowCommits: number + longAnimationFrames: number + worstLongAnimationFrameMs: number + heapMb: number | null + componentsCreated: number + componentsDestroyed: number + workerMessages: number + lastUpdateCount: number + cellRendererCallsPerSecond: number + componentRenderCallsPerSecond: number + cellRendererRates: ReadonlyArray + componentRenderRates: ReadonlyArray + domMutationsPerSecond: number + rowModelCallsPerSecond: number + rowModelAverageMs: number + rowModelMaxMs: number + visibleRows: number +} + +export const initialMetrics: FeedMetrics = { + actualTicksPerSecond: 0, + rowUpdatesPerSecond: 0, + workerMessagesPerSecond: 0, + stateApplicationsPerSecond: 0, + supersededUpdatesPerSecond: 0, + totalTicks: 0, + rafCallbacksPerSecond: 0, + tableCommitsPerSecond: 0, + lastBatchSize: 0, + averageCommitLatencyMs: 0, + p95CommitLatencyMs: 0, + maxCommitLatencyMs: 0, + slowCommits: 0, + longAnimationFrames: 0, + worstLongAnimationFrameMs: 0, + heapMb: null, + componentsCreated: 0, + componentsDestroyed: 0, + workerMessages: 0, + lastUpdateCount: 0, + cellRendererCallsPerSecond: 0, + componentRenderCallsPerSecond: 0, + cellRendererRates: [], + componentRenderRates: [], + domMutationsPerSecond: 0, + rowModelCallsPerSecond: 0, + rowModelAverageMs: 0, + rowModelMaxMs: 0, + visibleRows: 0, +} + +const userTiming = { entryCount: 0, measureCandidateCount: 0 } +const userTimingSamplingInterval = 20 + +export function recordMeasure( + name: string, + start: number, + end: number, + detail: Record, +): void { + userTiming.measureCandidateCount++ + if (userTiming.measureCandidateCount % userTimingSamplingInterval !== 0) + return + try { + performance.measure(name, { start, end, detail }) + userTiming.entryCount++ + if (userTiming.entryCount % 1_000 === 0) { + performance.clearMeasures('market-update-to-dom-commit') + } + } catch { + // User Timing Level 3 options are not implemented in every browser. + } +} + +export function markBenchmarkAction( + name: string, + detail: Record = {}, +): void { + try { + performance.mark(`benchmark:${name}`, { detail }) + userTiming.entryCount++ + if (userTiming.entryCount % 1_000 === 0) { + performance.clearMarks() + } + } catch { + // User Timing Level 3 detail is not implemented in every browser. + } +} + +export class BenchmarkMonitor { + readonly #runtime = { + sampleStartedAt: performance.now(), + sessionStartedAt: performance.now(), + pendingMutationStartedAt: null as number | null, + commitLatencySamples: [] as Array, + slowCommitCount: 0, + totalTicks: 0, + ticksInSample: 0, + rowUpdatesInSample: 0, + workerMessagesInSample: 0, + stateApplicationsInSample: 0, + supersededUpdatesInSample: 0, + lastBatchSize: 0, + lastUpdateCount: 0, + workerMessages: 0, + frameTrackingStartedAt: performance.now(), + frameTimestamps: [] as Array, + tableCommitsInSample: 0, + longAnimationFrameCount: 0, + worstLongAnimationFrameMs: 0, + previousCellRendererCalls: 0, + previousComponentRenderCalls: 0, + previousCellRendererCallsByName: { + ...quoteRenderDiagnostics.cellRendererCallsByName, + }, + previousComponentRenderCallsByName: { + ...quoteRenderDiagnostics.componentRenderCallsByName, + }, + domMutationsInSample: 0, + previousRowModelCalls: 0, + previousRowModelDuration: 0, + } + + markCommitPending(): void { + this.#runtime.pendingMutationStartedAt ??= performance.now() + } + + recordDomCommit(): void { + const runtime = this.#runtime + if (runtime.pendingMutationStartedAt !== null) { + const commitEndedAt = performance.now() + const duration = commitEndedAt - runtime.pendingMutationStartedAt + runtime.commitLatencySamples.push({ + recordedAt: commitEndedAt, + duration, + }) + if (duration > 16.7) runtime.slowCommitCount++ + recordMeasure( + 'market-update-to-dom-commit', + runtime.pendingMutationStartedAt, + commitEndedAt, + {}, + ) + runtime.pendingMutationStartedAt = null + runtime.tableCommitsInSample++ + } + } + + recordWorkerMessage(): void { + this.#runtime.workerMessages++ + this.#runtime.workerMessagesInSample++ + } + + recordBatch( + tickCount: number, + updateCount: number, + supersededUpdateCount: number, + ): void { + const runtime = this.#runtime + runtime.lastBatchSize = tickCount + runtime.lastUpdateCount = updateCount + runtime.ticksInSample += tickCount + runtime.totalTicks += tickCount + runtime.rowUpdatesInSample += updateCount + runtime.stateApplicationsInSample++ + runtime.supersededUpdatesInSample += supersededUpdateCount + } + + recordAnimationFrame(now: number): void { + const timestamps = this.#runtime.frameTimestamps + timestamps.push(now) + pruneFrameTimestamps(timestamps, now) + } + + recordLongAnimationFrame(duration: number, startTime: number): void { + const runtime = this.#runtime + if (startTime < runtime.sessionStartedAt) return + runtime.longAnimationFrameCount++ + runtime.worstLongAnimationFrameMs = Math.max( + runtime.worstLongAnimationFrameMs, + duration, + ) + } + + recordDomMutations(count: number): void { + this.#runtime.domMutationsInSample += count + } + + resetDomMutations(): void { + this.#runtime.domMutationsInSample = 0 + } + + shouldPublish(now: number): boolean { + return now - this.#runtime.sampleStartedAt >= 500 + } + + publish(now: number): FeedMetrics { + const runtime = this.#runtime + const sampleDuration = now - runtime.sampleStartedAt + pruneLatencySamples(runtime.commitLatencySamples, now) + pruneFrameTimestamps(runtime.frameTimestamps, now) + const averageCommitLatencySamples = runtime.commitLatencySamples + .filter((sample) => sample.recordedAt >= now - averageLatencyWindowMs) + .map((sample) => sample.duration) + const percentileCommitLatencySamples = runtime.commitLatencySamples.map( + (sample) => sample.duration, + ) + const sortedCommitLatencySamples = [...percentileCommitLatencySamples].sort( + (left, right) => left - right, + ) + const rowModelCalls = + rowModelDiagnostics.calls - runtime.previousRowModelCalls + const rowModelDuration = + rowModelDiagnostics.totalDurationMs - runtime.previousRowModelDuration + const cellRendererCalls = + quoteRenderDiagnostics.cellRendererCalls - + runtime.previousCellRendererCalls + const componentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls - + runtime.previousComponentRenderCalls + const cellRendererRates = calculateInvocationRates( + quoteRenderDiagnostics.cellRendererCallsByName, + runtime.previousCellRendererCallsByName, + sampleDuration, + ) + const componentRenderRates = calculateInvocationRates( + quoteRenderDiagnostics.componentRenderCallsByName, + runtime.previousComponentRenderCallsByName, + sampleDuration, + ) + const averageCommitLatencyMs = + averageCommitLatencySamples.length === 0 + ? 0 + : averageCommitLatencySamples.reduce((sum, value) => sum + value, 0) / + averageCommitLatencySamples.length + const p95Index = Math.max( + 0, + Math.ceil(sortedCommitLatencySamples.length * 0.95) - 1, + ) + const metrics: FeedMetrics = { + actualTicksPerSecond: + sampleDuration === 0 + ? 0 + : (runtime.ticksInSample / sampleDuration) * 1_000, + rowUpdatesPerSecond: + (runtime.rowUpdatesInSample / sampleDuration) * 1_000, + workerMessagesPerSecond: + (runtime.workerMessagesInSample / sampleDuration) * 1_000, + stateApplicationsPerSecond: + (runtime.stateApplicationsInSample / sampleDuration) * 1_000, + supersededUpdatesPerSecond: + (runtime.supersededUpdatesInSample / sampleDuration) * 1_000, + totalTicks: runtime.totalTicks, + rafCallbacksPerSecond: calculateFrameRate( + runtime.frameTimestamps, + runtime.frameTrackingStartedAt, + now, + ), + tableCommitsPerSecond: + (runtime.tableCommitsInSample / sampleDuration) * 1_000, + lastBatchSize: runtime.lastBatchSize, + averageCommitLatencyMs, + p95CommitLatencyMs: sortedCommitLatencySamples[p95Index] ?? 0, + maxCommitLatencyMs: sortedCommitLatencySamples.at(-1) ?? 0, + slowCommits: runtime.slowCommitCount, + longAnimationFrames: runtime.longAnimationFrameCount, + worstLongAnimationFrameMs: runtime.worstLongAnimationFrameMs, + heapMb: readHeapSizeMb(), + componentsCreated: quoteCellLifecycle.created, + componentsDestroyed: quoteCellLifecycle.destroyed, + workerMessages: runtime.workerMessages, + lastUpdateCount: runtime.lastUpdateCount, + cellRendererCallsPerSecond: (cellRendererCalls / sampleDuration) * 1_000, + componentRenderCallsPerSecond: + (componentRenderCalls / sampleDuration) * 1_000, + cellRendererRates, + componentRenderRates, + domMutationsPerSecond: + (runtime.domMutationsInSample / sampleDuration) * 1_000, + rowModelCallsPerSecond: (rowModelCalls / sampleDuration) * 1_000, + rowModelAverageMs: + rowModelCalls === 0 ? 0 : rowModelDuration / rowModelCalls, + rowModelMaxMs: rowModelDiagnostics.maxDurationMs, + visibleRows: rowModelDiagnostics.lastRowCount, + } + + runtime.sampleStartedAt = now + runtime.previousCellRendererCalls = quoteRenderDiagnostics.cellRendererCalls + runtime.previousComponentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls + runtime.previousCellRendererCallsByName = { + ...quoteRenderDiagnostics.cellRendererCallsByName, + } + runtime.previousComponentRenderCallsByName = { + ...quoteRenderDiagnostics.componentRenderCallsByName, + } + runtime.domMutationsInSample = 0 + runtime.previousRowModelCalls = rowModelDiagnostics.calls + runtime.previousRowModelDuration = rowModelDiagnostics.totalDurationMs + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.tableCommitsInSample = 0 + return metrics + } + + reset(): void { + const runtime = this.#runtime + runtime.sampleStartedAt = performance.now() + runtime.sessionStartedAt = runtime.sampleStartedAt + runtime.pendingMutationStartedAt = null + runtime.commitLatencySamples = [] + runtime.slowCommitCount = 0 + runtime.totalTicks = 0 + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.lastBatchSize = 0 + runtime.lastUpdateCount = 0 + runtime.workerMessages = 0 + runtime.frameTrackingStartedAt = runtime.sampleStartedAt + runtime.frameTimestamps = [] + runtime.tableCommitsInSample = 0 + runtime.longAnimationFrameCount = 0 + runtime.worstLongAnimationFrameMs = 0 + runtime.previousCellRendererCalls = quoteRenderDiagnostics.cellRendererCalls + runtime.previousComponentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls + runtime.previousCellRendererCallsByName = { + ...quoteRenderDiagnostics.cellRendererCallsByName, + } + runtime.previousComponentRenderCallsByName = { + ...quoteRenderDiagnostics.componentRenderCallsByName, + } + runtime.domMutationsInSample = 0 + runtime.previousRowModelCalls = rowModelDiagnostics.calls + runtime.previousRowModelDuration = rowModelDiagnostics.totalDurationMs + rowModelDiagnostics.maxDurationMs = 0 + } +} + +export const longAnimationFramesSupported = + PerformanceObserver.supportedEntryTypes.includes('long-animation-frame') + +function readHeapSizeMb(): number | null { + const memory = ( + performance as Performance & { + memory?: { usedJSHeapSize: number } + } + ).memory + return memory ? memory.usedJSHeapSize / 1_048_576 : null +} + +function calculateInvocationRates( + current: Record, + previous: Record, + sampleDuration: number, +): ReadonlyArray { + return Object.entries(current).map(([name, calls]) => ({ + name, + callsPerSecond: + sampleDuration === 0 + ? 0 + : ((calls - (previous[name] ?? 0)) / sampleDuration) * 1_000, + })) +} + +function pruneLatencySamples( + samples: Array, + now: number, +): void { + const cutoff = now - percentileLatencyWindowMs + const firstRetainedIndex = samples.findIndex( + (sample) => sample.recordedAt >= cutoff, + ) + if (firstRetainedIndex > 0) samples.splice(0, firstRetainedIndex) + else if (firstRetainedIndex === -1) samples.length = 0 +} + +function pruneFrameTimestamps(timestamps: Array, now: number): void { + const cutoff = now - frameRateWindowMs + const firstRetainedIndex = timestamps.findIndex( + (timestamp) => timestamp >= cutoff, + ) + if (firstRetainedIndex > 0) timestamps.splice(0, firstRetainedIndex) + else if (firstRetainedIndex === -1) timestamps.length = 0 +} + +function calculateFrameRate( + timestamps: ReadonlyArray, + trackingStartedAt: number, + now: number, +): number { + const observedWindowMs = Math.min( + frameRateWindowMs, + Math.max(1, now - trackingStartedAt), + ) + return (timestamps.length / observedWindowMs) * 1_000 +} + +export function exposeTradingBenchmarkSnapshot( + metrics: FeedMetrics, + extras: { mountedCells: number; liveComponents: number }, +): void { + Object.assign(globalThis, { + __TANSTACK_TRADING_BENCHMARK__: { + capturedAt: performance.now(), + metrics, + ...extras, + }, + }) +} diff --git a/examples/alpine/realtime-trading/src/benchmark/trading-benchmark-controller.ts b/examples/alpine/realtime-trading/src/benchmark/trading-benchmark-controller.ts new file mode 100644 index 0000000000..895f292bb5 --- /dev/null +++ b/examples/alpine/realtime-trading/src/benchmark/trading-benchmark-controller.ts @@ -0,0 +1,145 @@ +import { batch, createAtom, createStore } from '@tanstack/store' +import { TRADING_COLUMN_COUNT } from '../table/trading-table' +import { + BenchmarkMonitor, + exposeTradingBenchmarkSnapshot, + initialMetrics, + longAnimationFramesSupported, +} from './benchmark-monitor' +import type { FeedMetrics } from './benchmark-monitor' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { RendererMode } from '../table/trading-table' + +export interface TradingBenchmarkState { + metrics: FeedMetrics + mountedCells: number + liveComponents: number + longAnimationFramesSupported: boolean +} + +export interface TradingBenchmarkActions { + resetViewState: () => void + setRendererMode: (mode: RendererMode) => void + setRenderedRowCount: (count: number) => void + selectSymbol: (symbol: string | null) => void + resetMarket: () => void +} + +const initialState: TradingBenchmarkState = { + metrics: initialMetrics, + mountedCells: 0, + liveComponents: 0, + longAnimationFramesSupported, +} + +export class TradingBenchmarkController { + readonly store = createStore(initialState) + readonly renderAtoms = { + selectedSymbol: createAtom(null), + rendererMode: createAtom('stable'), + } + readonly monitor = new BenchmarkMonitor() + readonly feed: MarketFeedController + readonly actions: TradingBenchmarkActions + + readonly #runtime = { + animationFrameId: 0, + longAnimationFrameObserver: null as PerformanceObserver | null, + stopObservingFeed: null as (() => void) | null, + } + + constructor(feed: MarketFeedController) { + this.feed = feed + this.actions = { + resetViewState: () => { + this.renderAtoms.selectedSymbol.set(null) + }, + setRendererMode: (mode) => { + this.renderAtoms.rendererMode.set(mode) + }, + setRenderedRowCount: (count) => { + const mountedCells = count * TRADING_COLUMN_COUNT + if (mountedCells !== this.store.get().mountedCells) { + this.#patch({ mountedCells }) + } + }, + selectSymbol: (symbol) => { + this.renderAtoms.selectedSymbol.set(symbol) + }, + resetMarket: () => { + batch(() => { + this.monitor.reset() + this.store.setState((state) => ({ + ...state, + metrics: { ...initialMetrics }, + mountedCells: 0, + liveComponents: 0, + })) + this.renderAtoms.selectedSymbol.set(null) + this.feed.actions.reset() + }) + }, + } + } + + start(): () => void { + const longAnimationFrameObserver = longAnimationFramesSupported + ? new PerformanceObserver((entries) => { + for (const entry of entries.getEntries()) { + this.monitor.recordLongAnimationFrame( + entry.duration, + entry.startTime, + ) + } + }) + : null + + this.#runtime.longAnimationFrameObserver = longAnimationFrameObserver + this.#runtime.stopObservingFeed = this.feed.observe({ + messageReceived: () => this.monitor.recordWorkerMessage(), + mutationStarted: () => this.monitor.markCommitPending(), + batchApplied: ({ tickCount, updateCount, supersededUpdateCount }) => + this.monitor.recordBatch(tickCount, updateCount, supersededUpdateCount), + renderCommitted: () => this.monitor.recordDomCommit(), + }) + longAnimationFrameObserver?.observe({ + type: 'long-animation-frame', + }) + this.#runtime.animationFrameId = requestAnimationFrame(this.#benchmarkFrame) + + return () => this.stop() + } + + stop(): void { + cancelAnimationFrame(this.#runtime.animationFrameId) + this.#runtime.longAnimationFrameObserver?.disconnect() + this.#runtime.stopObservingFeed?.() + this.#runtime.longAnimationFrameObserver = null + this.#runtime.stopObservingFeed = null + } + + readonly #benchmarkFrame = (now: number): void => { + this.monitor.recordAnimationFrame(now) + if (this.monitor.shouldPublish(now)) { + this.#publishMetrics(this.monitor.publish(now)) + } + this.#runtime.animationFrameId = requestAnimationFrame(this.#benchmarkFrame) + } + + #patch(patch: Partial): void { + this.store.setState((state) => ({ ...state, ...patch })) + } + + #publishMetrics(metrics: FeedMetrics): void { + const liveComponents = + metrics.componentsCreated - metrics.componentsDestroyed + this.#patch({ + metrics, + liveComponents, + }) + exposeTradingBenchmarkSnapshot(metrics, { + mountedCells: this.store.get().mountedCells, + liveComponents, + }) + } +} diff --git a/examples/alpine/realtime-trading/src/feed/feed-sample-rates.ts b/examples/alpine/realtime-trading/src/feed/feed-sample-rates.ts new file mode 100644 index 0000000000..17dc2015a6 --- /dev/null +++ b/examples/alpine/realtime-trading/src/feed/feed-sample-rates.ts @@ -0,0 +1,33 @@ +export const feedSampleRateOptions = [ + { label: '100', value: 100 }, + { label: '250', value: 250 }, + { label: '500', value: 500 }, + { label: '1K', value: 1_000 }, + { label: '2.5K', value: 2_500 }, + { label: '5K', value: 5_000 }, + { label: '10K', value: 10_000 }, + { label: '25K', value: 25_000 }, + { label: '50K', value: 50_000 }, + { label: '100K', value: 100_000 }, +] as const + +export function feedSampleRateIndex(rate: number): number { + return feedSampleRateOptions.reduce((closestIndex, candidate, index) => { + const closest = feedSampleRateOptions[closestIndex] + return Math.abs(candidate.value - rate) < Math.abs(closest.value - rate) + ? index + : closestIndex + }, 0) +} + +export function feedSampleRateAt(stepIndex: number): number { + const index = Math.min( + feedSampleRateOptions.length - 1, + Math.max(0, Math.round(stepIndex)), + ) + return feedSampleRateOptions[index].value +} + +export function normalizeFeedSampleRate(rate: number): number { + return feedSampleRateAt(feedSampleRateIndex(rate)) +} diff --git a/examples/alpine/realtime-trading/src/feed/market-data.ts b/examples/alpine/realtime-trading/src/feed/market-data.ts new file mode 100644 index 0000000000..6231865d3f --- /dev/null +++ b/examples/alpine/realtime-trading/src/feed/market-data.ts @@ -0,0 +1,38 @@ +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './worker/market-feed-protocol' + +export interface MarketQuote extends Omit { + history: ReadonlyArray +} + +export function hydrateMarketQuotes( + snapshots: Array, +): Array { + return snapshots.map((quote) => ({ + ...quote, + history: [...quote.history], + })) +} + +export function applyMarketUpdates( + quotes: Array, + updates: Array, +): Array { + const nextQuotes = [...quotes] + + for (const update of updates) { + const { index, history, ...values } = update + const previousQuote = quotes.at(index) + if (!previousQuote) continue + + nextQuotes[index] = { + ...previousQuote, + ...values, + history: history ?? previousQuote.history, + } + } + + return nextQuotes +} diff --git a/examples/alpine/realtime-trading/src/feed/market-feed-config.ts b/examples/alpine/realtime-trading/src/feed/market-feed-config.ts new file mode 100644 index 0000000000..9d477ed663 --- /dev/null +++ b/examples/alpine/realtime-trading/src/feed/market-feed-config.ts @@ -0,0 +1,15 @@ +export interface MarketFeedConfig { + readonly instrumentCount: number + readonly targetSamplesPerSecond: number + readonly publishIntervalMs: number + readonly updateSparklines: boolean + readonly sparklineSampleIntervalMs: number +} + +export const initialMarketFeedConfig: MarketFeedConfig = { + instrumentCount: 100, + targetSamplesPerSecond: 10_000, + publishIntervalMs: 20, + updateSparklines: true, + sparklineSampleIntervalMs: 16, +} diff --git a/examples/alpine/realtime-trading/src/feed/market-feed-controller.ts b/examples/alpine/realtime-trading/src/feed/market-feed-controller.ts new file mode 100644 index 0000000000..157c577821 --- /dev/null +++ b/examples/alpine/realtime-trading/src/feed/market-feed-controller.ts @@ -0,0 +1,229 @@ +import { batch, createAtom } from '@tanstack/store' +import { normalizeFeedSampleRate } from './feed-sample-rates' +import { initialMarketFeedConfig } from './market-feed-config' +import { applyMarketUpdates, hydrateMarketQuotes } from './market-data' +import type { + MarketFeedCommand, + MarketFeedEvent, +} from './worker/market-feed-protocol' +import type { MarketQuote } from './market-data' + +export interface MarketFeedBatch { + tickCount: number + updateCount: number + supersededUpdateCount: number +} + +export interface MarketFeedObserver { + messageReceived?: () => void + mutationStarted?: () => void + batchApplied?: (batch: MarketFeedBatch) => void + renderCommitted?: () => void +} + +export interface MarketFeedActions { + toggle: () => void + setInstrumentCount: (count: number) => void + setTargetRate: (rate: number) => void + setPublishInterval: (intervalMs: number) => void + setSparklineUpdates: (enabled: boolean) => void + setSparklineSampleInterval: (intervalMs: number) => void + runBurst: () => void + reset: () => void +} + +export class MarketFeedController { + readonly workerReady = createAtom(false) + readonly running = createAtom( + !new URLSearchParams(location.search).has('paused'), + ) + readonly instrumentCount = createAtom(initialMarketFeedConfig.instrumentCount) + readonly targetTicksPerSecond = createAtom( + initialMarketFeedConfig.targetSamplesPerSecond, + ) + readonly publishIntervalMs = createAtom( + initialMarketFeedConfig.publishIntervalMs, + ) + readonly updateSparklines = createAtom( + initialMarketFeedConfig.updateSparklines, + ) + readonly sparklineSampleIntervalMs = createAtom( + initialMarketFeedConfig.sparklineSampleIntervalMs, + ) + readonly quotes = createAtom>([]) + readonly actions: MarketFeedActions + readonly #observers = new Set() + readonly #runtime = { + worker: null as Worker | null, + feedSessionId: 0, + renderPending: false, + resetWaitingForCommit: false, + resetSnapshotReady: false, + quoteIndexBySymbol: new Map(), + } + + constructor() { + this.actions = { + toggle: () => { + const running = !this.running.get() + this.running.set(running) + this.#post({ type: 'set-running', running }) + }, + setInstrumentCount: (count) => { + this.instrumentCount.set(count) + this.#resetWorker(count) + }, + setTargetRate: (rate) => { + const sampleRate = normalizeFeedSampleRate(rate) + this.targetTicksPerSecond.set(sampleRate) + this.#post({ type: 'set-rate', ticksPerSecond: sampleRate }) + }, + setPublishInterval: (publishIntervalMs) => { + this.publishIntervalMs.set(publishIntervalMs) + this.#post({ + type: 'set-publish-interval', + intervalMs: publishIntervalMs, + }) + }, + setSparklineUpdates: (enabled) => { + this.updateSparklines.set(enabled) + this.#post({ type: 'set-sparklines', enabled }) + }, + setSparklineSampleInterval: (intervalMs) => { + this.sparklineSampleIntervalMs.set(intervalMs) + this.#post({ type: 'set-sparkline-interval', intervalMs }) + }, + runBurst: () => this.#post({ type: 'burst', tickCount: 25_000 }), + reset: () => this.#resetWorker(this.instrumentCount.get()), + } + } + + start(): () => void { + const worker = new Worker( + new URL('./worker/market-feed.worker.ts', import.meta.url), + { type: 'module' }, + ) + this.#runtime.worker = worker + worker.addEventListener('message', this.#handleWorkerMessage) + worker.addEventListener('error', this.#handleWorkerError) + this.#post({ + type: 'start', + rowCount: this.instrumentCount.get(), + running: this.running.get(), + ticksPerSecond: this.targetTicksPerSecond.get(), + publishIntervalMs: this.publishIntervalMs.get(), + updateSparklines: this.updateSparklines.get(), + sparklineSampleIntervalMs: this.sparklineSampleIntervalMs.get(), + }) + return () => this.stop() + } + + stop(): void { + this.#runtime.worker?.removeEventListener( + 'message', + this.#handleWorkerMessage, + ) + this.#runtime.worker?.removeEventListener('error', this.#handleWorkerError) + this.#runtime.worker?.terminate() + this.#runtime.worker = null + this.#observers.clear() + } + + observe(observer: MarketFeedObserver): () => void { + this.#observers.add(observer) + return () => this.#observers.delete(observer) + } + + getQuoteBySymbol( + quotes: Array, + symbol: string | null, + ): MarketQuote | null { + if (symbol === null) return null + + const index = this.#runtime.quoteIndexBySymbol.get(symbol) + return index === undefined ? null : (quotes[index] ?? null) + } + + completeRender(): void { + if (!this.#runtime.renderPending) return + + this.#runtime.renderPending = false + for (const observer of this.#observers) { + observer.renderCommitted?.() + } + if ( + this.#runtime.resetWaitingForCommit && + this.#runtime.resetSnapshotReady + ) { + this.#runtime.resetWaitingForCommit = false + this.#runtime.resetSnapshotReady = false + this.#post({ type: 'set-running', running: this.running.get() }) + } + } + + readonly #handleWorkerMessage = ({ + data, + }: MessageEvent): void => { + if (data.type === 'snapshot') { + this.#runtime.feedSessionId = data.sessionId + if (this.#runtime.resetWaitingForCommit) { + this.#runtime.resetSnapshotReady = true + } + this.#startMutation() + const quotes = hydrateMarketQuotes(data.quotes) + this.#runtime.quoteIndexBySymbol = new Map( + quotes.map((quote, index) => [quote.symbol, index]), + ) + batch(() => { + this.quotes.set(quotes) + this.workerReady.set(true) + }) + return + } + + if (data.sessionId !== this.#runtime.feedSessionId) return + + for (const observer of this.#observers) { + observer.messageReceived?.() + } + this.#startMutation() + this.quotes.set(applyMarketUpdates(this.quotes.get(), data.updates)) + const feedBatch = { + tickCount: data.tickCount, + updateCount: data.updates.length, + supersededUpdateCount: data.coalescedUpdateCount, + } + for (const observer of this.#observers) { + observer.batchApplied?.(feedBatch) + } + } + + readonly #handleWorkerError = (error: ErrorEvent): void => { + batch(() => { + this.workerReady.set(false) + this.running.set(false) + }) + console.error('Market feed worker failed', error) + } + + #resetWorker(rowCount: number): void { + this.workerReady.set(false) + if (this.running.get()) { + this.#runtime.resetWaitingForCommit = true + this.#runtime.resetSnapshotReady = false + this.#post({ type: 'set-running', running: false }) + } + this.#post({ type: 'reset', rowCount }) + } + + #startMutation(): void { + this.#runtime.renderPending = true + for (const observer of this.#observers) { + observer.mutationStarted?.() + } + } + + #post(command: MarketFeedCommand): void { + this.#runtime.worker?.postMessage(command) + } +} diff --git a/examples/alpine/realtime-trading/src/feed/market-instruments.ts b/examples/alpine/realtime-trading/src/feed/market-instruments.ts new file mode 100644 index 0000000000..ac18d14ea9 --- /dev/null +++ b/examples/alpine/realtime-trading/src/feed/market-instruments.ts @@ -0,0 +1,742 @@ +export type MarketCode = + | 'US' + | 'NL' + | 'DE' + | 'FR' + | 'IT' + | 'ES' + | 'CH' + | 'DK' + | 'SE' + | 'FI' + | 'GB' + | 'KR' + | 'JP' + | 'HK' + | 'CA' + | 'AU' + +export type BaseInstrument = readonly [ + symbol: string, + company: string, + market: MarketCode, +] + +/** + * Current S&P 500 constituent universe used by the realtime trading examples. + * + * Source snapshot: https://github.com/datasets/s-and-p-500-companies + * Retrieved: 2026-08-15. + * Multiple share classes are intentionally represented as separate instruments. + */ +export const marketInstruments = Object.freeze([ + ['MMM', '3M', 'US'], + ['AOS', 'A. O. Smith', 'US'], + ['ABT', 'Abbott Laboratories', 'US'], + ['ABBV', 'AbbVie', 'US'], + ['ACN', 'Accenture', 'US'], + ['ADBE', 'Adobe Inc.', 'US'], + ['AMD', 'Advanced Micro Devices', 'US'], + ['AES', 'AES Corporation', 'US'], + ['AFL', 'Aflac', 'US'], + ['A', 'Agilent Technologies', 'US'], + ['APD', 'Air Products', 'US'], + ['ABNB', 'Airbnb', 'US'], + ['AKAM', 'Akamai Technologies', 'US'], + ['ALB', 'Albemarle Corporation', 'US'], + ['ARE', 'Alexandria Real Estate Equities', 'US'], + ['ALGN', 'Align Technology', 'US'], + ['ALLE', 'Allegion', 'US'], + ['LNT', 'Alliant Energy', 'US'], + ['ALL', 'Allstate', 'US'], + ['GOOGL', 'Alphabet Inc. (Class A)', 'US'], + ['GOOG', 'Alphabet Inc. (Class C)', 'US'], + ['MO', 'Altria', 'US'], + ['AMZN', 'Amazon', 'US'], + ['AMCR', 'Amcor', 'US'], + ['AEE', 'Ameren', 'US'], + ['AEP', 'American Electric Power', 'US'], + ['AXP', 'American Express', 'US'], + ['AIG', 'American International Group', 'US'], + ['AMT', 'American Tower', 'US'], + ['AWK', 'American Water Works', 'US'], + ['AMP', 'Ameriprise Financial', 'US'], + ['AME', 'Ametek', 'US'], + ['AMGN', 'Amgen', 'US'], + ['APH', 'Amphenol', 'US'], + ['ADI', 'Analog Devices', 'US'], + ['AON', 'Aon plc', 'US'], + ['APA', 'APA Corporation', 'US'], + ['APO', 'Apollo Global Management', 'US'], + ['AAPL', 'Apple Inc.', 'US'], + ['AMAT', 'Applied Materials', 'US'], + ['APP', 'AppLovin', 'US'], + ['APTV', 'Aptiv', 'US'], + ['ACGL', 'Arch Capital Group', 'US'], + ['ADM', 'Archer Daniels Midland', 'US'], + ['ARES', 'Ares Management', 'US'], + ['ANET', 'Arista Networks', 'US'], + ['AJG', 'Arthur J. Gallagher & Co.', 'US'], + ['AIZ', 'Assurant', 'US'], + ['T', 'AT&T', 'US'], + ['ATO', 'Atmos Energy', 'US'], + ['ADSK', 'Autodesk', 'US'], + ['ADP', 'Automatic Data Processing', 'US'], + ['AZO', 'AutoZone', 'US'], + ['AVB', 'AvalonBay Communities', 'US'], + ['AVY', 'Avery Dennison', 'US'], + ['AXON', 'Axon Enterprise', 'US'], + ['BKR', 'Baker Hughes', 'US'], + ['BALL', 'Ball Corporation', 'US'], + ['BAC', 'Bank of America', 'US'], + ['BAX', 'Baxter International', 'US'], + ['BDX', 'Becton Dickinson', 'US'], + ['BRK.B', 'Berkshire Hathaway', 'US'], + ['BBY', 'Best Buy', 'US'], + ['TECH', 'Bio-Techne', 'US'], + ['BIIB', 'Biogen', 'US'], + ['BLK', 'BlackRock', 'US'], + ['BX', 'Blackstone Inc.', 'US'], + ['XYZ', 'Block, Inc.', 'US'], + ['BNY', 'BNY Mellon', 'US'], + ['BA', 'Boeing', 'US'], + ['BKNG', 'Booking Holdings', 'US'], + ['BSX', 'Boston Scientific', 'US'], + ['BMY', 'Bristol Myers Squibb', 'US'], + ['AVGO', 'Broadcom', 'US'], + ['BR', 'Broadridge Financial Solutions', 'US'], + ['BRO', 'Brown & Brown', 'US'], + ['BF.B', 'Brown–Forman', 'US'], + ['BLDR', 'Builders FirstSource', 'US'], + ['BG', 'Bunge Global', 'US'], + ['BXP', 'BXP, Inc.', 'US'], + ['CHRW', 'C.H. Robinson', 'US'], + ['CDNS', 'Cadence Design Systems', 'US'], + ['CPT', 'Camden Property Trust', 'US'], + ['COF', 'Capital One', 'US'], + ['CAH', 'Cardinal Health', 'US'], + ['CCL', 'Carnival Corporation', 'US'], + ['CARR', 'Carrier Global', 'US'], + ['CVNA', 'Carvana', 'US'], + ['CASY', "Casey's", 'US'], + ['CAT', 'Caterpillar Inc.', 'US'], + ['CBOE', 'Cboe Global Markets', 'US'], + ['CBRE', 'CBRE Group', 'US'], + ['CDW', 'CDW Corporation', 'US'], + ['COR', 'Cencora', 'US'], + ['CNC', 'Centene Corporation', 'US'], + ['CNP', 'CenterPoint Energy', 'US'], + ['CF', 'CF Industries', 'US'], + ['CRL', 'Charles River Laboratories', 'US'], + ['SCHW', 'Charles Schwab Corporation', 'US'], + ['CHTR', 'Charter Communications', 'US'], + ['CVX', 'Chevron Corporation', 'US'], + ['CMG', 'Chipotle Mexican Grill', 'US'], + ['CB', 'Chubb Limited', 'US'], + ['CHD', 'Church & Dwight', 'US'], + ['CIEN', 'Ciena', 'US'], + ['CI', 'Cigna', 'US'], + ['CINF', 'Cincinnati Financial', 'US'], + ['CTAS', 'Cintas', 'US'], + ['CSCO', 'Cisco', 'US'], + ['C', 'Citigroup', 'US'], + ['CFG', 'Citizens Financial Group', 'US'], + ['CLX', 'Clorox', 'US'], + ['CME', 'CME Group', 'US'], + ['CMS', 'CMS Energy', 'US'], + ['KO', 'Coca-Cola Company (The)', 'US'], + ['CTSH', 'Cognizant', 'US'], + ['COHR', 'Coherent Corp.', 'US'], + ['COIN', 'Coinbase', 'US'], + ['CL', 'Colgate-Palmolive', 'US'], + ['CMCSA', 'Comcast', 'US'], + ['FIX', 'Comfort Systems USA', 'US'], + ['COP', 'ConocoPhillips', 'US'], + ['ED', 'Consolidated Edison', 'US'], + ['STZ', 'Constellation Brands', 'US'], + ['CEG', 'Constellation Energy', 'US'], + ['COO', 'Cooper Companies (The)', 'US'], + ['CPRT', 'Copart', 'US'], + ['GLW', 'Corning Inc.', 'US'], + ['CPAY', 'Corpay', 'US'], + ['CTVA', 'Corteva', 'US'], + ['CSGP', 'CoStar Group', 'US'], + ['COST', 'Costco', 'US'], + ['CRH', 'CRH plc', 'US'], + ['CRWD', 'CrowdStrike', 'US'], + ['CCI', 'Crown Castle', 'US'], + ['CSX', 'CSX Corporation', 'US'], + ['CMI', 'Cummins', 'US'], + ['CVS', 'CVS Health', 'US'], + ['DHR', 'Danaher Corporation', 'US'], + ['DRI', 'Darden Restaurants', 'US'], + ['DDOG', 'Datadog', 'US'], + ['DVA', 'DaVita', 'US'], + ['DECK', 'Deckers Brands', 'US'], + ['DE', 'Deere & Company', 'US'], + ['DELL', 'Dell Technologies', 'US'], + ['DAL', 'Delta Air Lines', 'US'], + ['DVN', 'Devon Energy', 'US'], + ['DXCM', 'Dexcom', 'US'], + ['FANG', 'Diamondback Energy', 'US'], + ['DLR', 'Digital Realty', 'US'], + ['DG', 'Dollar General', 'US'], + ['DLTR', 'Dollar Tree', 'US'], + ['D', 'Dominion Energy', 'US'], + ['DPZ', "Domino's", 'US'], + ['DASH', 'DoorDash', 'US'], + ['DOV', 'Dover Corporation', 'US'], + ['DOW', 'Dow Inc.', 'US'], + ['DHI', 'D. R. Horton', 'US'], + ['DTE', 'DTE Energy', 'US'], + ['DUK', 'Duke Energy', 'US'], + ['DD', 'DuPont', 'US'], + ['ETN', 'Eaton Corporation', 'US'], + ['EBAY', 'eBay Inc.', 'US'], + ['ECHO', 'EchoStar', 'US'], + ['ECL', 'Ecolab', 'US'], + ['EIX', 'Edison International', 'US'], + ['EW', 'Edwards Lifesciences', 'US'], + ['ELV', 'Elevance Health', 'US'], + ['EME', 'Emcor', 'US'], + ['EMR', 'Emerson Electric', 'US'], + ['ETR', 'Entergy', 'US'], + ['EOG', 'EOG Resources', 'US'], + ['EQT', 'EQT Corporation', 'US'], + ['EFX', 'Equifax', 'US'], + ['EQIX', 'Equinix', 'US'], + ['EQR', 'Equity Residential', 'US'], + ['ERIE', 'Erie Indemnity', 'US'], + ['ESS', 'Essex Property Trust', 'US'], + ['EL', 'Estée Lauder Companies (The)', 'US'], + ['EG', 'Everest Group', 'US'], + ['EVRG', 'Evergy', 'US'], + ['ES', 'Eversource Energy', 'US'], + ['EXC', 'Exelon', 'US'], + ['EXE', 'Expand Energy', 'US'], + ['EXPE', 'Expedia Group', 'US'], + ['EXPD', 'Expeditors International', 'US'], + ['EXR', 'Extra Space Storage', 'US'], + ['XOM', 'ExxonMobil', 'US'], + ['FFIV', 'F5, Inc.', 'US'], + ['FDS', 'FactSet', 'US'], + ['FICO', 'Fair Isaac', 'US'], + ['FAST', 'Fastenal', 'US'], + ['FRT', 'Federal Realty Investment Trust', 'US'], + ['FDX', 'FedEx', 'US'], + ['FDXF', 'FedEx Freight', 'US'], + ['FERG', 'Ferguson Enterprises', 'US'], + ['FIS', 'Fidelity National Information Services', 'US'], + ['FITB', 'Fifth Third Bancorp', 'US'], + ['FSLR', 'First Solar', 'US'], + ['FE', 'FirstEnergy', 'US'], + ['FISV', 'Fiserv', 'US'], + ['FLEX', 'Flex Ltd.', 'US'], + ['F', 'Ford Motor Company', 'US'], + ['FTNT', 'Fortinet', 'US'], + ['FTV', 'Fortive', 'US'], + ['FOXA', 'Fox Corporation (Class A)', 'US'], + ['FOX', 'Fox Corporation (Class B)', 'US'], + ['BEN', 'Franklin Resources', 'US'], + ['FCX', 'Freeport-McMoRan', 'US'], + ['GRMN', 'Garmin', 'US'], + ['IT', 'Gartner', 'US'], + ['GE', 'GE Aerospace', 'US'], + ['GEHC', 'GE HealthCare', 'US'], + ['GEV', 'GE Vernova', 'US'], + ['GEN', 'Gen Digital', 'US'], + ['GNRC', 'Generac', 'US'], + ['GD', 'General Dynamics', 'US'], + ['GIS', 'General Mills', 'US'], + ['GM', 'General Motors', 'US'], + ['GPC', 'Genuine Parts Company', 'US'], + ['GILD', 'Gilead Sciences', 'US'], + ['GPN', 'Global Payments', 'US'], + ['GL', 'Globe Life', 'US'], + ['GDDY', 'GoDaddy', 'US'], + ['GS', 'Goldman Sachs', 'US'], + ['HAL', 'Halliburton', 'US'], + ['HIG', 'Hartford (The)', 'US'], + ['HAS', 'Hasbro', 'US'], + ['HCA', 'HCA Healthcare', 'US'], + ['DOC', 'Healthpeak Properties', 'US'], + ['HSIC', 'Henry Schein', 'US'], + ['HSY', 'Hershey Company (The)', 'US'], + ['HPE', 'Hewlett Packard Enterprise', 'US'], + ['HLT', 'Hilton Worldwide', 'US'], + ['HD', 'Home Depot (The)', 'US'], + ['HONA', 'Honeywell Aerospace', 'US'], + ['HON', 'Honeywell Technologies', 'US'], + ['HRL', 'Hormel Foods', 'US'], + ['HST', 'Host Hotels & Resorts', 'US'], + ['HWM', 'Howmet Aerospace', 'US'], + ['HPQ', 'HP Inc.', 'US'], + ['HUBB', 'Hubbell Incorporated', 'US'], + ['HUM', 'Humana', 'US'], + ['HBAN', 'Huntington Bancshares', 'US'], + ['HII', 'Huntington Ingalls Industries', 'US'], + ['IBM', 'IBM', 'US'], + ['IEX', 'IDEX Corporation', 'US'], + ['IDXX', 'Idexx Laboratories', 'US'], + ['ITW', 'Illinois Tool Works', 'US'], + ['INCY', 'Incyte', 'US'], + ['IR', 'Ingersoll Rand', 'US'], + ['PODD', 'Insulet Corporation', 'US'], + ['INTC', 'Intel', 'US'], + ['IBKR', 'Interactive Brokers', 'US'], + ['ICE', 'Intercontinental Exchange', 'US'], + ['IFF', 'International Flavors & Fragrances', 'US'], + ['IP', 'International Paper', 'US'], + ['INTU', 'Intuit', 'US'], + ['ISRG', 'Intuitive Surgical', 'US'], + ['IVZ', 'Invesco', 'US'], + ['INVH', 'Invitation Homes', 'US'], + ['IQV', 'IQVIA', 'US'], + ['IRM', 'Iron Mountain', 'US'], + ['JBHT', 'J.B. Hunt', 'US'], + ['JBL', 'Jabil', 'US'], + ['JKHY', 'Jack Henry & Associates', 'US'], + ['J', 'Jacobs Solutions', 'US'], + ['JNJ', 'Johnson & Johnson', 'US'], + ['JCI', 'Johnson Controls', 'US'], + ['JPM', 'JPMorgan Chase', 'US'], + ['KVUE', 'Kenvue', 'US'], + ['KDP', 'Keurig Dr Pepper', 'US'], + ['KEY', 'KeyCorp', 'US'], + ['KEYS', 'Keysight Technologies', 'US'], + ['KMB', 'Kimberly-Clark', 'US'], + ['KIM', 'Kimco Realty', 'US'], + ['KMI', 'Kinder Morgan', 'US'], + ['KKR', 'KKR & Co.', 'US'], + ['KLAC', 'KLA Corporation', 'US'], + ['KHC', 'Kraft Heinz', 'US'], + ['KR', 'Kroger', 'US'], + ['LHX', 'L3Harris', 'US'], + ['LH', 'Labcorp', 'US'], + ['LRCX', 'Lam Research', 'US'], + ['LVS', 'Las Vegas Sands', 'US'], + ['LDOS', 'Leidos', 'US'], + ['LEN', 'Lennar', 'US'], + ['LII', 'Lennox International', 'US'], + ['LLY', 'Lilly (Eli)', 'US'], + ['LIN', 'Linde plc', 'US'], + ['LYV', 'Live Nation Entertainment', 'US'], + ['LMT', 'Lockheed Martin', 'US'], + ['L', 'Loews Corporation', 'US'], + ['LOW', "Lowe's", 'US'], + ['LULU', 'Lululemon Athletica', 'US'], + ['LITE', 'Lumentum', 'US'], + ['LYB', 'LyondellBasell', 'US'], + ['MTB', 'M&T Bank', 'US'], + ['MPC', 'Marathon Petroleum', 'US'], + ['MAR', 'Marriott International', 'US'], + ['MRSH', 'Marsh McLennan', 'US'], + ['MLM', 'Martin Marietta Materials', 'US'], + ['MRVL', 'Marvell Technology', 'US'], + ['MAS', 'Masco', 'US'], + ['MA', 'Mastercard', 'US'], + ['MKC', 'McCormick & Company', 'US'], + ['MCD', "McDonald's", 'US'], + ['MCK', 'McKesson Corporation', 'US'], + ['MDT', 'Medtronic', 'US'], + ['MRK', 'Merck & Co.', 'US'], + ['META', 'Meta Platforms', 'US'], + ['MET', 'MetLife', 'US'], + ['MTD', 'Mettler Toledo', 'US'], + ['MGM', 'MGM Resorts', 'US'], + ['MCHP', 'Microchip Technology', 'US'], + ['MU', 'Micron Technology', 'US'], + ['MSFT', 'Microsoft', 'US'], + ['MAA', 'Mid-America Apartment Communities', 'US'], + ['MRNA', 'Moderna', 'US'], + ['TAP', 'Molson Coors Beverage Company', 'US'], + ['MDLZ', 'Mondelez International', 'US'], + ['MPWR', 'Monolithic Power Systems', 'US'], + ['MNST', 'Monster Beverage', 'US'], + ['MCO', "Moody's Corporation", 'US'], + ['MS', 'Morgan Stanley', 'US'], + ['MOS', 'Mosaic Company (The)', 'US'], + ['MSI', 'Motorola Solutions', 'US'], + ['MSCI', 'MSCI', 'US'], + ['NDAQ', 'Nasdaq, Inc.', 'US'], + ['NTAP', 'NetApp', 'US'], + ['NFLX', 'Netflix', 'US'], + ['NEM', 'Newmont', 'US'], + ['NWSA', 'News Corp (Class A)', 'US'], + ['NWS', 'News Corp (Class B)', 'US'], + ['NEE', 'NextEra Energy', 'US'], + ['NKE', 'Nike, Inc.', 'US'], + ['NI', 'NiSource', 'US'], + ['NDSN', 'Nordson Corporation', 'US'], + ['NSC', 'Norfolk Southern', 'US'], + ['NTRS', 'Northern Trust', 'US'], + ['NOC', 'Northrop Grumman', 'US'], + ['NCLH', 'Norwegian Cruise Line Holdings', 'US'], + ['NRG', 'NRG Energy', 'US'], + ['NUE', 'Nucor', 'US'], + ['NVDA', 'Nvidia', 'US'], + ['NVR', 'NVR, Inc.', 'US'], + ['NXPI', 'NXP Semiconductors', 'US'], + ['ORLY', "O'Reilly Automotive", 'US'], + ['OXY', 'Occidental Petroleum', 'US'], + ['ODFL', 'Old Dominion', 'US'], + ['OMC', 'Omnicom Group', 'US'], + ['ON', 'ON Semiconductor', 'US'], + ['OKE', 'Oneok', 'US'], + ['ORCL', 'Oracle Corporation', 'US'], + ['OTIS', 'Otis Worldwide', 'US'], + ['PCAR', 'Paccar', 'US'], + ['PKG', 'Packaging Corporation of America', 'US'], + ['PLTR', 'Palantir Technologies', 'US'], + ['PANW', 'Palo Alto Networks', 'US'], + ['PSKY', 'Paramount Skydance Corporation', 'US'], + ['PH', 'Parker Hannifin', 'US'], + ['PAYX', 'Paychex', 'US'], + ['PYPL', 'PayPal', 'US'], + ['PNR', 'Pentair', 'US'], + ['PEP', 'PepsiCo', 'US'], + ['PFE', 'Pfizer', 'US'], + ['PCG', 'PG&E Corporation', 'US'], + ['PM', 'Philip Morris International', 'US'], + ['PSX', 'Phillips 66', 'US'], + ['PNW', 'Pinnacle West Capital', 'US'], + ['PNC', 'PNC Financial Services', 'US'], + ['PPG', 'PPG Industries', 'US'], + ['PPL', 'PPL Corporation', 'US'], + ['PFG', 'Principal Financial Group', 'US'], + ['PG', 'Procter & Gamble', 'US'], + ['PGR', 'Progressive Corporation', 'US'], + ['PLD', 'Prologis', 'US'], + ['PRU', 'Prudential Financial', 'US'], + ['PEG', 'Public Service Enterprise Group', 'US'], + ['PTC', 'PTC Inc.', 'US'], + ['PSA', 'Public Storage', 'US'], + ['PHM', 'PulteGroup', 'US'], + ['PWR', 'Quanta Services', 'US'], + ['QCOM', 'Qualcomm', 'US'], + ['DGX', 'Quest Diagnostics', 'US'], + ['Q', 'Qnity Electronics', 'US'], + ['RL', 'Ralph Lauren Corporation', 'US'], + ['RJF', 'Raymond James Financial', 'US'], + ['RTX', 'RTX Corporation', 'US'], + ['O', 'Realty Income', 'US'], + ['REG', 'Regency Centers', 'US'], + ['REGN', 'Regeneron Pharmaceuticals', 'US'], + ['RF', 'Regions Financial Corporation', 'US'], + ['RSG', 'Republic Services', 'US'], + ['RMD', 'ResMed|', 'US'], + ['RVTY', 'Revvity', 'US'], + ['HOOD', 'Robinhood Markets', 'US'], + ['ROK', 'Rockwell Automation', 'US'], + ['ROL', 'Rollins, Inc.', 'US'], + ['ROP', 'Roper Technologies', 'US'], + ['ROST', 'Ross Stores', 'US'], + ['RCL', 'Royal Caribbean Group', 'US'], + ['SPGI', 'S&P Global', 'US'], + ['CRM', 'Salesforce', 'US'], + ['SNDK', 'Sandisk', 'US'], + ['SBAC', 'SBA Communications', 'US'], + ['SLB', 'Schlumberger', 'US'], + ['STX', 'Seagate Technology', 'US'], + ['SRE', 'Sempra', 'US'], + ['NOW', 'ServiceNow', 'US'], + ['SHW', 'Sherwin-Williams', 'US'], + ['SPG', 'Simon Property Group', 'US'], + ['SWKS', 'Skyworks Solutions', 'US'], + ['SJM', 'J.M. Smucker Company (The)', 'US'], + ['SW', 'Smurfit Westrock', 'US'], + ['SNA', 'Snap-on', 'US'], + ['SOLV', 'Solventum', 'US'], + ['SO', 'Southern Company', 'US'], + ['LUV', 'Southwest Airlines', 'US'], + ['SWK', 'Stanley Black & Decker', 'US'], + ['SBUX', 'Starbucks', 'US'], + ['STT', 'State Street Corporation', 'US'], + ['STLD', 'Steel Dynamics', 'US'], + ['STE', 'Steris', 'US'], + ['SYK', 'Stryker Corporation', 'US'], + ['SMCI', 'Supermicro', 'US'], + ['SYF', 'Synchrony Financial', 'US'], + ['SNPS', 'Synopsys', 'US'], + ['SYY', 'Sysco', 'US'], + ['TMUS', 'T-Mobile US', 'US'], + ['TROW', 'T. Rowe Price', 'US'], + ['TTWO', 'Take-Two Interactive', 'US'], + ['TPR', 'Tapestry, Inc.', 'US'], + ['TRGP', 'Targa Resources', 'US'], + ['TGT', 'Target Corporation', 'US'], + ['TEL', 'TE Connectivity', 'US'], + ['TDY', 'Teledyne Technologies', 'US'], + ['TER', 'Teradyne', 'US'], + ['TSLA', 'Tesla, Inc.', 'US'], + ['TXN', 'Texas Instruments', 'US'], + ['TPL', 'Texas Pacific Land Corporation', 'US'], + ['TXT', 'Textron', 'US'], + ['TMO', 'Thermo Fisher Scientific', 'US'], + ['TJX', 'TJX Companies', 'US'], + ['TKO', 'TKO Group Holdings', 'US'], + ['TTD', 'Trade Desk (The)', 'US'], + ['TSCO', 'Tractor Supply', 'US'], + ['TT', 'Trane Technologies', 'US'], + ['TDG', 'TransDigm Group', 'US'], + ['TRV', 'Travelers Companies (The)', 'US'], + ['TRMB', 'Trimble Inc.', 'US'], + ['TFC', 'Truist Financial', 'US'], + ['TYL', 'Tyler Technologies', 'US'], + ['TSN', 'Tyson Foods', 'US'], + ['USB', 'U.S. Bancorp', 'US'], + ['UBER', 'Uber', 'US'], + ['UDR', 'UDR, Inc.', 'US'], + ['ULTA', 'Ulta Beauty', 'US'], + ['UNP', 'Union Pacific Corporation', 'US'], + ['UAL', 'United Airlines Holdings', 'US'], + ['UPS', 'United Parcel Service', 'US'], + ['URI', 'United Rentals', 'US'], + ['UNH', 'UnitedHealth Group', 'US'], + ['UHS', 'Universal Health Services', 'US'], + ['VLO', 'Valero Energy', 'US'], + ['VEEV', 'Veeva Systems', 'US'], + ['VTR', 'Ventas', 'US'], + ['VLTO', 'Veralto', 'US'], + ['VRSN', 'Verisign', 'US'], + ['VRSK', 'Verisk Analytics', 'US'], + ['VZ', 'Verizon', 'US'], + ['VRTX', 'Vertex Pharmaceuticals', 'US'], + ['VRT', 'Vertiv', 'US'], + ['VTRS', 'Viatris', 'US'], + ['VICI', 'Vici Properties', 'US'], + ['V', 'Visa Inc.', 'US'], + ['VST', 'Vistra Corp.', 'US'], + ['VMC', 'Vulcan Materials Company', 'US'], + ['WRB', 'W. R. Berkley Corporation', 'US'], + ['GWW', 'W. W. Grainger', 'US'], + ['WAB', 'Wabtec', 'US'], + ['WMT', 'Walmart', 'US'], + ['DIS', 'Walt Disney Company (The)', 'US'], + ['WBD', 'Warner Bros. Discovery', 'US'], + ['WM', 'Waste Management', 'US'], + ['WAT', 'Waters Corporation', 'US'], + ['WEC', 'WEC Energy Group', 'US'], + ['WFC', 'Wells Fargo', 'US'], + ['WELL', 'Welltower', 'US'], + ['WST', 'West Pharmaceutical Services', 'US'], + ['WDC', 'Western Digital', 'US'], + ['WY', 'Weyerhaeuser', 'US'], + ['WSM', 'Williams-Sonoma, Inc.', 'US'], + ['WMB', 'Williams Companies', 'US'], + ['WTW', 'Willis Towers Watson', 'US'], + ['WDAY', 'Workday, Inc.', 'US'], + ['WYNN', 'Wynn Resorts', 'US'], + ['XEL', 'Xcel Energy', 'US'], + ['XYL', 'Xylem Inc.', 'US'], + ['YUM', 'Yum! Brands', 'US'], + ['ZBRA', 'Zebra Technologies', 'US'], + ['ZBH', 'Zimmer Biomet', 'US'], + ['ZTS', 'Zoetis', 'US'], +]) + +/** + * Representative liquid international listings used to diversify the fixture. + * Symbols use their local-market form and the third tuple value is an ISO-style + * country/market code, rather than a trading currency or exchange MIC. + * + * References checked 2026-08-15: STOXX Europe 50, KRX KOSPI market, + * JPX TOPIX Core30, and HKEX index constituent materials. + */ +const europeanInstruments = Object.freeze([ + ['ASML', 'ASML Holding', 'NL'], + ['INGA', 'ING Group', 'NL'], + ['ADYEN', 'Adyen', 'NL'], + ['PHIA', 'Philips', 'NL'], + ['HEIA', 'Heineken', 'NL'], + ['SAP', 'SAP', 'DE'], + ['SIE', 'Siemens', 'DE'], + ['ALV', 'Allianz', 'DE'], + ['DTE', 'Deutsche Telekom', 'DE'], + ['MBG', 'Mercedes-Benz Group', 'DE'], + ['BMW', 'BMW', 'DE'], + ['BAS', 'BASF', 'DE'], + ['MUV2', 'Munich Re', 'DE'], + ['VOW3', 'Volkswagen Preference', 'DE'], + ['IFX', 'Infineon Technologies', 'DE'], + ['MC', 'LVMH', 'FR'], + ['OR', "L'Oréal", 'FR'], + ['AIR', 'Airbus', 'FR'], + ['SU', 'Schneider Electric', 'FR'], + ['TTE', 'TotalEnergies', 'FR'], + ['SAN', 'Sanofi', 'FR'], + ['BNP', 'BNP Paribas', 'FR'], + ['CS', 'AXA', 'FR'], + ['DG', 'Vinci', 'FR'], + ['ENEL', 'Enel', 'IT'], + ['ENI', 'Eni', 'IT'], + ['ISP', 'Intesa Sanpaolo', 'IT'], + ['UCG', 'UniCredit', 'IT'], + ['STLAM', 'Stellantis', 'IT'], + ['SAN', 'Banco Santander', 'ES'], + ['IBE', 'Iberdrola', 'ES'], + ['ITX', 'Inditex', 'ES'], + ['BBVA', 'BBVA', 'ES'], + ['NESN', 'Nestlé', 'CH'], + ['ROG', 'Roche Holding', 'CH'], + ['NOVN', 'Novartis', 'CH'], + ['UBSG', 'UBS Group', 'CH'], + ['NOVO-B', 'Novo Nordisk', 'DK'], + ['MAERSK-B', 'A.P. Moller - Maersk', 'DK'], + ['VOLV-B', 'Volvo', 'SE'], + ['ERIC-B', 'Ericsson', 'SE'], + ['NOKIA', 'Nokia', 'FI'], + ['SHEL', 'Shell', 'GB'], + ['AZN', 'AstraZeneca', 'GB'], + ['HSBA', 'HSBC Holdings', 'GB'], + ['ULVR', 'Unilever', 'GB'], + ['LSEG', 'London Stock Exchange Group', 'GB'], +]) + +const europeanMarketCodes = Object.freeze([ + 'NL', + 'DE', + 'FR', + 'IT', + 'ES', + 'CH', + 'DK', + 'SE', + 'FI', + 'GB', +]) + +const europeanMarketGroups = Object.freeze( + europeanMarketCodes.map((market) => + europeanInstruments.filter(([, , instrumentMarket]) => + Object.is(instrumentMarket, market), + ), + ), +) + +const interleavedEuropeanInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...europeanMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + europeanMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const southKoreanInstruments = Object.freeze([ + ['005930', 'Samsung Electronics', 'KR'], + ['000660', 'SK hynix', 'KR'], + ['373220', 'LG Energy Solution', 'KR'], + ['207940', 'Samsung Biologics', 'KR'], + ['005380', 'Hyundai Motor', 'KR'], + ['000270', 'Kia', 'KR'], + ['068270', 'Celltrion', 'KR'], + ['105560', 'KB Financial Group', 'KR'], + ['055550', 'Shinhan Financial Group', 'KR'], + ['035420', 'NAVER', 'KR'], + ['035720', 'Kakao', 'KR'], + ['006400', 'Samsung SDI', 'KR'], + ['051910', 'LG Chem', 'KR'], + ['012330', 'Hyundai Mobis', 'KR'], + ['066570', 'LG Electronics', 'KR'], +]) + +const japaneseInstruments = Object.freeze([ + ['8306', 'Mitsubishi UFJ Financial Group', 'JP'], + ['7203', 'Toyota Motor', 'JP'], + ['6501', 'Hitachi', 'JP'], + ['8316', 'Sumitomo Mitsui Financial Group', 'JP'], + ['6758', 'Sony Group', 'JP'], + ['8058', 'Mitsubishi Corporation', 'JP'], + ['9984', 'SoftBank Group', 'JP'], + ['8035', 'Tokyo Electron', 'JP'], + ['8411', 'Mizuho Financial Group', 'JP'], + ['8031', 'Mitsui & Co.', 'JP'], + ['6861', 'Keyence', 'JP'], + ['7974', 'Nintendo', 'JP'], + ['6098', 'Recruit Holdings', 'JP'], + ['9432', 'Nippon Telegraph and Telephone', 'JP'], + ['4063', 'Shin-Etsu Chemical', 'JP'], +]) + +const hongKongInstruments = Object.freeze([ + ['0700', 'Tencent Holdings', 'HK'], + ['9988', 'Alibaba Group', 'HK'], + ['1810', 'Xiaomi', 'HK'], + ['3690', 'Meituan', 'HK'], + ['0941', 'China Mobile', 'HK'], + ['1211', 'BYD Company', 'HK'], + ['1299', 'AIA Group', 'HK'], + ['0388', 'Hong Kong Exchanges and Clearing', 'HK'], + ['0005', 'HSBC Holdings', 'HK'], + ['2318', 'Ping An Insurance', 'HK'], +]) + +const canadianInstruments = Object.freeze([ + ['RY', 'Royal Bank of Canada', 'CA'], + ['TD', 'Toronto-Dominion Bank', 'CA'], + ['SHOP', 'Shopify', 'CA'], + ['ENB', 'Enbridge', 'CA'], + ['CNR', 'Canadian National Railway', 'CA'], + ['CP', 'Canadian Pacific Kansas City', 'CA'], + ['BMO', 'Bank of Montreal', 'CA'], + ['CSU', 'Constellation Software', 'CA'], +]) + +const australianInstruments = Object.freeze([ + ['BHP', 'BHP Group', 'AU'], + ['CBA', 'Commonwealth Bank of Australia', 'AU'], + ['CSL', 'CSL', 'AU'], + ['NAB', 'National Australia Bank', 'AU'], + ['WBC', 'Westpac Banking Corporation', 'AU'], + ['ANZ', 'ANZ Group Holdings', 'AU'], + ['WES', 'Wesfarmers', 'AU'], + ['MQG', 'Macquarie Group', 'AU'], +]) + +const internationalMarketGroups = Object.freeze([ + interleavedEuropeanInstruments, + southKoreanInstruments, + japaneseInstruments, + hongKongInstruments, + canadianInstruments, + australianInstruments, +]) + +export const internationalInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...internationalMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + internationalMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const INTERNATIONAL_INSERTION_INTERVAL = 3 + +/** + * U.S. and international instruments are interleaved so ordinary benchmark + * sizes exercise multiple symbol formats and market labels. + */ +export const globalInstruments = Object.freeze( + marketInstruments.flatMap((instrument, index) => { + const internationalInstrument = + index % INTERNATIONAL_INSERTION_INTERVAL === 0 + ? internationalInstruments[index / INTERNATIONAL_INSERTION_INTERVAL] + : undefined + + return internationalInstrument + ? [instrument, internationalInstrument] + : [instrument] + }), +) as unknown as ReadonlyArray diff --git a/examples/alpine/realtime-trading/src/feed/worker/market-feed-engine.ts b/examples/alpine/realtime-trading/src/feed/worker/market-feed-engine.ts new file mode 100644 index 0000000000..fbd9c369c0 --- /dev/null +++ b/examples/alpine/realtime-trading/src/feed/worker/market-feed-engine.ts @@ -0,0 +1,177 @@ +import { globalInstruments } from '../market-instruments.ts' +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const INITIAL_MARKET_SEED = 0x4d41524b +const LIVE_FEED_SEED = 0x5449434b + +export class MarketFeedEngine { + #quotes: Array = [] + #lastHistorySampledAt = new Uint32Array(0) + #random = createRandom(2_026) + #rowCursor = 0 + #tickIndex = 0 + + reset(count: number): Array { + const random = createRandom(INITIAL_MARKET_SEED ^ count) + const createdAt = Date.now() + + this.#quotes = Array.from({ length: count }, (_, index) => { + const [baseSymbol, company, market] = + globalInstruments[index % globalInstruments.length] + const series = Math.floor(index / globalInstruments.length) + const symbol = series === 0 ? baseSymbol : `${baseSymbol}${series}` + const previousClose = roundPrice(20 + random() * 480) + const open = roundPrice(previousClose * (1 + (random() - 0.5) * 0.016)) + const spread = Math.max(0.01, open * (0.0002 + random() * 0.0004)) + const history = Array.from({ length: 24 }, (_, historyIndex) => + roundPrice( + open * + (1 + Math.sin(historyIndex / 4) * 0.002 + (random() - 0.5) * 0.001), + ), + ) + const volume = Math.floor(50_000 + random() * 2_000_000) + const lastSize = Math.floor(10 + random() * 5_000) + + return { + id: `instrument-${index}`, + symbol, + company, + venue: market, + previousClose, + open, + high: open, + low: open, + price: open, + bid: roundPrice(open - spread / 2), + ask: roundPrice(open + spread / 2), + bidSize: Math.floor(100 + random() * 25_000), + askSize: Math.floor(100 + random() * 25_000), + lastSize, + lastMove: 0, + lastUpdatedAt: createdAt, + volume, + turnover: roundMoney(open * volume), + history, + } + }) + + this.#random = createRandom(LIVE_FEED_SEED ^ count) + this.#rowCursor = 0 + this.#lastHistorySampledAt = new Uint32Array(count) + this.#lastHistorySampledAt.fill(createdAt >>> 0) + + return this.#quotes.map((quote) => ({ + ...quote, + history: [...quote.history], + })) + } + + applyTicks( + tickCount: number, + updateSparklines: boolean, + sparklineSampleIntervalMs: number, + ): Array { + if (this.#quotes.length === 0 || tickCount <= 0) return [] + + const updatedAt = Date.now() + const sampledAt = updatedAt >>> 0 + const sampleIntervalMs = Math.max(16, sparklineSampleIntervalMs) + const updatedQuotes = new Map() + const stride = 97 + + this.#tickIndex = 0 + while (this.#tickIndex < tickCount) { + this.#rowCursor = (this.#rowCursor + stride) % this.#quotes.length + const quote = this.#quotes[this.#rowCursor] + const lastSampledAt = this.#lastHistorySampledAt[this.#rowCursor] + const shouldUpdateHistory = + updateSparklines && + (sampledAt - lastSampledAt) >>> 0 >= sampleIntervalMs + + if (shouldUpdateHistory) { + this.#lastHistorySampledAt[this.#rowCursor] = sampledAt + } + + this.#applyTick(quote, shouldUpdateHistory, updatedAt) + + const previousUpdate = updatedQuotes.get(this.#rowCursor) + updatedQuotes.set(this.#rowCursor, { + index: this.#rowCursor, + price: quote.price, + bid: quote.bid, + ask: quote.ask, + bidSize: quote.bidSize, + askSize: quote.askSize, + lastSize: quote.lastSize, + lastMove: quote.lastMove, + lastUpdatedAt: quote.lastUpdatedAt, + high: quote.high, + low: quote.low, + volume: quote.volume, + turnover: quote.turnover, + ...(shouldUpdateHistory || previousUpdate?.history + ? { history: [...quote.history] } + : {}), + }) + this.#tickIndex++ + } + + return [...updatedQuotes.values()] + } + + #applyTick( + quote: MarketQuoteSnapshot, + updateHistory: boolean, + updatedAt: number, + ): void { + const previousPrice = quote.price + const volatility = 0.00015 + this.#random() * 0.0012 + const move = previousPrice * (this.#random() - 0.495) * volatility + const nextPrice = roundPrice(Math.max(0.1, previousPrice + move)) + const spread = Math.max( + 0.01, + nextPrice * (0.00015 + this.#random() * 0.0005), + ) + + quote.lastMove = nextPrice - previousPrice + quote.price = nextPrice + quote.high = Math.max(quote.high, nextPrice) + quote.low = Math.min(quote.low, nextPrice) + quote.bid = roundPrice(nextPrice - spread / 2) + quote.ask = roundPrice(nextPrice + spread / 2) + quote.bidSize = Math.floor(100 + this.#random() * 25_000) + quote.askSize = Math.floor(100 + this.#random() * 25_000) + quote.lastSize = Math.floor(10 + this.#random() * 5_000) + quote.lastUpdatedAt = updatedAt + quote.volume += quote.lastSize + quote.turnover = roundMoney(quote.turnover + nextPrice * quote.lastSize) + + if (updateHistory) { + quote.history = [...quote.history.slice(-23), nextPrice] + } + } +} + +function createRandom(seed: number): () => number { + const runtime = { state: seed >>> 0 } + return () => { + runtime.state += 0x6d2b79f5 + const stateValue = runtime.state + const firstMix = Math.imul(stateValue ^ (stateValue >>> 15), stateValue | 1) + const secondMix = + firstMix + Math.imul(firstMix ^ (firstMix >>> 7), firstMix | 61) + const value = firstMix ^ secondMix + return ((value ^ (value >>> 14)) >>> 0) / 4_294_967_296 + } +} + +function roundPrice(value: number): number { + return Math.round(value * 100) / 100 +} + +function roundMoney(value: number): number { + return Math.round(value * 100) / 100 +} diff --git a/examples/alpine/realtime-trading/src/feed/worker/market-feed-protocol.ts b/examples/alpine/realtime-trading/src/feed/worker/market-feed-protocol.ts new file mode 100644 index 0000000000..21997ec89c --- /dev/null +++ b/examples/alpine/realtime-trading/src/feed/worker/market-feed-protocol.ts @@ -0,0 +1,70 @@ +export interface MarketQuoteSnapshot { + id: string + symbol: string + company: string + venue: string + previousClose: number + open: number + high: number + low: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + volume: number + turnover: number + history: Array +} + +export interface MarketQuoteUpdate { + index: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + high: number + low: number + volume: number + turnover: number + history?: Array +} + +export type MarketFeedCommand = + | { + type: 'start' + rowCount: number + running: boolean + ticksPerSecond: number + publishIntervalMs: number + updateSparklines: boolean + sparklineSampleIntervalMs: number + } + | { type: 'set-running'; running: boolean } + | { type: 'set-rate'; ticksPerSecond: number } + | { type: 'set-publish-interval'; intervalMs: number } + | { type: 'set-sparklines'; enabled: boolean } + | { type: 'set-sparkline-interval'; intervalMs: number } + | { type: 'reset'; rowCount: number } + | { type: 'burst'; tickCount: number } + +export type MarketFeedEvent = + | { + type: 'snapshot' + sessionId: number + quotes: Array + } + | { + type: 'updates' + sessionId: number + tickCount: number + coalescedUpdateCount: number + updates: Array + } diff --git a/examples/alpine/realtime-trading/src/feed/worker/market-feed.worker.ts b/examples/alpine/realtime-trading/src/feed/worker/market-feed.worker.ts new file mode 100644 index 0000000000..2b7a642fd9 --- /dev/null +++ b/examples/alpine/realtime-trading/src/feed/worker/market-feed.worker.ts @@ -0,0 +1,143 @@ +import { initialMarketFeedConfig } from '../market-feed-config' +import { MarketFeedEngine } from './market-feed-engine' +import type { + MarketFeedCommand, + MarketFeedEvent, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const engine = new MarketFeedEngine() +const pendingUpdates = new Map() +const runtime = { + sessionId: 0, + pendingTickCount: 0, + pendingCoalescedUpdateCount: 0, + initialized: false, + running: true, + ticksPerSecond: initialMarketFeedConfig.targetSamplesPerSecond, + publishIntervalMs: initialMarketFeedConfig.publishIntervalMs, + publishTimerId: null as ReturnType | null, + updateSparklines: initialMarketFeedConfig.updateSparklines, + sparklineSampleIntervalMs: initialMarketFeedConfig.sparklineSampleIntervalMs, + tickBudget: 0, + lastTickAt: performance.now(), +} + +addEventListener('message', ({ data }: MessageEvent) => { + switch (data.type) { + case 'start': + runtime.running = data.running + runtime.ticksPerSecond = data.ticksPerSecond + runtime.publishIntervalMs = data.publishIntervalMs + runtime.updateSparklines = data.updateSparklines + runtime.sparklineSampleIntervalMs = data.sparklineSampleIntervalMs + restartPublishTimer() + reset(data.rowCount) + break + case 'set-running': + runtime.running = data.running + break + case 'set-rate': + runtime.ticksPerSecond = data.ticksPerSecond + break + case 'set-publish-interval': + runtime.publishIntervalMs = Math.max(4, data.intervalMs) + restartPublishTimer() + break + case 'set-sparklines': + runtime.updateSparklines = data.enabled + break + case 'set-sparkline-interval': + runtime.sparklineSampleIntervalMs = Math.max(16, data.intervalMs) + break + case 'reset': + reset(data.rowCount) + break + case 'burst': + produceTicks(data.tickCount) + flush() + break + } +}) + +setInterval(() => { + const now = performance.now() + const elapsed = Math.min(100, Math.max(0, now - runtime.lastTickAt)) + runtime.lastTickAt = now + + if (runtime.initialized && runtime.running) { + runtime.tickBudget += (runtime.ticksPerSecond * elapsed) / 1_000 + const tickCount = Math.floor(runtime.tickBudget) + runtime.tickBudget -= tickCount + produceTicks(tickCount) + } +}, 16) + +restartPublishTimer() + +function reset(rowCount: number): void { + runtime.initialized = true + runtime.sessionId++ + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + runtime.tickBudget = 0 + runtime.lastTickAt = performance.now() + + post({ + type: 'snapshot', + sessionId: runtime.sessionId, + quotes: engine.reset(rowCount), + }) +} + +function produceTicks(tickCount: number): void { + if (!runtime.initialized || tickCount <= 0) return + + runtime.pendingTickCount += tickCount + for (const update of engine.applyTicks( + tickCount, + runtime.updateSparklines, + runtime.sparklineSampleIntervalMs, + )) { + const previousUpdate = pendingUpdates.get(update.index) + if (previousUpdate) runtime.pendingCoalescedUpdateCount++ + pendingUpdates.set(update.index, { + ...update, + ...(update.history || !previousUpdate?.history + ? {} + : { history: previousUpdate.history }), + }) + } +} + +function flush(): void { + if (runtime.pendingTickCount === 0) return + + const message: MarketFeedEvent = { + type: 'updates', + sessionId: runtime.sessionId, + tickCount: runtime.pendingTickCount, + coalescedUpdateCount: runtime.pendingCoalescedUpdateCount, + updates: [...pendingUpdates.values()], + } + + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + post(message) +} + +function restartPublishTimer(): void { + if (runtime.publishTimerId !== null) { + clearInterval(runtime.publishTimerId) + } + runtime.publishTimerId = setInterval( + flush, + Math.max(4, runtime.publishIntervalMs), + ) +} + +function post(event: MarketFeedEvent): void { + postMessage(event) +} diff --git a/examples/alpine/realtime-trading/src/index.css b/examples/alpine/realtime-trading/src/index.css new file mode 100644 index 0000000000..7f670c5626 --- /dev/null +++ b/examples/alpine/realtime-trading/src/index.css @@ -0,0 +1,1007 @@ +:root { + color-scheme: dark; + --font-ui: + Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, + 'Segoe UI', sans-serif; + --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace; + font-family: var(--font-ui); + font-synthesis: none; + --background: #050505; + --panel: #080808; + --panel-raised: #111111; + --panel-hover: #181818; + --surface-bar: #080808; + --surface-toolbar: #0d0d0d; + --surface-table: #050505; + --surface-header: #101010; + --surface-control: #151515; + --border: #303030; + --border-soft: #242424; + --border-strong: #4a4a4a; + --text: #e7ebf0; + --text-strong: #ffffff; + --text-inverse: #f7f9fb; + --muted: #737982; + --blue: #62a9ff; + --blue-soft: #a9d0ff; + --green: #42e488; + --red: #ff646b; + --amber: #dfb465; + --depth-bid: #315774; + --depth-ask: #634049; + --row-alt: rgb(255 255 255 / 1.8%); + --row-selected: rgb(66 132 214 / 16%); + --control-border: #354456; + --control-hover: #192431; + --sidebar-width: 18rem; + --shell-bar-height: 2.625rem; + --metrics-height: 3.5rem; + --statusbar-height: 1.625rem; + --table-header-height: 2rem; + --table-row-height: 2rem; + --shell-inline-padding: 0.75rem; + --table-cell-inline-padding: 0.6rem; + --control-radius: 1px; +} + +* { + box-sizing: border-box; +} + +html, +body { + min-width: 320px; + min-height: 100%; + margin: 0; + background: var(--background); +} + +body { + color: var(--text); +} + +button, +select, +input { + font: inherit; +} + +button, +select { + color: var(--text); + background: var(--panel-raised); + border: 1px solid var(--control-border); + border-radius: var(--control-radius); +} + +button { + padding: 0.5rem 0.65rem; + cursor: pointer; + font-size: 0.72rem; + font-weight: 650; + letter-spacing: 0.025em; +} + +button:hover { + background: var(--control-hover); + border-color: var(--border-strong); +} + +button:focus-visible, +select:focus-visible, +input:focus-visible { + outline: 1px solid var(--blue); + outline-offset: 1px; +} + +select { + width: 100%; + padding: 0.45rem 0.55rem; + font-size: 0.75rem; +} + +.trading-terminal { + --active-sidebar-width: var(--sidebar-width); + display: grid; + width: 100%; + height: 100dvh; + min-height: 0; + overflow: hidden; + background: var(--background); + grid-template-areas: + 'header sidebar' + 'content sidebar' + 'footer sidebar'; + grid-template-columns: minmax(0, 1fr) var(--active-sidebar-width); + grid-template-rows: auto minmax(0, 1fr) auto; + transition: grid-template-columns 160ms ease; +} + +.trading-terminal.is-sidebar-collapsed { + --active-sidebar-width: 0px; +} + +.shell-header { + display: flex; + min-width: 0; + flex-direction: column; + grid-area: header; +} + +.app-bar { + display: flex; + min-height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + background: var(--surface-bar); + border-bottom: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.68rem; + letter-spacing: 0.045em; +} + +.brand, +.header-actions, +.feed-status { + display: flex; + align-items: center; +} + +.brand { + gap: 0.65rem; + color: var(--text-strong); +} + +.header-actions { + gap: 0.75rem; +} + +.sidebar-toggle { + display: grid; + width: 1.9rem; + height: 1.9rem; + padding: 0; + place-items: center; + color: var(--muted); + background: transparent; + border-color: transparent; +} + +.sidebar-toggle:hover { + color: var(--text-strong); + background: var(--surface-control); + border-color: var(--border); +} + +.sidebar-toggle svg { + width: 1rem; + height: 1rem; + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-width: 1.4; +} + +.feed-status { + gap: 0.4rem; + color: var(--muted); +} + +.feed-status.is-running { + color: var(--green); +} + +.status-dot { + width: 6px; + height: 6px; + background: var(--muted); + border-radius: 50%; +} + +.feed-status.is-running .status-dot { + background: var(--green); +} + +.development-warning { + flex: 0 0 auto; + padding: 0.3rem 0.75rem; + color: var(--amber); + background: color-mix(in srgb, var(--amber) 8%, var(--background)); + border-bottom: 1px solid color-mix(in srgb, var(--amber) 24%, var(--border)); + font-family: var(--font-mono); + font-size: 0.62rem; + letter-spacing: 0.04em; +} + +.market-panel { + display: flex; + min-width: 0; + min-height: 0; + flex-direction: column; + background: var(--panel); + grid-area: content; +} + +.metrics-strip { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + background: var(--border); + border-bottom: 1px solid var(--border); + gap: 1px; +} + +.metrics-strip h2 { + margin: 0; + padding: 0.65rem var(--shell-inline-padding) 0.45rem; + color: var(--muted); + background: var(--surface-table); + font-size: 0.58rem; + grid-column: 1 / -1; + letter-spacing: 0.075em; +} + +.metrics-strip article { + min-width: 0; + min-height: 4.25rem; + padding: 0.5rem var(--shell-inline-padding); + background: var(--surface-bar); +} + +.metrics-strip span, +.metrics-strip small { + display: block; + color: var(--muted); + font-size: 0.56rem; + letter-spacing: 0.045em; + line-height: 1.35; +} + +.metrics-strip strong { + display: block; + margin: 0.12rem 0 0.08rem; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.88rem; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +.metrics-strip strong.metric-alert { + color: var(--amber); +} + +.table-scroll { + flex: 1; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +table { + min-width: 100%; + border-spacing: 0; + table-layout: fixed; + font-family: var(--font-ui); + font-size: 0.78rem; + font-variant-numeric: tabular-nums; +} + +.trading-data-grid { + display: grid; +} + +.trading-data-grid thead, +.trading-data-grid tbody { + display: grid; +} + +.trading-data-grid tbody { + -webkit-user-select: none; + user-select: none; +} + +.trading-data-grid thead > tr, +.trading-data-grid tbody > tr { + display: flex; + width: 100%; +} + +.trading-data-grid tbody > tr { + min-height: var(--table-row-height); + content-visibility: auto; + contain-intrinsic-block-size: var(--table-row-height); +} + +.trading-data-grid th, +.trading-data-grid td { + flex: 0 0 auto; +} + +thead { + position: sticky; + z-index: 2; + top: 0; +} + +th { + height: var(--table-header-height); + padding: 0 var(--table-cell-inline-padding); + color: var(--muted); + background: var(--surface-header); + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border); + font-size: 0.7rem; + font-weight: 500; + letter-spacing: 0.005em; + text-align: left; + white-space: nowrap; +} + +th.column-group-header { + color: #666b72; + font-size: 0.72rem; + font-weight: 500; + text-align: center; +} + +thead tr:first-child th.column-group-header { + color: #777d85; + font-size: 0.76rem; +} + +th.numeric-header { + text-align: right; +} + +td { + height: var(--table-row-height); + padding: 0 var(--table-cell-inline-padding); + overflow: hidden; + color: #eef1f5; + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border-soft); + text-align: right; + text-overflow: ellipsis; + white-space: nowrap; +} + +th:last-child, +td:last-child { + border-right: 0; +} + +td[data-column-id='market'], +td[data-column-id='name'], +td[data-column-id='symbol'] { + text-align: left; +} + +td[data-column-id='market'] { + color: var(--blue); + font-weight: 550; +} + +td[data-column-id='name'] { + color: var(--text-strong); +} + +td[data-column-id='symbol'] { + color: #d8dde4; + font-weight: 600; +} + +tbody tr:nth-child(even) { + background: var(--row-alt); +} + +tbody tr:hover { + background: var(--panel-hover); +} + +tbody tr[data-symbol-selected='true'] { + background: var(--row-selected); + box-shadow: inset 2px 0 0 var(--blue); +} + +.table-scroll:focus { + outline: none; +} + +th { + position: relative; +} + +.leaf-header-content { + display: flex; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + height: 100%; + align-items: stretch; + margin-inline: calc(-1 * var(--table-cell-inline-padding)); +} + +.column-drag-handle, +.sort-header-button { + min-width: 0; + height: 100%; + padding: 0; + color: inherit; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-weight: inherit; + letter-spacing: inherit; +} + +.column-drag-handle { + flex: 0 0 1.05rem; + color: var(--muted); + cursor: grab; + opacity: 0.35; + font-size: 0.56rem; + letter-spacing: -0.32rem; + text-align: center; +} + +.column-drag-handle:active { + cursor: grabbing; +} + +th:hover .column-drag-handle, +.column-drag-handle:focus-visible { + opacity: 0.9; +} + +.column-drag-handle:hover, +.sort-header-button:hover { + background: rgb(255 255 255 / 4%); + border-color: transparent; +} + +th.is-column-dragging { + opacity: 0.45; +} + +th.is-column-drop-target { + background: rgb(50 139 255 / 16%); + box-shadow: inset 4px 0 0 var(--blue); +} + +th.is-column-drop-target::before { + position: absolute; + z-index: 6; + top: -1px; + bottom: -1px; + left: -2px; + width: 4px; + background: #62a9ff; + box-shadow: + 0 0 0 1px rgb(0 0 0 / 55%), + 0 0 12px rgb(70 151 255 / 90%); + content: ''; + pointer-events: none; +} + +.sort-header-button { + display: flex; + min-width: 0; + flex: 1; + align-items: center; + justify-content: flex-start; + gap: 0.3rem; + padding-inline: 0.25rem var(--table-cell-inline-padding); + cursor: default; + text-align: inherit; +} + +.numeric-header .sort-header-button { + justify-content: flex-end; +} + +.sort-header-button.is-sortable { + cursor: pointer; +} + +.sort-header-button:disabled { + opacity: 1; +} + +.header-label { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.sort-indicator { + flex: 0 0 auto; + color: #66717e; + font-size: 0.72rem; +} + +.sort-indicator.is-active { + color: var(--blue-soft); +} + +.column-resize-handle { + position: absolute; + z-index: 3; + top: 0; + right: -3px; + width: 7px; + height: 100%; + cursor: col-resize; + touch-action: none; + user-select: none; +} + +.column-resize-handle::after { + position: absolute; + top: 20%; + right: 3px; + width: 1px; + height: 60%; + background: var(--border-strong); + content: ''; + opacity: 0; +} + +th:hover > .column-resize-handle::after, +.column-resize-handle.is-resizing::after { + background: var(--blue); + opacity: 1; +} + +tbody tr[aria-selected='true'] { + background: rgb(76 145 228 / 13%); +} + +td[aria-selected='true'] { + position: relative; + background: rgb(70 139 222 / 12%); +} + +td[data-cell-focused='true'] { + background: rgb(70 139 222 / 21%); +} + +td[aria-selected='true']::after { + position: absolute; + z-index: 1; + inset: 0; + border: 1px solid transparent; + content: ''; + pointer-events: none; +} + +td[data-selection-top='true']::after { + border-top-color: var(--blue); +} + +td[data-selection-right='true']::after { + border-right-color: var(--blue); +} + +td[data-selection-bottom='true']::after { + border-bottom-color: var(--blue); +} + +td[data-selection-left='true']::after { + border-left-color: var(--blue); +} + +.price-button { + min-width: 4.5rem; + padding: 0; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-variant-numeric: tabular-nums; + font-weight: 600; + text-align: right; +} + +.price-button:hover { + background: transparent; + text-decoration: underline; + text-underline-offset: 2px; +} + +.move-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.move-cell.quote-up, +.percent-change-cell.quote-up { + background: color-mix(in srgb, var(--green) 7%, transparent); +} + +.move-cell.quote-down, +.percent-change-cell.quote-down { + background: color-mix(in srgb, var(--red) 7%, transparent); +} + +.percent-change-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.spread-cell { + display: flex; + align-items: baseline; + justify-content: flex-end; + gap: 0.35rem; + color: var(--text); +} + +.spread-cell small { + min-width: 2.8rem; + color: var(--muted); + font-size: 0.55rem; +} + +.spread-cell.spread-wide, +.spread-cell.spread-wide small { + color: var(--amber); +} + +.depth-cell { + position: relative; + display: flex; + height: 17px; + overflow: hidden; + background: var(--surface-control); +} + +.depth-bid, +.depth-ask { + height: 100%; + opacity: 0.78; +} + +.depth-bid { + background: var(--depth-bid); + border-right: 1px solid var(--panel); +} + +.depth-ask { + background: var(--depth-ask); +} + +.depth-values { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 0.28rem; + color: var(--text-strong); + font-size: 0.57rem; + text-shadow: 0 1px var(--background); +} + +.quote-age { + color: var(--muted); +} + +.quote-age-warm { + color: var(--amber); +} + +.quote-age-stale { + color: var(--red); +} + +.quote-up { + color: var(--green); +} + +.quote-down { + color: var(--red); +} + +.sparkline { + display: block; + width: 100%; + height: 1.35rem; + margin-left: auto; + color: var(--blue-soft); + overflow: visible; +} + +.sparkline.quote-up { + color: var(--green); +} + +.sparkline.quote-down { + color: var(--red); +} + +.sparkline polyline { + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-linejoin: miter; + stroke-width: 1.25; + vector-effect: non-scaling-stroke; +} + +.market-statusbar { + display: flex; + flex: 0 0 var(--statusbar-height); + min-height: var(--statusbar-height); + gap: 1.1rem; + align-items: center; + padding: 0 0.65rem; + color: var(--muted); + background: var(--surface-bar); + border-top: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.56rem; + grid-area: footer; + letter-spacing: 0.035em; +} + +.market-statusbar strong { + margin-left: 0.25rem; + color: var(--text); + font-weight: 500; +} + +.sidebar-slot { + width: var(--sidebar-width); + min-width: 0; + min-height: 0; + overflow: hidden; + background: var(--surface-table); + border-left: 1px solid var(--border); + grid-area: sidebar; + transition: + opacity 120ms ease, + transform 160ms ease, + visibility 160ms; +} + +.is-sidebar-collapsed .sidebar-slot { + visibility: hidden; + opacity: 0; + pointer-events: none; + transform: translateX(100%); +} + +.configurator { + width: 100%; + height: 100%; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +.configurator > header { + display: flex; + height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + color: var(--text-strong); + background: var(--surface-toolbar); + border-bottom: 1px solid var(--border); + font-size: 0.65rem; + font-weight: 700; + letter-spacing: 0.055em; +} + +.configurator > header small { + color: var(--muted); + font-size: 0.54rem; + font-weight: 500; +} + +.config-section { + display: grid; + gap: 0.7rem; + padding: 0.8rem var(--shell-inline-padding); + border-bottom: 1px solid var(--border); +} + +.config-section h2 { + margin: 0; + color: var(--muted); + font-size: 0.58rem; + letter-spacing: 0.075em; +} + +.primary-action { + width: 100%; + color: var(--text-inverse); + background: var(--blue); + border-color: var(--blue-soft); +} + +.primary-action:hover { + background: var(--blue-soft); + border-color: var(--text-strong); +} + +.field { + display: grid; + gap: 0.35rem; + color: var(--text); + font-size: 0.66rem; +} + +.rate-field > span { + display: flex; + justify-content: space-between; +} + +.rate-field strong { + color: var(--text); + font-family: var(--font-mono); + font-weight: 500; +} + +.field small { + color: var(--muted); + font-family: var(--font-mono); + font-size: 0.55rem; +} + +input[type='range'] { + width: 100%; + margin: 0; + accent-color: var(--blue); +} + +.toggle-field { + display: flex; + gap: 0.5rem; + align-items: flex-start; + color: var(--text); + font-size: 0.66rem; + line-height: 1.3; +} + +.toggle-field input { + margin: 0.12rem 0 0; + accent-color: var(--blue); +} + +.toggle-field small { + display: block; + margin-top: 0.14rem; + color: var(--muted); + font-size: 0.57rem; +} + +.action-grid { + display: grid; + grid-template-columns: 1fr; + gap: 0.4rem; +} + +.diagnostics dl, +.selected-instrument dl { + display: grid; + gap: 0; + margin: 0; +} + +.diagnostics dl > div, +.selected-instrument dl > div { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 24px; + border-bottom: 1px solid var(--border-soft); +} + +.diagnostics dl > div:last-child, +.selected-instrument dl > div:last-child { + border-bottom: 0; +} + +.diagnostics dl > div:has(dd[data-testid$='-breakdown']) { + display: grid; + grid-template-columns: minmax(0, 1fr); + align-content: center; + padding-block: 0.28rem; +} + +.diagnostics dd[data-testid$='-breakdown'] { + width: 100%; + overflow-x: auto; + padding-block: 0.12rem; + white-space: nowrap; + scrollbar-width: thin; +} + +dt { + color: var(--muted); + font-size: 0.61rem; +} + +dd { + margin: 0; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.62rem; +} + +.selection { + display: flex; + align-items: flex-start; + justify-content: space-between; +} + +.selection div { + display: grid; + gap: 0.18rem; +} + +.selection strong { + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.85rem; +} + +.selection span, +.selection small, +.selected-instrument p { + color: var(--muted); + font-size: 0.61rem; +} + +.selected-instrument p { + margin: 0; + line-height: 1.45; +} + +@media (max-width: 980px) { + :root { + --sidebar-width: 15.625rem; + } +} + +@media (max-width: 720px) { + .trading-terminal { + --active-sidebar-width: 0px; + height: 100dvh; + min-height: 0; + overflow: hidden; + } + + .market-panel { + min-height: 0; + } + + .table-scroll { + min-height: 0; + } + + .sidebar-slot { + position: fixed; + z-index: 20; + top: 0; + right: 0; + bottom: 0; + width: min(var(--sidebar-width), calc(100vw - 2.75rem)); + box-shadow: -18px 0 42px rgb(0 0 0 / 48%); + } + + .is-sidebar-collapsed .sidebar-slot { + box-shadow: none; + } +} diff --git a/examples/alpine/realtime-trading/src/main.ts b/examples/alpine/realtime-trading/src/main.ts new file mode 100644 index 0000000000..5ad223d3c7 --- /dev/null +++ b/examples/alpine/realtime-trading/src/main.ts @@ -0,0 +1,565 @@ +import Alpine from 'alpinejs' +import { shallow } from '@tanstack/store' +import { FlexRender, createTable } from '@tanstack/alpine-table' +import { TradingBenchmarkController } from './benchmark/trading-benchmark-controller' +import { MarketFeedController } from './feed/market-feed-controller' +import { + feedSampleRateAt, + feedSampleRateIndex, + feedSampleRateOptions, +} from './feed/feed-sample-rates' +import { configuratorOptions } from './shell/configurator-options' +import { + createTradingColumns, + readMeasuredRows, +} from './table/table-config/trading-columns' +import { tradingFeatures } from './table/trading-features' +import { + TradingGridPointerController, + handleCellNavigation, + reorderColumnIds, + sortAriaValue, + sortIndicator, +} from './table/table-interactions' +import './table/table-config/quote-cells' +import './index.css' +import type { AlpineTable } from '@tanstack/alpine-table' +import type { MarketQuote } from './feed/market-data' + +type Table = AlpineTable +const integer = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }) +const rate = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const ms = (number: number) => `${number.toFixed(2)} ms` + +function applyCellMarkup(element: HTMLElement, markup: unknown) { + const html = markup == null ? '' : String(markup) + const existing = element.firstElementChild as HTMLElement | null + if (existing && html.startsWith('<')) { + const closeIndex = html.indexOf('>') + const startTag = closeIndex === -1 ? html : html.slice(1, closeIndex) + const tagName = startTag.split(/\s/, 1)[0]?.replace(/\/$/, '') + if (tagName && existing.tagName.toLowerCase() === tagName) { + for (const match of startTag.matchAll(/([^\s=]+)="([^"]*)"/g)) { + const name = match[1]! + const value = match[2]! + if (existing.getAttribute(name) !== value) { + existing.setAttribute(name, value) + } + } + return + } + } + if (element.innerHTML !== html) { + element.innerHTML = html + } +} + +Alpine.data('tradingApp', () => { + const feed = new MarketFeedController() + const controller = new TradingBenchmarkController(feed) + const local = Alpine.reactive({ + feed: { + workerReady: feed.workerReady.get(), + running: feed.running.get(), + instrumentCount: feed.instrumentCount.get(), + targetTicksPerSecond: feed.targetTicksPerSecond.get(), + publishIntervalMs: feed.publishIntervalMs.get(), + updateSparklines: feed.updateSparklines.get(), + sparklineSampleIntervalMs: feed.sparklineSampleIntervalMs.get(), + quotes: feed.quotes.get(), + }, + benchmark: controller.store.get(), + selectedSymbol: controller.renderAtoms.selectedSymbol.get(), + rendererMode: controller.renderAtoms.rendererMode.get(), + sidebarOpen: true, + tableVersion: 0, + quotesVersion: 0, + }) + const columns = createTradingColumns(() => local.rendererMode) + const table = createTable( + { + key: 'alpine-realtime-trading', + features: tradingFeatures, + columns, + get data() { + return local.feed.quotes + }, + getRowId: (row: MarketQuote) => row.id, + columnResizeMode: 'onChange', + defaultColumn: { minSize: 56, maxSize: 800 }, + autoResetCellSelection: false, + }, + (state) => ({ + sorting: state.sorting, + columnFilters: state.columnFilters, + columnOrder: state.columnOrder, + rowSelection: state.rowSelection, + cellSelection: state.cellSelection, + }), + ) + const pointer = new TradingGridPointerController() + const runtime = { + cleanups: [] as Array<() => void>, + manuallyResized: false, + dragColumnId: null as string | null, + dragSource: null as HTMLTableCellElement | null, + dragTarget: null as HTMLTableCellElement | null, + cachedRows: [] as ReturnType['rows'], + cachedFeed: null as Array | null, + cachedTableVersion: -1, + lastRenderedRowCount: -1, + lastTableUi: null as { + sorting: unknown + columnFilters: unknown + columnOrder: unknown + rowSelection: unknown + cellSelection: unknown + } | null, + domCommitScheduled: false, + } + const rows = () => { + if ( + runtime.cachedFeed !== local.feed.quotes || + runtime.cachedTableVersion !== local.tableVersion + ) { + runtime.cachedFeed = local.feed.quotes + runtime.cachedTableVersion = local.tableVersion + runtime.cachedRows = readMeasuredRows(() => table.getRowModel().rows) + } + return runtime.cachedRows + } + const renderRows = () => { + void local.quotesVersion + const currentRows = rows() + if (runtime.lastRenderedRowCount !== currentRows.length) { + runtime.lastRenderedRowCount = currentRows.length + queueMicrotask(() => + controller.actions.setRenderedRowCount(runtime.lastRenderedRowCount), + ) + } + return currentRows + } + const writeSizes = (tableElement: HTMLTableElement) => { + for (const header of table.getFlatHeaders()) { + tableElement.style.setProperty( + `--header-${header.id}-size`, + String(header.getSize()), + ) + tableElement.style.setProperty( + `--col-${header.column.id}-size`, + String(header.column.getSize()), + ) + } + tableElement.style.width = `${table.getTotalSize()}px` + } + const scheduleDomCommit = () => { + if (runtime.domCommitScheduled) return + + runtime.domCommitScheduled = true + Alpine.nextTick(() => { + runtime.domCommitScheduled = false + feed.completeRender() + }) + } + + return { + table, + FlexRender, + applyCellMarkup, + local, + feed, + controller, + feedSampleRateOptions, + configuratorOptions, + init(this: { $refs: Record }) { + const scroll = this.$refs.scroll as HTMLDivElement + const tableElement = this.$refs.table as HTMLTableElement + const resizeObserver = new ResizeObserver(() => { + if (runtime.manuallyResized) return + const width = table.getTotalSize() + if (scroll.clientWidth <= width + 1 || width <= 0) return + const ratio = scroll.clientWidth / width + table.setColumnSizing( + Object.fromEntries( + table + .getVisibleLeafColumns() + .map((column) => [column.id, column.getSize() * ratio]), + ), + ) + }) + resizeObserver.observe(scroll) + const mutationObserver = new MutationObserver((records) => + controller.monitor.recordDomMutations(records.length), + ) + mutationObserver.observe(tableElement.tBodies[0], { + attributes: true, + attributeFilter: ['class', 'style'], + characterData: true, + childList: true, + subtree: true, + }) + const subscriptions = [ + feed.workerReady.subscribe((value) => { + local.feed.workerReady = value + }), + feed.running.subscribe((value) => { + local.feed.running = value + }), + feed.instrumentCount.subscribe((value) => { + local.feed.instrumentCount = value + }), + feed.targetTicksPerSecond.subscribe((value) => { + local.feed.targetTicksPerSecond = value + }), + feed.publishIntervalMs.subscribe((value) => { + local.feed.publishIntervalMs = value + }), + feed.updateSparklines.subscribe((value) => { + local.feed.updateSparklines = value + }), + feed.sparklineSampleIntervalMs.subscribe((value) => { + local.feed.sparklineSampleIntervalMs = value + }), + feed.quotes.subscribe((quotes) => { + const lengthChanged = quotes.length !== local.feed.quotes.length + runtime.cachedFeed = null + local.feed.quotes = quotes + if (lengthChanged) { + local.quotesVersion++ + local.tableVersion++ + } + table.setOptions((previous) => ({ ...previous, data: quotes })) + scheduleDomCommit() + }), + controller.store.subscribe((state) => { + const current = local.benchmark + if (current.mountedCells !== state.mountedCells) { + current.mountedCells = state.mountedCells + } + if (current.liveComponents !== state.liveComponents) { + current.liveComponents = state.liveComponents + } + current.metrics = state.metrics + }), + controller.renderAtoms.selectedSymbol.subscribe((symbol) => { + local.selectedSymbol = symbol + }), + controller.renderAtoms.rendererMode.subscribe((mode) => { + local.rendererMode = mode + local.tableVersion++ + }), + table.store.subscribe(() => { + const state = table.store.state + const next = { + sorting: state.sorting, + columnFilters: state.columnFilters, + columnOrder: state.columnOrder, + rowSelection: state.rowSelection, + cellSelection: state.cellSelection, + } + if (runtime.lastTableUi && shallow(runtime.lastTableUi, next)) { + return + } + runtime.lastTableUi = next + local.tableVersion++ + }), + table.atoms.columnSizing.subscribe(() => writeSizes(tableElement)), + table.atoms.columnOrder.subscribe(() => writeSizes(tableElement)), + table.atoms.columnResizing.subscribe((state) => { + if (state.isResizingColumn !== false) runtime.manuallyResized = true + }), + ] + const stopFeed = feed.start() + const stopBenchmark = controller.start() + runtime.cleanups.push( + stopFeed, + stopBenchmark, + () => resizeObserver.disconnect(), + () => mutationObserver.disconnect(), + ...subscriptions.map( + (subscription) => () => subscription.unsubscribe(), + ), + ) + Alpine.nextTick(() => writeSizes(tableElement)) + scheduleDomCommit() + }, + destroy() { + for (const cleanup of runtime.cleanups) cleanup() + runtime.cleanups.length = 0 + }, + rows, + renderRows, + toggleSidebar() { + local.sidebarOpen = !local.sidebarOpen + }, + feedStatus() { + return !local.feed.workerReady + ? 'FEED CONNECTING' + : local.feed.running + ? 'FEED LIVE' + : 'FEED PAUSED' + }, + setInstrumentCount(event: Event) { + controller.actions.resetViewState() + feed.actions.setInstrumentCount( + Number((event.target as HTMLSelectElement).value), + ) + }, + sampleRateIndex() { + return feedSampleRateIndex(local.feed.targetTicksPerSecond) + }, + setSampleRate(event: Event) { + feed.actions.setTargetRate( + feedSampleRateAt(Number((event.target as HTMLInputElement).value)), + ) + }, + setPublishInterval(event: Event) { + feed.actions.setPublishInterval( + Number((event.target as HTMLSelectElement).value), + ) + }, + setRendererMode(event: Event) { + controller.actions.setRendererMode( + (event.target as HTMLInputElement).checked ? 'swap' : 'stable', + ) + }, + setSparklineUpdates(event: Event) { + feed.actions.setSparklineUpdates( + (event.target as HTMLInputElement).checked, + ) + }, + setSparklineInterval(event: Event) { + feed.actions.setSparklineSampleInterval( + Number((event.target as HTMLSelectElement).value), + ) + }, + metricItems() { + const metrics = local.benchmark.metrics + return [ + [ + 'FRAME RATE (EST.)', + metrics.rafCallbacksPerSecond.toFixed(1), + 'rAF callbacks/s · rolling 1 s', + 'frame-rate', + ], + [ + 'AVG COMMIT', + ms(metrics.averageCommitLatencyMs), + 'snapshot → DOM · rolling 3 s', + 'average-commit-latency', + ], + [ + 'LONG FRAMES', + local.benchmark.longAnimationFramesSupported + ? String(metrics.longAnimationFrames) + : 'N/A', + local.benchmark.longAnimationFramesSupported + ? `since reset · worst ${ms(metrics.worstLongAnimationFrameMs)}` + : 'unsupported', + 'long-frame-count', + ], + [ + 'THROUGHPUT', + `${rate.format(metrics.rowUpdatesPerSecond)} rows/s`, + `${metrics.stateApplicationsPerSecond.toFixed(1)} snapshots/s · rows deduplicated per snapshot`, + 'throughput-rate', + ], + ] + }, + diagnostics() { + const metrics = local.benchmark.metrics + const invocation = (items: typeof metrics.cellRendererRates) => { + const active = items.filter((item) => item.callsPerSecond > 0) + return active.length + ? active + .map((item) => `${item.name} ${rate.format(item.callsPerSecond)}`) + .join(' · ') + : '—' + } + return [ + [ + 'Worker-generated samples / s', + rate.format(metrics.actualTicksPerSecond), + 'actual-rate', + ], + [ + 'Changed rows / s', + rate.format(metrics.rowUpdatesPerSecond), + 'row-update-rate', + ], + [ + 'Worker messages / s', + metrics.workerMessagesPerSecond.toFixed(1), + 'message-rate', + ], + [ + 'Snapshots applied / s', + metrics.stateApplicationsPerSecond.toFixed(1), + 'state-apply-rate', + ], + [ + 'DOM commits / s', + metrics.tableCommitsPerSecond.toFixed(1), + 'table-render-rate', + ], + [ + 'Commit latency p95 / max (10 s)', + `${ms(metrics.p95CommitLatencyMs)} / ${ms(metrics.maxCommitLatencyMs)}`, + '', + ], + ['Mounted cells', integer.format(local.benchmark.mountedCells), ''], + ['Live components', integer.format(local.benchmark.liveComponents), ''], + [ + 'Created / destroyed', + `${integer.format(metrics.componentsCreated)} / ${integer.format(metrics.componentsDestroyed)}`, + '', + ], + [ + 'Renderer callbacks / s', + rate.format(metrics.cellRendererCallsPerSecond), + 'cell-render-rate', + ], + [ + 'Component executions / s', + rate.format(metrics.componentRenderCallsPerSecond), + 'component-render-rate', + ], + [ + 'Executions by component / s', + invocation(metrics.componentRenderRates), + 'component-render-breakdown', + ], + [ + 'Callbacks by column / s', + invocation(metrics.cellRendererRates), + 'cell-render-breakdown', + ], + [ + 'Observed MutationRecords / s', + rate.format(metrics.domMutationsPerSecond), + 'dom-mutation-rate', + ], + [ + 'Core row model calls / s', + metrics.rowModelCallsPerSecond.toFixed(1), + 'row-model-call-rate', + ], + [ + 'Core row model avg / max', + `${ms(metrics.rowModelAverageMs)} / ${ms(metrics.rowModelMaxMs)}`, + 'row-model-duration', + ], + [ + 'Visible rows', + integer.format(metrics.visibleRows), + 'visible-row-count', + ], + [ + 'Worker messages', + integer.format(metrics.workerMessages), + 'worker-messages', + ], + [ + 'Worker-coalesced updates / s', + rate.format(metrics.supersededUpdatesPerSecond), + 'superseded-update-rate', + ], + [ + 'Last samples / updated rows', + `${integer.format(metrics.lastBatchSize)} / ${integer.format(metrics.lastUpdateCount)}`, + '', + ], + [ + 'Commits > 16.7 ms (since reset)', + integer.format(metrics.slowCommits), + '', + ], + [ + 'JS heap (current, GC-sensitive)', + metrics.heapMb === null ? 'N/A' : `${metrics.heapMb.toFixed(1)} MB`, + '', + ], + ] + }, + selectedQuote() { + return feed.getQuoteBySymbol(local.feed.quotes, local.selectedSymbol) + }, + formatInteger: (number: number) => integer.format(number), + formatRate: (number: number) => rate.format(number), + sortIndicator, + sortAriaValue, + isTextColumn(id: string) { + return ['market', 'name', 'symbol'].includes(id) + }, + onGridKeyDown(event: KeyboardEvent) { + handleCellNavigation(table, event) + }, + onBodyMouseDown(event: MouseEvent) { + pointer.handleMouseDown(table, event, controller.actions.selectSymbol) + }, + onBodyPointerOver(event: MouseEvent) { + pointer.handlePointerOver(table, event) + }, + onBodyClick(event: MouseEvent) { + pointer.handleClick(table, event) + }, + resetPointer() { + pointer.resetPointerCell() + }, + clearDrag() { + runtime.dragSource?.classList.remove('is-column-dragging') + runtime.dragTarget?.classList.remove('is-column-drop-target') + runtime.dragColumnId = null + runtime.dragSource = null + runtime.dragTarget = null + }, + dragStart( + header: ReturnType[number], + event: DragEvent, + ) { + runtime.dragColumnId = header.column.id + runtime.dragSource = (event.currentTarget as HTMLElement).closest('th') + runtime.dragSource?.classList.add('is-column-dragging') + if (event.dataTransfer) { + event.dataTransfer.effectAllowed = 'move' + event.dataTransfer.setData('text/plain', header.column.id) + } + }, + dragOver( + header: ReturnType[number], + event: DragEvent, + ) { + event.preventDefault() + runtime.dragTarget?.classList.remove('is-column-drop-target') + runtime.dragTarget = null + const element = (event.currentTarget as HTMLElement).closest('th') + if (runtime.dragColumnId !== header.column.id && element) { + element.classList.add('is-column-drop-target') + runtime.dragTarget = element + } + }, + drop( + header: ReturnType[number], + event: DragEvent, + ) { + event.preventDefault() + const source = + event.dataTransfer?.getData('text/plain') || runtime.dragColumnId + if (source) + table.setColumnOrder( + reorderColumnIds( + table.getVisibleLeafColumns().map((column) => column.id), + source, + header.column.id, + ), + ) + this.clearDrag() + }, + } +}) + +window.Alpine = Alpine +Alpine.start() diff --git a/examples/alpine/realtime-trading/src/shell/configurator-options.ts b/examples/alpine/realtime-trading/src/shell/configurator-options.ts new file mode 100644 index 0000000000..5e21d71492 --- /dev/null +++ b/examples/alpine/realtime-trading/src/shell/configurator-options.ts @@ -0,0 +1,49 @@ +export interface ConfiguratorOption { + readonly label: string + readonly value: TValue +} + +const instrumentCountOptions = [ + { label: '50', value: 50 }, + { label: '100', value: 100 }, + { label: '150', value: 150 }, + { label: '250', value: 250 }, + { label: '350', value: 350 }, + { label: '500', value: 500 }, + { label: '750', value: 750 }, + { label: '1,000', value: 1_000 }, + { label: '1,500', value: 1_500 }, + { label: '2,500', value: 2_500 }, + { label: '5,000', value: 5_000 }, + { label: '1,000,000', value: 1_000_000 }, + { label: '10,000,000', value: 10_000_000 }, +] as const satisfies ReadonlyArray> + +const workerDeliveryOptions = [ + { label: '8 ms · 125 msg/s', value: 8 }, + { label: '16 ms · 62.5 msg/s', value: 16 }, + { label: '20 ms · 50 msg/s', value: 20 }, + { label: '33 ms · 30 msg/s', value: 33 }, + { label: '50 ms · 20 msg/s', value: 50 }, + { label: '100 ms · 10 msg/s', value: 100 }, + { label: '250 ms · 4 msg/s', value: 250 }, + { label: '500 ms · 2 msg/s', value: 500 }, + { label: '1,000 ms · 1 msg/s', value: 1_000 }, +] as const satisfies ReadonlyArray> + +const intradaySamplingOptions = [ + { label: '16 ms · fastest', value: 16 }, + { label: '33 ms · very fast', value: 33 }, + { label: '50 ms · fast', value: 50 }, + { label: '100 ms', value: 100 }, + { label: '250 ms', value: 250 }, + { label: '500 ms', value: 500 }, + { label: '1,000 ms', value: 1_000 }, + { label: '2,000 ms', value: 2_000 }, +] as const satisfies ReadonlyArray> + +export const configuratorOptions = { + instrumentCounts: instrumentCountOptions, + workerDeliveryIntervals: workerDeliveryOptions, + intradaySamplingIntervals: intradaySamplingOptions, +} as const diff --git a/examples/alpine/realtime-trading/src/table/table-config/quote-cells.ts b/examples/alpine/realtime-trading/src/table/table-config/quote-cells.ts new file mode 100644 index 0000000000..b5f115e28f --- /dev/null +++ b/examples/alpine/realtime-trading/src/table/table-config/quote-cells.ts @@ -0,0 +1,145 @@ +export const quoteCellLifecycle = { created: 0, destroyed: 0 } +export const quoteCellRendererNames = [ + 'Market', + 'Name', + 'Symbol', + 'Last', + 'Change', + 'ChangePercent', + 'Bid', + 'BidVolume', + 'Ask', + 'AskVolume', + 'Open', + 'High', + 'Low', + 'Intraday', +] as const +export const quoteComponentNames = [ + 'PriceCell', + 'StableMoveCell', + 'UpMoveCell', + 'DownMoveCell', + 'PercentChangeCell', + 'SparklineCell', +] as const +export type QuoteCellRendererName = (typeof quoteCellRendererNames)[number] +export type QuoteComponentName = (typeof quoteComponentNames)[number] +const counters = (names: ReadonlyArray) => + Object.fromEntries(names.map((name) => [name, 0])) as Record +export const quoteRenderDiagnostics = { + cellRendererCalls: 0, + componentRenderCalls: 0, + cellRendererCallsByName: counters(quoteCellRendererNames), + componentRenderCallsByName: counters(quoteComponentNames), +} +export function recordCellRender(name: QuoteCellRendererName, value: T): T { + quoteRenderDiagnostics.cellRendererCalls++ + quoteRenderDiagnostics.cellRendererCallsByName[name]++ + return value +} +const signed = (value: number) => `${value >= 0 ? '+' : ''}${value.toFixed(2)}` + +abstract class QuoteElement extends HTMLElement { + protected abstract readonly componentName: QuoteComponentName + connectedCallback() { + quoteCellLifecycle.created++ + this.renderCell() + } + disconnectedCallback() { + quoteCellLifecycle.destroyed++ + } + attributeChangedCallback() { + if (this.isConnected) this.renderCell() + } + protected renderCell() { + quoteRenderDiagnostics.componentRenderCalls++ + quoteRenderDiagnostics.componentRenderCallsByName[this.componentName]++ + } + protected number(name: string) { + return Number(this.getAttribute(name) ?? 0) + } +} + +class PriceCell extends QuoteElement { + protected readonly componentName = 'PriceCell' + static observedAttributes = ['price', 'move'] + protected renderCell() { + super.renderCell() + const price = this.number('price') + const move = this.number('move') + this.innerHTML = `` + } +} +abstract class MoveCell extends QuoteElement { + static observedAttributes = ['move'] + protected direction: 'up' | 'down' | null = null + protected indicator = '' + protected renderCell() { + super.renderCell() + const move = this.number('move') + const direction = this.direction ?? (move >= 0 ? 'up' : 'down') + this.innerHTML = `${this.indicator}${signed(move)}` + } +} +class StableMoveCell extends MoveCell { + protected readonly componentName = 'StableMoveCell' +} +class UpMoveCell extends MoveCell { + protected readonly componentName = 'UpMoveCell' + protected direction = 'up' as const + protected indicator = '▲ ' +} +class DownMoveCell extends MoveCell { + protected readonly componentName = 'DownMoveCell' + protected direction = 'down' as const + protected indicator = '▼ ' +} +class PercentChangeCell extends QuoteElement { + protected readonly componentName = 'PercentChangeCell' + static observedAttributes = ['value'] + protected renderCell() { + super.renderCell() + const value = this.number('value') + this.innerHTML = `${signed(value)}%` + } +} +class SparklineCell extends QuoteElement { + protected readonly componentName = 'SparklineCell' + static observedAttributes = ['points', 'rising'] + protected renderCell() { + super.renderCell() + this.innerHTML = `` + } +} + +const definitions = [ + ['quote-price-cell', PriceCell], + ['quote-stable-move', StableMoveCell], + ['quote-up-move', UpMoveCell], + ['quote-down-move', DownMoveCell], + ['quote-percent-change', PercentChangeCell], + ['quote-sparkline', SparklineCell], +] as const +for (const [name, definition] of definitions) + if (!customElements.get(name)) customElements.define(name, definition) + +export function sparklineMarkup(values: ReadonlyArray): string { + const first = values[0] ?? 0 + const range = values.reduce( + (current, value) => ({ + min: Math.min(current.min, value), + max: Math.max(current.max, value), + }), + { min: first, max: first }, + ) + const height = range.max - range.min || 1 + const denominator = Math.max(1, values.length - 1) + const points = values + .map( + (value, index) => + `${((index / denominator) * 100).toFixed(1)},${(22 - ((value - range.min) / height) * 20).toFixed(1)}`, + ) + .join(' ') + return `` +} diff --git a/examples/alpine/realtime-trading/src/table/table-config/trading-columns.ts b/examples/alpine/realtime-trading/src/table/table-config/trading-columns.ts new file mode 100644 index 0000000000..14926a2fdc --- /dev/null +++ b/examples/alpine/realtime-trading/src/table/table-config/trading-columns.ts @@ -0,0 +1,199 @@ +import { createColumnHelper } from '@tanstack/alpine-table' +import { tradingFeatures } from '../trading-features' +import { recordCellRender, sparklineMarkup } from './quote-cells' +import type { MarketQuote } from '../../feed/market-data' + +export type RendererMode = 'stable' | 'swap' +export interface CoreTableState { + sorting: Array<{ id: string; desc: boolean }> + columnFilters: Array<{ id: string; value: unknown }> +} +const compact = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const columnHelper = createColumnHelper() +const safe = (value: string) => + value + .replaceAll('&', '&') + .replaceAll('<', '<') + .replaceAll('>', '>') + .replaceAll('"', '"') + +export function createTradingColumns(getRendererMode: () => RendererMode) { + return columnHelper.columns([ + columnHelper.group({ + id: 'instrument', + header: 'Instrument', + columns: columnHelper.columns([ + columnHelper.accessor('venue', { + id: 'market', + header: 'Market', + size: 72, + cell: (info) => recordCellRender('Market', safe(info.getValue())), + }), + columnHelper.accessor('company', { + id: 'name', + header: 'Name', + size: 180, + cell: (info) => recordCellRender('Name', safe(info.getValue())), + }), + columnHelper.accessor('symbol', { + header: 'Symbol', + size: 92, + filterFn: 'includesString', + cell: (info) => recordCellRender('Symbol', safe(info.getValue())), + }), + ]), + }), + columnHelper.group({ + id: 'priceAndChange', + header: 'Price & Change', + columns: columnHelper.columns([ + columnHelper.accessor('price', { + header: 'Price', + size: 96, + sortFn: 'basic', + cell: (info) => + recordCellRender( + 'Last', + ``, + ), + }), + columnHelper.accessor(getDayChange, { + id: 'change', + header: 'Chg', + size: 94, + cell: (info) => + recordCellRender( + 'Change', + moveMarkup(getRendererMode(), info.getValue()), + ), + }), + columnHelper.accessor(getDayChangePercent, { + id: 'changePercent', + header: 'Chg%', + size: 90, + cell: (info) => + recordCellRender( + 'ChangePercent', + ``, + ), + }), + ]), + }), + columnHelper.group({ + id: 'orderBook', + header: 'Order Book', + columns: columnHelper.columns([ + columnHelper.accessor('bid', { + header: 'Bid', + size: 90, + cell: (info) => recordCellRender('Bid', info.getValue().toFixed(2)), + }), + columnHelper.accessor('bidSize', { + header: 'Bid Vol', + size: 100, + cell: (info) => + recordCellRender('BidVolume', compact.format(info.getValue())), + }), + columnHelper.accessor('ask', { + header: 'Ask', + size: 90, + cell: (info) => recordCellRender('Ask', info.getValue().toFixed(2)), + }), + columnHelper.accessor('askSize', { + header: 'Ask Vol', + size: 100, + cell: (info) => + recordCellRender('AskVolume', compact.format(info.getValue())), + }), + ]), + }), + columnHelper.group({ + id: 'session', + header: 'Session', + columns: columnHelper.columns([ + columnHelper.accessor('open', { + header: 'Open', + size: 90, + cell: (info) => recordCellRender('Open', info.getValue().toFixed(2)), + }), + columnHelper.accessor('high', { + header: 'High', + size: 90, + cell: (info) => recordCellRender('High', info.getValue().toFixed(2)), + }), + columnHelper.accessor('low', { + header: 'Low', + size: 90, + cell: (info) => recordCellRender('Low', info.getValue().toFixed(2)), + }), + ]), + }), + columnHelper.group({ + id: 'chart', + header: 'Chart', + columns: columnHelper.columns([ + columnHelper.accessor('history', { + header: 'Intraday', + size: 150, + enableSorting: false, + cell: (info) => + recordCellRender('Intraday', sparklineMarkup(info.getValue())), + }), + ]), + }), + ]) +} +function moveMarkup(mode: RendererMode, move: number) { + if (mode === 'stable') + return `` + return move >= 0 + ? `` + : `` +} +export const rowModelDiagnostics = { + hasMeasurement: false, + calls: 0, + totalDurationMs: 0, + maxDurationMs: 0, + lastRowCount: 0, +} +export const TRADING_COLUMN_COUNT = 14 +export function readMeasuredRows(readRows: () => Array): Array { + const start = performance.now() + const rows = readRows() + const end = performance.now() + const duration = end - start + rowModelDiagnostics.calls++ + rowModelDiagnostics.hasMeasurement = true + rowModelDiagnostics.totalDurationMs += duration + rowModelDiagnostics.maxDurationMs = Math.max( + rowModelDiagnostics.maxDurationMs, + duration, + ) + rowModelDiagnostics.lastRowCount = rows.length + if ((rowModelDiagnostics.calls - 1) % 20 === 0) { + try { + performance.measure('tanstack-row-model', { + start, + end, + detail: { rowCount: rows.length }, + }) + if (rowModelDiagnostics.calls % 1_000 === 0) + performance.clearMeasures('tanstack-row-model') + } catch { + /* optional sampled User Timing detail */ + } + } + return rows +} +export function getDayChange(quote: MarketQuote): number { + return quote.price - quote.previousClose +} +export function getDayChangePercent(quote: MarketQuote): number { + return quote.previousClose === 0 + ? 0 + : (getDayChange(quote) / quote.previousClose) * 100 +} diff --git a/examples/alpine/realtime-trading/src/table/table-interactions.ts b/examples/alpine/realtime-trading/src/table/table-interactions.ts new file mode 100644 index 0000000000..99649a40bd --- /dev/null +++ b/examples/alpine/realtime-trading/src/table/table-interactions.ts @@ -0,0 +1,187 @@ +export type CellDirection = 'up' | 'down' | 'left' | 'right' + +interface RowSelectionTable { + resetRowSelection: (defaultState?: boolean) => void +} + +interface SelectableRow { + getIsSelected: () => boolean + getToggleSelectedHandler: (options?: { + selectChildren?: boolean + }) => (event: unknown) => void +} + +interface SelectableGridCell { + row: SelectableGridRow + getSelectionStartHandler: ( + contextDocument?: Document, + ) => (event: unknown) => void + getSelectionExtendHandler: () => (event: unknown) => void +} + +interface SelectableGridRow extends SelectableRow { + original: { symbol: string } + getAllCellsByColumnId: () => Record +} + +interface TradingGridTable extends RowSelectionTable { + getRowModel: () => { + rowsById: Record + } +} + +interface SelectionCellTarget { + element: HTMLTableCellElement + cell: SelectableGridCell +} + +interface CellNavigationTable { + extendCellSelection: (direction: CellDirection) => void + moveCellSelection: (direction: CellDirection) => void + resetCellSelection: (defaultState?: boolean) => void + selectAllCells: () => void +} + +const keyDirections: Partial> = { + ArrowUp: 'up', + ArrowDown: 'down', + ArrowLeft: 'left', + ArrowRight: 'right', +} + +export function reorderColumnIds( + columnIds: Array, + sourceId: string, + targetId: string, +): Array { + if (sourceId === targetId || !columnIds.includes(sourceId)) return columnIds + + const withoutSource = columnIds.filter((id) => id !== sourceId) + const targetIndex = withoutSource.indexOf(targetId) + if (targetIndex < 0) return columnIds + + return [ + ...withoutSource.slice(0, targetIndex), + sourceId, + ...withoutSource.slice(targetIndex), + ] +} + +export function selectRowFromPointer( + table: RowSelectionTable, + row: SelectableRow, + event: MouseEvent, +): void { + const additive = event.ctrlKey || event.metaKey + const checked = additive ? !row.getIsSelected() : true + + if (!event.shiftKey && !additive) table.resetRowSelection(true) + + row.getToggleSelectedHandler({ selectChildren: false })({ + target: { checked }, + shiftKey: event.shiftKey, + ctrlKey: event.ctrlKey, + metaKey: event.metaKey, + }) +} + +export class TradingGridPointerController { + #lastPointerCell: HTMLTableCellElement | null = null + + handleMouseDown( + table: TradingGridTable, + event: MouseEvent, + selectSymbol: (symbol: string) => void, + ): void { + if (event.button !== 0) return + + const target = this.#findCellTarget(table, event.composedPath()) + if (!target) return + + event.preventDefault() + this.#lastPointerCell = target.element + selectSymbol(target.cell.row.original.symbol) + target.cell.getSelectionStartHandler(target.element.ownerDocument)(event) + } + + handlePointerOver(table: TradingGridTable, event: MouseEvent): void { + if ((event.buttons & 1) === 0) { + this.resetPointerCell() + return + } + + const target = this.#findCellTarget(table, event.composedPath()) + if (!target || target.element === this.#lastPointerCell) return + + this.#lastPointerCell = target.element + target.cell.getSelectionExtendHandler()(event) + } + + handleClick(table: TradingGridTable, event: MouseEvent): void { + const target = this.#findCellTarget(table, event.composedPath()) + if (!target) return + selectRowFromPointer(table, target.cell.row, event) + } + + resetPointerCell(): void { + this.#lastPointerCell = null + } + + #findCellTarget( + table: TradingGridTable, + path: Array, + ): SelectionCellTarget | null { + for (const target of path) { + if (!(target instanceof HTMLTableCellElement)) continue + + const columnId = target.dataset['columnId'] + const rowId = + target.closest('tr[data-row-id]')?.dataset['rowId'] + if (!columnId || !rowId) return null + + const row = table.getRowModel().rowsById[rowId] + const cell = row.getAllCellsByColumnId()[columnId] + return { element: target, cell } + } + + return null + } +} + +export function handleCellNavigation( + table: CellNavigationTable, + event: KeyboardEvent, +): void { + if (event.key === 'Escape') { + event.preventDefault() + table.resetCellSelection(true) + return + } + + if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a') { + event.preventDefault() + table.selectAllCells() + return + } + + const direction = keyDirections[event.key] + if (!direction) return + + event.preventDefault() + if (event.shiftKey) table.extendCellSelection(direction) + else table.moveCellSelection(direction) +} + +export function sortIndicator(direction: false | 'asc' | 'desc'): string { + if (direction === 'asc') return '↑' + if (direction === 'desc') return '↓' + return '↕' +} + +export function sortAriaValue( + direction: false | 'asc' | 'desc', +): 'ascending' | 'descending' | 'none' { + if (direction === 'asc') return 'ascending' + if (direction === 'desc') return 'descending' + return 'none' +} diff --git a/examples/alpine/realtime-trading/src/table/trading-features.ts b/examples/alpine/realtime-trading/src/table/trading-features.ts new file mode 100644 index 0000000000..1a75ebdb36 --- /dev/null +++ b/examples/alpine/realtime-trading/src/table/trading-features.ts @@ -0,0 +1,16 @@ +import { + createFilteredRowModel, + createSortedRowModel, + filterFn_includesString, + sortFn_basic, + stockFeatures, + tableFeatures, +} from '@tanstack/alpine-table' + +export const tradingFeatures = tableFeatures({ + ...stockFeatures, + filteredRowModel: createFilteredRowModel(), + sortedRowModel: createSortedRowModel(), + filterFns: { includesString: filterFn_includesString }, + sortFns: { basic: sortFn_basic }, +}) diff --git a/examples/alpine/realtime-trading/src/table/trading-table.ts b/examples/alpine/realtime-trading/src/table/trading-table.ts new file mode 100644 index 0000000000..39fde46d14 --- /dev/null +++ b/examples/alpine/realtime-trading/src/table/trading-table.ts @@ -0,0 +1,8 @@ +export { + TRADING_COLUMN_COUNT, + rowModelDiagnostics, +} from './table-config/trading-columns' +export type { + CoreTableState, + RendererMode, +} from './table-config/trading-columns' diff --git a/examples/alpine/realtime-trading/src/vite-env.d.ts b/examples/alpine/realtime-trading/src/vite-env.d.ts new file mode 100644 index 0000000000..99f6333028 --- /dev/null +++ b/examples/alpine/realtime-trading/src/vite-env.d.ts @@ -0,0 +1,9 @@ +/// + +import type Alpine from 'alpinejs' + +declare global { + interface Window { + Alpine: typeof Alpine + } +} diff --git a/examples/alpine/realtime-trading/tests/e2e/smoke.spec.ts b/examples/alpine/realtime-trading/tests/e2e/smoke.spec.ts new file mode 100644 index 0000000000..c24e70f006 --- /dev/null +++ b/examples/alpine/realtime-trading/tests/e2e/smoke.spec.ts @@ -0,0 +1,126 @@ +import path from 'node:path' +import { expect, test } from '@playwright/test' +import { startExampleServer } from '../../../../../tests/e2e/helpers/startExampleServer' +import { + setRangeValue, + resumeTradingFeed, + pausedFeedUrl, +} from '../../../../../tests/e2e/helpers/setRangeValue' +import type { Page } from '@playwright/test' + +const exampleDir = path.resolve() + +function collectPageErrors(page: Page) { + const errors: Array = [] + page.on('pageerror', (error) => errors.push(error.message)) + page.on('console', (message) => { + if (message.type() === 'error') errors.push(message.text()) + }) + return errors +} + +test('runs the Alpine realtime trading workload', async ({ page }) => { + test.setTimeout(120_000) + const server = await startExampleServer(exampleDir) + const errors = collectPageErrors(page) + + try { + await page.goto(pausedFeedUrl(server.url)) + + const table = page.getByTestId('trading-table') + const instrumentCount = page.getByTestId('instrument-count-select') + await expect(table).toBeVisible() + await expect(instrumentCount).toHaveValue('100') + await expect(page.locator('.brand')).toHaveText('MARKET MONITOR') + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(table.locator('tbody')).toHaveCSS('user-select', 'none') + await expect(table.locator('tbody tr').first()).toHaveCSS( + 'content-visibility', + 'auto', + ) + await expect(table.locator('thead tr')).toHaveCount(2) + await expect(table.locator('thead tr').last().locator('th')).toHaveCount(14) + await expect(table.locator('thead')).not.toContainText('Identity') + await expect(table.locator('thead')).not.toContainText('Market Data') + await expect(table.locator('thead')).toContainText('Market') + await expect(table.locator('thead')).toContainText('Bid Vol') + await expect(table.locator('thead')).toContainText('Intraday') + const selectedRow = table.locator('tbody tr').first() + const selectedSymbol = await selectedRow.getAttribute('data-symbol') + await selectedRow.locator('td').nth(1).click() + await expect(page.getByTestId('selected-instrument')).toContainText( + selectedSymbol ?? '', + ) + await expect(page.getByTestId('feed-status')).toHaveText('FEED PAUSED') + await expect(instrumentCount.locator('option[value="150"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="350"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="750"]')).toHaveCount(1) + + const targetRateSlider = page.getByTestId('target-rate-slider') + await expect(targetRateSlider).toHaveAttribute('min', '0') + await expect(targetRateSlider).toHaveAttribute('max', '9') + await expect(targetRateSlider).toHaveAttribute('step', '1') + await expect(targetRateSlider).toHaveValue('6') + await setRangeValue(targetRateSlider, '7') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '25K samples/s', + ) + await setRangeValue(targetRateSlider, '8') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '50K samples/s', + ) + await setRangeValue(targetRateSlider, '6') + + const sparklineInterval = page.getByTestId( + 'sparkline-sample-interval-select', + ) + await expect(sparklineInterval).toHaveValue('16') + await sparklineInterval.selectOption('100') + await expect(sparklineInterval).toHaveValue('100') + await sparklineInterval.selectOption('16') + + const publishInterval = page.getByTestId('publish-interval-select') + await expect(publishInterval.locator('option[value="500"]')).toHaveCount(1) + await expect(publishInterval.locator('option[value="1000"]')).toHaveCount(1) + + // Exercise delivery and rendering without turning this smoke test into a + // throughput benchmark on shared CI runners. Configure controls while paused. + await setRangeValue(targetRateSlider, '0') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '100 samples/s', + ) + await publishInterval.selectOption('500') + await expect(publishInterval).toHaveValue('500') + await sparklineInterval.selectOption('100') + const swapRenderer = page.getByRole('checkbox', { + name: /Swap Tick component/, + }) + await swapRenderer.check() + await expect(swapRenderer).toBeChecked() + + const firstPrice = table.locator('tbody tr').first().getByRole('button') + const priceBeforeUpdate = await firstPrice.textContent() + await resumeTradingFeed(page) + await expect + .poll(() => firstPrice.textContent()) + .not.toBe(priceBeforeUpdate) + + await page.getByTestId('feed-toggle').click() + await expect(page.getByTestId('feed-toggle')).toHaveText('START FEED') + await expect(page.getByTestId('feed-status')).toHaveText('FEED PAUSED') + + // Delivery is cumulative; instantaneous rates can legitimately fall to + // zero between samples on a busy runner. The price assertion above proves + // that a delivered update reached the rendered table. + await expect + .poll(async () => { + const text = await page.getByTestId('worker-messages').textContent() + return Number(text?.replace(/\D/g, '') ?? 0) + }) + .toBeGreaterThan(0) + + expect(errors).toEqual([]) + } finally { + await server.close() + } +}) diff --git a/examples/alpine/realtime-trading/tsconfig.json b/examples/alpine/realtime-trading/tsconfig.json new file mode 100644 index 0000000000..4986527dc3 --- /dev/null +++ b/examples/alpine/realtime-trading/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "types": ["vite/client"] + }, + "include": ["src", "tests/e2e", "vite.config.ts"] +} diff --git a/examples/alpine/realtime-trading/vite.config.ts b/examples/alpine/realtime-trading/vite.config.ts new file mode 100644 index 0000000000..7af6c0bce8 --- /dev/null +++ b/examples/alpine/realtime-trading/vite.config.ts @@ -0,0 +1,2 @@ +import { defineConfig } from 'vite' +export default defineConfig({ server: { port: 7777, allowedHosts: true } }) diff --git a/examples/alpine/row-pinning/package.json b/examples/alpine/row-pinning/package.json index 4dc77b887e..3630d7d906 100644 --- a/examples/alpine/row-pinning/package.json +++ b/examples/alpine/row-pinning/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.1.2", - "alpinejs": "^3.16.1" + "@faker-js/faker": "^10.6.0", + "@tanstack/alpine-table": "^9.3.1", + "alpinejs": "^3.17.5" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@types/alpinejs": "^3.13.11", + "@types/alpinejs": "^3.17.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/alpine/row-selection/package.json b/examples/alpine/row-selection/package.json index b829d379cd..c3ff04256b 100644 --- a/examples/alpine/row-selection/package.json +++ b/examples/alpine/row-selection/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.1.2", - "alpinejs": "^3.16.1" + "@faker-js/faker": "^10.6.0", + "@tanstack/alpine-table": "^9.3.1", + "alpinejs": "^3.17.5" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@types/alpinejs": "^3.13.11", + "@types/alpinejs": "^3.17.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/alpine/sorting-dynamic-data/package.json b/examples/alpine/sorting-dynamic-data/package.json index 3339d71109..e229342490 100644 --- a/examples/alpine/sorting-dynamic-data/package.json +++ b/examples/alpine/sorting-dynamic-data/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.1.2", - "alpinejs": "^3.16.1" + "@faker-js/faker": "^10.6.0", + "@tanstack/alpine-table": "^9.3.1", + "alpinejs": "^3.17.5" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@types/alpinejs": "^3.13.11", + "@types/alpinejs": "^3.17.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/alpine/sorting/package.json b/examples/alpine/sorting/package.json index 4bd5116d2d..abf1d37ba6 100644 --- a/examples/alpine/sorting/package.json +++ b/examples/alpine/sorting/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.1.2", - "alpinejs": "^3.16.1" + "@faker-js/faker": "^10.6.0", + "@tanstack/alpine-table": "^9.3.1", + "alpinejs": "^3.17.5" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@types/alpinejs": "^3.13.11", + "@types/alpinejs": "^3.17.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/alpine/sub-components/package.json b/examples/alpine/sub-components/package.json index 06aa7420cf..360c2bfce2 100644 --- a/examples/alpine/sub-components/package.json +++ b/examples/alpine/sub-components/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/alpine-table": "^9.1.2", - "alpinejs": "^3.16.1" + "@faker-js/faker": "^10.6.0", + "@tanstack/alpine-table": "^9.3.1", + "alpinejs": "^3.17.5" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@types/alpinejs": "^3.13.11", + "@types/alpinejs": "^3.17.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/angular/aggregation/package.json b/examples/angular/aggregation/package.json index 2f98c5049e..6ae7bde173 100644 --- a/examples/angular/aggregation/package.json +++ b/examples/angular/aggregation/package.json @@ -11,23 +11,23 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/basic-app-table/package.json b/examples/angular/basic-app-table/package.json index 3e82a74da0..ddbd734d9f 100644 --- a/examples/angular/basic-app-table/package.json +++ b/examples/angular/basic-app-table/package.json @@ -11,24 +11,24 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-devtools": "^0.0.9", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-table-devtools": "^9.2.0", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-devtools": "^0.0.13", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-table-devtools": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/basic-dynamic-columns/package.json b/examples/angular/basic-dynamic-columns/package.json index 08ab0b0f20..012d177167 100644 --- a/examples/angular/basic-dynamic-columns/package.json +++ b/examples/angular/basic-dynamic-columns/package.json @@ -11,24 +11,24 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-pacer": "^0.24.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-pacer": "^0.27.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/basic-dynamic-columns/src/app/debounced-input/debounced-input.ts b/examples/angular/basic-dynamic-columns/src/app/debounced-input/debounced-input.ts index cc83285953..7f6302270c 100644 --- a/examples/angular/basic-dynamic-columns/src/app/debounced-input/debounced-input.ts +++ b/examples/angular/basic-dynamic-columns/src/app/debounced-input/debounced-input.ts @@ -1,5 +1,5 @@ import { Directive, HostListener, input, output } from '@angular/core' -import { injectDebouncedCallback } from '@tanstack/angular-pacer' +import { injectDebouncer } from '@tanstack/angular-pacer' @Directive({ standalone: true, @@ -9,13 +9,13 @@ export class DebouncedInput { readonly debounce = input(500) readonly changeEvent = output() - readonly #emitChange = injectDebouncedCallback( + readonly #emitChange = injectDebouncer( (event: Event) => this.changeEvent.emit(event), - { wait: () => this.debounce() }, + () => ({ wait: this.debounce() }), ) @HostListener('change', ['$event']) onChange(event: Event) { - this.#emitChange(event) + this.#emitChange.maybeExecute(event) } } diff --git a/examples/angular/basic-external-atoms/package.json b/examples/angular/basic-external-atoms/package.json index dfdee1147a..154dda968a 100644 --- a/examples/angular/basic-external-atoms/package.json +++ b/examples/angular/basic-external-atoms/package.json @@ -11,25 +11,25 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-devtools": "^0.0.9", - "@tanstack/angular-store": "^0.11.1", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-table-devtools": "^9.2.0", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-devtools": "^0.0.13", + "@tanstack/angular-store": "^0.11.2", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-table-devtools": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/basic-external-state/package.json b/examples/angular/basic-external-state/package.json index 677fc0866a..4e8f4cf6df 100644 --- a/examples/angular/basic-external-state/package.json +++ b/examples/angular/basic-external-state/package.json @@ -11,25 +11,25 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-devtools": "^0.0.9", - "@tanstack/angular-store": "^0.11.1", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-table-devtools": "^9.2.0", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-devtools": "^0.0.13", + "@tanstack/angular-store": "^0.11.2", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-table-devtools": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/basic-inject-table/package.json b/examples/angular/basic-inject-table/package.json index 69202bcb1e..97e573ce65 100644 --- a/examples/angular/basic-inject-table/package.json +++ b/examples/angular/basic-inject-table/package.json @@ -11,25 +11,25 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-devtools": "^0.0.9", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-table-devtools": "^9.2.0", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-devtools": "^0.0.13", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-table-devtools": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/cell-selection/package.json b/examples/angular/cell-selection/package.json index ec31b876c4..7d3e47cd5e 100644 --- a/examples/angular/cell-selection/package.json +++ b/examples/angular/cell-selection/package.json @@ -11,27 +11,27 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/cdk": "^22.1.0", - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-devtools": "^0.0.9", - "@tanstack/angular-hotkeys": "^0.10.0", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-table-devtools": "^9.2.0", + "@angular/cdk": "^22.2.7", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-devtools": "^0.0.13", + "@tanstack/angular-hotkeys": "^0.24.0", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-table-devtools": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/cell-spanning/package.json b/examples/angular/cell-spanning/package.json index de3311dad2..eb47ead7f5 100644 --- a/examples/angular/cell-spanning/package.json +++ b/examples/angular/cell-spanning/package.json @@ -11,23 +11,23 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/cell-spanning/src/app/app.html b/examples/angular/cell-spanning/src/app/app.html index c11327e750..bd5c2635bf 100644 --- a/examples/angular/cell-spanning/src/app/app.html +++ b/examples/angular/cell-spanning/src/app/app.html @@ -76,8 +76,7 @@

Row Spanning

> {{ headerCell - }}{{ sortIndicator(header.column.getIsSorted()) }} + }}{{ sortIndicator(header.column.getIsSorted()) }} } @@ -134,8 +133,7 @@

Reference (no spanning)

> {{ headerCell - }}{{ sortIndicator(header.column.getIsSorted()) }} + }}{{ sortIndicator(header.column.getIsSorted()) }} } diff --git a/examples/angular/column-ordering/package.json b/examples/angular/column-ordering/package.json index db0da6c6b4..4e9305e31c 100644 --- a/examples/angular/column-ordering/package.json +++ b/examples/angular/column-ordering/package.json @@ -11,23 +11,23 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/column-pinning-split/package.json b/examples/angular/column-pinning-split/package.json index 7a506f5e37..3894d56f88 100644 --- a/examples/angular/column-pinning-split/package.json +++ b/examples/angular/column-pinning-split/package.json @@ -11,23 +11,23 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/column-pinning-sticky/package.json b/examples/angular/column-pinning-sticky/package.json index d470c99f18..6dcf2a48af 100644 --- a/examples/angular/column-pinning-sticky/package.json +++ b/examples/angular/column-pinning-sticky/package.json @@ -11,23 +11,23 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/column-pinning/package.json b/examples/angular/column-pinning/package.json index ee19280ce4..151c099c1a 100644 --- a/examples/angular/column-pinning/package.json +++ b/examples/angular/column-pinning/package.json @@ -11,23 +11,23 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/column-resizing-performant/package.json b/examples/angular/column-resizing-performant/package.json index 49f737f784..63d0577323 100644 --- a/examples/angular/column-resizing-performant/package.json +++ b/examples/angular/column-resizing-performant/package.json @@ -11,23 +11,23 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/column-resizing/package.json b/examples/angular/column-resizing/package.json index 8afe088c1e..4f1fb0d3b1 100644 --- a/examples/angular/column-resizing/package.json +++ b/examples/angular/column-resizing/package.json @@ -11,23 +11,23 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/column-sizing/package.json b/examples/angular/column-sizing/package.json index 20daddd04a..a58c99a595 100644 --- a/examples/angular/column-sizing/package.json +++ b/examples/angular/column-sizing/package.json @@ -11,23 +11,23 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/column-visibility/package.json b/examples/angular/column-visibility/package.json index 4af2d4db4d..2088abfbeb 100644 --- a/examples/angular/column-visibility/package.json +++ b/examples/angular/column-visibility/package.json @@ -11,23 +11,23 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/composable-tables/package.json b/examples/angular/composable-tables/package.json index 74a6f0bbdf..9645a4deda 100644 --- a/examples/angular/composable-tables/package.json +++ b/examples/angular/composable-tables/package.json @@ -11,25 +11,25 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-devtools": "^0.0.9", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-table-devtools": "^9.2.0", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-devtools": "^0.0.13", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-table-devtools": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/custom-plugin/.vscode/launch.json b/examples/angular/custom-plugin/.vscode/launch.json index f30a599183..1b3018404a 100644 --- a/examples/angular/custom-plugin/.vscode/launch.json +++ b/examples/angular/custom-plugin/.vscode/launch.json @@ -7,7 +7,7 @@ "type": "chrome", "request": "launch", "preLaunchTask": "npm: start", - "url": "http://localhost:4200/" + "url": "http://localhost:7777/" } ] } diff --git a/examples/angular/custom-plugin/package.json b/examples/angular/custom-plugin/package.json index fcbfd13e8a..0ecfb3cd1a 100644 --- a/examples/angular/custom-plugin/package.json +++ b/examples/angular/custom-plugin/package.json @@ -11,22 +11,22 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/editable/package.json b/examples/angular/editable/package.json index cf0709582b..157817f327 100644 --- a/examples/angular/editable/package.json +++ b/examples/angular/editable/package.json @@ -11,23 +11,23 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/expanding/package.json b/examples/angular/expanding/package.json index 497db4108f..88209c2a4a 100644 --- a/examples/angular/expanding/package.json +++ b/examples/angular/expanding/package.json @@ -11,23 +11,23 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/filters-faceted-bucketed/package.json b/examples/angular/filters-faceted-bucketed/package.json index e2db9f6dd9..6509f581b3 100644 --- a/examples/angular/filters-faceted-bucketed/package.json +++ b/examples/angular/filters-faceted-bucketed/package.json @@ -11,23 +11,23 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/filters-faceted/package.json b/examples/angular/filters-faceted/package.json index d14107f006..93c02bee95 100644 --- a/examples/angular/filters-faceted/package.json +++ b/examples/angular/filters-faceted/package.json @@ -11,24 +11,24 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-pacer": "^0.24.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-pacer": "^0.27.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/filters-faceted/src/app/debounced-input/debounced-input.ts b/examples/angular/filters-faceted/src/app/debounced-input/debounced-input.ts index cc83285953..7f6302270c 100644 --- a/examples/angular/filters-faceted/src/app/debounced-input/debounced-input.ts +++ b/examples/angular/filters-faceted/src/app/debounced-input/debounced-input.ts @@ -1,5 +1,5 @@ import { Directive, HostListener, input, output } from '@angular/core' -import { injectDebouncedCallback } from '@tanstack/angular-pacer' +import { injectDebouncer } from '@tanstack/angular-pacer' @Directive({ standalone: true, @@ -9,13 +9,13 @@ export class DebouncedInput { readonly debounce = input(500) readonly changeEvent = output() - readonly #emitChange = injectDebouncedCallback( + readonly #emitChange = injectDebouncer( (event: Event) => this.changeEvent.emit(event), - { wait: () => this.debounce() }, + () => ({ wait: this.debounce() }), ) @HostListener('change', ['$event']) onChange(event: Event) { - this.#emitChange(event) + this.#emitChange.maybeExecute(event) } } diff --git a/examples/angular/filters-fuzzy/package.json b/examples/angular/filters-fuzzy/package.json index d04c5fcf76..0828104a1f 100644 --- a/examples/angular/filters-fuzzy/package.json +++ b/examples/angular/filters-fuzzy/package.json @@ -11,25 +11,25 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-pacer": "^0.24.0", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/match-sorter-utils": "^9.1.2", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-pacer": "^0.27.0", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/match-sorter-utils": "^9.2.6", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/filters-fuzzy/src/app/debounced-input/debounced-input.ts b/examples/angular/filters-fuzzy/src/app/debounced-input/debounced-input.ts index cc83285953..7f6302270c 100644 --- a/examples/angular/filters-fuzzy/src/app/debounced-input/debounced-input.ts +++ b/examples/angular/filters-fuzzy/src/app/debounced-input/debounced-input.ts @@ -1,5 +1,5 @@ import { Directive, HostListener, input, output } from '@angular/core' -import { injectDebouncedCallback } from '@tanstack/angular-pacer' +import { injectDebouncer } from '@tanstack/angular-pacer' @Directive({ standalone: true, @@ -9,13 +9,13 @@ export class DebouncedInput { readonly debounce = input(500) readonly changeEvent = output() - readonly #emitChange = injectDebouncedCallback( + readonly #emitChange = injectDebouncer( (event: Event) => this.changeEvent.emit(event), - { wait: () => this.debounce() }, + () => ({ wait: this.debounce() }), ) @HostListener('change', ['$event']) onChange(event: Event) { - this.#emitChange(event) + this.#emitChange.maybeExecute(event) } } diff --git a/examples/angular/filters/package.json b/examples/angular/filters/package.json index 2dc25f709d..60cdd1a9bf 100644 --- a/examples/angular/filters/package.json +++ b/examples/angular/filters/package.json @@ -11,24 +11,24 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-pacer": "^0.24.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-pacer": "^0.27.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/filters/src/app/debounced-input/debounced-input.ts b/examples/angular/filters/src/app/debounced-input/debounced-input.ts index cc83285953..7f6302270c 100644 --- a/examples/angular/filters/src/app/debounced-input/debounced-input.ts +++ b/examples/angular/filters/src/app/debounced-input/debounced-input.ts @@ -1,5 +1,5 @@ import { Directive, HostListener, input, output } from '@angular/core' -import { injectDebouncedCallback } from '@tanstack/angular-pacer' +import { injectDebouncer } from '@tanstack/angular-pacer' @Directive({ standalone: true, @@ -9,13 +9,13 @@ export class DebouncedInput { readonly debounce = input(500) readonly changeEvent = output() - readonly #emitChange = injectDebouncedCallback( + readonly #emitChange = injectDebouncer( (event: Event) => this.changeEvent.emit(event), - { wait: () => this.debounce() }, + () => ({ wait: this.debounce() }), ) @HostListener('change', ['$event']) onChange(event: Event) { - this.#emitChange(event) + this.#emitChange.maybeExecute(event) } } diff --git a/examples/angular/grouped-aggregation/package.json b/examples/angular/grouped-aggregation/package.json index 545dd7f60f..4efd26ba8b 100644 --- a/examples/angular/grouped-aggregation/package.json +++ b/examples/angular/grouped-aggregation/package.json @@ -11,23 +11,23 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/grouping/package.json b/examples/angular/grouping/package.json index 08e56f7d38..7b7b8d6eb1 100644 --- a/examples/angular/grouping/package.json +++ b/examples/angular/grouping/package.json @@ -11,23 +11,23 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/header-groups/package.json b/examples/angular/header-groups/package.json index 32939c4a82..a9c33135d8 100644 --- a/examples/angular/header-groups/package.json +++ b/examples/angular/header-groups/package.json @@ -11,23 +11,23 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/kitchen-sink/package.json b/examples/angular/kitchen-sink/package.json index cf5dab7c9b..c9dd9bbe27 100644 --- a/examples/angular/kitchen-sink/package.json +++ b/examples/angular/kitchen-sink/package.json @@ -11,26 +11,26 @@ "watch": "ng build --watch --configuration development" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-devtools": "^0.0.9", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-table-devtools": "^9.2.0", - "@tanstack/match-sorter-utils": "^9.1.2", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-devtools": "^0.0.13", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-table-devtools": "^9.3.2", + "@tanstack/match-sorter-utils": "^9.2.6", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/pagination/package.json b/examples/angular/pagination/package.json index 8c9b293ac8..1103a30688 100644 --- a/examples/angular/pagination/package.json +++ b/examples/angular/pagination/package.json @@ -11,23 +11,23 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/realtime-trading/README.md b/examples/angular/realtime-trading/README.md new file mode 100644 index 0000000000..35bae0169a --- /dev/null +++ b/examples/angular/realtime-trading/README.md @@ -0,0 +1,243 @@ +# Angular realtime trading benchmark + +This is a standalone stress example for the current TanStack Angular Table +adapter. It combines a high-frequency synthetic market feed, immutable row +snapshots, sortable and resizable columns, range selection, dynamic Angular +cell components, optional row virtualization, and browser performance +instrumentation. + +The goal is not to reproduce an exchange. It is to provide a repeatable grid +workload in which feed generation, message delivery, state application, table +work, Angular rendering, and browser layout can be measured separately. + +## Run and verify + +```bash +pnpm --dir examples/angular/realtime-trading dev +``` + +Open `http://localhost:7777`. + +Use a production build before recording representative timings: + +```bash +pnpm --dir examples/angular/realtime-trading build +pnpm --dir examples/angular/realtime-trading test:types +pnpm --dir examples/angular/realtime-trading lint +pnpm --dir examples/angular/realtime-trading test:e2e +``` + +Development mode includes Angular assertions and extra benchmark bookkeeping, +so its absolute timings should not be compared with a production build. + +## Directory structure + +| Path | Responsibility | +| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------- | +| `src/app/feed/` | Market types, the instrument universe, feed configuration, immutable update helpers, and the Angular feed service. | +| `src/app/feed/worker/` | Worker protocol, deterministic market engine, and the module Web Worker that generates and publishes quote updates. | +| `src/app/benchmark/` | Performance monitor and the controller that connects feed lifecycle events to UI diagnostics. | +| `src/app/shell/` | Full-viewport layout, header, metrics strip, sidebar configurator, selected-instrument panel, diagnostics, and status bar. | +| `src/app/table/table-config/` | Grouped column definitions and custom quote cell components. | +| `src/app/table/view/` | Header component plus table-level selection and cell host directives. | +| `src/app/table/` | Current table, table interactions, initial column fitting, and the TanStack Virtual integration. | +| `src/app/table/worker/` | Optional experimental table-worker implementation and its row-model worker. | +| `src/app/app.ts` | Composition root; it projects only the selected table implementation into the shell. | + +The feed, benchmark, shell, and table layers are deliberately separate. The +feed can run without the benchmark monitor, and shell components inject only +the controller or service whose state they display. + +## Data and worker pipeline + +The initial configuration is 100 instruments, 10K generated samples per +second, a 20 ms delivery interval, enabled intraday charts, and 16 ms intraday +sampling. + +1. `MarketFeedService` creates a module worker and sends the current + configuration. +2. `market-feed-engine.ts` owns mutable quote state inside the worker. A + deterministic PRNG and stable instrument IDs keep runs reproducible. +3. A 16 ms generation loop accrues a fractional sample budget and applies the + requested synthetic workload to the worker-owned quotes. +4. Updated instruments are stored in a `Map` by row index. Repeated updates to + one instrument are coalesced, retaining its latest value. +5. A separate publication timer posts one message at the configured delivery + interval. Generation rate and message rate are therefore independent. +6. The main thread creates a new outer quotes array and replaces only the row + objects included in the message. Unchanged rows retain their references. +7. A session ID rejects messages from an obsolete worker configuration after a + reset or instrument-count change. + +The terms in the UI are intentionally distinct: + +- **Synthetic quote workload** is generated samples per second inside the + worker. It is not DOM events, table renders, or `postMessage` calls. +- **Worker delivery interval** is the target cadence for coalesced messages. + For example, 20 ms targets roughly 50 messages per second. +- **Row updates** is the number of unique immutable row objects applied on the + main thread. It can be lower than generated samples because of coalescing. +- **Message samples** is the number of generated samples represented by the + latest delivered batch. + +Intraday history is sampled independently of quote generation. Its interval +controls how frequently a row receives a new history array; other quote fields +can continue changing between history samples. The 25K burst command generates +and flushes one intentionally expensive batch immediately. + +The worker is analogous to an upstream WebSocket/SSE producer, but it is not a +network benchmark: serialization, browser worker messaging, main-thread state +application, and rendering are in scope; network latency is not. + +## Angular state and rendering architecture + +- `MarketFeedService` owns feed signals and worker lifecycle. +- `TradingBenchmarkController` owns benchmark-only state, selected symbol, + renderer mode, virtualization preference, and derived metrics. +- The application is zoneless and uses signal inputs, outputs, queries, + `computed`, `effect`, `DestroyRef`, and `OnPush` components. +- The root component does not subscribe to individual diagnostics. It only + chooses the normal or experimental worker-backed table and supplies the same + signal values to it. +- Custom cells are declared with `flexRenderComponent` only where an Angular + component is required. Plain columns remain plain render callbacks. +- Stable row IDs come from the instrument ID, so sorting and updates do not + make row identity depend on the current array position. + +The optional **table worker** is separate from the market-feed worker. The feed +worker always produces market data; the table worker moves the supported +row-model work off the main thread. Both table paths intentionally have their +own column configuration boundary so component render tokens stay explicit. + +## Table behavior + +The grid has 14 leaf columns grouped into Instrument, Price & Change, Order +Book, Session, and Chart sections. It supports: + +- core sorting and filtering; +- on-change column resizing, including double-click reset; +- drag-and-drop leaf-column ordering with a visible drop target; +- CSS-only row hover; +- click/modified-click row selection; +- mouse-drag cell range selection and keyboard navigation; +- custom Price, Move, Percent Change, and Sparkline components; +- a stress mode that swaps the move component type when direction changes, + intentionally exercising destruction and recreation. + +Selection events are delegated once at the table boundary by +`TradingGridSelectionDirective`. It resolves a cell from `event.composedPath()` +and data attributes, avoiding a `mousedown`/move listener per cell. The cell +directive uses signal inputs and host properties for width, focus, ARIA, and +selection-edge attributes; it does not toggle CSS classes imperatively. + +Column sizes are written to table-level CSS custom properties. Cells reference +those variables rather than recomputing an inline pixel width during every +quote update. A `ResizeObserver` expands the initial column sizes to available +width; manual resizing disables subsequent automatic fitting. + +## Full DOM and virtual rows + +The internal preference is `auto`, `tanstack`, or `none`: + +- Below 200 rows, `auto` resolves to **Full DOM**, but virtualization remains + manually selectable. +- From 200 through 1,499 rows, `auto` resolves to **TanStack Virtual**, and the + user may still switch back to Full DOM. +- At 1,500 rows or more, virtualization is forced and the control is locked to + prevent an accidental full-table mount. + +TanStack Virtual uses a fixed 32 px estimate, 10-row overscan, instrument row +IDs as item keys, cached measurements, and transformed rows inside a body-sized +spacer. Only the visible overscan window creates Angular row views. The footer +reads the virtualizer range and reports the current row interval. + +The Angular virtualizer disables application-wide ticks and schedules a local +`detectChanges()` flush for virtualizer changes. This confines scroll-driven +updates to the table instead of checking the complete application shell. + +Both Full DOM and virtual rows use `content-visibility: auto` with a matching +intrinsic block size. In Full DOM this may save browser style/layout/paint work, +but Angular still creates every row and cell. In virtual mode it is an +additional browser hint; virtualization remains the mechanism that limits +mounted views. + +## Performance decisions + +- Market calculations execute off the main thread. +- Repeated worker samples are coalesced before crossing the worker boundary. +- Immutable snapshots preserve unchanged row and history references. +- Stable row IDs and keyed `@for` blocks preserve row identity. +- High-frequency selection input is delegated at the table, not bound per + cell. +- Column widths use CSS variables and update only on sizing/order changes. +- Shell widgets read narrow signal state and do not make the root consume the + complete feed. +- Dynamic component churn is opt-in; the stable renderer is the realistic + baseline. +- Virtualization limits framework and DOM work for larger data sets. +- Benchmark metrics publish at a lower cadence than the data feed. + +`content-visibility`, worker generation, and virtualization solve different +problems. None of them prevents the table core from rebuilding a sorted or +filtered row model when its data/state inputs require it. + +## Diagnostics + +The benchmark layer observes the feed through callbacks, so it can be removed +without changing feed semantics. It reports: + +- a compact **Live health** summary in the configurator: estimated frame + callbacks over a rolling 1-second window, average market-mutation-to-DOM- + commit latency over 3 seconds, cumulative long animation frames, and + throughput as changed rows plus applied snapshots per second; +- generated worker samples, changed rows, received messages, state applies, + and completed DOM commits; +- p95/maximum commit latency over a rolling 10-second window and commits over + 16.7 ms accumulated since reset; +- long animation frames and worst duration when the browser supports the Long + Animation Frames API; +- mounted cell hosts and live/created/destroyed dynamic components; +- cell-render callbacks by column and component executions by type; +- DOM `MutationRecord` delivery rate from a `MutationObserver` limited to text, + child-list, and `class`/`style` attributes; +- core row-model call rate and average/maximum duration; +- heap information where the browser exposes it. + +The frame-rate value is an estimated `requestAnimationFrame` callback rate, not +GPU-presented FPS; its healthy ceiling follows the display refresh rate. The +latency starts at the first pending feed mutation and ends in Angular's +`afterEveryRender` callback, after Angular has committed the DOM. + +`Changed rows/s` sums the update array lengths delivered by each snapshot. +Symbols are deduplicated inside one worker message, but the same row can count +again in the next snapshot; it is therefore applied row throughput, not the +number of distinct instruments touched during the entire second. + +Renderer callback counts are not DOM mutation counts. A callback can execute +and still reuse a component/view, while a component execution count records the +framework component path itself. `MutationObserver` reports delivered records, +not a one-to-one count of browser DOM operations; record coalescing and custom +component internals affect it, and observing a hot subtree has profiling +overhead. The attribute filter excludes selection-oriented `data-*` changes to +reduce noise. Heap is Chromium-only and GC-sensitive. Growth during swap mode is +not automatically a leak: confirm retention with repeated post-GC snapshots. +The rAF loop only appends a timestamp; rolling aggregation and heap reads run at +the 500 ms metrics publication cadence. Mutation observation remains the most +intrusive diagnostic because the browser must create records for the observed +subtree. + +Use Chrome Performance/Angular DevTools for call stacks and frame analysis, and +the in-app diagnostics for controlled comparisons. Keep row count, workload, +delivery interval, renderer mode, and virtual mode identical between runs. + +## Standalone example policy + +This folder intentionally contains its own instruments, feed engine, worker, +benchmark monitor, styles, and UI instead of importing a shared demo package. +That duplication lets the example run independently and be copied to +StackBlitz. Shared concepts and some README text are therefore repeated across +adapter examples by design. + +The package pins `@tanstack/angular-table` to the repository version. The root +workspace override resolves it to `packages/angular-table` while retaining a +release-like example manifest. diff --git a/examples/angular/realtime-trading/angular.json b/examples/angular/realtime-trading/angular.json new file mode 100644 index 0000000000..5512416689 --- /dev/null +++ b/examples/angular/realtime-trading/angular.json @@ -0,0 +1,76 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "cli": { + "packageManager": "pnpm", + "analytics": false, + "cache": { + "enabled": false + } + }, + "newProjectRoot": "projects", + "projects": { + "realtime-trading": { + "projectType": "application", + "schematics": { + "@schematics/angular:component": { + "inlineTemplate": true, + "inlineStyle": true, + "skipTests": true + } + }, + "root": "", + "sourceRoot": "src", + "prefix": "app", + "architect": { + "build": { + "builder": "@angular/build:application", + "options": { + "browser": "src/main.ts", + "tsConfig": "tsconfig.app.json", + "assets": [], + "styles": ["src/styles.css"] + }, + "configurations": { + "production": { + "budgets": [ + { + "type": "initial", + "maximumWarning": "500kB", + "maximumError": "1MB" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "4kB", + "maximumError": "8kB" + } + ], + "outputHashing": "all" + }, + "development": { + "optimization": false, + "extractLicenses": false, + "sourceMap": true + } + }, + "defaultConfiguration": "production" + }, + "serve": { + "builder": "@angular/build:dev-server", + "options": { + "allowedHosts": true + }, + "configurations": { + "production": { + "buildTarget": "realtime-trading:build:production" + }, + "development": { + "buildTarget": "realtime-trading:build:development" + } + }, + "defaultConfiguration": "development" + } + } + } + } +} diff --git a/examples/angular/realtime-trading/package.json b/examples/angular/realtime-trading/package.json new file mode 100644 index 0000000000..eed0086451 --- /dev/null +++ b/examples/angular/realtime-trading/package.json @@ -0,0 +1,38 @@ +{ + "name": "tanstack-angular-table-example-realtime-trading", + "scripts": { + "ng": "ng", + "start": "ng serve --port 7777", + "dev": "ng serve --port 7777", + "build": "ng build", + "watch": "ng build --watch --configuration development", + "lint": "eslint ./src", + "test:types": "tsc -p tsconfig.app.json --noEmit", + "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" + }, + "nx": { + "targets": { + "test:e2e": { + "parallelism": false + } + } + }, + "private": true, + "packageManager": "pnpm@12.18.0", + "dependencies": { + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-virtual": "^6.1.12", + "rxjs": "~7.8.2", + "tslib": "^2.9.1" + }, + "devDependencies": { + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", + "typescript": "6.0.3" + } +} diff --git a/examples/angular/realtime-trading/src/app/app.config.ts b/examples/angular/realtime-trading/src/app/app.config.ts new file mode 100644 index 0000000000..cbb47d366c --- /dev/null +++ b/examples/angular/realtime-trading/src/app/app.config.ts @@ -0,0 +1,6 @@ +import { provideBrowserGlobalErrorListeners } from '@angular/core' +import type { ApplicationConfig } from '@angular/core' + +export const appConfig: ApplicationConfig = { + providers: [provideBrowserGlobalErrorListeners()], +} diff --git a/examples/angular/realtime-trading/src/app/app.ts b/examples/angular/realtime-trading/src/app/app.ts new file mode 100644 index 0000000000..e348e9374c --- /dev/null +++ b/examples/angular/realtime-trading/src/app/app.ts @@ -0,0 +1,35 @@ +import { ChangeDetectionStrategy, Component, inject } from '@angular/core' +import { TradingBenchmarkController } from './benchmark/trading-benchmark.controller' +import { CurrentTradingTable } from './table/current-trading-table' +import { TradingShell } from './shell/trading-shell' +import { WorkerTradingTable } from './table/worker/worker-trading-table' + +@Component({ + selector: 'app-root', + imports: [CurrentTradingTable, TradingShell, WorkerTradingTable], + template: ` + + @if (controller.tableWorkerEnabled()) { + + } @else { + + } + + `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class App { + readonly controller = inject(TradingBenchmarkController) +} diff --git a/examples/angular/realtime-trading/src/app/benchmark/benchmark-monitor.ts b/examples/angular/realtime-trading/src/app/benchmark/benchmark-monitor.ts new file mode 100644 index 0000000000..4c614e5e39 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/benchmark/benchmark-monitor.ts @@ -0,0 +1,267 @@ +import { quoteCellLifecycle } from '../table/table-config/quote-cells' + +export interface FeedMetrics { + actualTicksPerSecond: number + rowUpdatesPerSecond: number + workerMessagesPerSecond: number + stateApplicationsPerSecond: number + supersededUpdatesPerSecond: number + totalTicks: number + rafCallbacksPerSecond: number + tableRendersPerSecond: number + lastBatchSize: number + averageRenderMs: number + p95RenderMs: number + maxRenderMs: number + slowRenders: number + longAnimationFrames: number + worstLongAnimationFrameMs: number + heapMb: number | null + componentsCreated: number + componentsDestroyed: number + workerMessages: number + lastUpdateCount: number + domMutationsPerSecond: number +} + +export const initialMetrics: FeedMetrics = { + actualTicksPerSecond: 0, + rowUpdatesPerSecond: 0, + workerMessagesPerSecond: 0, + stateApplicationsPerSecond: 0, + supersededUpdatesPerSecond: 0, + totalTicks: 0, + rafCallbacksPerSecond: 0, + tableRendersPerSecond: 0, + lastBatchSize: 0, + averageRenderMs: 0, + p95RenderMs: 0, + maxRenderMs: 0, + slowRenders: 0, + longAnimationFrames: 0, + worstLongAnimationFrameMs: 0, + heapMb: null, + componentsCreated: 0, + componentsDestroyed: 0, + workerMessages: 0, + lastUpdateCount: 0, + domMutationsPerSecond: 0, +} + +interface CommitLatencySample { + recordedAt: number + duration: number +} + +const AVERAGE_COMMIT_WINDOW_MS = 3_000 +const PERCENTILE_COMMIT_WINDOW_MS = 10_000 +const FRAME_RATE_WINDOW_MS = 1_000 + +export class BenchmarkMonitor { + readonly #runtime = { + sampleStartedAt: performance.now(), + sessionStartedAt: performance.now(), + frameTrackingStartedAt: performance.now(), + pendingRenderStartedAt: null as number | null, + renderSamples: [] as Array, + frameTimestamps: [] as Array, + totalTicks: 0, + ticksInSample: 0, + rowUpdatesInSample: 0, + workerMessagesInSample: 0, + stateApplicationsInSample: 0, + supersededUpdatesInSample: 0, + lastBatchSize: 0, + lastUpdateCount: 0, + workerMessages: 0, + tableRendersInSample: 0, + slowRenderCount: 0, + longAnimationFrameCount: 0, + worstLongAnimationFrameMs: 0, + domMutationsInSample: 0, + } + + markRenderPending(): void { + this.#runtime.pendingRenderStartedAt ??= performance.now() + } + + recordCompletedRender(): void { + const runtime = this.#runtime + if (runtime.pendingRenderStartedAt !== null) { + const renderEndedAt = performance.now() + const duration = renderEndedAt - runtime.pendingRenderStartedAt + runtime.renderSamples.push({ recordedAt: renderEndedAt, duration }) + if (duration > 16.7) runtime.slowRenderCount++ + runtime.pendingRenderStartedAt = null + runtime.tableRendersInSample++ + } + } + + recordWorkerMessage(): void { + this.#runtime.workerMessages++ + this.#runtime.workerMessagesInSample++ + } + + recordBatch( + tickCount: number, + updateCount: number, + supersededUpdateCount: number, + ): void { + const runtime = this.#runtime + runtime.lastBatchSize = tickCount + runtime.lastUpdateCount = updateCount + runtime.ticksInSample += tickCount + runtime.totalTicks += tickCount + runtime.rowUpdatesInSample += updateCount + runtime.stateApplicationsInSample++ + runtime.supersededUpdatesInSample += supersededUpdateCount + } + + recordAnimationFrame(now: number): void { + this.#runtime.frameTimestamps.push(now) + } + + recordLongAnimationFrame(duration: number, startTime: number): void { + const runtime = this.#runtime + if (startTime < runtime.sessionStartedAt) return + runtime.longAnimationFrameCount++ + runtime.worstLongAnimationFrameMs = Math.max( + runtime.worstLongAnimationFrameMs, + duration, + ) + } + + recordDomMutations(count: number): void { + this.#runtime.domMutationsInSample += count + } + + resetDomMutations(): void { + this.#runtime.domMutationsInSample = 0 + } + + shouldPublish(now: number): boolean { + return now - this.#runtime.sampleStartedAt >= 500 + } + + publish(now: number): FeedMetrics { + const runtime = this.#runtime + const sampleDuration = now - runtime.sampleStartedAt + runtime.renderSamples = runtime.renderSamples.filter( + (sample) => sample.recordedAt >= now - PERCENTILE_COMMIT_WINDOW_MS, + ) + runtime.frameTimestamps = runtime.frameTimestamps.filter( + (timestamp) => timestamp >= now - FRAME_RATE_WINDOW_MS, + ) + const averageRenderSamples = runtime.renderSamples.filter( + (sample) => sample.recordedAt >= now - AVERAGE_COMMIT_WINDOW_MS, + ) + const sortedRenderSamples = runtime.renderSamples + .map((sample) => sample.duration) + .sort((left, right) => left - right) + const averageRenderMs = + averageRenderSamples.length === 0 + ? 0 + : averageRenderSamples.reduce( + (sum, sample) => sum + sample.duration, + 0, + ) / averageRenderSamples.length + const p95Index = Math.max( + 0, + Math.ceil(sortedRenderSamples.length * 0.95) - 1, + ) + const metrics: FeedMetrics = { + actualTicksPerSecond: + sampleDuration === 0 + ? 0 + : (runtime.ticksInSample / sampleDuration) * 1_000, + rowUpdatesPerSecond: + (runtime.rowUpdatesInSample / sampleDuration) * 1_000, + workerMessagesPerSecond: + (runtime.workerMessagesInSample / sampleDuration) * 1_000, + stateApplicationsPerSecond: + (runtime.stateApplicationsInSample / sampleDuration) * 1_000, + supersededUpdatesPerSecond: + (runtime.supersededUpdatesInSample / sampleDuration) * 1_000, + totalTicks: runtime.totalTicks, + rafCallbacksPerSecond: + (runtime.frameTimestamps.length / + Math.min( + FRAME_RATE_WINDOW_MS, + Math.max(1, now - runtime.frameTrackingStartedAt), + )) * + 1_000, + tableRendersPerSecond: + (runtime.tableRendersInSample / sampleDuration) * 1_000, + lastBatchSize: runtime.lastBatchSize, + averageRenderMs, + p95RenderMs: sortedRenderSamples[p95Index] ?? 0, + maxRenderMs: sortedRenderSamples.at(-1) ?? 0, + slowRenders: runtime.slowRenderCount, + longAnimationFrames: runtime.longAnimationFrameCount, + worstLongAnimationFrameMs: runtime.worstLongAnimationFrameMs, + heapMb: readHeapSizeMb(), + componentsCreated: quoteCellLifecycle.created, + componentsDestroyed: quoteCellLifecycle.destroyed, + workerMessages: runtime.workerMessages, + lastUpdateCount: runtime.lastUpdateCount, + domMutationsPerSecond: + (runtime.domMutationsInSample / sampleDuration) * 1_000, + } + + runtime.sampleStartedAt = now + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.domMutationsInSample = 0 + runtime.tableRendersInSample = 0 + return metrics + } + + reset(): void { + const runtime = this.#runtime + runtime.sampleStartedAt = performance.now() + runtime.sessionStartedAt = runtime.sampleStartedAt + runtime.pendingRenderStartedAt = null + runtime.renderSamples = [] + runtime.frameTrackingStartedAt = runtime.sampleStartedAt + runtime.frameTimestamps = [] + runtime.totalTicks = 0 + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.lastBatchSize = 0 + runtime.lastUpdateCount = 0 + runtime.workerMessages = 0 + runtime.tableRendersInSample = 0 + runtime.slowRenderCount = 0 + runtime.longAnimationFrameCount = 0 + runtime.worstLongAnimationFrameMs = 0 + runtime.domMutationsInSample = 0 + } +} + +function readHeapSizeMb(): number | null { + const memory = ( + performance as Performance & { + memory?: { usedJSHeapSize: number } + } + ).memory + return memory ? memory.usedJSHeapSize / 1_048_576 : null +} + +export function exposeTradingBenchmarkSnapshot( + metrics: FeedMetrics, + extras: { mountedCells: number; liveComponents: number }, +): void { + Object.assign(globalThis, { + __TANSTACK_TRADING_BENCHMARK__: { + capturedAt: performance.now(), + metrics, + ...extras, + }, + }) +} diff --git a/examples/angular/realtime-trading/src/app/benchmark/trading-benchmark.controller.ts b/examples/angular/realtime-trading/src/app/benchmark/trading-benchmark.controller.ts new file mode 100644 index 0000000000..f2bbe3c008 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/benchmark/trading-benchmark.controller.ts @@ -0,0 +1,154 @@ +import { + DestroyRef, + Injectable, + computed, + inject, + isDevMode, + signal, +} from '@angular/core' +import { TRADING_COLUMN_COUNT } from '../table/table-config/trading-column-types' +import { MarketFeedService } from '../feed/market-feed.service' +import { + FORCED_VIRTUALIZATION_ROW_COUNT, + resolveVirtualScrollMode, +} from '../table/trading-row-virtualizer' +import { + BenchmarkMonitor, + exposeTradingBenchmarkSnapshot, + initialMetrics, +} from './benchmark-monitor' +import type { + VirtualScrollMode, + VirtualScrollPreference, +} from '../table/trading-row-virtualizer' +import type { FeedMetrics } from './benchmark-monitor' +import type { RendererMode } from '../table/table-config/trading-column-types' + +@Injectable({ providedIn: 'root' }) +export class TradingBenchmarkController { + readonly #destroyRef = inject(DestroyRef) + readonly #monitor = new BenchmarkMonitor() + readonly #feed = inject(MarketFeedService) + readonly #longAnimationFrameObserver: PerformanceObserver | null + + readonly devMode = isDevMode() + readonly longAnimationFramesSupported = + PerformanceObserver.supportedEntryTypes.includes('long-animation-frame') + readonly tableWorkerEnabled = signal(false) + readonly renderedRowCount = signal(0) + readonly rendererMode = signal('stable') + readonly requestedVirtualScrollMode = signal('auto') + readonly selectedSymbol = signal(null) + readonly metrics = signal(initialMetrics) + readonly displayQuotes = this.#feed.quotes + readonly selectedQuote = computed(() => { + const symbol = this.selectedSymbol() + return symbol + ? (this.displayQuotes().find((quote) => quote.symbol === symbol) ?? null) + : null + }) + readonly virtualScrollForced = computed( + () => this.#feed.instrumentCount() >= FORCED_VIRTUALIZATION_ROW_COUNT, + ) + readonly virtualScrollMode = computed(() => + resolveVirtualScrollMode( + this.requestedVirtualScrollMode(), + this.#feed.instrumentCount(), + ), + ) + readonly mountedCells = computed( + () => this.renderedRowCount() * TRADING_COLUMN_COUNT, + ) + readonly liveComponents = computed(() => { + const metrics = this.metrics() + return metrics.componentsCreated - metrics.componentsDestroyed + }) + + #animationFrameId: number | null = null + + constructor() { + const stopObservingFeed = this.#feed.observe({ + messageReceived: () => this.#monitor.recordWorkerMessage(), + mutationStarted: () => this.#monitor.markRenderPending(), + batchApplied: ({ tickCount, updateCount, supersededUpdateCount }) => + this.#monitor.recordBatch( + tickCount, + updateCount, + supersededUpdateCount, + ), + renderCommitted: () => this.#monitor.recordCompletedRender(), + }) + this.#longAnimationFrameObserver = this.longAnimationFramesSupported + ? new PerformanceObserver(this.#recordLongAnimationFrames) + : null + this.#longAnimationFrameObserver?.observe({ + type: 'long-animation-frame', + }) + this.#animationFrameId = requestAnimationFrame(this.#benchmarkFrame) + this.#destroyRef.onDestroy(() => { + stopObservingFeed() + if (this.#animationFrameId !== null) { + cancelAnimationFrame(this.#animationFrameId) + } + this.#longAnimationFrameObserver?.disconnect() + }) + } + + setRendererMode(shouldSwap: boolean): void { + this.rendererMode.set(shouldSwap ? 'swap' : 'stable') + } + + setTableWorkerEnabled(enabled: boolean): void { + this.tableWorkerEnabled.set(enabled) + } + + setVirtualScrollEnabled(enabled: boolean): void { + if (this.virtualScrollForced()) return + this.requestedVirtualScrollMode.set(enabled ? 'tanstack' : 'none') + } + + setRenderedRowCount(count: number): void { + this.renderedRowCount.set(count) + } + + recordDomMutations(count: number): void { + this.#monitor.recordDomMutations(count) + } + + resetDomMutations(): void { + this.#monitor.resetDomMutations() + } + + resetViewState(): void { + this.selectedSymbol.set(null) + this.requestedVirtualScrollMode.set('auto') + } + + resetMarket(): void { + this.#monitor.reset() + this.resetViewState() + this.metrics.set(initialMetrics) + this.#feed.reset() + } + + readonly #benchmarkFrame = (now: number): void => { + this.#monitor.recordAnimationFrame(now) + if (this.#monitor.shouldPublish(now)) { + const metrics = this.#monitor.publish(now) + this.metrics.set(metrics) + exposeTradingBenchmarkSnapshot(metrics, { + mountedCells: this.mountedCells(), + liveComponents: this.liveComponents(), + }) + } + this.#animationFrameId = requestAnimationFrame(this.#benchmarkFrame) + } + + readonly #recordLongAnimationFrames = ( + entries: PerformanceObserverEntryList, + ): void => { + for (const entry of entries.getEntries()) { + this.#monitor.recordLongAnimationFrame(entry.duration, entry.startTime) + } + } +} diff --git a/examples/angular/realtime-trading/src/app/feed/feed-sample-rates.ts b/examples/angular/realtime-trading/src/app/feed/feed-sample-rates.ts new file mode 100644 index 0000000000..17dc2015a6 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/feed/feed-sample-rates.ts @@ -0,0 +1,33 @@ +export const feedSampleRateOptions = [ + { label: '100', value: 100 }, + { label: '250', value: 250 }, + { label: '500', value: 500 }, + { label: '1K', value: 1_000 }, + { label: '2.5K', value: 2_500 }, + { label: '5K', value: 5_000 }, + { label: '10K', value: 10_000 }, + { label: '25K', value: 25_000 }, + { label: '50K', value: 50_000 }, + { label: '100K', value: 100_000 }, +] as const + +export function feedSampleRateIndex(rate: number): number { + return feedSampleRateOptions.reduce((closestIndex, candidate, index) => { + const closest = feedSampleRateOptions[closestIndex] + return Math.abs(candidate.value - rate) < Math.abs(closest.value - rate) + ? index + : closestIndex + }, 0) +} + +export function feedSampleRateAt(stepIndex: number): number { + const index = Math.min( + feedSampleRateOptions.length - 1, + Math.max(0, Math.round(stepIndex)), + ) + return feedSampleRateOptions[index].value +} + +export function normalizeFeedSampleRate(rate: number): number { + return feedSampleRateAt(feedSampleRateIndex(rate)) +} diff --git a/examples/angular/realtime-trading/src/app/feed/market-data.ts b/examples/angular/realtime-trading/src/app/feed/market-data.ts new file mode 100644 index 0000000000..6231865d3f --- /dev/null +++ b/examples/angular/realtime-trading/src/app/feed/market-data.ts @@ -0,0 +1,38 @@ +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './worker/market-feed-protocol' + +export interface MarketQuote extends Omit { + history: ReadonlyArray +} + +export function hydrateMarketQuotes( + snapshots: Array, +): Array { + return snapshots.map((quote) => ({ + ...quote, + history: [...quote.history], + })) +} + +export function applyMarketUpdates( + quotes: Array, + updates: Array, +): Array { + const nextQuotes = [...quotes] + + for (const update of updates) { + const { index, history, ...values } = update + const previousQuote = quotes.at(index) + if (!previousQuote) continue + + nextQuotes[index] = { + ...previousQuote, + ...values, + history: history ?? previousQuote.history, + } + } + + return nextQuotes +} diff --git a/examples/angular/realtime-trading/src/app/feed/market-feed-config.ts b/examples/angular/realtime-trading/src/app/feed/market-feed-config.ts new file mode 100644 index 0000000000..9d477ed663 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/feed/market-feed-config.ts @@ -0,0 +1,15 @@ +export interface MarketFeedConfig { + readonly instrumentCount: number + readonly targetSamplesPerSecond: number + readonly publishIntervalMs: number + readonly updateSparklines: boolean + readonly sparklineSampleIntervalMs: number +} + +export const initialMarketFeedConfig: MarketFeedConfig = { + instrumentCount: 100, + targetSamplesPerSecond: 10_000, + publishIntervalMs: 20, + updateSparklines: true, + sparklineSampleIntervalMs: 16, +} diff --git a/examples/angular/realtime-trading/src/app/feed/market-feed.service.ts b/examples/angular/realtime-trading/src/app/feed/market-feed.service.ts new file mode 100644 index 0000000000..c4a83df35c --- /dev/null +++ b/examples/angular/realtime-trading/src/app/feed/market-feed.service.ts @@ -0,0 +1,175 @@ +import { + DestroyRef, + Injectable, + afterEveryRender, + inject, + signal, +} from '@angular/core' +import { normalizeFeedSampleRate } from './feed-sample-rates' +import { initialMarketFeedConfig } from './market-feed-config' +import { applyMarketUpdates, hydrateMarketQuotes } from './market-data' +import type { + MarketFeedCommand, + MarketFeedEvent, +} from './worker/market-feed-protocol' +import type { MarketQuote } from './market-data' + +export interface MarketFeedBatch { + tickCount: number + updateCount: number + supersededUpdateCount: number +} + +export interface MarketFeedObserver { + messageReceived?: () => void + mutationStarted?: () => void + batchApplied?: (batch: MarketFeedBatch) => void + renderCommitted?: () => void +} + +@Injectable({ providedIn: 'root' }) +export class MarketFeedService { + readonly #destroyRef = inject(DestroyRef) + readonly #worker = new Worker( + new URL('./worker/market-feed.worker', import.meta.url), + { type: 'module' }, + ) + readonly #observers = new Set() + + readonly workerReady = signal(false) + readonly running = signal(!new URLSearchParams(location.search).has('paused')) + readonly instrumentCount = signal(initialMarketFeedConfig.instrumentCount) + readonly targetTicksPerSecond = signal( + initialMarketFeedConfig.targetSamplesPerSecond, + ) + readonly publishIntervalMs = signal(initialMarketFeedConfig.publishIntervalMs) + readonly updateSparklines = signal(initialMarketFeedConfig.updateSparklines) + readonly sparklineSampleIntervalMs = signal( + initialMarketFeedConfig.sparklineSampleIntervalMs, + ) + readonly quotes = signal>([]) + + #feedSessionId = 0 + #renderPending = false + + constructor() { + afterEveryRender(() => this.completeRender()) + this.#worker.addEventListener('message', this.#handleWorkerMessage) + this.#worker.addEventListener('error', this.#handleWorkerError) + this.#post({ + type: 'start', + rowCount: this.instrumentCount(), + running: this.running(), + ticksPerSecond: this.targetTicksPerSecond(), + publishIntervalMs: this.publishIntervalMs(), + updateSparklines: this.updateSparklines(), + sparklineSampleIntervalMs: this.sparklineSampleIntervalMs(), + }) + this.#destroyRef.onDestroy(() => { + this.#worker.removeEventListener('message', this.#handleWorkerMessage) + this.#worker.removeEventListener('error', this.#handleWorkerError) + this.#worker.terminate() + this.#observers.clear() + }) + } + + observe(observer: MarketFeedObserver): () => void { + this.#observers.add(observer) + return () => this.#observers.delete(observer) + } + + completeRender(): void { + if (!this.#renderPending) return + + this.#renderPending = false + for (const observer of this.#observers) { + observer.renderCommitted?.() + } + } + + toggle(): void { + const running = !this.running() + this.running.set(running) + this.#post({ type: 'set-running', running }) + } + + setInstrumentCount(count: number): void { + this.instrumentCount.set(count) + this.reset() + } + + setTargetRate(rate: number): void { + const sampleRate = normalizeFeedSampleRate(rate) + this.targetTicksPerSecond.set(sampleRate) + this.#post({ type: 'set-rate', ticksPerSecond: sampleRate }) + } + + setPublishInterval(publishIntervalMs: number): void { + this.publishIntervalMs.set(publishIntervalMs) + this.#post({ type: 'set-publish-interval', intervalMs: publishIntervalMs }) + } + + setSparklineUpdates(enabled: boolean): void { + this.updateSparklines.set(enabled) + this.#post({ type: 'set-sparklines', enabled }) + } + + setSparklineSampleInterval(intervalMs: number): void { + this.sparklineSampleIntervalMs.set(intervalMs) + this.#post({ type: 'set-sparkline-interval', intervalMs }) + } + + runBurst(): void { + this.#post({ type: 'burst', tickCount: 25_000 }) + } + + reset(): void { + this.workerReady.set(false) + this.#post({ type: 'reset', rowCount: this.instrumentCount() }) + } + + readonly #handleWorkerMessage = ({ + data, + }: MessageEvent): void => { + if (data.type === 'snapshot') { + this.#feedSessionId = data.sessionId + this.#startMutation() + this.quotes.set(hydrateMarketQuotes(data.quotes)) + this.workerReady.set(true) + return + } + + if (data.sessionId !== this.#feedSessionId) return + + for (const observer of this.#observers) { + observer.messageReceived?.() + } + this.#startMutation() + this.quotes.update((quotes) => applyMarketUpdates(quotes, data.updates)) + const batch = { + tickCount: data.tickCount, + updateCount: data.updates.length, + supersededUpdateCount: data.coalescedUpdateCount, + } + for (const observer of this.#observers) { + observer.batchApplied?.(batch) + } + } + + readonly #handleWorkerError = (error: ErrorEvent): void => { + this.workerReady.set(false) + this.running.set(false) + console.error('Market feed worker failed', error) + } + + #startMutation(): void { + this.#renderPending = true + for (const observer of this.#observers) { + observer.mutationStarted?.() + } + } + + #post(command: MarketFeedCommand): void { + this.#worker.postMessage(command) + } +} diff --git a/examples/angular/realtime-trading/src/app/feed/market-instruments.ts b/examples/angular/realtime-trading/src/app/feed/market-instruments.ts new file mode 100644 index 0000000000..ac18d14ea9 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/feed/market-instruments.ts @@ -0,0 +1,742 @@ +export type MarketCode = + | 'US' + | 'NL' + | 'DE' + | 'FR' + | 'IT' + | 'ES' + | 'CH' + | 'DK' + | 'SE' + | 'FI' + | 'GB' + | 'KR' + | 'JP' + | 'HK' + | 'CA' + | 'AU' + +export type BaseInstrument = readonly [ + symbol: string, + company: string, + market: MarketCode, +] + +/** + * Current S&P 500 constituent universe used by the realtime trading examples. + * + * Source snapshot: https://github.com/datasets/s-and-p-500-companies + * Retrieved: 2026-08-15. + * Multiple share classes are intentionally represented as separate instruments. + */ +export const marketInstruments = Object.freeze([ + ['MMM', '3M', 'US'], + ['AOS', 'A. O. Smith', 'US'], + ['ABT', 'Abbott Laboratories', 'US'], + ['ABBV', 'AbbVie', 'US'], + ['ACN', 'Accenture', 'US'], + ['ADBE', 'Adobe Inc.', 'US'], + ['AMD', 'Advanced Micro Devices', 'US'], + ['AES', 'AES Corporation', 'US'], + ['AFL', 'Aflac', 'US'], + ['A', 'Agilent Technologies', 'US'], + ['APD', 'Air Products', 'US'], + ['ABNB', 'Airbnb', 'US'], + ['AKAM', 'Akamai Technologies', 'US'], + ['ALB', 'Albemarle Corporation', 'US'], + ['ARE', 'Alexandria Real Estate Equities', 'US'], + ['ALGN', 'Align Technology', 'US'], + ['ALLE', 'Allegion', 'US'], + ['LNT', 'Alliant Energy', 'US'], + ['ALL', 'Allstate', 'US'], + ['GOOGL', 'Alphabet Inc. (Class A)', 'US'], + ['GOOG', 'Alphabet Inc. (Class C)', 'US'], + ['MO', 'Altria', 'US'], + ['AMZN', 'Amazon', 'US'], + ['AMCR', 'Amcor', 'US'], + ['AEE', 'Ameren', 'US'], + ['AEP', 'American Electric Power', 'US'], + ['AXP', 'American Express', 'US'], + ['AIG', 'American International Group', 'US'], + ['AMT', 'American Tower', 'US'], + ['AWK', 'American Water Works', 'US'], + ['AMP', 'Ameriprise Financial', 'US'], + ['AME', 'Ametek', 'US'], + ['AMGN', 'Amgen', 'US'], + ['APH', 'Amphenol', 'US'], + ['ADI', 'Analog Devices', 'US'], + ['AON', 'Aon plc', 'US'], + ['APA', 'APA Corporation', 'US'], + ['APO', 'Apollo Global Management', 'US'], + ['AAPL', 'Apple Inc.', 'US'], + ['AMAT', 'Applied Materials', 'US'], + ['APP', 'AppLovin', 'US'], + ['APTV', 'Aptiv', 'US'], + ['ACGL', 'Arch Capital Group', 'US'], + ['ADM', 'Archer Daniels Midland', 'US'], + ['ARES', 'Ares Management', 'US'], + ['ANET', 'Arista Networks', 'US'], + ['AJG', 'Arthur J. Gallagher & Co.', 'US'], + ['AIZ', 'Assurant', 'US'], + ['T', 'AT&T', 'US'], + ['ATO', 'Atmos Energy', 'US'], + ['ADSK', 'Autodesk', 'US'], + ['ADP', 'Automatic Data Processing', 'US'], + ['AZO', 'AutoZone', 'US'], + ['AVB', 'AvalonBay Communities', 'US'], + ['AVY', 'Avery Dennison', 'US'], + ['AXON', 'Axon Enterprise', 'US'], + ['BKR', 'Baker Hughes', 'US'], + ['BALL', 'Ball Corporation', 'US'], + ['BAC', 'Bank of America', 'US'], + ['BAX', 'Baxter International', 'US'], + ['BDX', 'Becton Dickinson', 'US'], + ['BRK.B', 'Berkshire Hathaway', 'US'], + ['BBY', 'Best Buy', 'US'], + ['TECH', 'Bio-Techne', 'US'], + ['BIIB', 'Biogen', 'US'], + ['BLK', 'BlackRock', 'US'], + ['BX', 'Blackstone Inc.', 'US'], + ['XYZ', 'Block, Inc.', 'US'], + ['BNY', 'BNY Mellon', 'US'], + ['BA', 'Boeing', 'US'], + ['BKNG', 'Booking Holdings', 'US'], + ['BSX', 'Boston Scientific', 'US'], + ['BMY', 'Bristol Myers Squibb', 'US'], + ['AVGO', 'Broadcom', 'US'], + ['BR', 'Broadridge Financial Solutions', 'US'], + ['BRO', 'Brown & Brown', 'US'], + ['BF.B', 'Brown–Forman', 'US'], + ['BLDR', 'Builders FirstSource', 'US'], + ['BG', 'Bunge Global', 'US'], + ['BXP', 'BXP, Inc.', 'US'], + ['CHRW', 'C.H. Robinson', 'US'], + ['CDNS', 'Cadence Design Systems', 'US'], + ['CPT', 'Camden Property Trust', 'US'], + ['COF', 'Capital One', 'US'], + ['CAH', 'Cardinal Health', 'US'], + ['CCL', 'Carnival Corporation', 'US'], + ['CARR', 'Carrier Global', 'US'], + ['CVNA', 'Carvana', 'US'], + ['CASY', "Casey's", 'US'], + ['CAT', 'Caterpillar Inc.', 'US'], + ['CBOE', 'Cboe Global Markets', 'US'], + ['CBRE', 'CBRE Group', 'US'], + ['CDW', 'CDW Corporation', 'US'], + ['COR', 'Cencora', 'US'], + ['CNC', 'Centene Corporation', 'US'], + ['CNP', 'CenterPoint Energy', 'US'], + ['CF', 'CF Industries', 'US'], + ['CRL', 'Charles River Laboratories', 'US'], + ['SCHW', 'Charles Schwab Corporation', 'US'], + ['CHTR', 'Charter Communications', 'US'], + ['CVX', 'Chevron Corporation', 'US'], + ['CMG', 'Chipotle Mexican Grill', 'US'], + ['CB', 'Chubb Limited', 'US'], + ['CHD', 'Church & Dwight', 'US'], + ['CIEN', 'Ciena', 'US'], + ['CI', 'Cigna', 'US'], + ['CINF', 'Cincinnati Financial', 'US'], + ['CTAS', 'Cintas', 'US'], + ['CSCO', 'Cisco', 'US'], + ['C', 'Citigroup', 'US'], + ['CFG', 'Citizens Financial Group', 'US'], + ['CLX', 'Clorox', 'US'], + ['CME', 'CME Group', 'US'], + ['CMS', 'CMS Energy', 'US'], + ['KO', 'Coca-Cola Company (The)', 'US'], + ['CTSH', 'Cognizant', 'US'], + ['COHR', 'Coherent Corp.', 'US'], + ['COIN', 'Coinbase', 'US'], + ['CL', 'Colgate-Palmolive', 'US'], + ['CMCSA', 'Comcast', 'US'], + ['FIX', 'Comfort Systems USA', 'US'], + ['COP', 'ConocoPhillips', 'US'], + ['ED', 'Consolidated Edison', 'US'], + ['STZ', 'Constellation Brands', 'US'], + ['CEG', 'Constellation Energy', 'US'], + ['COO', 'Cooper Companies (The)', 'US'], + ['CPRT', 'Copart', 'US'], + ['GLW', 'Corning Inc.', 'US'], + ['CPAY', 'Corpay', 'US'], + ['CTVA', 'Corteva', 'US'], + ['CSGP', 'CoStar Group', 'US'], + ['COST', 'Costco', 'US'], + ['CRH', 'CRH plc', 'US'], + ['CRWD', 'CrowdStrike', 'US'], + ['CCI', 'Crown Castle', 'US'], + ['CSX', 'CSX Corporation', 'US'], + ['CMI', 'Cummins', 'US'], + ['CVS', 'CVS Health', 'US'], + ['DHR', 'Danaher Corporation', 'US'], + ['DRI', 'Darden Restaurants', 'US'], + ['DDOG', 'Datadog', 'US'], + ['DVA', 'DaVita', 'US'], + ['DECK', 'Deckers Brands', 'US'], + ['DE', 'Deere & Company', 'US'], + ['DELL', 'Dell Technologies', 'US'], + ['DAL', 'Delta Air Lines', 'US'], + ['DVN', 'Devon Energy', 'US'], + ['DXCM', 'Dexcom', 'US'], + ['FANG', 'Diamondback Energy', 'US'], + ['DLR', 'Digital Realty', 'US'], + ['DG', 'Dollar General', 'US'], + ['DLTR', 'Dollar Tree', 'US'], + ['D', 'Dominion Energy', 'US'], + ['DPZ', "Domino's", 'US'], + ['DASH', 'DoorDash', 'US'], + ['DOV', 'Dover Corporation', 'US'], + ['DOW', 'Dow Inc.', 'US'], + ['DHI', 'D. R. Horton', 'US'], + ['DTE', 'DTE Energy', 'US'], + ['DUK', 'Duke Energy', 'US'], + ['DD', 'DuPont', 'US'], + ['ETN', 'Eaton Corporation', 'US'], + ['EBAY', 'eBay Inc.', 'US'], + ['ECHO', 'EchoStar', 'US'], + ['ECL', 'Ecolab', 'US'], + ['EIX', 'Edison International', 'US'], + ['EW', 'Edwards Lifesciences', 'US'], + ['ELV', 'Elevance Health', 'US'], + ['EME', 'Emcor', 'US'], + ['EMR', 'Emerson Electric', 'US'], + ['ETR', 'Entergy', 'US'], + ['EOG', 'EOG Resources', 'US'], + ['EQT', 'EQT Corporation', 'US'], + ['EFX', 'Equifax', 'US'], + ['EQIX', 'Equinix', 'US'], + ['EQR', 'Equity Residential', 'US'], + ['ERIE', 'Erie Indemnity', 'US'], + ['ESS', 'Essex Property Trust', 'US'], + ['EL', 'Estée Lauder Companies (The)', 'US'], + ['EG', 'Everest Group', 'US'], + ['EVRG', 'Evergy', 'US'], + ['ES', 'Eversource Energy', 'US'], + ['EXC', 'Exelon', 'US'], + ['EXE', 'Expand Energy', 'US'], + ['EXPE', 'Expedia Group', 'US'], + ['EXPD', 'Expeditors International', 'US'], + ['EXR', 'Extra Space Storage', 'US'], + ['XOM', 'ExxonMobil', 'US'], + ['FFIV', 'F5, Inc.', 'US'], + ['FDS', 'FactSet', 'US'], + ['FICO', 'Fair Isaac', 'US'], + ['FAST', 'Fastenal', 'US'], + ['FRT', 'Federal Realty Investment Trust', 'US'], + ['FDX', 'FedEx', 'US'], + ['FDXF', 'FedEx Freight', 'US'], + ['FERG', 'Ferguson Enterprises', 'US'], + ['FIS', 'Fidelity National Information Services', 'US'], + ['FITB', 'Fifth Third Bancorp', 'US'], + ['FSLR', 'First Solar', 'US'], + ['FE', 'FirstEnergy', 'US'], + ['FISV', 'Fiserv', 'US'], + ['FLEX', 'Flex Ltd.', 'US'], + ['F', 'Ford Motor Company', 'US'], + ['FTNT', 'Fortinet', 'US'], + ['FTV', 'Fortive', 'US'], + ['FOXA', 'Fox Corporation (Class A)', 'US'], + ['FOX', 'Fox Corporation (Class B)', 'US'], + ['BEN', 'Franklin Resources', 'US'], + ['FCX', 'Freeport-McMoRan', 'US'], + ['GRMN', 'Garmin', 'US'], + ['IT', 'Gartner', 'US'], + ['GE', 'GE Aerospace', 'US'], + ['GEHC', 'GE HealthCare', 'US'], + ['GEV', 'GE Vernova', 'US'], + ['GEN', 'Gen Digital', 'US'], + ['GNRC', 'Generac', 'US'], + ['GD', 'General Dynamics', 'US'], + ['GIS', 'General Mills', 'US'], + ['GM', 'General Motors', 'US'], + ['GPC', 'Genuine Parts Company', 'US'], + ['GILD', 'Gilead Sciences', 'US'], + ['GPN', 'Global Payments', 'US'], + ['GL', 'Globe Life', 'US'], + ['GDDY', 'GoDaddy', 'US'], + ['GS', 'Goldman Sachs', 'US'], + ['HAL', 'Halliburton', 'US'], + ['HIG', 'Hartford (The)', 'US'], + ['HAS', 'Hasbro', 'US'], + ['HCA', 'HCA Healthcare', 'US'], + ['DOC', 'Healthpeak Properties', 'US'], + ['HSIC', 'Henry Schein', 'US'], + ['HSY', 'Hershey Company (The)', 'US'], + ['HPE', 'Hewlett Packard Enterprise', 'US'], + ['HLT', 'Hilton Worldwide', 'US'], + ['HD', 'Home Depot (The)', 'US'], + ['HONA', 'Honeywell Aerospace', 'US'], + ['HON', 'Honeywell Technologies', 'US'], + ['HRL', 'Hormel Foods', 'US'], + ['HST', 'Host Hotels & Resorts', 'US'], + ['HWM', 'Howmet Aerospace', 'US'], + ['HPQ', 'HP Inc.', 'US'], + ['HUBB', 'Hubbell Incorporated', 'US'], + ['HUM', 'Humana', 'US'], + ['HBAN', 'Huntington Bancshares', 'US'], + ['HII', 'Huntington Ingalls Industries', 'US'], + ['IBM', 'IBM', 'US'], + ['IEX', 'IDEX Corporation', 'US'], + ['IDXX', 'Idexx Laboratories', 'US'], + ['ITW', 'Illinois Tool Works', 'US'], + ['INCY', 'Incyte', 'US'], + ['IR', 'Ingersoll Rand', 'US'], + ['PODD', 'Insulet Corporation', 'US'], + ['INTC', 'Intel', 'US'], + ['IBKR', 'Interactive Brokers', 'US'], + ['ICE', 'Intercontinental Exchange', 'US'], + ['IFF', 'International Flavors & Fragrances', 'US'], + ['IP', 'International Paper', 'US'], + ['INTU', 'Intuit', 'US'], + ['ISRG', 'Intuitive Surgical', 'US'], + ['IVZ', 'Invesco', 'US'], + ['INVH', 'Invitation Homes', 'US'], + ['IQV', 'IQVIA', 'US'], + ['IRM', 'Iron Mountain', 'US'], + ['JBHT', 'J.B. Hunt', 'US'], + ['JBL', 'Jabil', 'US'], + ['JKHY', 'Jack Henry & Associates', 'US'], + ['J', 'Jacobs Solutions', 'US'], + ['JNJ', 'Johnson & Johnson', 'US'], + ['JCI', 'Johnson Controls', 'US'], + ['JPM', 'JPMorgan Chase', 'US'], + ['KVUE', 'Kenvue', 'US'], + ['KDP', 'Keurig Dr Pepper', 'US'], + ['KEY', 'KeyCorp', 'US'], + ['KEYS', 'Keysight Technologies', 'US'], + ['KMB', 'Kimberly-Clark', 'US'], + ['KIM', 'Kimco Realty', 'US'], + ['KMI', 'Kinder Morgan', 'US'], + ['KKR', 'KKR & Co.', 'US'], + ['KLAC', 'KLA Corporation', 'US'], + ['KHC', 'Kraft Heinz', 'US'], + ['KR', 'Kroger', 'US'], + ['LHX', 'L3Harris', 'US'], + ['LH', 'Labcorp', 'US'], + ['LRCX', 'Lam Research', 'US'], + ['LVS', 'Las Vegas Sands', 'US'], + ['LDOS', 'Leidos', 'US'], + ['LEN', 'Lennar', 'US'], + ['LII', 'Lennox International', 'US'], + ['LLY', 'Lilly (Eli)', 'US'], + ['LIN', 'Linde plc', 'US'], + ['LYV', 'Live Nation Entertainment', 'US'], + ['LMT', 'Lockheed Martin', 'US'], + ['L', 'Loews Corporation', 'US'], + ['LOW', "Lowe's", 'US'], + ['LULU', 'Lululemon Athletica', 'US'], + ['LITE', 'Lumentum', 'US'], + ['LYB', 'LyondellBasell', 'US'], + ['MTB', 'M&T Bank', 'US'], + ['MPC', 'Marathon Petroleum', 'US'], + ['MAR', 'Marriott International', 'US'], + ['MRSH', 'Marsh McLennan', 'US'], + ['MLM', 'Martin Marietta Materials', 'US'], + ['MRVL', 'Marvell Technology', 'US'], + ['MAS', 'Masco', 'US'], + ['MA', 'Mastercard', 'US'], + ['MKC', 'McCormick & Company', 'US'], + ['MCD', "McDonald's", 'US'], + ['MCK', 'McKesson Corporation', 'US'], + ['MDT', 'Medtronic', 'US'], + ['MRK', 'Merck & Co.', 'US'], + ['META', 'Meta Platforms', 'US'], + ['MET', 'MetLife', 'US'], + ['MTD', 'Mettler Toledo', 'US'], + ['MGM', 'MGM Resorts', 'US'], + ['MCHP', 'Microchip Technology', 'US'], + ['MU', 'Micron Technology', 'US'], + ['MSFT', 'Microsoft', 'US'], + ['MAA', 'Mid-America Apartment Communities', 'US'], + ['MRNA', 'Moderna', 'US'], + ['TAP', 'Molson Coors Beverage Company', 'US'], + ['MDLZ', 'Mondelez International', 'US'], + ['MPWR', 'Monolithic Power Systems', 'US'], + ['MNST', 'Monster Beverage', 'US'], + ['MCO', "Moody's Corporation", 'US'], + ['MS', 'Morgan Stanley', 'US'], + ['MOS', 'Mosaic Company (The)', 'US'], + ['MSI', 'Motorola Solutions', 'US'], + ['MSCI', 'MSCI', 'US'], + ['NDAQ', 'Nasdaq, Inc.', 'US'], + ['NTAP', 'NetApp', 'US'], + ['NFLX', 'Netflix', 'US'], + ['NEM', 'Newmont', 'US'], + ['NWSA', 'News Corp (Class A)', 'US'], + ['NWS', 'News Corp (Class B)', 'US'], + ['NEE', 'NextEra Energy', 'US'], + ['NKE', 'Nike, Inc.', 'US'], + ['NI', 'NiSource', 'US'], + ['NDSN', 'Nordson Corporation', 'US'], + ['NSC', 'Norfolk Southern', 'US'], + ['NTRS', 'Northern Trust', 'US'], + ['NOC', 'Northrop Grumman', 'US'], + ['NCLH', 'Norwegian Cruise Line Holdings', 'US'], + ['NRG', 'NRG Energy', 'US'], + ['NUE', 'Nucor', 'US'], + ['NVDA', 'Nvidia', 'US'], + ['NVR', 'NVR, Inc.', 'US'], + ['NXPI', 'NXP Semiconductors', 'US'], + ['ORLY', "O'Reilly Automotive", 'US'], + ['OXY', 'Occidental Petroleum', 'US'], + ['ODFL', 'Old Dominion', 'US'], + ['OMC', 'Omnicom Group', 'US'], + ['ON', 'ON Semiconductor', 'US'], + ['OKE', 'Oneok', 'US'], + ['ORCL', 'Oracle Corporation', 'US'], + ['OTIS', 'Otis Worldwide', 'US'], + ['PCAR', 'Paccar', 'US'], + ['PKG', 'Packaging Corporation of America', 'US'], + ['PLTR', 'Palantir Technologies', 'US'], + ['PANW', 'Palo Alto Networks', 'US'], + ['PSKY', 'Paramount Skydance Corporation', 'US'], + ['PH', 'Parker Hannifin', 'US'], + ['PAYX', 'Paychex', 'US'], + ['PYPL', 'PayPal', 'US'], + ['PNR', 'Pentair', 'US'], + ['PEP', 'PepsiCo', 'US'], + ['PFE', 'Pfizer', 'US'], + ['PCG', 'PG&E Corporation', 'US'], + ['PM', 'Philip Morris International', 'US'], + ['PSX', 'Phillips 66', 'US'], + ['PNW', 'Pinnacle West Capital', 'US'], + ['PNC', 'PNC Financial Services', 'US'], + ['PPG', 'PPG Industries', 'US'], + ['PPL', 'PPL Corporation', 'US'], + ['PFG', 'Principal Financial Group', 'US'], + ['PG', 'Procter & Gamble', 'US'], + ['PGR', 'Progressive Corporation', 'US'], + ['PLD', 'Prologis', 'US'], + ['PRU', 'Prudential Financial', 'US'], + ['PEG', 'Public Service Enterprise Group', 'US'], + ['PTC', 'PTC Inc.', 'US'], + ['PSA', 'Public Storage', 'US'], + ['PHM', 'PulteGroup', 'US'], + ['PWR', 'Quanta Services', 'US'], + ['QCOM', 'Qualcomm', 'US'], + ['DGX', 'Quest Diagnostics', 'US'], + ['Q', 'Qnity Electronics', 'US'], + ['RL', 'Ralph Lauren Corporation', 'US'], + ['RJF', 'Raymond James Financial', 'US'], + ['RTX', 'RTX Corporation', 'US'], + ['O', 'Realty Income', 'US'], + ['REG', 'Regency Centers', 'US'], + ['REGN', 'Regeneron Pharmaceuticals', 'US'], + ['RF', 'Regions Financial Corporation', 'US'], + ['RSG', 'Republic Services', 'US'], + ['RMD', 'ResMed|', 'US'], + ['RVTY', 'Revvity', 'US'], + ['HOOD', 'Robinhood Markets', 'US'], + ['ROK', 'Rockwell Automation', 'US'], + ['ROL', 'Rollins, Inc.', 'US'], + ['ROP', 'Roper Technologies', 'US'], + ['ROST', 'Ross Stores', 'US'], + ['RCL', 'Royal Caribbean Group', 'US'], + ['SPGI', 'S&P Global', 'US'], + ['CRM', 'Salesforce', 'US'], + ['SNDK', 'Sandisk', 'US'], + ['SBAC', 'SBA Communications', 'US'], + ['SLB', 'Schlumberger', 'US'], + ['STX', 'Seagate Technology', 'US'], + ['SRE', 'Sempra', 'US'], + ['NOW', 'ServiceNow', 'US'], + ['SHW', 'Sherwin-Williams', 'US'], + ['SPG', 'Simon Property Group', 'US'], + ['SWKS', 'Skyworks Solutions', 'US'], + ['SJM', 'J.M. Smucker Company (The)', 'US'], + ['SW', 'Smurfit Westrock', 'US'], + ['SNA', 'Snap-on', 'US'], + ['SOLV', 'Solventum', 'US'], + ['SO', 'Southern Company', 'US'], + ['LUV', 'Southwest Airlines', 'US'], + ['SWK', 'Stanley Black & Decker', 'US'], + ['SBUX', 'Starbucks', 'US'], + ['STT', 'State Street Corporation', 'US'], + ['STLD', 'Steel Dynamics', 'US'], + ['STE', 'Steris', 'US'], + ['SYK', 'Stryker Corporation', 'US'], + ['SMCI', 'Supermicro', 'US'], + ['SYF', 'Synchrony Financial', 'US'], + ['SNPS', 'Synopsys', 'US'], + ['SYY', 'Sysco', 'US'], + ['TMUS', 'T-Mobile US', 'US'], + ['TROW', 'T. Rowe Price', 'US'], + ['TTWO', 'Take-Two Interactive', 'US'], + ['TPR', 'Tapestry, Inc.', 'US'], + ['TRGP', 'Targa Resources', 'US'], + ['TGT', 'Target Corporation', 'US'], + ['TEL', 'TE Connectivity', 'US'], + ['TDY', 'Teledyne Technologies', 'US'], + ['TER', 'Teradyne', 'US'], + ['TSLA', 'Tesla, Inc.', 'US'], + ['TXN', 'Texas Instruments', 'US'], + ['TPL', 'Texas Pacific Land Corporation', 'US'], + ['TXT', 'Textron', 'US'], + ['TMO', 'Thermo Fisher Scientific', 'US'], + ['TJX', 'TJX Companies', 'US'], + ['TKO', 'TKO Group Holdings', 'US'], + ['TTD', 'Trade Desk (The)', 'US'], + ['TSCO', 'Tractor Supply', 'US'], + ['TT', 'Trane Technologies', 'US'], + ['TDG', 'TransDigm Group', 'US'], + ['TRV', 'Travelers Companies (The)', 'US'], + ['TRMB', 'Trimble Inc.', 'US'], + ['TFC', 'Truist Financial', 'US'], + ['TYL', 'Tyler Technologies', 'US'], + ['TSN', 'Tyson Foods', 'US'], + ['USB', 'U.S. Bancorp', 'US'], + ['UBER', 'Uber', 'US'], + ['UDR', 'UDR, Inc.', 'US'], + ['ULTA', 'Ulta Beauty', 'US'], + ['UNP', 'Union Pacific Corporation', 'US'], + ['UAL', 'United Airlines Holdings', 'US'], + ['UPS', 'United Parcel Service', 'US'], + ['URI', 'United Rentals', 'US'], + ['UNH', 'UnitedHealth Group', 'US'], + ['UHS', 'Universal Health Services', 'US'], + ['VLO', 'Valero Energy', 'US'], + ['VEEV', 'Veeva Systems', 'US'], + ['VTR', 'Ventas', 'US'], + ['VLTO', 'Veralto', 'US'], + ['VRSN', 'Verisign', 'US'], + ['VRSK', 'Verisk Analytics', 'US'], + ['VZ', 'Verizon', 'US'], + ['VRTX', 'Vertex Pharmaceuticals', 'US'], + ['VRT', 'Vertiv', 'US'], + ['VTRS', 'Viatris', 'US'], + ['VICI', 'Vici Properties', 'US'], + ['V', 'Visa Inc.', 'US'], + ['VST', 'Vistra Corp.', 'US'], + ['VMC', 'Vulcan Materials Company', 'US'], + ['WRB', 'W. R. Berkley Corporation', 'US'], + ['GWW', 'W. W. Grainger', 'US'], + ['WAB', 'Wabtec', 'US'], + ['WMT', 'Walmart', 'US'], + ['DIS', 'Walt Disney Company (The)', 'US'], + ['WBD', 'Warner Bros. Discovery', 'US'], + ['WM', 'Waste Management', 'US'], + ['WAT', 'Waters Corporation', 'US'], + ['WEC', 'WEC Energy Group', 'US'], + ['WFC', 'Wells Fargo', 'US'], + ['WELL', 'Welltower', 'US'], + ['WST', 'West Pharmaceutical Services', 'US'], + ['WDC', 'Western Digital', 'US'], + ['WY', 'Weyerhaeuser', 'US'], + ['WSM', 'Williams-Sonoma, Inc.', 'US'], + ['WMB', 'Williams Companies', 'US'], + ['WTW', 'Willis Towers Watson', 'US'], + ['WDAY', 'Workday, Inc.', 'US'], + ['WYNN', 'Wynn Resorts', 'US'], + ['XEL', 'Xcel Energy', 'US'], + ['XYL', 'Xylem Inc.', 'US'], + ['YUM', 'Yum! Brands', 'US'], + ['ZBRA', 'Zebra Technologies', 'US'], + ['ZBH', 'Zimmer Biomet', 'US'], + ['ZTS', 'Zoetis', 'US'], +]) + +/** + * Representative liquid international listings used to diversify the fixture. + * Symbols use their local-market form and the third tuple value is an ISO-style + * country/market code, rather than a trading currency or exchange MIC. + * + * References checked 2026-08-15: STOXX Europe 50, KRX KOSPI market, + * JPX TOPIX Core30, and HKEX index constituent materials. + */ +const europeanInstruments = Object.freeze([ + ['ASML', 'ASML Holding', 'NL'], + ['INGA', 'ING Group', 'NL'], + ['ADYEN', 'Adyen', 'NL'], + ['PHIA', 'Philips', 'NL'], + ['HEIA', 'Heineken', 'NL'], + ['SAP', 'SAP', 'DE'], + ['SIE', 'Siemens', 'DE'], + ['ALV', 'Allianz', 'DE'], + ['DTE', 'Deutsche Telekom', 'DE'], + ['MBG', 'Mercedes-Benz Group', 'DE'], + ['BMW', 'BMW', 'DE'], + ['BAS', 'BASF', 'DE'], + ['MUV2', 'Munich Re', 'DE'], + ['VOW3', 'Volkswagen Preference', 'DE'], + ['IFX', 'Infineon Technologies', 'DE'], + ['MC', 'LVMH', 'FR'], + ['OR', "L'Oréal", 'FR'], + ['AIR', 'Airbus', 'FR'], + ['SU', 'Schneider Electric', 'FR'], + ['TTE', 'TotalEnergies', 'FR'], + ['SAN', 'Sanofi', 'FR'], + ['BNP', 'BNP Paribas', 'FR'], + ['CS', 'AXA', 'FR'], + ['DG', 'Vinci', 'FR'], + ['ENEL', 'Enel', 'IT'], + ['ENI', 'Eni', 'IT'], + ['ISP', 'Intesa Sanpaolo', 'IT'], + ['UCG', 'UniCredit', 'IT'], + ['STLAM', 'Stellantis', 'IT'], + ['SAN', 'Banco Santander', 'ES'], + ['IBE', 'Iberdrola', 'ES'], + ['ITX', 'Inditex', 'ES'], + ['BBVA', 'BBVA', 'ES'], + ['NESN', 'Nestlé', 'CH'], + ['ROG', 'Roche Holding', 'CH'], + ['NOVN', 'Novartis', 'CH'], + ['UBSG', 'UBS Group', 'CH'], + ['NOVO-B', 'Novo Nordisk', 'DK'], + ['MAERSK-B', 'A.P. Moller - Maersk', 'DK'], + ['VOLV-B', 'Volvo', 'SE'], + ['ERIC-B', 'Ericsson', 'SE'], + ['NOKIA', 'Nokia', 'FI'], + ['SHEL', 'Shell', 'GB'], + ['AZN', 'AstraZeneca', 'GB'], + ['HSBA', 'HSBC Holdings', 'GB'], + ['ULVR', 'Unilever', 'GB'], + ['LSEG', 'London Stock Exchange Group', 'GB'], +]) + +const europeanMarketCodes = Object.freeze([ + 'NL', + 'DE', + 'FR', + 'IT', + 'ES', + 'CH', + 'DK', + 'SE', + 'FI', + 'GB', +]) + +const europeanMarketGroups = Object.freeze( + europeanMarketCodes.map((market) => + europeanInstruments.filter(([, , instrumentMarket]) => + Object.is(instrumentMarket, market), + ), + ), +) + +const interleavedEuropeanInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...europeanMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + europeanMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const southKoreanInstruments = Object.freeze([ + ['005930', 'Samsung Electronics', 'KR'], + ['000660', 'SK hynix', 'KR'], + ['373220', 'LG Energy Solution', 'KR'], + ['207940', 'Samsung Biologics', 'KR'], + ['005380', 'Hyundai Motor', 'KR'], + ['000270', 'Kia', 'KR'], + ['068270', 'Celltrion', 'KR'], + ['105560', 'KB Financial Group', 'KR'], + ['055550', 'Shinhan Financial Group', 'KR'], + ['035420', 'NAVER', 'KR'], + ['035720', 'Kakao', 'KR'], + ['006400', 'Samsung SDI', 'KR'], + ['051910', 'LG Chem', 'KR'], + ['012330', 'Hyundai Mobis', 'KR'], + ['066570', 'LG Electronics', 'KR'], +]) + +const japaneseInstruments = Object.freeze([ + ['8306', 'Mitsubishi UFJ Financial Group', 'JP'], + ['7203', 'Toyota Motor', 'JP'], + ['6501', 'Hitachi', 'JP'], + ['8316', 'Sumitomo Mitsui Financial Group', 'JP'], + ['6758', 'Sony Group', 'JP'], + ['8058', 'Mitsubishi Corporation', 'JP'], + ['9984', 'SoftBank Group', 'JP'], + ['8035', 'Tokyo Electron', 'JP'], + ['8411', 'Mizuho Financial Group', 'JP'], + ['8031', 'Mitsui & Co.', 'JP'], + ['6861', 'Keyence', 'JP'], + ['7974', 'Nintendo', 'JP'], + ['6098', 'Recruit Holdings', 'JP'], + ['9432', 'Nippon Telegraph and Telephone', 'JP'], + ['4063', 'Shin-Etsu Chemical', 'JP'], +]) + +const hongKongInstruments = Object.freeze([ + ['0700', 'Tencent Holdings', 'HK'], + ['9988', 'Alibaba Group', 'HK'], + ['1810', 'Xiaomi', 'HK'], + ['3690', 'Meituan', 'HK'], + ['0941', 'China Mobile', 'HK'], + ['1211', 'BYD Company', 'HK'], + ['1299', 'AIA Group', 'HK'], + ['0388', 'Hong Kong Exchanges and Clearing', 'HK'], + ['0005', 'HSBC Holdings', 'HK'], + ['2318', 'Ping An Insurance', 'HK'], +]) + +const canadianInstruments = Object.freeze([ + ['RY', 'Royal Bank of Canada', 'CA'], + ['TD', 'Toronto-Dominion Bank', 'CA'], + ['SHOP', 'Shopify', 'CA'], + ['ENB', 'Enbridge', 'CA'], + ['CNR', 'Canadian National Railway', 'CA'], + ['CP', 'Canadian Pacific Kansas City', 'CA'], + ['BMO', 'Bank of Montreal', 'CA'], + ['CSU', 'Constellation Software', 'CA'], +]) + +const australianInstruments = Object.freeze([ + ['BHP', 'BHP Group', 'AU'], + ['CBA', 'Commonwealth Bank of Australia', 'AU'], + ['CSL', 'CSL', 'AU'], + ['NAB', 'National Australia Bank', 'AU'], + ['WBC', 'Westpac Banking Corporation', 'AU'], + ['ANZ', 'ANZ Group Holdings', 'AU'], + ['WES', 'Wesfarmers', 'AU'], + ['MQG', 'Macquarie Group', 'AU'], +]) + +const internationalMarketGroups = Object.freeze([ + interleavedEuropeanInstruments, + southKoreanInstruments, + japaneseInstruments, + hongKongInstruments, + canadianInstruments, + australianInstruments, +]) + +export const internationalInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...internationalMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + internationalMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const INTERNATIONAL_INSERTION_INTERVAL = 3 + +/** + * U.S. and international instruments are interleaved so ordinary benchmark + * sizes exercise multiple symbol formats and market labels. + */ +export const globalInstruments = Object.freeze( + marketInstruments.flatMap((instrument, index) => { + const internationalInstrument = + index % INTERNATIONAL_INSERTION_INTERVAL === 0 + ? internationalInstruments[index / INTERNATIONAL_INSERTION_INTERVAL] + : undefined + + return internationalInstrument + ? [instrument, internationalInstrument] + : [instrument] + }), +) as unknown as ReadonlyArray diff --git a/examples/angular/realtime-trading/src/app/feed/worker/market-feed-engine.ts b/examples/angular/realtime-trading/src/app/feed/worker/market-feed-engine.ts new file mode 100644 index 0000000000..86a68e2f64 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/feed/worker/market-feed-engine.ts @@ -0,0 +1,177 @@ +import { globalInstruments } from '../market-instruments' +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const INITIAL_MARKET_SEED = 0x4d41524b +const LIVE_FEED_SEED = 0x5449434b + +export class MarketFeedEngine { + #quotes: Array = [] + #lastHistorySampledAt = new Uint32Array(0) + #random = createRandom(2_026) + #rowCursor = 0 + #tickIndex = 0 + + reset(count: number): Array { + const random = createRandom(INITIAL_MARKET_SEED ^ count) + const createdAt = Date.now() + + this.#quotes = Array.from({ length: count }, (_, index) => { + const [baseSymbol, company, market] = + globalInstruments[index % globalInstruments.length] + const series = Math.floor(index / globalInstruments.length) + const symbol = series === 0 ? baseSymbol : `${baseSymbol}${series}` + const previousClose = roundPrice(20 + random() * 480) + const open = roundPrice(previousClose * (1 + (random() - 0.5) * 0.016)) + const spread = Math.max(0.01, open * (0.0002 + random() * 0.0004)) + const history = Array.from({ length: 24 }, (_, historyIndex) => + roundPrice( + open * + (1 + Math.sin(historyIndex / 4) * 0.002 + (random() - 0.5) * 0.001), + ), + ) + const volume = Math.floor(50_000 + random() * 2_000_000) + const lastSize = Math.floor(10 + random() * 5_000) + + return { + id: `instrument-${index}`, + symbol, + company, + venue: market, + previousClose, + open, + high: open, + low: open, + price: open, + bid: roundPrice(open - spread / 2), + ask: roundPrice(open + spread / 2), + bidSize: Math.floor(100 + random() * 25_000), + askSize: Math.floor(100 + random() * 25_000), + lastSize, + lastMove: 0, + lastUpdatedAt: createdAt, + volume, + turnover: roundMoney(open * volume), + history, + } + }) + + this.#random = createRandom(LIVE_FEED_SEED ^ count) + this.#rowCursor = 0 + this.#lastHistorySampledAt = new Uint32Array(count) + this.#lastHistorySampledAt.fill(createdAt >>> 0) + + return this.#quotes.map((quote) => ({ + ...quote, + history: [...quote.history], + })) + } + + applyTicks( + tickCount: number, + updateSparklines: boolean, + sparklineSampleIntervalMs: number, + ): Array { + if (this.#quotes.length === 0 || tickCount <= 0) return [] + + const updatedAt = Date.now() + const sampledAt = updatedAt >>> 0 + const sampleIntervalMs = Math.max(16, sparklineSampleIntervalMs) + const updatedQuotes = new Map() + const stride = 97 + + this.#tickIndex = 0 + while (this.#tickIndex < tickCount) { + this.#rowCursor = (this.#rowCursor + stride) % this.#quotes.length + const quote = this.#quotes[this.#rowCursor] + const lastSampledAt = this.#lastHistorySampledAt[this.#rowCursor] + const shouldUpdateHistory = + updateSparklines && + (sampledAt - lastSampledAt) >>> 0 >= sampleIntervalMs + + if (shouldUpdateHistory) { + this.#lastHistorySampledAt[this.#rowCursor] = sampledAt + } + + this.#applyTick(quote, shouldUpdateHistory, updatedAt) + + const previousUpdate = updatedQuotes.get(this.#rowCursor) + updatedQuotes.set(this.#rowCursor, { + index: this.#rowCursor, + price: quote.price, + bid: quote.bid, + ask: quote.ask, + bidSize: quote.bidSize, + askSize: quote.askSize, + lastSize: quote.lastSize, + lastMove: quote.lastMove, + lastUpdatedAt: quote.lastUpdatedAt, + high: quote.high, + low: quote.low, + volume: quote.volume, + turnover: quote.turnover, + ...(shouldUpdateHistory || previousUpdate?.history + ? { history: [...quote.history] } + : {}), + }) + this.#tickIndex++ + } + + return [...updatedQuotes.values()] + } + + #applyTick( + quote: MarketQuoteSnapshot, + updateHistory: boolean, + updatedAt: number, + ): void { + const previousPrice = quote.price + const volatility = 0.00015 + this.#random() * 0.0012 + const move = previousPrice * (this.#random() - 0.495) * volatility + const nextPrice = roundPrice(Math.max(0.1, previousPrice + move)) + const spread = Math.max( + 0.01, + nextPrice * (0.00015 + this.#random() * 0.0005), + ) + + quote.lastMove = nextPrice - previousPrice + quote.price = nextPrice + quote.high = Math.max(quote.high, nextPrice) + quote.low = Math.min(quote.low, nextPrice) + quote.bid = roundPrice(nextPrice - spread / 2) + quote.ask = roundPrice(nextPrice + spread / 2) + quote.bidSize = Math.floor(100 + this.#random() * 25_000) + quote.askSize = Math.floor(100 + this.#random() * 25_000) + quote.lastSize = Math.floor(10 + this.#random() * 5_000) + quote.lastUpdatedAt = updatedAt + quote.volume += quote.lastSize + quote.turnover = roundMoney(quote.turnover + nextPrice * quote.lastSize) + + if (updateHistory) { + quote.history = [...quote.history.slice(-23), nextPrice] + } + } +} + +function createRandom(seed: number): () => number { + const runtime = { state: seed >>> 0 } + return () => { + runtime.state += 0x6d2b79f5 + const stateValue = runtime.state + const firstMix = Math.imul(stateValue ^ (stateValue >>> 15), stateValue | 1) + const secondMix = + firstMix + Math.imul(firstMix ^ (firstMix >>> 7), firstMix | 61) + const value = firstMix ^ secondMix + return ((value ^ (value >>> 14)) >>> 0) / 4_294_967_296 + } +} + +function roundPrice(value: number): number { + return Math.round(value * 100) / 100 +} + +function roundMoney(value: number): number { + return Math.round(value * 100) / 100 +} diff --git a/examples/angular/realtime-trading/src/app/feed/worker/market-feed-protocol.ts b/examples/angular/realtime-trading/src/app/feed/worker/market-feed-protocol.ts new file mode 100644 index 0000000000..21997ec89c --- /dev/null +++ b/examples/angular/realtime-trading/src/app/feed/worker/market-feed-protocol.ts @@ -0,0 +1,70 @@ +export interface MarketQuoteSnapshot { + id: string + symbol: string + company: string + venue: string + previousClose: number + open: number + high: number + low: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + volume: number + turnover: number + history: Array +} + +export interface MarketQuoteUpdate { + index: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + high: number + low: number + volume: number + turnover: number + history?: Array +} + +export type MarketFeedCommand = + | { + type: 'start' + rowCount: number + running: boolean + ticksPerSecond: number + publishIntervalMs: number + updateSparklines: boolean + sparklineSampleIntervalMs: number + } + | { type: 'set-running'; running: boolean } + | { type: 'set-rate'; ticksPerSecond: number } + | { type: 'set-publish-interval'; intervalMs: number } + | { type: 'set-sparklines'; enabled: boolean } + | { type: 'set-sparkline-interval'; intervalMs: number } + | { type: 'reset'; rowCount: number } + | { type: 'burst'; tickCount: number } + +export type MarketFeedEvent = + | { + type: 'snapshot' + sessionId: number + quotes: Array + } + | { + type: 'updates' + sessionId: number + tickCount: number + coalescedUpdateCount: number + updates: Array + } diff --git a/examples/angular/realtime-trading/src/app/feed/worker/market-feed.worker.ts b/examples/angular/realtime-trading/src/app/feed/worker/market-feed.worker.ts new file mode 100644 index 0000000000..2b7a642fd9 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/feed/worker/market-feed.worker.ts @@ -0,0 +1,143 @@ +import { initialMarketFeedConfig } from '../market-feed-config' +import { MarketFeedEngine } from './market-feed-engine' +import type { + MarketFeedCommand, + MarketFeedEvent, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const engine = new MarketFeedEngine() +const pendingUpdates = new Map() +const runtime = { + sessionId: 0, + pendingTickCount: 0, + pendingCoalescedUpdateCount: 0, + initialized: false, + running: true, + ticksPerSecond: initialMarketFeedConfig.targetSamplesPerSecond, + publishIntervalMs: initialMarketFeedConfig.publishIntervalMs, + publishTimerId: null as ReturnType | null, + updateSparklines: initialMarketFeedConfig.updateSparklines, + sparklineSampleIntervalMs: initialMarketFeedConfig.sparklineSampleIntervalMs, + tickBudget: 0, + lastTickAt: performance.now(), +} + +addEventListener('message', ({ data }: MessageEvent) => { + switch (data.type) { + case 'start': + runtime.running = data.running + runtime.ticksPerSecond = data.ticksPerSecond + runtime.publishIntervalMs = data.publishIntervalMs + runtime.updateSparklines = data.updateSparklines + runtime.sparklineSampleIntervalMs = data.sparklineSampleIntervalMs + restartPublishTimer() + reset(data.rowCount) + break + case 'set-running': + runtime.running = data.running + break + case 'set-rate': + runtime.ticksPerSecond = data.ticksPerSecond + break + case 'set-publish-interval': + runtime.publishIntervalMs = Math.max(4, data.intervalMs) + restartPublishTimer() + break + case 'set-sparklines': + runtime.updateSparklines = data.enabled + break + case 'set-sparkline-interval': + runtime.sparklineSampleIntervalMs = Math.max(16, data.intervalMs) + break + case 'reset': + reset(data.rowCount) + break + case 'burst': + produceTicks(data.tickCount) + flush() + break + } +}) + +setInterval(() => { + const now = performance.now() + const elapsed = Math.min(100, Math.max(0, now - runtime.lastTickAt)) + runtime.lastTickAt = now + + if (runtime.initialized && runtime.running) { + runtime.tickBudget += (runtime.ticksPerSecond * elapsed) / 1_000 + const tickCount = Math.floor(runtime.tickBudget) + runtime.tickBudget -= tickCount + produceTicks(tickCount) + } +}, 16) + +restartPublishTimer() + +function reset(rowCount: number): void { + runtime.initialized = true + runtime.sessionId++ + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + runtime.tickBudget = 0 + runtime.lastTickAt = performance.now() + + post({ + type: 'snapshot', + sessionId: runtime.sessionId, + quotes: engine.reset(rowCount), + }) +} + +function produceTicks(tickCount: number): void { + if (!runtime.initialized || tickCount <= 0) return + + runtime.pendingTickCount += tickCount + for (const update of engine.applyTicks( + tickCount, + runtime.updateSparklines, + runtime.sparklineSampleIntervalMs, + )) { + const previousUpdate = pendingUpdates.get(update.index) + if (previousUpdate) runtime.pendingCoalescedUpdateCount++ + pendingUpdates.set(update.index, { + ...update, + ...(update.history || !previousUpdate?.history + ? {} + : { history: previousUpdate.history }), + }) + } +} + +function flush(): void { + if (runtime.pendingTickCount === 0) return + + const message: MarketFeedEvent = { + type: 'updates', + sessionId: runtime.sessionId, + tickCount: runtime.pendingTickCount, + coalescedUpdateCount: runtime.pendingCoalescedUpdateCount, + updates: [...pendingUpdates.values()], + } + + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + post(message) +} + +function restartPublishTimer(): void { + if (runtime.publishTimerId !== null) { + clearInterval(runtime.publishTimerId) + } + runtime.publishTimerId = setInterval( + flush, + Math.max(4, runtime.publishIntervalMs), + ) +} + +function post(event: MarketFeedEvent): void { + postMessage(event) +} diff --git a/examples/angular/realtime-trading/src/app/shell/configurator-options.ts b/examples/angular/realtime-trading/src/app/shell/configurator-options.ts new file mode 100644 index 0000000000..49a9566fe7 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/shell/configurator-options.ts @@ -0,0 +1,55 @@ +export interface ConfiguratorOption { + readonly label: string + readonly value: TValue +} + +const instrumentCountOptions = [ + { label: '50', value: 50 }, + { label: '100', value: 100 }, + { label: '150', value: 150 }, + { label: '250', value: 250 }, + { label: '350', value: 350 }, + { label: '500', value: 500 }, + { label: '750', value: 750 }, + { label: '1,000', value: 1_000 }, + { label: '1,500', value: 1_500 }, + { label: '2,500', value: 2_500 }, + { label: '5,000', value: 5_000 }, + { label: '1,000,000', value: 1_000_000 }, + { label: '10,000,000', value: 10_000_000 }, +] as const satisfies ReadonlyArray> + +const workerDeliveryOptions = [ + { label: '8 ms · 125 msg/s', value: 8 }, + { label: '16 ms · 62.5 msg/s', value: 16 }, + { label: '20 ms · 50 msg/s', value: 20 }, + { label: '33 ms · 30 msg/s', value: 33 }, + { label: '50 ms · 20 msg/s', value: 50 }, + { label: '100 ms · 10 msg/s', value: 100 }, + { label: '250 ms · 4 msg/s', value: 250 }, + { label: '500 ms · 2 msg/s', value: 500 }, + { label: '1,000 ms · 1 msg/s', value: 1_000 }, +] as const satisfies ReadonlyArray> + +const rowRenderingOptions = [ + { label: 'Full DOM · render every row', value: 'none' }, + { label: 'TanStack Virtual · visible rows only', value: 'tanstack' }, +] as const satisfies ReadonlyArray> + +const intradaySamplingOptions = [ + { label: '16 ms · fastest', value: 16 }, + { label: '33 ms · very fast', value: 33 }, + { label: '50 ms · fast', value: 50 }, + { label: '100 ms', value: 100 }, + { label: '250 ms', value: 250 }, + { label: '500 ms', value: 500 }, + { label: '1,000 ms', value: 1_000 }, + { label: '2,000 ms', value: 2_000 }, +] as const satisfies ReadonlyArray> + +export const configuratorOptions = { + instrumentCounts: instrumentCountOptions, + workerDeliveryIntervals: workerDeliveryOptions, + rowRenderingModes: rowRenderingOptions, + intradaySamplingIntervals: intradaySamplingOptions, +} as const diff --git a/examples/angular/realtime-trading/src/app/shell/configurator.html b/examples/angular/realtime-trading/src/app/shell/configurator.html new file mode 100644 index 0000000000..7b2ae6a228 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/shell/configurator.html @@ -0,0 +1,183 @@ + diff --git a/examples/angular/realtime-trading/src/app/shell/configurator.ts b/examples/angular/realtime-trading/src/app/shell/configurator.ts new file mode 100644 index 0000000000..83f8ab41b9 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/shell/configurator.ts @@ -0,0 +1,52 @@ +import { ChangeDetectionStrategy, Component, inject } from '@angular/core' +import { TradingBenchmarkController } from '../benchmark/trading-benchmark.controller' +import { + feedSampleRateAt, + feedSampleRateIndex, + feedSampleRateOptions, +} from '../feed/feed-sample-rates' +import { MarketFeedService } from '../feed/market-feed.service' +import { configuratorOptions } from './configurator-options' +import { Diagnostics } from './diagnostics' +import { MetricsStrip } from './metrics-strip' +import { SelectedInstrument } from './selected-instrument' +import { + formatRate, + inputChecked, + inputValue, + selectValue, +} from './shell-formatters' + +@Component({ + selector: 'app-configurator', + imports: [Diagnostics, MetricsStrip, SelectedInstrument], + templateUrl: './configurator.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class Configurator { + readonly controller = inject(TradingBenchmarkController) + readonly feed = inject(MarketFeedService) + readonly formatRate = formatRate + readonly options = configuratorOptions + readonly sampleRateOptions = feedSampleRateOptions + readonly sampleRateIndex = feedSampleRateIndex + + readonly setRowCount = (event: Event) => { + this.controller.resetViewState() + this.feed.setInstrumentCount(Number(selectValue(event))) + } + readonly setTargetRate = (event: Event) => + this.feed.setTargetRate(feedSampleRateAt(Number(inputValue(event)))) + readonly setPublishInterval = (event: Event) => + this.feed.setPublishInterval(Number(selectValue(event))) + readonly setRendererMode = (event: Event) => + this.controller.setRendererMode(inputChecked(event)) + readonly setTableWorkerEnabled = (event: Event) => + this.controller.setTableWorkerEnabled(inputChecked(event)) + readonly setVirtualScrollMode = (event: Event) => + this.controller.setVirtualScrollEnabled(selectValue(event) === 'tanstack') + readonly setSparklineUpdates = (event: Event) => + this.feed.setSparklineUpdates(inputChecked(event)) + readonly setSparklineSampleInterval = (event: Event) => + this.feed.setSparklineSampleInterval(Number(selectValue(event))) +} diff --git a/examples/angular/realtime-trading/src/app/shell/diagnostics.ts b/examples/angular/realtime-trading/src/app/shell/diagnostics.ts new file mode 100644 index 0000000000..0817db8c2b --- /dev/null +++ b/examples/angular/realtime-trading/src/app/shell/diagnostics.ts @@ -0,0 +1,134 @@ +import { ChangeDetectionStrategy, Component, inject } from '@angular/core' +import { TradingBenchmarkController } from '../benchmark/trading-benchmark.controller' +import { formatInteger, formatRate } from './shell-formatters' + +@Component({ + selector: 'app-diagnostics', + template: ` +
+

DIAGNOSTICS

+
+
+
Rendered rows / source
+
+ {{ formatInteger(controller.renderedRowCount()) }} / + {{ formatInteger(controller.displayQuotes().length) }} +
+
+
+
Mounted cell hosts
+
{{ formatInteger(controller.mountedCells()) }}
+
+
+
Live components
+
{{ formatInteger(controller.liveComponents()) }}
+
+
+
Created / destroyed
+
+ {{ formatInteger(controller.metrics().componentsCreated) }} / + {{ formatInteger(controller.metrics().componentsDestroyed) }} +
+
+
+
Worker samples / s
+
+ {{ formatRate(controller.metrics().actualTicksPerSecond) }} +
+
+
+
Worker messages / s
+
+ {{ controller.metrics().workerMessagesPerSecond.toFixed(1) }} +
+
+
+
Changed rows / s
+
+ {{ formatRate(controller.metrics().rowUpdatesPerSecond) }} +
+
+
+
State snapshots / s
+
+ {{ controller.metrics().stateApplicationsPerSecond.toFixed(1) }} +
+
+
+
Table DOM commits / s
+
+ {{ controller.metrics().tableRendersPerSecond.toFixed(1) }} +
+
+
+
P95 / max commit latency (rolling 10 s)
+
+ {{ controller.metrics().p95RenderMs.toFixed(2) }} ms / + {{ controller.metrics().maxRenderMs.toFixed(2) }} ms +
+
+
+
Worker messages since reset
+
+ {{ formatInteger(controller.metrics().workerMessages) }} +
+
+
+
Worker-coalesced updates / s
+
+ {{ formatRate(controller.metrics().supersededUpdatesPerSecond) }} +
+
+
+
Last message samples / updated rows
+
+ {{ formatInteger(controller.metrics().lastBatchSize) }} / + {{ formatInteger(controller.metrics().lastUpdateCount) }} +
+
+
+
Commits > 16.7 ms since reset
+
{{ controller.metrics().slowRenders }}
+
+
+
Observed MutationRecords / s
+
+ {{ formatRate(controller.metrics().domMutationsPerSecond) }} +
+
+
+
Long animation frames
+
+ {{ + controller.longAnimationFramesSupported + ? formatInteger(controller.metrics().longAnimationFrames) + : 'Unsupported' + }} +
+
+
+
JS heap (GC-sensitive)
+
+ {{ + controller.metrics().heapMb === null + ? 'N/A' + : controller.metrics().heapMb!.toFixed(1) + ' MB' + }} +
+
+
+

+ MutationObserver counts delivered records, not individual DOM + operations, and adds profiling overhead. Only class/style attributes, + text, and child-list changes are observed. Heap is a Chromium-only + point-in-time value and can move before garbage collection. +

+
+ `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class Diagnostics { + readonly controller = inject(TradingBenchmarkController) + readonly formatInteger = formatInteger + readonly formatRate = formatRate +} diff --git a/examples/angular/realtime-trading/src/app/shell/market-statusbar.ts b/examples/angular/realtime-trading/src/app/shell/market-statusbar.ts new file mode 100644 index 0000000000..e092b39875 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/shell/market-statusbar.ts @@ -0,0 +1,36 @@ +import { ChangeDetectionStrategy, Component, inject } from '@angular/core' +import { TradingBenchmarkController } from '../benchmark/trading-benchmark.controller' +import { formatInteger } from './shell-formatters' + +@Component({ + selector: 'app-market-statusbar', + template: ` +
+ + MESSAGE SAMPLES + + {{ formatInteger(controller.metrics().lastBatchSize) }} + + + + CHANGED ROWS + + {{ formatInteger(controller.metrics().lastUpdateCount) }} + + + + CELL HOSTS + {{ formatInteger(controller.mountedCells()) }} + + + COMPONENTS + {{ formatInteger(controller.liveComponents()) }} + +
+ `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class MarketStatusbar { + readonly controller = inject(TradingBenchmarkController) + readonly formatInteger = formatInteger +} diff --git a/examples/angular/realtime-trading/src/app/shell/metrics-strip.ts b/examples/angular/realtime-trading/src/app/shell/metrics-strip.ts new file mode 100644 index 0000000000..7e92dddac0 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/shell/metrics-strip.ts @@ -0,0 +1,60 @@ +import { ChangeDetectionStrategy, Component, inject } from '@angular/core' +import { TradingBenchmarkController } from '../benchmark/trading-benchmark.controller' +import { formatMs, formatRate } from './shell-formatters' + +@Component({ + selector: 'app-metrics-strip', + template: ` +
+

LIVE HEALTH

+
+ FRAME RATE (EST.) + + {{ controller.metrics().rafCallbacksPerSecond.toFixed(1) }} + + rAF callbacks/s · rolling 1 s +
+
+ AVG COMMIT + + {{ formatMs(controller.metrics().averageRenderMs) }} + + snapshot → DOM · rolling 3 s +
+
+ LONG FRAMES + @if (controller.longAnimationFramesSupported) { + + {{ controller.metrics().longAnimationFrames }} + + + since reset · worst + {{ formatMs(controller.metrics().worstLongAnimationFrameMs) }} + + } @else { + N/A + unsupported + } +
+
+ THROUGHPUT + + {{ formatRate(controller.metrics().rowUpdatesPerSecond) }} rows/s + + + {{ controller.metrics().stateApplicationsPerSecond.toFixed(1) }} + snapshots/s · rows deduplicated per snapshot + +
+
+ `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class MetricsStrip { + readonly controller = inject(TradingBenchmarkController) + readonly formatMs = formatMs + readonly formatRate = formatRate +} diff --git a/examples/angular/realtime-trading/src/app/shell/selected-instrument.ts b/examples/angular/realtime-trading/src/app/shell/selected-instrument.ts new file mode 100644 index 0000000000..bd537d13ba --- /dev/null +++ b/examples/angular/realtime-trading/src/app/shell/selected-instrument.ts @@ -0,0 +1,41 @@ +import { ChangeDetectionStrategy, Component, inject } from '@angular/core' +import { TradingBenchmarkController } from '../benchmark/trading-benchmark.controller' + +@Component({ + selector: 'app-selected-instrument', + template: ` +
+

SELECTED INSTRUMENT

+ @if (controller.selectedQuote(); as quote) { +
+
+ {{ quote.symbol }} + {{ quote.company }} +
+ {{ quote.venue }} +
+
+
+
Last
+
{{ quote.price.toFixed(2) }}
+
+
+
Bid / ask
+
{{ quote.bid.toFixed(2) }} / {{ quote.ask.toFixed(2) }}
+
+
+ } @else { +

+ Click or begin a cell selection in any row to inspect its instrument. +

+ } +
+ `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class SelectedInstrument { + readonly controller = inject(TradingBenchmarkController) +} diff --git a/examples/angular/realtime-trading/src/app/shell/shell-formatters.ts b/examples/angular/realtime-trading/src/app/shell/shell-formatters.ts new file mode 100644 index 0000000000..5526e66d53 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/shell/shell-formatters.ts @@ -0,0 +1,19 @@ +const integerFormatter = new Intl.NumberFormat('en-US', { + maximumFractionDigits: 0, +}) +const rateFormatter = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) + +export const formatInteger = (value: number): string => + integerFormatter.format(value) +export const formatRate = (value: number): string => rateFormatter.format(value) +export const formatMs = (value: number): string => `${value.toFixed(2)} ms` + +export const selectValue = (event: Event): string => + (event.target as HTMLSelectElement).value +export const inputValue = (event: Event): string => + (event.target as HTMLInputElement).value +export const inputChecked = (event: Event): boolean => + (event.target as HTMLInputElement).checked diff --git a/examples/angular/realtime-trading/src/app/shell/shell-header.ts b/examples/angular/realtime-trading/src/app/shell/shell-header.ts new file mode 100644 index 0000000000..0398004644 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/shell/shell-header.ts @@ -0,0 +1,59 @@ +import { + ChangeDetectionStrategy, + Component, + inject, + input, + output, +} from '@angular/core' +import { MarketFeedService } from '../feed/market-feed.service' + +@Component({ + selector: 'app-shell-header', + template: ` +
+
+ MARKET MONITOR +
+
+ + + {{ + !feed.workerReady() + ? 'FEED CONNECTING' + : feed.running() + ? 'FEED LIVE' + : 'FEED PAUSED' + }} + + +
+
+ `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ShellHeader { + readonly feed = inject(MarketFeedService) + readonly sidebarOpen = input.required() + readonly sidebarToggle = output() +} diff --git a/examples/angular/realtime-trading/src/app/shell/trading-shell.html b/examples/angular/realtime-trading/src/app/shell/trading-shell.html new file mode 100644 index 0000000000..ddce4e567d --- /dev/null +++ b/examples/angular/realtime-trading/src/app/shell/trading-shell.html @@ -0,0 +1,20 @@ +
+
+ + + @if (devMode) { + + } +
+ +
+ +
+ + + +
diff --git a/examples/angular/realtime-trading/src/app/shell/trading-shell.ts b/examples/angular/realtime-trading/src/app/shell/trading-shell.ts new file mode 100644 index 0000000000..02ffb4850f --- /dev/null +++ b/examples/angular/realtime-trading/src/app/shell/trading-shell.ts @@ -0,0 +1,22 @@ +import { + ChangeDetectionStrategy, + Component, + inject, + signal, +} from '@angular/core' +import { TradingBenchmarkController } from '../benchmark/trading-benchmark.controller' +import { Configurator } from './configurator' +import { MarketStatusbar } from './market-statusbar' +import { ShellHeader } from './shell-header' + +@Component({ + selector: 'app-trading-shell', + imports: [Configurator, MarketStatusbar, ShellHeader], + templateUrl: './trading-shell.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class TradingShell { + readonly devMode = inject(TradingBenchmarkController).devMode + readonly sidebarOpen = signal(true) + readonly toggleSidebar = () => this.sidebarOpen.update((open) => !open) +} diff --git a/examples/angular/realtime-trading/src/app/table/current-trading-table.ts b/examples/angular/realtime-trading/src/app/table/current-trading-table.ts new file mode 100644 index 0000000000..5afdc6d03e --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/current-trading-table.ts @@ -0,0 +1,98 @@ +import { + ChangeDetectionStrategy, + Component, + computed, + inject, + input, + output, + untracked, + viewChild, +} from '@angular/core' +import { FlexRender, injectTable } from '@tanstack/angular-table' +import { TradingBenchmarkController } from '../benchmark/trading-benchmark.controller' +import { createTradingColumns } from './table-config/trading-columns' +import { tradingFeatures } from './trading-features' +import { TradingTableInteractionController } from './table-interactions' +import { injectTradingTableInitialFit } from './trading-table-initial-fit' +import { TradingGridCellDirective } from './view/trading-grid-cell.directive' +import { TradingGridSelectionDirective } from './view/trading-grid-selection.directive' +import { TradingHeaderCell } from './view/trading-header-cell' +import { TradingTableBenchmarkDirective } from './view/trading-table-benchmark.directive' +import { + TRADING_ROW_HEIGHT, + injectTradingRowVirtualizer, +} from './trading-row-virtualizer' +import type { ElementRef } from '@angular/core' +import type { MarketQuote } from '../feed/market-data' +import type { RendererMode } from './table-config/trading-column-types' +import type { VirtualScrollMode } from './trading-row-virtualizer' + +@Component({ + selector: 'app-current-trading-table', + imports: [ + FlexRender, + TradingGridCellDirective, + TradingGridSelectionDirective, + TradingHeaderCell, + TradingTableBenchmarkDirective, + ], + templateUrl: './table-v9.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class CurrentTradingTable { + readonly #controller = inject(TradingBenchmarkController) + readonly quotes = input>([]) + readonly rendererMode = input.required() + readonly selectedSymbol = input(null) + readonly virtualScrollMode = input.required() + readonly symbolSelected = output() + readonly tanStackScrollContainer = viewChild>( + 'tanStackScrollContainer', + ) + readonly rowHeight = TRADING_ROW_HEIGHT + readonly interactions = new TradingTableInteractionController() + + readonly columns = createTradingColumns({ + rendererMode: () => this.rendererMode(), + selectSymbol: (symbol) => this.symbolSelected.emit(symbol), + }) + + readonly table = injectTable(() => ({ + data: this.quotes(), + columns: this.columns, + features: tradingFeatures, + columnResizeMode: 'onChange' as const, + defaultColumn: { minSize: 56, maxSize: 800 }, + autoResetCellSelection: false, + getRowId: (row) => row.id, + })) + readonly tableStyle = computed(() => { + void this.table.atoms.columnSizing.get() + void this.table.atoms.columnOrder.get() + return untracked(() => { + const styles: Record = { + width: `${this.table.getTotalSize()}px`, + } + for (const header of this.table.getFlatHeaders()) { + styles[`--header-${header.id}-size`] = `${header.getSize()}` + styles[`--col-${header.column.id}-size`] = `${header.column.getSize()}` + } + return styles + }) + }) + readonly rows = computed(() => this.table.getRowModel().rows) + readonly virtualization = injectTradingRowVirtualizer( + this.rows, + this.virtualScrollMode, + this.tanStackScrollContainer, + (count) => this.#controller.setRenderedRowCount(count), + ) + + readonly tableHeight = computed(() => this.rows().length * this.rowHeight) + readonly workerPending = computed(() => null) + readonly workerComputeMs = computed(() => null) + + constructor() { + injectTradingTableInitialFit(this.table, this.tanStackScrollContainer) + } +} diff --git a/examples/angular/realtime-trading/src/app/table/table-config/quote-cells.ts b/examples/angular/realtime-trading/src/app/table/table-config/quote-cells.ts new file mode 100644 index 0000000000..d7bd35a9a2 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/table-config/quote-cells.ts @@ -0,0 +1,258 @@ +import { + ChangeDetectionStrategy, + Component, + DestroyRef, + computed, + inject, + input, + output, +} from '@angular/core' + +const compactNumber = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) + +export const quoteCellLifecycle = { + created: 0, + destroyed: 0, +} + +function trackLifecycle(): void { + quoteCellLifecycle.created++ + inject(DestroyRef).onDestroy(() => quoteCellLifecycle.destroyed++) +} + +@Component({ + selector: 'app-price-cell', + template: ` + + `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class PriceCell { + readonly price = input.required() + readonly move = input.required() + readonly select = output() + readonly formattedPrice = computed(() => this.price().toFixed(2)) + + constructor() { + trackLifecycle() + } +} + +@Component({ + selector: 'app-stable-move-cell', + template: ` + + {{ formattedMove() }} + + `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class StableMoveCell { + readonly move = input.required() + readonly formattedMove = computed(() => formatSigned(this.move())) + + constructor() { + trackLifecycle() + } +} + +@Component({ + selector: 'app-percent-change-cell', + template: ` + + {{ formattedValue() }} + + `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class PercentChangeCell { + readonly value = input.required() + readonly formattedValue = computed( + () => `${this.value() >= 0 ? '+' : ''}${this.value().toFixed(2)}%`, + ) + + constructor() { + trackLifecycle() + } +} + +@Component({ + selector: 'app-spread-cell', + template: ` + + {{ formattedSpread() }} + {{ basisPoints().toFixed(1) }} bp + + `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class SpreadCell { + readonly bid = input.required() + readonly ask = input.required() + readonly spread = computed(() => Math.max(0, this.ask() - this.bid())) + readonly basisPoints = computed(() => { + const midpoint = (this.bid() + this.ask()) / 2 + return midpoint === 0 ? 0 : (this.spread() / midpoint) * 10_000 + }) + readonly formattedSpread = computed(() => this.spread().toFixed(2)) + + constructor() { + trackLifecycle() + } +} + +@Component({ + selector: 'app-depth-cell', + template: ` +
+ + + + {{ formattedBidSize() }} + {{ formattedAskSize() }} + +
+ `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class DepthCell { + readonly bidSize = input.required() + readonly askSize = input.required() + readonly bidShare = computed(() => { + const total = this.bidSize() + this.askSize() + return total === 0 ? 50 : (this.bidSize() / total) * 100 + }) + readonly formattedBidSize = computed(() => + compactNumber.format(this.bidSize()), + ) + readonly formattedAskSize = computed(() => + compactNumber.format(this.askSize()), + ) + + constructor() { + trackLifecycle() + } +} + +@Component({ + selector: 'app-quote-age-cell', + template: ` + + {{ formattedAge() }} + + `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class QuoteAgeCell { + readonly ageMs = input.required() + readonly formattedAge = computed(() => { + const age = this.ageMs() + return age < 1_000 + ? `${Math.round(age)} ms` + : `${(age / 1_000).toFixed(1)} s` + }) + + constructor() { + trackLifecycle() + } +} + +@Component({ + selector: 'app-up-move-cell', + template: `▲ {{ formattedMove() }}`, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class UpMoveCell { + readonly move = input.required() + readonly formattedMove = computed(() => formatSigned(this.move())) + + constructor() { + trackLifecycle() + } +} + +@Component({ + selector: 'app-down-move-cell', + template: `▼ {{ formattedMove() }}`, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class DownMoveCell { + readonly move = input.required() + readonly formattedMove = computed(() => formatSigned(this.move())) + + constructor() { + trackLifecycle() + } +} + +@Component({ + selector: 'app-sparkline-cell', + template: ` + + + + `, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class SparklineCell { + readonly values = input.required>() + readonly rising = computed(() => { + const values = this.values() + return (values.at(-1) ?? 0) >= (values[0] ?? 0) + }) + readonly points = computed(() => { + const values = this.values() + const min = Math.min(...values) + const max = Math.max(...values) + const range = max - min || 1 + const denominator = Math.max(1, values.length - 1) + + return values + .map((value, index) => { + const x = (index / denominator) * 100 + const y = 22 - ((value - min) / range) * 20 + return `${x.toFixed(1)},${y.toFixed(1)}` + }) + .join(' ') + }) + + constructor() { + trackLifecycle() + } +} + +function formatSigned(value: number): string { + const sign = value >= 0 ? '+' : '' + return `${sign}${value.toFixed(2)}` +} diff --git a/examples/angular/realtime-trading/src/app/table/table-config/trading-column-types.ts b/examples/angular/realtime-trading/src/app/table/table-config/trading-column-types.ts new file mode 100644 index 0000000000..dc6e83a0b2 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/table-config/trading-column-types.ts @@ -0,0 +1,8 @@ +export type RendererMode = 'stable' | 'swap' + +export interface TradingColumnState { + rendererMode: () => RendererMode + selectSymbol: (symbol: string) => void +} + +export const TRADING_COLUMN_COUNT = 14 diff --git a/examples/angular/realtime-trading/src/app/table/table-config/trading-columns.ts b/examples/angular/realtime-trading/src/app/table/table-config/trading-columns.ts new file mode 100644 index 0000000000..e613dcd1ae --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/table-config/trading-columns.ts @@ -0,0 +1,165 @@ +import { + createColumnHelper, + flexRenderComponent, +} from '@tanstack/angular-table' +import { tradingFeatures } from '../trading-features' +import { + DownMoveCell, + PercentChangeCell, + PriceCell, + SparklineCell, + StableMoveCell, + UpMoveCell, +} from './quote-cells' +import type { MarketQuote } from '../../feed/market-data' +import type { TradingColumnState } from './trading-column-types' + +const compactFormatter = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const columnHelper = createColumnHelper() + +export function createTradingColumns(state: TradingColumnState) { + return columnHelper.columns([ + columnHelper.group({ + id: 'instrument', + header: 'Instrument', + columns: columnHelper.columns([ + columnHelper.accessor('venue', { + id: 'market', + header: 'Market', + size: 72, + cell: (info) => info.getValue(), + }), + columnHelper.accessor('company', { + id: 'name', + header: 'Name', + size: 180, + cell: (info) => info.getValue(), + }), + columnHelper.accessor('symbol', { + header: 'Symbol', + size: 92, + cell: (info) => info.getValue(), + }), + ]), + }), + columnHelper.group({ + id: 'priceAndChange', + header: 'Price & Change', + columns: columnHelper.columns([ + columnHelper.accessor('price', { + header: 'Price', + size: 96, + cell: (info) => { + const change = getDayChange(info.row.original) + return flexRenderComponent(PriceCell, { + inputs: { price: info.getValue(), move: change }, + outputs: { + select: () => state.selectSymbol(info.row.original.symbol), + }, + }) + }, + }), + columnHelper.accessor((row) => getDayChange(row), { + id: 'change', + header: 'Chg', + size: 94, + cell: (info) => { + const move = info.getValue() + if (state.rendererMode() === 'stable') { + return flexRenderComponent(StableMoveCell, { + inputs: { move }, + }) + } + return flexRenderComponent(move >= 0 ? UpMoveCell : DownMoveCell, { + inputs: { move }, + }) + }, + }), + columnHelper.accessor((row) => getDayChangePercent(row), { + id: 'changePercent', + header: 'Chg%', + size: 90, + cell: (info) => + flexRenderComponent(PercentChangeCell, { + inputs: { value: info.getValue() }, + }), + }), + ]), + }), + columnHelper.group({ + id: 'orderBook', + header: 'Order Book', + columns: columnHelper.columns([ + columnHelper.accessor('bid', { + header: 'Bid', + size: 90, + cell: (info) => info.getValue().toFixed(2), + }), + columnHelper.accessor('bidSize', { + header: 'Bid Vol', + size: 100, + cell: (info) => compactFormatter.format(info.getValue()), + }), + columnHelper.accessor('ask', { + header: 'Ask', + size: 90, + cell: (info) => info.getValue().toFixed(2), + }), + columnHelper.accessor('askSize', { + header: 'Ask Vol', + size: 100, + cell: (info) => compactFormatter.format(info.getValue()), + }), + ]), + }), + columnHelper.group({ + id: 'session', + header: 'Session', + columns: columnHelper.columns([ + columnHelper.accessor('open', { + header: 'Open', + size: 90, + cell: (info) => info.getValue().toFixed(2), + }), + columnHelper.accessor('high', { + header: 'High', + size: 90, + cell: (info) => info.getValue().toFixed(2), + }), + columnHelper.accessor('low', { + header: 'Low', + size: 90, + cell: (info) => info.getValue().toFixed(2), + }), + ]), + }), + columnHelper.group({ + id: 'chart', + header: 'Chart', + columns: columnHelper.columns([ + columnHelper.accessor('history', { + header: 'Intraday', + size: 150, + enableSorting: false, + cell: (info) => + flexRenderComponent(SparklineCell, { + inputs: { values: info.getValue() }, + }), + }), + ]), + }), + ]) +} + +function getDayChange(quote: MarketQuote): number { + return quote.price - quote.previousClose +} + +function getDayChangePercent(quote: MarketQuote): number { + return quote.previousClose === 0 + ? 0 + : (getDayChange(quote) / quote.previousClose) * 100 +} diff --git a/examples/angular/realtime-trading/src/app/table/table-interactions.ts b/examples/angular/realtime-trading/src/app/table/table-interactions.ts new file mode 100644 index 0000000000..24d43b8138 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/table-interactions.ts @@ -0,0 +1,181 @@ +import { signal } from '@angular/core' + +export type CellDirection = 'up' | 'down' | 'left' | 'right' + +interface RowSelectionTable { + resetRowSelection: (defaultState?: boolean) => void +} + +interface SelectableRow { + getIsSelected: () => boolean + getToggleSelectedHandler: (options?: { + selectChildren?: boolean + }) => (event: unknown) => void +} + +interface CellNavigationTable { + extendCellSelection: (direction: CellDirection) => void + moveCellSelection: (direction: CellDirection) => void + resetCellSelection: (defaultState?: boolean) => void + selectAllCells: () => void +} + +export interface ColumnOrderTable { + getVisibleLeafColumns: () => Array<{ id: string }> + setColumnOrder: (columnIds: Array) => void +} + +const keyDirections: Partial> = { + ArrowUp: 'up', + ArrowDown: 'down', + ArrowLeft: 'left', + ArrowRight: 'right', +} + +export function reorderColumnIds( + columnIds: Array, + sourceId: string, + targetId: string, +): Array { + if (sourceId === targetId || !columnIds.includes(sourceId)) return columnIds + + const withoutSource = columnIds.filter((id) => id !== sourceId) + const targetIndex = withoutSource.indexOf(targetId) + if (targetIndex < 0) return columnIds + + return [ + ...withoutSource.slice(0, targetIndex), + sourceId, + ...withoutSource.slice(targetIndex), + ] +} + +export function selectRowFromPointer( + table: RowSelectionTable, + row: SelectableRow, + event: MouseEvent, +): void { + const additive = event.ctrlKey || event.metaKey + const checked = additive ? !row.getIsSelected() : true + + if (!event.shiftKey && !additive) table.resetRowSelection(true) + + row.getToggleSelectedHandler({ selectChildren: false })({ + target: { checked }, + shiftKey: event.shiftKey, + ctrlKey: event.ctrlKey, + metaKey: event.metaKey, + }) +} + +export function handleCellNavigation( + table: CellNavigationTable, + event: KeyboardEvent, +): void { + if (event.key === 'Escape') { + event.preventDefault() + table.resetCellSelection(true) + return + } + + if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a') { + event.preventDefault() + table.selectAllCells() + return + } + + const direction = keyDirections[event.key] + if (!direction) return + + event.preventDefault() + if (event.shiftKey) table.extendCellSelection(direction) + else table.moveCellSelection(direction) +} + +export function sortIndicator(direction: false | 'asc' | 'desc'): string { + if (direction === 'asc') return '↑' + if (direction === 'desc') return '↓' + return '↕' +} + +export function sortAriaValue( + direction: false | 'asc' | 'desc', +): 'ascending' | 'descending' | 'none' { + if (direction === 'asc') return 'ascending' + if (direction === 'desc') return 'descending' + return 'none' +} + +export class TradingTableInteractionController { + readonly draggedColumnId = signal(null) + readonly dropTargetColumnId = signal(null) + + startColumnDrag(event: DragEvent, columnId: string): void { + this.draggedColumnId.set(columnId) + event.dataTransfer?.setData('text/plain', columnId) + if (event.dataTransfer) event.dataTransfer.effectAllowed = 'move' + } + + dragOverColumn(event: DragEvent, targetId: string): void { + event.preventDefault() + if (targetId === this.draggedColumnId()) { + this.dropTargetColumnId.set(null) + return + } + this.dropTargetColumnId.set(targetId) + } + + dropColumn( + table: ColumnOrderTable, + event: DragEvent, + targetId: string, + ): void { + event.preventDefault() + const sourceId = + event.dataTransfer?.getData('text/plain') || this.draggedColumnId() + if (!sourceId) { + this.clearColumnDrag() + return + } + + table.setColumnOrder( + reorderColumnIds( + table.getVisibleLeafColumns().map((column) => column.id), + sourceId, + targetId, + ), + ) + this.clearColumnDrag() + } + + endColumnDrag(): void { + this.clearColumnDrag() + } + + private clearColumnDrag(): void { + this.draggedColumnId.set(null) + this.dropTargetColumnId.set(null) + } + + selectRow( + table: RowSelectionTable, + row: SelectableRow, + event: MouseEvent, + ): void { + selectRowFromPointer(table, row, event) + } + + navigateCells(table: CellNavigationTable, event: KeyboardEvent): void { + handleCellNavigation(table, event) + } + + sortIndicator(direction: false | 'asc' | 'desc'): string { + return sortIndicator(direction) + } + + sortAriaValue( + direction: false | 'asc' | 'desc', + ): 'ascending' | 'descending' | 'none' { + return sortAriaValue(direction) + } +} diff --git a/examples/angular/realtime-trading/src/app/table/table-v9.html b/examples/angular/realtime-trading/src/app/table/table-v9.html new file mode 100644 index 0000000000..06c7e85ada --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/table-v9.html @@ -0,0 +1,144 @@ +@switch (virtualScrollMode()) { + @case ('tanstack') { +
+ + + + @for (headerGroup of table.getHeaderGroups(); track headerGroup.id) { + + @for (header of headerGroup.headers; track header.id) { + + } + + } + + + @for (virtualRow of virtualization.tanStackVirtualRows(); track virtualRow.key) { + @if (rows()[virtualRow.index]; as row) { + + @for (cell of row.getVisibleCells(); track cell.id) { + + } + + } + } + +
+ + {{ renderCell }} + +
+
+ } + @default { +
+ + + @for (headerGroup of table.getHeaderGroups(); track headerGroup.id) { + + @for (header of headerGroup.headers; track header.id) { + + } + + } + + + @for (row of rows(); track row.id) { + + @for (cell of row.getVisibleCells(); track cell.id) { + + } + + } + +
+ + {{ renderCell }} + +
+
+ } +} + +@if (virtualScrollMode() !== 'none') { +
+ + TanStack · Total · {{ rows().length }} rows · + {{ table.getVisibleLeafColumns().length }} columns + + @if (virtualization.visibleRange(); as visibleRange) { + + Current · rows {{ visibleRange.start }}..{{ visibleRange.end }} + + } @else { + Current · rows — + } +
+} diff --git a/examples/angular/realtime-trading/src/app/table/trading-features.ts b/examples/angular/realtime-trading/src/app/table/trading-features.ts new file mode 100644 index 0000000000..3bd98b192e --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/trading-features.ts @@ -0,0 +1,10 @@ +import { + createSortedRowModel, + stockFeatures, + tableFeatures, +} from '@tanstack/angular-table' + +export const tradingFeatures = tableFeatures({ + ...stockFeatures, + sortedRowModel: createSortedRowModel(), +}) diff --git a/examples/angular/realtime-trading/src/app/table/trading-row-virtualizer.ts b/examples/angular/realtime-trading/src/app/table/trading-row-virtualizer.ts new file mode 100644 index 0000000000..122e4d1b6f --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/trading-row-virtualizer.ts @@ -0,0 +1,115 @@ +import { + ChangeDetectorRef, + DestroyRef, + computed, + effect, + inject, +} from '@angular/core' +import { injectVirtualizer } from '@tanstack/angular-virtual' +import type { ElementRef, Signal } from '@angular/core' + +export const TRADING_ROW_HEIGHT = 32 +export const DEFAULT_VIRTUALIZATION_ROW_COUNT = 200 +export const FORCED_VIRTUALIZATION_ROW_COUNT = 1_500 + +const TANSTACK_OVERSCAN = 10 + +export type VirtualScrollMode = 'tanstack' | 'none' +export type VirtualScrollPreference = VirtualScrollMode | 'auto' + +export function resolveVirtualScrollMode( + requestedMode: VirtualScrollPreference, + instrumentCount: number, +): VirtualScrollMode { + if (instrumentCount >= FORCED_VIRTUALIZATION_ROW_COUNT) return 'tanstack' + if (requestedMode !== 'auto') return requestedMode + return instrumentCount >= DEFAULT_VIRTUALIZATION_ROW_COUNT + ? 'tanstack' + : 'none' +} + +interface TradingVirtualRow { + id: string +} + +function injectLocalDomFlush() { + const changeDetectorRef = inject(ChangeDetectorRef) + const destroyRef = inject(DestroyRef) + const state = { + destroyed: false, + queued: false, + } + + destroyRef.onDestroy(() => { + state.destroyed = true + }) + + return () => { + if (state.queued || state.destroyed) return + + state.queued = true + queueMicrotask(() => { + state.queued = false + if (!state.destroyed) { + changeDetectorRef.detectChanges() + } + }) + } +} + +export function injectTradingRowVirtualizer( + rows: Signal>, + mode: Signal, + tanStackScrollContainer: Signal | undefined>, + reportRenderedRowCount: (count: number) => void, +) { + const scheduleLocalDomFlush = injectLocalDomFlush() + const rowVirtualizer = injectVirtualizer( + () => ({ + count: rows().length, + scrollElement: tanStackScrollContainer()?.nativeElement, + estimateSize: () => TRADING_ROW_HEIGHT, + getItemKey: (index) => rows()[index]?.id ?? index, + overscan: TANSTACK_OVERSCAN, + enabled: mode() === 'tanstack', + useCachedMeasurements: true, + useApplicationRefTick: false, + onChange: scheduleLocalDomFlush, + }), + ) + + const tanStackVirtualRows = rowVirtualizer.getVirtualItems + const tanStackTotalSize = rowVirtualizer.getTotalSize + const visibleRange = computed(() => { + const rowCount = rows().length + const range = rowVirtualizer.range() + + if (mode() !== 'tanstack' || rowCount === 0 || range === null) { + return null + } + + const lastRowIndex = rowCount - 1 + const start = Math.min(range.startIndex, lastRowIndex) + + return { + start, + end: Math.min(Math.max(start, range.endIndex), lastRowIndex), + } + }) + const renderedRowCount = computed(() => { + if (mode() === 'tanstack') { + return tanStackVirtualRows().length + } + return rows().length + }) + + effect(() => reportRenderedRowCount(renderedRowCount())) + + return { + rowVirtualizer, + tanStackVirtualRows, + tanStackTotalSize, + visibleRange, + renderedRowCount, + } +} diff --git a/examples/angular/realtime-trading/src/app/table/trading-table-initial-fit.ts b/examples/angular/realtime-trading/src/app/table/trading-table-initial-fit.ts new file mode 100644 index 0000000000..0786f26529 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/trading-table-initial-fit.ts @@ -0,0 +1,63 @@ +import { DestroyRef, afterNextRender, inject } from '@angular/core' +import type { ElementRef, Signal } from '@angular/core' + +interface FitColumn { + getSize: () => number + id: string +} + +interface FitTable { + atoms: { + columnResizing: { + subscribe: ( + listener: (state: { isResizingColumn: false | string }) => void, + ) => { unsubscribe: () => void } + } + } + getTotalSize: () => number + getVisibleLeafColumns: () => Array + setColumnSizing: (sizes: Record) => void +} + +export function injectTradingTableInitialFit( + table: FitTable, + scrollContainer: Signal | undefined>, +): void { + const destroyRef = inject(DestroyRef) + const runtime = { manuallyResized: false } + + afterNextRender(() => { + const element = scrollContainer()?.nativeElement + if (!element) return + + const fitAvailableWidth = () => { + if (runtime.manuallyResized) return + const currentWidth = table.getTotalSize() + const availableWidth = element.clientWidth + if (availableWidth <= currentWidth + 1 || currentWidth <= 0) return + + const ratio = availableWidth / currentWidth + table.setColumnSizing( + Object.fromEntries( + table + .getVisibleLeafColumns() + .map((column) => [column.id, column.getSize() * ratio]), + ), + ) + } + + const resizeObserver = new ResizeObserver(fitAvailableWidth) + const resizingSubscription = table.atoms.columnResizing.subscribe( + (state) => { + if (state.isResizingColumn !== false) runtime.manuallyResized = true + }, + ) + resizeObserver.observe(element) + fitAvailableWidth() + + destroyRef.onDestroy(() => { + resizeObserver.disconnect() + resizingSubscription.unsubscribe() + }) + }) +} diff --git a/examples/angular/realtime-trading/src/app/table/view/trading-grid-cell.directive.ts b/examples/angular/realtime-trading/src/app/table/view/trading-grid-cell.directive.ts new file mode 100644 index 0000000000..150b65c5d2 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/view/trading-grid-cell.directive.ts @@ -0,0 +1,42 @@ +import { Directive, computed, inject, input } from '@angular/core' +import { TradingGridSelectionDirective } from './trading-grid-selection.directive' +import type { Cell, TableFeatures } from '@tanstack/angular-table' +import type { MarketQuote } from '../../feed/market-data' + +type TradingCell = Cell + +@Directive({ + selector: 'td[appTradingGridCell]', + host: { + '[style.width]': 'staticHostState().width', + '[attr.data-column-id]': 'staticHostState().columnId', + '[attr.data-cell-focused]': "selectionHostState().focused ? 'true' : null", + '[attr.data-selection-top]': "selectionHostState().top ? 'true' : null", + '[attr.data-selection-right]': "selectionHostState().right ? 'true' : null", + '[attr.data-selection-bottom]': + "selectionHostState().bottom ? 'true' : null", + '[attr.data-selection-left]': "selectionHostState().left ? 'true' : null", + '[attr.tabindex]': 'selectionHostState().tabIndex', + '[attr.aria-selected]': 'selectionHostState().selected', + }, +}) +export class TradingGridCellDirective { + readonly #selection = inject(TradingGridSelectionDirective) + + readonly cell = input.required({ + alias: 'appTradingGridCell', + }) + + readonly staticHostState = computed(() => { + const columnId = this.cell().column.id + + return { + width: `calc(var(--col-${columnId}-size) * 1px)`, + columnId, + } + }) + + readonly selectionHostState = computed(() => { + return this.#selection.readCellSelectionState(this.cell()) + }) +} diff --git a/examples/angular/realtime-trading/src/app/table/view/trading-grid-selection.directive.ts b/examples/angular/realtime-trading/src/app/table/view/trading-grid-selection.directive.ts new file mode 100644 index 0000000000..f58c6f6b4c --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/view/trading-grid-selection.directive.ts @@ -0,0 +1,98 @@ +import { Directive, input, output } from '@angular/core' +import type { Cell, Table, TableFeatures } from '@tanstack/angular-table' +import type { MarketQuote } from '../../feed/market-data' +import type { TradingTableInteractionController } from '../table-interactions' + +type TradingCell = Cell +type TradingTable = Table + +interface SelectionCellTarget { + readonly element: HTMLTableCellElement + readonly cell: TradingCell +} + +@Directive({ + selector: 'table[appTradingGridSelection]', + host: { + '(mousedown)': 'handleMouseDown($event)', + '(mousemove)': 'handleMouseMove($event)', + '(mouseleave)': 'resetPointerCell()', + '(click)': 'handleClick($event)', + }, +}) +export class TradingGridSelectionDirective { + readonly table = input.required({ + alias: 'appTradingGridSelection', + }) + readonly interactions = input.required() + readonly symbolSelected = output() + + #lastPointerCell: HTMLTableCellElement | null = null + + readCellSelectionState(cell: TradingCell) { + this.table().atoms.cellSelection.get() + const edges = cell.getSelectionEdges() + + return { + selected: cell.getIsSelected(), + focused: cell.getIsFocused(), + top: edges.top, + right: edges.right, + bottom: edges.bottom, + left: edges.left, + tabIndex: cell.getTabIndex(), + } + } + + handleMouseDown(event: MouseEvent): void { + if (event.button !== 0) return + + const target = this.#findCellTarget(event.composedPath()) + if (!target) return + + event.preventDefault() + this.#lastPointerCell = target.element + this.symbolSelected.emit(target.cell.row.original.symbol) + target.cell.getSelectionStartHandler(target.element.ownerDocument)(event) + } + + handleMouseMove(event: MouseEvent): void { + if ((event.buttons & 1) === 0) { + this.#lastPointerCell = null + return + } + + const target = this.#findCellTarget(event.composedPath()) + if (!target || target.element === this.#lastPointerCell) return + + this.#lastPointerCell = target.element + target.cell.getSelectionExtendHandler()(event) + } + + resetPointerCell(): void { + this.#lastPointerCell = null + } + + handleClick(event: MouseEvent): void { + const target = this.#findCellTarget(event.composedPath()) + if (!target) return + this.interactions().selectRow(this.table(), target.cell.row, event) + } + + #findCellTarget(path: Array): SelectionCellTarget | null { + for (const target of path) { + if (!(target instanceof HTMLTableCellElement)) continue + + const columnId = target.dataset['columnId'] + const rowId = + target.closest('tr[data-row-id]')?.dataset['rowId'] + if (!columnId || !rowId) return null + + const row = this.table().getRowModel().rowsById[rowId] + const cell = row.getAllCellsByColumnId()[columnId] + return { element: target, cell } + } + + return null + } +} diff --git a/examples/angular/realtime-trading/src/app/table/view/trading-header-cell.html b/examples/angular/realtime-trading/src/app/table/view/trading-header-cell.html new file mode 100644 index 0000000000..4a79e34760 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/view/trading-header-cell.html @@ -0,0 +1,53 @@ +@if (!header().isPlaceholder) { + @if (isGroup()) { + + {{ headerCell }} + + } @else { +
+ + +
+ @if (header().column.getCanResize()) { + + } + } +} diff --git a/examples/angular/realtime-trading/src/app/table/view/trading-header-cell.ts b/examples/angular/realtime-trading/src/app/table/view/trading-header-cell.ts new file mode 100644 index 0000000000..d0fc7df5d8 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/view/trading-header-cell.ts @@ -0,0 +1,64 @@ +import { + ChangeDetectionStrategy, + Component, + computed, + input, +} from '@angular/core' +import { FlexRender } from '@tanstack/angular-table' +import type { Header, TableFeatures } from '@tanstack/angular-table' +import type { MarketQuote } from '../../feed/market-data' +import type { + ColumnOrderTable, + TradingTableInteractionController, +} from '../table-interactions' + +type TradingHeader = Header + +@Component({ + selector: 'th[appTradingHeaderCell]', + imports: [FlexRender], + templateUrl: './trading-header-cell.html', + host: { + '[attr.colspan]': 'header().colSpan', + '[attr.aria-sort]': 'ariaSort()', + '[class.column-group-header]': 'isGroup()', + '[class.numeric-header]': 'isNumeric()', + '[class.is-column-dragging]': + 'interactions().draggedColumnId() === header().column.id', + '[class.is-column-drop-target]': + 'interactions().dropTargetColumnId() === header().column.id', + '[style.width]': 'width()', + }, + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class TradingHeaderCell { + readonly header = input.required({ + alias: 'appTradingHeaderCell', + }) + readonly table = input.required() + readonly interactions = input.required() + + readonly isGroup = computed(() => this.header().subHeaders.length > 0) + readonly isNumeric = computed( + () => !this.isGroup() && !isTextColumn(this.header().column.id), + ) + readonly width = computed( + () => `calc(var(--header-${this.header().id}-size) * 1px)`, + ) + readonly sorted = computed(() => this.header().column.getIsSorted()) + readonly ariaSort = computed(() => + this.isGroup() ? null : this.interactions().sortAriaValue(this.sorted()), + ) + + startColumnDrag(event: DragEvent): void { + this.interactions().startColumnDrag(event, this.header().column.id) + } + + dropColumn(event: DragEvent): void { + this.interactions().dropColumn(this.table(), event, this.header().column.id) + } +} + +function isTextColumn(columnId: string): boolean { + return columnId === 'market' || columnId === 'name' || columnId === 'symbol' +} diff --git a/examples/angular/realtime-trading/src/app/table/view/trading-table-benchmark.directive.ts b/examples/angular/realtime-trading/src/app/table/view/trading-table-benchmark.directive.ts new file mode 100644 index 0000000000..75b3de8586 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/view/trading-table-benchmark.directive.ts @@ -0,0 +1,25 @@ +import { DestroyRef, Directive, ElementRef, inject } from '@angular/core' +import { TradingBenchmarkController } from '../../benchmark/trading-benchmark.controller' + +@Directive({ + selector: 'tbody[appTradingTableBenchmark]', +}) +export class TradingTableBenchmarkDirective { + readonly #controller = inject(TradingBenchmarkController) + readonly #element = inject>(ElementRef) + readonly #observer = new MutationObserver((records) => { + this.#controller.recordDomMutations(records.length) + }) + + constructor() { + this.#controller.resetDomMutations() + this.#observer.observe(this.#element.nativeElement, { + attributes: true, + attributeFilter: ['class', 'style'], + characterData: true, + childList: true, + subtree: true, + }) + inject(DestroyRef).onDestroy(() => this.#observer.disconnect()) + } +} diff --git a/examples/angular/realtime-trading/src/app/table/worker/table-row-model.worker.ts b/examples/angular/realtime-trading/src/app/table/worker/table-row-model.worker.ts new file mode 100644 index 0000000000..39252b634f --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/worker/table-row-model.worker.ts @@ -0,0 +1,53 @@ +import { + createColumnHelper, + createFilteredRowModel, + createSortedRowModel, + stockFeatures, + tableFeatures, +} from '@tanstack/angular-table' +import { + initTableWorker, + workerRowModelsFeature, +} from '@tanstack/angular-table/experimental-worker-plugin' +import type { MarketQuote } from '../../feed/market-data' + +const workerFeatures = tableFeatures({ + ...stockFeatures, + workerRowModelsFeature, + filteredRowModel: createFilteredRowModel(), + sortedRowModel: createSortedRowModel(), +}) +const columnHelper = createColumnHelper() + +// The worker only computes row models, so it needs portable accessors but none +// of the Angular render components used by the visible table. +const workerColumns = columnHelper.columns([ + columnHelper.accessor('venue', { id: 'market' }), + columnHelper.accessor('company', { id: 'name' }), + columnHelper.accessor('symbol', {}), + columnHelper.accessor('price', {}), + columnHelper.accessor((row) => row.price - row.previousClose, { + id: 'change', + }), + columnHelper.accessor( + (row) => + row.previousClose === 0 + ? 0 + : ((row.price - row.previousClose) / row.previousClose) * 100, + { id: 'changePercent' }, + ), + columnHelper.accessor('bid', {}), + columnHelper.accessor('bidSize', {}), + columnHelper.accessor('ask', {}), + columnHelper.accessor('askSize', {}), + columnHelper.accessor('open', {}), + columnHelper.accessor('high', {}), + columnHelper.accessor('low', {}), + columnHelper.accessor('history', { enableSorting: false }), +]) + +initTableWorker({ + features: workerFeatures, + columns: workerColumns, + getRowId: (row) => row.id, +}) diff --git a/examples/angular/realtime-trading/src/app/table/worker/worker-trading-table.ts b/examples/angular/realtime-trading/src/app/table/worker/worker-trading-table.ts new file mode 100644 index 0000000000..2c18b8a293 --- /dev/null +++ b/examples/angular/realtime-trading/src/app/table/worker/worker-trading-table.ts @@ -0,0 +1,138 @@ +import { + ChangeDetectionStrategy, + Component, + DestroyRef, + computed, + inject, + input, + output, + untracked, + viewChild, +} from '@angular/core' +import { + FlexRender, + injectTable, + stockFeatures, + tableFeatures, +} from '@tanstack/angular-table' +import { + createTableWorker, + createWorkerRowModel, + workerRowModelsFeature, +} from '@tanstack/angular-table/experimental-worker-plugin' +import { TradingBenchmarkController } from '../../benchmark/trading-benchmark.controller' +import { createTradingColumns } from '../table-config/trading-columns' +import { TradingTableInteractionController } from '../table-interactions' +import { injectTradingTableInitialFit } from '../trading-table-initial-fit' +import { TradingGridCellDirective } from '../view/trading-grid-cell.directive' +import { TradingGridSelectionDirective } from '../view/trading-grid-selection.directive' +import { TradingHeaderCell } from '../view/trading-header-cell' +import { TradingTableBenchmarkDirective } from '../view/trading-table-benchmark.directive' +import { + TRADING_ROW_HEIGHT, + injectTradingRowVirtualizer, +} from '../trading-row-virtualizer' +import type { ColumnDef } from '@tanstack/angular-table' +import type { ElementRef } from '@angular/core' +import type { MarketQuote } from '../../feed/market-data' +import type { RendererMode } from '../table-config/trading-column-types' +import type { VirtualScrollMode } from '../trading-row-virtualizer' + +function createWorkerTableRuntime() { + const worker = createTableWorker({ + createWorker: () => + new Worker(new URL('./table-row-model.worker', import.meta.url), { + type: 'module', + }), + }) + const features = tableFeatures({ + ...stockFeatures, + workerRowModelsFeature, + filteredRowModel: createWorkerRowModel(worker, 'filtered'), + sortedRowModel: createWorkerRowModel(worker, 'sorted'), + }) + + return { worker, features } +} + +type WorkerFeatures = ReturnType['features'] + +@Component({ + selector: 'app-worker-trading-table', + imports: [ + FlexRender, + TradingGridCellDirective, + TradingGridSelectionDirective, + TradingHeaderCell, + TradingTableBenchmarkDirective, + ], + templateUrl: '../table-v9.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class WorkerTradingTable { + readonly #controller = inject(TradingBenchmarkController) + readonly #destroyRef = inject(DestroyRef) + readonly #workerRuntime = createWorkerTableRuntime() + readonly quotes = input>([]) + readonly rendererMode = input.required() + readonly selectedSymbol = input(null) + readonly virtualScrollMode = input.required() + readonly symbolSelected = output() + readonly tanStackScrollContainer = viewChild>( + 'tanStackScrollContainer', + ) + readonly rowHeight = TRADING_ROW_HEIGHT + readonly interactions = new TradingTableInteractionController() + + readonly columns = createTradingColumns({ + rendererMode: () => this.rendererMode(), + selectSymbol: (symbol) => this.symbolSelected.emit(symbol), + }) + + readonly table = injectTable(() => ({ + data: this.quotes(), + columns: this.columns as Array>, + features: this.#workerRuntime.features, + columnResizeMode: 'onChange' as const, + defaultColumn: { minSize: 56, maxSize: 800 }, + autoResetCellSelection: false, + getRowId: (row) => row.id, + })) + readonly tableStyle = computed(() => { + void this.table.atoms.columnSizing.get() + void this.table.atoms.columnOrder.get() + return untracked(() => { + const styles: Record = { + width: `${this.table.getTotalSize()}px`, + } + for (const header of this.table.getFlatHeaders()) { + styles[`--header-${header.id}-size`] = `${header.getSize()}` + styles[`--col-${header.column.id}-size`] = `${header.column.getSize()}` + } + return styles + }) + }) + readonly rows = computed(() => this.table.getRowModel().rows) + readonly virtualization = injectTradingRowVirtualizer( + this.rows, + this.virtualScrollMode, + this.tanStackScrollContainer, + (count) => this.#controller.setRenderedRowCount(count), + ) + + readonly workerPending = computed(() => { + return String(this.table.atoms.workerRowModels.get().isPending) + }) + + readonly workerComputeMs = computed(() => { + const computeMs = this.table.atoms.workerRowModels.get().lastComputeMs + return computeMs === undefined ? null : computeMs.toFixed(3) + }) + + readonly tableHeight = computed(() => this.rows().length * this.rowHeight) + + constructor() { + injectTradingTableInitialFit(this.table, this.tanStackScrollContainer) + this.#destroyRef.onDestroy(() => this.#workerRuntime.worker.terminate()) + } +} diff --git a/examples/angular/realtime-trading/src/index.html b/examples/angular/realtime-trading/src/index.html new file mode 100644 index 0000000000..3122a836db --- /dev/null +++ b/examples/angular/realtime-trading/src/index.html @@ -0,0 +1,17 @@ + + + + + Angular Real-time Trading flexRender Lab + + + + + + + + + diff --git a/examples/angular/realtime-trading/src/main.ts b/examples/angular/realtime-trading/src/main.ts new file mode 100644 index 0000000000..c9b5d07d64 --- /dev/null +++ b/examples/angular/realtime-trading/src/main.ts @@ -0,0 +1,5 @@ +import { bootstrapApplication } from '@angular/platform-browser' +import { App } from './app/app' +import { appConfig } from './app/app.config' + +bootstrapApplication(App, appConfig).catch((error) => console.error(error)) diff --git a/examples/angular/realtime-trading/src/styles.css b/examples/angular/realtime-trading/src/styles.css new file mode 100644 index 0000000000..113476ec65 --- /dev/null +++ b/examples/angular/realtime-trading/src/styles.css @@ -0,0 +1,1088 @@ +:root { + color-scheme: dark; + --font-ui: + Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, + 'Segoe UI', sans-serif; + --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace; + font-family: var(--font-ui); + font-synthesis: none; + --background: #050505; + --panel: #080808; + --panel-raised: #111111; + --panel-hover: #181818; + --surface-bar: #080808; + --surface-toolbar: #0d0d0d; + --surface-table: #050505; + --surface-header: #101010; + --surface-control: #151515; + --border: #303030; + --border-soft: #242424; + --border-strong: #4a4a4a; + --text: #e7ebf0; + --text-strong: #ffffff; + --text-inverse: #f7f9fb; + --muted: #737982; + --blue: #62a9ff; + --blue-soft: #a9d0ff; + --green: #42e488; + --red: #ff646b; + --amber: #dfb465; + --depth-bid: #315774; + --depth-ask: #634049; + --row-alt: rgb(255 255 255 / 1.8%); + --row-selected: rgb(66 132 214 / 16%); + --control-border: #354456; + --control-hover: #192431; + --sidebar-width: 18rem; + --shell-bar-height: 2.625rem; + --metrics-height: 3.5rem; + --statusbar-height: 1.625rem; + --virtual-footer-height: 2.125rem; + --table-header-height: 2rem; + --table-row-height: 2rem; + --shell-inline-padding: 0.75rem; + --table-cell-inline-padding: 0.6rem; + --control-radius: 1px; +} + +* { + box-sizing: border-box; +} + +html, +body { + min-width: 320px; + min-height: 100%; + margin: 0; + background: var(--background); +} + +body { + color: var(--text); +} + +button, +select, +input { + font: inherit; +} + +button, +select { + color: var(--text); + background: var(--panel-raised); + border: 1px solid var(--control-border); + border-radius: var(--control-radius); +} + +button { + padding: 0.5rem 0.65rem; + cursor: pointer; + font-size: 0.72rem; + font-weight: 650; + letter-spacing: 0.025em; +} + +button:hover { + background: var(--control-hover); + border-color: var(--border-strong); +} + +button:focus-visible, +select:focus-visible, +input:focus-visible { + outline: 1px solid var(--blue); + outline-offset: 1px; +} + +select { + width: 100%; + padding: 0.45rem 0.55rem; + font-size: 0.75rem; +} + +.trading-terminal { + --active-sidebar-width: var(--sidebar-width); + display: grid; + width: 100%; + height: 100dvh; + min-height: 0; + overflow: hidden; + background: var(--background); + grid-template-areas: + 'header sidebar' + 'content sidebar' + 'footer sidebar'; + grid-template-columns: minmax(0, 1fr) var(--active-sidebar-width); + grid-template-rows: auto minmax(0, 1fr) auto; + transition: grid-template-columns 160ms ease; +} + +.trading-terminal.is-sidebar-collapsed { + --active-sidebar-width: 0px; +} + +.shell-header { + display: flex; + min-width: 0; + flex-direction: column; + grid-area: header; +} + +.app-bar { + display: flex; + min-height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + background: var(--surface-bar); + border-bottom: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.68rem; + letter-spacing: 0.045em; +} + +.brand, +.header-actions, +.feed-status { + display: flex; + align-items: center; +} + +.brand { + gap: 0.65rem; + color: var(--text-strong); +} + +.header-actions { + gap: 0.75rem; +} + +.sidebar-toggle { + display: grid; + width: 1.9rem; + height: 1.9rem; + padding: 0; + place-items: center; + color: var(--muted); + background: transparent; + border-color: transparent; +} + +.sidebar-toggle:hover { + color: var(--text-strong); + background: var(--surface-control); + border-color: var(--border); +} + +.sidebar-toggle svg { + width: 1rem; + height: 1rem; + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-width: 1.4; +} + +.feed-status { + gap: 0.4rem; + color: var(--muted); +} + +.feed-status.is-running { + color: var(--green); +} + +.status-dot { + width: 6px; + height: 6px; + background: var(--muted); + border-radius: 50%; +} + +.feed-status.is-running .status-dot { + background: var(--green); +} + +.development-warning { + flex: 0 0 auto; + padding: 0.3rem 0.75rem; + color: var(--amber); + background: color-mix(in srgb, var(--amber) 8%, var(--background)); + border-bottom: 1px solid color-mix(in srgb, var(--amber) 24%, var(--border)); + font-family: var(--font-mono); + font-size: 0.62rem; + letter-spacing: 0.04em; +} + +.market-panel { + display: flex; + min-width: 0; + min-height: 0; + flex-direction: column; + background: var(--panel); + grid-area: content; +} + +.metrics-strip { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + background: var(--border); + border-bottom: 1px solid var(--border); + gap: 1px; +} + +.metrics-strip h2 { + margin: 0; + padding: 0.65rem var(--shell-inline-padding) 0.45rem; + color: var(--muted); + background: var(--surface-table); + font-size: 0.58rem; + grid-column: 1 / -1; + letter-spacing: 0.075em; +} + +.metrics-strip article { + min-width: 0; + min-height: 4.25rem; + padding: 0.5rem var(--shell-inline-padding); + background: var(--surface-bar); +} + +.metrics-strip span, +.metrics-strip small { + display: block; + color: var(--muted); + font-size: 0.56rem; + letter-spacing: 0.045em; + line-height: 1.35; +} + +.metrics-strip strong { + display: block; + margin: 0.12rem 0 0.08rem; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.88rem; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +.metrics-strip strong.metric-alert { + color: var(--amber); +} + +.table-scroll { + flex: 1; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +app-current-trading-table, +app-worker-trading-table { + display: flex; + flex-direction: column; + flex: 1; + min-width: 0; + min-height: 0; +} + +.virtual-scroll-footer { + display: flex; + flex: 0 0 auto; + align-items: center; + justify-content: space-between; + min-height: var(--virtual-footer-height); + padding: 0 var(--shell-inline-padding); + color: var(--muted); + background: var(--surface-toolbar); + border-top: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.68rem; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +table { + min-width: 100%; + border-spacing: 0; + table-layout: fixed; + font-family: var(--font-ui); + font-size: 0.78rem; + font-variant-numeric: tabular-nums; +} + +.virtual-table { + display: grid; +} + +.virtual-table thead { + display: grid; +} + +.virtual-table thead tr, +.virtual-table-row { + display: flex; + width: 100%; +} + +.virtual-table th, +.virtual-table-row > td { + flex: 0 0 auto; +} + +.virtual-table-body { + position: relative; + display: grid; +} + +.virtual-table-row { + position: absolute; + left: 0; + height: var(--table-row-height); +} + +.virtual-table-row > td { + display: block; +} + +.trading-data-grid { + display: grid; +} + +.trading-data-grid thead, +.trading-data-grid tbody { + display: grid; +} + +.trading-data-grid tbody { + -webkit-user-select: none; + user-select: none; +} + +.trading-data-grid thead > tr, +.trading-data-grid tbody > tr { + display: flex; + width: 100%; +} + +.trading-data-grid tbody > tr { + min-height: var(--table-row-height); + content-visibility: auto; + contain-intrinsic-block-size: var(--table-row-height); +} + +.trading-data-grid th, +.trading-data-grid td { + flex: 0 0 auto; +} + +thead { + position: sticky; + z-index: 2; + top: 0; +} + +th { + height: var(--table-header-height); + padding: 0 var(--table-cell-inline-padding); + color: var(--muted); + background: var(--surface-header); + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border); + font-size: 0.7rem; + font-weight: 500; + letter-spacing: 0.005em; + text-align: left; + white-space: nowrap; +} + +th.column-group-header { + color: #666b72; + font-size: 0.72rem; + font-weight: 500; + text-align: center; +} + +thead tr:first-child th.column-group-header { + color: #777d85; + font-size: 0.76rem; +} + +th.numeric-header { + text-align: right; +} + +td { + height: var(--table-row-height); + padding: 0 var(--table-cell-inline-padding); + overflow: hidden; + color: #eef1f5; + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border-soft); + text-align: right; + text-overflow: ellipsis; + white-space: nowrap; +} + +th:last-child, +td:last-child { + border-right: 0; +} + +td[data-column-id='market'], +td[data-column-id='name'], +td[data-column-id='symbol'] { + text-align: left; +} + +td[data-column-id='market'] { + color: var(--blue); + font-weight: 550; +} + +td[data-column-id='name'] { + color: var(--text-strong); +} + +td[data-column-id='symbol'] { + color: #d8dde4; + font-weight: 600; +} + +tbody tr:nth-child(even) { + background: var(--row-alt); +} + +tbody tr.virtual-table-row.is-even-row { + background: var(--row-alt); +} + +tbody tr:hover { + background: var(--panel-hover); +} + +tbody tr[data-symbol-selected='true'] { + background: var(--row-selected); + box-shadow: inset 2px 0 0 var(--blue); +} + +.table-scroll:focus { + outline: none; +} + +th { + position: relative; +} + +.leaf-header-content { + display: flex; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + height: 100%; + align-items: stretch; + margin-inline: calc(-1 * var(--table-cell-inline-padding)); +} + +.column-drag-handle, +.sort-header-button { + min-width: 0; + height: 100%; + padding: 0; + color: inherit; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-weight: inherit; + letter-spacing: inherit; +} + +.column-drag-handle { + flex: 0 0 1.05rem; + color: var(--muted); + cursor: grab; + opacity: 0.35; + font-size: 0.56rem; + letter-spacing: -0.32rem; + text-align: center; +} + +.column-drag-handle:active { + cursor: grabbing; +} + +th:hover .column-drag-handle, +.column-drag-handle:focus-visible { + opacity: 0.9; +} + +.column-drag-handle:hover, +.sort-header-button:hover { + background: rgb(255 255 255 / 4%); + border-color: transparent; +} + +th.is-column-dragging { + opacity: 0.45; +} + +th.is-column-drop-target { + background: rgb(50 139 255 / 16%); + box-shadow: inset 4px 0 0 var(--blue); +} + +th.is-column-drop-target::before { + position: absolute; + z-index: 6; + top: -1px; + bottom: -1px; + left: -2px; + width: 4px; + background: #62a9ff; + box-shadow: + 0 0 0 1px rgb(0 0 0 / 55%), + 0 0 12px rgb(70 151 255 / 90%); + content: ''; + pointer-events: none; +} + +.sort-header-button { + display: flex; + min-width: 0; + flex: 1; + align-items: center; + justify-content: flex-start; + gap: 0.3rem; + padding-inline: 0.25rem var(--table-cell-inline-padding); + cursor: default; + text-align: inherit; +} + +.numeric-header .sort-header-button { + justify-content: flex-end; +} + +.sort-header-button.is-sortable { + cursor: pointer; +} + +.sort-header-button:disabled { + opacity: 1; +} + +.header-label { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.sort-indicator { + flex: 0 0 auto; + color: #66717e; + font-size: 0.72rem; +} + +.sort-indicator.is-active { + color: var(--blue-soft); +} + +.column-resize-handle { + position: absolute; + z-index: 3; + top: 0; + right: -3px; + width: 7px; + height: 100%; + cursor: col-resize; + touch-action: none; + user-select: none; +} + +.column-resize-handle::after { + position: absolute; + top: 20%; + right: 3px; + width: 1px; + height: 60%; + background: var(--border-strong); + content: ''; + opacity: 0; +} + +th:hover > .column-resize-handle::after, +.column-resize-handle.is-resizing::after { + background: var(--blue); + opacity: 1; +} + +tbody tr[aria-selected='true'] { + background: rgb(76 145 228 / 13%); +} + +td[aria-selected='true'] { + position: relative; + background: rgb(70 139 222 / 12%); +} + +td[data-cell-focused='true'] { + background: rgb(70 139 222 / 21%); +} + +td[aria-selected='true']::after { + position: absolute; + z-index: 1; + inset: 0; + border: 1px solid transparent; + content: ''; + pointer-events: none; +} + +td[data-selection-top='true']::after { + border-top-color: var(--blue); +} + +td[data-selection-right='true']::after { + border-right-color: var(--blue); +} + +td[data-selection-bottom='true']::after { + border-bottom-color: var(--blue); +} + +td[data-selection-left='true']::after { + border-left-color: var(--blue); +} + +.price-button { + min-width: 4.5rem; + padding: 0; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-variant-numeric: tabular-nums; + font-weight: 600; + text-align: right; +} + +.price-button:hover { + background: transparent; + text-decoration: underline; + text-underline-offset: 2px; +} + +.move-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.move-cell.quote-up, +.percent-change-cell.quote-up { + background: color-mix(in srgb, var(--green) 7%, transparent); +} + +.move-cell.quote-down, +.percent-change-cell.quote-down { + background: color-mix(in srgb, var(--red) 7%, transparent); +} + +.percent-change-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.spread-cell { + display: flex; + align-items: baseline; + justify-content: flex-end; + gap: 0.35rem; + color: var(--text); +} + +.spread-cell small { + min-width: 2.8rem; + color: var(--muted); + font-size: 0.55rem; +} + +.spread-cell.spread-wide, +.spread-cell.spread-wide small { + color: var(--amber); +} + +app-depth-cell, +app-stable-move-cell, +app-up-move-cell, +app-down-move-cell, +app-percent-change-cell, +app-sparkline-cell { + display: block; + width: 100%; +} + +.depth-cell { + position: relative; + display: flex; + height: 17px; + overflow: hidden; + background: var(--surface-control); +} + +.depth-bid, +.depth-ask { + height: 100%; + opacity: 0.78; +} + +.depth-bid { + background: var(--depth-bid); + border-right: 1px solid var(--panel); +} + +.depth-ask { + background: var(--depth-ask); +} + +.depth-values { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 0.28rem; + color: var(--text-strong); + font-size: 0.57rem; + text-shadow: 0 1px var(--background); +} + +.quote-age { + color: var(--muted); +} + +.quote-age-warm { + color: var(--amber); +} + +.quote-age-stale { + color: var(--red); +} + +.quote-up { + color: var(--green); +} + +.quote-down { + color: var(--red); +} + +.sparkline { + display: block; + width: 100%; + height: 1.35rem; + margin-left: auto; + color: var(--blue-soft); + overflow: visible; +} + +.sparkline.quote-up { + color: var(--green); +} + +.sparkline.quote-down { + color: var(--red); +} + +.sparkline polyline { + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-linejoin: miter; + stroke-width: 1.25; + vector-effect: non-scaling-stroke; +} + +.market-statusbar { + display: flex; + flex: 0 0 var(--statusbar-height); + min-height: var(--statusbar-height); + gap: 1.1rem; + align-items: center; + padding: 0 0.65rem; + color: var(--muted); + background: var(--surface-bar); + border-top: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.56rem; + grid-area: footer; + letter-spacing: 0.035em; +} + +.market-statusbar strong { + margin-left: 0.25rem; + color: var(--text); + font-weight: 500; +} + +.sidebar-slot { + width: var(--sidebar-width); + min-width: 0; + min-height: 0; + overflow: hidden; + background: var(--surface-table); + border-left: 1px solid var(--border); + grid-area: sidebar; + transition: + opacity 120ms ease, + transform 160ms ease, + visibility 160ms; +} + +.is-sidebar-collapsed .sidebar-slot { + visibility: hidden; + opacity: 0; + pointer-events: none; + transform: translateX(100%); +} + +.configurator { + width: 100%; + height: 100%; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +.configurator > header { + display: flex; + height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + color: var(--text-strong); + background: var(--surface-toolbar); + border-bottom: 1px solid var(--border); + font-size: 0.65rem; + font-weight: 700; + letter-spacing: 0.055em; +} + +.configurator > header small { + color: var(--muted); + font-size: 0.54rem; + font-weight: 500; +} + +.config-section { + display: grid; + gap: 0.7rem; + padding: 0.8rem var(--shell-inline-padding); + border-bottom: 1px solid var(--border); +} + +.config-section h2 { + margin: 0; + color: var(--muted); + font-size: 0.58rem; + letter-spacing: 0.075em; +} + +.primary-action { + width: 100%; + color: var(--text-inverse); + background: var(--blue); + border-color: var(--blue-soft); +} + +.primary-action:hover { + background: var(--blue-soft); + border-color: var(--text-strong); +} + +.field { + display: grid; + gap: 0.35rem; + color: var(--text); + font-size: 0.66rem; +} + +.rate-field > span { + display: flex; + justify-content: space-between; +} + +.rate-field strong { + color: var(--text); + font-family: var(--font-mono); + font-weight: 500; +} + +.field small { + color: var(--muted); + font-family: var(--font-mono); + font-size: 0.55rem; +} + +input[type='range'] { + width: 100%; + margin: 0; + accent-color: var(--blue); +} + +.toggle-field { + display: flex; + gap: 0.5rem; + align-items: flex-start; + color: var(--text); + font-size: 0.66rem; + line-height: 1.3; +} + +.toggle-field input { + margin: 0.12rem 0 0; + accent-color: var(--blue); +} + +.toggle-field small { + display: block; + margin-top: 0.14rem; + color: var(--muted); + font-size: 0.57rem; +} + +.action-grid { + display: grid; + grid-template-columns: 1fr; + gap: 0.4rem; +} + +.diagnostics dl, +.selected-instrument dl { + display: grid; + gap: 0; + margin: 0; +} + +.diagnostics dl > div, +.selected-instrument dl > div { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 24px; + border-bottom: 1px solid var(--border-soft); +} + +.diagnostics dl > div:last-child, +.selected-instrument dl > div:last-child { + border-bottom: 0; +} + +.diagnostics dl > div:has(dd[data-testid$='-breakdown']) { + display: grid; + grid-template-columns: minmax(0, 1fr); + align-content: center; + padding-block: 0.28rem; +} + +.diagnostics dd[data-testid$='-breakdown'] { + width: 100%; + overflow-x: auto; + padding-block: 0.12rem; + white-space: nowrap; + scrollbar-width: thin; +} + +.diagnostic-note { + margin: 0.5rem 0 0; + color: var(--muted); + font-size: 0.56rem; + line-height: 1.45; +} + +dt { + color: var(--muted); + font-size: 0.61rem; +} + +dd { + margin: 0; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.62rem; +} + +.selection { + display: flex; + align-items: flex-start; + justify-content: space-between; +} + +.selection div { + display: grid; + gap: 0.18rem; +} + +.selection strong { + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.85rem; +} + +.selection span, +.selection small, +.selected-instrument p { + color: var(--muted); + font-size: 0.61rem; +} + +.selected-instrument p { + margin: 0; + line-height: 1.45; +} + +@media (max-width: 980px) { + :root { + --sidebar-width: 15.625rem; + } +} + +@media (max-width: 720px) { + .trading-terminal { + --active-sidebar-width: 0px; + height: 100dvh; + min-height: 0; + overflow: hidden; + } + + .market-panel { + min-height: 0; + } + + .table-scroll { + min-height: 0; + } + + .sidebar-slot { + position: fixed; + z-index: 20; + top: 0; + right: 0; + bottom: 0; + width: min(var(--sidebar-width), calc(100vw - 2.75rem)); + box-shadow: -18px 0 42px rgb(0 0 0 / 48%); + } + + .is-sidebar-collapsed .sidebar-slot { + box-shadow: none; + } +} diff --git a/examples/angular/realtime-trading/tests/e2e/smoke.spec.ts b/examples/angular/realtime-trading/tests/e2e/smoke.spec.ts new file mode 100644 index 0000000000..637bba6bb5 --- /dev/null +++ b/examples/angular/realtime-trading/tests/e2e/smoke.spec.ts @@ -0,0 +1,250 @@ +import path from 'node:path' +import { expect, test } from '@playwright/test' +import { startExampleServer } from '../../../../../tests/e2e/helpers/startExampleServer' +import { + setRangeValue, + scrollTradingTable, + pauseTradingFeed, + resumeTradingFeed, + pausedFeedUrl, +} from '../../../../../tests/e2e/helpers/setRangeValue' +import type { Page } from '@playwright/test' + +const exampleDir = path.resolve() + +function collectPageErrors(page: Page) { + const errors: Array = [] + + page.on('pageerror', (error) => errors.push(error.message)) + page.on('console', (message) => { + if (message.type() === 'error') errors.push(message.text()) + }) + + return errors +} + +test('runs the Angular realtime trading workload', async ({ page }) => { + test.setTimeout(120_000) + const server = await startExampleServer(exampleDir) + const errors = collectPageErrors(page) + + try { + await page.goto(pausedFeedUrl(server.url)) + + const table = page.getByTestId('trading-table') + const instrumentCount = page.getByTestId('instrument-count-select') + const virtualScrollSelect = page.getByTestId('virtual-scroll-select') + await expect(table).toBeVisible() + await expect(instrumentCount).toHaveValue('100') + await expect(page.locator('.brand')).toHaveText('MARKET MONITOR') + await expect(virtualScrollSelect).toHaveValue('none') + await expect(virtualScrollSelect).toBeEnabled() + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(table.locator('tbody')).toHaveCSS('user-select', 'none') + await expect(table.locator('tbody tr').first()).toHaveCSS( + 'content-visibility', + 'auto', + ) + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await instrumentCount.selectOption('250') + await expect(virtualScrollSelect).toHaveValue('tanstack') + await expect(virtualScrollSelect).toBeEnabled() + await expect.poll(() => table.locator('tbody tr').count()).toBeLessThan(250) + await expect(page.getByTestId('virtual-scroll-footer')).toBeVisible() + await instrumentCount.selectOption('100') + await expect(virtualScrollSelect).toHaveValue('none') + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await virtualScrollSelect.selectOption('tanstack') + await expect.poll(() => table.locator('tbody tr').count()).toBeLessThan(100) + await expect(table.locator('tbody tr').first()).toHaveCSS( + 'content-visibility', + 'auto', + ) + await expect(page.getByTestId('virtual-scroll-footer')).toBeVisible() + await virtualScrollSelect.selectOption('none') + await expect(table.locator('tbody tr')).toHaveCount(100) + await pauseTradingFeed(page) + await instrumentCount.selectOption('1500') + await expect(virtualScrollSelect).toHaveValue('tanstack') + await expect(virtualScrollSelect).toBeDisabled() + await expect + .poll(() => table.locator('tbody tr').count()) + .toBeLessThan(1500) + await expect(page.getByTestId('virtual-scroll-footer')).toContainText( + 'Total · 1500 rows · 14 columns', + ) + await expect(page.getByTestId('visible-row-range')).toHaveText( + /^\s*Current · rows 0\.\.\d+\s*$/, + ) + await scrollTradingTable(page, 2_000) + await expect + .poll(async () => + Number( + await table + .locator('tbody tr') + .first() + .getAttribute('data-virtual-index'), + ), + ) + .toBeGreaterThan(0) + await expect(page.getByTestId('visible-row-range')).toHaveText( + /^\s*Current · rows [1-9]\d*\.\.\d+\s*$/, + ) + await instrumentCount.selectOption('100') + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await expect(virtualScrollSelect).toHaveValue('none') + await expect(virtualScrollSelect).toBeEnabled() + await expect(table.locator('tbody tr')).toHaveCount(100) + await resumeTradingFeed(page) + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await expect(virtualScrollSelect).toHaveValue('none') + await expect(virtualScrollSelect).toBeEnabled() + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(table.locator('thead tr')).toHaveCount(2) + await expect(table.locator('thead tr').last().locator('th')).toHaveCount(14) + await expect(table.locator('thead')).not.toContainText('Identity') + await expect(table.locator('thead')).not.toContainText('Market Data') + await expect(table.locator('thead')).toContainText('Market') + await expect(table.locator('thead')).toContainText('Bid Vol') + await expect(table.locator('thead')).toContainText('Intraday') + + const selectionStart = table.locator('tbody tr').nth(0).locator('td').nth(1) + const selectionEnd = table.locator('tbody tr').nth(2).locator('td').nth(3) + const selectedSymbol = await table + .locator('tbody tr') + .nth(0) + .getAttribute('data-symbol') + const selectionStartBox = await selectionStart.boundingBox() + const selectionEndBox = await selectionEnd.boundingBox() + if (!selectionStartBox || !selectionEndBox) { + throw new Error('Expected visible cells for the drag-selection check') + } + await page.mouse.move( + selectionStartBox.x + selectionStartBox.width / 2, + selectionStartBox.y + selectionStartBox.height / 2, + ) + await page.mouse.down() + await page.mouse.move( + selectionEndBox.x + selectionEndBox.width / 2, + selectionEndBox.y + selectionEndBox.height / 2, + { steps: 4 }, + ) + await page.mouse.up() + await expect(table.locator('td[aria-selected="true"]')).toHaveCount(9) + await expect(page.getByTestId('selected-instrument')).toContainText( + selectedSymbol ?? '', + ) + + await expect(page.getByTestId('feed-status')).toHaveText('FEED LIVE') + await expect(instrumentCount.locator('option[value="150"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="350"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="750"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="1500"]')).toHaveCount(1) + + const targetRateSlider = page.getByTestId('target-rate-slider') + await expect(targetRateSlider).toHaveAttribute('min', '0') + await expect(targetRateSlider).toHaveAttribute('max', '9') + await expect(targetRateSlider).toHaveAttribute('step', '1') + await expect(targetRateSlider).toHaveValue('6') + await setRangeValue(targetRateSlider, '7') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '25K samples/s', + ) + await setRangeValue(targetRateSlider, '8') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '50K samples/s', + ) + await setRangeValue(targetRateSlider, '6') + + const sparklineInterval = page.getByTestId( + 'sparkline-sample-interval-select', + ) + await expect(sparklineInterval).toHaveValue('16') + await sparklineInterval.selectOption('100') + await expect(sparklineInterval).toHaveValue('100') + await sparklineInterval.selectOption('16') + + const publishInterval = page.getByTestId('publish-interval-select') + await expect(publishInterval.locator('option[value="500"]')).toHaveCount(1) + await expect(publishInterval.locator('option[value="1000"]')).toHaveCount(1) + + await expect + .poll(async () => { + const text = await page.getByTestId('row-update-rate').textContent() + return Number(text?.replace(/\D/g, '') ?? 0) + }) + .toBeGreaterThan(0) + await expect + .poll(async () => { + const text = await page.getByTestId('worker-messages').textContent() + return Number(text?.replace(/\D/g, '') ?? 0) + }) + .toBeGreaterThan(0) + await expect + .poll(async () => + Number(await page.getByTestId('message-rate').textContent()), + ) + .toBeGreaterThan(0) + await expect + .poll(async () => + Number(await page.getByTestId('table-render-rate').textContent()), + ) + .toBeGreaterThan(0) + await expect(page.getByTestId('long-frame-count')).toHaveText( + /^\s*(?:N\/A|\d+)\s*$/, + ) + + const tableWorker = page.getByTestId('table-worker-toggle') + await expect(tableWorker).toBeEnabled() + await tableWorker.check() + await expect(page.getByText('ROW MODEL WORKER ON')).toBeVisible() + await expect(table.locator('tbody tr')).toHaveCount(100) + await instrumentCount.selectOption('1500') + await expect + .poll(() => table.locator('tbody tr').count()) + .toBeLessThan(1500) + await instrumentCount.selectOption('100') + await expect(table.locator('tbody tr')).toHaveCount(100) + await page.getByTestId('feed-toggle').click() + await expect + .poll(() => + page + .locator('app-worker-trading-table [data-table-worker-pending]') + .getAttribute('data-table-worker-compute-ms'), + ) + .not.toBeNull() + await expect( + page.locator('app-worker-trading-table [data-table-worker-pending]'), + ).toHaveAttribute('data-table-worker-pending', 'false') + await page.getByTestId('feed-toggle').click() + await tableWorker.uncheck() + + await expect(tableWorker).toBeEnabled() + await instrumentCount.selectOption('1500') + await expect + .poll(() => table.locator('tbody tr').count()) + .toBeLessThan(1500) + await expect(page.getByTestId('virtual-scroll-footer')).toBeVisible() + const firstPrice = table.locator('tbody tr').first().getByRole('button') + const priceBeforeUpdate = await firstPrice.textContent() + await expect + .poll(() => firstPrice.textContent()) + .not.toBe(priceBeforeUpdate) + await instrumentCount.selectOption('100') + await expect(table.locator('tbody tr')).toHaveCount(100) + + await page + .getByLabel( + 'Swap Tick component A ↔ B destroy and recreate when direction changes', + ) + .check() + await page.getByTestId('feed-toggle').click() + await expect(page.getByTestId('feed-toggle')).toHaveText('START FEED') + await expect(page.getByTestId('feed-status')).toHaveText('FEED PAUSED') + + expect(errors).toEqual([]) + } finally { + await server.close() + } +}) diff --git a/examples/angular/realtime-trading/tsconfig.app.json b/examples/angular/realtime-trading/tsconfig.app.json new file mode 100644 index 0000000000..8426ad9558 --- /dev/null +++ b/examples/angular/realtime-trading/tsconfig.app.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/app", + "types": [] + }, + "include": ["src/**/*.ts"], + "exclude": ["src/**/*.spec.ts"] +} diff --git a/examples/angular/realtime-trading/tsconfig.json b/examples/angular/realtime-trading/tsconfig.json new file mode 100644 index 0000000000..9ff0bce067 --- /dev/null +++ b/examples/angular/realtime-trading/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "skipLibCheck": true, + "isolatedModules": true, + "experimentalDecorators": true, + "importHelpers": true, + "target": "ES2022", + "module": "preserve" + }, + "angularCompilerOptions": { + "enableI18nLegacyMessageIdFormat": false, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true + }, + "include": ["**/*.ts", "tests/e2e"] +} diff --git a/examples/angular/remote-data/package.json b/examples/angular/remote-data/package.json index 4613cb45ed..6997e02f3e 100644 --- a/examples/angular/remote-data/package.json +++ b/examples/angular/remote-data/package.json @@ -14,28 +14,28 @@ "serve:ssr:remote-data": "node dist/remote-data/server/server.mjs" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/platform-browser-dynamic": "^22.1.1", - "@angular/platform-server": "^22.1.1", - "@angular/router": "^22.1.1", - "@angular/ssr": "^22.1.2", - "@tanstack/angular-table": "^9.2.1", - "express": "^5.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/platform-browser-dynamic": "^22.2.6", + "@angular/platform-server": "^22.2.6", + "@angular/router": "^22.2.6", + "@angular/ssr": "^22.2.7", + "@tanstack/angular-table": "^9.3.2", + "express": "^5.3.0", "rxjs": "~7.8.2" }, "devDependencies": { - "@angular-devkit/build-angular": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular-devkit/build-angular": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "@types/express": "^5.0.6", - "@types/node": "^26.2.0", - "tslib": "^2.8.1", + "@types/node": "^26.6.6", + "tslib": "^2.9.1", "typescript": "6.0.3" } } diff --git a/examples/angular/row-dnd/package.json b/examples/angular/row-dnd/package.json index 3f8fe4c0ea..76a553f389 100644 --- a/examples/angular/row-dnd/package.json +++ b/examples/angular/row-dnd/package.json @@ -11,24 +11,24 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/cdk": "^22.1.0", - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/cdk": "^22.2.7", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/row-pinning/package.json b/examples/angular/row-pinning/package.json index d824388dc7..575e7700c3 100644 --- a/examples/angular/row-pinning/package.json +++ b/examples/angular/row-pinning/package.json @@ -11,23 +11,23 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/row-selection-signal/package.json b/examples/angular/row-selection-signal/package.json index 26d3c96c93..7149c48504 100644 --- a/examples/angular/row-selection-signal/package.json +++ b/examples/angular/row-selection-signal/package.json @@ -12,26 +12,26 @@ "test:types": "tsc -p tsconfig.app.json --noEmit" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/animations": "^22.1.1", - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/platform-browser-dynamic": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-devtools": "^0.0.9", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-table-devtools": "^9.2.0", + "@angular/animations": "^22.2.6", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/platform-browser-dynamic": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-devtools": "^0.0.13", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-table-devtools": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/row-selection/package.json b/examples/angular/row-selection/package.json index 5f37b467cd..564719cea3 100644 --- a/examples/angular/row-selection/package.json +++ b/examples/angular/row-selection/package.json @@ -11,26 +11,26 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/cdk": "^22.1.0", - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-devtools": "^0.0.9", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-table-devtools": "^9.2.0", + "@angular/cdk": "^22.2.7", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-devtools": "^0.0.13", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-table-devtools": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/signal-input/package.json b/examples/angular/signal-input/package.json index 026eb94840..6d95653537 100644 --- a/examples/angular/signal-input/package.json +++ b/examples/angular/signal-input/package.json @@ -11,24 +11,24 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/cdk": "^22.1.0", - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/cdk": "^22.2.7", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/sorting/package.json b/examples/angular/sorting/package.json index 944fc0a135..4e04414acf 100644 --- a/examples/angular/sorting/package.json +++ b/examples/angular/sorting/package.json @@ -11,23 +11,23 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/sub-components/package.json b/examples/angular/sub-components/package.json index 26a94be76e..d1276fc512 100644 --- a/examples/angular/sub-components/package.json +++ b/examples/angular/sub-components/package.json @@ -11,23 +11,23 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/virtualized-columns/package.json b/examples/angular/virtualized-columns/package.json index cb437951c2..3db7cdbbfa 100644 --- a/examples/angular/virtualized-columns/package.json +++ b/examples/angular/virtualized-columns/package.json @@ -11,24 +11,24 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-virtual": "^6.0.2", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-virtual": "^6.1.12", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/virtualized-infinite-scrolling/package.json b/examples/angular/virtualized-infinite-scrolling/package.json index b1d5184d15..af3d9d1668 100644 --- a/examples/angular/virtualized-infinite-scrolling/package.json +++ b/examples/angular/virtualized-infinite-scrolling/package.json @@ -11,24 +11,24 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-virtual": "^6.0.2", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-virtual": "^6.1.12", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/virtualized-rows/package.json b/examples/angular/virtualized-rows/package.json index 0abfe2c4f7..4550cc1104 100644 --- a/examples/angular/virtualized-rows/package.json +++ b/examples/angular/virtualized-rows/package.json @@ -11,24 +11,24 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-virtual": "^6.0.2", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-virtual": "^6.1.12", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/with-tanstack-form/package.json b/examples/angular/with-tanstack-form/package.json index 230aab5c56..e0d5cdb364 100644 --- a/examples/angular/with-tanstack-form/package.json +++ b/examples/angular/with-tanstack-form/package.json @@ -11,27 +11,27 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-devtools": "^0.0.9", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-devtools": "^0.0.13", "@tanstack/angular-form": "^1.33.5", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-table-devtools": "^9.2.0", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-table-devtools": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1", - "zod": "^4.4.3" + "tslib": "^2.9.1", + "zod": "^4.6.7" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/angular/with-tanstack-query/package.json b/examples/angular/with-tanstack-query/package.json index fc1759e751..8e07743a8a 100644 --- a/examples/angular/with-tanstack-query/package.json +++ b/examples/angular/with-tanstack-query/package.json @@ -11,26 +11,26 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "private": true, - "packageManager": "pnpm@11.21.0", + "packageManager": "pnpm@12.18.0", "dependencies": { - "@angular/common": "^22.1.1", - "@angular/compiler": "^22.1.1", - "@angular/core": "^22.1.1", - "@angular/forms": "^22.1.1", - "@angular/platform-browser": "^22.1.1", - "@angular/router": "^22.1.1", - "@faker-js/faker": "^10.5.0", - "@tanstack/angular-devtools": "^0.0.9", - "@tanstack/angular-query-experimental": "^5.101.4", - "@tanstack/angular-table": "^9.2.1", - "@tanstack/angular-table-devtools": "^9.2.0", + "@angular/common": "^22.2.6", + "@angular/compiler": "^22.2.6", + "@angular/core": "^22.2.6", + "@angular/forms": "^22.2.6", + "@angular/platform-browser": "^22.2.6", + "@angular/router": "^22.2.6", + "@faker-js/faker": "^10.6.0", + "@tanstack/angular-devtools": "^0.0.13", + "@tanstack/angular-query-experimental": "^5.107.1", + "@tanstack/angular-table": "^9.3.2", + "@tanstack/angular-table-devtools": "^9.3.2", "rxjs": "~7.8.2", - "tslib": "^2.8.1" + "tslib": "^2.9.1" }, "devDependencies": { - "@angular/build": "^22.1.2", - "@angular/cli": "^22.1.2", - "@angular/compiler-cli": "^22.1.1", + "@angular/build": "^22.2.7", + "@angular/cli": "^22.2.7", + "@angular/compiler-cli": "^22.2.6", "typescript": "6.0.3" } } diff --git a/examples/ember/aggregation/babel.config.js b/examples/ember/aggregation/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/aggregation/babel.config.js +++ b/examples/ember/aggregation/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/aggregation/package.json b/examples/ember/aggregation/package.json index 47e8f313f1..2234d3bbcd 100644 --- a/examples/ember/aggregation/package.json +++ b/examples/ember/aggregation/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/basic-app-table/babel.config.js b/examples/ember/basic-app-table/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/basic-app-table/babel.config.js +++ b/examples/ember/basic-app-table/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/basic-app-table/package.json b/examples/ember/basic-app-table/package.json index c035f302f6..44476be23b 100644 --- a/examples/ember/basic-app-table/package.json +++ b/examples/ember/basic-app-table/package.json @@ -23,32 +23,33 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/basic-external-atoms/babel.config.js b/examples/ember/basic-external-atoms/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/basic-external-atoms/babel.config.js +++ b/examples/ember/basic-external-atoms/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/basic-external-atoms/package.json b/examples/ember/basic-external-atoms/package.json index 766c5213e2..40afb7ec59 100644 --- a/examples/ember/basic-external-atoms/package.json +++ b/examples/ember/basic-external-atoms/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/basic-external-state/babel.config.js b/examples/ember/basic-external-state/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/basic-external-state/babel.config.js +++ b/examples/ember/basic-external-state/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/basic-external-state/package.json b/examples/ember/basic-external-state/package.json index d11d562f34..268f9576f6 100644 --- a/examples/ember/basic-external-state/package.json +++ b/examples/ember/basic-external-state/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/basic-table/babel.config.js b/examples/ember/basic-table/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/basic-table/babel.config.js +++ b/examples/ember/basic-table/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/basic-table/package.json b/examples/ember/basic-table/package.json index 7aa97a6686..4048a74c7c 100644 --- a/examples/ember/basic-table/package.json +++ b/examples/ember/basic-table/package.json @@ -23,32 +23,33 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/cell-selection/app/templates/application.gts b/examples/ember/cell-selection/app/templates/application.gts index 8b4999aa94..348a15042d 100644 --- a/examples/ember/cell-selection/app/templates/application.gts +++ b/examples/ember/cell-selection/app/templates/application.gts @@ -2,7 +2,7 @@ import Component from '@glimmer/component' import { tracked } from '@glimmer/tracking' import { on } from '@ember/modifier' import { faker } from '@faker-js/faker' -import { createMultiHotkeyHandler } from '@tanstack/hotkeys' +import { onHotkeys, type EmberHotkeyDefinition } from '@tanstack/ember-hotkeys' import { FlexRenderCell, FlexRenderHeader, @@ -234,21 +234,49 @@ export default class CellSelectionTable extends Component { } // keyboard navigation is TanStack Hotkeys driving the table's imperative - // APIs; table-core ships no keydown handling of its own. Ember has no hotkeys - // adapter, so the framework-agnostic core handler is used directly. - onGridKeyDown = createMultiHotkeyHandler({ - ArrowUp: () => this.tableInstance.moveCellSelection('up'), - ArrowDown: () => this.tableInstance.moveCellSelection('down'), - ArrowLeft: () => this.tableInstance.moveCellSelection('left'), - ArrowRight: () => this.tableInstance.moveCellSelection('right'), - 'Shift+ArrowUp': () => this.tableInstance.extendCellSelection('up'), - 'Shift+ArrowDown': () => this.tableInstance.extendCellSelection('down'), - 'Shift+ArrowLeft': () => this.tableInstance.extendCellSelection('left'), - 'Shift+ArrowRight': () => this.tableInstance.extendCellSelection('right'), - 'Mod+A': () => this.tableInstance.selectAllCells(), - Escape: () => this.tableInstance.resetCellSelection(true), - 'Mod+C': () => this.copySelection(), - }) as unknown as (event: KeyboardEvent) => void + // APIs; table-core ships no keydown handling of its own. The `onHotkeys` + // modifier on the grid element scopes every binding to it, so the hotkeys + // only fire while the grid (or a cell inside it) has focus. + gridHotkeys: Array = [ + { + hotkey: 'ArrowUp', + callback: () => this.tableInstance.moveCellSelection('up'), + }, + { + hotkey: 'ArrowDown', + callback: () => this.tableInstance.moveCellSelection('down'), + }, + { + hotkey: 'ArrowLeft', + callback: () => this.tableInstance.moveCellSelection('left'), + }, + { + hotkey: 'ArrowRight', + callback: () => this.tableInstance.moveCellSelection('right'), + }, + { + hotkey: 'Shift+ArrowUp', + callback: () => this.tableInstance.extendCellSelection('up'), + }, + { + hotkey: 'Shift+ArrowDown', + callback: () => this.tableInstance.extendCellSelection('down'), + }, + { + hotkey: 'Shift+ArrowLeft', + callback: () => this.tableInstance.extendCellSelection('left'), + }, + { + hotkey: 'Shift+ArrowRight', + callback: () => this.tableInstance.extendCellSelection('right'), + }, + { hotkey: 'Mod+A', callback: () => this.tableInstance.selectAllCells() }, + { + hotkey: 'Escape', + callback: () => this.tableInstance.resetCellSelection(true), + }, + { hotkey: 'Mod+C', callback: () => this.copySelection() }, + ] refreshData = () => { this.data = makeData(20) @@ -393,7 +421,7 @@ export default class CellSelectionTable extends Component { columns
-
+
{{#each this.headerGroups as |headerGroup|}} diff --git a/examples/ember/cell-selection/babel.config.js b/examples/ember/cell-selection/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/cell-selection/babel.config.js +++ b/examples/ember/cell-selection/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/cell-selection/package.json b/examples/ember/cell-selection/package.json index 6ae78dfffe..c428d74801 100644 --- a/examples/ember/cell-selection/package.json +++ b/examples/ember/cell-selection/package.json @@ -23,34 +23,35 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", - "@tanstack/hotkeys": "^0.8.0", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-hotkeys": "^0.13.0", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/cell-spanning/babel.config.js b/examples/ember/cell-spanning/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/cell-spanning/babel.config.js +++ b/examples/ember/cell-spanning/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/cell-spanning/package.json b/examples/ember/cell-spanning/package.json index 08d7b61bd7..fd4072e7c9 100644 --- a/examples/ember/cell-spanning/package.json +++ b/examples/ember/cell-spanning/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/column-ordering/babel.config.js b/examples/ember/column-ordering/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/column-ordering/babel.config.js +++ b/examples/ember/column-ordering/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/column-ordering/package.json b/examples/ember/column-ordering/package.json index 94f134b61a..9f58c1128d 100644 --- a/examples/ember/column-ordering/package.json +++ b/examples/ember/column-ordering/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/column-pinning-split/babel.config.js b/examples/ember/column-pinning-split/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/column-pinning-split/babel.config.js +++ b/examples/ember/column-pinning-split/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/column-pinning-split/package.json b/examples/ember/column-pinning-split/package.json index 76fbc25c2d..5e14ee8009 100644 --- a/examples/ember/column-pinning-split/package.json +++ b/examples/ember/column-pinning-split/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/column-pinning-sticky/babel.config.js b/examples/ember/column-pinning-sticky/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/column-pinning-sticky/babel.config.js +++ b/examples/ember/column-pinning-sticky/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/column-pinning-sticky/package.json b/examples/ember/column-pinning-sticky/package.json index 107992dc09..d1ed3ff68c 100644 --- a/examples/ember/column-pinning-sticky/package.json +++ b/examples/ember/column-pinning-sticky/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/column-pinning/babel.config.js b/examples/ember/column-pinning/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/column-pinning/babel.config.js +++ b/examples/ember/column-pinning/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/column-pinning/package.json b/examples/ember/column-pinning/package.json index b972ebf630..237b034965 100644 --- a/examples/ember/column-pinning/package.json +++ b/examples/ember/column-pinning/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/column-resizing-performant/babel.config.js b/examples/ember/column-resizing-performant/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/column-resizing-performant/babel.config.js +++ b/examples/ember/column-resizing-performant/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/column-resizing-performant/package.json b/examples/ember/column-resizing-performant/package.json index 1a48d6bd5a..00bf3292e2 100644 --- a/examples/ember/column-resizing-performant/package.json +++ b/examples/ember/column-resizing-performant/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/column-resizing/babel.config.js b/examples/ember/column-resizing/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/column-resizing/babel.config.js +++ b/examples/ember/column-resizing/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/column-resizing/package.json b/examples/ember/column-resizing/package.json index b45904cbb2..bf85296ce4 100644 --- a/examples/ember/column-resizing/package.json +++ b/examples/ember/column-resizing/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/column-sizing/babel.config.js b/examples/ember/column-sizing/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/column-sizing/babel.config.js +++ b/examples/ember/column-sizing/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/column-sizing/package.json b/examples/ember/column-sizing/package.json index 4f6e248cff..545c298f14 100644 --- a/examples/ember/column-sizing/package.json +++ b/examples/ember/column-sizing/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/column-visibility/babel.config.js b/examples/ember/column-visibility/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/column-visibility/babel.config.js +++ b/examples/ember/column-visibility/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/column-visibility/package.json b/examples/ember/column-visibility/package.json index 10206470bd..92d1efd993 100644 --- a/examples/ember/column-visibility/package.json +++ b/examples/ember/column-visibility/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/custom-plugin/babel.config.js b/examples/ember/custom-plugin/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/custom-plugin/babel.config.js +++ b/examples/ember/custom-plugin/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/custom-plugin/package.json b/examples/ember/custom-plugin/package.json index a1a26bc1ed..110457a0ed 100644 --- a/examples/ember/custom-plugin/package.json +++ b/examples/ember/custom-plugin/package.json @@ -23,34 +23,35 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", - "@tanstack/table-core": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", + "@tanstack/table-core": "^9.3.1", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/editable/babel.config.js b/examples/ember/editable/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/editable/babel.config.js +++ b/examples/ember/editable/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/editable/package.json b/examples/ember/editable/package.json index 6ef149e43b..ea120b6af1 100644 --- a/examples/ember/editable/package.json +++ b/examples/ember/editable/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/expanding/babel.config.js b/examples/ember/expanding/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/expanding/babel.config.js +++ b/examples/ember/expanding/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/expanding/package.json b/examples/ember/expanding/package.json index 99afdd3689..09bf08048c 100644 --- a/examples/ember/expanding/package.json +++ b/examples/ember/expanding/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/filters-faceted-bucketed/babel.config.js b/examples/ember/filters-faceted-bucketed/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/filters-faceted-bucketed/babel.config.js +++ b/examples/ember/filters-faceted-bucketed/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/filters-faceted-bucketed/package.json b/examples/ember/filters-faceted-bucketed/package.json index d1aa61e3a0..6251113c45 100644 --- a/examples/ember/filters-faceted-bucketed/package.json +++ b/examples/ember/filters-faceted-bucketed/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/filters-faceted/babel.config.js b/examples/ember/filters-faceted/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/filters-faceted/babel.config.js +++ b/examples/ember/filters-faceted/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/filters-faceted/package.json b/examples/ember/filters-faceted/package.json index 810b2e8e8f..538168a248 100644 --- a/examples/ember/filters-faceted/package.json +++ b/examples/ember/filters-faceted/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/filters-fuzzy/babel.config.js b/examples/ember/filters-fuzzy/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/filters-fuzzy/babel.config.js +++ b/examples/ember/filters-fuzzy/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/filters-fuzzy/package.json b/examples/ember/filters-fuzzy/package.json index 5ec8bd6ea7..df875b023d 100644 --- a/examples/ember/filters-fuzzy/package.json +++ b/examples/ember/filters-fuzzy/package.json @@ -23,34 +23,35 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", - "@tanstack/match-sorter-utils": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", + "@tanstack/match-sorter-utils": "^9.2.6", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/filters/babel.config.js b/examples/ember/filters/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/filters/babel.config.js +++ b/examples/ember/filters/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/filters/package.json b/examples/ember/filters/package.json index 02cd9150bf..a813d976f6 100644 --- a/examples/ember/filters/package.json +++ b/examples/ember/filters/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/grouped-aggregation/babel.config.js b/examples/ember/grouped-aggregation/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/grouped-aggregation/babel.config.js +++ b/examples/ember/grouped-aggregation/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/grouped-aggregation/package.json b/examples/ember/grouped-aggregation/package.json index 38f4b0b0c4..827c4a407d 100644 --- a/examples/ember/grouped-aggregation/package.json +++ b/examples/ember/grouped-aggregation/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/grouping/babel.config.js b/examples/ember/grouping/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/grouping/babel.config.js +++ b/examples/ember/grouping/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/grouping/package.json b/examples/ember/grouping/package.json index 282fe76b2c..677469966d 100644 --- a/examples/ember/grouping/package.json +++ b/examples/ember/grouping/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/header-groups/babel.config.js b/examples/ember/header-groups/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/header-groups/babel.config.js +++ b/examples/ember/header-groups/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/header-groups/package.json b/examples/ember/header-groups/package.json index f199ea60a1..508bd6248f 100644 --- a/examples/ember/header-groups/package.json +++ b/examples/ember/header-groups/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/kitchen-sink/babel.config.js b/examples/ember/kitchen-sink/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/kitchen-sink/babel.config.js +++ b/examples/ember/kitchen-sink/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/kitchen-sink/package.json b/examples/ember/kitchen-sink/package.json index 4ed106483b..a7dd32028b 100644 --- a/examples/ember/kitchen-sink/package.json +++ b/examples/ember/kitchen-sink/package.json @@ -23,34 +23,35 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", - "@tanstack/match-sorter-utils": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", + "@tanstack/match-sorter-utils": "^9.2.6", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/pagination/babel.config.js b/examples/ember/pagination/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/pagination/babel.config.js +++ b/examples/ember/pagination/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/pagination/package.json b/examples/ember/pagination/package.json index 502b6f66d9..1433942bb7 100644 --- a/examples/ember/pagination/package.json +++ b/examples/ember/pagination/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/realtime-trading/README.md b/examples/ember/realtime-trading/README.md new file mode 100644 index 0000000000..141a8603fb --- /dev/null +++ b/examples/ember/realtime-trading/README.md @@ -0,0 +1,154 @@ +# Ember realtime trading benchmark + +This standalone example exercises the current TanStack Ember Table adapter +with a high-frequency worker feed, immutable snapshots, interactive columns, +Glimmer quote components, Virtual Core, and browser diagnostics. It is a +repeatable rendering stress workload, not an exchange or network benchmark. + +## Run and verify + +```bash +pnpm --dir examples/ember/realtime-trading dev +``` + +Open `http://localhost:7777`. + +```bash +pnpm --dir examples/ember/realtime-trading test:types +pnpm --dir examples/ember/realtime-trading build +pnpm --dir examples/ember/realtime-trading test:e2e +``` + +This example currently has no separate `lint` package script. Use a production +build for performance recordings. + +## Structure and ownership + +| Path | Responsibility | +| ------------------------------- | ---------------------------------------------------------------------------------------------------------------- | +| `app/feed/` | Market model, instrument universe, configuration, immutable update helpers, and Ember-native tracked controller. | +| `app/feed/worker/` | Typed protocol, deterministic engine, and module worker. | +| `app/benchmark/` | Browser monitor and benchmark controller. | +| `app/components/shell/` | GTS header, metrics, configurator, diagnostics, selected instrument, status bar, and shell layout. | +| `app/components/table/` | Trading table Glimmer component. | +| `app/table/table-config/` | Grouped columns and custom GTS quote components. | +| `app/table/` | Table construction, features, delegated interactions, and Virtual Core integration. | +| `app/utils/subscriptions.ts` | Owner-bound destruction cleanup helper. | +| `app/templates/application.gts` | Creates feed/benchmark controllers and composes the shell. | + +`MarketFeedController` owns worker/feed state. `TradingBenchmarkController` +observes feed lifecycle callbacks and owns diagnostic/view state. The +application passes stable controllers to shell/table components; Glimmer +components read the controller's `@tracked` properties directly. `quotes` is +its own high-frequency tracked property; feed status and each configuration +value are separate tracked properties. Derived benchmark values use `@cached`. +There is no foreign Store subscription or mirrored component state, and the +root does not proxy every quote or metric as application state. + +## Feed and worker pipeline + +Defaults are 100 instruments, 10K generated samples/s, 20 ms delivery, enabled +intraday charts, and 16 ms chart sampling. + +Mutable quote state is private to the worker. A deterministic 16 ms budget loop +generates samples, a row-indexed `Map` coalesces repeated changes, and a separate +timer publishes the latest unique rows. The main thread creates a new outer +array and replaces only changed rows; untouched rows and unsampled history +arrays retain references. Session IDs reject stale messages after resets or +instrument-count changes. + +- **Synthetic quote workload** is worker-generated samples/s, not Glimmer + renders, events, or messages. +- **Worker delivery interval** controls coalesced message cadence; 20 ms targets + around 50 messages/s. +- **Row updates** is the number of unique immutable rows applied. +- **Message samples** is the generated work represented by the latest message. + +Intraday history uses its own cadence. The 25K burst deliberately publishes one +heavy batch. The worker resembles an upstream stream, without network latency. + +## Ember table architecture + +The grid has 14 leaf columns grouped into Instrument, Price & Change, Order +Book, Session, and Chart. It includes sorting/filtering, on-change resizing, +double-click reset, drag ordering, CSS hover, row selection, drag cell ranges, +keyboard navigation, and Price/Move/Percent/Sparkline Glimmer components. + +`flexRenderComponent` is used for actual component cells. Stable instrument IDs +back row identity. One table/body interaction path resolves cells through +`event.composedPath()` and data attributes instead of allocating handlers on +every cell. Column widths are CSS variables updated on sizing/order; a +`ResizeObserver` performs initial fitting until manual resize. The +CSS-variable string is an `@cached` getter that reads Ember-reactive table +sizing and order, so the first fit and later table updates reach the DOM +without an imperative Store subscription. A/B move component swapping is an +explicit lifecycle stress mode. + +## Virtualization + +- Below 200 rows, automatic mode uses Full DOM, while Virtual is selectable. +- From 200 through 1,499 rows, automatic mode uses TanStack Virtual and Full DOM + remains selectable. +- At 1,500 rows or more, Virtual is forced and its control is disabled. + +The local Virtual Core integration owns one instance with 32 px estimates, +10-row overscan, stable row IDs, transformed rows, and a spacer body. Instance +notifications invalidate only the table range, and the footer reads that range. +Both Full DOM and virtual rows use `content-visibility: auto`; Full DOM still +creates every Glimmer row/cell. + +## Performance decisions + +- worker-side generation and pre-message coalescing; +- immutable structural sharing for rows/history; +- direct `@tracked` feed/view state and `@cached` derived state; +- stable table and virtual row identity; +- componentized GTS shell/table/cell boundaries; +- delegated pointer input and CSS hover; +- CSS variables for width propagation; +- opt-in lifecycle churn and independently sampled charts; +- virtual mounting for larger row counts; +- explicit destructor cleanup and lower-frequency metric publication. + +The outer array intentionally changes for an immutable batch. Structural +sharing reduces cell work, but sorting/filtering can still trigger row-model +processing when data changes. + +## Diagnostics and interpretation + +The compact **Live health** section lives in the configurator and reports the +estimated frame callback rate over 1 second, average market-mutation-to-DOM- +commit latency over 3 seconds, cumulative long animation frames, and throughput +as changed rows plus applied snapshots per second. Detailed diagnostics retain +worker samples/messages, state applies, DOM commits, rolling 10-second p95/max +commit latency, cumulative slow commits, mounted hosts, component +lifecycle/execution, row-model timing, DOM mutation records, and heap. + +The frame value counts `requestAnimationFrame` callbacks, not GPU-presented +frames, so its ceiling follows the display refresh rate. Renderer callbacks and +DOM mutations are different measurements. `MutationObserver` counts delivered +records, not individual DOM operations, and has overhead on a hot subtree; it +only observes text, child-list, and `class`/`style` changes to reduce selection +noise. Heap is a Chromium-only, GC-sensitive point-in-time value. User Timing +timeline measures are sampled 1-in-20 while the in-memory latency calculation +keeps every commit, reducing profiler self-interference. Temporary heap growth +during component swapping is not a leak without post-GC retention. +The rAF loop only appends a timestamp; rolling aggregation and heap reads run at +the 500 ms metrics publication cadence. Mutation observation remains the most +intrusive diagnostic because the browser must create records for the observed +subtree. + +`Changed rows/s` sums the update array lengths delivered by each snapshot. +Symbols are deduplicated inside one message, but the same row can count again in +the next snapshot; it is applied row throughput, not distinct instruments per +second. + +## Standalone policy + +All instruments, feed, worker, benchmark, shell, styles, and table code are +copied into this directory intentionally. It remains independently runnable and +StackBlitz-friendly, so common implementation and README material is repeated +across adapters by design. + +The workspace resolves `@tanstack/ember-table` to the repository adapter while +the example package remains release-like. diff --git a/examples/ember/realtime-trading/app/app.css b/examples/ember/realtime-trading/app/app.css new file mode 100644 index 0000000000..de3e3d9155 --- /dev/null +++ b/examples/ember/realtime-trading/app/app.css @@ -0,0 +1,1014 @@ +:root { + color-scheme: dark; + --font-ui: + Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, + 'Segoe UI', sans-serif; + --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace; + font-family: var(--font-ui); + font-synthesis: none; + --background: #050505; + --panel: #080808; + --panel-raised: #111111; + --panel-hover: #181818; + --surface-bar: #080808; + --surface-toolbar: #0d0d0d; + --surface-table: #050505; + --surface-header: #101010; + --surface-control: #151515; + --border: #303030; + --border-soft: #242424; + --border-strong: #4a4a4a; + --text: #e7ebf0; + --text-strong: #ffffff; + --text-inverse: #f7f9fb; + --muted: #737982; + --blue: #62a9ff; + --blue-soft: #a9d0ff; + --green: #42e488; + --red: #ff646b; + --amber: #dfb465; + --depth-bid: #315774; + --depth-ask: #634049; + --row-alt: rgb(255 255 255 / 1.8%); + --row-selected: rgb(66 132 214 / 16%); + --control-border: #354456; + --control-hover: #192431; + --sidebar-width: 18rem; + --shell-bar-height: 2.625rem; + --metrics-height: 3.5rem; + --statusbar-height: 1.625rem; + --table-header-height: 2rem; + --table-row-height: 2rem; + --shell-inline-padding: 0.75rem; + --table-cell-inline-padding: 0.6rem; + --control-radius: 1px; +} + +* { + box-sizing: border-box; +} + +html, +body { + min-width: 320px; + min-height: 100%; + margin: 0; + background: var(--background); +} + +body { + color: var(--text); +} + +button, +select, +input { + font: inherit; +} + +button, +select { + color: var(--text); + background: var(--panel-raised); + border: 1px solid var(--control-border); + border-radius: var(--control-radius); +} + +button { + padding: 0.5rem 0.65rem; + cursor: pointer; + font-size: 0.72rem; + font-weight: 650; + letter-spacing: 0.025em; +} + +button:hover { + background: var(--control-hover); + border-color: var(--border-strong); +} + +button:focus-visible, +select:focus-visible, +input:focus-visible { + outline: 1px solid var(--blue); + outline-offset: 1px; +} + +select { + width: 100%; + padding: 0.45rem 0.55rem; + font-size: 0.75rem; +} + +.trading-terminal { + --active-sidebar-width: var(--sidebar-width); + display: grid; + width: 100%; + height: 100dvh; + min-height: 0; + overflow: hidden; + background: var(--background); + grid-template-areas: + 'header sidebar' + 'content sidebar' + 'footer sidebar'; + grid-template-columns: minmax(0, 1fr) var(--active-sidebar-width); + grid-template-rows: auto minmax(0, 1fr) auto; + transition: grid-template-columns 160ms ease; +} + +.trading-terminal.is-sidebar-collapsed { + --active-sidebar-width: 0px; +} + +.shell-header { + display: flex; + min-width: 0; + flex-direction: column; + grid-area: header; +} + +.app-bar { + display: flex; + min-height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + background: var(--surface-bar); + border-bottom: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.68rem; + letter-spacing: 0.045em; +} + +.brand, +.header-actions, +.feed-status { + display: flex; + align-items: center; +} + +.brand { + gap: 0.65rem; + color: var(--text-strong); +} + +.header-actions { + gap: 0.75rem; +} + +.sidebar-toggle { + display: grid; + width: 1.9rem; + height: 1.9rem; + padding: 0; + place-items: center; + color: var(--muted); + background: transparent; + border-color: transparent; +} + +.sidebar-toggle:hover { + color: var(--text-strong); + background: var(--surface-control); + border-color: var(--border); +} + +.sidebar-toggle svg { + width: 1rem; + height: 1rem; + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-width: 1.4; +} + +.feed-status { + gap: 0.4rem; + color: var(--muted); +} + +.feed-status.is-running { + color: var(--green); +} + +.status-dot { + width: 6px; + height: 6px; + background: var(--muted); + border-radius: 50%; +} + +.feed-status.is-running .status-dot { + background: var(--green); +} + +.development-warning { + flex: 0 0 auto; + padding: 0.3rem 0.75rem; + color: var(--amber); + background: color-mix(in srgb, var(--amber) 8%, var(--background)); + border-bottom: 1px solid color-mix(in srgb, var(--amber) 24%, var(--border)); + font-family: var(--font-mono); + font-size: 0.62rem; + letter-spacing: 0.04em; +} + +.market-panel { + display: flex; + min-width: 0; + min-height: 0; + flex-direction: column; + background: var(--panel); + grid-area: content; +} + +.metrics-strip { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + background: var(--border); + border-bottom: 1px solid var(--border); + gap: 1px; +} + +.metrics-strip h2 { + margin: 0; + padding: 0.65rem var(--shell-inline-padding) 0.45rem; + color: var(--muted); + background: var(--surface-table); + font-size: 0.58rem; + grid-column: 1 / -1; + letter-spacing: 0.075em; +} + +.metrics-strip article { + min-width: 0; + min-height: 4.25rem; + padding: 0.5rem var(--shell-inline-padding); + background: var(--surface-bar); +} + +.metrics-strip span, +.metrics-strip small { + display: block; + color: var(--muted); + font-size: 0.56rem; + letter-spacing: 0.045em; + line-height: 1.35; +} + +.metrics-strip strong { + display: block; + margin: 0.12rem 0 0.08rem; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.88rem; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +.metrics-strip strong.metric-alert { + color: var(--amber); +} + +.table-scroll { + flex: 1; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +table { + min-width: 100%; + border-spacing: 0; + table-layout: fixed; + font-family: var(--font-ui); + font-size: 0.78rem; + font-variant-numeric: tabular-nums; +} + +.trading-data-grid { + display: grid; +} + +.trading-data-grid thead, +.trading-data-grid tbody { + display: grid; +} + +.trading-data-grid tbody { + -webkit-user-select: none; + user-select: none; +} + +.trading-data-grid thead > tr, +.trading-data-grid tbody > tr { + display: flex; + width: 100%; +} + +.trading-data-grid tbody > tr { + min-height: var(--table-row-height); + content-visibility: auto; + contain-intrinsic-block-size: var(--table-row-height); +} + +.trading-data-grid th, +.trading-data-grid td { + flex: 0 0 auto; +} + +thead { + position: sticky; + z-index: 2; + top: 0; +} + +th { + height: var(--table-header-height); + padding: 0 var(--table-cell-inline-padding); + color: var(--muted); + background: var(--surface-header); + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border); + font-size: 0.7rem; + font-weight: 500; + letter-spacing: 0.005em; + text-align: left; + white-space: nowrap; +} + +th.column-group-header { + color: #666b72; + font-size: 0.72rem; + font-weight: 500; + text-align: center; +} + +thead tr:first-child th.column-group-header { + color: #777d85; + font-size: 0.76rem; +} + +th.numeric-header { + text-align: right; +} + +td { + height: var(--table-row-height); + padding: 0 var(--table-cell-inline-padding); + overflow: hidden; + color: #eef1f5; + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border-soft); + text-align: right; + text-overflow: ellipsis; + white-space: nowrap; +} + +th:last-child, +td:last-child { + border-right: 0; +} + +td[data-column-id='market'], +td[data-column-id='name'], +td[data-column-id='symbol'] { + text-align: left; +} + +td[data-column-id='market'] { + color: var(--blue); + font-weight: 550; +} + +td[data-column-id='name'] { + color: var(--text-strong); +} + +td[data-column-id='symbol'] { + color: #d8dde4; + font-weight: 600; +} + +tbody tr:nth-child(even) { + background: var(--row-alt); +} + +tbody tr:hover { + background: var(--panel-hover); +} + +tbody tr[data-symbol-selected='true'] { + background: var(--row-selected); + box-shadow: inset 2px 0 0 var(--blue); +} + +.table-scroll:focus { + outline: none; +} + +th { + position: relative; +} + +.leaf-header-content { + display: flex; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + height: 100%; + align-items: stretch; + margin-inline: calc(-1 * var(--table-cell-inline-padding)); +} + +.column-drag-handle, +.sort-header-button { + min-width: 0; + height: 100%; + padding: 0; + color: inherit; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-weight: inherit; + letter-spacing: inherit; +} + +.column-drag-handle { + flex: 0 0 1.05rem; + color: var(--muted); + cursor: grab; + opacity: 0.35; + font-size: 0.56rem; + letter-spacing: -0.32rem; + text-align: center; +} + +.column-drag-handle:active { + cursor: grabbing; +} + +th:hover .column-drag-handle, +.column-drag-handle:focus-visible { + opacity: 0.9; +} + +.column-drag-handle:hover, +.sort-header-button:hover { + background: rgb(255 255 255 / 4%); + border-color: transparent; +} + +th.is-column-dragging { + opacity: 0.45; +} + +th.is-column-drop-target { + background: rgb(50 139 255 / 16%); + box-shadow: inset 4px 0 0 var(--blue); +} + +th.is-column-drop-target::before { + position: absolute; + z-index: 6; + top: -1px; + bottom: -1px; + left: -2px; + width: 4px; + background: #62a9ff; + box-shadow: + 0 0 0 1px rgb(0 0 0 / 55%), + 0 0 12px rgb(70 151 255 / 90%); + content: ''; + pointer-events: none; +} + +.sort-header-button { + display: flex; + min-width: 0; + flex: 1; + align-items: center; + justify-content: flex-start; + gap: 0.3rem; + padding-inline: 0.25rem var(--table-cell-inline-padding); + cursor: default; + text-align: inherit; +} + +.numeric-header .sort-header-button { + justify-content: flex-end; +} + +.sort-header-button.is-sortable { + cursor: pointer; +} + +.sort-header-button:disabled { + opacity: 1; +} + +.header-label { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.sort-indicator { + flex: 0 0 auto; + color: #66717e; + font-size: 0.72rem; +} + +.sort-indicator.is-active { + color: var(--blue-soft); +} + +.column-resize-handle { + position: absolute; + z-index: 3; + top: 0; + right: -3px; + width: 7px; + height: 100%; + cursor: col-resize; + touch-action: none; + user-select: none; +} + +.column-resize-handle::after { + position: absolute; + top: 20%; + right: 3px; + width: 1px; + height: 60%; + background: var(--border-strong); + content: ''; + opacity: 0; +} + +th:hover > .column-resize-handle::after, +.column-resize-handle.is-resizing::after { + background: var(--blue); + opacity: 1; +} + +tbody tr[aria-selected='true'] { + background: rgb(76 145 228 / 13%); +} + +td[aria-selected='true'] { + position: relative; + background: rgb(70 139 222 / 12%); +} + +td[data-cell-focused='true'] { + background: rgb(70 139 222 / 21%); +} + +td[aria-selected='true']::after { + position: absolute; + z-index: 1; + inset: 0; + border: 1px solid transparent; + content: ''; + pointer-events: none; +} + +td[data-selection-top='true']::after { + border-top-color: var(--blue); +} + +td[data-selection-right='true']::after { + border-right-color: var(--blue); +} + +td[data-selection-bottom='true']::after { + border-bottom-color: var(--blue); +} + +td[data-selection-left='true']::after { + border-left-color: var(--blue); +} + +.price-button { + min-width: 4.5rem; + padding: 0; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-variant-numeric: tabular-nums; + font-weight: 600; + text-align: right; +} + +.price-button:hover { + background: transparent; + text-decoration: underline; + text-underline-offset: 2px; +} + +.move-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.move-cell.quote-up, +.percent-change-cell.quote-up { + background: color-mix(in srgb, var(--green) 7%, transparent); +} + +.move-cell.quote-down, +.percent-change-cell.quote-down { + background: color-mix(in srgb, var(--red) 7%, transparent); +} + +.percent-change-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.spread-cell { + display: flex; + align-items: baseline; + justify-content: flex-end; + gap: 0.35rem; + color: var(--text); +} + +.spread-cell small { + min-width: 2.8rem; + color: var(--muted); + font-size: 0.55rem; +} + +.spread-cell.spread-wide, +.spread-cell.spread-wide small { + color: var(--amber); +} + +.depth-cell { + position: relative; + display: flex; + height: 17px; + overflow: hidden; + background: var(--surface-control); +} + +.depth-bid, +.depth-ask { + height: 100%; + opacity: 0.78; +} + +.depth-bid { + background: var(--depth-bid); + border-right: 1px solid var(--panel); +} + +.depth-ask { + background: var(--depth-ask); +} + +.depth-values { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 0.28rem; + color: var(--text-strong); + font-size: 0.57rem; + text-shadow: 0 1px var(--background); +} + +.quote-age { + color: var(--muted); +} + +.quote-age-warm { + color: var(--amber); +} + +.quote-age-stale { + color: var(--red); +} + +.quote-up { + color: var(--green); +} + +.quote-down { + color: var(--red); +} + +.sparkline { + display: block; + width: 100%; + height: 1.35rem; + margin-left: auto; + color: var(--blue-soft); + overflow: visible; +} + +.sparkline.quote-up { + color: var(--green); +} + +.sparkline.quote-down { + color: var(--red); +} + +.sparkline polyline { + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-linejoin: miter; + stroke-width: 1.25; + vector-effect: non-scaling-stroke; +} + +.market-statusbar { + display: flex; + flex: 0 0 var(--statusbar-height); + min-height: var(--statusbar-height); + gap: 1.1rem; + align-items: center; + padding: 0 0.65rem; + color: var(--muted); + background: var(--surface-bar); + border-top: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.56rem; + grid-area: footer; + letter-spacing: 0.035em; +} + +.market-statusbar strong { + margin-left: 0.25rem; + color: var(--text); + font-weight: 500; +} + +.sidebar-slot { + width: var(--sidebar-width); + min-width: 0; + min-height: 0; + overflow: hidden; + background: var(--surface-table); + border-left: 1px solid var(--border); + grid-area: sidebar; + transition: + opacity 120ms ease, + transform 160ms ease, + visibility 160ms; +} + +.is-sidebar-collapsed .sidebar-slot { + visibility: hidden; + opacity: 0; + pointer-events: none; + transform: translateX(100%); +} + +.configurator { + width: 100%; + height: 100%; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +.configurator > header { + display: flex; + height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + color: var(--text-strong); + background: var(--surface-toolbar); + border-bottom: 1px solid var(--border); + font-size: 0.65rem; + font-weight: 700; + letter-spacing: 0.055em; +} + +.configurator > header small { + color: var(--muted); + font-size: 0.54rem; + font-weight: 500; +} + +.config-section { + display: grid; + gap: 0.7rem; + padding: 0.8rem var(--shell-inline-padding); + border-bottom: 1px solid var(--border); +} + +.config-section h2 { + margin: 0; + color: var(--muted); + font-size: 0.58rem; + letter-spacing: 0.075em; +} + +.primary-action { + width: 100%; + color: var(--text-inverse); + background: var(--blue); + border-color: var(--blue-soft); +} + +.primary-action:hover { + background: var(--blue-soft); + border-color: var(--text-strong); +} + +.field { + display: grid; + gap: 0.35rem; + color: var(--text); + font-size: 0.66rem; +} + +.rate-field > span { + display: flex; + justify-content: space-between; +} + +.rate-field strong { + color: var(--text); + font-family: var(--font-mono); + font-weight: 500; +} + +.field small { + color: var(--muted); + font-family: var(--font-mono); + font-size: 0.55rem; +} + +input[type='range'] { + width: 100%; + margin: 0; + accent-color: var(--blue); +} + +.toggle-field { + display: flex; + gap: 0.5rem; + align-items: flex-start; + color: var(--text); + font-size: 0.66rem; + line-height: 1.3; +} + +.toggle-field input { + margin: 0.12rem 0 0; + accent-color: var(--blue); +} + +.toggle-field small { + display: block; + margin-top: 0.14rem; + color: var(--muted); + font-size: 0.57rem; +} + +.action-grid { + display: grid; + grid-template-columns: 1fr; + gap: 0.4rem; +} + +.diagnostics dl, +.selected-instrument dl { + display: grid; + gap: 0; + margin: 0; +} + +.diagnostics dl > div, +.selected-instrument dl > div { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 24px; + border-bottom: 1px solid var(--border-soft); +} + +.diagnostics dl > div:last-child, +.selected-instrument dl > div:last-child { + border-bottom: 0; +} + +.diagnostics dl > div:has(dd[data-testid$='-breakdown']) { + display: grid; + grid-template-columns: minmax(0, 1fr); + align-content: center; + padding-block: 0.28rem; +} + +.diagnostics dd[data-testid$='-breakdown'] { + width: 100%; + overflow-x: auto; + padding-block: 0.12rem; + white-space: nowrap; + scrollbar-width: thin; +} + +.diagnostic-note { + margin: 0.5rem 0 0; + color: var(--muted); + font-size: 0.56rem; + line-height: 1.45; +} + +dt { + color: var(--muted); + font-size: 0.61rem; +} + +dd { + margin: 0; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.62rem; +} + +.selection { + display: flex; + align-items: flex-start; + justify-content: space-between; +} + +.selection div { + display: grid; + gap: 0.18rem; +} + +.selection strong { + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.85rem; +} + +.selection span, +.selection small, +.selected-instrument p { + color: var(--muted); + font-size: 0.61rem; +} + +.selected-instrument p { + margin: 0; + line-height: 1.45; +} + +@media (max-width: 980px) { + :root { + --sidebar-width: 15.625rem; + } +} + +@media (max-width: 720px) { + .trading-terminal { + --active-sidebar-width: 0px; + height: 100dvh; + min-height: 0; + overflow: hidden; + } + + .market-panel { + min-height: 0; + } + + .table-scroll { + min-height: 0; + } + + .sidebar-slot { + position: fixed; + z-index: 20; + top: 0; + right: 0; + bottom: 0; + width: min(var(--sidebar-width), calc(100vw - 2.75rem)); + box-shadow: -18px 0 42px rgb(0 0 0 / 48%); + } + + .is-sidebar-collapsed .sidebar-slot { + box-shadow: none; + } +} diff --git a/examples/ember/realtime-trading/app/app.ts b/examples/ember/realtime-trading/app/app.ts new file mode 100644 index 0000000000..253a0de562 --- /dev/null +++ b/examples/ember/realtime-trading/app/app.ts @@ -0,0 +1,22 @@ +/** + * Looking for services that come from addons? + * + * See: https://github.com/embroider-build/embroider/issues/2659 + * + * We currently don't support app-tree merging from libraries. + * + * For services, I highly recommend looking into either of + * - https://github.com/chancancode/ember-polaris-service- + * - https://ember-primitives.pages.dev/6-utils/createService.md + * - https://ember-primitives.pages.dev/6-utils/createAsyncService.md + */ +import Application from 'ember-strict-application-resolver' +import './app.css' + +export default class App extends Application { + modules = { + ...import.meta.glob('./router.*', { eager: true }), + ...import.meta.glob('./templates/**/*', { eager: true }), + ...import.meta.glob('./services/**/*', { eager: true }), + } +} diff --git a/examples/ember/realtime-trading/app/benchmark/benchmark-monitor.ts b/examples/ember/realtime-trading/app/benchmark/benchmark-monitor.ts new file mode 100644 index 0000000000..a403dcf00b --- /dev/null +++ b/examples/ember/realtime-trading/app/benchmark/benchmark-monitor.ts @@ -0,0 +1,415 @@ +import { + quoteCellLifecycle, + quoteRenderDiagnostics, +} from '../table/table-config/quote-cells.gts' +import { rowModelDiagnostics } from '../table/trading-table' + +export interface NamedInvocationRate { + name: string + callsPerSecond: number +} + +export interface FeedMetrics { + actualTicksPerSecond: number + rowUpdatesPerSecond: number + workerMessagesPerSecond: number + stateApplicationsPerSecond: number + supersededUpdatesPerSecond: number + totalTicks: number + rafCallbacksPerSecond: number + tableRendersPerSecond: number + lastBatchSize: number + averageRenderMs: number + p95RenderMs: number + maxRenderMs: number + slowRenders: number + longAnimationFrames: number + worstLongAnimationFrameMs: number + heapMb: number | null + componentsCreated: number + componentsDestroyed: number + workerMessages: number + lastUpdateCount: number + cellRendererCallsPerSecond: number + componentRenderCallsPerSecond: number + cellRendererRates: ReadonlyArray + componentRenderRates: ReadonlyArray + domMutationsPerSecond: number + rowModelCallsPerSecond: number + rowModelAverageMs: number + rowModelMaxMs: number + visibleRows: number +} + +export const initialMetrics: FeedMetrics = { + actualTicksPerSecond: 0, + rowUpdatesPerSecond: 0, + workerMessagesPerSecond: 0, + stateApplicationsPerSecond: 0, + supersededUpdatesPerSecond: 0, + totalTicks: 0, + rafCallbacksPerSecond: 0, + tableRendersPerSecond: 0, + lastBatchSize: 0, + averageRenderMs: 0, + p95RenderMs: 0, + maxRenderMs: 0, + slowRenders: 0, + longAnimationFrames: 0, + worstLongAnimationFrameMs: 0, + heapMb: null, + componentsCreated: 0, + componentsDestroyed: 0, + workerMessages: 0, + lastUpdateCount: 0, + cellRendererCallsPerSecond: 0, + componentRenderCallsPerSecond: 0, + cellRendererRates: [], + componentRenderRates: [], + domMutationsPerSecond: 0, + rowModelCallsPerSecond: 0, + rowModelAverageMs: 0, + rowModelMaxMs: 0, + visibleRows: 0, +} + +const userTiming = { entryCount: 0, measureCallCount: 0 } +const USER_TIMING_SAMPLE_INTERVAL = 20 + +interface CommitLatencySample { + recordedAt: number + duration: number +} + +const AVERAGE_COMMIT_WINDOW_MS = 3_000 +const PERCENTILE_COMMIT_WINDOW_MS = 10_000 +const FRAME_RATE_WINDOW_MS = 1_000 + +export function recordMeasure( + name: string, + start: number, + end: number, + detail: Record, +): void { + userTiming.measureCallCount++ + if (userTiming.measureCallCount % USER_TIMING_SAMPLE_INTERVAL !== 0) return + try { + performance.measure(name, { start, end, detail }) + userTiming.entryCount++ + if (userTiming.entryCount % 1_000 === 0) { + performance.clearMeasures('market-update-to-dom-commit') + } + } catch { + // User Timing Level 3 options are not implemented in every browser. + } +} + +export function markBenchmarkAction( + name: string, + detail: Record = {}, +): void { + try { + performance.mark(`benchmark:${name}`, { detail }) + userTiming.entryCount++ + if (userTiming.entryCount % 1_000 === 0) { + performance.clearMarks() + } + } catch { + // User Timing Level 3 detail is not implemented in every browser. + } +} + +export class BenchmarkMonitor { + readonly #runtime = { + sampleStartedAt: performance.now(), + sessionStartedAt: performance.now(), + frameTrackingStartedAt: performance.now(), + pendingRenderStartedAt: null as number | null, + renderSamples: [] as Array, + frameTimestamps: [] as Array, + totalTicks: 0, + ticksInSample: 0, + rowUpdatesInSample: 0, + workerMessagesInSample: 0, + stateApplicationsInSample: 0, + supersededUpdatesInSample: 0, + lastBatchSize: 0, + lastUpdateCount: 0, + workerMessages: 0, + tableRendersInSample: 0, + slowRenderCount: 0, + longAnimationFrameCount: 0, + worstLongAnimationFrameMs: 0, + previousCellRendererCalls: 0, + previousComponentRenderCalls: 0, + previousCellRendererCallsByName: { + ...quoteRenderDiagnostics.cellRendererCallsByName, + }, + previousComponentRenderCallsByName: { + ...quoteRenderDiagnostics.componentRenderCallsByName, + }, + domMutationsInSample: 0, + previousRowModelCalls: 0, + previousRowModelDuration: 0, + } + + markRenderPending(): void { + this.#runtime.pendingRenderStartedAt ??= performance.now() + } + + recordCompletedRender(): void { + const runtime = this.#runtime + if (runtime.pendingRenderStartedAt !== null) { + const renderEndedAt = performance.now() + const duration = renderEndedAt - runtime.pendingRenderStartedAt + runtime.renderSamples.push({ recordedAt: renderEndedAt, duration }) + if (duration > 16.7) runtime.slowRenderCount++ + recordMeasure( + 'market-update-to-dom-commit', + runtime.pendingRenderStartedAt, + renderEndedAt, + {}, + ) + runtime.pendingRenderStartedAt = null + runtime.tableRendersInSample++ + } + } + + recordWorkerMessage(): void { + this.#runtime.workerMessages++ + this.#runtime.workerMessagesInSample++ + } + + recordBatch( + tickCount: number, + updateCount: number, + supersededUpdateCount: number, + ): void { + const runtime = this.#runtime + runtime.lastBatchSize = tickCount + runtime.lastUpdateCount = updateCount + runtime.ticksInSample += tickCount + runtime.totalTicks += tickCount + runtime.rowUpdatesInSample += updateCount + runtime.stateApplicationsInSample++ + runtime.supersededUpdatesInSample += supersededUpdateCount + } + + recordAnimationFrame(now: number): void { + this.#runtime.frameTimestamps.push(now) + } + + recordLongAnimationFrame(duration: number, startTime: number): void { + const runtime = this.#runtime + if (startTime < runtime.sessionStartedAt) return + runtime.longAnimationFrameCount++ + runtime.worstLongAnimationFrameMs = Math.max( + runtime.worstLongAnimationFrameMs, + duration, + ) + } + + recordDomMutations(count: number): void { + this.#runtime.domMutationsInSample += count + } + + resetDomMutations(): void { + this.#runtime.domMutationsInSample = 0 + } + + shouldPublish(now: number): boolean { + return now - this.#runtime.sampleStartedAt >= 500 + } + + publish(now: number): FeedMetrics { + const runtime = this.#runtime + const sampleDuration = now - runtime.sampleStartedAt + runtime.renderSamples = runtime.renderSamples.filter( + (sample) => sample.recordedAt >= now - PERCENTILE_COMMIT_WINDOW_MS, + ) + runtime.frameTimestamps = runtime.frameTimestamps.filter( + (timestamp) => timestamp >= now - FRAME_RATE_WINDOW_MS, + ) + const averageRenderSamples = runtime.renderSamples.filter( + (sample) => sample.recordedAt >= now - AVERAGE_COMMIT_WINDOW_MS, + ) + const sortedRenderSamples = runtime.renderSamples + .map((sample) => sample.duration) + .sort((left, right) => left - right) + const rowModelCalls = + rowModelDiagnostics.calls - runtime.previousRowModelCalls + const rowModelDuration = + rowModelDiagnostics.totalDurationMs - runtime.previousRowModelDuration + const cellRendererCalls = + quoteRenderDiagnostics.cellRendererCalls - + runtime.previousCellRendererCalls + const componentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls - + runtime.previousComponentRenderCalls + const cellRendererRates = calculateInvocationRates( + quoteRenderDiagnostics.cellRendererCallsByName, + runtime.previousCellRendererCallsByName, + sampleDuration, + ) + const componentRenderRates = calculateInvocationRates( + quoteRenderDiagnostics.componentRenderCallsByName, + runtime.previousComponentRenderCallsByName, + sampleDuration, + ) + const averageRenderMs = + averageRenderSamples.length === 0 + ? 0 + : averageRenderSamples.reduce( + (sum, sample) => sum + sample.duration, + 0, + ) / averageRenderSamples.length + const p95Index = Math.max( + 0, + Math.ceil(sortedRenderSamples.length * 0.95) - 1, + ) + const metrics: FeedMetrics = { + actualTicksPerSecond: + sampleDuration === 0 + ? 0 + : (runtime.ticksInSample / sampleDuration) * 1_000, + rowUpdatesPerSecond: + (runtime.rowUpdatesInSample / sampleDuration) * 1_000, + workerMessagesPerSecond: + (runtime.workerMessagesInSample / sampleDuration) * 1_000, + stateApplicationsPerSecond: + (runtime.stateApplicationsInSample / sampleDuration) * 1_000, + supersededUpdatesPerSecond: + (runtime.supersededUpdatesInSample / sampleDuration) * 1_000, + totalTicks: runtime.totalTicks, + rafCallbacksPerSecond: + (runtime.frameTimestamps.length / + Math.min( + FRAME_RATE_WINDOW_MS, + Math.max(1, now - runtime.frameTrackingStartedAt), + )) * + 1_000, + tableRendersPerSecond: + (runtime.tableRendersInSample / sampleDuration) * 1_000, + lastBatchSize: runtime.lastBatchSize, + averageRenderMs, + p95RenderMs: sortedRenderSamples[p95Index] ?? 0, + maxRenderMs: sortedRenderSamples.at(-1) ?? 0, + slowRenders: runtime.slowRenderCount, + longAnimationFrames: runtime.longAnimationFrameCount, + worstLongAnimationFrameMs: runtime.worstLongAnimationFrameMs, + heapMb: readHeapSizeMb(), + componentsCreated: quoteCellLifecycle.created, + componentsDestroyed: quoteCellLifecycle.destroyed, + workerMessages: runtime.workerMessages, + lastUpdateCount: runtime.lastUpdateCount, + cellRendererCallsPerSecond: (cellRendererCalls / sampleDuration) * 1_000, + componentRenderCallsPerSecond: + (componentRenderCalls / sampleDuration) * 1_000, + cellRendererRates, + componentRenderRates, + domMutationsPerSecond: + (runtime.domMutationsInSample / sampleDuration) * 1_000, + rowModelCallsPerSecond: (rowModelCalls / sampleDuration) * 1_000, + rowModelAverageMs: + rowModelCalls === 0 ? 0 : rowModelDuration / rowModelCalls, + rowModelMaxMs: rowModelDiagnostics.maxDurationMs, + visibleRows: rowModelDiagnostics.lastRowCount, + } + + runtime.sampleStartedAt = now + runtime.previousCellRendererCalls = quoteRenderDiagnostics.cellRendererCalls + runtime.previousComponentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls + runtime.previousCellRendererCallsByName = { + ...quoteRenderDiagnostics.cellRendererCallsByName, + } + runtime.previousComponentRenderCallsByName = { + ...quoteRenderDiagnostics.componentRenderCallsByName, + } + runtime.domMutationsInSample = 0 + runtime.previousRowModelCalls = rowModelDiagnostics.calls + runtime.previousRowModelDuration = rowModelDiagnostics.totalDurationMs + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.tableRendersInSample = 0 + return metrics + } + + reset(): void { + const runtime = this.#runtime + runtime.sampleStartedAt = performance.now() + runtime.sessionStartedAt = runtime.sampleStartedAt + runtime.pendingRenderStartedAt = null + runtime.renderSamples = [] + runtime.frameTrackingStartedAt = runtime.sampleStartedAt + runtime.frameTimestamps = [] + runtime.totalTicks = 0 + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.lastBatchSize = 0 + runtime.lastUpdateCount = 0 + runtime.workerMessages = 0 + runtime.tableRendersInSample = 0 + runtime.slowRenderCount = 0 + runtime.longAnimationFrameCount = 0 + runtime.worstLongAnimationFrameMs = 0 + runtime.previousCellRendererCalls = quoteRenderDiagnostics.cellRendererCalls + runtime.previousComponentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls + runtime.previousCellRendererCallsByName = { + ...quoteRenderDiagnostics.cellRendererCallsByName, + } + runtime.previousComponentRenderCallsByName = { + ...quoteRenderDiagnostics.componentRenderCallsByName, + } + runtime.domMutationsInSample = 0 + runtime.previousRowModelCalls = rowModelDiagnostics.calls + runtime.previousRowModelDuration = rowModelDiagnostics.totalDurationMs + rowModelDiagnostics.maxDurationMs = 0 + } +} + +export const longAnimationFramesSupported = + PerformanceObserver.supportedEntryTypes.includes('long-animation-frame') + +function readHeapSizeMb(): number | null { + const memory = ( + performance as Performance & { + memory?: { usedJSHeapSize: number } + } + ).memory + return memory ? memory.usedJSHeapSize / 1_048_576 : null +} + +function calculateInvocationRates( + current: Record, + previous: Record, + sampleDuration: number, +): ReadonlyArray { + return Object.entries(current).map(([name, calls]) => ({ + name, + callsPerSecond: + sampleDuration === 0 + ? 0 + : ((calls - (previous[name] ?? 0)) / sampleDuration) * 1_000, + })) +} + +export function exposeTradingBenchmarkSnapshot( + metrics: FeedMetrics, + extras: { mountedCells: number; liveComponents: number }, +): void { + Object.assign(globalThis, { + __TANSTACK_TRADING_BENCHMARK__: { + capturedAt: performance.now(), + metrics, + ...extras, + }, + }) +} diff --git a/examples/ember/realtime-trading/app/benchmark/trading-benchmark-controller.ts b/examples/ember/realtime-trading/app/benchmark/trading-benchmark-controller.ts new file mode 100644 index 0000000000..fee900a3ce --- /dev/null +++ b/examples/ember/realtime-trading/app/benchmark/trading-benchmark-controller.ts @@ -0,0 +1,123 @@ +import { cached, tracked } from '@glimmer/tracking' +import { TRADING_COLUMN_COUNT } from '../table/trading-table' +import { + BenchmarkMonitor, + exposeTradingBenchmarkSnapshot, + initialMetrics, + longAnimationFramesSupported, +} from './benchmark-monitor' +import type { FeedMetrics } from './benchmark-monitor' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { RendererMode } from '../table/trading-table' + +export interface TradingBenchmarkActions { + resetViewState: () => void + setRendererMode: (mode: RendererMode) => void + setRenderedRowCount: (count: number) => void + selectSymbol: (symbol: string | null) => void + resetMarket: () => void +} + +export class TradingBenchmarkController { + @tracked metrics: FeedMetrics = initialMetrics + @tracked mountedCells = 0 + @tracked selectedSymbol: string | null = null + @tracked rendererMode: RendererMode = 'stable' + invalidateTable: (() => void) | null = null + @cached + get liveComponents(): number { + const metrics = this.metrics + return metrics.componentsCreated - metrics.componentsDestroyed + } + readonly longAnimationFramesSupported = longAnimationFramesSupported + readonly monitor = new BenchmarkMonitor() + readonly feed: MarketFeedController + readonly actions: TradingBenchmarkActions + + readonly #runtime = { + animationFrameId: 0, + longAnimationFrameObserver: null as PerformanceObserver | null, + stopObservingFeed: null as (() => void) | null, + } + + constructor(feed: MarketFeedController) { + this.feed = feed + this.actions = { + resetViewState: () => { + this.selectedSymbol = null + this.invalidateTable?.() + }, + setRendererMode: (mode) => { + this.rendererMode = mode + }, + setRenderedRowCount: (count) => { + const mountedCells = count * TRADING_COLUMN_COUNT + if (mountedCells !== this.mountedCells) { + this.mountedCells = mountedCells + } + }, + selectSymbol: (symbol) => { + this.selectedSymbol = symbol + }, + resetMarket: () => { + this.monitor.reset() + this.metrics = { ...initialMetrics } + this.mountedCells = 0 + this.selectedSymbol = null + this.feed.actions.reset() + }, + } + } + + start(): () => void { + const longAnimationFrameObserver = longAnimationFramesSupported + ? new PerformanceObserver((entries) => { + for (const entry of entries.getEntries()) { + this.monitor.recordLongAnimationFrame( + entry.duration, + entry.startTime, + ) + } + }) + : null + + this.#runtime.longAnimationFrameObserver = longAnimationFrameObserver + this.#runtime.stopObservingFeed = this.feed.observe({ + messageReceived: () => this.monitor.recordWorkerMessage(), + mutationStarted: () => this.monitor.markRenderPending(), + batchApplied: ({ tickCount, updateCount, supersededUpdateCount }) => + this.monitor.recordBatch(tickCount, updateCount, supersededUpdateCount), + renderCommitted: () => this.monitor.recordCompletedRender(), + }) + longAnimationFrameObserver?.observe({ + type: 'long-animation-frame', + }) + this.#runtime.animationFrameId = requestAnimationFrame(this.#benchmarkFrame) + + return () => this.stop() + } + + stop(): void { + cancelAnimationFrame(this.#runtime.animationFrameId) + this.#runtime.longAnimationFrameObserver?.disconnect() + this.#runtime.stopObservingFeed?.() + this.#runtime.longAnimationFrameObserver = null + this.#runtime.stopObservingFeed = null + } + + readonly #benchmarkFrame = (now: number): void => { + this.monitor.recordAnimationFrame(now) + if (this.monitor.shouldPublish(now)) { + this.#publishMetrics(this.monitor.publish(now)) + } + this.#runtime.animationFrameId = requestAnimationFrame(this.#benchmarkFrame) + } + + #publishMetrics(metrics: FeedMetrics): void { + this.metrics = metrics + exposeTradingBenchmarkSnapshot(metrics, { + mountedCells: this.mountedCells, + liveComponents: this.liveComponents, + }) + } +} diff --git a/examples/ember/realtime-trading/app/components/shell/app-header.gts b/examples/ember/realtime-trading/app/components/shell/app-header.gts new file mode 100644 index 0000000000..017ccddfe6 --- /dev/null +++ b/examples/ember/realtime-trading/app/components/shell/app-header.gts @@ -0,0 +1,63 @@ +import Component from '@glimmer/component' +import { on } from '@ember/modifier' +import type { MarketFeedController } from '../../feed/market-feed-controller' + +interface Signature { + Args: { + feed: MarketFeedController + sidebarOpen: boolean + toggleSidebar: () => void + } +} + +export default class AppHeader extends Component { + get workerReady() { + return this.args.feed.workerReady + } + get running() { + return this.args.feed.running + } + get status() { + return !this.workerReady + ? 'FEED CONNECTING' + : this.running + ? 'FEED LIVE' + : 'FEED PAUSED' + } + +} + +const and = (left: boolean, right: boolean): boolean => left && right diff --git a/examples/ember/realtime-trading/app/components/shell/configurator-options.ts b/examples/ember/realtime-trading/app/components/shell/configurator-options.ts new file mode 100644 index 0000000000..5e21d71492 --- /dev/null +++ b/examples/ember/realtime-trading/app/components/shell/configurator-options.ts @@ -0,0 +1,49 @@ +export interface ConfiguratorOption { + readonly label: string + readonly value: TValue +} + +const instrumentCountOptions = [ + { label: '50', value: 50 }, + { label: '100', value: 100 }, + { label: '150', value: 150 }, + { label: '250', value: 250 }, + { label: '350', value: 350 }, + { label: '500', value: 500 }, + { label: '750', value: 750 }, + { label: '1,000', value: 1_000 }, + { label: '1,500', value: 1_500 }, + { label: '2,500', value: 2_500 }, + { label: '5,000', value: 5_000 }, + { label: '1,000,000', value: 1_000_000 }, + { label: '10,000,000', value: 10_000_000 }, +] as const satisfies ReadonlyArray> + +const workerDeliveryOptions = [ + { label: '8 ms · 125 msg/s', value: 8 }, + { label: '16 ms · 62.5 msg/s', value: 16 }, + { label: '20 ms · 50 msg/s', value: 20 }, + { label: '33 ms · 30 msg/s', value: 33 }, + { label: '50 ms · 20 msg/s', value: 50 }, + { label: '100 ms · 10 msg/s', value: 100 }, + { label: '250 ms · 4 msg/s', value: 250 }, + { label: '500 ms · 2 msg/s', value: 500 }, + { label: '1,000 ms · 1 msg/s', value: 1_000 }, +] as const satisfies ReadonlyArray> + +const intradaySamplingOptions = [ + { label: '16 ms · fastest', value: 16 }, + { label: '33 ms · very fast', value: 33 }, + { label: '50 ms · fast', value: 50 }, + { label: '100 ms', value: 100 }, + { label: '250 ms', value: 250 }, + { label: '500 ms', value: 500 }, + { label: '1,000 ms', value: 1_000 }, + { label: '2,000 ms', value: 2_000 }, +] as const satisfies ReadonlyArray> + +export const configuratorOptions = { + instrumentCounts: instrumentCountOptions, + workerDeliveryIntervals: workerDeliveryOptions, + intradaySamplingIntervals: intradaySamplingOptions, +} as const diff --git a/examples/ember/realtime-trading/app/components/shell/configurator.gts b/examples/ember/realtime-trading/app/components/shell/configurator.gts new file mode 100644 index 0000000000..cd06e8fb5e --- /dev/null +++ b/examples/ember/realtime-trading/app/components/shell/configurator.gts @@ -0,0 +1,211 @@ +import Component from '@glimmer/component' +import { on } from '@ember/modifier' +import { modifier } from 'ember-modifier' +import { + feedSampleRateAt, + feedSampleRateIndex, + feedSampleRateOptions, +} from '../../feed/feed-sample-rates' +import { initialMarketFeedConfig } from '../../feed/market-feed-config' +import { configuratorOptions } from './configurator-options' +import Diagnostics from './diagnostics.gts' +import MetricsStrip from './metrics-strip.gts' +import SelectedInstrument from './selected-instrument.gts' +import type { MarketFeedController } from '../../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../../benchmark/trading-benchmark-controller' + +interface Signature { + Args: { controller: TradingBenchmarkController; feed: MarketFeedController } +} +const rate = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const captureSelect = modifier( + ( + element: HTMLSelectElement, + [capture]: [(el: HTMLSelectElement | null) => void], + ) => { + capture(element) + return () => capture(null) + }, +) + +export default class Configurator extends Component { + readonly feedSampleRateOptions = feedSampleRateOptions + readonly options = configuratorOptions + uiInstrumentCount = initialMarketFeedConfig.instrumentCount + instrumentSelect: HTMLSelectElement | null = null + captureInstrumentSelect = (element: HTMLSelectElement | null) => { + this.instrumentSelect = element + if (element) { + element.value = String(this.uiInstrumentCount) + } + } + get running() { + return this.args.feed.running + } + get targetTicksPerSecond() { + return this.args.feed.targetTicksPerSecond + } + get publishIntervalMs() { + return this.args.feed.publishIntervalMs + } + get updateSparklines() { + return this.args.feed.updateSparklines + } + get sparklineSampleIntervalMs() { + return this.args.feed.sparklineSampleIntervalMs + } + get rendererMode() { + return this.args.controller.rendererMode + } + get sampleRateIndex() { + return feedSampleRateIndex(this.targetTicksPerSecond) + } + get sampleRateLabel() { + return `${rate.format(this.targetTicksPerSecond)} samples/s` + } + + setInstrumentCount = (value: string) => { + const count = Number(value) + this.args.feed.actions.setInstrumentCount(count) + this.args.controller.actions.resetViewState() + this.uiInstrumentCount = count + } + setInstrumentCountFromEvent = (event: Event) => { + this.setInstrumentCount(selectValue(event)) + } + setSampleRate = (event: Event) => { + this.args.feed.actions.setTargetRate(feedSampleRateAt(numberValue(event))) + } + setPublishInterval = (event: Event) => { + this.args.feed.actions.setPublishInterval(numberValue(event)) + } + setRendererMode = (event: Event) => { + this.args.controller.actions.setRendererMode( + checked(event) ? 'swap' : 'stable', + ) + } + setSparklineUpdates = (event: Event) => { + this.args.feed.actions.setSparklineUpdates(checked(event)) + } + setSparklineInterval = (event: Event) => { + this.args.feed.actions.setSparklineSampleInterval(numberValue(event)) + } + + +} + +const selectValue = (event: Event): string => + (event.target as HTMLInputElement | HTMLSelectElement).value +const numberValue = (event: Event): number => Number(selectValue(event)) +const checked = (event: Event): boolean => + (event.target as HTMLInputElement).checked +const subtract = (left: number, right: number): number => left - right +const eq = (left: unknown, right: unknown): boolean => left === right +const optionValue = (option: { + readonly value: number | string +}): number | string => option.value +const optionLabel = (option: { readonly label: string }): string => option.label diff --git a/examples/ember/realtime-trading/app/components/shell/diagnostics.gts b/examples/ember/realtime-trading/app/components/shell/diagnostics.gts new file mode 100644 index 0000000000..8c6f3e2600 --- /dev/null +++ b/examples/ember/realtime-trading/app/components/shell/diagnostics.gts @@ -0,0 +1,154 @@ +import Component from '@glimmer/component' +import type { NamedInvocationRate } from '../../benchmark/benchmark-monitor' +import type { TradingBenchmarkController } from '../../benchmark/trading-benchmark-controller' + +interface Signature { + Args: { controller: TradingBenchmarkController } +} +const integer = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }) +const rate = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const ms = (value: number): string => `${value.toFixed(2)} ms` +const invocations = (values: ReadonlyArray): string => { + const active = values.filter((entry) => entry.callsPerSecond > 0) + return active.length + ? active + .map((entry) => `${entry.name} ${rate.format(entry.callsPerSecond)}`) + .join(' · ') + : '—' +} + +export default class Diagnostics extends Component { + get items() { + const metrics = this.args.controller.metrics + return [ + { + label: 'Mounted cells', + value: integer.format(this.args.controller.mountedCells), + testId: '', + }, + { + label: 'Live components', + value: integer.format(this.args.controller.liveComponents), + testId: '', + }, + { + label: 'Created / destroyed', + value: `${integer.format(metrics.componentsCreated)} / ${integer.format(metrics.componentsDestroyed)}`, + testId: '', + }, + { + label: 'Renderer callbacks / s', + value: rate.format(metrics.cellRendererCallsPerSecond), + testId: 'cell-render-rate', + }, + { + label: 'Component executions / s', + value: rate.format(metrics.componentRenderCallsPerSecond), + testId: 'component-render-rate', + }, + { + label: 'Executions by component / s', + value: invocations(metrics.componentRenderRates), + testId: 'component-render-breakdown', + }, + { + label: 'Callbacks by column / s', + value: invocations(metrics.cellRendererRates), + testId: 'cell-render-breakdown', + }, + { + label: 'Observed MutationRecords / s', + value: rate.format(metrics.domMutationsPerSecond), + testId: 'dom-mutation-rate', + }, + { + label: 'Worker samples / s', + value: rate.format(metrics.actualTicksPerSecond), + testId: 'actual-rate', + }, + { + label: 'Worker messages / s', + value: metrics.workerMessagesPerSecond.toFixed(1), + testId: 'message-rate', + }, + { + label: 'Changed rows / s', + value: rate.format(metrics.rowUpdatesPerSecond), + testId: 'row-update-rate', + }, + { + label: 'State snapshots / s', + value: metrics.stateApplicationsPerSecond.toFixed(1), + testId: 'state-apply-rate', + }, + { + label: 'Table DOM commits / s', + value: metrics.tableRendersPerSecond.toFixed(1), + testId: 'table-render-rate', + }, + { + label: 'P95 / max commit latency (rolling 10 s)', + value: `${ms(metrics.p95RenderMs)} / ${ms(metrics.maxRenderMs)}`, + testId: '', + }, + { + label: 'Core row model calls / s', + value: metrics.rowModelCallsPerSecond.toFixed(1), + testId: 'row-model-call-rate', + }, + { + label: 'Core row model avg / max', + value: `${ms(metrics.rowModelAverageMs)} / ${ms(metrics.rowModelMaxMs)}`, + testId: 'row-model-duration', + }, + { + label: 'Visible rows', + value: integer.format(metrics.visibleRows), + testId: 'visible-row-count', + }, + { + label: 'Worker messages since reset', + value: integer.format(metrics.workerMessages), + testId: 'worker-messages', + }, + { + label: 'Worker-coalesced updates / s', + value: rate.format(metrics.supersededUpdatesPerSecond), + testId: 'superseded-update-rate', + }, + { + label: 'Last samples / updated rows', + value: `${integer.format(metrics.lastBatchSize)} / ${integer.format(metrics.lastUpdateCount)}`, + testId: '', + }, + { + label: 'Commits > 16.7 ms since reset', + value: integer.format(metrics.slowRenders), + testId: '', + }, + { + label: 'JS heap (GC-sensitive)', + value: + metrics.heapMb === null ? 'N/A' : `${metrics.heapMb.toFixed(1)} MB`, + testId: '', + }, + ] + } + +} +const or = (left: T, right: T): T => left || right diff --git a/examples/ember/realtime-trading/app/components/shell/market-statusbar.gts b/examples/ember/realtime-trading/app/components/shell/market-statusbar.gts new file mode 100644 index 0000000000..ba6a5d31f0 --- /dev/null +++ b/examples/ember/realtime-trading/app/components/shell/market-statusbar.gts @@ -0,0 +1,31 @@ +import Component from '@glimmer/component' +import type { TradingBenchmarkController } from '../../benchmark/trading-benchmark-controller' + +interface Signature { + Args: { controller: TradingBenchmarkController } +} +const integer = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }) + +export default class MarketStatusbar extends Component { + get metrics() { + return this.args.controller.metrics + } + get mountedCells() { + return this.args.controller.mountedCells + } + get liveComponents() { + return this.args.controller.liveComponents + } + +} +const format = (value: number): string => integer.format(value) diff --git a/examples/ember/realtime-trading/app/components/shell/metrics-strip.gts b/examples/ember/realtime-trading/app/components/shell/metrics-strip.gts new file mode 100644 index 0000000000..70b7d6f7bd --- /dev/null +++ b/examples/ember/realtime-trading/app/components/shell/metrics-strip.gts @@ -0,0 +1,59 @@ +import Component from '@glimmer/component' +import type { TradingBenchmarkController } from '../../benchmark/trading-benchmark-controller' + +interface Signature { + Args: { controller: TradingBenchmarkController } +} +const rate = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const ms = (value: number): string => `${value.toFixed(2)} ms` + +export default class MetricsStrip extends Component { + get items() { + const metrics = this.args.controller.metrics + return [ + [ + 'FRAME RATE (EST.)', + metrics.rafCallbacksPerSecond.toFixed(1), + 'rAF callbacks/s · rolling 1 s', + 'frame-rate', + ], + [ + 'AVG COMMIT', + ms(metrics.averageRenderMs), + 'snapshot → DOM · rolling 3 s', + 'average-commit-latency', + ], + [ + 'LONG FRAMES', + this.args.controller.longAnimationFramesSupported + ? String(metrics.longAnimationFrames) + : 'N/A', + this.args.controller.longAnimationFramesSupported + ? `since reset · worst ${ms(metrics.worstLongAnimationFrameMs)}` + : 'unsupported', + 'long-frame-count', + ], + [ + 'THROUGHPUT', + `${rate.format(metrics.rowUpdatesPerSecond)} rows/s`, + `${metrics.stateApplicationsPerSecond.toFixed(1)} snapshots/s · rows deduplicated per snapshot`, + 'throughput-rate', + ], + ] as const + } + +} + +const or = (left: T, right: T): T => left || right diff --git a/examples/ember/realtime-trading/app/components/shell/selected-instrument.gts b/examples/ember/realtime-trading/app/components/shell/selected-instrument.gts new file mode 100644 index 0000000000..55d6ce99ae --- /dev/null +++ b/examples/ember/realtime-trading/app/components/shell/selected-instrument.gts @@ -0,0 +1,37 @@ +import Component from '@glimmer/component' +import type { MarketQuote } from '../../feed/market-data' +import type { MarketFeedController } from '../../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../../benchmark/trading-benchmark-controller' + +interface Signature { + Args: { controller: TradingBenchmarkController; feed: MarketFeedController } +} + +export default class SelectedInstrument extends Component { + get quote(): MarketQuote | null { + return this.args.feed.getQuoteBySymbol( + this.args.feed.quotes, + this.args.controller.selectedSymbol, + ) + } + +} +const fixed = (value: number): string => value.toFixed(2) diff --git a/examples/ember/realtime-trading/app/components/shell/trading-shell.gts b/examples/ember/realtime-trading/app/components/shell/trading-shell.gts new file mode 100644 index 0000000000..26ed6fc155 --- /dev/null +++ b/examples/ember/realtime-trading/app/components/shell/trading-shell.gts @@ -0,0 +1,48 @@ +import Component from '@glimmer/component' +import { tracked } from '@glimmer/tracking' +import AppHeader from './app-header.gts' +import Configurator from './configurator.gts' +import MarketStatusbar from './market-statusbar.gts' +import TradingTable from '../table/trading-table.gts' +import type { MarketFeedController } from '../../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../../benchmark/trading-benchmark-controller' + +interface Signature { + Args: { + controller: TradingBenchmarkController + feed: MarketFeedController + } +} + +export default class TradingShell extends Component { + @tracked sidebarOpen = true + toggleSidebar = () => { + this.sidebarOpen = !this.sidebarOpen + } + get rootClass() { + return `trading-terminal${this.sidebarOpen ? '' : ' is-sidebar-collapsed'}` + } + +} + +const isDevelopment = import.meta.env.DEV diff --git a/examples/ember/realtime-trading/app/components/table/trading-table.gts b/examples/ember/realtime-trading/app/components/table/trading-table.gts new file mode 100644 index 0000000000..aa58df5da8 --- /dev/null +++ b/examples/ember/realtime-trading/app/components/table/trading-table.gts @@ -0,0 +1,436 @@ +import Component from '@glimmer/component' +import { cached, tracked } from '@glimmer/tracking' +import { on } from '@ember/modifier' +import { htmlSafe } from '@ember/template' +import { modifier } from 'ember-modifier' +import { + FlexRenderCell, + FlexRenderHeader, + useTable, + type Header, + type Row, + type Table, +} from '@tanstack/ember-table' +import { + createTradingColumns, + readMeasuredRows, +} from '../../table/table-config/trading-columns.gts' +import { tradingFeatures } from '../../table/trading-features' +import { + TradingGridPointerController, + handleCellNavigation, + reorderColumnIds, + sortAriaValue, + sortIndicator, +} from '../../table/table-interactions' +import { registerCleanup } from '../../utils/subscriptions' +import { run } from '@ember/runloop' +import type Owner from '@ember/owner' +import type { MarketQuote } from '../../feed/market-data' +import type { MarketFeedController } from '../../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../../benchmark/trading-benchmark-controller' + +interface Signature { + Args: { + controller: TradingBenchmarkController + feed: MarketFeedController + } +} +interface TableView { + quotes: Array +} +type TradingRow = Row +type TradingHeader = Header +interface RenderedRow { + id: string + row: TradingRow + cells: ReturnType +} + +const captureElement = modifier( + ( + element: HTMLElement, + [capture]: [(element: HTMLElement | null) => void], + ) => { + capture(element) + return () => capture(null) + }, +) + +const markRenderCommitted = modifier( + ( + _element: HTMLElement, + [feed, quotes]: [MarketFeedController, Array], + ) => { + void quotes + queueMicrotask(() => feed.completeRender()) + }, +) + +export default class TradingTable extends Component { + @tracked viewGeneration = 0 + tableView: TableView = { + quotes: [], + } + readonly pointer = new TradingGridPointerController() + readonly layout = { manuallyResized: false } + readonly drag = { + columnId: null as string | null, + source: null as HTMLTableCellElement | null, + target: null as HTMLTableCellElement | null, + } + scrollElement: HTMLDivElement | null = null + bodyElement: HTMLTableSectionElement | null = null + resizeObserver: ResizeObserver | null = null + mutationObserver: MutationObserver | null = null + + table: Table = useTable(this, () => ({ + features: tradingFeatures, + columns: this.columns, + data: this.data, + getRowId: (row: MarketQuote) => row.id, + columnResizeMode: 'onChange' as const, + defaultColumn: { minSize: 56, maxSize: 800 }, + autoResetCellSelection: false, + })) + + constructor(owner: Owner, args: Signature['Args']) { + super(owner, args) + this.args.controller.invalidateTable = this.queueSync + const stopObserving = this.args.feed.observe({ + viewChanged: this.queueSync, + }) + this.queueSync() + registerCleanup(this, () => { + this.args.controller.invalidateTable = null + stopObserving() + this.resizeObserver?.disconnect() + this.mutationObserver?.disconnect() + }) + } + + queueSync = () => { + queueMicrotask(() => { + run(() => this.syncView()) + }) + } + + syncView = () => { + this.tableView = { + quotes: this.args.feed.quotes, + } + this.viewGeneration++ + } + + @cached + get columns(): ReturnType { + return createTradingColumns( + this.args.controller, + this.args.controller.rendererMode, + ) + } + get data(): Array { + void this.viewGeneration + return this.tableView.quotes + } + get selectedSymbol() { + return this.args.controller.selectedSymbol + } + + get rows(): Array { + // The table-core memo compares `table.options.data` internally. Consume the + // Ember source explicitly as well so this template getter owns the Glimmer + // tag that schedules the row-block update for an external worker message. + void this.data + return readMeasuredRows(() => this.table.getRowModel().rows) + } + get headerGroups() { + return this.table.getHeaderGroups() + } + get sourceRowCount() { + void this.viewGeneration + return this.tableView.quotes.length + } + get renderedRows(): Array { + void this.viewGeneration + const result = this.rows.map((row) => ({ + id: row.id, + row, + cells: row.getVisibleCells(), + })) + queueMicrotask(() => + this.args.controller.actions.setRenderedRowCount(result.length), + ) + return result + } + + captureScroll = (element: HTMLElement | null) => { + this.scrollElement = element as HTMLDivElement | null + if (!this.scrollElement) return + this.resizeObserver?.disconnect() + this.resizeObserver = new ResizeObserver(() => this.fitAvailableWidth()) + this.resizeObserver.observe(this.scrollElement) + queueMicrotask(() => { + run(() => this.fitAvailableWidth()) + }) + } + captureBody = (element: HTMLElement | null) => { + this.mutationObserver?.disconnect() + this.bodyElement = element as HTMLTableSectionElement | null + if (!this.bodyElement) return + this.args.controller.monitor.resetDomMutations() + this.mutationObserver = new MutationObserver((records) => + this.args.controller.monitor.recordDomMutations(records.length), + ) + this.mutationObserver.observe(this.bodyElement, { + attributes: true, + attributeFilter: ['class', 'style'], + characterData: true, + childList: true, + subtree: true, + }) + } + + @cached + get columnSizeVars(): string { + void this.table.store.state.columnSizing + void this.table.store.state.columnOrder + return this.table + .getFlatHeaders() + .flatMap((header) => [ + `--header-${header.id}-size:${header.getSize()}`, + `--col-${header.column.id}-size:${header.column.getSize()}`, + ]) + .join(';') + } + get tableStyle() { + return htmlSafe( + `${this.columnSizeVars};width:${this.table.getTotalSize()}px`, + ) + } + fitAvailableWidth() { + if (!this.scrollElement || this.layout.manuallyResized) return + const width = this.table.getTotalSize() + if (this.scrollElement.clientWidth <= width + 1 || width <= 0) return + const ratio = this.scrollElement.clientWidth / width + this.table.setColumnSizing( + Object.fromEntries( + this.table + .getVisibleLeafColumns() + .map((column) => [column.id, column.getSize() * ratio]), + ), + ) + } + + resizeColumn = (header: TradingHeader) => (event: Event) => { + this.layout.manuallyResized = true + header.getResizeHandler()?.(event) + } + resetColumnSize = (header: TradingHeader) => () => { + this.layout.manuallyResized = true + header.column.resetSize() + } + + onGridKeyDown = (event: KeyboardEvent) => + handleCellNavigation(this.table, event) + onBodyMouseDown = (event: MouseEvent) => + this.pointer.handleMouseDown( + this.table, + event, + this.args.controller.actions.selectSymbol, + ) + onBodyPointerOver = (event: MouseEvent) => + this.pointer.handlePointerOver(this.table, event) + onBodyClick = (event: MouseEvent) => + this.pointer.handleClick(this.table, event) + resetPointer = () => this.pointer.resetPointerCell() + clearDrag = () => { + this.drag.source?.classList.remove('is-column-dragging') + this.drag.target?.classList.remove('is-column-drop-target') + this.drag.columnId = null + this.drag.source = null + this.drag.target = null + } + dragStart = (header: TradingHeader) => (event: DragEvent) => { + this.drag.columnId = header.column.id + this.drag.source = (event.currentTarget as HTMLElement).closest('th') + this.drag.source?.classList.add('is-column-dragging') + if (event.dataTransfer) { + event.dataTransfer.effectAllowed = 'move' + event.dataTransfer.setData('text/plain', header.column.id) + } + } + dragOver = (header: TradingHeader) => (event: DragEvent) => { + event.preventDefault() + this.drag.target?.classList.remove('is-column-drop-target') + this.drag.target = null + const element = (event.currentTarget as HTMLElement).closest('th') + if (this.drag.columnId !== header.column.id && element) { + element.classList.add('is-column-drop-target') + this.drag.target = element + } + } + drop = (header: TradingHeader) => (event: DragEvent) => { + event.preventDefault() + const source = + event.dataTransfer?.getData('text/plain') || this.drag.columnId + if (source) + this.table.setColumnOrder( + reorderColumnIds( + this.table.getVisibleLeafColumns().map((column) => column.id), + source, + header.column.id, + ), + ) + this.clearDrag() + } + + +} + +const isLeaf = (header: TradingHeader): boolean => + header.subHeaders.length === 0 +const canSort = (header: TradingHeader): boolean => header.column.getCanSort() +const isSorted = (header: TradingHeader): boolean => + header.column.getIsSorted() !== false +const canResize = (header: TradingHeader): boolean => + header.column.getCanResize() +const isResizing = (header: TradingHeader): boolean => + header.column.getIsResizing() +const toggleSort = (header: TradingHeader) => + header.column.getToggleSortingHandler() ?? (() => undefined) +const indicator = (header: TradingHeader): string => + sortIndicator(header.column.getIsSorted()) +const sortAria = (header: TradingHeader) => + isLeaf(header) ? sortAriaValue(header.column.getIsSorted()) : undefined +const headerStyle = (header: TradingHeader) => + htmlSafe(`width:calc(var(--header-${header.id}-size) * 1px)`) +const headerClass = (header: TradingHeader): string => + `${isLeaf(header) ? '' : 'column-group-header'} ${isLeaf(header) && !['market', 'name', 'symbol'].includes(header.column.id) ? 'numeric-header' : ''}` +const cellStyle = (columnId: string) => + htmlSafe(`width:calc(var(--col-${columnId}-size) * 1px)`) +const edgeAttr = ( + cell: { + getSelectionEdges: () => { + top: boolean + right: boolean + bottom: boolean + left: boolean + } + }, + edge: 'top' | 'right' | 'bottom' | 'left', +): string | undefined => (cell.getSelectionEdges()[edge] ? 'true' : undefined) +const rowSelected = (row: TradingRow): boolean => row.getIsSelected() +const cellSelected = ( + cell: ReturnType[number], +): boolean => cell.getIsSelected() +const cellFocused = ( + cell: ReturnType[number], +): string | undefined => (cell.getIsFocused() ? 'true' : undefined) +const cellTabIndex = ( + cell: ReturnType[number], +): number => cell.getTabIndex() +const eq = (left: unknown, right: unknown): boolean => left === right +const not = (value: boolean): boolean => !value diff --git a/examples/ember/realtime-trading/app/config.ts b/examples/ember/realtime-trading/app/config.ts new file mode 100644 index 0000000000..8b0d33268d --- /dev/null +++ b/examples/ember/realtime-trading/app/config.ts @@ -0,0 +1,17 @@ +interface Config { + environment: 'development' | 'production' + locationType: 'history' | 'hash' | 'none' | 'auto' + rootURL: string + EmberENV?: Record + APP: Record & { rootElement?: string; autoboot?: boolean } +} + +const ENV: Config = { + environment: import.meta.env.DEV ? 'development' : 'production', + rootURL: '/', + locationType: 'history', + EmberENV: {}, + APP: {}, +} + +export default ENV diff --git a/examples/ember/realtime-trading/app/feed/feed-sample-rates.ts b/examples/ember/realtime-trading/app/feed/feed-sample-rates.ts new file mode 100644 index 0000000000..dfacf21d02 --- /dev/null +++ b/examples/ember/realtime-trading/app/feed/feed-sample-rates.ts @@ -0,0 +1,33 @@ +export const feedSampleRateOptions = [ + { label: '100', value: 100 }, + { label: '250', value: 250 }, + { label: '500', value: 500 }, + { label: '1K', value: 1_000 }, + { label: '2.5K', value: 2_500 }, + { label: '5K', value: 5_000 }, + { label: '10K', value: 10_000 }, + { label: '25K', value: 25_000 }, + { label: '50K', value: 50_000 }, + { label: '100K', value: 100_000 }, +] as const + +export function feedSampleRateIndex(rate: number): number { + return feedSampleRateOptions.reduce((closestIndex, candidate, index) => { + const closest = feedSampleRateOptions[closestIndex]! + return Math.abs(candidate.value - rate) < Math.abs(closest.value - rate) + ? index + : closestIndex + }, 0) +} + +export function feedSampleRateAt(stepIndex: number): number { + const index = Math.min( + feedSampleRateOptions.length - 1, + Math.max(0, Math.round(stepIndex)), + ) + return feedSampleRateOptions[index]!.value +} + +export function normalizeFeedSampleRate(rate: number): number { + return feedSampleRateAt(feedSampleRateIndex(rate)) +} diff --git a/examples/ember/realtime-trading/app/feed/market-data.ts b/examples/ember/realtime-trading/app/feed/market-data.ts new file mode 100644 index 0000000000..6231865d3f --- /dev/null +++ b/examples/ember/realtime-trading/app/feed/market-data.ts @@ -0,0 +1,38 @@ +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './worker/market-feed-protocol' + +export interface MarketQuote extends Omit { + history: ReadonlyArray +} + +export function hydrateMarketQuotes( + snapshots: Array, +): Array { + return snapshots.map((quote) => ({ + ...quote, + history: [...quote.history], + })) +} + +export function applyMarketUpdates( + quotes: Array, + updates: Array, +): Array { + const nextQuotes = [...quotes] + + for (const update of updates) { + const { index, history, ...values } = update + const previousQuote = quotes.at(index) + if (!previousQuote) continue + + nextQuotes[index] = { + ...previousQuote, + ...values, + history: history ?? previousQuote.history, + } + } + + return nextQuotes +} diff --git a/examples/ember/realtime-trading/app/feed/market-feed-config.ts b/examples/ember/realtime-trading/app/feed/market-feed-config.ts new file mode 100644 index 0000000000..9d477ed663 --- /dev/null +++ b/examples/ember/realtime-trading/app/feed/market-feed-config.ts @@ -0,0 +1,15 @@ +export interface MarketFeedConfig { + readonly instrumentCount: number + readonly targetSamplesPerSecond: number + readonly publishIntervalMs: number + readonly updateSparklines: boolean + readonly sparklineSampleIntervalMs: number +} + +export const initialMarketFeedConfig: MarketFeedConfig = { + instrumentCount: 100, + targetSamplesPerSecond: 10_000, + publishIntervalMs: 20, + updateSparklines: true, + sparklineSampleIntervalMs: 16, +} diff --git a/examples/ember/realtime-trading/app/feed/market-feed-controller.ts b/examples/ember/realtime-trading/app/feed/market-feed-controller.ts new file mode 100644 index 0000000000..6bc135d2c3 --- /dev/null +++ b/examples/ember/realtime-trading/app/feed/market-feed-controller.ts @@ -0,0 +1,226 @@ +import { tracked } from '@glimmer/tracking' +import { normalizeFeedSampleRate } from './feed-sample-rates' +import { initialMarketFeedConfig } from './market-feed-config' +import { applyMarketUpdates, hydrateMarketQuotes } from './market-data' +import type { + MarketFeedCommand, + MarketFeedEvent, +} from './worker/market-feed-protocol' +import type { MarketQuote } from './market-data' + +export interface MarketFeedBatch { + tickCount: number + updateCount: number + supersededUpdateCount: number +} + +export interface MarketFeedObserver { + messageReceived?: () => void + mutationStarted?: () => void + batchApplied?: (batch: MarketFeedBatch) => void + renderCommitted?: () => void + viewChanged?: () => void +} + +export interface MarketFeedActions { + toggle: () => void + setInstrumentCount: (count: number) => void + setTargetRate: (rate: number) => void + setPublishInterval: (intervalMs: number) => void + setSparklineUpdates: (enabled: boolean) => void + setSparklineSampleInterval: (intervalMs: number) => void + runBurst: () => void + reset: () => void +} + +export class MarketFeedController { + @tracked workerReady = false + @tracked running = !new URLSearchParams(location.search).has('paused') + instrumentCount = initialMarketFeedConfig.instrumentCount + @tracked targetTicksPerSecond = initialMarketFeedConfig.targetSamplesPerSecond + @tracked publishIntervalMs = initialMarketFeedConfig.publishIntervalMs + @tracked updateSparklines = initialMarketFeedConfig.updateSparklines + @tracked sparklineSampleIntervalMs = + initialMarketFeedConfig.sparklineSampleIntervalMs + quotes: Array = [] + readonly actions: MarketFeedActions + readonly #observers = new Set() + readonly #runtime = { + worker: null as Worker | null, + feedSessionId: 0, + renderPending: false, + resetWaitingForCommit: false, + resetSnapshotReady: false, + quoteIndexBySymbol: new Map(), + } + + constructor() { + this.actions = { + toggle: () => { + const running = !this.running + this.running = running + this.#post({ type: 'set-running', running }) + }, + setInstrumentCount: (count) => { + this.instrumentCount = count + this.#resetWorker(count) + }, + setTargetRate: (rate) => { + const sampleRate = normalizeFeedSampleRate(rate) + this.targetTicksPerSecond = sampleRate + this.#post({ type: 'set-rate', ticksPerSecond: sampleRate }) + }, + setPublishInterval: (publishIntervalMs) => { + this.publishIntervalMs = publishIntervalMs + this.#post({ + type: 'set-publish-interval', + intervalMs: publishIntervalMs, + }) + }, + setSparklineUpdates: (enabled) => { + this.updateSparklines = enabled + this.#post({ type: 'set-sparklines', enabled }) + }, + setSparklineSampleInterval: (intervalMs) => { + this.sparklineSampleIntervalMs = intervalMs + this.#post({ type: 'set-sparkline-interval', intervalMs }) + }, + runBurst: () => this.#post({ type: 'burst', tickCount: 25_000 }), + reset: () => this.#resetWorker(this.instrumentCount), + } + } + + start(): () => void { + const worker = new Worker( + new URL('./worker/market-feed.worker.ts', import.meta.url), + { type: 'module' }, + ) + this.#runtime.worker = worker + worker.addEventListener('message', this.#handleWorkerMessage) + worker.addEventListener('error', this.#handleWorkerError) + this.#post({ + type: 'start', + rowCount: this.instrumentCount, + running: this.running, + ticksPerSecond: this.targetTicksPerSecond, + publishIntervalMs: this.publishIntervalMs, + updateSparklines: this.updateSparklines, + sparklineSampleIntervalMs: this.sparklineSampleIntervalMs, + }) + return () => this.stop() + } + + stop(): void { + this.#runtime.worker?.removeEventListener( + 'message', + this.#handleWorkerMessage, + ) + this.#runtime.worker?.removeEventListener('error', this.#handleWorkerError) + this.#runtime.worker?.terminate() + this.#runtime.worker = null + this.#observers.clear() + } + + observe(observer: MarketFeedObserver): () => void { + this.#observers.add(observer) + return () => this.#observers.delete(observer) + } + + getQuoteBySymbol( + quotes: Array, + symbol: string | null, + ): MarketQuote | null { + if (symbol === null) return null + + const index = this.#runtime.quoteIndexBySymbol.get(symbol) + return index === undefined ? null : (quotes[index] ?? null) + } + + completeRender(): void { + if (!this.#runtime.renderPending) return + + this.#runtime.renderPending = false + for (const observer of this.#observers) { + observer.renderCommitted?.() + } + if ( + this.#runtime.resetWaitingForCommit && + this.#runtime.resetSnapshotReady + ) { + this.#runtime.resetWaitingForCommit = false + this.#runtime.resetSnapshotReady = false + this.#post({ type: 'set-running', running: this.running }) + } + } + + readonly #handleWorkerMessage = ({ + data, + }: MessageEvent): void => { + if (data.type === 'snapshot') { + this.#runtime.feedSessionId = data.sessionId + if (this.#runtime.resetWaitingForCommit) { + this.#runtime.resetSnapshotReady = true + } + this.#startMutation() + const quotes = hydrateMarketQuotes(data.quotes) + this.#runtime.quoteIndexBySymbol = new Map( + quotes.map((quote, index) => [quote.symbol, index]), + ) + this.quotes = quotes + this.workerReady = true + this.#notifyView() + return + } + + if (data.sessionId !== this.#runtime.feedSessionId) return + + for (const observer of this.#observers) { + observer.messageReceived?.() + } + this.#startMutation() + const quotes = applyMarketUpdates(this.quotes, data.updates) + this.quotes = quotes + this.#notifyView() + const feedBatch = { + tickCount: data.tickCount, + updateCount: data.updates.length, + supersededUpdateCount: data.coalescedUpdateCount, + } + for (const observer of this.#observers) { + observer.batchApplied?.(feedBatch) + } + } + + readonly #handleWorkerError = (error: ErrorEvent): void => { + this.workerReady = false + this.running = false + console.error('Market feed worker failed', error) + } + + #resetWorker(rowCount: number): void { + if (this.running) { + this.workerReady = false + this.#runtime.resetWaitingForCommit = true + this.#runtime.resetSnapshotReady = false + this.#post({ type: 'set-running', running: false }) + } + this.#post({ type: 'reset', rowCount }) + } + + #startMutation(): void { + this.#runtime.renderPending = true + for (const observer of this.#observers) { + observer.mutationStarted?.() + } + } + + #notifyView(): void { + for (const observer of this.#observers) { + observer.viewChanged?.() + } + } + + #post(command: MarketFeedCommand): void { + this.#runtime.worker?.postMessage(command) + } +} diff --git a/examples/ember/realtime-trading/app/feed/market-instruments.ts b/examples/ember/realtime-trading/app/feed/market-instruments.ts new file mode 100644 index 0000000000..ac18d14ea9 --- /dev/null +++ b/examples/ember/realtime-trading/app/feed/market-instruments.ts @@ -0,0 +1,742 @@ +export type MarketCode = + | 'US' + | 'NL' + | 'DE' + | 'FR' + | 'IT' + | 'ES' + | 'CH' + | 'DK' + | 'SE' + | 'FI' + | 'GB' + | 'KR' + | 'JP' + | 'HK' + | 'CA' + | 'AU' + +export type BaseInstrument = readonly [ + symbol: string, + company: string, + market: MarketCode, +] + +/** + * Current S&P 500 constituent universe used by the realtime trading examples. + * + * Source snapshot: https://github.com/datasets/s-and-p-500-companies + * Retrieved: 2026-08-15. + * Multiple share classes are intentionally represented as separate instruments. + */ +export const marketInstruments = Object.freeze([ + ['MMM', '3M', 'US'], + ['AOS', 'A. O. Smith', 'US'], + ['ABT', 'Abbott Laboratories', 'US'], + ['ABBV', 'AbbVie', 'US'], + ['ACN', 'Accenture', 'US'], + ['ADBE', 'Adobe Inc.', 'US'], + ['AMD', 'Advanced Micro Devices', 'US'], + ['AES', 'AES Corporation', 'US'], + ['AFL', 'Aflac', 'US'], + ['A', 'Agilent Technologies', 'US'], + ['APD', 'Air Products', 'US'], + ['ABNB', 'Airbnb', 'US'], + ['AKAM', 'Akamai Technologies', 'US'], + ['ALB', 'Albemarle Corporation', 'US'], + ['ARE', 'Alexandria Real Estate Equities', 'US'], + ['ALGN', 'Align Technology', 'US'], + ['ALLE', 'Allegion', 'US'], + ['LNT', 'Alliant Energy', 'US'], + ['ALL', 'Allstate', 'US'], + ['GOOGL', 'Alphabet Inc. (Class A)', 'US'], + ['GOOG', 'Alphabet Inc. (Class C)', 'US'], + ['MO', 'Altria', 'US'], + ['AMZN', 'Amazon', 'US'], + ['AMCR', 'Amcor', 'US'], + ['AEE', 'Ameren', 'US'], + ['AEP', 'American Electric Power', 'US'], + ['AXP', 'American Express', 'US'], + ['AIG', 'American International Group', 'US'], + ['AMT', 'American Tower', 'US'], + ['AWK', 'American Water Works', 'US'], + ['AMP', 'Ameriprise Financial', 'US'], + ['AME', 'Ametek', 'US'], + ['AMGN', 'Amgen', 'US'], + ['APH', 'Amphenol', 'US'], + ['ADI', 'Analog Devices', 'US'], + ['AON', 'Aon plc', 'US'], + ['APA', 'APA Corporation', 'US'], + ['APO', 'Apollo Global Management', 'US'], + ['AAPL', 'Apple Inc.', 'US'], + ['AMAT', 'Applied Materials', 'US'], + ['APP', 'AppLovin', 'US'], + ['APTV', 'Aptiv', 'US'], + ['ACGL', 'Arch Capital Group', 'US'], + ['ADM', 'Archer Daniels Midland', 'US'], + ['ARES', 'Ares Management', 'US'], + ['ANET', 'Arista Networks', 'US'], + ['AJG', 'Arthur J. Gallagher & Co.', 'US'], + ['AIZ', 'Assurant', 'US'], + ['T', 'AT&T', 'US'], + ['ATO', 'Atmos Energy', 'US'], + ['ADSK', 'Autodesk', 'US'], + ['ADP', 'Automatic Data Processing', 'US'], + ['AZO', 'AutoZone', 'US'], + ['AVB', 'AvalonBay Communities', 'US'], + ['AVY', 'Avery Dennison', 'US'], + ['AXON', 'Axon Enterprise', 'US'], + ['BKR', 'Baker Hughes', 'US'], + ['BALL', 'Ball Corporation', 'US'], + ['BAC', 'Bank of America', 'US'], + ['BAX', 'Baxter International', 'US'], + ['BDX', 'Becton Dickinson', 'US'], + ['BRK.B', 'Berkshire Hathaway', 'US'], + ['BBY', 'Best Buy', 'US'], + ['TECH', 'Bio-Techne', 'US'], + ['BIIB', 'Biogen', 'US'], + ['BLK', 'BlackRock', 'US'], + ['BX', 'Blackstone Inc.', 'US'], + ['XYZ', 'Block, Inc.', 'US'], + ['BNY', 'BNY Mellon', 'US'], + ['BA', 'Boeing', 'US'], + ['BKNG', 'Booking Holdings', 'US'], + ['BSX', 'Boston Scientific', 'US'], + ['BMY', 'Bristol Myers Squibb', 'US'], + ['AVGO', 'Broadcom', 'US'], + ['BR', 'Broadridge Financial Solutions', 'US'], + ['BRO', 'Brown & Brown', 'US'], + ['BF.B', 'Brown–Forman', 'US'], + ['BLDR', 'Builders FirstSource', 'US'], + ['BG', 'Bunge Global', 'US'], + ['BXP', 'BXP, Inc.', 'US'], + ['CHRW', 'C.H. Robinson', 'US'], + ['CDNS', 'Cadence Design Systems', 'US'], + ['CPT', 'Camden Property Trust', 'US'], + ['COF', 'Capital One', 'US'], + ['CAH', 'Cardinal Health', 'US'], + ['CCL', 'Carnival Corporation', 'US'], + ['CARR', 'Carrier Global', 'US'], + ['CVNA', 'Carvana', 'US'], + ['CASY', "Casey's", 'US'], + ['CAT', 'Caterpillar Inc.', 'US'], + ['CBOE', 'Cboe Global Markets', 'US'], + ['CBRE', 'CBRE Group', 'US'], + ['CDW', 'CDW Corporation', 'US'], + ['COR', 'Cencora', 'US'], + ['CNC', 'Centene Corporation', 'US'], + ['CNP', 'CenterPoint Energy', 'US'], + ['CF', 'CF Industries', 'US'], + ['CRL', 'Charles River Laboratories', 'US'], + ['SCHW', 'Charles Schwab Corporation', 'US'], + ['CHTR', 'Charter Communications', 'US'], + ['CVX', 'Chevron Corporation', 'US'], + ['CMG', 'Chipotle Mexican Grill', 'US'], + ['CB', 'Chubb Limited', 'US'], + ['CHD', 'Church & Dwight', 'US'], + ['CIEN', 'Ciena', 'US'], + ['CI', 'Cigna', 'US'], + ['CINF', 'Cincinnati Financial', 'US'], + ['CTAS', 'Cintas', 'US'], + ['CSCO', 'Cisco', 'US'], + ['C', 'Citigroup', 'US'], + ['CFG', 'Citizens Financial Group', 'US'], + ['CLX', 'Clorox', 'US'], + ['CME', 'CME Group', 'US'], + ['CMS', 'CMS Energy', 'US'], + ['KO', 'Coca-Cola Company (The)', 'US'], + ['CTSH', 'Cognizant', 'US'], + ['COHR', 'Coherent Corp.', 'US'], + ['COIN', 'Coinbase', 'US'], + ['CL', 'Colgate-Palmolive', 'US'], + ['CMCSA', 'Comcast', 'US'], + ['FIX', 'Comfort Systems USA', 'US'], + ['COP', 'ConocoPhillips', 'US'], + ['ED', 'Consolidated Edison', 'US'], + ['STZ', 'Constellation Brands', 'US'], + ['CEG', 'Constellation Energy', 'US'], + ['COO', 'Cooper Companies (The)', 'US'], + ['CPRT', 'Copart', 'US'], + ['GLW', 'Corning Inc.', 'US'], + ['CPAY', 'Corpay', 'US'], + ['CTVA', 'Corteva', 'US'], + ['CSGP', 'CoStar Group', 'US'], + ['COST', 'Costco', 'US'], + ['CRH', 'CRH plc', 'US'], + ['CRWD', 'CrowdStrike', 'US'], + ['CCI', 'Crown Castle', 'US'], + ['CSX', 'CSX Corporation', 'US'], + ['CMI', 'Cummins', 'US'], + ['CVS', 'CVS Health', 'US'], + ['DHR', 'Danaher Corporation', 'US'], + ['DRI', 'Darden Restaurants', 'US'], + ['DDOG', 'Datadog', 'US'], + ['DVA', 'DaVita', 'US'], + ['DECK', 'Deckers Brands', 'US'], + ['DE', 'Deere & Company', 'US'], + ['DELL', 'Dell Technologies', 'US'], + ['DAL', 'Delta Air Lines', 'US'], + ['DVN', 'Devon Energy', 'US'], + ['DXCM', 'Dexcom', 'US'], + ['FANG', 'Diamondback Energy', 'US'], + ['DLR', 'Digital Realty', 'US'], + ['DG', 'Dollar General', 'US'], + ['DLTR', 'Dollar Tree', 'US'], + ['D', 'Dominion Energy', 'US'], + ['DPZ', "Domino's", 'US'], + ['DASH', 'DoorDash', 'US'], + ['DOV', 'Dover Corporation', 'US'], + ['DOW', 'Dow Inc.', 'US'], + ['DHI', 'D. R. Horton', 'US'], + ['DTE', 'DTE Energy', 'US'], + ['DUK', 'Duke Energy', 'US'], + ['DD', 'DuPont', 'US'], + ['ETN', 'Eaton Corporation', 'US'], + ['EBAY', 'eBay Inc.', 'US'], + ['ECHO', 'EchoStar', 'US'], + ['ECL', 'Ecolab', 'US'], + ['EIX', 'Edison International', 'US'], + ['EW', 'Edwards Lifesciences', 'US'], + ['ELV', 'Elevance Health', 'US'], + ['EME', 'Emcor', 'US'], + ['EMR', 'Emerson Electric', 'US'], + ['ETR', 'Entergy', 'US'], + ['EOG', 'EOG Resources', 'US'], + ['EQT', 'EQT Corporation', 'US'], + ['EFX', 'Equifax', 'US'], + ['EQIX', 'Equinix', 'US'], + ['EQR', 'Equity Residential', 'US'], + ['ERIE', 'Erie Indemnity', 'US'], + ['ESS', 'Essex Property Trust', 'US'], + ['EL', 'Estée Lauder Companies (The)', 'US'], + ['EG', 'Everest Group', 'US'], + ['EVRG', 'Evergy', 'US'], + ['ES', 'Eversource Energy', 'US'], + ['EXC', 'Exelon', 'US'], + ['EXE', 'Expand Energy', 'US'], + ['EXPE', 'Expedia Group', 'US'], + ['EXPD', 'Expeditors International', 'US'], + ['EXR', 'Extra Space Storage', 'US'], + ['XOM', 'ExxonMobil', 'US'], + ['FFIV', 'F5, Inc.', 'US'], + ['FDS', 'FactSet', 'US'], + ['FICO', 'Fair Isaac', 'US'], + ['FAST', 'Fastenal', 'US'], + ['FRT', 'Federal Realty Investment Trust', 'US'], + ['FDX', 'FedEx', 'US'], + ['FDXF', 'FedEx Freight', 'US'], + ['FERG', 'Ferguson Enterprises', 'US'], + ['FIS', 'Fidelity National Information Services', 'US'], + ['FITB', 'Fifth Third Bancorp', 'US'], + ['FSLR', 'First Solar', 'US'], + ['FE', 'FirstEnergy', 'US'], + ['FISV', 'Fiserv', 'US'], + ['FLEX', 'Flex Ltd.', 'US'], + ['F', 'Ford Motor Company', 'US'], + ['FTNT', 'Fortinet', 'US'], + ['FTV', 'Fortive', 'US'], + ['FOXA', 'Fox Corporation (Class A)', 'US'], + ['FOX', 'Fox Corporation (Class B)', 'US'], + ['BEN', 'Franklin Resources', 'US'], + ['FCX', 'Freeport-McMoRan', 'US'], + ['GRMN', 'Garmin', 'US'], + ['IT', 'Gartner', 'US'], + ['GE', 'GE Aerospace', 'US'], + ['GEHC', 'GE HealthCare', 'US'], + ['GEV', 'GE Vernova', 'US'], + ['GEN', 'Gen Digital', 'US'], + ['GNRC', 'Generac', 'US'], + ['GD', 'General Dynamics', 'US'], + ['GIS', 'General Mills', 'US'], + ['GM', 'General Motors', 'US'], + ['GPC', 'Genuine Parts Company', 'US'], + ['GILD', 'Gilead Sciences', 'US'], + ['GPN', 'Global Payments', 'US'], + ['GL', 'Globe Life', 'US'], + ['GDDY', 'GoDaddy', 'US'], + ['GS', 'Goldman Sachs', 'US'], + ['HAL', 'Halliburton', 'US'], + ['HIG', 'Hartford (The)', 'US'], + ['HAS', 'Hasbro', 'US'], + ['HCA', 'HCA Healthcare', 'US'], + ['DOC', 'Healthpeak Properties', 'US'], + ['HSIC', 'Henry Schein', 'US'], + ['HSY', 'Hershey Company (The)', 'US'], + ['HPE', 'Hewlett Packard Enterprise', 'US'], + ['HLT', 'Hilton Worldwide', 'US'], + ['HD', 'Home Depot (The)', 'US'], + ['HONA', 'Honeywell Aerospace', 'US'], + ['HON', 'Honeywell Technologies', 'US'], + ['HRL', 'Hormel Foods', 'US'], + ['HST', 'Host Hotels & Resorts', 'US'], + ['HWM', 'Howmet Aerospace', 'US'], + ['HPQ', 'HP Inc.', 'US'], + ['HUBB', 'Hubbell Incorporated', 'US'], + ['HUM', 'Humana', 'US'], + ['HBAN', 'Huntington Bancshares', 'US'], + ['HII', 'Huntington Ingalls Industries', 'US'], + ['IBM', 'IBM', 'US'], + ['IEX', 'IDEX Corporation', 'US'], + ['IDXX', 'Idexx Laboratories', 'US'], + ['ITW', 'Illinois Tool Works', 'US'], + ['INCY', 'Incyte', 'US'], + ['IR', 'Ingersoll Rand', 'US'], + ['PODD', 'Insulet Corporation', 'US'], + ['INTC', 'Intel', 'US'], + ['IBKR', 'Interactive Brokers', 'US'], + ['ICE', 'Intercontinental Exchange', 'US'], + ['IFF', 'International Flavors & Fragrances', 'US'], + ['IP', 'International Paper', 'US'], + ['INTU', 'Intuit', 'US'], + ['ISRG', 'Intuitive Surgical', 'US'], + ['IVZ', 'Invesco', 'US'], + ['INVH', 'Invitation Homes', 'US'], + ['IQV', 'IQVIA', 'US'], + ['IRM', 'Iron Mountain', 'US'], + ['JBHT', 'J.B. Hunt', 'US'], + ['JBL', 'Jabil', 'US'], + ['JKHY', 'Jack Henry & Associates', 'US'], + ['J', 'Jacobs Solutions', 'US'], + ['JNJ', 'Johnson & Johnson', 'US'], + ['JCI', 'Johnson Controls', 'US'], + ['JPM', 'JPMorgan Chase', 'US'], + ['KVUE', 'Kenvue', 'US'], + ['KDP', 'Keurig Dr Pepper', 'US'], + ['KEY', 'KeyCorp', 'US'], + ['KEYS', 'Keysight Technologies', 'US'], + ['KMB', 'Kimberly-Clark', 'US'], + ['KIM', 'Kimco Realty', 'US'], + ['KMI', 'Kinder Morgan', 'US'], + ['KKR', 'KKR & Co.', 'US'], + ['KLAC', 'KLA Corporation', 'US'], + ['KHC', 'Kraft Heinz', 'US'], + ['KR', 'Kroger', 'US'], + ['LHX', 'L3Harris', 'US'], + ['LH', 'Labcorp', 'US'], + ['LRCX', 'Lam Research', 'US'], + ['LVS', 'Las Vegas Sands', 'US'], + ['LDOS', 'Leidos', 'US'], + ['LEN', 'Lennar', 'US'], + ['LII', 'Lennox International', 'US'], + ['LLY', 'Lilly (Eli)', 'US'], + ['LIN', 'Linde plc', 'US'], + ['LYV', 'Live Nation Entertainment', 'US'], + ['LMT', 'Lockheed Martin', 'US'], + ['L', 'Loews Corporation', 'US'], + ['LOW', "Lowe's", 'US'], + ['LULU', 'Lululemon Athletica', 'US'], + ['LITE', 'Lumentum', 'US'], + ['LYB', 'LyondellBasell', 'US'], + ['MTB', 'M&T Bank', 'US'], + ['MPC', 'Marathon Petroleum', 'US'], + ['MAR', 'Marriott International', 'US'], + ['MRSH', 'Marsh McLennan', 'US'], + ['MLM', 'Martin Marietta Materials', 'US'], + ['MRVL', 'Marvell Technology', 'US'], + ['MAS', 'Masco', 'US'], + ['MA', 'Mastercard', 'US'], + ['MKC', 'McCormick & Company', 'US'], + ['MCD', "McDonald's", 'US'], + ['MCK', 'McKesson Corporation', 'US'], + ['MDT', 'Medtronic', 'US'], + ['MRK', 'Merck & Co.', 'US'], + ['META', 'Meta Platforms', 'US'], + ['MET', 'MetLife', 'US'], + ['MTD', 'Mettler Toledo', 'US'], + ['MGM', 'MGM Resorts', 'US'], + ['MCHP', 'Microchip Technology', 'US'], + ['MU', 'Micron Technology', 'US'], + ['MSFT', 'Microsoft', 'US'], + ['MAA', 'Mid-America Apartment Communities', 'US'], + ['MRNA', 'Moderna', 'US'], + ['TAP', 'Molson Coors Beverage Company', 'US'], + ['MDLZ', 'Mondelez International', 'US'], + ['MPWR', 'Monolithic Power Systems', 'US'], + ['MNST', 'Monster Beverage', 'US'], + ['MCO', "Moody's Corporation", 'US'], + ['MS', 'Morgan Stanley', 'US'], + ['MOS', 'Mosaic Company (The)', 'US'], + ['MSI', 'Motorola Solutions', 'US'], + ['MSCI', 'MSCI', 'US'], + ['NDAQ', 'Nasdaq, Inc.', 'US'], + ['NTAP', 'NetApp', 'US'], + ['NFLX', 'Netflix', 'US'], + ['NEM', 'Newmont', 'US'], + ['NWSA', 'News Corp (Class A)', 'US'], + ['NWS', 'News Corp (Class B)', 'US'], + ['NEE', 'NextEra Energy', 'US'], + ['NKE', 'Nike, Inc.', 'US'], + ['NI', 'NiSource', 'US'], + ['NDSN', 'Nordson Corporation', 'US'], + ['NSC', 'Norfolk Southern', 'US'], + ['NTRS', 'Northern Trust', 'US'], + ['NOC', 'Northrop Grumman', 'US'], + ['NCLH', 'Norwegian Cruise Line Holdings', 'US'], + ['NRG', 'NRG Energy', 'US'], + ['NUE', 'Nucor', 'US'], + ['NVDA', 'Nvidia', 'US'], + ['NVR', 'NVR, Inc.', 'US'], + ['NXPI', 'NXP Semiconductors', 'US'], + ['ORLY', "O'Reilly Automotive", 'US'], + ['OXY', 'Occidental Petroleum', 'US'], + ['ODFL', 'Old Dominion', 'US'], + ['OMC', 'Omnicom Group', 'US'], + ['ON', 'ON Semiconductor', 'US'], + ['OKE', 'Oneok', 'US'], + ['ORCL', 'Oracle Corporation', 'US'], + ['OTIS', 'Otis Worldwide', 'US'], + ['PCAR', 'Paccar', 'US'], + ['PKG', 'Packaging Corporation of America', 'US'], + ['PLTR', 'Palantir Technologies', 'US'], + ['PANW', 'Palo Alto Networks', 'US'], + ['PSKY', 'Paramount Skydance Corporation', 'US'], + ['PH', 'Parker Hannifin', 'US'], + ['PAYX', 'Paychex', 'US'], + ['PYPL', 'PayPal', 'US'], + ['PNR', 'Pentair', 'US'], + ['PEP', 'PepsiCo', 'US'], + ['PFE', 'Pfizer', 'US'], + ['PCG', 'PG&E Corporation', 'US'], + ['PM', 'Philip Morris International', 'US'], + ['PSX', 'Phillips 66', 'US'], + ['PNW', 'Pinnacle West Capital', 'US'], + ['PNC', 'PNC Financial Services', 'US'], + ['PPG', 'PPG Industries', 'US'], + ['PPL', 'PPL Corporation', 'US'], + ['PFG', 'Principal Financial Group', 'US'], + ['PG', 'Procter & Gamble', 'US'], + ['PGR', 'Progressive Corporation', 'US'], + ['PLD', 'Prologis', 'US'], + ['PRU', 'Prudential Financial', 'US'], + ['PEG', 'Public Service Enterprise Group', 'US'], + ['PTC', 'PTC Inc.', 'US'], + ['PSA', 'Public Storage', 'US'], + ['PHM', 'PulteGroup', 'US'], + ['PWR', 'Quanta Services', 'US'], + ['QCOM', 'Qualcomm', 'US'], + ['DGX', 'Quest Diagnostics', 'US'], + ['Q', 'Qnity Electronics', 'US'], + ['RL', 'Ralph Lauren Corporation', 'US'], + ['RJF', 'Raymond James Financial', 'US'], + ['RTX', 'RTX Corporation', 'US'], + ['O', 'Realty Income', 'US'], + ['REG', 'Regency Centers', 'US'], + ['REGN', 'Regeneron Pharmaceuticals', 'US'], + ['RF', 'Regions Financial Corporation', 'US'], + ['RSG', 'Republic Services', 'US'], + ['RMD', 'ResMed|', 'US'], + ['RVTY', 'Revvity', 'US'], + ['HOOD', 'Robinhood Markets', 'US'], + ['ROK', 'Rockwell Automation', 'US'], + ['ROL', 'Rollins, Inc.', 'US'], + ['ROP', 'Roper Technologies', 'US'], + ['ROST', 'Ross Stores', 'US'], + ['RCL', 'Royal Caribbean Group', 'US'], + ['SPGI', 'S&P Global', 'US'], + ['CRM', 'Salesforce', 'US'], + ['SNDK', 'Sandisk', 'US'], + ['SBAC', 'SBA Communications', 'US'], + ['SLB', 'Schlumberger', 'US'], + ['STX', 'Seagate Technology', 'US'], + ['SRE', 'Sempra', 'US'], + ['NOW', 'ServiceNow', 'US'], + ['SHW', 'Sherwin-Williams', 'US'], + ['SPG', 'Simon Property Group', 'US'], + ['SWKS', 'Skyworks Solutions', 'US'], + ['SJM', 'J.M. Smucker Company (The)', 'US'], + ['SW', 'Smurfit Westrock', 'US'], + ['SNA', 'Snap-on', 'US'], + ['SOLV', 'Solventum', 'US'], + ['SO', 'Southern Company', 'US'], + ['LUV', 'Southwest Airlines', 'US'], + ['SWK', 'Stanley Black & Decker', 'US'], + ['SBUX', 'Starbucks', 'US'], + ['STT', 'State Street Corporation', 'US'], + ['STLD', 'Steel Dynamics', 'US'], + ['STE', 'Steris', 'US'], + ['SYK', 'Stryker Corporation', 'US'], + ['SMCI', 'Supermicro', 'US'], + ['SYF', 'Synchrony Financial', 'US'], + ['SNPS', 'Synopsys', 'US'], + ['SYY', 'Sysco', 'US'], + ['TMUS', 'T-Mobile US', 'US'], + ['TROW', 'T. Rowe Price', 'US'], + ['TTWO', 'Take-Two Interactive', 'US'], + ['TPR', 'Tapestry, Inc.', 'US'], + ['TRGP', 'Targa Resources', 'US'], + ['TGT', 'Target Corporation', 'US'], + ['TEL', 'TE Connectivity', 'US'], + ['TDY', 'Teledyne Technologies', 'US'], + ['TER', 'Teradyne', 'US'], + ['TSLA', 'Tesla, Inc.', 'US'], + ['TXN', 'Texas Instruments', 'US'], + ['TPL', 'Texas Pacific Land Corporation', 'US'], + ['TXT', 'Textron', 'US'], + ['TMO', 'Thermo Fisher Scientific', 'US'], + ['TJX', 'TJX Companies', 'US'], + ['TKO', 'TKO Group Holdings', 'US'], + ['TTD', 'Trade Desk (The)', 'US'], + ['TSCO', 'Tractor Supply', 'US'], + ['TT', 'Trane Technologies', 'US'], + ['TDG', 'TransDigm Group', 'US'], + ['TRV', 'Travelers Companies (The)', 'US'], + ['TRMB', 'Trimble Inc.', 'US'], + ['TFC', 'Truist Financial', 'US'], + ['TYL', 'Tyler Technologies', 'US'], + ['TSN', 'Tyson Foods', 'US'], + ['USB', 'U.S. Bancorp', 'US'], + ['UBER', 'Uber', 'US'], + ['UDR', 'UDR, Inc.', 'US'], + ['ULTA', 'Ulta Beauty', 'US'], + ['UNP', 'Union Pacific Corporation', 'US'], + ['UAL', 'United Airlines Holdings', 'US'], + ['UPS', 'United Parcel Service', 'US'], + ['URI', 'United Rentals', 'US'], + ['UNH', 'UnitedHealth Group', 'US'], + ['UHS', 'Universal Health Services', 'US'], + ['VLO', 'Valero Energy', 'US'], + ['VEEV', 'Veeva Systems', 'US'], + ['VTR', 'Ventas', 'US'], + ['VLTO', 'Veralto', 'US'], + ['VRSN', 'Verisign', 'US'], + ['VRSK', 'Verisk Analytics', 'US'], + ['VZ', 'Verizon', 'US'], + ['VRTX', 'Vertex Pharmaceuticals', 'US'], + ['VRT', 'Vertiv', 'US'], + ['VTRS', 'Viatris', 'US'], + ['VICI', 'Vici Properties', 'US'], + ['V', 'Visa Inc.', 'US'], + ['VST', 'Vistra Corp.', 'US'], + ['VMC', 'Vulcan Materials Company', 'US'], + ['WRB', 'W. R. Berkley Corporation', 'US'], + ['GWW', 'W. W. Grainger', 'US'], + ['WAB', 'Wabtec', 'US'], + ['WMT', 'Walmart', 'US'], + ['DIS', 'Walt Disney Company (The)', 'US'], + ['WBD', 'Warner Bros. Discovery', 'US'], + ['WM', 'Waste Management', 'US'], + ['WAT', 'Waters Corporation', 'US'], + ['WEC', 'WEC Energy Group', 'US'], + ['WFC', 'Wells Fargo', 'US'], + ['WELL', 'Welltower', 'US'], + ['WST', 'West Pharmaceutical Services', 'US'], + ['WDC', 'Western Digital', 'US'], + ['WY', 'Weyerhaeuser', 'US'], + ['WSM', 'Williams-Sonoma, Inc.', 'US'], + ['WMB', 'Williams Companies', 'US'], + ['WTW', 'Willis Towers Watson', 'US'], + ['WDAY', 'Workday, Inc.', 'US'], + ['WYNN', 'Wynn Resorts', 'US'], + ['XEL', 'Xcel Energy', 'US'], + ['XYL', 'Xylem Inc.', 'US'], + ['YUM', 'Yum! Brands', 'US'], + ['ZBRA', 'Zebra Technologies', 'US'], + ['ZBH', 'Zimmer Biomet', 'US'], + ['ZTS', 'Zoetis', 'US'], +]) + +/** + * Representative liquid international listings used to diversify the fixture. + * Symbols use their local-market form and the third tuple value is an ISO-style + * country/market code, rather than a trading currency or exchange MIC. + * + * References checked 2026-08-15: STOXX Europe 50, KRX KOSPI market, + * JPX TOPIX Core30, and HKEX index constituent materials. + */ +const europeanInstruments = Object.freeze([ + ['ASML', 'ASML Holding', 'NL'], + ['INGA', 'ING Group', 'NL'], + ['ADYEN', 'Adyen', 'NL'], + ['PHIA', 'Philips', 'NL'], + ['HEIA', 'Heineken', 'NL'], + ['SAP', 'SAP', 'DE'], + ['SIE', 'Siemens', 'DE'], + ['ALV', 'Allianz', 'DE'], + ['DTE', 'Deutsche Telekom', 'DE'], + ['MBG', 'Mercedes-Benz Group', 'DE'], + ['BMW', 'BMW', 'DE'], + ['BAS', 'BASF', 'DE'], + ['MUV2', 'Munich Re', 'DE'], + ['VOW3', 'Volkswagen Preference', 'DE'], + ['IFX', 'Infineon Technologies', 'DE'], + ['MC', 'LVMH', 'FR'], + ['OR', "L'Oréal", 'FR'], + ['AIR', 'Airbus', 'FR'], + ['SU', 'Schneider Electric', 'FR'], + ['TTE', 'TotalEnergies', 'FR'], + ['SAN', 'Sanofi', 'FR'], + ['BNP', 'BNP Paribas', 'FR'], + ['CS', 'AXA', 'FR'], + ['DG', 'Vinci', 'FR'], + ['ENEL', 'Enel', 'IT'], + ['ENI', 'Eni', 'IT'], + ['ISP', 'Intesa Sanpaolo', 'IT'], + ['UCG', 'UniCredit', 'IT'], + ['STLAM', 'Stellantis', 'IT'], + ['SAN', 'Banco Santander', 'ES'], + ['IBE', 'Iberdrola', 'ES'], + ['ITX', 'Inditex', 'ES'], + ['BBVA', 'BBVA', 'ES'], + ['NESN', 'Nestlé', 'CH'], + ['ROG', 'Roche Holding', 'CH'], + ['NOVN', 'Novartis', 'CH'], + ['UBSG', 'UBS Group', 'CH'], + ['NOVO-B', 'Novo Nordisk', 'DK'], + ['MAERSK-B', 'A.P. Moller - Maersk', 'DK'], + ['VOLV-B', 'Volvo', 'SE'], + ['ERIC-B', 'Ericsson', 'SE'], + ['NOKIA', 'Nokia', 'FI'], + ['SHEL', 'Shell', 'GB'], + ['AZN', 'AstraZeneca', 'GB'], + ['HSBA', 'HSBC Holdings', 'GB'], + ['ULVR', 'Unilever', 'GB'], + ['LSEG', 'London Stock Exchange Group', 'GB'], +]) + +const europeanMarketCodes = Object.freeze([ + 'NL', + 'DE', + 'FR', + 'IT', + 'ES', + 'CH', + 'DK', + 'SE', + 'FI', + 'GB', +]) + +const europeanMarketGroups = Object.freeze( + europeanMarketCodes.map((market) => + europeanInstruments.filter(([, , instrumentMarket]) => + Object.is(instrumentMarket, market), + ), + ), +) + +const interleavedEuropeanInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...europeanMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + europeanMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const southKoreanInstruments = Object.freeze([ + ['005930', 'Samsung Electronics', 'KR'], + ['000660', 'SK hynix', 'KR'], + ['373220', 'LG Energy Solution', 'KR'], + ['207940', 'Samsung Biologics', 'KR'], + ['005380', 'Hyundai Motor', 'KR'], + ['000270', 'Kia', 'KR'], + ['068270', 'Celltrion', 'KR'], + ['105560', 'KB Financial Group', 'KR'], + ['055550', 'Shinhan Financial Group', 'KR'], + ['035420', 'NAVER', 'KR'], + ['035720', 'Kakao', 'KR'], + ['006400', 'Samsung SDI', 'KR'], + ['051910', 'LG Chem', 'KR'], + ['012330', 'Hyundai Mobis', 'KR'], + ['066570', 'LG Electronics', 'KR'], +]) + +const japaneseInstruments = Object.freeze([ + ['8306', 'Mitsubishi UFJ Financial Group', 'JP'], + ['7203', 'Toyota Motor', 'JP'], + ['6501', 'Hitachi', 'JP'], + ['8316', 'Sumitomo Mitsui Financial Group', 'JP'], + ['6758', 'Sony Group', 'JP'], + ['8058', 'Mitsubishi Corporation', 'JP'], + ['9984', 'SoftBank Group', 'JP'], + ['8035', 'Tokyo Electron', 'JP'], + ['8411', 'Mizuho Financial Group', 'JP'], + ['8031', 'Mitsui & Co.', 'JP'], + ['6861', 'Keyence', 'JP'], + ['7974', 'Nintendo', 'JP'], + ['6098', 'Recruit Holdings', 'JP'], + ['9432', 'Nippon Telegraph and Telephone', 'JP'], + ['4063', 'Shin-Etsu Chemical', 'JP'], +]) + +const hongKongInstruments = Object.freeze([ + ['0700', 'Tencent Holdings', 'HK'], + ['9988', 'Alibaba Group', 'HK'], + ['1810', 'Xiaomi', 'HK'], + ['3690', 'Meituan', 'HK'], + ['0941', 'China Mobile', 'HK'], + ['1211', 'BYD Company', 'HK'], + ['1299', 'AIA Group', 'HK'], + ['0388', 'Hong Kong Exchanges and Clearing', 'HK'], + ['0005', 'HSBC Holdings', 'HK'], + ['2318', 'Ping An Insurance', 'HK'], +]) + +const canadianInstruments = Object.freeze([ + ['RY', 'Royal Bank of Canada', 'CA'], + ['TD', 'Toronto-Dominion Bank', 'CA'], + ['SHOP', 'Shopify', 'CA'], + ['ENB', 'Enbridge', 'CA'], + ['CNR', 'Canadian National Railway', 'CA'], + ['CP', 'Canadian Pacific Kansas City', 'CA'], + ['BMO', 'Bank of Montreal', 'CA'], + ['CSU', 'Constellation Software', 'CA'], +]) + +const australianInstruments = Object.freeze([ + ['BHP', 'BHP Group', 'AU'], + ['CBA', 'Commonwealth Bank of Australia', 'AU'], + ['CSL', 'CSL', 'AU'], + ['NAB', 'National Australia Bank', 'AU'], + ['WBC', 'Westpac Banking Corporation', 'AU'], + ['ANZ', 'ANZ Group Holdings', 'AU'], + ['WES', 'Wesfarmers', 'AU'], + ['MQG', 'Macquarie Group', 'AU'], +]) + +const internationalMarketGroups = Object.freeze([ + interleavedEuropeanInstruments, + southKoreanInstruments, + japaneseInstruments, + hongKongInstruments, + canadianInstruments, + australianInstruments, +]) + +export const internationalInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...internationalMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + internationalMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const INTERNATIONAL_INSERTION_INTERVAL = 3 + +/** + * U.S. and international instruments are interleaved so ordinary benchmark + * sizes exercise multiple symbol formats and market labels. + */ +export const globalInstruments = Object.freeze( + marketInstruments.flatMap((instrument, index) => { + const internationalInstrument = + index % INTERNATIONAL_INSERTION_INTERVAL === 0 + ? internationalInstruments[index / INTERNATIONAL_INSERTION_INTERVAL] + : undefined + + return internationalInstrument + ? [instrument, internationalInstrument] + : [instrument] + }), +) as unknown as ReadonlyArray diff --git a/examples/ember/realtime-trading/app/feed/worker/market-feed-engine.ts b/examples/ember/realtime-trading/app/feed/worker/market-feed-engine.ts new file mode 100644 index 0000000000..3e5818f4d7 --- /dev/null +++ b/examples/ember/realtime-trading/app/feed/worker/market-feed-engine.ts @@ -0,0 +1,177 @@ +import { globalInstruments } from '../market-instruments.ts' +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const INITIAL_MARKET_SEED = 0x4d41524b +const LIVE_FEED_SEED = 0x5449434b + +export class MarketFeedEngine { + #quotes: Array = [] + #lastHistorySampledAt = new Uint32Array(0) + #random = createRandom(2_026) + #rowCursor = 0 + #tickIndex = 0 + + reset(count: number): Array { + const random = createRandom(INITIAL_MARKET_SEED ^ count) + const createdAt = Date.now() + + this.#quotes = Array.from({ length: count }, (_, index) => { + const [baseSymbol, company, market] = + globalInstruments[index % globalInstruments.length]! + const series = Math.floor(index / globalInstruments.length) + const symbol = series === 0 ? baseSymbol : `${baseSymbol}${series}` + const previousClose = roundPrice(20 + random() * 480) + const open = roundPrice(previousClose * (1 + (random() - 0.5) * 0.016)) + const spread = Math.max(0.01, open * (0.0002 + random() * 0.0004)) + const history = Array.from({ length: 24 }, (_, historyIndex) => + roundPrice( + open * + (1 + Math.sin(historyIndex / 4) * 0.002 + (random() - 0.5) * 0.001), + ), + ) + const volume = Math.floor(50_000 + random() * 2_000_000) + const lastSize = Math.floor(10 + random() * 5_000) + + return { + id: `instrument-${index}`, + symbol, + company, + venue: market, + previousClose, + open, + high: open, + low: open, + price: open, + bid: roundPrice(open - spread / 2), + ask: roundPrice(open + spread / 2), + bidSize: Math.floor(100 + random() * 25_000), + askSize: Math.floor(100 + random() * 25_000), + lastSize, + lastMove: 0, + lastUpdatedAt: createdAt, + volume, + turnover: roundMoney(open * volume), + history, + } + }) + + this.#random = createRandom(LIVE_FEED_SEED ^ count) + this.#rowCursor = 0 + this.#lastHistorySampledAt = new Uint32Array(count) + this.#lastHistorySampledAt.fill(createdAt >>> 0) + + return this.#quotes.map((quote) => ({ + ...quote, + history: [...quote.history], + })) + } + + applyTicks( + tickCount: number, + updateSparklines: boolean, + sparklineSampleIntervalMs: number, + ): Array { + if (this.#quotes.length === 0 || tickCount <= 0) return [] + + const updatedAt = Date.now() + const sampledAt = updatedAt >>> 0 + const sampleIntervalMs = Math.max(16, sparklineSampleIntervalMs) + const updatedQuotes = new Map() + const stride = 97 + + this.#tickIndex = 0 + while (this.#tickIndex < tickCount) { + this.#rowCursor = (this.#rowCursor + stride) % this.#quotes.length + const quote = this.#quotes[this.#rowCursor]! + const lastSampledAt = this.#lastHistorySampledAt[this.#rowCursor]! + const shouldUpdateHistory = + updateSparklines && + (sampledAt - lastSampledAt) >>> 0 >= sampleIntervalMs + + if (shouldUpdateHistory) { + this.#lastHistorySampledAt[this.#rowCursor] = sampledAt + } + + this.#applyTick(quote, shouldUpdateHistory, updatedAt) + + const previousUpdate = updatedQuotes.get(this.#rowCursor) + updatedQuotes.set(this.#rowCursor, { + index: this.#rowCursor, + price: quote.price, + bid: quote.bid, + ask: quote.ask, + bidSize: quote.bidSize, + askSize: quote.askSize, + lastSize: quote.lastSize, + lastMove: quote.lastMove, + lastUpdatedAt: quote.lastUpdatedAt, + high: quote.high, + low: quote.low, + volume: quote.volume, + turnover: quote.turnover, + ...(shouldUpdateHistory || previousUpdate?.history + ? { history: [...quote.history] } + : {}), + }) + this.#tickIndex++ + } + + return [...updatedQuotes.values()] + } + + #applyTick( + quote: MarketQuoteSnapshot, + updateHistory: boolean, + updatedAt: number, + ): void { + const previousPrice = quote.price + const volatility = 0.00015 + this.#random() * 0.0012 + const move = previousPrice * (this.#random() - 0.495) * volatility + const nextPrice = roundPrice(Math.max(0.1, previousPrice + move)) + const spread = Math.max( + 0.01, + nextPrice * (0.00015 + this.#random() * 0.0005), + ) + + quote.lastMove = nextPrice - previousPrice + quote.price = nextPrice + quote.high = Math.max(quote.high, nextPrice) + quote.low = Math.min(quote.low, nextPrice) + quote.bid = roundPrice(nextPrice - spread / 2) + quote.ask = roundPrice(nextPrice + spread / 2) + quote.bidSize = Math.floor(100 + this.#random() * 25_000) + quote.askSize = Math.floor(100 + this.#random() * 25_000) + quote.lastSize = Math.floor(10 + this.#random() * 5_000) + quote.lastUpdatedAt = updatedAt + quote.volume += quote.lastSize + quote.turnover = roundMoney(quote.turnover + nextPrice * quote.lastSize) + + if (updateHistory) { + quote.history = [...quote.history.slice(-23), nextPrice] + } + } +} + +function createRandom(seed: number): () => number { + const runtime = { state: seed >>> 0 } + return () => { + runtime.state += 0x6d2b79f5 + const stateValue = runtime.state + const firstMix = Math.imul(stateValue ^ (stateValue >>> 15), stateValue | 1) + const secondMix = + firstMix + Math.imul(firstMix ^ (firstMix >>> 7), firstMix | 61) + const value = firstMix ^ secondMix + return ((value ^ (value >>> 14)) >>> 0) / 4_294_967_296 + } +} + +function roundPrice(value: number): number { + return Math.round(value * 100) / 100 +} + +function roundMoney(value: number): number { + return Math.round(value * 100) / 100 +} diff --git a/examples/ember/realtime-trading/app/feed/worker/market-feed-protocol.ts b/examples/ember/realtime-trading/app/feed/worker/market-feed-protocol.ts new file mode 100644 index 0000000000..21997ec89c --- /dev/null +++ b/examples/ember/realtime-trading/app/feed/worker/market-feed-protocol.ts @@ -0,0 +1,70 @@ +export interface MarketQuoteSnapshot { + id: string + symbol: string + company: string + venue: string + previousClose: number + open: number + high: number + low: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + volume: number + turnover: number + history: Array +} + +export interface MarketQuoteUpdate { + index: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + high: number + low: number + volume: number + turnover: number + history?: Array +} + +export type MarketFeedCommand = + | { + type: 'start' + rowCount: number + running: boolean + ticksPerSecond: number + publishIntervalMs: number + updateSparklines: boolean + sparklineSampleIntervalMs: number + } + | { type: 'set-running'; running: boolean } + | { type: 'set-rate'; ticksPerSecond: number } + | { type: 'set-publish-interval'; intervalMs: number } + | { type: 'set-sparklines'; enabled: boolean } + | { type: 'set-sparkline-interval'; intervalMs: number } + | { type: 'reset'; rowCount: number } + | { type: 'burst'; tickCount: number } + +export type MarketFeedEvent = + | { + type: 'snapshot' + sessionId: number + quotes: Array + } + | { + type: 'updates' + sessionId: number + tickCount: number + coalescedUpdateCount: number + updates: Array + } diff --git a/examples/ember/realtime-trading/app/feed/worker/market-feed.worker.ts b/examples/ember/realtime-trading/app/feed/worker/market-feed.worker.ts new file mode 100644 index 0000000000..2b7a642fd9 --- /dev/null +++ b/examples/ember/realtime-trading/app/feed/worker/market-feed.worker.ts @@ -0,0 +1,143 @@ +import { initialMarketFeedConfig } from '../market-feed-config' +import { MarketFeedEngine } from './market-feed-engine' +import type { + MarketFeedCommand, + MarketFeedEvent, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const engine = new MarketFeedEngine() +const pendingUpdates = new Map() +const runtime = { + sessionId: 0, + pendingTickCount: 0, + pendingCoalescedUpdateCount: 0, + initialized: false, + running: true, + ticksPerSecond: initialMarketFeedConfig.targetSamplesPerSecond, + publishIntervalMs: initialMarketFeedConfig.publishIntervalMs, + publishTimerId: null as ReturnType | null, + updateSparklines: initialMarketFeedConfig.updateSparklines, + sparklineSampleIntervalMs: initialMarketFeedConfig.sparklineSampleIntervalMs, + tickBudget: 0, + lastTickAt: performance.now(), +} + +addEventListener('message', ({ data }: MessageEvent) => { + switch (data.type) { + case 'start': + runtime.running = data.running + runtime.ticksPerSecond = data.ticksPerSecond + runtime.publishIntervalMs = data.publishIntervalMs + runtime.updateSparklines = data.updateSparklines + runtime.sparklineSampleIntervalMs = data.sparklineSampleIntervalMs + restartPublishTimer() + reset(data.rowCount) + break + case 'set-running': + runtime.running = data.running + break + case 'set-rate': + runtime.ticksPerSecond = data.ticksPerSecond + break + case 'set-publish-interval': + runtime.publishIntervalMs = Math.max(4, data.intervalMs) + restartPublishTimer() + break + case 'set-sparklines': + runtime.updateSparklines = data.enabled + break + case 'set-sparkline-interval': + runtime.sparklineSampleIntervalMs = Math.max(16, data.intervalMs) + break + case 'reset': + reset(data.rowCount) + break + case 'burst': + produceTicks(data.tickCount) + flush() + break + } +}) + +setInterval(() => { + const now = performance.now() + const elapsed = Math.min(100, Math.max(0, now - runtime.lastTickAt)) + runtime.lastTickAt = now + + if (runtime.initialized && runtime.running) { + runtime.tickBudget += (runtime.ticksPerSecond * elapsed) / 1_000 + const tickCount = Math.floor(runtime.tickBudget) + runtime.tickBudget -= tickCount + produceTicks(tickCount) + } +}, 16) + +restartPublishTimer() + +function reset(rowCount: number): void { + runtime.initialized = true + runtime.sessionId++ + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + runtime.tickBudget = 0 + runtime.lastTickAt = performance.now() + + post({ + type: 'snapshot', + sessionId: runtime.sessionId, + quotes: engine.reset(rowCount), + }) +} + +function produceTicks(tickCount: number): void { + if (!runtime.initialized || tickCount <= 0) return + + runtime.pendingTickCount += tickCount + for (const update of engine.applyTicks( + tickCount, + runtime.updateSparklines, + runtime.sparklineSampleIntervalMs, + )) { + const previousUpdate = pendingUpdates.get(update.index) + if (previousUpdate) runtime.pendingCoalescedUpdateCount++ + pendingUpdates.set(update.index, { + ...update, + ...(update.history || !previousUpdate?.history + ? {} + : { history: previousUpdate.history }), + }) + } +} + +function flush(): void { + if (runtime.pendingTickCount === 0) return + + const message: MarketFeedEvent = { + type: 'updates', + sessionId: runtime.sessionId, + tickCount: runtime.pendingTickCount, + coalescedUpdateCount: runtime.pendingCoalescedUpdateCount, + updates: [...pendingUpdates.values()], + } + + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + post(message) +} + +function restartPublishTimer(): void { + if (runtime.publishTimerId !== null) { + clearInterval(runtime.publishTimerId) + } + runtime.publishTimerId = setInterval( + flush, + Math.max(4, runtime.publishIntervalMs), + ) +} + +function post(event: MarketFeedEvent): void { + postMessage(event) +} diff --git a/examples/ember/realtime-trading/app/router.ts b/examples/ember/realtime-trading/app/router.ts new file mode 100644 index 0000000000..eadbe60450 --- /dev/null +++ b/examples/ember/realtime-trading/app/router.ts @@ -0,0 +1,51 @@ +import EmbroiderRouter from '@embroider/router' +import config from '#config' + +export default class Router extends EmbroiderRouter { + location = config.locationType + rootURL = config.rootURL +} + +Router.map(function () {}) + +/** + * Caveat: + * - https://github.com/embroider-build/embroider/issues/2521 + * We don't yet have a way to do this in a nice way + * + */ +// function bundle(name: string, loader: () => Promise<{ default: unknown }>[]) { +// return { +// names: [name], +// load: async () => { +// const [template, route, controller] = await Promise.all(loader()); +// let slashName = name.replaceAll(".", "/"); +// let results: Record = {}; + +// if (template) results[`./templates/${slashName}`] = template.default; +// if (route) results[`./routes/${slashName}`] = route.default; +// if (controller) results[`./controllers/${slashName}`] = controller.default; + +// return { +// default: results, +// }; +// }, +// }; +// } + +/** + * Examples from: + * - https://github.com/NullVoxPopuli/limber/blob/67e2f54bbe224052e38f9a9e566d704411e65e86/apps/repl/app/router.ts#L35 + */ +// (window as any)._embroiderRouteBundles_ = [ +// bundle("docs", () => [import("./templates/docs.gts")]), +// bundle("docs.repl-sdk", () => [import("./templates/docs/repl-sdk.gts")]), +// bundle("docs.ember-repl", () => [import("./templates/docs/ember-repl.gts")]), +// bundle("docs.embedding", () => [import("./templates/docs/embedding.gts")]), +// bundle("docs.editor", () => [import("./templates/docs/editor.gts")]), +// bundle("docs.whatever", () => [ +// import("./the/template.gts"), +// import("./the/route.ts"), +// import("./the/controller.ts"), +// ]), +// ]; diff --git a/examples/ember/realtime-trading/app/table/table-config/quote-cells.gts b/examples/ember/realtime-trading/app/table/table-config/quote-cells.gts new file mode 100644 index 0000000000..2c2f8796c6 --- /dev/null +++ b/examples/ember/realtime-trading/app/table/table-config/quote-cells.gts @@ -0,0 +1,220 @@ +import Component from '@glimmer/component' +import { registerDestructor } from '@ember/destroyable' +import { on } from '@ember/modifier' +import type Owner from '@ember/owner' +import type { CellRenderableSignature } from '@tanstack/ember-table' +import type { MarketQuote } from '../../feed/market-data' +import type { tradingFeatures } from '../trading-features' + +export const quoteCellLifecycle = { created: 0, destroyed: 0 } + +export const quoteCellRendererNames = [ + 'Market', + 'Name', + 'Symbol', + 'Last', + 'Change', + 'ChangePercent', + 'Bid', + 'BidVolume', + 'Ask', + 'AskVolume', + 'Open', + 'High', + 'Low', + 'Intraday', +] as const +export const quoteComponentNames = [ + 'PriceCell', + 'StableMoveCell', + 'UpMoveCell', + 'DownMoveCell', + 'PercentChangeCell', + 'SpreadCell', + 'DepthCell', + 'QuoteAgeCell', + 'SparklineCell', +] as const +export type QuoteCellRendererName = (typeof quoteCellRendererNames)[number] +export type QuoteComponentName = (typeof quoteComponentNames)[number] + +const createCounterMap = (names: ReadonlyArray) => + Object.fromEntries(names.map((name) => [name, 0])) as Record + +export const quoteRenderDiagnostics = { + cellRendererCalls: 0, + componentRenderCalls: 0, + cellRendererCallsByName: createCounterMap(quoteCellRendererNames), + componentRenderCallsByName: createCounterMap(quoteComponentNames), +} + +export function recordCellRender(name: QuoteCellRendererName, value: T): T { + quoteRenderDiagnostics.cellRendererCalls++ + quoteRenderDiagnostics.cellRendererCallsByName[name]++ + return value +} + +interface PriceOptions { + selectSymbol: (symbol: string) => void +} +abstract class QuoteCell extends Component { + constructor(owner: Owner, args: object, name: QuoteComponentName) { + super(owner, args) + quoteCellLifecycle.created++ + registerDestructor(this, () => { + quoteCellLifecycle.destroyed++ + }) + } +} + +export class PriceCell extends QuoteCell< + CellRenderableSignature< + typeof tradingFeatures, + MarketQuote, + number, + PriceOptions + > +> { + constructor(owner: Owner, args: object) { + super(owner, args, 'PriceCell') + } + get quote() { + return this.args.ctx.row.original + } + select = () => { + this.args.options?.selectSymbol(this.quote.symbol) + } + +} + +abstract class MoveCellBase extends QuoteCell< + CellRenderableSignature +> { + get move() { + return ( + this.args.ctx.row.original.price - + this.args.ctx.row.original.previousClose + ) + } + get positive() { + return this.move >= 0 + } +} + +export class StableMoveCell extends MoveCellBase { + constructor(owner: Owner, args: object) { + super(owner, args, 'StableMoveCell') + } + +} + +export class UpMoveCell extends MoveCellBase { + constructor(owner: Owner, args: object) { + super(owner, args, 'UpMoveCell') + } + +} + +export class DownMoveCell extends MoveCellBase { + constructor(owner: Owner, args: object) { + super(owner, args, 'DownMoveCell') + } + +} + +export class PercentChangeCell extends QuoteCell< + CellRenderableSignature +> { + constructor(owner: Owner, args: object) { + super(owner, args, 'PercentChangeCell') + } + get value() { + const quote = this.args.ctx.row.original + return quote.previousClose === 0 + ? 0 + : ((quote.price - quote.previousClose) / quote.previousClose) * 100 + } + +} + +export class SparklineCell extends QuoteCell< + CellRenderableSignature +> { + constructor(owner: Owner, args: object) { + super(owner, args, 'SparklineCell') + } + get values() { + return this.args.ctx.row.original.history + } + get rising() { + return (this.values.at(-1) ?? 0) >= (this.values[0] ?? 0) + } + get points() { + const first = this.values[0] ?? 0 + const range = this.values.reduce( + (result, value) => ({ + min: Math.min(result.min, value), + max: Math.max(result.max, value), + }), + { min: first, max: first }, + ) + const scale = range.max - range.min || 1 + const denominator = Math.max(1, this.values.length - 1) + return this.values + .map((value, index) => { + const x = (index / denominator) * 100 + const y = 22 - ((value - range.min) / scale) * 20 + return `${x.toFixed(1)},${y.toFixed(1)}` + }) + .join(' ') + } + +} + +const fixed = (value: number): string => value.toFixed(2) +const signed = (value: number): string => + `${value >= 0 ? '+' : ''}${value.toFixed(2)}` +const percent = (value: number): string => + `${value >= 0 ? '+' : ''}${value.toFixed(2)}%` +const nonNegative = (value: number): boolean => value >= 0 +const isPositive = (quote: MarketQuote): boolean => + quote.price - quote.previousClose >= 0 +const recordComponent = (name: QuoteComponentName): string => { + quoteRenderDiagnostics.componentRenderCalls++ + quoteRenderDiagnostics.componentRenderCallsByName[name]++ + return '' +} diff --git a/examples/ember/realtime-trading/app/table/table-config/trading-columns.gts b/examples/ember/realtime-trading/app/table/table-config/trading-columns.gts new file mode 100644 index 0000000000..73e8fc6340 --- /dev/null +++ b/examples/ember/realtime-trading/app/table/table-config/trading-columns.gts @@ -0,0 +1,209 @@ +import { createColumnHelper, flexRenderComponent } from '@tanstack/ember-table' +import { + DownMoveCell, + PercentChangeCell, + PriceCell, + SparklineCell, + StableMoveCell, + UpMoveCell, + recordCellRender, +} from './quote-cells.gts' +import { tradingFeatures } from '../trading-features' +import type { MarketQuote } from '../../feed/market-data' +import type { TradingBenchmarkController } from '../../benchmark/trading-benchmark-controller' + +export type RendererMode = 'stable' | 'swap' +export interface CoreTableState { + sorting: Array<{ id: string; desc: boolean }> + columnFilters: Array<{ id: string; value: unknown }> +} + +const compact = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const columnHelper = createColumnHelper() + +export function createTradingColumns( + controller: TradingBenchmarkController, + rendererMode: RendererMode, +) { + return columnHelper.columns([ + columnHelper.group({ + id: 'instrument', + header: 'Instrument', + columns: columnHelper.columns([ + columnHelper.accessor('venue', { + id: 'market', + header: 'Market', + size: 72, + cell: (info) => recordCellRender('Market', info.getValue()), + }), + columnHelper.accessor('company', { + id: 'name', + header: 'Name', + size: 180, + cell: (info) => recordCellRender('Name', info.getValue()), + }), + columnHelper.accessor('symbol', { + header: 'Symbol', + size: 92, + filterFn: 'includesString', + cell: (info) => recordCellRender('Symbol', info.getValue()), + }), + ]), + }), + columnHelper.group({ + id: 'priceAndChange', + header: 'Price & Change', + columns: columnHelper.columns([ + columnHelper.accessor('price', { + header: 'Price', + size: 96, + sortFn: 'basic', + cell: () => + recordCellRender( + 'Last', + flexRenderComponent(PriceCell, { + selectSymbol: controller.actions.selectSymbol, + }), + ), + }), + columnHelper.accessor(getDayChange, { + id: 'change', + header: 'Chg', + size: 94, + cell: (info) => + recordCellRender( + 'Change', + rendererMode === 'stable' + ? flexRenderComponent(StableMoveCell) + : info.getValue() >= 0 + ? flexRenderComponent(UpMoveCell) + : flexRenderComponent(DownMoveCell), + ), + }), + columnHelper.accessor(getDayChangePercent, { + id: 'changePercent', + header: 'Chg%', + size: 90, + cell: () => + recordCellRender( + 'ChangePercent', + flexRenderComponent(PercentChangeCell), + ), + }), + ]), + }), + columnHelper.group({ + id: 'orderBook', + header: 'Order Book', + columns: columnHelper.columns([ + columnHelper.accessor('bid', { + header: 'Bid', + size: 90, + cell: (info) => recordCellRender('Bid', info.getValue().toFixed(2)), + }), + columnHelper.accessor('bidSize', { + header: 'Bid Vol', + size: 100, + cell: (info) => + recordCellRender('BidVolume', compact.format(info.getValue())), + }), + columnHelper.accessor('ask', { + header: 'Ask', + size: 90, + cell: (info) => recordCellRender('Ask', info.getValue().toFixed(2)), + }), + columnHelper.accessor('askSize', { + header: 'Ask Vol', + size: 100, + cell: (info) => + recordCellRender('AskVolume', compact.format(info.getValue())), + }), + ]), + }), + columnHelper.group({ + id: 'session', + header: 'Session', + columns: columnHelper.columns([ + columnHelper.accessor('open', { + header: 'Open', + size: 90, + cell: (info) => recordCellRender('Open', info.getValue().toFixed(2)), + }), + columnHelper.accessor('high', { + header: 'High', + size: 90, + cell: (info) => recordCellRender('High', info.getValue().toFixed(2)), + }), + columnHelper.accessor('low', { + header: 'Low', + size: 90, + cell: (info) => recordCellRender('Low', info.getValue().toFixed(2)), + }), + ]), + }), + columnHelper.group({ + id: 'chart', + header: 'Chart', + columns: columnHelper.columns([ + columnHelper.accessor('history', { + header: 'Intraday', + size: 150, + enableSorting: false, + cell: () => + recordCellRender('Intraday', flexRenderComponent(SparklineCell)), + }), + ]), + }), + ]) +} + +export const rowModelDiagnostics = { + hasMeasurement: false, + calls: 0, + totalDurationMs: 0, + maxDurationMs: 0, + lastRowCount: 0, +} +export const TRADING_COLUMN_COUNT = 14 + +export function readMeasuredRows(readRows: () => Array): Array { + const start = performance.now() + const rows = readRows() + const end = performance.now() + const duration = end - start + rowModelDiagnostics.calls++ + rowModelDiagnostics.hasMeasurement = true + rowModelDiagnostics.totalDurationMs += duration + rowModelDiagnostics.maxDurationMs = Math.max( + rowModelDiagnostics.maxDurationMs, + duration, + ) + rowModelDiagnostics.lastRowCount = rows.length + if ((rowModelDiagnostics.calls - 1) % 20 !== 0) return rows + try { + performance.measure('tanstack-row-model', { + start, + end, + detail: { rowCount: rows.length }, + }) + if (rowModelDiagnostics.calls % 20_000 === 0) { + performance.clearMeasures('tanstack-row-model') + } + } catch { + /* optional User Timing detail */ + } + return rows +} + +export function getDayChange(quote: MarketQuote): number { + return quote.price - quote.previousClose +} + +export function getDayChangePercent(quote: MarketQuote): number { + return quote.previousClose === 0 + ? 0 + : (getDayChange(quote) / quote.previousClose) * 100 +} diff --git a/examples/ember/realtime-trading/app/table/table-interactions.ts b/examples/ember/realtime-trading/app/table/table-interactions.ts new file mode 100644 index 0000000000..a32e9d5963 --- /dev/null +++ b/examples/ember/realtime-trading/app/table/table-interactions.ts @@ -0,0 +1,189 @@ +export type CellDirection = 'up' | 'down' | 'left' | 'right' + +interface RowSelectionTable { + resetRowSelection: (defaultState?: boolean) => void +} + +interface SelectableRow { + getIsSelected: () => boolean + getToggleSelectedHandler: (options?: { + selectChildren?: boolean + }) => (event: unknown) => void +} + +interface SelectableGridCell { + row: SelectableGridRow + getSelectionStartHandler: ( + contextDocument?: Document, + ) => (event: unknown) => void + getSelectionExtendHandler: () => (event: unknown) => void +} + +interface SelectableGridRow extends SelectableRow { + original: { symbol: string } + getAllCellsByColumnId: () => Record +} + +interface TradingGridTable extends RowSelectionTable { + getRowModel: () => { + rowsById: Record + } +} + +interface SelectionCellTarget { + element: HTMLTableCellElement + cell: SelectableGridCell +} + +interface CellNavigationTable { + extendCellSelection: (direction: CellDirection) => void + moveCellSelection: (direction: CellDirection) => void + resetCellSelection: (defaultState?: boolean) => void + selectAllCells: () => void +} + +const keyDirections: Partial> = { + ArrowUp: 'up', + ArrowDown: 'down', + ArrowLeft: 'left', + ArrowRight: 'right', +} + +export function reorderColumnIds( + columnIds: Array, + sourceId: string, + targetId: string, +): Array { + if (sourceId === targetId || !columnIds.includes(sourceId)) return columnIds + + const withoutSource = columnIds.filter((id) => id !== sourceId) + const targetIndex = withoutSource.indexOf(targetId) + if (targetIndex < 0) return columnIds + + return [ + ...withoutSource.slice(0, targetIndex), + sourceId, + ...withoutSource.slice(targetIndex), + ] +} + +export function selectRowFromPointer( + table: RowSelectionTable, + row: SelectableRow, + event: MouseEvent, +): void { + const additive = event.ctrlKey || event.metaKey + const checked = additive ? !row.getIsSelected() : true + + if (!event.shiftKey && !additive) table.resetRowSelection(true) + + row.getToggleSelectedHandler({ selectChildren: false })({ + target: { checked }, + shiftKey: event.shiftKey, + ctrlKey: event.ctrlKey, + metaKey: event.metaKey, + }) +} + +export class TradingGridPointerController { + #lastPointerCell: HTMLTableCellElement | null = null + + handleMouseDown( + table: TradingGridTable, + event: MouseEvent, + selectSymbol: (symbol: string) => void, + ): void { + if (event.button !== 0) return + + const target = this.#findCellTarget(table, event.composedPath()) + if (!target) return + + event.preventDefault() + this.#lastPointerCell = target.element + selectSymbol(target.cell.row.original.symbol) + target.cell.getSelectionStartHandler(target.element.ownerDocument)(event) + } + + handlePointerOver(table: TradingGridTable, event: MouseEvent): void { + if ((event.buttons & 1) === 0) { + this.resetPointerCell() + return + } + + const target = this.#findCellTarget(table, event.composedPath()) + if (!target || target.element === this.#lastPointerCell) return + + this.#lastPointerCell = target.element + target.cell.getSelectionExtendHandler()(event) + } + + handleClick(table: TradingGridTable, event: MouseEvent): void { + const target = this.#findCellTarget(table, event.composedPath()) + if (!target) return + selectRowFromPointer(table, target.cell.row, event) + } + + resetPointerCell(): void { + this.#lastPointerCell = null + } + + #findCellTarget( + table: TradingGridTable, + path: Array, + ): SelectionCellTarget | null { + for (const target of path) { + if (!(target instanceof HTMLTableCellElement)) continue + + const columnId = target.dataset['columnId'] + const rowId = + target.closest('tr[data-row-id]')?.dataset['rowId'] + if (!columnId || !rowId) return null + + const row = table.getRowModel().rowsById[rowId] + if (!row) return null + const cell = row.getAllCellsByColumnId()[columnId] + if (!cell) return null + return { element: target, cell } + } + + return null + } +} + +export function handleCellNavigation( + table: CellNavigationTable, + event: KeyboardEvent, +): void { + if (event.key === 'Escape') { + event.preventDefault() + table.resetCellSelection(true) + return + } + + if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a') { + event.preventDefault() + table.selectAllCells() + return + } + + const direction = keyDirections[event.key] + if (!direction) return + + event.preventDefault() + if (event.shiftKey) table.extendCellSelection(direction) + else table.moveCellSelection(direction) +} + +export function sortIndicator(direction: false | 'asc' | 'desc'): string { + if (direction === 'asc') return '↑' + if (direction === 'desc') return '↓' + return '↕' +} + +export function sortAriaValue( + direction: false | 'asc' | 'desc', +): 'ascending' | 'descending' | 'none' { + if (direction === 'asc') return 'ascending' + if (direction === 'desc') return 'descending' + return 'none' +} diff --git a/examples/ember/realtime-trading/app/table/trading-features.ts b/examples/ember/realtime-trading/app/table/trading-features.ts new file mode 100644 index 0000000000..7d0a780dda --- /dev/null +++ b/examples/ember/realtime-trading/app/table/trading-features.ts @@ -0,0 +1,16 @@ +import { + createFilteredRowModel, + createSortedRowModel, + filterFn_includesString, + sortFn_basic, + stockFeatures, + tableFeatures, +} from '@tanstack/ember-table' + +export const tradingFeatures = tableFeatures({ + ...stockFeatures, + filteredRowModel: createFilteredRowModel(), + sortedRowModel: createSortedRowModel(), + filterFns: { includesString: filterFn_includesString }, + sortFns: { basic: sortFn_basic }, +}) diff --git a/examples/ember/realtime-trading/app/table/trading-table.ts b/examples/ember/realtime-trading/app/table/trading-table.ts new file mode 100644 index 0000000000..6e1059f144 --- /dev/null +++ b/examples/ember/realtime-trading/app/table/trading-table.ts @@ -0,0 +1,8 @@ +export { + TRADING_COLUMN_COUNT, + rowModelDiagnostics, +} from './table-config/trading-columns.gts' +export type { + CoreTableState, + RendererMode, +} from './table-config/trading-columns.gts' diff --git a/examples/ember/realtime-trading/app/templates/application.gts b/examples/ember/realtime-trading/app/templates/application.gts new file mode 100644 index 0000000000..695fb27818 --- /dev/null +++ b/examples/ember/realtime-trading/app/templates/application.gts @@ -0,0 +1,25 @@ +import Component from '@glimmer/component' +import { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' +import { MarketFeedController } from '../feed/market-feed-controller' +import TradingShell from '../components/shell/trading-shell.gts' +import { registerCleanup } from '../utils/subscriptions' +import type Owner from '@ember/owner' + +export default class Application extends Component { + readonly feed = new MarketFeedController() + readonly controller = new TradingBenchmarkController(this.feed) + + constructor(owner: Owner, args: object) { + super(owner, args) + const stopFeed = this.feed.start() + const stopBenchmark = this.controller.start() + registerCleanup(this, () => { + stopBenchmark() + stopFeed() + }) + } + + +} diff --git a/examples/ember/realtime-trading/app/utils/subscriptions.ts b/examples/ember/realtime-trading/app/utils/subscriptions.ts new file mode 100644 index 0000000000..7d6ea1eaeb --- /dev/null +++ b/examples/ember/realtime-trading/app/utils/subscriptions.ts @@ -0,0 +1,5 @@ +import { registerDestructor } from '@ember/destroyable' + +export function registerCleanup(owner: object, cleanup: () => void): void { + registerDestructor(owner, cleanup) +} diff --git a/examples/ember/realtime-trading/babel.config.js b/examples/ember/realtime-trading/babel.config.js new file mode 100644 index 0000000000..2cca5822ec --- /dev/null +++ b/examples/ember/realtime-trading/babel.config.js @@ -0,0 +1,45 @@ +import { buildMacros } from '@embroider/macros/babel' + +const macros = buildMacros({ + configure(config) { + if (process.env.EMBER_ENV === 'test') { + config.enableRuntimeMode() + } + }, +}) + +export default { + plugins: [ + [ + '@babel/plugin-transform-typescript', + { + onlyRemoveTypeImports: true, + }, + ], + [ + 'babel-plugin-ember-template-compilation', + { + transforms: [...macros.templateMacros], + }, + ], + [ + 'module:decorator-transforms', + { + runtime: { + import: import.meta.resolve('decorator-transforms/runtime-esm'), + }, + }, + ], + [ + '@babel/plugin-transform-runtime', + { + absoluteRuntime: import.meta.dirname, + }, + ], + ...macros.babelMacros, + ], + + generatorOpts: { + compact: false, + }, +} diff --git a/examples/ember/realtime-trading/index.html b/examples/ember/realtime-trading/index.html new file mode 100644 index 0000000000..b9dbf7e836 --- /dev/null +++ b/examples/ember/realtime-trading/index.html @@ -0,0 +1,17 @@ + + + + + Minimal App + + + + + + + diff --git a/examples/ember/realtime-trading/package.json b/examples/ember/realtime-trading/package.json new file mode 100644 index 0000000000..b270f10525 --- /dev/null +++ b/examples/ember/realtime-trading/package.json @@ -0,0 +1,66 @@ +{ + "name": "tanstack-ember-table-example-realtime-trading", + "private": true, + "type": "module", + "imports": { + "#app/*": "./app/*", + "#config": "./app/config.ts", + "#components/*": "./app/components/*", + "#services/*": "./app/services/*", + "#test-helpers/*": "./tests/helpers/*", + "#utils/*": "./app/utils/*" + }, + "exports": { + "./tests/*": "./tests/*", + "./*": "./app/*" + }, + "scripts": { + "dev": "vite", + "build": "vite build", + "serve": "vite preview", + "start": "vite", + "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts", + "test:types": "ember-tsc --noEmit" + }, + "nx": { + "targets": { + "test:e2e": { + "parallelism": false + } + } + }, + "dependencies": { + "@embroider/macros": "1.21.4", + "@embroider/router": "3.0.6", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", + "@tanstack/store": "^0.11.2", + "decorator-transforms": "2.4.0", + "ember-modifier": "^4.3.0", + "ember-source": "7.4.0", + "ember-strict-application-resolver": "0.1.1" + }, + "devDependencies": { + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rollup/plugin-babel": "7.1.0", + "babel-plugin-ember-template-compilation": "4.0.1", + "typescript": "6.0.3", + "vite": "^8.3.8" + }, + "engines": { + "node": ">= 24.11" + }, + "ember": { + "edition": "octane" + } +} diff --git a/examples/ember/realtime-trading/tests/e2e/smoke.spec.ts b/examples/ember/realtime-trading/tests/e2e/smoke.spec.ts new file mode 100644 index 0000000000..a3e2f967b2 --- /dev/null +++ b/examples/ember/realtime-trading/tests/e2e/smoke.spec.ts @@ -0,0 +1,59 @@ +import path from 'node:path' +import { expect, test } from '@playwright/test' +import { startExampleServer } from '../../../../../tests/e2e/helpers/startExampleServer' +import { pausedFeedUrl } from '../../../../../tests/e2e/helpers/setRangeValue' +import type { Page } from '@playwright/test' + +const exampleDir = path.resolve() + +let server: Awaited> + +function collectPageErrors(page: Page) { + const errors: Array = [] + page.on('pageerror', (error) => errors.push(error.message)) + page.on('console', (message) => { + if (message.type() === 'error') errors.push(message.text()) + }) + return errors +} + +test.beforeAll(async () => { + test.setTimeout(120_000) + server = await startExampleServer(exampleDir) + await fetch(pausedFeedUrl(server.url)) +}) + +test.afterAll(async () => { + await server.close() +}) + +test('loads the Ember realtime trading table', async ({ page }) => { + test.setTimeout(60_000) + const errors = collectPageErrors(page) + + await page.goto(pausedFeedUrl(server.url)) + + const table = page.getByTestId('trading-table') + await expect(table).toBeVisible() + await expect(page.locator('.brand')).toHaveText('MARKET MONITOR') + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(table.locator('thead tr')).toHaveCount(2) + await expect(table.locator('thead tr').last().locator('th')).toHaveCount(14) + await expect(table.locator('thead')).toContainText('Market') + await expect(table.locator('thead')).toContainText('Bid Vol') + await expect(table.locator('thead')).toContainText('Intraday') + + const selectedRow = table.locator('tbody tr').first() + const selectedSymbol = await selectedRow.getAttribute('data-symbol') + await selectedRow.locator('td').nth(1).click() + await expect(page.getByTestId('selected-instrument')).toContainText( + selectedSymbol ?? '', + ) + + expect( + await page.evaluate( + () => performance.getEntriesByName('tanstack-row-model').length > 0, + ), + ).toBe(true) + expect(errors).toEqual([]) +}) diff --git a/examples/ember/realtime-trading/tsconfig.json b/examples/ember/realtime-trading/tsconfig.json new file mode 100644 index 0000000000..c4f982dc22 --- /dev/null +++ b/examples/ember/realtime-trading/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "@ember/app-tsconfig", + "compilerOptions": { + "allowJs": true, + "lib": ["ES2025", "DOM", "DOM.Iterable"], + "types": [ + "ember-source/types", + "@embroider/core/virtual", + "vite/client", + "@glint/ember-tsc/types" + ] + } +} diff --git a/examples/ember/realtime-trading/vite.config.mjs b/examples/ember/realtime-trading/vite.config.mjs new file mode 100644 index 0000000000..0f024aaa3b --- /dev/null +++ b/examples/ember/realtime-trading/vite.config.mjs @@ -0,0 +1,10 @@ +import { defineConfig } from 'vite' +import { ember } from '@nullvoxpopuli/ember-vite' + +export default defineConfig({ + server: { + port: 7777, + allowedHosts: true, + }, + plugins: [ember()], +}) diff --git a/examples/ember/remote-data/babel.config.js b/examples/ember/remote-data/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/remote-data/babel.config.js +++ b/examples/ember/remote-data/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/remote-data/package.json b/examples/ember/remote-data/package.json index 2b9d0b23c8..5123819fa0 100644 --- a/examples/ember/remote-data/package.json +++ b/examples/ember/remote-data/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/row-dnd/babel.config.js b/examples/ember/row-dnd/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/row-dnd/babel.config.js +++ b/examples/ember/row-dnd/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/row-dnd/package.json b/examples/ember/row-dnd/package.json index 03e0e8ac71..5c5551f9c6 100644 --- a/examples/ember/row-dnd/package.json +++ b/examples/ember/row-dnd/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/row-pinning/babel.config.js b/examples/ember/row-pinning/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/row-pinning/babel.config.js +++ b/examples/ember/row-pinning/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/row-pinning/package.json b/examples/ember/row-pinning/package.json index d0419e8831..c76033458e 100644 --- a/examples/ember/row-pinning/package.json +++ b/examples/ember/row-pinning/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/row-selection/babel.config.js b/examples/ember/row-selection/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/row-selection/babel.config.js +++ b/examples/ember/row-selection/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/row-selection/package.json b/examples/ember/row-selection/package.json index 01526f4872..39648493d3 100644 --- a/examples/ember/row-selection/package.json +++ b/examples/ember/row-selection/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/sorting/babel.config.js b/examples/ember/sorting/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/sorting/babel.config.js +++ b/examples/ember/sorting/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/sorting/package.json b/examples/ember/sorting/package.json index d31af77ffe..8a3e2704f2 100644 --- a/examples/ember/sorting/package.json +++ b/examples/ember/sorting/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/ember/sub-components/babel.config.js b/examples/ember/sub-components/babel.config.js index 10915e4299..2cca5822ec 100644 --- a/examples/ember/sub-components/babel.config.js +++ b/examples/ember/sub-components/babel.config.js @@ -13,9 +13,7 @@ export default { [ '@babel/plugin-transform-typescript', { - allExtensions: true, onlyRemoveTypeImports: true, - allowDeclareFields: true, }, ], [ @@ -36,8 +34,6 @@ export default { '@babel/plugin-transform-runtime', { absoluteRuntime: import.meta.dirname, - useESModules: true, - regenerator: false, }, ], ...macros.babelMacros, diff --git a/examples/ember/sub-components/package.json b/examples/ember/sub-components/package.json index cbeef90142..64624d531e 100644 --- a/examples/ember/sub-components/package.json +++ b/examples/ember/sub-components/package.json @@ -23,33 +23,34 @@ "test:types": "ember-tsc --noEmit" }, "dependencies": { - "@embroider/macros": "1.20.6", + "@embroider/macros": "1.21.4", "@embroider/router": "3.0.6", - "@faker-js/faker": "^10.5.0", - "@glimmer/component": "2.1.1", - "@tanstack/ember-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@glimmer/component": "2.2.1", + "@tanstack/ember-table": "^9.3.2", "decorator-transforms": "2.4.0", - "ember-source": "7.2.0", + "ember-source": "7.4.0", "ember-strict-application-resolver": "0.1.1" }, "devDependencies": { - "@babel/core": "7.29.7", - "@babel/plugin-transform-runtime": "7.29.7", - "@babel/plugin-transform-typescript": "7.29.7", - "@babel/runtime": "7.29.7", - "@ember/app-tsconfig": "2.0.0", - "@embroider/core": "4.6.3", - "@glint/ember-tsc": "1.10.0", - "@glint/template": "1.8.0", - "@glint/tsserver-plugin": "2.7.0", - "@nullvoxpopuli/ember-vite": "1.1.0", + "@babel/core": "8.1.2", + "@babel/plugin-transform-runtime": "8.1.2", + "@babel/plugin-transform-typescript": "8.0.6", + "@babel/runtime": "8.1.2", + "@ember/app-tsconfig": "2.1.0", + "@embroider/core": "4.6.10", + "@glint/ember-tsc": "1.14.3", + "@glint/template": "1.11.1", + "@glint/tsserver-plugin": "2.7.16", + "@nullvoxpopuli/ember-vite": "1.5.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-babel": "7.1.0", - "babel-plugin-ember-template-compilation": "4.0.0", + "babel-plugin-ember-template-compilation": "4.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "engines": { - "node": ">= 24" + "node": ">= 24.11" }, "ember": { "edition": "octane" diff --git a/examples/lit/aggregation/package.json b/examples/lit/aggregation/package.json index cf33858204..532c4fa30b 100644 --- a/examples/lit/aggregation/package.json +++ b/examples/lit/aggregation/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/basic-app-table/package.json b/examples/lit/basic-app-table/package.json index e561899177..3a899160ff 100644 --- a/examples/lit/basic-app-table/package.json +++ b/examples/lit/basic-app-table/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", "@lit/context": "^1.1.6", - "@tanstack/lit-table": "^9.1.2", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/basic-dynamic-columns/package.json b/examples/lit/basic-dynamic-columns/package.json index 9e6b8eead2..d135e5ddfb 100644 --- a/examples/lit/basic-dynamic-columns/package.json +++ b/examples/lit/basic-dynamic-columns/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/basic-external-atoms/package.json b/examples/lit/basic-external-atoms/package.json index 69fd20098c..d26f10c785 100644 --- a/examples/lit/basic-external-atoms/package.json +++ b/examples/lit/basic-external-atoms/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", - "@tanstack/store": "^0.11.1", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", + "@tanstack/store": "^0.11.2", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/basic-external-state/package.json b/examples/lit/basic-external-state/package.json index 424ae48f67..255717e4c8 100644 --- a/examples/lit/basic-external-state/package.json +++ b/examples/lit/basic-external-state/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/basic-subscribe/package.json b/examples/lit/basic-subscribe/package.json index de83636c17..b5acb87edd 100644 --- a/examples/lit/basic-subscribe/package.json +++ b/examples/lit/basic-subscribe/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-store": "^0.14.1", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-store": "^0.14.2", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/basic-table-controller/package.json b/examples/lit/basic-table-controller/package.json index f87fc54903..3bbf011bed 100644 --- a/examples/lit/basic-table-controller/package.json +++ b/examples/lit/basic-table-controller/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/cell-selection/package.json b/examples/lit/cell-selection/package.json index 908939f963..a518cc3082 100644 --- a/examples/lit/cell-selection/package.json +++ b/examples/lit/cell-selection/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-hotkeys": "^0.11.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-hotkeys": "^0.26.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/cell-selection/src/main.ts b/examples/lit/cell-selection/src/main.ts index 2fb34d8319..2cef6941b4 100644 --- a/examples/lit/cell-selection/src/main.ts +++ b/examples/lit/cell-selection/src/main.ts @@ -1,8 +1,9 @@ import { customElement, state } from 'lit/decorators.js' import { LitElement, css, html } from 'lit' +import { createRef, ref } from 'lit/directives/ref.js' import { repeat } from 'lit/directives/repeat.js' import { faker } from '@faker-js/faker' -import { createMultiHotkeyHandler } from '@tanstack/lit-hotkeys' +import { HotkeyController } from '@tanstack/lit-hotkeys' import { FlexRender, TableController, @@ -18,6 +19,7 @@ import { tableFeatures, } from '@tanstack/lit-table' import { makeData } from './makeData' +import type { HotkeyChord } from '@tanstack/lit-hotkeys' import type { Cell, ColumnDef, LitTable } from '@tanstack/lit-table' import type { Person } from './makeData' @@ -120,6 +122,33 @@ export class LitCellSelectionExample extends LitElement { private _isFirstColumnLayout = true private _lastLayoutKey = '' private _table?: LitTable + private _grid = createRef() + + // keyboard navigation is TanStack Hotkeys driving the table's imperative + // APIs; table-core ships no keydown handling of its own. Each binding gets a + // HotkeyController whose `target` is the grid element, so the hotkeys only + // fire while the grid (or a cell inside it) has focus. The controllers read + // the target after each render, once the ref is set. + private _gridHotkeys = ( + [ + ['ArrowUp', () => this._table?.moveCellSelection('up')], + ['ArrowDown', () => this._table?.moveCellSelection('down')], + ['ArrowLeft', () => this._table?.moveCellSelection('left')], + ['ArrowRight', () => this._table?.moveCellSelection('right')], + ['Shift+ArrowUp', () => this._table?.extendCellSelection('up')], + ['Shift+ArrowDown', () => this._table?.extendCellSelection('down')], + ['Shift+ArrowLeft', () => this._table?.extendCellSelection('left')], + ['Shift+ArrowRight', () => this._table?.extendCellSelection('right')], + ['Mod+A', () => this._table?.selectAllCells()], + ['Escape', () => this._table?.resetCellSelection(true)], + ['Mod+C', () => this._table && this.copySelection(this._table)], + ] satisfies Array<[HotkeyChord, () => void]> + ).map( + ([hotkey, callback]) => + new HotkeyController(this, hotkey, callback, () => ({ + target: this._grid.value, + })), + ) // Lit renders into shadow DOM, so the demo styles live here rather than in a // global stylesheet. The selection outline uses inset box-shadows: on a @@ -293,23 +322,6 @@ export class LitCellSelectionExample extends LitElement { this._table = table - // keyboard navigation is TanStack Hotkeys driving the table's imperative - // APIs; table-core ships no keydown handling of its own. One stateless - // handler is simpler here than eleven HotkeyControllers. - const onGridKeyDown = createMultiHotkeyHandler({ - ArrowUp: () => table.moveCellSelection('up'), - ArrowDown: () => table.moveCellSelection('down'), - ArrowLeft: () => table.moveCellSelection('left'), - ArrowRight: () => table.moveCellSelection('right'), - 'Shift+ArrowUp': () => table.extendCellSelection('up'), - 'Shift+ArrowDown': () => table.extendCellSelection('down'), - 'Shift+ArrowLeft': () => table.extendCellSelection('left'), - 'Shift+ArrowRight': () => table.extendCellSelection('right'), - 'Mod+A': () => table.selectAllCells(), - Escape: () => table.resetCellSelection(true), - 'Mod+C': () => this.copySelection(table), - }) - return html`
-
+
${repeat( diff --git a/examples/lit/cell-spanning/package.json b/examples/lit/cell-spanning/package.json index 6b2e8e3ab8..c5cb49f39f 100644 --- a/examples/lit/cell-spanning/package.json +++ b/examples/lit/cell-spanning/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/column-ordering/package.json b/examples/lit/column-ordering/package.json index d235129720..daa3b0335d 100644 --- a/examples/lit/column-ordering/package.json +++ b/examples/lit/column-ordering/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/column-pinning-split/package.json b/examples/lit/column-pinning-split/package.json index 2f37c3a8cd..5d3eff653e 100644 --- a/examples/lit/column-pinning-split/package.json +++ b/examples/lit/column-pinning-split/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/column-pinning-sticky/package.json b/examples/lit/column-pinning-sticky/package.json index d5fea59b9c..e99c1f8489 100644 --- a/examples/lit/column-pinning-sticky/package.json +++ b/examples/lit/column-pinning-sticky/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/column-pinning/package.json b/examples/lit/column-pinning/package.json index 4d4b216f5c..3fc0e4b785 100644 --- a/examples/lit/column-pinning/package.json +++ b/examples/lit/column-pinning/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/column-resizing-performant/package.json b/examples/lit/column-resizing-performant/package.json index 69467d0013..6696333099 100644 --- a/examples/lit/column-resizing-performant/package.json +++ b/examples/lit/column-resizing-performant/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/column-resizing/package.json b/examples/lit/column-resizing/package.json index ea24d53b32..417e9a56c0 100644 --- a/examples/lit/column-resizing/package.json +++ b/examples/lit/column-resizing/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/column-sizing/package.json b/examples/lit/column-sizing/package.json index 90b8ed0a72..9a260ef228 100644 --- a/examples/lit/column-sizing/package.json +++ b/examples/lit/column-sizing/package.json @@ -11,13 +11,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/column-visibility/package.json b/examples/lit/column-visibility/package.json index 50a416f8b2..1ebfc1f747 100644 --- a/examples/lit/column-visibility/package.json +++ b/examples/lit/column-visibility/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/composable-tables/package.json b/examples/lit/composable-tables/package.json index 9f35fdc962..6f0f62ae25 100644 --- a/examples/lit/composable-tables/package.json +++ b/examples/lit/composable-tables/package.json @@ -12,14 +12,15 @@ "lint": "eslint ./src" }, "dependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", "@lit/context": "^1.1.6", - "@tanstack/lit-table": "^9.1.2", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/expanding/package.json b/examples/lit/expanding/package.json index ade717cb39..84eb4e93d0 100644 --- a/examples/lit/expanding/package.json +++ b/examples/lit/expanding/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/filters-faceted-bucketed/package.json b/examples/lit/filters-faceted-bucketed/package.json index e5304c811c..e42cb649c2 100644 --- a/examples/lit/filters-faceted-bucketed/package.json +++ b/examples/lit/filters-faceted-bucketed/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/filters-faceted/package.json b/examples/lit/filters-faceted/package.json index 71a8ea19af..c51f35e809 100644 --- a/examples/lit/filters-faceted/package.json +++ b/examples/lit/filters-faceted/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/filters-fuzzy/package.json b/examples/lit/filters-fuzzy/package.json index 580df96514..ef47009b20 100644 --- a/examples/lit/filters-fuzzy/package.json +++ b/examples/lit/filters-fuzzy/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", - "@tanstack/match-sorter-utils": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", + "@tanstack/match-sorter-utils": "^9.2.6", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/filters/package.json b/examples/lit/filters/package.json index 4185b07921..cccfd312a2 100644 --- a/examples/lit/filters/package.json +++ b/examples/lit/filters/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/grouped-aggregation/package.json b/examples/lit/grouped-aggregation/package.json index 777384f646..0353775f29 100644 --- a/examples/lit/grouped-aggregation/package.json +++ b/examples/lit/grouped-aggregation/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/grouping/package.json b/examples/lit/grouping/package.json index 56f5c94afb..4333c10c02 100644 --- a/examples/lit/grouping/package.json +++ b/examples/lit/grouping/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/header-groups/package.json b/examples/lit/header-groups/package.json index 12d1399621..4383cd74e7 100644 --- a/examples/lit/header-groups/package.json +++ b/examples/lit/header-groups/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/kitchen-sink/package.json b/examples/lit/kitchen-sink/package.json index 79d1391d9a..4673273c10 100644 --- a/examples/lit/kitchen-sink/package.json +++ b/examples/lit/kitchen-sink/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", - "@tanstack/match-sorter-utils": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", + "@tanstack/match-sorter-utils": "^9.2.6", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/pagination/package.json b/examples/lit/pagination/package.json index 2f2ae7f86f..a97f4547c8 100644 --- a/examples/lit/pagination/package.json +++ b/examples/lit/pagination/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/realtime-trading/.gitignore b/examples/lit/realtime-trading/.gitignore new file mode 100644 index 0000000000..1502ec233f --- /dev/null +++ b/examples/lit/realtime-trading/.gitignore @@ -0,0 +1,3 @@ +dist +node_modules + diff --git a/examples/lit/realtime-trading/README.md b/examples/lit/realtime-trading/README.md new file mode 100644 index 0000000000..4ff29124a5 --- /dev/null +++ b/examples/lit/realtime-trading/README.md @@ -0,0 +1,147 @@ +# Lit realtime trading benchmark + +This standalone example exercises the current TanStack Lit Table adapter with +a high-frequency worker feed, immutable snapshots, interactive columns, custom +elements for quote cells, Lit Virtual, and browser diagnostics. It is a +repeatable rendering workload, not an exchange or network benchmark. + +## Run and verify + +```bash +pnpm --dir examples/lit/realtime-trading dev +``` + +Open `http://localhost:7777`. + +```bash +pnpm --dir examples/lit/realtime-trading test:types +pnpm --dir examples/lit/realtime-trading lint +pnpm --dir examples/lit/realtime-trading build +pnpm --dir examples/lit/realtime-trading test:e2e +``` + +Use the production build for measurements. + +## Structure and ownership + +| Path | Responsibility | +| --------------------------------- | ------------------------------------------------------------------------------------------------------ | +| `src/feed/` | Market types, instruments, configuration, immutable updates, and direct TanStack atom feed controller. | +| `src/feed/worker/` | Protocol, deterministic engine, and module worker. | +| `src/benchmark/` | Browser monitor, benchmark controller, table timing, and row-model diagnostics. | +| `src/shell/` | Custom elements for header, metrics, controls, diagnostics, selected instrument, status, and layout. | +| `src/shell/controller-element.ts` | Base element that subscribes to controller sources and releases subscriptions on disconnect. | +| `src/table/table-config/` | Grouped columns and custom quote cell elements. | +| `src/table/` | Lit Table element, delegated interactions, column layout, and Lit Virtual integration. | +| `src/main.ts` | Root custom element that creates, starts, stops, and passes the controllers. | + +The feed controller is independent from the benchmark controller. The root +passes stable controller objects; each shell/table custom element observes the +specific atom/store sources it consumes. Quotes and every feed control/status +value are independent direct atoms; the table observes only `quotes` and +`instrumentCount`. `ControllerElement` converts those +notifications into `requestUpdate()` and guarantees unsubscribe on disconnect, +avoiding one broad application-level subscription. + +## Feed and worker pipeline + +Defaults are 100 instruments, 10K generated samples/s, 20 ms delivery, enabled +intraday charts, and 16 ms chart sampling. + +Mutable market state stays inside the worker. A deterministic 16 ms budget loop +generates samples, a row-indexed `Map` coalesces repeated instrument changes, +and an independent timer publishes the latest unique rows. The main thread +creates a new outer array and only new changed rows; untouched rows and +unsampled histories retain identity. Session IDs reject obsolete batches after +reset or instrument-count changes. + +- **Synthetic quote workload** is worker-generated samples/s, not custom-element + updates or messages. +- **Worker delivery interval** controls coalesced `postMessage` cadence; 20 ms + targets about 50 messages/s. +- **Row updates** is the count of unique immutable rows applied. +- **Message samples** is generated work represented by the latest batch. + +Intraday sampling is independent. The 25K burst deliberately publishes one +heavy batch. Worker messaging resembles an upstream stream without including +network latency. + +## Lit table architecture + +The 14 leaf columns are grouped into Instrument, Price & Change, Order Book, +Session, and Chart. The grid supports sorting/filtering, on-change resizing, +double-click reset, drag column ordering, CSS hover, row selection, drag cell +ranges, keyboard navigation, and Price/Move/Percent/Sparkline custom elements. + +Stable instrument IDs define row identity. One body-level interaction +controller resolves cells from `event.composedPath()` and data attributes, +avoiding handlers on every cell. Column widths are CSS variables written only +when sizing/order changes; a `ResizeObserver` performs initial fitting until a +manual resize. The A/B move option is intentionally a custom-element lifecycle +stress path. + +## Virtualization + +- Below 200 rows, automatic mode uses Full DOM, with Virtual still selectable. +- From 200 through 1,499 rows, automatic mode uses TanStack Virtual, with Full + DOM still selectable. +- At 1,500 rows or more, Virtual is forced and its control is disabled. + +Lit Virtual uses a 32 px estimate, 10-row overscan, stable row IDs, transformed +rows, and a spacer body. The footer derives the visible interval from the +virtualizer. Both modes apply `content-visibility: auto`; Full DOM still creates +all elements even when the browser skips some offscreen layout/paint. + +## Performance decisions + +- worker-side generation and coalescing; +- structural sharing for unchanged rows/history arrays; +- source-specific atom/store subscriptions in custom elements; +- stable keyed row/virtual identity; +- lifecycle-safe controller element subscriptions; +- delegated pointer input and CSS hover; +- CSS variables for width propagation; +- independently configurable chart/component stress; +- virtual mounting at larger sizes; +- metrics published below feed frequency. + +A new outer array is required by the immutable contract. Stable row references +help rendering, but sorting/filtering may still recompute the row model when +data changes. + +## Diagnostics and interpretation + +The sidebar keeps four cross-framework health signals prominent: estimated +frame callbacks, average snapshot-to-DOM-commit latency, cumulative long +animation frames, and changed-row/snapshot throughput. The remaining counters +stay in Diagnostics so they do not look like equally important scores. + +`AVG COMMIT` is not the duration of `render()` and it does not include the +browser's later layout or paint. It starts when a new immutable snapshot is +applied and ends in a guarded microtask queued from `updated()`. That extra +microtask lets nested quote-cell custom elements finish their Lit updates +before the sample closes. The average uses a rolling 3-second window; diagnostic +p95/max use 10 seconds. The frame-rate estimate counts standard +`requestAnimationFrame` callbacks over one second. It is refresh-rate dependent +and is not a GPU/compositor FPS measurement. + +Callback counts and DOM mutations describe different layers. +`Observed MutationRecords/s` is the number delivered by a `MutationObserver` +on the table body, not the number of browser DOM operations. The observer tracks +text, child-list, class, and style changes; it excludes selection data +attributes to reduce noise. Registering an observer still adds work at very high +mutation rates, so confirm close results with a Performance recording without +treating this counter as a score. Heap is Chrome-only, current and GC-sensitive; +growth is not a leak without post-GC retention. React Scan is not part of these +shared measurements. User Timing commit and row-model entries are sampled once +every 20 candidates; the numeric counters remain exact, while the Performance +timeline avoids one retained entry per hot-path execution. + +## Standalone policy + +All instruments, feed, worker, benchmark, shell, styles, and table code live in +this folder intentionally. It runs independently and can be copied to +StackBlitz, so shared implementation and README text are duplicated by design. + +The workspace resolves the pinned `@tanstack/lit-table` dependency to the local +adapter package while keeping the manifest release-like. diff --git a/examples/lit/realtime-trading/index.html b/examples/lit/realtime-trading/index.html new file mode 100644 index 0000000000..25afac7a22 --- /dev/null +++ b/examples/lit/realtime-trading/index.html @@ -0,0 +1,12 @@ + + + + + + TanStack Lit Table · Realtime Trading + + + + + + diff --git a/examples/lit/realtime-trading/package.json b/examples/lit/realtime-trading/package.json new file mode 100644 index 0000000000..395f5c0f4c --- /dev/null +++ b/examples/lit/realtime-trading/package.json @@ -0,0 +1,32 @@ +{ + "name": "tanstack-lit-table-example-realtime-trading", + "private": true, + "type": "module", + "scripts": { + "start": "vite", + "dev": "vite", + "build": "vite build", + "serve": "vite preview", + "lint": "eslint ./src", + "test:types": "tsc --noEmit", + "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" + }, + "nx": { + "targets": { + "test:e2e": { + "parallelism": false + } + } + }, + "dependencies": { + "@tanstack/lit-table": "^9.3.1", + "@tanstack/lit-virtual": "^3.15.3", + "@tanstack/store": "^0.11.2", + "lit": "^3.3.3" + }, + "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "typescript": "6.0.3", + "vite": "^8.3.8" + } +} diff --git a/examples/lit/realtime-trading/src/benchmark/benchmark-monitor.ts b/examples/lit/realtime-trading/src/benchmark/benchmark-monitor.ts new file mode 100644 index 0000000000..bdceb13a7c --- /dev/null +++ b/examples/lit/realtime-trading/src/benchmark/benchmark-monitor.ts @@ -0,0 +1,449 @@ +import { + quoteCellLifecycle, + quoteRenderDiagnostics, +} from '../table/table-config/quote-cells' +import { rowModelDiagnostics } from '../table/trading-table' + +export interface NamedInvocationRate { + name: string + callsPerSecond: number +} + +interface TimedLatencySample { + recordedAt: number + duration: number +} + +const averageLatencyWindowMs = 3_000 +const percentileLatencyWindowMs = 10_000 +const frameRateWindowMs = 1_000 + +export interface FeedMetrics { + actualTicksPerSecond: number + rowUpdatesPerSecond: number + workerMessagesPerSecond: number + stateApplicationsPerSecond: number + supersededUpdatesPerSecond: number + totalTicks: number + rafCallbacksPerSecond: number + tableCommitsPerSecond: number + lastBatchSize: number + averageCommitLatencyMs: number + p95CommitLatencyMs: number + maxCommitLatencyMs: number + slowCommits: number + longAnimationFrames: number + worstLongAnimationFrameMs: number + heapMb: number | null + componentsCreated: number + componentsDestroyed: number + workerMessages: number + lastUpdateCount: number + cellRendererCallsPerSecond: number + componentRenderCallsPerSecond: number + cellRendererRates: ReadonlyArray + componentRenderRates: ReadonlyArray + domMutationsPerSecond: number + rowModelCallsPerSecond: number + rowModelAverageMs: number + rowModelMaxMs: number + visibleRows: number +} + +export const initialMetrics: FeedMetrics = { + actualTicksPerSecond: 0, + rowUpdatesPerSecond: 0, + workerMessagesPerSecond: 0, + stateApplicationsPerSecond: 0, + supersededUpdatesPerSecond: 0, + totalTicks: 0, + rafCallbacksPerSecond: 0, + tableCommitsPerSecond: 0, + lastBatchSize: 0, + averageCommitLatencyMs: 0, + p95CommitLatencyMs: 0, + maxCommitLatencyMs: 0, + slowCommits: 0, + longAnimationFrames: 0, + worstLongAnimationFrameMs: 0, + heapMb: null, + componentsCreated: 0, + componentsDestroyed: 0, + workerMessages: 0, + lastUpdateCount: 0, + cellRendererCallsPerSecond: 0, + componentRenderCallsPerSecond: 0, + cellRendererRates: [], + componentRenderRates: [], + domMutationsPerSecond: 0, + rowModelCallsPerSecond: 0, + rowModelAverageMs: 0, + rowModelMaxMs: 0, + visibleRows: 0, +} + +const userTiming = { entryCount: 0, measureCandidateCount: 0 } +const userTimingSamplingInterval = 20 + +export function recordMeasure( + name: string, + start: number, + end: number, + detail: Record, +): void { + userTiming.measureCandidateCount++ + if (userTiming.measureCandidateCount % userTimingSamplingInterval !== 0) + return + try { + performance.measure(name, { start, end, detail }) + userTiming.entryCount++ + if (userTiming.entryCount % 1_000 === 0) { + performance.clearMeasures('market-update-to-dom-commit') + } + } catch { + // User Timing Level 3 options are not implemented in every browser. + } +} + +export function markBenchmarkAction( + name: string, + detail: Record = {}, +): void { + try { + performance.mark(`benchmark:${name}`, { detail }) + userTiming.entryCount++ + if (userTiming.entryCount % 1_000 === 0) { + performance.clearMarks() + } + } catch { + // User Timing Level 3 detail is not implemented in every browser. + } +} + +export class BenchmarkMonitor { + readonly #runtime = { + sampleStartedAt: performance.now(), + sessionStartedAt: performance.now(), + pendingMutationStartedAt: null as number | null, + commitLatencySamples: [] as Array, + slowCommitCount: 0, + totalTicks: 0, + ticksInSample: 0, + rowUpdatesInSample: 0, + workerMessagesInSample: 0, + stateApplicationsInSample: 0, + supersededUpdatesInSample: 0, + lastBatchSize: 0, + lastUpdateCount: 0, + workerMessages: 0, + frameTrackingStartedAt: performance.now(), + frameTimestamps: [] as Array, + tableCommitsInSample: 0, + longAnimationFrameCount: 0, + worstLongAnimationFrameMs: 0, + previousCellRendererCalls: 0, + previousComponentRenderCalls: 0, + previousCellRendererCallsByName: { + ...quoteRenderDiagnostics.cellRendererCallsByName, + }, + previousComponentRenderCallsByName: { + ...quoteRenderDiagnostics.componentRenderCallsByName, + }, + domMutationsInSample: 0, + previousRowModelCalls: 0, + previousRowModelDuration: 0, + } + + markCommitPending(): void { + this.#runtime.pendingMutationStartedAt ??= performance.now() + } + + recordDomCommit(): void { + const runtime = this.#runtime + if (runtime.pendingMutationStartedAt !== null) { + const commitEndedAt = performance.now() + const duration = commitEndedAt - runtime.pendingMutationStartedAt + runtime.commitLatencySamples.push({ + recordedAt: commitEndedAt, + duration, + }) + if (duration > 16.7) runtime.slowCommitCount++ + recordMeasure( + 'market-update-to-dom-commit', + runtime.pendingMutationStartedAt, + commitEndedAt, + {}, + ) + runtime.pendingMutationStartedAt = null + runtime.tableCommitsInSample++ + } + } + + recordWorkerMessage(): void { + this.#runtime.workerMessages++ + this.#runtime.workerMessagesInSample++ + } + + recordBatch( + tickCount: number, + updateCount: number, + supersededUpdateCount: number, + ): void { + const runtime = this.#runtime + runtime.lastBatchSize = tickCount + runtime.lastUpdateCount = updateCount + runtime.ticksInSample += tickCount + runtime.totalTicks += tickCount + runtime.rowUpdatesInSample += updateCount + runtime.stateApplicationsInSample++ + runtime.supersededUpdatesInSample += supersededUpdateCount + } + + recordAnimationFrame(now: number): void { + const timestamps = this.#runtime.frameTimestamps + timestamps.push(now) + pruneFrameTimestamps(timestamps, now) + } + + recordLongAnimationFrame(duration: number, startTime: number): void { + const runtime = this.#runtime + if (startTime < runtime.sessionStartedAt) return + runtime.longAnimationFrameCount++ + runtime.worstLongAnimationFrameMs = Math.max( + runtime.worstLongAnimationFrameMs, + duration, + ) + } + + recordDomMutations(count: number): void { + this.#runtime.domMutationsInSample += count + } + + resetDomMutations(): void { + this.#runtime.domMutationsInSample = 0 + } + + shouldPublish(now: number): boolean { + return now - this.#runtime.sampleStartedAt >= 500 + } + + publish(now: number): FeedMetrics { + const runtime = this.#runtime + const sampleDuration = now - runtime.sampleStartedAt + pruneLatencySamples(runtime.commitLatencySamples, now) + pruneFrameTimestamps(runtime.frameTimestamps, now) + const averageCommitLatencySamples = runtime.commitLatencySamples + .filter((sample) => sample.recordedAt >= now - averageLatencyWindowMs) + .map((sample) => sample.duration) + const percentileCommitLatencySamples = runtime.commitLatencySamples.map( + (sample) => sample.duration, + ) + const sortedCommitLatencySamples = [...percentileCommitLatencySamples].sort( + (left, right) => left - right, + ) + const rowModelCalls = + rowModelDiagnostics.calls - runtime.previousRowModelCalls + const rowModelDuration = + rowModelDiagnostics.totalDurationMs - runtime.previousRowModelDuration + const cellRendererCalls = + quoteRenderDiagnostics.cellRendererCalls - + runtime.previousCellRendererCalls + const componentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls - + runtime.previousComponentRenderCalls + const cellRendererRates = calculateInvocationRates( + quoteRenderDiagnostics.cellRendererCallsByName, + runtime.previousCellRendererCallsByName, + sampleDuration, + ) + const componentRenderRates = calculateInvocationRates( + quoteRenderDiagnostics.componentRenderCallsByName, + runtime.previousComponentRenderCallsByName, + sampleDuration, + ) + const averageCommitLatencyMs = + averageCommitLatencySamples.length === 0 + ? 0 + : averageCommitLatencySamples.reduce((sum, value) => sum + value, 0) / + averageCommitLatencySamples.length + const p95Index = Math.max( + 0, + Math.ceil(sortedCommitLatencySamples.length * 0.95) - 1, + ) + const metrics: FeedMetrics = { + actualTicksPerSecond: + sampleDuration === 0 + ? 0 + : (runtime.ticksInSample / sampleDuration) * 1_000, + rowUpdatesPerSecond: + (runtime.rowUpdatesInSample / sampleDuration) * 1_000, + workerMessagesPerSecond: + (runtime.workerMessagesInSample / sampleDuration) * 1_000, + stateApplicationsPerSecond: + (runtime.stateApplicationsInSample / sampleDuration) * 1_000, + supersededUpdatesPerSecond: + (runtime.supersededUpdatesInSample / sampleDuration) * 1_000, + totalTicks: runtime.totalTicks, + rafCallbacksPerSecond: calculateFrameRate( + runtime.frameTimestamps, + runtime.frameTrackingStartedAt, + now, + ), + tableCommitsPerSecond: + (runtime.tableCommitsInSample / sampleDuration) * 1_000, + lastBatchSize: runtime.lastBatchSize, + averageCommitLatencyMs, + p95CommitLatencyMs: sortedCommitLatencySamples[p95Index] ?? 0, + maxCommitLatencyMs: sortedCommitLatencySamples.at(-1) ?? 0, + slowCommits: runtime.slowCommitCount, + longAnimationFrames: runtime.longAnimationFrameCount, + worstLongAnimationFrameMs: runtime.worstLongAnimationFrameMs, + heapMb: readHeapSizeMb(), + componentsCreated: quoteCellLifecycle.created, + componentsDestroyed: quoteCellLifecycle.destroyed, + workerMessages: runtime.workerMessages, + lastUpdateCount: runtime.lastUpdateCount, + cellRendererCallsPerSecond: (cellRendererCalls / sampleDuration) * 1_000, + componentRenderCallsPerSecond: + (componentRenderCalls / sampleDuration) * 1_000, + cellRendererRates, + componentRenderRates, + domMutationsPerSecond: + (runtime.domMutationsInSample / sampleDuration) * 1_000, + rowModelCallsPerSecond: (rowModelCalls / sampleDuration) * 1_000, + rowModelAverageMs: + rowModelCalls === 0 ? 0 : rowModelDuration / rowModelCalls, + rowModelMaxMs: rowModelDiagnostics.maxDurationMs, + visibleRows: rowModelDiagnostics.lastRowCount, + } + + runtime.sampleStartedAt = now + runtime.previousCellRendererCalls = quoteRenderDiagnostics.cellRendererCalls + runtime.previousComponentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls + runtime.previousCellRendererCallsByName = { + ...quoteRenderDiagnostics.cellRendererCallsByName, + } + runtime.previousComponentRenderCallsByName = { + ...quoteRenderDiagnostics.componentRenderCallsByName, + } + runtime.domMutationsInSample = 0 + runtime.previousRowModelCalls = rowModelDiagnostics.calls + runtime.previousRowModelDuration = rowModelDiagnostics.totalDurationMs + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.tableCommitsInSample = 0 + return metrics + } + + reset(): void { + const runtime = this.#runtime + runtime.sampleStartedAt = performance.now() + runtime.sessionStartedAt = runtime.sampleStartedAt + runtime.pendingMutationStartedAt = null + runtime.commitLatencySamples = [] + runtime.slowCommitCount = 0 + runtime.totalTicks = 0 + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.lastBatchSize = 0 + runtime.lastUpdateCount = 0 + runtime.workerMessages = 0 + runtime.frameTrackingStartedAt = runtime.sampleStartedAt + runtime.frameTimestamps = [] + runtime.tableCommitsInSample = 0 + runtime.longAnimationFrameCount = 0 + runtime.worstLongAnimationFrameMs = 0 + runtime.previousCellRendererCalls = quoteRenderDiagnostics.cellRendererCalls + runtime.previousComponentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls + runtime.previousCellRendererCallsByName = { + ...quoteRenderDiagnostics.cellRendererCallsByName, + } + runtime.previousComponentRenderCallsByName = { + ...quoteRenderDiagnostics.componentRenderCallsByName, + } + runtime.domMutationsInSample = 0 + runtime.previousRowModelCalls = rowModelDiagnostics.calls + runtime.previousRowModelDuration = rowModelDiagnostics.totalDurationMs + rowModelDiagnostics.maxDurationMs = 0 + } +} + +export const longAnimationFramesSupported = + PerformanceObserver.supportedEntryTypes.includes('long-animation-frame') + +function readHeapSizeMb(): number | null { + const memory = ( + performance as Performance & { + memory?: { usedJSHeapSize: number } + } + ).memory + return memory ? memory.usedJSHeapSize / 1_048_576 : null +} + +function calculateInvocationRates( + current: Record, + previous: Record, + sampleDuration: number, +): ReadonlyArray { + return Object.entries(current).map(([name, calls]) => ({ + name, + callsPerSecond: + sampleDuration === 0 + ? 0 + : ((calls - (previous[name] ?? 0)) / sampleDuration) * 1_000, + })) +} + +function pruneLatencySamples( + samples: Array, + now: number, +): void { + const cutoff = now - percentileLatencyWindowMs + const firstRetainedIndex = samples.findIndex( + (sample) => sample.recordedAt >= cutoff, + ) + if (firstRetainedIndex > 0) samples.splice(0, firstRetainedIndex) + else if (firstRetainedIndex === -1) samples.length = 0 +} + +function pruneFrameTimestamps(timestamps: Array, now: number): void { + const cutoff = now - frameRateWindowMs + const firstRetainedIndex = timestamps.findIndex( + (timestamp) => timestamp >= cutoff, + ) + if (firstRetainedIndex > 0) timestamps.splice(0, firstRetainedIndex) + else if (firstRetainedIndex === -1) timestamps.length = 0 +} + +function calculateFrameRate( + timestamps: ReadonlyArray, + trackingStartedAt: number, + now: number, +): number { + const observedWindowMs = Math.min( + frameRateWindowMs, + Math.max(1, now - trackingStartedAt), + ) + return (timestamps.length / observedWindowMs) * 1_000 +} + +export function exposeTradingBenchmarkSnapshot( + metrics: FeedMetrics, + extras: { mountedCells: number; liveComponents: number }, +): void { + Object.assign(globalThis, { + __TANSTACK_TRADING_BENCHMARK__: { + capturedAt: performance.now(), + metrics, + ...extras, + }, + }) +} diff --git a/examples/lit/realtime-trading/src/benchmark/table-benchmark.ts b/examples/lit/realtime-trading/src/benchmark/table-benchmark.ts new file mode 100644 index 0000000000..346a6cdc0c --- /dev/null +++ b/examples/lit/realtime-trading/src/benchmark/table-benchmark.ts @@ -0,0 +1,23 @@ +import type { TradingBenchmarkController } from './trading-benchmark-controller' + +export function startTableBenchmark( + controller: TradingBenchmarkController, +): () => void { + const tableBody = document.querySelector( + '.market-panel [data-trading-table] tbody', + ) + if (!tableBody) return () => undefined + + controller.monitor.resetDomMutations() + const observer = new MutationObserver((records) => { + controller.monitor.recordDomMutations(records.length) + }) + observer.observe(tableBody, { + attributes: true, + attributeFilter: ['class', 'style'], + characterData: true, + childList: true, + subtree: true, + }) + return () => observer.disconnect() +} diff --git a/examples/lit/realtime-trading/src/benchmark/trading-benchmark-controller.ts b/examples/lit/realtime-trading/src/benchmark/trading-benchmark-controller.ts new file mode 100644 index 0000000000..2f42289477 --- /dev/null +++ b/examples/lit/realtime-trading/src/benchmark/trading-benchmark-controller.ts @@ -0,0 +1,161 @@ +import { batch, createAtom, createStore } from '@tanstack/store' +import { TRADING_COLUMN_COUNT } from '../table/trading-table' +import { FORCED_VIRTUALIZATION_ROW_COUNT } from '../table/trading-row-virtualizer' +import { + BenchmarkMonitor, + exposeTradingBenchmarkSnapshot, + initialMetrics, + longAnimationFramesSupported, +} from './benchmark-monitor' +import type { FeedMetrics } from './benchmark-monitor' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { RendererMode } from '../table/trading-table' +import type { VirtualScrollPreference } from '../table/trading-row-virtualizer' + +export interface TradingBenchmarkState { + requestedVirtualScrollMode: VirtualScrollPreference + metrics: FeedMetrics + mountedCells: number + liveComponents: number + longAnimationFramesSupported: boolean +} + +export interface TradingBenchmarkActions { + resetViewState: () => void + setRendererMode: (mode: RendererMode) => void + setVirtualScrollEnabled: (enabled: boolean) => void + setRenderedRowCount: (count: number) => void + selectSymbol: (symbol: string | null) => void + resetMarket: () => void +} + +const initialState: TradingBenchmarkState = { + requestedVirtualScrollMode: 'auto', + metrics: initialMetrics, + mountedCells: 0, + liveComponents: 0, + longAnimationFramesSupported, +} + +export class TradingBenchmarkController { + readonly store = createStore(initialState) + readonly renderAtoms = { + selectedSymbol: createAtom(null), + rendererMode: createAtom('stable'), + } + readonly monitor = new BenchmarkMonitor() + readonly feed: MarketFeedController + readonly actions: TradingBenchmarkActions + + readonly #runtime = { + animationFrameId: 0, + longAnimationFrameObserver: null as PerformanceObserver | null, + stopObservingFeed: null as (() => void) | null, + } + + constructor(feed: MarketFeedController) { + this.feed = feed + this.actions = { + resetViewState: () => { + this.renderAtoms.selectedSymbol.set(null) + this.#patch({ requestedVirtualScrollMode: 'auto' }) + }, + setRendererMode: (mode) => { + this.renderAtoms.rendererMode.set(mode) + }, + setVirtualScrollEnabled: (enabled) => { + if ( + this.feed.instrumentCount.get() >= FORCED_VIRTUALIZATION_ROW_COUNT + ) { + return + } + this.#patch({ + requestedVirtualScrollMode: enabled ? 'tanstack' : 'none', + }) + }, + setRenderedRowCount: (count) => { + const mountedCells = count * TRADING_COLUMN_COUNT + if (mountedCells !== this.store.get().mountedCells) { + this.#patch({ mountedCells }) + } + }, + selectSymbol: (symbol) => { + this.renderAtoms.selectedSymbol.set(symbol) + }, + resetMarket: () => { + batch(() => { + this.monitor.reset() + this.store.setState((state) => ({ + ...state, + metrics: { ...initialMetrics }, + mountedCells: 0, + liveComponents: 0, + })) + this.renderAtoms.selectedSymbol.set(null) + this.feed.actions.reset() + }) + }, + } + } + + start(): () => void { + const longAnimationFrameObserver = longAnimationFramesSupported + ? new PerformanceObserver((entries) => { + for (const entry of entries.getEntries()) { + this.monitor.recordLongAnimationFrame( + entry.duration, + entry.startTime, + ) + } + }) + : null + + this.#runtime.longAnimationFrameObserver = longAnimationFrameObserver + this.#runtime.stopObservingFeed = this.feed.observe({ + messageReceived: () => this.monitor.recordWorkerMessage(), + mutationStarted: () => this.monitor.markCommitPending(), + batchApplied: ({ tickCount, updateCount, supersededUpdateCount }) => + this.monitor.recordBatch(tickCount, updateCount, supersededUpdateCount), + renderCommitted: () => this.monitor.recordDomCommit(), + }) + longAnimationFrameObserver?.observe({ + type: 'long-animation-frame', + }) + this.#runtime.animationFrameId = requestAnimationFrame(this.#benchmarkFrame) + + return () => this.stop() + } + + stop(): void { + cancelAnimationFrame(this.#runtime.animationFrameId) + this.#runtime.longAnimationFrameObserver?.disconnect() + this.#runtime.stopObservingFeed?.() + this.#runtime.longAnimationFrameObserver = null + this.#runtime.stopObservingFeed = null + } + + readonly #benchmarkFrame = (now: number): void => { + this.monitor.recordAnimationFrame(now) + if (this.monitor.shouldPublish(now)) { + this.#publishMetrics(this.monitor.publish(now)) + } + this.#runtime.animationFrameId = requestAnimationFrame(this.#benchmarkFrame) + } + + #patch(patch: Partial): void { + this.store.setState((state) => ({ ...state, ...patch })) + } + + #publishMetrics(metrics: FeedMetrics): void { + const liveComponents = + metrics.componentsCreated - metrics.componentsDestroyed + this.#patch({ + metrics, + liveComponents, + }) + exposeTradingBenchmarkSnapshot(metrics, { + mountedCells: this.store.get().mountedCells, + liveComponents, + }) + } +} diff --git a/examples/lit/realtime-trading/src/feed/feed-sample-rates.ts b/examples/lit/realtime-trading/src/feed/feed-sample-rates.ts new file mode 100644 index 0000000000..17dc2015a6 --- /dev/null +++ b/examples/lit/realtime-trading/src/feed/feed-sample-rates.ts @@ -0,0 +1,33 @@ +export const feedSampleRateOptions = [ + { label: '100', value: 100 }, + { label: '250', value: 250 }, + { label: '500', value: 500 }, + { label: '1K', value: 1_000 }, + { label: '2.5K', value: 2_500 }, + { label: '5K', value: 5_000 }, + { label: '10K', value: 10_000 }, + { label: '25K', value: 25_000 }, + { label: '50K', value: 50_000 }, + { label: '100K', value: 100_000 }, +] as const + +export function feedSampleRateIndex(rate: number): number { + return feedSampleRateOptions.reduce((closestIndex, candidate, index) => { + const closest = feedSampleRateOptions[closestIndex] + return Math.abs(candidate.value - rate) < Math.abs(closest.value - rate) + ? index + : closestIndex + }, 0) +} + +export function feedSampleRateAt(stepIndex: number): number { + const index = Math.min( + feedSampleRateOptions.length - 1, + Math.max(0, Math.round(stepIndex)), + ) + return feedSampleRateOptions[index].value +} + +export function normalizeFeedSampleRate(rate: number): number { + return feedSampleRateAt(feedSampleRateIndex(rate)) +} diff --git a/examples/lit/realtime-trading/src/feed/market-data.ts b/examples/lit/realtime-trading/src/feed/market-data.ts new file mode 100644 index 0000000000..6231865d3f --- /dev/null +++ b/examples/lit/realtime-trading/src/feed/market-data.ts @@ -0,0 +1,38 @@ +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './worker/market-feed-protocol' + +export interface MarketQuote extends Omit { + history: ReadonlyArray +} + +export function hydrateMarketQuotes( + snapshots: Array, +): Array { + return snapshots.map((quote) => ({ + ...quote, + history: [...quote.history], + })) +} + +export function applyMarketUpdates( + quotes: Array, + updates: Array, +): Array { + const nextQuotes = [...quotes] + + for (const update of updates) { + const { index, history, ...values } = update + const previousQuote = quotes.at(index) + if (!previousQuote) continue + + nextQuotes[index] = { + ...previousQuote, + ...values, + history: history ?? previousQuote.history, + } + } + + return nextQuotes +} diff --git a/examples/lit/realtime-trading/src/feed/market-feed-config.ts b/examples/lit/realtime-trading/src/feed/market-feed-config.ts new file mode 100644 index 0000000000..9d477ed663 --- /dev/null +++ b/examples/lit/realtime-trading/src/feed/market-feed-config.ts @@ -0,0 +1,15 @@ +export interface MarketFeedConfig { + readonly instrumentCount: number + readonly targetSamplesPerSecond: number + readonly publishIntervalMs: number + readonly updateSparklines: boolean + readonly sparklineSampleIntervalMs: number +} + +export const initialMarketFeedConfig: MarketFeedConfig = { + instrumentCount: 100, + targetSamplesPerSecond: 10_000, + publishIntervalMs: 20, + updateSparklines: true, + sparklineSampleIntervalMs: 16, +} diff --git a/examples/lit/realtime-trading/src/feed/market-feed-controller.ts b/examples/lit/realtime-trading/src/feed/market-feed-controller.ts new file mode 100644 index 0000000000..ac8bc2a472 --- /dev/null +++ b/examples/lit/realtime-trading/src/feed/market-feed-controller.ts @@ -0,0 +1,227 @@ +import { batch, createAtom } from '@tanstack/store' +import { normalizeFeedSampleRate } from './feed-sample-rates' +import { initialMarketFeedConfig } from './market-feed-config' +import { applyMarketUpdates, hydrateMarketQuotes } from './market-data' +import type { + MarketFeedCommand, + MarketFeedEvent, +} from './worker/market-feed-protocol' +import type { MarketQuote } from './market-data' + +export interface MarketFeedBatch { + tickCount: number + updateCount: number + supersededUpdateCount: number +} + +export interface MarketFeedObserver { + messageReceived?: () => void + mutationStarted?: () => void + batchApplied?: (batch: MarketFeedBatch) => void + renderCommitted?: () => void +} + +export interface MarketFeedActions { + toggle: () => void + setInstrumentCount: (count: number) => void + setTargetRate: (rate: number) => void + setPublishInterval: (intervalMs: number) => void + setSparklineUpdates: (enabled: boolean) => void + setSparklineSampleInterval: (intervalMs: number) => void + runBurst: () => void + reset: () => void +} + +export class MarketFeedController { + readonly workerReady = createAtom(false) + readonly running = createAtom( + !new URLSearchParams(location.search).has('paused'), + ) + readonly instrumentCount = createAtom(initialMarketFeedConfig.instrumentCount) + readonly targetTicksPerSecond = createAtom( + initialMarketFeedConfig.targetSamplesPerSecond, + ) + readonly publishIntervalMs = createAtom( + initialMarketFeedConfig.publishIntervalMs, + ) + readonly updateSparklines = createAtom( + initialMarketFeedConfig.updateSparklines, + ) + readonly sparklineSampleIntervalMs = createAtom( + initialMarketFeedConfig.sparklineSampleIntervalMs, + ) + readonly quotes = createAtom>([]) + readonly actions: MarketFeedActions + readonly #observers = new Set() + readonly #runtime = { + worker: null as Worker | null, + feedSessionId: 0, + renderPending: false, + resetWaitingForCommit: false, + resetSnapshotReady: false, + quoteIndexBySymbol: new Map(), + } + + constructor() { + this.actions = { + toggle: () => { + const running = !this.running.get() + this.running.set(running) + this.#post({ type: 'set-running', running }) + }, + setInstrumentCount: (count) => { + this.instrumentCount.set(count) + this.#resetWorker(count) + }, + setTargetRate: (rate) => { + const sampleRate = normalizeFeedSampleRate(rate) + this.targetTicksPerSecond.set(sampleRate) + this.#post({ type: 'set-rate', ticksPerSecond: sampleRate }) + }, + setPublishInterval: (publishIntervalMs) => { + this.publishIntervalMs.set(publishIntervalMs) + this.#post({ + type: 'set-publish-interval', + intervalMs: publishIntervalMs, + }) + }, + setSparklineUpdates: (enabled) => { + this.updateSparklines.set(enabled) + this.#post({ type: 'set-sparklines', enabled }) + }, + setSparklineSampleInterval: (intervalMs) => { + this.sparklineSampleIntervalMs.set(intervalMs) + this.#post({ type: 'set-sparkline-interval', intervalMs }) + }, + runBurst: () => this.#post({ type: 'burst', tickCount: 25_000 }), + reset: () => this.#resetWorker(this.instrumentCount.get()), + } + } + + start(): () => void { + const worker = new Worker( + new URL('./worker/market-feed.worker.ts', import.meta.url), + { type: 'module' }, + ) + this.#runtime.worker = worker + worker.addEventListener('message', this.#handleWorkerMessage) + worker.addEventListener('error', this.#handleWorkerError) + this.#post({ + type: 'start', + rowCount: this.instrumentCount.get(), + running: this.running.get(), + ticksPerSecond: this.targetTicksPerSecond.get(), + publishIntervalMs: this.publishIntervalMs.get(), + updateSparklines: this.updateSparklines.get(), + sparklineSampleIntervalMs: this.sparklineSampleIntervalMs.get(), + }) + return () => this.stop() + } + + stop(): void { + this.#runtime.worker?.removeEventListener( + 'message', + this.#handleWorkerMessage, + ) + this.#runtime.worker?.removeEventListener('error', this.#handleWorkerError) + this.#runtime.worker?.terminate() + this.#runtime.worker = null + this.#observers.clear() + } + + observe(observer: MarketFeedObserver): () => void { + this.#observers.add(observer) + return () => this.#observers.delete(observer) + } + + getQuoteBySymbol( + quotes: Array, + symbol: string | null, + ): MarketQuote | null { + if (symbol === null) return null + + const index = this.#runtime.quoteIndexBySymbol.get(symbol) + return index === undefined ? null : (quotes[index] ?? null) + } + + completeRender(): void { + if (!this.#runtime.renderPending) return + + this.#runtime.renderPending = false + for (const observer of this.#observers) { + observer.renderCommitted?.() + } + if ( + this.#runtime.resetWaitingForCommit && + this.#runtime.resetSnapshotReady + ) { + this.#runtime.resetWaitingForCommit = false + this.#runtime.resetSnapshotReady = false + this.#post({ type: 'set-running', running: this.running.get() }) + } + } + + readonly #handleWorkerMessage = ({ + data, + }: MessageEvent): void => { + if (data.type === 'snapshot') { + this.#runtime.feedSessionId = data.sessionId + if (this.#runtime.resetWaitingForCommit) { + this.#runtime.resetSnapshotReady = true + } + this.#startMutation() + const quotes = hydrateMarketQuotes(data.quotes) + this.#runtime.quoteIndexBySymbol = new Map( + quotes.map((quote, index) => [quote.symbol, index]), + ) + batch(() => { + this.quotes.set(quotes) + this.workerReady.set(true) + }) + return + } + + if (data.sessionId !== this.#runtime.feedSessionId) return + + for (const observer of this.#observers) { + observer.messageReceived?.() + } + this.#startMutation() + this.quotes.set(applyMarketUpdates(this.quotes.get(), data.updates)) + const feedBatch = { + tickCount: data.tickCount, + updateCount: data.updates.length, + supersededUpdateCount: data.coalescedUpdateCount, + } + for (const observer of this.#observers) { + observer.batchApplied?.(feedBatch) + } + } + + readonly #handleWorkerError = (error: ErrorEvent): void => { + batch(() => { + this.workerReady.set(false) + this.running.set(false) + }) + console.error('Market feed worker failed', error) + } + + #resetWorker(rowCount: number): void { + this.workerReady.set(false) + this.#runtime.resetWaitingForCommit = true + this.#runtime.resetSnapshotReady = false + this.#post({ type: 'set-running', running: false }) + this.#post({ type: 'reset', rowCount }) + } + + #startMutation(): void { + this.#runtime.renderPending = true + for (const observer of this.#observers) { + observer.mutationStarted?.() + } + } + + #post(command: MarketFeedCommand): void { + this.#runtime.worker?.postMessage(command) + } +} diff --git a/examples/lit/realtime-trading/src/feed/market-instruments.ts b/examples/lit/realtime-trading/src/feed/market-instruments.ts new file mode 100644 index 0000000000..ac18d14ea9 --- /dev/null +++ b/examples/lit/realtime-trading/src/feed/market-instruments.ts @@ -0,0 +1,742 @@ +export type MarketCode = + | 'US' + | 'NL' + | 'DE' + | 'FR' + | 'IT' + | 'ES' + | 'CH' + | 'DK' + | 'SE' + | 'FI' + | 'GB' + | 'KR' + | 'JP' + | 'HK' + | 'CA' + | 'AU' + +export type BaseInstrument = readonly [ + symbol: string, + company: string, + market: MarketCode, +] + +/** + * Current S&P 500 constituent universe used by the realtime trading examples. + * + * Source snapshot: https://github.com/datasets/s-and-p-500-companies + * Retrieved: 2026-08-15. + * Multiple share classes are intentionally represented as separate instruments. + */ +export const marketInstruments = Object.freeze([ + ['MMM', '3M', 'US'], + ['AOS', 'A. O. Smith', 'US'], + ['ABT', 'Abbott Laboratories', 'US'], + ['ABBV', 'AbbVie', 'US'], + ['ACN', 'Accenture', 'US'], + ['ADBE', 'Adobe Inc.', 'US'], + ['AMD', 'Advanced Micro Devices', 'US'], + ['AES', 'AES Corporation', 'US'], + ['AFL', 'Aflac', 'US'], + ['A', 'Agilent Technologies', 'US'], + ['APD', 'Air Products', 'US'], + ['ABNB', 'Airbnb', 'US'], + ['AKAM', 'Akamai Technologies', 'US'], + ['ALB', 'Albemarle Corporation', 'US'], + ['ARE', 'Alexandria Real Estate Equities', 'US'], + ['ALGN', 'Align Technology', 'US'], + ['ALLE', 'Allegion', 'US'], + ['LNT', 'Alliant Energy', 'US'], + ['ALL', 'Allstate', 'US'], + ['GOOGL', 'Alphabet Inc. (Class A)', 'US'], + ['GOOG', 'Alphabet Inc. (Class C)', 'US'], + ['MO', 'Altria', 'US'], + ['AMZN', 'Amazon', 'US'], + ['AMCR', 'Amcor', 'US'], + ['AEE', 'Ameren', 'US'], + ['AEP', 'American Electric Power', 'US'], + ['AXP', 'American Express', 'US'], + ['AIG', 'American International Group', 'US'], + ['AMT', 'American Tower', 'US'], + ['AWK', 'American Water Works', 'US'], + ['AMP', 'Ameriprise Financial', 'US'], + ['AME', 'Ametek', 'US'], + ['AMGN', 'Amgen', 'US'], + ['APH', 'Amphenol', 'US'], + ['ADI', 'Analog Devices', 'US'], + ['AON', 'Aon plc', 'US'], + ['APA', 'APA Corporation', 'US'], + ['APO', 'Apollo Global Management', 'US'], + ['AAPL', 'Apple Inc.', 'US'], + ['AMAT', 'Applied Materials', 'US'], + ['APP', 'AppLovin', 'US'], + ['APTV', 'Aptiv', 'US'], + ['ACGL', 'Arch Capital Group', 'US'], + ['ADM', 'Archer Daniels Midland', 'US'], + ['ARES', 'Ares Management', 'US'], + ['ANET', 'Arista Networks', 'US'], + ['AJG', 'Arthur J. Gallagher & Co.', 'US'], + ['AIZ', 'Assurant', 'US'], + ['T', 'AT&T', 'US'], + ['ATO', 'Atmos Energy', 'US'], + ['ADSK', 'Autodesk', 'US'], + ['ADP', 'Automatic Data Processing', 'US'], + ['AZO', 'AutoZone', 'US'], + ['AVB', 'AvalonBay Communities', 'US'], + ['AVY', 'Avery Dennison', 'US'], + ['AXON', 'Axon Enterprise', 'US'], + ['BKR', 'Baker Hughes', 'US'], + ['BALL', 'Ball Corporation', 'US'], + ['BAC', 'Bank of America', 'US'], + ['BAX', 'Baxter International', 'US'], + ['BDX', 'Becton Dickinson', 'US'], + ['BRK.B', 'Berkshire Hathaway', 'US'], + ['BBY', 'Best Buy', 'US'], + ['TECH', 'Bio-Techne', 'US'], + ['BIIB', 'Biogen', 'US'], + ['BLK', 'BlackRock', 'US'], + ['BX', 'Blackstone Inc.', 'US'], + ['XYZ', 'Block, Inc.', 'US'], + ['BNY', 'BNY Mellon', 'US'], + ['BA', 'Boeing', 'US'], + ['BKNG', 'Booking Holdings', 'US'], + ['BSX', 'Boston Scientific', 'US'], + ['BMY', 'Bristol Myers Squibb', 'US'], + ['AVGO', 'Broadcom', 'US'], + ['BR', 'Broadridge Financial Solutions', 'US'], + ['BRO', 'Brown & Brown', 'US'], + ['BF.B', 'Brown–Forman', 'US'], + ['BLDR', 'Builders FirstSource', 'US'], + ['BG', 'Bunge Global', 'US'], + ['BXP', 'BXP, Inc.', 'US'], + ['CHRW', 'C.H. Robinson', 'US'], + ['CDNS', 'Cadence Design Systems', 'US'], + ['CPT', 'Camden Property Trust', 'US'], + ['COF', 'Capital One', 'US'], + ['CAH', 'Cardinal Health', 'US'], + ['CCL', 'Carnival Corporation', 'US'], + ['CARR', 'Carrier Global', 'US'], + ['CVNA', 'Carvana', 'US'], + ['CASY', "Casey's", 'US'], + ['CAT', 'Caterpillar Inc.', 'US'], + ['CBOE', 'Cboe Global Markets', 'US'], + ['CBRE', 'CBRE Group', 'US'], + ['CDW', 'CDW Corporation', 'US'], + ['COR', 'Cencora', 'US'], + ['CNC', 'Centene Corporation', 'US'], + ['CNP', 'CenterPoint Energy', 'US'], + ['CF', 'CF Industries', 'US'], + ['CRL', 'Charles River Laboratories', 'US'], + ['SCHW', 'Charles Schwab Corporation', 'US'], + ['CHTR', 'Charter Communications', 'US'], + ['CVX', 'Chevron Corporation', 'US'], + ['CMG', 'Chipotle Mexican Grill', 'US'], + ['CB', 'Chubb Limited', 'US'], + ['CHD', 'Church & Dwight', 'US'], + ['CIEN', 'Ciena', 'US'], + ['CI', 'Cigna', 'US'], + ['CINF', 'Cincinnati Financial', 'US'], + ['CTAS', 'Cintas', 'US'], + ['CSCO', 'Cisco', 'US'], + ['C', 'Citigroup', 'US'], + ['CFG', 'Citizens Financial Group', 'US'], + ['CLX', 'Clorox', 'US'], + ['CME', 'CME Group', 'US'], + ['CMS', 'CMS Energy', 'US'], + ['KO', 'Coca-Cola Company (The)', 'US'], + ['CTSH', 'Cognizant', 'US'], + ['COHR', 'Coherent Corp.', 'US'], + ['COIN', 'Coinbase', 'US'], + ['CL', 'Colgate-Palmolive', 'US'], + ['CMCSA', 'Comcast', 'US'], + ['FIX', 'Comfort Systems USA', 'US'], + ['COP', 'ConocoPhillips', 'US'], + ['ED', 'Consolidated Edison', 'US'], + ['STZ', 'Constellation Brands', 'US'], + ['CEG', 'Constellation Energy', 'US'], + ['COO', 'Cooper Companies (The)', 'US'], + ['CPRT', 'Copart', 'US'], + ['GLW', 'Corning Inc.', 'US'], + ['CPAY', 'Corpay', 'US'], + ['CTVA', 'Corteva', 'US'], + ['CSGP', 'CoStar Group', 'US'], + ['COST', 'Costco', 'US'], + ['CRH', 'CRH plc', 'US'], + ['CRWD', 'CrowdStrike', 'US'], + ['CCI', 'Crown Castle', 'US'], + ['CSX', 'CSX Corporation', 'US'], + ['CMI', 'Cummins', 'US'], + ['CVS', 'CVS Health', 'US'], + ['DHR', 'Danaher Corporation', 'US'], + ['DRI', 'Darden Restaurants', 'US'], + ['DDOG', 'Datadog', 'US'], + ['DVA', 'DaVita', 'US'], + ['DECK', 'Deckers Brands', 'US'], + ['DE', 'Deere & Company', 'US'], + ['DELL', 'Dell Technologies', 'US'], + ['DAL', 'Delta Air Lines', 'US'], + ['DVN', 'Devon Energy', 'US'], + ['DXCM', 'Dexcom', 'US'], + ['FANG', 'Diamondback Energy', 'US'], + ['DLR', 'Digital Realty', 'US'], + ['DG', 'Dollar General', 'US'], + ['DLTR', 'Dollar Tree', 'US'], + ['D', 'Dominion Energy', 'US'], + ['DPZ', "Domino's", 'US'], + ['DASH', 'DoorDash', 'US'], + ['DOV', 'Dover Corporation', 'US'], + ['DOW', 'Dow Inc.', 'US'], + ['DHI', 'D. R. Horton', 'US'], + ['DTE', 'DTE Energy', 'US'], + ['DUK', 'Duke Energy', 'US'], + ['DD', 'DuPont', 'US'], + ['ETN', 'Eaton Corporation', 'US'], + ['EBAY', 'eBay Inc.', 'US'], + ['ECHO', 'EchoStar', 'US'], + ['ECL', 'Ecolab', 'US'], + ['EIX', 'Edison International', 'US'], + ['EW', 'Edwards Lifesciences', 'US'], + ['ELV', 'Elevance Health', 'US'], + ['EME', 'Emcor', 'US'], + ['EMR', 'Emerson Electric', 'US'], + ['ETR', 'Entergy', 'US'], + ['EOG', 'EOG Resources', 'US'], + ['EQT', 'EQT Corporation', 'US'], + ['EFX', 'Equifax', 'US'], + ['EQIX', 'Equinix', 'US'], + ['EQR', 'Equity Residential', 'US'], + ['ERIE', 'Erie Indemnity', 'US'], + ['ESS', 'Essex Property Trust', 'US'], + ['EL', 'Estée Lauder Companies (The)', 'US'], + ['EG', 'Everest Group', 'US'], + ['EVRG', 'Evergy', 'US'], + ['ES', 'Eversource Energy', 'US'], + ['EXC', 'Exelon', 'US'], + ['EXE', 'Expand Energy', 'US'], + ['EXPE', 'Expedia Group', 'US'], + ['EXPD', 'Expeditors International', 'US'], + ['EXR', 'Extra Space Storage', 'US'], + ['XOM', 'ExxonMobil', 'US'], + ['FFIV', 'F5, Inc.', 'US'], + ['FDS', 'FactSet', 'US'], + ['FICO', 'Fair Isaac', 'US'], + ['FAST', 'Fastenal', 'US'], + ['FRT', 'Federal Realty Investment Trust', 'US'], + ['FDX', 'FedEx', 'US'], + ['FDXF', 'FedEx Freight', 'US'], + ['FERG', 'Ferguson Enterprises', 'US'], + ['FIS', 'Fidelity National Information Services', 'US'], + ['FITB', 'Fifth Third Bancorp', 'US'], + ['FSLR', 'First Solar', 'US'], + ['FE', 'FirstEnergy', 'US'], + ['FISV', 'Fiserv', 'US'], + ['FLEX', 'Flex Ltd.', 'US'], + ['F', 'Ford Motor Company', 'US'], + ['FTNT', 'Fortinet', 'US'], + ['FTV', 'Fortive', 'US'], + ['FOXA', 'Fox Corporation (Class A)', 'US'], + ['FOX', 'Fox Corporation (Class B)', 'US'], + ['BEN', 'Franklin Resources', 'US'], + ['FCX', 'Freeport-McMoRan', 'US'], + ['GRMN', 'Garmin', 'US'], + ['IT', 'Gartner', 'US'], + ['GE', 'GE Aerospace', 'US'], + ['GEHC', 'GE HealthCare', 'US'], + ['GEV', 'GE Vernova', 'US'], + ['GEN', 'Gen Digital', 'US'], + ['GNRC', 'Generac', 'US'], + ['GD', 'General Dynamics', 'US'], + ['GIS', 'General Mills', 'US'], + ['GM', 'General Motors', 'US'], + ['GPC', 'Genuine Parts Company', 'US'], + ['GILD', 'Gilead Sciences', 'US'], + ['GPN', 'Global Payments', 'US'], + ['GL', 'Globe Life', 'US'], + ['GDDY', 'GoDaddy', 'US'], + ['GS', 'Goldman Sachs', 'US'], + ['HAL', 'Halliburton', 'US'], + ['HIG', 'Hartford (The)', 'US'], + ['HAS', 'Hasbro', 'US'], + ['HCA', 'HCA Healthcare', 'US'], + ['DOC', 'Healthpeak Properties', 'US'], + ['HSIC', 'Henry Schein', 'US'], + ['HSY', 'Hershey Company (The)', 'US'], + ['HPE', 'Hewlett Packard Enterprise', 'US'], + ['HLT', 'Hilton Worldwide', 'US'], + ['HD', 'Home Depot (The)', 'US'], + ['HONA', 'Honeywell Aerospace', 'US'], + ['HON', 'Honeywell Technologies', 'US'], + ['HRL', 'Hormel Foods', 'US'], + ['HST', 'Host Hotels & Resorts', 'US'], + ['HWM', 'Howmet Aerospace', 'US'], + ['HPQ', 'HP Inc.', 'US'], + ['HUBB', 'Hubbell Incorporated', 'US'], + ['HUM', 'Humana', 'US'], + ['HBAN', 'Huntington Bancshares', 'US'], + ['HII', 'Huntington Ingalls Industries', 'US'], + ['IBM', 'IBM', 'US'], + ['IEX', 'IDEX Corporation', 'US'], + ['IDXX', 'Idexx Laboratories', 'US'], + ['ITW', 'Illinois Tool Works', 'US'], + ['INCY', 'Incyte', 'US'], + ['IR', 'Ingersoll Rand', 'US'], + ['PODD', 'Insulet Corporation', 'US'], + ['INTC', 'Intel', 'US'], + ['IBKR', 'Interactive Brokers', 'US'], + ['ICE', 'Intercontinental Exchange', 'US'], + ['IFF', 'International Flavors & Fragrances', 'US'], + ['IP', 'International Paper', 'US'], + ['INTU', 'Intuit', 'US'], + ['ISRG', 'Intuitive Surgical', 'US'], + ['IVZ', 'Invesco', 'US'], + ['INVH', 'Invitation Homes', 'US'], + ['IQV', 'IQVIA', 'US'], + ['IRM', 'Iron Mountain', 'US'], + ['JBHT', 'J.B. Hunt', 'US'], + ['JBL', 'Jabil', 'US'], + ['JKHY', 'Jack Henry & Associates', 'US'], + ['J', 'Jacobs Solutions', 'US'], + ['JNJ', 'Johnson & Johnson', 'US'], + ['JCI', 'Johnson Controls', 'US'], + ['JPM', 'JPMorgan Chase', 'US'], + ['KVUE', 'Kenvue', 'US'], + ['KDP', 'Keurig Dr Pepper', 'US'], + ['KEY', 'KeyCorp', 'US'], + ['KEYS', 'Keysight Technologies', 'US'], + ['KMB', 'Kimberly-Clark', 'US'], + ['KIM', 'Kimco Realty', 'US'], + ['KMI', 'Kinder Morgan', 'US'], + ['KKR', 'KKR & Co.', 'US'], + ['KLAC', 'KLA Corporation', 'US'], + ['KHC', 'Kraft Heinz', 'US'], + ['KR', 'Kroger', 'US'], + ['LHX', 'L3Harris', 'US'], + ['LH', 'Labcorp', 'US'], + ['LRCX', 'Lam Research', 'US'], + ['LVS', 'Las Vegas Sands', 'US'], + ['LDOS', 'Leidos', 'US'], + ['LEN', 'Lennar', 'US'], + ['LII', 'Lennox International', 'US'], + ['LLY', 'Lilly (Eli)', 'US'], + ['LIN', 'Linde plc', 'US'], + ['LYV', 'Live Nation Entertainment', 'US'], + ['LMT', 'Lockheed Martin', 'US'], + ['L', 'Loews Corporation', 'US'], + ['LOW', "Lowe's", 'US'], + ['LULU', 'Lululemon Athletica', 'US'], + ['LITE', 'Lumentum', 'US'], + ['LYB', 'LyondellBasell', 'US'], + ['MTB', 'M&T Bank', 'US'], + ['MPC', 'Marathon Petroleum', 'US'], + ['MAR', 'Marriott International', 'US'], + ['MRSH', 'Marsh McLennan', 'US'], + ['MLM', 'Martin Marietta Materials', 'US'], + ['MRVL', 'Marvell Technology', 'US'], + ['MAS', 'Masco', 'US'], + ['MA', 'Mastercard', 'US'], + ['MKC', 'McCormick & Company', 'US'], + ['MCD', "McDonald's", 'US'], + ['MCK', 'McKesson Corporation', 'US'], + ['MDT', 'Medtronic', 'US'], + ['MRK', 'Merck & Co.', 'US'], + ['META', 'Meta Platforms', 'US'], + ['MET', 'MetLife', 'US'], + ['MTD', 'Mettler Toledo', 'US'], + ['MGM', 'MGM Resorts', 'US'], + ['MCHP', 'Microchip Technology', 'US'], + ['MU', 'Micron Technology', 'US'], + ['MSFT', 'Microsoft', 'US'], + ['MAA', 'Mid-America Apartment Communities', 'US'], + ['MRNA', 'Moderna', 'US'], + ['TAP', 'Molson Coors Beverage Company', 'US'], + ['MDLZ', 'Mondelez International', 'US'], + ['MPWR', 'Monolithic Power Systems', 'US'], + ['MNST', 'Monster Beverage', 'US'], + ['MCO', "Moody's Corporation", 'US'], + ['MS', 'Morgan Stanley', 'US'], + ['MOS', 'Mosaic Company (The)', 'US'], + ['MSI', 'Motorola Solutions', 'US'], + ['MSCI', 'MSCI', 'US'], + ['NDAQ', 'Nasdaq, Inc.', 'US'], + ['NTAP', 'NetApp', 'US'], + ['NFLX', 'Netflix', 'US'], + ['NEM', 'Newmont', 'US'], + ['NWSA', 'News Corp (Class A)', 'US'], + ['NWS', 'News Corp (Class B)', 'US'], + ['NEE', 'NextEra Energy', 'US'], + ['NKE', 'Nike, Inc.', 'US'], + ['NI', 'NiSource', 'US'], + ['NDSN', 'Nordson Corporation', 'US'], + ['NSC', 'Norfolk Southern', 'US'], + ['NTRS', 'Northern Trust', 'US'], + ['NOC', 'Northrop Grumman', 'US'], + ['NCLH', 'Norwegian Cruise Line Holdings', 'US'], + ['NRG', 'NRG Energy', 'US'], + ['NUE', 'Nucor', 'US'], + ['NVDA', 'Nvidia', 'US'], + ['NVR', 'NVR, Inc.', 'US'], + ['NXPI', 'NXP Semiconductors', 'US'], + ['ORLY', "O'Reilly Automotive", 'US'], + ['OXY', 'Occidental Petroleum', 'US'], + ['ODFL', 'Old Dominion', 'US'], + ['OMC', 'Omnicom Group', 'US'], + ['ON', 'ON Semiconductor', 'US'], + ['OKE', 'Oneok', 'US'], + ['ORCL', 'Oracle Corporation', 'US'], + ['OTIS', 'Otis Worldwide', 'US'], + ['PCAR', 'Paccar', 'US'], + ['PKG', 'Packaging Corporation of America', 'US'], + ['PLTR', 'Palantir Technologies', 'US'], + ['PANW', 'Palo Alto Networks', 'US'], + ['PSKY', 'Paramount Skydance Corporation', 'US'], + ['PH', 'Parker Hannifin', 'US'], + ['PAYX', 'Paychex', 'US'], + ['PYPL', 'PayPal', 'US'], + ['PNR', 'Pentair', 'US'], + ['PEP', 'PepsiCo', 'US'], + ['PFE', 'Pfizer', 'US'], + ['PCG', 'PG&E Corporation', 'US'], + ['PM', 'Philip Morris International', 'US'], + ['PSX', 'Phillips 66', 'US'], + ['PNW', 'Pinnacle West Capital', 'US'], + ['PNC', 'PNC Financial Services', 'US'], + ['PPG', 'PPG Industries', 'US'], + ['PPL', 'PPL Corporation', 'US'], + ['PFG', 'Principal Financial Group', 'US'], + ['PG', 'Procter & Gamble', 'US'], + ['PGR', 'Progressive Corporation', 'US'], + ['PLD', 'Prologis', 'US'], + ['PRU', 'Prudential Financial', 'US'], + ['PEG', 'Public Service Enterprise Group', 'US'], + ['PTC', 'PTC Inc.', 'US'], + ['PSA', 'Public Storage', 'US'], + ['PHM', 'PulteGroup', 'US'], + ['PWR', 'Quanta Services', 'US'], + ['QCOM', 'Qualcomm', 'US'], + ['DGX', 'Quest Diagnostics', 'US'], + ['Q', 'Qnity Electronics', 'US'], + ['RL', 'Ralph Lauren Corporation', 'US'], + ['RJF', 'Raymond James Financial', 'US'], + ['RTX', 'RTX Corporation', 'US'], + ['O', 'Realty Income', 'US'], + ['REG', 'Regency Centers', 'US'], + ['REGN', 'Regeneron Pharmaceuticals', 'US'], + ['RF', 'Regions Financial Corporation', 'US'], + ['RSG', 'Republic Services', 'US'], + ['RMD', 'ResMed|', 'US'], + ['RVTY', 'Revvity', 'US'], + ['HOOD', 'Robinhood Markets', 'US'], + ['ROK', 'Rockwell Automation', 'US'], + ['ROL', 'Rollins, Inc.', 'US'], + ['ROP', 'Roper Technologies', 'US'], + ['ROST', 'Ross Stores', 'US'], + ['RCL', 'Royal Caribbean Group', 'US'], + ['SPGI', 'S&P Global', 'US'], + ['CRM', 'Salesforce', 'US'], + ['SNDK', 'Sandisk', 'US'], + ['SBAC', 'SBA Communications', 'US'], + ['SLB', 'Schlumberger', 'US'], + ['STX', 'Seagate Technology', 'US'], + ['SRE', 'Sempra', 'US'], + ['NOW', 'ServiceNow', 'US'], + ['SHW', 'Sherwin-Williams', 'US'], + ['SPG', 'Simon Property Group', 'US'], + ['SWKS', 'Skyworks Solutions', 'US'], + ['SJM', 'J.M. Smucker Company (The)', 'US'], + ['SW', 'Smurfit Westrock', 'US'], + ['SNA', 'Snap-on', 'US'], + ['SOLV', 'Solventum', 'US'], + ['SO', 'Southern Company', 'US'], + ['LUV', 'Southwest Airlines', 'US'], + ['SWK', 'Stanley Black & Decker', 'US'], + ['SBUX', 'Starbucks', 'US'], + ['STT', 'State Street Corporation', 'US'], + ['STLD', 'Steel Dynamics', 'US'], + ['STE', 'Steris', 'US'], + ['SYK', 'Stryker Corporation', 'US'], + ['SMCI', 'Supermicro', 'US'], + ['SYF', 'Synchrony Financial', 'US'], + ['SNPS', 'Synopsys', 'US'], + ['SYY', 'Sysco', 'US'], + ['TMUS', 'T-Mobile US', 'US'], + ['TROW', 'T. Rowe Price', 'US'], + ['TTWO', 'Take-Two Interactive', 'US'], + ['TPR', 'Tapestry, Inc.', 'US'], + ['TRGP', 'Targa Resources', 'US'], + ['TGT', 'Target Corporation', 'US'], + ['TEL', 'TE Connectivity', 'US'], + ['TDY', 'Teledyne Technologies', 'US'], + ['TER', 'Teradyne', 'US'], + ['TSLA', 'Tesla, Inc.', 'US'], + ['TXN', 'Texas Instruments', 'US'], + ['TPL', 'Texas Pacific Land Corporation', 'US'], + ['TXT', 'Textron', 'US'], + ['TMO', 'Thermo Fisher Scientific', 'US'], + ['TJX', 'TJX Companies', 'US'], + ['TKO', 'TKO Group Holdings', 'US'], + ['TTD', 'Trade Desk (The)', 'US'], + ['TSCO', 'Tractor Supply', 'US'], + ['TT', 'Trane Technologies', 'US'], + ['TDG', 'TransDigm Group', 'US'], + ['TRV', 'Travelers Companies (The)', 'US'], + ['TRMB', 'Trimble Inc.', 'US'], + ['TFC', 'Truist Financial', 'US'], + ['TYL', 'Tyler Technologies', 'US'], + ['TSN', 'Tyson Foods', 'US'], + ['USB', 'U.S. Bancorp', 'US'], + ['UBER', 'Uber', 'US'], + ['UDR', 'UDR, Inc.', 'US'], + ['ULTA', 'Ulta Beauty', 'US'], + ['UNP', 'Union Pacific Corporation', 'US'], + ['UAL', 'United Airlines Holdings', 'US'], + ['UPS', 'United Parcel Service', 'US'], + ['URI', 'United Rentals', 'US'], + ['UNH', 'UnitedHealth Group', 'US'], + ['UHS', 'Universal Health Services', 'US'], + ['VLO', 'Valero Energy', 'US'], + ['VEEV', 'Veeva Systems', 'US'], + ['VTR', 'Ventas', 'US'], + ['VLTO', 'Veralto', 'US'], + ['VRSN', 'Verisign', 'US'], + ['VRSK', 'Verisk Analytics', 'US'], + ['VZ', 'Verizon', 'US'], + ['VRTX', 'Vertex Pharmaceuticals', 'US'], + ['VRT', 'Vertiv', 'US'], + ['VTRS', 'Viatris', 'US'], + ['VICI', 'Vici Properties', 'US'], + ['V', 'Visa Inc.', 'US'], + ['VST', 'Vistra Corp.', 'US'], + ['VMC', 'Vulcan Materials Company', 'US'], + ['WRB', 'W. R. Berkley Corporation', 'US'], + ['GWW', 'W. W. Grainger', 'US'], + ['WAB', 'Wabtec', 'US'], + ['WMT', 'Walmart', 'US'], + ['DIS', 'Walt Disney Company (The)', 'US'], + ['WBD', 'Warner Bros. Discovery', 'US'], + ['WM', 'Waste Management', 'US'], + ['WAT', 'Waters Corporation', 'US'], + ['WEC', 'WEC Energy Group', 'US'], + ['WFC', 'Wells Fargo', 'US'], + ['WELL', 'Welltower', 'US'], + ['WST', 'West Pharmaceutical Services', 'US'], + ['WDC', 'Western Digital', 'US'], + ['WY', 'Weyerhaeuser', 'US'], + ['WSM', 'Williams-Sonoma, Inc.', 'US'], + ['WMB', 'Williams Companies', 'US'], + ['WTW', 'Willis Towers Watson', 'US'], + ['WDAY', 'Workday, Inc.', 'US'], + ['WYNN', 'Wynn Resorts', 'US'], + ['XEL', 'Xcel Energy', 'US'], + ['XYL', 'Xylem Inc.', 'US'], + ['YUM', 'Yum! Brands', 'US'], + ['ZBRA', 'Zebra Technologies', 'US'], + ['ZBH', 'Zimmer Biomet', 'US'], + ['ZTS', 'Zoetis', 'US'], +]) + +/** + * Representative liquid international listings used to diversify the fixture. + * Symbols use their local-market form and the third tuple value is an ISO-style + * country/market code, rather than a trading currency or exchange MIC. + * + * References checked 2026-08-15: STOXX Europe 50, KRX KOSPI market, + * JPX TOPIX Core30, and HKEX index constituent materials. + */ +const europeanInstruments = Object.freeze([ + ['ASML', 'ASML Holding', 'NL'], + ['INGA', 'ING Group', 'NL'], + ['ADYEN', 'Adyen', 'NL'], + ['PHIA', 'Philips', 'NL'], + ['HEIA', 'Heineken', 'NL'], + ['SAP', 'SAP', 'DE'], + ['SIE', 'Siemens', 'DE'], + ['ALV', 'Allianz', 'DE'], + ['DTE', 'Deutsche Telekom', 'DE'], + ['MBG', 'Mercedes-Benz Group', 'DE'], + ['BMW', 'BMW', 'DE'], + ['BAS', 'BASF', 'DE'], + ['MUV2', 'Munich Re', 'DE'], + ['VOW3', 'Volkswagen Preference', 'DE'], + ['IFX', 'Infineon Technologies', 'DE'], + ['MC', 'LVMH', 'FR'], + ['OR', "L'Oréal", 'FR'], + ['AIR', 'Airbus', 'FR'], + ['SU', 'Schneider Electric', 'FR'], + ['TTE', 'TotalEnergies', 'FR'], + ['SAN', 'Sanofi', 'FR'], + ['BNP', 'BNP Paribas', 'FR'], + ['CS', 'AXA', 'FR'], + ['DG', 'Vinci', 'FR'], + ['ENEL', 'Enel', 'IT'], + ['ENI', 'Eni', 'IT'], + ['ISP', 'Intesa Sanpaolo', 'IT'], + ['UCG', 'UniCredit', 'IT'], + ['STLAM', 'Stellantis', 'IT'], + ['SAN', 'Banco Santander', 'ES'], + ['IBE', 'Iberdrola', 'ES'], + ['ITX', 'Inditex', 'ES'], + ['BBVA', 'BBVA', 'ES'], + ['NESN', 'Nestlé', 'CH'], + ['ROG', 'Roche Holding', 'CH'], + ['NOVN', 'Novartis', 'CH'], + ['UBSG', 'UBS Group', 'CH'], + ['NOVO-B', 'Novo Nordisk', 'DK'], + ['MAERSK-B', 'A.P. Moller - Maersk', 'DK'], + ['VOLV-B', 'Volvo', 'SE'], + ['ERIC-B', 'Ericsson', 'SE'], + ['NOKIA', 'Nokia', 'FI'], + ['SHEL', 'Shell', 'GB'], + ['AZN', 'AstraZeneca', 'GB'], + ['HSBA', 'HSBC Holdings', 'GB'], + ['ULVR', 'Unilever', 'GB'], + ['LSEG', 'London Stock Exchange Group', 'GB'], +]) + +const europeanMarketCodes = Object.freeze([ + 'NL', + 'DE', + 'FR', + 'IT', + 'ES', + 'CH', + 'DK', + 'SE', + 'FI', + 'GB', +]) + +const europeanMarketGroups = Object.freeze( + europeanMarketCodes.map((market) => + europeanInstruments.filter(([, , instrumentMarket]) => + Object.is(instrumentMarket, market), + ), + ), +) + +const interleavedEuropeanInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...europeanMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + europeanMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const southKoreanInstruments = Object.freeze([ + ['005930', 'Samsung Electronics', 'KR'], + ['000660', 'SK hynix', 'KR'], + ['373220', 'LG Energy Solution', 'KR'], + ['207940', 'Samsung Biologics', 'KR'], + ['005380', 'Hyundai Motor', 'KR'], + ['000270', 'Kia', 'KR'], + ['068270', 'Celltrion', 'KR'], + ['105560', 'KB Financial Group', 'KR'], + ['055550', 'Shinhan Financial Group', 'KR'], + ['035420', 'NAVER', 'KR'], + ['035720', 'Kakao', 'KR'], + ['006400', 'Samsung SDI', 'KR'], + ['051910', 'LG Chem', 'KR'], + ['012330', 'Hyundai Mobis', 'KR'], + ['066570', 'LG Electronics', 'KR'], +]) + +const japaneseInstruments = Object.freeze([ + ['8306', 'Mitsubishi UFJ Financial Group', 'JP'], + ['7203', 'Toyota Motor', 'JP'], + ['6501', 'Hitachi', 'JP'], + ['8316', 'Sumitomo Mitsui Financial Group', 'JP'], + ['6758', 'Sony Group', 'JP'], + ['8058', 'Mitsubishi Corporation', 'JP'], + ['9984', 'SoftBank Group', 'JP'], + ['8035', 'Tokyo Electron', 'JP'], + ['8411', 'Mizuho Financial Group', 'JP'], + ['8031', 'Mitsui & Co.', 'JP'], + ['6861', 'Keyence', 'JP'], + ['7974', 'Nintendo', 'JP'], + ['6098', 'Recruit Holdings', 'JP'], + ['9432', 'Nippon Telegraph and Telephone', 'JP'], + ['4063', 'Shin-Etsu Chemical', 'JP'], +]) + +const hongKongInstruments = Object.freeze([ + ['0700', 'Tencent Holdings', 'HK'], + ['9988', 'Alibaba Group', 'HK'], + ['1810', 'Xiaomi', 'HK'], + ['3690', 'Meituan', 'HK'], + ['0941', 'China Mobile', 'HK'], + ['1211', 'BYD Company', 'HK'], + ['1299', 'AIA Group', 'HK'], + ['0388', 'Hong Kong Exchanges and Clearing', 'HK'], + ['0005', 'HSBC Holdings', 'HK'], + ['2318', 'Ping An Insurance', 'HK'], +]) + +const canadianInstruments = Object.freeze([ + ['RY', 'Royal Bank of Canada', 'CA'], + ['TD', 'Toronto-Dominion Bank', 'CA'], + ['SHOP', 'Shopify', 'CA'], + ['ENB', 'Enbridge', 'CA'], + ['CNR', 'Canadian National Railway', 'CA'], + ['CP', 'Canadian Pacific Kansas City', 'CA'], + ['BMO', 'Bank of Montreal', 'CA'], + ['CSU', 'Constellation Software', 'CA'], +]) + +const australianInstruments = Object.freeze([ + ['BHP', 'BHP Group', 'AU'], + ['CBA', 'Commonwealth Bank of Australia', 'AU'], + ['CSL', 'CSL', 'AU'], + ['NAB', 'National Australia Bank', 'AU'], + ['WBC', 'Westpac Banking Corporation', 'AU'], + ['ANZ', 'ANZ Group Holdings', 'AU'], + ['WES', 'Wesfarmers', 'AU'], + ['MQG', 'Macquarie Group', 'AU'], +]) + +const internationalMarketGroups = Object.freeze([ + interleavedEuropeanInstruments, + southKoreanInstruments, + japaneseInstruments, + hongKongInstruments, + canadianInstruments, + australianInstruments, +]) + +export const internationalInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...internationalMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + internationalMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const INTERNATIONAL_INSERTION_INTERVAL = 3 + +/** + * U.S. and international instruments are interleaved so ordinary benchmark + * sizes exercise multiple symbol formats and market labels. + */ +export const globalInstruments = Object.freeze( + marketInstruments.flatMap((instrument, index) => { + const internationalInstrument = + index % INTERNATIONAL_INSERTION_INTERVAL === 0 + ? internationalInstruments[index / INTERNATIONAL_INSERTION_INTERVAL] + : undefined + + return internationalInstrument + ? [instrument, internationalInstrument] + : [instrument] + }), +) as unknown as ReadonlyArray diff --git a/examples/lit/realtime-trading/src/feed/worker/market-feed-engine.ts b/examples/lit/realtime-trading/src/feed/worker/market-feed-engine.ts new file mode 100644 index 0000000000..fbd9c369c0 --- /dev/null +++ b/examples/lit/realtime-trading/src/feed/worker/market-feed-engine.ts @@ -0,0 +1,177 @@ +import { globalInstruments } from '../market-instruments.ts' +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const INITIAL_MARKET_SEED = 0x4d41524b +const LIVE_FEED_SEED = 0x5449434b + +export class MarketFeedEngine { + #quotes: Array = [] + #lastHistorySampledAt = new Uint32Array(0) + #random = createRandom(2_026) + #rowCursor = 0 + #tickIndex = 0 + + reset(count: number): Array { + const random = createRandom(INITIAL_MARKET_SEED ^ count) + const createdAt = Date.now() + + this.#quotes = Array.from({ length: count }, (_, index) => { + const [baseSymbol, company, market] = + globalInstruments[index % globalInstruments.length] + const series = Math.floor(index / globalInstruments.length) + const symbol = series === 0 ? baseSymbol : `${baseSymbol}${series}` + const previousClose = roundPrice(20 + random() * 480) + const open = roundPrice(previousClose * (1 + (random() - 0.5) * 0.016)) + const spread = Math.max(0.01, open * (0.0002 + random() * 0.0004)) + const history = Array.from({ length: 24 }, (_, historyIndex) => + roundPrice( + open * + (1 + Math.sin(historyIndex / 4) * 0.002 + (random() - 0.5) * 0.001), + ), + ) + const volume = Math.floor(50_000 + random() * 2_000_000) + const lastSize = Math.floor(10 + random() * 5_000) + + return { + id: `instrument-${index}`, + symbol, + company, + venue: market, + previousClose, + open, + high: open, + low: open, + price: open, + bid: roundPrice(open - spread / 2), + ask: roundPrice(open + spread / 2), + bidSize: Math.floor(100 + random() * 25_000), + askSize: Math.floor(100 + random() * 25_000), + lastSize, + lastMove: 0, + lastUpdatedAt: createdAt, + volume, + turnover: roundMoney(open * volume), + history, + } + }) + + this.#random = createRandom(LIVE_FEED_SEED ^ count) + this.#rowCursor = 0 + this.#lastHistorySampledAt = new Uint32Array(count) + this.#lastHistorySampledAt.fill(createdAt >>> 0) + + return this.#quotes.map((quote) => ({ + ...quote, + history: [...quote.history], + })) + } + + applyTicks( + tickCount: number, + updateSparklines: boolean, + sparklineSampleIntervalMs: number, + ): Array { + if (this.#quotes.length === 0 || tickCount <= 0) return [] + + const updatedAt = Date.now() + const sampledAt = updatedAt >>> 0 + const sampleIntervalMs = Math.max(16, sparklineSampleIntervalMs) + const updatedQuotes = new Map() + const stride = 97 + + this.#tickIndex = 0 + while (this.#tickIndex < tickCount) { + this.#rowCursor = (this.#rowCursor + stride) % this.#quotes.length + const quote = this.#quotes[this.#rowCursor] + const lastSampledAt = this.#lastHistorySampledAt[this.#rowCursor] + const shouldUpdateHistory = + updateSparklines && + (sampledAt - lastSampledAt) >>> 0 >= sampleIntervalMs + + if (shouldUpdateHistory) { + this.#lastHistorySampledAt[this.#rowCursor] = sampledAt + } + + this.#applyTick(quote, shouldUpdateHistory, updatedAt) + + const previousUpdate = updatedQuotes.get(this.#rowCursor) + updatedQuotes.set(this.#rowCursor, { + index: this.#rowCursor, + price: quote.price, + bid: quote.bid, + ask: quote.ask, + bidSize: quote.bidSize, + askSize: quote.askSize, + lastSize: quote.lastSize, + lastMove: quote.lastMove, + lastUpdatedAt: quote.lastUpdatedAt, + high: quote.high, + low: quote.low, + volume: quote.volume, + turnover: quote.turnover, + ...(shouldUpdateHistory || previousUpdate?.history + ? { history: [...quote.history] } + : {}), + }) + this.#tickIndex++ + } + + return [...updatedQuotes.values()] + } + + #applyTick( + quote: MarketQuoteSnapshot, + updateHistory: boolean, + updatedAt: number, + ): void { + const previousPrice = quote.price + const volatility = 0.00015 + this.#random() * 0.0012 + const move = previousPrice * (this.#random() - 0.495) * volatility + const nextPrice = roundPrice(Math.max(0.1, previousPrice + move)) + const spread = Math.max( + 0.01, + nextPrice * (0.00015 + this.#random() * 0.0005), + ) + + quote.lastMove = nextPrice - previousPrice + quote.price = nextPrice + quote.high = Math.max(quote.high, nextPrice) + quote.low = Math.min(quote.low, nextPrice) + quote.bid = roundPrice(nextPrice - spread / 2) + quote.ask = roundPrice(nextPrice + spread / 2) + quote.bidSize = Math.floor(100 + this.#random() * 25_000) + quote.askSize = Math.floor(100 + this.#random() * 25_000) + quote.lastSize = Math.floor(10 + this.#random() * 5_000) + quote.lastUpdatedAt = updatedAt + quote.volume += quote.lastSize + quote.turnover = roundMoney(quote.turnover + nextPrice * quote.lastSize) + + if (updateHistory) { + quote.history = [...quote.history.slice(-23), nextPrice] + } + } +} + +function createRandom(seed: number): () => number { + const runtime = { state: seed >>> 0 } + return () => { + runtime.state += 0x6d2b79f5 + const stateValue = runtime.state + const firstMix = Math.imul(stateValue ^ (stateValue >>> 15), stateValue | 1) + const secondMix = + firstMix + Math.imul(firstMix ^ (firstMix >>> 7), firstMix | 61) + const value = firstMix ^ secondMix + return ((value ^ (value >>> 14)) >>> 0) / 4_294_967_296 + } +} + +function roundPrice(value: number): number { + return Math.round(value * 100) / 100 +} + +function roundMoney(value: number): number { + return Math.round(value * 100) / 100 +} diff --git a/examples/lit/realtime-trading/src/feed/worker/market-feed-protocol.ts b/examples/lit/realtime-trading/src/feed/worker/market-feed-protocol.ts new file mode 100644 index 0000000000..21997ec89c --- /dev/null +++ b/examples/lit/realtime-trading/src/feed/worker/market-feed-protocol.ts @@ -0,0 +1,70 @@ +export interface MarketQuoteSnapshot { + id: string + symbol: string + company: string + venue: string + previousClose: number + open: number + high: number + low: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + volume: number + turnover: number + history: Array +} + +export interface MarketQuoteUpdate { + index: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + high: number + low: number + volume: number + turnover: number + history?: Array +} + +export type MarketFeedCommand = + | { + type: 'start' + rowCount: number + running: boolean + ticksPerSecond: number + publishIntervalMs: number + updateSparklines: boolean + sparklineSampleIntervalMs: number + } + | { type: 'set-running'; running: boolean } + | { type: 'set-rate'; ticksPerSecond: number } + | { type: 'set-publish-interval'; intervalMs: number } + | { type: 'set-sparklines'; enabled: boolean } + | { type: 'set-sparkline-interval'; intervalMs: number } + | { type: 'reset'; rowCount: number } + | { type: 'burst'; tickCount: number } + +export type MarketFeedEvent = + | { + type: 'snapshot' + sessionId: number + quotes: Array + } + | { + type: 'updates' + sessionId: number + tickCount: number + coalescedUpdateCount: number + updates: Array + } diff --git a/examples/lit/realtime-trading/src/feed/worker/market-feed.worker.ts b/examples/lit/realtime-trading/src/feed/worker/market-feed.worker.ts new file mode 100644 index 0000000000..2b7a642fd9 --- /dev/null +++ b/examples/lit/realtime-trading/src/feed/worker/market-feed.worker.ts @@ -0,0 +1,143 @@ +import { initialMarketFeedConfig } from '../market-feed-config' +import { MarketFeedEngine } from './market-feed-engine' +import type { + MarketFeedCommand, + MarketFeedEvent, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const engine = new MarketFeedEngine() +const pendingUpdates = new Map() +const runtime = { + sessionId: 0, + pendingTickCount: 0, + pendingCoalescedUpdateCount: 0, + initialized: false, + running: true, + ticksPerSecond: initialMarketFeedConfig.targetSamplesPerSecond, + publishIntervalMs: initialMarketFeedConfig.publishIntervalMs, + publishTimerId: null as ReturnType | null, + updateSparklines: initialMarketFeedConfig.updateSparklines, + sparklineSampleIntervalMs: initialMarketFeedConfig.sparklineSampleIntervalMs, + tickBudget: 0, + lastTickAt: performance.now(), +} + +addEventListener('message', ({ data }: MessageEvent) => { + switch (data.type) { + case 'start': + runtime.running = data.running + runtime.ticksPerSecond = data.ticksPerSecond + runtime.publishIntervalMs = data.publishIntervalMs + runtime.updateSparklines = data.updateSparklines + runtime.sparklineSampleIntervalMs = data.sparklineSampleIntervalMs + restartPublishTimer() + reset(data.rowCount) + break + case 'set-running': + runtime.running = data.running + break + case 'set-rate': + runtime.ticksPerSecond = data.ticksPerSecond + break + case 'set-publish-interval': + runtime.publishIntervalMs = Math.max(4, data.intervalMs) + restartPublishTimer() + break + case 'set-sparklines': + runtime.updateSparklines = data.enabled + break + case 'set-sparkline-interval': + runtime.sparklineSampleIntervalMs = Math.max(16, data.intervalMs) + break + case 'reset': + reset(data.rowCount) + break + case 'burst': + produceTicks(data.tickCount) + flush() + break + } +}) + +setInterval(() => { + const now = performance.now() + const elapsed = Math.min(100, Math.max(0, now - runtime.lastTickAt)) + runtime.lastTickAt = now + + if (runtime.initialized && runtime.running) { + runtime.tickBudget += (runtime.ticksPerSecond * elapsed) / 1_000 + const tickCount = Math.floor(runtime.tickBudget) + runtime.tickBudget -= tickCount + produceTicks(tickCount) + } +}, 16) + +restartPublishTimer() + +function reset(rowCount: number): void { + runtime.initialized = true + runtime.sessionId++ + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + runtime.tickBudget = 0 + runtime.lastTickAt = performance.now() + + post({ + type: 'snapshot', + sessionId: runtime.sessionId, + quotes: engine.reset(rowCount), + }) +} + +function produceTicks(tickCount: number): void { + if (!runtime.initialized || tickCount <= 0) return + + runtime.pendingTickCount += tickCount + for (const update of engine.applyTicks( + tickCount, + runtime.updateSparklines, + runtime.sparklineSampleIntervalMs, + )) { + const previousUpdate = pendingUpdates.get(update.index) + if (previousUpdate) runtime.pendingCoalescedUpdateCount++ + pendingUpdates.set(update.index, { + ...update, + ...(update.history || !previousUpdate?.history + ? {} + : { history: previousUpdate.history }), + }) + } +} + +function flush(): void { + if (runtime.pendingTickCount === 0) return + + const message: MarketFeedEvent = { + type: 'updates', + sessionId: runtime.sessionId, + tickCount: runtime.pendingTickCount, + coalescedUpdateCount: runtime.pendingCoalescedUpdateCount, + updates: [...pendingUpdates.values()], + } + + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + post(message) +} + +function restartPublishTimer(): void { + if (runtime.publishTimerId !== null) { + clearInterval(runtime.publishTimerId) + } + runtime.publishTimerId = setInterval( + flush, + Math.max(4, runtime.publishIntervalMs), + ) +} + +function post(event: MarketFeedEvent): void { + postMessage(event) +} diff --git a/examples/lit/realtime-trading/src/index.css b/examples/lit/realtime-trading/src/index.css new file mode 100644 index 0000000000..0f57ee21d7 --- /dev/null +++ b/examples/lit/realtime-trading/src/index.css @@ -0,0 +1,1070 @@ +:root { + color-scheme: dark; + --font-ui: + Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, + 'Segoe UI', sans-serif; + --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace; + font-family: var(--font-ui); + font-synthesis: none; + --background: #050505; + --panel: #080808; + --panel-raised: #111111; + --panel-hover: #181818; + --surface-bar: #080808; + --surface-toolbar: #0d0d0d; + --surface-table: #050505; + --surface-header: #101010; + --surface-control: #151515; + --border: #303030; + --border-soft: #242424; + --border-strong: #4a4a4a; + --text: #e7ebf0; + --text-strong: #ffffff; + --text-inverse: #f7f9fb; + --muted: #737982; + --blue: #62a9ff; + --blue-soft: #a9d0ff; + --green: #42e488; + --red: #ff646b; + --amber: #dfb465; + --depth-bid: #315774; + --depth-ask: #634049; + --row-alt: rgb(255 255 255 / 1.8%); + --row-selected: rgb(66 132 214 / 16%); + --control-border: #354456; + --control-hover: #192431; + --sidebar-width: 18rem; + --shell-bar-height: 2.625rem; + --metrics-height: 3.5rem; + --statusbar-height: 1.625rem; + --virtual-footer-height: 2.125rem; + --table-header-height: 2rem; + --table-row-height: 2rem; + --shell-inline-padding: 0.75rem; + --table-cell-inline-padding: 0.6rem; + --control-radius: 1px; +} + +* { + box-sizing: border-box; +} + +html, +body { + min-width: 320px; + min-height: 100%; + margin: 0; + background: var(--background); +} + +body { + color: var(--text); +} + +button, +select, +input { + font: inherit; +} + +button, +select { + color: var(--text); + background: var(--panel-raised); + border: 1px solid var(--control-border); + border-radius: var(--control-radius); +} + +button { + padding: 0.5rem 0.65rem; + cursor: pointer; + font-size: 0.72rem; + font-weight: 650; + letter-spacing: 0.025em; +} + +button:hover { + background: var(--control-hover); + border-color: var(--border-strong); +} + +button:focus-visible, +select:focus-visible, +input:focus-visible { + outline: 1px solid var(--blue); + outline-offset: 1px; +} + +select { + width: 100%; + padding: 0.45rem 0.55rem; + font-size: 0.75rem; +} + +.trading-terminal { + --active-sidebar-width: var(--sidebar-width); + display: grid; + width: 100%; + height: 100dvh; + min-height: 0; + overflow: hidden; + background: var(--background); + grid-template-areas: + 'header sidebar' + 'content sidebar' + 'footer sidebar'; + grid-template-columns: minmax(0, 1fr) var(--active-sidebar-width); + grid-template-rows: auto minmax(0, 1fr) auto; + transition: grid-template-columns 160ms ease; +} + +.trading-terminal.is-sidebar-collapsed { + --active-sidebar-width: 0px; +} + +.shell-header { + display: flex; + min-width: 0; + flex-direction: column; + grid-area: header; +} + +.app-bar { + display: flex; + min-height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + background: var(--surface-bar); + border-bottom: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.68rem; + letter-spacing: 0.045em; +} + +.brand, +.header-actions, +.feed-status { + display: flex; + align-items: center; +} + +.brand { + gap: 0.65rem; + color: var(--text-strong); +} + +.header-actions { + gap: 0.75rem; +} + +.sidebar-toggle { + display: grid; + width: 1.9rem; + height: 1.9rem; + padding: 0; + place-items: center; + color: var(--muted); + background: transparent; + border-color: transparent; +} + +.sidebar-toggle:hover { + color: var(--text-strong); + background: var(--surface-control); + border-color: var(--border); +} + +.sidebar-toggle svg { + width: 1rem; + height: 1rem; + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-width: 1.4; +} + +.feed-status { + gap: 0.4rem; + color: var(--muted); +} + +.feed-status.is-running { + color: var(--green); +} + +.status-dot { + width: 6px; + height: 6px; + background: var(--muted); + border-radius: 50%; +} + +.feed-status.is-running .status-dot { + background: var(--green); +} + +.development-warning { + flex: 0 0 auto; + padding: 0.3rem 0.75rem; + color: var(--amber); + background: color-mix(in srgb, var(--amber) 8%, var(--background)); + border-bottom: 1px solid color-mix(in srgb, var(--amber) 24%, var(--border)); + font-family: var(--font-mono); + font-size: 0.62rem; + letter-spacing: 0.04em; +} + +.market-panel { + display: flex; + min-width: 0; + min-height: 0; + flex-direction: column; + background: var(--panel); + grid-area: content; +} + +.metrics-strip { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + background: var(--border); + border-bottom: 1px solid var(--border); + gap: 1px; +} + +.metrics-strip h2 { + margin: 0; + padding: 0.65rem var(--shell-inline-padding) 0.45rem; + color: var(--muted); + background: var(--surface-table); + font-size: 0.58rem; + grid-column: 1 / -1; + letter-spacing: 0.075em; +} + +trading-metrics-strip { + display: block; +} + +.metrics-strip article { + min-width: 0; + min-height: 4.25rem; + padding: 0.5rem var(--shell-inline-padding); + background: var(--surface-bar); +} + +.metrics-strip span, +.metrics-strip small { + display: block; + color: var(--muted); + font-size: 0.56rem; + letter-spacing: 0.045em; + line-height: 1.35; +} + +.metrics-strip strong { + display: block; + margin: 0.12rem 0 0.08rem; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.88rem; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +.metrics-strip strong.metric-alert { + color: var(--amber); +} + +.table-scroll { + flex: 1; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +trading-data-table { + display: flex; + flex-direction: column; + flex: 1; + min-width: 0; + min-height: 0; +} + +.virtual-scroll-footer { + display: flex; + flex: 0 0 auto; + align-items: center; + justify-content: space-between; + min-height: var(--virtual-footer-height); + padding: 0 var(--shell-inline-padding); + color: var(--muted); + background: var(--surface-toolbar); + border-top: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.68rem; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +table { + min-width: 100%; + border-spacing: 0; + table-layout: fixed; + font-family: var(--font-ui); + font-size: 0.78rem; + font-variant-numeric: tabular-nums; +} + +.virtual-table { + display: grid; +} + +.virtual-table thead { + display: grid; +} + +.virtual-table thead tr, +.virtual-table-row { + display: flex; + width: 100%; +} + +.virtual-table th, +.virtual-table-row > td { + flex: 0 0 auto; +} + +.virtual-table-body { + position: relative; + display: grid; +} + +.virtual-table-row { + position: absolute; + left: 0; + height: var(--table-row-height); +} + +.virtual-table-row > td { + display: block; +} + +.trading-data-grid { + display: grid; +} + +.trading-data-grid thead, +.trading-data-grid tbody { + display: grid; +} + +.trading-data-grid tbody { + -webkit-user-select: none; + user-select: none; +} + +.trading-data-grid thead > tr, +.trading-data-grid tbody > tr { + display: flex; + width: 100%; +} + +.trading-data-grid tbody > tr { + min-height: var(--table-row-height); + content-visibility: auto; + contain-intrinsic-block-size: var(--table-row-height); +} + +.trading-data-grid th, +.trading-data-grid td { + flex: 0 0 auto; +} + +thead { + position: sticky; + z-index: 2; + top: 0; +} + +th { + height: var(--table-header-height); + padding: 0 var(--table-cell-inline-padding); + color: var(--muted); + background: var(--surface-header); + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border); + font-size: 0.7rem; + font-weight: 500; + letter-spacing: 0.005em; + text-align: left; + white-space: nowrap; +} + +th.column-group-header { + color: #666b72; + font-size: 0.72rem; + font-weight: 500; + text-align: center; +} + +thead tr:first-child th.column-group-header { + color: #777d85; + font-size: 0.76rem; +} + +th.numeric-header { + text-align: right; +} + +td { + height: var(--table-row-height); + padding: 0 var(--table-cell-inline-padding); + overflow: hidden; + color: #eef1f5; + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border-soft); + text-align: right; + text-overflow: ellipsis; + white-space: nowrap; +} + +th:last-child, +td:last-child { + border-right: 0; +} + +td[data-column-id='market'], +td[data-column-id='name'], +td[data-column-id='symbol'] { + text-align: left; +} + +td[data-column-id='market'] { + color: var(--blue); + font-weight: 550; +} + +td[data-column-id='name'] { + color: var(--text-strong); +} + +td[data-column-id='symbol'] { + color: #d8dde4; + font-weight: 600; +} + +tbody tr:nth-child(even) { + background: var(--row-alt); +} + +tbody tr:hover { + background: var(--panel-hover); +} + +tbody tr[data-symbol-selected='true'] { + background: var(--row-selected); + box-shadow: inset 2px 0 0 var(--blue); +} + +.table-scroll:focus { + outline: none; +} + +th { + position: relative; +} + +.leaf-header-content { + display: flex; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + height: 100%; + align-items: stretch; + margin-inline: calc(-1 * var(--table-cell-inline-padding)); +} + +.column-drag-handle, +.sort-header-button { + min-width: 0; + height: 100%; + padding: 0; + color: inherit; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-weight: inherit; + letter-spacing: inherit; +} + +.column-drag-handle { + flex: 0 0 1.05rem; + color: var(--muted); + cursor: grab; + opacity: 0.35; + font-size: 0.56rem; + letter-spacing: -0.32rem; + text-align: center; +} + +.column-drag-handle:active { + cursor: grabbing; +} + +th:hover .column-drag-handle, +.column-drag-handle:focus-visible { + opacity: 0.9; +} + +.column-drag-handle:hover, +.sort-header-button:hover { + background: rgb(255 255 255 / 4%); + border-color: transparent; +} + +th.is-column-dragging { + opacity: 0.45; +} + +th.is-column-drop-target { + background: rgb(50 139 255 / 16%); + box-shadow: inset 4px 0 0 var(--blue); +} + +th.is-column-drop-target::before { + position: absolute; + z-index: 6; + top: -1px; + bottom: -1px; + left: -2px; + width: 4px; + background: #62a9ff; + box-shadow: + 0 0 0 1px rgb(0 0 0 / 55%), + 0 0 12px rgb(70 151 255 / 90%); + content: ''; + pointer-events: none; +} + +.sort-header-button { + display: flex; + min-width: 0; + flex: 1; + align-items: center; + justify-content: flex-start; + gap: 0.3rem; + padding-inline: 0.25rem var(--table-cell-inline-padding); + cursor: default; + text-align: inherit; +} + +.numeric-header .sort-header-button { + justify-content: flex-end; +} + +.sort-header-button.is-sortable { + cursor: pointer; +} + +.sort-header-button:disabled { + opacity: 1; +} + +.header-label { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.sort-indicator { + flex: 0 0 auto; + color: #66717e; + font-size: 0.72rem; +} + +.sort-indicator.is-active { + color: var(--blue-soft); +} + +.column-resize-handle { + position: absolute; + z-index: 3; + top: 0; + right: -3px; + width: 7px; + height: 100%; + cursor: col-resize; + touch-action: none; + user-select: none; +} + +.column-resize-handle::after { + position: absolute; + top: 20%; + right: 3px; + width: 1px; + height: 60%; + background: var(--border-strong); + content: ''; + opacity: 0; +} + +th:hover > .column-resize-handle::after, +.column-resize-handle.is-resizing::after { + background: var(--blue); + opacity: 1; +} + +tbody tr[aria-selected='true'] { + background: rgb(76 145 228 / 13%); +} + +td[aria-selected='true'] { + position: relative; + background: rgb(70 139 222 / 12%); +} + +td[data-cell-focused='true'] { + background: rgb(70 139 222 / 21%); +} + +td[aria-selected='true']::after { + position: absolute; + z-index: 1; + inset: 0; + border: 1px solid transparent; + content: ''; + pointer-events: none; +} + +td[data-selection-top='true']::after { + border-top-color: var(--blue); +} + +td[data-selection-right='true']::after { + border-right-color: var(--blue); +} + +td[data-selection-bottom='true']::after { + border-bottom-color: var(--blue); +} + +td[data-selection-left='true']::after { + border-left-color: var(--blue); +} + +.price-button { + min-width: 4.5rem; + padding: 0; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-variant-numeric: tabular-nums; + font-weight: 600; + text-align: right; +} + +.price-button:hover { + background: transparent; + text-decoration: underline; + text-underline-offset: 2px; +} + +.move-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.move-cell.quote-up, +.percent-change-cell.quote-up { + background: color-mix(in srgb, var(--green) 7%, transparent); +} + +.move-cell.quote-down, +.percent-change-cell.quote-down { + background: color-mix(in srgb, var(--red) 7%, transparent); +} + +.percent-change-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.spread-cell { + display: flex; + align-items: baseline; + justify-content: flex-end; + gap: 0.35rem; + color: var(--text); +} + +.spread-cell small { + min-width: 2.8rem; + color: var(--muted); + font-size: 0.55rem; +} + +.spread-cell.spread-wide, +.spread-cell.spread-wide small { + color: var(--amber); +} + +.depth-cell { + position: relative; + display: flex; + height: 17px; + overflow: hidden; + background: var(--surface-control); +} + +.depth-bid, +.depth-ask { + height: 100%; + opacity: 0.78; +} + +.depth-bid { + background: var(--depth-bid); + border-right: 1px solid var(--panel); +} + +.depth-ask { + background: var(--depth-ask); +} + +.depth-values { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 0.28rem; + color: var(--text-strong); + font-size: 0.57rem; + text-shadow: 0 1px var(--background); +} + +.quote-age { + color: var(--muted); +} + +.quote-age-warm { + color: var(--amber); +} + +.quote-age-stale { + color: var(--red); +} + +.quote-up { + color: var(--green); +} + +.quote-down { + color: var(--red); +} + +.sparkline { + display: block; + width: 100%; + height: 1.35rem; + margin-left: auto; + color: var(--blue-soft); + overflow: visible; +} + +.sparkline.quote-up { + color: var(--green); +} + +.sparkline.quote-down { + color: var(--red); +} + +.sparkline polyline { + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-linejoin: miter; + stroke-width: 1.25; + vector-effect: non-scaling-stroke; +} + +.market-statusbar { + display: flex; + flex: 0 0 var(--statusbar-height); + min-height: var(--statusbar-height); + gap: 1.1rem; + align-items: center; + padding: 0 0.65rem; + color: var(--muted); + background: var(--surface-bar); + border-top: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.56rem; + grid-area: footer; + letter-spacing: 0.035em; +} + +.market-statusbar strong { + margin-left: 0.25rem; + color: var(--text); + font-weight: 500; +} + +.sidebar-slot { + width: var(--sidebar-width); + min-width: 0; + min-height: 0; + overflow: hidden; + background: var(--surface-table); + border-left: 1px solid var(--border); + grid-area: sidebar; + transition: + opacity 120ms ease, + transform 160ms ease, + visibility 160ms; +} + +.is-sidebar-collapsed .sidebar-slot { + visibility: hidden; + opacity: 0; + pointer-events: none; + transform: translateX(100%); +} + +.configurator { + width: 100%; + height: 100%; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +.configurator > header { + display: flex; + height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + color: var(--text-strong); + background: var(--surface-toolbar); + border-bottom: 1px solid var(--border); + font-size: 0.65rem; + font-weight: 700; + letter-spacing: 0.055em; +} + +.configurator > header small { + color: var(--muted); + font-size: 0.54rem; + font-weight: 500; +} + +.config-section { + display: grid; + gap: 0.7rem; + padding: 0.8rem var(--shell-inline-padding); + border-bottom: 1px solid var(--border); +} + +.config-section h2 { + margin: 0; + color: var(--muted); + font-size: 0.58rem; + letter-spacing: 0.075em; +} + +.primary-action { + width: 100%; + color: var(--text-inverse); + background: var(--blue); + border-color: var(--blue-soft); +} + +.primary-action:hover { + background: var(--blue-soft); + border-color: var(--text-strong); +} + +.field { + display: grid; + gap: 0.35rem; + color: var(--text); + font-size: 0.66rem; +} + +.rate-field > span { + display: flex; + justify-content: space-between; +} + +.rate-field strong { + color: var(--text); + font-family: var(--font-mono); + font-weight: 500; +} + +.field small { + color: var(--muted); + font-family: var(--font-mono); + font-size: 0.55rem; +} + +input[type='range'] { + width: 100%; + margin: 0; + accent-color: var(--blue); +} + +.toggle-field { + display: flex; + gap: 0.5rem; + align-items: flex-start; + color: var(--text); + font-size: 0.66rem; + line-height: 1.3; +} + +.toggle-field input { + margin: 0.12rem 0 0; + accent-color: var(--blue); +} + +.toggle-field small { + display: block; + margin-top: 0.14rem; + color: var(--muted); + font-size: 0.57rem; +} + +.action-grid { + display: grid; + grid-template-columns: 1fr; + gap: 0.4rem; +} + +.diagnostics dl, +.selected-instrument dl { + display: grid; + gap: 0; + margin: 0; +} + +.diagnostics dl > div, +.selected-instrument dl > div { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 24px; + border-bottom: 1px solid var(--border-soft); +} + +.diagnostics dl > div:last-child, +.selected-instrument dl > div:last-child { + border-bottom: 0; +} + +.diagnostics dl > div:has(dd[data-testid$='-breakdown']) { + display: grid; + grid-template-columns: minmax(0, 1fr); + align-content: center; + padding-block: 0.28rem; +} + +.diagnostics dd[data-testid$='-breakdown'] { + width: 100%; + overflow-x: auto; + padding-block: 0.12rem; + white-space: nowrap; + scrollbar-width: thin; +} + +dt { + color: var(--muted); + font-size: 0.61rem; +} + +dd { + margin: 0; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.62rem; +} + +.selection { + display: flex; + align-items: flex-start; + justify-content: space-between; +} + +.selection div { + display: grid; + gap: 0.18rem; +} + +.selection strong { + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.85rem; +} + +.selection span, +.selection small, +.selected-instrument p { + color: var(--muted); + font-size: 0.61rem; +} + +.selected-instrument p { + margin: 0; + line-height: 1.45; +} + +@media (max-width: 980px) { + :root { + --sidebar-width: 15.625rem; + } +} + +@media (max-width: 720px) { + .trading-terminal { + --active-sidebar-width: 0px; + height: 100dvh; + min-height: 0; + overflow: hidden; + } + + .market-panel { + min-height: 0; + } + + .table-scroll { + min-height: 0; + } + + .sidebar-slot { + position: fixed; + z-index: 20; + top: 0; + right: 0; + bottom: 0; + width: min(var(--sidebar-width), calc(100vw - 2.75rem)); + box-shadow: -18px 0 42px rgb(0 0 0 / 48%); + } + + .is-sidebar-collapsed .sidebar-slot { + box-shadow: none; + } +} diff --git a/examples/lit/realtime-trading/src/main.ts b/examples/lit/realtime-trading/src/main.ts new file mode 100644 index 0000000000..b0c36824e4 --- /dev/null +++ b/examples/lit/realtime-trading/src/main.ts @@ -0,0 +1,35 @@ +import { LitElement, html } from 'lit' +import { customElement } from 'lit/decorators.js' +import { TradingBenchmarkController } from './benchmark/trading-benchmark-controller' +import { MarketFeedController } from './feed/market-feed-controller' +import './shell/TradingShell' +import './index.css' + +@customElement('realtime-trading-app') +export class RealtimeTradingApp extends LitElement { + readonly #feed = new MarketFeedController() + readonly #benchmark = new TradingBenchmarkController(this.#feed) + readonly #stop = { + feed: null as (() => void) | null, + benchmark: null as (() => void) | null, + } + protected createRenderRoot() { + return this + } + connectedCallback() { + super.connectedCallback() + this.#stop.feed = this.#feed.start() + this.#stop.benchmark = this.#benchmark.start() + } + disconnectedCallback() { + this.#stop.benchmark?.() + this.#stop.feed?.() + super.disconnectedCallback() + } + protected render() { + return html`` + } +} diff --git a/examples/lit/realtime-trading/src/shell/AppHeader.ts b/examples/lit/realtime-trading/src/shell/AppHeader.ts new file mode 100644 index 0000000000..4b349bab9b --- /dev/null +++ b/examples/lit/realtime-trading/src/shell/AppHeader.ts @@ -0,0 +1,42 @@ +import { html } from 'lit' +import { customElement, property } from 'lit/decorators.js' +import { ControllerElement } from './controller-element' +import type { MarketFeedController } from '../feed/market-feed-controller' + +@customElement('trading-app-header') +export class AppHeader extends ControllerElement { + @property({ attribute: false }) feed!: MarketFeedController + @property({ type: Boolean }) sidebarOpen = true + @property({ attribute: false }) toggleSidebar: () => void = () => undefined + protected firstUpdated() { + this.observe(this.feed.workerReady) + this.observe(this.feed.running) + } + protected render() { + const workerReady = this.feed.workerReady.get() + const running = this.feed.running.get() + return html`
+
MARKET MONITOR
+
+ ${!workerReady ? 'FEED CONNECTING' : running ? 'FEED LIVE' : 'FEED PAUSED'} +
+
` + } +} diff --git a/examples/lit/realtime-trading/src/shell/Configurator.ts b/examples/lit/realtime-trading/src/shell/Configurator.ts new file mode 100644 index 0000000000..18b3c1f7a8 --- /dev/null +++ b/examples/lit/realtime-trading/src/shell/Configurator.ts @@ -0,0 +1,216 @@ +import { html } from 'lit' +import { customElement, property } from 'lit/decorators.js' +import { repeat } from 'lit/directives/repeat.js' +import { + feedSampleRateAt, + feedSampleRateIndex, + feedSampleRateOptions, +} from '../feed/feed-sample-rates' +import { + FORCED_VIRTUALIZATION_ROW_COUNT, + resolveVirtualScrollMode, +} from '../table/trading-row-virtualizer' +import { configuratorOptions } from './configurator-options' +import { ControllerElement } from './controller-element' +import './Diagnostics' +import './MetricsStrip' +import './SelectedInstrument' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +const rate = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const value = (event: Event) => + (event.target as HTMLInputElement | HTMLSelectElement).value +const number = (event: Event) => Number(value(event)) +const checked = (event: Event) => (event.target as HTMLInputElement).checked +const options = ( + items: ReadonlyArray<{ + readonly label: string + readonly value: number | string + }>, + selectedValue: number | string, +) => + repeat( + items, + (item) => item.value, + (item) => + html``, + ) + +@customElement('trading-configurator') +export class Configurator extends ControllerElement { + @property({ attribute: false }) controller!: TradingBenchmarkController + @property({ attribute: false }) feed!: MarketFeedController + protected firstUpdated() { + this.observe(this.controller.store) + this.observe(this.controller.renderAtoms.rendererMode) + this.observe(this.feed.running) + this.observe(this.feed.instrumentCount) + this.observe(this.feed.targetTicksPerSecond) + this.observe(this.feed.publishIntervalMs) + this.observe(this.feed.updateSparklines) + this.observe(this.feed.sparklineSampleIntervalMs) + } + protected render() { + const feedState = { + running: this.feed.running.get(), + instrumentCount: this.feed.instrumentCount.get(), + targetTicksPerSecond: this.feed.targetTicksPerSecond.get(), + publishIntervalMs: this.feed.publishIntervalMs.get(), + updateSparklines: this.feed.updateSparklines.get(), + sparklineSampleIntervalMs: this.feed.sparklineSampleIntervalMs.get(), + } + const benchmark = this.controller.store.get() + const forced = feedState.instrumentCount >= FORCED_VIRTUALIZATION_ROW_COUNT + const virtualMode = resolveVirtualScrollMode( + benchmark.requestedVirtualScrollMode, + feedState.instrumentCount, + ) + return html`` + } +} diff --git a/examples/lit/realtime-trading/src/shell/Diagnostics.ts b/examples/lit/realtime-trading/src/shell/Diagnostics.ts new file mode 100644 index 0000000000..2d78db9cd8 --- /dev/null +++ b/examples/lit/realtime-trading/src/shell/Diagnostics.ts @@ -0,0 +1,153 @@ +import { html } from 'lit' +import { customElement, property } from 'lit/decorators.js' +import { repeat } from 'lit/directives/repeat.js' +import { ControllerElement } from './controller-element' +import type { NamedInvocationRate } from '../benchmark/benchmark-monitor' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +const integer = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }) +const rate = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const ms = (value: number) => `${value.toFixed(2)} ms` +const invocations = (values: ReadonlyArray) => { + const active = values.filter((entry) => entry.callsPerSecond > 0) + return active.length + ? active + .map((entry) => `${entry.name} ${rate.format(entry.callsPerSecond)}`) + .join(' · ') + : '—' +} +@customElement('trading-diagnostics') +export class Diagnostics extends ControllerElement { + @property({ attribute: false }) controller!: TradingBenchmarkController + protected firstUpdated() { + this.observe(this.controller.store) + } + protected render() { + const state = this.controller.store.get() + const metrics = state.metrics + const items = [ + [ + 'Worker-generated samples / s', + rate.format(metrics.actualTicksPerSecond), + 'actual-rate', + ], + [ + 'Changed rows / s', + rate.format(metrics.rowUpdatesPerSecond), + 'row-update-rate', + ], + [ + 'Worker messages / s', + metrics.workerMessagesPerSecond.toFixed(1), + 'message-rate', + ], + [ + 'Snapshots applied / s', + metrics.stateApplicationsPerSecond.toFixed(1), + 'state-apply-rate', + ], + [ + 'DOM commits / s', + metrics.tableCommitsPerSecond.toFixed(1), + 'table-render-rate', + ], + [ + 'Commit latency p95 / max (10 s)', + `${ms(metrics.p95CommitLatencyMs)} / ${ms(metrics.maxCommitLatencyMs)}`, + '', + ], + ['Mounted cells', integer.format(state.mountedCells), ''], + ['Live components', integer.format(state.liveComponents), ''], + [ + 'Created / destroyed', + `${integer.format(metrics.componentsCreated)} / ${integer.format(metrics.componentsDestroyed)}`, + '', + ], + [ + 'Renderer callbacks / s', + rate.format(metrics.cellRendererCallsPerSecond), + 'cell-render-rate', + ], + [ + 'Component executions / s', + rate.format(metrics.componentRenderCallsPerSecond), + 'component-render-rate', + ], + [ + 'Executions by component / s', + invocations(metrics.componentRenderRates), + 'component-render-breakdown', + ], + [ + 'Callbacks by column / s', + invocations(metrics.cellRendererRates), + 'cell-render-breakdown', + ], + [ + 'Observed MutationRecords / s', + rate.format(metrics.domMutationsPerSecond), + 'dom-mutation-rate', + ], + [ + 'Core row model calls / s', + metrics.rowModelCallsPerSecond.toFixed(1), + 'row-model-call-rate', + ], + [ + 'Core row model avg / max', + `${ms(metrics.rowModelAverageMs)} / ${ms(metrics.rowModelMaxMs)}`, + 'row-model-duration', + ], + [ + 'Visible rows', + integer.format(metrics.visibleRows), + 'visible-row-count', + ], + [ + 'Worker messages', + integer.format(metrics.workerMessages), + 'worker-messages', + ], + [ + 'Worker-coalesced updates / s', + rate.format(metrics.supersededUpdatesPerSecond), + 'superseded-update-rate', + ], + [ + 'Last samples / updated rows', + `${integer.format(metrics.lastBatchSize)} / ${integer.format(metrics.lastUpdateCount)}`, + '', + ], + [ + 'Commits > 16.7 ms (since reset)', + integer.format(metrics.slowCommits), + '', + ], + [ + 'JS heap (current, GC-sensitive)', + metrics.heapMb === null ? 'N/A' : `${metrics.heapMb.toFixed(1)} MB`, + '', + ], + ] as const + return html`
+

DIAGNOSTICS

+
+ ${repeat( + items, + (item) => item[0], + (item) => + html`
+
${item[0]}
+
${item[1]}
+
`, + )} +
+
` + } +} diff --git a/examples/lit/realtime-trading/src/shell/MarketStatusbar.ts b/examples/lit/realtime-trading/src/shell/MarketStatusbar.ts new file mode 100644 index 0000000000..8c6a569c09 --- /dev/null +++ b/examples/lit/realtime-trading/src/shell/MarketStatusbar.ts @@ -0,0 +1,29 @@ +import { html } from 'lit' +import { customElement, property } from 'lit/decorators.js' +import { ControllerElement } from './controller-element' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +const integer = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }) +@customElement('trading-market-statusbar') +export class MarketStatusbar extends ControllerElement { + @property({ attribute: false }) controller!: TradingBenchmarkController + protected firstUpdated() { + this.observe(this.controller.store) + } + protected render() { + const state = this.controller.store.get() + return html`
+ MESSAGE SAMPLES + ${integer.format(state.metrics.lastBatchSize)}CHANGED ROWS + ${integer.format(state.metrics.lastUpdateCount)}HOSTS ${integer.format(state.mountedCells)}COMPONENTS + ${integer.format(state.liveComponents)} +
` + } +} diff --git a/examples/lit/realtime-trading/src/shell/MetricsStrip.ts b/examples/lit/realtime-trading/src/shell/MetricsStrip.ts new file mode 100644 index 0000000000..6dcb4bb849 --- /dev/null +++ b/examples/lit/realtime-trading/src/shell/MetricsStrip.ts @@ -0,0 +1,65 @@ +import { html } from 'lit' +import { customElement, property } from 'lit/decorators.js' +import { repeat } from 'lit/directives/repeat.js' +import { ControllerElement } from './controller-element' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +const rate = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const ms = (value: number) => `${value.toFixed(2)} ms` +@customElement('trading-metrics-strip') +export class MetricsStrip extends ControllerElement { + @property({ attribute: false }) controller!: TradingBenchmarkController + protected firstUpdated() { + this.observe(this.controller.store) + } + protected render() { + const state = this.controller.store.get() + const metrics = state.metrics + const items = [ + [ + 'FRAME RATE (EST.)', + metrics.rafCallbacksPerSecond.toFixed(1), + 'rAF callbacks/s · rolling 1 s', + 'frame-rate', + ], + [ + 'AVG COMMIT', + ms(metrics.averageCommitLatencyMs), + 'snapshot → DOM · rolling 3 s', + 'average-commit-latency', + ], + [ + 'LONG FRAMES', + state.longAnimationFramesSupported + ? String(metrics.longAnimationFrames) + : 'N/A', + state.longAnimationFramesSupported + ? `since reset · worst ${ms(metrics.worstLongAnimationFrameMs)}` + : 'unsupported', + 'long-frame-count', + ], + [ + 'THROUGHPUT', + `${rate.format(metrics.rowUpdatesPerSecond)} rows/s`, + `${metrics.stateApplicationsPerSecond.toFixed(1)} snapshots/s · rows deduplicated per snapshot`, + 'throughput-rate', + ], + ] as const + return html`
+

LIVE HEALTH

+ ${repeat( + items, + (item) => item[0], + (item) => + html`
+ ${item[0]}${item[1]}${item[2]} +
`, + )} +
` + } +} diff --git a/examples/lit/realtime-trading/src/shell/SelectedInstrument.ts b/examples/lit/realtime-trading/src/shell/SelectedInstrument.ts new file mode 100644 index 0000000000..4676a16fe5 --- /dev/null +++ b/examples/lit/realtime-trading/src/shell/SelectedInstrument.ts @@ -0,0 +1,50 @@ +import { html } from 'lit' +import { customElement, property } from 'lit/decorators.js' +import { ControllerElement } from './controller-element' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +@customElement('trading-selected-instrument') +export class SelectedInstrument extends ControllerElement { + @property({ attribute: false }) controller!: TradingBenchmarkController + @property({ attribute: false }) feed!: MarketFeedController + protected firstUpdated() { + this.observe(this.controller.renderAtoms.selectedSymbol) + this.observe(this.feed.quotes) + } + protected render() { + const quote = this.feed.getQuoteBySymbol( + this.feed.quotes.get(), + this.controller.renderAtoms.selectedSymbol.get(), + ) + return html`
+

SELECTED INSTRUMENT

+ ${ + quote + ? html`
+
+ ${quote.symbol}${quote.company} +
+ ${quote.venue} +
+
+
+
Last
+
${quote.price.toFixed(2)}
+
+
+
Bid / ask
+
${quote.bid.toFixed(2)} / ${quote.ask.toFixed(2)}
+
+
` + : html`

+ Click or begin a cell selection in any row to inspect its + instrument. +

` + } +
` + } +} diff --git a/examples/lit/realtime-trading/src/shell/TradingShell.ts b/examples/lit/realtime-trading/src/shell/TradingShell.ts new file mode 100644 index 0000000000..dc34079d74 --- /dev/null +++ b/examples/lit/realtime-trading/src/shell/TradingShell.ts @@ -0,0 +1,44 @@ +import { html } from 'lit' +import { customElement, property, state } from 'lit/decorators.js' +import { ControllerElement } from './controller-element' +import './AppHeader' +import './Configurator' +import './MarketStatusbar' +import '../table/TradingTable' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +@customElement('trading-shell') +export class TradingShell extends ControllerElement { + @property({ attribute: false }) controller!: TradingBenchmarkController + @property({ attribute: false }) feed!: MarketFeedController + @state() private sidebarOpen = true + protected render() { + return html`
+
+ { + this.sidebarOpen = !this.sidebarOpen + }} + >${import.meta.env.DEV ? html`` : null} +
+
+ +
+ + +
` + } +} diff --git a/examples/lit/realtime-trading/src/shell/configurator-options.ts b/examples/lit/realtime-trading/src/shell/configurator-options.ts new file mode 100644 index 0000000000..49a9566fe7 --- /dev/null +++ b/examples/lit/realtime-trading/src/shell/configurator-options.ts @@ -0,0 +1,55 @@ +export interface ConfiguratorOption { + readonly label: string + readonly value: TValue +} + +const instrumentCountOptions = [ + { label: '50', value: 50 }, + { label: '100', value: 100 }, + { label: '150', value: 150 }, + { label: '250', value: 250 }, + { label: '350', value: 350 }, + { label: '500', value: 500 }, + { label: '750', value: 750 }, + { label: '1,000', value: 1_000 }, + { label: '1,500', value: 1_500 }, + { label: '2,500', value: 2_500 }, + { label: '5,000', value: 5_000 }, + { label: '1,000,000', value: 1_000_000 }, + { label: '10,000,000', value: 10_000_000 }, +] as const satisfies ReadonlyArray> + +const workerDeliveryOptions = [ + { label: '8 ms · 125 msg/s', value: 8 }, + { label: '16 ms · 62.5 msg/s', value: 16 }, + { label: '20 ms · 50 msg/s', value: 20 }, + { label: '33 ms · 30 msg/s', value: 33 }, + { label: '50 ms · 20 msg/s', value: 50 }, + { label: '100 ms · 10 msg/s', value: 100 }, + { label: '250 ms · 4 msg/s', value: 250 }, + { label: '500 ms · 2 msg/s', value: 500 }, + { label: '1,000 ms · 1 msg/s', value: 1_000 }, +] as const satisfies ReadonlyArray> + +const rowRenderingOptions = [ + { label: 'Full DOM · render every row', value: 'none' }, + { label: 'TanStack Virtual · visible rows only', value: 'tanstack' }, +] as const satisfies ReadonlyArray> + +const intradaySamplingOptions = [ + { label: '16 ms · fastest', value: 16 }, + { label: '33 ms · very fast', value: 33 }, + { label: '50 ms · fast', value: 50 }, + { label: '100 ms', value: 100 }, + { label: '250 ms', value: 250 }, + { label: '500 ms', value: 500 }, + { label: '1,000 ms', value: 1_000 }, + { label: '2,000 ms', value: 2_000 }, +] as const satisfies ReadonlyArray> + +export const configuratorOptions = { + instrumentCounts: instrumentCountOptions, + workerDeliveryIntervals: workerDeliveryOptions, + rowRenderingModes: rowRenderingOptions, + intradaySamplingIntervals: intradaySamplingOptions, +} as const diff --git a/examples/lit/realtime-trading/src/shell/controller-element.ts b/examples/lit/realtime-trading/src/shell/controller-element.ts new file mode 100644 index 0000000000..01ca122f3c --- /dev/null +++ b/examples/lit/realtime-trading/src/shell/controller-element.ts @@ -0,0 +1,19 @@ +import { LitElement } from 'lit' +import type { Subscription } from '@tanstack/store' + +export abstract class ControllerElement extends LitElement { + readonly #subscriptions: Array = [] + protected createRenderRoot() { + return this + } + protected observe(source: { + subscribe: (listener: () => void) => Subscription + }): void { + this.#subscriptions.push(source.subscribe(() => this.requestUpdate())) + } + disconnectedCallback() { + for (const subscription of this.#subscriptions) subscription.unsubscribe() + this.#subscriptions.length = 0 + super.disconnectedCallback() + } +} diff --git a/examples/lit/realtime-trading/src/table/TradingTable.ts b/examples/lit/realtime-trading/src/table/TradingTable.ts new file mode 100644 index 0000000000..d7c5e01390 --- /dev/null +++ b/examples/lit/realtime-trading/src/table/TradingTable.ts @@ -0,0 +1,394 @@ +import { html } from 'lit' +import { customElement, property } from 'lit/decorators.js' +import { repeat } from 'lit/directives/repeat.js' +import { createRef, ref } from 'lit/directives/ref.js' +import { VirtualizerController } from '@tanstack/lit-virtual' +import { FlexRender, TableController } from '@tanstack/lit-table' +import { startTableBenchmark } from '../benchmark/table-benchmark' +import { ControllerElement } from '../shell/controller-element' +import { + createTradingColumns, + readMeasuredRows, +} from './table-config/trading-columns' +import { tradingFeatures } from './trading-features' +import { + TradingGridPointerController, + handleCellNavigation, + reorderColumnIds, + sortAriaValue, + sortIndicator, +} from './table-interactions' +import { + TRADING_ROW_HEIGHT, + TRADING_ROW_OVERSCAN, + resolveVirtualScrollMode, +} from './trading-row-virtualizer' +import './table-config/quote-cells' +import type { Ref } from 'lit/directives/ref.js' +import type { LitTable } from '@tanstack/lit-table' +import type { MarketQuote } from '../feed/market-data' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +interface SelectedTableState { + sorting: unknown + columnFilters: unknown + columnOrder: unknown + rowSelection: unknown + cellSelection: unknown +} +type TradingTableInstance = LitTable< + typeof tradingFeatures, + MarketQuote, + SelectedTableState +> + +@customElement('trading-data-table') +export class TradingTable extends ControllerElement { + @property({ attribute: false }) controller!: TradingBenchmarkController + @property({ attribute: false }) feed!: MarketFeedController + readonly #tableController = new TableController< + typeof tradingFeatures, + MarketQuote + >(this) + readonly #scrollRef: Ref = createRef() + readonly #tableRef: Ref = createRef() + readonly #virtualizer = new VirtualizerController< + HTMLDivElement, + HTMLTableRowElement + >(this, { + count: 0, + getScrollElement: () => this.#scrollRef.value ?? null, + estimateSize: () => TRADING_ROW_HEIGHT, + overscan: TRADING_ROW_OVERSCAN, + }) + readonly #pointer = new TradingGridPointerController() + readonly #drag = { + columnId: null as string | null, + source: null as HTMLTableCellElement | null, + target: null as HTMLTableCellElement | null, + } + readonly #layout = { manuallyResized: false } + #table?: TradingTableInstance + #columns?: ReturnType + #cleanup: Array<() => void> = [] + #domCommitScheduled = false + + protected firstUpdated() { + this.observe(this.feed.quotes) + this.observe(this.feed.instrumentCount) + this.observe(this.controller.store) + this.observe(this.controller.renderAtoms.rendererMode) + this.observe(this.controller.renderAtoms.selectedSymbol) + const table = this.#table + if (!table) return + const sizing = table.atoms.columnSizing.subscribe(() => + this.#writeColumnSizes(), + ) + const order = table.atoms.columnOrder.subscribe(() => + this.#writeColumnSizes(), + ) + const resizing = table.atoms.columnResizing.subscribe((state) => { + if (state.isResizingColumn !== false) this.#layout.manuallyResized = true + }) + const resizeObserver = new ResizeObserver(() => this.#fitAvailableWidth()) + if (this.#scrollRef.value) resizeObserver.observe(this.#scrollRef.value) + this.#cleanup.push( + () => sizing.unsubscribe(), + () => order.unsubscribe(), + () => resizing.unsubscribe(), + () => resizeObserver.disconnect(), + startTableBenchmark(this.controller), + ) + this.#writeColumnSizes() + this.#fitAvailableWidth() + this.#scheduleDomCommit() + } + protected updated() { + this.#writeColumnSizes() + this.#scheduleDomCommit() + } + disconnectedCallback() { + for (const cleanup of this.#cleanup) cleanup() + this.#cleanup.length = 0 + super.disconnectedCallback() + } + + #writeColumnSizes() { + const element = this.#tableRef.value + const table = this.#table + if (!element || !table) return + for (const header of table.getFlatHeaders()) { + element.style.setProperty( + `--header-${header.id}-size`, + String(header.getSize()), + ) + element.style.setProperty( + `--col-${header.column.id}-size`, + String(header.column.getSize()), + ) + } + element.style.width = `${table.getTotalSize()}px` + } + + #scheduleDomCommit() { + if (this.#domCommitScheduled) return + + this.#domCommitScheduled = true + queueMicrotask(() => { + this.#domCommitScheduled = false + if (this.isConnected) this.feed.completeRender() + }) + } + #fitAvailableWidth() { + const container = this.#scrollRef.value + const table = this.#table + if (!container || !table || this.#layout.manuallyResized) return + const width = table.getTotalSize() + if (container.clientWidth <= width + 1 || width <= 0) return + const ratio = container.clientWidth / width + table.setColumnSizing( + Object.fromEntries( + table + .getVisibleLeafColumns() + .map((column) => [column.id, column.getSize() * ratio]), + ), + ) + } + #clearDrag = () => { + this.#drag.source?.classList.remove('is-column-dragging') + this.#drag.target?.classList.remove('is-column-drop-target') + this.#drag.columnId = null + this.#drag.source = null + this.#drag.target = null + } + #showDrop(columnId: string, element: HTMLTableCellElement | null) { + this.#drag.target?.classList.remove('is-column-drop-target') + this.#drag.target = null + if (this.#drag.columnId === columnId || !element) return + element.classList.add('is-column-drop-target') + this.#drag.target = element + } + + protected render() { + this.#columns ??= createTradingColumns(this.controller) + const table = this.#tableController.table( + { + key: 'lit-realtime-trading', + features: tradingFeatures, + columns: this.#columns, + data: this.feed.quotes.get(), + getRowId: (row) => row.id, + columnResizeMode: 'onChange', + defaultColumn: { minSize: 56, maxSize: 800 }, + autoResetCellSelection: false, + }, + (state) => ({ + sorting: state.sorting, + columnFilters: state.columnFilters, + columnOrder: state.columnOrder, + rowSelection: state.rowSelection, + cellSelection: state.cellSelection, + }), + ) + this.#table = table + const rows = readMeasuredRows(() => table.getRowModel().rows) + const benchmark = this.controller.store.get() + const virtualMode = resolveVirtualScrollMode( + benchmark.requestedVirtualScrollMode, + this.feed.instrumentCount.get(), + ) + const virtualizer = this.#virtualizer.getVirtualizer() + virtualizer.setOptions({ + ...virtualizer.options, + count: rows.length, + enabled: virtualMode === 'tanstack', + getItemKey: (index) => rows[index]?.id ?? index, + }) + virtualizer._willUpdate() + const virtualRows = virtualizer.getVirtualItems() + this.controller.actions.setRenderedRowCount( + virtualMode === 'tanstack' ? virtualRows.length : rows.length, + ) + const range = virtualizer.range + const visibleRange = + virtualMode === 'tanstack' && range && rows.length + ? { + start: Math.min(range.startIndex, rows.length - 1), + end: Math.min(range.endIndex, rows.length - 1), + } + : null + const renderRow = ( + row: (typeof rows)[number], + virtualRow?: (typeof virtualRows)[number], + ) => + html`
+ ${repeat( + row.getVisibleCells(), + (cell) => cell.id, + (cell) => { + const edges = cell.getSelectionEdges() + return html`` + }, + )} + ` + return html`
+
+ ${FlexRender({ cell })} +
handleCellNavigation(table, event)} + > + + ${repeat( + table.getHeaderGroups(), + (group) => group.id, + (group) => + html` + ${repeat( + group.headers, + (header) => header.id, + (header) => { + const leaf = header.subHeaders.length === 0 + const sorted = header.column.getIsSorted() + return html`` + }, + )} + `, + )} + + this.#pointer.handleMouseDown(table, event, this.controller.actions.selectSymbol)} + @pointerover=${(event: MouseEvent) => this.#pointer.handlePointerOver(table, event)} + @mouseleave=${() => this.#pointer.resetPointerCell()} + @click=${(event: MouseEvent) => this.#pointer.handleClick(table, event)} + > + ${ + virtualMode === 'tanstack' + ? repeat( + virtualRows, + (item) => item.key, + (item) => renderRow(rows[item.index], item), + ) + : repeat( + rows, + (row) => row.id, + (row) => renderRow(row), + ) + } + +
+ ${ + !header.isPlaceholder + ? leaf + ? html`
{ + event.preventDefault() + this.#showDrop( + header.column.id, + ( + event.currentTarget as HTMLElement + ).closest('th'), + ) + }} + @drop=${(event: DragEvent) => { + event.preventDefault() + const source = + event.dataTransfer?.getData( + 'text/plain', + ) || this.#drag.columnId + if (source) + table.setColumnOrder( + reorderColumnIds( + table + .getVisibleLeafColumns() + .map((column) => column.id), + source, + header.column.id, + ), + ) + this.#clearDrag() + }} + > + +
+ ${header.column.getCanResize() ? html`` : null}` + : FlexRender({ header }) + : null + } +
+
+ ${virtualMode === 'tanstack' ? html`
TanStack · Total · ${rows.length} rows · ${table.getVisibleLeafColumns().length} columns${visibleRange ? `Current · rows ${visibleRange.start}..${visibleRange.end}` : 'Current · rows —'}
` : null}` + } +} diff --git a/examples/lit/realtime-trading/src/table/table-config/quote-cells.ts b/examples/lit/realtime-trading/src/table/table-config/quote-cells.ts new file mode 100644 index 0000000000..e10aa97938 --- /dev/null +++ b/examples/lit/realtime-trading/src/table/table-config/quote-cells.ts @@ -0,0 +1,149 @@ +import { LitElement, html, svg } from 'lit' +import { customElement, property } from 'lit/decorators.js' + +export const quoteCellLifecycle = { created: 0, destroyed: 0 } +export const quoteCellRendererNames = [ + 'Market', + 'Name', + 'Symbol', + 'Last', + 'Change', + 'ChangePercent', + 'Bid', + 'BidVolume', + 'Ask', + 'AskVolume', + 'Open', + 'High', + 'Low', + 'Intraday', +] as const +export const quoteComponentNames = [ + 'PriceCell', + 'StableMoveCell', + 'UpMoveCell', + 'DownMoveCell', + 'PercentChangeCell', + 'SparklineCell', +] as const +export type QuoteCellRendererName = (typeof quoteCellRendererNames)[number] +export type QuoteComponentName = (typeof quoteComponentNames)[number] +const counters = (names: ReadonlyArray) => + Object.fromEntries(names.map((name) => [name, 0])) as Record +export const quoteRenderDiagnostics = { + cellRendererCalls: 0, + componentRenderCalls: 0, + cellRendererCallsByName: counters(quoteCellRendererNames), + componentRenderCallsByName: counters(quoteComponentNames), +} +export function recordCellRender(name: QuoteCellRendererName, value: T): T { + quoteRenderDiagnostics.cellRendererCalls++ + quoteRenderDiagnostics.cellRendererCallsByName[name]++ + return value +} +const signed = (value: number) => `${value >= 0 ? '+' : ''}${value.toFixed(2)}` + +abstract class QuoteElement extends LitElement { + protected abstract readonly componentName: QuoteComponentName + protected createRenderRoot() { + return this + } + connectedCallback() { + super.connectedCallback() + quoteCellLifecycle.created++ + } + disconnectedCallback() { + quoteCellLifecycle.destroyed++ + super.disconnectedCallback() + } + protected recordRender() { + quoteRenderDiagnostics.componentRenderCalls++ + quoteRenderDiagnostics.componentRenderCallsByName[this.componentName]++ + } +} + +@customElement('quote-price-cell') +export class PriceCell extends QuoteElement { + protected readonly componentName = 'PriceCell' + @property({ type: Number }) price = 0 + @property({ type: Number }) move = 0 + @property({ attribute: false }) select: () => void = () => undefined + protected render() { + this.recordRender() + return html`` + } +} + +abstract class MoveCell extends QuoteElement { + @property({ type: Number }) move = 0 + protected direction: 'up' | 'down' | null = null + protected indicator = '' + protected render() { + this.recordRender() + const direction = this.direction ?? (this.move >= 0 ? 'up' : 'down') + return html`${this.indicator}${signed(this.move)}` + } +} +@customElement('quote-stable-move') +export class StableMoveCell extends MoveCell { + protected readonly componentName = 'StableMoveCell' +} +@customElement('quote-up-move') +export class UpMoveCell extends MoveCell { + protected readonly componentName = 'UpMoveCell' + protected direction = 'up' as const + protected indicator = '▲ ' +} +@customElement('quote-down-move') +export class DownMoveCell extends MoveCell { + protected readonly componentName = 'DownMoveCell' + protected direction = 'down' as const + protected indicator = '▼ ' +} + +@customElement('quote-percent-change') +export class PercentChangeCell extends QuoteElement { + protected readonly componentName = 'PercentChangeCell' + @property({ type: Number }) value = 0 + protected render() { + this.recordRender() + return html`${signed(this.value)}%` + } +} + +@customElement('quote-sparkline') +export class SparklineCell extends QuoteElement { + protected readonly componentName = 'SparklineCell' + @property({ attribute: false }) values: ReadonlyArray = [] + protected render() { + this.recordRender() + const first = this.values[0] ?? 0 + const range = this.values.reduce( + (current, value) => ({ + min: Math.min(current.min, value), + max: Math.max(current.max, value), + }), + { min: first, max: first }, + ) + const height = range.max - range.min || 1 + const denominator = Math.max(1, this.values.length - 1) + const points = this.values + .map( + (value, index) => + `${((index / denominator) * 100).toFixed(1)},${(22 - ((value - range.min) / height) * 20).toFixed(1)}`, + ) + .join(' ') + const rising = (this.values.at(-1) ?? 0) >= first + return svg`` + } +} diff --git a/examples/lit/realtime-trading/src/table/table-config/trading-columns.ts b/examples/lit/realtime-trading/src/table/table-config/trading-columns.ts new file mode 100644 index 0000000000..93d52876d3 --- /dev/null +++ b/examples/lit/realtime-trading/src/table/table-config/trading-columns.ts @@ -0,0 +1,212 @@ +import { html } from 'lit' +import { createColumnHelper } from '@tanstack/lit-table' +import { tradingFeatures } from '../trading-features' +import { recordCellRender } from './quote-cells' +import type { MarketQuote } from '../../feed/market-data' +import type { TradingBenchmarkController } from '../../benchmark/trading-benchmark-controller' + +export type RendererMode = 'stable' | 'swap' +export interface CoreTableState { + sorting: Array<{ id: string; desc: boolean }> + columnFilters: Array<{ id: string; value: unknown }> +} +const compact = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const columnHelper = createColumnHelper() + +export function createTradingColumns(controller: TradingBenchmarkController) { + return columnHelper.columns([ + columnHelper.group({ + id: 'instrument', + header: 'Instrument', + columns: columnHelper.columns([ + columnHelper.accessor('venue', { + id: 'market', + header: 'Market', + size: 72, + cell: (info) => recordCellRender('Market', info.getValue()), + }), + columnHelper.accessor('company', { + id: 'name', + header: 'Name', + size: 180, + cell: (info) => recordCellRender('Name', info.getValue()), + }), + columnHelper.accessor('symbol', { + header: 'Symbol', + size: 92, + filterFn: 'includesString', + cell: (info) => recordCellRender('Symbol', info.getValue()), + }), + ]), + }), + columnHelper.group({ + id: 'priceAndChange', + header: 'Price & Change', + columns: columnHelper.columns([ + columnHelper.accessor('price', { + header: 'Price', + size: 96, + sortFn: 'basic', + cell: (info) => + recordCellRender( + 'Last', + html` + controller.actions.selectSymbol(info.row.original.symbol)} + >`, + ), + }), + columnHelper.accessor(getDayChange, { + id: 'change', + header: 'Chg', + size: 94, + cell: (info) => + recordCellRender( + 'Change', + renderMove( + controller.renderAtoms.rendererMode.get(), + info.getValue(), + ), + ), + }), + columnHelper.accessor(getDayChangePercent, { + id: 'changePercent', + header: 'Chg%', + size: 90, + cell: (info) => + recordCellRender( + 'ChangePercent', + html``, + ), + }), + ]), + }), + columnHelper.group({ + id: 'orderBook', + header: 'Order Book', + columns: columnHelper.columns([ + columnHelper.accessor('bid', { + header: 'Bid', + size: 90, + cell: (info) => recordCellRender('Bid', info.getValue().toFixed(2)), + }), + columnHelper.accessor('bidSize', { + header: 'Bid Vol', + size: 100, + cell: (info) => + recordCellRender('BidVolume', compact.format(info.getValue())), + }), + columnHelper.accessor('ask', { + header: 'Ask', + size: 90, + cell: (info) => recordCellRender('Ask', info.getValue().toFixed(2)), + }), + columnHelper.accessor('askSize', { + header: 'Ask Vol', + size: 100, + cell: (info) => + recordCellRender('AskVolume', compact.format(info.getValue())), + }), + ]), + }), + columnHelper.group({ + id: 'session', + header: 'Session', + columns: columnHelper.columns([ + columnHelper.accessor('open', { + header: 'Open', + size: 90, + cell: (info) => recordCellRender('Open', info.getValue().toFixed(2)), + }), + columnHelper.accessor('high', { + header: 'High', + size: 90, + cell: (info) => recordCellRender('High', info.getValue().toFixed(2)), + }), + columnHelper.accessor('low', { + header: 'Low', + size: 90, + cell: (info) => recordCellRender('Low', info.getValue().toFixed(2)), + }), + ]), + }), + columnHelper.group({ + id: 'chart', + header: 'Chart', + columns: columnHelper.columns([ + columnHelper.accessor('history', { + header: 'Intraday', + size: 150, + enableSorting: false, + cell: (info) => + recordCellRender( + 'Intraday', + html``, + ), + }), + ]), + }), + ]) +} + +function renderMove(mode: RendererMode, move: number) { + if (mode === 'stable') + return html`` + return move >= 0 + ? html`` + : html`` +} + +export const rowModelDiagnostics = { + hasMeasurement: false, + calls: 0, + totalDurationMs: 0, + maxDurationMs: 0, + lastRowCount: 0, +} +export const TRADING_COLUMN_COUNT = 14 +export function readMeasuredRows(readRows: () => Array): Array { + const start = performance.now() + const rows = readRows() + const end = performance.now() + const duration = end - start + rowModelDiagnostics.calls++ + rowModelDiagnostics.hasMeasurement = true + rowModelDiagnostics.totalDurationMs += duration + rowModelDiagnostics.maxDurationMs = Math.max( + rowModelDiagnostics.maxDurationMs, + duration, + ) + rowModelDiagnostics.lastRowCount = rows.length + if (rowModelDiagnostics.calls % 20 === 0) { + try { + performance.measure('tanstack-row-model', { + start, + end, + detail: { rowCount: rows.length }, + }) + if (rowModelDiagnostics.calls % 1_000 === 0) + performance.clearMeasures('tanstack-row-model') + } catch { + /* optional sampled User Timing detail */ + } + } + return rows +} +export function getDayChange(quote: MarketQuote): number { + return quote.price - quote.previousClose +} +export function getDayChangePercent(quote: MarketQuote): number { + return quote.previousClose === 0 + ? 0 + : (getDayChange(quote) / quote.previousClose) * 100 +} diff --git a/examples/lit/realtime-trading/src/table/table-interactions.ts b/examples/lit/realtime-trading/src/table/table-interactions.ts new file mode 100644 index 0000000000..99649a40bd --- /dev/null +++ b/examples/lit/realtime-trading/src/table/table-interactions.ts @@ -0,0 +1,187 @@ +export type CellDirection = 'up' | 'down' | 'left' | 'right' + +interface RowSelectionTable { + resetRowSelection: (defaultState?: boolean) => void +} + +interface SelectableRow { + getIsSelected: () => boolean + getToggleSelectedHandler: (options?: { + selectChildren?: boolean + }) => (event: unknown) => void +} + +interface SelectableGridCell { + row: SelectableGridRow + getSelectionStartHandler: ( + contextDocument?: Document, + ) => (event: unknown) => void + getSelectionExtendHandler: () => (event: unknown) => void +} + +interface SelectableGridRow extends SelectableRow { + original: { symbol: string } + getAllCellsByColumnId: () => Record +} + +interface TradingGridTable extends RowSelectionTable { + getRowModel: () => { + rowsById: Record + } +} + +interface SelectionCellTarget { + element: HTMLTableCellElement + cell: SelectableGridCell +} + +interface CellNavigationTable { + extendCellSelection: (direction: CellDirection) => void + moveCellSelection: (direction: CellDirection) => void + resetCellSelection: (defaultState?: boolean) => void + selectAllCells: () => void +} + +const keyDirections: Partial> = { + ArrowUp: 'up', + ArrowDown: 'down', + ArrowLeft: 'left', + ArrowRight: 'right', +} + +export function reorderColumnIds( + columnIds: Array, + sourceId: string, + targetId: string, +): Array { + if (sourceId === targetId || !columnIds.includes(sourceId)) return columnIds + + const withoutSource = columnIds.filter((id) => id !== sourceId) + const targetIndex = withoutSource.indexOf(targetId) + if (targetIndex < 0) return columnIds + + return [ + ...withoutSource.slice(0, targetIndex), + sourceId, + ...withoutSource.slice(targetIndex), + ] +} + +export function selectRowFromPointer( + table: RowSelectionTable, + row: SelectableRow, + event: MouseEvent, +): void { + const additive = event.ctrlKey || event.metaKey + const checked = additive ? !row.getIsSelected() : true + + if (!event.shiftKey && !additive) table.resetRowSelection(true) + + row.getToggleSelectedHandler({ selectChildren: false })({ + target: { checked }, + shiftKey: event.shiftKey, + ctrlKey: event.ctrlKey, + metaKey: event.metaKey, + }) +} + +export class TradingGridPointerController { + #lastPointerCell: HTMLTableCellElement | null = null + + handleMouseDown( + table: TradingGridTable, + event: MouseEvent, + selectSymbol: (symbol: string) => void, + ): void { + if (event.button !== 0) return + + const target = this.#findCellTarget(table, event.composedPath()) + if (!target) return + + event.preventDefault() + this.#lastPointerCell = target.element + selectSymbol(target.cell.row.original.symbol) + target.cell.getSelectionStartHandler(target.element.ownerDocument)(event) + } + + handlePointerOver(table: TradingGridTable, event: MouseEvent): void { + if ((event.buttons & 1) === 0) { + this.resetPointerCell() + return + } + + const target = this.#findCellTarget(table, event.composedPath()) + if (!target || target.element === this.#lastPointerCell) return + + this.#lastPointerCell = target.element + target.cell.getSelectionExtendHandler()(event) + } + + handleClick(table: TradingGridTable, event: MouseEvent): void { + const target = this.#findCellTarget(table, event.composedPath()) + if (!target) return + selectRowFromPointer(table, target.cell.row, event) + } + + resetPointerCell(): void { + this.#lastPointerCell = null + } + + #findCellTarget( + table: TradingGridTable, + path: Array, + ): SelectionCellTarget | null { + for (const target of path) { + if (!(target instanceof HTMLTableCellElement)) continue + + const columnId = target.dataset['columnId'] + const rowId = + target.closest('tr[data-row-id]')?.dataset['rowId'] + if (!columnId || !rowId) return null + + const row = table.getRowModel().rowsById[rowId] + const cell = row.getAllCellsByColumnId()[columnId] + return { element: target, cell } + } + + return null + } +} + +export function handleCellNavigation( + table: CellNavigationTable, + event: KeyboardEvent, +): void { + if (event.key === 'Escape') { + event.preventDefault() + table.resetCellSelection(true) + return + } + + if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a') { + event.preventDefault() + table.selectAllCells() + return + } + + const direction = keyDirections[event.key] + if (!direction) return + + event.preventDefault() + if (event.shiftKey) table.extendCellSelection(direction) + else table.moveCellSelection(direction) +} + +export function sortIndicator(direction: false | 'asc' | 'desc'): string { + if (direction === 'asc') return '↑' + if (direction === 'desc') return '↓' + return '↕' +} + +export function sortAriaValue( + direction: false | 'asc' | 'desc', +): 'ascending' | 'descending' | 'none' { + if (direction === 'asc') return 'ascending' + if (direction === 'desc') return 'descending' + return 'none' +} diff --git a/examples/lit/realtime-trading/src/table/trading-features.ts b/examples/lit/realtime-trading/src/table/trading-features.ts new file mode 100644 index 0000000000..790e9a816b --- /dev/null +++ b/examples/lit/realtime-trading/src/table/trading-features.ts @@ -0,0 +1,16 @@ +import { + createFilteredRowModel, + createSortedRowModel, + filterFn_includesString, + sortFn_basic, + stockFeatures, + tableFeatures, +} from '@tanstack/lit-table' + +export const tradingFeatures = tableFeatures({ + ...stockFeatures, + filteredRowModel: createFilteredRowModel(), + sortedRowModel: createSortedRowModel(), + filterFns: { includesString: filterFn_includesString }, + sortFns: { basic: sortFn_basic }, +}) diff --git a/examples/lit/realtime-trading/src/table/trading-row-virtualizer.ts b/examples/lit/realtime-trading/src/table/trading-row-virtualizer.ts new file mode 100644 index 0000000000..bc4b34b528 --- /dev/null +++ b/examples/lit/realtime-trading/src/table/trading-row-virtualizer.ts @@ -0,0 +1,18 @@ +export const TRADING_ROW_HEIGHT = 32 +export const TRADING_ROW_OVERSCAN = 10 +export const DEFAULT_VIRTUALIZATION_ROW_COUNT = 200 +export const FORCED_VIRTUALIZATION_ROW_COUNT = 1_500 + +export type VirtualScrollMode = 'tanstack' | 'none' +export type VirtualScrollPreference = VirtualScrollMode | 'auto' + +export function resolveVirtualScrollMode( + requestedMode: VirtualScrollPreference, + instrumentCount: number, +): VirtualScrollMode { + if (instrumentCount >= FORCED_VIRTUALIZATION_ROW_COUNT) return 'tanstack' + if (requestedMode !== 'auto') return requestedMode + return instrumentCount >= DEFAULT_VIRTUALIZATION_ROW_COUNT + ? 'tanstack' + : 'none' +} diff --git a/examples/lit/realtime-trading/src/table/trading-table.ts b/examples/lit/realtime-trading/src/table/trading-table.ts new file mode 100644 index 0000000000..77e4e6bee1 --- /dev/null +++ b/examples/lit/realtime-trading/src/table/trading-table.ts @@ -0,0 +1,9 @@ +export { + TRADING_COLUMN_COUNT, + rowModelDiagnostics, +} from './table-config/trading-columns' +export type { + CoreTableState, + RendererMode, +} from './table-config/trading-columns' +export type { VirtualScrollMode } from './trading-row-virtualizer' diff --git a/examples/lit/realtime-trading/src/vite-env.d.ts b/examples/lit/realtime-trading/src/vite-env.d.ts new file mode 100644 index 0000000000..11f02fe2a0 --- /dev/null +++ b/examples/lit/realtime-trading/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/lit/realtime-trading/tests/e2e/smoke.spec.ts b/examples/lit/realtime-trading/tests/e2e/smoke.spec.ts new file mode 100644 index 0000000000..0a7646360f --- /dev/null +++ b/examples/lit/realtime-trading/tests/e2e/smoke.spec.ts @@ -0,0 +1,181 @@ +import path from 'node:path' +import { expect, test } from '@playwright/test' +import { startExampleServer } from '../../../../../tests/e2e/helpers/startExampleServer' +import { + setRangeValue, + scrollTradingTable, + pauseTradingFeed, + resumeTradingFeed, + pausedFeedUrl, +} from '../../../../../tests/e2e/helpers/setRangeValue' +import type { Page } from '@playwright/test' + +const exampleDir = path.resolve() + +function collectPageErrors(page: Page) { + const errors: Array = [] + page.on('pageerror', (error) => errors.push(error.message)) + page.on('console', (message) => { + if (message.type() === 'error') errors.push(message.text()) + }) + return errors +} + +test('runs the Lit realtime trading workload', async ({ page }) => { + const server = await startExampleServer(exampleDir) + const errors = collectPageErrors(page) + + try { + await page.goto(pausedFeedUrl(server.url)) + + const table = page.getByTestId('trading-table') + const instrumentCount = page.getByTestId('instrument-count-select') + const virtualScrollSelect = page.getByTestId('virtual-scroll-select') + await expect(table).toBeVisible() + await expect(instrumentCount).toHaveValue('100') + await expect(page.locator('.brand')).toHaveText('MARKET MONITOR') + await expect(virtualScrollSelect).toHaveValue('none') + await expect(virtualScrollSelect).toBeEnabled() + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(table.locator('tbody')).toHaveCSS('user-select', 'none') + await expect(table.locator('tbody tr').first()).toHaveCSS( + 'content-visibility', + 'auto', + ) + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await instrumentCount.selectOption('250') + await expect(virtualScrollSelect).toHaveValue('tanstack') + await expect(virtualScrollSelect).toBeEnabled() + await expect.poll(() => table.locator('tbody tr').count()).toBeLessThan(250) + await expect(page.getByTestId('virtual-scroll-footer')).toBeVisible() + await instrumentCount.selectOption('100') + await expect(virtualScrollSelect).toHaveValue('none') + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await virtualScrollSelect.selectOption('tanstack') + await expect.poll(() => table.locator('tbody tr').count()).toBeLessThan(100) + await expect(table.locator('tbody tr').first()).toHaveCSS( + 'content-visibility', + 'auto', + ) + await expect(page.getByTestId('virtual-scroll-footer')).toBeVisible() + await virtualScrollSelect.selectOption('none') + await expect(table.locator('tbody tr')).toHaveCount(100) + await instrumentCount.selectOption('1500') + await expect(virtualScrollSelect).toHaveValue('tanstack') + await expect(virtualScrollSelect).toBeDisabled() + await expect + .poll(() => table.locator('tbody tr').count()) + .toBeLessThan(1500) + await expect(page.getByTestId('virtual-scroll-footer')).toContainText( + 'Total · 1500 rows · 14 columns', + ) + await expect(page.getByTestId('visible-row-range')).toHaveText( + /^\s*Current · rows 0\.\.\d+\s*$/, + ) + await scrollTradingTable(page, 2_000) + await expect + .poll(async () => + Number( + await table + .locator('tbody tr') + .first() + .getAttribute('data-virtual-index'), + ), + ) + .toBeGreaterThan(0) + await expect(page.getByTestId('visible-row-range')).toHaveText( + /^\s*Current · rows [1-9]\d*\.\.\d+\s*$/, + ) + await instrumentCount.selectOption('100') + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await expect(virtualScrollSelect).toHaveValue('none') + await expect(virtualScrollSelect).toBeEnabled() + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(table.locator('thead tr')).toHaveCount(2) + await expect(table.locator('thead tr').last().locator('th')).toHaveCount(14) + await expect(table.locator('thead')).not.toContainText('Identity') + await expect(table.locator('thead')).not.toContainText('Market Data') + await expect(table.locator('thead')).toContainText('Market') + await expect(table.locator('thead')).toContainText('Bid Vol') + await expect(table.locator('thead')).toContainText('Intraday') + const selectedRow = table.locator('tbody tr').first() + const selectedSymbol = await selectedRow.getAttribute('data-symbol') + await selectedRow.locator('td').nth(1).click() + await expect(page.getByTestId('selected-instrument')).toContainText( + selectedSymbol ?? '', + ) + await expect(page.getByTestId('feed-status')).toHaveText('FEED PAUSED') + await expect(instrumentCount.locator('option[value="150"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="350"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="750"]')).toHaveCount(1) + + const targetRateSlider = page.getByTestId('target-rate-slider') + await expect(targetRateSlider).toHaveAttribute('min', '0') + await expect(targetRateSlider).toHaveAttribute('max', '9') + await expect(targetRateSlider).toHaveAttribute('step', '1') + await expect(targetRateSlider).toHaveValue('6') + await setRangeValue(targetRateSlider, '7') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '25K samples/s', + ) + await setRangeValue(targetRateSlider, '8') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '50K samples/s', + ) + await setRangeValue(targetRateSlider, '6') + + const sparklineInterval = page.getByTestId( + 'sparkline-sample-interval-select', + ) + await expect(sparklineInterval).toHaveValue('16') + await sparklineInterval.selectOption('100') + await expect(sparklineInterval).toHaveValue('100') + await sparklineInterval.selectOption('16') + + const publishInterval = page.getByTestId('publish-interval-select') + await expect(publishInterval.locator('option[value="500"]')).toHaveCount(1) + await expect(publishInterval.locator('option[value="1000"]')).toHaveCount(1) + + // Exercise delivery and rendering without turning this smoke test into a + // throughput benchmark on shared CI runners. Configure controls while paused. + await setRangeValue(targetRateSlider, '0') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '100 samples/s', + ) + await publishInterval.selectOption('500') + await expect(publishInterval).toHaveValue('500') + await sparklineInterval.selectOption('100') + const swapRenderer = page.getByRole('checkbox', { + name: /Swap Tick component/, + }) + await swapRenderer.check() + await expect(swapRenderer).toBeChecked() + + const firstPrice = table.locator('tbody tr').first().getByRole('button') + const priceBeforeUpdate = await firstPrice.textContent() + await resumeTradingFeed(page) + await expect + .poll(() => firstPrice.textContent()) + .not.toBe(priceBeforeUpdate) + + await pauseTradingFeed(page) + + await instrumentCount.selectOption('750') + await expect.poll(() => table.locator('tbody tr').count()).toBeLessThan(750) + + // Delivery is cumulative; instantaneous rates can legitimately fall to + // zero between samples on a busy runner. The price assertion above proves + // that a delivered update reached the rendered table. + await expect + .poll(async () => { + const text = await page.getByTestId('worker-messages').textContent() + return Number(text?.replace(/\D/g, '') ?? 0) + }) + .toBeGreaterThan(0) + + expect(errors).toEqual([]) + } finally { + await server.close() + } +}) diff --git a/examples/lit/realtime-trading/tsconfig.json b/examples/lit/realtime-trading/tsconfig.json new file mode 100644 index 0000000000..91eacfe230 --- /dev/null +++ b/examples/lit/realtime-trading/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ES2022", + "useDefineForClassFields": false, + "module": "ESNext", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "experimentalDecorators": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "types": ["vite/client"] + }, + "include": ["src", "tests/e2e", "vite.config.ts"] +} diff --git a/examples/lit/realtime-trading/vite.config.ts b/examples/lit/realtime-trading/vite.config.ts new file mode 100644 index 0000000000..7af6c0bce8 --- /dev/null +++ b/examples/lit/realtime-trading/vite.config.ts @@ -0,0 +1,2 @@ +import { defineConfig } from 'vite' +export default defineConfig({ server: { port: 7777, allowedHosts: true } }) diff --git a/examples/lit/row-pinning/package.json b/examples/lit/row-pinning/package.json index f63b786f9e..36dc3d8dfb 100644 --- a/examples/lit/row-pinning/package.json +++ b/examples/lit/row-pinning/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/row-selection/package.json b/examples/lit/row-selection/package.json index d2086ae1ab..fc2962f211 100644 --- a/examples/lit/row-selection/package.json +++ b/examples/lit/row-selection/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/sorting-dynamic-data/package.json b/examples/lit/sorting-dynamic-data/package.json index 11d8fb21b7..13f3eda6b1 100644 --- a/examples/lit/sorting-dynamic-data/package.json +++ b/examples/lit/sorting-dynamic-data/package.json @@ -11,13 +11,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/sorting/package.json b/examples/lit/sorting/package.json index 48faebc53a..32fd99ad03 100644 --- a/examples/lit/sorting/package.json +++ b/examples/lit/sorting/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/sub-components/package.json b/examples/lit/sub-components/package.json index 73b68e5c9d..91cb0527d6 100644 --- a/examples/lit/sub-components/package.json +++ b/examples/lit/sub-components/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/virtualized-columns/package.json b/examples/lit/virtualized-columns/package.json index 48e68c2683..88a44ae790 100644 --- a/examples/lit/virtualized-columns/package.json +++ b/examples/lit/virtualized-columns/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", - "@tanstack/lit-virtual": "^3.13.36", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", + "@tanstack/lit-virtual": "^3.15.3", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/virtualized-infinite-scrolling/package.json b/examples/lit/virtualized-infinite-scrolling/package.json index aa7d166c8c..cd8993d354 100644 --- a/examples/lit/virtualized-infinite-scrolling/package.json +++ b/examples/lit/virtualized-infinite-scrolling/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", - "@tanstack/lit-virtual": "^3.13.36", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", + "@tanstack/lit-virtual": "^3.15.3", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/lit/virtualized-rows/package.json b/examples/lit/virtualized-rows/package.json index 4224e0005c..9232aceb86 100644 --- a/examples/lit/virtualized-rows/package.json +++ b/examples/lit/virtualized-rows/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/lit-table": "^9.1.2", - "@tanstack/lit-virtual": "^3.13.36", + "@faker-js/faker": "^10.6.0", + "@tanstack/lit-table": "^9.3.1", + "@tanstack/lit-virtual": "^3.15.3", "lit": "^3.3.3" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/octane/aggregation/package.json b/examples/octane/aggregation/package.json index 1d179b87c0..fb1613d2e2 100644 --- a/examples/octane/aggregation/package.json +++ b/examples/octane/aggregation/package.json @@ -11,14 +11,16 @@ "test:types": "tsrx-tsc --noEmit" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/octane-store": "^0.12.2", - "@tanstack/octane-table": "^9.1.2", - "octane": "0.1.36" + "@faker-js/faker": "^10.6.0", + "@tanstack/octane-store": "^0.13.0", + "@tanstack/octane-table": "^9.3.1", + "octane": "0.17.0" }, "devDependencies": { - "@tsrx/typescript-plugin": "^0.3.118", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@tsrx/oxc": "0.23.0", + "@tsrx/typescript-plugin": "^0.7.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/octane/aggregation/src/main.tsrx b/examples/octane/aggregation/src/main.tsrx index 293ba08e7f..1982915692 100644 --- a/examples/octane/aggregation/src/main.tsrx +++ b/examples/octane/aggregation/src/main.tsrx @@ -218,7 +218,7 @@ function App() @{ {table.getFooterGroups().map((group) => ( {group.headers.map((header) => ( - + {header.isPlaceholder ? null : ( )} diff --git a/examples/octane/basic-dynamic-columns/package.json b/examples/octane/basic-dynamic-columns/package.json index ec583679f5..228b5eb5bf 100644 --- a/examples/octane/basic-dynamic-columns/package.json +++ b/examples/octane/basic-dynamic-columns/package.json @@ -11,13 +11,15 @@ "test:types": "tsrx-tsc --noEmit" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/octane-table": "^9.1.2", - "octane": "0.1.36" + "@faker-js/faker": "^10.6.0", + "@tanstack/octane-table": "^9.3.1", + "octane": "0.17.0" }, "devDependencies": { - "@tsrx/typescript-plugin": "^0.3.118", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@tsrx/oxc": "0.23.0", + "@tsrx/typescript-plugin": "^0.7.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/octane/basic-dynamic-columns/src/main.tsrx b/examples/octane/basic-dynamic-columns/src/main.tsrx index c01f4840fd..0b10aad9b0 100644 --- a/examples/octane/basic-dynamic-columns/src/main.tsrx +++ b/examples/octane/basic-dynamic-columns/src/main.tsrx @@ -191,7 +191,7 @@ function App() @{ @for (const headerGroup of table.getHeaderGroups(); key headerGroup.id) { @for (const header of headerGroup.headers; key header.id) { - + {header.isPlaceholder ? null : <>
@for (const header of headerGroup.headers; key header.id) { - + {header.isPlaceholder ? null :
', exact: true }) - .evaluate((button) => { + .evaluate(async (button) => { const started = performance.now() ;(button as HTMLButtonElement).click() + // Octane commits a click's updates in the next microtask. + await Promise.resolve() return { elapsed: performance.now() - started, status: document.querySelector('.controls strong')?.textContent, @@ -48,9 +50,10 @@ test('updates pagination atom and row model without errors', async ({ const sortTiming = await page .locator('.sortable-header') .first() - .evaluate((header) => { + .evaluate(async (header) => { const started = performance.now() ;(header as HTMLElement).click() + await Promise.resolve() return { elapsed: performance.now() - started, text: header.textContent, diff --git a/examples/octane/basic-external-state/package.json b/examples/octane/basic-external-state/package.json index eb0ab56ff3..8fc2f5945a 100644 --- a/examples/octane/basic-external-state/package.json +++ b/examples/octane/basic-external-state/package.json @@ -11,13 +11,15 @@ "test:types": "tsrx-tsc --noEmit" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/octane-table": "^9.1.2", - "octane": "0.1.36" + "@faker-js/faker": "^10.6.0", + "@tanstack/octane-table": "^9.3.1", + "octane": "0.17.0" }, "devDependencies": { - "@tsrx/typescript-plugin": "^0.3.118", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@tsrx/oxc": "0.23.0", + "@tsrx/typescript-plugin": "^0.7.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/octane/basic-external-state/src/main.tsrx b/examples/octane/basic-external-state/src/main.tsrx index 1a71fc3ffa..5ba290ca20 100644 --- a/examples/octane/basic-external-state/src/main.tsrx +++ b/examples/octane/basic-external-state/src/main.tsrx @@ -93,7 +93,7 @@ function App() @{ @for (const headerGroup of table.getHeaderGroups(); key headerGroup.id) { @for (const header of headerGroup.headers; key header.id) { - + {header.isPlaceholder ? null :
{ + const timing = await next.evaluate(async (button) => { const started = performance.now() ;(button as HTMLButtonElement).click() + // Octane commits a click's updates in the next microtask. + await Promise.resolve() return { elapsed: performance.now() - started, status: document.querySelector('.controls strong')?.textContent, @@ -56,9 +58,10 @@ test('advances controlled pagination repeatedly without render-phase errors', as const sortTiming = await page .locator('.sortable-header') .first() - .evaluate((header) => { + .evaluate(async (header) => { const started = performance.now() ;(header as HTMLElement).click() + await Promise.resolve() return { elapsed: performance.now() - started, text: header.textContent, diff --git a/examples/octane/basic-subscribe/package.json b/examples/octane/basic-subscribe/package.json index 97d66c4797..07890c04a2 100644 --- a/examples/octane/basic-subscribe/package.json +++ b/examples/octane/basic-subscribe/package.json @@ -11,14 +11,16 @@ "test:types": "tsrx-tsc --noEmit" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/octane-store": "^0.12.2", - "@tanstack/octane-table": "^9.1.2", - "octane": "0.1.36" + "@faker-js/faker": "^10.6.0", + "@tanstack/octane-store": "^0.13.0", + "@tanstack/octane-table": "^9.3.1", + "octane": "0.17.0" }, "devDependencies": { - "@tsrx/typescript-plugin": "^0.3.118", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@tsrx/oxc": "0.23.0", + "@tsrx/typescript-plugin": "^0.7.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/octane/basic-subscribe/src/main.tsrx b/examples/octane/basic-subscribe/src/main.tsrx index 21f97dbb86..f919160e64 100644 --- a/examples/octane/basic-subscribe/src/main.tsrx +++ b/examples/octane/basic-subscribe/src/main.tsrx @@ -139,7 +139,7 @@ function App() @{ @for (const headerGroup of table.getHeaderGroups(); key headerGroup.id) { @for (const header of headerGroup.headers; key header.id) { - + {header.isPlaceholder ? null : <> {header.column.getCanFilter() @@ -175,7 +175,7 @@ function App() @{ />} - + Page Rows ({String(table.getRowModel().rows.length)}) diff --git a/examples/octane/basic-use-app-table/package.json b/examples/octane/basic-use-app-table/package.json index 2b5a3e49b1..b2123d0ddb 100644 --- a/examples/octane/basic-use-app-table/package.json +++ b/examples/octane/basic-use-app-table/package.json @@ -11,12 +11,14 @@ "test:types": "tsrx-tsc --noEmit" }, "dependencies": { - "@tanstack/octane-table": "^9.1.2", - "octane": "0.1.36" + "@tanstack/octane-table": "^9.3.1", + "octane": "0.17.0" }, "devDependencies": { - "@tsrx/typescript-plugin": "^0.3.118", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@tsrx/oxc": "0.23.0", + "@tsrx/typescript-plugin": "^0.7.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/octane/basic-use-table/package.json b/examples/octane/basic-use-table/package.json index 0762d2ccfa..89cd4779d1 100644 --- a/examples/octane/basic-use-table/package.json +++ b/examples/octane/basic-use-table/package.json @@ -11,12 +11,14 @@ "test:types": "tsrx-tsc --noEmit" }, "dependencies": { - "@tanstack/octane-table": "^9.1.2", - "octane": "0.1.36" + "@tanstack/octane-table": "^9.3.1", + "octane": "0.17.0" }, "devDependencies": { - "@tsrx/typescript-plugin": "^0.3.118", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@tsrx/oxc": "0.23.0", + "@tsrx/typescript-plugin": "^0.7.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/octane/cell-spanning/package.json b/examples/octane/cell-spanning/package.json index 54146600e7..0e04f17dab 100644 --- a/examples/octane/cell-spanning/package.json +++ b/examples/octane/cell-spanning/package.json @@ -11,13 +11,15 @@ "test:types": "tsrx-tsc --noEmit" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/octane-table": "^9.1.2", - "octane": "0.1.36" + "@faker-js/faker": "^10.6.0", + "@tanstack/octane-table": "^9.3.1", + "octane": "0.17.0" }, "devDependencies": { - "@tsrx/typescript-plugin": "^0.3.118", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@tsrx/oxc": "0.23.0", + "@tsrx/typescript-plugin": "^0.7.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/octane/cell-spanning/src/main.tsrx b/examples/octane/cell-spanning/src/main.tsrx index 78de73474f..d6844b75aa 100644 --- a/examples/octane/cell-spanning/src/main.tsrx +++ b/examples/octane/cell-spanning/src/main.tsrx @@ -175,7 +175,7 @@ function App() @{ {table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( - + +
+ +} diff --git a/examples/octane/realtime-trading/src/shell/Configurator.tsrx b/examples/octane/realtime-trading/src/shell/Configurator.tsrx new file mode 100644 index 0000000000..6e08e79b7a --- /dev/null +++ b/examples/octane/realtime-trading/src/shell/Configurator.tsrx @@ -0,0 +1,105 @@ +import { feedSampleRateAt, feedSampleRateIndex, feedSampleRateOptions } from '../feed/feed-sample-rates' +import { useSelector } from '@tanstack/octane-store' +import { configuratorOptions } from './configurator-options' +import { Diagnostics } from './Diagnostics.tsrx' +import { MetricsStrip } from './MetricsStrip.tsrx' +import { SelectedInstrument } from './SelectedInstrument.tsrx' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +const rate = new Intl.NumberFormat('en-US', { notation: 'compact', maximumFractionDigits: 1 }) + +export function Configurator(props: { + controller: TradingBenchmarkController + feed: MarketFeedController +}) @{ + const running = useSelector(props.feed.running) + const instrumentCount = useSelector(props.feed.instrumentCount) + const targetTicksPerSecond = useSelector(props.feed.targetTicksPerSecond) + const publishIntervalMs = useSelector(props.feed.publishIntervalMs) + const updateSparklines = useSelector(props.feed.updateSparklines) + const sparklineSampleIntervalMs = useSelector( + props.feed.sparklineSampleIntervalMs, + ) + const rendererMode = useSelector(props.controller.renderAtoms.rendererMode) + const value = (event: Event): string => (event.target as HTMLInputElement | HTMLSelectElement).value + const number = (event: Event): number => Number(value(event)) + const checked = (event: Event): boolean => (event.target as HTMLInputElement).checked + + +} diff --git a/examples/octane/realtime-trading/src/shell/Diagnostics.tsrx b/examples/octane/realtime-trading/src/shell/Diagnostics.tsrx new file mode 100644 index 0000000000..2226b4a1e1 --- /dev/null +++ b/examples/octane/realtime-trading/src/shell/Diagnostics.tsrx @@ -0,0 +1,51 @@ +import { useSelector } from '@tanstack/octane-store' +import type { NamedInvocationRate } from '../benchmark/benchmark-monitor' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +const integer = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }) +const rate = new Intl.NumberFormat('en-US', { notation: 'compact', maximumFractionDigits: 1 }) +const ms = (value: number): string => `${value.toFixed(2)} ms` +const invocations = (values: ReadonlyArray): string => { + const active = values.filter((entry) => entry.callsPerSecond > 0) + return active.length ? active.map((entry) => `${entry.name} ${rate.format(entry.callsPerSecond)}`).join(' · ') : '—' +} + +export function Diagnostics({ controller }: { controller: TradingBenchmarkController }) @{ + const state = useSelector(controller.store) + const metrics = state.metrics + const items = [ + ['Mounted cells', integer.format(state.mountedCells), ''], + ['Live components', integer.format(state.liveComponents), ''], + ['Created / destroyed', `${integer.format(metrics.componentsCreated)} / ${integer.format(metrics.componentsDestroyed)}`, ''], + ['Renderer callbacks / s', rate.format(metrics.cellRendererCallsPerSecond), 'cell-render-rate'], + ['Component executions / s', rate.format(metrics.componentRenderCallsPerSecond), 'component-render-rate'], + ['Executions by component / s', invocations(metrics.componentRenderRates), 'component-render-breakdown'], + ['Callbacks by column / s', invocations(metrics.cellRendererRates), 'cell-render-breakdown'], + ['Observed MutationRecords / s', rate.format(metrics.domMutationsPerSecond), 'dom-mutation-rate'], + ['Worker samples / s', rate.format(metrics.actualTicksPerSecond), 'actual-rate'], + ['Worker messages / s', metrics.workerMessagesPerSecond.toFixed(1), 'message-rate'], + ['Changed rows / s', rate.format(metrics.rowUpdatesPerSecond), 'row-update-rate'], + ['State snapshots / s', metrics.stateApplicationsPerSecond.toFixed(1), 'state-apply-rate'], + ['Table DOM commits / s', metrics.tableRendersPerSecond.toFixed(1), 'table-render-rate'], + ['P95 / max commit latency (rolling 10 s)', `${ms(metrics.p95RenderMs)} / ${ms(metrics.maxRenderMs)}`, ''], + ['Core row model calls / s', metrics.rowModelCallsPerSecond.toFixed(1), 'row-model-call-rate'], + ['Core row model avg / max', `${ms(metrics.rowModelAverageMs)} / ${ms(metrics.rowModelMaxMs)}`, 'row-model-duration'], + ['Visible rows', integer.format(metrics.visibleRows), 'visible-row-count'], + ['Worker messages since reset', integer.format(metrics.workerMessages), 'worker-messages'], + ['Worker-coalesced updates / s', rate.format(metrics.supersededUpdatesPerSecond), 'superseded-update-rate'], + ['Last samples / updated rows', `${integer.format(metrics.lastBatchSize)} / ${integer.format(metrics.lastUpdateCount)}`, ''], + ['Commits > 16.7 ms since reset', integer.format(metrics.slowRenders), ''], + ['JS heap (GC-sensitive)', metrics.heapMb === null ? 'N/A' : `${metrics.heapMb.toFixed(1)} MB`, ''], + ] as const +
+

DIAGNOSTICS

+
+ @for (const item of items; key item[0]) { +
{item[0]}
{item[1]}
+ } +
+

+ MutationObserver counts delivered records, not individual DOM operations, and adds profiling overhead. Only class/style attributes, text, and child-list changes are observed. Heap is a Chromium-only point-in-time value and can move before garbage collection. +

+
+} diff --git a/examples/octane/realtime-trading/src/shell/MarketStatusbar.tsrx b/examples/octane/realtime-trading/src/shell/MarketStatusbar.tsrx new file mode 100644 index 0000000000..7f586ed543 --- /dev/null +++ b/examples/octane/realtime-trading/src/shell/MarketStatusbar.tsrx @@ -0,0 +1,24 @@ +import { shallow, useSelector } from '@tanstack/octane-store' +import type { TradingBenchmarkController, TradingBenchmarkState } from '../benchmark/trading-benchmark-controller' + +const integer = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }) +const selectStatusbarState = (state: TradingBenchmarkState) => ({ + lastBatchSize: state.metrics.lastBatchSize, + lastUpdateCount: state.metrics.lastUpdateCount, + mountedCells: state.mountedCells, + liveComponents: state.liveComponents, +}) + +export function MarketStatusbar({ controller }: { controller: TradingBenchmarkController }) @{ + const state = useSelector( + controller.store, + selectStatusbarState, + { compare: shallow }, + ) +
+ MESSAGE SAMPLES {integer.format(state.lastBatchSize)} + CHANGED ROWS {integer.format(state.lastUpdateCount)} + HOSTS {integer.format(state.mountedCells)} + COMPONENTS {integer.format(state.liveComponents)} +
+} diff --git a/examples/octane/realtime-trading/src/shell/MetricsStrip.tsrx b/examples/octane/realtime-trading/src/shell/MetricsStrip.tsrx new file mode 100644 index 0000000000..93938c1bee --- /dev/null +++ b/examples/octane/realtime-trading/src/shell/MetricsStrip.tsrx @@ -0,0 +1,22 @@ +import { useSelector } from '@tanstack/octane-store' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +const rate = new Intl.NumberFormat('en-US', { notation: 'compact', maximumFractionDigits: 1 }) +const ms = (value: number): string => `${value.toFixed(2)} ms` + +export function MetricsStrip({ controller }: { controller: TradingBenchmarkController }) @{ + const state = useSelector(controller.store) + const metrics = state.metrics + const items = [ + ['FRAME RATE (EST.)', metrics.rafCallbacksPerSecond.toFixed(1), 'rAF callbacks/s · rolling 1 s', 'frame-rate'], + ['AVG COMMIT', ms(metrics.averageRenderMs), 'snapshot → DOM · rolling 3 s', 'average-commit-latency'], + ['LONG FRAMES', state.longAnimationFramesSupported ? String(metrics.longAnimationFrames) : 'N/A', state.longAnimationFramesSupported ? `since reset · worst ${ms(metrics.worstLongAnimationFrameMs)}` : 'unsupported', 'long-frame-count'], + ['THROUGHPUT', `${rate.format(metrics.rowUpdatesPerSecond)} rows/s`, `${metrics.stateApplicationsPerSecond.toFixed(1)} snapshots/s · rows deduplicated per snapshot`, 'throughput-rate'], + ] as const +
+

LIVE HEALTH

+ @for (const item of items; key item[0]) { +
{item[0]}{item[1]}{item[2]}
+ } +
+} diff --git a/examples/octane/realtime-trading/src/shell/SelectedInstrument.tsrx b/examples/octane/realtime-trading/src/shell/SelectedInstrument.tsrx new file mode 100644 index 0000000000..6c69f7901b --- /dev/null +++ b/examples/octane/realtime-trading/src/shell/SelectedInstrument.tsrx @@ -0,0 +1,19 @@ +import { useSelector } from '@tanstack/octane-store' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +export function SelectedInstrument(props: { + controller: TradingBenchmarkController + feed: MarketFeedController +}) @{ + const quotes = useSelector(props.feed.quotes) + const symbol = useSelector(props.controller.renderAtoms.selectedSymbol) + const quote = props.feed.getQuoteBySymbol(quotes, symbol) +
+

SELECTED INSTRUMENT

+ {quote ? <> +
{quote.symbol}{quote.company}
{quote.venue}
+
Last
{quote.price.toFixed(2)}
Bid / ask
{quote.bid.toFixed(2)} / {quote.ask.toFixed(2)}
+ :

Click or begin a cell selection in any row to inspect its instrument.

} +
+} diff --git a/examples/octane/realtime-trading/src/shell/TradingShell.tsrx b/examples/octane/realtime-trading/src/shell/TradingShell.tsrx new file mode 100644 index 0000000000..d0cec4fa46 --- /dev/null +++ b/examples/octane/realtime-trading/src/shell/TradingShell.tsrx @@ -0,0 +1,36 @@ +import { useEffect, useState } from 'octane' +import { AppHeader } from './AppHeader.tsrx' +import { Configurator } from './Configurator.tsrx' +import { MarketStatusbar } from './MarketStatusbar.tsrx' +import { TradingTable } from '../table/TradingTable.tsrx' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +export function TradingShell(props: { + controller: TradingBenchmarkController + feed: MarketFeedController +}) @{ + const [sidebarOpen, setSidebarOpen] = useState(true) + useEffect(() => { + const stopFeed = props.feed.start() + const stopBenchmark = props.controller.start() + return () => { + stopBenchmark() + stopFeed() + } + }, [props.controller, props.feed]) + +
+
+ setSidebarOpen((open) => !open)} /> + {import.meta.env.DEV && } +
+
+ +
+ +
+ {sidebarOpen && } +
+
+} diff --git a/examples/octane/realtime-trading/src/shell/configurator-options.ts b/examples/octane/realtime-trading/src/shell/configurator-options.ts new file mode 100644 index 0000000000..5e21d71492 --- /dev/null +++ b/examples/octane/realtime-trading/src/shell/configurator-options.ts @@ -0,0 +1,49 @@ +export interface ConfiguratorOption { + readonly label: string + readonly value: TValue +} + +const instrumentCountOptions = [ + { label: '50', value: 50 }, + { label: '100', value: 100 }, + { label: '150', value: 150 }, + { label: '250', value: 250 }, + { label: '350', value: 350 }, + { label: '500', value: 500 }, + { label: '750', value: 750 }, + { label: '1,000', value: 1_000 }, + { label: '1,500', value: 1_500 }, + { label: '2,500', value: 2_500 }, + { label: '5,000', value: 5_000 }, + { label: '1,000,000', value: 1_000_000 }, + { label: '10,000,000', value: 10_000_000 }, +] as const satisfies ReadonlyArray> + +const workerDeliveryOptions = [ + { label: '8 ms · 125 msg/s', value: 8 }, + { label: '16 ms · 62.5 msg/s', value: 16 }, + { label: '20 ms · 50 msg/s', value: 20 }, + { label: '33 ms · 30 msg/s', value: 33 }, + { label: '50 ms · 20 msg/s', value: 50 }, + { label: '100 ms · 10 msg/s', value: 100 }, + { label: '250 ms · 4 msg/s', value: 250 }, + { label: '500 ms · 2 msg/s', value: 500 }, + { label: '1,000 ms · 1 msg/s', value: 1_000 }, +] as const satisfies ReadonlyArray> + +const intradaySamplingOptions = [ + { label: '16 ms · fastest', value: 16 }, + { label: '33 ms · very fast', value: 33 }, + { label: '50 ms · fast', value: 50 }, + { label: '100 ms', value: 100 }, + { label: '250 ms', value: 250 }, + { label: '500 ms', value: 500 }, + { label: '1,000 ms', value: 1_000 }, + { label: '2,000 ms', value: 2_000 }, +] as const satisfies ReadonlyArray> + +export const configuratorOptions = { + instrumentCounts: instrumentCountOptions, + workerDeliveryIntervals: workerDeliveryOptions, + intradaySamplingIntervals: intradaySamplingOptions, +} as const diff --git a/examples/octane/realtime-trading/src/table/TradingTable.tsrx b/examples/octane/realtime-trading/src/table/TradingTable.tsrx new file mode 100644 index 0000000000..bd2a4c52ea --- /dev/null +++ b/examples/octane/realtime-trading/src/table/TradingTable.tsrx @@ -0,0 +1,242 @@ +import { useLayoutEffect, useMemo, useRef } from 'octane' +import { useTable } from '@tanstack/octane-table' +import { startTableBenchmark } from '../benchmark/table-benchmark' +import { useSelector } from '@tanstack/octane-store' +import { createTradingColumns, readMeasuredRows } from './table-config/trading-columns.tsrx' +import { tradingFeatures } from './trading-features' +import { handleCellNavigation, reorderColumnIds, sortAriaValue, sortIndicator } from './table-interactions' +import { useTradingGridPointer } from './use-trading-grid-pointer' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { MarketQuote } from '../feed/market-data' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +interface TradingTableProps { + controller: TradingBenchmarkController + feed: MarketFeedController +} + +export function TradingTable({ controller, feed }: TradingTableProps) @{ + const quotes = useSelector(feed.quotes) + const rendererMode = useSelector(controller.renderAtoms.rendererMode) + const selectedSymbol = useSelector(controller.renderAtoms.selectedSymbol) + const columns = useMemo( + () => createTradingColumns(controller, rendererMode), + [controller, rendererMode], + ) + const table = useTable( + { + features: tradingFeatures, + columns, + data: quotes, + getRowId: (row: MarketQuote) => row.id, + columnResizeMode: 'onChange', + defaultColumn: { minSize: 56, maxSize: 800 }, + autoResetCellSelection: false, + }, + (state) => ({ + sorting: state.sorting, + columnFilters: state.columnFilters, + columnOrder: state.columnOrder, + rowSelection: state.rowSelection, + cellSelection: state.cellSelection, + }), + ) + const rows = readMeasuredRows(() => table.getRowModel().rows) + const scrollRef = useRef(null) + const tableRef = useRef(null) + const bodyRef = useRef(null) + const manuallyResized = useRef(false) + const pointer = useTradingGridPointer(table, controller.actions.selectSymbol) + const drag = useRef({ + columnId: null as string | null, + source: null as HTMLTableCellElement | null, + target: null as HTMLTableCellElement | null, + }) + + useLayoutEffect(() => { + controller.actions.setRenderedRowCount(rows.length) + feed.completeRender() + }, null) + + useLayoutEffect(() => { + const writeColumnSizes = () => { + const element = tableRef.current + if (!element) return + for (const header of table.getFlatHeaders()) { + element.style.setProperty(`--header-${header.id}-size`, String(header.getSize())) + element.style.setProperty(`--col-${header.column.id}-size`, String(header.column.getSize())) + } + element.style.width = `${table.getTotalSize()}px` + } + const fitAvailableWidth = () => { + const container = scrollRef.current + if (!container || manuallyResized.current) return + const width = table.getTotalSize() + if (container.clientWidth <= width + 1 || width <= 0) return + const ratio = container.clientWidth / width + table.setColumnSizing(Object.fromEntries( + table.getVisibleLeafColumns().map((column) => [column.id, column.getSize() * ratio]), + )) + } + const sizing = table.atoms.columnSizing.subscribe(writeColumnSizes) + const order = table.atoms.columnOrder.subscribe(writeColumnSizes) + const resizing = table.atoms.columnResizing.subscribe((state) => { + if (state.isResizingColumn !== false) manuallyResized.current = true + }) + const resizeObserver = new ResizeObserver(fitAvailableWidth) + if (scrollRef.current) resizeObserver.observe(scrollRef.current) + writeColumnSizes() + fitAvailableWidth() + const stopBenchmark = startTableBenchmark(controller, bodyRef.current) + return () => { + sizing.unsubscribe() + order.unsubscribe() + resizing.unsubscribe() + resizeObserver.disconnect() + stopBenchmark() + } + }, [controller, table.store]) + + const clearDrag = () => { + drag.current.source?.classList.remove('is-column-dragging') + drag.current.target?.classList.remove('is-column-drop-target') + drag.current.columnId = null + drag.current.source = null + drag.current.target = null + } + const showDropTarget = (columnId: string, element: HTMLTableCellElement | null) => { + drag.current.target?.classList.remove('is-column-drop-target') + drag.current.target = null + if (drag.current.columnId === columnId || !element) return + element.classList.add('is-column-drop-target') + drag.current.target = element + } + const renderRow = (row: (typeof rows)[number]) => ( + + @for (const cell of row.getVisibleCells(); key cell.id) { + const edges = cell.getSelectionEdges() + + + + } + + ) + + <> +
+ handleCellNavigation(table, event)} + > + + @for (const group of table.getHeaderGroups(); key group.id) { + + @for (const header of group.headers; key header.id) { + const leaf = header.subHeaders.length === 0 + const sorted = header.column.getIsSorted() + + } + + } + + + {rows.map((row) => renderRow(row))} + +
+ {!header.isPlaceholder && (leaf ? <> +
{ + event.preventDefault() + showDropTarget(header.column.id, event.currentTarget.closest('th')) + }} + onDrop={(event) => { + event.preventDefault() + const source = event.dataTransfer?.getData('text/plain') || drag.current.columnId + if (source) { + table.setColumnOrder(reorderColumnIds( + table.getVisibleLeafColumns().map((column) => column.id), + source, + header.column.id, + )) + } + clearDrag() + }} + > + + +
+ {header.column.getCanResize() &&
header.column.resetSize()} + onMouseDown={header.getResizeHandler()} + onTouchStart={header.getResizeHandler()} + />} + : )} +
+
+ +} diff --git a/examples/octane/realtime-trading/src/table/table-config/quote-cells.tsrx b/examples/octane/realtime-trading/src/table/table-config/quote-cells.tsrx new file mode 100644 index 0000000000..2ca5ecf8e6 --- /dev/null +++ b/examples/octane/realtime-trading/src/table/table-config/quote-cells.tsrx @@ -0,0 +1,94 @@ +import { useEffect } from 'octane' + +export const quoteCellLifecycle = { created: 0, destroyed: 0 } + +export const quoteCellRendererNames = [ + 'Market', 'Name', 'Symbol', 'Last', 'Change', 'ChangePercent', 'Bid', + 'BidVolume', 'Ask', 'AskVolume', 'Open', 'High', 'Low', 'Intraday', +] as const + +export const quoteComponentNames = [ + 'PriceCell', 'StableMoveCell', 'UpMoveCell', 'DownMoveCell', + 'PercentChangeCell', 'SpreadCell', 'DepthCell', 'QuoteAgeCell', + 'SparklineCell', +] as const + +export type QuoteCellRendererName = (typeof quoteCellRendererNames)[number] +export type QuoteComponentName = (typeof quoteComponentNames)[number] + +const createCounterMap = (names: ReadonlyArray) => + Object.fromEntries(names.map((name) => [name, 0])) as Record + +export const quoteRenderDiagnostics = { + cellRendererCalls: 0, + componentRenderCalls: 0, + cellRendererCallsByName: createCounterMap(quoteCellRendererNames), + componentRenderCallsByName: createCounterMap(quoteComponentNames), +} + +export function recordCellRender(name: QuoteCellRendererName, value: T): T { + quoteRenderDiagnostics.cellRendererCalls++ + quoteRenderDiagnostics.cellRendererCallsByName[name]++ + return value +} + +function useLifecycleCounter(name: QuoteComponentName): void { + quoteRenderDiagnostics.componentRenderCalls++ + quoteRenderDiagnostics.componentRenderCallsByName[name]++ + useEffect(() => { + quoteCellLifecycle.created++ + return () => { quoteCellLifecycle.destroyed++ } + }, []) +} + +export function PriceCell(props: { price: number; move: number; onSelect: () => void }) @{ + useLifecycleCounter('PriceCell') + +} + +export function StableMoveCell({ move }: { move: number }) @{ + useLifecycleCounter('StableMoveCell') + = 0 ? 'quote-up' : 'quote-down'}`}>{formatSigned(move)} +} + +export function UpMoveCell({ move }: { move: number }) @{ + useLifecycleCounter('UpMoveCell') + ▲ {formatSigned(move)} +} + +export function DownMoveCell({ move }: { move: number }) @{ + useLifecycleCounter('DownMoveCell') + ▼ {formatSigned(move)} +} + +export function PercentChangeCell({ value }: { value: number }) @{ + useLifecycleCounter('PercentChangeCell') + = 0 ? 'quote-up' : 'quote-down'}`}> + {value >= 0 ? '+' : ''}{value.toFixed(2)}% + +} + +export function SparklineCell({ values }: { values: ReadonlyArray }) @{ + useLifecycleCounter('SparklineCell') + const rising = (values.at(-1) ?? 0) >= (values[0] ?? 0) + const first = values[0] ?? 0 + const range = values.reduce( + (result, value) => ({ min: Math.min(result.min, value), max: Math.max(result.max, value) }), + { min: first, max: first }, + ) + const scale = range.max - range.min || 1 + const denominator = Math.max(1, values.length - 1) + const points = values.map((value, index) => { + const x = (index / denominator) * 100 + const y = 22 - ((value - range.min) / scale) * 20 + return `${x.toFixed(1)},${y.toFixed(1)}` + }).join(' ') + + + + +} + +const formatSigned = (value: number): string => `${value >= 0 ? '+' : ''}${value.toFixed(2)}` diff --git a/examples/octane/realtime-trading/src/table/table-config/trading-columns.tsrx b/examples/octane/realtime-trading/src/table/table-config/trading-columns.tsrx new file mode 100644 index 0000000000..951a35bc3c --- /dev/null +++ b/examples/octane/realtime-trading/src/table/table-config/trading-columns.tsrx @@ -0,0 +1,200 @@ +import { createColumnHelper } from '@tanstack/octane-table' +import { tradingFeatures } from '../trading-features' +import { + DownMoveCell, + PercentChangeCell, + PriceCell, + SparklineCell, + StableMoveCell, + UpMoveCell, + recordCellRender, +} from './quote-cells.tsrx' +import type { MarketQuote } from '../../feed/market-data' +import type { TradingBenchmarkController } from '../../benchmark/trading-benchmark-controller' + +export type RendererMode = 'stable' | 'swap' +export interface CoreTableState { + sorting: Array<{ id: string; desc: boolean }> + columnFilters: Array<{ id: string; value: unknown }> +} + +const compact = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const columnHelper = createColumnHelper() + +export function createTradingColumns( + controller: TradingBenchmarkController, + rendererMode: RendererMode, +) { + return columnHelper.columns([ + columnHelper.group({ + id: 'instrument', + header: 'Instrument', + columns: columnHelper.columns([ + columnHelper.accessor('venue', { + id: 'market', + header: 'Market', + size: 72, + cell: (info) => recordCellRender('Market', info.getValue()), + }), + columnHelper.accessor('company', { + id: 'name', + header: 'Name', + size: 180, + cell: (info) => recordCellRender('Name', info.getValue()), + }), + columnHelper.accessor('symbol', { + header: 'Symbol', + size: 92, + filterFn: 'includesString', + cell: (info) => recordCellRender('Symbol', info.getValue()), + }), + ]), + }), + columnHelper.group({ + id: 'priceAndChange', + header: 'Price & Change', + columns: columnHelper.columns([ + columnHelper.accessor('price', { + header: 'Price', + size: 96, + sortFn: 'basic', + cell: (info) => + recordCellRender( + 'Last', + controller.actions.selectSymbol(info.row.original.symbol)} + />, + ), + }), + columnHelper.accessor(getDayChange, { + id: 'change', + header: 'Chg', + size: 94, + cell: (info) => + recordCellRender( + 'Change', + , + ), + }), + columnHelper.accessor(getDayChangePercent, { + id: 'changePercent', + header: 'Chg%', + size: 90, + cell: (info) => + recordCellRender( + 'ChangePercent', + , + ), + }), + ]), + }), + columnHelper.group({ + id: 'orderBook', + header: 'Order Book', + columns: columnHelper.columns([ + columnHelper.accessor('bid', { + header: 'Bid', + size: 90, + cell: (info) => recordCellRender('Bid', info.getValue().toFixed(2)), + }), + columnHelper.accessor('bidSize', { + header: 'Bid Vol', + size: 100, + cell: (info) => + recordCellRender('BidVolume', compact.format(info.getValue())), + }), + columnHelper.accessor('ask', { + header: 'Ask', + size: 90, + cell: (info) => recordCellRender('Ask', info.getValue().toFixed(2)), + }), + columnHelper.accessor('askSize', { + header: 'Ask Vol', + size: 100, + cell: (info) => + recordCellRender('AskVolume', compact.format(info.getValue())), + }), + ]), + }), + columnHelper.group({ + id: 'session', + header: 'Session', + columns: columnHelper.columns([ + columnHelper.accessor('open', { + header: 'Open', + size: 90, + cell: (info) => recordCellRender('Open', info.getValue().toFixed(2)), + }), + columnHelper.accessor('high', { + header: 'High', + size: 90, + cell: (info) => recordCellRender('High', info.getValue().toFixed(2)), + }), + columnHelper.accessor('low', { + header: 'Low', + size: 90, + cell: (info) => recordCellRender('Low', info.getValue().toFixed(2)), + }), + ]), + }), + columnHelper.group({ + id: 'chart', + header: 'Chart', + columns: columnHelper.columns([ + columnHelper.accessor('history', { + header: 'Intraday', + size: 150, + enableSorting: false, + cell: (info) => + recordCellRender('Intraday', ), + }), + ]), + }), + ]) +} + +function MoveCell({ mode, move }: { mode: RendererMode; move: number }) @{ + if (mode === 'stable') return + if (move >= 0) return + +} + +export const rowModelDiagnostics = { + hasMeasurement: false, + calls: 0, + totalDurationMs: 0, + maxDurationMs: 0, + lastRowCount: 0, +} +export const TRADING_COLUMN_COUNT = 14 + +export function readMeasuredRows(readRows: () => Array): Array { + const start = performance.now() + const rows = readRows() + const end = performance.now() + const duration = end - start + rowModelDiagnostics.calls++ + rowModelDiagnostics.hasMeasurement = true + rowModelDiagnostics.totalDurationMs += duration + rowModelDiagnostics.maxDurationMs = Math.max(rowModelDiagnostics.maxDurationMs, duration) + rowModelDiagnostics.lastRowCount = rows.length + if (rowModelDiagnostics.calls % 20 !== 0) return rows + try { + performance.measure('tanstack-row-model', { start, end, detail: { rowCount: rows.length } }) + if (rowModelDiagnostics.calls % 20_000 === 0) performance.clearMeasures('tanstack-row-model') + } catch { /* optional User Timing detail */ } + return rows +} + +export function getDayChange(quote: MarketQuote): number { + return quote.price - quote.previousClose +} + +export function getDayChangePercent(quote: MarketQuote): number { + return quote.previousClose === 0 ? 0 : (getDayChange(quote) / quote.previousClose) * 100 +} diff --git a/examples/octane/realtime-trading/src/table/table-interactions.ts b/examples/octane/realtime-trading/src/table/table-interactions.ts new file mode 100644 index 0000000000..42356f5bd8 --- /dev/null +++ b/examples/octane/realtime-trading/src/table/table-interactions.ts @@ -0,0 +1,144 @@ +export type CellDirection = 'up' | 'down' | 'left' | 'right' + +interface RowSelectionTable { + resetRowSelection: (defaultState?: boolean) => void +} + +interface SelectableRow { + getIsSelected: () => boolean + getToggleSelectedHandler: (options?: { + selectChildren?: boolean + }) => (event: unknown) => void +} + +interface SelectableGridCell { + row: SelectableGridRow + getSelectionStartHandler: ( + contextDocument?: Document, + ) => (event: unknown) => void + getSelectionExtendHandler: () => (event: unknown) => void +} + +interface SelectableGridRow extends SelectableRow { + original: { symbol: string } + getAllCellsByColumnId: () => Partial> +} + +export interface TradingGridTable extends RowSelectionTable { + getRowModel: () => { + rowsById: Partial> + } +} + +export interface SelectionCellTarget { + element: HTMLTableCellElement + cell: SelectableGridCell +} + +interface CellNavigationTable { + extendCellSelection: (direction: CellDirection) => void + moveCellSelection: (direction: CellDirection) => void + resetCellSelection: (defaultState?: boolean) => void + selectAllCells: () => void +} + +const keyDirections: Partial> = { + ArrowUp: 'up', + ArrowDown: 'down', + ArrowLeft: 'left', + ArrowRight: 'right', +} + +export function reorderColumnIds( + columnIds: Array, + sourceId: string, + targetId: string, +): Array { + if (sourceId === targetId || !columnIds.includes(sourceId)) return columnIds + + const withoutSource = columnIds.filter((id) => id !== sourceId) + const targetIndex = withoutSource.indexOf(targetId) + if (targetIndex < 0) return columnIds + + return [ + ...withoutSource.slice(0, targetIndex), + sourceId, + ...withoutSource.slice(targetIndex), + ] +} + +export function selectRowFromPointer( + table: RowSelectionTable, + row: SelectableRow, + event: MouseEvent, +): void { + const additive = event.ctrlKey || event.metaKey + const checked = additive ? !row.getIsSelected() : true + + if (!event.shiftKey && !additive) table.resetRowSelection(true) + + row.getToggleSelectedHandler({ selectChildren: false })({ + target: { checked }, + shiftKey: event.shiftKey, + ctrlKey: event.ctrlKey, + metaKey: event.metaKey, + }) +} + +export function findTradingGridCellTarget( + table: TradingGridTable, + path: Array, +): SelectionCellTarget | null { + for (const target of path) { + if (!(target instanceof HTMLTableCellElement)) continue + + const columnId = target.dataset['columnId'] + const rowId = + target.closest('tr[data-row-id]')?.dataset['rowId'] + if (!columnId || !rowId) return null + + const row = table.getRowModel().rowsById[rowId] + const cell = row?.getAllCellsByColumnId()[columnId] + return row && cell ? { element: target, cell } : null + } + + return null +} + +export function handleCellNavigation( + table: CellNavigationTable, + event: KeyboardEvent, +): void { + if (event.key === 'Escape') { + event.preventDefault() + table.resetCellSelection(true) + return + } + + if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a') { + event.preventDefault() + table.selectAllCells() + return + } + + const direction = keyDirections[event.key] + if (!direction) return + + event.preventDefault() + if (event.shiftKey) table.extendCellSelection(direction) + else table.moveCellSelection(direction) +} + +export function sortIndicator(direction: false | 'asc' | 'desc'): string { + if (direction === 'asc') return '↑' + if (direction === 'desc') return '↓' + return '↕' +} + +export function sortAriaValue( + direction: false | 'asc' | 'desc', +): 'ascending' | 'descending' | 'none' { + if (direction === 'asc') return 'ascending' + if (direction === 'desc') return 'descending' + return 'none' +} diff --git a/examples/octane/realtime-trading/src/table/trading-features.ts b/examples/octane/realtime-trading/src/table/trading-features.ts new file mode 100644 index 0000000000..0f3b980ccf --- /dev/null +++ b/examples/octane/realtime-trading/src/table/trading-features.ts @@ -0,0 +1,16 @@ +import { + createFilteredRowModel, + createSortedRowModel, + filterFn_includesString, + sortFn_basic, + stockFeatures, + tableFeatures, +} from '@tanstack/octane-table' + +export const tradingFeatures = tableFeatures({ + ...stockFeatures, + filteredRowModel: createFilteredRowModel(), + sortedRowModel: createSortedRowModel(), + filterFns: { includesString: filterFn_includesString }, + sortFns: { basic: sortFn_basic }, +}) diff --git a/examples/octane/realtime-trading/src/table/trading-table.ts b/examples/octane/realtime-trading/src/table/trading-table.ts new file mode 100644 index 0000000000..b5aaa8f2a6 --- /dev/null +++ b/examples/octane/realtime-trading/src/table/trading-table.ts @@ -0,0 +1,8 @@ +export { + TRADING_COLUMN_COUNT, + rowModelDiagnostics, +} from './table-config/trading-columns.tsrx' +export type { + CoreTableState, + RendererMode, +} from './table-config/trading-columns.tsrx' diff --git a/examples/octane/realtime-trading/src/table/use-trading-grid-pointer.ts b/examples/octane/realtime-trading/src/table/use-trading-grid-pointer.ts new file mode 100644 index 0000000000..671ad11f3f --- /dev/null +++ b/examples/octane/realtime-trading/src/table/use-trading-grid-pointer.ts @@ -0,0 +1,59 @@ +import { useMemo, useRef } from 'octane' +import { + findTradingGridCellTarget, + selectRowFromPointer, +} from './table-interactions' +import type { TradingGridTable } from './table-interactions' + +export interface TradingGridPointerHandlers { + readonly onMouseDown: (event: MouseEvent) => void + readonly onPointerOver: (event: PointerEvent) => void + readonly onMouseLeave: () => void + readonly onClick: (event: MouseEvent) => void +} + +export function useTradingGridPointer( + table: TradingGridTable, + selectSymbol: (symbol: string) => void, +): TradingGridPointerHandlers { + const lastPointerCell = useRef(null) + + return useMemo( + () => ({ + onMouseDown(event) { + if (event.button !== 0) return + + const target = findTradingGridCellTarget(table, event.composedPath()) + if (!target) return + + event.preventDefault() + lastPointerCell.current = target.element + selectSymbol(target.cell.row.original.symbol) + target.cell.getSelectionStartHandler(target.element.ownerDocument)( + event, + ) + }, + onPointerOver(event) { + if ((event.buttons & 1) === 0) { + lastPointerCell.current = null + return + } + + const target = findTradingGridCellTarget(table, event.composedPath()) + if (!target || target.element === lastPointerCell.current) return + + lastPointerCell.current = target.element + target.cell.getSelectionExtendHandler()(event) + }, + onMouseLeave() { + lastPointerCell.current = null + }, + onClick(event) { + const target = findTradingGridCellTarget(table, event.composedPath()) + if (!target) return + selectRowFromPointer(table, target.cell.row, event) + }, + }), + [selectSymbol, table], + ) +} diff --git a/examples/octane/realtime-trading/src/vite-env.d.ts b/examples/octane/realtime-trading/src/vite-env.d.ts new file mode 100644 index 0000000000..11f02fe2a0 --- /dev/null +++ b/examples/octane/realtime-trading/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/octane/realtime-trading/tests/e2e/smoke.spec.ts b/examples/octane/realtime-trading/tests/e2e/smoke.spec.ts new file mode 100644 index 0000000000..247454bf0a --- /dev/null +++ b/examples/octane/realtime-trading/tests/e2e/smoke.spec.ts @@ -0,0 +1,146 @@ +import path from 'node:path' +import { expect, test } from '@playwright/test' +import { startExampleServer } from '../../../../../tests/e2e/helpers/startExampleServer' +import { + setRangeValue, + pauseTradingFeed, + resumeTradingFeed, + pausedFeedUrl, +} from '../../../../../tests/e2e/helpers/setRangeValue' +import type { Page } from '@playwright/test' + +const exampleDir = path.resolve() + +function collectPageErrors(page: Page) { + const errors: Array = [] + page.on('pageerror', (error) => errors.push(error.message)) + page.on('console', (message) => { + if (message.type() === 'error') errors.push(message.text()) + }) + return errors +} + +test('runs the Octane realtime trading workload', async ({ page }) => { + const server = await startExampleServer(exampleDir) + const errors = collectPageErrors(page) + + try { + await page.goto(pausedFeedUrl(server.url)) + + const table = page.getByTestId('trading-table') + const instrumentCount = page.getByTestId('instrument-count-select') + await expect(table).toBeVisible() + await expect(instrumentCount).toHaveValue('100') + await expect(page.locator('.brand')).toHaveText('MARKET MONITOR') + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(table.locator('tbody')).toHaveCSS('user-select', 'none') + await expect(table.locator('tbody tr').first()).toHaveCSS( + 'content-visibility', + 'auto', + ) + await expect(table.locator('thead tr')).toHaveCount(2) + await expect(table.locator('thead tr').last().locator('th')).toHaveCount(14) + await expect(table.locator('thead')).not.toContainText('Identity') + await expect(table.locator('thead')).not.toContainText('Market Data') + await expect(table.locator('thead')).toContainText('Market') + await expect(table.locator('thead')).toContainText('Bid Vol') + await expect(table.locator('thead')).toContainText('Intraday') + const selectedRow = table.locator('tbody tr').first() + const selectedSymbol = await selectedRow.getAttribute('data-symbol') + await selectedRow.locator('td').nth(1).click() + await expect(page.getByTestId('selected-instrument')).toContainText( + selectedSymbol ?? '', + ) + await expect(page.getByTestId('feed-status')).toHaveText('FEED PAUSED') + await expect(instrumentCount.locator('option[value="150"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="350"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="750"]')).toHaveCount(1) + + const targetRateSlider = page.getByTestId('target-rate-slider') + await expect(targetRateSlider).toHaveAttribute('min', '0') + await expect(targetRateSlider).toHaveAttribute('max', '9') + await expect(targetRateSlider).toHaveAttribute('step', '1') + await expect(targetRateSlider).toHaveValue('6') + await setRangeValue(targetRateSlider, '7') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '25K samples/s', + ) + await setRangeValue(targetRateSlider, '8') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '50K samples/s', + ) + await setRangeValue(targetRateSlider, '6') + + const sparklineInterval = page.getByTestId( + 'sparkline-sample-interval-select', + ) + await expect(sparklineInterval).toHaveValue('16') + await sparklineInterval.selectOption('100') + await expect(sparklineInterval).toHaveValue('100') + await sparklineInterval.selectOption('16') + + const publishInterval = page.getByTestId('publish-interval-select') + await expect(publishInterval.locator('option[value="500"]')).toHaveCount(1) + await expect(publishInterval.locator('option[value="1000"]')).toHaveCount(1) + + // Exercise delivery and rendering without turning this smoke test into a + // throughput benchmark on shared CI runners. Configure controls while paused. + await setRangeValue(targetRateSlider, '3') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '1K samples/s', + ) + await publishInterval.selectOption('250') + await expect(publishInterval).toHaveValue('250') + await sparklineInterval.selectOption('100') + const swapRenderer = page.getByRole('checkbox', { + name: /Swap Tick component/, + }) + await swapRenderer.check() + await expect(swapRenderer).toBeChecked() + + const firstPrice = table.locator('tbody tr').first().getByRole('button') + const priceBeforeUpdate = await firstPrice.textContent() + await resumeTradingFeed(page) + await expect + .poll(async () => { + const text = await page.getByTestId('row-update-rate').textContent() + return Number(text?.replace(/\D/g, '') ?? 0) + }) + .toBeGreaterThan(0) + await expect + .poll(async () => { + const text = await page.getByTestId('worker-messages').textContent() + return Number(text?.replace(/\D/g, '') ?? 0) + }) + .toBeGreaterThan(0) + await expect + .poll(async () => + Number(await page.getByTestId('message-rate').textContent()), + ) + .toBeGreaterThan(0) + await expect + .poll(async () => + Number(await page.getByTestId('table-render-rate').textContent()), + ) + .toBeGreaterThan(0) + + await expect + .poll(() => firstPrice.textContent()) + .not.toBe(priceBeforeUpdate) + + // Row-model timing is sampled every twentieth call, so wait for a sample + // before stopping the lower-rate feed. + await expect + .poll(() => + page.evaluate( + () => performance.getEntriesByName('tanstack-row-model').length, + ), + ) + .toBeGreaterThan(0) + await pauseTradingFeed(page) + + expect(errors).toEqual([]) + } finally { + await server.close() + } +}) diff --git a/examples/octane/realtime-trading/tsconfig.json b/examples/octane/realtime-trading/tsconfig.json new file mode 100644 index 0000000000..a33b01356c --- /dev/null +++ b/examples/octane/realtime-trading/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "target": "ES2022", + "useDefineForClassFields": true, + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + "moduleResolution": "Bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + "jsxImportSource": "octane", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "types": ["node"] + }, + "include": ["src", "vite.config.ts"] +} diff --git a/examples/octane/realtime-trading/vite.config.ts b/examples/octane/realtime-trading/vite.config.ts new file mode 100644 index 0000000000..42562920a8 --- /dev/null +++ b/examples/octane/realtime-trading/vite.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'vite' +import { octane } from 'octane/compiler/vite' + +export default defineConfig({ + server: { + port: 7777, + allowedHosts: true, + }, + plugins: [octane()], +}) diff --git a/examples/octane/row-pinning/package.json b/examples/octane/row-pinning/package.json index f576aab91e..a33de753b1 100644 --- a/examples/octane/row-pinning/package.json +++ b/examples/octane/row-pinning/package.json @@ -11,13 +11,15 @@ "test:types": "tsrx-tsc --noEmit" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/octane-table": "^9.1.2", - "octane": "0.1.36" + "@faker-js/faker": "^10.6.0", + "@tanstack/octane-table": "^9.3.1", + "octane": "0.17.0" }, "devDependencies": { - "@tsrx/typescript-plugin": "^0.3.118", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@tsrx/oxc": "0.23.0", + "@tsrx/typescript-plugin": "^0.7.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/octane/row-pinning/src/main.tsrx b/examples/octane/row-pinning/src/main.tsrx index bca08824aa..9718a3e39a 100644 --- a/examples/octane/row-pinning/src/main.tsrx +++ b/examples/octane/row-pinning/src/main.tsrx @@ -192,7 +192,7 @@ function App() @{ {headerGroup.headers.map((header) => { return ( - + {header.isPlaceholder ? null : ( <> diff --git a/examples/octane/row-selection/package.json b/examples/octane/row-selection/package.json index 96bed08322..442a21f18a 100644 --- a/examples/octane/row-selection/package.json +++ b/examples/octane/row-selection/package.json @@ -11,14 +11,16 @@ "test:types": "tsrx-tsc --noEmit" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/octane-store": "^0.12.2", - "@tanstack/octane-table": "^9.1.2", - "octane": "0.1.36" + "@faker-js/faker": "^10.6.0", + "@tanstack/octane-store": "^0.13.0", + "@tanstack/octane-table": "^9.3.1", + "octane": "0.17.0" }, "devDependencies": { - "@tsrx/typescript-plugin": "^0.3.118", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@tsrx/oxc": "0.23.0", + "@tsrx/typescript-plugin": "^0.7.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/octane/row-selection/src/main.tsrx b/examples/octane/row-selection/src/main.tsrx index cc61d91cf7..82fae98ce5 100644 --- a/examples/octane/row-selection/src/main.tsrx +++ b/examples/octane/row-selection/src/main.tsrx @@ -149,7 +149,7 @@ function App() @{ {headerGroup.headers.map((header) => { return ( - + {header.isPlaceholder ? null : ( <> @@ -190,7 +190,7 @@ function App() @{ onChange={table.getToggleAllPageRowsSelectedHandler()} /> - + Page Rows ({table.getRowModel().rows.length.toLocaleString()}) diff --git a/examples/octane/sorting/package.json b/examples/octane/sorting/package.json index f29fcc401b..fec93169d8 100644 --- a/examples/octane/sorting/package.json +++ b/examples/octane/sorting/package.json @@ -11,13 +11,15 @@ "test:types": "tsrx-tsc --noEmit" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/octane-table": "^9.1.2", - "octane": "0.1.36" + "@faker-js/faker": "^10.6.0", + "@tanstack/octane-table": "^9.3.1", + "octane": "0.17.0" }, "devDependencies": { - "@tsrx/typescript-plugin": "^0.3.118", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@tsrx/oxc": "0.23.0", + "@tsrx/typescript-plugin": "^0.7.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/octane/sorting/src/main.tsrx b/examples/octane/sorting/src/main.tsrx index 767cc08b81..0b8bb1b9fb 100644 --- a/examples/octane/sorting/src/main.tsrx +++ b/examples/octane/sorting/src/main.tsrx @@ -132,7 +132,7 @@ function App() @{ {headerGroup.headers.map((header) => { return ( - + {header.isPlaceholder ? null : (
{headerGroup.headers.map((header) => { return ( - + {header.isPlaceholder ? null : (
@@ -140,7 +140,7 @@ function Table({ {row.getIsExpanded() && ( {/* 2nd row is a custom 1 cell row */} - + {renderSubComponent({ row })} diff --git a/examples/preact/aggregation/package.json b/examples/preact/aggregation/package.json index df7d08286c..d189bbd29f 100644 --- a/examples/preact/aggregation/package.json +++ b/examples/preact/aggregation/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-store": "^0.13.2", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-store": "^0.13.5", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/basic-dynamic-columns/package.json b/examples/preact/basic-dynamic-columns/package.json index 5d79702cc4..0804cb652f 100644 --- a/examples/preact/basic-dynamic-columns/package.json +++ b/examples/preact/basic-dynamic-columns/package.json @@ -12,16 +12,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-devtools": "^0.10.10", - "@tanstack/preact-pacer": "^0.23.0", - "@tanstack/preact-table": "^9.1.2", - "@tanstack/preact-table-devtools": "^9.2.0", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-devtools": "^0.10.15", + "@tanstack/preact-pacer": "^0.24.2", + "@tanstack/preact-table": "^9.3.1", + "@tanstack/preact-table-devtools": "^9.3.2", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/basic-external-atoms/package.json b/examples/preact/basic-external-atoms/package.json index dac4e378b1..18677ce351 100644 --- a/examples/preact/basic-external-atoms/package.json +++ b/examples/preact/basic-external-atoms/package.json @@ -12,16 +12,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-devtools": "^0.10.10", - "@tanstack/preact-store": "^0.13.2", - "@tanstack/preact-table": "^9.1.2", - "@tanstack/preact-table-devtools": "^9.2.0", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-devtools": "^0.10.15", + "@tanstack/preact-store": "^0.13.5", + "@tanstack/preact-table": "^9.3.1", + "@tanstack/preact-table-devtools": "^9.3.2", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/basic-external-state/package.json b/examples/preact/basic-external-state/package.json index 640d8f0320..2c63e1d8c6 100644 --- a/examples/preact/basic-external-state/package.json +++ b/examples/preact/basic-external-state/package.json @@ -12,16 +12,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-devtools": "^0.10.10", - "@tanstack/preact-store": "^0.13.2", - "@tanstack/preact-table": "^9.1.2", - "@tanstack/preact-table-devtools": "^9.2.0", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-devtools": "^0.10.15", + "@tanstack/preact-store": "^0.13.5", + "@tanstack/preact-table": "^9.3.1", + "@tanstack/preact-table-devtools": "^9.3.2", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/basic-subscribe/package.json b/examples/preact/basic-subscribe/package.json index 0911ee84e4..d4b5f9ac51 100644 --- a/examples/preact/basic-subscribe/package.json +++ b/examples/preact/basic-subscribe/package.json @@ -12,16 +12,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-devtools": "^0.10.10", - "@tanstack/preact-store": "^0.13.2", - "@tanstack/preact-table": "^9.1.2", - "@tanstack/preact-table-devtools": "^9.2.0", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-devtools": "^0.10.15", + "@tanstack/preact-store": "^0.13.5", + "@tanstack/preact-table": "^9.3.1", + "@tanstack/preact-table-devtools": "^9.3.2", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/basic-use-app-table/package.json b/examples/preact/basic-use-app-table/package.json index 3fde03f7d5..ce3e83bcd7 100644 --- a/examples/preact/basic-use-app-table/package.json +++ b/examples/preact/basic-use-app-table/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@tanstack/preact-devtools": "^0.10.10", - "@tanstack/preact-table": "^9.1.2", - "@tanstack/preact-table-devtools": "^9.2.0", - "preact": "^10.29.8" + "@tanstack/preact-devtools": "^0.10.15", + "@tanstack/preact-table": "^9.3.1", + "@tanstack/preact-table-devtools": "^9.3.2", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/basic-use-table/package.json b/examples/preact/basic-use-table/package.json index a3d3722406..c6648b8f5f 100644 --- a/examples/preact/basic-use-table/package.json +++ b/examples/preact/basic-use-table/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@tanstack/preact-devtools": "^0.10.10", - "@tanstack/preact-table": "^9.1.2", - "@tanstack/preact-table-devtools": "^9.2.0", - "preact": "^10.29.8" + "@tanstack/preact-devtools": "^0.10.15", + "@tanstack/preact-table": "^9.3.1", + "@tanstack/preact-table-devtools": "^9.3.2", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/cell-selection/package.json b/examples/preact/cell-selection/package.json index 0dc7bedd00..e0616e9c59 100644 --- a/examples/preact/cell-selection/package.json +++ b/examples/preact/cell-selection/package.json @@ -12,17 +12,18 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-devtools": "^0.10.10", - "@tanstack/preact-hotkeys": "^0.10.0", - "@tanstack/preact-store": "^0.13.2", - "@tanstack/preact-table": "^9.1.2", - "@tanstack/preact-table-devtools": "^9.2.0", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-devtools": "^0.10.15", + "@tanstack/preact-hotkeys": "^0.23.0", + "@tanstack/preact-store": "^0.13.5", + "@tanstack/preact-table": "^9.3.1", + "@tanstack/preact-table-devtools": "^9.3.2", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/cell-spanning/package.json b/examples/preact/cell-spanning/package.json index 96eefef72e..7fe09c6473 100644 --- a/examples/preact/cell-spanning/package.json +++ b/examples/preact/cell-spanning/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/column-ordering/package.json b/examples/preact/column-ordering/package.json index 46a4875b0d..ae1b7027e3 100644 --- a/examples/preact/column-ordering/package.json +++ b/examples/preact/column-ordering/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/column-pinning-split/package.json b/examples/preact/column-pinning-split/package.json index 70a36f8681..98b49bf3a9 100644 --- a/examples/preact/column-pinning-split/package.json +++ b/examples/preact/column-pinning-split/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/column-pinning-sticky/package.json b/examples/preact/column-pinning-sticky/package.json index ccd6e9d092..8edb82a4dd 100644 --- a/examples/preact/column-pinning-sticky/package.json +++ b/examples/preact/column-pinning-sticky/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/column-pinning-sticky/src/main.tsx b/examples/preact/column-pinning-sticky/src/main.tsx index a929bb074f..6e352dba8b 100644 --- a/examples/preact/column-pinning-sticky/src/main.tsx +++ b/examples/preact/column-pinning-sticky/src/main.tsx @@ -50,7 +50,7 @@ const getCommonPinningStyles = ( isPinned === 'end' ? `${column.getAfter('end')}px` : undefined, opacity: isPinned ? 0.95 : 1, position: isPinned ? 'sticky' : 'relative', - width: column.getSize(), + width: `${column.getSize()}px`, zIndex: isPinned ? 1 : 0, } } @@ -180,7 +180,7 @@ function App() {
diff --git a/examples/preact/column-pinning/package.json b/examples/preact/column-pinning/package.json index 558cea16f1..f301ca9d86 100644 --- a/examples/preact/column-pinning/package.json +++ b/examples/preact/column-pinning/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/column-resizing-performant/package.json b/examples/preact/column-resizing-performant/package.json index 3fd7222067..5fa57ca68f 100644 --- a/examples/preact/column-resizing-performant/package.json +++ b/examples/preact/column-resizing-performant/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/column-resizing-performant/src/main.tsx b/examples/preact/column-resizing-performant/src/main.tsx index 9f70558ed3..a1c830e7a6 100644 --- a/examples/preact/column-resizing-performant/src/main.tsx +++ b/examples/preact/column-resizing-performant/src/main.tsx @@ -149,7 +149,7 @@ function App() { {table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( + {#each row.getVisibleCells() as cell (cell.id)}{@const edges = cell.getSelectionEdges()}{/each} + +{/snippet} + +
+
{''}
-
+
{table.getHeaderGroups().map((headerGroup) => ( @@ -138,7 +138,7 @@ function App() { key={header.id} colSpan={header.colSpan} style={{ - width: header.getSize(), + width: `${header.getSize()}px`, }} > {header.isPlaceholder ? null : ( @@ -176,7 +176,7 @@ function App() { + {props.virtualScrollMode === 'tanstack' + ? props.virtualRows.map((virtualRow) => { + const row = props.rows[virtualRow.index] + return ( + + ) + }) + : props.rows.map((row) => ( + + ))} + + ) +} + +type TradingTableRow = ReturnType< + ReturnType['getRowModel'] +>['rows'][number] + +function TradingRowBoundary(props: { + table: ReturnType + row: TradingTableRow + virtualRow?: VirtualItem +}) { + const { row, table, virtualRow } = props + + return ( + + `${row.id in state.rowSelection ? 1 : 0}:${cellSelectionRowKey( + state.cellSelection, + table.getCellSelectionBounds(), + row.getDisplayIndex(), + row.id, + )}` + } + > + {() => ( + + {row.getVisibleCells().map((cell) => { + const edges = cell.getSelectionEdges() + + return ( + + ) + })} + + )} + + ) +} + +function getHeaderClassName(header: { + subHeaders: ReadonlyArray + column: { id: string } +}): string | undefined { + if (header.subHeaders.length > 0) return 'column-group-header' + return isTextColumn(header.column.id) ? undefined : 'numeric-header' +} + +function isTextColumn(columnId: string): boolean { + return columnId === 'market' || columnId === 'name' || columnId === 'symbol' +} + +function readVisibleRange( + range: { startIndex: number; endIndex: number } | null, + rowCount: number, + virtualScrollMode: VirtualScrollMode, +): { start: number; end: number } | null { + if (virtualScrollMode !== 'tanstack' || rowCount === 0 || range === null) { + return null + } + + const lastRowIndex = rowCount - 1 + const start = Math.min(range.startIndex, lastRowIndex) + return { + start, + end: Math.min(Math.max(start, range.endIndex), lastRowIndex), + } +} + +function readRows( + table: ReturnType, + quoteSnapshot: Array, + coreState: CoreTableState, +) { + void quoteSnapshot + void coreState + return readMeasuredRows(() => table.getRowModel().rows) +} + +function cellSelectionRowKey( + ranges: CellSelectionState, + bounds: Array, + rowIndex: number, + rowId: string, +): string { + const active = ranges.at(-1) + const initial = + active?.anchorRowId === rowId ? `f${active.anchorColumnId}` : '' + + return bounds.reduce((key, bound) => { + const self = rowIndex >= bound.minRowIndex && rowIndex <= bound.maxRowIndex + const above = + rowIndex - 1 >= bound.minRowIndex && rowIndex - 1 <= bound.maxRowIndex + const below = + rowIndex + 1 >= bound.minRowIndex && rowIndex + 1 <= bound.maxRowIndex + if (!self && !above && !below) return key + return `${key}|${self ? 1 : 0}${above ? 1 : 0}${below ? 1 : 0}:${bound.minColumnIndex}-${bound.maxColumnIndex}` + }, initial) +} diff --git a/examples/react/realtime-trading/src/table/use-trading-grid-pointer.ts b/examples/react/realtime-trading/src/table/use-trading-grid-pointer.ts new file mode 100644 index 0000000000..a2209c3d7c --- /dev/null +++ b/examples/react/realtime-trading/src/table/use-trading-grid-pointer.ts @@ -0,0 +1,76 @@ +import { useRef } from 'react' +import { + findTradingGridCellTarget, + selectRowFromPointer, +} from './table-interactions' +import type { + MouseEvent as ReactMouseEvent, + PointerEvent as ReactPointerEvent, +} from 'react' +import type { TradingGridTable } from './table-interactions' + +export interface TradingGridPointerHandlers { + readonly onMouseDown: ( + event: ReactMouseEvent, + ) => void + readonly onPointerOver: ( + event: ReactPointerEvent, + ) => void + readonly onMouseLeave: () => void + readonly onClick: (event: ReactMouseEvent) => void +} + +export function useTradingGridPointer( + table: TradingGridTable, + selectSymbol: (symbol: string) => void, +): TradingGridPointerHandlers { + const lastPointerCell = useRef(null) + + return { + onMouseDown(event) { + if (event.button !== 0) return + + const nativeEvent = event.nativeEvent + const target = findTradingGridCellTarget( + table, + nativeEvent.composedPath(), + ) + if (!target) return + + nativeEvent.preventDefault() + lastPointerCell.current = target.element + selectSymbol(target.cell.row.original.symbol) + target.cell.getSelectionStartHandler(target.element.ownerDocument)( + nativeEvent, + ) + }, + onPointerOver(event) { + const nativeEvent = event.nativeEvent + if ((nativeEvent.buttons & 1) === 0) { + lastPointerCell.current = null + return + } + + const target = findTradingGridCellTarget( + table, + nativeEvent.composedPath(), + ) + if (!target || target.element === lastPointerCell.current) return + + lastPointerCell.current = target.element + target.cell.getSelectionExtendHandler()(nativeEvent) + }, + onMouseLeave() { + lastPointerCell.current = null + }, + onClick(event) { + const nativeEvent = event.nativeEvent + const target = findTradingGridCellTarget( + table, + nativeEvent.composedPath(), + ) + if (!target) return + selectRowFromPointer(table, target.cell.row, nativeEvent) + }, + } +} diff --git a/examples/react/realtime-trading/src/vite-env.d.ts b/examples/react/realtime-trading/src/vite-env.d.ts new file mode 100644 index 0000000000..11f02fe2a0 --- /dev/null +++ b/examples/react/realtime-trading/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/react/realtime-trading/tests/e2e/smoke.spec.ts b/examples/react/realtime-trading/tests/e2e/smoke.spec.ts new file mode 100644 index 0000000000..5045105428 --- /dev/null +++ b/examples/react/realtime-trading/tests/e2e/smoke.spec.ts @@ -0,0 +1,160 @@ +import path from 'node:path' +import { expect, test } from '@playwright/test' +import { startExampleServer } from '../../../../../tests/e2e/helpers/startExampleServer' +import { + setRangeValue, + scrollTradingTable, + pausedFeedUrl, +} from '../../../../../tests/e2e/helpers/setRangeValue' +import type { Page } from '@playwright/test' + +const exampleDir = path.resolve() + +function collectPageErrors(page: Page) { + const errors: Array = [] + page.on('pageerror', (error) => errors.push(error.message)) + page.on('console', (message) => { + if (message.type() === 'error') errors.push(message.text()) + }) + return errors +} + +test('runs the React realtime trading workload', async ({ page }) => { + test.setTimeout(120_000) + const server = await startExampleServer(exampleDir) + const errors = collectPageErrors(page) + + try { + await page.route( + 'https://unpkg.com/react-scan/dist/auto.global.js', + (route) => + route.fulfill({ + contentType: 'application/javascript', + body: '', + }), + ) + + await page.goto(pausedFeedUrl(server.url)) + + const table = page.getByTestId('trading-table') + const instrumentCount = page.getByTestId('instrument-count-select') + const virtualScrollSelect = page.getByTestId('virtual-scroll-select') + await expect(table).toBeVisible() + await expect(instrumentCount).toHaveValue('100') + await expect(page.locator('.brand')).toHaveText('MARKET MONITOR') + await expect(virtualScrollSelect).toHaveValue('none') + await expect(virtualScrollSelect).toBeEnabled() + await expect(table.locator('tbody tr')).toHaveCount(100) + const firstRow = table.locator('tbody tr').first() + const selectedSymbol = await firstRow.getAttribute('data-symbol') + await firstRow.getByRole('button').click() + await expect(page.getByTestId('selected-instrument')).toContainText( + selectedSymbol ?? '', + ) + await expect(table.locator('tbody')).toHaveCSS('user-select', 'none') + await expect(table.locator('tbody tr').first()).toHaveCSS( + 'content-visibility', + 'auto', + ) + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await instrumentCount.selectOption('250') + await expect(virtualScrollSelect).toHaveValue('tanstack') + await expect(virtualScrollSelect).toBeEnabled() + await expect.poll(() => table.locator('tbody tr').count()).toBeLessThan(250) + await expect(page.getByTestId('virtual-scroll-footer')).toBeVisible() + await instrumentCount.selectOption('100') + await expect(virtualScrollSelect).toHaveValue('none') + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await virtualScrollSelect.selectOption('tanstack') + await expect.poll(() => table.locator('tbody tr').count()).toBeLessThan(100) + await expect(table.locator('tbody tr').first()).toHaveCSS( + 'content-visibility', + 'auto', + ) + await expect(page.getByTestId('virtual-scroll-footer')).toBeVisible() + await virtualScrollSelect.selectOption('none') + await expect(table.locator('tbody tr')).toHaveCount(100) + await instrumentCount.selectOption('1500') + await expect(virtualScrollSelect).toHaveValue('tanstack') + await expect(virtualScrollSelect).toBeDisabled() + await expect + .poll(() => table.locator('tbody tr').count()) + .toBeLessThan(1500) + await expect(page.getByTestId('virtual-scroll-footer')).toContainText( + 'Total · 1500 rows · 14 columns', + ) + await expect(page.getByTestId('visible-row-range')).toHaveText( + /^\s*Current · rows 0\.\.\d+\s*$/, + ) + await scrollTradingTable(page, 2_000) + await expect + .poll(async () => + Number( + await table + .locator('tbody tr') + .first() + .getAttribute('data-virtual-index'), + ), + ) + .toBeGreaterThan(0) + await expect(page.getByTestId('visible-row-range')).toHaveText( + /^\s*Current · rows [1-9]\d*\.\.\d+\s*$/, + ) + await instrumentCount.selectOption('100') + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await expect(virtualScrollSelect).toHaveValue('none') + await expect(virtualScrollSelect).toBeEnabled() + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(table.locator('thead tr')).toHaveCount(2) + await expect(table.locator('thead tr').last().locator('th')).toHaveCount(14) + await expect(table.locator('thead')).not.toContainText('Identity') + await expect(table.locator('thead')).not.toContainText('Market Data') + await expect(table.locator('thead')).toContainText('Market') + await expect(table.locator('thead')).toContainText('Bid Vol') + await expect(table.locator('thead')).toContainText('Intraday') + await expect(page.getByTestId('feed-status')).toHaveText('FEED PAUSED') + await expect(instrumentCount.locator('option[value="150"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="350"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="750"]')).toHaveCount(1) + + const targetRateSlider = page.getByTestId('target-rate-slider') + await expect(targetRateSlider).toHaveAttribute('min', '0') + await expect(targetRateSlider).toHaveAttribute('max', '9') + await expect(targetRateSlider).toHaveAttribute('step', '1') + await expect(targetRateSlider).toHaveValue('6') + await setRangeValue(targetRateSlider, '7') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '25K samples/s', + ) + await setRangeValue(targetRateSlider, '8') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '50K samples/s', + ) + await setRangeValue(targetRateSlider, '6') + + const sparklineInterval = page.getByTestId( + 'sparkline-sample-interval-select', + ) + await expect(sparklineInterval).toHaveValue('16') + await sparklineInterval.selectOption('100') + await expect(sparklineInterval).toHaveValue('100') + await sparklineInterval.selectOption('16') + + const publishInterval = page.getByTestId('publish-interval-select') + await expect(publishInterval.locator('option[value="500"]')).toHaveCount(1) + await expect(publishInterval.locator('option[value="1000"]')).toHaveCount(1) + + await instrumentCount.selectOption('750') + await expect.poll(() => table.locator('tbody tr').count()).toBeLessThan(750) + expect( + await page.evaluate( + () => performance.getEntriesByName('tanstack-row-model').length > 0, + ), + ).toBe(true) + + expect(errors).toEqual([]) + } finally { + await server.close() + } +}) diff --git a/examples/react/realtime-trading/tsconfig.json b/examples/react/realtime-trading/tsconfig.json new file mode 100644 index 0000000000..6bb83b8604 --- /dev/null +++ b/examples/react/realtime-trading/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "ES2022", + "useDefineForClassFields": true, + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src", "tests/e2e", "vite.config.ts"] +} diff --git a/examples/react/realtime-trading/vite.config.ts b/examples/react/realtime-trading/vite.config.ts new file mode 100644 index 0000000000..aa2c490a08 --- /dev/null +++ b/examples/react/realtime-trading/vite.config.ts @@ -0,0 +1,46 @@ +import react, { reactCompilerPreset } from '@vitejs/plugin-react' +import babel from '@rolldown/plugin-babel' +import rollupReplace from '@rollup/plugin-replace' +import { defineConfig } from 'vite' + +export default defineConfig(({ command, mode }) => { + const development = mode === 'development' + const profiling = mode === 'profile' + + return { + server: { + port: 7777, + allowedHosts: true, + }, + plugins: [ + rollupReplace({ + preventAssignment: true, + values: { + __DEV__: JSON.stringify(development), + 'process.env.NODE_ENV': JSON.stringify( + development ? 'development' : 'production', + ), + }, + }), + react(), + ...(command === 'build' + ? [ + babel({ + presets: [reactCompilerPreset()], + include: [/\/src\/.*\.[jt]sx?$/], + }), + ] + : []), + ], + resolve: { + alias: profiling + ? [ + { + find: /^react-dom\/client$/, + replacement: 'react-dom/profiling', + }, + ] + : [], + }, + } +}) diff --git a/examples/react/row-dnd/package.json b/examples/react/row-dnd/package.json index 3cf928d15b..638bb47df3 100644 --- a/examples/react/row-dnd/package.json +++ b/examples/react/row-dnd/package.json @@ -16,19 +16,20 @@ "@dnd-kit/modifiers": "^9.0.0", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/row-pinning/package.json b/examples/react/row-pinning/package.json index 3991fc7ab5..6168ac36f5 100644 --- a/examples/react/row-pinning/package.json +++ b/examples/react/row-pinning/package.json @@ -12,20 +12,21 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/row-selection/package.json b/examples/react/row-selection/package.json index f411d17a9d..d1cfa1949a 100644 --- a/examples/react/row-selection/package.json +++ b/examples/react/row-selection/package.json @@ -12,23 +12,24 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-store": "^0.11.1", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-store": "^0.11.2", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/sorting/package.json b/examples/react/sorting/package.json index c2cc6bacb8..aaabf3ce93 100644 --- a/examples/react/sorting/package.json +++ b/examples/react/sorting/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/spreadsheet/package.json b/examples/react/spreadsheet/package.json index e882c5266b..d37552fbb9 100644 --- a/examples/react/spreadsheet/package.json +++ b/examples/react/spreadsheet/package.json @@ -12,22 +12,23 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-hotkeys": "^0.10.0", - "@tanstack/react-store": "^0.11.1", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-virtual": "^3.14.9", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-hotkeys": "^0.25.0", + "@tanstack/react-store": "^0.11.2", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-virtual": "^3.14.26", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/spreadsheet/src/useGridInteractions.ts b/examples/react/spreadsheet/src/useGridInteractions.ts index d2d8074dee..606a52a7a9 100644 --- a/examples/react/spreadsheet/src/useGridInteractions.ts +++ b/examples/react/spreadsheet/src/useGridInteractions.ts @@ -462,12 +462,16 @@ export function useGridInteractions(options: GridInteractionOptions) { (event: React.KeyboardEvent) => { if (event.key === 'Escape') { event.preventDefault() + // the grid's own hotkeys must not also act on a key the editor handled + event.stopPropagation() cancelEditing() } else if (event.key === 'Enter') { event.preventDefault() + event.stopPropagation() commitEditing(event.shiftKey ? 'up' : 'down') } else if (event.key === 'Tab') { event.preventDefault() + event.stopPropagation() commitEditing(event.shiftKey ? 'left' : 'right') } }, diff --git a/examples/react/sub-components/package.json b/examples/react/sub-components/package.json index e6e4e57fb8..1467cdc129 100644 --- a/examples/react/sub-components/package.json +++ b/examples/react/sub-components/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/virtualized-columns-experimental/package.json b/examples/react/virtualized-columns-experimental/package.json index 96d84aaa18..16939a51d4 100644 --- a/examples/react/virtualized-columns-experimental/package.json +++ b/examples/react/virtualized-columns-experimental/package.json @@ -11,20 +11,21 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-virtual": "^3.14.9", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-virtual": "^3.14.26", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/virtualized-columns/package.json b/examples/react/virtualized-columns/package.json index 774e183f99..f4a8bad1cb 100644 --- a/examples/react/virtualized-columns/package.json +++ b/examples/react/virtualized-columns/package.json @@ -12,20 +12,21 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-virtual": "^3.14.9", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-virtual": "^3.14.26", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/virtualized-infinite-scrolling/package.json b/examples/react/virtualized-infinite-scrolling/package.json index fd2cbc904a..0d29f822a9 100644 --- a/examples/react/virtualized-infinite-scrolling/package.json +++ b/examples/react/virtualized-infinite-scrolling/package.json @@ -12,21 +12,22 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-query": "^5.101.4", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-virtual": "^3.14.9", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-query": "^5.107.1", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-virtual": "^3.14.26", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/virtualized-rows-experimental/package.json b/examples/react/virtualized-rows-experimental/package.json index 8db6a38e17..1e6149db42 100644 --- a/examples/react/virtualized-rows-experimental/package.json +++ b/examples/react/virtualized-rows-experimental/package.json @@ -11,20 +11,21 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-virtual": "^3.14.9", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-virtual": "^3.14.26", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/virtualized-rows/package.json b/examples/react/virtualized-rows/package.json index 15278e1fe5..881bf757f1 100644 --- a/examples/react/virtualized-rows/package.json +++ b/examples/react/virtualized-rows/package.json @@ -12,20 +12,21 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-virtual": "^3.14.9", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-virtual": "^3.14.26", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/web-worker-row-models/package.json b/examples/react/web-worker-row-models/package.json index f8a7bcb24c..a1feac7879 100644 --- a/examples/react/web-worker-row-models/package.json +++ b/examples/react/web-worker-row-models/package.json @@ -12,24 +12,25 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-router": "^1.170.27", - "@tanstack/react-start": "^1.168.44", - "@tanstack/react-store": "^0.11.1", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-router": "^1.170.46", + "@tanstack/react-start": "^1.169.5", + "@tanstack/react-store": "^0.11.2", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", - "@types/node": "^26.2.0", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", + "@types/node": "^26.6.6", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/web-worker-row-models/src/router.tsx b/examples/react/web-worker-row-models/src/router.tsx index 16ab116fb4..5f2f7b01bc 100644 --- a/examples/react/web-worker-row-models/src/router.tsx +++ b/examples/react/web-worker-row-models/src/router.tsx @@ -5,7 +5,9 @@ export function getRouter() { const router = createRouter({ routeTree, defaultPreload: 'intent', - defaultErrorComponent: (err) =>
{err.error.stack}
, + defaultErrorComponent: ({ error }) => ( +
{error instanceof Error ? error.stack : String(error)}
+ ), defaultNotFoundComponent: () =>

not found

, scrollRestoration: true, }) diff --git a/examples/react/with-tanstack-form/package.json b/examples/react/with-tanstack-form/package.json index d13e76a079..e440c83308 100644 --- a/examples/react/with-tanstack-form/package.json +++ b/examples/react/with-tanstack-form/package.json @@ -12,26 +12,27 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-devtools": "^0.10.10", + "@faker-js/faker": "^10.6.0", + "@tanstack/react-devtools": "^0.10.14", "@tanstack/react-form": "^1.33.5", "@tanstack/react-form-devtools": "^0.2.34", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-pacer-devtools": "0.8.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8", - "zod": "^4.4.3" + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-pacer-devtools": "0.9.1", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1", + "zod": "^4.6.7" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/with-tanstack-query/package.json b/examples/react/with-tanstack-query/package.json index 65e6d7b5b6..f750ff5b27 100644 --- a/examples/react/with-tanstack-query/package.json +++ b/examples/react/with-tanstack-query/package.json @@ -12,23 +12,24 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-query": "^5.101.4", - "@tanstack/react-query-devtools": "^5.101.4", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-query": "^5.107.1", + "@tanstack/react-query-devtools": "^5.107.1", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/with-tanstack-router/package.json b/examples/react/with-tanstack-router/package.json index b2bdca92ce..562d745615 100644 --- a/examples/react/with-tanstack-router/package.json +++ b/examples/react/with-tanstack-router/package.json @@ -12,28 +12,29 @@ "test:types": "tsc" }, "dependencies": { - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-pacer-devtools": "0.8.0", - "@tanstack/react-query": "^5.101.4", - "@tanstack/react-query-devtools": "^5.101.4", - "@tanstack/react-router": "^1.170.27", - "@tanstack/react-router-devtools": "^1.167.1", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-pacer-devtools": "0.9.1", + "@tanstack/react-query": "^5.107.1", + "@tanstack/react-query-devtools": "^5.107.1", + "@tanstack/react-router": "^1.170.46", + "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", - "@rolldown/plugin-babel": "^0.2.3", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@tanstack/router-vite-plugin": "^1.167.30", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@tanstack/router-vite-plugin": "^1.167.49", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/solid/aggregation/package.json b/examples/solid/aggregation/package.json index 42f01f9bbf..0f26c6c41c 100644 --- a/examples/solid/aggregation/package.json +++ b/examples/solid/aggregation/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/basic-app-table/package.json b/examples/solid/basic-app-table/package.json index f84b4d3e26..11765a9bc9 100644 --- a/examples/solid/basic-app-table/package.json +++ b/examples/solid/basic-app-table/package.json @@ -13,15 +13,16 @@ }, "license": "MIT", "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/solid-devtools": "^0.8.10", - "@tanstack/solid-table": "^9.1.2", - "@tanstack/solid-table-devtools": "^9.2.0", - "solid-js": "^1.9.14" + "@faker-js/faker": "^10.6.0", + "@tanstack/solid-devtools": "^0.8.14", + "@tanstack/solid-table": "^9.3.1", + "@tanstack/solid-table-devtools": "^9.3.2", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/basic-dynamic-columns/package.json b/examples/solid/basic-dynamic-columns/package.json index 68b6c7d09a..ab3f7aae6e 100644 --- a/examples/solid/basic-dynamic-columns/package.json +++ b/examples/solid/basic-dynamic-columns/package.json @@ -13,14 +13,15 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-pacer": "^0.22.0", - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-pacer": "^0.24.0", + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/basic-external-atoms/package.json b/examples/solid/basic-external-atoms/package.json index 301c9f696f..16c4061798 100644 --- a/examples/solid/basic-external-atoms/package.json +++ b/examples/solid/basic-external-atoms/package.json @@ -13,16 +13,17 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-devtools": "^0.8.10", - "@tanstack/solid-store": "^0.11.1", - "@tanstack/solid-table": "^9.1.2", - "@tanstack/solid-table-devtools": "^9.2.0", - "solid-js": "^1.9.14" + "@tanstack/solid-devtools": "^0.8.14", + "@tanstack/solid-store": "^0.11.2", + "@tanstack/solid-table": "^9.3.1", + "@tanstack/solid-table-devtools": "^9.3.2", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/basic-external-state/package.json b/examples/solid/basic-external-state/package.json index 10c8c1b232..a7ac5e303d 100644 --- a/examples/solid/basic-external-state/package.json +++ b/examples/solid/basic-external-state/package.json @@ -13,15 +13,16 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-devtools": "^0.8.10", - "@tanstack/solid-table": "^9.1.2", - "@tanstack/solid-table-devtools": "^9.2.0", - "solid-js": "^1.9.14" + "@tanstack/solid-devtools": "^0.8.14", + "@tanstack/solid-table": "^9.3.1", + "@tanstack/solid-table-devtools": "^9.3.2", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/basic-use-table/package.json b/examples/solid/basic-use-table/package.json index bdef53b14a..072c4e81b7 100644 --- a/examples/solid/basic-use-table/package.json +++ b/examples/solid/basic-use-table/package.json @@ -13,14 +13,15 @@ }, "license": "MIT", "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-devtools": "^0.8.10", - "@tanstack/solid-table": "^9.1.2", - "@tanstack/solid-table-devtools": "^9.2.0", - "solid-js": "^1.9.14" + "@tanstack/solid-devtools": "^0.8.14", + "@tanstack/solid-table": "^9.3.1", + "@tanstack/solid-table-devtools": "^9.3.2", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/cell-selection/package.json b/examples/solid/cell-selection/package.json index 469c472a1b..2acb7332cf 100644 --- a/examples/solid/cell-selection/package.json +++ b/examples/solid/cell-selection/package.json @@ -13,16 +13,17 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-devtools": "^0.8.10", - "@tanstack/solid-hotkeys": "^0.10.0", - "@tanstack/solid-table": "^9.1.2", - "@tanstack/solid-table-devtools": "^9.2.0", - "solid-js": "^1.9.14" + "@tanstack/solid-devtools": "^0.8.14", + "@tanstack/solid-hotkeys": "^0.24.0", + "@tanstack/solid-table": "^9.3.1", + "@tanstack/solid-table-devtools": "^9.3.2", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/cell-spanning/package.json b/examples/solid/cell-spanning/package.json index 5cb007bfc7..5ed0366290 100644 --- a/examples/solid/cell-spanning/package.json +++ b/examples/solid/cell-spanning/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@faker-js/faker": "^10.6.0", + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/column-ordering/package.json b/examples/solid/column-ordering/package.json index 78784490ac..e6128c33ec 100644 --- a/examples/solid/column-ordering/package.json +++ b/examples/solid/column-ordering/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/column-pinning-split/package.json b/examples/solid/column-pinning-split/package.json index ade215690b..6918a9f59b 100644 --- a/examples/solid/column-pinning-split/package.json +++ b/examples/solid/column-pinning-split/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/column-pinning-sticky/package.json b/examples/solid/column-pinning-sticky/package.json index 1e48715119..1bb0299b0c 100644 --- a/examples/solid/column-pinning-sticky/package.json +++ b/examples/solid/column-pinning-sticky/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/column-pinning/package.json b/examples/solid/column-pinning/package.json index a7ed13cdf4..2acfbcda4b 100644 --- a/examples/solid/column-pinning/package.json +++ b/examples/solid/column-pinning/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/column-resizing-performant/package.json b/examples/solid/column-resizing-performant/package.json index 6837bfd44d..fe204bbbe5 100644 --- a/examples/solid/column-resizing-performant/package.json +++ b/examples/solid/column-resizing-performant/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/column-resizing/package.json b/examples/solid/column-resizing/package.json index 13b884616e..3d9aebbfa9 100644 --- a/examples/solid/column-resizing/package.json +++ b/examples/solid/column-resizing/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@faker-js/faker": "^10.6.0", + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/column-sizing/package.json b/examples/solid/column-sizing/package.json index c40eb99f54..f8e32dfb73 100644 --- a/examples/solid/column-sizing/package.json +++ b/examples/solid/column-sizing/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@faker-js/faker": "^10.6.0", + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/column-visibility/package.json b/examples/solid/column-visibility/package.json index 814b82c273..7cd0a98939 100644 --- a/examples/solid/column-visibility/package.json +++ b/examples/solid/column-visibility/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@faker-js/faker": "^10.6.0", + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/composable-tables/package.json b/examples/solid/composable-tables/package.json index 49017f4c71..a738c13b19 100644 --- a/examples/solid/composable-tables/package.json +++ b/examples/solid/composable-tables/package.json @@ -13,14 +13,15 @@ }, "license": "MIT", "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-devtools": "^0.8.10", - "@tanstack/solid-table": "^9.1.2", - "@tanstack/solid-table-devtools": "^9.2.0", - "solid-js": "^1.9.14" + "@tanstack/solid-devtools": "^0.8.14", + "@tanstack/solid-table": "^9.3.1", + "@tanstack/solid-table-devtools": "^9.3.2", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/expanding/package.json b/examples/solid/expanding/package.json index 8ce91487a8..a9fd8c6380 100644 --- a/examples/solid/expanding/package.json +++ b/examples/solid/expanding/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/filters-faceted-bucketed/package.json b/examples/solid/filters-faceted-bucketed/package.json index 54b46f4e64..5e469d2c46 100644 --- a/examples/solid/filters-faceted-bucketed/package.json +++ b/examples/solid/filters-faceted-bucketed/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/filters-faceted/package.json b/examples/solid/filters-faceted/package.json index 9c45bf0436..3149cef314 100644 --- a/examples/solid/filters-faceted/package.json +++ b/examples/solid/filters-faceted/package.json @@ -13,14 +13,15 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-pacer": "^0.22.0", - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-pacer": "^0.24.0", + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/filters-fuzzy/package.json b/examples/solid/filters-fuzzy/package.json index 992c4d090e..0fd25c5355 100644 --- a/examples/solid/filters-fuzzy/package.json +++ b/examples/solid/filters-fuzzy/package.json @@ -13,15 +13,16 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/solid-pacer": "^0.22.0", - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/solid-pacer": "^0.24.0", + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/filters/package.json b/examples/solid/filters/package.json index a02ff54205..3842f6ccc2 100644 --- a/examples/solid/filters/package.json +++ b/examples/solid/filters/package.json @@ -13,14 +13,15 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-pacer": "^0.22.0", - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-pacer": "^0.24.0", + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/grouped-aggregation/package.json b/examples/solid/grouped-aggregation/package.json index d0558c9eae..9847b836e2 100644 --- a/examples/solid/grouped-aggregation/package.json +++ b/examples/solid/grouped-aggregation/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/grouping/package.json b/examples/solid/grouping/package.json index 7daebe97ef..8d00ec2a68 100644 --- a/examples/solid/grouping/package.json +++ b/examples/solid/grouping/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/header-groups/package.json b/examples/solid/header-groups/package.json index 24414ba398..57e9396f16 100644 --- a/examples/solid/header-groups/package.json +++ b/examples/solid/header-groups/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@faker-js/faker": "^10.6.0", + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/kitchen-sink/package.json b/examples/solid/kitchen-sink/package.json index a345d9ecb9..aa8ab8ea61 100644 --- a/examples/solid/kitchen-sink/package.json +++ b/examples/solid/kitchen-sink/package.json @@ -13,16 +13,17 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/solid-devtools": "^0.8.10", - "@tanstack/solid-table": "^9.1.2", - "@tanstack/solid-table-devtools": "^9.2.0", - "solid-js": "^1.9.14" + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/solid-devtools": "^0.8.14", + "@tanstack/solid-table": "^9.3.1", + "@tanstack/solid-table-devtools": "^9.3.2", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/pagination/package.json b/examples/solid/pagination/package.json index 9b6c8d58d7..575d35511b 100644 --- a/examples/solid/pagination/package.json +++ b/examples/solid/pagination/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/realtime-trading/README.md b/examples/solid/realtime-trading/README.md new file mode 100644 index 0000000000..1d899e91b5 --- /dev/null +++ b/examples/solid/realtime-trading/README.md @@ -0,0 +1,195 @@ +# Solid realtime trading benchmark + +This standalone example exercises the current TanStack Solid Table adapter +with a high-frequency worker feed, immutable snapshots, fine-grained reactive +cells, table interactions, virtual rows, and browser diagnostics. It is a +repeatable UI workload, not an exchange or network benchmark. + +## Run and verify + +```bash +pnpm --dir examples/solid/realtime-trading dev +``` + +Open `http://localhost:7777`. + +```bash +pnpm --dir examples/solid/realtime-trading test:types +pnpm --dir examples/solid/realtime-trading lint +pnpm --dir examples/solid/realtime-trading build +pnpm --dir examples/solid/realtime-trading test:e2e +``` + +Record performance against the production build; development checks distort +absolute timings. + +## Structure and ownership + +| Path | Responsibility | +| ------------------------- | -------------------------------------------------------------------------------------------------- | +| `src/feed/` | Market model, instrument universe, feed config, immutable update logic, and Solid feed controller. | +| `src/feed/worker/` | Protocol, deterministic market engine, and module worker. | +| `src/benchmark/` | Benchmark monitor and the controller that exposes benchmark signals/actions. | +| `src/shell/` | Contexts, viewport shell, header, metrics, configurator, diagnostics, and selected instrument. | +| `src/table/table-config/` | Declarative columns, named cell renderers, component props, and quote value calculations. | +| `src/table/` | Table model primitive, view components, interactions, layout, and virtualization. | +| `src/App.tsx` | Creates feed/benchmark controllers and composes their providers with the table. | + +`createMarketFeedController` and `createTradingBenchmarkController` are +separate. The feed owns worker state and quotes; the benchmark observes feed +events and owns only diagnostic/view state. Solid contexts provide controller +objects, and consumers read individual accessors rather than one global state +snapshot. + +## Feed and worker pipeline + +The initial setup is 100 instruments, 10K generated samples/s, 20 ms delivery, +enabled intraday charts, and 16 ms chart sampling. + +Mutable quotes never leave the worker. A deterministic generator and a 16 ms +budget loop create samples, while a row-indexed `Map` coalesces repeated changes. +A separate timer publishes the latest unique updates. On the main thread the +outer quote array is new, changed rows are new, and untouched rows keep their +references. History arrays change only at their own sampling cadence. Session +IDs prevent stale batches from an old configuration from being applied. + +- **Synthetic quote workload** is generated worker samples/s, not messages or + framework updates. +- **Worker delivery interval** controls coalesced messages; 20 ms targets about + 50 messages/s. +- **Row updates** is the unique immutable rows applied by a message. +- **Message samples** is the worker work represented by the latest message. + +The 25K burst immediately generates and flushes an intentionally heavy batch. +The worker is a local stand-in for an upstream stream; network latency is not +part of the test. + +## Solid table architecture + +The table has 14 leaf columns grouped into Instrument, Price & Change, Order +Book, Session, and Chart. It supports sorting/filtering, on-change resizing, +double-click reset, drag ordering, row selection, drag cell ranges, keyboard +navigation, and component-based Price/Move/Percent/Sparkline cells. + +The table reads the feed's quote accessor directly from context; `App` does not +subscribe to or forward quote snapshots. `TradingTable` is only the composition +root for `createTradingTableModel`, row virtualization, layout and commit +effects, plus `TradingTableHeader`, `TradingTableBody`, and +`TradingTableFooter`. Stable instrument IDs back `getRowId`. Full-DOM rows use +Solid's position-owned `` scopes and a dedicated `TradingTableRow` +boundary. Each position receives the current TanStack `Row`. One row-level memo +keeps its render cells while the row ID, column configuration, and cell order +are unchanged. A small Solid context exposes an `Accessor` for that +row, so named renderers and their component props update without replacing the +mounted `FlexRender`. It is a normal accessor, not a proxy or mutable registry. + +Row and cell DOM attributes are written directly in JSX. Every cell slot also +receives the current row-model cell at the same visible-column index; selection +edges, focus, selected state, and roving tabindex are computed from that current +cell. This avoids stale selection geometry without `getAllCellsByColumnId()` or +per-cell row/column ID memos. Grid-level pointer interaction remains delegated +to the table body. + +`` is intentionally not used for the immutable TanStack row model. Solid +keys `` by item identity, while TanStack creates new `Row` objects after a +new data array. Stable `getRowId` values preserve table state, but do not change +Solid's identity comparison; `` would therefore treat every new row object +as a replacement. `` keeps the DOM/component slot mounted while replacing +the current `Row` and selection `Cell` props at that position. The separate +render-cell memo changes only for a new row ID, column definition/order, or row +moving into the slot, so quote snapshots update component props without +remounting `FlexRender`. Sorting updates the affected positions as expected. + +The column configuration is memoized by renderer mode. Changing Stable to A/B +therefore refreshes the column definition once, while normal quote batches do +not rebuild columns. `trading-columns.tsx` contains only the declarative schema; +named renderers, component prop interfaces, and market calculations live in +focused colocated modules. In A/B mode the Move renderer selects the direction +component when that row changes, intentionally testing mount/unmount churn. + +`createTradingGridSelectionHandlers` creates one delegated body handler object +and resolves cells from `composedPath()` plus identity data attributes. No +pointer listener is added per cell, and hover remains CSS-only. Header drag, +grid attributes, and body attributes use focused reusable prop factories; the +hot row/cell path stays as direct JSX. Column dimensions live in CSS variables +and update only for column sizing/order; a `ResizeObserver` performs the initial +fit until the user resizes manually. + +## Virtualization + +- Below 200 rows, automatic mode chooses Full DOM, but Virtual is selectable. +- From 200 through 1,499 rows, automatic mode chooses TanStack Virtual and the + user may still choose Full DOM. +- At 1,500 rows or more, Virtual is forced and the control is disabled. + +`createVirtualizer` uses 32 px row estimates, 10-row overscan, stable row IDs, +transformed rows, and a spacer body. Its range drives the current-row footer. +Both rendering paths use `content-visibility: auto`; in Full DOM it can skip +some browser rendering but does not avoid creating every Solid row/cell. + +## Performance decisions + +- market work and coalescing happen before crossing to the main thread; +- immutable snapshots preserve unchanged row/history references; +- fine-grained signals avoid broad shell or root invalidation; +- position-owned rows/cells preserve DOM slots and render-cell identity while + an accessor updates the current immutable quote; +- delegated grid interaction avoids per-cell handlers; +- CSS variables isolate width changes from quote updates; +- dynamic component churn and sparkline frequency are explicit controls; +- virtualization limits mounted DOM for larger data; +- metrics publish at a lower cadence than feed updates. + +A new outer array is part of the immutable contract. Structural sharing helps +cell rendering, but table sorting/filtering can still rebuild a row model when +the data accessor changes. + +## Diagnostics and interpretation + +The sidebar starts with four cross-framework health signals: estimated rAF +callbacks/s over one second, average snapshot-to-DOM-commit latency over three +seconds, long animation frames accumulated since reset, and throughput as +changed rows/s plus applied snapshots/s. “Changed rows” is deduplicated within +each snapshot; the same instrument can count again in a later snapshot. The +advanced diagnostics retain worker samples/messages, DOM commits, a rolling +10-second p95/max commit latency, slow commits, lifecycle/execution rates, DOM +mutation records, and optional heap information. + +The frame figure is deliberately labeled estimated: it counts this page's rAF +callbacks, is capped by the display refresh rate, and falls when a tab is +throttled. It is a portable responsiveness signal, not compositor-presented +FPS. + +Solid applies reactive DOM writes synchronously, but the quote-tracking effect +queues one coalesced microtask before closing a pending commit measurement. This +prevents an effect scheduled early in the reactive graph from reporting a +commit before child bindings have settled. User Timing timeline entries are +sampled at one in 20 commits; the in-memory latency calculation still records +every commit. + +Renderer callbacks are not equivalent to DOM mutations. With this example's +immutable outer array, TanStack can produce new row/cell instances, but the +row-ID equality boundary keeps `FlexRender` stable across quote snapshots. +Column mode/order changes, sorting, and virtual-slot reuse replace the relevant +render cell. A/B mode additionally replaces the direction component when the +sign changes. A rising heap during +component swapping is not proof of a leak without stable post-GC retention. +The heap value is Chromium-only, represents the current GC-sensitive JS heap, +and is not a retained-size measurement. The DOM rate counts `MutationRecord` +objects, not individual browser operations; records may be coalesced. Its +observer watches text/child changes and only `class`/`style` attributes to +reduce, but not eliminate, observer overhead. Non-feed text/child changes and +interaction-driven `class`/`style` changes (including virtual scrolling) are +included, so do not interpret the rate as feed-only work. Use a production +build, identical controls, Chrome Performance, and Solid DevTools for meaningful +comparisons. + +## Standalone policy + +This directory intentionally owns copies of the feed, worker, instruments, +benchmark code, UI, and styles. That makes it independent and StackBlitz-ready; +shared code and explanatory README sections are duplicated across adapters by +design. + +The workspace resolves the pinned `@tanstack/solid-table` dependency to the +local adapter package while keeping the manifest release-like. diff --git a/examples/solid/realtime-trading/index.html b/examples/solid/realtime-trading/index.html new file mode 100644 index 0000000000..bddd49c0fd --- /dev/null +++ b/examples/solid/realtime-trading/index.html @@ -0,0 +1,17 @@ + + + + + + + + Solid Real-time Trading flexRender Lab + + +
+ + + diff --git a/examples/solid/realtime-trading/package.json b/examples/solid/realtime-trading/package.json new file mode 100644 index 0000000000..5341953bc4 --- /dev/null +++ b/examples/solid/realtime-trading/package.json @@ -0,0 +1,32 @@ +{ + "name": "tanstack-solid-table-example-realtime-trading", + "private": true, + "type": "module", + "scripts": { + "start": "vite", + "dev": "vite", + "build": "vite build", + "serve": "vite preview", + "lint": "eslint ./src", + "test:types": "tsc --noEmit", + "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" + }, + "nx": { + "targets": { + "test:e2e": { + "parallelism": false + } + } + }, + "dependencies": { + "@tanstack/solid-table": "^9.3.1", + "@tanstack/solid-virtual": "^3.13.53", + "solid-js": "^1.9.19" + }, + "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "typescript": "6.0.3", + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" + } +} diff --git a/examples/solid/realtime-trading/src/App.tsx b/examples/solid/realtime-trading/src/App.tsx new file mode 100644 index 0000000000..1dfc26f920 --- /dev/null +++ b/examples/solid/realtime-trading/src/App.tsx @@ -0,0 +1,17 @@ +import { createTradingBenchmarkController } from './benchmark/trading-benchmark-controller' +import { createMarketFeedController } from './feed/market-feed-controller' +import { TradingShell } from './shell/TradingShell' +import { TradingShellProvider } from './shell/trading-shell-context' +import { TradingTable } from './table/trading-table' + +export default function App() { + const feed = createMarketFeedController() + const controller = createTradingBenchmarkController(feed) + return ( + + + + + + ) +} diff --git a/examples/solid/realtime-trading/src/benchmark/benchmark-monitor.ts b/examples/solid/realtime-trading/src/benchmark/benchmark-monitor.ts new file mode 100644 index 0000000000..b40c18b603 --- /dev/null +++ b/examples/solid/realtime-trading/src/benchmark/benchmark-monitor.ts @@ -0,0 +1,396 @@ +import { + quoteCellLifecycle, + quoteRenderDiagnostics, +} from '../table/table-config/quote-cells' + +export interface NamedInvocationRate { + name: string + callsPerSecond: number +} + +interface TimedLatencySample { + recordedAt: number + duration: number +} + +const averageLatencyWindowMs = 3_000 +const percentileLatencyWindowMs = 10_000 +const frameRateWindowMs = 1_000 + +export interface FeedMetrics { + actualTicksPerSecond: number + rowUpdatesPerSecond: number + workerMessagesPerSecond: number + stateApplicationsPerSecond: number + supersededUpdatesPerSecond: number + totalTicks: number + rafCallbacksPerSecond: number + tableCommitsPerSecond: number + lastBatchSize: number + averageCommitLatencyMs: number + p95CommitLatencyMs: number + maxCommitLatencyMs: number + slowCommits: number + longAnimationFrames: number + worstLongAnimationFrameMs: number + heapMb: number | null + componentsCreated: number + componentsDestroyed: number + workerMessages: number + lastUpdateCount: number + cellRendererCallsPerSecond: number + componentRenderCallsPerSecond: number + cellRendererRates: ReadonlyArray + componentRenderRates: ReadonlyArray + domMutationsPerSecond: number +} + +export const initialMetrics: FeedMetrics = { + actualTicksPerSecond: 0, + rowUpdatesPerSecond: 0, + workerMessagesPerSecond: 0, + stateApplicationsPerSecond: 0, + supersededUpdatesPerSecond: 0, + totalTicks: 0, + rafCallbacksPerSecond: 0, + tableCommitsPerSecond: 0, + lastBatchSize: 0, + averageCommitLatencyMs: 0, + p95CommitLatencyMs: 0, + maxCommitLatencyMs: 0, + slowCommits: 0, + longAnimationFrames: 0, + worstLongAnimationFrameMs: 0, + heapMb: null, + componentsCreated: 0, + componentsDestroyed: 0, + workerMessages: 0, + lastUpdateCount: 0, + cellRendererCallsPerSecond: 0, + componentRenderCallsPerSecond: 0, + cellRendererRates: [], + componentRenderRates: [], + domMutationsPerSecond: 0, +} + +const userTiming = { entryCount: 0, measureCalls: 0 } + +function recordCommitMeasure(start: number, end: number): void { + userTiming.measureCalls++ + if (userTiming.measureCalls % 20 !== 0) return + try { + performance.measure('market-update-to-dom-commit', { start, end }) + userTiming.entryCount++ + if (userTiming.entryCount % 1_000 === 0) { + performance.clearMeasures('market-update-to-dom-commit') + } + } catch { + // User Timing Level 3 options are not implemented in every browser. + } +} + +export class BenchmarkMonitor { + readonly #runtime = { + sampleStartedAt: performance.now(), + sessionStartedAt: performance.now(), + pendingMutationStartedAt: null as number | null, + commitLatencySamples: [] as Array, + slowCommitCount: 0, + totalTicks: 0, + ticksInSample: 0, + rowUpdatesInSample: 0, + workerMessagesInSample: 0, + stateApplicationsInSample: 0, + supersededUpdatesInSample: 0, + lastBatchSize: 0, + lastUpdateCount: 0, + workerMessages: 0, + frameTrackingStartedAt: performance.now(), + frameTimestamps: [] as Array, + tableCommitsInSample: 0, + longAnimationFrameCount: 0, + worstLongAnimationFrameMs: 0, + previousCellRendererCalls: 0, + previousComponentRenderCalls: 0, + previousCellRendererCallsByName: { + ...quoteRenderDiagnostics.cellRendererCallsByName, + }, + previousComponentRenderCallsByName: { + ...quoteRenderDiagnostics.componentRenderCallsByName, + }, + domMutationsInSample: 0, + } + + markCommitPending(): void { + this.#runtime.pendingMutationStartedAt ??= performance.now() + } + + recordDomCommit(): void { + const runtime = this.#runtime + if (runtime.pendingMutationStartedAt !== null) { + const commitEndedAt = performance.now() + const duration = commitEndedAt - runtime.pendingMutationStartedAt + runtime.commitLatencySamples.push({ recordedAt: commitEndedAt, duration }) + if (duration > 16.7) runtime.slowCommitCount++ + recordCommitMeasure(runtime.pendingMutationStartedAt, commitEndedAt) + runtime.pendingMutationStartedAt = null + runtime.tableCommitsInSample++ + } + } + + recordWorkerMessage(): void { + this.#runtime.workerMessages++ + this.#runtime.workerMessagesInSample++ + } + + recordBatch( + tickCount: number, + updateCount: number, + supersededUpdateCount: number, + ): void { + const runtime = this.#runtime + runtime.lastBatchSize = tickCount + runtime.lastUpdateCount = updateCount + runtime.ticksInSample += tickCount + runtime.totalTicks += tickCount + runtime.rowUpdatesInSample += updateCount + runtime.stateApplicationsInSample++ + runtime.supersededUpdatesInSample += supersededUpdateCount + } + + recordAnimationFrame(now: number): void { + const timestamps = this.#runtime.frameTimestamps + timestamps.push(now) + pruneFrameTimestamps(timestamps, now) + } + + recordLongAnimationFrame(duration: number, startTime: number): void { + const runtime = this.#runtime + if (startTime < runtime.sessionStartedAt) return + runtime.longAnimationFrameCount++ + runtime.worstLongAnimationFrameMs = Math.max( + runtime.worstLongAnimationFrameMs, + duration, + ) + } + + recordDomMutations(count: number): void { + this.#runtime.domMutationsInSample += count + } + + resetDomMutations(): void { + this.#runtime.domMutationsInSample = 0 + } + + shouldPublish(now: number): boolean { + return now - this.#runtime.sampleStartedAt >= 500 + } + + publish(now: number): FeedMetrics { + const runtime = this.#runtime + const sampleDuration = now - runtime.sampleStartedAt + const cellRendererCalls = + quoteRenderDiagnostics.cellRendererCalls - + runtime.previousCellRendererCalls + const componentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls - + runtime.previousComponentRenderCalls + const cellRendererRates = calculateInvocationRates( + quoteRenderDiagnostics.cellRendererCallsByName, + runtime.previousCellRendererCallsByName, + sampleDuration, + ) + const componentRenderRates = calculateInvocationRates( + quoteRenderDiagnostics.componentRenderCallsByName, + runtime.previousComponentRenderCallsByName, + sampleDuration, + ) + pruneLatencySamples(runtime.commitLatencySamples, now) + pruneFrameTimestamps(runtime.frameTimestamps, now) + const averageCommitLatencySamples = runtime.commitLatencySamples + .filter((sample) => sample.recordedAt >= now - averageLatencyWindowMs) + .map((sample) => sample.duration) + const percentileCommitLatencySamples = runtime.commitLatencySamples.map( + (sample) => sample.duration, + ) + const sortedCommitLatencySamples = [...percentileCommitLatencySamples].sort( + (left, right) => left - right, + ) + const averageCommitLatencyMs = + averageCommitLatencySamples.length === 0 + ? 0 + : averageCommitLatencySamples.reduce((sum, value) => sum + value, 0) / + averageCommitLatencySamples.length + const p95Index = Math.max( + 0, + Math.ceil(sortedCommitLatencySamples.length * 0.95) - 1, + ) + const metrics: FeedMetrics = { + actualTicksPerSecond: + sampleDuration === 0 + ? 0 + : (runtime.ticksInSample / sampleDuration) * 1_000, + rowUpdatesPerSecond: + (runtime.rowUpdatesInSample / sampleDuration) * 1_000, + workerMessagesPerSecond: + (runtime.workerMessagesInSample / sampleDuration) * 1_000, + stateApplicationsPerSecond: + (runtime.stateApplicationsInSample / sampleDuration) * 1_000, + supersededUpdatesPerSecond: + (runtime.supersededUpdatesInSample / sampleDuration) * 1_000, + totalTicks: runtime.totalTicks, + rafCallbacksPerSecond: calculateFrameRate( + runtime.frameTimestamps, + runtime.frameTrackingStartedAt, + now, + ), + tableCommitsPerSecond: + sampleDuration === 0 + ? 0 + : (runtime.tableCommitsInSample / sampleDuration) * 1_000, + lastBatchSize: runtime.lastBatchSize, + averageCommitLatencyMs, + p95CommitLatencyMs: sortedCommitLatencySamples[p95Index] ?? 0, + maxCommitLatencyMs: sortedCommitLatencySamples.at(-1) ?? 0, + slowCommits: runtime.slowCommitCount, + longAnimationFrames: runtime.longAnimationFrameCount, + worstLongAnimationFrameMs: runtime.worstLongAnimationFrameMs, + heapMb: readHeapSizeMb(), + componentsCreated: quoteCellLifecycle.created, + componentsDestroyed: quoteCellLifecycle.destroyed, + workerMessages: runtime.workerMessages, + lastUpdateCount: runtime.lastUpdateCount, + cellRendererCallsPerSecond: (cellRendererCalls / sampleDuration) * 1_000, + componentRenderCallsPerSecond: + (componentRenderCalls / sampleDuration) * 1_000, + cellRendererRates, + componentRenderRates, + domMutationsPerSecond: + (runtime.domMutationsInSample / sampleDuration) * 1_000, + } + + runtime.sampleStartedAt = now + runtime.previousCellRendererCalls = quoteRenderDiagnostics.cellRendererCalls + runtime.previousComponentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls + runtime.previousCellRendererCallsByName = { + ...quoteRenderDiagnostics.cellRendererCallsByName, + } + runtime.previousComponentRenderCallsByName = { + ...quoteRenderDiagnostics.componentRenderCallsByName, + } + runtime.domMutationsInSample = 0 + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.tableCommitsInSample = 0 + return metrics + } + + reset(): void { + const runtime = this.#runtime + runtime.sampleStartedAt = performance.now() + runtime.sessionStartedAt = runtime.sampleStartedAt + runtime.pendingMutationStartedAt = null + runtime.commitLatencySamples = [] + runtime.slowCommitCount = 0 + runtime.totalTicks = 0 + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.lastBatchSize = 0 + runtime.lastUpdateCount = 0 + runtime.workerMessages = 0 + runtime.frameTrackingStartedAt = runtime.sampleStartedAt + runtime.frameTimestamps = [] + runtime.tableCommitsInSample = 0 + runtime.longAnimationFrameCount = 0 + runtime.worstLongAnimationFrameMs = 0 + runtime.previousCellRendererCalls = quoteRenderDiagnostics.cellRendererCalls + runtime.previousComponentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls + runtime.previousCellRendererCallsByName = { + ...quoteRenderDiagnostics.cellRendererCallsByName, + } + runtime.previousComponentRenderCallsByName = { + ...quoteRenderDiagnostics.componentRenderCallsByName, + } + runtime.domMutationsInSample = 0 + } +} + +export const longAnimationFramesSupported = + PerformanceObserver.supportedEntryTypes.includes('long-animation-frame') + +function readHeapSizeMb(): number | null { + const memory = ( + performance as Performance & { + memory?: { usedJSHeapSize: number } + } + ).memory + return memory ? memory.usedJSHeapSize / 1_048_576 : null +} + +function calculateInvocationRates( + current: Record, + previous: Record, + sampleDuration: number, +): ReadonlyArray { + return Object.entries(current).map(([name, calls]) => ({ + name, + callsPerSecond: + sampleDuration === 0 + ? 0 + : ((calls - (previous[name] ?? 0)) / sampleDuration) * 1_000, + })) +} + +function pruneLatencySamples( + samples: Array, + now: number, +): void { + const cutoff = now - percentileLatencyWindowMs + const firstRetainedIndex = samples.findIndex( + (sample) => sample.recordedAt >= cutoff, + ) + if (firstRetainedIndex > 0) samples.splice(0, firstRetainedIndex) + else if (firstRetainedIndex === -1) samples.length = 0 +} + +function pruneFrameTimestamps(timestamps: Array, now: number): void { + const cutoff = now - frameRateWindowMs + const firstRetainedIndex = timestamps.findIndex( + (timestamp) => timestamp >= cutoff, + ) + if (firstRetainedIndex > 0) timestamps.splice(0, firstRetainedIndex) + else if (firstRetainedIndex === -1) timestamps.length = 0 +} + +function calculateFrameRate( + timestamps: ReadonlyArray, + trackingStartedAt: number, + now: number, +): number { + const observedWindowMs = Math.min( + frameRateWindowMs, + Math.max(1, now - trackingStartedAt), + ) + return (timestamps.length / observedWindowMs) * 1_000 +} + +export function exposeTradingBenchmarkSnapshot( + metrics: FeedMetrics, + extras: { mountedCells: number; liveComponents: number }, +): void { + Object.assign(globalThis, { + __TANSTACK_TRADING_BENCHMARK__: { + capturedAt: performance.now(), + metrics, + ...extras, + }, + }) +} diff --git a/examples/solid/realtime-trading/src/benchmark/trading-benchmark-controller.ts b/examples/solid/realtime-trading/src/benchmark/trading-benchmark-controller.ts new file mode 100644 index 0000000000..90cabf312e --- /dev/null +++ b/examples/solid/realtime-trading/src/benchmark/trading-benchmark-controller.ts @@ -0,0 +1,155 @@ +import { createMemo, createSignal, onCleanup, onMount } from 'solid-js' +import { TRADING_COLUMN_COUNT } from '../table/table-config/trading-columns' +import { + FORCED_VIRTUALIZATION_ROW_COUNT, + resolveVirtualScrollMode, +} from '../table/trading-row-virtualizer' +import { + BenchmarkMonitor, + exposeTradingBenchmarkSnapshot, + initialMetrics, + longAnimationFramesSupported, +} from './benchmark-monitor' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { RendererMode } from '../table/table-config/trading-columns' +import type { VirtualScrollPreference } from '../table/trading-row-virtualizer' + +export function createTradingBenchmarkController(feed: MarketFeedController) { + const [rendererMode, setRendererMode] = createSignal('stable') + const [requestedVirtualScrollMode, setRequestedVirtualScrollMode] = + createSignal('auto') + const [renderedRowCount, setRenderedRowCount] = createSignal(0) + const [selectedSymbol, setSelectedSymbol] = createSignal(null) + const [metrics, setMetrics] = createSignal(initialMetrics) + const monitor = new BenchmarkMonitor() + const runtime = { + animationFrameId: 0, + longAnimationFrameObserver: null as PerformanceObserver | null, + mutationObserver: null as MutationObserver | null, + } + + const stopObservingFeed = feed.observe({ + messageReceived: () => monitor.recordWorkerMessage(), + mutationStarted: () => monitor.markCommitPending(), + batchApplied: ({ tickCount, updateCount, supersededUpdateCount }) => + monitor.recordBatch(tickCount, updateCount, supersededUpdateCount), + renderCommitted: () => monitor.recordDomCommit(), + }) + + const observeTableMutations = (): void => { + const tableBody = document.querySelector( + '.market-panel [data-trading-table] tbody', + ) + if (!tableBody) return + + monitor.resetDomMutations() + runtime.mutationObserver = new MutationObserver((records) => { + monitor.recordDomMutations(records.length) + }) + runtime.mutationObserver.observe(tableBody, { + attributes: true, + attributeFilter: ['class', 'style'], + characterData: true, + childList: true, + subtree: true, + }) + } + + const benchmarkFrame = (now: number): void => { + monitor.recordAnimationFrame(now) + if (monitor.shouldPublish(now)) { + const nextMetrics = monitor.publish(now) + setMetrics(nextMetrics) + exposeTradingBenchmarkSnapshot(nextMetrics, { + mountedCells: renderedRowCount() * TRADING_COLUMN_COUNT, + liveComponents: + nextMetrics.componentsCreated - nextMetrics.componentsDestroyed, + }) + } + runtime.animationFrameId = requestAnimationFrame(benchmarkFrame) + } + + onMount(() => { + observeTableMutations() + if (longAnimationFramesSupported) { + runtime.longAnimationFrameObserver = new PerformanceObserver( + (entries) => { + for (const entry of entries.getEntries()) { + monitor.recordLongAnimationFrame(entry.duration, entry.startTime) + } + }, + ) + runtime.longAnimationFrameObserver.observe({ + type: 'long-animation-frame', + }) + } + runtime.animationFrameId = requestAnimationFrame(benchmarkFrame) + }) + + onCleanup(() => { + stopObservingFeed() + cancelAnimationFrame(runtime.animationFrameId) + runtime.longAnimationFrameObserver?.disconnect() + runtime.mutationObserver?.disconnect() + }) + + const resetViewState = (): void => { + setSelectedSymbol(null) + setRequestedVirtualScrollMode('auto') + } + + const actions = { + resetViewState, + setRendererMode, + setVirtualScrollEnabled(enabled: boolean): void { + if (feed.state.instrumentCount() >= FORCED_VIRTUALIZATION_ROW_COUNT) + return + setRequestedVirtualScrollMode(enabled ? 'tanstack' : 'none') + }, + setRenderedRowCount, + selectSymbol: setSelectedSymbol, + resetMarket(): void { + monitor.reset() + resetViewState() + setMetrics({ ...initialMetrics }) + feed.actions.reset() + }, + } + + const virtualScrollForced = createMemo( + () => feed.state.instrumentCount() >= FORCED_VIRTUALIZATION_ROW_COUNT, + ) + const virtualScrollMode = createMemo(() => + resolveVirtualScrollMode( + requestedVirtualScrollMode(), + feed.state.instrumentCount(), + ), + ) + const mountedCells = createMemo( + () => renderedRowCount() * TRADING_COLUMN_COUNT, + ) + const liveComponents = createMemo( + () => metrics().componentsCreated - metrics().componentsDestroyed, + ) + + return { + feed, + state: { + rendererMode, + requestedVirtualScrollMode, + virtualScrollForced, + virtualScrollMode, + renderedRowCount, + selectedSymbol, + metrics, + mountedCells, + liveComponents, + }, + actions, + monitor, + } +} + +export type TradingBenchmarkController = ReturnType< + typeof createTradingBenchmarkController +> diff --git a/examples/solid/realtime-trading/src/feed/feed-sample-rates.ts b/examples/solid/realtime-trading/src/feed/feed-sample-rates.ts new file mode 100644 index 0000000000..17dc2015a6 --- /dev/null +++ b/examples/solid/realtime-trading/src/feed/feed-sample-rates.ts @@ -0,0 +1,33 @@ +export const feedSampleRateOptions = [ + { label: '100', value: 100 }, + { label: '250', value: 250 }, + { label: '500', value: 500 }, + { label: '1K', value: 1_000 }, + { label: '2.5K', value: 2_500 }, + { label: '5K', value: 5_000 }, + { label: '10K', value: 10_000 }, + { label: '25K', value: 25_000 }, + { label: '50K', value: 50_000 }, + { label: '100K', value: 100_000 }, +] as const + +export function feedSampleRateIndex(rate: number): number { + return feedSampleRateOptions.reduce((closestIndex, candidate, index) => { + const closest = feedSampleRateOptions[closestIndex] + return Math.abs(candidate.value - rate) < Math.abs(closest.value - rate) + ? index + : closestIndex + }, 0) +} + +export function feedSampleRateAt(stepIndex: number): number { + const index = Math.min( + feedSampleRateOptions.length - 1, + Math.max(0, Math.round(stepIndex)), + ) + return feedSampleRateOptions[index].value +} + +export function normalizeFeedSampleRate(rate: number): number { + return feedSampleRateAt(feedSampleRateIndex(rate)) +} diff --git a/examples/solid/realtime-trading/src/feed/market-data.ts b/examples/solid/realtime-trading/src/feed/market-data.ts new file mode 100644 index 0000000000..6231865d3f --- /dev/null +++ b/examples/solid/realtime-trading/src/feed/market-data.ts @@ -0,0 +1,38 @@ +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './worker/market-feed-protocol' + +export interface MarketQuote extends Omit { + history: ReadonlyArray +} + +export function hydrateMarketQuotes( + snapshots: Array, +): Array { + return snapshots.map((quote) => ({ + ...quote, + history: [...quote.history], + })) +} + +export function applyMarketUpdates( + quotes: Array, + updates: Array, +): Array { + const nextQuotes = [...quotes] + + for (const update of updates) { + const { index, history, ...values } = update + const previousQuote = quotes.at(index) + if (!previousQuote) continue + + nextQuotes[index] = { + ...previousQuote, + ...values, + history: history ?? previousQuote.history, + } + } + + return nextQuotes +} diff --git a/examples/solid/realtime-trading/src/feed/market-feed-config.ts b/examples/solid/realtime-trading/src/feed/market-feed-config.ts new file mode 100644 index 0000000000..9d477ed663 --- /dev/null +++ b/examples/solid/realtime-trading/src/feed/market-feed-config.ts @@ -0,0 +1,15 @@ +export interface MarketFeedConfig { + readonly instrumentCount: number + readonly targetSamplesPerSecond: number + readonly publishIntervalMs: number + readonly updateSparklines: boolean + readonly sparklineSampleIntervalMs: number +} + +export const initialMarketFeedConfig: MarketFeedConfig = { + instrumentCount: 100, + targetSamplesPerSecond: 10_000, + publishIntervalMs: 20, + updateSparklines: true, + sparklineSampleIntervalMs: 16, +} diff --git a/examples/solid/realtime-trading/src/feed/market-feed-controller.ts b/examples/solid/realtime-trading/src/feed/market-feed-controller.ts new file mode 100644 index 0000000000..379fc3114c --- /dev/null +++ b/examples/solid/realtime-trading/src/feed/market-feed-controller.ts @@ -0,0 +1,201 @@ +import { createSignal, onCleanup, onMount } from 'solid-js' +import { normalizeFeedSampleRate } from './feed-sample-rates' +import { initialMarketFeedConfig } from './market-feed-config' +import { applyMarketUpdates, hydrateMarketQuotes } from './market-data' +import type { + MarketFeedCommand, + MarketFeedEvent, +} from './worker/market-feed-protocol' +import type { MarketQuote } from './market-data' + +export interface MarketFeedBatch { + tickCount: number + updateCount: number + supersededUpdateCount: number +} + +export interface MarketFeedObserver { + messageReceived?: () => void + mutationStarted?: () => void + batchApplied?: (batch: MarketFeedBatch) => void + renderCommitted?: () => void +} + +export function createMarketFeedController() { + const [workerReady, setWorkerReady] = createSignal(false) + const [running, setRunning] = createSignal( + !new URLSearchParams(location.search).has('paused'), + ) + const [instrumentCount, setInstrumentCount] = createSignal( + initialMarketFeedConfig.instrumentCount, + ) + const [targetTicksPerSecond, setTargetTicksPerSecond] = createSignal( + initialMarketFeedConfig.targetSamplesPerSecond, + ) + const [publishIntervalMs, setPublishIntervalMsState] = createSignal( + initialMarketFeedConfig.publishIntervalMs, + ) + const [updateSparklines, setUpdateSparklines] = createSignal( + initialMarketFeedConfig.updateSparklines, + ) + const [sparklineSampleIntervalMs, setSparklineSampleIntervalMs] = + createSignal(initialMarketFeedConfig.sparklineSampleIntervalMs) + const [quotes, setQuotes] = createSignal>([]) + const observers = new Set() + const runtime = { + worker: null as Worker | null, + feedSessionId: 0, + renderPending: false, + quoteIndexBySymbol: new Map(), + } + + const post = (command: MarketFeedCommand): void => + runtime.worker?.postMessage(command) + + const startMutation = (): void => { + runtime.renderPending = true + for (const observer of observers) { + observer.mutationStarted?.() + } + } + + const completeRender = (): void => { + if (!runtime.renderPending) return + + runtime.renderPending = false + for (const observer of observers) { + observer.renderCommitted?.() + } + } + + const handleWorkerMessage = ({ + data, + }: MessageEvent): void => { + if (data.type === 'snapshot') { + runtime.feedSessionId = data.sessionId + startMutation() + const nextQuotes = hydrateMarketQuotes(data.quotes) + runtime.quoteIndexBySymbol = new Map( + nextQuotes.map((quote, index) => [quote.symbol, index]), + ) + setQuotes(nextQuotes) + setWorkerReady(true) + return + } + + if (data.sessionId !== runtime.feedSessionId) return + + for (const observer of observers) { + observer.messageReceived?.() + } + startMutation() + setQuotes((currentQuotes) => + applyMarketUpdates(currentQuotes, data.updates), + ) + const batch = { + tickCount: data.tickCount, + updateCount: data.updates.length, + supersededUpdateCount: data.coalescedUpdateCount, + } + for (const observer of observers) { + observer.batchApplied?.(batch) + } + } + + const handleWorkerError = (error: ErrorEvent): void => { + setWorkerReady(false) + setRunning(false) + console.error('Market feed worker failed', error) + } + + const reset = (): void => { + setWorkerReady(false) + post({ type: 'reset', rowCount: instrumentCount() }) + } + + onMount(() => { + runtime.worker = new Worker( + new URL('./worker/market-feed.worker.ts', import.meta.url), + { type: 'module' }, + ) + runtime.worker.addEventListener('message', handleWorkerMessage) + runtime.worker.addEventListener('error', handleWorkerError) + post({ + type: 'start', + rowCount: instrumentCount(), + running: running(), + ticksPerSecond: targetTicksPerSecond(), + publishIntervalMs: publishIntervalMs(), + updateSparklines: updateSparklines(), + sparklineSampleIntervalMs: sparklineSampleIntervalMs(), + }) + }) + + onCleanup(() => { + runtime.worker?.removeEventListener('message', handleWorkerMessage) + runtime.worker?.removeEventListener('error', handleWorkerError) + runtime.worker?.terminate() + runtime.worker = null + observers.clear() + }) + + const actions = { + toggle(): void { + const nextRunning = !running() + setRunning(nextRunning) + post({ type: 'set-running', running: nextRunning }) + }, + setInstrumentCount(count: number): void { + setInstrumentCount(count) + reset() + }, + setTargetRate(rate: number): void { + const sampleRate = normalizeFeedSampleRate(rate) + setTargetTicksPerSecond(sampleRate) + post({ type: 'set-rate', ticksPerSecond: sampleRate }) + }, + setPublishInterval(intervalMs: number): void { + setPublishIntervalMsState(intervalMs) + post({ type: 'set-publish-interval', intervalMs }) + }, + setSparklineUpdates(enabled: boolean): void { + setUpdateSparklines(enabled) + post({ type: 'set-sparklines', enabled }) + }, + setSparklineSampleInterval(intervalMs: number): void { + setSparklineSampleIntervalMs(intervalMs) + post({ type: 'set-sparkline-interval', intervalMs }) + }, + runBurst(): void { + post({ type: 'burst', tickCount: 25_000 }) + }, + reset, + } + + return { + state: { + workerReady, + running, + instrumentCount, + targetTicksPerSecond, + publishIntervalMs, + updateSparklines, + sparklineSampleIntervalMs, + quotes, + }, + actions, + observe(observer: MarketFeedObserver): () => void { + observers.add(observer) + return () => observers.delete(observer) + }, + getQuoteBySymbol(symbol: string | null): MarketQuote | null { + if (symbol === null) return null + + const index = runtime.quoteIndexBySymbol.get(symbol) + return index === undefined ? null : (quotes()[index] ?? null) + }, + completeRender, + } +} + +export type MarketFeedController = ReturnType diff --git a/examples/solid/realtime-trading/src/feed/market-instruments.ts b/examples/solid/realtime-trading/src/feed/market-instruments.ts new file mode 100644 index 0000000000..ac18d14ea9 --- /dev/null +++ b/examples/solid/realtime-trading/src/feed/market-instruments.ts @@ -0,0 +1,742 @@ +export type MarketCode = + | 'US' + | 'NL' + | 'DE' + | 'FR' + | 'IT' + | 'ES' + | 'CH' + | 'DK' + | 'SE' + | 'FI' + | 'GB' + | 'KR' + | 'JP' + | 'HK' + | 'CA' + | 'AU' + +export type BaseInstrument = readonly [ + symbol: string, + company: string, + market: MarketCode, +] + +/** + * Current S&P 500 constituent universe used by the realtime trading examples. + * + * Source snapshot: https://github.com/datasets/s-and-p-500-companies + * Retrieved: 2026-08-15. + * Multiple share classes are intentionally represented as separate instruments. + */ +export const marketInstruments = Object.freeze([ + ['MMM', '3M', 'US'], + ['AOS', 'A. O. Smith', 'US'], + ['ABT', 'Abbott Laboratories', 'US'], + ['ABBV', 'AbbVie', 'US'], + ['ACN', 'Accenture', 'US'], + ['ADBE', 'Adobe Inc.', 'US'], + ['AMD', 'Advanced Micro Devices', 'US'], + ['AES', 'AES Corporation', 'US'], + ['AFL', 'Aflac', 'US'], + ['A', 'Agilent Technologies', 'US'], + ['APD', 'Air Products', 'US'], + ['ABNB', 'Airbnb', 'US'], + ['AKAM', 'Akamai Technologies', 'US'], + ['ALB', 'Albemarle Corporation', 'US'], + ['ARE', 'Alexandria Real Estate Equities', 'US'], + ['ALGN', 'Align Technology', 'US'], + ['ALLE', 'Allegion', 'US'], + ['LNT', 'Alliant Energy', 'US'], + ['ALL', 'Allstate', 'US'], + ['GOOGL', 'Alphabet Inc. (Class A)', 'US'], + ['GOOG', 'Alphabet Inc. (Class C)', 'US'], + ['MO', 'Altria', 'US'], + ['AMZN', 'Amazon', 'US'], + ['AMCR', 'Amcor', 'US'], + ['AEE', 'Ameren', 'US'], + ['AEP', 'American Electric Power', 'US'], + ['AXP', 'American Express', 'US'], + ['AIG', 'American International Group', 'US'], + ['AMT', 'American Tower', 'US'], + ['AWK', 'American Water Works', 'US'], + ['AMP', 'Ameriprise Financial', 'US'], + ['AME', 'Ametek', 'US'], + ['AMGN', 'Amgen', 'US'], + ['APH', 'Amphenol', 'US'], + ['ADI', 'Analog Devices', 'US'], + ['AON', 'Aon plc', 'US'], + ['APA', 'APA Corporation', 'US'], + ['APO', 'Apollo Global Management', 'US'], + ['AAPL', 'Apple Inc.', 'US'], + ['AMAT', 'Applied Materials', 'US'], + ['APP', 'AppLovin', 'US'], + ['APTV', 'Aptiv', 'US'], + ['ACGL', 'Arch Capital Group', 'US'], + ['ADM', 'Archer Daniels Midland', 'US'], + ['ARES', 'Ares Management', 'US'], + ['ANET', 'Arista Networks', 'US'], + ['AJG', 'Arthur J. Gallagher & Co.', 'US'], + ['AIZ', 'Assurant', 'US'], + ['T', 'AT&T', 'US'], + ['ATO', 'Atmos Energy', 'US'], + ['ADSK', 'Autodesk', 'US'], + ['ADP', 'Automatic Data Processing', 'US'], + ['AZO', 'AutoZone', 'US'], + ['AVB', 'AvalonBay Communities', 'US'], + ['AVY', 'Avery Dennison', 'US'], + ['AXON', 'Axon Enterprise', 'US'], + ['BKR', 'Baker Hughes', 'US'], + ['BALL', 'Ball Corporation', 'US'], + ['BAC', 'Bank of America', 'US'], + ['BAX', 'Baxter International', 'US'], + ['BDX', 'Becton Dickinson', 'US'], + ['BRK.B', 'Berkshire Hathaway', 'US'], + ['BBY', 'Best Buy', 'US'], + ['TECH', 'Bio-Techne', 'US'], + ['BIIB', 'Biogen', 'US'], + ['BLK', 'BlackRock', 'US'], + ['BX', 'Blackstone Inc.', 'US'], + ['XYZ', 'Block, Inc.', 'US'], + ['BNY', 'BNY Mellon', 'US'], + ['BA', 'Boeing', 'US'], + ['BKNG', 'Booking Holdings', 'US'], + ['BSX', 'Boston Scientific', 'US'], + ['BMY', 'Bristol Myers Squibb', 'US'], + ['AVGO', 'Broadcom', 'US'], + ['BR', 'Broadridge Financial Solutions', 'US'], + ['BRO', 'Brown & Brown', 'US'], + ['BF.B', 'Brown–Forman', 'US'], + ['BLDR', 'Builders FirstSource', 'US'], + ['BG', 'Bunge Global', 'US'], + ['BXP', 'BXP, Inc.', 'US'], + ['CHRW', 'C.H. Robinson', 'US'], + ['CDNS', 'Cadence Design Systems', 'US'], + ['CPT', 'Camden Property Trust', 'US'], + ['COF', 'Capital One', 'US'], + ['CAH', 'Cardinal Health', 'US'], + ['CCL', 'Carnival Corporation', 'US'], + ['CARR', 'Carrier Global', 'US'], + ['CVNA', 'Carvana', 'US'], + ['CASY', "Casey's", 'US'], + ['CAT', 'Caterpillar Inc.', 'US'], + ['CBOE', 'Cboe Global Markets', 'US'], + ['CBRE', 'CBRE Group', 'US'], + ['CDW', 'CDW Corporation', 'US'], + ['COR', 'Cencora', 'US'], + ['CNC', 'Centene Corporation', 'US'], + ['CNP', 'CenterPoint Energy', 'US'], + ['CF', 'CF Industries', 'US'], + ['CRL', 'Charles River Laboratories', 'US'], + ['SCHW', 'Charles Schwab Corporation', 'US'], + ['CHTR', 'Charter Communications', 'US'], + ['CVX', 'Chevron Corporation', 'US'], + ['CMG', 'Chipotle Mexican Grill', 'US'], + ['CB', 'Chubb Limited', 'US'], + ['CHD', 'Church & Dwight', 'US'], + ['CIEN', 'Ciena', 'US'], + ['CI', 'Cigna', 'US'], + ['CINF', 'Cincinnati Financial', 'US'], + ['CTAS', 'Cintas', 'US'], + ['CSCO', 'Cisco', 'US'], + ['C', 'Citigroup', 'US'], + ['CFG', 'Citizens Financial Group', 'US'], + ['CLX', 'Clorox', 'US'], + ['CME', 'CME Group', 'US'], + ['CMS', 'CMS Energy', 'US'], + ['KO', 'Coca-Cola Company (The)', 'US'], + ['CTSH', 'Cognizant', 'US'], + ['COHR', 'Coherent Corp.', 'US'], + ['COIN', 'Coinbase', 'US'], + ['CL', 'Colgate-Palmolive', 'US'], + ['CMCSA', 'Comcast', 'US'], + ['FIX', 'Comfort Systems USA', 'US'], + ['COP', 'ConocoPhillips', 'US'], + ['ED', 'Consolidated Edison', 'US'], + ['STZ', 'Constellation Brands', 'US'], + ['CEG', 'Constellation Energy', 'US'], + ['COO', 'Cooper Companies (The)', 'US'], + ['CPRT', 'Copart', 'US'], + ['GLW', 'Corning Inc.', 'US'], + ['CPAY', 'Corpay', 'US'], + ['CTVA', 'Corteva', 'US'], + ['CSGP', 'CoStar Group', 'US'], + ['COST', 'Costco', 'US'], + ['CRH', 'CRH plc', 'US'], + ['CRWD', 'CrowdStrike', 'US'], + ['CCI', 'Crown Castle', 'US'], + ['CSX', 'CSX Corporation', 'US'], + ['CMI', 'Cummins', 'US'], + ['CVS', 'CVS Health', 'US'], + ['DHR', 'Danaher Corporation', 'US'], + ['DRI', 'Darden Restaurants', 'US'], + ['DDOG', 'Datadog', 'US'], + ['DVA', 'DaVita', 'US'], + ['DECK', 'Deckers Brands', 'US'], + ['DE', 'Deere & Company', 'US'], + ['DELL', 'Dell Technologies', 'US'], + ['DAL', 'Delta Air Lines', 'US'], + ['DVN', 'Devon Energy', 'US'], + ['DXCM', 'Dexcom', 'US'], + ['FANG', 'Diamondback Energy', 'US'], + ['DLR', 'Digital Realty', 'US'], + ['DG', 'Dollar General', 'US'], + ['DLTR', 'Dollar Tree', 'US'], + ['D', 'Dominion Energy', 'US'], + ['DPZ', "Domino's", 'US'], + ['DASH', 'DoorDash', 'US'], + ['DOV', 'Dover Corporation', 'US'], + ['DOW', 'Dow Inc.', 'US'], + ['DHI', 'D. R. Horton', 'US'], + ['DTE', 'DTE Energy', 'US'], + ['DUK', 'Duke Energy', 'US'], + ['DD', 'DuPont', 'US'], + ['ETN', 'Eaton Corporation', 'US'], + ['EBAY', 'eBay Inc.', 'US'], + ['ECHO', 'EchoStar', 'US'], + ['ECL', 'Ecolab', 'US'], + ['EIX', 'Edison International', 'US'], + ['EW', 'Edwards Lifesciences', 'US'], + ['ELV', 'Elevance Health', 'US'], + ['EME', 'Emcor', 'US'], + ['EMR', 'Emerson Electric', 'US'], + ['ETR', 'Entergy', 'US'], + ['EOG', 'EOG Resources', 'US'], + ['EQT', 'EQT Corporation', 'US'], + ['EFX', 'Equifax', 'US'], + ['EQIX', 'Equinix', 'US'], + ['EQR', 'Equity Residential', 'US'], + ['ERIE', 'Erie Indemnity', 'US'], + ['ESS', 'Essex Property Trust', 'US'], + ['EL', 'Estée Lauder Companies (The)', 'US'], + ['EG', 'Everest Group', 'US'], + ['EVRG', 'Evergy', 'US'], + ['ES', 'Eversource Energy', 'US'], + ['EXC', 'Exelon', 'US'], + ['EXE', 'Expand Energy', 'US'], + ['EXPE', 'Expedia Group', 'US'], + ['EXPD', 'Expeditors International', 'US'], + ['EXR', 'Extra Space Storage', 'US'], + ['XOM', 'ExxonMobil', 'US'], + ['FFIV', 'F5, Inc.', 'US'], + ['FDS', 'FactSet', 'US'], + ['FICO', 'Fair Isaac', 'US'], + ['FAST', 'Fastenal', 'US'], + ['FRT', 'Federal Realty Investment Trust', 'US'], + ['FDX', 'FedEx', 'US'], + ['FDXF', 'FedEx Freight', 'US'], + ['FERG', 'Ferguson Enterprises', 'US'], + ['FIS', 'Fidelity National Information Services', 'US'], + ['FITB', 'Fifth Third Bancorp', 'US'], + ['FSLR', 'First Solar', 'US'], + ['FE', 'FirstEnergy', 'US'], + ['FISV', 'Fiserv', 'US'], + ['FLEX', 'Flex Ltd.', 'US'], + ['F', 'Ford Motor Company', 'US'], + ['FTNT', 'Fortinet', 'US'], + ['FTV', 'Fortive', 'US'], + ['FOXA', 'Fox Corporation (Class A)', 'US'], + ['FOX', 'Fox Corporation (Class B)', 'US'], + ['BEN', 'Franklin Resources', 'US'], + ['FCX', 'Freeport-McMoRan', 'US'], + ['GRMN', 'Garmin', 'US'], + ['IT', 'Gartner', 'US'], + ['GE', 'GE Aerospace', 'US'], + ['GEHC', 'GE HealthCare', 'US'], + ['GEV', 'GE Vernova', 'US'], + ['GEN', 'Gen Digital', 'US'], + ['GNRC', 'Generac', 'US'], + ['GD', 'General Dynamics', 'US'], + ['GIS', 'General Mills', 'US'], + ['GM', 'General Motors', 'US'], + ['GPC', 'Genuine Parts Company', 'US'], + ['GILD', 'Gilead Sciences', 'US'], + ['GPN', 'Global Payments', 'US'], + ['GL', 'Globe Life', 'US'], + ['GDDY', 'GoDaddy', 'US'], + ['GS', 'Goldman Sachs', 'US'], + ['HAL', 'Halliburton', 'US'], + ['HIG', 'Hartford (The)', 'US'], + ['HAS', 'Hasbro', 'US'], + ['HCA', 'HCA Healthcare', 'US'], + ['DOC', 'Healthpeak Properties', 'US'], + ['HSIC', 'Henry Schein', 'US'], + ['HSY', 'Hershey Company (The)', 'US'], + ['HPE', 'Hewlett Packard Enterprise', 'US'], + ['HLT', 'Hilton Worldwide', 'US'], + ['HD', 'Home Depot (The)', 'US'], + ['HONA', 'Honeywell Aerospace', 'US'], + ['HON', 'Honeywell Technologies', 'US'], + ['HRL', 'Hormel Foods', 'US'], + ['HST', 'Host Hotels & Resorts', 'US'], + ['HWM', 'Howmet Aerospace', 'US'], + ['HPQ', 'HP Inc.', 'US'], + ['HUBB', 'Hubbell Incorporated', 'US'], + ['HUM', 'Humana', 'US'], + ['HBAN', 'Huntington Bancshares', 'US'], + ['HII', 'Huntington Ingalls Industries', 'US'], + ['IBM', 'IBM', 'US'], + ['IEX', 'IDEX Corporation', 'US'], + ['IDXX', 'Idexx Laboratories', 'US'], + ['ITW', 'Illinois Tool Works', 'US'], + ['INCY', 'Incyte', 'US'], + ['IR', 'Ingersoll Rand', 'US'], + ['PODD', 'Insulet Corporation', 'US'], + ['INTC', 'Intel', 'US'], + ['IBKR', 'Interactive Brokers', 'US'], + ['ICE', 'Intercontinental Exchange', 'US'], + ['IFF', 'International Flavors & Fragrances', 'US'], + ['IP', 'International Paper', 'US'], + ['INTU', 'Intuit', 'US'], + ['ISRG', 'Intuitive Surgical', 'US'], + ['IVZ', 'Invesco', 'US'], + ['INVH', 'Invitation Homes', 'US'], + ['IQV', 'IQVIA', 'US'], + ['IRM', 'Iron Mountain', 'US'], + ['JBHT', 'J.B. Hunt', 'US'], + ['JBL', 'Jabil', 'US'], + ['JKHY', 'Jack Henry & Associates', 'US'], + ['J', 'Jacobs Solutions', 'US'], + ['JNJ', 'Johnson & Johnson', 'US'], + ['JCI', 'Johnson Controls', 'US'], + ['JPM', 'JPMorgan Chase', 'US'], + ['KVUE', 'Kenvue', 'US'], + ['KDP', 'Keurig Dr Pepper', 'US'], + ['KEY', 'KeyCorp', 'US'], + ['KEYS', 'Keysight Technologies', 'US'], + ['KMB', 'Kimberly-Clark', 'US'], + ['KIM', 'Kimco Realty', 'US'], + ['KMI', 'Kinder Morgan', 'US'], + ['KKR', 'KKR & Co.', 'US'], + ['KLAC', 'KLA Corporation', 'US'], + ['KHC', 'Kraft Heinz', 'US'], + ['KR', 'Kroger', 'US'], + ['LHX', 'L3Harris', 'US'], + ['LH', 'Labcorp', 'US'], + ['LRCX', 'Lam Research', 'US'], + ['LVS', 'Las Vegas Sands', 'US'], + ['LDOS', 'Leidos', 'US'], + ['LEN', 'Lennar', 'US'], + ['LII', 'Lennox International', 'US'], + ['LLY', 'Lilly (Eli)', 'US'], + ['LIN', 'Linde plc', 'US'], + ['LYV', 'Live Nation Entertainment', 'US'], + ['LMT', 'Lockheed Martin', 'US'], + ['L', 'Loews Corporation', 'US'], + ['LOW', "Lowe's", 'US'], + ['LULU', 'Lululemon Athletica', 'US'], + ['LITE', 'Lumentum', 'US'], + ['LYB', 'LyondellBasell', 'US'], + ['MTB', 'M&T Bank', 'US'], + ['MPC', 'Marathon Petroleum', 'US'], + ['MAR', 'Marriott International', 'US'], + ['MRSH', 'Marsh McLennan', 'US'], + ['MLM', 'Martin Marietta Materials', 'US'], + ['MRVL', 'Marvell Technology', 'US'], + ['MAS', 'Masco', 'US'], + ['MA', 'Mastercard', 'US'], + ['MKC', 'McCormick & Company', 'US'], + ['MCD', "McDonald's", 'US'], + ['MCK', 'McKesson Corporation', 'US'], + ['MDT', 'Medtronic', 'US'], + ['MRK', 'Merck & Co.', 'US'], + ['META', 'Meta Platforms', 'US'], + ['MET', 'MetLife', 'US'], + ['MTD', 'Mettler Toledo', 'US'], + ['MGM', 'MGM Resorts', 'US'], + ['MCHP', 'Microchip Technology', 'US'], + ['MU', 'Micron Technology', 'US'], + ['MSFT', 'Microsoft', 'US'], + ['MAA', 'Mid-America Apartment Communities', 'US'], + ['MRNA', 'Moderna', 'US'], + ['TAP', 'Molson Coors Beverage Company', 'US'], + ['MDLZ', 'Mondelez International', 'US'], + ['MPWR', 'Monolithic Power Systems', 'US'], + ['MNST', 'Monster Beverage', 'US'], + ['MCO', "Moody's Corporation", 'US'], + ['MS', 'Morgan Stanley', 'US'], + ['MOS', 'Mosaic Company (The)', 'US'], + ['MSI', 'Motorola Solutions', 'US'], + ['MSCI', 'MSCI', 'US'], + ['NDAQ', 'Nasdaq, Inc.', 'US'], + ['NTAP', 'NetApp', 'US'], + ['NFLX', 'Netflix', 'US'], + ['NEM', 'Newmont', 'US'], + ['NWSA', 'News Corp (Class A)', 'US'], + ['NWS', 'News Corp (Class B)', 'US'], + ['NEE', 'NextEra Energy', 'US'], + ['NKE', 'Nike, Inc.', 'US'], + ['NI', 'NiSource', 'US'], + ['NDSN', 'Nordson Corporation', 'US'], + ['NSC', 'Norfolk Southern', 'US'], + ['NTRS', 'Northern Trust', 'US'], + ['NOC', 'Northrop Grumman', 'US'], + ['NCLH', 'Norwegian Cruise Line Holdings', 'US'], + ['NRG', 'NRG Energy', 'US'], + ['NUE', 'Nucor', 'US'], + ['NVDA', 'Nvidia', 'US'], + ['NVR', 'NVR, Inc.', 'US'], + ['NXPI', 'NXP Semiconductors', 'US'], + ['ORLY', "O'Reilly Automotive", 'US'], + ['OXY', 'Occidental Petroleum', 'US'], + ['ODFL', 'Old Dominion', 'US'], + ['OMC', 'Omnicom Group', 'US'], + ['ON', 'ON Semiconductor', 'US'], + ['OKE', 'Oneok', 'US'], + ['ORCL', 'Oracle Corporation', 'US'], + ['OTIS', 'Otis Worldwide', 'US'], + ['PCAR', 'Paccar', 'US'], + ['PKG', 'Packaging Corporation of America', 'US'], + ['PLTR', 'Palantir Technologies', 'US'], + ['PANW', 'Palo Alto Networks', 'US'], + ['PSKY', 'Paramount Skydance Corporation', 'US'], + ['PH', 'Parker Hannifin', 'US'], + ['PAYX', 'Paychex', 'US'], + ['PYPL', 'PayPal', 'US'], + ['PNR', 'Pentair', 'US'], + ['PEP', 'PepsiCo', 'US'], + ['PFE', 'Pfizer', 'US'], + ['PCG', 'PG&E Corporation', 'US'], + ['PM', 'Philip Morris International', 'US'], + ['PSX', 'Phillips 66', 'US'], + ['PNW', 'Pinnacle West Capital', 'US'], + ['PNC', 'PNC Financial Services', 'US'], + ['PPG', 'PPG Industries', 'US'], + ['PPL', 'PPL Corporation', 'US'], + ['PFG', 'Principal Financial Group', 'US'], + ['PG', 'Procter & Gamble', 'US'], + ['PGR', 'Progressive Corporation', 'US'], + ['PLD', 'Prologis', 'US'], + ['PRU', 'Prudential Financial', 'US'], + ['PEG', 'Public Service Enterprise Group', 'US'], + ['PTC', 'PTC Inc.', 'US'], + ['PSA', 'Public Storage', 'US'], + ['PHM', 'PulteGroup', 'US'], + ['PWR', 'Quanta Services', 'US'], + ['QCOM', 'Qualcomm', 'US'], + ['DGX', 'Quest Diagnostics', 'US'], + ['Q', 'Qnity Electronics', 'US'], + ['RL', 'Ralph Lauren Corporation', 'US'], + ['RJF', 'Raymond James Financial', 'US'], + ['RTX', 'RTX Corporation', 'US'], + ['O', 'Realty Income', 'US'], + ['REG', 'Regency Centers', 'US'], + ['REGN', 'Regeneron Pharmaceuticals', 'US'], + ['RF', 'Regions Financial Corporation', 'US'], + ['RSG', 'Republic Services', 'US'], + ['RMD', 'ResMed|', 'US'], + ['RVTY', 'Revvity', 'US'], + ['HOOD', 'Robinhood Markets', 'US'], + ['ROK', 'Rockwell Automation', 'US'], + ['ROL', 'Rollins, Inc.', 'US'], + ['ROP', 'Roper Technologies', 'US'], + ['ROST', 'Ross Stores', 'US'], + ['RCL', 'Royal Caribbean Group', 'US'], + ['SPGI', 'S&P Global', 'US'], + ['CRM', 'Salesforce', 'US'], + ['SNDK', 'Sandisk', 'US'], + ['SBAC', 'SBA Communications', 'US'], + ['SLB', 'Schlumberger', 'US'], + ['STX', 'Seagate Technology', 'US'], + ['SRE', 'Sempra', 'US'], + ['NOW', 'ServiceNow', 'US'], + ['SHW', 'Sherwin-Williams', 'US'], + ['SPG', 'Simon Property Group', 'US'], + ['SWKS', 'Skyworks Solutions', 'US'], + ['SJM', 'J.M. Smucker Company (The)', 'US'], + ['SW', 'Smurfit Westrock', 'US'], + ['SNA', 'Snap-on', 'US'], + ['SOLV', 'Solventum', 'US'], + ['SO', 'Southern Company', 'US'], + ['LUV', 'Southwest Airlines', 'US'], + ['SWK', 'Stanley Black & Decker', 'US'], + ['SBUX', 'Starbucks', 'US'], + ['STT', 'State Street Corporation', 'US'], + ['STLD', 'Steel Dynamics', 'US'], + ['STE', 'Steris', 'US'], + ['SYK', 'Stryker Corporation', 'US'], + ['SMCI', 'Supermicro', 'US'], + ['SYF', 'Synchrony Financial', 'US'], + ['SNPS', 'Synopsys', 'US'], + ['SYY', 'Sysco', 'US'], + ['TMUS', 'T-Mobile US', 'US'], + ['TROW', 'T. Rowe Price', 'US'], + ['TTWO', 'Take-Two Interactive', 'US'], + ['TPR', 'Tapestry, Inc.', 'US'], + ['TRGP', 'Targa Resources', 'US'], + ['TGT', 'Target Corporation', 'US'], + ['TEL', 'TE Connectivity', 'US'], + ['TDY', 'Teledyne Technologies', 'US'], + ['TER', 'Teradyne', 'US'], + ['TSLA', 'Tesla, Inc.', 'US'], + ['TXN', 'Texas Instruments', 'US'], + ['TPL', 'Texas Pacific Land Corporation', 'US'], + ['TXT', 'Textron', 'US'], + ['TMO', 'Thermo Fisher Scientific', 'US'], + ['TJX', 'TJX Companies', 'US'], + ['TKO', 'TKO Group Holdings', 'US'], + ['TTD', 'Trade Desk (The)', 'US'], + ['TSCO', 'Tractor Supply', 'US'], + ['TT', 'Trane Technologies', 'US'], + ['TDG', 'TransDigm Group', 'US'], + ['TRV', 'Travelers Companies (The)', 'US'], + ['TRMB', 'Trimble Inc.', 'US'], + ['TFC', 'Truist Financial', 'US'], + ['TYL', 'Tyler Technologies', 'US'], + ['TSN', 'Tyson Foods', 'US'], + ['USB', 'U.S. Bancorp', 'US'], + ['UBER', 'Uber', 'US'], + ['UDR', 'UDR, Inc.', 'US'], + ['ULTA', 'Ulta Beauty', 'US'], + ['UNP', 'Union Pacific Corporation', 'US'], + ['UAL', 'United Airlines Holdings', 'US'], + ['UPS', 'United Parcel Service', 'US'], + ['URI', 'United Rentals', 'US'], + ['UNH', 'UnitedHealth Group', 'US'], + ['UHS', 'Universal Health Services', 'US'], + ['VLO', 'Valero Energy', 'US'], + ['VEEV', 'Veeva Systems', 'US'], + ['VTR', 'Ventas', 'US'], + ['VLTO', 'Veralto', 'US'], + ['VRSN', 'Verisign', 'US'], + ['VRSK', 'Verisk Analytics', 'US'], + ['VZ', 'Verizon', 'US'], + ['VRTX', 'Vertex Pharmaceuticals', 'US'], + ['VRT', 'Vertiv', 'US'], + ['VTRS', 'Viatris', 'US'], + ['VICI', 'Vici Properties', 'US'], + ['V', 'Visa Inc.', 'US'], + ['VST', 'Vistra Corp.', 'US'], + ['VMC', 'Vulcan Materials Company', 'US'], + ['WRB', 'W. R. Berkley Corporation', 'US'], + ['GWW', 'W. W. Grainger', 'US'], + ['WAB', 'Wabtec', 'US'], + ['WMT', 'Walmart', 'US'], + ['DIS', 'Walt Disney Company (The)', 'US'], + ['WBD', 'Warner Bros. Discovery', 'US'], + ['WM', 'Waste Management', 'US'], + ['WAT', 'Waters Corporation', 'US'], + ['WEC', 'WEC Energy Group', 'US'], + ['WFC', 'Wells Fargo', 'US'], + ['WELL', 'Welltower', 'US'], + ['WST', 'West Pharmaceutical Services', 'US'], + ['WDC', 'Western Digital', 'US'], + ['WY', 'Weyerhaeuser', 'US'], + ['WSM', 'Williams-Sonoma, Inc.', 'US'], + ['WMB', 'Williams Companies', 'US'], + ['WTW', 'Willis Towers Watson', 'US'], + ['WDAY', 'Workday, Inc.', 'US'], + ['WYNN', 'Wynn Resorts', 'US'], + ['XEL', 'Xcel Energy', 'US'], + ['XYL', 'Xylem Inc.', 'US'], + ['YUM', 'Yum! Brands', 'US'], + ['ZBRA', 'Zebra Technologies', 'US'], + ['ZBH', 'Zimmer Biomet', 'US'], + ['ZTS', 'Zoetis', 'US'], +]) + +/** + * Representative liquid international listings used to diversify the fixture. + * Symbols use their local-market form and the third tuple value is an ISO-style + * country/market code, rather than a trading currency or exchange MIC. + * + * References checked 2026-08-15: STOXX Europe 50, KRX KOSPI market, + * JPX TOPIX Core30, and HKEX index constituent materials. + */ +const europeanInstruments = Object.freeze([ + ['ASML', 'ASML Holding', 'NL'], + ['INGA', 'ING Group', 'NL'], + ['ADYEN', 'Adyen', 'NL'], + ['PHIA', 'Philips', 'NL'], + ['HEIA', 'Heineken', 'NL'], + ['SAP', 'SAP', 'DE'], + ['SIE', 'Siemens', 'DE'], + ['ALV', 'Allianz', 'DE'], + ['DTE', 'Deutsche Telekom', 'DE'], + ['MBG', 'Mercedes-Benz Group', 'DE'], + ['BMW', 'BMW', 'DE'], + ['BAS', 'BASF', 'DE'], + ['MUV2', 'Munich Re', 'DE'], + ['VOW3', 'Volkswagen Preference', 'DE'], + ['IFX', 'Infineon Technologies', 'DE'], + ['MC', 'LVMH', 'FR'], + ['OR', "L'Oréal", 'FR'], + ['AIR', 'Airbus', 'FR'], + ['SU', 'Schneider Electric', 'FR'], + ['TTE', 'TotalEnergies', 'FR'], + ['SAN', 'Sanofi', 'FR'], + ['BNP', 'BNP Paribas', 'FR'], + ['CS', 'AXA', 'FR'], + ['DG', 'Vinci', 'FR'], + ['ENEL', 'Enel', 'IT'], + ['ENI', 'Eni', 'IT'], + ['ISP', 'Intesa Sanpaolo', 'IT'], + ['UCG', 'UniCredit', 'IT'], + ['STLAM', 'Stellantis', 'IT'], + ['SAN', 'Banco Santander', 'ES'], + ['IBE', 'Iberdrola', 'ES'], + ['ITX', 'Inditex', 'ES'], + ['BBVA', 'BBVA', 'ES'], + ['NESN', 'Nestlé', 'CH'], + ['ROG', 'Roche Holding', 'CH'], + ['NOVN', 'Novartis', 'CH'], + ['UBSG', 'UBS Group', 'CH'], + ['NOVO-B', 'Novo Nordisk', 'DK'], + ['MAERSK-B', 'A.P. Moller - Maersk', 'DK'], + ['VOLV-B', 'Volvo', 'SE'], + ['ERIC-B', 'Ericsson', 'SE'], + ['NOKIA', 'Nokia', 'FI'], + ['SHEL', 'Shell', 'GB'], + ['AZN', 'AstraZeneca', 'GB'], + ['HSBA', 'HSBC Holdings', 'GB'], + ['ULVR', 'Unilever', 'GB'], + ['LSEG', 'London Stock Exchange Group', 'GB'], +]) + +const europeanMarketCodes = Object.freeze([ + 'NL', + 'DE', + 'FR', + 'IT', + 'ES', + 'CH', + 'DK', + 'SE', + 'FI', + 'GB', +]) + +const europeanMarketGroups = Object.freeze( + europeanMarketCodes.map((market) => + europeanInstruments.filter(([, , instrumentMarket]) => + Object.is(instrumentMarket, market), + ), + ), +) + +const interleavedEuropeanInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...europeanMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + europeanMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const southKoreanInstruments = Object.freeze([ + ['005930', 'Samsung Electronics', 'KR'], + ['000660', 'SK hynix', 'KR'], + ['373220', 'LG Energy Solution', 'KR'], + ['207940', 'Samsung Biologics', 'KR'], + ['005380', 'Hyundai Motor', 'KR'], + ['000270', 'Kia', 'KR'], + ['068270', 'Celltrion', 'KR'], + ['105560', 'KB Financial Group', 'KR'], + ['055550', 'Shinhan Financial Group', 'KR'], + ['035420', 'NAVER', 'KR'], + ['035720', 'Kakao', 'KR'], + ['006400', 'Samsung SDI', 'KR'], + ['051910', 'LG Chem', 'KR'], + ['012330', 'Hyundai Mobis', 'KR'], + ['066570', 'LG Electronics', 'KR'], +]) + +const japaneseInstruments = Object.freeze([ + ['8306', 'Mitsubishi UFJ Financial Group', 'JP'], + ['7203', 'Toyota Motor', 'JP'], + ['6501', 'Hitachi', 'JP'], + ['8316', 'Sumitomo Mitsui Financial Group', 'JP'], + ['6758', 'Sony Group', 'JP'], + ['8058', 'Mitsubishi Corporation', 'JP'], + ['9984', 'SoftBank Group', 'JP'], + ['8035', 'Tokyo Electron', 'JP'], + ['8411', 'Mizuho Financial Group', 'JP'], + ['8031', 'Mitsui & Co.', 'JP'], + ['6861', 'Keyence', 'JP'], + ['7974', 'Nintendo', 'JP'], + ['6098', 'Recruit Holdings', 'JP'], + ['9432', 'Nippon Telegraph and Telephone', 'JP'], + ['4063', 'Shin-Etsu Chemical', 'JP'], +]) + +const hongKongInstruments = Object.freeze([ + ['0700', 'Tencent Holdings', 'HK'], + ['9988', 'Alibaba Group', 'HK'], + ['1810', 'Xiaomi', 'HK'], + ['3690', 'Meituan', 'HK'], + ['0941', 'China Mobile', 'HK'], + ['1211', 'BYD Company', 'HK'], + ['1299', 'AIA Group', 'HK'], + ['0388', 'Hong Kong Exchanges and Clearing', 'HK'], + ['0005', 'HSBC Holdings', 'HK'], + ['2318', 'Ping An Insurance', 'HK'], +]) + +const canadianInstruments = Object.freeze([ + ['RY', 'Royal Bank of Canada', 'CA'], + ['TD', 'Toronto-Dominion Bank', 'CA'], + ['SHOP', 'Shopify', 'CA'], + ['ENB', 'Enbridge', 'CA'], + ['CNR', 'Canadian National Railway', 'CA'], + ['CP', 'Canadian Pacific Kansas City', 'CA'], + ['BMO', 'Bank of Montreal', 'CA'], + ['CSU', 'Constellation Software', 'CA'], +]) + +const australianInstruments = Object.freeze([ + ['BHP', 'BHP Group', 'AU'], + ['CBA', 'Commonwealth Bank of Australia', 'AU'], + ['CSL', 'CSL', 'AU'], + ['NAB', 'National Australia Bank', 'AU'], + ['WBC', 'Westpac Banking Corporation', 'AU'], + ['ANZ', 'ANZ Group Holdings', 'AU'], + ['WES', 'Wesfarmers', 'AU'], + ['MQG', 'Macquarie Group', 'AU'], +]) + +const internationalMarketGroups = Object.freeze([ + interleavedEuropeanInstruments, + southKoreanInstruments, + japaneseInstruments, + hongKongInstruments, + canadianInstruments, + australianInstruments, +]) + +export const internationalInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...internationalMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + internationalMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const INTERNATIONAL_INSERTION_INTERVAL = 3 + +/** + * U.S. and international instruments are interleaved so ordinary benchmark + * sizes exercise multiple symbol formats and market labels. + */ +export const globalInstruments = Object.freeze( + marketInstruments.flatMap((instrument, index) => { + const internationalInstrument = + index % INTERNATIONAL_INSERTION_INTERVAL === 0 + ? internationalInstruments[index / INTERNATIONAL_INSERTION_INTERVAL] + : undefined + + return internationalInstrument + ? [instrument, internationalInstrument] + : [instrument] + }), +) as unknown as ReadonlyArray diff --git a/examples/solid/realtime-trading/src/feed/worker/market-feed-engine.ts b/examples/solid/realtime-trading/src/feed/worker/market-feed-engine.ts new file mode 100644 index 0000000000..fbd9c369c0 --- /dev/null +++ b/examples/solid/realtime-trading/src/feed/worker/market-feed-engine.ts @@ -0,0 +1,177 @@ +import { globalInstruments } from '../market-instruments.ts' +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const INITIAL_MARKET_SEED = 0x4d41524b +const LIVE_FEED_SEED = 0x5449434b + +export class MarketFeedEngine { + #quotes: Array = [] + #lastHistorySampledAt = new Uint32Array(0) + #random = createRandom(2_026) + #rowCursor = 0 + #tickIndex = 0 + + reset(count: number): Array { + const random = createRandom(INITIAL_MARKET_SEED ^ count) + const createdAt = Date.now() + + this.#quotes = Array.from({ length: count }, (_, index) => { + const [baseSymbol, company, market] = + globalInstruments[index % globalInstruments.length] + const series = Math.floor(index / globalInstruments.length) + const symbol = series === 0 ? baseSymbol : `${baseSymbol}${series}` + const previousClose = roundPrice(20 + random() * 480) + const open = roundPrice(previousClose * (1 + (random() - 0.5) * 0.016)) + const spread = Math.max(0.01, open * (0.0002 + random() * 0.0004)) + const history = Array.from({ length: 24 }, (_, historyIndex) => + roundPrice( + open * + (1 + Math.sin(historyIndex / 4) * 0.002 + (random() - 0.5) * 0.001), + ), + ) + const volume = Math.floor(50_000 + random() * 2_000_000) + const lastSize = Math.floor(10 + random() * 5_000) + + return { + id: `instrument-${index}`, + symbol, + company, + venue: market, + previousClose, + open, + high: open, + low: open, + price: open, + bid: roundPrice(open - spread / 2), + ask: roundPrice(open + spread / 2), + bidSize: Math.floor(100 + random() * 25_000), + askSize: Math.floor(100 + random() * 25_000), + lastSize, + lastMove: 0, + lastUpdatedAt: createdAt, + volume, + turnover: roundMoney(open * volume), + history, + } + }) + + this.#random = createRandom(LIVE_FEED_SEED ^ count) + this.#rowCursor = 0 + this.#lastHistorySampledAt = new Uint32Array(count) + this.#lastHistorySampledAt.fill(createdAt >>> 0) + + return this.#quotes.map((quote) => ({ + ...quote, + history: [...quote.history], + })) + } + + applyTicks( + tickCount: number, + updateSparklines: boolean, + sparklineSampleIntervalMs: number, + ): Array { + if (this.#quotes.length === 0 || tickCount <= 0) return [] + + const updatedAt = Date.now() + const sampledAt = updatedAt >>> 0 + const sampleIntervalMs = Math.max(16, sparklineSampleIntervalMs) + const updatedQuotes = new Map() + const stride = 97 + + this.#tickIndex = 0 + while (this.#tickIndex < tickCount) { + this.#rowCursor = (this.#rowCursor + stride) % this.#quotes.length + const quote = this.#quotes[this.#rowCursor] + const lastSampledAt = this.#lastHistorySampledAt[this.#rowCursor] + const shouldUpdateHistory = + updateSparklines && + (sampledAt - lastSampledAt) >>> 0 >= sampleIntervalMs + + if (shouldUpdateHistory) { + this.#lastHistorySampledAt[this.#rowCursor] = sampledAt + } + + this.#applyTick(quote, shouldUpdateHistory, updatedAt) + + const previousUpdate = updatedQuotes.get(this.#rowCursor) + updatedQuotes.set(this.#rowCursor, { + index: this.#rowCursor, + price: quote.price, + bid: quote.bid, + ask: quote.ask, + bidSize: quote.bidSize, + askSize: quote.askSize, + lastSize: quote.lastSize, + lastMove: quote.lastMove, + lastUpdatedAt: quote.lastUpdatedAt, + high: quote.high, + low: quote.low, + volume: quote.volume, + turnover: quote.turnover, + ...(shouldUpdateHistory || previousUpdate?.history + ? { history: [...quote.history] } + : {}), + }) + this.#tickIndex++ + } + + return [...updatedQuotes.values()] + } + + #applyTick( + quote: MarketQuoteSnapshot, + updateHistory: boolean, + updatedAt: number, + ): void { + const previousPrice = quote.price + const volatility = 0.00015 + this.#random() * 0.0012 + const move = previousPrice * (this.#random() - 0.495) * volatility + const nextPrice = roundPrice(Math.max(0.1, previousPrice + move)) + const spread = Math.max( + 0.01, + nextPrice * (0.00015 + this.#random() * 0.0005), + ) + + quote.lastMove = nextPrice - previousPrice + quote.price = nextPrice + quote.high = Math.max(quote.high, nextPrice) + quote.low = Math.min(quote.low, nextPrice) + quote.bid = roundPrice(nextPrice - spread / 2) + quote.ask = roundPrice(nextPrice + spread / 2) + quote.bidSize = Math.floor(100 + this.#random() * 25_000) + quote.askSize = Math.floor(100 + this.#random() * 25_000) + quote.lastSize = Math.floor(10 + this.#random() * 5_000) + quote.lastUpdatedAt = updatedAt + quote.volume += quote.lastSize + quote.turnover = roundMoney(quote.turnover + nextPrice * quote.lastSize) + + if (updateHistory) { + quote.history = [...quote.history.slice(-23), nextPrice] + } + } +} + +function createRandom(seed: number): () => number { + const runtime = { state: seed >>> 0 } + return () => { + runtime.state += 0x6d2b79f5 + const stateValue = runtime.state + const firstMix = Math.imul(stateValue ^ (stateValue >>> 15), stateValue | 1) + const secondMix = + firstMix + Math.imul(firstMix ^ (firstMix >>> 7), firstMix | 61) + const value = firstMix ^ secondMix + return ((value ^ (value >>> 14)) >>> 0) / 4_294_967_296 + } +} + +function roundPrice(value: number): number { + return Math.round(value * 100) / 100 +} + +function roundMoney(value: number): number { + return Math.round(value * 100) / 100 +} diff --git a/examples/solid/realtime-trading/src/feed/worker/market-feed-protocol.ts b/examples/solid/realtime-trading/src/feed/worker/market-feed-protocol.ts new file mode 100644 index 0000000000..21997ec89c --- /dev/null +++ b/examples/solid/realtime-trading/src/feed/worker/market-feed-protocol.ts @@ -0,0 +1,70 @@ +export interface MarketQuoteSnapshot { + id: string + symbol: string + company: string + venue: string + previousClose: number + open: number + high: number + low: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + volume: number + turnover: number + history: Array +} + +export interface MarketQuoteUpdate { + index: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + high: number + low: number + volume: number + turnover: number + history?: Array +} + +export type MarketFeedCommand = + | { + type: 'start' + rowCount: number + running: boolean + ticksPerSecond: number + publishIntervalMs: number + updateSparklines: boolean + sparklineSampleIntervalMs: number + } + | { type: 'set-running'; running: boolean } + | { type: 'set-rate'; ticksPerSecond: number } + | { type: 'set-publish-interval'; intervalMs: number } + | { type: 'set-sparklines'; enabled: boolean } + | { type: 'set-sparkline-interval'; intervalMs: number } + | { type: 'reset'; rowCount: number } + | { type: 'burst'; tickCount: number } + +export type MarketFeedEvent = + | { + type: 'snapshot' + sessionId: number + quotes: Array + } + | { + type: 'updates' + sessionId: number + tickCount: number + coalescedUpdateCount: number + updates: Array + } diff --git a/examples/solid/realtime-trading/src/feed/worker/market-feed.worker.ts b/examples/solid/realtime-trading/src/feed/worker/market-feed.worker.ts new file mode 100644 index 0000000000..2b7a642fd9 --- /dev/null +++ b/examples/solid/realtime-trading/src/feed/worker/market-feed.worker.ts @@ -0,0 +1,143 @@ +import { initialMarketFeedConfig } from '../market-feed-config' +import { MarketFeedEngine } from './market-feed-engine' +import type { + MarketFeedCommand, + MarketFeedEvent, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const engine = new MarketFeedEngine() +const pendingUpdates = new Map() +const runtime = { + sessionId: 0, + pendingTickCount: 0, + pendingCoalescedUpdateCount: 0, + initialized: false, + running: true, + ticksPerSecond: initialMarketFeedConfig.targetSamplesPerSecond, + publishIntervalMs: initialMarketFeedConfig.publishIntervalMs, + publishTimerId: null as ReturnType | null, + updateSparklines: initialMarketFeedConfig.updateSparklines, + sparklineSampleIntervalMs: initialMarketFeedConfig.sparklineSampleIntervalMs, + tickBudget: 0, + lastTickAt: performance.now(), +} + +addEventListener('message', ({ data }: MessageEvent) => { + switch (data.type) { + case 'start': + runtime.running = data.running + runtime.ticksPerSecond = data.ticksPerSecond + runtime.publishIntervalMs = data.publishIntervalMs + runtime.updateSparklines = data.updateSparklines + runtime.sparklineSampleIntervalMs = data.sparklineSampleIntervalMs + restartPublishTimer() + reset(data.rowCount) + break + case 'set-running': + runtime.running = data.running + break + case 'set-rate': + runtime.ticksPerSecond = data.ticksPerSecond + break + case 'set-publish-interval': + runtime.publishIntervalMs = Math.max(4, data.intervalMs) + restartPublishTimer() + break + case 'set-sparklines': + runtime.updateSparklines = data.enabled + break + case 'set-sparkline-interval': + runtime.sparklineSampleIntervalMs = Math.max(16, data.intervalMs) + break + case 'reset': + reset(data.rowCount) + break + case 'burst': + produceTicks(data.tickCount) + flush() + break + } +}) + +setInterval(() => { + const now = performance.now() + const elapsed = Math.min(100, Math.max(0, now - runtime.lastTickAt)) + runtime.lastTickAt = now + + if (runtime.initialized && runtime.running) { + runtime.tickBudget += (runtime.ticksPerSecond * elapsed) / 1_000 + const tickCount = Math.floor(runtime.tickBudget) + runtime.tickBudget -= tickCount + produceTicks(tickCount) + } +}, 16) + +restartPublishTimer() + +function reset(rowCount: number): void { + runtime.initialized = true + runtime.sessionId++ + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + runtime.tickBudget = 0 + runtime.lastTickAt = performance.now() + + post({ + type: 'snapshot', + sessionId: runtime.sessionId, + quotes: engine.reset(rowCount), + }) +} + +function produceTicks(tickCount: number): void { + if (!runtime.initialized || tickCount <= 0) return + + runtime.pendingTickCount += tickCount + for (const update of engine.applyTicks( + tickCount, + runtime.updateSparklines, + runtime.sparklineSampleIntervalMs, + )) { + const previousUpdate = pendingUpdates.get(update.index) + if (previousUpdate) runtime.pendingCoalescedUpdateCount++ + pendingUpdates.set(update.index, { + ...update, + ...(update.history || !previousUpdate?.history + ? {} + : { history: previousUpdate.history }), + }) + } +} + +function flush(): void { + if (runtime.pendingTickCount === 0) return + + const message: MarketFeedEvent = { + type: 'updates', + sessionId: runtime.sessionId, + tickCount: runtime.pendingTickCount, + coalescedUpdateCount: runtime.pendingCoalescedUpdateCount, + updates: [...pendingUpdates.values()], + } + + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + post(message) +} + +function restartPublishTimer(): void { + if (runtime.publishTimerId !== null) { + clearInterval(runtime.publishTimerId) + } + runtime.publishTimerId = setInterval( + flush, + Math.max(4, runtime.publishIntervalMs), + ) +} + +function post(event: MarketFeedEvent): void { + postMessage(event) +} diff --git a/examples/solid/realtime-trading/src/index.css b/examples/solid/realtime-trading/src/index.css new file mode 100644 index 0000000000..397c86fc54 --- /dev/null +++ b/examples/solid/realtime-trading/src/index.css @@ -0,0 +1,1058 @@ +:root { + color-scheme: dark; + --font-ui: + Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, + 'Segoe UI', sans-serif; + --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace; + font-family: var(--font-ui); + font-synthesis: none; + --background: #050505; + --panel: #080808; + --panel-raised: #111111; + --panel-hover: #181818; + --surface-bar: #080808; + --surface-toolbar: #0d0d0d; + --surface-table: #050505; + --surface-header: #101010; + --surface-control: #151515; + --border: #303030; + --border-soft: #242424; + --border-strong: #4a4a4a; + --text: #e7ebf0; + --text-strong: #ffffff; + --text-inverse: #f7f9fb; + --muted: #737982; + --blue: #62a9ff; + --blue-soft: #a9d0ff; + --green: #42e488; + --red: #ff646b; + --amber: #dfb465; + --depth-bid: #315774; + --depth-ask: #634049; + --row-alt: rgb(255 255 255 / 1.8%); + --row-selected: rgb(66 132 214 / 16%); + --control-border: #354456; + --control-hover: #192431; + --sidebar-width: 18rem; + --shell-bar-height: 2.625rem; + --metrics-height: 3.5rem; + --statusbar-height: 1.625rem; + --virtual-footer-height: 2.125rem; + --table-header-height: 2rem; + --table-row-height: 2rem; + --shell-inline-padding: 0.75rem; + --table-cell-inline-padding: 0.6rem; + --control-radius: 1px; +} + +* { + box-sizing: border-box; +} + +html, +body { + min-width: 320px; + min-height: 100%; + margin: 0; + background: var(--background); +} + +body { + color: var(--text); +} + +button, +select, +input { + font: inherit; +} + +button, +select { + color: var(--text); + background: var(--panel-raised); + border: 1px solid var(--control-border); + border-radius: var(--control-radius); +} + +button { + padding: 0.5rem 0.65rem; + cursor: pointer; + font-size: 0.72rem; + font-weight: 650; + letter-spacing: 0.025em; +} + +button:hover { + background: var(--control-hover); + border-color: var(--border-strong); +} + +button:focus-visible, +select:focus-visible, +input:focus-visible { + outline: 1px solid var(--blue); + outline-offset: 1px; +} + +select { + width: 100%; + padding: 0.45rem 0.55rem; + font-size: 0.75rem; +} + +.trading-terminal { + --active-sidebar-width: var(--sidebar-width); + display: grid; + width: 100%; + height: 100dvh; + min-height: 0; + overflow: hidden; + background: var(--background); + grid-template-areas: + 'header sidebar' + 'content sidebar' + 'footer sidebar'; + grid-template-columns: minmax(0, 1fr) var(--active-sidebar-width); + grid-template-rows: auto minmax(0, 1fr) auto; + transition: grid-template-columns 160ms ease; +} + +.trading-terminal.is-sidebar-collapsed { + --active-sidebar-width: 0px; +} + +.shell-header { + display: flex; + min-width: 0; + flex-direction: column; + grid-area: header; +} + +.app-bar { + display: flex; + min-height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + background: var(--surface-bar); + border-bottom: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.68rem; + letter-spacing: 0.045em; +} + +.brand, +.header-actions, +.feed-status { + display: flex; + align-items: center; +} + +.brand { + gap: 0.65rem; + color: var(--text-strong); +} + +.header-actions { + gap: 0.75rem; +} + +.sidebar-toggle { + display: grid; + width: 1.9rem; + height: 1.9rem; + padding: 0; + place-items: center; + color: var(--muted); + background: transparent; + border-color: transparent; +} + +.sidebar-toggle:hover { + color: var(--text-strong); + background: var(--surface-control); + border-color: var(--border); +} + +.sidebar-toggle svg { + width: 1rem; + height: 1rem; + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-width: 1.4; +} + +.feed-status { + gap: 0.4rem; + color: var(--muted); +} + +.feed-status.is-running { + color: var(--green); +} + +.status-dot { + width: 6px; + height: 6px; + background: var(--muted); + border-radius: 50%; +} + +.feed-status.is-running .status-dot { + background: var(--green); +} + +.development-warning { + flex: 0 0 auto; + padding: 0.3rem 0.75rem; + color: var(--amber); + background: color-mix(in srgb, var(--amber) 8%, var(--background)); + border-bottom: 1px solid color-mix(in srgb, var(--amber) 24%, var(--border)); + font-family: var(--font-mono); + font-size: 0.62rem; + letter-spacing: 0.04em; +} + +.market-panel { + display: flex; + min-width: 0; + min-height: 0; + flex-direction: column; + background: var(--panel); + grid-area: content; +} + +.metrics-strip { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + background: var(--border); + border-bottom: 1px solid var(--border); + gap: 1px; +} + +.metrics-strip h2 { + margin: 0; + padding: 0.65rem var(--shell-inline-padding) 0.45rem; + color: var(--muted); + background: var(--surface-table); + font-size: 0.58rem; + grid-column: 1 / -1; + letter-spacing: 0.075em; +} + +.metrics-strip article { + min-width: 0; + min-height: 4.25rem; + padding: 0.5rem var(--shell-inline-padding); + background: var(--surface-bar); +} + +.metrics-strip span, +.metrics-strip small { + display: block; + color: var(--muted); + font-size: 0.56rem; + letter-spacing: 0.045em; + line-height: 1.35; +} + +.metrics-strip strong { + display: block; + margin: 0.12rem 0 0.08rem; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.88rem; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +.metrics-strip strong.metric-alert { + color: var(--amber); +} + +.table-scroll { + flex: 1; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +.virtual-scroll-footer { + display: flex; + flex: 0 0 auto; + align-items: center; + justify-content: space-between; + min-height: var(--virtual-footer-height); + padding: 0 var(--shell-inline-padding); + color: var(--muted); + background: var(--surface-toolbar); + border-top: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.68rem; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +table { + min-width: 100%; + border-spacing: 0; + table-layout: fixed; + font-family: var(--font-ui); + font-size: 0.78rem; + font-variant-numeric: tabular-nums; +} + +.virtual-table { + display: grid; +} + +.virtual-table thead { + display: grid; +} + +.virtual-table thead tr, +.virtual-table-row { + display: flex; + width: 100%; +} + +.virtual-table th, +.virtual-table-row > td { + flex: 0 0 auto; +} + +.virtual-table-body { + position: relative; + display: grid; +} + +.virtual-table-row { + position: absolute; + left: 0; + height: var(--table-row-height); +} + +.virtual-table-row > td { + display: block; +} + +.trading-data-grid { + display: grid; +} + +.trading-data-grid thead, +.trading-data-grid tbody { + display: grid; +} + +.trading-data-grid tbody { + -webkit-user-select: none; + user-select: none; +} + +.trading-data-grid thead > tr, +.trading-data-grid tbody > tr { + display: flex; + width: 100%; +} + +.trading-data-grid tbody > tr { + min-height: var(--table-row-height); + content-visibility: auto; + contain-intrinsic-block-size: var(--table-row-height); +} + +.trading-data-grid th, +.trading-data-grid td { + flex: 0 0 auto; +} + +thead { + position: sticky; + z-index: 2; + top: 0; +} + +th { + height: var(--table-header-height); + padding: 0 var(--table-cell-inline-padding); + color: var(--muted); + background: var(--surface-header); + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border); + font-size: 0.7rem; + font-weight: 500; + letter-spacing: 0.005em; + text-align: left; + white-space: nowrap; +} + +th.column-group-header { + color: #666b72; + font-size: 0.72rem; + font-weight: 500; + text-align: center; +} + +thead tr:first-child th.column-group-header { + color: #777d85; + font-size: 0.76rem; +} + +th.numeric-header { + text-align: right; +} + +td { + height: var(--table-row-height); + padding: 0 var(--table-cell-inline-padding); + overflow: hidden; + color: #eef1f5; + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border-soft); + text-align: right; + text-overflow: ellipsis; + white-space: nowrap; +} + +th:last-child, +td:last-child { + border-right: 0; +} + +td[data-column-id='market'], +td[data-column-id='name'], +td[data-column-id='symbol'] { + text-align: left; +} + +td[data-column-id='market'] { + color: var(--blue); + font-weight: 550; +} + +td[data-column-id='name'] { + color: var(--text-strong); +} + +td[data-column-id='symbol'] { + color: #d8dde4; + font-weight: 600; +} + +tbody tr:nth-child(even) { + background: var(--row-alt); +} + +tbody tr:hover { + background: var(--panel-hover); +} + +tbody tr[data-symbol-selected='true'] { + background: var(--row-selected); + box-shadow: inset 2px 0 0 var(--blue); +} + +.table-scroll:focus { + outline: none; +} + +th { + position: relative; +} + +.leaf-header-content { + display: flex; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + height: 100%; + align-items: stretch; + margin-inline: calc(-1 * var(--table-cell-inline-padding)); +} + +.column-drag-handle, +.sort-header-button { + min-width: 0; + height: 100%; + padding: 0; + color: inherit; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-weight: inherit; + letter-spacing: inherit; +} + +.column-drag-handle { + flex: 0 0 1.05rem; + color: var(--muted); + cursor: grab; + opacity: 0.35; + font-size: 0.56rem; + letter-spacing: -0.32rem; + text-align: center; +} + +.column-drag-handle:active { + cursor: grabbing; +} + +th:hover .column-drag-handle, +.column-drag-handle:focus-visible { + opacity: 0.9; +} + +.column-drag-handle:hover, +.sort-header-button:hover { + background: rgb(255 255 255 / 4%); + border-color: transparent; +} + +th.is-column-dragging { + opacity: 0.45; +} + +th.is-column-drop-target { + background: rgb(50 139 255 / 16%); + box-shadow: inset 4px 0 0 var(--blue); +} + +th.is-column-drop-target::before { + position: absolute; + z-index: 6; + top: -1px; + bottom: -1px; + left: -2px; + width: 4px; + background: #62a9ff; + box-shadow: + 0 0 0 1px rgb(0 0 0 / 55%), + 0 0 12px rgb(70 151 255 / 90%); + content: ''; + pointer-events: none; +} + +.sort-header-button { + display: flex; + min-width: 0; + flex: 1; + align-items: center; + justify-content: flex-start; + gap: 0.3rem; + padding-inline: 0.25rem var(--table-cell-inline-padding); + cursor: default; + text-align: inherit; +} + +.numeric-header .sort-header-button { + justify-content: flex-end; +} + +.sort-header-button.is-sortable { + cursor: pointer; +} + +.sort-header-button:disabled { + opacity: 1; +} + +.header-label { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.sort-indicator { + flex: 0 0 auto; + color: #66717e; + font-size: 0.72rem; +} + +.sort-indicator.is-active { + color: var(--blue-soft); +} + +.column-resize-handle { + position: absolute; + z-index: 3; + top: 0; + right: -3px; + width: 7px; + height: 100%; + cursor: col-resize; + touch-action: none; + user-select: none; +} + +.column-resize-handle::after { + position: absolute; + top: 20%; + right: 3px; + width: 1px; + height: 60%; + background: var(--border-strong); + content: ''; + opacity: 0; +} + +th:hover > .column-resize-handle::after, +.column-resize-handle.is-resizing::after { + background: var(--blue); + opacity: 1; +} + +tbody tr[aria-selected='true'] { + background: rgb(76 145 228 / 13%); +} + +td[aria-selected='true'] { + position: relative; + background: rgb(70 139 222 / 12%); +} + +td[data-cell-focused='true'] { + background: rgb(70 139 222 / 21%); +} + +td[aria-selected='true']::after { + position: absolute; + z-index: 1; + inset: 0; + border: 1px solid transparent; + content: ''; + pointer-events: none; +} + +td[data-selection-top='true']::after { + border-top-color: var(--blue); +} + +td[data-selection-right='true']::after { + border-right-color: var(--blue); +} + +td[data-selection-bottom='true']::after { + border-bottom-color: var(--blue); +} + +td[data-selection-left='true']::after { + border-left-color: var(--blue); +} + +.price-button { + min-width: 4.5rem; + padding: 0; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-variant-numeric: tabular-nums; + font-weight: 600; + text-align: right; +} + +.price-button:hover { + background: transparent; + text-decoration: underline; + text-underline-offset: 2px; +} + +.move-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.move-cell.quote-up, +.percent-change-cell.quote-up { + background: color-mix(in srgb, var(--green) 7%, transparent); +} + +.move-cell.quote-down, +.percent-change-cell.quote-down { + background: color-mix(in srgb, var(--red) 7%, transparent); +} + +.percent-change-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.spread-cell { + display: flex; + align-items: baseline; + justify-content: flex-end; + gap: 0.35rem; + color: var(--text); +} + +.spread-cell small { + min-width: 2.8rem; + color: var(--muted); + font-size: 0.55rem; +} + +.spread-cell.spread-wide, +.spread-cell.spread-wide small { + color: var(--amber); +} + +.depth-cell { + position: relative; + display: flex; + height: 17px; + overflow: hidden; + background: var(--surface-control); +} + +.depth-bid, +.depth-ask { + height: 100%; + opacity: 0.78; +} + +.depth-bid { + background: var(--depth-bid); + border-right: 1px solid var(--panel); +} + +.depth-ask { + background: var(--depth-ask); +} + +.depth-values { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 0.28rem; + color: var(--text-strong); + font-size: 0.57rem; + text-shadow: 0 1px var(--background); +} + +.quote-age { + color: var(--muted); +} + +.quote-age-warm { + color: var(--amber); +} + +.quote-age-stale { + color: var(--red); +} + +.quote-up { + color: var(--green); +} + +.quote-down { + color: var(--red); +} + +.sparkline { + display: block; + width: 100%; + height: 1.35rem; + margin-left: auto; + color: var(--blue-soft); + overflow: visible; +} + +.sparkline.quote-up { + color: var(--green); +} + +.sparkline.quote-down { + color: var(--red); +} + +.sparkline polyline { + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-linejoin: miter; + stroke-width: 1.25; + vector-effect: non-scaling-stroke; +} + +.market-statusbar { + display: flex; + flex: 0 0 var(--statusbar-height); + min-height: var(--statusbar-height); + gap: 1.1rem; + align-items: center; + padding: 0 0.65rem; + color: var(--muted); + background: var(--surface-bar); + border-top: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.56rem; + grid-area: footer; + letter-spacing: 0.035em; +} + +.market-statusbar strong { + margin-left: 0.25rem; + color: var(--text); + font-weight: 500; +} + +.sidebar-slot { + width: var(--sidebar-width); + min-width: 0; + min-height: 0; + overflow: hidden; + background: var(--surface-table); + border-left: 1px solid var(--border); + grid-area: sidebar; + transition: + opacity 120ms ease, + transform 160ms ease, + visibility 160ms; +} + +.is-sidebar-collapsed .sidebar-slot { + visibility: hidden; + opacity: 0; + pointer-events: none; + transform: translateX(100%); +} + +.configurator { + width: 100%; + height: 100%; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +.configurator > header { + display: flex; + height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + color: var(--text-strong); + background: var(--surface-toolbar); + border-bottom: 1px solid var(--border); + font-size: 0.65rem; + font-weight: 700; + letter-spacing: 0.055em; +} + +.configurator > header small { + color: var(--muted); + font-size: 0.54rem; + font-weight: 500; +} + +.config-section { + display: grid; + gap: 0.7rem; + padding: 0.8rem var(--shell-inline-padding); + border-bottom: 1px solid var(--border); +} + +.config-section h2 { + margin: 0; + color: var(--muted); + font-size: 0.58rem; + letter-spacing: 0.075em; +} + +.primary-action { + width: 100%; + color: var(--text-inverse); + background: var(--blue); + border-color: var(--blue-soft); +} + +.primary-action:hover { + background: var(--blue-soft); + border-color: var(--text-strong); +} + +.field { + display: grid; + gap: 0.35rem; + color: var(--text); + font-size: 0.66rem; +} + +.rate-field > span { + display: flex; + justify-content: space-between; +} + +.rate-field strong { + color: var(--text); + font-family: var(--font-mono); + font-weight: 500; +} + +.field small { + color: var(--muted); + font-family: var(--font-mono); + font-size: 0.55rem; +} + +input[type='range'] { + width: 100%; + margin: 0; + accent-color: var(--blue); +} + +.toggle-field { + display: flex; + gap: 0.5rem; + align-items: flex-start; + color: var(--text); + font-size: 0.66rem; + line-height: 1.3; +} + +.toggle-field input { + margin: 0.12rem 0 0; + accent-color: var(--blue); +} + +.toggle-field small { + display: block; + margin-top: 0.14rem; + color: var(--muted); + font-size: 0.57rem; +} + +.action-grid { + display: grid; + grid-template-columns: 1fr; + gap: 0.4rem; +} + +.diagnostics dl, +.selected-instrument dl { + display: grid; + gap: 0; + margin: 0; +} + +.diagnostics dl > div, +.selected-instrument dl > div { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 24px; + border-bottom: 1px solid var(--border-soft); +} + +.diagnostics dl > div:last-child, +.selected-instrument dl > div:last-child { + border-bottom: 0; +} + +.diagnostics dl > div:has(dd[data-testid$='-breakdown']) { + display: grid; + grid-template-columns: minmax(0, 1fr); + align-content: center; + padding-block: 0.28rem; +} + +.diagnostics dd[data-testid$='-breakdown'] { + width: 100%; + overflow-x: auto; + padding-block: 0.12rem; + white-space: nowrap; + scrollbar-width: thin; +} + +dt { + color: var(--muted); + font-size: 0.61rem; +} + +dd { + margin: 0; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.62rem; +} + +.selection { + display: flex; + align-items: flex-start; + justify-content: space-between; +} + +.selection div { + display: grid; + gap: 0.18rem; +} + +.selection strong { + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.85rem; +} + +.selection span, +.selection small, +.selected-instrument p { + color: var(--muted); + font-size: 0.61rem; +} + +.selected-instrument p { + margin: 0; + line-height: 1.45; +} + +@media (max-width: 980px) { + :root { + --sidebar-width: 15.625rem; + } +} + +@media (max-width: 720px) { + .trading-terminal { + --active-sidebar-width: 0px; + height: 100dvh; + min-height: 0; + overflow: hidden; + } + + .market-panel { + min-height: 0; + } + + .table-scroll { + min-height: 0; + } + + .sidebar-slot { + position: fixed; + z-index: 20; + top: 0; + right: 0; + bottom: 0; + width: min(var(--sidebar-width), calc(100vw - 2.75rem)); + box-shadow: -18px 0 42px rgb(0 0 0 / 48%); + } + + .is-sidebar-collapsed .sidebar-slot { + box-shadow: none; + } +} diff --git a/examples/solid/realtime-trading/src/index.tsx b/examples/solid/realtime-trading/src/index.tsx new file mode 100644 index 0000000000..3b0ef7f19f --- /dev/null +++ b/examples/solid/realtime-trading/src/index.tsx @@ -0,0 +1,8 @@ +import { render } from 'solid-js/web' +import App from './App' +import './index.css' + +const rootElement = document.getElementById('root') +if (!rootElement) throw new Error('Failed to find the root element') + +render(() => , rootElement) diff --git a/examples/solid/realtime-trading/src/shell/TradingShell.tsx b/examples/solid/realtime-trading/src/shell/TradingShell.tsx new file mode 100644 index 0000000000..8fdf1b60a9 --- /dev/null +++ b/examples/solid/realtime-trading/src/shell/TradingShell.tsx @@ -0,0 +1,601 @@ +import { For, Show, createMemo, createSignal } from 'solid-js' +import { longAnimationFramesSupported } from '../benchmark/benchmark-monitor' +import { + feedSampleRateAt, + feedSampleRateIndex, + feedSampleRateOptions, +} from '../feed/feed-sample-rates' +import { FORCED_VIRTUALIZATION_ROW_COUNT } from '../table/trading-row-virtualizer' +import { + useMarketFeedController, + useTradingShellController, +} from './trading-shell-context' +import { configuratorOptions } from './configurator-options' +import type { JSX } from 'solid-js' +import type { FeedMetrics } from '../benchmark/benchmark-monitor' + +const integerFormatter = new Intl.NumberFormat('en-US', { + maximumFractionDigits: 0, +}) +const rateFormatter = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +export function TradingShell(props: { children: JSX.Element }) { + const [sidebarOpen, setSidebarOpen] = createSignal(true) + const toggleSidebar = () => setSidebarOpen((open) => !open) + + return ( +
+
+ + + + + +
+ +
+ {props.children} +
+ + +
+ ) +} + +function AppHeader(props: { + sidebarOpen: boolean + onSidebarToggle: () => void +}) { + const { workerReady, running } = useMarketFeedController().state + return ( +
+
+ MARKET MONITOR +
+
+ + + +
+
+ ) +} + +function MarketStatusbar() { + const { metrics, mountedCells, liveComponents } = + useTradingShellController().state + return ( +
+ + MESSAGE SAMPLES{' '} + {formatInteger(metrics().lastBatchSize)} + + + CHANGED ROWS {formatInteger(metrics().lastUpdateCount)} + + + HOSTS {formatInteger(mountedCells())} + + + COMPONENTS {formatInteger(liveComponents())} + +
+ ) +} + +function Configurator() { + const { state, actions } = useTradingShellController() + const feed = useMarketFeedController() + const { rendererMode, virtualScrollForced, virtualScrollMode } = state + const { + running, + instrumentCount, + targetTicksPerSecond, + publishIntervalMs, + updateSparklines, + sparklineSampleIntervalMs, + } = feed.state + const { + resetViewState, + setRendererMode, + setVirtualScrollEnabled, + resetMarket, + } = actions + const { + toggle, + setInstrumentCount, + setTargetRate, + setPublishInterval, + setSparklineUpdates, + setSparklineSampleInterval, + runBurst, + } = feed.actions + return ( + + ) +} + +function MetricsStrip() { + const { metrics } = useTradingShellController().state + return ( +
+

LIVE HEALTH

+
+ FRAME RATE (EST.) + + {metrics().rafCallbacksPerSecond.toFixed(1)} + + rAF callbacks/s · rolling 1 s +
+
+ AVG COMMIT + + {formatMs(metrics().averageCommitLatencyMs)} + + snapshot → DOM · rolling 3 s +
+
+ LONG FRAMES + + N/A + unsupported by this browser + + } + > + 0, + }} + > + {metrics().longAnimationFrames} + + + since reset · worst {formatMs(metrics().worstLongAnimationFrameMs)} + + +
+
+ THROUGHPUT + + {formatRate(metrics().rowUpdatesPerSecond)} rows/s + + + {metrics().stateApplicationsPerSecond.toFixed(1)} + snapshots/s · rows deduplicated per snapshot + +
+
+ ) +} + +function Diagnostics() { + const { metrics, mountedCells, liveComponents } = + useTradingShellController().state + return ( +
+

DIAGNOSTICS

+
+
+
Worker samples / s
+
+ {formatRate(metrics().actualTicksPerSecond)} +
+
+
+
Worker messages / s
+
+ {metrics().workerMessagesPerSecond.toFixed(1)} +
+
+
+
Changed rows / s
+
+ {formatRate(metrics().rowUpdatesPerSecond)} +
+
+
+
Snapshots applied / s
+
+ {metrics().stateApplicationsPerSecond.toFixed(1)} +
+
+
+
DOM commits / s
+
+ {metrics().tableCommitsPerSecond.toFixed(1)} +
+
+
+
P95 / max commit latency
+
+ {formatMs(metrics().p95CommitLatencyMs)} /{' '} + {formatMs(metrics().maxCommitLatencyMs)} +
+
+
+
Mounted cells
+
{formatInteger(mountedCells())}
+
+
+
Live components
+
{formatInteger(liveComponents())}
+
+
+
Created / destroyed
+
+ {formatInteger(metrics().componentsCreated)} /{' '} + {formatInteger(metrics().componentsDestroyed)} +
+
+
+
Renderer callbacks / s
+
+ {formatRate(metrics().cellRendererCallsPerSecond)} +
+
+
+
Component executions / s
+
+ {formatRate(metrics().componentRenderCallsPerSecond)} +
+
+
+
Executions by component / s
+
+ {formatInvocationRates(metrics().componentRenderRates)} +
+
+
+
Callbacks by column / s
+
+ {formatInvocationRates(metrics().cellRendererRates)} +
+
+
+
Observed MutationRecords / s
+
+ {formatRate(metrics().domMutationsPerSecond)} +
+
+
+
Worker messages
+
+ {formatInteger(metrics().workerMessages)} +
+
+
+
Worker-coalesced updates / s
+
+ {formatRate(metrics().supersededUpdatesPerSecond)} +
+
+
+
Last message samples / updated rows
+
+ {formatInteger(metrics().lastBatchSize)} /{' '} + {formatInteger(metrics().lastUpdateCount)} +
+
+
+
Commits > 16.7 ms
+
{metrics().slowCommits}
+
+
+
Long animation frames
+
+ {longAnimationFramesSupported + ? formatInteger(metrics().longAnimationFrames) + : 'Unsupported'} +
+
+
+
JS heap (GC-sensitive)
+
+ {metrics().heapMb === null + ? 'N/A' + : `${metrics().heapMb?.toFixed(1)} MB`} +
+
+
+
+ ) +} + +function SelectedInstrument() { + const feed = useMarketFeedController() + const { selectedSymbol } = useTradingShellController().state + const selectedQuote = createMemo(() => + feed.getQuoteBySymbol(selectedSymbol()), + ) + return ( +
+

SELECTED INSTRUMENT

+ + Click or begin a cell selection in any row to inspect its + instrument. +

+ } + > + {(quote) => ( + <> +
+
+ {quote().symbol} + {quote().company} +
+ {quote().venue} +
+
+
+
Last
+
{quote().price.toFixed(2)}
+
+
+
Bid / ask
+
+ {quote().bid.toFixed(2)} / {quote().ask.toFixed(2)} +
+
+
+ + )} +
+
+ ) +} + +function formatInteger(value: number): string { + return integerFormatter.format(value) +} + +function formatRate(value: number): string { + return rateFormatter.format(value) +} + +function formatMs(value: number): string { + return `${value.toFixed(2)} ms` +} + +function formatInvocationRates( + rates: FeedMetrics['componentRenderRates'], +): string { + const activeRates = rates + .filter((rate) => rate.callsPerSecond > 0) + .sort((left, right) => right.callsPerSecond - left.callsPerSecond) + return activeRates.length === 0 + ? 'No calls in sample' + : activeRates + .map((rate) => `${rate.name} ${formatRate(rate.callsPerSecond)}`) + .join(' · ') +} diff --git a/examples/solid/realtime-trading/src/shell/configurator-options.ts b/examples/solid/realtime-trading/src/shell/configurator-options.ts new file mode 100644 index 0000000000..49a9566fe7 --- /dev/null +++ b/examples/solid/realtime-trading/src/shell/configurator-options.ts @@ -0,0 +1,55 @@ +export interface ConfiguratorOption { + readonly label: string + readonly value: TValue +} + +const instrumentCountOptions = [ + { label: '50', value: 50 }, + { label: '100', value: 100 }, + { label: '150', value: 150 }, + { label: '250', value: 250 }, + { label: '350', value: 350 }, + { label: '500', value: 500 }, + { label: '750', value: 750 }, + { label: '1,000', value: 1_000 }, + { label: '1,500', value: 1_500 }, + { label: '2,500', value: 2_500 }, + { label: '5,000', value: 5_000 }, + { label: '1,000,000', value: 1_000_000 }, + { label: '10,000,000', value: 10_000_000 }, +] as const satisfies ReadonlyArray> + +const workerDeliveryOptions = [ + { label: '8 ms · 125 msg/s', value: 8 }, + { label: '16 ms · 62.5 msg/s', value: 16 }, + { label: '20 ms · 50 msg/s', value: 20 }, + { label: '33 ms · 30 msg/s', value: 33 }, + { label: '50 ms · 20 msg/s', value: 50 }, + { label: '100 ms · 10 msg/s', value: 100 }, + { label: '250 ms · 4 msg/s', value: 250 }, + { label: '500 ms · 2 msg/s', value: 500 }, + { label: '1,000 ms · 1 msg/s', value: 1_000 }, +] as const satisfies ReadonlyArray> + +const rowRenderingOptions = [ + { label: 'Full DOM · render every row', value: 'none' }, + { label: 'TanStack Virtual · visible rows only', value: 'tanstack' }, +] as const satisfies ReadonlyArray> + +const intradaySamplingOptions = [ + { label: '16 ms · fastest', value: 16 }, + { label: '33 ms · very fast', value: 33 }, + { label: '50 ms · fast', value: 50 }, + { label: '100 ms', value: 100 }, + { label: '250 ms', value: 250 }, + { label: '500 ms', value: 500 }, + { label: '1,000 ms', value: 1_000 }, + { label: '2,000 ms', value: 2_000 }, +] as const satisfies ReadonlyArray> + +export const configuratorOptions = { + instrumentCounts: instrumentCountOptions, + workerDeliveryIntervals: workerDeliveryOptions, + rowRenderingModes: rowRenderingOptions, + intradaySamplingIntervals: intradaySamplingOptions, +} as const diff --git a/examples/solid/realtime-trading/src/shell/trading-shell-context.tsx b/examples/solid/realtime-trading/src/shell/trading-shell-context.tsx new file mode 100644 index 0000000000..906f35e52e --- /dev/null +++ b/examples/solid/realtime-trading/src/shell/trading-shell-context.tsx @@ -0,0 +1,51 @@ +import { createContext, useContext } from 'solid-js' +import type { JSX } from 'solid-js' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +const TradingShellContext = createContext() +const MarketFeedContext = createContext() + +export function MarketFeedProvider(props: { + controller: MarketFeedController + children: JSX.Element +}) { + return ( + + {props.children} + + ) +} + +export function TradingShellProvider(props: { + controller: TradingBenchmarkController + children: JSX.Element +}) { + return ( + + + {props.children} + + + ) +} + +export function useMarketFeedController(): MarketFeedController { + const controller = useContext(MarketFeedContext) + if (!controller) { + throw new Error( + 'Market data consumers must be rendered inside MarketFeedProvider', + ) + } + return controller +} + +export function useTradingShellController(): TradingBenchmarkController { + const controller = useContext(TradingShellContext) + if (!controller) { + throw new Error( + 'Trading shell components must be rendered inside TradingShellProvider', + ) + } + return controller +} diff --git a/examples/solid/realtime-trading/src/table/create-column-drag.ts b/examples/solid/realtime-trading/src/table/create-column-drag.ts new file mode 100644 index 0000000000..2acf3b96ba --- /dev/null +++ b/examples/solid/realtime-trading/src/table/create-column-drag.ts @@ -0,0 +1,66 @@ +import { createSignal } from 'solid-js' +import { reorderColumnIds } from './table-interactions' +import type { JSX } from 'solid-js' +import type { TradingTableInstance } from './trading-table-features' + +export function createColumnDrag(table: TradingTableInstance) { + const [sourceColumnId, setSourceColumnId] = createSignal(null) + const [targetColumnId, setTargetColumnId] = createSignal(null) + + const clear = (): void => { + setSourceColumnId(null) + setTargetColumnId(null) + } + + const createDropZoneProps = ( + columnId: string, + ): Pick => ({ + onDragOver(event) { + event.preventDefault() + setTargetColumnId(sourceColumnId() === columnId ? null : columnId) + }, + onDrop(event) { + event.preventDefault() + const sourceId = + event.dataTransfer?.getData('text/plain') || sourceColumnId() + if (sourceId) { + table.setColumnOrder( + reorderColumnIds( + table.getVisibleLeafColumns().map((column) => column.id), + sourceId, + columnId, + ), + ) + } + clear() + }, + }) + + const createHandleProps = ( + columnId: string, + ): Pick< + JSX.IntrinsicElements['button'], + 'draggable' | 'aria-label' | 'onDragStart' | 'onDragEnd' + > => ({ + draggable: true, + 'aria-label': `Move ${columnId} column`, + onDragStart(event) { + setSourceColumnId(columnId) + const dataTransfer = event.dataTransfer + if (!dataTransfer) return + + dataTransfer.effectAllowed = 'move' + dataTransfer.setData('text/plain', columnId) + }, + onDragEnd: clear, + }) + + return { + createDropZoneProps, + createHandleProps, + isDragging: (columnId: string) => sourceColumnId() === columnId, + isDropTarget: (columnId: string) => targetColumnId() === columnId, + } +} + +export type ColumnDrag = ReturnType diff --git a/examples/solid/realtime-trading/src/table/create-trading-table-model.ts b/examples/solid/realtime-trading/src/table/create-trading-table-model.ts new file mode 100644 index 0000000000..0c890ae800 --- /dev/null +++ b/examples/solid/realtime-trading/src/table/create-trading-table-model.ts @@ -0,0 +1,60 @@ +import { createTable } from '@tanstack/solid-table' +import { createMemo } from 'solid-js' +import { createTradingColumns } from './table-config/trading-columns' +import { tradingTableFeatures } from './trading-table-features' +import type { Accessor } from 'solid-js' +import type { MarketQuote } from '../feed/market-data' +import type { RendererMode } from './table-config/trading-columns' + +export interface CreateTradingTableModelOptions { + quotes: Accessor> + rendererMode: Accessor + onSelectSymbol: (symbol: string) => void +} + +/** + * Owns the TanStack Table model and the computations derived from table atoms. + * Consumers can subscribe to rows, columns, or layout independently. + */ +export function createTradingTableModel( + options: CreateTradingTableModelOptions, +) { + const columns = createMemo(() => + createTradingColumns({ + rendererMode: options.rendererMode(), + onSelectSymbol: options.onSelectSymbol, + }), + ) + const table = createTable({ + key: 'solid-realtime-trading', + features: tradingTableFeatures, + columnResizeMode: 'onChange', + defaultColumn: { minSize: 56, maxSize: 800 }, + autoResetCellSelection: false, + get columns() { + return columns() + }, + get data() { + return options.quotes() + }, + getRowId: (row) => row.id, + }) + const rows = createMemo(() => table.getRowModel().rows) + const tableStyle = createMemo(() => { + void table.atoms.columnSizing.get() + void table.atoms.columnOrder.get() + + const style: Record = { + width: `${table.getTotalSize()}px`, + } + for (const header of table.getFlatHeaders()) { + style[`--header-${header.id}-size`] = `${header.getSize()}` + style[`--col-${header.column.id}-size`] = `${header.column.getSize()}` + } + return style + }) + + return { columns, rows, table, tableStyle } +} + +export type TradingTableModel = ReturnType diff --git a/examples/solid/realtime-trading/src/table/jsx-attributes.ts b/examples/solid/realtime-trading/src/table/jsx-attributes.ts new file mode 100644 index 0000000000..b67d9c7ad2 --- /dev/null +++ b/examples/solid/realtime-trading/src/table/jsx-attributes.ts @@ -0,0 +1,4 @@ +/** Solid's intrinsic element types intentionally omit open-ended data-* keys. */ +export type WithDataAttributes = Attributes & { + [attribute: `data-${string}`]: string | number | boolean | undefined +} diff --git a/examples/solid/realtime-trading/src/table/table-config/market-quote-values.ts b/examples/solid/realtime-trading/src/table/table-config/market-quote-values.ts new file mode 100644 index 0000000000..4e2b5a21b1 --- /dev/null +++ b/examples/solid/realtime-trading/src/table/table-config/market-quote-values.ts @@ -0,0 +1,11 @@ +import type { MarketQuote } from '../../feed/market-data' + +export function getDayChange(quote: MarketQuote): number { + return quote.price - quote.previousClose +} + +export function getDayChangePercent(quote: MarketQuote): number { + return quote.previousClose === 0 + ? 0 + : (getDayChange(quote) / quote.previousClose) * 100 +} diff --git a/examples/solid/realtime-trading/src/table/table-config/quote-cell-props.ts b/examples/solid/realtime-trading/src/table/table-config/quote-cell-props.ts new file mode 100644 index 0000000000..eb0e12d911 --- /dev/null +++ b/examples/solid/realtime-trading/src/table/table-config/quote-cell-props.ts @@ -0,0 +1,31 @@ +export interface PriceCellProps { + price: number + move: number + onSelect: () => void +} + +export interface MoveCellProps { + move: number +} + +export interface PercentChangeCellProps { + value: number +} + +export interface SpreadCellProps { + bid: number + ask: number +} + +export interface DepthCellProps { + bidSize: number + askSize: number +} + +export interface QuoteAgeCellProps { + ageMs: number +} + +export interface SparklineCellProps { + values: ReadonlyArray +} diff --git a/examples/solid/realtime-trading/src/table/table-config/quote-cell-renderers.tsx b/examples/solid/realtime-trading/src/table/table-config/quote-cell-renderers.tsx new file mode 100644 index 0000000000..c83c2bf561 --- /dev/null +++ b/examples/solid/realtime-trading/src/table/table-config/quote-cell-renderers.tsx @@ -0,0 +1,119 @@ +import { Show } from 'solid-js' +import { useTradingRowData } from '../trading-row-data-context' +import { + DownMoveCell, + PercentChangeCell, + PriceCell, + SparklineCell, + StableMoveCell, + UpMoveCell, + recordCellRender, +} from './quote-cells' +import { getDayChange, getDayChangePercent } from './market-quote-values' + +const compactFormatter = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) + +export function createPriceCellRenderer( + onSelectSymbol: (symbol: string) => void, +) { + return function PriceCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('Last', () => ( + onSelectSymbol(quote().symbol)} + /> + )) + } +} + +export function StableMoveCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('Change', () => ( + + )) +} + +export function SwappingMoveCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('Change', () => ( + = 0} + fallback={} + > + + + )) +} + +export function PercentChangeCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('ChangePercent', () => ( + + )) +} + +export function SparklineCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('Intraday', () => ( + + )) +} + +export function MarketCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('Market', () => <>{quote().venue}) +} + +export function NameCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('Name', () => <>{quote().company}) +} + +export function SymbolCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('Symbol', () => <>{quote().symbol}) +} + +export function BidCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('Bid', () => <>{quote().bid.toFixed(2)}) +} + +export function BidVolumeCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('BidVolume', () => ( + <>{compactFormatter.format(quote().bidSize)} + )) +} + +export function AskCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('Ask', () => <>{quote().ask.toFixed(2)}) +} + +export function AskVolumeCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('AskVolume', () => ( + <>{compactFormatter.format(quote().askSize)} + )) +} + +export function OpenCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('Open', () => <>{quote().open.toFixed(2)}) +} + +export function HighCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('High', () => <>{quote().high.toFixed(2)}) +} + +export function LowCellRenderer() { + const quote = useTradingRowData() + return recordCellRender('Low', () => <>{quote().low.toFixed(2)}) +} diff --git a/examples/solid/realtime-trading/src/table/table-config/quote-cells.tsx b/examples/solid/realtime-trading/src/table/table-config/quote-cells.tsx new file mode 100644 index 0000000000..510246103b --- /dev/null +++ b/examples/solid/realtime-trading/src/table/table-config/quote-cells.tsx @@ -0,0 +1,245 @@ +import { createMemo, onCleanup, onMount } from 'solid-js' +import type { + DepthCellProps, + MoveCellProps, + PercentChangeCellProps, + PriceCellProps, + QuoteAgeCellProps, + SparklineCellProps, + SpreadCellProps, +} from './quote-cell-props' + +const compactNumber = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) + +export const quoteCellLifecycle = { + created: 0, + destroyed: 0, +} + +export const quoteCellRendererNames = [ + 'Market', + 'Name', + 'Symbol', + 'Last', + 'Change', + 'ChangePercent', + 'Bid', + 'BidVolume', + 'Ask', + 'AskVolume', + 'Open', + 'High', + 'Low', + 'Intraday', +] as const + +export const quoteComponentNames = [ + 'PriceCell', + 'StableMoveCell', + 'UpMoveCell', + 'DownMoveCell', + 'PercentChangeCell', + 'SpreadCell', + 'DepthCell', + 'QuoteAgeCell', + 'SparklineCell', +] as const + +export type QuoteCellRendererName = (typeof quoteCellRendererNames)[number] +export type QuoteComponentName = (typeof quoteComponentNames)[number] + +const createCounterMap = ( + names: ReadonlyArray, +): Record => + Object.fromEntries(names.map((name) => [name, 0])) as Record + +export const quoteRenderDiagnostics = { + cellRendererCalls: 0, + componentRenderCalls: 0, + cellRendererCallsByName: createCounterMap(quoteCellRendererNames), + componentRenderCallsByName: createCounterMap(quoteComponentNames), +} + +export function recordCellRender( + name: QuoteCellRendererName, + value: () => T, +): T { + quoteRenderDiagnostics.cellRendererCalls++ + quoteRenderDiagnostics.cellRendererCallsByName[name]++ + return value() +} + +function trackLifecycle(componentName: QuoteComponentName): void { + quoteRenderDiagnostics.componentRenderCalls++ + quoteRenderDiagnostics.componentRenderCallsByName[componentName]++ + onMount(() => { + quoteCellLifecycle.created++ + }) + onCleanup(() => { + quoteCellLifecycle.destroyed++ + }) +} + +export function PriceCell(props: PriceCellProps) { + trackLifecycle('PriceCell') + return ( + + ) +} + +export function StableMoveCell(props: MoveCellProps) { + trackLifecycle('StableMoveCell') + return ( + = 0, + 'quote-down': props.move < 0, + }} + > + {formatSigned(props.move)} + + ) +} + +export function UpMoveCell(props: MoveCellProps) { + trackLifecycle('UpMoveCell') + return ▲ {formatSigned(props.move)} +} + +export function DownMoveCell(props: MoveCellProps) { + trackLifecycle('DownMoveCell') + return ▼ {formatSigned(props.move)} +} + +export function PercentChangeCell(props: PercentChangeCellProps) { + trackLifecycle('PercentChangeCell') + return ( + = 0, + 'quote-down': props.value < 0, + }} + > + {props.value >= 0 ? '+' : ''} + {props.value.toFixed(2)}% + + ) +} + +export function SpreadCell(props: SpreadCellProps) { + trackLifecycle('SpreadCell') + const spread = createMemo(() => Math.max(0, props.ask - props.bid)) + const basisPoints = createMemo(() => { + const midpoint = (props.bid + props.ask) / 2 + return midpoint === 0 ? 0 : (spread() / midpoint) * 10_000 + }) + + return ( + = 4 }}> + {spread().toFixed(2)} + {basisPoints().toFixed(1)} bp + + ) +} + +export function DepthCell(props: DepthCellProps) { + trackLifecycle('DepthCell') + const bidShare = createMemo(() => { + const total = props.bidSize + props.askSize + return total === 0 ? 50 : (props.bidSize / total) * 100 + }) + + return ( +
+ + + + {compactNumber.format(props.bidSize)} + {compactNumber.format(props.askSize)} + +
+ ) +} + +export function QuoteAgeCell(props: QuoteAgeCellProps) { + trackLifecycle('QuoteAgeCell') + return ( + = 500, + 'quote-age-stale': props.ageMs >= 1_500, + }} + > + {props.ageMs < 1_000 + ? `${Math.round(props.ageMs)} ms` + : `${(props.ageMs / 1_000).toFixed(1)} s`} + + ) +} + +export function SparklineCell(props: SparklineCellProps) { + trackLifecycle('SparklineCell') + const rising = createMemo( + () => (props.values.at(-1) ?? 0) >= (props.values[0] ?? 0), + ) + const points = createMemo(() => { + const { min, max } = findRange(props.values) + const range = max - min || 1 + const denominator = Math.max(1, props.values.length - 1) + return props.values + .map((value, index) => { + const x = (index / denominator) * 100 + const y = 22 - ((value - min) / range) * 20 + return `${x.toFixed(1)},${y.toFixed(1)}` + }) + .join(' ') + }) + + return ( + + + + ) +} + +function formatSigned(value: number): string { + return `${value >= 0 ? '+' : ''}${value.toFixed(2)}` +} + +function findRange(values: ReadonlyArray): { + min: number + max: number +} { + const first = values[0] ?? 0 + return values.reduce( + (range, value) => { + range.min = Math.min(range.min, value) + range.max = Math.max(range.max, value) + return range + }, + { min: first, max: first }, + ) +} diff --git a/examples/solid/realtime-trading/src/table/table-config/trading-columns.tsx b/examples/solid/realtime-trading/src/table/table-config/trading-columns.tsx new file mode 100644 index 0000000000..9cf09e5174 --- /dev/null +++ b/examples/solid/realtime-trading/src/table/table-config/trading-columns.tsx @@ -0,0 +1,153 @@ +import { createColumnHelper } from '@tanstack/solid-table' +import { + AskCellRenderer, + AskVolumeCellRenderer, + BidCellRenderer, + BidVolumeCellRenderer, + HighCellRenderer, + LowCellRenderer, + MarketCellRenderer, + NameCellRenderer, + OpenCellRenderer, + PercentChangeCellRenderer, + SparklineCellRenderer, + StableMoveCellRenderer, + SwappingMoveCellRenderer, + SymbolCellRenderer, + createPriceCellRenderer, +} from './quote-cell-renderers' +import { getDayChange, getDayChangePercent } from './market-quote-values' +import { tradingTableFeatures } from '../trading-table-features' +import type { MarketQuote } from '../../feed/market-data' + +export type RendererMode = 'stable' | 'swap' + +export interface TradingColumnOptions { + rendererMode: RendererMode + onSelectSymbol: (symbol: string) => void +} + +const columnHelper = createColumnHelper< + typeof tradingTableFeatures, + MarketQuote +>() + +export function createTradingColumns(options: TradingColumnOptions) { + const priceCell = createPriceCellRenderer(options.onSelectSymbol) + const changeCell = + options.rendererMode === 'stable' + ? StableMoveCellRenderer + : SwappingMoveCellRenderer + + return columnHelper.columns([ + columnHelper.group({ + id: 'instrument', + header: 'Instrument', + columns: columnHelper.columns([ + columnHelper.accessor('venue', { + id: 'market', + header: 'Market', + size: 72, + cell: MarketCellRenderer, + }), + columnHelper.accessor('company', { + id: 'name', + header: 'Name', + size: 180, + cell: NameCellRenderer, + }), + columnHelper.accessor('symbol', { + header: 'Symbol', + size: 92, + cell: SymbolCellRenderer, + }), + ]), + }), + columnHelper.group({ + id: 'priceAndChange', + header: 'Price & Change', + columns: columnHelper.columns([ + columnHelper.accessor('price', { + header: 'Price', + size: 96, + cell: priceCell, + }), + columnHelper.accessor((row) => getDayChange(row), { + id: 'change', + header: 'Chg', + size: 94, + cell: changeCell, + }), + columnHelper.accessor((row) => getDayChangePercent(row), { + id: 'changePercent', + header: 'Chg%', + size: 90, + cell: PercentChangeCellRenderer, + }), + ]), + }), + columnHelper.group({ + id: 'orderBook', + header: 'Order Book', + columns: columnHelper.columns([ + columnHelper.accessor('bid', { + header: 'Bid', + size: 90, + cell: BidCellRenderer, + }), + columnHelper.accessor('bidSize', { + header: 'Bid Vol', + size: 100, + cell: BidVolumeCellRenderer, + }), + columnHelper.accessor('ask', { + header: 'Ask', + size: 90, + cell: AskCellRenderer, + }), + columnHelper.accessor('askSize', { + header: 'Ask Vol', + size: 100, + cell: AskVolumeCellRenderer, + }), + ]), + }), + columnHelper.group({ + id: 'session', + header: 'Session', + columns: columnHelper.columns([ + columnHelper.accessor('open', { + header: 'Open', + size: 90, + cell: OpenCellRenderer, + }), + columnHelper.accessor('high', { + header: 'High', + size: 90, + cell: HighCellRenderer, + }), + columnHelper.accessor('low', { + header: 'Low', + size: 90, + cell: LowCellRenderer, + }), + ]), + }), + columnHelper.group({ + id: 'chart', + header: 'Chart', + columns: columnHelper.columns([ + columnHelper.accessor('history', { + header: 'Intraday', + size: 150, + enableSorting: false, + cell: SparklineCellRenderer, + }), + ]), + }), + ]) +} + +export type TradingColumnSet = ReturnType + +export const TRADING_COLUMN_COUNT = 14 diff --git a/examples/solid/realtime-trading/src/table/table-interactions.ts b/examples/solid/realtime-trading/src/table/table-interactions.ts new file mode 100644 index 0000000000..6ed8912743 --- /dev/null +++ b/examples/solid/realtime-trading/src/table/table-interactions.ts @@ -0,0 +1,194 @@ +import type { JSX } from 'solid-js' + +export type CellDirection = 'up' | 'down' | 'left' | 'right' + +interface RowSelectionTable { + resetRowSelection: (defaultState?: boolean) => void +} + +interface SelectableRow { + getIsSelected: () => boolean + getToggleSelectedHandler: (options?: { + selectChildren?: boolean + }) => (event: unknown) => void +} + +interface SelectableGridCell { + row: SelectableGridRow + getSelectionStartHandler: ( + contextDocument?: Document, + ) => (event: unknown) => void + getSelectionExtendHandler: () => (event: unknown) => void +} + +interface SelectableGridRow extends SelectableRow { + original: { symbol: string } + getAllCellsByColumnId: () => Record +} + +interface TradingGridTable extends RowSelectionTable { + getRowModel: () => { + rowsById: Record + } +} + +interface SelectionCellTarget { + element: HTMLTableCellElement + cell: SelectableGridCell +} + +interface CellNavigationTable { + extendCellSelection: (direction: CellDirection) => void + moveCellSelection: (direction: CellDirection) => void + resetCellSelection: (defaultState?: boolean) => void + selectAllCells: () => void +} + +const keyDirections: Partial> = { + ArrowUp: 'up', + ArrowDown: 'down', + ArrowLeft: 'left', + ArrowRight: 'right', +} + +export function reorderColumnIds( + columnIds: Array, + sourceId: string, + targetId: string, +): Array { + if (sourceId === targetId || !columnIds.includes(sourceId)) return columnIds + + const withoutSource = columnIds.filter((id) => id !== sourceId) + const targetIndex = withoutSource.indexOf(targetId) + if (targetIndex < 0) return columnIds + + return [ + ...withoutSource.slice(0, targetIndex), + sourceId, + ...withoutSource.slice(targetIndex), + ] +} + +export function selectRowFromPointer( + table: RowSelectionTable, + row: SelectableRow, + event: MouseEvent, +): void { + const additive = event.ctrlKey || event.metaKey + const checked = additive ? !row.getIsSelected() : true + + if (!event.shiftKey && !additive) table.resetRowSelection(true) + + row.getToggleSelectedHandler({ selectChildren: false })({ + target: { checked }, + shiftKey: event.shiftKey, + ctrlKey: event.ctrlKey, + metaKey: event.metaKey, + }) +} + +/** + * Creates the only pointer listeners used by the table body. Cells expose just + * identity data; delegated events resolve the current TanStack cell on demand. + */ +export function createTradingGridSelectionHandlers( + table: TradingGridTable, + selectSymbol: (symbol: string) => void, +) { + const runtime = { lastCell: null as HTMLTableCellElement | null } + + return { + onMouseDown(event) { + if (event.button !== 0) return + + const target = findCellTarget(table, event.composedPath()) + if (!target) return + + event.preventDefault() + runtime.lastCell = target.element + selectSymbol(target.cell.row.original.symbol) + target.cell.getSelectionStartHandler(target.element.ownerDocument)(event) + }, + onMouseOver(event) { + if ((event.buttons & 1) === 0) { + runtime.lastCell = null + return + } + + const target = findCellTarget(table, event.composedPath()) + if (!target || target.element === runtime.lastCell) return + + runtime.lastCell = target.element + target.cell.getSelectionExtendHandler()(event) + }, + onMouseLeave() { + runtime.lastCell = null + }, + onClick(event) { + const target = findCellTarget(table, event.composedPath()) + if (!target) return + selectRowFromPointer(table, target.cell.row, event) + }, + } satisfies Pick< + JSX.IntrinsicElements['tbody'], + 'onMouseDown' | 'onMouseOver' | 'onMouseLeave' | 'onClick' + > +} + +function findCellTarget( + table: TradingGridTable, + path: Array, +): SelectionCellTarget | null { + for (const target of path) { + if (!(target instanceof HTMLTableCellElement)) continue + + const columnId = target.dataset['columnId'] + const rowId = + target.closest('tr[data-row-id]')?.dataset['rowId'] + if (!columnId || !rowId) return null + + const row = table.getRowModel().rowsById[rowId] + const cell = row.getAllCellsByColumnId()[columnId] + return { element: target, cell } + } + + return null +} + +export function handleCellNavigation( + table: CellNavigationTable, + event: KeyboardEvent, +): void { + if (event.key === 'Escape') { + event.preventDefault() + table.resetCellSelection(true) + return + } + + if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a') { + event.preventDefault() + table.selectAllCells() + return + } + + const direction = keyDirections[event.key] + if (!direction) return + + event.preventDefault() + if (event.shiftKey) table.extendCellSelection(direction) + else table.moveCellSelection(direction) +} + +export function sortIndicator(direction: false | 'asc' | 'desc'): string { + if (direction === 'asc') return '↑' + if (direction === 'desc') return '↓' + return '↕' +} + +export function sortAriaValue( + direction: false | 'asc' | 'desc', +): 'ascending' | 'descending' | 'none' { + if (direction === 'asc') return 'ascending' + if (direction === 'desc') return 'descending' + return 'none' +} diff --git a/examples/solid/realtime-trading/src/table/trading-grid-props.ts b/examples/solid/realtime-trading/src/table/trading-grid-props.ts new file mode 100644 index 0000000000..b4cac193e0 --- /dev/null +++ b/examples/solid/realtime-trading/src/table/trading-grid-props.ts @@ -0,0 +1,41 @@ +import { handleCellNavigation } from './table-interactions' +import type { Accessor, JSX } from 'solid-js' +import type { WithDataAttributes } from './jsx-attributes' +import type { TradingTableInstance } from './trading-table-features' + +export interface TradingGridPropsOptions { + table: TradingTableInstance + virtualized: Accessor +} + +export function createTradingGridProps( + options: TradingGridPropsOptions, +): WithDataAttributes { + return { + class: 'table-scroll', + get classList() { + return { 'is-virtualized': options.virtualized() } + }, + 'data-trading-table': true, + tabindex: 0, + onKeyDown: (event) => handleCellNavigation(options.table, event), + } +} + +export function createTradingTableElementProps( + options: TradingGridPropsOptions, + style: Accessor>, +): WithDataAttributes { + return { + class: 'trading-data-grid', + get classList() { + return { 'virtual-table': options.virtualized() } + }, + 'data-testid': 'trading-table', + role: 'grid', + 'aria-multiselectable': true, + get style() { + return style() + }, + } +} diff --git a/examples/solid/realtime-trading/src/table/trading-row-data-context.tsx b/examples/solid/realtime-trading/src/table/trading-row-data-context.tsx new file mode 100644 index 0000000000..593c084a93 --- /dev/null +++ b/examples/solid/realtime-trading/src/table/trading-row-data-context.tsx @@ -0,0 +1,26 @@ +import { createContext, useContext } from 'solid-js' +import type { Accessor, JSX } from 'solid-js' +import type { MarketQuote } from '../feed/market-data' + +export interface TradingRowDataProviderProps { + quote: Accessor + children?: JSX.Element +} + +const TradingRowDataContext = createContext>() + +export function TradingRowDataProvider(props: TradingRowDataProviderProps) { + return ( + + {props.children} + + ) +} + +export function useTradingRowData(): Accessor { + const quote = useContext(TradingRowDataContext) + if (!quote) { + throw new Error('Trading cell renderers require TradingRowDataProvider') + } + return quote +} diff --git a/examples/solid/realtime-trading/src/table/trading-row-virtualizer.ts b/examples/solid/realtime-trading/src/table/trading-row-virtualizer.ts new file mode 100644 index 0000000000..ded27acb4e --- /dev/null +++ b/examples/solid/realtime-trading/src/table/trading-row-virtualizer.ts @@ -0,0 +1,77 @@ +import { createVirtualizer } from '@tanstack/solid-virtual' +import { createEffect, createMemo } from 'solid-js' +import type { Accessor } from 'solid-js' +import type { TradingRow } from './trading-table-features' + +export const TRADING_ROW_HEIGHT = 32 +export const TRADING_ROW_OVERSCAN = 10 +export const DEFAULT_VIRTUALIZATION_ROW_COUNT = 200 +export const FORCED_VIRTUALIZATION_ROW_COUNT = 1_500 + +export type VirtualScrollMode = 'tanstack' | 'none' +export type VirtualScrollPreference = VirtualScrollMode | 'auto' + +export interface TradingRowVirtualizationOptions { + rows: Accessor> + scrollElement: Accessor + enabled: Accessor + onRenderedRowCount: (count: number) => void +} + +export function createTradingRowVirtualization( + options: TradingRowVirtualizationOptions, +) { + const virtualizer = createVirtualizer({ + get count() { + return options.rows().length + }, + estimateSize: () => TRADING_ROW_HEIGHT, + getScrollElement: options.scrollElement, + getItemKey: (index) => options.rows()[index]?.id ?? index, + overscan: TRADING_ROW_OVERSCAN, + get enabled() { + return options.enabled() + }, + }) + const virtualRows = virtualizer.getVirtualItems + const visibleRange = createMemo(() => { + const items = virtualRows() + const rowCount = options.rows().length + if (!options.enabled() || rowCount === 0 || items.length === 0) return null + + const lastRowIndex = rowCount - 1 + const start = Math.min(items[0]!.index, lastRowIndex) + return { + start, + end: Math.min(items[items.length - 1]!.index, lastRowIndex), + } + }) + const bodyHeight = createMemo(() => + options.enabled() + ? `${options.rows().length * TRADING_ROW_HEIGHT}px` + : undefined, + ) + + createEffect(() => { + options.onRenderedRowCount( + options.enabled() ? virtualRows().length : options.rows().length, + ) + }) + + return { bodyHeight, virtualizer, virtualRows, visibleRange } +} + +export type TradingRowVirtualization = ReturnType< + typeof createTradingRowVirtualization +> + +export function resolveVirtualScrollMode( + requestedMode: VirtualScrollPreference, + instrumentCount: number, +): VirtualScrollMode { + if (instrumentCount >= FORCED_VIRTUALIZATION_ROW_COUNT) return 'tanstack' + if (requestedMode !== 'auto') return requestedMode + return instrumentCount >= DEFAULT_VIRTUALIZATION_ROW_COUNT + ? 'tanstack' + : 'none' +} diff --git a/examples/solid/realtime-trading/src/table/trading-table-body.tsx b/examples/solid/realtime-trading/src/table/trading-table-body.tsx new file mode 100644 index 0000000000..3a074634b3 --- /dev/null +++ b/examples/solid/realtime-trading/src/table/trading-table-body.tsx @@ -0,0 +1,81 @@ +import { Index, Show, createMemo } from 'solid-js' +import { createTradingGridSelectionHandlers } from './table-interactions' +import { TradingTableRow } from './trading-table-row' +import type { Accessor, JSX } from 'solid-js' +import type { TradingColumnSet } from './table-config/trading-columns' +import type { TradingRowVirtualization } from './trading-row-virtualizer' +import type { TradingRow, TradingTableInstance } from './trading-table-features' + +export interface TradingTableBodyProps { + table: TradingTableInstance + rows: Accessor> + columnVersion: Accessor + selectedSymbol: Accessor + virtualized: Accessor + virtualization: TradingRowVirtualization + selectSymbol: (symbol: string) => void +} + +export function TradingTableBody(props: TradingTableBodyProps) { + const bodyProps = createTradingTableBodyProps(props) + + return ( +
+ }> + + + + ) +} + +function FullTableRows(props: TradingTableBodyProps) { + return ( + + {(row) => ( + + )} + + ) +} + +function VirtualTableRows(props: TradingTableBodyProps) { + return ( + + {(virtualRow) => { + const row = createMemo(() => props.rows()[virtualRow().index]) + return ( + + ) + }} + + ) +} + +function createTradingTableBodyProps( + options: TradingTableBodyProps, +): JSX.IntrinsicElements['tbody'] { + const selectionHandlers = createTradingGridSelectionHandlers( + options.table, + options.selectSymbol, + ) + + return { + ...selectionHandlers, + get classList() { + return { 'virtual-table-body': options.virtualized() } + }, + get style() { + const height = options.virtualization.bodyHeight() + return height === undefined ? undefined : { height } + }, + } +} diff --git a/examples/solid/realtime-trading/src/table/trading-table-effects.ts b/examples/solid/realtime-trading/src/table/trading-table-effects.ts new file mode 100644 index 0000000000..d106818ba1 --- /dev/null +++ b/examples/solid/realtime-trading/src/table/trading-table-effects.ts @@ -0,0 +1,68 @@ +import { createEffect, onCleanup, onMount } from 'solid-js' +import type { Accessor } from 'solid-js' +import type { TradingTableInstance } from './trading-table-features' + +export function createFeedCommitTracking( + quotes: Accessor, + completeCommit: () => void, +): void { + const runtime = { queued: false, disposed: false } + + createEffect(() => { + quotes() + if (runtime.queued) return + + runtime.queued = true + queueMicrotask(() => { + runtime.queued = false + if (!runtime.disposed) completeCommit() + }) + }) + + onCleanup(() => { + runtime.disposed = true + }) +} + +export function createTableAutoFit( + table: TradingTableInstance, + scrollElement: Accessor, +): void { + const runtime = { manuallyResized: false } + + onMount(() => { + const fitAvailableWidth = (): void => { + const element = scrollElement() + if (!element || runtime.manuallyResized) return + + const currentWidth = table.getTotalSize() + const availableWidth = element.clientWidth + if (availableWidth <= currentWidth + 1 || currentWidth <= 0) return + + const ratio = availableWidth / currentWidth + table.setColumnSizing( + Object.fromEntries( + table + .getVisibleLeafColumns() + .map((column) => [column.id, column.getSize() * ratio]), + ), + ) + } + const resizeObserver = new ResizeObserver(fitAvailableWidth) + const resizingSubscription = table.atoms.columnResizing.subscribe( + (state) => { + if (state.isResizingColumn !== false) { + runtime.manuallyResized = true + } + }, + ) + const element = scrollElement() + if (element) resizeObserver.observe(element) + fitAvailableWidth() + + onCleanup(() => { + resizeObserver.disconnect() + resizingSubscription.unsubscribe() + }) + }) +} diff --git a/examples/solid/realtime-trading/src/table/trading-table-features.ts b/examples/solid/realtime-trading/src/table/trading-table-features.ts new file mode 100644 index 0000000000..0af9b8983b --- /dev/null +++ b/examples/solid/realtime-trading/src/table/trading-table-features.ts @@ -0,0 +1,19 @@ +import { + createSortedRowModel, + stockFeatures, + tableFeatures, +} from '@tanstack/solid-table' +import type { Cell, Header, Row, SolidTable } from '@tanstack/solid-table' +import type { MarketQuote } from '../feed/market-data' + +export const tradingTableFeatures = tableFeatures({ + ...stockFeatures, + sortedRowModel: createSortedRowModel(), +}) + +export type TradingTableFeatures = typeof tradingTableFeatures +export type TradingTableInstance = SolidTable +export type TradingRow = Row +export type TradingCell = Cell +export type TradingCellContext = ReturnType +export type TradingHeader = Header diff --git a/examples/solid/realtime-trading/src/table/trading-table-footer.tsx b/examples/solid/realtime-trading/src/table/trading-table-footer.tsx new file mode 100644 index 0000000000..22bdc6ab9a --- /dev/null +++ b/examples/solid/realtime-trading/src/table/trading-table-footer.tsx @@ -0,0 +1,33 @@ +import { Show } from 'solid-js' +import type { Accessor } from 'solid-js' +import type { TradingRowVirtualization } from './trading-row-virtualizer' +import type { TradingRow, TradingTableInstance } from './trading-table-features' + +export interface TradingTableFooterProps { + table: TradingTableInstance + rows: Accessor> + virtualized: Accessor + virtualization: TradingRowVirtualization +} + +function visibleRangeLabel(virtualization: TradingRowVirtualization): string { + const items = virtualization.virtualRows() + if (items.length === 0) return 'Current · rows —' + return `Current · rows ${items[0]!.index}..${items[items.length - 1]!.index}` +} + +export function TradingTableFooter(props: TradingTableFooterProps) { + return ( + +
+ + TanStack · Total · {props.rows().length} rows ·{' '} + {props.table.getVisibleLeafColumns().length} columns + + + {visibleRangeLabel(props.virtualization)} + +
+
+ ) +} diff --git a/examples/solid/realtime-trading/src/table/trading-table-header.tsx b/examples/solid/realtime-trading/src/table/trading-table-header.tsx new file mode 100644 index 0000000000..6a0f1ae86c --- /dev/null +++ b/examples/solid/realtime-trading/src/table/trading-table-header.tsx @@ -0,0 +1,166 @@ +import { FlexRender } from '@tanstack/solid-table' +import { For, Show } from 'solid-js' +import { createColumnDrag } from './create-column-drag' +import { sortAriaValue, sortIndicator } from './table-interactions' +import type { JSX } from 'solid-js' +import type { ColumnDrag } from './create-column-drag' +import type { + TradingHeader, + TradingTableInstance, +} from './trading-table-features' + +export interface TradingTableHeaderProps { + table: TradingTableInstance +} + +export function TradingTableHeader(props: TradingTableHeaderProps) { + const columnDrag = createColumnDrag(props.table) + + return ( +
+ + {(headerGroup) => ( + + + {(header) => ( + + )} + + + )} + + + ) +} + +interface TradingHeaderCellProps { + header: TradingHeader + columnDrag: ColumnDrag +} + +function TradingHeaderCell(props: TradingHeaderCellProps) { + const isLeaf = () => props.header.subHeaders.length === 0 + const headerCellProps = createHeaderCellProps( + () => props.header, + isLeaf, + props.columnDrag, + ) + + return ( + + ) +} + +function TradingLeafHeader(props: TradingHeaderCellProps) { + const dropZoneProps = props.columnDrag.createDropZoneProps( + props.header.column.id, + ) + const dragHandleProps = props.columnDrag.createHandleProps( + props.header.column.id, + ) + const sortButtonProps = createSortButtonProps(() => props.header) + const resizeHandleProps = createResizeHandleProps(() => props.header) + + return ( + <> +
+ + +
+ +
+ + + ) +} + +function createHeaderCellProps( + header: () => TradingHeader, + isLeaf: () => boolean, + columnDrag: ColumnDrag, +): JSX.IntrinsicElements['th'] { + return { + get colSpan() { + return header().colSpan + }, + get style() { + return { + width: `calc(var(--header-${header().id}-size) * 1px)`, + } + }, + get ['aria-sort']() { + return isLeaf() ? sortAriaValue(header().column.getIsSorted()) : undefined + }, + get classList() { + const columnId = header().column.id + return { + 'column-group-header': !isLeaf(), + 'numeric-header': isLeaf() && !isTextColumn(columnId), + 'is-column-dragging': columnDrag.isDragging(columnId), + 'is-column-drop-target': columnDrag.isDropTarget(columnId), + } + }, + } +} + +function createSortButtonProps( + header: () => TradingHeader, +): JSX.IntrinsicElements['button'] { + return { + type: 'button', + class: 'sort-header-button', + get classList() { + return { 'is-sortable': header().column.getCanSort() } + }, + get disabled() { + return !header().column.getCanSort() + }, + onClick: header().column.getToggleSortingHandler(), + } +} + +function createResizeHandleProps( + header: () => TradingHeader, +): JSX.IntrinsicElements['div'] { + return { + class: 'column-resize-handle', + get classList() { + return { 'is-resizing': header().column.getIsResizing() } + }, + role: 'separator', + 'aria-orientation': 'vertical', + onDblClick: () => header().column.resetSize(), + onMouseDown: header().getResizeHandler(), + onTouchStart: header().getResizeHandler(), + } +} + +function isTextColumn(columnId: string): boolean { + return columnId === 'market' || columnId === 'name' || columnId === 'symbol' +} diff --git a/examples/solid/realtime-trading/src/table/trading-table-row.tsx b/examples/solid/realtime-trading/src/table/trading-table-row.tsx new file mode 100644 index 0000000000..6d25d8258a --- /dev/null +++ b/examples/solid/realtime-trading/src/table/trading-table-row.tsx @@ -0,0 +1,105 @@ +import { FlexRender } from '@tanstack/solid-table' +import { Index, createMemo } from 'solid-js' +import { TradingRowDataProvider } from './trading-row-data-context' +import type { VirtualItem } from '@tanstack/solid-virtual' +import type { TradingColumnSet } from './table-config/trading-columns' +import type { TradingCell, TradingRow } from './trading-table-features' + +export interface TradingTableRowProps { + row: TradingRow + columnVersion: TradingColumnSet + selectedSymbol: string | null + virtualItem?: VirtualItem +} + +interface TradingTableCellProps { + cell: TradingCell + renderCell: TradingCell +} + +export function TradingTableRow(props: TradingTableRowProps) { + const currentCells = createMemo(() => props.row.getVisibleCells()) + const renderState = createMemo( + () => ({ + rowId: props.row.id, + columns: props.columnVersion, + cells: currentCells(), + }), + undefined, + { + equals: (previous, next) => + previous.rowId === next.rowId && + previous.columns === next.columns && + haveSameCellOrder(previous.cells, next.cells), + }, + ) + + return ( + props.row.original}> +
+ + {(cell, index) => ( + + )} + + + + ) +} + +function TradingTableCell(props: TradingTableCellProps) { + const selection = createMemo(() => ({ + edges: props.cell.getSelectionEdges(), + focused: props.cell.getIsFocused(), + selected: props.cell.getIsSelected(), + tabIndex: props.cell.getTabIndex(), + })) + + return ( + + ) +} + +function haveSameCellOrder( + previous: ReadonlyArray, + next: ReadonlyArray, +): boolean { + return ( + previous.length === next.length && + previous.every((cell, index) => cell.column.id === next[index]?.column.id) + ) +} diff --git a/examples/solid/realtime-trading/src/table/trading-table.tsx b/examples/solid/realtime-trading/src/table/trading-table.tsx new file mode 100644 index 0000000000..6c19ecfbeb --- /dev/null +++ b/examples/solid/realtime-trading/src/table/trading-table.tsx @@ -0,0 +1,77 @@ +import { createSignal } from 'solid-js' +import { + useMarketFeedController, + useTradingShellController, +} from '../shell/trading-shell-context' +import { createTradingTableModel } from './create-trading-table-model' +import { + createTradingGridProps, + createTradingTableElementProps, +} from './trading-grid-props' +import { + createFeedCommitTracking, + createTableAutoFit, +} from './trading-table-effects' +import { createTradingRowVirtualization } from './trading-row-virtualizer' +import { TradingTableBody } from './trading-table-body' +import { TradingTableFooter } from './trading-table-footer' +import { TradingTableHeader } from './trading-table-header' + +export function TradingTable() { + const feed = useMarketFeedController() + const { state, actions } = useTradingShellController() + const [scrollElement, setScrollElement] = createSignal( + null, + ) + const virtualized = () => state.virtualScrollMode() === 'tanstack' + const model = createTradingTableModel({ + quotes: feed.state.quotes, + rendererMode: state.rendererMode, + onSelectSymbol: actions.selectSymbol, + }) + const virtualization = createTradingRowVirtualization({ + rows: model.rows, + scrollElement, + enabled: virtualized, + onRenderedRowCount: actions.setRenderedRowCount, + }) + const elementOptions = { table: model.table, virtualized } + const gridProps = createTradingGridProps(elementOptions) + const tableProps = createTradingTableElementProps( + elementOptions, + model.tableStyle, + ) + + createFeedCommitTracking(feed.state.quotes, feed.completeRender) + createTableAutoFit(model.table, scrollElement) + + return ( + <> +
{ + setScrollElement(element) + }} + > +
@@ -190,7 +190,10 @@ function App() {
{'
(relative)'}
-
+
{table.getHeaderGroups().map((headerGroup) => (
@@ -199,7 +202,7 @@ function App() { key={header.id} className="th" style={{ - width: header.getSize(), + width: `${header.getSize()}px`, }} > {header.isPlaceholder ? null : ( @@ -238,7 +241,7 @@ function App() { key={cell.id} className="td" style={{ - width: cell.column.getSize(), + width: `${cell.column.getSize()}px`, }} > @@ -255,7 +258,7 @@ function App() {
@@ -273,8 +276,8 @@ function App() { className="th" style={{ position: 'absolute', - left: header.getStart(), - width: header.getSize(), + left: `${header.getStart()}px`, + width: `${header.getSize()}px`, }} > {header.isPlaceholder ? null : ( @@ -320,8 +323,8 @@ function App() { className="td" style={{ position: 'absolute', - left: cell.column.getStart(), - width: cell.column.getSize(), + left: `${cell.column.getStart()}px`, + width: `${cell.column.getSize()}px`, }} > diff --git a/examples/preact/column-sizing/package.json b/examples/preact/column-sizing/package.json index 8fb3895676..10ca767f98 100644 --- a/examples/preact/column-sizing/package.json +++ b/examples/preact/column-sizing/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/column-sizing/src/main.tsx b/examples/preact/column-sizing/src/main.tsx index dcf4819b5b..d369bae215 100644 --- a/examples/preact/column-sizing/src/main.tsx +++ b/examples/preact/column-sizing/src/main.tsx @@ -112,7 +112,7 @@ function App() {
@@ -123,7 +123,7 @@ function App() { key={header.id} colSpan={header.colSpan} style={{ - width: header.getSize(), + width: `${header.getSize()}px`, }} > {header.isPlaceholder ? null : ( @@ -142,7 +142,7 @@ function App() { + pointerInteractions.handleMouseDown(props.table, event, selectSymbol) + } + onPointerOver={(event) => + pointerInteractions.handlePointerOver(props.table, event) + } + onMouseLeave={() => pointerInteractions.resetPointerCell()} + onClick={(event) => pointerInteractions.handleClick(props.table, event)} + > + {props.rows.map((row) => ( + + ))} + + ) +} + +type TradingTableRow = ReturnType< + ReturnType['getRowModel'] +>['rows'][number] + +function TradingRowBoundary(props: { + table: ReturnType + row: TradingTableRow +}) { + const { row, table } = props + + return ( + + `${row.id in state.rowSelection ? 1 : 0}:${cellSelectionRowKey( + state.cellSelection, + table.getCellSelectionBounds(), + row.getDisplayIndex(), + row.id, + )}` + } + > + {() => ( + + {row.getVisibleCells().map((cell) => { + const edges = cell.getSelectionEdges() + + return ( + + ) + })} + + )} + + ) +} + +function getHeaderClassName(header: { + subHeaders: ReadonlyArray + column: { id: string } +}): string | undefined { + if (header.subHeaders.length > 0) return 'column-group-header' + return isTextColumn(header.column.id) ? undefined : 'numeric-header' +} + +function isTextColumn(columnId: string): boolean { + return columnId === 'market' || columnId === 'name' || columnId === 'symbol' +} + +function readRows( + table: ReturnType, + quoteSnapshot: Array, + coreState: CoreTableState, +) { + void quoteSnapshot + void coreState + return readMeasuredRows(() => table.getRowModel().rows) +} + +function cellSelectionRowKey( + ranges: CellSelectionState, + bounds: Array, + rowIndex: number, + rowId: string, +): string { + const active = ranges.at(-1) + const initial = + active?.anchorRowId === rowId ? `f${active.anchorColumnId}` : '' + + return bounds.reduce((key, bound) => { + const self = rowIndex >= bound.minRowIndex && rowIndex <= bound.maxRowIndex + const above = + rowIndex - 1 >= bound.minRowIndex && rowIndex - 1 <= bound.maxRowIndex + const below = + rowIndex + 1 >= bound.minRowIndex && rowIndex + 1 <= bound.maxRowIndex + if (!self && !above && !below) return key + return `${key}|${self ? 1 : 0}${above ? 1 : 0}${below ? 1 : 0}:${bound.minColumnIndex}-${bound.maxColumnIndex}` + }, initial) +} diff --git a/examples/preact/realtime-trading/src/vite-env.d.ts b/examples/preact/realtime-trading/src/vite-env.d.ts new file mode 100644 index 0000000000..11f02fe2a0 --- /dev/null +++ b/examples/preact/realtime-trading/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/preact/realtime-trading/tests/e2e/smoke.spec.ts b/examples/preact/realtime-trading/tests/e2e/smoke.spec.ts new file mode 100644 index 0000000000..49789a8140 --- /dev/null +++ b/examples/preact/realtime-trading/tests/e2e/smoke.spec.ts @@ -0,0 +1,94 @@ +import path from 'node:path' +import { expect, test } from '@playwright/test' +import { startExampleServer } from '../../../../../tests/e2e/helpers/startExampleServer' +import { + setRangeValue, + pausedFeedUrl, +} from '../../../../../tests/e2e/helpers/setRangeValue' +import type { Page } from '@playwright/test' + +const exampleDir = path.resolve() + +function collectPageErrors(page: Page) { + const errors: Array = [] + page.on('pageerror', (error) => errors.push(error.message)) + page.on('console', (message) => { + if (message.type() === 'error') errors.push(message.text()) + }) + return errors +} + +test('runs the Preact realtime trading workload', async ({ page }) => { + const server = await startExampleServer(exampleDir) + const errors = collectPageErrors(page) + + try { + await page.goto(pausedFeedUrl(server.url)) + + const table = page.getByTestId('trading-table') + const instrumentCount = page.getByTestId('instrument-count-select') + await expect(table).toBeVisible() + await expect(instrumentCount).toHaveValue('100') + await expect(page.locator('.brand')).toHaveText('MARKET MONITOR') + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(table.locator('tbody')).toHaveCSS('user-select', 'none') + await expect(table.locator('tbody tr').first()).toHaveCSS( + 'content-visibility', + 'auto', + ) + await expect(table.locator('thead tr')).toHaveCount(2) + await expect(table.locator('thead tr').last().locator('th')).toHaveCount(14) + await expect(table.locator('thead')).not.toContainText('Identity') + await expect(table.locator('thead')).not.toContainText('Market Data') + await expect(table.locator('thead')).toContainText('Market') + await expect(table.locator('thead')).toContainText('Bid Vol') + await expect(table.locator('thead')).toContainText('Intraday') + const selectedRow = table.locator('tbody tr').first() + const selectedSymbol = await selectedRow.getAttribute('data-symbol') + await selectedRow.locator('td').nth(1).click() + await expect(page.getByTestId('selected-instrument')).toContainText( + selectedSymbol ?? '', + ) + await expect(page.getByTestId('feed-status')).toHaveText('FEED PAUSED') + await expect(instrumentCount.locator('option[value="150"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="350"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="750"]')).toHaveCount(1) + + const targetRateSlider = page.getByTestId('target-rate-slider') + await expect(targetRateSlider).toHaveAttribute('min', '0') + await expect(targetRateSlider).toHaveAttribute('max', '9') + await expect(targetRateSlider).toHaveAttribute('step', '1') + await expect(targetRateSlider).toHaveValue('6') + await setRangeValue(targetRateSlider, '7') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '25K samples/s', + ) + await setRangeValue(targetRateSlider, '8') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '50K samples/s', + ) + await setRangeValue(targetRateSlider, '6') + + const sparklineInterval = page.getByTestId( + 'sparkline-sample-interval-select', + ) + await expect(sparklineInterval).toHaveValue('16') + await sparklineInterval.selectOption('100') + await expect(sparklineInterval).toHaveValue('100') + await sparklineInterval.selectOption('16') + + const publishInterval = page.getByTestId('publish-interval-select') + await expect(publishInterval.locator('option[value="500"]')).toHaveCount(1) + await expect(publishInterval.locator('option[value="1000"]')).toHaveCount(1) + + expect( + await page.evaluate( + () => performance.getEntriesByName('tanstack-row-model').length > 0, + ), + ).toBe(true) + + expect(errors).toEqual([]) + } finally { + await server.close() + } +}) diff --git a/examples/preact/realtime-trading/tsconfig.json b/examples/preact/realtime-trading/tsconfig.json new file mode 100644 index 0000000000..2172bff227 --- /dev/null +++ b/examples/preact/realtime-trading/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ES2022", + "useDefineForClassFields": true, + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + "jsxImportSource": "preact", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src", "tests/e2e", "vite.config.ts"] +} diff --git a/examples/preact/realtime-trading/vite.config.ts b/examples/preact/realtime-trading/vite.config.ts new file mode 100644 index 0000000000..e208c56eb2 --- /dev/null +++ b/examples/preact/realtime-trading/vite.config.ts @@ -0,0 +1,10 @@ +import preact from '@preact/preset-vite' +import { defineConfig } from 'vite' + +export default defineConfig({ + server: { + port: 7777, + allowedHosts: true, + }, + plugins: [preact()], +}) diff --git a/examples/preact/row-pinning/package.json b/examples/preact/row-pinning/package.json index d36706288e..4e8393f548 100644 --- a/examples/preact/row-pinning/package.json +++ b/examples/preact/row-pinning/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/row-selection/package.json b/examples/preact/row-selection/package.json index 50dd6d3183..bd64283086 100644 --- a/examples/preact/row-selection/package.json +++ b/examples/preact/row-selection/package.json @@ -12,16 +12,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-devtools": "^0.10.10", - "@tanstack/preact-store": "^0.13.2", - "@tanstack/preact-table": "^9.1.2", - "@tanstack/preact-table-devtools": "^9.2.0", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-devtools": "^0.10.15", + "@tanstack/preact-store": "^0.13.5", + "@tanstack/preact-table": "^9.3.1", + "@tanstack/preact-table-devtools": "^9.3.2", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/sorting/package.json b/examples/preact/sorting/package.json index 4ee7845f3c..45d9b76ddf 100644 --- a/examples/preact/sorting/package.json +++ b/examples/preact/sorting/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/sub-components/package.json b/examples/preact/sub-components/package.json index e633153355..5c07eb7df6 100644 --- a/examples/preact/sub-components/package.json +++ b/examples/preact/sub-components/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/with-tanstack-form/package.json b/examples/preact/with-tanstack-form/package.json index 55f487c03a..b79e324023 100644 --- a/examples/preact/with-tanstack-form/package.json +++ b/examples/preact/with-tanstack-form/package.json @@ -12,20 +12,21 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-devtools": "^0.10.10", - "@tanstack/preact-form": "^1.30.5", - "@tanstack/preact-pacer": "^0.23.0", - "@tanstack/preact-pacer-devtools": "0.7.0", - "@tanstack/preact-table": "^9.1.2", - "@tanstack/preact-table-devtools": "^9.2.0", + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-devtools": "^0.10.15", + "@tanstack/preact-form": "1.30.5", + "@tanstack/preact-pacer": "^0.24.2", + "@tanstack/preact-pacer-devtools": "0.8.1", + "@tanstack/preact-table": "^9.3.1", + "@tanstack/preact-table-devtools": "^9.3.2", "@tanstack/react-form-devtools": "^0.2.34", - "preact": "^10.29.8", - "zod": "^4.4.3" + "preact": "^11.2.0", + "zod": "^4.6.7" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/with-tanstack-form/src/table.tsx b/examples/preact/with-tanstack-form/src/table.tsx index 87e980aa7f..a6f1ad9a5a 100644 --- a/examples/preact/with-tanstack-form/src/table.tsx +++ b/examples/preact/with-tanstack-form/src/table.tsx @@ -14,7 +14,7 @@ import { tableFeatures, } from '@tanstack/preact-table' import { useDebouncedCallback } from '@tanstack/preact-pacer/debouncer' -import type { JSX } from 'preact' +import type { ComponentProps } from 'preact' import type { Column, PreactTable } from '@tanstack/preact-table' function SortIndicator() { @@ -183,6 +183,11 @@ function Filter({ ) } +// Keeps Preact's per-`type` prop union intact. +type DistributiveOmit = T extends unknown + ? Omit + : never + function DebouncedInput({ value: initialValue, onChange, @@ -194,7 +199,7 @@ function DebouncedInput({ onChange: (value: string | number) => void debounce?: number devtoolsKey: string -} & Omit, 'onChange'>) { +} & DistributiveOmit, 'onChange' | 'value'>) { const [value, setValue] = useState(initialValue) useEffect(() => { diff --git a/examples/preact/with-tanstack-query/package.json b/examples/preact/with-tanstack-query/package.json index 407e981fd2..9ba2927e4f 100644 --- a/examples/preact/with-tanstack-query/package.json +++ b/examples/preact/with-tanstack-query/package.json @@ -12,17 +12,18 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-devtools": "^0.10.10", - "@tanstack/preact-query": "^5.101.4", - "@tanstack/preact-query-devtools": "^5.101.4", - "@tanstack/preact-table": "^9.1.2", - "@tanstack/preact-table-devtools": "^9.2.0", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-devtools": "^0.10.15", + "@tanstack/preact-query": "^5.107.1", + "@tanstack/preact-query-devtools": "^5.107.1", + "@tanstack/preact-table": "^9.3.1", + "@tanstack/preact-table-devtools": "^9.3.2", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/aggregation/package.json b/examples/react/aggregation/package.json index b45c27cd83..d4479a9527 100644 --- a/examples/react/aggregation/package.json +++ b/examples/react/aggregation/package.json @@ -11,19 +11,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/basic-dynamic-columns/package.json b/examples/react/basic-dynamic-columns/package.json index f3e294ab6f..3c7b2b249e 100644 --- a/examples/react/basic-dynamic-columns/package.json +++ b/examples/react/basic-dynamic-columns/package.json @@ -12,22 +12,23 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/basic-external-atoms/package.json b/examples/react/basic-external-atoms/package.json index ac2f323c46..3b5c29e01b 100644 --- a/examples/react/basic-external-atoms/package.json +++ b/examples/react/basic-external-atoms/package.json @@ -12,22 +12,23 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-store": "^0.11.1", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-store": "^0.11.2", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/basic-external-state/package.json b/examples/react/basic-external-state/package.json index d5628e0765..910b17e56a 100644 --- a/examples/react/basic-external-state/package.json +++ b/examples/react/basic-external-state/package.json @@ -12,22 +12,23 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-store": "^0.11.1", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-store": "^0.11.2", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/basic-subscribe/package.json b/examples/react/basic-subscribe/package.json index cb3f202544..d3e9847539 100644 --- a/examples/react/basic-subscribe/package.json +++ b/examples/react/basic-subscribe/package.json @@ -12,23 +12,24 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-store": "^0.11.1", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-store": "^0.11.2", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/basic-use-app-table/package.json b/examples/react/basic-use-app-table/package.json index 1e4dac894e..cb02103f47 100644 --- a/examples/react/basic-use-app-table/package.json +++ b/examples/react/basic-use-app-table/package.json @@ -12,20 +12,21 @@ "test:types": "tsc" }, "dependencies": { - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/basic-use-legacy-table/package.json b/examples/react/basic-use-legacy-table/package.json index 6ac575250a..519658ffd8 100644 --- a/examples/react/basic-use-legacy-table/package.json +++ b/examples/react/basic-use-legacy-table/package.json @@ -12,22 +12,23 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/basic-use-table/package.json b/examples/react/basic-use-table/package.json index ef176577a7..b1c106fcd0 100644 --- a/examples/react/basic-use-table/package.json +++ b/examples/react/basic-use-table/package.json @@ -12,20 +12,21 @@ "test:types": "tsc" }, "dependencies": { - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/cell-selection/package.json b/examples/react/cell-selection/package.json index 608f859423..65ff49435c 100644 --- a/examples/react/cell-selection/package.json +++ b/examples/react/cell-selection/package.json @@ -12,23 +12,24 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-hotkeys": "^0.10.0", - "@tanstack/react-store": "^0.11.1", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-hotkeys": "^0.25.0", + "@tanstack/react-store": "^0.11.2", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/cell-spanning/package.json b/examples/react/cell-spanning/package.json index 0ceff563d5..55b4f57e7b 100644 --- a/examples/react/cell-spanning/package.json +++ b/examples/react/cell-spanning/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/column-dnd/package.json b/examples/react/column-dnd/package.json index 5b2055651a..3b30212f44 100644 --- a/examples/react/column-dnd/package.json +++ b/examples/react/column-dnd/package.json @@ -16,19 +16,20 @@ "@dnd-kit/modifiers": "^9.0.0", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/column-ordering/package.json b/examples/react/column-ordering/package.json index 6ce98d7358..f931b7f315 100644 --- a/examples/react/column-ordering/package.json +++ b/examples/react/column-ordering/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/column-pinning-split/package.json b/examples/react/column-pinning-split/package.json index 7712f2fe2b..36b957de0c 100644 --- a/examples/react/column-pinning-split/package.json +++ b/examples/react/column-pinning-split/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/column-pinning-sticky/package.json b/examples/react/column-pinning-sticky/package.json index 4eaf8cb856..318e095aba 100644 --- a/examples/react/column-pinning-sticky/package.json +++ b/examples/react/column-pinning-sticky/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/column-pinning/package.json b/examples/react/column-pinning/package.json index 9a6af3970e..566786950d 100644 --- a/examples/react/column-pinning/package.json +++ b/examples/react/column-pinning/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/column-resizing-performant/package.json b/examples/react/column-resizing-performant/package.json index f79d0a3925..e7467c5d4c 100644 --- a/examples/react/column-resizing-performant/package.json +++ b/examples/react/column-resizing-performant/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/column-resizing/package.json b/examples/react/column-resizing/package.json index 1021d16b2b..ee0897255b 100644 --- a/examples/react/column-resizing/package.json +++ b/examples/react/column-resizing/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/column-sizing/package.json b/examples/react/column-sizing/package.json index c6d5ff4d96..76997d9116 100644 --- a/examples/react/column-sizing/package.json +++ b/examples/react/column-sizing/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/column-visibility/package.json b/examples/react/column-visibility/package.json index 8464747d62..618d48601e 100644 --- a/examples/react/column-visibility/package.json +++ b/examples/react/column-visibility/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/composable-tables/package.json b/examples/react/composable-tables/package.json index 67f4b6942d..3fba9c6033 100644 --- a/examples/react/composable-tables/package.json +++ b/examples/react/composable-tables/package.json @@ -12,22 +12,23 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-store": "^0.11.1", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-store": "^0.11.2", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/custom-plugin/package.json b/examples/react/custom-plugin/package.json index b8f9fd6c61..f1266c1c91 100644 --- a/examples/react/custom-plugin/package.json +++ b/examples/react/custom-plugin/package.json @@ -12,20 +12,21 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/expanding/package.json b/examples/react/expanding/package.json index 90c5e0f7a1..86afb1a234 100644 --- a/examples/react/expanding/package.json +++ b/examples/react/expanding/package.json @@ -12,20 +12,21 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/filters-faceted-bucketed/package.json b/examples/react/filters-faceted-bucketed/package.json index 8cc017b5a4..b55873387a 100644 --- a/examples/react/filters-faceted-bucketed/package.json +++ b/examples/react/filters-faceted-bucketed/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/filters-faceted/package.json b/examples/react/filters-faceted/package.json index 2db49ba878..a6e379e632 100644 --- a/examples/react/filters-faceted/package.json +++ b/examples/react/filters-faceted/package.json @@ -12,21 +12,22 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/filters-fuzzy/package.json b/examples/react/filters-fuzzy/package.json index 41836cd781..f94ca708cd 100644 --- a/examples/react/filters-fuzzy/package.json +++ b/examples/react/filters-fuzzy/package.json @@ -12,21 +12,22 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/filters/package.json b/examples/react/filters/package.json index 8806d603ae..a424a16faf 100644 --- a/examples/react/filters/package.json +++ b/examples/react/filters/package.json @@ -12,21 +12,22 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/grouped-aggregation/package.json b/examples/react/grouped-aggregation/package.json index 1b721cfc61..34812c1e3c 100644 --- a/examples/react/grouped-aggregation/package.json +++ b/examples/react/grouped-aggregation/package.json @@ -11,19 +11,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/grouping/package.json b/examples/react/grouping/package.json index 118c9ab9ad..7e69037713 100644 --- a/examples/react/grouping/package.json +++ b/examples/react/grouping/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/header-groups/package.json b/examples/react/header-groups/package.json index 7105e925af..18a62994fd 100644 --- a/examples/react/header-groups/package.json +++ b/examples/react/header-groups/package.json @@ -12,19 +12,20 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/kitchen-sink-chakra-ui/package.json b/examples/react/kitchen-sink-chakra-ui/package.json index 8d7a96bb5b..d3cfcf3511 100644 --- a/examples/react/kitchen-sink-chakra-ui/package.json +++ b/examples/react/kitchen-sink-chakra-ui/package.json @@ -12,32 +12,33 @@ "test:types": "tsc" }, "dependencies": { - "@chakra-ui/react": "^3.36.1", + "@chakra-ui/react": "^3.38.0", "@dnd-kit/core": "^6.3.1", "@dnd-kit/modifiers": "^9.0.0", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", "@emotion/react": "^11.14.0", - "@faker-js/faker": "^10.5.0", - "@tabler/icons-react": "^3.46.0", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", + "@faker-js/faker": "^10.6.0", + "@tabler/icons-react": "^3.51.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", "date-fns": "^4.4.0", "next-themes": "^0.4.6", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/kitchen-sink-chakra-ui/src/main.tsx b/examples/react/kitchen-sink-chakra-ui/src/main.tsx index c4b2ce0b82..b86c2f5976 100644 --- a/examples/react/kitchen-sink-chakra-ui/src/main.tsx +++ b/examples/react/kitchen-sink-chakra-ui/src/main.tsx @@ -174,6 +174,9 @@ function ChakraExampleProvider({ children }: { children: React.ReactNode }) { defaultTheme="system" enableSystem disableTransitionOnChange + // This client-only example applies themes through effects, so the SSR + // initialization script should remain inert. + scriptProps={{ type: 'text/plain' }} > {children} diff --git a/examples/react/kitchen-sink-chakra-ui/tests/e2e/smoke.spec.ts b/examples/react/kitchen-sink-chakra-ui/tests/e2e/smoke.spec.ts index d1b9fe970b..a1ecc2f1e9 100644 --- a/examples/react/kitchen-sink-chakra-ui/tests/e2e/smoke.spec.ts +++ b/examples/react/kitchen-sink-chakra-ui/tests/e2e/smoke.spec.ts @@ -92,3 +92,23 @@ test('regenerates table data', async ({ page }) => { await server.close() } }) + +test('switches themes and restores the saved preference', async ({ page }) => { + const { errors, server } = await openExample(page) + + try { + await page.getByRole('button', { name: 'Theme', exact: true }).click() + await page.getByRole('menuitem', { name: 'Dark', exact: true }).click() + await expect(page.locator('html')).toHaveClass(/dark/) + + await page.reload() + await expect(page.locator('html')).toHaveClass(/dark/) + + await page.getByRole('button', { name: 'Theme', exact: true }).click() + await page.getByRole('menuitem', { name: 'Light', exact: true }).click() + await expect(page.locator('html')).toHaveClass(/light/) + expect(errors).toEqual([]) + } finally { + await server.close() + } +}) diff --git a/examples/react/kitchen-sink-hero-ui/package.json b/examples/react/kitchen-sink-hero-ui/package.json index cb36864bb7..1c148d7ebb 100644 --- a/examples/react/kitchen-sink-hero-ui/package.json +++ b/examples/react/kitchen-sink-hero-ui/package.json @@ -16,28 +16,29 @@ "@dnd-kit/modifiers": "^9.0.0", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", - "@faker-js/faker": "^10.5.0", - "@heroui/react": "^3.2.4", - "@heroui/styles": "^3.2.4", - "@tailwindcss/vite": "^4.3.3", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", + "@faker-js/faker": "^10.6.0", + "@heroui/react": "^3.2.7", + "@heroui/styles": "^3.2.7", + "@tailwindcss/vite": "^4.3.5", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", "date-fns": "^4.4.0", - "react": "^19.2.8", - "react-dom": "^19.2.8", - "tailwindcss": "^4.3.3" + "react": "^19.3.1", + "react-dom": "^19.3.1", + "tailwindcss": "^4.3.5" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/kitchen-sink-mantine/package.json b/examples/react/kitchen-sink-mantine/package.json index a2e914c8c7..dd9d9ee2e4 100644 --- a/examples/react/kitchen-sink-mantine/package.json +++ b/examples/react/kitchen-sink-mantine/package.json @@ -16,30 +16,31 @@ "@dnd-kit/modifiers": "^9.0.0", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", - "@faker-js/faker": "^10.5.0", - "@mantine/core": "^9.5.1", - "@mantine/hooks": "^9.5.1", - "@tabler/icons-react": "^3.46.0", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", + "@faker-js/faker": "^10.6.0", + "@mantine/core": "^9.8.0", + "@mantine/hooks": "^9.8.0", + "@tabler/icons-react": "^3.51.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", "date-fns": "^4.4.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", - "postcss": "^8.5.26", + "postcss": "^8.5.32", "postcss-preset-mantine": "^1.18.0", "postcss-simple-vars": "^7.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/kitchen-sink-material-ui/package.json b/examples/react/kitchen-sink-material-ui/package.json index c15ec3ce9e..82927d2a0d 100644 --- a/examples/react/kitchen-sink-material-ui/package.json +++ b/examples/react/kitchen-sink-material-ui/package.json @@ -18,26 +18,27 @@ "@dnd-kit/utilities": "^3.2.2", "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.1", - "@faker-js/faker": "^10.5.0", - "@mui/icons-material": "^9.3.1", - "@mui/material": "^9.3.1", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", + "@faker-js/faker": "^10.6.0", + "@mui/icons-material": "^9.5.0", + "@mui/material": "^9.5.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", "date-fns": "^4.4.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/kitchen-sink-react-aria/package.json b/examples/react/kitchen-sink-react-aria/package.json index 5c56f119c8..a59eb4390c 100644 --- a/examples/react/kitchen-sink-react-aria/package.json +++ b/examples/react/kitchen-sink-react-aria/package.json @@ -16,27 +16,28 @@ "@dnd-kit/modifiers": "^9.0.0", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", - "@faker-js/faker": "^10.5.0", - "@tailwindcss/vite": "^4.3.3", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", + "@faker-js/faker": "^10.6.0", + "@tailwindcss/vite": "^4.3.5", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", "date-fns": "^4.4.0", - "react": "^19.2.8", - "react-aria-components": "^1.20.0", - "react-dom": "^19.2.8", - "tailwindcss": "^4.3.3" + "react": "^19.3.1", + "react-aria-components": "^1.22.1", + "react-dom": "^19.3.1", + "tailwindcss": "^4.3.5" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/kitchen-sink-shadcn-base/package.json b/examples/react/kitchen-sink-shadcn-base/package.json index 6d1b5a2361..bcee9606b8 100644 --- a/examples/react/kitchen-sink-shadcn-base/package.json +++ b/examples/react/kitchen-sink-shadcn-base/package.json @@ -13,38 +13,39 @@ "shadcn": "pnpm dlx shadcn@latest" }, "dependencies": { - "@base-ui/react": "^1.7.0", + "@base-ui/react": "^1.9.0", "@dnd-kit/core": "^6.3.1", "@dnd-kit/modifiers": "^9.0.0", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", - "@faker-js/faker": "^10.5.0", - "@tailwindcss/vite": "^4.3.3", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", + "@faker-js/faker": "^10.6.0", + "@tailwindcss/vite": "^4.3.5", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "1.1.1", "date-fns": "^4.4.0", - "lucide-react": "^1.31.0", - "react": "^19.2.8", - "react-day-picker": "10.0.1", - "react-dom": "^19.2.8", - "tailwind-merge": "^3.6.0", - "tailwindcss": "^4.3.3", + "lucide-react": "^1.72.0", + "react": "^19.3.1", + "react-day-picker": "10.0.2", + "react-dom": "^19.3.1", + "tailwind-merge": "^3.7.0", + "tailwindcss": "^4.3.5", "tw-animate-css": "^1.4.0" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/kitchen-sink-shadcn-radix/package.json b/examples/react/kitchen-sink-shadcn-radix/package.json index 1e10cfc453..b34eefac92 100644 --- a/examples/react/kitchen-sink-shadcn-radix/package.json +++ b/examples/react/kitchen-sink-shadcn-radix/package.json @@ -17,34 +17,35 @@ "@dnd-kit/modifiers": "^9.0.0", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", - "@faker-js/faker": "^10.5.0", - "@tailwindcss/vite": "^4.3.3", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", + "@faker-js/faker": "^10.6.0", + "@tailwindcss/vite": "^4.3.5", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "1.1.1", "date-fns": "^4.4.0", - "lucide-react": "^1.31.0", - "radix-ui": "^1.6.7", - "react": "^19.2.8", - "react-day-picker": "10.0.1", - "react-dom": "^19.2.8", - "tailwind-merge": "^3.6.0", - "tailwindcss": "^4.3.3", + "lucide-react": "^1.72.0", + "radix-ui": "^1.8.1", + "react": "^19.3.1", + "react-day-picker": "10.0.2", + "react-dom": "^19.3.1", + "tailwind-merge": "^3.7.0", + "tailwindcss": "^4.3.5", "tw-animate-css": "^1.4.0" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/kitchen-sink/package.json b/examples/react/kitchen-sink/package.json index d002d2bfff..5bcfc33531 100644 --- a/examples/react/kitchen-sink/package.json +++ b/examples/react/kitchen-sink/package.json @@ -16,27 +16,28 @@ "@dnd-kit/modifiers": "^9.0.0", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", - "@faker-js/faker": "^10.5.0", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/react-devtools": "^0.10.10", - "@tanstack/react-hotkeys": "^0.10.0", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-router": "^1.170.27", - "@tanstack/react-start": "^1.168.44", - "@tanstack/react-store": "^0.11.1", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-table-devtools": "^9.2.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/react-devtools": "^0.10.14", + "@tanstack/react-hotkeys": "^0.25.0", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-router": "^1.170.46", + "@tanstack/react-start": "^1.169.5", + "@tanstack/react-store": "^0.11.2", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-table-devtools": "^9.3.2", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", - "@types/node": "^26.2.0", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", + "@types/node": "^26.6.6", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/kitchen-sink/src/router.tsx b/examples/react/kitchen-sink/src/router.tsx index 16ab116fb4..5f2f7b01bc 100644 --- a/examples/react/kitchen-sink/src/router.tsx +++ b/examples/react/kitchen-sink/src/router.tsx @@ -5,7 +5,9 @@ export function getRouter() { const router = createRouter({ routeTree, defaultPreload: 'intent', - defaultErrorComponent: (err) =>
{err.error.stack}
, + defaultErrorComponent: ({ error }) => ( +
{error instanceof Error ? error.stack : String(error)}
+ ), defaultNotFoundComponent: () =>

not found

, scrollRestoration: true, }) diff --git a/examples/react/lib-chakra-ui/package.json b/examples/react/lib-chakra-ui/package.json index 66b2be1bf4..ec0a306a55 100644 --- a/examples/react/lib-chakra-ui/package.json +++ b/examples/react/lib-chakra-ui/package.json @@ -12,22 +12,23 @@ "test:types": "tsc" }, "dependencies": { - "@chakra-ui/react": "^3.36.1", + "@chakra-ui/react": "^3.38.0", "@emotion/react": "^11.14.0", - "@faker-js/faker": "^10.5.0", - "@tabler/icons-react": "^3.46.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tabler/icons-react": "^3.51.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/lib-hero-ui/package.json b/examples/react/lib-hero-ui/package.json index eda991be82..37da7bc82f 100644 --- a/examples/react/lib-hero-ui/package.json +++ b/examples/react/lib-hero-ui/package.json @@ -12,23 +12,24 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@heroui/react": "^3.2.4", - "@heroui/styles": "^3.2.4", - "@tailwindcss/vite": "^4.3.3", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8", - "tailwindcss": "^4.3.3" + "@faker-js/faker": "^10.6.0", + "@heroui/react": "^3.2.7", + "@heroui/styles": "^3.2.7", + "@tailwindcss/vite": "^4.3.5", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1", + "tailwindcss": "^4.3.5" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/lib-mantine/package.json b/examples/react/lib-mantine/package.json index f09d31bf77..6561844cda 100644 --- a/examples/react/lib-mantine/package.json +++ b/examples/react/lib-mantine/package.json @@ -12,25 +12,26 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@mantine/core": "^9.5.1", - "@mantine/hooks": "^9.5.1", - "@tabler/icons-react": "^3.46.0", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@mantine/core": "^9.8.0", + "@mantine/hooks": "^9.8.0", + "@tabler/icons-react": "^3.51.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", - "postcss": "^8.5.26", + "postcss": "^8.5.32", "postcss-preset-mantine": "^1.18.0", "postcss-simple-vars": "^7.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/lib-material-ui/package.json b/examples/react/lib-material-ui/package.json index 121bfd06cb..2fa3bf8950 100644 --- a/examples/react/lib-material-ui/package.json +++ b/examples/react/lib-material-ui/package.json @@ -14,21 +14,22 @@ "dependencies": { "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.1", - "@faker-js/faker": "^10.5.0", - "@mui/icons-material": "^9.3.1", - "@mui/material": "^9.3.1", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@mui/icons-material": "^9.5.0", + "@mui/material": "^9.5.0", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/lib-react-aria/package.json b/examples/react/lib-react-aria/package.json index 87dbd92ce3..c1769aec5e 100644 --- a/examples/react/lib-react-aria/package.json +++ b/examples/react/lib-react-aria/package.json @@ -12,22 +12,23 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tailwindcss/vite": "^4.3.3", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-aria-components": "^1.20.0", - "react-dom": "^19.2.8", - "tailwindcss": "^4.3.3" + "@faker-js/faker": "^10.6.0", + "@tailwindcss/vite": "^4.3.5", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-aria-components": "^1.22.1", + "react-dom": "^19.3.1", + "tailwindcss": "^4.3.5" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/lib-shadcn-base/package.json b/examples/react/lib-shadcn-base/package.json index 28b63330c7..b41548ff3d 100644 --- a/examples/react/lib-shadcn-base/package.json +++ b/examples/react/lib-shadcn-base/package.json @@ -12,28 +12,29 @@ "test:types": "tsc" }, "dependencies": { - "@base-ui/react": "^1.7.0", - "@faker-js/faker": "^10.5.0", - "@tailwindcss/vite": "^4.3.3", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", + "@base-ui/react": "^1.9.0", + "@faker-js/faker": "^10.6.0", + "@tailwindcss/vite": "^4.3.5", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", - "lucide-react": "^1.31.0", - "react": "^19.2.8", - "react-dom": "^19.2.8", - "tailwind-merge": "^3.6.0", - "tailwindcss": "^4.3.3", + "lucide-react": "^1.72.0", + "react": "^19.3.1", + "react-dom": "^19.3.1", + "tailwind-merge": "^3.7.0", + "tailwindcss": "^4.3.5", "tw-animate-css": "^1.4.0" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/lib-shadcn-radix/package.json b/examples/react/lib-shadcn-radix/package.json index b6514d823c..06d064383d 100644 --- a/examples/react/lib-shadcn-radix/package.json +++ b/examples/react/lib-shadcn-radix/package.json @@ -12,28 +12,29 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tailwindcss/vite": "^4.3.3", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-table": "^9.1.2", + "@faker-js/faker": "^10.6.0", + "@tailwindcss/vite": "^4.3.5", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-table": "^9.3.1", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", - "lucide-react": "^1.31.0", - "radix-ui": "^1.6.7", - "react": "^19.2.8", - "react-dom": "^19.2.8", - "tailwind-merge": "^3.6.0", - "tailwindcss": "^4.3.3", + "lucide-react": "^1.72.0", + "radix-ui": "^1.8.1", + "react": "^19.3.1", + "react-dom": "^19.3.1", + "tailwind-merge": "^3.7.0", + "tailwindcss": "^4.3.5", "tw-animate-css": "^1.4.0" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/mantine-react-table/package.json b/examples/react/mantine-react-table/package.json index b96aea3f77..6c63617aa5 100644 --- a/examples/react/mantine-react-table/package.json +++ b/examples/react/mantine-react-table/package.json @@ -12,31 +12,32 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@mantine/core": "^9.5.1", - "@mantine/dates": "^9.5.1", - "@mantine/hooks": "^9.5.1", - "@tabler/icons-react": "^3.46.0", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/react-store": "^0.11.1", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-virtual": "^3.14.9", + "@faker-js/faker": "^10.6.0", + "@mantine/core": "^9.8.0", + "@mantine/dates": "^9.8.0", + "@mantine/hooks": "^9.8.0", + "@tabler/icons-react": "^3.51.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/react-store": "^0.11.2", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-virtual": "^3.14.26", "clsx": "^2.1.1", - "dayjs": "^1.11.21", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "dayjs": "^1.11.23", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", - "postcss": "^8.5.26", + "postcss": "^8.5.32", "postcss-preset-mantine": "^1.18.0", "postcss-simple-vars": "^7.0.1", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/mantine-react-table/src/mantine-react-table/locales/np.ts b/examples/react/mantine-react-table/src/mantine-react-table/locales/np.ts index d531fdf857..c3124731b4 100644 --- a/examples/react/mantine-react-table/src/mantine-react-table/locales/np.ts +++ b/examples/react/mantine-react-table/src/mantine-react-table/locales/np.ts @@ -44,8 +44,7 @@ export const MRT_Localization_NP: MRT_Localization = { filterNotEquals: 'असमान', filterStartsWith: 'सुरुमा समावेश गरिएको', filterWeakEquals: 'असमान', - filteringByColumn: - '{column} द्वारा फिल्टर गर्दै - {filterType} {filterValue}', + filteringByColumn: '{column} द्वारा फिल्टर गर्दै - {filterType} {filterValue}', goToFirstPage: 'पहिलो पृष्ठमा जानुहोस्', goToLastPage: 'अन्तिम पृष्ठमा जानुहोस्', goToNextPage: 'अर्को पृष्ठमा जानुहोस्', diff --git a/examples/react/mantine-react-table/src/mantine-react-table/locales/th.ts b/examples/react/mantine-react-table/src/mantine-react-table/locales/th.ts index 8b563f041d..1f59242350 100644 --- a/examples/react/mantine-react-table/src/mantine-react-table/locales/th.ts +++ b/examples/react/mantine-react-table/src/mantine-react-table/locales/th.ts @@ -36,8 +36,7 @@ export const MRT_Localization_TH: MRT_Localization = { filterGreaterThanOrEqualTo: 'กรองเมื่อมากกว่าหรือเท่ากับ', filterInNumberRange: 'กรองเมื่อค่าอยู่อยู่ในช่วง', filterIncludesString: 'กรองเมื่อมีข้อความว่า', - filterIncludesStringSensitive: - 'กรองเมื่อมีข้อความว่า (ตรงตามตัวพิมพ์ใหญ่-เล็ก)', + filterIncludesStringSensitive: 'กรองเมื่อมีข้อความว่า (ตรงตามตัวพิมพ์ใหญ่-เล็ก)', filterLessThan: 'กรองเมื่อน้อยกว่า', filterLessThanOrEqualTo: 'กรองเมื่อน้อยกว่าหรือเท่ากับ', filterMode: 'โหมดการกรอง: {filterType}', diff --git a/examples/react/material-react-table/package.json b/examples/react/material-react-table/package.json index 5c8f2a8153..8e14283fb7 100644 --- a/examples/react/material-react-table/package.json +++ b/examples/react/material-react-table/package.json @@ -14,27 +14,28 @@ "dependencies": { "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.1", - "@faker-js/faker": "^10.5.0", - "@mui/icons-material": "^9.3.1", - "@mui/material": "^9.3.1", - "@mui/x-date-pickers": "^9.11.0", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/react-pacer": "^0.23.0", - "@tanstack/react-store": "^0.11.1", - "@tanstack/react-table": "^9.1.2", - "@tanstack/react-virtual": "^3.14.9", + "@faker-js/faker": "^10.6.0", + "@mui/icons-material": "^9.5.0", + "@mui/material": "^9.5.0", + "@mui/x-date-pickers": "^9.18.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/react-pacer": "^0.24.1", + "@tanstack/react-store": "^0.11.2", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-virtual": "^3.14.26", "highlight-words": "^2.0.0", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/material-react-table/src/material-react-table/locales/np.ts b/examples/react/material-react-table/src/material-react-table/locales/np.ts index 1148aac6ad..6e3fd90016 100644 --- a/examples/react/material-react-table/src/material-react-table/locales/np.ts +++ b/examples/react/material-react-table/src/material-react-table/locales/np.ts @@ -45,8 +45,7 @@ export const MRT_Localization_NP: MRT_Localization = { filterNotEquals: 'असमान', filterStartsWith: 'सुरुमा समावेश गरिएको', filterWeakEquals: 'असमान', - filteringByColumn: - '{column} द्वारा फिल्टर गर्दै - {filterType} {filterValue}', + filteringByColumn: '{column} द्वारा फिल्टर गर्दै - {filterType} {filterValue}', goToFirstPage: 'पहिलो पृष्ठमा जानुहोस्', goToLastPage: 'अन्तिम पृष्ठमा जानुहोस्', goToNextPage: 'अर्को पृष्ठमा जानुहोस्', diff --git a/examples/react/pagination/package.json b/examples/react/pagination/package.json index 412467a6af..70c08fc6ac 100644 --- a/examples/react/pagination/package.json +++ b/examples/react/pagination/package.json @@ -12,20 +12,21 @@ "test:types": "tsc" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/react-store": "^0.11.1", - "@tanstack/react-table": "^9.1.2", - "react": "^19.2.8", - "react-dom": "^19.2.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/react-store": "^0.11.2", + "@tanstack/react-table": "^9.3.1", + "react": "^19.3.1", + "react-dom": "^19.3.1" }, "devDependencies": { - "@rolldown/plugin-babel": "^0.2.3", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", "@rollup/plugin-replace": "^6.0.3", - "@types/react": "^19.2.18", - "@types/react-dom": "^19.2.4", - "@vitejs/plugin-react": "^6.0.5", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", "babel-plugin-react-compiler": "^1.0.0", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/react/realtime-trading/README.md b/examples/react/realtime-trading/README.md new file mode 100644 index 0000000000..3b92048931 --- /dev/null +++ b/examples/react/realtime-trading/README.md @@ -0,0 +1,252 @@ +# React realtime trading benchmark + +This is a standalone stress example for the current TanStack React Table +adapter. It combines a high-frequency synthetic market feed, immutable row +snapshots, sortable and resizable columns, range selection, dynamic React cell +components, optional row virtualization, React Profiler measurements, and +browser performance instrumentation. + +The goal is to make feed work, message delivery, state application, table work, +React commits, and browser layout independently observable. It is a repeatable +rendering benchmark, not an exchange or network simulator. + +## Run and verify + +```bash +pnpm --dir examples/react/realtime-trading dev +``` + +Open `http://localhost:7777`. + +For React commit timings, use the profiling production build: + +```bash +pnpm --dir examples/react/realtime-trading build:profile +``` + +The normal verification commands are: + +```bash +pnpm --dir examples/react/realtime-trading test:types +pnpm --dir examples/react/realtime-trading lint +pnpm --dir examples/react/realtime-trading build +pnpm --dir examples/react/realtime-trading test:e2e +``` + +Development builds include React checks and produce deliberately pessimistic +timings. The standard production build disables Profiler callbacks; the +`profile` mode aliases the profiling React DOM client so commit metrics remain +available. + +## Directory structure + +| Path | Responsibility | +| ------------------------- | ------------------------------------------------------------------------------------------------------------------ | +| `src/feed/` | Market types, instruments, feed configuration, immutable update helpers, controller, and React lifecycle hook. | +| `src/feed/worker/` | Worker protocol, deterministic market engine, and the module Web Worker. | +| `src/benchmark/` | Browser monitor, benchmark controller, table observers, and React Profiler integration. | +| `src/shell/` | Controller contexts, full-viewport shell, metrics, configurator, diagnostics, selected instrument, and status bar. | +| `src/table/table-config/` | Grouped columns, row boundary, custom cells, and render counters. | +| `src/table/` | Table instance, subscription boundaries, interactions, pointer hook, initial fit, and virtualization. | +| `src/App.tsx` | Composition root; creates controllers, providers, shell, table, and Profiler boundary. | + +Feed state and benchmark state are intentionally separate. `MarketFeedController` +can run without `TradingBenchmarkController`; the latter observes feed lifecycle +events and owns only controls/metrics used by this benchmark UI. + +## Data and worker pipeline + +The initial configuration is 100 instruments, 10K generated samples per +second, a 20 ms delivery interval, enabled intraday charts, and 16 ms intraday +sampling. + +1. `MarketFeedController` starts a module worker and sends the active config. +2. `market-feed-engine.ts` mutates worker-private quote state using a + deterministic PRNG and stable instrument IDs. +3. A 16 ms loop accrues a fractional sample budget and produces the requested + amount of synthetic market work. +4. A `Map` keyed by row index retains the latest pending update for each + instrument, coalescing repeated samples. +5. A separate timer publishes at the selected delivery interval. Worker work + rate and `postMessage` rate are deliberately independent. +6. The main thread creates a new outer quotes array and replaces only the rows + present in the message. Unchanged row objects remain referentially stable. +7. History arrays change only on an intraday sample. A session ID discards stale + messages after reset or instrument-count changes. + +UI terminology: + +- **Synthetic quote workload** means generated samples per second inside the + worker, not browser events, React renders, or messages. +- **Worker delivery interval** is the target coalesced-message cadence; 20 ms + targets approximately 50 messages per second. +- **Changed rows** counts immutable row objects applied on the main thread. + Rows are deduplicated within one snapshot, but the same row can be counted + again in a later snapshot, so this is intentionally a throughput rate rather + than a count of distinct instruments over the whole second. +- **Message samples** is the generated work represented by the latest message. + +Intraday history sampling is independent of the quote workload, and the 25K +burst creates one intentionally expensive immediate batch. The worker resembles +an upstream WebSocket/SSE producer but does not include network latency. + +## React state and rendering architecture + +- `MarketFeedController` exposes each feed value as a direct TanStack atom: + `quotes`, status, row count, workload, delivery, and chart controls do not + share one aggregate `MarketFeedState` notification. +- `quotes` is its own high-frequency atom. The table subscribes to it directly, + while the header/configurator subscribe only to their lower-frequency atoms. +- Benchmark summary state remains a TanStack Store because its metrics are + published together as one coherent snapshot. +- `createStoreContext` provides the controllers without making every consumer + subscribe to the complete state object. +- Shell components call `useSelector` with narrow slices and shallow comparison + where a selector returns an object. +- Selected symbol and renderer mode are dedicated atoms because they have + different consumers and update frequencies from aggregate diagnostics. +- `TradingTable` subscribes directly to quote data and the virtualization + inputs it needs; the parent shell does not receive the quotes array. +- `table.Subscribe` boundaries isolate sorting/filtering/order changes, each + resize handle, and each row's selection state. +- Stable row IDs come from instrument IDs through `getRowId`. + +React Compiler is enabled in the Vite Babel pipeline for `src`. The current +adapter is compiled normally; there is no historical v8 implementation or +`use no memo` compatibility boundary in this example. Compiler optimization +does not replace correct subscription ownership: components still subscribe to +the smallest practical state slice. + +## Table behavior + +The grid has 14 leaf columns grouped into Instrument, Price & Change, Order +Book, Session, and Chart sections. It provides: + +- core sorting and filtering; +- on-change column resizing with double-click reset; +- drag-and-drop leaf-column ordering; +- CSS-only row hover; +- click/modified-click row selection; +- mouse-drag cell range selection and keyboard navigation; +- custom Price, Move, Percent Change, and Sparkline components; +- an opt-in mode that swaps move component A/B as direction changes. + +`useTradingGridPointer` installs handlers once on `tbody`. It uses +`event.composedPath()` and data attributes to resolve the TanStack cell, so the +table does not allocate pointer handlers for every cell. Refs retain transient +drag state without triggering React renders. + +Column sizes are written to CSS custom properties only when sizing or ordering +changes. Cells reference those properties, avoiding width-object churn during +quote updates. A `ResizeObserver` expands the initial column sizes to the +available viewport; the first manual resize disables later automatic fitting. + +## Full DOM and virtual rows + +The internal preference is `auto`, `tanstack`, or `none`: + +- Below 200 rows, `auto` resolves to **Full DOM**, while virtualization remains + manually selectable. +- From 200 through 1,499 rows, `auto` resolves to **TanStack Virtual**, but the + user may still choose Full DOM. +- At 1,500 rows or more, virtualization is forced and the control is locked. + +React Virtual uses a fixed 32 px estimate, 10-row overscan, stable row IDs as +item keys, transformed rows, and a body-sized spacer. The footer reports the +current range from the virtualizer. Full DOM maps the complete row model. + +Both paths apply `content-visibility: auto` with a matching intrinsic height. +For Full DOM this can reduce browser work but not React element creation or DOM +mount count. Virtualization is what limits mounted row components. + +## Performance decisions + +- Market calculations run outside the main thread. +- Repeated samples are coalesced before worker messaging. +- Immutable snapshots preserve untouched row/history references. +- Stable row keys and `getRowId` preserve identity through sorting. +- Controller contexts carry stable objects; selectors subscribe to slices. +- Table, header, resize handle, row selection, and cell renderer boundaries are + independently subscribable. +- Pointer selection is delegated and transient pointer state lives in refs. +- Column widths use CSS variables instead of per-tick style recalculation. +- Dynamic component destruction is opt-in; stable components are the baseline. +- Virtualization limits React and DOM work at larger row counts. +- Benchmark publication is throttled separately from the feed. + +A new outer data array is required to publish immutable state. Referentially +stable untouched rows, keyed rows, and narrow subscriptions reduce downstream +work; they do not guarantee that the table's sorted/filtered row model can skip +all processing when its data input changes. + +## Diagnostics + +The compact **Live health** block lives in the configurator sidebar and keeps +four cross-framework signals visible: + +- **Frame rate (est.)** counts `requestAnimationFrame` callbacks over a rolling + one-second window. It is a main-thread scheduling signal capped by the + display refresh rate, not proof of GPU-presented frames or a React Scan FPS + value. +- **Average commit latency** is the rolling three-second average from the first + pending market mutation to the table's DOM commit. Several snapshots may be + coalesced behind one commit, so this includes scheduling, React work, and DOM + commit latency; it is not component render duration. +- **Long frames** comes from the browser Long Animation Frames API and is + cumulative since reset. The worst duration is shown when supported. +- **Throughput** pairs changed rows/s with applied snapshots/s. Changed rows are + deduplicated per snapshot, not across the full reporting window. + +The detailed section retains generated worker samples, messages, state applies, +table DOM commits, a 10-second commit-latency p95/max, cumulative slow commits, +mounted hosts, component lifecycle counts, callbacks by column, executions by +component type, DOM `MutationRecord` rate, core row-model timing, and optional +heap information. + +The React Profiler additionally records actual/base duration and commit counts +when using development or the profiling build. The in-memory latency, Profiler, +and row-model aggregates inspect every call, but the Performance timeline emits +only one User Timing measure per 20 calls to avoid making instrumentation a +significant part of a hot run. Old measures are periodically pruned. + +The `MutationObserver` watches the table body for text/children and only +`class`/`style` attribute changes. Its value is browser `MutationRecord`s per +second, not DOM operations: a record can represent a coalesced change, and +framework write patterns can produce different record counts for equivalent +screens. Creating records also has real overhead at high rates, so treat it as +a diagnostic and confirm important comparisons with a Performance recording. +Heap is Chrome-only `usedJSHeapSize`, changes with garbage-collection timing, +and is useful as a trend rather than a leak verdict. + +The monitor itself schedules one lightweight `requestAnimationFrame` callback +and publishes its sidebar snapshot every 500 ms. The sidebar subscribes to that +snapshot independently, so publishing diagnostics does not update the quotes +atom or table data boundary, but it is still instrumentation overhead and must +remain enabled in both sides of an A/B comparison. React Profiler and React +DevTools also add overhead by design. + +Callback counts are not DOM mutation counts. A cell callback can execute while +React reuses the existing component and DOM. Likewise, a rising heap during the +component-swap stress test is not proof of a leak until repeated post-GC heap +snapshots show retained instances. + +Use Chrome Performance and React DevTools for call stacks/flamegraphs, and keep +the instrument count, workload, delivery interval, renderer mode, build mode, +and virtualization mode fixed between comparisons. + +React Scan remains an optional development-only aid in this example. It is not +used by any canonical counter because the other adapter examples cannot share +it, and its instrumentation can alter a recording. Use the profiling production +build without React Scan for cross-framework comparisons. + +## Standalone example policy + +This directory owns its instrument list, feed engine, worker, diagnostics, +styles, and UI instead of importing a common demo package. The duplication is +intentional: each adapter example must run independently and remain easy to +copy to StackBlitz. Shared architectural explanations are repeated in the +READMEs for the same reason. + +The package pins `@tanstack/react-table` to the repository version. The root +workspace override resolves it to `packages/react-table` while preserving a +release-like manifest. diff --git a/examples/react/realtime-trading/index.html b/examples/react/realtime-trading/index.html new file mode 100644 index 0000000000..c3dac68d53 --- /dev/null +++ b/examples/react/realtime-trading/index.html @@ -0,0 +1,17 @@ + + + + + + + + React Real-time Trading flexRender Lab + + +
+ + + diff --git a/examples/react/realtime-trading/package.json b/examples/react/realtime-trading/package.json new file mode 100644 index 0000000000..b91d7febf1 --- /dev/null +++ b/examples/react/realtime-trading/package.json @@ -0,0 +1,40 @@ +{ + "name": "tanstack-react-table-example-realtime-trading", + "private": true, + "type": "module", + "scripts": { + "start": "vite", + "dev": "vite", + "build": "vite build", + "build:profile": "vite build --mode profile", + "serve": "vite preview", + "lint": "eslint ./src", + "test:types": "tsc --noEmit", + "test:e2e": "PLAYWRIGHT_VITE_MODE=profile PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" + }, + "nx": { + "targets": { + "test:e2e": { + "parallelism": false + } + } + }, + "dependencies": { + "@tanstack/react-store": "^0.11.2", + "@tanstack/react-table": "^9.3.1", + "@tanstack/react-virtual": "^3.14.26", + "react": "^19.3.1", + "react-dom": "^19.3.1" + }, + "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@rolldown/plugin-babel": "^0.3.1", + "@rollup/plugin-replace": "^6.0.3", + "@types/react": "^19.3.0", + "@types/react-dom": "^19.3.0", + "@vitejs/plugin-react": "^6.3.0", + "babel-plugin-react-compiler": "^1.0.0", + "typescript": "6.0.3", + "vite": "^8.3.8" + } +} diff --git a/examples/react/realtime-trading/src/App.tsx b/examples/react/realtime-trading/src/App.tsx new file mode 100644 index 0000000000..2df39ff073 --- /dev/null +++ b/examples/react/realtime-trading/src/App.tsx @@ -0,0 +1,34 @@ +import { Profiler } from 'react' +import { useMarketFeedController } from './feed/use-market-feed-controller' +import { useTradingBenchmarkController } from './benchmark/use-trading-benchmark-controller' +import { TradingShell } from './shell/TradingShell' +import { + TradingShellProvider, + useTradingShellController, +} from './shell/trading-shell-context' +import { TradingTable } from './table/trading-table' + +export function App() { + const feed = useMarketFeedController() + const controller = useTradingBenchmarkController(feed) + return ( + + + + + + ) +} + +function TradingTableOutlet() { + const controller = useTradingShellController() + + return ( + + + + ) +} diff --git a/examples/react/realtime-trading/src/benchmark/benchmark-monitor.ts b/examples/react/realtime-trading/src/benchmark/benchmark-monitor.ts new file mode 100644 index 0000000000..3f8503a2cd --- /dev/null +++ b/examples/react/realtime-trading/src/benchmark/benchmark-monitor.ts @@ -0,0 +1,513 @@ +import { + quoteCellLifecycle, + quoteRenderDiagnostics, +} from '../table/table-config/quote-cells' +import { rowModelDiagnostics } from '../table/trading-table' +import type { ProfilerOnRenderCallback } from 'react' + +export interface NamedInvocationRate { + name: string + callsPerSecond: number +} + +interface TimedLatencySample { + recordedAt: number + duration: number +} + +const averageLatencyWindowMs = 3_000 +const percentileLatencyWindowMs = 10_000 +const frameRateWindowMs = 1_000 + +export interface FeedMetrics { + actualTicksPerSecond: number + rowUpdatesPerSecond: number + workerMessagesPerSecond: number + stateApplicationsPerSecond: number + supersededUpdatesPerSecond: number + totalTicks: number + estimatedFrameRate: number + tableCommitsPerSecond: number + lastBatchSize: number + averageCommitLatencyMs: number + p95CommitLatencyMs: number + maxCommitLatencyMs: number + slowCommits: number + longAnimationFrames: number + worstLongAnimationFrameMs: number + heapMb: number | null + componentsCreated: number + componentsDestroyed: number + workerMessages: number + lastUpdateCount: number + cellRendererCallsPerSecond: number + componentRenderCallsPerSecond: number + cellRendererRates: ReadonlyArray + componentRenderRates: ReadonlyArray + domMutationsPerSecond: number + profilerCommitsPerSecond: number + profilerAverageActualMs: number + profilerP95ActualMs: number + profilerAverageBaseMs: number + rowModelCallsPerSecond: number + rowModelAverageMs: number + rowModelMaxMs: number + visibleRows: number +} + +export const initialMetrics: FeedMetrics = { + actualTicksPerSecond: 0, + rowUpdatesPerSecond: 0, + workerMessagesPerSecond: 0, + stateApplicationsPerSecond: 0, + supersededUpdatesPerSecond: 0, + totalTicks: 0, + estimatedFrameRate: 0, + tableCommitsPerSecond: 0, + lastBatchSize: 0, + averageCommitLatencyMs: 0, + p95CommitLatencyMs: 0, + maxCommitLatencyMs: 0, + slowCommits: 0, + longAnimationFrames: 0, + worstLongAnimationFrameMs: 0, + heapMb: null, + componentsCreated: 0, + componentsDestroyed: 0, + workerMessages: 0, + lastUpdateCount: 0, + cellRendererCallsPerSecond: 0, + componentRenderCallsPerSecond: 0, + cellRendererRates: [], + componentRenderRates: [], + domMutationsPerSecond: 0, + profilerCommitsPerSecond: 0, + profilerAverageActualMs: 0, + profilerP95ActualMs: 0, + profilerAverageBaseMs: 0, + rowModelCallsPerSecond: 0, + rowModelAverageMs: 0, + rowModelMaxMs: 0, + visibleRows: 0, +} + +const userTiming = { + entryCount: 0, + measureCallsByName: {} as Record, +} + +export function recordMeasure( + name: string, + start: number, + end: number, + detail: Record, +): void { + const measureCall = (userTiming.measureCallsByName[name] ?? 0) + 1 + userTiming.measureCallsByName[name] = measureCall + if ((measureCall - 1) % 20 !== 0) return + + try { + performance.measure(name, { start, end, detail }) + userTiming.entryCount++ + if (userTiming.entryCount % 1_000 === 0) { + performance.clearMeasures('react-profiler-commit') + performance.clearMeasures('market-update-to-dom-commit') + } + } catch { + // User Timing Level 3 options are not implemented in every browser. + } +} + +export function markBenchmarkAction( + name: string, + detail: Record = {}, +): void { + try { + performance.mark(`benchmark:${name}`, { detail }) + userTiming.entryCount++ + if (userTiming.entryCount % 1_000 === 0) { + performance.clearMarks() + } + } catch { + // User Timing Level 3 detail is not implemented in every browser. + } +} + +interface ProfilerSample { + actualDuration: number + baseDuration: number +} + +export class BenchmarkMonitor { + readonly #runtime = { + sessionStartedAt: performance.now(), + sampleStartedAt: performance.now(), + pendingCommitStartedAt: null as number | null, + commitLatencySamples: [] as Array, + slowCommitCount: 0, + profilerSamples: [] as Array, + totalTicks: 0, + ticksInSample: 0, + rowUpdatesInSample: 0, + workerMessagesInSample: 0, + stateApplicationsInSample: 0, + supersededUpdatesInSample: 0, + lastBatchSize: 0, + lastUpdateCount: 0, + workerMessages: 0, + frameTrackingStartedAt: performance.now(), + frameTimestamps: [] as Array, + tableCommitsInSample: 0, + longAnimationFrameCount: 0, + worstLongAnimationFrameMs: 0, + previousCellRendererCalls: 0, + previousComponentRenderCalls: 0, + previousCellRendererCallsByName: { + ...quoteRenderDiagnostics.cellRendererCallsByName, + }, + previousComponentRenderCallsByName: { + ...quoteRenderDiagnostics.componentRenderCallsByName, + }, + domMutationsInSample: 0, + previousRowModelCalls: 0, + previousRowModelDuration: 0, + } + + readonly recordProfilerRender: ProfilerOnRenderCallback = ( + id, + phase, + actualDuration, + baseDuration, + startTime, + commitTime, + ) => { + this.#runtime.profilerSamples.push({ actualDuration, baseDuration }) + recordMeasure('react-profiler-commit', startTime, commitTime, { + id, + phase, + actualDuration, + baseDuration, + }) + } + + markCommitPending(): void { + this.#runtime.pendingCommitStartedAt ??= performance.now() + } + + recordDomCommit(): void { + const runtime = this.#runtime + if (runtime.pendingCommitStartedAt !== null) { + const commitEndedAt = performance.now() + const duration = commitEndedAt - runtime.pendingCommitStartedAt + runtime.commitLatencySamples.push({ + recordedAt: commitEndedAt, + duration, + }) + if (duration > 16.7) runtime.slowCommitCount++ + recordMeasure( + 'market-update-to-dom-commit', + runtime.pendingCommitStartedAt, + commitEndedAt, + {}, + ) + runtime.pendingCommitStartedAt = null + runtime.tableCommitsInSample++ + } + } + + recordWorkerMessage(): void { + this.#runtime.workerMessages++ + this.#runtime.workerMessagesInSample++ + } + + recordBatch( + tickCount: number, + updateCount: number, + supersededUpdateCount: number, + ): void { + const runtime = this.#runtime + runtime.lastBatchSize = tickCount + runtime.lastUpdateCount = updateCount + runtime.ticksInSample += tickCount + runtime.totalTicks += tickCount + runtime.rowUpdatesInSample += updateCount + runtime.stateApplicationsInSample++ + runtime.supersededUpdatesInSample += supersededUpdateCount + } + + recordAnimationFrame(now: number): void { + const timestamps = this.#runtime.frameTimestamps + timestamps.push(now) + pruneFrameTimestamps(timestamps, now) + } + + recordLongAnimationFrame(duration: number, startTime: number): void { + const runtime = this.#runtime + if (startTime < runtime.sessionStartedAt) return + + runtime.longAnimationFrameCount++ + runtime.worstLongAnimationFrameMs = Math.max( + runtime.worstLongAnimationFrameMs, + duration, + ) + } + + recordDomMutations(count: number): void { + this.#runtime.domMutationsInSample += count + } + + resetDomMutations(): void { + this.#runtime.domMutationsInSample = 0 + } + + shouldPublish(now: number): boolean { + return now - this.#runtime.sampleStartedAt >= 500 + } + + publish(now: number): FeedMetrics { + const runtime = this.#runtime + const sampleDuration = now - runtime.sampleStartedAt + pruneLatencySamples(runtime.commitLatencySamples, now) + pruneFrameTimestamps(runtime.frameTimestamps, now) + const averageCommitLatencySamples = runtime.commitLatencySamples + .filter((sample) => sample.recordedAt >= now - averageLatencyWindowMs) + .map((sample) => sample.duration) + const percentileCommitLatencySamples = runtime.commitLatencySamples.map( + (sample) => sample.duration, + ) + const sortedCommitLatencySamples = [...percentileCommitLatencySamples].sort( + (left, right) => left - right, + ) + const profilerSamples = runtime.profilerSamples + const sortedProfilerSamples = profilerSamples + .map((sample) => sample.actualDuration) + .sort((left, right) => left - right) + const rowModelCalls = + rowModelDiagnostics.calls - runtime.previousRowModelCalls + const rowModelDuration = + rowModelDiagnostics.totalDurationMs - runtime.previousRowModelDuration + const cellRendererCalls = + quoteRenderDiagnostics.cellRendererCalls - + runtime.previousCellRendererCalls + const componentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls - + runtime.previousComponentRenderCalls + const cellRendererRates = calculateInvocationRates( + quoteRenderDiagnostics.cellRendererCallsByName, + runtime.previousCellRendererCallsByName, + sampleDuration, + ) + const componentRenderRates = calculateInvocationRates( + quoteRenderDiagnostics.componentRenderCallsByName, + runtime.previousComponentRenderCallsByName, + sampleDuration, + ) + const averageCommitLatencyMs = + averageCommitLatencySamples.length === 0 + ? 0 + : averageCommitLatencySamples.reduce((sum, value) => sum + value, 0) / + averageCommitLatencySamples.length + const p95Index = Math.max( + 0, + Math.ceil(sortedCommitLatencySamples.length * 0.95) - 1, + ) + const profilerP95Index = Math.max( + 0, + Math.ceil(sortedProfilerSamples.length * 0.95) - 1, + ) + const metrics: FeedMetrics = { + actualTicksPerSecond: + sampleDuration === 0 + ? 0 + : (runtime.ticksInSample / sampleDuration) * 1_000, + rowUpdatesPerSecond: + (runtime.rowUpdatesInSample / sampleDuration) * 1_000, + workerMessagesPerSecond: + (runtime.workerMessagesInSample / sampleDuration) * 1_000, + stateApplicationsPerSecond: + (runtime.stateApplicationsInSample / sampleDuration) * 1_000, + supersededUpdatesPerSecond: + (runtime.supersededUpdatesInSample / sampleDuration) * 1_000, + totalTicks: runtime.totalTicks, + estimatedFrameRate: calculateFrameRate( + runtime.frameTimestamps, + runtime.frameTrackingStartedAt, + now, + ), + tableCommitsPerSecond: + (runtime.tableCommitsInSample / sampleDuration) * 1_000, + lastBatchSize: runtime.lastBatchSize, + averageCommitLatencyMs, + p95CommitLatencyMs: sortedCommitLatencySamples[p95Index] ?? 0, + maxCommitLatencyMs: sortedCommitLatencySamples.at(-1) ?? 0, + slowCommits: runtime.slowCommitCount, + longAnimationFrames: runtime.longAnimationFrameCount, + worstLongAnimationFrameMs: runtime.worstLongAnimationFrameMs, + heapMb: readHeapSizeMb(), + componentsCreated: quoteCellLifecycle.created, + componentsDestroyed: quoteCellLifecycle.destroyed, + workerMessages: runtime.workerMessages, + lastUpdateCount: runtime.lastUpdateCount, + cellRendererCallsPerSecond: (cellRendererCalls / sampleDuration) * 1_000, + componentRenderCallsPerSecond: + (componentRenderCalls / sampleDuration) * 1_000, + cellRendererRates, + componentRenderRates, + domMutationsPerSecond: + (runtime.domMutationsInSample / sampleDuration) * 1_000, + profilerCommitsPerSecond: + (profilerSamples.length / sampleDuration) * 1_000, + profilerAverageActualMs: + profilerSamples.length === 0 + ? 0 + : profilerSamples.reduce( + (sum, sample) => sum + sample.actualDuration, + 0, + ) / profilerSamples.length, + profilerP95ActualMs: sortedProfilerSamples[profilerP95Index] ?? 0, + profilerAverageBaseMs: + profilerSamples.length === 0 + ? 0 + : profilerSamples.reduce( + (sum, sample) => sum + sample.baseDuration, + 0, + ) / profilerSamples.length, + rowModelCallsPerSecond: (rowModelCalls / sampleDuration) * 1_000, + rowModelAverageMs: + rowModelCalls === 0 ? 0 : rowModelDuration / rowModelCalls, + rowModelMaxMs: rowModelDiagnostics.maxDurationMs, + visibleRows: rowModelDiagnostics.lastRowCount, + } + + runtime.sampleStartedAt = now + runtime.previousCellRendererCalls = quoteRenderDiagnostics.cellRendererCalls + runtime.previousComponentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls + runtime.previousCellRendererCallsByName = { + ...quoteRenderDiagnostics.cellRendererCallsByName, + } + runtime.previousComponentRenderCallsByName = { + ...quoteRenderDiagnostics.componentRenderCallsByName, + } + runtime.domMutationsInSample = 0 + runtime.profilerSamples = [] + runtime.previousRowModelCalls = rowModelDiagnostics.calls + runtime.previousRowModelDuration = rowModelDiagnostics.totalDurationMs + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.tableCommitsInSample = 0 + return metrics + } + + reset(): void { + const runtime = this.#runtime + runtime.sessionStartedAt = performance.now() + runtime.sampleStartedAt = runtime.sessionStartedAt + runtime.pendingCommitStartedAt = null + runtime.commitLatencySamples = [] + runtime.slowCommitCount = 0 + runtime.profilerSamples = [] + runtime.totalTicks = 0 + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.lastBatchSize = 0 + runtime.lastUpdateCount = 0 + runtime.workerMessages = 0 + runtime.frameTrackingStartedAt = runtime.sampleStartedAt + runtime.frameTimestamps = [] + runtime.tableCommitsInSample = 0 + runtime.longAnimationFrameCount = 0 + runtime.worstLongAnimationFrameMs = 0 + runtime.previousCellRendererCalls = quoteRenderDiagnostics.cellRendererCalls + runtime.previousComponentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls + runtime.previousCellRendererCallsByName = { + ...quoteRenderDiagnostics.cellRendererCallsByName, + } + runtime.previousComponentRenderCallsByName = { + ...quoteRenderDiagnostics.componentRenderCallsByName, + } + runtime.domMutationsInSample = 0 + runtime.previousRowModelCalls = rowModelDiagnostics.calls + runtime.previousRowModelDuration = rowModelDiagnostics.totalDurationMs + rowModelDiagnostics.maxDurationMs = 0 + } +} + +export const longAnimationFramesSupported = + PerformanceObserver.supportedEntryTypes.includes('long-animation-frame') + +function readHeapSizeMb(): number | null { + const memory = ( + performance as Performance & { + memory?: { usedJSHeapSize: number } + } + ).memory + return memory ? memory.usedJSHeapSize / 1_048_576 : null +} + +function calculateInvocationRates( + current: Record, + previous: Record, + sampleDuration: number, +): ReadonlyArray { + return Object.entries(current).map(([name, calls]) => ({ + name, + callsPerSecond: + sampleDuration === 0 + ? 0 + : ((calls - (previous[name] ?? 0)) / sampleDuration) * 1_000, + })) +} + +function pruneLatencySamples( + samples: Array, + now: number, +): void { + const cutoff = now - percentileLatencyWindowMs + const firstRetainedIndex = samples.findIndex( + (sample) => sample.recordedAt >= cutoff, + ) + if (firstRetainedIndex > 0) samples.splice(0, firstRetainedIndex) + else if (firstRetainedIndex === -1) samples.length = 0 +} + +function pruneFrameTimestamps(timestamps: Array, now: number): void { + const cutoff = now - frameRateWindowMs + const firstRetainedIndex = timestamps.findIndex( + (timestamp) => timestamp >= cutoff, + ) + if (firstRetainedIndex > 0) timestamps.splice(0, firstRetainedIndex) + else if (firstRetainedIndex === -1) timestamps.length = 0 +} + +function calculateFrameRate( + timestamps: ReadonlyArray, + trackingStartedAt: number, + now: number, +): number { + const observedWindowMs = Math.min( + frameRateWindowMs, + Math.max(1, now - trackingStartedAt), + ) + return (timestamps.length / observedWindowMs) * 1_000 +} + +export function exposeTradingBenchmarkSnapshot( + metrics: FeedMetrics, + extras: { mountedCells: number; liveComponents: number }, +): void { + Object.assign(globalThis, { + __TANSTACK_TRADING_BENCHMARK__: { + capturedAt: performance.now(), + metrics, + ...extras, + }, + }) +} diff --git a/examples/react/realtime-trading/src/benchmark/trading-benchmark-controller.ts b/examples/react/realtime-trading/src/benchmark/trading-benchmark-controller.ts new file mode 100644 index 0000000000..791f1b3a23 --- /dev/null +++ b/examples/react/realtime-trading/src/benchmark/trading-benchmark-controller.ts @@ -0,0 +1,161 @@ +import { batch, createAtom, createStore } from '@tanstack/react-store' +import { TRADING_COLUMN_COUNT } from '../table/trading-table' +import { FORCED_VIRTUALIZATION_ROW_COUNT } from '../table/trading-row-virtualizer' +import { + BenchmarkMonitor, + exposeTradingBenchmarkSnapshot, + initialMetrics, + longAnimationFramesSupported, +} from './benchmark-monitor' +import type { FeedMetrics } from './benchmark-monitor' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { RendererMode } from '../table/trading-table' +import type { VirtualScrollPreference } from '../table/trading-row-virtualizer' + +export interface TradingBenchmarkState { + requestedVirtualScrollMode: VirtualScrollPreference + metrics: FeedMetrics + mountedCells: number + liveComponents: number + longAnimationFramesSupported: boolean +} + +export interface TradingBenchmarkActions { + resetViewState: () => void + setRendererMode: (mode: RendererMode) => void + setVirtualScrollEnabled: (enabled: boolean) => void + setRenderedRowCount: (count: number) => void + selectSymbol: (symbol: string | null) => void + resetMarket: () => void +} + +const initialState: TradingBenchmarkState = { + requestedVirtualScrollMode: 'auto', + metrics: initialMetrics, + mountedCells: 0, + liveComponents: 0, + longAnimationFramesSupported, +} + +export class TradingBenchmarkController { + readonly store = createStore(initialState) + readonly renderAtoms = { + selectedSymbol: createAtom(null), + rendererMode: createAtom('stable'), + } + readonly monitor = new BenchmarkMonitor() + readonly feed: MarketFeedController + readonly actions: TradingBenchmarkActions + + readonly #runtime = { + animationFrameId: 0, + longAnimationFrameObserver: null as PerformanceObserver | null, + stopObservingFeed: null as (() => void) | null, + } + + constructor(feed: MarketFeedController) { + this.feed = feed + this.actions = { + resetViewState: () => { + this.renderAtoms.selectedSymbol.set(null) + this.#patch({ requestedVirtualScrollMode: 'auto' }) + }, + setRendererMode: (mode) => { + this.renderAtoms.rendererMode.set(mode) + }, + setVirtualScrollEnabled: (enabled) => { + if ( + this.feed.instrumentCount.get() >= FORCED_VIRTUALIZATION_ROW_COUNT + ) { + return + } + this.#patch({ + requestedVirtualScrollMode: enabled ? 'tanstack' : 'none', + }) + }, + setRenderedRowCount: (count) => { + const mountedCells = count * TRADING_COLUMN_COUNT + if (mountedCells !== this.store.get().mountedCells) { + this.#patch({ mountedCells }) + } + }, + selectSymbol: (symbol) => { + this.renderAtoms.selectedSymbol.set(symbol) + }, + resetMarket: () => { + batch(() => { + this.monitor.reset() + this.store.setState((state) => ({ + ...state, + metrics: { ...initialMetrics }, + mountedCells: 0, + liveComponents: 0, + })) + this.renderAtoms.selectedSymbol.set(null) + this.feed.actions.reset() + }) + }, + } + } + + start(): () => void { + const longAnimationFrameObserver = longAnimationFramesSupported + ? new PerformanceObserver((entries) => { + for (const entry of entries.getEntries()) { + this.monitor.recordLongAnimationFrame( + entry.duration, + entry.startTime, + ) + } + }) + : null + + this.#runtime.longAnimationFrameObserver = longAnimationFrameObserver + this.#runtime.stopObservingFeed = this.feed.observe({ + messageReceived: () => this.monitor.recordWorkerMessage(), + mutationStarted: () => this.monitor.markCommitPending(), + batchApplied: ({ tickCount, updateCount, supersededUpdateCount }) => + this.monitor.recordBatch(tickCount, updateCount, supersededUpdateCount), + renderCommitted: () => this.monitor.recordDomCommit(), + }) + longAnimationFrameObserver?.observe({ + type: 'long-animation-frame', + }) + this.#runtime.animationFrameId = requestAnimationFrame(this.#benchmarkFrame) + + return () => this.stop() + } + + stop(): void { + cancelAnimationFrame(this.#runtime.animationFrameId) + this.#runtime.longAnimationFrameObserver?.disconnect() + this.#runtime.stopObservingFeed?.() + this.#runtime.longAnimationFrameObserver = null + this.#runtime.stopObservingFeed = null + } + + readonly #benchmarkFrame = (now: number): void => { + this.monitor.recordAnimationFrame(now) + if (this.monitor.shouldPublish(now)) { + this.#publishMetrics(this.monitor.publish(now)) + } + this.#runtime.animationFrameId = requestAnimationFrame(this.#benchmarkFrame) + } + + #patch(patch: Partial): void { + this.store.setState((state) => ({ ...state, ...patch })) + } + + #publishMetrics(metrics: FeedMetrics): void { + const liveComponents = + metrics.componentsCreated - metrics.componentsDestroyed + this.#patch({ + metrics, + liveComponents, + }) + exposeTradingBenchmarkSnapshot(metrics, { + mountedCells: this.store.get().mountedCells, + liveComponents, + }) + } +} diff --git a/examples/react/realtime-trading/src/benchmark/use-table-benchmark.ts b/examples/react/realtime-trading/src/benchmark/use-table-benchmark.ts new file mode 100644 index 0000000000..bc335d2477 --- /dev/null +++ b/examples/react/realtime-trading/src/benchmark/use-table-benchmark.ts @@ -0,0 +1,28 @@ +import { useEffect } from 'react' +import type { TradingBenchmarkController } from './trading-benchmark-controller' + +export function useTableBenchmark( + controller: TradingBenchmarkController, +): void { + useEffect(() => { + const tableBody = document.querySelector( + '.market-panel [data-trading-table] tbody', + ) + if (!tableBody) { + return + } + + controller.monitor.resetDomMutations() + const observer = new MutationObserver((records) => { + controller.monitor.recordDomMutations(records.length) + }) + observer.observe(tableBody, { + attributes: true, + attributeFilter: ['class', 'style'], + characterData: true, + childList: true, + subtree: true, + }) + return () => observer.disconnect() + }, [controller]) +} diff --git a/examples/react/realtime-trading/src/benchmark/use-trading-benchmark-controller.ts b/examples/react/realtime-trading/src/benchmark/use-trading-benchmark-controller.ts new file mode 100644 index 0000000000..b163778419 --- /dev/null +++ b/examples/react/realtime-trading/src/benchmark/use-trading-benchmark-controller.ts @@ -0,0 +1,13 @@ +import { useEffect, useState } from 'react' +import { TradingBenchmarkController } from './trading-benchmark-controller' +import type { MarketFeedController } from '../feed/market-feed-controller' + +export function useTradingBenchmarkController(feed: MarketFeedController) { + const [controller] = useState(() => new TradingBenchmarkController(feed)) + + useEffect(() => controller.start(), [controller]) + + return controller +} + +export type { TradingBenchmarkController } from './trading-benchmark-controller' diff --git a/examples/react/realtime-trading/src/feed/feed-sample-rates.ts b/examples/react/realtime-trading/src/feed/feed-sample-rates.ts new file mode 100644 index 0000000000..17dc2015a6 --- /dev/null +++ b/examples/react/realtime-trading/src/feed/feed-sample-rates.ts @@ -0,0 +1,33 @@ +export const feedSampleRateOptions = [ + { label: '100', value: 100 }, + { label: '250', value: 250 }, + { label: '500', value: 500 }, + { label: '1K', value: 1_000 }, + { label: '2.5K', value: 2_500 }, + { label: '5K', value: 5_000 }, + { label: '10K', value: 10_000 }, + { label: '25K', value: 25_000 }, + { label: '50K', value: 50_000 }, + { label: '100K', value: 100_000 }, +] as const + +export function feedSampleRateIndex(rate: number): number { + return feedSampleRateOptions.reduce((closestIndex, candidate, index) => { + const closest = feedSampleRateOptions[closestIndex] + return Math.abs(candidate.value - rate) < Math.abs(closest.value - rate) + ? index + : closestIndex + }, 0) +} + +export function feedSampleRateAt(stepIndex: number): number { + const index = Math.min( + feedSampleRateOptions.length - 1, + Math.max(0, Math.round(stepIndex)), + ) + return feedSampleRateOptions[index].value +} + +export function normalizeFeedSampleRate(rate: number): number { + return feedSampleRateAt(feedSampleRateIndex(rate)) +} diff --git a/examples/react/realtime-trading/src/feed/market-data.ts b/examples/react/realtime-trading/src/feed/market-data.ts new file mode 100644 index 0000000000..6231865d3f --- /dev/null +++ b/examples/react/realtime-trading/src/feed/market-data.ts @@ -0,0 +1,38 @@ +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './worker/market-feed-protocol' + +export interface MarketQuote extends Omit { + history: ReadonlyArray +} + +export function hydrateMarketQuotes( + snapshots: Array, +): Array { + return snapshots.map((quote) => ({ + ...quote, + history: [...quote.history], + })) +} + +export function applyMarketUpdates( + quotes: Array, + updates: Array, +): Array { + const nextQuotes = [...quotes] + + for (const update of updates) { + const { index, history, ...values } = update + const previousQuote = quotes.at(index) + if (!previousQuote) continue + + nextQuotes[index] = { + ...previousQuote, + ...values, + history: history ?? previousQuote.history, + } + } + + return nextQuotes +} diff --git a/examples/react/realtime-trading/src/feed/market-feed-config.ts b/examples/react/realtime-trading/src/feed/market-feed-config.ts new file mode 100644 index 0000000000..9d477ed663 --- /dev/null +++ b/examples/react/realtime-trading/src/feed/market-feed-config.ts @@ -0,0 +1,15 @@ +export interface MarketFeedConfig { + readonly instrumentCount: number + readonly targetSamplesPerSecond: number + readonly publishIntervalMs: number + readonly updateSparklines: boolean + readonly sparklineSampleIntervalMs: number +} + +export const initialMarketFeedConfig: MarketFeedConfig = { + instrumentCount: 100, + targetSamplesPerSecond: 10_000, + publishIntervalMs: 20, + updateSparklines: true, + sparklineSampleIntervalMs: 16, +} diff --git a/examples/react/realtime-trading/src/feed/market-feed-controller.ts b/examples/react/realtime-trading/src/feed/market-feed-controller.ts new file mode 100644 index 0000000000..bcfc6c012f --- /dev/null +++ b/examples/react/realtime-trading/src/feed/market-feed-controller.ts @@ -0,0 +1,227 @@ +import { batch, createAtom } from '@tanstack/react-store' +import { normalizeFeedSampleRate } from './feed-sample-rates' +import { initialMarketFeedConfig } from './market-feed-config' +import { applyMarketUpdates, hydrateMarketQuotes } from './market-data' +import type { + MarketFeedCommand, + MarketFeedEvent, +} from './worker/market-feed-protocol' +import type { MarketQuote } from './market-data' + +export interface MarketFeedBatch { + tickCount: number + updateCount: number + supersededUpdateCount: number +} + +export interface MarketFeedObserver { + messageReceived?: () => void + mutationStarted?: () => void + batchApplied?: (batch: MarketFeedBatch) => void + renderCommitted?: () => void +} + +export interface MarketFeedActions { + toggle: () => void + setInstrumentCount: (count: number) => void + setTargetRate: (rate: number) => void + setPublishInterval: (intervalMs: number) => void + setSparklineUpdates: (enabled: boolean) => void + setSparklineSampleInterval: (intervalMs: number) => void + runBurst: () => void + reset: () => void +} + +export class MarketFeedController { + readonly workerReady = createAtom(false) + readonly running = createAtom( + !new URLSearchParams(location.search).has('paused'), + ) + readonly instrumentCount = createAtom(initialMarketFeedConfig.instrumentCount) + readonly targetTicksPerSecond = createAtom( + initialMarketFeedConfig.targetSamplesPerSecond, + ) + readonly publishIntervalMs = createAtom( + initialMarketFeedConfig.publishIntervalMs, + ) + readonly updateSparklines = createAtom( + initialMarketFeedConfig.updateSparklines, + ) + readonly sparklineSampleIntervalMs = createAtom( + initialMarketFeedConfig.sparklineSampleIntervalMs, + ) + readonly quotes = createAtom>([]) + readonly actions: MarketFeedActions + readonly #observers = new Set() + readonly #runtime = { + worker: null as Worker | null, + feedSessionId: 0, + renderPending: false, + resetWaitingForCommit: false, + resetSnapshotReady: false, + quoteIndexBySymbol: new Map(), + } + + constructor() { + this.actions = { + toggle: () => { + const running = !this.running.get() + this.running.set(running) + this.#post({ type: 'set-running', running }) + }, + setInstrumentCount: (count) => { + this.instrumentCount.set(count) + this.#resetWorker(count) + }, + setTargetRate: (rate) => { + const sampleRate = normalizeFeedSampleRate(rate) + this.targetTicksPerSecond.set(sampleRate) + this.#post({ type: 'set-rate', ticksPerSecond: sampleRate }) + }, + setPublishInterval: (publishIntervalMs) => { + this.publishIntervalMs.set(publishIntervalMs) + this.#post({ + type: 'set-publish-interval', + intervalMs: publishIntervalMs, + }) + }, + setSparklineUpdates: (enabled) => { + this.updateSparklines.set(enabled) + this.#post({ type: 'set-sparklines', enabled }) + }, + setSparklineSampleInterval: (intervalMs) => { + this.sparklineSampleIntervalMs.set(intervalMs) + this.#post({ type: 'set-sparkline-interval', intervalMs }) + }, + runBurst: () => this.#post({ type: 'burst', tickCount: 25_000 }), + reset: () => this.#resetWorker(this.instrumentCount.get()), + } + } + + start(): () => void { + const worker = new Worker( + new URL('./worker/market-feed.worker.ts', import.meta.url), + { type: 'module' }, + ) + this.#runtime.worker = worker + worker.addEventListener('message', this.#handleWorkerMessage) + worker.addEventListener('error', this.#handleWorkerError) + this.#post({ + type: 'start', + rowCount: this.instrumentCount.get(), + running: this.running.get(), + ticksPerSecond: this.targetTicksPerSecond.get(), + publishIntervalMs: this.publishIntervalMs.get(), + updateSparklines: this.updateSparklines.get(), + sparklineSampleIntervalMs: this.sparklineSampleIntervalMs.get(), + }) + return () => this.stop() + } + + stop(): void { + this.#runtime.worker?.removeEventListener( + 'message', + this.#handleWorkerMessage, + ) + this.#runtime.worker?.removeEventListener('error', this.#handleWorkerError) + this.#runtime.worker?.terminate() + this.#runtime.worker = null + this.#observers.clear() + } + + observe(observer: MarketFeedObserver): () => void { + this.#observers.add(observer) + return () => this.#observers.delete(observer) + } + + getQuoteBySymbol( + quotes: Array, + symbol: string | null, + ): MarketQuote | null { + if (symbol === null) return null + + const index = this.#runtime.quoteIndexBySymbol.get(symbol) + return index === undefined ? null : (quotes[index] ?? null) + } + + completeRender(): void { + if (!this.#runtime.renderPending) return + + this.#runtime.renderPending = false + for (const observer of this.#observers) { + observer.renderCommitted?.() + } + if ( + this.#runtime.resetWaitingForCommit && + this.#runtime.resetSnapshotReady + ) { + this.#runtime.resetWaitingForCommit = false + this.#runtime.resetSnapshotReady = false + this.#post({ type: 'set-running', running: this.running.get() }) + } + } + + readonly #handleWorkerMessage = ({ + data, + }: MessageEvent): void => { + if (data.type === 'snapshot') { + this.#runtime.feedSessionId = data.sessionId + if (this.#runtime.resetWaitingForCommit) { + this.#runtime.resetSnapshotReady = true + } + this.#startMutation() + const quotes = hydrateMarketQuotes(data.quotes) + this.#runtime.quoteIndexBySymbol = new Map( + quotes.map((quote, index) => [quote.symbol, index]), + ) + batch(() => { + this.quotes.set(quotes) + this.workerReady.set(true) + }) + return + } + + if (data.sessionId !== this.#runtime.feedSessionId) return + + for (const observer of this.#observers) { + observer.messageReceived?.() + } + this.#startMutation() + this.quotes.set(applyMarketUpdates(this.quotes.get(), data.updates)) + const feedBatch = { + tickCount: data.tickCount, + updateCount: data.updates.length, + supersededUpdateCount: data.coalescedUpdateCount, + } + for (const observer of this.#observers) { + observer.batchApplied?.(feedBatch) + } + } + + readonly #handleWorkerError = (error: ErrorEvent): void => { + batch(() => { + this.workerReady.set(false) + this.running.set(false) + }) + console.error('Market feed worker failed', error) + } + + #resetWorker(rowCount: number): void { + this.workerReady.set(false) + this.#runtime.resetWaitingForCommit = true + this.#runtime.resetSnapshotReady = false + this.#post({ type: 'set-running', running: false }) + this.#post({ type: 'reset', rowCount }) + } + + #startMutation(): void { + this.#runtime.renderPending = true + for (const observer of this.#observers) { + observer.mutationStarted?.() + } + } + + #post(command: MarketFeedCommand): void { + this.#runtime.worker?.postMessage(command) + } +} diff --git a/examples/react/realtime-trading/src/feed/market-instruments.ts b/examples/react/realtime-trading/src/feed/market-instruments.ts new file mode 100644 index 0000000000..ac18d14ea9 --- /dev/null +++ b/examples/react/realtime-trading/src/feed/market-instruments.ts @@ -0,0 +1,742 @@ +export type MarketCode = + | 'US' + | 'NL' + | 'DE' + | 'FR' + | 'IT' + | 'ES' + | 'CH' + | 'DK' + | 'SE' + | 'FI' + | 'GB' + | 'KR' + | 'JP' + | 'HK' + | 'CA' + | 'AU' + +export type BaseInstrument = readonly [ + symbol: string, + company: string, + market: MarketCode, +] + +/** + * Current S&P 500 constituent universe used by the realtime trading examples. + * + * Source snapshot: https://github.com/datasets/s-and-p-500-companies + * Retrieved: 2026-08-15. + * Multiple share classes are intentionally represented as separate instruments. + */ +export const marketInstruments = Object.freeze([ + ['MMM', '3M', 'US'], + ['AOS', 'A. O. Smith', 'US'], + ['ABT', 'Abbott Laboratories', 'US'], + ['ABBV', 'AbbVie', 'US'], + ['ACN', 'Accenture', 'US'], + ['ADBE', 'Adobe Inc.', 'US'], + ['AMD', 'Advanced Micro Devices', 'US'], + ['AES', 'AES Corporation', 'US'], + ['AFL', 'Aflac', 'US'], + ['A', 'Agilent Technologies', 'US'], + ['APD', 'Air Products', 'US'], + ['ABNB', 'Airbnb', 'US'], + ['AKAM', 'Akamai Technologies', 'US'], + ['ALB', 'Albemarle Corporation', 'US'], + ['ARE', 'Alexandria Real Estate Equities', 'US'], + ['ALGN', 'Align Technology', 'US'], + ['ALLE', 'Allegion', 'US'], + ['LNT', 'Alliant Energy', 'US'], + ['ALL', 'Allstate', 'US'], + ['GOOGL', 'Alphabet Inc. (Class A)', 'US'], + ['GOOG', 'Alphabet Inc. (Class C)', 'US'], + ['MO', 'Altria', 'US'], + ['AMZN', 'Amazon', 'US'], + ['AMCR', 'Amcor', 'US'], + ['AEE', 'Ameren', 'US'], + ['AEP', 'American Electric Power', 'US'], + ['AXP', 'American Express', 'US'], + ['AIG', 'American International Group', 'US'], + ['AMT', 'American Tower', 'US'], + ['AWK', 'American Water Works', 'US'], + ['AMP', 'Ameriprise Financial', 'US'], + ['AME', 'Ametek', 'US'], + ['AMGN', 'Amgen', 'US'], + ['APH', 'Amphenol', 'US'], + ['ADI', 'Analog Devices', 'US'], + ['AON', 'Aon plc', 'US'], + ['APA', 'APA Corporation', 'US'], + ['APO', 'Apollo Global Management', 'US'], + ['AAPL', 'Apple Inc.', 'US'], + ['AMAT', 'Applied Materials', 'US'], + ['APP', 'AppLovin', 'US'], + ['APTV', 'Aptiv', 'US'], + ['ACGL', 'Arch Capital Group', 'US'], + ['ADM', 'Archer Daniels Midland', 'US'], + ['ARES', 'Ares Management', 'US'], + ['ANET', 'Arista Networks', 'US'], + ['AJG', 'Arthur J. Gallagher & Co.', 'US'], + ['AIZ', 'Assurant', 'US'], + ['T', 'AT&T', 'US'], + ['ATO', 'Atmos Energy', 'US'], + ['ADSK', 'Autodesk', 'US'], + ['ADP', 'Automatic Data Processing', 'US'], + ['AZO', 'AutoZone', 'US'], + ['AVB', 'AvalonBay Communities', 'US'], + ['AVY', 'Avery Dennison', 'US'], + ['AXON', 'Axon Enterprise', 'US'], + ['BKR', 'Baker Hughes', 'US'], + ['BALL', 'Ball Corporation', 'US'], + ['BAC', 'Bank of America', 'US'], + ['BAX', 'Baxter International', 'US'], + ['BDX', 'Becton Dickinson', 'US'], + ['BRK.B', 'Berkshire Hathaway', 'US'], + ['BBY', 'Best Buy', 'US'], + ['TECH', 'Bio-Techne', 'US'], + ['BIIB', 'Biogen', 'US'], + ['BLK', 'BlackRock', 'US'], + ['BX', 'Blackstone Inc.', 'US'], + ['XYZ', 'Block, Inc.', 'US'], + ['BNY', 'BNY Mellon', 'US'], + ['BA', 'Boeing', 'US'], + ['BKNG', 'Booking Holdings', 'US'], + ['BSX', 'Boston Scientific', 'US'], + ['BMY', 'Bristol Myers Squibb', 'US'], + ['AVGO', 'Broadcom', 'US'], + ['BR', 'Broadridge Financial Solutions', 'US'], + ['BRO', 'Brown & Brown', 'US'], + ['BF.B', 'Brown–Forman', 'US'], + ['BLDR', 'Builders FirstSource', 'US'], + ['BG', 'Bunge Global', 'US'], + ['BXP', 'BXP, Inc.', 'US'], + ['CHRW', 'C.H. Robinson', 'US'], + ['CDNS', 'Cadence Design Systems', 'US'], + ['CPT', 'Camden Property Trust', 'US'], + ['COF', 'Capital One', 'US'], + ['CAH', 'Cardinal Health', 'US'], + ['CCL', 'Carnival Corporation', 'US'], + ['CARR', 'Carrier Global', 'US'], + ['CVNA', 'Carvana', 'US'], + ['CASY', "Casey's", 'US'], + ['CAT', 'Caterpillar Inc.', 'US'], + ['CBOE', 'Cboe Global Markets', 'US'], + ['CBRE', 'CBRE Group', 'US'], + ['CDW', 'CDW Corporation', 'US'], + ['COR', 'Cencora', 'US'], + ['CNC', 'Centene Corporation', 'US'], + ['CNP', 'CenterPoint Energy', 'US'], + ['CF', 'CF Industries', 'US'], + ['CRL', 'Charles River Laboratories', 'US'], + ['SCHW', 'Charles Schwab Corporation', 'US'], + ['CHTR', 'Charter Communications', 'US'], + ['CVX', 'Chevron Corporation', 'US'], + ['CMG', 'Chipotle Mexican Grill', 'US'], + ['CB', 'Chubb Limited', 'US'], + ['CHD', 'Church & Dwight', 'US'], + ['CIEN', 'Ciena', 'US'], + ['CI', 'Cigna', 'US'], + ['CINF', 'Cincinnati Financial', 'US'], + ['CTAS', 'Cintas', 'US'], + ['CSCO', 'Cisco', 'US'], + ['C', 'Citigroup', 'US'], + ['CFG', 'Citizens Financial Group', 'US'], + ['CLX', 'Clorox', 'US'], + ['CME', 'CME Group', 'US'], + ['CMS', 'CMS Energy', 'US'], + ['KO', 'Coca-Cola Company (The)', 'US'], + ['CTSH', 'Cognizant', 'US'], + ['COHR', 'Coherent Corp.', 'US'], + ['COIN', 'Coinbase', 'US'], + ['CL', 'Colgate-Palmolive', 'US'], + ['CMCSA', 'Comcast', 'US'], + ['FIX', 'Comfort Systems USA', 'US'], + ['COP', 'ConocoPhillips', 'US'], + ['ED', 'Consolidated Edison', 'US'], + ['STZ', 'Constellation Brands', 'US'], + ['CEG', 'Constellation Energy', 'US'], + ['COO', 'Cooper Companies (The)', 'US'], + ['CPRT', 'Copart', 'US'], + ['GLW', 'Corning Inc.', 'US'], + ['CPAY', 'Corpay', 'US'], + ['CTVA', 'Corteva', 'US'], + ['CSGP', 'CoStar Group', 'US'], + ['COST', 'Costco', 'US'], + ['CRH', 'CRH plc', 'US'], + ['CRWD', 'CrowdStrike', 'US'], + ['CCI', 'Crown Castle', 'US'], + ['CSX', 'CSX Corporation', 'US'], + ['CMI', 'Cummins', 'US'], + ['CVS', 'CVS Health', 'US'], + ['DHR', 'Danaher Corporation', 'US'], + ['DRI', 'Darden Restaurants', 'US'], + ['DDOG', 'Datadog', 'US'], + ['DVA', 'DaVita', 'US'], + ['DECK', 'Deckers Brands', 'US'], + ['DE', 'Deere & Company', 'US'], + ['DELL', 'Dell Technologies', 'US'], + ['DAL', 'Delta Air Lines', 'US'], + ['DVN', 'Devon Energy', 'US'], + ['DXCM', 'Dexcom', 'US'], + ['FANG', 'Diamondback Energy', 'US'], + ['DLR', 'Digital Realty', 'US'], + ['DG', 'Dollar General', 'US'], + ['DLTR', 'Dollar Tree', 'US'], + ['D', 'Dominion Energy', 'US'], + ['DPZ', "Domino's", 'US'], + ['DASH', 'DoorDash', 'US'], + ['DOV', 'Dover Corporation', 'US'], + ['DOW', 'Dow Inc.', 'US'], + ['DHI', 'D. R. Horton', 'US'], + ['DTE', 'DTE Energy', 'US'], + ['DUK', 'Duke Energy', 'US'], + ['DD', 'DuPont', 'US'], + ['ETN', 'Eaton Corporation', 'US'], + ['EBAY', 'eBay Inc.', 'US'], + ['ECHO', 'EchoStar', 'US'], + ['ECL', 'Ecolab', 'US'], + ['EIX', 'Edison International', 'US'], + ['EW', 'Edwards Lifesciences', 'US'], + ['ELV', 'Elevance Health', 'US'], + ['EME', 'Emcor', 'US'], + ['EMR', 'Emerson Electric', 'US'], + ['ETR', 'Entergy', 'US'], + ['EOG', 'EOG Resources', 'US'], + ['EQT', 'EQT Corporation', 'US'], + ['EFX', 'Equifax', 'US'], + ['EQIX', 'Equinix', 'US'], + ['EQR', 'Equity Residential', 'US'], + ['ERIE', 'Erie Indemnity', 'US'], + ['ESS', 'Essex Property Trust', 'US'], + ['EL', 'Estée Lauder Companies (The)', 'US'], + ['EG', 'Everest Group', 'US'], + ['EVRG', 'Evergy', 'US'], + ['ES', 'Eversource Energy', 'US'], + ['EXC', 'Exelon', 'US'], + ['EXE', 'Expand Energy', 'US'], + ['EXPE', 'Expedia Group', 'US'], + ['EXPD', 'Expeditors International', 'US'], + ['EXR', 'Extra Space Storage', 'US'], + ['XOM', 'ExxonMobil', 'US'], + ['FFIV', 'F5, Inc.', 'US'], + ['FDS', 'FactSet', 'US'], + ['FICO', 'Fair Isaac', 'US'], + ['FAST', 'Fastenal', 'US'], + ['FRT', 'Federal Realty Investment Trust', 'US'], + ['FDX', 'FedEx', 'US'], + ['FDXF', 'FedEx Freight', 'US'], + ['FERG', 'Ferguson Enterprises', 'US'], + ['FIS', 'Fidelity National Information Services', 'US'], + ['FITB', 'Fifth Third Bancorp', 'US'], + ['FSLR', 'First Solar', 'US'], + ['FE', 'FirstEnergy', 'US'], + ['FISV', 'Fiserv', 'US'], + ['FLEX', 'Flex Ltd.', 'US'], + ['F', 'Ford Motor Company', 'US'], + ['FTNT', 'Fortinet', 'US'], + ['FTV', 'Fortive', 'US'], + ['FOXA', 'Fox Corporation (Class A)', 'US'], + ['FOX', 'Fox Corporation (Class B)', 'US'], + ['BEN', 'Franklin Resources', 'US'], + ['FCX', 'Freeport-McMoRan', 'US'], + ['GRMN', 'Garmin', 'US'], + ['IT', 'Gartner', 'US'], + ['GE', 'GE Aerospace', 'US'], + ['GEHC', 'GE HealthCare', 'US'], + ['GEV', 'GE Vernova', 'US'], + ['GEN', 'Gen Digital', 'US'], + ['GNRC', 'Generac', 'US'], + ['GD', 'General Dynamics', 'US'], + ['GIS', 'General Mills', 'US'], + ['GM', 'General Motors', 'US'], + ['GPC', 'Genuine Parts Company', 'US'], + ['GILD', 'Gilead Sciences', 'US'], + ['GPN', 'Global Payments', 'US'], + ['GL', 'Globe Life', 'US'], + ['GDDY', 'GoDaddy', 'US'], + ['GS', 'Goldman Sachs', 'US'], + ['HAL', 'Halliburton', 'US'], + ['HIG', 'Hartford (The)', 'US'], + ['HAS', 'Hasbro', 'US'], + ['HCA', 'HCA Healthcare', 'US'], + ['DOC', 'Healthpeak Properties', 'US'], + ['HSIC', 'Henry Schein', 'US'], + ['HSY', 'Hershey Company (The)', 'US'], + ['HPE', 'Hewlett Packard Enterprise', 'US'], + ['HLT', 'Hilton Worldwide', 'US'], + ['HD', 'Home Depot (The)', 'US'], + ['HONA', 'Honeywell Aerospace', 'US'], + ['HON', 'Honeywell Technologies', 'US'], + ['HRL', 'Hormel Foods', 'US'], + ['HST', 'Host Hotels & Resorts', 'US'], + ['HWM', 'Howmet Aerospace', 'US'], + ['HPQ', 'HP Inc.', 'US'], + ['HUBB', 'Hubbell Incorporated', 'US'], + ['HUM', 'Humana', 'US'], + ['HBAN', 'Huntington Bancshares', 'US'], + ['HII', 'Huntington Ingalls Industries', 'US'], + ['IBM', 'IBM', 'US'], + ['IEX', 'IDEX Corporation', 'US'], + ['IDXX', 'Idexx Laboratories', 'US'], + ['ITW', 'Illinois Tool Works', 'US'], + ['INCY', 'Incyte', 'US'], + ['IR', 'Ingersoll Rand', 'US'], + ['PODD', 'Insulet Corporation', 'US'], + ['INTC', 'Intel', 'US'], + ['IBKR', 'Interactive Brokers', 'US'], + ['ICE', 'Intercontinental Exchange', 'US'], + ['IFF', 'International Flavors & Fragrances', 'US'], + ['IP', 'International Paper', 'US'], + ['INTU', 'Intuit', 'US'], + ['ISRG', 'Intuitive Surgical', 'US'], + ['IVZ', 'Invesco', 'US'], + ['INVH', 'Invitation Homes', 'US'], + ['IQV', 'IQVIA', 'US'], + ['IRM', 'Iron Mountain', 'US'], + ['JBHT', 'J.B. Hunt', 'US'], + ['JBL', 'Jabil', 'US'], + ['JKHY', 'Jack Henry & Associates', 'US'], + ['J', 'Jacobs Solutions', 'US'], + ['JNJ', 'Johnson & Johnson', 'US'], + ['JCI', 'Johnson Controls', 'US'], + ['JPM', 'JPMorgan Chase', 'US'], + ['KVUE', 'Kenvue', 'US'], + ['KDP', 'Keurig Dr Pepper', 'US'], + ['KEY', 'KeyCorp', 'US'], + ['KEYS', 'Keysight Technologies', 'US'], + ['KMB', 'Kimberly-Clark', 'US'], + ['KIM', 'Kimco Realty', 'US'], + ['KMI', 'Kinder Morgan', 'US'], + ['KKR', 'KKR & Co.', 'US'], + ['KLAC', 'KLA Corporation', 'US'], + ['KHC', 'Kraft Heinz', 'US'], + ['KR', 'Kroger', 'US'], + ['LHX', 'L3Harris', 'US'], + ['LH', 'Labcorp', 'US'], + ['LRCX', 'Lam Research', 'US'], + ['LVS', 'Las Vegas Sands', 'US'], + ['LDOS', 'Leidos', 'US'], + ['LEN', 'Lennar', 'US'], + ['LII', 'Lennox International', 'US'], + ['LLY', 'Lilly (Eli)', 'US'], + ['LIN', 'Linde plc', 'US'], + ['LYV', 'Live Nation Entertainment', 'US'], + ['LMT', 'Lockheed Martin', 'US'], + ['L', 'Loews Corporation', 'US'], + ['LOW', "Lowe's", 'US'], + ['LULU', 'Lululemon Athletica', 'US'], + ['LITE', 'Lumentum', 'US'], + ['LYB', 'LyondellBasell', 'US'], + ['MTB', 'M&T Bank', 'US'], + ['MPC', 'Marathon Petroleum', 'US'], + ['MAR', 'Marriott International', 'US'], + ['MRSH', 'Marsh McLennan', 'US'], + ['MLM', 'Martin Marietta Materials', 'US'], + ['MRVL', 'Marvell Technology', 'US'], + ['MAS', 'Masco', 'US'], + ['MA', 'Mastercard', 'US'], + ['MKC', 'McCormick & Company', 'US'], + ['MCD', "McDonald's", 'US'], + ['MCK', 'McKesson Corporation', 'US'], + ['MDT', 'Medtronic', 'US'], + ['MRK', 'Merck & Co.', 'US'], + ['META', 'Meta Platforms', 'US'], + ['MET', 'MetLife', 'US'], + ['MTD', 'Mettler Toledo', 'US'], + ['MGM', 'MGM Resorts', 'US'], + ['MCHP', 'Microchip Technology', 'US'], + ['MU', 'Micron Technology', 'US'], + ['MSFT', 'Microsoft', 'US'], + ['MAA', 'Mid-America Apartment Communities', 'US'], + ['MRNA', 'Moderna', 'US'], + ['TAP', 'Molson Coors Beverage Company', 'US'], + ['MDLZ', 'Mondelez International', 'US'], + ['MPWR', 'Monolithic Power Systems', 'US'], + ['MNST', 'Monster Beverage', 'US'], + ['MCO', "Moody's Corporation", 'US'], + ['MS', 'Morgan Stanley', 'US'], + ['MOS', 'Mosaic Company (The)', 'US'], + ['MSI', 'Motorola Solutions', 'US'], + ['MSCI', 'MSCI', 'US'], + ['NDAQ', 'Nasdaq, Inc.', 'US'], + ['NTAP', 'NetApp', 'US'], + ['NFLX', 'Netflix', 'US'], + ['NEM', 'Newmont', 'US'], + ['NWSA', 'News Corp (Class A)', 'US'], + ['NWS', 'News Corp (Class B)', 'US'], + ['NEE', 'NextEra Energy', 'US'], + ['NKE', 'Nike, Inc.', 'US'], + ['NI', 'NiSource', 'US'], + ['NDSN', 'Nordson Corporation', 'US'], + ['NSC', 'Norfolk Southern', 'US'], + ['NTRS', 'Northern Trust', 'US'], + ['NOC', 'Northrop Grumman', 'US'], + ['NCLH', 'Norwegian Cruise Line Holdings', 'US'], + ['NRG', 'NRG Energy', 'US'], + ['NUE', 'Nucor', 'US'], + ['NVDA', 'Nvidia', 'US'], + ['NVR', 'NVR, Inc.', 'US'], + ['NXPI', 'NXP Semiconductors', 'US'], + ['ORLY', "O'Reilly Automotive", 'US'], + ['OXY', 'Occidental Petroleum', 'US'], + ['ODFL', 'Old Dominion', 'US'], + ['OMC', 'Omnicom Group', 'US'], + ['ON', 'ON Semiconductor', 'US'], + ['OKE', 'Oneok', 'US'], + ['ORCL', 'Oracle Corporation', 'US'], + ['OTIS', 'Otis Worldwide', 'US'], + ['PCAR', 'Paccar', 'US'], + ['PKG', 'Packaging Corporation of America', 'US'], + ['PLTR', 'Palantir Technologies', 'US'], + ['PANW', 'Palo Alto Networks', 'US'], + ['PSKY', 'Paramount Skydance Corporation', 'US'], + ['PH', 'Parker Hannifin', 'US'], + ['PAYX', 'Paychex', 'US'], + ['PYPL', 'PayPal', 'US'], + ['PNR', 'Pentair', 'US'], + ['PEP', 'PepsiCo', 'US'], + ['PFE', 'Pfizer', 'US'], + ['PCG', 'PG&E Corporation', 'US'], + ['PM', 'Philip Morris International', 'US'], + ['PSX', 'Phillips 66', 'US'], + ['PNW', 'Pinnacle West Capital', 'US'], + ['PNC', 'PNC Financial Services', 'US'], + ['PPG', 'PPG Industries', 'US'], + ['PPL', 'PPL Corporation', 'US'], + ['PFG', 'Principal Financial Group', 'US'], + ['PG', 'Procter & Gamble', 'US'], + ['PGR', 'Progressive Corporation', 'US'], + ['PLD', 'Prologis', 'US'], + ['PRU', 'Prudential Financial', 'US'], + ['PEG', 'Public Service Enterprise Group', 'US'], + ['PTC', 'PTC Inc.', 'US'], + ['PSA', 'Public Storage', 'US'], + ['PHM', 'PulteGroup', 'US'], + ['PWR', 'Quanta Services', 'US'], + ['QCOM', 'Qualcomm', 'US'], + ['DGX', 'Quest Diagnostics', 'US'], + ['Q', 'Qnity Electronics', 'US'], + ['RL', 'Ralph Lauren Corporation', 'US'], + ['RJF', 'Raymond James Financial', 'US'], + ['RTX', 'RTX Corporation', 'US'], + ['O', 'Realty Income', 'US'], + ['REG', 'Regency Centers', 'US'], + ['REGN', 'Regeneron Pharmaceuticals', 'US'], + ['RF', 'Regions Financial Corporation', 'US'], + ['RSG', 'Republic Services', 'US'], + ['RMD', 'ResMed|', 'US'], + ['RVTY', 'Revvity', 'US'], + ['HOOD', 'Robinhood Markets', 'US'], + ['ROK', 'Rockwell Automation', 'US'], + ['ROL', 'Rollins, Inc.', 'US'], + ['ROP', 'Roper Technologies', 'US'], + ['ROST', 'Ross Stores', 'US'], + ['RCL', 'Royal Caribbean Group', 'US'], + ['SPGI', 'S&P Global', 'US'], + ['CRM', 'Salesforce', 'US'], + ['SNDK', 'Sandisk', 'US'], + ['SBAC', 'SBA Communications', 'US'], + ['SLB', 'Schlumberger', 'US'], + ['STX', 'Seagate Technology', 'US'], + ['SRE', 'Sempra', 'US'], + ['NOW', 'ServiceNow', 'US'], + ['SHW', 'Sherwin-Williams', 'US'], + ['SPG', 'Simon Property Group', 'US'], + ['SWKS', 'Skyworks Solutions', 'US'], + ['SJM', 'J.M. Smucker Company (The)', 'US'], + ['SW', 'Smurfit Westrock', 'US'], + ['SNA', 'Snap-on', 'US'], + ['SOLV', 'Solventum', 'US'], + ['SO', 'Southern Company', 'US'], + ['LUV', 'Southwest Airlines', 'US'], + ['SWK', 'Stanley Black & Decker', 'US'], + ['SBUX', 'Starbucks', 'US'], + ['STT', 'State Street Corporation', 'US'], + ['STLD', 'Steel Dynamics', 'US'], + ['STE', 'Steris', 'US'], + ['SYK', 'Stryker Corporation', 'US'], + ['SMCI', 'Supermicro', 'US'], + ['SYF', 'Synchrony Financial', 'US'], + ['SNPS', 'Synopsys', 'US'], + ['SYY', 'Sysco', 'US'], + ['TMUS', 'T-Mobile US', 'US'], + ['TROW', 'T. Rowe Price', 'US'], + ['TTWO', 'Take-Two Interactive', 'US'], + ['TPR', 'Tapestry, Inc.', 'US'], + ['TRGP', 'Targa Resources', 'US'], + ['TGT', 'Target Corporation', 'US'], + ['TEL', 'TE Connectivity', 'US'], + ['TDY', 'Teledyne Technologies', 'US'], + ['TER', 'Teradyne', 'US'], + ['TSLA', 'Tesla, Inc.', 'US'], + ['TXN', 'Texas Instruments', 'US'], + ['TPL', 'Texas Pacific Land Corporation', 'US'], + ['TXT', 'Textron', 'US'], + ['TMO', 'Thermo Fisher Scientific', 'US'], + ['TJX', 'TJX Companies', 'US'], + ['TKO', 'TKO Group Holdings', 'US'], + ['TTD', 'Trade Desk (The)', 'US'], + ['TSCO', 'Tractor Supply', 'US'], + ['TT', 'Trane Technologies', 'US'], + ['TDG', 'TransDigm Group', 'US'], + ['TRV', 'Travelers Companies (The)', 'US'], + ['TRMB', 'Trimble Inc.', 'US'], + ['TFC', 'Truist Financial', 'US'], + ['TYL', 'Tyler Technologies', 'US'], + ['TSN', 'Tyson Foods', 'US'], + ['USB', 'U.S. Bancorp', 'US'], + ['UBER', 'Uber', 'US'], + ['UDR', 'UDR, Inc.', 'US'], + ['ULTA', 'Ulta Beauty', 'US'], + ['UNP', 'Union Pacific Corporation', 'US'], + ['UAL', 'United Airlines Holdings', 'US'], + ['UPS', 'United Parcel Service', 'US'], + ['URI', 'United Rentals', 'US'], + ['UNH', 'UnitedHealth Group', 'US'], + ['UHS', 'Universal Health Services', 'US'], + ['VLO', 'Valero Energy', 'US'], + ['VEEV', 'Veeva Systems', 'US'], + ['VTR', 'Ventas', 'US'], + ['VLTO', 'Veralto', 'US'], + ['VRSN', 'Verisign', 'US'], + ['VRSK', 'Verisk Analytics', 'US'], + ['VZ', 'Verizon', 'US'], + ['VRTX', 'Vertex Pharmaceuticals', 'US'], + ['VRT', 'Vertiv', 'US'], + ['VTRS', 'Viatris', 'US'], + ['VICI', 'Vici Properties', 'US'], + ['V', 'Visa Inc.', 'US'], + ['VST', 'Vistra Corp.', 'US'], + ['VMC', 'Vulcan Materials Company', 'US'], + ['WRB', 'W. R. Berkley Corporation', 'US'], + ['GWW', 'W. W. Grainger', 'US'], + ['WAB', 'Wabtec', 'US'], + ['WMT', 'Walmart', 'US'], + ['DIS', 'Walt Disney Company (The)', 'US'], + ['WBD', 'Warner Bros. Discovery', 'US'], + ['WM', 'Waste Management', 'US'], + ['WAT', 'Waters Corporation', 'US'], + ['WEC', 'WEC Energy Group', 'US'], + ['WFC', 'Wells Fargo', 'US'], + ['WELL', 'Welltower', 'US'], + ['WST', 'West Pharmaceutical Services', 'US'], + ['WDC', 'Western Digital', 'US'], + ['WY', 'Weyerhaeuser', 'US'], + ['WSM', 'Williams-Sonoma, Inc.', 'US'], + ['WMB', 'Williams Companies', 'US'], + ['WTW', 'Willis Towers Watson', 'US'], + ['WDAY', 'Workday, Inc.', 'US'], + ['WYNN', 'Wynn Resorts', 'US'], + ['XEL', 'Xcel Energy', 'US'], + ['XYL', 'Xylem Inc.', 'US'], + ['YUM', 'Yum! Brands', 'US'], + ['ZBRA', 'Zebra Technologies', 'US'], + ['ZBH', 'Zimmer Biomet', 'US'], + ['ZTS', 'Zoetis', 'US'], +]) + +/** + * Representative liquid international listings used to diversify the fixture. + * Symbols use their local-market form and the third tuple value is an ISO-style + * country/market code, rather than a trading currency or exchange MIC. + * + * References checked 2026-08-15: STOXX Europe 50, KRX KOSPI market, + * JPX TOPIX Core30, and HKEX index constituent materials. + */ +const europeanInstruments = Object.freeze([ + ['ASML', 'ASML Holding', 'NL'], + ['INGA', 'ING Group', 'NL'], + ['ADYEN', 'Adyen', 'NL'], + ['PHIA', 'Philips', 'NL'], + ['HEIA', 'Heineken', 'NL'], + ['SAP', 'SAP', 'DE'], + ['SIE', 'Siemens', 'DE'], + ['ALV', 'Allianz', 'DE'], + ['DTE', 'Deutsche Telekom', 'DE'], + ['MBG', 'Mercedes-Benz Group', 'DE'], + ['BMW', 'BMW', 'DE'], + ['BAS', 'BASF', 'DE'], + ['MUV2', 'Munich Re', 'DE'], + ['VOW3', 'Volkswagen Preference', 'DE'], + ['IFX', 'Infineon Technologies', 'DE'], + ['MC', 'LVMH', 'FR'], + ['OR', "L'Oréal", 'FR'], + ['AIR', 'Airbus', 'FR'], + ['SU', 'Schneider Electric', 'FR'], + ['TTE', 'TotalEnergies', 'FR'], + ['SAN', 'Sanofi', 'FR'], + ['BNP', 'BNP Paribas', 'FR'], + ['CS', 'AXA', 'FR'], + ['DG', 'Vinci', 'FR'], + ['ENEL', 'Enel', 'IT'], + ['ENI', 'Eni', 'IT'], + ['ISP', 'Intesa Sanpaolo', 'IT'], + ['UCG', 'UniCredit', 'IT'], + ['STLAM', 'Stellantis', 'IT'], + ['SAN', 'Banco Santander', 'ES'], + ['IBE', 'Iberdrola', 'ES'], + ['ITX', 'Inditex', 'ES'], + ['BBVA', 'BBVA', 'ES'], + ['NESN', 'Nestlé', 'CH'], + ['ROG', 'Roche Holding', 'CH'], + ['NOVN', 'Novartis', 'CH'], + ['UBSG', 'UBS Group', 'CH'], + ['NOVO-B', 'Novo Nordisk', 'DK'], + ['MAERSK-B', 'A.P. Moller - Maersk', 'DK'], + ['VOLV-B', 'Volvo', 'SE'], + ['ERIC-B', 'Ericsson', 'SE'], + ['NOKIA', 'Nokia', 'FI'], + ['SHEL', 'Shell', 'GB'], + ['AZN', 'AstraZeneca', 'GB'], + ['HSBA', 'HSBC Holdings', 'GB'], + ['ULVR', 'Unilever', 'GB'], + ['LSEG', 'London Stock Exchange Group', 'GB'], +]) + +const europeanMarketCodes = Object.freeze([ + 'NL', + 'DE', + 'FR', + 'IT', + 'ES', + 'CH', + 'DK', + 'SE', + 'FI', + 'GB', +]) + +const europeanMarketGroups = Object.freeze( + europeanMarketCodes.map((market) => + europeanInstruments.filter(([, , instrumentMarket]) => + Object.is(instrumentMarket, market), + ), + ), +) + +const interleavedEuropeanInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...europeanMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + europeanMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const southKoreanInstruments = Object.freeze([ + ['005930', 'Samsung Electronics', 'KR'], + ['000660', 'SK hynix', 'KR'], + ['373220', 'LG Energy Solution', 'KR'], + ['207940', 'Samsung Biologics', 'KR'], + ['005380', 'Hyundai Motor', 'KR'], + ['000270', 'Kia', 'KR'], + ['068270', 'Celltrion', 'KR'], + ['105560', 'KB Financial Group', 'KR'], + ['055550', 'Shinhan Financial Group', 'KR'], + ['035420', 'NAVER', 'KR'], + ['035720', 'Kakao', 'KR'], + ['006400', 'Samsung SDI', 'KR'], + ['051910', 'LG Chem', 'KR'], + ['012330', 'Hyundai Mobis', 'KR'], + ['066570', 'LG Electronics', 'KR'], +]) + +const japaneseInstruments = Object.freeze([ + ['8306', 'Mitsubishi UFJ Financial Group', 'JP'], + ['7203', 'Toyota Motor', 'JP'], + ['6501', 'Hitachi', 'JP'], + ['8316', 'Sumitomo Mitsui Financial Group', 'JP'], + ['6758', 'Sony Group', 'JP'], + ['8058', 'Mitsubishi Corporation', 'JP'], + ['9984', 'SoftBank Group', 'JP'], + ['8035', 'Tokyo Electron', 'JP'], + ['8411', 'Mizuho Financial Group', 'JP'], + ['8031', 'Mitsui & Co.', 'JP'], + ['6861', 'Keyence', 'JP'], + ['7974', 'Nintendo', 'JP'], + ['6098', 'Recruit Holdings', 'JP'], + ['9432', 'Nippon Telegraph and Telephone', 'JP'], + ['4063', 'Shin-Etsu Chemical', 'JP'], +]) + +const hongKongInstruments = Object.freeze([ + ['0700', 'Tencent Holdings', 'HK'], + ['9988', 'Alibaba Group', 'HK'], + ['1810', 'Xiaomi', 'HK'], + ['3690', 'Meituan', 'HK'], + ['0941', 'China Mobile', 'HK'], + ['1211', 'BYD Company', 'HK'], + ['1299', 'AIA Group', 'HK'], + ['0388', 'Hong Kong Exchanges and Clearing', 'HK'], + ['0005', 'HSBC Holdings', 'HK'], + ['2318', 'Ping An Insurance', 'HK'], +]) + +const canadianInstruments = Object.freeze([ + ['RY', 'Royal Bank of Canada', 'CA'], + ['TD', 'Toronto-Dominion Bank', 'CA'], + ['SHOP', 'Shopify', 'CA'], + ['ENB', 'Enbridge', 'CA'], + ['CNR', 'Canadian National Railway', 'CA'], + ['CP', 'Canadian Pacific Kansas City', 'CA'], + ['BMO', 'Bank of Montreal', 'CA'], + ['CSU', 'Constellation Software', 'CA'], +]) + +const australianInstruments = Object.freeze([ + ['BHP', 'BHP Group', 'AU'], + ['CBA', 'Commonwealth Bank of Australia', 'AU'], + ['CSL', 'CSL', 'AU'], + ['NAB', 'National Australia Bank', 'AU'], + ['WBC', 'Westpac Banking Corporation', 'AU'], + ['ANZ', 'ANZ Group Holdings', 'AU'], + ['WES', 'Wesfarmers', 'AU'], + ['MQG', 'Macquarie Group', 'AU'], +]) + +const internationalMarketGroups = Object.freeze([ + interleavedEuropeanInstruments, + southKoreanInstruments, + japaneseInstruments, + hongKongInstruments, + canadianInstruments, + australianInstruments, +]) + +export const internationalInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...internationalMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + internationalMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const INTERNATIONAL_INSERTION_INTERVAL = 3 + +/** + * U.S. and international instruments are interleaved so ordinary benchmark + * sizes exercise multiple symbol formats and market labels. + */ +export const globalInstruments = Object.freeze( + marketInstruments.flatMap((instrument, index) => { + const internationalInstrument = + index % INTERNATIONAL_INSERTION_INTERVAL === 0 + ? internationalInstruments[index / INTERNATIONAL_INSERTION_INTERVAL] + : undefined + + return internationalInstrument + ? [instrument, internationalInstrument] + : [instrument] + }), +) as unknown as ReadonlyArray diff --git a/examples/react/realtime-trading/src/feed/use-market-feed-controller.ts b/examples/react/realtime-trading/src/feed/use-market-feed-controller.ts new file mode 100644 index 0000000000..74c5208f38 --- /dev/null +++ b/examples/react/realtime-trading/src/feed/use-market-feed-controller.ts @@ -0,0 +1,10 @@ +import { useEffect, useState } from 'react' +import { MarketFeedController } from './market-feed-controller' + +export function useMarketFeedController(): MarketFeedController { + const [controller] = useState(() => new MarketFeedController()) + + useEffect(() => controller.start(), [controller]) + + return controller +} diff --git a/examples/react/realtime-trading/src/feed/worker/market-feed-engine.ts b/examples/react/realtime-trading/src/feed/worker/market-feed-engine.ts new file mode 100644 index 0000000000..fbd9c369c0 --- /dev/null +++ b/examples/react/realtime-trading/src/feed/worker/market-feed-engine.ts @@ -0,0 +1,177 @@ +import { globalInstruments } from '../market-instruments.ts' +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const INITIAL_MARKET_SEED = 0x4d41524b +const LIVE_FEED_SEED = 0x5449434b + +export class MarketFeedEngine { + #quotes: Array = [] + #lastHistorySampledAt = new Uint32Array(0) + #random = createRandom(2_026) + #rowCursor = 0 + #tickIndex = 0 + + reset(count: number): Array { + const random = createRandom(INITIAL_MARKET_SEED ^ count) + const createdAt = Date.now() + + this.#quotes = Array.from({ length: count }, (_, index) => { + const [baseSymbol, company, market] = + globalInstruments[index % globalInstruments.length] + const series = Math.floor(index / globalInstruments.length) + const symbol = series === 0 ? baseSymbol : `${baseSymbol}${series}` + const previousClose = roundPrice(20 + random() * 480) + const open = roundPrice(previousClose * (1 + (random() - 0.5) * 0.016)) + const spread = Math.max(0.01, open * (0.0002 + random() * 0.0004)) + const history = Array.from({ length: 24 }, (_, historyIndex) => + roundPrice( + open * + (1 + Math.sin(historyIndex / 4) * 0.002 + (random() - 0.5) * 0.001), + ), + ) + const volume = Math.floor(50_000 + random() * 2_000_000) + const lastSize = Math.floor(10 + random() * 5_000) + + return { + id: `instrument-${index}`, + symbol, + company, + venue: market, + previousClose, + open, + high: open, + low: open, + price: open, + bid: roundPrice(open - spread / 2), + ask: roundPrice(open + spread / 2), + bidSize: Math.floor(100 + random() * 25_000), + askSize: Math.floor(100 + random() * 25_000), + lastSize, + lastMove: 0, + lastUpdatedAt: createdAt, + volume, + turnover: roundMoney(open * volume), + history, + } + }) + + this.#random = createRandom(LIVE_FEED_SEED ^ count) + this.#rowCursor = 0 + this.#lastHistorySampledAt = new Uint32Array(count) + this.#lastHistorySampledAt.fill(createdAt >>> 0) + + return this.#quotes.map((quote) => ({ + ...quote, + history: [...quote.history], + })) + } + + applyTicks( + tickCount: number, + updateSparklines: boolean, + sparklineSampleIntervalMs: number, + ): Array { + if (this.#quotes.length === 0 || tickCount <= 0) return [] + + const updatedAt = Date.now() + const sampledAt = updatedAt >>> 0 + const sampleIntervalMs = Math.max(16, sparklineSampleIntervalMs) + const updatedQuotes = new Map() + const stride = 97 + + this.#tickIndex = 0 + while (this.#tickIndex < tickCount) { + this.#rowCursor = (this.#rowCursor + stride) % this.#quotes.length + const quote = this.#quotes[this.#rowCursor] + const lastSampledAt = this.#lastHistorySampledAt[this.#rowCursor] + const shouldUpdateHistory = + updateSparklines && + (sampledAt - lastSampledAt) >>> 0 >= sampleIntervalMs + + if (shouldUpdateHistory) { + this.#lastHistorySampledAt[this.#rowCursor] = sampledAt + } + + this.#applyTick(quote, shouldUpdateHistory, updatedAt) + + const previousUpdate = updatedQuotes.get(this.#rowCursor) + updatedQuotes.set(this.#rowCursor, { + index: this.#rowCursor, + price: quote.price, + bid: quote.bid, + ask: quote.ask, + bidSize: quote.bidSize, + askSize: quote.askSize, + lastSize: quote.lastSize, + lastMove: quote.lastMove, + lastUpdatedAt: quote.lastUpdatedAt, + high: quote.high, + low: quote.low, + volume: quote.volume, + turnover: quote.turnover, + ...(shouldUpdateHistory || previousUpdate?.history + ? { history: [...quote.history] } + : {}), + }) + this.#tickIndex++ + } + + return [...updatedQuotes.values()] + } + + #applyTick( + quote: MarketQuoteSnapshot, + updateHistory: boolean, + updatedAt: number, + ): void { + const previousPrice = quote.price + const volatility = 0.00015 + this.#random() * 0.0012 + const move = previousPrice * (this.#random() - 0.495) * volatility + const nextPrice = roundPrice(Math.max(0.1, previousPrice + move)) + const spread = Math.max( + 0.01, + nextPrice * (0.00015 + this.#random() * 0.0005), + ) + + quote.lastMove = nextPrice - previousPrice + quote.price = nextPrice + quote.high = Math.max(quote.high, nextPrice) + quote.low = Math.min(quote.low, nextPrice) + quote.bid = roundPrice(nextPrice - spread / 2) + quote.ask = roundPrice(nextPrice + spread / 2) + quote.bidSize = Math.floor(100 + this.#random() * 25_000) + quote.askSize = Math.floor(100 + this.#random() * 25_000) + quote.lastSize = Math.floor(10 + this.#random() * 5_000) + quote.lastUpdatedAt = updatedAt + quote.volume += quote.lastSize + quote.turnover = roundMoney(quote.turnover + nextPrice * quote.lastSize) + + if (updateHistory) { + quote.history = [...quote.history.slice(-23), nextPrice] + } + } +} + +function createRandom(seed: number): () => number { + const runtime = { state: seed >>> 0 } + return () => { + runtime.state += 0x6d2b79f5 + const stateValue = runtime.state + const firstMix = Math.imul(stateValue ^ (stateValue >>> 15), stateValue | 1) + const secondMix = + firstMix + Math.imul(firstMix ^ (firstMix >>> 7), firstMix | 61) + const value = firstMix ^ secondMix + return ((value ^ (value >>> 14)) >>> 0) / 4_294_967_296 + } +} + +function roundPrice(value: number): number { + return Math.round(value * 100) / 100 +} + +function roundMoney(value: number): number { + return Math.round(value * 100) / 100 +} diff --git a/examples/react/realtime-trading/src/feed/worker/market-feed-protocol.ts b/examples/react/realtime-trading/src/feed/worker/market-feed-protocol.ts new file mode 100644 index 0000000000..21997ec89c --- /dev/null +++ b/examples/react/realtime-trading/src/feed/worker/market-feed-protocol.ts @@ -0,0 +1,70 @@ +export interface MarketQuoteSnapshot { + id: string + symbol: string + company: string + venue: string + previousClose: number + open: number + high: number + low: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + volume: number + turnover: number + history: Array +} + +export interface MarketQuoteUpdate { + index: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + high: number + low: number + volume: number + turnover: number + history?: Array +} + +export type MarketFeedCommand = + | { + type: 'start' + rowCount: number + running: boolean + ticksPerSecond: number + publishIntervalMs: number + updateSparklines: boolean + sparklineSampleIntervalMs: number + } + | { type: 'set-running'; running: boolean } + | { type: 'set-rate'; ticksPerSecond: number } + | { type: 'set-publish-interval'; intervalMs: number } + | { type: 'set-sparklines'; enabled: boolean } + | { type: 'set-sparkline-interval'; intervalMs: number } + | { type: 'reset'; rowCount: number } + | { type: 'burst'; tickCount: number } + +export type MarketFeedEvent = + | { + type: 'snapshot' + sessionId: number + quotes: Array + } + | { + type: 'updates' + sessionId: number + tickCount: number + coalescedUpdateCount: number + updates: Array + } diff --git a/examples/react/realtime-trading/src/feed/worker/market-feed.worker.ts b/examples/react/realtime-trading/src/feed/worker/market-feed.worker.ts new file mode 100644 index 0000000000..2b7a642fd9 --- /dev/null +++ b/examples/react/realtime-trading/src/feed/worker/market-feed.worker.ts @@ -0,0 +1,143 @@ +import { initialMarketFeedConfig } from '../market-feed-config' +import { MarketFeedEngine } from './market-feed-engine' +import type { + MarketFeedCommand, + MarketFeedEvent, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const engine = new MarketFeedEngine() +const pendingUpdates = new Map() +const runtime = { + sessionId: 0, + pendingTickCount: 0, + pendingCoalescedUpdateCount: 0, + initialized: false, + running: true, + ticksPerSecond: initialMarketFeedConfig.targetSamplesPerSecond, + publishIntervalMs: initialMarketFeedConfig.publishIntervalMs, + publishTimerId: null as ReturnType | null, + updateSparklines: initialMarketFeedConfig.updateSparklines, + sparklineSampleIntervalMs: initialMarketFeedConfig.sparklineSampleIntervalMs, + tickBudget: 0, + lastTickAt: performance.now(), +} + +addEventListener('message', ({ data }: MessageEvent) => { + switch (data.type) { + case 'start': + runtime.running = data.running + runtime.ticksPerSecond = data.ticksPerSecond + runtime.publishIntervalMs = data.publishIntervalMs + runtime.updateSparklines = data.updateSparklines + runtime.sparklineSampleIntervalMs = data.sparklineSampleIntervalMs + restartPublishTimer() + reset(data.rowCount) + break + case 'set-running': + runtime.running = data.running + break + case 'set-rate': + runtime.ticksPerSecond = data.ticksPerSecond + break + case 'set-publish-interval': + runtime.publishIntervalMs = Math.max(4, data.intervalMs) + restartPublishTimer() + break + case 'set-sparklines': + runtime.updateSparklines = data.enabled + break + case 'set-sparkline-interval': + runtime.sparklineSampleIntervalMs = Math.max(16, data.intervalMs) + break + case 'reset': + reset(data.rowCount) + break + case 'burst': + produceTicks(data.tickCount) + flush() + break + } +}) + +setInterval(() => { + const now = performance.now() + const elapsed = Math.min(100, Math.max(0, now - runtime.lastTickAt)) + runtime.lastTickAt = now + + if (runtime.initialized && runtime.running) { + runtime.tickBudget += (runtime.ticksPerSecond * elapsed) / 1_000 + const tickCount = Math.floor(runtime.tickBudget) + runtime.tickBudget -= tickCount + produceTicks(tickCount) + } +}, 16) + +restartPublishTimer() + +function reset(rowCount: number): void { + runtime.initialized = true + runtime.sessionId++ + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + runtime.tickBudget = 0 + runtime.lastTickAt = performance.now() + + post({ + type: 'snapshot', + sessionId: runtime.sessionId, + quotes: engine.reset(rowCount), + }) +} + +function produceTicks(tickCount: number): void { + if (!runtime.initialized || tickCount <= 0) return + + runtime.pendingTickCount += tickCount + for (const update of engine.applyTicks( + tickCount, + runtime.updateSparklines, + runtime.sparklineSampleIntervalMs, + )) { + const previousUpdate = pendingUpdates.get(update.index) + if (previousUpdate) runtime.pendingCoalescedUpdateCount++ + pendingUpdates.set(update.index, { + ...update, + ...(update.history || !previousUpdate?.history + ? {} + : { history: previousUpdate.history }), + }) + } +} + +function flush(): void { + if (runtime.pendingTickCount === 0) return + + const message: MarketFeedEvent = { + type: 'updates', + sessionId: runtime.sessionId, + tickCount: runtime.pendingTickCount, + coalescedUpdateCount: runtime.pendingCoalescedUpdateCount, + updates: [...pendingUpdates.values()], + } + + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + post(message) +} + +function restartPublishTimer(): void { + if (runtime.publishTimerId !== null) { + clearInterval(runtime.publishTimerId) + } + runtime.publishTimerId = setInterval( + flush, + Math.max(4, runtime.publishIntervalMs), + ) +} + +function post(event: MarketFeedEvent): void { + postMessage(event) +} diff --git a/examples/react/realtime-trading/src/index.css b/examples/react/realtime-trading/src/index.css new file mode 100644 index 0000000000..397c86fc54 --- /dev/null +++ b/examples/react/realtime-trading/src/index.css @@ -0,0 +1,1058 @@ +:root { + color-scheme: dark; + --font-ui: + Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, + 'Segoe UI', sans-serif; + --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace; + font-family: var(--font-ui); + font-synthesis: none; + --background: #050505; + --panel: #080808; + --panel-raised: #111111; + --panel-hover: #181818; + --surface-bar: #080808; + --surface-toolbar: #0d0d0d; + --surface-table: #050505; + --surface-header: #101010; + --surface-control: #151515; + --border: #303030; + --border-soft: #242424; + --border-strong: #4a4a4a; + --text: #e7ebf0; + --text-strong: #ffffff; + --text-inverse: #f7f9fb; + --muted: #737982; + --blue: #62a9ff; + --blue-soft: #a9d0ff; + --green: #42e488; + --red: #ff646b; + --amber: #dfb465; + --depth-bid: #315774; + --depth-ask: #634049; + --row-alt: rgb(255 255 255 / 1.8%); + --row-selected: rgb(66 132 214 / 16%); + --control-border: #354456; + --control-hover: #192431; + --sidebar-width: 18rem; + --shell-bar-height: 2.625rem; + --metrics-height: 3.5rem; + --statusbar-height: 1.625rem; + --virtual-footer-height: 2.125rem; + --table-header-height: 2rem; + --table-row-height: 2rem; + --shell-inline-padding: 0.75rem; + --table-cell-inline-padding: 0.6rem; + --control-radius: 1px; +} + +* { + box-sizing: border-box; +} + +html, +body { + min-width: 320px; + min-height: 100%; + margin: 0; + background: var(--background); +} + +body { + color: var(--text); +} + +button, +select, +input { + font: inherit; +} + +button, +select { + color: var(--text); + background: var(--panel-raised); + border: 1px solid var(--control-border); + border-radius: var(--control-radius); +} + +button { + padding: 0.5rem 0.65rem; + cursor: pointer; + font-size: 0.72rem; + font-weight: 650; + letter-spacing: 0.025em; +} + +button:hover { + background: var(--control-hover); + border-color: var(--border-strong); +} + +button:focus-visible, +select:focus-visible, +input:focus-visible { + outline: 1px solid var(--blue); + outline-offset: 1px; +} + +select { + width: 100%; + padding: 0.45rem 0.55rem; + font-size: 0.75rem; +} + +.trading-terminal { + --active-sidebar-width: var(--sidebar-width); + display: grid; + width: 100%; + height: 100dvh; + min-height: 0; + overflow: hidden; + background: var(--background); + grid-template-areas: + 'header sidebar' + 'content sidebar' + 'footer sidebar'; + grid-template-columns: minmax(0, 1fr) var(--active-sidebar-width); + grid-template-rows: auto minmax(0, 1fr) auto; + transition: grid-template-columns 160ms ease; +} + +.trading-terminal.is-sidebar-collapsed { + --active-sidebar-width: 0px; +} + +.shell-header { + display: flex; + min-width: 0; + flex-direction: column; + grid-area: header; +} + +.app-bar { + display: flex; + min-height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + background: var(--surface-bar); + border-bottom: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.68rem; + letter-spacing: 0.045em; +} + +.brand, +.header-actions, +.feed-status { + display: flex; + align-items: center; +} + +.brand { + gap: 0.65rem; + color: var(--text-strong); +} + +.header-actions { + gap: 0.75rem; +} + +.sidebar-toggle { + display: grid; + width: 1.9rem; + height: 1.9rem; + padding: 0; + place-items: center; + color: var(--muted); + background: transparent; + border-color: transparent; +} + +.sidebar-toggle:hover { + color: var(--text-strong); + background: var(--surface-control); + border-color: var(--border); +} + +.sidebar-toggle svg { + width: 1rem; + height: 1rem; + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-width: 1.4; +} + +.feed-status { + gap: 0.4rem; + color: var(--muted); +} + +.feed-status.is-running { + color: var(--green); +} + +.status-dot { + width: 6px; + height: 6px; + background: var(--muted); + border-radius: 50%; +} + +.feed-status.is-running .status-dot { + background: var(--green); +} + +.development-warning { + flex: 0 0 auto; + padding: 0.3rem 0.75rem; + color: var(--amber); + background: color-mix(in srgb, var(--amber) 8%, var(--background)); + border-bottom: 1px solid color-mix(in srgb, var(--amber) 24%, var(--border)); + font-family: var(--font-mono); + font-size: 0.62rem; + letter-spacing: 0.04em; +} + +.market-panel { + display: flex; + min-width: 0; + min-height: 0; + flex-direction: column; + background: var(--panel); + grid-area: content; +} + +.metrics-strip { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + background: var(--border); + border-bottom: 1px solid var(--border); + gap: 1px; +} + +.metrics-strip h2 { + margin: 0; + padding: 0.65rem var(--shell-inline-padding) 0.45rem; + color: var(--muted); + background: var(--surface-table); + font-size: 0.58rem; + grid-column: 1 / -1; + letter-spacing: 0.075em; +} + +.metrics-strip article { + min-width: 0; + min-height: 4.25rem; + padding: 0.5rem var(--shell-inline-padding); + background: var(--surface-bar); +} + +.metrics-strip span, +.metrics-strip small { + display: block; + color: var(--muted); + font-size: 0.56rem; + letter-spacing: 0.045em; + line-height: 1.35; +} + +.metrics-strip strong { + display: block; + margin: 0.12rem 0 0.08rem; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.88rem; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +.metrics-strip strong.metric-alert { + color: var(--amber); +} + +.table-scroll { + flex: 1; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +.virtual-scroll-footer { + display: flex; + flex: 0 0 auto; + align-items: center; + justify-content: space-between; + min-height: var(--virtual-footer-height); + padding: 0 var(--shell-inline-padding); + color: var(--muted); + background: var(--surface-toolbar); + border-top: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.68rem; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +table { + min-width: 100%; + border-spacing: 0; + table-layout: fixed; + font-family: var(--font-ui); + font-size: 0.78rem; + font-variant-numeric: tabular-nums; +} + +.virtual-table { + display: grid; +} + +.virtual-table thead { + display: grid; +} + +.virtual-table thead tr, +.virtual-table-row { + display: flex; + width: 100%; +} + +.virtual-table th, +.virtual-table-row > td { + flex: 0 0 auto; +} + +.virtual-table-body { + position: relative; + display: grid; +} + +.virtual-table-row { + position: absolute; + left: 0; + height: var(--table-row-height); +} + +.virtual-table-row > td { + display: block; +} + +.trading-data-grid { + display: grid; +} + +.trading-data-grid thead, +.trading-data-grid tbody { + display: grid; +} + +.trading-data-grid tbody { + -webkit-user-select: none; + user-select: none; +} + +.trading-data-grid thead > tr, +.trading-data-grid tbody > tr { + display: flex; + width: 100%; +} + +.trading-data-grid tbody > tr { + min-height: var(--table-row-height); + content-visibility: auto; + contain-intrinsic-block-size: var(--table-row-height); +} + +.trading-data-grid th, +.trading-data-grid td { + flex: 0 0 auto; +} + +thead { + position: sticky; + z-index: 2; + top: 0; +} + +th { + height: var(--table-header-height); + padding: 0 var(--table-cell-inline-padding); + color: var(--muted); + background: var(--surface-header); + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border); + font-size: 0.7rem; + font-weight: 500; + letter-spacing: 0.005em; + text-align: left; + white-space: nowrap; +} + +th.column-group-header { + color: #666b72; + font-size: 0.72rem; + font-weight: 500; + text-align: center; +} + +thead tr:first-child th.column-group-header { + color: #777d85; + font-size: 0.76rem; +} + +th.numeric-header { + text-align: right; +} + +td { + height: var(--table-row-height); + padding: 0 var(--table-cell-inline-padding); + overflow: hidden; + color: #eef1f5; + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border-soft); + text-align: right; + text-overflow: ellipsis; + white-space: nowrap; +} + +th:last-child, +td:last-child { + border-right: 0; +} + +td[data-column-id='market'], +td[data-column-id='name'], +td[data-column-id='symbol'] { + text-align: left; +} + +td[data-column-id='market'] { + color: var(--blue); + font-weight: 550; +} + +td[data-column-id='name'] { + color: var(--text-strong); +} + +td[data-column-id='symbol'] { + color: #d8dde4; + font-weight: 600; +} + +tbody tr:nth-child(even) { + background: var(--row-alt); +} + +tbody tr:hover { + background: var(--panel-hover); +} + +tbody tr[data-symbol-selected='true'] { + background: var(--row-selected); + box-shadow: inset 2px 0 0 var(--blue); +} + +.table-scroll:focus { + outline: none; +} + +th { + position: relative; +} + +.leaf-header-content { + display: flex; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + height: 100%; + align-items: stretch; + margin-inline: calc(-1 * var(--table-cell-inline-padding)); +} + +.column-drag-handle, +.sort-header-button { + min-width: 0; + height: 100%; + padding: 0; + color: inherit; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-weight: inherit; + letter-spacing: inherit; +} + +.column-drag-handle { + flex: 0 0 1.05rem; + color: var(--muted); + cursor: grab; + opacity: 0.35; + font-size: 0.56rem; + letter-spacing: -0.32rem; + text-align: center; +} + +.column-drag-handle:active { + cursor: grabbing; +} + +th:hover .column-drag-handle, +.column-drag-handle:focus-visible { + opacity: 0.9; +} + +.column-drag-handle:hover, +.sort-header-button:hover { + background: rgb(255 255 255 / 4%); + border-color: transparent; +} + +th.is-column-dragging { + opacity: 0.45; +} + +th.is-column-drop-target { + background: rgb(50 139 255 / 16%); + box-shadow: inset 4px 0 0 var(--blue); +} + +th.is-column-drop-target::before { + position: absolute; + z-index: 6; + top: -1px; + bottom: -1px; + left: -2px; + width: 4px; + background: #62a9ff; + box-shadow: + 0 0 0 1px rgb(0 0 0 / 55%), + 0 0 12px rgb(70 151 255 / 90%); + content: ''; + pointer-events: none; +} + +.sort-header-button { + display: flex; + min-width: 0; + flex: 1; + align-items: center; + justify-content: flex-start; + gap: 0.3rem; + padding-inline: 0.25rem var(--table-cell-inline-padding); + cursor: default; + text-align: inherit; +} + +.numeric-header .sort-header-button { + justify-content: flex-end; +} + +.sort-header-button.is-sortable { + cursor: pointer; +} + +.sort-header-button:disabled { + opacity: 1; +} + +.header-label { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.sort-indicator { + flex: 0 0 auto; + color: #66717e; + font-size: 0.72rem; +} + +.sort-indicator.is-active { + color: var(--blue-soft); +} + +.column-resize-handle { + position: absolute; + z-index: 3; + top: 0; + right: -3px; + width: 7px; + height: 100%; + cursor: col-resize; + touch-action: none; + user-select: none; +} + +.column-resize-handle::after { + position: absolute; + top: 20%; + right: 3px; + width: 1px; + height: 60%; + background: var(--border-strong); + content: ''; + opacity: 0; +} + +th:hover > .column-resize-handle::after, +.column-resize-handle.is-resizing::after { + background: var(--blue); + opacity: 1; +} + +tbody tr[aria-selected='true'] { + background: rgb(76 145 228 / 13%); +} + +td[aria-selected='true'] { + position: relative; + background: rgb(70 139 222 / 12%); +} + +td[data-cell-focused='true'] { + background: rgb(70 139 222 / 21%); +} + +td[aria-selected='true']::after { + position: absolute; + z-index: 1; + inset: 0; + border: 1px solid transparent; + content: ''; + pointer-events: none; +} + +td[data-selection-top='true']::after { + border-top-color: var(--blue); +} + +td[data-selection-right='true']::after { + border-right-color: var(--blue); +} + +td[data-selection-bottom='true']::after { + border-bottom-color: var(--blue); +} + +td[data-selection-left='true']::after { + border-left-color: var(--blue); +} + +.price-button { + min-width: 4.5rem; + padding: 0; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-variant-numeric: tabular-nums; + font-weight: 600; + text-align: right; +} + +.price-button:hover { + background: transparent; + text-decoration: underline; + text-underline-offset: 2px; +} + +.move-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.move-cell.quote-up, +.percent-change-cell.quote-up { + background: color-mix(in srgb, var(--green) 7%, transparent); +} + +.move-cell.quote-down, +.percent-change-cell.quote-down { + background: color-mix(in srgb, var(--red) 7%, transparent); +} + +.percent-change-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.spread-cell { + display: flex; + align-items: baseline; + justify-content: flex-end; + gap: 0.35rem; + color: var(--text); +} + +.spread-cell small { + min-width: 2.8rem; + color: var(--muted); + font-size: 0.55rem; +} + +.spread-cell.spread-wide, +.spread-cell.spread-wide small { + color: var(--amber); +} + +.depth-cell { + position: relative; + display: flex; + height: 17px; + overflow: hidden; + background: var(--surface-control); +} + +.depth-bid, +.depth-ask { + height: 100%; + opacity: 0.78; +} + +.depth-bid { + background: var(--depth-bid); + border-right: 1px solid var(--panel); +} + +.depth-ask { + background: var(--depth-ask); +} + +.depth-values { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 0.28rem; + color: var(--text-strong); + font-size: 0.57rem; + text-shadow: 0 1px var(--background); +} + +.quote-age { + color: var(--muted); +} + +.quote-age-warm { + color: var(--amber); +} + +.quote-age-stale { + color: var(--red); +} + +.quote-up { + color: var(--green); +} + +.quote-down { + color: var(--red); +} + +.sparkline { + display: block; + width: 100%; + height: 1.35rem; + margin-left: auto; + color: var(--blue-soft); + overflow: visible; +} + +.sparkline.quote-up { + color: var(--green); +} + +.sparkline.quote-down { + color: var(--red); +} + +.sparkline polyline { + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-linejoin: miter; + stroke-width: 1.25; + vector-effect: non-scaling-stroke; +} + +.market-statusbar { + display: flex; + flex: 0 0 var(--statusbar-height); + min-height: var(--statusbar-height); + gap: 1.1rem; + align-items: center; + padding: 0 0.65rem; + color: var(--muted); + background: var(--surface-bar); + border-top: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.56rem; + grid-area: footer; + letter-spacing: 0.035em; +} + +.market-statusbar strong { + margin-left: 0.25rem; + color: var(--text); + font-weight: 500; +} + +.sidebar-slot { + width: var(--sidebar-width); + min-width: 0; + min-height: 0; + overflow: hidden; + background: var(--surface-table); + border-left: 1px solid var(--border); + grid-area: sidebar; + transition: + opacity 120ms ease, + transform 160ms ease, + visibility 160ms; +} + +.is-sidebar-collapsed .sidebar-slot { + visibility: hidden; + opacity: 0; + pointer-events: none; + transform: translateX(100%); +} + +.configurator { + width: 100%; + height: 100%; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +.configurator > header { + display: flex; + height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + color: var(--text-strong); + background: var(--surface-toolbar); + border-bottom: 1px solid var(--border); + font-size: 0.65rem; + font-weight: 700; + letter-spacing: 0.055em; +} + +.configurator > header small { + color: var(--muted); + font-size: 0.54rem; + font-weight: 500; +} + +.config-section { + display: grid; + gap: 0.7rem; + padding: 0.8rem var(--shell-inline-padding); + border-bottom: 1px solid var(--border); +} + +.config-section h2 { + margin: 0; + color: var(--muted); + font-size: 0.58rem; + letter-spacing: 0.075em; +} + +.primary-action { + width: 100%; + color: var(--text-inverse); + background: var(--blue); + border-color: var(--blue-soft); +} + +.primary-action:hover { + background: var(--blue-soft); + border-color: var(--text-strong); +} + +.field { + display: grid; + gap: 0.35rem; + color: var(--text); + font-size: 0.66rem; +} + +.rate-field > span { + display: flex; + justify-content: space-between; +} + +.rate-field strong { + color: var(--text); + font-family: var(--font-mono); + font-weight: 500; +} + +.field small { + color: var(--muted); + font-family: var(--font-mono); + font-size: 0.55rem; +} + +input[type='range'] { + width: 100%; + margin: 0; + accent-color: var(--blue); +} + +.toggle-field { + display: flex; + gap: 0.5rem; + align-items: flex-start; + color: var(--text); + font-size: 0.66rem; + line-height: 1.3; +} + +.toggle-field input { + margin: 0.12rem 0 0; + accent-color: var(--blue); +} + +.toggle-field small { + display: block; + margin-top: 0.14rem; + color: var(--muted); + font-size: 0.57rem; +} + +.action-grid { + display: grid; + grid-template-columns: 1fr; + gap: 0.4rem; +} + +.diagnostics dl, +.selected-instrument dl { + display: grid; + gap: 0; + margin: 0; +} + +.diagnostics dl > div, +.selected-instrument dl > div { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 24px; + border-bottom: 1px solid var(--border-soft); +} + +.diagnostics dl > div:last-child, +.selected-instrument dl > div:last-child { + border-bottom: 0; +} + +.diagnostics dl > div:has(dd[data-testid$='-breakdown']) { + display: grid; + grid-template-columns: minmax(0, 1fr); + align-content: center; + padding-block: 0.28rem; +} + +.diagnostics dd[data-testid$='-breakdown'] { + width: 100%; + overflow-x: auto; + padding-block: 0.12rem; + white-space: nowrap; + scrollbar-width: thin; +} + +dt { + color: var(--muted); + font-size: 0.61rem; +} + +dd { + margin: 0; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.62rem; +} + +.selection { + display: flex; + align-items: flex-start; + justify-content: space-between; +} + +.selection div { + display: grid; + gap: 0.18rem; +} + +.selection strong { + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.85rem; +} + +.selection span, +.selection small, +.selected-instrument p { + color: var(--muted); + font-size: 0.61rem; +} + +.selected-instrument p { + margin: 0; + line-height: 1.45; +} + +@media (max-width: 980px) { + :root { + --sidebar-width: 15.625rem; + } +} + +@media (max-width: 720px) { + .trading-terminal { + --active-sidebar-width: 0px; + height: 100dvh; + min-height: 0; + overflow: hidden; + } + + .market-panel { + min-height: 0; + } + + .table-scroll { + min-height: 0; + } + + .sidebar-slot { + position: fixed; + z-index: 20; + top: 0; + right: 0; + bottom: 0; + width: min(var(--sidebar-width), calc(100vw - 2.75rem)); + box-shadow: -18px 0 42px rgb(0 0 0 / 48%); + } + + .is-sidebar-collapsed .sidebar-slot { + box-shadow: none; + } +} diff --git a/examples/react/realtime-trading/src/main.tsx b/examples/react/realtime-trading/src/main.tsx new file mode 100644 index 0000000000..27b3622c66 --- /dev/null +++ b/examples/react/realtime-trading/src/main.tsx @@ -0,0 +1,48 @@ +import { createRoot } from 'react-dom/client' +import { App } from './App' +import './index.css' + +if (import.meta.env.DEV) { + const nativeMeasure = performance.measure.bind(performance) + const allowedMeasures = new Set([ + 'react-profiler-commit', + 'tanstack-row-model', + 'market-update-to-dom-commit', + ]) + performance.measure = (( + name: string, + startOrOptions?: string | PerformanceMeasureOptions, + endMark?: string, + ) => { + // React 19 DEV records a User Timing measure per component. Combined with + // this live feed that path freezes Chromium, so keep only benchmark marks. + if (!allowedMeasures.has(name)) { + return undefined as unknown as PerformanceMeasure + } + try { + if ( + startOrOptions && + typeof startOrOptions === 'object' && + 'detail' in startOrOptions + ) { + const { detail: _detail, ...rest } = startOrOptions + return nativeMeasure(name, rest, endMark) + } + return nativeMeasure(name, startOrOptions as string, endMark) + } catch { + return undefined as unknown as PerformanceMeasure + } + }) as typeof performance.measure + + const reactScan = document.createElement('script') + reactScan.src = 'https://unpkg.com/react-scan/dist/auto.global.js' + reactScan.async = true + document.head.append(reactScan) +} + +const rootElement = document.getElementById('root') +if (!rootElement) throw new Error('Failed to find the root element') + +// StrictMode is intentionally omitted: its development-only mount replay would +// contaminate the component lifecycle counters used by this benchmark. +createRoot(rootElement).render() diff --git a/examples/react/realtime-trading/src/shell/TradingShell.tsx b/examples/react/realtime-trading/src/shell/TradingShell.tsx new file mode 100644 index 0000000000..ce9275a03c --- /dev/null +++ b/examples/react/realtime-trading/src/shell/TradingShell.tsx @@ -0,0 +1,688 @@ +import { shallow, useSelector } from '@tanstack/react-store' +import { useState } from 'react' +import { + feedSampleRateAt, + feedSampleRateIndex, + feedSampleRateOptions, +} from '../feed/feed-sample-rates' +import { + FORCED_VIRTUALIZATION_ROW_COUNT, + resolveVirtualScrollMode, +} from '../table/trading-row-virtualizer' +import { + useMarketFeedController, + useTradingShellController, + useTradingShellState, +} from './trading-shell-context' +import { configuratorOptions } from './configurator-options' +import type { ReactNode } from 'react' +import type { FeedMetrics } from '../benchmark/benchmark-monitor' + +const integerFormatter = new Intl.NumberFormat('en-US', { + maximumFractionDigits: 0, +}) +const rateFormatter = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +export function TradingShell(props: { children: ReactNode }) { + const [sidebarOpen, setSidebarOpen] = useState(true) + const toggleSidebar = () => setSidebarOpen((open) => !open) + + return ( +
+
+ + + {import.meta.env.DEV && ( + + )} + + {import.meta.env.MODE === 'production' && ( + + )} +
+ +
+ {props.children} +
+ +
{sidebarOpen && }
+
+ ) +} + +function AppHeader(props: { + sidebarOpen: boolean + onSidebarToggle: () => void +}) { + const feed = useMarketFeedController() + const workerReady = useSelector(feed.workerReady) + const running = useSelector(feed.running) + return ( +
+
+ MARKET MONITOR +
+
+ + + +
+
+ ) +} + +function MarketStatusbar() { + const { lastBatchSize, lastUpdateCount, mountedCells, liveComponents } = + useTradingShellState( + (state) => ({ + lastBatchSize: state.metrics.lastBatchSize, + lastUpdateCount: state.metrics.lastUpdateCount, + mountedCells: state.mountedCells, + liveComponents: state.liveComponents, + }), + { compare: shallow }, + ) + return ( +
+ + MESSAGE SAMPLES {formatInteger(lastBatchSize)} + + + CHANGED ROWS {formatInteger(lastUpdateCount)} + + + HOSTS {formatInteger(mountedCells)} + + + COMPONENTS {formatInteger(liveComponents)} + +
+ ) +} + +function Configurator() { + const benchmarkState = useTradingShellState( + (storeState) => ({ + requestedVirtualScrollMode: storeState.requestedVirtualScrollMode, + }), + { compare: shallow }, + ) + const controller = useTradingShellController() + const feed = useMarketFeedController() + const running = useSelector(feed.running) + const instrumentCount = useSelector(feed.instrumentCount) + const targetTicksPerSecond = useSelector(feed.targetTicksPerSecond) + const publishIntervalMs = useSelector(feed.publishIntervalMs) + const updateSparklines = useSelector(feed.updateSparklines) + const sparklineSampleIntervalMs = useSelector(feed.sparklineSampleIntervalMs) + const rendererMode = useSelector(controller.renderAtoms.rendererMode) + const { actions } = controller + const feedActions = feed.actions + const { requestedVirtualScrollMode } = benchmarkState + const { setRendererMode, setVirtualScrollEnabled, resetMarket } = actions + const { + toggle, + setInstrumentCount, + setTargetRate, + setPublishInterval, + setSparklineUpdates, + setSparklineSampleInterval, + runBurst, + } = feedActions + const virtualScrollForced = instrumentCount >= FORCED_VIRTUALIZATION_ROW_COUNT + const virtualScrollMode = resolveVirtualScrollMode( + requestedVirtualScrollMode, + instrumentCount, + ) + + return ( + + ) +} + +function LiveHealth() { + const { metrics, longAnimationFramesSupported } = useTradingShellState( + (state) => ({ + metrics: state.metrics, + longAnimationFramesSupported: state.longAnimationFramesSupported, + }), + { compare: shallow }, + ) + return ( +
+

LIVE HEALTH

+
+ FRAME RATE (EST.) + + {metrics.estimatedFrameRate.toFixed(1)} + + rAF callbacks/s · rolling 1 s +
+
+ AVG COMMIT + + {formatMs(metrics.averageCommitLatencyMs)} + + snapshot → DOM · rolling 3 s +
+
+ LONG FRAMES + {longAnimationFramesSupported ? ( + <> + 0 ? 'metric-alert' : ''} + > + {metrics.longAnimationFrames} + + + since reset · worst {formatMs(metrics.worstLongAnimationFrameMs)} + + + ) : ( + <> + N/A + unsupported + + )} +
+
+ THROUGHPUT + + {formatRate(metrics.rowUpdatesPerSecond)} rows/s + + + {metrics.stateApplicationsPerSecond.toFixed(1)} snapshots/s · rows + deduplicated per snapshot + +
+
+ ) +} + +function Diagnostics() { + const { + metrics, + mountedCells, + liveComponents, + longAnimationFramesSupported, + } = useTradingShellState( + (state) => ({ + metrics: state.metrics, + mountedCells: state.mountedCells, + liveComponents: state.liveComponents, + longAnimationFramesSupported: state.longAnimationFramesSupported, + }), + { compare: shallow }, + ) + const profilerEnabled = + import.meta.env.DEV || import.meta.env.MODE === 'profile' + return ( +
+

DIAGNOSTICS

+
+
+
Worker samples / s
+
+ {formatRate(metrics.actualTicksPerSecond)} +
+
+
+
Changed rows / s
+
+ {formatRate(metrics.rowUpdatesPerSecond)} +
+
+
+
Worker messages / s
+
+ {metrics.workerMessagesPerSecond.toFixed(1)} +
+
+
+
State applies / s
+
+ {metrics.stateApplicationsPerSecond.toFixed(1)} +
+
+
+
Table DOM commits / s
+
+ {metrics.tableCommitsPerSecond.toFixed(1)} +
+
+
+
Commit latency p95 / max
+
+ {formatMs(metrics.p95CommitLatencyMs)} /{' '} + {formatMs(metrics.maxCommitLatencyMs)} +
+
+
+
Mounted cells
+
{formatInteger(mountedCells)}
+
+
+
Live components
+
{formatInteger(liveComponents)}
+
+
+
Created / destroyed
+
+ {formatInteger(metrics.componentsCreated)} /{' '} + {formatInteger(metrics.componentsDestroyed)} +
+
+
+
Renderer callbacks / s
+
+ {formatRate(metrics.cellRendererCallsPerSecond)} +
+
+
+
Component executions / s
+
+ {formatRate(metrics.componentRenderCallsPerSecond)} +
+
+
+
Executions by component / s
+
+ {formatInvocationRates(metrics.componentRenderRates)} +
+
+
+
Callbacks by column / s
+
+ {formatInvocationRates(metrics.cellRendererRates)} +
+
+
+
Observed MutationRecords / s
+
+ {formatRate(metrics.domMutationsPerSecond)} +
+
+
+
React Profiler commits / s
+
+ {profilerEnabled + ? metrics.profilerCommitsPerSecond.toFixed(1) + : 'PROFILE BUILD REQUIRED'} +
+
+
+
Profiler actual avg / p95
+
+ {profilerEnabled + ? `${formatMs(metrics.profilerAverageActualMs)} / ${formatMs( + metrics.profilerP95ActualMs, + )}` + : 'N/A'} +
+
+
+
Profiler base avg
+
+ {profilerEnabled ? formatMs(metrics.profilerAverageBaseMs) : 'N/A'} +
+
+
+
Core row model calls / s
+
+ {metrics.rowModelCallsPerSecond.toFixed(1)} +
+
+
+
Core row model avg / max
+
+ {formatMs(metrics.rowModelAverageMs)} /{' '} + {formatMs(metrics.rowModelMaxMs)} +
+
+
+
Visible rows
+
+ {formatInteger(metrics.visibleRows)} +
+
+
+
Worker messages
+
+ {formatInteger(metrics.workerMessages)} +
+
+
+
Worker-coalesced updates / s
+
+ {formatRate(metrics.supersededUpdatesPerSecond)} +
+
+
+
Last message samples / updated rows
+
+ {formatInteger(metrics.lastBatchSize)} /{' '} + {formatInteger(metrics.lastUpdateCount)} +
+
+
+
Commits > 16.7 ms since reset
+
{metrics.slowCommits}
+
+
+
Long animation frames
+
+ {longAnimationFramesSupported + ? formatInteger(metrics.longAnimationFrames) + : 'Unsupported'} +
+
+
+
+ JS heap (GC-sensitive) +
+
+ {metrics.heapMb === null + ? 'N/A' + : `${metrics.heapMb.toFixed(1)} MB`} +
+
+
+
+ ) +} + +function SelectedInstrument() { + const controller = useTradingShellController() + const feed = useMarketFeedController() + const selectedSymbol = useSelector(controller.renderAtoms.selectedSymbol) + const quotes = useSelector(feed.quotes) + const selectedQuote = feed.getQuoteBySymbol(quotes, selectedSymbol) + return ( +
+

SELECTED INSTRUMENT

+ {selectedQuote ? ( + <> +
+
+ {selectedQuote.symbol} + {selectedQuote.company} +
+ {selectedQuote.venue} +
+
+
+
Last
+
{selectedQuote.price.toFixed(2)}
+
+
+
Bid / ask
+
+ {selectedQuote.bid.toFixed(2)} / {selectedQuote.ask.toFixed(2)} +
+
+
+ + ) : ( +

+ Click or begin a cell selection in any row to inspect its instrument. +

+ )} +
+ ) +} + +function formatInteger(value: number): string { + return integerFormatter.format(value) +} + +function formatRate(value: number): string { + return rateFormatter.format(value) +} + +function formatMs(value: number): string { + return `${value.toFixed(2)} ms` +} + +function formatInvocationRates( + rates: FeedMetrics['componentRenderRates'], +): string { + const activeRates = rates + .filter((rate) => rate.callsPerSecond > 0) + .sort((left, right) => right.callsPerSecond - left.callsPerSecond) + return activeRates.length === 0 + ? 'No calls in sample' + : activeRates + .map((rate) => `${rate.name} ${formatRate(rate.callsPerSecond)}`) + .join(' · ') +} diff --git a/examples/react/realtime-trading/src/shell/configurator-options.ts b/examples/react/realtime-trading/src/shell/configurator-options.ts new file mode 100644 index 0000000000..49a9566fe7 --- /dev/null +++ b/examples/react/realtime-trading/src/shell/configurator-options.ts @@ -0,0 +1,55 @@ +export interface ConfiguratorOption { + readonly label: string + readonly value: TValue +} + +const instrumentCountOptions = [ + { label: '50', value: 50 }, + { label: '100', value: 100 }, + { label: '150', value: 150 }, + { label: '250', value: 250 }, + { label: '350', value: 350 }, + { label: '500', value: 500 }, + { label: '750', value: 750 }, + { label: '1,000', value: 1_000 }, + { label: '1,500', value: 1_500 }, + { label: '2,500', value: 2_500 }, + { label: '5,000', value: 5_000 }, + { label: '1,000,000', value: 1_000_000 }, + { label: '10,000,000', value: 10_000_000 }, +] as const satisfies ReadonlyArray> + +const workerDeliveryOptions = [ + { label: '8 ms · 125 msg/s', value: 8 }, + { label: '16 ms · 62.5 msg/s', value: 16 }, + { label: '20 ms · 50 msg/s', value: 20 }, + { label: '33 ms · 30 msg/s', value: 33 }, + { label: '50 ms · 20 msg/s', value: 50 }, + { label: '100 ms · 10 msg/s', value: 100 }, + { label: '250 ms · 4 msg/s', value: 250 }, + { label: '500 ms · 2 msg/s', value: 500 }, + { label: '1,000 ms · 1 msg/s', value: 1_000 }, +] as const satisfies ReadonlyArray> + +const rowRenderingOptions = [ + { label: 'Full DOM · render every row', value: 'none' }, + { label: 'TanStack Virtual · visible rows only', value: 'tanstack' }, +] as const satisfies ReadonlyArray> + +const intradaySamplingOptions = [ + { label: '16 ms · fastest', value: 16 }, + { label: '33 ms · very fast', value: 33 }, + { label: '50 ms · fast', value: 50 }, + { label: '100 ms', value: 100 }, + { label: '250 ms', value: 250 }, + { label: '500 ms', value: 500 }, + { label: '1,000 ms', value: 1_000 }, + { label: '2,000 ms', value: 2_000 }, +] as const satisfies ReadonlyArray> + +export const configuratorOptions = { + instrumentCounts: instrumentCountOptions, + workerDeliveryIntervals: workerDeliveryOptions, + rowRenderingModes: rowRenderingOptions, + intradaySamplingIntervals: intradaySamplingOptions, +} as const diff --git a/examples/react/realtime-trading/src/shell/trading-shell-context.tsx b/examples/react/realtime-trading/src/shell/trading-shell-context.tsx new file mode 100644 index 0000000000..1c876ec374 --- /dev/null +++ b/examples/react/realtime-trading/src/shell/trading-shell-context.tsx @@ -0,0 +1,50 @@ +import { createStoreContext, useSelector } from '@tanstack/react-store' +import type { ReactNode } from 'react' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../benchmark/use-trading-benchmark-controller' +import type { TradingBenchmarkState } from '../benchmark/trading-benchmark-controller' +import type { UseSelectorOptions } from '@tanstack/react-store' + +const { + StoreProvider: TradingStoreProvider, + useStoreContext: useTradingShellController, +} = createStoreContext() + +const { + StoreProvider: MarketFeedStoreProvider, + useStoreContext: useMarketFeedController, +} = createStoreContext() + +export function MarketFeedProvider(props: { + controller: MarketFeedController + children: ReactNode +}) { + return ( + + {props.children} + + ) +} + +export function TradingShellProvider(props: { + controller: TradingBenchmarkController + children: ReactNode +}) { + return ( + + + {props.children} + + + ) +} + +export { useMarketFeedController, useTradingShellController } + +export function useTradingShellState( + selector: (state: TradingBenchmarkState) => TSelected, + options?: UseSelectorOptions, +): TSelected { + const controller = useTradingShellController() + return useSelector(controller.store, selector, options) +} diff --git a/examples/react/realtime-trading/src/table/table-config/quote-cells.tsx b/examples/react/realtime-trading/src/table/table-config/quote-cells.tsx new file mode 100644 index 0000000000..1c5ff4523d --- /dev/null +++ b/examples/react/realtime-trading/src/table/table-config/quote-cells.tsx @@ -0,0 +1,219 @@ +import { useEffect } from 'react' + +const compactNumber = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) + +export const quoteCellLifecycle = { + created: 0, + destroyed: 0, +} + +export const quoteCellRendererNames = [ + 'Market', + 'Name', + 'Symbol', + 'Last', + 'Change', + 'ChangePercent', + 'Bid', + 'BidVolume', + 'Ask', + 'AskVolume', + 'Open', + 'High', + 'Low', + 'Intraday', +] as const + +export const quoteComponentNames = [ + 'PriceCell', + 'StableMoveCell', + 'UpMoveCell', + 'DownMoveCell', + 'PercentChangeCell', + 'SpreadCell', + 'DepthCell', + 'QuoteAgeCell', + 'SparklineCell', +] as const + +export type QuoteCellRendererName = (typeof quoteCellRendererNames)[number] +export type QuoteComponentName = (typeof quoteComponentNames)[number] + +const createCounterMap = ( + names: ReadonlyArray, +): Record => + Object.fromEntries(names.map((name) => [name, 0])) as Record + +export const quoteRenderDiagnostics = { + cellRendererCalls: 0, + componentRenderCalls: 0, + cellRendererCallsByName: createCounterMap(quoteCellRendererNames), + componentRenderCallsByName: createCounterMap(quoteComponentNames), +} + +export function recordCellRender(name: QuoteCellRendererName, value: T): T { + 'use no memo' + // Benchmark instrumentation is intentionally impure and must run per call. + quoteRenderDiagnostics.cellRendererCalls++ + quoteRenderDiagnostics.cellRendererCallsByName[name]++ + return value +} + +function useLifecycleCounter(componentName: QuoteComponentName): void { + 'use no memo' + // This diagnostic mutation measures component-function invocation itself. + quoteRenderDiagnostics.componentRenderCalls++ + quoteRenderDiagnostics.componentRenderCallsByName[componentName]++ + useEffect(() => { + quoteCellLifecycle.created++ + return () => { + quoteCellLifecycle.destroyed++ + } + }, []) +} + +export function PriceCell(props: { + price: number + move: number + onSelect: () => void +}) { + useLifecycleCounter('PriceCell') + return ( + + ) +} + +export function StableMoveCell({ move }: { move: number }) { + useLifecycleCounter('StableMoveCell') + return ( + = 0 ? 'quote-up' : 'quote-down'}`}> + {formatSigned(move)} + + ) +} + +export function UpMoveCell({ move }: { move: number }) { + useLifecycleCounter('UpMoveCell') + return ▲ {formatSigned(move)} +} + +export function DownMoveCell({ move }: { move: number }) { + useLifecycleCounter('DownMoveCell') + return ▼ {formatSigned(move)} +} + +export function PercentChangeCell({ value }: { value: number }) { + useLifecycleCounter('PercentChangeCell') + return ( + = 0 ? 'quote-up' : 'quote-down'}`} + > + {value >= 0 ? '+' : ''} + {value.toFixed(2)}% + + ) +} + +export function SpreadCell({ bid, ask }: { bid: number; ask: number }) { + useLifecycleCounter('SpreadCell') + const spread = Math.max(0, ask - bid) + const midpoint = (bid + ask) / 2 + const basisPoints = midpoint === 0 ? 0 : (spread / midpoint) * 10_000 + + return ( + = 4 ? 'spread-wide' : ''}`}> + {spread.toFixed(2)} + {basisPoints.toFixed(1)} bp + + ) +} + +export function DepthCell(props: { bidSize: number; askSize: number }) { + useLifecycleCounter('DepthCell') + const total = props.bidSize + props.askSize + const bidShare = total === 0 ? 50 : (props.bidSize / total) * 100 + + return ( +
+ + + + {compactNumber.format(props.bidSize)} + {compactNumber.format(props.askSize)} + +
+ ) +} + +export function QuoteAgeCell({ ageMs }: { ageMs: number }) { + useLifecycleCounter('QuoteAgeCell') + const className = + ageMs >= 1_500 + ? 'quote-age quote-age-stale' + : ageMs >= 500 + ? 'quote-age quote-age-warm' + : 'quote-age' + + return ( + + {ageMs < 1_000 + ? `${Math.round(ageMs)} ms` + : `${(ageMs / 1_000).toFixed(1)} s`} + + ) +} + +export function SparklineCell({ values }: { values: ReadonlyArray }) { + useLifecycleCounter('SparklineCell') + const rising = (values.at(-1) ?? 0) >= (values[0] ?? 0) + const { min, max } = findRange(values) + const range = max - min || 1 + const denominator = Math.max(1, values.length - 1) + const points = values + .map((value, index) => { + const x = (index / denominator) * 100 + const y = 22 - ((value - min) / range) * 20 + return `${x.toFixed(1)},${y.toFixed(1)}` + }) + .join(' ') + + return ( + + + + ) +} + +function formatSigned(value: number): string { + return `${value >= 0 ? '+' : ''}${value.toFixed(2)}` +} + +function findRange(values: ReadonlyArray): { + min: number + max: number +} { + const first = values[0] ?? 0 + return values.reduce( + (range, value) => { + range.min = Math.min(range.min, value) + range.max = Math.max(range.max, value) + return range + }, + { min: first, max: first }, + ) +} diff --git a/examples/react/realtime-trading/src/table/table-config/trading-table-config.tsx b/examples/react/realtime-trading/src/table/table-config/trading-table-config.tsx new file mode 100644 index 0000000000..8b89f56f6a --- /dev/null +++ b/examples/react/realtime-trading/src/table/table-config/trading-table-config.tsx @@ -0,0 +1,267 @@ +import { createColumnHelper } from '@tanstack/react-table' +import { useSelector } from '@tanstack/react-store' +import { useTradingShellController } from '../../shell/trading-shell-context' +import { tradingFeatures } from '../trading-features' +import { + DownMoveCell, + PercentChangeCell, + PriceCell, + SparklineCell, + StableMoveCell, + UpMoveCell, + recordCellRender, +} from './quote-cells' +import type { ReactNode } from 'react' +import type { MarketQuote } from '../../feed/market-data' + +export type RendererMode = 'stable' | 'swap' +export interface CoreTableState { + sorting: Array<{ id: string; desc: boolean }> + columnFilters: Array<{ id: string; value: unknown }> +} + +const compactFormatter = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const columnHelper = createColumnHelper() + +export const tradingColumns = columnHelper.columns([ + columnHelper.group({ + id: 'instrument', + header: 'Instrument', + columns: columnHelper.columns([ + columnHelper.accessor('venue', { + id: 'market', + header: 'Market', + size: 72, + cell: (info) => recordCellRender('Market', info.getValue()), + }), + columnHelper.accessor('company', { + id: 'name', + header: 'Name', + size: 180, + cell: (info) => recordCellRender('Name', info.getValue()), + }), + columnHelper.accessor('symbol', { + header: 'Symbol', + size: 92, + filterFn: 'includesString', + cell: (info) => recordCellRender('Symbol', info.getValue()), + }), + ]), + }), + columnHelper.group({ + id: 'priceAndChange', + header: 'Price & Change', + columns: columnHelper.columns([ + columnHelper.accessor('price', { + header: 'Price', + size: 96, + sortFn: 'basic', + cell: (info) => + recordCellRender('Last', ), + }), + columnHelper.accessor((row) => getDayChange(row), { + id: 'change', + header: 'Chg', + size: 94, + cell: (info) => + recordCellRender( + 'Change', + , + ), + }), + columnHelper.accessor((row) => getDayChangePercent(row), { + id: 'changePercent', + header: 'Chg%', + size: 90, + cell: (info) => + recordCellRender( + 'ChangePercent', + , + ), + }), + ]), + }), + columnHelper.group({ + id: 'orderBook', + header: 'Order Book', + columns: columnHelper.columns([ + columnHelper.accessor('bid', { + header: 'Bid', + size: 90, + cell: (info) => recordCellRender('Bid', info.getValue().toFixed(2)), + }), + columnHelper.accessor('bidSize', { + header: 'Bid Vol', + size: 100, + cell: (info) => + recordCellRender( + 'BidVolume', + compactFormatter.format(info.getValue()), + ), + }), + columnHelper.accessor('ask', { + header: 'Ask', + size: 90, + cell: (info) => recordCellRender('Ask', info.getValue().toFixed(2)), + }), + columnHelper.accessor('askSize', { + header: 'Ask Vol', + size: 100, + cell: (info) => + recordCellRender( + 'AskVolume', + compactFormatter.format(info.getValue()), + ), + }), + ]), + }), + columnHelper.group({ + id: 'session', + header: 'Session', + columns: columnHelper.columns([ + columnHelper.accessor('open', { + header: 'Open', + size: 90, + cell: (info) => recordCellRender('Open', info.getValue().toFixed(2)), + }), + columnHelper.accessor('high', { + header: 'High', + size: 90, + cell: (info) => recordCellRender('High', info.getValue().toFixed(2)), + }), + columnHelper.accessor('low', { + header: 'Low', + size: 90, + cell: (info) => recordCellRender('Low', info.getValue().toFixed(2)), + }), + ]), + }), + columnHelper.group({ + id: 'chart', + header: 'Chart', + columns: columnHelper.columns([ + columnHelper.accessor('history', { + header: 'Intraday', + size: 150, + enableSorting: false, + cell: (info) => + recordCellRender( + 'Intraday', + , + ), + }), + ]), + }), +]) + +export const rowModelDiagnostics = { + hasMeasurement: false, + calls: 0, + totalDurationMs: 0, + maxDurationMs: 0, + lastRowCount: 0, +} + +export const TRADING_COLUMN_COUNT = 14 + +export function readMeasuredRows(readRows: () => Array): Array { + const start = performance.now() + const rows = readRows() + const end = performance.now() + const duration = end - start + + rowModelDiagnostics.calls++ + rowModelDiagnostics.hasMeasurement = true + rowModelDiagnostics.totalDurationMs += duration + rowModelDiagnostics.maxDurationMs = Math.max( + rowModelDiagnostics.maxDurationMs, + duration, + ) + rowModelDiagnostics.lastRowCount = rows.length + + if (rowModelDiagnostics.calls % 1_000 === 0) { + performance.clearMeasures('tanstack-row-model') + } + if ((rowModelDiagnostics.calls - 1) % 20 === 0) { + try { + performance.measure('tanstack-row-model', { + start, + end, + detail: { rowCount: rows.length }, + }) + } catch { + // User Timing Level 3 detail is not implemented in every browser. + } + } + + return rows +} + +function LastPriceCell(props: { quote: MarketQuote }) { + const { selectSymbol } = useTradingShellController().actions + return ( + selectSymbol(props.quote.symbol)} + /> + ) +} + +function DayChangeCell(props: { quote: MarketQuote }) { + const { rendererMode } = useTradingShellController().renderAtoms + const mode = useSelector(rendererMode) + const change = getDayChange(props.quote) + if (mode === 'stable') { + return + } + return change >= 0 ? ( + + ) : ( + + ) +} + +export function TradingRow(props: { + quote: MarketQuote + children: ReactNode + rowSelected: boolean + virtualRow?: { index: number; start: number } +}) { + const { selectedSymbol } = useTradingShellController().renderAtoms + const selected = useSelector( + selectedSymbol, + (symbol) => symbol === props.quote.symbol, + ) + return ( +
+ {props.children} + + ) +} + +function getDayChange(quote: MarketQuote): number { + return quote.price - quote.previousClose +} + +function getDayChangePercent(quote: MarketQuote): number { + return quote.previousClose === 0 + ? 0 + : (getDayChange(quote) / quote.previousClose) * 100 +} diff --git a/examples/react/realtime-trading/src/table/table-interactions.ts b/examples/react/realtime-trading/src/table/table-interactions.ts new file mode 100644 index 0000000000..a7458f73ff --- /dev/null +++ b/examples/react/realtime-trading/src/table/table-interactions.ts @@ -0,0 +1,147 @@ +import type { AriaAttributes, KeyboardEvent as ReactKeyboardEvent } from 'react' + +export type CellDirection = 'up' | 'down' | 'left' | 'right' + +interface RowSelectionTable { + resetRowSelection: (defaultState?: boolean) => void +} + +interface SelectableRow { + getIsSelected: () => boolean + getToggleSelectedHandler: (options?: { + selectChildren?: boolean + }) => (event: unknown) => void +} + +interface SelectableGridCell { + row: SelectableGridRow + getSelectionStartHandler: ( + contextDocument?: Document, + ) => (event: unknown) => void + getSelectionExtendHandler: () => (event: unknown) => void +} + +interface SelectableGridRow extends SelectableRow { + original: { symbol: string } + getAllCellsByColumnId: () => Partial> +} + +export interface TradingGridTable extends RowSelectionTable { + getRowModel: () => { + rowsById: Partial> + } +} + +export interface SelectionCellTarget { + element: HTMLTableCellElement + cell: SelectableGridCell +} + +interface CellNavigationTable { + extendCellSelection: (direction: CellDirection) => void + moveCellSelection: (direction: CellDirection) => void + resetCellSelection: (defaultState?: boolean) => void + selectAllCells: () => void +} + +const keyDirections: Partial> = { + ArrowUp: 'up', + ArrowDown: 'down', + ArrowLeft: 'left', + ArrowRight: 'right', +} + +export function reorderColumnIds( + columnIds: Array, + sourceId: string, + targetId: string, +): Array { + if (sourceId === targetId || !columnIds.includes(sourceId)) return columnIds + + const withoutSource = columnIds.filter((id) => id !== sourceId) + const targetIndex = withoutSource.indexOf(targetId) + if (targetIndex < 0) return columnIds + + return [ + ...withoutSource.slice(0, targetIndex), + sourceId, + ...withoutSource.slice(targetIndex), + ] +} + +export function selectRowFromPointer( + table: RowSelectionTable, + row: SelectableRow, + event: MouseEvent, +): void { + const additive = event.ctrlKey || event.metaKey + const checked = additive ? !row.getIsSelected() : true + + if (!event.shiftKey && !additive) table.resetRowSelection(true) + + row.getToggleSelectedHandler({ selectChildren: false })({ + target: { checked }, + shiftKey: event.shiftKey, + ctrlKey: event.ctrlKey, + metaKey: event.metaKey, + nativeEvent: event, + }) +} + +export function findTradingGridCellTarget( + table: TradingGridTable, + path: Array, +): SelectionCellTarget | null { + for (const target of path) { + if (!(target instanceof HTMLTableCellElement)) continue + + const columnId = target.dataset['columnId'] + const rowId = + target.closest('tr[data-row-id]')?.dataset['rowId'] + if (!columnId || !rowId) return null + + const row = table.getRowModel().rowsById[rowId] + const cell = row?.getAllCellsByColumnId()[columnId] + return row && cell ? { element: target, cell } : null + } + + return null +} + +export function handleCellNavigation( + table: CellNavigationTable, + event: ReactKeyboardEvent, +): void { + if (event.key === 'Escape') { + event.preventDefault() + table.resetCellSelection(true) + return + } + + if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a') { + event.preventDefault() + table.selectAllCells() + return + } + + const direction = keyDirections[event.key] + if (!direction) return + + event.preventDefault() + if (event.shiftKey) table.extendCellSelection(direction) + else table.moveCellSelection(direction) +} + +export function sortIndicator(direction: false | 'asc' | 'desc'): string { + if (direction === 'asc') return '↑' + if (direction === 'desc') return '↓' + return '↕' +} + +export function sortAriaValue( + direction: false | 'asc' | 'desc', +): AriaAttributes['aria-sort'] { + if (direction === 'asc') return 'ascending' + if (direction === 'desc') return 'descending' + return 'none' +} diff --git a/examples/react/realtime-trading/src/table/trading-features.ts b/examples/react/realtime-trading/src/table/trading-features.ts new file mode 100644 index 0000000000..7ee77afd06 --- /dev/null +++ b/examples/react/realtime-trading/src/table/trading-features.ts @@ -0,0 +1,16 @@ +import { + createFilteredRowModel, + createSortedRowModel, + filterFn_includesString, + sortFn_basic, + stockFeatures, + tableFeatures, +} from '@tanstack/react-table' + +export const tradingFeatures = tableFeatures({ + ...stockFeatures, + filteredRowModel: createFilteredRowModel(), + sortedRowModel: createSortedRowModel(), + filterFns: { includesString: filterFn_includesString }, + sortFns: { basic: sortFn_basic }, +}) diff --git a/examples/react/realtime-trading/src/table/trading-row-virtualizer.ts b/examples/react/realtime-trading/src/table/trading-row-virtualizer.ts new file mode 100644 index 0000000000..bc4b34b528 --- /dev/null +++ b/examples/react/realtime-trading/src/table/trading-row-virtualizer.ts @@ -0,0 +1,18 @@ +export const TRADING_ROW_HEIGHT = 32 +export const TRADING_ROW_OVERSCAN = 10 +export const DEFAULT_VIRTUALIZATION_ROW_COUNT = 200 +export const FORCED_VIRTUALIZATION_ROW_COUNT = 1_500 + +export type VirtualScrollMode = 'tanstack' | 'none' +export type VirtualScrollPreference = VirtualScrollMode | 'auto' + +export function resolveVirtualScrollMode( + requestedMode: VirtualScrollPreference, + instrumentCount: number, +): VirtualScrollMode { + if (instrumentCount >= FORCED_VIRTUALIZATION_ROW_COUNT) return 'tanstack' + if (requestedMode !== 'auto') return requestedMode + return instrumentCount >= DEFAULT_VIRTUALIZATION_ROW_COUNT + ? 'tanstack' + : 'none' +} diff --git a/examples/react/realtime-trading/src/table/trading-table.tsx b/examples/react/realtime-trading/src/table/trading-table.tsx new file mode 100644 index 0000000000..46298f5abd --- /dev/null +++ b/examples/react/realtime-trading/src/table/trading-table.tsx @@ -0,0 +1,588 @@ +import { FlexRender, useTable } from '@tanstack/react-table' +import { useVirtualizer } from '@tanstack/react-virtual' +import { useSelector } from '@tanstack/react-store' +import { useLayoutEffect, useRef } from 'react' +import { useTableBenchmark } from '../benchmark/use-table-benchmark' +import { + useMarketFeedController, + useTradingShellController, + useTradingShellState, +} from '../shell/trading-shell-context' +import { + TradingRow, + readMeasuredRows, + tradingColumns, +} from './table-config/trading-table-config' +import { + handleCellNavigation, + reorderColumnIds, + sortAriaValue, + sortIndicator, +} from './table-interactions' +import { useTradingGridPointer } from './use-trading-grid-pointer' +import { tradingFeatures } from './trading-features' +import { + TRADING_ROW_HEIGHT, + TRADING_ROW_OVERSCAN, + resolveVirtualScrollMode, +} from './trading-row-virtualizer' +import type { VirtualScrollMode } from './trading-row-virtualizer' +import type { + CellSelectionBounds, + CellSelectionState, +} from '@tanstack/react-table' +import type { VirtualItem } from '@tanstack/react-virtual' +import type { MarketQuote } from '../feed/market-data' +import type { CoreTableState } from './table-config/trading-table-config' + +export { + TRADING_COLUMN_COUNT, + rowModelDiagnostics, +} from './table-config/trading-table-config' +export type { + CoreTableState, + RendererMode, +} from './table-config/trading-table-config' +export type { VirtualScrollMode } from './trading-row-virtualizer' + +export function TradingTable() { + const controller = useTradingShellController() + const feed = useMarketFeedController() + const quotes = useSelector(feed.quotes) + const requestedVirtualScrollMode = useTradingShellState( + (state) => state.requestedVirtualScrollMode, + ) + const instrumentCount = useSelector(feed.instrumentCount) + const virtualScrollMode = resolveVirtualScrollMode( + requestedVirtualScrollMode, + instrumentCount, + ) + + useLayoutEffect(() => feed.completeRender()) + useTableBenchmark(controller) + const table = useTradingTable({ quotes }) + const layoutRefs = useTradingTableLayout(table) + + return ( + ({ + sorting: state.sorting, + columnFilters: state.columnFilters, + columnOrder: state.columnOrder, + })} + > + {(coreState) => ( + + )} + + ) +} + +type TradingTableInstance = ReturnType + +interface ColumnDragRuntime { + columnId: string | null + sourceElement: HTMLTableCellElement | null + targetElement: HTMLTableCellElement | null +} + +function clearColumnDrag(runtime: ColumnDragRuntime): void { + runtime.sourceElement?.classList.remove('is-column-dragging') + runtime.targetElement?.classList.remove('is-column-drop-target') + runtime.columnId = null + runtime.sourceElement = null + runtime.targetElement = null +} + +function showColumnDropTarget( + runtime: ColumnDragRuntime, + targetColumnId: string, + targetElement: HTMLTableCellElement | null, +): void { + runtime.targetElement?.classList.remove('is-column-drop-target') + runtime.targetElement = null + if (runtime.columnId === targetColumnId || !targetElement) return + targetElement.classList.add('is-column-drop-target') + runtime.targetElement = targetElement +} + +function useTradingTableLayout(table: TradingTableInstance) { + const scrollRef = useRef(null) + const tableRef = useRef(null) + const fitRuntime = useRef({ manuallyResized: false }) + const tableRuntime = useRef(table) + tableRuntime.current = table + + useLayoutEffect(() => { + const writeColumnSizes = () => { + const currentTable = tableRuntime.current + const tableElement = tableRef.current + if (!tableElement) return + for (const header of currentTable.getFlatHeaders()) { + tableElement.style.setProperty( + `--header-${header.id}-size`, + String(header.getSize()), + ) + tableElement.style.setProperty( + `--col-${header.column.id}-size`, + String(header.column.getSize()), + ) + } + tableElement.style.width = `${currentTable.getTotalSize()}px` + } + + writeColumnSizes() + const sizingSubscription = + tableRuntime.current.atoms.columnSizing.subscribe(writeColumnSizes) + const orderSubscription = + tableRuntime.current.atoms.columnOrder.subscribe(writeColumnSizes) + const fitAvailableWidth = () => { + const currentTable = tableRuntime.current + const scrollElement = scrollRef.current + if (!scrollElement || fitRuntime.current.manuallyResized) return + const currentWidth = currentTable.getTotalSize() + const availableWidth = scrollElement.clientWidth + if (availableWidth <= currentWidth + 1 || currentWidth <= 0) return + + const ratio = availableWidth / currentWidth + currentTable.setColumnSizing( + Object.fromEntries( + currentTable + .getVisibleLeafColumns() + .map((column) => [column.id, column.getSize() * ratio]), + ), + ) + } + const resizeObserver = new ResizeObserver(fitAvailableWidth) + const resizingSubscription = + tableRuntime.current.atoms.columnResizing.subscribe((state) => { + if (state.isResizingColumn !== false) { + fitRuntime.current.manuallyResized = true + } + }) + if (scrollRef.current) resizeObserver.observe(scrollRef.current) + fitAvailableWidth() + + return () => { + sizingSubscription.unsubscribe() + orderSubscription.unsubscribe() + resizingSubscription.unsubscribe() + resizeObserver.disconnect() + } + }, []) + + return { scrollRef, tableRef } +} + +function TradingTableHeader(props: { table: TradingTableInstance }) { + const dragRuntime = useRef({ + columnId: null, + sourceElement: null, + targetElement: null, + }) + + return ( + ({ + columnOrder: state.columnOrder, + sorting: state.sorting, + })} + > + {() => ( + + {props.table.getHeaderGroups().map((headerGroup) => ( + + {headerGroup.headers.map((header) => { + const isLeaf = header.subHeaders.length === 0 + const sorted = header.column.getIsSorted() + return ( + + ) + })} + + ))} + + )} + + ) +} + +function useTradingTable(props: { quotes: Array }) { + return useTable( + { + key: 'react-realtime-trading', + features: tradingFeatures, + columns: tradingColumns, + data: props.quotes, + getRowId: (row) => row.id, + columnResizeMode: 'onChange', + defaultColumn: { minSize: 56, maxSize: 800 }, + autoResetCellSelection: false, + }, + () => null, + ) +} + +function TradingTableViewport(props: { + table: ReturnType + rows: ReturnType['getRowModel']>['rows'] + sourceRowCount: number + layoutRefs: ReturnType + virtualScrollMode: VirtualScrollMode + reportRenderedRowCount: (count: number) => void +}) { + const rowVirtualizer = useVirtualizer({ + count: props.rows.length, + estimateSize: () => TRADING_ROW_HEIGHT, + getScrollElement: () => props.layoutRefs.scrollRef.current, + getItemKey: (index) => props.rows[index]?.id ?? index, + overscan: TRADING_ROW_OVERSCAN, + enabled: props.virtualScrollMode === 'tanstack', + }) + const virtualRows = rowVirtualizer.getVirtualItems() + const renderedRowCount = + props.virtualScrollMode === 'tanstack' + ? virtualRows.length + : props.rows.length + const visibleRange = readVisibleRange( + rowVirtualizer.range, + props.rows.length, + props.virtualScrollMode, + ) + + useLayoutEffect(() => { + props.reportRenderedRowCount(renderedRowCount) + }, [props.reportRenderedRowCount, renderedRowCount]) + + return ( + <> +
handleCellNavigation(props.table, event)} + > +
@@ -159,7 +159,7 @@ function App() {
@@ -170,7 +170,7 @@ function App() { key={header.id} className="th" style={{ - width: header.getSize(), + width: `${header.getSize()}px`, }} > {header.isPlaceholder ? null : ( @@ -190,7 +190,7 @@ function App() { key={cell.id} className="td" style={{ - width: cell.column.getSize(), + width: `${cell.column.getSize()}px`, }} > @@ -207,7 +207,7 @@ function App() {
@@ -225,8 +225,8 @@ function App() { className="th" style={{ position: 'absolute', - left: header.getStart(), - width: header.getSize(), + left: `${header.getStart()}px`, + width: `${header.getSize()}px`, }} > {header.isPlaceholder ? null : ( @@ -253,8 +253,8 @@ function App() { className="td" style={{ position: 'absolute', - left: cell.column.getStart(), - width: cell.column.getSize(), + left: `${cell.column.getStart()}px`, + width: `${cell.column.getSize()}px`, }} > diff --git a/examples/preact/column-visibility/package.json b/examples/preact/column-visibility/package.json index eee14c9bdb..1cddf1b7fc 100644 --- a/examples/preact/column-visibility/package.json +++ b/examples/preact/column-visibility/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/composable-tables/package.json b/examples/preact/composable-tables/package.json index 29ee9848fc..40fd6a35df 100644 --- a/examples/preact/composable-tables/package.json +++ b/examples/preact/composable-tables/package.json @@ -12,16 +12,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-devtools": "^0.10.10", - "@tanstack/preact-store": "^0.13.2", - "@tanstack/preact-table": "^9.1.2", - "@tanstack/preact-table-devtools": "^9.2.0", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-devtools": "^0.10.15", + "@tanstack/preact-store": "^0.13.5", + "@tanstack/preact-table": "^9.3.1", + "@tanstack/preact-table-devtools": "^9.3.2", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/custom-plugin/package.json b/examples/preact/custom-plugin/package.json index 116fffca98..d468e290be 100644 --- a/examples/preact/custom-plugin/package.json +++ b/examples/preact/custom-plugin/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/expanding/package.json b/examples/preact/expanding/package.json index 3535a5c1ef..f9b39d554a 100644 --- a/examples/preact/expanding/package.json +++ b/examples/preact/expanding/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/expanding/src/main.tsx b/examples/preact/expanding/src/main.tsx index 945b9ecfdd..b161a92cc8 100644 --- a/examples/preact/expanding/src/main.tsx +++ b/examples/preact/expanding/src/main.tsx @@ -20,7 +20,7 @@ import { useTable, } from '@tanstack/preact-table' import { makeData } from './makeData' -import type { JSX } from 'preact' +import type { InputHTMLAttributes } from 'preact' import type { Person } from './makeData' import type { Column, Table } from '@tanstack/preact-table' import './index.css' @@ -354,7 +354,10 @@ function IndeterminateCheckbox({ indeterminate?: boolean checked?: boolean onChange?: (event: Event) => void -} & Omit, 'checked' | 'onChange'>) { +} & Omit< + InputHTMLAttributes, + 'checked' | 'onChange' | 'type' | 'role' | 'list' +>) { const ref = useRef(null) useEffect(() => { diff --git a/examples/preact/filters-faceted-bucketed/package.json b/examples/preact/filters-faceted-bucketed/package.json index c58a249f97..c598abe472 100644 --- a/examples/preact/filters-faceted-bucketed/package.json +++ b/examples/preact/filters-faceted-bucketed/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/filters-faceted/package.json b/examples/preact/filters-faceted/package.json index 1fffb457b3..c22412eae8 100644 --- a/examples/preact/filters-faceted/package.json +++ b/examples/preact/filters-faceted/package.json @@ -12,15 +12,16 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/preact-pacer": "^0.23.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/preact-pacer": "^0.24.2", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/filters-fuzzy/package.json b/examples/preact/filters-fuzzy/package.json index 12691c0514..ed032ffb81 100644 --- a/examples/preact/filters-fuzzy/package.json +++ b/examples/preact/filters-fuzzy/package.json @@ -12,15 +12,16 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/preact-pacer": "^0.23.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/preact-pacer": "^0.24.2", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/filters/package.json b/examples/preact/filters/package.json index e5bf2e5055..81df93534f 100644 --- a/examples/preact/filters/package.json +++ b/examples/preact/filters/package.json @@ -12,15 +12,16 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/preact-pacer": "^0.23.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/preact-pacer": "^0.24.2", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/grouped-aggregation/package.json b/examples/preact/grouped-aggregation/package.json index 6b7269dab3..b35382b264 100644 --- a/examples/preact/grouped-aggregation/package.json +++ b/examples/preact/grouped-aggregation/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/grouping/package.json b/examples/preact/grouping/package.json index 20f9e32eb7..7645a0a01f 100644 --- a/examples/preact/grouping/package.json +++ b/examples/preact/grouping/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/header-groups/package.json b/examples/preact/header-groups/package.json index 7bc4852c13..ec8444f4f8 100644 --- a/examples/preact/header-groups/package.json +++ b/examples/preact/header-groups/package.json @@ -12,13 +12,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/kitchen-sink/package.json b/examples/preact/kitchen-sink/package.json index 38badd6386..29c8614b6c 100644 --- a/examples/preact/kitchen-sink/package.json +++ b/examples/preact/kitchen-sink/package.json @@ -12,16 +12,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/preact-devtools": "^0.10.10", - "@tanstack/preact-table": "^9.1.2", - "@tanstack/preact-table-devtools": "^9.2.0", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/preact-devtools": "^0.10.15", + "@tanstack/preact-table": "^9.3.1", + "@tanstack/preact-table-devtools": "^9.3.2", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/kitchen-sink/src/main.tsx b/examples/preact/kitchen-sink/src/main.tsx index cf5f84486e..e6f4e46a7a 100644 --- a/examples/preact/kitchen-sink/src/main.tsx +++ b/examples/preact/kitchen-sink/src/main.tsx @@ -30,7 +30,7 @@ import { } from '@tanstack/preact-table-devtools' import { compareItems, rankItem } from '@tanstack/match-sorter-utils' import { makeData } from './makeData' -import type { JSX } from 'preact' +import type { CSSProperties, ComponentProps, InputHTMLAttributes } from 'preact' import type { RankingInfo } from '@tanstack/match-sorter-utils' import type { Person } from './makeData' import type { @@ -119,7 +119,7 @@ const features = tableFeatures({ const getCommonPinningStyles = ( column: Column, -): JSX.CSSProperties => { +): CSSProperties => { const isPinned = column.getIsPinned() const isLastLeftPinnedColumn = isPinned === 'start' && column.getIsLastColumn('start') @@ -146,7 +146,10 @@ function IndeterminateCheckbox({ indeterminate, className = '', ...rest -}: { indeterminate?: boolean } & JSX.InputHTMLAttributes) { +}: { indeterminate?: boolean } & Omit< + InputHTMLAttributes, + 'type' | 'role' | 'list' +>) { const ref = useRef(null) useEffect(() => { @@ -158,6 +161,11 @@ function IndeterminateCheckbox({ return } +// Keeps Preact's per-`type` prop union intact. +type DistributiveOmit = T extends unknown + ? Omit + : never + function DebouncedInput({ value: initialValue, onChange, @@ -167,7 +175,7 @@ function DebouncedInput({ value: string | number onChange: (value: string | number) => void debounce?: number -} & Omit, 'onChange' | 'value'>) { +} & DistributiveOmit, 'onChange' | 'value'>) { const [value, setValue] = useState(initialValue) const timeoutRef = useRef | undefined>( undefined, @@ -283,7 +291,7 @@ function TableHeader({ table: PreactTable }) { const column = header.column - const style: JSX.CSSProperties = { + const style: CSSProperties = { ...getCommonPinningStyles(column), whiteSpace: 'nowrap', width: `calc(var(--header-${header.id}-size) * 1px)`, @@ -683,7 +691,9 @@ function App() {
- +
{table.getHeaderGroups().map((headerGroup) => ( diff --git a/examples/preact/pagination/package.json b/examples/preact/pagination/package.json index c83962fdb3..c223992aa3 100644 --- a/examples/preact/pagination/package.json +++ b/examples/preact/pagination/package.json @@ -12,14 +12,15 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/preact-store": "^0.13.2", - "@tanstack/preact-table": "^9.1.2", - "preact": "^10.29.8" + "@faker-js/faker": "^10.6.0", + "@tanstack/preact-store": "^0.13.5", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" }, "devDependencies": { "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/preact/realtime-trading/README.md b/examples/preact/realtime-trading/README.md new file mode 100644 index 0000000000..349dd32476 --- /dev/null +++ b/examples/preact/realtime-trading/README.md @@ -0,0 +1,174 @@ +# Preact realtime trading benchmark + +This standalone example exercises the current TanStack Preact Table adapter +with an immutable high-frequency feed, table interactions, custom components, +virtual rows, and browser diagnostics. It is a rendering stress lab rather than +an exchange or network-latency simulation. + +## Run and verify + +```bash +pnpm --dir examples/preact/realtime-trading dev +``` + +Open `http://localhost:7777`. + +```bash +pnpm --dir examples/preact/realtime-trading test:types +pnpm --dir examples/preact/realtime-trading lint +pnpm --dir examples/preact/realtime-trading build +pnpm --dir examples/preact/realtime-trading test:e2e +``` + +Use the production build for measurements; development checks inflate the +absolute cost. + +## Structure and ownership + +| Path | Responsibility | +| ------------------------- | ------------------------------------------------------------------------------------------------- | +| `src/feed/` | Market types, instruments, immutable update helpers, config, controller, and controller hook. | +| `src/feed/worker/` | Worker protocol, deterministic market engine, and module worker. | +| `src/benchmark/` | Feed/render timing, DOM/long-frame observers, row-model and component diagnostics. | +| `src/shell/` | TanStack Store contexts, viewport shell, metrics, controls, selected instrument, and diagnostics. | +| `src/table/table-config/` | Grouped columns, row/cell components, and render counters. | +| `src/table/` | Preact Table instance, subscriptions, interactions, column layout, and Virtual Core hook. | +| `src/App.tsx` | Creates the controllers and composes providers, shell, and table. | + +Feed state and benchmark state are different controllers. The feed does not +depend on the monitor; the benchmark subscribes to feed lifecycle callbacks. +TanStack Preact Store contexts pass stable controller objects, while components +subscribe to direct feed atoms. `quotes` has an independent high-frequency atom; +status, instrument count, workload, delivery, and chart settings each have their +own atom and cannot notify the table data boundary. Renderer mode and selected +symbol are also separate atoms so their updates do not invalidate unrelated +shell content. Benchmark metrics remain an aggregate snapshot store. + +## Feed and worker pipeline + +The initial setup is 100 instruments, 10K generated samples/s, 20 ms worker +delivery, enabled intraday charts, and 16 ms chart sampling. + +The module worker keeps mutable quote state private. A deterministic PRNG and a +16 ms budget loop generate samples; a `Map` coalesces repeated updates for the +same row. A separate publication timer sends the latest unique row updates at +the configured interval. The main thread creates a new outer array and new +objects only for changed rows, preserving every untouched row reference. +History arrays are replaced only when their sampling interval elapses. Session +IDs reject stale messages after reset or row-count changes. + +- **Synthetic quote workload** is worker-side generated samples per second. It + is not pointer events, renders, or messages. +- **Worker delivery interval** controls coalesced `postMessage` cadence; 20 ms + targets about 50 messages/s. +- **Changed rows** counts row snapshots applied on the main thread. Rows are + deduplicated within one snapshot, but the same row can be counted again in a + later snapshot, so it is throughput rather than a global distinct-row count. +- **Message samples** shows how much generated work the latest message contains. + +The 25K burst deliberately creates and flushes one expensive batch. The worker +mimics an external streaming producer, but network transport is not measured. + +## Table and interaction architecture + +The 14 leaf columns are grouped into Instrument, Price & Change, Order Book, +Session, and Chart. The example supports core sorting/filtering, on-change +resizing, double-click size reset, drag column ordering, row selection, drag +cell ranges, keyboard navigation, and custom Price/Move/Percent/Sparkline cells. +Stable instrument IDs are supplied through `getRowId`. + +`table.Subscribe` boundaries isolate table state, resize handles, and row +selection. `TradingGridPointerController` is allocated once for the body and +receives delegated mouse/pointer events. It resolves cells from +`event.composedPath()` and data attributes, eliminating listeners per cell. +Row hover is CSS-only. + +Column widths are table-level CSS custom properties updated only when sizing or +ordering changes. Initial sizes expand to the viewport through a +`ResizeObserver`; manual resizing turns off further auto-fit. The optional move +component A/B mode intentionally destroys/recreates component types and should +not be treated as the normal baseline. + +## Virtualization + +The preference is `auto`, `tanstack`, or `none`: + +- below 200 rows, `auto` means Full DOM, while Virtual remains selectable; +- 200–1,499 rows default to TanStack Virtual but can be switched to Full DOM; +- 1,500 or more rows force Virtual and lock the control. + +Because this adapter consumes `@tanstack/virtual-core` directly, the local +`useVirtualizer` hook owns the Virtualizer instance and synchronizes its change +notifications with Preact. It uses 32 px rows, 10-row overscan, row IDs as item +keys, transformed rows, and a spacer body. The footer reads the virtualizer +range. Both modes use `content-visibility: auto`; that browser hint does not +avoid mounting every component in Full DOM mode. + +## Performance decisions + +- worker-side generation and pre-message coalescing; +- structural sharing for unchanged rows and histories; +- stable table/virtualizer keys; +- direct Preact Store atom subscriptions, including an isolated quote atom; +- table/row/resize subscription boundaries; +- one delegated grid interaction controller; +- CSS variables for column sizing; +- opt-in component churn and independently sampled sparklines; +- virtual mounting for large row counts; +- benchmark publication slower than the data stream. + +The immutable outer array must change when a batch is applied. Stable inner +references reduce renderer work, but sorting/filtering may still require a core +row-model pass when data changes. + +## Diagnostics and interpretation + +The compact **Live health** block lives in the configurator sidebar and shows +four cross-framework signals: + +- **Frame rate (est.)** counts `requestAnimationFrame` callbacks over a rolling + one-second window. It is capped by display refresh and is not a measurement of + GPU-presented frames. +- **Average commit latency** is a rolling three-second average from the first + pending market mutation to the table's DOM commit. It includes scheduling, + Preact work, and the commit; it is not component render duration. +- **Long frames** comes from the Long Animation Frames API and is cumulative + since reset, with the worst observed duration when supported. +- **Throughput** pairs changed rows/s with applied snapshots/s; changed rows are + deduplicated per snapshot, not across the complete reporting window. + +Detailed diagnostics retain worker samples, messages, state applies, table DOM +commits, a 10-second commit-latency p95/max, cumulative slow commits, mounted +hosts, component creation/destruction, cell callbacks by column, component +executions by type, DOM `MutationRecord` rate, row-model timing, and heap data +where supported. + +The in-memory latency and row-model aggregates inspect every call, while the +Performance timeline writes only one User Timing measure per 20 calls to keep +instrumentation from dominating a hot run. The `MutationObserver` watches the +table body for text/children and only `class`/`style` attribute changes. Its +rate counts browser records rather than DOM operations: records can be +coalesced, equivalent UIs can produce different patterns, and creating records +has real overhead. Heap is Chrome-only `usedJSHeapSize`, is sensitive to +garbage-collection timing, and should be read as a trend rather than proof of a +leak. + +The monitor itself adds one lightweight `requestAnimationFrame` callback and +publishes the sidebar snapshot every 500 ms. That subscription is independent +from the quote atom and table data boundary, but it remains instrumentation +overhead and must stay enabled on both sides of an A/B comparison. + +Callback execution does not imply a DOM mutation, and temporary heap growth is +not by itself a leak. Compare identical production configurations and confirm +retention with post-GC heap snapshots. Use browser Performance tooling and +Preact DevTools for call stacks alongside the in-app counters. + +## Standalone policy + +All feed, worker, instrument, shell, style, and benchmark files are copied into +this directory intentionally. The example can run alone or be moved to +StackBlitz without a shared example package, so common implementation and README +sections are duplicated across adapters by design. + +The workspace resolves the pinned `@tanstack/preact-table` dependency to the +repository package while keeping the example manifest release-like. diff --git a/examples/preact/realtime-trading/index.html b/examples/preact/realtime-trading/index.html new file mode 100644 index 0000000000..849dbe8b48 --- /dev/null +++ b/examples/preact/realtime-trading/index.html @@ -0,0 +1,17 @@ + + + + + + + + Preact Real-time Trading FlexRender Lab + + +
+ + + diff --git a/examples/preact/realtime-trading/package.json b/examples/preact/realtime-trading/package.json new file mode 100644 index 0000000000..5b26c40886 --- /dev/null +++ b/examples/preact/realtime-trading/package.json @@ -0,0 +1,32 @@ +{ + "name": "tanstack-preact-table-example-realtime-trading", + "private": true, + "type": "module", + "scripts": { + "start": "vite", + "dev": "vite", + "build": "vite build", + "serve": "vite preview", + "lint": "eslint ./src", + "test:types": "tsc --noEmit", + "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" + }, + "nx": { + "targets": { + "test:e2e": { + "parallelism": false + } + } + }, + "dependencies": { + "@tanstack/preact-store": "^0.13.5", + "@tanstack/preact-table": "^9.3.1", + "preact": "^11.2.0" + }, + "devDependencies": { + "@preact/preset-vite": "^2.10.6", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "typescript": "6.0.3", + "vite": "^8.3.8" + } +} diff --git a/examples/preact/realtime-trading/src/App.tsx b/examples/preact/realtime-trading/src/App.tsx new file mode 100644 index 0000000000..3b702068d6 --- /dev/null +++ b/examples/preact/realtime-trading/src/App.tsx @@ -0,0 +1,21 @@ +import { useMarketFeedController } from './feed/use-market-feed-controller' +import { useTradingBenchmarkController } from './benchmark/use-trading-benchmark-controller' +import { TradingShell } from './shell/TradingShell' +import { TradingShellProvider } from './shell/trading-shell-context' +import { TradingTable } from './table/trading-table' + +export function App() { + const feed = useMarketFeedController() + const controller = useTradingBenchmarkController(feed) + return ( + + + + + + ) +} + +function TradingTableOutlet() { + return +} diff --git a/examples/preact/realtime-trading/src/benchmark/benchmark-monitor.ts b/examples/preact/realtime-trading/src/benchmark/benchmark-monitor.ts new file mode 100644 index 0000000000..bc4444714a --- /dev/null +++ b/examples/preact/realtime-trading/src/benchmark/benchmark-monitor.ts @@ -0,0 +1,453 @@ +import { + quoteCellLifecycle, + quoteRenderDiagnostics, +} from '../table/table-config/quote-cells' +import { rowModelDiagnostics } from '../table/trading-table' + +export interface NamedInvocationRate { + name: string + callsPerSecond: number +} + +interface TimedLatencySample { + recordedAt: number + duration: number +} + +const averageLatencyWindowMs = 3_000 +const percentileLatencyWindowMs = 10_000 +const frameRateWindowMs = 1_000 + +export interface FeedMetrics { + actualTicksPerSecond: number + rowUpdatesPerSecond: number + workerMessagesPerSecond: number + stateApplicationsPerSecond: number + supersededUpdatesPerSecond: number + totalTicks: number + estimatedFrameRate: number + tableCommitsPerSecond: number + lastBatchSize: number + averageCommitLatencyMs: number + p95CommitLatencyMs: number + maxCommitLatencyMs: number + slowCommits: number + longAnimationFrames: number + worstLongAnimationFrameMs: number + heapMb: number | null + componentsCreated: number + componentsDestroyed: number + workerMessages: number + lastUpdateCount: number + cellRendererCallsPerSecond: number + componentRenderCallsPerSecond: number + cellRendererRates: ReadonlyArray + componentRenderRates: ReadonlyArray + domMutationsPerSecond: number + rowModelCallsPerSecond: number + rowModelAverageMs: number + rowModelMaxMs: number + visibleRows: number +} + +export const initialMetrics: FeedMetrics = { + actualTicksPerSecond: 0, + rowUpdatesPerSecond: 0, + workerMessagesPerSecond: 0, + stateApplicationsPerSecond: 0, + supersededUpdatesPerSecond: 0, + totalTicks: 0, + estimatedFrameRate: 0, + tableCommitsPerSecond: 0, + lastBatchSize: 0, + averageCommitLatencyMs: 0, + p95CommitLatencyMs: 0, + maxCommitLatencyMs: 0, + slowCommits: 0, + longAnimationFrames: 0, + worstLongAnimationFrameMs: 0, + heapMb: null, + componentsCreated: 0, + componentsDestroyed: 0, + workerMessages: 0, + lastUpdateCount: 0, + cellRendererCallsPerSecond: 0, + componentRenderCallsPerSecond: 0, + cellRendererRates: [], + componentRenderRates: [], + domMutationsPerSecond: 0, + rowModelCallsPerSecond: 0, + rowModelAverageMs: 0, + rowModelMaxMs: 0, + visibleRows: 0, +} + +const userTiming = { + entryCount: 0, + measureCallsByName: {} as Record, +} + +export function recordMeasure( + name: string, + start: number, + end: number, + detail: Record, +): void { + const measureCall = (userTiming.measureCallsByName[name] ?? 0) + 1 + userTiming.measureCallsByName[name] = measureCall + if ((measureCall - 1) % 20 !== 0) return + + try { + performance.measure(name, { start, end, detail }) + userTiming.entryCount++ + if (userTiming.entryCount % 1_000 === 0) { + performance.clearMeasures('market-update-to-dom-commit') + } + } catch { + // User Timing Level 3 options are not implemented in every browser. + } +} + +export function markBenchmarkAction( + name: string, + detail: Record = {}, +): void { + try { + performance.mark(`benchmark:${name}`, { detail }) + userTiming.entryCount++ + if (userTiming.entryCount % 1_000 === 0) { + performance.clearMarks() + } + } catch { + // User Timing Level 3 detail is not implemented in every browser. + } +} + +export class BenchmarkMonitor { + readonly #runtime = { + sessionStartedAt: performance.now(), + sampleStartedAt: performance.now(), + pendingCommitStartedAt: null as number | null, + commitLatencySamples: [] as Array, + slowCommitCount: 0, + totalTicks: 0, + ticksInSample: 0, + rowUpdatesInSample: 0, + workerMessagesInSample: 0, + stateApplicationsInSample: 0, + supersededUpdatesInSample: 0, + lastBatchSize: 0, + lastUpdateCount: 0, + workerMessages: 0, + frameTrackingStartedAt: performance.now(), + frameTimestamps: [] as Array, + tableCommitsInSample: 0, + longAnimationFrameCount: 0, + worstLongAnimationFrameMs: 0, + previousCellRendererCalls: 0, + previousComponentRenderCalls: 0, + previousCellRendererCallsByName: { + ...quoteRenderDiagnostics.cellRendererCallsByName, + }, + previousComponentRenderCallsByName: { + ...quoteRenderDiagnostics.componentRenderCallsByName, + }, + domMutationsInSample: 0, + previousRowModelCalls: 0, + previousRowModelDuration: 0, + } + + markCommitPending(): void { + this.#runtime.pendingCommitStartedAt ??= performance.now() + } + + recordDomCommit(): void { + const runtime = this.#runtime + if (runtime.pendingCommitStartedAt !== null) { + const commitEndedAt = performance.now() + const duration = commitEndedAt - runtime.pendingCommitStartedAt + runtime.commitLatencySamples.push({ + recordedAt: commitEndedAt, + duration, + }) + if (duration > 16.7) runtime.slowCommitCount++ + recordMeasure( + 'market-update-to-dom-commit', + runtime.pendingCommitStartedAt, + commitEndedAt, + {}, + ) + runtime.pendingCommitStartedAt = null + runtime.tableCommitsInSample++ + } + } + + recordWorkerMessage(): void { + this.#runtime.workerMessages++ + this.#runtime.workerMessagesInSample++ + } + + recordBatch( + tickCount: number, + updateCount: number, + supersededUpdateCount: number, + ): void { + const runtime = this.#runtime + runtime.lastBatchSize = tickCount + runtime.lastUpdateCount = updateCount + runtime.ticksInSample += tickCount + runtime.totalTicks += tickCount + runtime.rowUpdatesInSample += updateCount + runtime.stateApplicationsInSample++ + runtime.supersededUpdatesInSample += supersededUpdateCount + } + + recordAnimationFrame(now: number): void { + const timestamps = this.#runtime.frameTimestamps + timestamps.push(now) + pruneFrameTimestamps(timestamps, now) + } + + recordLongAnimationFrame(duration: number, startTime: number): void { + const runtime = this.#runtime + if (startTime < runtime.sessionStartedAt) return + + runtime.longAnimationFrameCount++ + runtime.worstLongAnimationFrameMs = Math.max( + runtime.worstLongAnimationFrameMs, + duration, + ) + } + + recordDomMutations(count: number): void { + this.#runtime.domMutationsInSample += count + } + + resetDomMutations(): void { + this.#runtime.domMutationsInSample = 0 + } + + shouldPublish(now: number): boolean { + return now - this.#runtime.sampleStartedAt >= 500 + } + + publish(now: number): FeedMetrics { + const runtime = this.#runtime + const sampleDuration = now - runtime.sampleStartedAt + pruneLatencySamples(runtime.commitLatencySamples, now) + pruneFrameTimestamps(runtime.frameTimestamps, now) + const averageCommitLatencySamples = runtime.commitLatencySamples + .filter((sample) => sample.recordedAt >= now - averageLatencyWindowMs) + .map((sample) => sample.duration) + const percentileCommitLatencySamples = runtime.commitLatencySamples.map( + (sample) => sample.duration, + ) + const sortedCommitLatencySamples = [...percentileCommitLatencySamples].sort( + (left, right) => left - right, + ) + const rowModelCalls = + rowModelDiagnostics.calls - runtime.previousRowModelCalls + const rowModelDuration = + rowModelDiagnostics.totalDurationMs - runtime.previousRowModelDuration + const cellRendererCalls = + quoteRenderDiagnostics.cellRendererCalls - + runtime.previousCellRendererCalls + const componentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls - + runtime.previousComponentRenderCalls + const cellRendererRates = calculateInvocationRates( + quoteRenderDiagnostics.cellRendererCallsByName, + runtime.previousCellRendererCallsByName, + sampleDuration, + ) + const componentRenderRates = calculateInvocationRates( + quoteRenderDiagnostics.componentRenderCallsByName, + runtime.previousComponentRenderCallsByName, + sampleDuration, + ) + const averageCommitLatencyMs = + averageCommitLatencySamples.length === 0 + ? 0 + : averageCommitLatencySamples.reduce((sum, value) => sum + value, 0) / + averageCommitLatencySamples.length + const p95Index = Math.max( + 0, + Math.ceil(sortedCommitLatencySamples.length * 0.95) - 1, + ) + const metrics: FeedMetrics = { + actualTicksPerSecond: + sampleDuration === 0 + ? 0 + : (runtime.ticksInSample / sampleDuration) * 1_000, + rowUpdatesPerSecond: + (runtime.rowUpdatesInSample / sampleDuration) * 1_000, + workerMessagesPerSecond: + (runtime.workerMessagesInSample / sampleDuration) * 1_000, + stateApplicationsPerSecond: + (runtime.stateApplicationsInSample / sampleDuration) * 1_000, + supersededUpdatesPerSecond: + (runtime.supersededUpdatesInSample / sampleDuration) * 1_000, + totalTicks: runtime.totalTicks, + estimatedFrameRate: calculateFrameRate( + runtime.frameTimestamps, + runtime.frameTrackingStartedAt, + now, + ), + tableCommitsPerSecond: + (runtime.tableCommitsInSample / sampleDuration) * 1_000, + lastBatchSize: runtime.lastBatchSize, + averageCommitLatencyMs, + p95CommitLatencyMs: sortedCommitLatencySamples[p95Index] ?? 0, + maxCommitLatencyMs: sortedCommitLatencySamples.at(-1) ?? 0, + slowCommits: runtime.slowCommitCount, + longAnimationFrames: runtime.longAnimationFrameCount, + worstLongAnimationFrameMs: runtime.worstLongAnimationFrameMs, + heapMb: readHeapSizeMb(), + componentsCreated: quoteCellLifecycle.created, + componentsDestroyed: quoteCellLifecycle.destroyed, + workerMessages: runtime.workerMessages, + lastUpdateCount: runtime.lastUpdateCount, + cellRendererCallsPerSecond: (cellRendererCalls / sampleDuration) * 1_000, + componentRenderCallsPerSecond: + (componentRenderCalls / sampleDuration) * 1_000, + cellRendererRates, + componentRenderRates, + domMutationsPerSecond: + (runtime.domMutationsInSample / sampleDuration) * 1_000, + rowModelCallsPerSecond: (rowModelCalls / sampleDuration) * 1_000, + rowModelAverageMs: + rowModelCalls === 0 ? 0 : rowModelDuration / rowModelCalls, + rowModelMaxMs: rowModelDiagnostics.maxDurationMs, + visibleRows: rowModelDiagnostics.lastRowCount, + } + + runtime.sampleStartedAt = now + runtime.previousCellRendererCalls = quoteRenderDiagnostics.cellRendererCalls + runtime.previousComponentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls + runtime.previousCellRendererCallsByName = { + ...quoteRenderDiagnostics.cellRendererCallsByName, + } + runtime.previousComponentRenderCallsByName = { + ...quoteRenderDiagnostics.componentRenderCallsByName, + } + runtime.domMutationsInSample = 0 + runtime.previousRowModelCalls = rowModelDiagnostics.calls + runtime.previousRowModelDuration = rowModelDiagnostics.totalDurationMs + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.tableCommitsInSample = 0 + return metrics + } + + reset(): void { + const runtime = this.#runtime + runtime.sessionStartedAt = performance.now() + runtime.sampleStartedAt = runtime.sessionStartedAt + runtime.pendingCommitStartedAt = null + runtime.commitLatencySamples = [] + runtime.slowCommitCount = 0 + runtime.totalTicks = 0 + runtime.ticksInSample = 0 + runtime.rowUpdatesInSample = 0 + runtime.workerMessagesInSample = 0 + runtime.stateApplicationsInSample = 0 + runtime.supersededUpdatesInSample = 0 + runtime.lastBatchSize = 0 + runtime.lastUpdateCount = 0 + runtime.workerMessages = 0 + runtime.frameTrackingStartedAt = runtime.sampleStartedAt + runtime.frameTimestamps = [] + runtime.tableCommitsInSample = 0 + runtime.longAnimationFrameCount = 0 + runtime.worstLongAnimationFrameMs = 0 + runtime.previousCellRendererCalls = quoteRenderDiagnostics.cellRendererCalls + runtime.previousComponentRenderCalls = + quoteRenderDiagnostics.componentRenderCalls + runtime.previousCellRendererCallsByName = { + ...quoteRenderDiagnostics.cellRendererCallsByName, + } + runtime.previousComponentRenderCallsByName = { + ...quoteRenderDiagnostics.componentRenderCallsByName, + } + runtime.domMutationsInSample = 0 + runtime.previousRowModelCalls = rowModelDiagnostics.calls + runtime.previousRowModelDuration = rowModelDiagnostics.totalDurationMs + rowModelDiagnostics.maxDurationMs = 0 + } +} + +export const longAnimationFramesSupported = + PerformanceObserver.supportedEntryTypes.includes('long-animation-frame') + +function readHeapSizeMb(): number | null { + const memory = ( + performance as Performance & { + memory?: { usedJSHeapSize: number } + } + ).memory + return memory ? memory.usedJSHeapSize / 1_048_576 : null +} + +function calculateInvocationRates( + current: Record, + previous: Record, + sampleDuration: number, +): ReadonlyArray { + return Object.entries(current).map(([name, calls]) => ({ + name, + callsPerSecond: + sampleDuration === 0 + ? 0 + : ((calls - (previous[name] ?? 0)) / sampleDuration) * 1_000, + })) +} + +function pruneLatencySamples( + samples: Array, + now: number, +): void { + const cutoff = now - percentileLatencyWindowMs + const firstRetainedIndex = samples.findIndex( + (sample) => sample.recordedAt >= cutoff, + ) + if (firstRetainedIndex > 0) samples.splice(0, firstRetainedIndex) + else if (firstRetainedIndex === -1) samples.length = 0 +} + +function pruneFrameTimestamps(timestamps: Array, now: number): void { + const cutoff = now - frameRateWindowMs + const firstRetainedIndex = timestamps.findIndex( + (timestamp) => timestamp >= cutoff, + ) + if (firstRetainedIndex > 0) timestamps.splice(0, firstRetainedIndex) + else if (firstRetainedIndex === -1) timestamps.length = 0 +} + +function calculateFrameRate( + timestamps: ReadonlyArray, + trackingStartedAt: number, + now: number, +): number { + const observedWindowMs = Math.min( + frameRateWindowMs, + Math.max(1, now - trackingStartedAt), + ) + return (timestamps.length / observedWindowMs) * 1_000 +} + +export function exposeTradingBenchmarkSnapshot( + metrics: FeedMetrics, + extras: { mountedCells: number; liveComponents: number }, +): void { + Object.assign(globalThis, { + __TANSTACK_TRADING_BENCHMARK__: { + capturedAt: performance.now(), + metrics, + ...extras, + }, + }) +} diff --git a/examples/preact/realtime-trading/src/benchmark/trading-benchmark-controller.ts b/examples/preact/realtime-trading/src/benchmark/trading-benchmark-controller.ts new file mode 100644 index 0000000000..ec092c4230 --- /dev/null +++ b/examples/preact/realtime-trading/src/benchmark/trading-benchmark-controller.ts @@ -0,0 +1,145 @@ +import { batch, createAtom, createStore } from '@tanstack/preact-store' +import { TRADING_COLUMN_COUNT } from '../table/trading-table' +import { + BenchmarkMonitor, + exposeTradingBenchmarkSnapshot, + initialMetrics, + longAnimationFramesSupported, +} from './benchmark-monitor' +import type { FeedMetrics } from './benchmark-monitor' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { RendererMode } from '../table/trading-table' + +export interface TradingBenchmarkState { + metrics: FeedMetrics + mountedCells: number + liveComponents: number + longAnimationFramesSupported: boolean +} + +export interface TradingBenchmarkActions { + resetViewState: () => void + setRendererMode: (mode: RendererMode) => void + setRenderedRowCount: (count: number) => void + selectSymbol: (symbol: string | null) => void + resetMarket: () => void +} + +const initialState: TradingBenchmarkState = { + metrics: initialMetrics, + mountedCells: 0, + liveComponents: 0, + longAnimationFramesSupported, +} + +export class TradingBenchmarkController { + readonly store = createStore(initialState) + readonly renderAtoms = { + selectedSymbol: createAtom(null), + rendererMode: createAtom('stable'), + } + readonly monitor = new BenchmarkMonitor() + readonly feed: MarketFeedController + readonly actions: TradingBenchmarkActions + + readonly #runtime = { + animationFrameId: 0, + longAnimationFrameObserver: null as PerformanceObserver | null, + stopObservingFeed: null as (() => void) | null, + } + + constructor(feed: MarketFeedController) { + this.feed = feed + this.actions = { + resetViewState: () => { + this.renderAtoms.selectedSymbol.set(null) + }, + setRendererMode: (mode) => { + this.renderAtoms.rendererMode.set(mode) + }, + setRenderedRowCount: (count) => { + const mountedCells = count * TRADING_COLUMN_COUNT + if (mountedCells !== this.store.get().mountedCells) { + this.#patch({ mountedCells }) + } + }, + selectSymbol: (symbol) => { + this.renderAtoms.selectedSymbol.set(symbol) + }, + resetMarket: () => { + batch(() => { + this.monitor.reset() + this.store.setState((state) => ({ + ...state, + metrics: { ...initialMetrics }, + mountedCells: 0, + liveComponents: 0, + })) + this.renderAtoms.selectedSymbol.set(null) + this.feed.actions.reset() + }) + }, + } + } + + start(): () => void { + const longAnimationFrameObserver = longAnimationFramesSupported + ? new PerformanceObserver((entries) => { + for (const entry of entries.getEntries()) { + this.monitor.recordLongAnimationFrame( + entry.duration, + entry.startTime, + ) + } + }) + : null + + this.#runtime.longAnimationFrameObserver = longAnimationFrameObserver + this.#runtime.stopObservingFeed = this.feed.observe({ + messageReceived: () => this.monitor.recordWorkerMessage(), + mutationStarted: () => this.monitor.markCommitPending(), + batchApplied: ({ tickCount, updateCount, supersededUpdateCount }) => + this.monitor.recordBatch(tickCount, updateCount, supersededUpdateCount), + renderCommitted: () => this.monitor.recordDomCommit(), + }) + longAnimationFrameObserver?.observe({ + type: 'long-animation-frame', + }) + this.#runtime.animationFrameId = requestAnimationFrame(this.#benchmarkFrame) + + return () => this.stop() + } + + stop(): void { + cancelAnimationFrame(this.#runtime.animationFrameId) + this.#runtime.longAnimationFrameObserver?.disconnect() + this.#runtime.stopObservingFeed?.() + this.#runtime.longAnimationFrameObserver = null + this.#runtime.stopObservingFeed = null + } + + readonly #benchmarkFrame = (now: number): void => { + this.monitor.recordAnimationFrame(now) + if (this.monitor.shouldPublish(now)) { + this.#publishMetrics(this.monitor.publish(now)) + } + this.#runtime.animationFrameId = requestAnimationFrame(this.#benchmarkFrame) + } + + #patch(patch: Partial): void { + this.store.setState((state) => ({ ...state, ...patch })) + } + + #publishMetrics(metrics: FeedMetrics): void { + const liveComponents = + metrics.componentsCreated - metrics.componentsDestroyed + this.#patch({ + metrics, + liveComponents, + }) + exposeTradingBenchmarkSnapshot(metrics, { + mountedCells: this.store.get().mountedCells, + liveComponents, + }) + } +} diff --git a/examples/preact/realtime-trading/src/benchmark/use-table-benchmark.ts b/examples/preact/realtime-trading/src/benchmark/use-table-benchmark.ts new file mode 100644 index 0000000000..de40f98f9f --- /dev/null +++ b/examples/preact/realtime-trading/src/benchmark/use-table-benchmark.ts @@ -0,0 +1,28 @@ +import { useEffect } from 'preact/hooks' +import type { TradingBenchmarkController } from './trading-benchmark-controller' + +export function useTableBenchmark( + controller: TradingBenchmarkController, +): void { + useEffect(() => { + const tableBody = document.querySelector( + '.market-panel [data-trading-table] tbody', + ) + if (!tableBody) { + return + } + + controller.monitor.resetDomMutations() + const observer = new MutationObserver((records) => { + controller.monitor.recordDomMutations(records.length) + }) + observer.observe(tableBody, { + attributes: true, + attributeFilter: ['class', 'style'], + characterData: true, + childList: true, + subtree: true, + }) + return () => observer.disconnect() + }, [controller]) +} diff --git a/examples/preact/realtime-trading/src/benchmark/use-trading-benchmark-controller.ts b/examples/preact/realtime-trading/src/benchmark/use-trading-benchmark-controller.ts new file mode 100644 index 0000000000..670253ed6a --- /dev/null +++ b/examples/preact/realtime-trading/src/benchmark/use-trading-benchmark-controller.ts @@ -0,0 +1,13 @@ +import { useEffect, useState } from 'preact/hooks' +import { TradingBenchmarkController } from './trading-benchmark-controller' +import type { MarketFeedController } from '../feed/market-feed-controller' + +export function useTradingBenchmarkController(feed: MarketFeedController) { + const [controller] = useState(() => new TradingBenchmarkController(feed)) + + useEffect(() => controller.start(), [controller]) + + return controller +} + +export type { TradingBenchmarkController } from './trading-benchmark-controller' diff --git a/examples/preact/realtime-trading/src/feed/feed-sample-rates.ts b/examples/preact/realtime-trading/src/feed/feed-sample-rates.ts new file mode 100644 index 0000000000..17dc2015a6 --- /dev/null +++ b/examples/preact/realtime-trading/src/feed/feed-sample-rates.ts @@ -0,0 +1,33 @@ +export const feedSampleRateOptions = [ + { label: '100', value: 100 }, + { label: '250', value: 250 }, + { label: '500', value: 500 }, + { label: '1K', value: 1_000 }, + { label: '2.5K', value: 2_500 }, + { label: '5K', value: 5_000 }, + { label: '10K', value: 10_000 }, + { label: '25K', value: 25_000 }, + { label: '50K', value: 50_000 }, + { label: '100K', value: 100_000 }, +] as const + +export function feedSampleRateIndex(rate: number): number { + return feedSampleRateOptions.reduce((closestIndex, candidate, index) => { + const closest = feedSampleRateOptions[closestIndex] + return Math.abs(candidate.value - rate) < Math.abs(closest.value - rate) + ? index + : closestIndex + }, 0) +} + +export function feedSampleRateAt(stepIndex: number): number { + const index = Math.min( + feedSampleRateOptions.length - 1, + Math.max(0, Math.round(stepIndex)), + ) + return feedSampleRateOptions[index].value +} + +export function normalizeFeedSampleRate(rate: number): number { + return feedSampleRateAt(feedSampleRateIndex(rate)) +} diff --git a/examples/preact/realtime-trading/src/feed/market-data.ts b/examples/preact/realtime-trading/src/feed/market-data.ts new file mode 100644 index 0000000000..6231865d3f --- /dev/null +++ b/examples/preact/realtime-trading/src/feed/market-data.ts @@ -0,0 +1,38 @@ +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './worker/market-feed-protocol' + +export interface MarketQuote extends Omit { + history: ReadonlyArray +} + +export function hydrateMarketQuotes( + snapshots: Array, +): Array { + return snapshots.map((quote) => ({ + ...quote, + history: [...quote.history], + })) +} + +export function applyMarketUpdates( + quotes: Array, + updates: Array, +): Array { + const nextQuotes = [...quotes] + + for (const update of updates) { + const { index, history, ...values } = update + const previousQuote = quotes.at(index) + if (!previousQuote) continue + + nextQuotes[index] = { + ...previousQuote, + ...values, + history: history ?? previousQuote.history, + } + } + + return nextQuotes +} diff --git a/examples/preact/realtime-trading/src/feed/market-feed-config.ts b/examples/preact/realtime-trading/src/feed/market-feed-config.ts new file mode 100644 index 0000000000..9d477ed663 --- /dev/null +++ b/examples/preact/realtime-trading/src/feed/market-feed-config.ts @@ -0,0 +1,15 @@ +export interface MarketFeedConfig { + readonly instrumentCount: number + readonly targetSamplesPerSecond: number + readonly publishIntervalMs: number + readonly updateSparklines: boolean + readonly sparklineSampleIntervalMs: number +} + +export const initialMarketFeedConfig: MarketFeedConfig = { + instrumentCount: 100, + targetSamplesPerSecond: 10_000, + publishIntervalMs: 20, + updateSparklines: true, + sparklineSampleIntervalMs: 16, +} diff --git a/examples/preact/realtime-trading/src/feed/market-feed-controller.ts b/examples/preact/realtime-trading/src/feed/market-feed-controller.ts new file mode 100644 index 0000000000..21b5f59222 --- /dev/null +++ b/examples/preact/realtime-trading/src/feed/market-feed-controller.ts @@ -0,0 +1,227 @@ +import { batch, createAtom } from '@tanstack/preact-store' +import { normalizeFeedSampleRate } from './feed-sample-rates' +import { initialMarketFeedConfig } from './market-feed-config' +import { applyMarketUpdates, hydrateMarketQuotes } from './market-data' +import type { + MarketFeedCommand, + MarketFeedEvent, +} from './worker/market-feed-protocol' +import type { MarketQuote } from './market-data' + +export interface MarketFeedBatch { + tickCount: number + updateCount: number + supersededUpdateCount: number +} + +export interface MarketFeedObserver { + messageReceived?: () => void + mutationStarted?: () => void + batchApplied?: (batch: MarketFeedBatch) => void + renderCommitted?: () => void +} + +export interface MarketFeedActions { + toggle: () => void + setInstrumentCount: (count: number) => void + setTargetRate: (rate: number) => void + setPublishInterval: (intervalMs: number) => void + setSparklineUpdates: (enabled: boolean) => void + setSparklineSampleInterval: (intervalMs: number) => void + runBurst: () => void + reset: () => void +} + +export class MarketFeedController { + readonly workerReady = createAtom(false) + readonly running = createAtom( + !new URLSearchParams(location.search).has('paused'), + ) + readonly instrumentCount = createAtom(initialMarketFeedConfig.instrumentCount) + readonly targetTicksPerSecond = createAtom( + initialMarketFeedConfig.targetSamplesPerSecond, + ) + readonly publishIntervalMs = createAtom( + initialMarketFeedConfig.publishIntervalMs, + ) + readonly updateSparklines = createAtom( + initialMarketFeedConfig.updateSparklines, + ) + readonly sparklineSampleIntervalMs = createAtom( + initialMarketFeedConfig.sparklineSampleIntervalMs, + ) + readonly quotes = createAtom>([]) + readonly actions: MarketFeedActions + readonly #observers = new Set() + readonly #runtime = { + worker: null as Worker | null, + feedSessionId: 0, + renderPending: false, + resetWaitingForCommit: false, + resetSnapshotReady: false, + quoteIndexBySymbol: new Map(), + } + + constructor() { + this.actions = { + toggle: () => { + const running = !this.running.get() + this.running.set(running) + this.#post({ type: 'set-running', running }) + }, + setInstrumentCount: (count) => { + this.instrumentCount.set(count) + this.#resetWorker(count) + }, + setTargetRate: (rate) => { + const sampleRate = normalizeFeedSampleRate(rate) + this.targetTicksPerSecond.set(sampleRate) + this.#post({ type: 'set-rate', ticksPerSecond: sampleRate }) + }, + setPublishInterval: (publishIntervalMs) => { + this.publishIntervalMs.set(publishIntervalMs) + this.#post({ + type: 'set-publish-interval', + intervalMs: publishIntervalMs, + }) + }, + setSparklineUpdates: (enabled) => { + this.updateSparklines.set(enabled) + this.#post({ type: 'set-sparklines', enabled }) + }, + setSparklineSampleInterval: (intervalMs) => { + this.sparklineSampleIntervalMs.set(intervalMs) + this.#post({ type: 'set-sparkline-interval', intervalMs }) + }, + runBurst: () => this.#post({ type: 'burst', tickCount: 25_000 }), + reset: () => this.#resetWorker(this.instrumentCount.get()), + } + } + + start(): () => void { + const worker = new Worker( + new URL('./worker/market-feed.worker.ts', import.meta.url), + { type: 'module' }, + ) + this.#runtime.worker = worker + worker.addEventListener('message', this.#handleWorkerMessage) + worker.addEventListener('error', this.#handleWorkerError) + this.#post({ + type: 'start', + rowCount: this.instrumentCount.get(), + running: this.running.get(), + ticksPerSecond: this.targetTicksPerSecond.get(), + publishIntervalMs: this.publishIntervalMs.get(), + updateSparklines: this.updateSparklines.get(), + sparklineSampleIntervalMs: this.sparklineSampleIntervalMs.get(), + }) + return () => this.stop() + } + + stop(): void { + this.#runtime.worker?.removeEventListener( + 'message', + this.#handleWorkerMessage, + ) + this.#runtime.worker?.removeEventListener('error', this.#handleWorkerError) + this.#runtime.worker?.terminate() + this.#runtime.worker = null + this.#observers.clear() + } + + observe(observer: MarketFeedObserver): () => void { + this.#observers.add(observer) + return () => this.#observers.delete(observer) + } + + getQuoteBySymbol( + quotes: Array, + symbol: string | null, + ): MarketQuote | null { + if (symbol === null) return null + + const index = this.#runtime.quoteIndexBySymbol.get(symbol) + return index === undefined ? null : (quotes[index] ?? null) + } + + completeRender(): void { + if (!this.#runtime.renderPending) return + + this.#runtime.renderPending = false + for (const observer of this.#observers) { + observer.renderCommitted?.() + } + if ( + this.#runtime.resetWaitingForCommit && + this.#runtime.resetSnapshotReady + ) { + this.#runtime.resetWaitingForCommit = false + this.#runtime.resetSnapshotReady = false + this.#post({ type: 'set-running', running: this.running.get() }) + } + } + + readonly #handleWorkerMessage = ({ + data, + }: MessageEvent): void => { + if (data.type === 'snapshot') { + this.#runtime.feedSessionId = data.sessionId + if (this.#runtime.resetWaitingForCommit) { + this.#runtime.resetSnapshotReady = true + } + this.#startMutation() + const quotes = hydrateMarketQuotes(data.quotes) + this.#runtime.quoteIndexBySymbol = new Map( + quotes.map((quote, index) => [quote.symbol, index]), + ) + batch(() => { + this.quotes.set(quotes) + this.workerReady.set(true) + }) + return + } + + if (data.sessionId !== this.#runtime.feedSessionId) return + + for (const observer of this.#observers) { + observer.messageReceived?.() + } + this.#startMutation() + this.quotes.set(applyMarketUpdates(this.quotes.get(), data.updates)) + const feedBatch = { + tickCount: data.tickCount, + updateCount: data.updates.length, + supersededUpdateCount: data.coalescedUpdateCount, + } + for (const observer of this.#observers) { + observer.batchApplied?.(feedBatch) + } + } + + readonly #handleWorkerError = (error: ErrorEvent): void => { + batch(() => { + this.workerReady.set(false) + this.running.set(false) + }) + console.error('Market feed worker failed', error) + } + + #resetWorker(rowCount: number): void { + this.workerReady.set(false) + this.#runtime.resetWaitingForCommit = true + this.#runtime.resetSnapshotReady = false + this.#post({ type: 'set-running', running: false }) + this.#post({ type: 'reset', rowCount }) + } + + #startMutation(): void { + this.#runtime.renderPending = true + for (const observer of this.#observers) { + observer.mutationStarted?.() + } + } + + #post(command: MarketFeedCommand): void { + this.#runtime.worker?.postMessage(command) + } +} diff --git a/examples/preact/realtime-trading/src/feed/market-instruments.ts b/examples/preact/realtime-trading/src/feed/market-instruments.ts new file mode 100644 index 0000000000..ac18d14ea9 --- /dev/null +++ b/examples/preact/realtime-trading/src/feed/market-instruments.ts @@ -0,0 +1,742 @@ +export type MarketCode = + | 'US' + | 'NL' + | 'DE' + | 'FR' + | 'IT' + | 'ES' + | 'CH' + | 'DK' + | 'SE' + | 'FI' + | 'GB' + | 'KR' + | 'JP' + | 'HK' + | 'CA' + | 'AU' + +export type BaseInstrument = readonly [ + symbol: string, + company: string, + market: MarketCode, +] + +/** + * Current S&P 500 constituent universe used by the realtime trading examples. + * + * Source snapshot: https://github.com/datasets/s-and-p-500-companies + * Retrieved: 2026-08-15. + * Multiple share classes are intentionally represented as separate instruments. + */ +export const marketInstruments = Object.freeze([ + ['MMM', '3M', 'US'], + ['AOS', 'A. O. Smith', 'US'], + ['ABT', 'Abbott Laboratories', 'US'], + ['ABBV', 'AbbVie', 'US'], + ['ACN', 'Accenture', 'US'], + ['ADBE', 'Adobe Inc.', 'US'], + ['AMD', 'Advanced Micro Devices', 'US'], + ['AES', 'AES Corporation', 'US'], + ['AFL', 'Aflac', 'US'], + ['A', 'Agilent Technologies', 'US'], + ['APD', 'Air Products', 'US'], + ['ABNB', 'Airbnb', 'US'], + ['AKAM', 'Akamai Technologies', 'US'], + ['ALB', 'Albemarle Corporation', 'US'], + ['ARE', 'Alexandria Real Estate Equities', 'US'], + ['ALGN', 'Align Technology', 'US'], + ['ALLE', 'Allegion', 'US'], + ['LNT', 'Alliant Energy', 'US'], + ['ALL', 'Allstate', 'US'], + ['GOOGL', 'Alphabet Inc. (Class A)', 'US'], + ['GOOG', 'Alphabet Inc. (Class C)', 'US'], + ['MO', 'Altria', 'US'], + ['AMZN', 'Amazon', 'US'], + ['AMCR', 'Amcor', 'US'], + ['AEE', 'Ameren', 'US'], + ['AEP', 'American Electric Power', 'US'], + ['AXP', 'American Express', 'US'], + ['AIG', 'American International Group', 'US'], + ['AMT', 'American Tower', 'US'], + ['AWK', 'American Water Works', 'US'], + ['AMP', 'Ameriprise Financial', 'US'], + ['AME', 'Ametek', 'US'], + ['AMGN', 'Amgen', 'US'], + ['APH', 'Amphenol', 'US'], + ['ADI', 'Analog Devices', 'US'], + ['AON', 'Aon plc', 'US'], + ['APA', 'APA Corporation', 'US'], + ['APO', 'Apollo Global Management', 'US'], + ['AAPL', 'Apple Inc.', 'US'], + ['AMAT', 'Applied Materials', 'US'], + ['APP', 'AppLovin', 'US'], + ['APTV', 'Aptiv', 'US'], + ['ACGL', 'Arch Capital Group', 'US'], + ['ADM', 'Archer Daniels Midland', 'US'], + ['ARES', 'Ares Management', 'US'], + ['ANET', 'Arista Networks', 'US'], + ['AJG', 'Arthur J. Gallagher & Co.', 'US'], + ['AIZ', 'Assurant', 'US'], + ['T', 'AT&T', 'US'], + ['ATO', 'Atmos Energy', 'US'], + ['ADSK', 'Autodesk', 'US'], + ['ADP', 'Automatic Data Processing', 'US'], + ['AZO', 'AutoZone', 'US'], + ['AVB', 'AvalonBay Communities', 'US'], + ['AVY', 'Avery Dennison', 'US'], + ['AXON', 'Axon Enterprise', 'US'], + ['BKR', 'Baker Hughes', 'US'], + ['BALL', 'Ball Corporation', 'US'], + ['BAC', 'Bank of America', 'US'], + ['BAX', 'Baxter International', 'US'], + ['BDX', 'Becton Dickinson', 'US'], + ['BRK.B', 'Berkshire Hathaway', 'US'], + ['BBY', 'Best Buy', 'US'], + ['TECH', 'Bio-Techne', 'US'], + ['BIIB', 'Biogen', 'US'], + ['BLK', 'BlackRock', 'US'], + ['BX', 'Blackstone Inc.', 'US'], + ['XYZ', 'Block, Inc.', 'US'], + ['BNY', 'BNY Mellon', 'US'], + ['BA', 'Boeing', 'US'], + ['BKNG', 'Booking Holdings', 'US'], + ['BSX', 'Boston Scientific', 'US'], + ['BMY', 'Bristol Myers Squibb', 'US'], + ['AVGO', 'Broadcom', 'US'], + ['BR', 'Broadridge Financial Solutions', 'US'], + ['BRO', 'Brown & Brown', 'US'], + ['BF.B', 'Brown–Forman', 'US'], + ['BLDR', 'Builders FirstSource', 'US'], + ['BG', 'Bunge Global', 'US'], + ['BXP', 'BXP, Inc.', 'US'], + ['CHRW', 'C.H. Robinson', 'US'], + ['CDNS', 'Cadence Design Systems', 'US'], + ['CPT', 'Camden Property Trust', 'US'], + ['COF', 'Capital One', 'US'], + ['CAH', 'Cardinal Health', 'US'], + ['CCL', 'Carnival Corporation', 'US'], + ['CARR', 'Carrier Global', 'US'], + ['CVNA', 'Carvana', 'US'], + ['CASY', "Casey's", 'US'], + ['CAT', 'Caterpillar Inc.', 'US'], + ['CBOE', 'Cboe Global Markets', 'US'], + ['CBRE', 'CBRE Group', 'US'], + ['CDW', 'CDW Corporation', 'US'], + ['COR', 'Cencora', 'US'], + ['CNC', 'Centene Corporation', 'US'], + ['CNP', 'CenterPoint Energy', 'US'], + ['CF', 'CF Industries', 'US'], + ['CRL', 'Charles River Laboratories', 'US'], + ['SCHW', 'Charles Schwab Corporation', 'US'], + ['CHTR', 'Charter Communications', 'US'], + ['CVX', 'Chevron Corporation', 'US'], + ['CMG', 'Chipotle Mexican Grill', 'US'], + ['CB', 'Chubb Limited', 'US'], + ['CHD', 'Church & Dwight', 'US'], + ['CIEN', 'Ciena', 'US'], + ['CI', 'Cigna', 'US'], + ['CINF', 'Cincinnati Financial', 'US'], + ['CTAS', 'Cintas', 'US'], + ['CSCO', 'Cisco', 'US'], + ['C', 'Citigroup', 'US'], + ['CFG', 'Citizens Financial Group', 'US'], + ['CLX', 'Clorox', 'US'], + ['CME', 'CME Group', 'US'], + ['CMS', 'CMS Energy', 'US'], + ['KO', 'Coca-Cola Company (The)', 'US'], + ['CTSH', 'Cognizant', 'US'], + ['COHR', 'Coherent Corp.', 'US'], + ['COIN', 'Coinbase', 'US'], + ['CL', 'Colgate-Palmolive', 'US'], + ['CMCSA', 'Comcast', 'US'], + ['FIX', 'Comfort Systems USA', 'US'], + ['COP', 'ConocoPhillips', 'US'], + ['ED', 'Consolidated Edison', 'US'], + ['STZ', 'Constellation Brands', 'US'], + ['CEG', 'Constellation Energy', 'US'], + ['COO', 'Cooper Companies (The)', 'US'], + ['CPRT', 'Copart', 'US'], + ['GLW', 'Corning Inc.', 'US'], + ['CPAY', 'Corpay', 'US'], + ['CTVA', 'Corteva', 'US'], + ['CSGP', 'CoStar Group', 'US'], + ['COST', 'Costco', 'US'], + ['CRH', 'CRH plc', 'US'], + ['CRWD', 'CrowdStrike', 'US'], + ['CCI', 'Crown Castle', 'US'], + ['CSX', 'CSX Corporation', 'US'], + ['CMI', 'Cummins', 'US'], + ['CVS', 'CVS Health', 'US'], + ['DHR', 'Danaher Corporation', 'US'], + ['DRI', 'Darden Restaurants', 'US'], + ['DDOG', 'Datadog', 'US'], + ['DVA', 'DaVita', 'US'], + ['DECK', 'Deckers Brands', 'US'], + ['DE', 'Deere & Company', 'US'], + ['DELL', 'Dell Technologies', 'US'], + ['DAL', 'Delta Air Lines', 'US'], + ['DVN', 'Devon Energy', 'US'], + ['DXCM', 'Dexcom', 'US'], + ['FANG', 'Diamondback Energy', 'US'], + ['DLR', 'Digital Realty', 'US'], + ['DG', 'Dollar General', 'US'], + ['DLTR', 'Dollar Tree', 'US'], + ['D', 'Dominion Energy', 'US'], + ['DPZ', "Domino's", 'US'], + ['DASH', 'DoorDash', 'US'], + ['DOV', 'Dover Corporation', 'US'], + ['DOW', 'Dow Inc.', 'US'], + ['DHI', 'D. R. Horton', 'US'], + ['DTE', 'DTE Energy', 'US'], + ['DUK', 'Duke Energy', 'US'], + ['DD', 'DuPont', 'US'], + ['ETN', 'Eaton Corporation', 'US'], + ['EBAY', 'eBay Inc.', 'US'], + ['ECHO', 'EchoStar', 'US'], + ['ECL', 'Ecolab', 'US'], + ['EIX', 'Edison International', 'US'], + ['EW', 'Edwards Lifesciences', 'US'], + ['ELV', 'Elevance Health', 'US'], + ['EME', 'Emcor', 'US'], + ['EMR', 'Emerson Electric', 'US'], + ['ETR', 'Entergy', 'US'], + ['EOG', 'EOG Resources', 'US'], + ['EQT', 'EQT Corporation', 'US'], + ['EFX', 'Equifax', 'US'], + ['EQIX', 'Equinix', 'US'], + ['EQR', 'Equity Residential', 'US'], + ['ERIE', 'Erie Indemnity', 'US'], + ['ESS', 'Essex Property Trust', 'US'], + ['EL', 'Estée Lauder Companies (The)', 'US'], + ['EG', 'Everest Group', 'US'], + ['EVRG', 'Evergy', 'US'], + ['ES', 'Eversource Energy', 'US'], + ['EXC', 'Exelon', 'US'], + ['EXE', 'Expand Energy', 'US'], + ['EXPE', 'Expedia Group', 'US'], + ['EXPD', 'Expeditors International', 'US'], + ['EXR', 'Extra Space Storage', 'US'], + ['XOM', 'ExxonMobil', 'US'], + ['FFIV', 'F5, Inc.', 'US'], + ['FDS', 'FactSet', 'US'], + ['FICO', 'Fair Isaac', 'US'], + ['FAST', 'Fastenal', 'US'], + ['FRT', 'Federal Realty Investment Trust', 'US'], + ['FDX', 'FedEx', 'US'], + ['FDXF', 'FedEx Freight', 'US'], + ['FERG', 'Ferguson Enterprises', 'US'], + ['FIS', 'Fidelity National Information Services', 'US'], + ['FITB', 'Fifth Third Bancorp', 'US'], + ['FSLR', 'First Solar', 'US'], + ['FE', 'FirstEnergy', 'US'], + ['FISV', 'Fiserv', 'US'], + ['FLEX', 'Flex Ltd.', 'US'], + ['F', 'Ford Motor Company', 'US'], + ['FTNT', 'Fortinet', 'US'], + ['FTV', 'Fortive', 'US'], + ['FOXA', 'Fox Corporation (Class A)', 'US'], + ['FOX', 'Fox Corporation (Class B)', 'US'], + ['BEN', 'Franklin Resources', 'US'], + ['FCX', 'Freeport-McMoRan', 'US'], + ['GRMN', 'Garmin', 'US'], + ['IT', 'Gartner', 'US'], + ['GE', 'GE Aerospace', 'US'], + ['GEHC', 'GE HealthCare', 'US'], + ['GEV', 'GE Vernova', 'US'], + ['GEN', 'Gen Digital', 'US'], + ['GNRC', 'Generac', 'US'], + ['GD', 'General Dynamics', 'US'], + ['GIS', 'General Mills', 'US'], + ['GM', 'General Motors', 'US'], + ['GPC', 'Genuine Parts Company', 'US'], + ['GILD', 'Gilead Sciences', 'US'], + ['GPN', 'Global Payments', 'US'], + ['GL', 'Globe Life', 'US'], + ['GDDY', 'GoDaddy', 'US'], + ['GS', 'Goldman Sachs', 'US'], + ['HAL', 'Halliburton', 'US'], + ['HIG', 'Hartford (The)', 'US'], + ['HAS', 'Hasbro', 'US'], + ['HCA', 'HCA Healthcare', 'US'], + ['DOC', 'Healthpeak Properties', 'US'], + ['HSIC', 'Henry Schein', 'US'], + ['HSY', 'Hershey Company (The)', 'US'], + ['HPE', 'Hewlett Packard Enterprise', 'US'], + ['HLT', 'Hilton Worldwide', 'US'], + ['HD', 'Home Depot (The)', 'US'], + ['HONA', 'Honeywell Aerospace', 'US'], + ['HON', 'Honeywell Technologies', 'US'], + ['HRL', 'Hormel Foods', 'US'], + ['HST', 'Host Hotels & Resorts', 'US'], + ['HWM', 'Howmet Aerospace', 'US'], + ['HPQ', 'HP Inc.', 'US'], + ['HUBB', 'Hubbell Incorporated', 'US'], + ['HUM', 'Humana', 'US'], + ['HBAN', 'Huntington Bancshares', 'US'], + ['HII', 'Huntington Ingalls Industries', 'US'], + ['IBM', 'IBM', 'US'], + ['IEX', 'IDEX Corporation', 'US'], + ['IDXX', 'Idexx Laboratories', 'US'], + ['ITW', 'Illinois Tool Works', 'US'], + ['INCY', 'Incyte', 'US'], + ['IR', 'Ingersoll Rand', 'US'], + ['PODD', 'Insulet Corporation', 'US'], + ['INTC', 'Intel', 'US'], + ['IBKR', 'Interactive Brokers', 'US'], + ['ICE', 'Intercontinental Exchange', 'US'], + ['IFF', 'International Flavors & Fragrances', 'US'], + ['IP', 'International Paper', 'US'], + ['INTU', 'Intuit', 'US'], + ['ISRG', 'Intuitive Surgical', 'US'], + ['IVZ', 'Invesco', 'US'], + ['INVH', 'Invitation Homes', 'US'], + ['IQV', 'IQVIA', 'US'], + ['IRM', 'Iron Mountain', 'US'], + ['JBHT', 'J.B. Hunt', 'US'], + ['JBL', 'Jabil', 'US'], + ['JKHY', 'Jack Henry & Associates', 'US'], + ['J', 'Jacobs Solutions', 'US'], + ['JNJ', 'Johnson & Johnson', 'US'], + ['JCI', 'Johnson Controls', 'US'], + ['JPM', 'JPMorgan Chase', 'US'], + ['KVUE', 'Kenvue', 'US'], + ['KDP', 'Keurig Dr Pepper', 'US'], + ['KEY', 'KeyCorp', 'US'], + ['KEYS', 'Keysight Technologies', 'US'], + ['KMB', 'Kimberly-Clark', 'US'], + ['KIM', 'Kimco Realty', 'US'], + ['KMI', 'Kinder Morgan', 'US'], + ['KKR', 'KKR & Co.', 'US'], + ['KLAC', 'KLA Corporation', 'US'], + ['KHC', 'Kraft Heinz', 'US'], + ['KR', 'Kroger', 'US'], + ['LHX', 'L3Harris', 'US'], + ['LH', 'Labcorp', 'US'], + ['LRCX', 'Lam Research', 'US'], + ['LVS', 'Las Vegas Sands', 'US'], + ['LDOS', 'Leidos', 'US'], + ['LEN', 'Lennar', 'US'], + ['LII', 'Lennox International', 'US'], + ['LLY', 'Lilly (Eli)', 'US'], + ['LIN', 'Linde plc', 'US'], + ['LYV', 'Live Nation Entertainment', 'US'], + ['LMT', 'Lockheed Martin', 'US'], + ['L', 'Loews Corporation', 'US'], + ['LOW', "Lowe's", 'US'], + ['LULU', 'Lululemon Athletica', 'US'], + ['LITE', 'Lumentum', 'US'], + ['LYB', 'LyondellBasell', 'US'], + ['MTB', 'M&T Bank', 'US'], + ['MPC', 'Marathon Petroleum', 'US'], + ['MAR', 'Marriott International', 'US'], + ['MRSH', 'Marsh McLennan', 'US'], + ['MLM', 'Martin Marietta Materials', 'US'], + ['MRVL', 'Marvell Technology', 'US'], + ['MAS', 'Masco', 'US'], + ['MA', 'Mastercard', 'US'], + ['MKC', 'McCormick & Company', 'US'], + ['MCD', "McDonald's", 'US'], + ['MCK', 'McKesson Corporation', 'US'], + ['MDT', 'Medtronic', 'US'], + ['MRK', 'Merck & Co.', 'US'], + ['META', 'Meta Platforms', 'US'], + ['MET', 'MetLife', 'US'], + ['MTD', 'Mettler Toledo', 'US'], + ['MGM', 'MGM Resorts', 'US'], + ['MCHP', 'Microchip Technology', 'US'], + ['MU', 'Micron Technology', 'US'], + ['MSFT', 'Microsoft', 'US'], + ['MAA', 'Mid-America Apartment Communities', 'US'], + ['MRNA', 'Moderna', 'US'], + ['TAP', 'Molson Coors Beverage Company', 'US'], + ['MDLZ', 'Mondelez International', 'US'], + ['MPWR', 'Monolithic Power Systems', 'US'], + ['MNST', 'Monster Beverage', 'US'], + ['MCO', "Moody's Corporation", 'US'], + ['MS', 'Morgan Stanley', 'US'], + ['MOS', 'Mosaic Company (The)', 'US'], + ['MSI', 'Motorola Solutions', 'US'], + ['MSCI', 'MSCI', 'US'], + ['NDAQ', 'Nasdaq, Inc.', 'US'], + ['NTAP', 'NetApp', 'US'], + ['NFLX', 'Netflix', 'US'], + ['NEM', 'Newmont', 'US'], + ['NWSA', 'News Corp (Class A)', 'US'], + ['NWS', 'News Corp (Class B)', 'US'], + ['NEE', 'NextEra Energy', 'US'], + ['NKE', 'Nike, Inc.', 'US'], + ['NI', 'NiSource', 'US'], + ['NDSN', 'Nordson Corporation', 'US'], + ['NSC', 'Norfolk Southern', 'US'], + ['NTRS', 'Northern Trust', 'US'], + ['NOC', 'Northrop Grumman', 'US'], + ['NCLH', 'Norwegian Cruise Line Holdings', 'US'], + ['NRG', 'NRG Energy', 'US'], + ['NUE', 'Nucor', 'US'], + ['NVDA', 'Nvidia', 'US'], + ['NVR', 'NVR, Inc.', 'US'], + ['NXPI', 'NXP Semiconductors', 'US'], + ['ORLY', "O'Reilly Automotive", 'US'], + ['OXY', 'Occidental Petroleum', 'US'], + ['ODFL', 'Old Dominion', 'US'], + ['OMC', 'Omnicom Group', 'US'], + ['ON', 'ON Semiconductor', 'US'], + ['OKE', 'Oneok', 'US'], + ['ORCL', 'Oracle Corporation', 'US'], + ['OTIS', 'Otis Worldwide', 'US'], + ['PCAR', 'Paccar', 'US'], + ['PKG', 'Packaging Corporation of America', 'US'], + ['PLTR', 'Palantir Technologies', 'US'], + ['PANW', 'Palo Alto Networks', 'US'], + ['PSKY', 'Paramount Skydance Corporation', 'US'], + ['PH', 'Parker Hannifin', 'US'], + ['PAYX', 'Paychex', 'US'], + ['PYPL', 'PayPal', 'US'], + ['PNR', 'Pentair', 'US'], + ['PEP', 'PepsiCo', 'US'], + ['PFE', 'Pfizer', 'US'], + ['PCG', 'PG&E Corporation', 'US'], + ['PM', 'Philip Morris International', 'US'], + ['PSX', 'Phillips 66', 'US'], + ['PNW', 'Pinnacle West Capital', 'US'], + ['PNC', 'PNC Financial Services', 'US'], + ['PPG', 'PPG Industries', 'US'], + ['PPL', 'PPL Corporation', 'US'], + ['PFG', 'Principal Financial Group', 'US'], + ['PG', 'Procter & Gamble', 'US'], + ['PGR', 'Progressive Corporation', 'US'], + ['PLD', 'Prologis', 'US'], + ['PRU', 'Prudential Financial', 'US'], + ['PEG', 'Public Service Enterprise Group', 'US'], + ['PTC', 'PTC Inc.', 'US'], + ['PSA', 'Public Storage', 'US'], + ['PHM', 'PulteGroup', 'US'], + ['PWR', 'Quanta Services', 'US'], + ['QCOM', 'Qualcomm', 'US'], + ['DGX', 'Quest Diagnostics', 'US'], + ['Q', 'Qnity Electronics', 'US'], + ['RL', 'Ralph Lauren Corporation', 'US'], + ['RJF', 'Raymond James Financial', 'US'], + ['RTX', 'RTX Corporation', 'US'], + ['O', 'Realty Income', 'US'], + ['REG', 'Regency Centers', 'US'], + ['REGN', 'Regeneron Pharmaceuticals', 'US'], + ['RF', 'Regions Financial Corporation', 'US'], + ['RSG', 'Republic Services', 'US'], + ['RMD', 'ResMed|', 'US'], + ['RVTY', 'Revvity', 'US'], + ['HOOD', 'Robinhood Markets', 'US'], + ['ROK', 'Rockwell Automation', 'US'], + ['ROL', 'Rollins, Inc.', 'US'], + ['ROP', 'Roper Technologies', 'US'], + ['ROST', 'Ross Stores', 'US'], + ['RCL', 'Royal Caribbean Group', 'US'], + ['SPGI', 'S&P Global', 'US'], + ['CRM', 'Salesforce', 'US'], + ['SNDK', 'Sandisk', 'US'], + ['SBAC', 'SBA Communications', 'US'], + ['SLB', 'Schlumberger', 'US'], + ['STX', 'Seagate Technology', 'US'], + ['SRE', 'Sempra', 'US'], + ['NOW', 'ServiceNow', 'US'], + ['SHW', 'Sherwin-Williams', 'US'], + ['SPG', 'Simon Property Group', 'US'], + ['SWKS', 'Skyworks Solutions', 'US'], + ['SJM', 'J.M. Smucker Company (The)', 'US'], + ['SW', 'Smurfit Westrock', 'US'], + ['SNA', 'Snap-on', 'US'], + ['SOLV', 'Solventum', 'US'], + ['SO', 'Southern Company', 'US'], + ['LUV', 'Southwest Airlines', 'US'], + ['SWK', 'Stanley Black & Decker', 'US'], + ['SBUX', 'Starbucks', 'US'], + ['STT', 'State Street Corporation', 'US'], + ['STLD', 'Steel Dynamics', 'US'], + ['STE', 'Steris', 'US'], + ['SYK', 'Stryker Corporation', 'US'], + ['SMCI', 'Supermicro', 'US'], + ['SYF', 'Synchrony Financial', 'US'], + ['SNPS', 'Synopsys', 'US'], + ['SYY', 'Sysco', 'US'], + ['TMUS', 'T-Mobile US', 'US'], + ['TROW', 'T. Rowe Price', 'US'], + ['TTWO', 'Take-Two Interactive', 'US'], + ['TPR', 'Tapestry, Inc.', 'US'], + ['TRGP', 'Targa Resources', 'US'], + ['TGT', 'Target Corporation', 'US'], + ['TEL', 'TE Connectivity', 'US'], + ['TDY', 'Teledyne Technologies', 'US'], + ['TER', 'Teradyne', 'US'], + ['TSLA', 'Tesla, Inc.', 'US'], + ['TXN', 'Texas Instruments', 'US'], + ['TPL', 'Texas Pacific Land Corporation', 'US'], + ['TXT', 'Textron', 'US'], + ['TMO', 'Thermo Fisher Scientific', 'US'], + ['TJX', 'TJX Companies', 'US'], + ['TKO', 'TKO Group Holdings', 'US'], + ['TTD', 'Trade Desk (The)', 'US'], + ['TSCO', 'Tractor Supply', 'US'], + ['TT', 'Trane Technologies', 'US'], + ['TDG', 'TransDigm Group', 'US'], + ['TRV', 'Travelers Companies (The)', 'US'], + ['TRMB', 'Trimble Inc.', 'US'], + ['TFC', 'Truist Financial', 'US'], + ['TYL', 'Tyler Technologies', 'US'], + ['TSN', 'Tyson Foods', 'US'], + ['USB', 'U.S. Bancorp', 'US'], + ['UBER', 'Uber', 'US'], + ['UDR', 'UDR, Inc.', 'US'], + ['ULTA', 'Ulta Beauty', 'US'], + ['UNP', 'Union Pacific Corporation', 'US'], + ['UAL', 'United Airlines Holdings', 'US'], + ['UPS', 'United Parcel Service', 'US'], + ['URI', 'United Rentals', 'US'], + ['UNH', 'UnitedHealth Group', 'US'], + ['UHS', 'Universal Health Services', 'US'], + ['VLO', 'Valero Energy', 'US'], + ['VEEV', 'Veeva Systems', 'US'], + ['VTR', 'Ventas', 'US'], + ['VLTO', 'Veralto', 'US'], + ['VRSN', 'Verisign', 'US'], + ['VRSK', 'Verisk Analytics', 'US'], + ['VZ', 'Verizon', 'US'], + ['VRTX', 'Vertex Pharmaceuticals', 'US'], + ['VRT', 'Vertiv', 'US'], + ['VTRS', 'Viatris', 'US'], + ['VICI', 'Vici Properties', 'US'], + ['V', 'Visa Inc.', 'US'], + ['VST', 'Vistra Corp.', 'US'], + ['VMC', 'Vulcan Materials Company', 'US'], + ['WRB', 'W. R. Berkley Corporation', 'US'], + ['GWW', 'W. W. Grainger', 'US'], + ['WAB', 'Wabtec', 'US'], + ['WMT', 'Walmart', 'US'], + ['DIS', 'Walt Disney Company (The)', 'US'], + ['WBD', 'Warner Bros. Discovery', 'US'], + ['WM', 'Waste Management', 'US'], + ['WAT', 'Waters Corporation', 'US'], + ['WEC', 'WEC Energy Group', 'US'], + ['WFC', 'Wells Fargo', 'US'], + ['WELL', 'Welltower', 'US'], + ['WST', 'West Pharmaceutical Services', 'US'], + ['WDC', 'Western Digital', 'US'], + ['WY', 'Weyerhaeuser', 'US'], + ['WSM', 'Williams-Sonoma, Inc.', 'US'], + ['WMB', 'Williams Companies', 'US'], + ['WTW', 'Willis Towers Watson', 'US'], + ['WDAY', 'Workday, Inc.', 'US'], + ['WYNN', 'Wynn Resorts', 'US'], + ['XEL', 'Xcel Energy', 'US'], + ['XYL', 'Xylem Inc.', 'US'], + ['YUM', 'Yum! Brands', 'US'], + ['ZBRA', 'Zebra Technologies', 'US'], + ['ZBH', 'Zimmer Biomet', 'US'], + ['ZTS', 'Zoetis', 'US'], +]) + +/** + * Representative liquid international listings used to diversify the fixture. + * Symbols use their local-market form and the third tuple value is an ISO-style + * country/market code, rather than a trading currency or exchange MIC. + * + * References checked 2026-08-15: STOXX Europe 50, KRX KOSPI market, + * JPX TOPIX Core30, and HKEX index constituent materials. + */ +const europeanInstruments = Object.freeze([ + ['ASML', 'ASML Holding', 'NL'], + ['INGA', 'ING Group', 'NL'], + ['ADYEN', 'Adyen', 'NL'], + ['PHIA', 'Philips', 'NL'], + ['HEIA', 'Heineken', 'NL'], + ['SAP', 'SAP', 'DE'], + ['SIE', 'Siemens', 'DE'], + ['ALV', 'Allianz', 'DE'], + ['DTE', 'Deutsche Telekom', 'DE'], + ['MBG', 'Mercedes-Benz Group', 'DE'], + ['BMW', 'BMW', 'DE'], + ['BAS', 'BASF', 'DE'], + ['MUV2', 'Munich Re', 'DE'], + ['VOW3', 'Volkswagen Preference', 'DE'], + ['IFX', 'Infineon Technologies', 'DE'], + ['MC', 'LVMH', 'FR'], + ['OR', "L'Oréal", 'FR'], + ['AIR', 'Airbus', 'FR'], + ['SU', 'Schneider Electric', 'FR'], + ['TTE', 'TotalEnergies', 'FR'], + ['SAN', 'Sanofi', 'FR'], + ['BNP', 'BNP Paribas', 'FR'], + ['CS', 'AXA', 'FR'], + ['DG', 'Vinci', 'FR'], + ['ENEL', 'Enel', 'IT'], + ['ENI', 'Eni', 'IT'], + ['ISP', 'Intesa Sanpaolo', 'IT'], + ['UCG', 'UniCredit', 'IT'], + ['STLAM', 'Stellantis', 'IT'], + ['SAN', 'Banco Santander', 'ES'], + ['IBE', 'Iberdrola', 'ES'], + ['ITX', 'Inditex', 'ES'], + ['BBVA', 'BBVA', 'ES'], + ['NESN', 'Nestlé', 'CH'], + ['ROG', 'Roche Holding', 'CH'], + ['NOVN', 'Novartis', 'CH'], + ['UBSG', 'UBS Group', 'CH'], + ['NOVO-B', 'Novo Nordisk', 'DK'], + ['MAERSK-B', 'A.P. Moller - Maersk', 'DK'], + ['VOLV-B', 'Volvo', 'SE'], + ['ERIC-B', 'Ericsson', 'SE'], + ['NOKIA', 'Nokia', 'FI'], + ['SHEL', 'Shell', 'GB'], + ['AZN', 'AstraZeneca', 'GB'], + ['HSBA', 'HSBC Holdings', 'GB'], + ['ULVR', 'Unilever', 'GB'], + ['LSEG', 'London Stock Exchange Group', 'GB'], +]) + +const europeanMarketCodes = Object.freeze([ + 'NL', + 'DE', + 'FR', + 'IT', + 'ES', + 'CH', + 'DK', + 'SE', + 'FI', + 'GB', +]) + +const europeanMarketGroups = Object.freeze( + europeanMarketCodes.map((market) => + europeanInstruments.filter(([, , instrumentMarket]) => + Object.is(instrumentMarket, market), + ), + ), +) + +const interleavedEuropeanInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...europeanMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + europeanMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const southKoreanInstruments = Object.freeze([ + ['005930', 'Samsung Electronics', 'KR'], + ['000660', 'SK hynix', 'KR'], + ['373220', 'LG Energy Solution', 'KR'], + ['207940', 'Samsung Biologics', 'KR'], + ['005380', 'Hyundai Motor', 'KR'], + ['000270', 'Kia', 'KR'], + ['068270', 'Celltrion', 'KR'], + ['105560', 'KB Financial Group', 'KR'], + ['055550', 'Shinhan Financial Group', 'KR'], + ['035420', 'NAVER', 'KR'], + ['035720', 'Kakao', 'KR'], + ['006400', 'Samsung SDI', 'KR'], + ['051910', 'LG Chem', 'KR'], + ['012330', 'Hyundai Mobis', 'KR'], + ['066570', 'LG Electronics', 'KR'], +]) + +const japaneseInstruments = Object.freeze([ + ['8306', 'Mitsubishi UFJ Financial Group', 'JP'], + ['7203', 'Toyota Motor', 'JP'], + ['6501', 'Hitachi', 'JP'], + ['8316', 'Sumitomo Mitsui Financial Group', 'JP'], + ['6758', 'Sony Group', 'JP'], + ['8058', 'Mitsubishi Corporation', 'JP'], + ['9984', 'SoftBank Group', 'JP'], + ['8035', 'Tokyo Electron', 'JP'], + ['8411', 'Mizuho Financial Group', 'JP'], + ['8031', 'Mitsui & Co.', 'JP'], + ['6861', 'Keyence', 'JP'], + ['7974', 'Nintendo', 'JP'], + ['6098', 'Recruit Holdings', 'JP'], + ['9432', 'Nippon Telegraph and Telephone', 'JP'], + ['4063', 'Shin-Etsu Chemical', 'JP'], +]) + +const hongKongInstruments = Object.freeze([ + ['0700', 'Tencent Holdings', 'HK'], + ['9988', 'Alibaba Group', 'HK'], + ['1810', 'Xiaomi', 'HK'], + ['3690', 'Meituan', 'HK'], + ['0941', 'China Mobile', 'HK'], + ['1211', 'BYD Company', 'HK'], + ['1299', 'AIA Group', 'HK'], + ['0388', 'Hong Kong Exchanges and Clearing', 'HK'], + ['0005', 'HSBC Holdings', 'HK'], + ['2318', 'Ping An Insurance', 'HK'], +]) + +const canadianInstruments = Object.freeze([ + ['RY', 'Royal Bank of Canada', 'CA'], + ['TD', 'Toronto-Dominion Bank', 'CA'], + ['SHOP', 'Shopify', 'CA'], + ['ENB', 'Enbridge', 'CA'], + ['CNR', 'Canadian National Railway', 'CA'], + ['CP', 'Canadian Pacific Kansas City', 'CA'], + ['BMO', 'Bank of Montreal', 'CA'], + ['CSU', 'Constellation Software', 'CA'], +]) + +const australianInstruments = Object.freeze([ + ['BHP', 'BHP Group', 'AU'], + ['CBA', 'Commonwealth Bank of Australia', 'AU'], + ['CSL', 'CSL', 'AU'], + ['NAB', 'National Australia Bank', 'AU'], + ['WBC', 'Westpac Banking Corporation', 'AU'], + ['ANZ', 'ANZ Group Holdings', 'AU'], + ['WES', 'Wesfarmers', 'AU'], + ['MQG', 'Macquarie Group', 'AU'], +]) + +const internationalMarketGroups = Object.freeze([ + interleavedEuropeanInstruments, + southKoreanInstruments, + japaneseInstruments, + hongKongInstruments, + canadianInstruments, + australianInstruments, +]) + +export const internationalInstruments = Object.freeze( + Array.from( + { + length: Math.max( + ...internationalMarketGroups.map((instruments) => instruments.length), + ), + }, + (_, index) => + internationalMarketGroups + .map((instruments) => instruments[index]) + .filter(Boolean), + ).flat(), +) + +const INTERNATIONAL_INSERTION_INTERVAL = 3 + +/** + * U.S. and international instruments are interleaved so ordinary benchmark + * sizes exercise multiple symbol formats and market labels. + */ +export const globalInstruments = Object.freeze( + marketInstruments.flatMap((instrument, index) => { + const internationalInstrument = + index % INTERNATIONAL_INSERTION_INTERVAL === 0 + ? internationalInstruments[index / INTERNATIONAL_INSERTION_INTERVAL] + : undefined + + return internationalInstrument + ? [instrument, internationalInstrument] + : [instrument] + }), +) as unknown as ReadonlyArray diff --git a/examples/preact/realtime-trading/src/feed/use-market-feed-controller.ts b/examples/preact/realtime-trading/src/feed/use-market-feed-controller.ts new file mode 100644 index 0000000000..29196b8773 --- /dev/null +++ b/examples/preact/realtime-trading/src/feed/use-market-feed-controller.ts @@ -0,0 +1,10 @@ +import { useEffect, useState } from 'preact/hooks' +import { MarketFeedController } from './market-feed-controller' + +export function useMarketFeedController(): MarketFeedController { + const [controller] = useState(() => new MarketFeedController()) + + useEffect(() => controller.start(), [controller]) + + return controller +} diff --git a/examples/preact/realtime-trading/src/feed/worker/market-feed-engine.ts b/examples/preact/realtime-trading/src/feed/worker/market-feed-engine.ts new file mode 100644 index 0000000000..fbd9c369c0 --- /dev/null +++ b/examples/preact/realtime-trading/src/feed/worker/market-feed-engine.ts @@ -0,0 +1,177 @@ +import { globalInstruments } from '../market-instruments.ts' +import type { + MarketQuoteSnapshot, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const INITIAL_MARKET_SEED = 0x4d41524b +const LIVE_FEED_SEED = 0x5449434b + +export class MarketFeedEngine { + #quotes: Array = [] + #lastHistorySampledAt = new Uint32Array(0) + #random = createRandom(2_026) + #rowCursor = 0 + #tickIndex = 0 + + reset(count: number): Array { + const random = createRandom(INITIAL_MARKET_SEED ^ count) + const createdAt = Date.now() + + this.#quotes = Array.from({ length: count }, (_, index) => { + const [baseSymbol, company, market] = + globalInstruments[index % globalInstruments.length] + const series = Math.floor(index / globalInstruments.length) + const symbol = series === 0 ? baseSymbol : `${baseSymbol}${series}` + const previousClose = roundPrice(20 + random() * 480) + const open = roundPrice(previousClose * (1 + (random() - 0.5) * 0.016)) + const spread = Math.max(0.01, open * (0.0002 + random() * 0.0004)) + const history = Array.from({ length: 24 }, (_, historyIndex) => + roundPrice( + open * + (1 + Math.sin(historyIndex / 4) * 0.002 + (random() - 0.5) * 0.001), + ), + ) + const volume = Math.floor(50_000 + random() * 2_000_000) + const lastSize = Math.floor(10 + random() * 5_000) + + return { + id: `instrument-${index}`, + symbol, + company, + venue: market, + previousClose, + open, + high: open, + low: open, + price: open, + bid: roundPrice(open - spread / 2), + ask: roundPrice(open + spread / 2), + bidSize: Math.floor(100 + random() * 25_000), + askSize: Math.floor(100 + random() * 25_000), + lastSize, + lastMove: 0, + lastUpdatedAt: createdAt, + volume, + turnover: roundMoney(open * volume), + history, + } + }) + + this.#random = createRandom(LIVE_FEED_SEED ^ count) + this.#rowCursor = 0 + this.#lastHistorySampledAt = new Uint32Array(count) + this.#lastHistorySampledAt.fill(createdAt >>> 0) + + return this.#quotes.map((quote) => ({ + ...quote, + history: [...quote.history], + })) + } + + applyTicks( + tickCount: number, + updateSparklines: boolean, + sparklineSampleIntervalMs: number, + ): Array { + if (this.#quotes.length === 0 || tickCount <= 0) return [] + + const updatedAt = Date.now() + const sampledAt = updatedAt >>> 0 + const sampleIntervalMs = Math.max(16, sparklineSampleIntervalMs) + const updatedQuotes = new Map() + const stride = 97 + + this.#tickIndex = 0 + while (this.#tickIndex < tickCount) { + this.#rowCursor = (this.#rowCursor + stride) % this.#quotes.length + const quote = this.#quotes[this.#rowCursor] + const lastSampledAt = this.#lastHistorySampledAt[this.#rowCursor] + const shouldUpdateHistory = + updateSparklines && + (sampledAt - lastSampledAt) >>> 0 >= sampleIntervalMs + + if (shouldUpdateHistory) { + this.#lastHistorySampledAt[this.#rowCursor] = sampledAt + } + + this.#applyTick(quote, shouldUpdateHistory, updatedAt) + + const previousUpdate = updatedQuotes.get(this.#rowCursor) + updatedQuotes.set(this.#rowCursor, { + index: this.#rowCursor, + price: quote.price, + bid: quote.bid, + ask: quote.ask, + bidSize: quote.bidSize, + askSize: quote.askSize, + lastSize: quote.lastSize, + lastMove: quote.lastMove, + lastUpdatedAt: quote.lastUpdatedAt, + high: quote.high, + low: quote.low, + volume: quote.volume, + turnover: quote.turnover, + ...(shouldUpdateHistory || previousUpdate?.history + ? { history: [...quote.history] } + : {}), + }) + this.#tickIndex++ + } + + return [...updatedQuotes.values()] + } + + #applyTick( + quote: MarketQuoteSnapshot, + updateHistory: boolean, + updatedAt: number, + ): void { + const previousPrice = quote.price + const volatility = 0.00015 + this.#random() * 0.0012 + const move = previousPrice * (this.#random() - 0.495) * volatility + const nextPrice = roundPrice(Math.max(0.1, previousPrice + move)) + const spread = Math.max( + 0.01, + nextPrice * (0.00015 + this.#random() * 0.0005), + ) + + quote.lastMove = nextPrice - previousPrice + quote.price = nextPrice + quote.high = Math.max(quote.high, nextPrice) + quote.low = Math.min(quote.low, nextPrice) + quote.bid = roundPrice(nextPrice - spread / 2) + quote.ask = roundPrice(nextPrice + spread / 2) + quote.bidSize = Math.floor(100 + this.#random() * 25_000) + quote.askSize = Math.floor(100 + this.#random() * 25_000) + quote.lastSize = Math.floor(10 + this.#random() * 5_000) + quote.lastUpdatedAt = updatedAt + quote.volume += quote.lastSize + quote.turnover = roundMoney(quote.turnover + nextPrice * quote.lastSize) + + if (updateHistory) { + quote.history = [...quote.history.slice(-23), nextPrice] + } + } +} + +function createRandom(seed: number): () => number { + const runtime = { state: seed >>> 0 } + return () => { + runtime.state += 0x6d2b79f5 + const stateValue = runtime.state + const firstMix = Math.imul(stateValue ^ (stateValue >>> 15), stateValue | 1) + const secondMix = + firstMix + Math.imul(firstMix ^ (firstMix >>> 7), firstMix | 61) + const value = firstMix ^ secondMix + return ((value ^ (value >>> 14)) >>> 0) / 4_294_967_296 + } +} + +function roundPrice(value: number): number { + return Math.round(value * 100) / 100 +} + +function roundMoney(value: number): number { + return Math.round(value * 100) / 100 +} diff --git a/examples/preact/realtime-trading/src/feed/worker/market-feed-protocol.ts b/examples/preact/realtime-trading/src/feed/worker/market-feed-protocol.ts new file mode 100644 index 0000000000..21997ec89c --- /dev/null +++ b/examples/preact/realtime-trading/src/feed/worker/market-feed-protocol.ts @@ -0,0 +1,70 @@ +export interface MarketQuoteSnapshot { + id: string + symbol: string + company: string + venue: string + previousClose: number + open: number + high: number + low: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + volume: number + turnover: number + history: Array +} + +export interface MarketQuoteUpdate { + index: number + price: number + bid: number + ask: number + bidSize: number + askSize: number + lastSize: number + lastMove: number + lastUpdatedAt: number + high: number + low: number + volume: number + turnover: number + history?: Array +} + +export type MarketFeedCommand = + | { + type: 'start' + rowCount: number + running: boolean + ticksPerSecond: number + publishIntervalMs: number + updateSparklines: boolean + sparklineSampleIntervalMs: number + } + | { type: 'set-running'; running: boolean } + | { type: 'set-rate'; ticksPerSecond: number } + | { type: 'set-publish-interval'; intervalMs: number } + | { type: 'set-sparklines'; enabled: boolean } + | { type: 'set-sparkline-interval'; intervalMs: number } + | { type: 'reset'; rowCount: number } + | { type: 'burst'; tickCount: number } + +export type MarketFeedEvent = + | { + type: 'snapshot' + sessionId: number + quotes: Array + } + | { + type: 'updates' + sessionId: number + tickCount: number + coalescedUpdateCount: number + updates: Array + } diff --git a/examples/preact/realtime-trading/src/feed/worker/market-feed.worker.ts b/examples/preact/realtime-trading/src/feed/worker/market-feed.worker.ts new file mode 100644 index 0000000000..2b7a642fd9 --- /dev/null +++ b/examples/preact/realtime-trading/src/feed/worker/market-feed.worker.ts @@ -0,0 +1,143 @@ +import { initialMarketFeedConfig } from '../market-feed-config' +import { MarketFeedEngine } from './market-feed-engine' +import type { + MarketFeedCommand, + MarketFeedEvent, + MarketQuoteUpdate, +} from './market-feed-protocol' + +const engine = new MarketFeedEngine() +const pendingUpdates = new Map() +const runtime = { + sessionId: 0, + pendingTickCount: 0, + pendingCoalescedUpdateCount: 0, + initialized: false, + running: true, + ticksPerSecond: initialMarketFeedConfig.targetSamplesPerSecond, + publishIntervalMs: initialMarketFeedConfig.publishIntervalMs, + publishTimerId: null as ReturnType | null, + updateSparklines: initialMarketFeedConfig.updateSparklines, + sparklineSampleIntervalMs: initialMarketFeedConfig.sparklineSampleIntervalMs, + tickBudget: 0, + lastTickAt: performance.now(), +} + +addEventListener('message', ({ data }: MessageEvent) => { + switch (data.type) { + case 'start': + runtime.running = data.running + runtime.ticksPerSecond = data.ticksPerSecond + runtime.publishIntervalMs = data.publishIntervalMs + runtime.updateSparklines = data.updateSparklines + runtime.sparklineSampleIntervalMs = data.sparklineSampleIntervalMs + restartPublishTimer() + reset(data.rowCount) + break + case 'set-running': + runtime.running = data.running + break + case 'set-rate': + runtime.ticksPerSecond = data.ticksPerSecond + break + case 'set-publish-interval': + runtime.publishIntervalMs = Math.max(4, data.intervalMs) + restartPublishTimer() + break + case 'set-sparklines': + runtime.updateSparklines = data.enabled + break + case 'set-sparkline-interval': + runtime.sparklineSampleIntervalMs = Math.max(16, data.intervalMs) + break + case 'reset': + reset(data.rowCount) + break + case 'burst': + produceTicks(data.tickCount) + flush() + break + } +}) + +setInterval(() => { + const now = performance.now() + const elapsed = Math.min(100, Math.max(0, now - runtime.lastTickAt)) + runtime.lastTickAt = now + + if (runtime.initialized && runtime.running) { + runtime.tickBudget += (runtime.ticksPerSecond * elapsed) / 1_000 + const tickCount = Math.floor(runtime.tickBudget) + runtime.tickBudget -= tickCount + produceTicks(tickCount) + } +}, 16) + +restartPublishTimer() + +function reset(rowCount: number): void { + runtime.initialized = true + runtime.sessionId++ + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + runtime.tickBudget = 0 + runtime.lastTickAt = performance.now() + + post({ + type: 'snapshot', + sessionId: runtime.sessionId, + quotes: engine.reset(rowCount), + }) +} + +function produceTicks(tickCount: number): void { + if (!runtime.initialized || tickCount <= 0) return + + runtime.pendingTickCount += tickCount + for (const update of engine.applyTicks( + tickCount, + runtime.updateSparklines, + runtime.sparklineSampleIntervalMs, + )) { + const previousUpdate = pendingUpdates.get(update.index) + if (previousUpdate) runtime.pendingCoalescedUpdateCount++ + pendingUpdates.set(update.index, { + ...update, + ...(update.history || !previousUpdate?.history + ? {} + : { history: previousUpdate.history }), + }) + } +} + +function flush(): void { + if (runtime.pendingTickCount === 0) return + + const message: MarketFeedEvent = { + type: 'updates', + sessionId: runtime.sessionId, + tickCount: runtime.pendingTickCount, + coalescedUpdateCount: runtime.pendingCoalescedUpdateCount, + updates: [...pendingUpdates.values()], + } + + runtime.pendingTickCount = 0 + runtime.pendingCoalescedUpdateCount = 0 + pendingUpdates.clear() + post(message) +} + +function restartPublishTimer(): void { + if (runtime.publishTimerId !== null) { + clearInterval(runtime.publishTimerId) + } + runtime.publishTimerId = setInterval( + flush, + Math.max(4, runtime.publishIntervalMs), + ) +} + +function post(event: MarketFeedEvent): void { + postMessage(event) +} diff --git a/examples/preact/realtime-trading/src/index.css b/examples/preact/realtime-trading/src/index.css new file mode 100644 index 0000000000..7f670c5626 --- /dev/null +++ b/examples/preact/realtime-trading/src/index.css @@ -0,0 +1,1007 @@ +:root { + color-scheme: dark; + --font-ui: + Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, + 'Segoe UI', sans-serif; + --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace; + font-family: var(--font-ui); + font-synthesis: none; + --background: #050505; + --panel: #080808; + --panel-raised: #111111; + --panel-hover: #181818; + --surface-bar: #080808; + --surface-toolbar: #0d0d0d; + --surface-table: #050505; + --surface-header: #101010; + --surface-control: #151515; + --border: #303030; + --border-soft: #242424; + --border-strong: #4a4a4a; + --text: #e7ebf0; + --text-strong: #ffffff; + --text-inverse: #f7f9fb; + --muted: #737982; + --blue: #62a9ff; + --blue-soft: #a9d0ff; + --green: #42e488; + --red: #ff646b; + --amber: #dfb465; + --depth-bid: #315774; + --depth-ask: #634049; + --row-alt: rgb(255 255 255 / 1.8%); + --row-selected: rgb(66 132 214 / 16%); + --control-border: #354456; + --control-hover: #192431; + --sidebar-width: 18rem; + --shell-bar-height: 2.625rem; + --metrics-height: 3.5rem; + --statusbar-height: 1.625rem; + --table-header-height: 2rem; + --table-row-height: 2rem; + --shell-inline-padding: 0.75rem; + --table-cell-inline-padding: 0.6rem; + --control-radius: 1px; +} + +* { + box-sizing: border-box; +} + +html, +body { + min-width: 320px; + min-height: 100%; + margin: 0; + background: var(--background); +} + +body { + color: var(--text); +} + +button, +select, +input { + font: inherit; +} + +button, +select { + color: var(--text); + background: var(--panel-raised); + border: 1px solid var(--control-border); + border-radius: var(--control-radius); +} + +button { + padding: 0.5rem 0.65rem; + cursor: pointer; + font-size: 0.72rem; + font-weight: 650; + letter-spacing: 0.025em; +} + +button:hover { + background: var(--control-hover); + border-color: var(--border-strong); +} + +button:focus-visible, +select:focus-visible, +input:focus-visible { + outline: 1px solid var(--blue); + outline-offset: 1px; +} + +select { + width: 100%; + padding: 0.45rem 0.55rem; + font-size: 0.75rem; +} + +.trading-terminal { + --active-sidebar-width: var(--sidebar-width); + display: grid; + width: 100%; + height: 100dvh; + min-height: 0; + overflow: hidden; + background: var(--background); + grid-template-areas: + 'header sidebar' + 'content sidebar' + 'footer sidebar'; + grid-template-columns: minmax(0, 1fr) var(--active-sidebar-width); + grid-template-rows: auto minmax(0, 1fr) auto; + transition: grid-template-columns 160ms ease; +} + +.trading-terminal.is-sidebar-collapsed { + --active-sidebar-width: 0px; +} + +.shell-header { + display: flex; + min-width: 0; + flex-direction: column; + grid-area: header; +} + +.app-bar { + display: flex; + min-height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + background: var(--surface-bar); + border-bottom: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.68rem; + letter-spacing: 0.045em; +} + +.brand, +.header-actions, +.feed-status { + display: flex; + align-items: center; +} + +.brand { + gap: 0.65rem; + color: var(--text-strong); +} + +.header-actions { + gap: 0.75rem; +} + +.sidebar-toggle { + display: grid; + width: 1.9rem; + height: 1.9rem; + padding: 0; + place-items: center; + color: var(--muted); + background: transparent; + border-color: transparent; +} + +.sidebar-toggle:hover { + color: var(--text-strong); + background: var(--surface-control); + border-color: var(--border); +} + +.sidebar-toggle svg { + width: 1rem; + height: 1rem; + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-width: 1.4; +} + +.feed-status { + gap: 0.4rem; + color: var(--muted); +} + +.feed-status.is-running { + color: var(--green); +} + +.status-dot { + width: 6px; + height: 6px; + background: var(--muted); + border-radius: 50%; +} + +.feed-status.is-running .status-dot { + background: var(--green); +} + +.development-warning { + flex: 0 0 auto; + padding: 0.3rem 0.75rem; + color: var(--amber); + background: color-mix(in srgb, var(--amber) 8%, var(--background)); + border-bottom: 1px solid color-mix(in srgb, var(--amber) 24%, var(--border)); + font-family: var(--font-mono); + font-size: 0.62rem; + letter-spacing: 0.04em; +} + +.market-panel { + display: flex; + min-width: 0; + min-height: 0; + flex-direction: column; + background: var(--panel); + grid-area: content; +} + +.metrics-strip { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + background: var(--border); + border-bottom: 1px solid var(--border); + gap: 1px; +} + +.metrics-strip h2 { + margin: 0; + padding: 0.65rem var(--shell-inline-padding) 0.45rem; + color: var(--muted); + background: var(--surface-table); + font-size: 0.58rem; + grid-column: 1 / -1; + letter-spacing: 0.075em; +} + +.metrics-strip article { + min-width: 0; + min-height: 4.25rem; + padding: 0.5rem var(--shell-inline-padding); + background: var(--surface-bar); +} + +.metrics-strip span, +.metrics-strip small { + display: block; + color: var(--muted); + font-size: 0.56rem; + letter-spacing: 0.045em; + line-height: 1.35; +} + +.metrics-strip strong { + display: block; + margin: 0.12rem 0 0.08rem; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.88rem; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +.metrics-strip strong.metric-alert { + color: var(--amber); +} + +.table-scroll { + flex: 1; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +table { + min-width: 100%; + border-spacing: 0; + table-layout: fixed; + font-family: var(--font-ui); + font-size: 0.78rem; + font-variant-numeric: tabular-nums; +} + +.trading-data-grid { + display: grid; +} + +.trading-data-grid thead, +.trading-data-grid tbody { + display: grid; +} + +.trading-data-grid tbody { + -webkit-user-select: none; + user-select: none; +} + +.trading-data-grid thead > tr, +.trading-data-grid tbody > tr { + display: flex; + width: 100%; +} + +.trading-data-grid tbody > tr { + min-height: var(--table-row-height); + content-visibility: auto; + contain-intrinsic-block-size: var(--table-row-height); +} + +.trading-data-grid th, +.trading-data-grid td { + flex: 0 0 auto; +} + +thead { + position: sticky; + z-index: 2; + top: 0; +} + +th { + height: var(--table-header-height); + padding: 0 var(--table-cell-inline-padding); + color: var(--muted); + background: var(--surface-header); + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border); + font-size: 0.7rem; + font-weight: 500; + letter-spacing: 0.005em; + text-align: left; + white-space: nowrap; +} + +th.column-group-header { + color: #666b72; + font-size: 0.72rem; + font-weight: 500; + text-align: center; +} + +thead tr:first-child th.column-group-header { + color: #777d85; + font-size: 0.76rem; +} + +th.numeric-header { + text-align: right; +} + +td { + height: var(--table-row-height); + padding: 0 var(--table-cell-inline-padding); + overflow: hidden; + color: #eef1f5; + border-right: 1px solid var(--border-soft); + border-bottom: 1px solid var(--border-soft); + text-align: right; + text-overflow: ellipsis; + white-space: nowrap; +} + +th:last-child, +td:last-child { + border-right: 0; +} + +td[data-column-id='market'], +td[data-column-id='name'], +td[data-column-id='symbol'] { + text-align: left; +} + +td[data-column-id='market'] { + color: var(--blue); + font-weight: 550; +} + +td[data-column-id='name'] { + color: var(--text-strong); +} + +td[data-column-id='symbol'] { + color: #d8dde4; + font-weight: 600; +} + +tbody tr:nth-child(even) { + background: var(--row-alt); +} + +tbody tr:hover { + background: var(--panel-hover); +} + +tbody tr[data-symbol-selected='true'] { + background: var(--row-selected); + box-shadow: inset 2px 0 0 var(--blue); +} + +.table-scroll:focus { + outline: none; +} + +th { + position: relative; +} + +.leaf-header-content { + display: flex; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + height: 100%; + align-items: stretch; + margin-inline: calc(-1 * var(--table-cell-inline-padding)); +} + +.column-drag-handle, +.sort-header-button { + min-width: 0; + height: 100%; + padding: 0; + color: inherit; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-weight: inherit; + letter-spacing: inherit; +} + +.column-drag-handle { + flex: 0 0 1.05rem; + color: var(--muted); + cursor: grab; + opacity: 0.35; + font-size: 0.56rem; + letter-spacing: -0.32rem; + text-align: center; +} + +.column-drag-handle:active { + cursor: grabbing; +} + +th:hover .column-drag-handle, +.column-drag-handle:focus-visible { + opacity: 0.9; +} + +.column-drag-handle:hover, +.sort-header-button:hover { + background: rgb(255 255 255 / 4%); + border-color: transparent; +} + +th.is-column-dragging { + opacity: 0.45; +} + +th.is-column-drop-target { + background: rgb(50 139 255 / 16%); + box-shadow: inset 4px 0 0 var(--blue); +} + +th.is-column-drop-target::before { + position: absolute; + z-index: 6; + top: -1px; + bottom: -1px; + left: -2px; + width: 4px; + background: #62a9ff; + box-shadow: + 0 0 0 1px rgb(0 0 0 / 55%), + 0 0 12px rgb(70 151 255 / 90%); + content: ''; + pointer-events: none; +} + +.sort-header-button { + display: flex; + min-width: 0; + flex: 1; + align-items: center; + justify-content: flex-start; + gap: 0.3rem; + padding-inline: 0.25rem var(--table-cell-inline-padding); + cursor: default; + text-align: inherit; +} + +.numeric-header .sort-header-button { + justify-content: flex-end; +} + +.sort-header-button.is-sortable { + cursor: pointer; +} + +.sort-header-button:disabled { + opacity: 1; +} + +.header-label { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.sort-indicator { + flex: 0 0 auto; + color: #66717e; + font-size: 0.72rem; +} + +.sort-indicator.is-active { + color: var(--blue-soft); +} + +.column-resize-handle { + position: absolute; + z-index: 3; + top: 0; + right: -3px; + width: 7px; + height: 100%; + cursor: col-resize; + touch-action: none; + user-select: none; +} + +.column-resize-handle::after { + position: absolute; + top: 20%; + right: 3px; + width: 1px; + height: 60%; + background: var(--border-strong); + content: ''; + opacity: 0; +} + +th:hover > .column-resize-handle::after, +.column-resize-handle.is-resizing::after { + background: var(--blue); + opacity: 1; +} + +tbody tr[aria-selected='true'] { + background: rgb(76 145 228 / 13%); +} + +td[aria-selected='true'] { + position: relative; + background: rgb(70 139 222 / 12%); +} + +td[data-cell-focused='true'] { + background: rgb(70 139 222 / 21%); +} + +td[aria-selected='true']::after { + position: absolute; + z-index: 1; + inset: 0; + border: 1px solid transparent; + content: ''; + pointer-events: none; +} + +td[data-selection-top='true']::after { + border-top-color: var(--blue); +} + +td[data-selection-right='true']::after { + border-right-color: var(--blue); +} + +td[data-selection-bottom='true']::after { + border-bottom-color: var(--blue); +} + +td[data-selection-left='true']::after { + border-left-color: var(--blue); +} + +.price-button { + min-width: 4.5rem; + padding: 0; + background: transparent; + border: 0; + border-radius: 0; + font-family: inherit; + font-size: inherit; + font-variant-numeric: tabular-nums; + font-weight: 600; + text-align: right; +} + +.price-button:hover { + background: transparent; + text-decoration: underline; + text-underline-offset: 2px; +} + +.move-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.move-cell.quote-up, +.percent-change-cell.quote-up { + background: color-mix(in srgb, var(--green) 7%, transparent); +} + +.move-cell.quote-down, +.percent-change-cell.quote-down { + background: color-mix(in srgb, var(--red) 7%, transparent); +} + +.percent-change-cell { + display: block; + width: calc(100% + 2 * var(--table-cell-inline-padding)); + margin-inline: calc(-1 * var(--table-cell-inline-padding)); + padding-inline: var(--table-cell-inline-padding); + line-height: var(--table-row-height); + text-align: right; +} + +.spread-cell { + display: flex; + align-items: baseline; + justify-content: flex-end; + gap: 0.35rem; + color: var(--text); +} + +.spread-cell small { + min-width: 2.8rem; + color: var(--muted); + font-size: 0.55rem; +} + +.spread-cell.spread-wide, +.spread-cell.spread-wide small { + color: var(--amber); +} + +.depth-cell { + position: relative; + display: flex; + height: 17px; + overflow: hidden; + background: var(--surface-control); +} + +.depth-bid, +.depth-ask { + height: 100%; + opacity: 0.78; +} + +.depth-bid { + background: var(--depth-bid); + border-right: 1px solid var(--panel); +} + +.depth-ask { + background: var(--depth-ask); +} + +.depth-values { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 0.28rem; + color: var(--text-strong); + font-size: 0.57rem; + text-shadow: 0 1px var(--background); +} + +.quote-age { + color: var(--muted); +} + +.quote-age-warm { + color: var(--amber); +} + +.quote-age-stale { + color: var(--red); +} + +.quote-up { + color: var(--green); +} + +.quote-down { + color: var(--red); +} + +.sparkline { + display: block; + width: 100%; + height: 1.35rem; + margin-left: auto; + color: var(--blue-soft); + overflow: visible; +} + +.sparkline.quote-up { + color: var(--green); +} + +.sparkline.quote-down { + color: var(--red); +} + +.sparkline polyline { + fill: none; + stroke: currentColor; + stroke-linecap: square; + stroke-linejoin: miter; + stroke-width: 1.25; + vector-effect: non-scaling-stroke; +} + +.market-statusbar { + display: flex; + flex: 0 0 var(--statusbar-height); + min-height: var(--statusbar-height); + gap: 1.1rem; + align-items: center; + padding: 0 0.65rem; + color: var(--muted); + background: var(--surface-bar); + border-top: 1px solid var(--border); + font-family: var(--font-mono); + font-size: 0.56rem; + grid-area: footer; + letter-spacing: 0.035em; +} + +.market-statusbar strong { + margin-left: 0.25rem; + color: var(--text); + font-weight: 500; +} + +.sidebar-slot { + width: var(--sidebar-width); + min-width: 0; + min-height: 0; + overflow: hidden; + background: var(--surface-table); + border-left: 1px solid var(--border); + grid-area: sidebar; + transition: + opacity 120ms ease, + transform 160ms ease, + visibility 160ms; +} + +.is-sidebar-collapsed .sidebar-slot { + visibility: hidden; + opacity: 0; + pointer-events: none; + transform: translateX(100%); +} + +.configurator { + width: 100%; + height: 100%; + min-height: 0; + overflow: auto; + background: var(--surface-table); +} + +.configurator > header { + display: flex; + height: var(--shell-bar-height); + align-items: center; + justify-content: space-between; + padding: 0 var(--shell-inline-padding); + color: var(--text-strong); + background: var(--surface-toolbar); + border-bottom: 1px solid var(--border); + font-size: 0.65rem; + font-weight: 700; + letter-spacing: 0.055em; +} + +.configurator > header small { + color: var(--muted); + font-size: 0.54rem; + font-weight: 500; +} + +.config-section { + display: grid; + gap: 0.7rem; + padding: 0.8rem var(--shell-inline-padding); + border-bottom: 1px solid var(--border); +} + +.config-section h2 { + margin: 0; + color: var(--muted); + font-size: 0.58rem; + letter-spacing: 0.075em; +} + +.primary-action { + width: 100%; + color: var(--text-inverse); + background: var(--blue); + border-color: var(--blue-soft); +} + +.primary-action:hover { + background: var(--blue-soft); + border-color: var(--text-strong); +} + +.field { + display: grid; + gap: 0.35rem; + color: var(--text); + font-size: 0.66rem; +} + +.rate-field > span { + display: flex; + justify-content: space-between; +} + +.rate-field strong { + color: var(--text); + font-family: var(--font-mono); + font-weight: 500; +} + +.field small { + color: var(--muted); + font-family: var(--font-mono); + font-size: 0.55rem; +} + +input[type='range'] { + width: 100%; + margin: 0; + accent-color: var(--blue); +} + +.toggle-field { + display: flex; + gap: 0.5rem; + align-items: flex-start; + color: var(--text); + font-size: 0.66rem; + line-height: 1.3; +} + +.toggle-field input { + margin: 0.12rem 0 0; + accent-color: var(--blue); +} + +.toggle-field small { + display: block; + margin-top: 0.14rem; + color: var(--muted); + font-size: 0.57rem; +} + +.action-grid { + display: grid; + grid-template-columns: 1fr; + gap: 0.4rem; +} + +.diagnostics dl, +.selected-instrument dl { + display: grid; + gap: 0; + margin: 0; +} + +.diagnostics dl > div, +.selected-instrument dl > div { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 24px; + border-bottom: 1px solid var(--border-soft); +} + +.diagnostics dl > div:last-child, +.selected-instrument dl > div:last-child { + border-bottom: 0; +} + +.diagnostics dl > div:has(dd[data-testid$='-breakdown']) { + display: grid; + grid-template-columns: minmax(0, 1fr); + align-content: center; + padding-block: 0.28rem; +} + +.diagnostics dd[data-testid$='-breakdown'] { + width: 100%; + overflow-x: auto; + padding-block: 0.12rem; + white-space: nowrap; + scrollbar-width: thin; +} + +dt { + color: var(--muted); + font-size: 0.61rem; +} + +dd { + margin: 0; + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.62rem; +} + +.selection { + display: flex; + align-items: flex-start; + justify-content: space-between; +} + +.selection div { + display: grid; + gap: 0.18rem; +} + +.selection strong { + color: var(--text-strong); + font-family: var(--font-mono); + font-size: 0.85rem; +} + +.selection span, +.selection small, +.selected-instrument p { + color: var(--muted); + font-size: 0.61rem; +} + +.selected-instrument p { + margin: 0; + line-height: 1.45; +} + +@media (max-width: 980px) { + :root { + --sidebar-width: 15.625rem; + } +} + +@media (max-width: 720px) { + .trading-terminal { + --active-sidebar-width: 0px; + height: 100dvh; + min-height: 0; + overflow: hidden; + } + + .market-panel { + min-height: 0; + } + + .table-scroll { + min-height: 0; + } + + .sidebar-slot { + position: fixed; + z-index: 20; + top: 0; + right: 0; + bottom: 0; + width: min(var(--sidebar-width), calc(100vw - 2.75rem)); + box-shadow: -18px 0 42px rgb(0 0 0 / 48%); + } + + .is-sidebar-collapsed .sidebar-slot { + box-shadow: none; + } +} diff --git a/examples/preact/realtime-trading/src/main.tsx b/examples/preact/realtime-trading/src/main.tsx new file mode 100644 index 0000000000..ff31652405 --- /dev/null +++ b/examples/preact/realtime-trading/src/main.tsx @@ -0,0 +1,10 @@ +import { render } from 'preact' +import { App } from './App' +import './index.css' + +const rootElement = document.getElementById('root') +if (!rootElement) throw new Error('Failed to find the root element') + +// StrictMode is intentionally omitted: its development-only mount replay would +// contaminate the component lifecycle counters used by this benchmark. +render(, rootElement) diff --git a/examples/preact/realtime-trading/src/shell/TradingShell.tsx b/examples/preact/realtime-trading/src/shell/TradingShell.tsx new file mode 100644 index 0000000000..671e467563 --- /dev/null +++ b/examples/preact/realtime-trading/src/shell/TradingShell.tsx @@ -0,0 +1,615 @@ +import { shallow, useSelector } from '@tanstack/preact-store' +import { useState } from 'preact/hooks' +import { + feedSampleRateAt, + feedSampleRateIndex, + feedSampleRateOptions, +} from '../feed/feed-sample-rates' +import { + useMarketFeedController, + useTradingShellController, + useTradingShellState, +} from './trading-shell-context' +import { configuratorOptions } from './configurator-options' +import type { ComponentChildren } from 'preact' +import type { FeedMetrics } from '../benchmark/benchmark-monitor' + +const integerFormatter = new Intl.NumberFormat('en-US', { + maximumFractionDigits: 0, +}) +const rateFormatter = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +export function TradingShell(props: { children: ComponentChildren }) { + const [sidebarOpen, setSidebarOpen] = useState(true) + const toggleSidebar = () => setSidebarOpen((open) => !open) + + return ( +
+
+ + + {import.meta.env.DEV && ( + + )} +
+ +
+ {props.children} +
+ +
{sidebarOpen && }
+
+ ) +} + +function AppHeader(props: { + sidebarOpen: boolean + onSidebarToggle: () => void +}) { + const feed = useMarketFeedController() + const workerReady = useSelector(feed.workerReady) + const running = useSelector(feed.running) + return ( +
+
+ MARKET MONITOR +
+
+ + + +
+
+ ) +} + +function MarketStatusbar() { + const { lastBatchSize, lastUpdateCount, mountedCells, liveComponents } = + useTradingShellState( + (state) => ({ + lastBatchSize: state.metrics.lastBatchSize, + lastUpdateCount: state.metrics.lastUpdateCount, + mountedCells: state.mountedCells, + liveComponents: state.liveComponents, + }), + { compare: shallow }, + ) + return ( +
+ + MESSAGE SAMPLES {formatInteger(lastBatchSize)} + + + CHANGED ROWS {formatInteger(lastUpdateCount)} + + + HOSTS {formatInteger(mountedCells)} + + + COMPONENTS {formatInteger(liveComponents)} + +
+ ) +} + +function Configurator() { + const controller = useTradingShellController() + const feed = useMarketFeedController() + const running = useSelector(feed.running) + const instrumentCount = useSelector(feed.instrumentCount) + const targetTicksPerSecond = useSelector(feed.targetTicksPerSecond) + const publishIntervalMs = useSelector(feed.publishIntervalMs) + const updateSparklines = useSelector(feed.updateSparklines) + const sparklineSampleIntervalMs = useSelector(feed.sparklineSampleIntervalMs) + const rendererMode = useSelector(controller.renderAtoms.rendererMode) + const { actions } = controller + const feedActions = feed.actions + const { setRendererMode, resetMarket } = actions + const { + toggle, + setInstrumentCount, + setTargetRate, + setPublishInterval, + setSparklineUpdates, + setSparklineSampleInterval, + runBurst, + } = feedActions + + return ( + + ) +} + +function LiveHealth() { + const { metrics, longAnimationFramesSupported } = useTradingShellState( + (state) => ({ + metrics: state.metrics, + longAnimationFramesSupported: state.longAnimationFramesSupported, + }), + { compare: shallow }, + ) + return ( +
+

LIVE HEALTH

+
+ FRAME RATE (EST.) + + {metrics.estimatedFrameRate.toFixed(1)} + + rAF callbacks/s · rolling 1 s +
+
+ AVG COMMIT + + {formatMs(metrics.averageCommitLatencyMs)} + + snapshot → DOM · rolling 3 s +
+
+ LONG FRAMES + {longAnimationFramesSupported ? ( + <> + 0 ? 'metric-alert' : ''} + > + {metrics.longAnimationFrames} + + + since reset · worst {formatMs(metrics.worstLongAnimationFrameMs)} + + + ) : ( + <> + N/A + unsupported + + )} +
+
+ THROUGHPUT + + {formatRate(metrics.rowUpdatesPerSecond)} rows/s + + + {metrics.stateApplicationsPerSecond.toFixed(1)} snapshots/s · rows + deduplicated per snapshot + +
+
+ ) +} + +function Diagnostics() { + const { + metrics, + mountedCells, + liveComponents, + longAnimationFramesSupported, + } = useTradingShellState( + (state) => ({ + metrics: state.metrics, + mountedCells: state.mountedCells, + liveComponents: state.liveComponents, + longAnimationFramesSupported: state.longAnimationFramesSupported, + }), + { compare: shallow }, + ) + return ( +
+

DIAGNOSTICS

+
+
+
Worker samples / s
+
+ {formatRate(metrics.actualTicksPerSecond)} +
+
+
+
Changed rows / s
+
+ {formatRate(metrics.rowUpdatesPerSecond)} +
+
+
+
Worker messages / s
+
+ {metrics.workerMessagesPerSecond.toFixed(1)} +
+
+
+
State applies / s
+
+ {metrics.stateApplicationsPerSecond.toFixed(1)} +
+
+
+
Table DOM commits / s
+
+ {metrics.tableCommitsPerSecond.toFixed(1)} +
+
+
+
Commit latency p95 / max
+
+ {formatMs(metrics.p95CommitLatencyMs)} /{' '} + {formatMs(metrics.maxCommitLatencyMs)} +
+
+
+
Mounted cells
+
{formatInteger(mountedCells)}
+
+
+
Live components
+
{formatInteger(liveComponents)}
+
+
+
Created / destroyed
+
+ {formatInteger(metrics.componentsCreated)} /{' '} + {formatInteger(metrics.componentsDestroyed)} +
+
+
+
Renderer callbacks / s
+
+ {formatRate(metrics.cellRendererCallsPerSecond)} +
+
+
+
Component executions / s
+
+ {formatRate(metrics.componentRenderCallsPerSecond)} +
+
+
+
Executions by component / s
+
+ {formatInvocationRates(metrics.componentRenderRates)} +
+
+
+
Callbacks by column / s
+
+ {formatInvocationRates(metrics.cellRendererRates)} +
+
+
+
Observed MutationRecords / s
+
+ {formatRate(metrics.domMutationsPerSecond)} +
+
+
+
Core row model calls / s
+
+ {metrics.rowModelCallsPerSecond.toFixed(1)} +
+
+
+
Core row model avg / max
+
+ {formatMs(metrics.rowModelAverageMs)} /{' '} + {formatMs(metrics.rowModelMaxMs)} +
+
+
+
Visible rows
+
+ {formatInteger(metrics.visibleRows)} +
+
+
+
Worker messages
+
+ {formatInteger(metrics.workerMessages)} +
+
+
+
Worker-coalesced updates / s
+
+ {formatRate(metrics.supersededUpdatesPerSecond)} +
+
+
+
Last message samples / updated rows
+
+ {formatInteger(metrics.lastBatchSize)} /{' '} + {formatInteger(metrics.lastUpdateCount)} +
+
+
+
Commits > 16.7 ms since reset
+
{metrics.slowCommits}
+
+
+
Long animation frames
+
+ {longAnimationFramesSupported + ? formatInteger(metrics.longAnimationFrames) + : 'Unsupported'} +
+
+
+
+ JS heap (GC-sensitive) +
+
+ {metrics.heapMb === null + ? 'N/A' + : `${metrics.heapMb.toFixed(1)} MB`} +
+
+
+
+ ) +} + +function SelectedInstrument() { + const controller = useTradingShellController() + const feed = useMarketFeedController() + const selectedSymbol = useSelector(controller.renderAtoms.selectedSymbol) + const quotes = useSelector(feed.quotes) + const selectedQuote = feed.getQuoteBySymbol(quotes, selectedSymbol) + return ( +
+

SELECTED INSTRUMENT

+ {selectedQuote ? ( + <> +
+
+ {selectedQuote.symbol} + {selectedQuote.company} +
+ {selectedQuote.venue} +
+
+
+
Last
+
{selectedQuote.price.toFixed(2)}
+
+
+
Bid / ask
+
+ {selectedQuote.bid.toFixed(2)} / {selectedQuote.ask.toFixed(2)} +
+
+
+ + ) : ( +

+ Click or begin a cell selection in any row to inspect its instrument. +

+ )} +
+ ) +} + +function formatInteger(value: number): string { + return integerFormatter.format(value) +} + +function formatRate(value: number): string { + return rateFormatter.format(value) +} + +function formatMs(value: number): string { + return `${value.toFixed(2)} ms` +} + +function formatInvocationRates( + rates: FeedMetrics['componentRenderRates'], +): string { + const activeRates = rates + .filter((rate) => rate.callsPerSecond > 0) + .sort((left, right) => right.callsPerSecond - left.callsPerSecond) + return activeRates.length === 0 + ? 'No calls in sample' + : activeRates + .map((rate) => `${rate.name} ${formatRate(rate.callsPerSecond)}`) + .join(' · ') +} diff --git a/examples/preact/realtime-trading/src/shell/configurator-options.ts b/examples/preact/realtime-trading/src/shell/configurator-options.ts new file mode 100644 index 0000000000..5e21d71492 --- /dev/null +++ b/examples/preact/realtime-trading/src/shell/configurator-options.ts @@ -0,0 +1,49 @@ +export interface ConfiguratorOption { + readonly label: string + readonly value: TValue +} + +const instrumentCountOptions = [ + { label: '50', value: 50 }, + { label: '100', value: 100 }, + { label: '150', value: 150 }, + { label: '250', value: 250 }, + { label: '350', value: 350 }, + { label: '500', value: 500 }, + { label: '750', value: 750 }, + { label: '1,000', value: 1_000 }, + { label: '1,500', value: 1_500 }, + { label: '2,500', value: 2_500 }, + { label: '5,000', value: 5_000 }, + { label: '1,000,000', value: 1_000_000 }, + { label: '10,000,000', value: 10_000_000 }, +] as const satisfies ReadonlyArray> + +const workerDeliveryOptions = [ + { label: '8 ms · 125 msg/s', value: 8 }, + { label: '16 ms · 62.5 msg/s', value: 16 }, + { label: '20 ms · 50 msg/s', value: 20 }, + { label: '33 ms · 30 msg/s', value: 33 }, + { label: '50 ms · 20 msg/s', value: 50 }, + { label: '100 ms · 10 msg/s', value: 100 }, + { label: '250 ms · 4 msg/s', value: 250 }, + { label: '500 ms · 2 msg/s', value: 500 }, + { label: '1,000 ms · 1 msg/s', value: 1_000 }, +] as const satisfies ReadonlyArray> + +const intradaySamplingOptions = [ + { label: '16 ms · fastest', value: 16 }, + { label: '33 ms · very fast', value: 33 }, + { label: '50 ms · fast', value: 50 }, + { label: '100 ms', value: 100 }, + { label: '250 ms', value: 250 }, + { label: '500 ms', value: 500 }, + { label: '1,000 ms', value: 1_000 }, + { label: '2,000 ms', value: 2_000 }, +] as const satisfies ReadonlyArray> + +export const configuratorOptions = { + instrumentCounts: instrumentCountOptions, + workerDeliveryIntervals: workerDeliveryOptions, + intradaySamplingIntervals: intradaySamplingOptions, +} as const diff --git a/examples/preact/realtime-trading/src/shell/trading-shell-context.tsx b/examples/preact/realtime-trading/src/shell/trading-shell-context.tsx new file mode 100644 index 0000000000..8ad0654958 --- /dev/null +++ b/examples/preact/realtime-trading/src/shell/trading-shell-context.tsx @@ -0,0 +1,50 @@ +import { createStoreContext, useSelector } from '@tanstack/preact-store' +import type { ComponentChildren } from 'preact' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../benchmark/use-trading-benchmark-controller' +import type { TradingBenchmarkState } from '../benchmark/trading-benchmark-controller' +import type { UseSelectorOptions } from '@tanstack/preact-store' + +const { + StoreProvider: TradingStoreProvider, + useStoreContext: useTradingShellController, +} = createStoreContext() + +const { + StoreProvider: MarketFeedStoreProvider, + useStoreContext: useMarketFeedController, +} = createStoreContext() + +export function MarketFeedProvider(props: { + controller: MarketFeedController + children: ComponentChildren +}) { + return ( + + {props.children} + + ) +} + +export function TradingShellProvider(props: { + controller: TradingBenchmarkController + children: ComponentChildren +}) { + return ( + + + {props.children} + + + ) +} + +export { useMarketFeedController, useTradingShellController } + +export function useTradingShellState( + selector: (state: TradingBenchmarkState) => TSelected, + options?: UseSelectorOptions, +): TSelected { + const controller = useTradingShellController() + return useSelector(controller.store, selector, options) +} diff --git a/examples/preact/realtime-trading/src/table/table-config/quote-cells.tsx b/examples/preact/realtime-trading/src/table/table-config/quote-cells.tsx new file mode 100644 index 0000000000..05c16e9578 --- /dev/null +++ b/examples/preact/realtime-trading/src/table/table-config/quote-cells.tsx @@ -0,0 +1,219 @@ +import { useEffect } from 'preact/hooks' + +const compactNumber = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) + +export const quoteCellLifecycle = { + created: 0, + destroyed: 0, +} + +export const quoteCellRendererNames = [ + 'Market', + 'Name', + 'Symbol', + 'Last', + 'Change', + 'ChangePercent', + 'Bid', + 'BidVolume', + 'Ask', + 'AskVolume', + 'Open', + 'High', + 'Low', + 'Intraday', +] as const + +export const quoteComponentNames = [ + 'PriceCell', + 'StableMoveCell', + 'UpMoveCell', + 'DownMoveCell', + 'PercentChangeCell', + 'SpreadCell', + 'DepthCell', + 'QuoteAgeCell', + 'SparklineCell', +] as const + +export type QuoteCellRendererName = (typeof quoteCellRendererNames)[number] +export type QuoteComponentName = (typeof quoteComponentNames)[number] + +const createCounterMap = ( + names: ReadonlyArray, +): Record => + Object.fromEntries(names.map((name) => [name, 0])) as Record + +export const quoteRenderDiagnostics = { + cellRendererCalls: 0, + componentRenderCalls: 0, + cellRendererCallsByName: createCounterMap(quoteCellRendererNames), + componentRenderCallsByName: createCounterMap(quoteComponentNames), +} + +export function recordCellRender(name: QuoteCellRendererName, value: T): T { + 'use no memo' + // Benchmark instrumentation is intentionally impure and must run per call. + quoteRenderDiagnostics.cellRendererCalls++ + quoteRenderDiagnostics.cellRendererCallsByName[name]++ + return value +} + +function useLifecycleCounter(componentName: QuoteComponentName): void { + 'use no memo' + // This diagnostic mutation measures component-function invocation itself. + quoteRenderDiagnostics.componentRenderCalls++ + quoteRenderDiagnostics.componentRenderCallsByName[componentName]++ + useEffect(() => { + quoteCellLifecycle.created++ + return () => { + quoteCellLifecycle.destroyed++ + } + }, []) +} + +export function PriceCell(props: { + price: number + move: number + onSelect: () => void +}) { + useLifecycleCounter('PriceCell') + return ( + + ) +} + +export function StableMoveCell({ move }: { move: number }) { + useLifecycleCounter('StableMoveCell') + return ( + = 0 ? 'quote-up' : 'quote-down'}`}> + {formatSigned(move)} + + ) +} + +export function UpMoveCell({ move }: { move: number }) { + useLifecycleCounter('UpMoveCell') + return ▲ {formatSigned(move)} +} + +export function DownMoveCell({ move }: { move: number }) { + useLifecycleCounter('DownMoveCell') + return ▼ {formatSigned(move)} +} + +export function PercentChangeCell({ value }: { value: number }) { + useLifecycleCounter('PercentChangeCell') + return ( + = 0 ? 'quote-up' : 'quote-down'}`} + > + {value >= 0 ? '+' : ''} + {value.toFixed(2)}% + + ) +} + +export function SpreadCell({ bid, ask }: { bid: number; ask: number }) { + useLifecycleCounter('SpreadCell') + const spread = Math.max(0, ask - bid) + const midpoint = (bid + ask) / 2 + const basisPoints = midpoint === 0 ? 0 : (spread / midpoint) * 10_000 + + return ( + = 4 ? 'spread-wide' : ''}`}> + {spread.toFixed(2)} + {basisPoints.toFixed(1)} bp + + ) +} + +export function DepthCell(props: { bidSize: number; askSize: number }) { + useLifecycleCounter('DepthCell') + const total = props.bidSize + props.askSize + const bidShare = total === 0 ? 50 : (props.bidSize / total) * 100 + + return ( +
+ + + + {compactNumber.format(props.bidSize)} + {compactNumber.format(props.askSize)} + +
+ ) +} + +export function QuoteAgeCell({ ageMs }: { ageMs: number }) { + useLifecycleCounter('QuoteAgeCell') + const className = + ageMs >= 1_500 + ? 'quote-age quote-age-stale' + : ageMs >= 500 + ? 'quote-age quote-age-warm' + : 'quote-age' + + return ( + + {ageMs < 1_000 + ? `${Math.round(ageMs)} ms` + : `${(ageMs / 1_000).toFixed(1)} s`} + + ) +} + +export function SparklineCell({ values }: { values: ReadonlyArray }) { + useLifecycleCounter('SparklineCell') + const rising = (values.at(-1) ?? 0) >= (values[0] ?? 0) + const { min, max } = findRange(values) + const range = max - min || 1 + const denominator = Math.max(1, values.length - 1) + const points = values + .map((value, index) => { + const x = (index / denominator) * 100 + const y = 22 - ((value - min) / range) * 20 + return `${x.toFixed(1)},${y.toFixed(1)}` + }) + .join(' ') + + return ( + + + + ) +} + +function formatSigned(value: number): string { + return `${value >= 0 ? '+' : ''}${value.toFixed(2)}` +} + +function findRange(values: ReadonlyArray): { + min: number + max: number +} { + const first = values[0] ?? 0 + return values.reduce( + (range, value) => { + range.min = Math.min(range.min, value) + range.max = Math.max(range.max, value) + return range + }, + { min: first, max: first }, + ) +} diff --git a/examples/preact/realtime-trading/src/table/table-config/trading-table-config.tsx b/examples/preact/realtime-trading/src/table/table-config/trading-table-config.tsx new file mode 100644 index 0000000000..f8b23abd0f --- /dev/null +++ b/examples/preact/realtime-trading/src/table/table-config/trading-table-config.tsx @@ -0,0 +1,259 @@ +import { createColumnHelper } from '@tanstack/preact-table' +import { useSelector } from '@tanstack/preact-store' +import { useTradingShellController } from '../../shell/trading-shell-context' +import { tradingFeatures } from '../trading-features' +import { + DownMoveCell, + PercentChangeCell, + PriceCell, + SparklineCell, + StableMoveCell, + UpMoveCell, + recordCellRender, +} from './quote-cells' +import type { ComponentChildren } from 'preact' +import type { MarketQuote } from '../../feed/market-data' + +export type RendererMode = 'stable' | 'swap' +export interface CoreTableState { + sorting: Array<{ id: string; desc: boolean }> + columnFilters: Array<{ id: string; value: unknown }> +} + +const compactFormatter = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const columnHelper = createColumnHelper() + +export const tradingColumns = columnHelper.columns([ + columnHelper.group({ + id: 'instrument', + header: 'Instrument', + columns: columnHelper.columns([ + columnHelper.accessor('venue', { + id: 'market', + header: 'Market', + size: 72, + cell: (info) => recordCellRender('Market', info.getValue()), + }), + columnHelper.accessor('company', { + id: 'name', + header: 'Name', + size: 180, + cell: (info) => recordCellRender('Name', info.getValue()), + }), + columnHelper.accessor('symbol', { + header: 'Symbol', + size: 92, + filterFn: 'includesString', + cell: (info) => recordCellRender('Symbol', info.getValue()), + }), + ]), + }), + columnHelper.group({ + id: 'priceAndChange', + header: 'Price & Change', + columns: columnHelper.columns([ + columnHelper.accessor('price', { + header: 'Price', + size: 96, + sortFn: 'basic', + cell: (info) => + recordCellRender('Last', ), + }), + columnHelper.accessor((row) => getDayChange(row), { + id: 'change', + header: 'Chg', + size: 94, + cell: (info) => + recordCellRender( + 'Change', + , + ), + }), + columnHelper.accessor((row) => getDayChangePercent(row), { + id: 'changePercent', + header: 'Chg%', + size: 90, + cell: (info) => + recordCellRender( + 'ChangePercent', + , + ), + }), + ]), + }), + columnHelper.group({ + id: 'orderBook', + header: 'Order Book', + columns: columnHelper.columns([ + columnHelper.accessor('bid', { + header: 'Bid', + size: 90, + cell: (info) => recordCellRender('Bid', info.getValue().toFixed(2)), + }), + columnHelper.accessor('bidSize', { + header: 'Bid Vol', + size: 100, + cell: (info) => + recordCellRender( + 'BidVolume', + compactFormatter.format(info.getValue()), + ), + }), + columnHelper.accessor('ask', { + header: 'Ask', + size: 90, + cell: (info) => recordCellRender('Ask', info.getValue().toFixed(2)), + }), + columnHelper.accessor('askSize', { + header: 'Ask Vol', + size: 100, + cell: (info) => + recordCellRender( + 'AskVolume', + compactFormatter.format(info.getValue()), + ), + }), + ]), + }), + columnHelper.group({ + id: 'session', + header: 'Session', + columns: columnHelper.columns([ + columnHelper.accessor('open', { + header: 'Open', + size: 90, + cell: (info) => recordCellRender('Open', info.getValue().toFixed(2)), + }), + columnHelper.accessor('high', { + header: 'High', + size: 90, + cell: (info) => recordCellRender('High', info.getValue().toFixed(2)), + }), + columnHelper.accessor('low', { + header: 'Low', + size: 90, + cell: (info) => recordCellRender('Low', info.getValue().toFixed(2)), + }), + ]), + }), + columnHelper.group({ + id: 'chart', + header: 'Chart', + columns: columnHelper.columns([ + columnHelper.accessor('history', { + header: 'Intraday', + size: 150, + enableSorting: false, + cell: (info) => + recordCellRender( + 'Intraday', + , + ), + }), + ]), + }), +]) + +export const rowModelDiagnostics = { + hasMeasurement: false, + calls: 0, + totalDurationMs: 0, + maxDurationMs: 0, + lastRowCount: 0, +} + +export const TRADING_COLUMN_COUNT = 14 + +export function readMeasuredRows(readRows: () => Array): Array { + const start = performance.now() + const rows = readRows() + const end = performance.now() + const duration = end - start + + rowModelDiagnostics.calls++ + rowModelDiagnostics.hasMeasurement = true + rowModelDiagnostics.totalDurationMs += duration + rowModelDiagnostics.maxDurationMs = Math.max( + rowModelDiagnostics.maxDurationMs, + duration, + ) + rowModelDiagnostics.lastRowCount = rows.length + + if (rowModelDiagnostics.calls % 1_000 === 0) { + performance.clearMeasures('tanstack-row-model') + } + if ((rowModelDiagnostics.calls - 1) % 20 === 0) { + try { + performance.measure('tanstack-row-model', { + start, + end, + detail: { rowCount: rows.length }, + }) + } catch { + // User Timing Level 3 detail is not implemented in every browser. + } + } + + return rows +} + +function LastPriceCell(props: { quote: MarketQuote }) { + const { selectSymbol } = useTradingShellController().actions + return ( + selectSymbol(props.quote.symbol)} + /> + ) +} + +function DayChangeCell(props: { quote: MarketQuote }) { + const { rendererMode } = useTradingShellController().renderAtoms + const mode = useSelector(rendererMode) + const change = getDayChange(props.quote) + if (mode === 'stable') { + return + } + return change >= 0 ? ( + + ) : ( + + ) +} + +export function TradingRow(props: { + quote: MarketQuote + children: ComponentChildren + rowSelected: boolean +}) { + const { selectedSymbol } = useTradingShellController().renderAtoms + const selected = useSelector( + selectedSymbol, + (symbol) => symbol === props.quote.symbol, + ) + return ( +
+ {props.children} + + ) +} + +function getDayChange(quote: MarketQuote): number { + return quote.price - quote.previousClose +} + +function getDayChangePercent(quote: MarketQuote): number { + return quote.previousClose === 0 + ? 0 + : (getDayChange(quote) / quote.previousClose) * 100 +} diff --git a/examples/preact/realtime-trading/src/table/table-interactions.ts b/examples/preact/realtime-trading/src/table/table-interactions.ts new file mode 100644 index 0000000000..af8d504b68 --- /dev/null +++ b/examples/preact/realtime-trading/src/table/table-interactions.ts @@ -0,0 +1,190 @@ +import type { AriaAttributes, TargetedKeyboardEvent } from 'preact' + +export type CellDirection = 'up' | 'down' | 'left' | 'right' + +interface RowSelectionTable { + resetRowSelection: (defaultState?: boolean) => void +} + +interface SelectableRow { + getIsSelected: () => boolean + getToggleSelectedHandler: (options?: { + selectChildren?: boolean + }) => (event: unknown) => void +} + +interface SelectableGridCell { + row: SelectableGridRow + getSelectionStartHandler: ( + contextDocument?: Document, + ) => (event: unknown) => void + getSelectionExtendHandler: () => (event: unknown) => void +} + +interface SelectableGridRow extends SelectableRow { + original: { symbol: string } + getAllCellsByColumnId: () => Record +} + +interface TradingGridTable extends RowSelectionTable { + getRowModel: () => { + rowsById: Record + } +} + +interface SelectionCellTarget { + element: HTMLTableCellElement + cell: SelectableGridCell +} + +interface CellNavigationTable { + extendCellSelection: (direction: CellDirection) => void + moveCellSelection: (direction: CellDirection) => void + resetCellSelection: (defaultState?: boolean) => void + selectAllCells: () => void +} + +const keyDirections: Partial> = { + ArrowUp: 'up', + ArrowDown: 'down', + ArrowLeft: 'left', + ArrowRight: 'right', +} + +export function reorderColumnIds( + columnIds: Array, + sourceId: string, + targetId: string, +): Array { + if (sourceId === targetId || !columnIds.includes(sourceId)) return columnIds + + const withoutSource = columnIds.filter((id) => id !== sourceId) + const targetIndex = withoutSource.indexOf(targetId) + if (targetIndex < 0) return columnIds + + return [ + ...withoutSource.slice(0, targetIndex), + sourceId, + ...withoutSource.slice(targetIndex), + ] +} + +export function selectRowFromPointer( + table: RowSelectionTable, + row: SelectableRow, + event: MouseEvent, +): void { + const additive = event.ctrlKey || event.metaKey + const checked = additive ? !row.getIsSelected() : true + + if (!event.shiftKey && !additive) table.resetRowSelection(true) + + row.getToggleSelectedHandler({ selectChildren: false })({ + target: { checked }, + shiftKey: event.shiftKey, + ctrlKey: event.ctrlKey, + metaKey: event.metaKey, + nativeEvent: event, + }) +} + +export class TradingGridPointerController { + #lastPointerCell: HTMLTableCellElement | null = null + + handleMouseDown( + table: TradingGridTable, + event: MouseEvent, + selectSymbol: (symbol: string) => void, + ): void { + if (event.button !== 0) return + + const target = this.#findCellTarget(table, event.composedPath()) + if (!target) return + + event.preventDefault() + this.#lastPointerCell = target.element + selectSymbol(target.cell.row.original.symbol) + target.cell.getSelectionStartHandler(target.element.ownerDocument)(event) + } + + handlePointerOver(table: TradingGridTable, event: MouseEvent): void { + if ((event.buttons & 1) === 0) { + this.resetPointerCell() + return + } + + const target = this.#findCellTarget(table, event.composedPath()) + if (!target || target.element === this.#lastPointerCell) return + + this.#lastPointerCell = target.element + target.cell.getSelectionExtendHandler()(event) + } + + handleClick(table: TradingGridTable, event: MouseEvent): void { + const target = this.#findCellTarget(table, event.composedPath()) + if (!target) return + selectRowFromPointer(table, target.cell.row, event) + } + + resetPointerCell(): void { + this.#lastPointerCell = null + } + + #findCellTarget( + table: TradingGridTable, + path: Array, + ): SelectionCellTarget | null { + for (const target of path) { + if (!(target instanceof HTMLTableCellElement)) continue + + const columnId = target.dataset['columnId'] + const rowId = + target.closest('tr[data-row-id]')?.dataset['rowId'] + if (!columnId || !rowId) return null + + const row = table.getRowModel().rowsById[rowId] + const cell = row.getAllCellsByColumnId()[columnId] + return { element: target, cell } + } + + return null + } +} + +export function handleCellNavigation( + table: CellNavigationTable, + event: TargetedKeyboardEvent, +): void { + if (event.key === 'Escape') { + event.preventDefault() + table.resetCellSelection(true) + return + } + + if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a') { + event.preventDefault() + table.selectAllCells() + return + } + + const direction = keyDirections[event.key] + if (!direction) return + + event.preventDefault() + if (event.shiftKey) table.extendCellSelection(direction) + else table.moveCellSelection(direction) +} + +export function sortIndicator(direction: false | 'asc' | 'desc'): string { + if (direction === 'asc') return '↑' + if (direction === 'desc') return '↓' + return '↕' +} + +export function sortAriaValue( + direction: false | 'asc' | 'desc', +): AriaAttributes['aria-sort'] { + if (direction === 'asc') return 'ascending' + if (direction === 'desc') return 'descending' + return 'none' +} diff --git a/examples/preact/realtime-trading/src/table/trading-features.ts b/examples/preact/realtime-trading/src/table/trading-features.ts new file mode 100644 index 0000000000..c31972ec47 --- /dev/null +++ b/examples/preact/realtime-trading/src/table/trading-features.ts @@ -0,0 +1,16 @@ +import { + createFilteredRowModel, + createSortedRowModel, + filterFn_includesString, + sortFn_basic, + stockFeatures, + tableFeatures, +} from '@tanstack/preact-table' + +export const tradingFeatures = tableFeatures({ + ...stockFeatures, + filteredRowModel: createFilteredRowModel(), + sortedRowModel: createSortedRowModel(), + filterFns: { includesString: filterFn_includesString }, + sortFns: { basic: sortFn_basic }, +}) diff --git a/examples/preact/realtime-trading/src/table/trading-table.tsx b/examples/preact/realtime-trading/src/table/trading-table.tsx new file mode 100644 index 0000000000..65f23f642a --- /dev/null +++ b/examples/preact/realtime-trading/src/table/trading-table.tsx @@ -0,0 +1,491 @@ +import { FlexRender, useTable } from '@tanstack/preact-table' +import { useSelector } from '@tanstack/preact-store' +import { useLayoutEffect, useRef, useState } from 'preact/hooks' +import { useTableBenchmark } from '../benchmark/use-table-benchmark' +import { + useMarketFeedController, + useTradingShellController, +} from '../shell/trading-shell-context' +import { + TradingRow, + readMeasuredRows, + tradingColumns, +} from './table-config/trading-table-config' +import { tradingFeatures } from './trading-features' +import { + TradingGridPointerController, + handleCellNavigation, + reorderColumnIds, + sortAriaValue, + sortIndicator, +} from './table-interactions' +import type { + CellSelectionBounds, + CellSelectionState, +} from '@tanstack/preact-table' +import type { MarketQuote } from '../feed/market-data' +import type { CoreTableState } from './table-config/trading-table-config' + +export { + TRADING_COLUMN_COUNT, + rowModelDiagnostics, +} from './table-config/trading-table-config' +export type { + CoreTableState, + RendererMode, +} from './table-config/trading-table-config' + +export function TradingTable() { + const controller = useTradingShellController() + const feed = useMarketFeedController() + const quotes = useSelector(feed.quotes) + + useLayoutEffect(() => feed.completeRender()) + useTableBenchmark(controller) + const table = useTradingTable({ quotes }) + const layoutRefs = useTradingTableLayout(table) + + return ( + ({ + sorting: state.sorting, + columnFilters: state.columnFilters, + columnOrder: state.columnOrder, + })} + > + {(coreState) => ( + + )} + + ) +} + +type TradingTableInstance = ReturnType + +interface ColumnDragRuntime { + columnId: string | null + sourceElement: HTMLTableCellElement | null + targetElement: HTMLTableCellElement | null +} + +function clearColumnDrag(runtime: ColumnDragRuntime): void { + runtime.sourceElement?.classList.remove('is-column-dragging') + runtime.targetElement?.classList.remove('is-column-drop-target') + runtime.columnId = null + runtime.sourceElement = null + runtime.targetElement = null +} + +function showColumnDropTarget( + runtime: ColumnDragRuntime, + targetColumnId: string, + targetElement: HTMLTableCellElement | null, +): void { + runtime.targetElement?.classList.remove('is-column-drop-target') + runtime.targetElement = null + if (runtime.columnId === targetColumnId || !targetElement) return + targetElement.classList.add('is-column-drop-target') + runtime.targetElement = targetElement +} + +function useTradingTableLayout(table: TradingTableInstance) { + const scrollRef = useRef(null) + const tableRef = useRef(null) + const fitRuntime = useRef({ manuallyResized: false }) + const tableRuntime = useRef(table) + tableRuntime.current = table + + useLayoutEffect(() => { + const writeColumnSizes = () => { + const currentTable = tableRuntime.current + const tableElement = tableRef.current + if (!tableElement) return + for (const header of currentTable.getFlatHeaders()) { + tableElement.style.setProperty( + `--header-${header.id}-size`, + String(header.getSize()), + ) + tableElement.style.setProperty( + `--col-${header.column.id}-size`, + String(header.column.getSize()), + ) + } + tableElement.style.width = `${currentTable.getTotalSize()}px` + } + + writeColumnSizes() + const sizingSubscription = + tableRuntime.current.atoms.columnSizing.subscribe(writeColumnSizes) + const orderSubscription = + tableRuntime.current.atoms.columnOrder.subscribe(writeColumnSizes) + const fitAvailableWidth = () => { + const currentTable = tableRuntime.current + const scrollElement = scrollRef.current + if (!scrollElement || fitRuntime.current.manuallyResized) return + const currentWidth = currentTable.getTotalSize() + const availableWidth = scrollElement.clientWidth + if (availableWidth <= currentWidth + 1 || currentWidth <= 0) return + + const ratio = availableWidth / currentWidth + currentTable.setColumnSizing( + Object.fromEntries( + currentTable + .getVisibleLeafColumns() + .map((column) => [column.id, column.getSize() * ratio]), + ), + ) + } + const resizeObserver = new ResizeObserver(fitAvailableWidth) + const resizingSubscription = + tableRuntime.current.atoms.columnResizing.subscribe((state) => { + if (state.isResizingColumn !== false) { + fitRuntime.current.manuallyResized = true + } + }) + if (scrollRef.current) resizeObserver.observe(scrollRef.current) + fitAvailableWidth() + + return () => { + sizingSubscription.unsubscribe() + orderSubscription.unsubscribe() + resizingSubscription.unsubscribe() + resizeObserver.disconnect() + } + }, []) + + return { scrollRef, tableRef } +} + +function TradingTableHeader(props: { table: TradingTableInstance }) { + const dragRuntime = useRef({ + columnId: null, + sourceElement: null, + targetElement: null, + }) + + return ( + ({ + columnOrder: state.columnOrder, + sorting: state.sorting, + })} + > + {() => ( + + {props.table.getHeaderGroups().map((headerGroup) => ( + + {headerGroup.headers.map((header) => { + const isLeaf = header.subHeaders.length === 0 + const sorted = header.column.getIsSorted() + return ( + + ) + })} + + ))} + + )} + + ) +} + +function useTradingTable(props: { quotes: Array }) { + return useTable( + { + key: 'preact-realtime-trading', + features: tradingFeatures, + columns: tradingColumns, + data: props.quotes, + getRowId: (row) => row.id, + columnResizeMode: 'onChange', + defaultColumn: { minSize: 56, maxSize: 800 }, + autoResetCellSelection: false, + }, + () => null, + ) +} + +function TradingTableViewport(props: { + table: ReturnType + rows: ReturnType['getRowModel']>['rows'] + sourceRowCount: number + layoutRefs: ReturnType + reportRenderedRowCount: (count: number) => void +}) { + const renderedRowCount = props.rows.length + + useLayoutEffect(() => { + props.reportRenderedRowCount(renderedRowCount) + }, [props.reportRenderedRowCount, renderedRowCount]) + + return ( +
handleCellNavigation(props.table, event)} + > +
+ {!header.isPlaceholder && + (isLeaf ? ( + <> +
{ + event.preventDefault() + showColumnDropTarget( + dragRuntime.current, + header.column.id, + event.currentTarget.closest('th'), + ) + }} + onDrop={(event) => { + event.preventDefault() + const dataTransfer = event.dataTransfer + const sourceId = + dataTransfer?.getData('text/plain') || + dragRuntime.current.columnId + if (sourceId) { + props.table.setColumnOrder( + reorderColumnIds( + props.table + .getVisibleLeafColumns() + .map((column) => column.id), + sourceId, + header.column.id, + ), + ) + } + clearColumnDrag(dragRuntime.current) + }} + > + + +
+ {header.column.getCanResize() && ( + + state.columnResizing.isResizingColumn === + header.column.id + } + > + {(isResizing) => ( +
header.column.resetSize()} + onMouseDown={header.getResizeHandler()} + onTouchStart={header.getResizeHandler()} + /> + )} + + )} + + ) : ( + + ))} +
+ + +
+
+ ) +} + +function TradingRows(props: { + table: ReturnType + rows: ReturnType['getRowModel']>['rows'] + sourceRowCount: number +}) { + const { selectSymbol } = useTradingShellController().actions + const [pointerInteractions] = useState( + () => new TradingGridPointerController(), + ) + + return ( +
+ +
+ {!header.isPlaceholder && + (isLeaf ? ( + <> +
{ + event.preventDefault() + showColumnDropTarget( + dragRuntime.current, + header.column.id, + event.currentTarget.closest('th'), + ) + }} + onDrop={(event) => { + event.preventDefault() + const sourceId = + event.dataTransfer.getData('text/plain') || + dragRuntime.current.columnId + if (sourceId) { + props.table.setColumnOrder( + reorderColumnIds( + props.table + .getVisibleLeafColumns() + .map((column) => column.id), + sourceId, + header.column.id, + ), + ) + } + clearColumnDrag(dragRuntime.current) + }} + > + + +
+ {header.column.getCanResize() && ( + + state.columnResizing.isResizingColumn === + header.column.id + } + > + {(isResizing) => ( +
+ header.column.resetSize() + } + onMouseDown={header.getResizeHandler()} + onTouchStart={header.getResizeHandler()} + /> + )} + + )} + + ) : ( + + ))} +
+ + +
+
+ {props.virtualScrollMode === 'tanstack' && ( +
+ + TanStack · Total · {props.rows.length} rows ·{' '} + {props.table.getVisibleLeafColumns().length} columns + + + {visibleRange + ? `Current · rows ${visibleRange.start}..${visibleRange.end}` + : 'Current · rows —'} + +
+ )} + + ) +} + +function TradingRows(props: { + table: ReturnType + rows: ReturnType['getRowModel']>['rows'] + sourceRowCount: number + virtualRows: Array + virtualScrollMode: VirtualScrollMode +}) { + const { selectSymbol } = useTradingShellController().actions + const pointerInteractions = useTradingGridPointer(props.table, selectSymbol) + + return ( +
+ +
+ + }> + + + +
+ +
+ + +
+
+ + + ) +} diff --git a/examples/solid/realtime-trading/src/vite-env.d.ts b/examples/solid/realtime-trading/src/vite-env.d.ts new file mode 100644 index 0000000000..11f02fe2a0 --- /dev/null +++ b/examples/solid/realtime-trading/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/solid/realtime-trading/tests/e2e/smoke.spec.ts b/examples/solid/realtime-trading/tests/e2e/smoke.spec.ts new file mode 100644 index 0000000000..75bc5bb93f --- /dev/null +++ b/examples/solid/realtime-trading/tests/e2e/smoke.spec.ts @@ -0,0 +1,211 @@ +import path from 'node:path' +import { expect, test } from '@playwright/test' +import { startExampleServer } from '../../../../../tests/e2e/helpers/startExampleServer' +import { + setRangeValue, + scrollTradingTable, + pauseTradingFeed, + resumeTradingFeed, + pausedFeedUrl, +} from '../../../../../tests/e2e/helpers/setRangeValue' +import type { Page } from '@playwright/test' + +const exampleDir = path.resolve() + +function collectPageErrors(page: Page) { + const errors: Array = [] + page.on('pageerror', (error) => errors.push(error.message)) + page.on('console', (message) => { + if (message.type() === 'error') errors.push(message.text()) + }) + return errors +} + +test('runs the Solid realtime trading workload', async ({ page }) => { + test.setTimeout(120_000) + const server = await startExampleServer(exampleDir) + const errors = collectPageErrors(page) + + try { + await page.goto(pausedFeedUrl(server.url)) + + const table = page.getByTestId('trading-table') + const instrumentCount = page.getByTestId('instrument-count-select') + const virtualScrollSelect = page.getByTestId('virtual-scroll-select') + await expect(table).toBeVisible() + await expect(instrumentCount).toHaveValue('100') + await expect(page.locator('.brand')).toHaveText('MARKET MONITOR') + await expect(virtualScrollSelect).toHaveValue('none') + await expect(virtualScrollSelect).toBeEnabled() + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(table.locator('tbody')).toHaveCSS('user-select', 'none') + await expect(table.locator('tbody tr').first()).toHaveCSS( + 'content-visibility', + 'auto', + ) + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await instrumentCount.selectOption('250') + await expect(virtualScrollSelect).toHaveValue('tanstack') + await expect(virtualScrollSelect).toBeEnabled() + await expect.poll(() => table.locator('tbody tr').count()).toBeLessThan(250) + await expect(page.getByTestId('virtual-scroll-footer')).toBeVisible() + await instrumentCount.selectOption('100') + await expect(virtualScrollSelect).toHaveValue('none') + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await virtualScrollSelect.selectOption('tanstack') + await expect.poll(() => table.locator('tbody tr').count()).toBeLessThan(100) + await expect(table.locator('tbody tr').first()).toHaveCSS( + 'content-visibility', + 'auto', + ) + await expect(page.getByTestId('virtual-scroll-footer')).toBeVisible() + await virtualScrollSelect.selectOption('none') + await expect(table.locator('tbody tr')).toHaveCount(100) + await instrumentCount.selectOption('1500') + await expect(virtualScrollSelect).toHaveValue('tanstack') + await expect(virtualScrollSelect).toBeDisabled() + await expect + .poll(() => table.locator('tbody tr').count()) + .toBeLessThan(1500) + await expect(page.getByTestId('virtual-scroll-footer')).toContainText( + 'Total · 1500 rows · 14 columns', + ) + await expect(page.getByTestId('visible-row-range')).toHaveText( + /^\s*Current · rows 0\.\.\d+\s*$/, + ) + await scrollTradingTable(page, 2_000) + await expect + .poll(async () => + Number( + await table + .locator('tbody tr') + .first() + .getAttribute('data-virtual-index'), + ), + ) + .toBeGreaterThan(0) + await expect(page.getByTestId('visible-row-range')).toHaveText( + /^\s*Current · rows [1-9]\d*\.\.\d+\s*$/, + ) + await instrumentCount.selectOption('100') + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await expect(virtualScrollSelect).toHaveValue('none') + await expect(virtualScrollSelect).toBeEnabled() + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(table.locator('thead tr')).toHaveCount(2) + await expect(table.locator('thead tr').last().locator('th')).toHaveCount(14) + await expect(table.locator('thead')).not.toContainText('Identity') + await expect(table.locator('thead')).not.toContainText('Market Data') + await expect(table.locator('thead')).toContainText('Market') + await expect(table.locator('thead')).toContainText('Bid Vol') + await expect(table.locator('thead')).toContainText('Intraday') + const selectedRow = table.locator('tbody tr').first() + const selectedSymbol = await selectedRow.getAttribute('data-symbol') + await selectedRow.locator('td').nth(1).click() + await expect(page.getByTestId('selected-instrument')).toContainText( + selectedSymbol ?? '', + ) + + await expect(page.getByTestId('feed-status')).toHaveText('FEED PAUSED') + await expect(page.getByTestId('feed-toggle')).toHaveText('START FEED') + const dragStart = table.locator('tbody tr').nth(0).locator('td').nth(1) + const dragEnd = table.locator('tbody tr').nth(2).locator('td').nth(4) + const dragStartBox = await dragStart.boundingBox() + const dragEndBox = await dragEnd.boundingBox() + expect(dragStartBox).not.toBeNull() + expect(dragEndBox).not.toBeNull() + if (dragStartBox && dragEndBox) { + await page.mouse.move( + dragStartBox.x + dragStartBox.width / 2, + dragStartBox.y + dragStartBox.height / 2, + ) + await page.mouse.down() + await page.mouse.move( + dragEndBox.x + dragEndBox.width / 2, + dragEndBox.y + dragEndBox.height / 2, + { steps: 12 }, + ) + await page.mouse.up() + } + await expect(table.locator('td[aria-selected="true"]')).toHaveCount(12) + await expect(table.locator('td[data-cell-focused="true"]')).toHaveCount(1) + await expect(table.locator('td[data-selection-top="true"]')).toHaveCount(4) + await expect(table.locator('td[data-selection-right="true"]')).toHaveCount( + 3, + ) + await expect(table.locator('td[data-selection-bottom="true"]')).toHaveCount( + 4, + ) + await expect(table.locator('td[data-selection-left="true"]')).toHaveCount(3) + + await expect(instrumentCount.locator('option[value="150"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="350"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="750"]')).toHaveCount(1) + + const targetRateSlider = page.getByTestId('target-rate-slider') + await expect(targetRateSlider).toHaveAttribute('min', '0') + await expect(targetRateSlider).toHaveAttribute('max', '9') + await expect(targetRateSlider).toHaveAttribute('step', '1') + await expect(targetRateSlider).toHaveValue('6') + await setRangeValue(targetRateSlider, '7') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '25K samples/s', + ) + await setRangeValue(targetRateSlider, '8') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '50K samples/s', + ) + await setRangeValue(targetRateSlider, '6') + + const sparklineInterval = page.getByTestId( + 'sparkline-sample-interval-select', + ) + await expect(sparklineInterval).toHaveValue('16') + await sparklineInterval.selectOption('100') + await expect(sparklineInterval).toHaveValue('100') + await sparklineInterval.selectOption('16') + + const publishInterval = page.getByTestId('publish-interval-select') + await expect(publishInterval.locator('option[value="500"]')).toHaveCount(1) + await expect(publishInterval.locator('option[value="1000"]')).toHaveCount(1) + + // Exercise delivery and rendering without turning this smoke test into a + // throughput benchmark on shared CI runners. Configure controls while paused. + await setRangeValue(targetRateSlider, '0') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '100 samples/s', + ) + await publishInterval.selectOption('500') + await expect(publishInterval).toHaveValue('500') + await sparklineInterval.selectOption('100') + const swapRenderer = page.getByRole('checkbox', { + name: /Swap Tick component/, + }) + await swapRenderer.check() + await expect(swapRenderer).toBeChecked() + + const firstPrice = table.locator('tbody tr').first().getByRole('button') + const priceBeforeUpdate = await firstPrice.textContent() + await resumeTradingFeed(page) + await expect + .poll(() => firstPrice.textContent()) + .not.toBe(priceBeforeUpdate) + + await pauseTradingFeed(page) + + // Delivery is cumulative; instantaneous rates can legitimately fall to + // zero between samples on a busy runner. The price assertion above proves + // that a delivered update reached the rendered table. + await expect + .poll(async () => { + const text = await page.getByTestId('worker-messages').textContent() + return Number(text?.replace(/\D/g, '') ?? 0) + }) + .toBeGreaterThan(0) + + expect(errors).toEqual([]) + } finally { + await server.close() + } +}) diff --git a/examples/solid/realtime-trading/tsconfig.json b/examples/solid/realtime-trading/tsconfig.json new file mode 100644 index 0000000000..24795ad41a --- /dev/null +++ b/examples/solid/realtime-trading/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ES2022", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "preserve", + "jsxImportSource": "solid-js", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src", "tests/e2e", "vite.config.ts"] +} diff --git a/examples/solid/realtime-trading/vite.config.ts b/examples/solid/realtime-trading/vite.config.ts new file mode 100644 index 0000000000..7352cff5df --- /dev/null +++ b/examples/solid/realtime-trading/vite.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite' +import solidPlugin from 'vite-plugin-solid' + +export default defineConfig({ + server: { + port: 7777, + allowedHosts: true, + }, + plugins: [solidPlugin()], + build: { + target: 'esnext', + }, +}) diff --git a/examples/solid/row-pinning/package.json b/examples/solid/row-pinning/package.json index 8143b4cfbf..bcdfcc0572 100644 --- a/examples/solid/row-pinning/package.json +++ b/examples/solid/row-pinning/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/row-selection/package.json b/examples/solid/row-selection/package.json index 94b0dc9272..8e4d628219 100644 --- a/examples/solid/row-selection/package.json +++ b/examples/solid/row-selection/package.json @@ -13,15 +13,16 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-devtools": "^0.8.10", - "@tanstack/solid-table": "^9.1.2", - "@tanstack/solid-table-devtools": "^9.2.0", - "solid-js": "^1.9.14" + "@tanstack/solid-devtools": "^0.8.14", + "@tanstack/solid-table": "^9.3.1", + "@tanstack/solid-table-devtools": "^9.3.2", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/sorting/package.json b/examples/solid/sorting/package.json index 549282768e..4601af37e8 100644 --- a/examples/solid/sorting/package.json +++ b/examples/solid/sorting/package.json @@ -13,13 +13,14 @@ }, "license": "MIT", "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" }, "dependencies": { - "@tanstack/solid-table": "^9.1.2", - "solid-js": "^1.9.14" + "@tanstack/solid-table": "^9.3.1", + "solid-js": "^1.9.19" } } diff --git a/examples/solid/spreadsheet/package.json b/examples/solid/spreadsheet/package.json index 083c2c438b..bf97178478 100644 --- a/examples/solid/spreadsheet/package.json +++ b/examples/solid/spreadsheet/package.json @@ -12,15 +12,16 @@ "test:types": "tsc --noEmit" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/solid-hotkeys": "^0.10.0", - "@tanstack/solid-table": "^9.1.2", - "@tanstack/solid-virtual": "^3.13.36", - "solid-js": "^1.9.14" + "@faker-js/faker": "^10.6.0", + "@tanstack/solid-hotkeys": "^0.24.0", + "@tanstack/solid-table": "^9.3.1", + "@tanstack/solid-virtual": "^3.13.53", + "solid-js": "^1.9.19" }, "devDependencies": { + "@rolldown/binding-wasm32-wasi": "~1.3.2", "typescript": "6.0.3", - "vite": "^8.2.1", - "vite-plugin-solid": "^2.11.14" + "vite": "^8.3.8", + "vite-plugin-solid": "^2.11.16" } } diff --git a/examples/solid/spreadsheet/src/Spreadsheet.tsx b/examples/solid/spreadsheet/src/Spreadsheet.tsx index 0552aa4cdb..2def569908 100644 --- a/examples/solid/spreadsheet/src/Spreadsheet.tsx +++ b/examples/solid/spreadsheet/src/Spreadsheet.tsx @@ -228,6 +228,20 @@ export function Spreadsheet() { sheets().findIndex((sheet) => sheet.id === activeSheetId()), ) + const active = () => table.atoms.cellSelection.get().at(-1) + const activeValue = () => { + const current = active() + return current + ? formatCellValue( + interactions.getValue(current.anchorRowId, current.anchorColumnId), + ) + : '' + } + const summary = () => { + void table.atoms.cellSelection.get() + return interactions.getSelectionSummary() + } + return (
@@ -425,29 +439,11 @@ export function Spreadsheet() {
- - {(atoms) => { - const active = () => atoms.cellSelection.get().at(-1) - const activeValue = () => { - const current = active() - return current - ? formatCellValue( - interactions.getValue( - current.anchorRowId, - current.anchorColumnId, - ), - ) - : '' - } - return ( - - ) - }} - + (gridRef = handle)} @@ -512,28 +508,16 @@ export function Spreadsheet() { Ready - - {(atoms) => { - const summary = () => { - void atoms.cellSelection.get() - return interactions.getSelectionSummary() - } - return ( -
- {summary().count.toLocaleString()} selected - {summary().numericCount ? ( - <> - - Count: {summary().numericCount.toLocaleString()} - - Sum: {formatNumber(summary().sum)} - Average: {formatNumber(summary().average)} - - ) : null} -
- ) - }} -
+
+ {summary().count.toLocaleString()} selected + {summary().numericCount ? ( + <> + Count: {summary().numericCount.toLocaleString()} + Sum: {formatNumber(summary().sum)} + Average: {formatNumber(summary().average)} + + ) : null} +
+
+ diff --git a/examples/svelte/realtime-trading/src/shell/Configurator.svelte b/examples/svelte/realtime-trading/src/shell/Configurator.svelte new file mode 100644 index 0000000000..f2fb024885 --- /dev/null +++ b/examples/svelte/realtime-trading/src/shell/Configurator.svelte @@ -0,0 +1,48 @@ + + + diff --git a/examples/svelte/realtime-trading/src/shell/Diagnostics.svelte b/examples/svelte/realtime-trading/src/shell/Diagnostics.svelte new file mode 100644 index 0000000000..8faf513bd6 --- /dev/null +++ b/examples/svelte/realtime-trading/src/shell/Diagnostics.svelte @@ -0,0 +1,43 @@ + + +

DIAGNOSTICS

+ {#each items as item (item[0])}
{item[0]}
{item[1]}
{/each} +
diff --git a/examples/svelte/realtime-trading/src/shell/MarketStatusbar.svelte b/examples/svelte/realtime-trading/src/shell/MarketStatusbar.svelte new file mode 100644 index 0000000000..21032c6d14 --- /dev/null +++ b/examples/svelte/realtime-trading/src/shell/MarketStatusbar.svelte @@ -0,0 +1,13 @@ + + +
+ MESSAGE SAMPLES {integer.format(state.current.metrics.lastBatchSize)} + CHANGED ROWS {integer.format(state.current.metrics.lastUpdateCount)} + HOSTS {integer.format(state.current.mountedCells)} + COMPONENTS {integer.format(state.current.liveComponents)} +
diff --git a/examples/svelte/realtime-trading/src/shell/MetricsStrip.svelte b/examples/svelte/realtime-trading/src/shell/MetricsStrip.svelte new file mode 100644 index 0000000000..3ab0f30117 --- /dev/null +++ b/examples/svelte/realtime-trading/src/shell/MetricsStrip.svelte @@ -0,0 +1,19 @@ + + +
+

LIVE HEALTH

+ {#each items as item (item.label)}
{item.label}{item.value}{item.detail}
{/each} +
THROUGHPUT{rate.format(metrics.rowUpdatesPerSecond)} rows/s{metrics.stateApplicationsPerSecond.toFixed(1)} snapshots/s · rows deduplicated per snapshot
+
diff --git a/examples/svelte/realtime-trading/src/shell/SelectedInstrument.svelte b/examples/svelte/realtime-trading/src/shell/SelectedInstrument.svelte new file mode 100644 index 0000000000..dbf747480e --- /dev/null +++ b/examples/svelte/realtime-trading/src/shell/SelectedInstrument.svelte @@ -0,0 +1,16 @@ + + +
+

SELECTED INSTRUMENT

+ {#if selectedQuote} +
{selectedQuote.symbol}{selectedQuote.company}
{selectedQuote.venue}
+
Last
{selectedQuote.price.toFixed(2)}
Bid / ask
{selectedQuote.bid.toFixed(2)} / {selectedQuote.ask.toFixed(2)}
+ {:else}

Click or begin a cell selection in any row to inspect its instrument.

{/if} +
diff --git a/examples/svelte/realtime-trading/src/shell/TradingShell.svelte b/examples/svelte/realtime-trading/src/shell/TradingShell.svelte new file mode 100644 index 0000000000..6406fa8b71 --- /dev/null +++ b/examples/svelte/realtime-trading/src/shell/TradingShell.svelte @@ -0,0 +1,15 @@ + + +
+
{ layout.sidebarOpen = !layout.sidebarOpen }} />{#if import.meta.env.DEV}{/if}
+
{@render children()}
+ + +
diff --git a/examples/svelte/realtime-trading/src/shell/configurator-options.ts b/examples/svelte/realtime-trading/src/shell/configurator-options.ts new file mode 100644 index 0000000000..49a9566fe7 --- /dev/null +++ b/examples/svelte/realtime-trading/src/shell/configurator-options.ts @@ -0,0 +1,55 @@ +export interface ConfiguratorOption { + readonly label: string + readonly value: TValue +} + +const instrumentCountOptions = [ + { label: '50', value: 50 }, + { label: '100', value: 100 }, + { label: '150', value: 150 }, + { label: '250', value: 250 }, + { label: '350', value: 350 }, + { label: '500', value: 500 }, + { label: '750', value: 750 }, + { label: '1,000', value: 1_000 }, + { label: '1,500', value: 1_500 }, + { label: '2,500', value: 2_500 }, + { label: '5,000', value: 5_000 }, + { label: '1,000,000', value: 1_000_000 }, + { label: '10,000,000', value: 10_000_000 }, +] as const satisfies ReadonlyArray> + +const workerDeliveryOptions = [ + { label: '8 ms · 125 msg/s', value: 8 }, + { label: '16 ms · 62.5 msg/s', value: 16 }, + { label: '20 ms · 50 msg/s', value: 20 }, + { label: '33 ms · 30 msg/s', value: 33 }, + { label: '50 ms · 20 msg/s', value: 50 }, + { label: '100 ms · 10 msg/s', value: 100 }, + { label: '250 ms · 4 msg/s', value: 250 }, + { label: '500 ms · 2 msg/s', value: 500 }, + { label: '1,000 ms · 1 msg/s', value: 1_000 }, +] as const satisfies ReadonlyArray> + +const rowRenderingOptions = [ + { label: 'Full DOM · render every row', value: 'none' }, + { label: 'TanStack Virtual · visible rows only', value: 'tanstack' }, +] as const satisfies ReadonlyArray> + +const intradaySamplingOptions = [ + { label: '16 ms · fastest', value: 16 }, + { label: '33 ms · very fast', value: 33 }, + { label: '50 ms · fast', value: 50 }, + { label: '100 ms', value: 100 }, + { label: '250 ms', value: 250 }, + { label: '500 ms', value: 500 }, + { label: '1,000 ms', value: 1_000 }, + { label: '2,000 ms', value: 2_000 }, +] as const satisfies ReadonlyArray> + +export const configuratorOptions = { + instrumentCounts: instrumentCountOptions, + workerDeliveryIntervals: workerDeliveryOptions, + rowRenderingModes: rowRenderingOptions, + intradaySamplingIntervals: intradaySamplingOptions, +} as const diff --git a/examples/svelte/realtime-trading/src/shell/trading-shell-context.ts b/examples/svelte/realtime-trading/src/shell/trading-shell-context.ts new file mode 100644 index 0000000000..25ab35c22c --- /dev/null +++ b/examples/svelte/realtime-trading/src/shell/trading-shell-context.ts @@ -0,0 +1,35 @@ +import { getContext, setContext } from 'svelte' +import type { MarketFeedController } from '../feed/market-feed-controller' +import type { TradingBenchmarkController } from '../benchmark/trading-benchmark-controller' + +interface TradingControllers { + benchmark: TradingBenchmarkController + feed: MarketFeedController +} + +const tradingControllersKey = Symbol('trading-controllers') + +export function provideTradingControllers( + benchmark: TradingBenchmarkController, +): void { + setContext(tradingControllersKey, { + benchmark, + feed: benchmark.feed, + }) +} + +export function useTradingShellController(): TradingBenchmarkController { + const controllers = getContext( + tradingControllersKey, + ) + if (!controllers) throw new Error('Missing trading controllers') + return controllers.benchmark +} + +export function useMarketFeedController(): MarketFeedController { + const controllers = getContext( + tradingControllersKey, + ) + if (!controllers) throw new Error('Missing trading controllers') + return controllers.feed +} diff --git a/examples/svelte/realtime-trading/src/table/TradingTable.svelte b/examples/svelte/realtime-trading/src/table/TradingTable.svelte new file mode 100644 index 0000000000..0c9e18b5e2 --- /dev/null +++ b/examples/svelte/realtime-trading/src/table/TradingTable.svelte @@ -0,0 +1,175 @@ + + +{#snippet renderRow(row: (typeof rows)[number], virtualRow?: VirtualItem)} +
handleCellNavigation(table, event)}> + + {#each table.getHeaderGroups() as headerGroup (headerGroup.id)} + {#each headerGroup.headers as header (header.id)} + {@const isLeaf = header.subHeaders.length === 0}{@const sorted = header.column.getIsSorted()} + + {/each} + {/each} + + + + + pointerInteractions.handleMouseDown(table, event, controller.actions.selectSymbol)} onpointerover={(event) => pointerInteractions.handlePointerOver(table, event)} onmouseleave={() => pointerInteractions.resetPointerCell()} onclick={(event) => pointerInteractions.handleClick(table, event)}> + {#if virtualScrollMode === 'tanstack'} + {#each virtualRows as virtualRow (virtualRow.key)}{@render renderRow(rows[virtualRow.index], virtualRow)}{/each} + {:else} + {#each rows as row (row.id)}{@render renderRow(row)}{/each} + {/if} + +
+ {#if !header.isPlaceholder} + {#if isLeaf} +
{ event.preventDefault(); showColumnDropTarget(header.column.id, (event.currentTarget as HTMLElement).closest('th')) }} ondrop={(event) => { event.preventDefault(); const sourceId = event.dataTransfer?.getData('text/plain') || drag.columnId; if (sourceId) table.setColumnOrder(reorderColumnIds(table.getVisibleLeafColumns().map((column) => column.id), sourceId, header.column.id)); clearColumnDrag() }}> + + +
+ {#if header.column.getCanResize()}{/if} + {:else}{/if} + {/if} +
+
+{#if virtualScrollMode === 'tanstack'}
TanStack · Total · {rows.length} rows · {table.getVisibleLeafColumns().length} columns{visibleRange ? `Current · rows ${visibleRange.start}..${visibleRange.end}` : 'Current · rows —'}
{/if} diff --git a/examples/svelte/realtime-trading/src/table/table-config/DayChangeCell.svelte b/examples/svelte/realtime-trading/src/table/table-config/DayChangeCell.svelte new file mode 100644 index 0000000000..ac9fd4210c --- /dev/null +++ b/examples/svelte/realtime-trading/src/table/table-config/DayChangeCell.svelte @@ -0,0 +1,19 @@ + + +{#if mode.current === 'stable'} + +{:else if change >= 0} + +{:else} + +{/if} diff --git a/examples/svelte/realtime-trading/src/table/table-config/LastPriceCell.svelte b/examples/svelte/realtime-trading/src/table/table-config/LastPriceCell.svelte new file mode 100644 index 0000000000..2fe41997c7 --- /dev/null +++ b/examples/svelte/realtime-trading/src/table/table-config/LastPriceCell.svelte @@ -0,0 +1,11 @@ + + + selectSymbol(quote.symbol)} /> diff --git a/examples/svelte/realtime-trading/src/table/table-config/MoveCell.svelte b/examples/svelte/realtime-trading/src/table/table-config/MoveCell.svelte new file mode 100644 index 0000000000..0ecf1544b2 --- /dev/null +++ b/examples/svelte/realtime-trading/src/table/table-config/MoveCell.svelte @@ -0,0 +1,17 @@ + + +{indicator}{formatSigned(move)} diff --git a/examples/svelte/realtime-trading/src/table/table-config/PercentChangeCell.svelte b/examples/svelte/realtime-trading/src/table/table-config/PercentChangeCell.svelte new file mode 100644 index 0000000000..d108a65007 --- /dev/null +++ b/examples/svelte/realtime-trading/src/table/table-config/PercentChangeCell.svelte @@ -0,0 +1,10 @@ + + += 0} class:quote-down={value < 0} class="percent-change-cell">{value >= 0 ? '+' : ''}{value.toFixed(2)}% diff --git a/examples/svelte/realtime-trading/src/table/table-config/PriceCell.svelte b/examples/svelte/realtime-trading/src/table/table-config/PriceCell.svelte new file mode 100644 index 0000000000..4f25bd5fd5 --- /dev/null +++ b/examples/svelte/realtime-trading/src/table/table-config/PriceCell.svelte @@ -0,0 +1,10 @@ + + + diff --git a/examples/svelte/realtime-trading/src/table/table-config/SparklineCell.svelte b/examples/svelte/realtime-trading/src/table/table-config/SparklineCell.svelte new file mode 100644 index 0000000000..bee2789d9d --- /dev/null +++ b/examples/svelte/realtime-trading/src/table/table-config/SparklineCell.svelte @@ -0,0 +1,12 @@ + + + diff --git a/examples/svelte/realtime-trading/src/table/table-config/quote-cells.ts b/examples/svelte/realtime-trading/src/table/table-config/quote-cells.ts new file mode 100644 index 0000000000..ddc96e7296 --- /dev/null +++ b/examples/svelte/realtime-trading/src/table/table-config/quote-cells.ts @@ -0,0 +1,75 @@ +export const quoteCellLifecycle = { created: 0, destroyed: 0 } + +export const quoteCellRendererNames = [ + 'Market', + 'Name', + 'Symbol', + 'Last', + 'Change', + 'ChangePercent', + 'Bid', + 'BidVolume', + 'Ask', + 'AskVolume', + 'Open', + 'High', + 'Low', + 'Intraday', +] as const + +export const quoteComponentNames = [ + 'PriceCell', + 'StableMoveCell', + 'UpMoveCell', + 'DownMoveCell', + 'PercentChangeCell', + 'SparklineCell', +] as const + +export type QuoteCellRendererName = (typeof quoteCellRendererNames)[number] +export type QuoteComponentName = (typeof quoteComponentNames)[number] + +const createCounterMap = (names: ReadonlyArray) => + Object.fromEntries(names.map((name) => [name, 0])) as Record + +export const quoteRenderDiagnostics = { + cellRendererCalls: 0, + componentRenderCalls: 0, + cellRendererCallsByName: createCounterMap(quoteCellRendererNames), + componentRenderCallsByName: createCounterMap(quoteComponentNames), +} + +export function recordCellRender(name: QuoteCellRendererName, value: T): T { + quoteRenderDiagnostics.cellRendererCalls++ + quoteRenderDiagnostics.cellRendererCallsByName[name]++ + return value +} + +export function recordComponentRender(name: QuoteComponentName): void { + quoteRenderDiagnostics.componentRenderCalls++ + quoteRenderDiagnostics.componentRenderCallsByName[name]++ +} + +export function formatSigned(value: number): string { + return `${value >= 0 ? '+' : ''}${value.toFixed(2)}` +} + +export function sparklinePoints(values: ReadonlyArray): string { + const first = values[0] ?? 0 + const range = values.reduce( + (current, value) => ({ + min: Math.min(current.min, value), + max: Math.max(current.max, value), + }), + { min: first, max: first }, + ) + const height = range.max - range.min || 1 + const denominator = Math.max(1, values.length - 1) + return values + .map((value, index) => { + const x = (index / denominator) * 100 + const y = 22 - ((value - range.min) / height) * 20 + return `${x.toFixed(1)},${y.toFixed(1)}` + }) + .join(' ') +} diff --git a/examples/svelte/realtime-trading/src/table/table-config/trading-columns.ts b/examples/svelte/realtime-trading/src/table/table-config/trading-columns.ts new file mode 100644 index 0000000000..27461145be --- /dev/null +++ b/examples/svelte/realtime-trading/src/table/table-config/trading-columns.ts @@ -0,0 +1,202 @@ +import { createColumnHelper, renderComponent } from '@tanstack/svelte-table' +import { tradingFeatures } from '../trading-features' +import DayChangeCell from './DayChangeCell.svelte' +import LastPriceCell from './LastPriceCell.svelte' +import PercentChangeCell from './PercentChangeCell.svelte' +import SparklineCell from './SparklineCell.svelte' +import { recordCellRender } from './quote-cells' +import type { MarketQuote } from '../../feed/market-data' + +export type RendererMode = 'stable' | 'swap' +export interface CoreTableState { + sorting: Array<{ id: string; desc: boolean }> + columnFilters: Array<{ id: string; value: unknown }> +} + +const compactFormatter = new Intl.NumberFormat('en-US', { + notation: 'compact', + maximumFractionDigits: 1, +}) +const columnHelper = createColumnHelper() + +export const tradingColumns = columnHelper.columns([ + columnHelper.group({ + id: 'instrument', + header: 'Instrument', + columns: columnHelper.columns([ + columnHelper.accessor('venue', { + id: 'market', + header: 'Market', + size: 72, + cell: (info) => recordCellRender('Market', info.getValue()), + }), + columnHelper.accessor('company', { + id: 'name', + header: 'Name', + size: 180, + cell: (info) => recordCellRender('Name', info.getValue()), + }), + columnHelper.accessor('symbol', { + header: 'Symbol', + size: 92, + filterFn: 'includesString', + cell: (info) => recordCellRender('Symbol', info.getValue()), + }), + ]), + }), + columnHelper.group({ + id: 'priceAndChange', + header: 'Price & Change', + columns: columnHelper.columns([ + columnHelper.accessor('price', { + header: 'Price', + size: 96, + sortFn: 'basic', + cell: (info) => + recordCellRender( + 'Last', + renderComponent(LastPriceCell, { quote: info.row.original }), + ), + }), + columnHelper.accessor(getDayChange, { + id: 'change', + header: 'Chg', + size: 94, + cell: (info) => + recordCellRender( + 'Change', + renderComponent(DayChangeCell, { quote: info.row.original }), + ), + }), + columnHelper.accessor(getDayChangePercent, { + id: 'changePercent', + header: 'Chg%', + size: 90, + cell: (info) => + recordCellRender( + 'ChangePercent', + renderComponent(PercentChangeCell, { value: info.getValue() }), + ), + }), + ]), + }), + columnHelper.group({ + id: 'orderBook', + header: 'Order Book', + columns: columnHelper.columns([ + columnHelper.accessor('bid', { + header: 'Bid', + size: 90, + cell: (info) => recordCellRender('Bid', info.getValue().toFixed(2)), + }), + columnHelper.accessor('bidSize', { + header: 'Bid Vol', + size: 100, + cell: (info) => + recordCellRender( + 'BidVolume', + compactFormatter.format(info.getValue()), + ), + }), + columnHelper.accessor('ask', { + header: 'Ask', + size: 90, + cell: (info) => recordCellRender('Ask', info.getValue().toFixed(2)), + }), + columnHelper.accessor('askSize', { + header: 'Ask Vol', + size: 100, + cell: (info) => + recordCellRender( + 'AskVolume', + compactFormatter.format(info.getValue()), + ), + }), + ]), + }), + columnHelper.group({ + id: 'session', + header: 'Session', + columns: columnHelper.columns([ + columnHelper.accessor('open', { + header: 'Open', + size: 90, + cell: (info) => recordCellRender('Open', info.getValue().toFixed(2)), + }), + columnHelper.accessor('high', { + header: 'High', + size: 90, + cell: (info) => recordCellRender('High', info.getValue().toFixed(2)), + }), + columnHelper.accessor('low', { + header: 'Low', + size: 90, + cell: (info) => recordCellRender('Low', info.getValue().toFixed(2)), + }), + ]), + }), + columnHelper.group({ + id: 'chart', + header: 'Chart', + columns: columnHelper.columns([ + columnHelper.accessor('history', { + header: 'Intraday', + size: 150, + enableSorting: false, + cell: (info) => + recordCellRender( + 'Intraday', + renderComponent(SparklineCell, { values: info.getValue() }), + ), + }), + ]), + }), +]) + +export const rowModelDiagnostics = { + hasMeasurement: false, + calls: 0, + totalDurationMs: 0, + maxDurationMs: 0, + lastRowCount: 0, +} +export const TRADING_COLUMN_COUNT = 14 + +export function readMeasuredRows(readRows: () => Array): Array { + const start = performance.now() + const rows = readRows() + const end = performance.now() + const duration = end - start + rowModelDiagnostics.calls++ + rowModelDiagnostics.hasMeasurement = true + rowModelDiagnostics.totalDurationMs += duration + rowModelDiagnostics.maxDurationMs = Math.max( + rowModelDiagnostics.maxDurationMs, + duration, + ) + rowModelDiagnostics.lastRowCount = rows.length + if ((rowModelDiagnostics.calls - 1) % 20 === 0) { + try { + performance.measure('tanstack-row-model', { + start, + end, + detail: { rowCount: rows.length }, + }) + if (rowModelDiagnostics.calls % 20_000 === 0) { + performance.clearMeasures('tanstack-row-model') + } + } catch { + /* User Timing Level 3 is optional. */ + } + } + return rows +} + +export function getDayChange(quote: MarketQuote): number { + return quote.price - quote.previousClose +} +export function getDayChangePercent(quote: MarketQuote): number { + return quote.previousClose === 0 + ? 0 + : (getDayChange(quote) / quote.previousClose) * 100 +} diff --git a/examples/svelte/realtime-trading/src/table/table-interactions.ts b/examples/svelte/realtime-trading/src/table/table-interactions.ts new file mode 100644 index 0000000000..99649a40bd --- /dev/null +++ b/examples/svelte/realtime-trading/src/table/table-interactions.ts @@ -0,0 +1,187 @@ +export type CellDirection = 'up' | 'down' | 'left' | 'right' + +interface RowSelectionTable { + resetRowSelection: (defaultState?: boolean) => void +} + +interface SelectableRow { + getIsSelected: () => boolean + getToggleSelectedHandler: (options?: { + selectChildren?: boolean + }) => (event: unknown) => void +} + +interface SelectableGridCell { + row: SelectableGridRow + getSelectionStartHandler: ( + contextDocument?: Document, + ) => (event: unknown) => void + getSelectionExtendHandler: () => (event: unknown) => void +} + +interface SelectableGridRow extends SelectableRow { + original: { symbol: string } + getAllCellsByColumnId: () => Record +} + +interface TradingGridTable extends RowSelectionTable { + getRowModel: () => { + rowsById: Record + } +} + +interface SelectionCellTarget { + element: HTMLTableCellElement + cell: SelectableGridCell +} + +interface CellNavigationTable { + extendCellSelection: (direction: CellDirection) => void + moveCellSelection: (direction: CellDirection) => void + resetCellSelection: (defaultState?: boolean) => void + selectAllCells: () => void +} + +const keyDirections: Partial> = { + ArrowUp: 'up', + ArrowDown: 'down', + ArrowLeft: 'left', + ArrowRight: 'right', +} + +export function reorderColumnIds( + columnIds: Array, + sourceId: string, + targetId: string, +): Array { + if (sourceId === targetId || !columnIds.includes(sourceId)) return columnIds + + const withoutSource = columnIds.filter((id) => id !== sourceId) + const targetIndex = withoutSource.indexOf(targetId) + if (targetIndex < 0) return columnIds + + return [ + ...withoutSource.slice(0, targetIndex), + sourceId, + ...withoutSource.slice(targetIndex), + ] +} + +export function selectRowFromPointer( + table: RowSelectionTable, + row: SelectableRow, + event: MouseEvent, +): void { + const additive = event.ctrlKey || event.metaKey + const checked = additive ? !row.getIsSelected() : true + + if (!event.shiftKey && !additive) table.resetRowSelection(true) + + row.getToggleSelectedHandler({ selectChildren: false })({ + target: { checked }, + shiftKey: event.shiftKey, + ctrlKey: event.ctrlKey, + metaKey: event.metaKey, + }) +} + +export class TradingGridPointerController { + #lastPointerCell: HTMLTableCellElement | null = null + + handleMouseDown( + table: TradingGridTable, + event: MouseEvent, + selectSymbol: (symbol: string) => void, + ): void { + if (event.button !== 0) return + + const target = this.#findCellTarget(table, event.composedPath()) + if (!target) return + + event.preventDefault() + this.#lastPointerCell = target.element + selectSymbol(target.cell.row.original.symbol) + target.cell.getSelectionStartHandler(target.element.ownerDocument)(event) + } + + handlePointerOver(table: TradingGridTable, event: MouseEvent): void { + if ((event.buttons & 1) === 0) { + this.resetPointerCell() + return + } + + const target = this.#findCellTarget(table, event.composedPath()) + if (!target || target.element === this.#lastPointerCell) return + + this.#lastPointerCell = target.element + target.cell.getSelectionExtendHandler()(event) + } + + handleClick(table: TradingGridTable, event: MouseEvent): void { + const target = this.#findCellTarget(table, event.composedPath()) + if (!target) return + selectRowFromPointer(table, target.cell.row, event) + } + + resetPointerCell(): void { + this.#lastPointerCell = null + } + + #findCellTarget( + table: TradingGridTable, + path: Array, + ): SelectionCellTarget | null { + for (const target of path) { + if (!(target instanceof HTMLTableCellElement)) continue + + const columnId = target.dataset['columnId'] + const rowId = + target.closest('tr[data-row-id]')?.dataset['rowId'] + if (!columnId || !rowId) return null + + const row = table.getRowModel().rowsById[rowId] + const cell = row.getAllCellsByColumnId()[columnId] + return { element: target, cell } + } + + return null + } +} + +export function handleCellNavigation( + table: CellNavigationTable, + event: KeyboardEvent, +): void { + if (event.key === 'Escape') { + event.preventDefault() + table.resetCellSelection(true) + return + } + + if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a') { + event.preventDefault() + table.selectAllCells() + return + } + + const direction = keyDirections[event.key] + if (!direction) return + + event.preventDefault() + if (event.shiftKey) table.extendCellSelection(direction) + else table.moveCellSelection(direction) +} + +export function sortIndicator(direction: false | 'asc' | 'desc'): string { + if (direction === 'asc') return '↑' + if (direction === 'desc') return '↓' + return '↕' +} + +export function sortAriaValue( + direction: false | 'asc' | 'desc', +): 'ascending' | 'descending' | 'none' { + if (direction === 'asc') return 'ascending' + if (direction === 'desc') return 'descending' + return 'none' +} diff --git a/examples/svelte/realtime-trading/src/table/trading-features.ts b/examples/svelte/realtime-trading/src/table/trading-features.ts new file mode 100644 index 0000000000..dedf4d1c5e --- /dev/null +++ b/examples/svelte/realtime-trading/src/table/trading-features.ts @@ -0,0 +1,16 @@ +import { + createFilteredRowModel, + createSortedRowModel, + filterFn_includesString, + sortFn_basic, + stockFeatures, + tableFeatures, +} from '@tanstack/svelte-table' + +export const tradingFeatures = tableFeatures({ + ...stockFeatures, + filteredRowModel: createFilteredRowModel(), + sortedRowModel: createSortedRowModel(), + filterFns: { includesString: filterFn_includesString }, + sortFns: { basic: sortFn_basic }, +}) diff --git a/examples/svelte/realtime-trading/src/table/trading-row-virtualizer.ts b/examples/svelte/realtime-trading/src/table/trading-row-virtualizer.ts new file mode 100644 index 0000000000..bc4b34b528 --- /dev/null +++ b/examples/svelte/realtime-trading/src/table/trading-row-virtualizer.ts @@ -0,0 +1,18 @@ +export const TRADING_ROW_HEIGHT = 32 +export const TRADING_ROW_OVERSCAN = 10 +export const DEFAULT_VIRTUALIZATION_ROW_COUNT = 200 +export const FORCED_VIRTUALIZATION_ROW_COUNT = 1_500 + +export type VirtualScrollMode = 'tanstack' | 'none' +export type VirtualScrollPreference = VirtualScrollMode | 'auto' + +export function resolveVirtualScrollMode( + requestedMode: VirtualScrollPreference, + instrumentCount: number, +): VirtualScrollMode { + if (instrumentCount >= FORCED_VIRTUALIZATION_ROW_COUNT) return 'tanstack' + if (requestedMode !== 'auto') return requestedMode + return instrumentCount >= DEFAULT_VIRTUALIZATION_ROW_COUNT + ? 'tanstack' + : 'none' +} diff --git a/examples/svelte/realtime-trading/src/table/trading-table.ts b/examples/svelte/realtime-trading/src/table/trading-table.ts new file mode 100644 index 0000000000..77e4e6bee1 --- /dev/null +++ b/examples/svelte/realtime-trading/src/table/trading-table.ts @@ -0,0 +1,9 @@ +export { + TRADING_COLUMN_COUNT, + rowModelDiagnostics, +} from './table-config/trading-columns' +export type { + CoreTableState, + RendererMode, +} from './table-config/trading-columns' +export type { VirtualScrollMode } from './trading-row-virtualizer' diff --git a/examples/svelte/realtime-trading/src/vite-env.d.ts b/examples/svelte/realtime-trading/src/vite-env.d.ts new file mode 100644 index 0000000000..11f02fe2a0 --- /dev/null +++ b/examples/svelte/realtime-trading/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/examples/svelte/realtime-trading/tests/e2e/smoke.spec.ts b/examples/svelte/realtime-trading/tests/e2e/smoke.spec.ts new file mode 100644 index 0000000000..2355f46485 --- /dev/null +++ b/examples/svelte/realtime-trading/tests/e2e/smoke.spec.ts @@ -0,0 +1,183 @@ +import path from 'node:path' +import { expect, test } from '@playwright/test' +import { startExampleServer } from '../../../../../tests/e2e/helpers/startExampleServer' +import { + setRangeValue, + scrollTradingTable, + resumeTradingFeed, + pausedFeedUrl, +} from '../../../../../tests/e2e/helpers/setRangeValue' +import type { Page } from '@playwright/test' + +const exampleDir = path.resolve() + +function collectPageErrors(page: Page) { + const errors: Array = [] + page.on('pageerror', (error) => errors.push(error.message)) + page.on('console', (message) => { + if (message.type() === 'error') errors.push(message.text()) + }) + return errors +} + +test('runs the Svelte realtime trading workload', async ({ page }) => { + test.setTimeout(120_000) + const server = await startExampleServer(exampleDir) + const errors = collectPageErrors(page) + + try { + await page.goto(pausedFeedUrl(server.url)) + + const table = page.getByTestId('trading-table') + const instrumentCount = page.getByTestId('instrument-count-select') + const virtualScrollSelect = page.getByTestId('virtual-scroll-select') + await expect(table).toBeVisible() + await expect(instrumentCount).toHaveValue('100') + await expect(page.locator('.brand')).toHaveText('MARKET MONITOR') + await expect(virtualScrollSelect).toHaveValue('none') + await expect(virtualScrollSelect).toBeEnabled() + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(table.locator('tbody')).toHaveCSS('user-select', 'none') + await expect(table.locator('tbody tr').first()).toHaveCSS( + 'content-visibility', + 'auto', + ) + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await instrumentCount.selectOption('250') + await expect(virtualScrollSelect).toHaveValue('tanstack') + await expect(virtualScrollSelect).toBeEnabled() + await expect.poll(() => table.locator('tbody tr').count()).toBeLessThan(250) + await expect(page.getByTestId('virtual-scroll-footer')).toBeVisible() + await instrumentCount.selectOption('100') + await expect(virtualScrollSelect).toHaveValue('none') + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await virtualScrollSelect.selectOption('tanstack') + await expect.poll(() => table.locator('tbody tr').count()).toBeLessThan(100) + await expect(table.locator('tbody tr').first()).toHaveCSS( + 'content-visibility', + 'auto', + ) + await expect(page.getByTestId('virtual-scroll-footer')).toBeVisible() + await virtualScrollSelect.selectOption('none') + await expect(table.locator('tbody tr')).toHaveCount(100) + await instrumentCount.selectOption('1500') + await expect(virtualScrollSelect).toHaveValue('tanstack') + await expect(virtualScrollSelect).toBeDisabled() + await expect + .poll(() => table.locator('tbody tr').count()) + .toBeLessThan(1500) + await expect(page.getByTestId('virtual-scroll-footer')).toContainText( + 'Total · 1500 rows · 14 columns', + ) + await expect(page.getByTestId('visible-row-range')).toHaveText( + /^\s*Current · rows 0\.\.\d+\s*$/, + ) + await scrollTradingTable(page, 2_000) + await expect + .poll(async () => + Number( + await table + .locator('tbody tr') + .first() + .getAttribute('data-virtual-index'), + ), + ) + .toBeGreaterThan(0) + await expect(page.getByTestId('visible-row-range')).toHaveText( + /^\s*Current · rows [1-9]\d*\.\.\d+\s*$/, + ) + await instrumentCount.selectOption('100') + await expect(page.getByTestId('virtual-scroll-footer')).toHaveCount(0) + await expect(virtualScrollSelect).toHaveValue('none') + await expect(virtualScrollSelect).toBeEnabled() + await expect(table.locator('tbody tr')).toHaveCount(100) + await expect(table.locator('thead tr')).toHaveCount(2) + await expect(table.locator('thead tr').last().locator('th')).toHaveCount(14) + await expect(table.locator('thead')).not.toContainText('Identity') + await expect(table.locator('thead')).not.toContainText('Market Data') + await expect(table.locator('thead')).toContainText('Market') + await expect(table.locator('thead')).toContainText('Bid Vol') + await expect(table.locator('thead')).toContainText('Intraday') + const selectedRow = table.locator('tbody tr').first() + const selectedSymbol = await selectedRow.getAttribute('data-symbol') + await selectedRow.locator('td').nth(1).click() + await expect(page.getByTestId('selected-instrument')).toContainText( + selectedSymbol ?? '', + ) + await expect(page.getByTestId('feed-status')).toHaveText('FEED PAUSED') + await expect(instrumentCount.locator('option[value="150"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="350"]')).toHaveCount(1) + await expect(instrumentCount.locator('option[value="750"]')).toHaveCount(1) + + const targetRateSlider = page.getByTestId('target-rate-slider') + await expect(targetRateSlider).toHaveAttribute('min', '0') + await expect(targetRateSlider).toHaveAttribute('max', '9') + await expect(targetRateSlider).toHaveAttribute('step', '1') + await expect(targetRateSlider).toHaveValue('6') + await setRangeValue(targetRateSlider, '7') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '25K samples/s', + ) + await setRangeValue(targetRateSlider, '8') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '50K samples/s', + ) + await setRangeValue(targetRateSlider, '6') + + const sparklineInterval = page.getByTestId( + 'sparkline-sample-interval-select', + ) + await expect(sparklineInterval).toHaveValue('16') + await sparklineInterval.selectOption('100') + await expect(sparklineInterval).toHaveValue('100') + await sparklineInterval.selectOption('16') + + const publishInterval = page.getByTestId('publish-interval-select') + await expect(publishInterval.locator('option[value="500"]')).toHaveCount(1) + await expect(publishInterval.locator('option[value="1000"]')).toHaveCount(1) + + // Exercise delivery and rendering without turning this smoke test into a + // throughput benchmark on shared CI runners. Configure controls while paused. + await setRangeValue(targetRateSlider, '0') + await expect(page.getByTestId('target-sample-rate')).toContainText( + '100 samples/s', + ) + await publishInterval.selectOption('500') + await expect(publishInterval).toHaveValue('500') + await sparklineInterval.selectOption('100') + const swapRenderer = page.getByRole('checkbox', { + name: /Swap Tick component/, + }) + await swapRenderer.check() + await expect(swapRenderer).toBeChecked() + + const firstPrice = table.locator('tbody tr').first().getByRole('button') + const priceBeforeUpdate = await firstPrice.textContent() + await resumeTradingFeed(page) + await expect + .poll(() => firstPrice.textContent()) + .not.toBe(priceBeforeUpdate) + + await page.getByTestId('feed-toggle').click() + await expect(page.getByTestId('feed-toggle')).toHaveText('START FEED') + await expect(page.getByTestId('feed-status')).toHaveText('FEED PAUSED') + + // Delivery is cumulative; instantaneous rates can legitimately fall to + // zero between samples on a busy runner. The price assertion above proves + // that a delivered update reached the rendered table. + await expect + .poll(async () => { + const text = await page.getByTestId('worker-messages').textContent() + return Number(text?.replace(/\D/g, '') ?? 0) + }) + .toBeGreaterThan(0) + + await instrumentCount.selectOption('750') + await expect.poll(() => table.locator('tbody tr').count()).toBeLessThan(750) + + expect(errors).toEqual([]) + } finally { + await server.close() + } +}) diff --git a/examples/svelte/realtime-trading/tsconfig.json b/examples/svelte/realtime-trading/tsconfig.json new file mode 100644 index 0000000000..f5abb31723 --- /dev/null +++ b/examples/svelte/realtime-trading/tsconfig.json @@ -0,0 +1,25 @@ +{ + "extends": "@tsconfig/svelte/tsconfig.json", + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "types": ["svelte", "vite/client"] + }, + "include": [ + "src/**/*.d.ts", + "src/**/*.ts", + "src/**/*.svelte", + "tests/**/*.ts", + "vite.config.ts" + ] +} diff --git a/examples/svelte/realtime-trading/vite.config.ts b/examples/svelte/realtime-trading/vite.config.ts new file mode 100644 index 0000000000..476cc68e22 --- /dev/null +++ b/examples/svelte/realtime-trading/vite.config.ts @@ -0,0 +1,7 @@ +import { svelte } from '@sveltejs/vite-plugin-svelte' +import { defineConfig } from 'vite' + +export default defineConfig({ + server: { port: 7777, allowedHosts: true }, + plugins: [svelte()], +}) diff --git a/examples/svelte/row-pinning/package.json b/examples/svelte/row-pinning/package.json index f4bbfe5513..64f462bfb7 100644 --- a/examples/svelte/row-pinning/package.json +++ b/examples/svelte/row-pinning/package.json @@ -11,14 +11,15 @@ "lint": "eslint ./src" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@sveltejs/vite-plugin-svelte": "^7.3.0", - "@tanstack/svelte-table": "^9.1.2", - "@tsconfig/svelte": "^5.0.8", - "svelte": "^5.56.8", - "svelte-check": "^4.7.4", + "@sveltejs/vite-plugin-svelte": "^7.3.1", + "@tanstack/svelte-table": "^9.3.2", + "@tsconfig/svelte": "^5.0.9", + "svelte": "^5.57.3", + "svelte-check": "^4.7.8", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/svelte/row-selection/package.json b/examples/svelte/row-selection/package.json index 5b8a3999d4..fc3449bb84 100644 --- a/examples/svelte/row-selection/package.json +++ b/examples/svelte/row-selection/package.json @@ -11,14 +11,15 @@ "lint": "eslint ./src" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@sveltejs/vite-plugin-svelte": "^7.3.0", - "@tanstack/svelte-table": "^9.1.2", - "@tsconfig/svelte": "^5.0.8", - "svelte": "^5.56.8", - "svelte-check": "^4.7.4", + "@sveltejs/vite-plugin-svelte": "^7.3.1", + "@tanstack/svelte-table": "^9.3.2", + "@tsconfig/svelte": "^5.0.9", + "svelte": "^5.57.3", + "svelte-check": "^4.7.8", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/svelte/sorting/package.json b/examples/svelte/sorting/package.json index ae90a73844..fb89afc09f 100644 --- a/examples/svelte/sorting/package.json +++ b/examples/svelte/sorting/package.json @@ -11,14 +11,15 @@ "lint": "eslint ./src" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@sveltejs/vite-plugin-svelte": "^7.3.0", - "@tanstack/svelte-table": "^9.1.2", - "@tsconfig/svelte": "^5.0.8", - "svelte": "^5.56.8", - "svelte-check": "^4.7.4", + "@sveltejs/vite-plugin-svelte": "^7.3.1", + "@tanstack/svelte-table": "^9.3.2", + "@tsconfig/svelte": "^5.0.9", + "svelte": "^5.57.3", + "svelte-check": "^4.7.8", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/svelte/spreadsheet/package.json b/examples/svelte/spreadsheet/package.json index 62d3e38489..a516f9caef 100644 --- a/examples/svelte/spreadsheet/package.json +++ b/examples/svelte/spreadsheet/package.json @@ -12,16 +12,17 @@ "test:types": "svelte-check --tsconfig ./tsconfig.json" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@sveltejs/vite-plugin-svelte": "^7.3.0", - "@tanstack/svelte-hotkeys": "^0.10.0", - "@tanstack/svelte-table": "^9.1.2", - "@tanstack/svelte-virtual": "^3.13.35", - "@tsconfig/svelte": "^5.0.8", - "svelte": "^5.56.8", - "svelte-check": "^4.7.4", + "@sveltejs/vite-plugin-svelte": "^7.3.1", + "@tanstack/svelte-hotkeys": "^0.24.0", + "@tanstack/svelte-table": "^9.3.2", + "@tanstack/svelte-virtual": "^3.13.52", + "@tsconfig/svelte": "^5.0.9", + "svelte": "^5.57.3", + "svelte-check": "^4.7.8", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/svelte/spreadsheet/src/createGridInteractions.svelte.ts b/examples/svelte/spreadsheet/src/createGridInteractions.svelte.ts index fb1dc1a265..9adaae72b5 100644 --- a/examples/svelte/spreadsheet/src/createGridInteractions.svelte.ts +++ b/examples/svelte/spreadsheet/src/createGridInteractions.svelte.ts @@ -460,12 +460,16 @@ export function createGridInteractions(options: GridInteractionOptions) { (event: KeyboardEvent) => { if (event.key === 'Escape') { event.preventDefault() + // the grid's own hotkeys must not also act on a key the editor handled + event.stopPropagation() cancelEditing() } else if (event.key === 'Enter') { event.preventDefault() + event.stopPropagation() commitEditing(event.shiftKey ? 'up' : 'down') } else if (event.key === 'Tab') { event.preventDefault() + event.stopPropagation() commitEditing(event.shiftKey ? 'left' : 'right') } }, diff --git a/examples/svelte/sub-components/package.json b/examples/svelte/sub-components/package.json index 09cd6432d8..6aa42abf55 100644 --- a/examples/svelte/sub-components/package.json +++ b/examples/svelte/sub-components/package.json @@ -11,14 +11,15 @@ "lint": "eslint ./src" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@sveltejs/vite-plugin-svelte": "^7.3.0", - "@tanstack/svelte-table": "^9.1.2", - "@tsconfig/svelte": "^5.0.8", - "svelte": "^5.56.8", - "svelte-check": "^4.7.4", + "@sveltejs/vite-plugin-svelte": "^7.3.1", + "@tanstack/svelte-table": "^9.3.2", + "@tsconfig/svelte": "^5.0.9", + "svelte": "^5.57.3", + "svelte-check": "^4.7.8", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/svelte/virtualized-columns/package.json b/examples/svelte/virtualized-columns/package.json index 0d927b7a8b..f598abd871 100644 --- a/examples/svelte/virtualized-columns/package.json +++ b/examples/svelte/virtualized-columns/package.json @@ -11,15 +11,16 @@ "lint": "eslint ./src" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@sveltejs/vite-plugin-svelte": "^7.3.0", - "@tanstack/svelte-table": "^9.1.2", - "@tanstack/svelte-virtual": "^3.13.35", - "@tsconfig/svelte": "^5.0.8", - "svelte": "^5.56.8", - "svelte-check": "^4.7.4", + "@sveltejs/vite-plugin-svelte": "^7.3.1", + "@tanstack/svelte-table": "^9.3.2", + "@tanstack/svelte-virtual": "^3.13.52", + "@tsconfig/svelte": "^5.0.9", + "svelte": "^5.57.3", + "svelte-check": "^4.7.8", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/svelte/virtualized-infinite-scrolling/package.json b/examples/svelte/virtualized-infinite-scrolling/package.json index 51bc9051ba..45e268cc1d 100644 --- a/examples/svelte/virtualized-infinite-scrolling/package.json +++ b/examples/svelte/virtualized-infinite-scrolling/package.json @@ -11,16 +11,17 @@ "lint": "eslint ./src" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@sveltejs/vite-plugin-svelte": "^7.3.0", - "@tanstack/svelte-query": "^6.1.38", - "@tanstack/svelte-table": "^9.1.2", - "@tanstack/svelte-virtual": "^3.13.35", - "@tsconfig/svelte": "^5.0.8", - "svelte": "^5.56.8", - "svelte-check": "^4.7.4", + "@sveltejs/vite-plugin-svelte": "^7.3.1", + "@tanstack/svelte-query": "^6.4.1", + "@tanstack/svelte-table": "^9.3.2", + "@tanstack/svelte-virtual": "^3.13.52", + "@tsconfig/svelte": "^5.0.9", + "svelte": "^5.57.3", + "svelte-check": "^4.7.8", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/svelte/virtualized-rows/package.json b/examples/svelte/virtualized-rows/package.json index 61e45a1dcb..713817cd8e 100644 --- a/examples/svelte/virtualized-rows/package.json +++ b/examples/svelte/virtualized-rows/package.json @@ -11,15 +11,16 @@ "lint": "eslint ./src" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@sveltejs/vite-plugin-svelte": "^7.3.0", - "@tanstack/svelte-table": "^9.1.2", - "@tanstack/svelte-virtual": "^3.13.35", - "@tsconfig/svelte": "^5.0.8", - "svelte": "^5.56.8", - "svelte-check": "^4.7.4", + "@sveltejs/vite-plugin-svelte": "^7.3.1", + "@tanstack/svelte-table": "^9.3.2", + "@tanstack/svelte-virtual": "^3.13.52", + "@tsconfig/svelte": "^5.0.9", + "svelte": "^5.57.3", + "svelte-check": "^4.7.8", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" } } diff --git a/examples/svelte/with-tanstack-form/package.json b/examples/svelte/with-tanstack-form/package.json index f0b224107f..4d53483195 100644 --- a/examples/svelte/with-tanstack-form/package.json +++ b/examples/svelte/with-tanstack-form/package.json @@ -11,21 +11,22 @@ "lint": "eslint ./src" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@sveltejs/vite-plugin-svelte": "^7.3.0", - "@tsconfig/svelte": "^5.0.8", - "svelte": "^5.56.8", - "svelte-check": "^4.7.4", + "@sveltejs/vite-plugin-svelte": "^7.3.1", + "@tsconfig/svelte": "^5.0.9", + "svelte": "^5.57.3", + "svelte-check": "^4.7.8", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "dependencies": { "@tanstack/form-core": "^1.33.5", - "@tanstack/svelte-devtools": "^0.1.3", + "@tanstack/svelte-devtools": "^0.1.8", "@tanstack/svelte-form": "^1.33.5", - "@tanstack/svelte-table": "^9.1.2", - "@tanstack/table-devtools": "^9.2.0", - "zod": "^4.4.3" + "@tanstack/svelte-table": "^9.3.2", + "@tanstack/table-devtools": "^9.3.2", + "zod": "^4.6.7" } } diff --git a/examples/svelte/with-tanstack-query/package.json b/examples/svelte/with-tanstack-query/package.json index 8907949027..3bc7f57fd1 100644 --- a/examples/svelte/with-tanstack-query/package.json +++ b/examples/svelte/with-tanstack-query/package.json @@ -11,21 +11,22 @@ "lint": "eslint ./src" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@sveltejs/vite-plugin-svelte": "^7.3.0", - "@tsconfig/svelte": "^5.0.8", - "svelte": "^5.56.8", - "svelte-check": "^4.7.4", + "@sveltejs/vite-plugin-svelte": "^7.3.1", + "@tsconfig/svelte": "^5.0.9", + "svelte": "^5.57.3", + "svelte-check": "^4.7.8", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "dependencies": { - "@tanstack/query-devtools": "^5.101.4", - "@tanstack/svelte-devtools": "^0.1.3", - "@tanstack/svelte-query": "^6.1.38", - "@tanstack/svelte-query-devtools": "^6.1.38", - "@tanstack/svelte-table": "^9.1.2", - "@tanstack/table-devtools": "^9.2.0" + "@tanstack/query-devtools": "^5.107.1", + "@tanstack/svelte-devtools": "^0.1.8", + "@tanstack/svelte-query": "^6.4.1", + "@tanstack/svelte-query-devtools": "^6.4.1", + "@tanstack/svelte-table": "^9.3.2", + "@tanstack/table-devtools": "^9.3.2" } } diff --git a/examples/vanilla/aggregation/package.json b/examples/vanilla/aggregation/package.json index 6dcdc1fbdd..514024de9c 100644 --- a/examples/vanilla/aggregation/package.json +++ b/examples/vanilla/aggregation/package.json @@ -11,13 +11,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@types/node": "^26.2.0", + "@types/node": "^26.6.6", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "dependencies": { - "@tanstack/table-core": "^9.1.2" + "@tanstack/table-core": "^9.3.1" } } diff --git a/examples/vanilla/basic/package.json b/examples/vanilla/basic/package.json index 2fa94985d1..7bc214d147 100644 --- a/examples/vanilla/basic/package.json +++ b/examples/vanilla/basic/package.json @@ -11,13 +11,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@types/node": "^26.2.0", + "@types/node": "^26.6.6", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "dependencies": { - "@tanstack/table-core": "^9.1.2" + "@tanstack/table-core": "^9.3.1" } } diff --git a/examples/vanilla/pagination/package.json b/examples/vanilla/pagination/package.json index 111d02bff3..30e7a44319 100644 --- a/examples/vanilla/pagination/package.json +++ b/examples/vanilla/pagination/package.json @@ -11,13 +11,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@types/node": "^26.2.0", + "@types/node": "^26.6.6", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "dependencies": { - "@tanstack/table-core": "^9.1.2" + "@tanstack/table-core": "^9.3.1" } } diff --git a/examples/vanilla/sorting/package.json b/examples/vanilla/sorting/package.json index 1687b29fe1..ce2f2e5e22 100644 --- a/examples/vanilla/sorting/package.json +++ b/examples/vanilla/sorting/package.json @@ -11,13 +11,14 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "devDependencies": { - "@faker-js/faker": "^10.5.0", + "@faker-js/faker": "^10.6.0", + "@rolldown/binding-wasm32-wasi": "~1.3.2", "@rollup/plugin-replace": "^6.0.3", - "@types/node": "^26.2.0", + "@types/node": "^26.6.6", "typescript": "6.0.3", - "vite": "^8.2.1" + "vite": "^8.3.8" }, "dependencies": { - "@tanstack/table-core": "^9.1.2" + "@tanstack/table-core": "^9.3.1" } } diff --git a/examples/vue/aggregation/package.json b/examples/vue/aggregation/package.json index bf9ba01713..a4698557ad 100644 --- a/examples/vue/aggregation/package.json +++ b/examples/vue/aggregation/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/basic-dynamic-columns/package.json b/examples/vue/basic-dynamic-columns/package.json index 0dc1b94ff0..f5e64b5ed7 100644 --- a/examples/vue/basic-dynamic-columns/package.json +++ b/examples/vue/basic-dynamic-columns/package.json @@ -10,18 +10,19 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-devtools": "^0.2.24", - "@tanstack/vue-table": "^9.1.2", - "@tanstack/vue-table-devtools": "^9.2.0", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-devtools": "^0.2.28", + "@tanstack/vue-table": "^9.3.1", + "@tanstack/vue-table-devtools": "^9.3.2", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/basic-external-atoms/package.json b/examples/vue/basic-external-atoms/package.json index 297d98b7cc..de1eb5aa2d 100644 --- a/examples/vue/basic-external-atoms/package.json +++ b/examples/vue/basic-external-atoms/package.json @@ -10,19 +10,20 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-devtools": "^0.2.24", - "@tanstack/vue-store": "^0.11.1", - "@tanstack/vue-table": "^9.1.2", - "@tanstack/vue-table-devtools": "^9.2.0", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-devtools": "^0.2.28", + "@tanstack/vue-store": "^0.11.2", + "@tanstack/vue-table": "^9.3.1", + "@tanstack/vue-table-devtools": "^9.3.2", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/basic-external-state/package.json b/examples/vue/basic-external-state/package.json index 03ff00fbfa..9305d91422 100644 --- a/examples/vue/basic-external-state/package.json +++ b/examples/vue/basic-external-state/package.json @@ -10,18 +10,19 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-devtools": "^0.2.24", - "@tanstack/vue-table": "^9.1.2", - "@tanstack/vue-table-devtools": "^9.2.0", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-devtools": "^0.2.28", + "@tanstack/vue-table": "^9.3.1", + "@tanstack/vue-table-devtools": "^9.3.2", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/basic-use-app-table/package.json b/examples/vue/basic-use-app-table/package.json index 877e0cde68..d2f8ed79ac 100644 --- a/examples/vue/basic-use-app-table/package.json +++ b/examples/vue/basic-use-app-table/package.json @@ -10,17 +10,18 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@tanstack/vue-devtools": "^0.2.24", - "@tanstack/vue-table": "^9.1.2", - "@tanstack/vue-table-devtools": "^9.2.0", - "vue": "^3.5.41" + "@tanstack/vue-devtools": "^0.2.28", + "@tanstack/vue-table": "^9.3.1", + "@tanstack/vue-table-devtools": "^9.3.2", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/basic-use-table/package.json b/examples/vue/basic-use-table/package.json index ee0faba314..44d9686fc3 100644 --- a/examples/vue/basic-use-table/package.json +++ b/examples/vue/basic-use-table/package.json @@ -10,17 +10,18 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@tanstack/vue-devtools": "^0.2.24", - "@tanstack/vue-table": "^9.1.2", - "@tanstack/vue-table-devtools": "^9.2.0", - "vue": "^3.5.41" + "@tanstack/vue-devtools": "^0.2.28", + "@tanstack/vue-table": "^9.3.1", + "@tanstack/vue-table-devtools": "^9.3.2", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/cell-selection/package.json b/examples/vue/cell-selection/package.json index c80bfad81d..605bc8e934 100644 --- a/examples/vue/cell-selection/package.json +++ b/examples/vue/cell-selection/package.json @@ -10,19 +10,20 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-devtools": "^0.2.24", - "@tanstack/vue-hotkeys": "^0.10.0", - "@tanstack/vue-table": "^9.1.2", - "@tanstack/vue-table-devtools": "^9.2.0", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-devtools": "^0.2.28", + "@tanstack/vue-hotkeys": "^0.24.0", + "@tanstack/vue-table": "^9.3.1", + "@tanstack/vue-table-devtools": "^9.3.2", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/cell-spanning/package.json b/examples/vue/cell-spanning/package.json index a2fbdf69ea..9b0aeabf37 100644 --- a/examples/vue/cell-spanning/package.json +++ b/examples/vue/cell-spanning/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/column-ordering/package.json b/examples/vue/column-ordering/package.json index e44181184b..e367f7d0a3 100644 --- a/examples/vue/column-ordering/package.json +++ b/examples/vue/column-ordering/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/column-pinning-split/package.json b/examples/vue/column-pinning-split/package.json index cdad925117..6daae52f7c 100644 --- a/examples/vue/column-pinning-split/package.json +++ b/examples/vue/column-pinning-split/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/column-pinning-sticky/package.json b/examples/vue/column-pinning-sticky/package.json index 0e6ad74612..9e7ab1e8f6 100644 --- a/examples/vue/column-pinning-sticky/package.json +++ b/examples/vue/column-pinning-sticky/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/column-pinning/package.json b/examples/vue/column-pinning/package.json index 1920124330..f312d5e048 100644 --- a/examples/vue/column-pinning/package.json +++ b/examples/vue/column-pinning/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/column-resizing-performant/package.json b/examples/vue/column-resizing-performant/package.json index 5e4ab12af4..2740ea2117 100644 --- a/examples/vue/column-resizing-performant/package.json +++ b/examples/vue/column-resizing-performant/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/column-resizing/package.json b/examples/vue/column-resizing/package.json index f3c45879e2..bc50f4a43b 100644 --- a/examples/vue/column-resizing/package.json +++ b/examples/vue/column-resizing/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/column-sizing/package.json b/examples/vue/column-sizing/package.json index b785ca9e13..645a85112e 100644 --- a/examples/vue/column-sizing/package.json +++ b/examples/vue/column-sizing/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/column-visibility/package.json b/examples/vue/column-visibility/package.json index a520c5d72b..7d0c2af9d4 100644 --- a/examples/vue/column-visibility/package.json +++ b/examples/vue/column-visibility/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/composable-tables/package.json b/examples/vue/composable-tables/package.json index 9122a185c8..0759a911be 100644 --- a/examples/vue/composable-tables/package.json +++ b/examples/vue/composable-tables/package.json @@ -10,18 +10,19 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@tanstack/vue-devtools": "^0.2.24", - "@tanstack/vue-store": "^0.11.1", - "@tanstack/vue-table": "^9.1.2", - "@tanstack/vue-table-devtools": "^9.2.0", - "vue": "^3.5.41" + "@tanstack/vue-devtools": "^0.2.28", + "@tanstack/vue-store": "^0.11.2", + "@tanstack/vue-table": "^9.3.1", + "@tanstack/vue-table-devtools": "^9.3.2", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/expanding/package.json b/examples/vue/expanding/package.json index d981aa2e1e..19b05c8dbc 100644 --- a/examples/vue/expanding/package.json +++ b/examples/vue/expanding/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/filters-faceted-bucketed/package.json b/examples/vue/filters-faceted-bucketed/package.json index 96b12d208c..25b293c109 100644 --- a/examples/vue/filters-faceted-bucketed/package.json +++ b/examples/vue/filters-faceted-bucketed/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/filters-faceted/package.json b/examples/vue/filters-faceted/package.json index 58f4e6f51f..47ceb9f42c 100644 --- a/examples/vue/filters-faceted/package.json +++ b/examples/vue/filters-faceted/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/filters-fuzzy/package.json b/examples/vue/filters-fuzzy/package.json index 0805e21b79..76503cc087 100644 --- a/examples/vue/filters-fuzzy/package.json +++ b/examples/vue/filters-fuzzy/package.json @@ -10,17 +10,18 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/filters/package.json b/examples/vue/filters/package.json index 04dc30faa4..7c54c41ffc 100644 --- a/examples/vue/filters/package.json +++ b/examples/vue/filters/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/grouped-aggregation/package.json b/examples/vue/grouped-aggregation/package.json index 844bf1c577..2bb3af64cf 100644 --- a/examples/vue/grouped-aggregation/package.json +++ b/examples/vue/grouped-aggregation/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/grouping/package.json b/examples/vue/grouping/package.json index e8d854c17c..3baa872c54 100644 --- a/examples/vue/grouping/package.json +++ b/examples/vue/grouping/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/header-groups/package.json b/examples/vue/header-groups/package.json index 22071cf6e2..f834498d5f 100644 --- a/examples/vue/header-groups/package.json +++ b/examples/vue/header-groups/package.json @@ -10,16 +10,17 @@ "test:e2e": "PLAYWRIGHT_TEST_DIR=$PWD/tests/e2e playwright test --config ../../../playwright.config.ts" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@tanstack/vue-table": "^9.1.2", - "vue": "^3.5.41" + "@faker-js/faker": "^10.6.0", + "@tanstack/vue-table": "^9.3.1", + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/kitchen-sink-shadcn/package.json b/examples/vue/kitchen-sink-shadcn/package.json index edd3686cd6..94dc3ec184 100644 --- a/examples/vue/kitchen-sink-shadcn/package.json +++ b/examples/vue/kitchen-sink-shadcn/package.json @@ -12,31 +12,32 @@ "shadcn": "pnpm dlx shadcn-vue@latest" }, "dependencies": { - "@faker-js/faker": "^10.5.0", - "@internationalized/date": "^3.12.3", - "@lucide/vue": "^1.31.0", - "@tailwindcss/vite": "^4.3.3", - "@tanstack/match-sorter-utils": "^9.1.2", - "@tanstack/pacer": "^0.22.0", - "@tanstack/vue-devtools": "^0.2.24", - "@tanstack/vue-table": "^9.1.2", - "@tanstack/vue-table-devtools": "^9.2.0", - "@vueuse/core": "^14.4.0", + "@faker-js/faker": "^10.6.0", + "@internationalized/date": "^3.12.4", + "@lucide/vue": "^1.72.0", + "@tailwindcss/vite": "^4.3.5", + "@tanstack/match-sorter-utils": "^9.2.6", + "@tanstack/pacer": "^0.23.1", + "@tanstack/vue-devtools": "^0.2.28", + "@tanstack/vue-table": "^9.3.1", + "@tanstack/vue-table-devtools": "^9.3.2", + "@vueuse/core": "^15.0.0", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "dnd-kit-vue": "^0.0.2", - "reka-ui": "^2.10.3", - "tailwind-merge": "^3.6.0", - "tailwindcss": "^4.3.3", + "reka-ui": "^2.11.0", + "tailwind-merge": "^3.7.0", + "tailwindcss": "^4.3.5", "tw-animate-css": "^1.4.0", - "vue": "^3.5.41" + "vue": "^3.5.45" }, "devDependencies": { - "@types/node": "^26.2.0", - "@vitejs/plugin-vue": "^6.0.8", + "@rolldown/binding-wasm32-wasi": "~1.3.2", + "@types/node": "^26.6.6", + "@vitejs/plugin-vue": "^6.0.11", "@vitejs/plugin-vue-jsx": "^5.1.6", "typescript": "6.0.3", - "vite": "^8.2.1", - "vue-tsc": "^3.3.9" + "vite": "^8.3.8", + "vue-tsc": "^3.3.14" } } diff --git a/examples/vue/kitchen-sink-shadcn/src/components/data-table/DataTableFilterList.vue b/examples/vue/kitchen-sink-shadcn/src/components/data-table/DataTableFilterList.vue index 04bf1383d7..65aaf319c8 100644 --- a/examples/vue/kitchen-sink-shadcn/src/components/data-table/DataTableFilterList.vue +++ b/examples/vue/kitchen-sink-shadcn/src/components/data-table/DataTableFilterList.vue @@ -7,7 +7,7 @@ import type { FilterOperator, JoinOperator, } from '@/types' -import type { Column, RowData } from '@tanstack/vue-table' +import type { Column, RowData, VueTable } from '@tanstack/vue-table' import type { features } from '@/hooks/features' import { Badge } from '@/components/ui/badge' @@ -37,7 +37,7 @@ import { cn } from '@/lib/utils' import { useTableContext } from '@/hooks/table' import DataTableFilterValueInput from '@/components/data-table/DataTableFilterValueInput.vue' -const table = useTableContext() +const table: VueTable = useTableContext() const columnFilters = computed( () => table.atoms.columnFilters.get() as Array, ) diff --git a/examples/vue/kitchen-sink-shadcn/src/components/data-table/DataTablePagination.vue b/examples/vue/kitchen-sink-shadcn/src/components/data-table/DataTablePagination.vue index a842572c9d..e8f14d78e7 100644 --- a/examples/vue/kitchen-sink-shadcn/src/components/data-table/DataTablePagination.vue +++ b/examples/vue/kitchen-sink-shadcn/src/components/data-table/DataTablePagination.vue @@ -6,6 +6,8 @@ import { ChevronsRight, } from '@lucide/vue' import { useTableContext } from '@/hooks/table' +import type { RowData, VueTable } from '@tanstack/vue-table' +import type { features } from '@/hooks/features' import { Button } from '@/components/ui/button' import { @@ -20,7 +22,7 @@ const props = withDefaults(defineProps<{ pageSizeOptions?: Array }>(), { pageSizeOptions: () => [10, 20, 30, 40, 50, Infinity], }) -const table = useTableContext() +const table: VueTable = useTableContext()