Compare commits

...

6 Commits

Author SHA1 Message Date
64e7061084 ts_core: lockfile records the pnpm 12.4.2 pin
Some checks failed
dependency freshness / dependencies on newest stable (push) Waiting to run
file length / file-length (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
ts_config tests / test (push) Waiting to run
ts_core tests / test (push) Waiting to run
web_ui tests / test (push) Waiting to run
crdt_sync_flutter tests / test (push) Has been cancelled
crdt-sync pre-commit / pre-commit (push) Has been cancelled
crdt-sync tests / test (push) Has been cancelled
freedays pre-commit / pre-commit (push) Has been cancelled
freedays tests / test (push) Has been cancelled
gatelock pre-commit / pre-commit (push) Has been cancelled
gatelock tests / test (push) Has been cancelled
music_theory tests / test (push) Has been cancelled
The packageManager field was bumped after the last install, so CI's
--frozen-lockfile refused it (ERR_PNPM_FROZEN_LOCKFILE_WITH_OUTDATED_LOCKFILE).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnAYyNH1Sm4iJNidfYbrZJ
2026-09-16 21:59:01 +02:00
b28dfdeb60 gatelock: annotate a fixture param ruff 0.16.8 now flags; TS workflows dispatchable
The ruff bump surfaced one ANN001 in test_window.py. ts-core / web-ui /
ts-config workflows gain workflow_dispatch so a workflow-only change (like the
last commit, which touched no ts_core/** path and therefore never ran) can be
re-verified on demand.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnAYyNH1Sm4iJNidfYbrZJ
2026-09-16 21:53:47 +02:00
cb64e93b97 ci: install the linked preset's deps before linting ts_core/web_ui; deps green
ts_core and web_ui depend on `link:../ts_config`. pnpm links the directory
and installs nothing inside it, and a flat config imports its plugins from
the preset's own node_modules, so CI died on "Cannot find package
'@eslint/js'" while the local tree (where ts_config had been installed by
hand) passed. Both workflows now `pnpm install` in ts_config first, and
trigger on ts_config/** too so a preset change re-verifies its consumers.

The same push turned the dependency-freshness job red on five pins that had
aged underneath it (ruff 0.16.8 in four requirements.txt,
flutter_secure_storage 11.2.0 in crdt_sync_flutter); bumped, pubspec.lock is
ignored in that package so nothing else moves.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnAYyNH1Sm4iJNidfYbrZJ
2026-09-16 21:50:13 +02:00
c5b3fceeae ts_core 0.1.1, web_ui 0.4.0: consume @kuhyx/ts-config
The two shared packages are the first repos on the preset (link:../ts_config
inside the monorepo; consumers outside use the git tag). Each eslint.config.js
is now the defineConfig() call plus one override with its reason: a public
API name (`nextChance`, `fuzzyMatch`) the boolean-prefix rule would rename,
which is a breaking change for the three repos importing it.

Everything else the preset flagged is fixed in code, not disabled:
key order (perfectionist), hex casing, sort compare functions in tests,
Iterator#map().toArray(), explicit returns on multiline arrows.

web_ui: react-refresh/only-export-components was a real finding --
range-slider.tsx exported `steppedValue` next to the component, which breaks
Vite HMR for the module. The keyboard contract moves to stepped-value.ts as
`steppedValue` + a new pure `keyTarget(key, values, current)`, which also
resolves unicorn/no-late-event-control: the handler now decides the target
first and calls preventDefault() only when it owns the key. Its tests move
with it (the 250-line gate caught the combined file). Minor bump for the new
export. dist/ rebuilt in both packages.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnAYyNH1Sm4iJNidfYbrZJ
2026-09-16 21:46:41 +02:00
0f9699d4f3 ts_config: project option, entry-point barrel and className carve-outs
Surfaced by making ts_core and web_ui the first consumers:

- base({ project }) uses an explicit tsconfig list instead of the project
  service. Both packages exclude tests from tsconfig.json so they never land
  in dist/, and widen the include in tsconfig.lint.json for lint only; the
  project service would have reported every test file as "not found".
- unicorn/no-barrel-files is off for src/index.ts: a package entry point IS
  a barrel, that is its job. Stays on everywhere else.
- unicorn/no-keyword-prefix is off in the React layer: `className` is
  React's prop name and fires on every styled element.
- pnpm-workspace.yaml: allowBuilds for unrs-resolver set to false explicitly
  (pnpm 12 had written a placeholder); the resolver's prebuilt binding is
  used, no install script runs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnAYyNH1Sm4iJNidfYbrZJ
2026-09-16 21:45:59 +02:00
128ede438e ts_config: @kuhyx/ts-config, the one lint/TS bar every TypeScript repo extends
Evil Martians' "ten anti-AI-slop moves" as a package: strict tsconfig base
(noUncheckedIndexedAccess, exactOptionalPropertyTypes), type-checked
typescript-eslint strict+stylistic, unicorn/sonarjs/perfectionist, behaviour
rules for tests (expect-expect, no-focused-tests), React (hooks, @eslint-react,
jsx-a11y strict, you-might-not-need-an-effect), Playwright, and layer
boundaries via eslint-plugin-boundaries 7 with the article's default policies.
Knip / jscpd / Stryker bases; Stryker carries no break threshold on purpose.

Plugins are dependencies, not devDependencies: a flat config imports them from
this package's own node_modules, so a consumer installing from the git tag
gets them or the lint cannot run. No build step, so the tag needs no prepare.

test/fixture is a mini repo with one planted violation per rule family;
test/expected.js names the rule that must catch each, and the suite runs the
real CLI over it (in a child process -- v8 coverage merges natively-loaded
and transformed copies of the same module into "uncovered"). 35 tests, 100%
branch coverage on the factories.

eslint/fast.js is the type-free subset for a per-edit hook: 0.52 s cold on
one file, measured against 1.28 s for base() without types -- importing a
plugin is the cost, so it loads none, nor base.js which imports them.

Probed under ESLint 10: jsx-a11y 6.10.2 (peer says <=9) and boundaries 7.2.0
both run; the fixture pins that.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnAYyNH1Sm4iJNidfYbrZJ
2026-09-16 21:40:08 +02:00
96 changed files with 6464 additions and 563 deletions

37
.github/workflows/ts-config-tests.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: ts_config tests
on:
push:
branches: [main]
paths: ['ts_config/**']
pull_request:
branches: [main]
paths: ['ts_config/**']
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ts_config
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 12
- uses: actions/setup-node@v4
with:
node-version: "24.21.0"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint (the preset lints itself)
run: pnpm lint
- name: Fixture + factory tests with the 100% coverage gate
run: pnpm coverage

View File

@ -3,10 +3,11 @@ name: ts_core tests
on:
push:
branches: [main]
paths: ['ts_core/**']
paths: ['ts_core/**', 'ts_config/**']
pull_request:
branches: [main]
paths: ['ts_core/**']
paths: ['ts_core/**', 'ts_config/**']
workflow_dispatch:
jobs:
test:
@ -26,6 +27,14 @@ jobs:
with:
node-version: "24.21.0"
# The preset is a `link:../ts_config` dependency. pnpm links the
# directory but installs nothing inside it, and a flat config imports
# its plugins from the preset's own node_modules -- so without this
# step the lint dies on "Cannot find package '@eslint/js'".
- name: Install the shared lint preset's dependencies
run: pnpm install --frozen-lockfile
working-directory: ts_config
- name: Install dependencies
run: pnpm install --frozen-lockfile

View File

@ -3,10 +3,11 @@ name: web_ui tests
on:
push:
branches: [main]
paths: ['web_ui/**']
paths: ['web_ui/**', 'ts_config/**']
pull_request:
branches: [main]
paths: ['web_ui/**']
paths: ['web_ui/**', 'ts_config/**']
workflow_dispatch:
jobs:
test:
@ -26,6 +27,14 @@ jobs:
with:
node-version: "24.21.0"
# The preset is a `link:../ts_config` dependency. pnpm links the
# directory but installs nothing inside it, and a flat config imports
# its plugins from the preset's own node_modules -- so without this
# step the lint dies on "Cannot find package '@eslint/js'".
- name: Install the shared lint preset's dependencies
run: pnpm install --frozen-lockfile
working-directory: ts_config
- name: Install dependencies
run: pnpm install --frozen-lockfile

View File

@ -96,3 +96,20 @@ component references (`components.html`, `button.html`). Read
`DOCS-tokens.md` before touching any theme/CSS/style file in any repo. The
`unified-design-system` Claude Code skill is a thin pointer here, not a
duplicate.
## ts_config/
`@kuhyx/ts-config` — the one lint / TypeScript bar every kuhyx TypeScript
repo extends (pnpm only, like `ts_core` and `web_ui`). A strict
`tsconfig.base.json`, ESLint flat-config presets (`defineConfig()` stacking
base / react / vitest / playwright / layer `boundaries()`), a type-free
`eslint/fast` subset for editor hooks, and Knip / jscpd / Stryker bases.
Plain JS, no build step; the git tag is the release. Every plugin is a
`dependency` of the package so consumers list none. A fixture repo with one
planted violation per rule family proves each gate bites.
```jsonc
"devDependencies": {
"@kuhyx/ts-config": "github:kuhyx/utils#ts_config-v0.1.0&path:/ts_config"
}
```

View File

@ -8,5 +8,5 @@ pylint==4.0.8
pytest==9.1.1
pytest-cov==7.1.0
requests==2.34.2
ruff==0.16.7
ruff==0.16.8
types-requests==2.33.0.20260906

View File

@ -18,7 +18,7 @@ dependencies:
crypto: 3.0.7
flutter:
sdk: flutter
flutter_secure_storage: 11.1.1
flutter_secure_storage: 11.2.0
# A real dependency, not a dev one: lib/testing/ ships the keystore fake so
# consuming apps can test their own sync wiring without rebuilding it.
flutter_test:

View File

@ -7,4 +7,4 @@ pre-commit==4.6.2
pylint==4.0.8
pytest==9.1.1
pytest-cov==7.1.0
ruff==0.16.7
ruff==0.16.8

View File

@ -102,7 +102,9 @@ class TestSetup:
topmost_on = True
mock_root.attributes.assert_any_call("-topmost", topmost_on)
def test_suspend_handles_are_the_armed_collaborators(self, mock_root) -> None:
def test_suspend_handles_are_the_armed_collaborators(
self, mock_root: MagicMock
) -> None:
"""An app that suspends the lock stops the very loop and watcher it arms."""
window, _hooks = make_window(mock_root, config=LockConfig(mode="soft"))

View File

@ -7,4 +7,4 @@ pre-commit==4.6.2
pylint==4.0.8
pytest==9.1.1
pytest-cov==7.1.0
ruff==0.16.7
ruff==0.16.8

View File

@ -8,4 +8,4 @@ pre-commit==4.6.2
pylint==4.0.8
pytest==9.1.1
pytest-cov==7.1.0
ruff==0.16.7
ruff==0.16.8

2
ts_config/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules/
coverage/

View File

@ -0,0 +1,54 @@
# Pre-commit Configuration for ts_config
# Install: pre-commit install && pre-commit install --hook-type pre-push
# Run: pre-commit run --config ts_config/.pre-commit-config.yaml --all-files
# NOTE: this subproject lives inside the ~/src/utils monorepo, whose git root is
# one level up. pre-commit always runs hooks from the git root, so every path
# below is written relative to THAT, not to this directory, and the top-level
# `files` key keeps these hooks off the sibling subprojects. Mirrors
# web_ui/.pre-commit-config.yaml.
files: ^ts_config/
# The fixture exists to violate every rule; formatting hooks must not "fix" it.
exclude: ^ts_config/test/fixture/
default_stages: [pre-commit]
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: check-yaml
# pnpm 12 writes the lockfile as two YAML documents.
args: [--allow-multiple-documents]
- id: check-json
# tsconfig*.json are JSONC -- TypeScript allows comments.
exclude: ^ts_config/tsconfig.*\.json$
- id: check-merge-conflict
- id: mixed-line-ending
args: [--fix=lf]
- repo: local
hooks:
- id: file-length-cap
name: file length <= 250 lines
entry: bash scripts/check_file_length.sh
language: system
pass_filenames: true
- id: ts-config-lint
name: ts_config eslint (the preset lints itself)
entry: bash -c 'cd ts_config && pnpm lint'
language: system
pass_filenames: false
files: ^ts_config/.*\.(js|mjs|json)$
- id: ts-config-test
name: ts_config fixture + factory tests, 100% coverage
entry: bash -c 'cd ts_config && pnpm coverage'
language: system
pass_filenames: false
stages: [pre-push]

88
ts_config/README.md Normal file
View File

@ -0,0 +1,88 @@
# `@kuhyx/ts-config`
The one lint / TypeScript bar every kuhyx TypeScript repo extends. Plain JS
and JSON, no build step: a git tag is the release.
Born 2026-09-16 from Evil Martians' *Ten anti-AI-slop moves for frontend
projects*: every rule here is a deterministic gate that decides with an exit
code what a reviewer would otherwise have to notice in a model-written diff.
Before this package the ten repos carried hand-copied `eslint.config.js`
files in three different strictness tiers.
## Install
**pnpm only** (npm cannot install a subdirectory of a git repo).
```jsonc
// package.json
"devDependencies": {
"@kuhyx/ts-config": "github:kuhyx/utils#ts_config-v0.1.0&path:/ts_config",
"eslint": "10.10.0",
"typescript": "6.0.3",
"typescript-eslint": "8.70.0"
}
```
The three peers are the consumer's; every plugin is a `dependency` of this
package so a consumer never lists one. Bump every consumer to the same
`typescript-eslint` -- two copies in one resolution tree are two plugin
instances, and flat config rejects the second.
## Use
```jsonc
// tsconfig.json
{ "extends": "@kuhyx/ts-config/tsconfig", "compilerOptions": { "lib": ["ES2023", "DOM"], "jsx": "react-jsx", "paths": { "@/*": ["./src/*"] } } }
```
```js
// eslint.config.js
import { defineConfig, folderElements } from "@kuhyx/ts-config";
export default defineConfig({
tsconfigRootDir: import.meta.dirname,
react: true,
boundaries: { elements: folderElements(["components", "services", "utils", "types"]) },
// Repo-specific overrides go last and each carries the reason it exists.
overrides: [],
});
```
`knip.json`: `{ "extends": "@kuhyx/ts-config/knip" }`. `.jscpd.json`: copy
`jscpd.base.json` (jscpd has no extends). `stryker.config.mjs`:
`import { strykerBase } from "@kuhyx/ts-config/stryker"; export default { ...strykerBase };`
## What is in it
| Export | Content |
| --- | --- |
| `./tsconfig` | `strict`, `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes` and the rest of the strictness block. No output options. |
| `defineConfig()` | `base` + optional `react` / `vitest` (default on) / `playwright` / `boundaries` + `overrides`. |
| `base()` | typescript-eslint strict+stylistic *type-checked*, unicorn (all), sonarjs, perfectionist; `no-explicit-any`, `no-non-null-assertion`, `explicit-module-boundary-types`; kebab-case filenames; alias-only imports (`aliasOnly: false` to drop); the house "off" list, each with its reason (`overrides.js`). |
| `react` | react-hooks, @eslint-react (type-checked), react-refresh, jsx-a11y strict, react-you-might-not-need-an-effect. |
| `vitestConfig` | `expect-expect`, `no-focused-tests`, `no-disabled-tests`, `valid-expect` + the test-file relaxations. |
| `playwrightConfig` | conditionals in tests, missing `await`, `.only`. |
| `boundaries()` | eslint-plugin-boundaries with the article's default policies (components→services→utils; router→pages; design-system isolated; mocks test-only). `folderElements([...])` builds the element list for a `src/<layer>/` tree; `allow: { layer: [...] }` overrides one layer. |
| `./eslint/fast` | Type-free subset for the editor hook: 0.52 s cold on one file (base without types: 1.28 s). Report-only use. |
| `./knip`, `./jscpd`, `./stryker` | Dead code, duplicate code, mutation testing bases. Stryker has **no** `break` threshold on purpose: a detector, not a KPI. |
## What the tests prove
`test/fixture/` is a mini repo with one planted violation per rule family
(`any`, `!`, `.only`, a test with no assertion, a parent-relative import,
services→components, router→utils, design-system→services, a page importing
a mock, a derived-state effect, an `img` without `alt`, a conditional in an
e2e test, a `Wrong_Name.ts`). `test/expected.js` names the rule that must
catch each; the suite runs the real CLI over the fixture and fails if a plant
is missed or a clean file is flagged. `pnpm coverage` holds the factories at
100% branches.
## Known limits
- `eslint-plugin-jsx-a11y` 6.10.2 declares peer ESLint ≤ 9. It runs cleanly
under 10 (the fixture proves `alt-text` and `click-events-have-key-events`);
if a release starts crashing, the React layer is where it comes out.
- `eslint-plugin-react` is deliberately absent (calls `context.getFilename()`,
removed in ESLint 10). @eslint-react covers it.
- TypeScript stays on 6.0.x: typescript-eslint caps at `<6.1.0`. Allowlisted
in `../dependency-freshness.allowlist.yaml`.

View File

@ -0,0 +1,10 @@
// The preset lints itself. Everything here is plain JS, so the type-aware
// layer is off by construction; the fixture is excluded because its whole
// job is to violate.
import { defineConfig } from "./eslint/index.js";
export default defineConfig({
aliasOnly: false,
ignores: ["test/fixture"],
tsconfigRootDir: import.meta.dirname,
});

115
ts_config/eslint/base.js Normal file
View File

@ -0,0 +1,115 @@
// The type-aware baseline every kuhyx TypeScript repo lints against.
//
// typescript-eslint's *type-checked* strict + stylistic presets, so anything
// they flag is an error, not a warning. On top: unicorn (all), sonarjs
// (cognitive complexity / duplicate logic), perfectionist (sorting). Unused
// disable directives are themselves errors, so every `eslint-disable` in a
// consumer must be load-bearing.
//
// Split by concern so no file crosses the 250-line cap: this file wires the
// presets and the type-aware parser; overrides.js holds the house "off" list
// (each with its reason); naming.js and imports.js hold the rules the article
// calls "structural" -- filenames matching exports, imports only through
// aliases.
//
// Deliberately absent:
// - eslint-plugin-react: 7.37.x still calls context.getFilename(), removed
// in ESLint 10, so it crashes the run. @eslint-react covers the ground
// (see the React layer).
//
// TypeScript stays on 6.0.x, not 7.x: typescript-eslint requires
// "typescript >=4.8.4 <6.1.0", and losing every type-aware rule would be a far
// bigger regression than gaining the Go-native compiler. The pin is
// allowlisted in utils/dependency-freshness.allowlist.yaml.
import js from "@eslint/js";
import perfectionist from "eslint-plugin-perfectionist";
import sonarjs from "eslint-plugin-sonarjs";
import unicorn from "eslint-plugin-unicorn";
import globals from "globals";
import tseslint from "typescript-eslint";
import { DEFAULT_IGNORES } from "./ignores.js";
import { imports } from "./imports.js";
import { naming } from "./naming.js";
import { overrides } from "./overrides.js";
import { requireNonEmptyString } from "./require.js";
/** Globs the type-aware rules apply to. */
export const TS_FILES = ["**/*.{ts,tsx,mts,cts}"];
export { DEFAULT_IGNORES } from "./ignores.js";
/**
* The baseline config array.
*
* @param {object} options
* @param {string} options.tsconfigRootDir Consumer's repo root
* (`import.meta.dirname` in its eslint.config.js). Required, because
* pre-commit runs ESLint from the Git root while control-panel and
* dufs-cloud keep their web app one level down -- cwd is not the root.
* @param {string[]} [options.ignores] Extra ignore globs.
* @param {boolean} [options.aliasOnly] Ban `../` parent-relative imports so
* every cross-directory import goes through the repo's `@/` alias. Default
* true; a repo with no alias configured turns it off with a reason.
* @param {string[]} [options.project] tsconfig paths for the type-aware
* rules, relative to tsconfigRootDir. Default is the project service
* (nearest tsconfig.json per file). A package whose tsconfig.json excludes
* its tests so they never land in dist/ passes its lint tsconfig here.
*/
export function base({ aliasOnly = true, ignores = [], project, tsconfigRootDir }) {
requireNonEmptyString(tsconfigRootDir, "base() tsconfigRootDir");
const parserOptions = project
? { project, tsconfigRootDir }
: { projectService: true, tsconfigRootDir };
return tseslint.config(
{ ignores: [...DEFAULT_IGNORES, ...ignores] },
{ linterOptions: { reportUnusedDisableDirectives: "error" } },
js.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
unicorn.configs.all,
sonarjs.configs.recommended,
perfectionist.configs["recommended-natural"],
{
files: TS_FILES,
languageOptions: { parserOptions },
rules: {
// `type X = {}` and `interface X {}` are interchangeable for the
// shapes this codebase writes; picking one keeps diffs quiet.
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
// Every exported symbol is read by someone who did not write it, so
// an explicit boundary type is documentation, not ceremony.
"@typescript-eslint/explicit-module-boundary-types": "error",
// `any` and `!` are how a model hides a hole in its reasoning. Both
// are already errors in strictTypeChecked; restating them here makes
// the intent survive a preset upgrade that softens either.
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-non-null-assertion": "error",
// Numbers in template literals are unambiguous and pervasive
// (counts, totals, grades).
"@typescript-eslint/restrict-template-expressions": [
"error",
{ allowNumber: true },
],
},
},
...naming,
...(aliasOnly ? imports : []),
...overrides,
// Plain JS config files get no type-aware linting, and they run under
// Node (eslint.config.js, vitest.config.js, scripts) so its globals are
// known rather than each `process` being an undefined variable.
{
extends: [tseslint.configs.disableTypeChecked],
files: ["**/*.{js,mjs,cjs}"],
languageOptions: { globals: globals.node },
},
);
}

View File

@ -0,0 +1,111 @@
// Layer boundaries: the dependency direction is declared, and the linter
// enforces it.
//
// A model keeps no architectural context between sessions and drifts toward
// the "GitHub average" -- a service that imports a component because that was
// the shortest path. This is the fence. Elements are per repo (they name real
// directories); the default policy set is the article's:
//
// components -> services, utils, types, design-system
// services -> utils, types
// utils / types / config -> types only (no domain logic underneath)
// design-system -> design-system, types (isolated from state, API, domain)
// router -> pages only
// mocks -> importable from tests only
//
// Anything not listed is disallowed, so an element type with no policy can
// import nothing outside itself -- adding a type means writing its policy.
import boundariesPlugin from "eslint-plugin-boundaries";
import { requireNonEmptyArray, requireNonEmptyString } from "./require.js";
/** The article's default policies, keyed by element type. */
export const DEFAULT_ALLOW = {
components: ["services", "utils", "types", "design-system", "components"],
config: ["types"],
"design-system": ["design-system", "types"],
mocks: ["types", "mocks"],
pages: ["components", "services", "utils", "types", "design-system", "pages"],
router: ["pages"],
services: ["utils", "types", "services"],
types: ["types"],
utils: ["utils", "types"],
};
/**
* Element descriptors for a conventional `src/<type>/` layout.
*
* v7 elements are folders: the pattern names the directory itself and every
* file below it belongs to that element. (`src/<type>/*` would make each
* *sub*-folder its own element and leave the files directly inside unknown.)
*
* @param {string[]} types Directory names under `src/` that are layers.
* @param {string} [root] Path prefix the directories live under.
*/
export function folderElements(types, root = "src") {
return types.map((type) => ({ pattern: `${root}/${type}`, type }));
}
/**
* @param {object} options
* @param {string} options.tsconfigRootDir Consumer repo root, so the TS
* resolver finds the `@/` alias in the consumer's tsconfig.
* @param {Array<{type: string, pattern: string}>} options.elements
* The repo's layers; `folderElements([...])` builds the common case.
* @param {Record<string, string[]>} [options.allow] Per-type allow lists.
* Merged over DEFAULT_ALLOW, so a repo overrides one layer, not all.
* @param {string[]} [options.testFiles] Globs that may import mocks.
*/
export function boundaries({
allow = {},
elements,
testFiles = ["**/*.test.*", "**/*.spec.*", "**/test/**"],
tsconfigRootDir,
}) {
requireNonEmptyArray(elements, "boundaries() elements");
requireNonEmptyString(tsconfigRootDir, "boundaries() tsconfigRootDir");
const merged = { ...DEFAULT_ALLOW, ...allow };
const known = new Set(elements.map((element) => element.type));
const policies = Object.entries(merged)
.filter(([from]) => known.has(from))
.map(([from, to]) => {
const anyOf = to.filter((type) => known.has(type));
return { allow: { to: { element: { types: { anyOf } } } }, from: { element: { type: from } } };
});
return [
{
files: ["**/*.{ts,tsx,js,jsx,mts,cts}"],
plugins: { boundaries: boundariesPlugin },
rules: {
"boundaries/dependencies": [
"error",
{
default: "disallow",
policies: [
...policies,
// Tests may reach any layer, mocks included. Mocks appear in no
// production allow list, so a non-test module importing one is
// either dead code or a fixture leaking into the build.
{
allow: { to: { element: { types: { anyOf: [...known] } } } },
from: { file: { categories: "test" } },
},
],
},
],
},
settings: {
// Element patterns are matched relative to root-path, which defaults
// to process.cwd(). pre-commit runs from the Git root and the tests
// from the package dir, so the repo root is passed explicitly or the
// patterns match nothing and every file is "unknown".
"boundaries/elements": elements,
"boundaries/files": [{ category: "test", pattern: testFiles }],
"boundaries/root-path": tsconfigRootDir,
"import/resolver": {
typescript: { alwaysTryTypes: true, project: tsconfigRootDir },
},
},
},
];
}

33
ts_config/eslint/fast.js Normal file
View File

@ -0,0 +1,33 @@
// The editor-hook subset: the rules that catch the model's most common holes
// without type information and without loading the heavy plugins.
//
// Used by the Claude Code PostToolUse hook that reports (never fixes) lint
// findings on the file just edited, against a 1.0 s per-turn budget. The
// full type-aware bar stays in pre-commit; this is the same-session feedback
// the article calls "put the rules in front of the model".
//
// Measured cold on one fixture file (2026-09-16, this machine): bare
// typescript-eslint 0.50 s; +unicorn 0.87 s; +sonarjs 0.75 s; all of
// base() without types 1.28 s. Importing a plugin is the cost, not the
// number of its rules that run, so this file loads none of the three -- nor
// base.js, which imports them (that alone was +0.55 s).
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import { DEFAULT_IGNORES } from "./ignores.js";
import { imports } from "./imports.js";
export default tseslint.config(
{ ignores: DEFAULT_IGNORES },
js.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
{
rules: {
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-non-null-assertion": "error",
},
},
...imports,
);

View File

@ -0,0 +1,5 @@
// Kept in its own module so fast.js can import it without pulling in
// base.js, whose plugin imports are what make a cold lint slow.
/** Directories no consumer wants linted; a consumer adds its own on top. */
export const DEFAULT_IGNORES = ["dist", "coverage", "node_modules", "build"];

View File

@ -0,0 +1,27 @@
// Structural rules: imports only through aliases.
//
// `../../services/api` encodes the importing file's depth in every consumer;
// move the file and every one of them breaks, and a model that guesses the
// depth wrong produces an import that resolves to the wrong module or to
// nothing. `@/services/api` is location-independent. Same-directory `./x`
// stays allowed: that is a sibling, not a traversal.
/** @type {import("eslint").Linter.Config[]} */
export const imports = [
{
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["../*"],
message:
"Import through the repo alias (`@/…`) instead of a parent-relative path.",
},
],
},
],
},
},
];

