diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn new file mode 100644 index 0000000..e46f7aa --- /dev/null +++ b/.clj-kondo/config.edn @@ -0,0 +1,109 @@ +{:linters + {:aliased-namespace-symbol {:level :error} + :aliased-namespace-var-usage {:level :error} + :aliased-referred-var {:level :error} + :case-quoted-test {:level :error} + :case-symbol-test {:level :error} + :clj-kondo-config {:level :error} + :cond-else {:level :error} + :condition-always-true {:level :error} + :consistent-alias {:level :error + :aliases {clojure.edn edn + clojure.set set + clojure.spec.alpha s + clojure.spec.gen.alpha gen + clojure.string str + clojure.test t}} + :def-fn {:level :error} + :deprecated-namespace {:level :error} + :deprecated-var {:level :error} + :destructured-or-always-evaluates {:level :error} + :destructured-or-binding-of-same-map {:level :error} + :discouraged-java-method {:level :error} + :discouraged-namespace {:level :error} + :discouraged-tag {:level :error} + :discouraged-var {:level :error} + :do-template {:level :error} + :docstring-leading-trailing-whitespace {:level :error} + :docstring-no-summary {:level :error} + :duplicate-key-args {:level :error} + :duplicate-refer {:level :error} + :earmuffed-var-not-dynamic {:level :error} + :equals-expected-position {:level :error + :position :first} + :equals-false {:level :error} + :equals-float {:level :error} + :equals-nil {:level :error} + :equals-true {:level :error} + :if-nil-return {:level :error} + :inline-def {:level :error} + :is-message-not-string {:level :error} + :keyword-binding {:level :error} + :line-length {:level :error + :max-line-length 120} + :locking-suspicious-lock {:level :error} + :loop-without-recur {:level :error} + :main-without-gen-class {:level :error} + :min-clj-kondo-version {:level :error} + :minus-one {:level :error} + :missing-body-in-when {:level :error} + :missing-clause-in-try {:level :error} + :missing-docstring {:level :error} + :missing-else-branch {:level :error} + :missing-protocol-method {:level :error} + :missing-test-assertion {:level :error} + :multiple-async-in-deftest {:level :error} + :non-arg-vec-return-type-hint {:level :error} + :not-empty? {:level :error} + :plus-one {:level :error} + :reduce-without-init {:level :error} + :redundant-call {:level :error} + :redundant-do {:level :error} + :redundant-expression {:level :error} + :redundant-fn-wrapper {:level :error} + :redundant-format {:level :error} + :redundant-ignore {:level :error} + :redundant-let {:level :error} + :redundant-let-binding {:level :error} + :redundant-nested-call {:level :error} + :redundant-primitive-coercion {:level :error} + :redundant-str-call {:level :error} + :refer {:level :error} + :refer-all {:level :error} + :redefined-var {:level :error} + :schema-misplaced-return {:level :error} + :self-requiring-namespace {:level :error} + :shadowed-fn-param {:level :error} + :shadowed-var {:level :error} + :single-key-in {:level :error} + :single-logical-operand {:level :error} + :single-operand-comparison {:level :error} + :underscore-in-namespace {:level :error} + :unbound-destructuring-default {:level :error} + :uninitialized-var {:level :error} + :unreachable-code {:level :error} + :unresolved-excluded-var {:level :error} + :unresolved-namespace {:level :error} + :unresolved-protocol-method {:level :error} + :unresolved-var {:level :error} + :unquote-not-syntax-quoted {:level :error} + :unsorted-imports {:level :error} + :unsorted-required-namespaces {:level :error + :sort :case-insensitive} + :unused-alias {:level :error} + :unused-binding {:level :error + :exclude-destructured-keys-in-fn-args false + :exclude-destructured-as false + :exclude-defmulti-args false} + :unused-excluded-var {:level :error} + :unused-import {:level :error} + :unused-namespace {:level :error + :simple-libspec false} + :unused-private-var {:level :error} + :unused-referred-var {:level :error} + :unused-value {:level :error} + :use {:level :error} + :used-underscored-binding {:level :error} + :var-same-name-except-case {:level :error} + :warn-on-reflection {:level :error + :warn-only-on-interop true}}} diff --git a/.cljstyle b/.cljstyle index 7d18cfb..0dba930 100644 --- a/.cljstyle +++ b/.cljstyle @@ -1,6 +1,6 @@ {:files {:pattern #"\.(clj[cs]?|edn|cljstyle)$" - :ignore #{".git" "target" "node_modules" #"\.clj-kondo/(?!config\.edn).*"}} + :ignore #{".git" ".cljs_node_repl" "target" "node_modules" #"\.clj-kondo/(?!config\.edn).*"}} :rules {:blank-lines {:padding-lines 1} :indentation {:indents {s/fdef [[:inner 0]]}}}} diff --git a/.github/workflows/clojure.yml b/.github/workflows/clojure.yml index a9d4dd3..695e857 100644 --- a/.github/workflows/clojure.yml +++ b/.github/workflows/clojure.yml @@ -7,38 +7,50 @@ on: branches: ["main"] merge_group: +permissions: + contents: read + +# Regular dependency updates must be at least 14 days old. These runtime pins +# include urgent October 2026 security fixes for compromised eMudhra CAs: +# https://nodejs.org/en/blog/release/v24.22.1/ +# https://adoptium.net/news/2026/10/temurin-october-2026-emudhra/ +# https://www.python.org/downloads/release/python-31410/ +# setup-python 7.1.0 also fixes bundled downloader dependencies: +# https://github.com/actions/setup-python/pull/1347 +# https://github.com/actions/setup-python/pull/1350 + jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + + env: + PIP_CONSTRAINT: ${{ github.workspace }}/requirements.txt + PIP_BUILD_CONSTRAINT: ${{ github.workspace }}/requirements.txt steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 name: Check out repository - - uses: actions/setup-node@v4 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 name: Set up Node with: - node-version: lts/* + node-version: "24.22.1" cache: npm - - uses: actions/setup-java@v4 + - uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0 name: Set up Java with: distribution: temurin - java-version: 11 - - uses: actions/setup-python@v4 + java-version: "21.0.13+9" + - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 name: Set up Python with: - python-version: 3.12 + python-version: "3.14.10" cache: pip - - uses: actions/cache@v3 + - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 name: pre-commit cache with: path: ~/.cache/pre-commit - key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} - - name: Docker cache - uses: ScribeMD/docker-cache@0.3.6 - with: - key: ${{ runner.os }}-docker-${{ hashFiles('.pre-commit-config.yaml') }} - - uses: actions/cache@v3 + key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml', 'requirements.txt', '.github/workflows/clojure.yml') }} + - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 name: Clojure cache with: path: | @@ -47,19 +59,80 @@ jobs: ~/.clojure ~/.cpcache key: ${{ runner.os }}-clojure-${{ hashFiles('deps.edn') }} - - name: Install Clojure - run: | - curl -L -O https://github.com/clojure/brew-install/releases/latest/download/posix-install.sh - chmod +x posix-install.sh - sudo ./posix-install.sh - rm posix-install.sh + - name: Install Clojure tools + uses: DeLaGuardo/setup-clojure@6d46099eae24853c33c0482f2bb54edf4f1a4c74 # 13.7.0 + with: + cli: "1.12.6.1673" + - name: Install npm dependencies + run: npm ci --ignore-scripts - name: Run pre-commit hooks run: | pip install -r requirements.txt - pre-commit run --all-files - - name: Run clj tests - run: bin/test clj - - name: Run cljs tests + SKIP=kaocha-test pre-commit run --all-files + - name: Run tests + run: bin/kaocha + - name: Run benchmarks run: | - npm install - bin/test cljs + bin/benchmark + bin/benchmark-node + - name: Upload coverage artifact + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: coverage-report + path: target/coverage + if-no-files-found: warn + - name: Upload JUnit XML artifact + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: junit-xml + path: target/test-results/junit.xml + if-no-files-found: warn + + spec-parity: + runs-on: ubuntu-24.04 + + env: + SQIDS_SPEC_DIR: ${{ github.workspace }}/target/sqids-spec + + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + name: Check out repository + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + name: Check out sqids-spec + with: + repository: sqids/sqids-spec + ref: 49b8ad8ea0725ee79c374ceb098cf100b52b0ec5 # 2025-01-03 + path: target/sqids-spec + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + name: Set up Node + with: + node-version: "24.22.1" + cache: npm + cache-dependency-path: | + package-lock.json + target/sqids-spec/package-lock.json + - uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0 + name: Set up Java + with: + distribution: temurin + java-version: "21.0.13+9" + - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + name: Clojure cache + with: + path: | + ~/.m2/repository + ~/.gitlibs + ~/.clojure + ~/.cpcache + key: ${{ runner.os }}-clojure-${{ hashFiles('deps.edn') }} + - name: Install Clojure tools + uses: DeLaGuardo/setup-clojure@6d46099eae24853c33c0482f2bb54edf4f1a4c74 # 13.7.0 + with: + cli: "1.12.6.1673" + - name: Install sqids-spec dependencies + working-directory: target/sqids-spec + run: npm ci --ignore-scripts + - name: Run sqids-spec parity + run: bin/parity diff --git a/.gitignore b/.gitignore index 6172e3a..e455879 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -*.class *.iml +*.class +*.iml *.jar *.log *.swp @@ -7,13 +8,19 @@ .calva/output-window/ .classpath .clj-kondo/.cache +.cljs_node_repl/ .cpcache +.cpcache/ .eastwood .factorypath .hg/ .hgignore .idea .lein-* +.lein-deps-sum +.lein-failures +.lein-plugins/ +.lein-repl-history .lsp/.cache .lsp/sqlite.db .nrepl-* @@ -26,11 +33,17 @@ .shadow-cljs .socket-repl-port .sw* +.venv/ .vscode /checkouts +/checkouts/ /classes +/classes/ +/lib/ +/out /src/gen /target +/target/ Brewfile.lock.json cljs-test-runner-out/ node_modules/ diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml new file mode 100644 index 0000000..74e68e0 --- /dev/null +++ b/.markdownlint-cli2.yaml @@ -0,0 +1,5 @@ +--- +config: + MD013: false +ignores: + - node_modules/** diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..2ef8e73 --- /dev/null +++ b/.npmrc @@ -0,0 +1,4 @@ +engine-strict=true +ignore-scripts=true +min-release-age=14 +save-exact=true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 106dc15..bda6eb5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,38 +1,52 @@ repos: - - repo: https://github.com/clj-kondo/clj-kondo - rev: v2023.10.20 - hooks: - - id: clj-kondo-docker - pass_filenames: false - require_serial: true - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # v6.0.0 hooks: - id: check-shebang-scripts-are-executable - id: trailing-whitespace - id: end-of-file-fixer - id: check-added-large-files - repo: https://github.com/scop/pre-commit-shfmt - rev: v3.7.0-4 + rev: 479be5958357ba5ab65ce47172117348516860e9 # v3.14.1-1 hooks: - - id: shfmt-docker - entry: mvdan/shfmt:v3.7.0 + - id: shfmt args: [-w, -s, -i, "2"] - - repo: https://github.com/koalaman/shellcheck-precommit - rev: v0.9.0 - hooks: - - id: shellcheck - repo: local hooks: + - id: shellcheck + name: ShellCheck v0.11.0 + entry: shellcheck + language: python + additional_dependencies: ["shellcheck-py==0.11.0.1"] + types: [shell] + - id: clj-kondo + name: clj-kondo + entry: clojure -M:clj-kondo --lint src test dev bin/update-blocklist build.clj deps.edn tests.edn shadow-cljs.edn + language: system + pass_filenames: false + require_serial: true - id: cljstyle name: cljstyle - entry: bin/_cljstyle fix + entry: clojure -M:cljstyle fix language: system types: [file] + - id: kaocha-test + name: kaocha-test + entry: bin/kaocha + language: system + pass_filenames: false + always_run: true + require_serial: true + - id: markdownlint-cli2 + name: markdownlint-cli2 + language: system + entry: npm exec --no -- markdownlint-cli2 + types: [markdown] + args: ["--config", ".markdownlint-cli2.yaml", "--fix"] - id: prettier name: prettier - language: docker_image - entry: tmknom/prettier + language: system + entry: npm exec --no -- prettier types: [text] args: [--write, --list-different, --ignore-unknown] - id: git-diff diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..99ad8c8 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,51 @@ +# Repository Guidelines + +## Layout and contracts + +- Runtime and public API live in `src/org/sqids/clojure.cljc`. Keep implementation + helpers private. Behavior tests live in `test/org/sqids/clojure_test.cljc`; + the differential parity harness remains under `test/org/sqids/clojure/`. +- `sqids` validates an options map once and returns a non-associative `deftype` + instance directly. `encode` and `decode` require that instance and reject raw + options or wrapper maps. Keep options separately and reconstruct to change + settings; the instance's fields are implementation details. +- Keep runtime code dependency-free and focused on the algorithm. Test generators + and reference implementations belong under `test/`, benchmarks under `dev/`. +- Use ordinary return values and `ex-info` for errors. Do not add result-envelope + frameworks, metadata caches, or automatic configuration compilation on calls. +- Prefer simple Clojure. Use private mutable buffers only when measurement shows + a benefit; never mutate shared configuration or caller-owned values. +- Preserve arbitrary JVM integers and the ClojureScript safe-integer boundary. +- `resources/org/sqids/clojure/blocklist.json` is generated by + `bin/update-blocklist`. Missing bundled data must fail clearly. + +## Verification + +- `bin/kaocha`: JVM and ClojureScript tests. `tests.edn` owns suite/report settings. +- Test public behavior with known vectors, deterministic properties, invalid + inputs, and relevant regressions. Avoid tests that only mirror implementation. +- Coverage includes algorithm loops, with a 90% minimum. Do not hide executable + code from coverage or contort algorithms just to reach 100%. +- `SQIDS_SPEC_DIR=/path/to/sqids-spec bin/parity`: compare both runtimes with the + upstream TypeScript implementation in the shared safe-integer domain. Compile + the Node runner with advanced optimization and inferred externs. +- `bin/benchmark`: allocation budgets for ordinary, multi-digit, and bigint + inputs, plus many-number allocation scaling. +- `bin/benchmark-node`: advanced-compiled Node timings with default and empty + blocklists. Compare latency on the same runtime/hardware; do not gate CI on + noisy timings. +- `pre-commit run --all-files`: formatting, lint, shell checks, and tests. + CI runs hooks with `SKIP=kaocha-test`, then runs the tests separately. +- Run formatting before tests; changing source during coverage invalidates reports. + +## Maintenance + +- Follow `.cljstyle` and `.clj-kondo/config.edn`; document public contracts and + non-obvious helpers. Keep scripts executable and dependencies pinned. +- Keep README examples, CHANGELOG, and CI commands synchronized with behavior. +- Select stable dependency releases at least 14 days old; document security-fix + exceptions with upstream evidence. Keep npm and Python transitive pins, CI + tool versions, and action SHAs synchronized. Preserve the npm release-age + gate and Python constraints when updating or running hooks. +- Prefer focused changes. Describe the problem, resulting behavior, and validation + in PRs, with short imperative commit subjects. diff --git a/Brewfile b/Brewfile index f9b60e1..2028709 100644 --- a/Brewfile +++ b/Brewfile @@ -1,9 +1,6 @@ # frozen_string_literal: true -tap 'borkdude/brew' +tap 'babashka/brew' -brew 'borkdude/brew/clj-kondo' +brew 'babashka/brew/babashka' brew 'clojure' -brew 'pre-commit' - -cask 'cljstyle' diff --git a/CHANGELOG.md b/CHANGELOG.md index a5bb9fd..cd8cfd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # CHANGELOG -**v1.0.15**: +## Unreleased + +## v1.1.0 + +- Updated development dependencies, compilers, build tools, and CI actions using + a 14-day release-age window, with documented security exceptions. Pinned CI + actions and toolchains, locked formatter dependencies, and constrained Python + hook dependencies. +- Replaced Java/JavaScript runtime wrappers with a shared Clojure/ClojureScript + implementation in `org.sqids.clojure`, with private implementation helpers and + a bundled default blocklist. +- Changed `sqids` to return a reusable, non-associative `deftype` instance + directly instead of a configuration map containing `:instance`. Pass that + instance to `encode` and `decode`; keep options separately and construct a new + instance to change settings. Raw options and wrapper maps are rejected. +- Added arbitrary-size JVM integer support and safe-integer checks on JavaScript + encoding and decoding. +- Used per-call buffers and cursor-based decoding for linear allocation growth + in the number of encoded values. Prefix assembly shares the buffer operations + across JVM and JavaScript. +- Added advanced-compiled ClojureScript reference parity, public API properties, + allocation budgets covering multi-digit and bigint inputs, and Node benchmarks. +- Consolidated behavior tests and generators into `org.sqids.clojure-test`. +- Missing bundled blocklist data now fails clearly instead of disabling filtering. + +## v1.0.15 - Initial implementation diff --git a/README.md b/README.md index 336208d..497d29a 100644 --- a/README.md +++ b/README.md @@ -7,32 +7,27 @@ YouTube-looking IDs from numbers. It's good for link shortening, fast & URL-safe ID generation and decoding back into numbers for quicker database lookups. -`sqids-clojure` supports both Clojure and ClojureScript! In a Clojure -environment, `sqids-clojure` wraps -[`sqids-java`](https://github.com/sqids/sqids-java). In a ClojureScript -environment, `sqids-clojure` wraps -[`sqids-javascript`](https://github.com/sqids/sqids-javascript). - -If you notice any issues with decoding or encoding, these are likely an issue in -the upstream wrapped Sqids library. +`sqids-clojure` supports both Clojure and ClojureScript with a shared pure +implementation in this repository. ## Getting started [CLI/`deps.edn`](https://clojure.org/reference/deps_and_cli) dependency -information: +information (replace with the latest version from +[Clojars](https://clojars.org/org.sqids/sqids-clojure)): ```clojure ;; maven -org.sqids/sqids-clojure {:mvn/version "1.0.15"} +org.sqids/sqids-clojure {:mvn/version "1.1.0"} ``` [Leiningen](https://leiningen.org/) dependency information: ```clojure -[org.sqids/sqids-clojure "1.0.15"] +[org.sqids/sqids-clojure "1.1.0"] ``` -After installation, require `sqids-clojure`: +After installation, require the `org.sqids.clojure` namespace: ```clojure (require '[org.sqids.clojure :as sqids]) @@ -53,6 +48,29 @@ Simple encode & decode: (sqids/decode sqids id)) ; [1 2 3] ``` +Create an instance once and reuse it. `sqids` validates an options map and returns +a non-associative `deftype` instance, which `encode` and `decode` accept directly. +Keep your options separately if you need to serialize them or construct another +instance with different settings: + +```clojure +(def options {:block-list #{}}) +(def unfiltered (sqids/sqids options)) +(def padded (sqids/sqids (assoc options :min-length 10))) +``` + +The instance does not support `assoc`; its fields are implementation details. +Serialize the options map, not the instance. This changes the previous map return +type: remove `:instance` lookups and pass the constructor's result directly to +`encode` and `decode`. Raw options and maps wrapping an instance are rejected. + +Inputs must be sequential collections of non-negative integers. The JVM supports +arbitrary-size integers; ClojureScript supports integers up to +`Number.MAX_SAFE_INTEGER` (9,007,199,254,740,991). Decoding returns `[]` for IDs +containing characters outside the alphabet, or values outside the ClojureScript +safe-integer range. Invalid argument types and exhausted blocklist retries throw +`ExceptionInfo` with explanatory data. + > **Note** > 🚧 Because of the algorithm's design, **multiple IDs can decode back into the > same sequence of numbers**. If it's important to your design that IDs are @@ -85,7 +103,7 @@ Randomize IDs by providing a custom alphabet: (sqids/decode sqids id)) ; [1 2 3] ``` -Prevent specific words from appearing anywhere in the auto-generated IDs: +Override the blocklist: ```clojure (def sqids @@ -98,6 +116,79 @@ Prevent specific words from appearing anywhere in the auto-generated IDs: (sqids/decode sqids id)) ; [1 2 3] ``` +Three-character blocklist words match only whole IDs. Longer words containing +digits match only at either end; other longer words match anywhere. Words shorter +than three characters are ignored. + +## Development + +Use Java 21, Clojure CLI, Node.js 22+, npm 11.10+, and Python 3.11+. On macOS, +`bin/setup` installs the Homebrew prerequisites. Then run: + +```bash +python3 -m venv .venv +source .venv/bin/activate +export PIP_CONSTRAINT="$PWD/requirements.txt" +export PIP_BUILD_CONSTRAINT="$PIP_CONSTRAINT" +pip install -r requirements.txt +npm ci +bin/kaocha +bin/benchmark +bin/benchmark-node +pre-commit run --all-files +``` + +Dependency updates use stable releases at least 14 days old, with documented +exceptions for security fixes. `.npmrc` applies this age window when resolving +npm dependencies, disables lifecycle scripts, and requires a supporting npm +version. Formatters use the same npm lockfile as the development tools. Python +pins also constrain isolated hook environments. CI actions use commit SHAs and +tool versions are explicit; keep those pins synchronized with `deps.edn`. +Clojure lint and formatting hooks run the pinned aliases from `deps.edn`. +The scoped `markdownlint-cli2` overrides select aged security fixes for KaTeX, +markdown-it, and smol-toml that its dependency ranges would otherwise exclude. +Remove them when an age-qualified upstream release includes those fixes. + +`bin/kaocha` runs JVM and ClojureScript tests, including fixed vectors, invalid +inputs, and seeded roundtrip properties. Coverage includes all runtime code, +with a 90% minimum; reports are written to `target/coverage/` and JUnit XML to +`target/test-results/junit.xml`. + +Run the same differential corpus against this library on the JVM and Node.js +and the upstream TypeScript implementation. The Node runner uses advanced +ClojureScript optimization: + +```bash +SQIDS_SPEC_DIR=/path/to/sqids-spec bin/parity +``` + +Install the reference repository's dependencies with `npm ci` first. The corpus +covers the shared JavaScript-safe integer domain, custom alphabets, padding, +blocklist retries, alternate encodings, malformed IDs, and invalid options. + +`bin/benchmark` measures JVM time and allocation with reused configurations. +CI enforces per-call allocation budgets for single-digit, multi-digit, and +128-bit integer inputs, plus linear allocation growth for many-number inputs. + +`bin/benchmark-node` measures the advanced-compiled public API on Node, including +multi-digit and maximum-safe-integer inputs. It reports the default and empty +blocklists separately to expose filtering cost. Both benchmarks consume results +after warmup and report median timings; CI does not gate on noisy wall-clock +limits. Compare timings using the same runtime and hardware. + +All runtime code lives in `src/org/sqids/clojure.cljc`, with private implementation +helpers behind the public API. Behavior tests and generators live in +`test/org/sqids/clojure_test.cljc`; the parity harness stays under +`test/org/sqids/clojure/`, and benchmarks live under `dev/`. +There are no third-party runtime dependencies. Temporary mutable buffers are +owned by individual calls; instances can be shared across threads. + +Refresh the bundled default blocklist with `bin/update-blocklist`. Missing +blocklist data is an error, so a broken package cannot silently disable filtering. +Use `{:block-list #{}}` to disable filtering explicitly. + +`clojure -T:build jar` builds the source JAR; it does not run the tests. + ## License [MIT](LICENSE) diff --git a/bin/_cljstyle b/bin/_cljstyle deleted file mode 100755 index a5d3f74..0000000 --- a/bin/_cljstyle +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -if command -v cljstyle >/dev/null; then - cljstyle "$@" -else - clojure -M:cljstyle "$@" -fi diff --git a/bin/benchmark b/bin/benchmark new file mode 100755 index 0000000..c88d509 --- /dev/null +++ b/bin/benchmark @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -euo pipefail + +clojure -J-Xmx512m -M:dev:clj -m org.sqids.clojure.benchmark "$@" diff --git a/bin/benchmark-node b/bin/benchmark-node new file mode 100755 index 0000000..c08afc7 --- /dev/null +++ b/bin/benchmark-node @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -euo pipefail + +clojure -J-Xmx512m -X:dev:clj:test org.sqids.clojure.benchmark-node-runner/run "$@" diff --git a/bin/kaocha b/bin/kaocha new file mode 100755 index 0000000..0cf2703 --- /dev/null +++ b/bin/kaocha @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -euxfo pipefail + +clojure -M:dev:clj:test "$@" diff --git a/bin/parity b/bin/parity new file mode 100755 index 0000000..cf18c64 --- /dev/null +++ b/bin/parity @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euxfo pipefail + +: "${SQIDS_SPEC_DIR:?SQIDS_SPEC_DIR must point to a checked-out sqids-spec repository}" + +clojure -X:dev:clj:test org.sqids.clojure.parity-runner/run "$@" diff --git a/bin/repl b/bin/repl index 2324627..ea96f26 100755 --- a/bin/repl +++ b/bin/repl @@ -10,7 +10,7 @@ cljs) npx shadow-cljs -A:dev node-repl ;; *) - : "Usage: bin/repl clj|cljs" >&2 + echo "Usage: bin/repl clj|cljs" >&2 exit 1 ;; esac diff --git a/bin/setup b/bin/setup index aaf1c84..589afe1 100755 --- a/bin/setup +++ b/bin/setup @@ -3,4 +3,4 @@ set -euxfo pipefail brew bundle -npm install +npm ci diff --git a/bin/test b/bin/test deleted file mode 100755 index 034bd23..0000000 --- a/bin/test +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -set -euxfo pipefail - -case "${1:-}" in -clj) - clojure -M:dev:clj:test - ;; -cljs) - npx shadow-cljs -A:dev compile test - node target/cljs-tests.js - ;; -*) - : "Usage: bin/run-tests clj|cljs" - exit 1 - ;; -esac diff --git a/bin/update-blocklist b/bin/update-blocklist new file mode 100755 index 0000000..c11f841 --- /dev/null +++ b/bin/update-blocklist @@ -0,0 +1,75 @@ +#!/usr/bin/env bb + +(set! *warn-on-reflection* true) + +(require + '[babashka.fs :as fs] + '[cheshire.core :as json] + '[clojure.string :as str]) + +(def default-source-url + "Default upstream Sqids blocklist JSON URL." + "https://raw.githubusercontent.com/sqids/sqids-spec/main/src/blocklist.json") + +(def script-path + "Canonical path to this script." + (fs/canonicalize *file*)) + +(def repo-root + "Repository root directory derived from `script-path`." + (-> script-path fs/parent fs/parent)) + +(def default-output-path + "Default destination for the generated bundled blocklist." + (str (fs/path repo-root "resources" "org" "sqids" "clojure" "blocklist.json"))) + +(def source-url + "Effective source URL, optionally overridden by the first CLI argument." + (or (first *command-line-args*) default-source-url)) + +(def output-path + "Effective output path, optionally overridden by the second CLI argument." + (or (second *command-line-args*) default-output-path)) + +(defn fail + "Prints `message` to stderr and exits with a non-zero status." + [message] + (binding [*out* *err*] + (println message)) + (System/exit 1)) + +(defn normalize-words + "Normalizes fetched words into a trimmed, sorted vector of unique strings." + [words] + (->> words + (map str/trim) + (remove str/blank?) + set + sort + vec)) + +(defn parse-words + "Parses upstream JSON and returns normalized blocklist entries." + [body] + (let [data + (try + (json/parse-string body) + (catch Exception e + (fail (str "Failed to parse upstream blocklist JSON: " (.getMessage e)))))] + (when-not (and (sequential? data) (every? string? data)) + (fail "Expected a JSON array of strings")) + (normalize-words data))) + +(defn run + "Fetches the upstream blocklist and writes the bundled JSON artifact." + [] + (let [body (try + (slurp source-url) + (catch Exception e + (fail (str "Failed to fetch blocklist: " (.getMessage e))))) + words (parse-words body)] + (fs/create-dirs (fs/parent output-path)) + (spit output-path (str (json/generate-string words {:pretty true}) "\n")) + (println (str "Wrote " (count words) " blocklist entries to " output-path)))) + +(run) diff --git a/build.clj b/build.clj index 1043e8a..9791371 100644 --- a/build.clj +++ b/build.clj @@ -1,22 +1,27 @@ (ns build - (:refer-clojure :exclude [test]) (:require [clojure.string :as str] [clojure.tools.build.api :as b] [deps-deploy.deps-deploy :as dd])) -(def lib 'org.sqids/sqids-clojure) +(def lib + "Library coordinate for release artifacts." + 'org.sqids/sqids-clojure) (def versions + "Map of release and snapshot version strings." (let [major 1 - minor 0 - commits {:release (b/git-count-revs nil) + minor 1 + patch {:release 0 :snapshot "9999-SNAPSHOT"}] - (update-vals commits #(str/join "." [major minor %])))) + (update-vals patch #(str/join "." [major minor %])))) -(def class-dir "target/classes") +(def class-dir + "Compilation output directory used by tools.build." + "target/classes") (defn- pom-template + "Builds pom metadata entries for a given version." [version] [[:description "Official Clojure port of Sqids. Generate short YouTube-looking IDs from numbers."] [:url "https://github.com/sqids/sqids-clojure"] @@ -34,6 +39,7 @@ [:tag (str "v" version)]]]) (defn jar-opts + "Returns normalized build options for jar/install/deploy tasks." [opts] (let [version (versions (if (:snapshot opts) :snapshot :release))] (assoc opts @@ -43,18 +49,18 @@ :basis (b/create-basis {:aliases [:clj]}) :class-dir class-dir :target "target" - :src-dirs ["src"] + :src-dirs ["src" "resources"] :pom-data (pom-template version)))) (defn jar - "Run the CI pipeline of tests (and build the JAR)." + "Builds the source JAR and POM. Run bin/kaocha separately before publishing." [opts] (b/delete {:path "target"}) (let [opts (jar-opts opts)] (println "\nWriting pom.xml...") (b/write-pom opts) (println "\nCopying source...") - (b/copy-dir {:src-dirs ["src"] :target-dir class-dir}) + (b/copy-dir {:src-dirs ["src" "resources"] :target-dir class-dir}) (println "\nBuilding JAR..." (:jar-file opts)) (b/jar opts)) opts) diff --git a/deps.edn b/deps.edn index 176dfbd..d1ea756 100644 --- a/deps.edn +++ b/deps.edn @@ -1,50 +1,51 @@ {:paths - ["src"] + ["src" "resources"] :deps - {borkdude/dynaload {:mvn/version "0.3.5"}} + {} :aliases {:clj {:extra-deps - {org.clojure/clojure {:mvn/version "1.11.1"} - org.sqids/sqids {:mvn/version "0.1.0"}}} + {org.clojure/clojure {:mvn/version "1.12.6"}}} :cljs {:extra-deps - {thheller/shadow-cljs {:mvn/version "2.26.2"}}} + {thheller/shadow-cljs {:mvn/version "3.5.7"}}} :dev {:extra-paths ["dev" "test"] :extra-deps - {expound/expound {:mvn/version "0.9.0"} - org.clojure/test.check {:mvn/version "1.1.1"} - org.clojure/tools.namespace {:mvn/version "1.4.4"} - orchestra/orchestra {:mvn/version "2021.01.01-1"}}} + {org.clojure/data.json {:mvn/version "2.5.2"} + org.clojure/test.check {:mvn/version "1.1.3"}}} :test {:extra-deps - {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}} - :main-opts ["-m" "cognitect.test-runner"]} + {org.clojure/clojurescript {:mvn/version "1.12.145"} + lambdaisland/kaocha {:mvn/version "1.91.1392"} + com.lambdaisland/kaocha-cljs {:mvn/version "1.9.181"} + lambdaisland/kaocha-junit-xml {:mvn/version "1.17.101"} + lambdaisland/kaocha-cloverage {:mvn/version "1.1.89"}} + :main-opts ["-m" "kaocha.runner"]} :cljstyle - {:replace-deps {mvxcvi/cljstyle {:mvn/version "0.15.0"}} + {:replace-deps {mvxcvi/cljstyle {:mvn/version "0.17.642"}} :main-opts ["-m" "cljstyle.main"]} :clj-kondo - {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2023.10.20"}} + {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2026.08.04"}} :main-opts ["-m" "clj-kondo.main"]} :build {:replace-deps - {io.github.clojure/tools.build {:mvn/version "0.9.6"} - slipset/deps-deploy {:mvn/version "0.2.0"}} + {io.github.clojure/tools.build {:mvn/version "0.10.14"} + slipset/deps-deploy {:mvn/version "0.2.5"}} :ns-default build} :nrepl - {:extra-deps {nrepl/nrepl {:mvn/version "1.1.0"}} + {:extra-deps {nrepl/nrepl {:mvn/version "1.8.0"}} :main-opts ["-m" "nrepl.cmdline" "--interactive" "--color"]}}} diff --git a/dev/org/sqids/clojure/benchmark.clj b/dev/org/sqids/clojure/benchmark.clj new file mode 100644 index 0000000..cd85de2 --- /dev/null +++ b/dev/org/sqids/clojure/benchmark.clj @@ -0,0 +1,110 @@ +(ns org.sqids.clojure.benchmark + "Allocation regression checks with illustrative, non-gating JVM timings." + (:gen-class) + (:require + [org.sqids.clojure :as sqids]) + (:import + (com.sun.management + ThreadMXBean) + (java.lang.management + ManagementFactory) + (java.util.concurrent.atomic + AtomicReference))) + +(set! *warn-on-reflection* true) + +(def ^:private ^AtomicReference sink + "Retains each result so benchmark work cannot be eliminated by the compiler." + (AtomicReference.)) + +(defn- measure + "Measures one batch, including identical result-consumption overhead in every call." + [^ThreadMXBean allocation-bean n f] + (let [thread-id (.getId (Thread/currentThread)) + before-bytes (.getThreadAllocatedBytes allocation-bean thread-id) + before-time (System/nanoTime)] + (dotimes [_ n] + (.lazySet sink (f))) + {:microseconds (/ (- (System/nanoTime) before-time) (* 1000.0 n)) + :bytes (/ (- (.getThreadAllocatedBytes allocation-bean thread-id) before-bytes) + (double n))})) + +(defn- median + "Returns the middle of an odd number of measurements." + [values] + (nth (sort values) (quot (count values) 2))) + +(defn- sample + "Reports median time and allocation over three batches after explicit warmup." + [allocation-bean label warmup iterations f] + (dotimes [_ warmup] + (.lazySet sink (f))) + (let [batches (repeatedly 3 #(measure allocation-bean iterations f)) + allocated (median (map :bytes batches)) + microseconds (median (map :microseconds batches))] + (println (format "%s: %.2f us/call, %.0f bytes/call" label microseconds allocated)) + allocated)) + +(defn- allocation-budgets + "Checks absolute allocation budgets for short IDs, multi-digit values and bigints. + + Budgets include public validation and the default blocklist, with one reused + configuration. They are deliberately independent of another implementation + path: a uniform increase in allocation must fail this check. Ceilings allow + modest JIT variation while protecting the encoder's recursive digit path. + The added JDK 21 baselines are about 2 KB for multi-digit values and 6 KB + for a 128-bit integer; their ceilings leave approximately 25% headroom." + [allocation-bean] + (let [config (sqids/sqids)] + (doseq [[numbers encode-budget decode-budget] [[[1] 1400 1400] + [[1 2] 1800 1800] + [[1 2 3] 2100 2100] + [[1000000000 2000000000 3000000000] 2400 2600] + [[340282366920938463463374607431768211455N] 7400 7100]]] + (let [id (sqids/encode config numbers)] + (when-not (= numbers (sqids/decode config id)) + (throw (ex-info "Benchmark fixture failed to round-trip" {:numbers numbers}))) + (doseq [[operation budget f] [[:encode encode-budget #(sqids/encode config numbers)] + [:decode decode-budget #(sqids/decode config id)]]] + (let [allocated (sample allocation-bean (str numbers " " (name operation)) 30000 10000 f)] + (when (> allocated budget) + (throw (ex-info "ID allocation budget exceeded" + {:operation operation :numbers numbers :bytes allocated :budget budget}))))))))) + +(defn- allocation-scaling + "Checks allocation growth over a sixteenfold increase in long input length." + [allocation-bean] + (let [config (sqids/sqids {:alphabet "abc" :block-list #{}}) + samples (mapv + (fn [size] + (let [numbers (vec (repeat size 0)) + id (sqids/encode config numbers)] + (when-not (= numbers (sqids/decode config id)) + (throw (ex-info "Scaling fixture failed to round-trip" {:size size}))) + {:encode (sample allocation-bean (str size " numbers encode") 5 3 + #(sqids/encode config numbers)) + :decode (sample allocation-bean (str size " numbers decode") 5 3 + #(sqids/decode config id))})) + [4000 16000 64000])] + (doseq [operation [:encode :decode] + [small large] (partition 2 1 samples)] + (let [ratio (/ (operation large) (operation small))] + (println (format "%s allocation growth on quadrupled input: %.2fx" (name operation) ratio)) + ;; Linear code approaches 4x; 10% headroom accommodates array/vector growth. + ;; Quadratic concatenation grows toward 16x and n^1.5 allocation toward 8x. + (when (> ratio 4.4) + (throw (ex-info "Long-input allocation growth exceeded linear budget" + {:operation operation :ratio ratio :budget 4.4}))))))) + +(defn -main + "Runs allocation checks on HotSpot; wall-clock timings are informational only." + [& _] + (let [allocation-bean (ManagementFactory/getThreadMXBean)] + (when-not (and (instance? ThreadMXBean allocation-bean) + (.isThreadAllocatedMemorySupported ^ThreadMXBean allocation-bean)) + (throw (ex-info "Thread allocation metrics are unavailable on this JVM" {}))) + (.setThreadAllocatedMemoryEnabled ^ThreadMXBean allocation-bean true) + (println "Reused default configuration; median of three batches; output consumed.") + (allocation-budgets allocation-bean) + (allocation-scaling allocation-bean)) + (shutdown-agents)) diff --git a/dev/org/sqids/clojure/benchmark_node.cljs b/dev/org/sqids/clojure/benchmark_node.cljs new file mode 100644 index 0000000..6c91908 --- /dev/null +++ b/dev/org/sqids/clojure/benchmark_node.cljs @@ -0,0 +1,42 @@ +(ns org.sqids.clojure.benchmark-node + "Informational Node timings for the advanced-compiled public API." + (:require + [org.sqids.clojure :as sqids])) + +(def ^:private sink + "Retains benchmark results so the work remains observable." + (volatile! nil)) + +(defn- sample + "Reports the median of three batches after warmup; never gates on wall-clock time." + [label f] + (dotimes [_ 20000] + (vreset! sink (f))) + (let [timings (doall + (repeatedly 3 + (fn [] + (let [start (js/performance.now)] + (dotimes [_ 10000] + (vreset! sink (f))) + (/ (* 1000 (- (js/performance.now) start)) 10000))))) + median (nth (sort timings) 1)] + (println label (str (.toFixed median 2) " us/call")))) + +(defn -main + "Measures ordinary and multi-digit IDs with reused default and unfiltered configurations." + [& _] + (println "Node" (aget js/process "version") "; advanced compilation; output consumed; timings informational.") + (doseq [[label options numbers] + [["default / three numbers" {} [1 2 3]] + ["default / multi-digit" {} [1000000000 2000000000 3000000000]] + ["default / maximum safe integer" {} [9007199254740991]] + ["empty blocklist / three numbers" {:block-list #{}} [1 2 3]]]] + (let [config (sqids/sqids options) + id (sqids/encode config numbers)] + (when-not (= numbers (sqids/decode config id)) + (throw (ex-info "Node benchmark fixture failed to round-trip" {:label label}))) + (sample (str label " encode:") #(sqids/encode config numbers)) + (sample (str label " decode:") #(sqids/decode config id)))) + (println "Consumed final result length:" (count @sink))) + +(set! *main-cli-fn* -main) diff --git a/dev/org/sqids/clojure/benchmark_node_runner.clj b/dev/org/sqids/clojure/benchmark_node_runner.clj new file mode 100644 index 0000000..3bc70ea --- /dev/null +++ b/dev/org/sqids/clojure/benchmark_node_runner.clj @@ -0,0 +1,20 @@ +(ns org.sqids.clojure.benchmark-node-runner + (:require + [cljs.build.api :as cljs] + [clojure.java.shell :as shell])) + +(defn run + "Compiles the Node benchmark with production optimizations and runs it." + [_] + (cljs/build {:main 'org.sqids.clojure.benchmark-node + :target :nodejs + :optimizations :advanced + :output-dir "target/benchmark-node/cljs" + :output-to "target/benchmark-node/runner.js"}) + (let [{:keys [exit out err]} (shell/sh "node" "target/benchmark-node/runner.js")] + (print out) + (binding [*out* *err*] + (print err)) + (when-not (zero? exit) + (throw (ex-info "Node benchmark failed" {:exit exit})))) + (shutdown-agents)) diff --git a/dev/org/sqids/clojure/test_runner.cljc b/dev/org/sqids/clojure/test_runner.cljc deleted file mode 100644 index 92ec04c..0000000 --- a/dev/org/sqids/clojure/test_runner.cljc +++ /dev/null @@ -1,12 +0,0 @@ -(ns org.sqids.clojure.test-runner - (:require - [clojure.test :as t] - [org.sqids.clojure.alphabet-test] - [org.sqids.clojure.block-list-test] - [org.sqids.clojure.encoding-test] - [org.sqids.clojure.min-length-test] - [org.sqids.clojure.spec-test])) - -(defn run-all-tests - [] - (t/run-all-tests #"^org\.sqids\.clojure\..*-test$")) diff --git a/package-lock.json b/package-lock.json index 94fab0e..24b0103 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,95 +4,1327 @@ "requires": true, "packages": { "": { + "devDependencies": { + "markdownlint-cli2": "0.23.3", + "prettier": "3.9.10", + "shadow-cljs": "3.5.7", + "ws": "8.22.0" + }, + "engines": { + "node": ">=22", + "npm": ">=11.10.0" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@sindresorhus/merge-streams": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-4.0.0.tgz", + "integrity": "sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@types/debug": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz", + "integrity": "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/ms": "*" + } + }, + "node_modules/@types/katex": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.8.tgz", + "integrity": "sha512-trgaNyfU+Xh2Tc+ABIb44a5AYUpicB3uwirOioeOkNPPbmgRNtcWyDeeFRzjPZENO9Vq8gvVqfhaaXWLlevVwg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/ms": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", + "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/unist": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.11.tgz", + "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==", + "dev": true, + "license": "MIT" + }, + "node_modules/ansi-regex": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.4.0.tgz", + "integrity": "sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/character-entities": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", + "integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-legacy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", + "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-reference-invalid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-2.0.1.tgz", + "integrity": "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/commander": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-15.0.0.tgz", + "integrity": "sha512-z67u4ZhzCL/Tydu1lJARtEZYWbWaN7oYLHbsuzocr6y4N6WZAagG3RQ4FW61V1/0+jImpj293XfrcYnd1qxtPg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22.12.0" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decode-named-character-reference": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.3.0.tgz", + "integrity": "sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "character-entities": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/devlop": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", + "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", + "dev": true, + "license": "MIT", + "dependencies": { + "dequal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/entities": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-8.1.0.tgz", + "integrity": "sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fastq": { + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.3.tgz", + "integrity": "sha512-XKv5nnLs6nLF71NgiKJLIZFLkPyIEuOselLG7ujZnGrRfQK8HpvY+WqKhAJUAdLomwVHErVS4LfxFlPq0/FTAw==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/get-east-asian-width": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.7.0.tgz", + "integrity": "sha512-XjH1AECxf0giL2V1aU8vKyRR2ppRUb5c0EvT7zuJTokQ74bNo52zOtghqdWIqrhUD79fo3x0WfKZdOqxF6LG1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/globby": { + "version": "16.2.4", + "resolved": "https://registry.npmjs.org/globby/-/globby-16.2.4.tgz", + "integrity": "sha512-c8B/VNLmxRcmqqenRA9t+9IyOjf9+V6lTxPaUJLqOCONdQkWZ0ETYgX0qbtJqPsgCNusT9MZ5Jeidw8Eb9tn2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sindresorhus/merge-streams": "^4.0.0", + "fast-glob": "^3.3.3", + "ignore": "^7.0.5", + "is-path-inside": "^4.0.0", + "micromatch": "^4.0.8", + "slash": "^5.1.0", + "unicorn-magic": "^0.4.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/ignore": { + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.12.tgz", + "integrity": "sha512-/8UvqAPU9DGTI9k4mxtf49U37Isfwr8Uts96+SBHIkFxPJnHS0Ew4f00sM4Scd8V8EjM0jUNtVDdv1kPdt35lg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/is-alphabetical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz", + "integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-alphanumerical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz", + "integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-alphabetical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-decimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz", + "integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-hexadecimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-2.0.1.tgz", + "integrity": "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-path-inside": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz", + "integrity": "sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.5.tgz", + "integrity": "sha512-6B3tLtFqtQS4ekarvLVMZ+X+VlvQekbe4taUkf/rhVO3d/h0M2rfARm/pXLcPEsjjMsFgrFgSrhQIxcSVrBz8w==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/js-yaml": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.4.1.tgz", + "integrity": "sha512-28R/k+NAjeuf7+CKlTxWZVExJGwVVLwY06DgEnOMz2gEpfNkDcD7QvyiVPT0xy0XXhU8vHsd4Ot42OOPdJG7dQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.mjs" + } + }, + "node_modules/jsonc-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", + "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/jsonpointer": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-5.0.1.tgz", + "integrity": "sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/katex": { + "version": "0.18.10", + "resolved": "https://registry.npmjs.org/katex/-/katex-0.18.10.tgz", + "integrity": "sha512-/B6p9eY9DX7aHBfpkHdpirDTZ5QH9xTwL9y837PWuzuv41O5jFdqNQwVQEQsimY0/iVNkwBY4+4hMfhQ7d4Dbw==", + "dev": true, + "funding": [ + "https://opencollective.com/katex", + "https://github.com/sponsors/katex" + ], + "license": "MIT", + "dependencies": { + "commander": "^15.0.0" + }, + "bin": { + "katex": "cli.js" + } + }, + "node_modules/linkify-it": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-6.1.0.tgz", + "integrity": "sha512-wJ/TwpSDTLepCrQoYWYIExIKg5Zchex2Nn5yk2mFnB+6PtdkHtyLx742md9csRjjOnGkKIS/RrbY7l8D6gT9Vw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/markdown-it" + } + ], + "license": "MIT", + "dependencies": { + "uc.micro": "^3.0.0" + } + }, + "node_modules/markdown-it": { + "version": "15.0.3", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-15.0.3.tgz", + "integrity": "sha512-+Az7Ojz3iRGu8KYMvJ6xVhvrxP3eE+vEtJX75Ow88XBpcQNV/0lGX5ZynIIBftREo4DC2jsveAMDaeltmm8QvQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/markdown-it" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^3.0.3", + "entities": "^8.1.0", + "linkify-it": "^6.1.0", + "mdurl": "^2.1.0", + "punycode.js": "^2.3.1", + "uc.micro": "^3.0.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, + "node_modules/markdown-it/node_modules/argparse": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-3.0.3.tgz", + "integrity": "sha512-Sn98ftV3KfsO8xfLPHG6oT8y+b0yvbrLgZjgPDXsharNY15tTAjqIsIju4S32nl6/iEUNNE4v+yL2Zhm8ooP3w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "PSF-2.0" + }, + "node_modules/markdownlint": { + "version": "0.41.1", + "resolved": "https://registry.npmjs.org/markdownlint/-/markdownlint-0.41.1.tgz", + "integrity": "sha512-qHKeU2E1bdyNAT077go2FVTNXvYcktN5IHtF6XyeD1l0PClxzSp2tUApAV14ORI8DGX4H9bNKZEzelZp4qn8IA==", + "dev": true, + "license": "MIT", + "dependencies": { + "micromark": "4.0.2", + "micromark-core-commonmark": "2.0.3", + "micromark-extension-directive": "4.0.0", + "micromark-extension-gfm-autolink-literal": "2.1.0", + "micromark-extension-gfm-footnote": "2.1.0", + "micromark-extension-gfm-table": "2.1.1", + "micromark-extension-math": "3.1.0", + "micromark-util-types": "2.0.2", + "string-width": "8.2.1" + }, + "engines": { + "node": ">=22" + }, + "funding": { + "url": "https://github.com/sponsors/DavidAnson" + } + }, + "node_modules/markdownlint-cli2": { + "version": "0.23.3", + "resolved": "https://registry.npmjs.org/markdownlint-cli2/-/markdownlint-cli2-0.23.3.tgz", + "integrity": "sha512-xAr5o/TGpC3v6lE6cKIW4b5eOFRrRX5u7Vtjae9ix3RALv8nNOd94XMkD/1OXXBtpMcJ4uQGbpSo3hv5UqS4uQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "globby": "16.2.4", + "js-yaml": "5.4.1", + "jsonc-parser": "3.3.1", + "jsonpointer": "5.0.1", + "markdown-it": "15.0.1", + "markdownlint": "0.41.1", + "markdownlint-cli2-formatter-default": "0.0.6", + "micromatch": "4.0.8", + "smol-toml": "1.8.0" + }, + "bin": { + "markdownlint-cli2": "markdownlint-cli2-bin.mjs" + }, + "engines": { + "node": ">=22" + }, + "funding": { + "url": "https://github.com/sponsors/DavidAnson" + } + }, + "node_modules/markdownlint-cli2-formatter-default": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/markdownlint-cli2-formatter-default/-/markdownlint-cli2-formatter-default-0.0.6.tgz", + "integrity": "sha512-VVDGKsq9sgzu378swJ0fcHfSicUnMxnL8gnLm/Q4J/xsNJ4e5bA6lvAz7PCzIl0/No0lHyaWdqVD2jotxOSFMQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/DavidAnson" + }, + "peerDependencies": { + "markdownlint-cli2": ">=0.0.4" + } + }, + "node_modules/mdurl": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.1.0.tgz", + "integrity": "sha512-1+HBaOx0zi/dQWht8rNv9MYf9qqpqL/kxI0hXImU6Y547zM6Sni8BQibt7ifgMcYtQg41ao3Ivd6cnSM86inpg==", + "dev": true, + "license": "MIT" + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromark": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz", + "integrity": "sha512-zpe98Q6kvavpCr1NPVSCMebCKfD7CA2NqZ+rykeNhONIJBpc1tFKt9hucLGwha3jNTNI8lHpctWJWoimVF4PfA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "@types/debug": "^4.0.0", + "debug": "^4.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-combine-extensions": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-core-commonmark": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.3.tgz", + "integrity": "sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-factory-destination": "^2.0.0", + "micromark-factory-label": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-factory-title": "^2.0.0", + "micromark-factory-whitespace": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-html-tag-name": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-extension-directive": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/micromark-extension-directive/-/micromark-extension-directive-4.0.0.tgz", + "integrity": "sha512-/C2nqVmXXmiseSSuCdItCMho7ybwwop6RrrRPk0KbOHW21JKoCldC+8rFOaundDoRBUWBnJJcxeA/Kvi34WQXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-factory-whitespace": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0", + "parse-entities": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-autolink-literal": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-2.1.0.tgz", + "integrity": "sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==", + "dev": true, + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-footnote": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-2.1.0.tgz", + "integrity": "sha512-/yPhxI1ntnDNsiHtzLKYnE3vf9JZ6cAisqVDauhp4CEHxlb4uoOTxOCJ+9s51bIB8U1N1FJ1RXOKTIlD5B/gqw==", + "dev": true, + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-table": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-2.1.1.tgz", + "integrity": "sha512-t2OU/dXXioARrC6yWfJ4hqB7rct14e8f7m0cbI5hUmDyyIlwv5vEtooptH8INkbLzOatzKuVbQmAYcbWoyz6Dg==", + "dev": true, + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-math": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-math/-/micromark-extension-math-3.1.0.tgz", + "integrity": "sha512-lvEqd+fHjATVs+2v/8kg9i5Q0AP2k85H0WUOwpIVvUML8BapsMvh1XAogmQjOCsLpoKRCVQqEkQBB3NhVBcsOg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/katex": "^0.16.0", + "devlop": "^1.0.0", + "katex": "^0.16.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-factory-destination": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz", + "integrity": "sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-label": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.1.tgz", + "integrity": "sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-space": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.1.0.tgz", + "integrity": "sha512-fS8hnLIjnjvdQIj39Geug8wWsR0HrYZ43KShKxNfwT7t2LOHo/LbWZEzEaSOjwtjdCsjoE6syHhonEzW0zv0+Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-title": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.1.tgz", + "integrity": "sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-whitespace": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.1.tgz", + "integrity": "sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", "dependencies": { - "sqids": "0.3.0" - }, - "devDependencies": { - "shadow-cljs": "^3.3.6" + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" } }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "node_modules/micromark-util-chunked": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.1.tgz", + "integrity": "sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==", "dev": true, "funding": [ { - "type": "github", - "url": "https://github.com/sponsors/feross" + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" }, { - "type": "patreon", - "url": "https://www.patreon.com/feross" + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-classify-character": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.1.tgz", + "integrity": "sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" }, { - "type": "consulting", - "url": "https://feross.org/support" + "type": "OpenCollective", + "url": "https://opencollective.com/unified" } ], - "license": "MIT" + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } }, - "node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "node_modules/micromark-util-combine-extensions": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.1.tgz", + "integrity": "sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==", "dev": true, "funding": [ { - "type": "github", - "url": "https://github.com/sponsors/feross" + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" }, { - "type": "patreon", - "url": "https://www.patreon.com/feross" + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-chunked": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-numeric-character-reference": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.2.tgz", + "integrity": "sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" }, { - "type": "consulting", - "url": "https://feross.org/support" + "type": "OpenCollective", + "url": "https://opencollective.com/unified" } ], "license": "MIT", "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" + "micromark-util-symbol": "^2.0.0" } }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "node_modules/micromark-util-encode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz", + "integrity": "sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==", "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "license": "MIT" }, - "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "node_modules/micromark-util-html-tag-name": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.1.tgz", + "integrity": "sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==", "dev": true, "funding": [ { - "type": "github", - "url": "https://github.com/sponsors/feross" + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" }, { - "type": "patreon", - "url": "https://www.patreon.com/feross" + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-normalize-identifier": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.1.tgz", + "integrity": "sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" }, { - "type": "consulting", - "url": "https://feross.org/support" + "type": "OpenCollective", + "url": "https://opencollective.com/unified" } ], - "license": "BSD-3-Clause" + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } }, - "node_modules/isexe": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.5.tgz", - "integrity": "sha512-6B3tLtFqtQS4ekarvLVMZ+X+VlvQekbe4taUkf/rhVO3d/h0M2rfARm/pXLcPEsjjMsFgrFgSrhQIxcSVrBz8w==", + "node_modules/micromark-util-resolve-all": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.1.tgz", + "integrity": "sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==", "dev": true, - "license": "BlueOak-1.0.0", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-sanitize-uri": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz", + "integrity": "sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-subtokenize": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.1.0.tgz", + "integrity": "sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-types": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz", + "integrity": "sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, "engines": { - "node": ">=18" + "node": ">=8.6" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/parse-entities": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-4.0.2.tgz", + "integrity": "sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "^2.0.0", + "character-entities-legacy": "^3.0.0", + "character-reference-invalid": "^2.0.0", + "decode-named-character-reference": "^1.0.0", + "is-alphanumerical": "^2.0.0", + "is-decimal": "^2.0.0", + "is-hexadecimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/prettier": { + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.10.tgz", + "integrity": "sha512-skGHTH1Yb9QvaTC4hWnRTzEYtCpApF0UMBPz+t/0ZPzP8ihefo/btKd+QA7pUE0fEwA1SbS/NmhyEcstdXOIdA==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" } }, "node_modules/process": { @@ -105,6 +1337,37 @@ "node": ">= 0.6.0" } }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/readline-sync": { "version": "1.4.10", "resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz", @@ -114,10 +1377,45 @@ "node": ">= 0.8.0" } }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, "node_modules/shadow-cljs": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/shadow-cljs/-/shadow-cljs-3.3.6.tgz", - "integrity": "sha512-t5TBJmy77abwlkAY7UOXa1s9H/28nTHeDVckgzEVS8ONYtDvbNCHEuBYfS7wwV9wVZVybRNb7dILWNXISJL1Nw==", + "version": "3.5.7", + "resolved": "https://registry.npmjs.org/shadow-cljs/-/shadow-cljs-3.5.7.tgz", + "integrity": "sha512-v0qvoSGM36uSBz+GRqdI8FzSFJAXzrTJEctddTsLxo0mqAHpk1yUZteqHL5WIjUDeTPHaiiYIre524B7OMJwPg==", "dev": true, "license": "ISC", "dependencies": { @@ -142,6 +1440,32 @@ "integrity": "sha512-cZB2pzVXBnhpJ6PQdsjO+j/MksR28mv4QD/hP/2y1fsIa9Z9RutYgh3N34FZ8Ktl4puAXaIGlct+gMCJ5BmwmA==", "dev": true }, + "node_modules/slash": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz", + "integrity": "sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/smol-toml": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.9.1.tgz", + "integrity": "sha512-j7WyPdf0CJoutMzMoPLF/bVXHtKZIT9Rb4eGeEbWw8X2t5oirjPgpL+OpaENZrILYaXqYwnVH+qgUwVbl+pUJQ==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">= 18" + }, + "funding": { + "url": "https://github.com/sponsors/cyyynthia" + } + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -163,10 +1487,71 @@ "source-map": "^0.6.0" } }, - "node_modules/sqids": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/sqids/-/sqids-0.3.0.tgz", - "integrity": "sha512-lOQK1ucVg+W6n3FhRwwSeUijxe93b51Bfz5PMRMihVf1iVkl82ePQG7V5vwrhzB11v0NtsR25PSZRGiSomJaJw==" + "node_modules/string-width": { + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-8.2.1.tgz", + "integrity": "sha512-IIaP0g3iy9Cyy18w3M9YcaDudujEAVHKt3a3QJg1+sr/oX96TbaGUubG0hJyCjCBThFH+tFpcIyoUHUn1ogaLA==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-east-asian-width": "^1.5.0", + "strip-ansi": "^7.1.2" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/strip-ansi": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", + "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.2.2" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/uc.micro": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-3.0.0.tgz", + "integrity": "sha512-U3PppEkleoTnIfi8BozMx3yju3qc/L6SwqWo2Sw+54PX+PX0q9I+r1Um5HCmqD7n9VDX5/v3vQH/AjA6deDdtw==", + "dev": true, + "license": "MIT" + }, + "node_modules/unicorn-magic": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.4.1.tgz", + "integrity": "sha512-lzlXPoVB0Uy/FvTaUgX39RbixYiSKoc3JSoSf01+0c2B6FR3qdYIPN7Qjo/AV7n6sqLCk0509cT3LRj1oSZ1+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, "node_modules/which": { "version": "5.0.0", @@ -185,9 +1570,9 @@ } }, "node_modules/ws": { - "version": "8.19.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.19.0.tgz", - "integrity": "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==", + "version": "8.22.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz", + "integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 27bdddb..9be5734 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,20 @@ { - "dependencies": { - "sqids": "0.3.0" + "private": true, + "engines": { + "node": ">=22", + "npm": ">=11.10.0" }, "devDependencies": { - "shadow-cljs": "^3.3.6" + "markdownlint-cli2": "0.23.3", + "prettier": "3.9.10", + "shadow-cljs": "3.5.7", + "ws": "8.22.0" + }, + "overrides": { + "markdownlint-cli2": { + "katex": "0.18.10", + "markdown-it": "15.0.3", + "smol-toml": "1.9.1" + } } } diff --git a/requirements.txt b/requirements.txt index 416634f..db4f57b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,18 @@ -pre-commit +# Python 3.11+ tooling and hook dependencies; also used as pip/build constraints. +# Stable releases published before 2026-10-19 (14-day minimum age at update). +cfgv==3.5.0 +distlib==0.4.4 +filelock==4.2.2 +identify==2.6.20 +nodeenv==1.11.0 +packaging==26.3 +platformdirs==4.13.4 +pre-commit==4.7.0 +python-discovery==1.6.3 +pyyaml==6.0.3 +ruamel-yaml==0.19.1 +setuptools==84.0.0 +setuptools-download==1.1.0 +shellcheck-py==0.11.0.1 +virtualenv==21.14.11 +wheel==0.48.0 diff --git a/resources/org/sqids/clojure/blocklist.json b/resources/org/sqids/clojure/blocklist.json new file mode 100644 index 0000000..7506493 --- /dev/null +++ b/resources/org/sqids/clojure/blocklist.json @@ -0,0 +1,562 @@ +[ + "0rgasm", + "1d10t", + "1d1ot", + "1di0t", + "1diot", + "1eccacu10", + "1eccacu1o", + "1eccacul0", + "1eccaculo", + "1mbec11e", + "1mbec1le", + "1mbeci1e", + "1mbecile", + "a11upat0", + "a11upato", + "a1lupat0", + "a1lupato", + "aand", + "ah01e", + "ah0le", + "aho1e", + "ahole", + "al1upat0", + "al1upato", + "allupat0", + "allupato", + "ana1", + "ana1e", + "anal", + "anale", + "anus", + "arrapat0", + "arrapato", + "arsch", + "arse", + "ass", + "b00b", + "b00be", + "b01ata", + "b0ceta", + "b0iata", + "b0ob", + "b0obe", + "b0sta", + "b1tch", + "b1te", + "b1tte", + "ba1atkar", + "balatkar", + "bastard0", + "bastardo", + "batt0na", + "battona", + "bitch", + "bite", + "bitte", + "bo0b", + "bo0be", + "bo1ata", + "boceta", + "boiata", + "boob", + "boobe", + "bosta", + "bran1age", + "bran1er", + "bran1ette", + "bran1eur", + "bran1euse", + "branlage", + "branler", + "branlette", + "branleur", + "branleuse", + "c0ck", + "c0g110ne", + "c0g11one", + "c0g1i0ne", + "c0g1ione", + "c0gl10ne", + "c0gl1one", + "c0gli0ne", + "c0glione", + "c0na", + "c0nnard", + "c0nnasse", + "c0nne", + "c0u111es", + "c0u11les", + "c0u1l1es", + "c0u1lles", + "c0ui11es", + "c0ui1les", + "c0uil1es", + "c0uilles", + "c11t", + "c11t0", + "c11to", + "c1it", + "c1it0", + "c1ito", + "cabr0n", + "cabra0", + "cabrao", + "cabron", + "caca", + "cacca", + "cacete", + "cagante", + "cagar", + "cagare", + "cagna", + "cara1h0", + "cara1ho", + "caracu10", + "caracu1o", + "caracul0", + "caraculo", + "caralh0", + "caralho", + "cazz0", + "cazz1mma", + "cazzata", + "cazzimma", + "cazzo", + "ch00t1a", + "ch00t1ya", + "ch00tia", + "ch00tiya", + "ch0d", + "ch0ot1a", + "ch0ot1ya", + "ch0otia", + "ch0otiya", + "ch1asse", + "ch1avata", + "ch1er", + "ch1ng0", + "ch1ngadaz0s", + "ch1ngadazos", + "ch1ngader1ta", + "ch1ngaderita", + "ch1ngar", + "ch1ngo", + "ch1ngues", + "ch1nk", + "chatte", + "chiasse", + "chiavata", + "chier", + "ching0", + "chingadaz0s", + "chingadazos", + "chingader1ta", + "chingaderita", + "chingar", + "chingo", + "chingues", + "chink", + "cho0t1a", + "cho0t1ya", + "cho0tia", + "cho0tiya", + "chod", + "choot1a", + "choot1ya", + "chootia", + "chootiya", + "cl1t", + "cl1t0", + "cl1to", + "clit", + "clit0", + "clito", + "cock", + "cog110ne", + "cog11one", + "cog1i0ne", + "cog1ione", + "cogl10ne", + "cogl1one", + "cogli0ne", + "coglione", + "cona", + "connard", + "connasse", + "conne", + "cou111es", + "cou11les", + "cou1l1es", + "cou1lles", + "coui11es", + "coui1les", + "couil1es", + "couilles", + "cracker", + "crap", + "cu10", + "cu1att0ne", + "cu1attone", + "cu1er0", + "cu1ero", + "cu1o", + "cul0", + "culatt0ne", + "culattone", + "culer0", + "culero", + "culo", + "cum", + "cunt", + "d11d0", + "d11do", + "d1ck", + "d1ld0", + "d1ldo", + "damn", + "de1ch", + "deich", + "depp", + "di1d0", + "di1do", + "dick", + "dild0", + "dildo", + "dyke", + "encu1e", + "encule", + "enema", + "enf01re", + "enf0ire", + "enfo1re", + "enfoire", + "estup1d0", + "estup1do", + "estupid0", + "estupido", + "etr0n", + "etron", + "f0da", + "f0der", + "f0ttere", + "f0tters1", + "f0ttersi", + "f0tze", + "f0utre", + "f1ca", + "f1cker", + "f1ga", + "fag", + "fica", + "ficker", + "figa", + "foda", + "foder", + "fottere", + "fotters1", + "fottersi", + "fotze", + "foutre", + "fr0c10", + "fr0c1o", + "fr0ci0", + "fr0cio", + "fr0sc10", + "fr0sc1o", + "fr0sci0", + "fr0scio", + "froc10", + "froc1o", + "froci0", + "frocio", + "frosc10", + "frosc1o", + "frosci0", + "froscio", + "fuck", + "g00", + "g0o", + "g0u1ne", + "g0uine", + "gandu", + "go0", + "goo", + "gou1ne", + "gouine", + "gr0gnasse", + "grognasse", + "haram1", + "harami", + "haramzade", + "hund1n", + "hundin", + "id10t", + "id1ot", + "idi0t", + "idiot", + "imbec11e", + "imbec1le", + "imbeci1e", + "imbecile", + "j1zz", + "jerk", + "jizz", + "k1ke", + "kam1ne", + "kamine", + "kike", + "leccacu10", + "leccacu1o", + "leccacul0", + "leccaculo", + "m1erda", + "m1gn0tta", + "m1gnotta", + "m1nch1a", + "m1nchia", + "m1st", + "mam0n", + "mamahuev0", + "mamahuevo", + "mamon", + "masturbat10n", + "masturbat1on", + "masturbate", + "masturbati0n", + "masturbation", + "merd0s0", + "merd0so", + "merda", + "merde", + "merdos0", + "merdoso", + "mierda", + "mign0tta", + "mignotta", + "minch1a", + "minchia", + "mist", + "musch1", + "muschi", + "n1gger", + "neger", + "negr0", + "negre", + "negro", + "nerch1a", + "nerchia", + "nigger", + "orgasm", + "p00p", + "p011a", + "p01la", + "p0l1a", + "p0lla", + "p0mp1n0", + "p0mp1no", + "p0mpin0", + "p0mpino", + "p0op", + "p0rca", + "p0rn", + "p0rra", + "p0uff1asse", + "p0uffiasse", + "p1p1", + "p1pi", + "p1r1a", + "p1rla", + "p1sc10", + "p1sc1o", + "p1sci0", + "p1scio", + "p1sser", + "pa11e", + "pa1le", + "pal1e", + "palle", + "pane1e1r0", + "pane1e1ro", + "pane1eir0", + "pane1eiro", + "panele1r0", + "panele1ro", + "paneleir0", + "paneleiro", + "patakha", + "pec0r1na", + "pec0rina", + "pecor1na", + "pecorina", + "pen1s", + "pendej0", + "pendejo", + "penis", + "pip1", + "pipi", + "pir1a", + "pirla", + "pisc10", + "pisc1o", + "pisci0", + "piscio", + "pisser", + "po0p", + "po11a", + "po1la", + "pol1a", + "polla", + "pomp1n0", + "pomp1no", + "pompin0", + "pompino", + "poop", + "porca", + "porn", + "porra", + "pouff1asse", + "pouffiasse", + "pr1ck", + "prick", + "pussy", + "put1za", + "puta", + "puta1n", + "putain", + "pute", + "putiza", + "puttana", + "queca", + "r0mp1ba11e", + "r0mp1ba1le", + "r0mp1bal1e", + "r0mp1balle", + "r0mpiba11e", + "r0mpiba1le", + "r0mpibal1e", + "r0mpiballe", + "rand1", + "randi", + "rape", + "recch10ne", + "recch1one", + "recchi0ne", + "recchione", + "retard", + "romp1ba11e", + "romp1ba1le", + "romp1bal1e", + "romp1balle", + "rompiba11e", + "rompiba1le", + "rompibal1e", + "rompiballe", + "ruff1an0", + "ruff1ano", + "ruffian0", + "ruffiano", + "s1ut", + "sa10pe", + "sa1aud", + "sa1ope", + "sacanagem", + "sal0pe", + "salaud", + "salope", + "saugnapf", + "sb0rr0ne", + "sb0rra", + "sb0rrone", + "sbattere", + "sbatters1", + "sbattersi", + "sborr0ne", + "sborra", + "sborrone", + "sc0pare", + "sc0pata", + "sch1ampe", + "sche1se", + "sche1sse", + "scheise", + "scheisse", + "schlampe", + "schwachs1nn1g", + "schwachs1nnig", + "schwachsinn1g", + "schwachsinnig", + "schwanz", + "scopare", + "scopata", + "sexy", + "sh1t", + "shit", + "slut", + "sp0mp1nare", + "sp0mpinare", + "spomp1nare", + "spompinare", + "str0nz0", + "str0nza", + "str0nzo", + "stronz0", + "stronza", + "stronzo", + "stup1d", + "stupid", + "succh1am1", + "succh1ami", + "succhiam1", + "succhiami", + "sucker", + "t0pa", + "tapette", + "test1c1e", + "test1cle", + "testic1e", + "testicle", + "tette", + "topa", + "tr01a", + "tr0ia", + "tr0mbare", + "tr1ng1er", + "tr1ngler", + "tring1er", + "tringler", + "tro1a", + "troia", + "trombare", + "turd", + "twat", + "vaffancu10", + "vaffancu1o", + "vaffancul0", + "vaffanculo", + "vag1na", + "vagina", + "verdammt", + "verga", + "w1chsen", + "wank", + "wichsen", + "x0ch0ta", + "x0chota", + "xana", + "xoch0ta", + "xochota", + "z0cc01a", + "z0cc0la", + "z0cco1a", + "z0ccola", + "z1z1", + "z1zi", + "ziz1", + "zizi", + "zocc01a", + "zocc0la", + "zocco1a", + "zoccola" +] diff --git a/shadow-cljs.edn b/shadow-cljs.edn index fa087fc..e0dfc96 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -1,3 +1,3 @@ -{:deps {:aliases [:cljs]} +{:deps {:aliases [:clj :cljs]} :builds {:test {:target :node-test :output-to "target/cljs-tests.js"}}} diff --git a/src/deps.cljs b/src/deps.cljs deleted file mode 100644 index 9a421d9..0000000 --- a/src/deps.cljs +++ /dev/null @@ -1 +0,0 @@ -{:npm-deps {"sqids" "0.3.0"}} diff --git a/src/org/sqids/clojure.cljc b/src/org/sqids/clojure.cljc index 715682e..3e4f1ff 100644 --- a/src/org/sqids/clojure.cljc +++ b/src/org/sqids/clojure.cljc @@ -1,83 +1,324 @@ (ns org.sqids.clojure (:require - [org.sqids.clojure.platform :as platform] - [org.sqids.clojure.spec :as spec])) + #?@(:clj + [[clojure.edn :as edn] + [clojure.java.io :as io]]) + [clojure.string :as str]) + #?(:clj + (:import + (java.util + Locale)) + :cljs + (:import + (goog.string + StringBuffer))) + #?(:cljs + (:require-macros + [org.sqids.clojure :as sqids-macros]))) + +#?(:clj (set! *warn-on-reflection* true)) + +#?(:clj + (defmacro ^:private read-default-blocklist + "Embeds the required bundled blocklist at compile time on both platforms." + [] + (let [path "org/sqids/clojure/blocklist.json" + resource (io/resource path)] + (when-not resource + (throw (ex-info "Missing bundled Sqids blocklist" {:resource path}))) + (set (edn/read-string (slurp resource)))))) (def default-options - (spec/conform! ::spec/options - {:alphabet platform/default-alphabet - :min-length platform/default-min-length - :block-list (set platform/default-block-list)})) + "Default, uncompiled Sqids options, suitable for passing to `sqids`." + {:alphabet "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + :min-length 0 + :block-list #?(:clj (read-default-blocklist) + :cljs (sqids-macros/read-default-blocklist))}) + +(deftype ^{:no-doc true :doc "Immutable, non-associative compiled options used by encode and decode."} + Sqids + [alphabet min-length block-list-index alphabet-set]) + +(defn- require-instance + "Checks that the argument is a Sqids instance and returns it." + [candidate] + (if (instance? Sqids candidate) + candidate + (throw (ex-info "Create an instance with sqids before encoding or decoding" {:instance candidate})))) + +(defn- rotate-left + "Returns `alphabet` rotated left by `offset` characters." + [alphabet offset] + (str (subs alphabet offset) (subs alphabet 0 offset))) + +(defn- consistent-shuffle + "Applies the deterministic Sqids shuffle to an owned character array." + [alphabet] + (let [characters #?(:clj (.toCharArray ^String alphabet) + :cljs (.split alphabet "")) + size (long (alength characters))] + (loop [left 0 + right (dec size)] + (if (pos? right) + (let [left-char (aget characters left) + right-char (aget characters right) + swap-index (rem (+ (* left right) + #?(:clj (int left-char) :cljs (.charCodeAt left-char 0)) + #?(:clj (int right-char) :cljs (.charCodeAt right-char 0))) + size)] + (aset characters left (aget characters swap-index)) + (aset characters swap-index left-char) + (recur (inc left) (dec right))) + #?(:clj (String. characters) + :cljs (.join characters "")))))) + +(defn- lower-case + "Normalizes matching independently of the JVM's default locale." + [word] + #?(:clj (.toLowerCase ^String word Locale/ROOT) + :cljs (str/lower-case word))) + +(defn- normalize-blocklist + "Lowercases and deduplicates words, removing those too short or impossible for this alphabet." + [words alphabet] + (let [alphabet-set (set (lower-case alphabet))] + (into #{} + (comp (map lower-case) + (filter #(>= (count %) 3)) + (filter #(every? alphabet-set %))) + words))) + +(defn- index-blocklist + "Groups normalized words by matching rule; nil disables blocklist checks." + [words] + (when (seq words) + (reduce (fn [index word] + (update index + (cond + (= 3 (count word)) :exact + (re-find #"\d" word) :prefix-suffix + :else :contains) + conj word)) + {:exact #{} :prefix-suffix [] :contains []} + words))) + +(defn- matches-any? + "Scans a word vector with early termination and no per-word sequence nodes." + [pred words] + (reduce (fn [_ word] + (if (pred word) + (reduced true) + false)) + false + words)) + +(defn- blocked-id? + "Returns whether an ID matches a compiled blocklist index." + [index id] + (boolean + (when (and index (>= (count id) 3)) + (let [id (lower-case id)] + (or (contains? (:exact index) id) + (and (> (count id) 3) + (or (matches-any? #(or (str/starts-with? id %) (str/ends-with? id %)) + (:prefix-suffix index)) + (matches-any? #(str/includes? id %) (:contains index))))))))) + +(defn- validated-options + "Applies defaults and validates options before compiling an instance." + [options] + (when-not (map? options) + (throw (ex-info "Sqids options must be a map" {:options options}))) + (let [{:keys [alphabet min-length block-list] :as options} (merge default-options options)] + (when-not (and (string? alphabet) + (<= 3 (count alphabet) 128) + (= (count alphabet) (count (set alphabet))) + (not (re-find #"[^\u0000-\u007f]" alphabet))) + (throw (ex-info "Alphabet must contain at least 3 unique ASCII characters" {:alphabet alphabet}))) + (when-not (and (integer? min-length) (<= 0 min-length 255)) + (throw (ex-info "Minimum length must be an integer between 0 and 255" {:min-length min-length}))) + (when-not (and (set? block-list) (every? string? block-list)) + (throw (ex-info "Blocklist must be a set of strings" {:block-list block-list}))) + options)) (defn sqids - "Builds a sqids map. Supported options in `options`: + "Builds a reusable Sqids instance from an options map. + + Options are `:alphabet` (at least 3 unique ASCII characters), `:min-length` + (integer from 0 to 255), and `:block-list` (a set of strings). An omitted + blocklist uses the bundled default; an empty set disables filtering. - | key | description | - |---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| - | `:alphabet` | A string. The alphabet to which a vector of numbers will be encoded to a Sqid and from which a Sqid will be decoded to a vector of numbers. Minimum length is `org.sqids.Sqids$MIN_ALPHABET_LENGTH`. Must not contain multi-byte characters. Must consistent of unique characters. Default is `org.sqids.Sqids$Builder/DEFAULT_ALPHABET`. | - | `:min-length` | An int. The minimum length of an Sqid. Must be in [0, `org.sqids.Sqids$MIN_LENGTH_LIMIT`]. Default is `org.sqids.Sqids$Builder/DEFAULT_MIN_LENGTH`. | - | `:block-list` | A set of strings. Any words that should be excluded from an encoded Sqid. Any words shorter than `org.sqids.Sqids/MIN_BLOCK_LIST_WORD_LENGTH` will be excluded. | " + The returned instance does not support associative operations. Retain the + options separately and call `sqids` again to change them. Invalid options + throw ex-info." ([] (sqids {})) ([options] - (let [complete-options - (->> options - (spec/conform! ::spec/options) - (merge default-options)) + (let [{:keys [alphabet min-length block-list]} (validated-options options)] + (->Sqids (consistent-shuffle alphabet) + (int min-length) + (index-blocklist (normalize-blocklist block-list alphabet)) + (set alphabet))))) - instance - (platform/sqids complete-options)] +(defn- to-id + "Encodes one integer, reserving the first alphabet character for separators." + [number ^String alphabet] + (let [base (dec (count alphabet)) + out #?(:clj (StringBuilder.) :cljs (array))] + (loop [number number] + (let [digit (.charAt alphabet (inc (int (rem number base)))) + quotient (quot number base)] + #?(:clj (.append ^StringBuilder out ^char digit) + :cljs (.push out digit)) + (if (pos? quotient) + (recur quotient) + #?(:clj (.toString (.reverse ^StringBuilder out)) + :cljs (.join (.reverse out) ""))))))) - (->> instance - (assoc complete-options :instance) - (spec/conform! ::spec/sqids))))) - -;; NOTE: Generative testing is disabled for encode because it may throw a -;; RuntimeException. -(defn encode - "Encodes numbers into a Sqid string. Arguments: +(defn- prefix-offset + "Computes the initial prefix offset once, before blocklist retries." + [^String alphabet numbers] + (let [size (count alphabet)] + (reduce-kv (fn [offset index number] + (let [character (.charAt alphabet (int (rem number size)))] + (rem (+ offset index #?(:clj (int character) + :cljs (.charCodeAt character 0))) + size))) + (rem (count numbers) size) + numbers))) - | name | description | - |------------|-------------------------------------------------------------------------------| - | `s` | A map returned by `org.sqids.clojure/sqids`. | - | `nat-ints` | A sequential collection of natural ints that will be encoded into a Sqid. | +(defn- encode-unpadded + "Builds the unpadded ID, returning it and the final alphabet." + [numbers ^String alphabet offset] + (let [rotated (rotate-left alphabet offset) + out #?(:clj (StringBuilder.) :cljs (StringBuffer.)) + number-count (count numbers)] + (.append ^StringBuilder out ^char (.charAt ^String rotated 0)) + (loop [current-alphabet (str/reverse rotated) + index 0] + (let [digits (to-id (nth numbers index) current-alphabet)] + (.append ^StringBuilder out ^String digits) + (if (< index (dec number-count)) + (do + (.append ^StringBuilder out ^char (.charAt ^String current-alphabet 0)) + (recur (consistent-shuffle current-alphabet) (inc index))) + [(.toString ^StringBuilder out) + current-alphabet]))))) - Returns an empty string if `nat-ints` is empty. Throws a `RuntimeException` if - any value in `nat-ints` is negative. May throw a `RuntimeException` if a Sqid - cannot be generated due to too many attempts." - [s nat-ints] - (let [instance - (spec/conform! ::spec/instance (:instance s)) +(defn- pad-to-min-length + "Adds Sqids padding, bounded by the configured maximum of 255 characters." + [id min-length alphabet] + (if (<= min-length (count id)) + id + (loop [id (str id (.charAt ^String alphabet 0)) + alphabet alphabet] + (if (<= min-length (count id)) + id + (let [alphabet (consistent-shuffle alphabet) + required (- min-length (count id))] + (recur (str id (subs alphabet 0 (min required (count alphabet)))) + alphabet)))))) - numbers - (->> nat-ints - (spec/conform! ::spec/nat-ints) - (mapv long)) +(defn- validated-numbers + "Realizes and validates the input once so encoding and retries can index it." + [numbers] + (when-not (sequential? numbers) + (throw (ex-info "Numbers must be a sequence of non-negative integers" {:numbers numbers}))) + (let [numbers (vec numbers)] + (doseq [number numbers] + (when-not #?(:clj (and (integer? number) (not (neg? number))) + :cljs (and (js/Number.isSafeInteger number) (<= 0 number))) + (throw (ex-info "Numbers must be non-negative integers within the platform range" {:number number})))) + numbers)) - result - (platform/encode instance numbers)] +(defn- encode-with-retries + "Tries successive prefix offsets until the padded ID passes the blocklist." + [^Sqids instance numbers] + (let [alphabet (.-alphabet instance) + min-length (.-min-length instance) + block-list-index (.-block-list-index instance) + offset (prefix-offset alphabet numbers) + size (count alphabet)] + (loop [attempt 0] + (when (> attempt size) + (throw (ex-info "Reached max attempts to re-generate the ID" + {:numbers numbers :attempts attempt}))) + (let [[id final-alphabet] (encode-unpadded numbers alphabet (rem (+ offset attempt) size)) + id (pad-to-min-length id min-length final-alphabet)] + (if (blocked-id? block-list-index id) + (recur (inc attempt)) + id))))) - (spec/conform! ::spec/sqid result))) +(defn encode + "Encodes a sequence of non-negative integers using an instance from `sqids`. -(defn decode - "Decodes a Sqid string into numbers. Arguments: + JVM integers may be arbitrarily large; ClojureScript numbers must be safe + integers (at most 9007199254740991). Invalid arguments or exhaustion of all + blocklist retries throw ex-info. An empty sequence encodes to an empty string." + [sqids-instance numbers] + (let [instance (require-instance sqids-instance) + numbers (validated-numbers numbers)] + (if (empty? numbers) + "" + (encode-with-retries instance numbers)))) - | name | description | - |--------|----------------------------------------------| - | `s` | A map returned by `org.sqids.clojure/sqids`. | - | `sqid` | A Sqid string. | +(defn- valid-characters? + "Checks the entire ID, including padding, against cached alphabet membership." + [alphabet-set ^String id] + (let [length (count id)] + (loop [index 0] + (or (= index length) + (and (contains? alphabet-set (.charAt id index)) + (recur (inc index))))))) - Returns an empty vector if `sqid` is empty. For particularly long Sqids, - results may be negative due to long overflow; these results should be - considered invalid." - [s sqid] - (let [instance - (spec/conform! ::spec/instance (:instance s)) +(defn- to-number + "Decodes a character range without allocating a substring." + [^String id ^String alphabet start end] + (let [base (dec (count alphabet))] + ;; A boxed initial value permits JVM promotion to BigInt on large chunks. + (loop [number (identity 0) + index start] + (if (= index end) + number + (let [digit (dec (.indexOf alphabet #?(:clj (int (.charAt id index)) + :cljs (.charAt id index)))) + number #?(:clj (+' (*' number base) digit) + :cljs (+ (* number base) digit))] + #?(:clj (recur number (inc index)) + :cljs (when (js/Number.isSafeInteger number) + (recur number (inc index))))))))) - id - (spec/conform! ::spec/sqid sqid) +(defn- decode-numbers + "Reads the digit chunks after the prefix; an empty chunk marks the start of padding." + [^String sqid ^String alphabet] + (let [size (count sqid) + offset (.indexOf alphabet #?(:clj (int (.charAt sqid 0)) + :cljs (.charAt sqid 0)))] + (loop [cursor 1 + alphabet (str/reverse (rotate-left alphabet offset)) + numbers (transient [])] + (let [separator (.charAt ^String alphabet 0) + separator-index (.indexOf sqid #?(:clj (int separator) :cljs separator) (int cursor)) + end (if (neg? separator-index) size separator-index)] + (if (= cursor end) + (persistent! numbers) + (if-some [number (to-number sqid alphabet cursor end)] + (let [numbers (conj! numbers number) + next-cursor (inc end)] + (if (< next-cursor size) + (recur (long next-cursor) (consistent-shuffle alphabet) numbers) + (persistent! numbers))) + [])))))) - numbers - (vec (platform/decode instance id))] +(defn decode + "Decodes a string using an instance from `sqids`, returning a vector. - (spec/conform! ::spec/ints numbers))) + Empty or malformed IDs return `[]`. ClojureScript also returns `[]` if any + decoded integer exceeds 9007199254740991. Non-string inputs throw ex-info." + [sqids-instance ^String sqid] + (let [^Sqids instance (require-instance sqids-instance)] + (when-not (string? sqid) + (throw (ex-info "Sqid must be a string" {:sqid sqid}))) + (if (or (empty? sqid) (not (valid-characters? (.-alphabet-set instance) sqid))) + [] + (decode-numbers sqid (.-alphabet instance))))) diff --git a/src/org/sqids/clojure/platform.clj b/src/org/sqids/clojure/platform.clj deleted file mode 100644 index 68a8bd6..0000000 --- a/src/org/sqids/clojure/platform.clj +++ /dev/null @@ -1,49 +0,0 @@ -(ns org.sqids.clojure.platform - (:refer-clojure :exclude [class]) - (:require - [clojure.spec.alpha :as s]) - (:import - (org.sqids - Sqids - Sqids$Builder))) - -(def default-alphabet - Sqids$Builder/DEFAULT_ALPHABET) - -(def default-min-length - Sqids$Builder/DEFAULT_MIN_LENGTH) - -(def default-block-list - Sqids$Builder/DEFAULT_BLOCK_LIST) - -(def class - Sqids) - -(defn sqids - [{:keys [alphabet min-length block-list]}] - (.. (Sqids/builder) - (alphabet alphabet) - (minLength min-length) - (blockList block-list) - build)) - -(defn encode - [^org.sqids.Sqids instance numbers] - (.encode instance numbers)) - -(defn decode - [^org.sqids.Sqids instance sqid] - (.decode instance sqid)) - -(defn byte-count - [^String s] - (count (.getBytes s))) - -(def max-value - Long/MAX_VALUE) - -(def max-value+1 - (inc' max-value)) - -(s/def ::ints-elem - int?) diff --git a/src/org/sqids/clojure/platform.cljs b/src/org/sqids/clojure/platform.cljs deleted file mode 100644 index d61e513..0000000 --- a/src/org/sqids/clojure/platform.cljs +++ /dev/null @@ -1,44 +0,0 @@ -(ns org.sqids.clojure.platform - (:require - ["sqids" :as sqids] - ["sqids$default" :as Sqids] - [clojure.spec.alpha :as s])) - -(def default-alphabet - sqids/defaultOptions.alphabet) - -(def default-min-length - sqids/defaultOptions.minLength) - -(def default-block-list - (js->clj sqids/defaultOptions.blocklist)) - -(def class - Sqids) - -(defn sqids - [{:keys [alphabet min-length block-list]}] - (Sqids. (clj->js {:alphabet alphabet - :minLength min-length - :blocklist block-list}))) - -(defn encode - [^js instance numbers] - (js->clj (.encode instance (clj->js numbers)))) - -(defn decode - [^js instance sqid] - (js->clj (.decode instance (clj->js sqid)))) - -(defn byte-count - [s] - (.-size (js/Blob. [s]))) - -(def max-value - js/Number.MAX_SAFE_INTEGER) - -(def max-value+1 - (inc max-value)) - -(s/def ::ints-elem - (s/and number? #(= % (long %)))) diff --git a/src/org/sqids/clojure/spec.cljc b/src/org/sqids/clojure/spec.cljc deleted file mode 100644 index 3b65a67..0000000 --- a/src/org/sqids/clojure/spec.cljc +++ /dev/null @@ -1,134 +0,0 @@ -(ns org.sqids.clojure.spec - (:require - [borkdude.dynaload :refer [dynaload]] - [clojure.set :as set] - [clojure.spec.alpha :as s] - [clojure.spec.gen.alpha :as gen] - [clojure.string :as string] - [org.sqids.clojure.platform :as platform])) - -(defn conform! - [spec input] - (let [conformed (s/conform spec input)] - (when (s/invalid? conformed) - (throw (ex-info "Invalid input" (s/explain-data spec input)))) - conformed)) - -;; TODO: Replace with constants from sqids-java once -;; https://github.com/sqids/sqids-java/pull/7 is merged -(def min-alphabet-length - 3) - -(def min-length-limit - 255) - -(defn ^:private sqids - [& args] - (apply (dynaload 'org.sqids.clojure/sqids) args)) - -(defn ^:private decode - [& args] - (apply (dynaload 'org.sqids.clojure/decode) args)) - -(defn ^:private encode - [& args] - (apply (dynaload 'org.sqids.clojure/encode) args)) - -(s/def ::alphabet-string - string?) - -(s/def ::alphabet-distinct - #(apply distinct? %)) - -(s/def ::alphabet-min-length - #(>= (count %) min-alphabet-length)) - -(s/def ::alphabet-no-multibyte - #(= (count %) (platform/byte-count %))) - -(s/def ::alphabet - (s/with-gen - (s/and ::alphabet-string - ::alphabet-distinct - ::alphabet-min-length - ::alphabet-no-multibyte) - #(->> {:min-elements min-alphabet-length} - ;; TODO: Once https://github.com/sqids/sqids-java/pull/10 is merged, - ;; change to: - ;; - ;; (gen/set (gen/fmap char (gen/choose 0 127))) - ;; - ;; because regex chars are currently treated improperly - (gen/set (gen/char-alphanumeric)) - (gen/fmap string/join)))) - -(s/def ::min-length - (s/int-in 0 (inc min-length-limit))) - -(s/def ::block-list - (s/coll-of string? :kind set?)) - -(s/def ::options - (s/keys :opt-un [::alphabet ::min-length ::block-list])) - -(s/def ::instance - #(instance? platform/class %)) - -(s/def ::sqids - (s/with-gen - (s/keys :req-un [::instance ::alphabet ::min-length ::block-list]) - #(gen/fmap sqids (s/gen ::options)))) - -(s/def ::nat-ints - (s/coll-of (s/int-in 0 platform/max-value+1) - :kind sequential?)) - -(s/def ::ints - (s/coll-of ::platform/ints-elem :kind vector?)) - -(s/def ::sqid - (s/with-gen - string? - (fn [] - (->> (gen/tuple (s/gen ::sqids) (s/gen ::nat-ints)) - (gen/fmap - (fn [[s nat-ints]] - (try - (encode s nat-ints) - (catch #?(:cljs :default :clj RuntimeException) _ - ;; TODO: Catch a more specific exception from sqids-java once - ;; present. - nil)))) - (gen/such-that some?))))) - -(s/fdef org.sqids.clojure/sqids - :args (s/alt :nullary (s/cat) - :unary (s/cat :options ::options)) - :ret ::sqids) - -(s/fdef org.sqids.clojure/encode - :args (s/cat :s ::sqids :nat-ints ::nat-ints) - :ret ::sqid - :fn (fn [info] - (let [{:keys [ret args]} info - {:keys [s nat-ints]} args] - (= nat-ints (decode s ret))))) - -(s/fdef org.sqids.clojure/decode - :args (s/cat :s ::sqids :sqid ::sqid) - :ret ::ints - :fn (fn [info] - (let [{:keys [ret args]} info] - (or - (not (s/valid? ::nat-ints ret)) - (let [{:keys [s sqid]} - args - - expected - (if (set/subset? (set sqid) (-> s :alphabet set)) - (->> ret - (encode s) - (decode s)) - [])] - - (= ret expected)))))) diff --git a/test-resources/org/sqids/clojure/sqids_spec_runner.mjs b/test-resources/org/sqids/clojure/sqids_spec_runner.mjs new file mode 100644 index 0000000..8ccb8af --- /dev/null +++ b/test-resources/org/sqids/clojure/sqids_spec_runner.mjs @@ -0,0 +1,67 @@ +import { readFileSync } from "node:fs"; +import { pathToFileURL } from "node:url"; + +const [requestFilePath, specDir] = process.argv.slice(2); + +if (!requestFilePath || !specDir) { + throw new Error("Expected request JSON path and sqids-spec checkout path"); +} + +const { default: Sqids } = await import( + pathToFileURL(`${specDir}/src/index.ts`).href +); + +const requests = JSON.parse(readFileSync(requestFilePath, "utf8")); + +const wireToOptions = (wireOptions = {}) => { + const options = {}; + + if ("alphabet" in wireOptions) { + options.alphabet = wireOptions.alphabet; + } + + if ("min-length" in wireOptions) { + options.minLength = wireOptions["min-length"]; + } + + if ("block-list" in wireOptions) { + options.blocklist = new Set(wireOptions["block-list"]); + } + + return options; +}; + +const evaluate = (request) => { + try { + const sqids = new Sqids(wireToOptions(request.options)); + + switch (request.op) { + case "roundtrip": { + const sqid = sqids.encode(request.numbers); + + return { + value: { + sqid, + numbers: sqids.decode(sqid), + }, + }; + } + + case "decode": + return { value: sqids.decode(request.sqid) }; + + case "encode": + return { value: sqids.encode(request.numbers) }; + + case "sqids": + return { value: "initialized" }; + + default: + throw new Error(`Unknown parity op: ${request.op}`); + } + } catch { + return { error: true }; + } +}; + +console.log(JSON.stringify(requests.map(evaluate))); diff --git a/test/org/sqids/clojure/alphabet_test.cljc b/test/org/sqids/clojure/alphabet_test.cljc deleted file mode 100644 index 82420a0..0000000 --- a/test/org/sqids/clojure/alphabet_test.cljc +++ /dev/null @@ -1,50 +0,0 @@ -(ns org.sqids.clojure.alphabet-test - (:require - [clojure.spec.alpha :as s] - [clojure.test :as t :refer [deftest is]] - [org.sqids.clojure :as sut] - [org.sqids.clojure.spec :as spec]) - #?(:clj - (:import - (clojure.lang - ExceptionInfo)))) - -(defn make - [alphabet] - (sut/sqids {:alphabet alphabet})) - -(defn alphabet-spec-fails - [alphabet root-spec] - (let [e - (is (thrown? ExceptionInfo (make alphabet))) - - {::s/keys [problems]} - (ex-data e)] - - (is (= 1 (count problems))) - (let [{:keys [via val]} (first problems)] - (is (= alphabet val)) - (is (= root-spec (last via)))))) - -(deftest simple-alphabet-test - (let [sqids (make "0123456789abcdef") - numbers [1 2 3] - id "489158"] - (is (= id (sut/encode sqids numbers))) - (is (= numbers (sut/decode sqids id))))) - -(deftest short-alphabet-test - (let [sqids (make "abc") - numbers [1 2 3]] - (is (= numbers (->> numbers - (sut/encode sqids) - (sut/decode sqids)))))) - -(deftest multibyte-tests - (alphabet-spec-fails "ë1092" ::spec/alphabet-no-multibyte)) - -(deftest repeating-alphabet-characters - (alphabet-spec-fails "aabcdefg" ::spec/alphabet-distinct)) - -(deftest too-short-of-an-alphabet - (alphabet-spec-fails "ab" ::spec/alphabet-min-length)) diff --git a/test/org/sqids/clojure/block_list_test.cljc b/test/org/sqids/clojure/block_list_test.cljc deleted file mode 100644 index c52dd0b..0000000 --- a/test/org/sqids/clojure/block_list_test.cljc +++ /dev/null @@ -1,71 +0,0 @@ -(ns org.sqids.clojure.block-list-test - (:require - [clojure.test :as t :refer [deftest is]] - [org.sqids.clojure :as sut])) - -(defn make - [block-list] - (sut/sqids {:block-list block-list})) - -(deftest block-list-test - (let [sqids (sut/sqids) - numbers [4572721]] - (is (= numbers (sut/decode sqids "aho1e"))) - (is (= "JExTR" (sut/encode sqids numbers))))) - -(deftest empty-block-list-test - (let [sqids (make #{}) - numbers [4572721]] - (is (= numbers (sut/decode sqids "aho1e"))) - (is (= "aho1e" (sut/encode sqids numbers))))) - -(deftest non-empty-block-list-test - (let [sqids (make #{"ArUO"})] - (let [numbers [4572721]] - (is (= numbers (sut/decode sqids "aho1e")) - (= "aho1e" (sut/encode sqids numbers)))) - (let [numbers [100000]] - (is (= numbers (sut/decode sqids "ArUO"))) - (is (= "QyG4" (sut/encode sqids numbers))) - (is (= numbers (sut/decode sqids "QyG4")))))) - -(deftest encode-block-list - (let [sqids (make #{"JSwXFaosAN" ; normal result of 1st encoding, let's block that word on purpose - "OCjV9JK64o" ; result of 2nd encoding - "rBHf" ; result of 3rd encoding is `4rBHfOiqd3`, let's block a substring - "79SM" ; result of 4th encoding is `dyhgw479SM`, let's block the postfix - "7tE6" ; result of 4th encoding is `7tE6jdAHLe`, let's block the prefix - }) - numbers [1000000 2000000]] - (is (= "1aYeB7bRUt" (sut/encode sqids numbers))) - (is (= numbers (sut/decode sqids "1aYeB7bRUt"))))) - -(deftest decode-block-list - (let [sqids (make #{"86Rf07" "se8ojk" "ARsz1p" "Q8AI49" "5sQRZO"}) - numbers [1 2 3]] - (is (= numbers (sut/decode sqids "86Rf07"))) - (is (= numbers (sut/decode sqids "se8ojk"))) - (is (= numbers (sut/decode sqids "ARsz1p"))) - (is (= numbers (sut/decode sqids "Q8AI49"))) - (is (= numbers (sut/decode sqids "5sQRZO"))))) - -(deftest short-block-list - (let [sqids (make #{"pnd"}) - numbers [1000]] - (is (= numbers (->> numbers - (sut/encode sqids) - (sut/decode sqids)))))) - -(deftest lowercase-block-list - (let [sqids (sut/sqids {:alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - :block-list #{"sxnzkl"}}) - numbers [1 2 3]] - (is (= "IBSHOZ" (sut/encode sqids numbers))) - (is (= numbers (sut/decode sqids "IBSHOZ"))))) - -(deftest max-block-list - (let [sqids (sut/sqids {:alphabet "abc" - :min-length 3 - :block-list #{"cab" "abc" "bca"}})] - (is (thrown? #?(:cljs js/Error :clj RuntimeException) - (sut/encode sqids [0]))))) diff --git a/test/org/sqids/clojure/encoding_test.cljc b/test/org/sqids/clojure/encoding_test.cljc deleted file mode 100644 index 6b57ef8..0000000 --- a/test/org/sqids/clojure/encoding_test.cljc +++ /dev/null @@ -1,71 +0,0 @@ -(ns org.sqids.clojure.encoding-test - (:require - [clojure.spec.alpha :as s] - [clojure.test :as t :refer [deftest is]] - [org.sqids.clojure :as sut] - [org.sqids.clojure.platform :as platform] - [org.sqids.clojure.spec :as spec]) - #?(:clj - (:import - (clojure.lang - ExceptionInfo)))) - -(def sqids - (sut/sqids)) - -(deftest simple-test - (let [numbers [1 2 3] - id "86Rf07"] - (is (= id (sut/encode sqids numbers))) - (is (= numbers (sut/decode sqids id))))) - -(deftest different-inputs-test - (let [numbers [0 0 0 1 2 3 100 1000 100000 1000000 platform/max-value]] - (is (= numbers (->> numbers - (sut/encode sqids) - (sut/decode sqids)))))) - -(deftest incremental-number-test - (doseq [[id & numbers] [["bM" 0] ["Uk" 1] ["gb" 2] ["Ef" 3] ["Vq" 4] - ["uw" 5] ["OI" 6] ["AX" 7] ["p6" 8] ["nJ" 9]]] - (is (= id (sut/encode sqids numbers))) - (is (= numbers (sut/decode sqids id))))) - -(deftest incremental-numbers-test - (doseq [[id & numbers] - [["SvIz" 0 0] ["n3qa" 0 1] ["tryF" 0 2] ["eg6q" 0 3] ["rSCF" 0 4] - ["sR8x" 0 5] ["uY2M" 0 6] ["74dI" 0 7] ["30WX" 0 8] ["moxr" 0 9]]] - (is (= id (sut/encode sqids numbers))) - (is (= numbers (sut/decode sqids id))))) - -(deftest multi-input-test - (let [numbers (range 0 100)] - (is (= numbers (->> numbers - (sut/encode sqids) - (sut/decode sqids)))))) - -(deftest encode-no-numbers-test - (is (= "" (sut/encode sqids [])))) - -(deftest decode-empty-string-test - (is (= [] (sut/decode sqids "")))) - -(deftest decode-invalid-character-test - (is (= [] (sut/decode sqids "*")))) - -(defn nat-ints-spec-fails - [number] - (let [e - (is (thrown? ExceptionInfo (sut/encode sqids [number]))) - - {::s/keys [problems]} - (ex-data e)] - - (is (= 1 (count problems))) - (let [{:keys [via val]} (first problems)] - (is (= number val)) - (is (= ::spec/nat-ints (last via)))))) - -(deftest encode-out-of-range-numbers-test - (nat-ints-spec-fails -1) - (nat-ints-spec-fails platform/max-value+1)) diff --git a/test/org/sqids/clojure/min_length_test.cljc b/test/org/sqids/clojure/min_length_test.cljc deleted file mode 100644 index 45cf8da..0000000 --- a/test/org/sqids/clojure/min_length_test.cljc +++ /dev/null @@ -1,68 +0,0 @@ -(ns org.sqids.clojure.min-length-test - (:require - [clojure.test :as t :refer [deftest is]] - [org.sqids.clojure :as sut])) - -(def min-length - (count "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")) - -(defn make - [min-length] - (sut/sqids {:min-length min-length})) - -(def sqids - (make min-length)) - -(deftest simple-test - (let [numbers [1 2 3] - id "86Rf07xd4zBmiJXQG6otHEbew02c3PWsUOLZxADhCpKj7aVFv9I8RquYrNlSTM"] - (is (= id (sut/encode sqids numbers))) - (is (= numbers (sut/decode sqids id))))) - -(deftest incremental-test - (let [numbers [1 2 3]] - (doseq [[min-length id] - [[6 "86Rf07"] - [7 "86Rf07x"] - [8 "86Rf07xd"] - [9 "86Rf07xd4"] - [10 "86Rf07xd4z"] - [11 "86Rf07xd4zB"] - [12 "86Rf07xd4zBm"] - [13 "86Rf07xd4zBmi"] - [(+ min-length 0) "86Rf07xd4zBmiJXQG6otHEbew02c3PWsUOLZxADhCpKj7aVFv9I8RquYrNlSTM"] - [(+ min-length 1) "86Rf07xd4zBmiJXQG6otHEbew02c3PWsUOLZxADhCpKj7aVFv9I8RquYrNlSTMy"] - [(+ min-length 2) "86Rf07xd4zBmiJXQG6otHEbew02c3PWsUOLZxADhCpKj7aVFv9I8RquYrNlSTMyf"] - [(+ min-length 3) "86Rf07xd4zBmiJXQG6otHEbew02c3PWsUOLZxADhCpKj7aVFv9I8RquYrNlSTMyf1"]]] - (let [sqids (make min-length)] - (is (= id (sut/encode sqids numbers))) - (is (= numbers (sut/decode sqids id))))))) - -(deftest incremental-numbers-test - (doseq [[id & numbers] - [["SvIzsqYMyQwI3GWgJAe17URxX8V924Co0DaTZLtFjHriEn5bPhcSkfmvOslpBu" 0 0] - ["n3qafPOLKdfHpuNw3M61r95svbeJGk7aAEgYn4WlSjXURmF8IDqZBy0CT2VxQc" 0 1] - ["tryFJbWcFMiYPg8sASm51uIV93GXTnvRzyfLleh06CpodJD42B7OraKtkQNxUZ" 0 2] - ["eg6ql0A3XmvPoCzMlB6DraNGcWSIy5VR8iYup2Qk4tjZFKe1hbwfgHdUTsnLqE" 0 3] - ["rSCFlp0rB2inEljaRdxKt7FkIbODSf8wYgTsZM1HL9JzN35cyoqueUvVWCm4hX" 0 4] - ["sR8xjC8WQkOwo74PnglH1YFdTI0eaf56RGVSitzbjuZ3shNUXBrqLxEJyAmKv2" 0 5] - ["uY2MYFqCLpgx5XQcjdtZK286AwWV7IBGEfuS9yTmbJvkzoUPeYRHr4iDs3naN0" 0 6] - ["74dID7X28VLQhBlnGmjZrec5wTA1fqpWtK4YkaoEIM9SRNiC3gUJH0OFvsPDdy" 0 7] - ["30WXpesPhgKiEI5RHTY7xbB1GnytJvXOl2p0AcUjdF6waZDo9Qk8VLzMuWrqCS" 0 8] - ["moxr3HqLAK0GsTND6jowfZz3SUx7cQ8aC54Pl1RbIvFXmEJuBMYVeW9yrdOtin" 0 9]]] - (is (= id (sut/encode sqids numbers))) - (is (= numbers (sut/decode sqids id))))) - -(deftest min-lengths-test - (doseq [min-length [0 1 5 10 min-length]] - (let [sqids (make min-length)] - (doseq [numbers [[0] - [0 0 0 0 0] - [1 2 3 4 5 6 7 8 9 10] - [100 200 300] - [1000 2000 30000] - [(long #?(:clj Integer/MAX_VALUE - :cljs js/Number.MAX_SAFE_INTEGER))]]] - (let [id (sut/encode sqids numbers)] - (is (<= min-length (count id))) - (is (= numbers (sut/decode sqids id)))))))) diff --git a/test/org/sqids/clojure/parity.clj b/test/org/sqids/clojure/parity.clj new file mode 100644 index 0000000..efa3c79 --- /dev/null +++ b/test/org/sqids/clojure/parity.clj @@ -0,0 +1,157 @@ +(ns org.sqids.clojure.parity + (:require + [clojure.string :as str] + [clojure.test.check.generators :as gen] + [org.sqids.clojure :as sut])) + +(def js-safe-int-max + "Largest non-negative integer shared with the JavaScript reference." + 9007199254740991) + +(defn fixed-requests + "Returns curated success and rejection cases from the shared Sqids contract." + [] + [{:id "default-simple" + :op "roundtrip" + :options {} + :numbers [1 2 3]} + {:id "default-blocklist" + :op "roundtrip" + :options {} + :numbers [4572721]} + {:id "custom-alphabet" + :op "roundtrip" + :options {:alphabet "0123456789abcdef"} + :numbers [1 2 3]} + {:id "custom-min-length" + :op "roundtrip" + :options {:min-length 10} + :numbers [1 2 3]} + {:id "custom-block-list" + :op "roundtrip" + :options {:block-list ["ArUO"]} + :numbers [100000]} + {:id "invalid-character" + :op "decode" + :options {} + :sqid "*"} + {:id "repeated-blocklist-retries" + :op "roundtrip" + :options {:block-list ["JSwXFaosAN" "OCjV9JK64o" "rBHf" "79SM" "7tE6"]} + :numbers [1000000 2000000]} + {:id "blocklist-uppercase-alphabet" + :op "roundtrip" + :options {:alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZ" :block-list ["sxnzkl"]} + :numbers [1 2 3]} + {:id "blocklist-retry-exhaustion" + :op "encode" + :options {:alphabet "abc" :min-length 3 :block-list ["cab" "abc" "bca"]} + :numbers [0] + :expect-error? true} + {:id "negative-number" + :op "encode" + :options {} + :numbers [-1] + :expect-error? true}]) + +(defn boundary-requests + "Exercises safe-integer edges across small alphabets and padding boundaries." + [] + (vec + (for [[alphabet-index alphabet-option] + (map-indexed vector [(:alphabet sut/default-options) + "abc" "0123456789abcdef" "\u0000\t .[]\\" + (apply str (map char (range 128)))]) + minimum-length [0 1 62 255] + [numbers-index numbers] + (map-indexed vector [[] [0] [js-safe-int-max] + [0 1 255 256 4294967295 4294967296 + 9007199254740990 js-safe-int-max]])] + {:id (format "boundary-%d-%d-%d" alphabet-index minimum-length numbers-index) + :op "roundtrip" + :options {:alphabet alphabet-option :min-length minimum-length :block-list []} + :numbers numbers}))) + +(defn noncanonical-requests + "Checks alternate prefixes, truncation, trailing padding and blocked ID decoding." + [] + (mapv (fn [index sqid] + {:id (format "noncanonical-%02d" index) + :op "decode" + :options {:block-list ["86Rf07" "se8ojk" "ARsz1p" "Q8AI49" "5sQRZO"]} + :sqid sqid}) + (range) + ["" "8" "86" "86Rf" "86Rf07" "se8ojk" "ARsz1p" "Q8AI49" "5sQRZO" + "86Rf07xd4z" "86Rf07xd4zBmiJXQG6rw1fC9tZ0sbeA2nvIhU3Oq5V7"])) + +(defn invalid-options-requests + "Requires both implementations to reject invalid shared constructor options." + [] + (mapv (fn [index options] + {:id (format "invalid-options-%02d" index) + :op "sqids" + :options options + :expect-error? true}) + (range) + [{:alphabet ""} {:alphabet "ab"} {:alphabet "aab"} {:alphabet "abcé"} + {:min-length -1} {:min-length 256}])) + +(def ^:private options-generator + "Generates ASCII alphabets, padding and alphabet-compatible blocklist words." + (gen/bind + (gen/one-of [(gen/return (:alphabet sut/default-options)) + (gen/fmap #(apply str %) (gen/vector-distinct + (gen/elements (mapv char (range 128))) + {:min-elements 3 :max-elements 128}))]) + (fn [alphabet] + (gen/fmap + (fn [[minimum words]] + {:alphabet alphabet :min-length minimum :block-list words}) + (gen/tuple (gen/choose 0 255) + (gen/vector + (gen/fmap #(apply str %) + (gen/vector (gen/elements (vec (str/lower-case alphabet))) 0 12)) + 0 8)))))) + +(def ^:private numbers-generator + "Exercises arbitrary safe integers with extra weight on arithmetic boundaries." + (gen/vector + (gen/frequency + [[3 (gen/elements [0 1 2 255 256 65535 65536 2147483647 2147483648 + 4294967295 4294967296 9007199254740990 js-safe-int-max])] + [7 (gen/large-integer* {:min 0 :max js-safe-int-max})]]) + 0 8)) + +(defn- samples + "Produces a reproducible sequence using a separate seed for each case." + [generator n seed] + (mapv #(gen/generate generator 12 (+ seed %)) (range n))) + +(defn requests + "Builds the single corpus evaluated by JVM, compiled CLJS and sqids-spec." + [] + (into [] cat + [(fixed-requests) + (boundary-requests) + (noncanonical-requests) + (invalid-options-requests) + (map-indexed + (fn [index [options numbers]] + {:id (str "generated-roundtrip-" index) :op "roundtrip" + :options options :numbers numbers}) + (samples (gen/tuple options-generator numbers-generator) 384 42000)) + (map-indexed + (fn [index [options sqid]] + {:id (str "generated-decode-" index) :op "decode" :options options :sqid sqid}) + (samples + (gen/bind options-generator + (fn [options] + ;; Seven digits in the largest alphabet remain JS-safe. + (gen/fmap #(vector options (apply str %)) + (gen/vector (gen/elements (vec (:alphabet options))) 0 8)))) + 256 44000)) + (map-indexed + (fn [index options] + {:id (str "invalid-character-" index) :op "decode" + :options options :sqid (str (subs (:alphabet options) 0 (mod index 3)) "\u0100")}) + (samples options-generator 32 43000))])) diff --git a/test/org/sqids/clojure/parity_evaluator.cljc b/test/org/sqids/clojure/parity_evaluator.cljc new file mode 100644 index 0000000..1e8ce82 --- /dev/null +++ b/test/org/sqids/clojure/parity_evaluator.cljc @@ -0,0 +1,18 @@ +(ns org.sqids.clojure.parity-evaluator + (:require + [org.sqids.clojure :as sqids])) + +(defn response + "Evaluates one JSON-shaped request on either platform; exception text is language-specific." + [{:keys [op options numbers sqid]}] + (try + (let [config (sqids/sqids (cond-> options + (contains? options :block-list) (update :block-list set)))] + {:value (case op + "roundtrip" (let [id (sqids/encode config numbers)] + {:sqid id :numbers (sqids/decode config id)}) + "encode" (sqids/encode config numbers) + "decode" (sqids/decode config sqid) + "sqids" "initialized")}) + (catch #?(:clj Exception :cljs :default) _ + {:error true}))) diff --git a/test/org/sqids/clojure/parity_node.cljs b/test/org/sqids/clojure/parity_node.cljs new file mode 100644 index 0000000..b9c177c --- /dev/null +++ b/test/org/sqids/clojure/parity_node.cljs @@ -0,0 +1,12 @@ +(ns org.sqids.clojure.parity-node + (:require + [org.sqids.clojure.parity-evaluator :as evaluator])) + +(defn -main + "Reads the shared corpus from JSON and emits this compiled implementation's results." + [request-path] + (let [^js fs (js/require "fs") + requests (js->clj (js/JSON.parse (.readFileSync fs request-path "utf8")) :keywordize-keys true)] + (.log js/console (js/JSON.stringify (clj->js (mapv evaluator/response requests)))))) + +(set! *main-cli-fn* -main) diff --git a/test/org/sqids/clojure/parity_runner.clj b/test/org/sqids/clojure/parity_runner.clj new file mode 100644 index 0000000..e9d7a84 --- /dev/null +++ b/test/org/sqids/clojure/parity_runner.clj @@ -0,0 +1,57 @@ +(ns org.sqids.clojure.parity-runner + (:require + [cljs.build.api :as cljs] + [clojure.data.json :as json] + [clojure.java.io :as io] + [clojure.java.shell :as shell] + [clojure.test :as t] + [org.sqids.clojure.parity :as parity] + [org.sqids.clojure.parity-evaluator :as evaluator])) + +(set! *warn-on-reflection* true) + +(defn- command-results + "Runs a JSON-producing process, failing immediately if the runner fails." + [& args] + (let [{:keys [exit out err]} (apply shell/sh args)] + (when-not (zero? exit) + (throw (ex-info "Parity runner failed" {:command args :exit exit :out out :err err}))) + (json/read-str out :key-fn keyword))) + +(defn- check-results + "Checks successful values, expected failures and independent roundtrip inputs." + [platform requests expected actual] + (t/is (= (count requests) (count expected) (count actual)) platform) + (doseq [[request reference result] (map vector requests expected actual)] + (t/testing (str platform " " (:id request)) + (t/is (= reference result)) + (t/is (= (boolean (:expect-error? request)) (boolean (:error result)))) + (when (= "roundtrip" (:op request)) + (t/is (= (:numbers request) (get-in result [:value :numbers]))))))) + +(defn run + "Compiles CLJS with advanced optimization and checks both platforms against upstream." + [_] + (let [spec-dir (or (System/getenv "SQIDS_SPEC_DIR") + (throw (ex-info "Set SQIDS_SPEC_DIR to a sqids-spec checkout" {}))) + requests (parity/requests) + request-path (.getAbsolutePath (io/file "target/parity/requests.json")) + runner-path (.getAbsolutePath (io/file "test-resources/org/sqids/clojure/sqids_spec_runner.mjs"))] + (println "Compiling ClojureScript parity runner with advanced optimization...") + (cljs/build {:main 'org.sqids.clojure.parity-node + :target :nodejs + :optimizations :advanced + :infer-externs true + :output-dir "target/parity/cljs-advanced" + :output-to "target/parity/runner.js"}) + (spit request-path (json/write-str requests)) + (let [reference (command-results "npx" "--no-install" "vite-node" "--script" + runner-path request-path spec-dir :dir spec-dir) + node (command-results "node" "target/parity/runner.js" request-path)] + (binding [t/*report-counters* (ref t/*initial-report-counters*)] + (check-results "JVM" requests reference (mapv evaluator/response requests)) + (check-results "CLJS" requests reference node) + (println (count requests) "requests per platform;" @t/*report-counters*) + (when (pos? (+ (:fail @t/*report-counters*) (:error @t/*report-counters*))) + (throw (ex-info "Sqids parity failed" @t/*report-counters*))))) + (shutdown-agents))) diff --git a/test/org/sqids/clojure/spec_test.cljc b/test/org/sqids/clojure/spec_test.cljc deleted file mode 100644 index ef6fad6..0000000 --- a/test/org/sqids/clojure/spec_test.cljc +++ /dev/null @@ -1,39 +0,0 @@ -(ns org.sqids.clojure.spec-test - (:require - [clojure.spec.alpha :as s] - [clojure.spec.test.alpha :as stest] - [clojure.test :as t :refer [deftest]] - [clojure.test.check] - [clojure.test.check.properties] - [expound.alpha :as expound] - [org.sqids.clojure] - [org.sqids.clojure.spec])) - -(defn check - [results] - (doseq [result results] - (let [{:keys [failure] :as abbrev} - (stest/abbrev-result result) - - message - (binding [s/*explain-out* expound/printer] - (expound/explain-result-str result)) - - expected - (->> abbrev :spec rest (apply hash-map) :ret) - - actual - (if (instance? #?(:cljs js/Error :clj Throwable) failure) - failure - (::stest/val failure))] - - (t/do-report {:type (if failure :fail :pass) - :message message - :expected expected - :actual actual})))) - -(deftest sqids-test - (check (stest/check `org.sqids.clojure/sqids))) - -(deftest decode-test - (check (stest/check `org.sqids.clojure/decode))) diff --git a/test/org/sqids/clojure_test.cljc b/test/org/sqids/clojure_test.cljc new file mode 100644 index 0000000..7e9aa26 --- /dev/null +++ b/test/org/sqids/clojure_test.cljc @@ -0,0 +1,486 @@ +(ns org.sqids.clojure-test + (:require + #?(:clj [clojure.edn :as edn] + :cljs [cljs.reader :as edn]) + #?(:clj [clojure.java.io]) + [clojure.string :as str] + [clojure.test :as t] + [clojure.test.check :as check] + [clojure.test.check.generators :as gen] + [clojure.test.check.properties :as prop] + [org.sqids.clojure :as sut]) + #?(:clj + (:import + (java.util + Locale)))) + +(t/deftest options-can-be-reused-and-serialized-test + (doseq [options [sut/default-options + {:alphabet "abcdefg" + :min-length 12 + :block-list #{"ABC" "ignore-this"}}]] + (let [instance (sut/sqids options) + id (sut/encode instance [1 2 3])] + (doseq [saved-options [options (edn/read-string (pr-str options))]] + (let [rebuilt (sut/sqids saved-options)] + (t/is (= id (sut/encode rebuilt [1 2 3]))) + (t/is (= [1 2 3] (sut/decode rebuilt id)))))))) + +(t/deftest changed-options-are-applied-by-construction-test + (let [options sut/default-options + config (sut/sqids options) + changed (sut/sqids (assoc options :block-list #{"86Rf07"}))] + (t/is (= "se8ojk" (sut/encode changed [1 2 3]))) + (t/is (= "86Rf07" (sut/encode config [1 2 3]))) + (t/is (= [1 2 3] (sut/decode changed "se8ojk"))))) + +(t/deftest returned-instance-is-not-associative-test + (let [instance (sut/sqids)] + (t/is (false? (map? instance))) + (t/is (false? (associative? instance))) + (doseq [option-key [:min-length :instance]] + (t/is (thrown? #?(:clj ClassCastException :cljs js/Error) + (assoc instance option-key nil)))))) + +(t/deftest explicit-construction-is-required-test + (doseq [config [nil {} sut/default-options {:instance {}} {:instance (sut/sqids)}]] + (doseq [numbers [[] [1 2 3]]] + (t/is (thrown? #?(:clj clojure.lang.ExceptionInfo :cljs cljs.core/ExceptionInfo) + (sut/encode config numbers)))) + (doseq [id ["" "86Rf07"]] + (t/is (thrown? #?(:clj clojure.lang.ExceptionInfo :cljs cljs.core/ExceptionInfo) + (sut/decode config id)))))) + +(t/deftest invalid-options-test + (doseq [options [nil [] "options" 123 (sut/sqids) + {:alphabet nil} {:min-length nil} {:block-list nil} + {:block-list []} {:block-list #{nil}} {:block-list #{1}}]] + (t/is (thrown? #?(:clj clojure.lang.ExceptionInfo :cljs cljs.core/ExceptionInfo) + (sut/sqids options)) + (pr-str options)))) + +(def ^:private default-instance + "Default Sqids instance used by encoding tests." + (sut/sqids)) + +(t/deftest canonical-id-test + (let [numbers [1 2 3] + id "86Rf07"] + (t/is (= id (sut/encode default-instance numbers))) + (t/is (= numbers (sut/decode default-instance id))))) + +(t/deftest different-inputs-test + (let [numbers [0 0 0 1 2 3 100 1000 100000 1000000 #?(:clj 9007199254740991N :cljs js/Number.MAX_SAFE_INTEGER)]] + (t/is (= numbers (->> numbers + (sut/encode default-instance) + (sut/decode default-instance)))))) + +(t/deftest incremental-number-test + (doseq [[id & numbers] [["bM" 0] ["Uk" 1] ["gb" 2] ["Ef" 3] ["Vq" 4] + ["uw" 5] ["OI" 6] ["AX" 7] ["p6" 8] ["nJ" 9]]] + (t/is (= id (sut/encode default-instance numbers))) + (t/is (= numbers (sut/decode default-instance id))))) + +(t/deftest incremental-numbers-same-index-0-test + (doseq [[id & numbers] + [["SvIz" 0 0] ["n3qa" 0 1] ["tryF" 0 2] ["eg6q" 0 3] ["rSCF" 0 4] + ["sR8x" 0 5] ["uY2M" 0 6] ["74dI" 0 7] ["30WX" 0 8] ["moxr" 0 9]]] + (t/is (= id (sut/encode default-instance numbers))) + (t/is (= numbers (sut/decode default-instance id))))) + +(t/deftest incremental-numbers-same-index-1-test + (doseq [[id & numbers] + [["SvIz" 0 0] ["nWqP" 1 0] ["tSyw" 2 0] ["eX68" 3 0] ["rxCY" 4 0] + ["sV8a" 5 0] ["uf2K" 6 0] ["7Cdk" 7 0] ["3aWP" 8 0] ["m2xn" 9 0]]] + (t/is (= id (sut/encode default-instance numbers))) + (t/is (= numbers (sut/decode default-instance id))))) + +(t/deftest multi-input-test + (let [numbers (range 0 100)] + (t/is (= numbers (->> numbers + (sut/encode default-instance) + (sut/decode default-instance)))))) + +(t/deftest many-numbers-roundtrip-test + (let [config (sut/sqids {:alphabet "abc" :block-list #{}}) + numbers (vec (repeat 4096 0)) + id (sut/encode config numbers)] + (t/is (= 8192 (count id))) + (t/is (= numbers (sut/decode config id))))) + +(t/deftest encode-no-numbers-test + (t/is (= "" (sut/encode default-instance [])))) + +(t/deftest decode-empty-string-test + (t/is (= [] (sut/decode default-instance "")))) + +(t/deftest decode-invalid-character-test + (t/is (= [] (sut/decode default-instance "*")))) + +#?(:cljs + (t/deftest decode-overflow-safe-integer-test + ;; Encoded on CLJ from [9007199254740992N], which exceeds JS MAX_SAFE_INTEGER. + (t/is (= [] (sut/decode default-instance "pup591lWlB"))))) + +(t/deftest invalid-numbers-test + (doseq [numbers [nil 1 "123" #{1 2} {:a 1} [-1] [1.5] [##Inf] [##NaN] + [nil] [true] ["1"] [1 2 -3]]] + (t/is (thrown? #?(:clj clojure.lang.ExceptionInfo :cljs cljs.core/ExceptionInfo) + (sut/encode default-instance numbers)) + (pr-str numbers))) + #?(:cljs + (t/is (thrown? cljs.core/ExceptionInfo + (sut/encode default-instance [9007199254740992]))))) + +(t/deftest sequential-inputs-test + (doseq [numbers [[1 2 3] '(1 2 3) (map inc (range 3))]] + (t/is (= "86Rf07" (sut/encode default-instance numbers))))) + +(t/deftest caller-exceptions-propagate-test + (let [cause (ex-info "Caller sequence failed" {:input :failed}) + numbers (map (fn [_] (throw cause)) [1]) + caught (try + (sut/encode default-instance numbers) + nil + (catch #?(:clj Exception :cljs :default) error + error))] + (t/is (identical? cause caught)))) + +#?(:clj + (t/deftest big-integer-roundtrip-test + (let [numbers [0N + 1N + 18446744073709551616N + 340282366920938463463374607431768211455N + 12345678901234567890123456789012345678901234567890N] + id (sut/encode default-instance numbers)] + (t/is (string? id)) + (t/is (= numbers (sut/decode default-instance id)))))) + +#?(:clj + (t/deftest shared-configuration-is-thread-safe-test + (let [config (sut/sqids) + jobs (doall + (repeatedly 8 + #(future + (every? (fn [_] + (and (= "86Rf07" (sut/encode config [1 2 3])) + (= [1 2 3] (sut/decode config "86Rf07")))) + (range 100)))))] + (t/is (every? deref jobs))))) + +(t/deftest decode-cursor-boundaries-test + (let [config (sut/sqids)] + (doseq [[id expected] [["" []] ["8" []] ["0" []] ["00" [60]] + ["86Rf07" [1 2 3]] + ["86Rf07x" [1 2 3]] + ["86Rf07xd4z" [1 2 3]]]] + (t/is (= expected (sut/decode config id)) id)))) + +(t/deftest invalid-characters-test + (let [config (sut/sqids)] + (doseq [id ["*" "*86Rf07" "86*Rf07" "86Rf07*" "86Rf07xd4z*" "😀" "ë"]] + (t/is (= [] (sut/decode config id)) id)))) + +(t/deftest non-string-inputs-test + (let [config (sut/sqids)] + (doseq [id [nil 1 :id [\8 \6] true]] + (t/is (thrown? #?(:clj clojure.lang.ExceptionInfo :cljs cljs.core/ExceptionInfo) + (sut/decode config id)) + (pr-str id))))) + +(t/deftest javascript-safe-integer-boundary-test + (let [config (sut/sqids)] + ;; The second ID encodes MAX_SAFE_INTEGER + 1; JVM arithmetic retains it, + ;; while JavaScript must reject it rather than silently round it. + (t/is (= [9007199254740991] (sut/decode config (sut/encode config [9007199254740991])))) + (t/is (= #?(:clj [9007199254740992N] :cljs []) + (sut/decode config "pup591lWlB"))))) + +(t/deftest simple-alphabet-test + (let [sqids (sut/sqids {:alphabet "0123456789abcdef"}) + numbers [1 2 3] + id "489158"] + (t/is (= id (sut/encode sqids numbers))) + (t/is (= numbers (sut/decode sqids id))))) + +(t/deftest short-alphabet-test + (let [sqids (sut/sqids {:alphabet "abc"}) + numbers [1 2 3]] + (t/is (= numbers (->> numbers + (sut/encode sqids) + (sut/decode sqids)))))) + +(t/deftest long-alphabet-test + (let [alphabet "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+|{}[];:'\"/?.>,<`~" + sqids (sut/sqids {:alphabet alphabet}) + numbers [1 2 3]] + (t/is (= numbers (->> numbers + (sut/encode sqids) + (sut/decode sqids)))))) + +(t/deftest invalid-alphabets-test + (doseq [alphabet [nil 123 [:a :b :c] "ë1092" "ab\u0080" "ab\ud800" "ab\udfff" + "abc😀" "aabcdefg" "" "a" "ab"]] + (t/is (thrown? #?(:clj clojure.lang.ExceptionInfo :cljs cljs.core/ExceptionInfo) + (sut/sqids {:alphabet alphabet})) + (pr-str alphabet)))) + +(t/deftest full-ascii-alphabet-test + (let [alphabet (apply str (map char (range 128))) + config (sut/sqids {:alphabet alphabet :block-list #{}}) + numbers [0 127 128 16384]] + (t/is (= numbers (sut/decode config (sut/encode config numbers)))))) + +(def ^:private default-alphabet-length + "Default alphabet length used in padding boundary tests." + (count "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")) + +(def ^:private padded-instance + "Sqids instance padded to the default alphabet length." + (sut/sqids {:min-length default-alphabet-length})) + +(t/deftest padded-id-test + (let [numbers [1 2 3] + id "86Rf07xd4zBmiJXQG6otHEbew02c3PWsUOLZxADhCpKj7aVFv9I8RquYrNlSTM"] + (t/is (= id (sut/encode padded-instance numbers))) + (t/is (= numbers (sut/decode padded-instance id))))) + +(t/deftest incremental-min-length-test + (let [numbers [1 2 3]] + (doseq [[target-min-length expected-id] + [[6 "86Rf07"] + [7 "86Rf07x"] + [8 "86Rf07xd"] + [9 "86Rf07xd4"] + [10 "86Rf07xd4z"] + [11 "86Rf07xd4zB"] + [12 "86Rf07xd4zBm"] + [13 "86Rf07xd4zBmi"] + [(+ default-alphabet-length 0) "86Rf07xd4zBmiJXQG6otHEbew02c3PWsUOLZxADhCpKj7aVFv9I8RquYrNlSTM"] + [(inc default-alphabet-length) "86Rf07xd4zBmiJXQG6otHEbew02c3PWsUOLZxADhCpKj7aVFv9I8RquYrNlSTMy"] + [(+ default-alphabet-length 2) "86Rf07xd4zBmiJXQG6otHEbew02c3PWsUOLZxADhCpKj7aVFv9I8RquYrNlSTMyf"] + [(+ default-alphabet-length 3) "86Rf07xd4zBmiJXQG6otHEbew02c3PWsUOLZxADhCpKj7aVFv9I8RquYrNlSTMyf1"]]] + (let [sqids-config (sut/sqids {:min-length target-min-length})] + (t/is (= expected-id (sut/encode sqids-config numbers))) + (t/is (= numbers (sut/decode sqids-config expected-id))))))) + +(t/deftest padded-incremental-numbers-test + (doseq [[id & numbers] + [["SvIzsqYMyQwI3GWgJAe17URxX8V924Co0DaTZLtFjHriEn5bPhcSkfmvOslpBu" 0 0] + ["n3qafPOLKdfHpuNw3M61r95svbeJGk7aAEgYn4WlSjXURmF8IDqZBy0CT2VxQc" 0 1] + ["tryFJbWcFMiYPg8sASm51uIV93GXTnvRzyfLleh06CpodJD42B7OraKtkQNxUZ" 0 2] + ["eg6ql0A3XmvPoCzMlB6DraNGcWSIy5VR8iYup2Qk4tjZFKe1hbwfgHdUTsnLqE" 0 3] + ["rSCFlp0rB2inEljaRdxKt7FkIbODSf8wYgTsZM1HL9JzN35cyoqueUvVWCm4hX" 0 4] + ["sR8xjC8WQkOwo74PnglH1YFdTI0eaf56RGVSitzbjuZ3shNUXBrqLxEJyAmKv2" 0 5] + ["uY2MYFqCLpgx5XQcjdtZK286AwWV7IBGEfuS9yTmbJvkzoUPeYRHr4iDs3naN0" 0 6] + ["74dID7X28VLQhBlnGmjZrec5wTA1fqpWtK4YkaoEIM9SRNiC3gUJH0OFvsPDdy" 0 7] + ["30WXpesPhgKiEI5RHTY7xbB1GnytJvXOl2p0AcUjdF6waZDo9Qk8VLzMuWrqCS" 0 8] + ["moxr3HqLAK0GsTND6jowfZz3SUx7cQ8aC54Pl1RbIvFXmEJuBMYVeW9yrdOtin" 0 9]]] + (t/is (= id (sut/encode padded-instance numbers))) + (t/is (= numbers (sut/decode padded-instance id))))) + +(t/deftest min-lengths-test + (doseq [target-min-length [0 1 5 10 default-alphabet-length]] + (let [sqids-config (sut/sqids {:min-length target-min-length})] + (doseq [numbers [[0] + [0 0 0 0 0] + [1 2 3 4 5 6 7 8 9 10] + [100 200 300] + [1000 2000 3000] + [1000000] + [(long #?(:clj Long/MAX_VALUE + :cljs js/Number.MAX_SAFE_INTEGER))]]] + (let [id (sut/encode sqids-config numbers)] + (t/is (<= target-min-length (count id))) + (t/is (= numbers (sut/decode sqids-config id)))))))) + +(t/deftest invalid-min-length-test + (doseq [value [nil -1 256 1.5 "10" ##Inf ##NaN]] + (t/is (thrown? #?(:clj clojure.lang.ExceptionInfo :cljs cljs.core/ExceptionInfo) + (sut/sqids {:min-length value})) + (pr-str value)))) + +(t/deftest maximum-min-length-test + (let [config (sut/sqids {:alphabet "abc" :min-length 255 :block-list #{}}) + id (sut/encode config [1 2 3])] + (t/is (= 255 (count id))) + (t/is (= [1 2 3] (sut/decode config id))) + (t/is (= "" (sut/encode config []))))) + +#?(:clj + (t/deftest integral-bigint-min-length-test + (t/is (= "86Rf07xd4z" (sut/encode (sut/sqids {:min-length 10N}) [1 2 3]))))) + +(t/deftest default-block-list-test + (let [sqids (sut/sqids) + numbers [4572721]] + (t/is (= numbers (sut/decode sqids "aho1e"))) + (t/is (= "JExTR" (sut/encode sqids numbers))))) + +(t/deftest empty-block-list-test + (let [sqids (sut/sqids {:block-list #{}}) + numbers [4572721]] + (t/is (= numbers (sut/decode sqids "aho1e"))) + (t/is (= "aho1e" (sut/encode sqids numbers))))) + +(t/deftest non-empty-block-list-test + (let [sqids (sut/sqids {:block-list #{"ArUO"}})] + (let [numbers [4572721]] + (t/is (= numbers (sut/decode sqids "aho1e"))) + (t/is (= "aho1e" (sut/encode sqids numbers)))) + (let [numbers [100000]] + (t/is (= numbers (sut/decode sqids "ArUO"))) + (t/is (= "QyG4" (sut/encode sqids numbers))) + (t/is (= numbers (sut/decode sqids "QyG4")))))) + +(t/deftest encode-block-list-test + (let [sqids (sut/sqids {:block-list #{"JSwXFaosAN" ; normal result of 1st encoding, block explicitly + "OCjV9JK64o" ; result of 2nd encoding + "rBHf" ; result of 3rd encoding is `4rBHfOiqd3`, block substring + "79SM" ; result of 4th encoding is `dyhgw479SM`, block postfix + "7tE6" ; result of 4th encoding is `7tE6jdAHLe`, block prefix + }}) + numbers [1000000 2000000]] + (t/is (= "1aYeB7bRUt" (sut/encode sqids numbers))) + (t/is (= numbers (sut/decode sqids "1aYeB7bRUt"))))) + +(t/deftest decode-block-list-test + (let [sqids (sut/sqids {:block-list #{"86Rf07" "se8ojk" "ARsz1p" "Q8AI49" "5sQRZO"}}) + numbers [1 2 3]] + (t/is (= numbers (sut/decode sqids "86Rf07"))) + (t/is (= numbers (sut/decode sqids "se8ojk"))) + (t/is (= numbers (sut/decode sqids "ARsz1p"))) + (t/is (= numbers (sut/decode sqids "Q8AI49"))) + (t/is (= numbers (sut/decode sqids "5sQRZO"))))) + +(t/deftest short-block-list-test + (let [sqids (sut/sqids {:block-list #{"pnd"}}) + numbers [1000]] + (t/is (= numbers (->> numbers + (sut/encode sqids) + (sut/decode sqids)))))) + +(t/deftest lowercase-block-list-test + (let [sqids (sut/sqids {:alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + :block-list #{"sxnzkl"}}) + numbers [1 2 3]] + (t/is (= "IBSHOZ" (sut/encode sqids numbers))) + (t/is (= numbers (sut/decode sqids "IBSHOZ"))))) + +(t/deftest irrelevant-block-list-words-test + (let [options {:alphabet "abc123" :block-list #{"AB1" "xy" "ab!" "B2C" "12a"}} + config (sut/sqids options) + normalized (sut/sqids (assoc options :block-list #{"ab1" "b2c" "12a"}))] + (t/is (= #{"AB1" "xy" "ab!" "B2C" "12a"} (:block-list options))) + (doseq [numbers [[0] [1 2 3] [1000 2000]]] + (t/is (= (sut/encode normalized numbers) (sut/encode config numbers)))))) + +(t/deftest max-block-list-test + (let [sqids (sut/sqids {:alphabet "abc" + :min-length 3 + :block-list #{"cab" "abc" "bca"}})] + #?(:clj + (t/is (thrown-with-msg? clojure.lang.ExceptionInfo + #"Reached max attempts to re-generate the ID" + (sut/encode sqids [0]))) + :cljs + (t/is (thrown-with-msg? js/Error + #"Reached max attempts to re-generate the ID" + (sut/encode sqids [0])))))) + +(t/deftest specific-is-blocked-id-scenarios-test + ;; id or word <= 3 chars should match exactly + (let [sqids (sut/sqids {:block-list #{"hey"}})] + (t/is (= "86u" (sut/encode sqids [100])))) + + ;; id or word <= 3 chars should match exactly (blocked) + (let [sqids (sut/sqids {:block-list #{"86u"}})] + (t/is (= "sec" (sut/encode sqids [100])))) + + ;; short block-list words should not match inside longer ids + (let [sqids (sut/sqids {:block-list #{"vFo"}})] + (t/is (= "gMvFo" (sut/encode sqids [1000000])))) + + ;; word with digits should match prefix + (let [sqids (sut/sqids {:block-list #{"lP3i"}})] + (t/is (= "oDqljxrokxRt" (sut/encode sqids [100 202 303 404])))) + + ;; word with digits should match suffix + (let [sqids (sut/sqids {:block-list #{"1HkYs"}})] + (t/is (= "oDqljxrokxRt" (sut/encode sqids [100 202 303 404])))) + + ;; word with digits should not match in the middle + (let [sqids (sut/sqids {:block-list #{"0hfxX"}})] + (t/is (= "862REt0hfxXVdsLG8vGWD" (sut/encode sqids [101 202 303 404 505 606 707])))) + + ;; word without digits should match in the middle + (let [sqids (sut/sqids {:block-list #{"hfxX"}})] + (t/is (= "seu8n1jO9C4KQQDxdOxsK" (sut/encode sqids [101 202 303 404 505 606 707]))))) + +#?(:clj + (t/deftest read-default-blocklist-missing-resource-test + (with-redefs [clojure.java.io/resource (constantly nil)] + (t/is (thrown-with-msg? clojure.lang.ExceptionInfo #"blocklist" + (#'sut/read-default-blocklist nil nil)))))) + +#?(:clj + (t/deftest block-list-matching-is-locale-independent-test + (let [original-locale (Locale/getDefault)] + (try + (Locale/setDefault (Locale/forLanguageTag "tr-TR")) + (let [config (sut/sqids {:block-list #{"LP3I"}})] + (t/is (= "oDqljxrokxRt" (sut/encode config [100 202 303 404])))) + (finally + (Locale/setDefault original-locale)))))) + +(def ^:private number-gen + "Random ordinary integers mixed with arithmetic boundary values." + (gen/frequency + [[4 (gen/choose 0 1000000000)] + [1 (gen/elements #?(:clj [0 1 9007199254740991N 9223372036854775807N + 9223372036854775808N 340282366920938463463374607431768211455N] + :cljs [0 1 9007199254740990 9007199254740991]))]])) + +(def ^:private options-gen + "Varied alphabet order, alphabet length and minimum length, without blocking." + (gen/let [characters (gen/shuffle (vec (:alphabet sut/default-options))) + length (gen/choose 3 (count characters)) + min-length (gen/choose 0 255)] + {:alphabet (apply str (take length characters)) + :min-length min-length + :block-list #{}})) + +(t/deftest generated-roundtrips-test + (let [result + (check/quick-check + 400 + (prop/for-all [options options-gen + numbers (gen/vector number-gen 0 12)] + (let [config (sut/sqids options) + id (sut/encode config numbers) + decoded (sut/decode config id)] + (and (vector? decoded) + (= numbers decoded) + (= id (sut/encode config numbers)) + (every? (set (:alphabet options)) id) + (if (empty? numbers) + (= "" id) + (<= (:min-length options) (count id)))))) + :seed 42000)] + (t/is (:pass? result) (pr-str result)))) + +(t/deftest generated-blocklist-retries-test + (let [config (sut/sqids {:block-list #{}}) + result + (check/quick-check + 100 + (prop/for-all [number (gen/choose 10000 1000000000)] + (let [id (sut/encode config [number]) + blocked-config (sut/sqids {:block-list #{(str/upper-case id)}}) + retry-id (sut/encode blocked-config [number])] + (and (not= (str/lower-case id) (str/lower-case retry-id)) + (= [number] (sut/decode blocked-config retry-id)) + (= [number] (sut/decode blocked-config id))))) + :seed 42001)] + (t/is (:pass? result) (pr-str result)))) diff --git a/tests.edn b/tests.edn new file mode 100644 index 0000000..866c5b0 --- /dev/null +++ b/tests.edn @@ -0,0 +1,35 @@ +#kaocha/v1 +{:plugins + [:kaocha.plugin/cloverage + :kaocha.plugin/junit-xml] + + :reporter + [kaocha.report/documentation] + + :tests + [{:id :unit + :source-paths ["src"] + :test-paths ["test"] + :ns-patterns [".*-test$"]} + + {:id :cljs + :type :kaocha.type/cljs + :source-paths ["src"] + :test-paths ["test"] + :ns-patterns [".*-test$"] + :cljs/repl-env cljs.repl.node/repl-env + :cljs/compiler-options {:output-dir "target/cljs-test"} + :cljs/timeout 30000}] + + ;; Default cloverage output for `bin/kaocha`. + :cloverage/opts + {:output "target/coverage" + :fail-threshold 90 + :codecov? true + :lcov? true + :summary? true + :html? true + :text? false} + + :kaocha.plugin.junit-xml/target-file + "target/test-results/junit.xml"}