55
ts_config/eslint/index.js Normal file
View File

@ -0,0 +1,55 @@
// One call for the common case, the pieces for everything else.
//
// import { defineConfig } from "@kuhyx/ts-config";
// export default defineConfig({
// tsconfigRootDir: import.meta.dirname,
// react: true,
// boundaries: { elements: folderElements(["components", "services"]) },
// });
import { base } from "./base.js";
import { boundaries } from "./boundaries.js";
import { playwrightConfig } from "./playwright.js";
import { react } from "./react.js";
import { vitestConfig } from "./vitest.js";
export { base } from "./base.js";
export { boundaries, DEFAULT_ALLOW, folderElements } from "./boundaries.js";
export { playwrightConfig } from "./playwright.js";
export { react } from "./react.js";
export { vitestConfig } from "./vitest.js";
/**
* @param {object} options
* @param {string} options.tsconfigRootDir `import.meta.dirname` of the
* consumer's eslint.config.js.
* @param {string[]} [options.ignores]
* @param {boolean} [options.aliasOnly]
* @param {string[]} [options.project] See base().
* @param {boolean} [options.react] Stack the React layer.
* @param {boolean} [options.vitest] Stack the vitest rules (default true).
* @param {boolean} [options.playwright] Stack the Playwright rules.
* @param {object} [options.boundaries] Options for boundaries(); omitted
* means no layer enforcement (a repo that has not declared its layers).
* @param {import("eslint").Linter.Config[]} [options.overrides] Repo-specific
* config objects appended last, so they win. Each needs a reason comment.
*/
export function defineConfig({
aliasOnly,
boundaries: boundariesOptions,
ignores,
overrides = [],
playwright = false,
project,
react: withReact = false,
tsconfigRootDir,
vitest = true,
}) {
return [
...base({ aliasOnly, ignores, project, tsconfigRootDir }),
...(withReact ? react : []),
...(vitest ? vitestConfig : []),
...(playwright ? playwrightConfig : []),
...(boundariesOptions ? boundaries({ tsconfigRootDir, ...boundariesOptions }) : []),
...overrides,
];
}

View File

@ -0,0 +1,31 @@
// Structural rules: a file's name tells you what it exports.
//
// The article's "filenames matching exports" move. Kebab-case files exporting
// PascalCase components is the house convention across every kuhyx web repo;
// a model that invents `UserCard.tsx` next to `user-list.tsx` has not read the
// tree, and the rule says so before review has to.
/** @type {import("eslint").Linter.Config[]} */
export const naming = [
{
rules: {
// Keep the rule, widen its vocabulary. `passesFilters(server, filter)`
// and `matchesQuery(...)` are predicates that read as English; forcing
// them to `isPassingFilters` would be worse prose in service of a prefix
// list. `passes`/`matches` are added, nothing is removed.
"unicorn/consistent-boolean-name": [
"error",
{ prefixes: { matches: true, passes: true } },
],
// Kebab-case files exporting PascalCase components: house convention.
"unicorn/filename-case": ["error", { case: "kebabCase" }],
// Keep the rule, drop one replacement: `props` is React's own word.
// `interface FilterBarProps` is the convention every React codebase and
// every reader expects; `FilterBarProperties` would be unidiomatic in
// service of a generic dictionary. Every other replacement stays on.
"unicorn/name-replacements": ["error", { replacements: { props: false } }],
},
},
];

View File

@ -0,0 +1,76 @@
// House overrides, applied to every file including the consumer's own config.
//
// Each rule below is switched off deliberately: these are the cases where
// "more aggressive" makes the code worse rather than safer. A rule you must
// disable at every use site is worse than no rule at all, because
// reportUnusedDisableDirectives then turns the disables into their own debt.
//
// Anything a single repo needs beyond this list stays in THAT repo's
// eslint.config.js with its own reason comment; it moves here only once three
// repos carry the same override.
/** @type {import("eslint").Linter.Config[]} */
export const overrides = [
{
// A package's entry point IS a barrel: its whole job is to name the
// public API. The rule stays on everywhere else, where a barrel is how
// `import { x } from "@/utils"` ends up pulling in forty modules.
files: ["src/index.{ts,tsx}", "index.{ts,tsx}"],
rules: { "unicorn/no-barrel-files": "off" },
},
{
rules: {
// Directly contradicts unicorn/consistent-class-member-order: one wants
// a private field before the getter that reads it, the other wants the
// getter first, and satisfying either re-triggers the other. unicorn's
// wins because "declare the field before the code that uses it" is a
// reason, whereas alphabetical order within a class is not.
"perfectionist/sort-classes": "off",
// Alphabetises declarations within a file, which actively fights reading
// order: it would scatter `GRADES -> gradeRank -> isTripleA` into
// `compositeRank -> GRADES -> gradeCoverage`. Alphabetical order is not
// narrative order. Every *other* perfectionist rule stays on -- sorting
// imports, union members and object keys destroys no narrative.
"perfectionist/sort-modules": "off",
// Wants JSDoc blocks written without leading `*`, which is neither the
// TypeScript convention nor what editors/typedoc render.
"unicorn/no-asterisk-prefix-in-documentation-comments": "off",
// Flags hand-wrapped comment prose. Comments are wrapped to 80 columns
// on purpose; the rule would force one long line per paragraph.
"unicorn/no-manually-wrapped-comments": "off",
// `null` is load-bearing wherever JSON crosses a boundary: JSON has no
// `undefined`, and "the API sent null" and "the field was absent" are
// different facts that UIs render differently. Collapsing them loses
// information.
"unicorn/no-null": "off",
// `Temporal` does not exist in the runtimes these repos target (Node 26
// reports `typeof Temporal === "undefined"`); the rule is unfollowable
// until it ships. Inputs are ISO-8601 strings, which Date.parse handles
// identically across engines -- the cross-engine inconsistency the rule
// warns about is for non-ISO strings.
"unicorn/prefer-temporal": "off",
// The domain vocabulary is abbreviated on purpose: `os`, `spdx`, `repo`,
// `env`, `rng` are the names the source data and the maths use, and
// expanding them would obscure the mapping.
"unicorn/prevent-abbreviations": "off",
// Rewrites `/** @type {X} */` into a `//` comment, which strips the type
// annotation TypeScript reads from JSDoc in plain-JS files. This package
// and every consumer's config file are plain JS.
"unicorn/single-line-block-comment-style": "off",
// Caps a try block at ONE statement. Unfollowable where the whole point
// is that several steps can throw: getItem (throws in private
// browsing), JSON.parse (throws on junk) and a shape check belong in one
// try because any of them failing means the same thing. The rule has no
// maximum option, so it is all or nothing.
"unicorn/try-complexity": "off",
},
},
];

View File

@ -0,0 +1,22 @@
// End-to-end specs. No kuhyx repo had Playwright on 2026-09-16; the preset
// ships so the first one that does gets the same bar without inventing it.
//
// The rules that matter most for model-written e2e: a conditional inside a
// test (the test passes whichever branch runs), a forgotten `await` on an
// async matcher (the assertion never fires), and `.only`.
import playwright from "eslint-plugin-playwright";
/** @type {import("eslint").Linter.Config[]} */
export const playwrightConfig = [
{
...playwright.configs["flat/recommended"],
files: ["**/e2e/**", "**/*.e2e.{ts,js}", "**/*.pw.{ts,js}"],
rules: {
...playwright.configs["flat/recommended"].rules,
"playwright/missing-playwright-await": "error",
"playwright/no-conditional-in-test": "error",
"playwright/no-focused-test": "error",
"playwright/no-skipped-test": "error",
},
},
];

56
ts_config/eslint/react.js vendored Normal file
View File

@ -0,0 +1,56 @@
// React layer, stacked on base().
//
// Four plugins, each covering ground the others do not:
// - react-hooks: the rules of hooks + exhaustive deps, plus React 19's
// compiler-derived checks (`recommended` in 7.x).
// - @eslint-react: component/JSX correctness, type-checked variant, and the
// replacement for eslint-plugin-react (which crashes under ESLint 10).
// - react-refresh: a file that mixes a component with a non-component
// export silently breaks Vite HMR for the whole module.
// - react-you-might-not-need-an-effect: the article names "an effect that
// derives state from props" as the single most frequent AI edit. The
// fixture's Button does exactly that, and this is the rule that sees it.
// - jsx-a11y: accessibility is "the first thing to go" when a model
// optimises for how the screen looks. Its 6.10.2 peer range stops at
// ESLint ^9, but under 10 it runs cleanly (verified by the fixture test),
// so the `strict` preset is on.
import eslintReact from "@eslint-react/eslint-plugin";
import jsxA11y from "eslint-plugin-jsx-a11y";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import youMightNotNeedAnEffect from "eslint-plugin-react-you-might-not-need-an-effect";
import { TS_FILES } from "./base.js";
/** @type {import("eslint").Linter.Config[]} */
export const react = [
{
...eslintReact.configs["recommended-type-checked"],
files: TS_FILES,
},
{
files: TS_FILES,
plugins: { "react-hooks": reactHooks },
rules: reactHooks.configs.recommended.rules,
},
{
files: ["**/*.tsx", "**/*.jsx"],
...jsxA11y.flatConfigs.strict,
},
{
files: TS_FILES,
...youMightNotNeedAnEffect.configs.recommended,
},
{
files: ["**/*.tsx", "**/*.jsx"],
...reactRefresh.configs.vite,
},
{
files: TS_FILES,
rules: {
// `className` is React's own prop name; in a React codebase the rule
// fires on every styled element and cannot be satisfied.
"unicorn/no-keyword-prefix": "off",
},
},
];

View File

@ -0,0 +1,30 @@
// Argument guards for the factories. A preset that silently accepts a missing
// repo root lints with the wrong project and reports nothing -- the worst
// failure mode for a gate -- so the factories refuse loudly instead.
/**
* @param {unknown} value
* @param {string} what Name used in the error message.
* @returns {string}
*/
export function requireNonEmptyString(value, what) {
const isPresent = typeof value === "string" && value !== "";
if (!isPresent) {
throw new TypeError(`@kuhyx/ts-config: ${what} is required (pass import.meta.dirname)`);
}
return value;
}
/**
* @template T
* @param {unknown} value
* @param {string} what
* @returns {T[]}
*/
export function requireNonEmptyArray(value, what) {
const isPresent = Array.isArray(value) && value.length > 0;
if (!isPresent) {
throw new TypeError(`@kuhyx/ts-config: ${what} needs a non-empty list`);
}
return value;
}

View File

@ -0,0 +1,59 @@
// Test files: the rules that catch a test which cannot fail, plus the
// relaxations that stop the strict presets fighting mocks and fixtures.
//
// `expect-expect` is the article's "tests with no assertions" -- a model
// writes `it("works", () => { render(<X/>) })` and it passes forever.
// `no-focused-tests` is the forgotten `.only` that silently skips the suite.
import vitest from "@vitest/eslint-plugin";
/** Globs vitest rules apply to. */
export const TEST_FILES = [
"**/*.test.{ts,tsx,js,jsx}",
"**/*.spec.{ts,tsx,js,jsx}",
"**/test/**",
"**/__tests__/**",
"**/__fixtures__/**",
];
const RULES = {
...vitest.configs.recommended.rules,
"vitest/expect-expect": "error",
"vitest/no-disabled-tests": "error",
"vitest/no-focused-tests": "error",
// vitest's `expect(value, message)` is how a loop of assertions names the
// case that failed; the rule's default of one argument would ban it.
"vitest/valid-expect": ["error", { maxArgs: 2 }],
};
/** @type {import("eslint").Linter.Config[]} */
export const vitestConfig = [
{
files: TEST_FILES,
plugins: { vitest },
rules: RULES,
},
// `typecheck` makes valid-title & co. read the TS type of a test's
// arguments; it needs parser services, which only the TS files have.
{
files: ["**/*.{ts,tsx,mts,cts}"],
settings: { vitest: { typecheck: true } },
},
{
files: TEST_FILES,
rules: {
"@typescript-eslint/no-empty-function": "off",
// Tests reach for `!` on queries that cannot return null in a passing
// test; asserting them again would only add noise.
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/unbound-method": "off",
"sonarjs/no-duplicate-string": "off",
// Test helpers live beside the tests that use them; hoisting every
// fixture factory to module scope to satisfy a scoping rule would
// scatter each test's setup away from the test.
"unicorn/consistent-function-scoping": "off",
// A no-op stub is the point of a stub.
"unicorn/no-empty-file": "off",
},
},
];

18
ts_config/jscpd.base.json Normal file
View File

@ -0,0 +1,18 @@
{
"absolute": true,
"exitCode": 1,
"format": ["typescript", "tsx", "javascript"],
"gitignore": true,
"ignore": [
"**/node_modules/**",
"**/dist/**",
"**/coverage/**",
"**/*.test.*",
"**/*.spec.*",
"**/__fixtures__/**"
],
"minLines": 10,
"minTokens": 70,
"reporters": ["consoleFull"],
"threshold": 0
}

18
ts_config/knip.base.json Normal file
View File

@ -0,0 +1,18 @@
{
"$schema": "https://unpkg.com/knip@6/schema.json",
"ignore": ["**/dist/**", "**/coverage/**", "**/*.d.ts"],
"ignoreDependencies": ["@kuhyx/ts-config"],
"ignoreExportsUsedInFile": true,
"rules": {
"binaries": "error",
"dependencies": "error",
"devDependencies": "error",
"duplicates": "error",
"enumMembers": "error",
"exports": "error",
"files": "error",
"types": "error",
"unlisted": "error",
"unresolved": "error"
}
}

71
ts_config/package.json Normal file
View File

@ -0,0 +1,71 @@
{
"name": "@kuhyx/ts-config",
"version": "0.1.0",
"private": false,
"type": "module",
"description": "The one lint/TypeScript bar every kuhyx TypeScript repo extends: a strict tsconfig base, ESLint flat-config presets (base, react, vitest, playwright, layer boundaries, a fast editor subset), and Knip / jscpd / Stryker bases. Plain JS, no build step -- consumable straight from a git tag.",
"license": "MIT",
"engines": {
"node": ">=24",
"pnpm": ">=10"
},
"packageManager": "pnpm@12.4.2",
"files": [
"eslint",
"tsconfig.base.json",
"knip.base.json",
"jscpd.base.json",
"stryker.base.mjs",
"README.md"
],
"exports": {
".": "./eslint/index.js",
"./eslint": "./eslint/index.js",
"./eslint/base": "./eslint/base.js",
"./eslint/react": "./eslint/react.js",
"./eslint/vitest": "./eslint/vitest.js",
"./eslint/playwright": "./eslint/playwright.js",
"./eslint/boundaries": "./eslint/boundaries.js",
"./eslint/fast": "./eslint/fast.js",
"./tsconfig": "./tsconfig.base.json",
"./knip": "./knip.base.json",
"./jscpd": "./jscpd.base.json",
"./stryker": "./stryker.base.mjs"
},
"scripts": {
"lint": "eslint .",
"test": "vitest run",
"coverage": "vitest run --coverage"
},
"dependencies": {
"@eslint-react/eslint-plugin": "5.19.1",
"@eslint/js": "10.0.1",
"@vitest/eslint-plugin": "1.6.27",
"eslint-import-resolver-typescript": "4.4.5",
"eslint-plugin-boundaries": "7.2.0",
"eslint-plugin-jsx-a11y": "6.10.2",
"eslint-plugin-perfectionist": "5.11.1",
"eslint-plugin-playwright": "2.12.0",
"eslint-plugin-react-hooks": "7.1.1",
"eslint-plugin-react-refresh": "0.5.7",
"eslint-plugin-react-you-might-not-need-an-effect": "1.0.2",
"eslint-plugin-sonarjs": "4.2.1",
"eslint-plugin-unicorn": "75.0.0",
"globals": "17.12.0"
},
"peerDependencies": {
"eslint": ">=10",
"typescript": ">=6",
"typescript-eslint": ">=8.70.0"
},
"devDependencies": {
"@playwright/test": "1.63.0",
"@types/react": "19.3.0",
"@vitest/coverage-v8": "5.0.1",
"eslint": "10.10.0",
"react": "19.3.0",
"typescript": "6.0.3",
"typescript-eslint": "8.70.0",
"vitest": "5.0.1"
}
}

4458
ts_config/pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
allowBuilds:
unrs-resolver: false
minimumReleaseAgeExclude:
- eslint-plugin-unicorn@75.0.0

View File

@ -0,0 +1,18 @@
// Mutation testing base. Stryker flips `<` to `<=`, empties arrays, inverts
// conditions and swaps return values; a test that still passes was not
// testing behaviour.
//
// No `break` threshold on purpose -- the article's one hard rule: treat the
// score as a detector, never as a KPI. The weekly workflow reports it; nothing
// fails on it.
/** @type {import("@stryker-mutator/api/core").PartialStrykerOptions} */
export const strykerBase = {
coverageAnalysis: "perTest",
ignoreStatic: true,
incremental: true,
mutate: ["src/**/*.ts", "src/**/*.tsx", "!src/**/*.test.*", "!src/**/*.spec.*", "!src/**/*.d.ts"],
reporters: ["clear-text", "progress", "json", "html"],
testRunner: "vitest",
thresholds: { break: null, high: 80, low: 60 },
timeoutMS: 60_000,
};

View File

@ -0,0 +1,44 @@
// The JSON/MJS bases are data, but data a consumer's tool parses: a typo in
// one is a broken lint/knip/jscpd run in every repo at once.
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { strykerBase } from "../stryker.base.mjs";
const ROOT = path.join(import.meta.dirname, "..");
describe("bases", () => {
it("stryker never breaks the build on score", () => {
expect(strykerBase.thresholds.break).toBeNull();
expect(strykerBase.testRunner).toBe("vitest");
expect(strykerBase.mutate).toContain("!src/**/*.test.*");
});
it("tsconfig base carries the two flags the article names", () => {
const raw = fs.readFileSync(path.join(ROOT, "tsconfig.base.json"), "utf8");
// JSONC: strip the comment lines before parsing.
const json = JSON.parse(raw.split("\n").filter((line) => !line.trimStart().startsWith("//")).join("\n"));
expect(json.compilerOptions.strict).toBe(true);
expect(json.compilerOptions.noUncheckedIndexedAccess).toBe(true);
expect(json.compilerOptions.exactOptionalPropertyTypes).toBe(true);
expect(json.compilerOptions.outDir).toBeUndefined();
});
it("knip and jscpd bases are valid JSON with exit-1 semantics", () => {
const knip = JSON.parse(fs.readFileSync(path.join(ROOT, "knip.base.json"), "utf8"));
expect(Object.values(knip.rules).every((level) => level === "error")).toBe(true);
const jscpd = JSON.parse(fs.readFileSync(path.join(ROOT, "jscpd.base.json"), "utf8"));
expect(jscpd.exitCode).toBe(1);
expect(jscpd.threshold).toBe(0);
});
it("every export in package.json points at a shipped file", () => {
const manifest = JSON.parse(fs.readFileSync(path.join(ROOT, "package.json"), "utf8"));
for (const target of Object.values(manifest.exports)) {
expect(fs.existsSync(path.join(ROOT, target)), target).toBe(true);
const [, top] = target.split("/", 2);
expect(manifest.files, `${top} missing from "files"`).toContain(top);
}
});
});

View File

@ -0,0 +1,141 @@
// The factories: what each option adds, and what a bad call refuses.
import { describe, expect, it } from "vitest";
import { base, DEFAULT_IGNORES } from "../eslint/base.js";
import { boundaries, DEFAULT_ALLOW, folderElements } from "../eslint/boundaries.js";
import fast from "../eslint/fast.js";
import { defineConfig } from "../eslint/index.js";
const ROOT = import.meta.dirname;
/** Rule ids that appear anywhere in a flat config array. */
function ruleIds(config) {
return new Set(config.flatMap((entry) => Object.keys(entry.rules ?? {})));
}
/** Plugin names registered anywhere in a flat config array. */
function pluginNames(config) {
return new Set(config.flatMap((entry) => Object.keys(entry.plugins ?? {})));
}
describe("base()", () => {
it("refuses to run without a tsconfigRootDir", () => {
expect(() => base({})).toThrow(/tsconfigRootDir/);
expect(() => base({ tsconfigRootDir: "" })).toThrow(/tsconfigRootDir/);
});
it("prepends the default ignores and keeps the caller's", () => {
const [ignores] = base({ ignores: ["public"], tsconfigRootDir: ROOT });
expect(ignores.ignores).toEqual([...DEFAULT_IGNORES, "public"]);
});
it("wires the type-aware parser at the given root", () => {
const entry = base({ tsconfigRootDir: ROOT }).find(
(candidate) => candidate.languageOptions?.parserOptions?.projectService === true,
);
expect(entry?.languageOptions.parserOptions.tsconfigRootDir).toBe(ROOT);
});
it("uses an explicit project list instead of the project service when given", () => {
const entry = base({ project: ["./tsconfig.lint.json"], tsconfigRootDir: ROOT }).find(
(candidate) => candidate.languageOptions?.parserOptions?.project,
);
expect(entry.languageOptions.parserOptions).toEqual({
project: ["./tsconfig.lint.json"],
tsconfigRootDir: ROOT,
});
expect(entry.languageOptions.parserOptions.projectService).toBeUndefined();
});
it("drops the alias-only import ban when asked", () => {
expect(ruleIds(base({ tsconfigRootDir: ROOT }))).toContain("no-restricted-imports");
expect(ruleIds(base({ aliasOnly: false, tsconfigRootDir: ROOT }))).not.toContain(
"no-restricted-imports",
);
});
});
describe("boundaries()", () => {
it("refuses an empty element list", () => {
expect(() => boundaries({ elements: [], tsconfigRootDir: ROOT })).toThrow(/elements/);
expect(() => boundaries({ tsconfigRootDir: ROOT })).toThrow(/elements/);
});
it("refuses to run without a tsconfigRootDir", () => {
expect(() => boundaries({ elements: folderElements(["utils"]) })).toThrow(/tsconfigRootDir/);
});
it("emits a policy only for element types the repo declared", () => {
const [entry] = boundaries({
elements: folderElements(["components", "services"]),
tsconfigRootDir: ROOT,
});
const { policies } = entry.rules["boundaries/dependencies"][1];
const froms = policies.filter((p) => p.from.element).map((p) => p.from.element.type);
expect(froms.toSorted((a, b) => a.localeCompare(b))).toEqual(["components", "services"]);
const components = policies.find((p) => p.from.element?.type === "components");
// utils/types are not declared here, so they are filtered out of the
// allow list rather than left dangling.
expect(components.allow.to.element.types.anyOf).toEqual(["services", "components"]);
});
it("merges a repo's allow override over one layer only", () => {
const [entry] = boundaries({
allow: { services: ["components"] },
elements: folderElements(["components", "services"]),
tsconfigRootDir: ROOT,
});
const { policies } = entry.rules["boundaries/dependencies"][1];
const services = policies.find((p) => p.from.element?.type === "services");
expect(services.allow.to.element.types.anyOf).toEqual(["components"]);
expect(DEFAULT_ALLOW.services).toEqual(["utils", "types", "services"]);
});
it("points the TS resolver at the repo root and marks tests", () => {
const [entry] = boundaries({
elements: folderElements(["utils"], "lib"),
testFiles: ["**/*.spec.ts"],
tsconfigRootDir: ROOT,
});
expect(entry.settings["boundaries/elements"]).toEqual([{ pattern: "lib/utils", type: "utils" }]);
expect(entry.settings["boundaries/files"]).toEqual([{ category: "test", pattern: ["**/*.spec.ts"] }]);
expect(entry.settings["import/resolver"].typescript.project).toBe(ROOT);
expect(entry.settings["boundaries/root-path"]).toBe(ROOT);
});
});
describe("defineConfig()", () => {
it("stacks nothing optional by default except vitest", () => {
const plugins = pluginNames(defineConfig({ tsconfigRootDir: ROOT }));
expect(plugins).toContain("vitest");
expect(plugins).not.toContain("boundaries");
expect(plugins).not.toContain("react-hooks");
expect(plugins).not.toContain("playwright");
});
it("stacks every layer when asked and appends overrides last", () => {
const override = { rules: { "unicorn/no-null": "error" } };
const config = defineConfig({
boundaries: { elements: folderElements(["components"]) },
overrides: [override],
playwright: true,
react: true,
tsconfigRootDir: ROOT,
vitest: false,
});
const plugins = pluginNames(config);
for (const name of ["boundaries", "react-hooks", "playwright", "jsx-a11y"]) {
expect(plugins).toContain(name);
}
expect(plugins).not.toContain("vitest");
expect(config.at(-1)).toBe(override);
});
});
describe("fast", () => {
it("is type-free: no projectService anywhere", () => {
const typeAware = fast.some((entry) => entry.languageOptions?.parserOptions?.projectService);
expect(typeAware).toBe(false);
expect(ruleIds(fast)).toContain("@typescript-eslint/no-explicit-any");
});
});

View File

@ -0,0 +1,29 @@
// One deliberate violation per rule family in test/fixture, and the rule id
// that must catch it. A rule missing from this table is a rule the preset
// does not prove; a fixture file missing from it is a plant nobody checks.
export const EXPECTED = {
"e2e/home.spec.ts": [
"playwright/missing-playwright-await",
"playwright/no-conditional-in-test",
],
"src/components/button.tsx": [
"jsx-a11y/alt-text",
"jsx-a11y/click-events-have-key-events",
"react-hooks/set-state-in-effect",
"react-you-might-not-need-an-effect/no-derived-state",
],
"src/design-system/theme.ts": ["boundaries/dependencies"],
"src/helper.test.ts": ["vitest/expect-expect", "vitest/no-focused-tests"],
"src/pages/home.tsx": ["boundaries/dependencies"],
"src/router/routes.ts": ["boundaries/dependencies"],
"src/services/api.ts": [
"@typescript-eslint/no-explicit-any",
"@typescript-eslint/no-non-null-assertion",
"boundaries/dependencies",
"no-restricted-imports",
],
"src/Wrong_Name.ts": ["unicorn/filename-case"],
};
/** Files that must lint clean: proves the presets do not fire on good code. */
export const CLEAN = ["src/mocks/user.ts", "src/utils/helper.ts"];

View File

@ -0,0 +1,64 @@
// Runs the real preset over the fixture mini-repo and checks that every
// planted violation is caught by the rule the table names, and that the
// clean files stay clean.
//
// The lint runs as the CLI in a child process, exactly as a consumer's
// pre-commit hook runs it. It also keeps the preset modules out of this
// process: v8 coverage merges the natively-loaded copies ESLint imports with
// the vitest-transformed ones the unit tests import, and the merge reports
// executed lines as uncovered.
import { execFileSync } from "node:child_process";
import path from "node:path";
import { beforeAll, describe, expect, it } from "vitest";
import { CLEAN, EXPECTED } from "./expected.js";
const FIXTURE = path.join(import.meta.dirname, "fixture");
const ESLINT_BIN = path.join(import.meta.dirname, "..", "node_modules", "eslint", "bin", "eslint.js");
/** @type {Map<string, Set<string>>} relative path -> rule ids reported */
const found = new Map();
beforeAll(() => {
let stdout;
try {
stdout = execFileSync(process.execPath, [ESLINT_BIN, ".", "--format", "json"], {
cwd: FIXTURE,
encoding: "utf8",
});
} catch (error) {
// Planted violations make ESLint exit 1; the JSON report is still on stdout.
stdout = error.stdout;
}
const results = JSON.parse(stdout.slice(stdout.indexOf("[")));
for (const result of results) {
const relative = path.relative(FIXTURE, result.filePath);
found.set(relative, new Set(result.messages.map((m) => m.ruleId)));
}
}, 120_000);
describe("planted violations", () => {
for (const [file, rules] of Object.entries(EXPECTED)) {
for (const rule of rules) {
it(`${file}: ${rule}`, () => {
expect([...(found.get(file) ?? [])]).toContain(rule);
});
}
}
});
describe("clean files", () => {
for (const file of CLEAN) {
it(`${file} reports nothing`, () => {
expect([...(found.get(file) ?? [])]).toEqual([]);
});
}
});
it("every fixture file is accounted for", () => {
const expectedFiles = new Set(Object.keys(EXPECTED));
const known = expectedFiles.union(new Set(CLEAN));
for (const file of found.keys()) {
expect(known.has(file), `unlisted fixture file: ${file}`).toBe(true);
}
});

View File

@ -0,0 +1,9 @@
import { expect, test } from "@playwright/test";
// Violations: playwright no-conditional-in-test, missing-playwright-await.
test("home", async ({ page }) => {
if (Math.random() > 0.5) {
await page.goto("/");
}
expect(page.locator("p")).toBeVisible();
});

View File

@ -0,0 +1,15 @@
import { defineConfig, folderElements } from "../../eslint/index.js";
export default defineConfig({
boundaries: {
elements: folderElements([
"components", "services", "utils", "pages", "router", "mocks", "design-system",
]),
},
// The fixture reaches its preset by relative path; a consumer imports the
// package name, so the alias-only rule never sees this line there.
ignores: ["eslint.config.js"],
playwright: true,
react: true,
tsconfigRootDir: import.meta.dirname,
});

View File

@ -0,0 +1,2 @@
// Violation: unicorn/filename-case (kebab-case expected).
export const wrongName = 1;

View File

@ -0,0 +1,16 @@
// Violations: you-might-not-need-an-effect (derived state via effect),
// jsx-a11y (img without alt, click on non-interactive div).
import { useEffect, useState } from "react";
export function Button({ label }: { label: string }): React.JSX.Element {
const [upper, setUpper] = useState("");
useEffect(() => {
setUpper(label.toUpperCase());
}, [label]);
return (
<div onClick={() => undefined}>
<img src="x.png" />
{upper}
</div>
);
}

View File

@ -0,0 +1,4 @@
// Violation: design-system must not import services.
import { fetchUser } from "@/services/api";
export const theme = { primary: String(fetchUser("x")) };

View File

@ -0,0 +1,14 @@
import { describe, expect, it } from "vitest";
import { helper } from "./utils/helper";
import { mockUser } from "./mocks/user";
describe("helper", () => {
// Violations: no-focused-tests, expect-expect.
it.only("trims", () => {
expect(helper(" a ")).toBe("a");
});
it("has no assertion", () => {
helper(mockUser.name);
});
});

View File

@ -0,0 +1 @@
export const mockUser = { id: "1", name: "Mock" };

View File

@ -0,0 +1,7 @@
// Violation: a production page importing a mock (boundaries).
import { mockUser } from "@/mocks/user";
import { fetchUser } from "@/services/api";
export function Home(): React.JSX.Element {
return <p>{String(fetchUser(mockUser.id))}</p>;
}

View File

@ -0,0 +1,4 @@
// Violation: router may only import pages.
import { helper } from "@/utils/helper";
export const routes = [helper("/")];

View File

@ -0,0 +1,10 @@
// Violations: no-explicit-any, no-non-null-assertion, parent-relative import,
// services importing from components (boundaries).
import { Button } from "../components/button";
import { helper } from "@/utils/helper";
export function fetchUser(id: string): any {
const cache: Record<string, string | undefined> = {};
const name = cache[id]!;
return { id, name, label: helper(name), button: Button };
}

View File

@ -0,0 +1,8 @@
export function helper(value: string): string {
return value.trim();
}
// Violation for Knip: never imported anywhere.
export function deadExport(): number {
return 1;
}

View File

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"lib": ["ES2023", "DOM"],
"jsx": "react-jsx",
"module": "ESNext",
"moduleResolution": "bundler",
"noEmit": true,
"types": [],
"paths": { "@/*": ["./src/*"] }
},
"include": ["src", "e2e"]
}

View File

@ -0,0 +1,26 @@
{
// The strictness every kuhyx TypeScript repo compiles under. Nothing here
// is about output: lib / jsx / module / outDir / paths stay in the repo's
// own tsconfig, which `extends` this one.
//
// The two flags the article singles out are the two that make a model
// state its assumptions: noUncheckedIndexedAccess turns `arr[0]` into
// "element or undefined", exactOptionalPropertyTypes stops `undefined`
// being smuggled into an optional property.
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"useUnknownInCatchVariables": true,
"verbatimModuleSyntax": true,
"isolatedModules": true,
"erasableSyntaxOnly": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}

View File

@ -0,0 +1,16 @@
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
coverage: {
include: ["eslint/**/*.js", "stryker.base.mjs"],
provider: "v8",
// The same bar as ts_core and web_ui: the package every repo's lint
// runs through does not get to be the least-tested code in the tree.
thresholds: { branches: 100, functions: 100, lines: 100, statements: 100 },
},
environment: "node",
include: ["test/**/*.test.js"],
testTimeout: 120_000,
},
});

View File

@ -1 +1 @@
{"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,KAAK;IACpB,4EAA4E;IAC5E,GAAG,EAAE,MAAM,MAAM,CAAA;CAClB;AAED,2EAA2E;AAC3E,eAAO,MAAM,eAAe,QAAO,KAEjC,CAAA;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,EAAE,KAAyB,CAAA;AAEjD,sEAAsE;AACtE,MAAM,WAAW,WAAY,SAAQ,KAAK;IACxC,mEAAmE;IACnE,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAElC,2DAA2D;IAC3D,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CAC9B;AAED,uEAAuE;AACvE,eAAO,MAAM,iBAAiB,GAAI,gBAAW,KAAG,WAW/C,CAAA"}
{"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,KAAK;IACpB,4EAA4E;IAC5E,GAAG,EAAE,MAAM,MAAM,CAAA;CAClB;AAED,2EAA2E;AAC3E,eAAO,MAAM,eAAe,QAAO,KAAmD,CAAA;AAEtF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,EAAE,KAAyB,CAAA;AAEjD,sEAAsE;AACtE,MAAM,WAAW,WAAY,SAAQ,KAAK;IACxC,mEAAmE;IACnE,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAElC,2DAA2D;IAC3D,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CAC9B;AAED,uEAAuE;AACvE,eAAO,MAAM,iBAAiB,GAAI,gBAAW,KAAG,WAW/C,CAAA"}

View File

@ -1,7 +1,5 @@
/** A {@link Clock} backed by the browser's monotonic performance timer. */
export const createRealClock = () => ({
now: () => performance.now(),
});
export const createRealClock = () => ({ now: () => performance.now() });
/**
* The one real clock instance UI code should pass around.
*
@ -15,10 +13,10 @@ export const realClock = createRealClock();
export const createManualClock = (startMs = 0) => {
let current = startMs;
return {
now: () => current,
advance: (deltaMs) => {
current += deltaMs;
},
now: () => current,
set: (timeMs) => {
current = timeMs;
},

View File

@ -1 +1 @@
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAaA,2EAA2E;AAC3E,MAAM,CAAC,MAAM,eAAe,GAAG,GAAU,EAAE,CAAC,CAAC;IAC3C,GAAG,EAAE,GAAW,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE;CACrC,CAAC,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAU,eAAe,EAAE,CAAA;AAWjD,uEAAuE;AACvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAO,GAAG,CAAC,EAAe,EAAE;IAC5D,IAAI,OAAO,GAAG,OAAO,CAAA;IACrB,OAAO;QACL,GAAG,EAAE,GAAW,EAAE,CAAC,OAAO;QAC1B,OAAO,EAAE,CAAC,OAAe,EAAQ,EAAE;YACjC,OAAO,IAAI,OAAO,CAAA;QACpB,CAAC;QACD,GAAG,EAAE,CAAC,MAAc,EAAQ,EAAE;YAC5B,OAAO,GAAG,MAAM,CAAA;QAClB,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAaA,2EAA2E;AAC3E,MAAM,CAAC,MAAM,eAAe,GAAG,GAAU,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAW,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AAEtF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAU,eAAe,EAAE,CAAA;AAWjD,uEAAuE;AACvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAO,GAAG,CAAC,EAAe,EAAE;IAC5D,IAAI,OAAO,GAAG,OAAO,CAAA;IACrB,OAAO;QACL,OAAO,EAAE,CAAC,OAAe,EAAQ,EAAE;YACjC,OAAO,IAAI,OAAO,CAAA;QACpB,CAAC;QACD,GAAG,EAAE,GAAW,EAAE,CAAC,OAAO;QAC1B,GAAG,EAAE,CAAC,MAAc,EAAQ,EAAE;YAC5B,OAAO,GAAG,MAAM,CAAA;QAClB,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}

View File

@ -6,6 +6,6 @@
* -- that is the coupling that makes people vendor their own copy instead,
* which is how these ended up duplicated four ways to begin with.
*/
export { createManualClock, createRealClock, realClock, type Clock, type ManualClock, } from './clock.ts';
export { type Clock, createManualClock, createRealClock, type ManualClock, realClock, } from './clock.ts';
export { createRng, createSeededRng, nextChance, nextFloat, nextInt, pick, type Rng, type SeededRng, } from './rng.ts';
//# sourceMappingURL=index.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,SAAS,EACT,KAAK,KAAK,EACV,KAAK,WAAW,GACjB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,SAAS,EACT,eAAe,EACf,UAAU,EACV,SAAS,EACT,OAAO,EACP,IAAI,EACJ,KAAK,GAAG,EACR,KAAK,SAAS,GACf,MAAM,UAAU,CAAA"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,KAAK,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,KAAK,WAAW,EAChB,SAAS,GACV,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,SAAS,EACT,eAAe,EACf,UAAU,EACV,SAAS,EACT,OAAO,EACP,IAAI,EACJ,KAAK,GAAG,EACR,KAAK,SAAS,GACf,MAAM,UAAU,CAAA"}

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,SAAS,GAGV,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,SAAS,EACT,eAAe,EACf,UAAU,EACV,SAAS,EACT,OAAO,EACP,IAAI,GAGL,MAAM,UAAU,CAAA"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAEL,iBAAiB,EACjB,eAAe,EAEf,SAAS,GACV,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,SAAS,EACT,eAAe,EACf,UAAU,EACV,SAAS,EACT,OAAO,EACP,IAAI,GAGL,MAAM,UAAU,CAAA"}

View File

@ -54,14 +54,14 @@ export declare const pick: <T>(rng: Rng, items: readonly [T, ...T[]]) => T;
* around rather than threading mutable state through free functions.
*/
export interface SeededRng {
/** True with the given probability in [0, 1]. */
chance: (probability: number) => boolean;
/** Uniform float in [0, 1). */
float: () => number;
/** Uniform integer in [minInclusive, maxInclusive]. */
int: (minInclusive: number, maxInclusive: number) => number;
/** Uniform element of a non-empty array. */
pick: <T>(items: readonly T[]) => T;
/** True with the given probability in [0, 1]. */
chance: (probability: number) => boolean;
}
/**
* Creates a {@link SeededRng} over the same mulberry32 core.

View File

@ -1 +1 @@
{"version":3,"file":"rng.d.ts","sourceRoot":"","sources":["../src/rng.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,gDAAgD;AAChD,MAAM,WAAW,GAAG;IAClB,qDAAqD;IACrD,CAAC,EAAE,MAAM,CAAA;CACV;AAED,mDAAmD;AACnD,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,GAA0B,CAAA;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,GAAG,KAAG,MAMpC,CAAA;AAED,uEAAuE;AACvE,eAAO,MAAM,OAAO,GAClB,KAAK,GAAG,EACR,cAAc,MAAM,EACpB,cAAc,MAAM,KACnB,MAC4E,CAAA;AAE/E,2DAA2D;AAC3D,eAAO,MAAM,UAAU,GAAI,KAAK,GAAG,EAAE,aAAa,MAAM,KAAG,OAC7B,CAAA;AAE9B;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,KAAG,CAW/D,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,MAAM,CAAA;IACnB,uDAAuD;IACvD,GAAG,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,MAAM,CAAA;IAC3D,4CAA4C;IAC5C,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,KAAK,CAAC,CAAA;IACnC,iDAAiD;IACjD,MAAM,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAA;CACzC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,SAgB9C,CAAA"}
{"version":3,"file":"rng.d.ts","sourceRoot":"","sources":["../src/rng.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,gDAAgD;AAChD,MAAM,WAAW,GAAG;IAClB,qDAAqD;IACrD,CAAC,EAAE,MAAM,CAAA;CACV;AAED,mDAAmD;AACnD,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,GAA0B,CAAA;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,GAAG,KAAG,MAMpC,CAAA;AAED,uEAAuE;AACvE,eAAO,MAAM,OAAO,GAClB,KAAK,GAAG,EACR,cAAc,MAAM,EACpB,cAAc,MAAM,KACnB,MAC4E,CAAA;AAE/E,2DAA2D;AAC3D,eAAO,MAAM,UAAU,GAAI,KAAK,GAAG,EAAE,aAAa,MAAM,KAAG,OAC7B,CAAA;AAE9B;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,KAAG,CAW/D,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,iDAAiD;IACjD,MAAM,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAA;IACxC,+BAA+B;IAC/B,KAAK,EAAE,MAAM,MAAM,CAAA;IACnB,uDAAuD;IACvD,GAAG,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,MAAM,CAAA;IAC3D,4CAA4C;IAC5C,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,KAAK,CAAC,CAAA;CACpC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,SAgB9C,CAAA"}

4
ts_core/dist/rng.js vendored
View File

@ -32,7 +32,7 @@ export const createRng = (seed) => ({ s: seed >>> 0 });
* of it, so they all consume exactly one step per call.
*/
export const nextFloat = (rng) => {
rng.s = (rng.s + 0x6d_2b_79_f5) >>> 0;
rng.s = (rng.s + 0x6D_2B_79_F5) >>> 0;
let t = rng.s;
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
@ -72,6 +72,7 @@ export const createSeededRng = (seed) => {
const state = createRng(seed);
const float = () => nextFloat(state);
return {
chance: (probability) => float() < probability,
float,
int: (minInclusive, maxInclusive) => nextInt(state, minInclusive, maxInclusive),
pick: (items) => {
@ -81,7 +82,6 @@ export const createSeededRng = (seed) => {
}
return chosen;
},
chance: (probability) => float() < probability,
};
};
//# sourceMappingURL=rng.js.map

View File

@ -1 +1 @@
{"version":3,"file":"rng.js","sourceRoot":"","sources":["../src/rng.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAQH,mDAAmD;AACnD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAY,EAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE,CAAC,CAAA;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAQ,EAAU,EAAE;IAC5C,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;IACrC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;IACb,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;IACpC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAA;IACzC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,aAAa,CAAA;AACjD,CAAC,CAAA;AAED,uEAAuE;AACvE,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,GAAQ,EACR,YAAoB,EACpB,YAAoB,EACZ,EAAE,CACV,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,GAAG,YAAY,GAAG,CAAC,CAAC,CAAC,CAAA;AAE/E,2DAA2D;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAE,WAAmB,EAAW,EAAE,CACnE,SAAS,CAAC,GAAG,CAAC,GAAG,WAAW,CAAA;AAE9B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAI,GAAQ,EAAE,KAA2B,EAAK,EAAE;IAClE,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAChD,IAAI,GAAG,GAAM,KAAK,CAAC,CAAC,CAAC,CAAA;IACrB,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,GAAG,GAAG,IAAI,CAAA;QACZ,CAAC;QACD,IAAI,IAAI,CAAC,CAAA;IACX,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAiBD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAa,EAAE;IACzD,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;IAC7B,MAAM,KAAK,GAAG,GAAW,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC5C,OAAO;QACL,KAAK;QACL,GAAG,EAAE,CAAC,YAAoB,EAAE,YAAoB,EAAU,EAAE,CAC1D,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC;QAC5C,IAAI,EAAE,CAAI,KAAmB,EAAK,EAAE;YAClC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;YACxD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;YAC7C,CAAC;YACD,OAAO,MAAM,CAAA;QACf,CAAC;QACD,MAAM,EAAE,CAAC,WAAmB,EAAW,EAAE,CAAC,KAAK,EAAE,GAAG,WAAW;KAChE,CAAA;AACH,CAAC,CAAA"}
{"version":3,"file":"rng.js","sourceRoot":"","sources":["../src/rng.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAQH,mDAAmD;AACnD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAY,EAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE,CAAC,CAAA;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAQ,EAAU,EAAE;IAC5C,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;IACrC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;IACb,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;IACpC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAA;IACzC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,aAAa,CAAA;AACjD,CAAC,CAAA;AAED,uEAAuE;AACvE,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,GAAQ,EACR,YAAoB,EACpB,YAAoB,EACZ,EAAE,CACV,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,GAAG,YAAY,GAAG,CAAC,CAAC,CAAC,CAAA;AAE/E,2DAA2D;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAE,WAAmB,EAAW,EAAE,CACnE,SAAS,CAAC,GAAG,CAAC,GAAG,WAAW,CAAA;AAE9B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAI,GAAQ,EAAE,KAA2B,EAAK,EAAE;IAClE,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAChD,IAAI,GAAG,GAAM,KAAK,CAAC,CAAC,CAAC,CAAA;IACrB,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,GAAG,GAAG,IAAI,CAAA;QACZ,CAAC;QACD,IAAI,IAAI,CAAC,CAAA;IACX,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAiBD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAa,EAAE;IACzD,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;IAC7B,MAAM,KAAK,GAAG,GAAW,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC5C,OAAO;QACL,MAAM,EAAE,CAAC,WAAmB,EAAW,EAAE,CAAC,KAAK,EAAE,GAAG,WAAW;QAC/D,KAAK;QACL,GAAG,EAAE,CAAC,YAAoB,EAAE,YAAoB,EAAU,EAAE,CAC1D,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC;QAC5C,IAAI,EAAE,CAAI,KAAmB,EAAK,EAAE;YAClC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;YACxD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;YAC7C,CAAC;YACD,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}

View File

@ -1,28 +1,24 @@
// Type-aware flat config, mirroring web_ui's so the two shared TS packages
// hold an identical bar.
import js from "@eslint/js";
import tseslint from "typescript-eslint";
// The shared preset, nothing else local except one frozen API name. This
// package is one of the repos the bar is defined for. Framework-free, so no
// React layer.
import { defineConfig } from "@kuhyx/ts-config";
export default tseslint.config(
{ ignores: ["dist", "coverage", "eslint.config.js"] },
{ linterOptions: { reportUnusedDisableDirectives: "error" } },
js.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
files: ["**/*.ts"],
languageOptions: {
parserOptions: {
project: ["./tsconfig.lint.json"],
tsconfigRootDir: import.meta.dirname,
export default defineConfig({
// Flat files under src/, no layers to fence and no alias configured.
aliasOnly: false,
overrides: [
{
files: ["src/rng.ts"],
rules: {
// `nextChance` is public API consumed by three repos; the preset's
// boolean-name prefixes would rename it to `isNextChance`, which is
// worse prose and a breaking change for no safety gain.
"unicorn/consistent-boolean-name": "off",
},
},
rules: {
// Every exported symbol crosses a package boundary, so an explicit
// return type is documentation, not ceremony.
"@typescript-eslint/explicit-function-return-type": "error",
},
},
);
],
// tsconfig.json excludes the tests so they never land in dist/; the lint
// project widens the include for type-aware rules (see tsconfig.lint.json).
project: ["./tsconfig.lint.json"],
tsconfigRootDir: import.meta.dirname,
});

View File

@ -1,6 +1,6 @@
{
"name": "@kuhyx/ts-core",
"version": "0.1.0",
"version": "0.1.1",
"private": false,
"type": "module",
"description": "Framework-free TypeScript utilities shared across kuhy's games and web apps: an injectable Clock and a seeded mulberry32 RNG. Deliberately no React and no CSS -- see @kuhyx/web-ui for the UI layer.",
@ -9,7 +9,7 @@
"node": ">=24",
"pnpm": ">=10"
},
"packageManager": "pnpm@12.4.1+sha512.2e81e399d73fe8390dab25e06aa788ab7a5908248d2f5a370f82b481147a6a7a367bf8048f9a6fdb6460f21a66f0542dedb8b94ca2c8723596741920b1656d4c",
"packageManager": "pnpm@12.4.2",
"files": [
"dist"
],
@ -29,11 +29,12 @@
},
"devDependencies": {
"@eslint/js": "10.0.1",
"@kuhyx/ts-config": "link:../ts_config",
"@types/node": "26.5.1",
"@vitest/coverage-v8": "5.0.0",
"@vitest/coverage-v8": "5.0.1",
"eslint": "10.10.0",
"typescript": "6.0.3",
"typescript-eslint": "8.70.0",
"vitest": "5.0.0"
"vitest": "5.0.1"
}
}

View File

@ -7,153 +7,153 @@ importers:
configDependencies: {}
packageManagerDependencies:
pnpm:
specifier: 12.4.1
version: 12.4.1
specifier: 12.4.2
version: 12.4.2
packages:
'@pnpm/exe.android-arm64@12.4.1':
resolution: {integrity: sha512-/HwsqXMSmlOfgtV9+O0ratzjV6Vd/8n1hh4rGHpCGmDURvt52MwZxdbhyxP4K03ZfvgSDvotFPr8O+RzE5Eu8A==}
'@pnpm/exe.android-arm64@12.4.2':
resolution: {integrity: sha512-E255MbcQ0V1577M2BV0ajWuP7KmTPYA0jqZnk3rK6Lq3kTvZWulMMb7iqRmnLsQbyWTkMEB2CfyM70loVDA8xg==}
cpu: [arm64]
os: [android]
'@pnpm/exe.android-x64@12.4.1':
resolution: {integrity: sha512-+l74Qb4c2YjOzNKHXJLg+1wr8xHM1ckkUhnU5KRUK9TJqiiczt6yeTZqqzHIlJ8i6pAoj5V0OJevDRwnQKLgrQ==}
'@pnpm/exe.android-x64@12.4.2':
resolution: {integrity: sha512-J1pSeCUwuKxMG70ZzpWn8JzElxiEa8NN/3N0SlZRtU2xbztChaJCKF3HaBNIj9yPfeofWzJo/lwNvDDjraQuZw==}
cpu: [x64]
os: [android]
'@pnpm/exe.darwin-arm64@12.4.1':
resolution: {integrity: sha512-6rkZkT3iGfaxknUdGHraqSWFvTa6N0ajAHluv9Ax0GRWs0sIcGNiFhDopv6xSZCsJZmG483aNS/b6UEDy3blfw==}
'@pnpm/exe.darwin-arm64@12.4.2':
resolution: {integrity: sha512-A0WDo8iErfZBXgrLseQxw8i8Y9ctUpOEl/Uu+cubnTzpD8tT9ykIB548L8YTM2WD4OS+ZOHSxy8aGZcvKq8PaQ==}
cpu: [arm64]
os: [darwin]
'@pnpm/exe.darwin-x64@12.4.1':
resolution: {integrity: sha512-Vb1CHlR88HghC1qUxjxjs82zQSXnXacPD+btG2CmG8Q/hBU7Q0/b2YWJKSQqZXicunV5khFtfTlAwJddV9RkYA==}
'@pnpm/exe.darwin-x64@12.4.2':
resolution: {integrity: sha512-MSgJdovBWHcb5DEOvfPH9yNi/T5O1Xa4ess+E1ESGo/5yuty7S4JoiIjami+fsNXfnoQMlwsMUqYU4zAvBcNCw==}
cpu: [x64]
os: [darwin]
'@pnpm/exe.freebsd-x64@12.4.1':
resolution: {integrity: sha512-iT3iHz3Nl0Sxxj7UPOtZ/aQ81AFsQhjoeWMAlPkSRO04gsgDGAXv3UYxOFaesMWsfNxaGn0A+CITbuCHFF66FA==}
'@pnpm/exe.freebsd-x64@12.4.2':
resolution: {integrity: sha512-h2YumlQSNvgbRPv+RXwABohX65f9bOBZn+jMIt7bFDISZPCzQ+Nvpt6Awbp4ip5PwQgYxbu5iREJ1fHE39Fm8A==}
cpu: [x64]
os: [freebsd]
'@pnpm/exe.linux-arm64-musl@12.4.1':
resolution: {integrity: sha512-aBooZfNXM5f+OGUgCAMFWpE/kAhsWfvmqIyMtHy6zl3aNxyInWrcY/Saln/UElzo7lZWMC0Yktroxd/2J26lNQ==}
'@pnpm/exe.linux-arm64-musl@12.4.2':
resolution: {integrity: sha512-LwSEtSEDTv6S51YLs3YvSkPyun/QmfMic1UGICUkPWFu6ByP43RdMlkKvmVkfGhAYCpnxO057vrmyJqtfZrPCA==}
cpu: [arm64]
os: [linux]
libc: [musl]
'@pnpm/exe.linux-arm64@12.4.1':
resolution: {integrity: sha512-TlOdacTTP09BgcMvwWBFRsu8VAjfwqwnslBj+XSq1JFM3ck4f3k+1O/747EuctxZxs3/o785b6Q3s7Pd92Ptsg==}
'@pnpm/exe.linux-arm64@12.4.2':
resolution: {integrity: sha512-2dSiDXyhx+RTHsewxex8f/jVjqQXWJ2oow4kCVHEWdZKeBpgMxvZ6fHkTAUBJXgqhbKIDHvuNlZBP7gJfUWL5A==}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@pnpm/exe.linux-ppc64@12.4.1':
resolution: {integrity: sha512-r/ab/MlIBo75oizUP5ITiziCCrnXz4SJwfErLQ+603AshB+Yq7xTMCoMtzTSCAMu6aaymIKkAFtZvd2J75Wq0w==}
'@pnpm/exe.linux-ppc64@12.4.2':
resolution: {integrity: sha512-8Itc+jQk+MTz04LS9D1RcH+VctAWmzM4l1cJQ+Sx7pAJNo7EKHdRMbC0Tok1jyQ7eEHNJZD5EleYneZqWfZM+g==}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@pnpm/exe.linux-riscv64@12.4.1':
resolution: {integrity: sha512-C/D1QWdKMiB8+wv/spl1rGITFUuqC+aI/fb6h8NB5sqxsOaGXeYc/g891oCuzggHn6SODk9p+I09hI76x/cMNw==}
'@pnpm/exe.linux-riscv64@12.4.2':
resolution: {integrity: sha512-hleOeqhTVpH+z9RVMGnxvU4ZnrkBUClWjCbHD9u6kwyqhGSpevoU1wTGish+CBRhmIgMAy9pAfFpqhbAKOKNfw==}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@pnpm/exe.linux-s390x@12.4.1':
resolution: {integrity: sha512-nxz5zD4yXt94uzbStDk0QTPKW+aE92hH1b5tFXK9ctB1HE9Xcq1vjTiA2LsZMFC6p4gdu5OwQeFqYNAVGa6QlA==}
'@pnpm/exe.linux-s390x@12.4.2':
resolution: {integrity: sha512-LAsQRRdP9aToENR6dtcIJ9l+e1zMYOX0tQcLGpRyLPVBQcYRLlvAPcmDshsiIHQjp05SDa9FI0czX1ZQ1a7a/A==}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@pnpm/exe.linux-x64-musl@12.4.1':
resolution: {integrity: sha512-5AwgFdGhVUg2kIweYGfxzSLEHiIG77PQhZAkXC3TwofQHsu1Wr+TrV5/rNX2PopFnHRzuE581zoB8F6Wle32yg==}
'@pnpm/exe.linux-x64-musl@12.4.2':
resolution: {integrity: sha512-kzfzH2/0BWdTABK14Yj5a1xsdkTEQUp2eXEPNakaD9jKL025lq3hyaKHIz/gIZaPDMe/1bFFK/En4ztFlbBJxw==}
cpu: [x64]
os: [linux]
libc: [musl]
'@pnpm/exe.linux-x64@12.4.1':
resolution: {integrity: sha512-FJOZuuuQMhp0oLzBtcKkLXknBI92hfkmSnlKc47vfin4HrmfID5khY2lGekL9tCzk1cpR+HShEw/meFl+nHtzQ==}
'@pnpm/exe.linux-x64@12.4.2':
resolution: {integrity: sha512-/pbt0UVTa8NMDhzOWLQRfZ6G9ROKXlJPZtx845BqyWfc7hCrWXhTLBd70yO2y8+E+IWN3oHM1s/JsIQNGk1yvg==}
cpu: [x64]
os: [linux]
libc: [glibc]
'@pnpm/exe.win32-arm64@12.4.1':
resolution: {integrity: sha512-OO7eKBL9S+xk5hRy+JUUZSNJknGuGe3GEUffsrlC2LbqKF02g+VX1anGIzSbJDvkkdnpJhSlxF5AUz2JzJu2Jw==}
'@pnpm/exe.win32-arm64@12.4.2':
resolution: {integrity: sha512-PsW19e4dAUNpZ0cS9flaxFuAmpt2dKlH/Vvi8TZ4qyJjjQzue/CEsWm+6wKVP4CJ7IT8RdL4qh+soOPWIgF2Zw==}
cpu: [arm64]
os: [win32]
'@pnpm/exe.win32-x64@12.4.1':
resolution: {integrity: sha512-x7gJHZgHo6hp354xCYA2NvoFzYJkHwovt2kVsUBK5EmXULLcP51JGMq09CX+5FRFJUZFKoXjLu3mZWmfP7o6PQ==}
'@pnpm/exe.win32-x64@12.4.2':
resolution: {integrity: sha512-+xGoeE0g55ztWvl8i5QqdmNfW3nIrTVcoQrNshEOwxthm9Ag48oXton3uxOA3/SANyz5AXexEjj2KO20NnOrEw==}
cpu: [x64]
os: [win32]
pnpm@12.4.1:
resolution: {integrity: sha512-LoHjmdc/6DkNqyXgaqeIq3pZCCSNL1o3D4K0gRR6ano2e/gEj5pv22Rg8hpm8FQt7bi5TKLIcjWWdBkgsWVtTA==}
pnpm@12.4.2:
resolution: {integrity: sha512-CK3GYTGAJ1x8ntraOdzwjJxhrU5+rzMKTzRh8QKw+QdCNFTRF/mOctR/7wYWBwZE17/8lzpqV/UJCm18NosHyQ==}
engines: {node: '>=18.*'}
hasBin: true
snapshots:
'@pnpm/exe.android-arm64@12.4.1':
'@pnpm/exe.android-arm64@12.4.2':
optional: true
'@pnpm/exe.android-x64@12.4.1':
'@pnpm/exe.android-x64@12.4.2':
optional: true
'@pnpm/exe.darwin-arm64@12.4.1':
'@pnpm/exe.darwin-arm64@12.4.2':
optional: true
'@pnpm/exe.darwin-x64@12.4.1':
'@pnpm/exe.darwin-x64@12.4.2':
optional: true
'@pnpm/exe.freebsd-x64@12.4.1':
'@pnpm/exe.freebsd-x64@12.4.2':
optional: true
'@pnpm/exe.linux-arm64-musl@12.4.1':
'@pnpm/exe.linux-arm64-musl@12.4.2':
optional: true
'@pnpm/exe.linux-arm64@12.4.1':
'@pnpm/exe.linux-arm64@12.4.2':
optional: true
'@pnpm/exe.linux-ppc64@12.4.1':
'@pnpm/exe.linux-ppc64@12.4.2':
optional: true
'@pnpm/exe.linux-riscv64@12.4.1':
'@pnpm/exe.linux-riscv64@12.4.2':
optional: true
'@pnpm/exe.linux-s390x@12.4.1':
'@pnpm/exe.linux-s390x@12.4.2':
optional: true
'@pnpm/exe.linux-x64-musl@12.4.1':
'@pnpm/exe.linux-x64-musl@12.4.2':
optional: true
'@pnpm/exe.linux-x64@12.4.1':
'@pnpm/exe.linux-x64@12.4.2':
optional: true
'@pnpm/exe.win32-arm64@12.4.1':
'@pnpm/exe.win32-arm64@12.4.2':
optional: true
'@pnpm/exe.win32-x64@12.4.1':
'@pnpm/exe.win32-x64@12.4.2':
optional: true
pnpm@12.4.1:
pnpm@12.4.2:
optionalDependencies:
'@pnpm/exe.android-arm64': 12.4.1
'@pnpm/exe.android-x64': 12.4.1
'@pnpm/exe.darwin-arm64': 12.4.1
'@pnpm/exe.darwin-x64': 12.4.1
'@pnpm/exe.freebsd-x64': 12.4.1
'@pnpm/exe.linux-arm64': 12.4.1
'@pnpm/exe.linux-arm64-musl': 12.4.1
'@pnpm/exe.linux-ppc64': 12.4.1
'@pnpm/exe.linux-riscv64': 12.4.1
'@pnpm/exe.linux-s390x': 12.4.1
'@pnpm/exe.linux-x64': 12.4.1
'@pnpm/exe.linux-x64-musl': 12.4.1
'@pnpm/exe.win32-arm64': 12.4.1
'@pnpm/exe.win32-x64': 12.4.1
'@pnpm/exe.android-arm64': 12.4.2
'@pnpm/exe.android-x64': 12.4.2
'@pnpm/exe.darwin-arm64': 12.4.2
'@pnpm/exe.darwin-x64': 12.4.2
'@pnpm/exe.freebsd-x64': 12.4.2
'@pnpm/exe.linux-arm64': 12.4.2
'@pnpm/exe.linux-arm64-musl': 12.4.2
'@pnpm/exe.linux-ppc64': 12.4.2
'@pnpm/exe.linux-riscv64': 12.4.2
'@pnpm/exe.linux-s390x': 12.4.2
'@pnpm/exe.linux-x64': 12.4.2
'@pnpm/exe.linux-x64-musl': 12.4.2
'@pnpm/exe.win32-arm64': 12.4.2
'@pnpm/exe.win32-x64': 12.4.2
---
lockfileVersion: '9.0'
@ -169,12 +169,15 @@ importers:
'@eslint/js':
specifier: 10.0.1
version: 10.0.1(eslint@10.10.0(supports-color@7.2.0))
'@kuhyx/ts-config':
specifier: link:../ts_config
version: link:../ts_config
'@types/node':
specifier: 26.5.1
version: 26.5.1
'@vitest/coverage-v8':
specifier: 5.0.0
version: 5.0.0(vitest@5.0.0)
specifier: 5.0.1
version: 5.0.1(vitest@5.0.1)
eslint:
specifier: 10.10.0
version: 10.10.0(supports-color@7.2.0)
@ -185,8 +188,8 @@ importers:
specifier: 8.70.0
version: 8.70.0(eslint@10.10.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
vitest:
specifier: 5.0.0
version: 5.0.0(@types/node@26.5.1)(@vitest/coverage-v8@5.0.0)(vite@8.2.1(@types/node@26.5.1))
specifier: 5.0.1
version: 5.0.1(@types/node@26.5.1)(@vitest/coverage-v8@5.0.1)(vite@8.2.1(@types/node@26.5.1))
packages:
@ -280,9 +283,6 @@ packages:
resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==}
engines: {node: '>=6.0.0'}
'@jridgewell/sourcemap-codec@1.5.5':
resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==}
'@jridgewell/sourcemap-codec@1.6.0':
resolution: {integrity: sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==}
@ -471,11 +471,11 @@ packages:
resolution: {integrity: sha512-BoC8PiO4Hkdo0TVJh9Ntxr5MxPDI7/oFsrygN5ADelFSeXG/qgNuucIGA+L5Z6JpPTE/uRfcTWtscjbUaufepQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@vitest/coverage-v8@5.0.0':
resolution: {integrity: sha512-toMg6PZGCIa/lQNCDoASrfb1ly4hsUKXFtFYC9kD4t78o5Y6LyNJU7AENt8eHPr3quYdxaxK7hj2mnbFfUk9NA==}
'@vitest/coverage-v8@5.0.1':
resolution: {integrity: sha512-FRC8ACiudC3dI6MTplzRSYWHDRnIv2IPfbzs4FdoJNsMal/35sWV8hwIfV8ZcqzSPy+uXHeMVONt9CEqtOU17w==}
peerDependencies:
'@vitest/browser': 5.0.0
vitest: 5.0.0
'@vitest/browser': 5.0.1
vitest: 5.0.1
peerDependenciesMeta:
'@vitest/browser':
optional: true
@ -488,8 +488,8 @@ packages:
resolution: {integrity: sha512-1EOLRfsTMnyAr3+kEAsP4o9dhaDlGPpD7H5iLBBeq//YpNB1VIahkPhB+eRp9N2Dkfw8oySROjE3yf9XDeaIkQ==}
engines: {node: '>=22'}
'@vitest/mocker@5.0.0':
resolution: {integrity: sha512-66PGTMIiVJP3t4a5yxU9qPtf7MdTBs8jmToMvy+HVflB3Yy13WJZTtPePdvU+wjRV02SKK5doLbSA6o9pwOmiA==}
'@vitest/mocker@5.0.1':
resolution: {integrity: sha512-6K1DoBNAPGvuOcSsGA4D6x+5zEEff/KmOOP3uetT2TrGpVfI+HRHRnJJfKi5ib/g1vx8IYHQD8s0pbJz8WQI7Q==}
peerDependencies:
msw: ^2.4.9
vite: ^6.0.0 || ^7.0.0 || ^8.0.0
@ -499,8 +499,8 @@ packages:
vite:
optional: true
'@vitest/spy@5.0.0':
resolution: {integrity: sha512-uy+luWBAPw9XfthoHi5AkfHUnuPYEESjl0p/r+meoBnU8bxg5GDQ3Ey8MjcJ6sqahkL4PFyrvfMJJBw7LbU06g==}
'@vitest/spy@5.0.1':
resolution: {integrity: sha512-rbto/mF/SGERxEgYOek7Xm6B9b+y+mVoo+f4b2LymYO8zM1b7uB5nHuhVMTP2hxdzgxvGiZYGxGIaMvL5y180Q==}
acorn-jsx@5.3.2:
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
@ -978,20 +978,20 @@ packages:
yaml:
optional: true
vitest@5.0.0:
resolution: {integrity: sha512-gpsMNoRhMjMktVxPtstOH4/PJuPyovVaMDr4oDilXaGH1EcqM2OE96SoHT2VIQ6fTGtTjqmHDrEu2X9RQiXf8Q==}
vitest@5.0.1:
resolution: {integrity: sha512-iA95lQbKEkvrtTkdAgnWbXfbipWiiWe/hDl2P5tMi6WFwD76G0NxXAGp/M9EOcYupeGJRr6wppMc7CoA41TQjg==}
engines: {node: ^22.12.0 || ^24.0.0 || >=26.0.0}
hasBin: true
peerDependencies:
'@edge-runtime/vm': '*'
'@opentelemetry/api': ^1.9.0
'@types/node': ^22.0.0 || >=24.0.0
'@vitest/browser-playwright': 5.0.0
'@vitest/browser-preview': 5.0.0
'@vitest/browser-playwright': 5.0.1
'@vitest/browser-preview': 5.0.1
'@vitest/browser-webdriverio': ^5.0.0-beta.5 || >=5.0.0
'@vitest/coverage-istanbul': 5.0.0
'@vitest/coverage-v8': 5.0.0
'@vitest/ui': 5.0.0
'@vitest/coverage-istanbul': 5.0.1
'@vitest/coverage-v8': 5.0.1
'@vitest/ui': 5.0.1
happy-dom: '*'
jsdom: '*'
vite: ^6.4.0 || ^7.0.0 || ^8.0.0
@ -1118,14 +1118,12 @@ snapshots:
'@jridgewell/resolve-uri@3.1.2': {}
'@jridgewell/sourcemap-codec@1.5.5': {}
'@jridgewell/sourcemap-codec@1.6.0': {}
'@jridgewell/trace-mapping@0.3.31':
dependencies:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.5.5
'@jridgewell/sourcemap-codec': 1.6.0
'@keyv/bigmap@1.3.1(keyv@5.6.0)':
dependencies:
@ -1289,7 +1287,7 @@ snapshots:
'@typescript-eslint/types': 8.70.0
eslint-visitor-keys: 5.0.1
'@vitest/coverage-v8@5.0.0(vitest@5.0.0)':
'@vitest/coverage-v8@5.0.1(vitest@5.0.1)':
dependencies:
'@bcoe/v8-coverage': 1.0.2
'@vitest/istanbul-lib-coverage': 1.0.1
@ -1299,7 +1297,7 @@ snapshots:
obug: 2.1.4
std-env: 4.2.0
tinyrainbow: 3.1.1
vitest: 5.0.0(@types/node@26.5.1)(@vitest/coverage-v8@5.0.0)(vite@8.2.1(@types/node@26.5.1))
vitest: 5.0.1(@types/node@26.5.1)(@vitest/coverage-v8@5.0.1)(vite@8.2.1(@types/node@26.5.1))
'@vitest/istanbul-lib-coverage@1.0.1': {}
@ -1307,16 +1305,16 @@ snapshots:
dependencies:
'@vitest/istanbul-lib-coverage': 1.0.1
'@vitest/mocker@5.0.0(vite@8.2.1(@types/node@26.5.1))':
'@vitest/mocker@5.0.1(vite@8.2.1(@types/node@26.5.1))':
dependencies:
'@jridgewell/trace-mapping': 0.3.31
'@vitest/spy': 5.0.0
'@vitest/spy': 5.0.1
estree-walker: 3.0.3
magic-string: 1.3.1
optionalDependencies:
vite: 8.2.1(@types/node@26.5.1)
'@vitest/spy@5.0.0': {}
'@vitest/spy@5.0.1': {}
acorn-jsx@5.3.2(acorn@8.18.0):
dependencies:
@ -1725,10 +1723,10 @@ snapshots:
'@types/node': 26.5.1
fsevents: 2.3.3
vitest@5.0.0(@types/node@26.5.1)(@vitest/coverage-v8@5.0.0)(vite@8.2.1(@types/node@26.5.1)):
vitest@5.0.1(@types/node@26.5.1)(@vitest/coverage-v8@5.0.1)(vite@8.2.1(@types/node@26.5.1)):
dependencies:
'@types/chai': 5.2.3
'@vitest/mocker': 5.0.0(vite@8.2.1(@types/node@26.5.1))
'@vitest/mocker': 5.0.1(vite@8.2.1(@types/node@26.5.1))
chai: 6.2.2
es-module-lexer: 2.3.2
expect-type: 1.4.0
@ -1743,7 +1741,7 @@ snapshots:
why-is-node-running: 2.3.0
optionalDependencies:
'@types/node': 26.5.1
'@vitest/coverage-v8': 5.0.0(vitest@5.0.0)
'@vitest/coverage-v8': 5.0.1(vitest@5.0.1)
transitivePeerDependencies:
- msw

View File

@ -1,10 +1,10 @@
import { describe, expect, it, vi } from 'vitest'
import {
type Clock,
createManualClock,
createRealClock,
realClock,
type Clock,
} from './clock.ts'
describe('createRealClock', () => {

View File

@ -12,9 +12,7 @@ export interface Clock {
}
/** A {@link Clock} backed by the browser's monotonic performance timer. */
export const createRealClock = (): Clock => ({
now: (): number => performance.now(),
})
export const createRealClock = (): Clock => ({ now: (): number => performance.now() })
/**
* The one real clock instance UI code should pass around.
@ -39,10 +37,10 @@ export interface ManualClock extends Clock {
export const createManualClock = (startMs = 0): ManualClock => {
let current = startMs
return {
now: (): number => current,
advance: (deltaMs: number): void => {
current += deltaMs
},
now: (): number => current,
set: (timeMs: number): void => {
current = timeMs
},

View File

@ -7,11 +7,11 @@
* which is how these ended up duplicated four ways to begin with.
*/
export {
type Clock,
createManualClock,
createRealClock,
realClock,
type Clock,
type ManualClock,
realClock,
} from './clock.ts'
export {
createRng,

View File

@ -20,8 +20,8 @@ import {
* would defeat the entire point of the test.
*/
const GOLDEN_12345 = [
0.979_728_267_760_947_3, 0.306_752_264_499_664_3, 0.484_205_421_525_985,
0.817_934_412_509_203, 0.509_428_369_347_006_1,
0.9797282677609473, 0.3067522644996643, 0.484205421525985,
0.817934412509203, 0.5094283693470061,
]
describe('mulberry32 core', () => {
@ -51,7 +51,7 @@ describe('mulberry32 core', () => {
it('stays within [0, 1) across many draws', () => {
const rng = createRng(42)
for (let i = 0; i < 1000; i += 1) {
for (let index = 0; index < 1000; index += 1) {
const value = nextFloat(rng)
expect(value).toBeGreaterThanOrEqual(0)
expect(value).toBeLessThan(1)
@ -68,10 +68,10 @@ describe('nextInt', () => {
it('is inclusive of both bounds', () => {
const rng = createRng(3)
const seen = new Set<number>()
for (let i = 0; i < 500; i += 1) {
for (let index = 0; index < 500; index += 1) {
seen.add(nextInt(rng, 1, 3))
}
expect([...seen].sort()).toEqual([1, 2, 3])
expect([...seen].toSorted((a, b) => a - b)).toEqual([1, 2, 3])
})
it('returns the only value when min equals max', () => {
@ -97,7 +97,7 @@ describe('nextChance', () => {
it('lands near the requested probability over many draws', () => {
const rng = createRng(2024)
let hits = 0
for (let i = 0; i < 4000; i += 1) {
for (let index = 0; index < 4000; index += 1) {
if (nextChance(rng, 0.25)) {
hits += 1
}
@ -115,10 +115,10 @@ describe('pick', () => {
it('eventually returns every element', () => {
const rng = createRng(4)
const seen = new Set<string>()
for (let i = 0; i < 500; i += 1) {
for (let index = 0; index < 500; index += 1) {
seen.add(pick(rng, ['a', 'b', 'c']))
}
expect([...seen].sort()).toEqual(['a', 'b', 'c'])
expect([...seen].toSorted((a, b) => a.localeCompare(b))).toEqual(['a', 'b', 'c'])
})
it('is deterministic for a given seed', () => {

View File

@ -40,7 +40,7 @@ export const createRng = (seed: number): Rng => ({ s: seed >>> 0 })
* of it, so they all consume exactly one step per call.
*/
export const nextFloat = (rng: Rng): number => {
rng.s = (rng.s + 0x6d_2b_79_f5) >>> 0
rng.s = (rng.s + 0x6D_2B_79_F5) >>> 0
let t = rng.s
t = Math.imul(t ^ (t >>> 15), t | 1)
t ^= t + Math.imul(t ^ (t >>> 7), t | 61)
@ -84,14 +84,14 @@ export const pick = <T>(rng: Rng, items: readonly [T, ...T[]]): T => {
* around rather than threading mutable state through free functions.
*/
export interface SeededRng {
/** True with the given probability in [0, 1]. */
chance: (probability: number) => boolean
/** Uniform float in [0, 1). */
float: () => number
/** Uniform integer in [minInclusive, maxInclusive]. */
int: (minInclusive: number, maxInclusive: number) => number
/** Uniform element of a non-empty array. */
pick: <T>(items: readonly T[]) => T
/** True with the given probability in [0, 1]. */
chance: (probability: number) => boolean
}
/**
@ -105,6 +105,7 @@ export const createSeededRng = (seed: number): SeededRng => {
const state = createRng(seed)
const float = (): number => nextFloat(state)
return {
chance: (probability: number): boolean => float() < probability,
float,
int: (minInclusive: number, maxInclusive: number): number =>
nextInt(state, minInclusive, maxInclusive),
@ -115,6 +116,5 @@ export const createSeededRng = (seed: number): SeededRng => {
}
return chosen
},
chance: (probability: number): boolean => float() < probability,
}
}

View File

@ -1,4 +1,6 @@
{
// Strictness comes from the shared base; only output/lib options live here.
"extends": "@kuhyx/ts-config/tsconfig",
"compilerOptions": {
"target": "ES2023",
// DOM is here only for `performance.now()` in clock.ts -- the package
@ -9,21 +11,6 @@
"module": "ESNext",
"moduleResolution": "bundler",
/* Strictness: everything on, matching the consumers so a file that
compiles here compiles there. */
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"exactOptionalPropertyTypes": true,
"useUnknownInCatchVariables": true,
"verbatimModuleSyntax": true,
"isolatedModules": true,
"erasableSyntaxOnly": true,
/* Ships a prebuilt dist/ (ESM + .d.ts) because consumers use Vite, which
does not transpile dependencies. */
"rewriteRelativeImportExtensions": true,
@ -32,10 +19,7 @@
"declarationMap": true,
"sourceMap": true,
"outDir": "dist",
"rootDir": "src",
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
"rootDir": "src"
},
"include": ["src"],
"exclude": ["src/**/*.test.ts"]

View File

@ -5,6 +5,7 @@
* `import "@kuhyx/web-ui/tokens.css";`
*/
export { clamp01, fractionFromPointer, nth, quantileValue, valueQuantile } from "./quantile.ts";
export { RangeSlider, steppedValue, type RangeSliderProps } from "./range-slider.tsx";
export { RangeSlider, type RangeSliderProps } from "./range-slider.tsx";
export { keyTarget, steppedValue } from "./stepped-value.ts";
export { fuzzyMatch } from "./text.ts";
//# sourceMappingURL=index.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,GAAG,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,GAAG,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}

View File

@ -5,6 +5,7 @@
* `import "@kuhyx/web-ui/tokens.css";`
*/
export { clamp01, fractionFromPointer, nth, quantileValue, valueQuantile } from "./quantile.js";
export { RangeSlider, steppedValue } from "./range-slider.js";
export { RangeSlider } from "./range-slider.js";
export { keyTarget, steppedValue } from "./stepped-value.js";
export { fuzzyMatch } from "./text.js";
//# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,GAAG,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,YAAY,EAAyB,MAAM,mBAAoB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,GAAG,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAChG,OAAO,EAAE,WAAW,EAAyB,MAAM,mBAAoB,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}

View File

@ -1 +1 @@
{"version":3,"file":"quantile.d.ts","sourceRoot":"","sources":["../src/quantile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMpE;AAED,kCAAkC;AAClC,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAS1E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAa9E;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1E"}
{"version":3,"file":"quantile.d.ts","sourceRoot":"","sources":["../src/quantile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMpE;AAED,kCAAkC;AAClC,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEzC;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAS1E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAY9E;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1E"}

View File

@ -52,9 +52,7 @@ export function quantileValue(sorted, f) {
*/
export function valueQuantile(sorted, value) {
const n = sorted.length;
if (n <= 1)
return 0;
if (value <= nth(sorted, 0))
if ((n <= 1) || (value <= nth(sorted, 0)))
return 0;
if (value >= nth(sorted, n - 1))
return 1;

View File

@ -1 +1 @@
{"version":3,"file":"quantile.js","sourceRoot":"","sources":["../src/quantile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,MAAyB,EAAE,KAAa;IAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,UAAU,CAAC,SAAS,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,kCAAkC;AAClC,MAAM,UAAU,OAAO,CAAC,CAAS;IAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,MAAyB,EAAE,CAAS;IAChE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAyB,EAAE,KAAa;IACpE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACrB,IAAI,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACtC,IAAI,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IAC1C,qEAAqE;IACrE,kDAAkD;IAClD,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC;IAC/C,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAClB,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC1B,yDAAyD;IACzD,OAAO,CAAC,EAAE,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAa,EAAE,OAAe;IAChE,OAAO,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5E,CAAC"}
{"version":3,"file":"quantile.js","sourceRoot":"","sources":["../src/quantile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,MAAyB,EAAE,KAAa;IAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,UAAU,CAAC,SAAS,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,kCAAkC;AAClC,MAAM,UAAU,OAAO,CAAC,CAAS;IAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,MAAyB,EAAE,CAAS;IAChE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAyB,EAAE,KAAa;IACpE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACpD,IAAI,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IAC1C,qEAAqE;IACrE,kDAAkD;IAClD,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC;IAC/C,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAClB,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC1B,yDAAyD;IACzD,OAAO,CAAC,EAAE,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAa,EAAE,OAAe;IAChE,OAAO,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5E,CAAC"}

View File

@ -16,16 +16,5 @@ export interface RangeSliderProps {
/** The full ascending distribution — not just its endpoints. */
readonly values: readonly number[];
}
/**
* Steps one thumb by `delta` positions through the distribution. Pure, so the
* keyboard contract is testable without layout.
*
* Steps to the next *distinct* value rather than the next index. Real
* distributions are lumpy -- awesome-mcp-explorer's star counts hold ~1500
* duplicate zeros -- and an index step inside a run of equal values changes the
* index while leaving the value (and therefore the thumb, and the filter)
* exactly where it was. That reads as a dead arrow key.
*/
export declare function steppedValue(values: readonly number[], current: number, delta: number): number;
export declare function RangeSlider({ format, hi, label, lo, onChange, values, }: RangeSliderProps): null | React.JSX.Element;
//# sourceMappingURL=range-slider.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"range-slider.d.ts","sourceRoot":"","sources":["../src/range-slider.tsx"],"names":[],"mappings":"AAyBA,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5C,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,gEAAgE;IAChE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAID;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,MAAM,CAkBR;AAED,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,EAAE,EACF,KAAK,EACL,EAAE,EACF,QAAQ,EACR,MAAM,GACP,EAAE,gBAAgB,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAyG7C"}
{"version":3,"file":"range-slider.d.ts","sourceRoot":"","sources":["../src/range-slider.tsx"],"names":[],"mappings":"AA0BA,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5C,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,gEAAgE;IAChE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAID,wBAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,EAAE,EACF,KAAK,EACL,EAAE,EACF,QAAQ,EACR,MAAM,GACP,EAAE,gBAAgB,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAkG7C"}

View File

@ -22,36 +22,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
*/
import { useCallback, useState } from "react";
import { fractionFromPointer, nth, quantileValue, valueQuantile } from "./quantile.js";
/**
* Steps one thumb by `delta` positions through the distribution. Pure, so the
* keyboard contract is testable without layout.
*
* Steps to the next *distinct* value rather than the next index. Real
* distributions are lumpy -- awesome-mcp-explorer's star counts hold ~1500
* duplicate zeros -- and an index step inside a run of equal values changes the
* index while leaving the value (and therefore the thumb, and the filter)
* exactly where it was. That reads as a dead arrow key.
*/
export function steppedValue(values, current, delta) {
const last = values.length - 1;
// Round to a real sample index so a thumb sitting between two samples still
// advances rather than stalling on a fractional step.
const index = Math.round(valueQuantile(values, current) * last);
const direction = Math.sign(delta);
if (direction === 0)
return nth(values, index);
let cursor = index;
for (let taken = 0; taken < Math.abs(delta); taken++) {
let next = cursor + direction;
while (next >= 0 && next <= last && nth(values, next) === nth(values, cursor)) {
next += direction;
}
if (next < 0 || next > last)
break;
cursor = next;
}
return nth(values, cursor);
}
import { keyTarget } from "./stepped-value.js";
export function RangeSlider({ format, hi, label, lo, onChange, values, }) {
const [drag, setDrag] = useState(null);
const apply = useCallback((thumb, value) => {
@ -63,29 +34,17 @@ export function RangeSlider({ format, hi, label, lo, onChange, values, }) {
// Reads the rect off the event's own target rather than a ref: the pointer
// handlers are bound to the track, so currentTarget *is* the track. A ref
// would add a null branch that cannot happen once the element is mounted.
const valueAt = useCallback((track, clientX) => quantileValue(values, fractionFromPointer(track.getBoundingClientRect(), clientX)), [values]);
const valueAt = useCallback((track, clientX) => {
const fraction = fractionFromPointer(track.getBoundingClientRect(), clientX);
return quantileValue(values, fraction);
}, [values]);
const onKeyDown = useCallback((thumb, event) => {
const current = thumb === "lo" ? lo : hi;
const step = (delta) => {
event.preventDefault();
apply(thumb, steppedValue(values, current, delta));
};
if (event.key === "ArrowLeft" || event.key === "ArrowDown")
step(-1);
else if (event.key === "ArrowRight" || event.key === "ArrowUp")
step(1);
else if (event.key === "PageDown")
step(-10);
else if (event.key === "PageUp")
step(10);
else if (event.key === "Home") {
event.preventDefault();
apply(thumb, nth(values, 0));
}
else if (event.key === "End") {
event.preventDefault();
apply(thumb, nth(values, values.length - 1));
}
const target = keyTarget(event.key, values, current);
if (target === undefined)
return;
event.preventDefault();
apply(thumb, target);
}, [apply, hi, lo, values]);
// Fewer than two values means there is nothing to range over.
if (values.length < 2)
@ -95,19 +54,21 @@ export function RangeSlider({ format, hi, label, lo, onChange, values, }) {
const loFraction = valueQuantile(values, lo) * 100;
const hiFraction = valueQuantile(values, hi) * 100;
const name = label ?? "Range";
const thumbProps = (thumb) => ({
"aria-valuemax": highest,
"aria-valuemin": lowest,
"aria-valuenow": thumb === "lo" ? lo : hi,
className: `slider-thumb slider-${thumb}`,
onKeyDown: (event) => {
onKeyDown(thumb, event);
},
role: "slider",
style: { left: `${String(thumb === "lo" ? loFraction : hiFraction)}%` },
tabIndex: 0,
type: "button",
});
const thumbProps = (thumb) => {
return {
"aria-valuemax": highest,
"aria-valuemin": lowest,
"aria-valuenow": thumb === "lo" ? lo : hi,
className: `slider-thumb slider-${thumb}`,
onKeyDown: (event) => {
onKeyDown(thumb, event);
},
role: "slider",
style: { left: `${String(thumb === "lo" ? loFraction : hiFraction)}%` },
tabIndex: 0,
type: "button",
};
};
return (_jsxs("div", { className: "slider", children: [label !== undefined && format !== undefined && (_jsxs("div", { className: "slider-head", children: [_jsx("span", { children: label }), _jsxs("span", { className: "slider-value", children: [format(lo), " \u2013 ", format(hi)] })] })), _jsxs("div", { className: "slider-track", onPointerDown: (event) => {
const value = valueAt(event.currentTarget, event.clientX);
// Grab whichever thumb is nearer, so a press anywhere on the track

File diff suppressed because one or more lines are too long

19
web_ui/dist/stepped-value.d.ts vendored Normal file
View File

@ -0,0 +1,19 @@
/**
* Steps one thumb by `delta` positions through the distribution. Pure, so the
* keyboard contract is testable without layout.
*
* Steps to the next *distinct* value rather than the next index. Real
* distributions are lumpy -- awesome-mcp-explorer's star counts hold ~1500
* duplicate zeros -- and an index step inside a run of equal values changes the
* index while leaving the value (and therefore the thumb, and the filter)
* exactly where it was. That reads as a dead arrow key.
*/
export declare function steppedValue(values: readonly number[], current: number, delta: number): number;
/**
* The value a thumb at `current` moves to for a key, or `undefined` when the
* key is not one the slider handles (so the event is left to the browser).
* Arrow keys step one distinct value, Page keys ten, Home/End jump to the
* bounds.
*/
export declare function keyTarget(key: string, values: readonly number[], current: number): number | undefined;
//# sourceMappingURL=stepped-value.d.ts.map

1
web_ui/dist/stepped-value.d.ts.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"stepped-value.d.ts","sourceRoot":"","sources":["../src/stepped-value.ts"],"names":[],"mappings":"AAOA;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,MAAM,CAkBR;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CA0BpB"}

70
web_ui/dist/stepped-value.js vendored Normal file
View File

@ -0,0 +1,70 @@
/**
* The keyboard contract of the range slider, kept pure and in its own module
* so range-slider.tsx exports only the component (react-refresh needs that
* for HMR to keep working) and the contract is testable without layout.
*/
import { nth, valueQuantile } from "./quantile.js";
/**
* Steps one thumb by `delta` positions through the distribution. Pure, so the
* keyboard contract is testable without layout.
*
* Steps to the next *distinct* value rather than the next index. Real
* distributions are lumpy -- awesome-mcp-explorer's star counts hold ~1500
* duplicate zeros -- and an index step inside a run of equal values changes the
* index while leaving the value (and therefore the thumb, and the filter)
* exactly where it was. That reads as a dead arrow key.
*/
export function steppedValue(values, current, delta) {
const last = values.length - 1;
// Round to a real sample index so a thumb sitting between two samples still
// advances rather than stalling on a fractional step.
const index = Math.round(valueQuantile(values, current) * last);
const direction = Math.sign(delta);
if (direction === 0)
return nth(values, index);
let cursor = index;
for (let taken = 0; taken < Math.abs(delta); taken++) {
let next = cursor + direction;
while (next >= 0 && next <= last && nth(values, next) === nth(values, cursor)) {
next += direction;
}
if (next < 0 || next > last)
break;
cursor = next;
}
return nth(values, cursor);
}
/**
* The value a thumb at `current` moves to for a key, or `undefined` when the
* key is not one the slider handles (so the event is left to the browser).
* Arrow keys step one distinct value, Page keys ten, Home/End jump to the
* bounds.
*/
export function keyTarget(key, values, current) {
switch (key) {
case "ArrowDown":
case "ArrowLeft": {
return steppedValue(values, current, -1);
}
case "ArrowRight":
case "ArrowUp": {
return steppedValue(values, current, 1);
}
case "End": {
return nth(values, values.length - 1);
}
case "Home": {
return nth(values, 0);
}
case "PageDown": {
return steppedValue(values, current, -10);
}
case "PageUp": {
return steppedValue(values, current, 10);
}
default: {
return undefined;
}
}
}
//# sourceMappingURL=stepped-value.js.map

1
web_ui/dist/stepped-value.js.map vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"stepped-value.js","sourceRoot":"","sources":["../src/stepped-value.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAyB,EACzB,OAAe,EACf,KAAa;IAEb,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/B,4EAA4E;IAC5E,sDAAsD;IACtD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE/C,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACrD,IAAI,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC;QAC9B,OAAO,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;YAC9E,IAAI,IAAI,SAAS,CAAC;QACpB,CAAC;QACD,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,IAAI;YAAE,MAAM;QACnC,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CACvB,GAAW,EACX,MAAyB,EACzB,OAAe;IAEf,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,WAAW,CAAC;QACjB,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,OAAO,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3C,CAAC;QACD,KAAK,YAAY,CAAC;QAClB,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,OAAO,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QAC1C,CAAC;QACD,KAAK,KAAK,CAAC,CAAC,CAAC;YACX,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACxC,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACxB,CAAC;QACD,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,OAAO,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;AACH,CAAC"}

View File

@ -1,42 +1,25 @@
// Type-aware flat config for the shared component layer.
//
// A trimmed version of awesome-mcp-explorer's: typescript-eslint's
// *type-checked* strict + stylistic presets, so anything they flag is an error.
// The consumers layer unicorn/sonarjs/perfectionist on top; this package keeps
// to the presets its own devDependencies actually declare, because a config
// referencing plugins that are not installed is a lint script that cannot run.
import js from "@eslint/js";
import tseslint from "typescript-eslint";
// The shared preset with the React layer, plus one frozen API name. This
// package is one of the repos the bar is defined for.
import { defineConfig } from "@kuhyx/ts-config";
export default tseslint.config(
// eslint.config.js itself is not in tsconfig.lint.json, so type-aware
// rules cannot run on it; linting the linter config buys nothing anyway.
{ ignores: ["dist", "coverage", "eslint.config.js"] },
{ linterOptions: { reportUnusedDisableDirectives: "error" } },
js.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
files: ["**/*.{ts,tsx}"],
languageOptions: {
parserOptions: {
project: ["./tsconfig.lint.json"],
tsconfigRootDir: import.meta.dirname,
export default defineConfig({
// Flat files under src/, no layers to fence and no alias configured.
aliasOnly: false,
overrides: [
{
files: ["src/text.ts"],
rules: {
// `fuzzyMatch` is public API at four call sites in dufs-cloud and
// awesome-mcp-explorer; the preset's prefix list would rename it to
// `matchesFuzzy`, a breaking change for no safety gain. Revisit at
// the next major.
"unicorn/consistent-boolean-name": "off",
},
},
rules: {
// Every exported symbol here is consumed across a package boundary, so
// an explicit return type is documentation, not ceremony.
"@typescript-eslint/explicit-function-return-type": "error",
},
},
{
// Tests reach for non-null assertions on queries that cannot return null
// in a passing test; asserting them again would only add noise.
files: ["**/*.test.{ts,tsx}"],
rules: { "@typescript-eslint/no-non-null-assertion": "off" },
},
);
],
// tsconfig.json excludes the tests so they never land in dist/; the lint
// project widens the include for type-aware rules (see tsconfig.lint.json).
project: ["./tsconfig.lint.json"],
react: true,
tsconfigRootDir: import.meta.dirname,
});

View File

@ -1,6 +1,6 @@
{
"name": "@kuhyx/web-ui",
"version": "0.3.2",
"version": "0.4.0",
"private": false,
"type": "module",
"description": "The shared token + component layer for kuhy's web apps: the frozen palette, spacing/radius/type scales as CSS custom properties, and the components that were each reimplemented in two or more repos.",
@ -9,7 +9,7 @@
"node": ">=24",
"pnpm": ">=10"
},
"packageManager": "pnpm@12.4.1+sha512.2e81e399d73fe8390dab25e06aa788ab7a5908248d2f5a370f82b481147a6a7a367bf8048f9a6fdb6460f21a66f0542dedb8b94ca2c8723596741920b1656d4c",
"packageManager": "pnpm@12.4.2",
"files": [
"dist"
],
@ -34,19 +34,20 @@
},
"devDependencies": {
"@eslint/js": "10.0.1",
"@kuhyx/ts-config": "link:../ts_config",
"@testing-library/jest-dom": "7.0.1",
"@testing-library/react": "16.3.3",
"@testing-library/user-event": "14.6.7",
"@types/node": "26.5.1",
"@types/react": "19.3.0",
"@types/react-dom": "19.3.0",
"@vitest/coverage-v8": "5.0.0",
"@vitest/coverage-v8": "5.0.1",
"eslint": "10.10.0",
"jsdom": "30.0.1",
"react": "19.3.0",
"react-dom": "19.3.0",
"typescript": "6.0.3",
"typescript-eslint": "8.70.0",
"vitest": "5.0.0",
"@types/node": "26.5.1"
"vitest": "5.0.1"
}
}

View File

@ -7,153 +7,153 @@ importers:
configDependencies: {}
packageManagerDependencies:
pnpm:
specifier: 12.4.1
version: 12.4.1
specifier: 12.4.2
version: 12.4.2
packages:
'@pnpm/exe.android-arm64@12.4.1':
resolution: {integrity: sha512-/HwsqXMSmlOfgtV9+O0ratzjV6Vd/8n1hh4rGHpCGmDURvt52MwZxdbhyxP4K03ZfvgSDvotFPr8O+RzE5Eu8A==}
'@pnpm/exe.android-arm64@12.4.2':
resolution: {integrity: sha512-E255MbcQ0V1577M2BV0ajWuP7KmTPYA0jqZnk3rK6Lq3kTvZWulMMb7iqRmnLsQbyWTkMEB2CfyM70loVDA8xg==}
cpu: [arm64]
os: [android]
'@pnpm/exe.android-x64@12.4.1':
resolution: {integrity: sha512-+l74Qb4c2YjOzNKHXJLg+1wr8xHM1ckkUhnU5KRUK9TJqiiczt6yeTZqqzHIlJ8i6pAoj5V0OJevDRwnQKLgrQ==}
'@pnpm/exe.android-x64@12.4.2':
resolution: {integrity: sha512-J1pSeCUwuKxMG70ZzpWn8JzElxiEa8NN/3N0SlZRtU2xbztChaJCKF3HaBNIj9yPfeofWzJo/lwNvDDjraQuZw==}
cpu: [x64]
os: [android]
'@pnpm/exe.darwin-arm64@12.4.1':
resolution: {integrity: sha512-6rkZkT3iGfaxknUdGHraqSWFvTa6N0ajAHluv9Ax0GRWs0sIcGNiFhDopv6xSZCsJZmG483aNS/b6UEDy3blfw==}
'@pnpm/exe.darwin-arm64@12.4.2':
resolution: {integrity: sha512-A0WDo8iErfZBXgrLseQxw8i8Y9ctUpOEl/Uu+cubnTzpD8tT9ykIB548L8YTM2WD4OS+ZOHSxy8aGZcvKq8PaQ==}
cpu: [arm64]
os: [darwin]
'@pnpm/exe.darwin-x64@12.4.1':
resolution: {integrity: sha512-Vb1CHlR88HghC1qUxjxjs82zQSXnXacPD+btG2CmG8Q/hBU7Q0/b2YWJKSQqZXicunV5khFtfTlAwJddV9RkYA==}
'@pnpm/exe.darwin-x64@12.4.2':
resolution: {integrity: sha512-MSgJdovBWHcb5DEOvfPH9yNi/T5O1Xa4ess+E1ESGo/5yuty7S4JoiIjami+fsNXfnoQMlwsMUqYU4zAvBcNCw==}
cpu: [x64]
os: [darwin]
'@pnpm/exe.freebsd-x64@12.4.1':
resolution: {integrity: sha512-iT3iHz3Nl0Sxxj7UPOtZ/aQ81AFsQhjoeWMAlPkSRO04gsgDGAXv3UYxOFaesMWsfNxaGn0A+CITbuCHFF66FA==}
'@pnpm/exe.freebsd-x64@12.4.2':
resolution: {integrity: sha512-h2YumlQSNvgbRPv+RXwABohX65f9bOBZn+jMIt7bFDISZPCzQ+Nvpt6Awbp4ip5PwQgYxbu5iREJ1fHE39Fm8A==}
cpu: [x64]
os: [freebsd]
'@pnpm/exe.linux-arm64-musl@12.4.1':
resolution: {integrity: sha512-aBooZfNXM5f+OGUgCAMFWpE/kAhsWfvmqIyMtHy6zl3aNxyInWrcY/Saln/UElzo7lZWMC0Yktroxd/2J26lNQ==}
'@pnpm/exe.linux-arm64-musl@12.4.2':
resolution: {integrity: sha512-LwSEtSEDTv6S51YLs3YvSkPyun/QmfMic1UGICUkPWFu6ByP43RdMlkKvmVkfGhAYCpnxO057vrmyJqtfZrPCA==}
cpu: [arm64]
os: [linux]
libc: [musl]
'@pnpm/exe.linux-arm64@12.4.1':
resolution: {integrity: sha512-TlOdacTTP09BgcMvwWBFRsu8VAjfwqwnslBj+XSq1JFM3ck4f3k+1O/747EuctxZxs3/o785b6Q3s7Pd92Ptsg==}
'@pnpm/exe.linux-arm64@12.4.2':
resolution: {integrity: sha512-2dSiDXyhx+RTHsewxex8f/jVjqQXWJ2oow4kCVHEWdZKeBpgMxvZ6fHkTAUBJXgqhbKIDHvuNlZBP7gJfUWL5A==}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@pnpm/exe.linux-ppc64@12.4.1':
resolution: {integrity: sha512-r/ab/MlIBo75oizUP5ITiziCCrnXz4SJwfErLQ+603AshB+Yq7xTMCoMtzTSCAMu6aaymIKkAFtZvd2J75Wq0w==}
'@pnpm/exe.linux-ppc64@12.4.2':
resolution: {integrity: sha512-8Itc+jQk+MTz04LS9D1RcH+VctAWmzM4l1cJQ+Sx7pAJNo7EKHdRMbC0Tok1jyQ7eEHNJZD5EleYneZqWfZM+g==}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@pnpm/exe.linux-riscv64@12.4.1':
resolution: {integrity: sha512-C/D1QWdKMiB8+wv/spl1rGITFUuqC+aI/fb6h8NB5sqxsOaGXeYc/g891oCuzggHn6SODk9p+I09hI76x/cMNw==}
'@pnpm/exe.linux-riscv64@12.4.2':
resolution: {integrity: sha512-hleOeqhTVpH+z9RVMGnxvU4ZnrkBUClWjCbHD9u6kwyqhGSpevoU1wTGish+CBRhmIgMAy9pAfFpqhbAKOKNfw==}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@pnpm/exe.linux-s390x@12.4.1':
resolution: {integrity: sha512-nxz5zD4yXt94uzbStDk0QTPKW+aE92hH1b5tFXK9ctB1HE9Xcq1vjTiA2LsZMFC6p4gdu5OwQeFqYNAVGa6QlA==}
'@pnpm/exe.linux-s390x@12.4.2':
resolution: {integrity: sha512-LAsQRRdP9aToENR6dtcIJ9l+e1zMYOX0tQcLGpRyLPVBQcYRLlvAPcmDshsiIHQjp05SDa9FI0czX1ZQ1a7a/A==}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@pnpm/exe.linux-x64-musl@12.4.1':
resolution: {integrity: sha512-5AwgFdGhVUg2kIweYGfxzSLEHiIG77PQhZAkXC3TwofQHsu1Wr+TrV5/rNX2PopFnHRzuE581zoB8F6Wle32yg==}
'@pnpm/exe.linux-x64-musl@12.4.2':
resolution: {integrity: sha512-kzfzH2/0BWdTABK14Yj5a1xsdkTEQUp2eXEPNakaD9jKL025lq3hyaKHIz/gIZaPDMe/1bFFK/En4ztFlbBJxw==}
cpu: [x64]
os: [linux]
libc: [musl]
'@pnpm/exe.linux-x64@12.4.1':
resolution: {integrity: sha512-FJOZuuuQMhp0oLzBtcKkLXknBI92hfkmSnlKc47vfin4HrmfID5khY2lGekL9tCzk1cpR+HShEw/meFl+nHtzQ==}
'@pnpm/exe.linux-x64@12.4.2':
resolution: {integrity: sha512-/pbt0UVTa8NMDhzOWLQRfZ6G9ROKXlJPZtx845BqyWfc7hCrWXhTLBd70yO2y8+E+IWN3oHM1s/JsIQNGk1yvg==}
cpu: [x64]
os: [linux]
libc: [glibc]
'@pnpm/exe.win32-arm64@12.4.1':
resolution: {integrity: sha512-OO7eKBL9S+xk5hRy+JUUZSNJknGuGe3GEUffsrlC2LbqKF02g+VX1anGIzSbJDvkkdnpJhSlxF5AUz2JzJu2Jw==}
'@pnpm/exe.win32-arm64@12.4.2':
resolution: {integrity: sha512-PsW19e4dAUNpZ0cS9flaxFuAmpt2dKlH/Vvi8TZ4qyJjjQzue/CEsWm+6wKVP4CJ7IT8RdL4qh+soOPWIgF2Zw==}
cpu: [arm64]
os: [win32]
'@pnpm/exe.win32-x64@12.4.1':
resolution: {integrity: sha512-x7gJHZgHo6hp354xCYA2NvoFzYJkHwovt2kVsUBK5EmXULLcP51JGMq09CX+5FRFJUZFKoXjLu3mZWmfP7o6PQ==}
'@pnpm/exe.win32-x64@12.4.2':
resolution: {integrity: sha512-+xGoeE0g55ztWvl8i5QqdmNfW3nIrTVcoQrNshEOwxthm9Ag48oXton3uxOA3/SANyz5AXexEjj2KO20NnOrEw==}
cpu: [x64]
os: [win32]
pnpm@12.4.1:
resolution: {integrity: sha512-LoHjmdc/6DkNqyXgaqeIq3pZCCSNL1o3D4K0gRR6ano2e/gEj5pv22Rg8hpm8FQt7bi5TKLIcjWWdBkgsWVtTA==}
pnpm@12.4.2:
resolution: {integrity: sha512-CK3GYTGAJ1x8ntraOdzwjJxhrU5+rzMKTzRh8QKw+QdCNFTRF/mOctR/7wYWBwZE17/8lzpqV/UJCm18NosHyQ==}
engines: {node: '>=18.*'}
hasBin: true
snapshots:
'@pnpm/exe.android-arm64@12.4.1':
'@pnpm/exe.android-arm64@12.4.2':
optional: true
'@pnpm/exe.android-x64@12.4.1':
'@pnpm/exe.android-x64@12.4.2':
optional: true
'@pnpm/exe.darwin-arm64@12.4.1':
'@pnpm/exe.darwin-arm64@12.4.2':
optional: true
'@pnpm/exe.darwin-x64@12.4.1':
'@pnpm/exe.darwin-x64@12.4.2':
optional: true
'@pnpm/exe.freebsd-x64@12.4.1':
'@pnpm/exe.freebsd-x64@12.4.2':
optional: true
'@pnpm/exe.linux-arm64-musl@12.4.1':
'@pnpm/exe.linux-arm64-musl@12.4.2':
optional: true
'@pnpm/exe.linux-arm64@12.4.1':
'@pnpm/exe.linux-arm64@12.4.2':
optional: true
'@pnpm/exe.linux-ppc64@12.4.1':
'@pnpm/exe.linux-ppc64@12.4.2':
optional: true
'@pnpm/exe.linux-riscv64@12.4.1':
'@pnpm/exe.linux-riscv64@12.4.2':
optional: true
'@pnpm/exe.linux-s390x@12.4.1':
'@pnpm/exe.linux-s390x@12.4.2':
optional: true
'@pnpm/exe.linux-x64-musl@12.4.1':
'@pnpm/exe.linux-x64-musl@12.4.2':
optional: true
'@pnpm/exe.linux-x64@12.4.1':
'@pnpm/exe.linux-x64@12.4.2':
optional: true
'@pnpm/exe.win32-arm64@12.4.1':
'@pnpm/exe.win32-arm64@12.4.2':
optional: true
'@pnpm/exe.win32-x64@12.4.1':
'@pnpm/exe.win32-x64@12.4.2':
optional: true
pnpm@12.4.1:
pnpm@12.4.2:
optionalDependencies:
'@pnpm/exe.android-arm64': 12.4.1
'@pnpm/exe.android-x64': 12.4.1
'@pnpm/exe.darwin-arm64': 12.4.1
'@pnpm/exe.darwin-x64': 12.4.1
'@pnpm/exe.freebsd-x64': 12.4.1
'@pnpm/exe.linux-arm64': 12.4.1
'@pnpm/exe.linux-arm64-musl': 12.4.1
'@pnpm/exe.linux-ppc64': 12.4.1
'@pnpm/exe.linux-riscv64': 12.4.1
'@pnpm/exe.linux-s390x': 12.4.1
'@pnpm/exe.linux-x64': 12.4.1
'@pnpm/exe.linux-x64-musl': 12.4.1
'@pnpm/exe.win32-arm64': 12.4.1
'@pnpm/exe.win32-x64': 12.4.1
'@pnpm/exe.android-arm64': 12.4.2
'@pnpm/exe.android-x64': 12.4.2
'@pnpm/exe.darwin-arm64': 12.4.2
'@pnpm/exe.darwin-x64': 12.4.2
'@pnpm/exe.freebsd-x64': 12.4.2
'@pnpm/exe.linux-arm64': 12.4.2
'@pnpm/exe.linux-arm64-musl': 12.4.2
'@pnpm/exe.linux-ppc64': 12.4.2
'@pnpm/exe.linux-riscv64': 12.4.2
'@pnpm/exe.linux-s390x': 12.4.2
'@pnpm/exe.linux-x64': 12.4.2
'@pnpm/exe.linux-x64-musl': 12.4.2
'@pnpm/exe.win32-arm64': 12.4.2
'@pnpm/exe.win32-x64': 12.4.2
---
lockfileVersion: '9.0'
@ -169,9 +169,12 @@ importers:
'@eslint/js':
specifier: 10.0.1
version: 10.0.1(eslint@10.10.0(supports-color@7.2.0))
'@kuhyx/ts-config':
specifier: link:../ts_config
version: link:../ts_config
'@testing-library/jest-dom':
specifier: 7.0.1
version: 7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.0)
version: 7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.1)
'@testing-library/react':
specifier: 16.3.3
version: 16.3.3(@testing-library/dom@10.4.1)(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
@ -188,8 +191,8 @@ importers:
specifier: 19.3.0
version: 19.3.0(@types/react@19.3.0)
'@vitest/coverage-v8':
specifier: 5.0.0
version: 5.0.0(vitest@5.0.0)
specifier: 5.0.1
version: 5.0.1(vitest@5.0.1)
eslint:
specifier: 10.10.0
version: 10.10.0(supports-color@7.2.0)
@ -209,8 +212,8 @@ importers:
specifier: 8.70.0
version: 8.70.0(eslint@10.10.0(supports-color@7.2.0))(supports-color@7.2.0)(typescript@6.0.3)
vitest:
specifier: 5.0.0
version: 5.0.0(@types/node@26.5.1)(@vitest/coverage-v8@5.0.0)(jsdom@30.0.1)(vite@8.2.2(@types/node@26.5.1))
specifier: 5.0.1
version: 5.0.1(@types/node@26.5.1)(@vitest/coverage-v8@5.0.1)(jsdom@30.0.1)(vite@8.2.2(@types/node@26.5.1))
packages:
@ -372,9 +375,6 @@ packages:
resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==}
engines: {node: '>=6.0.0'}
'@jridgewell/sourcemap-codec@1.5.5':
resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==}
'@jridgewell/sourcemap-codec@1.6.0':
resolution: {integrity: sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==}
@ -615,11 +615,11 @@ packages:
resolution: {integrity: sha512-BoC8PiO4Hkdo0TVJh9Ntxr5MxPDI7/oFsrygN5ADelFSeXG/qgNuucIGA+L5Z6JpPTE/uRfcTWtscjbUaufepQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@vitest/coverage-v8@5.0.0':
resolution: {integrity: sha512-toMg6PZGCIa/lQNCDoASrfb1ly4hsUKXFtFYC9kD4t78o5Y6LyNJU7AENt8eHPr3quYdxaxK7hj2mnbFfUk9NA==}
'@vitest/coverage-v8@5.0.1':
resolution: {integrity: sha512-FRC8ACiudC3dI6MTplzRSYWHDRnIv2IPfbzs4FdoJNsMal/35sWV8hwIfV8ZcqzSPy+uXHeMVONt9CEqtOU17w==}
peerDependencies:
'@vitest/browser': 5.0.0
vitest: 5.0.0
'@vitest/browser': 5.0.1
vitest: 5.0.1
peerDependenciesMeta:
'@vitest/browser':
optional: true
@ -632,8 +632,8 @@ packages:
resolution: {integrity: sha512-1EOLRfsTMnyAr3+kEAsP4o9dhaDlGPpD7H5iLBBeq//YpNB1VIahkPhB+eRp9N2Dkfw8oySROjE3yf9XDeaIkQ==}
engines: {node: '>=22'}
'@vitest/mocker@5.0.0':
resolution: {integrity: sha512-66PGTMIiVJP3t4a5yxU9qPtf7MdTBs8jmToMvy+HVflB3Yy13WJZTtPePdvU+wjRV02SKK5doLbSA6o9pwOmiA==}
'@vitest/mocker@5.0.1':
resolution: {integrity: sha512-6K1DoBNAPGvuOcSsGA4D6x+5zEEff/KmOOP3uetT2TrGpVfI+HRHRnJJfKi5ib/g1vx8IYHQD8s0pbJz8WQI7Q==}
peerDependencies:
msw: ^2.4.9
vite: ^6.0.0 || ^7.0.0 || ^8.0.0
@ -643,8 +643,8 @@ packages:
vite:
optional: true
'@vitest/spy@5.0.0':
resolution: {integrity: sha512-uy+luWBAPw9XfthoHi5AkfHUnuPYEESjl0p/r+meoBnU8bxg5GDQ3Ey8MjcJ6sqahkL4PFyrvfMJJBw7LbU06g==}
'@vitest/spy@5.0.1':
resolution: {integrity: sha512-rbto/mF/SGERxEgYOek7Xm6B9b+y+mVoo+f4b2LymYO8zM1b7uB5nHuhVMTP2hxdzgxvGiZYGxGIaMvL5y180Q==}
acorn-jsx@5.3.2:
resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}
@ -1265,20 +1265,20 @@ packages:
yaml:
optional: true
vitest@5.0.0:
resolution: {integrity: sha512-gpsMNoRhMjMktVxPtstOH4/PJuPyovVaMDr4oDilXaGH1EcqM2OE96SoHT2VIQ6fTGtTjqmHDrEu2X9RQiXf8Q==}
vitest@5.0.1:
resolution: {integrity: sha512-iA95lQbKEkvrtTkdAgnWbXfbipWiiWe/hDl2P5tMi6WFwD76G0NxXAGp/M9EOcYupeGJRr6wppMc7CoA41TQjg==}
engines: {node: ^22.12.0 || ^24.0.0 || >=26.0.0}
hasBin: true
peerDependencies:
'@edge-runtime/vm': '*'
'@opentelemetry/api': ^1.9.0
'@types/node': ^22.0.0 || >=24.0.0
'@vitest/browser-playwright': 5.0.0
'@vitest/browser-preview': 5.0.0
'@vitest/browser-playwright': 5.0.1
'@vitest/browser-preview': 5.0.1
'@vitest/browser-webdriverio': ^5.0.0-beta.5 || >=5.0.0
'@vitest/coverage-istanbul': 5.0.0
'@vitest/coverage-v8': 5.0.0
'@vitest/ui': 5.0.0
'@vitest/coverage-istanbul': 5.0.1
'@vitest/coverage-v8': 5.0.1
'@vitest/ui': 5.0.1
happy-dom: '*'
jsdom: '*'
vite: ^6.4.0 || ^7.0.0 || ^8.0.0
@ -1487,14 +1487,12 @@ snapshots:
'@jridgewell/resolve-uri@3.1.2': {}
'@jridgewell/sourcemap-codec@1.5.5': {}
'@jridgewell/sourcemap-codec@1.6.0': {}
'@jridgewell/trace-mapping@0.3.31':
dependencies:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.5.5
'@jridgewell/sourcemap-codec': 1.6.0
'@keyv/bigmap@1.3.1(keyv@5.6.0)':
dependencies:
@ -1564,7 +1562,7 @@ snapshots:
picocolors: 1.1.1
pretty-format: 27.5.1
'@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.0)':
'@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.1)':
dependencies:
'@adobe/css-tools': 4.5.0
'@testing-library/dom': 10.4.1
@ -1574,7 +1572,7 @@ snapshots:
picocolors: 1.1.1
redent: 3.0.0
optionalDependencies:
vitest: 5.0.0(@types/node@26.5.1)(@vitest/coverage-v8@5.0.0)(jsdom@30.0.1)(vite@8.2.2(@types/node@26.5.1))
vitest: 5.0.1(@types/node@26.5.1)(@vitest/coverage-v8@5.0.1)(jsdom@30.0.1)(vite@8.2.2(@types/node@26.5.1))
'@testing-library/react@16.3.3(@testing-library/dom@10.4.1)(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)':
dependencies:
@ -1708,7 +1706,7 @@ snapshots:
'@typescript-eslint/types': 8.70.0
eslint-visitor-keys: 5.0.1
'@vitest/coverage-v8@5.0.0(vitest@5.0.0)':
'@vitest/coverage-v8@5.0.1(vitest@5.0.1)':
dependencies:
'@bcoe/v8-coverage': 1.0.2
'@vitest/istanbul-lib-coverage': 1.0.1
@ -1718,7 +1716,7 @@ snapshots:
obug: 2.1.4
std-env: 4.2.0
tinyrainbow: 3.1.1
vitest: 5.0.0(@types/node@26.5.1)(@vitest/coverage-v8@5.0.0)(jsdom@30.0.1)(vite@8.2.2(@types/node@26.5.1))
vitest: 5.0.1(@types/node@26.5.1)(@vitest/coverage-v8@5.0.1)(jsdom@30.0.1)(vite@8.2.2(@types/node@26.5.1))
'@vitest/istanbul-lib-coverage@1.0.1': {}
@ -1726,16 +1724,16 @@ snapshots:
dependencies:
'@vitest/istanbul-lib-coverage': 1.0.1
'@vitest/mocker@5.0.0(vite@8.2.2(@types/node@26.5.1))':
'@vitest/mocker@5.0.1(vite@8.2.2(@types/node@26.5.1))':
dependencies:
'@jridgewell/trace-mapping': 0.3.31
'@vitest/spy': 5.0.0
'@vitest/spy': 5.0.1
estree-walker: 3.0.3
magic-string: 1.3.1
optionalDependencies:
vite: 8.2.2(@types/node@26.5.1)
'@vitest/spy@5.0.0': {}
'@vitest/spy@5.0.1': {}
acorn-jsx@5.3.2(acorn@8.18.0):
dependencies:
@ -2283,10 +2281,10 @@ snapshots:
'@types/node': 26.5.1
fsevents: 2.3.3
vitest@5.0.0(@types/node@26.5.1)(@vitest/coverage-v8@5.0.0)(jsdom@30.0.1)(vite@8.2.2(@types/node@26.5.1)):
vitest@5.0.1(@types/node@26.5.1)(@vitest/coverage-v8@5.0.1)(jsdom@30.0.1)(vite@8.2.2(@types/node@26.5.1)):
dependencies:
'@types/chai': 5.2.3
'@vitest/mocker': 5.0.0(vite@8.2.2(@types/node@26.5.1))
'@vitest/mocker': 5.0.1(vite@8.2.2(@types/node@26.5.1))
chai: 6.2.2
es-module-lexer: 2.3.2
expect-type: 1.4.0
@ -2301,7 +2299,7 @@ snapshots:
why-is-node-running: 2.3.0
optionalDependencies:
'@types/node': 26.5.1
'@vitest/coverage-v8': 5.0.0(vitest@5.0.0)
'@vitest/coverage-v8': 5.0.1(vitest@5.0.1)
jsdom: 30.0.1
transitivePeerDependencies:
- msw

View File

@ -5,5 +5,6 @@
* `import "@kuhyx/web-ui/tokens.css";`
*/
export { clamp01, fractionFromPointer, nth, quantileValue, valueQuantile } from "./quantile.ts";
export { RangeSlider, steppedValue, type RangeSliderProps } from "./range-slider.tsx";
export { RangeSlider, type RangeSliderProps } from "./range-slider.tsx";
export { keyTarget, steppedValue } from "./stepped-value.ts";
export { fuzzyMatch } from "./text.ts";

View File

@ -55,8 +55,7 @@ export function quantileValue(sorted: readonly number[], f: number): number {
*/
export function valueQuantile(sorted: readonly number[], value: number): number {
const n = sorted.length;
if (n <= 1) return 0;
if (value <= nth(sorted, 0)) return 0;
if ((n <= 1) || (value <= nth(sorted, 0))) return 0;
if (value >= nth(sorted, n - 1)) return 1;
// value strictly inside the range, so there is an index hi >= 1 with
// sorted[hi] >= value and sorted[hi - 1] < value.

View File

@ -1,7 +1,7 @@
import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { RangeSlider, steppedValue } from "./range-slider.tsx";
import { RangeSlider } from "./range-slider.tsx";
/** Ten evenly spaced values, so a quantile fraction maps to a predictable value. */
const VALUES = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90];
@ -29,63 +29,6 @@ function thumbs(): HTMLElement[] {
return screen.getAllByRole("slider");
}
describe("steppedValue", () => {
it("advances one sample at a time", () => {
expect(steppedValue(VALUES, 30, 1)).toBe(40);
});
it("moves backwards for a negative delta", () => {
expect(steppedValue(VALUES, 30, -1)).toBe(20);
});
it("clamps at the top", () => {
expect(steppedValue(VALUES, 90, 5)).toBe(90);
});
it("clamps at the bottom", () => {
expect(steppedValue(VALUES, 0, -5)).toBe(0);
});
it("rounds a between-samples value to a real sample", () => {
expect(steppedValue(VALUES, 34, 1)).toBe(40);
});
it("returns the current sample for a zero delta", () => {
expect(steppedValue(VALUES, 30, 0)).toBe(30);
});
describe("on a lumpy distribution", () => {
// The shape that actually broke in the browser: awesome-mcp-explorer's
// star counts hold ~1500 duplicate zeros, so an index step inside the run
// moved the index but not the value, and the arrow key looked dead.
const LUMPY = [...Array.from({ length: 50 }, () => 0), 5, 5, 5, 100, 5000];
it("escapes a run of duplicates instead of stalling", () => {
expect(steppedValue(LUMPY, 0, 1)).toBe(5);
});
it("keeps stepping past the second run", () => {
expect(steppedValue(LUMPY, 5, 1)).toBe(100);
});
it("steps back out of a run", () => {
expect(steppedValue(LUMPY, 5, -1)).toBe(0);
});
it("counts distinct values for a multi-step jump", () => {
expect(steppedValue(LUMPY, 0, 2)).toBe(100);
});
it("clamps at the top rather than running off the end", () => {
expect(steppedValue(LUMPY, 5000, 1)).toBe(5000);
});
it("clamps at the bottom", () => {
expect(steppedValue(LUMPY, 0, -1)).toBe(0);
});
});
});
describe("RangeSlider", () => {
it("renders nothing when there is nothing to range over", () => {
const { container } = render(<RangeSlider hi={1} lo={1} onChange={vi.fn()} values={[1]} />);

View File

@ -22,6 +22,7 @@
import { useCallback, useState } from "react";
import { fractionFromPointer, nth, quantileValue, valueQuantile } from "./quantile.ts";
import { keyTarget } from "./stepped-value.ts";
export interface RangeSliderProps {
/**
@ -44,40 +45,6 @@ export interface RangeSliderProps {
type Thumb = "hi" | "lo";
/**
* Steps one thumb by `delta` positions through the distribution. Pure, so the
* keyboard contract is testable without layout.
*
* Steps to the next *distinct* value rather than the next index. Real
* distributions are lumpy -- awesome-mcp-explorer's star counts hold ~1500
* duplicate zeros -- and an index step inside a run of equal values changes the
* index while leaving the value (and therefore the thumb, and the filter)
* exactly where it was. That reads as a dead arrow key.
*/
export function steppedValue(
values: readonly number[],
current: number,
delta: number,
): number {
const last = values.length - 1;
// Round to a real sample index so a thumb sitting between two samples still
// advances rather than stalling on a fractional step.
const index = Math.round(valueQuantile(values, current) * last);
const direction = Math.sign(delta);
if (direction === 0) return nth(values, index);
let cursor = index;
for (let taken = 0; taken < Math.abs(delta); taken++) {
let next = cursor + direction;
while (next >= 0 && next <= last && nth(values, next) === nth(values, cursor)) {
next += direction;
}
if (next < 0 || next > last) break;
cursor = next;
}
return nth(values, cursor);
}
export function RangeSlider({
format,
hi,
@ -86,7 +53,7 @@ export function RangeSlider({
onChange,
values,
}: RangeSliderProps): null | React.JSX.Element {
const [drag, setDrag] = useState<Thumb | null>(null);
const [drag, setDrag] = useState<null | Thumb>(null);
const apply = useCallback(
(thumb: Thumb, value: number): void => {
@ -100,29 +67,20 @@ export function RangeSlider({
// handlers are bound to the track, so currentTarget *is* the track. A ref
// would add a null branch that cannot happen once the element is mounted.
const valueAt = useCallback(
(track: HTMLElement, clientX: number): number =>
quantileValue(values, fractionFromPointer(track.getBoundingClientRect(), clientX)),
(track: HTMLElement, clientX: number): number => {
const fraction = fractionFromPointer(track.getBoundingClientRect(), clientX);
return quantileValue(values, fraction);
},
[values],
);
const onKeyDown = useCallback(
(thumb: Thumb, event: React.KeyboardEvent): void => {
const current = thumb === "lo" ? lo : hi;
const step = (delta: number): void => {
event.preventDefault();
apply(thumb, steppedValue(values, current, delta));
};
if (event.key === "ArrowLeft" || event.key === "ArrowDown") step(-1);
else if (event.key === "ArrowRight" || event.key === "ArrowUp") step(1);
else if (event.key === "PageDown") step(-10);
else if (event.key === "PageUp") step(10);
else if (event.key === "Home") {
event.preventDefault();
apply(thumb, nth(values, 0));
} else if (event.key === "End") {
event.preventDefault();
apply(thumb, nth(values, values.length - 1));
}
const target = keyTarget(event.key, values, current);
if (target === undefined) return;
event.preventDefault();
apply(thumb, target);
},
[apply, hi, lo, values],
);
@ -136,19 +94,21 @@ export function RangeSlider({
const hiFraction = valueQuantile(values, hi) * 100;
const name = label ?? "Range";
const thumbProps = (thumb: Thumb): React.ComponentProps<"button"> => ({
"aria-valuemax": highest,
"aria-valuemin": lowest,
"aria-valuenow": thumb === "lo" ? lo : hi,
className: `slider-thumb slider-${thumb}`,
onKeyDown: (event): void => {
onKeyDown(thumb, event);
},
role: "slider",
style: { left: `${String(thumb === "lo" ? loFraction : hiFraction)}%` },
tabIndex: 0,
type: "button",
});
const thumbProps = (thumb: Thumb): React.ComponentProps<"button"> => {
return {
"aria-valuemax": highest,
"aria-valuemin": lowest,
"aria-valuenow": thumb === "lo" ? lo : hi,
className: `slider-thumb slider-${thumb}`,
onKeyDown: (event): void => {
onKeyDown(thumb, event);
},
role: "slider",
style: { left: `${String(thumb === "lo" ? loFraction : hiFraction)}%` },
tabIndex: 0,
type: "button",
};
};
return (
<div className="slider">

View File

@ -0,0 +1,79 @@
import { describe, expect, it } from "vitest";
import { keyTarget, steppedValue } from "./stepped-value.ts";
/** Ten evenly spaced values, so a quantile fraction maps to a predictable value. */
const VALUES = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90];
describe("keyTarget", () => {
it("leaves keys the slider does not own to the browser", () => {
expect(keyTarget("Tab", VALUES, 30)).toBeUndefined();
expect(keyTarget("a", VALUES, 30)).toBeUndefined();
});
it("maps every owned key onto the distribution", () => {
expect(keyTarget("ArrowLeft", VALUES, 30)).toBe(20);
expect(keyTarget("ArrowDown", VALUES, 30)).toBe(20);
expect(keyTarget("ArrowRight", VALUES, 30)).toBe(40);
expect(keyTarget("ArrowUp", VALUES, 30)).toBe(40);
expect(keyTarget("Home", VALUES, 30)).toBe(0);
expect(keyTarget("End", VALUES, 30)).toBe(90);
});
});
describe("steppedValue", () => {
it("advances one sample at a time", () => {
expect(steppedValue(VALUES, 30, 1)).toBe(40);
});
it("moves backwards for a negative delta", () => {
expect(steppedValue(VALUES, 30, -1)).toBe(20);
});
it("clamps at the top", () => {
expect(steppedValue(VALUES, 90, 5)).toBe(90);
});
it("clamps at the bottom", () => {
expect(steppedValue(VALUES, 0, -5)).toBe(0);
});
it("rounds a between-samples value to a real sample", () => {
expect(steppedValue(VALUES, 34, 1)).toBe(40);
});
it("returns the current sample for a zero delta", () => {
expect(steppedValue(VALUES, 30, 0)).toBe(30);
});
describe("on a lumpy distribution", () => {
// The shape that actually broke in the browser: awesome-mcp-explorer's
// star counts hold ~1500 duplicate zeros, so an index step inside the run
// moved the index but not the value, and the arrow key looked dead.
const LUMPY = [...Array.from({ length: 50 }, () => 0), 5, 5, 5, 100, 5000];
it("escapes a run of duplicates instead of stalling", () => {
expect(steppedValue(LUMPY, 0, 1)).toBe(5);
});
it("keeps stepping past the second run", () => {
expect(steppedValue(LUMPY, 5, 1)).toBe(100);
});
it("steps back out of a run", () => {
expect(steppedValue(LUMPY, 5, -1)).toBe(0);
});
it("counts distinct values for a multi-step jump", () => {
expect(steppedValue(LUMPY, 0, 2)).toBe(100);
});
it("clamps at the top rather than running off the end", () => {
expect(steppedValue(LUMPY, 5000, 1)).toBe(5000);
});
it("clamps at the bottom", () => {
expect(steppedValue(LUMPY, 0, -1)).toBe(0);
});
});
});

View File

@ -0,0 +1,78 @@
/**
* The keyboard contract of the range slider, kept pure and in its own module
* so range-slider.tsx exports only the component (react-refresh needs that
* for HMR to keep working) and the contract is testable without layout.
*/
import { nth, valueQuantile } from "./quantile.ts";
/**
* Steps one thumb by `delta` positions through the distribution. Pure, so the
* keyboard contract is testable without layout.
*
* Steps to the next *distinct* value rather than the next index. Real
* distributions are lumpy -- awesome-mcp-explorer's star counts hold ~1500
* duplicate zeros -- and an index step inside a run of equal values changes the
* index while leaving the value (and therefore the thumb, and the filter)
* exactly where it was. That reads as a dead arrow key.
*/
export function steppedValue(
values: readonly number[],
current: number,
delta: number,
): number {
const last = values.length - 1;
// Round to a real sample index so a thumb sitting between two samples still
// advances rather than stalling on a fractional step.
const index = Math.round(valueQuantile(values, current) * last);
const direction = Math.sign(delta);
if (direction === 0) return nth(values, index);
let cursor = index;
for (let taken = 0; taken < Math.abs(delta); taken++) {
let next = cursor + direction;
while (next >= 0 && next <= last && nth(values, next) === nth(values, cursor)) {
next += direction;
}
if (next < 0 || next > last) break;
cursor = next;
}
return nth(values, cursor);
}
/**
* The value a thumb at `current` moves to for a key, or `undefined` when the
* key is not one the slider handles (so the event is left to the browser).
* Arrow keys step one distinct value, Page keys ten, Home/End jump to the
* bounds.
*/
export function keyTarget(
key: string,
values: readonly number[],
current: number,
): number | undefined {
switch (key) {
case "ArrowDown":
case "ArrowLeft": {
return steppedValue(values, current, -1);
}
case "ArrowRight":
case "ArrowUp": {
return steppedValue(values, current, 1);
}
case "End": {
return nth(values, values.length - 1);
}
case "Home": {
return nth(values, 0);
}
case "PageDown": {
return steppedValue(values, current, -10);
}
case "PageUp": {
return steppedValue(values, current, 10);
}
default: {
return undefined;
}
}
}

View File

@ -13,7 +13,7 @@ const TRACK_WIDTH = 1000;
if (hasDom) {
Object.defineProperty(Element.prototype, "getBoundingClientRect", {
configurable: true,
value(): DOMRect {
value: (): DOMRect => {
return {
bottom: 20,
height: 20,

View File

@ -1,6 +1,5 @@
// @vitest-environment node
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const css = readFileSync(new URL("tokens.css", import.meta.url), "utf8");
@ -13,9 +12,10 @@ const css = readFileSync(new URL("tokens.css", import.meta.url), "utf8");
*/
function declared(name: string): string[] {
return [...css.matchAll(new RegExp(`--${name}:\\s*([^;]+);`, "g"))].map((m) =>
(m[1] ?? "").trim(),
);
return css
.matchAll(new RegExp(String.raw`--${name}:\s*([^;]+);`, "g"))
.map((m) => (m[1] ?? "").trim())
.toArray();
}
describe("tokens.css", () => {
@ -124,7 +124,7 @@ describe("tokens.css", () => {
const block = /@media \(prefers-reduced-motion: reduce\)\s*\{([\s\S]*?)\n\}/.exec(css)?.[1];
expect(block).toBeDefined();
for (const step of ["fast", "base", "slow"]) {
expect(block).toMatch(new RegExp(`--duration-${step}:\\s*0ms;`));
expect(block).toMatch(new RegExp(String.raw`--duration-${step}:\s*0ms;`));
}
});

View File

@ -1,4 +1,6 @@
{
// Strictness comes from the shared base; only output/lib options live here.
"extends": "@kuhyx/ts-config/tsconfig",
"compilerOptions": {
"target": "ES2023",
"lib": ["ESNext", "DOM", "DOM.Iterable"],
@ -7,20 +9,6 @@
"jsx": "react-jsx",
"types": ["vitest/globals"],
/* Strictness: everything on, matching both consumers so a file that
compiles here compiles there. */
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"exactOptionalPropertyTypes": true,
"useUnknownInCatchVariables": true,
"verbatimModuleSyntax": true,
"isolatedModules": true,
"erasableSyntaxOnly": true,
/* This package ships a prebuilt dist/ (ESM + .d.ts) because consumers use
Vite, which does not transpile dependencies. So unlike the consumers,
@ -31,10 +19,7 @@
"declarationMap": true,
"sourceMap": true,
"outDir": "dist",
"rootDir": "src",
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
"rootDir": "src"
},
"include": ["src"],
"exclude": ["src/**/*.test.ts", "src/**/*.test.tsx", "src/test"]